repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 188 | func_name stringlengths 7 127 | whole_func_string stringlengths 77 3.91k | language stringclasses 1
value | func_code_string stringlengths 77 3.91k | func_code_tokens listlengths 20 745 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 477 | split_name stringclasses 1
value | func_code_url stringlengths 111 288 |
|---|---|---|---|---|---|---|---|---|---|---|
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.getRoleGroups | public Set<CmsGroup> getRoleGroups(CmsDbContext dbc, String roleGroupName, boolean directUsersOnly)
throws CmsException {
return getRoleGroupsImpl(dbc, roleGroupName, directUsersOnly, new HashMap<String, Set<CmsGroup>>());
} | java | public Set<CmsGroup> getRoleGroups(CmsDbContext dbc, String roleGroupName, boolean directUsersOnly)
throws CmsException {
return getRoleGroupsImpl(dbc, roleGroupName, directUsersOnly, new HashMap<String, Set<CmsGroup>>());
} | [
"public",
"Set",
"<",
"CmsGroup",
">",
"getRoleGroups",
"(",
"CmsDbContext",
"dbc",
",",
"String",
"roleGroupName",
",",
"boolean",
"directUsersOnly",
")",
"throws",
"CmsException",
"{",
"return",
"getRoleGroupsImpl",
"(",
"dbc",
",",
"roleGroupName",
",",
"direct... | Collects the groups which constitute a given role.<p>
@param dbc the database context
@param roleGroupName the group related to the role
@param directUsersOnly if true, only the group belonging to the entry itself wil
@return the set of groups which constitute the role
@throws CmsException if something goes wrong | [
"Collects",
"the",
"groups",
"which",
"constitute",
"a",
"given",
"role",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L4617-L4621 |
h2oai/h2o-2 | src/main/java/water/Job.java | Job.waitUntilJobEnded | public static void waitUntilJobEnded(Key jobkey, int pollingIntervalMillis) {
while (true) {
if (Job.isEnded(jobkey)) {
return;
}
try { Thread.sleep (pollingIntervalMillis); } catch (Exception ignore) {}
}
} | java | public static void waitUntilJobEnded(Key jobkey, int pollingIntervalMillis) {
while (true) {
if (Job.isEnded(jobkey)) {
return;
}
try { Thread.sleep (pollingIntervalMillis); } catch (Exception ignore) {}
}
} | [
"public",
"static",
"void",
"waitUntilJobEnded",
"(",
"Key",
"jobkey",
",",
"int",
"pollingIntervalMillis",
")",
"{",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"Job",
".",
"isEnded",
"(",
"jobkey",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"Threa... | Block synchronously waiting for a job to end, success or not.
@param jobkey Job to wait for.
@param pollingIntervalMillis Polling interval sleep time. | [
"Block",
"synchronously",
"waiting",
"for",
"a",
"job",
"to",
"end",
"success",
"or",
"not",
"."
] | train | https://github.com/h2oai/h2o-2/blob/be350f3f2c2fb6f135cc07c41f83fd0e4f521ac1/src/main/java/water/Job.java#L374-L382 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java | ImgUtil.compress | public static void compress(File imageFile, File outFile, float quality) throws IORuntimeException {
Img.from(imageFile).setQuality(quality).write(outFile);
} | java | public static void compress(File imageFile, File outFile, float quality) throws IORuntimeException {
Img.from(imageFile).setQuality(quality).write(outFile);
} | [
"public",
"static",
"void",
"compress",
"(",
"File",
"imageFile",
",",
"File",
"outFile",
",",
"float",
"quality",
")",
"throws",
"IORuntimeException",
"{",
"Img",
".",
"from",
"(",
"imageFile",
")",
".",
"setQuality",
"(",
"quality",
")",
".",
"write",
"(... | 压缩图像,输出图像只支持jpg文件
@param imageFile 图像文件
@param outFile 输出文件,只支持jpg文件
@throws IORuntimeException IO异常
@since 4.3.2 | [
"压缩图像,输出图像只支持jpg文件"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java#L1130-L1132 |
zalando-stups/java-sproc-wrapper | src/main/java/de/zalando/typemapper/parser/postgres/RowMapper.java | RowMapper.mapRow | public final Element mapRow(final ResultSet rs, final String columnName) throws SQLException {
final Element element = new Element();
List<String> l;
try {
l = ParseUtils.postgresROW2StringList(rs.getString(columnName));
} catch (RowParserException e) {
throw new SQLException(e);
}
element.setRowList(l);
return element;
} | java | public final Element mapRow(final ResultSet rs, final String columnName) throws SQLException {
final Element element = new Element();
List<String> l;
try {
l = ParseUtils.postgresROW2StringList(rs.getString(columnName));
} catch (RowParserException e) {
throw new SQLException(e);
}
element.setRowList(l);
return element;
} | [
"public",
"final",
"Element",
"mapRow",
"(",
"final",
"ResultSet",
"rs",
",",
"final",
"String",
"columnName",
")",
"throws",
"SQLException",
"{",
"final",
"Element",
"element",
"=",
"new",
"Element",
"(",
")",
";",
"List",
"<",
"String",
">",
"l",
";",
... | @param rs
@param columnName
@return
@throws java.sql.SQLException | [
"@param",
"rs",
"@param",
"columnName"
] | train | https://github.com/zalando-stups/java-sproc-wrapper/blob/b86a6243e83e8ea33d1a46e9dbac8c79082dc0ec/src/main/java/de/zalando/typemapper/parser/postgres/RowMapper.java#L31-L42 |
lagom/lagom | service/javadsl/api/src/main/java/com/lightbend/lagom/javadsl/api/transport/RequestHeader.java | RequestHeader.withMethod | public RequestHeader withMethod(Method method) {
return new RequestHeader(method, uri, protocol, acceptedResponseProtocols, principal, headers, lowercaseHeaders);
} | java | public RequestHeader withMethod(Method method) {
return new RequestHeader(method, uri, protocol, acceptedResponseProtocols, principal, headers, lowercaseHeaders);
} | [
"public",
"RequestHeader",
"withMethod",
"(",
"Method",
"method",
")",
"{",
"return",
"new",
"RequestHeader",
"(",
"method",
",",
"uri",
",",
"protocol",
",",
"acceptedResponseProtocols",
",",
"principal",
",",
"headers",
",",
"lowercaseHeaders",
")",
";",
"}"
] | Return a copy of this request header with the given method set.
@param method The method to set.
@return A copy of this request header. | [
"Return",
"a",
"copy",
"of",
"this",
"request",
"header",
"with",
"the",
"given",
"method",
"set",
"."
] | train | https://github.com/lagom/lagom/blob/3763055a9d1aace793a5d970f4e688aea61b1a5a/service/javadsl/api/src/main/java/com/lightbend/lagom/javadsl/api/transport/RequestHeader.java#L92-L94 |
sebastiangraf/perfidix | src/main/java/org/perfidix/ouput/asciitable/NiceTable.java | NiceTable.updateColumnWidth | void updateColumnWidth(final int index, final int newSize) {
columnLengths[index] = Math.max(columnLengths[index], newSize);
} | java | void updateColumnWidth(final int index, final int newSize) {
columnLengths[index] = Math.max(columnLengths[index], newSize);
} | [
"void",
"updateColumnWidth",
"(",
"final",
"int",
"index",
",",
"final",
"int",
"newSize",
")",
"{",
"columnLengths",
"[",
"index",
"]",
"=",
"Math",
".",
"max",
"(",
"columnLengths",
"[",
"index",
"]",
",",
"newSize",
")",
";",
"}"
] | Performs an update on the column lengths.
@param index
the index of the column
@param newSize
the new size of the column | [
"Performs",
"an",
"update",
"on",
"the",
"column",
"lengths",
"."
] | train | https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/ouput/asciitable/NiceTable.java#L167-L169 |
wildfly/wildfly-core | server/src/main/java/org/jboss/as/server/deployment/reflect/DeploymentReflectionIndex.java | DeploymentReflectionIndex.getClassIndex | @SuppressWarnings({"unchecked"})
public synchronized ClassReflectionIndex getClassIndex(Class clazz) {
try {
ClassReflectionIndex index = classes.get(clazz);
if (index == null) {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
index = new ClassReflectionIndex(clazz, this);
} else {
index = AccessController.doPrivileged((PrivilegedAction<ClassReflectionIndex>) () -> new ClassReflectionIndex(clazz, this));
}
classes.put(clazz, index);
}
return index;
} catch (Throwable e) {
throw ServerLogger.ROOT_LOGGER.errorGettingReflectiveInformation(clazz, clazz.getClassLoader(), e);
}
} | java | @SuppressWarnings({"unchecked"})
public synchronized ClassReflectionIndex getClassIndex(Class clazz) {
try {
ClassReflectionIndex index = classes.get(clazz);
if (index == null) {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
index = new ClassReflectionIndex(clazz, this);
} else {
index = AccessController.doPrivileged((PrivilegedAction<ClassReflectionIndex>) () -> new ClassReflectionIndex(clazz, this));
}
classes.put(clazz, index);
}
return index;
} catch (Throwable e) {
throw ServerLogger.ROOT_LOGGER.errorGettingReflectiveInformation(clazz, clazz.getClassLoader(), e);
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
"}",
")",
"public",
"synchronized",
"ClassReflectionIndex",
"getClassIndex",
"(",
"Class",
"clazz",
")",
"{",
"try",
"{",
"ClassReflectionIndex",
"index",
"=",
"classes",
".",
"get",
"(",
"clazz",
")",
";",
"... | Get the (possibly cached) index for a given class.
@param clazz the class
@return the index | [
"Get",
"the",
"(",
"possibly",
"cached",
")",
"index",
"for",
"a",
"given",
"class",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/server/src/main/java/org/jboss/as/server/deployment/reflect/DeploymentReflectionIndex.java#L63-L80 |
Waikato/moa | moa/src/main/java/moa/classifiers/core/attributeclassobservers/FIMTDDNumericAttributeClassObserver.java | FIMTDDNumericAttributeClassObserver.searchForBestSplitOption | protected AttributeSplitSuggestion searchForBestSplitOption(Node currentNode, AttributeSplitSuggestion currentBestOption, SplitCriterion criterion, int attIndex) {
// Return null if the current node is null or we have finished looking through all the possible splits
if (currentNode == null || countRightTotal == 0.0) {
return currentBestOption;
}
if (currentNode.left != null) {
currentBestOption = searchForBestSplitOption(currentNode.left, currentBestOption, criterion, attIndex);
}
sumTotalLeft += currentNode.leftStatistics.getValue(1);
sumTotalRight -= currentNode.leftStatistics.getValue(1);
sumSqTotalLeft += currentNode.leftStatistics.getValue(2);
sumSqTotalRight -= currentNode.leftStatistics.getValue(2);
countLeftTotal += currentNode.leftStatistics.getValue(0);
countRightTotal -= currentNode.leftStatistics.getValue(0);
double[][] postSplitDists = new double[][]{{countLeftTotal, sumTotalLeft, sumSqTotalLeft}, {countRightTotal, sumTotalRight, sumSqTotalRight}};
double[] preSplitDist = new double[]{(countLeftTotal + countRightTotal), (sumTotalLeft + sumTotalRight), (sumSqTotalLeft + sumSqTotalRight)};
double merit = criterion.getMeritOfSplit(preSplitDist, postSplitDists);
if ((currentBestOption == null) || (merit > currentBestOption.merit)) {
currentBestOption = new AttributeSplitSuggestion(
new NumericAttributeBinaryTest(attIndex,
currentNode.cut_point, true), postSplitDists, merit);
}
if (currentNode.right != null) {
currentBestOption = searchForBestSplitOption(currentNode.right, currentBestOption, criterion, attIndex);
}
sumTotalLeft -= currentNode.leftStatistics.getValue(1);
sumTotalRight += currentNode.leftStatistics.getValue(1);
sumSqTotalLeft -= currentNode.leftStatistics.getValue(2);
sumSqTotalRight += currentNode.leftStatistics.getValue(2);
countLeftTotal -= currentNode.leftStatistics.getValue(0);
countRightTotal += currentNode.leftStatistics.getValue(0);
return currentBestOption;
} | java | protected AttributeSplitSuggestion searchForBestSplitOption(Node currentNode, AttributeSplitSuggestion currentBestOption, SplitCriterion criterion, int attIndex) {
// Return null if the current node is null or we have finished looking through all the possible splits
if (currentNode == null || countRightTotal == 0.0) {
return currentBestOption;
}
if (currentNode.left != null) {
currentBestOption = searchForBestSplitOption(currentNode.left, currentBestOption, criterion, attIndex);
}
sumTotalLeft += currentNode.leftStatistics.getValue(1);
sumTotalRight -= currentNode.leftStatistics.getValue(1);
sumSqTotalLeft += currentNode.leftStatistics.getValue(2);
sumSqTotalRight -= currentNode.leftStatistics.getValue(2);
countLeftTotal += currentNode.leftStatistics.getValue(0);
countRightTotal -= currentNode.leftStatistics.getValue(0);
double[][] postSplitDists = new double[][]{{countLeftTotal, sumTotalLeft, sumSqTotalLeft}, {countRightTotal, sumTotalRight, sumSqTotalRight}};
double[] preSplitDist = new double[]{(countLeftTotal + countRightTotal), (sumTotalLeft + sumTotalRight), (sumSqTotalLeft + sumSqTotalRight)};
double merit = criterion.getMeritOfSplit(preSplitDist, postSplitDists);
if ((currentBestOption == null) || (merit > currentBestOption.merit)) {
currentBestOption = new AttributeSplitSuggestion(
new NumericAttributeBinaryTest(attIndex,
currentNode.cut_point, true), postSplitDists, merit);
}
if (currentNode.right != null) {
currentBestOption = searchForBestSplitOption(currentNode.right, currentBestOption, criterion, attIndex);
}
sumTotalLeft -= currentNode.leftStatistics.getValue(1);
sumTotalRight += currentNode.leftStatistics.getValue(1);
sumSqTotalLeft -= currentNode.leftStatistics.getValue(2);
sumSqTotalRight += currentNode.leftStatistics.getValue(2);
countLeftTotal -= currentNode.leftStatistics.getValue(0);
countRightTotal += currentNode.leftStatistics.getValue(0);
return currentBestOption;
} | [
"protected",
"AttributeSplitSuggestion",
"searchForBestSplitOption",
"(",
"Node",
"currentNode",
",",
"AttributeSplitSuggestion",
"currentBestOption",
",",
"SplitCriterion",
"criterion",
",",
"int",
"attIndex",
")",
"{",
"// Return null if the current node is null or we have finish... | Implementation of the FindBestSplit algorithm from E.Ikonomovska et al. | [
"Implementation",
"of",
"the",
"FindBestSplit",
"algorithm",
"from",
"E",
".",
"Ikonomovska",
"et",
"al",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/classifiers/core/attributeclassobservers/FIMTDDNumericAttributeClassObserver.java#L148-L187 |
tweea/matrixjavalib-main-common | src/main/java/net/matrix/util/Collections3.java | Collections3.convertToString | public static String convertToString(final Collection collection, final String prefix, final String postfix) {
StringBuilder builder = new StringBuilder();
for (Object o : collection) {
builder.append(prefix).append(o).append(postfix);
}
return builder.toString();
} | java | public static String convertToString(final Collection collection, final String prefix, final String postfix) {
StringBuilder builder = new StringBuilder();
for (Object o : collection) {
builder.append(prefix).append(o).append(postfix);
}
return builder.toString();
} | [
"public",
"static",
"String",
"convertToString",
"(",
"final",
"Collection",
"collection",
",",
"final",
"String",
"prefix",
",",
"final",
"String",
"postfix",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Objec... | 转换 Collection 所有元素(通过 toString())为 String,每个元素的前面加入 prefix,后面加入
postfix,如<div>mymessage</div>。
@param collection
来源集合
@param prefix
前缀
@param postfix
后缀
@return 组合字符串 | [
"转换",
"Collection",
"所有元素(通过",
"toString",
"()",
")为",
"String,每个元素的前面加入",
"prefix,后面加入",
"postfix,如<div",
">",
"mymessage<",
"/",
"div",
">",
"。"
] | train | https://github.com/tweea/matrixjavalib-main-common/blob/ac8f98322a422e3ef76c3e12d47b98268cec7006/src/main/java/net/matrix/util/Collections3.java#L105-L111 |
Azure/azure-sdk-for-java | datalakestore/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakestore/v2015_10_01_preview/implementation/AccountsInner.java | AccountsInner.deleteFirewallRule | public void deleteFirewallRule(String resourceGroupName, String accountName, String firewallRuleName) {
deleteFirewallRuleWithServiceResponseAsync(resourceGroupName, accountName, firewallRuleName).toBlocking().single().body();
} | java | public void deleteFirewallRule(String resourceGroupName, String accountName, String firewallRuleName) {
deleteFirewallRuleWithServiceResponseAsync(resourceGroupName, accountName, firewallRuleName).toBlocking().single().body();
} | [
"public",
"void",
"deleteFirewallRule",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"firewallRuleName",
")",
"{",
"deleteFirewallRuleWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"firewallRuleName",
")",
... | Deletes the specified firewall rule from the specified Data Lake Store account.
@param resourceGroupName The name of the Azure resource group that contains the Data Lake Store account.
@param accountName The name of the Data Lake Store account from which to delete the firewall rule.
@param firewallRuleName The name of the firewall rule to delete.
@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 | [
"Deletes",
"the",
"specified",
"firewall",
"rule",
"from",
"the",
"specified",
"Data",
"Lake",
"Store",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datalakestore/resource-manager/v2015_10_01_preview/src/main/java/com/microsoft/azure/management/datalakestore/v2015_10_01_preview/implementation/AccountsInner.java#L149-L151 |
liferay/com-liferay-commerce | commerce-api/src/main/java/com/liferay/commerce/model/CommerceCountryWrapper.java | CommerceCountryWrapper.setName | @Override
public void setName(String name, java.util.Locale locale) {
_commerceCountry.setName(name, locale);
} | java | @Override
public void setName(String name, java.util.Locale locale) {
_commerceCountry.setName(name, locale);
} | [
"@",
"Override",
"public",
"void",
"setName",
"(",
"String",
"name",
",",
"java",
".",
"util",
".",
"Locale",
"locale",
")",
"{",
"_commerceCountry",
".",
"setName",
"(",
"name",
",",
"locale",
")",
";",
"}"
] | Sets the localized name of this commerce country in the language.
@param name the localized name of this commerce country
@param locale the locale of the language | [
"Sets",
"the",
"localized",
"name",
"of",
"this",
"commerce",
"country",
"in",
"the",
"language",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-api/src/main/java/com/liferay/commerce/model/CommerceCountryWrapper.java#L693-L696 |
FasterXML/woodstox | src/main/java/com/ctc/wstx/io/InputSourceFactory.java | InputSourceFactory.constructDocumentSource | public static BranchingReaderSource constructDocumentSource
(ReaderConfig cfg, InputBootstrapper bs, String pubId, SystemId sysId,
Reader r, boolean realClose)
{
/* To resolve [WSTX-50] need to ensure that P_BASE_URL overrides
* the defaults if/as necessary
*/
URL url = cfg.getBaseURL();
if (url != null) {
sysId = SystemId.construct(url);
}
BranchingReaderSource rs = new BranchingReaderSource(cfg, pubId, sysId, r, realClose);
if (bs != null) {
rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(),
-bs.getInputColumn());
}
return rs;
} | java | public static BranchingReaderSource constructDocumentSource
(ReaderConfig cfg, InputBootstrapper bs, String pubId, SystemId sysId,
Reader r, boolean realClose)
{
/* To resolve [WSTX-50] need to ensure that P_BASE_URL overrides
* the defaults if/as necessary
*/
URL url = cfg.getBaseURL();
if (url != null) {
sysId = SystemId.construct(url);
}
BranchingReaderSource rs = new BranchingReaderSource(cfg, pubId, sysId, r, realClose);
if (bs != null) {
rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(),
-bs.getInputColumn());
}
return rs;
} | [
"public",
"static",
"BranchingReaderSource",
"constructDocumentSource",
"(",
"ReaderConfig",
"cfg",
",",
"InputBootstrapper",
"bs",
",",
"String",
"pubId",
",",
"SystemId",
"sysId",
",",
"Reader",
"r",
",",
"boolean",
"realClose",
")",
"{",
"/* To resolve [WSTX-50] ne... | Factory method used for creating the main-level document reader
source. | [
"Factory",
"method",
"used",
"for",
"creating",
"the",
"main",
"-",
"level",
"document",
"reader",
"source",
"."
] | train | https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/io/InputSourceFactory.java#L46-L63 |
alkacon/opencms-core | src-gwt/org/opencms/ugc/client/export/CmsXmlContentUgcApi.java | CmsXmlContentUgcApi.handleError | public void handleError(Throwable e, I_CmsErrorCallback callback) {
String errorCode = CmsUgcConstants.ErrorCode.errMisc.toString();
String message;
if (e instanceof CmsUgcException) {
CmsUgcException formException = (CmsUgcException)e;
errorCode = formException.getErrorCode().toString();
message = formException.getUserMessage();
} else {
message = e.getMessage();
}
if (callback != null) {
callback.call(errorCode, message, JavaScriptObject.createObject());
}
} | java | public void handleError(Throwable e, I_CmsErrorCallback callback) {
String errorCode = CmsUgcConstants.ErrorCode.errMisc.toString();
String message;
if (e instanceof CmsUgcException) {
CmsUgcException formException = (CmsUgcException)e;
errorCode = formException.getErrorCode().toString();
message = formException.getUserMessage();
} else {
message = e.getMessage();
}
if (callback != null) {
callback.call(errorCode, message, JavaScriptObject.createObject());
}
} | [
"public",
"void",
"handleError",
"(",
"Throwable",
"e",
",",
"I_CmsErrorCallback",
"callback",
")",
"{",
"String",
"errorCode",
"=",
"CmsUgcConstants",
".",
"ErrorCode",
".",
"errMisc",
".",
"toString",
"(",
")",
";",
"String",
"message",
";",
"if",
"(",
"e"... | Passes an exception to the given error handling callback and optionally outputs some debug info.<p>
@param e the exception
@param callback the error handling callback | [
"Passes",
"an",
"exception",
"to",
"the",
"given",
"error",
"handling",
"callback",
"and",
"optionally",
"outputs",
"some",
"debug",
"info",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ugc/client/export/CmsXmlContentUgcApi.java#L131-L145 |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/xml/XMLUtils.java | XMLUtils.childrenWithTag | public static Iterable<Element> childrenWithTag(Element e, String tag) {
return new ElementChildrenIterable(e, tagNameIsPredicate(tag));
} | java | public static Iterable<Element> childrenWithTag(Element e, String tag) {
return new ElementChildrenIterable(e, tagNameIsPredicate(tag));
} | [
"public",
"static",
"Iterable",
"<",
"Element",
">",
"childrenWithTag",
"(",
"Element",
"e",
",",
"String",
"tag",
")",
"{",
"return",
"new",
"ElementChildrenIterable",
"(",
"e",
",",
"tagNameIsPredicate",
"(",
"tag",
")",
")",
";",
"}"
] | Returns an {@link Iterable} over all children of {@code e} with tag {@code tag} | [
"Returns",
"an",
"{"
] | train | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/xml/XMLUtils.java#L493-L495 |
ltsopensource/light-task-scheduler | lts-core/src/main/java/com/github/ltsopensource/core/commons/utils/GenericsUtils.java | GenericsUtils.getMethodGenericReturnType | public static Class getMethodGenericReturnType(Method method, int index) {
Type returnType = method.getGenericReturnType();
if(returnType instanceof ParameterizedType){
ParameterizedType type = (ParameterizedType) returnType;
Type[] typeArguments = type.getActualTypeArguments();
if (index >= typeArguments.length || index < 0) {
throw new IllegalArgumentException("index "+ (index<0 ? " must > 0 " : " over total arguments"));
}
return (Class)typeArguments[index];
}
return Object.class;
} | java | public static Class getMethodGenericReturnType(Method method, int index) {
Type returnType = method.getGenericReturnType();
if(returnType instanceof ParameterizedType){
ParameterizedType type = (ParameterizedType) returnType;
Type[] typeArguments = type.getActualTypeArguments();
if (index >= typeArguments.length || index < 0) {
throw new IllegalArgumentException("index "+ (index<0 ? " must > 0 " : " over total arguments"));
}
return (Class)typeArguments[index];
}
return Object.class;
} | [
"public",
"static",
"Class",
"getMethodGenericReturnType",
"(",
"Method",
"method",
",",
"int",
"index",
")",
"{",
"Type",
"returnType",
"=",
"method",
".",
"getGenericReturnType",
"(",
")",
";",
"if",
"(",
"returnType",
"instanceof",
"ParameterizedType",
")",
"... | 通过反射,获得方法返回值泛型参数的实际类型. 如: public Map<String, Buyer> getNames(){}
@param method 方法
@param index 泛型参数所在索引,从0开始.
@return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回<code>Object.class</code> | [
"通过反射",
"获得方法返回值泛型参数的实际类型",
".",
"如",
":",
"public",
"Map<String",
"Buyer",
">",
"getNames",
"()",
"{}"
] | train | https://github.com/ltsopensource/light-task-scheduler/blob/64d3aa000ff5022be5e94f511b58f405e5f4c8eb/lts-core/src/main/java/com/github/ltsopensource/core/commons/utils/GenericsUtils.java#L55-L66 |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java | SegmentServiceImpl.readMetaTable | private boolean readMetaTable(ReadStream is, int crc)
throws IOException
{
byte []key = new byte[TABLE_KEY_SIZE];
is.read(key, 0, key.length);
crc = Crc32Caucho.generate(crc, key);
int rowLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, rowLength);
int keyOffset = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, keyOffset);
int keyLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, keyLength);
int dataLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, dataLength);
byte []data = new byte[dataLength];
is.readAll(data, 0, data.length);
crc = Crc32Caucho.generate(crc, data);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-table crc mismatch");
return false;
}
TableEntry entry = new TableEntry(key,
rowLength,
keyOffset,
keyLength,
data);
_tableList.add(entry);
return true;
} | java | private boolean readMetaTable(ReadStream is, int crc)
throws IOException
{
byte []key = new byte[TABLE_KEY_SIZE];
is.read(key, 0, key.length);
crc = Crc32Caucho.generate(crc, key);
int rowLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, rowLength);
int keyOffset = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, keyOffset);
int keyLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, keyLength);
int dataLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, dataLength);
byte []data = new byte[dataLength];
is.readAll(data, 0, data.length);
crc = Crc32Caucho.generate(crc, data);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-table crc mismatch");
return false;
}
TableEntry entry = new TableEntry(key,
rowLength,
keyOffset,
keyLength,
data);
_tableList.add(entry);
return true;
} | [
"private",
"boolean",
"readMetaTable",
"(",
"ReadStream",
"is",
",",
"int",
"crc",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"key",
"=",
"new",
"byte",
"[",
"TABLE_KEY_SIZE",
"]",
";",
"is",
".",
"read",
"(",
"key",
",",
"0",
",",
"key",
"... | Read metadata for a table.
<pre><code>
key byte[32]
rowLength int16
keyOffset int16
keyLength int16
crc int32
</code></pre> | [
"Read",
"metadata",
"for",
"a",
"table",
"."
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java#L770-L811 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringParser.java | StringParser.parseLong | public static long parseLong (@Nullable final String sStr, @Nonnegative final int nRadix, final long nDefault)
{
if (sStr != null && sStr.length () > 0)
try
{
return Long.parseLong (sStr, nRadix);
}
catch (final NumberFormatException ex)
{
// Fall through
}
return nDefault;
} | java | public static long parseLong (@Nullable final String sStr, @Nonnegative final int nRadix, final long nDefault)
{
if (sStr != null && sStr.length () > 0)
try
{
return Long.parseLong (sStr, nRadix);
}
catch (final NumberFormatException ex)
{
// Fall through
}
return nDefault;
} | [
"public",
"static",
"long",
"parseLong",
"(",
"@",
"Nullable",
"final",
"String",
"sStr",
",",
"@",
"Nonnegative",
"final",
"int",
"nRadix",
",",
"final",
"long",
"nDefault",
")",
"{",
"if",
"(",
"sStr",
"!=",
"null",
"&&",
"sStr",
".",
"length",
"(",
... | Parse the given {@link String} as long with the specified radix.
@param sStr
The string to parse. May be <code>null</code>.
@param nRadix
The radix to use. Must be ≥ {@link Character#MIN_RADIX} and ≤
{@link Character#MAX_RADIX}.
@param nDefault
The default value to be returned if the passed object could not be
converted to a valid value.
@return The default if the string does not represent a valid value. | [
"Parse",
"the",
"given",
"{",
"@link",
"String",
"}",
"as",
"long",
"with",
"the",
"specified",
"radix",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringParser.java#L1035-L1047 |
linroid/FilterMenu | library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java | FilterMenuLayout.isClockwise | private boolean isClockwise(Point center, Point a, Point b) {
double cross = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y);
return cross > 0;
} | java | private boolean isClockwise(Point center, Point a, Point b) {
double cross = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y);
return cross > 0;
} | [
"private",
"boolean",
"isClockwise",
"(",
"Point",
"center",
",",
"Point",
"a",
",",
"Point",
"b",
")",
"{",
"double",
"cross",
"=",
"(",
"a",
".",
"x",
"-",
"center",
".",
"x",
")",
"*",
"(",
"b",
".",
"y",
"-",
"center",
".",
"y",
")",
"-",
... | judge a->b is ordered clockwise
@param center
@param a
@param b
@return | [
"judge",
"a",
"-",
">",
"b",
"is",
"ordered",
"clockwise"
] | train | https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L748-L751 |
lazy-koala/java-toolkit | fast-toolkit3d/src/main/java/com/thankjava/toolkit3d/core/ehcache/EhcacheManager.java | EhcacheManager.setCache | public void setCache(String cacheName, String cacheKey, Object object) {
Cache cache = cacheManager.getCache(cacheName);
if (cache == null) {
return;
}
cache.put(new Element(cacheKey, object));
} | java | public void setCache(String cacheName, String cacheKey, Object object) {
Cache cache = cacheManager.getCache(cacheName);
if (cache == null) {
return;
}
cache.put(new Element(cacheKey, object));
} | [
"public",
"void",
"setCache",
"(",
"String",
"cacheName",
",",
"String",
"cacheKey",
",",
"Object",
"object",
")",
"{",
"Cache",
"cache",
"=",
"cacheManager",
".",
"getCache",
"(",
"cacheName",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"{",
"retur... | 设置缓存
<p>Function: setCache</p>
<p>Description: </p>
@param cacheName 缓存名 ehcache.xml 里面配置的缓存策略
@param cacheKey 缓存key
@param object
@author acexy@thankjava.com
@date 2016年4月18日 下午5:41:37
@version 1.0 | [
"设置缓存",
"<p",
">",
"Function",
":",
"setCache<",
"/",
"p",
">",
"<p",
">",
"Description",
":",
"<",
"/",
"p",
">"
] | train | https://github.com/lazy-koala/java-toolkit/blob/f46055fae0cc73049597a3708e515f5c6582d27a/fast-toolkit3d/src/main/java/com/thankjava/toolkit3d/core/ehcache/EhcacheManager.java#L33-L39 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java | IOGroovyMethods.withStream | public static <T, U extends OutputStream> T withStream(U os, @ClosureParams(value=FirstParam.class) Closure<T> closure) throws IOException {
try {
T result = closure.call(os);
os.flush();
OutputStream temp = os;
os = null;
temp.close();
return result;
} finally {
closeWithWarning(os);
}
} | java | public static <T, U extends OutputStream> T withStream(U os, @ClosureParams(value=FirstParam.class) Closure<T> closure) throws IOException {
try {
T result = closure.call(os);
os.flush();
OutputStream temp = os;
os = null;
temp.close();
return result;
} finally {
closeWithWarning(os);
}
} | [
"public",
"static",
"<",
"T",
",",
"U",
"extends",
"OutputStream",
">",
"T",
"withStream",
"(",
"U",
"os",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"FirstParam",
".",
"class",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
... | Passes this OutputStream to the closure, ensuring that the stream
is closed after the closure returns, regardless of errors.
@param os the stream which is used and then closed
@param closure the closure that the stream is passed into
@return the value returned by the closure
@throws IOException if an IOException occurs.
@since 1.5.2 | [
"Passes",
"this",
"OutputStream",
"to",
"the",
"closure",
"ensuring",
"that",
"the",
"stream",
"is",
"closed",
"after",
"the",
"closure",
"returns",
"regardless",
"of",
"errors",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java#L1295-L1308 |
leancloud/java-sdk-all | realtime/src/main/java/cn/leancloud/im/v2/AVIMClient.java | AVIMClient.getConversation | public AVIMConversation getConversation(String conversationId, boolean isTransient, boolean isTemporary) {
return this.getConversation(conversationId, isTransient, isTemporary,false);
} | java | public AVIMConversation getConversation(String conversationId, boolean isTransient, boolean isTemporary) {
return this.getConversation(conversationId, isTransient, isTemporary,false);
} | [
"public",
"AVIMConversation",
"getConversation",
"(",
"String",
"conversationId",
",",
"boolean",
"isTransient",
",",
"boolean",
"isTemporary",
")",
"{",
"return",
"this",
".",
"getConversation",
"(",
"conversationId",
",",
"isTransient",
",",
"isTemporary",
",",
"f... | get an existed conversation
@param conversationId
@param isTransient
@param isTemporary
@return | [
"get",
"an",
"existed",
"conversation"
] | train | https://github.com/leancloud/java-sdk-all/blob/323f8e7ee38051b1350790e5192304768c5c9f5f/realtime/src/main/java/cn/leancloud/im/v2/AVIMClient.java#L429-L431 |
micwin/ticino | events/src/main/java/net/micwin/ticino/events/EventScope.java | EventScope.collectReceiver | private void collectReceiver(final Class<?> eventClass, final Collection<ReceiverDescriptor> receiverCollection) {
if (this.receiverMap.get(eventClass) != null) {
receiverCollection.addAll(this.receiverMap.get(eventClass));
}
if (!eventClass.isInterface() && eventClass.getSuperclass() != Object.class) {
this.collectReceiver(eventClass.getSuperclass(), receiverCollection);
}
for (final Class interfaceClass : eventClass.getInterfaces()) {
this.collectReceiver(interfaceClass, receiverCollection);
}
} | java | private void collectReceiver(final Class<?> eventClass, final Collection<ReceiverDescriptor> receiverCollection) {
if (this.receiverMap.get(eventClass) != null) {
receiverCollection.addAll(this.receiverMap.get(eventClass));
}
if (!eventClass.isInterface() && eventClass.getSuperclass() != Object.class) {
this.collectReceiver(eventClass.getSuperclass(), receiverCollection);
}
for (final Class interfaceClass : eventClass.getInterfaces()) {
this.collectReceiver(interfaceClass, receiverCollection);
}
} | [
"private",
"void",
"collectReceiver",
"(",
"final",
"Class",
"<",
"?",
">",
"eventClass",
",",
"final",
"Collection",
"<",
"ReceiverDescriptor",
">",
"receiverCollection",
")",
"{",
"if",
"(",
"this",
".",
"receiverMap",
".",
"get",
"(",
"eventClass",
")",
"... | collects receiver descriptors of super classes and interfaces.
@param eventClass
@param receiverCollection
the collection receivers are put in. | [
"collects",
"receiver",
"descriptors",
"of",
"super",
"classes",
"and",
"interfaces",
"."
] | train | https://github.com/micwin/ticino/blob/4d143093500cd2fb9767ebe8cd05ddda23e35613/events/src/main/java/net/micwin/ticino/events/EventScope.java#L421-L432 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java | AppServiceEnvironmentsInner.listWorkerPoolInstanceMetricDefinitionsAsync | public Observable<Page<ResourceMetricDefinitionInner>> listWorkerPoolInstanceMetricDefinitionsAsync(final String resourceGroupName, final String name, final String workerPoolName, final String instance) {
return listWorkerPoolInstanceMetricDefinitionsWithServiceResponseAsync(resourceGroupName, name, workerPoolName, instance)
.map(new Func1<ServiceResponse<Page<ResourceMetricDefinitionInner>>, Page<ResourceMetricDefinitionInner>>() {
@Override
public Page<ResourceMetricDefinitionInner> call(ServiceResponse<Page<ResourceMetricDefinitionInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<ResourceMetricDefinitionInner>> listWorkerPoolInstanceMetricDefinitionsAsync(final String resourceGroupName, final String name, final String workerPoolName, final String instance) {
return listWorkerPoolInstanceMetricDefinitionsWithServiceResponseAsync(resourceGroupName, name, workerPoolName, instance)
.map(new Func1<ServiceResponse<Page<ResourceMetricDefinitionInner>>, Page<ResourceMetricDefinitionInner>>() {
@Override
public Page<ResourceMetricDefinitionInner> call(ServiceResponse<Page<ResourceMetricDefinitionInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"ResourceMetricDefinitionInner",
">",
">",
"listWorkerPoolInstanceMetricDefinitionsAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
",",
"final",
"String",
"workerPoolName",
",",
"final",
"Str... | Get metric definitions for a specific instance of a worker pool of an App Service Environment.
Get metric definitions for a specific instance of a worker pool of an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param workerPoolName Name of the worker pool.
@param instance Name of the instance in the worker pool.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ResourceMetricDefinitionInner> object | [
"Get",
"metric",
"definitions",
"for",
"a",
"specific",
"instance",
"of",
"a",
"worker",
"pool",
"of",
"an",
"App",
"Service",
"Environment",
".",
"Get",
"metric",
"definitions",
"for",
"a",
"specific",
"instance",
"of",
"a",
"worker",
"pool",
"of",
"an",
... | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L5541-L5549 |
OpenLiberty/open-liberty | dev/com.ibm.ws.event/src/com/ibm/ws/event/internal/TopicBasedCache.java | TopicBasedCache.getTopicData | TopicData getTopicData(Topic topic, String topicName) {
TopicData topicData = null;
if (topic != null) {
topicData = topic.getTopicData();
}
if (topicData == null) {
topicData = topicDataCache.get(topicName);
if (topic != null && topicData != null) {
topic.setTopicDataReference(topicData.getReference());
}
}
if (topicData == null) {
synchronized (this) {
topicData = buildTopicData(topicName);
if (topic != null) {
topic.setTopicDataReference(topicData.getReference());
}
}
}
return topicData;
} | java | TopicData getTopicData(Topic topic, String topicName) {
TopicData topicData = null;
if (topic != null) {
topicData = topic.getTopicData();
}
if (topicData == null) {
topicData = topicDataCache.get(topicName);
if (topic != null && topicData != null) {
topic.setTopicDataReference(topicData.getReference());
}
}
if (topicData == null) {
synchronized (this) {
topicData = buildTopicData(topicName);
if (topic != null) {
topic.setTopicDataReference(topicData.getReference());
}
}
}
return topicData;
} | [
"TopicData",
"getTopicData",
"(",
"Topic",
"topic",
",",
"String",
"topicName",
")",
"{",
"TopicData",
"topicData",
"=",
"null",
";",
"if",
"(",
"topic",
"!=",
"null",
")",
"{",
"topicData",
"=",
"topic",
".",
"getTopicData",
"(",
")",
";",
"}",
"if",
... | Get the cached information about the specified topic. The cached data
will allow us to avoid the expense of finding various and sundry data
associated with a specific topic and topic hierarchies.
@param topic
the topic associated with an event
@param topicName
the topic name associated with an event
@return the cached information | [
"Get",
"the",
"cached",
"information",
"about",
"the",
"specified",
"topic",
".",
"The",
"cached",
"data",
"will",
"allow",
"us",
"to",
"avoid",
"the",
"expense",
"of",
"finding",
"various",
"and",
"sundry",
"data",
"associated",
"with",
"a",
"specific",
"to... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.event/src/com/ibm/ws/event/internal/TopicBasedCache.java#L233-L257 |
attribyte/wpdb | src/main/java/org/attribyte/wp/db/DB.java | DB.addPostTerm | public boolean addPostTerm(final long postId, final TaxonomyTerm taxonomyTerm) throws SQLException {
List<TaxonomyTerm> currTerms = selectPostTerms(postId, taxonomyTerm.taxonomy);
for(TaxonomyTerm currTerm : currTerms) {
if(currTerm.term.name.equals(taxonomyTerm.term.name)) {
return false;
}
}
Connection conn = null;
PreparedStatement stmt = null;
Timer.Context ctx = metrics.postTermsSetTimer.time();
try {
conn = connectionSupplier.getConnection();
stmt = conn.prepareStatement(insertPostTermSQL);
stmt.setLong(1, postId);
stmt.setLong(2, taxonomyTerm.id);
stmt.setInt(3, currTerms.size()); //Add at the last position...
return stmt.executeUpdate() > 0;
} finally {
ctx.stop();
SQLUtil.closeQuietly(conn, stmt);
}
} | java | public boolean addPostTerm(final long postId, final TaxonomyTerm taxonomyTerm) throws SQLException {
List<TaxonomyTerm> currTerms = selectPostTerms(postId, taxonomyTerm.taxonomy);
for(TaxonomyTerm currTerm : currTerms) {
if(currTerm.term.name.equals(taxonomyTerm.term.name)) {
return false;
}
}
Connection conn = null;
PreparedStatement stmt = null;
Timer.Context ctx = metrics.postTermsSetTimer.time();
try {
conn = connectionSupplier.getConnection();
stmt = conn.prepareStatement(insertPostTermSQL);
stmt.setLong(1, postId);
stmt.setLong(2, taxonomyTerm.id);
stmt.setInt(3, currTerms.size()); //Add at the last position...
return stmt.executeUpdate() > 0;
} finally {
ctx.stop();
SQLUtil.closeQuietly(conn, stmt);
}
} | [
"public",
"boolean",
"addPostTerm",
"(",
"final",
"long",
"postId",
",",
"final",
"TaxonomyTerm",
"taxonomyTerm",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"TaxonomyTerm",
">",
"currTerms",
"=",
"selectPostTerms",
"(",
"postId",
",",
"taxonomyTerm",
".",
... | Adds a term at the end of the current terms if it does not already exist.
@param postId The post id.
@param taxonomyTerm The taxonomy term to add.
@return Was the term added?
@throws SQLException on database error. | [
"Adds",
"a",
"term",
"at",
"the",
"end",
"of",
"the",
"current",
"terms",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | train | https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/db/DB.java#L2529-L2552 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java | JBBPDslBuilder.ShortArray | public JBBPDslBuilder ShortArray(final String name, final String sizeExpression) {
final Item item = new Item(BinType.SHORT_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | java | public JBBPDslBuilder ShortArray(final String name, final String sizeExpression) {
final Item item = new Item(BinType.SHORT_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | [
"public",
"JBBPDslBuilder",
"ShortArray",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"sizeExpression",
")",
"{",
"final",
"Item",
"item",
"=",
"new",
"Item",
"(",
"BinType",
".",
"SHORT_ARRAY",
",",
"name",
",",
"this",
".",
"byteOrder",
")",
... | Add named fixed signed short array which size calculated through expression.
@param name name of the field, if null then anonymous
@param sizeExpression expression to be used to calculate size, must not be null
@return the builder instance, must not be null | [
"Add",
"named",
"fixed",
"signed",
"short",
"array",
"which",
"size",
"calculated",
"through",
"expression",
"."
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L1003-L1008 |
nguyenq/tess4j | src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java | ImageIOHelper.getIIOImageList | public static List<IIOImage> getIIOImageList(BufferedImage bi) throws IOException {
List<IIOImage> iioImageList = new ArrayList<IIOImage>();
IIOImage oimage = new IIOImage(bi, null, null);
iioImageList.add(oimage);
return iioImageList;
} | java | public static List<IIOImage> getIIOImageList(BufferedImage bi) throws IOException {
List<IIOImage> iioImageList = new ArrayList<IIOImage>();
IIOImage oimage = new IIOImage(bi, null, null);
iioImageList.add(oimage);
return iioImageList;
} | [
"public",
"static",
"List",
"<",
"IIOImage",
">",
"getIIOImageList",
"(",
"BufferedImage",
"bi",
")",
"throws",
"IOException",
"{",
"List",
"<",
"IIOImage",
">",
"iioImageList",
"=",
"new",
"ArrayList",
"<",
"IIOImage",
">",
"(",
")",
";",
"IIOImage",
"oimag... | Gets a list of <code>IIOImage</code> objects for a
<code>BufferedImage</code>.
@param bi input image
@return a list of <code>IIOImage</code> objects
@throws IOException | [
"Gets",
"a",
"list",
"of",
"<code",
">",
"IIOImage<",
"/",
"code",
">",
"objects",
"for",
"a",
"<code",
">",
"BufferedImage<",
"/",
"code",
">",
"."
] | train | https://github.com/nguyenq/tess4j/blob/cfcd4a8a44042f150b4aaf7bdf5ffc485a2236e1/src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java#L431-L436 |
UrielCh/ovh-java-sdk | ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java | ApiOvhXdsl.serviceName_modem_portMappings_name_PUT | public void serviceName_modem_portMappings_name_PUT(String serviceName, String name, OvhPortMapping body) throws IOException {
String qPath = "/xdsl/{serviceName}/modem/portMappings/{name}";
StringBuilder sb = path(qPath, serviceName, name);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_modem_portMappings_name_PUT(String serviceName, String name, OvhPortMapping body) throws IOException {
String qPath = "/xdsl/{serviceName}/modem/portMappings/{name}";
StringBuilder sb = path(qPath, serviceName, name);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_modem_portMappings_name_PUT",
"(",
"String",
"serviceName",
",",
"String",
"name",
",",
"OvhPortMapping",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/xdsl/{serviceName}/modem/portMappings/{name}\"",
";",
"StringBuild... | Alter this object properties
REST: PUT /xdsl/{serviceName}/modem/portMappings/{name}
@param body [required] New object properties
@param serviceName [required] The internal name of your XDSL offer
@param name [required] Name of the port mapping entry | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java#L1288-L1292 |
sebastiangraf/perfidix | src/main/java/org/perfidix/element/BenchmarkExecutor.java | BenchmarkExecutor.checkAndExecuteBeforeAfters | private void checkAndExecuteBeforeAfters(final Object obj, final Class<? extends Annotation> anno, final Method... meths) {
final PerfidixMethodCheckException checkExc = checkMethod(obj, anno, meths);
if (checkExc == null) {
for (Method m : meths) {
final PerfidixMethodInvocationException invoExc = invokeMethod(obj, anno, m);
if (invoExc != null) {
BENCHRES.addException(invoExc);
}
}
} else {
BENCHRES.addException(checkExc);
}
} | java | private void checkAndExecuteBeforeAfters(final Object obj, final Class<? extends Annotation> anno, final Method... meths) {
final PerfidixMethodCheckException checkExc = checkMethod(obj, anno, meths);
if (checkExc == null) {
for (Method m : meths) {
final PerfidixMethodInvocationException invoExc = invokeMethod(obj, anno, m);
if (invoExc != null) {
BENCHRES.addException(invoExc);
}
}
} else {
BENCHRES.addException(checkExc);
}
} | [
"private",
"void",
"checkAndExecuteBeforeAfters",
"(",
"final",
"Object",
"obj",
",",
"final",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"anno",
",",
"final",
"Method",
"...",
"meths",
")",
"{",
"final",
"PerfidixMethodCheckException",
"checkExc",
"=",
"c... | Checking and executing several before/after methods.
@param obj on which the execution should take place
@param meths to be executed
@param anno the related annotation | [
"Checking",
"and",
"executing",
"several",
"before",
"/",
"after",
"methods",
"."
] | train | https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/element/BenchmarkExecutor.java#L305-L317 |
UrielCh/ovh-java-sdk | ovh-java-sdk-newAccount/src/main/java/net/minidev/ovh/api/ApiOvhNewAccount.java | ApiOvhNewAccount.contracts_GET | public ArrayList<OvhContract> contracts_GET(OvhOvhCompanyEnum company, OvhOvhSubsidiaryEnum subsidiary) throws IOException {
String qPath = "/newAccount/contracts";
StringBuilder sb = path(qPath);
query(sb, "company", company);
query(sb, "subsidiary", subsidiary);
String resp = execN(qPath, "GET", sb.toString(), null);
return convertTo(resp, t3);
} | java | public ArrayList<OvhContract> contracts_GET(OvhOvhCompanyEnum company, OvhOvhSubsidiaryEnum subsidiary) throws IOException {
String qPath = "/newAccount/contracts";
StringBuilder sb = path(qPath);
query(sb, "company", company);
query(sb, "subsidiary", subsidiary);
String resp = execN(qPath, "GET", sb.toString(), null);
return convertTo(resp, t3);
} | [
"public",
"ArrayList",
"<",
"OvhContract",
">",
"contracts_GET",
"(",
"OvhOvhCompanyEnum",
"company",
",",
"OvhOvhSubsidiaryEnum",
"subsidiary",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/newAccount/contracts\"",
";",
"StringBuilder",
"sb",
"=",
"p... | Returns the contracts that governs the creation of an OVH identifier
REST: GET /newAccount/contracts
@param subsidiary [required]
@param company [required] | [
"Returns",
"the",
"contracts",
"that",
"governs",
"the",
"creation",
"of",
"an",
"OVH",
"identifier"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-newAccount/src/main/java/net/minidev/ovh/api/ApiOvhNewAccount.java#L70-L77 |
kiswanij/jk-util | src/main/java/com/jk/util/JKDateTimeUtil.java | JKDateTimeUtil.isDate | public static boolean isDate(String strDate, String pattern) {
try {
parseDate(strDate, pattern);
return true;
} catch (Exception e) {
return false;
}
} | java | public static boolean isDate(String strDate, String pattern) {
try {
parseDate(strDate, pattern);
return true;
} catch (Exception e) {
return false;
}
} | [
"public",
"static",
"boolean",
"isDate",
"(",
"String",
"strDate",
",",
"String",
"pattern",
")",
"{",
"try",
"{",
"parseDate",
"(",
"strDate",
",",
"pattern",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"f... | Checks if is date.
@param strDate the str date
@param pattern the pattern
@return true, if is date | [
"Checks",
"if",
"is",
"date",
"."
] | train | https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/JKDateTimeUtil.java#L236-L243 |
spring-projects/spring-android | spring-android-rest-template/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java | HierarchicalUriComponents.encodeUriComponent | static String encodeUriComponent(String source, String encoding, Type type) throws UnsupportedEncodingException {
if (source == null) {
return null;
}
Assert.hasLength(encoding, "Encoding must not be empty");
byte[] bytes = encodeBytes(source.getBytes(encoding), type);
return new String(bytes, "US-ASCII");
} | java | static String encodeUriComponent(String source, String encoding, Type type) throws UnsupportedEncodingException {
if (source == null) {
return null;
}
Assert.hasLength(encoding, "Encoding must not be empty");
byte[] bytes = encodeBytes(source.getBytes(encoding), type);
return new String(bytes, "US-ASCII");
} | [
"static",
"String",
"encodeUriComponent",
"(",
"String",
"source",
",",
"String",
"encoding",
",",
"Type",
"type",
")",
"throws",
"UnsupportedEncodingException",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Assert",
".",
"ha... | Encodes the given source into an encoded String using the rules specified
by the given component and with the given options.
@param source the source string
@param encoding the encoding of the source string
@param type the URI component for the source
@return the encoded URI
@throws IllegalArgumentException when the given uri parameter is not a valid URI | [
"Encodes",
"the",
"given",
"source",
"into",
"an",
"encoded",
"String",
"using",
"the",
"rules",
"specified",
"by",
"the",
"given",
"component",
"and",
"with",
"the",
"given",
"options",
"."
] | train | https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-rest-template/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java#L220-L227 |
docusign/docusign-java-client | src/main/java/com/docusign/esign/api/EnvelopesApi.java | EnvelopesApi.updateChunkedUpload | public ChunkedUploadResponse updateChunkedUpload(String accountId, String chunkedUploadId) throws ApiException {
return updateChunkedUpload(accountId, chunkedUploadId, null);
} | java | public ChunkedUploadResponse updateChunkedUpload(String accountId, String chunkedUploadId) throws ApiException {
return updateChunkedUpload(accountId, chunkedUploadId, null);
} | [
"public",
"ChunkedUploadResponse",
"updateChunkedUpload",
"(",
"String",
"accountId",
",",
"String",
"chunkedUploadId",
")",
"throws",
"ApiException",
"{",
"return",
"updateChunkedUpload",
"(",
"accountId",
",",
"chunkedUploadId",
",",
"null",
")",
";",
"}"
] | Integrity-Check and Commit a ChunkedUpload, readying it for use elsewhere.
@param accountId The external account number (int) or account ID Guid. (required)
@param chunkedUploadId (required)
@return ChunkedUploadResponse | [
"Integrity",
"-",
"Check",
"and",
"Commit",
"a",
"ChunkedUpload",
"readying",
"it",
"for",
"use",
"elsewhere",
"."
] | train | https://github.com/docusign/docusign-java-client/blob/17ae82ace0f023e98edf813be832950568212e34/src/main/java/com/docusign/esign/api/EnvelopesApi.java#L4782-L4784 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/BatchUpdateDaemon.java | BatchUpdateDaemon.invalidateById | public void invalidateById(Object id, int causeOfInvalidation, boolean waitOnInvalidation, DCache cache, boolean checkPreInvalidationListener) {
invalidateById(id, causeOfInvalidation, CachePerf.LOCAL, waitOnInvalidation, InvalidateByIdEvent.INVOKE_INTERNAL_INVALIDATE_BY_ID, InvalidateByIdEvent.INVOKE_DRS_RENOUNCE,
cache, checkPreInvalidationListener);
} | java | public void invalidateById(Object id, int causeOfInvalidation, boolean waitOnInvalidation, DCache cache, boolean checkPreInvalidationListener) {
invalidateById(id, causeOfInvalidation, CachePerf.LOCAL, waitOnInvalidation, InvalidateByIdEvent.INVOKE_INTERNAL_INVALIDATE_BY_ID, InvalidateByIdEvent.INVOKE_DRS_RENOUNCE,
cache, checkPreInvalidationListener);
} | [
"public",
"void",
"invalidateById",
"(",
"Object",
"id",
",",
"int",
"causeOfInvalidation",
",",
"boolean",
"waitOnInvalidation",
",",
"DCache",
"cache",
",",
"boolean",
"checkPreInvalidationListener",
")",
"{",
"invalidateById",
"(",
"id",
",",
"causeOfInvalidation",... | This invalidates a cache entry in all
caches (with the same cache name)
whose cache id or data id is specified.
@param id The id (cache id or data id) that is used to to
invalidate fragments.
@param waitOnInvalidation True indicates that this method should
not return until all invalidations have taken effect.
False indicates that the invalidations will take effect the next
time the BatchUpdateDaemon wakes.
@param causeOfInvalidation The cause of this invalidation.
@param checkPreInvalidationListener true indicates that we will verify with the preInvalidationListener
prior to invalidating. False means we will bypass this check. | [
"This",
"invalidates",
"a",
"cache",
"entry",
"in",
"all",
"caches",
"(",
"with",
"the",
"same",
"cache",
"name",
")",
"whose",
"cache",
"id",
"or",
"data",
"id",
"is",
"specified",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/BatchUpdateDaemon.java#L140-L143 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLSameIndividualAxiomImpl_CustomFieldSerializer.java | OWLSameIndividualAxiomImpl_CustomFieldSerializer.deserializeInstance | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLSameIndividualAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | java | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLSameIndividualAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | [
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLSameIndividualAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] | Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful | [
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLSameIndividualAxiomImpl_CustomFieldSerializer.java#L95-L98 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/repository/internal/AbstractCachedExtensionRepository.java | AbstractCachedExtensionRepository.addCachedExtensionVersion | protected void addCachedExtensionVersion(String feature, E extension)
{
// versions
List<E> versions = this.extensionsVersions.get(feature);
if (versions == null) {
versions = new ArrayList<E>();
this.extensionsVersions.put(feature, versions);
versions.add(extension);
} else {
int index = 0;
while (index < versions.size()
&& extension.getId().getVersion().compareTo(versions.get(index).getId().getVersion()) < 0) {
++index;
}
versions.add(index, extension);
}
} | java | protected void addCachedExtensionVersion(String feature, E extension)
{
// versions
List<E> versions = this.extensionsVersions.get(feature);
if (versions == null) {
versions = new ArrayList<E>();
this.extensionsVersions.put(feature, versions);
versions.add(extension);
} else {
int index = 0;
while (index < versions.size()
&& extension.getId().getVersion().compareTo(versions.get(index).getId().getVersion()) < 0) {
++index;
}
versions.add(index, extension);
}
} | [
"protected",
"void",
"addCachedExtensionVersion",
"(",
"String",
"feature",
",",
"E",
"extension",
")",
"{",
"// versions",
"List",
"<",
"E",
">",
"versions",
"=",
"this",
".",
"extensionsVersions",
".",
"get",
"(",
"feature",
")",
";",
"if",
"(",
"versions"... | Register extension in all caches.
@param feature the feature
@param extension the extension | [
"Register",
"extension",
"in",
"all",
"caches",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/repository/internal/AbstractCachedExtensionRepository.java#L121-L140 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfDocument.java | PdfDocument.localDestination | boolean localDestination(String name, PdfDestination destination) {
Object obj[] = (Object[])localDestinations.get(name);
if (obj == null)
obj = new Object[3];
if (obj[2] != null)
return false;
obj[2] = destination;
localDestinations.put(name, obj);
destination.addPage(writer.getCurrentPage());
return true;
} | java | boolean localDestination(String name, PdfDestination destination) {
Object obj[] = (Object[])localDestinations.get(name);
if (obj == null)
obj = new Object[3];
if (obj[2] != null)
return false;
obj[2] = destination;
localDestinations.put(name, obj);
destination.addPage(writer.getCurrentPage());
return true;
} | [
"boolean",
"localDestination",
"(",
"String",
"name",
",",
"PdfDestination",
"destination",
")",
"{",
"Object",
"obj",
"[",
"]",
"=",
"(",
"Object",
"[",
"]",
")",
"localDestinations",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"obj",
"==",
"null",
... | The local destination to where a local goto with the same
name will jump to.
@param name the name of this local destination
@param destination the <CODE>PdfDestination</CODE> with the jump coordinates
@return <CODE>true</CODE> if the local destination was added,
<CODE>false</CODE> if a local destination with the same name
already existed | [
"The",
"local",
"destination",
"to",
"where",
"a",
"local",
"goto",
"with",
"the",
"same",
"name",
"will",
"jump",
"to",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfDocument.java#L2089-L2099 |
msgpack/msgpack-java | msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java | MessageUnpacker.unpackLong | public long unpackLong()
throws IOException
{
byte b = readByte();
if (Code.isFixInt(b)) {
return (long) b;
}
switch (b) {
case Code.UINT8: // unsigned int 8
byte u8 = readByte();
return (long) (u8 & 0xff);
case Code.UINT16: // unsigned int 16
short u16 = readShort();
return (long) (u16 & 0xffff);
case Code.UINT32: // unsigned int 32
int u32 = readInt();
if (u32 < 0) {
return (long) (u32 & 0x7fffffff) + 0x80000000L;
}
else {
return (long) u32;
}
case Code.UINT64: // unsigned int 64
long u64 = readLong();
if (u64 < 0L) {
throw overflowU64(u64);
}
return u64;
case Code.INT8: // signed int 8
byte i8 = readByte();
return (long) i8;
case Code.INT16: // signed int 16
short i16 = readShort();
return (long) i16;
case Code.INT32: // signed int 32
int i32 = readInt();
return (long) i32;
case Code.INT64: // signed int 64
long i64 = readLong();
return i64;
}
throw unexpected("Integer", b);
} | java | public long unpackLong()
throws IOException
{
byte b = readByte();
if (Code.isFixInt(b)) {
return (long) b;
}
switch (b) {
case Code.UINT8: // unsigned int 8
byte u8 = readByte();
return (long) (u8 & 0xff);
case Code.UINT16: // unsigned int 16
short u16 = readShort();
return (long) (u16 & 0xffff);
case Code.UINT32: // unsigned int 32
int u32 = readInt();
if (u32 < 0) {
return (long) (u32 & 0x7fffffff) + 0x80000000L;
}
else {
return (long) u32;
}
case Code.UINT64: // unsigned int 64
long u64 = readLong();
if (u64 < 0L) {
throw overflowU64(u64);
}
return u64;
case Code.INT8: // signed int 8
byte i8 = readByte();
return (long) i8;
case Code.INT16: // signed int 16
short i16 = readShort();
return (long) i16;
case Code.INT32: // signed int 32
int i32 = readInt();
return (long) i32;
case Code.INT64: // signed int 64
long i64 = readLong();
return i64;
}
throw unexpected("Integer", b);
} | [
"public",
"long",
"unpackLong",
"(",
")",
"throws",
"IOException",
"{",
"byte",
"b",
"=",
"readByte",
"(",
")",
";",
"if",
"(",
"Code",
".",
"isFixInt",
"(",
"b",
")",
")",
"{",
"return",
"(",
"long",
")",
"b",
";",
"}",
"switch",
"(",
"b",
")",
... | Reads a long.
This method throws {@link MessageIntegerOverflowException} if the value doesn't fit in the range of long. This may happen when {@link #getNextFormat()} returns UINT64.
@return the read value
@throws MessageIntegerOverflowException when value doesn't fit in the range of long
@throws MessageTypeException when value is not MessagePack Integer type
@throws IOException when underlying input throws IOException | [
"Reads",
"a",
"long",
"."
] | train | https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L972-L1014 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/util/raytrace/RaytraceWorld.java | RaytraceWorld.getMin | public double getMin(double x, double y, double z)
{
double ret = Double.NaN;
if (!Double.isNaN(x))
ret = x;
if (!Double.isNaN(y))
{
if (!Double.isNaN(ret))
ret = Math.min(ret, y);
else
ret = y;
}
if (!Double.isNaN(z))
{
if (!Double.isNaN(ret))
ret = Math.min(ret, z);
else
ret = z;
}
return ret;
} | java | public double getMin(double x, double y, double z)
{
double ret = Double.NaN;
if (!Double.isNaN(x))
ret = x;
if (!Double.isNaN(y))
{
if (!Double.isNaN(ret))
ret = Math.min(ret, y);
else
ret = y;
}
if (!Double.isNaN(z))
{
if (!Double.isNaN(ret))
ret = Math.min(ret, z);
else
ret = z;
}
return ret;
} | [
"public",
"double",
"getMin",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"double",
"ret",
"=",
"Double",
".",
"NaN",
";",
"if",
"(",
"!",
"Double",
".",
"isNaN",
"(",
"x",
")",
")",
"ret",
"=",
"x",
";",
"if",
"(",
... | Gets the minimum value of <code>x</code>, <code>y</code>, <code>z</code>.
@param x the x
@param y the y
@param z the z
@return <code>Double.NaN</code> if <code>x</code>, <code>y</code> and <code>z</code> are all three <code>Double.NaN</code> | [
"Gets",
"the",
"minimum",
"value",
"of",
"<code",
">",
"x<",
"/",
"code",
">",
"<code",
">",
"y<",
"/",
"code",
">",
"<code",
">",
"z<",
"/",
"code",
">",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/raytrace/RaytraceWorld.java#L251-L271 |
cogroo/cogroo4 | cogroo-ann/src/main/java/org/cogroo/config/LanguageConfigurationUtil.java | LanguageConfigurationUtil.get | public static LanguageConfiguration get(InputStream configuration) {
try {
return unmarshal(configuration);
} catch (JAXBException e) {
throw new InitializationException("Invalid configuration file.", e);
}
} | java | public static LanguageConfiguration get(InputStream configuration) {
try {
return unmarshal(configuration);
} catch (JAXBException e) {
throw new InitializationException("Invalid configuration file.", e);
}
} | [
"public",
"static",
"LanguageConfiguration",
"get",
"(",
"InputStream",
"configuration",
")",
"{",
"try",
"{",
"return",
"unmarshal",
"(",
"configuration",
")",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"throw",
"new",
"InitializationException",
"(... | Creates a {@link LanguageConfiguration} from a {@link InputStream}, which
remains opened.
@param configuration
the input stream
@return a {@link LanguageConfiguration} | [
"Creates",
"a",
"{",
"@link",
"LanguageConfiguration",
"}",
"from",
"a",
"{",
"@link",
"InputStream",
"}",
"which",
"remains",
"opened",
"."
] | train | https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-ann/src/main/java/org/cogroo/config/LanguageConfigurationUtil.java#L69-L75 |
aws/aws-sdk-java | aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/CodeGenerator.java | CodeGenerator.execute | public void execute() {
try {
final IntermediateModel intermediateModel =
new IntermediateModelBuilder(models, codeGenBinDirectory).build();
// Dump the intermediate model to a file
writeIntermediateModel(intermediateModel);
emitCode(intermediateModel);
} catch (Exception e) {
throw new RuntimeException(
"Failed to generate code. Exception message : "
+ e.getMessage(), e);
}
} | java | public void execute() {
try {
final IntermediateModel intermediateModel =
new IntermediateModelBuilder(models, codeGenBinDirectory).build();
// Dump the intermediate model to a file
writeIntermediateModel(intermediateModel);
emitCode(intermediateModel);
} catch (Exception e) {
throw new RuntimeException(
"Failed to generate code. Exception message : "
+ e.getMessage(), e);
}
} | [
"public",
"void",
"execute",
"(",
")",
"{",
"try",
"{",
"final",
"IntermediateModel",
"intermediateModel",
"=",
"new",
"IntermediateModelBuilder",
"(",
"models",
",",
"codeGenBinDirectory",
")",
".",
"build",
"(",
")",
";",
"// Dump the intermediate model to a file",
... | load ServiceModel. load code gen configuration from individual client. load Waiters. generate intermediate model. generate
code. | [
"load",
"ServiceModel",
".",
"load",
"code",
"gen",
"configuration",
"from",
"individual",
"client",
".",
"load",
"Waiters",
".",
"generate",
"intermediate",
"model",
".",
"generate",
"code",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/CodeGenerator.java#L59-L75 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/slot/TimerService.java | TimerService.isValid | public boolean isValid(K key, UUID ticket) {
if (timeouts.containsKey(key)) {
Timeout<K> timeout = timeouts.get(key);
return timeout.getTicket().equals(ticket);
} else {
return false;
}
} | java | public boolean isValid(K key, UUID ticket) {
if (timeouts.containsKey(key)) {
Timeout<K> timeout = timeouts.get(key);
return timeout.getTicket().equals(ticket);
} else {
return false;
}
} | [
"public",
"boolean",
"isValid",
"(",
"K",
"key",
",",
"UUID",
"ticket",
")",
"{",
"if",
"(",
"timeouts",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"Timeout",
"<",
"K",
">",
"timeout",
"=",
"timeouts",
".",
"get",
"(",
"key",
")",
";",
"return"... | Check whether the timeout for the given key and ticket is still valid (not yet unregistered
and not yet overwritten).
@param key for which to check the timeout
@param ticket of the timeout
@return True if the timeout ticket is still valid; otherwise false | [
"Check",
"whether",
"the",
"timeout",
"for",
"the",
"given",
"key",
"and",
"ticket",
"is",
"still",
"valid",
"(",
"not",
"yet",
"unregistered",
"and",
"not",
"yet",
"overwritten",
")",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/slot/TimerService.java#L143-L151 |
kiegroup/drools | drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java | DRL5Parser.nestedConstraint | private void nestedConstraint( PatternDescrBuilder< ? > pattern, String prefix ) throws RecognitionException {
int prefixLenght = getNestedConstraintPrefixLenght();
int prefixStart = input.index();
prefix += input.toString( prefixStart, prefixStart + prefixLenght - 2 );
for (int i = 0; i < prefixLenght; i++) {
input.consume();
}
constraints( pattern, prefix );
match( input,
DRL5Lexer.RIGHT_PAREN,
null,
null,
DroolsEditorType.SYMBOL );
} | java | private void nestedConstraint( PatternDescrBuilder< ? > pattern, String prefix ) throws RecognitionException {
int prefixLenght = getNestedConstraintPrefixLenght();
int prefixStart = input.index();
prefix += input.toString( prefixStart, prefixStart + prefixLenght - 2 );
for (int i = 0; i < prefixLenght; i++) {
input.consume();
}
constraints( pattern, prefix );
match( input,
DRL5Lexer.RIGHT_PAREN,
null,
null,
DroolsEditorType.SYMBOL );
} | [
"private",
"void",
"nestedConstraint",
"(",
"PatternDescrBuilder",
"<",
"?",
">",
"pattern",
",",
"String",
"prefix",
")",
"throws",
"RecognitionException",
"{",
"int",
"prefixLenght",
"=",
"getNestedConstraintPrefixLenght",
"(",
")",
";",
"int",
"prefixStart",
"=",... | nestedConstraint := ( ID ( DOT | HASH ) )* ID DOT LEFT_PAREN constraints RIGHT_PAREN
@param pattern
@throws RecognitionException | [
"nestedConstraint",
":",
"=",
"(",
"ID",
"(",
"DOT",
"|",
"HASH",
")",
")",
"*",
"ID",
"DOT",
"LEFT_PAREN",
"constraints",
"RIGHT_PAREN"
] | train | https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java#L3294-L3309 |
bbottema/simple-java-mail | modules/simple-java-mail/src/main/java/org/simplejavamail/converter/EmailConverter.java | EmailConverter.emlToMimeMessage | public static MimeMessage emlToMimeMessage(@Nonnull final String eml, @Nonnull final Session session) {
checkNonEmptyArgument(session, "session");
checkNonEmptyArgument(eml, "eml");
try {
return new MimeMessage(session, new ByteArrayInputStream(eml.getBytes(UTF_8)));
} catch (final MessagingException e) {
throw new EmailConverterException(format(EmailConverterException.PARSE_ERROR_EML, e.getMessage()), e);
}
} | java | public static MimeMessage emlToMimeMessage(@Nonnull final String eml, @Nonnull final Session session) {
checkNonEmptyArgument(session, "session");
checkNonEmptyArgument(eml, "eml");
try {
return new MimeMessage(session, new ByteArrayInputStream(eml.getBytes(UTF_8)));
} catch (final MessagingException e) {
throw new EmailConverterException(format(EmailConverterException.PARSE_ERROR_EML, e.getMessage()), e);
}
} | [
"public",
"static",
"MimeMessage",
"emlToMimeMessage",
"(",
"@",
"Nonnull",
"final",
"String",
"eml",
",",
"@",
"Nonnull",
"final",
"Session",
"session",
")",
"{",
"checkNonEmptyArgument",
"(",
"session",
",",
"\"session\"",
")",
";",
"checkNonEmptyArgument",
"(",... | Relies on JavaMail's native parser of EML data, {@link MimeMessage#MimeMessage(Session, InputStream)}. | [
"Relies",
"on",
"JavaMail",
"s",
"native",
"parser",
"of",
"EML",
"data",
"{"
] | train | https://github.com/bbottema/simple-java-mail/blob/b03635328aeecd525e35eddfef8f5b9a184559d8/modules/simple-java-mail/src/main/java/org/simplejavamail/converter/EmailConverter.java#L241-L249 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/VirtualNetworkGatewaysInner.java | VirtualNetworkGatewaysInner.beginResetVpnClientSharedKeyAsync | public Observable<Void> beginResetVpnClientSharedKeyAsync(String resourceGroupName, String virtualNetworkGatewayName) {
return beginResetVpnClientSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginResetVpnClientSharedKeyAsync(String resourceGroupName, String virtualNetworkGatewayName) {
return beginResetVpnClientSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginResetVpnClientSharedKeyAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayName",
")",
"{",
"return",
"beginResetVpnClientSharedKeyWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetw... | Resets the VPN client shared key of the virtual network gateway in the specified resource group.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Resets",
"the",
"VPN",
"client",
"shared",
"key",
"of",
"the",
"virtual",
"network",
"gateway",
"in",
"the",
"specified",
"resource",
"group",
"."
] | 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/VirtualNetworkGatewaysInner.java#L1562-L1569 |
wso2/transport-http | components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/sender/http2/Http2ClientChannel.java | Http2ClientChannel.putInFlightMessage | public void putInFlightMessage(int streamId, OutboundMsgHolder inFlightMessage) {
if (LOG.isDebugEnabled()) {
LOG.debug("In flight message added to channel: {} with stream id: {} ", this, streamId);
}
inFlightMessages.put(streamId, inFlightMessage);
} | java | public void putInFlightMessage(int streamId, OutboundMsgHolder inFlightMessage) {
if (LOG.isDebugEnabled()) {
LOG.debug("In flight message added to channel: {} with stream id: {} ", this, streamId);
}
inFlightMessages.put(streamId, inFlightMessage);
} | [
"public",
"void",
"putInFlightMessage",
"(",
"int",
"streamId",
",",
"OutboundMsgHolder",
"inFlightMessage",
")",
"{",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"In flight message added to channel: {} with stream id: {} ... | Adds a in-flight message.
@param streamId stream id
@param inFlightMessage {@link OutboundMsgHolder} which holds the in-flight message | [
"Adds",
"a",
"in",
"-",
"flight",
"message",
"."
] | train | https://github.com/wso2/transport-http/blob/c51aa715b473db6c1b82a7d7b22f6e65f74df4c9/components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/sender/http2/Http2ClientChannel.java#L127-L132 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/data/conversion/provider/SimpleConversionService.java | SimpleConversionService.useDefault | protected boolean useDefault(Object value, Class<?> toType) {
return value == null && isDefaultValuesEnabled() && this.defaultValues.containsKey(toType);
} | java | protected boolean useDefault(Object value, Class<?> toType) {
return value == null && isDefaultValuesEnabled() && this.defaultValues.containsKey(toType);
} | [
"protected",
"boolean",
"useDefault",
"(",
"Object",
"value",
",",
"Class",
"<",
"?",
">",
"toType",
")",
"{",
"return",
"value",
"==",
"null",
"&&",
"isDefaultValuesEnabled",
"(",
")",
"&&",
"this",
".",
"defaultValues",
".",
"containsKey",
"(",
"toType",
... | Determines whether the {@link Object default value} for the specified {@link Class type}
should be used as the converted {@link Object value} when the converted {@link Object value}
is {@literal null}.
@param value {@link Object value} to convert.
@param toType {@link Class type} to convert the {@link Object value} into.
@return a boolean value indicating whether the {@link Object default value} for the specified {@link Class type}
should be used as the converted {@link Object value} when the converted {@link Object value}
is {@literal null}.
@see #isDefaultValuesEnabled() | [
"Determines",
"whether",
"the",
"{",
"@link",
"Object",
"default",
"value",
"}",
"for",
"the",
"specified",
"{",
"@link",
"Class",
"type",
"}",
"should",
"be",
"used",
"as",
"the",
"converted",
"{",
"@link",
"Object",
"value",
"}",
"when",
"the",
"converte... | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/data/conversion/provider/SimpleConversionService.java#L406-L408 |
apache/flink | flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java | ExecutionConfig.registerTypeWithKryoSerializer | @SuppressWarnings("rawtypes")
public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) {
if (type == null || serializerClass == null) {
throw new NullPointerException("Cannot register null class or serializer.");
}
@SuppressWarnings("unchecked")
Class<? extends Serializer<?>> castedSerializerClass = (Class<? extends Serializer<?>>) serializerClass;
registeredTypesWithKryoSerializerClasses.put(type, castedSerializerClass);
} | java | @SuppressWarnings("rawtypes")
public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) {
if (type == null || serializerClass == null) {
throw new NullPointerException("Cannot register null class or serializer.");
}
@SuppressWarnings("unchecked")
Class<? extends Serializer<?>> castedSerializerClass = (Class<? extends Serializer<?>>) serializerClass;
registeredTypesWithKryoSerializerClasses.put(type, castedSerializerClass);
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"void",
"registerTypeWithKryoSerializer",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Class",
"<",
"?",
"extends",
"Serializer",
">",
"serializerClass",
")",
"{",
"if",
"(",
"type",
"==",
"null",
"|... | Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer
@param type The class of the types serialized with the given serializer.
@param serializerClass The class of the serializer to use. | [
"Registers",
"the",
"given",
"Serializer",
"via",
"its",
"class",
"as",
"a",
"serializer",
"for",
"the",
"given",
"type",
"at",
"the",
"KryoSerializer"
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java#L812-L821 |
google/j2objc | jre_emul/android/platform/libcore/luni/src/main/java/org/apache/harmony/xml/dom/InnerNodeImpl.java | InnerNodeImpl.matchesNameOrWildcard | private static boolean matchesNameOrWildcard(String pattern, String s) {
return "*".equals(pattern) || Objects.equal(pattern, s);
} | java | private static boolean matchesNameOrWildcard(String pattern, String s) {
return "*".equals(pattern) || Objects.equal(pattern, s);
} | [
"private",
"static",
"boolean",
"matchesNameOrWildcard",
"(",
"String",
"pattern",
",",
"String",
"s",
")",
"{",
"return",
"\"*\"",
".",
"equals",
"(",
"pattern",
")",
"||",
"Objects",
".",
"equal",
"(",
"pattern",
",",
"s",
")",
";",
"}"
] | Returns true if {@code pattern} equals either "*" or {@code s}. Pattern
may be {@code null}. | [
"Returns",
"true",
"if",
"{"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/org/apache/harmony/xml/dom/InnerNodeImpl.java#L264-L266 |
jferard/fastods | fastods/src/main/java/com/github/jferard/fastods/TextBuilder.java | TextBuilder.styledSpan | public TextBuilder styledSpan(final String text, final TextStyle ts) {
this.curParagraphBuilder.styledSpan(text, ts);
return this;
} | java | public TextBuilder styledSpan(final String text, final TextStyle ts) {
this.curParagraphBuilder.styledSpan(text, ts);
return this;
} | [
"public",
"TextBuilder",
"styledSpan",
"(",
"final",
"String",
"text",
",",
"final",
"TextStyle",
"ts",
")",
"{",
"this",
".",
"curParagraphBuilder",
".",
"styledSpan",
"(",
"text",
",",
"ts",
")",
";",
"return",
"this",
";",
"}"
] | Adds a TextStyle and text to the footer/header region specified by
region.<br>
The paragraph to be used is paragraph.<br>
The text will be shown in the order it was added with this function.
@param text The string with the text
@param ts The text style to be used
@return this for fluent style | [
"Adds",
"a",
"TextStyle",
"and",
"text",
"to",
"the",
"footer",
"/",
"header",
"region",
"specified",
"by",
"region",
".",
"<br",
">",
"The",
"paragraph",
"to",
"be",
"used",
"is",
"paragraph",
".",
"<br",
">",
"The",
"text",
"will",
"be",
"shown",
"in... | train | https://github.com/jferard/fastods/blob/a034d173083ffa602dc525699b97f753082eaef9/fastods/src/main/java/com/github/jferard/fastods/TextBuilder.java#L214-L217 |
jeremybrooks/jinx | src/main/java/net/jeremybrooks/jinx/api/GalleriesApi.java | GalleriesApi.editPhoto | public Response editPhoto(String galleryId, String photoId, String comment) throws JinxException {
JinxUtils.validateParams(galleryId, photoId, comment);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.galleries.editPhoto");
params.put("gallery_id", galleryId);
params.put("photo_id", photoId);
params.put("comment", comment);
return jinx.flickrPost(params, Response.class);
} | java | public Response editPhoto(String galleryId, String photoId, String comment) throws JinxException {
JinxUtils.validateParams(galleryId, photoId, comment);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.galleries.editPhoto");
params.put("gallery_id", galleryId);
params.put("photo_id", photoId);
params.put("comment", comment);
return jinx.flickrPost(params, Response.class);
} | [
"public",
"Response",
"editPhoto",
"(",
"String",
"galleryId",
",",
"String",
"photoId",
",",
"String",
"comment",
")",
"throws",
"JinxException",
"{",
"JinxUtils",
".",
"validateParams",
"(",
"galleryId",
",",
"photoId",
",",
"comment",
")",
";",
"Map",
"<",
... | Edit the comment for a gallery photo.
<br>
This method requires authentication with 'write' permission.
@param galleryId Required. The ID of the gallery containing the photo. Note: this is the compound ID returned in methods like flickr.galleries.getList, and flickr.galleries.getListForPhoto.
@param photoId Required. The photo ID in the gallery whose comment to edit.
@param comment Required. The updated comment for the photo.
@return object with response from Flickr indicating ok or fail.
@throws JinxException if required parameters are null or empty, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.galleries.editPhoto.html">flickr.galleries.editPhoto</a> | [
"Edit",
"the",
"comment",
"for",
"a",
"gallery",
"photo",
".",
"<br",
">",
"This",
"method",
"requires",
"authentication",
"with",
"write",
"permission",
"."
] | train | https://github.com/jeremybrooks/jinx/blob/ab7a4b7462d08bcbfd9b98bd3f5029771c20f6c6/src/main/java/net/jeremybrooks/jinx/api/GalleriesApi.java#L136-L144 |
pagehelper/Mybatis-PageHelper | src/main/java/com/github/pagehelper/parser/SqlServerParser.java | SqlServerParser.cloneOrderByElement | protected OrderByElement cloneOrderByElement(OrderByElement orig, Expression expression) {
OrderByElement element = new OrderByElement();
element.setAsc(orig.isAsc());
element.setAscDescPresent(orig.isAscDescPresent());
element.setNullOrdering(orig.getNullOrdering());
element.setExpression(expression);
return element;
} | java | protected OrderByElement cloneOrderByElement(OrderByElement orig, Expression expression) {
OrderByElement element = new OrderByElement();
element.setAsc(orig.isAsc());
element.setAscDescPresent(orig.isAscDescPresent());
element.setNullOrdering(orig.getNullOrdering());
element.setExpression(expression);
return element;
} | [
"protected",
"OrderByElement",
"cloneOrderByElement",
"(",
"OrderByElement",
"orig",
",",
"Expression",
"expression",
")",
"{",
"OrderByElement",
"element",
"=",
"new",
"OrderByElement",
"(",
")",
";",
"element",
".",
"setAsc",
"(",
"orig",
".",
"isAsc",
"(",
")... | 复制 OrderByElement
@param orig 原 OrderByElement
@param expression 新 OrderByElement 的排序要素
@return 复制的新 OrderByElement | [
"复制",
"OrderByElement"
] | train | https://github.com/pagehelper/Mybatis-PageHelper/blob/319750fd47cf75328ff321f38125fa15e954e60f/src/main/java/com/github/pagehelper/parser/SqlServerParser.java#L414-L421 |
mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/IndexCache.java | IndexCache.getIndexEntry | long getIndexEntry(SubFileParameter subFileParameter, long blockNumber) throws IOException {
// check if the block number is out of bounds
if (blockNumber >= subFileParameter.numberOfBlocks) {
throw new IOException("invalid block number: " + blockNumber);
}
// calculate the index block number
long indexBlockNumber = blockNumber / INDEX_ENTRIES_PER_BLOCK;
// create the cache entry key for this request
IndexCacheEntryKey indexCacheEntryKey = new IndexCacheEntryKey(subFileParameter, indexBlockNumber);
// check for cached index block
byte[] indexBlock = this.map.get(indexCacheEntryKey);
if (indexBlock == null) {
// cache miss, seek to the correct index block in the file and read it
long indexBlockPosition = subFileParameter.indexStartAddress + indexBlockNumber * SIZE_OF_INDEX_BLOCK;
int remainingIndexSize = (int) (subFileParameter.indexEndAddress - indexBlockPosition);
int indexBlockSize = Math.min(SIZE_OF_INDEX_BLOCK, remainingIndexSize);
indexBlock = new byte[indexBlockSize];
ByteBuffer indexBlockWrapper = ByteBuffer.wrap(indexBlock, 0, indexBlockSize);
synchronized (this.fileChannel) {
this.fileChannel.position(indexBlockPosition);
if (this.fileChannel.read(indexBlockWrapper) != indexBlockSize) {
throw new IOException("could not read index block with size: " + indexBlockSize);
}
}
// put the index block in the map
this.map.put(indexCacheEntryKey, indexBlock);
}
// calculate the address of the index entry inside the index block
long indexEntryInBlock = blockNumber % INDEX_ENTRIES_PER_BLOCK;
int addressInIndexBlock = (int) (indexEntryInBlock * SubFileParameter.BYTES_PER_INDEX_ENTRY);
// return the real index entry
return Deserializer.getFiveBytesLong(indexBlock, addressInIndexBlock);
} | java | long getIndexEntry(SubFileParameter subFileParameter, long blockNumber) throws IOException {
// check if the block number is out of bounds
if (blockNumber >= subFileParameter.numberOfBlocks) {
throw new IOException("invalid block number: " + blockNumber);
}
// calculate the index block number
long indexBlockNumber = blockNumber / INDEX_ENTRIES_PER_BLOCK;
// create the cache entry key for this request
IndexCacheEntryKey indexCacheEntryKey = new IndexCacheEntryKey(subFileParameter, indexBlockNumber);
// check for cached index block
byte[] indexBlock = this.map.get(indexCacheEntryKey);
if (indexBlock == null) {
// cache miss, seek to the correct index block in the file and read it
long indexBlockPosition = subFileParameter.indexStartAddress + indexBlockNumber * SIZE_OF_INDEX_BLOCK;
int remainingIndexSize = (int) (subFileParameter.indexEndAddress - indexBlockPosition);
int indexBlockSize = Math.min(SIZE_OF_INDEX_BLOCK, remainingIndexSize);
indexBlock = new byte[indexBlockSize];
ByteBuffer indexBlockWrapper = ByteBuffer.wrap(indexBlock, 0, indexBlockSize);
synchronized (this.fileChannel) {
this.fileChannel.position(indexBlockPosition);
if (this.fileChannel.read(indexBlockWrapper) != indexBlockSize) {
throw new IOException("could not read index block with size: " + indexBlockSize);
}
}
// put the index block in the map
this.map.put(indexCacheEntryKey, indexBlock);
}
// calculate the address of the index entry inside the index block
long indexEntryInBlock = blockNumber % INDEX_ENTRIES_PER_BLOCK;
int addressInIndexBlock = (int) (indexEntryInBlock * SubFileParameter.BYTES_PER_INDEX_ENTRY);
// return the real index entry
return Deserializer.getFiveBytesLong(indexBlock, addressInIndexBlock);
} | [
"long",
"getIndexEntry",
"(",
"SubFileParameter",
"subFileParameter",
",",
"long",
"blockNumber",
")",
"throws",
"IOException",
"{",
"// check if the block number is out of bounds",
"if",
"(",
"blockNumber",
">=",
"subFileParameter",
".",
"numberOfBlocks",
")",
"{",
"thro... | Returns the index entry of a block in the given map file. If the required index entry is not cached, it will be
read from the map file index and put in the cache.
@param subFileParameter the parameters of the map file for which the index entry is needed.
@param blockNumber the number of the block in the map file.
@return the index entry.
@throws IOException if an I/O error occurs during reading. | [
"Returns",
"the",
"index",
"entry",
"of",
"a",
"block",
"in",
"the",
"given",
"map",
"file",
".",
"If",
"the",
"required",
"index",
"entry",
"is",
"not",
"cached",
"it",
"will",
"be",
"read",
"from",
"the",
"map",
"file",
"index",
"and",
"put",
"in",
... | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/IndexCache.java#L71-L111 |
threerings/narya | core/src/main/java/com/threerings/presents/peer/util/PeerUtil.java | PeerUtil.createProviderProxy | public static <S extends InvocationProvider, T extends InvocationService<?>>
S createProviderProxy (Class<S> clazz, final T svc, final Client client)
{
return clazz.cast(Proxy.newProxyInstance(
clazz.getClassLoader(), new Class<?>[] { clazz },
new InvocationHandler() {
public Object invoke (Object proxy, Method method, Object[] args)
throws Throwable {
Method smethod = _pmethods.get(method);
if (smethod == null) {
Class<?>[] ptypes = method.getParameterTypes();
_pmethods.put(method, smethod = svc.getClass().getMethod(
method.getName(), ArrayUtil.splice(ptypes, 0, 1)));
}
return smethod.invoke(svc, ArrayUtil.splice(args, 0, 1));
}
}));
} | java | public static <S extends InvocationProvider, T extends InvocationService<?>>
S createProviderProxy (Class<S> clazz, final T svc, final Client client)
{
return clazz.cast(Proxy.newProxyInstance(
clazz.getClassLoader(), new Class<?>[] { clazz },
new InvocationHandler() {
public Object invoke (Object proxy, Method method, Object[] args)
throws Throwable {
Method smethod = _pmethods.get(method);
if (smethod == null) {
Class<?>[] ptypes = method.getParameterTypes();
_pmethods.put(method, smethod = svc.getClass().getMethod(
method.getName(), ArrayUtil.splice(ptypes, 0, 1)));
}
return smethod.invoke(svc, ArrayUtil.splice(args, 0, 1));
}
}));
} | [
"public",
"static",
"<",
"S",
"extends",
"InvocationProvider",
",",
"T",
"extends",
"InvocationService",
"<",
"?",
">",
">",
"S",
"createProviderProxy",
"(",
"Class",
"<",
"S",
">",
"clazz",
",",
"final",
"T",
"svc",
",",
"final",
"Client",
"client",
")",
... | Creates a proxy object implementing the specified provider interface (a subinterface of
{@link InvocationProvider} that forwards requests to the given service implementation
(a subinterface of {@link InvocationService} corresponding to the provider interface)
on the specified client. This is useful for server entities that need to call a method
either on the current server (with <code>null</code> as the caller parameter) or on a
peer server.
@param clazz the subclass of {@link InvocationProvider} desired to be implemented
@param svc the implementation of the corresponding subclass of {@link InvocationService}
@param client the client to pass to the service methods | [
"Creates",
"a",
"proxy",
"object",
"implementing",
"the",
"specified",
"provider",
"interface",
"(",
"a",
"subinterface",
"of",
"{",
"@link",
"InvocationProvider",
"}",
"that",
"forwards",
"requests",
"to",
"the",
"given",
"service",
"implementation",
"(",
"a",
... | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/peer/util/PeerUtil.java#L54-L71 |
jbundle/jbundle | thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java | ScreenUtil.setProperty | public static void setProperty(String key, String value, PropertyOwner propertyOwner, Map<String,Object> properties)
{
if (propertyOwner != null)
{
propertyOwner.setProperty(key, value);
}
if (properties != null)
{
if (value != null)
properties.put(key, value);
else
properties.remove(key);
}
} | java | public static void setProperty(String key, String value, PropertyOwner propertyOwner, Map<String,Object> properties)
{
if (propertyOwner != null)
{
propertyOwner.setProperty(key, value);
}
if (properties != null)
{
if (value != null)
properties.put(key, value);
else
properties.remove(key);
}
} | [
"public",
"static",
"void",
"setProperty",
"(",
"String",
"key",
",",
"String",
"value",
",",
"PropertyOwner",
"propertyOwner",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"if",
"(",
"propertyOwner",
"!=",
"null",
")",
"{",
"prop... | A utility to set the property from the propertyowner or the property. | [
"A",
"utility",
"to",
"set",
"the",
"property",
"from",
"the",
"propertyowner",
"or",
"the",
"property",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/landf/ScreenUtil.java#L224-L237 |
alkacon/opencms-core | src-gwt/org/opencms/ade/sitemap/client/hoverbar/CmsSitemapHoverbar.java | CmsSitemapHoverbar.installOn | public static void installOn(CmsSitemapController controller, CmsTreeItem treeItem, CmsUUID entryId) {
CmsSitemapHoverbar hoverbar = new CmsSitemapHoverbar(controller, entryId, true, true, null);
installHoverbar(hoverbar, treeItem.getListItemWidget());
} | java | public static void installOn(CmsSitemapController controller, CmsTreeItem treeItem, CmsUUID entryId) {
CmsSitemapHoverbar hoverbar = new CmsSitemapHoverbar(controller, entryId, true, true, null);
installHoverbar(hoverbar, treeItem.getListItemWidget());
} | [
"public",
"static",
"void",
"installOn",
"(",
"CmsSitemapController",
"controller",
",",
"CmsTreeItem",
"treeItem",
",",
"CmsUUID",
"entryId",
")",
"{",
"CmsSitemapHoverbar",
"hoverbar",
"=",
"new",
"CmsSitemapHoverbar",
"(",
"controller",
",",
"entryId",
",",
"true... | Installs a hover bar for the given item widget.<p>
@param controller the controller
@param treeItem the item to hover
@param entryId the entry id | [
"Installs",
"a",
"hover",
"bar",
"for",
"the",
"given",
"item",
"widget",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/sitemap/client/hoverbar/CmsSitemapHoverbar.java#L150-L154 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLAnnotationPropertyDomainAxiomImpl_CustomFieldSerializer.java | OWLAnnotationPropertyDomainAxiomImpl_CustomFieldSerializer.deserializeInstance | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLAnnotationPropertyDomainAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | java | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLAnnotationPropertyDomainAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | [
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLAnnotationPropertyDomainAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
... | Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful | [
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLAnnotationPropertyDomainAxiomImpl_CustomFieldSerializer.java#L98-L101 |
auth0/auth0-java | src/main/java/com/auth0/client/mgmt/filter/FieldsFilter.java | FieldsFilter.withFields | public FieldsFilter withFields(String fields, boolean includeFields) {
parameters.put("fields", fields);
parameters.put("include_fields", includeFields);
return this;
} | java | public FieldsFilter withFields(String fields, boolean includeFields) {
parameters.put("fields", fields);
parameters.put("include_fields", includeFields);
return this;
} | [
"public",
"FieldsFilter",
"withFields",
"(",
"String",
"fields",
",",
"boolean",
"includeFields",
")",
"{",
"parameters",
".",
"put",
"(",
"\"fields\"",
",",
"fields",
")",
";",
"parameters",
".",
"put",
"(",
"\"include_fields\"",
",",
"includeFields",
")",
";... | Only retrieve certain fields from the item.
@param fields a list of comma separated fields to retrieve.
@param includeFields whether to include or exclude in the response the fields that were given.
@return this filter instance | [
"Only",
"retrieve",
"certain",
"fields",
"from",
"the",
"item",
"."
] | train | https://github.com/auth0/auth0-java/blob/b7bc099ee9c6cde5a87c4ecfebc6d811aeb1027c/src/main/java/com/auth0/client/mgmt/filter/FieldsFilter.java#L15-L19 |
Azure/azure-sdk-for-java | mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java | LiveEventsInner.beginStartAsync | public Observable<Void> beginStartAsync(String resourceGroupName, String accountName, String liveEventName) {
return beginStartWithServiceResponseAsync(resourceGroupName, accountName, liveEventName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginStartAsync(String resourceGroupName, String accountName, String liveEventName) {
return beginStartWithServiceResponseAsync(resourceGroupName, accountName, liveEventName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginStartAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"liveEventName",
")",
"{",
"return",
"beginStartWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
... | Start Live Event.
Starts an existing Live Event.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param liveEventName The name of the Live Event.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Start",
"Live",
"Event",
".",
"Starts",
"an",
"existing",
"Live",
"Event",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java#L1226-L1233 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/VersionsImpl.java | VersionsImpl.listWithServiceResponseAsync | public Observable<ServiceResponse<List<VersionInfo>>> listWithServiceResponseAsync(UUID appId, ListVersionsOptionalParameter listOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
final Integer skip = listOptionalParameter != null ? listOptionalParameter.skip() : null;
final Integer take = listOptionalParameter != null ? listOptionalParameter.take() : null;
return listWithServiceResponseAsync(appId, skip, take);
} | java | public Observable<ServiceResponse<List<VersionInfo>>> listWithServiceResponseAsync(UUID appId, ListVersionsOptionalParameter listOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
final Integer skip = listOptionalParameter != null ? listOptionalParameter.skip() : null;
final Integer take = listOptionalParameter != null ? listOptionalParameter.take() : null;
return listWithServiceResponseAsync(appId, skip, take);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"List",
"<",
"VersionInfo",
">",
">",
">",
"listWithServiceResponseAsync",
"(",
"UUID",
"appId",
",",
"ListVersionsOptionalParameter",
"listOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"e... | Gets the application versions info.
@param appId The application ID.
@param listOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<VersionInfo> object | [
"Gets",
"the",
"application",
"versions",
"info",
"."
] | 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/VersionsImpl.java#L332-L343 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/lss/LssClient.java | LssClient.pauseAppStream | public PauseAppStreamResponse pauseAppStream(PauseAppStreamRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string.");
checkStringNotEmpty(request.getStream(), "The parameter stream should NOT be null or empty string.");
InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_APP,
request.getApp(), LIVE_SESSION, request.getStream());
internalRequest.addParameter(PAUSE, null);
return invokeHttpClient(internalRequest, PauseAppStreamResponse.class);
} | java | public PauseAppStreamResponse pauseAppStream(PauseAppStreamRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string.");
checkStringNotEmpty(request.getStream(), "The parameter stream should NOT be null or empty string.");
InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_APP,
request.getApp(), LIVE_SESSION, request.getStream());
internalRequest.addParameter(PAUSE, null);
return invokeHttpClient(internalRequest, PauseAppStreamResponse.class);
} | [
"public",
"PauseAppStreamResponse",
"pauseAppStream",
"(",
"PauseAppStreamRequest",
"request",
")",
"{",
"checkNotNull",
"(",
"request",
",",
"\"The parameter request should NOT be null.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getApp",
"(",
")",
",",
... | Pause your app stream by app name and stream name
@param request The request object containing all parameters for pausing app session.
@return the response | [
"Pause",
"your",
"app",
"stream",
"by",
"app",
"name",
"and",
"stream",
"name"
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/lss/LssClient.java#L920-L928 |
logic-ng/LogicNG | src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java | CCTotalizer.buildAMK | void buildAMK(final EncodingResult result, final Variable[] vars, int rhs) {
final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars);
this.incData = new CCIncrementalData(result, CCConfig.AMK_ENCODER.TOTALIZER, rhs, cardinalityOutvars);
this.toCNF(cardinalityOutvars, rhs, Bound.UPPER);
assert this.cardinalityInvars.size() == 0;
for (int i = rhs; i < cardinalityOutvars.size(); i++)
this.result.addClause(cardinalityOutvars.get(i).negate());
} | java | void buildAMK(final EncodingResult result, final Variable[] vars, int rhs) {
final LNGVector<Variable> cardinalityOutvars = this.initializeConstraint(result, vars);
this.incData = new CCIncrementalData(result, CCConfig.AMK_ENCODER.TOTALIZER, rhs, cardinalityOutvars);
this.toCNF(cardinalityOutvars, rhs, Bound.UPPER);
assert this.cardinalityInvars.size() == 0;
for (int i = rhs; i < cardinalityOutvars.size(); i++)
this.result.addClause(cardinalityOutvars.get(i).negate());
} | [
"void",
"buildAMK",
"(",
"final",
"EncodingResult",
"result",
",",
"final",
"Variable",
"[",
"]",
"vars",
",",
"int",
"rhs",
")",
"{",
"final",
"LNGVector",
"<",
"Variable",
">",
"cardinalityOutvars",
"=",
"this",
".",
"initializeConstraint",
"(",
"result",
... | Builds an at-most-k constraint.
@param result the result
@param vars the variables
@param rhs the right-hand side
@throws IllegalArgumentException if the right hand side of the constraint was negative | [
"Builds",
"an",
"at",
"-",
"most",
"-",
"k",
"constraint",
"."
] | train | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/cardinalityconstraints/CCTotalizer.java#L83-L90 |
facebookarchive/hadoop-20 | src/contrib/fairscheduler/src/java/org/apache/hadoop/mapred/FairScheduler.java | FairScheduler.mergeJobs | private void mergeJobs (LinkedList<JobInProgress> jobsToReinsert, TaskType taskType) {
LinkedList<JobInProgress> sortedJobs = (taskType == TaskType.MAP) ?
sortedJobsByMapNeed : sortedJobsByReduceNeed;
Comparator<JobInProgress> comparator = (taskType == TaskType.MAP) ?
mapComparator : reduceComparator;
// for each job to be reinserted
for(JobInProgress jobToReinsert: jobsToReinsert) {
// look at existing jobs in the sorted list starting with the head
boolean reinserted = false;
ListIterator<JobInProgress> iter = sortedJobs.listIterator(0);
while (iter.hasNext()) {
JobInProgress job = iter.next();
if (comparator.compare(jobToReinsert, job) < 0) {
// found the point of insertion, move the iterator back one step
iter.previous();
// now we are positioned before the job we compared against
// insert it before this job
iter.add(jobToReinsert);
reinserted = true;
break;
}
}
if (!reinserted) {
sortedJobs.add(jobToReinsert);
}
}
} | java | private void mergeJobs (LinkedList<JobInProgress> jobsToReinsert, TaskType taskType) {
LinkedList<JobInProgress> sortedJobs = (taskType == TaskType.MAP) ?
sortedJobsByMapNeed : sortedJobsByReduceNeed;
Comparator<JobInProgress> comparator = (taskType == TaskType.MAP) ?
mapComparator : reduceComparator;
// for each job to be reinserted
for(JobInProgress jobToReinsert: jobsToReinsert) {
// look at existing jobs in the sorted list starting with the head
boolean reinserted = false;
ListIterator<JobInProgress> iter = sortedJobs.listIterator(0);
while (iter.hasNext()) {
JobInProgress job = iter.next();
if (comparator.compare(jobToReinsert, job) < 0) {
// found the point of insertion, move the iterator back one step
iter.previous();
// now we are positioned before the job we compared against
// insert it before this job
iter.add(jobToReinsert);
reinserted = true;
break;
}
}
if (!reinserted) {
sortedJobs.add(jobToReinsert);
}
}
} | [
"private",
"void",
"mergeJobs",
"(",
"LinkedList",
"<",
"JobInProgress",
">",
"jobsToReinsert",
",",
"TaskType",
"taskType",
")",
"{",
"LinkedList",
"<",
"JobInProgress",
">",
"sortedJobs",
"=",
"(",
"taskType",
"==",
"TaskType",
".",
"MAP",
")",
"?",
"sortedJ... | reinsert a set of jobs into the sorted jobs for a given type (MAP/REDUCE)
the re-insertion happens in place.
we are exploiting the property that the jobs being inserted will most likely end
up at the head of the sorted list and not require a lot comparisons | [
"reinsert",
"a",
"set",
"of",
"jobs",
"into",
"the",
"sorted",
"jobs",
"for",
"a",
"given",
"type",
"(",
"MAP",
"/",
"REDUCE",
")",
"the",
"re",
"-",
"insertion",
"happens",
"in",
"place",
".",
"we",
"are",
"exploiting",
"the",
"property",
"that",
"the... | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/fairscheduler/src/java/org/apache/hadoop/mapred/FairScheduler.java#L829-L857 |
haifengl/smile | math/src/main/java/smile/sort/SortUtils.java | SortUtils.siftUp | public static <T extends Comparable<? super T>> void siftUp(T[] arr, int k) {
while (k > 1 && arr[k/2].compareTo(arr[k]) < 0) {
swap(arr, k, k/2);
k = k/2;
}
} | java | public static <T extends Comparable<? super T>> void siftUp(T[] arr, int k) {
while (k > 1 && arr[k/2].compareTo(arr[k]) < 0) {
swap(arr, k, k/2);
k = k/2;
}
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"void",
"siftUp",
"(",
"T",
"[",
"]",
"arr",
",",
"int",
"k",
")",
"{",
"while",
"(",
"k",
">",
"1",
"&&",
"arr",
"[",
"k",
"/",
"2",
"]",
".",
"compareT... | To restore the max-heap condition when a node's priority is increased.
We move up the heap, exchaning the node at position k with its parent
(at postion k/2) if necessary, continuing as long as a[k/2] < a[k] or
until we reach the top of the heap. | [
"To",
"restore",
"the",
"max",
"-",
"heap",
"condition",
"when",
"a",
"node",
"s",
"priority",
"is",
"increased",
".",
"We",
"move",
"up",
"the",
"heap",
"exchaning",
"the",
"node",
"at",
"position",
"k",
"with",
"its",
"parent",
"(",
"at",
"postion",
... | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/sort/SortUtils.java#L114-L119 |
wcm-io/wcm-io-handler | url/src/main/java/io/wcm/handler/url/suffix/SuffixParser.java | SuffixParser.getResource | public @Nullable Resource getResource(@Nullable Predicate<Resource> filter, @Nullable Resource baseResource) {
List<Resource> suffixResources = getResources(filter, baseResource);
if (suffixResources.isEmpty()) {
return null;
}
else {
return suffixResources.get(0);
}
} | java | public @Nullable Resource getResource(@Nullable Predicate<Resource> filter, @Nullable Resource baseResource) {
List<Resource> suffixResources = getResources(filter, baseResource);
if (suffixResources.isEmpty()) {
return null;
}
else {
return suffixResources.get(0);
}
} | [
"public",
"@",
"Nullable",
"Resource",
"getResource",
"(",
"@",
"Nullable",
"Predicate",
"<",
"Resource",
">",
"filter",
",",
"@",
"Nullable",
"Resource",
"baseResource",
")",
"{",
"List",
"<",
"Resource",
">",
"suffixResources",
"=",
"getResources",
"(",
"fil... | Get the first item returned by {@link #getResources(Predicate, Resource)} or null if list is empty
@param filter the resource filter
@param baseResource the suffix path is relative to this resource path (null for current page's jcr:content node)
@return the first {@link Resource} or null | [
"Get",
"the",
"first",
"item",
"returned",
"by",
"{"
] | train | https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/url/src/main/java/io/wcm/handler/url/suffix/SuffixParser.java#L218-L226 |
hal/elemento | samples/dagger/src/main/java/org/jboss/gwt/elemento/sample/dagger/client/TodoItemElement.java | TodoItemElement.create | static TodoItemElement create(Provider<ApplicationElement> application, TodoItemRepository repository) {
return new Templated_TodoItemElement(application, repository);
} | java | static TodoItemElement create(Provider<ApplicationElement> application, TodoItemRepository repository) {
return new Templated_TodoItemElement(application, repository);
} | [
"static",
"TodoItemElement",
"create",
"(",
"Provider",
"<",
"ApplicationElement",
">",
"application",
",",
"TodoItemRepository",
"repository",
")",
"{",
"return",
"new",
"Templated_TodoItemElement",
"(",
"application",
",",
"repository",
")",
";",
"}"
] | Don't use ApplicationElement directly as this will lead to a dependency cycle in the generated GIN code! | [
"Don",
"t",
"use",
"ApplicationElement",
"directly",
"as",
"this",
"will",
"lead",
"to",
"a",
"dependency",
"cycle",
"in",
"the",
"generated",
"GIN",
"code!"
] | train | https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/samples/dagger/src/main/java/org/jboss/gwt/elemento/sample/dagger/client/TodoItemElement.java#L39-L41 |
killbill/killbill | invoice/src/main/java/org/killbill/billing/invoice/dao/DefaultInvoiceDao.java | DefaultInvoiceDao.getInvoicesTags | private List<Tag> getInvoicesTags(final InternalTenantContext context) {
return tagInternalApi.getTagsForAccountType(ObjectType.INVOICE, false, context);
} | java | private List<Tag> getInvoicesTags(final InternalTenantContext context) {
return tagInternalApi.getTagsForAccountType(ObjectType.INVOICE, false, context);
} | [
"private",
"List",
"<",
"Tag",
">",
"getInvoicesTags",
"(",
"final",
"InternalTenantContext",
"context",
")",
"{",
"return",
"tagInternalApi",
".",
"getTagsForAccountType",
"(",
"ObjectType",
".",
"INVOICE",
",",
"false",
",",
"context",
")",
";",
"}"
] | PERF: fetch tags once. See also https://github.com/killbill/killbill/issues/720. | [
"PERF",
":",
"fetch",
"tags",
"once",
".",
"See",
"also",
"https",
":",
"//",
"github",
".",
"com",
"/",
"killbill",
"/",
"killbill",
"/",
"issues",
"/",
"720",
"."
] | train | https://github.com/killbill/killbill/blob/6457b485fb32a182c76197a83f428123331f1380/invoice/src/main/java/org/killbill/billing/invoice/dao/DefaultInvoiceDao.java#L1385-L1387 |
osglworks/java-mvc | src/main/java/org/osgl/mvc/result/NotModified.java | NotModified.of | public static NotModified of(String etag, Object... args) {
touchPayload().message(etag, args);
return _INSTANCE;
} | java | public static NotModified of(String etag, Object... args) {
touchPayload().message(etag, args);
return _INSTANCE;
} | [
"public",
"static",
"NotModified",
"of",
"(",
"String",
"etag",
",",
"Object",
"...",
"args",
")",
"{",
"touchPayload",
"(",
")",
".",
"message",
"(",
"etag",
",",
"args",
")",
";",
"return",
"_INSTANCE",
";",
"}"
] | Returns a static NotModified instance which when calling on
{@link #etag()} method, will return whatever stored in the
{@link #payload} thread local.
<p>
Before return the static instance, the specified etag will
be stored into the {@link #payload} thread local
@param etag the etag
@param args the args used to populate the etag
@return a static instance | [
"Returns",
"a",
"static",
"NotModified",
"instance",
"which",
"when",
"calling",
"on",
"{",
"@link",
"#etag",
"()",
"}",
"method",
"will",
"return",
"whatever",
"stored",
"in",
"the",
"{",
"@link",
"#payload",
"}",
"thread",
"local",
".",
"<p",
">",
"Befor... | train | https://github.com/osglworks/java-mvc/blob/4d2b2ec40498ac6ee7040c0424377cbeacab124b/src/main/java/org/osgl/mvc/result/NotModified.java#L111-L114 |
kevinherron/opc-ua-stack | stack-core/src/main/java/com/digitalpetri/opcua/stack/core/Stack.java | Stack.releaseSharedResources | public static synchronized void releaseSharedResources(long timeout, TimeUnit unit) {
if (EVENT_LOOP != null) {
try {
EVENT_LOOP.shutdownGracefully().await(timeout, unit);
} catch (InterruptedException e) {
LoggerFactory.getLogger(Stack.class)
.warn("Interrupted awaiting event loop shutdown.", e);
}
EVENT_LOOP = null;
}
if (SCHEDULED_EXECUTOR_SERVICE != null) {
SCHEDULED_EXECUTOR_SERVICE.shutdown();
SCHEDULED_EXECUTOR_SERVICE = null;
}
if (EXECUTOR_SERVICE != null) {
EXECUTOR_SERVICE.shutdown();
EXECUTOR_SERVICE = null;
}
if (WHEEL_TIMER != null) {
WHEEL_TIMER.stop().forEach(Timeout::cancel);
WHEEL_TIMER = null;
}
} | java | public static synchronized void releaseSharedResources(long timeout, TimeUnit unit) {
if (EVENT_LOOP != null) {
try {
EVENT_LOOP.shutdownGracefully().await(timeout, unit);
} catch (InterruptedException e) {
LoggerFactory.getLogger(Stack.class)
.warn("Interrupted awaiting event loop shutdown.", e);
}
EVENT_LOOP = null;
}
if (SCHEDULED_EXECUTOR_SERVICE != null) {
SCHEDULED_EXECUTOR_SERVICE.shutdown();
SCHEDULED_EXECUTOR_SERVICE = null;
}
if (EXECUTOR_SERVICE != null) {
EXECUTOR_SERVICE.shutdown();
EXECUTOR_SERVICE = null;
}
if (WHEEL_TIMER != null) {
WHEEL_TIMER.stop().forEach(Timeout::cancel);
WHEEL_TIMER = null;
}
} | [
"public",
"static",
"synchronized",
"void",
"releaseSharedResources",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"if",
"(",
"EVENT_LOOP",
"!=",
"null",
")",
"{",
"try",
"{",
"EVENT_LOOP",
".",
"shutdownGracefully",
"(",
")",
".",
"await",
"("... | Release shared resources, waiting at most the specified timeout for the {@link NioEventLoopGroup} to shutdown
gracefully.
@param timeout the duration of the timeout.
@param unit the unit of the timeout duration. | [
"Release",
"shared",
"resources",
"waiting",
"at",
"most",
"the",
"specified",
"timeout",
"for",
"the",
"{",
"@link",
"NioEventLoopGroup",
"}",
"to",
"shutdown",
"gracefully",
"."
] | train | https://github.com/kevinherron/opc-ua-stack/blob/007f4e5c4ff102814bec17bb7c41f27e2e52f2fd/stack-core/src/main/java/com/digitalpetri/opcua/stack/core/Stack.java#L163-L188 |
alibaba/simpleimage | simpleimage.core/src/main/java/com/alibaba/simpleimage/util/ImageColorConvertHelper.java | ImageColorConvertHelper.convertCMYK2RGB | public static PlanarImage convertCMYK2RGB(PlanarImage src) {
ColorSpace srcColorSpace = src.getColorModel().getColorSpace();
// check if BufferedImage is cmyk format
if (srcColorSpace.getType() != ColorSpace.TYPE_CMYK) {
return src;
}
/**
* ICC_ColorSpace object mean jai read ColorSpace from image embed profile, we can not inverted cmyk color, and
* can not repace BufferedImage's ColorSpace
*/
if (srcColorSpace instanceof ICC_ColorSpace) {
// -- Convert CMYK to RGB
ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
false, true, Transparency.OPAQUE);
ImageLayout rgbImageLayout = new ImageLayout();
rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(src.getWidth(), src.getHeight()));
RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
ParameterBlockJAI pb = new ParameterBlockJAI("colorconvert");
pb.addSource(src);
pb.setParameter("colormodel", rgbColorModel);
return JAI.create("colorconvert", pb, rgbHints);
} else {
// get user defined color from ColorProfile data
ColorSpace cmykColorSpace = CMMColorSpace.getInstance(src.getColorModel().getColorSpace().getType());
ColorModel cmykColorModel = RasterFactory.createComponentColorModel(src.getSampleModel().getDataType(),
cmykColorSpace, false, true,
Transparency.OPAQUE);
// replace ColorSpace by format convertor with CMYK ColorSpace
ImageLayout cmykImageLayout = new ImageLayout();
cmykImageLayout.setColorModel(cmykColorModel);
RenderingHints cmykHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, cmykImageLayout);
cmykHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
ParameterBlockJAI pb = new ParameterBlockJAI("format");
pb.addSource(src);
pb.setParameter("datatype", src.getSampleModel().getDataType());
PlanarImage op = JAI.create("format", pb, cmykHints);
// invert CMYK pixel value
pb = new ParameterBlockJAI("invert");
pb.addSource(src);
op = JAI.create("invert", pb, cmykHints);
// -- Convert CMYK to RGB
ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
false, true, Transparency.OPAQUE);
ImageLayout rgbImageLayout = new ImageLayout();
rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(op.getWidth(), op.getHeight()));
RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
pb = new ParameterBlockJAI("colorconvert");
pb.addSource(op);
pb.setParameter("colormodel", rgbColorModel);
return JAI.create("colorconvert", pb, rgbHints);
}// endif
} | java | public static PlanarImage convertCMYK2RGB(PlanarImage src) {
ColorSpace srcColorSpace = src.getColorModel().getColorSpace();
// check if BufferedImage is cmyk format
if (srcColorSpace.getType() != ColorSpace.TYPE_CMYK) {
return src;
}
/**
* ICC_ColorSpace object mean jai read ColorSpace from image embed profile, we can not inverted cmyk color, and
* can not repace BufferedImage's ColorSpace
*/
if (srcColorSpace instanceof ICC_ColorSpace) {
// -- Convert CMYK to RGB
ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
false, true, Transparency.OPAQUE);
ImageLayout rgbImageLayout = new ImageLayout();
rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(src.getWidth(), src.getHeight()));
RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
ParameterBlockJAI pb = new ParameterBlockJAI("colorconvert");
pb.addSource(src);
pb.setParameter("colormodel", rgbColorModel);
return JAI.create("colorconvert", pb, rgbHints);
} else {
// get user defined color from ColorProfile data
ColorSpace cmykColorSpace = CMMColorSpace.getInstance(src.getColorModel().getColorSpace().getType());
ColorModel cmykColorModel = RasterFactory.createComponentColorModel(src.getSampleModel().getDataType(),
cmykColorSpace, false, true,
Transparency.OPAQUE);
// replace ColorSpace by format convertor with CMYK ColorSpace
ImageLayout cmykImageLayout = new ImageLayout();
cmykImageLayout.setColorModel(cmykColorModel);
RenderingHints cmykHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, cmykImageLayout);
cmykHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
ParameterBlockJAI pb = new ParameterBlockJAI("format");
pb.addSource(src);
pb.setParameter("datatype", src.getSampleModel().getDataType());
PlanarImage op = JAI.create("format", pb, cmykHints);
// invert CMYK pixel value
pb = new ParameterBlockJAI("invert");
pb.addSource(src);
op = JAI.create("invert", pb, cmykHints);
// -- Convert CMYK to RGB
ColorSpace rgbColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorModel rgbColorModel = RasterFactory.createComponentColorModel(DataBuffer.TYPE_BYTE, rgbColorSpace,
false, true, Transparency.OPAQUE);
ImageLayout rgbImageLayout = new ImageLayout();
rgbImageLayout.setSampleModel(rgbColorModel.createCompatibleSampleModel(op.getWidth(), op.getHeight()));
RenderingHints rgbHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rgbImageLayout);
rgbHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
pb = new ParameterBlockJAI("colorconvert");
pb.addSource(op);
pb.setParameter("colormodel", rgbColorModel);
return JAI.create("colorconvert", pb, rgbHints);
}// endif
} | [
"public",
"static",
"PlanarImage",
"convertCMYK2RGB",
"(",
"PlanarImage",
"src",
")",
"{",
"ColorSpace",
"srcColorSpace",
"=",
"src",
".",
"getColorModel",
"(",
")",
".",
"getColorSpace",
"(",
")",
";",
"// check if BufferedImage is cmyk format",
"if",
"(",
"srcColo... | JAI在读cmyk格式的时候分2种:
<pre>
CMYK的图形读取,JAI使用的RGBA的模式的, 因此,为了替换使用自己的Color Profile, 直接使用format的操作。
<li>如果cmyk自带了 ICC_Profile, 那么数据是不会被修改的。 这个情况下, 我们应该使用内置的Color Profile</li>
<li>如果cmyk图形使用默认的ICC_Profile, 那么他使用内置的InvertedCMYKColorSpace, 这是时候颜色会发生反转</li>
</pre>
@param src 任意颜色空间图形
@return ColorSpace.CS_sRGB 表示的BufferedImage | [
"JAI在读cmyk格式的时候分2种:"
] | train | https://github.com/alibaba/simpleimage/blob/aabe559c267402b754c2ad606b796c4c6570788c/simpleimage.core/src/main/java/com/alibaba/simpleimage/util/ImageColorConvertHelper.java#L89-L152 |
legsem/legstar.avro | legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslatorMain.java | Xsd2AvroTranslatorMain.collectOptions | private boolean collectOptions(final Options options, final String[] args)
throws Exception {
if (args != null && args.length > 0) {
CommandLineParser parser = new PosixParser();
CommandLine line = parser.parse(options, args);
return processLine(line, options);
}
return true;
} | java | private boolean collectOptions(final Options options, final String[] args)
throws Exception {
if (args != null && args.length > 0) {
CommandLineParser parser = new PosixParser();
CommandLine line = parser.parse(options, args);
return processLine(line, options);
}
return true;
} | [
"private",
"boolean",
"collectOptions",
"(",
"final",
"Options",
"options",
",",
"final",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"if",
"(",
"args",
"!=",
"null",
"&&",
"args",
".",
"length",
">",
"0",
")",
"{",
"CommandLineParser",
... | Take arguments received on the command line and setup corresponding
options.
<p/>
No arguments is valid. It means use the defaults.
@param options the expected options
@param args the actual arguments received on the command line
@return true if arguments were valid
@throws Exception if something goes wrong while parsing arguments | [
"Take",
"arguments",
"received",
"on",
"the",
"command",
"line",
"and",
"setup",
"corresponding",
"options",
".",
"<p",
"/",
">",
"No",
"arguments",
"is",
"valid",
".",
"It",
"means",
"use",
"the",
"defaults",
"."
] | train | https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslatorMain.java#L153-L161 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java | Constraints.gte | public PropertyConstraint gte(String propertyName, Comparable propertyValue) {
return new ParameterizedPropertyConstraint(propertyName, gte(propertyValue));
} | java | public PropertyConstraint gte(String propertyName, Comparable propertyValue) {
return new ParameterizedPropertyConstraint(propertyName, gte(propertyValue));
} | [
"public",
"PropertyConstraint",
"gte",
"(",
"String",
"propertyName",
",",
"Comparable",
"propertyValue",
")",
"{",
"return",
"new",
"ParameterizedPropertyConstraint",
"(",
"propertyName",
",",
"gte",
"(",
"propertyValue",
")",
")",
";",
"}"
] | Apply a "greater than equal to" constraint to a bean property.
@param propertyName The first property
@param propertyValue The constraint value
@return The constraint | [
"Apply",
"a",
"greater",
"than",
"equal",
"to",
"constraint",
"to",
"a",
"bean",
"property",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java#L702-L704 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.service.location/src/com/ibm/ws/kernel/service/location/internal/FileLocator.java | FileLocator.findFileInNamedPath | public static File findFileInNamedPath(String name, Collection<String> pathNameList) {
if (name == null || pathNameList == null || pathNameList.size() == 0)
return null;
for (String path : pathNameList) {
if (path == null || path.length() == 0)
continue;
File result = getFile(new File(path), name);
if (result != null)
return result;
}
return null;
} | java | public static File findFileInNamedPath(String name, Collection<String> pathNameList) {
if (name == null || pathNameList == null || pathNameList.size() == 0)
return null;
for (String path : pathNameList) {
if (path == null || path.length() == 0)
continue;
File result = getFile(new File(path), name);
if (result != null)
return result;
}
return null;
} | [
"public",
"static",
"File",
"findFileInNamedPath",
"(",
"String",
"name",
",",
"Collection",
"<",
"String",
">",
"pathNameList",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"pathNameList",
"==",
"null",
"||",
"pathNameList",
".",
"size",
"(",
")",
"==... | Look for given file in any of the specified directories, return the first
one found.
@param name
The name of the file to find
@param pathNameList
The list of directories to check
@return The File object if the file is found; null if name is null,
pathNameList is null or empty, or file is not found.
@throws SecurityException
If a security manager exists and its <code>{@link java.lang.SecurityManager#checkRead(java.lang.String)}</code> method denies read access to the file. | [
"Look",
"for",
"given",
"file",
"in",
"any",
"of",
"the",
"specified",
"directories",
"return",
"the",
"first",
"one",
"found",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service.location/src/com/ibm/ws/kernel/service/location/internal/FileLocator.java#L44-L57 |
thinkaurelius/faunus | src/main/java/com/thinkaurelius/faunus/FaunusPipeline.java | FaunusPipeline.hasNot | public FaunusPipeline hasNot(final String key, final Compare compare, final Object... values) {
return this.has(key, compare.opposite(), values);
} | java | public FaunusPipeline hasNot(final String key, final Compare compare, final Object... values) {
return this.has(key, compare.opposite(), values);
} | [
"public",
"FaunusPipeline",
"hasNot",
"(",
"final",
"String",
"key",
",",
"final",
"Compare",
"compare",
",",
"final",
"Object",
"...",
"values",
")",
"{",
"return",
"this",
".",
"has",
"(",
"key",
",",
"compare",
".",
"opposite",
"(",
")",
",",
"values"... | Emit the current element if it does not have a property value comparable to the provided values.
@param key the property key of the element
@param compare the comparator (will be not'd)
@param values the values to compare against where only one needs to succeed (or'd)
@return the extended FaunusPipeline | [
"Emit",
"the",
"current",
"element",
"if",
"it",
"does",
"not",
"have",
"a",
"property",
"value",
"comparable",
"to",
"the",
"provided",
"values",
"."
] | train | https://github.com/thinkaurelius/faunus/blob/1eb8494eeb3fe3b84a98d810d304ba01d55b0d6e/src/main/java/com/thinkaurelius/faunus/FaunusPipeline.java#L671-L673 |
windup/windup | rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ModuleAnalysisHelper.java | ModuleAnalysisHelper.deriveGroupIdFromPackages | String deriveGroupIdFromPackages(ProjectModel projectModel)
{
Map<Object, Long> pkgsMap = new HashMap<>();
Set<String> pkgs = new HashSet<>(1000);
GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(graphContext.getGraph()).V(projectModel);
pkgsMap = pipeline.out(ProjectModel.PROJECT_MODEL_TO_FILE)
.has(WindupVertexFrame.TYPE_PROP, new P(new BiPredicate<String, String>() {
@Override
public boolean test(String o, String o2) {
return o.contains(o2);
}
},
GraphTypeManager.getTypeValue(JavaClassFileModel.class)))
.hasKey(JavaClassFileModel.PROPERTY_PACKAGE_NAME)
.groupCount()
.by(v -> upToThirdDot(graphContext, (Vertex)v)).toList().get(0);
Map.Entry<Object, Long> biggest = null;
for (Map.Entry<Object, Long> entry : pkgsMap.entrySet())
{
if (biggest == null || biggest.getValue() < entry.getValue())
biggest = entry;
}
// More than a half is of this package.
if (biggest != null && biggest.getValue() > pkgsMap.size() / 2)
return biggest.getKey().toString();
return null;
} | java | String deriveGroupIdFromPackages(ProjectModel projectModel)
{
Map<Object, Long> pkgsMap = new HashMap<>();
Set<String> pkgs = new HashSet<>(1000);
GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(graphContext.getGraph()).V(projectModel);
pkgsMap = pipeline.out(ProjectModel.PROJECT_MODEL_TO_FILE)
.has(WindupVertexFrame.TYPE_PROP, new P(new BiPredicate<String, String>() {
@Override
public boolean test(String o, String o2) {
return o.contains(o2);
}
},
GraphTypeManager.getTypeValue(JavaClassFileModel.class)))
.hasKey(JavaClassFileModel.PROPERTY_PACKAGE_NAME)
.groupCount()
.by(v -> upToThirdDot(graphContext, (Vertex)v)).toList().get(0);
Map.Entry<Object, Long> biggest = null;
for (Map.Entry<Object, Long> entry : pkgsMap.entrySet())
{
if (biggest == null || biggest.getValue() < entry.getValue())
biggest = entry;
}
// More than a half is of this package.
if (biggest != null && biggest.getValue() > pkgsMap.size() / 2)
return biggest.getKey().toString();
return null;
} | [
"String",
"deriveGroupIdFromPackages",
"(",
"ProjectModel",
"projectModel",
")",
"{",
"Map",
"<",
"Object",
",",
"Long",
">",
"pkgsMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Set",
"<",
"String",
">",
"pkgs",
"=",
"new",
"HashSet",
"<>",
"(",
"100... | Counts the packages prefixes appearing in this project and if some of them make more than half of the total of existing packages, this prefix
is returned. Otherwise, returns null.
This is just a helper, it isn't something really hard-setting the package. It's something to use if the user didn't specify using
--mavenize.groupId, and the archive or project name is something insane, like few sencences paragraph (a description) or a number or such. | [
"Counts",
"the",
"packages",
"prefixes",
"appearing",
"in",
"this",
"project",
"and",
"if",
"some",
"of",
"them",
"make",
"more",
"than",
"half",
"of",
"the",
"total",
"of",
"existing",
"packages",
"this",
"prefix",
"is",
"returned",
".",
"Otherwise",
"retur... | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ModuleAnalysisHelper.java#L87-L117 |
grails/grails-core | grails-core/src/main/groovy/grails/util/GrailsClassUtils.java | GrailsClassUtils.getBooleanFromMap | public static boolean getBooleanFromMap(String key, Map<?, ?> map) {
boolean defaultValue = false;
return getBooleanFromMap(key, map, defaultValue);
} | java | public static boolean getBooleanFromMap(String key, Map<?, ?> map) {
boolean defaultValue = false;
return getBooleanFromMap(key, map, defaultValue);
} | [
"public",
"static",
"boolean",
"getBooleanFromMap",
"(",
"String",
"key",
",",
"Map",
"<",
"?",
",",
"?",
">",
"map",
")",
"{",
"boolean",
"defaultValue",
"=",
"false",
";",
"return",
"getBooleanFromMap",
"(",
"key",
",",
"map",
",",
"defaultValue",
")",
... | Retrieves a boolean value from a Map for the given key
@param key The key that references the boolean value
@param map The map to look in
@return A boolean value which will be false if the map is null, the map doesn't contain the key or the value is false | [
"Retrieves",
"a",
"boolean",
"value",
"from",
"a",
"Map",
"for",
"the",
"given",
"key"
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L812-L815 |
osmdroid/osmdroid | osmdroid-geopackage/src/main/java/org/osmdroid/gpkg/overlay/features/SphericalUtil.java | SphericalUtil.computeHeading | public static double computeHeading(IGeoPoint from, IGeoPoint to) {
// http://williams.best.vwh.net/avform.htm#Crs
double fromLat = toRadians(from.getLatitude());
double fromLng = toRadians(from.getLongitude());
double toLat = toRadians(to.getLatitude());
double toLng = toRadians(to.getLongitude());
double dLng = toLng - fromLng;
double heading = atan2(
sin(dLng) * cos(toLat),
cos(fromLat) * sin(toLat) - sin(fromLat) * cos(toLat) * cos(dLng));
return wrap(toDegrees(heading), -180, 180);
} | java | public static double computeHeading(IGeoPoint from, IGeoPoint to) {
// http://williams.best.vwh.net/avform.htm#Crs
double fromLat = toRadians(from.getLatitude());
double fromLng = toRadians(from.getLongitude());
double toLat = toRadians(to.getLatitude());
double toLng = toRadians(to.getLongitude());
double dLng = toLng - fromLng;
double heading = atan2(
sin(dLng) * cos(toLat),
cos(fromLat) * sin(toLat) - sin(fromLat) * cos(toLat) * cos(dLng));
return wrap(toDegrees(heading), -180, 180);
} | [
"public",
"static",
"double",
"computeHeading",
"(",
"IGeoPoint",
"from",
",",
"IGeoPoint",
"to",
")",
"{",
"// http://williams.best.vwh.net/avform.htm#Crs",
"double",
"fromLat",
"=",
"toRadians",
"(",
"from",
".",
"getLatitude",
"(",
")",
")",
";",
"double",
"fro... | Returns the heading from one LatLng to another LatLng. Headings are
expressed in degrees clockwise from North within the range [-180,180).
@return The heading in degrees clockwise from north. | [
"Returns",
"the",
"heading",
"from",
"one",
"LatLng",
"to",
"another",
"LatLng",
".",
"Headings",
"are",
"expressed",
"in",
"degrees",
"clockwise",
"from",
"North",
"within",
"the",
"range",
"[",
"-",
"180",
"180",
")",
"."
] | train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-geopackage/src/main/java/org/osmdroid/gpkg/overlay/features/SphericalUtil.java#L136-L147 |
wso2/transport-http | components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/common/states/Http2StateUtil.java | Http2StateUtil.validatePromisedStreamState | public static void validatePromisedStreamState(int originalStreamId, int streamId, Http2Connection conn,
HttpCarbonMessage inboundRequestMsg) throws Http2Exception {
if (streamId == originalStreamId) { // Not a promised stream, no need to validate
return;
}
if (!isValidStreamId(streamId, conn)) {
inboundRequestMsg.getHttpOutboundRespStatusFuture().
notifyHttpListener(new ServerConnectorException(PROMISED_STREAM_REJECTED_ERROR));
throw new Http2Exception(Http2Error.REFUSED_STREAM, PROMISED_STREAM_REJECTED_ERROR);
}
} | java | public static void validatePromisedStreamState(int originalStreamId, int streamId, Http2Connection conn,
HttpCarbonMessage inboundRequestMsg) throws Http2Exception {
if (streamId == originalStreamId) { // Not a promised stream, no need to validate
return;
}
if (!isValidStreamId(streamId, conn)) {
inboundRequestMsg.getHttpOutboundRespStatusFuture().
notifyHttpListener(new ServerConnectorException(PROMISED_STREAM_REJECTED_ERROR));
throw new Http2Exception(Http2Error.REFUSED_STREAM, PROMISED_STREAM_REJECTED_ERROR);
}
} | [
"public",
"static",
"void",
"validatePromisedStreamState",
"(",
"int",
"originalStreamId",
",",
"int",
"streamId",
",",
"Http2Connection",
"conn",
",",
"HttpCarbonMessage",
"inboundRequestMsg",
")",
"throws",
"Http2Exception",
"{",
"if",
"(",
"streamId",
"==",
"origin... | Validates the state of promised stream with the original stream id and given stream id.
@param originalStreamId the original id of the stream
@param streamId the id of the stream to be validated
@param conn HTTP2 connection
@param inboundRequestMsg request message received from the client
@throws Http2Exception throws if stream id is not valid for given connection | [
"Validates",
"the",
"state",
"of",
"promised",
"stream",
"with",
"the",
"original",
"stream",
"id",
"and",
"given",
"stream",
"id",
"."
] | train | https://github.com/wso2/transport-http/blob/c51aa715b473db6c1b82a7d7b22f6e65f74df4c9/components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/common/states/Http2StateUtil.java#L200-L210 |
TinkoffCreditSystems/decoro | library/src/main/java/ru/tinkoff/decoro/MaskImpl.java | MaskImpl.validSlotIndexOffset | private SlotIndexOffset validSlotIndexOffset(Slot slot, final char value) {
final SlotIndexOffset result = new SlotIndexOffset();
while (slot != null && !slot.canInsertHere(value)) {
if (!result.nonHarcodedSlotSkipped && !slot.hardcoded()) {
result.nonHarcodedSlotSkipped = true;
}
slot = slot.getNextSlot();
result.indexOffset++;
}
return result;
} | java | private SlotIndexOffset validSlotIndexOffset(Slot slot, final char value) {
final SlotIndexOffset result = new SlotIndexOffset();
while (slot != null && !slot.canInsertHere(value)) {
if (!result.nonHarcodedSlotSkipped && !slot.hardcoded()) {
result.nonHarcodedSlotSkipped = true;
}
slot = slot.getNextSlot();
result.indexOffset++;
}
return result;
} | [
"private",
"SlotIndexOffset",
"validSlotIndexOffset",
"(",
"Slot",
"slot",
",",
"final",
"char",
"value",
")",
"{",
"final",
"SlotIndexOffset",
"result",
"=",
"new",
"SlotIndexOffset",
"(",
")",
";",
"while",
"(",
"slot",
"!=",
"null",
"&&",
"!",
"slot",
"."... | Looks for a slot to insert {@code value}. Search moves to the right from the specified one
(including it). While searching it checks whether the're any non-hardcoded slots that cannot
accept pending input if such slots are found it is marked in a resulting object.
@param slot slot from where to start
@param value value to be inserted to slot
@return wrapper around index offset to the found slot and flag showing did search skip any
non-hardcoded slots | [
"Looks",
"for",
"a",
"slot",
"to",
"insert",
"{",
"@code",
"value",
"}",
".",
"Search",
"moves",
"to",
"the",
"right",
"from",
"the",
"specified",
"one",
"(",
"including",
"it",
")",
".",
"While",
"searching",
"it",
"checks",
"whether",
"the",
"re",
"a... | train | https://github.com/TinkoffCreditSystems/decoro/blob/f2693d0b3def13aabf59cf642fc0b6f5c8c94f63/library/src/main/java/ru/tinkoff/decoro/MaskImpl.java#L454-L466 |
pravega/pravega | segmentstore/server/src/main/java/io/pravega/segmentstore/server/reading/StreamSegmentReadIndex.java | StreamSegmentReadIndex.readDirect | InputStream readDirect(long startOffset, int length) {
Exceptions.checkNotClosed(this.closed, this);
Preconditions.checkState(!this.recoveryMode, "StreamSegmentReadIndex is in Recovery Mode.");
Preconditions.checkArgument(length >= 0, "length must be a non-negative number");
Preconditions.checkArgument(startOffset >= this.metadata.getStorageLength(), "startOffset must refer to an offset beyond the Segment's StorageLength offset.");
Preconditions.checkArgument(startOffset + length <= this.metadata.getLength(), "startOffset+length must be less than the length of the Segment.");
Preconditions.checkArgument(startOffset >= Math.min(this.metadata.getStartOffset(), this.metadata.getStorageLength()),
"startOffset is before the Segment's StartOffset.");
// Get the first entry. This one is trickier because the requested start offset may not fall on an entry boundary.
CompletableReadResultEntry nextEntry;
synchronized (this.lock) {
ReadIndexEntry indexEntry = this.indexEntries.getFloor(startOffset);
if (indexEntry == null || startOffset > indexEntry.getLastStreamSegmentOffset() || !indexEntry.isDataEntry()) {
// Data not available or data exist in a partially merged transaction.
return null;
} else {
// Fetch data from the cache for the first entry, but do not update the cache hit stats.
nextEntry = createMemoryRead(indexEntry, startOffset, length, false);
}
}
// Collect the contents of congruent Index Entries into a list, as long as we still encounter data in the cache.
// Since we know all entries should be in the cache and are contiguous, there is no need
assert Futures.isSuccessful(nextEntry.getContent()) : "Found CacheReadResultEntry that is not completed yet: " + nextEntry;
val entryContents = nextEntry.getContent().join();
ArrayList<InputStream> contents = new ArrayList<>();
contents.add(entryContents.getData());
int readLength = entryContents.getLength();
while (readLength < length) {
// No need to search the index; from now on, we know each offset we are looking for is at the beginning of a cache entry.
// Also, no need to acquire the lock there. The cache itself is thread safe, and if the entry we are about to fetch
// has just been evicted, we'll just get null back and stop reading (which is acceptable).
byte[] entryData = this.cache.get(new CacheKey(this.metadata.getId(), startOffset + readLength));
if (entryData == null) {
// Could not find the 'next' cache entry: this means the requested range is not fully cached.
return null;
}
int entryReadLength = Math.min(entryData.length, length - readLength);
assert entryReadLength > 0 : "about to have fetched zero bytes from a cache entry";
contents.add(new ByteArrayInputStream(entryData, 0, entryReadLength));
readLength += entryReadLength;
}
// Coalesce the results into a single InputStream and return the result.
return new SequenceInputStream(Iterators.asEnumeration(contents.iterator()));
} | java | InputStream readDirect(long startOffset, int length) {
Exceptions.checkNotClosed(this.closed, this);
Preconditions.checkState(!this.recoveryMode, "StreamSegmentReadIndex is in Recovery Mode.");
Preconditions.checkArgument(length >= 0, "length must be a non-negative number");
Preconditions.checkArgument(startOffset >= this.metadata.getStorageLength(), "startOffset must refer to an offset beyond the Segment's StorageLength offset.");
Preconditions.checkArgument(startOffset + length <= this.metadata.getLength(), "startOffset+length must be less than the length of the Segment.");
Preconditions.checkArgument(startOffset >= Math.min(this.metadata.getStartOffset(), this.metadata.getStorageLength()),
"startOffset is before the Segment's StartOffset.");
// Get the first entry. This one is trickier because the requested start offset may not fall on an entry boundary.
CompletableReadResultEntry nextEntry;
synchronized (this.lock) {
ReadIndexEntry indexEntry = this.indexEntries.getFloor(startOffset);
if (indexEntry == null || startOffset > indexEntry.getLastStreamSegmentOffset() || !indexEntry.isDataEntry()) {
// Data not available or data exist in a partially merged transaction.
return null;
} else {
// Fetch data from the cache for the first entry, but do not update the cache hit stats.
nextEntry = createMemoryRead(indexEntry, startOffset, length, false);
}
}
// Collect the contents of congruent Index Entries into a list, as long as we still encounter data in the cache.
// Since we know all entries should be in the cache and are contiguous, there is no need
assert Futures.isSuccessful(nextEntry.getContent()) : "Found CacheReadResultEntry that is not completed yet: " + nextEntry;
val entryContents = nextEntry.getContent().join();
ArrayList<InputStream> contents = new ArrayList<>();
contents.add(entryContents.getData());
int readLength = entryContents.getLength();
while (readLength < length) {
// No need to search the index; from now on, we know each offset we are looking for is at the beginning of a cache entry.
// Also, no need to acquire the lock there. The cache itself is thread safe, and if the entry we are about to fetch
// has just been evicted, we'll just get null back and stop reading (which is acceptable).
byte[] entryData = this.cache.get(new CacheKey(this.metadata.getId(), startOffset + readLength));
if (entryData == null) {
// Could not find the 'next' cache entry: this means the requested range is not fully cached.
return null;
}
int entryReadLength = Math.min(entryData.length, length - readLength);
assert entryReadLength > 0 : "about to have fetched zero bytes from a cache entry";
contents.add(new ByteArrayInputStream(entryData, 0, entryReadLength));
readLength += entryReadLength;
}
// Coalesce the results into a single InputStream and return the result.
return new SequenceInputStream(Iterators.asEnumeration(contents.iterator()));
} | [
"InputStream",
"readDirect",
"(",
"long",
"startOffset",
",",
"int",
"length",
")",
"{",
"Exceptions",
".",
"checkNotClosed",
"(",
"this",
".",
"closed",
",",
"this",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"this",
".",
"recoveryMode",
",",
... | Reads a contiguous sequence of bytes of the given length starting at the given offset. Every byte in the range
must meet the following conditions:
<ul>
<li> It must exist in this segment. This excludes bytes from merged transactions and future reads.
<li> It must be part of data that is not yet committed to Storage (tail part) - as such, it must be fully in the cache.
</ul>
Note: This method will not cause cache statistics to be updated. As such, Cache entry generations will not be
updated for those entries that are touched.
@param startOffset The offset in the StreamSegment where to start reading.
@param length The number of bytes to read.
@return An InputStream containing the requested data, or null if all of the conditions of this read cannot be met.
@throws IllegalStateException If the read index is in recovery mode.
@throws IllegalArgumentException If the parameters are invalid (offset, length or offset+length are not in the Segment's range). | [
"Reads",
"a",
"contiguous",
"sequence",
"of",
"bytes",
"of",
"the",
"given",
"length",
"starting",
"at",
"the",
"given",
"offset",
".",
"Every",
"byte",
"in",
"the",
"range",
"must",
"meet",
"the",
"following",
"conditions",
":",
"<ul",
">",
"<li",
">",
... | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/reading/StreamSegmentReadIndex.java#L622-L670 |
youngmonkeys/ezyfox-sfs2x | src/main/java/com/tvd12/ezyfox/sfs2x/data/impl/SimpleTransformer.java | SimpleTransformer.initWithStringType | protected void initWithStringType() {
transformers.put(String.class, new Transformer() {
@Override
public SFSDataWrapper transform(Object value) {
return new SFSDataWrapper(SFSDataType.UTF_STRING, value);
}
});
transformers.put(String[].class, new Transformer() {
@Override
public SFSDataWrapper transform(Object value) {
return new SFSDataWrapper(SFSDataType.UTF_STRING_ARRAY, stringArrayToCollection((String[])value));
}
});
} | java | protected void initWithStringType() {
transformers.put(String.class, new Transformer() {
@Override
public SFSDataWrapper transform(Object value) {
return new SFSDataWrapper(SFSDataType.UTF_STRING, value);
}
});
transformers.put(String[].class, new Transformer() {
@Override
public SFSDataWrapper transform(Object value) {
return new SFSDataWrapper(SFSDataType.UTF_STRING_ARRAY, stringArrayToCollection((String[])value));
}
});
} | [
"protected",
"void",
"initWithStringType",
"(",
")",
"{",
"transformers",
".",
"put",
"(",
"String",
".",
"class",
",",
"new",
"Transformer",
"(",
")",
"{",
"@",
"Override",
"public",
"SFSDataWrapper",
"transform",
"(",
"Object",
"value",
")",
"{",
"return",... | Add transformer of string and transformer of array of strings to the map | [
"Add",
"transformer",
"of",
"string",
"and",
"transformer",
"of",
"array",
"of",
"strings",
"to",
"the",
"map"
] | train | https://github.com/youngmonkeys/ezyfox-sfs2x/blob/7e004033a3b551c3ae970a0c8f45db7b1ec144de/src/main/java/com/tvd12/ezyfox/sfs2x/data/impl/SimpleTransformer.java#L411-L425 |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java | IntegerExtensions.bitwiseXor | @Pure
@Inline(value="($1 ^ $2)", constantExpression=true)
public static int bitwiseXor(int a, int b) {
return a ^ b;
} | java | @Pure
@Inline(value="($1 ^ $2)", constantExpression=true)
public static int bitwiseXor(int a, int b) {
return a ^ b;
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"($1 ^ $2)\"",
",",
"constantExpression",
"=",
"true",
")",
"public",
"static",
"int",
"bitwiseXor",
"(",
"int",
"a",
",",
"int",
"b",
")",
"{",
"return",
"a",
"^",
"b",
";",
"}"
] | The bitwise exclusive <code>or</code> operation. This is the equivalent to the java <code>^</code> operator.
@param a
an integer.
@param b
an integer.
@return <code>a^b</code> | [
"The",
"bitwise",
"exclusive",
"<code",
">",
"or<",
"/",
"code",
">",
"operation",
".",
"This",
"is",
"the",
"equivalent",
"to",
"the",
"java",
"<code",
">",
"^<",
"/",
"code",
">",
"operator",
"."
] | train | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IntegerExtensions.java#L91-L95 |
zaproxy/zaproxy | src/org/zaproxy/zap/extension/pscan/ExtensionPassiveScan.java | ExtensionPassiveScan.setPluginPassiveScannerEnabled | void setPluginPassiveScannerEnabled(int pluginId, boolean enabled) {
PluginPassiveScanner scanner = getPluginPassiveScanner(pluginId);
if (scanner != null) {
scanner.setEnabled(enabled);
scanner.save();
}
} | java | void setPluginPassiveScannerEnabled(int pluginId, boolean enabled) {
PluginPassiveScanner scanner = getPluginPassiveScanner(pluginId);
if (scanner != null) {
scanner.setEnabled(enabled);
scanner.save();
}
} | [
"void",
"setPluginPassiveScannerEnabled",
"(",
"int",
"pluginId",
",",
"boolean",
"enabled",
")",
"{",
"PluginPassiveScanner",
"scanner",
"=",
"getPluginPassiveScanner",
"(",
"pluginId",
")",
";",
"if",
"(",
"scanner",
"!=",
"null",
")",
"{",
"scanner",
".",
"se... | Sets whether or not the plug-in passive scanner with the given {@code pluginId} is {@code enabled}.
@param pluginId the ID of the plug-in passive scanner
@param enabled {@code true} if the scanner should be enabled, {@code false} otherwise | [
"Sets",
"whether",
"or",
"not",
"the",
"plug",
"-",
"in",
"passive",
"scanner",
"with",
"the",
"given",
"{",
"@code",
"pluginId",
"}",
"is",
"{",
"@code",
"enabled",
"}",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/pscan/ExtensionPassiveScan.java#L342-L348 |
jcustenborder/connect-utils | connect-utils/src/main/java/com/github/jcustenborder/kafka/connect/utils/config/ConfigUtils.java | ConfigUtils.hostAndPort | public static HostAndPort hostAndPort(AbstractConfig config, String key, Integer defaultPort) {
final String input = config.getString(key);
return hostAndPort(input, defaultPort);
} | java | public static HostAndPort hostAndPort(AbstractConfig config, String key, Integer defaultPort) {
final String input = config.getString(key);
return hostAndPort(input, defaultPort);
} | [
"public",
"static",
"HostAndPort",
"hostAndPort",
"(",
"AbstractConfig",
"config",
",",
"String",
"key",
",",
"Integer",
"defaultPort",
")",
"{",
"final",
"String",
"input",
"=",
"config",
".",
"getString",
"(",
"key",
")",
";",
"return",
"hostAndPort",
"(",
... | Method is used to parse a string ConfigDef item to a HostAndPort
@param config Config to read from
@param key ConfigItem to get the host string from.
@param defaultPort The default port to use if a port was not specified. Can be null.
@return HostAndPort based on the ConfigItem. | [
"Method",
"is",
"used",
"to",
"parse",
"a",
"string",
"ConfigDef",
"item",
"to",
"a",
"HostAndPort"
] | train | https://github.com/jcustenborder/connect-utils/blob/19add138921f59ffcc85282d7aad551eeb582370/connect-utils/src/main/java/com/github/jcustenborder/kafka/connect/utils/config/ConfigUtils.java#L157-L160 |
kevoree/kevoree-library | mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/ProtocolProcessor.java | ProtocolProcessor.processUnsubscribe | void processUnsubscribe(ServerChannel session, String clientID, List<String> topics, int messageID) {
Log.trace("processUnsubscribe invoked, removing subscription on topics {}, for clientID <{}>", topics, clientID);
for (String topic : topics) {
subscriptions.removeSubscription(topic, clientID);
}
//ack the client
UnsubAckMessage ackMessage = new UnsubAckMessage();
ackMessage.setMessageID(messageID);
Log.trace("replying with UnsubAck to MSG ID {}", messageID);
session.write(ackMessage);
} | java | void processUnsubscribe(ServerChannel session, String clientID, List<String> topics, int messageID) {
Log.trace("processUnsubscribe invoked, removing subscription on topics {}, for clientID <{}>", topics, clientID);
for (String topic : topics) {
subscriptions.removeSubscription(topic, clientID);
}
//ack the client
UnsubAckMessage ackMessage = new UnsubAckMessage();
ackMessage.setMessageID(messageID);
Log.trace("replying with UnsubAck to MSG ID {}", messageID);
session.write(ackMessage);
} | [
"void",
"processUnsubscribe",
"(",
"ServerChannel",
"session",
",",
"String",
"clientID",
",",
"List",
"<",
"String",
">",
"topics",
",",
"int",
"messageID",
")",
"{",
"Log",
".",
"trace",
"(",
"\"processUnsubscribe invoked, removing subscription on topics {}, for clien... | Remove the clientID from topic subscription, if not previously subscribed,
doesn't reply any error | [
"Remove",
"the",
"clientID",
"from",
"topic",
"subscription",
"if",
"not",
"previously",
"subscribed",
"doesn",
"t",
"reply",
"any",
"error"
] | train | https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/ProtocolProcessor.java#L485-L497 |
vincentk/joptimizer | src/main/java/com/joptimizer/util/Utils.java | Utils.calculateScaledResidual | public static double calculateScaledResidual(double[][] A, double[] x, double[] b){
DoubleMatrix2D AMatrix = DoubleFactory2D.dense.make(A);
DoubleMatrix1D xVector = DoubleFactory1D.dense.make(x);
DoubleMatrix1D bVector = DoubleFactory1D.dense.make(b);
return calculateScaledResidual(AMatrix, xVector, bVector);
} | java | public static double calculateScaledResidual(double[][] A, double[] x, double[] b){
DoubleMatrix2D AMatrix = DoubleFactory2D.dense.make(A);
DoubleMatrix1D xVector = DoubleFactory1D.dense.make(x);
DoubleMatrix1D bVector = DoubleFactory1D.dense.make(b);
return calculateScaledResidual(AMatrix, xVector, bVector);
} | [
"public",
"static",
"double",
"calculateScaledResidual",
"(",
"double",
"[",
"]",
"[",
"]",
"A",
",",
"double",
"[",
"]",
"x",
",",
"double",
"[",
"]",
"b",
")",
"{",
"DoubleMatrix2D",
"AMatrix",
"=",
"DoubleFactory2D",
".",
"dense",
".",
"make",
"(",
... | Calculate the scaled residual
<br> ||Ax-b||_oo/( ||A||_oo . ||x||_oo + ||b||_oo ), with
<br> ||x||_oo = max(||x[i]||) | [
"Calculate",
"the",
"scaled",
"residual",
"<br",
">",
"||Ax",
"-",
"b||_oo",
"/",
"(",
"||A||_oo",
".",
"||x||_oo",
"+",
"||b||_oo",
")",
"with",
"<br",
">",
"||x||_oo",
"=",
"max",
"(",
"||x",
"[",
"i",
"]",
"||",
")"
] | train | https://github.com/vincentk/joptimizer/blob/65064c1bb0b26c7261358021e4c93d06dd43564f/src/main/java/com/joptimizer/util/Utils.java#L167-L172 |
pac4j/pac4j | pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java | ContextHelper.getCookie | public static Cookie getCookie(final WebContext context, final String name) {
return getCookie(context.getRequestCookies(), name);
} | java | public static Cookie getCookie(final WebContext context, final String name) {
return getCookie(context.getRequestCookies(), name);
} | [
"public",
"static",
"Cookie",
"getCookie",
"(",
"final",
"WebContext",
"context",
",",
"final",
"String",
"name",
")",
"{",
"return",
"getCookie",
"(",
"context",
".",
"getRequestCookies",
"(",
")",
",",
"name",
")",
";",
"}"
] | Get a specific cookie by its name.
@param context the current web context
@param name the name of the cookie
@return the cookie | [
"Get",
"a",
"specific",
"cookie",
"by",
"its",
"name",
"."
] | train | https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java#L40-L42 |
GenesysPureEngage/workspace-client-java | src/main/java/com/genesys/internal/workspace/api/UcsApi.java | UcsApi.setCompleted | public ApiSuccessResponse setCompleted(String id, CompletedData completedData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = setCompletedWithHttpInfo(id, completedData);
return resp.getData();
} | java | public ApiSuccessResponse setCompleted(String id, CompletedData completedData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = setCompletedWithHttpInfo(id, completedData);
return resp.getData();
} | [
"public",
"ApiSuccessResponse",
"setCompleted",
"(",
"String",
"id",
",",
"CompletedData",
"completedData",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ApiSuccessResponse",
">",
"resp",
"=",
"setCompletedWithHttpInfo",
"(",
"id",
",",
"completedData",
")"... | Set the interaction as being completed
@param id id of the Interaction (required)
@param completedData (optional)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Set",
"the",
"interaction",
"as",
"being",
"completed"
] | train | https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/internal/workspace/api/UcsApi.java#L2044-L2047 |
foundation-runtime/service-directory | 2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/ServiceDirectoryThread.java | ServiceDirectoryThread.getThread | public static Thread getThread(Runnable runnable, String name){
return doThread(runnable, name, DefaultThreadDeamon);
} | java | public static Thread getThread(Runnable runnable, String name){
return doThread(runnable, name, DefaultThreadDeamon);
} | [
"public",
"static",
"Thread",
"getThread",
"(",
"Runnable",
"runnable",
",",
"String",
"name",
")",
"{",
"return",
"doThread",
"(",
"runnable",
",",
"name",
",",
"DefaultThreadDeamon",
")",
";",
"}"
] | Get a Thread.
@param runnable
the runnable task.
@param name
the thread name.
@return
the Thread. | [
"Get",
"a",
"Thread",
"."
] | train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/ServiceDirectoryThread.java#L64-L66 |
fuinorg/event-store-commons | jpa/src/main/java/org/fuin/esc/jpa/AbstractJpaEventStore.java | AbstractJpaEventStore.setNativeSqlParameters | private final void setNativeSqlParameters(final Query query, final List<NativeSqlCondition> conditions) {
for (final NativeSqlCondition condition : conditions) {
query.setParameter(condition.getColumn(), condition.getValue());
}
} | java | private final void setNativeSqlParameters(final Query query, final List<NativeSqlCondition> conditions) {
for (final NativeSqlCondition condition : conditions) {
query.setParameter(condition.getColumn(), condition.getValue());
}
} | [
"private",
"final",
"void",
"setNativeSqlParameters",
"(",
"final",
"Query",
"query",
",",
"final",
"List",
"<",
"NativeSqlCondition",
">",
"conditions",
")",
"{",
"for",
"(",
"final",
"NativeSqlCondition",
"condition",
":",
"conditions",
")",
"{",
"query",
".",... | Sets parameters in a query.
@param query
Query to set parameters for.
@param streamId
Unique stream identifier that has the parameter values.
@param additionalConditions
Parameters to add in addition to the ones from the stream
identifier. | [
"Sets",
"parameters",
"in",
"a",
"query",
"."
] | train | https://github.com/fuinorg/event-store-commons/blob/ea175582d8cda2b5a6d2fe52bbb2f1c183eee77c/jpa/src/main/java/org/fuin/esc/jpa/AbstractJpaEventStore.java#L473-L477 |
artikcloud/artikcloud-java | src/main/java/cloud/artik/api/MessagesApi.java | MessagesApi.getNormalizedActions | public NormalizedActionsEnvelope getNormalizedActions(String uid, String ddid, String mid, String offset, Integer count, Long startDate, Long endDate, String order) throws ApiException {
ApiResponse<NormalizedActionsEnvelope> resp = getNormalizedActionsWithHttpInfo(uid, ddid, mid, offset, count, startDate, endDate, order);
return resp.getData();
} | java | public NormalizedActionsEnvelope getNormalizedActions(String uid, String ddid, String mid, String offset, Integer count, Long startDate, Long endDate, String order) throws ApiException {
ApiResponse<NormalizedActionsEnvelope> resp = getNormalizedActionsWithHttpInfo(uid, ddid, mid, offset, count, startDate, endDate, order);
return resp.getData();
} | [
"public",
"NormalizedActionsEnvelope",
"getNormalizedActions",
"(",
"String",
"uid",
",",
"String",
"ddid",
",",
"String",
"mid",
",",
"String",
"offset",
",",
"Integer",
"count",
",",
"Long",
"startDate",
",",
"Long",
"endDate",
",",
"String",
"order",
")",
"... | Get Normalized Actions
Get the actions normalized
@param uid User ID. If not specified, assume that of the current authenticated user. If specified, it must be that of a user for which the current authenticated user has read access to. (optional)
@param ddid Destination device ID of the actions being searched. (optional)
@param mid The message ID being searched. (optional)
@param offset A string that represents the starting item, should be the value of 'next' field received in the last response. (required for pagination) (optional)
@param count count (optional)
@param startDate startDate (optional)
@param endDate endDate (optional)
@param order Desired sort order: 'asc' or 'desc' (optional)
@return NormalizedActionsEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Get",
"Normalized",
"Actions",
"Get",
"the",
"actions",
"normalized"
] | train | https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/MessagesApi.java#L844-L847 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/internal/networking/OutboundHandler.java | OutboundHandler.initDstBuffer | protected final void initDstBuffer(int sizeBytes, byte[] bytes) {
if (bytes != null && bytes.length > sizeBytes) {
throw new IllegalArgumentException("Buffer overflow. Can't initialize dstBuffer for "
+ this + " and channel" + channel + " because too many bytes, sizeBytes " + sizeBytes
+ ". bytes.length " + bytes.length);
}
ChannelOptions config = channel.options();
ByteBuffer buffer = newByteBuffer(sizeBytes, config.getOption(DIRECT_BUF));
if (bytes != null) {
buffer.put(bytes);
}
buffer.flip();
dst = (D) buffer;
} | java | protected final void initDstBuffer(int sizeBytes, byte[] bytes) {
if (bytes != null && bytes.length > sizeBytes) {
throw new IllegalArgumentException("Buffer overflow. Can't initialize dstBuffer for "
+ this + " and channel" + channel + " because too many bytes, sizeBytes " + sizeBytes
+ ". bytes.length " + bytes.length);
}
ChannelOptions config = channel.options();
ByteBuffer buffer = newByteBuffer(sizeBytes, config.getOption(DIRECT_BUF));
if (bytes != null) {
buffer.put(bytes);
}
buffer.flip();
dst = (D) buffer;
} | [
"protected",
"final",
"void",
"initDstBuffer",
"(",
"int",
"sizeBytes",
",",
"byte",
"[",
"]",
"bytes",
")",
"{",
"if",
"(",
"bytes",
"!=",
"null",
"&&",
"bytes",
".",
"length",
">",
"sizeBytes",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
... | Initializes the dst ByteBuffer with the configured size.
The buffer created is reading mode.
@param sizeBytes the size of the dst ByteBuffer.
@param bytes the bytes added to the buffer. Can be null if nothing
should be added.
@throws IllegalArgumentException if the size of the buffer is too small. | [
"Initializes",
"the",
"dst",
"ByteBuffer",
"with",
"the",
"configured",
"size",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/networking/OutboundHandler.java#L108-L122 |
GenesysPureEngage/authentication-client-java | src/main/java/com/genesys/internal/authentication/api/AuthenticationApi.java | AuthenticationApi.authorizeAsync | public com.squareup.okhttp.Call authorizeAsync(String clientId, String redirectUri, String responseType, String authorization, Boolean hideTenant, String scope, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = authorizeValidateBeforeCall(clientId, redirectUri, responseType, authorization, hideTenant, scope, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
} | java | public com.squareup.okhttp.Call authorizeAsync(String clientId, String redirectUri, String responseType, String authorization, Boolean hideTenant, String scope, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = authorizeValidateBeforeCall(clientId, redirectUri, responseType, authorization, hideTenant, scope, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
} | [
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"authorizeAsync",
"(",
"String",
"clientId",
",",
"String",
"redirectUri",
",",
"String",
"responseType",
",",
"String",
"authorization",
",",
"Boolean",
"hideTenant",
",",
"String",
"scope",
",",
"... | Perform authorization (asynchronously)
Perform authorization based on the code grant type &mdash; either Authorization Code Grant or Implicit Grant. For more information, see [Authorization Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1). **Note:** For the optional **scope** parameter, the Authentication API supports only the `*` value.
@param clientId The ID of the application or service that is registered as the client. You'll need to get this value from your PureEngage Cloud representative. (required)
@param redirectUri The URI that you want users to be redirected to after entering valid credentials during an Implicit or Authorization Code grant. The Authentication API includes this as part of the URI it returns in the 'Location' header. (required)
@param responseType The response type to let the Authentication API know which grant flow you're using. Possible values are `code` for Authorization Code Grant or `token` for Implicit Grant. For more information about this parameter, see [Response Type](https://tools.ietf.org/html/rfc6749#section-3.1.1). (required)
@param authorization Basic authorization. For example: 'Authorization: Basic Y3...MQ==' (optional)
@param hideTenant Hide the **tenant** field in the UI for Authorization Code Grant. (optional, default to false)
@param scope The scope of the access request. The Authentication API supports only the `*` value. (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object | [
"Perform",
"authorization",
"(",
"asynchronously",
")",
"Perform",
"authorization",
"based",
"on",
"the",
"code",
"grant",
"type",
"&",
";",
"mdash",
";",
"either",
"Authorization",
"Code",
"Grant",
"or",
"Implicit",
"Grant",
".",
"For",
"more",
"information"... | train | https://github.com/GenesysPureEngage/authentication-client-java/blob/eb0d58343ee42ebd3c037163c1137f611dfcbb3a/src/main/java/com/genesys/internal/authentication/api/AuthenticationApi.java#L198-L222 |
airbnb/lottie-android | lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java | LottieCompositionFactory.fromUrl | public static LottieTask<LottieComposition> fromUrl(final Context context, final String url) {
String urlCacheKey = "url_" + url;
return cache(urlCacheKey, new Callable<LottieResult<LottieComposition>>() {
@Override public LottieResult<LottieComposition> call() {
return NetworkFetcher.fetchSync(context, url);
}
});
} | java | public static LottieTask<LottieComposition> fromUrl(final Context context, final String url) {
String urlCacheKey = "url_" + url;
return cache(urlCacheKey, new Callable<LottieResult<LottieComposition>>() {
@Override public LottieResult<LottieComposition> call() {
return NetworkFetcher.fetchSync(context, url);
}
});
} | [
"public",
"static",
"LottieTask",
"<",
"LottieComposition",
">",
"fromUrl",
"(",
"final",
"Context",
"context",
",",
"final",
"String",
"url",
")",
"{",
"String",
"urlCacheKey",
"=",
"\"url_\"",
"+",
"url",
";",
"return",
"cache",
"(",
"urlCacheKey",
",",
"n... | Fetch an animation from an http url. Once it is downloaded once, Lottie will cache the file to disk for
future use. Because of this, you may call `fromUrl` ahead of time to warm the cache if you think you
might need an animation in the future. | [
"Fetch",
"an",
"animation",
"from",
"an",
"http",
"url",
".",
"Once",
"it",
"is",
"downloaded",
"once",
"Lottie",
"will",
"cache",
"the",
"file",
"to",
"disk",
"for",
"future",
"use",
".",
"Because",
"of",
"this",
"you",
"may",
"call",
"fromUrl",
"ahead"... | train | https://github.com/airbnb/lottie-android/blob/126dabdc9f586c87822f85fe1128cdad439d30fa/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java#L63-L70 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CfInterfaceCodeGen.java | CfInterfaceCodeGen.writeClassBody | @Override
public void writeClassBody(Definition def, Writer out) throws IOException
{
out.write("public interface " + getClassName(def) + " extends Serializable, Referenceable");
writeLeftCurlyBracket(out, 0);
int indent = 1;
writeConnection(def, out, indent);
writeRightCurlyBracket(out, 0);
} | java | @Override
public void writeClassBody(Definition def, Writer out) throws IOException
{
out.write("public interface " + getClassName(def) + " extends Serializable, Referenceable");
writeLeftCurlyBracket(out, 0);
int indent = 1;
writeConnection(def, out, indent);
writeRightCurlyBracket(out, 0);
} | [
"@",
"Override",
"public",
"void",
"writeClassBody",
"(",
"Definition",
"def",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"out",
".",
"write",
"(",
"\"public interface \"",
"+",
"getClassName",
"(",
"def",
")",
"+",
"\" extends Serializable, Referenc... | Output class code
@param def definition
@param out Writer
@throws IOException ioException | [
"Output",
"class",
"code"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CfInterfaceCodeGen.java#L43-L53 |
nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java | Scheduler.toDateAddDaysSetOfWeek | public static Date toDateAddDaysSetOfWeek(int days, int dayOfWeek)
{
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, days);
return cal.getTime();
} | java | public static Date toDateAddDaysSetOfWeek(int days, int dayOfWeek)
{
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, days);
return cal.getTime();
} | [
"public",
"static",
"Date",
"toDateAddDaysSetOfWeek",
"(",
"int",
"days",
",",
"int",
"dayOfWeek",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"days",
")",
... | Add days of the year (positive or negative),
then set day of week
@param days the days to add or subtract
@param dayOfWeek the day of week to set
@return the new date time | [
"Add",
"days",
"of",
"the",
"year",
"(",
"positive",
"or",
"negative",
")",
"then",
"set",
"day",
"of",
"week"
] | train | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Scheduler.java#L57-L65 |
alkacon/opencms-core | src/org/opencms/file/wrapper/CmsResourceWrapperXmlPage.java | CmsResourceWrapperXmlPage.getStringValue | private String getStringValue(CmsObject cms, CmsResource resource, byte[] content) throws CmsException {
// get the encoding for the resource
CmsProperty prop = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true);
String enc = prop.getValue();
if (enc == null) {
enc = OpenCms.getSystemInfo().getDefaultEncoding();
}
// create a String with the right encoding
return CmsEncoder.createString(content, enc);
} | java | private String getStringValue(CmsObject cms, CmsResource resource, byte[] content) throws CmsException {
// get the encoding for the resource
CmsProperty prop = cms.readPropertyObject(resource, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true);
String enc = prop.getValue();
if (enc == null) {
enc = OpenCms.getSystemInfo().getDefaultEncoding();
}
// create a String with the right encoding
return CmsEncoder.createString(content, enc);
} | [
"private",
"String",
"getStringValue",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
",",
"byte",
"[",
"]",
"content",
")",
"throws",
"CmsException",
"{",
"// get the encoding for the resource",
"CmsProperty",
"prop",
"=",
"cms",
".",
"readPropertyObject",
... | Returns the content as a string while using the correct encoding.<p>
@param cms the initialized CmsObject
@param resource the resource where the content belongs to
@param content the byte array which should be converted into a string
@return the content as a string
@throws CmsException if something goes wrong | [
"Returns",
"the",
"content",
"as",
"a",
"string",
"while",
"using",
"the",
"correct",
"encoding",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/wrapper/CmsResourceWrapperXmlPage.java#L1076-L1087 |
mangstadt/biweekly | src/main/java/biweekly/property/Trigger.java | Trigger.setDuration | public void setDuration(Duration duration, Related related) {
this.date = null;
this.duration = duration;
setRelated(related);
} | java | public void setDuration(Duration duration, Related related) {
this.date = null;
this.duration = duration;
setRelated(related);
} | [
"public",
"void",
"setDuration",
"(",
"Duration",
"duration",
",",
"Related",
"related",
")",
"{",
"this",
".",
"date",
"=",
"null",
";",
"this",
".",
"duration",
"=",
"duration",
";",
"setRelated",
"(",
"related",
")",
";",
"}"
] | Sets a relative time at which the alarm will trigger.
@param duration the relative time
@param related the date-time field that the duration is relative to | [
"Sets",
"a",
"relative",
"time",
"at",
"which",
"the",
"alarm",
"will",
"trigger",
"."
] | train | https://github.com/mangstadt/biweekly/blob/2e21350f85c13dfff52fdef98fdbebe2976fcf61/src/main/java/biweekly/property/Trigger.java#L103-L107 |
LearnLib/automatalib | serialization/etf/src/main/java/net/automatalib/serialization/etf/writer/Mealy2ETFWriterIO.java | Mealy2ETFWriterIO.writeETF | @Override
protected void writeETF(PrintWriter pw, MealyMachine<?, I, ?, O> mealy, Alphabet<I> inputs) {
writeETFInternal(pw, mealy, inputs);
} | java | @Override
protected void writeETF(PrintWriter pw, MealyMachine<?, I, ?, O> mealy, Alphabet<I> inputs) {
writeETFInternal(pw, mealy, inputs);
} | [
"@",
"Override",
"protected",
"void",
"writeETF",
"(",
"PrintWriter",
"pw",
",",
"MealyMachine",
"<",
"?",
",",
"I",
",",
"?",
",",
"O",
">",
"mealy",
",",
"Alphabet",
"<",
"I",
">",
"inputs",
")",
"{",
"writeETFInternal",
"(",
"pw",
",",
"mealy",
",... | Write ETF parts specific for Mealy machines with IO semantics.
Writes:
- the initial state,
- the valuations for the state ids,
- the transitions,
- the input alphabet (for the input labels on edges),
- the output alphabet (for the output labels on edges).
@param pw the Writer.
@param mealy the Mealy machine to write.
@param inputs the alphabet. | [
"Write",
"ETF",
"parts",
"specific",
"for",
"Mealy",
"machines",
"with",
"IO",
"semantics",
"."
] | train | https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/serialization/etf/src/main/java/net/automatalib/serialization/etf/writer/Mealy2ETFWriterIO.java#L67-L70 |
Netflix/spectator | spectator-api/src/main/java/com/netflix/spectator/api/patterns/LongTaskTimer.java | LongTaskTimer.get | public static LongTaskTimer get(Registry registry, Id id) {
ConcurrentMap<Id, Object> state = registry.state();
Object obj = Utils.computeIfAbsent(state, id, i -> {
LongTaskTimer timer = new LongTaskTimer(registry, id);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.activeTasks)
.monitorValue(timer, LongTaskTimer::activeTasks);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.duration)
.monitorValue(timer, t -> t.duration() / NANOS_PER_SECOND);
return timer;
});
if (!(obj instanceof LongTaskTimer)) {
Utils.propagateTypeError(registry, id, LongTaskTimer.class, obj.getClass());
obj = new LongTaskTimer(new NoopRegistry(), id);
}
return (LongTaskTimer) obj;
} | java | public static LongTaskTimer get(Registry registry, Id id) {
ConcurrentMap<Id, Object> state = registry.state();
Object obj = Utils.computeIfAbsent(state, id, i -> {
LongTaskTimer timer = new LongTaskTimer(registry, id);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.activeTasks)
.monitorValue(timer, LongTaskTimer::activeTasks);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.duration)
.monitorValue(timer, t -> t.duration() / NANOS_PER_SECOND);
return timer;
});
if (!(obj instanceof LongTaskTimer)) {
Utils.propagateTypeError(registry, id, LongTaskTimer.class, obj.getClass());
obj = new LongTaskTimer(new NoopRegistry(), id);
}
return (LongTaskTimer) obj;
} | [
"public",
"static",
"LongTaskTimer",
"get",
"(",
"Registry",
"registry",
",",
"Id",
"id",
")",
"{",
"ConcurrentMap",
"<",
"Id",
",",
"Object",
">",
"state",
"=",
"registry",
".",
"state",
"(",
")",
";",
"Object",
"obj",
"=",
"Utils",
".",
"computeIfAbsen... | Creates a timer for tracking long running tasks.
@param registry
Registry to use.
@param id
Identifier for the metric being registered.
@return
Timer instance. | [
"Creates",
"a",
"timer",
"for",
"tracking",
"long",
"running",
"tasks",
"."
] | train | https://github.com/Netflix/spectator/blob/259318252770de3bad581b85adff187d8f2c6537/spectator-api/src/main/java/com/netflix/spectator/api/patterns/LongTaskTimer.java#L50-L69 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.