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
|
---|---|---|---|---|---|---|---|---|---|---|
pressgang-ccms/PressGangCCMSContentSpecProcessor | src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java | ContentSpecParser.parseLevelLine | protected Level parseLevelLine(final ParserData parserData, final String line, int lineNumber) throws ParsingException {
"""
Processes a line that represents the start of a Content Specification Level. This method creates the level based on the data in
the line and then changes the current processing level to the new level.
@param parserData
@param line The line to be processed as a level.
@return True if the line was processed without errors, otherwise false.
"""
String tempInput[] = StringUtilities.split(line, ':', 2);
// Remove the whitespace from each value in the split array
tempInput = CollectionUtilities.trimStringArray(tempInput);
if (tempInput.length >= 1) {
final LevelType levelType = LevelType.getLevelType(tempInput[0]);
Level retValue = null;
try {
retValue = parseLevel(parserData, lineNumber, levelType, line);
} catch (ParsingException e) {
log.error(e.getMessage());
// Create a basic level so the rest of the spec can be processed
retValue = createEmptyLevelFromType(lineNumber, levelType, line);
retValue.setUniqueId("L" + lineNumber);
}
parserData.getLevels().put(retValue.getUniqueId(), retValue);
return retValue;
} else {
throw new ParsingException(format(ProcessorConstants.ERROR_LEVEL_FORMAT_MSG, lineNumber, line));
}
} | java | protected Level parseLevelLine(final ParserData parserData, final String line, int lineNumber) throws ParsingException {
String tempInput[] = StringUtilities.split(line, ':', 2);
// Remove the whitespace from each value in the split array
tempInput = CollectionUtilities.trimStringArray(tempInput);
if (tempInput.length >= 1) {
final LevelType levelType = LevelType.getLevelType(tempInput[0]);
Level retValue = null;
try {
retValue = parseLevel(parserData, lineNumber, levelType, line);
} catch (ParsingException e) {
log.error(e.getMessage());
// Create a basic level so the rest of the spec can be processed
retValue = createEmptyLevelFromType(lineNumber, levelType, line);
retValue.setUniqueId("L" + lineNumber);
}
parserData.getLevels().put(retValue.getUniqueId(), retValue);
return retValue;
} else {
throw new ParsingException(format(ProcessorConstants.ERROR_LEVEL_FORMAT_MSG, lineNumber, line));
}
} | [
"protected",
"Level",
"parseLevelLine",
"(",
"final",
"ParserData",
"parserData",
",",
"final",
"String",
"line",
",",
"int",
"lineNumber",
")",
"throws",
"ParsingException",
"{",
"String",
"tempInput",
"[",
"]",
"=",
"StringUtilities",
".",
"split",
"(",
"line",
",",
"'",
"'",
",",
"2",
")",
";",
"// Remove the whitespace from each value in the split array",
"tempInput",
"=",
"CollectionUtilities",
".",
"trimStringArray",
"(",
"tempInput",
")",
";",
"if",
"(",
"tempInput",
".",
"length",
">=",
"1",
")",
"{",
"final",
"LevelType",
"levelType",
"=",
"LevelType",
".",
"getLevelType",
"(",
"tempInput",
"[",
"0",
"]",
")",
";",
"Level",
"retValue",
"=",
"null",
";",
"try",
"{",
"retValue",
"=",
"parseLevel",
"(",
"parserData",
",",
"lineNumber",
",",
"levelType",
",",
"line",
")",
";",
"}",
"catch",
"(",
"ParsingException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"// Create a basic level so the rest of the spec can be processed",
"retValue",
"=",
"createEmptyLevelFromType",
"(",
"lineNumber",
",",
"levelType",
",",
"line",
")",
";",
"retValue",
".",
"setUniqueId",
"(",
"\"L\"",
"+",
"lineNumber",
")",
";",
"}",
"parserData",
".",
"getLevels",
"(",
")",
".",
"put",
"(",
"retValue",
".",
"getUniqueId",
"(",
")",
",",
"retValue",
")",
";",
"return",
"retValue",
";",
"}",
"else",
"{",
"throw",
"new",
"ParsingException",
"(",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_LEVEL_FORMAT_MSG",
",",
"lineNumber",
",",
"line",
")",
")",
";",
"}",
"}"
]
| Processes a line that represents the start of a Content Specification Level. This method creates the level based on the data in
the line and then changes the current processing level to the new level.
@param parserData
@param line The line to be processed as a level.
@return True if the line was processed without errors, otherwise false. | [
"Processes",
"a",
"line",
"that",
"represents",
"the",
"start",
"of",
"a",
"Content",
"Specification",
"Level",
".",
"This",
"method",
"creates",
"the",
"level",
"based",
"on",
"the",
"data",
"in",
"the",
"line",
"and",
"then",
"changes",
"the",
"current",
"processing",
"level",
"to",
"the",
"new",
"level",
"."
]
| train | https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L608-L631 |
webmetrics/browsermob-proxy | src/main/java/org/browsermob/proxy/jetty/html/TableForm.java | TableForm.addSelect | public Select addSelect(String tag,
String label,
boolean multiple,
int size) {
"""
Add a Select field.
@param tag The form name of the element
@param label The label for the element in the table.
"""
Select s = new Select(tag,multiple);
s.setSize(size);
addField(label,s);
return s;
} | java | public Select addSelect(String tag,
String label,
boolean multiple,
int size)
{
Select s = new Select(tag,multiple);
s.setSize(size);
addField(label,s);
return s;
} | [
"public",
"Select",
"addSelect",
"(",
"String",
"tag",
",",
"String",
"label",
",",
"boolean",
"multiple",
",",
"int",
"size",
")",
"{",
"Select",
"s",
"=",
"new",
"Select",
"(",
"tag",
",",
"multiple",
")",
";",
"s",
".",
"setSize",
"(",
"size",
")",
";",
"addField",
"(",
"label",
",",
"s",
")",
";",
"return",
"s",
";",
"}"
]
| Add a Select field.
@param tag The form name of the element
@param label The label for the element in the table. | [
"Add",
"a",
"Select",
"field",
"."
]
| train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/browsermob/proxy/jetty/html/TableForm.java#L167-L176 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/BoardsApi.java | BoardsApi.createBoardList | public BoardList createBoardList(Object projectIdOrPath, Integer boardId, Integer labelId) throws GitLabApiException {
"""
Creates a new Issue Board list.
<pre><code>GitLab Endpoint: POST /projects/:id/boards/:board_id/lists</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param boardId the ID of the board
@param labelId the ID of the label
@return the created BoardList instance
@throws GitLabApiException if any exception occurs
"""
GitLabApiForm formData = new GitLabApiForm()
.withParam("label_id", labelId, true);
Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists");
return (response.readEntity(BoardList.class));
} | java | public BoardList createBoardList(Object projectIdOrPath, Integer boardId, Integer labelId) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("label_id", labelId, true);
Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists");
return (response.readEntity(BoardList.class));
} | [
"public",
"BoardList",
"createBoardList",
"(",
"Object",
"projectIdOrPath",
",",
"Integer",
"boardId",
",",
"Integer",
"labelId",
")",
"throws",
"GitLabApiException",
"{",
"GitLabApiForm",
"formData",
"=",
"new",
"GitLabApiForm",
"(",
")",
".",
"withParam",
"(",
"\"label_id\"",
",",
"labelId",
",",
"true",
")",
";",
"Response",
"response",
"=",
"post",
"(",
"Response",
".",
"Status",
".",
"CREATED",
",",
"formData",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"boards\"",
",",
"boardId",
",",
"\"lists\"",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"BoardList",
".",
"class",
")",
")",
";",
"}"
]
| Creates a new Issue Board list.
<pre><code>GitLab Endpoint: POST /projects/:id/boards/:board_id/lists</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param boardId the ID of the board
@param labelId the ID of the label
@return the created BoardList instance
@throws GitLabApiException if any exception occurs | [
"Creates",
"a",
"new",
"Issue",
"Board",
"list",
"."
]
| train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/BoardsApi.java#L290-L295 |
arquillian/arquillian-algeron | common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java | GitOperations.pullFromRepository | public PullResult pullFromRepository(Git git, String remote, String remoteBranch) {
"""
Pull repository from current branch and remote branch with same name as current
@param git
instance.
@param remote
to be used.
@param remoteBranch
to use.
"""
try {
return git.pull()
.setRemote(remote)
.setRemoteBranchName(remoteBranch)
.call();
} catch (GitAPIException e) {
throw new IllegalStateException(e);
}
} | java | public PullResult pullFromRepository(Git git, String remote, String remoteBranch) {
try {
return git.pull()
.setRemote(remote)
.setRemoteBranchName(remoteBranch)
.call();
} catch (GitAPIException e) {
throw new IllegalStateException(e);
}
} | [
"public",
"PullResult",
"pullFromRepository",
"(",
"Git",
"git",
",",
"String",
"remote",
",",
"String",
"remoteBranch",
")",
"{",
"try",
"{",
"return",
"git",
".",
"pull",
"(",
")",
".",
"setRemote",
"(",
"remote",
")",
".",
"setRemoteBranchName",
"(",
"remoteBranch",
")",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"GitAPIException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}"
]
| Pull repository from current branch and remote branch with same name as current
@param git
instance.
@param remote
to be used.
@param remoteBranch
to use. | [
"Pull",
"repository",
"from",
"current",
"branch",
"and",
"remote",
"branch",
"with",
"same",
"name",
"as",
"current"
]
| train | https://github.com/arquillian/arquillian-algeron/blob/ec79372defdafe99ab2f7bb696f1c1eabdbbacb6/common/git/src/main/java/org/arquillian/algeron/git/GitOperations.java#L259-L268 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/journal/entry/CreatorJournalEntry.java | CreatorJournalEntry.invokeMethod | public Object invokeMethod(ManagementDelegate delegate, JournalWriter writer)
throws ServerException, JournalException {
"""
Process the management method:
<ul>
<li>Check the operating mode - if we are in
{@link JournalOperatingMode#READ_ONLY Read-Only} mode, this check will
throw an exception.</li>
<li>Prepare the writer in case we need to initialize a new file with a
repository hash.</li>
<li>Invoke the method on the ManagementDelegate.</li>
<li>Write the full journal entry, including any context changes from the
Management method.</li>
</ul>
These operations occur within a synchronized block. We must be sure that
any pending operations are complete before we get the repository hash, so
we are confident that the hash accurately reflects the state of the
repository. Since all API-M operations go through this synchronized
block, we can be confident that the previous one had completed before the
current one started.
<p>
There might be a way to enforce the synchronization at a lower level,
thus increasing throughput, but we haven't explored it yet.
"""
synchronized (JournalWriter.SYNCHRONIZER) {
JournalOperatingMode.enforceCurrentMode();
writer.prepareToWriteJournalEntry();
Object result = super.getMethod().invoke(delegate);
writer.writeJournalEntry(this);
return result;
}
} | java | public Object invokeMethod(ManagementDelegate delegate, JournalWriter writer)
throws ServerException, JournalException {
synchronized (JournalWriter.SYNCHRONIZER) {
JournalOperatingMode.enforceCurrentMode();
writer.prepareToWriteJournalEntry();
Object result = super.getMethod().invoke(delegate);
writer.writeJournalEntry(this);
return result;
}
} | [
"public",
"Object",
"invokeMethod",
"(",
"ManagementDelegate",
"delegate",
",",
"JournalWriter",
"writer",
")",
"throws",
"ServerException",
",",
"JournalException",
"{",
"synchronized",
"(",
"JournalWriter",
".",
"SYNCHRONIZER",
")",
"{",
"JournalOperatingMode",
".",
"enforceCurrentMode",
"(",
")",
";",
"writer",
".",
"prepareToWriteJournalEntry",
"(",
")",
";",
"Object",
"result",
"=",
"super",
".",
"getMethod",
"(",
")",
".",
"invoke",
"(",
"delegate",
")",
";",
"writer",
".",
"writeJournalEntry",
"(",
"this",
")",
";",
"return",
"result",
";",
"}",
"}"
]
| Process the management method:
<ul>
<li>Check the operating mode - if we are in
{@link JournalOperatingMode#READ_ONLY Read-Only} mode, this check will
throw an exception.</li>
<li>Prepare the writer in case we need to initialize a new file with a
repository hash.</li>
<li>Invoke the method on the ManagementDelegate.</li>
<li>Write the full journal entry, including any context changes from the
Management method.</li>
</ul>
These operations occur within a synchronized block. We must be sure that
any pending operations are complete before we get the repository hash, so
we are confident that the hash accurately reflects the state of the
repository. Since all API-M operations go through this synchronized
block, we can be confident that the previous one had completed before the
current one started.
<p>
There might be a way to enforce the synchronization at a lower level,
thus increasing throughput, but we haven't explored it yet. | [
"Process",
"the",
"management",
"method",
":",
"<ul",
">",
"<li",
">",
"Check",
"the",
"operating",
"mode",
"-",
"if",
"we",
"are",
"in",
"{"
]
| train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/entry/CreatorJournalEntry.java#L55-L64 |
QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java | ObjectUpdater.addNewObject | public ObjectResult addNewObject(SpiderTransaction parentTran, DBObject dbObj) {
"""
Add the given DBObject to the database as a new object. No check is made to see if
an object with the same ID already exists. If the update is successful, updates are
merged to the given parent SpiderTransaction.
@param parentTran Parent {@link SpiderTransaction} to which updates are applied
if the add is successful.
@param dbObj DBObject to be added to the database.
@return {@link ObjectResult} representing the results of the update.
"""
ObjectResult result = new ObjectResult();
try {
addBrandNewObject(dbObj);
result.setObjectID(dbObj.getObjectID());
result.setUpdated(true);
parentTran.mergeSubTransaction(m_dbTran);
m_logger.trace("addNewObject(): Object added/updated for ID={}", dbObj.getObjectID());
} catch (Throwable ex) {
buildErrorStatus(result, dbObj.getObjectID(), ex);
}
return result;
} | java | public ObjectResult addNewObject(SpiderTransaction parentTran, DBObject dbObj) {
ObjectResult result = new ObjectResult();
try {
addBrandNewObject(dbObj);
result.setObjectID(dbObj.getObjectID());
result.setUpdated(true);
parentTran.mergeSubTransaction(m_dbTran);
m_logger.trace("addNewObject(): Object added/updated for ID={}", dbObj.getObjectID());
} catch (Throwable ex) {
buildErrorStatus(result, dbObj.getObjectID(), ex);
}
return result;
} | [
"public",
"ObjectResult",
"addNewObject",
"(",
"SpiderTransaction",
"parentTran",
",",
"DBObject",
"dbObj",
")",
"{",
"ObjectResult",
"result",
"=",
"new",
"ObjectResult",
"(",
")",
";",
"try",
"{",
"addBrandNewObject",
"(",
"dbObj",
")",
";",
"result",
".",
"setObjectID",
"(",
"dbObj",
".",
"getObjectID",
"(",
")",
")",
";",
"result",
".",
"setUpdated",
"(",
"true",
")",
";",
"parentTran",
".",
"mergeSubTransaction",
"(",
"m_dbTran",
")",
";",
"m_logger",
".",
"trace",
"(",
"\"addNewObject(): Object added/updated for ID={}\"",
",",
"dbObj",
".",
"getObjectID",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"ex",
")",
"{",
"buildErrorStatus",
"(",
"result",
",",
"dbObj",
".",
"getObjectID",
"(",
")",
",",
"ex",
")",
";",
"}",
"return",
"result",
";",
"}"
]
| Add the given DBObject to the database as a new object. No check is made to see if
an object with the same ID already exists. If the update is successful, updates are
merged to the given parent SpiderTransaction.
@param parentTran Parent {@link SpiderTransaction} to which updates are applied
if the add is successful.
@param dbObj DBObject to be added to the database.
@return {@link ObjectResult} representing the results of the update. | [
"Add",
"the",
"given",
"DBObject",
"to",
"the",
"database",
"as",
"a",
"new",
"object",
".",
"No",
"check",
"is",
"made",
"to",
"see",
"if",
"an",
"object",
"with",
"the",
"same",
"ID",
"already",
"exists",
".",
"If",
"the",
"update",
"is",
"successful",
"updates",
"are",
"merged",
"to",
"the",
"given",
"parent",
"SpiderTransaction",
"."
]
| train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/spider/ObjectUpdater.java#L112-L124 |
pressgang-ccms/PressGangCCMSContentSpecProcessor | src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java | ContentSpecParser.processEitherSpec | protected ParserResults processEitherSpec(final ParserData parserData, final boolean processProcesses) {
"""
Process Content Specification that is either NEW or EDITED. That is that it should start with a CHECKSUM and ID or a Title.
@param parserData
@param processProcesses If processes should be processed to populate the relationships.
@return True if the content spec was processed successfully otherwise false.
"""
try {
final Pair<String, String> keyValuePair = ProcessorUtilities.getAndValidateKeyValuePair(parserData.getLines().peek());
final String key = keyValuePair.getFirst();
if (key.equalsIgnoreCase(CommonConstants.CS_CHECKSUM_TITLE) || key.equalsIgnoreCase(CommonConstants.CS_ID_TITLE)) {
return processEditedSpec(parserData, processProcesses);
} else {
return processNewSpec(parserData, processProcesses);
}
} catch (InvalidKeyValueException e) {
log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG, e);
return new ParserResults(false, null);
}
} | java | protected ParserResults processEitherSpec(final ParserData parserData, final boolean processProcesses) {
try {
final Pair<String, String> keyValuePair = ProcessorUtilities.getAndValidateKeyValuePair(parserData.getLines().peek());
final String key = keyValuePair.getFirst();
if (key.equalsIgnoreCase(CommonConstants.CS_CHECKSUM_TITLE) || key.equalsIgnoreCase(CommonConstants.CS_ID_TITLE)) {
return processEditedSpec(parserData, processProcesses);
} else {
return processNewSpec(parserData, processProcesses);
}
} catch (InvalidKeyValueException e) {
log.error(ProcessorConstants.ERROR_INCORRECT_FILE_FORMAT_MSG, e);
return new ParserResults(false, null);
}
} | [
"protected",
"ParserResults",
"processEitherSpec",
"(",
"final",
"ParserData",
"parserData",
",",
"final",
"boolean",
"processProcesses",
")",
"{",
"try",
"{",
"final",
"Pair",
"<",
"String",
",",
"String",
">",
"keyValuePair",
"=",
"ProcessorUtilities",
".",
"getAndValidateKeyValuePair",
"(",
"parserData",
".",
"getLines",
"(",
")",
".",
"peek",
"(",
")",
")",
";",
"final",
"String",
"key",
"=",
"keyValuePair",
".",
"getFirst",
"(",
")",
";",
"if",
"(",
"key",
".",
"equalsIgnoreCase",
"(",
"CommonConstants",
".",
"CS_CHECKSUM_TITLE",
")",
"||",
"key",
".",
"equalsIgnoreCase",
"(",
"CommonConstants",
".",
"CS_ID_TITLE",
")",
")",
"{",
"return",
"processEditedSpec",
"(",
"parserData",
",",
"processProcesses",
")",
";",
"}",
"else",
"{",
"return",
"processNewSpec",
"(",
"parserData",
",",
"processProcesses",
")",
";",
"}",
"}",
"catch",
"(",
"InvalidKeyValueException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"ProcessorConstants",
".",
"ERROR_INCORRECT_FILE_FORMAT_MSG",
",",
"e",
")",
";",
"return",
"new",
"ParserResults",
"(",
"false",
",",
"null",
")",
";",
"}",
"}"
]
| Process Content Specification that is either NEW or EDITED. That is that it should start with a CHECKSUM and ID or a Title.
@param parserData
@param processProcesses If processes should be processed to populate the relationships.
@return True if the content spec was processed successfully otherwise false. | [
"Process",
"Content",
"Specification",
"that",
"is",
"either",
"NEW",
"or",
"EDITED",
".",
"That",
"is",
"that",
"it",
"should",
"start",
"with",
"a",
"CHECKSUM",
"and",
"ID",
"or",
"a",
"Title",
"."
]
| train | https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecParser.java#L352-L366 |
IBM/ibm-cos-sdk-java | ibm-cos-java-sdk-core/src/main/java/com/ibm/cloud/objectstorage/auth/SignerFactory.java | SignerFactory.createSigner | @SdkProtectedApi
public static Signer createSigner(String signerType, SignerParams params) {
"""
Create an instance of the given signer type and initialize it with the
given parameters.
@param signerType The signer type.
@param params The parameters to intialize the signer with.
@return The new signer instance.
"""
Signer signer = createSigner(signerType);
if (signer instanceof ServiceAwareSigner) {
((ServiceAwareSigner) signer).setServiceName(params.getServiceName());
}
if (signer instanceof RegionAwareSigner) {
((RegionAwareSigner) signer).setRegionName(params.getRegionName());
}
return signer;
} | java | @SdkProtectedApi
public static Signer createSigner(String signerType, SignerParams params) {
Signer signer = createSigner(signerType);
if (signer instanceof ServiceAwareSigner) {
((ServiceAwareSigner) signer).setServiceName(params.getServiceName());
}
if (signer instanceof RegionAwareSigner) {
((RegionAwareSigner) signer).setRegionName(params.getRegionName());
}
return signer;
} | [
"@",
"SdkProtectedApi",
"public",
"static",
"Signer",
"createSigner",
"(",
"String",
"signerType",
",",
"SignerParams",
"params",
")",
"{",
"Signer",
"signer",
"=",
"createSigner",
"(",
"signerType",
")",
";",
"if",
"(",
"signer",
"instanceof",
"ServiceAwareSigner",
")",
"{",
"(",
"(",
"ServiceAwareSigner",
")",
"signer",
")",
".",
"setServiceName",
"(",
"params",
".",
"getServiceName",
"(",
")",
")",
";",
"}",
"if",
"(",
"signer",
"instanceof",
"RegionAwareSigner",
")",
"{",
"(",
"(",
"RegionAwareSigner",
")",
"signer",
")",
".",
"setRegionName",
"(",
"params",
".",
"getRegionName",
"(",
")",
")",
";",
"}",
"return",
"signer",
";",
"}"
]
| Create an instance of the given signer type and initialize it with the
given parameters.
@param signerType The signer type.
@param params The parameters to intialize the signer with.
@return The new signer instance. | [
"Create",
"an",
"instance",
"of",
"the",
"given",
"signer",
"type",
"and",
"initialize",
"it",
"with",
"the",
"given",
"parameters",
"."
]
| train | https://github.com/IBM/ibm-cos-sdk-java/blob/d0bb2dd754c328a05e7dba8dc42e28b271b6daf2/ibm-cos-java-sdk-core/src/main/java/com/ibm/cloud/objectstorage/auth/SignerFactory.java#L143-L156 |
bThink-BGU/BPjs | src/main/java/il/ac/bgu/cs/bp/bpjs/analysis/DfsTraversalNode.java | DfsTraversalNode.getInitialNode | public static DfsTraversalNode getInitialNode(BProgram bp, ExecutorService exSvc) throws Exception {
"""
Get the initial nod for a run of the passed {@code BPorgram}.
@param bp The {@link BProgram} being verified.
@param exSvc The executor service that will run the threads
@return Initial node for the BProgram run
@throws Exception in case there's an error with the executed JavaScript code.
@deprecated Use the inside code, this whole class might be going away soon.
"""
BProgramSyncSnapshot seed = bp.setup().start(exSvc);
return new DfsTraversalNode(bp, seed, null);
} | java | public static DfsTraversalNode getInitialNode(BProgram bp, ExecutorService exSvc) throws Exception {
BProgramSyncSnapshot seed = bp.setup().start(exSvc);
return new DfsTraversalNode(bp, seed, null);
} | [
"public",
"static",
"DfsTraversalNode",
"getInitialNode",
"(",
"BProgram",
"bp",
",",
"ExecutorService",
"exSvc",
")",
"throws",
"Exception",
"{",
"BProgramSyncSnapshot",
"seed",
"=",
"bp",
".",
"setup",
"(",
")",
".",
"start",
"(",
"exSvc",
")",
";",
"return",
"new",
"DfsTraversalNode",
"(",
"bp",
",",
"seed",
",",
"null",
")",
";",
"}"
]
| Get the initial nod for a run of the passed {@code BPorgram}.
@param bp The {@link BProgram} being verified.
@param exSvc The executor service that will run the threads
@return Initial node for the BProgram run
@throws Exception in case there's an error with the executed JavaScript code.
@deprecated Use the inside code, this whole class might be going away soon. | [
"Get",
"the",
"initial",
"nod",
"for",
"a",
"run",
"of",
"the",
"passed",
"{",
"@code",
"BPorgram",
"}",
"."
]
| train | https://github.com/bThink-BGU/BPjs/blob/2d388365a27ad79ded108eaf98a35a7ef292ae1f/src/main/java/il/ac/bgu/cs/bp/bpjs/analysis/DfsTraversalNode.java#L35-L39 |
looly/hutool | hutool-script/src/main/java/cn/hutool/script/ScriptUtil.java | ScriptUtil.eval | public static Object eval(String script, ScriptContext context) throws ScriptRuntimeException {
"""
编译脚本
@param script 脚本内容
@param context 脚本上下文
@return {@link CompiledScript}
@throws ScriptRuntimeException 脚本异常
@since 3.2.0
"""
try {
return compile(script).eval(context);
} catch (ScriptException e) {
throw new ScriptRuntimeException(e);
}
} | java | public static Object eval(String script, ScriptContext context) throws ScriptRuntimeException {
try {
return compile(script).eval(context);
} catch (ScriptException e) {
throw new ScriptRuntimeException(e);
}
} | [
"public",
"static",
"Object",
"eval",
"(",
"String",
"script",
",",
"ScriptContext",
"context",
")",
"throws",
"ScriptRuntimeException",
"{",
"try",
"{",
"return",
"compile",
"(",
"script",
")",
".",
"eval",
"(",
"context",
")",
";",
"}",
"catch",
"(",
"ScriptException",
"e",
")",
"{",
"throw",
"new",
"ScriptRuntimeException",
"(",
"e",
")",
";",
"}",
"}"
]
| 编译脚本
@param script 脚本内容
@param context 脚本上下文
@return {@link CompiledScript}
@throws ScriptRuntimeException 脚本异常
@since 3.2.0 | [
"编译脚本"
]
| train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-script/src/main/java/cn/hutool/script/ScriptUtil.java#L63-L69 |
WASdev/standards.jsr352.jbatch | com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/SplitControllerImpl.java | SplitControllerImpl.buildSubJobBatchWorkUnits | private void buildSubJobBatchWorkUnits() {
"""
Note we restart all flows. There is no concept of "the flow completed". It is only steps
within the flows that may have already completed and so may not have needed to be rerun.
"""
List<Flow> flows = this.split.getFlows();
parallelBatchWorkUnits = new ArrayList<BatchFlowInSplitWorkUnit>();
// Build all sub jobs from flows in split
synchronized (subJobs) {
for (Flow flow : flows) {
subJobs.add(PartitionedStepBuilder.buildFlowInSplitSubJob(jobContext, this.split, flow));
}
// Go back to earlier idea that we may have seen this id before, and need a special "always restart" behavior
// for split-flows.
for (JSLJob job : subJobs) {
int count = batchKernel.getJobInstanceCount(job.getId());
FlowInSplitBuilderConfig config = new FlowInSplitBuilderConfig(job, completedWorkQueue, rootJobExecutionId);
if (count == 0) {
parallelBatchWorkUnits.add(batchKernel.buildNewFlowInSplitWorkUnit(config));
} else if (count == 1) {
parallelBatchWorkUnits.add(batchKernel.buildOnRestartFlowInSplitWorkUnit(config));
} else {
throw new IllegalStateException("There is an inconsistency somewhere in the internal subjob creation");
}
}
}
} | java | private void buildSubJobBatchWorkUnits() {
List<Flow> flows = this.split.getFlows();
parallelBatchWorkUnits = new ArrayList<BatchFlowInSplitWorkUnit>();
// Build all sub jobs from flows in split
synchronized (subJobs) {
for (Flow flow : flows) {
subJobs.add(PartitionedStepBuilder.buildFlowInSplitSubJob(jobContext, this.split, flow));
}
// Go back to earlier idea that we may have seen this id before, and need a special "always restart" behavior
// for split-flows.
for (JSLJob job : subJobs) {
int count = batchKernel.getJobInstanceCount(job.getId());
FlowInSplitBuilderConfig config = new FlowInSplitBuilderConfig(job, completedWorkQueue, rootJobExecutionId);
if (count == 0) {
parallelBatchWorkUnits.add(batchKernel.buildNewFlowInSplitWorkUnit(config));
} else if (count == 1) {
parallelBatchWorkUnits.add(batchKernel.buildOnRestartFlowInSplitWorkUnit(config));
} else {
throw new IllegalStateException("There is an inconsistency somewhere in the internal subjob creation");
}
}
}
} | [
"private",
"void",
"buildSubJobBatchWorkUnits",
"(",
")",
"{",
"List",
"<",
"Flow",
">",
"flows",
"=",
"this",
".",
"split",
".",
"getFlows",
"(",
")",
";",
"parallelBatchWorkUnits",
"=",
"new",
"ArrayList",
"<",
"BatchFlowInSplitWorkUnit",
">",
"(",
")",
";",
"// Build all sub jobs from flows in split\r",
"synchronized",
"(",
"subJobs",
")",
"{",
"for",
"(",
"Flow",
"flow",
":",
"flows",
")",
"{",
"subJobs",
".",
"add",
"(",
"PartitionedStepBuilder",
".",
"buildFlowInSplitSubJob",
"(",
"jobContext",
",",
"this",
".",
"split",
",",
"flow",
")",
")",
";",
"}",
"// Go back to earlier idea that we may have seen this id before, and need a special \"always restart\" behavior\r",
"// for split-flows.\r",
"for",
"(",
"JSLJob",
"job",
":",
"subJobs",
")",
"{",
"int",
"count",
"=",
"batchKernel",
".",
"getJobInstanceCount",
"(",
"job",
".",
"getId",
"(",
")",
")",
";",
"FlowInSplitBuilderConfig",
"config",
"=",
"new",
"FlowInSplitBuilderConfig",
"(",
"job",
",",
"completedWorkQueue",
",",
"rootJobExecutionId",
")",
";",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"parallelBatchWorkUnits",
".",
"add",
"(",
"batchKernel",
".",
"buildNewFlowInSplitWorkUnit",
"(",
"config",
")",
")",
";",
"}",
"else",
"if",
"(",
"count",
"==",
"1",
")",
"{",
"parallelBatchWorkUnits",
".",
"add",
"(",
"batchKernel",
".",
"buildOnRestartFlowInSplitWorkUnit",
"(",
"config",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"There is an inconsistency somewhere in the internal subjob creation\"",
")",
";",
"}",
"}",
"}",
"}"
]
| Note we restart all flows. There is no concept of "the flow completed". It is only steps
within the flows that may have already completed and so may not have needed to be rerun. | [
"Note",
"we",
"restart",
"all",
"flows",
".",
"There",
"is",
"no",
"concept",
"of",
"the",
"flow",
"completed",
".",
"It",
"is",
"only",
"steps",
"within",
"the",
"flows",
"that",
"may",
"have",
"already",
"completed",
"and",
"so",
"may",
"not",
"have",
"needed",
"to",
"be",
"rerun",
"."
]
| train | https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/impl/SplitControllerImpl.java#L138-L163 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/view/ViewUtils.java | ViewUtils.pixelToDip | public static float pixelToDip(WindowManager windowManager, int pixel) {
"""
Convert the pixels to dips, based on density scale
@param windowManager the window manager of the display to use the scale density of.
@param pixel to be converted value.
@return converted value(dip).
"""
DisplayMetrics metrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(metrics);
return metrics.scaledDensity * pixel;
} | java | public static float pixelToDip(WindowManager windowManager, int pixel) {
DisplayMetrics metrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(metrics);
return metrics.scaledDensity * pixel;
} | [
"public",
"static",
"float",
"pixelToDip",
"(",
"WindowManager",
"windowManager",
",",
"int",
"pixel",
")",
"{",
"DisplayMetrics",
"metrics",
"=",
"new",
"DisplayMetrics",
"(",
")",
";",
"windowManager",
".",
"getDefaultDisplay",
"(",
")",
".",
"getMetrics",
"(",
"metrics",
")",
";",
"return",
"metrics",
".",
"scaledDensity",
"*",
"pixel",
";",
"}"
]
| Convert the pixels to dips, based on density scale
@param windowManager the window manager of the display to use the scale density of.
@param pixel to be converted value.
@return converted value(dip). | [
"Convert",
"the",
"pixels",
"to",
"dips",
"based",
"on",
"density",
"scale"
]
| train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/view/ViewUtils.java#L75-L79 |
mozilla/rhino | src/org/mozilla/javascript/ScriptRuntime.java | ScriptRuntime.throwCustomError | public static JavaScriptException throwCustomError(Context cx, Scriptable scope, String constructorName,
String message) {
"""
Equivalent to executing "new $constructorName(message, sourceFileName, sourceLineNo)" from JavaScript.
@param cx the current context
@param scope the current scope
@param message the message
@return a JavaScriptException you should throw
"""
int[] linep = { 0 };
String filename = Context.getSourcePositionFromStack(linep);
final Scriptable error = cx.newObject(scope, constructorName,
new Object[] { message, filename, Integer.valueOf(linep[0]) });
return new JavaScriptException(error, filename, linep[0]);
} | java | public static JavaScriptException throwCustomError(Context cx, Scriptable scope, String constructorName,
String message) {
int[] linep = { 0 };
String filename = Context.getSourcePositionFromStack(linep);
final Scriptable error = cx.newObject(scope, constructorName,
new Object[] { message, filename, Integer.valueOf(linep[0]) });
return new JavaScriptException(error, filename, linep[0]);
} | [
"public",
"static",
"JavaScriptException",
"throwCustomError",
"(",
"Context",
"cx",
",",
"Scriptable",
"scope",
",",
"String",
"constructorName",
",",
"String",
"message",
")",
"{",
"int",
"[",
"]",
"linep",
"=",
"{",
"0",
"}",
";",
"String",
"filename",
"=",
"Context",
".",
"getSourcePositionFromStack",
"(",
"linep",
")",
";",
"final",
"Scriptable",
"error",
"=",
"cx",
".",
"newObject",
"(",
"scope",
",",
"constructorName",
",",
"new",
"Object",
"[",
"]",
"{",
"message",
",",
"filename",
",",
"Integer",
".",
"valueOf",
"(",
"linep",
"[",
"0",
"]",
")",
"}",
")",
";",
"return",
"new",
"JavaScriptException",
"(",
"error",
",",
"filename",
",",
"linep",
"[",
"0",
"]",
")",
";",
"}"
]
| Equivalent to executing "new $constructorName(message, sourceFileName, sourceLineNo)" from JavaScript.
@param cx the current context
@param scope the current scope
@param message the message
@return a JavaScriptException you should throw | [
"Equivalent",
"to",
"executing",
"new",
"$constructorName",
"(",
"message",
"sourceFileName",
"sourceLineNo",
")",
"from",
"JavaScript",
"."
]
| train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptRuntime.java#L4575-L4582 |
paymill/paymill-java | src/main/java/com/paymill/services/SubscriptionService.java | SubscriptionService.endTrialAt | public Subscription endTrialAt( String subscription, Date date ) {
"""
Stop the trial period of a subscription on a specific date.
@param subscription the subscription.
@param date the date, on which the subscription should end.
@return the updated subscription.
"""
return this.endTrialAt( new Subscription( subscription ), date );
} | java | public Subscription endTrialAt( String subscription, Date date ) {
return this.endTrialAt( new Subscription( subscription ), date );
} | [
"public",
"Subscription",
"endTrialAt",
"(",
"String",
"subscription",
",",
"Date",
"date",
")",
"{",
"return",
"this",
".",
"endTrialAt",
"(",
"new",
"Subscription",
"(",
"subscription",
")",
",",
"date",
")",
";",
"}"
]
| Stop the trial period of a subscription on a specific date.
@param subscription the subscription.
@param date the date, on which the subscription should end.
@return the updated subscription. | [
"Stop",
"the",
"trial",
"period",
"of",
"a",
"subscription",
"on",
"a",
"specific",
"date",
"."
]
| train | https://github.com/paymill/paymill-java/blob/17281a0d4376c76f1711af9f09bfc138c90ba65a/src/main/java/com/paymill/services/SubscriptionService.java#L540-L542 |
revinate/assertj-json | src/main/java/com/revinate/assertj/json/JsonPathAssert.java | JsonPathAssert.jsonPathAsListOf | public <T> AbstractListAssert<?, ? extends List<? extends T>, T, ? extends AbstractAssert<?, T>> jsonPathAsListOf(String path, Class<T> type) {
"""
Extracts a JSON array using a JsonPath expression and wrap it in a {@link ListAssert}. This method requires
the JsonPath to be <a href="https://github.com/jayway/JsonPath#jsonprovider-spi">configured with Jackson or
Gson</a>.
@param path JsonPath to extract the array
@param type The type to cast the content of the array, i.e.: {@link String}, {@link Integer}
@param <T> The generic type of the type field
@return an instance of {@link ListAssert}
"""
return Assertions.assertThat(actual.read(path, new TypeRef<List<T>>() {
}));
} | java | public <T> AbstractListAssert<?, ? extends List<? extends T>, T, ? extends AbstractAssert<?, T>> jsonPathAsListOf(String path, Class<T> type) {
return Assertions.assertThat(actual.read(path, new TypeRef<List<T>>() {
}));
} | [
"public",
"<",
"T",
">",
"AbstractListAssert",
"<",
"?",
",",
"?",
"extends",
"List",
"<",
"?",
"extends",
"T",
">",
",",
"T",
",",
"?",
"extends",
"AbstractAssert",
"<",
"?",
",",
"T",
">",
">",
"jsonPathAsListOf",
"(",
"String",
"path",
",",
"Class",
"<",
"T",
">",
"type",
")",
"{",
"return",
"Assertions",
".",
"assertThat",
"(",
"actual",
".",
"read",
"(",
"path",
",",
"new",
"TypeRef",
"<",
"List",
"<",
"T",
">",
">",
"(",
")",
"{",
"}",
")",
")",
";",
"}"
]
| Extracts a JSON array using a JsonPath expression and wrap it in a {@link ListAssert}. This method requires
the JsonPath to be <a href="https://github.com/jayway/JsonPath#jsonprovider-spi">configured with Jackson or
Gson</a>.
@param path JsonPath to extract the array
@param type The type to cast the content of the array, i.e.: {@link String}, {@link Integer}
@param <T> The generic type of the type field
@return an instance of {@link ListAssert} | [
"Extracts",
"a",
"JSON",
"array",
"using",
"a",
"JsonPath",
"expression",
"and",
"wrap",
"it",
"in",
"a",
"{",
"@link",
"ListAssert",
"}",
".",
"This",
"method",
"requires",
"the",
"JsonPath",
"to",
"be",
"<a",
"href",
"=",
"https",
":",
"//",
"github",
".",
"com",
"/",
"jayway",
"/",
"JsonPath#jsonprovider",
"-",
"spi",
">",
"configured",
"with",
"Jackson",
"or",
"Gson<",
"/",
"a",
">",
"."
]
| train | https://github.com/revinate/assertj-json/blob/84c36ef2ae46e317bf5b2c9d553ca2174301cdd3/src/main/java/com/revinate/assertj/json/JsonPathAssert.java#L55-L58 |
querydsl/querydsl | querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java | ExpressionUtils.predicateTemplate | public static PredicateTemplate predicateTemplate(String template, Object... args) {
"""
Create a new Template expression
@param template template
@param args template parameters
@return template expression
"""
return predicateTemplate(TemplateFactory.DEFAULT.create(template), ImmutableList.copyOf(args));
} | java | public static PredicateTemplate predicateTemplate(String template, Object... args) {
return predicateTemplate(TemplateFactory.DEFAULT.create(template), ImmutableList.copyOf(args));
} | [
"public",
"static",
"PredicateTemplate",
"predicateTemplate",
"(",
"String",
"template",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"predicateTemplate",
"(",
"TemplateFactory",
".",
"DEFAULT",
".",
"create",
"(",
"template",
")",
",",
"ImmutableList",
".",
"copyOf",
"(",
"args",
")",
")",
";",
"}"
]
| Create a new Template expression
@param template template
@param args template parameters
@return template expression | [
"Create",
"a",
"new",
"Template",
"expression"
]
| train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L140-L142 |
Domo42/saga-lib | saga-lib/src/main/java/com/codebullets/sagalib/processing/SagaTypeCacheLoader.java | SagaTypeCacheLoader.containsItem | private SagaType containsItem(final Iterable<SagaType> source, final Class itemToSearch) {
"""
Checks whether the source list contains a saga type matching the input class.
"""
SagaType containedItem = null;
for (SagaType sagaType : source) {
if (sagaType.getSagaClass().equals(itemToSearch)) {
containedItem = sagaType;
break;
}
}
return containedItem;
} | java | private SagaType containsItem(final Iterable<SagaType> source, final Class itemToSearch) {
SagaType containedItem = null;
for (SagaType sagaType : source) {
if (sagaType.getSagaClass().equals(itemToSearch)) {
containedItem = sagaType;
break;
}
}
return containedItem;
} | [
"private",
"SagaType",
"containsItem",
"(",
"final",
"Iterable",
"<",
"SagaType",
">",
"source",
",",
"final",
"Class",
"itemToSearch",
")",
"{",
"SagaType",
"containedItem",
"=",
"null",
";",
"for",
"(",
"SagaType",
"sagaType",
":",
"source",
")",
"{",
"if",
"(",
"sagaType",
".",
"getSagaClass",
"(",
")",
".",
"equals",
"(",
"itemToSearch",
")",
")",
"{",
"containedItem",
"=",
"sagaType",
";",
"break",
";",
"}",
"}",
"return",
"containedItem",
";",
"}"
]
| Checks whether the source list contains a saga type matching the input class. | [
"Checks",
"whether",
"the",
"source",
"list",
"contains",
"a",
"saga",
"type",
"matching",
"the",
"input",
"class",
"."
]
| train | https://github.com/Domo42/saga-lib/blob/c8f232e2a51fcb6a3fe0082cfbf105c1e6bf90ef/saga-lib/src/main/java/com/codebullets/sagalib/processing/SagaTypeCacheLoader.java#L120-L131 |
square/flow | flow/src/main/java/flow/Flow.java | Flow.onNewIntent | @CheckResult public static boolean onNewIntent(@NonNull Intent intent,
@NonNull Activity activity) {
"""
Handles an Intent carrying a History extra.
@return true if the Intent contains a History and it was handled.
"""
//noinspection ConstantConditions
checkArgument(intent != null, "intent may not be null");
if (intent.hasExtra(InternalLifecycleIntegration.INTENT_KEY)) {
InternalLifecycleIntegration.require(activity).onNewIntent(intent);
return true;
}
return false;
} | java | @CheckResult public static boolean onNewIntent(@NonNull Intent intent,
@NonNull Activity activity) {
//noinspection ConstantConditions
checkArgument(intent != null, "intent may not be null");
if (intent.hasExtra(InternalLifecycleIntegration.INTENT_KEY)) {
InternalLifecycleIntegration.require(activity).onNewIntent(intent);
return true;
}
return false;
} | [
"@",
"CheckResult",
"public",
"static",
"boolean",
"onNewIntent",
"(",
"@",
"NonNull",
"Intent",
"intent",
",",
"@",
"NonNull",
"Activity",
"activity",
")",
"{",
"//noinspection ConstantConditions",
"checkArgument",
"(",
"intent",
"!=",
"null",
",",
"\"intent may not be null\"",
")",
";",
"if",
"(",
"intent",
".",
"hasExtra",
"(",
"InternalLifecycleIntegration",
".",
"INTENT_KEY",
")",
")",
"{",
"InternalLifecycleIntegration",
".",
"require",
"(",
"activity",
")",
".",
"onNewIntent",
"(",
"intent",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Handles an Intent carrying a History extra.
@return true if the Intent contains a History and it was handled. | [
"Handles",
"an",
"Intent",
"carrying",
"a",
"History",
"extra",
"."
]
| train | https://github.com/square/flow/blob/1656288d1cb4a92dfbcff8276f4d7f9e3390419b/flow/src/main/java/flow/Flow.java#L107-L116 |
netty/netty | codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapter.java | InboundHttp2ToHttpAdapter.putMessage | protected final void putMessage(Http2Stream stream, FullHttpMessage message) {
"""
Make {@code message} be the state associated with {@code stream}.
@param stream The stream which {@code message} is associated with.
@param message The message which contains the HTTP semantics.
"""
FullHttpMessage previous = stream.setProperty(messageKey, message);
if (previous != message && previous != null) {
previous.release();
}
} | java | protected final void putMessage(Http2Stream stream, FullHttpMessage message) {
FullHttpMessage previous = stream.setProperty(messageKey, message);
if (previous != message && previous != null) {
previous.release();
}
} | [
"protected",
"final",
"void",
"putMessage",
"(",
"Http2Stream",
"stream",
",",
"FullHttpMessage",
"message",
")",
"{",
"FullHttpMessage",
"previous",
"=",
"stream",
".",
"setProperty",
"(",
"messageKey",
",",
"message",
")",
";",
"if",
"(",
"previous",
"!=",
"message",
"&&",
"previous",
"!=",
"null",
")",
"{",
"previous",
".",
"release",
"(",
")",
";",
"}",
"}"
]
| Make {@code message} be the state associated with {@code stream}.
@param stream The stream which {@code message} is associated with.
@param message The message which contains the HTTP semantics. | [
"Make",
"{"
]
| train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapter.java#L114-L119 |
artikcloud/artikcloud-java | src/main/java/cloud/artik/api/UsersApi.java | UsersApi.createUserProperties | public PropertiesEnvelope createUserProperties(String userId, AppProperties properties, String aid) throws ApiException {
"""
Create User Application Properties
Create application properties for a user
@param userId User Id (required)
@param properties Properties to be updated (required)
@param aid Application ID (optional)
@return PropertiesEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<PropertiesEnvelope> resp = createUserPropertiesWithHttpInfo(userId, properties, aid);
return resp.getData();
} | java | public PropertiesEnvelope createUserProperties(String userId, AppProperties properties, String aid) throws ApiException {
ApiResponse<PropertiesEnvelope> resp = createUserPropertiesWithHttpInfo(userId, properties, aid);
return resp.getData();
} | [
"public",
"PropertiesEnvelope",
"createUserProperties",
"(",
"String",
"userId",
",",
"AppProperties",
"properties",
",",
"String",
"aid",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"PropertiesEnvelope",
">",
"resp",
"=",
"createUserPropertiesWithHttpInfo",
"(",
"userId",
",",
"properties",
",",
"aid",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
]
| Create User Application Properties
Create application properties for a user
@param userId User Id (required)
@param properties Properties to be updated (required)
@param aid Application ID (optional)
@return PropertiesEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Create",
"User",
"Application",
"Properties",
"Create",
"application",
"properties",
"for",
"a",
"user"
]
| train | https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/UsersApi.java#L139-L142 |
aboutsip/sipstack | sipstack-netty-codec-sip/src/main/java/io/sipstack/netty/codec/sip/AbstractConnection.java | AbstractConnection.toByteBuf | protected ByteBuf toByteBuf(final SipMessage msg) {
"""
All {@link Connection}s needs to convert the msg to a {@link ByteBuf}
before writing it to the {@link ChannelHandlerContext}.
@param msg
the {@link SipMessage} to convert.
@return the resulting {@link ByteBuf}
"""
try {
final Buffer b = msg.toBuffer();
final int capacity = b.capacity() + 2;
final ByteBuf buffer = this.channel.alloc().buffer(capacity, capacity);
for (int i = 0; i < b.getReadableBytes(); ++i) {
buffer.writeByte(b.getByte(i));
}
buffer.writeByte(SipParser.CR);
buffer.writeByte(SipParser.LF);
return buffer;
} catch (final IOException e) {
// shouldn't be possible since the underlying buffer
// from the msg is backed by a byte-array.
// TODO: do something appropriate other than this
throw new RuntimeException("Unable to convert SipMessage to a ByteBuf due to IOException", e);
}
} | java | protected ByteBuf toByteBuf(final SipMessage msg) {
try {
final Buffer b = msg.toBuffer();
final int capacity = b.capacity() + 2;
final ByteBuf buffer = this.channel.alloc().buffer(capacity, capacity);
for (int i = 0; i < b.getReadableBytes(); ++i) {
buffer.writeByte(b.getByte(i));
}
buffer.writeByte(SipParser.CR);
buffer.writeByte(SipParser.LF);
return buffer;
} catch (final IOException e) {
// shouldn't be possible since the underlying buffer
// from the msg is backed by a byte-array.
// TODO: do something appropriate other than this
throw new RuntimeException("Unable to convert SipMessage to a ByteBuf due to IOException", e);
}
} | [
"protected",
"ByteBuf",
"toByteBuf",
"(",
"final",
"SipMessage",
"msg",
")",
"{",
"try",
"{",
"final",
"Buffer",
"b",
"=",
"msg",
".",
"toBuffer",
"(",
")",
";",
"final",
"int",
"capacity",
"=",
"b",
".",
"capacity",
"(",
")",
"+",
"2",
";",
"final",
"ByteBuf",
"buffer",
"=",
"this",
".",
"channel",
".",
"alloc",
"(",
")",
".",
"buffer",
"(",
"capacity",
",",
"capacity",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"b",
".",
"getReadableBytes",
"(",
")",
";",
"++",
"i",
")",
"{",
"buffer",
".",
"writeByte",
"(",
"b",
".",
"getByte",
"(",
"i",
")",
")",
";",
"}",
"buffer",
".",
"writeByte",
"(",
"SipParser",
".",
"CR",
")",
";",
"buffer",
".",
"writeByte",
"(",
"SipParser",
".",
"LF",
")",
";",
"return",
"buffer",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"// shouldn't be possible since the underlying buffer",
"// from the msg is backed by a byte-array.",
"// TODO: do something appropriate other than this",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to convert SipMessage to a ByteBuf due to IOException\"",
",",
"e",
")",
";",
"}",
"}"
]
| All {@link Connection}s needs to convert the msg to a {@link ByteBuf}
before writing it to the {@link ChannelHandlerContext}.
@param msg
the {@link SipMessage} to convert.
@return the resulting {@link ByteBuf} | [
"All",
"{",
"@link",
"Connection",
"}",
"s",
"needs",
"to",
"convert",
"the",
"msg",
"to",
"a",
"{",
"@link",
"ByteBuf",
"}",
"before",
"writing",
"it",
"to",
"the",
"{",
"@link",
"ChannelHandlerContext",
"}",
"."
]
| train | https://github.com/aboutsip/sipstack/blob/33f2db1d580738f0385687b0429fab0630118f42/sipstack-netty-codec-sip/src/main/java/io/sipstack/netty/codec/sip/AbstractConnection.java#L119-L137 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/HostServerGroupTracker.java | HostServerGroupTracker.getHostEffect | private synchronized HostServerGroupEffect getHostEffect(PathAddress address, String host, Resource root) {
"""
Creates an appropriate HSGE for resources in the host tree, excluding the server and server-config subtrees
"""
if (requiresMapping) {
map(root);
requiresMapping = false;
}
Set<String> mapped = hostsToGroups.get(host);
if (mapped == null) {
// Unassigned host. Treat like an unassigned profile or socket-binding-group;
// i.e. available to all server group scoped roles.
// Except -- WFLY-2085 -- the master HC is not open to all s-g-s-rs
Resource hostResource = root.getChild(PathElement.pathElement(HOST, host));
if (hostResource != null) {
ModelNode dcModel = hostResource.getModel().get(DOMAIN_CONTROLLER);
if (!dcModel.hasDefined(REMOTE)) {
mapped = Collections.emptySet(); // prevents returning HostServerGroupEffect.forUnassignedHost(address, host)
}
}
}
return mapped == null ? HostServerGroupEffect.forUnassignedHost(address, host)
: HostServerGroupEffect.forMappedHost(address, mapped, host);
} | java | private synchronized HostServerGroupEffect getHostEffect(PathAddress address, String host, Resource root) {
if (requiresMapping) {
map(root);
requiresMapping = false;
}
Set<String> mapped = hostsToGroups.get(host);
if (mapped == null) {
// Unassigned host. Treat like an unassigned profile or socket-binding-group;
// i.e. available to all server group scoped roles.
// Except -- WFLY-2085 -- the master HC is not open to all s-g-s-rs
Resource hostResource = root.getChild(PathElement.pathElement(HOST, host));
if (hostResource != null) {
ModelNode dcModel = hostResource.getModel().get(DOMAIN_CONTROLLER);
if (!dcModel.hasDefined(REMOTE)) {
mapped = Collections.emptySet(); // prevents returning HostServerGroupEffect.forUnassignedHost(address, host)
}
}
}
return mapped == null ? HostServerGroupEffect.forUnassignedHost(address, host)
: HostServerGroupEffect.forMappedHost(address, mapped, host);
} | [
"private",
"synchronized",
"HostServerGroupEffect",
"getHostEffect",
"(",
"PathAddress",
"address",
",",
"String",
"host",
",",
"Resource",
"root",
")",
"{",
"if",
"(",
"requiresMapping",
")",
"{",
"map",
"(",
"root",
")",
";",
"requiresMapping",
"=",
"false",
";",
"}",
"Set",
"<",
"String",
">",
"mapped",
"=",
"hostsToGroups",
".",
"get",
"(",
"host",
")",
";",
"if",
"(",
"mapped",
"==",
"null",
")",
"{",
"// Unassigned host. Treat like an unassigned profile or socket-binding-group;",
"// i.e. available to all server group scoped roles.",
"// Except -- WFLY-2085 -- the master HC is not open to all s-g-s-rs",
"Resource",
"hostResource",
"=",
"root",
".",
"getChild",
"(",
"PathElement",
".",
"pathElement",
"(",
"HOST",
",",
"host",
")",
")",
";",
"if",
"(",
"hostResource",
"!=",
"null",
")",
"{",
"ModelNode",
"dcModel",
"=",
"hostResource",
".",
"getModel",
"(",
")",
".",
"get",
"(",
"DOMAIN_CONTROLLER",
")",
";",
"if",
"(",
"!",
"dcModel",
".",
"hasDefined",
"(",
"REMOTE",
")",
")",
"{",
"mapped",
"=",
"Collections",
".",
"emptySet",
"(",
")",
";",
"// prevents returning HostServerGroupEffect.forUnassignedHost(address, host)",
"}",
"}",
"}",
"return",
"mapped",
"==",
"null",
"?",
"HostServerGroupEffect",
".",
"forUnassignedHost",
"(",
"address",
",",
"host",
")",
":",
"HostServerGroupEffect",
".",
"forMappedHost",
"(",
"address",
",",
"mapped",
",",
"host",
")",
";",
"}"
]
| Creates an appropriate HSGE for resources in the host tree, excluding the server and server-config subtrees | [
"Creates",
"an",
"appropriate",
"HSGE",
"for",
"resources",
"in",
"the",
"host",
"tree",
"excluding",
"the",
"server",
"and",
"server",
"-",
"config",
"subtrees"
]
| train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/HostServerGroupTracker.java#L314-L335 |
joniles/mpxj | src/main/java/net/sf/mpxj/turboproject/PEPUtility.java | PEPUtility.getShort | public static final int getShort(byte[] data, int offset) {
"""
Read a two byte integer.
@param data byte array
@param offset offset into array
@return integer value
"""
int result = 0;
int i = offset;
for (int shiftBy = 0; shiftBy < 16; shiftBy += 8)
{
result |= ((data[i] & 0xff)) << shiftBy;
++i;
}
return result;
} | java | public static final int getShort(byte[] data, int offset)
{
int result = 0;
int i = offset;
for (int shiftBy = 0; shiftBy < 16; shiftBy += 8)
{
result |= ((data[i] & 0xff)) << shiftBy;
++i;
}
return result;
} | [
"public",
"static",
"final",
"int",
"getShort",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"{",
"int",
"result",
"=",
"0",
";",
"int",
"i",
"=",
"offset",
";",
"for",
"(",
"int",
"shiftBy",
"=",
"0",
";",
"shiftBy",
"<",
"16",
";",
"shiftBy",
"+=",
"8",
")",
"{",
"result",
"|=",
"(",
"(",
"data",
"[",
"i",
"]",
"&",
"0xff",
")",
")",
"<<",
"shiftBy",
";",
"++",
"i",
";",
"}",
"return",
"result",
";",
"}"
]
| Read a two byte integer.
@param data byte array
@param offset offset into array
@return integer value | [
"Read",
"a",
"two",
"byte",
"integer",
"."
]
| train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/turboproject/PEPUtility.java#L61-L71 |
google/closure-compiler | src/com/google/javascript/jscomp/ConstParamCheck.java | ConstParamCheck.isSafeValue | private boolean isSafeValue(Scope scope, Node argument) {
"""
Checks if the method call argument is made of constant string literals.
<p>This function argument checker will return true if:
<ol>
<li>The argument is a constant variable assigned from a string literal, or
<li>The argument is an expression that is a string literal, or
<li>The argument is a ternary expression choosing between string literals, or
<li>The argument is a concatenation of the above.
</ol>
@param scope The scope chain to use in name lookups.
@param argument The node of function argument to check.
"""
if (NodeUtil.isSomeCompileTimeConstStringValue(argument)) {
return true;
} else if (argument.isAdd()) {
Node left = argument.getFirstChild();
Node right = argument.getLastChild();
return isSafeValue(scope, left) && isSafeValue(scope, right);
} else if (argument.isName()) {
String name = argument.getString();
Var var = scope.getVar(name);
if (var == null || !var.isInferredConst()) {
return false;
}
Node initialValue = var.getInitialValue();
if (initialValue == null) {
return false;
}
return isSafeValue(var.getScope(), initialValue);
}
return false;
} | java | private boolean isSafeValue(Scope scope, Node argument) {
if (NodeUtil.isSomeCompileTimeConstStringValue(argument)) {
return true;
} else if (argument.isAdd()) {
Node left = argument.getFirstChild();
Node right = argument.getLastChild();
return isSafeValue(scope, left) && isSafeValue(scope, right);
} else if (argument.isName()) {
String name = argument.getString();
Var var = scope.getVar(name);
if (var == null || !var.isInferredConst()) {
return false;
}
Node initialValue = var.getInitialValue();
if (initialValue == null) {
return false;
}
return isSafeValue(var.getScope(), initialValue);
}
return false;
} | [
"private",
"boolean",
"isSafeValue",
"(",
"Scope",
"scope",
",",
"Node",
"argument",
")",
"{",
"if",
"(",
"NodeUtil",
".",
"isSomeCompileTimeConstStringValue",
"(",
"argument",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"argument",
".",
"isAdd",
"(",
")",
")",
"{",
"Node",
"left",
"=",
"argument",
".",
"getFirstChild",
"(",
")",
";",
"Node",
"right",
"=",
"argument",
".",
"getLastChild",
"(",
")",
";",
"return",
"isSafeValue",
"(",
"scope",
",",
"left",
")",
"&&",
"isSafeValue",
"(",
"scope",
",",
"right",
")",
";",
"}",
"else",
"if",
"(",
"argument",
".",
"isName",
"(",
")",
")",
"{",
"String",
"name",
"=",
"argument",
".",
"getString",
"(",
")",
";",
"Var",
"var",
"=",
"scope",
".",
"getVar",
"(",
"name",
")",
";",
"if",
"(",
"var",
"==",
"null",
"||",
"!",
"var",
".",
"isInferredConst",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"Node",
"initialValue",
"=",
"var",
".",
"getInitialValue",
"(",
")",
";",
"if",
"(",
"initialValue",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"isSafeValue",
"(",
"var",
".",
"getScope",
"(",
")",
",",
"initialValue",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Checks if the method call argument is made of constant string literals.
<p>This function argument checker will return true if:
<ol>
<li>The argument is a constant variable assigned from a string literal, or
<li>The argument is an expression that is a string literal, or
<li>The argument is a ternary expression choosing between string literals, or
<li>The argument is a concatenation of the above.
</ol>
@param scope The scope chain to use in name lookups.
@param argument The node of function argument to check. | [
"Checks",
"if",
"the",
"method",
"call",
"argument",
"is",
"made",
"of",
"constant",
"string",
"literals",
"."
]
| train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ConstParamCheck.java#L118-L138 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/loader/WordVectorSerializer.java | WordVectorSerializer.writeWordVectors | @Deprecated
public static void writeWordVectors(ParagraphVectors vectors, OutputStream stream) {
"""
This method saves paragraph vectors to the given output stream.
@param vectors
@param stream
"""
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8))) {
/*
This method acts similary to w2v csv serialization, except of additional tag for labels
*/
VocabCache<VocabWord> vocabCache = vectors.getVocab();
for (VocabWord word : vocabCache.vocabWords()) {
StringBuilder builder = new StringBuilder();
builder.append(word.isLabel() ? "L" : "E").append(" ");
builder.append(word.getLabel().replaceAll(" ", WHITESPACE_REPLACEMENT)).append(" ");
INDArray vector = vectors.getWordVectorMatrix(word.getLabel());
for (int j = 0; j < vector.length(); j++) {
builder.append(vector.getDouble(j));
if (j < vector.length() - 1) {
builder.append(" ");
}
}
writer.write(builder.append("\n").toString());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} | java | @Deprecated
public static void writeWordVectors(ParagraphVectors vectors, OutputStream stream) {
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8))) {
/*
This method acts similary to w2v csv serialization, except of additional tag for labels
*/
VocabCache<VocabWord> vocabCache = vectors.getVocab();
for (VocabWord word : vocabCache.vocabWords()) {
StringBuilder builder = new StringBuilder();
builder.append(word.isLabel() ? "L" : "E").append(" ");
builder.append(word.getLabel().replaceAll(" ", WHITESPACE_REPLACEMENT)).append(" ");
INDArray vector = vectors.getWordVectorMatrix(word.getLabel());
for (int j = 0; j < vector.length(); j++) {
builder.append(vector.getDouble(j));
if (j < vector.length() - 1) {
builder.append(" ");
}
}
writer.write(builder.append("\n").toString());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"writeWordVectors",
"(",
"ParagraphVectors",
"vectors",
",",
"OutputStream",
"stream",
")",
"{",
"try",
"(",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"stream",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
")",
"{",
"/*\n This method acts similary to w2v csv serialization, except of additional tag for labels\n */",
"VocabCache",
"<",
"VocabWord",
">",
"vocabCache",
"=",
"vectors",
".",
"getVocab",
"(",
")",
";",
"for",
"(",
"VocabWord",
"word",
":",
"vocabCache",
".",
"vocabWords",
"(",
")",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"word",
".",
"isLabel",
"(",
")",
"?",
"\"L\"",
":",
"\"E\"",
")",
".",
"append",
"(",
"\" \"",
")",
";",
"builder",
".",
"append",
"(",
"word",
".",
"getLabel",
"(",
")",
".",
"replaceAll",
"(",
"\" \"",
",",
"WHITESPACE_REPLACEMENT",
")",
")",
".",
"append",
"(",
"\" \"",
")",
";",
"INDArray",
"vector",
"=",
"vectors",
".",
"getWordVectorMatrix",
"(",
"word",
".",
"getLabel",
"(",
")",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"vector",
".",
"length",
"(",
")",
";",
"j",
"++",
")",
"{",
"builder",
".",
"append",
"(",
"vector",
".",
"getDouble",
"(",
"j",
")",
")",
";",
"if",
"(",
"j",
"<",
"vector",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"builder",
".",
"append",
"(",
"\" \"",
")",
";",
"}",
"}",
"writer",
".",
"write",
"(",
"builder",
".",
"append",
"(",
"\"\\n\"",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
]
| This method saves paragraph vectors to the given output stream.
@param vectors
@param stream | [
"This",
"method",
"saves",
"paragraph",
"vectors",
"to",
"the",
"given",
"output",
"stream",
"."
]
| train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/loader/WordVectorSerializer.java#L1155-L1182 |
DataArt/CalculationEngine | calculation-engine/engine-converters/src/main/java/com/dataart/spreadsheetanalytics/engine/DependencyExtractors.java | DependencyExtractors.createAttributeFunctionMeta | static <T extends FunctionMeta> T createAttributeFunctionMeta(Class<T> metaClass, String formula, IDataModel model) throws Exception {
"""
Create an instance of new {@link FunctionMeta} and fills it with minimum information.
"""
T meta = (T) metaClass.newInstance().parse(formula);
meta.setDataModelId(model.getDataModelId());
if (meta.getName() == null) { meta.setName(model.getName()); }
return meta;
} | java | static <T extends FunctionMeta> T createAttributeFunctionMeta(Class<T> metaClass, String formula, IDataModel model) throws Exception {
T meta = (T) metaClass.newInstance().parse(formula);
meta.setDataModelId(model.getDataModelId());
if (meta.getName() == null) { meta.setName(model.getName()); }
return meta;
} | [
"static",
"<",
"T",
"extends",
"FunctionMeta",
">",
"T",
"createAttributeFunctionMeta",
"(",
"Class",
"<",
"T",
">",
"metaClass",
",",
"String",
"formula",
",",
"IDataModel",
"model",
")",
"throws",
"Exception",
"{",
"T",
"meta",
"=",
"(",
"T",
")",
"metaClass",
".",
"newInstance",
"(",
")",
".",
"parse",
"(",
"formula",
")",
";",
"meta",
".",
"setDataModelId",
"(",
"model",
".",
"getDataModelId",
"(",
")",
")",
";",
"if",
"(",
"meta",
".",
"getName",
"(",
")",
"==",
"null",
")",
"{",
"meta",
".",
"setName",
"(",
"model",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"meta",
";",
"}"
]
| Create an instance of new {@link FunctionMeta} and fills it with minimum information. | [
"Create",
"an",
"instance",
"of",
"new",
"{"
]
| train | https://github.com/DataArt/CalculationEngine/blob/34ce1d9c1f9b57a502906b274311d28580b134e5/calculation-engine/engine-converters/src/main/java/com/dataart/spreadsheetanalytics/engine/DependencyExtractors.java#L210-L216 |
VoltDB/voltdb | src/frontend/org/voltdb/rejoin/TaskLogImpl.java | TaskLogImpl.bufferCatchup | private void bufferCatchup(int messageSize) throws IOException {
"""
The buffers are bound by the number of tasks in them. Once the current
buffer has enough tasks, it will be queued and a new buffer will be
created.
@throws IOException
"""
// If the current buffer has too many tasks logged, queue it and
// create a new one.
if (m_tail != null && m_tail.size() > 0 && messageSize > m_bufferHeadroom) {
// compile the invocation buffer
m_tail.compile();
final RejoinTaskBuffer boundTail = m_tail;
final Runnable r = new Runnable() {
@Override
public void run() {
try {
m_buffers.offer(boundTail.getContainer());
if (m_reader.sizeInBytes() > m_overflowLimit * 1024 * 1024) {
// we can never catch up, should break rejoin.
VoltDB.crashLocalVoltDB("On-disk task log is full. Please reduce " +
"workload and try live rejoin again, or use blocking rejoin.");
}
} catch (Throwable t) {
VoltDB.crashLocalVoltDB("Error in task log buffering transactions", true, t);
}
}
};
m_es.execute(r);
// Reset
m_tail = null;
m_tasksPendingInCurrentTail = 0;
}
// create a new buffer
if (m_tail == null) {
m_tail = new RejoinTaskBuffer(m_partitionId, messageSize);
m_bufferHeadroom = RejoinTaskBuffer.DEFAULT_BUFFER_SIZE;
}
} | java | private void bufferCatchup(int messageSize) throws IOException {
// If the current buffer has too many tasks logged, queue it and
// create a new one.
if (m_tail != null && m_tail.size() > 0 && messageSize > m_bufferHeadroom) {
// compile the invocation buffer
m_tail.compile();
final RejoinTaskBuffer boundTail = m_tail;
final Runnable r = new Runnable() {
@Override
public void run() {
try {
m_buffers.offer(boundTail.getContainer());
if (m_reader.sizeInBytes() > m_overflowLimit * 1024 * 1024) {
// we can never catch up, should break rejoin.
VoltDB.crashLocalVoltDB("On-disk task log is full. Please reduce " +
"workload and try live rejoin again, or use blocking rejoin.");
}
} catch (Throwable t) {
VoltDB.crashLocalVoltDB("Error in task log buffering transactions", true, t);
}
}
};
m_es.execute(r);
// Reset
m_tail = null;
m_tasksPendingInCurrentTail = 0;
}
// create a new buffer
if (m_tail == null) {
m_tail = new RejoinTaskBuffer(m_partitionId, messageSize);
m_bufferHeadroom = RejoinTaskBuffer.DEFAULT_BUFFER_SIZE;
}
} | [
"private",
"void",
"bufferCatchup",
"(",
"int",
"messageSize",
")",
"throws",
"IOException",
"{",
"// If the current buffer has too many tasks logged, queue it and",
"// create a new one.",
"if",
"(",
"m_tail",
"!=",
"null",
"&&",
"m_tail",
".",
"size",
"(",
")",
">",
"0",
"&&",
"messageSize",
">",
"m_bufferHeadroom",
")",
"{",
"// compile the invocation buffer",
"m_tail",
".",
"compile",
"(",
")",
";",
"final",
"RejoinTaskBuffer",
"boundTail",
"=",
"m_tail",
";",
"final",
"Runnable",
"r",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"m_buffers",
".",
"offer",
"(",
"boundTail",
".",
"getContainer",
"(",
")",
")",
";",
"if",
"(",
"m_reader",
".",
"sizeInBytes",
"(",
")",
">",
"m_overflowLimit",
"*",
"1024",
"*",
"1024",
")",
"{",
"// we can never catch up, should break rejoin.",
"VoltDB",
".",
"crashLocalVoltDB",
"(",
"\"On-disk task log is full. Please reduce \"",
"+",
"\"workload and try live rejoin again, or use blocking rejoin.\"",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"VoltDB",
".",
"crashLocalVoltDB",
"(",
"\"Error in task log buffering transactions\"",
",",
"true",
",",
"t",
")",
";",
"}",
"}",
"}",
";",
"m_es",
".",
"execute",
"(",
"r",
")",
";",
"// Reset",
"m_tail",
"=",
"null",
";",
"m_tasksPendingInCurrentTail",
"=",
"0",
";",
"}",
"// create a new buffer",
"if",
"(",
"m_tail",
"==",
"null",
")",
"{",
"m_tail",
"=",
"new",
"RejoinTaskBuffer",
"(",
"m_partitionId",
",",
"messageSize",
")",
";",
"m_bufferHeadroom",
"=",
"RejoinTaskBuffer",
".",
"DEFAULT_BUFFER_SIZE",
";",
"}",
"}"
]
| The buffers are bound by the number of tasks in them. Once the current
buffer has enough tasks, it will be queued and a new buffer will be
created.
@throws IOException | [
"The",
"buffers",
"are",
"bound",
"by",
"the",
"number",
"of",
"tasks",
"in",
"them",
".",
"Once",
"the",
"current",
"buffer",
"has",
"enough",
"tasks",
"it",
"will",
"be",
"queued",
"and",
"a",
"new",
"buffer",
"will",
"be",
"created",
"."
]
| train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/rejoin/TaskLogImpl.java#L94-L130 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/rowio/RowInputBinary.java | RowInputBinary.resetRow | public void resetRow(int filepos, int rowsize) throws IOException {
"""
Used to reset the row, ready for a new db row to be written into the
byte[] buffer by an external routine.
"""
if (out != null) {
out.reset(rowsize);
buf = out.getBuffer();
}
super.resetRow(filepos, rowsize);
} | java | public void resetRow(int filepos, int rowsize) throws IOException {
if (out != null) {
out.reset(rowsize);
buf = out.getBuffer();
}
super.resetRow(filepos, rowsize);
} | [
"public",
"void",
"resetRow",
"(",
"int",
"filepos",
",",
"int",
"rowsize",
")",
"throws",
"IOException",
"{",
"if",
"(",
"out",
"!=",
"null",
")",
"{",
"out",
".",
"reset",
"(",
"rowsize",
")",
";",
"buf",
"=",
"out",
".",
"getBuffer",
"(",
")",
";",
"}",
"super",
".",
"resetRow",
"(",
"filepos",
",",
"rowsize",
")",
";",
"}"
]
| Used to reset the row, ready for a new db row to be written into the
byte[] buffer by an external routine. | [
"Used",
"to",
"reset",
"the",
"row",
"ready",
"for",
"a",
"new",
"db",
"row",
"to",
"be",
"written",
"into",
"the",
"byte",
"[]",
"buffer",
"by",
"an",
"external",
"routine",
"."
]
| train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/rowio/RowInputBinary.java#L271-L280 |
landawn/AbacusUtil | src/com/landawn/abacus/util/LongMultiset.java | LongMultiset.removeAll | public boolean removeAll(final Collection<?> c, final long occurrences) {
"""
Remove the specified occurrences from the specified elements.
The elements will be removed from this set if the occurrences equals to or less than 0 after the operation.
@param c
@param occurrences
the occurrences to remove if the element is in the specified collection <code>c</code>.
@return <tt>true</tt> if this set changed as a result of the call
"""
checkOccurrences(occurrences);
if (N.isNullOrEmpty(c) || occurrences == 0) {
return false;
}
boolean result = false;
for (Object e : c) {
if (result == false) {
result = remove(e, occurrences);
} else {
remove(e, occurrences);
}
}
return result;
} | java | public boolean removeAll(final Collection<?> c, final long occurrences) {
checkOccurrences(occurrences);
if (N.isNullOrEmpty(c) || occurrences == 0) {
return false;
}
boolean result = false;
for (Object e : c) {
if (result == false) {
result = remove(e, occurrences);
} else {
remove(e, occurrences);
}
}
return result;
} | [
"public",
"boolean",
"removeAll",
"(",
"final",
"Collection",
"<",
"?",
">",
"c",
",",
"final",
"long",
"occurrences",
")",
"{",
"checkOccurrences",
"(",
"occurrences",
")",
";",
"if",
"(",
"N",
".",
"isNullOrEmpty",
"(",
"c",
")",
"||",
"occurrences",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"boolean",
"result",
"=",
"false",
";",
"for",
"(",
"Object",
"e",
":",
"c",
")",
"{",
"if",
"(",
"result",
"==",
"false",
")",
"{",
"result",
"=",
"remove",
"(",
"e",
",",
"occurrences",
")",
";",
"}",
"else",
"{",
"remove",
"(",
"e",
",",
"occurrences",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
]
| Remove the specified occurrences from the specified elements.
The elements will be removed from this set if the occurrences equals to or less than 0 after the operation.
@param c
@param occurrences
the occurrences to remove if the element is in the specified collection <code>c</code>.
@return <tt>true</tt> if this set changed as a result of the call | [
"Remove",
"the",
"specified",
"occurrences",
"from",
"the",
"specified",
"elements",
".",
"The",
"elements",
"will",
"be",
"removed",
"from",
"this",
"set",
"if",
"the",
"occurrences",
"equals",
"to",
"or",
"less",
"than",
"0",
"after",
"the",
"operation",
"."
]
| train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/LongMultiset.java#L873-L891 |
moparisthebest/beehive | beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/FormatTag.java | FormatTag.getLocale | public Locale getLocale()
throws JspException {
"""
Returns the locale based on the country and language.
@return the locale
"""
Locale loc = null;
if (_language != null || _country != null) {
// language is required
if (_language == null) {
String s = Bundle.getString("Tags_LocaleRequiresLanguage", new Object[]{_country});
registerTagError(s, null);
return super.getUserLocale();
}
if (_country == null)
loc = new Locale(_language);
else
loc = new Locale(_language, _country);
}
else
loc = super.getUserLocale();
return loc;
} | java | public Locale getLocale()
throws JspException
{
Locale loc = null;
if (_language != null || _country != null) {
// language is required
if (_language == null) {
String s = Bundle.getString("Tags_LocaleRequiresLanguage", new Object[]{_country});
registerTagError(s, null);
return super.getUserLocale();
}
if (_country == null)
loc = new Locale(_language);
else
loc = new Locale(_language, _country);
}
else
loc = super.getUserLocale();
return loc;
} | [
"public",
"Locale",
"getLocale",
"(",
")",
"throws",
"JspException",
"{",
"Locale",
"loc",
"=",
"null",
";",
"if",
"(",
"_language",
"!=",
"null",
"||",
"_country",
"!=",
"null",
")",
"{",
"// language is required",
"if",
"(",
"_language",
"==",
"null",
")",
"{",
"String",
"s",
"=",
"Bundle",
".",
"getString",
"(",
"\"Tags_LocaleRequiresLanguage\"",
",",
"new",
"Object",
"[",
"]",
"{",
"_country",
"}",
")",
";",
"registerTagError",
"(",
"s",
",",
"null",
")",
";",
"return",
"super",
".",
"getUserLocale",
"(",
")",
";",
"}",
"if",
"(",
"_country",
"==",
"null",
")",
"loc",
"=",
"new",
"Locale",
"(",
"_language",
")",
";",
"else",
"loc",
"=",
"new",
"Locale",
"(",
"_language",
",",
"_country",
")",
";",
"}",
"else",
"loc",
"=",
"super",
".",
"getUserLocale",
"(",
")",
";",
"return",
"loc",
";",
"}"
]
| Returns the locale based on the country and language.
@return the locale | [
"Returns",
"the",
"locale",
"based",
"on",
"the",
"country",
"and",
"language",
"."
]
| train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/FormatTag.java#L69-L90 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/interceptor/action/ActionInterceptorContext.java | ActionInterceptorContext.setOverrideForward | public void setOverrideForward( InterceptorForward fwd, ActionInterceptor interceptor ) {
"""
Set an {@link InterceptorForward} that changes the destination URI of the intercepted action. If the
InterceptorForward points to a nested page flow, then {@link ActionInterceptor#afterNestedIntercept} will be
called before the nested page flow returns to the original page flow.
"""
setResultOverride( fwd, interceptor );
//
// If there was no original forward (i.e., this is happening before the action was invoked), create a
// pseudo-forward out of the original request.
//
if ( _originalForward == null ) _originalForward = new OriginalForward( getRequest() );
//
// Store this context in the request.
//
getRequest().setAttribute( ACTIVE_INTERCEPTOR_CONTEXT_ATTR, this );
} | java | public void setOverrideForward( InterceptorForward fwd, ActionInterceptor interceptor )
{
setResultOverride( fwd, interceptor );
//
// If there was no original forward (i.e., this is happening before the action was invoked), create a
// pseudo-forward out of the original request.
//
if ( _originalForward == null ) _originalForward = new OriginalForward( getRequest() );
//
// Store this context in the request.
//
getRequest().setAttribute( ACTIVE_INTERCEPTOR_CONTEXT_ATTR, this );
} | [
"public",
"void",
"setOverrideForward",
"(",
"InterceptorForward",
"fwd",
",",
"ActionInterceptor",
"interceptor",
")",
"{",
"setResultOverride",
"(",
"fwd",
",",
"interceptor",
")",
";",
"//",
"// If there was no original forward (i.e., this is happening before the action was invoked), create a",
"// pseudo-forward out of the original request.",
"//",
"if",
"(",
"_originalForward",
"==",
"null",
")",
"_originalForward",
"=",
"new",
"OriginalForward",
"(",
"getRequest",
"(",
")",
")",
";",
"//",
"// Store this context in the request.",
"//",
"getRequest",
"(",
")",
".",
"setAttribute",
"(",
"ACTIVE_INTERCEPTOR_CONTEXT_ATTR",
",",
"this",
")",
";",
"}"
]
| Set an {@link InterceptorForward} that changes the destination URI of the intercepted action. If the
InterceptorForward points to a nested page flow, then {@link ActionInterceptor#afterNestedIntercept} will be
called before the nested page flow returns to the original page flow. | [
"Set",
"an",
"{"
]
| train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/interceptor/action/ActionInterceptorContext.java#L97-L111 |
FINRAOS/JTAF-ExtWebDriver | src/main/java/org/finra/jtaf/ewd/properties/GUIHierarchyConcatenationProperties.java | GUIHierarchyConcatenationProperties.getPropertyValue | public String getPropertyValue(String key, Object[] parameters) {
"""
Searches over the group of {@code GUIProperties} for a property
corresponding to the given key.
@param key
key to be found
@param parameters
instances of the {@code String} literal <code>"{n}"</code> in
the retrieved value will be replaced by the {@code String}
representation of {@code params[n]}
@return the first property found associated with a concatenation of the
given names
@throws MissingGUIPropertyException
"""
if (parameters != null && parameters.length > 0) {
String parameters2[] = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) {
Object parameter = parameters[i];
if (parameter != null) {
parameters2[i] = String.valueOf(parameter);
}
}
return getPropertyValue(new String[] { key }, parameters2);
} else {
return getPropertyValue(key);
}
} | java | public String getPropertyValue(String key, Object[] parameters) {
if (parameters != null && parameters.length > 0) {
String parameters2[] = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) {
Object parameter = parameters[i];
if (parameter != null) {
parameters2[i] = String.valueOf(parameter);
}
}
return getPropertyValue(new String[] { key }, parameters2);
} else {
return getPropertyValue(key);
}
} | [
"public",
"String",
"getPropertyValue",
"(",
"String",
"key",
",",
"Object",
"[",
"]",
"parameters",
")",
"{",
"if",
"(",
"parameters",
"!=",
"null",
"&&",
"parameters",
".",
"length",
">",
"0",
")",
"{",
"String",
"parameters2",
"[",
"]",
"=",
"new",
"String",
"[",
"parameters",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parameters",
".",
"length",
";",
"i",
"++",
")",
"{",
"Object",
"parameter",
"=",
"parameters",
"[",
"i",
"]",
";",
"if",
"(",
"parameter",
"!=",
"null",
")",
"{",
"parameters2",
"[",
"i",
"]",
"=",
"String",
".",
"valueOf",
"(",
"parameter",
")",
";",
"}",
"}",
"return",
"getPropertyValue",
"(",
"new",
"String",
"[",
"]",
"{",
"key",
"}",
",",
"parameters2",
")",
";",
"}",
"else",
"{",
"return",
"getPropertyValue",
"(",
"key",
")",
";",
"}",
"}"
]
| Searches over the group of {@code GUIProperties} for a property
corresponding to the given key.
@param key
key to be found
@param parameters
instances of the {@code String} literal <code>"{n}"</code> in
the retrieved value will be replaced by the {@code String}
representation of {@code params[n]}
@return the first property found associated with a concatenation of the
given names
@throws MissingGUIPropertyException | [
"Searches",
"over",
"the",
"group",
"of",
"{",
"@code",
"GUIProperties",
"}",
"for",
"a",
"property",
"corresponding",
"to",
"the",
"given",
"key",
"."
]
| train | https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/properties/GUIHierarchyConcatenationProperties.java#L272-L285 |
ReactiveX/RxJavaAsyncUtil | src/main/java/rx/util/async/Async.java | Async.toAsync | public static FuncN<Observable<Void>> toAsync(ActionN action) {
"""
Convert a synchronous action call into an asynchronous function call through an Observable.
<p>
<img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toAsync.an.png" alt="">
@param action the action to convert
@return a function that returns an Observable that executes the {@code action} and emits {@code null}
@see <a href="https://github.com/ReactiveX/RxJava/wiki/Async-Operators#wiki-toasync-or-asyncaction-or-asyncfunc">RxJava Wiki: toAsync()</a>
"""
return toAsync(action, Schedulers.computation());
} | java | public static FuncN<Observable<Void>> toAsync(ActionN action) {
return toAsync(action, Schedulers.computation());
} | [
"public",
"static",
"FuncN",
"<",
"Observable",
"<",
"Void",
">",
">",
"toAsync",
"(",
"ActionN",
"action",
")",
"{",
"return",
"toAsync",
"(",
"action",
",",
"Schedulers",
".",
"computation",
"(",
")",
")",
";",
"}"
]
| Convert a synchronous action call into an asynchronous function call through an Observable.
<p>
<img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toAsync.an.png" alt="">
@param action the action to convert
@return a function that returns an Observable that executes the {@code action} and emits {@code null}
@see <a href="https://github.com/ReactiveX/RxJava/wiki/Async-Operators#wiki-toasync-or-asyncaction-or-asyncfunc">RxJava Wiki: toAsync()</a> | [
"Convert",
"a",
"synchronous",
"action",
"call",
"into",
"an",
"asynchronous",
"function",
"call",
"through",
"an",
"Observable",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"src",
"=",
"https",
":",
"//",
"raw",
".",
"github",
".",
"com",
"/",
"wiki",
"/",
"ReactiveX",
"/",
"RxJava",
"/",
"images",
"/",
"rx",
"-",
"operators",
"/",
"toAsync",
".",
"an",
".",
"png",
"alt",
"=",
">"
]
| train | https://github.com/ReactiveX/RxJavaAsyncUtil/blob/6294e1da30e639df79f76399906229314c14e74d/src/main/java/rx/util/async/Async.java#L720-L722 |
authlete/authlete-java-common | src/main/java/com/authlete/common/api/AuthleteApiException.java | AuthleteApiException.setResponse | private void setResponse(int statusCode, String statusMessage, String responseBody, Map<String, List<String>> responseHeaders) {
"""
Set the data fields related to HTTP response information.
@param statusCode
HTTP status code.
@param statusMessage
HTTP status message.
@param responseBody
HTTP response body.
"""
mStatusCode = statusCode;
mStatusMessage = statusMessage;
mResponseBody = responseBody;
mResponseHeaders = responseHeaders;
} | java | private void setResponse(int statusCode, String statusMessage, String responseBody, Map<String, List<String>> responseHeaders)
{
mStatusCode = statusCode;
mStatusMessage = statusMessage;
mResponseBody = responseBody;
mResponseHeaders = responseHeaders;
} | [
"private",
"void",
"setResponse",
"(",
"int",
"statusCode",
",",
"String",
"statusMessage",
",",
"String",
"responseBody",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"responseHeaders",
")",
"{",
"mStatusCode",
"=",
"statusCode",
";",
"mStatusMessage",
"=",
"statusMessage",
";",
"mResponseBody",
"=",
"responseBody",
";",
"mResponseHeaders",
"=",
"responseHeaders",
";",
"}"
]
| Set the data fields related to HTTP response information.
@param statusCode
HTTP status code.
@param statusMessage
HTTP status message.
@param responseBody
HTTP response body. | [
"Set",
"the",
"data",
"fields",
"related",
"to",
"HTTP",
"response",
"information",
"."
]
| train | https://github.com/authlete/authlete-java-common/blob/49c94c483713cbf5a04d805ff7dbd83766c9c964/src/main/java/com/authlete/common/api/AuthleteApiException.java#L293-L299 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java | ProcessGroovyMethods.pipeTo | public static Process pipeTo(final Process left, final Process right) throws IOException {
"""
Allows one Process to asynchronously pipe data to another Process.
@param left a Process instance
@param right a Process to pipe output to
@return the second Process to allow chaining
@throws java.io.IOException if an IOException occurs.
@since 1.5.2
"""
new Thread(new Runnable() {
public void run() {
InputStream in = new BufferedInputStream(getIn(left));
OutputStream out = new BufferedOutputStream(getOut(right));
byte[] buf = new byte[8192];
int next;
try {
while ((next = in.read(buf)) != -1) {
out.write(buf, 0, next);
}
} catch (IOException e) {
throw new GroovyRuntimeException("exception while reading process stream", e);
} finally {
closeWithWarning(out);
closeWithWarning(in);
}
}
}).start();
return right;
} | java | public static Process pipeTo(final Process left, final Process right) throws IOException {
new Thread(new Runnable() {
public void run() {
InputStream in = new BufferedInputStream(getIn(left));
OutputStream out = new BufferedOutputStream(getOut(right));
byte[] buf = new byte[8192];
int next;
try {
while ((next = in.read(buf)) != -1) {
out.write(buf, 0, next);
}
} catch (IOException e) {
throw new GroovyRuntimeException("exception while reading process stream", e);
} finally {
closeWithWarning(out);
closeWithWarning(in);
}
}
}).start();
return right;
} | [
"public",
"static",
"Process",
"pipeTo",
"(",
"final",
"Process",
"left",
",",
"final",
"Process",
"right",
")",
"throws",
"IOException",
"{",
"new",
"Thread",
"(",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"InputStream",
"in",
"=",
"new",
"BufferedInputStream",
"(",
"getIn",
"(",
"left",
")",
")",
";",
"OutputStream",
"out",
"=",
"new",
"BufferedOutputStream",
"(",
"getOut",
"(",
"right",
")",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"8192",
"]",
";",
"int",
"next",
";",
"try",
"{",
"while",
"(",
"(",
"next",
"=",
"in",
".",
"read",
"(",
"buf",
")",
")",
"!=",
"-",
"1",
")",
"{",
"out",
".",
"write",
"(",
"buf",
",",
"0",
",",
"next",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"GroovyRuntimeException",
"(",
"\"exception while reading process stream\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"closeWithWarning",
"(",
"out",
")",
";",
"closeWithWarning",
"(",
"in",
")",
";",
"}",
"}",
"}",
")",
".",
"start",
"(",
")",
";",
"return",
"right",
";",
"}"
]
| Allows one Process to asynchronously pipe data to another Process.
@param left a Process instance
@param right a Process to pipe output to
@return the second Process to allow chaining
@throws java.io.IOException if an IOException occurs.
@since 1.5.2 | [
"Allows",
"one",
"Process",
"to",
"asynchronously",
"pipe",
"data",
"to",
"another",
"Process",
"."
]
| train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L393-L413 |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/SATSolver.java | SATSolver.addWithRelaxation | public void addWithRelaxation(final Variable relaxationVar, final Collection<? extends Formula> formulas) {
"""
Adds a collection of formulas to the solver.
@param relaxationVar the relaxation variable
@param formulas the collection of formulas
"""
for (final Formula formula : formulas) { this.addWithRelaxation(relaxationVar, formula); }
} | java | public void addWithRelaxation(final Variable relaxationVar, final Collection<? extends Formula> formulas) {
for (final Formula formula : formulas) { this.addWithRelaxation(relaxationVar, formula); }
} | [
"public",
"void",
"addWithRelaxation",
"(",
"final",
"Variable",
"relaxationVar",
",",
"final",
"Collection",
"<",
"?",
"extends",
"Formula",
">",
"formulas",
")",
"{",
"for",
"(",
"final",
"Formula",
"formula",
":",
"formulas",
")",
"{",
"this",
".",
"addWithRelaxation",
"(",
"relaxationVar",
",",
"formula",
")",
";",
"}",
"}"
]
| Adds a collection of formulas to the solver.
@param relaxationVar the relaxation variable
@param formulas the collection of formulas | [
"Adds",
"a",
"collection",
"of",
"formulas",
"to",
"the",
"solver",
"."
]
| train | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/SATSolver.java#L161-L163 |
luuuis/jcalendar | src/main/java/com/toedter/calendar/JDateChooser.java | JDateChooser.setSelectableDateRange | public void setSelectableDateRange(Date min, Date max) {
"""
Sets a valid date range for selectable dates. If max is before min, the
default range with no limitation is set.
@param min
the minimum selectable date or null (then the minimum date is
set to 01\01\0001)
@param max
the maximum selectable date or null (then the maximum date is
set to 01\01\9999)
"""
jcalendar.setSelectableDateRange(min, max);
dateEditor.setSelectableDateRange(jcalendar.getMinSelectableDate(),
jcalendar.getMaxSelectableDate());
} | java | public void setSelectableDateRange(Date min, Date max) {
jcalendar.setSelectableDateRange(min, max);
dateEditor.setSelectableDateRange(jcalendar.getMinSelectableDate(),
jcalendar.getMaxSelectableDate());
} | [
"public",
"void",
"setSelectableDateRange",
"(",
"Date",
"min",
",",
"Date",
"max",
")",
"{",
"jcalendar",
".",
"setSelectableDateRange",
"(",
"min",
",",
"max",
")",
";",
"dateEditor",
".",
"setSelectableDateRange",
"(",
"jcalendar",
".",
"getMinSelectableDate",
"(",
")",
",",
"jcalendar",
".",
"getMaxSelectableDate",
"(",
")",
")",
";",
"}"
]
| Sets a valid date range for selectable dates. If max is before min, the
default range with no limitation is set.
@param min
the minimum selectable date or null (then the minimum date is
set to 01\01\0001)
@param max
the maximum selectable date or null (then the maximum date is
set to 01\01\9999) | [
"Sets",
"a",
"valid",
"date",
"range",
"for",
"selectable",
"dates",
".",
"If",
"max",
"is",
"before",
"min",
"the",
"default",
"range",
"with",
"no",
"limitation",
"is",
"set",
"."
]
| train | https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDateChooser.java#L512-L516 |
jenkinsci/ghprb-plugin | src/main/java/org/jenkinsci/plugins/ghprb/GhprbPullRequest.java | GhprbPullRequest.containsComment | private boolean containsComment(GHPullRequest ghPullRequest, String expectedBody) {
"""
Checks whether the specific PR contains a comment with the expected body.
@return true if the PR contains comment with the specified body, otherwise false
"""
List<GHIssueComment> prComments;
try {
prComments = ghPullRequest.getComments();
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to get comments for PR " + ghPullRequest, e);
// return false in case of an error - probably safer to have multiple comments than possibly none
return false;
}
for (GHIssueComment comment : prComments) {
if (comment.getBody() != null && comment.getBody().equals(expectedBody)) {
return true;
}
}
return false;
} | java | private boolean containsComment(GHPullRequest ghPullRequest, String expectedBody) {
List<GHIssueComment> prComments;
try {
prComments = ghPullRequest.getComments();
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to get comments for PR " + ghPullRequest, e);
// return false in case of an error - probably safer to have multiple comments than possibly none
return false;
}
for (GHIssueComment comment : prComments) {
if (comment.getBody() != null && comment.getBody().equals(expectedBody)) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"containsComment",
"(",
"GHPullRequest",
"ghPullRequest",
",",
"String",
"expectedBody",
")",
"{",
"List",
"<",
"GHIssueComment",
">",
"prComments",
";",
"try",
"{",
"prComments",
"=",
"ghPullRequest",
".",
"getComments",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Failed to get comments for PR \"",
"+",
"ghPullRequest",
",",
"e",
")",
";",
"// return false in case of an error - probably safer to have multiple comments than possibly none",
"return",
"false",
";",
"}",
"for",
"(",
"GHIssueComment",
"comment",
":",
"prComments",
")",
"{",
"if",
"(",
"comment",
".",
"getBody",
"(",
")",
"!=",
"null",
"&&",
"comment",
".",
"getBody",
"(",
")",
".",
"equals",
"(",
"expectedBody",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Checks whether the specific PR contains a comment with the expected body.
@return true if the PR contains comment with the specified body, otherwise false | [
"Checks",
"whether",
"the",
"specific",
"PR",
"contains",
"a",
"comment",
"with",
"the",
"expected",
"body",
"."
]
| train | https://github.com/jenkinsci/ghprb-plugin/blob/b972d3b94ebbe6d40542c2771407e297bff8430b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbPullRequest.java#L185-L200 |
pedrovgs/Renderers | renderers/src/main/java/com/pedrogomez/renderers/RendererBuilder.java | RendererBuilder.createRenderer | private Renderer createRenderer(T content, ViewGroup parent) {
"""
Create a Renderer getting a copy from the prototypes collection.
@param content to render.
@param parent used to inflate the view.
@return a new renderer.
"""
int prototypeIndex = getPrototypeIndex(content);
Renderer renderer = getPrototypeByIndex(prototypeIndex).copy();
renderer.onCreate(content, layoutInflater, parent);
return renderer;
} | java | private Renderer createRenderer(T content, ViewGroup parent) {
int prototypeIndex = getPrototypeIndex(content);
Renderer renderer = getPrototypeByIndex(prototypeIndex).copy();
renderer.onCreate(content, layoutInflater, parent);
return renderer;
} | [
"private",
"Renderer",
"createRenderer",
"(",
"T",
"content",
",",
"ViewGroup",
"parent",
")",
"{",
"int",
"prototypeIndex",
"=",
"getPrototypeIndex",
"(",
"content",
")",
";",
"Renderer",
"renderer",
"=",
"getPrototypeByIndex",
"(",
"prototypeIndex",
")",
".",
"copy",
"(",
")",
";",
"renderer",
".",
"onCreate",
"(",
"content",
",",
"layoutInflater",
",",
"parent",
")",
";",
"return",
"renderer",
";",
"}"
]
| Create a Renderer getting a copy from the prototypes collection.
@param content to render.
@param parent used to inflate the view.
@return a new renderer. | [
"Create",
"a",
"Renderer",
"getting",
"a",
"copy",
"from",
"the",
"prototypes",
"collection",
"."
]
| train | https://github.com/pedrovgs/Renderers/blob/7477fb6e3984468b32b59c8520b66afb765081ea/renderers/src/main/java/com/pedrogomez/renderers/RendererBuilder.java#L279-L284 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/NetworkSecurityGroupsInner.java | NetworkSecurityGroupsInner.updateTags | public NetworkSecurityGroupInner updateTags(String resourceGroupName, String networkSecurityGroupName, Map<String, String> tags) {
"""
Updates a network security group tags.
@param resourceGroupName The name of the resource group.
@param networkSecurityGroupName The name of the network security group.
@param tags Resource tags.
@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 NetworkSecurityGroupInner object if successful.
"""
return updateTagsWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, tags).toBlocking().last().body();
} | java | public NetworkSecurityGroupInner updateTags(String resourceGroupName, String networkSecurityGroupName, Map<String, String> tags) {
return updateTagsWithServiceResponseAsync(resourceGroupName, networkSecurityGroupName, tags).toBlocking().last().body();
} | [
"public",
"NetworkSecurityGroupInner",
"updateTags",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkSecurityGroupName",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"updateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"networkSecurityGroupName",
",",
"tags",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
]
| Updates a network security group tags.
@param resourceGroupName The name of the resource group.
@param networkSecurityGroupName The name of the network security group.
@param tags Resource tags.
@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 NetworkSecurityGroupInner object if successful. | [
"Updates",
"a",
"network",
"security",
"group",
"tags",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/NetworkSecurityGroupsInner.java#L681-L683 |
osmdroid/osmdroid | osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/TileWriter.java | TileWriter.isSymbolicDirectoryLink | private boolean isSymbolicDirectoryLink(final File pParentDirectory, final File pDirectory) {
"""
Checks to see if it appears that a directory is a symbolic link. It does this by comparing
the canonical path of the parent directory and the parent directory of the directory's
canonical path. If they are equal, then they come from the same true parent. If not, then
pDirectory is a symbolic link. If we get an exception, we err on the side of caution and
return "true" expecting the calculateDirectorySize to now skip further processing since
something went goofy.
"""
try {
final String canonicalParentPath1 = pParentDirectory.getCanonicalPath();
final String canonicalParentPath2 = pDirectory.getCanonicalFile().getParent();
return !canonicalParentPath1.equals(canonicalParentPath2);
} catch (final IOException e) {
return true;
} catch (final NoSuchElementException e) {
// See: http://code.google.com/p/android/issues/detail?id=4961
// See: http://code.google.com/p/android/issues/detail?id=5807
return true;
}
} | java | private boolean isSymbolicDirectoryLink(final File pParentDirectory, final File pDirectory) {
try {
final String canonicalParentPath1 = pParentDirectory.getCanonicalPath();
final String canonicalParentPath2 = pDirectory.getCanonicalFile().getParent();
return !canonicalParentPath1.equals(canonicalParentPath2);
} catch (final IOException e) {
return true;
} catch (final NoSuchElementException e) {
// See: http://code.google.com/p/android/issues/detail?id=4961
// See: http://code.google.com/p/android/issues/detail?id=5807
return true;
}
} | [
"private",
"boolean",
"isSymbolicDirectoryLink",
"(",
"final",
"File",
"pParentDirectory",
",",
"final",
"File",
"pDirectory",
")",
"{",
"try",
"{",
"final",
"String",
"canonicalParentPath1",
"=",
"pParentDirectory",
".",
"getCanonicalPath",
"(",
")",
";",
"final",
"String",
"canonicalParentPath2",
"=",
"pDirectory",
".",
"getCanonicalFile",
"(",
")",
".",
"getParent",
"(",
")",
";",
"return",
"!",
"canonicalParentPath1",
".",
"equals",
"(",
"canonicalParentPath2",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"return",
"true",
";",
"}",
"catch",
"(",
"final",
"NoSuchElementException",
"e",
")",
"{",
"// See: http://code.google.com/p/android/issues/detail?id=4961",
"// See: http://code.google.com/p/android/issues/detail?id=5807",
"return",
"true",
";",
"}",
"}"
]
| Checks to see if it appears that a directory is a symbolic link. It does this by comparing
the canonical path of the parent directory and the parent directory of the directory's
canonical path. If they are equal, then they come from the same true parent. If not, then
pDirectory is a symbolic link. If we get an exception, we err on the side of caution and
return "true" expecting the calculateDirectorySize to now skip further processing since
something went goofy. | [
"Checks",
"to",
"see",
"if",
"it",
"appears",
"that",
"a",
"directory",
"is",
"a",
"symbolic",
"link",
".",
"It",
"does",
"this",
"by",
"comparing",
"the",
"canonical",
"path",
"of",
"the",
"parent",
"directory",
"and",
"the",
"parent",
"directory",
"of",
"the",
"directory",
"s",
"canonical",
"path",
".",
"If",
"they",
"are",
"equal",
"then",
"they",
"come",
"from",
"the",
"same",
"true",
"parent",
".",
"If",
"not",
"then",
"pDirectory",
"is",
"a",
"symbolic",
"link",
".",
"If",
"we",
"get",
"an",
"exception",
"we",
"err",
"on",
"the",
"side",
"of",
"caution",
"and",
"return",
"true",
"expecting",
"the",
"calculateDirectorySize",
"to",
"now",
"skip",
"further",
"processing",
"since",
"something",
"went",
"goofy",
"."
]
| train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/TileWriter.java#L229-L242 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/cpnl/CpnlElFunctions.java | CpnlElFunctions.getFormatter | public static Format getFormatter(@Nonnull final Locale locale, @Nonnull final String format,
@Nullable final Class<?>... type) {
"""
Creates the formatter for a describing string rule
@param locale the local to use for formatting
@param format the format string rule
@param type the optional value type
@return the Format instance
"""
Format formatter = null;
Pattern TEXT_FORMAT_STRING = Pattern.compile("^\\{([^}]+)}(.+)$");
Matcher matcher = TEXT_FORMAT_STRING.matcher(format);
if (matcher.matches()) {
switch (matcher.group(1)) {
case "Message":
formatter = new MessageFormat(matcher.group(2), locale);
break;
case "Date":
formatter = new SimpleDateFormat(matcher.group(2), locale);
break;
case "String":
formatter = new FormatterFormat(matcher.group(2), locale);
break;
default:
case "Log":
formatter = new LoggerFormat(matcher.group(2));
break;
}
} else {
if (type != null && type.length == 1 && type[0] != null &&
(Calendar.class.isAssignableFrom(type[0]) || Date.class.isAssignableFrom(type[0]))) {
formatter = new SimpleDateFormat(format, locale);
} else {
formatter = new LoggerFormat(format);
}
}
return formatter;
} | java | public static Format getFormatter(@Nonnull final Locale locale, @Nonnull final String format,
@Nullable final Class<?>... type) {
Format formatter = null;
Pattern TEXT_FORMAT_STRING = Pattern.compile("^\\{([^}]+)}(.+)$");
Matcher matcher = TEXT_FORMAT_STRING.matcher(format);
if (matcher.matches()) {
switch (matcher.group(1)) {
case "Message":
formatter = new MessageFormat(matcher.group(2), locale);
break;
case "Date":
formatter = new SimpleDateFormat(matcher.group(2), locale);
break;
case "String":
formatter = new FormatterFormat(matcher.group(2), locale);
break;
default:
case "Log":
formatter = new LoggerFormat(matcher.group(2));
break;
}
} else {
if (type != null && type.length == 1 && type[0] != null &&
(Calendar.class.isAssignableFrom(type[0]) || Date.class.isAssignableFrom(type[0]))) {
formatter = new SimpleDateFormat(format, locale);
} else {
formatter = new LoggerFormat(format);
}
}
return formatter;
} | [
"public",
"static",
"Format",
"getFormatter",
"(",
"@",
"Nonnull",
"final",
"Locale",
"locale",
",",
"@",
"Nonnull",
"final",
"String",
"format",
",",
"@",
"Nullable",
"final",
"Class",
"<",
"?",
">",
"...",
"type",
")",
"{",
"Format",
"formatter",
"=",
"null",
";",
"Pattern",
"TEXT_FORMAT_STRING",
"=",
"Pattern",
".",
"compile",
"(",
"\"^\\\\{([^}]+)}(.+)$\"",
")",
";",
"Matcher",
"matcher",
"=",
"TEXT_FORMAT_STRING",
".",
"matcher",
"(",
"format",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"switch",
"(",
"matcher",
".",
"group",
"(",
"1",
")",
")",
"{",
"case",
"\"Message\"",
":",
"formatter",
"=",
"new",
"MessageFormat",
"(",
"matcher",
".",
"group",
"(",
"2",
")",
",",
"locale",
")",
";",
"break",
";",
"case",
"\"Date\"",
":",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"matcher",
".",
"group",
"(",
"2",
")",
",",
"locale",
")",
";",
"break",
";",
"case",
"\"String\"",
":",
"formatter",
"=",
"new",
"FormatterFormat",
"(",
"matcher",
".",
"group",
"(",
"2",
")",
",",
"locale",
")",
";",
"break",
";",
"default",
":",
"case",
"\"Log\"",
":",
"formatter",
"=",
"new",
"LoggerFormat",
"(",
"matcher",
".",
"group",
"(",
"2",
")",
")",
";",
"break",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"type",
"!=",
"null",
"&&",
"type",
".",
"length",
"==",
"1",
"&&",
"type",
"[",
"0",
"]",
"!=",
"null",
"&&",
"(",
"Calendar",
".",
"class",
".",
"isAssignableFrom",
"(",
"type",
"[",
"0",
"]",
")",
"||",
"Date",
".",
"class",
".",
"isAssignableFrom",
"(",
"type",
"[",
"0",
"]",
")",
")",
")",
"{",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"format",
",",
"locale",
")",
";",
"}",
"else",
"{",
"formatter",
"=",
"new",
"LoggerFormat",
"(",
"format",
")",
";",
"}",
"}",
"return",
"formatter",
";",
"}"
]
| Creates the formatter for a describing string rule
@param locale the local to use for formatting
@param format the format string rule
@param type the optional value type
@return the Format instance | [
"Creates",
"the",
"formatter",
"for",
"a",
"describing",
"string",
"rule"
]
| train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/cpnl/CpnlElFunctions.java#L358-L388 |
DDTH/ddth-zookeeper | src/main/java/com/github/ddth/zookeeper/ZooKeeperClient.java | ZooKeeperClient.setData | public boolean setData(String path, byte[] value, boolean createNodes)
throws ZooKeeperException {
"""
Writes raw data to a node.
@param path
@param value
@param createNodes
{@code true} to have nodes to be created if not exist
@return {@code true} if write successfully, {@code false} otherwise (note
does not exist, for example)
@throws ZooKeeperException
"""
return _write(path, value, createNodes);
} | java | public boolean setData(String path, byte[] value, boolean createNodes)
throws ZooKeeperException {
return _write(path, value, createNodes);
} | [
"public",
"boolean",
"setData",
"(",
"String",
"path",
",",
"byte",
"[",
"]",
"value",
",",
"boolean",
"createNodes",
")",
"throws",
"ZooKeeperException",
"{",
"return",
"_write",
"(",
"path",
",",
"value",
",",
"createNodes",
")",
";",
"}"
]
| Writes raw data to a node.
@param path
@param value
@param createNodes
{@code true} to have nodes to be created if not exist
@return {@code true} if write successfully, {@code false} otherwise (note
does not exist, for example)
@throws ZooKeeperException | [
"Writes",
"raw",
"data",
"to",
"a",
"node",
"."
]
| train | https://github.com/DDTH/ddth-zookeeper/blob/0994eea8b25fa3d885f3da4579768b7d08c1c32b/src/main/java/com/github/ddth/zookeeper/ZooKeeperClient.java#L656-L659 |
Azure/azure-sdk-for-java | containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ContainerServicesInner.java | ContainerServicesInner.beginCreateOrUpdateAsync | public Observable<ContainerServiceInner> beginCreateOrUpdateAsync(String resourceGroupName, String containerServiceName, ContainerServiceInner parameters) {
"""
Creates or updates a container service.
Creates or updates a container service with the specified configuration of orchestrator, masters, and agents.
@param resourceGroupName The name of the resource group.
@param containerServiceName The name of the container service in the specified subscription and resource group.
@param parameters Parameters supplied to the Create or Update a Container Service operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ContainerServiceInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, containerServiceName, parameters).map(new Func1<ServiceResponse<ContainerServiceInner>, ContainerServiceInner>() {
@Override
public ContainerServiceInner call(ServiceResponse<ContainerServiceInner> response) {
return response.body();
}
});
} | java | public Observable<ContainerServiceInner> beginCreateOrUpdateAsync(String resourceGroupName, String containerServiceName, ContainerServiceInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, containerServiceName, parameters).map(new Func1<ServiceResponse<ContainerServiceInner>, ContainerServiceInner>() {
@Override
public ContainerServiceInner call(ServiceResponse<ContainerServiceInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ContainerServiceInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"containerServiceName",
",",
"ContainerServiceInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"containerServiceName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ContainerServiceInner",
">",
",",
"ContainerServiceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ContainerServiceInner",
"call",
"(",
"ServiceResponse",
"<",
"ContainerServiceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Creates or updates a container service.
Creates or updates a container service with the specified configuration of orchestrator, masters, and agents.
@param resourceGroupName The name of the resource group.
@param containerServiceName The name of the container service in the specified subscription and resource group.
@param parameters Parameters supplied to the Create or Update a Container Service operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ContainerServiceInner object | [
"Creates",
"or",
"updates",
"a",
"container",
"service",
".",
"Creates",
"or",
"updates",
"a",
"container",
"service",
"with",
"the",
"specified",
"configuration",
"of",
"orchestrator",
"masters",
"and",
"agents",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ContainerServicesInner.java#L339-L346 |
census-instrumentation/opencensus-java | contrib/http_util/src/main/java/io/opencensus/contrib/http/HttpServerHandler.java | HttpServerHandler.handleStart | public HttpRequestContext handleStart(C carrier, Q request) {
"""
Instrument an incoming request before it is handled.
<p>This method will create a span under the deserialized propagated parent context. If the
parent context is not present, the span will be created under the current context.
<p>The generated span will NOT be set as current context. User can control when to enter the
scope of this span. Use {@link AbstractHttpHandler#getSpanFromContext} to retrieve the span.
@param carrier the entity that holds the HTTP information.
@param request the request entity.
@return the {@link HttpRequestContext} that contains stats and trace data associated with the
request.
@since 0.19
"""
checkNotNull(carrier, "carrier");
checkNotNull(request, "request");
SpanBuilder spanBuilder = null;
String spanName = getSpanName(request, extractor);
// de-serialize the context
SpanContext spanContext = null;
try {
spanContext = textFormat.extract(carrier, getter);
} catch (SpanContextParseException e) {
// TODO: Currently we cannot distinguish between context parse error and missing context.
// Logging would be annoying so we just ignore this error and do not even log a message.
}
if (spanContext == null || publicEndpoint) {
spanBuilder = tracer.spanBuilder(spanName);
} else {
spanBuilder = tracer.spanBuilderWithRemoteParent(spanName, spanContext);
}
Span span = spanBuilder.setSpanKind(Kind.SERVER).startSpan();
if (publicEndpoint && spanContext != null) {
span.addLink(Link.fromSpanContext(spanContext, Type.PARENT_LINKED_SPAN));
}
if (span.getOptions().contains(Options.RECORD_EVENTS)) {
addSpanRequestAttributes(span, request, extractor);
}
return getNewContext(span, tagger.getCurrentTagContext());
} | java | public HttpRequestContext handleStart(C carrier, Q request) {
checkNotNull(carrier, "carrier");
checkNotNull(request, "request");
SpanBuilder spanBuilder = null;
String spanName = getSpanName(request, extractor);
// de-serialize the context
SpanContext spanContext = null;
try {
spanContext = textFormat.extract(carrier, getter);
} catch (SpanContextParseException e) {
// TODO: Currently we cannot distinguish between context parse error and missing context.
// Logging would be annoying so we just ignore this error and do not even log a message.
}
if (spanContext == null || publicEndpoint) {
spanBuilder = tracer.spanBuilder(spanName);
} else {
spanBuilder = tracer.spanBuilderWithRemoteParent(spanName, spanContext);
}
Span span = spanBuilder.setSpanKind(Kind.SERVER).startSpan();
if (publicEndpoint && spanContext != null) {
span.addLink(Link.fromSpanContext(spanContext, Type.PARENT_LINKED_SPAN));
}
if (span.getOptions().contains(Options.RECORD_EVENTS)) {
addSpanRequestAttributes(span, request, extractor);
}
return getNewContext(span, tagger.getCurrentTagContext());
} | [
"public",
"HttpRequestContext",
"handleStart",
"(",
"C",
"carrier",
",",
"Q",
"request",
")",
"{",
"checkNotNull",
"(",
"carrier",
",",
"\"carrier\"",
")",
";",
"checkNotNull",
"(",
"request",
",",
"\"request\"",
")",
";",
"SpanBuilder",
"spanBuilder",
"=",
"null",
";",
"String",
"spanName",
"=",
"getSpanName",
"(",
"request",
",",
"extractor",
")",
";",
"// de-serialize the context",
"SpanContext",
"spanContext",
"=",
"null",
";",
"try",
"{",
"spanContext",
"=",
"textFormat",
".",
"extract",
"(",
"carrier",
",",
"getter",
")",
";",
"}",
"catch",
"(",
"SpanContextParseException",
"e",
")",
"{",
"// TODO: Currently we cannot distinguish between context parse error and missing context.",
"// Logging would be annoying so we just ignore this error and do not even log a message.",
"}",
"if",
"(",
"spanContext",
"==",
"null",
"||",
"publicEndpoint",
")",
"{",
"spanBuilder",
"=",
"tracer",
".",
"spanBuilder",
"(",
"spanName",
")",
";",
"}",
"else",
"{",
"spanBuilder",
"=",
"tracer",
".",
"spanBuilderWithRemoteParent",
"(",
"spanName",
",",
"spanContext",
")",
";",
"}",
"Span",
"span",
"=",
"spanBuilder",
".",
"setSpanKind",
"(",
"Kind",
".",
"SERVER",
")",
".",
"startSpan",
"(",
")",
";",
"if",
"(",
"publicEndpoint",
"&&",
"spanContext",
"!=",
"null",
")",
"{",
"span",
".",
"addLink",
"(",
"Link",
".",
"fromSpanContext",
"(",
"spanContext",
",",
"Type",
".",
"PARENT_LINKED_SPAN",
")",
")",
";",
"}",
"if",
"(",
"span",
".",
"getOptions",
"(",
")",
".",
"contains",
"(",
"Options",
".",
"RECORD_EVENTS",
")",
")",
"{",
"addSpanRequestAttributes",
"(",
"span",
",",
"request",
",",
"extractor",
")",
";",
"}",
"return",
"getNewContext",
"(",
"span",
",",
"tagger",
".",
"getCurrentTagContext",
"(",
")",
")",
";",
"}"
]
| Instrument an incoming request before it is handled.
<p>This method will create a span under the deserialized propagated parent context. If the
parent context is not present, the span will be created under the current context.
<p>The generated span will NOT be set as current context. User can control when to enter the
scope of this span. Use {@link AbstractHttpHandler#getSpanFromContext} to retrieve the span.
@param carrier the entity that holds the HTTP information.
@param request the request entity.
@return the {@link HttpRequestContext} that contains stats and trace data associated with the
request.
@since 0.19 | [
"Instrument",
"an",
"incoming",
"request",
"before",
"it",
"is",
"handled",
"."
]
| train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/contrib/http_util/src/main/java/io/opencensus/contrib/http/HttpServerHandler.java#L118-L147 |
vvakame/JsonPullParser | jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java | AptUtil.getTypeElement | public static TypeElement getTypeElement(Types typeUtils, Element element) {
"""
Retrieves the corresponding {@link TypeElement} of the given element.
@param typeUtils
@param element
@return The corresponding {@link TypeElement}.
@author vvakame
"""
TypeMirror type = element.asType();
return (TypeElement) typeUtils.asElement(type);
} | java | public static TypeElement getTypeElement(Types typeUtils, Element element) {
TypeMirror type = element.asType();
return (TypeElement) typeUtils.asElement(type);
} | [
"public",
"static",
"TypeElement",
"getTypeElement",
"(",
"Types",
"typeUtils",
",",
"Element",
"element",
")",
"{",
"TypeMirror",
"type",
"=",
"element",
".",
"asType",
"(",
")",
";",
"return",
"(",
"TypeElement",
")",
"typeUtils",
".",
"asElement",
"(",
"type",
")",
";",
"}"
]
| Retrieves the corresponding {@link TypeElement} of the given element.
@param typeUtils
@param element
@return The corresponding {@link TypeElement}.
@author vvakame | [
"Retrieves",
"the",
"corresponding",
"{"
]
| train | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-apt/src/main/java/net/vvakame/apt/AptUtil.java#L147-L150 |
greenmail-mail-test/greenmail | greenmail-core/src/main/java/com/icegreen/greenmail/imap/commands/IdRange.java | IdRange.containsUid | public static boolean containsUid(IdRange[] idRanges, long uid) {
"""
Checks if ranges contain the uid
@param idRanges the id ranges
@param uid the uid
@return true, if ranges contain given uid
"""
if (null != idRanges && idRanges.length > 0) {
for (IdRange range : idRanges) {
if (range.includes(uid)) {
return true;
}
}
}
return false;
} | java | public static boolean containsUid(IdRange[] idRanges, long uid) {
if (null != idRanges && idRanges.length > 0) {
for (IdRange range : idRanges) {
if (range.includes(uid)) {
return true;
}
}
}
return false;
} | [
"public",
"static",
"boolean",
"containsUid",
"(",
"IdRange",
"[",
"]",
"idRanges",
",",
"long",
"uid",
")",
"{",
"if",
"(",
"null",
"!=",
"idRanges",
"&&",
"idRanges",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"IdRange",
"range",
":",
"idRanges",
")",
"{",
"if",
"(",
"range",
".",
"includes",
"(",
"uid",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
]
| Checks if ranges contain the uid
@param idRanges the id ranges
@param uid the uid
@return true, if ranges contain given uid | [
"Checks",
"if",
"ranges",
"contain",
"the",
"uid"
]
| train | https://github.com/greenmail-mail-test/greenmail/blob/6d19a62233d1ef6fedbbd1f6fdde2d28e713834a/greenmail-core/src/main/java/com/icegreen/greenmail/imap/commands/IdRange.java#L149-L158 |
facebook/fresco | samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java | DefaultZoomableController.mapAbsoluteToRelative | private void mapAbsoluteToRelative(float[] destPoints, float[] srcPoints, int numPoints) {
"""
Maps array of 2D points from view-absolute to image-relative coordinates.
This does NOT take into account the zoomable transformation.
Points are represented by a float array of [x0, y0, x1, y1, ...].
@param destPoints destination array (may be the same as source array)
@param srcPoints source array
@param numPoints number of points to map
"""
for (int i = 0; i < numPoints; i++) {
destPoints[i * 2 + 0] = (srcPoints[i * 2 + 0] - mImageBounds.left) / mImageBounds.width();
destPoints[i * 2 + 1] = (srcPoints[i * 2 + 1] - mImageBounds.top) / mImageBounds.height();
}
} | java | private void mapAbsoluteToRelative(float[] destPoints, float[] srcPoints, int numPoints) {
for (int i = 0; i < numPoints; i++) {
destPoints[i * 2 + 0] = (srcPoints[i * 2 + 0] - mImageBounds.left) / mImageBounds.width();
destPoints[i * 2 + 1] = (srcPoints[i * 2 + 1] - mImageBounds.top) / mImageBounds.height();
}
} | [
"private",
"void",
"mapAbsoluteToRelative",
"(",
"float",
"[",
"]",
"destPoints",
",",
"float",
"[",
"]",
"srcPoints",
",",
"int",
"numPoints",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numPoints",
";",
"i",
"++",
")",
"{",
"destPoints",
"[",
"i",
"*",
"2",
"+",
"0",
"]",
"=",
"(",
"srcPoints",
"[",
"i",
"*",
"2",
"+",
"0",
"]",
"-",
"mImageBounds",
".",
"left",
")",
"/",
"mImageBounds",
".",
"width",
"(",
")",
";",
"destPoints",
"[",
"i",
"*",
"2",
"+",
"1",
"]",
"=",
"(",
"srcPoints",
"[",
"i",
"*",
"2",
"+",
"1",
"]",
"-",
"mImageBounds",
".",
"top",
")",
"/",
"mImageBounds",
".",
"height",
"(",
")",
";",
"}",
"}"
]
| Maps array of 2D points from view-absolute to image-relative coordinates.
This does NOT take into account the zoomable transformation.
Points are represented by a float array of [x0, y0, x1, y1, ...].
@param destPoints destination array (may be the same as source array)
@param srcPoints source array
@param numPoints number of points to map | [
"Maps",
"array",
"of",
"2D",
"points",
"from",
"view",
"-",
"absolute",
"to",
"image",
"-",
"relative",
"coordinates",
".",
"This",
"does",
"NOT",
"take",
"into",
"account",
"the",
"zoomable",
"transformation",
".",
"Points",
"are",
"represented",
"by",
"a",
"float",
"array",
"of",
"[",
"x0",
"y0",
"x1",
"y1",
"...",
"]",
"."
]
| train | https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/samples/zoomable/src/main/java/com/facebook/samples/zoomable/DefaultZoomableController.java#L316-L321 |
auth0/auth0-java | src/main/java/com/auth0/client/mgmt/filter/ResourceServersFilter.java | ResourceServersFilter.withPage | public ResourceServersFilter withPage(int pageNumber, int amountPerPage) {
"""
Filter by page
@param pageNumber the page number to retrieve.
@param amountPerPage the amount of items per page to retrieve.
@return this filter instance
"""
parameters.put("page", pageNumber);
parameters.put("per_page", amountPerPage);
return this;
} | java | public ResourceServersFilter withPage(int pageNumber, int amountPerPage) {
parameters.put("page", pageNumber);
parameters.put("per_page", amountPerPage);
return this;
} | [
"public",
"ResourceServersFilter",
"withPage",
"(",
"int",
"pageNumber",
",",
"int",
"amountPerPage",
")",
"{",
"parameters",
".",
"put",
"(",
"\"page\"",
",",
"pageNumber",
")",
";",
"parameters",
".",
"put",
"(",
"\"per_page\"",
",",
"amountPerPage",
")",
";",
"return",
"this",
";",
"}"
]
| Filter by page
@param pageNumber the page number to retrieve.
@param amountPerPage the amount of items per page to retrieve.
@return this filter instance | [
"Filter",
"by",
"page"
]
| train | https://github.com/auth0/auth0-java/blob/b7bc099ee9c6cde5a87c4ecfebc6d811aeb1027c/src/main/java/com/auth0/client/mgmt/filter/ResourceServersFilter.java#L15-L19 |
windup/windup | config/api/src/main/java/org/jboss/windup/config/phase/RulePhaseFinder.java | RulePhaseFinder.getAvailablePhases | public List<Class<? extends RulePhase>> getAvailablePhases() {
"""
Returns the phases loaded in this finder, sorted by Class.getSimpleName().
"""
ArrayList<Class<? extends RulePhase>> phases = new ArrayList<>(this.cachedPhases.values());
// It could be sorted by the real order.
phases.sort(new Comparator()
{
@Override
public int compare(Object phaseClass1, Object phaseClass2)
{
if (phaseClass1 == null || !(phaseClass1 instanceof Class))
return -1;
if (phaseClass2 == null || !(phaseClass2 instanceof Class))
return 1;
String name1 = ((Class<? extends RulePhase>)phaseClass1).getSimpleName();
String name2 = ((Class<? extends RulePhase>)phaseClass2).getSimpleName();
return name1.compareToIgnoreCase(name2);
}
});
return phases;
} | java | public List<Class<? extends RulePhase>> getAvailablePhases() {
ArrayList<Class<? extends RulePhase>> phases = new ArrayList<>(this.cachedPhases.values());
// It could be sorted by the real order.
phases.sort(new Comparator()
{
@Override
public int compare(Object phaseClass1, Object phaseClass2)
{
if (phaseClass1 == null || !(phaseClass1 instanceof Class))
return -1;
if (phaseClass2 == null || !(phaseClass2 instanceof Class))
return 1;
String name1 = ((Class<? extends RulePhase>)phaseClass1).getSimpleName();
String name2 = ((Class<? extends RulePhase>)phaseClass2).getSimpleName();
return name1.compareToIgnoreCase(name2);
}
});
return phases;
} | [
"public",
"List",
"<",
"Class",
"<",
"?",
"extends",
"RulePhase",
">",
">",
"getAvailablePhases",
"(",
")",
"{",
"ArrayList",
"<",
"Class",
"<",
"?",
"extends",
"RulePhase",
">",
">",
"phases",
"=",
"new",
"ArrayList",
"<>",
"(",
"this",
".",
"cachedPhases",
".",
"values",
"(",
")",
")",
";",
"// It could be sorted by the real order.",
"phases",
".",
"sort",
"(",
"new",
"Comparator",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"Object",
"phaseClass1",
",",
"Object",
"phaseClass2",
")",
"{",
"if",
"(",
"phaseClass1",
"==",
"null",
"||",
"!",
"(",
"phaseClass1",
"instanceof",
"Class",
")",
")",
"return",
"-",
"1",
";",
"if",
"(",
"phaseClass2",
"==",
"null",
"||",
"!",
"(",
"phaseClass2",
"instanceof",
"Class",
")",
")",
"return",
"1",
";",
"String",
"name1",
"=",
"(",
"(",
"Class",
"<",
"?",
"extends",
"RulePhase",
">",
")",
"phaseClass1",
")",
".",
"getSimpleName",
"(",
")",
";",
"String",
"name2",
"=",
"(",
"(",
"Class",
"<",
"?",
"extends",
"RulePhase",
">",
")",
"phaseClass2",
")",
".",
"getSimpleName",
"(",
")",
";",
"return",
"name1",
".",
"compareToIgnoreCase",
"(",
"name2",
")",
";",
"}",
"}",
")",
";",
"return",
"phases",
";",
"}"
]
| Returns the phases loaded in this finder, sorted by Class.getSimpleName(). | [
"Returns",
"the",
"phases",
"loaded",
"in",
"this",
"finder",
"sorted",
"by",
"Class",
".",
"getSimpleName",
"()",
"."
]
| train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/config/api/src/main/java/org/jboss/windup/config/phase/RulePhaseFinder.java#L60-L79 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/EpicsApi.java | EpicsApi.updateEpic | public Epic updateEpic(Object groupIdOrPath, Integer epicIid, Epic epic) throws GitLabApiException {
"""
Updates an epic using the information contained in the provided Epic instance. Only the following
fields from the Epic instance are used:
<pre><code>
title - the title of the epic (optional)
labels - comma separated list of labels (optional)
description - the description of the epic (optional)
startDate - the start date of the epic (optional)
endDate - the end date of the epic (optional)
</code></pre>
<pre><code>GitLab Endpoint: PUT /groups/:id/epics/:epic_iid</code></pre>
@param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
@param epicIid the IID of the epic to update
@param epic the Epic instance with update information
@return an Epic instance containing info on the updated epic
@throws GitLabApiException if any exception occurs
"""
Form formData = new GitLabApiForm()
.withParam("title", epic.getTitle(), true)
.withParam("labels", epic.getLabels())
.withParam("description", epic.getDescription())
.withParam("start_date", epic.getStartDate())
.withParam("end_date", epic.getEndDate());
Response response = put(Response.Status.OK, formData.asMap(),
"groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid);
return (response.readEntity(Epic.class));
} | java | public Epic updateEpic(Object groupIdOrPath, Integer epicIid, Epic epic) throws GitLabApiException {
Form formData = new GitLabApiForm()
.withParam("title", epic.getTitle(), true)
.withParam("labels", epic.getLabels())
.withParam("description", epic.getDescription())
.withParam("start_date", epic.getStartDate())
.withParam("end_date", epic.getEndDate());
Response response = put(Response.Status.OK, formData.asMap(),
"groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid);
return (response.readEntity(Epic.class));
} | [
"public",
"Epic",
"updateEpic",
"(",
"Object",
"groupIdOrPath",
",",
"Integer",
"epicIid",
",",
"Epic",
"epic",
")",
"throws",
"GitLabApiException",
"{",
"Form",
"formData",
"=",
"new",
"GitLabApiForm",
"(",
")",
".",
"withParam",
"(",
"\"title\"",
",",
"epic",
".",
"getTitle",
"(",
")",
",",
"true",
")",
".",
"withParam",
"(",
"\"labels\"",
",",
"epic",
".",
"getLabels",
"(",
")",
")",
".",
"withParam",
"(",
"\"description\"",
",",
"epic",
".",
"getDescription",
"(",
")",
")",
".",
"withParam",
"(",
"\"start_date\"",
",",
"epic",
".",
"getStartDate",
"(",
")",
")",
".",
"withParam",
"(",
"\"end_date\"",
",",
"epic",
".",
"getEndDate",
"(",
")",
")",
";",
"Response",
"response",
"=",
"put",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"formData",
".",
"asMap",
"(",
")",
",",
"\"groups\"",
",",
"getGroupIdOrPath",
"(",
"groupIdOrPath",
")",
",",
"\"epics\"",
",",
"epicIid",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"Epic",
".",
"class",
")",
")",
";",
"}"
]
| Updates an epic using the information contained in the provided Epic instance. Only the following
fields from the Epic instance are used:
<pre><code>
title - the title of the epic (optional)
labels - comma separated list of labels (optional)
description - the description of the epic (optional)
startDate - the start date of the epic (optional)
endDate - the end date of the epic (optional)
</code></pre>
<pre><code>GitLab Endpoint: PUT /groups/:id/epics/:epic_iid</code></pre>
@param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
@param epicIid the IID of the epic to update
@param epic the Epic instance with update information
@return an Epic instance containing info on the updated epic
@throws GitLabApiException if any exception occurs | [
"Updates",
"an",
"epic",
"using",
"the",
"information",
"contained",
"in",
"the",
"provided",
"Epic",
"instance",
".",
"Only",
"the",
"following",
"fields",
"from",
"the",
"Epic",
"instance",
"are",
"used",
":",
"<pre",
">",
"<code",
">",
"title",
"-",
"the",
"title",
"of",
"the",
"epic",
"(",
"optional",
")",
"labels",
"-",
"comma",
"separated",
"list",
"of",
"labels",
"(",
"optional",
")",
"description",
"-",
"the",
"description",
"of",
"the",
"epic",
"(",
"optional",
")",
"startDate",
"-",
"the",
"start",
"date",
"of",
"the",
"epic",
"(",
"optional",
")",
"endDate",
"-",
"the",
"end",
"date",
"of",
"the",
"epic",
"(",
"optional",
")",
"<",
"/",
"code",
">",
"<",
"/",
"pre",
">",
"<pre",
">",
"<code",
">",
"GitLab",
"Endpoint",
":",
"PUT",
"/",
"groups",
"/",
":",
"id",
"/",
"epics",
"/",
":",
"epic_iid<",
"/",
"code",
">",
"<",
"/",
"pre",
">"
]
| train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/EpicsApi.java#L318-L328 |
BellaDati/belladati-sdk-java | src/main/java/com/belladati/sdk/impl/BellaDatiServiceImpl.java | BellaDatiServiceImpl.appendDateTime | public URIBuilder appendDateTime(URIBuilder builder, Interval<DateUnit> dateInterval, Interval<TimeUnit> timeInterval) {
"""
Appends a date/time definition parameter to the URI builder. Won't do
anything if both intervals are <tt>null</tt>.
@param builder the builder to append to
@param dateInterval date interval to append, or <tt>null</tt>
@param timeInterval time interval to append, or <tt>null</tt>
@return the same builder, for chaining
"""
if (dateInterval != null || timeInterval != null) {
ObjectNode dateTimeNode = new ObjectMapper().createObjectNode();
if (dateInterval != null) {
dateTimeNode.setAll(dateInterval.toJson());
}
if (timeInterval != null) {
dateTimeNode.setAll(timeInterval.toJson());
}
builder.addParameter("dateTimeDefinition", dateTimeNode.toString());
}
return builder;
} | java | public URIBuilder appendDateTime(URIBuilder builder, Interval<DateUnit> dateInterval, Interval<TimeUnit> timeInterval) {
if (dateInterval != null || timeInterval != null) {
ObjectNode dateTimeNode = new ObjectMapper().createObjectNode();
if (dateInterval != null) {
dateTimeNode.setAll(dateInterval.toJson());
}
if (timeInterval != null) {
dateTimeNode.setAll(timeInterval.toJson());
}
builder.addParameter("dateTimeDefinition", dateTimeNode.toString());
}
return builder;
} | [
"public",
"URIBuilder",
"appendDateTime",
"(",
"URIBuilder",
"builder",
",",
"Interval",
"<",
"DateUnit",
">",
"dateInterval",
",",
"Interval",
"<",
"TimeUnit",
">",
"timeInterval",
")",
"{",
"if",
"(",
"dateInterval",
"!=",
"null",
"||",
"timeInterval",
"!=",
"null",
")",
"{",
"ObjectNode",
"dateTimeNode",
"=",
"new",
"ObjectMapper",
"(",
")",
".",
"createObjectNode",
"(",
")",
";",
"if",
"(",
"dateInterval",
"!=",
"null",
")",
"{",
"dateTimeNode",
".",
"setAll",
"(",
"dateInterval",
".",
"toJson",
"(",
")",
")",
";",
"}",
"if",
"(",
"timeInterval",
"!=",
"null",
")",
"{",
"dateTimeNode",
".",
"setAll",
"(",
"timeInterval",
".",
"toJson",
"(",
")",
")",
";",
"}",
"builder",
".",
"addParameter",
"(",
"\"dateTimeDefinition\"",
",",
"dateTimeNode",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"builder",
";",
"}"
]
| Appends a date/time definition parameter to the URI builder. Won't do
anything if both intervals are <tt>null</tt>.
@param builder the builder to append to
@param dateInterval date interval to append, or <tt>null</tt>
@param timeInterval time interval to append, or <tt>null</tt>
@return the same builder, for chaining | [
"Appends",
"a",
"date",
"/",
"time",
"definition",
"parameter",
"to",
"the",
"URI",
"builder",
".",
"Won",
"t",
"do",
"anything",
"if",
"both",
"intervals",
"are",
"<tt",
">",
"null<",
"/",
"tt",
">",
"."
]
| train | https://github.com/BellaDati/belladati-sdk-java/blob/1a732a57ebc825ddf47ce405723cc958adb1a43f/src/main/java/com/belladati/sdk/impl/BellaDatiServiceImpl.java#L406-L418 |
javalite/activeweb | javalite-async/src/main/java/org/javalite/async/Async.java | Async.getTopTextMessages | public List<String> getTopTextMessages(int maxSize, String queueName) {
"""
Returns top <code>TextMessage</code>s in queue. Does not remove anything from queue. This method can be used for
an admin tool to peek inside the queue.
@param maxSize max number of messages to lookup.
@return top commands in queue or empty list is nothing is found in queue.
"""
checkStarted();
List<String> res = new ArrayList<>();
try(Session session = consumerConnection.createSession()) {
Queue queue = (Queue) jmsServer.lookup(QUEUE_NAMESPACE + queueName);
Enumeration messages = session.createBrowser(queue).getEnumeration();
for(int i = 0; i < maxSize && messages.hasMoreElements(); i++) {
TextMessage message = (TextMessage) messages.nextElement();
res.add(message.getText());
}
return res;
} catch (Exception e) {
throw new AsyncException("Could not lookup messages", e);
}
} | java | public List<String> getTopTextMessages(int maxSize, String queueName) {
checkStarted();
List<String> res = new ArrayList<>();
try(Session session = consumerConnection.createSession()) {
Queue queue = (Queue) jmsServer.lookup(QUEUE_NAMESPACE + queueName);
Enumeration messages = session.createBrowser(queue).getEnumeration();
for(int i = 0; i < maxSize && messages.hasMoreElements(); i++) {
TextMessage message = (TextMessage) messages.nextElement();
res.add(message.getText());
}
return res;
} catch (Exception e) {
throw new AsyncException("Could not lookup messages", e);
}
} | [
"public",
"List",
"<",
"String",
">",
"getTopTextMessages",
"(",
"int",
"maxSize",
",",
"String",
"queueName",
")",
"{",
"checkStarted",
"(",
")",
";",
"List",
"<",
"String",
">",
"res",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"(",
"Session",
"session",
"=",
"consumerConnection",
".",
"createSession",
"(",
")",
")",
"{",
"Queue",
"queue",
"=",
"(",
"Queue",
")",
"jmsServer",
".",
"lookup",
"(",
"QUEUE_NAMESPACE",
"+",
"queueName",
")",
";",
"Enumeration",
"messages",
"=",
"session",
".",
"createBrowser",
"(",
"queue",
")",
".",
"getEnumeration",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"maxSize",
"&&",
"messages",
".",
"hasMoreElements",
"(",
")",
";",
"i",
"++",
")",
"{",
"TextMessage",
"message",
"=",
"(",
"TextMessage",
")",
"messages",
".",
"nextElement",
"(",
")",
";",
"res",
".",
"add",
"(",
"message",
".",
"getText",
"(",
")",
")",
";",
"}",
"return",
"res",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"AsyncException",
"(",
"\"Could not lookup messages\"",
",",
"e",
")",
";",
"}",
"}"
]
| Returns top <code>TextMessage</code>s in queue. Does not remove anything from queue. This method can be used for
an admin tool to peek inside the queue.
@param maxSize max number of messages to lookup.
@return top commands in queue or empty list is nothing is found in queue. | [
"Returns",
"top",
"<code",
">",
"TextMessage<",
"/",
"code",
">",
"s",
"in",
"queue",
".",
"Does",
"not",
"remove",
"anything",
"from",
"queue",
".",
"This",
"method",
"can",
"be",
"used",
"for",
"an",
"admin",
"tool",
"to",
"peek",
"inside",
"the",
"queue",
"."
]
| train | https://github.com/javalite/activeweb/blob/f25f589da94852b6f5625182360732e0861794a6/javalite-async/src/main/java/org/javalite/async/Async.java#L574-L588 |
versionone/VersionOne.SDK.Java.ObjectModel | src/main/java/com/versionone/om/V1InstanceGetter.java | V1InstanceGetter.messageReceipts | Collection<MessageReceipt> messageReceipts(MessageReceiptFilter filter) {
"""
/* public Collection<Conversation> conversations(ConversationFilter filter) {
return get(Conversation.class, (filter != null) ? filter : new ConversationFilter());
}
"""
return get(MessageReceipt.class, (filter != null) ? filter : new MessageReceiptFilter());
} | java | Collection<MessageReceipt> messageReceipts(MessageReceiptFilter filter) {
return get(MessageReceipt.class, (filter != null) ? filter : new MessageReceiptFilter());
} | [
"Collection",
"<",
"MessageReceipt",
">",
"messageReceipts",
"(",
"MessageReceiptFilter",
"filter",
")",
"{",
"return",
"get",
"(",
"MessageReceipt",
".",
"class",
",",
"(",
"filter",
"!=",
"null",
")",
"?",
"filter",
":",
"new",
"MessageReceiptFilter",
"(",
")",
")",
";",
"}"
]
| /* public Collection<Conversation> conversations(ConversationFilter filter) {
return get(Conversation.class, (filter != null) ? filter : new ConversationFilter());
} | [
"/",
"*",
"public",
"Collection<Conversation",
">",
"conversations",
"(",
"ConversationFilter",
"filter",
")",
"{",
"return",
"get",
"(",
"Conversation",
".",
"class",
"(",
"filter",
"!",
"=",
"null",
")",
"?",
"filter",
":",
"new",
"ConversationFilter",
"()",
")",
";",
"}"
]
| train | https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/V1InstanceGetter.java#L360-L362 |
apptik/jus | android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java | ImageLoader.getCacheKey | private static String getCacheKey(String url, int maxWidth, int maxHeight, ScaleType scaleType) {
"""
Creates a cache key for use with the L1 cache.
@param url The URL of the request.
@param maxWidth The max-width of the output.
@param maxHeight The max-height of the output.
@param scaleType The scaleType of the imageView.
"""
return "#W" + maxWidth + "#H" + maxHeight + "#S" + scaleType.ordinal() + url;
} | java | private static String getCacheKey(String url, int maxWidth, int maxHeight, ScaleType scaleType) {
return "#W" + maxWidth + "#H" + maxHeight + "#S" + scaleType.ordinal() + url;
} | [
"private",
"static",
"String",
"getCacheKey",
"(",
"String",
"url",
",",
"int",
"maxWidth",
",",
"int",
"maxHeight",
",",
"ScaleType",
"scaleType",
")",
"{",
"return",
"\"#W\"",
"+",
"maxWidth",
"+",
"\"#H\"",
"+",
"maxHeight",
"+",
"\"#S\"",
"+",
"scaleType",
".",
"ordinal",
"(",
")",
"+",
"url",
";",
"}"
]
| Creates a cache key for use with the L1 cache.
@param url The URL of the request.
@param maxWidth The max-width of the output.
@param maxHeight The max-height of the output.
@param scaleType The scaleType of the imageView. | [
"Creates",
"a",
"cache",
"key",
"for",
"use",
"with",
"the",
"L1",
"cache",
"."
]
| train | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/android/jus-android/src/main/java/io/apptik/comm/jus/ui/ImageLoader.java#L567-L569 |
cache2k/cache2k | cache2k-spring/src/main/java/org/cache2k/extra/spring/SpringCache2kCacheManager.java | SpringCache2kCacheManager.addCaches | @SafeVarargs
public final SpringCache2kCacheManager addCaches(Function<Cache2kBuilder<?,?>, Cache2kBuilder<?,?>>... fs) {
"""
Adds a caches to this cache manager that maybe is configured via the {@link Cache2kBuilder}.
The configuration parameter {@link Cache2kBuilder#exceptionPropagator}
is managed by this class and cannot be used. This method can be used in case a programmatic
configuration of a cache manager is preferred.
<p>Rationale: The method provides a builder that is already seeded with the effective manager.
This makes it possible to use the builder without code bloat. Since the actual build is done
within this class, it is also possible to reset specific settings or do assertions.
@throws IllegalArgumentException if cache is already created
"""
for (Function<Cache2kBuilder<?,?>, Cache2kBuilder<?,?>> f : fs) {
addCache(f.apply(defaultSetup.apply(Cache2kBuilder.forUnknownTypes().manager(manager))));
}
return this;
} | java | @SafeVarargs
public final SpringCache2kCacheManager addCaches(Function<Cache2kBuilder<?,?>, Cache2kBuilder<?,?>>... fs) {
for (Function<Cache2kBuilder<?,?>, Cache2kBuilder<?,?>> f : fs) {
addCache(f.apply(defaultSetup.apply(Cache2kBuilder.forUnknownTypes().manager(manager))));
}
return this;
} | [
"@",
"SafeVarargs",
"public",
"final",
"SpringCache2kCacheManager",
"addCaches",
"(",
"Function",
"<",
"Cache2kBuilder",
"<",
"?",
",",
"?",
">",
",",
"Cache2kBuilder",
"<",
"?",
",",
"?",
">",
">",
"...",
"fs",
")",
"{",
"for",
"(",
"Function",
"<",
"Cache2kBuilder",
"<",
"?",
",",
"?",
">",
",",
"Cache2kBuilder",
"<",
"?",
",",
"?",
">",
">",
"f",
":",
"fs",
")",
"{",
"addCache",
"(",
"f",
".",
"apply",
"(",
"defaultSetup",
".",
"apply",
"(",
"Cache2kBuilder",
".",
"forUnknownTypes",
"(",
")",
".",
"manager",
"(",
"manager",
")",
")",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
]
| Adds a caches to this cache manager that maybe is configured via the {@link Cache2kBuilder}.
The configuration parameter {@link Cache2kBuilder#exceptionPropagator}
is managed by this class and cannot be used. This method can be used in case a programmatic
configuration of a cache manager is preferred.
<p>Rationale: The method provides a builder that is already seeded with the effective manager.
This makes it possible to use the builder without code bloat. Since the actual build is done
within this class, it is also possible to reset specific settings or do assertions.
@throws IllegalArgumentException if cache is already created | [
"Adds",
"a",
"caches",
"to",
"this",
"cache",
"manager",
"that",
"maybe",
"is",
"configured",
"via",
"the",
"{",
"@link",
"Cache2kBuilder",
"}",
".",
"The",
"configuration",
"parameter",
"{",
"@link",
"Cache2kBuilder#exceptionPropagator",
"}",
"is",
"managed",
"by",
"this",
"class",
"and",
"cannot",
"be",
"used",
".",
"This",
"method",
"can",
"be",
"used",
"in",
"case",
"a",
"programmatic",
"configuration",
"of",
"a",
"cache",
"manager",
"is",
"preferred",
"."
]
| train | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-spring/src/main/java/org/cache2k/extra/spring/SpringCache2kCacheManager.java#L129-L135 |
jcuda/jcusparse | JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java | JCusparse.cusparseSbsrxmv | public static int cusparseSbsrxmv(
cusparseHandle handle,
int dirA,
int transA,
int sizeOfMask,
int mb,
int nb,
int nnzb,
Pointer alpha,
cusparseMatDescr descrA,
Pointer bsrSortedValA,
Pointer bsrSortedMaskPtrA,
Pointer bsrSortedRowPtrA,
Pointer bsrSortedEndPtrA,
Pointer bsrSortedColIndA,
int blockDim,
Pointer x,
Pointer beta,
Pointer y) {
"""
Description: Matrix-vector multiplication y = alpha * op(A) * x + beta * y,
where A is a sparse matrix in extended BSR storage format, x and y are dense
vectors.
"""
return checkResult(cusparseSbsrxmvNative(handle, dirA, transA, sizeOfMask, mb, nb, nnzb, alpha, descrA, bsrSortedValA, bsrSortedMaskPtrA, bsrSortedRowPtrA, bsrSortedEndPtrA, bsrSortedColIndA, blockDim, x, beta, y));
} | java | public static int cusparseSbsrxmv(
cusparseHandle handle,
int dirA,
int transA,
int sizeOfMask,
int mb,
int nb,
int nnzb,
Pointer alpha,
cusparseMatDescr descrA,
Pointer bsrSortedValA,
Pointer bsrSortedMaskPtrA,
Pointer bsrSortedRowPtrA,
Pointer bsrSortedEndPtrA,
Pointer bsrSortedColIndA,
int blockDim,
Pointer x,
Pointer beta,
Pointer y)
{
return checkResult(cusparseSbsrxmvNative(handle, dirA, transA, sizeOfMask, mb, nb, nnzb, alpha, descrA, bsrSortedValA, bsrSortedMaskPtrA, bsrSortedRowPtrA, bsrSortedEndPtrA, bsrSortedColIndA, blockDim, x, beta, y));
} | [
"public",
"static",
"int",
"cusparseSbsrxmv",
"(",
"cusparseHandle",
"handle",
",",
"int",
"dirA",
",",
"int",
"transA",
",",
"int",
"sizeOfMask",
",",
"int",
"mb",
",",
"int",
"nb",
",",
"int",
"nnzb",
",",
"Pointer",
"alpha",
",",
"cusparseMatDescr",
"descrA",
",",
"Pointer",
"bsrSortedValA",
",",
"Pointer",
"bsrSortedMaskPtrA",
",",
"Pointer",
"bsrSortedRowPtrA",
",",
"Pointer",
"bsrSortedEndPtrA",
",",
"Pointer",
"bsrSortedColIndA",
",",
"int",
"blockDim",
",",
"Pointer",
"x",
",",
"Pointer",
"beta",
",",
"Pointer",
"y",
")",
"{",
"return",
"checkResult",
"(",
"cusparseSbsrxmvNative",
"(",
"handle",
",",
"dirA",
",",
"transA",
",",
"sizeOfMask",
",",
"mb",
",",
"nb",
",",
"nnzb",
",",
"alpha",
",",
"descrA",
",",
"bsrSortedValA",
",",
"bsrSortedMaskPtrA",
",",
"bsrSortedRowPtrA",
",",
"bsrSortedEndPtrA",
",",
"bsrSortedColIndA",
",",
"blockDim",
",",
"x",
",",
"beta",
",",
"y",
")",
")",
";",
"}"
]
| Description: Matrix-vector multiplication y = alpha * op(A) * x + beta * y,
where A is a sparse matrix in extended BSR 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",
"extended",
"BSR",
"storage",
"format",
"x",
"and",
"y",
"are",
"dense",
"vectors",
"."
]
| train | https://github.com/jcuda/jcusparse/blob/7687a62a4ef6b76cb91cf7da93d4cf5ade96a791/JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java#L1968-L1989 |
jMetal/jMetal | jmetal-core/src/main/java/org/uma/jmetal/util/SolutionListUtils.java | SolutionListUtils.findIndexOfBestSolution | public static <S> int findIndexOfBestSolution(List<S> solutionList, Comparator<S> comparator) {
"""
Finds the index of the best solution in the list according to a comparator
@param solutionList
@param comparator
@return The index of the best solution
"""
if (solutionList == null) {
throw new NullSolutionListException();
} else if (solutionList.isEmpty()) {
throw new EmptySolutionListException();
} else if (comparator == null) {
throw new JMetalException("The comparator is null");
}
int index = 0;
S bestKnown = solutionList.get(0);
S candidateSolution;
int flag;
for (int i = 1; i < solutionList.size(); i++) {
candidateSolution = solutionList.get(i);
flag = comparator.compare(bestKnown, candidateSolution);
if (flag == 1) {
index = i;
bestKnown = candidateSolution;
}
}
return index;
} | java | public static <S> int findIndexOfBestSolution(List<S> solutionList, Comparator<S> comparator) {
if (solutionList == null) {
throw new NullSolutionListException();
} else if (solutionList.isEmpty()) {
throw new EmptySolutionListException();
} else if (comparator == null) {
throw new JMetalException("The comparator is null");
}
int index = 0;
S bestKnown = solutionList.get(0);
S candidateSolution;
int flag;
for (int i = 1; i < solutionList.size(); i++) {
candidateSolution = solutionList.get(i);
flag = comparator.compare(bestKnown, candidateSolution);
if (flag == 1) {
index = i;
bestKnown = candidateSolution;
}
}
return index;
} | [
"public",
"static",
"<",
"S",
">",
"int",
"findIndexOfBestSolution",
"(",
"List",
"<",
"S",
">",
"solutionList",
",",
"Comparator",
"<",
"S",
">",
"comparator",
")",
"{",
"if",
"(",
"solutionList",
"==",
"null",
")",
"{",
"throw",
"new",
"NullSolutionListException",
"(",
")",
";",
"}",
"else",
"if",
"(",
"solutionList",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"EmptySolutionListException",
"(",
")",
";",
"}",
"else",
"if",
"(",
"comparator",
"==",
"null",
")",
"{",
"throw",
"new",
"JMetalException",
"(",
"\"The comparator is null\"",
")",
";",
"}",
"int",
"index",
"=",
"0",
";",
"S",
"bestKnown",
"=",
"solutionList",
".",
"get",
"(",
"0",
")",
";",
"S",
"candidateSolution",
";",
"int",
"flag",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"solutionList",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"candidateSolution",
"=",
"solutionList",
".",
"get",
"(",
"i",
")",
";",
"flag",
"=",
"comparator",
".",
"compare",
"(",
"bestKnown",
",",
"candidateSolution",
")",
";",
"if",
"(",
"flag",
"==",
"1",
")",
"{",
"index",
"=",
"i",
";",
"bestKnown",
"=",
"candidateSolution",
";",
"}",
"}",
"return",
"index",
";",
"}"
]
| Finds the index of the best solution in the list according to a comparator
@param solutionList
@param comparator
@return The index of the best solution | [
"Finds",
"the",
"index",
"of",
"the",
"best",
"solution",
"in",
"the",
"list",
"according",
"to",
"a",
"comparator"
]
| train | https://github.com/jMetal/jMetal/blob/bc981e6aede275d26c5216c9a01227d9675b0cf7/jmetal-core/src/main/java/org/uma/jmetal/util/SolutionListUtils.java#L46-L70 |
Microsoft/azure-maven-plugins | azure-maven-plugin-lib/src/main/java/com/microsoft/azure/maven/FTPUploader.java | FTPUploader.uploadDirectoryWithRetries | public void uploadDirectoryWithRetries(final String ftpServer, final String username, final String password,
final String sourceDirectory, final String targetDirectory,
final int maxRetryCount) throws MojoExecutionException {
"""
Upload directory to specified FTP server with retries.
@param ftpServer
@param username
@param password
@param sourceDirectory
@param targetDirectory
@param maxRetryCount
@throws MojoExecutionException
"""
int retryCount = 0;
while (retryCount < maxRetryCount) {
retryCount++;
log.info(UPLOAD_START + ftpServer);
if (uploadDirectory(ftpServer, username, password, sourceDirectory, targetDirectory)) {
log.info(UPLOAD_SUCCESS + ftpServer);
return;
} else {
log.warn(String.format(UPLOAD_FAILURE, retryCount, maxRetryCount));
}
}
// Reaching here means all retries failed.
throw new MojoExecutionException(String.format(UPLOAD_RETRY_FAILURE, maxRetryCount));
} | java | public void uploadDirectoryWithRetries(final String ftpServer, final String username, final String password,
final String sourceDirectory, final String targetDirectory,
final int maxRetryCount) throws MojoExecutionException {
int retryCount = 0;
while (retryCount < maxRetryCount) {
retryCount++;
log.info(UPLOAD_START + ftpServer);
if (uploadDirectory(ftpServer, username, password, sourceDirectory, targetDirectory)) {
log.info(UPLOAD_SUCCESS + ftpServer);
return;
} else {
log.warn(String.format(UPLOAD_FAILURE, retryCount, maxRetryCount));
}
}
// Reaching here means all retries failed.
throw new MojoExecutionException(String.format(UPLOAD_RETRY_FAILURE, maxRetryCount));
} | [
"public",
"void",
"uploadDirectoryWithRetries",
"(",
"final",
"String",
"ftpServer",
",",
"final",
"String",
"username",
",",
"final",
"String",
"password",
",",
"final",
"String",
"sourceDirectory",
",",
"final",
"String",
"targetDirectory",
",",
"final",
"int",
"maxRetryCount",
")",
"throws",
"MojoExecutionException",
"{",
"int",
"retryCount",
"=",
"0",
";",
"while",
"(",
"retryCount",
"<",
"maxRetryCount",
")",
"{",
"retryCount",
"++",
";",
"log",
".",
"info",
"(",
"UPLOAD_START",
"+",
"ftpServer",
")",
";",
"if",
"(",
"uploadDirectory",
"(",
"ftpServer",
",",
"username",
",",
"password",
",",
"sourceDirectory",
",",
"targetDirectory",
")",
")",
"{",
"log",
".",
"info",
"(",
"UPLOAD_SUCCESS",
"+",
"ftpServer",
")",
";",
"return",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"UPLOAD_FAILURE",
",",
"retryCount",
",",
"maxRetryCount",
")",
")",
";",
"}",
"}",
"// Reaching here means all retries failed.",
"throw",
"new",
"MojoExecutionException",
"(",
"String",
".",
"format",
"(",
"UPLOAD_RETRY_FAILURE",
",",
"maxRetryCount",
")",
")",
";",
"}"
]
| Upload directory to specified FTP server with retries.
@param ftpServer
@param username
@param password
@param sourceDirectory
@param targetDirectory
@param maxRetryCount
@throws MojoExecutionException | [
"Upload",
"directory",
"to",
"specified",
"FTP",
"server",
"with",
"retries",
"."
]
| train | https://github.com/Microsoft/azure-maven-plugins/blob/a254902e820185df1823b1d692c7c1d119490b1e/azure-maven-plugin-lib/src/main/java/com/microsoft/azure/maven/FTPUploader.java#L57-L73 |
aspectran/aspectran | core/src/main/java/com/aspectran/core/util/ReflectionUtils.java | ReflectionUtils.getTypeDifferenceWeight | public static float getTypeDifferenceWeight(Class<?>[] srcArgs, Class<?>[] destArgs) {
"""
Returns the sum of the object transformation cost for each class in the source
argument list.
@param srcArgs the source arguments
@param destArgs the destination arguments
@return the accumulated weight for all arguments
"""
float weight = 0.0f;
for (int i = 0; i < srcArgs.length; i++) {
Class<?> srcClass = srcArgs[i];
Class<?> destClass = destArgs[i];
weight += getTypeDifferenceWeight(srcClass, destClass);
if (weight == Float.MAX_VALUE) {
break;
}
}
return weight;
} | java | public static float getTypeDifferenceWeight(Class<?>[] srcArgs, Class<?>[] destArgs) {
float weight = 0.0f;
for (int i = 0; i < srcArgs.length; i++) {
Class<?> srcClass = srcArgs[i];
Class<?> destClass = destArgs[i];
weight += getTypeDifferenceWeight(srcClass, destClass);
if (weight == Float.MAX_VALUE) {
break;
}
}
return weight;
} | [
"public",
"static",
"float",
"getTypeDifferenceWeight",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
"srcArgs",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"destArgs",
")",
"{",
"float",
"weight",
"=",
"0.0f",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"srcArgs",
".",
"length",
";",
"i",
"++",
")",
"{",
"Class",
"<",
"?",
">",
"srcClass",
"=",
"srcArgs",
"[",
"i",
"]",
";",
"Class",
"<",
"?",
">",
"destClass",
"=",
"destArgs",
"[",
"i",
"]",
";",
"weight",
"+=",
"getTypeDifferenceWeight",
"(",
"srcClass",
",",
"destClass",
")",
";",
"if",
"(",
"weight",
"==",
"Float",
".",
"MAX_VALUE",
")",
"{",
"break",
";",
"}",
"}",
"return",
"weight",
";",
"}"
]
| Returns the sum of the object transformation cost for each class in the source
argument list.
@param srcArgs the source arguments
@param destArgs the destination arguments
@return the accumulated weight for all arguments | [
"Returns",
"the",
"sum",
"of",
"the",
"object",
"transformation",
"cost",
"for",
"each",
"class",
"in",
"the",
"source",
"argument",
"list",
"."
]
| train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ReflectionUtils.java#L134-L145 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/SerializerBase.java | SerializerBase.fireCDATAEvent | protected void fireCDATAEvent(char[] chars, int start, int length)
throws org.xml.sax.SAXException {
"""
Report the CDATA trace event
@param chars content of CDATA
@param start starting index of characters to output
@param length number of characters to output
"""
if (m_tracer != null)
{
flushMyWriter();
m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CDATA, chars, start,length);
}
} | java | protected void fireCDATAEvent(char[] chars, int start, int length)
throws org.xml.sax.SAXException
{
if (m_tracer != null)
{
flushMyWriter();
m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CDATA, chars, start,length);
}
} | [
"protected",
"void",
"fireCDATAEvent",
"(",
"char",
"[",
"]",
"chars",
",",
"int",
"start",
",",
"int",
"length",
")",
"throws",
"org",
".",
"xml",
".",
"sax",
".",
"SAXException",
"{",
"if",
"(",
"m_tracer",
"!=",
"null",
")",
"{",
"flushMyWriter",
"(",
")",
";",
"m_tracer",
".",
"fireGenerateEvent",
"(",
"SerializerTrace",
".",
"EVENTTYPE_CDATA",
",",
"chars",
",",
"start",
",",
"length",
")",
";",
"}",
"}"
]
| Report the CDATA trace event
@param chars content of CDATA
@param start starting index of characters to output
@param length number of characters to output | [
"Report",
"the",
"CDATA",
"trace",
"event"
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/SerializerBase.java#L1045-L1053 |
rjstanford/protea-http | src/main/java/cc/protea/util/http/Message.java | Message.addHeader | @SuppressWarnings("unchecked")
public T addHeader(final String name, final String value) {
"""
Adds a single header value to the Message.
@param name
The header name.
@param value
The header value
@return this Message, to support chained method calls
"""
List<String> values = new ArrayList<String>();
values.add(value);
this.headers.put(name, values);
return (T) this;
} | java | @SuppressWarnings("unchecked")
public T addHeader(final String name, final String value) {
List<String> values = new ArrayList<String>();
values.add(value);
this.headers.put(name, values);
return (T) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"addHeader",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"value",
")",
"{",
"List",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"values",
".",
"add",
"(",
"value",
")",
";",
"this",
".",
"headers",
".",
"put",
"(",
"name",
",",
"values",
")",
";",
"return",
"(",
"T",
")",
"this",
";",
"}"
]
| Adds a single header value to the Message.
@param name
The header name.
@param value
The header value
@return this Message, to support chained method calls | [
"Adds",
"a",
"single",
"header",
"value",
"to",
"the",
"Message",
"."
]
| train | https://github.com/rjstanford/protea-http/blob/4d4a18805639181a738faff199e39d58337169ea/src/main/java/cc/protea/util/http/Message.java#L104-L111 |
cryptomator/webdav-nio-adapter | src/main/java/org/cryptomator/frontend/webdav/mount/ProcessUtil.java | ProcessUtil.waitFor | public static void waitFor(Process proc, long timeout, TimeUnit unit) throws CommandTimeoutException {
"""
Waits for the process to terminate or throws an exception if it fails to do so within the given timeout.
@param proc A started process
@param timeout Maximum time to wait
@param unit Time unit of <code>timeout</code>
@throws CommandTimeoutException Thrown in case of a timeout
"""
try {
boolean finishedInTime = proc.waitFor(timeout, unit);
if (!finishedInTime) {
proc.destroyForcibly();
throw new CommandTimeoutException();
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
} | java | public static void waitFor(Process proc, long timeout, TimeUnit unit) throws CommandTimeoutException {
try {
boolean finishedInTime = proc.waitFor(timeout, unit);
if (!finishedInTime) {
proc.destroyForcibly();
throw new CommandTimeoutException();
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
} | [
"public",
"static",
"void",
"waitFor",
"(",
"Process",
"proc",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"CommandTimeoutException",
"{",
"try",
"{",
"boolean",
"finishedInTime",
"=",
"proc",
".",
"waitFor",
"(",
"timeout",
",",
"unit",
")",
";",
"if",
"(",
"!",
"finishedInTime",
")",
"{",
"proc",
".",
"destroyForcibly",
"(",
")",
";",
"throw",
"new",
"CommandTimeoutException",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"}"
]
| Waits for the process to terminate or throws an exception if it fails to do so within the given timeout.
@param proc A started process
@param timeout Maximum time to wait
@param unit Time unit of <code>timeout</code>
@throws CommandTimeoutException Thrown in case of a timeout | [
"Waits",
"for",
"the",
"process",
"to",
"terminate",
"or",
"throws",
"an",
"exception",
"if",
"it",
"fails",
"to",
"do",
"so",
"within",
"the",
"given",
"timeout",
"."
]
| train | https://github.com/cryptomator/webdav-nio-adapter/blob/55b0d7dccea9a4ede0a30a95583d8f04c8a86d18/src/main/java/org/cryptomator/frontend/webdav/mount/ProcessUtil.java#L63-L73 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java | ArgumentAttr.attribArg | Type attribArg(JCTree tree, Env<AttrContext> env) {
"""
Main entry point for attributing an argument with given tree and attribution environment.
"""
Env<AttrContext> prevEnv = this.env;
try {
this.env = env;
tree.accept(this);
return result;
} finally {
this.env = prevEnv;
}
} | java | Type attribArg(JCTree tree, Env<AttrContext> env) {
Env<AttrContext> prevEnv = this.env;
try {
this.env = env;
tree.accept(this);
return result;
} finally {
this.env = prevEnv;
}
} | [
"Type",
"attribArg",
"(",
"JCTree",
"tree",
",",
"Env",
"<",
"AttrContext",
">",
"env",
")",
"{",
"Env",
"<",
"AttrContext",
">",
"prevEnv",
"=",
"this",
".",
"env",
";",
"try",
"{",
"this",
".",
"env",
"=",
"env",
";",
"tree",
".",
"accept",
"(",
"this",
")",
";",
"return",
"result",
";",
"}",
"finally",
"{",
"this",
".",
"env",
"=",
"prevEnv",
";",
"}",
"}"
]
| Main entry point for attributing an argument with given tree and attribution environment. | [
"Main",
"entry",
"point",
"for",
"attributing",
"an",
"argument",
"with",
"given",
"tree",
"and",
"attribution",
"environment",
"."
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java#L189-L198 |
apereo/cas | core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/resolver/impl/ServiceTicketRequestWebflowEventResolver.java | ServiceTicketRequestWebflowEventResolver.grantServiceTicket | protected Event grantServiceTicket(final RequestContext context) {
"""
Grant service ticket for the given credential based on the service and tgt
that are found in the request context.
@param context the context
@return the resulting event. Warning, authentication failure or error.
@since 4.1.0
"""
val ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context);
val credential = getCredentialFromContext(context);
try {
val service = WebUtils.getService(context);
val authn = getWebflowEventResolutionConfigurationContext().getTicketRegistrySupport().getAuthenticationFrom(ticketGrantingTicketId);
val registeredService = getWebflowEventResolutionConfigurationContext().getServicesManager().findServiceBy(service);
if (authn != null && registeredService != null) {
LOGGER.debug("Enforcing access strategy policies for registered service [{}] and principal [{}]", registeredService, authn.getPrincipal());
val audit = AuditableContext.builder().service(service)
.authentication(authn)
.registeredService(registeredService)
.retrievePrincipalAttributesFromReleasePolicy(Boolean.TRUE)
.build();
val accessResult = getWebflowEventResolutionConfigurationContext().getRegisteredServiceAccessStrategyEnforcer().execute(audit);
accessResult.throwExceptionIfNeeded();
}
val authenticationResult =
getWebflowEventResolutionConfigurationContext().getAuthenticationSystemSupport()
.handleAndFinalizeSingleAuthenticationTransaction(service, credential);
val serviceTicketId = getWebflowEventResolutionConfigurationContext().getCentralAuthenticationService()
.grantServiceTicket(ticketGrantingTicketId, service, authenticationResult);
WebUtils.putServiceTicketInRequestScope(context, serviceTicketId);
WebUtils.putWarnCookieIfRequestParameterPresent(getWebflowEventResolutionConfigurationContext().getWarnCookieGenerator(), context);
return newEvent(CasWebflowConstants.TRANSITION_ID_WARN);
} catch (final AuthenticationException | AbstractTicketException e) {
return newEvent(CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, e);
}
} | java | protected Event grantServiceTicket(final RequestContext context) {
val ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context);
val credential = getCredentialFromContext(context);
try {
val service = WebUtils.getService(context);
val authn = getWebflowEventResolutionConfigurationContext().getTicketRegistrySupport().getAuthenticationFrom(ticketGrantingTicketId);
val registeredService = getWebflowEventResolutionConfigurationContext().getServicesManager().findServiceBy(service);
if (authn != null && registeredService != null) {
LOGGER.debug("Enforcing access strategy policies for registered service [{}] and principal [{}]", registeredService, authn.getPrincipal());
val audit = AuditableContext.builder().service(service)
.authentication(authn)
.registeredService(registeredService)
.retrievePrincipalAttributesFromReleasePolicy(Boolean.TRUE)
.build();
val accessResult = getWebflowEventResolutionConfigurationContext().getRegisteredServiceAccessStrategyEnforcer().execute(audit);
accessResult.throwExceptionIfNeeded();
}
val authenticationResult =
getWebflowEventResolutionConfigurationContext().getAuthenticationSystemSupport()
.handleAndFinalizeSingleAuthenticationTransaction(service, credential);
val serviceTicketId = getWebflowEventResolutionConfigurationContext().getCentralAuthenticationService()
.grantServiceTicket(ticketGrantingTicketId, service, authenticationResult);
WebUtils.putServiceTicketInRequestScope(context, serviceTicketId);
WebUtils.putWarnCookieIfRequestParameterPresent(getWebflowEventResolutionConfigurationContext().getWarnCookieGenerator(), context);
return newEvent(CasWebflowConstants.TRANSITION_ID_WARN);
} catch (final AuthenticationException | AbstractTicketException e) {
return newEvent(CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, e);
}
} | [
"protected",
"Event",
"grantServiceTicket",
"(",
"final",
"RequestContext",
"context",
")",
"{",
"val",
"ticketGrantingTicketId",
"=",
"WebUtils",
".",
"getTicketGrantingTicketId",
"(",
"context",
")",
";",
"val",
"credential",
"=",
"getCredentialFromContext",
"(",
"context",
")",
";",
"try",
"{",
"val",
"service",
"=",
"WebUtils",
".",
"getService",
"(",
"context",
")",
";",
"val",
"authn",
"=",
"getWebflowEventResolutionConfigurationContext",
"(",
")",
".",
"getTicketRegistrySupport",
"(",
")",
".",
"getAuthenticationFrom",
"(",
"ticketGrantingTicketId",
")",
";",
"val",
"registeredService",
"=",
"getWebflowEventResolutionConfigurationContext",
"(",
")",
".",
"getServicesManager",
"(",
")",
".",
"findServiceBy",
"(",
"service",
")",
";",
"if",
"(",
"authn",
"!=",
"null",
"&&",
"registeredService",
"!=",
"null",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Enforcing access strategy policies for registered service [{}] and principal [{}]\"",
",",
"registeredService",
",",
"authn",
".",
"getPrincipal",
"(",
")",
")",
";",
"val",
"audit",
"=",
"AuditableContext",
".",
"builder",
"(",
")",
".",
"service",
"(",
"service",
")",
".",
"authentication",
"(",
"authn",
")",
".",
"registeredService",
"(",
"registeredService",
")",
".",
"retrievePrincipalAttributesFromReleasePolicy",
"(",
"Boolean",
".",
"TRUE",
")",
".",
"build",
"(",
")",
";",
"val",
"accessResult",
"=",
"getWebflowEventResolutionConfigurationContext",
"(",
")",
".",
"getRegisteredServiceAccessStrategyEnforcer",
"(",
")",
".",
"execute",
"(",
"audit",
")",
";",
"accessResult",
".",
"throwExceptionIfNeeded",
"(",
")",
";",
"}",
"val",
"authenticationResult",
"=",
"getWebflowEventResolutionConfigurationContext",
"(",
")",
".",
"getAuthenticationSystemSupport",
"(",
")",
".",
"handleAndFinalizeSingleAuthenticationTransaction",
"(",
"service",
",",
"credential",
")",
";",
"val",
"serviceTicketId",
"=",
"getWebflowEventResolutionConfigurationContext",
"(",
")",
".",
"getCentralAuthenticationService",
"(",
")",
".",
"grantServiceTicket",
"(",
"ticketGrantingTicketId",
",",
"service",
",",
"authenticationResult",
")",
";",
"WebUtils",
".",
"putServiceTicketInRequestScope",
"(",
"context",
",",
"serviceTicketId",
")",
";",
"WebUtils",
".",
"putWarnCookieIfRequestParameterPresent",
"(",
"getWebflowEventResolutionConfigurationContext",
"(",
")",
".",
"getWarnCookieGenerator",
"(",
")",
",",
"context",
")",
";",
"return",
"newEvent",
"(",
"CasWebflowConstants",
".",
"TRANSITION_ID_WARN",
")",
";",
"}",
"catch",
"(",
"final",
"AuthenticationException",
"|",
"AbstractTicketException",
"e",
")",
"{",
"return",
"newEvent",
"(",
"CasWebflowConstants",
".",
"TRANSITION_ID_AUTHENTICATION_FAILURE",
",",
"e",
")",
";",
"}",
"}"
]
| Grant service ticket for the given credential based on the service and tgt
that are found in the request context.
@param context the context
@return the resulting event. Warning, authentication failure or error.
@since 4.1.0 | [
"Grant",
"service",
"ticket",
"for",
"the",
"given",
"credential",
"based",
"on",
"the",
"service",
"and",
"tgt",
"that",
"are",
"found",
"in",
"the",
"request",
"context",
"."
]
| train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/resolver/impl/ServiceTicketRequestWebflowEventResolver.java#L89-L122 |
netty/netty | buffer/src/main/java/io/netty/buffer/Unpooled.java | Unpooled.copiedBuffer | public static ByteBuf copiedBuffer(char[] array, Charset charset) {
"""
Creates a new big-endian buffer whose content is the specified
{@code array} encoded in the specified {@code charset}.
The new buffer's {@code readerIndex} and {@code writerIndex} are
{@code 0} and the length of the encoded string respectively.
"""
if (array == null) {
throw new NullPointerException("array");
}
return copiedBuffer(array, 0, array.length, charset);
} | java | public static ByteBuf copiedBuffer(char[] array, Charset charset) {
if (array == null) {
throw new NullPointerException("array");
}
return copiedBuffer(array, 0, array.length, charset);
} | [
"public",
"static",
"ByteBuf",
"copiedBuffer",
"(",
"char",
"[",
"]",
"array",
",",
"Charset",
"charset",
")",
"{",
"if",
"(",
"array",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"array\"",
")",
";",
"}",
"return",
"copiedBuffer",
"(",
"array",
",",
"0",
",",
"array",
".",
"length",
",",
"charset",
")",
";",
"}"
]
| Creates a new big-endian buffer whose content is the specified
{@code array} encoded in the specified {@code charset}.
The new buffer's {@code readerIndex} and {@code writerIndex} are
{@code 0} and the length of the encoded string respectively. | [
"Creates",
"a",
"new",
"big",
"-",
"endian",
"buffer",
"whose",
"content",
"is",
"the",
"specified",
"{"
]
| train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/buffer/src/main/java/io/netty/buffer/Unpooled.java#L628-L633 |
hltcoe/annotated-nyt | src/main/java/com/nytlabs/corpus/NYTCorpusDocumentParser.java | NYTCorpusDocumentParser.parseNYTCorpusDocumentFromFile | public NYTCorpusDocument parseNYTCorpusDocumentFromFile(InputStream is, boolean validating) {
"""
Parse an New York Times Document from an {@link InputStream}.
@param is
The {@link InputStream} from which to parse the document.
@param validating
True if the file is to be validated against the nitf DTD and
false if it is not. It is recommended that validation be
disabled, as all documents in the corpus have previously been
validated against the NITF DTD.
@return The parsed document, or null if an error occurs.
"""
Document document = null;
if (validating) {
document = loadValidating(is);
} else {
document = loadNonValidating(is);
}
return parseNYTCorpusDocumentFromDOMDocument(is, document);
} | java | public NYTCorpusDocument parseNYTCorpusDocumentFromFile(InputStream is, boolean validating) {
Document document = null;
if (validating) {
document = loadValidating(is);
} else {
document = loadNonValidating(is);
}
return parseNYTCorpusDocumentFromDOMDocument(is, document);
} | [
"public",
"NYTCorpusDocument",
"parseNYTCorpusDocumentFromFile",
"(",
"InputStream",
"is",
",",
"boolean",
"validating",
")",
"{",
"Document",
"document",
"=",
"null",
";",
"if",
"(",
"validating",
")",
"{",
"document",
"=",
"loadValidating",
"(",
"is",
")",
";",
"}",
"else",
"{",
"document",
"=",
"loadNonValidating",
"(",
"is",
")",
";",
"}",
"return",
"parseNYTCorpusDocumentFromDOMDocument",
"(",
"is",
",",
"document",
")",
";",
"}"
]
| Parse an New York Times Document from an {@link InputStream}.
@param is
The {@link InputStream} from which to parse the document.
@param validating
True if the file is to be validated against the nitf DTD and
false if it is not. It is recommended that validation be
disabled, as all documents in the corpus have previously been
validated against the NITF DTD.
@return The parsed document, or null if an error occurs. | [
"Parse",
"an",
"New",
"York",
"Times",
"Document",
"from",
"an",
"{",
"@link",
"InputStream",
"}",
"."
]
| train | https://github.com/hltcoe/annotated-nyt/blob/0a4daa97705591cefea9de61614770ae2665a48e/src/main/java/com/nytlabs/corpus/NYTCorpusDocumentParser.java#L329-L338 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfLayer.java | PdfLayer.createTitle | public static PdfLayer createTitle(String title, PdfWriter writer) {
"""
Creates a title layer. A title layer is not really a layer but a collection of layers
under the same title heading.
@param title the title text
@param writer the <CODE>PdfWriter</CODE>
@return the title layer
"""
if (title == null)
throw new NullPointerException("Title cannot be null.");
PdfLayer layer = new PdfLayer(title);
writer.registerLayer(layer);
return layer;
} | java | public static PdfLayer createTitle(String title, PdfWriter writer) {
if (title == null)
throw new NullPointerException("Title cannot be null.");
PdfLayer layer = new PdfLayer(title);
writer.registerLayer(layer);
return layer;
} | [
"public",
"static",
"PdfLayer",
"createTitle",
"(",
"String",
"title",
",",
"PdfWriter",
"writer",
")",
"{",
"if",
"(",
"title",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Title cannot be null.\"",
")",
";",
"PdfLayer",
"layer",
"=",
"new",
"PdfLayer",
"(",
"title",
")",
";",
"writer",
".",
"registerLayer",
"(",
"layer",
")",
";",
"return",
"layer",
";",
"}"
]
| Creates a title layer. A title layer is not really a layer but a collection of layers
under the same title heading.
@param title the title text
@param writer the <CODE>PdfWriter</CODE>
@return the title layer | [
"Creates",
"a",
"title",
"layer",
".",
"A",
"title",
"layer",
"is",
"not",
"really",
"a",
"layer",
"but",
"a",
"collection",
"of",
"layers",
"under",
"the",
"same",
"title",
"heading",
"."
]
| train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfLayer.java#L85-L91 |
stagemonitor/stagemonitor | stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationRegistry.java | ConfigurationRegistry.addConfigurationSource | public void addConfigurationSource(ConfigurationSource configurationSource, boolean firstPrio) {
"""
Adds a configuration source to the configuration.
<p>
Don't forget to call {@link #reloadAllConfigurationOptions()} or {@link #reloadDynamicConfigurationOptions()}
after adding all configuration sources.
@param configurationSource the configuration source to add
@param firstPrio whether the configuration source should be first or last priority
"""
if (configurationSource == null) {
return;
}
if (firstPrio) {
configurationSources.add(0, configurationSource);
} else {
configurationSources.add(configurationSource);
}
} | java | public void addConfigurationSource(ConfigurationSource configurationSource, boolean firstPrio) {
if (configurationSource == null) {
return;
}
if (firstPrio) {
configurationSources.add(0, configurationSource);
} else {
configurationSources.add(configurationSource);
}
} | [
"public",
"void",
"addConfigurationSource",
"(",
"ConfigurationSource",
"configurationSource",
",",
"boolean",
"firstPrio",
")",
"{",
"if",
"(",
"configurationSource",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"firstPrio",
")",
"{",
"configurationSources",
".",
"add",
"(",
"0",
",",
"configurationSource",
")",
";",
"}",
"else",
"{",
"configurationSources",
".",
"add",
"(",
"configurationSource",
")",
";",
"}",
"}"
]
| Adds a configuration source to the configuration.
<p>
Don't forget to call {@link #reloadAllConfigurationOptions()} or {@link #reloadDynamicConfigurationOptions()}
after adding all configuration sources.
@param configurationSource the configuration source to add
@param firstPrio whether the configuration source should be first or last priority | [
"Adds",
"a",
"configuration",
"source",
"to",
"the",
"configuration",
".",
"<p",
">",
"Don",
"t",
"forget",
"to",
"call",
"{",
"@link",
"#reloadAllConfigurationOptions",
"()",
"}",
"or",
"{",
"@link",
"#reloadDynamicConfigurationOptions",
"()",
"}",
"after",
"adding",
"all",
"configuration",
"sources",
"."
]
| train | https://github.com/stagemonitor/stagemonitor/blob/7a1bf6848906f816aa465983f602ea1f1e8f2b7b/stagemonitor-configuration/src/main/java/org/stagemonitor/configuration/ConfigurationRegistry.java#L358-L367 |
h2oai/h2o-2 | src/main/java/water/TaskGetKey.java | TaskGetKey.onAck | @Override public void onAck() {
"""
Received an ACK; executes on the node asking&receiving the Value
"""
if( _val != null ) { // Set transient fields after deserializing
assert !_xkey.home() && _val._key == null;
_val._key = _xkey;
}
// Now update the local store, caching the result.
// We only started down the TGK path because we missed locally, so we only
// expect to find a NULL in the local store. If somebody else installed
// another value (e.g. a racing TGK, or racing local Put) this value must
// be more recent than our NULL - but is UNORDERED relative to the Value
// returned from the Home. We'll take the local Value to preserve ordering
// and rely on invalidates from Home to force refreshes as needed.
// Hence we can do a blind putIfMatch here over a null or empty Value
// If it fails, what is there is also the TGK result.
Value old = H2O.raw_get(_xkey);
if( old != null && !old.isEmpty() ) old=null;
Value res = H2O.putIfMatch(_xkey,_val,old);
if( res != old ) _val = res;
} | java | @Override public void onAck() {
if( _val != null ) { // Set transient fields after deserializing
assert !_xkey.home() && _val._key == null;
_val._key = _xkey;
}
// Now update the local store, caching the result.
// We only started down the TGK path because we missed locally, so we only
// expect to find a NULL in the local store. If somebody else installed
// another value (e.g. a racing TGK, or racing local Put) this value must
// be more recent than our NULL - but is UNORDERED relative to the Value
// returned from the Home. We'll take the local Value to preserve ordering
// and rely on invalidates from Home to force refreshes as needed.
// Hence we can do a blind putIfMatch here over a null or empty Value
// If it fails, what is there is also the TGK result.
Value old = H2O.raw_get(_xkey);
if( old != null && !old.isEmpty() ) old=null;
Value res = H2O.putIfMatch(_xkey,_val,old);
if( res != old ) _val = res;
} | [
"@",
"Override",
"public",
"void",
"onAck",
"(",
")",
"{",
"if",
"(",
"_val",
"!=",
"null",
")",
"{",
"// Set transient fields after deserializing",
"assert",
"!",
"_xkey",
".",
"home",
"(",
")",
"&&",
"_val",
".",
"_key",
"==",
"null",
";",
"_val",
".",
"_key",
"=",
"_xkey",
";",
"}",
"// Now update the local store, caching the result.",
"// We only started down the TGK path because we missed locally, so we only",
"// expect to find a NULL in the local store. If somebody else installed",
"// another value (e.g. a racing TGK, or racing local Put) this value must",
"// be more recent than our NULL - but is UNORDERED relative to the Value",
"// returned from the Home. We'll take the local Value to preserve ordering",
"// and rely on invalidates from Home to force refreshes as needed.",
"// Hence we can do a blind putIfMatch here over a null or empty Value",
"// If it fails, what is there is also the TGK result.",
"Value",
"old",
"=",
"H2O",
".",
"raw_get",
"(",
"_xkey",
")",
";",
"if",
"(",
"old",
"!=",
"null",
"&&",
"!",
"old",
".",
"isEmpty",
"(",
")",
")",
"old",
"=",
"null",
";",
"Value",
"res",
"=",
"H2O",
".",
"putIfMatch",
"(",
"_xkey",
",",
"_val",
",",
"old",
")",
";",
"if",
"(",
"res",
"!=",
"old",
")",
"_val",
"=",
"res",
";",
"}"
]
| Received an ACK; executes on the node asking&receiving the Value | [
"Received",
"an",
"ACK",
";",
"executes",
"on",
"the",
"node",
"asking&receiving",
"the",
"Value"
]
| train | https://github.com/h2oai/h2o-2/blob/be350f3f2c2fb6f135cc07c41f83fd0e4f521ac1/src/main/java/water/TaskGetKey.java#L64-L84 |
joelittlejohn/jsonschema2pojo | jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/util/NameHelper.java | NameHelper.getFieldName | public String getFieldName(String propertyName, JsonNode node) {
"""
Get name of the field generated from property.
@param propertyName
@param node
@return
"""
if (node != null && node.has("javaName")) {
propertyName = node.get("javaName").textValue();
}
return propertyName;
} | java | public String getFieldName(String propertyName, JsonNode node) {
if (node != null && node.has("javaName")) {
propertyName = node.get("javaName").textValue();
}
return propertyName;
} | [
"public",
"String",
"getFieldName",
"(",
"String",
"propertyName",
",",
"JsonNode",
"node",
")",
"{",
"if",
"(",
"node",
"!=",
"null",
"&&",
"node",
".",
"has",
"(",
"\"javaName\"",
")",
")",
"{",
"propertyName",
"=",
"node",
".",
"get",
"(",
"\"javaName\"",
")",
".",
"textValue",
"(",
")",
";",
"}",
"return",
"propertyName",
";",
"}"
]
| Get name of the field generated from property.
@param propertyName
@param node
@return | [
"Get",
"name",
"of",
"the",
"field",
"generated",
"from",
"property",
"."
]
| train | https://github.com/joelittlejohn/jsonschema2pojo/blob/0552b80db93214eb186e4ae45b40866cc1e7eb84/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/util/NameHelper.java#L166-L173 |
morimekta/providence | providence-generator-java/src/main/java/net/morimekta/providence/generator/format/java/program/extras/HazelcastPortableProgramFormatter.java | HazelcastPortableProgramFormatter.appendPopulateMethod | private void appendPopulateMethod(List<CStructDescriptor> messages) {
"""
Method to append populate methods for the Hazelcast Config.
@param messages List with CStructDescriptor to iterate through.
<pre>
{@code
public static final com.hazelcast.config.Config populateConfig(com.hazelcast.config.Config config) {
PortableFactoryImpl instance = new PortableFactoryImpl();
config.getSerializationConfig().addPortableFactory(FACTORY_ID, instance);
...
return config;
}
}
</pre>
"""
writer.formatln("public static final %s populateConfig(%s %s, int %s) {",
Config.class.getName(),
Config.class.getName(),
CONFIG,
PORTABLE_VERSION)
.begin()
.formatln("%s %s = new %s();", FACTORY_IMPL, INSTANCE, FACTORY_IMPL)
.formatln("%s.getSerializationConfig().addPortableFactory(%s, %s);", CONFIG, FACTORY_ID, INSTANCE)
.formatln("%s.getSerializationConfig().setPortableVersion(%s);", CONFIG, PORTABLE_VERSION)
.appendln()
.formatln("%s.getSerializationConfig()", CONFIG)
.begin()
.begin();
for (CStructDescriptor struct : messages) {
writer.formatln(".addClassDefinition(%s.%s(%s))",
INSTANCE,
camelCase("get", struct.getName() + "Definition"),
PORTABLE_VERSION);
}
writer.append(";")
.end()
.end()
.formatln("return %s;", CONFIG)
.end()
.appendln("}")
.newline();
} | java | private void appendPopulateMethod(List<CStructDescriptor> messages) {
writer.formatln("public static final %s populateConfig(%s %s, int %s) {",
Config.class.getName(),
Config.class.getName(),
CONFIG,
PORTABLE_VERSION)
.begin()
.formatln("%s %s = new %s();", FACTORY_IMPL, INSTANCE, FACTORY_IMPL)
.formatln("%s.getSerializationConfig().addPortableFactory(%s, %s);", CONFIG, FACTORY_ID, INSTANCE)
.formatln("%s.getSerializationConfig().setPortableVersion(%s);", CONFIG, PORTABLE_VERSION)
.appendln()
.formatln("%s.getSerializationConfig()", CONFIG)
.begin()
.begin();
for (CStructDescriptor struct : messages) {
writer.formatln(".addClassDefinition(%s.%s(%s))",
INSTANCE,
camelCase("get", struct.getName() + "Definition"),
PORTABLE_VERSION);
}
writer.append(";")
.end()
.end()
.formatln("return %s;", CONFIG)
.end()
.appendln("}")
.newline();
} | [
"private",
"void",
"appendPopulateMethod",
"(",
"List",
"<",
"CStructDescriptor",
">",
"messages",
")",
"{",
"writer",
".",
"formatln",
"(",
"\"public static final %s populateConfig(%s %s, int %s) {\"",
",",
"Config",
".",
"class",
".",
"getName",
"(",
")",
",",
"Config",
".",
"class",
".",
"getName",
"(",
")",
",",
"CONFIG",
",",
"PORTABLE_VERSION",
")",
".",
"begin",
"(",
")",
".",
"formatln",
"(",
"\"%s %s = new %s();\"",
",",
"FACTORY_IMPL",
",",
"INSTANCE",
",",
"FACTORY_IMPL",
")",
".",
"formatln",
"(",
"\"%s.getSerializationConfig().addPortableFactory(%s, %s);\"",
",",
"CONFIG",
",",
"FACTORY_ID",
",",
"INSTANCE",
")",
".",
"formatln",
"(",
"\"%s.getSerializationConfig().setPortableVersion(%s);\"",
",",
"CONFIG",
",",
"PORTABLE_VERSION",
")",
".",
"appendln",
"(",
")",
".",
"formatln",
"(",
"\"%s.getSerializationConfig()\"",
",",
"CONFIG",
")",
".",
"begin",
"(",
")",
".",
"begin",
"(",
")",
";",
"for",
"(",
"CStructDescriptor",
"struct",
":",
"messages",
")",
"{",
"writer",
".",
"formatln",
"(",
"\".addClassDefinition(%s.%s(%s))\"",
",",
"INSTANCE",
",",
"camelCase",
"(",
"\"get\"",
",",
"struct",
".",
"getName",
"(",
")",
"+",
"\"Definition\"",
")",
",",
"PORTABLE_VERSION",
")",
";",
"}",
"writer",
".",
"append",
"(",
"\";\"",
")",
".",
"end",
"(",
")",
".",
"end",
"(",
")",
".",
"formatln",
"(",
"\"return %s;\"",
",",
"CONFIG",
")",
".",
"end",
"(",
")",
".",
"appendln",
"(",
"\"}\"",
")",
".",
"newline",
"(",
")",
";",
"}"
]
| Method to append populate methods for the Hazelcast Config.
@param messages List with CStructDescriptor to iterate through.
<pre>
{@code
public static final com.hazelcast.config.Config populateConfig(com.hazelcast.config.Config config) {
PortableFactoryImpl instance = new PortableFactoryImpl();
config.getSerializationConfig().addPortableFactory(FACTORY_ID, instance);
...
return config;
}
}
</pre> | [
"Method",
"to",
"append",
"populate",
"methods",
"for",
"the",
"Hazelcast",
"Config",
"."
]
| train | https://github.com/morimekta/providence/blob/7c17dc1c96b1a1d4b9ff942c2cfeb725278bd3aa/providence-generator-java/src/main/java/net/morimekta/providence/generator/format/java/program/extras/HazelcastPortableProgramFormatter.java#L205-L232 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java | AbstractQueryProtocol.readPacket | private void readPacket(Results results) throws SQLException {
"""
Read server response packet.
@param results result object
@throws SQLException if sub-result connection fail
@see <a href="https://mariadb.com/kb/en/mariadb/4-server-response-packets/">server response
packets</a>
"""
Buffer buffer;
try {
buffer = reader.getPacket(true);
} catch (IOException e) {
throw handleIoException(e);
}
switch (buffer.getByteAt(0)) {
//*********************************************************************************************************
//* OK response
//*********************************************************************************************************
case OK:
readOkPacket(buffer, results);
break;
//*********************************************************************************************************
//* ERROR response
//*********************************************************************************************************
case ERROR:
throw readErrorPacket(buffer, results);
//*********************************************************************************************************
//* LOCAL INFILE response
//*********************************************************************************************************
case LOCAL_INFILE:
readLocalInfilePacket(buffer, results);
break;
//*********************************************************************************************************
//* ResultSet
//*********************************************************************************************************
default:
readResultSet(buffer, results);
break;
}
} | java | private void readPacket(Results results) throws SQLException {
Buffer buffer;
try {
buffer = reader.getPacket(true);
} catch (IOException e) {
throw handleIoException(e);
}
switch (buffer.getByteAt(0)) {
//*********************************************************************************************************
//* OK response
//*********************************************************************************************************
case OK:
readOkPacket(buffer, results);
break;
//*********************************************************************************************************
//* ERROR response
//*********************************************************************************************************
case ERROR:
throw readErrorPacket(buffer, results);
//*********************************************************************************************************
//* LOCAL INFILE response
//*********************************************************************************************************
case LOCAL_INFILE:
readLocalInfilePacket(buffer, results);
break;
//*********************************************************************************************************
//* ResultSet
//*********************************************************************************************************
default:
readResultSet(buffer, results);
break;
}
} | [
"private",
"void",
"readPacket",
"(",
"Results",
"results",
")",
"throws",
"SQLException",
"{",
"Buffer",
"buffer",
";",
"try",
"{",
"buffer",
"=",
"reader",
".",
"getPacket",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"handleIoException",
"(",
"e",
")",
";",
"}",
"switch",
"(",
"buffer",
".",
"getByteAt",
"(",
"0",
")",
")",
"{",
"//*********************************************************************************************************",
"//* OK response",
"//*********************************************************************************************************",
"case",
"OK",
":",
"readOkPacket",
"(",
"buffer",
",",
"results",
")",
";",
"break",
";",
"//*********************************************************************************************************",
"//* ERROR response",
"//*********************************************************************************************************",
"case",
"ERROR",
":",
"throw",
"readErrorPacket",
"(",
"buffer",
",",
"results",
")",
";",
"//*********************************************************************************************************",
"//* LOCAL INFILE response",
"//*********************************************************************************************************",
"case",
"LOCAL_INFILE",
":",
"readLocalInfilePacket",
"(",
"buffer",
",",
"results",
")",
";",
"break",
";",
"//*********************************************************************************************************",
"//* ResultSet",
"//*********************************************************************************************************",
"default",
":",
"readResultSet",
"(",
"buffer",
",",
"results",
")",
";",
"break",
";",
"}",
"}"
]
| Read server response packet.
@param results result object
@throws SQLException if sub-result connection fail
@see <a href="https://mariadb.com/kb/en/mariadb/4-server-response-packets/">server response
packets</a> | [
"Read",
"server",
"response",
"packet",
"."
]
| train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/protocol/AbstractQueryProtocol.java#L1432-L1471 |
bushidowallet/bushido-java-service | bushido-wallet-service/src/main/java/com/authy/api/Users.java | Users.createUser | public com.authy.api.User createUser(String email, String phone, String countryCode) {
"""
Create a new user using his e-mail, phone and country code.
@param email
@param phone
@param countryCode
@return a User instance
"""
User user = new User(email, phone, countryCode);
String content = this.post(NEW_USER_PATH, user);
return userFromXml(this.getStatus(), content);
} | java | public com.authy.api.User createUser(String email, String phone, String countryCode) {
User user = new User(email, phone, countryCode);
String content = this.post(NEW_USER_PATH, user);
return userFromXml(this.getStatus(), content);
} | [
"public",
"com",
".",
"authy",
".",
"api",
".",
"User",
"createUser",
"(",
"String",
"email",
",",
"String",
"phone",
",",
"String",
"countryCode",
")",
"{",
"User",
"user",
"=",
"new",
"User",
"(",
"email",
",",
"phone",
",",
"countryCode",
")",
";",
"String",
"content",
"=",
"this",
".",
"post",
"(",
"NEW_USER_PATH",
",",
"user",
")",
";",
"return",
"userFromXml",
"(",
"this",
".",
"getStatus",
"(",
")",
",",
"content",
")",
";",
"}"
]
| Create a new user using his e-mail, phone and country code.
@param email
@param phone
@param countryCode
@return a User instance | [
"Create",
"a",
"new",
"user",
"using",
"his",
"e",
"-",
"mail",
"phone",
"and",
"country",
"code",
"."
]
| train | https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-wallet-service/src/main/java/com/authy/api/Users.java#L43-L49 |
padrig64/ValidationFramework | validationframework-core/src/main/java/com/google/code/validationframework/base/validator/generalvalidator/GeneralValidator.java | GeneralValidator.addResultCollector | public void addResultCollector(ResultCollector<?, DPO> resultCollector) {
"""
Adds the specified result collector to the triggers and data providers.
@param resultCollector Result collector to be added.
"""
if (resultCollector != null) {
addTrigger(resultCollector);
addDataProvider(resultCollector);
}
} | java | public void addResultCollector(ResultCollector<?, DPO> resultCollector) {
if (resultCollector != null) {
addTrigger(resultCollector);
addDataProvider(resultCollector);
}
} | [
"public",
"void",
"addResultCollector",
"(",
"ResultCollector",
"<",
"?",
",",
"DPO",
">",
"resultCollector",
")",
"{",
"if",
"(",
"resultCollector",
"!=",
"null",
")",
"{",
"addTrigger",
"(",
"resultCollector",
")",
";",
"addDataProvider",
"(",
"resultCollector",
")",
";",
"}",
"}"
]
| Adds the specified result collector to the triggers and data providers.
@param resultCollector Result collector to be added. | [
"Adds",
"the",
"specified",
"result",
"collector",
"to",
"the",
"triggers",
"and",
"data",
"providers",
"."
]
| train | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-core/src/main/java/com/google/code/validationframework/base/validator/generalvalidator/GeneralValidator.java#L165-L170 |
Netflix/governator | governator-legacy/src/main/java/com/netflix/governator/configuration/ConfigurationKey.java | ConfigurationKey.getKey | public String getKey(Map<String, String> variableValues) {
"""
Return the final key applying variables as needed
@param variableValues map of variable names to values
@return the key
"""
StringBuilder key = new StringBuilder();
for ( ConfigurationKeyPart p : parts )
{
if ( p.isVariable() )
{
String value = variableValues.get(p.getValue());
if ( value == null )
{
log.warn("No value found for variable: " + p.getValue());
value = "";
}
key.append(value);
}
else
{
key.append(p.getValue());
}
}
return key.toString();
} | java | public String getKey(Map<String, String> variableValues)
{
StringBuilder key = new StringBuilder();
for ( ConfigurationKeyPart p : parts )
{
if ( p.isVariable() )
{
String value = variableValues.get(p.getValue());
if ( value == null )
{
log.warn("No value found for variable: " + p.getValue());
value = "";
}
key.append(value);
}
else
{
key.append(p.getValue());
}
}
return key.toString();
} | [
"public",
"String",
"getKey",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"variableValues",
")",
"{",
"StringBuilder",
"key",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"ConfigurationKeyPart",
"p",
":",
"parts",
")",
"{",
"if",
"(",
"p",
".",
"isVariable",
"(",
")",
")",
"{",
"String",
"value",
"=",
"variableValues",
".",
"get",
"(",
"p",
".",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"log",
".",
"warn",
"(",
"\"No value found for variable: \"",
"+",
"p",
".",
"getValue",
"(",
")",
")",
";",
"value",
"=",
"\"\"",
";",
"}",
"key",
".",
"append",
"(",
"value",
")",
";",
"}",
"else",
"{",
"key",
".",
"append",
"(",
"p",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"key",
".",
"toString",
"(",
")",
";",
"}"
]
| Return the final key applying variables as needed
@param variableValues map of variable names to values
@return the key | [
"Return",
"the",
"final",
"key",
"applying",
"variables",
"as",
"needed"
]
| train | https://github.com/Netflix/governator/blob/c1f4bb1518e759c61f2e9cad8a896ec6beba0294/governator-legacy/src/main/java/com/netflix/governator/configuration/ConfigurationKey.java#L60-L82 |
cwilper/ttff | src/main/java/com/github/cwilper/ttff/Sources.java | Sources.drain | public static <T> long drain(Source<T> source, Sink<T> sink)
throws IOException {
"""
Exhausts the given source, sending each item to the given sink.
<p>
The source will be automatically closed regardless of success.
@param source the source to exhaust.
@param sink the sink to send each item to.
@param <T> the type.
@return the number of items encountered.
@throws IOException if an I/O problem occurs.
"""
long count = 0L;
try {
while (source.hasNext()) {
count++;
sink.put(source.next());
}
return count;
} finally {
source.close();
}
} | java | public static <T> long drain(Source<T> source, Sink<T> sink)
throws IOException {
long count = 0L;
try {
while (source.hasNext()) {
count++;
sink.put(source.next());
}
return count;
} finally {
source.close();
}
} | [
"public",
"static",
"<",
"T",
">",
"long",
"drain",
"(",
"Source",
"<",
"T",
">",
"source",
",",
"Sink",
"<",
"T",
">",
"sink",
")",
"throws",
"IOException",
"{",
"long",
"count",
"=",
"0L",
";",
"try",
"{",
"while",
"(",
"source",
".",
"hasNext",
"(",
")",
")",
"{",
"count",
"++",
";",
"sink",
".",
"put",
"(",
"source",
".",
"next",
"(",
")",
")",
";",
"}",
"return",
"count",
";",
"}",
"finally",
"{",
"source",
".",
"close",
"(",
")",
";",
"}",
"}"
]
| Exhausts the given source, sending each item to the given sink.
<p>
The source will be automatically closed regardless of success.
@param source the source to exhaust.
@param sink the sink to send each item to.
@param <T> the type.
@return the number of items encountered.
@throws IOException if an I/O problem occurs. | [
"Exhausts",
"the",
"given",
"source",
"sending",
"each",
"item",
"to",
"the",
"given",
"sink",
".",
"<p",
">",
"The",
"source",
"will",
"be",
"automatically",
"closed",
"regardless",
"of",
"success",
"."
]
| train | https://github.com/cwilper/ttff/blob/b351883764546078128d69c2ff0a8431dd45796b/src/main/java/com/github/cwilper/ttff/Sources.java#L266-L278 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getAttributeInfo | protected AttributeInfo getAttributeInfo(String attr, boolean useOuterJoins, UserAlias aUserAlias, Map pathClasses) {
"""
Return the TableAlias and the PathInfo for an Attribute name<br>
field names in functions (ie: sum(name) ) are tried to resolve ie: name
from FIELDDESCRIPTOR , UPPER(name_test) from Criteria<br>
also resolve pathExpression adress.city or owner.konti.saldo
@param attr
@param useOuterJoins
@param aUserAlias
@param pathClasses
@return ColumnInfo
"""
AttributeInfo result = new AttributeInfo();
TableAlias tableAlias;
SqlHelper.PathInfo pathInfo = SqlHelper.splitPath(attr);
String colName = pathInfo.column;
int sp;
// BRJ:
// check if we refer to an attribute in the parent query
// this prefix is temporary !
if (colName.startsWith(Criteria.PARENT_QUERY_PREFIX) && m_parentStatement != null)
{
String[] fieldNameRef = {colName.substring(Criteria.PARENT_QUERY_PREFIX.length())};
return m_parentStatement.getAttributeInfo(fieldNameRef[0], useOuterJoins, aUserAlias, pathClasses);
}
sp = colName.lastIndexOf(".");
if (sp == -1)
{
tableAlias = getRoot();
}
else
{
String pathName = colName.substring(0, sp);
String[] fieldNameRef = {colName.substring(sp + 1)};
tableAlias = getTableAlias(pathName, useOuterJoins, aUserAlias, fieldNameRef, pathClasses);
/**
* if we have not found an alias by the pathName or
* aliasName (if given), try again because pathName
* may be an aliasname. it can be only and only if it is not
* a path, which means there may be no path separators (,)
* in the pathName.
*/
if ((tableAlias == null) && (colName.lastIndexOf(".") == -1))
{
/**
* pathName might be an alias, so check this first
*/
tableAlias = getTableAlias(pathName, useOuterJoins, new UserAlias(pathName, pathName, pathName), null, pathClasses);
}
if (tableAlias != null)
{
// correct column name to match the alias
// productGroup.groupName -> groupName
pathInfo.column = fieldNameRef[0];
}
}
result.tableAlias = tableAlias;
result.pathInfo = pathInfo;
return result;
} | java | protected AttributeInfo getAttributeInfo(String attr, boolean useOuterJoins, UserAlias aUserAlias, Map pathClasses)
{
AttributeInfo result = new AttributeInfo();
TableAlias tableAlias;
SqlHelper.PathInfo pathInfo = SqlHelper.splitPath(attr);
String colName = pathInfo.column;
int sp;
// BRJ:
// check if we refer to an attribute in the parent query
// this prefix is temporary !
if (colName.startsWith(Criteria.PARENT_QUERY_PREFIX) && m_parentStatement != null)
{
String[] fieldNameRef = {colName.substring(Criteria.PARENT_QUERY_PREFIX.length())};
return m_parentStatement.getAttributeInfo(fieldNameRef[0], useOuterJoins, aUserAlias, pathClasses);
}
sp = colName.lastIndexOf(".");
if (sp == -1)
{
tableAlias = getRoot();
}
else
{
String pathName = colName.substring(0, sp);
String[] fieldNameRef = {colName.substring(sp + 1)};
tableAlias = getTableAlias(pathName, useOuterJoins, aUserAlias, fieldNameRef, pathClasses);
/**
* if we have not found an alias by the pathName or
* aliasName (if given), try again because pathName
* may be an aliasname. it can be only and only if it is not
* a path, which means there may be no path separators (,)
* in the pathName.
*/
if ((tableAlias == null) && (colName.lastIndexOf(".") == -1))
{
/**
* pathName might be an alias, so check this first
*/
tableAlias = getTableAlias(pathName, useOuterJoins, new UserAlias(pathName, pathName, pathName), null, pathClasses);
}
if (tableAlias != null)
{
// correct column name to match the alias
// productGroup.groupName -> groupName
pathInfo.column = fieldNameRef[0];
}
}
result.tableAlias = tableAlias;
result.pathInfo = pathInfo;
return result;
} | [
"protected",
"AttributeInfo",
"getAttributeInfo",
"(",
"String",
"attr",
",",
"boolean",
"useOuterJoins",
",",
"UserAlias",
"aUserAlias",
",",
"Map",
"pathClasses",
")",
"{",
"AttributeInfo",
"result",
"=",
"new",
"AttributeInfo",
"(",
")",
";",
"TableAlias",
"tableAlias",
";",
"SqlHelper",
".",
"PathInfo",
"pathInfo",
"=",
"SqlHelper",
".",
"splitPath",
"(",
"attr",
")",
";",
"String",
"colName",
"=",
"pathInfo",
".",
"column",
";",
"int",
"sp",
";",
"// BRJ:\r",
"// check if we refer to an attribute in the parent query\r",
"// this prefix is temporary !\r",
"if",
"(",
"colName",
".",
"startsWith",
"(",
"Criteria",
".",
"PARENT_QUERY_PREFIX",
")",
"&&",
"m_parentStatement",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"fieldNameRef",
"=",
"{",
"colName",
".",
"substring",
"(",
"Criteria",
".",
"PARENT_QUERY_PREFIX",
".",
"length",
"(",
")",
")",
"}",
";",
"return",
"m_parentStatement",
".",
"getAttributeInfo",
"(",
"fieldNameRef",
"[",
"0",
"]",
",",
"useOuterJoins",
",",
"aUserAlias",
",",
"pathClasses",
")",
";",
"}",
"sp",
"=",
"colName",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"sp",
"==",
"-",
"1",
")",
"{",
"tableAlias",
"=",
"getRoot",
"(",
")",
";",
"}",
"else",
"{",
"String",
"pathName",
"=",
"colName",
".",
"substring",
"(",
"0",
",",
"sp",
")",
";",
"String",
"[",
"]",
"fieldNameRef",
"=",
"{",
"colName",
".",
"substring",
"(",
"sp",
"+",
"1",
")",
"}",
";",
"tableAlias",
"=",
"getTableAlias",
"(",
"pathName",
",",
"useOuterJoins",
",",
"aUserAlias",
",",
"fieldNameRef",
",",
"pathClasses",
")",
";",
"/**\r\n\t\t\t * if we have not found an alias by the pathName or\r\n\t\t\t * aliasName (if given), try again because pathName\r\n\t\t\t * may be an aliasname. it can be only and only if it is not\r\n\t\t\t * a path, which means there may be no path separators (,)\r\n\t\t\t * in the pathName.\r\n\t\t\t */",
"if",
"(",
"(",
"tableAlias",
"==",
"null",
")",
"&&",
"(",
"colName",
".",
"lastIndexOf",
"(",
"\".\"",
")",
"==",
"-",
"1",
")",
")",
"{",
"/**\r\n\t\t\t\t * pathName might be an alias, so check this first\r\n\t\t\t\t */",
"tableAlias",
"=",
"getTableAlias",
"(",
"pathName",
",",
"useOuterJoins",
",",
"new",
"UserAlias",
"(",
"pathName",
",",
"pathName",
",",
"pathName",
")",
",",
"null",
",",
"pathClasses",
")",
";",
"}",
"if",
"(",
"tableAlias",
"!=",
"null",
")",
"{",
"// correct column name to match the alias\r",
"// productGroup.groupName -> groupName\r",
"pathInfo",
".",
"column",
"=",
"fieldNameRef",
"[",
"0",
"]",
";",
"}",
"}",
"result",
".",
"tableAlias",
"=",
"tableAlias",
";",
"result",
".",
"pathInfo",
"=",
"pathInfo",
";",
"return",
"result",
";",
"}"
]
| Return the TableAlias and the PathInfo for an Attribute name<br>
field names in functions (ie: sum(name) ) are tried to resolve ie: name
from FIELDDESCRIPTOR , UPPER(name_test) from Criteria<br>
also resolve pathExpression adress.city or owner.konti.saldo
@param attr
@param useOuterJoins
@param aUserAlias
@param pathClasses
@return ColumnInfo | [
"Return",
"the",
"TableAlias",
"and",
"the",
"PathInfo",
"for",
"an",
"Attribute",
"name<br",
">",
"field",
"names",
"in",
"functions",
"(",
"ie",
":",
"sum",
"(",
"name",
")",
")",
"are",
"tried",
"to",
"resolve",
"ie",
":",
"name",
"from",
"FIELDDESCRIPTOR",
"UPPER",
"(",
"name_test",
")",
"from",
"Criteria<br",
">",
"also",
"resolve",
"pathExpression",
"adress",
".",
"city",
"or",
"owner",
".",
"konti",
".",
"saldo"
]
| train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L183-L237 |
google/error-prone-javac | src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java | JShellTool.errormsg | @Override
public void errormsg(String key, Object... args) {
"""
Print error using resource bundle look-up, MessageFormat, and add prefix
and postfix
@param key the resource key
@param args
"""
if (isRunningInteractive()) {
rawout(prefixError(messageFormat(key, args)));
} else {
startmsg(key, args);
}
} | java | @Override
public void errormsg(String key, Object... args) {
if (isRunningInteractive()) {
rawout(prefixError(messageFormat(key, args)));
} else {
startmsg(key, args);
}
} | [
"@",
"Override",
"public",
"void",
"errormsg",
"(",
"String",
"key",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"isRunningInteractive",
"(",
")",
")",
"{",
"rawout",
"(",
"prefixError",
"(",
"messageFormat",
"(",
"key",
",",
"args",
")",
")",
")",
";",
"}",
"else",
"{",
"startmsg",
"(",
"key",
",",
"args",
")",
";",
"}",
"}"
]
| Print error using resource bundle look-up, MessageFormat, and add prefix
and postfix
@param key the resource key
@param args | [
"Print",
"error",
"using",
"resource",
"bundle",
"look",
"-",
"up",
"MessageFormat",
"and",
"add",
"prefix",
"and",
"postfix"
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java#L811-L818 |
OpenTSDB/opentsdb | src/tsd/RpcHandler.java | RpcHandler.applyCorsConfig | private boolean applyCorsConfig(final HttpRequest req, final AbstractHttpQuery query)
throws BadRequestException {
"""
Helper method to apply CORS configuration to a request, either a built-in
RPC or a user plugin.
@return <code>true</code> if a status reply was sent (in the the case of
certain HTTP methods); <code>false</code> otherwise.
"""
final String domain = req.headers().get("Origin");
// catch CORS requests and add the header or refuse them if the domain
// list has been configured
if (query.method() == HttpMethod.OPTIONS ||
(cors_domains != null && domain != null && !domain.isEmpty())) {
if (cors_domains == null || domain == null || domain.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED,
"Method not allowed", "The HTTP method [" +
query.method().getName() + "] is not permitted");
}
if (cors_domains.contains("*") ||
cors_domains.contains(domain.toUpperCase())) {
// when a domain has matched successfully, we need to add the header
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN,
domain);
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS,
"GET, POST, PUT, DELETE");
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
cors_headers);
// if the method requested was for OPTIONS then we'll return an OK
// here and no further processing is needed.
if (query.method() == HttpMethod.OPTIONS) {
query.sendStatusOnly(HttpResponseStatus.OK);
return true;
}
} else {
// You'd think that they would want the server to return a 403 if
// the Origin wasn't in the CORS domain list, but they want a 200
// without the allow origin header. We'll return an error in the
// body though.
throw new BadRequestException(HttpResponseStatus.OK,
"CORS domain not allowed", "The domain [" + domain +
"] is not permitted access");
}
}
return false;
} | java | private boolean applyCorsConfig(final HttpRequest req, final AbstractHttpQuery query)
throws BadRequestException {
final String domain = req.headers().get("Origin");
// catch CORS requests and add the header or refuse them if the domain
// list has been configured
if (query.method() == HttpMethod.OPTIONS ||
(cors_domains != null && domain != null && !domain.isEmpty())) {
if (cors_domains == null || domain == null || domain.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED,
"Method not allowed", "The HTTP method [" +
query.method().getName() + "] is not permitted");
}
if (cors_domains.contains("*") ||
cors_domains.contains(domain.toUpperCase())) {
// when a domain has matched successfully, we need to add the header
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN,
domain);
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS,
"GET, POST, PUT, DELETE");
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
cors_headers);
// if the method requested was for OPTIONS then we'll return an OK
// here and no further processing is needed.
if (query.method() == HttpMethod.OPTIONS) {
query.sendStatusOnly(HttpResponseStatus.OK);
return true;
}
} else {
// You'd think that they would want the server to return a 403 if
// the Origin wasn't in the CORS domain list, but they want a 200
// without the allow origin header. We'll return an error in the
// body though.
throw new BadRequestException(HttpResponseStatus.OK,
"CORS domain not allowed", "The domain [" + domain +
"] is not permitted access");
}
}
return false;
} | [
"private",
"boolean",
"applyCorsConfig",
"(",
"final",
"HttpRequest",
"req",
",",
"final",
"AbstractHttpQuery",
"query",
")",
"throws",
"BadRequestException",
"{",
"final",
"String",
"domain",
"=",
"req",
".",
"headers",
"(",
")",
".",
"get",
"(",
"\"Origin\"",
")",
";",
"// catch CORS requests and add the header or refuse them if the domain",
"// list has been configured",
"if",
"(",
"query",
".",
"method",
"(",
")",
"==",
"HttpMethod",
".",
"OPTIONS",
"||",
"(",
"cors_domains",
"!=",
"null",
"&&",
"domain",
"!=",
"null",
"&&",
"!",
"domain",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"if",
"(",
"cors_domains",
"==",
"null",
"||",
"domain",
"==",
"null",
"||",
"domain",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"METHOD_NOT_ALLOWED",
",",
"\"Method not allowed\"",
",",
"\"The HTTP method [\"",
"+",
"query",
".",
"method",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"] is not permitted\"",
")",
";",
"}",
"if",
"(",
"cors_domains",
".",
"contains",
"(",
"\"*\"",
")",
"||",
"cors_domains",
".",
"contains",
"(",
"domain",
".",
"toUpperCase",
"(",
")",
")",
")",
"{",
"// when a domain has matched successfully, we need to add the header",
"query",
".",
"response",
"(",
")",
".",
"headers",
"(",
")",
".",
"add",
"(",
"HttpHeaders",
".",
"ACCESS_CONTROL_ALLOW_ORIGIN",
",",
"domain",
")",
";",
"query",
".",
"response",
"(",
")",
".",
"headers",
"(",
")",
".",
"add",
"(",
"HttpHeaders",
".",
"ACCESS_CONTROL_ALLOW_METHODS",
",",
"\"GET, POST, PUT, DELETE\"",
")",
";",
"query",
".",
"response",
"(",
")",
".",
"headers",
"(",
")",
".",
"add",
"(",
"HttpHeaders",
".",
"ACCESS_CONTROL_ALLOW_HEADERS",
",",
"cors_headers",
")",
";",
"// if the method requested was for OPTIONS then we'll return an OK",
"// here and no further processing is needed.",
"if",
"(",
"query",
".",
"method",
"(",
")",
"==",
"HttpMethod",
".",
"OPTIONS",
")",
"{",
"query",
".",
"sendStatusOnly",
"(",
"HttpResponseStatus",
".",
"OK",
")",
";",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"// You'd think that they would want the server to return a 403 if",
"// the Origin wasn't in the CORS domain list, but they want a 200",
"// without the allow origin header. We'll return an error in the",
"// body though.",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"OK",
",",
"\"CORS domain not allowed\"",
",",
"\"The domain [\"",
"+",
"domain",
"+",
"\"] is not permitted access\"",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Helper method to apply CORS configuration to a request, either a built-in
RPC or a user plugin.
@return <code>true</code> if a status reply was sent (in the the case of
certain HTTP methods); <code>false</code> otherwise. | [
"Helper",
"method",
"to",
"apply",
"CORS",
"configuration",
"to",
"a",
"request",
"either",
"a",
"built",
"-",
"in",
"RPC",
"or",
"a",
"user",
"plugin",
"."
]
| train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/RpcHandler.java#L199-L241 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPose.java | GVRPose.setLocalRotation | public boolean setLocalRotation(int boneindex, float x, float y, float z, float w) {
"""
Sets the local rotation for the designated bone.
<p>
All bones in the skeleton start out at the origin oriented along the bone axis (usually 0,0,1).
The pose orients and positions each bone in the skeleton with respect to this initial state.
The local bone matrix expresses the orientation and position of the bone relative
to it's parent. This function sets the rotation component of that matrix from a quaternion.
The position of the bone is unaffected.
@param boneindex zero based index of bone to rotate.
@param x,y,z,w quaternion with the rotation for the named bone.
@see #setLocalRotations
@see #setWorldRotations
@see #setWorldMatrix
@see GVRSkeleton#setBoneAxis
"""
if (mSkeleton.isLocked(boneindex))
return false;
Bone bone = mBones[boneindex];
bone.setLocalRotation(x, y, z, w);
if (mSkeleton.getParentBoneIndex(boneindex) < 0)
{
bone.WorldMatrix.set(bone.LocalMatrix);
}
else
{
mNeedSync = true;
}
bone.Changed = LOCAL_ROT;
if (sDebug)
{
Log.d("BONE", "setLocalRotation: %s %s", mSkeleton.getBoneName(boneindex), bone.toString());
}
return true;
} | java | public boolean setLocalRotation(int boneindex, float x, float y, float z, float w)
{
if (mSkeleton.isLocked(boneindex))
return false;
Bone bone = mBones[boneindex];
bone.setLocalRotation(x, y, z, w);
if (mSkeleton.getParentBoneIndex(boneindex) < 0)
{
bone.WorldMatrix.set(bone.LocalMatrix);
}
else
{
mNeedSync = true;
}
bone.Changed = LOCAL_ROT;
if (sDebug)
{
Log.d("BONE", "setLocalRotation: %s %s", mSkeleton.getBoneName(boneindex), bone.toString());
}
return true;
} | [
"public",
"boolean",
"setLocalRotation",
"(",
"int",
"boneindex",
",",
"float",
"x",
",",
"float",
"y",
",",
"float",
"z",
",",
"float",
"w",
")",
"{",
"if",
"(",
"mSkeleton",
".",
"isLocked",
"(",
"boneindex",
")",
")",
"return",
"false",
";",
"Bone",
"bone",
"=",
"mBones",
"[",
"boneindex",
"]",
";",
"bone",
".",
"setLocalRotation",
"(",
"x",
",",
"y",
",",
"z",
",",
"w",
")",
";",
"if",
"(",
"mSkeleton",
".",
"getParentBoneIndex",
"(",
"boneindex",
")",
"<",
"0",
")",
"{",
"bone",
".",
"WorldMatrix",
".",
"set",
"(",
"bone",
".",
"LocalMatrix",
")",
";",
"}",
"else",
"{",
"mNeedSync",
"=",
"true",
";",
"}",
"bone",
".",
"Changed",
"=",
"LOCAL_ROT",
";",
"if",
"(",
"sDebug",
")",
"{",
"Log",
".",
"d",
"(",
"\"BONE\"",
",",
"\"setLocalRotation: %s %s\"",
",",
"mSkeleton",
".",
"getBoneName",
"(",
"boneindex",
")",
",",
"bone",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Sets the local rotation for the designated bone.
<p>
All bones in the skeleton start out at the origin oriented along the bone axis (usually 0,0,1).
The pose orients and positions each bone in the skeleton with respect to this initial state.
The local bone matrix expresses the orientation and position of the bone relative
to it's parent. This function sets the rotation component of that matrix from a quaternion.
The position of the bone is unaffected.
@param boneindex zero based index of bone to rotate.
@param x,y,z,w quaternion with the rotation for the named bone.
@see #setLocalRotations
@see #setWorldRotations
@see #setWorldMatrix
@see GVRSkeleton#setBoneAxis | [
"Sets",
"the",
"local",
"rotation",
"for",
"the",
"designated",
"bone",
".",
"<p",
">",
"All",
"bones",
"in",
"the",
"skeleton",
"start",
"out",
"at",
"the",
"origin",
"oriented",
"along",
"the",
"bone",
"axis",
"(",
"usually",
"0",
"0",
"1",
")",
".",
"The",
"pose",
"orients",
"and",
"positions",
"each",
"bone",
"in",
"the",
"skeleton",
"with",
"respect",
"to",
"this",
"initial",
"state",
".",
"The",
"local",
"bone",
"matrix",
"expresses",
"the",
"orientation",
"and",
"position",
"of",
"the",
"bone",
"relative",
"to",
"it",
"s",
"parent",
".",
"This",
"function",
"sets",
"the",
"rotation",
"component",
"of",
"that",
"matrix",
"from",
"a",
"quaternion",
".",
"The",
"position",
"of",
"the",
"bone",
"is",
"unaffected",
"."
]
| train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPose.java#L615-L637 |
lucee/Lucee | core/src/main/java/lucee/runtime/tag/FileTag.java | FileTag.setMode | private static void setMode(Resource file, int mode) throws ApplicationException {
"""
change mode of given file
@param file
@throws ApplicationException
"""
if (mode == -1 || SystemUtil.isWindows()) return;
try {
file.setMode(mode);
// FileUtil.setMode(file,mode);
}
catch (IOException e) {
throw new ApplicationException("can't change mode of file " + file, e.getMessage());
}
} | java | private static void setMode(Resource file, int mode) throws ApplicationException {
if (mode == -1 || SystemUtil.isWindows()) return;
try {
file.setMode(mode);
// FileUtil.setMode(file,mode);
}
catch (IOException e) {
throw new ApplicationException("can't change mode of file " + file, e.getMessage());
}
} | [
"private",
"static",
"void",
"setMode",
"(",
"Resource",
"file",
",",
"int",
"mode",
")",
"throws",
"ApplicationException",
"{",
"if",
"(",
"mode",
"==",
"-",
"1",
"||",
"SystemUtil",
".",
"isWindows",
"(",
")",
")",
"return",
";",
"try",
"{",
"file",
".",
"setMode",
"(",
"mode",
")",
";",
"// FileUtil.setMode(file,mode);",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ApplicationException",
"(",
"\"can't change mode of file \"",
"+",
"file",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
]
| change mode of given file
@param file
@throws ApplicationException | [
"change",
"mode",
"of",
"given",
"file"
]
| train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/tag/FileTag.java#L1203-L1212 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/cli/CliClient.java | CliClient.getIndexTypeFromString | private IndexType getIndexTypeFromString(String indexTypeAsString) {
"""
Getting IndexType object from indexType string
@param indexTypeAsString - string return by parser corresponding to IndexType
@return IndexType - an IndexType object
"""
IndexType indexType;
try
{
indexType = IndexType.findByValue(new Integer(indexTypeAsString));
}
catch (NumberFormatException e)
{
try
{
// if this is not an integer lets try to get IndexType by name
indexType = IndexType.valueOf(indexTypeAsString);
}
catch (IllegalArgumentException ie)
{
throw new RuntimeException("IndexType '" + indexTypeAsString + "' is unsupported.", ie);
}
}
if (indexType == null)
{
throw new RuntimeException("IndexType '" + indexTypeAsString + "' is unsupported.");
}
return indexType;
} | java | private IndexType getIndexTypeFromString(String indexTypeAsString)
{
IndexType indexType;
try
{
indexType = IndexType.findByValue(new Integer(indexTypeAsString));
}
catch (NumberFormatException e)
{
try
{
// if this is not an integer lets try to get IndexType by name
indexType = IndexType.valueOf(indexTypeAsString);
}
catch (IllegalArgumentException ie)
{
throw new RuntimeException("IndexType '" + indexTypeAsString + "' is unsupported.", ie);
}
}
if (indexType == null)
{
throw new RuntimeException("IndexType '" + indexTypeAsString + "' is unsupported.");
}
return indexType;
} | [
"private",
"IndexType",
"getIndexTypeFromString",
"(",
"String",
"indexTypeAsString",
")",
"{",
"IndexType",
"indexType",
";",
"try",
"{",
"indexType",
"=",
"IndexType",
".",
"findByValue",
"(",
"new",
"Integer",
"(",
"indexTypeAsString",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"try",
"{",
"// if this is not an integer lets try to get IndexType by name",
"indexType",
"=",
"IndexType",
".",
"valueOf",
"(",
"indexTypeAsString",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ie",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"IndexType '\"",
"+",
"indexTypeAsString",
"+",
"\"' is unsupported.\"",
",",
"ie",
")",
";",
"}",
"}",
"if",
"(",
"indexType",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"IndexType '\"",
"+",
"indexTypeAsString",
"+",
"\"' is unsupported.\"",
")",
";",
"}",
"return",
"indexType",
";",
"}"
]
| Getting IndexType object from indexType string
@param indexTypeAsString - string return by parser corresponding to IndexType
@return IndexType - an IndexType object | [
"Getting",
"IndexType",
"object",
"from",
"indexType",
"string"
]
| train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cli/CliClient.java#L2516-L2543 |
cchantep/acolyte | jdbc-java8/src/main/java/acolyte/jdbc/Java8CompositeHandler.java | Java8CompositeHandler.withUpdateHandler1 | public Java8CompositeHandler withUpdateHandler1(CountUpdateHandler h) {
"""
Returns handler that delegates update execution to |h| function.
Given function will be used only if executed statement is not detected
as a query by withQueryDetection.
@param h the new update handler
<pre>
{@code
import acolyte.jdbc.UpdateResult;
import acolyte.jdbc.StatementHandler.Parameter;
import static acolyte.jdbc.AcolyteDSL.handleStatement;
handleStatement.withUpdateHandler1((String sql, List<Parameter> ps) -> {
if (sql == "INSERT INTO Country (code, name) VALUES (?, ?)") {
return 1; // update count
} else return 0;
});
}
</pre>
"""
final UpdateHandler uh = new UpdateHandler() {
public UpdateResult apply(String sql, List<Parameter> ps) {
return new UpdateResult(h.apply(sql, ps));
}
};
return withUpdateHandler(uh);
} | java | public Java8CompositeHandler withUpdateHandler1(CountUpdateHandler h) {
final UpdateHandler uh = new UpdateHandler() {
public UpdateResult apply(String sql, List<Parameter> ps) {
return new UpdateResult(h.apply(sql, ps));
}
};
return withUpdateHandler(uh);
} | [
"public",
"Java8CompositeHandler",
"withUpdateHandler1",
"(",
"CountUpdateHandler",
"h",
")",
"{",
"final",
"UpdateHandler",
"uh",
"=",
"new",
"UpdateHandler",
"(",
")",
"{",
"public",
"UpdateResult",
"apply",
"(",
"String",
"sql",
",",
"List",
"<",
"Parameter",
">",
"ps",
")",
"{",
"return",
"new",
"UpdateResult",
"(",
"h",
".",
"apply",
"(",
"sql",
",",
"ps",
")",
")",
";",
"}",
"}",
";",
"return",
"withUpdateHandler",
"(",
"uh",
")",
";",
"}"
]
| Returns handler that delegates update execution to |h| function.
Given function will be used only if executed statement is not detected
as a query by withQueryDetection.
@param h the new update handler
<pre>
{@code
import acolyte.jdbc.UpdateResult;
import acolyte.jdbc.StatementHandler.Parameter;
import static acolyte.jdbc.AcolyteDSL.handleStatement;
handleStatement.withUpdateHandler1((String sql, List<Parameter> ps) -> {
if (sql == "INSERT INTO Country (code, name) VALUES (?, ?)") {
return 1; // update count
} else return 0;
});
}
</pre> | [
"Returns",
"handler",
"that",
"delegates",
"update",
"execution",
"to",
"|h|",
"function",
".",
"Given",
"function",
"will",
"be",
"used",
"only",
"if",
"executed",
"statement",
"is",
"not",
"detected",
"as",
"a",
"query",
"by",
"withQueryDetection",
"."
]
| train | https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-java8/src/main/java/acolyte/jdbc/Java8CompositeHandler.java#L199-L207 |
querydsl/querydsl | querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java | Expressions.dateTemplate | public static <T extends Comparable<?>> DateTemplate<T> dateTemplate(Class<? extends T> cl,
String template, Object... args) {
"""
Create a new Template expression
@param cl type of expression
@param template template
@param args template parameters
@return template expression
"""
return dateTemplate(cl, createTemplate(template), ImmutableList.copyOf(args));
} | java | public static <T extends Comparable<?>> DateTemplate<T> dateTemplate(Class<? extends T> cl,
String template, Object... args) {
return dateTemplate(cl, createTemplate(template), ImmutableList.copyOf(args));
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
">",
">",
"DateTemplate",
"<",
"T",
">",
"dateTemplate",
"(",
"Class",
"<",
"?",
"extends",
"T",
">",
"cl",
",",
"String",
"template",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"dateTemplate",
"(",
"cl",
",",
"createTemplate",
"(",
"template",
")",
",",
"ImmutableList",
".",
"copyOf",
"(",
"args",
")",
")",
";",
"}"
]
| Create a new Template expression
@param cl type of expression
@param template template
@param args template parameters
@return template expression | [
"Create",
"a",
"new",
"Template",
"expression"
]
| train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java#L480-L483 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java | MapUtil.join | public static <K, V> String join(Map<K, V> map, String separator, String keyValueSeparator) {
"""
将map转成字符串
@param <K> 键类型
@param <V> 值类型
@param map Map
@param separator entry之间的连接符
@param keyValueSeparator kv之间的连接符
@return 连接字符串
@since 3.1.1
"""
return join(map, separator, keyValueSeparator, false);
} | java | public static <K, V> String join(Map<K, V> map, String separator, String keyValueSeparator) {
return join(map, separator, keyValueSeparator, false);
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"String",
"join",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"String",
"separator",
",",
"String",
"keyValueSeparator",
")",
"{",
"return",
"join",
"(",
"map",
",",
"separator",
",",
"keyValueSeparator",
",",
"false",
")",
";",
"}"
]
| 将map转成字符串
@param <K> 键类型
@param <V> 值类型
@param map Map
@param separator entry之间的连接符
@param keyValueSeparator kv之间的连接符
@return 连接字符串
@since 3.1.1 | [
"将map转成字符串"
]
| train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java#L427-L429 |
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.updateCompositeEntityRoleAsync | public Observable<OperationStatus> updateCompositeEntityRoleAsync(UUID appId, String versionId, UUID cEntityId, UUID roleId, UpdateCompositeEntityRoleOptionalParameter updateCompositeEntityRoleOptionalParameter) {
"""
Update an entity role for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@param roleId The entity role ID.
@param updateCompositeEntityRoleOptionalParameter 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 OperationStatus object
"""
return updateCompositeEntityRoleWithServiceResponseAsync(appId, versionId, cEntityId, roleId, updateCompositeEntityRoleOptionalParameter).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | java | public Observable<OperationStatus> updateCompositeEntityRoleAsync(UUID appId, String versionId, UUID cEntityId, UUID roleId, UpdateCompositeEntityRoleOptionalParameter updateCompositeEntityRoleOptionalParameter) {
return updateCompositeEntityRoleWithServiceResponseAsync(appId, versionId, cEntityId, roleId, updateCompositeEntityRoleOptionalParameter).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OperationStatus",
">",
"updateCompositeEntityRoleAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"cEntityId",
",",
"UUID",
"roleId",
",",
"UpdateCompositeEntityRoleOptionalParameter",
"updateCompositeEntityRoleOptionalParameter",
")",
"{",
"return",
"updateCompositeEntityRoleWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"cEntityId",
",",
"roleId",
",",
"updateCompositeEntityRoleOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OperationStatus",
">",
",",
"OperationStatus",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OperationStatus",
"call",
"(",
"ServiceResponse",
"<",
"OperationStatus",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Update an entity role for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@param roleId The entity role ID.
@param updateCompositeEntityRoleOptionalParameter 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 OperationStatus object | [
"Update",
"an",
"entity",
"role",
"for",
"a",
"given",
"entity",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L12485-L12492 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java | ElementsTable.sanityCheckSourcePathModules | void sanityCheckSourcePathModules(List<String> moduleNames) throws ToolException {
"""
/*
This method sanity checks the following cases:
a. a source-path containing a single module and many modules specified with --module
b. no modules on source-path
c. mismatched source-path and many modules specified with --module
"""
if (!haveSourceLocationWithModule)
return;
if (moduleNames.size() > 1) {
String text = messager.getText("main.cannot_use_sourcepath_for_modules",
String.join(", ", moduleNames));
throw new ToolException(CMDERR, text);
}
String foundModule = getModuleName(StandardLocation.SOURCE_PATH);
if (foundModule == null) {
String text = messager.getText("main.module_not_found_on_sourcepath", moduleNames.get(0));
throw new ToolException(CMDERR, text);
}
if (!moduleNames.get(0).equals(foundModule)) {
String text = messager.getText("main.sourcepath_does_not_contain_module", moduleNames.get(0));
throw new ToolException(CMDERR, text);
}
} | java | void sanityCheckSourcePathModules(List<String> moduleNames) throws ToolException {
if (!haveSourceLocationWithModule)
return;
if (moduleNames.size() > 1) {
String text = messager.getText("main.cannot_use_sourcepath_for_modules",
String.join(", ", moduleNames));
throw new ToolException(CMDERR, text);
}
String foundModule = getModuleName(StandardLocation.SOURCE_PATH);
if (foundModule == null) {
String text = messager.getText("main.module_not_found_on_sourcepath", moduleNames.get(0));
throw new ToolException(CMDERR, text);
}
if (!moduleNames.get(0).equals(foundModule)) {
String text = messager.getText("main.sourcepath_does_not_contain_module", moduleNames.get(0));
throw new ToolException(CMDERR, text);
}
} | [
"void",
"sanityCheckSourcePathModules",
"(",
"List",
"<",
"String",
">",
"moduleNames",
")",
"throws",
"ToolException",
"{",
"if",
"(",
"!",
"haveSourceLocationWithModule",
")",
"return",
";",
"if",
"(",
"moduleNames",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"String",
"text",
"=",
"messager",
".",
"getText",
"(",
"\"main.cannot_use_sourcepath_for_modules\"",
",",
"String",
".",
"join",
"(",
"\", \"",
",",
"moduleNames",
")",
")",
";",
"throw",
"new",
"ToolException",
"(",
"CMDERR",
",",
"text",
")",
";",
"}",
"String",
"foundModule",
"=",
"getModuleName",
"(",
"StandardLocation",
".",
"SOURCE_PATH",
")",
";",
"if",
"(",
"foundModule",
"==",
"null",
")",
"{",
"String",
"text",
"=",
"messager",
".",
"getText",
"(",
"\"main.module_not_found_on_sourcepath\"",
",",
"moduleNames",
".",
"get",
"(",
"0",
")",
")",
";",
"throw",
"new",
"ToolException",
"(",
"CMDERR",
",",
"text",
")",
";",
"}",
"if",
"(",
"!",
"moduleNames",
".",
"get",
"(",
"0",
")",
".",
"equals",
"(",
"foundModule",
")",
")",
"{",
"String",
"text",
"=",
"messager",
".",
"getText",
"(",
"\"main.sourcepath_does_not_contain_module\"",
",",
"moduleNames",
".",
"get",
"(",
"0",
")",
")",
";",
"throw",
"new",
"ToolException",
"(",
"CMDERR",
",",
"text",
")",
";",
"}",
"}"
]
| /*
This method sanity checks the following cases:
a. a source-path containing a single module and many modules specified with --module
b. no modules on source-path
c. mismatched source-path and many modules specified with --module | [
"/",
"*",
"This",
"method",
"sanity",
"checks",
"the",
"following",
"cases",
":",
"a",
".",
"a",
"source",
"-",
"path",
"containing",
"a",
"single",
"module",
"and",
"many",
"modules",
"specified",
"with",
"--",
"module",
"b",
".",
"no",
"modules",
"on",
"source",
"-",
"path",
"c",
".",
"mismatched",
"source",
"-",
"path",
"and",
"many",
"modules",
"specified",
"with",
"--",
"module"
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java#L369-L389 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging/src/com/ibm/ws/logging/internal/impl/LoggingConfigUtils.java | LoggingConfigUtils.getFormatValue | public static TraceFormat getFormatValue(Object newValue, TraceFormat defaultValue) {
"""
Convert the property value to a TraceFormat type
@param s
String value
@return TraceFormat, BASIC is the default.
"""
if (newValue != null && newValue instanceof String) {
String strValue = ((String) newValue).toUpperCase();
try {
return TraceFormat.valueOf(strValue);
} catch (Exception e) {
}
}
return defaultValue;
} | java | public static TraceFormat getFormatValue(Object newValue, TraceFormat defaultValue) {
if (newValue != null && newValue instanceof String) {
String strValue = ((String) newValue).toUpperCase();
try {
return TraceFormat.valueOf(strValue);
} catch (Exception e) {
}
}
return defaultValue;
} | [
"public",
"static",
"TraceFormat",
"getFormatValue",
"(",
"Object",
"newValue",
",",
"TraceFormat",
"defaultValue",
")",
"{",
"if",
"(",
"newValue",
"!=",
"null",
"&&",
"newValue",
"instanceof",
"String",
")",
"{",
"String",
"strValue",
"=",
"(",
"(",
"String",
")",
"newValue",
")",
".",
"toUpperCase",
"(",
")",
";",
"try",
"{",
"return",
"TraceFormat",
".",
"valueOf",
"(",
"strValue",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"return",
"defaultValue",
";",
"}"
]
| Convert the property value to a TraceFormat type
@param s
String value
@return TraceFormat, BASIC is the default. | [
"Convert",
"the",
"property",
"value",
"to",
"a",
"TraceFormat",
"type"
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging/src/com/ibm/ws/logging/internal/impl/LoggingConfigUtils.java#L163-L173 |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/coordinate/GISCoordinates.java | GISCoordinates.EL2_WSG84 | @Pure
public static GeodesicPosition EL2_WSG84(double x, double y) {
"""
This function convert extended France Lambert II coordinate to geographic WSG84 Data.
@param x is the coordinate in extended France Lambert II
@param y is the coordinate in extended France Lambert II
@return lambda and phi in geographic WSG84 in degrees.
"""
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_2E_N,
LAMBERT_2E_C,
LAMBERT_2E_XS,
LAMBERT_2E_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | java | @Pure
public static GeodesicPosition EL2_WSG84(double x, double y) {
final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
LAMBERT_2E_N,
LAMBERT_2E_C,
LAMBERT_2E_XS,
LAMBERT_2E_YS);
return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
} | [
"@",
"Pure",
"public",
"static",
"GeodesicPosition",
"EL2_WSG84",
"(",
"double",
"x",
",",
"double",
"y",
")",
"{",
"final",
"Point2d",
"ntfLambdaPhi",
"=",
"NTFLambert_NTFLambdaPhi",
"(",
"x",
",",
"y",
",",
"LAMBERT_2E_N",
",",
"LAMBERT_2E_C",
",",
"LAMBERT_2E_XS",
",",
"LAMBERT_2E_YS",
")",
";",
"return",
"NTFLambdaPhi_WSG84",
"(",
"ntfLambdaPhi",
".",
"getX",
"(",
")",
",",
"ntfLambdaPhi",
".",
"getY",
"(",
")",
")",
";",
"}"
]
| This function convert extended France Lambert II coordinate to geographic WSG84 Data.
@param x is the coordinate in extended France Lambert II
@param y is the coordinate in extended France Lambert II
@return lambda and phi in geographic WSG84 in degrees. | [
"This",
"function",
"convert",
"extended",
"France",
"Lambert",
"II",
"coordinate",
"to",
"geographic",
"WSG84",
"Data",
"."
]
| train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/coordinate/GISCoordinates.java#L165-L173 |
logic-ng/LogicNG | src/main/java/org/logicng/formulas/FormulaFactory.java | FormulaFactory.constructClause | private Formula constructClause(final LinkedHashSet<Literal> literals) {
"""
Creates a new clause.
@param literals the literals
@return a new clause
"""
if (literals.isEmpty())
return this.falsum();
if (literals.size() == 1)
return literals.iterator().next();
Map<LinkedHashSet<? extends Formula>, Or> opOrMap = this.orsN;
switch (literals.size()) {
case 2:
opOrMap = this.ors2;
break;
case 3:
opOrMap = this.ors3;
break;
case 4:
opOrMap = this.ors4;
break;
default:
break;
}
Or tempOr = opOrMap.get(literals);
if (tempOr != null)
return tempOr;
tempOr = new Or(literals, this, true);
opOrMap.put(literals, tempOr);
return tempOr;
} | java | private Formula constructClause(final LinkedHashSet<Literal> literals) {
if (literals.isEmpty())
return this.falsum();
if (literals.size() == 1)
return literals.iterator().next();
Map<LinkedHashSet<? extends Formula>, Or> opOrMap = this.orsN;
switch (literals.size()) {
case 2:
opOrMap = this.ors2;
break;
case 3:
opOrMap = this.ors3;
break;
case 4:
opOrMap = this.ors4;
break;
default:
break;
}
Or tempOr = opOrMap.get(literals);
if (tempOr != null)
return tempOr;
tempOr = new Or(literals, this, true);
opOrMap.put(literals, tempOr);
return tempOr;
} | [
"private",
"Formula",
"constructClause",
"(",
"final",
"LinkedHashSet",
"<",
"Literal",
">",
"literals",
")",
"{",
"if",
"(",
"literals",
".",
"isEmpty",
"(",
")",
")",
"return",
"this",
".",
"falsum",
"(",
")",
";",
"if",
"(",
"literals",
".",
"size",
"(",
")",
"==",
"1",
")",
"return",
"literals",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"Map",
"<",
"LinkedHashSet",
"<",
"?",
"extends",
"Formula",
">",
",",
"Or",
">",
"opOrMap",
"=",
"this",
".",
"orsN",
";",
"switch",
"(",
"literals",
".",
"size",
"(",
")",
")",
"{",
"case",
"2",
":",
"opOrMap",
"=",
"this",
".",
"ors2",
";",
"break",
";",
"case",
"3",
":",
"opOrMap",
"=",
"this",
".",
"ors3",
";",
"break",
";",
"case",
"4",
":",
"opOrMap",
"=",
"this",
".",
"ors4",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"Or",
"tempOr",
"=",
"opOrMap",
".",
"get",
"(",
"literals",
")",
";",
"if",
"(",
"tempOr",
"!=",
"null",
")",
"return",
"tempOr",
";",
"tempOr",
"=",
"new",
"Or",
"(",
"literals",
",",
"this",
",",
"true",
")",
";",
"opOrMap",
".",
"put",
"(",
"literals",
",",
"tempOr",
")",
";",
"return",
"tempOr",
";",
"}"
]
| Creates a new clause.
@param literals the literals
@return a new clause | [
"Creates",
"a",
"new",
"clause",
"."
]
| train | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/formulas/FormulaFactory.java#L650-L675 |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.touchMessage | public MessageOptions touchMessage(String id, String reservationId, int timeout) throws IOException {
"""
Touching a reserved message extends its timeout to the specified duration.
@param id The ID of the message to delete.
@param reservationId This id is returned when you reserve a message and must be provided to delete a message that is reserved.
@param timeout After timeout (in seconds), item will be placed back onto queue.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server.
"""
return touchMessage(id, reservationId, (long) timeout);
} | java | public MessageOptions touchMessage(String id, String reservationId, int timeout) throws IOException {
return touchMessage(id, reservationId, (long) timeout);
} | [
"public",
"MessageOptions",
"touchMessage",
"(",
"String",
"id",
",",
"String",
"reservationId",
",",
"int",
"timeout",
")",
"throws",
"IOException",
"{",
"return",
"touchMessage",
"(",
"id",
",",
"reservationId",
",",
"(",
"long",
")",
"timeout",
")",
";",
"}"
]
| Touching a reserved message extends its timeout to the specified duration.
@param id The ID of the message to delete.
@param reservationId This id is returned when you reserve a message and must be provided to delete a message that is reserved.
@param timeout After timeout (in seconds), item will be placed back onto queue.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Touching",
"a",
"reserved",
"message",
"extends",
"its",
"timeout",
"to",
"the",
"specified",
"duration",
"."
]
| train | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L236-L238 |
alkacon/opencms-core | src/org/opencms/file/types/A_CmsResourceType.java | A_CmsResourceType.getMacroResolver | protected CmsMacroResolver getMacroResolver(CmsObject cms, String resourcename) {
"""
Creates a macro resolver based on the current users OpenCms context and the provided resource name.<p>
@param cms the current OpenCms user context
@param resourcename the resource name for macros like {@link A_CmsResourceType#MACRO_RESOURCE_FOLDER_PATH}
@return a macro resolver based on the current users OpenCms context and the provided resource name
"""
CmsMacroResolver result = CmsMacroResolver.newInstance().setCmsObject(cms);
if (isFolder() && (!CmsResource.isFolder(resourcename))) {
// ensure folder ends with "/" so
resourcename = resourcename.concat("/");
}
// add special mappings for macros in default properties
result.addMacro(MACRO_RESOURCE_ROOT_PATH, cms.getRequestContext().addSiteRoot(resourcename));
result.addMacro(MACRO_RESOURCE_SITE_PATH, resourcename);
result.addMacro(MACRO_RESOURCE_FOLDER_PATH, CmsResource.getFolderPath(resourcename));
result.addMacro(MACRO_RESOURCE_FOLDER_PATH_TOUCH, CmsResource.getFolderPath(resourcename));
result.addMacro(MACRO_RESOURCE_PARENT_PATH, CmsResource.getParentFolder(resourcename));
result.addMacro(MACRO_RESOURCE_NAME, CmsResource.getName(resourcename));
return result;
} | java | protected CmsMacroResolver getMacroResolver(CmsObject cms, String resourcename) {
CmsMacroResolver result = CmsMacroResolver.newInstance().setCmsObject(cms);
if (isFolder() && (!CmsResource.isFolder(resourcename))) {
// ensure folder ends with "/" so
resourcename = resourcename.concat("/");
}
// add special mappings for macros in default properties
result.addMacro(MACRO_RESOURCE_ROOT_PATH, cms.getRequestContext().addSiteRoot(resourcename));
result.addMacro(MACRO_RESOURCE_SITE_PATH, resourcename);
result.addMacro(MACRO_RESOURCE_FOLDER_PATH, CmsResource.getFolderPath(resourcename));
result.addMacro(MACRO_RESOURCE_FOLDER_PATH_TOUCH, CmsResource.getFolderPath(resourcename));
result.addMacro(MACRO_RESOURCE_PARENT_PATH, CmsResource.getParentFolder(resourcename));
result.addMacro(MACRO_RESOURCE_NAME, CmsResource.getName(resourcename));
return result;
} | [
"protected",
"CmsMacroResolver",
"getMacroResolver",
"(",
"CmsObject",
"cms",
",",
"String",
"resourcename",
")",
"{",
"CmsMacroResolver",
"result",
"=",
"CmsMacroResolver",
".",
"newInstance",
"(",
")",
".",
"setCmsObject",
"(",
"cms",
")",
";",
"if",
"(",
"isFolder",
"(",
")",
"&&",
"(",
"!",
"CmsResource",
".",
"isFolder",
"(",
"resourcename",
")",
")",
")",
"{",
"// ensure folder ends with \"/\" so",
"resourcename",
"=",
"resourcename",
".",
"concat",
"(",
"\"/\"",
")",
";",
"}",
"// add special mappings for macros in default properties",
"result",
".",
"addMacro",
"(",
"MACRO_RESOURCE_ROOT_PATH",
",",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"addSiteRoot",
"(",
"resourcename",
")",
")",
";",
"result",
".",
"addMacro",
"(",
"MACRO_RESOURCE_SITE_PATH",
",",
"resourcename",
")",
";",
"result",
".",
"addMacro",
"(",
"MACRO_RESOURCE_FOLDER_PATH",
",",
"CmsResource",
".",
"getFolderPath",
"(",
"resourcename",
")",
")",
";",
"result",
".",
"addMacro",
"(",
"MACRO_RESOURCE_FOLDER_PATH_TOUCH",
",",
"CmsResource",
".",
"getFolderPath",
"(",
"resourcename",
")",
")",
";",
"result",
".",
"addMacro",
"(",
"MACRO_RESOURCE_PARENT_PATH",
",",
"CmsResource",
".",
"getParentFolder",
"(",
"resourcename",
")",
")",
";",
"result",
".",
"addMacro",
"(",
"MACRO_RESOURCE_NAME",
",",
"CmsResource",
".",
"getName",
"(",
"resourcename",
")",
")",
";",
"return",
"result",
";",
"}"
]
| Creates a macro resolver based on the current users OpenCms context and the provided resource name.<p>
@param cms the current OpenCms user context
@param resourcename the resource name for macros like {@link A_CmsResourceType#MACRO_RESOURCE_FOLDER_PATH}
@return a macro resolver based on the current users OpenCms context and the provided resource name | [
"Creates",
"a",
"macro",
"resolver",
"based",
"on",
"the",
"current",
"users",
"OpenCms",
"context",
"and",
"the",
"provided",
"resource",
"name",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/types/A_CmsResourceType.java#L1049-L1065 |
stratosphere/stratosphere | stratosphere-addons/hbase/src/main/java/eu/stratosphere/addons/hbase/TableInputFormat.java | TableInputFormat.mapResultToRecord | public void mapResultToRecord(Record record, HBaseKey key, HBaseResult result) {
"""
Maps the current HBase Result into a Record.
This implementation simply stores the HBaseKey at position 0, and the HBase Result object at position 1.
@param record
@param key
@param result
"""
record.setField(0, key);
record.setField(1, result);
} | java | public void mapResultToRecord(Record record, HBaseKey key, HBaseResult result) {
record.setField(0, key);
record.setField(1, result);
} | [
"public",
"void",
"mapResultToRecord",
"(",
"Record",
"record",
",",
"HBaseKey",
"key",
",",
"HBaseResult",
"result",
")",
"{",
"record",
".",
"setField",
"(",
"0",
",",
"key",
")",
";",
"record",
".",
"setField",
"(",
"1",
",",
"result",
")",
";",
"}"
]
| Maps the current HBase Result into a Record.
This implementation simply stores the HBaseKey at position 0, and the HBase Result object at position 1.
@param record
@param key
@param result | [
"Maps",
"the",
"current",
"HBase",
"Result",
"into",
"a",
"Record",
".",
"This",
"implementation",
"simply",
"stores",
"the",
"HBaseKey",
"at",
"position",
"0",
"and",
"the",
"HBase",
"Result",
"object",
"at",
"position",
"1",
"."
]
| train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-addons/hbase/src/main/java/eu/stratosphere/addons/hbase/TableInputFormat.java#L257-L260 |
apache/groovy | subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java | Sql.firstRow | public GroovyRowResult firstRow(GString gstring) throws SQLException {
"""
Performs the given SQL query and return
the first row of the result set.
The query may contain GString expressions.
<p>
Example usage:
<pre>
def location = 25
def ans = sql.firstRow("select * from PERSON where location_id {@code <} $location")
println ans.firstname
</pre>
<p>
Resource handling is performed automatically where appropriate.
@param gstring a GString containing the SQL query with embedded params
@return a GroovyRowResult object or <code>null</code> if no row is found
@throws SQLException if a database access error occurs
@see #expand(Object)
"""
List<Object> params = getParameters(gstring);
String sql = asSql(gstring, params);
return firstRow(sql, params);
} | java | public GroovyRowResult firstRow(GString gstring) throws SQLException {
List<Object> params = getParameters(gstring);
String sql = asSql(gstring, params);
return firstRow(sql, params);
} | [
"public",
"GroovyRowResult",
"firstRow",
"(",
"GString",
"gstring",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"Object",
">",
"params",
"=",
"getParameters",
"(",
"gstring",
")",
";",
"String",
"sql",
"=",
"asSql",
"(",
"gstring",
",",
"params",
")",
";",
"return",
"firstRow",
"(",
"sql",
",",
"params",
")",
";",
"}"
]
| Performs the given SQL query and return
the first row of the result set.
The query may contain GString expressions.
<p>
Example usage:
<pre>
def location = 25
def ans = sql.firstRow("select * from PERSON where location_id {@code <} $location")
println ans.firstname
</pre>
<p>
Resource handling is performed automatically where appropriate.
@param gstring a GString containing the SQL query with embedded params
@return a GroovyRowResult object or <code>null</code> if no row is found
@throws SQLException if a database access error occurs
@see #expand(Object) | [
"Performs",
"the",
"given",
"SQL",
"query",
"and",
"return",
"the",
"first",
"row",
"of",
"the",
"result",
"set",
".",
"The",
"query",
"may",
"contain",
"GString",
"expressions",
".",
"<p",
">",
"Example",
"usage",
":",
"<pre",
">",
"def",
"location",
"=",
"25",
"def",
"ans",
"=",
"sql",
".",
"firstRow",
"(",
"select",
"*",
"from",
"PERSON",
"where",
"location_id",
"{",
"@code",
"<",
"}",
"$location",
")",
"println",
"ans",
".",
"firstname",
"<",
"/",
"pre",
">",
"<p",
">",
"Resource",
"handling",
"is",
"performed",
"automatically",
"where",
"appropriate",
"."
]
| train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java#L2209-L2213 |
mikepenz/Android-Iconics | library-core/src/main/java/com/mikepenz/iconics/Iconics.java | Iconics.styleEditable | public static void styleEditable(@NonNull Context ctx, @NonNull Editable editable) {
"""
Iterates over the editable once and replace icon font placeholders with the correct mapping.
Afterwards it will apply the styles
"""
styleEditable(ctx, null, editable, null, null);
} | java | public static void styleEditable(@NonNull Context ctx, @NonNull Editable editable) {
styleEditable(ctx, null, editable, null, null);
} | [
"public",
"static",
"void",
"styleEditable",
"(",
"@",
"NonNull",
"Context",
"ctx",
",",
"@",
"NonNull",
"Editable",
"editable",
")",
"{",
"styleEditable",
"(",
"ctx",
",",
"null",
",",
"editable",
",",
"null",
",",
"null",
")",
";",
"}"
]
| Iterates over the editable once and replace icon font placeholders with the correct mapping.
Afterwards it will apply the styles | [
"Iterates",
"over",
"the",
"editable",
"once",
"and",
"replace",
"icon",
"font",
"placeholders",
"with",
"the",
"correct",
"mapping",
".",
"Afterwards",
"it",
"will",
"apply",
"the",
"styles"
]
| train | https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/Iconics.java#L235-L237 |
korpling/ANNIS | annis-visualizers/src/main/java/annis/visualizers/iframe/dependency/VakyarthaDependencyTree.java | VakyarthaDependencyTree.getText | private String getText(SNode node, VisualizerInput input) {
"""
Get the text which is overlapped by the SNode.
@return Empty string, if there are no token overlapped by the node.
"""
SDocumentGraph sDocumentGraph = input.getSResult().getDocumentGraph();
List<DataSourceSequence> sequences = sDocumentGraph.
getOverlappedDataSourceSequence(node, SALT_TYPE.STEXT_OVERLAPPING_RELATION);
if (sequences != null && sequences.size() > 0)
{
return ((STextualDS) sequences.get(0).getDataSource()).getText().
substring(sequences.get(0).getStart().intValue(), sequences.get(0).getEnd().intValue());
}
return "";
} | java | private String getText(SNode node, VisualizerInput input)
{
SDocumentGraph sDocumentGraph = input.getSResult().getDocumentGraph();
List<DataSourceSequence> sequences = sDocumentGraph.
getOverlappedDataSourceSequence(node, SALT_TYPE.STEXT_OVERLAPPING_RELATION);
if (sequences != null && sequences.size() > 0)
{
return ((STextualDS) sequences.get(0).getDataSource()).getText().
substring(sequences.get(0).getStart().intValue(), sequences.get(0).getEnd().intValue());
}
return "";
} | [
"private",
"String",
"getText",
"(",
"SNode",
"node",
",",
"VisualizerInput",
"input",
")",
"{",
"SDocumentGraph",
"sDocumentGraph",
"=",
"input",
".",
"getSResult",
"(",
")",
".",
"getDocumentGraph",
"(",
")",
";",
"List",
"<",
"DataSourceSequence",
">",
"sequences",
"=",
"sDocumentGraph",
".",
"getOverlappedDataSourceSequence",
"(",
"node",
",",
"SALT_TYPE",
".",
"STEXT_OVERLAPPING_RELATION",
")",
";",
"if",
"(",
"sequences",
"!=",
"null",
"&&",
"sequences",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"return",
"(",
"(",
"STextualDS",
")",
"sequences",
".",
"get",
"(",
"0",
")",
".",
"getDataSource",
"(",
")",
")",
".",
"getText",
"(",
")",
".",
"substring",
"(",
"sequences",
".",
"get",
"(",
"0",
")",
".",
"getStart",
"(",
")",
".",
"intValue",
"(",
")",
",",
"sequences",
".",
"get",
"(",
"0",
")",
".",
"getEnd",
"(",
")",
".",
"intValue",
"(",
")",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
]
| Get the text which is overlapped by the SNode.
@return Empty string, if there are no token overlapped by the node. | [
"Get",
"the",
"text",
"which",
"is",
"overlapped",
"by",
"the",
"SNode",
"."
]
| train | https://github.com/korpling/ANNIS/blob/152a2e34832e015f73ac8ce8a7d4c32641641324/annis-visualizers/src/main/java/annis/visualizers/iframe/dependency/VakyarthaDependencyTree.java#L388-L402 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowController.java | PageFlowController.persistInSession | public void persistInSession( HttpServletRequest request, HttpServletResponse response ) {
"""
Store this object in the user session, in the appropriate place. Used by the framework; normally should not be
called directly.
"""
PageFlowController currentPageFlow = PageFlowUtils.getCurrentPageFlow( request, getServletContext() );
//
// This code implicitly destroys the current page flow. In order to prevent multiple threads
// from executing inside the JPF at once, synchronize on it in order to complete the "destroy"
// atomically.
//
if ( currentPageFlow != null && ! currentPageFlow.isOnNestingStack() )
{
synchronized ( currentPageFlow )
{
InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
}
}
//
// Here, there is no previous page flow to syncyronize upon before destruction
//
else
{
InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
}
} | java | public void persistInSession( HttpServletRequest request, HttpServletResponse response )
{
PageFlowController currentPageFlow = PageFlowUtils.getCurrentPageFlow( request, getServletContext() );
//
// This code implicitly destroys the current page flow. In order to prevent multiple threads
// from executing inside the JPF at once, synchronize on it in order to complete the "destroy"
// atomically.
//
if ( currentPageFlow != null && ! currentPageFlow.isOnNestingStack() )
{
synchronized ( currentPageFlow )
{
InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
}
}
//
// Here, there is no previous page flow to syncyronize upon before destruction
//
else
{
InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
}
} | [
"public",
"void",
"persistInSession",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"{",
"PageFlowController",
"currentPageFlow",
"=",
"PageFlowUtils",
".",
"getCurrentPageFlow",
"(",
"request",
",",
"getServletContext",
"(",
")",
")",
";",
"//",
"// This code implicitly destroys the current page flow. In order to prevent multiple threads",
"// from executing inside the JPF at once, synchronize on it in order to complete the \"destroy\"",
"// atomically.",
"//",
"if",
"(",
"currentPageFlow",
"!=",
"null",
"&&",
"!",
"currentPageFlow",
".",
"isOnNestingStack",
"(",
")",
")",
"{",
"synchronized",
"(",
"currentPageFlow",
")",
"{",
"InternalUtils",
".",
"setCurrentPageFlow",
"(",
"this",
",",
"request",
",",
"getServletContext",
"(",
")",
")",
";",
"}",
"}",
"//",
"// Here, there is no previous page flow to syncyronize upon before destruction",
"//",
"else",
"{",
"InternalUtils",
".",
"setCurrentPageFlow",
"(",
"this",
",",
"request",
",",
"getServletContext",
"(",
")",
")",
";",
"}",
"}"
]
| Store this object in the user session, in the appropriate place. Used by the framework; normally should not be
called directly. | [
"Store",
"this",
"object",
"in",
"the",
"user",
"session",
"in",
"the",
"appropriate",
"place",
".",
"Used",
"by",
"the",
"framework",
";",
"normally",
"should",
"not",
"be",
"called",
"directly",
"."
]
| train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/PageFlowController.java#L221-L244 |
reactor/reactor-netty | src/main/java/reactor/netty/ChannelBindException.java | ChannelBindException.fail | public static ChannelBindException fail(AbstractBootstrap<?, ?> bootstrap, @Nullable Throwable cause) {
"""
Build a {@link ChannelBindException}
@param bootstrap a netty bootstrap
@param cause a root cause
@return a new {@link ChannelBindException}
"""
Objects.requireNonNull(bootstrap, "bootstrap");
if (cause instanceof java.net.BindException ||
// With epoll/kqueue transport it is
// io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
(cause instanceof IOException && cause.getMessage() != null &&
cause.getMessage().contains("Address already in use"))) {
cause = null;
}
if (!(bootstrap.config().localAddress() instanceof InetSocketAddress)) {
return new ChannelBindException(bootstrap.config().localAddress().toString(), -1, cause);
}
InetSocketAddress address = (InetSocketAddress)bootstrap.config().localAddress();
return new ChannelBindException(address.getHostString(), address.getPort(), cause);
} | java | public static ChannelBindException fail(AbstractBootstrap<?, ?> bootstrap, @Nullable Throwable cause) {
Objects.requireNonNull(bootstrap, "bootstrap");
if (cause instanceof java.net.BindException ||
// With epoll/kqueue transport it is
// io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
(cause instanceof IOException && cause.getMessage() != null &&
cause.getMessage().contains("Address already in use"))) {
cause = null;
}
if (!(bootstrap.config().localAddress() instanceof InetSocketAddress)) {
return new ChannelBindException(bootstrap.config().localAddress().toString(), -1, cause);
}
InetSocketAddress address = (InetSocketAddress)bootstrap.config().localAddress();
return new ChannelBindException(address.getHostString(), address.getPort(), cause);
} | [
"public",
"static",
"ChannelBindException",
"fail",
"(",
"AbstractBootstrap",
"<",
"?",
",",
"?",
">",
"bootstrap",
",",
"@",
"Nullable",
"Throwable",
"cause",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"bootstrap",
",",
"\"bootstrap\"",
")",
";",
"if",
"(",
"cause",
"instanceof",
"java",
".",
"net",
".",
"BindException",
"||",
"// With epoll/kqueue transport it is",
"// io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use",
"(",
"cause",
"instanceof",
"IOException",
"&&",
"cause",
".",
"getMessage",
"(",
")",
"!=",
"null",
"&&",
"cause",
".",
"getMessage",
"(",
")",
".",
"contains",
"(",
"\"Address already in use\"",
")",
")",
")",
"{",
"cause",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"(",
"bootstrap",
".",
"config",
"(",
")",
".",
"localAddress",
"(",
")",
"instanceof",
"InetSocketAddress",
")",
")",
"{",
"return",
"new",
"ChannelBindException",
"(",
"bootstrap",
".",
"config",
"(",
")",
".",
"localAddress",
"(",
")",
".",
"toString",
"(",
")",
",",
"-",
"1",
",",
"cause",
")",
";",
"}",
"InetSocketAddress",
"address",
"=",
"(",
"InetSocketAddress",
")",
"bootstrap",
".",
"config",
"(",
")",
".",
"localAddress",
"(",
")",
";",
"return",
"new",
"ChannelBindException",
"(",
"address",
".",
"getHostString",
"(",
")",
",",
"address",
".",
"getPort",
"(",
")",
",",
"cause",
")",
";",
"}"
]
| Build a {@link ChannelBindException}
@param bootstrap a netty bootstrap
@param cause a root cause
@return a new {@link ChannelBindException} | [
"Build",
"a",
"{",
"@link",
"ChannelBindException",
"}"
]
| train | https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/ChannelBindException.java#L41-L56 |
jbundle/jbundle | base/screen/model/src/main/java/org/jbundle/base/screen/model/MenuScreen.java | MenuScreen.preSetupGrid | public void preSetupGrid(String strMenu) {
"""
Code to display a Menu.
@param strMenu The name of the menu to set up.
"""
super.preSetupGrid(strMenu);
if (m_strMenuObjectID == null)
this.setMenuProperty(strMenu);
Record menu = this.getMainRecord();
menu.setKeyArea(MenusModel.PARENT_FOLDER_ID_KEY);
if (m_strMenuObjectID != null)
strMenu = m_strMenuObjectID;
StringSubFileFilter behMenu = new StringSubFileFilter(strMenu, menu.getField(MenusModel.PARENT_FOLDER_ID), null, null, null, null);
menu.addListener(behMenu);
} | java | public void preSetupGrid(String strMenu)
{
super.preSetupGrid(strMenu);
if (m_strMenuObjectID == null)
this.setMenuProperty(strMenu);
Record menu = this.getMainRecord();
menu.setKeyArea(MenusModel.PARENT_FOLDER_ID_KEY);
if (m_strMenuObjectID != null)
strMenu = m_strMenuObjectID;
StringSubFileFilter behMenu = new StringSubFileFilter(strMenu, menu.getField(MenusModel.PARENT_FOLDER_ID), null, null, null, null);
menu.addListener(behMenu);
} | [
"public",
"void",
"preSetupGrid",
"(",
"String",
"strMenu",
")",
"{",
"super",
".",
"preSetupGrid",
"(",
"strMenu",
")",
";",
"if",
"(",
"m_strMenuObjectID",
"==",
"null",
")",
"this",
".",
"setMenuProperty",
"(",
"strMenu",
")",
";",
"Record",
"menu",
"=",
"this",
".",
"getMainRecord",
"(",
")",
";",
"menu",
".",
"setKeyArea",
"(",
"MenusModel",
".",
"PARENT_FOLDER_ID_KEY",
")",
";",
"if",
"(",
"m_strMenuObjectID",
"!=",
"null",
")",
"strMenu",
"=",
"m_strMenuObjectID",
";",
"StringSubFileFilter",
"behMenu",
"=",
"new",
"StringSubFileFilter",
"(",
"strMenu",
",",
"menu",
".",
"getField",
"(",
"MenusModel",
".",
"PARENT_FOLDER_ID",
")",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"menu",
".",
"addListener",
"(",
"behMenu",
")",
";",
"}"
]
| Code to display a Menu.
@param strMenu The name of the menu to set up. | [
"Code",
"to",
"display",
"a",
"Menu",
"."
]
| train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/MenuScreen.java#L228-L239 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.