repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
looly/hutool | hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java | MapUtil.getDate | public static Date getDate(Map<?, ?> map, Object key) {
"""
获取Map指定key的值,并转换为{@link Date}
@param map Map
@param key 键
@return 值
@since 4.1.2
"""
return get(map, key, Date.class);
} | java | public static Date getDate(Map<?, ?> map, Object key) {
return get(map, key, Date.class);
} | [
"public",
"static",
"Date",
"getDate",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"map",
",",
"Object",
"key",
")",
"{",
"return",
"get",
"(",
"map",
",",
"key",
",",
"Date",
".",
"class",
")",
";",
"}"
] | 获取Map指定key的值,并转换为{@link Date}
@param map Map
@param key 键
@return 值
@since 4.1.2 | [
"获取Map指定key的值,并转换为",
"{",
"@link",
"Date",
"}"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java#L852-L854 |
google/j2objc | translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java | ClassFile.getFieldNode | public FieldDeclaration getFieldNode(String name, String signature) {
"""
Returns the Procyon field definition for a specified variable,
or null if not found.
"""
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.FIELD) {
FieldDeclaration field = (FieldDeclaration) node;
if (field.getName().equals(name)
&& signature(field.getReturnType()).equals(signature)) {
return field;
}
}
}
return null;
} | java | public FieldDeclaration getFieldNode(String name, String signature) {
for (EntityDeclaration node : type.getMembers()) {
if (node.getEntityType() == EntityType.FIELD) {
FieldDeclaration field = (FieldDeclaration) node;
if (field.getName().equals(name)
&& signature(field.getReturnType()).equals(signature)) {
return field;
}
}
}
return null;
} | [
"public",
"FieldDeclaration",
"getFieldNode",
"(",
"String",
"name",
",",
"String",
"signature",
")",
"{",
"for",
"(",
"EntityDeclaration",
"node",
":",
"type",
".",
"getMembers",
"(",
")",
")",
"{",
"if",
"(",
"node",
".",
"getEntityType",
"(",
")",
"==",
"EntityType",
".",
"FIELD",
")",
"{",
"FieldDeclaration",
"field",
"=",
"(",
"FieldDeclaration",
")",
"node",
";",
"if",
"(",
"field",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
"&&",
"signature",
"(",
"field",
".",
"getReturnType",
"(",
")",
")",
".",
"equals",
"(",
"signature",
")",
")",
"{",
"return",
"field",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the Procyon field definition for a specified variable,
or null if not found. | [
"Returns",
"the",
"Procyon",
"field",
"definition",
"for",
"a",
"specified",
"variable",
"or",
"null",
"if",
"not",
"found",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/translator/src/main/java/com/google/devtools/j2objc/util/ClassFile.java#L143-L154 |
julienledem/brennus | brennus-builder/src/main/java/brennus/ClassBuilder.java | ClassBuilder.startMethod | public MethodDeclarationBuilder startMethod(Protection protection, Type returnType, String methodName) {
"""
.startMethod(protection, return, name){statements}.endMethod()
@param protection public/package/protected/private
@param returnType
@param methodName
@return a MethodDeclarationBuilder
"""
return startMethod(protection, returnType, methodName, false);
} | java | public MethodDeclarationBuilder startMethod(Protection protection, Type returnType, String methodName) {
return startMethod(protection, returnType, methodName, false);
} | [
"public",
"MethodDeclarationBuilder",
"startMethod",
"(",
"Protection",
"protection",
",",
"Type",
"returnType",
",",
"String",
"methodName",
")",
"{",
"return",
"startMethod",
"(",
"protection",
",",
"returnType",
",",
"methodName",
",",
"false",
")",
";",
"}"
] | .startMethod(protection, return, name){statements}.endMethod()
@param protection public/package/protected/private
@param returnType
@param methodName
@return a MethodDeclarationBuilder | [
".",
"startMethod",
"(",
"protection",
"return",
"name",
")",
"{",
"statements",
"}",
".",
"endMethod",
"()"
] | train | https://github.com/julienledem/brennus/blob/0798fb565d95af19ddc5accd084e58c4e882dbd0/brennus-builder/src/main/java/brennus/ClassBuilder.java#L116-L118 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ReUtil.java | ReUtil.replaceAll | public static String replaceAll(CharSequence content, String regex, String replacementTemplate) {
"""
正则替换指定值<br>
通过正则查找到字符串,然后把匹配到的字符串加入到replacementTemplate中,$1表示分组1的字符串
@param content 文本
@param regex 正则
@param replacementTemplate 替换的文本模板,可以使用$1类似的变量提取正则匹配出的内容
@return 处理后的文本
"""
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
return replaceAll(content, pattern, replacementTemplate);
} | java | public static String replaceAll(CharSequence content, String regex, String replacementTemplate) {
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
return replaceAll(content, pattern, replacementTemplate);
} | [
"public",
"static",
"String",
"replaceAll",
"(",
"CharSequence",
"content",
",",
"String",
"regex",
",",
"String",
"replacementTemplate",
")",
"{",
"final",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"regex",
",",
"Pattern",
".",
"DOTALL",
")",
";",
"return",
"replaceAll",
"(",
"content",
",",
"pattern",
",",
"replacementTemplate",
")",
";",
"}"
] | 正则替换指定值<br>
通过正则查找到字符串,然后把匹配到的字符串加入到replacementTemplate中,$1表示分组1的字符串
@param content 文本
@param regex 正则
@param replacementTemplate 替换的文本模板,可以使用$1类似的变量提取正则匹配出的内容
@return 处理后的文本 | [
"正则替换指定值<br",
">",
"通过正则查找到字符串,然后把匹配到的字符串加入到replacementTemplate中,$1表示分组1的字符串"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReUtil.java#L600-L603 |
datumbox/datumbox-framework | datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/distributions/DiscreteDistributions.java | DiscreteDistributions.bernoulliCdf | public static double bernoulliCdf(int k, double p) {
"""
Returns the cumulative probability under bernoulli
@param k
@param p
@return
"""
if(p<0) {
throw new IllegalArgumentException("The probability p can't be negative.");
}
double probabilitySum=0.0;
if(k<0) {
}
else if(k<1) { //aka k==0
probabilitySum=(1-p);
}
else { //k>=1 aka k==1
probabilitySum=1.0;
}
return probabilitySum;
} | java | public static double bernoulliCdf(int k, double p) {
if(p<0) {
throw new IllegalArgumentException("The probability p can't be negative.");
}
double probabilitySum=0.0;
if(k<0) {
}
else if(k<1) { //aka k==0
probabilitySum=(1-p);
}
else { //k>=1 aka k==1
probabilitySum=1.0;
}
return probabilitySum;
} | [
"public",
"static",
"double",
"bernoulliCdf",
"(",
"int",
"k",
",",
"double",
"p",
")",
"{",
"if",
"(",
"p",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The probability p can't be negative.\"",
")",
";",
"}",
"double",
"probabilitySum",
"=",
"0.0",
";",
"if",
"(",
"k",
"<",
"0",
")",
"{",
"}",
"else",
"if",
"(",
"k",
"<",
"1",
")",
"{",
"//aka k==0",
"probabilitySum",
"=",
"(",
"1",
"-",
"p",
")",
";",
"}",
"else",
"{",
"//k>=1 aka k==1",
"probabilitySum",
"=",
"1.0",
";",
"}",
"return",
"probabilitySum",
";",
"}"
] | Returns the cumulative probability under bernoulli
@param k
@param p
@return | [
"Returns",
"the",
"cumulative",
"probability",
"under",
"bernoulli"
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/distributions/DiscreteDistributions.java#L49-L66 |
alkacon/opencms-core | src/org/opencms/util/CmsHtmlExtractor.java | CmsHtmlExtractor.extractText | public static String extractText(String content, String encoding)
throws ParserException, UnsupportedEncodingException {
"""
Extract the text from a HTML page.<p>
@param content the html content
@param encoding the encoding of the content
@return the extracted text from the page
@throws ParserException if the parsing of the HTML failed
@throws UnsupportedEncodingException if the given encoding is not supported
"""
if (CmsStringUtil.isEmpty(content)) {
// if there is no HTML, then we don't need to extract anything
return content;
}
// we must make sure that the content passed to the parser always is
// a "valid" HTML page, i.e. is surrounded by <html><body>...</body></html>
// otherwise you will get strange results for some specific HTML constructs
StringBuffer newContent = new StringBuffer(content.length() + 32);
newContent.append(CmsLinkProcessor.HTML_START);
newContent.append(content);
newContent.append(CmsLinkProcessor.HTML_END);
// make sure the Lexer uses the right encoding
InputStream in = new ByteArrayInputStream(newContent.toString().getBytes(encoding));
// use the stream based version to process the results
return extractText(in, encoding);
} | java | public static String extractText(String content, String encoding)
throws ParserException, UnsupportedEncodingException {
if (CmsStringUtil.isEmpty(content)) {
// if there is no HTML, then we don't need to extract anything
return content;
}
// we must make sure that the content passed to the parser always is
// a "valid" HTML page, i.e. is surrounded by <html><body>...</body></html>
// otherwise you will get strange results for some specific HTML constructs
StringBuffer newContent = new StringBuffer(content.length() + 32);
newContent.append(CmsLinkProcessor.HTML_START);
newContent.append(content);
newContent.append(CmsLinkProcessor.HTML_END);
// make sure the Lexer uses the right encoding
InputStream in = new ByteArrayInputStream(newContent.toString().getBytes(encoding));
// use the stream based version to process the results
return extractText(in, encoding);
} | [
"public",
"static",
"String",
"extractText",
"(",
"String",
"content",
",",
"String",
"encoding",
")",
"throws",
"ParserException",
",",
"UnsupportedEncodingException",
"{",
"if",
"(",
"CmsStringUtil",
".",
"isEmpty",
"(",
"content",
")",
")",
"{",
"// if there is no HTML, then we don't need to extract anything",
"return",
"content",
";",
"}",
"// we must make sure that the content passed to the parser always is",
"// a \"valid\" HTML page, i.e. is surrounded by <html><body>...</body></html>",
"// otherwise you will get strange results for some specific HTML constructs",
"StringBuffer",
"newContent",
"=",
"new",
"StringBuffer",
"(",
"content",
".",
"length",
"(",
")",
"+",
"32",
")",
";",
"newContent",
".",
"append",
"(",
"CmsLinkProcessor",
".",
"HTML_START",
")",
";",
"newContent",
".",
"append",
"(",
"content",
")",
";",
"newContent",
".",
"append",
"(",
"CmsLinkProcessor",
".",
"HTML_END",
")",
";",
"// make sure the Lexer uses the right encoding",
"InputStream",
"in",
"=",
"new",
"ByteArrayInputStream",
"(",
"newContent",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"encoding",
")",
")",
";",
"// use the stream based version to process the results",
"return",
"extractText",
"(",
"in",
",",
"encoding",
")",
";",
"}"
] | Extract the text from a HTML page.<p>
@param content the html content
@param encoding the encoding of the content
@return the extracted text from the page
@throws ParserException if the parsing of the HTML failed
@throws UnsupportedEncodingException if the given encoding is not supported | [
"Extract",
"the",
"text",
"from",
"a",
"HTML",
"page",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsHtmlExtractor.java#L93-L115 |
samskivert/samskivert | src/main/java/com/samskivert/servlet/MessageManager.java | MessageManager.getMessage | public String getMessage (HttpServletRequest req, String path, Object[] args) {
"""
Looks up the message with the specified path in the resource bundle most appropriate for the
locales described as preferred by the request, then substitutes the supplied arguments into
that message using a <code>MessageFormat</code> object.
@see java.text.MessageFormat
"""
String msg = getMessage(req, path, true);
// we may cache message formatters later, but for now just use the static convenience
// function
return MessageFormat.format(MessageUtil.escape(msg), args);
} | java | public String getMessage (HttpServletRequest req, String path, Object[] args)
{
String msg = getMessage(req, path, true);
// we may cache message formatters later, but for now just use the static convenience
// function
return MessageFormat.format(MessageUtil.escape(msg), args);
} | [
"public",
"String",
"getMessage",
"(",
"HttpServletRequest",
"req",
",",
"String",
"path",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"String",
"msg",
"=",
"getMessage",
"(",
"req",
",",
"path",
",",
"true",
")",
";",
"// we may cache message formatters later, but for now just use the static convenience",
"// function",
"return",
"MessageFormat",
".",
"format",
"(",
"MessageUtil",
".",
"escape",
"(",
"msg",
")",
",",
"args",
")",
";",
"}"
] | Looks up the message with the specified path in the resource bundle most appropriate for the
locales described as preferred by the request, then substitutes the supplied arguments into
that message using a <code>MessageFormat</code> object.
@see java.text.MessageFormat | [
"Looks",
"up",
"the",
"message",
"with",
"the",
"specified",
"path",
"in",
"the",
"resource",
"bundle",
"most",
"appropriate",
"for",
"the",
"locales",
"described",
"as",
"preferred",
"by",
"the",
"request",
"then",
"substitutes",
"the",
"supplied",
"arguments",
"into",
"that",
"message",
"using",
"a",
"<code",
">",
"MessageFormat<",
"/",
"code",
">",
"object",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/MessageManager.java#L84-L90 |
synchronoss/cpo-api | cpo-cassandra/src/main/java/org/synchronoss/cpo/cassandra/CassandraCpoAdapter.java | CassandraCpoAdapter.insertObjects | @Override
public <T> long insertObjects(Collection<T> coll) throws CpoException {
"""
Iterates through a collection of Objects, creates and stores them in the datasource. The assumption is that the
objects contained in the collection do not exist in the datasource.
<p/>
This method creates and stores the objects in the datasource. The objects in the collection will be treated as one
transaction, assuming the datasource supports transactions.
<p/>
This means that if one of the objects fail being created in the datasource then the CpoAdapter will stop processing
the remainder of the collection and rollback all the objects created thus far. Rollback is on the underlying
datasource's support of rollback.
<p/>
<pre>Example:
<code>
<p/>
class SomeObject so = null;
class CpoAdapter cpo = null;
<p/>
try {
cpo = new CpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
} catch (CpoException ce) {
// Handle the error
cpo = null;
}
<p/>
if (cpo!=null) {
ArrayList al = new ArrayList();
for (int i=0; i<3; i++){
so = new SomeObject();
so.setId(1);
so.setName("SomeName");
al.add(so);
}
try{
cpo.insertObjects(al);
} catch (CpoException ce) {
// Handle the error
}
}
</code>
</pre>
@param coll This is a collection of objects that have been defined within the metadata of the datasource. If the
class is not defined an exception will be thrown.
@return The number of objects created in the datasource
@throws CpoException Thrown if there are errors accessing the datasource
"""
return processUpdateGroup(coll, CpoAdapter.CREATE_GROUP, null, null, null, null);
} | java | @Override
public <T> long insertObjects(Collection<T> coll) throws CpoException {
return processUpdateGroup(coll, CpoAdapter.CREATE_GROUP, null, null, null, null);
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"long",
"insertObjects",
"(",
"Collection",
"<",
"T",
">",
"coll",
")",
"throws",
"CpoException",
"{",
"return",
"processUpdateGroup",
"(",
"coll",
",",
"CpoAdapter",
".",
"CREATE_GROUP",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}"
] | Iterates through a collection of Objects, creates and stores them in the datasource. The assumption is that the
objects contained in the collection do not exist in the datasource.
<p/>
This method creates and stores the objects in the datasource. The objects in the collection will be treated as one
transaction, assuming the datasource supports transactions.
<p/>
This means that if one of the objects fail being created in the datasource then the CpoAdapter will stop processing
the remainder of the collection and rollback all the objects created thus far. Rollback is on the underlying
datasource's support of rollback.
<p/>
<pre>Example:
<code>
<p/>
class SomeObject so = null;
class CpoAdapter cpo = null;
<p/>
try {
cpo = new CpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
} catch (CpoException ce) {
// Handle the error
cpo = null;
}
<p/>
if (cpo!=null) {
ArrayList al = new ArrayList();
for (int i=0; i<3; i++){
so = new SomeObject();
so.setId(1);
so.setName("SomeName");
al.add(so);
}
try{
cpo.insertObjects(al);
} catch (CpoException ce) {
// Handle the error
}
}
</code>
</pre>
@param coll This is a collection of objects that have been defined within the metadata of the datasource. If the
class is not defined an exception will be thrown.
@return The number of objects created in the datasource
@throws CpoException Thrown if there are errors accessing the datasource | [
"Iterates",
"through",
"a",
"collection",
"of",
"Objects",
"creates",
"and",
"stores",
"them",
"in",
"the",
"datasource",
".",
"The",
"assumption",
"is",
"that",
"the",
"objects",
"contained",
"in",
"the",
"collection",
"do",
"not",
"exist",
"in",
"the",
"datasource",
".",
"<p",
"/",
">",
"This",
"method",
"creates",
"and",
"stores",
"the",
"objects",
"in",
"the",
"datasource",
".",
"The",
"objects",
"in",
"the",
"collection",
"will",
"be",
"treated",
"as",
"one",
"transaction",
"assuming",
"the",
"datasource",
"supports",
"transactions",
".",
"<p",
"/",
">",
"This",
"means",
"that",
"if",
"one",
"of",
"the",
"objects",
"fail",
"being",
"created",
"in",
"the",
"datasource",
"then",
"the",
"CpoAdapter",
"will",
"stop",
"processing",
"the",
"remainder",
"of",
"the",
"collection",
"and",
"rollback",
"all",
"the",
"objects",
"created",
"thus",
"far",
".",
"Rollback",
"is",
"on",
"the",
"underlying",
"datasource",
"s",
"support",
"of",
"rollback",
".",
"<p",
"/",
">",
"<pre",
">",
"Example",
":",
"<code",
">",
"<p",
"/",
">",
"class",
"SomeObject",
"so",
"=",
"null",
";",
"class",
"CpoAdapter",
"cpo",
"=",
"null",
";",
"<p",
"/",
">",
"try",
"{",
"cpo",
"=",
"new",
"CpoAdapter",
"(",
"new",
"JdbcDataSourceInfo",
"(",
"driver",
"url",
"user",
"password",
"1",
"1",
"false",
"))",
";",
"}",
"catch",
"(",
"CpoException",
"ce",
")",
"{",
"//",
"Handle",
"the",
"error",
"cpo",
"=",
"null",
";",
"}",
"<p",
"/",
">",
"if",
"(",
"cpo!",
"=",
"null",
")",
"{",
"ArrayList",
"al",
"=",
"new",
"ArrayList",
"()",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i<3",
";",
"i",
"++",
")",
"{",
"so",
"=",
"new",
"SomeObject",
"()",
";",
"so",
".",
"setId",
"(",
"1",
")",
";",
"so",
".",
"setName",
"(",
"SomeName",
")",
";",
"al",
".",
"add",
"(",
"so",
")",
";",
"}",
"try",
"{",
"cpo",
".",
"insertObjects",
"(",
"al",
")",
";",
"}",
"catch",
"(",
"CpoException",
"ce",
")",
"{",
"//",
"Handle",
"the",
"error",
"}",
"}",
"<",
"/",
"code",
">",
"<",
"/",
"pre",
">"
] | train | https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-cassandra/src/main/java/org/synchronoss/cpo/cassandra/CassandraCpoAdapter.java#L294-L297 |
graknlabs/grakn | server/src/graql/executor/ComputeExecutor.java | ComputeExecutor.initStatisticsMapReduce | private StatisticsMapReduce<?> initStatisticsMapReduce(GraqlCompute.Statistics.Value query,
Set<LabelId> targetTypes,
AttributeType.DataType<?> targetDataType) {
"""
Helper method to initialise the MapReduce algorithm for compute statistics queries
@param targetTypes representing the attribute types in which the statistics computation is targeted for
@param targetDataType representing the data type of the target attribute types
@return an object which is a subclass of StatisticsMapReduce
"""
Graql.Token.Compute.Method method = query.method();
if (method.equals(MIN)) {
return new MinMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
} else if (method.equals(MAX)) {
return new MaxMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
} else if (method.equals(MEAN)) {
return new MeanMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
}else if (method.equals(STD)) {
return new StdMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
} else if (method.equals(SUM)) {
return new SumMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
}
return null;
} | java | private StatisticsMapReduce<?> initStatisticsMapReduce(GraqlCompute.Statistics.Value query,
Set<LabelId> targetTypes,
AttributeType.DataType<?> targetDataType) {
Graql.Token.Compute.Method method = query.method();
if (method.equals(MIN)) {
return new MinMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
} else if (method.equals(MAX)) {
return new MaxMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
} else if (method.equals(MEAN)) {
return new MeanMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
}else if (method.equals(STD)) {
return new StdMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
} else if (method.equals(SUM)) {
return new SumMapReduce(targetTypes, targetDataType, DegreeVertexProgram.DEGREE);
}
return null;
} | [
"private",
"StatisticsMapReduce",
"<",
"?",
">",
"initStatisticsMapReduce",
"(",
"GraqlCompute",
".",
"Statistics",
".",
"Value",
"query",
",",
"Set",
"<",
"LabelId",
">",
"targetTypes",
",",
"AttributeType",
".",
"DataType",
"<",
"?",
">",
"targetDataType",
")",
"{",
"Graql",
".",
"Token",
".",
"Compute",
".",
"Method",
"method",
"=",
"query",
".",
"method",
"(",
")",
";",
"if",
"(",
"method",
".",
"equals",
"(",
"MIN",
")",
")",
"{",
"return",
"new",
"MinMapReduce",
"(",
"targetTypes",
",",
"targetDataType",
",",
"DegreeVertexProgram",
".",
"DEGREE",
")",
";",
"}",
"else",
"if",
"(",
"method",
".",
"equals",
"(",
"MAX",
")",
")",
"{",
"return",
"new",
"MaxMapReduce",
"(",
"targetTypes",
",",
"targetDataType",
",",
"DegreeVertexProgram",
".",
"DEGREE",
")",
";",
"}",
"else",
"if",
"(",
"method",
".",
"equals",
"(",
"MEAN",
")",
")",
"{",
"return",
"new",
"MeanMapReduce",
"(",
"targetTypes",
",",
"targetDataType",
",",
"DegreeVertexProgram",
".",
"DEGREE",
")",
";",
"}",
"else",
"if",
"(",
"method",
".",
"equals",
"(",
"STD",
")",
")",
"{",
"return",
"new",
"StdMapReduce",
"(",
"targetTypes",
",",
"targetDataType",
",",
"DegreeVertexProgram",
".",
"DEGREE",
")",
";",
"}",
"else",
"if",
"(",
"method",
".",
"equals",
"(",
"SUM",
")",
")",
"{",
"return",
"new",
"SumMapReduce",
"(",
"targetTypes",
",",
"targetDataType",
",",
"DegreeVertexProgram",
".",
"DEGREE",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Helper method to initialise the MapReduce algorithm for compute statistics queries
@param targetTypes representing the attribute types in which the statistics computation is targeted for
@param targetDataType representing the data type of the target attribute types
@return an object which is a subclass of StatisticsMapReduce | [
"Helper",
"method",
"to",
"initialise",
"the",
"MapReduce",
"algorithm",
"for",
"compute",
"statistics",
"queries"
] | train | https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/server/src/graql/executor/ComputeExecutor.java#L275-L292 |
UrielCh/ovh-java-sdk | ovh-java-sdk-vps/src/main/java/net/minidev/ovh/api/ApiOvhVps.java | ApiOvhVps.serviceName_option_option_DELETE | public void serviceName_option_option_DELETE(String serviceName, net.minidev.ovh.api.vps.OvhVpsOptionEnum option) throws IOException {
"""
Release a given option
REST: DELETE /vps/{serviceName}/option/{option}
@param serviceName [required] The internal name of your VPS offer
@param option [required] The option name
"""
String qPath = "/vps/{serviceName}/option/{option}";
StringBuilder sb = path(qPath, serviceName, option);
exec(qPath, "DELETE", sb.toString(), null);
} | java | public void serviceName_option_option_DELETE(String serviceName, net.minidev.ovh.api.vps.OvhVpsOptionEnum option) throws IOException {
String qPath = "/vps/{serviceName}/option/{option}";
StringBuilder sb = path(qPath, serviceName, option);
exec(qPath, "DELETE", sb.toString(), null);
} | [
"public",
"void",
"serviceName_option_option_DELETE",
"(",
"String",
"serviceName",
",",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"vps",
".",
"OvhVpsOptionEnum",
"option",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/vps/{serviceName}/option/{option}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"option",
")",
";",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] | Release a given option
REST: DELETE /vps/{serviceName}/option/{option}
@param serviceName [required] The internal name of your VPS offer
@param option [required] The option name | [
"Release",
"a",
"given",
"option"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-vps/src/main/java/net/minidev/ovh/api/ApiOvhVps.java#L1064-L1068 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.project_serviceName_region_regionName_workflow_backup_POST | public OvhBackup project_serviceName_region_regionName_workflow_backup_POST(String serviceName, String regionName, String cron, String instanceId, Long maxExecutionCount, String name, Long rotation) throws IOException {
"""
Create a new automated backup
REST: POST /cloud/project/{serviceName}/region/{regionName}/workflow/backup
@param cron [required] Unix Cron pattern (eg: '* * * * *')
@param instanceId [required] Instance ID to backup
@param maxExecutionCount [required] Number of execution to process before ending the job. Null value means that the job will never end.
@param name [required] Name of your backup job
@param regionName [required] Public Cloud region
@param rotation [required] Number of backup to keep
@param serviceName [required] Public Cloud project
API beta
"""
String qPath = "/cloud/project/{serviceName}/region/{regionName}/workflow/backup";
StringBuilder sb = path(qPath, serviceName, regionName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "cron", cron);
addBody(o, "instanceId", instanceId);
addBody(o, "maxExecutionCount", maxExecutionCount);
addBody(o, "name", name);
addBody(o, "rotation", rotation);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhBackup.class);
} | java | public OvhBackup project_serviceName_region_regionName_workflow_backup_POST(String serviceName, String regionName, String cron, String instanceId, Long maxExecutionCount, String name, Long rotation) throws IOException {
String qPath = "/cloud/project/{serviceName}/region/{regionName}/workflow/backup";
StringBuilder sb = path(qPath, serviceName, regionName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "cron", cron);
addBody(o, "instanceId", instanceId);
addBody(o, "maxExecutionCount", maxExecutionCount);
addBody(o, "name", name);
addBody(o, "rotation", rotation);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhBackup.class);
} | [
"public",
"OvhBackup",
"project_serviceName_region_regionName_workflow_backup_POST",
"(",
"String",
"serviceName",
",",
"String",
"regionName",
",",
"String",
"cron",
",",
"String",
"instanceId",
",",
"Long",
"maxExecutionCount",
",",
"String",
"name",
",",
"Long",
"rotation",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/project/{serviceName}/region/{regionName}/workflow/backup\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"regionName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"cron\"",
",",
"cron",
")",
";",
"addBody",
"(",
"o",
",",
"\"instanceId\"",
",",
"instanceId",
")",
";",
"addBody",
"(",
"o",
",",
"\"maxExecutionCount\"",
",",
"maxExecutionCount",
")",
";",
"addBody",
"(",
"o",
",",
"\"name\"",
",",
"name",
")",
";",
"addBody",
"(",
"o",
",",
"\"rotation\"",
",",
"rotation",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhBackup",
".",
"class",
")",
";",
"}"
] | Create a new automated backup
REST: POST /cloud/project/{serviceName}/region/{regionName}/workflow/backup
@param cron [required] Unix Cron pattern (eg: '* * * * *')
@param instanceId [required] Instance ID to backup
@param maxExecutionCount [required] Number of execution to process before ending the job. Null value means that the job will never end.
@param name [required] Name of your backup job
@param regionName [required] Public Cloud region
@param rotation [required] Number of backup to keep
@param serviceName [required] Public Cloud project
API beta | [
"Create",
"a",
"new",
"automated",
"backup"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L192-L203 |
jenkinsci/jenkins | core/src/main/java/jenkins/model/Jenkins.java | Jenkins.isDisplayNameUnique | boolean isDisplayNameUnique(String displayName, String currentJobName) {
"""
This method checks all existing jobs to see if displayName is
unique. It does not check the displayName against the displayName of the
job that the user is configuring though to prevent a validation warning
if the user sets the displayName to what it currently is.
@param displayName
@param currentJobName
"""
Collection<TopLevelItem> itemCollection = items.values();
// if there are a lot of projects, we'll have to store their
// display names in a HashSet or something for a quick check
for(TopLevelItem item : itemCollection) {
if(item.getName().equals(currentJobName)) {
// we won't compare the candidate displayName against the current
// item. This is to prevent an validation warning if the user
// sets the displayName to what the existing display name is
continue;
}
else if(displayName.equals(item.getDisplayName())) {
return false;
}
}
return true;
} | java | boolean isDisplayNameUnique(String displayName, String currentJobName) {
Collection<TopLevelItem> itemCollection = items.values();
// if there are a lot of projects, we'll have to store their
// display names in a HashSet or something for a quick check
for(TopLevelItem item : itemCollection) {
if(item.getName().equals(currentJobName)) {
// we won't compare the candidate displayName against the current
// item. This is to prevent an validation warning if the user
// sets the displayName to what the existing display name is
continue;
}
else if(displayName.equals(item.getDisplayName())) {
return false;
}
}
return true;
} | [
"boolean",
"isDisplayNameUnique",
"(",
"String",
"displayName",
",",
"String",
"currentJobName",
")",
"{",
"Collection",
"<",
"TopLevelItem",
">",
"itemCollection",
"=",
"items",
".",
"values",
"(",
")",
";",
"// if there are a lot of projects, we'll have to store their",
"// display names in a HashSet or something for a quick check",
"for",
"(",
"TopLevelItem",
"item",
":",
"itemCollection",
")",
"{",
"if",
"(",
"item",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"currentJobName",
")",
")",
"{",
"// we won't compare the candidate displayName against the current",
"// item. This is to prevent an validation warning if the user",
"// sets the displayName to what the existing display name is",
"continue",
";",
"}",
"else",
"if",
"(",
"displayName",
".",
"equals",
"(",
"item",
".",
"getDisplayName",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | This method checks all existing jobs to see if displayName is
unique. It does not check the displayName against the displayName of the
job that the user is configuring though to prevent a validation warning
if the user sets the displayName to what it currently is.
@param displayName
@param currentJobName | [
"This",
"method",
"checks",
"all",
"existing",
"jobs",
"to",
"see",
"if",
"displayName",
"is",
"unique",
".",
"It",
"does",
"not",
"check",
"the",
"displayName",
"against",
"the",
"displayName",
"of",
"the",
"job",
"that",
"the",
"user",
"is",
"configuring",
"though",
"to",
"prevent",
"a",
"validation",
"warning",
"if",
"the",
"user",
"sets",
"the",
"displayName",
"to",
"what",
"it",
"currently",
"is",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/model/Jenkins.java#L4776-L4794 |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java | ModelConstraints.checkCollectionForeignkeys | private void checkCollectionForeignkeys(ModelDef modelDef, String checkLevel) throws ConstraintException {
"""
Checks the foreignkeys of all collections in the model.
@param modelDef The model
@param checkLevel The current check level (this constraint is checked in basic and strict)
@exception ConstraintException If the value for foreignkey is invalid
"""
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
ClassDescriptorDef classDef;
CollectionDescriptorDef collDef;
for (Iterator it = modelDef.getClasses(); it.hasNext();)
{
classDef = (ClassDescriptorDef)it.next();
for (Iterator collIt = classDef.getCollections(); collIt.hasNext();)
{
collDef = (CollectionDescriptorDef)collIt.next();
if (!collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
{
checkIndirectionTable(modelDef, collDef);
}
else
{
checkCollectionForeignkeys(modelDef, collDef);
}
}
}
}
} | java | private void checkCollectionForeignkeys(ModelDef modelDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
ClassDescriptorDef classDef;
CollectionDescriptorDef collDef;
for (Iterator it = modelDef.getClasses(); it.hasNext();)
{
classDef = (ClassDescriptorDef)it.next();
for (Iterator collIt = classDef.getCollections(); collIt.hasNext();)
{
collDef = (CollectionDescriptorDef)collIt.next();
if (!collDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
{
if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
{
checkIndirectionTable(modelDef, collDef);
}
else
{
checkCollectionForeignkeys(modelDef, collDef);
}
}
}
}
} | [
"private",
"void",
"checkCollectionForeignkeys",
"(",
"ModelDef",
"modelDef",
",",
"String",
"checkLevel",
")",
"throws",
"ConstraintException",
"{",
"if",
"(",
"CHECKLEVEL_NONE",
".",
"equals",
"(",
"checkLevel",
")",
")",
"{",
"return",
";",
"}",
"ClassDescriptorDef",
"classDef",
";",
"CollectionDescriptorDef",
"collDef",
";",
"for",
"(",
"Iterator",
"it",
"=",
"modelDef",
".",
"getClasses",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"classDef",
"=",
"(",
"ClassDescriptorDef",
")",
"it",
".",
"next",
"(",
")",
";",
"for",
"(",
"Iterator",
"collIt",
"=",
"classDef",
".",
"getCollections",
"(",
")",
";",
"collIt",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"collDef",
"=",
"(",
"CollectionDescriptorDef",
")",
"collIt",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"collDef",
".",
"getBooleanProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_IGNORE",
",",
"false",
")",
")",
"{",
"if",
"(",
"collDef",
".",
"hasProperty",
"(",
"PropertyHelper",
".",
"OJB_PROPERTY_INDIRECTION_TABLE",
")",
")",
"{",
"checkIndirectionTable",
"(",
"modelDef",
",",
"collDef",
")",
";",
"}",
"else",
"{",
"checkCollectionForeignkeys",
"(",
"modelDef",
",",
"collDef",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Checks the foreignkeys of all collections in the model.
@param modelDef The model
@param checkLevel The current check level (this constraint is checked in basic and strict)
@exception ConstraintException If the value for foreignkey is invalid | [
"Checks",
"the",
"foreignkeys",
"of",
"all",
"collections",
"in",
"the",
"model",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ModelConstraints.java#L368-L397 |
Netflix/astyanax | astyanax-cassandra/src/main/java/com/netflix/astyanax/mapping/Mapping.java | Mapping.initInstance | public T initInstance(T instance, ColumnList<String> columns) {
"""
Populate the given instance with the values from the given column list
@param instance
instance
@param columns
column this
@return instance (as a convenience for chaining)
"""
for (com.netflix.astyanax.model.Column<String> column : columns) {
Field field = fields.get(column.getName());
if (field != null) { // otherwise it may be a column that was
// removed, etc.
Coercions.setFieldFromColumn(instance, field, column);
}
}
return instance;
} | java | public T initInstance(T instance, ColumnList<String> columns) {
for (com.netflix.astyanax.model.Column<String> column : columns) {
Field field = fields.get(column.getName());
if (field != null) { // otherwise it may be a column that was
// removed, etc.
Coercions.setFieldFromColumn(instance, field, column);
}
}
return instance;
} | [
"public",
"T",
"initInstance",
"(",
"T",
"instance",
",",
"ColumnList",
"<",
"String",
">",
"columns",
")",
"{",
"for",
"(",
"com",
".",
"netflix",
".",
"astyanax",
".",
"model",
".",
"Column",
"<",
"String",
">",
"column",
":",
"columns",
")",
"{",
"Field",
"field",
"=",
"fields",
".",
"get",
"(",
"column",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"field",
"!=",
"null",
")",
"{",
"// otherwise it may be a column that was",
"// removed, etc.",
"Coercions",
".",
"setFieldFromColumn",
"(",
"instance",
",",
"field",
",",
"column",
")",
";",
"}",
"}",
"return",
"instance",
";",
"}"
] | Populate the given instance with the values from the given column list
@param instance
instance
@param columns
column this
@return instance (as a convenience for chaining) | [
"Populate",
"the",
"given",
"instance",
"with",
"the",
"values",
"from",
"the",
"given",
"column",
"list"
] | train | https://github.com/Netflix/astyanax/blob/bcc3fd26e2dda05a923751aa32b139f6209fecdf/astyanax-cassandra/src/main/java/com/netflix/astyanax/mapping/Mapping.java#L273-L282 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/fieldaccessor/FieldAccessor.java | FieldAccessor.getValueOfMap | @SuppressWarnings("unchecked")
public Object getValueOfMap(final Object key, final Object targetObj) {
"""
フィールドがマップ形式の場合に、キーを指定して値を取得する。
@param key マップキーの値
@param targetObj オブジェクト(インスタンス)
@return マップの値
@throws IllegalArgumentException {@literal targetObj == null.}
@throws IllegalStateException {@literal フィールドのタイプがMap出ない場合}
"""
ArgUtils.notNull(targetObj, "targetObj");
if(!Map.class.isAssignableFrom(targetType)) {
throw new IllegalStateException("this method cannot call Map. This target type is " + targetType.getName());
}
final Map<Object, Object> map = (Map<Object, Object>) getValue(targetObj);
if(map == null) {
return null;
}
return map.get(key);
} | java | @SuppressWarnings("unchecked")
public Object getValueOfMap(final Object key, final Object targetObj) {
ArgUtils.notNull(targetObj, "targetObj");
if(!Map.class.isAssignableFrom(targetType)) {
throw new IllegalStateException("this method cannot call Map. This target type is " + targetType.getName());
}
final Map<Object, Object> map = (Map<Object, Object>) getValue(targetObj);
if(map == null) {
return null;
}
return map.get(key);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Object",
"getValueOfMap",
"(",
"final",
"Object",
"key",
",",
"final",
"Object",
"targetObj",
")",
"{",
"ArgUtils",
".",
"notNull",
"(",
"targetObj",
",",
"\"targetObj\"",
")",
";",
"if",
"(",
"!",
"Map",
".",
"class",
".",
"isAssignableFrom",
"(",
"targetType",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"this method cannot call Map. This target type is \"",
"+",
"targetType",
".",
"getName",
"(",
")",
")",
";",
"}",
"final",
"Map",
"<",
"Object",
",",
"Object",
">",
"map",
"=",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
")",
"getValue",
"(",
"targetObj",
")",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"map",
".",
"get",
"(",
"key",
")",
";",
"}"
] | フィールドがマップ形式の場合に、キーを指定して値を取得する。
@param key マップキーの値
@param targetObj オブジェクト(インスタンス)
@return マップの値
@throws IllegalArgumentException {@literal targetObj == null.}
@throws IllegalStateException {@literal フィールドのタイプがMap出ない場合} | [
"フィールドがマップ形式の場合に、キーを指定して値を取得する。"
] | train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/fieldaccessor/FieldAccessor.java#L229-L244 |
google/gson | gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java | ISO8601Utils.parseInt | private static int parseInt(String value, int beginIndex, int endIndex) throws NumberFormatException {
"""
Parse an integer located between 2 given offsets in a string
@param value the string to parse
@param beginIndex the start index for the integer in the string
@param endIndex the end index for the integer in the string
@return the int
@throws NumberFormatException if the value is not a number
"""
if (beginIndex < 0 || endIndex > value.length() || beginIndex > endIndex) {
throw new NumberFormatException(value);
}
// use same logic as in Integer.parseInt() but less generic we're not supporting negative values
int i = beginIndex;
int result = 0;
int digit;
if (i < endIndex) {
digit = Character.digit(value.charAt(i++), 10);
if (digit < 0) {
throw new NumberFormatException("Invalid number: " + value.substring(beginIndex, endIndex));
}
result = -digit;
}
while (i < endIndex) {
digit = Character.digit(value.charAt(i++), 10);
if (digit < 0) {
throw new NumberFormatException("Invalid number: " + value.substring(beginIndex, endIndex));
}
result *= 10;
result -= digit;
}
return -result;
} | java | private static int parseInt(String value, int beginIndex, int endIndex) throws NumberFormatException {
if (beginIndex < 0 || endIndex > value.length() || beginIndex > endIndex) {
throw new NumberFormatException(value);
}
// use same logic as in Integer.parseInt() but less generic we're not supporting negative values
int i = beginIndex;
int result = 0;
int digit;
if (i < endIndex) {
digit = Character.digit(value.charAt(i++), 10);
if (digit < 0) {
throw new NumberFormatException("Invalid number: " + value.substring(beginIndex, endIndex));
}
result = -digit;
}
while (i < endIndex) {
digit = Character.digit(value.charAt(i++), 10);
if (digit < 0) {
throw new NumberFormatException("Invalid number: " + value.substring(beginIndex, endIndex));
}
result *= 10;
result -= digit;
}
return -result;
} | [
"private",
"static",
"int",
"parseInt",
"(",
"String",
"value",
",",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"throws",
"NumberFormatException",
"{",
"if",
"(",
"beginIndex",
"<",
"0",
"||",
"endIndex",
">",
"value",
".",
"length",
"(",
")",
"||",
"beginIndex",
">",
"endIndex",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"value",
")",
";",
"}",
"// use same logic as in Integer.parseInt() but less generic we're not supporting negative values",
"int",
"i",
"=",
"beginIndex",
";",
"int",
"result",
"=",
"0",
";",
"int",
"digit",
";",
"if",
"(",
"i",
"<",
"endIndex",
")",
"{",
"digit",
"=",
"Character",
".",
"digit",
"(",
"value",
".",
"charAt",
"(",
"i",
"++",
")",
",",
"10",
")",
";",
"if",
"(",
"digit",
"<",
"0",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"\"Invalid number: \"",
"+",
"value",
".",
"substring",
"(",
"beginIndex",
",",
"endIndex",
")",
")",
";",
"}",
"result",
"=",
"-",
"digit",
";",
"}",
"while",
"(",
"i",
"<",
"endIndex",
")",
"{",
"digit",
"=",
"Character",
".",
"digit",
"(",
"value",
".",
"charAt",
"(",
"i",
"++",
")",
",",
"10",
")",
";",
"if",
"(",
"digit",
"<",
"0",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"\"Invalid number: \"",
"+",
"value",
".",
"substring",
"(",
"beginIndex",
",",
"endIndex",
")",
")",
";",
"}",
"result",
"*=",
"10",
";",
"result",
"-=",
"digit",
";",
"}",
"return",
"-",
"result",
";",
"}"
] | Parse an integer located between 2 given offsets in a string
@param value the string to parse
@param beginIndex the start index for the integer in the string
@param endIndex the end index for the integer in the string
@return the int
@throws NumberFormatException if the value is not a number | [
"Parse",
"an",
"integer",
"located",
"between",
"2",
"given",
"offsets",
"in",
"a",
"string"
] | train | https://github.com/google/gson/blob/63ee47cb642c8018e5cddd639aa2be143220ad4b/gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java#L300-L324 |
OpenLiberty/open-liberty | dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/IndirectJndiLookupObjectFactory.java | IndirectJndiLookupObjectFactory.createDefaultResource | private Object createDefaultResource(String className, ResourceInfo resourceRefInfo) throws Exception {
"""
Try to obtain an object instance by creating a resource using a
ResourceFactory for a default resource.
"""
if (className != null) {
String javaCompDefaultFilter = "(" + com.ibm.ws.resource.ResourceFactory.JAVA_COMP_DEFAULT_NAME + "=*)";
String createsFilter = FilterUtils.createPropertyFilter(ResourceFactory.CREATES_OBJECT_CLASS, className);
String filter = "(&" + javaCompDefaultFilter + createsFilter + ")";
return createResourceWithFilter(filter, resourceRefInfo);
}
return null;
} | java | private Object createDefaultResource(String className, ResourceInfo resourceRefInfo) throws Exception {
if (className != null) {
String javaCompDefaultFilter = "(" + com.ibm.ws.resource.ResourceFactory.JAVA_COMP_DEFAULT_NAME + "=*)";
String createsFilter = FilterUtils.createPropertyFilter(ResourceFactory.CREATES_OBJECT_CLASS, className);
String filter = "(&" + javaCompDefaultFilter + createsFilter + ")";
return createResourceWithFilter(filter, resourceRefInfo);
}
return null;
} | [
"private",
"Object",
"createDefaultResource",
"(",
"String",
"className",
",",
"ResourceInfo",
"resourceRefInfo",
")",
"throws",
"Exception",
"{",
"if",
"(",
"className",
"!=",
"null",
")",
"{",
"String",
"javaCompDefaultFilter",
"=",
"\"(\"",
"+",
"com",
".",
"ibm",
".",
"ws",
".",
"resource",
".",
"ResourceFactory",
".",
"JAVA_COMP_DEFAULT_NAME",
"+",
"\"=*)\"",
";",
"String",
"createsFilter",
"=",
"FilterUtils",
".",
"createPropertyFilter",
"(",
"ResourceFactory",
".",
"CREATES_OBJECT_CLASS",
",",
"className",
")",
";",
"String",
"filter",
"=",
"\"(&\"",
"+",
"javaCompDefaultFilter",
"+",
"createsFilter",
"+",
"\")\"",
";",
"return",
"createResourceWithFilter",
"(",
"filter",
",",
"resourceRefInfo",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Try to obtain an object instance by creating a resource using a
ResourceFactory for a default resource. | [
"Try",
"to",
"obtain",
"an",
"object",
"instance",
"by",
"creating",
"a",
"resource",
"using",
"a",
"ResourceFactory",
"for",
"a",
"default",
"resource",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/IndirectJndiLookupObjectFactory.java#L345-L353 |
svenkubiak/mangooio | mangooio-core/src/main/java/io/mangoo/crypto/Crypto.java | Crypto.getPrivateKeyFromString | public PrivateKey getPrivateKeyFromString(String key) throws MangooEncryptionException {
"""
Generates Private Key from Base64 encoded string
@param key Base64 encoded string which represents the key
@return The PrivateKey
@throws MangooEncryptionException if getting private key from string fails
"""
Objects.requireNonNull(key, Required.KEY.toString());
try {
return KeyFactory.getInstance(ALGORITHM).generatePrivate(new PKCS8EncodedKeySpec(decodeBase64(key)));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new MangooEncryptionException("Failed to get private key from string", e);
}
} | java | public PrivateKey getPrivateKeyFromString(String key) throws MangooEncryptionException {
Objects.requireNonNull(key, Required.KEY.toString());
try {
return KeyFactory.getInstance(ALGORITHM).generatePrivate(new PKCS8EncodedKeySpec(decodeBase64(key)));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new MangooEncryptionException("Failed to get private key from string", e);
}
} | [
"public",
"PrivateKey",
"getPrivateKeyFromString",
"(",
"String",
"key",
")",
"throws",
"MangooEncryptionException",
"{",
"Objects",
".",
"requireNonNull",
"(",
"key",
",",
"Required",
".",
"KEY",
".",
"toString",
"(",
")",
")",
";",
"try",
"{",
"return",
"KeyFactory",
".",
"getInstance",
"(",
"ALGORITHM",
")",
".",
"generatePrivate",
"(",
"new",
"PKCS8EncodedKeySpec",
"(",
"decodeBase64",
"(",
"key",
")",
")",
")",
";",
"}",
"catch",
"(",
"InvalidKeySpecException",
"|",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"MangooEncryptionException",
"(",
"\"Failed to get private key from string\"",
",",
"e",
")",
";",
"}",
"}"
] | Generates Private Key from Base64 encoded string
@param key Base64 encoded string which represents the key
@return The PrivateKey
@throws MangooEncryptionException if getting private key from string fails | [
"Generates",
"Private",
"Key",
"from",
"Base64",
"encoded",
"string"
] | train | https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/crypto/Crypto.java#L293-L301 |
lecousin/java-framework-core | net.lecousin.core/src/main/java/net/lecousin/framework/xml/XMLStreamEvents.java | XMLStreamEvents.removeAttributeWithPrefix | public Attribute removeAttributeWithPrefix(CharSequence prefix, CharSequence name) {
"""
Remove and return the attribute for the given namespace prefix and local name if it exists.
"""
for (Iterator<Attribute> it = event.attributes.iterator(); it.hasNext(); ) {
Attribute attr = it.next();
if (attr.localName.equals(name) && attr.namespacePrefix.equals(prefix)) {
it.remove();
return attr;
}
}
return null;
} | java | public Attribute removeAttributeWithPrefix(CharSequence prefix, CharSequence name) {
for (Iterator<Attribute> it = event.attributes.iterator(); it.hasNext(); ) {
Attribute attr = it.next();
if (attr.localName.equals(name) && attr.namespacePrefix.equals(prefix)) {
it.remove();
return attr;
}
}
return null;
} | [
"public",
"Attribute",
"removeAttributeWithPrefix",
"(",
"CharSequence",
"prefix",
",",
"CharSequence",
"name",
")",
"{",
"for",
"(",
"Iterator",
"<",
"Attribute",
">",
"it",
"=",
"event",
".",
"attributes",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Attribute",
"attr",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"attr",
".",
"localName",
".",
"equals",
"(",
"name",
")",
"&&",
"attr",
".",
"namespacePrefix",
".",
"equals",
"(",
"prefix",
")",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"return",
"attr",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Remove and return the attribute for the given namespace prefix and local name if it exists. | [
"Remove",
"and",
"return",
"the",
"attribute",
"for",
"the",
"given",
"namespace",
"prefix",
"and",
"local",
"name",
"if",
"it",
"exists",
"."
] | train | https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/xml/XMLStreamEvents.java#L233-L242 |
SimonVT/android-menudrawer | menudrawer/src/net/simonvt/menudrawer/DraggableDrawer.java | DraggableDrawer.animateOffsetTo | protected void animateOffsetTo(int position, int velocity, boolean animate) {
"""
Moves the drawer to the position passed.
@param position The position the content is moved to.
@param velocity Optional velocity if called by releasing a drag event.
@param animate Whether the move is animated.
"""
endDrag();
endPeek();
final int startX = (int) mOffsetPixels;
final int dx = position - startX;
if (dx == 0 || !animate) {
setOffsetPixels(position);
setDrawerState(position == 0 ? STATE_CLOSED : STATE_OPEN);
stopLayerTranslation();
return;
}
int duration;
velocity = Math.abs(velocity);
if (velocity > 0) {
duration = 4 * Math.round(1000.f * Math.abs((float) dx / velocity));
} else {
duration = (int) (600.f * Math.abs((float) dx / mMenuSize));
}
duration = Math.min(duration, mMaxAnimationDuration);
animateOffsetTo(position, duration);
} | java | protected void animateOffsetTo(int position, int velocity, boolean animate) {
endDrag();
endPeek();
final int startX = (int) mOffsetPixels;
final int dx = position - startX;
if (dx == 0 || !animate) {
setOffsetPixels(position);
setDrawerState(position == 0 ? STATE_CLOSED : STATE_OPEN);
stopLayerTranslation();
return;
}
int duration;
velocity = Math.abs(velocity);
if (velocity > 0) {
duration = 4 * Math.round(1000.f * Math.abs((float) dx / velocity));
} else {
duration = (int) (600.f * Math.abs((float) dx / mMenuSize));
}
duration = Math.min(duration, mMaxAnimationDuration);
animateOffsetTo(position, duration);
} | [
"protected",
"void",
"animateOffsetTo",
"(",
"int",
"position",
",",
"int",
"velocity",
",",
"boolean",
"animate",
")",
"{",
"endDrag",
"(",
")",
";",
"endPeek",
"(",
")",
";",
"final",
"int",
"startX",
"=",
"(",
"int",
")",
"mOffsetPixels",
";",
"final",
"int",
"dx",
"=",
"position",
"-",
"startX",
";",
"if",
"(",
"dx",
"==",
"0",
"||",
"!",
"animate",
")",
"{",
"setOffsetPixels",
"(",
"position",
")",
";",
"setDrawerState",
"(",
"position",
"==",
"0",
"?",
"STATE_CLOSED",
":",
"STATE_OPEN",
")",
";",
"stopLayerTranslation",
"(",
")",
";",
"return",
";",
"}",
"int",
"duration",
";",
"velocity",
"=",
"Math",
".",
"abs",
"(",
"velocity",
")",
";",
"if",
"(",
"velocity",
">",
"0",
")",
"{",
"duration",
"=",
"4",
"*",
"Math",
".",
"round",
"(",
"1000.f",
"*",
"Math",
".",
"abs",
"(",
"(",
"float",
")",
"dx",
"/",
"velocity",
")",
")",
";",
"}",
"else",
"{",
"duration",
"=",
"(",
"int",
")",
"(",
"600.f",
"*",
"Math",
".",
"abs",
"(",
"(",
"float",
")",
"dx",
"/",
"mMenuSize",
")",
")",
";",
"}",
"duration",
"=",
"Math",
".",
"min",
"(",
"duration",
",",
"mMaxAnimationDuration",
")",
";",
"animateOffsetTo",
"(",
"position",
",",
"duration",
")",
";",
"}"
] | Moves the drawer to the position passed.
@param position The position the content is moved to.
@param velocity Optional velocity if called by releasing a drag event.
@param animate Whether the move is animated. | [
"Moves",
"the",
"drawer",
"to",
"the",
"position",
"passed",
"."
] | train | https://github.com/SimonVT/android-menudrawer/blob/59e8d18e109c77d911b8b63232d66d5f0551cf6a/menudrawer/src/net/simonvt/menudrawer/DraggableDrawer.java#L351-L375 |
querydsl/querydsl | querydsl-sql/src/main/java/com/querydsl/sql/oracle/AbstractOracleQuery.java | AbstractOracleQuery.connectBy | @WithBridgeMethods(value = OracleQuery.class, castRequired = true)
public C connectBy(Predicate cond) {
"""
CONNECT BY specifies the relationship between parent rows and child rows of the hierarchy.
@param cond condition
@return the current object
"""
return addFlag(Position.BEFORE_ORDER, CONNECT_BY, cond);
} | java | @WithBridgeMethods(value = OracleQuery.class, castRequired = true)
public C connectBy(Predicate cond) {
return addFlag(Position.BEFORE_ORDER, CONNECT_BY, cond);
} | [
"@",
"WithBridgeMethods",
"(",
"value",
"=",
"OracleQuery",
".",
"class",
",",
"castRequired",
"=",
"true",
")",
"public",
"C",
"connectBy",
"(",
"Predicate",
"cond",
")",
"{",
"return",
"addFlag",
"(",
"Position",
".",
"BEFORE_ORDER",
",",
"CONNECT_BY",
",",
"cond",
")",
";",
"}"
] | CONNECT BY specifies the relationship between parent rows and child rows of the hierarchy.
@param cond condition
@return the current object | [
"CONNECT",
"BY",
"specifies",
"the",
"relationship",
"between",
"parent",
"rows",
"and",
"child",
"rows",
"of",
"the",
"hierarchy",
"."
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/oracle/AbstractOracleQuery.java#L72-L75 |
alkacon/opencms-core | src/org/opencms/ade/configuration/CmsADEManager.java | CmsADEManager.elementToJson | protected JSONObject elementToJson(CmsContainerElementBean element, Set<String> excludeSettings) {
"""
Converts the given element to JSON.<p>
@param element the element to convert
@param excludeSettings the keys of settings which should not be written to the JSON
@return the JSON representation
"""
JSONObject data = null;
try {
data = new JSONObject();
data.put(FavListProp.ELEMENT.name().toLowerCase(), element.getId().toString());
if (element.getFormatterId() != null) {
data.put(FavListProp.FORMATTER.name().toLowerCase(), element.getFormatterId().toString());
}
JSONObject properties = new JSONObject();
for (Map.Entry<String, String> entry : element.getIndividualSettings().entrySet()) {
String settingKey = entry.getKey();
if (!excludeSettings.contains(settingKey)) {
properties.put(entry.getKey(), entry.getValue());
}
}
data.put(FavListProp.PROPERTIES.name().toLowerCase(), properties);
} catch (JSONException e) {
// should never happen
if (!LOG.isDebugEnabled()) {
LOG.warn(e.getLocalizedMessage());
}
LOG.debug(e.getLocalizedMessage(), e);
return null;
}
return data;
} | java | protected JSONObject elementToJson(CmsContainerElementBean element, Set<String> excludeSettings) {
JSONObject data = null;
try {
data = new JSONObject();
data.put(FavListProp.ELEMENT.name().toLowerCase(), element.getId().toString());
if (element.getFormatterId() != null) {
data.put(FavListProp.FORMATTER.name().toLowerCase(), element.getFormatterId().toString());
}
JSONObject properties = new JSONObject();
for (Map.Entry<String, String> entry : element.getIndividualSettings().entrySet()) {
String settingKey = entry.getKey();
if (!excludeSettings.contains(settingKey)) {
properties.put(entry.getKey(), entry.getValue());
}
}
data.put(FavListProp.PROPERTIES.name().toLowerCase(), properties);
} catch (JSONException e) {
// should never happen
if (!LOG.isDebugEnabled()) {
LOG.warn(e.getLocalizedMessage());
}
LOG.debug(e.getLocalizedMessage(), e);
return null;
}
return data;
} | [
"protected",
"JSONObject",
"elementToJson",
"(",
"CmsContainerElementBean",
"element",
",",
"Set",
"<",
"String",
">",
"excludeSettings",
")",
"{",
"JSONObject",
"data",
"=",
"null",
";",
"try",
"{",
"data",
"=",
"new",
"JSONObject",
"(",
")",
";",
"data",
".",
"put",
"(",
"FavListProp",
".",
"ELEMENT",
".",
"name",
"(",
")",
".",
"toLowerCase",
"(",
")",
",",
"element",
".",
"getId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"element",
".",
"getFormatterId",
"(",
")",
"!=",
"null",
")",
"{",
"data",
".",
"put",
"(",
"FavListProp",
".",
"FORMATTER",
".",
"name",
"(",
")",
".",
"toLowerCase",
"(",
")",
",",
"element",
".",
"getFormatterId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"JSONObject",
"properties",
"=",
"new",
"JSONObject",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"element",
".",
"getIndividualSettings",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"settingKey",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"!",
"excludeSettings",
".",
"contains",
"(",
"settingKey",
")",
")",
"{",
"properties",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"data",
".",
"put",
"(",
"FavListProp",
".",
"PROPERTIES",
".",
"name",
"(",
")",
".",
"toLowerCase",
"(",
")",
",",
"properties",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"// should never happen",
"if",
"(",
"!",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
")",
";",
"}",
"LOG",
".",
"debug",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"return",
"data",
";",
"}"
] | Converts the given element to JSON.<p>
@param element the element to convert
@param excludeSettings the keys of settings which should not be written to the JSON
@return the JSON representation | [
"Converts",
"the",
"given",
"element",
"to",
"JSON",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/CmsADEManager.java#L1344-L1370 |
teatrove/teatrove | tea/src/main/java/org/teatrove/tea/util/StringCompilationProvider.java | StringCompilationProvider.setTemplateSource | public void setTemplateSource(String name, String source) {
"""
Add or overwrite an existing source for the given fully-qualified dot
format of the given template name.
@param name The name of the template
@param source The source code for the template
"""
mTemplateSources.put(name, new TemplateSource(name, source));
} | java | public void setTemplateSource(String name, String source) {
mTemplateSources.put(name, new TemplateSource(name, source));
} | [
"public",
"void",
"setTemplateSource",
"(",
"String",
"name",
",",
"String",
"source",
")",
"{",
"mTemplateSources",
".",
"put",
"(",
"name",
",",
"new",
"TemplateSource",
"(",
"name",
",",
"source",
")",
")",
";",
"}"
] | Add or overwrite an existing source for the given fully-qualified dot
format of the given template name.
@param name The name of the template
@param source The source code for the template | [
"Add",
"or",
"overwrite",
"an",
"existing",
"source",
"for",
"the",
"given",
"fully",
"-",
"qualified",
"dot",
"format",
"of",
"the",
"given",
"template",
"name",
"."
] | train | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/util/StringCompilationProvider.java#L73-L75 |
fuinorg/utils4j | src/main/java/org/fuin/utils4j/Utils4J.java | Utils4J.addToClasspath | public static void addToClasspath(final File file, final ClassLoader classLoader) {
"""
Adds a file to the classpath.
@param file
File to add - Cannot be <code>null</code>.
@param classLoader
Class loader to use - Cannot be <code>null</code>.
"""
checkNotNull("file", file);
try {
addToClasspath(file.toURI().toURL(), classLoader);
} catch (final MalformedURLException e) {
throw new RuntimeException(e);
}
} | java | public static void addToClasspath(final File file, final ClassLoader classLoader) {
checkNotNull("file", file);
try {
addToClasspath(file.toURI().toURL(), classLoader);
} catch (final MalformedURLException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"void",
"addToClasspath",
"(",
"final",
"File",
"file",
",",
"final",
"ClassLoader",
"classLoader",
")",
"{",
"checkNotNull",
"(",
"\"file\"",
",",
"file",
")",
";",
"try",
"{",
"addToClasspath",
"(",
"file",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
",",
"classLoader",
")",
";",
"}",
"catch",
"(",
"final",
"MalformedURLException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Adds a file to the classpath.
@param file
File to add - Cannot be <code>null</code>.
@param classLoader
Class loader to use - Cannot be <code>null</code>. | [
"Adds",
"a",
"file",
"to",
"the",
"classpath",
"."
] | train | https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L227-L234 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java | MultiViewOps.decomposeAbsDualQuadratic | public static boolean decomposeAbsDualQuadratic( DMatrix4x4 Q , DMatrix3x3 w , DMatrix3 p ) {
"""
Decomposes the absolute dual quadratic into the following submatrices: Q=[w -w*p;-p'*w p'*w*p]
@see DecomposeAbsoluteDualQuadratic
@param Q (Input) Absolute quadratic. Typically found in auto calibration. Not modified.
@param w (Output) 3x3 symmetric matrix
@param p (Output) 3x1 vector
@return true if successful or false if it failed
"""
DecomposeAbsoluteDualQuadratic alg = new DecomposeAbsoluteDualQuadratic();
if( !alg.decompose(Q) )
return false;
w.set(alg.getW());
p.set(alg.getP());
return true;
} | java | public static boolean decomposeAbsDualQuadratic( DMatrix4x4 Q , DMatrix3x3 w , DMatrix3 p ) {
DecomposeAbsoluteDualQuadratic alg = new DecomposeAbsoluteDualQuadratic();
if( !alg.decompose(Q) )
return false;
w.set(alg.getW());
p.set(alg.getP());
return true;
} | [
"public",
"static",
"boolean",
"decomposeAbsDualQuadratic",
"(",
"DMatrix4x4",
"Q",
",",
"DMatrix3x3",
"w",
",",
"DMatrix3",
"p",
")",
"{",
"DecomposeAbsoluteDualQuadratic",
"alg",
"=",
"new",
"DecomposeAbsoluteDualQuadratic",
"(",
")",
";",
"if",
"(",
"!",
"alg",
".",
"decompose",
"(",
"Q",
")",
")",
"return",
"false",
";",
"w",
".",
"set",
"(",
"alg",
".",
"getW",
"(",
")",
")",
";",
"p",
".",
"set",
"(",
"alg",
".",
"getP",
"(",
")",
")",
";",
"return",
"true",
";",
"}"
] | Decomposes the absolute dual quadratic into the following submatrices: Q=[w -w*p;-p'*w p'*w*p]
@see DecomposeAbsoluteDualQuadratic
@param Q (Input) Absolute quadratic. Typically found in auto calibration. Not modified.
@param w (Output) 3x3 symmetric matrix
@param p (Output) 3x1 vector
@return true if successful or false if it failed | [
"Decomposes",
"the",
"absolute",
"dual",
"quadratic",
"into",
"the",
"following",
"submatrices",
":",
"Q",
"=",
"[",
"w",
"-",
"w",
"*",
"p",
";",
"-",
"p",
"*",
"w",
"p",
"*",
"w",
"*",
"p",
"]"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L1609-L1616 |
Deep-Symmetry/beat-link | src/main/java/org/deepsymmetry/beatlink/data/MetadataFinder.java | MetadataFinder.getAutoAttachCacheFiles | public List<File> getAutoAttachCacheFiles() {
"""
Get the metadata cache files that are currently configured to be automatically attached when matching media is
mounted in a player on the network.
@return the current auto-attache cache files, sorted by name
"""
ArrayList<File> currentFiles = new ArrayList<File>(autoAttachCacheFiles);
Collections.sort(currentFiles, new Comparator<File>() {
@Override
public int compare(File o1, File o2) {
return o1.getName().compareTo(o2.getName());
}
});
return Collections.unmodifiableList(currentFiles);
} | java | public List<File> getAutoAttachCacheFiles() {
ArrayList<File> currentFiles = new ArrayList<File>(autoAttachCacheFiles);
Collections.sort(currentFiles, new Comparator<File>() {
@Override
public int compare(File o1, File o2) {
return o1.getName().compareTo(o2.getName());
}
});
return Collections.unmodifiableList(currentFiles);
} | [
"public",
"List",
"<",
"File",
">",
"getAutoAttachCacheFiles",
"(",
")",
"{",
"ArrayList",
"<",
"File",
">",
"currentFiles",
"=",
"new",
"ArrayList",
"<",
"File",
">",
"(",
"autoAttachCacheFiles",
")",
";",
"Collections",
".",
"sort",
"(",
"currentFiles",
",",
"new",
"Comparator",
"<",
"File",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"File",
"o1",
",",
"File",
"o2",
")",
"{",
"return",
"o1",
".",
"getName",
"(",
")",
".",
"compareTo",
"(",
"o2",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"currentFiles",
")",
";",
"}"
] | Get the metadata cache files that are currently configured to be automatically attached when matching media is
mounted in a player on the network.
@return the current auto-attache cache files, sorted by name | [
"Get",
"the",
"metadata",
"cache",
"files",
"that",
"are",
"currently",
"configured",
"to",
"be",
"automatically",
"attached",
"when",
"matching",
"media",
"is",
"mounted",
"in",
"a",
"player",
"on",
"the",
"network",
"."
] | train | https://github.com/Deep-Symmetry/beat-link/blob/f958a2a70e8a87a31a75326d7b4db77c2f0b4212/src/main/java/org/deepsymmetry/beatlink/data/MetadataFinder.java#L665-L674 |
RestComm/sipunit | src/main/java/org/cafesip/sipunit/SipSession.java | SipSession.sendReply | public SipTransaction sendReply(RequestEvent request, Response response) {
"""
This method sends a stateful response to a previously received request. Call this method after
calling waitRequest(). The returned SipTransaction object must be used in any subsequent calls
to sendReply() for the same received request, if there are any.
@param request The RequestEvent object that was returned by a previous call to waitRequest().
@param response The response to send, as is.
@return A SipTransaction object that must be passed in to any subsequent call to sendReply()
for the same received request, or null if an error was encountered while sending the
response. The calling program doesn't need to do anything with the returned
SipTransaction other than pass it in to a subsequent call to sendReply() for the same
received request.
"""
initErrorInfo();
if (request == null) {
setReturnCode(INVALID_ARGUMENT);
setErrorMessage("A response cannot be sent because the request event is null.");
return null;
}
// The ServerTransaction needed will be in the
// RequestEvent if the dialog already existed. Otherwise, create it
// here.
Request req = request.getRequest();
if (req == null) {
setReturnCode(INVALID_ARGUMENT);
setErrorMessage("A response cannot be sent because the request is null.");
return null;
}
ServerTransaction trans = request.getServerTransaction();
if (trans == null) {
try {
trans = parent.getSipProvider().getNewServerTransaction(req);
} catch (TransactionAlreadyExistsException ex) {
/*
* TransactionAlreadyExistsException - this can happen if a transaction already exists that
* is already handling this Request. This may happen if the application gets retransmits of
* the same request before the initial transaction is allocated.
*/
setErrorMessage(
"Error: Can't get transaction object. If you've already called sendReply(RequestEvent, ...) with this RequestEvent, use the SipTransaction it returned to call sendReply(SipTransaction, ...) for subsequent replies to that request.");
setReturnCode(INTERNAL_ERROR);
return null;
} catch (Exception ex) {
setException(ex);
setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage());
setReturnCode(EXCEPTION_ENCOUNTERED);
return null;
}
}
// create the SipTransaction, put the ServerTransaction in it
SipTransaction transaction = new SipTransaction();
transaction.setServerTransaction(trans);
return sendReply(transaction, response);
} | java | public SipTransaction sendReply(RequestEvent request, Response response) {
initErrorInfo();
if (request == null) {
setReturnCode(INVALID_ARGUMENT);
setErrorMessage("A response cannot be sent because the request event is null.");
return null;
}
// The ServerTransaction needed will be in the
// RequestEvent if the dialog already existed. Otherwise, create it
// here.
Request req = request.getRequest();
if (req == null) {
setReturnCode(INVALID_ARGUMENT);
setErrorMessage("A response cannot be sent because the request is null.");
return null;
}
ServerTransaction trans = request.getServerTransaction();
if (trans == null) {
try {
trans = parent.getSipProvider().getNewServerTransaction(req);
} catch (TransactionAlreadyExistsException ex) {
/*
* TransactionAlreadyExistsException - this can happen if a transaction already exists that
* is already handling this Request. This may happen if the application gets retransmits of
* the same request before the initial transaction is allocated.
*/
setErrorMessage(
"Error: Can't get transaction object. If you've already called sendReply(RequestEvent, ...) with this RequestEvent, use the SipTransaction it returned to call sendReply(SipTransaction, ...) for subsequent replies to that request.");
setReturnCode(INTERNAL_ERROR);
return null;
} catch (Exception ex) {
setException(ex);
setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage());
setReturnCode(EXCEPTION_ENCOUNTERED);
return null;
}
}
// create the SipTransaction, put the ServerTransaction in it
SipTransaction transaction = new SipTransaction();
transaction.setServerTransaction(trans);
return sendReply(transaction, response);
} | [
"public",
"SipTransaction",
"sendReply",
"(",
"RequestEvent",
"request",
",",
"Response",
"response",
")",
"{",
"initErrorInfo",
"(",
")",
";",
"if",
"(",
"request",
"==",
"null",
")",
"{",
"setReturnCode",
"(",
"INVALID_ARGUMENT",
")",
";",
"setErrorMessage",
"(",
"\"A response cannot be sent because the request event is null.\"",
")",
";",
"return",
"null",
";",
"}",
"// The ServerTransaction needed will be in the",
"// RequestEvent if the dialog already existed. Otherwise, create it",
"// here.",
"Request",
"req",
"=",
"request",
".",
"getRequest",
"(",
")",
";",
"if",
"(",
"req",
"==",
"null",
")",
"{",
"setReturnCode",
"(",
"INVALID_ARGUMENT",
")",
";",
"setErrorMessage",
"(",
"\"A response cannot be sent because the request is null.\"",
")",
";",
"return",
"null",
";",
"}",
"ServerTransaction",
"trans",
"=",
"request",
".",
"getServerTransaction",
"(",
")",
";",
"if",
"(",
"trans",
"==",
"null",
")",
"{",
"try",
"{",
"trans",
"=",
"parent",
".",
"getSipProvider",
"(",
")",
".",
"getNewServerTransaction",
"(",
"req",
")",
";",
"}",
"catch",
"(",
"TransactionAlreadyExistsException",
"ex",
")",
"{",
"/*\n * TransactionAlreadyExistsException - this can happen if a transaction already exists that\n * is already handling this Request. This may happen if the application gets retransmits of\n * the same request before the initial transaction is allocated.\n */",
"setErrorMessage",
"(",
"\"Error: Can't get transaction object. If you've already called sendReply(RequestEvent, ...) with this RequestEvent, use the SipTransaction it returned to call sendReply(SipTransaction, ...) for subsequent replies to that request.\"",
")",
";",
"setReturnCode",
"(",
"INTERNAL_ERROR",
")",
";",
"return",
"null",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"setException",
"(",
"ex",
")",
";",
"setErrorMessage",
"(",
"\"Exception: \"",
"+",
"ex",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"setReturnCode",
"(",
"EXCEPTION_ENCOUNTERED",
")",
";",
"return",
"null",
";",
"}",
"}",
"// create the SipTransaction, put the ServerTransaction in it",
"SipTransaction",
"transaction",
"=",
"new",
"SipTransaction",
"(",
")",
";",
"transaction",
".",
"setServerTransaction",
"(",
"trans",
")",
";",
"return",
"sendReply",
"(",
"transaction",
",",
"response",
")",
";",
"}"
] | This method sends a stateful response to a previously received request. Call this method after
calling waitRequest(). The returned SipTransaction object must be used in any subsequent calls
to sendReply() for the same received request, if there are any.
@param request The RequestEvent object that was returned by a previous call to waitRequest().
@param response The response to send, as is.
@return A SipTransaction object that must be passed in to any subsequent call to sendReply()
for the same received request, or null if an error was encountered while sending the
response. The calling program doesn't need to do anything with the returned
SipTransaction other than pass it in to a subsequent call to sendReply() for the same
received request. | [
"This",
"method",
"sends",
"a",
"stateful",
"response",
"to",
"a",
"previously",
"received",
"request",
".",
"Call",
"this",
"method",
"after",
"calling",
"waitRequest",
"()",
".",
"The",
"returned",
"SipTransaction",
"object",
"must",
"be",
"used",
"in",
"any",
"subsequent",
"calls",
"to",
"sendReply",
"()",
"for",
"the",
"same",
"received",
"request",
"if",
"there",
"are",
"any",
"."
] | train | https://github.com/RestComm/sipunit/blob/18a6be2e29be3fbdc14226e8c41b25e2d57378b1/src/main/java/org/cafesip/sipunit/SipSession.java#L1382-L1430 |
mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java | LatLongUtils.vincentyDistance | public static double vincentyDistance(LatLong latLong1, LatLong latLong2) {
"""
Calculates geodetic distance between two LatLongs using Vincenty inverse formula
for ellipsoids. This is very accurate but consumes more resources and time than the
sphericalDistance method.
<p/>
Adaptation of Chriss Veness' JavaScript Code on
http://www.movable-type.co.uk/scripts/latlong-vincenty.html
<p/>
Paper: Vincenty inverse formula - T Vincenty, "Direct and Inverse Solutions of Geodesics
on the Ellipsoid with application of nested equations", Survey Review, vol XXII no 176,
1975 (http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf)
@param latLong1 first LatLong
@param latLong2 second LatLong
@return distance in meters between points as a double
"""
double f = 1 / LatLongUtils.INVERSE_FLATTENING;
double L = Math.toRadians(latLong2.getLongitude() - latLong1.getLongitude());
double U1 = Math.atan((1 - f) * Math.tan(Math.toRadians(latLong1.getLatitude())));
double U2 = Math.atan((1 - f) * Math.tan(Math.toRadians(latLong2.getLatitude())));
double sinU1 = Math.sin(U1), cosU1 = Math.cos(U1);
double sinU2 = Math.sin(U2), cosU2 = Math.cos(U2);
double lambda = L, lambdaP, iterLimit = 100;
double cosSqAlpha = 0, sinSigma = 0, cosSigma = 0, cos2SigmaM = 0, sigma = 0, sinLambda = 0, sinAlpha = 0, cosLambda = 0;
do {
sinLambda = Math.sin(lambda);
cosLambda = Math.cos(lambda);
sinSigma = Math.sqrt((cosU2 * sinLambda) * (cosU2 * sinLambda)
+ (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda)
* (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
if (sinSigma == 0)
return 0; // co-incident points
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
sigma = Math.atan2(sinSigma, cosSigma);
sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
cosSqAlpha = 1 - sinAlpha * sinAlpha;
if (cosSqAlpha != 0) {
cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
} else {
cos2SigmaM = 0;
}
double C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
lambdaP = lambda;
lambda = L
+ (1 - C)
* f
* sinAlpha
* (sigma + C * sinSigma
* (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
} while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
if (iterLimit == 0)
return 0; // formula failed to converge
double uSq = cosSqAlpha
* (Math.pow(LatLongUtils.EQUATORIAL_RADIUS, 2) - Math.pow(LatLongUtils.POLAR_RADIUS, 2))
/ Math.pow(LatLongUtils.POLAR_RADIUS, 2);
double A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
double B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
double deltaSigma = B
* sinSigma
* (cos2SigmaM + B
/ 4
* (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM
* (-3 + 4 * sinSigma * sinSigma)
* (-3 + 4 * cos2SigmaM * cos2SigmaM)));
double s = LatLongUtils.POLAR_RADIUS * A * (sigma - deltaSigma);
return s;
} | java | public static double vincentyDistance(LatLong latLong1, LatLong latLong2) {
double f = 1 / LatLongUtils.INVERSE_FLATTENING;
double L = Math.toRadians(latLong2.getLongitude() - latLong1.getLongitude());
double U1 = Math.atan((1 - f) * Math.tan(Math.toRadians(latLong1.getLatitude())));
double U2 = Math.atan((1 - f) * Math.tan(Math.toRadians(latLong2.getLatitude())));
double sinU1 = Math.sin(U1), cosU1 = Math.cos(U1);
double sinU2 = Math.sin(U2), cosU2 = Math.cos(U2);
double lambda = L, lambdaP, iterLimit = 100;
double cosSqAlpha = 0, sinSigma = 0, cosSigma = 0, cos2SigmaM = 0, sigma = 0, sinLambda = 0, sinAlpha = 0, cosLambda = 0;
do {
sinLambda = Math.sin(lambda);
cosLambda = Math.cos(lambda);
sinSigma = Math.sqrt((cosU2 * sinLambda) * (cosU2 * sinLambda)
+ (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda)
* (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
if (sinSigma == 0)
return 0; // co-incident points
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
sigma = Math.atan2(sinSigma, cosSigma);
sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
cosSqAlpha = 1 - sinAlpha * sinAlpha;
if (cosSqAlpha != 0) {
cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
} else {
cos2SigmaM = 0;
}
double C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
lambdaP = lambda;
lambda = L
+ (1 - C)
* f
* sinAlpha
* (sigma + C * sinSigma
* (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
} while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
if (iterLimit == 0)
return 0; // formula failed to converge
double uSq = cosSqAlpha
* (Math.pow(LatLongUtils.EQUATORIAL_RADIUS, 2) - Math.pow(LatLongUtils.POLAR_RADIUS, 2))
/ Math.pow(LatLongUtils.POLAR_RADIUS, 2);
double A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
double B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
double deltaSigma = B
* sinSigma
* (cos2SigmaM + B
/ 4
* (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM
* (-3 + 4 * sinSigma * sinSigma)
* (-3 + 4 * cos2SigmaM * cos2SigmaM)));
double s = LatLongUtils.POLAR_RADIUS * A * (sigma - deltaSigma);
return s;
} | [
"public",
"static",
"double",
"vincentyDistance",
"(",
"LatLong",
"latLong1",
",",
"LatLong",
"latLong2",
")",
"{",
"double",
"f",
"=",
"1",
"/",
"LatLongUtils",
".",
"INVERSE_FLATTENING",
";",
"double",
"L",
"=",
"Math",
".",
"toRadians",
"(",
"latLong2",
".",
"getLongitude",
"(",
")",
"-",
"latLong1",
".",
"getLongitude",
"(",
")",
")",
";",
"double",
"U1",
"=",
"Math",
".",
"atan",
"(",
"(",
"1",
"-",
"f",
")",
"*",
"Math",
".",
"tan",
"(",
"Math",
".",
"toRadians",
"(",
"latLong1",
".",
"getLatitude",
"(",
")",
")",
")",
")",
";",
"double",
"U2",
"=",
"Math",
".",
"atan",
"(",
"(",
"1",
"-",
"f",
")",
"*",
"Math",
".",
"tan",
"(",
"Math",
".",
"toRadians",
"(",
"latLong2",
".",
"getLatitude",
"(",
")",
")",
")",
")",
";",
"double",
"sinU1",
"=",
"Math",
".",
"sin",
"(",
"U1",
")",
",",
"cosU1",
"=",
"Math",
".",
"cos",
"(",
"U1",
")",
";",
"double",
"sinU2",
"=",
"Math",
".",
"sin",
"(",
"U2",
")",
",",
"cosU2",
"=",
"Math",
".",
"cos",
"(",
"U2",
")",
";",
"double",
"lambda",
"=",
"L",
",",
"lambdaP",
",",
"iterLimit",
"=",
"100",
";",
"double",
"cosSqAlpha",
"=",
"0",
",",
"sinSigma",
"=",
"0",
",",
"cosSigma",
"=",
"0",
",",
"cos2SigmaM",
"=",
"0",
",",
"sigma",
"=",
"0",
",",
"sinLambda",
"=",
"0",
",",
"sinAlpha",
"=",
"0",
",",
"cosLambda",
"=",
"0",
";",
"do",
"{",
"sinLambda",
"=",
"Math",
".",
"sin",
"(",
"lambda",
")",
";",
"cosLambda",
"=",
"Math",
".",
"cos",
"(",
"lambda",
")",
";",
"sinSigma",
"=",
"Math",
".",
"sqrt",
"(",
"(",
"cosU2",
"*",
"sinLambda",
")",
"*",
"(",
"cosU2",
"*",
"sinLambda",
")",
"+",
"(",
"cosU1",
"*",
"sinU2",
"-",
"sinU1",
"*",
"cosU2",
"*",
"cosLambda",
")",
"*",
"(",
"cosU1",
"*",
"sinU2",
"-",
"sinU1",
"*",
"cosU2",
"*",
"cosLambda",
")",
")",
";",
"if",
"(",
"sinSigma",
"==",
"0",
")",
"return",
"0",
";",
"// co-incident points",
"cosSigma",
"=",
"sinU1",
"*",
"sinU2",
"+",
"cosU1",
"*",
"cosU2",
"*",
"cosLambda",
";",
"sigma",
"=",
"Math",
".",
"atan2",
"(",
"sinSigma",
",",
"cosSigma",
")",
";",
"sinAlpha",
"=",
"cosU1",
"*",
"cosU2",
"*",
"sinLambda",
"/",
"sinSigma",
";",
"cosSqAlpha",
"=",
"1",
"-",
"sinAlpha",
"*",
"sinAlpha",
";",
"if",
"(",
"cosSqAlpha",
"!=",
"0",
")",
"{",
"cos2SigmaM",
"=",
"cosSigma",
"-",
"2",
"*",
"sinU1",
"*",
"sinU2",
"/",
"cosSqAlpha",
";",
"}",
"else",
"{",
"cos2SigmaM",
"=",
"0",
";",
"}",
"double",
"C",
"=",
"f",
"/",
"16",
"*",
"cosSqAlpha",
"*",
"(",
"4",
"+",
"f",
"*",
"(",
"4",
"-",
"3",
"*",
"cosSqAlpha",
")",
")",
";",
"lambdaP",
"=",
"lambda",
";",
"lambda",
"=",
"L",
"+",
"(",
"1",
"-",
"C",
")",
"*",
"f",
"*",
"sinAlpha",
"*",
"(",
"sigma",
"+",
"C",
"*",
"sinSigma",
"*",
"(",
"cos2SigmaM",
"+",
"C",
"*",
"cosSigma",
"*",
"(",
"-",
"1",
"+",
"2",
"*",
"cos2SigmaM",
"*",
"cos2SigmaM",
")",
")",
")",
";",
"}",
"while",
"(",
"Math",
".",
"abs",
"(",
"lambda",
"-",
"lambdaP",
")",
">",
"1e-12",
"&&",
"--",
"iterLimit",
">",
"0",
")",
";",
"if",
"(",
"iterLimit",
"==",
"0",
")",
"return",
"0",
";",
"// formula failed to converge",
"double",
"uSq",
"=",
"cosSqAlpha",
"*",
"(",
"Math",
".",
"pow",
"(",
"LatLongUtils",
".",
"EQUATORIAL_RADIUS",
",",
"2",
")",
"-",
"Math",
".",
"pow",
"(",
"LatLongUtils",
".",
"POLAR_RADIUS",
",",
"2",
")",
")",
"/",
"Math",
".",
"pow",
"(",
"LatLongUtils",
".",
"POLAR_RADIUS",
",",
"2",
")",
";",
"double",
"A",
"=",
"1",
"+",
"uSq",
"/",
"16384",
"*",
"(",
"4096",
"+",
"uSq",
"*",
"(",
"-",
"768",
"+",
"uSq",
"*",
"(",
"320",
"-",
"175",
"*",
"uSq",
")",
")",
")",
";",
"double",
"B",
"=",
"uSq",
"/",
"1024",
"*",
"(",
"256",
"+",
"uSq",
"*",
"(",
"-",
"128",
"+",
"uSq",
"*",
"(",
"74",
"-",
"47",
"*",
"uSq",
")",
")",
")",
";",
"double",
"deltaSigma",
"=",
"B",
"*",
"sinSigma",
"*",
"(",
"cos2SigmaM",
"+",
"B",
"/",
"4",
"*",
"(",
"cosSigma",
"*",
"(",
"-",
"1",
"+",
"2",
"*",
"cos2SigmaM",
"*",
"cos2SigmaM",
")",
"-",
"B",
"/",
"6",
"*",
"cos2SigmaM",
"*",
"(",
"-",
"3",
"+",
"4",
"*",
"sinSigma",
"*",
"sinSigma",
")",
"*",
"(",
"-",
"3",
"+",
"4",
"*",
"cos2SigmaM",
"*",
"cos2SigmaM",
")",
")",
")",
";",
"double",
"s",
"=",
"LatLongUtils",
".",
"POLAR_RADIUS",
"*",
"A",
"*",
"(",
"sigma",
"-",
"deltaSigma",
")",
";",
"return",
"s",
";",
"}"
] | Calculates geodetic distance between two LatLongs using Vincenty inverse formula
for ellipsoids. This is very accurate but consumes more resources and time than the
sphericalDistance method.
<p/>
Adaptation of Chriss Veness' JavaScript Code on
http://www.movable-type.co.uk/scripts/latlong-vincenty.html
<p/>
Paper: Vincenty inverse formula - T Vincenty, "Direct and Inverse Solutions of Geodesics
on the Ellipsoid with application of nested equations", Survey Review, vol XXII no 176,
1975 (http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf)
@param latLong1 first LatLong
@param latLong2 second LatLong
@return distance in meters between points as a double | [
"Calculates",
"geodetic",
"distance",
"between",
"two",
"LatLongs",
"using",
"Vincenty",
"inverse",
"formula",
"for",
"ellipsoids",
".",
"This",
"is",
"very",
"accurate",
"but",
"consumes",
"more",
"resources",
"and",
"time",
"than",
"the",
"sphericalDistance",
"method",
".",
"<p",
"/",
">",
"Adaptation",
"of",
"Chriss",
"Veness",
"JavaScript",
"Code",
"on",
"http",
":",
"//",
"www",
".",
"movable",
"-",
"type",
".",
"co",
".",
"uk",
"/",
"scripts",
"/",
"latlong",
"-",
"vincenty",
".",
"html",
"<p",
"/",
">",
"Paper",
":",
"Vincenty",
"inverse",
"formula",
"-",
"T",
"Vincenty",
"Direct",
"and",
"Inverse",
"Solutions",
"of",
"Geodesics",
"on",
"the",
"Ellipsoid",
"with",
"application",
"of",
"nested",
"equations",
"Survey",
"Review",
"vol",
"XXII",
"no",
"176",
"1975",
"(",
"http",
":",
"//",
"www",
".",
"ngs",
".",
"noaa",
".",
"gov",
"/",
"PUBS_LIB",
"/",
"inverse",
".",
"pdf",
")"
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java#L338-L394 |
gsi-upm/BeastTool | beast-tool/src/main/java/es/upm/dit/gsi/beast/reader/system/CreateSystemCaseManager.java | CreateSystemCaseManager.startSystemCaseManager | public static File startSystemCaseManager(String package_path,
String dest_dir) throws BeastException {
"""
This method creates CaseManager file and writes on it: the package, the
imports, its comments and the class name.
@param package_path
as es.upm.dit...
@param dest_dir
as src/main/java
@return the File with its first part written
@throws BeastException
"""
Logger logger = Logger
.getLogger("CreateSystemCaseManager.startSystemCaseManager");
File folder = SystemReader.createFolder(package_path, dest_dir);
File caseManager = new File(folder, "UserStoriesManager.java");
FileWriter caseManagerWriter;
try {
if (!caseManager.exists()) {
caseManagerWriter = new FileWriter(caseManager);
caseManagerWriter.write("package " + package_path + ";\n");
caseManagerWriter.write("\n");
caseManagerWriter.write("import org.junit.Assert;\n");
caseManagerWriter.write("import org.junit.Test;\n");
caseManagerWriter.write("import org.junit.runner.JUnitCore;\n");
caseManagerWriter.write("import org.junit.runner.Result;\n");
caseManagerWriter.write("\n");
caseManagerWriter.write("/**\n");
caseManagerWriter
.write(" * Main class to launch all tests in a single run\n");
caseManagerWriter.write(" *\n");
caseManagerWriter.write(" * @author es.upm.dit.gsi.beast\n");
caseManagerWriter.write(" */\n");
caseManagerWriter.write("public class UserStoriesManager {\n");
caseManagerWriter.write("\n");
caseManagerWriter.flush();
caseManagerWriter.close();
// logger.info("CaseManager has been created in "+dest_dir+Reader.createFolderPath(package_path));
} else {
List<String> lines = new ArrayList<String>();
// read the file into lines
BufferedReader r = new BufferedReader(new FileReader(
caseManager));
String in;
while ((in = r.readLine()) != null) {
lines.add(in);
}
r.close();
lines.remove(lines.size() - 1);
// write it back
PrintWriter w = new PrintWriter(new FileWriter(caseManager));
for (String line : lines) {
w.println(line);
}
w.close();
}
} catch (IOException e) {
logger.severe("ERROR writing Case Manager file");
throw new BeastException("ERROR writing Case Manager file", e);
}
return caseManager;
} | java | public static File startSystemCaseManager(String package_path,
String dest_dir) throws BeastException {
Logger logger = Logger
.getLogger("CreateSystemCaseManager.startSystemCaseManager");
File folder = SystemReader.createFolder(package_path, dest_dir);
File caseManager = new File(folder, "UserStoriesManager.java");
FileWriter caseManagerWriter;
try {
if (!caseManager.exists()) {
caseManagerWriter = new FileWriter(caseManager);
caseManagerWriter.write("package " + package_path + ";\n");
caseManagerWriter.write("\n");
caseManagerWriter.write("import org.junit.Assert;\n");
caseManagerWriter.write("import org.junit.Test;\n");
caseManagerWriter.write("import org.junit.runner.JUnitCore;\n");
caseManagerWriter.write("import org.junit.runner.Result;\n");
caseManagerWriter.write("\n");
caseManagerWriter.write("/**\n");
caseManagerWriter
.write(" * Main class to launch all tests in a single run\n");
caseManagerWriter.write(" *\n");
caseManagerWriter.write(" * @author es.upm.dit.gsi.beast\n");
caseManagerWriter.write(" */\n");
caseManagerWriter.write("public class UserStoriesManager {\n");
caseManagerWriter.write("\n");
caseManagerWriter.flush();
caseManagerWriter.close();
// logger.info("CaseManager has been created in "+dest_dir+Reader.createFolderPath(package_path));
} else {
List<String> lines = new ArrayList<String>();
// read the file into lines
BufferedReader r = new BufferedReader(new FileReader(
caseManager));
String in;
while ((in = r.readLine()) != null) {
lines.add(in);
}
r.close();
lines.remove(lines.size() - 1);
// write it back
PrintWriter w = new PrintWriter(new FileWriter(caseManager));
for (String line : lines) {
w.println(line);
}
w.close();
}
} catch (IOException e) {
logger.severe("ERROR writing Case Manager file");
throw new BeastException("ERROR writing Case Manager file", e);
}
return caseManager;
} | [
"public",
"static",
"File",
"startSystemCaseManager",
"(",
"String",
"package_path",
",",
"String",
"dest_dir",
")",
"throws",
"BeastException",
"{",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"\"CreateSystemCaseManager.startSystemCaseManager\"",
")",
";",
"File",
"folder",
"=",
"SystemReader",
".",
"createFolder",
"(",
"package_path",
",",
"dest_dir",
")",
";",
"File",
"caseManager",
"=",
"new",
"File",
"(",
"folder",
",",
"\"UserStoriesManager.java\"",
")",
";",
"FileWriter",
"caseManagerWriter",
";",
"try",
"{",
"if",
"(",
"!",
"caseManager",
".",
"exists",
"(",
")",
")",
"{",
"caseManagerWriter",
"=",
"new",
"FileWriter",
"(",
"caseManager",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"package \"",
"+",
"package_path",
"+",
"\";\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"import org.junit.Assert;\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"import org.junit.Test;\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"import org.junit.runner.JUnitCore;\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"import org.junit.runner.Result;\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"/**\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\" * Main class to launch all tests in a single run\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\" *\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\" * @author es.upm.dit.gsi.beast\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\" */\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"public class UserStoriesManager {\\n\"",
")",
";",
"caseManagerWriter",
".",
"write",
"(",
"\"\\n\"",
")",
";",
"caseManagerWriter",
".",
"flush",
"(",
")",
";",
"caseManagerWriter",
".",
"close",
"(",
")",
";",
"// logger.info(\"CaseManager has been created in \"+dest_dir+Reader.createFolderPath(package_path));",
"}",
"else",
"{",
"List",
"<",
"String",
">",
"lines",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"// read the file into lines",
"BufferedReader",
"r",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"caseManager",
")",
")",
";",
"String",
"in",
";",
"while",
"(",
"(",
"in",
"=",
"r",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"lines",
".",
"add",
"(",
"in",
")",
";",
"}",
"r",
".",
"close",
"(",
")",
";",
"lines",
".",
"remove",
"(",
"lines",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"// write it back",
"PrintWriter",
"w",
"=",
"new",
"PrintWriter",
"(",
"new",
"FileWriter",
"(",
"caseManager",
")",
")",
";",
"for",
"(",
"String",
"line",
":",
"lines",
")",
"{",
"w",
".",
"println",
"(",
"line",
")",
";",
"}",
"w",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"severe",
"(",
"\"ERROR writing Case Manager file\"",
")",
";",
"throw",
"new",
"BeastException",
"(",
"\"ERROR writing Case Manager file\"",
",",
"e",
")",
";",
"}",
"return",
"caseManager",
";",
"}"
] | This method creates CaseManager file and writes on it: the package, the
imports, its comments and the class name.
@param package_path
as es.upm.dit...
@param dest_dir
as src/main/java
@return the File with its first part written
@throws BeastException | [
"This",
"method",
"creates",
"CaseManager",
"file",
"and",
"writes",
"on",
"it",
":",
"the",
"package",
"the",
"imports",
"its",
"comments",
"and",
"the",
"class",
"name",
"."
] | train | https://github.com/gsi-upm/BeastTool/blob/cc7fdc75cb818c5d60802aaf32c27829e0ca144c/beast-tool/src/main/java/es/upm/dit/gsi/beast/reader/system/CreateSystemCaseManager.java#L47-L105 |
elki-project/elki | elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/ids/DBIDUtil.java | DBIDUtil.randomSample | public static DBIDVar randomSample(DBIDs ids, Random random) {
"""
Draw a single random sample.
@param ids IDs to draw from
@param random Random value
@return Random ID
"""
return DBIDUtil.ensureArray(ids).assignVar(random.nextInt(ids.size()), DBIDUtil.newVar());
} | java | public static DBIDVar randomSample(DBIDs ids, Random random) {
return DBIDUtil.ensureArray(ids).assignVar(random.nextInt(ids.size()), DBIDUtil.newVar());
} | [
"public",
"static",
"DBIDVar",
"randomSample",
"(",
"DBIDs",
"ids",
",",
"Random",
"random",
")",
"{",
"return",
"DBIDUtil",
".",
"ensureArray",
"(",
"ids",
")",
".",
"assignVar",
"(",
"random",
".",
"nextInt",
"(",
"ids",
".",
"size",
"(",
")",
")",
",",
"DBIDUtil",
".",
"newVar",
"(",
")",
")",
";",
"}"
] | Draw a single random sample.
@param ids IDs to draw from
@param random Random value
@return Random ID | [
"Draw",
"a",
"single",
"random",
"sample",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/ids/DBIDUtil.java#L714-L716 |
datasift/datasift-java | src/main/java/com/datasift/client/push/DataSiftPush.java | DataSiftPush.createPull | public FutureData<PushSubscription> createPull(PullJsonType jsonMeta, PreparedHistoricsQuery historics, String name,
Status initialStatus, long start, long end) {
"""
/*
Create a push subscription to be consumed via {@link #pull(PushSubscription, int, String)} using a live stream
@param historics the historic query which will be consumed via pull
@param name a name for the subscription
@param initialStatus the initial status of the subscription
@param start an option timestamp of when to start the subscription
@param end an optional timestamp of when to stop
@return this
"""
return createPull(jsonMeta, historics, null, name, initialStatus, start, end);
} | java | public FutureData<PushSubscription> createPull(PullJsonType jsonMeta, PreparedHistoricsQuery historics, String name,
Status initialStatus, long start, long end) {
return createPull(jsonMeta, historics, null, name, initialStatus, start, end);
} | [
"public",
"FutureData",
"<",
"PushSubscription",
">",
"createPull",
"(",
"PullJsonType",
"jsonMeta",
",",
"PreparedHistoricsQuery",
"historics",
",",
"String",
"name",
",",
"Status",
"initialStatus",
",",
"long",
"start",
",",
"long",
"end",
")",
"{",
"return",
"createPull",
"(",
"jsonMeta",
",",
"historics",
",",
"null",
",",
"name",
",",
"initialStatus",
",",
"start",
",",
"end",
")",
";",
"}"
] | /*
Create a push subscription to be consumed via {@link #pull(PushSubscription, int, String)} using a live stream
@param historics the historic query which will be consumed via pull
@param name a name for the subscription
@param initialStatus the initial status of the subscription
@param start an option timestamp of when to start the subscription
@param end an optional timestamp of when to stop
@return this | [
"/",
"*",
"Create",
"a",
"push",
"subscription",
"to",
"be",
"consumed",
"via",
"{",
"@link",
"#pull",
"(",
"PushSubscription",
"int",
"String",
")",
"}",
"using",
"a",
"live",
"stream"
] | train | https://github.com/datasift/datasift-java/blob/09de124f2a1a507ff6181e59875c6f325290850e/src/main/java/com/datasift/client/push/DataSiftPush.java#L491-L494 |
NessComputing/components-ness-jms | src/main/java/com/nesscomputing/jms/JmsRunnableFactory.java | JmsRunnableFactory.createQueueTextMessageListener | public QueueConsumer createQueueTextMessageListener(final String topic, final ConsumerCallback<String> messageCallback) {
"""
Creates a new {@link QueueConsumer}. For every text message received, the callback
is invoked with the contents of the text message as string.
"""
Preconditions.checkState(connectionFactory != null, "connection factory was never injected!");
return new QueueConsumer(connectionFactory, jmsConfig, topic, new TextMessageConsumerCallback(messageCallback));
} | java | public QueueConsumer createQueueTextMessageListener(final String topic, final ConsumerCallback<String> messageCallback)
{
Preconditions.checkState(connectionFactory != null, "connection factory was never injected!");
return new QueueConsumer(connectionFactory, jmsConfig, topic, new TextMessageConsumerCallback(messageCallback));
} | [
"public",
"QueueConsumer",
"createQueueTextMessageListener",
"(",
"final",
"String",
"topic",
",",
"final",
"ConsumerCallback",
"<",
"String",
">",
"messageCallback",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"connectionFactory",
"!=",
"null",
",",
"\"connection factory was never injected!\"",
")",
";",
"return",
"new",
"QueueConsumer",
"(",
"connectionFactory",
",",
"jmsConfig",
",",
"topic",
",",
"new",
"TextMessageConsumerCallback",
"(",
"messageCallback",
")",
")",
";",
"}"
] | Creates a new {@link QueueConsumer}. For every text message received, the callback
is invoked with the contents of the text message as string. | [
"Creates",
"a",
"new",
"{"
] | train | https://github.com/NessComputing/components-ness-jms/blob/29e0d320ada3a1a375483437a9f3ff629822b714/src/main/java/com/nesscomputing/jms/JmsRunnableFactory.java#L154-L158 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPath.java | DocPath.forPackage | public static DocPath forPackage(Utils utils, TypeElement typeElement) {
"""
Return the path for the package of a class.
For example, if the class is java.lang.Object,
the path is java/lang.
"""
return (typeElement == null) ? empty : forPackage(utils.containingPackage(typeElement));
} | java | public static DocPath forPackage(Utils utils, TypeElement typeElement) {
return (typeElement == null) ? empty : forPackage(utils.containingPackage(typeElement));
} | [
"public",
"static",
"DocPath",
"forPackage",
"(",
"Utils",
"utils",
",",
"TypeElement",
"typeElement",
")",
"{",
"return",
"(",
"typeElement",
"==",
"null",
")",
"?",
"empty",
":",
"forPackage",
"(",
"utils",
".",
"containingPackage",
"(",
"typeElement",
")",
")",
";",
"}"
] | Return the path for the package of a class.
For example, if the class is java.lang.Object,
the path is java/lang. | [
"Return",
"the",
"path",
"for",
"the",
"package",
"of",
"a",
"class",
".",
"For",
"example",
"if",
"the",
"class",
"is",
"java",
".",
"lang",
".",
"Object",
"the",
"path",
"is",
"java",
"/",
"lang",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPath.java#L81-L83 |
mikepenz/Android-Iconics | library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java | IconicsDrawable.roundedCornersDp | @NonNull
public IconicsDrawable roundedCornersDp(@Dimension(unit = DP) int sizeDp) {
"""
Set rounded corner from dp
@return The current IconicsDrawable for chaining.
"""
return roundedCornersPx(Utils.convertDpToPx(mContext, sizeDp));
} | java | @NonNull
public IconicsDrawable roundedCornersDp(@Dimension(unit = DP) int sizeDp) {
return roundedCornersPx(Utils.convertDpToPx(mContext, sizeDp));
} | [
"@",
"NonNull",
"public",
"IconicsDrawable",
"roundedCornersDp",
"(",
"@",
"Dimension",
"(",
"unit",
"=",
"DP",
")",
"int",
"sizeDp",
")",
"{",
"return",
"roundedCornersPx",
"(",
"Utils",
".",
"convertDpToPx",
"(",
"mContext",
",",
"sizeDp",
")",
")",
";",
"}"
] | Set rounded corner from dp
@return The current IconicsDrawable for chaining. | [
"Set",
"rounded",
"corner",
"from",
"dp"
] | train | https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L978-L981 |
resilience4j/resilience4j | resilience4j-spring/src/main/java/io/github/resilience4j/bulkhead/configure/BulkheadAspect.java | BulkheadAspect.handleJoinPointCompletableFuture | private Object handleJoinPointCompletableFuture(ProceedingJoinPoint proceedingJoinPoint, io.github.resilience4j.bulkhead.Bulkhead bulkhead) {
"""
handle the asynchronous completable future flow
@param proceedingJoinPoint AOPJoinPoint
@param bulkhead configured bulkhead
@return CompletionStage
"""
return bulkhead.executeCompletionStage(() -> {
try {
return (CompletionStage<?>) proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
throw new CompletionException(throwable);
}
});
} | java | private Object handleJoinPointCompletableFuture(ProceedingJoinPoint proceedingJoinPoint, io.github.resilience4j.bulkhead.Bulkhead bulkhead) {
return bulkhead.executeCompletionStage(() -> {
try {
return (CompletionStage<?>) proceedingJoinPoint.proceed();
} catch (Throwable throwable) {
throw new CompletionException(throwable);
}
});
} | [
"private",
"Object",
"handleJoinPointCompletableFuture",
"(",
"ProceedingJoinPoint",
"proceedingJoinPoint",
",",
"io",
".",
"github",
".",
"resilience4j",
".",
"bulkhead",
".",
"Bulkhead",
"bulkhead",
")",
"{",
"return",
"bulkhead",
".",
"executeCompletionStage",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"return",
"(",
"CompletionStage",
"<",
"?",
">",
")",
"proceedingJoinPoint",
".",
"proceed",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"throwable",
")",
"{",
"throw",
"new",
"CompletionException",
"(",
"throwable",
")",
";",
"}",
"}",
")",
";",
"}"
] | handle the asynchronous completable future flow
@param proceedingJoinPoint AOPJoinPoint
@param bulkhead configured bulkhead
@return CompletionStage | [
"handle",
"the",
"asynchronous",
"completable",
"future",
"flow"
] | train | https://github.com/resilience4j/resilience4j/blob/fa843d30f531c00f0c3dc218b65a7f2bb51af336/resilience4j-spring/src/main/java/io/github/resilience4j/bulkhead/configure/BulkheadAspect.java#L120-L128 |
google/closure-templates | java/src/com/google/template/soy/pysrc/internal/GenPyCallExprVisitor.java | GenPyCallExprVisitor.escapeCall | private PyExpr escapeCall(String callExpr, ImmutableList<SoyPrintDirective> directives) {
"""
Escaping directives might apply to the output of the call node, so wrap the output with all
required directives.
@param callExpr The expression text of the call itself.
@param directives The list of the directives to be applied to the call.
@return A PyExpr containing the call expression with all directives applied.
"""
PyExpr escapedExpr = new PyExpr(callExpr, Integer.MAX_VALUE);
if (directives.isEmpty()) {
return escapedExpr;
}
// Successively wrap each escapedExpr in various directives.
for (SoyPrintDirective directive : directives) {
Preconditions.checkState(
directive instanceof SoyPySrcPrintDirective,
"Autoescaping produced a bogus directive: %s",
directive.getName());
escapedExpr =
((SoyPySrcPrintDirective) directive).applyForPySrc(escapedExpr, ImmutableList.of());
}
return escapedExpr;
} | java | private PyExpr escapeCall(String callExpr, ImmutableList<SoyPrintDirective> directives) {
PyExpr escapedExpr = new PyExpr(callExpr, Integer.MAX_VALUE);
if (directives.isEmpty()) {
return escapedExpr;
}
// Successively wrap each escapedExpr in various directives.
for (SoyPrintDirective directive : directives) {
Preconditions.checkState(
directive instanceof SoyPySrcPrintDirective,
"Autoescaping produced a bogus directive: %s",
directive.getName());
escapedExpr =
((SoyPySrcPrintDirective) directive).applyForPySrc(escapedExpr, ImmutableList.of());
}
return escapedExpr;
} | [
"private",
"PyExpr",
"escapeCall",
"(",
"String",
"callExpr",
",",
"ImmutableList",
"<",
"SoyPrintDirective",
">",
"directives",
")",
"{",
"PyExpr",
"escapedExpr",
"=",
"new",
"PyExpr",
"(",
"callExpr",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"if",
"(",
"directives",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"escapedExpr",
";",
"}",
"// Successively wrap each escapedExpr in various directives.",
"for",
"(",
"SoyPrintDirective",
"directive",
":",
"directives",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"directive",
"instanceof",
"SoyPySrcPrintDirective",
",",
"\"Autoescaping produced a bogus directive: %s\"",
",",
"directive",
".",
"getName",
"(",
")",
")",
";",
"escapedExpr",
"=",
"(",
"(",
"SoyPySrcPrintDirective",
")",
"directive",
")",
".",
"applyForPySrc",
"(",
"escapedExpr",
",",
"ImmutableList",
".",
"of",
"(",
")",
")",
";",
"}",
"return",
"escapedExpr",
";",
"}"
] | Escaping directives might apply to the output of the call node, so wrap the output with all
required directives.
@param callExpr The expression text of the call itself.
@param directives The list of the directives to be applied to the call.
@return A PyExpr containing the call expression with all directives applied. | [
"Escaping",
"directives",
"might",
"apply",
"to",
"the",
"output",
"of",
"the",
"call",
"node",
"so",
"wrap",
"the",
"output",
"with",
"all",
"required",
"directives",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/GenPyCallExprVisitor.java#L280-L296 |
facebookarchive/hadoop-20 | src/mapred/org/apache/hadoop/mapred/FileOutputFormat.java | FileOutputFormat.getTaskOutputPath | public static Path getTaskOutputPath(JobConf conf, String name)
throws IOException {
"""
Helper function to create the task's temporary output directory and
return the path to the task's output file.
@param conf job-configuration
@param name temporary task-output filename
@return path to the task's temporary output file
@throws IOException
"""
// ${mapred.out.dir}
Path outputPath = getOutputPath(conf);
if (outputPath == null) {
throw new IOException("Undefined job output-path");
}
OutputCommitter committer = conf.getOutputCommitter();
Path workPath = outputPath;
TaskAttemptContext context = new TaskAttemptContext(conf,
TaskAttemptID.forName(conf.get("mapred.task.id")));
if (committer instanceof FileOutputCommitter) {
workPath = ((FileOutputCommitter)committer).getWorkPath(context,
outputPath);
}
// ${mapred.out.dir}/_temporary/_${taskid}/${name}
return new Path(workPath, name);
} | java | public static Path getTaskOutputPath(JobConf conf, String name)
throws IOException {
// ${mapred.out.dir}
Path outputPath = getOutputPath(conf);
if (outputPath == null) {
throw new IOException("Undefined job output-path");
}
OutputCommitter committer = conf.getOutputCommitter();
Path workPath = outputPath;
TaskAttemptContext context = new TaskAttemptContext(conf,
TaskAttemptID.forName(conf.get("mapred.task.id")));
if (committer instanceof FileOutputCommitter) {
workPath = ((FileOutputCommitter)committer).getWorkPath(context,
outputPath);
}
// ${mapred.out.dir}/_temporary/_${taskid}/${name}
return new Path(workPath, name);
} | [
"public",
"static",
"Path",
"getTaskOutputPath",
"(",
"JobConf",
"conf",
",",
"String",
"name",
")",
"throws",
"IOException",
"{",
"// ${mapred.out.dir}",
"Path",
"outputPath",
"=",
"getOutputPath",
"(",
"conf",
")",
";",
"if",
"(",
"outputPath",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Undefined job output-path\"",
")",
";",
"}",
"OutputCommitter",
"committer",
"=",
"conf",
".",
"getOutputCommitter",
"(",
")",
";",
"Path",
"workPath",
"=",
"outputPath",
";",
"TaskAttemptContext",
"context",
"=",
"new",
"TaskAttemptContext",
"(",
"conf",
",",
"TaskAttemptID",
".",
"forName",
"(",
"conf",
".",
"get",
"(",
"\"mapred.task.id\"",
")",
")",
")",
";",
"if",
"(",
"committer",
"instanceof",
"FileOutputCommitter",
")",
"{",
"workPath",
"=",
"(",
"(",
"FileOutputCommitter",
")",
"committer",
")",
".",
"getWorkPath",
"(",
"context",
",",
"outputPath",
")",
";",
"}",
"// ${mapred.out.dir}/_temporary/_${taskid}/${name}",
"return",
"new",
"Path",
"(",
"workPath",
",",
"name",
")",
";",
"}"
] | Helper function to create the task's temporary output directory and
return the path to the task's output file.
@param conf job-configuration
@param name temporary task-output filename
@return path to the task's temporary output file
@throws IOException | [
"Helper",
"function",
"to",
"create",
"the",
"task",
"s",
"temporary",
"output",
"directory",
"and",
"return",
"the",
"path",
"to",
"the",
"task",
"s",
"output",
"file",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/mapred/org/apache/hadoop/mapred/FileOutputFormat.java#L231-L250 |
google/auto | value/src/main/java/com/google/auto/value/processor/ErrorReporter.java | ErrorReporter.reportError | void reportError(String msg, Element e) {
"""
Issue a compilation error. This method does not throw an exception, since we want to continue
processing and perhaps report other errors. It is a good idea to introduce a test case in
CompilationTest for any new call to reportError(...) to ensure that we continue correctly after
an error.
@param msg the text of the warning
@param e the element to which it pertains
"""
messager.printMessage(Diagnostic.Kind.ERROR, msg, e);
errorCount++;
} | java | void reportError(String msg, Element e) {
messager.printMessage(Diagnostic.Kind.ERROR, msg, e);
errorCount++;
} | [
"void",
"reportError",
"(",
"String",
"msg",
",",
"Element",
"e",
")",
"{",
"messager",
".",
"printMessage",
"(",
"Diagnostic",
".",
"Kind",
".",
"ERROR",
",",
"msg",
",",
"e",
")",
";",
"errorCount",
"++",
";",
"}"
] | Issue a compilation error. This method does not throw an exception, since we want to continue
processing and perhaps report other errors. It is a good idea to introduce a test case in
CompilationTest for any new call to reportError(...) to ensure that we continue correctly after
an error.
@param msg the text of the warning
@param e the element to which it pertains | [
"Issue",
"a",
"compilation",
"error",
".",
"This",
"method",
"does",
"not",
"throw",
"an",
"exception",
"since",
"we",
"want",
"to",
"continue",
"processing",
"and",
"perhaps",
"report",
"other",
"errors",
".",
"It",
"is",
"a",
"good",
"idea",
"to",
"introduce",
"a",
"test",
"case",
"in",
"CompilationTest",
"for",
"any",
"new",
"call",
"to",
"reportError",
"(",
"...",
")",
"to",
"ensure",
"that",
"we",
"continue",
"correctly",
"after",
"an",
"error",
"."
] | train | https://github.com/google/auto/blob/4158a5fa71f1ef763e683b627f4d29bc04cfde9d/value/src/main/java/com/google/auto/value/processor/ErrorReporter.java#L65-L68 |
jbundle/jbundle | thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageManager.java | BaseMessageManager.init | public void init(App application, String strParams, Map<String, Object> properties) {
"""
Constructor.
@param application The parent application.
@param strParams The task properties.
"""
super.init(application, strParams, properties);
if (this.getProperty(Param.REMOTE_APP_NAME) == null)
this.setProperty(Param.REMOTE_APP_NAME, "org.jbundle.base.remote.server.RemoteSessionServer"/*Param.REMOTE_MESSAGE_APP*/);
m_messageMap = new Hashtable<String,BaseMessageQueue>();
} | java | public void init(App application, String strParams, Map<String, Object> properties)
{
super.init(application, strParams, properties);
if (this.getProperty(Param.REMOTE_APP_NAME) == null)
this.setProperty(Param.REMOTE_APP_NAME, "org.jbundle.base.remote.server.RemoteSessionServer"/*Param.REMOTE_MESSAGE_APP*/);
m_messageMap = new Hashtable<String,BaseMessageQueue>();
} | [
"public",
"void",
"init",
"(",
"App",
"application",
",",
"String",
"strParams",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"super",
".",
"init",
"(",
"application",
",",
"strParams",
",",
"properties",
")",
";",
"if",
"(",
"this",
".",
"getProperty",
"(",
"Param",
".",
"REMOTE_APP_NAME",
")",
"==",
"null",
")",
"this",
".",
"setProperty",
"(",
"Param",
".",
"REMOTE_APP_NAME",
",",
"\"org.jbundle.base.remote.server.RemoteSessionServer\"",
"/*Param.REMOTE_MESSAGE_APP*/",
")",
";",
"m_messageMap",
"=",
"new",
"Hashtable",
"<",
"String",
",",
"BaseMessageQueue",
">",
"(",
")",
";",
"}"
] | Constructor.
@param application The parent application.
@param strParams The task properties. | [
"Constructor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageManager.java#L55-L61 |
robocup-atan/atan | src/main/java/com/github/robocup_atan/atan/model/CommandFactory.java | CommandFactory.addKickCommand | public void addKickCommand(int power, int direction) {
"""
This command accelerates the ball with the given power in the given direction.
@param power Power is between minpower (-100) and maxpower (+100).
@param direction Direction is relative to the body of the player.
"""
StringBuilder buf = new StringBuilder();
buf.append("(kick ");
buf.append(power);
buf.append(' ');
buf.append(direction);
buf.append(')');
fifo.add(fifo.size(), buf.toString());
} | java | public void addKickCommand(int power, int direction) {
StringBuilder buf = new StringBuilder();
buf.append("(kick ");
buf.append(power);
buf.append(' ');
buf.append(direction);
buf.append(')');
fifo.add(fifo.size(), buf.toString());
} | [
"public",
"void",
"addKickCommand",
"(",
"int",
"power",
",",
"int",
"direction",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buf",
".",
"append",
"(",
"\"(kick \"",
")",
";",
"buf",
".",
"append",
"(",
"power",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"buf",
".",
"append",
"(",
"direction",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"fifo",
".",
"add",
"(",
"fifo",
".",
"size",
"(",
")",
",",
"buf",
".",
"toString",
"(",
")",
")",
";",
"}"
] | This command accelerates the ball with the given power in the given direction.
@param power Power is between minpower (-100) and maxpower (+100).
@param direction Direction is relative to the body of the player. | [
"This",
"command",
"accelerates",
"the",
"ball",
"with",
"the",
"given",
"power",
"in",
"the",
"given",
"direction",
"."
] | train | https://github.com/robocup-atan/atan/blob/52237b468b09ba5b7c52d290984dbe0326c96df7/src/main/java/com/github/robocup_atan/atan/model/CommandFactory.java#L201-L209 |
apache/groovy | subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java | Sql.executeInsert | public List<List<Object>> executeInsert(Map params, String sql) throws SQLException {
"""
A variant of {@link #executeInsert(String, java.util.List)}
useful when providing the named parameters as named arguments.
@param params a map containing the named parameters
@param sql The SQL statement to execute
@return A list of the auto-generated column values for each
inserted row (typically auto-generated keys)
@throws SQLException if a database access error occurs
@since 1.8.7
"""
return executeInsert(sql, singletonList(params));
} | java | public List<List<Object>> executeInsert(Map params, String sql) throws SQLException {
return executeInsert(sql, singletonList(params));
} | [
"public",
"List",
"<",
"List",
"<",
"Object",
">",
">",
"executeInsert",
"(",
"Map",
"params",
",",
"String",
"sql",
")",
"throws",
"SQLException",
"{",
"return",
"executeInsert",
"(",
"sql",
",",
"singletonList",
"(",
"params",
")",
")",
";",
"}"
] | A variant of {@link #executeInsert(String, java.util.List)}
useful when providing the named parameters as named arguments.
@param params a map containing the named parameters
@param sql The SQL statement to execute
@return A list of the auto-generated column values for each
inserted row (typically auto-generated keys)
@throws SQLException if a database access error occurs
@since 1.8.7 | [
"A",
"variant",
"of",
"{",
"@link",
"#executeInsert",
"(",
"String",
"java",
".",
"util",
".",
"List",
")",
"}",
"useful",
"when",
"providing",
"the",
"named",
"parameters",
"as",
"named",
"arguments",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java#L2717-L2719 |
RestComm/media-core | rtp/src/main/java/org/restcomm/media/core/rtcp/RtcpPacketFactory.java | RtcpPacketFactory.buildBye | public static RtcpPacket buildBye(RtpStatistics statistics) {
"""
Builds a packet containing an RTCP BYE message.
@param statistics
The statistics of the RTP session
@return The RTCP packet
"""
// TODO Validate padding
boolean padding = false;
// Build the initial report packet
RtcpReport report;
if(statistics.hasSent()) {
report = buildSenderReport(statistics, padding);
} else {
report = buildReceiverReport(statistics, padding);
}
// Build the SDES packet containing the CNAME
RtcpSdes sdes = buildSdes(statistics, padding);
// Build the BYE
RtcpBye bye = new RtcpBye(padding);
bye.addSsrc(statistics.getSsrc());
// Build the compound packet
return new RtcpPacket(report, sdes, bye);
} | java | public static RtcpPacket buildBye(RtpStatistics statistics) {
// TODO Validate padding
boolean padding = false;
// Build the initial report packet
RtcpReport report;
if(statistics.hasSent()) {
report = buildSenderReport(statistics, padding);
} else {
report = buildReceiverReport(statistics, padding);
}
// Build the SDES packet containing the CNAME
RtcpSdes sdes = buildSdes(statistics, padding);
// Build the BYE
RtcpBye bye = new RtcpBye(padding);
bye.addSsrc(statistics.getSsrc());
// Build the compound packet
return new RtcpPacket(report, sdes, bye);
} | [
"public",
"static",
"RtcpPacket",
"buildBye",
"(",
"RtpStatistics",
"statistics",
")",
"{",
"// TODO Validate padding",
"boolean",
"padding",
"=",
"false",
";",
"// Build the initial report packet",
"RtcpReport",
"report",
";",
"if",
"(",
"statistics",
".",
"hasSent",
"(",
")",
")",
"{",
"report",
"=",
"buildSenderReport",
"(",
"statistics",
",",
"padding",
")",
";",
"}",
"else",
"{",
"report",
"=",
"buildReceiverReport",
"(",
"statistics",
",",
"padding",
")",
";",
"}",
"// Build the SDES packet containing the CNAME",
"RtcpSdes",
"sdes",
"=",
"buildSdes",
"(",
"statistics",
",",
"padding",
")",
";",
"// Build the BYE",
"RtcpBye",
"bye",
"=",
"new",
"RtcpBye",
"(",
"padding",
")",
";",
"bye",
".",
"addSsrc",
"(",
"statistics",
".",
"getSsrc",
"(",
")",
")",
";",
"// Build the compound packet",
"return",
"new",
"RtcpPacket",
"(",
"report",
",",
"sdes",
",",
"bye",
")",
";",
"}"
] | Builds a packet containing an RTCP BYE message.
@param statistics
The statistics of the RTP session
@return The RTCP packet | [
"Builds",
"a",
"packet",
"containing",
"an",
"RTCP",
"BYE",
"message",
"."
] | train | https://github.com/RestComm/media-core/blob/07b8703343708599f60af66bae62aded77ee81b5/rtp/src/main/java/org/restcomm/media/core/rtcp/RtcpPacketFactory.java#L218-L239 |
EasyinnovaSL/Tiff-Library-4J | src/main/java/com/easyinnova/tiff/model/ValidationResult.java | ValidationResult.addWarning | public void addWarning(String desc, String value, String loc) {
"""
Adds an warning.
@param desc Warning description
@param value the String that caused the warning
@param loc the location
"""
iaddWarning(desc, value, loc);
} | java | public void addWarning(String desc, String value, String loc) {
iaddWarning(desc, value, loc);
} | [
"public",
"void",
"addWarning",
"(",
"String",
"desc",
",",
"String",
"value",
",",
"String",
"loc",
")",
"{",
"iaddWarning",
"(",
"desc",
",",
"value",
",",
"loc",
")",
";",
"}"
] | Adds an warning.
@param desc Warning description
@param value the String that caused the warning
@param loc the location | [
"Adds",
"an",
"warning",
"."
] | train | https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/model/ValidationResult.java#L161-L163 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/log/RaftLog.java | RaftLog.truncateEntriesFrom | public List<LogEntry> truncateEntriesFrom(long entryIndex) {
"""
Truncates log entries with indexes {@code >= entryIndex}.
@return truncated log entries
@throws IllegalArgumentException If no entries are available to
truncate, if {@code entryIndex} is
greater than last log index or smaller
than snapshot index.
"""
if (entryIndex <= snapshotIndex()) {
throw new IllegalArgumentException("Illegal index: " + entryIndex + ", snapshot index: " + snapshotIndex());
}
if (entryIndex > lastLogOrSnapshotIndex()) {
throw new IllegalArgumentException("Illegal index: " + entryIndex + ", last log index: " + lastLogOrSnapshotIndex());
}
long startSequence = toSequence(entryIndex);
assert startSequence >= logs.headSequence() : "Entry index: " + entryIndex + ", Head Seq: " + logs.headSequence();
List<LogEntry> truncated = new ArrayList<LogEntry>();
for (long ix = startSequence; ix <= logs.tailSequence(); ix++) {
truncated.add(logs.read(ix));
}
logs.setTailSequence(startSequence - 1);
return truncated;
} | java | public List<LogEntry> truncateEntriesFrom(long entryIndex) {
if (entryIndex <= snapshotIndex()) {
throw new IllegalArgumentException("Illegal index: " + entryIndex + ", snapshot index: " + snapshotIndex());
}
if (entryIndex > lastLogOrSnapshotIndex()) {
throw new IllegalArgumentException("Illegal index: " + entryIndex + ", last log index: " + lastLogOrSnapshotIndex());
}
long startSequence = toSequence(entryIndex);
assert startSequence >= logs.headSequence() : "Entry index: " + entryIndex + ", Head Seq: " + logs.headSequence();
List<LogEntry> truncated = new ArrayList<LogEntry>();
for (long ix = startSequence; ix <= logs.tailSequence(); ix++) {
truncated.add(logs.read(ix));
}
logs.setTailSequence(startSequence - 1);
return truncated;
} | [
"public",
"List",
"<",
"LogEntry",
">",
"truncateEntriesFrom",
"(",
"long",
"entryIndex",
")",
"{",
"if",
"(",
"entryIndex",
"<=",
"snapshotIndex",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Illegal index: \"",
"+",
"entryIndex",
"+",
"\", snapshot index: \"",
"+",
"snapshotIndex",
"(",
")",
")",
";",
"}",
"if",
"(",
"entryIndex",
">",
"lastLogOrSnapshotIndex",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Illegal index: \"",
"+",
"entryIndex",
"+",
"\", last log index: \"",
"+",
"lastLogOrSnapshotIndex",
"(",
")",
")",
";",
"}",
"long",
"startSequence",
"=",
"toSequence",
"(",
"entryIndex",
")",
";",
"assert",
"startSequence",
">=",
"logs",
".",
"headSequence",
"(",
")",
":",
"\"Entry index: \"",
"+",
"entryIndex",
"+",
"\", Head Seq: \"",
"+",
"logs",
".",
"headSequence",
"(",
")",
";",
"List",
"<",
"LogEntry",
">",
"truncated",
"=",
"new",
"ArrayList",
"<",
"LogEntry",
">",
"(",
")",
";",
"for",
"(",
"long",
"ix",
"=",
"startSequence",
";",
"ix",
"<=",
"logs",
".",
"tailSequence",
"(",
")",
";",
"ix",
"++",
")",
"{",
"truncated",
".",
"add",
"(",
"logs",
".",
"read",
"(",
"ix",
")",
")",
";",
"}",
"logs",
".",
"setTailSequence",
"(",
"startSequence",
"-",
"1",
")",
";",
"return",
"truncated",
";",
"}"
] | Truncates log entries with indexes {@code >= entryIndex}.
@return truncated log entries
@throws IllegalArgumentException If no entries are available to
truncate, if {@code entryIndex} is
greater than last log index or smaller
than snapshot index. | [
"Truncates",
"log",
"entries",
"with",
"indexes",
"{",
"@code",
">",
"=",
"entryIndex",
"}",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/log/RaftLog.java#L129-L147 |
sksamuel/scrimage | scrimage-core/src/main/java/com/sksamuel/scrimage/AwtImage.java | AwtImage.points | public Point[] points() {
"""
Returns an array of every point in the image, useful if you want to be able to
iterate over all the coordinates.
<p>
If you want the actual pixel values of every point then use pixels().
"""
Point[] points = new Point[width * height];
int k = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
points[k++] = new Point(x, y);
}
}
return points;
} | java | public Point[] points() {
Point[] points = new Point[width * height];
int k = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
points[k++] = new Point(x, y);
}
}
return points;
} | [
"public",
"Point",
"[",
"]",
"points",
"(",
")",
"{",
"Point",
"[",
"]",
"points",
"=",
"new",
"Point",
"[",
"width",
"*",
"height",
"]",
";",
"int",
"k",
"=",
"0",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"height",
";",
"y",
"++",
")",
"{",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"width",
";",
"x",
"++",
")",
"{",
"points",
"[",
"k",
"++",
"]",
"=",
"new",
"Point",
"(",
"x",
",",
"y",
")",
";",
"}",
"}",
"return",
"points",
";",
"}"
] | Returns an array of every point in the image, useful if you want to be able to
iterate over all the coordinates.
<p>
If you want the actual pixel values of every point then use pixels(). | [
"Returns",
"an",
"array",
"of",
"every",
"point",
"in",
"the",
"image",
"useful",
"if",
"you",
"want",
"to",
"be",
"able",
"to",
"iterate",
"over",
"all",
"the",
"coordinates",
".",
"<p",
">",
"If",
"you",
"want",
"the",
"actual",
"pixel",
"values",
"of",
"every",
"point",
"then",
"use",
"pixels",
"()",
"."
] | train | https://github.com/sksamuel/scrimage/blob/52dab448136e6657a71951b0e6b7d5e64dc979ac/scrimage-core/src/main/java/com/sksamuel/scrimage/AwtImage.java#L146-L155 |
jbundle/jbundle | thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/BaseApplet.java | BaseApplet.setStatus | public Object setStatus(int iStatus, Object comp, Object cursor) {
"""
Display the status text.
@param strMessage The message to display.
"""
Cursor oldCursor = null;
if (comp instanceof Component)
if (SwingUtilities.isEventDispatchThread()) // Just being careful
{
oldCursor = ((Component)comp).getCursor();
if (cursor == null)
cursor = (Cursor)Cursor.getPredefinedCursor(iStatus);
((Component)comp).setCursor((Cursor)cursor);
}
if (m_statusbar != null)
m_statusbar.setStatus(iStatus);
return oldCursor;
} | java | public Object setStatus(int iStatus, Object comp, Object cursor)
{
Cursor oldCursor = null;
if (comp instanceof Component)
if (SwingUtilities.isEventDispatchThread()) // Just being careful
{
oldCursor = ((Component)comp).getCursor();
if (cursor == null)
cursor = (Cursor)Cursor.getPredefinedCursor(iStatus);
((Component)comp).setCursor((Cursor)cursor);
}
if (m_statusbar != null)
m_statusbar.setStatus(iStatus);
return oldCursor;
} | [
"public",
"Object",
"setStatus",
"(",
"int",
"iStatus",
",",
"Object",
"comp",
",",
"Object",
"cursor",
")",
"{",
"Cursor",
"oldCursor",
"=",
"null",
";",
"if",
"(",
"comp",
"instanceof",
"Component",
")",
"if",
"(",
"SwingUtilities",
".",
"isEventDispatchThread",
"(",
")",
")",
"// Just being careful",
"{",
"oldCursor",
"=",
"(",
"(",
"Component",
")",
"comp",
")",
".",
"getCursor",
"(",
")",
";",
"if",
"(",
"cursor",
"==",
"null",
")",
"cursor",
"=",
"(",
"Cursor",
")",
"Cursor",
".",
"getPredefinedCursor",
"(",
"iStatus",
")",
";",
"(",
"(",
"Component",
")",
"comp",
")",
".",
"setCursor",
"(",
"(",
"Cursor",
")",
"cursor",
")",
";",
"}",
"if",
"(",
"m_statusbar",
"!=",
"null",
")",
"m_statusbar",
".",
"setStatus",
"(",
"iStatus",
")",
";",
"return",
"oldCursor",
";",
"}"
] | Display the status text.
@param strMessage The message to display. | [
"Display",
"the",
"status",
"text",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/BaseApplet.java#L1541-L1555 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/operators/BatchTask.java | BatchTask.cancelChainedTasks | public static void cancelChainedTasks(List<ChainedDriver<?, ?>> tasks) {
"""
Cancels all tasks via their {@link ChainedDriver#cancelTask()} method. Any occurring exception
and error is suppressed, such that the canceling method of every task is invoked in all cases.
@param tasks The tasks to be canceled.
"""
for (int i = 0; i < tasks.size(); i++) {
try {
tasks.get(i).cancelTask();
} catch (Throwable t) {
// do nothing
}
}
} | java | public static void cancelChainedTasks(List<ChainedDriver<?, ?>> tasks) {
for (int i = 0; i < tasks.size(); i++) {
try {
tasks.get(i).cancelTask();
} catch (Throwable t) {
// do nothing
}
}
} | [
"public",
"static",
"void",
"cancelChainedTasks",
"(",
"List",
"<",
"ChainedDriver",
"<",
"?",
",",
"?",
">",
">",
"tasks",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tasks",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"try",
"{",
"tasks",
".",
"get",
"(",
"i",
")",
".",
"cancelTask",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// do nothing",
"}",
"}",
"}"
] | Cancels all tasks via their {@link ChainedDriver#cancelTask()} method. Any occurring exception
and error is suppressed, such that the canceling method of every task is invoked in all cases.
@param tasks The tasks to be canceled. | [
"Cancels",
"all",
"tasks",
"via",
"their",
"{",
"@link",
"ChainedDriver#cancelTask",
"()",
"}",
"method",
".",
"Any",
"occurring",
"exception",
"and",
"error",
"is",
"suppressed",
"such",
"that",
"the",
"canceling",
"method",
"of",
"every",
"task",
"is",
"invoked",
"in",
"all",
"cases",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/operators/BatchTask.java#L1420-L1428 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.remote.portable.core/src/com/ibm/ws/ejb/portable/HandleImpl.java | HandleImpl.getReference | private EJBObject getReference() throws RemoteException {
"""
/*
d138969
GetReference will not get called for SessionBean
handles. The reason is the only time getReference is called is when ivEJBObject is null.
The only time ivEJBObject is null is when readObject method is called and it reads a
Constants.HANDLE_V1 id from the input stream. That only happens for Entity beans that
are sent by a pre-Aquila release server. It never happens for a session bean. This can be
seen by looking at com.ibm.ws.ejb.portable.Constants interface for HANDLE_V1 and HANDLE_V2.
By definition, HANDLE_V2 must be used for session beans. Consequently, readObject should never
null out ivEJBObject when a session bean Handle is being read from input stream, which means
getReference will never be called for session beans.
"""
EJBObject object = null;
EJBHome home = ivHomeHandle.getEJBHome();
Class homeClass = home.getClass();
try
{
Method fbpk = findFindByPrimaryKey(homeClass);
object = (EJBObject) fbpk.invoke(home, new Object[] { ivKey });
} catch (InvocationTargetException e)
{
// Unwrap the real exception and pass it back
// FFDCFilter.processException(e, CLASS_NAME + ".getReference", "144", this);
Throwable t = e.getTargetException();
if (t instanceof RemoteException)
{
throw (RemoteException) t;
}
else
{
throw new RemoteException("Could not find bean", t);
}
} catch (IllegalAccessException e)
{
// This shouldn't happen
// FFDCFilter.processException(e, CLASS_NAME + ".getReference", "158", this);
throw new RemoteException("Bad home interface definition", e);
}
return object;
} | java | private EJBObject getReference() throws RemoteException
{
EJBObject object = null;
EJBHome home = ivHomeHandle.getEJBHome();
Class homeClass = home.getClass();
try
{
Method fbpk = findFindByPrimaryKey(homeClass);
object = (EJBObject) fbpk.invoke(home, new Object[] { ivKey });
} catch (InvocationTargetException e)
{
// Unwrap the real exception and pass it back
// FFDCFilter.processException(e, CLASS_NAME + ".getReference", "144", this);
Throwable t = e.getTargetException();
if (t instanceof RemoteException)
{
throw (RemoteException) t;
}
else
{
throw new RemoteException("Could not find bean", t);
}
} catch (IllegalAccessException e)
{
// This shouldn't happen
// FFDCFilter.processException(e, CLASS_NAME + ".getReference", "158", this);
throw new RemoteException("Bad home interface definition", e);
}
return object;
} | [
"private",
"EJBObject",
"getReference",
"(",
")",
"throws",
"RemoteException",
"{",
"EJBObject",
"object",
"=",
"null",
";",
"EJBHome",
"home",
"=",
"ivHomeHandle",
".",
"getEJBHome",
"(",
")",
";",
"Class",
"homeClass",
"=",
"home",
".",
"getClass",
"(",
")",
";",
"try",
"{",
"Method",
"fbpk",
"=",
"findFindByPrimaryKey",
"(",
"homeClass",
")",
";",
"object",
"=",
"(",
"EJBObject",
")",
"fbpk",
".",
"invoke",
"(",
"home",
",",
"new",
"Object",
"[",
"]",
"{",
"ivKey",
"}",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"// Unwrap the real exception and pass it back",
"// FFDCFilter.processException(e, CLASS_NAME + \".getReference\", \"144\", this);",
"Throwable",
"t",
"=",
"e",
".",
"getTargetException",
"(",
")",
";",
"if",
"(",
"t",
"instanceof",
"RemoteException",
")",
"{",
"throw",
"(",
"RemoteException",
")",
"t",
";",
"}",
"else",
"{",
"throw",
"new",
"RemoteException",
"(",
"\"Could not find bean\"",
",",
"t",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"// This shouldn't happen",
"// FFDCFilter.processException(e, CLASS_NAME + \".getReference\", \"158\", this);",
"throw",
"new",
"RemoteException",
"(",
"\"Bad home interface definition\"",
",",
"e",
")",
";",
"}",
"return",
"object",
";",
"}"
] | /*
d138969
GetReference will not get called for SessionBean
handles. The reason is the only time getReference is called is when ivEJBObject is null.
The only time ivEJBObject is null is when readObject method is called and it reads a
Constants.HANDLE_V1 id from the input stream. That only happens for Entity beans that
are sent by a pre-Aquila release server. It never happens for a session bean. This can be
seen by looking at com.ibm.ws.ejb.portable.Constants interface for HANDLE_V1 and HANDLE_V2.
By definition, HANDLE_V2 must be used for session beans. Consequently, readObject should never
null out ivEJBObject when a session bean Handle is being read from input stream, which means
getReference will never be called for session beans. | [
"/",
"*",
"d138969",
"GetReference",
"will",
"not",
"get",
"called",
"for",
"SessionBean",
"handles",
".",
"The",
"reason",
"is",
"the",
"only",
"time",
"getReference",
"is",
"called",
"is",
"when",
"ivEJBObject",
"is",
"null",
".",
"The",
"only",
"time",
"ivEJBObject",
"is",
"null",
"is",
"when",
"readObject",
"method",
"is",
"called",
"and",
"it",
"reads",
"a",
"Constants",
".",
"HANDLE_V1",
"id",
"from",
"the",
"input",
"stream",
".",
"That",
"only",
"happens",
"for",
"Entity",
"beans",
"that",
"are",
"sent",
"by",
"a",
"pre",
"-",
"Aquila",
"release",
"server",
".",
"It",
"never",
"happens",
"for",
"a",
"session",
"bean",
".",
"This",
"can",
"be",
"seen",
"by",
"looking",
"at",
"com",
".",
"ibm",
".",
"ws",
".",
"ejb",
".",
"portable",
".",
"Constants",
"interface",
"for",
"HANDLE_V1",
"and",
"HANDLE_V2",
".",
"By",
"definition",
"HANDLE_V2",
"must",
"be",
"used",
"for",
"session",
"beans",
".",
"Consequently",
"readObject",
"should",
"never",
"null",
"out",
"ivEJBObject",
"when",
"a",
"session",
"bean",
"Handle",
"is",
"being",
"read",
"from",
"input",
"stream",
"which",
"means",
"getReference",
"will",
"never",
"be",
"called",
"for",
"session",
"beans",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.remote.portable.core/src/com/ibm/ws/ejb/portable/HandleImpl.java#L161-L193 |
wso2/transport-http | components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/sender/channel/pool/ConnectionManager.java | ConnectionManager.borrowTargetChannel | public TargetChannel borrowTargetChannel(HttpRoute httpRoute, SourceHandler sourceHandler,
Http2SourceHandler http2SourceHandler,
SenderConfiguration senderConfig, BootstrapConfiguration bootstrapConfig,
EventLoopGroup clientEventGroup) throws Exception {
"""
Gets the client target channel pool.
@param httpRoute Represents the endpoint address
@param sourceHandler Represents the HTTP/1.x source handler
@param http2SourceHandler Represents the HTTP/2 source handler
@param senderConfig Represents the client configurations
@param bootstrapConfig Represents the bootstrap info related to client connection creation
@param clientEventGroup Represents the eventloop group that the client channel should be bound to
@return the target channel which is requested for given parameters.
@throws Exception to notify any errors occur during retrieving the target channel
"""
GenericObjectPool trgHlrConnPool;
String trgHlrConnPoolId = httpRoute.toString() + connectionManagerId;
if (sourceHandler != null) {
ChannelHandlerContext inboundChannelContext = sourceHandler.getInboundChannelContext();
trgHlrConnPool = getTrgHlrPoolFromGlobalPoolWithSrcPool(httpRoute, senderConfig, bootstrapConfig,
trgHlrConnPoolId,
inboundChannelContext.channel().eventLoop(),
inboundChannelContext.channel().getClass(),
sourceHandler.getTargetChannelPool());
} else if (http2SourceHandler != null) {
ChannelHandlerContext inboundChannelContext = http2SourceHandler.getInboundChannelContext();
trgHlrConnPool = getTrgHlrPoolFromGlobalPoolWithSrcPool(httpRoute, senderConfig, bootstrapConfig,
trgHlrConnPoolId,
inboundChannelContext.channel().eventLoop(),
inboundChannelContext.channel().getClass(),
http2SourceHandler.getTargetChannelPool());
} else {
trgHlrConnPool = getTrgHlrPoolFromGlobalPool(httpRoute, senderConfig, bootstrapConfig, clientEventGroup);
}
return getTargetChannel(sourceHandler, http2SourceHandler, trgHlrConnPool, trgHlrConnPoolId);
} | java | public TargetChannel borrowTargetChannel(HttpRoute httpRoute, SourceHandler sourceHandler,
Http2SourceHandler http2SourceHandler,
SenderConfiguration senderConfig, BootstrapConfiguration bootstrapConfig,
EventLoopGroup clientEventGroup) throws Exception {
GenericObjectPool trgHlrConnPool;
String trgHlrConnPoolId = httpRoute.toString() + connectionManagerId;
if (sourceHandler != null) {
ChannelHandlerContext inboundChannelContext = sourceHandler.getInboundChannelContext();
trgHlrConnPool = getTrgHlrPoolFromGlobalPoolWithSrcPool(httpRoute, senderConfig, bootstrapConfig,
trgHlrConnPoolId,
inboundChannelContext.channel().eventLoop(),
inboundChannelContext.channel().getClass(),
sourceHandler.getTargetChannelPool());
} else if (http2SourceHandler != null) {
ChannelHandlerContext inboundChannelContext = http2SourceHandler.getInboundChannelContext();
trgHlrConnPool = getTrgHlrPoolFromGlobalPoolWithSrcPool(httpRoute, senderConfig, bootstrapConfig,
trgHlrConnPoolId,
inboundChannelContext.channel().eventLoop(),
inboundChannelContext.channel().getClass(),
http2SourceHandler.getTargetChannelPool());
} else {
trgHlrConnPool = getTrgHlrPoolFromGlobalPool(httpRoute, senderConfig, bootstrapConfig, clientEventGroup);
}
return getTargetChannel(sourceHandler, http2SourceHandler, trgHlrConnPool, trgHlrConnPoolId);
} | [
"public",
"TargetChannel",
"borrowTargetChannel",
"(",
"HttpRoute",
"httpRoute",
",",
"SourceHandler",
"sourceHandler",
",",
"Http2SourceHandler",
"http2SourceHandler",
",",
"SenderConfiguration",
"senderConfig",
",",
"BootstrapConfiguration",
"bootstrapConfig",
",",
"EventLoopGroup",
"clientEventGroup",
")",
"throws",
"Exception",
"{",
"GenericObjectPool",
"trgHlrConnPool",
";",
"String",
"trgHlrConnPoolId",
"=",
"httpRoute",
".",
"toString",
"(",
")",
"+",
"connectionManagerId",
";",
"if",
"(",
"sourceHandler",
"!=",
"null",
")",
"{",
"ChannelHandlerContext",
"inboundChannelContext",
"=",
"sourceHandler",
".",
"getInboundChannelContext",
"(",
")",
";",
"trgHlrConnPool",
"=",
"getTrgHlrPoolFromGlobalPoolWithSrcPool",
"(",
"httpRoute",
",",
"senderConfig",
",",
"bootstrapConfig",
",",
"trgHlrConnPoolId",
",",
"inboundChannelContext",
".",
"channel",
"(",
")",
".",
"eventLoop",
"(",
")",
",",
"inboundChannelContext",
".",
"channel",
"(",
")",
".",
"getClass",
"(",
")",
",",
"sourceHandler",
".",
"getTargetChannelPool",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"http2SourceHandler",
"!=",
"null",
")",
"{",
"ChannelHandlerContext",
"inboundChannelContext",
"=",
"http2SourceHandler",
".",
"getInboundChannelContext",
"(",
")",
";",
"trgHlrConnPool",
"=",
"getTrgHlrPoolFromGlobalPoolWithSrcPool",
"(",
"httpRoute",
",",
"senderConfig",
",",
"bootstrapConfig",
",",
"trgHlrConnPoolId",
",",
"inboundChannelContext",
".",
"channel",
"(",
")",
".",
"eventLoop",
"(",
")",
",",
"inboundChannelContext",
".",
"channel",
"(",
")",
".",
"getClass",
"(",
")",
",",
"http2SourceHandler",
".",
"getTargetChannelPool",
"(",
")",
")",
";",
"}",
"else",
"{",
"trgHlrConnPool",
"=",
"getTrgHlrPoolFromGlobalPool",
"(",
"httpRoute",
",",
"senderConfig",
",",
"bootstrapConfig",
",",
"clientEventGroup",
")",
";",
"}",
"return",
"getTargetChannel",
"(",
"sourceHandler",
",",
"http2SourceHandler",
",",
"trgHlrConnPool",
",",
"trgHlrConnPoolId",
")",
";",
"}"
] | Gets the client target channel pool.
@param httpRoute Represents the endpoint address
@param sourceHandler Represents the HTTP/1.x source handler
@param http2SourceHandler Represents the HTTP/2 source handler
@param senderConfig Represents the client configurations
@param bootstrapConfig Represents the bootstrap info related to client connection creation
@param clientEventGroup Represents the eventloop group that the client channel should be bound to
@return the target channel which is requested for given parameters.
@throws Exception to notify any errors occur during retrieving the target channel | [
"Gets",
"the",
"client",
"target",
"channel",
"pool",
"."
] | train | https://github.com/wso2/transport-http/blob/c51aa715b473db6c1b82a7d7b22f6e65f74df4c9/components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/sender/channel/pool/ConnectionManager.java#L70-L99 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java | PathFileObject.forJarPath | public static PathFileObject forJarPath(BaseFileManager fileManager,
Path path, Path userJarPath) {
"""
Create a PathFileObject for a file in a file system such as a jar file,
such that the binary name can be inferred from its position within the
file system.
The binary name is derived from {@code path}.
The name is derived from the composition of {@code userJarPath}
and {@code path}.
@param fileManager the file manager creating this file object
@param path the path referred to by this file object
@param userJarPath the path of the jar file containing the file system.
@return the file object
"""
return new JarFileObject(fileManager, path, userJarPath);
} | java | public static PathFileObject forJarPath(BaseFileManager fileManager,
Path path, Path userJarPath) {
return new JarFileObject(fileManager, path, userJarPath);
} | [
"public",
"static",
"PathFileObject",
"forJarPath",
"(",
"BaseFileManager",
"fileManager",
",",
"Path",
"path",
",",
"Path",
"userJarPath",
")",
"{",
"return",
"new",
"JarFileObject",
"(",
"fileManager",
",",
"path",
",",
"userJarPath",
")",
";",
"}"
] | Create a PathFileObject for a file in a file system such as a jar file,
such that the binary name can be inferred from its position within the
file system.
The binary name is derived from {@code path}.
The name is derived from the composition of {@code userJarPath}
and {@code path}.
@param fileManager the file manager creating this file object
@param path the path referred to by this file object
@param userJarPath the path of the jar file containing the file system.
@return the file object | [
"Create",
"a",
"PathFileObject",
"for",
"a",
"file",
"in",
"a",
"file",
"system",
"such",
"as",
"a",
"jar",
"file",
"such",
"that",
"the",
"binary",
"name",
"can",
"be",
"inferred",
"from",
"its",
"position",
"within",
"the",
"file",
"system",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java#L155-L158 |
alkacon/opencms-core | src/org/opencms/search/fields/CmsSearchFieldConfigurationOldCategories.java | CmsSearchFieldConfigurationOldCategories.appendCategories | @Override
protected I_CmsSearchDocument appendCategories(
I_CmsSearchDocument document,
CmsObject cms,
CmsResource resource,
I_CmsExtractionResult extractionResult,
List<CmsProperty> properties,
List<CmsProperty> propertiesSearched) {
"""
Extends the given document by resource category information based on properties.<p>
@param document the document to extend
@param cms the OpenCms context used for building the search index
@param resource the resource that is indexed
@param extractionResult the plain text extraction result from the resource
@param properties the list of all properties directly attached to the resource (not searched)
@param propertiesSearched the list of all searched properties of the resource
@return the document extended by resource category information
@see org.opencms.search.fields.CmsSearchFieldConfiguration#appendCategories(org.opencms.search.I_CmsSearchDocument, org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.extractors.I_CmsExtractionResult, java.util.List, java.util.List)
"""
Document doc = (Document)document.getDocument();
// add the category of the file (this is searched so the value can also be attached on a folder)
String value = CmsProperty.get(CmsPropertyDefinition.PROPERTY_SEARCH_CATEGORY, propertiesSearched).getValue();
if (CmsStringUtil.isNotEmpty(value)) {
// all categories are internally stored lower case
value = value.trim().toLowerCase();
if (value.length() > 0) {
Field field = new StringField(CmsSearchField.FIELD_CATEGORY, value, Field.Store.YES);
// field.setBoost(0);
doc.add(field);
}
}
return document;
} | java | @Override
protected I_CmsSearchDocument appendCategories(
I_CmsSearchDocument document,
CmsObject cms,
CmsResource resource,
I_CmsExtractionResult extractionResult,
List<CmsProperty> properties,
List<CmsProperty> propertiesSearched) {
Document doc = (Document)document.getDocument();
// add the category of the file (this is searched so the value can also be attached on a folder)
String value = CmsProperty.get(CmsPropertyDefinition.PROPERTY_SEARCH_CATEGORY, propertiesSearched).getValue();
if (CmsStringUtil.isNotEmpty(value)) {
// all categories are internally stored lower case
value = value.trim().toLowerCase();
if (value.length() > 0) {
Field field = new StringField(CmsSearchField.FIELD_CATEGORY, value, Field.Store.YES);
// field.setBoost(0);
doc.add(field);
}
}
return document;
} | [
"@",
"Override",
"protected",
"I_CmsSearchDocument",
"appendCategories",
"(",
"I_CmsSearchDocument",
"document",
",",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
",",
"I_CmsExtractionResult",
"extractionResult",
",",
"List",
"<",
"CmsProperty",
">",
"properties",
",",
"List",
"<",
"CmsProperty",
">",
"propertiesSearched",
")",
"{",
"Document",
"doc",
"=",
"(",
"Document",
")",
"document",
".",
"getDocument",
"(",
")",
";",
"// add the category of the file (this is searched so the value can also be attached on a folder)",
"String",
"value",
"=",
"CmsProperty",
".",
"get",
"(",
"CmsPropertyDefinition",
".",
"PROPERTY_SEARCH_CATEGORY",
",",
"propertiesSearched",
")",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"CmsStringUtil",
".",
"isNotEmpty",
"(",
"value",
")",
")",
"{",
"// all categories are internally stored lower case",
"value",
"=",
"value",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"value",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"Field",
"field",
"=",
"new",
"StringField",
"(",
"CmsSearchField",
".",
"FIELD_CATEGORY",
",",
"value",
",",
"Field",
".",
"Store",
".",
"YES",
")",
";",
"// field.setBoost(0);",
"doc",
".",
"add",
"(",
"field",
")",
";",
"}",
"}",
"return",
"document",
";",
"}"
] | Extends the given document by resource category information based on properties.<p>
@param document the document to extend
@param cms the OpenCms context used for building the search index
@param resource the resource that is indexed
@param extractionResult the plain text extraction result from the resource
@param properties the list of all properties directly attached to the resource (not searched)
@param propertiesSearched the list of all searched properties of the resource
@return the document extended by resource category information
@see org.opencms.search.fields.CmsSearchFieldConfiguration#appendCategories(org.opencms.search.I_CmsSearchDocument, org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.extractors.I_CmsExtractionResult, java.util.List, java.util.List) | [
"Extends",
"the",
"given",
"document",
"by",
"resource",
"category",
"information",
"based",
"on",
"properties",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/fields/CmsSearchFieldConfigurationOldCategories.java#L78-L101 |
digitalpetri/modbus | modbus-codec/src/main/java/com/digitalpetri/modbus/codec/Modbus.java | Modbus.releaseSharedResources | public static void releaseSharedResources(long timeout, TimeUnit unit) throws InterruptedException {
"""
Shutdown/stop any shared resources that me be in use, blocking until finished or interrupted.
@param timeout the duration to wait.
@param unit the {@link TimeUnit} of the {@code timeout} duration.
"""
sharedExecutor().awaitTermination(timeout, unit);
sharedEventLoop().shutdownGracefully().await(timeout, unit);
sharedWheelTimer().stop();
} | java | public static void releaseSharedResources(long timeout, TimeUnit unit) throws InterruptedException {
sharedExecutor().awaitTermination(timeout, unit);
sharedEventLoop().shutdownGracefully().await(timeout, unit);
sharedWheelTimer().stop();
} | [
"public",
"static",
"void",
"releaseSharedResources",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"sharedExecutor",
"(",
")",
".",
"awaitTermination",
"(",
"timeout",
",",
"unit",
")",
";",
"sharedEventLoop",
"(",
")",
".",
"shutdownGracefully",
"(",
")",
".",
"await",
"(",
"timeout",
",",
"unit",
")",
";",
"sharedWheelTimer",
"(",
")",
".",
"stop",
"(",
")",
";",
"}"
] | Shutdown/stop any shared resources that me be in use, blocking until finished or interrupted.
@param timeout the duration to wait.
@param unit the {@link TimeUnit} of the {@code timeout} duration. | [
"Shutdown",
"/",
"stop",
"any",
"shared",
"resources",
"that",
"me",
"be",
"in",
"use",
"blocking",
"until",
"finished",
"or",
"interrupted",
"."
] | train | https://github.com/digitalpetri/modbus/blob/66281d811e64dfcdf8c8a8d0e85cdd80ae809a19/modbus-codec/src/main/java/com/digitalpetri/modbus/codec/Modbus.java#L71-L75 |
vincentk/joptimizer | src/main/java/com/joptimizer/functions/LogarithmicBarrier.java | LogarithmicBarrier.createPhase1BarrierFunction | @Override
public BarrierFunction createPhase1BarrierFunction() {
"""
Create the barrier function for the Phase I.
It is a LogarithmicBarrier for the constraints:
<br>fi(X)-s, i=1,...,n
"""
final int dimPh1 = dim +1;
ConvexMultivariateRealFunction[] inequalitiesPh1 = new ConvexMultivariateRealFunction[this.fi.length];
for(int i=0; i<inequalitiesPh1.length; i++){
final ConvexMultivariateRealFunction originalFi = this.fi[i];
ConvexMultivariateRealFunction fi = new ConvexMultivariateRealFunction() {
@Override
public double value(double[] Y) {
DoubleMatrix1D y = DoubleFactory1D.dense.make(Y);
DoubleMatrix1D X = y.viewPart(0, dim);
return originalFi.value(X.toArray()) - y.get(dimPh1-1);
}
@Override
public double[] gradient(double[] Y) {
DoubleMatrix1D y = DoubleFactory1D.dense.make(Y);
DoubleMatrix1D X = y.viewPart(0, dim);
DoubleMatrix1D origGrad = F1.make(originalFi.gradient(X.toArray()));
DoubleMatrix1D ret = F1.make(1, -1);
ret = F1.append(origGrad, ret);
return ret.toArray();
}
@Override
public double[][] hessian(double[] Y) {
DoubleMatrix1D y = DoubleFactory1D.dense.make(Y);
DoubleMatrix1D X = y.viewPart(0, dim);
DoubleMatrix2D origHess;
double[][] origFiHessX = originalFi.hessian(X.toArray());
if(origFiHessX == FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER){
return FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER;
}else{
origHess = F2.make(origFiHessX);
DoubleMatrix2D[][] parts = new DoubleMatrix2D[][]{{origHess, null},{null,F2.make(1, 1)}};
return F2.compose(parts).toArray();
}
}
@Override
public int getDim() {
return dimPh1;
}
};
inequalitiesPh1[i] = fi;
}
BarrierFunction bfPh1 = new LogarithmicBarrier(inequalitiesPh1, dimPh1);
return bfPh1;
} | java | @Override
public BarrierFunction createPhase1BarrierFunction(){
final int dimPh1 = dim +1;
ConvexMultivariateRealFunction[] inequalitiesPh1 = new ConvexMultivariateRealFunction[this.fi.length];
for(int i=0; i<inequalitiesPh1.length; i++){
final ConvexMultivariateRealFunction originalFi = this.fi[i];
ConvexMultivariateRealFunction fi = new ConvexMultivariateRealFunction() {
@Override
public double value(double[] Y) {
DoubleMatrix1D y = DoubleFactory1D.dense.make(Y);
DoubleMatrix1D X = y.viewPart(0, dim);
return originalFi.value(X.toArray()) - y.get(dimPh1-1);
}
@Override
public double[] gradient(double[] Y) {
DoubleMatrix1D y = DoubleFactory1D.dense.make(Y);
DoubleMatrix1D X = y.viewPart(0, dim);
DoubleMatrix1D origGrad = F1.make(originalFi.gradient(X.toArray()));
DoubleMatrix1D ret = F1.make(1, -1);
ret = F1.append(origGrad, ret);
return ret.toArray();
}
@Override
public double[][] hessian(double[] Y) {
DoubleMatrix1D y = DoubleFactory1D.dense.make(Y);
DoubleMatrix1D X = y.viewPart(0, dim);
DoubleMatrix2D origHess;
double[][] origFiHessX = originalFi.hessian(X.toArray());
if(origFiHessX == FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER){
return FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER;
}else{
origHess = F2.make(origFiHessX);
DoubleMatrix2D[][] parts = new DoubleMatrix2D[][]{{origHess, null},{null,F2.make(1, 1)}};
return F2.compose(parts).toArray();
}
}
@Override
public int getDim() {
return dimPh1;
}
};
inequalitiesPh1[i] = fi;
}
BarrierFunction bfPh1 = new LogarithmicBarrier(inequalitiesPh1, dimPh1);
return bfPh1;
} | [
"@",
"Override",
"public",
"BarrierFunction",
"createPhase1BarrierFunction",
"(",
")",
"{",
"final",
"int",
"dimPh1",
"=",
"dim",
"+",
"1",
";",
"ConvexMultivariateRealFunction",
"[",
"]",
"inequalitiesPh1",
"=",
"new",
"ConvexMultivariateRealFunction",
"[",
"this",
".",
"fi",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"inequalitiesPh1",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"ConvexMultivariateRealFunction",
"originalFi",
"=",
"this",
".",
"fi",
"[",
"i",
"]",
";",
"ConvexMultivariateRealFunction",
"fi",
"=",
"new",
"ConvexMultivariateRealFunction",
"(",
")",
"{",
"@",
"Override",
"public",
"double",
"value",
"(",
"double",
"[",
"]",
"Y",
")",
"{",
"DoubleMatrix1D",
"y",
"=",
"DoubleFactory1D",
".",
"dense",
".",
"make",
"(",
"Y",
")",
";",
"DoubleMatrix1D",
"X",
"=",
"y",
".",
"viewPart",
"(",
"0",
",",
"dim",
")",
";",
"return",
"originalFi",
".",
"value",
"(",
"X",
".",
"toArray",
"(",
")",
")",
"-",
"y",
".",
"get",
"(",
"dimPh1",
"-",
"1",
")",
";",
"}",
"@",
"Override",
"public",
"double",
"[",
"]",
"gradient",
"(",
"double",
"[",
"]",
"Y",
")",
"{",
"DoubleMatrix1D",
"y",
"=",
"DoubleFactory1D",
".",
"dense",
".",
"make",
"(",
"Y",
")",
";",
"DoubleMatrix1D",
"X",
"=",
"y",
".",
"viewPart",
"(",
"0",
",",
"dim",
")",
";",
"DoubleMatrix1D",
"origGrad",
"=",
"F1",
".",
"make",
"(",
"originalFi",
".",
"gradient",
"(",
"X",
".",
"toArray",
"(",
")",
")",
")",
";",
"DoubleMatrix1D",
"ret",
"=",
"F1",
".",
"make",
"(",
"1",
",",
"-",
"1",
")",
";",
"ret",
"=",
"F1",
".",
"append",
"(",
"origGrad",
",",
"ret",
")",
";",
"return",
"ret",
".",
"toArray",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"double",
"[",
"]",
"[",
"]",
"hessian",
"(",
"double",
"[",
"]",
"Y",
")",
"{",
"DoubleMatrix1D",
"y",
"=",
"DoubleFactory1D",
".",
"dense",
".",
"make",
"(",
"Y",
")",
";",
"DoubleMatrix1D",
"X",
"=",
"y",
".",
"viewPart",
"(",
"0",
",",
"dim",
")",
";",
"DoubleMatrix2D",
"origHess",
";",
"double",
"[",
"]",
"[",
"]",
"origFiHessX",
"=",
"originalFi",
".",
"hessian",
"(",
"X",
".",
"toArray",
"(",
")",
")",
";",
"if",
"(",
"origFiHessX",
"==",
"FunctionsUtils",
".",
"ZEROES_2D_ARRAY_PLACEHOLDER",
")",
"{",
"return",
"FunctionsUtils",
".",
"ZEROES_2D_ARRAY_PLACEHOLDER",
";",
"}",
"else",
"{",
"origHess",
"=",
"F2",
".",
"make",
"(",
"origFiHessX",
")",
";",
"DoubleMatrix2D",
"[",
"]",
"[",
"]",
"parts",
"=",
"new",
"DoubleMatrix2D",
"[",
"]",
"[",
"]",
"{",
"{",
"origHess",
",",
"null",
"}",
",",
"{",
"null",
",",
"F2",
".",
"make",
"(",
"1",
",",
"1",
")",
"}",
"}",
";",
"return",
"F2",
".",
"compose",
"(",
"parts",
")",
".",
"toArray",
"(",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"int",
"getDim",
"(",
")",
"{",
"return",
"dimPh1",
";",
"}",
"}",
";",
"inequalitiesPh1",
"[",
"i",
"]",
"=",
"fi",
";",
"}",
"BarrierFunction",
"bfPh1",
"=",
"new",
"LogarithmicBarrier",
"(",
"inequalitiesPh1",
",",
"dimPh1",
")",
";",
"return",
"bfPh1",
";",
"}"
] | Create the barrier function for the Phase I.
It is a LogarithmicBarrier for the constraints:
<br>fi(X)-s, i=1,...,n | [
"Create",
"the",
"barrier",
"function",
"for",
"the",
"Phase",
"I",
".",
"It",
"is",
"a",
"LogarithmicBarrier",
"for",
"the",
"constraints",
":",
"<br",
">",
"fi",
"(",
"X",
")",
"-",
"s",
"i",
"=",
"1",
"...",
"n"
] | train | https://github.com/vincentk/joptimizer/blob/65064c1bb0b26c7261358021e4c93d06dd43564f/src/main/java/com/joptimizer/functions/LogarithmicBarrier.java#L108-L161 |
Impetus/Kundera | src/jpa-engine/core/src/main/java/com/impetus/kundera/metadata/model/type/AbstractManagedType.java | AbstractManagedType.onCheckListAttribute | private <E> boolean onCheckListAttribute(PluralAttribute<? super X, ?, ?> pluralAttribute, Class<E> paramClass) {
"""
On check list attribute.
@param <E>
the element type
@param pluralAttribute
the plural attribute
@param paramClass
the param class
@return true, if successful
"""
if (pluralAttribute != null)
{
if (isListAttribute(pluralAttribute) && isBindable(pluralAttribute, paramClass))
{
return true;
}
}
return false;
} | java | private <E> boolean onCheckListAttribute(PluralAttribute<? super X, ?, ?> pluralAttribute, Class<E> paramClass)
{
if (pluralAttribute != null)
{
if (isListAttribute(pluralAttribute) && isBindable(pluralAttribute, paramClass))
{
return true;
}
}
return false;
} | [
"private",
"<",
"E",
">",
"boolean",
"onCheckListAttribute",
"(",
"PluralAttribute",
"<",
"?",
"super",
"X",
",",
"?",
",",
"?",
">",
"pluralAttribute",
",",
"Class",
"<",
"E",
">",
"paramClass",
")",
"{",
"if",
"(",
"pluralAttribute",
"!=",
"null",
")",
"{",
"if",
"(",
"isListAttribute",
"(",
"pluralAttribute",
")",
"&&",
"isBindable",
"(",
"pluralAttribute",
",",
"paramClass",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | On check list attribute.
@param <E>
the element type
@param pluralAttribute
the plural attribute
@param paramClass
the param class
@return true, if successful | [
"On",
"check",
"list",
"attribute",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/metadata/model/type/AbstractManagedType.java#L981-L993 |
brettwooldridge/SansOrm | src/main/java/com/zaxxer/sansorm/OrmElf.java | OrmElf.updateObject | public static <T> T updateObject(Connection connection, T target) throws SQLException {
"""
Update a database row using the specified annotated object, the @Id field(s) is used in the WHERE
clause of the generated UPDATE statement.
@param connection a SQL connection
@param target the annotated object to use to update a row in the database
@param <T> the class template
@return the same object passed in
@throws SQLException if a {@link SQLException} occurs
"""
return OrmWriter.updateObject(connection, target);
} | java | public static <T> T updateObject(Connection connection, T target) throws SQLException
{
return OrmWriter.updateObject(connection, target);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"updateObject",
"(",
"Connection",
"connection",
",",
"T",
"target",
")",
"throws",
"SQLException",
"{",
"return",
"OrmWriter",
".",
"updateObject",
"(",
"connection",
",",
"target",
")",
";",
"}"
] | Update a database row using the specified annotated object, the @Id field(s) is used in the WHERE
clause of the generated UPDATE statement.
@param connection a SQL connection
@param target the annotated object to use to update a row in the database
@param <T> the class template
@return the same object passed in
@throws SQLException if a {@link SQLException} occurs | [
"Update",
"a",
"database",
"row",
"using",
"the",
"specified",
"annotated",
"object",
"the",
"@Id",
"field",
"(",
"s",
")",
"is",
"used",
"in",
"the",
"WHERE",
"clause",
"of",
"the",
"generated",
"UPDATE",
"statement",
"."
] | train | https://github.com/brettwooldridge/SansOrm/blob/ab22721db79c5f20c0e8483f09eda2844d596557/src/main/java/com/zaxxer/sansorm/OrmElf.java#L262-L265 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/search/bingvisualsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/visualsearch/implementation/BingImagesImpl.java | BingImagesImpl.visualSearchAsync | public ServiceFuture<ImageKnowledge> visualSearchAsync(VisualSearchOptionalParameter visualSearchOptionalParameter, final ServiceCallback<ImageKnowledge> serviceCallback) {
"""
Visual Search API lets you discover insights about an image such as visually similar images, shopping sources, and related searches. The API can also perform text recognition, identify entities (people, places, things), return other topical content for the user to explore, and more. For more information, see [Visual Search Overview](https://docs.microsoft.com/azure/cognitive-services/bing-visual-search/overview).
@param visualSearchOptionalParameter the object representing the optional parameters to be set before calling this API
@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(visualSearchWithServiceResponseAsync(visualSearchOptionalParameter), serviceCallback);
} | java | public ServiceFuture<ImageKnowledge> visualSearchAsync(VisualSearchOptionalParameter visualSearchOptionalParameter, final ServiceCallback<ImageKnowledge> serviceCallback) {
return ServiceFuture.fromResponse(visualSearchWithServiceResponseAsync(visualSearchOptionalParameter), serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"ImageKnowledge",
">",
"visualSearchAsync",
"(",
"VisualSearchOptionalParameter",
"visualSearchOptionalParameter",
",",
"final",
"ServiceCallback",
"<",
"ImageKnowledge",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"visualSearchWithServiceResponseAsync",
"(",
"visualSearchOptionalParameter",
")",
",",
"serviceCallback",
")",
";",
"}"
] | Visual Search API lets you discover insights about an image such as visually similar images, shopping sources, and related searches. The API can also perform text recognition, identify entities (people, places, things), return other topical content for the user to explore, and more. For more information, see [Visual Search Overview](https://docs.microsoft.com/azure/cognitive-services/bing-visual-search/overview).
@param visualSearchOptionalParameter the object representing the optional parameters to be set before calling this API
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object | [
"Visual",
"Search",
"API",
"lets",
"you",
"discover",
"insights",
"about",
"an",
"image",
"such",
"as",
"visually",
"similar",
"images",
"shopping",
"sources",
"and",
"related",
"searches",
".",
"The",
"API",
"can",
"also",
"perform",
"text",
"recognition",
"identify",
"entities",
"(",
"people",
"places",
"things",
")",
"return",
"other",
"topical",
"content",
"for",
"the",
"user",
"to",
"explore",
"and",
"more",
".",
"For",
"more",
"information",
"see",
"[",
"Visual",
"Search",
"Overview",
"]",
"(",
"https",
":",
"//",
"docs",
".",
"microsoft",
".",
"com",
"/",
"azure",
"/",
"cognitive",
"-",
"services",
"/",
"bing",
"-",
"visual",
"-",
"search",
"/",
"overview",
")",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/search/bingvisualsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/visualsearch/implementation/BingImagesImpl.java#L86-L88 |
umeding/fuzzer | src/main/java/com/uwemeding/fuzzer/Program.java | Program.addItem | private <T extends NameBearer> void addItem(T item, Map<String, T> items, String typeName) {
"""
Add an item to a map.
<p>
@param <T> the item type
@param item the item
@param items the item map
@param typeName the item type name string
"""
String itemName = item.getName();
if (items.containsKey(itemName)) {
throw new FuzzerException(name + ": '" + itemName + "' already present in " + typeName);
}
items.put(itemName, item);
} | java | private <T extends NameBearer> void addItem(T item, Map<String, T> items, String typeName) {
String itemName = item.getName();
if (items.containsKey(itemName)) {
throw new FuzzerException(name + ": '" + itemName + "' already present in " + typeName);
}
items.put(itemName, item);
} | [
"private",
"<",
"T",
"extends",
"NameBearer",
">",
"void",
"addItem",
"(",
"T",
"item",
",",
"Map",
"<",
"String",
",",
"T",
">",
"items",
",",
"String",
"typeName",
")",
"{",
"String",
"itemName",
"=",
"item",
".",
"getName",
"(",
")",
";",
"if",
"(",
"items",
".",
"containsKey",
"(",
"itemName",
")",
")",
"{",
"throw",
"new",
"FuzzerException",
"(",
"name",
"+",
"\": '\"",
"+",
"itemName",
"+",
"\"' already present in \"",
"+",
"typeName",
")",
";",
"}",
"items",
".",
"put",
"(",
"itemName",
",",
"item",
")",
";",
"}"
] | Add an item to a map.
<p>
@param <T> the item type
@param item the item
@param items the item map
@param typeName the item type name string | [
"Add",
"an",
"item",
"to",
"a",
"map",
".",
"<p",
">"
] | train | https://github.com/umeding/fuzzer/blob/e8aa46313bb1d1328865f26f99455124aede828c/src/main/java/com/uwemeding/fuzzer/Program.java#L385-L391 |
alkacon/opencms-core | src/org/opencms/ui/apps/scheduler/CmsJobEditView.java | CmsJobEditView.bindField | void bindField(AbstractField<?> field, String property) {
"""
Binds the given component to the given bean property.<p>
@param field the component
@param property the bean property
"""
m_group.bind(field, property);
field.setCaption(CmsVaadinUtils.getMessageText("label." + property));
field.setDescription(CmsVaadinUtils.getMessageText("label." + property + ".help"));
} | java | void bindField(AbstractField<?> field, String property) {
m_group.bind(field, property);
field.setCaption(CmsVaadinUtils.getMessageText("label." + property));
field.setDescription(CmsVaadinUtils.getMessageText("label." + property + ".help"));
} | [
"void",
"bindField",
"(",
"AbstractField",
"<",
"?",
">",
"field",
",",
"String",
"property",
")",
"{",
"m_group",
".",
"bind",
"(",
"field",
",",
"property",
")",
";",
"field",
".",
"setCaption",
"(",
"CmsVaadinUtils",
".",
"getMessageText",
"(",
"\"label.\"",
"+",
"property",
")",
")",
";",
"field",
".",
"setDescription",
"(",
"CmsVaadinUtils",
".",
"getMessageText",
"(",
"\"label.\"",
"+",
"property",
"+",
"\".help\"",
")",
")",
";",
"}"
] | Binds the given component to the given bean property.<p>
@param field the component
@param property the bean property | [
"Binds",
"the",
"given",
"component",
"to",
"the",
"given",
"bean",
"property",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/scheduler/CmsJobEditView.java#L449-L455 |
Claudenw/junit-contracts | junit/src/main/java/org/xenei/junit/contract/ContractSuite.java | ContractSuite.addSpecifiedClasses | private void addSpecifiedClasses(final List<Runner> runners, final Class<?> testClass, final RunnerBuilder builder,
final ContractTestMap contractTestMap, final Object baseObj, final TestInfo parentTestInfo)
throws InitializationError {
"""
Adds the specified classes to to the test suite.
May add error notations to the parentTestInfo.
@param runners
The list of runners to add the test to
@param testClass
The class under test
@param builder
The builder to user
@param errors
The list of errors.
@param contractTestMap
The ContractTestMap
@param baseObj
The object under test
@param parentTestInfo
The parent test Info.
@throws InitializationError
"""
// this is the list of all the JUnit runners in the suite.
final Set<TestInfo> testClasses = new LinkedHashSet<TestInfo>();
// we have a RunWith annotated class: Klass
// see if it is in the annotatedClasses
final BaseClassRunner bcr = new BaseClassRunner( testClass );
if (bcr.computeTestMethods().size() > 0) {
runners.add( bcr );
}
final List<Method> excludeMethods = getExcludedMethods( getTestClass().getJavaClass() );
/*
* get all the annotated classes that test the interfaces that
* parentTestInfo implements and iterate over them
*/
for (final TestInfo testInfo : contractTestMap.getAnnotatedClasses( testClasses, parentTestInfo )) {
if (!Arrays.asList( parentTestInfo.getSkipTests() ).contains( testInfo.getClassUnderTest() )) {
if (testInfo.getErrors().size() > 0) {
final TestInfoErrorRunner runner = new TestInfoErrorRunner( testClass, testInfo );
runner.logErrors( LOG );
runners.add( runner );
} else {
runners.add( new ContractTestRunner( baseObj, parentTestInfo, testInfo, excludeMethods ) );
}
}
}
if (runners.size() == 0) {
LOG.info( "No tests for " + testClass );
}
} | java | private void addSpecifiedClasses(final List<Runner> runners, final Class<?> testClass, final RunnerBuilder builder,
final ContractTestMap contractTestMap, final Object baseObj, final TestInfo parentTestInfo)
throws InitializationError {
// this is the list of all the JUnit runners in the suite.
final Set<TestInfo> testClasses = new LinkedHashSet<TestInfo>();
// we have a RunWith annotated class: Klass
// see if it is in the annotatedClasses
final BaseClassRunner bcr = new BaseClassRunner( testClass );
if (bcr.computeTestMethods().size() > 0) {
runners.add( bcr );
}
final List<Method> excludeMethods = getExcludedMethods( getTestClass().getJavaClass() );
/*
* get all the annotated classes that test the interfaces that
* parentTestInfo implements and iterate over them
*/
for (final TestInfo testInfo : contractTestMap.getAnnotatedClasses( testClasses, parentTestInfo )) {
if (!Arrays.asList( parentTestInfo.getSkipTests() ).contains( testInfo.getClassUnderTest() )) {
if (testInfo.getErrors().size() > 0) {
final TestInfoErrorRunner runner = new TestInfoErrorRunner( testClass, testInfo );
runner.logErrors( LOG );
runners.add( runner );
} else {
runners.add( new ContractTestRunner( baseObj, parentTestInfo, testInfo, excludeMethods ) );
}
}
}
if (runners.size() == 0) {
LOG.info( "No tests for " + testClass );
}
} | [
"private",
"void",
"addSpecifiedClasses",
"(",
"final",
"List",
"<",
"Runner",
">",
"runners",
",",
"final",
"Class",
"<",
"?",
">",
"testClass",
",",
"final",
"RunnerBuilder",
"builder",
",",
"final",
"ContractTestMap",
"contractTestMap",
",",
"final",
"Object",
"baseObj",
",",
"final",
"TestInfo",
"parentTestInfo",
")",
"throws",
"InitializationError",
"{",
"// this is the list of all the JUnit runners in the suite.",
"final",
"Set",
"<",
"TestInfo",
">",
"testClasses",
"=",
"new",
"LinkedHashSet",
"<",
"TestInfo",
">",
"(",
")",
";",
"// we have a RunWith annotated class: Klass",
"// see if it is in the annotatedClasses",
"final",
"BaseClassRunner",
"bcr",
"=",
"new",
"BaseClassRunner",
"(",
"testClass",
")",
";",
"if",
"(",
"bcr",
".",
"computeTestMethods",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"runners",
".",
"add",
"(",
"bcr",
")",
";",
"}",
"final",
"List",
"<",
"Method",
">",
"excludeMethods",
"=",
"getExcludedMethods",
"(",
"getTestClass",
"(",
")",
".",
"getJavaClass",
"(",
")",
")",
";",
"/*\n * get all the annotated classes that test the interfaces that\n * parentTestInfo implements and iterate over them\n */",
"for",
"(",
"final",
"TestInfo",
"testInfo",
":",
"contractTestMap",
".",
"getAnnotatedClasses",
"(",
"testClasses",
",",
"parentTestInfo",
")",
")",
"{",
"if",
"(",
"!",
"Arrays",
".",
"asList",
"(",
"parentTestInfo",
".",
"getSkipTests",
"(",
")",
")",
".",
"contains",
"(",
"testInfo",
".",
"getClassUnderTest",
"(",
")",
")",
")",
"{",
"if",
"(",
"testInfo",
".",
"getErrors",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"final",
"TestInfoErrorRunner",
"runner",
"=",
"new",
"TestInfoErrorRunner",
"(",
"testClass",
",",
"testInfo",
")",
";",
"runner",
".",
"logErrors",
"(",
"LOG",
")",
";",
"runners",
".",
"add",
"(",
"runner",
")",
";",
"}",
"else",
"{",
"runners",
".",
"add",
"(",
"new",
"ContractTestRunner",
"(",
"baseObj",
",",
"parentTestInfo",
",",
"testInfo",
",",
"excludeMethods",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"runners",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"LOG",
".",
"info",
"(",
"\"No tests for \"",
"+",
"testClass",
")",
";",
"}",
"}"
] | Adds the specified classes to to the test suite.
May add error notations to the parentTestInfo.
@param runners
The list of runners to add the test to
@param testClass
The class under test
@param builder
The builder to user
@param errors
The list of errors.
@param contractTestMap
The ContractTestMap
@param baseObj
The object under test
@param parentTestInfo
The parent test Info.
@throws InitializationError | [
"Adds",
"the",
"specified",
"classes",
"to",
"to",
"the",
"test",
"suite",
"."
] | train | https://github.com/Claudenw/junit-contracts/blob/47e7294dbff374cdd875b3aafe28db48a37fe4d4/junit/src/main/java/org/xenei/junit/contract/ContractSuite.java#L312-L350 |
deeplearning4j/deeplearning4j | datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/csv/SerializableCSVParser.java | SerializableCSVParser.isNextCharacterEscapedQuote | private boolean isNextCharacterEscapedQuote(String nextLine, boolean inQuotes, int i) {
"""
precondition: the current character is a quote or an escape
@param nextLine the current line
@param inQuotes true if the current context is quoted
@param i current index in line
@return true if the following character is a quote
"""
return inQuotes // we are in quotes, therefore there can be escaped quotes in here.
&& nextLine.length() > (i + 1) // there is indeed another character to check.
&& nextLine.charAt(i + 1) == quotechar;
} | java | private boolean isNextCharacterEscapedQuote(String nextLine, boolean inQuotes, int i) {
return inQuotes // we are in quotes, therefore there can be escaped quotes in here.
&& nextLine.length() > (i + 1) // there is indeed another character to check.
&& nextLine.charAt(i + 1) == quotechar;
} | [
"private",
"boolean",
"isNextCharacterEscapedQuote",
"(",
"String",
"nextLine",
",",
"boolean",
"inQuotes",
",",
"int",
"i",
")",
"{",
"return",
"inQuotes",
"// we are in quotes, therefore there can be escaped quotes in here.",
"&&",
"nextLine",
".",
"length",
"(",
")",
">",
"(",
"i",
"+",
"1",
")",
"// there is indeed another character to check.",
"&&",
"nextLine",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
"==",
"quotechar",
";",
"}"
] | precondition: the current character is a quote or an escape
@param nextLine the current line
@param inQuotes true if the current context is quoted
@param i current index in line
@return true if the following character is a quote | [
"precondition",
":",
"the",
"current",
"character",
"is",
"a",
"quote",
"or",
"an",
"escape"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/csv/SerializableCSVParser.java#L294-L298 |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/Boot.java | Boot.startJanusWithModuleType | public static Kernel startJanusWithModuleType(Class<? extends Module> platformModule, Class<? extends Agent> agentCls, Object... params)
throws Exception {
"""
Launch the Janus kernel and the first agent in the kernel.
<p>Thus function does not parse the command line. See {@link #main(String[])} for the command line management. When this
function is called, it is assumed that all the system's properties are correctly set.
<p>The platformModule parameter permits to specify the injection module to use. The injection module is in change of
creating/injecting all the components of the platform. The default injection module is retreived from the system property
with the name stored in {@link JanusConfig#INJECTION_MODULE_NAME}. The default type for the injection module is stored in
the constant {@link JanusConfig#INJECTION_MODULE_NAME_VALUE}.
<p>The function {@link #getBootAgentIdentifier()} permits to retreive the identifier of the launched agent.
@param platformModule type of the injection module to use for initializing the platform, if <code>null</code> the default
module will be used.
@param agentCls type of the first agent to launch.
@param params parameters to pass to the agent as its initliazation parameters.
@return the kernel that was launched.
@throws Exception - if it is impossible to start the platform.
@since 0.5
@see #main(String[])
@see #getBootAgentIdentifier()
"""
Class<? extends Module> startupModule = platformModule;
if (startupModule == null) {
startupModule = JanusConfig.getSystemPropertyAsClass(Module.class, JanusConfig.INJECTION_MODULE_NAME,
JanusConfig.INJECTION_MODULE_NAME_VALUE);
}
assert startupModule != null : "No platform injection module"; //$NON-NLS-1$
return startJanusWithModule(startupModule.newInstance(), agentCls, params);
} | java | public static Kernel startJanusWithModuleType(Class<? extends Module> platformModule, Class<? extends Agent> agentCls, Object... params)
throws Exception {
Class<? extends Module> startupModule = platformModule;
if (startupModule == null) {
startupModule = JanusConfig.getSystemPropertyAsClass(Module.class, JanusConfig.INJECTION_MODULE_NAME,
JanusConfig.INJECTION_MODULE_NAME_VALUE);
}
assert startupModule != null : "No platform injection module"; //$NON-NLS-1$
return startJanusWithModule(startupModule.newInstance(), agentCls, params);
} | [
"public",
"static",
"Kernel",
"startJanusWithModuleType",
"(",
"Class",
"<",
"?",
"extends",
"Module",
">",
"platformModule",
",",
"Class",
"<",
"?",
"extends",
"Agent",
">",
"agentCls",
",",
"Object",
"...",
"params",
")",
"throws",
"Exception",
"{",
"Class",
"<",
"?",
"extends",
"Module",
">",
"startupModule",
"=",
"platformModule",
";",
"if",
"(",
"startupModule",
"==",
"null",
")",
"{",
"startupModule",
"=",
"JanusConfig",
".",
"getSystemPropertyAsClass",
"(",
"Module",
".",
"class",
",",
"JanusConfig",
".",
"INJECTION_MODULE_NAME",
",",
"JanusConfig",
".",
"INJECTION_MODULE_NAME_VALUE",
")",
";",
"}",
"assert",
"startupModule",
"!=",
"null",
":",
"\"No platform injection module\"",
";",
"//$NON-NLS-1$",
"return",
"startJanusWithModule",
"(",
"startupModule",
".",
"newInstance",
"(",
")",
",",
"agentCls",
",",
"params",
")",
";",
"}"
] | Launch the Janus kernel and the first agent in the kernel.
<p>Thus function does not parse the command line. See {@link #main(String[])} for the command line management. When this
function is called, it is assumed that all the system's properties are correctly set.
<p>The platformModule parameter permits to specify the injection module to use. The injection module is in change of
creating/injecting all the components of the platform. The default injection module is retreived from the system property
with the name stored in {@link JanusConfig#INJECTION_MODULE_NAME}. The default type for the injection module is stored in
the constant {@link JanusConfig#INJECTION_MODULE_NAME_VALUE}.
<p>The function {@link #getBootAgentIdentifier()} permits to retreive the identifier of the launched agent.
@param platformModule type of the injection module to use for initializing the platform, if <code>null</code> the default
module will be used.
@param agentCls type of the first agent to launch.
@param params parameters to pass to the agent as its initliazation parameters.
@return the kernel that was launched.
@throws Exception - if it is impossible to start the platform.
@since 0.5
@see #main(String[])
@see #getBootAgentIdentifier() | [
"Launch",
"the",
"Janus",
"kernel",
"and",
"the",
"first",
"agent",
"in",
"the",
"kernel",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/Boot.java#L950-L959 |
wcm-io/wcm-io-handler | commons/src/main/java/io/wcm/handler/commons/dom/AbstractHtmlElementFactory.java | AbstractHtmlElementFactory.createImage | public Image createImage(String src, int width, int height) {
"""
Creates and adds imgage (img) element.
@param src Html "src" attribute.
@param width Html "width" attribute.
@param height Html "height" attribute.
@return Html element.
"""
return this.add(new Image(src, width, height));
} | java | public Image createImage(String src, int width, int height) {
return this.add(new Image(src, width, height));
} | [
"public",
"Image",
"createImage",
"(",
"String",
"src",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"return",
"this",
".",
"add",
"(",
"new",
"Image",
"(",
"src",
",",
"width",
",",
"height",
")",
")",
";",
"}"
] | Creates and adds imgage (img) element.
@param src Html "src" attribute.
@param width Html "width" attribute.
@param height Html "height" attribute.
@return Html element. | [
"Creates",
"and",
"adds",
"imgage",
"(",
"img",
")",
"element",
"."
] | train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/commons/src/main/java/io/wcm/handler/commons/dom/AbstractHtmlElementFactory.java#L148-L150 |
maestrano/maestrano-java | src/main/java/com/maestrano/net/MnoHttpClient.java | MnoHttpClient.delete | public String delete(String url) throws AuthenticationException, ApiException {
"""
Perform a PUT request on the specified endpoint
@param url
@param header
@param payload
@return response body
@throws ApiException
@throws AuthenticationException
"""
return performRequest(url, "DELETE", null, null, null);
} | java | public String delete(String url) throws AuthenticationException, ApiException {
return performRequest(url, "DELETE", null, null, null);
} | [
"public",
"String",
"delete",
"(",
"String",
"url",
")",
"throws",
"AuthenticationException",
",",
"ApiException",
"{",
"return",
"performRequest",
"(",
"url",
",",
"\"DELETE\"",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}"
] | Perform a PUT request on the specified endpoint
@param url
@param header
@param payload
@return response body
@throws ApiException
@throws AuthenticationException | [
"Perform",
"a",
"PUT",
"request",
"on",
"the",
"specified",
"endpoint"
] | train | https://github.com/maestrano/maestrano-java/blob/e71c6d3172d7645529d678d1cb3ea9e0a59de314/src/main/java/com/maestrano/net/MnoHttpClient.java#L145-L147 |
OpenLiberty/open-liberty | dev/com.ibm.ws.cdi.weld/src/com/ibm/ws/cdi/impl/CDIContainerImpl.java | CDIContainerImpl.createWebSphereCDIDeployment | private WebSphereCDIDeployment createWebSphereCDIDeployment(Application application,
Set<ExtensionArchive> extensionArchives) throws CDIException {
"""
This method creates the Deployment structure with all it's BDAs.
@param application
@param extensionArchives
@return
@throws CDIException
"""
WebSphereCDIDeployment webSphereCDIDeployment = new WebSphereCDIDeploymentImpl(application, cdiRuntime);
DiscoveredBdas discoveredBdas = new DiscoveredBdas(webSphereCDIDeployment);
if (application.hasModules()) {
Collection<CDIArchive> libraryArchives = application.getLibraryArchives();
Collection<CDIArchive> moduleArchives = application.getModuleArchives();
ClassLoader applicationClassLoader = application.getClassLoader();
webSphereCDIDeployment.setClassLoader(applicationClassLoader);
processLibraries(webSphereCDIDeployment,
discoveredBdas,
libraryArchives);
processModules(webSphereCDIDeployment,
discoveredBdas,
moduleArchives);
//discoveredBdas has the full map, let's go through them all to make sure the wire is complete
discoveredBdas.makeCrossBoundaryWiring();
//and finally the runtime extensions
addRuntimeExtensions(webSphereCDIDeployment,
discoveredBdas);
}
return webSphereCDIDeployment;
} | java | private WebSphereCDIDeployment createWebSphereCDIDeployment(Application application,
Set<ExtensionArchive> extensionArchives) throws CDIException {
WebSphereCDIDeployment webSphereCDIDeployment = new WebSphereCDIDeploymentImpl(application, cdiRuntime);
DiscoveredBdas discoveredBdas = new DiscoveredBdas(webSphereCDIDeployment);
if (application.hasModules()) {
Collection<CDIArchive> libraryArchives = application.getLibraryArchives();
Collection<CDIArchive> moduleArchives = application.getModuleArchives();
ClassLoader applicationClassLoader = application.getClassLoader();
webSphereCDIDeployment.setClassLoader(applicationClassLoader);
processLibraries(webSphereCDIDeployment,
discoveredBdas,
libraryArchives);
processModules(webSphereCDIDeployment,
discoveredBdas,
moduleArchives);
//discoveredBdas has the full map, let's go through them all to make sure the wire is complete
discoveredBdas.makeCrossBoundaryWiring();
//and finally the runtime extensions
addRuntimeExtensions(webSphereCDIDeployment,
discoveredBdas);
}
return webSphereCDIDeployment;
} | [
"private",
"WebSphereCDIDeployment",
"createWebSphereCDIDeployment",
"(",
"Application",
"application",
",",
"Set",
"<",
"ExtensionArchive",
">",
"extensionArchives",
")",
"throws",
"CDIException",
"{",
"WebSphereCDIDeployment",
"webSphereCDIDeployment",
"=",
"new",
"WebSphereCDIDeploymentImpl",
"(",
"application",
",",
"cdiRuntime",
")",
";",
"DiscoveredBdas",
"discoveredBdas",
"=",
"new",
"DiscoveredBdas",
"(",
"webSphereCDIDeployment",
")",
";",
"if",
"(",
"application",
".",
"hasModules",
"(",
")",
")",
"{",
"Collection",
"<",
"CDIArchive",
">",
"libraryArchives",
"=",
"application",
".",
"getLibraryArchives",
"(",
")",
";",
"Collection",
"<",
"CDIArchive",
">",
"moduleArchives",
"=",
"application",
".",
"getModuleArchives",
"(",
")",
";",
"ClassLoader",
"applicationClassLoader",
"=",
"application",
".",
"getClassLoader",
"(",
")",
";",
"webSphereCDIDeployment",
".",
"setClassLoader",
"(",
"applicationClassLoader",
")",
";",
"processLibraries",
"(",
"webSphereCDIDeployment",
",",
"discoveredBdas",
",",
"libraryArchives",
")",
";",
"processModules",
"(",
"webSphereCDIDeployment",
",",
"discoveredBdas",
",",
"moduleArchives",
")",
";",
"//discoveredBdas has the full map, let's go through them all to make sure the wire is complete",
"discoveredBdas",
".",
"makeCrossBoundaryWiring",
"(",
")",
";",
"//and finally the runtime extensions",
"addRuntimeExtensions",
"(",
"webSphereCDIDeployment",
",",
"discoveredBdas",
")",
";",
"}",
"return",
"webSphereCDIDeployment",
";",
"}"
] | This method creates the Deployment structure with all it's BDAs.
@param application
@param extensionArchives
@return
@throws CDIException | [
"This",
"method",
"creates",
"the",
"Deployment",
"structure",
"with",
"all",
"it",
"s",
"BDAs",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.cdi.weld/src/com/ibm/ws/cdi/impl/CDIContainerImpl.java#L200-L231 |
damianszczepanik/cucumber-reporting | src/main/java/net/masterthought/cucumber/Trends.java | Trends.addBuild | public void addBuild(String buildNumber, Reportable reportable) {
"""
Adds build into the trends.
@param buildNumber number of the build
@param reportable stats for the generated report
"""
buildNumbers = (String[]) ArrayUtils.add(buildNumbers, buildNumber);
passedFeatures = ArrayUtils.add(passedFeatures, reportable.getPassedFeatures());
failedFeatures = ArrayUtils.add(failedFeatures, reportable.getFailedFeatures());
totalFeatures = ArrayUtils.add(totalFeatures, reportable.getFeatures());
passedScenarios = ArrayUtils.add(passedScenarios, reportable.getPassedScenarios());
failedScenarios = ArrayUtils.add(failedScenarios, reportable.getFailedScenarios());
totalScenarios = ArrayUtils.add(totalScenarios, reportable.getScenarios());
passedSteps = ArrayUtils.add(passedSteps, reportable.getPassedSteps());
failedSteps = ArrayUtils.add(failedSteps, reportable.getFailedSteps());
skippedSteps = ArrayUtils.add(skippedSteps, reportable.getSkippedSteps());
pendingSteps = ArrayUtils.add(pendingSteps, reportable.getPendingSteps());
undefinedSteps = ArrayUtils.add(undefinedSteps, reportable.getUndefinedSteps());
totalSteps = ArrayUtils.add(totalSteps, reportable.getSteps());
durations = ArrayUtils.add(durations, reportable.getDuration());
// this should be removed later but for now correct features and save valid data
applyPatchForFeatures();
if (pendingSteps.length < buildNumbers.length) {
fillMissingSteps();
}
if (durations.length < buildNumbers.length) {
fillMissingDurations();
}
} | java | public void addBuild(String buildNumber, Reportable reportable) {
buildNumbers = (String[]) ArrayUtils.add(buildNumbers, buildNumber);
passedFeatures = ArrayUtils.add(passedFeatures, reportable.getPassedFeatures());
failedFeatures = ArrayUtils.add(failedFeatures, reportable.getFailedFeatures());
totalFeatures = ArrayUtils.add(totalFeatures, reportable.getFeatures());
passedScenarios = ArrayUtils.add(passedScenarios, reportable.getPassedScenarios());
failedScenarios = ArrayUtils.add(failedScenarios, reportable.getFailedScenarios());
totalScenarios = ArrayUtils.add(totalScenarios, reportable.getScenarios());
passedSteps = ArrayUtils.add(passedSteps, reportable.getPassedSteps());
failedSteps = ArrayUtils.add(failedSteps, reportable.getFailedSteps());
skippedSteps = ArrayUtils.add(skippedSteps, reportable.getSkippedSteps());
pendingSteps = ArrayUtils.add(pendingSteps, reportable.getPendingSteps());
undefinedSteps = ArrayUtils.add(undefinedSteps, reportable.getUndefinedSteps());
totalSteps = ArrayUtils.add(totalSteps, reportable.getSteps());
durations = ArrayUtils.add(durations, reportable.getDuration());
// this should be removed later but for now correct features and save valid data
applyPatchForFeatures();
if (pendingSteps.length < buildNumbers.length) {
fillMissingSteps();
}
if (durations.length < buildNumbers.length) {
fillMissingDurations();
}
} | [
"public",
"void",
"addBuild",
"(",
"String",
"buildNumber",
",",
"Reportable",
"reportable",
")",
"{",
"buildNumbers",
"=",
"(",
"String",
"[",
"]",
")",
"ArrayUtils",
".",
"add",
"(",
"buildNumbers",
",",
"buildNumber",
")",
";",
"passedFeatures",
"=",
"ArrayUtils",
".",
"add",
"(",
"passedFeatures",
",",
"reportable",
".",
"getPassedFeatures",
"(",
")",
")",
";",
"failedFeatures",
"=",
"ArrayUtils",
".",
"add",
"(",
"failedFeatures",
",",
"reportable",
".",
"getFailedFeatures",
"(",
")",
")",
";",
"totalFeatures",
"=",
"ArrayUtils",
".",
"add",
"(",
"totalFeatures",
",",
"reportable",
".",
"getFeatures",
"(",
")",
")",
";",
"passedScenarios",
"=",
"ArrayUtils",
".",
"add",
"(",
"passedScenarios",
",",
"reportable",
".",
"getPassedScenarios",
"(",
")",
")",
";",
"failedScenarios",
"=",
"ArrayUtils",
".",
"add",
"(",
"failedScenarios",
",",
"reportable",
".",
"getFailedScenarios",
"(",
")",
")",
";",
"totalScenarios",
"=",
"ArrayUtils",
".",
"add",
"(",
"totalScenarios",
",",
"reportable",
".",
"getScenarios",
"(",
")",
")",
";",
"passedSteps",
"=",
"ArrayUtils",
".",
"add",
"(",
"passedSteps",
",",
"reportable",
".",
"getPassedSteps",
"(",
")",
")",
";",
"failedSteps",
"=",
"ArrayUtils",
".",
"add",
"(",
"failedSteps",
",",
"reportable",
".",
"getFailedSteps",
"(",
")",
")",
";",
"skippedSteps",
"=",
"ArrayUtils",
".",
"add",
"(",
"skippedSteps",
",",
"reportable",
".",
"getSkippedSteps",
"(",
")",
")",
";",
"pendingSteps",
"=",
"ArrayUtils",
".",
"add",
"(",
"pendingSteps",
",",
"reportable",
".",
"getPendingSteps",
"(",
")",
")",
";",
"undefinedSteps",
"=",
"ArrayUtils",
".",
"add",
"(",
"undefinedSteps",
",",
"reportable",
".",
"getUndefinedSteps",
"(",
")",
")",
";",
"totalSteps",
"=",
"ArrayUtils",
".",
"add",
"(",
"totalSteps",
",",
"reportable",
".",
"getSteps",
"(",
")",
")",
";",
"durations",
"=",
"ArrayUtils",
".",
"add",
"(",
"durations",
",",
"reportable",
".",
"getDuration",
"(",
")",
")",
";",
"// this should be removed later but for now correct features and save valid data",
"applyPatchForFeatures",
"(",
")",
";",
"if",
"(",
"pendingSteps",
".",
"length",
"<",
"buildNumbers",
".",
"length",
")",
"{",
"fillMissingSteps",
"(",
")",
";",
"}",
"if",
"(",
"durations",
".",
"length",
"<",
"buildNumbers",
".",
"length",
")",
"{",
"fillMissingDurations",
"(",
")",
";",
"}",
"}"
] | Adds build into the trends.
@param buildNumber number of the build
@param reportable stats for the generated report | [
"Adds",
"build",
"into",
"the",
"trends",
"."
] | train | https://github.com/damianszczepanik/cucumber-reporting/blob/9ffe0d4a9c0aec161b0988a930a8312ba36dc742/src/main/java/net/masterthought/cucumber/Trends.java#L94-L123 |
hawkular/hawkular-inventory | hawkular-inventory-api/src/main/java/org/hawkular/inventory/base/Traversal.java | Traversal.inTx | protected <R> R inTx(TransactionPayload<R, BE> payload) {
"""
Runs the payload in transaction. It is the payload's responsibility to commit the transaction at some point
during its execution. If the payload throws an exception the transaction is automatically rolled back and
the exception rethrown.
<p>
<p><b>WARNING:</b> the payload might be called multiple times if the transaction it runs within fails. It is
therefore dangerous to keep any mutable state outside of the payload function that the function depends on.
@param payload the payload to execute in transaction
@param <R> the return type
@return the return value provided by the payload
"""
return inTx(context, payload);
} | java | protected <R> R inTx(TransactionPayload<R, BE> payload) {
return inTx(context, payload);
} | [
"protected",
"<",
"R",
">",
"R",
"inTx",
"(",
"TransactionPayload",
"<",
"R",
",",
"BE",
">",
"payload",
")",
"{",
"return",
"inTx",
"(",
"context",
",",
"payload",
")",
";",
"}"
] | Runs the payload in transaction. It is the payload's responsibility to commit the transaction at some point
during its execution. If the payload throws an exception the transaction is automatically rolled back and
the exception rethrown.
<p>
<p><b>WARNING:</b> the payload might be called multiple times if the transaction it runs within fails. It is
therefore dangerous to keep any mutable state outside of the payload function that the function depends on.
@param payload the payload to execute in transaction
@param <R> the return type
@return the return value provided by the payload | [
"Runs",
"the",
"payload",
"in",
"transaction",
".",
"It",
"is",
"the",
"payload",
"s",
"responsibility",
"to",
"commit",
"the",
"transaction",
"at",
"some",
"point",
"during",
"its",
"execution",
".",
"If",
"the",
"payload",
"throws",
"an",
"exception",
"the",
"transaction",
"is",
"automatically",
"rolled",
"back",
"and",
"the",
"exception",
"rethrown",
".",
"<p",
">",
"<p",
">",
"<b",
">",
"WARNING",
":",
"<",
"/",
"b",
">",
"the",
"payload",
"might",
"be",
"called",
"multiple",
"times",
"if",
"the",
"transaction",
"it",
"runs",
"within",
"fails",
".",
"It",
"is",
"therefore",
"dangerous",
"to",
"keep",
"any",
"mutable",
"state",
"outside",
"of",
"the",
"payload",
"function",
"that",
"the",
"function",
"depends",
"on",
"."
] | train | https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/base/Traversal.java#L78-L80 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java | HttpChannelConfig.parseIncomingHdrBufferSize | private void parseIncomingHdrBufferSize(Map<Object, Object> props) {
"""
Check the input configuration for the buffer size to use when parsing
the incoming headers.
@param props
"""
Object value = props.get(HttpConfigConstants.PROPNAME_INCOMING_HDR_BUFFSIZE);
if (null != value) {
try {
this.incomingHdrBuffSize = rangeLimit(convertInteger(value), HttpConfigConstants.MIN_BUFFER_SIZE, HttpConfigConstants.MAX_BUFFER_SIZE);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Incoming hdr buffer size is " + getIncomingHdrBufferSize());
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseIncomingHdrBufferSize", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid incoming hdr buffer size of " + value);
}
}
}
} | java | private void parseIncomingHdrBufferSize(Map<Object, Object> props) {
Object value = props.get(HttpConfigConstants.PROPNAME_INCOMING_HDR_BUFFSIZE);
if (null != value) {
try {
this.incomingHdrBuffSize = rangeLimit(convertInteger(value), HttpConfigConstants.MIN_BUFFER_SIZE, HttpConfigConstants.MAX_BUFFER_SIZE);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Incoming hdr buffer size is " + getIncomingHdrBufferSize());
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseIncomingHdrBufferSize", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid incoming hdr buffer size of " + value);
}
}
}
} | [
"private",
"void",
"parseIncomingHdrBufferSize",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"props",
")",
"{",
"Object",
"value",
"=",
"props",
".",
"get",
"(",
"HttpConfigConstants",
".",
"PROPNAME_INCOMING_HDR_BUFFSIZE",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"try",
"{",
"this",
".",
"incomingHdrBuffSize",
"=",
"rangeLimit",
"(",
"convertInteger",
"(",
"value",
")",
",",
"HttpConfigConstants",
".",
"MIN_BUFFER_SIZE",
",",
"HttpConfigConstants",
".",
"MAX_BUFFER_SIZE",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: Incoming hdr buffer size is \"",
"+",
"getIncomingHdrBufferSize",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"nfe",
",",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".parseIncomingHdrBufferSize\"",
",",
"\"1\"",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: Invalid incoming hdr buffer size of \"",
"+",
"value",
")",
";",
"}",
"}",
"}",
"}"
] | Check the input configuration for the buffer size to use when parsing
the incoming headers.
@param props | [
"Check",
"the",
"input",
"configuration",
"for",
"the",
"buffer",
"size",
"to",
"use",
"when",
"parsing",
"the",
"incoming",
"headers",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java#L589-L604 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2017_06_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2017_06_01_preview/implementation/ReplicationsInner.java | ReplicationsInner.getAsync | public Observable<ReplicationInner> getAsync(String resourceGroupName, String registryName, String replicationName) {
"""
Gets the properties of the specified replication.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param replicationName The name of the replication.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ReplicationInner object
"""
return getWithServiceResponseAsync(resourceGroupName, registryName, replicationName).map(new Func1<ServiceResponse<ReplicationInner>, ReplicationInner>() {
@Override
public ReplicationInner call(ServiceResponse<ReplicationInner> response) {
return response.body();
}
});
} | java | public Observable<ReplicationInner> getAsync(String resourceGroupName, String registryName, String replicationName) {
return getWithServiceResponseAsync(resourceGroupName, registryName, replicationName).map(new Func1<ServiceResponse<ReplicationInner>, ReplicationInner>() {
@Override
public ReplicationInner call(ServiceResponse<ReplicationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ReplicationInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"replicationName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"replicationName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ReplicationInner",
">",
",",
"ReplicationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ReplicationInner",
"call",
"(",
"ServiceResponse",
"<",
"ReplicationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the properties of the specified replication.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param replicationName The name of the replication.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ReplicationInner object | [
"Gets",
"the",
"properties",
"of",
"the",
"specified",
"replication",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2017_06_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2017_06_01_preview/implementation/ReplicationsInner.java#L143-L150 |
timols/java-gitlab-api | src/main/java/org/gitlab/api/GitlabAPI.java | GitlabAPI.deleteDiscussionNote | public void deleteDiscussionNote(GitlabMergeRequest mergeRequest, int discussionId, int noteId) throws IOException {
"""
Delete a discussion note of a merge request.
@param mergeRequest The merge request of the discussion.
@param discussionId The id of the discussion to resolve.
@param noteId The id of a discussion note.
@return The deleted note object.
@throws IOException on a GitLab api call error
"""
String tailUrl = GitlabProject.URL + "/" + mergeRequest.getProjectId() +
GitlabMergeRequest.URL + "/" + mergeRequest.getIid() +
GitlabDiscussion.URL + "/" + discussionId +
GitlabNote.URL + "/" + noteId;
retrieve().method(DELETE).to(tailUrl, Void.class);
} | java | public void deleteDiscussionNote(GitlabMergeRequest mergeRequest, int discussionId, int noteId) throws IOException {
String tailUrl = GitlabProject.URL + "/" + mergeRequest.getProjectId() +
GitlabMergeRequest.URL + "/" + mergeRequest.getIid() +
GitlabDiscussion.URL + "/" + discussionId +
GitlabNote.URL + "/" + noteId;
retrieve().method(DELETE).to(tailUrl, Void.class);
} | [
"public",
"void",
"deleteDiscussionNote",
"(",
"GitlabMergeRequest",
"mergeRequest",
",",
"int",
"discussionId",
",",
"int",
"noteId",
")",
"throws",
"IOException",
"{",
"String",
"tailUrl",
"=",
"GitlabProject",
".",
"URL",
"+",
"\"/\"",
"+",
"mergeRequest",
".",
"getProjectId",
"(",
")",
"+",
"GitlabMergeRequest",
".",
"URL",
"+",
"\"/\"",
"+",
"mergeRequest",
".",
"getIid",
"(",
")",
"+",
"GitlabDiscussion",
".",
"URL",
"+",
"\"/\"",
"+",
"discussionId",
"+",
"GitlabNote",
".",
"URL",
"+",
"\"/\"",
"+",
"noteId",
";",
"retrieve",
"(",
")",
".",
"method",
"(",
"DELETE",
")",
".",
"to",
"(",
"tailUrl",
",",
"Void",
".",
"class",
")",
";",
"}"
] | Delete a discussion note of a merge request.
@param mergeRequest The merge request of the discussion.
@param discussionId The id of the discussion to resolve.
@param noteId The id of a discussion note.
@return The deleted note object.
@throws IOException on a GitLab api call error | [
"Delete",
"a",
"discussion",
"note",
"of",
"a",
"merge",
"request",
"."
] | train | https://github.com/timols/java-gitlab-api/blob/f03eedf952cfbb40306be3bf9234dcf78fab029e/src/main/java/org/gitlab/api/GitlabAPI.java#L1951-L1957 |
revapi/revapi | revapi-java-spi/src/main/java/org/revapi/java/spi/Util.java | Util.findTypeByBinaryName | public static TypeElement findTypeByBinaryName(Elements elements, String binaryName) {
"""
Tries to find a type element using the provided Elements helper given its binary name. Note that this might NOT
be able to find some classes if there are conflicts in the canonical names (but that theoretically cannot happen
because the compiler should refuse to compile code with conflicting canonical names).
@param elements the elements instance to search the classpath
@param binaryName the binary name of the class
@return the type element with given binary name
"""
return findTypeByBinaryName(elements, new StringBuilder(binaryName));
} | java | public static TypeElement findTypeByBinaryName(Elements elements, String binaryName) {
return findTypeByBinaryName(elements, new StringBuilder(binaryName));
} | [
"public",
"static",
"TypeElement",
"findTypeByBinaryName",
"(",
"Elements",
"elements",
",",
"String",
"binaryName",
")",
"{",
"return",
"findTypeByBinaryName",
"(",
"elements",
",",
"new",
"StringBuilder",
"(",
"binaryName",
")",
")",
";",
"}"
] | Tries to find a type element using the provided Elements helper given its binary name. Note that this might NOT
be able to find some classes if there are conflicts in the canonical names (but that theoretically cannot happen
because the compiler should refuse to compile code with conflicting canonical names).
@param elements the elements instance to search the classpath
@param binaryName the binary name of the class
@return the type element with given binary name | [
"Tries",
"to",
"find",
"a",
"type",
"element",
"using",
"the",
"provided",
"Elements",
"helper",
"given",
"its",
"binary",
"name",
".",
"Note",
"that",
"this",
"might",
"NOT",
"be",
"able",
"to",
"find",
"some",
"classes",
"if",
"there",
"are",
"conflicts",
"in",
"the",
"canonical",
"names",
"(",
"but",
"that",
"theoretically",
"cannot",
"happen",
"because",
"the",
"compiler",
"should",
"refuse",
"to",
"compile",
"code",
"with",
"conflicting",
"canonical",
"names",
")",
"."
] | train | https://github.com/revapi/revapi/blob/e070b136d977441ab96fdce067a13e7e0423295b/revapi-java-spi/src/main/java/org/revapi/java/spi/Util.java#L1025-L1027 |
alibaba/canal | driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/server/ErrorPacket.java | ErrorPacket.fromBytes | public void fromBytes(byte[] data) {
"""
<pre>
VERSION 4.1
Bytes Name
----- ----
1 field_count, always = 0xff
2 errno
1 (sqlstate marker), always '#'
5 sqlstate (5 characters)
n message
</pre>
"""
int index = 0;
// 1. read field count
this.fieldCount = data[0];
index++;
// 2. read error no.
this.errorNumber = ByteHelper.readUnsignedShortLittleEndian(data, index);
index += 2;
// 3. read marker
this.sqlStateMarker = data[index];
index++;
// 4. read sqlState
this.sqlState = ByteHelper.readFixedLengthBytes(data, index, 5);
index += 5;
// 5. read message
this.message = new String(ByteHelper.readFixedLengthBytes(data, index, data.length - index));
// end read
} | java | public void fromBytes(byte[] data) {
int index = 0;
// 1. read field count
this.fieldCount = data[0];
index++;
// 2. read error no.
this.errorNumber = ByteHelper.readUnsignedShortLittleEndian(data, index);
index += 2;
// 3. read marker
this.sqlStateMarker = data[index];
index++;
// 4. read sqlState
this.sqlState = ByteHelper.readFixedLengthBytes(data, index, 5);
index += 5;
// 5. read message
this.message = new String(ByteHelper.readFixedLengthBytes(data, index, data.length - index));
// end read
} | [
"public",
"void",
"fromBytes",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"int",
"index",
"=",
"0",
";",
"// 1. read field count",
"this",
".",
"fieldCount",
"=",
"data",
"[",
"0",
"]",
";",
"index",
"++",
";",
"// 2. read error no.",
"this",
".",
"errorNumber",
"=",
"ByteHelper",
".",
"readUnsignedShortLittleEndian",
"(",
"data",
",",
"index",
")",
";",
"index",
"+=",
"2",
";",
"// 3. read marker",
"this",
".",
"sqlStateMarker",
"=",
"data",
"[",
"index",
"]",
";",
"index",
"++",
";",
"// 4. read sqlState",
"this",
".",
"sqlState",
"=",
"ByteHelper",
".",
"readFixedLengthBytes",
"(",
"data",
",",
"index",
",",
"5",
")",
";",
"index",
"+=",
"5",
";",
"// 5. read message",
"this",
".",
"message",
"=",
"new",
"String",
"(",
"ByteHelper",
".",
"readFixedLengthBytes",
"(",
"data",
",",
"index",
",",
"data",
".",
"length",
"-",
"index",
")",
")",
";",
"// end read",
"}"
] | <pre>
VERSION 4.1
Bytes Name
----- ----
1 field_count, always = 0xff
2 errno
1 (sqlstate marker), always '#'
5 sqlstate (5 characters)
n message
</pre> | [
"<pre",
">",
"VERSION",
"4",
".",
"1",
"Bytes",
"Name",
"-----",
"----",
"1",
"field_count",
"always",
"=",
"0xff",
"2",
"errno",
"1",
"(",
"sqlstate",
"marker",
")",
"always",
"#",
"5",
"sqlstate",
"(",
"5",
"characters",
")",
"n",
"message"
] | train | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/packets/server/ErrorPacket.java#L29-L46 |
wisdom-framework/wisdom | core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/osgi/BundlePackager.java | BundlePackager.mergeExtraHeaders | private static Properties mergeExtraHeaders(File baseDir, Properties properties) throws IOException {
"""
If a bundle has added extra headers, they are added to the bundle manifest.
@param baseDir the project directory
@param properties the current set of properties in which the read metadata are written
@return the merged set of properties
"""
File extra = new File(baseDir, EXTRA_HEADERS_FILE);
return Instructions.merge(properties, extra);
} | java | private static Properties mergeExtraHeaders(File baseDir, Properties properties) throws IOException {
File extra = new File(baseDir, EXTRA_HEADERS_FILE);
return Instructions.merge(properties, extra);
} | [
"private",
"static",
"Properties",
"mergeExtraHeaders",
"(",
"File",
"baseDir",
",",
"Properties",
"properties",
")",
"throws",
"IOException",
"{",
"File",
"extra",
"=",
"new",
"File",
"(",
"baseDir",
",",
"EXTRA_HEADERS_FILE",
")",
";",
"return",
"Instructions",
".",
"merge",
"(",
"properties",
",",
"extra",
")",
";",
"}"
] | If a bundle has added extra headers, they are added to the bundle manifest.
@param baseDir the project directory
@param properties the current set of properties in which the read metadata are written
@return the merged set of properties | [
"If",
"a",
"bundle",
"has",
"added",
"extra",
"headers",
"they",
"are",
"added",
"to",
"the",
"bundle",
"manifest",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/osgi/BundlePackager.java#L148-L151 |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/ActivityLifecycleCallback.java | ActivityLifecycleCallback.register | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static synchronized void register(android.app.Application application) {
"""
Enables lifecycle callbacks for Android devices
@param application App's Application object
"""
if (application == null) {
Logger.i("Application instance is null/system API is too old");
return;
}
if (registered) {
Logger.v("Lifecycle callbacks have already been registered");
return;
}
registered = true;
application.registerActivityLifecycleCallbacks(
new android.app.Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
CleverTapAPI.onActivityCreated(activity);
}
@Override
public void onActivityStarted(Activity activity) {}
@Override
public void onActivityResumed(Activity activity) {
CleverTapAPI.onActivityResumed(activity);
}
@Override
public void onActivityPaused(Activity activity) {
CleverTapAPI.onActivityPaused();
}
@Override
public void onActivityStopped(Activity activity) {}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {}
@Override
public void onActivityDestroyed(Activity activity) {}
}
);
Logger.i("Activity Lifecycle Callback successfully registered");
} | java | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static synchronized void register(android.app.Application application) {
if (application == null) {
Logger.i("Application instance is null/system API is too old");
return;
}
if (registered) {
Logger.v("Lifecycle callbacks have already been registered");
return;
}
registered = true;
application.registerActivityLifecycleCallbacks(
new android.app.Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
CleverTapAPI.onActivityCreated(activity);
}
@Override
public void onActivityStarted(Activity activity) {}
@Override
public void onActivityResumed(Activity activity) {
CleverTapAPI.onActivityResumed(activity);
}
@Override
public void onActivityPaused(Activity activity) {
CleverTapAPI.onActivityPaused();
}
@Override
public void onActivityStopped(Activity activity) {}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {}
@Override
public void onActivityDestroyed(Activity activity) {}
}
);
Logger.i("Activity Lifecycle Callback successfully registered");
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"ICE_CREAM_SANDWICH",
")",
"public",
"static",
"synchronized",
"void",
"register",
"(",
"android",
".",
"app",
".",
"Application",
"application",
")",
"{",
"if",
"(",
"application",
"==",
"null",
")",
"{",
"Logger",
".",
"i",
"(",
"\"Application instance is null/system API is too old\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"registered",
")",
"{",
"Logger",
".",
"v",
"(",
"\"Lifecycle callbacks have already been registered\"",
")",
";",
"return",
";",
"}",
"registered",
"=",
"true",
";",
"application",
".",
"registerActivityLifecycleCallbacks",
"(",
"new",
"android",
".",
"app",
".",
"Application",
".",
"ActivityLifecycleCallbacks",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onActivityCreated",
"(",
"Activity",
"activity",
",",
"Bundle",
"bundle",
")",
"{",
"CleverTapAPI",
".",
"onActivityCreated",
"(",
"activity",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onActivityStarted",
"(",
"Activity",
"activity",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"onActivityResumed",
"(",
"Activity",
"activity",
")",
"{",
"CleverTapAPI",
".",
"onActivityResumed",
"(",
"activity",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onActivityPaused",
"(",
"Activity",
"activity",
")",
"{",
"CleverTapAPI",
".",
"onActivityPaused",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onActivityStopped",
"(",
"Activity",
"activity",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"onActivitySaveInstanceState",
"(",
"Activity",
"activity",
",",
"Bundle",
"bundle",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"onActivityDestroyed",
"(",
"Activity",
"activity",
")",
"{",
"}",
"}",
")",
";",
"Logger",
".",
"i",
"(",
"\"Activity Lifecycle Callback successfully registered\"",
")",
";",
"}"
] | Enables lifecycle callbacks for Android devices
@param application App's Application object | [
"Enables",
"lifecycle",
"callbacks",
"for",
"Android",
"devices"
] | train | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/ActivityLifecycleCallback.java#L19-L65 |
google/gson | gson/src/main/java/com/google/gson/Gson.java | Gson.toJsonTree | public JsonElement toJsonTree(Object src) {
"""
This method serializes the specified object into its equivalent representation as a tree of
{@link JsonElement}s. This method should be used when the specified object is not a generic
type. This method uses {@link Class#getClass()} to get the type for the specified object, but
the {@code getClass()} loses the generic type information because of the Type Erasure feature
of Java. Note that this method works fine if the any of the object fields are of generic type,
just the object itself should not be of a generic type. If the object is of generic type, use
{@link #toJsonTree(Object, Type)} instead.
@param src the object for which Json representation is to be created setting for Gson
@return Json representation of {@code src}.
@since 1.4
"""
if (src == null) {
return JsonNull.INSTANCE;
}
return toJsonTree(src, src.getClass());
} | java | public JsonElement toJsonTree(Object src) {
if (src == null) {
return JsonNull.INSTANCE;
}
return toJsonTree(src, src.getClass());
} | [
"public",
"JsonElement",
"toJsonTree",
"(",
"Object",
"src",
")",
"{",
"if",
"(",
"src",
"==",
"null",
")",
"{",
"return",
"JsonNull",
".",
"INSTANCE",
";",
"}",
"return",
"toJsonTree",
"(",
"src",
",",
"src",
".",
"getClass",
"(",
")",
")",
";",
"}"
] | This method serializes the specified object into its equivalent representation as a tree of
{@link JsonElement}s. This method should be used when the specified object is not a generic
type. This method uses {@link Class#getClass()} to get the type for the specified object, but
the {@code getClass()} loses the generic type information because of the Type Erasure feature
of Java. Note that this method works fine if the any of the object fields are of generic type,
just the object itself should not be of a generic type. If the object is of generic type, use
{@link #toJsonTree(Object, Type)} instead.
@param src the object for which Json representation is to be created setting for Gson
@return Json representation of {@code src}.
@since 1.4 | [
"This",
"method",
"serializes",
"the",
"specified",
"object",
"into",
"its",
"equivalent",
"representation",
"as",
"a",
"tree",
"of",
"{",
"@link",
"JsonElement",
"}",
"s",
".",
"This",
"method",
"should",
"be",
"used",
"when",
"the",
"specified",
"object",
"is",
"not",
"a",
"generic",
"type",
".",
"This",
"method",
"uses",
"{",
"@link",
"Class#getClass",
"()",
"}",
"to",
"get",
"the",
"type",
"for",
"the",
"specified",
"object",
"but",
"the",
"{",
"@code",
"getClass",
"()",
"}",
"loses",
"the",
"generic",
"type",
"information",
"because",
"of",
"the",
"Type",
"Erasure",
"feature",
"of",
"Java",
".",
"Note",
"that",
"this",
"method",
"works",
"fine",
"if",
"the",
"any",
"of",
"the",
"object",
"fields",
"are",
"of",
"generic",
"type",
"just",
"the",
"object",
"itself",
"should",
"not",
"be",
"of",
"a",
"generic",
"type",
".",
"If",
"the",
"object",
"is",
"of",
"generic",
"type",
"use",
"{",
"@link",
"#toJsonTree",
"(",
"Object",
"Type",
")",
"}",
"instead",
"."
] | train | https://github.com/google/gson/blob/63ee47cb642c8018e5cddd639aa2be143220ad4b/gson/src/main/java/com/google/gson/Gson.java#L572-L577 |
Azure/azure-sdk-for-java | storage/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/storage/v2018_03_01_preview/implementation/BlobContainersInner.java | BlobContainersInner.lockImmutabilityPolicyAsync | public Observable<ImmutabilityPolicyInner> lockImmutabilityPolicyAsync(String resourceGroupName, String accountName, String containerName, String ifMatch) {
"""
Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation.
@param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive.
@param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
@param containerName The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number.
@param ifMatch The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ImmutabilityPolicyInner object
"""
return lockImmutabilityPolicyWithServiceResponseAsync(resourceGroupName, accountName, containerName, ifMatch).map(new Func1<ServiceResponseWithHeaders<ImmutabilityPolicyInner, BlobContainersLockImmutabilityPolicyHeaders>, ImmutabilityPolicyInner>() {
@Override
public ImmutabilityPolicyInner call(ServiceResponseWithHeaders<ImmutabilityPolicyInner, BlobContainersLockImmutabilityPolicyHeaders> response) {
return response.body();
}
});
} | java | public Observable<ImmutabilityPolicyInner> lockImmutabilityPolicyAsync(String resourceGroupName, String accountName, String containerName, String ifMatch) {
return lockImmutabilityPolicyWithServiceResponseAsync(resourceGroupName, accountName, containerName, ifMatch).map(new Func1<ServiceResponseWithHeaders<ImmutabilityPolicyInner, BlobContainersLockImmutabilityPolicyHeaders>, ImmutabilityPolicyInner>() {
@Override
public ImmutabilityPolicyInner call(ServiceResponseWithHeaders<ImmutabilityPolicyInner, BlobContainersLockImmutabilityPolicyHeaders> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ImmutabilityPolicyInner",
">",
"lockImmutabilityPolicyAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"containerName",
",",
"String",
"ifMatch",
")",
"{",
"return",
"lockImmutabilityPolicyWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"containerName",
",",
"ifMatch",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponseWithHeaders",
"<",
"ImmutabilityPolicyInner",
",",
"BlobContainersLockImmutabilityPolicyHeaders",
">",
",",
"ImmutabilityPolicyInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ImmutabilityPolicyInner",
"call",
"(",
"ServiceResponseWithHeaders",
"<",
"ImmutabilityPolicyInner",
",",
"BlobContainersLockImmutabilityPolicyHeaders",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation.
@param resourceGroupName The name of the resource group within the user's subscription. The name is case insensitive.
@param accountName The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
@param containerName The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number.
@param ifMatch The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ImmutabilityPolicyInner object | [
"Sets",
"the",
"ImmutabilityPolicy",
"to",
"Locked",
"state",
".",
"The",
"only",
"action",
"allowed",
"on",
"a",
"Locked",
"policy",
"is",
"ExtendImmutabilityPolicy",
"action",
".",
"ETag",
"in",
"If",
"-",
"Match",
"is",
"required",
"for",
"this",
"operation",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/storage/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/storage/v2018_03_01_preview/implementation/BlobContainersInner.java#L1515-L1522 |
pietermartin/sqlg | sqlg-core/src/main/java/org/umlg/sqlg/structure/topology/AbstractLabel.java | AbstractLabel.removeIndex | void removeIndex(Index idx, boolean preserveData) {
"""
remove a given index that was on this label
@param idx the index
@param preserveData should we keep the SQL data
"""
this.getSchema().getTopology().lock();
if (!uncommittedRemovedIndexes.contains(idx.getName())) {
uncommittedRemovedIndexes.add(idx.getName());
TopologyManager.removeIndex(this.sqlgGraph, idx);
if (!preserveData) {
idx.delete(sqlgGraph);
}
this.getSchema().getTopology().fire(idx, "", TopologyChangeAction.DELETE);
}
} | java | void removeIndex(Index idx, boolean preserveData) {
this.getSchema().getTopology().lock();
if (!uncommittedRemovedIndexes.contains(idx.getName())) {
uncommittedRemovedIndexes.add(idx.getName());
TopologyManager.removeIndex(this.sqlgGraph, idx);
if (!preserveData) {
idx.delete(sqlgGraph);
}
this.getSchema().getTopology().fire(idx, "", TopologyChangeAction.DELETE);
}
} | [
"void",
"removeIndex",
"(",
"Index",
"idx",
",",
"boolean",
"preserveData",
")",
"{",
"this",
".",
"getSchema",
"(",
")",
".",
"getTopology",
"(",
")",
".",
"lock",
"(",
")",
";",
"if",
"(",
"!",
"uncommittedRemovedIndexes",
".",
"contains",
"(",
"idx",
".",
"getName",
"(",
")",
")",
")",
"{",
"uncommittedRemovedIndexes",
".",
"add",
"(",
"idx",
".",
"getName",
"(",
")",
")",
";",
"TopologyManager",
".",
"removeIndex",
"(",
"this",
".",
"sqlgGraph",
",",
"idx",
")",
";",
"if",
"(",
"!",
"preserveData",
")",
"{",
"idx",
".",
"delete",
"(",
"sqlgGraph",
")",
";",
"}",
"this",
".",
"getSchema",
"(",
")",
".",
"getTopology",
"(",
")",
".",
"fire",
"(",
"idx",
",",
"\"\"",
",",
"TopologyChangeAction",
".",
"DELETE",
")",
";",
"}",
"}"
] | remove a given index that was on this label
@param idx the index
@param preserveData should we keep the SQL data | [
"remove",
"a",
"given",
"index",
"that",
"was",
"on",
"this",
"label"
] | train | https://github.com/pietermartin/sqlg/blob/c1845a1b31328a5ffda646873b0369ee72af56a7/sqlg-core/src/main/java/org/umlg/sqlg/structure/topology/AbstractLabel.java#L1032-L1042 |
alkacon/opencms-core | src/org/opencms/staticexport/CmsStaticExportManager.java | CmsStaticExportManager.getRfsPath | public static String getRfsPath(String filename, String extension, String parameters) {
"""
Creates unique, valid RFS name for the given filename that contains
a coded version of the given parameters, with the given file extension appended.<p>
Adapted from CmsFileUtil.getRfsPath().
@param filename the base file name
@param extension the extension to use
@param parameters the parameters to code in the result file name
@return a unique, valid RFS name for the given parameters
@see org.opencms.staticexport.CmsStaticExportManager
"""
boolean appendSlash = false;
if (filename.endsWith("/")) {
appendSlash = true;
filename = filename.substring(0, filename.length() - 1);
}
StringBuffer buf = new StringBuffer(128);
buf.append(filename);
buf.append('_');
int h = parameters.hashCode();
// ensure we do have a positive id value
buf.append(h > 0 ? h : -h);
buf.append(extension);
if (appendSlash) {
buf.append("/");
}
return buf.toString();
} | java | public static String getRfsPath(String filename, String extension, String parameters) {
boolean appendSlash = false;
if (filename.endsWith("/")) {
appendSlash = true;
filename = filename.substring(0, filename.length() - 1);
}
StringBuffer buf = new StringBuffer(128);
buf.append(filename);
buf.append('_');
int h = parameters.hashCode();
// ensure we do have a positive id value
buf.append(h > 0 ? h : -h);
buf.append(extension);
if (appendSlash) {
buf.append("/");
}
return buf.toString();
} | [
"public",
"static",
"String",
"getRfsPath",
"(",
"String",
"filename",
",",
"String",
"extension",
",",
"String",
"parameters",
")",
"{",
"boolean",
"appendSlash",
"=",
"false",
";",
"if",
"(",
"filename",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"appendSlash",
"=",
"true",
";",
"filename",
"=",
"filename",
".",
"substring",
"(",
"0",
",",
"filename",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
"128",
")",
";",
"buf",
".",
"append",
"(",
"filename",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"int",
"h",
"=",
"parameters",
".",
"hashCode",
"(",
")",
";",
"// ensure we do have a positive id value",
"buf",
".",
"append",
"(",
"h",
">",
"0",
"?",
"h",
":",
"-",
"h",
")",
";",
"buf",
".",
"append",
"(",
"extension",
")",
";",
"if",
"(",
"appendSlash",
")",
"{",
"buf",
".",
"append",
"(",
"\"/\"",
")",
";",
"}",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Creates unique, valid RFS name for the given filename that contains
a coded version of the given parameters, with the given file extension appended.<p>
Adapted from CmsFileUtil.getRfsPath().
@param filename the base file name
@param extension the extension to use
@param parameters the parameters to code in the result file name
@return a unique, valid RFS name for the given parameters
@see org.opencms.staticexport.CmsStaticExportManager | [
"Creates",
"unique",
"valid",
"RFS",
"name",
"for",
"the",
"given",
"filename",
"that",
"contains",
"a",
"coded",
"version",
"of",
"the",
"given",
"parameters",
"with",
"the",
"given",
"file",
"extension",
"appended",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsStaticExportManager.java#L317-L335 |
infinispan/infinispan | commons/src/main/java/org/infinispan/commons/dataconversion/StandardConversions.java | StandardConversions.convertTextToText | public static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType) {
"""
Convert text content to a different encoding.
@param source The source content.
@param sourceType MediaType for the source content.
@param destinationType the MediaType of the converted content.
@return content conforming to the destination MediaType.
"""
if (source == null) return null;
if (sourceType == null) throw new NullPointerException("MediaType cannot be null!");
if (!sourceType.match(MediaType.TEXT_PLAIN)) throw log.invalidMediaType(TEXT_PLAIN_TYPE, sourceType.toString());
boolean asString = destinationType.hasStringType();
Charset sourceCharset = sourceType.getCharset();
Charset destinationCharset = destinationType.getCharset();
if (sourceCharset.equals(destinationCharset)) return convertTextClass(source, destinationType, asString);
byte[] byteContent = source instanceof byte[] ? (byte[]) source : source.toString().getBytes(sourceCharset);
return convertTextClass(convertCharset(byteContent, sourceCharset, destinationCharset), destinationType, asString);
} | java | public static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType) {
if (source == null) return null;
if (sourceType == null) throw new NullPointerException("MediaType cannot be null!");
if (!sourceType.match(MediaType.TEXT_PLAIN)) throw log.invalidMediaType(TEXT_PLAIN_TYPE, sourceType.toString());
boolean asString = destinationType.hasStringType();
Charset sourceCharset = sourceType.getCharset();
Charset destinationCharset = destinationType.getCharset();
if (sourceCharset.equals(destinationCharset)) return convertTextClass(source, destinationType, asString);
byte[] byteContent = source instanceof byte[] ? (byte[]) source : source.toString().getBytes(sourceCharset);
return convertTextClass(convertCharset(byteContent, sourceCharset, destinationCharset), destinationType, asString);
} | [
"public",
"static",
"Object",
"convertTextToText",
"(",
"Object",
"source",
",",
"MediaType",
"sourceType",
",",
"MediaType",
"destinationType",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"sourceType",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"MediaType cannot be null!\"",
")",
";",
"if",
"(",
"!",
"sourceType",
".",
"match",
"(",
"MediaType",
".",
"TEXT_PLAIN",
")",
")",
"throw",
"log",
".",
"invalidMediaType",
"(",
"TEXT_PLAIN_TYPE",
",",
"sourceType",
".",
"toString",
"(",
")",
")",
";",
"boolean",
"asString",
"=",
"destinationType",
".",
"hasStringType",
"(",
")",
";",
"Charset",
"sourceCharset",
"=",
"sourceType",
".",
"getCharset",
"(",
")",
";",
"Charset",
"destinationCharset",
"=",
"destinationType",
".",
"getCharset",
"(",
")",
";",
"if",
"(",
"sourceCharset",
".",
"equals",
"(",
"destinationCharset",
")",
")",
"return",
"convertTextClass",
"(",
"source",
",",
"destinationType",
",",
"asString",
")",
";",
"byte",
"[",
"]",
"byteContent",
"=",
"source",
"instanceof",
"byte",
"[",
"]",
"?",
"(",
"byte",
"[",
"]",
")",
"source",
":",
"source",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"sourceCharset",
")",
";",
"return",
"convertTextClass",
"(",
"convertCharset",
"(",
"byteContent",
",",
"sourceCharset",
",",
"destinationCharset",
")",
",",
"destinationType",
",",
"asString",
")",
";",
"}"
] | Convert text content to a different encoding.
@param source The source content.
@param sourceType MediaType for the source content.
@param destinationType the MediaType of the converted content.
@return content conforming to the destination MediaType. | [
"Convert",
"text",
"content",
"to",
"a",
"different",
"encoding",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/dataconversion/StandardConversions.java#L41-L53 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.updateSecret | public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion) {
"""
Updates the attributes associated with a specified secret in a given key vault.
The UPDATE operation changes specified attributes of an existing stored secret. Attributes that are not specified in the request are left unchanged. The value of a secret itself cannot be changed. This operation requires the secrets/set permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param secretName The name of the secret.
@param secretVersion The version of the secret.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the SecretBundle object if successful.
"""
return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().body();
} | java | public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion) {
return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().body();
} | [
"public",
"SecretBundle",
"updateSecret",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"secretName",
",",
"String",
"secretVersion",
")",
"{",
"return",
"updateSecretWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"secretName",
",",
"secretVersion",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates the attributes associated with a specified secret in a given key vault.
The UPDATE operation changes specified attributes of an existing stored secret. Attributes that are not specified in the request are left unchanged. The value of a secret itself cannot be changed. This operation requires the secrets/set permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param secretName The name of the secret.
@param secretVersion The version of the secret.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the SecretBundle object if successful. | [
"Updates",
"the",
"attributes",
"associated",
"with",
"a",
"specified",
"secret",
"in",
"a",
"given",
"key",
"vault",
".",
"The",
"UPDATE",
"operation",
"changes",
"specified",
"attributes",
"of",
"an",
"existing",
"stored",
"secret",
".",
"Attributes",
"that",
"are",
"not",
"specified",
"in",
"the",
"request",
"are",
"left",
"unchanged",
".",
"The",
"value",
"of",
"a",
"secret",
"itself",
"cannot",
"be",
"changed",
".",
"This",
"operation",
"requires",
"the",
"secrets",
"/",
"set",
"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#L3620-L3622 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/TransactionManager.java | TransactionManager.getTransactionIDList | public DoubleIntIndex getTransactionIDList() {
"""
Return a lookup of all row ids for cached tables in transactions.
For auto-defrag, as currently there will be no RowAction entries
at the time of defrag.
"""
writeLock.lock();
try {
DoubleIntIndex lookup = new DoubleIntIndex(10, false);
lookup.setKeysSearchTarget();
Iterator it = this.rowActionMap.keySet().iterator();
for (; it.hasNext(); ) {
lookup.addUnique(it.nextInt(), 0);
}
return lookup;
} finally {
writeLock.unlock();
}
} | java | public DoubleIntIndex getTransactionIDList() {
writeLock.lock();
try {
DoubleIntIndex lookup = new DoubleIntIndex(10, false);
lookup.setKeysSearchTarget();
Iterator it = this.rowActionMap.keySet().iterator();
for (; it.hasNext(); ) {
lookup.addUnique(it.nextInt(), 0);
}
return lookup;
} finally {
writeLock.unlock();
}
} | [
"public",
"DoubleIntIndex",
"getTransactionIDList",
"(",
")",
"{",
"writeLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"DoubleIntIndex",
"lookup",
"=",
"new",
"DoubleIntIndex",
"(",
"10",
",",
"false",
")",
";",
"lookup",
".",
"setKeysSearchTarget",
"(",
")",
";",
"Iterator",
"it",
"=",
"this",
".",
"rowActionMap",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"for",
"(",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"lookup",
".",
"addUnique",
"(",
"it",
".",
"nextInt",
"(",
")",
",",
"0",
")",
";",
"}",
"return",
"lookup",
";",
"}",
"finally",
"{",
"writeLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Return a lookup of all row ids for cached tables in transactions.
For auto-defrag, as currently there will be no RowAction entries
at the time of defrag. | [
"Return",
"a",
"lookup",
"of",
"all",
"row",
"ids",
"for",
"cached",
"tables",
"in",
"transactions",
".",
"For",
"auto",
"-",
"defrag",
"as",
"currently",
"there",
"will",
"be",
"no",
"RowAction",
"entries",
"at",
"the",
"time",
"of",
"defrag",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/TransactionManager.java#L1177-L1196 |
buschmais/jqa-maven-plugin | src/main/java/com/buschmais/jqassistant/scm/maven/provider/CachingStoreProvider.java | CachingStoreProvider.getStore | public Store getStore(StoreConfiguration storeConfiguration, List<Class<?>> types) {
"""
Create/open store in the given directory.
@param storeConfiguration The store configuration.
@param types The types to register.
@return The store.
"""
StoreKey key = StoreKey.builder().uri(storeConfiguration.getUri().normalize()).username(storeConfiguration.getUsername()).build();
Store store = storesByKey.get(key);
if (store == null) {
store = StoreFactory.getStore(storeConfiguration);
store.start(types);
storesByKey.put(key, store);
keysByStore.put(store, key);
}
return store;
} | java | public Store getStore(StoreConfiguration storeConfiguration, List<Class<?>> types) {
StoreKey key = StoreKey.builder().uri(storeConfiguration.getUri().normalize()).username(storeConfiguration.getUsername()).build();
Store store = storesByKey.get(key);
if (store == null) {
store = StoreFactory.getStore(storeConfiguration);
store.start(types);
storesByKey.put(key, store);
keysByStore.put(store, key);
}
return store;
} | [
"public",
"Store",
"getStore",
"(",
"StoreConfiguration",
"storeConfiguration",
",",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"types",
")",
"{",
"StoreKey",
"key",
"=",
"StoreKey",
".",
"builder",
"(",
")",
".",
"uri",
"(",
"storeConfiguration",
".",
"getUri",
"(",
")",
".",
"normalize",
"(",
")",
")",
".",
"username",
"(",
"storeConfiguration",
".",
"getUsername",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"Store",
"store",
"=",
"storesByKey",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"store",
"==",
"null",
")",
"{",
"store",
"=",
"StoreFactory",
".",
"getStore",
"(",
"storeConfiguration",
")",
";",
"store",
".",
"start",
"(",
"types",
")",
";",
"storesByKey",
".",
"put",
"(",
"key",
",",
"store",
")",
";",
"keysByStore",
".",
"put",
"(",
"store",
",",
"key",
")",
";",
"}",
"return",
"store",
";",
"}"
] | Create/open store in the given directory.
@param storeConfiguration The store configuration.
@param types The types to register.
@return The store. | [
"Create",
"/",
"open",
"store",
"in",
"the",
"given",
"directory",
"."
] | train | https://github.com/buschmais/jqa-maven-plugin/blob/5c21a8058fc1b013333081907fbf00d3525e11c3/src/main/java/com/buschmais/jqassistant/scm/maven/provider/CachingStoreProvider.java#L53-L63 |
btaz/data-util | src/main/java/com/btaz/util/writer/HtmlTableWriter.java | HtmlTableWriter.writeTop | private void writeTop() throws IOException {
"""
Write the top part of the HTML document
@throws IOException exception
"""
// setup output HTML file
File outputFile = new File(outputDirectory, createFilename(currentPageNumber));
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(outputFile, false), Charset.forName(encoding)));
// write header
Map<String,Object> map = new HashMap<String,Object>();
map.put("pageTitle", pageTitle);
if(pageHeader != null && pageHeader.length() > 0) {
map.put("header", "<h1>" + pageHeader + "</h1>");
} else {
map.put("header","");
}
if(pageDescription != null && pageDescription.length() > 0) {
map.put("description", "<p>" + pageDescription + "</p>");
} else {
map.put("description", "");
}
String template = Template.readResourceAsStream("com/btaz/util/templates/html-table-header.ftl");
String output = Template.transform(template, map);
writer.write(output);
} | java | private void writeTop() throws IOException {
// setup output HTML file
File outputFile = new File(outputDirectory, createFilename(currentPageNumber));
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(outputFile, false), Charset.forName(encoding)));
// write header
Map<String,Object> map = new HashMap<String,Object>();
map.put("pageTitle", pageTitle);
if(pageHeader != null && pageHeader.length() > 0) {
map.put("header", "<h1>" + pageHeader + "</h1>");
} else {
map.put("header","");
}
if(pageDescription != null && pageDescription.length() > 0) {
map.put("description", "<p>" + pageDescription + "</p>");
} else {
map.put("description", "");
}
String template = Template.readResourceAsStream("com/btaz/util/templates/html-table-header.ftl");
String output = Template.transform(template, map);
writer.write(output);
} | [
"private",
"void",
"writeTop",
"(",
")",
"throws",
"IOException",
"{",
"// setup output HTML file",
"File",
"outputFile",
"=",
"new",
"File",
"(",
"outputDirectory",
",",
"createFilename",
"(",
"currentPageNumber",
")",
")",
";",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"outputFile",
",",
"false",
")",
",",
"Charset",
".",
"forName",
"(",
"encoding",
")",
")",
")",
";",
"// write header",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"map",
".",
"put",
"(",
"\"pageTitle\"",
",",
"pageTitle",
")",
";",
"if",
"(",
"pageHeader",
"!=",
"null",
"&&",
"pageHeader",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"map",
".",
"put",
"(",
"\"header\"",
",",
"\"<h1>\"",
"+",
"pageHeader",
"+",
"\"</h1>\"",
")",
";",
"}",
"else",
"{",
"map",
".",
"put",
"(",
"\"header\"",
",",
"\"\"",
")",
";",
"}",
"if",
"(",
"pageDescription",
"!=",
"null",
"&&",
"pageDescription",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"map",
".",
"put",
"(",
"\"description\"",
",",
"\"<p>\"",
"+",
"pageDescription",
"+",
"\"</p>\"",
")",
";",
"}",
"else",
"{",
"map",
".",
"put",
"(",
"\"description\"",
",",
"\"\"",
")",
";",
"}",
"String",
"template",
"=",
"Template",
".",
"readResourceAsStream",
"(",
"\"com/btaz/util/templates/html-table-header.ftl\"",
")",
";",
"String",
"output",
"=",
"Template",
".",
"transform",
"(",
"template",
",",
"map",
")",
";",
"writer",
".",
"write",
"(",
"output",
")",
";",
"}"
] | Write the top part of the HTML document
@throws IOException exception | [
"Write",
"the",
"top",
"part",
"of",
"the",
"HTML",
"document"
] | train | https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/writer/HtmlTableWriter.java#L142-L165 |
kaazing/gateway | mina.core/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java | AbstractProxyLogicHandler.writeData | protected WriteFuture writeData(final NextFilter nextFilter,
final IoBuffer data) {
"""
Writes data to the proxy server.
@param nextFilter the next filter
@param data Data buffer to be written.
"""
// write net data
ProxyHandshakeIoBuffer writeBuffer = new ProxyHandshakeIoBuffer(data);
LOGGER.debug(" session write: {}", writeBuffer);
WriteFuture writeFuture = new DefaultWriteFuture(getSession());
getProxyFilter().writeData(nextFilter, getSession(),
new DefaultWriteRequest(writeBuffer, writeFuture), true);
return writeFuture;
} | java | protected WriteFuture writeData(final NextFilter nextFilter,
final IoBuffer data) {
// write net data
ProxyHandshakeIoBuffer writeBuffer = new ProxyHandshakeIoBuffer(data);
LOGGER.debug(" session write: {}", writeBuffer);
WriteFuture writeFuture = new DefaultWriteFuture(getSession());
getProxyFilter().writeData(nextFilter, getSession(),
new DefaultWriteRequest(writeBuffer, writeFuture), true);
return writeFuture;
} | [
"protected",
"WriteFuture",
"writeData",
"(",
"final",
"NextFilter",
"nextFilter",
",",
"final",
"IoBuffer",
"data",
")",
"{",
"// write net data",
"ProxyHandshakeIoBuffer",
"writeBuffer",
"=",
"new",
"ProxyHandshakeIoBuffer",
"(",
"data",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\" session write: {}\"",
",",
"writeBuffer",
")",
";",
"WriteFuture",
"writeFuture",
"=",
"new",
"DefaultWriteFuture",
"(",
"getSession",
"(",
")",
")",
";",
"getProxyFilter",
"(",
")",
".",
"writeData",
"(",
"nextFilter",
",",
"getSession",
"(",
")",
",",
"new",
"DefaultWriteRequest",
"(",
"writeBuffer",
",",
"writeFuture",
")",
",",
"true",
")",
";",
"return",
"writeFuture",
";",
"}"
] | Writes data to the proxy server.
@param nextFilter the next filter
@param data Data buffer to be written. | [
"Writes",
"data",
"to",
"the",
"proxy",
"server",
"."
] | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.core/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java#L99-L111 |
pryzach/midao | midao-jdbc-core/src/main/java/org/midao/jdbc/core/MidaoFactory.java | MidaoFactory.getQueryRunner | public static QueryRunnerService getQueryRunner(DataSource ds, Class<? extends TypeHandler> typeHandlerClazz) {
"""
Returns new {@link org.midao.jdbc.core.service.QueryRunnerService} instance
@param ds SQL DataSource
@param typeHandlerClazz {@link org.midao.jdbc.core.handlers.type.TypeHandler} implementation
@return new {@link org.midao.jdbc.core.service.QueryRunnerService} instance
"""
return (QueryRunnerService) ProfilerFactory.newInstance(new QueryRunner(ds, typeHandlerClazz));
} | java | public static QueryRunnerService getQueryRunner(DataSource ds, Class<? extends TypeHandler> typeHandlerClazz) {
return (QueryRunnerService) ProfilerFactory.newInstance(new QueryRunner(ds, typeHandlerClazz));
} | [
"public",
"static",
"QueryRunnerService",
"getQueryRunner",
"(",
"DataSource",
"ds",
",",
"Class",
"<",
"?",
"extends",
"TypeHandler",
">",
"typeHandlerClazz",
")",
"{",
"return",
"(",
"QueryRunnerService",
")",
"ProfilerFactory",
".",
"newInstance",
"(",
"new",
"QueryRunner",
"(",
"ds",
",",
"typeHandlerClazz",
")",
")",
";",
"}"
] | Returns new {@link org.midao.jdbc.core.service.QueryRunnerService} instance
@param ds SQL DataSource
@param typeHandlerClazz {@link org.midao.jdbc.core.handlers.type.TypeHandler} implementation
@return new {@link org.midao.jdbc.core.service.QueryRunnerService} instance | [
"Returns",
"new",
"{",
"@link",
"org",
".",
"midao",
".",
"jdbc",
".",
"core",
".",
"service",
".",
"QueryRunnerService",
"}",
"instance"
] | train | https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/MidaoFactory.java#L60-L62 |
nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/Graphics.java | Graphics.drawRoundRect | public void drawRoundRect(float x, float y, float width, float height,
int cornerRadius, int segs) {
"""
Draw a rounded rectangle
@param x
The x coordinate of the top left corner of the rectangle
@param y
The y coordinate of the top left corner of the rectangle
@param width
The width of the rectangle
@param height
The height of the rectangle
@param cornerRadius
The radius of the rounded edges on the corners
@param segs
The number of segments to make the corners out of
"""
if (cornerRadius < 0)
throw new IllegalArgumentException("corner radius must be > 0");
if (cornerRadius == 0) {
drawRect(x, y, width, height);
return;
}
int mr = (int) Math.min(width, height) / 2;
// make sure that w & h are larger than 2*cornerRadius
if (cornerRadius > mr) {
cornerRadius = mr;
}
drawLine(x + cornerRadius, y, x + width - cornerRadius, y);
drawLine(x, y + cornerRadius, x, y + height - cornerRadius);
drawLine(x + width, y + cornerRadius, x + width, y + height
- cornerRadius);
drawLine(x + cornerRadius, y + height, x + width - cornerRadius, y
+ height);
float d = cornerRadius * 2;
// bottom right - 0, 90
drawArc(x + width - d, y + height - d, d, d, segs, 0, 90);
// bottom left - 90, 180
drawArc(x, y + height - d, d, d, segs, 90, 180);
// top right - 270, 360
drawArc(x + width - d, y, d, d, segs, 270, 360);
// top left - 180, 270
drawArc(x, y, d, d, segs, 180, 270);
} | java | public void drawRoundRect(float x, float y, float width, float height,
int cornerRadius, int segs) {
if (cornerRadius < 0)
throw new IllegalArgumentException("corner radius must be > 0");
if (cornerRadius == 0) {
drawRect(x, y, width, height);
return;
}
int mr = (int) Math.min(width, height) / 2;
// make sure that w & h are larger than 2*cornerRadius
if (cornerRadius > mr) {
cornerRadius = mr;
}
drawLine(x + cornerRadius, y, x + width - cornerRadius, y);
drawLine(x, y + cornerRadius, x, y + height - cornerRadius);
drawLine(x + width, y + cornerRadius, x + width, y + height
- cornerRadius);
drawLine(x + cornerRadius, y + height, x + width - cornerRadius, y
+ height);
float d = cornerRadius * 2;
// bottom right - 0, 90
drawArc(x + width - d, y + height - d, d, d, segs, 0, 90);
// bottom left - 90, 180
drawArc(x, y + height - d, d, d, segs, 90, 180);
// top right - 270, 360
drawArc(x + width - d, y, d, d, segs, 270, 360);
// top left - 180, 270
drawArc(x, y, d, d, segs, 180, 270);
} | [
"public",
"void",
"drawRoundRect",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"width",
",",
"float",
"height",
",",
"int",
"cornerRadius",
",",
"int",
"segs",
")",
"{",
"if",
"(",
"cornerRadius",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"corner radius must be > 0\"",
")",
";",
"if",
"(",
"cornerRadius",
"==",
"0",
")",
"{",
"drawRect",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
";",
"return",
";",
"}",
"int",
"mr",
"=",
"(",
"int",
")",
"Math",
".",
"min",
"(",
"width",
",",
"height",
")",
"/",
"2",
";",
"// make sure that w & h are larger than 2*cornerRadius\r",
"if",
"(",
"cornerRadius",
">",
"mr",
")",
"{",
"cornerRadius",
"=",
"mr",
";",
"}",
"drawLine",
"(",
"x",
"+",
"cornerRadius",
",",
"y",
",",
"x",
"+",
"width",
"-",
"cornerRadius",
",",
"y",
")",
";",
"drawLine",
"(",
"x",
",",
"y",
"+",
"cornerRadius",
",",
"x",
",",
"y",
"+",
"height",
"-",
"cornerRadius",
")",
";",
"drawLine",
"(",
"x",
"+",
"width",
",",
"y",
"+",
"cornerRadius",
",",
"x",
"+",
"width",
",",
"y",
"+",
"height",
"-",
"cornerRadius",
")",
";",
"drawLine",
"(",
"x",
"+",
"cornerRadius",
",",
"y",
"+",
"height",
",",
"x",
"+",
"width",
"-",
"cornerRadius",
",",
"y",
"+",
"height",
")",
";",
"float",
"d",
"=",
"cornerRadius",
"*",
"2",
";",
"// bottom right - 0, 90\r",
"drawArc",
"(",
"x",
"+",
"width",
"-",
"d",
",",
"y",
"+",
"height",
"-",
"d",
",",
"d",
",",
"d",
",",
"segs",
",",
"0",
",",
"90",
")",
";",
"// bottom left - 90, 180\r",
"drawArc",
"(",
"x",
",",
"y",
"+",
"height",
"-",
"d",
",",
"d",
",",
"d",
",",
"segs",
",",
"90",
",",
"180",
")",
";",
"// top right - 270, 360\r",
"drawArc",
"(",
"x",
"+",
"width",
"-",
"d",
",",
"y",
",",
"d",
",",
"d",
",",
"segs",
",",
"270",
",",
"360",
")",
";",
"// top left - 180, 270\r",
"drawArc",
"(",
"x",
",",
"y",
",",
"d",
",",
"d",
",",
"segs",
",",
"180",
",",
"270",
")",
";",
"}"
] | Draw a rounded rectangle
@param x
The x coordinate of the top left corner of the rectangle
@param y
The y coordinate of the top left corner of the rectangle
@param width
The width of the rectangle
@param height
The height of the rectangle
@param cornerRadius
The radius of the rounded edges on the corners
@param segs
The number of segments to make the corners out of | [
"Draw",
"a",
"rounded",
"rectangle"
] | train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Graphics.java#L1187-L1218 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/analysis/FieldInfo.java | FieldInfo.createUnresolvedFieldInfo | public static FieldInfo createUnresolvedFieldInfo(String className, String name, String signature, boolean isStatic) {
"""
Create a FieldInfo object to represent an unresolved field.
<em>Don't call this directly - use XFactory instead.</em>
@param className
name of class containing the field
@param name
name of field
@param signature
field signature
@param isStatic
true if field is static, false otherwise
@return FieldInfo object representing the unresolved field
"""
className = ClassName.toSlashedClassName(className);
return new FieldInfo(className, name, signature, null, // without seeing
// the definition
// we don't know
// if it has a
// generic type
isStatic ? Const.ACC_STATIC : 0, new HashMap<ClassDescriptor, AnnotationValue>(), false);
} | java | public static FieldInfo createUnresolvedFieldInfo(String className, String name, String signature, boolean isStatic) {
className = ClassName.toSlashedClassName(className);
return new FieldInfo(className, name, signature, null, // without seeing
// the definition
// we don't know
// if it has a
// generic type
isStatic ? Const.ACC_STATIC : 0, new HashMap<ClassDescriptor, AnnotationValue>(), false);
} | [
"public",
"static",
"FieldInfo",
"createUnresolvedFieldInfo",
"(",
"String",
"className",
",",
"String",
"name",
",",
"String",
"signature",
",",
"boolean",
"isStatic",
")",
"{",
"className",
"=",
"ClassName",
".",
"toSlashedClassName",
"(",
"className",
")",
";",
"return",
"new",
"FieldInfo",
"(",
"className",
",",
"name",
",",
"signature",
",",
"null",
",",
"// without seeing",
"// the definition",
"// we don't know",
"// if it has a",
"// generic type",
"isStatic",
"?",
"Const",
".",
"ACC_STATIC",
":",
"0",
",",
"new",
"HashMap",
"<",
"ClassDescriptor",
",",
"AnnotationValue",
">",
"(",
")",
",",
"false",
")",
";",
"}"
] | Create a FieldInfo object to represent an unresolved field.
<em>Don't call this directly - use XFactory instead.</em>
@param className
name of class containing the field
@param name
name of field
@param signature
field signature
@param isStatic
true if field is static, false otherwise
@return FieldInfo object representing the unresolved field | [
"Create",
"a",
"FieldInfo",
"object",
"to",
"represent",
"an",
"unresolved",
"field",
".",
"<em",
">",
"Don",
"t",
"call",
"this",
"directly",
"-",
"use",
"XFactory",
"instead",
".",
"<",
"/",
"em",
">"
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/analysis/FieldInfo.java#L308-L316 |
HanSolo/SteelSeries-Swing | src/main/java/eu/hansolo/steelseries/tools/GradientWrapper.java | GradientWrapper.copyArrays | private void copyArrays(final float[] FRACTIONS, final Color[] colors) {
"""
Just create a local copy of the fractions and colors array
@param FRACTIONS
@param colors
"""
fractions = new float[FRACTIONS.length];
System.arraycopy(FRACTIONS, 0, fractions, 0, FRACTIONS.length);
this.colors = colors.clone();
} | java | private void copyArrays(final float[] FRACTIONS, final Color[] colors) {
fractions = new float[FRACTIONS.length];
System.arraycopy(FRACTIONS, 0, fractions, 0, FRACTIONS.length);
this.colors = colors.clone();
} | [
"private",
"void",
"copyArrays",
"(",
"final",
"float",
"[",
"]",
"FRACTIONS",
",",
"final",
"Color",
"[",
"]",
"colors",
")",
"{",
"fractions",
"=",
"new",
"float",
"[",
"FRACTIONS",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"FRACTIONS",
",",
"0",
",",
"fractions",
",",
"0",
",",
"FRACTIONS",
".",
"length",
")",
";",
"this",
".",
"colors",
"=",
"colors",
".",
"clone",
"(",
")",
";",
"}"
] | Just create a local copy of the fractions and colors array
@param FRACTIONS
@param colors | [
"Just",
"create",
"a",
"local",
"copy",
"of",
"the",
"fractions",
"and",
"colors",
"array"
] | train | https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/tools/GradientWrapper.java#L161-L165 |
walkmod/walkmod-core | src/main/java/org/walkmod/util/ClassLoaderUtil.java | ClassLoaderUtil.getResource | public static URL getResource(String resourceName, Class<?> callingClass) {
"""
Load a given resource.
This method will try to load the resource using the following methods (in
order):
<ul>
<li>From Thread.currentThread().getContextClassLoader()
<li>From ClassLoaderUtil.class.getClassLoader()
<li>callingClass.getClassLoader()
</ul>
@param resourceName
The name IllegalStateException("Unable to call ")of the
resource to load
@param callingClass
The Class object of the calling object
@return Matching resouce or null if not found
"""
URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
if (url == null) {
url = ClassLoaderUtil.class.getClassLoader().getResource(resourceName);
}
if (url == null) {
ClassLoader cl = callingClass.getClassLoader();
if (cl != null) {
url = cl.getResource(resourceName);
}
}
if ((url == null) && (resourceName != null)
&& ((resourceName.length() == 0) || (resourceName.charAt(0) != '/'))) {
return getResource('/' + resourceName, callingClass);
}
return url;
} | java | public static URL getResource(String resourceName, Class<?> callingClass) {
URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
if (url == null) {
url = ClassLoaderUtil.class.getClassLoader().getResource(resourceName);
}
if (url == null) {
ClassLoader cl = callingClass.getClassLoader();
if (cl != null) {
url = cl.getResource(resourceName);
}
}
if ((url == null) && (resourceName != null)
&& ((resourceName.length() == 0) || (resourceName.charAt(0) != '/'))) {
return getResource('/' + resourceName, callingClass);
}
return url;
} | [
"public",
"static",
"URL",
"getResource",
"(",
"String",
"resourceName",
",",
"Class",
"<",
"?",
">",
"callingClass",
")",
"{",
"URL",
"url",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResource",
"(",
"resourceName",
")",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"url",
"=",
"ClassLoaderUtil",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"resourceName",
")",
";",
"}",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"ClassLoader",
"cl",
"=",
"callingClass",
".",
"getClassLoader",
"(",
")",
";",
"if",
"(",
"cl",
"!=",
"null",
")",
"{",
"url",
"=",
"cl",
".",
"getResource",
"(",
"resourceName",
")",
";",
"}",
"}",
"if",
"(",
"(",
"url",
"==",
"null",
")",
"&&",
"(",
"resourceName",
"!=",
"null",
")",
"&&",
"(",
"(",
"resourceName",
".",
"length",
"(",
")",
"==",
"0",
")",
"||",
"(",
"resourceName",
".",
"charAt",
"(",
"0",
")",
"!=",
"'",
"'",
")",
")",
")",
"{",
"return",
"getResource",
"(",
"'",
"'",
"+",
"resourceName",
",",
"callingClass",
")",
";",
"}",
"return",
"url",
";",
"}"
] | Load a given resource.
This method will try to load the resource using the following methods (in
order):
<ul>
<li>From Thread.currentThread().getContextClassLoader()
<li>From ClassLoaderUtil.class.getClassLoader()
<li>callingClass.getClassLoader()
</ul>
@param resourceName
The name IllegalStateException("Unable to call ")of the
resource to load
@param callingClass
The Class object of the calling object
@return Matching resouce or null if not found | [
"Load",
"a",
"given",
"resource",
"."
] | train | https://github.com/walkmod/walkmod-core/blob/fa79b836894fa00ca4b3e2bd26326a44b778f46f/src/main/java/org/walkmod/util/ClassLoaderUtil.java#L350-L366 |
youngmonkeys/ezyfox-sfs2x | src/main/java/com/tvd12/ezyfox/sfs2x/serverhandler/UserDisconnectEventHandler.java | UserDisconnectEventHandler.notifyHandlers | protected void notifyHandlers(ApiUser apiUser, ApiDisconnectionImpl disconnection) {
"""
Propagate event to handlers
@param apiUser user agent object
@param disconnection the disconnection info
"""
for(ServerHandlerClass handler : handlers) {
ReflectMethodUtil.invokeHandleMethod(
handler.getHandleMethod(),
handler.newInstance(),
context,
disconnection);
}
} | java | protected void notifyHandlers(ApiUser apiUser, ApiDisconnectionImpl disconnection) {
for(ServerHandlerClass handler : handlers) {
ReflectMethodUtil.invokeHandleMethod(
handler.getHandleMethod(),
handler.newInstance(),
context,
disconnection);
}
} | [
"protected",
"void",
"notifyHandlers",
"(",
"ApiUser",
"apiUser",
",",
"ApiDisconnectionImpl",
"disconnection",
")",
"{",
"for",
"(",
"ServerHandlerClass",
"handler",
":",
"handlers",
")",
"{",
"ReflectMethodUtil",
".",
"invokeHandleMethod",
"(",
"handler",
".",
"getHandleMethod",
"(",
")",
",",
"handler",
".",
"newInstance",
"(",
")",
",",
"context",
",",
"disconnection",
")",
";",
"}",
"}"
] | Propagate event to handlers
@param apiUser user agent object
@param disconnection the disconnection info | [
"Propagate",
"event",
"to",
"handlers"
] | train | https://github.com/youngmonkeys/ezyfox-sfs2x/blob/7e004033a3b551c3ae970a0c8f45db7b1ec144de/src/main/java/com/tvd12/ezyfox/sfs2x/serverhandler/UserDisconnectEventHandler.java#L112-L120 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java | ApiOvhDedicatedserver.serviceName_install_hardwareRaidSize_GET | public OvhHardwareRaidSize serviceName_install_hardwareRaidSize_GET(String serviceName, String partitionSchemeName, String templateName) throws IOException {
"""
Get hardware RAID size for a given configuration
REST: GET /dedicated/server/{serviceName}/install/hardwareRaidSize
@param partitionSchemeName [required] Partition scheme name
@param templateName [required] Template name
@param serviceName [required] The internal name of your dedicated server
"""
String qPath = "/dedicated/server/{serviceName}/install/hardwareRaidSize";
StringBuilder sb = path(qPath, serviceName);
query(sb, "partitionSchemeName", partitionSchemeName);
query(sb, "templateName", templateName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhHardwareRaidSize.class);
} | java | public OvhHardwareRaidSize serviceName_install_hardwareRaidSize_GET(String serviceName, String partitionSchemeName, String templateName) throws IOException {
String qPath = "/dedicated/server/{serviceName}/install/hardwareRaidSize";
StringBuilder sb = path(qPath, serviceName);
query(sb, "partitionSchemeName", partitionSchemeName);
query(sb, "templateName", templateName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhHardwareRaidSize.class);
} | [
"public",
"OvhHardwareRaidSize",
"serviceName_install_hardwareRaidSize_GET",
"(",
"String",
"serviceName",
",",
"String",
"partitionSchemeName",
",",
"String",
"templateName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicated/server/{serviceName}/install/hardwareRaidSize\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"query",
"(",
"sb",
",",
"\"partitionSchemeName\"",
",",
"partitionSchemeName",
")",
";",
"query",
"(",
"sb",
",",
"\"templateName\"",
",",
"templateName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhHardwareRaidSize",
".",
"class",
")",
";",
"}"
] | Get hardware RAID size for a given configuration
REST: GET /dedicated/server/{serviceName}/install/hardwareRaidSize
@param partitionSchemeName [required] Partition scheme name
@param templateName [required] Template name
@param serviceName [required] The internal name of your dedicated server | [
"Get",
"hardware",
"RAID",
"size",
"for",
"a",
"given",
"configuration"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L1701-L1708 |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java | FileSystem.toJarURL | @Pure
public static URL toJarURL(File jarFile, File insideFile) throws MalformedURLException {
"""
Replies the jar-schemed URL composed of the two given components.
<p>If the inputs are {@code /path1/archive.jar} and @{code /path2/file},
the output of this function is {@code jar:file:/path1/archive.jar!/path2/file}.
@param jarFile is the URL to the jar file.
@param insideFile is the name of the file inside the jar.
@return the jar-schemed URL.
@throws MalformedURLException when the URL is malformed.
"""
if (jarFile == null || insideFile == null) {
return null;
}
return toJarURL(jarFile, fromFileStandardToURLStandard(insideFile));
} | java | @Pure
public static URL toJarURL(File jarFile, File insideFile) throws MalformedURLException {
if (jarFile == null || insideFile == null) {
return null;
}
return toJarURL(jarFile, fromFileStandardToURLStandard(insideFile));
} | [
"@",
"Pure",
"public",
"static",
"URL",
"toJarURL",
"(",
"File",
"jarFile",
",",
"File",
"insideFile",
")",
"throws",
"MalformedURLException",
"{",
"if",
"(",
"jarFile",
"==",
"null",
"||",
"insideFile",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"toJarURL",
"(",
"jarFile",
",",
"fromFileStandardToURLStandard",
"(",
"insideFile",
")",
")",
";",
"}"
] | Replies the jar-schemed URL composed of the two given components.
<p>If the inputs are {@code /path1/archive.jar} and @{code /path2/file},
the output of this function is {@code jar:file:/path1/archive.jar!/path2/file}.
@param jarFile is the URL to the jar file.
@param insideFile is the name of the file inside the jar.
@return the jar-schemed URL.
@throws MalformedURLException when the URL is malformed. | [
"Replies",
"the",
"jar",
"-",
"schemed",
"URL",
"composed",
"of",
"the",
"two",
"given",
"components",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java#L298-L304 |
jurmous/etcd4j | src/main/java/mousio/etcd4j/EtcdClient.java | EtcdClient.getStoreStats | public EtcdStoreStatsResponse getStoreStats() {
"""
Get the Store Statistics of Etcd
@return vEtcdStoreStatsResponse
"""
try {
return new EtcdStoreStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | java | public EtcdStoreStatsResponse getStoreStats() {
try {
return new EtcdStoreStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | [
"public",
"EtcdStoreStatsResponse",
"getStoreStats",
"(",
")",
"{",
"try",
"{",
"return",
"new",
"EtcdStoreStatsRequest",
"(",
"this",
".",
"client",
",",
"retryHandler",
")",
".",
"send",
"(",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"EtcdException",
"|",
"EtcdAuthenticationException",
"|",
"TimeoutException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Get the Store Statistics of Etcd
@return vEtcdStoreStatsResponse | [
"Get",
"the",
"Store",
"Statistics",
"of",
"Etcd"
] | train | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/EtcdClient.java#L171-L177 |
MenoData/Time4J | base/src/main/java/net/time4j/UnitPatterns.java | UnitPatterns.getListPattern | String getListPattern(
TextWidth width,
int size
) {
"""
<p>Constructs a localized list pattern suitable for the use in
{@link java.text.MessageFormat#format(String, Object[])}. </p>
@param width text width (ABBREVIATED as synonym for SHORT)
@param size count of list items
@return message format pattern with placeholders {0}, {1}, ..., {x}, ...
@throws IllegalArgumentException if size is smaller than 2
"""
if (width == null) {
throw new NullPointerException("Missing width.");
}
if (
(size >= MIN_LIST_INDEX)
&& (size <= MAX_LIST_INDEX)
) {
return this.list.get(Integer.valueOf(size)).get(width);
}
return lookup(this.locale, width, size);
} | java | String getListPattern(
TextWidth width,
int size
) {
if (width == null) {
throw new NullPointerException("Missing width.");
}
if (
(size >= MIN_LIST_INDEX)
&& (size <= MAX_LIST_INDEX)
) {
return this.list.get(Integer.valueOf(size)).get(width);
}
return lookup(this.locale, width, size);
} | [
"String",
"getListPattern",
"(",
"TextWidth",
"width",
",",
"int",
"size",
")",
"{",
"if",
"(",
"width",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Missing width.\"",
")",
";",
"}",
"if",
"(",
"(",
"size",
">=",
"MIN_LIST_INDEX",
")",
"&&",
"(",
"size",
"<=",
"MAX_LIST_INDEX",
")",
")",
"{",
"return",
"this",
".",
"list",
".",
"get",
"(",
"Integer",
".",
"valueOf",
"(",
"size",
")",
")",
".",
"get",
"(",
"width",
")",
";",
"}",
"return",
"lookup",
"(",
"this",
".",
"locale",
",",
"width",
",",
"size",
")",
";",
"}"
] | <p>Constructs a localized list pattern suitable for the use in
{@link java.text.MessageFormat#format(String, Object[])}. </p>
@param width text width (ABBREVIATED as synonym for SHORT)
@param size count of list items
@return message format pattern with placeholders {0}, {1}, ..., {x}, ...
@throws IllegalArgumentException if size is smaller than 2 | [
"<p",
">",
"Constructs",
"a",
"localized",
"list",
"pattern",
"suitable",
"for",
"the",
"use",
"in",
"{",
"@link",
"java",
".",
"text",
".",
"MessageFormat#format",
"(",
"String",
"Object",
"[]",
")",
"}",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/UnitPatterns.java#L409-L427 |
ziccardi/jnrpe | jnrpe-plugins/src/main/java/it/jnrpe/plugin/CNativePlugin.java | CNativePlugin.execute | public final ReturnValue execute(final ICommandLine cl) {
"""
The first parameter must be the full path to the executable.
The rest of the array is sent to the executable as commands parameters
@param cl
The parsed command line
@return The return value of the plugin
"""
File fProcessFile = new File(cl.getOptionValue("executable"));
StreamManager streamMgr = new StreamManager();
if (!fProcessFile.exists()) {
return new ReturnValue(Status.UNKNOWN, "Could not exec executable : " + fProcessFile.getAbsolutePath());
}
try {
String[] vsParams = StringUtils.split(cl.getOptionValue("args", ""), false);
String[] vCommand = new String[vsParams.length + 1];
vCommand[0] = cl.getOptionValue("executable");
System.arraycopy(vsParams, 0, vCommand, 1, vsParams.length);
Process p = Runtime.getRuntime().exec(vCommand);
BufferedReader br = (BufferedReader) streamMgr.handle(new BufferedReader(new InputStreamReader(p.getInputStream())));
StringBuilder msg = new StringBuilder();
for (String line = br.readLine(); line != null; line = br.readLine()) {
if (msg.length() != 0) {
msg.append(System.lineSeparator());
}
msg.append(line);
}
int iReturnCode = p.waitFor();
return new ReturnValue(Status.fromIntValue(iReturnCode), msg.toString());
} catch (Exception e) {
String message = e.getMessage();
LOG.warn(getContext(), "Error executing the native plugin : " + message, e);
return new ReturnValue(Status.UNKNOWN, "Could not exec executable : " + fProcessFile.getName() + " - ERROR : " + message);
} finally {
streamMgr.closeAll();
}
} | java | public final ReturnValue execute(final ICommandLine cl) {
File fProcessFile = new File(cl.getOptionValue("executable"));
StreamManager streamMgr = new StreamManager();
if (!fProcessFile.exists()) {
return new ReturnValue(Status.UNKNOWN, "Could not exec executable : " + fProcessFile.getAbsolutePath());
}
try {
String[] vsParams = StringUtils.split(cl.getOptionValue("args", ""), false);
String[] vCommand = new String[vsParams.length + 1];
vCommand[0] = cl.getOptionValue("executable");
System.arraycopy(vsParams, 0, vCommand, 1, vsParams.length);
Process p = Runtime.getRuntime().exec(vCommand);
BufferedReader br = (BufferedReader) streamMgr.handle(new BufferedReader(new InputStreamReader(p.getInputStream())));
StringBuilder msg = new StringBuilder();
for (String line = br.readLine(); line != null; line = br.readLine()) {
if (msg.length() != 0) {
msg.append(System.lineSeparator());
}
msg.append(line);
}
int iReturnCode = p.waitFor();
return new ReturnValue(Status.fromIntValue(iReturnCode), msg.toString());
} catch (Exception e) {
String message = e.getMessage();
LOG.warn(getContext(), "Error executing the native plugin : " + message, e);
return new ReturnValue(Status.UNKNOWN, "Could not exec executable : " + fProcessFile.getName() + " - ERROR : " + message);
} finally {
streamMgr.closeAll();
}
} | [
"public",
"final",
"ReturnValue",
"execute",
"(",
"final",
"ICommandLine",
"cl",
")",
"{",
"File",
"fProcessFile",
"=",
"new",
"File",
"(",
"cl",
".",
"getOptionValue",
"(",
"\"executable\"",
")",
")",
";",
"StreamManager",
"streamMgr",
"=",
"new",
"StreamManager",
"(",
")",
";",
"if",
"(",
"!",
"fProcessFile",
".",
"exists",
"(",
")",
")",
"{",
"return",
"new",
"ReturnValue",
"(",
"Status",
".",
"UNKNOWN",
",",
"\"Could not exec executable : \"",
"+",
"fProcessFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"try",
"{",
"String",
"[",
"]",
"vsParams",
"=",
"StringUtils",
".",
"split",
"(",
"cl",
".",
"getOptionValue",
"(",
"\"args\"",
",",
"\"\"",
")",
",",
"false",
")",
";",
"String",
"[",
"]",
"vCommand",
"=",
"new",
"String",
"[",
"vsParams",
".",
"length",
"+",
"1",
"]",
";",
"vCommand",
"[",
"0",
"]",
"=",
"cl",
".",
"getOptionValue",
"(",
"\"executable\"",
")",
";",
"System",
".",
"arraycopy",
"(",
"vsParams",
",",
"0",
",",
"vCommand",
",",
"1",
",",
"vsParams",
".",
"length",
")",
";",
"Process",
"p",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
"vCommand",
")",
";",
"BufferedReader",
"br",
"=",
"(",
"BufferedReader",
")",
"streamMgr",
".",
"handle",
"(",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"p",
".",
"getInputStream",
"(",
")",
")",
")",
")",
";",
"StringBuilder",
"msg",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"String",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
";",
"line",
"!=",
"null",
";",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
")",
"{",
"if",
"(",
"msg",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"msg",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
";",
"}",
"msg",
".",
"append",
"(",
"line",
")",
";",
"}",
"int",
"iReturnCode",
"=",
"p",
".",
"waitFor",
"(",
")",
";",
"return",
"new",
"ReturnValue",
"(",
"Status",
".",
"fromIntValue",
"(",
"iReturnCode",
")",
",",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"message",
"=",
"e",
".",
"getMessage",
"(",
")",
";",
"LOG",
".",
"warn",
"(",
"getContext",
"(",
")",
",",
"\"Error executing the native plugin : \"",
"+",
"message",
",",
"e",
")",
";",
"return",
"new",
"ReturnValue",
"(",
"Status",
".",
"UNKNOWN",
",",
"\"Could not exec executable : \"",
"+",
"fProcessFile",
".",
"getName",
"(",
")",
"+",
"\" - ERROR : \"",
"+",
"message",
")",
";",
"}",
"finally",
"{",
"streamMgr",
".",
"closeAll",
"(",
")",
";",
"}",
"}"
] | The first parameter must be the full path to the executable.
The rest of the array is sent to the executable as commands parameters
@param cl
The parsed command line
@return The return value of the plugin | [
"The",
"first",
"parameter",
"must",
"be",
"the",
"full",
"path",
"to",
"the",
"executable",
"."
] | train | https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-plugins/src/main/java/it/jnrpe/plugin/CNativePlugin.java#L45-L80 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java | ArabicShaping.countSpaceSub | private static int countSpaceSub(char [] dest,int length, char subChar) {
"""
/*
Name : countSpaceSub
Function: Counts number of times the subChar appears in the array
"""
int i = 0;
int count = 0;
while (i < length) {
if (dest[i] == subChar) {
count++;
}
i++;
}
return count;
} | java | private static int countSpaceSub(char [] dest,int length, char subChar){
int i = 0;
int count = 0;
while (i < length) {
if (dest[i] == subChar) {
count++;
}
i++;
}
return count;
} | [
"private",
"static",
"int",
"countSpaceSub",
"(",
"char",
"[",
"]",
"dest",
",",
"int",
"length",
",",
"char",
"subChar",
")",
"{",
"int",
"i",
"=",
"0",
";",
"int",
"count",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"length",
")",
"{",
"if",
"(",
"dest",
"[",
"i",
"]",
"==",
"subChar",
")",
"{",
"count",
"++",
";",
"}",
"i",
"++",
";",
"}",
"return",
"count",
";",
"}"
] | /*
Name : countSpaceSub
Function: Counts number of times the subChar appears in the array | [
"/",
"*",
"Name",
":",
"countSpaceSub",
"Function",
":",
"Counts",
"number",
"of",
"times",
"the",
"subChar",
"appears",
"in",
"the",
"array"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/ArabicShaping.java#L1149-L1159 |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.addOperation | protected void addOperation(final MemcachedNode node, final Operation o) {
"""
Enqueue an operation on the given node.
@param node the node where to enqueue the {@link Operation}.
@param o the operation to add.
"""
if (!node.isAuthenticated()) {
retryOperation(o);
return;
}
o.setHandlingNode(node);
o.initialize();
node.addOp(o);
addedQueue.offer(node);
metrics.markMeter(OVERALL_REQUEST_METRIC);
Selector s = selector.wakeup();
assert s == selector : "Wakeup returned the wrong selector.";
getLogger().debug("Added %s to %s", o, node);
} | java | protected void addOperation(final MemcachedNode node, final Operation o) {
if (!node.isAuthenticated()) {
retryOperation(o);
return;
}
o.setHandlingNode(node);
o.initialize();
node.addOp(o);
addedQueue.offer(node);
metrics.markMeter(OVERALL_REQUEST_METRIC);
Selector s = selector.wakeup();
assert s == selector : "Wakeup returned the wrong selector.";
getLogger().debug("Added %s to %s", o, node);
} | [
"protected",
"void",
"addOperation",
"(",
"final",
"MemcachedNode",
"node",
",",
"final",
"Operation",
"o",
")",
"{",
"if",
"(",
"!",
"node",
".",
"isAuthenticated",
"(",
")",
")",
"{",
"retryOperation",
"(",
"o",
")",
";",
"return",
";",
"}",
"o",
".",
"setHandlingNode",
"(",
"node",
")",
";",
"o",
".",
"initialize",
"(",
")",
";",
"node",
".",
"addOp",
"(",
"o",
")",
";",
"addedQueue",
".",
"offer",
"(",
"node",
")",
";",
"metrics",
".",
"markMeter",
"(",
"OVERALL_REQUEST_METRIC",
")",
";",
"Selector",
"s",
"=",
"selector",
".",
"wakeup",
"(",
")",
";",
"assert",
"s",
"==",
"selector",
":",
"\"Wakeup returned the wrong selector.\"",
";",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"Added %s to %s\"",
",",
"o",
",",
"node",
")",
";",
"}"
] | Enqueue an operation on the given node.
@param node the node where to enqueue the {@link Operation}.
@param o the operation to add. | [
"Enqueue",
"an",
"operation",
"on",
"the",
"given",
"node",
"."
] | train | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1274-L1288 |
derari/cthul | xml/src/main/java/org/cthul/resolve/ResolvingException.java | ResolvingException.againAs | public <T1 extends Throwable>
RuntimeException againAs(Class<T1> t1)
throws T1 {
"""
Throws the {@linkplain #getResolvingCause() cause} if it is the
specified type, otherwise returns a
{@linkplain #asRuntimeException() runtime exception}.
<p>
Intended to be written as {@code throw e.againAs(IOException.class)}.
@param <T1>
@param t1
@return
@throws T1
"""
return againAs(t1, NULL_EX, NULL_EX, NULL_EX);
} | java | public <T1 extends Throwable>
RuntimeException againAs(Class<T1> t1)
throws T1 {
return againAs(t1, NULL_EX, NULL_EX, NULL_EX);
} | [
"public",
"<",
"T1",
"extends",
"Throwable",
">",
"RuntimeException",
"againAs",
"(",
"Class",
"<",
"T1",
">",
"t1",
")",
"throws",
"T1",
"{",
"return",
"againAs",
"(",
"t1",
",",
"NULL_EX",
",",
"NULL_EX",
",",
"NULL_EX",
")",
";",
"}"
] | Throws the {@linkplain #getResolvingCause() cause} if it is the
specified type, otherwise returns a
{@linkplain #asRuntimeException() runtime exception}.
<p>
Intended to be written as {@code throw e.againAs(IOException.class)}.
@param <T1>
@param t1
@return
@throws T1 | [
"Throws",
"the",
"{"
] | train | https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/xml/src/main/java/org/cthul/resolve/ResolvingException.java#L143-L147 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/MergeRequestApi.java | MergeRequestApi.createMergeRequest | public MergeRequest createMergeRequest(Object projectIdOrPath, String sourceBranch, String targetBranch, String title, String description, Integer assigneeId)
throws GitLabApiException {
"""
Creates a merge request and optionally assigns a reviewer to it.
<pre><code>GitLab Endpoint: POST /projects/:id/merge_requests</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param sourceBranch the source branch, required
@param targetBranch the target branch, required
@param title the title for the merge request, required
@param description the description of the merge request
@param assigneeId the Assignee user ID, optional
@return the created MergeRequest instance
@throws GitLabApiException if any exception occurs
"""
return createMergeRequest(projectIdOrPath, sourceBranch, targetBranch, title, description, assigneeId, null, null, null, null);
} | java | public MergeRequest createMergeRequest(Object projectIdOrPath, String sourceBranch, String targetBranch, String title, String description, Integer assigneeId)
throws GitLabApiException {
return createMergeRequest(projectIdOrPath, sourceBranch, targetBranch, title, description, assigneeId, null, null, null, null);
} | [
"public",
"MergeRequest",
"createMergeRequest",
"(",
"Object",
"projectIdOrPath",
",",
"String",
"sourceBranch",
",",
"String",
"targetBranch",
",",
"String",
"title",
",",
"String",
"description",
",",
"Integer",
"assigneeId",
")",
"throws",
"GitLabApiException",
"{",
"return",
"createMergeRequest",
"(",
"projectIdOrPath",
",",
"sourceBranch",
",",
"targetBranch",
",",
"title",
",",
"description",
",",
"assigneeId",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}"
] | Creates a merge request and optionally assigns a reviewer to it.
<pre><code>GitLab Endpoint: POST /projects/:id/merge_requests</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param sourceBranch the source branch, required
@param targetBranch the target branch, required
@param title the title for the merge request, required
@param description the description of the merge request
@param assigneeId the Assignee user ID, optional
@return the created MergeRequest instance
@throws GitLabApiException if any exception occurs | [
"Creates",
"a",
"merge",
"request",
"and",
"optionally",
"assigns",
"a",
"reviewer",
"to",
"it",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/MergeRequestApi.java#L415-L418 |
facebook/fresco | samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/util/SizeUtil.java | SizeUtil.calcDesiredSize | public static int calcDesiredSize(Context context, int parentWidth, int parentHeight) {
"""
Calculate desired size for the given View based on device orientation
@param context The Context
@param parentWidth The width of the Parent View
@param parentHeight The height of the Parent View
@return The desired size for the View
"""
int orientation = context.getResources().getConfiguration().orientation;
int desiredSize = (orientation == Configuration.ORIENTATION_LANDSCAPE) ?
parentWidth : parentHeight;
return Math.min(desiredSize, parentWidth);
} | java | public static int calcDesiredSize(Context context, int parentWidth, int parentHeight) {
int orientation = context.getResources().getConfiguration().orientation;
int desiredSize = (orientation == Configuration.ORIENTATION_LANDSCAPE) ?
parentWidth : parentHeight;
return Math.min(desiredSize, parentWidth);
} | [
"public",
"static",
"int",
"calcDesiredSize",
"(",
"Context",
"context",
",",
"int",
"parentWidth",
",",
"int",
"parentHeight",
")",
"{",
"int",
"orientation",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getConfiguration",
"(",
")",
".",
"orientation",
";",
"int",
"desiredSize",
"=",
"(",
"orientation",
"==",
"Configuration",
".",
"ORIENTATION_LANDSCAPE",
")",
"?",
"parentWidth",
":",
"parentHeight",
";",
"return",
"Math",
".",
"min",
"(",
"desiredSize",
",",
"parentWidth",
")",
";",
"}"
] | Calculate desired size for the given View based on device orientation
@param context The Context
@param parentWidth The width of the Parent View
@param parentHeight The height of the Parent View
@return The desired size for the View | [
"Calculate",
"desired",
"size",
"for",
"the",
"given",
"View",
"based",
"on",
"device",
"orientation"
] | train | https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/scrollperf/src/main/java/com/facebook/samples/scrollperf/util/SizeUtil.java#L57-L62 |
camunda/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryImpl.java | TaskQueryImpl.mergeVariables | protected void mergeVariables(TaskQueryImpl extendedQuery, TaskQueryImpl extendingQuery) {
"""
Simple implementation of variable merging. Variables are only overridden if they have the same name and are
in the same scope (ie are process instance, task or case execution variables).
"""
List<TaskQueryVariableValue> extendingVariables = extendingQuery.getVariables();
Set<TaskQueryVariableValueComparable> extendingVariablesComparable = new HashSet<TaskQueryVariableValueComparable>();
// set extending variables and save names for comparison of original variables
for (TaskQueryVariableValue extendingVariable : extendingVariables) {
extendedQuery.addVariable(extendingVariable);
extendingVariablesComparable.add(new TaskQueryVariableValueComparable(extendingVariable));
}
for (TaskQueryVariableValue originalVariable : this.getVariables()) {
if (!extendingVariablesComparable.contains(new TaskQueryVariableValueComparable(originalVariable))) {
extendedQuery.addVariable(originalVariable);
}
}
} | java | protected void mergeVariables(TaskQueryImpl extendedQuery, TaskQueryImpl extendingQuery) {
List<TaskQueryVariableValue> extendingVariables = extendingQuery.getVariables();
Set<TaskQueryVariableValueComparable> extendingVariablesComparable = new HashSet<TaskQueryVariableValueComparable>();
// set extending variables and save names for comparison of original variables
for (TaskQueryVariableValue extendingVariable : extendingVariables) {
extendedQuery.addVariable(extendingVariable);
extendingVariablesComparable.add(new TaskQueryVariableValueComparable(extendingVariable));
}
for (TaskQueryVariableValue originalVariable : this.getVariables()) {
if (!extendingVariablesComparable.contains(new TaskQueryVariableValueComparable(originalVariable))) {
extendedQuery.addVariable(originalVariable);
}
}
} | [
"protected",
"void",
"mergeVariables",
"(",
"TaskQueryImpl",
"extendedQuery",
",",
"TaskQueryImpl",
"extendingQuery",
")",
"{",
"List",
"<",
"TaskQueryVariableValue",
">",
"extendingVariables",
"=",
"extendingQuery",
".",
"getVariables",
"(",
")",
";",
"Set",
"<",
"TaskQueryVariableValueComparable",
">",
"extendingVariablesComparable",
"=",
"new",
"HashSet",
"<",
"TaskQueryVariableValueComparable",
">",
"(",
")",
";",
"// set extending variables and save names for comparison of original variables",
"for",
"(",
"TaskQueryVariableValue",
"extendingVariable",
":",
"extendingVariables",
")",
"{",
"extendedQuery",
".",
"addVariable",
"(",
"extendingVariable",
")",
";",
"extendingVariablesComparable",
".",
"add",
"(",
"new",
"TaskQueryVariableValueComparable",
"(",
"extendingVariable",
")",
")",
";",
"}",
"for",
"(",
"TaskQueryVariableValue",
"originalVariable",
":",
"this",
".",
"getVariables",
"(",
")",
")",
"{",
"if",
"(",
"!",
"extendingVariablesComparable",
".",
"contains",
"(",
"new",
"TaskQueryVariableValueComparable",
"(",
"originalVariable",
")",
")",
")",
"{",
"extendedQuery",
".",
"addVariable",
"(",
"originalVariable",
")",
";",
"}",
"}",
"}"
] | Simple implementation of variable merging. Variables are only overridden if they have the same name and are
in the same scope (ie are process instance, task or case execution variables). | [
"Simple",
"implementation",
"of",
"variable",
"merging",
".",
"Variables",
"are",
"only",
"overridden",
"if",
"they",
"have",
"the",
"same",
"name",
"and",
"are",
"in",
"the",
"same",
"scope",
"(",
"ie",
"are",
"process",
"instance",
"task",
"or",
"case",
"execution",
"variables",
")",
"."
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryImpl.java#L2078-L2095 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.