repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
mpetazzoni/ttorrent | ttorrent-client/src/main/java/com/turn/ttorrent/client/SharedTorrent.java | SharedTorrent.handlePieceSent | @Override
public void handlePieceSent(SharingPeer peer, Piece piece) {
"""
Piece upload completion handler.
<p/>
<p>
When a piece has been sent to a peer, we just record that we sent that
many bytes. If the piece is valid on the peer's side, it will send us a
HAVE message and we'll record that the piece is available on the peer at
that moment (see <code>handlePieceAvailability()</code>).
</p>
@param peer The peer we got this piece from.
@param piece The piece in question.
"""
logger.trace("Completed upload of {} to {}.", piece, peer);
myTorrentStatistic.addUploaded(piece.size());
} | java | @Override
public void handlePieceSent(SharingPeer peer, Piece piece) {
logger.trace("Completed upload of {} to {}.", piece, peer);
myTorrentStatistic.addUploaded(piece.size());
} | [
"@",
"Override",
"public",
"void",
"handlePieceSent",
"(",
"SharingPeer",
"peer",
",",
"Piece",
"piece",
")",
"{",
"logger",
".",
"trace",
"(",
"\"Completed upload of {} to {}.\"",
",",
"piece",
",",
"peer",
")",
";",
"myTorrentStatistic",
".",
"addUploaded",
"(",
"piece",
".",
"size",
"(",
")",
")",
";",
"}"
]
| Piece upload completion handler.
<p/>
<p>
When a piece has been sent to a peer, we just record that we sent that
many bytes. If the piece is valid on the peer's side, it will send us a
HAVE message and we'll record that the piece is available on the peer at
that moment (see <code>handlePieceAvailability()</code>).
</p>
@param peer The peer we got this piece from.
@param piece The piece in question. | [
"Piece",
"upload",
"completion",
"handler",
".",
"<p",
"/",
">",
"<p",
">",
"When",
"a",
"piece",
"has",
"been",
"sent",
"to",
"a",
"peer",
"we",
"just",
"record",
"that",
"we",
"sent",
"that",
"many",
"bytes",
".",
"If",
"the",
"piece",
"is",
"valid",
"on",
"the",
"peer",
"s",
"side",
"it",
"will",
"send",
"us",
"a",
"HAVE",
"message",
"and",
"we",
"ll",
"record",
"that",
"the",
"piece",
"is",
"available",
"on",
"the",
"peer",
"at",
"that",
"moment",
"(",
"see",
"<code",
">",
"handlePieceAvailability",
"()",
"<",
"/",
"code",
">",
")",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/SharedTorrent.java#L646-L650 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF4.java | CommonOps_DDF4.multAddOuter | public static void multAddOuter( double alpha , DMatrix4x4 A , double beta , DMatrix4 u , DMatrix4 v , DMatrix4x4 C ) {
"""
C = αA + βu*v<sup>T</sup>
@param alpha scale factor applied to A
@param A matrix
@param beta scale factor applies to outer product
@param u vector
@param v vector
@param C Storage for solution. Can be same instance as A.
"""
C.a11 = alpha*A.a11 + beta*u.a1*v.a1;
C.a12 = alpha*A.a12 + beta*u.a1*v.a2;
C.a13 = alpha*A.a13 + beta*u.a1*v.a3;
C.a14 = alpha*A.a14 + beta*u.a1*v.a4;
C.a21 = alpha*A.a21 + beta*u.a2*v.a1;
C.a22 = alpha*A.a22 + beta*u.a2*v.a2;
C.a23 = alpha*A.a23 + beta*u.a2*v.a3;
C.a24 = alpha*A.a24 + beta*u.a2*v.a4;
C.a31 = alpha*A.a31 + beta*u.a3*v.a1;
C.a32 = alpha*A.a32 + beta*u.a3*v.a2;
C.a33 = alpha*A.a33 + beta*u.a3*v.a3;
C.a34 = alpha*A.a34 + beta*u.a3*v.a4;
C.a41 = alpha*A.a41 + beta*u.a4*v.a1;
C.a42 = alpha*A.a42 + beta*u.a4*v.a2;
C.a43 = alpha*A.a43 + beta*u.a4*v.a3;
C.a44 = alpha*A.a44 + beta*u.a4*v.a4;
} | java | public static void multAddOuter( double alpha , DMatrix4x4 A , double beta , DMatrix4 u , DMatrix4 v , DMatrix4x4 C ) {
C.a11 = alpha*A.a11 + beta*u.a1*v.a1;
C.a12 = alpha*A.a12 + beta*u.a1*v.a2;
C.a13 = alpha*A.a13 + beta*u.a1*v.a3;
C.a14 = alpha*A.a14 + beta*u.a1*v.a4;
C.a21 = alpha*A.a21 + beta*u.a2*v.a1;
C.a22 = alpha*A.a22 + beta*u.a2*v.a2;
C.a23 = alpha*A.a23 + beta*u.a2*v.a3;
C.a24 = alpha*A.a24 + beta*u.a2*v.a4;
C.a31 = alpha*A.a31 + beta*u.a3*v.a1;
C.a32 = alpha*A.a32 + beta*u.a3*v.a2;
C.a33 = alpha*A.a33 + beta*u.a3*v.a3;
C.a34 = alpha*A.a34 + beta*u.a3*v.a4;
C.a41 = alpha*A.a41 + beta*u.a4*v.a1;
C.a42 = alpha*A.a42 + beta*u.a4*v.a2;
C.a43 = alpha*A.a43 + beta*u.a4*v.a3;
C.a44 = alpha*A.a44 + beta*u.a4*v.a4;
} | [
"public",
"static",
"void",
"multAddOuter",
"(",
"double",
"alpha",
",",
"DMatrix4x4",
"A",
",",
"double",
"beta",
",",
"DMatrix4",
"u",
",",
"DMatrix4",
"v",
",",
"DMatrix4x4",
"C",
")",
"{",
"C",
".",
"a11",
"=",
"alpha",
"*",
"A",
".",
"a11",
"+",
"beta",
"*",
"u",
".",
"a1",
"*",
"v",
".",
"a1",
";",
"C",
".",
"a12",
"=",
"alpha",
"*",
"A",
".",
"a12",
"+",
"beta",
"*",
"u",
".",
"a1",
"*",
"v",
".",
"a2",
";",
"C",
".",
"a13",
"=",
"alpha",
"*",
"A",
".",
"a13",
"+",
"beta",
"*",
"u",
".",
"a1",
"*",
"v",
".",
"a3",
";",
"C",
".",
"a14",
"=",
"alpha",
"*",
"A",
".",
"a14",
"+",
"beta",
"*",
"u",
".",
"a1",
"*",
"v",
".",
"a4",
";",
"C",
".",
"a21",
"=",
"alpha",
"*",
"A",
".",
"a21",
"+",
"beta",
"*",
"u",
".",
"a2",
"*",
"v",
".",
"a1",
";",
"C",
".",
"a22",
"=",
"alpha",
"*",
"A",
".",
"a22",
"+",
"beta",
"*",
"u",
".",
"a2",
"*",
"v",
".",
"a2",
";",
"C",
".",
"a23",
"=",
"alpha",
"*",
"A",
".",
"a23",
"+",
"beta",
"*",
"u",
".",
"a2",
"*",
"v",
".",
"a3",
";",
"C",
".",
"a24",
"=",
"alpha",
"*",
"A",
".",
"a24",
"+",
"beta",
"*",
"u",
".",
"a2",
"*",
"v",
".",
"a4",
";",
"C",
".",
"a31",
"=",
"alpha",
"*",
"A",
".",
"a31",
"+",
"beta",
"*",
"u",
".",
"a3",
"*",
"v",
".",
"a1",
";",
"C",
".",
"a32",
"=",
"alpha",
"*",
"A",
".",
"a32",
"+",
"beta",
"*",
"u",
".",
"a3",
"*",
"v",
".",
"a2",
";",
"C",
".",
"a33",
"=",
"alpha",
"*",
"A",
".",
"a33",
"+",
"beta",
"*",
"u",
".",
"a3",
"*",
"v",
".",
"a3",
";",
"C",
".",
"a34",
"=",
"alpha",
"*",
"A",
".",
"a34",
"+",
"beta",
"*",
"u",
".",
"a3",
"*",
"v",
".",
"a4",
";",
"C",
".",
"a41",
"=",
"alpha",
"*",
"A",
".",
"a41",
"+",
"beta",
"*",
"u",
".",
"a4",
"*",
"v",
".",
"a1",
";",
"C",
".",
"a42",
"=",
"alpha",
"*",
"A",
".",
"a42",
"+",
"beta",
"*",
"u",
".",
"a4",
"*",
"v",
".",
"a2",
";",
"C",
".",
"a43",
"=",
"alpha",
"*",
"A",
".",
"a43",
"+",
"beta",
"*",
"u",
".",
"a4",
"*",
"v",
".",
"a3",
";",
"C",
".",
"a44",
"=",
"alpha",
"*",
"A",
".",
"a44",
"+",
"beta",
"*",
"u",
".",
"a4",
"*",
"v",
".",
"a4",
";",
"}"
]
| C = αA + βu*v<sup>T</sup>
@param alpha scale factor applied to A
@param A matrix
@param beta scale factor applies to outer product
@param u vector
@param v vector
@param C Storage for solution. Can be same instance as A. | [
"C",
"=",
"&alpha",
";",
"A",
"+",
"&beta",
";",
"u",
"*",
"v<sup",
">",
"T<",
"/",
"sup",
">"
]
| train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF4.java#L802-L819 |
agmip/translator-dssat | src/main/java/org/agmip/translators/dssat/DssatControllerOutput.java | DssatControllerOutput.writeSingleExp | private void writeSingleExp(String arg0, Map result, DssatCommonOutput output, String file) {
"""
Write files and add file objects in the array
@param arg0 file output path
@param result data holder object
@param output DSSAT translator object
@param file Generated DSSAT file identifier
"""
futFiles.put(file, executor.submit(new DssatTranslateRunner(output, result, arg0)));
} | java | private void writeSingleExp(String arg0, Map result, DssatCommonOutput output, String file) {
futFiles.put(file, executor.submit(new DssatTranslateRunner(output, result, arg0)));
} | [
"private",
"void",
"writeSingleExp",
"(",
"String",
"arg0",
",",
"Map",
"result",
",",
"DssatCommonOutput",
"output",
",",
"String",
"file",
")",
"{",
"futFiles",
".",
"put",
"(",
"file",
",",
"executor",
".",
"submit",
"(",
"new",
"DssatTranslateRunner",
"(",
"output",
",",
"result",
",",
"arg0",
")",
")",
")",
";",
"}"
]
| Write files and add file objects in the array
@param arg0 file output path
@param result data holder object
@param output DSSAT translator object
@param file Generated DSSAT file identifier | [
"Write",
"files",
"and",
"add",
"file",
"objects",
"in",
"the",
"array"
]
| train | https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatControllerOutput.java#L274-L276 |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsFunctionRenderer.java | CmsFunctionRenderer.getDefaultResource | private static CmsResource getDefaultResource(CmsObject cms, String path) {
"""
Helper method for cached reading of resources under specific, fixed paths.<p>
@param cms the current CMS context
@param path the path to read
@return the resource which has been read
"""
CmsResource resource = (CmsResource)CmsVfsMemoryObjectCache.getVfsMemoryObjectCache().getCachedObject(
cms,
path);
if (resource == null) {
try {
resource = cms.readResource(path);
CmsVfsMemoryObjectCache.getVfsMemoryObjectCache().putCachedObject(cms, path, resource);
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
}
}
return resource;
} | java | private static CmsResource getDefaultResource(CmsObject cms, String path) {
CmsResource resource = (CmsResource)CmsVfsMemoryObjectCache.getVfsMemoryObjectCache().getCachedObject(
cms,
path);
if (resource == null) {
try {
resource = cms.readResource(path);
CmsVfsMemoryObjectCache.getVfsMemoryObjectCache().putCachedObject(cms, path, resource);
} catch (CmsException e) {
LOG.warn(e.getLocalizedMessage(), e);
}
}
return resource;
} | [
"private",
"static",
"CmsResource",
"getDefaultResource",
"(",
"CmsObject",
"cms",
",",
"String",
"path",
")",
"{",
"CmsResource",
"resource",
"=",
"(",
"CmsResource",
")",
"CmsVfsMemoryObjectCache",
".",
"getVfsMemoryObjectCache",
"(",
")",
".",
"getCachedObject",
"(",
"cms",
",",
"path",
")",
";",
"if",
"(",
"resource",
"==",
"null",
")",
"{",
"try",
"{",
"resource",
"=",
"cms",
".",
"readResource",
"(",
"path",
")",
";",
"CmsVfsMemoryObjectCache",
".",
"getVfsMemoryObjectCache",
"(",
")",
".",
"putCachedObject",
"(",
"cms",
",",
"path",
",",
"resource",
")",
";",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"return",
"resource",
";",
"}"
]
| Helper method for cached reading of resources under specific, fixed paths.<p>
@param cms the current CMS context
@param path the path to read
@return the resource which has been read | [
"Helper",
"method",
"for",
"cached",
"reading",
"of",
"resources",
"under",
"specific",
"fixed",
"paths",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsFunctionRenderer.java#L162-L176 |
igniterealtime/REST-API-Client | src/main/java/org/igniterealtime/restclient/RestApiClient.java | RestApiClient.deleteOwnerGroup | public Response deleteOwnerGroup(String roomName, String groupName) {
"""
Delete owner group from chatroom.
@param roomName
the room name
@param groupName
the groupName
@return the response
"""
return restClient.delete("chatrooms/" + roomName + "/owners/group/" + groupName,
new HashMap<String, String>());
} | java | public Response deleteOwnerGroup(String roomName, String groupName) {
return restClient.delete("chatrooms/" + roomName + "/owners/group/" + groupName,
new HashMap<String, String>());
} | [
"public",
"Response",
"deleteOwnerGroup",
"(",
"String",
"roomName",
",",
"String",
"groupName",
")",
"{",
"return",
"restClient",
".",
"delete",
"(",
"\"chatrooms/\"",
"+",
"roomName",
"+",
"\"/owners/group/\"",
"+",
"groupName",
",",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
")",
";",
"}"
]
| Delete owner group from chatroom.
@param roomName
the room name
@param groupName
the groupName
@return the response | [
"Delete",
"owner",
"group",
"from",
"chatroom",
"."
]
| train | https://github.com/igniterealtime/REST-API-Client/blob/fd544dd770ec2ababa47fef51579522ddce09f05/src/main/java/org/igniterealtime/restclient/RestApiClient.java#L369-L372 |
nmorel/gwt-jackson | gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonDeserializationContext.java | JsonDeserializationContext.addObjectId | public void addObjectId( IdKey id, Object instance ) {
"""
<p>addObjectId</p>
@param id a {@link com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey} object.
@param instance a {@link java.lang.Object} object.
"""
if ( null == idToObject ) {
idToObject = new HashMap<IdKey, Object>();
}
idToObject.put( id, instance );
} | java | public void addObjectId( IdKey id, Object instance ) {
if ( null == idToObject ) {
idToObject = new HashMap<IdKey, Object>();
}
idToObject.put( id, instance );
} | [
"public",
"void",
"addObjectId",
"(",
"IdKey",
"id",
",",
"Object",
"instance",
")",
"{",
"if",
"(",
"null",
"==",
"idToObject",
")",
"{",
"idToObject",
"=",
"new",
"HashMap",
"<",
"IdKey",
",",
"Object",
">",
"(",
")",
";",
"}",
"idToObject",
".",
"put",
"(",
"id",
",",
"instance",
")",
";",
"}"
]
| <p>addObjectId</p>
@param id a {@link com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey} object.
@param instance a {@link java.lang.Object} object. | [
"<p",
">",
"addObjectId<",
"/",
"p",
">"
]
| train | https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonDeserializationContext.java#L411-L416 |
aws/aws-sdk-java | aws-java-sdk-sns/src/main/java/com/amazonaws/services/sns/model/Endpoint.java | Endpoint.withAttributes | public Endpoint withAttributes(java.util.Map<String, String> attributes) {
"""
<p>
Attributes for endpoint.
</p>
@param attributes
Attributes for endpoint.
@return Returns a reference to this object so that method calls can be chained together.
"""
setAttributes(attributes);
return this;
} | java | public Endpoint withAttributes(java.util.Map<String, String> attributes) {
setAttributes(attributes);
return this;
} | [
"public",
"Endpoint",
"withAttributes",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
")",
"{",
"setAttributes",
"(",
"attributes",
")",
";",
"return",
"this",
";",
"}"
]
| <p>
Attributes for endpoint.
</p>
@param attributes
Attributes for endpoint.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Attributes",
"for",
"endpoint",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-sns/src/main/java/com/amazonaws/services/sns/model/Endpoint.java#L119-L122 |
whitesource/agents | wss-agent-report/src/main/java/org/whitesource/agent/report/PolicyCheckReport.java | PolicyCheckReport.copyReportResources | protected void copyReportResources(File workDir) throws IOException {
"""
Copy required resources for the report.
@param workDir Report work directory.
@throws IOException exception5
"""
FileUtils.copyResource(TEMPLATE_FOLDER + CSS_FILE, new File(workDir, CSS_FILE));
} | java | protected void copyReportResources(File workDir) throws IOException {
FileUtils.copyResource(TEMPLATE_FOLDER + CSS_FILE, new File(workDir, CSS_FILE));
} | [
"protected",
"void",
"copyReportResources",
"(",
"File",
"workDir",
")",
"throws",
"IOException",
"{",
"FileUtils",
".",
"copyResource",
"(",
"TEMPLATE_FOLDER",
"+",
"CSS_FILE",
",",
"new",
"File",
"(",
"workDir",
",",
"CSS_FILE",
")",
")",
";",
"}"
]
| Copy required resources for the report.
@param workDir Report work directory.
@throws IOException exception5 | [
"Copy",
"required",
"resources",
"for",
"the",
"report",
"."
]
| train | https://github.com/whitesource/agents/blob/8a947a3dbad257aff70f23f79fb3a55ca90b765f/wss-agent-report/src/main/java/org/whitesource/agent/report/PolicyCheckReport.java#L249-L251 |
jcuda/jcusparse | JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java | JCusparse.cusparseScsrmv | public static int cusparseScsrmv(
cusparseHandle handle,
int transA,
int m,
int n,
int nnz,
Pointer alpha,
cusparseMatDescr descrA,
Pointer csrSortedValA,
Pointer csrSortedRowPtrA,
Pointer csrSortedColIndA,
Pointer x,
Pointer beta,
Pointer y) {
"""
Description: Matrix-vector multiplication y = alpha * op(A) * x + beta * y,
where A is a sparse matrix in CSR storage format, x and y are dense vectors.
"""
return checkResult(cusparseScsrmvNative(handle, transA, m, n, nnz, alpha, descrA, csrSortedValA, csrSortedRowPtrA, csrSortedColIndA, x, beta, y));
} | java | public static int cusparseScsrmv(
cusparseHandle handle,
int transA,
int m,
int n,
int nnz,
Pointer alpha,
cusparseMatDescr descrA,
Pointer csrSortedValA,
Pointer csrSortedRowPtrA,
Pointer csrSortedColIndA,
Pointer x,
Pointer beta,
Pointer y)
{
return checkResult(cusparseScsrmvNative(handle, transA, m, n, nnz, alpha, descrA, csrSortedValA, csrSortedRowPtrA, csrSortedColIndA, x, beta, y));
} | [
"public",
"static",
"int",
"cusparseScsrmv",
"(",
"cusparseHandle",
"handle",
",",
"int",
"transA",
",",
"int",
"m",
",",
"int",
"n",
",",
"int",
"nnz",
",",
"Pointer",
"alpha",
",",
"cusparseMatDescr",
"descrA",
",",
"Pointer",
"csrSortedValA",
",",
"Pointer",
"csrSortedRowPtrA",
",",
"Pointer",
"csrSortedColIndA",
",",
"Pointer",
"x",
",",
"Pointer",
"beta",
",",
"Pointer",
"y",
")",
"{",
"return",
"checkResult",
"(",
"cusparseScsrmvNative",
"(",
"handle",
",",
"transA",
",",
"m",
",",
"n",
",",
"nnz",
",",
"alpha",
",",
"descrA",
",",
"csrSortedValA",
",",
"csrSortedRowPtrA",
",",
"csrSortedColIndA",
",",
"x",
",",
"beta",
",",
"y",
")",
")",
";",
"}"
]
| Description: Matrix-vector multiplication y = alpha * op(A) * x + beta * y,
where A is a sparse matrix in CSR storage format, x and y are dense vectors. | [
"Description",
":",
"Matrix",
"-",
"vector",
"multiplication",
"y",
"=",
"alpha",
"*",
"op",
"(",
"A",
")",
"*",
"x",
"+",
"beta",
"*",
"y",
"where",
"A",
"is",
"a",
"sparse",
"matrix",
"in",
"CSR",
"storage",
"format",
"x",
"and",
"y",
"are",
"dense",
"vectors",
"."
]
| train | https://github.com/jcuda/jcusparse/blob/7687a62a4ef6b76cb91cf7da93d4cf5ade96a791/JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java#L1355-L1371 |
facebookarchive/hadoop-20 | src/mapred/org/apache/hadoop/mapred/TaskLogServlet.java | TaskLogServlet.findFirstQuotable | private static int findFirstQuotable(byte[] data, int offset, int end) {
"""
Find the next quotable character in the given array.
@param data the bytes to look in
@param offset the first index to look in
@param end the index after the last one to look in
@return the index of the quotable character or end if none was found
"""
while (offset < end) {
switch (data[offset]) {
case '<':
case '>':
case '&':
return offset;
default:
offset += 1;
}
}
return offset;
} | java | private static int findFirstQuotable(byte[] data, int offset, int end) {
while (offset < end) {
switch (data[offset]) {
case '<':
case '>':
case '&':
return offset;
default:
offset += 1;
}
}
return offset;
} | [
"private",
"static",
"int",
"findFirstQuotable",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"end",
")",
"{",
"while",
"(",
"offset",
"<",
"end",
")",
"{",
"switch",
"(",
"data",
"[",
"offset",
"]",
")",
"{",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"return",
"offset",
";",
"default",
":",
"offset",
"+=",
"1",
";",
"}",
"}",
"return",
"offset",
";",
"}"
]
| Find the next quotable character in the given array.
@param data the bytes to look in
@param offset the first index to look in
@param end the index after the last one to look in
@return the index of the quotable character or end if none was found | [
"Find",
"the",
"next",
"quotable",
"character",
"in",
"the",
"given",
"array",
"."
]
| train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/mapred/org/apache/hadoop/mapred/TaskLogServlet.java#L64-L76 |
mlhartme/mork | src/main/java/net/oneandone/mork/reflect/Method.java | Method.forName | public static Selection forName(Class cl, String name) {
"""
Gets all valid Methods from the specified class with the
specified name.
@param cl Class to look at
@param name the Function name to look for
@return retrieves all Methods found
"""
java.lang.reflect.Method[] all;
int i;
List<Function> lst;
Function fn;
all = cl.getDeclaredMethods();
lst = new ArrayList<Function>();
for (i = 0; i < all.length; i++) {
if (name.equals(all[i].getName())) {
fn = create(all[i]);
if (fn != null) {
lst.add(fn);
}
}
}
return new Selection(lst);
} | java | public static Selection forName(Class cl, String name) {
java.lang.reflect.Method[] all;
int i;
List<Function> lst;
Function fn;
all = cl.getDeclaredMethods();
lst = new ArrayList<Function>();
for (i = 0; i < all.length; i++) {
if (name.equals(all[i].getName())) {
fn = create(all[i]);
if (fn != null) {
lst.add(fn);
}
}
}
return new Selection(lst);
} | [
"public",
"static",
"Selection",
"forName",
"(",
"Class",
"cl",
",",
"String",
"name",
")",
"{",
"java",
".",
"lang",
".",
"reflect",
".",
"Method",
"[",
"]",
"all",
";",
"int",
"i",
";",
"List",
"<",
"Function",
">",
"lst",
";",
"Function",
"fn",
";",
"all",
"=",
"cl",
".",
"getDeclaredMethods",
"(",
")",
";",
"lst",
"=",
"new",
"ArrayList",
"<",
"Function",
">",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"all",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"name",
".",
"equals",
"(",
"all",
"[",
"i",
"]",
".",
"getName",
"(",
")",
")",
")",
"{",
"fn",
"=",
"create",
"(",
"all",
"[",
"i",
"]",
")",
";",
"if",
"(",
"fn",
"!=",
"null",
")",
"{",
"lst",
".",
"add",
"(",
"fn",
")",
";",
"}",
"}",
"}",
"return",
"new",
"Selection",
"(",
"lst",
")",
";",
"}"
]
| Gets all valid Methods from the specified class with the
specified name.
@param cl Class to look at
@param name the Function name to look for
@return retrieves all Methods found | [
"Gets",
"all",
"valid",
"Methods",
"from",
"the",
"specified",
"class",
"with",
"the",
"specified",
"name",
"."
]
| train | https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/reflect/Method.java#L67-L84 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java | AnnotationTypeBuilder.buildAnnotationTypeInfo | public void buildAnnotationTypeInfo(XMLNode node, Content annotationContentTree)
throws DocletException {
"""
Build the annotation information tree documentation.
@param node the XML element that specifies which components to document
@param annotationContentTree the content tree to which the documentation will be added
@throws DocletException if there is a problem building the documentation
"""
Content annotationInfoTree = writer.getAnnotationInfoTreeHeader();
buildChildren(node, annotationInfoTree);
annotationContentTree.addContent(writer.getAnnotationInfo(annotationInfoTree));
} | java | public void buildAnnotationTypeInfo(XMLNode node, Content annotationContentTree)
throws DocletException {
Content annotationInfoTree = writer.getAnnotationInfoTreeHeader();
buildChildren(node, annotationInfoTree);
annotationContentTree.addContent(writer.getAnnotationInfo(annotationInfoTree));
} | [
"public",
"void",
"buildAnnotationTypeInfo",
"(",
"XMLNode",
"node",
",",
"Content",
"annotationContentTree",
")",
"throws",
"DocletException",
"{",
"Content",
"annotationInfoTree",
"=",
"writer",
".",
"getAnnotationInfoTreeHeader",
"(",
")",
";",
"buildChildren",
"(",
"node",
",",
"annotationInfoTree",
")",
";",
"annotationContentTree",
".",
"addContent",
"(",
"writer",
".",
"getAnnotationInfo",
"(",
"annotationInfoTree",
")",
")",
";",
"}"
]
| Build the annotation information tree documentation.
@param node the XML element that specifies which components to document
@param annotationContentTree the content tree to which the documentation will be added
@throws DocletException if there is a problem building the documentation | [
"Build",
"the",
"annotation",
"information",
"tree",
"documentation",
"."
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java#L157-L162 |
i-net-software/jlessc | src/com/inet/lib/less/UrlUtils.java | UrlUtils.dataUri | static void dataUri( CssFormatter formatter, byte[] bytes, String urlStr, String type ) {
"""
Write the bytes as inline url.
@param formatter current formatter
@param bytes the bytes
@param urlStr used if mime type is null to detect the mime type
@param type the mime type
"""
if( type == null ) {
switch( urlStr.substring( urlStr.lastIndexOf( '.' ) + 1 ) ) {
case "gif":
type = "image/gif;base64";
break;
case "png":
type = "image/png;base64";
break;
case "jpg":
case "jpeg":
type = "image/jpeg;base64";
break;
default:
type = "text/html";
}
} else {
type = removeQuote( type );
}
if( type.endsWith( "base64" ) ) {
formatter.append( "url(\"data:" ).append( type ).append( ',' );
formatter.append( toBase64( bytes ) );
formatter.append( "\")" );
} else {
formatter.append( "url(\"data:" ).append( type ).append( ',' );
appendEncode( formatter, bytes );
formatter.append( "\")" );
}
} | java | static void dataUri( CssFormatter formatter, byte[] bytes, String urlStr, String type ) {
if( type == null ) {
switch( urlStr.substring( urlStr.lastIndexOf( '.' ) + 1 ) ) {
case "gif":
type = "image/gif;base64";
break;
case "png":
type = "image/png;base64";
break;
case "jpg":
case "jpeg":
type = "image/jpeg;base64";
break;
default:
type = "text/html";
}
} else {
type = removeQuote( type );
}
if( type.endsWith( "base64" ) ) {
formatter.append( "url(\"data:" ).append( type ).append( ',' );
formatter.append( toBase64( bytes ) );
formatter.append( "\")" );
} else {
formatter.append( "url(\"data:" ).append( type ).append( ',' );
appendEncode( formatter, bytes );
formatter.append( "\")" );
}
} | [
"static",
"void",
"dataUri",
"(",
"CssFormatter",
"formatter",
",",
"byte",
"[",
"]",
"bytes",
",",
"String",
"urlStr",
",",
"String",
"type",
")",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"switch",
"(",
"urlStr",
".",
"substring",
"(",
"urlStr",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
")",
"{",
"case",
"\"gif\"",
":",
"type",
"=",
"\"image/gif;base64\"",
";",
"break",
";",
"case",
"\"png\"",
":",
"type",
"=",
"\"image/png;base64\"",
";",
"break",
";",
"case",
"\"jpg\"",
":",
"case",
"\"jpeg\"",
":",
"type",
"=",
"\"image/jpeg;base64\"",
";",
"break",
";",
"default",
":",
"type",
"=",
"\"text/html\"",
";",
"}",
"}",
"else",
"{",
"type",
"=",
"removeQuote",
"(",
"type",
")",
";",
"}",
"if",
"(",
"type",
".",
"endsWith",
"(",
"\"base64\"",
")",
")",
"{",
"formatter",
".",
"append",
"(",
"\"url(\\\"data:\"",
")",
".",
"append",
"(",
"type",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"formatter",
".",
"append",
"(",
"toBase64",
"(",
"bytes",
")",
")",
";",
"formatter",
".",
"append",
"(",
"\"\\\")\"",
")",
";",
"}",
"else",
"{",
"formatter",
".",
"append",
"(",
"\"url(\\\"data:\"",
")",
".",
"append",
"(",
"type",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"appendEncode",
"(",
"formatter",
",",
"bytes",
")",
";",
"formatter",
".",
"append",
"(",
"\"\\\")\"",
")",
";",
"}",
"}"
]
| Write the bytes as inline url.
@param formatter current formatter
@param bytes the bytes
@param urlStr used if mime type is null to detect the mime type
@param type the mime type | [
"Write",
"the",
"bytes",
"as",
"inline",
"url",
"."
]
| train | https://github.com/i-net-software/jlessc/blob/15b13e1637f6cc2e4d72df021e23ee0ca8d5e629/src/com/inet/lib/less/UrlUtils.java#L217-L246 |
trustathsh/ironcommon | src/main/java/de/hshannover/f4/trust/ironcommon/properties/Properties.java | Properties.set | public void set(String propertyPath, Object propertyValue)
throws PropertyException {
"""
Save the value with a given key. {@link Map} and {@link List} can only
contain simple data-types.
@param propertyPath
Example: foo.bar.key
@param propertyValue
only {@link String}, {@link Integer}, {@link Double},
{@link Boolean}, {@link Map} and {@link List} are supported
@throws PropertyException
If the propertyKey-Path is not a property key or is not part
of a property path.
"""
// check propertyPath
ObjectChecks
.checkForNullReference(propertyPath, "propertyPath is null");
// check propertyValue
if (!(propertyValue instanceof String)
&& !(propertyValue instanceof Integer)
&& !(propertyValue instanceof Double)
&& !(propertyValue instanceof Boolean)
&& !(propertyValue instanceof Map)
&& !(propertyValue instanceof List)) {
throw new PropertyException(
"Only String, int, double, boolean, Map and List are supported.");
}
// add the mPreFixPropertyPath if this Property is a copy with a deeper
// level
String fullPropertyPath = addPath(mPropertyPathPrefix, propertyPath);
// add propertyValue with the fullPropertyPath
addToRootMap(fullPropertyPath, propertyValue);
mLogger.debug("Set the property value: " + propertyValue + " on key: "
+ fullPropertyPath);
} | java | public void set(String propertyPath, Object propertyValue)
throws PropertyException {
// check propertyPath
ObjectChecks
.checkForNullReference(propertyPath, "propertyPath is null");
// check propertyValue
if (!(propertyValue instanceof String)
&& !(propertyValue instanceof Integer)
&& !(propertyValue instanceof Double)
&& !(propertyValue instanceof Boolean)
&& !(propertyValue instanceof Map)
&& !(propertyValue instanceof List)) {
throw new PropertyException(
"Only String, int, double, boolean, Map and List are supported.");
}
// add the mPreFixPropertyPath if this Property is a copy with a deeper
// level
String fullPropertyPath = addPath(mPropertyPathPrefix, propertyPath);
// add propertyValue with the fullPropertyPath
addToRootMap(fullPropertyPath, propertyValue);
mLogger.debug("Set the property value: " + propertyValue + " on key: "
+ fullPropertyPath);
} | [
"public",
"void",
"set",
"(",
"String",
"propertyPath",
",",
"Object",
"propertyValue",
")",
"throws",
"PropertyException",
"{",
"// check propertyPath",
"ObjectChecks",
".",
"checkForNullReference",
"(",
"propertyPath",
",",
"\"propertyPath is null\"",
")",
";",
"// check propertyValue",
"if",
"(",
"!",
"(",
"propertyValue",
"instanceof",
"String",
")",
"&&",
"!",
"(",
"propertyValue",
"instanceof",
"Integer",
")",
"&&",
"!",
"(",
"propertyValue",
"instanceof",
"Double",
")",
"&&",
"!",
"(",
"propertyValue",
"instanceof",
"Boolean",
")",
"&&",
"!",
"(",
"propertyValue",
"instanceof",
"Map",
")",
"&&",
"!",
"(",
"propertyValue",
"instanceof",
"List",
")",
")",
"{",
"throw",
"new",
"PropertyException",
"(",
"\"Only String, int, double, boolean, Map and List are supported.\"",
")",
";",
"}",
"// add the mPreFixPropertyPath if this Property is a copy with a deeper",
"// level",
"String",
"fullPropertyPath",
"=",
"addPath",
"(",
"mPropertyPathPrefix",
",",
"propertyPath",
")",
";",
"// add propertyValue with the fullPropertyPath",
"addToRootMap",
"(",
"fullPropertyPath",
",",
"propertyValue",
")",
";",
"mLogger",
".",
"debug",
"(",
"\"Set the property value: \"",
"+",
"propertyValue",
"+",
"\" on key: \"",
"+",
"fullPropertyPath",
")",
";",
"}"
]
| Save the value with a given key. {@link Map} and {@link List} can only
contain simple data-types.
@param propertyPath
Example: foo.bar.key
@param propertyValue
only {@link String}, {@link Integer}, {@link Double},
{@link Boolean}, {@link Map} and {@link List} are supported
@throws PropertyException
If the propertyKey-Path is not a property key or is not part
of a property path. | [
"Save",
"the",
"value",
"with",
"a",
"given",
"key",
".",
"{",
"@link",
"Map",
"}",
"and",
"{",
"@link",
"List",
"}",
"can",
"only",
"contain",
"simple",
"data",
"-",
"types",
"."
]
| train | https://github.com/trustathsh/ironcommon/blob/fee589a9300ab16744ca12fafae4357dd18c9fcb/src/main/java/de/hshannover/f4/trust/ironcommon/properties/Properties.java#L539-L565 |
dlemmermann/PreferencesFX | preferencesfx/src/main/java/com/dlsc/preferencesfx/model/Category.java | Category.of | public static Category of(String description, Node itemIcon, Setting... settings) {
"""
Creates a new category from settings, if the settings shouldn't be individually grouped.
@param description Category name, for display in {@link CategoryView}
@param itemIcon Icon to be shown next to the category name
@param settings {@link Setting} to be shown in the {@link CategoryView}
@return initialized Category object
"""
return new Category(description, itemIcon, Group.of(settings));
} | java | public static Category of(String description, Node itemIcon, Setting... settings) {
return new Category(description, itemIcon, Group.of(settings));
} | [
"public",
"static",
"Category",
"of",
"(",
"String",
"description",
",",
"Node",
"itemIcon",
",",
"Setting",
"...",
"settings",
")",
"{",
"return",
"new",
"Category",
"(",
"description",
",",
"itemIcon",
",",
"Group",
".",
"of",
"(",
"settings",
")",
")",
";",
"}"
]
| Creates a new category from settings, if the settings shouldn't be individually grouped.
@param description Category name, for display in {@link CategoryView}
@param itemIcon Icon to be shown next to the category name
@param settings {@link Setting} to be shown in the {@link CategoryView}
@return initialized Category object | [
"Creates",
"a",
"new",
"category",
"from",
"settings",
"if",
"the",
"settings",
"shouldn",
"t",
"be",
"individually",
"grouped",
"."
]
| train | https://github.com/dlemmermann/PreferencesFX/blob/e06a49663ec949c2f7eb56e6b5952c030ed42d33/preferencesfx/src/main/java/com/dlsc/preferencesfx/model/Category.java#L128-L130 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java | JsonUtil.getDouble | public static double getDouble(JsonObject object, String field, double defaultValue) {
"""
Returns a field in a Json object as a double.
@param object the Json Object
@param field the field in the Json object to return
@param defaultValue a default value for the field if the field value is null
@return the Json field value as a double
"""
final JsonValue value = object.get(field);
if (value == null || value.isNull()) {
return defaultValue;
} else {
return value.asDouble();
}
} | java | public static double getDouble(JsonObject object, String field, double defaultValue) {
final JsonValue value = object.get(field);
if (value == null || value.isNull()) {
return defaultValue;
} else {
return value.asDouble();
}
} | [
"public",
"static",
"double",
"getDouble",
"(",
"JsonObject",
"object",
",",
"String",
"field",
",",
"double",
"defaultValue",
")",
"{",
"final",
"JsonValue",
"value",
"=",
"object",
".",
"get",
"(",
"field",
")",
";",
"if",
"(",
"value",
"==",
"null",
"||",
"value",
".",
"isNull",
"(",
")",
")",
"{",
"return",
"defaultValue",
";",
"}",
"else",
"{",
"return",
"value",
".",
"asDouble",
"(",
")",
";",
"}",
"}"
]
| Returns a field in a Json object as a double.
@param object the Json Object
@param field the field in the Json object to return
@param defaultValue a default value for the field if the field value is null
@return the Json field value as a double | [
"Returns",
"a",
"field",
"in",
"a",
"Json",
"object",
"as",
"a",
"double",
"."
]
| train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L120-L127 |
amplexus/java-flac-encoder | src/main/java/net/sourceforge/javaflacencoder/MetadataBlockStreamInfo.java | MetadataBlockStreamInfo.getStreamInfo | public static EncodedElement getStreamInfo(StreamConfiguration sc,
int minFrameSize, int maxFrameSize, long samplesInStream, byte[] md5Hash) {
"""
Create a FLAC StreamInfo metadata block with the given parameters. Because
of the data stored in a StreamInfo block, this should generally be created
only after all encoding is done.
@param sc StreamConfiguration used in this FLAC stream.
@param minFrameSize Size of smallest frame in FLAC stream.
@param maxFrameSize Size of largest frame in FLAC stream.
@param samplesInStream Total number of inter-channel audio samples in
FLAC stream.
@param md5Hash MD5 hash of the raw audio samples.
@return EncodedElement containing created StreamInfo block.
"""
int bytes = getByteSize();
EncodedElement ele = new EncodedElement(bytes, 0);
int encodedBitsPerSample = sc.getBitsPerSample()-1;
ele.addInt(sc.getMinBlockSize(), 16);
ele.addInt(sc.getMaxBlockSize(), 16);
ele.addInt(minFrameSize, 24);
ele.addInt(maxFrameSize, 24);
ele.addInt(sc.getSampleRate(), 20);
ele.addInt(sc.getChannelCount()-1, 3);
ele.addInt(encodedBitsPerSample, 5);
ele.addLong(samplesInStream, 36);
for(int i = 0; i < 16; i++) {
ele.addInt(md5Hash[i], 8);
}
return ele;
} | java | public static EncodedElement getStreamInfo(StreamConfiguration sc,
int minFrameSize, int maxFrameSize, long samplesInStream, byte[] md5Hash) {
int bytes = getByteSize();
EncodedElement ele = new EncodedElement(bytes, 0);
int encodedBitsPerSample = sc.getBitsPerSample()-1;
ele.addInt(sc.getMinBlockSize(), 16);
ele.addInt(sc.getMaxBlockSize(), 16);
ele.addInt(minFrameSize, 24);
ele.addInt(maxFrameSize, 24);
ele.addInt(sc.getSampleRate(), 20);
ele.addInt(sc.getChannelCount()-1, 3);
ele.addInt(encodedBitsPerSample, 5);
ele.addLong(samplesInStream, 36);
for(int i = 0; i < 16; i++) {
ele.addInt(md5Hash[i], 8);
}
return ele;
} | [
"public",
"static",
"EncodedElement",
"getStreamInfo",
"(",
"StreamConfiguration",
"sc",
",",
"int",
"minFrameSize",
",",
"int",
"maxFrameSize",
",",
"long",
"samplesInStream",
",",
"byte",
"[",
"]",
"md5Hash",
")",
"{",
"int",
"bytes",
"=",
"getByteSize",
"(",
")",
";",
"EncodedElement",
"ele",
"=",
"new",
"EncodedElement",
"(",
"bytes",
",",
"0",
")",
";",
"int",
"encodedBitsPerSample",
"=",
"sc",
".",
"getBitsPerSample",
"(",
")",
"-",
"1",
";",
"ele",
".",
"addInt",
"(",
"sc",
".",
"getMinBlockSize",
"(",
")",
",",
"16",
")",
";",
"ele",
".",
"addInt",
"(",
"sc",
".",
"getMaxBlockSize",
"(",
")",
",",
"16",
")",
";",
"ele",
".",
"addInt",
"(",
"minFrameSize",
",",
"24",
")",
";",
"ele",
".",
"addInt",
"(",
"maxFrameSize",
",",
"24",
")",
";",
"ele",
".",
"addInt",
"(",
"sc",
".",
"getSampleRate",
"(",
")",
",",
"20",
")",
";",
"ele",
".",
"addInt",
"(",
"sc",
".",
"getChannelCount",
"(",
")",
"-",
"1",
",",
"3",
")",
";",
"ele",
".",
"addInt",
"(",
"encodedBitsPerSample",
",",
"5",
")",
";",
"ele",
".",
"addLong",
"(",
"samplesInStream",
",",
"36",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"16",
";",
"i",
"++",
")",
"{",
"ele",
".",
"addInt",
"(",
"md5Hash",
"[",
"i",
"]",
",",
"8",
")",
";",
"}",
"return",
"ele",
";",
"}"
]
| Create a FLAC StreamInfo metadata block with the given parameters. Because
of the data stored in a StreamInfo block, this should generally be created
only after all encoding is done.
@param sc StreamConfiguration used in this FLAC stream.
@param minFrameSize Size of smallest frame in FLAC stream.
@param maxFrameSize Size of largest frame in FLAC stream.
@param samplesInStream Total number of inter-channel audio samples in
FLAC stream.
@param md5Hash MD5 hash of the raw audio samples.
@return EncodedElement containing created StreamInfo block. | [
"Create",
"a",
"FLAC",
"StreamInfo",
"metadata",
"block",
"with",
"the",
"given",
"parameters",
".",
"Because",
"of",
"the",
"data",
"stored",
"in",
"a",
"StreamInfo",
"block",
"this",
"should",
"generally",
"be",
"created",
"only",
"after",
"all",
"encoding",
"is",
"done",
"."
]
| train | https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/MetadataBlockStreamInfo.java#L65-L82 |
martinwithaar/Encryptor4j | src/main/java/org/encryptor4j/Encryptor.java | Encryptor.wrapInputStream | public CipherInputStream wrapInputStream(InputStream is, byte[] iv) throws GeneralSecurityException, IOException {
"""
<p>Wraps an <code>InputStream</code> with a <code>CipherInputStream</code> using this encryptor's cipher.</p>
<p>If an <code>ivLength</code> has been specified and <code>prependIV</code> is set to <code>true</code> this method
will try to read and consume an IV from the <code>InputStream</code> before wrapping it.</p>
@param is
@param iv
@return
@throws GeneralSecurityException
@throws IOException
"""
Cipher cipher = getCipher(true);
if(iv == null && ivLength > 0) {
if(prependIV) {
iv = new byte[ivLength];
is.read(iv);
} else {
throw new IllegalStateException("Could not obtain IV");
}
}
if(iv != null) {
cipher.init(Cipher.DECRYPT_MODE, getKey(), getAlgorithmParameterSpec(iv));
} else {
cipher.init(Cipher.DECRYPT_MODE, getKey());
}
return new CipherInputStream(is, cipher);
} | java | public CipherInputStream wrapInputStream(InputStream is, byte[] iv) throws GeneralSecurityException, IOException {
Cipher cipher = getCipher(true);
if(iv == null && ivLength > 0) {
if(prependIV) {
iv = new byte[ivLength];
is.read(iv);
} else {
throw new IllegalStateException("Could not obtain IV");
}
}
if(iv != null) {
cipher.init(Cipher.DECRYPT_MODE, getKey(), getAlgorithmParameterSpec(iv));
} else {
cipher.init(Cipher.DECRYPT_MODE, getKey());
}
return new CipherInputStream(is, cipher);
} | [
"public",
"CipherInputStream",
"wrapInputStream",
"(",
"InputStream",
"is",
",",
"byte",
"[",
"]",
"iv",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"Cipher",
"cipher",
"=",
"getCipher",
"(",
"true",
")",
";",
"if",
"(",
"iv",
"==",
"null",
"&&",
"ivLength",
">",
"0",
")",
"{",
"if",
"(",
"prependIV",
")",
"{",
"iv",
"=",
"new",
"byte",
"[",
"ivLength",
"]",
";",
"is",
".",
"read",
"(",
"iv",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not obtain IV\"",
")",
";",
"}",
"}",
"if",
"(",
"iv",
"!=",
"null",
")",
"{",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"DECRYPT_MODE",
",",
"getKey",
"(",
")",
",",
"getAlgorithmParameterSpec",
"(",
"iv",
")",
")",
";",
"}",
"else",
"{",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"DECRYPT_MODE",
",",
"getKey",
"(",
")",
")",
";",
"}",
"return",
"new",
"CipherInputStream",
"(",
"is",
",",
"cipher",
")",
";",
"}"
]
| <p>Wraps an <code>InputStream</code> with a <code>CipherInputStream</code> using this encryptor's cipher.</p>
<p>If an <code>ivLength</code> has been specified and <code>prependIV</code> is set to <code>true</code> this method
will try to read and consume an IV from the <code>InputStream</code> before wrapping it.</p>
@param is
@param iv
@return
@throws GeneralSecurityException
@throws IOException | [
"<p",
">",
"Wraps",
"an",
"<code",
">",
"InputStream<",
"/",
"code",
">",
"with",
"a",
"<code",
">",
"CipherInputStream<",
"/",
"code",
">",
"using",
"this",
"encryptor",
"s",
"cipher",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"an",
"<code",
">",
"ivLength<",
"/",
"code",
">",
"has",
"been",
"specified",
"and",
"<code",
">",
"prependIV<",
"/",
"code",
">",
"is",
"set",
"to",
"<code",
">",
"true<",
"/",
"code",
">",
"this",
"method",
"will",
"try",
"to",
"read",
"and",
"consume",
"an",
"IV",
"from",
"the",
"<code",
">",
"InputStream<",
"/",
"code",
">",
"before",
"wrapping",
"it",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/martinwithaar/Encryptor4j/blob/8c31d84d9136309f59d810323ed68d902b9bac55/src/main/java/org/encryptor4j/Encryptor.java#L347-L363 |
ginere/ginere-base | src/main/java/eu/ginere/base/util/i18n/I18NConnector.java | I18NConnector.getLabel | public static String getLabel(Language lang, String section, String idInSection) {
"""
Returns the valur for this label (section|idInsection) for this lang
@param lang
@param section
@param idInSection
@return
"""
if (idInSection==null || "".equals(idInSection)){
log.warn("Empty label for section:"+section+" and lang:"+lang);
return "";
} else if (lang.isDebug()){
return lang.getLanguageId()+"|"+idInSection+"|"+section;
} else {
return connector.i18nLabel(lang, section, idInSection);
}
} | java | public static String getLabel(Language lang, String section, String idInSection) {
if (idInSection==null || "".equals(idInSection)){
log.warn("Empty label for section:"+section+" and lang:"+lang);
return "";
} else if (lang.isDebug()){
return lang.getLanguageId()+"|"+idInSection+"|"+section;
} else {
return connector.i18nLabel(lang, section, idInSection);
}
} | [
"public",
"static",
"String",
"getLabel",
"(",
"Language",
"lang",
",",
"String",
"section",
",",
"String",
"idInSection",
")",
"{",
"if",
"(",
"idInSection",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"idInSection",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"Empty label for section:\"",
"+",
"section",
"+",
"\" and lang:\"",
"+",
"lang",
")",
";",
"return",
"\"\"",
";",
"}",
"else",
"if",
"(",
"lang",
".",
"isDebug",
"(",
")",
")",
"{",
"return",
"lang",
".",
"getLanguageId",
"(",
")",
"+",
"\"|\"",
"+",
"idInSection",
"+",
"\"|\"",
"+",
"section",
";",
"}",
"else",
"{",
"return",
"connector",
".",
"i18nLabel",
"(",
"lang",
",",
"section",
",",
"idInSection",
")",
";",
"}",
"}"
]
| Returns the valur for this label (section|idInsection) for this lang
@param lang
@param section
@param idInSection
@return | [
"Returns",
"the",
"valur",
"for",
"this",
"label",
"(",
"section|idInsection",
")",
"for",
"this",
"lang"
]
| train | https://github.com/ginere/ginere-base/blob/b1cc1c5834bd8a31df475c6f3fc0ee51273c5a24/src/main/java/eu/ginere/base/util/i18n/I18NConnector.java#L67-L76 |
apereo/cas | support/cas-server-support-saml-core-api/src/main/java/org/apereo/cas/support/saml/SamlUtils.java | SamlUtils.logSamlObject | public static String logSamlObject(final OpenSamlConfigBean configBean, final XMLObject samlObject) throws SamlException {
"""
Log saml object.
@param configBean the config bean
@param samlObject the saml object
@return the string
@throws SamlException the saml exception
"""
val repeat = "*".repeat(SAML_OBJECT_LOG_ASTERIXLINE_LENGTH);
LOGGER.debug(repeat);
try (val writer = transformSamlObject(configBean, samlObject, true)) {
LOGGER.debug("Logging [{}]\n\n[{}]\n\n", samlObject.getClass().getName(), writer);
LOGGER.debug(repeat);
return writer.toString();
} catch (final Exception e) {
throw new SamlException(e.getMessage(), e);
}
} | java | public static String logSamlObject(final OpenSamlConfigBean configBean, final XMLObject samlObject) throws SamlException {
val repeat = "*".repeat(SAML_OBJECT_LOG_ASTERIXLINE_LENGTH);
LOGGER.debug(repeat);
try (val writer = transformSamlObject(configBean, samlObject, true)) {
LOGGER.debug("Logging [{}]\n\n[{}]\n\n", samlObject.getClass().getName(), writer);
LOGGER.debug(repeat);
return writer.toString();
} catch (final Exception e) {
throw new SamlException(e.getMessage(), e);
}
} | [
"public",
"static",
"String",
"logSamlObject",
"(",
"final",
"OpenSamlConfigBean",
"configBean",
",",
"final",
"XMLObject",
"samlObject",
")",
"throws",
"SamlException",
"{",
"val",
"repeat",
"=",
"\"*\"",
".",
"repeat",
"(",
"SAML_OBJECT_LOG_ASTERIXLINE_LENGTH",
")",
";",
"LOGGER",
".",
"debug",
"(",
"repeat",
")",
";",
"try",
"(",
"val",
"writer",
"=",
"transformSamlObject",
"(",
"configBean",
",",
"samlObject",
",",
"true",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Logging [{}]\\n\\n[{}]\\n\\n\"",
",",
"samlObject",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"writer",
")",
";",
"LOGGER",
".",
"debug",
"(",
"repeat",
")",
";",
"return",
"writer",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SamlException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
]
| Log saml object.
@param configBean the config bean
@param samlObject the saml object
@return the string
@throws SamlException the saml exception | [
"Log",
"saml",
"object",
"."
]
| train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-saml-core-api/src/main/java/org/apereo/cas/support/saml/SamlUtils.java#L250-L260 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/modules/CmsCloneModuleThread.java | CmsCloneModuleThread.alterPrefix | private String alterPrefix(String word, String oldPrefix, String newPrefix) {
"""
Manipulates a string by cutting of a prefix, if present, and adding a new prefix.
@param word the string to be manipulated
@param oldPrefix the old prefix that should be replaced
@param newPrefix the new prefix that is added
@return the manipulated string
"""
if (word.startsWith(oldPrefix)) {
return word.replaceFirst(oldPrefix, newPrefix);
}
return (newPrefix + word);
} | java | private String alterPrefix(String word, String oldPrefix, String newPrefix) {
if (word.startsWith(oldPrefix)) {
return word.replaceFirst(oldPrefix, newPrefix);
}
return (newPrefix + word);
} | [
"private",
"String",
"alterPrefix",
"(",
"String",
"word",
",",
"String",
"oldPrefix",
",",
"String",
"newPrefix",
")",
"{",
"if",
"(",
"word",
".",
"startsWith",
"(",
"oldPrefix",
")",
")",
"{",
"return",
"word",
".",
"replaceFirst",
"(",
"oldPrefix",
",",
"newPrefix",
")",
";",
"}",
"return",
"(",
"newPrefix",
"+",
"word",
")",
";",
"}"
]
| Manipulates a string by cutting of a prefix, if present, and adding a new prefix.
@param word the string to be manipulated
@param oldPrefix the old prefix that should be replaced
@param newPrefix the new prefix that is added
@return the manipulated string | [
"Manipulates",
"a",
"string",
"by",
"cutting",
"of",
"a",
"prefix",
"if",
"present",
"and",
"adding",
"a",
"new",
"prefix",
"."
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/modules/CmsCloneModuleThread.java#L477-L483 |
whitesource/fs-agent | src/main/java/org/whitesource/agent/dependency/resolver/npm/NpmDependencyResolver.java | NpmDependencyResolver.collectPackageJsonDependencies | private Collection<DependencyInfo> collectPackageJsonDependencies(Collection<BomFile> packageJsons) {
"""
Collect dependencies from package.json files - without 'npm ls'
"""
Collection<DependencyInfo> dependencies = new LinkedList<>();
ConcurrentHashMap<DependencyInfo, BomFile> dependencyPackageJsonMap = new ConcurrentHashMap<>();
ExecutorService executorService = Executors.newWorkStealingPool(NUM_THREADS);
Collection<EnrichDependency> threadsCollection = new LinkedList<>();
for (BomFile packageJson : packageJsons) {
if (packageJson != null && packageJson.isValid()) {
// do not add new dependencies if 'npm ls' already returned all
DependencyInfo dependency = new DependencyInfo();
dependencies.add(dependency);
threadsCollection.add(new EnrichDependency(packageJson, dependency, dependencyPackageJsonMap, npmAccessToken));
logger.debug("Collect package.json of the dependency in the file: {}", dependency.getFilename());
}
}
runThreadCollection(executorService, threadsCollection);
logger.debug("set hierarchy of the dependencies");
// remove duplicates dependencies
Map<String, DependencyInfo> existDependencies = new HashMap<>();
Map<DependencyInfo, BomFile> dependencyPackageJsonMapWithoutDuplicates = new HashMap<>();
for (Map.Entry<DependencyInfo, BomFile> entry : dependencyPackageJsonMap.entrySet()) {
DependencyInfo keyDep = entry.getKey();
String key = keyDep.getSha1() + keyDep.getVersion() + keyDep.getArtifactId();
if (!existDependencies.containsKey(key)) {
existDependencies.put(key, keyDep);
dependencyPackageJsonMapWithoutDuplicates.put(keyDep, entry.getValue());
}
}
setHierarchy(dependencyPackageJsonMapWithoutDuplicates, existDependencies);
return existDependencies.values();
} | java | private Collection<DependencyInfo> collectPackageJsonDependencies(Collection<BomFile> packageJsons) {
Collection<DependencyInfo> dependencies = new LinkedList<>();
ConcurrentHashMap<DependencyInfo, BomFile> dependencyPackageJsonMap = new ConcurrentHashMap<>();
ExecutorService executorService = Executors.newWorkStealingPool(NUM_THREADS);
Collection<EnrichDependency> threadsCollection = new LinkedList<>();
for (BomFile packageJson : packageJsons) {
if (packageJson != null && packageJson.isValid()) {
// do not add new dependencies if 'npm ls' already returned all
DependencyInfo dependency = new DependencyInfo();
dependencies.add(dependency);
threadsCollection.add(new EnrichDependency(packageJson, dependency, dependencyPackageJsonMap, npmAccessToken));
logger.debug("Collect package.json of the dependency in the file: {}", dependency.getFilename());
}
}
runThreadCollection(executorService, threadsCollection);
logger.debug("set hierarchy of the dependencies");
// remove duplicates dependencies
Map<String, DependencyInfo> existDependencies = new HashMap<>();
Map<DependencyInfo, BomFile> dependencyPackageJsonMapWithoutDuplicates = new HashMap<>();
for (Map.Entry<DependencyInfo, BomFile> entry : dependencyPackageJsonMap.entrySet()) {
DependencyInfo keyDep = entry.getKey();
String key = keyDep.getSha1() + keyDep.getVersion() + keyDep.getArtifactId();
if (!existDependencies.containsKey(key)) {
existDependencies.put(key, keyDep);
dependencyPackageJsonMapWithoutDuplicates.put(keyDep, entry.getValue());
}
}
setHierarchy(dependencyPackageJsonMapWithoutDuplicates, existDependencies);
return existDependencies.values();
} | [
"private",
"Collection",
"<",
"DependencyInfo",
">",
"collectPackageJsonDependencies",
"(",
"Collection",
"<",
"BomFile",
">",
"packageJsons",
")",
"{",
"Collection",
"<",
"DependencyInfo",
">",
"dependencies",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"ConcurrentHashMap",
"<",
"DependencyInfo",
",",
"BomFile",
">",
"dependencyPackageJsonMap",
"=",
"new",
"ConcurrentHashMap",
"<>",
"(",
")",
";",
"ExecutorService",
"executorService",
"=",
"Executors",
".",
"newWorkStealingPool",
"(",
"NUM_THREADS",
")",
";",
"Collection",
"<",
"EnrichDependency",
">",
"threadsCollection",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"for",
"(",
"BomFile",
"packageJson",
":",
"packageJsons",
")",
"{",
"if",
"(",
"packageJson",
"!=",
"null",
"&&",
"packageJson",
".",
"isValid",
"(",
")",
")",
"{",
"// do not add new dependencies if 'npm ls' already returned all",
"DependencyInfo",
"dependency",
"=",
"new",
"DependencyInfo",
"(",
")",
";",
"dependencies",
".",
"add",
"(",
"dependency",
")",
";",
"threadsCollection",
".",
"add",
"(",
"new",
"EnrichDependency",
"(",
"packageJson",
",",
"dependency",
",",
"dependencyPackageJsonMap",
",",
"npmAccessToken",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Collect package.json of the dependency in the file: {}\"",
",",
"dependency",
".",
"getFilename",
"(",
")",
")",
";",
"}",
"}",
"runThreadCollection",
"(",
"executorService",
",",
"threadsCollection",
")",
";",
"logger",
".",
"debug",
"(",
"\"set hierarchy of the dependencies\"",
")",
";",
"// remove duplicates dependencies",
"Map",
"<",
"String",
",",
"DependencyInfo",
">",
"existDependencies",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Map",
"<",
"DependencyInfo",
",",
"BomFile",
">",
"dependencyPackageJsonMapWithoutDuplicates",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"DependencyInfo",
",",
"BomFile",
">",
"entry",
":",
"dependencyPackageJsonMap",
".",
"entrySet",
"(",
")",
")",
"{",
"DependencyInfo",
"keyDep",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"String",
"key",
"=",
"keyDep",
".",
"getSha1",
"(",
")",
"+",
"keyDep",
".",
"getVersion",
"(",
")",
"+",
"keyDep",
".",
"getArtifactId",
"(",
")",
";",
"if",
"(",
"!",
"existDependencies",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"existDependencies",
".",
"put",
"(",
"key",
",",
"keyDep",
")",
";",
"dependencyPackageJsonMapWithoutDuplicates",
".",
"put",
"(",
"keyDep",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"setHierarchy",
"(",
"dependencyPackageJsonMapWithoutDuplicates",
",",
"existDependencies",
")",
";",
"return",
"existDependencies",
".",
"values",
"(",
")",
";",
"}"
]
| Collect dependencies from package.json files - without 'npm ls' | [
"Collect",
"dependencies",
"from",
"package",
".",
"json",
"files",
"-",
"without",
"npm",
"ls"
]
| train | https://github.com/whitesource/fs-agent/blob/d6ee4842c4f08f4aeda7eb2307b24c49b6bed0e1/src/main/java/org/whitesource/agent/dependency/resolver/npm/NpmDependencyResolver.java#L333-L362 |
HubSpot/Singularity | SingularityService/src/main/java/com/hubspot/singularity/data/SingularityValidator.java | SingularityValidator.getNewDayOfWeekValue | private String getNewDayOfWeekValue(String schedule, int dayOfWeekValue) {
"""
Standard cron: day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
Quartz: 1-7 or SUN-SAT
"""
String newDayOfWeekValue = null;
checkBadRequest(dayOfWeekValue >= 0 && dayOfWeekValue <= 7, "Schedule %s is invalid, day of week (%s) is not 0-7", schedule, dayOfWeekValue);
switch (dayOfWeekValue) {
case 7:
case 0:
newDayOfWeekValue = "SUN";
break;
case 1:
newDayOfWeekValue = "MON";
break;
case 2:
newDayOfWeekValue = "TUE";
break;
case 3:
newDayOfWeekValue = "WED";
break;
case 4:
newDayOfWeekValue = "THU";
break;
case 5:
newDayOfWeekValue = "FRI";
break;
case 6:
newDayOfWeekValue = "SAT";
break;
default:
badRequest("Schedule %s is invalid, day of week (%s) is not 0-7", schedule, dayOfWeekValue);
break;
}
return newDayOfWeekValue;
} | java | private String getNewDayOfWeekValue(String schedule, int dayOfWeekValue) {
String newDayOfWeekValue = null;
checkBadRequest(dayOfWeekValue >= 0 && dayOfWeekValue <= 7, "Schedule %s is invalid, day of week (%s) is not 0-7", schedule, dayOfWeekValue);
switch (dayOfWeekValue) {
case 7:
case 0:
newDayOfWeekValue = "SUN";
break;
case 1:
newDayOfWeekValue = "MON";
break;
case 2:
newDayOfWeekValue = "TUE";
break;
case 3:
newDayOfWeekValue = "WED";
break;
case 4:
newDayOfWeekValue = "THU";
break;
case 5:
newDayOfWeekValue = "FRI";
break;
case 6:
newDayOfWeekValue = "SAT";
break;
default:
badRequest("Schedule %s is invalid, day of week (%s) is not 0-7", schedule, dayOfWeekValue);
break;
}
return newDayOfWeekValue;
} | [
"private",
"String",
"getNewDayOfWeekValue",
"(",
"String",
"schedule",
",",
"int",
"dayOfWeekValue",
")",
"{",
"String",
"newDayOfWeekValue",
"=",
"null",
";",
"checkBadRequest",
"(",
"dayOfWeekValue",
">=",
"0",
"&&",
"dayOfWeekValue",
"<=",
"7",
",",
"\"Schedule %s is invalid, day of week (%s) is not 0-7\"",
",",
"schedule",
",",
"dayOfWeekValue",
")",
";",
"switch",
"(",
"dayOfWeekValue",
")",
"{",
"case",
"7",
":",
"case",
"0",
":",
"newDayOfWeekValue",
"=",
"\"SUN\"",
";",
"break",
";",
"case",
"1",
":",
"newDayOfWeekValue",
"=",
"\"MON\"",
";",
"break",
";",
"case",
"2",
":",
"newDayOfWeekValue",
"=",
"\"TUE\"",
";",
"break",
";",
"case",
"3",
":",
"newDayOfWeekValue",
"=",
"\"WED\"",
";",
"break",
";",
"case",
"4",
":",
"newDayOfWeekValue",
"=",
"\"THU\"",
";",
"break",
";",
"case",
"5",
":",
"newDayOfWeekValue",
"=",
"\"FRI\"",
";",
"break",
";",
"case",
"6",
":",
"newDayOfWeekValue",
"=",
"\"SAT\"",
";",
"break",
";",
"default",
":",
"badRequest",
"(",
"\"Schedule %s is invalid, day of week (%s) is not 0-7\"",
",",
"schedule",
",",
"dayOfWeekValue",
")",
";",
"break",
";",
"}",
"return",
"newDayOfWeekValue",
";",
"}"
]
| Standard cron: day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
Quartz: 1-7 or SUN-SAT | [
"Standard",
"cron",
":",
"day",
"of",
"week",
"(",
"0",
"-",
"6",
")",
"(",
"0",
"to",
"6",
"are",
"Sunday",
"to",
"Saturday",
"or",
"use",
"names",
";",
"7",
"is",
"Sunday",
"the",
"same",
"as",
"0",
")",
"Quartz",
":",
"1",
"-",
"7",
"or",
"SUN",
"-",
"SAT"
]
| train | https://github.com/HubSpot/Singularity/blob/384a8c16a10aa076af5ca45c8dfcedab9e5122c8/SingularityService/src/main/java/com/hubspot/singularity/data/SingularityValidator.java#L644-L678 |
Javacord/Javacord | javacord-api/src/main/java/org/javacord/api/DiscordApiBuilder.java | DiscordApiBuilder.loginShards | public Collection<CompletableFuture<DiscordApi>> loginShards(IntPredicate shardsCondition) {
"""
Login shards adhering to the given predicate to the account with the given token.
It is invalid to call {@link #setCurrentShard(int)} with
anything but {@code 0} before calling this method.
@param shardsCondition The predicate for identifying shards to connect, starting with {@code 0}!
@return A collection of {@link CompletableFuture}s which contain the {@code DiscordApi}s for the shards.
"""
return loginShards(IntStream.range(0, delegate.getTotalShards()).filter(shardsCondition).toArray());
} | java | public Collection<CompletableFuture<DiscordApi>> loginShards(IntPredicate shardsCondition) {
return loginShards(IntStream.range(0, delegate.getTotalShards()).filter(shardsCondition).toArray());
} | [
"public",
"Collection",
"<",
"CompletableFuture",
"<",
"DiscordApi",
">",
">",
"loginShards",
"(",
"IntPredicate",
"shardsCondition",
")",
"{",
"return",
"loginShards",
"(",
"IntStream",
".",
"range",
"(",
"0",
",",
"delegate",
".",
"getTotalShards",
"(",
")",
")",
".",
"filter",
"(",
"shardsCondition",
")",
".",
"toArray",
"(",
")",
")",
";",
"}"
]
| Login shards adhering to the given predicate to the account with the given token.
It is invalid to call {@link #setCurrentShard(int)} with
anything but {@code 0} before calling this method.
@param shardsCondition The predicate for identifying shards to connect, starting with {@code 0}!
@return A collection of {@link CompletableFuture}s which contain the {@code DiscordApi}s for the shards. | [
"Login",
"shards",
"adhering",
"to",
"the",
"given",
"predicate",
"to",
"the",
"account",
"with",
"the",
"given",
"token",
".",
"It",
"is",
"invalid",
"to",
"call",
"{",
"@link",
"#setCurrentShard",
"(",
"int",
")",
"}",
"with",
"anything",
"but",
"{",
"@code",
"0",
"}",
"before",
"calling",
"this",
"method",
"."
]
| train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-api/src/main/java/org/javacord/api/DiscordApiBuilder.java#L58-L60 |
datacleaner/DataCleaner | desktop/ui/src/main/java/org/datacleaner/widgets/visualization/JobGraphLinkPainter.java | JobGraphLinkPainter.startLink | public void startLink(final VertexContext startVertex) {
"""
Called when the drawing of a new link/edge is started
@param startVertex
"""
if (startVertex == null) {
return;
}
final AbstractLayout<Object, JobGraphLink> graphLayout = _graphContext.getGraphLayout();
final int x = (int) graphLayout.getX(startVertex.getVertex());
final int y = (int) graphLayout.getY(startVertex.getVertex());
logger.debug("startLink({})", startVertex);
_startVertex = startVertex;
_startPoint = new Point(x, y);
transformEdgeShape(_startPoint, _startPoint);
_graphContext.getVisualizationViewer().addPostRenderPaintable(_edgePaintable);
transformArrowShape(_startPoint, _startPoint);
_graphContext.getVisualizationViewer().addPostRenderPaintable(_arrowPaintable);
} | java | public void startLink(final VertexContext startVertex) {
if (startVertex == null) {
return;
}
final AbstractLayout<Object, JobGraphLink> graphLayout = _graphContext.getGraphLayout();
final int x = (int) graphLayout.getX(startVertex.getVertex());
final int y = (int) graphLayout.getY(startVertex.getVertex());
logger.debug("startLink({})", startVertex);
_startVertex = startVertex;
_startPoint = new Point(x, y);
transformEdgeShape(_startPoint, _startPoint);
_graphContext.getVisualizationViewer().addPostRenderPaintable(_edgePaintable);
transformArrowShape(_startPoint, _startPoint);
_graphContext.getVisualizationViewer().addPostRenderPaintable(_arrowPaintable);
} | [
"public",
"void",
"startLink",
"(",
"final",
"VertexContext",
"startVertex",
")",
"{",
"if",
"(",
"startVertex",
"==",
"null",
")",
"{",
"return",
";",
"}",
"final",
"AbstractLayout",
"<",
"Object",
",",
"JobGraphLink",
">",
"graphLayout",
"=",
"_graphContext",
".",
"getGraphLayout",
"(",
")",
";",
"final",
"int",
"x",
"=",
"(",
"int",
")",
"graphLayout",
".",
"getX",
"(",
"startVertex",
".",
"getVertex",
"(",
")",
")",
";",
"final",
"int",
"y",
"=",
"(",
"int",
")",
"graphLayout",
".",
"getY",
"(",
"startVertex",
".",
"getVertex",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"startLink({})\"",
",",
"startVertex",
")",
";",
"_startVertex",
"=",
"startVertex",
";",
"_startPoint",
"=",
"new",
"Point",
"(",
"x",
",",
"y",
")",
";",
"transformEdgeShape",
"(",
"_startPoint",
",",
"_startPoint",
")",
";",
"_graphContext",
".",
"getVisualizationViewer",
"(",
")",
".",
"addPostRenderPaintable",
"(",
"_edgePaintable",
")",
";",
"transformArrowShape",
"(",
"_startPoint",
",",
"_startPoint",
")",
";",
"_graphContext",
".",
"getVisualizationViewer",
"(",
")",
".",
"addPostRenderPaintable",
"(",
"_arrowPaintable",
")",
";",
"}"
]
| Called when the drawing of a new link/edge is started
@param startVertex | [
"Called",
"when",
"the",
"drawing",
"of",
"a",
"new",
"link",
"/",
"edge",
"is",
"started"
]
| train | https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/desktop/ui/src/main/java/org/datacleaner/widgets/visualization/JobGraphLinkPainter.java#L154-L172 |
TheHortonMachine/hortonmachine | dbs/src/main/java/org/hortonmachine/ssh/SshUtilities.java | SshUtilities.runShellCommand | public static String runShellCommand( Session session, String command ) throws JSchException, IOException {
"""
Launch a shell command.
@param session the session to use.
@param command the command to launch.
@return the output of the command.
@throws JSchException
@throws IOException
"""
String remoteResponseStr = launchACommand(session, command);
return remoteResponseStr;
} | java | public static String runShellCommand( Session session, String command ) throws JSchException, IOException {
String remoteResponseStr = launchACommand(session, command);
return remoteResponseStr;
} | [
"public",
"static",
"String",
"runShellCommand",
"(",
"Session",
"session",
",",
"String",
"command",
")",
"throws",
"JSchException",
",",
"IOException",
"{",
"String",
"remoteResponseStr",
"=",
"launchACommand",
"(",
"session",
",",
"command",
")",
";",
"return",
"remoteResponseStr",
";",
"}"
]
| Launch a shell command.
@param session the session to use.
@param command the command to launch.
@return the output of the command.
@throws JSchException
@throws IOException | [
"Launch",
"a",
"shell",
"command",
"."
]
| train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/dbs/src/main/java/org/hortonmachine/ssh/SshUtilities.java#L280-L283 |
Squarespace/cldr | compiler/src/main/java/com/squarespace/cldr/codegen/CalendarCodeGenerator.java | CalendarCodeGenerator.addWrapper | private void addWrapper(MethodSpec.Builder method, String pattern) {
"""
Formats a date-time combination into a wrapper format, e.g. "{1} at {0}"
"""
method.addComment("$S", pattern);
for (Node node : WRAPPER_PARSER.parseWrapper(pattern)) {
if (node instanceof Text) {
method.addStatement("b.append($S)", ((Text)node).text());
} else if (node instanceof Field) {
Field field = (Field)node;
switch (field.ch()) {
case '0':
method.beginControlFlow("if (timeType != null)");
method.addStatement("formatTime(timeType, d, b)");
method.nextControlFlow("else");
method.addStatement("formatSkeleton(timeSkel, d, b)");
method.endControlFlow();
break;
case '1':
method.beginControlFlow("if (dateType != null)");
method.addStatement("formatDate(dateType, d, b)");
method.nextControlFlow("else");
method.addStatement("formatSkeleton(dateSkel, d, b)");
method.endControlFlow();
break;
}
}
}
} | java | private void addWrapper(MethodSpec.Builder method, String pattern) {
method.addComment("$S", pattern);
for (Node node : WRAPPER_PARSER.parseWrapper(pattern)) {
if (node instanceof Text) {
method.addStatement("b.append($S)", ((Text)node).text());
} else if (node instanceof Field) {
Field field = (Field)node;
switch (field.ch()) {
case '0':
method.beginControlFlow("if (timeType != null)");
method.addStatement("formatTime(timeType, d, b)");
method.nextControlFlow("else");
method.addStatement("formatSkeleton(timeSkel, d, b)");
method.endControlFlow();
break;
case '1':
method.beginControlFlow("if (dateType != null)");
method.addStatement("formatDate(dateType, d, b)");
method.nextControlFlow("else");
method.addStatement("formatSkeleton(dateSkel, d, b)");
method.endControlFlow();
break;
}
}
}
} | [
"private",
"void",
"addWrapper",
"(",
"MethodSpec",
".",
"Builder",
"method",
",",
"String",
"pattern",
")",
"{",
"method",
".",
"addComment",
"(",
"\"$S\"",
",",
"pattern",
")",
";",
"for",
"(",
"Node",
"node",
":",
"WRAPPER_PARSER",
".",
"parseWrapper",
"(",
"pattern",
")",
")",
"{",
"if",
"(",
"node",
"instanceof",
"Text",
")",
"{",
"method",
".",
"addStatement",
"(",
"\"b.append($S)\"",
",",
"(",
"(",
"Text",
")",
"node",
")",
".",
"text",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"node",
"instanceof",
"Field",
")",
"{",
"Field",
"field",
"=",
"(",
"Field",
")",
"node",
";",
"switch",
"(",
"field",
".",
"ch",
"(",
")",
")",
"{",
"case",
"'",
"'",
":",
"method",
".",
"beginControlFlow",
"(",
"\"if (timeType != null)\"",
")",
";",
"method",
".",
"addStatement",
"(",
"\"formatTime(timeType, d, b)\"",
")",
";",
"method",
".",
"nextControlFlow",
"(",
"\"else\"",
")",
";",
"method",
".",
"addStatement",
"(",
"\"formatSkeleton(timeSkel, d, b)\"",
")",
";",
"method",
".",
"endControlFlow",
"(",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"method",
".",
"beginControlFlow",
"(",
"\"if (dateType != null)\"",
")",
";",
"method",
".",
"addStatement",
"(",
"\"formatDate(dateType, d, b)\"",
")",
";",
"method",
".",
"nextControlFlow",
"(",
"\"else\"",
")",
";",
"method",
".",
"addStatement",
"(",
"\"formatSkeleton(dateSkel, d, b)\"",
")",
";",
"method",
".",
"endControlFlow",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
]
| Formats a date-time combination into a wrapper format, e.g. "{1} at {0}" | [
"Formats",
"a",
"date",
"-",
"time",
"combination",
"into",
"a",
"wrapper",
"format",
"e",
".",
"g",
".",
"{",
"1",
"}",
"at",
"{",
"0",
"}"
]
| train | https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CalendarCodeGenerator.java#L345-L372 |
apache/flink | flink-connectors/flink-connector-elasticsearch-base/src/main/java/org/apache/flink/streaming/connectors/elasticsearch/ElasticsearchSinkBase.java | ElasticsearchSinkBase.buildBulkProcessor | @VisibleForTesting
protected BulkProcessor buildBulkProcessor(BulkProcessor.Listener listener) {
"""
Build the {@link BulkProcessor}.
<p>Note: this is exposed for testing purposes.
"""
checkNotNull(listener);
BulkProcessor.Builder bulkProcessorBuilder = callBridge.createBulkProcessorBuilder(client, listener);
// This makes flush() blocking
bulkProcessorBuilder.setConcurrentRequests(0);
if (bulkProcessorFlushMaxActions != null) {
bulkProcessorBuilder.setBulkActions(bulkProcessorFlushMaxActions);
}
if (bulkProcessorFlushMaxSizeMb != null) {
bulkProcessorBuilder.setBulkSize(new ByteSizeValue(bulkProcessorFlushMaxSizeMb, ByteSizeUnit.MB));
}
if (bulkProcessorFlushIntervalMillis != null) {
bulkProcessorBuilder.setFlushInterval(TimeValue.timeValueMillis(bulkProcessorFlushIntervalMillis));
}
// if backoff retrying is disabled, bulkProcessorFlushBackoffPolicy will be null
callBridge.configureBulkProcessorBackoff(bulkProcessorBuilder, bulkProcessorFlushBackoffPolicy);
return bulkProcessorBuilder.build();
} | java | @VisibleForTesting
protected BulkProcessor buildBulkProcessor(BulkProcessor.Listener listener) {
checkNotNull(listener);
BulkProcessor.Builder bulkProcessorBuilder = callBridge.createBulkProcessorBuilder(client, listener);
// This makes flush() blocking
bulkProcessorBuilder.setConcurrentRequests(0);
if (bulkProcessorFlushMaxActions != null) {
bulkProcessorBuilder.setBulkActions(bulkProcessorFlushMaxActions);
}
if (bulkProcessorFlushMaxSizeMb != null) {
bulkProcessorBuilder.setBulkSize(new ByteSizeValue(bulkProcessorFlushMaxSizeMb, ByteSizeUnit.MB));
}
if (bulkProcessorFlushIntervalMillis != null) {
bulkProcessorBuilder.setFlushInterval(TimeValue.timeValueMillis(bulkProcessorFlushIntervalMillis));
}
// if backoff retrying is disabled, bulkProcessorFlushBackoffPolicy will be null
callBridge.configureBulkProcessorBackoff(bulkProcessorBuilder, bulkProcessorFlushBackoffPolicy);
return bulkProcessorBuilder.build();
} | [
"@",
"VisibleForTesting",
"protected",
"BulkProcessor",
"buildBulkProcessor",
"(",
"BulkProcessor",
".",
"Listener",
"listener",
")",
"{",
"checkNotNull",
"(",
"listener",
")",
";",
"BulkProcessor",
".",
"Builder",
"bulkProcessorBuilder",
"=",
"callBridge",
".",
"createBulkProcessorBuilder",
"(",
"client",
",",
"listener",
")",
";",
"// This makes flush() blocking",
"bulkProcessorBuilder",
".",
"setConcurrentRequests",
"(",
"0",
")",
";",
"if",
"(",
"bulkProcessorFlushMaxActions",
"!=",
"null",
")",
"{",
"bulkProcessorBuilder",
".",
"setBulkActions",
"(",
"bulkProcessorFlushMaxActions",
")",
";",
"}",
"if",
"(",
"bulkProcessorFlushMaxSizeMb",
"!=",
"null",
")",
"{",
"bulkProcessorBuilder",
".",
"setBulkSize",
"(",
"new",
"ByteSizeValue",
"(",
"bulkProcessorFlushMaxSizeMb",
",",
"ByteSizeUnit",
".",
"MB",
")",
")",
";",
"}",
"if",
"(",
"bulkProcessorFlushIntervalMillis",
"!=",
"null",
")",
"{",
"bulkProcessorBuilder",
".",
"setFlushInterval",
"(",
"TimeValue",
".",
"timeValueMillis",
"(",
"bulkProcessorFlushIntervalMillis",
")",
")",
";",
"}",
"// if backoff retrying is disabled, bulkProcessorFlushBackoffPolicy will be null",
"callBridge",
".",
"configureBulkProcessorBackoff",
"(",
"bulkProcessorBuilder",
",",
"bulkProcessorFlushBackoffPolicy",
")",
";",
"return",
"bulkProcessorBuilder",
".",
"build",
"(",
")",
";",
"}"
]
| Build the {@link BulkProcessor}.
<p>Note: this is exposed for testing purposes. | [
"Build",
"the",
"{",
"@link",
"BulkProcessor",
"}",
"."
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-elasticsearch-base/src/main/java/org/apache/flink/streaming/connectors/elasticsearch/ElasticsearchSinkBase.java#L351-L376 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/CrsUtilities.java | CrsUtilities.readProjectionFile | @SuppressWarnings("nls")
public static CoordinateReferenceSystem readProjectionFile( String filePath, String extension ) throws Exception {
"""
Reads a {@link CoordinateReferenceSystem} from a prj file.
@param filePath the path to the prj file or the connected datafile it sidecar file for.
@param extension the extension of the data file. If <code>null</code> it is assumed to be prj.
@return the read {@link CoordinateReferenceSystem}.
@throws Exception
"""
CoordinateReferenceSystem crs = null;
String prjPath = null;
String filePathLower = filePath.trim().toLowerCase();
if (filePathLower.endsWith(".prj")) {
// it is the prj file
prjPath = filePath;
} else if (extension != null && filePathLower.endsWith("." + extension)) {
// datafile was supplied (substitute extension)
int dotLoc = filePath.lastIndexOf(".");
prjPath = filePath.substring(0, dotLoc);
prjPath = prjPath + ".prj";
} else {
prjPath = filePath + ".prj";
}
File prjFile = new File(prjPath);
if (!prjFile.exists()) {
throw new ModelsIOException("The prj file doesn't exist: " + prjPath, "CRSUTILITIES");
}
String wkt = FileUtilities.readFile(prjFile);
crs = CRS.parseWKT(wkt);
return crs;
} | java | @SuppressWarnings("nls")
public static CoordinateReferenceSystem readProjectionFile( String filePath, String extension ) throws Exception {
CoordinateReferenceSystem crs = null;
String prjPath = null;
String filePathLower = filePath.trim().toLowerCase();
if (filePathLower.endsWith(".prj")) {
// it is the prj file
prjPath = filePath;
} else if (extension != null && filePathLower.endsWith("." + extension)) {
// datafile was supplied (substitute extension)
int dotLoc = filePath.lastIndexOf(".");
prjPath = filePath.substring(0, dotLoc);
prjPath = prjPath + ".prj";
} else {
prjPath = filePath + ".prj";
}
File prjFile = new File(prjPath);
if (!prjFile.exists()) {
throw new ModelsIOException("The prj file doesn't exist: " + prjPath, "CRSUTILITIES");
}
String wkt = FileUtilities.readFile(prjFile);
crs = CRS.parseWKT(wkt);
return crs;
} | [
"@",
"SuppressWarnings",
"(",
"\"nls\"",
")",
"public",
"static",
"CoordinateReferenceSystem",
"readProjectionFile",
"(",
"String",
"filePath",
",",
"String",
"extension",
")",
"throws",
"Exception",
"{",
"CoordinateReferenceSystem",
"crs",
"=",
"null",
";",
"String",
"prjPath",
"=",
"null",
";",
"String",
"filePathLower",
"=",
"filePath",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"filePathLower",
".",
"endsWith",
"(",
"\".prj\"",
")",
")",
"{",
"// it is the prj file",
"prjPath",
"=",
"filePath",
";",
"}",
"else",
"if",
"(",
"extension",
"!=",
"null",
"&&",
"filePathLower",
".",
"endsWith",
"(",
"\".\"",
"+",
"extension",
")",
")",
"{",
"// datafile was supplied (substitute extension)",
"int",
"dotLoc",
"=",
"filePath",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"prjPath",
"=",
"filePath",
".",
"substring",
"(",
"0",
",",
"dotLoc",
")",
";",
"prjPath",
"=",
"prjPath",
"+",
"\".prj\"",
";",
"}",
"else",
"{",
"prjPath",
"=",
"filePath",
"+",
"\".prj\"",
";",
"}",
"File",
"prjFile",
"=",
"new",
"File",
"(",
"prjPath",
")",
";",
"if",
"(",
"!",
"prjFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"ModelsIOException",
"(",
"\"The prj file doesn't exist: \"",
"+",
"prjPath",
",",
"\"CRSUTILITIES\"",
")",
";",
"}",
"String",
"wkt",
"=",
"FileUtilities",
".",
"readFile",
"(",
"prjFile",
")",
";",
"crs",
"=",
"CRS",
".",
"parseWKT",
"(",
"wkt",
")",
";",
"return",
"crs",
";",
"}"
]
| Reads a {@link CoordinateReferenceSystem} from a prj file.
@param filePath the path to the prj file or the connected datafile it sidecar file for.
@param extension the extension of the data file. If <code>null</code> it is assumed to be prj.
@return the read {@link CoordinateReferenceSystem}.
@throws Exception | [
"Reads",
"a",
"{",
"@link",
"CoordinateReferenceSystem",
"}",
"from",
"a",
"prj",
"file",
"."
]
| train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/CrsUtilities.java#L116-L140 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/util/CellPosition.java | CellPosition.of | public static CellPosition of(int row, int column) {
"""
CellAddressのインスタンスを作成する。
@param row 行番号 (0から始まる)
@param column 列番号 (0から始まる)
@return {@link CellPosition}のインスタンス
@throws IllegalArgumentException {@literal row < 0 || column < 0}
"""
ArgUtils.notMin(row, 0, "row");
ArgUtils.notMin(column, 0, "column");
return new CellPosition(row, column);
} | java | public static CellPosition of(int row, int column) {
ArgUtils.notMin(row, 0, "row");
ArgUtils.notMin(column, 0, "column");
return new CellPosition(row, column);
} | [
"public",
"static",
"CellPosition",
"of",
"(",
"int",
"row",
",",
"int",
"column",
")",
"{",
"ArgUtils",
".",
"notMin",
"(",
"row",
",",
"0",
",",
"\"row\"",
")",
";",
"ArgUtils",
".",
"notMin",
"(",
"column",
",",
"0",
",",
"\"column\"",
")",
";",
"return",
"new",
"CellPosition",
"(",
"row",
",",
"column",
")",
";",
"}"
]
| CellAddressのインスタンスを作成する。
@param row 行番号 (0から始まる)
@param column 列番号 (0から始まる)
@return {@link CellPosition}のインスタンス
@throws IllegalArgumentException {@literal row < 0 || column < 0} | [
"CellAddressのインスタンスを作成する。"
]
| train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/util/CellPosition.java#L62-L67 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpd/MPDUtility.java | MPDUtility.fileHexDump | public static final void fileHexDump(String fileName, byte[] data) {
"""
Writes a hex dump to a file for a large byte array.
@param fileName output file name
@param data target data
"""
try
{
FileOutputStream os = new FileOutputStream(fileName);
os.write(hexdump(data, true, 16, "").getBytes());
os.close();
}
catch (IOException ex)
{
ex.printStackTrace();
}
} | java | public static final void fileHexDump(String fileName, byte[] data)
{
try
{
FileOutputStream os = new FileOutputStream(fileName);
os.write(hexdump(data, true, 16, "").getBytes());
os.close();
}
catch (IOException ex)
{
ex.printStackTrace();
}
} | [
"public",
"static",
"final",
"void",
"fileHexDump",
"(",
"String",
"fileName",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"try",
"{",
"FileOutputStream",
"os",
"=",
"new",
"FileOutputStream",
"(",
"fileName",
")",
";",
"os",
".",
"write",
"(",
"hexdump",
"(",
"data",
",",
"true",
",",
"16",
",",
"\"\"",
")",
".",
"getBytes",
"(",
")",
")",
";",
"os",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
]
| Writes a hex dump to a file for a large byte array.
@param fileName output file name
@param data target data | [
"Writes",
"a",
"hex",
"dump",
"to",
"a",
"file",
"for",
"a",
"large",
"byte",
"array",
"."
]
| train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpd/MPDUtility.java#L465-L478 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejbcontainer/util/ScheduleExpressionParserException.java | ScheduleExpressionParserException.logError | public void logError(String moduleName, String beanName, String methodName) {
"""
Logs an error message corresponding to this exception.
@param moduleName the module name
@param beanName the bean name
"""
Tr.error(tc, ivError.getMessageId(), new Object[] { beanName, moduleName, methodName, ivField });
} | java | public void logError(String moduleName, String beanName, String methodName)
{
Tr.error(tc, ivError.getMessageId(), new Object[] { beanName, moduleName, methodName, ivField });
} | [
"public",
"void",
"logError",
"(",
"String",
"moduleName",
",",
"String",
"beanName",
",",
"String",
"methodName",
")",
"{",
"Tr",
".",
"error",
"(",
"tc",
",",
"ivError",
".",
"getMessageId",
"(",
")",
",",
"new",
"Object",
"[",
"]",
"{",
"beanName",
",",
"moduleName",
",",
"methodName",
",",
"ivField",
"}",
")",
";",
"}"
]
| Logs an error message corresponding to this exception.
@param moduleName the module name
@param beanName the bean name | [
"Logs",
"an",
"error",
"message",
"corresponding",
"to",
"this",
"exception",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/ejbcontainer/util/ScheduleExpressionParserException.java#L95-L98 |
zeroturnaround/zt-zip | src/main/java/org/zeroturnaround/zip/ZipUtil.java | ZipUtil.entryEquals | public static boolean entryEquals(ZipFile zf1, ZipFile zf2, String path1, String path2) {
"""
Compares two ZIP entries (byte-by-byte). .
@param zf1
first ZIP file.
@param zf2
second ZIP file.
@param path1
name of the first entry.
@param path2
name of the second entry.
@return <code>true</code> if the contents of the entries were same.
"""
try {
return doEntryEquals(zf1, zf2, path1, path2);
}
catch (IOException e) {
throw ZipExceptionUtil.rethrow(e);
}
} | java | public static boolean entryEquals(ZipFile zf1, ZipFile zf2, String path1, String path2) {
try {
return doEntryEquals(zf1, zf2, path1, path2);
}
catch (IOException e) {
throw ZipExceptionUtil.rethrow(e);
}
} | [
"public",
"static",
"boolean",
"entryEquals",
"(",
"ZipFile",
"zf1",
",",
"ZipFile",
"zf2",
",",
"String",
"path1",
",",
"String",
"path2",
")",
"{",
"try",
"{",
"return",
"doEntryEquals",
"(",
"zf1",
",",
"zf2",
",",
"path1",
",",
"path2",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"ZipExceptionUtil",
".",
"rethrow",
"(",
"e",
")",
";",
"}",
"}"
]
| Compares two ZIP entries (byte-by-byte). .
@param zf1
first ZIP file.
@param zf2
second ZIP file.
@param path1
name of the first entry.
@param path2
name of the second entry.
@return <code>true</code> if the contents of the entries were same. | [
"Compares",
"two",
"ZIP",
"entries",
"(",
"byte",
"-",
"by",
"-",
"byte",
")",
".",
"."
]
| train | https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/ZipUtil.java#L3263-L3270 |
google/closure-templates | java/src/com/google/template/soy/jssrc/internal/JsType.java | JsType.getValueCoercion | @Nullable
final Expression getValueCoercion(Expression value, Generator codeGenerator) {
"""
Generates code to coerce the value, returns {@code null} if no coercion is necessary.
"""
boolean needsProtoCoercion = coercionStrategies.contains(ValueCoercionStrategy.PROTO);
if (!needsProtoCoercion) {
return null;
}
Expression coercion =
value.castAs("?").dotAccess("$jspbMessageInstance").or(value, codeGenerator);
return coercionStrategies.contains(ValueCoercionStrategy.NULL)
? value.and(coercion, codeGenerator)
: coercion;
} | java | @Nullable
final Expression getValueCoercion(Expression value, Generator codeGenerator) {
boolean needsProtoCoercion = coercionStrategies.contains(ValueCoercionStrategy.PROTO);
if (!needsProtoCoercion) {
return null;
}
Expression coercion =
value.castAs("?").dotAccess("$jspbMessageInstance").or(value, codeGenerator);
return coercionStrategies.contains(ValueCoercionStrategy.NULL)
? value.and(coercion, codeGenerator)
: coercion;
} | [
"@",
"Nullable",
"final",
"Expression",
"getValueCoercion",
"(",
"Expression",
"value",
",",
"Generator",
"codeGenerator",
")",
"{",
"boolean",
"needsProtoCoercion",
"=",
"coercionStrategies",
".",
"contains",
"(",
"ValueCoercionStrategy",
".",
"PROTO",
")",
";",
"if",
"(",
"!",
"needsProtoCoercion",
")",
"{",
"return",
"null",
";",
"}",
"Expression",
"coercion",
"=",
"value",
".",
"castAs",
"(",
"\"?\"",
")",
".",
"dotAccess",
"(",
"\"$jspbMessageInstance\"",
")",
".",
"or",
"(",
"value",
",",
"codeGenerator",
")",
";",
"return",
"coercionStrategies",
".",
"contains",
"(",
"ValueCoercionStrategy",
".",
"NULL",
")",
"?",
"value",
".",
"and",
"(",
"coercion",
",",
"codeGenerator",
")",
":",
"coercion",
";",
"}"
]
| Generates code to coerce the value, returns {@code null} if no coercion is necessary. | [
"Generates",
"code",
"to",
"coerce",
"the",
"value",
"returns",
"{"
]
| train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/JsType.java#L548-L559 |
iig-uni-freiburg/SEWOL | ext/org/deckfour/xes/extension/std/XOrganizationalExtension.java | XOrganizationalExtension.assignRole | public void assignRole(XEvent event, String role) {
"""
Assigns the role attribute value for a given event.
@param event
Event to be modified.
@param resource
Role string to be assigned.
"""
if (role != null && role.trim().length() > 0) {
XAttributeLiteral attr = (XAttributeLiteral) ATTR_ROLE.clone();
attr.setValue(role.trim());
event.getAttributes().put(KEY_ROLE, attr);
}
} | java | public void assignRole(XEvent event, String role) {
if (role != null && role.trim().length() > 0) {
XAttributeLiteral attr = (XAttributeLiteral) ATTR_ROLE.clone();
attr.setValue(role.trim());
event.getAttributes().put(KEY_ROLE, attr);
}
} | [
"public",
"void",
"assignRole",
"(",
"XEvent",
"event",
",",
"String",
"role",
")",
"{",
"if",
"(",
"role",
"!=",
"null",
"&&",
"role",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"XAttributeLiteral",
"attr",
"=",
"(",
"XAttributeLiteral",
")",
"ATTR_ROLE",
".",
"clone",
"(",
")",
";",
"attr",
".",
"setValue",
"(",
"role",
".",
"trim",
"(",
")",
")",
";",
"event",
".",
"getAttributes",
"(",
")",
".",
"put",
"(",
"KEY_ROLE",
",",
"attr",
")",
";",
"}",
"}"
]
| Assigns the role attribute value for a given event.
@param event
Event to be modified.
@param resource
Role string to be assigned. | [
"Assigns",
"the",
"role",
"attribute",
"value",
"for",
"a",
"given",
"event",
"."
]
| train | https://github.com/iig-uni-freiburg/SEWOL/blob/e791cb07a6e62ecf837d760d58a25f32fbf6bbca/ext/org/deckfour/xes/extension/std/XOrganizationalExtension.java#L228-L234 |
alipay/sofa-rpc | extension-impl/extension-common/src/main/java/com/alipay/sofa/rpc/bootstrap/DefaultConsumerBootstrap.java | DefaultConsumerBootstrap.subscribeFromDirectUrl | protected List<ProviderGroup> subscribeFromDirectUrl(String directUrl) {
"""
Subscribe provider list from direct url
@param directUrl direct url of consume config
@return Provider group list
"""
List<ProviderGroup> result = new ArrayList<ProviderGroup>();
List<ProviderInfo> tmpProviderInfoList = new ArrayList<ProviderInfo>();
String[] providerStrs = StringUtils.splitWithCommaOrSemicolon(directUrl);
for (String providerStr : providerStrs) {
ProviderInfo providerInfo = convertToProviderInfo(providerStr);
if (providerInfo.getStaticAttr(ProviderInfoAttrs.ATTR_SOURCE) == null) {
providerInfo.setStaticAttr(ProviderInfoAttrs.ATTR_SOURCE, "direct");
}
tmpProviderInfoList.add(providerInfo);
}
result.add(new ProviderGroup(RpcConstants.ADDRESS_DIRECT_GROUP, tmpProviderInfoList));
return result;
} | java | protected List<ProviderGroup> subscribeFromDirectUrl(String directUrl) {
List<ProviderGroup> result = new ArrayList<ProviderGroup>();
List<ProviderInfo> tmpProviderInfoList = new ArrayList<ProviderInfo>();
String[] providerStrs = StringUtils.splitWithCommaOrSemicolon(directUrl);
for (String providerStr : providerStrs) {
ProviderInfo providerInfo = convertToProviderInfo(providerStr);
if (providerInfo.getStaticAttr(ProviderInfoAttrs.ATTR_SOURCE) == null) {
providerInfo.setStaticAttr(ProviderInfoAttrs.ATTR_SOURCE, "direct");
}
tmpProviderInfoList.add(providerInfo);
}
result.add(new ProviderGroup(RpcConstants.ADDRESS_DIRECT_GROUP, tmpProviderInfoList));
return result;
} | [
"protected",
"List",
"<",
"ProviderGroup",
">",
"subscribeFromDirectUrl",
"(",
"String",
"directUrl",
")",
"{",
"List",
"<",
"ProviderGroup",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"ProviderGroup",
">",
"(",
")",
";",
"List",
"<",
"ProviderInfo",
">",
"tmpProviderInfoList",
"=",
"new",
"ArrayList",
"<",
"ProviderInfo",
">",
"(",
")",
";",
"String",
"[",
"]",
"providerStrs",
"=",
"StringUtils",
".",
"splitWithCommaOrSemicolon",
"(",
"directUrl",
")",
";",
"for",
"(",
"String",
"providerStr",
":",
"providerStrs",
")",
"{",
"ProviderInfo",
"providerInfo",
"=",
"convertToProviderInfo",
"(",
"providerStr",
")",
";",
"if",
"(",
"providerInfo",
".",
"getStaticAttr",
"(",
"ProviderInfoAttrs",
".",
"ATTR_SOURCE",
")",
"==",
"null",
")",
"{",
"providerInfo",
".",
"setStaticAttr",
"(",
"ProviderInfoAttrs",
".",
"ATTR_SOURCE",
",",
"\"direct\"",
")",
";",
"}",
"tmpProviderInfoList",
".",
"add",
"(",
"providerInfo",
")",
";",
"}",
"result",
".",
"add",
"(",
"new",
"ProviderGroup",
"(",
"RpcConstants",
".",
"ADDRESS_DIRECT_GROUP",
",",
"tmpProviderInfoList",
")",
")",
";",
"return",
"result",
";",
"}"
]
| Subscribe provider list from direct url
@param directUrl direct url of consume config
@return Provider group list | [
"Subscribe",
"provider",
"list",
"from",
"direct",
"url"
]
| train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/extension-impl/extension-common/src/main/java/com/alipay/sofa/rpc/bootstrap/DefaultConsumerBootstrap.java#L278-L292 |
apereo/cas | support/cas-server-support-x509-core/src/main/java/org/apereo/cas/adaptors/x509/authentication/principal/X509CommonNameEDIPIPrincipalResolver.java | X509CommonNameEDIPIPrincipalResolver.isTokenCommonName | private static boolean isTokenCommonName(final String inToken) {
"""
This method determines whether or not the input token is the Common Name (CN).
@param inToken The input token to be tested
@return Returns boolean value indicating whether or not the token string is the Common Name (CN) number
"""
val st = new StringTokenizer(inToken, "=");
return st.nextToken().equals(COMMON_NAME_VAR);
} | java | private static boolean isTokenCommonName(final String inToken) {
val st = new StringTokenizer(inToken, "=");
return st.nextToken().equals(COMMON_NAME_VAR);
} | [
"private",
"static",
"boolean",
"isTokenCommonName",
"(",
"final",
"String",
"inToken",
")",
"{",
"val",
"st",
"=",
"new",
"StringTokenizer",
"(",
"inToken",
",",
"\"=\"",
")",
";",
"return",
"st",
".",
"nextToken",
"(",
")",
".",
"equals",
"(",
"COMMON_NAME_VAR",
")",
";",
"}"
]
| This method determines whether or not the input token is the Common Name (CN).
@param inToken The input token to be tested
@return Returns boolean value indicating whether or not the token string is the Common Name (CN) number | [
"This",
"method",
"determines",
"whether",
"or",
"not",
"the",
"input",
"token",
"is",
"the",
"Common",
"Name",
"(",
"CN",
")",
"."
]
| train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-x509-core/src/main/java/org/apereo/cas/adaptors/x509/authentication/principal/X509CommonNameEDIPIPrincipalResolver.java#L104-L107 |
apache/incubator-druid | server/src/main/java/org/apache/druid/server/QueryLifecycle.java | QueryLifecycle.runSimple | @SuppressWarnings("unchecked")
public <T> Sequence<T> runSimple(
final Query<T> query,
final AuthenticationResult authenticationResult,
@Nullable final String remoteAddress
) {
"""
For callers where simplicity is desired over flexibility. This method does it all in one call. If the request
is unauthorized, an IllegalStateException will be thrown. Logs and metrics are emitted when the Sequence is
either fully iterated or throws an exception.
@param query the query
@param authenticationResult authentication result indicating identity of the requester
@param remoteAddress remote address, for logging; or null if unknown
@return results
"""
initialize(query);
final Sequence<T> results;
try {
final Access access = authorize(authenticationResult);
if (!access.isAllowed()) {
throw new ISE("Unauthorized");
}
final QueryLifecycle.QueryResponse queryResponse = execute();
results = queryResponse.getResults();
}
catch (Throwable e) {
emitLogsAndMetrics(e, remoteAddress, -1);
throw e;
}
return Sequences.wrap(
results,
new SequenceWrapper()
{
@Override
public void after(final boolean isDone, final Throwable thrown)
{
emitLogsAndMetrics(thrown, remoteAddress, -1);
}
}
);
} | java | @SuppressWarnings("unchecked")
public <T> Sequence<T> runSimple(
final Query<T> query,
final AuthenticationResult authenticationResult,
@Nullable final String remoteAddress
)
{
initialize(query);
final Sequence<T> results;
try {
final Access access = authorize(authenticationResult);
if (!access.isAllowed()) {
throw new ISE("Unauthorized");
}
final QueryLifecycle.QueryResponse queryResponse = execute();
results = queryResponse.getResults();
}
catch (Throwable e) {
emitLogsAndMetrics(e, remoteAddress, -1);
throw e;
}
return Sequences.wrap(
results,
new SequenceWrapper()
{
@Override
public void after(final boolean isDone, final Throwable thrown)
{
emitLogsAndMetrics(thrown, remoteAddress, -1);
}
}
);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"Sequence",
"<",
"T",
">",
"runSimple",
"(",
"final",
"Query",
"<",
"T",
">",
"query",
",",
"final",
"AuthenticationResult",
"authenticationResult",
",",
"@",
"Nullable",
"final",
"String",
"remoteAddress",
")",
"{",
"initialize",
"(",
"query",
")",
";",
"final",
"Sequence",
"<",
"T",
">",
"results",
";",
"try",
"{",
"final",
"Access",
"access",
"=",
"authorize",
"(",
"authenticationResult",
")",
";",
"if",
"(",
"!",
"access",
".",
"isAllowed",
"(",
")",
")",
"{",
"throw",
"new",
"ISE",
"(",
"\"Unauthorized\"",
")",
";",
"}",
"final",
"QueryLifecycle",
".",
"QueryResponse",
"queryResponse",
"=",
"execute",
"(",
")",
";",
"results",
"=",
"queryResponse",
".",
"getResults",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"emitLogsAndMetrics",
"(",
"e",
",",
"remoteAddress",
",",
"-",
"1",
")",
";",
"throw",
"e",
";",
"}",
"return",
"Sequences",
".",
"wrap",
"(",
"results",
",",
"new",
"SequenceWrapper",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"after",
"(",
"final",
"boolean",
"isDone",
",",
"final",
"Throwable",
"thrown",
")",
"{",
"emitLogsAndMetrics",
"(",
"thrown",
",",
"remoteAddress",
",",
"-",
"1",
")",
";",
"}",
"}",
")",
";",
"}"
]
| For callers where simplicity is desired over flexibility. This method does it all in one call. If the request
is unauthorized, an IllegalStateException will be thrown. Logs and metrics are emitted when the Sequence is
either fully iterated or throws an exception.
@param query the query
@param authenticationResult authentication result indicating identity of the requester
@param remoteAddress remote address, for logging; or null if unknown
@return results | [
"For",
"callers",
"where",
"simplicity",
"is",
"desired",
"over",
"flexibility",
".",
"This",
"method",
"does",
"it",
"all",
"in",
"one",
"call",
".",
"If",
"the",
"request",
"is",
"unauthorized",
"an",
"IllegalStateException",
"will",
"be",
"thrown",
".",
"Logs",
"and",
"metrics",
"are",
"emitted",
"when",
"the",
"Sequence",
"is",
"either",
"fully",
"iterated",
"or",
"throws",
"an",
"exception",
"."
]
| train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/server/src/main/java/org/apache/druid/server/QueryLifecycle.java#L120-L156 |
nguillaumin/slick2d-maven | slick2d-core/src/main/java/org/newdawn/slick/fills/GradientFill.java | GradientFill.colorAt | public Color colorAt(Shape shape, float x, float y) {
"""
Get the colour that should be applied at the specified location
@param shape The shape being filled
@param x The x coordinate of the point being coloured
@param y The y coordinate of the point being coloured
@return The colour that should be applied based on the control points of this gradient
"""
if (local) {
return colorAt(x-shape.getCenterX(),y-shape.getCenterY());
} else {
return colorAt(x,y);
}
} | java | public Color colorAt(Shape shape, float x, float y) {
if (local) {
return colorAt(x-shape.getCenterX(),y-shape.getCenterY());
} else {
return colorAt(x,y);
}
} | [
"public",
"Color",
"colorAt",
"(",
"Shape",
"shape",
",",
"float",
"x",
",",
"float",
"y",
")",
"{",
"if",
"(",
"local",
")",
"{",
"return",
"colorAt",
"(",
"x",
"-",
"shape",
".",
"getCenterX",
"(",
")",
",",
"y",
"-",
"shape",
".",
"getCenterY",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"colorAt",
"(",
"x",
",",
"y",
")",
";",
"}",
"}"
]
| Get the colour that should be applied at the specified location
@param shape The shape being filled
@param x The x coordinate of the point being coloured
@param y The y coordinate of the point being coloured
@return The colour that should be applied based on the control points of this gradient | [
"Get",
"the",
"colour",
"that",
"should",
"be",
"applied",
"at",
"the",
"specified",
"location"
]
| train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/fills/GradientFill.java#L197-L203 |
OpenLiberty/open-liberty | dev/com.ibm.ws.http.plugin.merge/src/com/ibm/ws/http/plugin/merge/internal/PluginMergeToolImpl.java | PluginMergeToolImpl.nodeListRemoveAll | public static void nodeListRemoveAll(Element xEml, NodeList nodes) {
"""
Removes all nodes contained in the NodeList from the Element.
Convenience method because NodeList objects in the DOM are live.
@param xEml
@param nodes
"""
int cnt = nodes.getLength();
for (int i = 0; i < cnt; i++)
xEml.removeChild(nodes.item(0));
} | java | public static void nodeListRemoveAll(Element xEml, NodeList nodes) {
int cnt = nodes.getLength();
for (int i = 0; i < cnt; i++)
xEml.removeChild(nodes.item(0));
} | [
"public",
"static",
"void",
"nodeListRemoveAll",
"(",
"Element",
"xEml",
",",
"NodeList",
"nodes",
")",
"{",
"int",
"cnt",
"=",
"nodes",
".",
"getLength",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cnt",
";",
"i",
"++",
")",
"xEml",
".",
"removeChild",
"(",
"nodes",
".",
"item",
"(",
"0",
")",
")",
";",
"}"
]
| Removes all nodes contained in the NodeList from the Element.
Convenience method because NodeList objects in the DOM are live.
@param xEml
@param nodes | [
"Removes",
"all",
"nodes",
"contained",
"in",
"the",
"NodeList",
"from",
"the",
"Element",
".",
"Convenience",
"method",
"because",
"NodeList",
"objects",
"in",
"the",
"DOM",
"are",
"live",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.http.plugin.merge/src/com/ibm/ws/http/plugin/merge/internal/PluginMergeToolImpl.java#L432-L436 |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/AppEventsLogger.java | AppEventsLogger.logSdkEvent | public void logSdkEvent(String eventName, Double valueToSum, Bundle parameters) {
"""
This method is intended only for internal use by the Facebook SDK and other use is unsupported.
"""
logEvent(eventName, valueToSum, parameters, true);
} | java | public void logSdkEvent(String eventName, Double valueToSum, Bundle parameters) {
logEvent(eventName, valueToSum, parameters, true);
} | [
"public",
"void",
"logSdkEvent",
"(",
"String",
"eventName",
",",
"Double",
"valueToSum",
",",
"Bundle",
"parameters",
")",
"{",
"logEvent",
"(",
"eventName",
",",
"valueToSum",
",",
"parameters",
",",
"true",
")",
";",
"}"
]
| This method is intended only for internal use by the Facebook SDK and other use is unsupported. | [
"This",
"method",
"is",
"intended",
"only",
"for",
"internal",
"use",
"by",
"the",
"Facebook",
"SDK",
"and",
"other",
"use",
"is",
"unsupported",
"."
]
| train | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppEventsLogger.java#L564-L566 |
ocelotds/ocelot | ocelot-web/src/main/java/org/ocelotds/core/services/MethodServices.java | MethodServices.getMethodFromDataService | public Method getMethodFromDataService(final Class dsClass, final MessageFromClient message, List<Object> arguments) throws NoSuchMethodException {
"""
Get pertinent method and fill the argument list from message arguments
@param dsClass
@param message
@param arguments
@return
@throws java.lang.NoSuchMethodException
"""
logger.debug("Try to find method {} on class {}", message.getOperation(), dsClass);
List<String> parameters = message.getParameters();
int nbparam = parameters.size() - getNumberOfNullEnderParameter(parameters); // determine how many parameter is null at the end
List<Method> candidates = getSortedCandidateMethods(message.getOperation(), dsClass.getMethods()); // take only method with the good name, and orderedby number of arguments
if (!candidates.isEmpty()) {
while (nbparam <= parameters.size()) {
for (Method method : candidates) {
if (method.getParameterTypes().length == nbparam) {
logger.debug("Process method {}", method.getName());
try {
checkMethod(method, arguments, parameters, nbparam);
logger.debug("Method {}.{} with good signature found.", dsClass, message.getOperation());
return method;
} catch (JsonMarshallerException | JsonUnmarshallingException | IllegalArgumentException iae) {
logger.debug("Method {}.{} not found. Some arguments didn't match. {}.", new Object[]{dsClass, message.getOperation(), iae.getMessage()});
}
arguments.clear();
}
}
nbparam++;
}
}
throw new NoSuchMethodException(dsClass.getName() + "." + message.getOperation());
} | java | public Method getMethodFromDataService(final Class dsClass, final MessageFromClient message, List<Object> arguments) throws NoSuchMethodException {
logger.debug("Try to find method {} on class {}", message.getOperation(), dsClass);
List<String> parameters = message.getParameters();
int nbparam = parameters.size() - getNumberOfNullEnderParameter(parameters); // determine how many parameter is null at the end
List<Method> candidates = getSortedCandidateMethods(message.getOperation(), dsClass.getMethods()); // take only method with the good name, and orderedby number of arguments
if (!candidates.isEmpty()) {
while (nbparam <= parameters.size()) {
for (Method method : candidates) {
if (method.getParameterTypes().length == nbparam) {
logger.debug("Process method {}", method.getName());
try {
checkMethod(method, arguments, parameters, nbparam);
logger.debug("Method {}.{} with good signature found.", dsClass, message.getOperation());
return method;
} catch (JsonMarshallerException | JsonUnmarshallingException | IllegalArgumentException iae) {
logger.debug("Method {}.{} not found. Some arguments didn't match. {}.", new Object[]{dsClass, message.getOperation(), iae.getMessage()});
}
arguments.clear();
}
}
nbparam++;
}
}
throw new NoSuchMethodException(dsClass.getName() + "." + message.getOperation());
} | [
"public",
"Method",
"getMethodFromDataService",
"(",
"final",
"Class",
"dsClass",
",",
"final",
"MessageFromClient",
"message",
",",
"List",
"<",
"Object",
">",
"arguments",
")",
"throws",
"NoSuchMethodException",
"{",
"logger",
".",
"debug",
"(",
"\"Try to find method {} on class {}\"",
",",
"message",
".",
"getOperation",
"(",
")",
",",
"dsClass",
")",
";",
"List",
"<",
"String",
">",
"parameters",
"=",
"message",
".",
"getParameters",
"(",
")",
";",
"int",
"nbparam",
"=",
"parameters",
".",
"size",
"(",
")",
"-",
"getNumberOfNullEnderParameter",
"(",
"parameters",
")",
";",
"// determine how many parameter is null at the end\r",
"List",
"<",
"Method",
">",
"candidates",
"=",
"getSortedCandidateMethods",
"(",
"message",
".",
"getOperation",
"(",
")",
",",
"dsClass",
".",
"getMethods",
"(",
")",
")",
";",
"// take only method with the good name, and orderedby number of arguments\r",
"if",
"(",
"!",
"candidates",
".",
"isEmpty",
"(",
")",
")",
"{",
"while",
"(",
"nbparam",
"<=",
"parameters",
".",
"size",
"(",
")",
")",
"{",
"for",
"(",
"Method",
"method",
":",
"candidates",
")",
"{",
"if",
"(",
"method",
".",
"getParameterTypes",
"(",
")",
".",
"length",
"==",
"nbparam",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Process method {}\"",
",",
"method",
".",
"getName",
"(",
")",
")",
";",
"try",
"{",
"checkMethod",
"(",
"method",
",",
"arguments",
",",
"parameters",
",",
"nbparam",
")",
";",
"logger",
".",
"debug",
"(",
"\"Method {}.{} with good signature found.\",",
" ",
"sClass,",
" ",
"essage.",
"g",
"etOperation(",
")",
")",
";",
"\r",
"return",
"method",
";",
"}",
"catch",
"(",
"JsonMarshallerException",
"|",
"JsonUnmarshallingException",
"|",
"IllegalArgumentException",
"iae",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Method {}.{} not found. Some arguments didn't match. {}.\",",
" ",
"ew ",
"bject[",
"]",
"{",
"d",
"sClass,",
" ",
"essage.",
"g",
"etOperation(",
")",
",",
" ",
"ae.",
"g",
"etMessage(",
")",
"}",
")",
";",
"\r",
"}",
"arguments",
".",
"clear",
"(",
")",
";",
"}",
"}",
"nbparam",
"++",
";",
"}",
"}",
"throw",
"new",
"NoSuchMethodException",
"(",
"dsClass",
".",
"getName",
"(",
")",
"+",
"\".\"",
"+",
"message",
".",
"getOperation",
"(",
")",
")",
";",
"}"
]
| Get pertinent method and fill the argument list from message arguments
@param dsClass
@param message
@param arguments
@return
@throws java.lang.NoSuchMethodException | [
"Get",
"pertinent",
"method",
"and",
"fill",
"the",
"argument",
"list",
"from",
"message",
"arguments"
]
| train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/core/services/MethodServices.java#L44-L68 |
pryzach/midao | midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java | TypeHandlerUtils.convertClob | public static Object convertClob(Object clob, InputStream input) throws SQLException {
"""
Transfers data from InputStream into sql.Clob
<p/>
Using default locale. If different locale is required see
{@link #convertClob(java.sql.Connection, String)}
@param clob sql.Clob which would be filled
@param input InputStream
@return sql.Clob from InputStream
@throws SQLException
"""
return convertClob(clob, toByteArray(input));
} | java | public static Object convertClob(Object clob, InputStream input) throws SQLException {
return convertClob(clob, toByteArray(input));
} | [
"public",
"static",
"Object",
"convertClob",
"(",
"Object",
"clob",
",",
"InputStream",
"input",
")",
"throws",
"SQLException",
"{",
"return",
"convertClob",
"(",
"clob",
",",
"toByteArray",
"(",
"input",
")",
")",
";",
"}"
]
| Transfers data from InputStream into sql.Clob
<p/>
Using default locale. If different locale is required see
{@link #convertClob(java.sql.Connection, String)}
@param clob sql.Clob which would be filled
@param input InputStream
@return sql.Clob from InputStream
@throws SQLException | [
"Transfers",
"data",
"from",
"InputStream",
"into",
"sql",
".",
"Clob",
"<p",
"/",
">",
"Using",
"default",
"locale",
".",
"If",
"different",
"locale",
"is",
"required",
"see",
"{",
"@link",
"#convertClob",
"(",
"java",
".",
"sql",
".",
"Connection",
"String",
")",
"}"
]
| train | https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java#L261-L263 |
lightblueseas/vintage-time | src/main/java/de/alpharogroup/date/CreateDateExtensions.java | CreateDateExtensions.newDate | public static Date newDate(final int year, final int month, final int day, final int hour,
final int minute, final int seconds, final int milliSecond) {
"""
Creates a new Date object from the given values.
@param year
The year.
@param month
The month.
@param day
The day.
@param hour
The hour.
@param minute
The minute.
@param seconds
The second.
@param milliSecond
The millisecond.
@return Returns the created Date object.
"""
return newDate(year, month, day, hour, minute, seconds, milliSecond, TimeZone.getDefault(),
Locale.getDefault());
} | java | public static Date newDate(final int year, final int month, final int day, final int hour,
final int minute, final int seconds, final int milliSecond)
{
return newDate(year, month, day, hour, minute, seconds, milliSecond, TimeZone.getDefault(),
Locale.getDefault());
} | [
"public",
"static",
"Date",
"newDate",
"(",
"final",
"int",
"year",
",",
"final",
"int",
"month",
",",
"final",
"int",
"day",
",",
"final",
"int",
"hour",
",",
"final",
"int",
"minute",
",",
"final",
"int",
"seconds",
",",
"final",
"int",
"milliSecond",
")",
"{",
"return",
"newDate",
"(",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"seconds",
",",
"milliSecond",
",",
"TimeZone",
".",
"getDefault",
"(",
")",
",",
"Locale",
".",
"getDefault",
"(",
")",
")",
";",
"}"
]
| Creates a new Date object from the given values.
@param year
The year.
@param month
The month.
@param day
The day.
@param hour
The hour.
@param minute
The minute.
@param seconds
The second.
@param milliSecond
The millisecond.
@return Returns the created Date object. | [
"Creates",
"a",
"new",
"Date",
"object",
"from",
"the",
"given",
"values",
"."
]
| train | https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/CreateDateExtensions.java#L117-L122 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ch/Subtypes2.java | Subtypes2.isSubtype | public boolean isSubtype(ObjectType type, ObjectType possibleSupertype) throws ClassNotFoundException {
"""
Determine whether or not a given ObjectType is a subtype of another.
Throws ClassNotFoundException if the question cannot be answered
definitively due to a missing class.
@param type
a ReferenceType
@param possibleSupertype
another Reference type
@return true if <code>type</code> is a subtype of
<code>possibleSupertype</code>, false if not
@throws ClassNotFoundException
if a missing class prevents a definitive answer
"""
if (DEBUG_QUERIES) {
System.out.println("isSubtype: check " + type + " subtype of " + possibleSupertype);
}
if (type.equals(possibleSupertype)) {
if (DEBUG_QUERIES) {
System.out.println(" ==> yes, types are same");
}
return true;
}
ClassDescriptor typeClassDescriptor = DescriptorFactory.getClassDescriptor(type);
ClassDescriptor possibleSuperclassClassDescriptor = DescriptorFactory.getClassDescriptor(possibleSupertype);
return isSubtype(typeClassDescriptor, possibleSuperclassClassDescriptor);
} | java | public boolean isSubtype(ObjectType type, ObjectType possibleSupertype) throws ClassNotFoundException {
if (DEBUG_QUERIES) {
System.out.println("isSubtype: check " + type + " subtype of " + possibleSupertype);
}
if (type.equals(possibleSupertype)) {
if (DEBUG_QUERIES) {
System.out.println(" ==> yes, types are same");
}
return true;
}
ClassDescriptor typeClassDescriptor = DescriptorFactory.getClassDescriptor(type);
ClassDescriptor possibleSuperclassClassDescriptor = DescriptorFactory.getClassDescriptor(possibleSupertype);
return isSubtype(typeClassDescriptor, possibleSuperclassClassDescriptor);
} | [
"public",
"boolean",
"isSubtype",
"(",
"ObjectType",
"type",
",",
"ObjectType",
"possibleSupertype",
")",
"throws",
"ClassNotFoundException",
"{",
"if",
"(",
"DEBUG_QUERIES",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"isSubtype: check \"",
"+",
"type",
"+",
"\" subtype of \"",
"+",
"possibleSupertype",
")",
";",
"}",
"if",
"(",
"type",
".",
"equals",
"(",
"possibleSupertype",
")",
")",
"{",
"if",
"(",
"DEBUG_QUERIES",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\" ==> yes, types are same\"",
")",
";",
"}",
"return",
"true",
";",
"}",
"ClassDescriptor",
"typeClassDescriptor",
"=",
"DescriptorFactory",
".",
"getClassDescriptor",
"(",
"type",
")",
";",
"ClassDescriptor",
"possibleSuperclassClassDescriptor",
"=",
"DescriptorFactory",
".",
"getClassDescriptor",
"(",
"possibleSupertype",
")",
";",
"return",
"isSubtype",
"(",
"typeClassDescriptor",
",",
"possibleSuperclassClassDescriptor",
")",
";",
"}"
]
| Determine whether or not a given ObjectType is a subtype of another.
Throws ClassNotFoundException if the question cannot be answered
definitively due to a missing class.
@param type
a ReferenceType
@param possibleSupertype
another Reference type
@return true if <code>type</code> is a subtype of
<code>possibleSupertype</code>, false if not
@throws ClassNotFoundException
if a missing class prevents a definitive answer | [
"Determine",
"whether",
"or",
"not",
"a",
"given",
"ObjectType",
"is",
"a",
"subtype",
"of",
"another",
".",
"Throws",
"ClassNotFoundException",
"if",
"the",
"question",
"cannot",
"be",
"answered",
"definitively",
"due",
"to",
"a",
"missing",
"class",
"."
]
| train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ch/Subtypes2.java#L508-L523 |
pravega/pravega | common/src/main/java/io/pravega/common/util/BitConverter.java | BitConverter.writeInt | public static int writeInt(byte[] target, int offset, int value) {
"""
Writes the given 32-bit Integer to the given byte array at the given offset.
@param target The byte array to write to.
@param offset The offset within the byte array to write at.
@param value The value to write.
@return The number of bytes written.
"""
target[offset] = (byte) (value >>> 24);
target[offset + 1] = (byte) (value >>> 16);
target[offset + 2] = (byte) (value >>> 8);
target[offset + 3] = (byte) value;
return Integer.BYTES;
} | java | public static int writeInt(byte[] target, int offset, int value) {
target[offset] = (byte) (value >>> 24);
target[offset + 1] = (byte) (value >>> 16);
target[offset + 2] = (byte) (value >>> 8);
target[offset + 3] = (byte) value;
return Integer.BYTES;
} | [
"public",
"static",
"int",
"writeInt",
"(",
"byte",
"[",
"]",
"target",
",",
"int",
"offset",
",",
"int",
"value",
")",
"{",
"target",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"24",
")",
";",
"target",
"[",
"offset",
"+",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"16",
")",
";",
"target",
"[",
"offset",
"+",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"8",
")",
";",
"target",
"[",
"offset",
"+",
"3",
"]",
"=",
"(",
"byte",
")",
"value",
";",
"return",
"Integer",
".",
"BYTES",
";",
"}"
]
| Writes the given 32-bit Integer to the given byte array at the given offset.
@param target The byte array to write to.
@param offset The offset within the byte array to write at.
@param value The value to write.
@return The number of bytes written. | [
"Writes",
"the",
"given",
"32",
"-",
"bit",
"Integer",
"to",
"the",
"given",
"byte",
"array",
"at",
"the",
"given",
"offset",
"."
]
| train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/common/src/main/java/io/pravega/common/util/BitConverter.java#L68-L74 |
mercadopago/dx-java | src/main/java/com/mercadopago/core/MPBase.java | MPBase.fillResource | private static <T extends MPBase> T fillResource(T sourceResource, T destinationResource) throws MPException {
"""
Copies the atributes from an obj to a destination obj
@param sourceResource source resource obj
@param destinationResource destination resource obj
@param <T>
@return
@throws MPException
"""
Field[] declaredFields = destinationResource.getClass().getDeclaredFields();
for (Field field : declaredFields) {
try {
Field originField = sourceResource.getClass().getDeclaredField(field.getName());
field.setAccessible(true);
originField.setAccessible(true);
field.set(destinationResource, originField.get(sourceResource));
} catch (Exception ex) {
throw new MPException(ex);
}
}
return destinationResource;
} | java | private static <T extends MPBase> T fillResource(T sourceResource, T destinationResource) throws MPException {
Field[] declaredFields = destinationResource.getClass().getDeclaredFields();
for (Field field : declaredFields) {
try {
Field originField = sourceResource.getClass().getDeclaredField(field.getName());
field.setAccessible(true);
originField.setAccessible(true);
field.set(destinationResource, originField.get(sourceResource));
} catch (Exception ex) {
throw new MPException(ex);
}
}
return destinationResource;
} | [
"private",
"static",
"<",
"T",
"extends",
"MPBase",
">",
"T",
"fillResource",
"(",
"T",
"sourceResource",
",",
"T",
"destinationResource",
")",
"throws",
"MPException",
"{",
"Field",
"[",
"]",
"declaredFields",
"=",
"destinationResource",
".",
"getClass",
"(",
")",
".",
"getDeclaredFields",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"declaredFields",
")",
"{",
"try",
"{",
"Field",
"originField",
"=",
"sourceResource",
".",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"field",
".",
"getName",
"(",
")",
")",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"originField",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"destinationResource",
",",
"originField",
".",
"get",
"(",
"sourceResource",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"MPException",
"(",
"ex",
")",
";",
"}",
"}",
"return",
"destinationResource",
";",
"}"
]
| Copies the atributes from an obj to a destination obj
@param sourceResource source resource obj
@param destinationResource destination resource obj
@param <T>
@return
@throws MPException | [
"Copies",
"the",
"atributes",
"from",
"an",
"obj",
"to",
"a",
"destination",
"obj"
]
| train | https://github.com/mercadopago/dx-java/blob/9df65a6bfb4db0c1fddd7699a5b109643961b03f/src/main/java/com/mercadopago/core/MPBase.java#L393-L407 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/LabsInner.java | LabsInner.createOrUpdate | public LabInner createOrUpdate(String resourceGroupName, String labAccountName, String labName, LabInner lab) {
"""
Create or replace an existing Lab.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param lab Represents a lab.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the LabInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, lab).toBlocking().single().body();
} | java | public LabInner createOrUpdate(String resourceGroupName, String labAccountName, String labName, LabInner lab) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, lab).toBlocking().single().body();
} | [
"public",
"LabInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"labAccountName",
",",
"String",
"labName",
",",
"LabInner",
"lab",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"labAccountName",
",",
"labName",
",",
"lab",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
]
| Create or replace an existing Lab.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param lab Represents a lab.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the LabInner object if successful. | [
"Create",
"or",
"replace",
"an",
"existing",
"Lab",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/LabsInner.java#L565-L567 |
querydsl/querydsl | querydsl-sql/src/main/java/com/querydsl/sql/Configuration.java | Configuration.getColumnOverride | public String getColumnOverride(SchemaAndTable key, String column) {
"""
Get the column override
@param key schema and table
@param column column
@return overridden column
"""
return nameMapping.getColumnOverride(key, column).or(column);
} | java | public String getColumnOverride(SchemaAndTable key, String column) {
return nameMapping.getColumnOverride(key, column).or(column);
} | [
"public",
"String",
"getColumnOverride",
"(",
"SchemaAndTable",
"key",
",",
"String",
"column",
")",
"{",
"return",
"nameMapping",
".",
"getColumnOverride",
"(",
"key",
",",
"column",
")",
".",
"or",
"(",
"column",
")",
";",
"}"
]
| Get the column override
@param key schema and table
@param column column
@return overridden column | [
"Get",
"the",
"column",
"override"
]
| train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/Configuration.java#L220-L222 |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java | MeshGenerator.generatePlane | public static void generatePlane(TFloatList positions, TFloatList normals, TFloatList textureCoords, TIntList indices, Vector2f size) {
"""
Generates a textured plane on xy. The center is at the middle of the plane.
@param positions Where to save the position information
@param normals Where to save the normal information, can be null to ignore the attribute
@param textureCoords Where to save the texture coordinate information, can be null to ignore the attribute
@param indices Where to save the indices
@param size The size of the plane to generate, on x and y
"""
/*
* 2-----3
* | |
* | |
* 0-----1
*/
// Corner positions
final Vector2f p = size.div(2);
final Vector3f p3 = new Vector3f(p.getX(), p.getY(), 0);
final Vector3f p2 = new Vector3f(-p.getX(), p.getY(), 0);
final Vector3f p1 = new Vector3f(p.getX(), -p.getY(), 0);
final Vector3f p0 = new Vector3f(-p.getX(), -p.getY(), 0);
// Normal
final Vector3f n = new Vector3f(0, 0, 1);
// Face
addVector(positions, p0);
addVector(normals, n);
addAll(textureCoords, 0, 0);
addVector(positions, p1);
addVector(normals, n);
addAll(textureCoords, 1, 0);
addVector(positions, p2);
addVector(normals, n);
addAll(textureCoords, 0, 1);
addVector(positions, p3);
addVector(normals, n);
addAll(textureCoords, 1, 1);
addAll(indices, 0, 3, 2, 0, 1, 3);
} | java | public static void generatePlane(TFloatList positions, TFloatList normals, TFloatList textureCoords, TIntList indices, Vector2f size) {
/*
* 2-----3
* | |
* | |
* 0-----1
*/
// Corner positions
final Vector2f p = size.div(2);
final Vector3f p3 = new Vector3f(p.getX(), p.getY(), 0);
final Vector3f p2 = new Vector3f(-p.getX(), p.getY(), 0);
final Vector3f p1 = new Vector3f(p.getX(), -p.getY(), 0);
final Vector3f p0 = new Vector3f(-p.getX(), -p.getY(), 0);
// Normal
final Vector3f n = new Vector3f(0, 0, 1);
// Face
addVector(positions, p0);
addVector(normals, n);
addAll(textureCoords, 0, 0);
addVector(positions, p1);
addVector(normals, n);
addAll(textureCoords, 1, 0);
addVector(positions, p2);
addVector(normals, n);
addAll(textureCoords, 0, 1);
addVector(positions, p3);
addVector(normals, n);
addAll(textureCoords, 1, 1);
addAll(indices, 0, 3, 2, 0, 1, 3);
} | [
"public",
"static",
"void",
"generatePlane",
"(",
"TFloatList",
"positions",
",",
"TFloatList",
"normals",
",",
"TFloatList",
"textureCoords",
",",
"TIntList",
"indices",
",",
"Vector2f",
"size",
")",
"{",
"/*\n * 2-----3\n * | |\n * | |\n * 0-----1\n */",
"// Corner positions",
"final",
"Vector2f",
"p",
"=",
"size",
".",
"div",
"(",
"2",
")",
";",
"final",
"Vector3f",
"p3",
"=",
"new",
"Vector3f",
"(",
"p",
".",
"getX",
"(",
")",
",",
"p",
".",
"getY",
"(",
")",
",",
"0",
")",
";",
"final",
"Vector3f",
"p2",
"=",
"new",
"Vector3f",
"(",
"-",
"p",
".",
"getX",
"(",
")",
",",
"p",
".",
"getY",
"(",
")",
",",
"0",
")",
";",
"final",
"Vector3f",
"p1",
"=",
"new",
"Vector3f",
"(",
"p",
".",
"getX",
"(",
")",
",",
"-",
"p",
".",
"getY",
"(",
")",
",",
"0",
")",
";",
"final",
"Vector3f",
"p0",
"=",
"new",
"Vector3f",
"(",
"-",
"p",
".",
"getX",
"(",
")",
",",
"-",
"p",
".",
"getY",
"(",
")",
",",
"0",
")",
";",
"// Normal",
"final",
"Vector3f",
"n",
"=",
"new",
"Vector3f",
"(",
"0",
",",
"0",
",",
"1",
")",
";",
"// Face",
"addVector",
"(",
"positions",
",",
"p0",
")",
";",
"addVector",
"(",
"normals",
",",
"n",
")",
";",
"addAll",
"(",
"textureCoords",
",",
"0",
",",
"0",
")",
";",
"addVector",
"(",
"positions",
",",
"p1",
")",
";",
"addVector",
"(",
"normals",
",",
"n",
")",
";",
"addAll",
"(",
"textureCoords",
",",
"1",
",",
"0",
")",
";",
"addVector",
"(",
"positions",
",",
"p2",
")",
";",
"addVector",
"(",
"normals",
",",
"n",
")",
";",
"addAll",
"(",
"textureCoords",
",",
"0",
",",
"1",
")",
";",
"addVector",
"(",
"positions",
",",
"p3",
")",
";",
"addVector",
"(",
"normals",
",",
"n",
")",
";",
"addAll",
"(",
"textureCoords",
",",
"1",
",",
"1",
")",
";",
"addAll",
"(",
"indices",
",",
"0",
",",
"3",
",",
"2",
",",
"0",
",",
"1",
",",
"3",
")",
";",
"}"
]
| Generates a textured plane on xy. The center is at the middle of the plane.
@param positions Where to save the position information
@param normals Where to save the normal information, can be null to ignore the attribute
@param textureCoords Where to save the texture coordinate information, can be null to ignore the attribute
@param indices Where to save the indices
@param size The size of the plane to generate, on x and y | [
"Generates",
"a",
"textured",
"plane",
"on",
"xy",
".",
"The",
"center",
"is",
"at",
"the",
"middle",
"of",
"the",
"plane",
"."
]
| train | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java#L623-L652 |
CloudBees-community/cloudbees-log4j-extras | src/main/java/com/cloudbees/log4j/jmx/Log4jConfigurer.java | Log4jConfigurer.setLoggerLevel | public void setLoggerLevel(@Nonnull String loggerName, @Nullable String level) {
"""
Set the level of the given logger.
@param loggerName name of the logger to set
@param level new level. <code>null</code> or unknown level will set logger level to <code>null</code>
@see Logger#setLevel(org.apache.log4j.Level)
"""
logger.info("setLoggerLevel(" + loggerName + "," + level + ")");
try {
Level levelAsObject = Level.toLevel(level);
LogManager.getLogger(loggerName).setLevel(levelAsObject);
} catch (RuntimeException e) {
logger.warn("Exception setting logger " + loggerName + " to level " + level, e);
throw e;
}
} | java | public void setLoggerLevel(@Nonnull String loggerName, @Nullable String level) {
logger.info("setLoggerLevel(" + loggerName + "," + level + ")");
try {
Level levelAsObject = Level.toLevel(level);
LogManager.getLogger(loggerName).setLevel(levelAsObject);
} catch (RuntimeException e) {
logger.warn("Exception setting logger " + loggerName + " to level " + level, e);
throw e;
}
} | [
"public",
"void",
"setLoggerLevel",
"(",
"@",
"Nonnull",
"String",
"loggerName",
",",
"@",
"Nullable",
"String",
"level",
")",
"{",
"logger",
".",
"info",
"(",
"\"setLoggerLevel(\"",
"+",
"loggerName",
"+",
"\",\"",
"+",
"level",
"+",
"\")\"",
")",
";",
"try",
"{",
"Level",
"levelAsObject",
"=",
"Level",
".",
"toLevel",
"(",
"level",
")",
";",
"LogManager",
".",
"getLogger",
"(",
"loggerName",
")",
".",
"setLevel",
"(",
"levelAsObject",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Exception setting logger \"",
"+",
"loggerName",
"+",
"\" to level \"",
"+",
"level",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"}"
]
| Set the level of the given logger.
@param loggerName name of the logger to set
@param level new level. <code>null</code> or unknown level will set logger level to <code>null</code>
@see Logger#setLevel(org.apache.log4j.Level) | [
"Set",
"the",
"level",
"of",
"the",
"given",
"logger",
"."
]
| train | https://github.com/CloudBees-community/cloudbees-log4j-extras/blob/cd204b9a4c02d69ff9adc4dbda65f90fc0de98f7/src/main/java/com/cloudbees/log4j/jmx/Log4jConfigurer.java#L131-L140 |
meltmedia/cadmium | core/src/main/java/com/meltmedia/cadmium/core/util/Jsr250Utils.java | Jsr250Utils.postConstruct | public static void postConstruct(Object obj, Logger log) throws Exception {
"""
Calls all @PostConstruct methods on the object passed in called in order from super class to child class.
@param obj The instance to inspect for Annotated methods and call them.
@param log
@throws Exception
"""
List<Method> methodsToRun = getAnnotatedMethodsFromChildToParent(obj.getClass(), PostConstruct.class, log);
Collections.reverse(methodsToRun);
for(Method aMethod : methodsToRun) {
safeInvokeMethod(obj, aMethod, log);
}
} | java | public static void postConstruct(Object obj, Logger log) throws Exception {
List<Method> methodsToRun = getAnnotatedMethodsFromChildToParent(obj.getClass(), PostConstruct.class, log);
Collections.reverse(methodsToRun);
for(Method aMethod : methodsToRun) {
safeInvokeMethod(obj, aMethod, log);
}
} | [
"public",
"static",
"void",
"postConstruct",
"(",
"Object",
"obj",
",",
"Logger",
"log",
")",
"throws",
"Exception",
"{",
"List",
"<",
"Method",
">",
"methodsToRun",
"=",
"getAnnotatedMethodsFromChildToParent",
"(",
"obj",
".",
"getClass",
"(",
")",
",",
"PostConstruct",
".",
"class",
",",
"log",
")",
";",
"Collections",
".",
"reverse",
"(",
"methodsToRun",
")",
";",
"for",
"(",
"Method",
"aMethod",
":",
"methodsToRun",
")",
"{",
"safeInvokeMethod",
"(",
"obj",
",",
"aMethod",
",",
"log",
")",
";",
"}",
"}"
]
| Calls all @PostConstruct methods on the object passed in called in order from super class to child class.
@param obj The instance to inspect for Annotated methods and call them.
@param log
@throws Exception | [
"Calls",
"all",
"@PostConstruct",
"methods",
"on",
"the",
"object",
"passed",
"in",
"called",
"in",
"order",
"from",
"super",
"class",
"to",
"child",
"class",
"."
]
| train | https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/core/src/main/java/com/meltmedia/cadmium/core/util/Jsr250Utils.java#L59-L65 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java | DebuggableThreadPoolExecutor.createWithMaximumPoolSize | public static DebuggableThreadPoolExecutor createWithMaximumPoolSize(String threadPoolName, int size, int keepAliveTime, TimeUnit unit) {
"""
Returns a ThreadPoolExecutor with a fixed maximum number of threads, but whose
threads are terminated when idle for too long.
When all threads are actively executing tasks, new tasks are queued.
@param threadPoolName the name of the threads created by this executor
@param size the maximum number of threads for this executor
@param keepAliveTime the time an idle thread is kept alive before being terminated
@param unit tht time unit for {@code keepAliveTime}
@return the new DebuggableThreadPoolExecutor
"""
return new DebuggableThreadPoolExecutor(size, Integer.MAX_VALUE, keepAliveTime, unit, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(threadPoolName));
} | java | public static DebuggableThreadPoolExecutor createWithMaximumPoolSize(String threadPoolName, int size, int keepAliveTime, TimeUnit unit)
{
return new DebuggableThreadPoolExecutor(size, Integer.MAX_VALUE, keepAliveTime, unit, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(threadPoolName));
} | [
"public",
"static",
"DebuggableThreadPoolExecutor",
"createWithMaximumPoolSize",
"(",
"String",
"threadPoolName",
",",
"int",
"size",
",",
"int",
"keepAliveTime",
",",
"TimeUnit",
"unit",
")",
"{",
"return",
"new",
"DebuggableThreadPoolExecutor",
"(",
"size",
",",
"Integer",
".",
"MAX_VALUE",
",",
"keepAliveTime",
",",
"unit",
",",
"new",
"LinkedBlockingQueue",
"<",
"Runnable",
">",
"(",
")",
",",
"new",
"NamedThreadFactory",
"(",
"threadPoolName",
")",
")",
";",
"}"
]
| Returns a ThreadPoolExecutor with a fixed maximum number of threads, but whose
threads are terminated when idle for too long.
When all threads are actively executing tasks, new tasks are queued.
@param threadPoolName the name of the threads created by this executor
@param size the maximum number of threads for this executor
@param keepAliveTime the time an idle thread is kept alive before being terminated
@param unit tht time unit for {@code keepAliveTime}
@return the new DebuggableThreadPoolExecutor | [
"Returns",
"a",
"ThreadPoolExecutor",
"with",
"a",
"fixed",
"maximum",
"number",
"of",
"threads",
"but",
"whose",
"threads",
"are",
"terminated",
"when",
"idle",
"for",
"too",
"long",
".",
"When",
"all",
"threads",
"are",
"actively",
"executing",
"tasks",
"new",
"tasks",
"are",
"queued",
"."
]
| train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java#L125-L128 |
synchronoss/cpo-api | cpo-jdbc/src/main/java/org/synchronoss/cpo/jdbc/JdbcCpoAdapter.java | JdbcCpoAdapter.processUpdateGroup | protected <T> long processUpdateGroup(Collection<T> coll, String groupType, String groupName, Collection<CpoWhere> wheres, Collection<CpoOrderBy> orderBy, Collection<CpoNativeFunction> nativeExpressions, Connection con) throws CpoException {
"""
DOCUMENT ME!
@param coll DOCUMENT ME!
@param groupType DOCUMENT ME!
@param groupName DOCUMENT ME!
@param wheres DOCUMENT ME!
@param orderBy DOCUMENT ME!
@param nativeExpressions DOCUMENT ME!
@param con DOCUMENT ME!
@return DOCUMENT ME!
@throws CpoException DOCUMENT ME!
"""
long updateCount = 0;
if (!coll.isEmpty()) {
T[] arr = (T[]) coll.toArray();
T obj1 = arr[0];
boolean allEqual = true;
for (int i = 1; i < arr.length; i++) {
if (!obj1.getClass().getName().equals(arr[i].getClass().getName())) {
allEqual = false;
break;
}
}
if (allEqual && batchUpdatesSupported_ && !JdbcCpoAdapter.PERSIST_GROUP.equals(groupType)) {
updateCount = processBatchUpdateGroup(arr, groupType, groupName, wheres, orderBy, nativeExpressions, con);
} else {
for (T obj : arr) {
updateCount += processUpdateGroup(obj, groupType, groupName, wheres, orderBy, nativeExpressions, con);
}
}
}
return updateCount;
} | java | protected <T> long processUpdateGroup(Collection<T> coll, String groupType, String groupName, Collection<CpoWhere> wheres, Collection<CpoOrderBy> orderBy, Collection<CpoNativeFunction> nativeExpressions, Connection con) throws CpoException {
long updateCount = 0;
if (!coll.isEmpty()) {
T[] arr = (T[]) coll.toArray();
T obj1 = arr[0];
boolean allEqual = true;
for (int i = 1; i < arr.length; i++) {
if (!obj1.getClass().getName().equals(arr[i].getClass().getName())) {
allEqual = false;
break;
}
}
if (allEqual && batchUpdatesSupported_ && !JdbcCpoAdapter.PERSIST_GROUP.equals(groupType)) {
updateCount = processBatchUpdateGroup(arr, groupType, groupName, wheres, orderBy, nativeExpressions, con);
} else {
for (T obj : arr) {
updateCount += processUpdateGroup(obj, groupType, groupName, wheres, orderBy, nativeExpressions, con);
}
}
}
return updateCount;
} | [
"protected",
"<",
"T",
">",
"long",
"processUpdateGroup",
"(",
"Collection",
"<",
"T",
">",
"coll",
",",
"String",
"groupType",
",",
"String",
"groupName",
",",
"Collection",
"<",
"CpoWhere",
">",
"wheres",
",",
"Collection",
"<",
"CpoOrderBy",
">",
"orderBy",
",",
"Collection",
"<",
"CpoNativeFunction",
">",
"nativeExpressions",
",",
"Connection",
"con",
")",
"throws",
"CpoException",
"{",
"long",
"updateCount",
"=",
"0",
";",
"if",
"(",
"!",
"coll",
".",
"isEmpty",
"(",
")",
")",
"{",
"T",
"[",
"]",
"arr",
"=",
"(",
"T",
"[",
"]",
")",
"coll",
".",
"toArray",
"(",
")",
";",
"T",
"obj1",
"=",
"arr",
"[",
"0",
"]",
";",
"boolean",
"allEqual",
"=",
"true",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"obj1",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"arr",
"[",
"i",
"]",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"{",
"allEqual",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"allEqual",
"&&",
"batchUpdatesSupported_",
"&&",
"!",
"JdbcCpoAdapter",
".",
"PERSIST_GROUP",
".",
"equals",
"(",
"groupType",
")",
")",
"{",
"updateCount",
"=",
"processBatchUpdateGroup",
"(",
"arr",
",",
"groupType",
",",
"groupName",
",",
"wheres",
",",
"orderBy",
",",
"nativeExpressions",
",",
"con",
")",
";",
"}",
"else",
"{",
"for",
"(",
"T",
"obj",
":",
"arr",
")",
"{",
"updateCount",
"+=",
"processUpdateGroup",
"(",
"obj",
",",
"groupType",
",",
"groupName",
",",
"wheres",
",",
"orderBy",
",",
"nativeExpressions",
",",
"con",
")",
";",
"}",
"}",
"}",
"return",
"updateCount",
";",
"}"
]
| DOCUMENT ME!
@param coll DOCUMENT ME!
@param groupType DOCUMENT ME!
@param groupName DOCUMENT ME!
@param wheres DOCUMENT ME!
@param orderBy DOCUMENT ME!
@param nativeExpressions DOCUMENT ME!
@param con DOCUMENT ME!
@return DOCUMENT ME!
@throws CpoException DOCUMENT ME! | [
"DOCUMENT",
"ME!"
]
| train | https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-jdbc/src/main/java/org/synchronoss/cpo/jdbc/JdbcCpoAdapter.java#L2778-L2803 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/ui/SeaGlassViewportUI.java | SeaGlassViewportUI.invokeGetter | private static Object invokeGetter(Object obj, String methodName, Object defaultValue) {
"""
Invokes the specified getter method if it exists.
@param obj
The object on which to invoke the method.
@param methodName
The name of the method.
@param defaultValue
This value is returned, if the method does not exist.
@return The value returned by the getter method or the default value.
"""
try {
Method method = obj.getClass().getMethod(methodName, new Class[0]);
Object result = method.invoke(obj, new Object[0]);
return result;
} catch (NoSuchMethodException e) {
return defaultValue;
} catch (IllegalAccessException e) {
return defaultValue;
} catch (InvocationTargetException e) {
return defaultValue;
}
} | java | private static Object invokeGetter(Object obj, String methodName, Object defaultValue) {
try {
Method method = obj.getClass().getMethod(methodName, new Class[0]);
Object result = method.invoke(obj, new Object[0]);
return result;
} catch (NoSuchMethodException e) {
return defaultValue;
} catch (IllegalAccessException e) {
return defaultValue;
} catch (InvocationTargetException e) {
return defaultValue;
}
} | [
"private",
"static",
"Object",
"invokeGetter",
"(",
"Object",
"obj",
",",
"String",
"methodName",
",",
"Object",
"defaultValue",
")",
"{",
"try",
"{",
"Method",
"method",
"=",
"obj",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"methodName",
",",
"new",
"Class",
"[",
"0",
"]",
")",
";",
"Object",
"result",
"=",
"method",
".",
"invoke",
"(",
"obj",
",",
"new",
"Object",
"[",
"0",
"]",
")",
";",
"return",
"result",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"return",
"defaultValue",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"return",
"defaultValue",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
]
| Invokes the specified getter method if it exists.
@param obj
The object on which to invoke the method.
@param methodName
The name of the method.
@param defaultValue
This value is returned, if the method does not exist.
@return The value returned by the getter method or the default value. | [
"Invokes",
"the",
"specified",
"getter",
"method",
"if",
"it",
"exists",
"."
]
| train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassViewportUI.java#L173-L185 |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/markdown/Emitter.java | Emitter._emitLines | private void _emitLines (final MarkdownHCStack aOut, final Block aBlock) {
"""
Transforms lines into HTML.
@param aOut
The StringBuilder to write to.
@param aBlock
The Block to process.
"""
switch (aBlock.m_eType)
{
case CODE:
_emitCodeLines (aOut, aBlock.m_aLines, aBlock.m_sMeta, true);
break;
case FENCED_CODE:
_emitCodeLines (aOut, aBlock.m_aLines, aBlock.m_sMeta, false);
break;
case PLUGIN:
emitPluginLines (aOut, aBlock.m_aLines, aBlock.m_sMeta);
break;
case XML:
_emitXMLLines (aOut, aBlock.m_aLines);
break;
case XML_COMMENT:
_emitXMLComment (aOut, aBlock.m_aLines);
break;
case PARAGRAPH:
_emitMarkedLines (aOut, aBlock.m_aLines);
break;
default:
_emitMarkedLines (aOut, aBlock.m_aLines);
break;
}
} | java | private void _emitLines (final MarkdownHCStack aOut, final Block aBlock)
{
switch (aBlock.m_eType)
{
case CODE:
_emitCodeLines (aOut, aBlock.m_aLines, aBlock.m_sMeta, true);
break;
case FENCED_CODE:
_emitCodeLines (aOut, aBlock.m_aLines, aBlock.m_sMeta, false);
break;
case PLUGIN:
emitPluginLines (aOut, aBlock.m_aLines, aBlock.m_sMeta);
break;
case XML:
_emitXMLLines (aOut, aBlock.m_aLines);
break;
case XML_COMMENT:
_emitXMLComment (aOut, aBlock.m_aLines);
break;
case PARAGRAPH:
_emitMarkedLines (aOut, aBlock.m_aLines);
break;
default:
_emitMarkedLines (aOut, aBlock.m_aLines);
break;
}
} | [
"private",
"void",
"_emitLines",
"(",
"final",
"MarkdownHCStack",
"aOut",
",",
"final",
"Block",
"aBlock",
")",
"{",
"switch",
"(",
"aBlock",
".",
"m_eType",
")",
"{",
"case",
"CODE",
":",
"_emitCodeLines",
"(",
"aOut",
",",
"aBlock",
".",
"m_aLines",
",",
"aBlock",
".",
"m_sMeta",
",",
"true",
")",
";",
"break",
";",
"case",
"FENCED_CODE",
":",
"_emitCodeLines",
"(",
"aOut",
",",
"aBlock",
".",
"m_aLines",
",",
"aBlock",
".",
"m_sMeta",
",",
"false",
")",
";",
"break",
";",
"case",
"PLUGIN",
":",
"emitPluginLines",
"(",
"aOut",
",",
"aBlock",
".",
"m_aLines",
",",
"aBlock",
".",
"m_sMeta",
")",
";",
"break",
";",
"case",
"XML",
":",
"_emitXMLLines",
"(",
"aOut",
",",
"aBlock",
".",
"m_aLines",
")",
";",
"break",
";",
"case",
"XML_COMMENT",
":",
"_emitXMLComment",
"(",
"aOut",
",",
"aBlock",
".",
"m_aLines",
")",
";",
"break",
";",
"case",
"PARAGRAPH",
":",
"_emitMarkedLines",
"(",
"aOut",
",",
"aBlock",
".",
"m_aLines",
")",
";",
"break",
";",
"default",
":",
"_emitMarkedLines",
"(",
"aOut",
",",
"aBlock",
".",
"m_aLines",
")",
";",
"break",
";",
"}",
"}"
]
| Transforms lines into HTML.
@param aOut
The StringBuilder to write to.
@param aBlock
The Block to process. | [
"Transforms",
"lines",
"into",
"HTML",
"."
]
| train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/markdown/Emitter.java#L219-L245 |
nmorel/gwt-jackson | gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/deser/array/AbstractArrayJsonDeserializer.java | AbstractArrayJsonDeserializer.doDeserializeNonArray | protected T doDeserializeNonArray( JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params ) {
"""
<p>doDeserializeNonArray</p>
@param reader a {@link com.github.nmorel.gwtjackson.client.stream.JsonReader} object.
@param ctx a {@link com.github.nmorel.gwtjackson.client.JsonDeserializationContext} object.
@param params a {@link com.github.nmorel.gwtjackson.client.JsonDeserializerParameters} object.
@return a T object.
"""
if ( ctx.isAcceptSingleValueAsArray() ) {
return doDeserializeSingleArray( reader, ctx, params );
} else {
throw ctx.traceError( "Cannot deserialize an array out of " + reader.peek() + " token", reader );
}
} | java | protected T doDeserializeNonArray( JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params ) {
if ( ctx.isAcceptSingleValueAsArray() ) {
return doDeserializeSingleArray( reader, ctx, params );
} else {
throw ctx.traceError( "Cannot deserialize an array out of " + reader.peek() + " token", reader );
}
} | [
"protected",
"T",
"doDeserializeNonArray",
"(",
"JsonReader",
"reader",
",",
"JsonDeserializationContext",
"ctx",
",",
"JsonDeserializerParameters",
"params",
")",
"{",
"if",
"(",
"ctx",
".",
"isAcceptSingleValueAsArray",
"(",
")",
")",
"{",
"return",
"doDeserializeSingleArray",
"(",
"reader",
",",
"ctx",
",",
"params",
")",
";",
"}",
"else",
"{",
"throw",
"ctx",
".",
"traceError",
"(",
"\"Cannot deserialize an array out of \"",
"+",
"reader",
".",
"peek",
"(",
")",
"+",
"\" token\"",
",",
"reader",
")",
";",
"}",
"}"
]
| <p>doDeserializeNonArray</p>
@param reader a {@link com.github.nmorel.gwtjackson.client.stream.JsonReader} object.
@param ctx a {@link com.github.nmorel.gwtjackson.client.JsonDeserializationContext} object.
@param params a {@link com.github.nmorel.gwtjackson.client.JsonDeserializerParameters} object.
@return a T object. | [
"<p",
">",
"doDeserializeNonArray<",
"/",
"p",
">"
]
| train | https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/deser/array/AbstractArrayJsonDeserializer.java#L65-L71 |
audit4j/audit4j-core | src/main/java/org/audit4j/core/schedule/ThreadPoolTaskScheduler.java | ThreadPoolTaskScheduler.createExecutor | protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory,
RejectedExecutionHandler rejectedExecutionHandler) {
"""
Create a new {@link ScheduledExecutorService} instance.
<p>
The default implementation creates a {@link ScheduledThreadPoolExecutor}.
Can be overridden in subclasses to provide custom
@param poolSize the specified pool size
@param threadFactory the ThreadFactory to use
@param rejectedExecutionHandler the RejectedExecutionHandler to use
@return a new ScheduledExecutorService instance
{@link ScheduledExecutorService} instances.
@see #afterPropertiesSet()
@see java.util.concurrent.ScheduledThreadPoolExecutor
"""
return new ScheduledThreadPoolExecutor(poolSize, threadFactory, rejectedExecutionHandler);
} | java | protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory,
RejectedExecutionHandler rejectedExecutionHandler) {
return new ScheduledThreadPoolExecutor(poolSize, threadFactory, rejectedExecutionHandler);
} | [
"protected",
"ScheduledExecutorService",
"createExecutor",
"(",
"int",
"poolSize",
",",
"ThreadFactory",
"threadFactory",
",",
"RejectedExecutionHandler",
"rejectedExecutionHandler",
")",
"{",
"return",
"new",
"ScheduledThreadPoolExecutor",
"(",
"poolSize",
",",
"threadFactory",
",",
"rejectedExecutionHandler",
")",
";",
"}"
]
| Create a new {@link ScheduledExecutorService} instance.
<p>
The default implementation creates a {@link ScheduledThreadPoolExecutor}.
Can be overridden in subclasses to provide custom
@param poolSize the specified pool size
@param threadFactory the ThreadFactory to use
@param rejectedExecutionHandler the RejectedExecutionHandler to use
@return a new ScheduledExecutorService instance
{@link ScheduledExecutorService} instances.
@see #afterPropertiesSet()
@see java.util.concurrent.ScheduledThreadPoolExecutor | [
"Create",
"a",
"new",
"{",
"@link",
"ScheduledExecutorService",
"}",
"instance",
".",
"<p",
">",
"The",
"default",
"implementation",
"creates",
"a",
"{",
"@link",
"ScheduledThreadPoolExecutor",
"}",
".",
"Can",
"be",
"overridden",
"in",
"subclasses",
"to",
"provide",
"custom"
]
| train | https://github.com/audit4j/audit4j-core/blob/dc8569108851e64cb0ecc7a39048db0ad070fba2/src/main/java/org/audit4j/core/schedule/ThreadPoolTaskScheduler.java#L133-L136 |
infinispan/infinispan | server/integration/commons/src/main/java/org/infinispan/server/commons/dmr/ModelNodes.java | ModelNodes.asString | public static String asString(ModelNode value, String defaultValue) {
"""
Returns the value of the node as a string, or the specified default value if the node is undefined.
@param value a model node
@return the value of the node as a string, or the specified default value if the node is undefined.
"""
return value.isDefined() ? value.asString() : defaultValue;
} | java | public static String asString(ModelNode value, String defaultValue) {
return value.isDefined() ? value.asString() : defaultValue;
} | [
"public",
"static",
"String",
"asString",
"(",
"ModelNode",
"value",
",",
"String",
"defaultValue",
")",
"{",
"return",
"value",
".",
"isDefined",
"(",
")",
"?",
"value",
".",
"asString",
"(",
")",
":",
"defaultValue",
";",
"}"
]
| Returns the value of the node as a string, or the specified default value if the node is undefined.
@param value a model node
@return the value of the node as a string, or the specified default value if the node is undefined. | [
"Returns",
"the",
"value",
"of",
"the",
"node",
"as",
"a",
"string",
"or",
"the",
"specified",
"default",
"value",
"if",
"the",
"node",
"is",
"undefined",
"."
]
| train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/commons/src/main/java/org/infinispan/server/commons/dmr/ModelNodes.java#L48-L50 |
deephacks/confit | provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanTable.java | HBeanTable.listEager | public HBeanRowCollector listEager(String schemaName, FetchType... fetchType)
throws HBeanNotFoundException {
"""
Fetch list rows for a particular schema and traverse and fetch references eagerly.
@param schemaName schema to fetch
@param fetchType data to fetch
@return collector carring the result from the query
"""
Set<HBeanRow> rows = listLazy(schemaName, fetchType);
HBeanRowCollector collector = new HBeanRowCollector(rows);
getEager(rows, collector, FETCH_DEPTH_MAX, fetchType);
return collector;
} | java | public HBeanRowCollector listEager(String schemaName, FetchType... fetchType)
throws HBeanNotFoundException {
Set<HBeanRow> rows = listLazy(schemaName, fetchType);
HBeanRowCollector collector = new HBeanRowCollector(rows);
getEager(rows, collector, FETCH_DEPTH_MAX, fetchType);
return collector;
} | [
"public",
"HBeanRowCollector",
"listEager",
"(",
"String",
"schemaName",
",",
"FetchType",
"...",
"fetchType",
")",
"throws",
"HBeanNotFoundException",
"{",
"Set",
"<",
"HBeanRow",
">",
"rows",
"=",
"listLazy",
"(",
"schemaName",
",",
"fetchType",
")",
";",
"HBeanRowCollector",
"collector",
"=",
"new",
"HBeanRowCollector",
"(",
"rows",
")",
";",
"getEager",
"(",
"rows",
",",
"collector",
",",
"FETCH_DEPTH_MAX",
",",
"fetchType",
")",
";",
"return",
"collector",
";",
"}"
]
| Fetch list rows for a particular schema and traverse and fetch references eagerly.
@param schemaName schema to fetch
@param fetchType data to fetch
@return collector carring the result from the query | [
"Fetch",
"list",
"rows",
"for",
"a",
"particular",
"schema",
"and",
"traverse",
"and",
"fetch",
"references",
"eagerly",
"."
]
| train | https://github.com/deephacks/confit/blob/4e6d4ee5fed32cbc5104433e61de1bcf1b360832/provider-hbase/src/main/java/org/deephacks/confit/internal/hbase/HBeanTable.java#L79-L85 |
LGoodDatePicker/LGoodDatePicker | Project/src/main/java/com/privatejgoodies/common/internal/RenderingUtils.java | RenderingUtils.getFontMetrics | public static FontMetrics getFontMetrics(JComponent c, Graphics g) {
"""
Returns the FontMetrics for the current Font of the passed in Graphics. This method is used
when a Graphics is available, typically when painting. If a Graphics is not available the
JComponent method of the same name should be used.
<p>
Callers should pass in a non-null JComponent, the exception to this is if a JComponent is not
readily available at the time of painting.
<p>
This does not necessarily return the FontMetrics from the Graphics.
@param c JComponent requesting FontMetrics, may be null
@param g Graphics Graphics
@return the FontMetrics
"""
if (getFontMetricsMethod != null) {
try {
return (FontMetrics) getFontMetricsMethod.invoke(null, new Object[]{c, g});
} catch (IllegalArgumentException e) {
// Use the fallback
} catch (IllegalAccessException e) {
// Use the fallback
} catch (InvocationTargetException e) {
// Use the fallback
}
}
return c.getFontMetrics(g.getFont());
} | java | public static FontMetrics getFontMetrics(JComponent c, Graphics g) {
if (getFontMetricsMethod != null) {
try {
return (FontMetrics) getFontMetricsMethod.invoke(null, new Object[]{c, g});
} catch (IllegalArgumentException e) {
// Use the fallback
} catch (IllegalAccessException e) {
// Use the fallback
} catch (InvocationTargetException e) {
// Use the fallback
}
}
return c.getFontMetrics(g.getFont());
} | [
"public",
"static",
"FontMetrics",
"getFontMetrics",
"(",
"JComponent",
"c",
",",
"Graphics",
"g",
")",
"{",
"if",
"(",
"getFontMetricsMethod",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"(",
"FontMetrics",
")",
"getFontMetricsMethod",
".",
"invoke",
"(",
"null",
",",
"new",
"Object",
"[",
"]",
"{",
"c",
",",
"g",
"}",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"// Use the fallback",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"// Use the fallback",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"// Use the fallback",
"}",
"}",
"return",
"c",
".",
"getFontMetrics",
"(",
"g",
".",
"getFont",
"(",
")",
")",
";",
"}"
]
| Returns the FontMetrics for the current Font of the passed in Graphics. This method is used
when a Graphics is available, typically when painting. If a Graphics is not available the
JComponent method of the same name should be used.
<p>
Callers should pass in a non-null JComponent, the exception to this is if a JComponent is not
readily available at the time of painting.
<p>
This does not necessarily return the FontMetrics from the Graphics.
@param c JComponent requesting FontMetrics, may be null
@param g Graphics Graphics
@return the FontMetrics | [
"Returns",
"the",
"FontMetrics",
"for",
"the",
"current",
"Font",
"of",
"the",
"passed",
"in",
"Graphics",
".",
"This",
"method",
"is",
"used",
"when",
"a",
"Graphics",
"is",
"available",
"typically",
"when",
"painting",
".",
"If",
"a",
"Graphics",
"is",
"not",
"available",
"the",
"JComponent",
"method",
"of",
"the",
"same",
"name",
"should",
"be",
"used",
".",
"<p",
">",
"Callers",
"should",
"pass",
"in",
"a",
"non",
"-",
"null",
"JComponent",
"the",
"exception",
"to",
"this",
"is",
"if",
"a",
"JComponent",
"is",
"not",
"readily",
"available",
"at",
"the",
"time",
"of",
"painting",
".",
"<p",
">",
"This",
"does",
"not",
"necessarily",
"return",
"the",
"FontMetrics",
"from",
"the",
"Graphics",
"."
]
| train | https://github.com/LGoodDatePicker/LGoodDatePicker/blob/c7df05a5fe382e1e08a6237e9391d8dc5fd48692/Project/src/main/java/com/privatejgoodies/common/internal/RenderingUtils.java#L169-L182 |
FrodeRanders/java-vopn | src/main/java/org/gautelis/vopn/lang/DynamicLoader.java | DynamicLoader.createClass | public Class createClass(String className) throws ClassNotFoundException {
"""
Dynamically loads the named class (fully qualified classname).
"""
Class clazz;
try {
clazz = Class.forName(className);
return clazz;
} catch (ExceptionInInitializerError eiie) {
String info = "Could not load the " + description + " object: " + className
+ ". Could not initialize static object in server: ";
info += eiie.getMessage();
throw new ClassNotFoundException(info, eiie);
} catch (LinkageError le) {
String info = "Could not load the " + description + " object: " + className
+ ". This object is depending on a class that has been changed after compilation ";
info += "or a class that was not found: ";
info += le.getMessage();
throw new ClassNotFoundException(info, le);
} catch (ClassNotFoundException cnfe) {
String info = "Could not find the " + description + " object: " + className + ": ";
info += cnfe.getMessage();
throw new ClassNotFoundException(info, cnfe);
}
} | java | public Class createClass(String className) throws ClassNotFoundException {
Class clazz;
try {
clazz = Class.forName(className);
return clazz;
} catch (ExceptionInInitializerError eiie) {
String info = "Could not load the " + description + " object: " + className
+ ". Could not initialize static object in server: ";
info += eiie.getMessage();
throw new ClassNotFoundException(info, eiie);
} catch (LinkageError le) {
String info = "Could not load the " + description + " object: " + className
+ ". This object is depending on a class that has been changed after compilation ";
info += "or a class that was not found: ";
info += le.getMessage();
throw new ClassNotFoundException(info, le);
} catch (ClassNotFoundException cnfe) {
String info = "Could not find the " + description + " object: " + className + ": ";
info += cnfe.getMessage();
throw new ClassNotFoundException(info, cnfe);
}
} | [
"public",
"Class",
"createClass",
"(",
"String",
"className",
")",
"throws",
"ClassNotFoundException",
"{",
"Class",
"clazz",
";",
"try",
"{",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"return",
"clazz",
";",
"}",
"catch",
"(",
"ExceptionInInitializerError",
"eiie",
")",
"{",
"String",
"info",
"=",
"\"Could not load the \"",
"+",
"description",
"+",
"\" object: \"",
"+",
"className",
"+",
"\". Could not initialize static object in server: \"",
";",
"info",
"+=",
"eiie",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"ClassNotFoundException",
"(",
"info",
",",
"eiie",
")",
";",
"}",
"catch",
"(",
"LinkageError",
"le",
")",
"{",
"String",
"info",
"=",
"\"Could not load the \"",
"+",
"description",
"+",
"\" object: \"",
"+",
"className",
"+",
"\". This object is depending on a class that has been changed after compilation \"",
";",
"info",
"+=",
"\"or a class that was not found: \"",
";",
"info",
"+=",
"le",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"ClassNotFoundException",
"(",
"info",
",",
"le",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"cnfe",
")",
"{",
"String",
"info",
"=",
"\"Could not find the \"",
"+",
"description",
"+",
"\" object: \"",
"+",
"className",
"+",
"\": \"",
";",
"info",
"+=",
"cnfe",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"ClassNotFoundException",
"(",
"info",
",",
"cnfe",
")",
";",
"}",
"}"
]
| Dynamically loads the named class (fully qualified classname). | [
"Dynamically",
"loads",
"the",
"named",
"class",
"(",
"fully",
"qualified",
"classname",
")",
"."
]
| train | https://github.com/FrodeRanders/java-vopn/blob/4c7b2f90201327af4eaa3cd46b3fee68f864e5cc/src/main/java/org/gautelis/vopn/lang/DynamicLoader.java#L258-L282 |
NordicSemiconductor/Android-DFU-Library | dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java | DfuBaseService.openInputStream | private InputStream openInputStream(@NonNull final String filePath, final String mimeType, final int mbrSize, final int types)
throws IOException {
"""
Opens the binary input stream that returns the firmware image content.
A Path to the file is given.
@param filePath the path to the HEX, BIN or ZIP file.
@param mimeType the file type.
@param mbrSize the size of MBR, by default 0x1000.
@param types the content files types in ZIP.
@return The input stream with binary image content.
"""
final InputStream is = new FileInputStream(filePath);
if (MIME_TYPE_ZIP.equals(mimeType))
return new ArchiveInputStream(is, mbrSize, types);
if (filePath.toLowerCase(Locale.US).endsWith("hex"))
return new HexInputStream(is, mbrSize);
return is;
} | java | private InputStream openInputStream(@NonNull final String filePath, final String mimeType, final int mbrSize, final int types)
throws IOException {
final InputStream is = new FileInputStream(filePath);
if (MIME_TYPE_ZIP.equals(mimeType))
return new ArchiveInputStream(is, mbrSize, types);
if (filePath.toLowerCase(Locale.US).endsWith("hex"))
return new HexInputStream(is, mbrSize);
return is;
} | [
"private",
"InputStream",
"openInputStream",
"(",
"@",
"NonNull",
"final",
"String",
"filePath",
",",
"final",
"String",
"mimeType",
",",
"final",
"int",
"mbrSize",
",",
"final",
"int",
"types",
")",
"throws",
"IOException",
"{",
"final",
"InputStream",
"is",
"=",
"new",
"FileInputStream",
"(",
"filePath",
")",
";",
"if",
"(",
"MIME_TYPE_ZIP",
".",
"equals",
"(",
"mimeType",
")",
")",
"return",
"new",
"ArchiveInputStream",
"(",
"is",
",",
"mbrSize",
",",
"types",
")",
";",
"if",
"(",
"filePath",
".",
"toLowerCase",
"(",
"Locale",
".",
"US",
")",
".",
"endsWith",
"(",
"\"hex\"",
")",
")",
"return",
"new",
"HexInputStream",
"(",
"is",
",",
"mbrSize",
")",
";",
"return",
"is",
";",
"}"
]
| Opens the binary input stream that returns the firmware image content.
A Path to the file is given.
@param filePath the path to the HEX, BIN or ZIP file.
@param mimeType the file type.
@param mbrSize the size of MBR, by default 0x1000.
@param types the content files types in ZIP.
@return The input stream with binary image content. | [
"Opens",
"the",
"binary",
"input",
"stream",
"that",
"returns",
"the",
"firmware",
"image",
"content",
".",
"A",
"Path",
"to",
"the",
"file",
"is",
"given",
"."
]
| train | https://github.com/NordicSemiconductor/Android-DFU-Library/blob/ec14c8c522bebe801a9a4c3dfbbeb1f53262c03f/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java#L1416-L1424 |
reactor/reactor-netty | src/main/java/reactor/netty/ByteBufFlux.java | ByteBufFlux.asInputStream | public Flux<InputStream> asInputStream() {
"""
Convert to a {@link InputStream} inbound {@link Flux}
@return a {@link InputStream} inbound {@link Flux}
"""
return handle((bb, sink) -> {
try {
sink.next(new ByteBufMono.ReleasingInputStream(bb));
}
catch (IllegalReferenceCountException e) {
sink.complete();
}
});
} | java | public Flux<InputStream> asInputStream() {
return handle((bb, sink) -> {
try {
sink.next(new ByteBufMono.ReleasingInputStream(bb));
}
catch (IllegalReferenceCountException e) {
sink.complete();
}
});
} | [
"public",
"Flux",
"<",
"InputStream",
">",
"asInputStream",
"(",
")",
"{",
"return",
"handle",
"(",
"(",
"bb",
",",
"sink",
")",
"->",
"{",
"try",
"{",
"sink",
".",
"next",
"(",
"new",
"ByteBufMono",
".",
"ReleasingInputStream",
"(",
"bb",
")",
")",
";",
"}",
"catch",
"(",
"IllegalReferenceCountException",
"e",
")",
"{",
"sink",
".",
"complete",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Convert to a {@link InputStream} inbound {@link Flux}
@return a {@link InputStream} inbound {@link Flux} | [
"Convert",
"to",
"a",
"{",
"@link",
"InputStream",
"}",
"inbound",
"{",
"@link",
"Flux",
"}"
]
| train | https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/ByteBufFlux.java#L214-L223 |
apache/flink | flink-connectors/flink-connector-filesystem/src/main/java/org/apache/flink/streaming/connectors/fs/bucketing/BucketingSink.java | BucketingSink.shouldRoll | private boolean shouldRoll(BucketState<T> bucketState, long currentProcessingTime) throws IOException {
"""
Returns {@code true} if the current {@code part-file} should be closed and a new should be created.
This happens if:
<ol>
<li>no file is created yet for the task to write to, or</li>
<li>the current file has reached the maximum bucket size.</li>
<li>the current file is older than roll over interval</li>
</ol>
"""
boolean shouldRoll = false;
int subtaskIndex = getRuntimeContext().getIndexOfThisSubtask();
if (!bucketState.isWriterOpen) {
shouldRoll = true;
LOG.debug("BucketingSink {} starting new bucket.", subtaskIndex);
} else {
long writePosition = bucketState.writer.getPos();
if (writePosition > batchSize) {
shouldRoll = true;
LOG.debug(
"BucketingSink {} starting new bucket because file position {} is above batch size {}.",
subtaskIndex,
writePosition,
batchSize);
} else {
if (currentProcessingTime - bucketState.creationTime > batchRolloverInterval) {
shouldRoll = true;
LOG.debug(
"BucketingSink {} starting new bucket because file is older than roll over interval {}.",
subtaskIndex,
batchRolloverInterval);
}
}
}
return shouldRoll;
} | java | private boolean shouldRoll(BucketState<T> bucketState, long currentProcessingTime) throws IOException {
boolean shouldRoll = false;
int subtaskIndex = getRuntimeContext().getIndexOfThisSubtask();
if (!bucketState.isWriterOpen) {
shouldRoll = true;
LOG.debug("BucketingSink {} starting new bucket.", subtaskIndex);
} else {
long writePosition = bucketState.writer.getPos();
if (writePosition > batchSize) {
shouldRoll = true;
LOG.debug(
"BucketingSink {} starting new bucket because file position {} is above batch size {}.",
subtaskIndex,
writePosition,
batchSize);
} else {
if (currentProcessingTime - bucketState.creationTime > batchRolloverInterval) {
shouldRoll = true;
LOG.debug(
"BucketingSink {} starting new bucket because file is older than roll over interval {}.",
subtaskIndex,
batchRolloverInterval);
}
}
}
return shouldRoll;
} | [
"private",
"boolean",
"shouldRoll",
"(",
"BucketState",
"<",
"T",
">",
"bucketState",
",",
"long",
"currentProcessingTime",
")",
"throws",
"IOException",
"{",
"boolean",
"shouldRoll",
"=",
"false",
";",
"int",
"subtaskIndex",
"=",
"getRuntimeContext",
"(",
")",
".",
"getIndexOfThisSubtask",
"(",
")",
";",
"if",
"(",
"!",
"bucketState",
".",
"isWriterOpen",
")",
"{",
"shouldRoll",
"=",
"true",
";",
"LOG",
".",
"debug",
"(",
"\"BucketingSink {} starting new bucket.\"",
",",
"subtaskIndex",
")",
";",
"}",
"else",
"{",
"long",
"writePosition",
"=",
"bucketState",
".",
"writer",
".",
"getPos",
"(",
")",
";",
"if",
"(",
"writePosition",
">",
"batchSize",
")",
"{",
"shouldRoll",
"=",
"true",
";",
"LOG",
".",
"debug",
"(",
"\"BucketingSink {} starting new bucket because file position {} is above batch size {}.\"",
",",
"subtaskIndex",
",",
"writePosition",
",",
"batchSize",
")",
";",
"}",
"else",
"{",
"if",
"(",
"currentProcessingTime",
"-",
"bucketState",
".",
"creationTime",
">",
"batchRolloverInterval",
")",
"{",
"shouldRoll",
"=",
"true",
";",
"LOG",
".",
"debug",
"(",
"\"BucketingSink {} starting new bucket because file is older than roll over interval {}.\"",
",",
"subtaskIndex",
",",
"batchRolloverInterval",
")",
";",
"}",
"}",
"}",
"return",
"shouldRoll",
";",
"}"
]
| Returns {@code true} if the current {@code part-file} should be closed and a new should be created.
This happens if:
<ol>
<li>no file is created yet for the task to write to, or</li>
<li>the current file has reached the maximum bucket size.</li>
<li>the current file is older than roll over interval</li>
</ol> | [
"Returns",
"{"
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-connector-filesystem/src/main/java/org/apache/flink/streaming/connectors/fs/bucketing/BucketingSink.java#L474-L500 |
sdl/odata | odata_renderer/src/main/java/com/sdl/odata/renderer/xml/writer/XMLErrorResponseWriter.java | XMLErrorResponseWriter.startDocument | public void startDocument() throws ODataRenderException {
"""
Start the XML stream document by defining things like the type of encoding, and prefixes used.
It needs to be used before calling any write method.
@throws ODataRenderException if unable to render
"""
outputStream = new ByteArrayOutputStream();
try {
xmlWriter = xmlOutputFactory.createXMLStreamWriter(outputStream, UTF_8.name());
xmlWriter.writeStartDocument(UTF_8.name(), XML_VERSION);
xmlWriter.setPrefix(METADATA, ODATA_METADATA_NS);
} catch (XMLStreamException e) {
LOG.error("Not possible to start stream XML");
throw new ODataRenderException("Not possible to start stream XML: ", e);
}
} | java | public void startDocument() throws ODataRenderException {
outputStream = new ByteArrayOutputStream();
try {
xmlWriter = xmlOutputFactory.createXMLStreamWriter(outputStream, UTF_8.name());
xmlWriter.writeStartDocument(UTF_8.name(), XML_VERSION);
xmlWriter.setPrefix(METADATA, ODATA_METADATA_NS);
} catch (XMLStreamException e) {
LOG.error("Not possible to start stream XML");
throw new ODataRenderException("Not possible to start stream XML: ", e);
}
} | [
"public",
"void",
"startDocument",
"(",
")",
"throws",
"ODataRenderException",
"{",
"outputStream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"try",
"{",
"xmlWriter",
"=",
"xmlOutputFactory",
".",
"createXMLStreamWriter",
"(",
"outputStream",
",",
"UTF_8",
".",
"name",
"(",
")",
")",
";",
"xmlWriter",
".",
"writeStartDocument",
"(",
"UTF_8",
".",
"name",
"(",
")",
",",
"XML_VERSION",
")",
";",
"xmlWriter",
".",
"setPrefix",
"(",
"METADATA",
",",
"ODATA_METADATA_NS",
")",
";",
"}",
"catch",
"(",
"XMLStreamException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Not possible to start stream XML\"",
")",
";",
"throw",
"new",
"ODataRenderException",
"(",
"\"Not possible to start stream XML: \"",
",",
"e",
")",
";",
"}",
"}"
]
| Start the XML stream document by defining things like the type of encoding, and prefixes used.
It needs to be used before calling any write method.
@throws ODataRenderException if unable to render | [
"Start",
"the",
"XML",
"stream",
"document",
"by",
"defining",
"things",
"like",
"the",
"type",
"of",
"encoding",
"and",
"prefixes",
"used",
".",
"It",
"needs",
"to",
"be",
"used",
"before",
"calling",
"any",
"write",
"method",
"."
]
| train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_renderer/src/main/java/com/sdl/odata/renderer/xml/writer/XMLErrorResponseWriter.java#L60-L71 |
jeremiehuchet/acrachilisync | acrachilisync-core/src/main/java/fr/dudie/acrachilisync/utils/ChiliprojectUtils.java | ChiliprojectUtils.isSynchronized | public static boolean isSynchronized(final AcraReport pReport, final Issue pIssue)
throws IssueParseException {
"""
Gets wheter or not the given report has already been synchronized with the given issue.
@param pReport
an ACRA report
@param pIssue
a Chiliproject issue
@return true if the given report has already been synchronized with the given issue
@throws IssueParseException
the Date of one of the synchronized issue is unreadable
"""
final IssueDescriptionReader reader = new IssueDescriptionReader(pIssue);
return CollectionUtils.exists(reader.getOccurrences(), new ReportPredicate(pReport));
} | java | public static boolean isSynchronized(final AcraReport pReport, final Issue pIssue)
throws IssueParseException {
final IssueDescriptionReader reader = new IssueDescriptionReader(pIssue);
return CollectionUtils.exists(reader.getOccurrences(), new ReportPredicate(pReport));
} | [
"public",
"static",
"boolean",
"isSynchronized",
"(",
"final",
"AcraReport",
"pReport",
",",
"final",
"Issue",
"pIssue",
")",
"throws",
"IssueParseException",
"{",
"final",
"IssueDescriptionReader",
"reader",
"=",
"new",
"IssueDescriptionReader",
"(",
"pIssue",
")",
";",
"return",
"CollectionUtils",
".",
"exists",
"(",
"reader",
".",
"getOccurrences",
"(",
")",
",",
"new",
"ReportPredicate",
"(",
"pReport",
")",
")",
";",
"}"
]
| Gets wheter or not the given report has already been synchronized with the given issue.
@param pReport
an ACRA report
@param pIssue
a Chiliproject issue
@return true if the given report has already been synchronized with the given issue
@throws IssueParseException
the Date of one of the synchronized issue is unreadable | [
"Gets",
"wheter",
"or",
"not",
"the",
"given",
"report",
"has",
"already",
"been",
"synchronized",
"with",
"the",
"given",
"issue",
"."
]
| train | https://github.com/jeremiehuchet/acrachilisync/blob/4eadb0218623e77e0d92b5a08515eea2db51e988/acrachilisync-core/src/main/java/fr/dudie/acrachilisync/utils/ChiliprojectUtils.java#L55-L60 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/StatementManager.java | StatementManager.getStatement | public synchronized Statement getStatement(Session session, long csid) {
"""
Returns an existing CompiledStatement object with the given
statement identifier. Returns null if the CompiledStatement object
has been invalidated and cannot be recompiled
@param session the session
@param csid the identifier of the requested CompiledStatement object
@return the requested CompiledStatement object
"""
Statement cs = (Statement) csidMap.get(csid);
if (cs == null) {
return null;
}
if (!cs.isValid()) {
String sql = (String) sqlLookup.get(csid);
// revalidate with the original schema
try {
Session sys = database.sessionManager.getSysSession(
session.currentSchema.name, session.getUser());
cs = sys.compileStatement(sql);
cs.setID(csid);
csidMap.put(csid, cs);
} catch (Throwable t) {
freeStatement(csid, session.getId(), true);
return null;
}
}
return cs;
} | java | public synchronized Statement getStatement(Session session, long csid) {
Statement cs = (Statement) csidMap.get(csid);
if (cs == null) {
return null;
}
if (!cs.isValid()) {
String sql = (String) sqlLookup.get(csid);
// revalidate with the original schema
try {
Session sys = database.sessionManager.getSysSession(
session.currentSchema.name, session.getUser());
cs = sys.compileStatement(sql);
cs.setID(csid);
csidMap.put(csid, cs);
} catch (Throwable t) {
freeStatement(csid, session.getId(), true);
return null;
}
}
return cs;
} | [
"public",
"synchronized",
"Statement",
"getStatement",
"(",
"Session",
"session",
",",
"long",
"csid",
")",
"{",
"Statement",
"cs",
"=",
"(",
"Statement",
")",
"csidMap",
".",
"get",
"(",
"csid",
")",
";",
"if",
"(",
"cs",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"cs",
".",
"isValid",
"(",
")",
")",
"{",
"String",
"sql",
"=",
"(",
"String",
")",
"sqlLookup",
".",
"get",
"(",
"csid",
")",
";",
"// revalidate with the original schema",
"try",
"{",
"Session",
"sys",
"=",
"database",
".",
"sessionManager",
".",
"getSysSession",
"(",
"session",
".",
"currentSchema",
".",
"name",
",",
"session",
".",
"getUser",
"(",
")",
")",
";",
"cs",
"=",
"sys",
".",
"compileStatement",
"(",
"sql",
")",
";",
"cs",
".",
"setID",
"(",
"csid",
")",
";",
"csidMap",
".",
"put",
"(",
"csid",
",",
"cs",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"freeStatement",
"(",
"csid",
",",
"session",
".",
"getId",
"(",
")",
",",
"true",
")",
";",
"return",
"null",
";",
"}",
"}",
"return",
"cs",
";",
"}"
]
| Returns an existing CompiledStatement object with the given
statement identifier. Returns null if the CompiledStatement object
has been invalidated and cannot be recompiled
@param session the session
@param csid the identifier of the requested CompiledStatement object
@return the requested CompiledStatement object | [
"Returns",
"an",
"existing",
"CompiledStatement",
"object",
"with",
"the",
"given",
"statement",
"identifier",
".",
"Returns",
"null",
"if",
"the",
"CompiledStatement",
"object",
"has",
"been",
"invalidated",
"and",
"cannot",
"be",
"recompiled"
]
| train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/StatementManager.java#L198-L226 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java | SimpleDocTreeVisitor.visitSerial | @Override
public R visitSerial(SerialTree node, P p) {
"""
{@inheritDoc} This implementation calls {@code defaultAction}.
@param node {@inheritDoc}
@param p {@inheritDoc}
@return the result of {@code defaultAction}
"""
return defaultAction(node, p);
} | java | @Override
public R visitSerial(SerialTree node, P p) {
return defaultAction(node, p);
} | [
"@",
"Override",
"public",
"R",
"visitSerial",
"(",
"SerialTree",
"node",
",",
"P",
"p",
")",
"{",
"return",
"defaultAction",
"(",
"node",
",",
"p",
")",
";",
"}"
]
| {@inheritDoc} This implementation calls {@code defaultAction}.
@param node {@inheritDoc}
@param p {@inheritDoc}
@return the result of {@code defaultAction} | [
"{",
"@inheritDoc",
"}",
"This",
"implementation",
"calls",
"{",
"@code",
"defaultAction",
"}",
"."
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java#L345-L348 |
oasp/oasp4j | modules/rest/src/main/java/io/oasp/module/rest/service/impl/RestServiceExceptionFacade.java | RestServiceExceptionFacade.createResponse | protected Response createResponse(Status status, NlsRuntimeException error, String message, String code,
Map<String, List<String>> errorsMap) {
"""
Create a response message as a JSON-String from the given parts.
@param status is the HTTP {@link Status}.
@param error is the catched or wrapped {@link NlsRuntimeException}.
@param message is the JSON message attribute.
@param code is the {@link NlsRuntimeException#getCode() error code}.
@param errorsMap is a map with all validation errors
@return the corresponding {@link Response}.
"""
return createResponse(status, message, code, error.getUuid(), errorsMap);
} | java | protected Response createResponse(Status status, NlsRuntimeException error, String message, String code,
Map<String, List<String>> errorsMap) {
return createResponse(status, message, code, error.getUuid(), errorsMap);
} | [
"protected",
"Response",
"createResponse",
"(",
"Status",
"status",
",",
"NlsRuntimeException",
"error",
",",
"String",
"message",
",",
"String",
"code",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"errorsMap",
")",
"{",
"return",
"createResponse",
"(",
"status",
",",
"message",
",",
"code",
",",
"error",
".",
"getUuid",
"(",
")",
",",
"errorsMap",
")",
";",
"}"
]
| Create a response message as a JSON-String from the given parts.
@param status is the HTTP {@link Status}.
@param error is the catched or wrapped {@link NlsRuntimeException}.
@param message is the JSON message attribute.
@param code is the {@link NlsRuntimeException#getCode() error code}.
@param errorsMap is a map with all validation errors
@return the corresponding {@link Response}. | [
"Create",
"a",
"response",
"message",
"as",
"a",
"JSON",
"-",
"String",
"from",
"the",
"given",
"parts",
"."
]
| train | https://github.com/oasp/oasp4j/blob/03f90132699fad95e52ec8efa54aa391f8d3c7e4/modules/rest/src/main/java/io/oasp/module/rest/service/impl/RestServiceExceptionFacade.java#L442-L446 |
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.listIntentsAsync | public Observable<List<IntentClassifier>> listIntentsAsync(UUID appId, String versionId, ListIntentsOptionalParameter listIntentsOptionalParameter) {
"""
Gets information about the intent models.
@param appId The application ID.
@param versionId The version ID.
@param listIntentsOptionalParameter 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<IntentClassifier> object
"""
return listIntentsWithServiceResponseAsync(appId, versionId, listIntentsOptionalParameter).map(new Func1<ServiceResponse<List<IntentClassifier>>, List<IntentClassifier>>() {
@Override
public List<IntentClassifier> call(ServiceResponse<List<IntentClassifier>> response) {
return response.body();
}
});
} | java | public Observable<List<IntentClassifier>> listIntentsAsync(UUID appId, String versionId, ListIntentsOptionalParameter listIntentsOptionalParameter) {
return listIntentsWithServiceResponseAsync(appId, versionId, listIntentsOptionalParameter).map(new Func1<ServiceResponse<List<IntentClassifier>>, List<IntentClassifier>>() {
@Override
public List<IntentClassifier> call(ServiceResponse<List<IntentClassifier>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"IntentClassifier",
">",
">",
"listIntentsAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"ListIntentsOptionalParameter",
"listIntentsOptionalParameter",
")",
"{",
"return",
"listIntentsWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"listIntentsOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"IntentClassifier",
">",
">",
",",
"List",
"<",
"IntentClassifier",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"IntentClassifier",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"IntentClassifier",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Gets information about the intent models.
@param appId The application ID.
@param versionId The version ID.
@param listIntentsOptionalParameter 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<IntentClassifier> object | [
"Gets",
"information",
"about",
"the",
"intent",
"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#L781-L788 |
craftercms/commons | utilities/src/main/java/org/craftercms/commons/monitoring/MemoryMonitor.java | MemoryMonitor.getMemoryStats | public static List<MemoryMonitor> getMemoryStats() {
"""
Query all register MemoryPools to get information and create a {@link MemoryMonitor} Pojo
@return List with all the memory usage stats.
"""
ArrayList<MemoryMonitor> memoryPoolInformation = new ArrayList<>();
MemoryUsage heapMem = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
memoryPoolInformation.add(new MemoryMonitor(HEAP_MEMORY,heapMem));
MemoryUsage nonHeapMen = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
memoryPoolInformation.add(new MemoryMonitor(NON_HEAP_MEMORY,nonHeapMen));
for(MemoryPoolMXBean memMXBean :ManagementFactory.getMemoryPoolMXBeans()){
memoryPoolInformation.add(new MemoryMonitor(memMXBean.getName(), memMXBean.getUsage()));
}
return Collections.unmodifiableList(memoryPoolInformation);
} | java | public static List<MemoryMonitor> getMemoryStats(){
ArrayList<MemoryMonitor> memoryPoolInformation = new ArrayList<>();
MemoryUsage heapMem = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
memoryPoolInformation.add(new MemoryMonitor(HEAP_MEMORY,heapMem));
MemoryUsage nonHeapMen = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
memoryPoolInformation.add(new MemoryMonitor(NON_HEAP_MEMORY,nonHeapMen));
for(MemoryPoolMXBean memMXBean :ManagementFactory.getMemoryPoolMXBeans()){
memoryPoolInformation.add(new MemoryMonitor(memMXBean.getName(), memMXBean.getUsage()));
}
return Collections.unmodifiableList(memoryPoolInformation);
} | [
"public",
"static",
"List",
"<",
"MemoryMonitor",
">",
"getMemoryStats",
"(",
")",
"{",
"ArrayList",
"<",
"MemoryMonitor",
">",
"memoryPoolInformation",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"MemoryUsage",
"heapMem",
"=",
"ManagementFactory",
".",
"getMemoryMXBean",
"(",
")",
".",
"getHeapMemoryUsage",
"(",
")",
";",
"memoryPoolInformation",
".",
"add",
"(",
"new",
"MemoryMonitor",
"(",
"HEAP_MEMORY",
",",
"heapMem",
")",
")",
";",
"MemoryUsage",
"nonHeapMen",
"=",
"ManagementFactory",
".",
"getMemoryMXBean",
"(",
")",
".",
"getNonHeapMemoryUsage",
"(",
")",
";",
"memoryPoolInformation",
".",
"add",
"(",
"new",
"MemoryMonitor",
"(",
"NON_HEAP_MEMORY",
",",
"nonHeapMen",
")",
")",
";",
"for",
"(",
"MemoryPoolMXBean",
"memMXBean",
":",
"ManagementFactory",
".",
"getMemoryPoolMXBeans",
"(",
")",
")",
"{",
"memoryPoolInformation",
".",
"add",
"(",
"new",
"MemoryMonitor",
"(",
"memMXBean",
".",
"getName",
"(",
")",
",",
"memMXBean",
".",
"getUsage",
"(",
")",
")",
")",
";",
"}",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"memoryPoolInformation",
")",
";",
"}"
]
| Query all register MemoryPools to get information and create a {@link MemoryMonitor} Pojo
@return List with all the memory usage stats. | [
"Query",
"all",
"register",
"MemoryPools",
"to",
"get",
"information",
"and",
"create",
"a",
"{"
]
| train | https://github.com/craftercms/commons/blob/3074fe49e56c2a4aae0832f40b17ae563335dc83/utilities/src/main/java/org/craftercms/commons/monitoring/MemoryMonitor.java#L62-L73 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java | KltTracker.unsafe_setImage | public void unsafe_setImage(I image, D derivX, D derivY) {
"""
Same as {@link #setImage}, but it doesn't check to see if the images are the same size each time
"""
this.image = image;
this.interpInput.setImage(image);
this.derivX = derivX;
this.derivY = derivY;
} | java | public void unsafe_setImage(I image, D derivX, D derivY) {
this.image = image;
this.interpInput.setImage(image);
this.derivX = derivX;
this.derivY = derivY;
} | [
"public",
"void",
"unsafe_setImage",
"(",
"I",
"image",
",",
"D",
"derivX",
",",
"D",
"derivY",
")",
"{",
"this",
".",
"image",
"=",
"image",
";",
"this",
".",
"interpInput",
".",
"setImage",
"(",
"image",
")",
";",
"this",
".",
"derivX",
"=",
"derivX",
";",
"this",
".",
"derivY",
"=",
"derivY",
";",
"}"
]
| Same as {@link #setImage}, but it doesn't check to see if the images are the same size each time | [
"Same",
"as",
"{"
]
| train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java#L132-L138 |
netty/netty | buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java | CompositeByteBuf.addComponents | public CompositeByteBuf addComponents(boolean increaseWriterIndex, Iterable<ByteBuf> buffers) {
"""
Add the given {@link ByteBuf}s and increase the {@code writerIndex} if {@code increaseWriterIndex} is
{@code true}.
{@link ByteBuf#release()} ownership of all {@link ByteBuf} objects in {@code buffers} is transferred to this
{@link CompositeByteBuf}.
@param buffers the {@link ByteBuf}s to add. {@link ByteBuf#release()} ownership of all {@link ByteBuf#release()}
ownership of all {@link ByteBuf} objects is transferred to this {@link CompositeByteBuf}.
"""
return addComponents(increaseWriterIndex, componentCount, buffers);
} | java | public CompositeByteBuf addComponents(boolean increaseWriterIndex, Iterable<ByteBuf> buffers) {
return addComponents(increaseWriterIndex, componentCount, buffers);
} | [
"public",
"CompositeByteBuf",
"addComponents",
"(",
"boolean",
"increaseWriterIndex",
",",
"Iterable",
"<",
"ByteBuf",
">",
"buffers",
")",
"{",
"return",
"addComponents",
"(",
"increaseWriterIndex",
",",
"componentCount",
",",
"buffers",
")",
";",
"}"
]
| Add the given {@link ByteBuf}s and increase the {@code writerIndex} if {@code increaseWriterIndex} is
{@code true}.
{@link ByteBuf#release()} ownership of all {@link ByteBuf} objects in {@code buffers} is transferred to this
{@link CompositeByteBuf}.
@param buffers the {@link ByteBuf}s to add. {@link ByteBuf#release()} ownership of all {@link ByteBuf#release()}
ownership of all {@link ByteBuf} objects is transferred to this {@link CompositeByteBuf}. | [
"Add",
"the",
"given",
"{",
"@link",
"ByteBuf",
"}",
"s",
"and",
"increase",
"the",
"{",
"@code",
"writerIndex",
"}",
"if",
"{",
"@code",
"increaseWriterIndex",
"}",
"is",
"{",
"@code",
"true",
"}",
"."
]
| train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java#L250-L252 |
phax/ph-css | ph-css/src/main/java/com/helger/css/reader/CSSReader.java | CSSReader.readFromString | @Nullable
public static CascadingStyleSheet readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion) {
"""
Read the CSS from the passed String using a character stream. An eventually
contained <code>@charset</code> rule is ignored.
@param sCSS
The source string containing the CSS to be parsed. May not be
<code>null</code>.
@param eVersion
The CSS version to use. May not be <code>null</code>.
@return <code>null</code> if reading failed, the CSS declarations
otherwise.
@since 3.7.3
"""
return readFromStringReader (sCSS, new CSSReaderSettings ().setCSSVersion (eVersion));
} | java | @Nullable
public static CascadingStyleSheet readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion)
{
return readFromStringReader (sCSS, new CSSReaderSettings ().setCSSVersion (eVersion));
} | [
"@",
"Nullable",
"public",
"static",
"CascadingStyleSheet",
"readFromString",
"(",
"@",
"Nonnull",
"final",
"String",
"sCSS",
",",
"@",
"Nonnull",
"final",
"ECSSVersion",
"eVersion",
")",
"{",
"return",
"readFromStringReader",
"(",
"sCSS",
",",
"new",
"CSSReaderSettings",
"(",
")",
".",
"setCSSVersion",
"(",
"eVersion",
")",
")",
";",
"}"
]
| Read the CSS from the passed String using a character stream. An eventually
contained <code>@charset</code> rule is ignored.
@param sCSS
The source string containing the CSS to be parsed. May not be
<code>null</code>.
@param eVersion
The CSS version to use. May not be <code>null</code>.
@return <code>null</code> if reading failed, the CSS declarations
otherwise.
@since 3.7.3 | [
"Read",
"the",
"CSS",
"from",
"the",
"passed",
"String",
"using",
"a",
"character",
"stream",
".",
"An",
"eventually",
"contained",
"<code",
">",
"@charset<",
"/",
"code",
">",
"rule",
"is",
"ignored",
"."
]
| train | https://github.com/phax/ph-css/blob/c9da5bb4decc681de6e27ce31712aad4c00adafa/ph-css/src/main/java/com/helger/css/reader/CSSReader.java#L523-L527 |
igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoStore.java | OmemoStore.storeOmemoPreKeys | public void storeOmemoPreKeys(OmemoDevice userDevice, TreeMap<Integer, T_PreKey> preKeyHashMap) {
"""
Store a whole bunch of preKeys.
@param userDevice our OmemoDevice.
@param preKeyHashMap HashMap of preKeys
"""
for (Map.Entry<Integer, T_PreKey> entry : preKeyHashMap.entrySet()) {
storeOmemoPreKey(userDevice, entry.getKey(), entry.getValue());
}
} | java | public void storeOmemoPreKeys(OmemoDevice userDevice, TreeMap<Integer, T_PreKey> preKeyHashMap) {
for (Map.Entry<Integer, T_PreKey> entry : preKeyHashMap.entrySet()) {
storeOmemoPreKey(userDevice, entry.getKey(), entry.getValue());
}
} | [
"public",
"void",
"storeOmemoPreKeys",
"(",
"OmemoDevice",
"userDevice",
",",
"TreeMap",
"<",
"Integer",
",",
"T_PreKey",
">",
"preKeyHashMap",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"T_PreKey",
">",
"entry",
":",
"preKeyHashMap",
".",
"entrySet",
"(",
")",
")",
"{",
"storeOmemoPreKey",
"(",
"userDevice",
",",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
]
| Store a whole bunch of preKeys.
@param userDevice our OmemoDevice.
@param preKeyHashMap HashMap of preKeys | [
"Store",
"a",
"whole",
"bunch",
"of",
"preKeys",
"."
]
| train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoStore.java#L404-L408 |
voldemort/voldemort | src/java/voldemort/utils/UpdateClusterUtils.java | UpdateClusterUtils.addPartitionToNode | public static Node addPartitionToNode(final Node node, Integer donatedPartition) {
"""
Add a partition to the node provided
@param node The node to which we'll add the partition
@param donatedPartition The partition to add
@return The new node with the new partition
"""
return UpdateClusterUtils.addPartitionsToNode(node, Sets.newHashSet(donatedPartition));
} | java | public static Node addPartitionToNode(final Node node, Integer donatedPartition) {
return UpdateClusterUtils.addPartitionsToNode(node, Sets.newHashSet(donatedPartition));
} | [
"public",
"static",
"Node",
"addPartitionToNode",
"(",
"final",
"Node",
"node",
",",
"Integer",
"donatedPartition",
")",
"{",
"return",
"UpdateClusterUtils",
".",
"addPartitionsToNode",
"(",
"node",
",",
"Sets",
".",
"newHashSet",
"(",
"donatedPartition",
")",
")",
";",
"}"
]
| Add a partition to the node provided
@param node The node to which we'll add the partition
@param donatedPartition The partition to add
@return The new node with the new partition | [
"Add",
"a",
"partition",
"to",
"the",
"node",
"provided"
]
| train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/UpdateClusterUtils.java#L67-L69 |
foundation-runtime/service-directory | 1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java | HeartbeatDirectoryRegistrationService.getCachedServiceInstance | private CachedProviderServiceInstance getCachedServiceInstance(
String serviceName, String providerId) {
"""
Get the Cached ProvidedServiceInstance by serviceName and providerId.
It is thread safe.
@param serviceName
the serviceName
@param providerId
the providerId
@return
the CachedProviderServiceInstance
"""
try {
read.lock();
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerId);
return getCacheServiceInstances().get(id);
} finally {
read.unlock();
}
} | java | private CachedProviderServiceInstance getCachedServiceInstance(
String serviceName, String providerId) {
try {
read.lock();
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerId);
return getCacheServiceInstances().get(id);
} finally {
read.unlock();
}
} | [
"private",
"CachedProviderServiceInstance",
"getCachedServiceInstance",
"(",
"String",
"serviceName",
",",
"String",
"providerId",
")",
"{",
"try",
"{",
"read",
".",
"lock",
"(",
")",
";",
"ServiceInstanceId",
"id",
"=",
"new",
"ServiceInstanceId",
"(",
"serviceName",
",",
"providerId",
")",
";",
"return",
"getCacheServiceInstances",
"(",
")",
".",
"get",
"(",
"id",
")",
";",
"}",
"finally",
"{",
"read",
".",
"unlock",
"(",
")",
";",
"}",
"}"
]
| Get the Cached ProvidedServiceInstance by serviceName and providerId.
It is thread safe.
@param serviceName
the serviceName
@param providerId
the providerId
@return
the CachedProviderServiceInstance | [
"Get",
"the",
"Cached",
"ProvidedServiceInstance",
"by",
"serviceName",
"and",
"providerId",
"."
]
| train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java#L350-L359 |
threerings/nenya | core/src/main/java/com/threerings/cast/builder/ComponentPanel.java | ComponentPanel.addClassEditors | protected void addClassEditors (BuilderModel model, String cprefix) {
"""
Adds editor user interface elements for each component class to
allow the user to select the desired component.
"""
List<ComponentClass> classes = model.getComponentClasses();
int size = classes.size();
for (int ii = 0; ii < size; ii++) {
ComponentClass cclass = classes.get(ii);
if (!cclass.name.startsWith(cprefix)) {
continue;
}
List<Integer> ccomps = model.getComponents(cclass);
if (ccomps.size() > 0) {
add(new ClassEditor(model, cclass, ccomps));
} else {
log.info("Not creating editor for empty class " +
"[class=" + cclass + "].");
}
}
} | java | protected void addClassEditors (BuilderModel model, String cprefix)
{
List<ComponentClass> classes = model.getComponentClasses();
int size = classes.size();
for (int ii = 0; ii < size; ii++) {
ComponentClass cclass = classes.get(ii);
if (!cclass.name.startsWith(cprefix)) {
continue;
}
List<Integer> ccomps = model.getComponents(cclass);
if (ccomps.size() > 0) {
add(new ClassEditor(model, cclass, ccomps));
} else {
log.info("Not creating editor for empty class " +
"[class=" + cclass + "].");
}
}
} | [
"protected",
"void",
"addClassEditors",
"(",
"BuilderModel",
"model",
",",
"String",
"cprefix",
")",
"{",
"List",
"<",
"ComponentClass",
">",
"classes",
"=",
"model",
".",
"getComponentClasses",
"(",
")",
";",
"int",
"size",
"=",
"classes",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"size",
";",
"ii",
"++",
")",
"{",
"ComponentClass",
"cclass",
"=",
"classes",
".",
"get",
"(",
"ii",
")",
";",
"if",
"(",
"!",
"cclass",
".",
"name",
".",
"startsWith",
"(",
"cprefix",
")",
")",
"{",
"continue",
";",
"}",
"List",
"<",
"Integer",
">",
"ccomps",
"=",
"model",
".",
"getComponents",
"(",
"cclass",
")",
";",
"if",
"(",
"ccomps",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"add",
"(",
"new",
"ClassEditor",
"(",
"model",
",",
"cclass",
",",
"ccomps",
")",
")",
";",
"}",
"else",
"{",
"log",
".",
"info",
"(",
"\"Not creating editor for empty class \"",
"+",
"\"[class=\"",
"+",
"cclass",
"+",
"\"].\"",
")",
";",
"}",
"}",
"}"
]
| Adds editor user interface elements for each component class to
allow the user to select the desired component. | [
"Adds",
"editor",
"user",
"interface",
"elements",
"for",
"each",
"component",
"class",
"to",
"allow",
"the",
"user",
"to",
"select",
"the",
"desired",
"component",
"."
]
| train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/ComponentPanel.java#L56-L73 |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/AdHocBase.java | AdHocBase.runAdHoc | public VoltTable[] runAdHoc(SystemProcedureExecutionContext ctx, byte[] serializedBatchData) {
"""
Call from derived class run() method for implementation.
@param ctx
@param aggregatorFragments
@param collectorFragments
@param sqlStatements
@param replicatedTableDMLFlags
@return
"""
Pair<Object[], AdHocPlannedStatement[]> data = decodeSerializedBatchData(serializedBatchData);
Object[] userparams = data.getFirst();
AdHocPlannedStatement[] statements = data.getSecond();
if (statements.length == 0) {
return new VoltTable[]{};
}
for (AdHocPlannedStatement statement : statements) {
if (!statement.core.wasPlannedAgainstHash(ctx.getCatalogHash())) {
@SuppressWarnings("deprecation")
String msg = String.format("AdHoc transaction %d wasn't planned " +
"against the current catalog version. Statement: %s",
DeprecatedProcedureAPIAccess.getVoltPrivateRealTransactionId(this),
new String(statement.sql, Constants.UTF8ENCODING));
throw new VoltAbortException(msg);
}
// Don't cache the statement text, since ad hoc statements
// that differ only by constants reuse the same plan, statement text may change.
long aggFragId = ActivePlanRepository.loadOrAddRefPlanFragment(
statement.core.aggregatorHash, statement.core.aggregatorFragment, null);
long collectorFragId = 0;
if (statement.core.collectorFragment != null) {
collectorFragId = ActivePlanRepository.loadOrAddRefPlanFragment(
statement.core.collectorHash, statement.core.collectorFragment, null);
}
SQLStmt stmt = SQLStmtAdHocHelper.createWithPlan(
statement.sql,
aggFragId,
statement.core.aggregatorHash,
true,
collectorFragId,
statement.core.collectorHash,
true,
statement.core.isReplicatedTableDML,
statement.core.readOnly,
statement.core.parameterTypes,
m_site);
Object[] params = paramsForStatement(statement, userparams);
voltQueueSQL(stmt, params);
}
return voltExecuteSQL(true);
} | java | public VoltTable[] runAdHoc(SystemProcedureExecutionContext ctx, byte[] serializedBatchData) {
Pair<Object[], AdHocPlannedStatement[]> data = decodeSerializedBatchData(serializedBatchData);
Object[] userparams = data.getFirst();
AdHocPlannedStatement[] statements = data.getSecond();
if (statements.length == 0) {
return new VoltTable[]{};
}
for (AdHocPlannedStatement statement : statements) {
if (!statement.core.wasPlannedAgainstHash(ctx.getCatalogHash())) {
@SuppressWarnings("deprecation")
String msg = String.format("AdHoc transaction %d wasn't planned " +
"against the current catalog version. Statement: %s",
DeprecatedProcedureAPIAccess.getVoltPrivateRealTransactionId(this),
new String(statement.sql, Constants.UTF8ENCODING));
throw new VoltAbortException(msg);
}
// Don't cache the statement text, since ad hoc statements
// that differ only by constants reuse the same plan, statement text may change.
long aggFragId = ActivePlanRepository.loadOrAddRefPlanFragment(
statement.core.aggregatorHash, statement.core.aggregatorFragment, null);
long collectorFragId = 0;
if (statement.core.collectorFragment != null) {
collectorFragId = ActivePlanRepository.loadOrAddRefPlanFragment(
statement.core.collectorHash, statement.core.collectorFragment, null);
}
SQLStmt stmt = SQLStmtAdHocHelper.createWithPlan(
statement.sql,
aggFragId,
statement.core.aggregatorHash,
true,
collectorFragId,
statement.core.collectorHash,
true,
statement.core.isReplicatedTableDML,
statement.core.readOnly,
statement.core.parameterTypes,
m_site);
Object[] params = paramsForStatement(statement, userparams);
voltQueueSQL(stmt, params);
}
return voltExecuteSQL(true);
} | [
"public",
"VoltTable",
"[",
"]",
"runAdHoc",
"(",
"SystemProcedureExecutionContext",
"ctx",
",",
"byte",
"[",
"]",
"serializedBatchData",
")",
"{",
"Pair",
"<",
"Object",
"[",
"]",
",",
"AdHocPlannedStatement",
"[",
"]",
">",
"data",
"=",
"decodeSerializedBatchData",
"(",
"serializedBatchData",
")",
";",
"Object",
"[",
"]",
"userparams",
"=",
"data",
".",
"getFirst",
"(",
")",
";",
"AdHocPlannedStatement",
"[",
"]",
"statements",
"=",
"data",
".",
"getSecond",
"(",
")",
";",
"if",
"(",
"statements",
".",
"length",
"==",
"0",
")",
"{",
"return",
"new",
"VoltTable",
"[",
"]",
"{",
"}",
";",
"}",
"for",
"(",
"AdHocPlannedStatement",
"statement",
":",
"statements",
")",
"{",
"if",
"(",
"!",
"statement",
".",
"core",
".",
"wasPlannedAgainstHash",
"(",
"ctx",
".",
"getCatalogHash",
"(",
")",
")",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"String",
"msg",
"=",
"String",
".",
"format",
"(",
"\"AdHoc transaction %d wasn't planned \"",
"+",
"\"against the current catalog version. Statement: %s\"",
",",
"DeprecatedProcedureAPIAccess",
".",
"getVoltPrivateRealTransactionId",
"(",
"this",
")",
",",
"new",
"String",
"(",
"statement",
".",
"sql",
",",
"Constants",
".",
"UTF8ENCODING",
")",
")",
";",
"throw",
"new",
"VoltAbortException",
"(",
"msg",
")",
";",
"}",
"// Don't cache the statement text, since ad hoc statements",
"// that differ only by constants reuse the same plan, statement text may change.",
"long",
"aggFragId",
"=",
"ActivePlanRepository",
".",
"loadOrAddRefPlanFragment",
"(",
"statement",
".",
"core",
".",
"aggregatorHash",
",",
"statement",
".",
"core",
".",
"aggregatorFragment",
",",
"null",
")",
";",
"long",
"collectorFragId",
"=",
"0",
";",
"if",
"(",
"statement",
".",
"core",
".",
"collectorFragment",
"!=",
"null",
")",
"{",
"collectorFragId",
"=",
"ActivePlanRepository",
".",
"loadOrAddRefPlanFragment",
"(",
"statement",
".",
"core",
".",
"collectorHash",
",",
"statement",
".",
"core",
".",
"collectorFragment",
",",
"null",
")",
";",
"}",
"SQLStmt",
"stmt",
"=",
"SQLStmtAdHocHelper",
".",
"createWithPlan",
"(",
"statement",
".",
"sql",
",",
"aggFragId",
",",
"statement",
".",
"core",
".",
"aggregatorHash",
",",
"true",
",",
"collectorFragId",
",",
"statement",
".",
"core",
".",
"collectorHash",
",",
"true",
",",
"statement",
".",
"core",
".",
"isReplicatedTableDML",
",",
"statement",
".",
"core",
".",
"readOnly",
",",
"statement",
".",
"core",
".",
"parameterTypes",
",",
"m_site",
")",
";",
"Object",
"[",
"]",
"params",
"=",
"paramsForStatement",
"(",
"statement",
",",
"userparams",
")",
";",
"voltQueueSQL",
"(",
"stmt",
",",
"params",
")",
";",
"}",
"return",
"voltExecuteSQL",
"(",
"true",
")",
";",
"}"
]
| Call from derived class run() method for implementation.
@param ctx
@param aggregatorFragments
@param collectorFragments
@param sqlStatements
@param replicatedTableDMLFlags
@return | [
"Call",
"from",
"derived",
"class",
"run",
"()",
"method",
"for",
"implementation",
"."
]
| train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/AdHocBase.java#L174-L221 |
ppiastucki/recast4j | detourcrowd/src/main/java/org/recast4j/detour/crowd/PathCorridor.java | PathCorridor.moveTargetPosition | public boolean moveTargetPosition(float[] npos, NavMeshQuery navquery, QueryFilter filter) {
"""
Moves the target from the curent location to the desired location, adjusting the corridor as needed to reflect
the change. Behavior: - The movement is constrained to the surface of the navigation mesh. - The corridor is
automatically adjusted (shorted or lengthened) in order to remain valid. - The new target will be located in the
adjusted corridor's last polygon.
The expected use case is that the desired target will be 'near' the current corridor. What is considered 'near'
depends on local polygon density, query search extents, etc. The resulting target will differ from the desired
target if the desired target is not on the navigation mesh, or it can't be reached using a local search.
@param npos
The desired new target position. [(x, y, z)]
@param navquery
The query object used to build the corridor.
@param filter
The filter to apply to the operation.
"""
// Move along navmesh and update new position.
Result<MoveAlongSurfaceResult> masResult = navquery.moveAlongSurface(m_path.get(m_path.size() - 1), m_target,
npos, filter);
if (masResult.succeeded()) {
m_path = mergeCorridorEndMoved(m_path, masResult.result.getVisited());
// TODO: should we do that?
// Adjust the position to stay on top of the navmesh.
/*
* float h = m_target[1]; navquery->getPolyHeight(m_path[m_npath-1],
* result, &h); result[1] = h;
*/
vCopy(m_target, masResult.result.getResultPos());
return true;
}
return false;
} | java | public boolean moveTargetPosition(float[] npos, NavMeshQuery navquery, QueryFilter filter) {
// Move along navmesh and update new position.
Result<MoveAlongSurfaceResult> masResult = navquery.moveAlongSurface(m_path.get(m_path.size() - 1), m_target,
npos, filter);
if (masResult.succeeded()) {
m_path = mergeCorridorEndMoved(m_path, masResult.result.getVisited());
// TODO: should we do that?
// Adjust the position to stay on top of the navmesh.
/*
* float h = m_target[1]; navquery->getPolyHeight(m_path[m_npath-1],
* result, &h); result[1] = h;
*/
vCopy(m_target, masResult.result.getResultPos());
return true;
}
return false;
} | [
"public",
"boolean",
"moveTargetPosition",
"(",
"float",
"[",
"]",
"npos",
",",
"NavMeshQuery",
"navquery",
",",
"QueryFilter",
"filter",
")",
"{",
"// Move along navmesh and update new position.",
"Result",
"<",
"MoveAlongSurfaceResult",
">",
"masResult",
"=",
"navquery",
".",
"moveAlongSurface",
"(",
"m_path",
".",
"get",
"(",
"m_path",
".",
"size",
"(",
")",
"-",
"1",
")",
",",
"m_target",
",",
"npos",
",",
"filter",
")",
";",
"if",
"(",
"masResult",
".",
"succeeded",
"(",
")",
")",
"{",
"m_path",
"=",
"mergeCorridorEndMoved",
"(",
"m_path",
",",
"masResult",
".",
"result",
".",
"getVisited",
"(",
")",
")",
";",
"// TODO: should we do that?",
"// Adjust the position to stay on top of the navmesh.",
"/*\n * float h = m_target[1]; navquery->getPolyHeight(m_path[m_npath-1],\n * result, &h); result[1] = h;\n */",
"vCopy",
"(",
"m_target",
",",
"masResult",
".",
"result",
".",
"getResultPos",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Moves the target from the curent location to the desired location, adjusting the corridor as needed to reflect
the change. Behavior: - The movement is constrained to the surface of the navigation mesh. - The corridor is
automatically adjusted (shorted or lengthened) in order to remain valid. - The new target will be located in the
adjusted corridor's last polygon.
The expected use case is that the desired target will be 'near' the current corridor. What is considered 'near'
depends on local polygon density, query search extents, etc. The resulting target will differ from the desired
target if the desired target is not on the navigation mesh, or it can't be reached using a local search.
@param npos
The desired new target position. [(x, y, z)]
@param navquery
The query object used to build the corridor.
@param filter
The filter to apply to the operation. | [
"Moves",
"the",
"target",
"from",
"the",
"curent",
"location",
"to",
"the",
"desired",
"location",
"adjusting",
"the",
"corridor",
"as",
"needed",
"to",
"reflect",
"the",
"change",
".",
"Behavior",
":",
"-",
"The",
"movement",
"is",
"constrained",
"to",
"the",
"surface",
"of",
"the",
"navigation",
"mesh",
".",
"-",
"The",
"corridor",
"is",
"automatically",
"adjusted",
"(",
"shorted",
"or",
"lengthened",
")",
"in",
"order",
"to",
"remain",
"valid",
".",
"-",
"The",
"new",
"target",
"will",
"be",
"located",
"in",
"the",
"adjusted",
"corridor",
"s",
"last",
"polygon",
"."
]
| train | https://github.com/ppiastucki/recast4j/blob/a414dc34f16b87c95fb4e0f46c28a7830d421788/detourcrowd/src/main/java/org/recast4j/detour/crowd/PathCorridor.java#L417-L433 |
aws/aws-sdk-java | aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/transform/AclXmlFactory.java | AclXmlFactory.convertToXml | protected XmlWriter convertToXml(EmailAddressGrantee grantee, XmlWriter xml) {
"""
Returns an XML fragment representing the specified email address grantee.
@param grantee
The email address grantee to convert to an XML representation
that can be sent to Amazon S3 as part of request.
@param xml
The XmlWriter to which to concatenate this node to.
@return The given XmlWriter containing the specified email address grantee
"""
xml.start("Grantee", new String[] {"xmlns:xsi" , "xsi:type"},
new String[] {"http://www.w3.org/2001/XMLSchema-instance", "AmazonCustomerByEmail"});
xml.start("EmailAddress").value(grantee.getIdentifier()).end();
xml.end();
return xml;
} | java | protected XmlWriter convertToXml(EmailAddressGrantee grantee, XmlWriter xml) {
xml.start("Grantee", new String[] {"xmlns:xsi" , "xsi:type"},
new String[] {"http://www.w3.org/2001/XMLSchema-instance", "AmazonCustomerByEmail"});
xml.start("EmailAddress").value(grantee.getIdentifier()).end();
xml.end();
return xml;
} | [
"protected",
"XmlWriter",
"convertToXml",
"(",
"EmailAddressGrantee",
"grantee",
",",
"XmlWriter",
"xml",
")",
"{",
"xml",
".",
"start",
"(",
"\"Grantee\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"xmlns:xsi\"",
",",
"\"xsi:type\"",
"}",
",",
"new",
"String",
"[",
"]",
"{",
"\"http://www.w3.org/2001/XMLSchema-instance\"",
",",
"\"AmazonCustomerByEmail\"",
"}",
")",
";",
"xml",
".",
"start",
"(",
"\"EmailAddress\"",
")",
".",
"value",
"(",
"grantee",
".",
"getIdentifier",
"(",
")",
")",
".",
"end",
"(",
")",
";",
"xml",
".",
"end",
"(",
")",
";",
"return",
"xml",
";",
"}"
]
| Returns an XML fragment representing the specified email address grantee.
@param grantee
The email address grantee to convert to an XML representation
that can be sent to Amazon S3 as part of request.
@param xml
The XmlWriter to which to concatenate this node to.
@return The given XmlWriter containing the specified email address grantee | [
"Returns",
"an",
"XML",
"fragment",
"representing",
"the",
"specified",
"email",
"address",
"grantee",
"."
]
| train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/transform/AclXmlFactory.java#L130-L137 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/Zodiac.java | Zodiac.getZodiac | public static String getZodiac(int month, int day) {
"""
通过生日计算星座
@param month 月,从0开始计数,见{@link Month#getValue()}
@param day 天
@return 星座名
"""
// 在分隔日前为前一个星座,否则为后一个星座
return day < dayArr[month] ? ZODIACS[month] : ZODIACS[month + 1];
} | java | public static String getZodiac(int month, int day) {
// 在分隔日前为前一个星座,否则为后一个星座
return day < dayArr[month] ? ZODIACS[month] : ZODIACS[month + 1];
} | [
"public",
"static",
"String",
"getZodiac",
"(",
"int",
"month",
",",
"int",
"day",
")",
"{",
"// 在分隔日前为前一个星座,否则为后一个星座\r",
"return",
"day",
"<",
"dayArr",
"[",
"month",
"]",
"?",
"ZODIACS",
"[",
"month",
"]",
":",
"ZODIACS",
"[",
"month",
"+",
"1",
"]",
";",
"}"
]
| 通过生日计算星座
@param month 月,从0开始计数,见{@link Month#getValue()}
@param day 天
@return 星座名 | [
"通过生日计算星座"
]
| train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/Zodiac.java#L62-L65 |
looly/hutool | hutool-cron/src/main/java/cn/hutool/cron/Scheduler.java | Scheduler.schedule | public Scheduler schedule(String id, String pattern, Runnable task) {
"""
新增Task
@param id ID,为每一个Task定义一个ID
@param pattern {@link CronPattern}对应的String表达式
@param task {@link Runnable}
@return this
"""
return schedule(id, new CronPattern(pattern), new RunnableTask(task));
} | java | public Scheduler schedule(String id, String pattern, Runnable task) {
return schedule(id, new CronPattern(pattern), new RunnableTask(task));
} | [
"public",
"Scheduler",
"schedule",
"(",
"String",
"id",
",",
"String",
"pattern",
",",
"Runnable",
"task",
")",
"{",
"return",
"schedule",
"(",
"id",
",",
"new",
"CronPattern",
"(",
"pattern",
")",
",",
"new",
"RunnableTask",
"(",
"task",
")",
")",
";",
"}"
]
| 新增Task
@param id ID,为每一个Task定义一个ID
@param pattern {@link CronPattern}对应的String表达式
@param task {@link Runnable}
@return this | [
"新增Task"
]
| train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-cron/src/main/java/cn/hutool/cron/Scheduler.java#L231-L233 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/converter/json/ObjectToJsonConverter.java | ObjectToJsonConverter.extractObjectWithContext | private Object extractObjectWithContext(Object pValue, Stack<String> pExtraArgs, JsonConvertOptions pOpts, boolean pJsonify)
throws AttributeNotFoundException {
"""
Handle a value which means to dive into the internal of a complex object
(if <code>pExtraArgs</code> is not null) and/or to convert
it to JSON (if <code>pJsonify</code> is true).
@param pValue value to extract from
@param pExtraArgs stack used for diving in to the value
@param pOpts options from which various processing
parameters (like maxDepth, maxCollectionSize and maxObjects) are taken and put
into context in order to influence the object traversal.
@param pJsonify whether the result should be returned as an JSON object
@return extracted value, either natively or as JSON
@throws AttributeNotFoundException if during traversal an attribute is not found as specified in the stack
"""
Object jsonResult;
setupContext(pOpts);
try {
jsonResult = extractObject(pValue, pExtraArgs, pJsonify);
} catch (ValueFaultHandler.AttributeFilteredException exp) {
jsonResult = null;
} finally {
clearContext();
}
return jsonResult;
} | java | private Object extractObjectWithContext(Object pValue, Stack<String> pExtraArgs, JsonConvertOptions pOpts, boolean pJsonify)
throws AttributeNotFoundException {
Object jsonResult;
setupContext(pOpts);
try {
jsonResult = extractObject(pValue, pExtraArgs, pJsonify);
} catch (ValueFaultHandler.AttributeFilteredException exp) {
jsonResult = null;
} finally {
clearContext();
}
return jsonResult;
} | [
"private",
"Object",
"extractObjectWithContext",
"(",
"Object",
"pValue",
",",
"Stack",
"<",
"String",
">",
"pExtraArgs",
",",
"JsonConvertOptions",
"pOpts",
",",
"boolean",
"pJsonify",
")",
"throws",
"AttributeNotFoundException",
"{",
"Object",
"jsonResult",
";",
"setupContext",
"(",
"pOpts",
")",
";",
"try",
"{",
"jsonResult",
"=",
"extractObject",
"(",
"pValue",
",",
"pExtraArgs",
",",
"pJsonify",
")",
";",
"}",
"catch",
"(",
"ValueFaultHandler",
".",
"AttributeFilteredException",
"exp",
")",
"{",
"jsonResult",
"=",
"null",
";",
"}",
"finally",
"{",
"clearContext",
"(",
")",
";",
"}",
"return",
"jsonResult",
";",
"}"
]
| Handle a value which means to dive into the internal of a complex object
(if <code>pExtraArgs</code> is not null) and/or to convert
it to JSON (if <code>pJsonify</code> is true).
@param pValue value to extract from
@param pExtraArgs stack used for diving in to the value
@param pOpts options from which various processing
parameters (like maxDepth, maxCollectionSize and maxObjects) are taken and put
into context in order to influence the object traversal.
@param pJsonify whether the result should be returned as an JSON object
@return extracted value, either natively or as JSON
@throws AttributeNotFoundException if during traversal an attribute is not found as specified in the stack | [
"Handle",
"a",
"value",
"which",
"means",
"to",
"dive",
"into",
"the",
"internal",
"of",
"a",
"complex",
"object",
"(",
"if",
"<code",
">",
"pExtraArgs<",
"/",
"code",
">",
"is",
"not",
"null",
")",
"and",
"/",
"or",
"to",
"convert",
"it",
"to",
"JSON",
"(",
"if",
"<code",
">",
"pJsonify<",
"/",
"code",
">",
"is",
"true",
")",
"."
]
| train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/converter/json/ObjectToJsonConverter.java#L202-L214 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/util/CmsClientStringUtil.java | CmsClientStringUtil.shortenString | public static String shortenString(String text, int maxLength) {
"""
Shortens the string to the given maximum length.<p>
Will include HTML entity ellipses replacing the cut off text.<p>
@param text the string to shorten
@param maxLength the maximum length
@return the shortened string
"""
if (text.length() <= maxLength) {
return text;
}
String newText = text.substring(0, maxLength - 1);
if (text.startsWith("/")) {
// file name?
newText = CmsStringUtil.formatResourceName(text, maxLength);
} else if (maxLength > 2) {
// enough space for ellipsis?
newText += CmsDomUtil.Entity.hellip.html();
}
if (CmsStringUtil.isEmptyOrWhitespaceOnly(newText)) {
// if empty, it could break the layout
newText = CmsDomUtil.Entity.nbsp.html();
}
return newText;
} | java | public static String shortenString(String text, int maxLength) {
if (text.length() <= maxLength) {
return text;
}
String newText = text.substring(0, maxLength - 1);
if (text.startsWith("/")) {
// file name?
newText = CmsStringUtil.formatResourceName(text, maxLength);
} else if (maxLength > 2) {
// enough space for ellipsis?
newText += CmsDomUtil.Entity.hellip.html();
}
if (CmsStringUtil.isEmptyOrWhitespaceOnly(newText)) {
// if empty, it could break the layout
newText = CmsDomUtil.Entity.nbsp.html();
}
return newText;
} | [
"public",
"static",
"String",
"shortenString",
"(",
"String",
"text",
",",
"int",
"maxLength",
")",
"{",
"if",
"(",
"text",
".",
"length",
"(",
")",
"<=",
"maxLength",
")",
"{",
"return",
"text",
";",
"}",
"String",
"newText",
"=",
"text",
".",
"substring",
"(",
"0",
",",
"maxLength",
"-",
"1",
")",
";",
"if",
"(",
"text",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"// file name?",
"newText",
"=",
"CmsStringUtil",
".",
"formatResourceName",
"(",
"text",
",",
"maxLength",
")",
";",
"}",
"else",
"if",
"(",
"maxLength",
">",
"2",
")",
"{",
"// enough space for ellipsis?",
"newText",
"+=",
"CmsDomUtil",
".",
"Entity",
".",
"hellip",
".",
"html",
"(",
")",
";",
"}",
"if",
"(",
"CmsStringUtil",
".",
"isEmptyOrWhitespaceOnly",
"(",
"newText",
")",
")",
"{",
"// if empty, it could break the layout",
"newText",
"=",
"CmsDomUtil",
".",
"Entity",
".",
"nbsp",
".",
"html",
"(",
")",
";",
"}",
"return",
"newText",
";",
"}"
]
| Shortens the string to the given maximum length.<p>
Will include HTML entity ellipses replacing the cut off text.<p>
@param text the string to shorten
@param maxLength the maximum length
@return the shortened string | [
"Shortens",
"the",
"string",
"to",
"the",
"given",
"maximum",
"length",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/util/CmsClientStringUtil.java#L205-L223 |
smartsheet-platform/smartsheet-java-sdk | src/main/java/com/smartsheet/api/internal/util/StreamUtil.java | StreamUtil.cloneContent | public static InputStream cloneContent(InputStream source, int readbackSize, ByteArrayOutputStream target) throws IOException {
"""
used when you want to clone a InputStream's content and still have it appear "rewound" to the stream beginning
@param source the stream around the contents we want to clone
@param readbackSize the farthest we should read a resetable stream before giving up
@param target an output stream into which we place a copy of the content read from source
@return the source if it was resetable; a new stream rewound around the source data otherwise
@throws IOException if any issues occur with the reading of bytes from the source stream
"""
if (source == null) {
return null;
}
// if the source supports mark/reset then we read and then reset up to the read-back size
if (source.markSupported()) {
readbackSize = Math.max(TEN_KB, readbackSize); // at least 10 KB (minimal waste, handles those -1 ContentLength cases)
source.mark(readbackSize);
copyContentIntoOutputStream(source, target, readbackSize, false);
source.reset();
return source;
} else {
copyContentIntoOutputStream(source, target, ONE_MB, true);
byte[] fullContentBytes = target.toByteArray();
// if we can't reset the source we need to create a replacement stream so others can read the content
return new ByteArrayInputStream(fullContentBytes);
}
} | java | public static InputStream cloneContent(InputStream source, int readbackSize, ByteArrayOutputStream target) throws IOException {
if (source == null) {
return null;
}
// if the source supports mark/reset then we read and then reset up to the read-back size
if (source.markSupported()) {
readbackSize = Math.max(TEN_KB, readbackSize); // at least 10 KB (minimal waste, handles those -1 ContentLength cases)
source.mark(readbackSize);
copyContentIntoOutputStream(source, target, readbackSize, false);
source.reset();
return source;
} else {
copyContentIntoOutputStream(source, target, ONE_MB, true);
byte[] fullContentBytes = target.toByteArray();
// if we can't reset the source we need to create a replacement stream so others can read the content
return new ByteArrayInputStream(fullContentBytes);
}
} | [
"public",
"static",
"InputStream",
"cloneContent",
"(",
"InputStream",
"source",
",",
"int",
"readbackSize",
",",
"ByteArrayOutputStream",
"target",
")",
"throws",
"IOException",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// if the source supports mark/reset then we read and then reset up to the read-back size",
"if",
"(",
"source",
".",
"markSupported",
"(",
")",
")",
"{",
"readbackSize",
"=",
"Math",
".",
"max",
"(",
"TEN_KB",
",",
"readbackSize",
")",
";",
"// at least 10 KB (minimal waste, handles those -1 ContentLength cases)",
"source",
".",
"mark",
"(",
"readbackSize",
")",
";",
"copyContentIntoOutputStream",
"(",
"source",
",",
"target",
",",
"readbackSize",
",",
"false",
")",
";",
"source",
".",
"reset",
"(",
")",
";",
"return",
"source",
";",
"}",
"else",
"{",
"copyContentIntoOutputStream",
"(",
"source",
",",
"target",
",",
"ONE_MB",
",",
"true",
")",
";",
"byte",
"[",
"]",
"fullContentBytes",
"=",
"target",
".",
"toByteArray",
"(",
")",
";",
"// if we can't reset the source we need to create a replacement stream so others can read the content",
"return",
"new",
"ByteArrayInputStream",
"(",
"fullContentBytes",
")",
";",
"}",
"}"
]
| used when you want to clone a InputStream's content and still have it appear "rewound" to the stream beginning
@param source the stream around the contents we want to clone
@param readbackSize the farthest we should read a resetable stream before giving up
@param target an output stream into which we place a copy of the content read from source
@return the source if it was resetable; a new stream rewound around the source data otherwise
@throws IOException if any issues occur with the reading of bytes from the source stream | [
"used",
"when",
"you",
"want",
"to",
"clone",
"a",
"InputStream",
"s",
"content",
"and",
"still",
"have",
"it",
"appear",
"rewound",
"to",
"the",
"stream",
"beginning"
]
| train | https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/f60e264412076271f83b65889ef9b891fad83df8/src/main/java/com/smartsheet/api/internal/util/StreamUtil.java#L99-L116 |
akquinet/androlog | androlog/src/main/java/de/akquinet/android/androlog/Log.java | Log.detectWTFMethods | private static void detectWTFMethods() {
"""
Check if the android Log class contains the <code>wtf</code> method
(Android 2.2+). In that case, the delegation to those method is enabled.
If not, calling {@link Log#wtf(Object, String)} log a message with the
level {@link Log#Constants.ASSERT}
"""
// Check if wtf exists (android 2.2+)
// static int wtf(String tag, String msg)
// static int wtf(String tag, Throwable tr)
// static int wtf(String tag, String msg, Throwable tr)
try {
wtfTagMessageMethod = android.util.Log.class.getMethod("wtf",
new Class[] { String.class, String.class });
wtfTagErrorMethod = android.util.Log.class.getMethod("wtf",
new Class[] { String.class, Throwable.class });
wtfTagMessageErrorMethod = android.util.Log.class
.getMethod("wtf", new Class[] { String.class, String.class,
Throwable.class });
useWTF = true;
} catch (Exception e) {
// wtf is not defined, will use Constants.ASSERT level.
useWTF = false;
}
} | java | private static void detectWTFMethods() {
// Check if wtf exists (android 2.2+)
// static int wtf(String tag, String msg)
// static int wtf(String tag, Throwable tr)
// static int wtf(String tag, String msg, Throwable tr)
try {
wtfTagMessageMethod = android.util.Log.class.getMethod("wtf",
new Class[] { String.class, String.class });
wtfTagErrorMethod = android.util.Log.class.getMethod("wtf",
new Class[] { String.class, Throwable.class });
wtfTagMessageErrorMethod = android.util.Log.class
.getMethod("wtf", new Class[] { String.class, String.class,
Throwable.class });
useWTF = true;
} catch (Exception e) {
// wtf is not defined, will use Constants.ASSERT level.
useWTF = false;
}
} | [
"private",
"static",
"void",
"detectWTFMethods",
"(",
")",
"{",
"// Check if wtf exists (android 2.2+)",
"// static int wtf(String tag, String msg)",
"// static int wtf(String tag, Throwable tr)",
"// static int wtf(String tag, String msg, Throwable tr)",
"try",
"{",
"wtfTagMessageMethod",
"=",
"android",
".",
"util",
".",
"Log",
".",
"class",
".",
"getMethod",
"(",
"\"wtf\"",
",",
"new",
"Class",
"[",
"]",
"{",
"String",
".",
"class",
",",
"String",
".",
"class",
"}",
")",
";",
"wtfTagErrorMethod",
"=",
"android",
".",
"util",
".",
"Log",
".",
"class",
".",
"getMethod",
"(",
"\"wtf\"",
",",
"new",
"Class",
"[",
"]",
"{",
"String",
".",
"class",
",",
"Throwable",
".",
"class",
"}",
")",
";",
"wtfTagMessageErrorMethod",
"=",
"android",
".",
"util",
".",
"Log",
".",
"class",
".",
"getMethod",
"(",
"\"wtf\"",
",",
"new",
"Class",
"[",
"]",
"{",
"String",
".",
"class",
",",
"String",
".",
"class",
",",
"Throwable",
".",
"class",
"}",
")",
";",
"useWTF",
"=",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// wtf is not defined, will use Constants.ASSERT level.",
"useWTF",
"=",
"false",
";",
"}",
"}"
]
| Check if the android Log class contains the <code>wtf</code> method
(Android 2.2+). In that case, the delegation to those method is enabled.
If not, calling {@link Log#wtf(Object, String)} log a message with the
level {@link Log#Constants.ASSERT} | [
"Check",
"if",
"the",
"android",
"Log",
"class",
"contains",
"the",
"<code",
">",
"wtf<",
"/",
"code",
">",
"method",
"(",
"Android",
"2",
".",
"2",
"+",
")",
".",
"In",
"that",
"case",
"the",
"delegation",
"to",
"those",
"method",
"is",
"enabled",
".",
"If",
"not",
"calling",
"{"
]
| train | https://github.com/akquinet/androlog/blob/82fa81354c01c9b1d1928062b634ba21f14be560/androlog/src/main/java/de/akquinet/android/androlog/Log.java#L503-L521 |
agmip/translator-dssat | src/main/java/org/agmip/translators/dssat/DssatCommonOutput.java | DssatCommonOutput.formatStr | protected String formatStr(int bits, String val, Object key) {
"""
Format the output string with maximum length
@param bits Maximum length of the output string
@param val the value of data
@param key the key of field in the map
@return formated string of number
"""
if (val.equals("")) {
return val;
} else if (val.length() > bits) {
//throw new Exception();
sbError.append("! Waring: There is a variable [").append(key).append("] with oversized content [").append(val).append("], only first ").append(bits).append(" bits will be applied.\r\n");
return val.substring(0, bits);
}
return val;
} | java | protected String formatStr(int bits, String val, Object key) {
if (val.equals("")) {
return val;
} else if (val.length() > bits) {
//throw new Exception();
sbError.append("! Waring: There is a variable [").append(key).append("] with oversized content [").append(val).append("], only first ").append(bits).append(" bits will be applied.\r\n");
return val.substring(0, bits);
}
return val;
} | [
"protected",
"String",
"formatStr",
"(",
"int",
"bits",
",",
"String",
"val",
",",
"Object",
"key",
")",
"{",
"if",
"(",
"val",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"val",
";",
"}",
"else",
"if",
"(",
"val",
".",
"length",
"(",
")",
">",
"bits",
")",
"{",
"//throw new Exception();",
"sbError",
".",
"append",
"(",
"\"! Waring: There is a variable [\"",
")",
".",
"append",
"(",
"key",
")",
".",
"append",
"(",
"\"] with oversized content [\"",
")",
".",
"append",
"(",
"val",
")",
".",
"append",
"(",
"\"], only first \"",
")",
".",
"append",
"(",
"bits",
")",
".",
"append",
"(",
"\" bits will be applied.\\r\\n\"",
")",
";",
"return",
"val",
".",
"substring",
"(",
"0",
",",
"bits",
")",
";",
"}",
"return",
"val",
";",
"}"
]
| Format the output string with maximum length
@param bits Maximum length of the output string
@param val the value of data
@param key the key of field in the map
@return formated string of number | [
"Format",
"the",
"output",
"string",
"with",
"maximum",
"length"
]
| train | https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatCommonOutput.java#L120-L130 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java | JavacParser.interfaceDeclaration | protected JCClassDecl interfaceDeclaration(JCModifiers mods, Comment dc) {
"""
InterfaceDeclaration = INTERFACE Ident TypeParametersOpt
[EXTENDS TypeList] InterfaceBody
@param mods The modifiers starting the interface declaration
@param dc The documentation comment for the interface, or null.
"""
int pos = token.pos;
accept(INTERFACE);
Name name = ident();
List<JCTypeParameter> typarams = typeParametersOpt();
List<JCExpression> extending = List.nil();
if (token.kind == EXTENDS) {
nextToken();
extending = typeList();
}
List<JCTree> defs = classOrInterfaceBody(name, true);
JCClassDecl result = toP(F.at(pos).ClassDef(
mods, name, typarams, null, extending, defs));
attach(result, dc);
return result;
} | java | protected JCClassDecl interfaceDeclaration(JCModifiers mods, Comment dc) {
int pos = token.pos;
accept(INTERFACE);
Name name = ident();
List<JCTypeParameter> typarams = typeParametersOpt();
List<JCExpression> extending = List.nil();
if (token.kind == EXTENDS) {
nextToken();
extending = typeList();
}
List<JCTree> defs = classOrInterfaceBody(name, true);
JCClassDecl result = toP(F.at(pos).ClassDef(
mods, name, typarams, null, extending, defs));
attach(result, dc);
return result;
} | [
"protected",
"JCClassDecl",
"interfaceDeclaration",
"(",
"JCModifiers",
"mods",
",",
"Comment",
"dc",
")",
"{",
"int",
"pos",
"=",
"token",
".",
"pos",
";",
"accept",
"(",
"INTERFACE",
")",
";",
"Name",
"name",
"=",
"ident",
"(",
")",
";",
"List",
"<",
"JCTypeParameter",
">",
"typarams",
"=",
"typeParametersOpt",
"(",
")",
";",
"List",
"<",
"JCExpression",
">",
"extending",
"=",
"List",
".",
"nil",
"(",
")",
";",
"if",
"(",
"token",
".",
"kind",
"==",
"EXTENDS",
")",
"{",
"nextToken",
"(",
")",
";",
"extending",
"=",
"typeList",
"(",
")",
";",
"}",
"List",
"<",
"JCTree",
">",
"defs",
"=",
"classOrInterfaceBody",
"(",
"name",
",",
"true",
")",
";",
"JCClassDecl",
"result",
"=",
"toP",
"(",
"F",
".",
"at",
"(",
"pos",
")",
".",
"ClassDef",
"(",
"mods",
",",
"name",
",",
"typarams",
",",
"null",
",",
"extending",
",",
"defs",
")",
")",
";",
"attach",
"(",
"result",
",",
"dc",
")",
";",
"return",
"result",
";",
"}"
]
| InterfaceDeclaration = INTERFACE Ident TypeParametersOpt
[EXTENDS TypeList] InterfaceBody
@param mods The modifiers starting the interface declaration
@param dc The documentation comment for the interface, or null. | [
"InterfaceDeclaration",
"=",
"INTERFACE",
"Ident",
"TypeParametersOpt",
"[",
"EXTENDS",
"TypeList",
"]",
"InterfaceBody"
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java#L3410-L3427 |
BranchMetrics/android-branch-deep-linking | Branch-SDK/src/io/branch/referral/ApkParser.java | ApkParser.compXmlString | private String compXmlString(byte[] xml, int sitOff, int stOff, int strInd) {
"""
<p>Get a {@link String} of the value stored in StringTable format at offset strOff, as
calculated from an initial starting point and a number of words to traverse.
</p>
@param xml The {@link Byte} array to be processed.
@param sitOff An {@link Integer} value indicating the initial offset within the supplied
{@link Byte} array.
@param stOff An {@link Integer} value indicating the initial offset of the supplied array.
@param strInd An {@link Integer} value indicating the string index to use in the LEW calculation.
@return A call to {@link #compXmlStringAt(byte[], int)}, with the result of the offset calculation
of this method as the {@link Integer} parameter.
"""
if (strInd < 0) return null;
int strOff = stOff + LEW(xml, sitOff + strInd * 4);
return compXmlStringAt(xml, strOff);
} | java | private String compXmlString(byte[] xml, int sitOff, int stOff, int strInd) {
if (strInd < 0) return null;
int strOff = stOff + LEW(xml, sitOff + strInd * 4);
return compXmlStringAt(xml, strOff);
} | [
"private",
"String",
"compXmlString",
"(",
"byte",
"[",
"]",
"xml",
",",
"int",
"sitOff",
",",
"int",
"stOff",
",",
"int",
"strInd",
")",
"{",
"if",
"(",
"strInd",
"<",
"0",
")",
"return",
"null",
";",
"int",
"strOff",
"=",
"stOff",
"+",
"LEW",
"(",
"xml",
",",
"sitOff",
"+",
"strInd",
"*",
"4",
")",
";",
"return",
"compXmlStringAt",
"(",
"xml",
",",
"strOff",
")",
";",
"}"
]
| <p>Get a {@link String} of the value stored in StringTable format at offset strOff, as
calculated from an initial starting point and a number of words to traverse.
</p>
@param xml The {@link Byte} array to be processed.
@param sitOff An {@link Integer} value indicating the initial offset within the supplied
{@link Byte} array.
@param stOff An {@link Integer} value indicating the initial offset of the supplied array.
@param strInd An {@link Integer} value indicating the string index to use in the LEW calculation.
@return A call to {@link #compXmlStringAt(byte[], int)}, with the result of the offset calculation
of this method as the {@link Integer} parameter. | [
"<p",
">",
"Get",
"a",
"{",
"@link",
"String",
"}",
"of",
"the",
"value",
"stored",
"in",
"StringTable",
"format",
"at",
"offset",
"strOff",
"as",
"calculated",
"from",
"an",
"initial",
"starting",
"point",
"and",
"a",
"number",
"of",
"words",
"to",
"traverse",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/BranchMetrics/android-branch-deep-linking/blob/e3bee2ccfcbf6d4bf1a5815b5b86666e4ff8f848/Branch-SDK/src/io/branch/referral/ApkParser.java#L246-L250 |
apache/incubator-gobblin | gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceExtractor.java | SalesforceExtractor.waitForPkBatches | private BatchInfo waitForPkBatches(BatchInfoList batchInfoList, int retryInterval)
throws InterruptedException, AsyncApiException {
"""
Waits for the PK batches to complete. The wait will stop after all batches are complete or on the first failed batch
@param batchInfoList list of batch info
@param retryInterval the polling interval
@return the last {@link BatchInfo} processed
@throws InterruptedException
@throws AsyncApiException
"""
BatchInfo batchInfo = null;
BatchInfo[] batchInfos = batchInfoList.getBatchInfo();
// Wait for all batches other than the first one. The first one is not processed in PK chunking mode
for (int i = 1; i < batchInfos.length; i++) {
BatchInfo bi = batchInfos[i];
// get refreshed job status
bi = this.bulkConnection.getBatchInfo(this.bulkJob.getId(), bi.getId());
while ((bi.getState() != BatchStateEnum.Completed)
&& (bi.getState() != BatchStateEnum.Failed)) {
Thread.sleep(retryInterval * 1000);
bi = this.bulkConnection.getBatchInfo(this.bulkJob.getId(), bi.getId());
log.debug("Bulk Api Batch Info:" + bi);
log.info("Waiting for bulk resultSetIds");
}
batchInfo = bi;
// exit if there was a failure
if (batchInfo.getState() == BatchStateEnum.Failed) {
break;
}
}
return batchInfo;
} | java | private BatchInfo waitForPkBatches(BatchInfoList batchInfoList, int retryInterval)
throws InterruptedException, AsyncApiException {
BatchInfo batchInfo = null;
BatchInfo[] batchInfos = batchInfoList.getBatchInfo();
// Wait for all batches other than the first one. The first one is not processed in PK chunking mode
for (int i = 1; i < batchInfos.length; i++) {
BatchInfo bi = batchInfos[i];
// get refreshed job status
bi = this.bulkConnection.getBatchInfo(this.bulkJob.getId(), bi.getId());
while ((bi.getState() != BatchStateEnum.Completed)
&& (bi.getState() != BatchStateEnum.Failed)) {
Thread.sleep(retryInterval * 1000);
bi = this.bulkConnection.getBatchInfo(this.bulkJob.getId(), bi.getId());
log.debug("Bulk Api Batch Info:" + bi);
log.info("Waiting for bulk resultSetIds");
}
batchInfo = bi;
// exit if there was a failure
if (batchInfo.getState() == BatchStateEnum.Failed) {
break;
}
}
return batchInfo;
} | [
"private",
"BatchInfo",
"waitForPkBatches",
"(",
"BatchInfoList",
"batchInfoList",
",",
"int",
"retryInterval",
")",
"throws",
"InterruptedException",
",",
"AsyncApiException",
"{",
"BatchInfo",
"batchInfo",
"=",
"null",
";",
"BatchInfo",
"[",
"]",
"batchInfos",
"=",
"batchInfoList",
".",
"getBatchInfo",
"(",
")",
";",
"// Wait for all batches other than the first one. The first one is not processed in PK chunking mode",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"batchInfos",
".",
"length",
";",
"i",
"++",
")",
"{",
"BatchInfo",
"bi",
"=",
"batchInfos",
"[",
"i",
"]",
";",
"// get refreshed job status",
"bi",
"=",
"this",
".",
"bulkConnection",
".",
"getBatchInfo",
"(",
"this",
".",
"bulkJob",
".",
"getId",
"(",
")",
",",
"bi",
".",
"getId",
"(",
")",
")",
";",
"while",
"(",
"(",
"bi",
".",
"getState",
"(",
")",
"!=",
"BatchStateEnum",
".",
"Completed",
")",
"&&",
"(",
"bi",
".",
"getState",
"(",
")",
"!=",
"BatchStateEnum",
".",
"Failed",
")",
")",
"{",
"Thread",
".",
"sleep",
"(",
"retryInterval",
"*",
"1000",
")",
";",
"bi",
"=",
"this",
".",
"bulkConnection",
".",
"getBatchInfo",
"(",
"this",
".",
"bulkJob",
".",
"getId",
"(",
")",
",",
"bi",
".",
"getId",
"(",
")",
")",
";",
"log",
".",
"debug",
"(",
"\"Bulk Api Batch Info:\"",
"+",
"bi",
")",
";",
"log",
".",
"info",
"(",
"\"Waiting for bulk resultSetIds\"",
")",
";",
"}",
"batchInfo",
"=",
"bi",
";",
"// exit if there was a failure",
"if",
"(",
"batchInfo",
".",
"getState",
"(",
")",
"==",
"BatchStateEnum",
".",
"Failed",
")",
"{",
"break",
";",
"}",
"}",
"return",
"batchInfo",
";",
"}"
]
| Waits for the PK batches to complete. The wait will stop after all batches are complete or on the first failed batch
@param batchInfoList list of batch info
@param retryInterval the polling interval
@return the last {@link BatchInfo} processed
@throws InterruptedException
@throws AsyncApiException | [
"Waits",
"for",
"the",
"PK",
"batches",
"to",
"complete",
".",
"The",
"wait",
"will",
"stop",
"after",
"all",
"batches",
"are",
"complete",
"or",
"on",
"the",
"first",
"failed",
"batch"
]
| train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceExtractor.java#L1008-L1037 |
apache/groovy | src/main/groovy/groovy/transform/stc/ClosureSignatureHint.java | ClosureSignatureHint.pickGenericType | public static ClassNode pickGenericType(ClassNode type, int gtIndex) {
"""
A helper method which will extract the n-th generic type from a class node.
@param type the class node from which to pick a generic type
@param gtIndex the index of the generic type to extract
@return the n-th generic type, or {@link org.codehaus.groovy.ast.ClassHelper#OBJECT_TYPE} if it doesn't exist.
"""
final GenericsType[] genericsTypes = type.getGenericsTypes();
if (genericsTypes==null || genericsTypes.length<gtIndex) {
return ClassHelper.OBJECT_TYPE;
}
return genericsTypes[gtIndex].getType();
} | java | public static ClassNode pickGenericType(ClassNode type, int gtIndex) {
final GenericsType[] genericsTypes = type.getGenericsTypes();
if (genericsTypes==null || genericsTypes.length<gtIndex) {
return ClassHelper.OBJECT_TYPE;
}
return genericsTypes[gtIndex].getType();
} | [
"public",
"static",
"ClassNode",
"pickGenericType",
"(",
"ClassNode",
"type",
",",
"int",
"gtIndex",
")",
"{",
"final",
"GenericsType",
"[",
"]",
"genericsTypes",
"=",
"type",
".",
"getGenericsTypes",
"(",
")",
";",
"if",
"(",
"genericsTypes",
"==",
"null",
"||",
"genericsTypes",
".",
"length",
"<",
"gtIndex",
")",
"{",
"return",
"ClassHelper",
".",
"OBJECT_TYPE",
";",
"}",
"return",
"genericsTypes",
"[",
"gtIndex",
"]",
".",
"getType",
"(",
")",
";",
"}"
]
| A helper method which will extract the n-th generic type from a class node.
@param type the class node from which to pick a generic type
@param gtIndex the index of the generic type to extract
@return the n-th generic type, or {@link org.codehaus.groovy.ast.ClassHelper#OBJECT_TYPE} if it doesn't exist. | [
"A",
"helper",
"method",
"which",
"will",
"extract",
"the",
"n",
"-",
"th",
"generic",
"type",
"from",
"a",
"class",
"node",
"."
]
| train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/transform/stc/ClosureSignatureHint.java#L61-L67 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/compaction/CompactionManager.java | CompactionManager.interruptCompactionFor | public void interruptCompactionFor(Iterable<CFMetaData> columnFamilies, boolean interruptValidation) {
"""
Try to stop all of the compactions for given ColumnFamilies.
Note that this method does not wait for all compactions to finish; you'll need to loop against
isCompacting if you want that behavior.
@param columnFamilies The ColumnFamilies to try to stop compaction upon.
@param interruptValidation true if validation operations for repair should also be interrupted
"""
assert columnFamilies != null;
// interrupt in-progress compactions
for (Holder compactionHolder : CompactionMetrics.getCompactions())
{
CompactionInfo info = compactionHolder.getCompactionInfo();
if ((info.getTaskType() == OperationType.VALIDATION) && !interruptValidation)
continue;
if (Iterables.contains(columnFamilies, info.getCFMetaData()))
compactionHolder.stop(); // signal compaction to stop
}
} | java | public void interruptCompactionFor(Iterable<CFMetaData> columnFamilies, boolean interruptValidation)
{
assert columnFamilies != null;
// interrupt in-progress compactions
for (Holder compactionHolder : CompactionMetrics.getCompactions())
{
CompactionInfo info = compactionHolder.getCompactionInfo();
if ((info.getTaskType() == OperationType.VALIDATION) && !interruptValidation)
continue;
if (Iterables.contains(columnFamilies, info.getCFMetaData()))
compactionHolder.stop(); // signal compaction to stop
}
} | [
"public",
"void",
"interruptCompactionFor",
"(",
"Iterable",
"<",
"CFMetaData",
">",
"columnFamilies",
",",
"boolean",
"interruptValidation",
")",
"{",
"assert",
"columnFamilies",
"!=",
"null",
";",
"// interrupt in-progress compactions",
"for",
"(",
"Holder",
"compactionHolder",
":",
"CompactionMetrics",
".",
"getCompactions",
"(",
")",
")",
"{",
"CompactionInfo",
"info",
"=",
"compactionHolder",
".",
"getCompactionInfo",
"(",
")",
";",
"if",
"(",
"(",
"info",
".",
"getTaskType",
"(",
")",
"==",
"OperationType",
".",
"VALIDATION",
")",
"&&",
"!",
"interruptValidation",
")",
"continue",
";",
"if",
"(",
"Iterables",
".",
"contains",
"(",
"columnFamilies",
",",
"info",
".",
"getCFMetaData",
"(",
")",
")",
")",
"compactionHolder",
".",
"stop",
"(",
")",
";",
"// signal compaction to stop",
"}",
"}"
]
| Try to stop all of the compactions for given ColumnFamilies.
Note that this method does not wait for all compactions to finish; you'll need to loop against
isCompacting if you want that behavior.
@param columnFamilies The ColumnFamilies to try to stop compaction upon.
@param interruptValidation true if validation operations for repair should also be interrupted | [
"Try",
"to",
"stop",
"all",
"of",
"the",
"compactions",
"for",
"given",
"ColumnFamilies",
"."
]
| train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/compaction/CompactionManager.java#L1454-L1468 |
xvik/guice-persist-orient | src/main/java/ru/vyarus/guice/persist/orient/db/transaction/internal/AnnotationTxConfigBuilder.java | AnnotationTxConfigBuilder.buildConfig | public static TxConfig buildConfig(final Class<?> type, final Method method, final boolean useDefaults) {
"""
Build transaction config for type.
@param type type to analyze
@param method method to analyze
@param useDefaults true to build default config if annotation not found
@return tx config for found annotation, null if useDefaults false and default config otherwise
"""
final Transactional transactional = findAnnotation(type, method, Transactional.class, useDefaults);
TxConfig res = null;
if (transactional != null) {
final TxType txType = findAnnotation(type, method, TxType.class, true);
res = new TxConfig(wrapExceptions(transactional.rollbackOn()),
wrapExceptions(transactional.ignore()), txType.value());
}
return res;
} | java | public static TxConfig buildConfig(final Class<?> type, final Method method, final boolean useDefaults) {
final Transactional transactional = findAnnotation(type, method, Transactional.class, useDefaults);
TxConfig res = null;
if (transactional != null) {
final TxType txType = findAnnotation(type, method, TxType.class, true);
res = new TxConfig(wrapExceptions(transactional.rollbackOn()),
wrapExceptions(transactional.ignore()), txType.value());
}
return res;
} | [
"public",
"static",
"TxConfig",
"buildConfig",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
",",
"final",
"Method",
"method",
",",
"final",
"boolean",
"useDefaults",
")",
"{",
"final",
"Transactional",
"transactional",
"=",
"findAnnotation",
"(",
"type",
",",
"method",
",",
"Transactional",
".",
"class",
",",
"useDefaults",
")",
";",
"TxConfig",
"res",
"=",
"null",
";",
"if",
"(",
"transactional",
"!=",
"null",
")",
"{",
"final",
"TxType",
"txType",
"=",
"findAnnotation",
"(",
"type",
",",
"method",
",",
"TxType",
".",
"class",
",",
"true",
")",
";",
"res",
"=",
"new",
"TxConfig",
"(",
"wrapExceptions",
"(",
"transactional",
".",
"rollbackOn",
"(",
")",
")",
",",
"wrapExceptions",
"(",
"transactional",
".",
"ignore",
"(",
")",
")",
",",
"txType",
".",
"value",
"(",
")",
")",
";",
"}",
"return",
"res",
";",
"}"
]
| Build transaction config for type.
@param type type to analyze
@param method method to analyze
@param useDefaults true to build default config if annotation not found
@return tx config for found annotation, null if useDefaults false and default config otherwise | [
"Build",
"transaction",
"config",
"for",
"type",
"."
]
| train | https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/db/transaction/internal/AnnotationTxConfigBuilder.java#L33-L42 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/io/IOUtils.java | IOUtils.writeObjectToFile | public static File writeObjectToFile(Object o, File file, boolean append) throws IOException {
"""
Write an object to a specified File.
@param o
object to be written to file
@param file
The temp File
@param append If true, append to this file instead of overwriting it
@throws IOException
If File cannot be written
@return File containing the object
"""
// file.createNewFile(); // cdm may 2005: does nothing needed
ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(
new GZIPOutputStream(new FileOutputStream(file, append))));
oos.writeObject(o);
oos.close();
return file;
} | java | public static File writeObjectToFile(Object o, File file, boolean append) throws IOException {
// file.createNewFile(); // cdm may 2005: does nothing needed
ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(
new GZIPOutputStream(new FileOutputStream(file, append))));
oos.writeObject(o);
oos.close();
return file;
} | [
"public",
"static",
"File",
"writeObjectToFile",
"(",
"Object",
"o",
",",
"File",
"file",
",",
"boolean",
"append",
")",
"throws",
"IOException",
"{",
"// file.createNewFile(); // cdm may 2005: does nothing needed\r",
"ObjectOutputStream",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"new",
"BufferedOutputStream",
"(",
"new",
"GZIPOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"file",
",",
"append",
")",
")",
")",
")",
";",
"oos",
".",
"writeObject",
"(",
"o",
")",
";",
"oos",
".",
"close",
"(",
")",
";",
"return",
"file",
";",
"}"
]
| Write an object to a specified File.
@param o
object to be written to file
@param file
The temp File
@param append If true, append to this file instead of overwriting it
@throws IOException
If File cannot be written
@return File containing the object | [
"Write",
"an",
"object",
"to",
"a",
"specified",
"File",
"."
]
| train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/io/IOUtils.java#L76-L83 |
radkovo/jStyleParser | src/main/java/cz/vutbr/web/domassign/Variator.java | Variator.tryOneTermVariant | public boolean tryOneTermVariant(int variant, Declaration d,
Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
"""
Uses variator functionality to test selected variant on term
@param variant
Which variant will be tested
@param d
The declaration on which variant will be tested
@param properties
Properties map where to store property type
@param values
Values map where to store property value
@return <code>true</code> in case of success, <code>false</code>
otherwise
"""
// only one term is allowed
if (d.size() != 1)
return false;
// try inherit variant
if (checkInherit(variant, d.get(0), properties))
return true;
this.terms = new ArrayList<Term<?>>();
this.terms.add(d.get(0));
return variant(variant, new IntegerRef(0), properties, values);
} | java | public boolean tryOneTermVariant(int variant, Declaration d,
Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
// only one term is allowed
if (d.size() != 1)
return false;
// try inherit variant
if (checkInherit(variant, d.get(0), properties))
return true;
this.terms = new ArrayList<Term<?>>();
this.terms.add(d.get(0));
return variant(variant, new IntegerRef(0), properties, values);
} | [
"public",
"boolean",
"tryOneTermVariant",
"(",
"int",
"variant",
",",
"Declaration",
"d",
",",
"Map",
"<",
"String",
",",
"CSSProperty",
">",
"properties",
",",
"Map",
"<",
"String",
",",
"Term",
"<",
"?",
">",
">",
"values",
")",
"{",
"// only one term is allowed",
"if",
"(",
"d",
".",
"size",
"(",
")",
"!=",
"1",
")",
"return",
"false",
";",
"// try inherit variant",
"if",
"(",
"checkInherit",
"(",
"variant",
",",
"d",
".",
"get",
"(",
"0",
")",
",",
"properties",
")",
")",
"return",
"true",
";",
"this",
".",
"terms",
"=",
"new",
"ArrayList",
"<",
"Term",
"<",
"?",
">",
">",
"(",
")",
";",
"this",
".",
"terms",
".",
"add",
"(",
"d",
".",
"get",
"(",
"0",
")",
")",
";",
"return",
"variant",
"(",
"variant",
",",
"new",
"IntegerRef",
"(",
"0",
")",
",",
"properties",
",",
"values",
")",
";",
"}"
]
| Uses variator functionality to test selected variant on term
@param variant
Which variant will be tested
@param d
The declaration on which variant will be tested
@param properties
Properties map where to store property type
@param values
Values map where to store property value
@return <code>true</code> in case of success, <code>false</code>
otherwise | [
"Uses",
"variator",
"functionality",
"to",
"test",
"selected",
"variant",
"on",
"term"
]
| train | https://github.com/radkovo/jStyleParser/blob/8ab049ac6866aa52c4d7deee25c9e294e7191957/src/main/java/cz/vutbr/web/domassign/Variator.java#L264-L279 |
goldmansachs/gs-collections | collections/src/main/java/com/gs/collections/impl/utility/StringIterate.java | StringIterate.forEach | @Deprecated
public static void forEach(String string, CodePointProcedure procedure) {
"""
For each int code point in the {@code string}, execute the {@link CodePointProcedure}.
@deprecated since 7.0. Use {@link #forEachCodePoint(String, CodePointProcedure)} instead.
"""
StringIterate.forEachCodePoint(string, procedure);
} | java | @Deprecated
public static void forEach(String string, CodePointProcedure procedure)
{
StringIterate.forEachCodePoint(string, procedure);
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"forEach",
"(",
"String",
"string",
",",
"CodePointProcedure",
"procedure",
")",
"{",
"StringIterate",
".",
"forEachCodePoint",
"(",
"string",
",",
"procedure",
")",
";",
"}"
]
| For each int code point in the {@code string}, execute the {@link CodePointProcedure}.
@deprecated since 7.0. Use {@link #forEachCodePoint(String, CodePointProcedure)} instead. | [
"For",
"each",
"int",
"code",
"point",
"in",
"the",
"{",
"@code",
"string",
"}",
"execute",
"the",
"{",
"@link",
"CodePointProcedure",
"}",
"."
]
| train | https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/StringIterate.java#L374-L378 |
greese/dasein-util | src/main/java/org/dasein/attributes/types/CurrencyFactory.java | CurrencyFactory.getType | public DataType<Currency> getType(String grp, Number idx, boolean ml, boolean mv, boolean req, String... params) {
"""
Provides a currency data type instance that supports the specified type rules.
This data type allows for zero or one type parameters. If no type parameter is specified,
then the data type will allow any currency value. If one is specified, it is expected
to be a single, comma-delimited string in which each element is the code for an
allowed currency. The code should return a valid currency when passed to
{@link java.util.Currency#getInstance(java.lang.String)}.
@param grp the group of the data type.
@param idx the index of the data type.
@param ml is the type multi-lingual?
@param mv can this type support multiple values?
@param req is a value required for this type?
@param params the type parameters
"""
if( params == null || params.length < 1 ) {
return new CurrencyAttribute(grp, idx, ml, mv, req);
}
else if( params.length == 1 && (params[0] == null || params[0].length() < 1 || params[0].equals("null")) ) {
return new CurrencyAttribute(grp, idx, ml, mv, req);
}
else {
return new CurrencyAttribute(grp, idx, ml, mv, req, params[0]);
}
} | java | public DataType<Currency> getType(String grp, Number idx, boolean ml, boolean mv, boolean req, String... params) {
if( params == null || params.length < 1 ) {
return new CurrencyAttribute(grp, idx, ml, mv, req);
}
else if( params.length == 1 && (params[0] == null || params[0].length() < 1 || params[0].equals("null")) ) {
return new CurrencyAttribute(grp, idx, ml, mv, req);
}
else {
return new CurrencyAttribute(grp, idx, ml, mv, req, params[0]);
}
} | [
"public",
"DataType",
"<",
"Currency",
">",
"getType",
"(",
"String",
"grp",
",",
"Number",
"idx",
",",
"boolean",
"ml",
",",
"boolean",
"mv",
",",
"boolean",
"req",
",",
"String",
"...",
"params",
")",
"{",
"if",
"(",
"params",
"==",
"null",
"||",
"params",
".",
"length",
"<",
"1",
")",
"{",
"return",
"new",
"CurrencyAttribute",
"(",
"grp",
",",
"idx",
",",
"ml",
",",
"mv",
",",
"req",
")",
";",
"}",
"else",
"if",
"(",
"params",
".",
"length",
"==",
"1",
"&&",
"(",
"params",
"[",
"0",
"]",
"==",
"null",
"||",
"params",
"[",
"0",
"]",
".",
"length",
"(",
")",
"<",
"1",
"||",
"params",
"[",
"0",
"]",
".",
"equals",
"(",
"\"null\"",
")",
")",
")",
"{",
"return",
"new",
"CurrencyAttribute",
"(",
"grp",
",",
"idx",
",",
"ml",
",",
"mv",
",",
"req",
")",
";",
"}",
"else",
"{",
"return",
"new",
"CurrencyAttribute",
"(",
"grp",
",",
"idx",
",",
"ml",
",",
"mv",
",",
"req",
",",
"params",
"[",
"0",
"]",
")",
";",
"}",
"}"
]
| Provides a currency data type instance that supports the specified type rules.
This data type allows for zero or one type parameters. If no type parameter is specified,
then the data type will allow any currency value. If one is specified, it is expected
to be a single, comma-delimited string in which each element is the code for an
allowed currency. The code should return a valid currency when passed to
{@link java.util.Currency#getInstance(java.lang.String)}.
@param grp the group of the data type.
@param idx the index of the data type.
@param ml is the type multi-lingual?
@param mv can this type support multiple values?
@param req is a value required for this type?
@param params the type parameters | [
"Provides",
"a",
"currency",
"data",
"type",
"instance",
"that",
"supports",
"the",
"specified",
"type",
"rules",
".",
"This",
"data",
"type",
"allows",
"for",
"zero",
"or",
"one",
"type",
"parameters",
".",
"If",
"no",
"type",
"parameter",
"is",
"specified",
"then",
"the",
"data",
"type",
"will",
"allow",
"any",
"currency",
"value",
".",
"If",
"one",
"is",
"specified",
"it",
"is",
"expected",
"to",
"be",
"a",
"single",
"comma",
"-",
"delimited",
"string",
"in",
"which",
"each",
"element",
"is",
"the",
"code",
"for",
"an",
"allowed",
"currency",
".",
"The",
"code",
"should",
"return",
"a",
"valid",
"currency",
"when",
"passed",
"to",
"{"
]
| train | https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/attributes/types/CurrencyFactory.java#L104-L114 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/CollectionUtils.java | CollectionUtils.sampleWithReplacement | public static <E> Collection<E> sampleWithReplacement(Collection<E> c, int n) {
"""
Samples with replacement from a collection
@param c
The collection to be sampled from
@param n
The number of samples to take
@return a new collection with the sample
"""
return sampleWithReplacement(c, n, new Random());
} | java | public static <E> Collection<E> sampleWithReplacement(Collection<E> c, int n) {
return sampleWithReplacement(c, n, new Random());
} | [
"public",
"static",
"<",
"E",
">",
"Collection",
"<",
"E",
">",
"sampleWithReplacement",
"(",
"Collection",
"<",
"E",
">",
"c",
",",
"int",
"n",
")",
"{",
"return",
"sampleWithReplacement",
"(",
"c",
",",
"n",
",",
"new",
"Random",
"(",
")",
")",
";",
"}"
]
| Samples with replacement from a collection
@param c
The collection to be sampled from
@param n
The number of samples to take
@return a new collection with the sample | [
"Samples",
"with",
"replacement",
"from",
"a",
"collection"
]
| train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/CollectionUtils.java#L377-L379 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.