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
|
---|---|---|---|---|---|---|---|---|---|---|
ops4j/org.ops4j.pax.logging | pax-logging-api/src/main/java/org/apache/logging/log4j/message/StringFormatterMessageFactory.java | StringFormatterMessageFactory.newMessage | @Override
public Message newMessage(final String message, final Object... params) {
"""
Creates {@link StringFormattedMessage} instances.
@param message The message pattern.
@param params The parameters to the message.
@return The Message.
@see MessageFactory#newMessage(String, Object...)
"""
return new StringFormattedMessage(message, params);
} | java | @Override
public Message newMessage(final String message, final Object... params) {
return new StringFormattedMessage(message, params);
} | [
"@",
"Override",
"public",
"Message",
"newMessage",
"(",
"final",
"String",
"message",
",",
"final",
"Object",
"...",
"params",
")",
"{",
"return",
"new",
"StringFormattedMessage",
"(",
"message",
",",
"params",
")",
";",
"}"
] | Creates {@link StringFormattedMessage} instances.
@param message The message pattern.
@param params The parameters to the message.
@return The Message.
@see MessageFactory#newMessage(String, Object...) | [
"Creates",
"{",
"@link",
"StringFormattedMessage",
"}",
"instances",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/apache/logging/log4j/message/StringFormatterMessageFactory.java#L60-L63 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java | DefaultDisseminatorImpl.viewObjectProfile | public MIMETypedStream viewObjectProfile() throws ServerException {
"""
Returns an HTML rendering of the object profile which contains key
metadata from the object, plus URLs for the object's Dissemination Index
and Item Index. The data is returned as HTML in a presentation-oriented
format. This is accomplished by doing an XSLT transform on the XML that
is obtained from getObjectProfile in API-A.
@return html packaged as a MIMETypedStream
@throws ServerException
"""
try {
ObjectProfile profile =
m_access.getObjectProfile(context,
reader.GetObjectPID(),
asOfDateTime);
Reader in = null;
try {
ReadableCharArrayWriter out = new ReadableCharArrayWriter(1024);
DefaultSerializer.objectProfileToXML(profile, asOfDateTime, out);
out.close();
in = out.toReader();
} catch (IOException ioe) {
throw new GeneralException("[DefaultDisseminatorImpl] An error has occurred. "
+ "The error was a \""
+ ioe.getClass().getName()
+ "\" . The "
+ "Reason was \""
+ ioe.getMessage()
+ "\" .");
}
//InputStream in = getObjectProfile().getStream();
ReadableByteArrayOutputStream bytes =
new ReadableByteArrayOutputStream(4096);
PrintWriter out =
new PrintWriter(
new OutputStreamWriter(bytes, Charset.forName("UTF-8")));
File xslFile =
new File(reposHomeDir, "access/viewObjectProfile.xslt");
Templates template =
XmlTransformUtility.getTemplates(xslFile);
Transformer transformer = template.newTransformer();
transformer.setParameter("fedora", context
.getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME));
transformer.transform(new StreamSource(in), new StreamResult(out));
out.close();
return new MIMETypedStream("text/html", bytes.toInputStream(),
null, bytes.length());
} catch (Exception e) {
throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
+ "in transforming xml for viewObjectProfile. "
+ "Underlying exception was: " + e.getMessage());
}
} | java | public MIMETypedStream viewObjectProfile() throws ServerException {
try {
ObjectProfile profile =
m_access.getObjectProfile(context,
reader.GetObjectPID(),
asOfDateTime);
Reader in = null;
try {
ReadableCharArrayWriter out = new ReadableCharArrayWriter(1024);
DefaultSerializer.objectProfileToXML(profile, asOfDateTime, out);
out.close();
in = out.toReader();
} catch (IOException ioe) {
throw new GeneralException("[DefaultDisseminatorImpl] An error has occurred. "
+ "The error was a \""
+ ioe.getClass().getName()
+ "\" . The "
+ "Reason was \""
+ ioe.getMessage()
+ "\" .");
}
//InputStream in = getObjectProfile().getStream();
ReadableByteArrayOutputStream bytes =
new ReadableByteArrayOutputStream(4096);
PrintWriter out =
new PrintWriter(
new OutputStreamWriter(bytes, Charset.forName("UTF-8")));
File xslFile =
new File(reposHomeDir, "access/viewObjectProfile.xslt");
Templates template =
XmlTransformUtility.getTemplates(xslFile);
Transformer transformer = template.newTransformer();
transformer.setParameter("fedora", context
.getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME));
transformer.transform(new StreamSource(in), new StreamResult(out));
out.close();
return new MIMETypedStream("text/html", bytes.toInputStream(),
null, bytes.length());
} catch (Exception e) {
throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
+ "in transforming xml for viewObjectProfile. "
+ "Underlying exception was: " + e.getMessage());
}
} | [
"public",
"MIMETypedStream",
"viewObjectProfile",
"(",
")",
"throws",
"ServerException",
"{",
"try",
"{",
"ObjectProfile",
"profile",
"=",
"m_access",
".",
"getObjectProfile",
"(",
"context",
",",
"reader",
".",
"GetObjectPID",
"(",
")",
",",
"asOfDateTime",
")",
";",
"Reader",
"in",
"=",
"null",
";",
"try",
"{",
"ReadableCharArrayWriter",
"out",
"=",
"new",
"ReadableCharArrayWriter",
"(",
"1024",
")",
";",
"DefaultSerializer",
".",
"objectProfileToXML",
"(",
"profile",
",",
"asOfDateTime",
",",
"out",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"in",
"=",
"out",
".",
"toReader",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"GeneralException",
"(",
"\"[DefaultDisseminatorImpl] An error has occurred. \"",
"+",
"\"The error was a \\\"\"",
"+",
"ioe",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"\\\" . The \"",
"+",
"\"Reason was \\\"\"",
"+",
"ioe",
".",
"getMessage",
"(",
")",
"+",
"\"\\\" .\"",
")",
";",
"}",
"//InputStream in = getObjectProfile().getStream();",
"ReadableByteArrayOutputStream",
"bytes",
"=",
"new",
"ReadableByteArrayOutputStream",
"(",
"4096",
")",
";",
"PrintWriter",
"out",
"=",
"new",
"PrintWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"bytes",
",",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
")",
")",
";",
"File",
"xslFile",
"=",
"new",
"File",
"(",
"reposHomeDir",
",",
"\"access/viewObjectProfile.xslt\"",
")",
";",
"Templates",
"template",
"=",
"XmlTransformUtility",
".",
"getTemplates",
"(",
"xslFile",
")",
";",
"Transformer",
"transformer",
"=",
"template",
".",
"newTransformer",
"(",
")",
";",
"transformer",
".",
"setParameter",
"(",
"\"fedora\"",
",",
"context",
".",
"getEnvironmentValue",
"(",
"Constants",
".",
"FEDORA_APP_CONTEXT_NAME",
")",
")",
";",
"transformer",
".",
"transform",
"(",
"new",
"StreamSource",
"(",
"in",
")",
",",
"new",
"StreamResult",
"(",
"out",
")",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"return",
"new",
"MIMETypedStream",
"(",
"\"text/html\"",
",",
"bytes",
".",
"toInputStream",
"(",
")",
",",
"null",
",",
"bytes",
".",
"length",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"DisseminationException",
"(",
"\"[DefaultDisseminatorImpl] had an error \"",
"+",
"\"in transforming xml for viewObjectProfile. \"",
"+",
"\"Underlying exception was: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Returns an HTML rendering of the object profile which contains key
metadata from the object, plus URLs for the object's Dissemination Index
and Item Index. The data is returned as HTML in a presentation-oriented
format. This is accomplished by doing an XSLT transform on the XML that
is obtained from getObjectProfile in API-A.
@return html packaged as a MIMETypedStream
@throws ServerException | [
"Returns",
"an",
"HTML",
"rendering",
"of",
"the",
"object",
"profile",
"which",
"contains",
"key",
"metadata",
"from",
"the",
"object",
"plus",
"URLs",
"for",
"the",
"object",
"s",
"Dissemination",
"Index",
"and",
"Item",
"Index",
".",
"The",
"data",
"is",
"returned",
"as",
"HTML",
"in",
"a",
"presentation",
"-",
"oriented",
"format",
".",
"This",
"is",
"accomplished",
"by",
"doing",
"an",
"XSLT",
"transform",
"on",
"the",
"XML",
"that",
"is",
"obtained",
"from",
"getObjectProfile",
"in",
"API",
"-",
"A",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java#L102-L145 |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Transform3D.java | Transform3D.setTranslation | public void setTranslation(double x, double y, double z) {
"""
Set the position.
<p>
This function changes only the elements of
the matrix related to the translation.
The scaling and the shearing are not changed.
<p>
After a call to this function, the matrix will
contains (? means any value):
<pre>
[ ? ? x ]
[ ? ? y ]
[ ? ? z ]
[ ? ? ? ]
</pre>
@param x
@param y
@param z
@see #makeTranslationMatrix(double, double, double)
"""
this.m03 = x;
this.m13 = y;
this.m23 = z;
} | java | public void setTranslation(double x, double y, double z) {
this.m03 = x;
this.m13 = y;
this.m23 = z;
} | [
"public",
"void",
"setTranslation",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"this",
".",
"m03",
"=",
"x",
";",
"this",
".",
"m13",
"=",
"y",
";",
"this",
".",
"m23",
"=",
"z",
";",
"}"
] | Set the position.
<p>
This function changes only the elements of
the matrix related to the translation.
The scaling and the shearing are not changed.
<p>
After a call to this function, the matrix will
contains (? means any value):
<pre>
[ ? ? x ]
[ ? ? y ]
[ ? ? z ]
[ ? ? ? ]
</pre>
@param x
@param y
@param z
@see #makeTranslationMatrix(double, double, double) | [
"Set",
"the",
"position",
".",
"<p",
">",
"This",
"function",
"changes",
"only",
"the",
"elements",
"of",
"the",
"matrix",
"related",
"to",
"the",
"translation",
".",
"The",
"scaling",
"and",
"the",
"shearing",
"are",
"not",
"changed",
".",
"<p",
">",
"After",
"a",
"call",
"to",
"this",
"function",
"the",
"matrix",
"will",
"contains",
"(",
"?",
"means",
"any",
"value",
")",
":",
"<pre",
">",
"[",
"?",
"?",
"x",
"]",
"[",
"?",
"?",
"y",
"]",
"[",
"?",
"?",
"z",
"]",
"[",
"?",
"?",
"?",
"]",
"<",
"/",
"pre",
">"
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Transform3D.java#L136-L140 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPRulePersistenceImpl.java | CPRulePersistenceImpl.findAll | @Override
public List<CPRule> findAll(int start, int end) {
"""
Returns a range of all the cp rules.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPRuleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of cp rules
@param end the upper bound of the range of cp rules (not inclusive)
@return the range of cp rules
"""
return findAll(start, end, null);
} | java | @Override
public List<CPRule> findAll(int start, int end) {
return findAll(start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CPRule",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the cp rules.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPRuleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of cp rules
@param end the upper bound of the range of cp rules (not inclusive)
@return the range of cp rules | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"cp",
"rules",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPRulePersistenceImpl.java#L1467-L1470 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/searchindex/CmsFieldsList.java | CmsFieldsList.fillDetailField | private void fillDetailField(CmsListItem item, String detailId) {
"""
Fills details of the field into the given item. <p>
@param item the list item to fill
@param detailId the id for the detail to fill
"""
StringBuffer html = new StringBuffer();
// search for the corresponding A_CmsSearchIndex:
String idxFieldName = (String)item.get(LIST_COLUMN_NAME);
List<CmsSearchField> fields = OpenCms.getSearchManager().getFieldConfiguration(
m_paramFieldconfiguration).getFields();
Iterator<CmsSearchField> itFields = fields.iterator();
CmsLuceneField idxField = null;
while (itFields.hasNext()) {
CmsLuceneField curField = (CmsLuceneField)itFields.next();
if (curField.getName().equals(idxFieldName)) {
idxField = curField;
}
}
if (idxField != null) {
html.append("<ul>\n");
Iterator<I_CmsSearchFieldMapping> itMappings = idxField.getMappings().iterator();
while (itMappings.hasNext()) {
CmsSearchFieldMapping mapping = (CmsSearchFieldMapping)itMappings.next();
html.append(" <li>\n").append(" ");
html.append(mapping.getType().toString());
if (CmsStringUtil.isNotEmpty(mapping.getParam())) {
html.append("=").append(mapping.getParam()).append("\n");
}
html.append(" </li>");
}
html.append("</ul>\n");
}
item.set(detailId, html.toString());
} | java | private void fillDetailField(CmsListItem item, String detailId) {
StringBuffer html = new StringBuffer();
// search for the corresponding A_CmsSearchIndex:
String idxFieldName = (String)item.get(LIST_COLUMN_NAME);
List<CmsSearchField> fields = OpenCms.getSearchManager().getFieldConfiguration(
m_paramFieldconfiguration).getFields();
Iterator<CmsSearchField> itFields = fields.iterator();
CmsLuceneField idxField = null;
while (itFields.hasNext()) {
CmsLuceneField curField = (CmsLuceneField)itFields.next();
if (curField.getName().equals(idxFieldName)) {
idxField = curField;
}
}
if (idxField != null) {
html.append("<ul>\n");
Iterator<I_CmsSearchFieldMapping> itMappings = idxField.getMappings().iterator();
while (itMappings.hasNext()) {
CmsSearchFieldMapping mapping = (CmsSearchFieldMapping)itMappings.next();
html.append(" <li>\n").append(" ");
html.append(mapping.getType().toString());
if (CmsStringUtil.isNotEmpty(mapping.getParam())) {
html.append("=").append(mapping.getParam()).append("\n");
}
html.append(" </li>");
}
html.append("</ul>\n");
}
item.set(detailId, html.toString());
} | [
"private",
"void",
"fillDetailField",
"(",
"CmsListItem",
"item",
",",
"String",
"detailId",
")",
"{",
"StringBuffer",
"html",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"// search for the corresponding A_CmsSearchIndex:",
"String",
"idxFieldName",
"=",
"(",
"String",
")",
"item",
".",
"get",
"(",
"LIST_COLUMN_NAME",
")",
";",
"List",
"<",
"CmsSearchField",
">",
"fields",
"=",
"OpenCms",
".",
"getSearchManager",
"(",
")",
".",
"getFieldConfiguration",
"(",
"m_paramFieldconfiguration",
")",
".",
"getFields",
"(",
")",
";",
"Iterator",
"<",
"CmsSearchField",
">",
"itFields",
"=",
"fields",
".",
"iterator",
"(",
")",
";",
"CmsLuceneField",
"idxField",
"=",
"null",
";",
"while",
"(",
"itFields",
".",
"hasNext",
"(",
")",
")",
"{",
"CmsLuceneField",
"curField",
"=",
"(",
"CmsLuceneField",
")",
"itFields",
".",
"next",
"(",
")",
";",
"if",
"(",
"curField",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"idxFieldName",
")",
")",
"{",
"idxField",
"=",
"curField",
";",
"}",
"}",
"if",
"(",
"idxField",
"!=",
"null",
")",
"{",
"html",
".",
"append",
"(",
"\"<ul>\\n\"",
")",
";",
"Iterator",
"<",
"I_CmsSearchFieldMapping",
">",
"itMappings",
"=",
"idxField",
".",
"getMappings",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"itMappings",
".",
"hasNext",
"(",
")",
")",
"{",
"CmsSearchFieldMapping",
"mapping",
"=",
"(",
"CmsSearchFieldMapping",
")",
"itMappings",
".",
"next",
"(",
")",
";",
"html",
".",
"append",
"(",
"\" <li>\\n\"",
")",
".",
"append",
"(",
"\" \"",
")",
";",
"html",
".",
"append",
"(",
"mapping",
".",
"getType",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"CmsStringUtil",
".",
"isNotEmpty",
"(",
"mapping",
".",
"getParam",
"(",
")",
")",
")",
"{",
"html",
".",
"append",
"(",
"\"=\"",
")",
".",
"append",
"(",
"mapping",
".",
"getParam",
"(",
")",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"html",
".",
"append",
"(",
"\" </li>\"",
")",
";",
"}",
"html",
".",
"append",
"(",
"\"</ul>\\n\"",
")",
";",
"}",
"item",
".",
"set",
"(",
"detailId",
",",
"html",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Fills details of the field into the given item. <p>
@param item the list item to fill
@param detailId the id for the detail to fill | [
"Fills",
"details",
"of",
"the",
"field",
"into",
"the",
"given",
"item",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/searchindex/CmsFieldsList.java#L681-L713 |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUESubspace.java | CLIQUESubspace.rightNeighbor | protected CLIQUEUnit rightNeighbor(CLIQUEUnit unit, int dim) {
"""
Returns the right neighbor of the given unit in the specified dimension.
@param unit the unit to determine the right neighbor for
@param dim the dimension
@return the right neighbor of the given unit in the specified dimension
"""
for(CLIQUEUnit u : denseUnits) {
if(u.containsRightNeighbor(unit, dim)) {
return u;
}
}
return null;
} | java | protected CLIQUEUnit rightNeighbor(CLIQUEUnit unit, int dim) {
for(CLIQUEUnit u : denseUnits) {
if(u.containsRightNeighbor(unit, dim)) {
return u;
}
}
return null;
} | [
"protected",
"CLIQUEUnit",
"rightNeighbor",
"(",
"CLIQUEUnit",
"unit",
",",
"int",
"dim",
")",
"{",
"for",
"(",
"CLIQUEUnit",
"u",
":",
"denseUnits",
")",
"{",
"if",
"(",
"u",
".",
"containsRightNeighbor",
"(",
"unit",
",",
"dim",
")",
")",
"{",
"return",
"u",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the right neighbor of the given unit in the specified dimension.
@param unit the unit to determine the right neighbor for
@param dim the dimension
@return the right neighbor of the given unit in the specified dimension | [
"Returns",
"the",
"right",
"neighbor",
"of",
"the",
"given",
"unit",
"in",
"the",
"specified",
"dimension",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/clique/CLIQUESubspace.java#L162-L169 |
JOML-CI/JOML | src/org/joml/Quaterniond.java | Quaterniond.lookAlong | public Quaterniond lookAlong(double dirX, double dirY, double dirZ, double upX, double upY, double upZ, Quaterniond dest) {
"""
/* (non-Javadoc)
@see org.joml.Quaterniondc#lookAlong(double, double, double, double, double, double, org.joml.Quaterniond)
"""
// Normalize direction
double invDirLength = 1.0 / Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
double dirnX = -dirX * invDirLength;
double dirnY = -dirY * invDirLength;
double dirnZ = -dirZ * invDirLength;
// left = up x dir
double leftX, leftY, leftZ;
leftX = upY * dirnZ - upZ * dirnY;
leftY = upZ * dirnX - upX * dirnZ;
leftZ = upX * dirnY - upY * dirnX;
// normalize left
double invLeftLength = 1.0 / Math.sqrt(leftX * leftX + leftY * leftY + leftZ * leftZ);
leftX *= invLeftLength;
leftY *= invLeftLength;
leftZ *= invLeftLength;
// up = direction x left
double upnX = dirnY * leftZ - dirnZ * leftY;
double upnY = dirnZ * leftX - dirnX * leftZ;
double upnZ = dirnX * leftY - dirnY * leftX;
/* Convert orthonormal basis vectors to quaternion */
double x, y, z, w;
double t;
double tr = leftX + upnY + dirnZ;
if (tr >= 0.0) {
t = Math.sqrt(tr + 1.0);
w = t * 0.5;
t = 0.5 / t;
x = (dirnY - upnZ) * t;
y = (leftZ - dirnX) * t;
z = (upnX - leftY) * t;
} else {
if (leftX > upnY && leftX > dirnZ) {
t = Math.sqrt(1.0 + leftX - upnY - dirnZ);
x = t * 0.5;
t = 0.5 / t;
y = (leftY + upnX) * t;
z = (dirnX + leftZ) * t;
w = (dirnY - upnZ) * t;
} else if (upnY > dirnZ) {
t = Math.sqrt(1.0 + upnY - leftX - dirnZ);
y = t * 0.5;
t = 0.5 / t;
x = (leftY + upnX) * t;
z = (upnZ + dirnY) * t;
w = (leftZ - dirnX) * t;
} else {
t = Math.sqrt(1.0 + dirnZ - leftX - upnY);
z = t * 0.5;
t = 0.5 / t;
x = (dirnX + leftZ) * t;
y = (upnZ + dirnY) * t;
w = (upnX - leftY) * t;
}
}
/* Multiply */
dest.set(this.w * x + this.x * w + this.y * z - this.z * y,
this.w * y - this.x * z + this.y * w + this.z * x,
this.w * z + this.x * y - this.y * x + this.z * w,
this.w * w - this.x * x - this.y * y - this.z * z);
return dest;
} | java | public Quaterniond lookAlong(double dirX, double dirY, double dirZ, double upX, double upY, double upZ, Quaterniond dest) {
// Normalize direction
double invDirLength = 1.0 / Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
double dirnX = -dirX * invDirLength;
double dirnY = -dirY * invDirLength;
double dirnZ = -dirZ * invDirLength;
// left = up x dir
double leftX, leftY, leftZ;
leftX = upY * dirnZ - upZ * dirnY;
leftY = upZ * dirnX - upX * dirnZ;
leftZ = upX * dirnY - upY * dirnX;
// normalize left
double invLeftLength = 1.0 / Math.sqrt(leftX * leftX + leftY * leftY + leftZ * leftZ);
leftX *= invLeftLength;
leftY *= invLeftLength;
leftZ *= invLeftLength;
// up = direction x left
double upnX = dirnY * leftZ - dirnZ * leftY;
double upnY = dirnZ * leftX - dirnX * leftZ;
double upnZ = dirnX * leftY - dirnY * leftX;
/* Convert orthonormal basis vectors to quaternion */
double x, y, z, w;
double t;
double tr = leftX + upnY + dirnZ;
if (tr >= 0.0) {
t = Math.sqrt(tr + 1.0);
w = t * 0.5;
t = 0.5 / t;
x = (dirnY - upnZ) * t;
y = (leftZ - dirnX) * t;
z = (upnX - leftY) * t;
} else {
if (leftX > upnY && leftX > dirnZ) {
t = Math.sqrt(1.0 + leftX - upnY - dirnZ);
x = t * 0.5;
t = 0.5 / t;
y = (leftY + upnX) * t;
z = (dirnX + leftZ) * t;
w = (dirnY - upnZ) * t;
} else if (upnY > dirnZ) {
t = Math.sqrt(1.0 + upnY - leftX - dirnZ);
y = t * 0.5;
t = 0.5 / t;
x = (leftY + upnX) * t;
z = (upnZ + dirnY) * t;
w = (leftZ - dirnX) * t;
} else {
t = Math.sqrt(1.0 + dirnZ - leftX - upnY);
z = t * 0.5;
t = 0.5 / t;
x = (dirnX + leftZ) * t;
y = (upnZ + dirnY) * t;
w = (upnX - leftY) * t;
}
}
/* Multiply */
dest.set(this.w * x + this.x * w + this.y * z - this.z * y,
this.w * y - this.x * z + this.y * w + this.z * x,
this.w * z + this.x * y - this.y * x + this.z * w,
this.w * w - this.x * x - this.y * y - this.z * z);
return dest;
} | [
"public",
"Quaterniond",
"lookAlong",
"(",
"double",
"dirX",
",",
"double",
"dirY",
",",
"double",
"dirZ",
",",
"double",
"upX",
",",
"double",
"upY",
",",
"double",
"upZ",
",",
"Quaterniond",
"dest",
")",
"{",
"// Normalize direction",
"double",
"invDirLength",
"=",
"1.0",
"/",
"Math",
".",
"sqrt",
"(",
"dirX",
"*",
"dirX",
"+",
"dirY",
"*",
"dirY",
"+",
"dirZ",
"*",
"dirZ",
")",
";",
"double",
"dirnX",
"=",
"-",
"dirX",
"*",
"invDirLength",
";",
"double",
"dirnY",
"=",
"-",
"dirY",
"*",
"invDirLength",
";",
"double",
"dirnZ",
"=",
"-",
"dirZ",
"*",
"invDirLength",
";",
"// left = up x dir",
"double",
"leftX",
",",
"leftY",
",",
"leftZ",
";",
"leftX",
"=",
"upY",
"*",
"dirnZ",
"-",
"upZ",
"*",
"dirnY",
";",
"leftY",
"=",
"upZ",
"*",
"dirnX",
"-",
"upX",
"*",
"dirnZ",
";",
"leftZ",
"=",
"upX",
"*",
"dirnY",
"-",
"upY",
"*",
"dirnX",
";",
"// normalize left",
"double",
"invLeftLength",
"=",
"1.0",
"/",
"Math",
".",
"sqrt",
"(",
"leftX",
"*",
"leftX",
"+",
"leftY",
"*",
"leftY",
"+",
"leftZ",
"*",
"leftZ",
")",
";",
"leftX",
"*=",
"invLeftLength",
";",
"leftY",
"*=",
"invLeftLength",
";",
"leftZ",
"*=",
"invLeftLength",
";",
"// up = direction x left",
"double",
"upnX",
"=",
"dirnY",
"*",
"leftZ",
"-",
"dirnZ",
"*",
"leftY",
";",
"double",
"upnY",
"=",
"dirnZ",
"*",
"leftX",
"-",
"dirnX",
"*",
"leftZ",
";",
"double",
"upnZ",
"=",
"dirnX",
"*",
"leftY",
"-",
"dirnY",
"*",
"leftX",
";",
"/* Convert orthonormal basis vectors to quaternion */",
"double",
"x",
",",
"y",
",",
"z",
",",
"w",
";",
"double",
"t",
";",
"double",
"tr",
"=",
"leftX",
"+",
"upnY",
"+",
"dirnZ",
";",
"if",
"(",
"tr",
">=",
"0.0",
")",
"{",
"t",
"=",
"Math",
".",
"sqrt",
"(",
"tr",
"+",
"1.0",
")",
";",
"w",
"=",
"t",
"*",
"0.5",
";",
"t",
"=",
"0.5",
"/",
"t",
";",
"x",
"=",
"(",
"dirnY",
"-",
"upnZ",
")",
"*",
"t",
";",
"y",
"=",
"(",
"leftZ",
"-",
"dirnX",
")",
"*",
"t",
";",
"z",
"=",
"(",
"upnX",
"-",
"leftY",
")",
"*",
"t",
";",
"}",
"else",
"{",
"if",
"(",
"leftX",
">",
"upnY",
"&&",
"leftX",
">",
"dirnZ",
")",
"{",
"t",
"=",
"Math",
".",
"sqrt",
"(",
"1.0",
"+",
"leftX",
"-",
"upnY",
"-",
"dirnZ",
")",
";",
"x",
"=",
"t",
"*",
"0.5",
";",
"t",
"=",
"0.5",
"/",
"t",
";",
"y",
"=",
"(",
"leftY",
"+",
"upnX",
")",
"*",
"t",
";",
"z",
"=",
"(",
"dirnX",
"+",
"leftZ",
")",
"*",
"t",
";",
"w",
"=",
"(",
"dirnY",
"-",
"upnZ",
")",
"*",
"t",
";",
"}",
"else",
"if",
"(",
"upnY",
">",
"dirnZ",
")",
"{",
"t",
"=",
"Math",
".",
"sqrt",
"(",
"1.0",
"+",
"upnY",
"-",
"leftX",
"-",
"dirnZ",
")",
";",
"y",
"=",
"t",
"*",
"0.5",
";",
"t",
"=",
"0.5",
"/",
"t",
";",
"x",
"=",
"(",
"leftY",
"+",
"upnX",
")",
"*",
"t",
";",
"z",
"=",
"(",
"upnZ",
"+",
"dirnY",
")",
"*",
"t",
";",
"w",
"=",
"(",
"leftZ",
"-",
"dirnX",
")",
"*",
"t",
";",
"}",
"else",
"{",
"t",
"=",
"Math",
".",
"sqrt",
"(",
"1.0",
"+",
"dirnZ",
"-",
"leftX",
"-",
"upnY",
")",
";",
"z",
"=",
"t",
"*",
"0.5",
";",
"t",
"=",
"0.5",
"/",
"t",
";",
"x",
"=",
"(",
"dirnX",
"+",
"leftZ",
")",
"*",
"t",
";",
"y",
"=",
"(",
"upnZ",
"+",
"dirnY",
")",
"*",
"t",
";",
"w",
"=",
"(",
"upnX",
"-",
"leftY",
")",
"*",
"t",
";",
"}",
"}",
"/* Multiply */",
"dest",
".",
"set",
"(",
"this",
".",
"w",
"*",
"x",
"+",
"this",
".",
"x",
"*",
"w",
"+",
"this",
".",
"y",
"*",
"z",
"-",
"this",
".",
"z",
"*",
"y",
",",
"this",
".",
"w",
"*",
"y",
"-",
"this",
".",
"x",
"*",
"z",
"+",
"this",
".",
"y",
"*",
"w",
"+",
"this",
".",
"z",
"*",
"x",
",",
"this",
".",
"w",
"*",
"z",
"+",
"this",
".",
"x",
"*",
"y",
"-",
"this",
".",
"y",
"*",
"x",
"+",
"this",
".",
"z",
"*",
"w",
",",
"this",
".",
"w",
"*",
"w",
"-",
"this",
".",
"x",
"*",
"x",
"-",
"this",
".",
"y",
"*",
"y",
"-",
"this",
".",
"z",
"*",
"z",
")",
";",
"return",
"dest",
";",
"}"
] | /* (non-Javadoc)
@see org.joml.Quaterniondc#lookAlong(double, double, double, double, double, double, org.joml.Quaterniond) | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Quaterniond.java#L1712-L1774 |
RestComm/media-core | ice/src/main/java/org/restcomm/media/core/ice/IceAgent.java | IceAgent.selectCandidatePair | private CandidatePair selectCandidatePair(IceComponent component, DatagramChannel channel) {
"""
Attempts to select a candidate pair on a ICE component.<br>
A candidate pair is only selected if the local candidate channel is
registered with the provided Selection Key.
@param component
The component that holds the gathered candidates.
@param key
The key of the datagram channel of the elected candidate.
@return Returns the selected candidate pair. If no pair was selected,
returns null.
"""
for (LocalCandidateWrapper localCandidate : component.getLocalCandidates()) {
if (channel.equals(localCandidate.getChannel())) {
return component.setCandidatePair(channel);
}
}
return null;
} | java | private CandidatePair selectCandidatePair(IceComponent component, DatagramChannel channel) {
for (LocalCandidateWrapper localCandidate : component.getLocalCandidates()) {
if (channel.equals(localCandidate.getChannel())) {
return component.setCandidatePair(channel);
}
}
return null;
} | [
"private",
"CandidatePair",
"selectCandidatePair",
"(",
"IceComponent",
"component",
",",
"DatagramChannel",
"channel",
")",
"{",
"for",
"(",
"LocalCandidateWrapper",
"localCandidate",
":",
"component",
".",
"getLocalCandidates",
"(",
")",
")",
"{",
"if",
"(",
"channel",
".",
"equals",
"(",
"localCandidate",
".",
"getChannel",
"(",
")",
")",
")",
"{",
"return",
"component",
".",
"setCandidatePair",
"(",
"channel",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Attempts to select a candidate pair on a ICE component.<br>
A candidate pair is only selected if the local candidate channel is
registered with the provided Selection Key.
@param component
The component that holds the gathered candidates.
@param key
The key of the datagram channel of the elected candidate.
@return Returns the selected candidate pair. If no pair was selected,
returns null. | [
"Attempts",
"to",
"select",
"a",
"candidate",
"pair",
"on",
"a",
"ICE",
"component",
".",
"<br",
">",
"A",
"candidate",
"pair",
"is",
"only",
"selected",
"if",
"the",
"local",
"candidate",
"channel",
"is",
"registered",
"with",
"the",
"provided",
"Selection",
"Key",
"."
] | train | https://github.com/RestComm/media-core/blob/07b8703343708599f60af66bae62aded77ee81b5/ice/src/main/java/org/restcomm/media/core/ice/IceAgent.java#L320-L327 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/MtoNBroker.java | MtoNBroker.storeMtoNImplementor | public void storeMtoNImplementor(CollectionDescriptor cod, Object realObject, Object otherObj, Collection mnKeys) {
"""
Stores new values of a M:N association in a indirection table.
@param cod The {@link org.apache.ojb.broker.metadata.CollectionDescriptor} for the m:n relation
@param realObject The real object
@param otherObj The referenced object
@param mnKeys The all {@link org.apache.ojb.broker.core.MtoNBroker.Key} matching the real object
"""
ClassDescriptor cld = pb.getDescriptorRepository().getDescriptorFor(realObject.getClass());
ValueContainer[] pkValues = pb.serviceBrokerHelper().getKeyValues(cld, realObject);
String[] pkColumns = cod.getFksToThisClass();
ClassDescriptor otherCld = pb.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(otherObj));
ValueContainer[] otherPkValues = pb.serviceBrokerHelper().getKeyValues(otherCld, otherObj);
String[] otherPkColumns = cod.getFksToItemClass();
String table = cod.getIndirectionTable();
MtoNBroker.Key key = new MtoNBroker.Key(otherPkValues);
if(mnKeys.contains(key))
{
return;
}
/*
fix for OJB-76, composite M & N keys that have some fields common
find the "shared" indirection table columns, values and remove these from m- or n- side
*/
for(int i = 0; i < otherPkColumns.length; i++)
{
int index = ArrayUtils.indexOf(pkColumns, otherPkColumns[i]);
if(index != -1)
{
// shared indirection table column found, remove this column from one side
pkColumns = (String[]) ArrayUtils.remove(pkColumns, index);
// remove duplicate value too
pkValues = (ValueContainer[]) ArrayUtils.remove(pkValues, index);
}
}
String[] cols = mergeColumns(pkColumns, otherPkColumns);
String insertStmt = pb.serviceSqlGenerator().getInsertMNStatement(table, pkColumns, otherPkColumns);
ValueContainer[] values = mergeContainer(pkValues, otherPkValues);
GenericObject gObj = new GenericObject(table, cols, values);
if(! tempObjects.contains(gObj))
{
pb.serviceJdbcAccess().executeUpdateSQL(insertStmt, cld, pkValues, otherPkValues);
tempObjects.add(gObj);
}
} | java | public void storeMtoNImplementor(CollectionDescriptor cod, Object realObject, Object otherObj, Collection mnKeys)
{
ClassDescriptor cld = pb.getDescriptorRepository().getDescriptorFor(realObject.getClass());
ValueContainer[] pkValues = pb.serviceBrokerHelper().getKeyValues(cld, realObject);
String[] pkColumns = cod.getFksToThisClass();
ClassDescriptor otherCld = pb.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(otherObj));
ValueContainer[] otherPkValues = pb.serviceBrokerHelper().getKeyValues(otherCld, otherObj);
String[] otherPkColumns = cod.getFksToItemClass();
String table = cod.getIndirectionTable();
MtoNBroker.Key key = new MtoNBroker.Key(otherPkValues);
if(mnKeys.contains(key))
{
return;
}
/*
fix for OJB-76, composite M & N keys that have some fields common
find the "shared" indirection table columns, values and remove these from m- or n- side
*/
for(int i = 0; i < otherPkColumns.length; i++)
{
int index = ArrayUtils.indexOf(pkColumns, otherPkColumns[i]);
if(index != -1)
{
// shared indirection table column found, remove this column from one side
pkColumns = (String[]) ArrayUtils.remove(pkColumns, index);
// remove duplicate value too
pkValues = (ValueContainer[]) ArrayUtils.remove(pkValues, index);
}
}
String[] cols = mergeColumns(pkColumns, otherPkColumns);
String insertStmt = pb.serviceSqlGenerator().getInsertMNStatement(table, pkColumns, otherPkColumns);
ValueContainer[] values = mergeContainer(pkValues, otherPkValues);
GenericObject gObj = new GenericObject(table, cols, values);
if(! tempObjects.contains(gObj))
{
pb.serviceJdbcAccess().executeUpdateSQL(insertStmt, cld, pkValues, otherPkValues);
tempObjects.add(gObj);
}
} | [
"public",
"void",
"storeMtoNImplementor",
"(",
"CollectionDescriptor",
"cod",
",",
"Object",
"realObject",
",",
"Object",
"otherObj",
",",
"Collection",
"mnKeys",
")",
"{",
"ClassDescriptor",
"cld",
"=",
"pb",
".",
"getDescriptorRepository",
"(",
")",
".",
"getDescriptorFor",
"(",
"realObject",
".",
"getClass",
"(",
")",
")",
";",
"ValueContainer",
"[",
"]",
"pkValues",
"=",
"pb",
".",
"serviceBrokerHelper",
"(",
")",
".",
"getKeyValues",
"(",
"cld",
",",
"realObject",
")",
";",
"String",
"[",
"]",
"pkColumns",
"=",
"cod",
".",
"getFksToThisClass",
"(",
")",
";",
"ClassDescriptor",
"otherCld",
"=",
"pb",
".",
"getDescriptorRepository",
"(",
")",
".",
"getDescriptorFor",
"(",
"ProxyHelper",
".",
"getRealClass",
"(",
"otherObj",
")",
")",
";",
"ValueContainer",
"[",
"]",
"otherPkValues",
"=",
"pb",
".",
"serviceBrokerHelper",
"(",
")",
".",
"getKeyValues",
"(",
"otherCld",
",",
"otherObj",
")",
";",
"String",
"[",
"]",
"otherPkColumns",
"=",
"cod",
".",
"getFksToItemClass",
"(",
")",
";",
"String",
"table",
"=",
"cod",
".",
"getIndirectionTable",
"(",
")",
";",
"MtoNBroker",
".",
"Key",
"key",
"=",
"new",
"MtoNBroker",
".",
"Key",
"(",
"otherPkValues",
")",
";",
"if",
"(",
"mnKeys",
".",
"contains",
"(",
"key",
")",
")",
"{",
"return",
";",
"}",
"/*\r\n fix for OJB-76, composite M & N keys that have some fields common\r\n find the \"shared\" indirection table columns, values and remove these from m- or n- side\r\n */",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"otherPkColumns",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"index",
"=",
"ArrayUtils",
".",
"indexOf",
"(",
"pkColumns",
",",
"otherPkColumns",
"[",
"i",
"]",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"// shared indirection table column found, remove this column from one side\r",
"pkColumns",
"=",
"(",
"String",
"[",
"]",
")",
"ArrayUtils",
".",
"remove",
"(",
"pkColumns",
",",
"index",
")",
";",
"// remove duplicate value too\r",
"pkValues",
"=",
"(",
"ValueContainer",
"[",
"]",
")",
"ArrayUtils",
".",
"remove",
"(",
"pkValues",
",",
"index",
")",
";",
"}",
"}",
"String",
"[",
"]",
"cols",
"=",
"mergeColumns",
"(",
"pkColumns",
",",
"otherPkColumns",
")",
";",
"String",
"insertStmt",
"=",
"pb",
".",
"serviceSqlGenerator",
"(",
")",
".",
"getInsertMNStatement",
"(",
"table",
",",
"pkColumns",
",",
"otherPkColumns",
")",
";",
"ValueContainer",
"[",
"]",
"values",
"=",
"mergeContainer",
"(",
"pkValues",
",",
"otherPkValues",
")",
";",
"GenericObject",
"gObj",
"=",
"new",
"GenericObject",
"(",
"table",
",",
"cols",
",",
"values",
")",
";",
"if",
"(",
"!",
"tempObjects",
".",
"contains",
"(",
"gObj",
")",
")",
"{",
"pb",
".",
"serviceJdbcAccess",
"(",
")",
".",
"executeUpdateSQL",
"(",
"insertStmt",
",",
"cld",
",",
"pkValues",
",",
"otherPkValues",
")",
";",
"tempObjects",
".",
"add",
"(",
"gObj",
")",
";",
"}",
"}"
] | Stores new values of a M:N association in a indirection table.
@param cod The {@link org.apache.ojb.broker.metadata.CollectionDescriptor} for the m:n relation
@param realObject The real object
@param otherObj The referenced object
@param mnKeys The all {@link org.apache.ojb.broker.core.MtoNBroker.Key} matching the real object | [
"Stores",
"new",
"values",
"of",
"a",
"M",
":",
"N",
"association",
"in",
"a",
"indirection",
"table",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/MtoNBroker.java#L83-L126 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/cache/ObjectCachePerClassImpl.java | ObjectCachePerClassImpl.getCachePerClass | private ObjectCache getCachePerClass(Class objectClass, int methodCall) {
"""
Gets the cache for the given class
@param objectClass The class to look up the cache for
@return The cache
"""
ObjectCache cache = (ObjectCache) cachesByClass.get(objectClass.getName());
if (cache == null && AbstractMetaCache.METHOD_CACHE == methodCall
&& !cachesByClass.containsKey(objectClass.getName()))
{
cache = new ObjectCacheDefaultImpl(null, null);
setClassCache(objectClass.getName(), cache);
}
return cache;
} | java | private ObjectCache getCachePerClass(Class objectClass, int methodCall)
{
ObjectCache cache = (ObjectCache) cachesByClass.get(objectClass.getName());
if (cache == null && AbstractMetaCache.METHOD_CACHE == methodCall
&& !cachesByClass.containsKey(objectClass.getName()))
{
cache = new ObjectCacheDefaultImpl(null, null);
setClassCache(objectClass.getName(), cache);
}
return cache;
} | [
"private",
"ObjectCache",
"getCachePerClass",
"(",
"Class",
"objectClass",
",",
"int",
"methodCall",
")",
"{",
"ObjectCache",
"cache",
"=",
"(",
"ObjectCache",
")",
"cachesByClass",
".",
"get",
"(",
"objectClass",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"cache",
"==",
"null",
"&&",
"AbstractMetaCache",
".",
"METHOD_CACHE",
"==",
"methodCall",
"&&",
"!",
"cachesByClass",
".",
"containsKey",
"(",
"objectClass",
".",
"getName",
"(",
")",
")",
")",
"{",
"cache",
"=",
"new",
"ObjectCacheDefaultImpl",
"(",
"null",
",",
"null",
")",
";",
"setClassCache",
"(",
"objectClass",
".",
"getName",
"(",
")",
",",
"cache",
")",
";",
"}",
"return",
"cache",
";",
"}"
] | Gets the cache for the given class
@param objectClass The class to look up the cache for
@return The cache | [
"Gets",
"the",
"cache",
"for",
"the",
"given",
"class"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/cache/ObjectCachePerClassImpl.java#L107-L117 |
jglobus/JGlobus | myproxy/src/main/java/org/globus/myproxy/MyProxy.java | MyProxy.get | public GSSCredential get(String username,
String passphrase,
int lifetime)
throws MyProxyException {
"""
Retrieves delegated credentials from MyProxy server Anonymously
(without local credentials)
Notes: Performs simple verification of private/public keys of
the delegated credential. Should be improved later.
And only checks for RSA keys.
@param username
The username of the credentials to retrieve.
@param passphrase
The passphrase of the credentials to retrieve.
@param lifetime
The requested lifetime of the retrieved credential (in seconds).
@return GSSCredential
The retrieved delegated credentials.
@exception MyProxyException
If an error occurred during the operation.
"""
return get(null, username, passphrase, lifetime);
} | java | public GSSCredential get(String username,
String passphrase,
int lifetime)
throws MyProxyException {
return get(null, username, passphrase, lifetime);
} | [
"public",
"GSSCredential",
"get",
"(",
"String",
"username",
",",
"String",
"passphrase",
",",
"int",
"lifetime",
")",
"throws",
"MyProxyException",
"{",
"return",
"get",
"(",
"null",
",",
"username",
",",
"passphrase",
",",
"lifetime",
")",
";",
"}"
] | Retrieves delegated credentials from MyProxy server Anonymously
(without local credentials)
Notes: Performs simple verification of private/public keys of
the delegated credential. Should be improved later.
And only checks for RSA keys.
@param username
The username of the credentials to retrieve.
@param passphrase
The passphrase of the credentials to retrieve.
@param lifetime
The requested lifetime of the retrieved credential (in seconds).
@return GSSCredential
The retrieved delegated credentials.
@exception MyProxyException
If an error occurred during the operation. | [
"Retrieves",
"delegated",
"credentials",
"from",
"MyProxy",
"server",
"Anonymously",
"(",
"without",
"local",
"credentials",
")"
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/myproxy/src/main/java/org/globus/myproxy/MyProxy.java#L897-L902 |
doanduyhai/Achilles | achilles-core/src/main/java/info/archinnov/achilles/internals/metamodel/AbstractProperty.java | AbstractProperty.encodeField | public VALUETO encodeField(ENTITY entity, Optional<CassandraOptions> cassandraOptions) {
"""
Encode the field of the given entity into CQL-compatible value using Achilles codec system and a CassandraOptions
containing a runtime SchemaNameProvider. Use the
<br/>
<br/>
<pre class="code"><code class="java">
CassandraOptions.withSchemaNameProvider(SchemaNameProvider provider)
</code></pre>
<br/>
static method to build such a CassandraOptions instance
@param entity
@return
"""
return encodeFromJava(getJavaValue(entity), cassandraOptions);
} | java | public VALUETO encodeField(ENTITY entity, Optional<CassandraOptions> cassandraOptions) {
return encodeFromJava(getJavaValue(entity), cassandraOptions);
} | [
"public",
"VALUETO",
"encodeField",
"(",
"ENTITY",
"entity",
",",
"Optional",
"<",
"CassandraOptions",
">",
"cassandraOptions",
")",
"{",
"return",
"encodeFromJava",
"(",
"getJavaValue",
"(",
"entity",
")",
",",
"cassandraOptions",
")",
";",
"}"
] | Encode the field of the given entity into CQL-compatible value using Achilles codec system and a CassandraOptions
containing a runtime SchemaNameProvider. Use the
<br/>
<br/>
<pre class="code"><code class="java">
CassandraOptions.withSchemaNameProvider(SchemaNameProvider provider)
</code></pre>
<br/>
static method to build such a CassandraOptions instance
@param entity
@return | [
"Encode",
"the",
"field",
"of",
"the",
"given",
"entity",
"into",
"CQL",
"-",
"compatible",
"value",
"using",
"Achilles",
"codec",
"system",
"and",
"a",
"CassandraOptions",
"containing",
"a",
"runtime",
"SchemaNameProvider",
".",
"Use",
"the",
"<br",
"/",
">",
"<br",
"/",
">",
"<pre",
"class",
"=",
"code",
">",
"<code",
"class",
"=",
"java",
">",
"CassandraOptions",
".",
"withSchemaNameProvider",
"(",
"SchemaNameProvider",
"provider",
")",
"<",
"/",
"code",
">",
"<",
"/",
"pre",
">",
"<br",
"/",
">",
"static",
"method",
"to",
"build",
"such",
"a",
"CassandraOptions",
"instance"
] | train | https://github.com/doanduyhai/Achilles/blob/8281c33100e72c993e570592ae1a5306afac6813/achilles-core/src/main/java/info/archinnov/achilles/internals/metamodel/AbstractProperty.java#L188-L190 |
alkacon/opencms-core | src/org/opencms/workplace/CmsWorkplace.java | CmsWorkplace.buttonBar | public String buttonBar(int segment, String attributes) {
"""
Returns the html for a button bar.<p>
@param segment the HTML segment (START / END)
@param attributes optional attributes for the table tag
@return a button bar html start / end segment
"""
if (segment == HTML_START) {
String result = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"";
if (attributes != null) {
result += " " + attributes;
}
return result + "><tr>\n";
} else {
return "</tr></table>";
}
} | java | public String buttonBar(int segment, String attributes) {
if (segment == HTML_START) {
String result = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"";
if (attributes != null) {
result += " " + attributes;
}
return result + "><tr>\n";
} else {
return "</tr></table>";
}
} | [
"public",
"String",
"buttonBar",
"(",
"int",
"segment",
",",
"String",
"attributes",
")",
"{",
"if",
"(",
"segment",
"==",
"HTML_START",
")",
"{",
"String",
"result",
"=",
"\"<table cellpadding=\\\"0\\\" cellspacing=\\\"0\\\" border=\\\"0\\\"\"",
";",
"if",
"(",
"attributes",
"!=",
"null",
")",
"{",
"result",
"+=",
"\" \"",
"+",
"attributes",
";",
"}",
"return",
"result",
"+",
"\"><tr>\\n\"",
";",
"}",
"else",
"{",
"return",
"\"</tr></table>\"",
";",
"}",
"}"
] | Returns the html for a button bar.<p>
@param segment the HTML segment (START / END)
@param attributes optional attributes for the table tag
@return a button bar html start / end segment | [
"Returns",
"the",
"html",
"for",
"a",
"button",
"bar",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/CmsWorkplace.java#L1279-L1290 |
osglworks/java-tool | src/main/java/org/osgl/util/IO.java | IO.writeContent | @Deprecated
public static void writeContent(CharSequence content, File file, String encoding) {
"""
Write string content to a file with encoding specified.
This is deprecated. Please use {@link #write(CharSequence, File, String)} instead
"""
write(content, file, encoding);
} | java | @Deprecated
public static void writeContent(CharSequence content, File file, String encoding) {
write(content, file, encoding);
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"writeContent",
"(",
"CharSequence",
"content",
",",
"File",
"file",
",",
"String",
"encoding",
")",
"{",
"write",
"(",
"content",
",",
"file",
",",
"encoding",
")",
";",
"}"
] | Write string content to a file with encoding specified.
This is deprecated. Please use {@link #write(CharSequence, File, String)} instead | [
"Write",
"string",
"content",
"to",
"a",
"file",
"with",
"encoding",
"specified",
"."
] | train | https://github.com/osglworks/java-tool/blob/8b6eee2bccb067eb32e6a7bc4a4dfef7a7d9008b/src/main/java/org/osgl/util/IO.java#L1702-L1705 |
samskivert/samskivert | src/main/java/com/samskivert/swing/util/RetryableTask.java | RetryableTask.invokeTask | public void invokeTask (Component parent, String retryMessage)
throws Exception {
"""
Invokes the supplied task and catches any thrown exceptions. In the
event of an exception, the provided message is displayed to the
user and the are allowed to retry the task or allow it to fail.
"""
while (true) {
try {
invoke();
return;
} catch (Exception e) {
Object[] options = new Object[] {
"Retry operation", "Abort operation" };
int rv = JOptionPane.showOptionDialog(
parent, retryMessage + "\n\n" + e.getMessage(),
"Operation failure", JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE, null, options, options[1]);
if (rv == 1) {
throw e;
}
}
}
} | java | public void invokeTask (Component parent, String retryMessage)
throws Exception
{
while (true) {
try {
invoke();
return;
} catch (Exception e) {
Object[] options = new Object[] {
"Retry operation", "Abort operation" };
int rv = JOptionPane.showOptionDialog(
parent, retryMessage + "\n\n" + e.getMessage(),
"Operation failure", JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE, null, options, options[1]);
if (rv == 1) {
throw e;
}
}
}
} | [
"public",
"void",
"invokeTask",
"(",
"Component",
"parent",
",",
"String",
"retryMessage",
")",
"throws",
"Exception",
"{",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"invoke",
"(",
")",
";",
"return",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Object",
"[",
"]",
"options",
"=",
"new",
"Object",
"[",
"]",
"{",
"\"Retry operation\"",
",",
"\"Abort operation\"",
"}",
";",
"int",
"rv",
"=",
"JOptionPane",
".",
"showOptionDialog",
"(",
"parent",
",",
"retryMessage",
"+",
"\"\\n\\n\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"\"Operation failure\"",
",",
"JOptionPane",
".",
"YES_NO_OPTION",
",",
"JOptionPane",
".",
"WARNING_MESSAGE",
",",
"null",
",",
"options",
",",
"options",
"[",
"1",
"]",
")",
";",
"if",
"(",
"rv",
"==",
"1",
")",
"{",
"throw",
"e",
";",
"}",
"}",
"}",
"}"
] | Invokes the supplied task and catches any thrown exceptions. In the
event of an exception, the provided message is displayed to the
user and the are allowed to retry the task or allow it to fail. | [
"Invokes",
"the",
"supplied",
"task",
"and",
"catches",
"any",
"thrown",
"exceptions",
".",
"In",
"the",
"event",
"of",
"an",
"exception",
"the",
"provided",
"message",
"is",
"displayed",
"to",
"the",
"user",
"and",
"the",
"are",
"allowed",
"to",
"retry",
"the",
"task",
"or",
"allow",
"it",
"to",
"fail",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/RetryableTask.java#L33-L53 |
phax/ph-commons | ph-xml/src/main/java/com/helger/xml/xpath/MapBasedXPathFunctionResolver.java | MapBasedXPathFunctionResolver.removeFunction | @Nonnull
public EChange removeFunction (@Nonnull final QName aName, @Nonnegative final int nArity) {
"""
Remove the function with the specified name.
@param aName
The name to be removed. May not be <code>null</code>.
@param nArity
The number of parameters of the function. Must be ≥ 0.
@return {@link EChange}
"""
final XPathFunctionKey aKey = new XPathFunctionKey (aName, nArity);
return removeFunction (aKey);
} | java | @Nonnull
public EChange removeFunction (@Nonnull final QName aName, @Nonnegative final int nArity)
{
final XPathFunctionKey aKey = new XPathFunctionKey (aName, nArity);
return removeFunction (aKey);
} | [
"@",
"Nonnull",
"public",
"EChange",
"removeFunction",
"(",
"@",
"Nonnull",
"final",
"QName",
"aName",
",",
"@",
"Nonnegative",
"final",
"int",
"nArity",
")",
"{",
"final",
"XPathFunctionKey",
"aKey",
"=",
"new",
"XPathFunctionKey",
"(",
"aName",
",",
"nArity",
")",
";",
"return",
"removeFunction",
"(",
"aKey",
")",
";",
"}"
] | Remove the function with the specified name.
@param aName
The name to be removed. May not be <code>null</code>.
@param nArity
The number of parameters of the function. Must be ≥ 0.
@return {@link EChange} | [
"Remove",
"the",
"function",
"with",
"the",
"specified",
"name",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/xpath/MapBasedXPathFunctionResolver.java#L152-L157 |
pravega/pravega | segmentstore/server/src/main/java/io/pravega/segmentstore/server/logs/ThrottlerCalculator.java | ThrottlerCalculator.getThrottlingDelay | DelayResult getThrottlingDelay() {
"""
Calculates the amount of time needed to delay based on the configured throttlers. The computed result is not additive,
as there is no benefit to adding delays from various Throttle Calculators together. For example, a cache throttling
delay will have increased batching as a side effect, so there's no need to include the batching one as well.
@return A DelayResult representing the computed delay. This delay is the maximum delay as calculated by the internal
throttlers.
"""
// These delays are not additive. There's no benefit to adding a batching delay on top of a throttling delay, since
// a throttling delay will have increased batching as a side effect.
int maxDelay = 0;
boolean maximum = false;
for (Throttler t : this.throttlers) {
int delay = t.getDelayMillis();
if (delay >= MAX_DELAY_MILLIS) {
// This throttler introduced the maximum delay. No need to search more.
maxDelay = MAX_DELAY_MILLIS;
maximum = true;
break;
}
maxDelay = Math.max(maxDelay, delay);
}
return new DelayResult(maxDelay, maximum);
} | java | DelayResult getThrottlingDelay() {
// These delays are not additive. There's no benefit to adding a batching delay on top of a throttling delay, since
// a throttling delay will have increased batching as a side effect.
int maxDelay = 0;
boolean maximum = false;
for (Throttler t : this.throttlers) {
int delay = t.getDelayMillis();
if (delay >= MAX_DELAY_MILLIS) {
// This throttler introduced the maximum delay. No need to search more.
maxDelay = MAX_DELAY_MILLIS;
maximum = true;
break;
}
maxDelay = Math.max(maxDelay, delay);
}
return new DelayResult(maxDelay, maximum);
} | [
"DelayResult",
"getThrottlingDelay",
"(",
")",
"{",
"// These delays are not additive. There's no benefit to adding a batching delay on top of a throttling delay, since",
"// a throttling delay will have increased batching as a side effect.",
"int",
"maxDelay",
"=",
"0",
";",
"boolean",
"maximum",
"=",
"false",
";",
"for",
"(",
"Throttler",
"t",
":",
"this",
".",
"throttlers",
")",
"{",
"int",
"delay",
"=",
"t",
".",
"getDelayMillis",
"(",
")",
";",
"if",
"(",
"delay",
">=",
"MAX_DELAY_MILLIS",
")",
"{",
"// This throttler introduced the maximum delay. No need to search more.",
"maxDelay",
"=",
"MAX_DELAY_MILLIS",
";",
"maximum",
"=",
"true",
";",
"break",
";",
"}",
"maxDelay",
"=",
"Math",
".",
"max",
"(",
"maxDelay",
",",
"delay",
")",
";",
"}",
"return",
"new",
"DelayResult",
"(",
"maxDelay",
",",
"maximum",
")",
";",
"}"
] | Calculates the amount of time needed to delay based on the configured throttlers. The computed result is not additive,
as there is no benefit to adding delays from various Throttle Calculators together. For example, a cache throttling
delay will have increased batching as a side effect, so there's no need to include the batching one as well.
@return A DelayResult representing the computed delay. This delay is the maximum delay as calculated by the internal
throttlers. | [
"Calculates",
"the",
"amount",
"of",
"time",
"needed",
"to",
"delay",
"based",
"on",
"the",
"configured",
"throttlers",
".",
"The",
"computed",
"result",
"is",
"not",
"additive",
"as",
"there",
"is",
"no",
"benefit",
"to",
"adding",
"delays",
"from",
"various",
"Throttle",
"Calculators",
"together",
".",
"For",
"example",
"a",
"cache",
"throttling",
"delay",
"will",
"have",
"increased",
"batching",
"as",
"a",
"side",
"effect",
"so",
"there",
"s",
"no",
"need",
"to",
"include",
"the",
"batching",
"one",
"as",
"well",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/logs/ThrottlerCalculator.java#L91-L109 |
infinispan/infinispan | jcache/embedded/src/main/java/org/infinispan/jcache/annotation/CacheLookupHelper.java | CacheLookupHelper.getCacheKeyGenerator | public static CacheKeyGenerator getCacheKeyGenerator(BeanManager beanManager, Class<? extends CacheKeyGenerator> methodCacheKeyGeneratorClass, CacheDefaults cacheDefaultsAnnotation) {
"""
Resolves and creates an instance of {@link javax.cache.annotation.CacheKeyGenerator}. To resolve the cache key generator class the
algorithm defined in JCACHE specification is used.
@param beanManager the bean manager instance.
@param methodCacheKeyGeneratorClass the {@link javax.cache.annotation.CacheKeyGenerator} class declared in the cache annotation.
@param cacheDefaultsAnnotation the {@link javax.cache.annotation.CacheDefaults} annotation instance.
@return the {@link javax.cache.annotation.CacheKeyGenerator} instance.
@throws NullPointerException if beanManager parameter is {@code null}.
"""
assertNotNull(beanManager, "beanManager parameter must not be null");
Class<? extends CacheKeyGenerator> cacheKeyGeneratorClass = DefaultCacheKeyGenerator.class;
if (!CacheKeyGenerator.class.equals(methodCacheKeyGeneratorClass)) {
cacheKeyGeneratorClass = methodCacheKeyGeneratorClass;
} else if (cacheDefaultsAnnotation != null && !CacheKeyGenerator.class.equals(cacheDefaultsAnnotation.cacheKeyGenerator())) {
cacheKeyGeneratorClass = cacheDefaultsAnnotation.cacheKeyGenerator();
}
final CreationalContext<?> creationalContext = beanManager.createCreationalContext(null);
final Set<Bean<?>> beans = beanManager.getBeans(cacheKeyGeneratorClass);
if (!beans.isEmpty()) {
final Bean<?> bean = beanManager.resolve(beans);
return (CacheKeyGenerator) beanManager.getReference(bean, CacheKeyGenerator.class, creationalContext);
}
// the CacheKeyGenerator implementation is not managed by CDI
try {
return cacheKeyGeneratorClass.newInstance();
} catch (InstantiationException e) {
throw log.unableToInstantiateCacheKeyGenerator(cacheKeyGeneratorClass, e);
} catch (IllegalAccessException e) {
throw log.unableToInstantiateCacheKeyGenerator(cacheKeyGeneratorClass, e);
}
} | java | public static CacheKeyGenerator getCacheKeyGenerator(BeanManager beanManager, Class<? extends CacheKeyGenerator> methodCacheKeyGeneratorClass, CacheDefaults cacheDefaultsAnnotation) {
assertNotNull(beanManager, "beanManager parameter must not be null");
Class<? extends CacheKeyGenerator> cacheKeyGeneratorClass = DefaultCacheKeyGenerator.class;
if (!CacheKeyGenerator.class.equals(methodCacheKeyGeneratorClass)) {
cacheKeyGeneratorClass = methodCacheKeyGeneratorClass;
} else if (cacheDefaultsAnnotation != null && !CacheKeyGenerator.class.equals(cacheDefaultsAnnotation.cacheKeyGenerator())) {
cacheKeyGeneratorClass = cacheDefaultsAnnotation.cacheKeyGenerator();
}
final CreationalContext<?> creationalContext = beanManager.createCreationalContext(null);
final Set<Bean<?>> beans = beanManager.getBeans(cacheKeyGeneratorClass);
if (!beans.isEmpty()) {
final Bean<?> bean = beanManager.resolve(beans);
return (CacheKeyGenerator) beanManager.getReference(bean, CacheKeyGenerator.class, creationalContext);
}
// the CacheKeyGenerator implementation is not managed by CDI
try {
return cacheKeyGeneratorClass.newInstance();
} catch (InstantiationException e) {
throw log.unableToInstantiateCacheKeyGenerator(cacheKeyGeneratorClass, e);
} catch (IllegalAccessException e) {
throw log.unableToInstantiateCacheKeyGenerator(cacheKeyGeneratorClass, e);
}
} | [
"public",
"static",
"CacheKeyGenerator",
"getCacheKeyGenerator",
"(",
"BeanManager",
"beanManager",
",",
"Class",
"<",
"?",
"extends",
"CacheKeyGenerator",
">",
"methodCacheKeyGeneratorClass",
",",
"CacheDefaults",
"cacheDefaultsAnnotation",
")",
"{",
"assertNotNull",
"(",
"beanManager",
",",
"\"beanManager parameter must not be null\"",
")",
";",
"Class",
"<",
"?",
"extends",
"CacheKeyGenerator",
">",
"cacheKeyGeneratorClass",
"=",
"DefaultCacheKeyGenerator",
".",
"class",
";",
"if",
"(",
"!",
"CacheKeyGenerator",
".",
"class",
".",
"equals",
"(",
"methodCacheKeyGeneratorClass",
")",
")",
"{",
"cacheKeyGeneratorClass",
"=",
"methodCacheKeyGeneratorClass",
";",
"}",
"else",
"if",
"(",
"cacheDefaultsAnnotation",
"!=",
"null",
"&&",
"!",
"CacheKeyGenerator",
".",
"class",
".",
"equals",
"(",
"cacheDefaultsAnnotation",
".",
"cacheKeyGenerator",
"(",
")",
")",
")",
"{",
"cacheKeyGeneratorClass",
"=",
"cacheDefaultsAnnotation",
".",
"cacheKeyGenerator",
"(",
")",
";",
"}",
"final",
"CreationalContext",
"<",
"?",
">",
"creationalContext",
"=",
"beanManager",
".",
"createCreationalContext",
"(",
"null",
")",
";",
"final",
"Set",
"<",
"Bean",
"<",
"?",
">",
">",
"beans",
"=",
"beanManager",
".",
"getBeans",
"(",
"cacheKeyGeneratorClass",
")",
";",
"if",
"(",
"!",
"beans",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"Bean",
"<",
"?",
">",
"bean",
"=",
"beanManager",
".",
"resolve",
"(",
"beans",
")",
";",
"return",
"(",
"CacheKeyGenerator",
")",
"beanManager",
".",
"getReference",
"(",
"bean",
",",
"CacheKeyGenerator",
".",
"class",
",",
"creationalContext",
")",
";",
"}",
"// the CacheKeyGenerator implementation is not managed by CDI",
"try",
"{",
"return",
"cacheKeyGeneratorClass",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"e",
")",
"{",
"throw",
"log",
".",
"unableToInstantiateCacheKeyGenerator",
"(",
"cacheKeyGeneratorClass",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"log",
".",
"unableToInstantiateCacheKeyGenerator",
"(",
"cacheKeyGeneratorClass",
",",
"e",
")",
";",
"}",
"}"
] | Resolves and creates an instance of {@link javax.cache.annotation.CacheKeyGenerator}. To resolve the cache key generator class the
algorithm defined in JCACHE specification is used.
@param beanManager the bean manager instance.
@param methodCacheKeyGeneratorClass the {@link javax.cache.annotation.CacheKeyGenerator} class declared in the cache annotation.
@param cacheDefaultsAnnotation the {@link javax.cache.annotation.CacheDefaults} annotation instance.
@return the {@link javax.cache.annotation.CacheKeyGenerator} instance.
@throws NullPointerException if beanManager parameter is {@code null}. | [
"Resolves",
"and",
"creates",
"an",
"instance",
"of",
"{",
"@link",
"javax",
".",
"cache",
".",
"annotation",
".",
"CacheKeyGenerator",
"}",
".",
"To",
"resolve",
"the",
"cache",
"key",
"generator",
"class",
"the",
"algorithm",
"defined",
"in",
"JCACHE",
"specification",
"is",
"used",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/jcache/embedded/src/main/java/org/infinispan/jcache/annotation/CacheLookupHelper.java#L69-L96 |
aws/aws-sdk-java | aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/EncryptedPutObjectRequest.java | EncryptedPutObjectRequest.setMaterialsDescription | public void setMaterialsDescription(Map<String, String> materialsDescription) {
"""
sets the materials description for the encryption materials to be used with the current PutObjectRequest.
@param materialsDescription the materialsDescription to set
"""
this.materialsDescription = materialsDescription == null
? null
: Collections.unmodifiableMap(new HashMap<String,String>(materialsDescription))
;
} | java | public void setMaterialsDescription(Map<String, String> materialsDescription) {
this.materialsDescription = materialsDescription == null
? null
: Collections.unmodifiableMap(new HashMap<String,String>(materialsDescription))
;
} | [
"public",
"void",
"setMaterialsDescription",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"materialsDescription",
")",
"{",
"this",
".",
"materialsDescription",
"=",
"materialsDescription",
"==",
"null",
"?",
"null",
":",
"Collections",
".",
"unmodifiableMap",
"(",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
"materialsDescription",
")",
")",
";",
"}"
] | sets the materials description for the encryption materials to be used with the current PutObjectRequest.
@param materialsDescription the materialsDescription to set | [
"sets",
"the",
"materials",
"description",
"for",
"the",
"encryption",
"materials",
"to",
"be",
"used",
"with",
"the",
"current",
"PutObjectRequest",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/EncryptedPutObjectRequest.java#L67-L72 |
ralscha/wampspring | src/main/java/ch/rasc/wampspring/EventMessenger.java | EventMessenger.sendTo | public void sendTo(String topicURI, Object event,
Set<String> eligibleWebSocketSessionIds) {
"""
Send an {@link EventMessage} to every client that is currently subscribed to the
given topicURI and is listed in the eligibleSessionIds set. If no session of the
provided set is subscribed to the topicURI nothing happens.
@param topicURI the name of the topic
@param event the payload of the {@link EventMessage}
@param eligibleWebSocketSessionIds only the WebSocket session ids listed here will
receive the EVENT message. If null or empty nobody receives the message.
"""
EventMessage eventMessage = new EventMessage(topicURI, event);
eventMessage.setEligibleWebSocketSessionIds(eligibleWebSocketSessionIds);
send(eventMessage);
} | java | public void sendTo(String topicURI, Object event,
Set<String> eligibleWebSocketSessionIds) {
EventMessage eventMessage = new EventMessage(topicURI, event);
eventMessage.setEligibleWebSocketSessionIds(eligibleWebSocketSessionIds);
send(eventMessage);
} | [
"public",
"void",
"sendTo",
"(",
"String",
"topicURI",
",",
"Object",
"event",
",",
"Set",
"<",
"String",
">",
"eligibleWebSocketSessionIds",
")",
"{",
"EventMessage",
"eventMessage",
"=",
"new",
"EventMessage",
"(",
"topicURI",
",",
"event",
")",
";",
"eventMessage",
".",
"setEligibleWebSocketSessionIds",
"(",
"eligibleWebSocketSessionIds",
")",
";",
"send",
"(",
"eventMessage",
")",
";",
"}"
] | Send an {@link EventMessage} to every client that is currently subscribed to the
given topicURI and is listed in the eligibleSessionIds set. If no session of the
provided set is subscribed to the topicURI nothing happens.
@param topicURI the name of the topic
@param event the payload of the {@link EventMessage}
@param eligibleWebSocketSessionIds only the WebSocket session ids listed here will
receive the EVENT message. If null or empty nobody receives the message. | [
"Send",
"an",
"{",
"@link",
"EventMessage",
"}",
"to",
"every",
"client",
"that",
"is",
"currently",
"subscribed",
"to",
"the",
"given",
"topicURI",
"and",
"is",
"listed",
"in",
"the",
"eligibleSessionIds",
"set",
".",
"If",
"no",
"session",
"of",
"the",
"provided",
"set",
"is",
"subscribed",
"to",
"the",
"topicURI",
"nothing",
"happens",
"."
] | train | https://github.com/ralscha/wampspring/blob/7571bb6773b848c580b29890587eb35397bfe5b5/src/main/java/ch/rasc/wampspring/EventMessenger.java#L116-L121 |
apache/groovy | subprojects/groovy-datetime/src/main/java/org/apache/groovy/datetime/extensions/DateTimeExtensions.java | DateTimeExtensions.isUptoEligible | private static boolean isUptoEligible(Temporal from, Temporal to) {
"""
Returns true if the {@code from} can be iterated up to {@code to}.
"""
TemporalAmount amount = rightShift(from, to);
if (amount instanceof Period) {
return isNonnegative((Period) amount);
} else if (amount instanceof Duration) {
return isNonnegative((Duration) amount);
} else {
throw new GroovyRuntimeException("Temporal implementations of "
+ from.getClass().getCanonicalName() + " are not supported by upto().");
}
} | java | private static boolean isUptoEligible(Temporal from, Temporal to) {
TemporalAmount amount = rightShift(from, to);
if (amount instanceof Period) {
return isNonnegative((Period) amount);
} else if (amount instanceof Duration) {
return isNonnegative((Duration) amount);
} else {
throw new GroovyRuntimeException("Temporal implementations of "
+ from.getClass().getCanonicalName() + " are not supported by upto().");
}
} | [
"private",
"static",
"boolean",
"isUptoEligible",
"(",
"Temporal",
"from",
",",
"Temporal",
"to",
")",
"{",
"TemporalAmount",
"amount",
"=",
"rightShift",
"(",
"from",
",",
"to",
")",
";",
"if",
"(",
"amount",
"instanceof",
"Period",
")",
"{",
"return",
"isNonnegative",
"(",
"(",
"Period",
")",
"amount",
")",
";",
"}",
"else",
"if",
"(",
"amount",
"instanceof",
"Duration",
")",
"{",
"return",
"isNonnegative",
"(",
"(",
"Duration",
")",
"amount",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"GroovyRuntimeException",
"(",
"\"Temporal implementations of \"",
"+",
"from",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
"+",
"\" are not supported by upto().\"",
")",
";",
"}",
"}"
] | Returns true if the {@code from} can be iterated up to {@code to}. | [
"Returns",
"true",
"if",
"the",
"{"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-datetime/src/main/java/org/apache/groovy/datetime/extensions/DateTimeExtensions.java#L169-L179 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscConfigurationsInner.java | DscConfigurationsInner.createOrUpdateAsync | public Observable<DscConfigurationInner> createOrUpdateAsync(String resourceGroupName, String automationAccountName, String configurationName, DscConfigurationCreateOrUpdateParameters parameters) {
"""
Create the configuration identified by configuration name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param configurationName The create or update parameters for configuration.
@param parameters The create or update parameters for configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DscConfigurationInner object
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName, parameters).map(new Func1<ServiceResponse<DscConfigurationInner>, DscConfigurationInner>() {
@Override
public DscConfigurationInner call(ServiceResponse<DscConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<DscConfigurationInner> createOrUpdateAsync(String resourceGroupName, String automationAccountName, String configurationName, DscConfigurationCreateOrUpdateParameters parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName, parameters).map(new Func1<ServiceResponse<DscConfigurationInner>, DscConfigurationInner>() {
@Override
public DscConfigurationInner call(ServiceResponse<DscConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DscConfigurationInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"configurationName",
",",
"DscConfigurationCreateOrUpdateParameters",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"configurationName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DscConfigurationInner",
">",
",",
"DscConfigurationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DscConfigurationInner",
"call",
"(",
"ServiceResponse",
"<",
"DscConfigurationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create the configuration identified by configuration name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param configurationName The create or update parameters for configuration.
@param parameters The create or update parameters for configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DscConfigurationInner object | [
"Create",
"the",
"configuration",
"identified",
"by",
"configuration",
"name",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscConfigurationsInner.java#L320-L327 |
Javacord/Javacord | javacord-api/src/main/java/org/javacord/api/entity/server/ServerUpdater.java | ServerUpdater.addRolesToUser | public ServerUpdater addRolesToUser(User user, Collection<Role> roles) {
"""
Queues a collection of roles to be assigned to the user.
@param user The server member the role should be added to.
@param roles The roles which should be added to the server member.
@return The current instance in order to chain call methods.
"""
delegate.addRolesToUser(user, roles);
return this;
} | java | public ServerUpdater addRolesToUser(User user, Collection<Role> roles) {
delegate.addRolesToUser(user, roles);
return this;
} | [
"public",
"ServerUpdater",
"addRolesToUser",
"(",
"User",
"user",
",",
"Collection",
"<",
"Role",
">",
"roles",
")",
"{",
"delegate",
".",
"addRolesToUser",
"(",
"user",
",",
"roles",
")",
";",
"return",
"this",
";",
"}"
] | Queues a collection of roles to be assigned to the user.
@param user The server member the role should be added to.
@param roles The roles which should be added to the server member.
@return The current instance in order to chain call methods. | [
"Queues",
"a",
"collection",
"of",
"roles",
"to",
"be",
"assigned",
"to",
"the",
"user",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-api/src/main/java/org/javacord/api/entity/server/ServerUpdater.java#L479-L482 |
pryzach/midao | midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java | TypeHandlerUtils.convertBlob | public static Object convertBlob(Connection conn, InputStream input) throws SQLException {
"""
Transfers data from InputStream into sql.Blob
@param conn connection for which sql.Blob object would be created
@param input InputStream
@return sql.Blob from InputStream
@throws SQLException
"""
return convertBlob(conn, toByteArray(input));
} | java | public static Object convertBlob(Connection conn, InputStream input) throws SQLException {
return convertBlob(conn, toByteArray(input));
} | [
"public",
"static",
"Object",
"convertBlob",
"(",
"Connection",
"conn",
",",
"InputStream",
"input",
")",
"throws",
"SQLException",
"{",
"return",
"convertBlob",
"(",
"conn",
",",
"toByteArray",
"(",
"input",
")",
")",
";",
"}"
] | Transfers data from InputStream into sql.Blob
@param conn connection for which sql.Blob object would be created
@param input InputStream
@return sql.Blob from InputStream
@throws SQLException | [
"Transfers",
"data",
"from",
"InputStream",
"into",
"sql",
".",
"Blob"
] | train | https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java#L95-L97 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/typeconvert/TypeConverter.java | TypeConverter.convertToBoolean | public static boolean convertToBoolean (@Nonnull final Object aSrcValue) {
"""
Convert the passed source value to boolean
@param aSrcValue
The source value. May not be <code>null</code>.
@return The converted value.
@throws TypeConverterException
if the source value is <code>null</code> or if no converter was
found or if the converter returned a <code>null</code> object.
@throws RuntimeException
If the converter itself throws an exception
@see TypeConverterProviderBestMatch
"""
if (aSrcValue == null)
throw new TypeConverterException (boolean.class, EReason.NULL_SOURCE_NOT_ALLOWED);
final Boolean aValue = convert (aSrcValue, Boolean.class);
return aValue.booleanValue ();
} | java | public static boolean convertToBoolean (@Nonnull final Object aSrcValue)
{
if (aSrcValue == null)
throw new TypeConverterException (boolean.class, EReason.NULL_SOURCE_NOT_ALLOWED);
final Boolean aValue = convert (aSrcValue, Boolean.class);
return aValue.booleanValue ();
} | [
"public",
"static",
"boolean",
"convertToBoolean",
"(",
"@",
"Nonnull",
"final",
"Object",
"aSrcValue",
")",
"{",
"if",
"(",
"aSrcValue",
"==",
"null",
")",
"throw",
"new",
"TypeConverterException",
"(",
"boolean",
".",
"class",
",",
"EReason",
".",
"NULL_SOURCE_NOT_ALLOWED",
")",
";",
"final",
"Boolean",
"aValue",
"=",
"convert",
"(",
"aSrcValue",
",",
"Boolean",
".",
"class",
")",
";",
"return",
"aValue",
".",
"booleanValue",
"(",
")",
";",
"}"
] | Convert the passed source value to boolean
@param aSrcValue
The source value. May not be <code>null</code>.
@return The converted value.
@throws TypeConverterException
if the source value is <code>null</code> or if no converter was
found or if the converter returned a <code>null</code> object.
@throws RuntimeException
If the converter itself throws an exception
@see TypeConverterProviderBestMatch | [
"Convert",
"the",
"passed",
"source",
"value",
"to",
"boolean"
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/typeconvert/TypeConverter.java#L114-L120 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/util/ByteConverter.java | ByteConverter.int4 | public static int int4(byte[] bytes, int idx) {
"""
Parses an int value from the byte array.
@param bytes The byte array to parse.
@param idx The starting index of the parse in the byte array.
@return parsed int value.
"""
return
((bytes[idx] & 255) << 24)
+ ((bytes[idx + 1] & 255) << 16)
+ ((bytes[idx + 2] & 255) << 8)
+ ((bytes[idx + 3] & 255));
} | java | public static int int4(byte[] bytes, int idx) {
return
((bytes[idx] & 255) << 24)
+ ((bytes[idx + 1] & 255) << 16)
+ ((bytes[idx + 2] & 255) << 8)
+ ((bytes[idx + 3] & 255));
} | [
"public",
"static",
"int",
"int4",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"idx",
")",
"{",
"return",
"(",
"(",
"bytes",
"[",
"idx",
"]",
"&",
"255",
")",
"<<",
"24",
")",
"+",
"(",
"(",
"bytes",
"[",
"idx",
"+",
"1",
"]",
"&",
"255",
")",
"<<",
"16",
")",
"+",
"(",
"(",
"bytes",
"[",
"idx",
"+",
"2",
"]",
"&",
"255",
")",
"<<",
"8",
")",
"+",
"(",
"(",
"bytes",
"[",
"idx",
"+",
"3",
"]",
"&",
"255",
")",
")",
";",
"}"
] | Parses an int value from the byte array.
@param bytes The byte array to parse.
@param idx The starting index of the parse in the byte array.
@return parsed int value. | [
"Parses",
"an",
"int",
"value",
"from",
"the",
"byte",
"array",
"."
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/util/ByteConverter.java#L45-L51 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/util/ShapeGenerator.java | ShapeGenerator.createScrollButtonTogetherIncrease | public Shape createScrollButtonTogetherIncrease(int x, int y, int w, int h) {
"""
Return a path for a scroll bar increase button. This is used when the
buttons are placed together at one end of the scroll bar.
@param x the X coordinate of the upper-left corner of the button
@param y the Y coordinate of the upper-left corner of the button
@param w the width of the button
@param h the height of the button
@return a path representing the shape.
"""
return createRectangle(x, y, w, h);
} | java | public Shape createScrollButtonTogetherIncrease(int x, int y, int w, int h) {
return createRectangle(x, y, w, h);
} | [
"public",
"Shape",
"createScrollButtonTogetherIncrease",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"w",
",",
"int",
"h",
")",
"{",
"return",
"createRectangle",
"(",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
";",
"}"
] | Return a path for a scroll bar increase button. This is used when the
buttons are placed together at one end of the scroll bar.
@param x the X coordinate of the upper-left corner of the button
@param y the Y coordinate of the upper-left corner of the button
@param w the width of the button
@param h the height of the button
@return a path representing the shape. | [
"Return",
"a",
"path",
"for",
"a",
"scroll",
"bar",
"increase",
"button",
".",
"This",
"is",
"used",
"when",
"the",
"buttons",
"are",
"placed",
"together",
"at",
"one",
"end",
"of",
"the",
"scroll",
"bar",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/util/ShapeGenerator.java#L712-L714 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java | DeletingWhileIterating.breakFollows | private boolean breakFollows(Loop loop, boolean needsPop) {
"""
looks to see if the following instruction is a GOTO, preceded by potentially a pop
@param loop
the loop structure we are checking
@param needsPop
whether we expect to see a pop next
@return whether a GOTO is found
"""
byte[] code = getCode().getCode();
int nextPC = getNextPC();
if (needsPop) {
int popOp = CodeByteUtils.getbyte(code, nextPC++);
if (popOp != Const.POP) {
return false;
}
}
int gotoOp = CodeByteUtils.getbyte(code, nextPC);
if ((gotoOp == Const.GOTO) || (gotoOp == Const.GOTO_W)) {
int target = nextPC + CodeByteUtils.getshort(code, nextPC + 1);
if (target > loop.getLoopFinish()) {
return true;
}
}
return false;
} | java | private boolean breakFollows(Loop loop, boolean needsPop) {
byte[] code = getCode().getCode();
int nextPC = getNextPC();
if (needsPop) {
int popOp = CodeByteUtils.getbyte(code, nextPC++);
if (popOp != Const.POP) {
return false;
}
}
int gotoOp = CodeByteUtils.getbyte(code, nextPC);
if ((gotoOp == Const.GOTO) || (gotoOp == Const.GOTO_W)) {
int target = nextPC + CodeByteUtils.getshort(code, nextPC + 1);
if (target > loop.getLoopFinish()) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"breakFollows",
"(",
"Loop",
"loop",
",",
"boolean",
"needsPop",
")",
"{",
"byte",
"[",
"]",
"code",
"=",
"getCode",
"(",
")",
".",
"getCode",
"(",
")",
";",
"int",
"nextPC",
"=",
"getNextPC",
"(",
")",
";",
"if",
"(",
"needsPop",
")",
"{",
"int",
"popOp",
"=",
"CodeByteUtils",
".",
"getbyte",
"(",
"code",
",",
"nextPC",
"++",
")",
";",
"if",
"(",
"popOp",
"!=",
"Const",
".",
"POP",
")",
"{",
"return",
"false",
";",
"}",
"}",
"int",
"gotoOp",
"=",
"CodeByteUtils",
".",
"getbyte",
"(",
"code",
",",
"nextPC",
")",
";",
"if",
"(",
"(",
"gotoOp",
"==",
"Const",
".",
"GOTO",
")",
"||",
"(",
"gotoOp",
"==",
"Const",
".",
"GOTO_W",
")",
")",
"{",
"int",
"target",
"=",
"nextPC",
"+",
"CodeByteUtils",
".",
"getshort",
"(",
"code",
",",
"nextPC",
"+",
"1",
")",
";",
"if",
"(",
"target",
">",
"loop",
".",
"getLoopFinish",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | looks to see if the following instruction is a GOTO, preceded by potentially a pop
@param loop
the loop structure we are checking
@param needsPop
whether we expect to see a pop next
@return whether a GOTO is found | [
"looks",
"to",
"see",
"if",
"the",
"following",
"instruction",
"is",
"a",
"GOTO",
"preceded",
"by",
"potentially",
"a",
"pop"
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java#L346-L367 |
Crab2died/Excel4J | src/main/java/com/github/crab2died/ExcelUtils.java | ExcelUtils.exportObjects2Excel | public void exportObjects2Excel(String templatePath, List<?> data, Class clazz, OutputStream os)
throws Excel4JException {
"""
基于Excel模板与注解{@link com.github.crab2died.annotation.ExcelField}导出Excel
@param templatePath Excel模板路径
@param data 待导出数据的集合
@param clazz 映射对象Class
@param os 生成的Excel待输出数据流
@throws Excel4JException 异常
@author Crab2Died
"""
exportObjects2Excel(templatePath, 0, data, null, clazz, true, os);
} | java | public void exportObjects2Excel(String templatePath, List<?> data, Class clazz, OutputStream os)
throws Excel4JException {
exportObjects2Excel(templatePath, 0, data, null, clazz, true, os);
} | [
"public",
"void",
"exportObjects2Excel",
"(",
"String",
"templatePath",
",",
"List",
"<",
"?",
">",
"data",
",",
"Class",
"clazz",
",",
"OutputStream",
"os",
")",
"throws",
"Excel4JException",
"{",
"exportObjects2Excel",
"(",
"templatePath",
",",
"0",
",",
"data",
",",
"null",
",",
"clazz",
",",
"true",
",",
"os",
")",
";",
"}"
] | 基于Excel模板与注解{@link com.github.crab2died.annotation.ExcelField}导出Excel
@param templatePath Excel模板路径
@param data 待导出数据的集合
@param clazz 映射对象Class
@param os 生成的Excel待输出数据流
@throws Excel4JException 异常
@author Crab2Died | [
"基于Excel模板与注解",
"{",
"@link",
"com",
".",
"github",
".",
"crab2died",
".",
"annotation",
".",
"ExcelField",
"}",
"导出Excel"
] | train | https://github.com/Crab2died/Excel4J/blob/2ab0a3b8226a69ff868c3ead6e724f3a774f5f77/src/main/java/com/github/crab2died/ExcelUtils.java#L606-L610 |
roboconf/roboconf-platform | core/roboconf-dm/src/main/java/net/roboconf/dm/internal/utils/ConfigurationUtils.java | ConfigurationUtils.loadApplicationBindings | public static void loadApplicationBindings( Application app ) {
"""
Loads the application bindings into an application.
@param app a non-null application
@param configurationDirectory the DM's configuration directory
"""
File descDir = new File( app.getDirectory(), Constants.PROJECT_DIR_DESC );
File appBindingsFile = new File( descDir, APP_BINDINGS_FILE );
Logger logger = Logger.getLogger( ConfigurationUtils.class.getName());
Properties props = Utils.readPropertiesFileQuietly( appBindingsFile, logger );
for( Map.Entry<?,?> entry : props.entrySet()) {
for( String part : Utils.splitNicely((String) entry.getValue(), "," )) {
if( ! Utils.isEmptyOrWhitespaces( part ))
app.bindWithApplication((String) entry.getKey(), part );
}
}
} | java | public static void loadApplicationBindings( Application app ) {
File descDir = new File( app.getDirectory(), Constants.PROJECT_DIR_DESC );
File appBindingsFile = new File( descDir, APP_BINDINGS_FILE );
Logger logger = Logger.getLogger( ConfigurationUtils.class.getName());
Properties props = Utils.readPropertiesFileQuietly( appBindingsFile, logger );
for( Map.Entry<?,?> entry : props.entrySet()) {
for( String part : Utils.splitNicely((String) entry.getValue(), "," )) {
if( ! Utils.isEmptyOrWhitespaces( part ))
app.bindWithApplication((String) entry.getKey(), part );
}
}
} | [
"public",
"static",
"void",
"loadApplicationBindings",
"(",
"Application",
"app",
")",
"{",
"File",
"descDir",
"=",
"new",
"File",
"(",
"app",
".",
"getDirectory",
"(",
")",
",",
"Constants",
".",
"PROJECT_DIR_DESC",
")",
";",
"File",
"appBindingsFile",
"=",
"new",
"File",
"(",
"descDir",
",",
"APP_BINDINGS_FILE",
")",
";",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"ConfigurationUtils",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"Properties",
"props",
"=",
"Utils",
".",
"readPropertiesFileQuietly",
"(",
"appBindingsFile",
",",
"logger",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"?",
",",
"?",
">",
"entry",
":",
"props",
".",
"entrySet",
"(",
")",
")",
"{",
"for",
"(",
"String",
"part",
":",
"Utils",
".",
"splitNicely",
"(",
"(",
"String",
")",
"entry",
".",
"getValue",
"(",
")",
",",
"\",\"",
")",
")",
"{",
"if",
"(",
"!",
"Utils",
".",
"isEmptyOrWhitespaces",
"(",
"part",
")",
")",
"app",
".",
"bindWithApplication",
"(",
"(",
"String",
")",
"entry",
".",
"getKey",
"(",
")",
",",
"part",
")",
";",
"}",
"}",
"}"
] | Loads the application bindings into an application.
@param app a non-null application
@param configurationDirectory the DM's configuration directory | [
"Loads",
"the",
"application",
"bindings",
"into",
"an",
"application",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm/src/main/java/net/roboconf/dm/internal/utils/ConfigurationUtils.java#L181-L194 |
alkacon/opencms-core | src/org/opencms/workplace/CmsWorkplace.java | CmsWorkplace.getWorkplaceExplorerLink | public static String getWorkplaceExplorerLink(final CmsObject cms, final String explorerRootPath) {
"""
Creates a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the
site of the given explorerRootPath and show the folder given in the explorerRootPath.
<p>
@param cms
the cms object
@param explorerRootPath
a root relative folder link (has to end with '/').
@return a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the
site of the given explorerRootPath and show the folder given in the explorerRootPath.
"""
// split the root site:
String targetSiteRoot = OpenCms.getSiteManager().getSiteRoot(explorerRootPath);
if (targetSiteRoot == null) {
if (OpenCms.getSiteManager().startsWithShared(explorerRootPath)) {
targetSiteRoot = OpenCms.getSiteManager().getSharedFolder();
} else {
targetSiteRoot = "";
}
}
String targetVfsFolder;
if (explorerRootPath.startsWith(targetSiteRoot)) {
targetVfsFolder = explorerRootPath.substring(targetSiteRoot.length());
targetVfsFolder = CmsStringUtil.joinPaths("/", targetVfsFolder);
} else {
targetVfsFolder = "/";
// happens in case of the shared site
}
StringBuilder link2Source = new StringBuilder();
link2Source.append(JSP_WORKPLACE_URI);
link2Source.append("?");
link2Source.append(CmsWorkplace.PARAM_WP_EXPLORER_RESOURCE);
link2Source.append("=");
link2Source.append(targetVfsFolder);
link2Source.append("&");
link2Source.append(PARAM_WP_VIEW);
link2Source.append("=");
link2Source.append(
OpenCms.getLinkManager().substituteLinkForUnknownTarget(
cms,
"/system/workplace/views/explorer/explorer_fs.jsp"));
link2Source.append("&");
link2Source.append(PARAM_WP_SITE);
link2Source.append("=");
link2Source.append(targetSiteRoot);
String result = link2Source.toString();
result = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, result);
return result;
} | java | public static String getWorkplaceExplorerLink(final CmsObject cms, final String explorerRootPath) {
// split the root site:
String targetSiteRoot = OpenCms.getSiteManager().getSiteRoot(explorerRootPath);
if (targetSiteRoot == null) {
if (OpenCms.getSiteManager().startsWithShared(explorerRootPath)) {
targetSiteRoot = OpenCms.getSiteManager().getSharedFolder();
} else {
targetSiteRoot = "";
}
}
String targetVfsFolder;
if (explorerRootPath.startsWith(targetSiteRoot)) {
targetVfsFolder = explorerRootPath.substring(targetSiteRoot.length());
targetVfsFolder = CmsStringUtil.joinPaths("/", targetVfsFolder);
} else {
targetVfsFolder = "/";
// happens in case of the shared site
}
StringBuilder link2Source = new StringBuilder();
link2Source.append(JSP_WORKPLACE_URI);
link2Source.append("?");
link2Source.append(CmsWorkplace.PARAM_WP_EXPLORER_RESOURCE);
link2Source.append("=");
link2Source.append(targetVfsFolder);
link2Source.append("&");
link2Source.append(PARAM_WP_VIEW);
link2Source.append("=");
link2Source.append(
OpenCms.getLinkManager().substituteLinkForUnknownTarget(
cms,
"/system/workplace/views/explorer/explorer_fs.jsp"));
link2Source.append("&");
link2Source.append(PARAM_WP_SITE);
link2Source.append("=");
link2Source.append(targetSiteRoot);
String result = link2Source.toString();
result = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, result);
return result;
} | [
"public",
"static",
"String",
"getWorkplaceExplorerLink",
"(",
"final",
"CmsObject",
"cms",
",",
"final",
"String",
"explorerRootPath",
")",
"{",
"// split the root site:",
"String",
"targetSiteRoot",
"=",
"OpenCms",
".",
"getSiteManager",
"(",
")",
".",
"getSiteRoot",
"(",
"explorerRootPath",
")",
";",
"if",
"(",
"targetSiteRoot",
"==",
"null",
")",
"{",
"if",
"(",
"OpenCms",
".",
"getSiteManager",
"(",
")",
".",
"startsWithShared",
"(",
"explorerRootPath",
")",
")",
"{",
"targetSiteRoot",
"=",
"OpenCms",
".",
"getSiteManager",
"(",
")",
".",
"getSharedFolder",
"(",
")",
";",
"}",
"else",
"{",
"targetSiteRoot",
"=",
"\"\"",
";",
"}",
"}",
"String",
"targetVfsFolder",
";",
"if",
"(",
"explorerRootPath",
".",
"startsWith",
"(",
"targetSiteRoot",
")",
")",
"{",
"targetVfsFolder",
"=",
"explorerRootPath",
".",
"substring",
"(",
"targetSiteRoot",
".",
"length",
"(",
")",
")",
";",
"targetVfsFolder",
"=",
"CmsStringUtil",
".",
"joinPaths",
"(",
"\"/\"",
",",
"targetVfsFolder",
")",
";",
"}",
"else",
"{",
"targetVfsFolder",
"=",
"\"/\"",
";",
"// happens in case of the shared site",
"}",
"StringBuilder",
"link2Source",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"link2Source",
".",
"append",
"(",
"JSP_WORKPLACE_URI",
")",
";",
"link2Source",
".",
"append",
"(",
"\"?\"",
")",
";",
"link2Source",
".",
"append",
"(",
"CmsWorkplace",
".",
"PARAM_WP_EXPLORER_RESOURCE",
")",
";",
"link2Source",
".",
"append",
"(",
"\"=\"",
")",
";",
"link2Source",
".",
"append",
"(",
"targetVfsFolder",
")",
";",
"link2Source",
".",
"append",
"(",
"\"&\"",
")",
";",
"link2Source",
".",
"append",
"(",
"PARAM_WP_VIEW",
")",
";",
"link2Source",
".",
"append",
"(",
"\"=\"",
")",
";",
"link2Source",
".",
"append",
"(",
"OpenCms",
".",
"getLinkManager",
"(",
")",
".",
"substituteLinkForUnknownTarget",
"(",
"cms",
",",
"\"/system/workplace/views/explorer/explorer_fs.jsp\"",
")",
")",
";",
"link2Source",
".",
"append",
"(",
"\"&\"",
")",
";",
"link2Source",
".",
"append",
"(",
"PARAM_WP_SITE",
")",
";",
"link2Source",
".",
"append",
"(",
"\"=\"",
")",
";",
"link2Source",
".",
"append",
"(",
"targetSiteRoot",
")",
";",
"String",
"result",
"=",
"link2Source",
".",
"toString",
"(",
")",
";",
"result",
"=",
"OpenCms",
".",
"getLinkManager",
"(",
")",
".",
"substituteLinkForUnknownTarget",
"(",
"cms",
",",
"result",
")",
";",
"return",
"result",
";",
"}"
] | Creates a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the
site of the given explorerRootPath and show the folder given in the explorerRootPath.
<p>
@param cms
the cms object
@param explorerRootPath
a root relative folder link (has to end with '/').
@return a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the
site of the given explorerRootPath and show the folder given in the explorerRootPath. | [
"Creates",
"a",
"link",
"for",
"the",
"OpenCms",
"workplace",
"that",
"will",
"reload",
"the",
"whole",
"workplace",
"switch",
"to",
"the",
"explorer",
"view",
"the",
"site",
"of",
"the",
"given",
"explorerRootPath",
"and",
"show",
"the",
"folder",
"given",
"in",
"the",
"explorerRootPath",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/CmsWorkplace.java#L773-L814 |
hibernate/hibernate-ogm | neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java | EmbeddedNeo4jEntityQueries.createEmbedded | public Node createEmbedded(GraphDatabaseService executionEngine, Object[] columnValues) {
"""
Create a single node representing an embedded element.
@param executionEngine the {@link GraphDatabaseService} used to run the query
@param columnValues the values in {@link org.hibernate.ogm.model.key.spi.EntityKey#getColumnValues()}
@return the corresponding node;
"""
Map<String, Object> params = params( columnValues );
Result result = executionEngine.execute( getCreateEmbeddedNodeQuery(), params );
return singleResult( result );
} | java | public Node createEmbedded(GraphDatabaseService executionEngine, Object[] columnValues) {
Map<String, Object> params = params( columnValues );
Result result = executionEngine.execute( getCreateEmbeddedNodeQuery(), params );
return singleResult( result );
} | [
"public",
"Node",
"createEmbedded",
"(",
"GraphDatabaseService",
"executionEngine",
",",
"Object",
"[",
"]",
"columnValues",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
"=",
"params",
"(",
"columnValues",
")",
";",
"Result",
"result",
"=",
"executionEngine",
".",
"execute",
"(",
"getCreateEmbeddedNodeQuery",
"(",
")",
",",
"params",
")",
";",
"return",
"singleResult",
"(",
"result",
")",
";",
"}"
] | Create a single node representing an embedded element.
@param executionEngine the {@link GraphDatabaseService} used to run the query
@param columnValues the values in {@link org.hibernate.ogm.model.key.spi.EntityKey#getColumnValues()}
@return the corresponding node; | [
"Create",
"a",
"single",
"node",
"representing",
"an",
"embedded",
"element",
"."
] | train | https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java#L66-L70 |
BioPAX/Paxtools | normalizer/src/main/java/org/biopax/paxtools/normalizer/MiriamLink.java | MiriamLink.getURI | public static String getURI(String name, String id) {
"""
Retrieves the unique MIRIAM URI of a specific entity (example: "urn:miriam:obo.go:GO%3A0045202").
@param name - name, URI/URL, or ID of a data type (examples: "ChEBI", "MIR:00000005")
@param id identifier of an entity within the data type (examples: "GO:0045202", "P62158")
@return unique standard MIRIAM URI of a given entity
@throws IllegalArgumentException when datatype not found
"""
Datatype datatype = getDatatype(name);
String db = datatype.getName();
if(checkRegExp(id, db)) {
try {
return getOfficialDataTypeURI(datatype) + ":" + URLEncoder.encode(id, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("UTF-8 encoding error of id=" + id, e);
}
} else
throw new IllegalArgumentException(
"ID pattern mismatch. db=" + db + ", id=" + id
+ ", regexp: " + datatype.getPattern());
} | java | public static String getURI(String name, String id)
{
Datatype datatype = getDatatype(name);
String db = datatype.getName();
if(checkRegExp(id, db)) {
try {
return getOfficialDataTypeURI(datatype) + ":" + URLEncoder.encode(id, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("UTF-8 encoding error of id=" + id, e);
}
} else
throw new IllegalArgumentException(
"ID pattern mismatch. db=" + db + ", id=" + id
+ ", regexp: " + datatype.getPattern());
} | [
"public",
"static",
"String",
"getURI",
"(",
"String",
"name",
",",
"String",
"id",
")",
"{",
"Datatype",
"datatype",
"=",
"getDatatype",
"(",
"name",
")",
";",
"String",
"db",
"=",
"datatype",
".",
"getName",
"(",
")",
";",
"if",
"(",
"checkRegExp",
"(",
"id",
",",
"db",
")",
")",
"{",
"try",
"{",
"return",
"getOfficialDataTypeURI",
"(",
"datatype",
")",
"+",
"\":\"",
"+",
"URLEncoder",
".",
"encode",
"(",
"id",
",",
"\"UTF-8\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"UTF-8 encoding error of id=\"",
"+",
"id",
",",
"e",
")",
";",
"}",
"}",
"else",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"ID pattern mismatch. db=\"",
"+",
"db",
"+",
"\", id=\"",
"+",
"id",
"+",
"\", regexp: \"",
"+",
"datatype",
".",
"getPattern",
"(",
")",
")",
";",
"}"
] | Retrieves the unique MIRIAM URI of a specific entity (example: "urn:miriam:obo.go:GO%3A0045202").
@param name - name, URI/URL, or ID of a data type (examples: "ChEBI", "MIR:00000005")
@param id identifier of an entity within the data type (examples: "GO:0045202", "P62158")
@return unique standard MIRIAM URI of a given entity
@throws IllegalArgumentException when datatype not found | [
"Retrieves",
"the",
"unique",
"MIRIAM",
"URI",
"of",
"a",
"specific",
"entity",
"(",
"example",
":",
"urn",
":",
"miriam",
":",
"obo",
".",
"go",
":",
"GO%3A0045202",
")",
"."
] | train | https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/normalizer/src/main/java/org/biopax/paxtools/normalizer/MiriamLink.java#L192-L206 |
deeplearning4j/deeplearning4j | nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/v2/ModelParameterServer.java | ModelParameterServer.configure | public void configure(@NonNull VoidConfiguration configuration, @NonNull Transport transport, @NonNull UpdaterParametersProvider updaterProvider) {
"""
This method stores provided entities for MPS internal use
@param configuration
@param transport
@param isMasterNode
"""
this.transport = transport;
this.masterMode = false;
this.configuration = configuration;
this.updaterParametersProvider = updaterProvider;
} | java | public void configure(@NonNull VoidConfiguration configuration, @NonNull Transport transport, @NonNull UpdaterParametersProvider updaterProvider) {
this.transport = transport;
this.masterMode = false;
this.configuration = configuration;
this.updaterParametersProvider = updaterProvider;
} | [
"public",
"void",
"configure",
"(",
"@",
"NonNull",
"VoidConfiguration",
"configuration",
",",
"@",
"NonNull",
"Transport",
"transport",
",",
"@",
"NonNull",
"UpdaterParametersProvider",
"updaterProvider",
")",
"{",
"this",
".",
"transport",
"=",
"transport",
";",
"this",
".",
"masterMode",
"=",
"false",
";",
"this",
".",
"configuration",
"=",
"configuration",
";",
"this",
".",
"updaterParametersProvider",
"=",
"updaterProvider",
";",
"}"
] | This method stores provided entities for MPS internal use
@param configuration
@param transport
@param isMasterNode | [
"This",
"method",
"stores",
"provided",
"entities",
"for",
"MPS",
"internal",
"use"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/v2/ModelParameterServer.java#L166-L171 |
Stratio/deep-spark | deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java | UtilMongoDB.subDocumentListCase | private static <T> Object subDocumentListCase(Type type, List<T> bsonOject)
throws IllegalAccessException, InstantiationException, InvocationTargetException {
"""
Sub document list case.
@param <T> the type parameter
@param type the type
@param bsonOject the bson oject
@return the object
@throws IllegalAccessException the illegal access exception
@throws InstantiationException the instantiation exception
@throws InvocationTargetException the invocation target exception
"""
ParameterizedType listType = (ParameterizedType) type;
Class<?> listClass = (Class<?>) listType.getActualTypeArguments()[0];
List list = new ArrayList();
for (T t : bsonOject) {
list.add(getObjectFromBson(listClass, (BSONObject) t));
}
return list;
} | java | private static <T> Object subDocumentListCase(Type type, List<T> bsonOject)
throws IllegalAccessException, InstantiationException, InvocationTargetException {
ParameterizedType listType = (ParameterizedType) type;
Class<?> listClass = (Class<?>) listType.getActualTypeArguments()[0];
List list = new ArrayList();
for (T t : bsonOject) {
list.add(getObjectFromBson(listClass, (BSONObject) t));
}
return list;
} | [
"private",
"static",
"<",
"T",
">",
"Object",
"subDocumentListCase",
"(",
"Type",
"type",
",",
"List",
"<",
"T",
">",
"bsonOject",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"InvocationTargetException",
"{",
"ParameterizedType",
"listType",
"=",
"(",
"ParameterizedType",
")",
"type",
";",
"Class",
"<",
"?",
">",
"listClass",
"=",
"(",
"Class",
"<",
"?",
">",
")",
"listType",
".",
"getActualTypeArguments",
"(",
")",
"[",
"0",
"]",
";",
"List",
"list",
"=",
"new",
"ArrayList",
"(",
")",
";",
"for",
"(",
"T",
"t",
":",
"bsonOject",
")",
"{",
"list",
".",
"add",
"(",
"getObjectFromBson",
"(",
"listClass",
",",
"(",
"BSONObject",
")",
"t",
")",
")",
";",
"}",
"return",
"list",
";",
"}"
] | Sub document list case.
@param <T> the type parameter
@param type the type
@param bsonOject the bson oject
@return the object
@throws IllegalAccessException the illegal access exception
@throws InstantiationException the instantiation exception
@throws InvocationTargetException the invocation target exception | [
"Sub",
"document",
"list",
"case",
"."
] | train | https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-mongodb/src/main/java/com/stratio/deep/mongodb/utils/UtilMongoDB.java#L133-L145 |
Azure/azure-sdk-for-java | datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java | AccountsInner.listDataLakeStoreAccountsWithServiceResponseAsync | public Observable<ServiceResponse<Page<DataLakeStoreAccountInfoInner>>> listDataLakeStoreAccountsWithServiceResponseAsync(final String resourceGroupName, final String accountName) {
"""
Gets the first page of Data Lake Store accounts linked to the specified Data Lake Analytics account. The response includes a link to the next page, if any.
@param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.
@param accountName The name of the Data Lake Analytics account for which to list Data Lake Store accounts.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<DataLakeStoreAccountInfoInner> object
"""
return listDataLakeStoreAccountsSinglePageAsync(resourceGroupName, accountName)
.concatMap(new Func1<ServiceResponse<Page<DataLakeStoreAccountInfoInner>>, Observable<ServiceResponse<Page<DataLakeStoreAccountInfoInner>>>>() {
@Override
public Observable<ServiceResponse<Page<DataLakeStoreAccountInfoInner>>> call(ServiceResponse<Page<DataLakeStoreAccountInfoInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listDataLakeStoreAccountsNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<DataLakeStoreAccountInfoInner>>> listDataLakeStoreAccountsWithServiceResponseAsync(final String resourceGroupName, final String accountName) {
return listDataLakeStoreAccountsSinglePageAsync(resourceGroupName, accountName)
.concatMap(new Func1<ServiceResponse<Page<DataLakeStoreAccountInfoInner>>, Observable<ServiceResponse<Page<DataLakeStoreAccountInfoInner>>>>() {
@Override
public Observable<ServiceResponse<Page<DataLakeStoreAccountInfoInner>>> call(ServiceResponse<Page<DataLakeStoreAccountInfoInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listDataLakeStoreAccountsNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountInfoInner",
">",
">",
">",
"listDataLakeStoreAccountsWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"accountName",
")",
"{",
"return",
"listDataLakeStoreAccountsSinglePageAsync",
"(",
"resourceGroupName",
",",
"accountName",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountInfoInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountInfoInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountInfoInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"DataLakeStoreAccountInfoInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listDataLakeStoreAccountsNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the first page of Data Lake Store accounts linked to the specified Data Lake Analytics account. The response includes a link to the next page, if any.
@param resourceGroupName The name of the Azure resource group that contains the Data Lake Analytics account.
@param accountName The name of the Data Lake Analytics account for which to list Data Lake Store accounts.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<DataLakeStoreAccountInfoInner> object | [
"Gets",
"the",
"first",
"page",
"of",
"Data",
"Lake",
"Store",
"accounts",
"linked",
"to",
"the",
"specified",
"Data",
"Lake",
"Analytics",
"account",
".",
"The",
"response",
"includes",
"a",
"link",
"to",
"the",
"next",
"page",
"if",
"any",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datalakeanalytics/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakeanalytics/v2015_10_01_preview/implementation/AccountsInner.java#L1581-L1593 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/block/component/ColorComponent.java | ColorComponent.getColor | public static EnumDyeColor getColor(IBlockAccess world, BlockPos pos) {
"""
Gets the {@link EnumDyeColor color} for the {@link Block} at world coords.
@param world the world
@param pos the pos
@return the EnumDyeColor, null if the block is not {@link ColorComponent}
"""
return world != null && pos != null ? getColor(world.getBlockState(pos)) : EnumDyeColor.WHITE;
} | java | public static EnumDyeColor getColor(IBlockAccess world, BlockPos pos)
{
return world != null && pos != null ? getColor(world.getBlockState(pos)) : EnumDyeColor.WHITE;
} | [
"public",
"static",
"EnumDyeColor",
"getColor",
"(",
"IBlockAccess",
"world",
",",
"BlockPos",
"pos",
")",
"{",
"return",
"world",
"!=",
"null",
"&&",
"pos",
"!=",
"null",
"?",
"getColor",
"(",
"world",
".",
"getBlockState",
"(",
"pos",
")",
")",
":",
"EnumDyeColor",
".",
"WHITE",
";",
"}"
] | Gets the {@link EnumDyeColor color} for the {@link Block} at world coords.
@param world the world
@param pos the pos
@return the EnumDyeColor, null if the block is not {@link ColorComponent} | [
"Gets",
"the",
"{",
"@link",
"EnumDyeColor",
"color",
"}",
"for",
"the",
"{",
"@link",
"Block",
"}",
"at",
"world",
"coords",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/block/component/ColorComponent.java#L203-L206 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/cellconverter/impl/AbstractDateCellConverterFactory.java | AbstractDateCellConverterFactory.parseString | protected T parseString(final DateFormat formatter, final String text) throws ParseException {
"""
文字列をパースして対応するオブジェクトに変換する
@param formatter フォーマッタ
@param text パース対象の文字列
@return パースした結果
@throws ParseException
"""
Date date = formatter.parse(text);
return convertTypeValue(date);
} | java | protected T parseString(final DateFormat formatter, final String text) throws ParseException {
Date date = formatter.parse(text);
return convertTypeValue(date);
} | [
"protected",
"T",
"parseString",
"(",
"final",
"DateFormat",
"formatter",
",",
"final",
"String",
"text",
")",
"throws",
"ParseException",
"{",
"Date",
"date",
"=",
"formatter",
".",
"parse",
"(",
"text",
")",
";",
"return",
"convertTypeValue",
"(",
"date",
")",
";",
"}"
] | 文字列をパースして対応するオブジェクトに変換する
@param formatter フォーマッタ
@param text パース対象の文字列
@return パースした結果
@throws ParseException | [
"文字列をパースして対応するオブジェクトに変換する"
] | train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/cellconverter/impl/AbstractDateCellConverterFactory.java#L90-L93 |
actorapp/actor-platform | actor-sdk/sdk-core/runtime/runtime-android/src/main/java/im/actor/runtime/android/crypto/PRNGFixes.java | PRNGFixes.getDeviceSerialNumber | private static String getDeviceSerialNumber() {
"""
Gets the hardware serial number of this device.
@return serial number or {@code null} if not available.
"""
// We're using the Reflection API because Build.SERIAL is only available
// since API Level 9 (Gingerbread, Android 2.3).
try {
return (String) Build.class.getField("SERIAL").get(null);
} catch (Exception ignored) {
return null;
}
} | java | private static String getDeviceSerialNumber() {
// We're using the Reflection API because Build.SERIAL is only available
// since API Level 9 (Gingerbread, Android 2.3).
try {
return (String) Build.class.getField("SERIAL").get(null);
} catch (Exception ignored) {
return null;
}
} | [
"private",
"static",
"String",
"getDeviceSerialNumber",
"(",
")",
"{",
"// We're using the Reflection API because Build.SERIAL is only available",
"// since API Level 9 (Gingerbread, Android 2.3).",
"try",
"{",
"return",
"(",
"String",
")",
"Build",
".",
"class",
".",
"getField",
"(",
"\"SERIAL\"",
")",
".",
"get",
"(",
"null",
")",
";",
"}",
"catch",
"(",
"Exception",
"ignored",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Gets the hardware serial number of this device.
@return serial number or {@code null} if not available. | [
"Gets",
"the",
"hardware",
"serial",
"number",
"of",
"this",
"device",
"."
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/runtime/runtime-android/src/main/java/im/actor/runtime/android/crypto/PRNGFixes.java#L326-L334 |
groovy/groovy-core | src/main/groovy/xml/QName.java | QName.valueOf | public static QName valueOf(String s) {
"""
Returns a QName holding the value of the specified String.
<p>
The string must be in the form returned by the QName.toString()
method, i.e. "{namespaceURI}localPart", with the "{namespaceURI}"
part being optional.
<p>
This method doesn't do a full validation of the resulting QName.
In particular, it doesn't check that the resulting namespace URI
is a legal URI (per RFC 2396 and RFC 2732), nor that the resulting
local part is a legal NCName per the XML Namespaces specification.
@param s the string to be parsed
@throws java.lang.IllegalArgumentException If the specified String cannot be parsed as a QName
@return QName corresponding to the given String
"""
if ((s == null) || s.equals("")) {
throw new IllegalArgumentException("invalid QName literal");
}
if (s.charAt(0) == '{') {
int i = s.indexOf('}');
if (i == -1) {
throw new IllegalArgumentException("invalid QName literal");
}
if (i == s.length() - 1) {
throw new IllegalArgumentException("invalid QName literal");
} else {
return new QName(s.substring(1, i), s.substring(i + 1));
}
} else {
return new QName(s);
}
} | java | public static QName valueOf(String s) {
if ((s == null) || s.equals("")) {
throw new IllegalArgumentException("invalid QName literal");
}
if (s.charAt(0) == '{') {
int i = s.indexOf('}');
if (i == -1) {
throw new IllegalArgumentException("invalid QName literal");
}
if (i == s.length() - 1) {
throw new IllegalArgumentException("invalid QName literal");
} else {
return new QName(s.substring(1, i), s.substring(i + 1));
}
} else {
return new QName(s);
}
} | [
"public",
"static",
"QName",
"valueOf",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"(",
"s",
"==",
"null",
")",
"||",
"s",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid QName literal\"",
")",
";",
"}",
"if",
"(",
"s",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"{",
"int",
"i",
"=",
"s",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"i",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid QName literal\"",
")",
";",
"}",
"if",
"(",
"i",
"==",
"s",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid QName literal\"",
")",
";",
"}",
"else",
"{",
"return",
"new",
"QName",
"(",
"s",
".",
"substring",
"(",
"1",
",",
"i",
")",
",",
"s",
".",
"substring",
"(",
"i",
"+",
"1",
")",
")",
";",
"}",
"}",
"else",
"{",
"return",
"new",
"QName",
"(",
"s",
")",
";",
"}",
"}"
] | Returns a QName holding the value of the specified String.
<p>
The string must be in the form returned by the QName.toString()
method, i.e. "{namespaceURI}localPart", with the "{namespaceURI}"
part being optional.
<p>
This method doesn't do a full validation of the resulting QName.
In particular, it doesn't check that the resulting namespace URI
is a legal URI (per RFC 2396 and RFC 2732), nor that the resulting
local part is a legal NCName per the XML Namespaces specification.
@param s the string to be parsed
@throws java.lang.IllegalArgumentException If the specified String cannot be parsed as a QName
@return QName corresponding to the given String | [
"Returns",
"a",
"QName",
"holding",
"the",
"value",
"of",
"the",
"specified",
"String",
".",
"<p",
">",
"The",
"string",
"must",
"be",
"in",
"the",
"form",
"returned",
"by",
"the",
"QName",
".",
"toString",
"()",
"method",
"i",
".",
"e",
".",
"{",
"namespaceURI",
"}",
"localPart",
"with",
"the",
"{",
"namespaceURI",
"}",
"part",
"being",
"optional",
".",
"<p",
">",
"This",
"method",
"doesn",
"t",
"do",
"a",
"full",
"validation",
"of",
"the",
"resulting",
"QName",
".",
"In",
"particular",
"it",
"doesn",
"t",
"check",
"that",
"the",
"resulting",
"namespace",
"URI",
"is",
"a",
"legal",
"URI",
"(",
"per",
"RFC",
"2396",
"and",
"RFC",
"2732",
")",
"nor",
"that",
"the",
"resulting",
"local",
"part",
"is",
"a",
"legal",
"NCName",
"per",
"the",
"XML",
"Namespaces",
"specification",
"."
] | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/groovy/xml/QName.java#L251-L272 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/xml/RaXmlGen.java | RaXmlGen.writeRequireConfigPropsXml | void writeRequireConfigPropsXml(List<ConfigPropType> props, Writer out, int indent) throws IOException {
"""
Output required config props xml part
@param props config properties
@param out Writer
@param indent space number
@throws IOException ioException
"""
if (props == null || props.size() == 0)
return;
for (ConfigPropType prop : props)
{
if (prop.isRequired())
{
writeIndent(out, indent);
out.write("<required-config-property>");
writeEol(out);
writeIndent(out, indent + 1);
out.write("<config-property-name>" + prop.getName() + "</config-property-name>");
writeEol(out);
writeIndent(out, indent);
out.write("</required-config-property>");
writeEol(out);
}
}
writeEol(out);
} | java | void writeRequireConfigPropsXml(List<ConfigPropType> props, Writer out, int indent) throws IOException
{
if (props == null || props.size() == 0)
return;
for (ConfigPropType prop : props)
{
if (prop.isRequired())
{
writeIndent(out, indent);
out.write("<required-config-property>");
writeEol(out);
writeIndent(out, indent + 1);
out.write("<config-property-name>" + prop.getName() + "</config-property-name>");
writeEol(out);
writeIndent(out, indent);
out.write("</required-config-property>");
writeEol(out);
}
}
writeEol(out);
} | [
"void",
"writeRequireConfigPropsXml",
"(",
"List",
"<",
"ConfigPropType",
">",
"props",
",",
"Writer",
"out",
",",
"int",
"indent",
")",
"throws",
"IOException",
"{",
"if",
"(",
"props",
"==",
"null",
"||",
"props",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
";",
"for",
"(",
"ConfigPropType",
"prop",
":",
"props",
")",
"{",
"if",
"(",
"prop",
".",
"isRequired",
"(",
")",
")",
"{",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"<required-config-property>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
"+",
"1",
")",
";",
"out",
".",
"write",
"(",
"\"<config-property-name>\"",
"+",
"prop",
".",
"getName",
"(",
")",
"+",
"\"</config-property-name>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"writeIndent",
"(",
"out",
",",
"indent",
")",
";",
"out",
".",
"write",
"(",
"\"</required-config-property>\"",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"}",
"}",
"writeEol",
"(",
"out",
")",
";",
"}"
] | Output required config props xml part
@param props config properties
@param out Writer
@param indent space number
@throws IOException ioException | [
"Output",
"required",
"config",
"props",
"xml",
"part"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/xml/RaXmlGen.java#L211-L233 |
looly/hutool | hutool-poi/src/main/java/cn/hutool/poi/excel/sax/Excel07SaxReader.java | Excel07SaxReader.fillBlankCell | private void fillBlankCell(String preCoordinate, String curCoordinate, boolean isEnd) {
"""
填充空白单元格,如果前一个单元格大于后一个,不需要填充<br>
@param preCoordinate 前一个单元格坐标
@param curCoordinate 当前单元格坐标
@param isEnd 是否为最后一个单元格
"""
if (false == curCoordinate.equals(preCoordinate)) {
int len = ExcelSaxUtil.countNullCell(preCoordinate, curCoordinate);
if (isEnd) {
len++;
}
while (len-- > 0) {
rowCellList.add(curCell++, "");
}
}
} | java | private void fillBlankCell(String preCoordinate, String curCoordinate, boolean isEnd) {
if (false == curCoordinate.equals(preCoordinate)) {
int len = ExcelSaxUtil.countNullCell(preCoordinate, curCoordinate);
if (isEnd) {
len++;
}
while (len-- > 0) {
rowCellList.add(curCell++, "");
}
}
} | [
"private",
"void",
"fillBlankCell",
"(",
"String",
"preCoordinate",
",",
"String",
"curCoordinate",
",",
"boolean",
"isEnd",
")",
"{",
"if",
"(",
"false",
"==",
"curCoordinate",
".",
"equals",
"(",
"preCoordinate",
")",
")",
"{",
"int",
"len",
"=",
"ExcelSaxUtil",
".",
"countNullCell",
"(",
"preCoordinate",
",",
"curCoordinate",
")",
";",
"if",
"(",
"isEnd",
")",
"{",
"len",
"++",
";",
"}",
"while",
"(",
"len",
"--",
">",
"0",
")",
"{",
"rowCellList",
".",
"add",
"(",
"curCell",
"++",
",",
"\"\"",
")",
";",
"}",
"}",
"}"
] | 填充空白单元格,如果前一个单元格大于后一个,不需要填充<br>
@param preCoordinate 前一个单元格坐标
@param curCoordinate 当前单元格坐标
@param isEnd 是否为最后一个单元格 | [
"填充空白单元格,如果前一个单元格大于后一个,不需要填充<br",
">"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-poi/src/main/java/cn/hutool/poi/excel/sax/Excel07SaxReader.java#L347-L357 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java | ComputeNodesImpl.disableScheduling | public void disableScheduling(String poolId, String nodeId) {
"""
Disables task scheduling on the specified compute node.
You can disable task scheduling on a node only if its current scheduling state is enabled.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node on which you want to disable task scheduling.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws BatchErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
disableSchedulingWithServiceResponseAsync(poolId, nodeId).toBlocking().single().body();
} | java | public void disableScheduling(String poolId, String nodeId) {
disableSchedulingWithServiceResponseAsync(poolId, nodeId).toBlocking().single().body();
} | [
"public",
"void",
"disableScheduling",
"(",
"String",
"poolId",
",",
"String",
"nodeId",
")",
"{",
"disableSchedulingWithServiceResponseAsync",
"(",
"poolId",
",",
"nodeId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Disables task scheduling on the specified compute node.
You can disable task scheduling on a node only if its current scheduling state is enabled.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node on which you want to disable task scheduling.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws BatchErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Disables",
"task",
"scheduling",
"on",
"the",
"specified",
"compute",
"node",
".",
"You",
"can",
"disable",
"task",
"scheduling",
"on",
"a",
"node",
"only",
"if",
"its",
"current",
"scheduling",
"state",
"is",
"enabled",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java#L1502-L1504 |
zaproxy/zaproxy | src/org/parosproxy/paros/network/HttpSender.java | HttpSender.sendAndReceiveImpl | private void sendAndReceiveImpl(HttpMessage message, HttpRequestConfig requestConfig) throws IOException {
"""
Helper method that sends the request of the given HTTP {@code message} with the given configurations.
<p>
No redirections are followed (see {@link #followRedirections(HttpMessage, HttpRequestConfig)}).
@param message the message that will be sent.
@param requestConfig the request configurations.
@throws IOException if an error occurred while sending the message or following the redirections.
"""
if (log.isDebugEnabled()) {
log.debug("Sending " + message.getRequestHeader().getMethod() + " " + message.getRequestHeader().getURI());
}
message.setTimeSentMillis(System.currentTimeMillis());
try {
if (requestConfig.isNotifyListeners()) {
notifyRequestListeners(message);
}
HttpMethodParams params = null;
if (requestConfig.getSoTimeout() != HttpRequestConfig.NO_VALUE_SET) {
params = new HttpMethodParams();
params.setSoTimeout(requestConfig.getSoTimeout());
}
sendAuthenticated(message, false, params);
} finally {
message.setTimeElapsedMillis((int) (System.currentTimeMillis() - message.getTimeSentMillis()));
if (log.isDebugEnabled()) {
log.debug(
"Received response after " + message.getTimeElapsedMillis() + "ms for "
+ message.getRequestHeader().getMethod() + " " + message.getRequestHeader().getURI());
}
if (requestConfig.isNotifyListeners()) {
notifyResponseListeners(message);
}
}
} | java | private void sendAndReceiveImpl(HttpMessage message, HttpRequestConfig requestConfig) throws IOException {
if (log.isDebugEnabled()) {
log.debug("Sending " + message.getRequestHeader().getMethod() + " " + message.getRequestHeader().getURI());
}
message.setTimeSentMillis(System.currentTimeMillis());
try {
if (requestConfig.isNotifyListeners()) {
notifyRequestListeners(message);
}
HttpMethodParams params = null;
if (requestConfig.getSoTimeout() != HttpRequestConfig.NO_VALUE_SET) {
params = new HttpMethodParams();
params.setSoTimeout(requestConfig.getSoTimeout());
}
sendAuthenticated(message, false, params);
} finally {
message.setTimeElapsedMillis((int) (System.currentTimeMillis() - message.getTimeSentMillis()));
if (log.isDebugEnabled()) {
log.debug(
"Received response after " + message.getTimeElapsedMillis() + "ms for "
+ message.getRequestHeader().getMethod() + " " + message.getRequestHeader().getURI());
}
if (requestConfig.isNotifyListeners()) {
notifyResponseListeners(message);
}
}
} | [
"private",
"void",
"sendAndReceiveImpl",
"(",
"HttpMessage",
"message",
",",
"HttpRequestConfig",
"requestConfig",
")",
"throws",
"IOException",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Sending \"",
"+",
"message",
".",
"getRequestHeader",
"(",
")",
".",
"getMethod",
"(",
")",
"+",
"\" \"",
"+",
"message",
".",
"getRequestHeader",
"(",
")",
".",
"getURI",
"(",
")",
")",
";",
"}",
"message",
".",
"setTimeSentMillis",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"try",
"{",
"if",
"(",
"requestConfig",
".",
"isNotifyListeners",
"(",
")",
")",
"{",
"notifyRequestListeners",
"(",
"message",
")",
";",
"}",
"HttpMethodParams",
"params",
"=",
"null",
";",
"if",
"(",
"requestConfig",
".",
"getSoTimeout",
"(",
")",
"!=",
"HttpRequestConfig",
".",
"NO_VALUE_SET",
")",
"{",
"params",
"=",
"new",
"HttpMethodParams",
"(",
")",
";",
"params",
".",
"setSoTimeout",
"(",
"requestConfig",
".",
"getSoTimeout",
"(",
")",
")",
";",
"}",
"sendAuthenticated",
"(",
"message",
",",
"false",
",",
"params",
")",
";",
"}",
"finally",
"{",
"message",
".",
"setTimeElapsedMillis",
"(",
"(",
"int",
")",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"message",
".",
"getTimeSentMillis",
"(",
")",
")",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Received response after \"",
"+",
"message",
".",
"getTimeElapsedMillis",
"(",
")",
"+",
"\"ms for \"",
"+",
"message",
".",
"getRequestHeader",
"(",
")",
".",
"getMethod",
"(",
")",
"+",
"\" \"",
"+",
"message",
".",
"getRequestHeader",
"(",
")",
".",
"getURI",
"(",
")",
")",
";",
"}",
"if",
"(",
"requestConfig",
".",
"isNotifyListeners",
"(",
")",
")",
"{",
"notifyResponseListeners",
"(",
"message",
")",
";",
"}",
"}",
"}"
] | Helper method that sends the request of the given HTTP {@code message} with the given configurations.
<p>
No redirections are followed (see {@link #followRedirections(HttpMessage, HttpRequestConfig)}).
@param message the message that will be sent.
@param requestConfig the request configurations.
@throws IOException if an error occurred while sending the message or following the redirections. | [
"Helper",
"method",
"that",
"sends",
"the",
"request",
"of",
"the",
"given",
"HTTP",
"{",
"@code",
"message",
"}",
"with",
"the",
"given",
"configurations",
".",
"<p",
">",
"No",
"redirections",
"are",
"followed",
"(",
"see",
"{",
"@link",
"#followRedirections",
"(",
"HttpMessage",
"HttpRequestConfig",
")",
"}",
")",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/network/HttpSender.java#L901-L932 |
netty/netty | transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java | ServerBootstrap.childOption | public <T> ServerBootstrap childOption(ChannelOption<T> childOption, T value) {
"""
Allow to specify a {@link ChannelOption} which is used for the {@link Channel} instances once they get created
(after the acceptor accepted the {@link Channel}). Use a value of {@code null} to remove a previous set
{@link ChannelOption}.
"""
if (childOption == null) {
throw new NullPointerException("childOption");
}
if (value == null) {
synchronized (childOptions) {
childOptions.remove(childOption);
}
} else {
synchronized (childOptions) {
childOptions.put(childOption, value);
}
}
return this;
} | java | public <T> ServerBootstrap childOption(ChannelOption<T> childOption, T value) {
if (childOption == null) {
throw new NullPointerException("childOption");
}
if (value == null) {
synchronized (childOptions) {
childOptions.remove(childOption);
}
} else {
synchronized (childOptions) {
childOptions.put(childOption, value);
}
}
return this;
} | [
"public",
"<",
"T",
">",
"ServerBootstrap",
"childOption",
"(",
"ChannelOption",
"<",
"T",
">",
"childOption",
",",
"T",
"value",
")",
"{",
"if",
"(",
"childOption",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"childOption\"",
")",
";",
"}",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"synchronized",
"(",
"childOptions",
")",
"{",
"childOptions",
".",
"remove",
"(",
"childOption",
")",
";",
"}",
"}",
"else",
"{",
"synchronized",
"(",
"childOptions",
")",
"{",
"childOptions",
".",
"put",
"(",
"childOption",
",",
"value",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Allow to specify a {@link ChannelOption} which is used for the {@link Channel} instances once they get created
(after the acceptor accepted the {@link Channel}). Use a value of {@code null} to remove a previous set
{@link ChannelOption}. | [
"Allow",
"to",
"specify",
"a",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport/src/main/java/io/netty/bootstrap/ServerBootstrap.java#L97-L111 |
google/closure-compiler | src/com/google/javascript/jscomp/TypeValidator.java | TypeValidator.expectITemplateArraySupertype | void expectITemplateArraySupertype(Node n, JSType type, String msg) {
"""
Expect the type to be an ITemplateArray or supertype of ITemplateArray.
"""
if (!getNativeType(I_TEMPLATE_ARRAY_TYPE).isSubtypeOf(type)) {
mismatch(n, msg, type, I_TEMPLATE_ARRAY_TYPE);
}
} | java | void expectITemplateArraySupertype(Node n, JSType type, String msg) {
if (!getNativeType(I_TEMPLATE_ARRAY_TYPE).isSubtypeOf(type)) {
mismatch(n, msg, type, I_TEMPLATE_ARRAY_TYPE);
}
} | [
"void",
"expectITemplateArraySupertype",
"(",
"Node",
"n",
",",
"JSType",
"type",
",",
"String",
"msg",
")",
"{",
"if",
"(",
"!",
"getNativeType",
"(",
"I_TEMPLATE_ARRAY_TYPE",
")",
".",
"isSubtypeOf",
"(",
"type",
")",
")",
"{",
"mismatch",
"(",
"n",
",",
"msg",
",",
"type",
",",
"I_TEMPLATE_ARRAY_TYPE",
")",
";",
"}",
"}"
] | Expect the type to be an ITemplateArray or supertype of ITemplateArray. | [
"Expect",
"the",
"type",
"to",
"be",
"an",
"ITemplateArray",
"or",
"supertype",
"of",
"ITemplateArray",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeValidator.java#L353-L357 |
datastax/java-driver | query-builder/src/main/java/com/datastax/oss/driver/api/querybuilder/SchemaBuilder.java | SchemaBuilder.dropAggregate | @NonNull
public static Drop dropAggregate(
@Nullable CqlIdentifier keyspace, @NonNull CqlIdentifier aggregateName) {
"""
Starts an DROP AGGREGATE query for the given aggregate name for the given keyspace name.
"""
return new DefaultDrop(keyspace, aggregateName, "AGGREGATE");
} | java | @NonNull
public static Drop dropAggregate(
@Nullable CqlIdentifier keyspace, @NonNull CqlIdentifier aggregateName) {
return new DefaultDrop(keyspace, aggregateName, "AGGREGATE");
} | [
"@",
"NonNull",
"public",
"static",
"Drop",
"dropAggregate",
"(",
"@",
"Nullable",
"CqlIdentifier",
"keyspace",
",",
"@",
"NonNull",
"CqlIdentifier",
"aggregateName",
")",
"{",
"return",
"new",
"DefaultDrop",
"(",
"keyspace",
",",
"aggregateName",
",",
"\"AGGREGATE\"",
")",
";",
"}"
] | Starts an DROP AGGREGATE query for the given aggregate name for the given keyspace name. | [
"Starts",
"an",
"DROP",
"AGGREGATE",
"query",
"for",
"the",
"given",
"aggregate",
"name",
"for",
"the",
"given",
"keyspace",
"name",
"."
] | train | https://github.com/datastax/java-driver/blob/612a63f2525618e2020e86c9ad75ab37adba6132/query-builder/src/main/java/com/datastax/oss/driver/api/querybuilder/SchemaBuilder.java#L589-L593 |
UrielCh/ovh-java-sdk | ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java | ApiOvhPackxdsl.packName_voipLine_options_hardwares_GET | public ArrayList<OvhVoIPHardware> packName_voipLine_options_hardwares_GET(String packName) throws IOException {
"""
Get available hardwares
REST: GET /pack/xdsl/{packName}/voipLine/options/hardwares
@param packName [required] The internal name of your pack
"""
String qPath = "/pack/xdsl/{packName}/voipLine/options/hardwares";
StringBuilder sb = path(qPath, packName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t5);
} | java | public ArrayList<OvhVoIPHardware> packName_voipLine_options_hardwares_GET(String packName) throws IOException {
String qPath = "/pack/xdsl/{packName}/voipLine/options/hardwares";
StringBuilder sb = path(qPath, packName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t5);
} | [
"public",
"ArrayList",
"<",
"OvhVoIPHardware",
">",
"packName_voipLine_options_hardwares_GET",
"(",
"String",
"packName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/pack/xdsl/{packName}/voipLine/options/hardwares\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"packName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t5",
")",
";",
"}"
] | Get available hardwares
REST: GET /pack/xdsl/{packName}/voipLine/options/hardwares
@param packName [required] The internal name of your pack | [
"Get",
"available",
"hardwares"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java#L301-L306 |
att/AAF | authz/authz-cass/src/main/java/com/att/dao/aaf/hl/Function.java | Function.addUserRole | public Result<Void> addUserRole(AuthzTrans trans,UserRoleDAO.Data urData) {
"""
Add a User to Role
1) Role must exist 2) User must be a known Credential (i.e. mechID ok if
Credential) or known Organizational User
@param trans
@param org
@param urData
@return
@throws DAOException
"""
Result<Void> rv;
if(Question.ADMIN.equals(urData.rname)) {
rv = mayAddAdmin(trans, urData.ns, urData.user);
} else if(Question.OWNER.equals(urData.rname)) {
rv = mayAddOwner(trans, urData.ns, urData.user);
} else {
rv = checkValidID(trans, new Date(), urData.user);
}
if(rv.notOK()) {
return rv;
}
// Check if record exists
if (q.userRoleDAO.read(trans, urData).isOKhasData()) {
return Result.err(Status.ERR_ConflictAlreadyExists,
"User Role exists");
}
if (q.roleDAO.read(trans, urData.ns, urData.rname).notOKorIsEmpty()) {
return Result.err(Status.ERR_RoleNotFound,
"Role [%s.%s] does not exist", urData.ns, urData.rname);
}
urData.expires = trans.org().expiration(null, Expiration.UserInRole, urData.user).getTime();
Result<UserRoleDAO.Data> udr = q.userRoleDAO.create(trans, urData);
switch (udr.status) {
case OK:
return Result.ok();
default:
return Result.err(udr);
}
} | java | public Result<Void> addUserRole(AuthzTrans trans,UserRoleDAO.Data urData) {
Result<Void> rv;
if(Question.ADMIN.equals(urData.rname)) {
rv = mayAddAdmin(trans, urData.ns, urData.user);
} else if(Question.OWNER.equals(urData.rname)) {
rv = mayAddOwner(trans, urData.ns, urData.user);
} else {
rv = checkValidID(trans, new Date(), urData.user);
}
if(rv.notOK()) {
return rv;
}
// Check if record exists
if (q.userRoleDAO.read(trans, urData).isOKhasData()) {
return Result.err(Status.ERR_ConflictAlreadyExists,
"User Role exists");
}
if (q.roleDAO.read(trans, urData.ns, urData.rname).notOKorIsEmpty()) {
return Result.err(Status.ERR_RoleNotFound,
"Role [%s.%s] does not exist", urData.ns, urData.rname);
}
urData.expires = trans.org().expiration(null, Expiration.UserInRole, urData.user).getTime();
Result<UserRoleDAO.Data> udr = q.userRoleDAO.create(trans, urData);
switch (udr.status) {
case OK:
return Result.ok();
default:
return Result.err(udr);
}
} | [
"public",
"Result",
"<",
"Void",
">",
"addUserRole",
"(",
"AuthzTrans",
"trans",
",",
"UserRoleDAO",
".",
"Data",
"urData",
")",
"{",
"Result",
"<",
"Void",
">",
"rv",
";",
"if",
"(",
"Question",
".",
"ADMIN",
".",
"equals",
"(",
"urData",
".",
"rname",
")",
")",
"{",
"rv",
"=",
"mayAddAdmin",
"(",
"trans",
",",
"urData",
".",
"ns",
",",
"urData",
".",
"user",
")",
";",
"}",
"else",
"if",
"(",
"Question",
".",
"OWNER",
".",
"equals",
"(",
"urData",
".",
"rname",
")",
")",
"{",
"rv",
"=",
"mayAddOwner",
"(",
"trans",
",",
"urData",
".",
"ns",
",",
"urData",
".",
"user",
")",
";",
"}",
"else",
"{",
"rv",
"=",
"checkValidID",
"(",
"trans",
",",
"new",
"Date",
"(",
")",
",",
"urData",
".",
"user",
")",
";",
"}",
"if",
"(",
"rv",
".",
"notOK",
"(",
")",
")",
"{",
"return",
"rv",
";",
"}",
"// Check if record exists",
"if",
"(",
"q",
".",
"userRoleDAO",
".",
"read",
"(",
"trans",
",",
"urData",
")",
".",
"isOKhasData",
"(",
")",
")",
"{",
"return",
"Result",
".",
"err",
"(",
"Status",
".",
"ERR_ConflictAlreadyExists",
",",
"\"User Role exists\"",
")",
";",
"}",
"if",
"(",
"q",
".",
"roleDAO",
".",
"read",
"(",
"trans",
",",
"urData",
".",
"ns",
",",
"urData",
".",
"rname",
")",
".",
"notOKorIsEmpty",
"(",
")",
")",
"{",
"return",
"Result",
".",
"err",
"(",
"Status",
".",
"ERR_RoleNotFound",
",",
"\"Role [%s.%s] does not exist\"",
",",
"urData",
".",
"ns",
",",
"urData",
".",
"rname",
")",
";",
"}",
"urData",
".",
"expires",
"=",
"trans",
".",
"org",
"(",
")",
".",
"expiration",
"(",
"null",
",",
"Expiration",
".",
"UserInRole",
",",
"urData",
".",
"user",
")",
".",
"getTime",
"(",
")",
";",
"Result",
"<",
"UserRoleDAO",
".",
"Data",
">",
"udr",
"=",
"q",
".",
"userRoleDAO",
".",
"create",
"(",
"trans",
",",
"urData",
")",
";",
"switch",
"(",
"udr",
".",
"status",
")",
"{",
"case",
"OK",
":",
"return",
"Result",
".",
"ok",
"(",
")",
";",
"default",
":",
"return",
"Result",
".",
"err",
"(",
"udr",
")",
";",
"}",
"}"
] | Add a User to Role
1) Role must exist 2) User must be a known Credential (i.e. mechID ok if
Credential) or known Organizational User
@param trans
@param org
@param urData
@return
@throws DAOException | [
"Add",
"a",
"User",
"to",
"Role"
] | train | https://github.com/att/AAF/blob/090562e956c0035db972aafba844dc6d3fc948ee/authz/authz-cass/src/main/java/com/att/dao/aaf/hl/Function.java#L1246-L1279 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/Channel.java | Channel.queryBlockByHash | public BlockInfo queryBlockByHash(Collection<Peer> peers, byte[] blockHash, User userContext) throws InvalidArgumentException, ProposalException {
"""
Query a peer in this channel for a Block by the block hash.
@param peers the Peers to query.
@param blockHash the hash of the Block in the chain.
@param userContext the user context
@return the {@link BlockInfo} with the given block Hash
@throws InvalidArgumentException if the channel is shutdown or any of the arguments are not valid.
@throws ProposalException if an error occurred processing the query.
"""
checkChannelState();
checkPeers(peers);
userContextCheck(userContext);
if (blockHash == null) {
throw new InvalidArgumentException("blockHash parameter is null.");
}
try {
logger.trace("queryBlockByHash with hash : " + Hex.encodeHexString(blockHash) + " on channel " + name);
QuerySCCRequest querySCCRequest = new QuerySCCRequest(userContext);
querySCCRequest.setFcn(QuerySCCRequest.GETBLOCKBYHASH);
querySCCRequest.setArgs(name);
querySCCRequest.setArgBytes(new byte[][] {blockHash});
ProposalResponse proposalResponse = sendProposalSerially(querySCCRequest, peers);
return new BlockInfo(Block.parseFrom(proposalResponse.getProposalResponse().getResponse().getPayload()));
} catch (InvalidProtocolBufferException e) {
ProposalException proposalException = new ProposalException(e);
logger.error(proposalException);
throw proposalException;
}
} | java | public BlockInfo queryBlockByHash(Collection<Peer> peers, byte[] blockHash, User userContext) throws InvalidArgumentException, ProposalException {
checkChannelState();
checkPeers(peers);
userContextCheck(userContext);
if (blockHash == null) {
throw new InvalidArgumentException("blockHash parameter is null.");
}
try {
logger.trace("queryBlockByHash with hash : " + Hex.encodeHexString(blockHash) + " on channel " + name);
QuerySCCRequest querySCCRequest = new QuerySCCRequest(userContext);
querySCCRequest.setFcn(QuerySCCRequest.GETBLOCKBYHASH);
querySCCRequest.setArgs(name);
querySCCRequest.setArgBytes(new byte[][] {blockHash});
ProposalResponse proposalResponse = sendProposalSerially(querySCCRequest, peers);
return new BlockInfo(Block.parseFrom(proposalResponse.getProposalResponse().getResponse().getPayload()));
} catch (InvalidProtocolBufferException e) {
ProposalException proposalException = new ProposalException(e);
logger.error(proposalException);
throw proposalException;
}
} | [
"public",
"BlockInfo",
"queryBlockByHash",
"(",
"Collection",
"<",
"Peer",
">",
"peers",
",",
"byte",
"[",
"]",
"blockHash",
",",
"User",
"userContext",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"checkChannelState",
"(",
")",
";",
"checkPeers",
"(",
"peers",
")",
";",
"userContextCheck",
"(",
"userContext",
")",
";",
"if",
"(",
"blockHash",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"blockHash parameter is null.\"",
")",
";",
"}",
"try",
"{",
"logger",
".",
"trace",
"(",
"\"queryBlockByHash with hash : \"",
"+",
"Hex",
".",
"encodeHexString",
"(",
"blockHash",
")",
"+",
"\" on channel \"",
"+",
"name",
")",
";",
"QuerySCCRequest",
"querySCCRequest",
"=",
"new",
"QuerySCCRequest",
"(",
"userContext",
")",
";",
"querySCCRequest",
".",
"setFcn",
"(",
"QuerySCCRequest",
".",
"GETBLOCKBYHASH",
")",
";",
"querySCCRequest",
".",
"setArgs",
"(",
"name",
")",
";",
"querySCCRequest",
".",
"setArgBytes",
"(",
"new",
"byte",
"[",
"]",
"[",
"]",
"{",
"blockHash",
"}",
")",
";",
"ProposalResponse",
"proposalResponse",
"=",
"sendProposalSerially",
"(",
"querySCCRequest",
",",
"peers",
")",
";",
"return",
"new",
"BlockInfo",
"(",
"Block",
".",
"parseFrom",
"(",
"proposalResponse",
".",
"getProposalResponse",
"(",
")",
".",
"getResponse",
"(",
")",
".",
"getPayload",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"InvalidProtocolBufferException",
"e",
")",
"{",
"ProposalException",
"proposalException",
"=",
"new",
"ProposalException",
"(",
"e",
")",
";",
"logger",
".",
"error",
"(",
"proposalException",
")",
";",
"throw",
"proposalException",
";",
"}",
"}"
] | Query a peer in this channel for a Block by the block hash.
@param peers the Peers to query.
@param blockHash the hash of the Block in the chain.
@param userContext the user context
@return the {@link BlockInfo} with the given block Hash
@throws InvalidArgumentException if the channel is shutdown or any of the arguments are not valid.
@throws ProposalException if an error occurred processing the query. | [
"Query",
"a",
"peer",
"in",
"this",
"channel",
"for",
"a",
"Block",
"by",
"the",
"block",
"hash",
"."
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2715-L2741 |
infinispan/infinispan | counter/src/main/java/org/infinispan/counter/impl/weak/WeakCounterImpl.java | WeakCounterImpl.removeWeakCounter | public static void removeWeakCounter(Cache<WeakCounterKey, CounterValue> cache, CounterConfiguration configuration,
String counterName) {
"""
It removes a weak counter from the {@code cache}, identified by the {@code counterName}.
@param cache The {@link Cache} to remove the counter from.
@param configuration The counter's configuration.
@param counterName The counter's name.
"""
ByteString counterNameByteString = ByteString.fromString(counterName);
for (int i = 0; i < configuration.concurrencyLevel(); ++i) {
cache.remove(new WeakCounterKey(counterNameByteString, i));
}
} | java | public static void removeWeakCounter(Cache<WeakCounterKey, CounterValue> cache, CounterConfiguration configuration,
String counterName) {
ByteString counterNameByteString = ByteString.fromString(counterName);
for (int i = 0; i < configuration.concurrencyLevel(); ++i) {
cache.remove(new WeakCounterKey(counterNameByteString, i));
}
} | [
"public",
"static",
"void",
"removeWeakCounter",
"(",
"Cache",
"<",
"WeakCounterKey",
",",
"CounterValue",
">",
"cache",
",",
"CounterConfiguration",
"configuration",
",",
"String",
"counterName",
")",
"{",
"ByteString",
"counterNameByteString",
"=",
"ByteString",
".",
"fromString",
"(",
"counterName",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"configuration",
".",
"concurrencyLevel",
"(",
")",
";",
"++",
"i",
")",
"{",
"cache",
".",
"remove",
"(",
"new",
"WeakCounterKey",
"(",
"counterNameByteString",
",",
"i",
")",
")",
";",
"}",
"}"
] | It removes a weak counter from the {@code cache}, identified by the {@code counterName}.
@param cache The {@link Cache} to remove the counter from.
@param configuration The counter's configuration.
@param counterName The counter's name. | [
"It",
"removes",
"a",
"weak",
"counter",
"from",
"the",
"{",
"@code",
"cache",
"}",
"identified",
"by",
"the",
"{",
"@code",
"counterName",
"}",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/counter/src/main/java/org/infinispan/counter/impl/weak/WeakCounterImpl.java#L113-L119 |
pmayweg/sonar-groovy | sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/jacoco/JaCoCoReportReader.java | JaCoCoReportReader.readJacocoReport | public JaCoCoReportReader readJacocoReport(IExecutionDataVisitor executionDataVisitor, ISessionInfoVisitor sessionInfoStore) {
"""
Read JaCoCo report determining the format to be used.
@param executionDataVisitor visitor to store execution data.
@param sessionInfoStore visitor to store info session.
@return true if binary format is the latest one.
@throws IOException in case of error or binary format not supported.
"""
if (jacocoExecutionData == null) {
return this;
}
JaCoCoExtensions.logger().info("Analysing {}", jacocoExecutionData);
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(jacocoExecutionData))) {
if (useCurrentBinaryFormat) {
ExecutionDataReader reader = new ExecutionDataReader(inputStream);
reader.setSessionInfoVisitor(sessionInfoStore);
reader.setExecutionDataVisitor(executionDataVisitor);
reader.read();
} else {
org.jacoco.previous.core.data.ExecutionDataReader reader = new org.jacoco.previous.core.data.ExecutionDataReader(inputStream);
reader.setSessionInfoVisitor(sessionInfoStore);
reader.setExecutionDataVisitor(executionDataVisitor);
reader.read();
}
} catch (IOException e) {
throw new IllegalArgumentException(String.format("Unable to read %s", jacocoExecutionData.getAbsolutePath()), e);
}
return this;
} | java | public JaCoCoReportReader readJacocoReport(IExecutionDataVisitor executionDataVisitor, ISessionInfoVisitor sessionInfoStore) {
if (jacocoExecutionData == null) {
return this;
}
JaCoCoExtensions.logger().info("Analysing {}", jacocoExecutionData);
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(jacocoExecutionData))) {
if (useCurrentBinaryFormat) {
ExecutionDataReader reader = new ExecutionDataReader(inputStream);
reader.setSessionInfoVisitor(sessionInfoStore);
reader.setExecutionDataVisitor(executionDataVisitor);
reader.read();
} else {
org.jacoco.previous.core.data.ExecutionDataReader reader = new org.jacoco.previous.core.data.ExecutionDataReader(inputStream);
reader.setSessionInfoVisitor(sessionInfoStore);
reader.setExecutionDataVisitor(executionDataVisitor);
reader.read();
}
} catch (IOException e) {
throw new IllegalArgumentException(String.format("Unable to read %s", jacocoExecutionData.getAbsolutePath()), e);
}
return this;
} | [
"public",
"JaCoCoReportReader",
"readJacocoReport",
"(",
"IExecutionDataVisitor",
"executionDataVisitor",
",",
"ISessionInfoVisitor",
"sessionInfoStore",
")",
"{",
"if",
"(",
"jacocoExecutionData",
"==",
"null",
")",
"{",
"return",
"this",
";",
"}",
"JaCoCoExtensions",
".",
"logger",
"(",
")",
".",
"info",
"(",
"\"Analysing {}\"",
",",
"jacocoExecutionData",
")",
";",
"try",
"(",
"InputStream",
"inputStream",
"=",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"jacocoExecutionData",
")",
")",
")",
"{",
"if",
"(",
"useCurrentBinaryFormat",
")",
"{",
"ExecutionDataReader",
"reader",
"=",
"new",
"ExecutionDataReader",
"(",
"inputStream",
")",
";",
"reader",
".",
"setSessionInfoVisitor",
"(",
"sessionInfoStore",
")",
";",
"reader",
".",
"setExecutionDataVisitor",
"(",
"executionDataVisitor",
")",
";",
"reader",
".",
"read",
"(",
")",
";",
"}",
"else",
"{",
"org",
".",
"jacoco",
".",
"previous",
".",
"core",
".",
"data",
".",
"ExecutionDataReader",
"reader",
"=",
"new",
"org",
".",
"jacoco",
".",
"previous",
".",
"core",
".",
"data",
".",
"ExecutionDataReader",
"(",
"inputStream",
")",
";",
"reader",
".",
"setSessionInfoVisitor",
"(",
"sessionInfoStore",
")",
";",
"reader",
".",
"setExecutionDataVisitor",
"(",
"executionDataVisitor",
")",
";",
"reader",
".",
"read",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Unable to read %s\"",
",",
"jacocoExecutionData",
".",
"getAbsolutePath",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Read JaCoCo report determining the format to be used.
@param executionDataVisitor visitor to store execution data.
@param sessionInfoStore visitor to store info session.
@return true if binary format is the latest one.
@throws IOException in case of error or binary format not supported. | [
"Read",
"JaCoCo",
"report",
"determining",
"the",
"format",
"to",
"be",
"used",
"."
] | train | https://github.com/pmayweg/sonar-groovy/blob/2d78d6578304601613db928795d81de340e6fa34/sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/jacoco/JaCoCoReportReader.java#L56-L78 |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/template/engine/velocity/VelocityUtil.java | VelocityUtil.toWriter | public static void toWriter(String templateFileName, VelocityContext context, Writer writer) {
"""
生成内容写入流<br>
会自动关闭Writer
@param templateFileName 模板文件名
@param context 上下文
@param writer 流
"""
assertInit();
final Template template = Velocity.getTemplate(templateFileName);
merge(template, context, writer);
} | java | public static void toWriter(String templateFileName, VelocityContext context, Writer writer) {
assertInit();
final Template template = Velocity.getTemplate(templateFileName);
merge(template, context, writer);
} | [
"public",
"static",
"void",
"toWriter",
"(",
"String",
"templateFileName",
",",
"VelocityContext",
"context",
",",
"Writer",
"writer",
")",
"{",
"assertInit",
"(",
")",
";",
"final",
"Template",
"template",
"=",
"Velocity",
".",
"getTemplate",
"(",
"templateFileName",
")",
";",
"merge",
"(",
"template",
",",
"context",
",",
"writer",
")",
";",
"}"
] | 生成内容写入流<br>
会自动关闭Writer
@param templateFileName 模板文件名
@param context 上下文
@param writer 流 | [
"生成内容写入流<br",
">",
"会自动关闭Writer"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/template/engine/velocity/VelocityUtil.java#L199-L204 |
phax/ph-masterdata | ph-masterdata/src/main/java/com/helger/masterdata/price/Price.java | Price.createFromGrossAmount | @Nonnull
public static Price createFromGrossAmount (@Nonnull final ECurrency eCurrency,
@Nonnull final BigDecimal aGrossAmount,
@Nonnull final IVATItem aVATItem,
@Nonnegative final int nScale,
@Nonnull final RoundingMode eRoundingMode) {
"""
Create a price from a gross amount.
@param eCurrency
Currency to use. May not be <code>null</code>.
@param aGrossAmount
The gross amount to use. May not be <code>null</code>.
@param aVATItem
The VAT item to use. May not be <code>null</code>.
@param nScale
The scaling to be used for the resulting amount, in case
<code>grossAmount / (1 + perc/100)</code> delivery an inexact
result.
@param eRoundingMode
The rounding mode to be used to create a valid result.
@return The created {@link Price}
"""
ValueEnforcer.notNull (aVATItem, "VATItem");
final BigDecimal aFactor = aVATItem.getMultiplicationFactorNetToGross ();
if (MathHelper.isEQ1 (aFactor))
{
// Shortcut for no VAT (net == gross)
return new Price (eCurrency, aGrossAmount, aVATItem);
}
return new Price (eCurrency, aGrossAmount.divide (aFactor, nScale, eRoundingMode), aVATItem);
} | java | @Nonnull
public static Price createFromGrossAmount (@Nonnull final ECurrency eCurrency,
@Nonnull final BigDecimal aGrossAmount,
@Nonnull final IVATItem aVATItem,
@Nonnegative final int nScale,
@Nonnull final RoundingMode eRoundingMode)
{
ValueEnforcer.notNull (aVATItem, "VATItem");
final BigDecimal aFactor = aVATItem.getMultiplicationFactorNetToGross ();
if (MathHelper.isEQ1 (aFactor))
{
// Shortcut for no VAT (net == gross)
return new Price (eCurrency, aGrossAmount, aVATItem);
}
return new Price (eCurrency, aGrossAmount.divide (aFactor, nScale, eRoundingMode), aVATItem);
} | [
"@",
"Nonnull",
"public",
"static",
"Price",
"createFromGrossAmount",
"(",
"@",
"Nonnull",
"final",
"ECurrency",
"eCurrency",
",",
"@",
"Nonnull",
"final",
"BigDecimal",
"aGrossAmount",
",",
"@",
"Nonnull",
"final",
"IVATItem",
"aVATItem",
",",
"@",
"Nonnegative",
"final",
"int",
"nScale",
",",
"@",
"Nonnull",
"final",
"RoundingMode",
"eRoundingMode",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aVATItem",
",",
"\"VATItem\"",
")",
";",
"final",
"BigDecimal",
"aFactor",
"=",
"aVATItem",
".",
"getMultiplicationFactorNetToGross",
"(",
")",
";",
"if",
"(",
"MathHelper",
".",
"isEQ1",
"(",
"aFactor",
")",
")",
"{",
"// Shortcut for no VAT (net == gross)",
"return",
"new",
"Price",
"(",
"eCurrency",
",",
"aGrossAmount",
",",
"aVATItem",
")",
";",
"}",
"return",
"new",
"Price",
"(",
"eCurrency",
",",
"aGrossAmount",
".",
"divide",
"(",
"aFactor",
",",
"nScale",
",",
"eRoundingMode",
")",
",",
"aVATItem",
")",
";",
"}"
] | Create a price from a gross amount.
@param eCurrency
Currency to use. May not be <code>null</code>.
@param aGrossAmount
The gross amount to use. May not be <code>null</code>.
@param aVATItem
The VAT item to use. May not be <code>null</code>.
@param nScale
The scaling to be used for the resulting amount, in case
<code>grossAmount / (1 + perc/100)</code> delivery an inexact
result.
@param eRoundingMode
The rounding mode to be used to create a valid result.
@return The created {@link Price} | [
"Create",
"a",
"price",
"from",
"a",
"gross",
"amount",
"."
] | train | https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/price/Price.java#L290-L306 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/QueryByCriteria.java | QueryByCriteria.setPathClass | public void setPathClass(String aPath, Class aClass) {
"""
Set the Class for a path. Used for relationships to extents.<br>
SqlStatment will use this class when resolving the path.
Without this hint SqlStatment will use the base class the
relationship points to ie: Article instead of CdArticle.
Using this method is the same as adding just one hint
@param aPath the path segment ie: allArticlesInGroup
@param aClass the Class ie: CdArticle
@see org.apache.ojb.broker.QueryTest#testInversePathExpression()
@see #addPathClass
"""
List pathClasses = new ArrayList();
pathClasses.add(aClass);
m_pathClasses.put(aPath, pathClasses);
} | java | public void setPathClass(String aPath, Class aClass)
{
List pathClasses = new ArrayList();
pathClasses.add(aClass);
m_pathClasses.put(aPath, pathClasses);
} | [
"public",
"void",
"setPathClass",
"(",
"String",
"aPath",
",",
"Class",
"aClass",
")",
"{",
"List",
"pathClasses",
"=",
"new",
"ArrayList",
"(",
")",
";",
"pathClasses",
".",
"add",
"(",
"aClass",
")",
";",
"m_pathClasses",
".",
"put",
"(",
"aPath",
",",
"pathClasses",
")",
";",
"}"
] | Set the Class for a path. Used for relationships to extents.<br>
SqlStatment will use this class when resolving the path.
Without this hint SqlStatment will use the base class the
relationship points to ie: Article instead of CdArticle.
Using this method is the same as adding just one hint
@param aPath the path segment ie: allArticlesInGroup
@param aClass the Class ie: CdArticle
@see org.apache.ojb.broker.QueryTest#testInversePathExpression()
@see #addPathClass | [
"Set",
"the",
"Class",
"for",
"a",
"path",
".",
"Used",
"for",
"relationships",
"to",
"extents",
".",
"<br",
">",
"SqlStatment",
"will",
"use",
"this",
"class",
"when",
"resolving",
"the",
"path",
".",
"Without",
"this",
"hint",
"SqlStatment",
"will",
"use",
"the",
"base",
"class",
"the",
"relationship",
"points",
"to",
"ie",
":",
"Article",
"instead",
"of",
"CdArticle",
".",
"Using",
"this",
"method",
"is",
"the",
"same",
"as",
"adding",
"just",
"one",
"hint"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/QueryByCriteria.java#L216-L221 |
apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/splitter/DistcpFileSplitter.java | DistcpFileSplitter.mergeSplits | private static WorkUnitState mergeSplits(FileSystem fs, CopyableFile file, Collection<WorkUnitState> workUnits,
Path parentPath) throws IOException {
"""
Merges all the splits for a given file.
Should be called on the target/destination file system (after blocks have been copied to targetFs).
@param fs {@link FileSystem} where file parts exist.
@param file {@link CopyableFile} to merge.
@param workUnits {@link WorkUnitState}s for all parts of this file.
@param parentPath {@link Path} where the parts of the file are located.
@return a {@link WorkUnit} equivalent to the distcp work unit if the file had not been split.
@throws IOException
"""
log.info(String.format("File %s was written in %d parts. Merging.", file.getDestination(), workUnits.size()));
Path[] parts = new Path[workUnits.size()];
for (WorkUnitState workUnit : workUnits) {
if (!isSplitWorkUnit(workUnit)) {
throw new IOException("Not a split work unit.");
}
Split split = getSplit(workUnit).get();
parts[split.getSplitNumber()] = new Path(parentPath, split.getPartName());
}
Path target = new Path(parentPath, file.getDestination().getName());
fs.rename(parts[0], target);
fs.concat(target, Arrays.copyOfRange(parts, 1, parts.length));
WorkUnitState finalWorkUnit = workUnits.iterator().next();
finalWorkUnit.removeProp(SPLIT_KEY);
return finalWorkUnit;
} | java | private static WorkUnitState mergeSplits(FileSystem fs, CopyableFile file, Collection<WorkUnitState> workUnits,
Path parentPath) throws IOException {
log.info(String.format("File %s was written in %d parts. Merging.", file.getDestination(), workUnits.size()));
Path[] parts = new Path[workUnits.size()];
for (WorkUnitState workUnit : workUnits) {
if (!isSplitWorkUnit(workUnit)) {
throw new IOException("Not a split work unit.");
}
Split split = getSplit(workUnit).get();
parts[split.getSplitNumber()] = new Path(parentPath, split.getPartName());
}
Path target = new Path(parentPath, file.getDestination().getName());
fs.rename(parts[0], target);
fs.concat(target, Arrays.copyOfRange(parts, 1, parts.length));
WorkUnitState finalWorkUnit = workUnits.iterator().next();
finalWorkUnit.removeProp(SPLIT_KEY);
return finalWorkUnit;
} | [
"private",
"static",
"WorkUnitState",
"mergeSplits",
"(",
"FileSystem",
"fs",
",",
"CopyableFile",
"file",
",",
"Collection",
"<",
"WorkUnitState",
">",
"workUnits",
",",
"Path",
"parentPath",
")",
"throws",
"IOException",
"{",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"File %s was written in %d parts. Merging.\"",
",",
"file",
".",
"getDestination",
"(",
")",
",",
"workUnits",
".",
"size",
"(",
")",
")",
")",
";",
"Path",
"[",
"]",
"parts",
"=",
"new",
"Path",
"[",
"workUnits",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"WorkUnitState",
"workUnit",
":",
"workUnits",
")",
"{",
"if",
"(",
"!",
"isSplitWorkUnit",
"(",
"workUnit",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Not a split work unit.\"",
")",
";",
"}",
"Split",
"split",
"=",
"getSplit",
"(",
"workUnit",
")",
".",
"get",
"(",
")",
";",
"parts",
"[",
"split",
".",
"getSplitNumber",
"(",
")",
"]",
"=",
"new",
"Path",
"(",
"parentPath",
",",
"split",
".",
"getPartName",
"(",
")",
")",
";",
"}",
"Path",
"target",
"=",
"new",
"Path",
"(",
"parentPath",
",",
"file",
".",
"getDestination",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"fs",
".",
"rename",
"(",
"parts",
"[",
"0",
"]",
",",
"target",
")",
";",
"fs",
".",
"concat",
"(",
"target",
",",
"Arrays",
".",
"copyOfRange",
"(",
"parts",
",",
"1",
",",
"parts",
".",
"length",
")",
")",
";",
"WorkUnitState",
"finalWorkUnit",
"=",
"workUnits",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"finalWorkUnit",
".",
"removeProp",
"(",
"SPLIT_KEY",
")",
";",
"return",
"finalWorkUnit",
";",
"}"
] | Merges all the splits for a given file.
Should be called on the target/destination file system (after blocks have been copied to targetFs).
@param fs {@link FileSystem} where file parts exist.
@param file {@link CopyableFile} to merge.
@param workUnits {@link WorkUnitState}s for all parts of this file.
@param parentPath {@link Path} where the parts of the file are located.
@return a {@link WorkUnit} equivalent to the distcp work unit if the file had not been split.
@throws IOException | [
"Merges",
"all",
"the",
"splits",
"for",
"a",
"given",
"file",
".",
"Should",
"be",
"called",
"on",
"the",
"target",
"/",
"destination",
"file",
"system",
"(",
"after",
"blocks",
"have",
"been",
"copied",
"to",
"targetFs",
")",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/splitter/DistcpFileSplitter.java#L186-L207 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/Scroller.java | Scroller.scrollView | public boolean scrollView(final View view, int direction) {
"""
Scrolls a ScrollView.
@param direction the direction to be scrolled
@return {@code true} if scrolling occurred, false if it did not
"""
if(view == null){
return false;
}
int height = view.getHeight();
height--;
int scrollTo = -1;
if (direction == DOWN) {
scrollTo = height;
}
else if (direction == UP) {
scrollTo = -height;
}
int originalY = view.getScrollY();
final int scrollAmount = scrollTo;
inst.runOnMainSync(new Runnable(){
public void run(){
view.scrollBy(0, scrollAmount);
}
});
if (originalY == view.getScrollY()) {
return false;
}
else{
return true;
}
} | java | public boolean scrollView(final View view, int direction){
if(view == null){
return false;
}
int height = view.getHeight();
height--;
int scrollTo = -1;
if (direction == DOWN) {
scrollTo = height;
}
else if (direction == UP) {
scrollTo = -height;
}
int originalY = view.getScrollY();
final int scrollAmount = scrollTo;
inst.runOnMainSync(new Runnable(){
public void run(){
view.scrollBy(0, scrollAmount);
}
});
if (originalY == view.getScrollY()) {
return false;
}
else{
return true;
}
} | [
"public",
"boolean",
"scrollView",
"(",
"final",
"View",
"view",
",",
"int",
"direction",
")",
"{",
"if",
"(",
"view",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"int",
"height",
"=",
"view",
".",
"getHeight",
"(",
")",
";",
"height",
"--",
";",
"int",
"scrollTo",
"=",
"-",
"1",
";",
"if",
"(",
"direction",
"==",
"DOWN",
")",
"{",
"scrollTo",
"=",
"height",
";",
"}",
"else",
"if",
"(",
"direction",
"==",
"UP",
")",
"{",
"scrollTo",
"=",
"-",
"height",
";",
"}",
"int",
"originalY",
"=",
"view",
".",
"getScrollY",
"(",
")",
";",
"final",
"int",
"scrollAmount",
"=",
"scrollTo",
";",
"inst",
".",
"runOnMainSync",
"(",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"view",
".",
"scrollBy",
"(",
"0",
",",
"scrollAmount",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"originalY",
"==",
"view",
".",
"getScrollY",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | Scrolls a ScrollView.
@param direction the direction to be scrolled
@return {@code true} if scrolling occurred, false if it did not | [
"Scrolls",
"a",
"ScrollView",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Scroller.java#L105-L136 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/UserApi.java | UserApi.updateUser | public User updateUser(User user, CharSequence password) throws GitLabApiException {
"""
<p>Modifies an existing user. Only administrators can change attributes of a user.</p>
<pre><code>GitLab Endpoint: PUT /users</code></pre>
<p>The following properties of the provided User instance can be set during update:<pre><code> email (required) - Email
username (required) - Username
name (required) - Name
skype (optional) - Skype ID
linkedin (optional) - LinkedIn
twitter (optional) - Twitter account
websiteUrl (optional) - Website URL
organization (optional) - Organization name
projectsLimit (optional) - Number of projects user can create
externUid (optional) - External UID
provider (optional) - External provider name
bio (optional) - User's biography
location (optional) - User's location
admin (optional) - User is admin - true or false (default)
canCreateGroup (optional) - User can create groups - true or false
skipConfirmation (optional) - Skip confirmation - true or false (default)
external (optional) - Flags the user as external - true or false(default)
sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
</code></pre>
@param user the User instance with the user info to modify
@param password the new password for the user
@return the modified User instance
@throws GitLabApiException if any exception occurs
"""
Form form = userToForm(user, null, password, false, false);
Response response = put(Response.Status.OK, form.asMap(), "users", user.getId());
return (response.readEntity(User.class));
} | java | public User updateUser(User user, CharSequence password) throws GitLabApiException {
Form form = userToForm(user, null, password, false, false);
Response response = put(Response.Status.OK, form.asMap(), "users", user.getId());
return (response.readEntity(User.class));
} | [
"public",
"User",
"updateUser",
"(",
"User",
"user",
",",
"CharSequence",
"password",
")",
"throws",
"GitLabApiException",
"{",
"Form",
"form",
"=",
"userToForm",
"(",
"user",
",",
"null",
",",
"password",
",",
"false",
",",
"false",
")",
";",
"Response",
"response",
"=",
"put",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"form",
".",
"asMap",
"(",
")",
",",
"\"users\"",
",",
"user",
".",
"getId",
"(",
")",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"User",
".",
"class",
")",
")",
";",
"}"
] | <p>Modifies an existing user. Only administrators can change attributes of a user.</p>
<pre><code>GitLab Endpoint: PUT /users</code></pre>
<p>The following properties of the provided User instance can be set during update:<pre><code> email (required) - Email
username (required) - Username
name (required) - Name
skype (optional) - Skype ID
linkedin (optional) - LinkedIn
twitter (optional) - Twitter account
websiteUrl (optional) - Website URL
organization (optional) - Organization name
projectsLimit (optional) - Number of projects user can create
externUid (optional) - External UID
provider (optional) - External provider name
bio (optional) - User's biography
location (optional) - User's location
admin (optional) - User is admin - true or false (default)
canCreateGroup (optional) - User can create groups - true or false
skipConfirmation (optional) - Skip confirmation - true or false (default)
external (optional) - Flags the user as external - true or false(default)
sharedRunnersMinutesLimit (optional) - Pipeline minutes quota for this user
</code></pre>
@param user the User instance with the user info to modify
@param password the new password for the user
@return the modified User instance
@throws GitLabApiException if any exception occurs | [
"<p",
">",
"Modifies",
"an",
"existing",
"user",
".",
"Only",
"administrators",
"can",
"change",
"attributes",
"of",
"a",
"user",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/UserApi.java#L492-L496 |
looly/hutool | hutool-log/src/main/java/cn/hutool/log/GlobalLogFactory.java | GlobalLogFactory.set | public static LogFactory set(Class<? extends LogFactory> logFactoryClass) {
"""
自定义日志实现
@see Slf4jLogFactory
@see Log4jLogFactory
@see Log4j2LogFactory
@see ApacheCommonsLogFactory
@see JdkLogFactory
@see ConsoleLogFactory
@param logFactoryClass 日志工厂类
@return 自定义的日志工厂类
"""
try {
return set(logFactoryClass.newInstance());
} catch (Exception e) {
throw new IllegalArgumentException("Can not instance LogFactory class!", e);
}
} | java | public static LogFactory set(Class<? extends LogFactory> logFactoryClass) {
try {
return set(logFactoryClass.newInstance());
} catch (Exception e) {
throw new IllegalArgumentException("Can not instance LogFactory class!", e);
}
} | [
"public",
"static",
"LogFactory",
"set",
"(",
"Class",
"<",
"?",
"extends",
"LogFactory",
">",
"logFactoryClass",
")",
"{",
"try",
"{",
"return",
"set",
"(",
"logFactoryClass",
".",
"newInstance",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can not instance LogFactory class!\"",
",",
"e",
")",
";",
"}",
"}"
] | 自定义日志实现
@see Slf4jLogFactory
@see Log4jLogFactory
@see Log4j2LogFactory
@see ApacheCommonsLogFactory
@see JdkLogFactory
@see ConsoleLogFactory
@param logFactoryClass 日志工厂类
@return 自定义的日志工厂类 | [
"自定义日志实现"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-log/src/main/java/cn/hutool/log/GlobalLogFactory.java#L50-L56 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java | SqlDateTimeUtils.dateSub | public static String dateSub(long ts, int days, TimeZone tz) {
"""
Do subtraction on date string.
@param ts the timestamp.
@param days days count you want to subtract.
@param tz time zone of the date time string
@return datetime string.
"""
ZoneId zoneId = tz.toZoneId();
Instant instant = Instant.ofEpochMilli(ts);
ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, zoneId);
long resultTs = zdt.minusDays(days).toInstant().toEpochMilli();
return dateFormat(resultTs, DATE_FORMAT_STRING, tz);
} | java | public static String dateSub(long ts, int days, TimeZone tz) {
ZoneId zoneId = tz.toZoneId();
Instant instant = Instant.ofEpochMilli(ts);
ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, zoneId);
long resultTs = zdt.minusDays(days).toInstant().toEpochMilli();
return dateFormat(resultTs, DATE_FORMAT_STRING, tz);
} | [
"public",
"static",
"String",
"dateSub",
"(",
"long",
"ts",
",",
"int",
"days",
",",
"TimeZone",
"tz",
")",
"{",
"ZoneId",
"zoneId",
"=",
"tz",
".",
"toZoneId",
"(",
")",
";",
"Instant",
"instant",
"=",
"Instant",
".",
"ofEpochMilli",
"(",
"ts",
")",
";",
"ZonedDateTime",
"zdt",
"=",
"ZonedDateTime",
".",
"ofInstant",
"(",
"instant",
",",
"zoneId",
")",
";",
"long",
"resultTs",
"=",
"zdt",
".",
"minusDays",
"(",
"days",
")",
".",
"toInstant",
"(",
")",
".",
"toEpochMilli",
"(",
")",
";",
"return",
"dateFormat",
"(",
"resultTs",
",",
"DATE_FORMAT_STRING",
",",
"tz",
")",
";",
"}"
] | Do subtraction on date string.
@param ts the timestamp.
@param days days count you want to subtract.
@param tz time zone of the date time string
@return datetime string. | [
"Do",
"subtraction",
"on",
"date",
"string",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java#L771-L777 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WLinkRenderer.java | WLinkRenderer.paintAjaxTrigger | private void paintAjaxTrigger(final WLink link, final XmlStringBuilder xml) {
"""
Paint the AJAX trigger if the link has an action.
@param link the link component being rendered
@param xml the XmlStringBuilder to paint to.
"""
AjaxTarget[] actionTargets = link.getActionTargets();
// Start tag
xml.appendTagOpen("ui:ajaxtrigger");
xml.appendAttribute("triggerId", link.getId());
xml.appendClose();
if (actionTargets != null && actionTargets.length > 0) {
// Targets
for (AjaxTarget target : actionTargets) {
xml.appendTagOpen("ui:ajaxtargetid");
xml.appendAttribute("targetId", target.getId());
xml.appendEnd();
}
} else {
// Target itself
xml.appendTagOpen("ui:ajaxtargetid");
xml.appendAttribute("targetId", link.getId());
xml.appendEnd();
}
// End tag
xml.appendEndTag("ui:ajaxtrigger");
} | java | private void paintAjaxTrigger(final WLink link, final XmlStringBuilder xml) {
AjaxTarget[] actionTargets = link.getActionTargets();
// Start tag
xml.appendTagOpen("ui:ajaxtrigger");
xml.appendAttribute("triggerId", link.getId());
xml.appendClose();
if (actionTargets != null && actionTargets.length > 0) {
// Targets
for (AjaxTarget target : actionTargets) {
xml.appendTagOpen("ui:ajaxtargetid");
xml.appendAttribute("targetId", target.getId());
xml.appendEnd();
}
} else {
// Target itself
xml.appendTagOpen("ui:ajaxtargetid");
xml.appendAttribute("targetId", link.getId());
xml.appendEnd();
}
// End tag
xml.appendEndTag("ui:ajaxtrigger");
} | [
"private",
"void",
"paintAjaxTrigger",
"(",
"final",
"WLink",
"link",
",",
"final",
"XmlStringBuilder",
"xml",
")",
"{",
"AjaxTarget",
"[",
"]",
"actionTargets",
"=",
"link",
".",
"getActionTargets",
"(",
")",
";",
"// Start tag",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:ajaxtrigger\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"triggerId\"",
",",
"link",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendClose",
"(",
")",
";",
"if",
"(",
"actionTargets",
"!=",
"null",
"&&",
"actionTargets",
".",
"length",
">",
"0",
")",
"{",
"// Targets",
"for",
"(",
"AjaxTarget",
"target",
":",
"actionTargets",
")",
"{",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:ajaxtargetid\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"targetId\"",
",",
"target",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// Target itself",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:ajaxtargetid\"",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"targetId\"",
",",
"link",
".",
"getId",
"(",
")",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"}",
"// End tag",
"xml",
".",
"appendEndTag",
"(",
"\"ui:ajaxtrigger\"",
")",
";",
"}"
] | Paint the AJAX trigger if the link has an action.
@param link the link component being rendered
@param xml the XmlStringBuilder to paint to. | [
"Paint",
"the",
"AJAX",
"trigger",
"if",
"the",
"link",
"has",
"an",
"action",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WLinkRenderer.java#L130-L154 |
acromusashi/acromusashi-stream | src/main/java/acromusashi/stream/bolt/AmBaseBolt.java | AmBaseBolt.emitWithOnlyAnchorAndGroupingStream | protected void emitWithOnlyAnchorAndGroupingStream(StreamMessage message, String groupingKey,
String streamId) {
"""
Use anchor function(child message failed. notify fail to parent message.), and not use this class's key history function.<br>
Send message to downstream component with grouping key.<br>
Use following situation.
<ol>
<li>Not use this class's key history function.</li>
<li>Use storm's fault detect function.</li>
</ol>
@param message sending message
@param groupingKey grouping key
@param streamId streamId
"""
getCollector().emit(streamId, this.getExecutingTuple(), new Values(groupingKey, message));
} | java | protected void emitWithOnlyAnchorAndGroupingStream(StreamMessage message, String groupingKey,
String streamId)
{
getCollector().emit(streamId, this.getExecutingTuple(), new Values(groupingKey, message));
} | [
"protected",
"void",
"emitWithOnlyAnchorAndGroupingStream",
"(",
"StreamMessage",
"message",
",",
"String",
"groupingKey",
",",
"String",
"streamId",
")",
"{",
"getCollector",
"(",
")",
".",
"emit",
"(",
"streamId",
",",
"this",
".",
"getExecutingTuple",
"(",
")",
",",
"new",
"Values",
"(",
"groupingKey",
",",
"message",
")",
")",
";",
"}"
] | Use anchor function(child message failed. notify fail to parent message.), and not use this class's key history function.<br>
Send message to downstream component with grouping key.<br>
Use following situation.
<ol>
<li>Not use this class's key history function.</li>
<li>Use storm's fault detect function.</li>
</ol>
@param message sending message
@param groupingKey grouping key
@param streamId streamId | [
"Use",
"anchor",
"function",
"(",
"child",
"message",
"failed",
".",
"notify",
"fail",
"to",
"parent",
"message",
".",
")",
"and",
"not",
"use",
"this",
"class",
"s",
"key",
"history",
"function",
".",
"<br",
">",
"Send",
"message",
"to",
"downstream",
"component",
"with",
"grouping",
"key",
".",
"<br",
">",
"Use",
"following",
"situation",
".",
"<ol",
">",
"<li",
">",
"Not",
"use",
"this",
"class",
"s",
"key",
"history",
"function",
".",
"<",
"/",
"li",
">",
"<li",
">",
"Use",
"storm",
"s",
"fault",
"detect",
"function",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ol",
">"
] | train | https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/bolt/AmBaseBolt.java#L723-L727 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/DoubleField.java | DoubleField.getSQLFromField | public void getSQLFromField(PreparedStatement statement, int iType, int iParamColumn) throws SQLException {
"""
Move the physical binary data to this SQL parameter row.
@param statement The SQL prepare statement.
@param iType the type of SQL statement.
@param iParamColumn The column in the prepared statement to set the data.
@exception SQLException From SQL calls.
"""
if (this.isNull())
{
if ((this.isNullable()) && (iType != DBConstants.SQL_SELECT_TYPE))
statement.setNull(iParamColumn, Types.DOUBLE);
else
statement.setDouble(iParamColumn, Double.NaN);
}
else
statement.setDouble(iParamColumn, this.getValue());
} | java | public void getSQLFromField(PreparedStatement statement, int iType, int iParamColumn) throws SQLException
{
if (this.isNull())
{
if ((this.isNullable()) && (iType != DBConstants.SQL_SELECT_TYPE))
statement.setNull(iParamColumn, Types.DOUBLE);
else
statement.setDouble(iParamColumn, Double.NaN);
}
else
statement.setDouble(iParamColumn, this.getValue());
} | [
"public",
"void",
"getSQLFromField",
"(",
"PreparedStatement",
"statement",
",",
"int",
"iType",
",",
"int",
"iParamColumn",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"this",
".",
"isNull",
"(",
")",
")",
"{",
"if",
"(",
"(",
"this",
".",
"isNullable",
"(",
")",
")",
"&&",
"(",
"iType",
"!=",
"DBConstants",
".",
"SQL_SELECT_TYPE",
")",
")",
"statement",
".",
"setNull",
"(",
"iParamColumn",
",",
"Types",
".",
"DOUBLE",
")",
";",
"else",
"statement",
".",
"setDouble",
"(",
"iParamColumn",
",",
"Double",
".",
"NaN",
")",
";",
"}",
"else",
"statement",
".",
"setDouble",
"(",
"iParamColumn",
",",
"this",
".",
"getValue",
"(",
")",
")",
";",
"}"
] | Move the physical binary data to this SQL parameter row.
@param statement The SQL prepare statement.
@param iType the type of SQL statement.
@param iParamColumn The column in the prepared statement to set the data.
@exception SQLException From SQL calls. | [
"Move",
"the",
"physical",
"binary",
"data",
"to",
"this",
"SQL",
"parameter",
"row",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/DoubleField.java#L143-L154 |
osmdroid/osmdroid | osmdroid-android/src/main/java/org/osmdroid/views/overlay/PathOverlay.java | PathOverlay.addGreatCircle | public void addGreatCircle(final GeoPoint startPoint, final GeoPoint endPoint) {
"""
Draw a great circle.
Calculate a point for every 100km along the path.
@param startPoint start point of the great circle
@param endPoint end point of the great circle
"""
// get the great circle path length in meters
final int greatCircleLength = (int) startPoint.distanceToAsDouble(endPoint);
// add one point for every 100kms of the great circle path
final int numberOfPoints = greatCircleLength/100000;
addGreatCircle(startPoint, endPoint, numberOfPoints);
} | java | public void addGreatCircle(final GeoPoint startPoint, final GeoPoint endPoint) {
// get the great circle path length in meters
final int greatCircleLength = (int) startPoint.distanceToAsDouble(endPoint);
// add one point for every 100kms of the great circle path
final int numberOfPoints = greatCircleLength/100000;
addGreatCircle(startPoint, endPoint, numberOfPoints);
} | [
"public",
"void",
"addGreatCircle",
"(",
"final",
"GeoPoint",
"startPoint",
",",
"final",
"GeoPoint",
"endPoint",
")",
"{",
"//\tget the great circle path length in meters",
"final",
"int",
"greatCircleLength",
"=",
"(",
"int",
")",
"startPoint",
".",
"distanceToAsDouble",
"(",
"endPoint",
")",
";",
"//\tadd one point for every 100kms of the great circle path",
"final",
"int",
"numberOfPoints",
"=",
"greatCircleLength",
"/",
"100000",
";",
"addGreatCircle",
"(",
"startPoint",
",",
"endPoint",
",",
"numberOfPoints",
")",
";",
"}"
] | Draw a great circle.
Calculate a point for every 100km along the path.
@param startPoint start point of the great circle
@param endPoint end point of the great circle | [
"Draw",
"a",
"great",
"circle",
".",
"Calculate",
"a",
"point",
"for",
"every",
"100km",
"along",
"the",
"path",
"."
] | train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/views/overlay/PathOverlay.java#L109-L117 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.listPrebuiltsWithServiceResponseAsync | public Observable<ServiceResponse<List<PrebuiltEntityExtractor>>> listPrebuiltsWithServiceResponseAsync(UUID appId, String versionId, ListPrebuiltsOptionalParameter listPrebuiltsOptionalParameter) {
"""
Gets information about the prebuilt entity models.
@param appId The application ID.
@param versionId The version ID.
@param listPrebuiltsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<PrebuiltEntityExtractor> object
"""
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
final Integer skip = listPrebuiltsOptionalParameter != null ? listPrebuiltsOptionalParameter.skip() : null;
final Integer take = listPrebuiltsOptionalParameter != null ? listPrebuiltsOptionalParameter.take() : null;
return listPrebuiltsWithServiceResponseAsync(appId, versionId, skip, take);
} | java | public Observable<ServiceResponse<List<PrebuiltEntityExtractor>>> listPrebuiltsWithServiceResponseAsync(UUID appId, String versionId, ListPrebuiltsOptionalParameter listPrebuiltsOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
final Integer skip = listPrebuiltsOptionalParameter != null ? listPrebuiltsOptionalParameter.skip() : null;
final Integer take = listPrebuiltsOptionalParameter != null ? listPrebuiltsOptionalParameter.take() : null;
return listPrebuiltsWithServiceResponseAsync(appId, versionId, skip, take);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"List",
"<",
"PrebuiltEntityExtractor",
">",
">",
">",
"listPrebuiltsWithServiceResponseAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"ListPrebuiltsOptionalParameter",
"listPrebuiltsOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"endpoint",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.endpoint() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"appId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter appId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"versionId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter versionId is required and cannot be null.\"",
")",
";",
"}",
"final",
"Integer",
"skip",
"=",
"listPrebuiltsOptionalParameter",
"!=",
"null",
"?",
"listPrebuiltsOptionalParameter",
".",
"skip",
"(",
")",
":",
"null",
";",
"final",
"Integer",
"take",
"=",
"listPrebuiltsOptionalParameter",
"!=",
"null",
"?",
"listPrebuiltsOptionalParameter",
".",
"take",
"(",
")",
":",
"null",
";",
"return",
"listPrebuiltsWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"skip",
",",
"take",
")",
";",
"}"
] | Gets information about the prebuilt entity models.
@param appId The application ID.
@param versionId The version ID.
@param listPrebuiltsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<PrebuiltEntityExtractor> object | [
"Gets",
"information",
"about",
"the",
"prebuilt",
"entity",
"models",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L2228-L2242 |
theHilikus/JRoboCom | jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/Player.java | Player.startRobot | public void startRobot(Robot newRobot) {
"""
Starts the thread of a robot in the player's thread group
@param newRobot the robot to start
"""
newRobot.getData().setActiveState(DEFAULT_START_STATE);
Thread newThread = new Thread(robotsThreads, newRobot, "Bot-" + newRobot.getSerialNumber());
newThread.start(); // jumpstarts the robot
} | java | public void startRobot(Robot newRobot) {
newRobot.getData().setActiveState(DEFAULT_START_STATE);
Thread newThread = new Thread(robotsThreads, newRobot, "Bot-" + newRobot.getSerialNumber());
newThread.start(); // jumpstarts the robot
} | [
"public",
"void",
"startRobot",
"(",
"Robot",
"newRobot",
")",
"{",
"newRobot",
".",
"getData",
"(",
")",
".",
"setActiveState",
"(",
"DEFAULT_START_STATE",
")",
";",
"Thread",
"newThread",
"=",
"new",
"Thread",
"(",
"robotsThreads",
",",
"newRobot",
",",
"\"Bot-\"",
"+",
"newRobot",
".",
"getSerialNumber",
"(",
")",
")",
";",
"newThread",
".",
"start",
"(",
")",
";",
"// jumpstarts the robot",
"}"
] | Starts the thread of a robot in the player's thread group
@param newRobot the robot to start | [
"Starts",
"the",
"thread",
"of",
"a",
"robot",
"in",
"the",
"player",
"s",
"thread",
"group"
] | train | https://github.com/theHilikus/JRoboCom/blob/0e31c1ecf1006e35f68c229ff66c37640effffac/jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/Player.java#L207-L212 |
pressgang-ccms/PressGangCCMSContentSpecProcessor | src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java | ContentSpecParser.parseFilesMetaData | protected FileList parseFilesMetaData(final ParserData parserData, final String value, final int lineNumber,
final String line) throws ParsingException {
"""
Parse an "Additional Files" metadata component into a List of {@link org.jboss.pressgang.ccms.contentspec.File} objects.
@param parserData
@param value The value of the key value pair
@param lineNumber The line number of the additional files key
@param line The full line of the key value pair
@return A list of parsed File objects.
@throws ParsingException Thrown if an error occurs during parsing.
"""
int startingPos = StringUtilities.indexOf(value, '[');
if (startingPos != -1) {
final List<File> files = new LinkedList<File>();
final HashMap<ParserType, String[]> variables = getLineVariables(parserData, value, lineNumber, '[', ']', ',', true);
final String[] vars = variables.get(ParserType.NONE);
// Loop over each file found and parse it
for (final String var : vars) {
final File file = parseFileMetaData(var, lineNumber);
if (file != null) {
files.add(file);
}
}
return new FileList(CommonConstants.CS_FILE_TITLE, files, lineNumber);
} else {
throw new ParsingException(format(ProcessorConstants.ERROR_INVALID_FILES_MSG, lineNumber, line));
}
} | java | protected FileList parseFilesMetaData(final ParserData parserData, final String value, final int lineNumber,
final String line) throws ParsingException {
int startingPos = StringUtilities.indexOf(value, '[');
if (startingPos != -1) {
final List<File> files = new LinkedList<File>();
final HashMap<ParserType, String[]> variables = getLineVariables(parserData, value, lineNumber, '[', ']', ',', true);
final String[] vars = variables.get(ParserType.NONE);
// Loop over each file found and parse it
for (final String var : vars) {
final File file = parseFileMetaData(var, lineNumber);
if (file != null) {
files.add(file);
}
}
return new FileList(CommonConstants.CS_FILE_TITLE, files, lineNumber);
} else {
throw new ParsingException(format(ProcessorConstants.ERROR_INVALID_FILES_MSG, lineNumber, line));
}
} | [
"protected",
"FileList",
"parseFilesMetaData",
"(",
"final",
"ParserData",
"parserData",
",",
"final",
"String",
"value",
",",
"final",
"int",
"lineNumber",
",",
"final",
"String",
"line",
")",
"throws",
"ParsingException",
"{",
"int",
"startingPos",
"=",
"StringUtilities",
".",
"indexOf",
"(",
"value",
",",
"'",
"'",
")",
";",
"if",
"(",
"startingPos",
"!=",
"-",
"1",
")",
"{",
"final",
"List",
"<",
"File",
">",
"files",
"=",
"new",
"LinkedList",
"<",
"File",
">",
"(",
")",
";",
"final",
"HashMap",
"<",
"ParserType",
",",
"String",
"[",
"]",
">",
"variables",
"=",
"getLineVariables",
"(",
"parserData",
",",
"value",
",",
"lineNumber",
",",
"'",
"'",
",",
"'",
"'",
",",
"'",
"'",
",",
"true",
")",
";",
"final",
"String",
"[",
"]",
"vars",
"=",
"variables",
".",
"get",
"(",
"ParserType",
".",
"NONE",
")",
";",
"// Loop over each file found and parse it",
"for",
"(",
"final",
"String",
"var",
":",
"vars",
")",
"{",
"final",
"File",
"file",
"=",
"parseFileMetaData",
"(",
"var",
",",
"lineNumber",
")",
";",
"if",
"(",
"file",
"!=",
"null",
")",
"{",
"files",
".",
"add",
"(",
"file",
")",
";",
"}",
"}",
"return",
"new",
"FileList",
"(",
"CommonConstants",
".",
"CS_FILE_TITLE",
",",
"files",
",",
"lineNumber",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ParsingException",
"(",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_INVALID_FILES_MSG",
",",
"lineNumber",
",",
"line",
")",
")",
";",
"}",
"}"
] | Parse an "Additional Files" metadata component into a List of {@link org.jboss.pressgang.ccms.contentspec.File} objects.
@param parserData
@param value The value of the key value pair
@param lineNumber The line number of the additional files key
@param line The full line of the key value pair
@return A list of parsed File objects.
@throws ParsingException Thrown if an error occurs during parsing. | [
"Parse",
"an",
"Additional",
"Files",
"metadata",
"component",
"into",
"a",
"List",
"of",
"{",
"@link",
"org",
".",
"jboss",
".",
"pressgang",
".",
"ccms",
".",
"contentspec",
".",
"File",
"}",
"objects",
"."
] | train | https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L858-L878 |
anotheria/moskito | moskito-integration/moskito-cdi/src/main/java/net/anotheria/moskito/integration/cdi/AbstractInterceptor.java | AbstractInterceptor.getAnnotationFromContext | protected static <T extends Annotation> T getAnnotationFromContext(InvocationContext context, Class<T> clazz) {
"""
Finds given annotation from {@link InvocationContext} (actually from method or class).
@param context {@link InvocationContext}
@param clazz annotation class
@param <T> type of the annotation
@return annotation instance
"""
T result = context.getMethod().getAnnotation(clazz);
return result != null ? result : context.getTarget().getClass().getAnnotation(clazz);
} | java | protected static <T extends Annotation> T getAnnotationFromContext(InvocationContext context, Class<T> clazz) {
T result = context.getMethod().getAnnotation(clazz);
return result != null ? result : context.getTarget().getClass().getAnnotation(clazz);
} | [
"protected",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"T",
"getAnnotationFromContext",
"(",
"InvocationContext",
"context",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"T",
"result",
"=",
"context",
".",
"getMethod",
"(",
")",
".",
"getAnnotation",
"(",
"clazz",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"result",
":",
"context",
".",
"getTarget",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getAnnotation",
"(",
"clazz",
")",
";",
"}"
] | Finds given annotation from {@link InvocationContext} (actually from method or class).
@param context {@link InvocationContext}
@param clazz annotation class
@param <T> type of the annotation
@return annotation instance | [
"Finds",
"given",
"annotation",
"from",
"{",
"@link",
"InvocationContext",
"}",
"(",
"actually",
"from",
"method",
"or",
"class",
")",
"."
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-integration/moskito-cdi/src/main/java/net/anotheria/moskito/integration/cdi/AbstractInterceptor.java#L124-L127 |
JodaOrg/joda-money | src/main/java/org/joda/money/BigMoney.java | BigMoney.dividedBy | public BigMoney dividedBy(BigDecimal valueToDivideBy, RoundingMode roundingMode) {
"""
Returns a copy of this monetary value divided by the specified value
using the specified rounding mode to adjust the scale.
<p>
The result has the same scale as this instance.
For example, 'USD 1.13' divided by '2.5' and rounding down gives 'USD 0.45'
(amount rounded down from 0.452).
<p>
This instance is immutable and unaffected by this method.
@param valueToDivideBy the scalar value to divide by, not null
@param roundingMode the rounding mode to use, not null
@return the new divided instance, never null
@throws ArithmeticException if dividing by zero
@throws ArithmeticException if the rounding fails
"""
MoneyUtils.checkNotNull(valueToDivideBy, "Divisor must not be null");
MoneyUtils.checkNotNull(roundingMode, "RoundingMode must not be null");
if (valueToDivideBy.compareTo(BigDecimal.ONE) == 0) {
return this;
}
BigDecimal newAmount = amount.divide(valueToDivideBy, roundingMode);
return BigMoney.of(currency, newAmount);
} | java | public BigMoney dividedBy(BigDecimal valueToDivideBy, RoundingMode roundingMode) {
MoneyUtils.checkNotNull(valueToDivideBy, "Divisor must not be null");
MoneyUtils.checkNotNull(roundingMode, "RoundingMode must not be null");
if (valueToDivideBy.compareTo(BigDecimal.ONE) == 0) {
return this;
}
BigDecimal newAmount = amount.divide(valueToDivideBy, roundingMode);
return BigMoney.of(currency, newAmount);
} | [
"public",
"BigMoney",
"dividedBy",
"(",
"BigDecimal",
"valueToDivideBy",
",",
"RoundingMode",
"roundingMode",
")",
"{",
"MoneyUtils",
".",
"checkNotNull",
"(",
"valueToDivideBy",
",",
"\"Divisor must not be null\"",
")",
";",
"MoneyUtils",
".",
"checkNotNull",
"(",
"roundingMode",
",",
"\"RoundingMode must not be null\"",
")",
";",
"if",
"(",
"valueToDivideBy",
".",
"compareTo",
"(",
"BigDecimal",
".",
"ONE",
")",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"BigDecimal",
"newAmount",
"=",
"amount",
".",
"divide",
"(",
"valueToDivideBy",
",",
"roundingMode",
")",
";",
"return",
"BigMoney",
".",
"of",
"(",
"currency",
",",
"newAmount",
")",
";",
"}"
] | Returns a copy of this monetary value divided by the specified value
using the specified rounding mode to adjust the scale.
<p>
The result has the same scale as this instance.
For example, 'USD 1.13' divided by '2.5' and rounding down gives 'USD 0.45'
(amount rounded down from 0.452).
<p>
This instance is immutable and unaffected by this method.
@param valueToDivideBy the scalar value to divide by, not null
@param roundingMode the rounding mode to use, not null
@return the new divided instance, never null
@throws ArithmeticException if dividing by zero
@throws ArithmeticException if the rounding fails | [
"Returns",
"a",
"copy",
"of",
"this",
"monetary",
"value",
"divided",
"by",
"the",
"specified",
"value",
"using",
"the",
"specified",
"rounding",
"mode",
"to",
"adjust",
"the",
"scale",
".",
"<p",
">",
"The",
"result",
"has",
"the",
"same",
"scale",
"as",
"this",
"instance",
".",
"For",
"example",
"USD",
"1",
".",
"13",
"divided",
"by",
"2",
".",
"5",
"and",
"rounding",
"down",
"gives",
"USD",
"0",
".",
"45",
"(",
"amount",
"rounded",
"down",
"from",
"0",
".",
"452",
")",
".",
"<p",
">",
"This",
"instance",
"is",
"immutable",
"and",
"unaffected",
"by",
"this",
"method",
"."
] | train | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/BigMoney.java#L1372-L1380 |
datasalt/pangool | core/src/main/java/com/datasalt/pangool/io/Mutator.java | Mutator.subSetOf | public static Schema subSetOf(String newName, Schema schema, String... subSetFields) {
"""
Creates a subset of the input Schema exactly with the fields whose names are specified.
The name of the schema is also specified as a parameter.
"""
List<Field> newSchema = new ArrayList<Field>();
for(String subSetField: subSetFields) {
newSchema.add(schema.getField(subSetField));
}
return new Schema(newName, newSchema);
} | java | public static Schema subSetOf(String newName, Schema schema, String... subSetFields) {
List<Field> newSchema = new ArrayList<Field>();
for(String subSetField: subSetFields) {
newSchema.add(schema.getField(subSetField));
}
return new Schema(newName, newSchema);
} | [
"public",
"static",
"Schema",
"subSetOf",
"(",
"String",
"newName",
",",
"Schema",
"schema",
",",
"String",
"...",
"subSetFields",
")",
"{",
"List",
"<",
"Field",
">",
"newSchema",
"=",
"new",
"ArrayList",
"<",
"Field",
">",
"(",
")",
";",
"for",
"(",
"String",
"subSetField",
":",
"subSetFields",
")",
"{",
"newSchema",
".",
"add",
"(",
"schema",
".",
"getField",
"(",
"subSetField",
")",
")",
";",
"}",
"return",
"new",
"Schema",
"(",
"newName",
",",
"newSchema",
")",
";",
"}"
] | Creates a subset of the input Schema exactly with the fields whose names are specified.
The name of the schema is also specified as a parameter. | [
"Creates",
"a",
"subset",
"of",
"the",
"input",
"Schema",
"exactly",
"with",
"the",
"fields",
"whose",
"names",
"are",
"specified",
".",
"The",
"name",
"of",
"the",
"schema",
"is",
"also",
"specified",
"as",
"a",
"parameter",
"."
] | train | https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/io/Mutator.java#L60-L66 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.addEntity | public UUID addEntity(UUID appId, String versionId, AddEntityOptionalParameter addEntityOptionalParameter) {
"""
Adds an entity extractor to the application.
@param appId The application ID.
@param versionId The version ID.
@param addEntityOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the UUID object if successful.
"""
return addEntityWithServiceResponseAsync(appId, versionId, addEntityOptionalParameter).toBlocking().single().body();
} | java | public UUID addEntity(UUID appId, String versionId, AddEntityOptionalParameter addEntityOptionalParameter) {
return addEntityWithServiceResponseAsync(appId, versionId, addEntityOptionalParameter).toBlocking().single().body();
} | [
"public",
"UUID",
"addEntity",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"AddEntityOptionalParameter",
"addEntityOptionalParameter",
")",
"{",
"return",
"addEntityWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"addEntityOptionalParameter",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Adds an entity extractor to the application.
@param appId The application ID.
@param versionId The version ID.
@param addEntityOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the UUID object if successful. | [
"Adds",
"an",
"entity",
"extractor",
"to",
"the",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L932-L934 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/BiLevelCacheMap.java | BiLevelCacheMap.put | public Object put(Object key, Object value) {
"""
If key is already in cacheL1, the new value will show with a delay,
since merge L2->L1 may not happen immediately. To force the merge sooner,
call <code>size()<code>.
"""
synchronized (_cacheL2)
{
_cacheL2.put(key, value);
// not really a miss, but merge to avoid big increase in L2 size
// (it cannot be reallocated, it is final)
mergeIfNeeded();
}
return value;
} | java | public Object put(Object key, Object value)
{
synchronized (_cacheL2)
{
_cacheL2.put(key, value);
// not really a miss, but merge to avoid big increase in L2 size
// (it cannot be reallocated, it is final)
mergeIfNeeded();
}
return value;
} | [
"public",
"Object",
"put",
"(",
"Object",
"key",
",",
"Object",
"value",
")",
"{",
"synchronized",
"(",
"_cacheL2",
")",
"{",
"_cacheL2",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"// not really a miss, but merge to avoid big increase in L2 size",
"// (it cannot be reallocated, it is final)",
"mergeIfNeeded",
"(",
")",
";",
"}",
"return",
"value",
";",
"}"
] | If key is already in cacheL1, the new value will show with a delay,
since merge L2->L1 may not happen immediately. To force the merge sooner,
call <code>size()<code>. | [
"If",
"key",
"is",
"already",
"in",
"cacheL1",
"the",
"new",
"value",
"will",
"show",
"with",
"a",
"delay",
"since",
"merge",
"L2",
"-",
">",
"L1",
"may",
"not",
"happen",
"immediately",
".",
"To",
"force",
"the",
"merge",
"sooner",
"call",
"<code",
">",
"size",
"()",
"<code",
">",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/util/BiLevelCacheMap.java#L162-L174 |
apache/groovy | src/main/groovy/groovy/util/ObjectGraphBuilder.java | ObjectGraphBuilder.setNewInstanceResolver | public void setNewInstanceResolver(final Object newInstanceResolver) {
"""
Sets the current NewInstanceResolver.<br>
It will assign DefaultNewInstanceResolver if null.<br>
It accepts a NewInstanceResolver instance or a Closure.
"""
if (newInstanceResolver instanceof NewInstanceResolver) {
this.newInstanceResolver = (NewInstanceResolver) newInstanceResolver;
} else if (newInstanceResolver instanceof Closure) {
final ObjectGraphBuilder self = this;
this.newInstanceResolver = new NewInstanceResolver() {
public Object newInstance(Class klass, Map attributes)
throws InstantiationException, IllegalAccessException {
Closure cls = (Closure) newInstanceResolver;
cls.setDelegate(self);
return cls.call(klass, attributes);
}
};
} else {
this.newInstanceResolver = new DefaultNewInstanceResolver();
}
} | java | public void setNewInstanceResolver(final Object newInstanceResolver) {
if (newInstanceResolver instanceof NewInstanceResolver) {
this.newInstanceResolver = (NewInstanceResolver) newInstanceResolver;
} else if (newInstanceResolver instanceof Closure) {
final ObjectGraphBuilder self = this;
this.newInstanceResolver = new NewInstanceResolver() {
public Object newInstance(Class klass, Map attributes)
throws InstantiationException, IllegalAccessException {
Closure cls = (Closure) newInstanceResolver;
cls.setDelegate(self);
return cls.call(klass, attributes);
}
};
} else {
this.newInstanceResolver = new DefaultNewInstanceResolver();
}
} | [
"public",
"void",
"setNewInstanceResolver",
"(",
"final",
"Object",
"newInstanceResolver",
")",
"{",
"if",
"(",
"newInstanceResolver",
"instanceof",
"NewInstanceResolver",
")",
"{",
"this",
".",
"newInstanceResolver",
"=",
"(",
"NewInstanceResolver",
")",
"newInstanceResolver",
";",
"}",
"else",
"if",
"(",
"newInstanceResolver",
"instanceof",
"Closure",
")",
"{",
"final",
"ObjectGraphBuilder",
"self",
"=",
"this",
";",
"this",
".",
"newInstanceResolver",
"=",
"new",
"NewInstanceResolver",
"(",
")",
"{",
"public",
"Object",
"newInstance",
"(",
"Class",
"klass",
",",
"Map",
"attributes",
")",
"throws",
"InstantiationException",
",",
"IllegalAccessException",
"{",
"Closure",
"cls",
"=",
"(",
"Closure",
")",
"newInstanceResolver",
";",
"cls",
".",
"setDelegate",
"(",
"self",
")",
";",
"return",
"cls",
".",
"call",
"(",
"klass",
",",
"attributes",
")",
";",
"}",
"}",
";",
"}",
"else",
"{",
"this",
".",
"newInstanceResolver",
"=",
"new",
"DefaultNewInstanceResolver",
"(",
")",
";",
"}",
"}"
] | Sets the current NewInstanceResolver.<br>
It will assign DefaultNewInstanceResolver if null.<br>
It accepts a NewInstanceResolver instance or a Closure. | [
"Sets",
"the",
"current",
"NewInstanceResolver",
".",
"<br",
">",
"It",
"will",
"assign",
"DefaultNewInstanceResolver",
"if",
"null",
".",
"<br",
">",
"It",
"accepts",
"a",
"NewInstanceResolver",
"instance",
"or",
"a",
"Closure",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/ObjectGraphBuilder.java#L263-L279 |
chhh/MSFTBX | MSFileToolbox/src/main/java/umich/ms/util/jaxb/JaxbUtils.java | JaxbUtils.unmarshal | public static <T> T unmarshal(Class<T> cl, Source s) throws JAXBException {
"""
Convert the contents of a Source to an object of a given class.
@param cl Type of object
@param s Source to be used
@return Object of the given type
"""
JAXBContext ctx = JAXBContext.newInstance(cl);
Unmarshaller u = ctx.createUnmarshaller();
return u.unmarshal(s, cl).getValue();
} | java | public static <T> T unmarshal(Class<T> cl, Source s) throws JAXBException {
JAXBContext ctx = JAXBContext.newInstance(cl);
Unmarshaller u = ctx.createUnmarshaller();
return u.unmarshal(s, cl).getValue();
} | [
"public",
"static",
"<",
"T",
">",
"T",
"unmarshal",
"(",
"Class",
"<",
"T",
">",
"cl",
",",
"Source",
"s",
")",
"throws",
"JAXBException",
"{",
"JAXBContext",
"ctx",
"=",
"JAXBContext",
".",
"newInstance",
"(",
"cl",
")",
";",
"Unmarshaller",
"u",
"=",
"ctx",
".",
"createUnmarshaller",
"(",
")",
";",
"return",
"u",
".",
"unmarshal",
"(",
"s",
",",
"cl",
")",
".",
"getValue",
"(",
")",
";",
"}"
] | Convert the contents of a Source to an object of a given class.
@param cl Type of object
@param s Source to be used
@return Object of the given type | [
"Convert",
"the",
"contents",
"of",
"a",
"Source",
"to",
"an",
"object",
"of",
"a",
"given",
"class",
"."
] | train | https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/jaxb/JaxbUtils.java#L286-L290 |
iobeam/iobeam-client-java | src/main/java/com/iobeam/api/client/Iobeam.java | Iobeam.registerDeviceAsync | public void registerDeviceAsync(String deviceId, RegisterCallback callback) {
"""
Registers a device asynchronously with the provided device ID.
See {@link #registerDeviceAsync(Device, RegisterCallback)} for more details.
@param deviceId Desired device ID.
@param callback Callback for result of the registration.
@throws ApiException Thrown if the iobeam client is not initialized.
"""
final Device d = new Device.Builder(projectId).id(deviceId).build();
registerDeviceAsync(d, callback);
} | java | public void registerDeviceAsync(String deviceId, RegisterCallback callback) {
final Device d = new Device.Builder(projectId).id(deviceId).build();
registerDeviceAsync(d, callback);
} | [
"public",
"void",
"registerDeviceAsync",
"(",
"String",
"deviceId",
",",
"RegisterCallback",
"callback",
")",
"{",
"final",
"Device",
"d",
"=",
"new",
"Device",
".",
"Builder",
"(",
"projectId",
")",
".",
"id",
"(",
"deviceId",
")",
".",
"build",
"(",
")",
";",
"registerDeviceAsync",
"(",
"d",
",",
"callback",
")",
";",
"}"
] | Registers a device asynchronously with the provided device ID.
See {@link #registerDeviceAsync(Device, RegisterCallback)} for more details.
@param deviceId Desired device ID.
@param callback Callback for result of the registration.
@throws ApiException Thrown if the iobeam client is not initialized. | [
"Registers",
"a",
"device",
"asynchronously",
"with",
"the",
"provided",
"device",
"ID",
"."
] | train | https://github.com/iobeam/iobeam-client-java/blob/06e7aeb2a313503392358a3671de7d28628d0e33/src/main/java/com/iobeam/api/client/Iobeam.java#L572-L575 |
facebook/fresco | imagepipeline-base/src/main/java/com/facebook/imageutils/TiffUtil.java | TiffUtil.readOrientationFromTIFF | public static int readOrientationFromTIFF(InputStream is, int length) throws IOException {
"""
Reads orientation information from TIFF data.
@param is the input stream of TIFF data
@param length length of the TIFF data
@return orientation information (1/3/6/8 on success, 0 if not found)
"""
// read tiff header
TiffHeader tiffHeader = new TiffHeader();
length = readTiffHeader(is, length, tiffHeader);
// move to the first IFD
// offset is relative to the beginning of the TIFF data
// and we already consumed the first 8 bytes of header
int toSkip = tiffHeader.firstIfdOffset - 8;
if (length == 0 || toSkip > length) {
return 0;
}
is.skip(toSkip);
length -= toSkip;
// move to the entry with orientation tag
length = moveToTiffEntryWithTag(is, length, tiffHeader.isLittleEndian, TIFF_TAG_ORIENTATION);
// read orientation
return getOrientationFromTiffEntry(is, length, tiffHeader.isLittleEndian);
} | java | public static int readOrientationFromTIFF(InputStream is, int length) throws IOException {
// read tiff header
TiffHeader tiffHeader = new TiffHeader();
length = readTiffHeader(is, length, tiffHeader);
// move to the first IFD
// offset is relative to the beginning of the TIFF data
// and we already consumed the first 8 bytes of header
int toSkip = tiffHeader.firstIfdOffset - 8;
if (length == 0 || toSkip > length) {
return 0;
}
is.skip(toSkip);
length -= toSkip;
// move to the entry with orientation tag
length = moveToTiffEntryWithTag(is, length, tiffHeader.isLittleEndian, TIFF_TAG_ORIENTATION);
// read orientation
return getOrientationFromTiffEntry(is, length, tiffHeader.isLittleEndian);
} | [
"public",
"static",
"int",
"readOrientationFromTIFF",
"(",
"InputStream",
"is",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"// read tiff header",
"TiffHeader",
"tiffHeader",
"=",
"new",
"TiffHeader",
"(",
")",
";",
"length",
"=",
"readTiffHeader",
"(",
"is",
",",
"length",
",",
"tiffHeader",
")",
";",
"// move to the first IFD",
"// offset is relative to the beginning of the TIFF data",
"// and we already consumed the first 8 bytes of header",
"int",
"toSkip",
"=",
"tiffHeader",
".",
"firstIfdOffset",
"-",
"8",
";",
"if",
"(",
"length",
"==",
"0",
"||",
"toSkip",
">",
"length",
")",
"{",
"return",
"0",
";",
"}",
"is",
".",
"skip",
"(",
"toSkip",
")",
";",
"length",
"-=",
"toSkip",
";",
"// move to the entry with orientation tag",
"length",
"=",
"moveToTiffEntryWithTag",
"(",
"is",
",",
"length",
",",
"tiffHeader",
".",
"isLittleEndian",
",",
"TIFF_TAG_ORIENTATION",
")",
";",
"// read orientation",
"return",
"getOrientationFromTiffEntry",
"(",
"is",
",",
"length",
",",
"tiffHeader",
".",
"isLittleEndian",
")",
";",
"}"
] | Reads orientation information from TIFF data.
@param is the input stream of TIFF data
@param length length of the TIFF data
@return orientation information (1/3/6/8 on success, 0 if not found) | [
"Reads",
"orientation",
"information",
"from",
"TIFF",
"data",
"."
] | train | https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imageutils/TiffUtil.java#L54-L74 |
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/date/GosuDateUtil.java | GosuDateUtil.addMonths | public static Date addMonths(Date date, int iMonths) {
"""
Adds the specified (signed) amount of months to the given date. For
example, to subtract 5 months from the current date, you can
achieve it by calling: <code>addMonths(Date, -5)</code>.
@param date The time.
@param iMonths The amount of months to add.
@return A new date with the months added.
"""
Calendar dateTime = dateToCalendar(date);
dateTime.add(Calendar.MONTH, iMonths);
return dateTime.getTime();
} | java | public static Date addMonths(Date date, int iMonths) {
Calendar dateTime = dateToCalendar(date);
dateTime.add(Calendar.MONTH, iMonths);
return dateTime.getTime();
} | [
"public",
"static",
"Date",
"addMonths",
"(",
"Date",
"date",
",",
"int",
"iMonths",
")",
"{",
"Calendar",
"dateTime",
"=",
"dateToCalendar",
"(",
"date",
")",
";",
"dateTime",
".",
"add",
"(",
"Calendar",
".",
"MONTH",
",",
"iMonths",
")",
";",
"return",
"dateTime",
".",
"getTime",
"(",
")",
";",
"}"
] | Adds the specified (signed) amount of months to the given date. For
example, to subtract 5 months from the current date, you can
achieve it by calling: <code>addMonths(Date, -5)</code>.
@param date The time.
@param iMonths The amount of months to add.
@return A new date with the months added. | [
"Adds",
"the",
"specified",
"(",
"signed",
")",
"amount",
"of",
"months",
"to",
"the",
"given",
"date",
".",
"For",
"example",
"to",
"subtract",
"5",
"months",
"from",
"the",
"current",
"date",
"you",
"can",
"achieve",
"it",
"by",
"calling",
":",
"<code",
">",
"addMonths",
"(",
"Date",
"-",
"5",
")",
"<",
"/",
"code",
">",
"."
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/date/GosuDateUtil.java#L109-L113 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/PeriodFormatter.java | PeriodFormatter.printTo | public void printTo(Writer out, ReadablePeriod period) throws IOException {
"""
Prints a ReadablePeriod to a Writer.
@param out the formatted period is written out
@param period the period to format, not null
"""
checkPrinter();
checkPeriod(period);
getPrinter().printTo(out, period, iLocale);
} | java | public void printTo(Writer out, ReadablePeriod period) throws IOException {
checkPrinter();
checkPeriod(period);
getPrinter().printTo(out, period, iLocale);
} | [
"public",
"void",
"printTo",
"(",
"Writer",
"out",
",",
"ReadablePeriod",
"period",
")",
"throws",
"IOException",
"{",
"checkPrinter",
"(",
")",
";",
"checkPeriod",
"(",
"period",
")",
";",
"getPrinter",
"(",
")",
".",
"printTo",
"(",
"out",
",",
"period",
",",
"iLocale",
")",
";",
"}"
] | Prints a ReadablePeriod to a Writer.
@param out the formatted period is written out
@param period the period to format, not null | [
"Prints",
"a",
"ReadablePeriod",
"to",
"a",
"Writer",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/PeriodFormatter.java#L226-L231 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowUtils.java | PageFlowUtils.generateFormBeanName | private static String generateFormBeanName( Class formBeanClass, HttpServletRequest request ) {
"""
Create the name for a form bean type.
@param formBeanClass the class whose type will determine the name.
@param request the current HttpServletRequest, which contains a reference to the current Struts module.
@return the name found in the Struts module, or, if none is found, a name that is either:
<ul>
<li>a camel-cased version of the base class name (minus any package or outer-class
qualifiers, or, if that name is already taken,</li>
<li>the full class name, with '.' and '$' replaced by '_'.</li>
</ul>
"""
ModuleConfig moduleConfig = RequestUtils.getRequestModuleConfig( request );
String formBeanClassName = formBeanClass.getName();
//
// A form-bean wasn't found for this type, so we'll create a name. First try and create
// name that is a camelcased version of the classname without all of its package/outer-class
// qualifiers. If one with that name already exists, munge the fully-qualified classname.
//
String formType = formBeanClassName;
int lastQualifier = formType.lastIndexOf( '$' );
if ( lastQualifier == -1 )
{
lastQualifier = formType.lastIndexOf( '.' );
}
String formName = formType.substring( lastQualifier + 1 );
formName = Character.toLowerCase( formName.charAt( 0 ) ) + formName.substring( 1 );
if ( moduleConfig.findFormBeanConfig( formName ) != null )
{
formName = formType.replace( '.', '_' ).replace( '$', '_' );
assert moduleConfig.findFormBeanConfig( formName ) == null : formName;
}
return formName;
} | java | private static String generateFormBeanName( Class formBeanClass, HttpServletRequest request )
{
ModuleConfig moduleConfig = RequestUtils.getRequestModuleConfig( request );
String formBeanClassName = formBeanClass.getName();
//
// A form-bean wasn't found for this type, so we'll create a name. First try and create
// name that is a camelcased version of the classname without all of its package/outer-class
// qualifiers. If one with that name already exists, munge the fully-qualified classname.
//
String formType = formBeanClassName;
int lastQualifier = formType.lastIndexOf( '$' );
if ( lastQualifier == -1 )
{
lastQualifier = formType.lastIndexOf( '.' );
}
String formName = formType.substring( lastQualifier + 1 );
formName = Character.toLowerCase( formName.charAt( 0 ) ) + formName.substring( 1 );
if ( moduleConfig.findFormBeanConfig( formName ) != null )
{
formName = formType.replace( '.', '_' ).replace( '$', '_' );
assert moduleConfig.findFormBeanConfig( formName ) == null : formName;
}
return formName;
} | [
"private",
"static",
"String",
"generateFormBeanName",
"(",
"Class",
"formBeanClass",
",",
"HttpServletRequest",
"request",
")",
"{",
"ModuleConfig",
"moduleConfig",
"=",
"RequestUtils",
".",
"getRequestModuleConfig",
"(",
"request",
")",
";",
"String",
"formBeanClassName",
"=",
"formBeanClass",
".",
"getName",
"(",
")",
";",
"//",
"// A form-bean wasn't found for this type, so we'll create a name. First try and create",
"// name that is a camelcased version of the classname without all of its package/outer-class",
"// qualifiers. If one with that name already exists, munge the fully-qualified classname.",
"//",
"String",
"formType",
"=",
"formBeanClassName",
";",
"int",
"lastQualifier",
"=",
"formType",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"lastQualifier",
"==",
"-",
"1",
")",
"{",
"lastQualifier",
"=",
"formType",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"}",
"String",
"formName",
"=",
"formType",
".",
"substring",
"(",
"lastQualifier",
"+",
"1",
")",
";",
"formName",
"=",
"Character",
".",
"toLowerCase",
"(",
"formName",
".",
"charAt",
"(",
"0",
")",
")",
"+",
"formName",
".",
"substring",
"(",
"1",
")",
";",
"if",
"(",
"moduleConfig",
".",
"findFormBeanConfig",
"(",
"formName",
")",
"!=",
"null",
")",
"{",
"formName",
"=",
"formType",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"assert",
"moduleConfig",
".",
"findFormBeanConfig",
"(",
"formName",
")",
"==",
"null",
":",
"formName",
";",
"}",
"return",
"formName",
";",
"}"
] | Create the name for a form bean type.
@param formBeanClass the class whose type will determine the name.
@param request the current HttpServletRequest, which contains a reference to the current Struts module.
@return the name found in the Struts module, or, if none is found, a name that is either:
<ul>
<li>a camel-cased version of the base class name (minus any package or outer-class
qualifiers, or, if that name is already taken,</li>
<li>the full class name, with '.' and '$' replaced by '_'.</li>
</ul> | [
"Create",
"the",
"name",
"for",
"a",
"form",
"bean",
"type",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowUtils.java#L759-L787 |
timols/java-gitlab-api | src/main/java/org/gitlab/api/GitlabAPI.java | GitlabAPI.createProjectForGroup | public GitlabProject createProjectForGroup(String name, GitlabGroup group) throws IOException {
"""
Creates a group Project
@param name The name of the project
@param group The group for which the project should be crated
@return The GitLab Project
@throws IOException on gitlab api call error
"""
return createProjectForGroup(name, group, null);
} | java | public GitlabProject createProjectForGroup(String name, GitlabGroup group) throws IOException {
return createProjectForGroup(name, group, null);
} | [
"public",
"GitlabProject",
"createProjectForGroup",
"(",
"String",
"name",
",",
"GitlabGroup",
"group",
")",
"throws",
"IOException",
"{",
"return",
"createProjectForGroup",
"(",
"name",
",",
"group",
",",
"null",
")",
";",
"}"
] | Creates a group Project
@param name The name of the project
@param group The group for which the project should be crated
@return The GitLab Project
@throws IOException on gitlab api call error | [
"Creates",
"a",
"group",
"Project"
] | train | https://github.com/timols/java-gitlab-api/blob/f03eedf952cfbb40306be3bf9234dcf78fab029e/src/main/java/org/gitlab/api/GitlabAPI.java#L1202-L1204 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/TableWriteItems.java | TableWriteItems.withHashOnlyKeysToDelete | public TableWriteItems withHashOnlyKeysToDelete(String hashKeyName,
Object... hashKeyValues) {
"""
Used to specify multiple hash-only primary keys to be deleted from the
current table.
@param hashKeyName
hash-only key name
@param hashKeyValues
a list of hash key values
"""
if (hashKeyName == null)
throw new IllegalArgumentException();
PrimaryKey[] primaryKeys = new PrimaryKey[hashKeyValues.length];
for (int i=0; i < hashKeyValues.length; i++)
primaryKeys[i] = new PrimaryKey(hashKeyName, hashKeyValues[i]);
return withPrimaryKeysToDelete(primaryKeys);
} | java | public TableWriteItems withHashOnlyKeysToDelete(String hashKeyName,
Object... hashKeyValues) {
if (hashKeyName == null)
throw new IllegalArgumentException();
PrimaryKey[] primaryKeys = new PrimaryKey[hashKeyValues.length];
for (int i=0; i < hashKeyValues.length; i++)
primaryKeys[i] = new PrimaryKey(hashKeyName, hashKeyValues[i]);
return withPrimaryKeysToDelete(primaryKeys);
} | [
"public",
"TableWriteItems",
"withHashOnlyKeysToDelete",
"(",
"String",
"hashKeyName",
",",
"Object",
"...",
"hashKeyValues",
")",
"{",
"if",
"(",
"hashKeyName",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"PrimaryKey",
"[",
"]",
"primaryKeys",
"=",
"new",
"PrimaryKey",
"[",
"hashKeyValues",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"hashKeyValues",
".",
"length",
";",
"i",
"++",
")",
"primaryKeys",
"[",
"i",
"]",
"=",
"new",
"PrimaryKey",
"(",
"hashKeyName",
",",
"hashKeyValues",
"[",
"i",
"]",
")",
";",
"return",
"withPrimaryKeysToDelete",
"(",
"primaryKeys",
")",
";",
"}"
] | Used to specify multiple hash-only primary keys to be deleted from the
current table.
@param hashKeyName
hash-only key name
@param hashKeyValues
a list of hash key values | [
"Used",
"to",
"specify",
"multiple",
"hash",
"-",
"only",
"primary",
"keys",
"to",
"be",
"deleted",
"from",
"the",
"current",
"table",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/TableWriteItems.java#L83-L91 |
google/closure-compiler | src/com/google/javascript/jscomp/CheckSuspiciousCode.java | CheckSuspiciousCode.checkLeftOperandOfLogicalOperator | private void checkLeftOperandOfLogicalOperator(NodeTraversal t, Node n) {
"""
Check for the LHS of a logical operator (&& and ||) being deterministically truthy or
falsy, using both syntactic and type information. This is always suspicious (though for
different reasons: "truthy and" means the LHS is always ignored and should be removed, "falsy
and" means the RHS is dead code, and vice versa for "or". However, there are a number of
legitimate use cases where we need to back off from using type information (see {@link
#getBooleanValueWithTypes} for more details on these back offs).
"""
if (n.isOr() || n.isAnd()) {
String operator = n.isOr() ? "||" : "&&";
TernaryValue v = getBooleanValueWithTypes(n.getFirstChild());
if (v != TernaryValue.UNKNOWN) {
String result = v == TernaryValue.TRUE ? "truthy" : "falsy";
t.report(n, SUSPICIOUS_LEFT_OPERAND_OF_LOGICAL_OPERATOR, operator, result);
}
}
} | java | private void checkLeftOperandOfLogicalOperator(NodeTraversal t, Node n) {
if (n.isOr() || n.isAnd()) {
String operator = n.isOr() ? "||" : "&&";
TernaryValue v = getBooleanValueWithTypes(n.getFirstChild());
if (v != TernaryValue.UNKNOWN) {
String result = v == TernaryValue.TRUE ? "truthy" : "falsy";
t.report(n, SUSPICIOUS_LEFT_OPERAND_OF_LOGICAL_OPERATOR, operator, result);
}
}
} | [
"private",
"void",
"checkLeftOperandOfLogicalOperator",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
")",
"{",
"if",
"(",
"n",
".",
"isOr",
"(",
")",
"||",
"n",
".",
"isAnd",
"(",
")",
")",
"{",
"String",
"operator",
"=",
"n",
".",
"isOr",
"(",
")",
"?",
"\"||\"",
":",
"\"&&\"",
";",
"TernaryValue",
"v",
"=",
"getBooleanValueWithTypes",
"(",
"n",
".",
"getFirstChild",
"(",
")",
")",
";",
"if",
"(",
"v",
"!=",
"TernaryValue",
".",
"UNKNOWN",
")",
"{",
"String",
"result",
"=",
"v",
"==",
"TernaryValue",
".",
"TRUE",
"?",
"\"truthy\"",
":",
"\"falsy\"",
";",
"t",
".",
"report",
"(",
"n",
",",
"SUSPICIOUS_LEFT_OPERAND_OF_LOGICAL_OPERATOR",
",",
"operator",
",",
"result",
")",
";",
"}",
"}",
"}"
] | Check for the LHS of a logical operator (&& and ||) being deterministically truthy or
falsy, using both syntactic and type information. This is always suspicious (though for
different reasons: "truthy and" means the LHS is always ignored and should be removed, "falsy
and" means the RHS is dead code, and vice versa for "or". However, there are a number of
legitimate use cases where we need to back off from using type information (see {@link
#getBooleanValueWithTypes} for more details on these back offs). | [
"Check",
"for",
"the",
"LHS",
"of",
"a",
"logical",
"operator",
"(",
"&",
";",
"&",
";",
"and",
"||",
")",
"being",
"deterministically",
"truthy",
"or",
"falsy",
"using",
"both",
"syntactic",
"and",
"type",
"information",
".",
"This",
"is",
"always",
"suspicious",
"(",
"though",
"for",
"different",
"reasons",
":",
"truthy",
"and",
"means",
"the",
"LHS",
"is",
"always",
"ignored",
"and",
"should",
"be",
"removed",
"falsy",
"and",
"means",
"the",
"RHS",
"is",
"dead",
"code",
"and",
"vice",
"versa",
"for",
"or",
".",
"However",
"there",
"are",
"a",
"number",
"of",
"legitimate",
"use",
"cases",
"where",
"we",
"need",
"to",
"back",
"off",
"from",
"using",
"type",
"information",
"(",
"see",
"{"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckSuspiciousCode.java#L174-L183 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/mps/prune_policy.java | prune_policy.get_nitro_bulk_response | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception {
"""
<pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre>
"""
prune_policy_responses result = (prune_policy_responses) service.get_payload_formatter().string_to_resource(prune_policy_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.prune_policy_response_array);
}
prune_policy[] result_prune_policy = new prune_policy[result.prune_policy_response_array.length];
for(int i = 0; i < result.prune_policy_response_array.length; i++)
{
result_prune_policy[i] = result.prune_policy_response_array[i].prune_policy[0];
}
return result_prune_policy;
} | java | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
prune_policy_responses result = (prune_policy_responses) service.get_payload_formatter().string_to_resource(prune_policy_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.prune_policy_response_array);
}
prune_policy[] result_prune_policy = new prune_policy[result.prune_policy_response_array.length];
for(int i = 0; i < result.prune_policy_response_array.length; i++)
{
result_prune_policy[i] = result.prune_policy_response_array[i].prune_policy[0];
}
return result_prune_policy;
} | [
"protected",
"base_resource",
"[",
"]",
"get_nitro_bulk_response",
"(",
"nitro_service",
"service",
",",
"String",
"response",
")",
"throws",
"Exception",
"{",
"prune_policy_responses",
"result",
"=",
"(",
"prune_policy_responses",
")",
"service",
".",
"get_payload_formatter",
"(",
")",
".",
"string_to_resource",
"(",
"prune_policy_responses",
".",
"class",
",",
"response",
")",
";",
"if",
"(",
"result",
".",
"errorcode",
"!=",
"0",
")",
"{",
"if",
"(",
"result",
".",
"errorcode",
"==",
"SESSION_NOT_EXISTS",
")",
"service",
".",
"clear_session",
"(",
")",
";",
"throw",
"new",
"nitro_exception",
"(",
"result",
".",
"message",
",",
"result",
".",
"errorcode",
",",
"(",
"base_response",
"[",
"]",
")",
"result",
".",
"prune_policy_response_array",
")",
";",
"}",
"prune_policy",
"[",
"]",
"result_prune_policy",
"=",
"new",
"prune_policy",
"[",
"result",
".",
"prune_policy_response_array",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"prune_policy_response_array",
".",
"length",
";",
"i",
"++",
")",
"{",
"result_prune_policy",
"[",
"i",
"]",
"=",
"result",
".",
"prune_policy_response_array",
"[",
"i",
"]",
".",
"prune_policy",
"[",
"0",
"]",
";",
"}",
"return",
"result_prune_policy",
";",
"}"
] | <pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre> | [
"<pre",
">",
"Converts",
"API",
"response",
"of",
"bulk",
"operation",
"into",
"object",
"and",
"returns",
"the",
"object",
"array",
"in",
"case",
"of",
"get",
"request",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/prune_policy.java#L223-L240 |
hector-client/hector | core/src/main/java/me/prettyprint/hector/api/factory/HFactory.java | HFactory.createColumnFamilyDefinition | public static ColumnFamilyDefinition createColumnFamilyDefinition(
String keyspace, String cfName, ComparatorType comparatorType) {
"""
Create a column family for a given keyspace without comparator type.
Example: String keyspace = "testKeyspace"; String column1 = "testcolumn";
ColumnFamilyDefinition columnFamily1 =
HFactory.createColumnFamilyDefinition(keyspace, column1,
ComparatorType.UTF8TYPE); List<ColumnFamilyDefinition> columns = new
ArrayList<ColumnFamilyDefinition>(); columns.add(columnFamily1);
KeyspaceDefinition testKeyspace =
HFactory.createKeyspaceDefinition(keyspace,
org.apache.cassandra.locator.SimpleStrategy.class.getName(), 1, columns);
cluster.addKeyspace(testKeyspace);
@param keyspace
@param cfName
@param comparatorType
"""
return new ThriftCfDef(keyspace, cfName, comparatorType);
} | java | public static ColumnFamilyDefinition createColumnFamilyDefinition(
String keyspace, String cfName, ComparatorType comparatorType) {
return new ThriftCfDef(keyspace, cfName, comparatorType);
} | [
"public",
"static",
"ColumnFamilyDefinition",
"createColumnFamilyDefinition",
"(",
"String",
"keyspace",
",",
"String",
"cfName",
",",
"ComparatorType",
"comparatorType",
")",
"{",
"return",
"new",
"ThriftCfDef",
"(",
"keyspace",
",",
"cfName",
",",
"comparatorType",
")",
";",
"}"
] | Create a column family for a given keyspace without comparator type.
Example: String keyspace = "testKeyspace"; String column1 = "testcolumn";
ColumnFamilyDefinition columnFamily1 =
HFactory.createColumnFamilyDefinition(keyspace, column1,
ComparatorType.UTF8TYPE); List<ColumnFamilyDefinition> columns = new
ArrayList<ColumnFamilyDefinition>(); columns.add(columnFamily1);
KeyspaceDefinition testKeyspace =
HFactory.createKeyspaceDefinition(keyspace,
org.apache.cassandra.locator.SimpleStrategy.class.getName(), 1, columns);
cluster.addKeyspace(testKeyspace);
@param keyspace
@param cfName
@param comparatorType | [
"Create",
"a",
"column",
"family",
"for",
"a",
"given",
"keyspace",
"without",
"comparator",
"type",
".",
"Example",
":",
"String",
"keyspace",
"=",
"testKeyspace",
";",
"String",
"column1",
"=",
"testcolumn",
";",
"ColumnFamilyDefinition",
"columnFamily1",
"=",
"HFactory",
".",
"createColumnFamilyDefinition",
"(",
"keyspace",
"column1",
"ComparatorType",
".",
"UTF8TYPE",
")",
";",
"List<ColumnFamilyDefinition",
">",
"columns",
"=",
"new",
"ArrayList<ColumnFamilyDefinition",
">",
"()",
";",
"columns",
".",
"add",
"(",
"columnFamily1",
")",
";",
"KeyspaceDefinition",
"testKeyspace",
"=",
"HFactory",
".",
"createKeyspaceDefinition",
"(",
"keyspace",
"org",
".",
"apache",
".",
"cassandra",
".",
"locator",
".",
"SimpleStrategy",
".",
"class",
".",
"getName",
"()",
"1",
"columns",
")",
";",
"cluster",
".",
"addKeyspace",
"(",
"testKeyspace",
")",
";"
] | train | https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/hector/api/factory/HFactory.java#L735-L738 |
jenkinsci/email-ext-plugin | src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java | ScriptContent.renderTemplate | private String renderTemplate(Run<?, ?> build, FilePath workspace, TaskListener listener, InputStream templateStream)
throws IOException {
"""
Renders the template using a SimpleTemplateEngine
@param build the build to act on
@param templateStream the template file stream
@return the rendered template content
@throws IOException
"""
String result;
final Map<String, Object> binding = new HashMap<>();
ExtendedEmailPublisherDescriptor descriptor = Jenkins.getActiveInstance().getDescriptorByType(ExtendedEmailPublisherDescriptor.class);
binding.put("build", build);
binding.put("listener", listener);
binding.put("it", new ScriptContentBuildWrapper(build));
binding.put("rooturl", descriptor.getHudsonUrl());
binding.put("project", build.getParent());
binding.put("workspace", workspace);
try {
String text = IOUtils.toString(templateStream);
boolean approvedScript = false;
if (templateStream instanceof UserProvidedContentInputStream && !AbstractEvalContent.isApprovedScript(text, GroovyLanguage.get())) {
approvedScript = false;
ScriptApproval.get().configuring(text, GroovyLanguage.get(), ApprovalContext.create().withItem(build.getParent()));
} else {
approvedScript = true;
}
// we add the binding to the SimpleTemplateEngine instead of the shell
GroovyShell shell = createEngine(descriptor, Collections.<String, Object>emptyMap(), !approvedScript);
SimpleTemplateEngine engine = new SimpleTemplateEngine(shell);
Template tmpl;
synchronized (templateCache) {
Reference<Template> templateR = templateCache.get(text);
tmpl = templateR == null ? null : templateR.get();
if (tmpl == null) {
tmpl = engine.createTemplate(text);
templateCache.put(text, new SoftReference<>(tmpl));
}
}
final Template tmplR = tmpl;
if (approvedScript) {
//The script has been approved by an admin, so run it as is
result = tmplR.make(binding).toString();
} else {
//unapproved script, so run in sandbox
StaticProxyInstanceWhitelist whitelist = new StaticProxyInstanceWhitelist(build, "templates-instances.whitelist");
result = GroovySandbox.runInSandbox(new Callable<String>() {
@Override
public String call() throws Exception {
return tmplR.make(binding).toString(); //TODO there is a PrintWriter instance created in make and bound to out
}
}, new ProxyWhitelist(
Whitelist.all(),
new TaskListenerInstanceWhitelist(listener),
new PrintStreamInstanceWhitelist(listener.getLogger()),
new EmailExtScriptTokenMacroWhitelist(),
whitelist));
}
} catch(Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
result = "Exception raised during template rendering: " + e.getMessage() + "\n\n" + sw.toString();
}
return result;
} | java | private String renderTemplate(Run<?, ?> build, FilePath workspace, TaskListener listener, InputStream templateStream)
throws IOException {
String result;
final Map<String, Object> binding = new HashMap<>();
ExtendedEmailPublisherDescriptor descriptor = Jenkins.getActiveInstance().getDescriptorByType(ExtendedEmailPublisherDescriptor.class);
binding.put("build", build);
binding.put("listener", listener);
binding.put("it", new ScriptContentBuildWrapper(build));
binding.put("rooturl", descriptor.getHudsonUrl());
binding.put("project", build.getParent());
binding.put("workspace", workspace);
try {
String text = IOUtils.toString(templateStream);
boolean approvedScript = false;
if (templateStream instanceof UserProvidedContentInputStream && !AbstractEvalContent.isApprovedScript(text, GroovyLanguage.get())) {
approvedScript = false;
ScriptApproval.get().configuring(text, GroovyLanguage.get(), ApprovalContext.create().withItem(build.getParent()));
} else {
approvedScript = true;
}
// we add the binding to the SimpleTemplateEngine instead of the shell
GroovyShell shell = createEngine(descriptor, Collections.<String, Object>emptyMap(), !approvedScript);
SimpleTemplateEngine engine = new SimpleTemplateEngine(shell);
Template tmpl;
synchronized (templateCache) {
Reference<Template> templateR = templateCache.get(text);
tmpl = templateR == null ? null : templateR.get();
if (tmpl == null) {
tmpl = engine.createTemplate(text);
templateCache.put(text, new SoftReference<>(tmpl));
}
}
final Template tmplR = tmpl;
if (approvedScript) {
//The script has been approved by an admin, so run it as is
result = tmplR.make(binding).toString();
} else {
//unapproved script, so run in sandbox
StaticProxyInstanceWhitelist whitelist = new StaticProxyInstanceWhitelist(build, "templates-instances.whitelist");
result = GroovySandbox.runInSandbox(new Callable<String>() {
@Override
public String call() throws Exception {
return tmplR.make(binding).toString(); //TODO there is a PrintWriter instance created in make and bound to out
}
}, new ProxyWhitelist(
Whitelist.all(),
new TaskListenerInstanceWhitelist(listener),
new PrintStreamInstanceWhitelist(listener.getLogger()),
new EmailExtScriptTokenMacroWhitelist(),
whitelist));
}
} catch(Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
result = "Exception raised during template rendering: " + e.getMessage() + "\n\n" + sw.toString();
}
return result;
} | [
"private",
"String",
"renderTemplate",
"(",
"Run",
"<",
"?",
",",
"?",
">",
"build",
",",
"FilePath",
"workspace",
",",
"TaskListener",
"listener",
",",
"InputStream",
"templateStream",
")",
"throws",
"IOException",
"{",
"String",
"result",
";",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"binding",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"ExtendedEmailPublisherDescriptor",
"descriptor",
"=",
"Jenkins",
".",
"getActiveInstance",
"(",
")",
".",
"getDescriptorByType",
"(",
"ExtendedEmailPublisherDescriptor",
".",
"class",
")",
";",
"binding",
".",
"put",
"(",
"\"build\"",
",",
"build",
")",
";",
"binding",
".",
"put",
"(",
"\"listener\"",
",",
"listener",
")",
";",
"binding",
".",
"put",
"(",
"\"it\"",
",",
"new",
"ScriptContentBuildWrapper",
"(",
"build",
")",
")",
";",
"binding",
".",
"put",
"(",
"\"rooturl\"",
",",
"descriptor",
".",
"getHudsonUrl",
"(",
")",
")",
";",
"binding",
".",
"put",
"(",
"\"project\"",
",",
"build",
".",
"getParent",
"(",
")",
")",
";",
"binding",
".",
"put",
"(",
"\"workspace\"",
",",
"workspace",
")",
";",
"try",
"{",
"String",
"text",
"=",
"IOUtils",
".",
"toString",
"(",
"templateStream",
")",
";",
"boolean",
"approvedScript",
"=",
"false",
";",
"if",
"(",
"templateStream",
"instanceof",
"UserProvidedContentInputStream",
"&&",
"!",
"AbstractEvalContent",
".",
"isApprovedScript",
"(",
"text",
",",
"GroovyLanguage",
".",
"get",
"(",
")",
")",
")",
"{",
"approvedScript",
"=",
"false",
";",
"ScriptApproval",
".",
"get",
"(",
")",
".",
"configuring",
"(",
"text",
",",
"GroovyLanguage",
".",
"get",
"(",
")",
",",
"ApprovalContext",
".",
"create",
"(",
")",
".",
"withItem",
"(",
"build",
".",
"getParent",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"approvedScript",
"=",
"true",
";",
"}",
"// we add the binding to the SimpleTemplateEngine instead of the shell",
"GroovyShell",
"shell",
"=",
"createEngine",
"(",
"descriptor",
",",
"Collections",
".",
"<",
"String",
",",
"Object",
">",
"emptyMap",
"(",
")",
",",
"!",
"approvedScript",
")",
";",
"SimpleTemplateEngine",
"engine",
"=",
"new",
"SimpleTemplateEngine",
"(",
"shell",
")",
";",
"Template",
"tmpl",
";",
"synchronized",
"(",
"templateCache",
")",
"{",
"Reference",
"<",
"Template",
">",
"templateR",
"=",
"templateCache",
".",
"get",
"(",
"text",
")",
";",
"tmpl",
"=",
"templateR",
"==",
"null",
"?",
"null",
":",
"templateR",
".",
"get",
"(",
")",
";",
"if",
"(",
"tmpl",
"==",
"null",
")",
"{",
"tmpl",
"=",
"engine",
".",
"createTemplate",
"(",
"text",
")",
";",
"templateCache",
".",
"put",
"(",
"text",
",",
"new",
"SoftReference",
"<>",
"(",
"tmpl",
")",
")",
";",
"}",
"}",
"final",
"Template",
"tmplR",
"=",
"tmpl",
";",
"if",
"(",
"approvedScript",
")",
"{",
"//The script has been approved by an admin, so run it as is",
"result",
"=",
"tmplR",
".",
"make",
"(",
"binding",
")",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"//unapproved script, so run in sandbox",
"StaticProxyInstanceWhitelist",
"whitelist",
"=",
"new",
"StaticProxyInstanceWhitelist",
"(",
"build",
",",
"\"templates-instances.whitelist\"",
")",
";",
"result",
"=",
"GroovySandbox",
".",
"runInSandbox",
"(",
"new",
"Callable",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"call",
"(",
")",
"throws",
"Exception",
"{",
"return",
"tmplR",
".",
"make",
"(",
"binding",
")",
".",
"toString",
"(",
")",
";",
"//TODO there is a PrintWriter instance created in make and bound to out",
"}",
"}",
",",
"new",
"ProxyWhitelist",
"(",
"Whitelist",
".",
"all",
"(",
")",
",",
"new",
"TaskListenerInstanceWhitelist",
"(",
"listener",
")",
",",
"new",
"PrintStreamInstanceWhitelist",
"(",
"listener",
".",
"getLogger",
"(",
")",
")",
",",
"new",
"EmailExtScriptTokenMacroWhitelist",
"(",
")",
",",
"whitelist",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"StringWriter",
"sw",
"=",
"new",
"StringWriter",
"(",
")",
";",
"PrintWriter",
"pw",
"=",
"new",
"PrintWriter",
"(",
"sw",
")",
";",
"e",
".",
"printStackTrace",
"(",
"pw",
")",
";",
"result",
"=",
"\"Exception raised during template rendering: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
"+",
"\"\\n\\n\"",
"+",
"sw",
".",
"toString",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Renders the template using a SimpleTemplateEngine
@param build the build to act on
@param templateStream the template file stream
@return the rendered template content
@throws IOException | [
"Renders",
"the",
"template",
"using",
"a",
"SimpleTemplateEngine"
] | train | https://github.com/jenkinsci/email-ext-plugin/blob/21fbd402665848a18205b26751424149e51e86e4/src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java#L114-L176 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java | JBBPDslBuilder.ByteArray | public JBBPDslBuilder ByteArray(final String name, final String sizeExpression) {
"""
Add named byte array which size calculated through expression.
@param name name of the array, it can be null for anonymous fields
@param sizeExpression expression to be used to calculate array length, must not be null or empty.
@return the builder instance, must not be null
"""
final Item item = new Item(BinType.BYTE_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | java | public JBBPDslBuilder ByteArray(final String name, final String sizeExpression) {
final Item item = new Item(BinType.BYTE_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | [
"public",
"JBBPDslBuilder",
"ByteArray",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"sizeExpression",
")",
"{",
"final",
"Item",
"item",
"=",
"new",
"Item",
"(",
"BinType",
".",
"BYTE_ARRAY",
",",
"name",
",",
"this",
".",
"byteOrder",
")",
";",
"item",
".",
"sizeExpression",
"=",
"assertExpressionChars",
"(",
"sizeExpression",
")",
";",
"this",
".",
"addItem",
"(",
"item",
")",
";",
"return",
"this",
";",
"}"
] | Add named byte array which size calculated through expression.
@param name name of the array, it can be null for anonymous fields
@param sizeExpression expression to be used to calculate array length, must not be null or empty.
@return the builder instance, must not be null | [
"Add",
"named",
"byte",
"array",
"which",
"size",
"calculated",
"through",
"expression",
"."
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L871-L876 |
Azure/azure-sdk-for-java | compute/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java | DisksInner.beginGrantAccessAsync | public Observable<AccessUriInner> beginGrantAccessAsync(String resourceGroupName, String diskName, GrantAccessData grantAccessData) {
"""
Grants access to a disk.
@param resourceGroupName The name of the resource group.
@param diskName The name of the managed disk that is being created. The name can't be changed after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters.
@param grantAccessData Access data object supplied in the body of the get disk access operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AccessUriInner object
"""
return beginGrantAccessWithServiceResponseAsync(resourceGroupName, diskName, grantAccessData).map(new Func1<ServiceResponse<AccessUriInner>, AccessUriInner>() {
@Override
public AccessUriInner call(ServiceResponse<AccessUriInner> response) {
return response.body();
}
});
} | java | public Observable<AccessUriInner> beginGrantAccessAsync(String resourceGroupName, String diskName, GrantAccessData grantAccessData) {
return beginGrantAccessWithServiceResponseAsync(resourceGroupName, diskName, grantAccessData).map(new Func1<ServiceResponse<AccessUriInner>, AccessUriInner>() {
@Override
public AccessUriInner call(ServiceResponse<AccessUriInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"AccessUriInner",
">",
"beginGrantAccessAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"diskName",
",",
"GrantAccessData",
"grantAccessData",
")",
"{",
"return",
"beginGrantAccessWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"diskName",
",",
"grantAccessData",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"AccessUriInner",
">",
",",
"AccessUriInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"AccessUriInner",
"call",
"(",
"ServiceResponse",
"<",
"AccessUriInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Grants access to a disk.
@param resourceGroupName The name of the resource group.
@param diskName The name of the managed disk that is being created. The name can't be changed after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters.
@param grantAccessData Access data object supplied in the body of the get disk access operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AccessUriInner object | [
"Grants",
"access",
"to",
"a",
"disk",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java#L1055-L1062 |
apache/groovy | subprojects/groovy-sql/src/main/java/groovy/sql/GroovyRowResult.java | GroovyRowResult.put | @SuppressWarnings("unchecked")
public Object put(Object key, Object value) {
"""
Associates the specified value with the specified property name in this result.
@param key the property name for the result
@param value the property value for the result
@return the previous value associated with <tt>key</tt>, or
<tt>null</tt> if there was no mapping for <tt>key</tt>.
(A <tt>null</tt> return can also indicate that the map
previously associated <tt>null</tt> with <tt>key</tt>.)
"""
// avoid different case keys being added by explicit remove
Object orig = remove(key);
result.put(key, value);
return orig;
} | java | @SuppressWarnings("unchecked")
public Object put(Object key, Object value) {
// avoid different case keys being added by explicit remove
Object orig = remove(key);
result.put(key, value);
return orig;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Object",
"put",
"(",
"Object",
"key",
",",
"Object",
"value",
")",
"{",
"// avoid different case keys being added by explicit remove",
"Object",
"orig",
"=",
"remove",
"(",
"key",
")",
";",
"result",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"orig",
";",
"}"
] | Associates the specified value with the specified property name in this result.
@param key the property name for the result
@param value the property value for the result
@return the previous value associated with <tt>key</tt>, or
<tt>null</tt> if there was no mapping for <tt>key</tt>.
(A <tt>null</tt> return can also indicate that the map
previously associated <tt>null</tt> with <tt>key</tt>.) | [
"Associates",
"the",
"specified",
"value",
"with",
"the",
"specified",
"property",
"name",
"in",
"this",
"result",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/GroovyRowResult.java#L175-L181 |
Mozu/mozu-java | mozu-java-core/src/main/java/com/mozu/api/urls/content/PropertyTypeUrl.java | PropertyTypeUrl.getPropertyTypeUrl | public static MozuUrl getPropertyTypeUrl(String propertyTypeName, String responseFields) {
"""
Get Resource Url for GetPropertyType
@param propertyTypeName The name of the property type.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/content/propertytypes/{propertyTypeName}?responseFields={responseFields}");
formatter.formatUrl("propertyTypeName", propertyTypeName);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl getPropertyTypeUrl(String propertyTypeName, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/content/propertytypes/{propertyTypeName}?responseFields={responseFields}");
formatter.formatUrl("propertyTypeName", propertyTypeName);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"getPropertyTypeUrl",
"(",
"String",
"propertyTypeName",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/content/propertytypes/{propertyTypeName}?responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"propertyTypeName\"",
",",
"propertyTypeName",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for GetPropertyType
@param propertyTypeName The name of the property type.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"GetPropertyType"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/content/PropertyTypeUrl.java#L38-L44 |
BlueBrain/bluima | modules/bluima_typesystem/src/main/java/de/julielab/jules/types/DiscontinuousAnnotation.java | DiscontinuousAnnotation.setValue | public void setValue(int i, Annotation v) {
"""
indexed setter for value - sets an indexed value - Annotations to be chained.
@generated
@param i index in the array to set
@param v value to set into the array
"""
if (DiscontinuousAnnotation_Type.featOkTst && ((DiscontinuousAnnotation_Type)jcasType).casFeat_value == null)
jcasType.jcas.throwFeatMissing("value", "de.julielab.jules.types.DiscontinuousAnnotation");
jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((DiscontinuousAnnotation_Type)jcasType).casFeatCode_value), i);
jcasType.ll_cas.ll_setRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((DiscontinuousAnnotation_Type)jcasType).casFeatCode_value), i, jcasType.ll_cas.ll_getFSRef(v));} | java | public void setValue(int i, Annotation v) {
if (DiscontinuousAnnotation_Type.featOkTst && ((DiscontinuousAnnotation_Type)jcasType).casFeat_value == null)
jcasType.jcas.throwFeatMissing("value", "de.julielab.jules.types.DiscontinuousAnnotation");
jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((DiscontinuousAnnotation_Type)jcasType).casFeatCode_value), i);
jcasType.ll_cas.ll_setRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((DiscontinuousAnnotation_Type)jcasType).casFeatCode_value), i, jcasType.ll_cas.ll_getFSRef(v));} | [
"public",
"void",
"setValue",
"(",
"int",
"i",
",",
"Annotation",
"v",
")",
"{",
"if",
"(",
"DiscontinuousAnnotation_Type",
".",
"featOkTst",
"&&",
"(",
"(",
"DiscontinuousAnnotation_Type",
")",
"jcasType",
")",
".",
"casFeat_value",
"==",
"null",
")",
"jcasType",
".",
"jcas",
".",
"throwFeatMissing",
"(",
"\"value\"",
",",
"\"de.julielab.jules.types.DiscontinuousAnnotation\"",
")",
";",
"jcasType",
".",
"jcas",
".",
"checkArrayBounds",
"(",
"jcasType",
".",
"ll_cas",
".",
"ll_getRefValue",
"(",
"addr",
",",
"(",
"(",
"DiscontinuousAnnotation_Type",
")",
"jcasType",
")",
".",
"casFeatCode_value",
")",
",",
"i",
")",
";",
"jcasType",
".",
"ll_cas",
".",
"ll_setRefArrayValue",
"(",
"jcasType",
".",
"ll_cas",
".",
"ll_getRefValue",
"(",
"addr",
",",
"(",
"(",
"DiscontinuousAnnotation_Type",
")",
"jcasType",
")",
".",
"casFeatCode_value",
")",
",",
"i",
",",
"jcasType",
".",
"ll_cas",
".",
"ll_getFSRef",
"(",
"v",
")",
")",
";",
"}"
] | indexed setter for value - sets an indexed value - Annotations to be chained.
@generated
@param i index in the array to set
@param v value to set into the array | [
"indexed",
"setter",
"for",
"value",
"-",
"sets",
"an",
"indexed",
"value",
"-",
"Annotations",
"to",
"be",
"chained",
"."
] | train | https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_typesystem/src/main/java/de/julielab/jules/types/DiscontinuousAnnotation.java#L116-L120 |
krummas/DrizzleJDBC | src/main/java/org/drizzle/jdbc/DrizzleConnection.java | DrizzleConnection.setSavepoint | public Savepoint setSavepoint(final String name) throws SQLException {
"""
Creates a savepoint with the given name in the current transaction and returns the new <code>Savepoint</code>
object that represents it.
<p/>
<p> if setSavepoint is invoked outside of an active transaction, a transaction will be started at this newly
created savepoint.
@param name a <code>String</code> containing the name of the savepoint
@return the new <code>Savepoint</code> object
@throws java.sql.SQLException if a database access error occurs, this method is called while participating in a
distributed transaction, this method is called on a closed connection or this
<code>Connection</code> object is currently in auto-commit mode
@throws java.sql.SQLFeatureNotSupportedException
if the JDBC driver does not support this method
@see java.sql.Savepoint
@since 1.4
"""
final Savepoint drizzleSavepoint = new DrizzleSavepoint(name, savepointCount++);
try {
protocol.setSavepoint(drizzleSavepoint.toString());
} catch (QueryException e) {
throw SQLExceptionMapper.get(e);
}
return drizzleSavepoint;
} | java | public Savepoint setSavepoint(final String name) throws SQLException {
final Savepoint drizzleSavepoint = new DrizzleSavepoint(name, savepointCount++);
try {
protocol.setSavepoint(drizzleSavepoint.toString());
} catch (QueryException e) {
throw SQLExceptionMapper.get(e);
}
return drizzleSavepoint;
} | [
"public",
"Savepoint",
"setSavepoint",
"(",
"final",
"String",
"name",
")",
"throws",
"SQLException",
"{",
"final",
"Savepoint",
"drizzleSavepoint",
"=",
"new",
"DrizzleSavepoint",
"(",
"name",
",",
"savepointCount",
"++",
")",
";",
"try",
"{",
"protocol",
".",
"setSavepoint",
"(",
"drizzleSavepoint",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"QueryException",
"e",
")",
"{",
"throw",
"SQLExceptionMapper",
".",
"get",
"(",
"e",
")",
";",
"}",
"return",
"drizzleSavepoint",
";",
"}"
] | Creates a savepoint with the given name in the current transaction and returns the new <code>Savepoint</code>
object that represents it.
<p/>
<p> if setSavepoint is invoked outside of an active transaction, a transaction will be started at this newly
created savepoint.
@param name a <code>String</code> containing the name of the savepoint
@return the new <code>Savepoint</code> object
@throws java.sql.SQLException if a database access error occurs, this method is called while participating in a
distributed transaction, this method is called on a closed connection or this
<code>Connection</code> object is currently in auto-commit mode
@throws java.sql.SQLFeatureNotSupportedException
if the JDBC driver does not support this method
@see java.sql.Savepoint
@since 1.4 | [
"Creates",
"a",
"savepoint",
"with",
"the",
"given",
"name",
"in",
"the",
"current",
"transaction",
"and",
"returns",
"the",
"new",
"<code",
">",
"Savepoint<",
"/",
"code",
">",
"object",
"that",
"represents",
"it",
".",
"<p",
"/",
">",
"<p",
">",
"if",
"setSavepoint",
"is",
"invoked",
"outside",
"of",
"an",
"active",
"transaction",
"a",
"transaction",
"will",
"be",
"started",
"at",
"this",
"newly",
"created",
"savepoint",
"."
] | train | https://github.com/krummas/DrizzleJDBC/blob/716f31fd71f3cc289edf69844d8117deb86d98d6/src/main/java/org/drizzle/jdbc/DrizzleConnection.java#L616-L625 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.getPatternAnyEntityRolesAsync | public Observable<List<EntityRole>> getPatternAnyEntityRolesAsync(UUID appId, String versionId, UUID entityId) {
"""
Get All Entity Roles for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param entityId entity Id
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<EntityRole> object
"""
return getPatternAnyEntityRolesWithServiceResponseAsync(appId, versionId, entityId).map(new Func1<ServiceResponse<List<EntityRole>>, List<EntityRole>>() {
@Override
public List<EntityRole> call(ServiceResponse<List<EntityRole>> response) {
return response.body();
}
});
} | java | public Observable<List<EntityRole>> getPatternAnyEntityRolesAsync(UUID appId, String versionId, UUID entityId) {
return getPatternAnyEntityRolesWithServiceResponseAsync(appId, versionId, entityId).map(new Func1<ServiceResponse<List<EntityRole>>, List<EntityRole>>() {
@Override
public List<EntityRole> call(ServiceResponse<List<EntityRole>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"EntityRole",
">",
">",
"getPatternAnyEntityRolesAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
")",
"{",
"return",
"getPatternAnyEntityRolesWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"entityId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"EntityRole",
">",
">",
",",
"List",
"<",
"EntityRole",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"EntityRole",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"EntityRole",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get All Entity Roles for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param entityId entity Id
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<EntityRole> object | [
"Get",
"All",
"Entity",
"Roles",
"for",
"a",
"given",
"entity",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L9086-L9093 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/multilayer/MultiLayerNetwork.java | MultiLayerNetwork.scoreExamples | public INDArray scoreExamples(DataSet data, boolean addRegularizationTerms) {
"""
Calculate the score for each example in a DataSet individually. Unlike {@link #score(DataSet)} and {@link #score(DataSet, boolean)}
this method does not average/sum over examples. This method allows for examples to be scored individually (at test time only), which
may be useful for example for autoencoder architectures and the like.<br>
Each row of the output (assuming addRegularizationTerms == true) is equivalent to calling score(DataSet) with a single example.
@param data The data to score
@param addRegularizationTerms If true: add l1/l2 regularization terms (if any) to the score. If false: don't add regularization terms
@return An INDArray (column vector) of size input.numRows(); the ith entry is the score (loss value) of the ith example
"""
try{
return scoreExamplesHelper(data, addRegularizationTerms);
} catch (OutOfMemoryError e){
CrashReportingUtil.writeMemoryCrashDump(this, e);
throw e;
}
} | java | public INDArray scoreExamples(DataSet data, boolean addRegularizationTerms) {
try{
return scoreExamplesHelper(data, addRegularizationTerms);
} catch (OutOfMemoryError e){
CrashReportingUtil.writeMemoryCrashDump(this, e);
throw e;
}
} | [
"public",
"INDArray",
"scoreExamples",
"(",
"DataSet",
"data",
",",
"boolean",
"addRegularizationTerms",
")",
"{",
"try",
"{",
"return",
"scoreExamplesHelper",
"(",
"data",
",",
"addRegularizationTerms",
")",
";",
"}",
"catch",
"(",
"OutOfMemoryError",
"e",
")",
"{",
"CrashReportingUtil",
".",
"writeMemoryCrashDump",
"(",
"this",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"}"
] | Calculate the score for each example in a DataSet individually. Unlike {@link #score(DataSet)} and {@link #score(DataSet, boolean)}
this method does not average/sum over examples. This method allows for examples to be scored individually (at test time only), which
may be useful for example for autoencoder architectures and the like.<br>
Each row of the output (assuming addRegularizationTerms == true) is equivalent to calling score(DataSet) with a single example.
@param data The data to score
@param addRegularizationTerms If true: add l1/l2 regularization terms (if any) to the score. If false: don't add regularization terms
@return An INDArray (column vector) of size input.numRows(); the ith entry is the score (loss value) of the ith example | [
"Calculate",
"the",
"score",
"for",
"each",
"example",
"in",
"a",
"DataSet",
"individually",
".",
"Unlike",
"{"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/multilayer/MultiLayerNetwork.java#L2555-L2562 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/BasicRecordStoreLoader.java | BasicRecordStoreLoader.loadValuesInternal | private void loadValuesInternal(List<Data> keys, boolean replaceExistingValues) throws Exception {
"""
Loads the values for the provided keys and invokes partition operations
to put the loaded entries into the partition record store. The method
will block until all entries have been put into the partition record store.
<p>
Unloadable keys will be removed before loading the values. Also, if
{@code replaceExistingValues} is {@code false}, the list of keys will
be filtered for existing keys in the partition record store.
@param keys the keys for which values will be loaded
@param replaceExistingValues if the existing entries for the keys should
be replaced with the loaded values
@throws Exception if there is an exception when invoking partition operations
to remove the existing keys or to put the loaded values into
the record store
"""
if (!replaceExistingValues) {
Future removeKeysFuture = removeExistingKeys(keys);
removeKeysFuture.get();
}
removeUnloadableKeys(keys);
if (keys.isEmpty()) {
return;
}
List<Future> futures = doBatchLoad(keys);
for (Future future : futures) {
future.get();
}
} | java | private void loadValuesInternal(List<Data> keys, boolean replaceExistingValues) throws Exception {
if (!replaceExistingValues) {
Future removeKeysFuture = removeExistingKeys(keys);
removeKeysFuture.get();
}
removeUnloadableKeys(keys);
if (keys.isEmpty()) {
return;
}
List<Future> futures = doBatchLoad(keys);
for (Future future : futures) {
future.get();
}
} | [
"private",
"void",
"loadValuesInternal",
"(",
"List",
"<",
"Data",
">",
"keys",
",",
"boolean",
"replaceExistingValues",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"replaceExistingValues",
")",
"{",
"Future",
"removeKeysFuture",
"=",
"removeExistingKeys",
"(",
"keys",
")",
";",
"removeKeysFuture",
".",
"get",
"(",
")",
";",
"}",
"removeUnloadableKeys",
"(",
"keys",
")",
";",
"if",
"(",
"keys",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"List",
"<",
"Future",
">",
"futures",
"=",
"doBatchLoad",
"(",
"keys",
")",
";",
"for",
"(",
"Future",
"future",
":",
"futures",
")",
"{",
"future",
".",
"get",
"(",
")",
";",
"}",
"}"
] | Loads the values for the provided keys and invokes partition operations
to put the loaded entries into the partition record store. The method
will block until all entries have been put into the partition record store.
<p>
Unloadable keys will be removed before loading the values. Also, if
{@code replaceExistingValues} is {@code false}, the list of keys will
be filtered for existing keys in the partition record store.
@param keys the keys for which values will be loaded
@param replaceExistingValues if the existing entries for the keys should
be replaced with the loaded values
@throws Exception if there is an exception when invoking partition operations
to remove the existing keys or to put the loaded values into
the record store | [
"Loads",
"the",
"values",
"for",
"the",
"provided",
"keys",
"and",
"invokes",
"partition",
"operations",
"to",
"put",
"the",
"loaded",
"entries",
"into",
"the",
"partition",
"record",
"store",
".",
"The",
"method",
"will",
"block",
"until",
"all",
"entries",
"have",
"been",
"put",
"into",
"the",
"partition",
"record",
"store",
".",
"<p",
">",
"Unloadable",
"keys",
"will",
"be",
"removed",
"before",
"loading",
"the",
"values",
".",
"Also",
"if",
"{",
"@code",
"replaceExistingValues",
"}",
"is",
"{",
"@code",
"false",
"}",
"the",
"list",
"of",
"keys",
"will",
"be",
"filtered",
"for",
"existing",
"keys",
"in",
"the",
"partition",
"record",
"store",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/recordstore/BasicRecordStoreLoader.java#L129-L142 |
libgdx/gdx-ai | gdx-ai/src/com/badlogic/gdx/ai/fsm/DefaultStateMachine.java | DefaultStateMachine.handleMessage | @Override
public boolean handleMessage (Telegram telegram) {
"""
Handles received telegrams. The telegram is first routed to the current state. If the current state does not deal with the
message, it's routed to the global state's message handler.
@param telegram the received telegram
@return true if telegram has been successfully handled; false otherwise.
"""
// First see if the current state is valid and that it can handle the message
if (currentState != null && currentState.onMessage(owner, telegram)) {
return true;
}
// If not, and if a global state has been implemented, send
// the message to the global state
if (globalState != null && globalState.onMessage(owner, telegram)) {
return true;
}
return false;
} | java | @Override
public boolean handleMessage (Telegram telegram) {
// First see if the current state is valid and that it can handle the message
if (currentState != null && currentState.onMessage(owner, telegram)) {
return true;
}
// If not, and if a global state has been implemented, send
// the message to the global state
if (globalState != null && globalState.onMessage(owner, telegram)) {
return true;
}
return false;
} | [
"@",
"Override",
"public",
"boolean",
"handleMessage",
"(",
"Telegram",
"telegram",
")",
"{",
"// First see if the current state is valid and that it can handle the message",
"if",
"(",
"currentState",
"!=",
"null",
"&&",
"currentState",
".",
"onMessage",
"(",
"owner",
",",
"telegram",
")",
")",
"{",
"return",
"true",
";",
"}",
"// If not, and if a global state has been implemented, send",
"// the message to the global state",
"if",
"(",
"globalState",
"!=",
"null",
"&&",
"globalState",
".",
"onMessage",
"(",
"owner",
",",
"telegram",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Handles received telegrams. The telegram is first routed to the current state. If the current state does not deal with the
message, it's routed to the global state's message handler.
@param telegram the received telegram
@return true if telegram has been successfully handled; false otherwise. | [
"Handles",
"received",
"telegrams",
".",
"The",
"telegram",
"is",
"first",
"routed",
"to",
"the",
"current",
"state",
".",
"If",
"the",
"current",
"state",
"does",
"not",
"deal",
"with",
"the",
"message",
"it",
"s",
"routed",
"to",
"the",
"global",
"state",
"s",
"message",
"handler",
"."
] | train | https://github.com/libgdx/gdx-ai/blob/2d1523a97193a45e18e11a4837c6800d08f177c5/gdx-ai/src/com/badlogic/gdx/ai/fsm/DefaultStateMachine.java#L158-L173 |
Red5/red5-server-common | src/main/java/org/red5/server/scope/Scope.java | Scope.hasChildScope | public boolean hasChildScope(ScopeType type, String name) {
"""
Check whether scope has child scope with given name and type
@param type Child scope type
@param name Child scope name
@return true if scope has child node with given name and type, false otherwise
"""
log.debug("Has child scope? {} in {}", name, this);
return children.getBasicScope(type, name) != null;
} | java | public boolean hasChildScope(ScopeType type, String name) {
log.debug("Has child scope? {} in {}", name, this);
return children.getBasicScope(type, name) != null;
} | [
"public",
"boolean",
"hasChildScope",
"(",
"ScopeType",
"type",
",",
"String",
"name",
")",
"{",
"log",
".",
"debug",
"(",
"\"Has child scope? {} in {}\"",
",",
"name",
",",
"this",
")",
";",
"return",
"children",
".",
"getBasicScope",
"(",
"type",
",",
"name",
")",
"!=",
"null",
";",
"}"
] | Check whether scope has child scope with given name and type
@param type Child scope type
@param name Child scope name
@return true if scope has child node with given name and type, false otherwise | [
"Check",
"whether",
"scope",
"has",
"child",
"scope",
"with",
"given",
"name",
"and",
"type"
] | train | https://github.com/Red5/red5-server-common/blob/39ae73710c25bda86d70b13ef37ae707962217b9/src/main/java/org/red5/server/scope/Scope.java#L818-L821 |
networknt/light-rest-4j | openapi-validator/src/main/java/com/networknt/openapi/ResponseValidator.java | ResponseValidator.getOpenApiOperation | private OpenApiOperation getOpenApiOperation(String uri, String httpMethod) throws URISyntaxException {
"""
locate operation based on uri and httpMethod
@param uri original uri of the request
@param httpMethod http method of the request
@return OpenApiOperation the wrapper of an api operation
"""
String uriWithoutQuery = new URI(uri).getPath();
NormalisedPath requestPath = new ApiNormalisedPath(uriWithoutQuery);
Optional<NormalisedPath> maybeApiPath = OpenApiHelper.findMatchingApiPath(requestPath);
if (!maybeApiPath.isPresent()) {
return null;
}
final NormalisedPath openApiPathString = maybeApiPath.get();
final Path path = OpenApiHelper.openApi3.getPath(openApiPathString.original());
final Operation operation = path.getOperation(httpMethod);
return new OpenApiOperation(openApiPathString, path, httpMethod, operation);
} | java | private OpenApiOperation getOpenApiOperation(String uri, String httpMethod) throws URISyntaxException {
String uriWithoutQuery = new URI(uri).getPath();
NormalisedPath requestPath = new ApiNormalisedPath(uriWithoutQuery);
Optional<NormalisedPath> maybeApiPath = OpenApiHelper.findMatchingApiPath(requestPath);
if (!maybeApiPath.isPresent()) {
return null;
}
final NormalisedPath openApiPathString = maybeApiPath.get();
final Path path = OpenApiHelper.openApi3.getPath(openApiPathString.original());
final Operation operation = path.getOperation(httpMethod);
return new OpenApiOperation(openApiPathString, path, httpMethod, operation);
} | [
"private",
"OpenApiOperation",
"getOpenApiOperation",
"(",
"String",
"uri",
",",
"String",
"httpMethod",
")",
"throws",
"URISyntaxException",
"{",
"String",
"uriWithoutQuery",
"=",
"new",
"URI",
"(",
"uri",
")",
".",
"getPath",
"(",
")",
";",
"NormalisedPath",
"requestPath",
"=",
"new",
"ApiNormalisedPath",
"(",
"uriWithoutQuery",
")",
";",
"Optional",
"<",
"NormalisedPath",
">",
"maybeApiPath",
"=",
"OpenApiHelper",
".",
"findMatchingApiPath",
"(",
"requestPath",
")",
";",
"if",
"(",
"!",
"maybeApiPath",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
"NormalisedPath",
"openApiPathString",
"=",
"maybeApiPath",
".",
"get",
"(",
")",
";",
"final",
"Path",
"path",
"=",
"OpenApiHelper",
".",
"openApi3",
".",
"getPath",
"(",
"openApiPathString",
".",
"original",
"(",
")",
")",
";",
"final",
"Operation",
"operation",
"=",
"path",
".",
"getOperation",
"(",
"httpMethod",
")",
";",
"return",
"new",
"OpenApiOperation",
"(",
"openApiPathString",
",",
"path",
",",
"httpMethod",
",",
"operation",
")",
";",
"}"
] | locate operation based on uri and httpMethod
@param uri original uri of the request
@param httpMethod http method of the request
@return OpenApiOperation the wrapper of an api operation | [
"locate",
"operation",
"based",
"on",
"uri",
"and",
"httpMethod"
] | train | https://github.com/networknt/light-rest-4j/blob/06b15128e6101351e617284a636ef5d632e6b1fe/openapi-validator/src/main/java/com/networknt/openapi/ResponseValidator.java#L173-L186 |
overturetool/overture | core/parser/src/main/java/org/overture/parser/lex/BacktrackInputReader.java | BacktrackInputReader.readerFactory | public static InputStreamReader readerFactory(File file, String charset)
throws IOException {
"""
Create an InputStreamReader from a File, depending on the filename.
@param file
@param charset
@return
@throws IOException
"""
String name = file.getName();
if (name.toLowerCase().endsWith(".doc"))
{
return new DocStreamReader(new FileInputStream(file), charset);
} else if (name.toLowerCase().endsWith(".docx"))
{
return new DocxStreamReader(new FileInputStream(file));
} else if (name.toLowerCase().endsWith(".odt"))
{
return new ODFStreamReader(new FileInputStream(file));
} else
{
return new LatexStreamReader(new FileInputStream(file), charset);
}
} | java | public static InputStreamReader readerFactory(File file, String charset)
throws IOException
{
String name = file.getName();
if (name.toLowerCase().endsWith(".doc"))
{
return new DocStreamReader(new FileInputStream(file), charset);
} else if (name.toLowerCase().endsWith(".docx"))
{
return new DocxStreamReader(new FileInputStream(file));
} else if (name.toLowerCase().endsWith(".odt"))
{
return new ODFStreamReader(new FileInputStream(file));
} else
{
return new LatexStreamReader(new FileInputStream(file), charset);
}
} | [
"public",
"static",
"InputStreamReader",
"readerFactory",
"(",
"File",
"file",
",",
"String",
"charset",
")",
"throws",
"IOException",
"{",
"String",
"name",
"=",
"file",
".",
"getName",
"(",
")",
";",
"if",
"(",
"name",
".",
"toLowerCase",
"(",
")",
".",
"endsWith",
"(",
"\".doc\"",
")",
")",
"{",
"return",
"new",
"DocStreamReader",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
",",
"charset",
")",
";",
"}",
"else",
"if",
"(",
"name",
".",
"toLowerCase",
"(",
")",
".",
"endsWith",
"(",
"\".docx\"",
")",
")",
"{",
"return",
"new",
"DocxStreamReader",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
")",
";",
"}",
"else",
"if",
"(",
"name",
".",
"toLowerCase",
"(",
")",
".",
"endsWith",
"(",
"\".odt\"",
")",
")",
"{",
"return",
"new",
"ODFStreamReader",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"LatexStreamReader",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
",",
"charset",
")",
";",
"}",
"}"
] | Create an InputStreamReader from a File, depending on the filename.
@param file
@param charset
@return
@throws IOException | [
"Create",
"an",
"InputStreamReader",
"from",
"a",
"File",
"depending",
"on",
"the",
"filename",
"."
] | train | https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/parser/src/main/java/org/overture/parser/lex/BacktrackInputReader.java#L208-L226 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/bos/BosClient.java | BosClient.getObjectContent | public byte[] getObjectContent(GetObjectRequest request) {
"""
Gets the object content stored in Bos under the specified bucket and key.
@param request The request object containing all the options on how to download the Bos object content.
@return The object content stored in Bos in the specified bucket and key.
"""
BosObjectInputStream content = this.getObject(request).getObjectContent();
try {
return IOUtils.toByteArray(content);
} catch (IOException e) {
try {
content.close();
} catch (IOException e1) {
// ignore, throw e not e1.
}
throw new BceClientException("Fail read object content", e);
} finally {
try {
content.close();
} catch (IOException e) {
// ignore
}
}
} | java | public byte[] getObjectContent(GetObjectRequest request) {
BosObjectInputStream content = this.getObject(request).getObjectContent();
try {
return IOUtils.toByteArray(content);
} catch (IOException e) {
try {
content.close();
} catch (IOException e1) {
// ignore, throw e not e1.
}
throw new BceClientException("Fail read object content", e);
} finally {
try {
content.close();
} catch (IOException e) {
// ignore
}
}
} | [
"public",
"byte",
"[",
"]",
"getObjectContent",
"(",
"GetObjectRequest",
"request",
")",
"{",
"BosObjectInputStream",
"content",
"=",
"this",
".",
"getObject",
"(",
"request",
")",
".",
"getObjectContent",
"(",
")",
";",
"try",
"{",
"return",
"IOUtils",
".",
"toByteArray",
"(",
"content",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"try",
"{",
"content",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e1",
")",
"{",
"// ignore, throw e not e1.",
"}",
"throw",
"new",
"BceClientException",
"(",
"\"Fail read object content\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"content",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// ignore",
"}",
"}",
"}"
] | Gets the object content stored in Bos under the specified bucket and key.
@param request The request object containing all the options on how to download the Bos object content.
@return The object content stored in Bos in the specified bucket and key. | [
"Gets",
"the",
"object",
"content",
"stored",
"in",
"Bos",
"under",
"the",
"specified",
"bucket",
"and",
"key",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bos/BosClient.java#L724-L742 |
landawn/AbacusUtil | src/com/landawn/abacus/dataSource/PoolableConnection.java | PoolableConnection.createStatement | @Override
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
"""
Method createStatement.
@param resultSetType
@param resultSetConcurrency
@return Statement
@throws SQLException
@see java.sql.Connection#createStatement(int, int)
"""
// return new
// NativeStatement(internalConn.createStatement(resultSetType,
// resultSetConcurrency), this);
return internalConn.createStatement(resultSetType, resultSetConcurrency);
} | java | @Override
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
// return new
// NativeStatement(internalConn.createStatement(resultSetType,
// resultSetConcurrency), this);
return internalConn.createStatement(resultSetType, resultSetConcurrency);
} | [
"@",
"Override",
"public",
"Statement",
"createStatement",
"(",
"int",
"resultSetType",
",",
"int",
"resultSetConcurrency",
")",
"throws",
"SQLException",
"{",
"// return new\r",
"// NativeStatement(internalConn.createStatement(resultSetType,\r",
"// resultSetConcurrency), this);\r",
"return",
"internalConn",
".",
"createStatement",
"(",
"resultSetType",
",",
"resultSetConcurrency",
")",
";",
"}"
] | Method createStatement.
@param resultSetType
@param resultSetConcurrency
@return Statement
@throws SQLException
@see java.sql.Connection#createStatement(int, int) | [
"Method",
"createStatement",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/dataSource/PoolableConnection.java#L272-L278 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.