repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
204
| func_name
stringlengths 5
103
| whole_func_string
stringlengths 87
3.44k
| language
stringclasses 1
value | func_code_string
stringlengths 87
3.44k
| func_code_tokens
sequencelengths 21
714
| func_documentation_string
stringlengths 61
1.95k
| func_documentation_tokens
sequencelengths 1
482
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
309
|
---|---|---|---|---|---|---|---|---|---|---|
codeprimate-software/cp-elements | src/main/java/org/cp/elements/data/caching/provider/ConcurrentMapCache.java | ConcurrentMapCache.putIfPresent | @Override
public VALUE putIfPresent(KEY key, VALUE newValue) {
Assert.notNull(newValue, "Value is required");
if (key != null) {
AtomicReference<VALUE> oldValueRef = new AtomicReference<>(null);
return newValue.equals(this.map.computeIfPresent(key, (theKey, oldValue) -> {
oldValueRef.set(oldValue);
return newValue;
})) ? oldValueRef.get() : null;
}
return null;
} | java | @Override
public VALUE putIfPresent(KEY key, VALUE newValue) {
Assert.notNull(newValue, "Value is required");
if (key != null) {
AtomicReference<VALUE> oldValueRef = new AtomicReference<>(null);
return newValue.equals(this.map.computeIfPresent(key, (theKey, oldValue) -> {
oldValueRef.set(oldValue);
return newValue;
})) ? oldValueRef.get() : null;
}
return null;
} | [
"@",
"Override",
"public",
"VALUE",
"putIfPresent",
"(",
"KEY",
"key",
",",
"VALUE",
"newValue",
")",
"{",
"Assert",
".",
"notNull",
"(",
"newValue",
",",
"\"Value is required\"",
")",
";",
"if",
"(",
"key",
"!=",
"null",
")",
"{",
"AtomicReference",
"<",
"VALUE",
">",
"oldValueRef",
"=",
"new",
"AtomicReference",
"<>",
"(",
"null",
")",
";",
"return",
"newValue",
".",
"equals",
"(",
"this",
".",
"map",
".",
"computeIfPresent",
"(",
"key",
",",
"(",
"theKey",
",",
"oldValue",
")",
"->",
"{",
"oldValueRef",
".",
"set",
"(",
"oldValue",
")",
";",
"return",
"newValue",
";",
"}",
")",
")",
"?",
"oldValueRef",
".",
"get",
"(",
")",
":",
"null",
";",
"}",
"return",
"null",
";",
"}"
] | Puts the {@link VALUE value} in this {@link Cache} mapped to the given {@link KEY key} iff an entry
with the given {@link KEY key} already exists in this {@link Cache}.
@param key {@link KEY key} used to map the {@link VALUE new value} in this {@link Cache}.
@param newValue {@link VALUE new value} replacing the existing value mapped to the given {@link KEY key}
in this {@link Cache}.
@return the existing {@link VALUE value} if present, otherwise return {@literal null}.
@throws IllegalArgumentException if the {@link VALUE value} is {@literal null}.
@see #contains(Comparable)
@see #put(Comparable, Object)
@see #putIfAbsent(Comparable, Object) | [
"Puts",
"the",
"{",
"@link",
"VALUE",
"value",
"}",
"in",
"this",
"{",
"@link",
"Cache",
"}",
"mapped",
"to",
"the",
"given",
"{",
"@link",
"KEY",
"key",
"}",
"iff",
"an",
"entry",
"with",
"the",
"given",
"{",
"@link",
"KEY",
"key",
"}",
"already",
"exists",
"in",
"this",
"{",
"@link",
"Cache",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/data/caching/provider/ConcurrentMapCache.java#L206-L222 |
nulab/backlog4j | src/main/java/com/nulabinc/backlog4j/api/option/CreateIssueParams.java | CreateIssueParams.actualHours | public CreateIssueParams actualHours(BigDecimal actualHours) {
if (actualHours == null) {
parameters.add(new NameValuePair("actualHours", ""));
} else {
parameters.add(new NameValuePair("actualHours", actualHours.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()));
}
return this;
} | java | public CreateIssueParams actualHours(BigDecimal actualHours) {
if (actualHours == null) {
parameters.add(new NameValuePair("actualHours", ""));
} else {
parameters.add(new NameValuePair("actualHours", actualHours.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()));
}
return this;
} | [
"public",
"CreateIssueParams",
"actualHours",
"(",
"BigDecimal",
"actualHours",
")",
"{",
"if",
"(",
"actualHours",
"==",
"null",
")",
"{",
"parameters",
".",
"add",
"(",
"new",
"NameValuePair",
"(",
"\"actualHours\"",
",",
"\"\"",
")",
")",
";",
"}",
"else",
"{",
"parameters",
".",
"add",
"(",
"new",
"NameValuePair",
"(",
"\"actualHours\"",
",",
"actualHours",
".",
"setScale",
"(",
"2",
",",
"BigDecimal",
".",
"ROUND_HALF_UP",
")",
".",
"toPlainString",
"(",
")",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the issue actual hours.
@param actualHours the issue actual hours
@return CreateIssueParams instance | [
"Sets",
"the",
"issue",
"actual",
"hours",
"."
] | train | https://github.com/nulab/backlog4j/blob/862ae0586ad808b2ec413f665b8dfc0c9a107b4e/src/main/java/com/nulabinc/backlog4j/api/option/CreateIssueParams.java#L121-L128 |
line/armeria | core/src/main/java/com/linecorp/armeria/client/circuitbreaker/CircuitBreakerHttpClient.java | CircuitBreakerHttpClient.newDecorator | public static Function<Client<HttpRequest, HttpResponse>, CircuitBreakerHttpClient>
newDecorator(CircuitBreakerMapping mapping, CircuitBreakerStrategy strategy) {
return delegate -> new CircuitBreakerHttpClient(delegate, mapping, strategy);
} | java | public static Function<Client<HttpRequest, HttpResponse>, CircuitBreakerHttpClient>
newDecorator(CircuitBreakerMapping mapping, CircuitBreakerStrategy strategy) {
return delegate -> new CircuitBreakerHttpClient(delegate, mapping, strategy);
} | [
"public",
"static",
"Function",
"<",
"Client",
"<",
"HttpRequest",
",",
"HttpResponse",
">",
",",
"CircuitBreakerHttpClient",
">",
"newDecorator",
"(",
"CircuitBreakerMapping",
"mapping",
",",
"CircuitBreakerStrategy",
"strategy",
")",
"{",
"return",
"delegate",
"->",
"new",
"CircuitBreakerHttpClient",
"(",
"delegate",
",",
"mapping",
",",
"strategy",
")",
";",
"}"
] | Creates a new decorator with the specified {@link CircuitBreakerMapping} and
{@link CircuitBreakerStrategy}.
<p>Since {@link CircuitBreaker} is a unit of failure detection, don't reuse the same instance for
unrelated services. | [
"Creates",
"a",
"new",
"decorator",
"with",
"the",
"specified",
"{",
"@link",
"CircuitBreakerMapping",
"}",
"and",
"{",
"@link",
"CircuitBreakerStrategy",
"}",
"."
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/client/circuitbreaker/CircuitBreakerHttpClient.java#L53-L56 |
brettonw/Bag | src/main/java/com/brettonw/bag/Bag.java | Bag.getInteger | public Integer getInteger (String key, Supplier<Integer> notFound) {
return getParsed (key, Integer::new, notFound);
} | java | public Integer getInteger (String key, Supplier<Integer> notFound) {
return getParsed (key, Integer::new, notFound);
} | [
"public",
"Integer",
"getInteger",
"(",
"String",
"key",
",",
"Supplier",
"<",
"Integer",
">",
"notFound",
")",
"{",
"return",
"getParsed",
"(",
"key",
",",
"Integer",
"::",
"new",
",",
"notFound",
")",
";",
"}"
] | Retrieve a mapped element and return it as an Integer.
@param key A string value used to index the element.
@param notFound A function to create a new Integer if the requested key was not found
@return The element as an Integer, or notFound if the element is not found. | [
"Retrieve",
"a",
"mapped",
"element",
"and",
"return",
"it",
"as",
"an",
"Integer",
"."
] | train | https://github.com/brettonw/Bag/blob/25c0ff74893b6c9a2c61bf0f97189ab82e0b2f56/src/main/java/com/brettonw/bag/Bag.java#L208-L210 |
cerner/beadledom | jackson/src/main/java/com/cerner/beadledom/jackson/filter/FieldFilter.java | FieldFilter.writeJson | public void writeJson(JsonParser parser, JsonGenerator jgen) throws IOException {
checkNotNull(parser, "JsonParser cannot be null for writeJson.");
checkNotNull(jgen, "JsonGenerator cannot be null for writeJson.");
JsonToken curToken = parser.nextToken();
while (curToken != null) {
curToken = processToken(curToken, parser, jgen);
}
jgen.flush();
} | java | public void writeJson(JsonParser parser, JsonGenerator jgen) throws IOException {
checkNotNull(parser, "JsonParser cannot be null for writeJson.");
checkNotNull(jgen, "JsonGenerator cannot be null for writeJson.");
JsonToken curToken = parser.nextToken();
while (curToken != null) {
curToken = processToken(curToken, parser, jgen);
}
jgen.flush();
} | [
"public",
"void",
"writeJson",
"(",
"JsonParser",
"parser",
",",
"JsonGenerator",
"jgen",
")",
"throws",
"IOException",
"{",
"checkNotNull",
"(",
"parser",
",",
"\"JsonParser cannot be null for writeJson.\"",
")",
";",
"checkNotNull",
"(",
"jgen",
",",
"\"JsonGenerator cannot be null for writeJson.\"",
")",
";",
"JsonToken",
"curToken",
"=",
"parser",
".",
"nextToken",
"(",
")",
";",
"while",
"(",
"curToken",
"!=",
"null",
")",
"{",
"curToken",
"=",
"processToken",
"(",
"curToken",
",",
"parser",
",",
"jgen",
")",
";",
"}",
"jgen",
".",
"flush",
"(",
")",
";",
"}"
] | Writes the json from the parser onto the generator, using the filters to only write the objects
specified.
@param parser JsonParser that is created from a Jackson utility (i.e. ObjectMapper)
@param jgen JsonGenerator that is used for writing json onto an underlying stream
@throws JsonGenerationException exception if Jackson throws an error while iterating through
the JsonParser
@throws IOException if en error occurs while Jackson is parsing or writing json | [
"Writes",
"the",
"json",
"from",
"the",
"parser",
"onto",
"the",
"generator",
"using",
"the",
"filters",
"to",
"only",
"write",
"the",
"objects",
"specified",
"."
] | train | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jackson/src/main/java/com/cerner/beadledom/jackson/filter/FieldFilter.java#L145-L153 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java | SerializedFormBuilder.buildFieldSerializationOverview | public void buildFieldSerializationOverview(TypeElement typeElement, Content classContentTree) {
if (utils.definesSerializableFields(typeElement)) {
VariableElement ve = utils.serializableFields(typeElement).first();
// Check to see if there are inline comments, tags or deprecation
// information to be printed.
if (fieldWriter.shouldPrintOverview(ve)) {
Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true);
fieldWriter.addMemberDeprecatedInfo(ve, fieldsOverviewContentTree);
if (!configuration.nocomment) {
fieldWriter.addMemberDescription(ve, fieldsOverviewContentTree);
fieldWriter.addMemberTags(ve, fieldsOverviewContentTree);
}
serializableFieldsTree.addContent(fieldsOverviewContentTree);
classContentTree.addContent(fieldWriter.getSerializableFields(
configuration.getText("doclet.Serialized_Form_class"),
serializableFieldsTree));
}
}
} | java | public void buildFieldSerializationOverview(TypeElement typeElement, Content classContentTree) {
if (utils.definesSerializableFields(typeElement)) {
VariableElement ve = utils.serializableFields(typeElement).first();
// Check to see if there are inline comments, tags or deprecation
// information to be printed.
if (fieldWriter.shouldPrintOverview(ve)) {
Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true);
fieldWriter.addMemberDeprecatedInfo(ve, fieldsOverviewContentTree);
if (!configuration.nocomment) {
fieldWriter.addMemberDescription(ve, fieldsOverviewContentTree);
fieldWriter.addMemberTags(ve, fieldsOverviewContentTree);
}
serializableFieldsTree.addContent(fieldsOverviewContentTree);
classContentTree.addContent(fieldWriter.getSerializableFields(
configuration.getText("doclet.Serialized_Form_class"),
serializableFieldsTree));
}
}
} | [
"public",
"void",
"buildFieldSerializationOverview",
"(",
"TypeElement",
"typeElement",
",",
"Content",
"classContentTree",
")",
"{",
"if",
"(",
"utils",
".",
"definesSerializableFields",
"(",
"typeElement",
")",
")",
"{",
"VariableElement",
"ve",
"=",
"utils",
".",
"serializableFields",
"(",
"typeElement",
")",
".",
"first",
"(",
")",
";",
"// Check to see if there are inline comments, tags or deprecation",
"// information to be printed.",
"if",
"(",
"fieldWriter",
".",
"shouldPrintOverview",
"(",
"ve",
")",
")",
"{",
"Content",
"serializableFieldsTree",
"=",
"fieldWriter",
".",
"getSerializableFieldsHeader",
"(",
")",
";",
"Content",
"fieldsOverviewContentTree",
"=",
"fieldWriter",
".",
"getFieldsContentHeader",
"(",
"true",
")",
";",
"fieldWriter",
".",
"addMemberDeprecatedInfo",
"(",
"ve",
",",
"fieldsOverviewContentTree",
")",
";",
"if",
"(",
"!",
"configuration",
".",
"nocomment",
")",
"{",
"fieldWriter",
".",
"addMemberDescription",
"(",
"ve",
",",
"fieldsOverviewContentTree",
")",
";",
"fieldWriter",
".",
"addMemberTags",
"(",
"ve",
",",
"fieldsOverviewContentTree",
")",
";",
"}",
"serializableFieldsTree",
".",
"addContent",
"(",
"fieldsOverviewContentTree",
")",
";",
"classContentTree",
".",
"addContent",
"(",
"fieldWriter",
".",
"getSerializableFields",
"(",
"configuration",
".",
"getText",
"(",
"\"doclet.Serialized_Form_class\"",
")",
",",
"serializableFieldsTree",
")",
")",
";",
"}",
"}",
"}"
] | Build the serialization overview for the given class.
@param typeElement the class to print the overview for.
@param classContentTree content tree to which the documentation will be added | [
"Build",
"the",
"serialization",
"overview",
"for",
"the",
"given",
"class",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java#L398-L417 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/util/CellPosition.java | CellPosition.of | public static CellPosition of(final Point point) {
ArgUtils.notNull(point, "point");
return of(point.y, point.x);
} | java | public static CellPosition of(final Point point) {
ArgUtils.notNull(point, "point");
return of(point.y, point.x);
} | [
"public",
"static",
"CellPosition",
"of",
"(",
"final",
"Point",
"point",
")",
"{",
"ArgUtils",
".",
"notNull",
"(",
"point",
",",
"\"point\"",
")",
";",
"return",
"of",
"(",
"point",
".",
"y",
",",
"point",
".",
"x",
")",
";",
"}"
] | CellAddressのインスタンスを作成する。
@param point セルの座標
@return {@link CellPosition}のインスタンス
@throws IllegalArgumentException {@literal point == null.} | [
"CellAddressのインスタンスを作成する。"
] | train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/util/CellPosition.java#L134-L137 |
JRebirth/JRebirth | org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ObjectUtility.java | ObjectUtility.checkAllMethodReturnTrue | public static boolean checkAllMethodReturnTrue(final Object instance, final List<Method> methods) {
boolean res = true;
if (!methods.isEmpty()) {
for (final Method method : methods) {
Object returnValue;
try {
returnValue = method.invoke(instance);
res &= returnValue instanceof Boolean && ((Boolean) returnValue).booleanValue();
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
res = false;
}
}
}
return res;
} | java | public static boolean checkAllMethodReturnTrue(final Object instance, final List<Method> methods) {
boolean res = true;
if (!methods.isEmpty()) {
for (final Method method : methods) {
Object returnValue;
try {
returnValue = method.invoke(instance);
res &= returnValue instanceof Boolean && ((Boolean) returnValue).booleanValue();
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
res = false;
}
}
}
return res;
} | [
"public",
"static",
"boolean",
"checkAllMethodReturnTrue",
"(",
"final",
"Object",
"instance",
",",
"final",
"List",
"<",
"Method",
">",
"methods",
")",
"{",
"boolean",
"res",
"=",
"true",
";",
"if",
"(",
"!",
"methods",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"final",
"Method",
"method",
":",
"methods",
")",
"{",
"Object",
"returnValue",
";",
"try",
"{",
"returnValue",
"=",
"method",
".",
"invoke",
"(",
"instance",
")",
";",
"res",
"&=",
"returnValue",
"instanceof",
"Boolean",
"&&",
"(",
"(",
"Boolean",
")",
"returnValue",
")",
".",
"booleanValue",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"IllegalArgumentException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"res",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"res",
";",
"}"
] | Check if all given methods return true or if the list is empty.
@param instance the context object
@param methods the list of method to check
@return true if all method return true or if the list is empty | [
"Check",
"if",
"all",
"given",
"methods",
"return",
"true",
"or",
"if",
"the",
"list",
"is",
"empty",
"."
] | train | https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/util/ObjectUtility.java#L95-L110 |
i-net-software/jlessc | src/com/inet/lib/less/ColorUtils.java | ColorUtils.rgb | static double rgb( int r, int g, int b ) {
return Double.longBitsToDouble( Expression.ALPHA_1 | (colorLargeDigit(r) << 32) | (colorLargeDigit(g) << 16) | colorLargeDigit(b) );
} | java | static double rgb( int r, int g, int b ) {
return Double.longBitsToDouble( Expression.ALPHA_1 | (colorLargeDigit(r) << 32) | (colorLargeDigit(g) << 16) | colorLargeDigit(b) );
} | [
"static",
"double",
"rgb",
"(",
"int",
"r",
",",
"int",
"g",
",",
"int",
"b",
")",
"{",
"return",
"Double",
".",
"longBitsToDouble",
"(",
"Expression",
".",
"ALPHA_1",
"|",
"(",
"colorLargeDigit",
"(",
"r",
")",
"<<",
"32",
")",
"|",
"(",
"colorLargeDigit",
"(",
"g",
")",
"<<",
"16",
")",
"|",
"colorLargeDigit",
"(",
"b",
")",
")",
";",
"}"
] | Create an color value.
@param r
red in range from 0 to 255
@param g
green in range from 0 to 255
@param b
blue in range from 0 to 255
@return color value as long | [
"Create",
"an",
"color",
"value",
"."
] | train | https://github.com/i-net-software/jlessc/blob/15b13e1637f6cc2e4d72df021e23ee0ca8d5e629/src/com/inet/lib/less/ColorUtils.java#L130-L132 |
derari/cthul | objects/src/main/java/org/cthul/objects/reflection/Signatures.java | Signatures.bestMatch | public static int bestMatch(Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) throws AmbiguousSignatureMatchException {
return bestMatch(signatures, varArgs, new JavaSignatureComparator(argTypes));
} | java | public static int bestMatch(Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) throws AmbiguousSignatureMatchException {
return bestMatch(signatures, varArgs, new JavaSignatureComparator(argTypes));
} | [
"public",
"static",
"int",
"bestMatch",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
"[",
"]",
"signatures",
",",
"boolean",
"[",
"]",
"varArgs",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"argTypes",
")",
"throws",
"AmbiguousSignatureMatchException",
"{",
"return",
"bestMatch",
"(",
"signatures",
",",
"varArgs",
",",
"new",
"JavaSignatureComparator",
"(",
"argTypes",
")",
")",
";",
"}"
] | Selects the best match in signatures for the given argument types.
@param signatures
@param varArgs
@param argTypes
@return index of best signature, -1 if nothing matched
@throws AmbiguousSignatureMatchException if two signatures matched equally | [
"Selects",
"the",
"best",
"match",
"in",
"signatures",
"for",
"the",
"given",
"argument",
"types",
"."
] | train | https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L421-L423 |
code4everything/util | src/main/java/com/zhazhapan/util/Checker.java | Checker.check | public static <T> T check(T value, T elseValue, boolean res) {
return res ? value : elseValue;
} | java | public static <T> T check(T value, T elseValue, boolean res) {
return res ? value : elseValue;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"check",
"(",
"T",
"value",
",",
"T",
"elseValue",
",",
"boolean",
"res",
")",
"{",
"return",
"res",
"?",
"value",
":",
"elseValue",
";",
"}"
] | 自定义检查
@param value res为true返回的值
@param elseValue res为false返回的值
@param res {@link Boolean}
@param <T> 值类型
@return 结果
@since 1.0.8 | [
"自定义检查"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/Checker.java#L1420-L1422 |
liferay/com-liferay-commerce | commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountRelPersistenceImpl.java | CommerceDiscountRelPersistenceImpl.removeByCD_CN | @Override
public void removeByCD_CN(long commerceDiscountId, long classNameId) {
for (CommerceDiscountRel commerceDiscountRel : findByCD_CN(
commerceDiscountId, classNameId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(commerceDiscountRel);
}
} | java | @Override
public void removeByCD_CN(long commerceDiscountId, long classNameId) {
for (CommerceDiscountRel commerceDiscountRel : findByCD_CN(
commerceDiscountId, classNameId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(commerceDiscountRel);
}
} | [
"@",
"Override",
"public",
"void",
"removeByCD_CN",
"(",
"long",
"commerceDiscountId",
",",
"long",
"classNameId",
")",
"{",
"for",
"(",
"CommerceDiscountRel",
"commerceDiscountRel",
":",
"findByCD_CN",
"(",
"commerceDiscountId",
",",
"classNameId",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
")",
"{",
"remove",
"(",
"commerceDiscountRel",
")",
";",
"}",
"}"
] | Removes all the commerce discount rels where commerceDiscountId = ? and classNameId = ? from the database.
@param commerceDiscountId the commerce discount ID
@param classNameId the class name ID | [
"Removes",
"all",
"the",
"commerce",
"discount",
"rels",
"where",
"commerceDiscountId",
"=",
"?",
";",
"and",
"classNameId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountRelPersistenceImpl.java#L1108-L1115 |
EMCECS/nfs-client-java | src/main/java/com/emc/ecs/nfsclient/rpc/RpcWrapper.java | RpcWrapper.callRpcNaked | public void callRpcNaked(S request, T response, String ipAddress) throws RpcException {
Xdr xdr = new Xdr(_maximumRequestSize);
request.marshalling(xdr);
response.unmarshalling(callRpc(ipAddress, xdr, request.isUsePrivilegedPort()));
} | java | public void callRpcNaked(S request, T response, String ipAddress) throws RpcException {
Xdr xdr = new Xdr(_maximumRequestSize);
request.marshalling(xdr);
response.unmarshalling(callRpc(ipAddress, xdr, request.isUsePrivilegedPort()));
} | [
"public",
"void",
"callRpcNaked",
"(",
"S",
"request",
",",
"T",
"response",
",",
"String",
"ipAddress",
")",
"throws",
"RpcException",
"{",
"Xdr",
"xdr",
"=",
"new",
"Xdr",
"(",
"_maximumRequestSize",
")",
";",
"request",
".",
"marshalling",
"(",
"xdr",
")",
";",
"response",
".",
"unmarshalling",
"(",
"callRpc",
"(",
"ipAddress",
",",
"xdr",
",",
"request",
".",
"isUsePrivilegedPort",
"(",
")",
")",
")",
";",
"}"
] | Make the call to a specified IP address.
@param request
The request to send.
@param response
A response to hold the returned data.
@param ipAddress
The IP address to use for communication.
@throws RpcException | [
"Make",
"the",
"call",
"to",
"a",
"specified",
"IP",
"address",
"."
] | train | https://github.com/EMCECS/nfs-client-java/blob/7ba25bad5052b95cd286052745327729288b2843/src/main/java/com/emc/ecs/nfsclient/rpc/RpcWrapper.java#L204-L208 |
jtablesaw/tablesaw | core/src/main/java/tech/tablesaw/aggregate/CrossTab.java | CrossTab.tablePercents | public static Table tablePercents(Table table, CategoricalColumn<?> column1, CategoricalColumn<?> column2) {
Table xTabs = counts(table, column1, column2);
return tablePercents(xTabs);
} | java | public static Table tablePercents(Table table, CategoricalColumn<?> column1, CategoricalColumn<?> column2) {
Table xTabs = counts(table, column1, column2);
return tablePercents(xTabs);
} | [
"public",
"static",
"Table",
"tablePercents",
"(",
"Table",
"table",
",",
"CategoricalColumn",
"<",
"?",
">",
"column1",
",",
"CategoricalColumn",
"<",
"?",
">",
"column2",
")",
"{",
"Table",
"xTabs",
"=",
"counts",
"(",
"table",
",",
"column1",
",",
"column2",
")",
";",
"return",
"tablePercents",
"(",
"xTabs",
")",
";",
"}"
] | Returns a table containing the table percents made from a source table, after first calculating the counts
cross-tabulated from the given columns | [
"Returns",
"a",
"table",
"containing",
"the",
"table",
"percents",
"made",
"from",
"a",
"source",
"table",
"after",
"first",
"calculating",
"the",
"counts",
"cross",
"-",
"tabulated",
"from",
"the",
"given",
"columns"
] | train | https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/aggregate/CrossTab.java#L278-L281 |
jmeetsma/Iglu-Util | src/main/java/org/ijsberg/iglu/util/io/FileSupport.java | FileSupport.getFilesInDirectoryTree | public static ArrayList<File> getFilesInDirectoryTree(File file, String includeMask) {
return getContentsInDirectoryTree(file, includeMask, true, false);
} | java | public static ArrayList<File> getFilesInDirectoryTree(File file, String includeMask) {
return getContentsInDirectoryTree(file, includeMask, true, false);
} | [
"public",
"static",
"ArrayList",
"<",
"File",
">",
"getFilesInDirectoryTree",
"(",
"File",
"file",
",",
"String",
"includeMask",
")",
"{",
"return",
"getContentsInDirectoryTree",
"(",
"file",
",",
"includeMask",
",",
"true",
",",
"false",
")",
";",
"}"
] | Retrieves all files from a directory and its subdirectories
matching the given mask.
@param file directory
@param includeMask mask to match
@return a list containing the found files | [
"Retrieves",
"all",
"files",
"from",
"a",
"directory",
"and",
"its",
"subdirectories",
"matching",
"the",
"given",
"mask",
"."
] | train | https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/io/FileSupport.java#L113-L115 |
elki-project/elki | elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/query/knn/LinearScanEuclideanDistanceKNNQuery.java | LinearScanEuclideanDistanceKNNQuery.linearScan | private KNNHeap linearScan(Relation<? extends O> relation, DBIDIter iter, final O obj, KNNHeap heap) {
final SquaredEuclideanDistanceFunction squared = SquaredEuclideanDistanceFunction.STATIC;
double max = Double.POSITIVE_INFINITY;
while(iter.valid()) {
final double dist = squared.distance(obj, relation.get(iter));
if(dist <= max) {
max = heap.insert(dist, iter);
}
iter.advance();
}
return heap;
} | java | private KNNHeap linearScan(Relation<? extends O> relation, DBIDIter iter, final O obj, KNNHeap heap) {
final SquaredEuclideanDistanceFunction squared = SquaredEuclideanDistanceFunction.STATIC;
double max = Double.POSITIVE_INFINITY;
while(iter.valid()) {
final double dist = squared.distance(obj, relation.get(iter));
if(dist <= max) {
max = heap.insert(dist, iter);
}
iter.advance();
}
return heap;
} | [
"private",
"KNNHeap",
"linearScan",
"(",
"Relation",
"<",
"?",
"extends",
"O",
">",
"relation",
",",
"DBIDIter",
"iter",
",",
"final",
"O",
"obj",
",",
"KNNHeap",
"heap",
")",
"{",
"final",
"SquaredEuclideanDistanceFunction",
"squared",
"=",
"SquaredEuclideanDistanceFunction",
".",
"STATIC",
";",
"double",
"max",
"=",
"Double",
".",
"POSITIVE_INFINITY",
";",
"while",
"(",
"iter",
".",
"valid",
"(",
")",
")",
"{",
"final",
"double",
"dist",
"=",
"squared",
".",
"distance",
"(",
"obj",
",",
"relation",
".",
"get",
"(",
"iter",
")",
")",
";",
"if",
"(",
"dist",
"<=",
"max",
")",
"{",
"max",
"=",
"heap",
".",
"insert",
"(",
"dist",
",",
"iter",
")",
";",
"}",
"iter",
".",
"advance",
"(",
")",
";",
"}",
"return",
"heap",
";",
"}"
] | Main loop of the linear scan.
@param relation Data relation
@param iter ID iterator
@param obj Query object
@param heap Output heap
@return Heap | [
"Main",
"loop",
"of",
"the",
"linear",
"scan",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/query/knn/LinearScanEuclideanDistanceKNNQuery.java#L84-L95 |
aws/aws-sdk-java | aws-java-sdk-ssm/src/main/java/com/amazonaws/services/simplesystemsmanagement/model/InventoryResultEntity.java | InventoryResultEntity.withData | public InventoryResultEntity withData(java.util.Map<String, InventoryResultItem> data) {
setData(data);
return this;
} | java | public InventoryResultEntity withData(java.util.Map<String, InventoryResultItem> data) {
setData(data);
return this;
} | [
"public",
"InventoryResultEntity",
"withData",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"InventoryResultItem",
">",
"data",
")",
"{",
"setData",
"(",
"data",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The data section in the inventory result entity JSON.
</p>
@param data
The data section in the inventory result entity JSON.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"data",
"section",
"in",
"the",
"inventory",
"result",
"entity",
"JSON",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-ssm/src/main/java/com/amazonaws/services/simplesystemsmanagement/model/InventoryResultEntity.java#L126-L129 |
JM-Lab/utils-elasticsearch | src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchIndex.java | JMElasticsearchIndex.sendDataAsync | public ActionFuture<IndexResponse> sendDataAsync(
String jsonSource, String index, String type, String id) {
return indexQueryAsync(buildIndexRequest(jsonSource, index, type, id));
} | java | public ActionFuture<IndexResponse> sendDataAsync(
String jsonSource, String index, String type, String id) {
return indexQueryAsync(buildIndexRequest(jsonSource, index, type, id));
} | [
"public",
"ActionFuture",
"<",
"IndexResponse",
">",
"sendDataAsync",
"(",
"String",
"jsonSource",
",",
"String",
"index",
",",
"String",
"type",
",",
"String",
"id",
")",
"{",
"return",
"indexQueryAsync",
"(",
"buildIndexRequest",
"(",
"jsonSource",
",",
"index",
",",
"type",
",",
"id",
")",
")",
";",
"}"
] | Send data async action future.
@param jsonSource the json source
@param index the index
@param type the type
@param id the id
@return the action future | [
"Send",
"data",
"async",
"action",
"future",
"."
] | train | https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchIndex.java#L318-L321 |
m-m-m/util | value/src/main/java/net/sf/mmm/util/value/impl/DefaultComposedValueConverter.java | DefaultComposedValueConverter.addConverterComponent | public void addConverterComponent(ValueConverter<?, ?> converter) {
if (converter instanceof AbstractRecursiveValueConverter) {
((AbstractRecursiveValueConverter<?, ?>) converter).setComposedValueConverter(this);
}
if (converter instanceof AbstractComponent) {
((AbstractComponent) converter).initialize();
}
addConverter(converter);
} | java | public void addConverterComponent(ValueConverter<?, ?> converter) {
if (converter instanceof AbstractRecursiveValueConverter) {
((AbstractRecursiveValueConverter<?, ?>) converter).setComposedValueConverter(this);
}
if (converter instanceof AbstractComponent) {
((AbstractComponent) converter).initialize();
}
addConverter(converter);
} | [
"public",
"void",
"addConverterComponent",
"(",
"ValueConverter",
"<",
"?",
",",
"?",
">",
"converter",
")",
"{",
"if",
"(",
"converter",
"instanceof",
"AbstractRecursiveValueConverter",
")",
"{",
"(",
"(",
"AbstractRecursiveValueConverter",
"<",
"?",
",",
"?",
">",
")",
"converter",
")",
".",
"setComposedValueConverter",
"(",
"this",
")",
";",
"}",
"if",
"(",
"converter",
"instanceof",
"AbstractComponent",
")",
"{",
"(",
"(",
"AbstractComponent",
")",
"converter",
")",
".",
"initialize",
"(",
")",
";",
"}",
"addConverter",
"(",
"converter",
")",
";",
"}"
] | @see #addConverter(ValueConverter)
@param converter is the converter to add. | [
"@see",
"#addConverter",
"(",
"ValueConverter",
")"
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/value/src/main/java/net/sf/mmm/util/value/impl/DefaultComposedValueConverter.java#L58-L67 |
http-builder-ng/http-builder-ng | http-builder-ng-core/src/main/java/groovyx/net/http/optional/Csv.java | Csv.toCsv | public static void toCsv(final HttpConfig delegate, final String contentType, final Character separator, final Character quote) {
delegate.context(contentType, Context.ID, new Context(separator, quote));
delegate.getRequest().encoder(contentType, Csv::encode);
delegate.getResponse().parser(contentType, Csv::parse);
} | java | public static void toCsv(final HttpConfig delegate, final String contentType, final Character separator, final Character quote) {
delegate.context(contentType, Context.ID, new Context(separator, quote));
delegate.getRequest().encoder(contentType, Csv::encode);
delegate.getResponse().parser(contentType, Csv::parse);
} | [
"public",
"static",
"void",
"toCsv",
"(",
"final",
"HttpConfig",
"delegate",
",",
"final",
"String",
"contentType",
",",
"final",
"Character",
"separator",
",",
"final",
"Character",
"quote",
")",
"{",
"delegate",
".",
"context",
"(",
"contentType",
",",
"Context",
".",
"ID",
",",
"new",
"Context",
"(",
"separator",
",",
"quote",
")",
")",
";",
"delegate",
".",
"getRequest",
"(",
")",
".",
"encoder",
"(",
"contentType",
",",
"Csv",
"::",
"encode",
")",
";",
"delegate",
".",
"getResponse",
"(",
")",
".",
"parser",
"(",
"contentType",
",",
"Csv",
"::",
"parse",
")",
";",
"}"
] | Used to configure the OpenCsv encoder/parser in the configuration context for the specified content type.
@param delegate the configuration object
@param contentType the content type to be registered
@param separator the CSV column separator character
@param quote the CSV quote character | [
"Used",
"to",
"configure",
"the",
"OpenCsv",
"encoder",
"/",
"parser",
"in",
"the",
"configuration",
"context",
"for",
"the",
"specified",
"content",
"type",
"."
] | train | https://github.com/http-builder-ng/http-builder-ng/blob/865f37732c102c748d3db8b905199dac9222a525/http-builder-ng-core/src/main/java/groovyx/net/http/optional/Csv.java#L142-L146 |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/DateUtil.java | DateUtil.getLastNDay | public static Date getLastNDay(Date d, int n, int unitType) {
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(unitType, -n);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
} | java | public static Date getLastNDay(Date d, int n, int unitType) {
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(unitType, -n);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
} | [
"public",
"static",
"Date",
"getLastNDay",
"(",
"Date",
"d",
",",
"int",
"n",
",",
"int",
"unitType",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"d",
")",
";",
"cal",
".",
"add",
"(",
"unitType",
",",
"-",
"n",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"0",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MINUTE",
",",
"0",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"SECOND",
",",
"0",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"MILLISECOND",
",",
"0",
")",
";",
"return",
"cal",
".",
"getTime",
"(",
")",
";",
"}"
] | Get date with n unitType before
@param d date
@param n number of units
@param unitType unit type : one of Calendar.DAY_OF_YEAR, Calendar.WEEK_OF_YEAR, Calendar.MONTH, Calendar.YEAR;
@return | [
"Get",
"date",
"with",
"n",
"unitType",
"before"
] | train | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/DateUtil.java#L755-L764 |
datacleaner/DataCleaner | engine/env/spark/src/main/java/org/datacleaner/spark/utils/HadoopUtils.java | HadoopUtils.getDirectoryIfExists | private static File getDirectoryIfExists(final File existingCandidate, final String path) {
if (existingCandidate != null) {
return existingCandidate;
}
if (!Strings.isNullOrEmpty(path)) {
final File directory = new File(path);
if (directory.exists() && directory.isDirectory()) {
return directory;
}
}
return null;
} | java | private static File getDirectoryIfExists(final File existingCandidate, final String path) {
if (existingCandidate != null) {
return existingCandidate;
}
if (!Strings.isNullOrEmpty(path)) {
final File directory = new File(path);
if (directory.exists() && directory.isDirectory()) {
return directory;
}
}
return null;
} | [
"private",
"static",
"File",
"getDirectoryIfExists",
"(",
"final",
"File",
"existingCandidate",
",",
"final",
"String",
"path",
")",
"{",
"if",
"(",
"existingCandidate",
"!=",
"null",
")",
"{",
"return",
"existingCandidate",
";",
"}",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"path",
")",
")",
"{",
"final",
"File",
"directory",
"=",
"new",
"File",
"(",
"path",
")",
";",
"if",
"(",
"directory",
".",
"exists",
"(",
")",
"&&",
"directory",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"directory",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Gets a candidate directory based on a file path, if it exists, and if it
another candidate hasn't already been resolved.
@param existingCandidate
an existing candidate directory. If this is non-null, it will
be returned immediately.
@param path
the path of a directory
@return a candidate directory, or null if none was resolved. | [
"Gets",
"a",
"candidate",
"directory",
"based",
"on",
"a",
"file",
"path",
"if",
"it",
"exists",
"and",
"if",
"it",
"another",
"candidate",
"hasn",
"t",
"already",
"been",
"resolved",
"."
] | train | https://github.com/datacleaner/DataCleaner/blob/9aa01fdac3560cef51c55df3cb2ac5c690b57639/engine/env/spark/src/main/java/org/datacleaner/spark/utils/HadoopUtils.java#L53-L64 |
Baidu-AIP/java-sdk | src/main/java/com/baidu/aip/imagesearch/AipImageSearch.java | AipImageSearch.sameHqUpdateContSign | public JSONObject sameHqUpdateContSign(String contSign, HashMap<String, String> options) {
AipRequest request = new AipRequest();
preOperation(request);
request.addBody("cont_sign", contSign);
if (options != null) {
request.addBody(options);
}
request.setUri(ImageSearchConsts.SAME_HQ_UPDATE);
postOperation(request);
return requestServer(request);
} | java | public JSONObject sameHqUpdateContSign(String contSign, HashMap<String, String> options) {
AipRequest request = new AipRequest();
preOperation(request);
request.addBody("cont_sign", contSign);
if (options != null) {
request.addBody(options);
}
request.setUri(ImageSearchConsts.SAME_HQ_UPDATE);
postOperation(request);
return requestServer(request);
} | [
"public",
"JSONObject",
"sameHqUpdateContSign",
"(",
"String",
"contSign",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"options",
")",
"{",
"AipRequest",
"request",
"=",
"new",
"AipRequest",
"(",
")",
";",
"preOperation",
"(",
"request",
")",
";",
"request",
".",
"addBody",
"(",
"\"cont_sign\"",
",",
"contSign",
")",
";",
"if",
"(",
"options",
"!=",
"null",
")",
"{",
"request",
".",
"addBody",
"(",
"options",
")",
";",
"}",
"request",
".",
"setUri",
"(",
"ImageSearchConsts",
".",
"SAME_HQ_UPDATE",
")",
";",
"postOperation",
"(",
"request",
")",
";",
"return",
"requestServer",
"(",
"request",
")",
";",
"}"
] | 相同图检索—更新接口
**更新图库中图片的摘要和分类信息(具体变量为brief、tags)**
@param contSign - 图片签名
@param options - 可选参数对象,key: value都为string类型
options - options列表:
brief 更新的摘要信息,最长256B。样例:{"name":"周杰伦", "id":"666"}
tags 1 - 65535范围内的整数,tag间以逗号分隔,最多2个tag。样例:"100,11" ;检索时可圈定分类维度进行检索
@return JSONObject | [
"相同图检索—更新接口",
"**",
"更新图库中图片的摘要和分类信息(具体变量为brief、tags)",
"**"
] | train | https://github.com/Baidu-AIP/java-sdk/blob/16bb8b7bb8f9bbcb7c8af62d0a67a1e79eecad90/src/main/java/com/baidu/aip/imagesearch/AipImageSearch.java#L259-L270 |
tvesalainen/lpg | src/main/java/org/vesalainen/parser/util/CharInput.java | CharInput.getString | @Override
public String getString(long start, int length)
{
if (length == 0)
{
return "";
}
if (array != null)
{
int ps = (int) (start % size);
int es = (int) ((start+length) % size);
if (ps < es)
{
return new String(array, ps, length);
}
else
{
StringBuilder sb = new StringBuilder();
sb.append(array, ps, size-ps);
sb.append(array, 0, es);
return sb.toString();
}
}
else
{
StringBuilder sb = new StringBuilder();
for (int ii=0;ii<length;ii++)
{
sb.append((char)get(start+ii));
}
return sb.toString();
}
} | java | @Override
public String getString(long start, int length)
{
if (length == 0)
{
return "";
}
if (array != null)
{
int ps = (int) (start % size);
int es = (int) ((start+length) % size);
if (ps < es)
{
return new String(array, ps, length);
}
else
{
StringBuilder sb = new StringBuilder();
sb.append(array, ps, size-ps);
sb.append(array, 0, es);
return sb.toString();
}
}
else
{
StringBuilder sb = new StringBuilder();
for (int ii=0;ii<length;ii++)
{
sb.append((char)get(start+ii));
}
return sb.toString();
}
} | [
"@",
"Override",
"public",
"String",
"getString",
"(",
"long",
"start",
",",
"int",
"length",
")",
"{",
"if",
"(",
"length",
"==",
"0",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"array",
"!=",
"null",
")",
"{",
"int",
"ps",
"=",
"(",
"int",
")",
"(",
"start",
"%",
"size",
")",
";",
"int",
"es",
"=",
"(",
"int",
")",
"(",
"(",
"start",
"+",
"length",
")",
"%",
"size",
")",
";",
"if",
"(",
"ps",
"<",
"es",
")",
"{",
"return",
"new",
"String",
"(",
"array",
",",
"ps",
",",
"length",
")",
";",
"}",
"else",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"array",
",",
"ps",
",",
"size",
"-",
"ps",
")",
";",
"sb",
".",
"append",
"(",
"array",
",",
"0",
",",
"es",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"}",
"else",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"length",
";",
"ii",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"(",
"char",
")",
"get",
"(",
"start",
"+",
"ii",
")",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"}"
] | Returns string from buffer
@param start Start of input
@param length Length of input
@return | [
"Returns",
"string",
"from",
"buffer"
] | train | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/parser/util/CharInput.java#L154-L186 |
Azure/azure-sdk-for-java | kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/DatabasesInner.java | DatabasesInner.listPrincipalsAsync | public Observable<List<DatabasePrincipalInner>> listPrincipalsAsync(String resourceGroupName, String clusterName, String databaseName) {
return listPrincipalsWithServiceResponseAsync(resourceGroupName, clusterName, databaseName).map(new Func1<ServiceResponse<List<DatabasePrincipalInner>>, List<DatabasePrincipalInner>>() {
@Override
public List<DatabasePrincipalInner> call(ServiceResponse<List<DatabasePrincipalInner>> response) {
return response.body();
}
});
} | java | public Observable<List<DatabasePrincipalInner>> listPrincipalsAsync(String resourceGroupName, String clusterName, String databaseName) {
return listPrincipalsWithServiceResponseAsync(resourceGroupName, clusterName, databaseName).map(new Func1<ServiceResponse<List<DatabasePrincipalInner>>, List<DatabasePrincipalInner>>() {
@Override
public List<DatabasePrincipalInner> call(ServiceResponse<List<DatabasePrincipalInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"DatabasePrincipalInner",
">",
">",
"listPrincipalsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
",",
"String",
"databaseName",
")",
"{",
"return",
"listPrincipalsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
",",
"databaseName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"DatabasePrincipalInner",
">",
">",
",",
"List",
"<",
"DatabasePrincipalInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"DatabasePrincipalInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"DatabasePrincipalInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Returns a list of database principals of the given Kusto cluster and database.
@param resourceGroupName The name of the resource group containing the Kusto cluster.
@param clusterName The name of the Kusto cluster.
@param databaseName The name of the database in the Kusto cluster.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<DatabasePrincipalInner> object | [
"Returns",
"a",
"list",
"of",
"database",
"principals",
"of",
"the",
"given",
"Kusto",
"cluster",
"and",
"database",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/DatabasesInner.java#L974-L981 |
ahome-it/lienzo-core | src/main/java/com/ait/lienzo/client/core/util/Matrix.java | Matrix.times | public Matrix times(final Matrix B)
{
final Matrix A = this;
if (A.m_columns != B.m_rows)
{
throw new GeometryException("Illegal matrix dimensions");
}
final Matrix C = new Matrix(A.m_rows, B.m_columns);
for (int i = 0; i < C.m_rows; i++)
{
for (int j = 0; j < C.m_columns; j++)
{
for (int k = 0; k < A.m_columns; k++)
{
C.m_data[i][j] += (A.m_data[i][k] * B.m_data[k][j]);
}
}
}
return C;
} | java | public Matrix times(final Matrix B)
{
final Matrix A = this;
if (A.m_columns != B.m_rows)
{
throw new GeometryException("Illegal matrix dimensions");
}
final Matrix C = new Matrix(A.m_rows, B.m_columns);
for (int i = 0; i < C.m_rows; i++)
{
for (int j = 0; j < C.m_columns; j++)
{
for (int k = 0; k < A.m_columns; k++)
{
C.m_data[i][j] += (A.m_data[i][k] * B.m_data[k][j]);
}
}
}
return C;
} | [
"public",
"Matrix",
"times",
"(",
"final",
"Matrix",
"B",
")",
"{",
"final",
"Matrix",
"A",
"=",
"this",
";",
"if",
"(",
"A",
".",
"m_columns",
"!=",
"B",
".",
"m_rows",
")",
"{",
"throw",
"new",
"GeometryException",
"(",
"\"Illegal matrix dimensions\"",
")",
";",
"}",
"final",
"Matrix",
"C",
"=",
"new",
"Matrix",
"(",
"A",
".",
"m_rows",
",",
"B",
".",
"m_columns",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"C",
".",
"m_rows",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"C",
".",
"m_columns",
";",
"j",
"++",
")",
"{",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"A",
".",
"m_columns",
";",
"k",
"++",
")",
"{",
"C",
".",
"m_data",
"[",
"i",
"]",
"[",
"j",
"]",
"+=",
"(",
"A",
".",
"m_data",
"[",
"i",
"]",
"[",
"k",
"]",
"*",
"B",
".",
"m_data",
"[",
"k",
"]",
"[",
"j",
"]",
")",
";",
"}",
"}",
"}",
"return",
"C",
";",
"}"
] | Returns C = A * B
@param B
@return new Matrix C
@throws GeometryException if the matrix dimensions don't match | [
"Returns",
"C",
"=",
"A",
"*",
"B"
] | train | https://github.com/ahome-it/lienzo-core/blob/8e03723700dec366f77064d12fb8676d8cd6be99/src/main/java/com/ait/lienzo/client/core/util/Matrix.java#L217-L238 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java | EscapedFunctions2.sqllocate | public static void sqllocate(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
if (parsedArgs.size() == 2) {
appendCall(buf, "position(", " in ", ")", parsedArgs);
} else if (parsedArgs.size() == 3) {
String tmp = "position(" + parsedArgs.get(0) + " in substring(" + parsedArgs.get(1) + " from "
+ parsedArgs.get(2) + "))";
buf.append("(")
.append(parsedArgs.get(2))
.append("*sign(")
.append(tmp)
.append(")+")
.append(tmp)
.append(")");
} else {
throw new PSQLException(GT.tr("{0} function takes two or three arguments.", "locate"),
PSQLState.SYNTAX_ERROR);
}
} | java | public static void sqllocate(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
if (parsedArgs.size() == 2) {
appendCall(buf, "position(", " in ", ")", parsedArgs);
} else if (parsedArgs.size() == 3) {
String tmp = "position(" + parsedArgs.get(0) + " in substring(" + parsedArgs.get(1) + " from "
+ parsedArgs.get(2) + "))";
buf.append("(")
.append(parsedArgs.get(2))
.append("*sign(")
.append(tmp)
.append(")+")
.append(tmp)
.append(")");
} else {
throw new PSQLException(GT.tr("{0} function takes two or three arguments.", "locate"),
PSQLState.SYNTAX_ERROR);
}
} | [
"public",
"static",
"void",
"sqllocate",
"(",
"StringBuilder",
"buf",
",",
"List",
"<",
"?",
"extends",
"CharSequence",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"parsedArgs",
".",
"size",
"(",
")",
"==",
"2",
")",
"{",
"appendCall",
"(",
"buf",
",",
"\"position(\"",
",",
"\" in \"",
",",
"\")\"",
",",
"parsedArgs",
")",
";",
"}",
"else",
"if",
"(",
"parsedArgs",
".",
"size",
"(",
")",
"==",
"3",
")",
"{",
"String",
"tmp",
"=",
"\"position(\"",
"+",
"parsedArgs",
".",
"get",
"(",
"0",
")",
"+",
"\" in substring(\"",
"+",
"parsedArgs",
".",
"get",
"(",
"1",
")",
"+",
"\" from \"",
"+",
"parsedArgs",
".",
"get",
"(",
"2",
")",
"+",
"\"))\"",
";",
"buf",
".",
"append",
"(",
"\"(\"",
")",
".",
"append",
"(",
"parsedArgs",
".",
"get",
"(",
"2",
")",
")",
".",
"append",
"(",
"\"*sign(\"",
")",
".",
"append",
"(",
"tmp",
")",
".",
"append",
"(",
"\")+\"",
")",
".",
"append",
"(",
"tmp",
")",
".",
"append",
"(",
"\")\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PSQLException",
"(",
"GT",
".",
"tr",
"(",
"\"{0} function takes two or three arguments.\"",
",",
"\"locate\"",
")",
",",
"PSQLState",
".",
"SYNTAX_ERROR",
")",
";",
"}",
"}"
] | locate translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens | [
"locate",
"translation"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java#L224-L241 |
arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java | KuberntesServiceUrlResourceProvider.getPort | private static int getPort(Service service, Annotation... qualifiers) {
for (Annotation q : qualifiers) {
if (q instanceof Port) {
Port port = (Port) q;
if (port.value() > 0) {
return port.value();
}
}
}
ServicePort servicePort = findQualifiedServicePort(service, qualifiers);
if (servicePort != null) {
return servicePort.getPort();
}
return 0;
} | java | private static int getPort(Service service, Annotation... qualifiers) {
for (Annotation q : qualifiers) {
if (q instanceof Port) {
Port port = (Port) q;
if (port.value() > 0) {
return port.value();
}
}
}
ServicePort servicePort = findQualifiedServicePort(service, qualifiers);
if (servicePort != null) {
return servicePort.getPort();
}
return 0;
} | [
"private",
"static",
"int",
"getPort",
"(",
"Service",
"service",
",",
"Annotation",
"...",
"qualifiers",
")",
"{",
"for",
"(",
"Annotation",
"q",
":",
"qualifiers",
")",
"{",
"if",
"(",
"q",
"instanceof",
"Port",
")",
"{",
"Port",
"port",
"=",
"(",
"Port",
")",
"q",
";",
"if",
"(",
"port",
".",
"value",
"(",
")",
">",
"0",
")",
"{",
"return",
"port",
".",
"value",
"(",
")",
";",
"}",
"}",
"}",
"ServicePort",
"servicePort",
"=",
"findQualifiedServicePort",
"(",
"service",
",",
"qualifiers",
")",
";",
"if",
"(",
"servicePort",
"!=",
"null",
")",
"{",
"return",
"servicePort",
".",
"getPort",
"(",
")",
";",
"}",
"return",
"0",
";",
"}"
] | Find the the qualified container port of the target service
Uses java annotations first or returns the container port.
@param service
The target service.
@param qualifiers
The set of qualifiers.
@return Returns the resolved containerPort of '0' as a fallback. | [
"Find",
"the",
"the",
"qualified",
"container",
"port",
"of",
"the",
"target",
"service",
"Uses",
"java",
"annotations",
"first",
"or",
"returns",
"the",
"container",
"port",
"."
] | train | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java#L128-L143 |
netty/netty | codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyMessageDecoder.java | HAProxyMessageDecoder.decodeLine | private ByteBuf decodeLine(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception {
final int eol = findEndOfLine(buffer);
if (!discarding) {
if (eol >= 0) {
final int length = eol - buffer.readerIndex();
if (length > V1_MAX_LENGTH) {
buffer.readerIndex(eol + DELIMITER_LENGTH);
failOverLimit(ctx, length);
return null;
}
ByteBuf frame = buffer.readSlice(length);
buffer.skipBytes(DELIMITER_LENGTH);
return frame;
} else {
final int length = buffer.readableBytes();
if (length > V1_MAX_LENGTH) {
discardedBytes = length;
buffer.skipBytes(length);
discarding = true;
failOverLimit(ctx, "over " + discardedBytes);
}
return null;
}
} else {
if (eol >= 0) {
final int delimLength = buffer.getByte(eol) == '\r' ? 2 : 1;
buffer.readerIndex(eol + delimLength);
discardedBytes = 0;
discarding = false;
} else {
discardedBytes = buffer.readableBytes();
buffer.skipBytes(discardedBytes);
}
return null;
}
} | java | private ByteBuf decodeLine(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception {
final int eol = findEndOfLine(buffer);
if (!discarding) {
if (eol >= 0) {
final int length = eol - buffer.readerIndex();
if (length > V1_MAX_LENGTH) {
buffer.readerIndex(eol + DELIMITER_LENGTH);
failOverLimit(ctx, length);
return null;
}
ByteBuf frame = buffer.readSlice(length);
buffer.skipBytes(DELIMITER_LENGTH);
return frame;
} else {
final int length = buffer.readableBytes();
if (length > V1_MAX_LENGTH) {
discardedBytes = length;
buffer.skipBytes(length);
discarding = true;
failOverLimit(ctx, "over " + discardedBytes);
}
return null;
}
} else {
if (eol >= 0) {
final int delimLength = buffer.getByte(eol) == '\r' ? 2 : 1;
buffer.readerIndex(eol + delimLength);
discardedBytes = 0;
discarding = false;
} else {
discardedBytes = buffer.readableBytes();
buffer.skipBytes(discardedBytes);
}
return null;
}
} | [
"private",
"ByteBuf",
"decodeLine",
"(",
"ChannelHandlerContext",
"ctx",
",",
"ByteBuf",
"buffer",
")",
"throws",
"Exception",
"{",
"final",
"int",
"eol",
"=",
"findEndOfLine",
"(",
"buffer",
")",
";",
"if",
"(",
"!",
"discarding",
")",
"{",
"if",
"(",
"eol",
">=",
"0",
")",
"{",
"final",
"int",
"length",
"=",
"eol",
"-",
"buffer",
".",
"readerIndex",
"(",
")",
";",
"if",
"(",
"length",
">",
"V1_MAX_LENGTH",
")",
"{",
"buffer",
".",
"readerIndex",
"(",
"eol",
"+",
"DELIMITER_LENGTH",
")",
";",
"failOverLimit",
"(",
"ctx",
",",
"length",
")",
";",
"return",
"null",
";",
"}",
"ByteBuf",
"frame",
"=",
"buffer",
".",
"readSlice",
"(",
"length",
")",
";",
"buffer",
".",
"skipBytes",
"(",
"DELIMITER_LENGTH",
")",
";",
"return",
"frame",
";",
"}",
"else",
"{",
"final",
"int",
"length",
"=",
"buffer",
".",
"readableBytes",
"(",
")",
";",
"if",
"(",
"length",
">",
"V1_MAX_LENGTH",
")",
"{",
"discardedBytes",
"=",
"length",
";",
"buffer",
".",
"skipBytes",
"(",
"length",
")",
";",
"discarding",
"=",
"true",
";",
"failOverLimit",
"(",
"ctx",
",",
"\"over \"",
"+",
"discardedBytes",
")",
";",
"}",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"eol",
">=",
"0",
")",
"{",
"final",
"int",
"delimLength",
"=",
"buffer",
".",
"getByte",
"(",
"eol",
")",
"==",
"'",
"'",
"?",
"2",
":",
"1",
";",
"buffer",
".",
"readerIndex",
"(",
"eol",
"+",
"delimLength",
")",
";",
"discardedBytes",
"=",
"0",
";",
"discarding",
"=",
"false",
";",
"}",
"else",
"{",
"discardedBytes",
"=",
"buffer",
".",
"readableBytes",
"(",
")",
";",
"buffer",
".",
"skipBytes",
"(",
"discardedBytes",
")",
";",
"}",
"return",
"null",
";",
"}",
"}"
] | Create a frame out of the {@link ByteBuf} and return it.
Based on code from {@link LineBasedFrameDecoder#decode(ChannelHandlerContext, ByteBuf)}.
@param ctx the {@link ChannelHandlerContext} which this {@link HAProxyMessageDecoder} belongs to
@param buffer the {@link ByteBuf} from which to read data
@return frame the {@link ByteBuf} which represent the frame or {@code null} if no frame could
be created | [
"Create",
"a",
"frame",
"out",
"of",
"the",
"{",
"@link",
"ByteBuf",
"}",
"and",
"return",
"it",
".",
"Based",
"on",
"code",
"from",
"{",
"@link",
"LineBasedFrameDecoder#decode",
"(",
"ChannelHandlerContext",
"ByteBuf",
")",
"}",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyMessageDecoder.java#L312-L347 |
hdecarne/java-default | src/main/java/de/carne/io/IOUtil.java | IOUtil.copyStream | public static long copyStream(File dst, InputStream src) throws IOException {
long copied;
try (FileOutputStream dstStream = new FileOutputStream(dst)) {
copied = copyStream(dstStream, src);
}
return copied;
} | java | public static long copyStream(File dst, InputStream src) throws IOException {
long copied;
try (FileOutputStream dstStream = new FileOutputStream(dst)) {
copied = copyStream(dstStream, src);
}
return copied;
} | [
"public",
"static",
"long",
"copyStream",
"(",
"File",
"dst",
",",
"InputStream",
"src",
")",
"throws",
"IOException",
"{",
"long",
"copied",
";",
"try",
"(",
"FileOutputStream",
"dstStream",
"=",
"new",
"FileOutputStream",
"(",
"dst",
")",
")",
"{",
"copied",
"=",
"copyStream",
"(",
"dstStream",
",",
"src",
")",
";",
"}",
"return",
"copied",
";",
"}"
] | Copies all bytes from an {@linkplain InputStream} to a {@linkplain File}.
@param dst the {@linkplain File} to copy to.
@param src the {@linkplain InputStream} to copy from.
@return the number of copied bytes.
@throws IOException if an I/O error occurs. | [
"Copies",
"all",
"bytes",
"from",
"an",
"{",
"@linkplain",
"InputStream",
"}",
"to",
"a",
"{",
"@linkplain",
"File",
"}",
"."
] | train | https://github.com/hdecarne/java-default/blob/ca16f6fdb0436e90e9e2df3106055e320bb3c9e3/src/main/java/de/carne/io/IOUtil.java#L101-L108 |
hageldave/ImagingKit | ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/Fourier.java | Fourier.inverseTransform | public static ColorImg inverseTransform(ColorImg target, ComplexImg fourier, int channel) {
Dimension dim = fourier.getDimension();
// if no target was specified create a new one
if(target == null) {
target = new ColorImg(dim, channel==ColorImg.channel_a);
}
// continue sanity checks
sanityCheckInverse_target(target, dim, channel);
// now do the transforms
if(fourier.getCurrentXshift() != 0 || fourier.getCurrentYshift() != 0){
ComplexValuedSampler complexIn = getSamplerForShiftedComplexImg(fourier);
RowMajorArrayAccessor realOut = new RowMajorArrayAccessor(target.getData()[channel], target.getWidth(), target.getHeight());
FFT.ifft(complexIn, realOut, realOut.getDimensions());
} else {
FFT.ifft( fourier.getDataReal(),
fourier.getDataImag(),
target.getData()[channel],
target.getWidth(), target.getHeight());
}
double scaling = 1.0/target.numValues();
ArrayUtils.scaleArray(target.getData()[channel], scaling);
return target;
} | java | public static ColorImg inverseTransform(ColorImg target, ComplexImg fourier, int channel) {
Dimension dim = fourier.getDimension();
// if no target was specified create a new one
if(target == null) {
target = new ColorImg(dim, channel==ColorImg.channel_a);
}
// continue sanity checks
sanityCheckInverse_target(target, dim, channel);
// now do the transforms
if(fourier.getCurrentXshift() != 0 || fourier.getCurrentYshift() != 0){
ComplexValuedSampler complexIn = getSamplerForShiftedComplexImg(fourier);
RowMajorArrayAccessor realOut = new RowMajorArrayAccessor(target.getData()[channel], target.getWidth(), target.getHeight());
FFT.ifft(complexIn, realOut, realOut.getDimensions());
} else {
FFT.ifft( fourier.getDataReal(),
fourier.getDataImag(),
target.getData()[channel],
target.getWidth(), target.getHeight());
}
double scaling = 1.0/target.numValues();
ArrayUtils.scaleArray(target.getData()[channel], scaling);
return target;
} | [
"public",
"static",
"ColorImg",
"inverseTransform",
"(",
"ColorImg",
"target",
",",
"ComplexImg",
"fourier",
",",
"int",
"channel",
")",
"{",
"Dimension",
"dim",
"=",
"fourier",
".",
"getDimension",
"(",
")",
";",
"// if no target was specified create a new one",
"if",
"(",
"target",
"==",
"null",
")",
"{",
"target",
"=",
"new",
"ColorImg",
"(",
"dim",
",",
"channel",
"==",
"ColorImg",
".",
"channel_a",
")",
";",
"}",
"// continue sanity checks",
"sanityCheckInverse_target",
"(",
"target",
",",
"dim",
",",
"channel",
")",
";",
"// now do the transforms",
"if",
"(",
"fourier",
".",
"getCurrentXshift",
"(",
")",
"!=",
"0",
"||",
"fourier",
".",
"getCurrentYshift",
"(",
")",
"!=",
"0",
")",
"{",
"ComplexValuedSampler",
"complexIn",
"=",
"getSamplerForShiftedComplexImg",
"(",
"fourier",
")",
";",
"RowMajorArrayAccessor",
"realOut",
"=",
"new",
"RowMajorArrayAccessor",
"(",
"target",
".",
"getData",
"(",
")",
"[",
"channel",
"]",
",",
"target",
".",
"getWidth",
"(",
")",
",",
"target",
".",
"getHeight",
"(",
")",
")",
";",
"FFT",
".",
"ifft",
"(",
"complexIn",
",",
"realOut",
",",
"realOut",
".",
"getDimensions",
"(",
")",
")",
";",
"}",
"else",
"{",
"FFT",
".",
"ifft",
"(",
"fourier",
".",
"getDataReal",
"(",
")",
",",
"fourier",
".",
"getDataImag",
"(",
")",
",",
"target",
".",
"getData",
"(",
")",
"[",
"channel",
"]",
",",
"target",
".",
"getWidth",
"(",
")",
",",
"target",
".",
"getHeight",
"(",
")",
")",
";",
"}",
"double",
"scaling",
"=",
"1.0",
"/",
"target",
".",
"numValues",
"(",
")",
";",
"ArrayUtils",
".",
"scaleArray",
"(",
"target",
".",
"getData",
"(",
")",
"[",
"channel",
"]",
",",
"scaling",
")",
";",
"return",
"target",
";",
"}"
] | Executes the inverse Fourier transforms on the specified {@link ComplexImg} that corresponds
to a specific channel of a {@link ColorImg} defined by the channel argument.
The resulting transform will be stored in the specified channel of the specified target.
If target is null a new ColorImg will be created and returned.
<p>
If the alpha channel was specified the specified target has to contain an alpha channel
({@link ColorImg#hasAlpha()}).
@param target image where the transform is stored to
@param fourier the ComplexImg that will be transformed and corresponds to the specified channel
@param channel the specified ComplexImg correspond to
@return the target img or a new ColorImg if target was null
@throws IllegalArgumentException <br>
if images are not of the same dimensions <br>
if alpha is specified as channel but specified target (if not null) is does not have an alpha channel | [
"Executes",
"the",
"inverse",
"Fourier",
"transforms",
"on",
"the",
"specified",
"{",
"@link",
"ComplexImg",
"}",
"that",
"corresponds",
"to",
"a",
"specific",
"channel",
"of",
"a",
"{",
"@link",
"ColorImg",
"}",
"defined",
"by",
"the",
"channel",
"argument",
".",
"The",
"resulting",
"transform",
"will",
"be",
"stored",
"in",
"the",
"specified",
"channel",
"of",
"the",
"specified",
"target",
".",
"If",
"target",
"is",
"null",
"a",
"new",
"ColorImg",
"will",
"be",
"created",
"and",
"returned",
".",
"<p",
">",
"If",
"the",
"alpha",
"channel",
"was",
"specified",
"the",
"specified",
"target",
"has",
"to",
"contain",
"an",
"alpha",
"channel",
"(",
"{",
"@link",
"ColorImg#hasAlpha",
"()",
"}",
")",
"."
] | train | https://github.com/hageldave/ImagingKit/blob/3837c7d550a12cf4dc5718b644ced94b97f52668/ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/Fourier.java#L139-L161 |
javagl/ND | nd-tuples/src/main/java/de/javagl/nd/tuples/d/DoubleTupleCollections.java | DoubleTupleCollections.getSize | private static int getSize(Tuple t, Iterable<? extends Tuple> tuples)
{
if (t != null)
{
return t.getSize();
}
Iterator<? extends Tuple> iterator = tuples.iterator();
if (iterator.hasNext())
{
Tuple first = iterator.next();
if (first != null)
{
return first.getSize();
}
}
return -1;
} | java | private static int getSize(Tuple t, Iterable<? extends Tuple> tuples)
{
if (t != null)
{
return t.getSize();
}
Iterator<? extends Tuple> iterator = tuples.iterator();
if (iterator.hasNext())
{
Tuple first = iterator.next();
if (first != null)
{
return first.getSize();
}
}
return -1;
} | [
"private",
"static",
"int",
"getSize",
"(",
"Tuple",
"t",
",",
"Iterable",
"<",
"?",
"extends",
"Tuple",
">",
"tuples",
")",
"{",
"if",
"(",
"t",
"!=",
"null",
")",
"{",
"return",
"t",
".",
"getSize",
"(",
")",
";",
"}",
"Iterator",
"<",
"?",
"extends",
"Tuple",
">",
"iterator",
"=",
"tuples",
".",
"iterator",
"(",
")",
";",
"if",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"Tuple",
"first",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"first",
"!=",
"null",
")",
"{",
"return",
"first",
".",
"getSize",
"(",
")",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Returns the size of the given tuple. If the given tuple is
<code>null</code>, then the size of the first tuple of the
given sequence is returned. If this first tuple is <code>null</code>,
or the given sequence is empty, then -1 is returned.
@param t The tuple
@param tuples The tuples
@return The size | [
"Returns",
"the",
"size",
"of",
"the",
"given",
"tuple",
".",
"If",
"the",
"given",
"tuple",
"is",
"<code",
">",
"null<",
"/",
"code",
">",
"then",
"the",
"size",
"of",
"the",
"first",
"tuple",
"of",
"the",
"given",
"sequence",
"is",
"returned",
".",
"If",
"this",
"first",
"tuple",
"is",
"<code",
">",
"null<",
"/",
"code",
">",
"or",
"the",
"given",
"sequence",
"is",
"empty",
"then",
"-",
"1",
"is",
"returned",
"."
] | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-tuples/src/main/java/de/javagl/nd/tuples/d/DoubleTupleCollections.java#L290-L306 |
mikepenz/FastAdapter | library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java | FastAdapter.onBindViewHolder | @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<Object> payloads) {
//we do not want the binding to happen twice (the legacyBindViewMode
if (!mLegacyBindViewMode) {
if (mVerbose)
Log.v(TAG, "onBindViewHolder: " + position + "/" + holder.getItemViewType() + " isLegacy: false");
//set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available
holder.itemView.setTag(R.id.fastadapter_item_adapter, this);
//now we bind the item to this viewHolder
mOnBindViewHolderListener.onBindViewHolder(holder, position, payloads);
}
super.onBindViewHolder(holder, position, payloads);
} | java | @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<Object> payloads) {
//we do not want the binding to happen twice (the legacyBindViewMode
if (!mLegacyBindViewMode) {
if (mVerbose)
Log.v(TAG, "onBindViewHolder: " + position + "/" + holder.getItemViewType() + " isLegacy: false");
//set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available
holder.itemView.setTag(R.id.fastadapter_item_adapter, this);
//now we bind the item to this viewHolder
mOnBindViewHolderListener.onBindViewHolder(holder, position, payloads);
}
super.onBindViewHolder(holder, position, payloads);
} | [
"@",
"Override",
"public",
"void",
"onBindViewHolder",
"(",
"RecyclerView",
".",
"ViewHolder",
"holder",
",",
"int",
"position",
",",
"List",
"<",
"Object",
">",
"payloads",
")",
"{",
"//we do not want the binding to happen twice (the legacyBindViewMode",
"if",
"(",
"!",
"mLegacyBindViewMode",
")",
"{",
"if",
"(",
"mVerbose",
")",
"Log",
".",
"v",
"(",
"TAG",
",",
"\"onBindViewHolder: \"",
"+",
"position",
"+",
"\"/\"",
"+",
"holder",
".",
"getItemViewType",
"(",
")",
"+",
"\" isLegacy: false\"",
")",
";",
"//set the R.id.fastadapter_item_adapter tag to the adapter so we always have the proper bound adapter available",
"holder",
".",
"itemView",
".",
"setTag",
"(",
"R",
".",
"id",
".",
"fastadapter_item_adapter",
",",
"this",
")",
";",
"//now we bind the item to this viewHolder",
"mOnBindViewHolderListener",
".",
"onBindViewHolder",
"(",
"holder",
",",
"position",
",",
"payloads",
")",
";",
"}",
"super",
".",
"onBindViewHolder",
"(",
"holder",
",",
"position",
",",
"payloads",
")",
";",
"}"
] | Binds the data to the created ViewHolder and sets the listeners to the holder.itemView
@param holder the viewHolder we bind the data on
@param position the global position
@param payloads the payloads for the bindViewHolder event containing data which allows to improve view animating | [
"Binds",
"the",
"data",
"to",
"the",
"created",
"ViewHolder",
"and",
"sets",
"the",
"listeners",
"to",
"the",
"holder",
".",
"itemView"
] | train | https://github.com/mikepenz/FastAdapter/blob/3b2412abe001ba58422e0125846b704d4dba4ae9/library-core/src/main/java/com/mikepenz/fastadapter/FastAdapter.java#L733-L745 |
micronaut-projects/micronaut-core | core/src/main/java/io/micronaut/core/bind/annotation/AbstractAnnotatedArgumentBinder.java | AbstractAnnotatedArgumentBinder.doBind | @SuppressWarnings("unchecked")
protected BindingResult<T> doBind(
ArgumentConversionContext<T> context,
ConvertibleValues<?> values,
String annotationValue) {
return doConvert(doResolve(context, values, annotationValue), context);
} | java | @SuppressWarnings("unchecked")
protected BindingResult<T> doBind(
ArgumentConversionContext<T> context,
ConvertibleValues<?> values,
String annotationValue) {
return doConvert(doResolve(context, values, annotationValue), context);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"BindingResult",
"<",
"T",
">",
"doBind",
"(",
"ArgumentConversionContext",
"<",
"T",
">",
"context",
",",
"ConvertibleValues",
"<",
"?",
">",
"values",
",",
"String",
"annotationValue",
")",
"{",
"return",
"doConvert",
"(",
"doResolve",
"(",
"context",
",",
"values",
",",
"annotationValue",
")",
",",
"context",
")",
";",
"}"
] | Do binding.
@param context context
@param values values
@param annotationValue annotationValue
@return result | [
"Do",
"binding",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/core/src/main/java/io/micronaut/core/bind/annotation/AbstractAnnotatedArgumentBinder.java#L60-L67 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/util/GuiStandardUtils.java | GuiStandardUtils.createDebugBorder | public static void createDebugBorder(JComponent c, Color color) {
if (color == null) {
color = Color.BLACK;
}
c.setBorder(BorderFactory.createLineBorder(color));
} | java | public static void createDebugBorder(JComponent c, Color color) {
if (color == null) {
color = Color.BLACK;
}
c.setBorder(BorderFactory.createLineBorder(color));
} | [
"public",
"static",
"void",
"createDebugBorder",
"(",
"JComponent",
"c",
",",
"Color",
"color",
")",
"{",
"if",
"(",
"color",
"==",
"null",
")",
"{",
"color",
"=",
"Color",
".",
"BLACK",
";",
"}",
"c",
".",
"setBorder",
"(",
"BorderFactory",
".",
"createLineBorder",
"(",
"color",
")",
")",
";",
"}"
] | Useful debug function to place a colored, line border around a component
for layout management debugging.
@param c
the component
@param color
the border color | [
"Useful",
"debug",
"function",
"to",
"place",
"a",
"colored",
"line",
"border",
"around",
"a",
"component",
"for",
"layout",
"management",
"debugging",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/util/GuiStandardUtils.java#L289-L294 |
zaproxy/zaproxy | src/org/apache/commons/httpclient/URI.java | URI.getRawCurrentHierPath | protected char[] getRawCurrentHierPath(char[] path) throws URIException {
if (_is_opaque_part) {
throw new URIException(URIException.PARSING, "no hierarchy level");
}
if (path == null) {
throw new URIException(URIException.PARSING, "empty path");
}
String buff = new String(path);
int first = buff.indexOf('/');
int last = buff.lastIndexOf('/');
if (last == 0) {
return rootPath;
} else if (first != last && last != -1) {
return buff.substring(0, last).toCharArray();
}
// FIXME: it could be a document on the server side
return path;
} | java | protected char[] getRawCurrentHierPath(char[] path) throws URIException {
if (_is_opaque_part) {
throw new URIException(URIException.PARSING, "no hierarchy level");
}
if (path == null) {
throw new URIException(URIException.PARSING, "empty path");
}
String buff = new String(path);
int first = buff.indexOf('/');
int last = buff.lastIndexOf('/');
if (last == 0) {
return rootPath;
} else if (first != last && last != -1) {
return buff.substring(0, last).toCharArray();
}
// FIXME: it could be a document on the server side
return path;
} | [
"protected",
"char",
"[",
"]",
"getRawCurrentHierPath",
"(",
"char",
"[",
"]",
"path",
")",
"throws",
"URIException",
"{",
"if",
"(",
"_is_opaque_part",
")",
"{",
"throw",
"new",
"URIException",
"(",
"URIException",
".",
"PARSING",
",",
"\"no hierarchy level\"",
")",
";",
"}",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"throw",
"new",
"URIException",
"(",
"URIException",
".",
"PARSING",
",",
"\"empty path\"",
")",
";",
"}",
"String",
"buff",
"=",
"new",
"String",
"(",
"path",
")",
";",
"int",
"first",
"=",
"buff",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"int",
"last",
"=",
"buff",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"last",
"==",
"0",
")",
"{",
"return",
"rootPath",
";",
"}",
"else",
"if",
"(",
"first",
"!=",
"last",
"&&",
"last",
"!=",
"-",
"1",
")",
"{",
"return",
"buff",
".",
"substring",
"(",
"0",
",",
"last",
")",
".",
"toCharArray",
"(",
")",
";",
"}",
"// FIXME: it could be a document on the server side",
"return",
"path",
";",
"}"
] | Get the raw-escaped current hierarchy level in the given path.
If the last namespace is a collection, the slash mark ('/') should be
ended with at the last character of the path string.
@param path the path
@return the current hierarchy level
@throws URIException no hierarchy level | [
"Get",
"the",
"raw",
"-",
"escaped",
"current",
"hierarchy",
"level",
"in",
"the",
"given",
"path",
".",
"If",
"the",
"last",
"namespace",
"is",
"a",
"collection",
"the",
"slash",
"mark",
"(",
"/",
")",
"should",
"be",
"ended",
"with",
"at",
"the",
"last",
"character",
"of",
"the",
"path",
"string",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/apache/commons/httpclient/URI.java#L2995-L3013 |
grpc/grpc-java | netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java | NettyChannelBuilder.enableKeepAlive | @Deprecated
public final NettyChannelBuilder enableKeepAlive(boolean enable, long keepAliveTime,
TimeUnit delayUnit, long keepAliveTimeout, TimeUnit timeoutUnit) {
if (enable) {
return keepAliveTime(keepAliveTime, delayUnit)
.keepAliveTimeout(keepAliveTimeout, timeoutUnit);
}
return keepAliveTime(KEEPALIVE_TIME_NANOS_DISABLED, TimeUnit.NANOSECONDS);
} | java | @Deprecated
public final NettyChannelBuilder enableKeepAlive(boolean enable, long keepAliveTime,
TimeUnit delayUnit, long keepAliveTimeout, TimeUnit timeoutUnit) {
if (enable) {
return keepAliveTime(keepAliveTime, delayUnit)
.keepAliveTimeout(keepAliveTimeout, timeoutUnit);
}
return keepAliveTime(KEEPALIVE_TIME_NANOS_DISABLED, TimeUnit.NANOSECONDS);
} | [
"@",
"Deprecated",
"public",
"final",
"NettyChannelBuilder",
"enableKeepAlive",
"(",
"boolean",
"enable",
",",
"long",
"keepAliveTime",
",",
"TimeUnit",
"delayUnit",
",",
"long",
"keepAliveTimeout",
",",
"TimeUnit",
"timeoutUnit",
")",
"{",
"if",
"(",
"enable",
")",
"{",
"return",
"keepAliveTime",
"(",
"keepAliveTime",
",",
"delayUnit",
")",
".",
"keepAliveTimeout",
"(",
"keepAliveTimeout",
",",
"timeoutUnit",
")",
";",
"}",
"return",
"keepAliveTime",
"(",
"KEEPALIVE_TIME_NANOS_DISABLED",
",",
"TimeUnit",
".",
"NANOSECONDS",
")",
";",
"}"
] | Enable keepalive with custom delay and timeout.
@deprecated Please use {@link #keepAliveTime} and {@link #keepAliveTimeout} instead | [
"Enable",
"keepalive",
"with",
"custom",
"delay",
"and",
"timeout",
"."
] | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java#L339-L347 |
ttddyy/datasource-proxy | src/main/java/net/ttddyy/dsproxy/support/ProxyDataSourceBuilder.java | ProxyDataSourceBuilder.logSlowQueryByJUL | public ProxyDataSourceBuilder logSlowQueryByJUL(long thresholdTime, TimeUnit timeUnit) {
return logSlowQueryByJUL(thresholdTime, timeUnit, null, null);
} | java | public ProxyDataSourceBuilder logSlowQueryByJUL(long thresholdTime, TimeUnit timeUnit) {
return logSlowQueryByJUL(thresholdTime, timeUnit, null, null);
} | [
"public",
"ProxyDataSourceBuilder",
"logSlowQueryByJUL",
"(",
"long",
"thresholdTime",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"return",
"logSlowQueryByJUL",
"(",
"thresholdTime",
",",
"timeUnit",
",",
"null",
",",
"null",
")",
";",
"}"
] | Register {@link JULSlowQueryListener}.
@param thresholdTime slow query threshold time
@param timeUnit slow query threshold time unit
@return builder
@since 1.4.1 | [
"Register",
"{",
"@link",
"JULSlowQueryListener",
"}",
"."
] | train | https://github.com/ttddyy/datasource-proxy/blob/62163ccf9a569a99aa3ad9f9151a32567447a62e/src/main/java/net/ttddyy/dsproxy/support/ProxyDataSourceBuilder.java#L439-L441 |
Esri/geometry-api-java | src/main/java/com/esri/core/geometry/MultiPathImpl.java | MultiPathImpl.closePathWithBezier | public void closePathWithBezier(Point2D controlPoint1, Point2D controlPoint2) {
_touch();
if (isEmptyImpl())
throw new GeometryException(
"Invalid call. This operation cannot be performed on an empty geometry.");
m_bPathStarted = false;
int pathIndex = m_paths.size() - 2;
byte pf = m_pathFlags.read(pathIndex);
m_pathFlags
.write(pathIndex,
(byte) (pf | PathFlags.enumClosed | PathFlags.enumHasNonlinearSegments));
_initSegmentData(6);
byte oldType = m_segmentFlags
.read((byte) ((m_pointCount - 1) & SegmentFlags.enumSegmentMask));
m_segmentFlags.write(m_pointCount - 1,
(byte) (SegmentFlags.enumBezierSeg));
int curveIndex = m_curveParamwritePoint;
if (getSegmentDataSize(oldType) < getSegmentDataSize((byte) SegmentFlags.enumBezierSeg)) {
m_segmentParamIndex.write(m_pointCount - 1, m_curveParamwritePoint);
m_curveParamwritePoint += 6;
} else {
// there was a closing bezier curve or an arc here. We can reuse the
// storage.
curveIndex = m_segmentParamIndex.read(m_pointCount - 1);
}
double z;
m_segmentParams.write(curveIndex, controlPoint1.x);
m_segmentParams.write(curveIndex + 1, controlPoint1.y);
z = 0;// TODO: calculate me.
m_segmentParams.write(curveIndex + 2, z);
m_segmentParams.write(curveIndex + 3, controlPoint2.x);
m_segmentParams.write(curveIndex + 4, controlPoint2.y);
z = 0;// TODO: calculate me.
m_segmentParams.write(curveIndex + 5, z);
} | java | public void closePathWithBezier(Point2D controlPoint1, Point2D controlPoint2) {
_touch();
if (isEmptyImpl())
throw new GeometryException(
"Invalid call. This operation cannot be performed on an empty geometry.");
m_bPathStarted = false;
int pathIndex = m_paths.size() - 2;
byte pf = m_pathFlags.read(pathIndex);
m_pathFlags
.write(pathIndex,
(byte) (pf | PathFlags.enumClosed | PathFlags.enumHasNonlinearSegments));
_initSegmentData(6);
byte oldType = m_segmentFlags
.read((byte) ((m_pointCount - 1) & SegmentFlags.enumSegmentMask));
m_segmentFlags.write(m_pointCount - 1,
(byte) (SegmentFlags.enumBezierSeg));
int curveIndex = m_curveParamwritePoint;
if (getSegmentDataSize(oldType) < getSegmentDataSize((byte) SegmentFlags.enumBezierSeg)) {
m_segmentParamIndex.write(m_pointCount - 1, m_curveParamwritePoint);
m_curveParamwritePoint += 6;
} else {
// there was a closing bezier curve or an arc here. We can reuse the
// storage.
curveIndex = m_segmentParamIndex.read(m_pointCount - 1);
}
double z;
m_segmentParams.write(curveIndex, controlPoint1.x);
m_segmentParams.write(curveIndex + 1, controlPoint1.y);
z = 0;// TODO: calculate me.
m_segmentParams.write(curveIndex + 2, z);
m_segmentParams.write(curveIndex + 3, controlPoint2.x);
m_segmentParams.write(curveIndex + 4, controlPoint2.y);
z = 0;// TODO: calculate me.
m_segmentParams.write(curveIndex + 5, z);
} | [
"public",
"void",
"closePathWithBezier",
"(",
"Point2D",
"controlPoint1",
",",
"Point2D",
"controlPoint2",
")",
"{",
"_touch",
"(",
")",
";",
"if",
"(",
"isEmptyImpl",
"(",
")",
")",
"throw",
"new",
"GeometryException",
"(",
"\"Invalid call. This operation cannot be performed on an empty geometry.\"",
")",
";",
"m_bPathStarted",
"=",
"false",
";",
"int",
"pathIndex",
"=",
"m_paths",
".",
"size",
"(",
")",
"-",
"2",
";",
"byte",
"pf",
"=",
"m_pathFlags",
".",
"read",
"(",
"pathIndex",
")",
";",
"m_pathFlags",
".",
"write",
"(",
"pathIndex",
",",
"(",
"byte",
")",
"(",
"pf",
"|",
"PathFlags",
".",
"enumClosed",
"|",
"PathFlags",
".",
"enumHasNonlinearSegments",
")",
")",
";",
"_initSegmentData",
"(",
"6",
")",
";",
"byte",
"oldType",
"=",
"m_segmentFlags",
".",
"read",
"(",
"(",
"byte",
")",
"(",
"(",
"m_pointCount",
"-",
"1",
")",
"&",
"SegmentFlags",
".",
"enumSegmentMask",
")",
")",
";",
"m_segmentFlags",
".",
"write",
"(",
"m_pointCount",
"-",
"1",
",",
"(",
"byte",
")",
"(",
"SegmentFlags",
".",
"enumBezierSeg",
")",
")",
";",
"int",
"curveIndex",
"=",
"m_curveParamwritePoint",
";",
"if",
"(",
"getSegmentDataSize",
"(",
"oldType",
")",
"<",
"getSegmentDataSize",
"(",
"(",
"byte",
")",
"SegmentFlags",
".",
"enumBezierSeg",
")",
")",
"{",
"m_segmentParamIndex",
".",
"write",
"(",
"m_pointCount",
"-",
"1",
",",
"m_curveParamwritePoint",
")",
";",
"m_curveParamwritePoint",
"+=",
"6",
";",
"}",
"else",
"{",
"// there was a closing bezier curve or an arc here. We can reuse the",
"// storage.",
"curveIndex",
"=",
"m_segmentParamIndex",
".",
"read",
"(",
"m_pointCount",
"-",
"1",
")",
";",
"}",
"double",
"z",
";",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
",",
"controlPoint1",
".",
"x",
")",
";",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"1",
",",
"controlPoint1",
".",
"y",
")",
";",
"z",
"=",
"0",
";",
"// TODO: calculate me.",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"2",
",",
"z",
")",
";",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"3",
",",
"controlPoint2",
".",
"x",
")",
";",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"4",
",",
"controlPoint2",
".",
"y",
")",
";",
"z",
"=",
"0",
";",
"// TODO: calculate me.",
"m_segmentParams",
".",
"write",
"(",
"curveIndex",
"+",
"5",
",",
"z",
")",
";",
"}"
] | Closes last path of the MultiPathImpl with the Bezier Segment.
The start point of the Bezier is the last point of the path and the last
point of the bezier is the first point of the path. | [
"Closes",
"last",
"path",
"of",
"the",
"MultiPathImpl",
"with",
"the",
"Bezier",
"Segment",
"."
] | train | https://github.com/Esri/geometry-api-java/blob/494da8ec953d76e7c6072afbc081abfe48ff07cf/src/main/java/com/esri/core/geometry/MultiPathImpl.java#L524-L564 |
MenoData/Time4J | base/src/main/java/net/time4j/DayPeriod.java | DayPeriod.of | public static DayPeriod of(Map<PlainTime, String> timeToLabels) {
if (timeToLabels.isEmpty()) {
throw new IllegalArgumentException("Label map is empty.");
}
SortedMap<PlainTime, String> map = new TreeMap<>(timeToLabels);
for (PlainTime key : timeToLabels.keySet()) {
if (key.getHour() == 24) {
map.put(PlainTime.midnightAtStartOfDay(), timeToLabels.get(key));
map.remove(key);
} else if (timeToLabels.get(key).isEmpty()) {
throw new IllegalArgumentException("Map has empty label: " + timeToLabels);
}
}
return new DayPeriod(null, "", map);
} | java | public static DayPeriod of(Map<PlainTime, String> timeToLabels) {
if (timeToLabels.isEmpty()) {
throw new IllegalArgumentException("Label map is empty.");
}
SortedMap<PlainTime, String> map = new TreeMap<>(timeToLabels);
for (PlainTime key : timeToLabels.keySet()) {
if (key.getHour() == 24) {
map.put(PlainTime.midnightAtStartOfDay(), timeToLabels.get(key));
map.remove(key);
} else if (timeToLabels.get(key).isEmpty()) {
throw new IllegalArgumentException("Map has empty label: " + timeToLabels);
}
}
return new DayPeriod(null, "", map);
} | [
"public",
"static",
"DayPeriod",
"of",
"(",
"Map",
"<",
"PlainTime",
",",
"String",
">",
"timeToLabels",
")",
"{",
"if",
"(",
"timeToLabels",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Label map is empty.\"",
")",
";",
"}",
"SortedMap",
"<",
"PlainTime",
",",
"String",
">",
"map",
"=",
"new",
"TreeMap",
"<>",
"(",
"timeToLabels",
")",
";",
"for",
"(",
"PlainTime",
"key",
":",
"timeToLabels",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"key",
".",
"getHour",
"(",
")",
"==",
"24",
")",
"{",
"map",
".",
"put",
"(",
"PlainTime",
".",
"midnightAtStartOfDay",
"(",
")",
",",
"timeToLabels",
".",
"get",
"(",
"key",
")",
")",
";",
"map",
".",
"remove",
"(",
"key",
")",
";",
"}",
"else",
"if",
"(",
"timeToLabels",
".",
"get",
"(",
"key",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Map has empty label: \"",
"+",
"timeToLabels",
")",
";",
"}",
"}",
"return",
"new",
"DayPeriod",
"(",
"null",
",",
"\"\"",
",",
"map",
")",
";",
"}"
] | /*[deutsch]
<p>Erzeugt eine Instanz, die auf benutzerdefinierten Daten beruht. </p>
@param timeToLabels map containing the day-periods where the keys represent starting points
and the values represent the associated labels intended for representation
@return user-specific instance
@throws IllegalArgumentException if given map is empty or contains empty values
@since 3.13/4.10 | [
"/",
"*",
"[",
"deutsch",
"]",
"<p",
">",
"Erzeugt",
"eine",
"Instanz",
"die",
"auf",
"benutzerdefinierten",
"Daten",
"beruht",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/DayPeriod.java#L180-L199 |
deeplearning4j/deeplearning4j | datavec/datavec-spark/src/main/java/org/datavec/spark/transform/utils/SparkUtils.java | SparkUtils.writeStringToFile | public static void writeStringToFile(String path, String toWrite, JavaSparkContext sc) throws IOException {
writeStringToFile(path, toWrite, sc.sc());
} | java | public static void writeStringToFile(String path, String toWrite, JavaSparkContext sc) throws IOException {
writeStringToFile(path, toWrite, sc.sc());
} | [
"public",
"static",
"void",
"writeStringToFile",
"(",
"String",
"path",
",",
"String",
"toWrite",
",",
"JavaSparkContext",
"sc",
")",
"throws",
"IOException",
"{",
"writeStringToFile",
"(",
"path",
",",
"toWrite",
",",
"sc",
".",
"sc",
"(",
")",
")",
";",
"}"
] | Write a String to a file (on HDFS or local) in UTF-8 format
@param path Path to write to
@param toWrite String to write
@param sc Spark context | [
"Write",
"a",
"String",
"to",
"a",
"file",
"(",
"on",
"HDFS",
"or",
"local",
")",
"in",
"UTF",
"-",
"8",
"format"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-spark/src/main/java/org/datavec/spark/transform/utils/SparkUtils.java#L74-L76 |
michel-kraemer/bson4jackson | src/main/java/de/undercouch/bson4jackson/io/DynamicOutputBuffer.java | DynamicOutputBuffer.putLong | public void putLong(int pos, long l) {
adaptSize(pos + 8);
ByteBuffer bb = getBuffer(pos);
int index = pos % _bufferSize;
if (bb.limit() - index >= 8) {
bb.putLong(index, l);
} else {
byte b0 = (byte)l;
byte b1 = (byte)(l >> 8);
byte b2 = (byte)(l >> 16);
byte b3 = (byte)(l >> 24);
byte b4 = (byte)(l >> 32);
byte b5 = (byte)(l >> 40);
byte b6 = (byte)(l >> 48);
byte b7 = (byte)(l >> 56);
if (_order == ByteOrder.BIG_ENDIAN) {
putBytes(pos, b7, b6, b5, b4, b3, b2, b1, b0);
} else {
putBytes(pos, b0, b1, b2, b3, b4, b5, b6, b7);
}
}
} | java | public void putLong(int pos, long l) {
adaptSize(pos + 8);
ByteBuffer bb = getBuffer(pos);
int index = pos % _bufferSize;
if (bb.limit() - index >= 8) {
bb.putLong(index, l);
} else {
byte b0 = (byte)l;
byte b1 = (byte)(l >> 8);
byte b2 = (byte)(l >> 16);
byte b3 = (byte)(l >> 24);
byte b4 = (byte)(l >> 32);
byte b5 = (byte)(l >> 40);
byte b6 = (byte)(l >> 48);
byte b7 = (byte)(l >> 56);
if (_order == ByteOrder.BIG_ENDIAN) {
putBytes(pos, b7, b6, b5, b4, b3, b2, b1, b0);
} else {
putBytes(pos, b0, b1, b2, b3, b4, b5, b6, b7);
}
}
} | [
"public",
"void",
"putLong",
"(",
"int",
"pos",
",",
"long",
"l",
")",
"{",
"adaptSize",
"(",
"pos",
"+",
"8",
")",
";",
"ByteBuffer",
"bb",
"=",
"getBuffer",
"(",
"pos",
")",
";",
"int",
"index",
"=",
"pos",
"%",
"_bufferSize",
";",
"if",
"(",
"bb",
".",
"limit",
"(",
")",
"-",
"index",
">=",
"8",
")",
"{",
"bb",
".",
"putLong",
"(",
"index",
",",
"l",
")",
";",
"}",
"else",
"{",
"byte",
"b0",
"=",
"(",
"byte",
")",
"l",
";",
"byte",
"b1",
"=",
"(",
"byte",
")",
"(",
"l",
">>",
"8",
")",
";",
"byte",
"b2",
"=",
"(",
"byte",
")",
"(",
"l",
">>",
"16",
")",
";",
"byte",
"b3",
"=",
"(",
"byte",
")",
"(",
"l",
">>",
"24",
")",
";",
"byte",
"b4",
"=",
"(",
"byte",
")",
"(",
"l",
">>",
"32",
")",
";",
"byte",
"b5",
"=",
"(",
"byte",
")",
"(",
"l",
">>",
"40",
")",
";",
"byte",
"b6",
"=",
"(",
"byte",
")",
"(",
"l",
">>",
"48",
")",
";",
"byte",
"b7",
"=",
"(",
"byte",
")",
"(",
"l",
">>",
"56",
")",
";",
"if",
"(",
"_order",
"==",
"ByteOrder",
".",
"BIG_ENDIAN",
")",
"{",
"putBytes",
"(",
"pos",
",",
"b7",
",",
"b6",
",",
"b5",
",",
"b4",
",",
"b3",
",",
"b2",
",",
"b1",
",",
"b0",
")",
";",
"}",
"else",
"{",
"putBytes",
"(",
"pos",
",",
"b0",
",",
"b1",
",",
"b2",
",",
"b3",
",",
"b4",
",",
"b5",
",",
"b6",
",",
"b7",
")",
";",
"}",
"}",
"}"
] | Puts a 64-bit integer into the buffer at the given position. Does
not increase the write position.
@param pos the position where to put the integer
@param l the 64-bit integer to put | [
"Puts",
"a",
"64",
"-",
"bit",
"integer",
"into",
"the",
"buffer",
"at",
"the",
"given",
"position",
".",
"Does",
"not",
"increase",
"the",
"write",
"position",
"."
] | train | https://github.com/michel-kraemer/bson4jackson/blob/32d2ab3c516b3c07490fdfcf0c5e4ed0a2ee3979/src/main/java/de/undercouch/bson4jackson/io/DynamicOutputBuffer.java#L429-L451 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDLoss.java | SDLoss.logLoss | public SDVariable logLoss(String name, @NonNull SDVariable label, @NonNull SDVariable predictions) {
return logLoss(name, label, predictions, null, LossReduce.MEAN_BY_NONZERO_WEIGHT_COUNT, LogLoss.DEFAULT_EPSILON);
} | java | public SDVariable logLoss(String name, @NonNull SDVariable label, @NonNull SDVariable predictions) {
return logLoss(name, label, predictions, null, LossReduce.MEAN_BY_NONZERO_WEIGHT_COUNT, LogLoss.DEFAULT_EPSILON);
} | [
"public",
"SDVariable",
"logLoss",
"(",
"String",
"name",
",",
"@",
"NonNull",
"SDVariable",
"label",
",",
"@",
"NonNull",
"SDVariable",
"predictions",
")",
"{",
"return",
"logLoss",
"(",
"name",
",",
"label",
",",
"predictions",
",",
"null",
",",
"LossReduce",
".",
"MEAN_BY_NONZERO_WEIGHT_COUNT",
",",
"LogLoss",
".",
"DEFAULT_EPSILON",
")",
";",
"}"
] | See {@link #logLoss(String, SDVariable, SDVariable, SDVariable, LossReduce, double)}. | [
"See",
"{"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDLoss.java#L213-L215 |
salesforce/Argus | ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/dto/PrincipalUserDto.java | PrincipalUserDto.transformToDto | public static PrincipalUserDto transformToDto(PrincipalUser user) {
if (user == null) {
throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
}
PrincipalUserDto result = createDtoObject(PrincipalUserDto.class, user);
for (Dashboard dashboard : user.getOwnedDashboards()) {
result.addOwnedDashboardId(dashboard.getId());
}
return result;
} | java | public static PrincipalUserDto transformToDto(PrincipalUser user) {
if (user == null) {
throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
}
PrincipalUserDto result = createDtoObject(PrincipalUserDto.class, user);
for (Dashboard dashboard : user.getOwnedDashboards()) {
result.addOwnedDashboardId(dashboard.getId());
}
return result;
} | [
"public",
"static",
"PrincipalUserDto",
"transformToDto",
"(",
"PrincipalUser",
"user",
")",
"{",
"if",
"(",
"user",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"Null entity object cannot be converted to Dto object.\"",
",",
"Status",
".",
"INTERNAL_SERVER_ERROR",
")",
";",
"}",
"PrincipalUserDto",
"result",
"=",
"createDtoObject",
"(",
"PrincipalUserDto",
".",
"class",
",",
"user",
")",
";",
"for",
"(",
"Dashboard",
"dashboard",
":",
"user",
".",
"getOwnedDashboards",
"(",
")",
")",
"{",
"result",
".",
"addOwnedDashboardId",
"(",
"dashboard",
".",
"getId",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Converts a user entity to DTO.
@param user The entity to convert.
@return The DTO.
@throws WebApplicationException If an error occurs. | [
"Converts",
"a",
"user",
"entity",
"to",
"DTO",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/dto/PrincipalUserDto.java#L74-L85 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/BackupDocumentWriter.java | BackupDocumentWriter.write | public void write( Document document ) {
assert document != null;
++count;
++totalCount;
if (count > maxDocumentsPerFile) {
// Close the stream (we'll open a new one later in the method) ...
close();
count = 1;
}
try {
if (stream == null) {
// Open the stream to the next file ...
++fileCount;
String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0');
String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION;
if (compress) filename = filename + GZIP_EXTENSION;
currentFile = new File(parentDirectory, filename);
OutputStream fileStream = new FileOutputStream(currentFile);
if (compress) fileStream = new GZIPOutputStream(fileStream);
stream = new BufferedOutputStream(fileStream);
}
Json.write(document, stream);
// Need to append a non-consumable character so that we can read multiple JSON documents per file
stream.write((byte)'\n');
} catch (IOException e) {
problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage());
}
} | java | public void write( Document document ) {
assert document != null;
++count;
++totalCount;
if (count > maxDocumentsPerFile) {
// Close the stream (we'll open a new one later in the method) ...
close();
count = 1;
}
try {
if (stream == null) {
// Open the stream to the next file ...
++fileCount;
String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0');
String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION;
if (compress) filename = filename + GZIP_EXTENSION;
currentFile = new File(parentDirectory, filename);
OutputStream fileStream = new FileOutputStream(currentFile);
if (compress) fileStream = new GZIPOutputStream(fileStream);
stream = new BufferedOutputStream(fileStream);
}
Json.write(document, stream);
// Need to append a non-consumable character so that we can read multiple JSON documents per file
stream.write((byte)'\n');
} catch (IOException e) {
problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage());
}
} | [
"public",
"void",
"write",
"(",
"Document",
"document",
")",
"{",
"assert",
"document",
"!=",
"null",
";",
"++",
"count",
";",
"++",
"totalCount",
";",
"if",
"(",
"count",
">",
"maxDocumentsPerFile",
")",
"{",
"// Close the stream (we'll open a new one later in the method) ...",
"close",
"(",
")",
";",
"count",
"=",
"1",
";",
"}",
"try",
"{",
"if",
"(",
"stream",
"==",
"null",
")",
"{",
"// Open the stream to the next file ...",
"++",
"fileCount",
";",
"String",
"suffix",
"=",
"StringUtil",
".",
"justifyRight",
"(",
"Long",
".",
"toString",
"(",
"fileCount",
")",
",",
"BackupService",
".",
"NUM_CHARS_IN_FILENAME_SUFFIX",
",",
"'",
"'",
")",
";",
"String",
"filename",
"=",
"filenamePrefix",
"+",
"\"_\"",
"+",
"suffix",
"+",
"DOCUMENTS_EXTENSION",
";",
"if",
"(",
"compress",
")",
"filename",
"=",
"filename",
"+",
"GZIP_EXTENSION",
";",
"currentFile",
"=",
"new",
"File",
"(",
"parentDirectory",
",",
"filename",
")",
";",
"OutputStream",
"fileStream",
"=",
"new",
"FileOutputStream",
"(",
"currentFile",
")",
";",
"if",
"(",
"compress",
")",
"fileStream",
"=",
"new",
"GZIPOutputStream",
"(",
"fileStream",
")",
";",
"stream",
"=",
"new",
"BufferedOutputStream",
"(",
"fileStream",
")",
";",
"}",
"Json",
".",
"write",
"(",
"document",
",",
"stream",
")",
";",
"// Need to append a non-consumable character so that we can read multiple JSON documents per file",
"stream",
".",
"write",
"(",
"(",
"byte",
")",
"'",
"'",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"problems",
".",
"addError",
"(",
"JcrI18n",
".",
"problemsWritingDocumentToBackup",
",",
"currentFile",
".",
"getAbsolutePath",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Append the supplied document to the files.
@param document the document to be written; may not be null | [
"Append",
"the",
"supplied",
"document",
"to",
"the",
"files",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/BackupDocumentWriter.java#L71-L98 |
Azure/azure-sdk-for-java | containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ContainerServicesInner.java | ContainerServicesInner.beginDelete | public void beginDelete(String resourceGroupName, String containerServiceName) {
beginDeleteWithServiceResponseAsync(resourceGroupName, containerServiceName).toBlocking().single().body();
} | java | public void beginDelete(String resourceGroupName, String containerServiceName) {
beginDeleteWithServiceResponseAsync(resourceGroupName, containerServiceName).toBlocking().single().body();
} | [
"public",
"void",
"beginDelete",
"(",
"String",
"resourceGroupName",
",",
"String",
"containerServiceName",
")",
"{",
"beginDeleteWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"containerServiceName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Deletes the specified container service.
Deletes the specified container service in the specified subscription and resource group. The operation does not delete other resources created as part of creating a container service, including storage accounts, VMs, and availability sets. All the other resources created with the container service are part of the same resource group and can be deleted individually.
@param resourceGroupName The name of the resource group.
@param containerServiceName The name of the container service in the specified subscription and resource group.
@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",
"container",
"service",
".",
"Deletes",
"the",
"specified",
"container",
"service",
"in",
"the",
"specified",
"subscription",
"and",
"resource",
"group",
".",
"The",
"operation",
"does",
"not",
"delete",
"other",
"resources",
"created",
"as",
"part",
"of",
"creating",
"a",
"container",
"service",
"including",
"storage",
"accounts",
"VMs",
"and",
"availability",
"sets",
".",
"All",
"the",
"other",
"resources",
"created",
"with",
"the",
"container",
"service",
"are",
"part",
"of",
"the",
"same",
"resource",
"group",
"and",
"can",
"be",
"deleted",
"individually",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ContainerServicesInner.java#L564-L566 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringHelper.java | StringHelper.trimStart | @Nullable
@CheckReturnValue
public static String trimStart (@Nullable final String sSrc, final char cLead)
{
return startsWith (sSrc, cLead) ? sSrc.substring (1, sSrc.length ()) : sSrc;
} | java | @Nullable
@CheckReturnValue
public static String trimStart (@Nullable final String sSrc, final char cLead)
{
return startsWith (sSrc, cLead) ? sSrc.substring (1, sSrc.length ()) : sSrc;
} | [
"@",
"Nullable",
"@",
"CheckReturnValue",
"public",
"static",
"String",
"trimStart",
"(",
"@",
"Nullable",
"final",
"String",
"sSrc",
",",
"final",
"char",
"cLead",
")",
"{",
"return",
"startsWith",
"(",
"sSrc",
",",
"cLead",
")",
"?",
"sSrc",
".",
"substring",
"(",
"1",
",",
"sSrc",
".",
"length",
"(",
")",
")",
":",
"sSrc",
";",
"}"
] | Trim the passed lead from the source value. If the source value does not
start with the passed lead, nothing happens.
@param sSrc
The input source string
@param cLead
The char to be trimmed of the beginning
@return The trimmed string, or the original input string, if the lead was not
found
@see #trimEnd(String, String)
@see #trimStartAndEnd(String, String)
@see #trimStartAndEnd(String, String, String) | [
"Trim",
"the",
"passed",
"lead",
"from",
"the",
"source",
"value",
".",
"If",
"the",
"source",
"value",
"does",
"not",
"start",
"with",
"the",
"passed",
"lead",
"nothing",
"happens",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L3322-L3327 |
jOOQ/jOOL | jOOL-java-8/src/main/java/org/jooq/lambda/Unchecked.java | Unchecked.objDoubleConsumer | public static <T> ObjDoubleConsumer<T> objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer) {
return objDoubleConsumer(consumer, THROWABLE_TO_RUNTIME_EXCEPTION);
} | java | public static <T> ObjDoubleConsumer<T> objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer) {
return objDoubleConsumer(consumer, THROWABLE_TO_RUNTIME_EXCEPTION);
} | [
"public",
"static",
"<",
"T",
">",
"ObjDoubleConsumer",
"<",
"T",
">",
"objDoubleConsumer",
"(",
"CheckedObjDoubleConsumer",
"<",
"T",
">",
"consumer",
")",
"{",
"return",
"objDoubleConsumer",
"(",
"consumer",
",",
"THROWABLE_TO_RUNTIME_EXCEPTION",
")",
";",
"}"
] | Wrap a {@link CheckedObjDoubleConsumer} in a {@link ObjDoubleConsumer}. | [
"Wrap",
"a",
"{"
] | train | https://github.com/jOOQ/jOOL/blob/889d87c85ca57bafd4eddd78e0f7ae2804d2ee86/jOOL-java-8/src/main/java/org/jooq/lambda/Unchecked.java#L292-L294 |
pressgang-ccms/PressGangCCMSCommonUtilities | src/main/java/org/jboss/pressgang/ccms/utils/common/ExecUtilities.java | ExecUtilities.runCommand | public static boolean runCommand(final Process p, final OutputStream output, final List<String> doNotPrintStrings) {
return runCommand(p, output, output, doNotPrintStrings);
} | java | public static boolean runCommand(final Process p, final OutputStream output, final List<String> doNotPrintStrings) {
return runCommand(p, output, output, doNotPrintStrings);
} | [
"public",
"static",
"boolean",
"runCommand",
"(",
"final",
"Process",
"p",
",",
"final",
"OutputStream",
"output",
",",
"final",
"List",
"<",
"String",
">",
"doNotPrintStrings",
")",
"{",
"return",
"runCommand",
"(",
"p",
",",
"output",
",",
"output",
",",
"doNotPrintStrings",
")",
";",
"}"
] | Run a Process, and read the various streams so there is not a buffer
overrun.
@param p The Process to be executed
@param output The Stream to receive the Process' output stream
@param doNotPrintStrings A collection of strings that should not be
dumped to std.out
@return true if the Process returned 0, false otherwise | [
"Run",
"a",
"Process",
"and",
"read",
"the",
"various",
"streams",
"so",
"there",
"is",
"not",
"a",
"buffer",
"overrun",
"."
] | train | https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/ExecUtilities.java#L62-L64 |
ops4j/org.ops4j.pax.wicket | service/src/main/java/org/ops4j/pax/wicket/api/support/DefaultPageMounter.java | DefaultPageMounter.addMountPoint | @Override
public void addMountPoint(String path, Class<? extends Page> pageClass) {
LOGGER.debug("Adding mount point for path {} = {}", path, pageClass.getName());
mountPoints.add(new DefaultMountPointInfo(path, pageClass));
} | java | @Override
public void addMountPoint(String path, Class<? extends Page> pageClass) {
LOGGER.debug("Adding mount point for path {} = {}", path, pageClass.getName());
mountPoints.add(new DefaultMountPointInfo(path, pageClass));
} | [
"@",
"Override",
"public",
"void",
"addMountPoint",
"(",
"String",
"path",
",",
"Class",
"<",
"?",
"extends",
"Page",
">",
"pageClass",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Adding mount point for path {} = {}\"",
",",
"path",
",",
"pageClass",
".",
"getName",
"(",
")",
")",
";",
"mountPoints",
".",
"add",
"(",
"new",
"DefaultMountPointInfo",
"(",
"path",
",",
"pageClass",
")",
")",
";",
"}"
] | {@inheritDoc}
A convenience method that uses a default coding strategy. | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/ops4j/org.ops4j.pax.wicket/blob/ef7cb4bdf918e9e61ec69789b9c690567616faa9/service/src/main/java/org/ops4j/pax/wicket/api/support/DefaultPageMounter.java#L136-L140 |
mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java | DynamoDBMapper.safeInvoke | private Object safeInvoke(Method method, Object object, Object... arguments) {
try {
return method.invoke(object, arguments);
} catch ( IllegalAccessException e ) {
throw new DynamoDBMappingException("Couldn't invoke " + method, e);
} catch ( IllegalArgumentException e ) {
throw new DynamoDBMappingException("Couldn't invoke " + method, e);
} catch ( InvocationTargetException e ) {
throw new DynamoDBMappingException("Couldn't invoke " + method, e);
}
} | java | private Object safeInvoke(Method method, Object object, Object... arguments) {
try {
return method.invoke(object, arguments);
} catch ( IllegalAccessException e ) {
throw new DynamoDBMappingException("Couldn't invoke " + method, e);
} catch ( IllegalArgumentException e ) {
throw new DynamoDBMappingException("Couldn't invoke " + method, e);
} catch ( InvocationTargetException e ) {
throw new DynamoDBMappingException("Couldn't invoke " + method, e);
}
} | [
"private",
"Object",
"safeInvoke",
"(",
"Method",
"method",
",",
"Object",
"object",
",",
"Object",
"...",
"arguments",
")",
"{",
"try",
"{",
"return",
"method",
".",
"invoke",
"(",
"object",
",",
"arguments",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"DynamoDBMappingException",
"(",
"\"Couldn't invoke \"",
"+",
"method",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"DynamoDBMappingException",
"(",
"\"Couldn't invoke \"",
"+",
"method",
",",
"e",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"DynamoDBMappingException",
"(",
"\"Couldn't invoke \"",
"+",
"method",
",",
"e",
")",
";",
"}",
"}"
] | Swallows the checked exceptions around Method.invoke and repackages them
as {@link DynamoDBMappingException} | [
"Swallows",
"the",
"checked",
"exceptions",
"around",
"Method",
".",
"invoke",
"and",
"repackages",
"them",
"as",
"{"
] | train | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java#L968-L978 |
google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java | MapWithProtoValuesSubject.usingDoubleToleranceForFieldDescriptorsForValues | public MapWithProtoValuesFluentAssertion<M> usingDoubleToleranceForFieldDescriptorsForValues(
double tolerance, Iterable<FieldDescriptor> fieldDescriptors) {
return usingConfig(config.usingDoubleToleranceForFieldDescriptors(tolerance, fieldDescriptors));
} | java | public MapWithProtoValuesFluentAssertion<M> usingDoubleToleranceForFieldDescriptorsForValues(
double tolerance, Iterable<FieldDescriptor> fieldDescriptors) {
return usingConfig(config.usingDoubleToleranceForFieldDescriptors(tolerance, fieldDescriptors));
} | [
"public",
"MapWithProtoValuesFluentAssertion",
"<",
"M",
">",
"usingDoubleToleranceForFieldDescriptorsForValues",
"(",
"double",
"tolerance",
",",
"Iterable",
"<",
"FieldDescriptor",
">",
"fieldDescriptors",
")",
"{",
"return",
"usingConfig",
"(",
"config",
".",
"usingDoubleToleranceForFieldDescriptors",
"(",
"tolerance",
",",
"fieldDescriptors",
")",
")",
";",
"}"
] | Compares double fields with these explicitly specified fields using the provided absolute
tolerance.
@param tolerance A finite, non-negative tolerance. | [
"Compares",
"double",
"fields",
"with",
"these",
"explicitly",
"specified",
"fields",
"using",
"the",
"provided",
"absolute",
"tolerance",
"."
] | train | https://github.com/google/truth/blob/60eceffd2e8c3297655d33ed87d965cf5af51108/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java#L552-L555 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/query/ResultIterator.java | ResultIterator.onCheckRelation | private void onCheckRelation()
{
try
{
results = populateEntities(entityMetadata, client);
if (entityMetadata.isRelationViaJoinTable()
|| (entityMetadata.getRelationNames() != null && !(entityMetadata.getRelationNames().isEmpty())))
{
query.setRelationalEntities(results, client, entityMetadata);
}
}
catch (Exception e)
{
throw new PersistenceException("Error while scrolling over results, Caused by :.", e);
}
} | java | private void onCheckRelation()
{
try
{
results = populateEntities(entityMetadata, client);
if (entityMetadata.isRelationViaJoinTable()
|| (entityMetadata.getRelationNames() != null && !(entityMetadata.getRelationNames().isEmpty())))
{
query.setRelationalEntities(results, client, entityMetadata);
}
}
catch (Exception e)
{
throw new PersistenceException("Error while scrolling over results, Caused by :.", e);
}
} | [
"private",
"void",
"onCheckRelation",
"(",
")",
"{",
"try",
"{",
"results",
"=",
"populateEntities",
"(",
"entityMetadata",
",",
"client",
")",
";",
"if",
"(",
"entityMetadata",
".",
"isRelationViaJoinTable",
"(",
")",
"||",
"(",
"entityMetadata",
".",
"getRelationNames",
"(",
")",
"!=",
"null",
"&&",
"!",
"(",
"entityMetadata",
".",
"getRelationNames",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
")",
")",
"{",
"query",
".",
"setRelationalEntities",
"(",
"results",
",",
"client",
",",
"entityMetadata",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"\"Error while scrolling over results, Caused by :.\"",
",",
"e",
")",
";",
"}",
"}"
] | on check relation event, invokes populate entities and set relational
entities, in case relations are present. | [
"on",
"check",
"relation",
"event",
"invokes",
"populate",
"entities",
"and",
"set",
"relational",
"entities",
"in",
"case",
"relations",
"are",
"present",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/query/ResultIterator.java#L238-L254 |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/SparseDoubleArray.java | SparseDoubleArray.dividePrimitive | public double dividePrimitive(int index, double value) {
if (index < 0 || index >= maxLength)
throw new ArrayIndexOutOfBoundsException(
"invalid index: " + index);
int pos = Arrays.binarySearch(indices, index);
// The divide operation is dividing a non-existent value in the
// array, which is always 0, so the corresponding result is 0.
// Therefore, we don't need to make room.
if (pos < 0)
return 0;
else {
double newValue = values[pos] / value;
// The new value is zero, so remove its position and shift
// everything over
if (newValue == 0) {
int newLength = indices.length - 1;
int[] newIndices = new int[newLength];
double[] newValues = new double[newLength];
for (int i = 0, j = 0; i < indices.length; ++i) {
if (i != pos) {
newIndices[j] = indices[i];
newValues[j] = values[i];
j++;
}
}
// swap the arrays
indices = newIndices;
values = newValues;
}
// Otherwise, the new value is still non-zero, so update it in the
// array
else
values[pos] = newValue;
return newValue;
}
} | java | public double dividePrimitive(int index, double value) {
if (index < 0 || index >= maxLength)
throw new ArrayIndexOutOfBoundsException(
"invalid index: " + index);
int pos = Arrays.binarySearch(indices, index);
// The divide operation is dividing a non-existent value in the
// array, which is always 0, so the corresponding result is 0.
// Therefore, we don't need to make room.
if (pos < 0)
return 0;
else {
double newValue = values[pos] / value;
// The new value is zero, so remove its position and shift
// everything over
if (newValue == 0) {
int newLength = indices.length - 1;
int[] newIndices = new int[newLength];
double[] newValues = new double[newLength];
for (int i = 0, j = 0; i < indices.length; ++i) {
if (i != pos) {
newIndices[j] = indices[i];
newValues[j] = values[i];
j++;
}
}
// swap the arrays
indices = newIndices;
values = newValues;
}
// Otherwise, the new value is still non-zero, so update it in the
// array
else
values[pos] = newValue;
return newValue;
}
} | [
"public",
"double",
"dividePrimitive",
"(",
"int",
"index",
",",
"double",
"value",
")",
"{",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">=",
"maxLength",
")",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
"\"invalid index: \"",
"+",
"index",
")",
";",
"int",
"pos",
"=",
"Arrays",
".",
"binarySearch",
"(",
"indices",
",",
"index",
")",
";",
"// The divide operation is dividing a non-existent value in the",
"// array, which is always 0, so the corresponding result is 0.",
"// Therefore, we don't need to make room.",
"if",
"(",
"pos",
"<",
"0",
")",
"return",
"0",
";",
"else",
"{",
"double",
"newValue",
"=",
"values",
"[",
"pos",
"]",
"/",
"value",
";",
"// The new value is zero, so remove its position and shift",
"// everything over",
"if",
"(",
"newValue",
"==",
"0",
")",
"{",
"int",
"newLength",
"=",
"indices",
".",
"length",
"-",
"1",
";",
"int",
"[",
"]",
"newIndices",
"=",
"new",
"int",
"[",
"newLength",
"]",
";",
"double",
"[",
"]",
"newValues",
"=",
"new",
"double",
"[",
"newLength",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"j",
"=",
"0",
";",
"i",
"<",
"indices",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"i",
"!=",
"pos",
")",
"{",
"newIndices",
"[",
"j",
"]",
"=",
"indices",
"[",
"i",
"]",
";",
"newValues",
"[",
"j",
"]",
"=",
"values",
"[",
"i",
"]",
";",
"j",
"++",
";",
"}",
"}",
"// swap the arrays",
"indices",
"=",
"newIndices",
";",
"values",
"=",
"newValues",
";",
"}",
"// Otherwise, the new value is still non-zero, so update it in the",
"// array",
"else",
"values",
"[",
"pos",
"]",
"=",
"newValue",
";",
"return",
"newValue",
";",
"}",
"}"
] | Divides the specified value to the index by the provided value and stores
the result at the index (just as {@code array[index] /= value})
@param index the position in the array
@param value the value by which the value at the index will be divided
@return the new value stored at the index | [
"Divides",
"the",
"specified",
"value",
"to",
"the",
"index",
"by",
"the",
"provided",
"value",
"and",
"stores",
"the",
"result",
"at",
"the",
"index",
"(",
"just",
"as",
"{",
"@code",
"array",
"[",
"index",
"]",
"/",
"=",
"value",
"}",
")"
] | train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/SparseDoubleArray.java#L252-L290 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java | MemberSummaryBuilder.buildEnumConstantsSummary | public void buildEnumConstantsSummary(XMLNode node, Content memberSummaryTree) {
MemberSummaryWriter writer =
memberSummaryWriters[VisibleMemberMap.ENUM_CONSTANTS];
VisibleMemberMap visibleMemberMap =
visibleMemberMaps[VisibleMemberMap.ENUM_CONSTANTS];
addSummary(writer, visibleMemberMap, false, memberSummaryTree);
} | java | public void buildEnumConstantsSummary(XMLNode node, Content memberSummaryTree) {
MemberSummaryWriter writer =
memberSummaryWriters[VisibleMemberMap.ENUM_CONSTANTS];
VisibleMemberMap visibleMemberMap =
visibleMemberMaps[VisibleMemberMap.ENUM_CONSTANTS];
addSummary(writer, visibleMemberMap, false, memberSummaryTree);
} | [
"public",
"void",
"buildEnumConstantsSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"memberSummaryTree",
")",
"{",
"MemberSummaryWriter",
"writer",
"=",
"memberSummaryWriters",
"[",
"VisibleMemberMap",
".",
"ENUM_CONSTANTS",
"]",
";",
"VisibleMemberMap",
"visibleMemberMap",
"=",
"visibleMemberMaps",
"[",
"VisibleMemberMap",
".",
"ENUM_CONSTANTS",
"]",
";",
"addSummary",
"(",
"writer",
",",
"visibleMemberMap",
",",
"false",
",",
"memberSummaryTree",
")",
";",
"}"
] | Build the summary for the enum constants.
@param node the XML element that specifies which components to document
@param memberSummaryTree the content tree to which the documentation will be added | [
"Build",
"the",
"summary",
"for",
"the",
"enum",
"constants",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java#L208-L214 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java | ApiOvhDedicatedCloud.serviceName_datacenter_datacenterId_filer_filerId_GET | public OvhFiler serviceName_datacenter_datacenterId_filer_filerId_GET(String serviceName, Long datacenterId, Long filerId) throws IOException {
String qPath = "/dedicatedCloud/{serviceName}/datacenter/{datacenterId}/filer/{filerId}";
StringBuilder sb = path(qPath, serviceName, datacenterId, filerId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFiler.class);
} | java | public OvhFiler serviceName_datacenter_datacenterId_filer_filerId_GET(String serviceName, Long datacenterId, Long filerId) throws IOException {
String qPath = "/dedicatedCloud/{serviceName}/datacenter/{datacenterId}/filer/{filerId}";
StringBuilder sb = path(qPath, serviceName, datacenterId, filerId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFiler.class);
} | [
"public",
"OvhFiler",
"serviceName_datacenter_datacenterId_filer_filerId_GET",
"(",
"String",
"serviceName",
",",
"Long",
"datacenterId",
",",
"Long",
"filerId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicatedCloud/{serviceName}/datacenter/{datacenterId}/filer/{filerId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"datacenterId",
",",
"filerId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhFiler",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /dedicatedCloud/{serviceName}/datacenter/{datacenterId}/filer/{filerId}
@param serviceName [required] Domain of the service
@param datacenterId [required]
@param filerId [required] Filer Id | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedCloud/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedCloud.java#L2253-L2258 |
spotify/helios | helios-services/src/main/java/com/spotify/helios/master/ZooKeeperMasterModel.java | ZooKeeperMasterModel.rolloutOptionsWithFallback | static RolloutOptions rolloutOptionsWithFallback(final RolloutOptions options, final Job job) {
return options.withFallback(
job.getRolloutOptions() == null
? RolloutOptions.getDefault()
: job.getRolloutOptions().withFallback(RolloutOptions.getDefault()));
} | java | static RolloutOptions rolloutOptionsWithFallback(final RolloutOptions options, final Job job) {
return options.withFallback(
job.getRolloutOptions() == null
? RolloutOptions.getDefault()
: job.getRolloutOptions().withFallback(RolloutOptions.getDefault()));
} | [
"static",
"RolloutOptions",
"rolloutOptionsWithFallback",
"(",
"final",
"RolloutOptions",
"options",
",",
"final",
"Job",
"job",
")",
"{",
"return",
"options",
".",
"withFallback",
"(",
"job",
".",
"getRolloutOptions",
"(",
")",
"==",
"null",
"?",
"RolloutOptions",
".",
"getDefault",
"(",
")",
":",
"job",
".",
"getRolloutOptions",
"(",
")",
".",
"withFallback",
"(",
"RolloutOptions",
".",
"getDefault",
"(",
")",
")",
")",
";",
"}"
] | Returns a {@link RolloutOptions} instance that will replace null attributes in options with
values from two tiers of fallbacks. First fallback to job then
{@link RolloutOptions#getDefault()}. | [
"Returns",
"a",
"{"
] | train | https://github.com/spotify/helios/blob/c9000bc1d6908651570be8b057d4981bba4df5b4/helios-services/src/main/java/com/spotify/helios/master/ZooKeeperMasterModel.java#L625-L630 |
Red5/red5-server-common | src/main/java/org/red5/server/net/rtmp/RTMPConnection.java | RTMPConnection.setup | public void setup(String host, String path, Map<String, Object> params) {
this.host = host;
this.path = path;
this.params = params;
if (Integer.valueOf(3).equals(params.get("objectEncoding"))) {
if (log.isDebugEnabled()) {
log.debug("Setting object encoding to AMF3");
}
state.setEncoding(Encoding.AMF3);
}
} | java | public void setup(String host, String path, Map<String, Object> params) {
this.host = host;
this.path = path;
this.params = params;
if (Integer.valueOf(3).equals(params.get("objectEncoding"))) {
if (log.isDebugEnabled()) {
log.debug("Setting object encoding to AMF3");
}
state.setEncoding(Encoding.AMF3);
}
} | [
"public",
"void",
"setup",
"(",
"String",
"host",
",",
"String",
"path",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
")",
"{",
"this",
".",
"host",
"=",
"host",
";",
"this",
".",
"path",
"=",
"path",
";",
"this",
".",
"params",
"=",
"params",
";",
"if",
"(",
"Integer",
".",
"valueOf",
"(",
"3",
")",
".",
"equals",
"(",
"params",
".",
"get",
"(",
"\"objectEncoding\"",
")",
")",
")",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Setting object encoding to AMF3\"",
")",
";",
"}",
"state",
".",
"setEncoding",
"(",
"Encoding",
".",
"AMF3",
")",
";",
"}",
"}"
] | Initialize connection.
@param host
Connection host
@param path
Connection path
@param params
Params passed from client | [
"Initialize",
"connection",
"."
] | train | https://github.com/Red5/red5-server-common/blob/39ae73710c25bda86d70b13ef37ae707962217b9/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java#L574-L584 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/Table.java | Table.getNextConstraintIndex | int getNextConstraintIndex(int from, int type) {
for (int i = from, size = constraintList.length; i < size; i++) {
Constraint c = constraintList[i];
if (c.getConstraintType() == type) {
return i;
}
}
return -1;
} | java | int getNextConstraintIndex(int from, int type) {
for (int i = from, size = constraintList.length; i < size; i++) {
Constraint c = constraintList[i];
if (c.getConstraintType() == type) {
return i;
}
}
return -1;
} | [
"int",
"getNextConstraintIndex",
"(",
"int",
"from",
",",
"int",
"type",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"from",
",",
"size",
"=",
"constraintList",
".",
"length",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"Constraint",
"c",
"=",
"constraintList",
"[",
"i",
"]",
";",
"if",
"(",
"c",
".",
"getConstraintType",
"(",
")",
"==",
"type",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Returns the next constraint of a given type
@param from
@param type | [
"Returns",
"the",
"next",
"constraint",
"of",
"a",
"given",
"type"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/Table.java#L896-L907 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/taglib/el/EvalHelper.java | EvalHelper.evalString | public static String evalString(String propertyName, String propertyValue, Tag tag, PageContext pageContext) throws JspException{
return (String) ExpressionEvaluatorManager.evaluate(propertyName,
propertyValue, String.class, tag, pageContext);
} | java | public static String evalString(String propertyName, String propertyValue, Tag tag, PageContext pageContext) throws JspException{
return (String) ExpressionEvaluatorManager.evaluate(propertyName,
propertyValue, String.class, tag, pageContext);
} | [
"public",
"static",
"String",
"evalString",
"(",
"String",
"propertyName",
",",
"String",
"propertyValue",
",",
"Tag",
"tag",
",",
"PageContext",
"pageContext",
")",
"throws",
"JspException",
"{",
"return",
"(",
"String",
")",
"ExpressionEvaluatorManager",
".",
"evaluate",
"(",
"propertyName",
",",
"propertyValue",
",",
"String",
".",
"class",
",",
"tag",
",",
"pageContext",
")",
";",
"}"
] | Evaluate the string EL expression passed as parameter
@param propertyName the property name
@param propertyValue the property value
@param tag the tag
@param pageContext the page context
@return the value corresponding to the EL expression passed as parameter
@throws JspException if an exception occurs | [
"Evaluate",
"the",
"string",
"EL",
"expression",
"passed",
"as",
"parameter"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/el/EvalHelper.java#L39-L43 |
zeroturnaround/zt-zip | src/main/java/org/zeroturnaround/zip/ZipUtil.java | ZipUtil.addEntries | public static void addEntries(File zip, ZipEntrySource[] entries, File destZip) {
if (log.isDebugEnabled()) {
log.debug("Copying '" + zip + "' to '" + destZip + "' and adding " + Arrays.asList(entries) + ".");
}
OutputStream destOut = null;
try {
destOut = new BufferedOutputStream(new FileOutputStream(destZip));
addEntries(zip, entries, destOut);
}
catch (IOException e) {
ZipExceptionUtil.rethrow(e);
}
finally {
IOUtils.closeQuietly(destOut);
}
} | java | public static void addEntries(File zip, ZipEntrySource[] entries, File destZip) {
if (log.isDebugEnabled()) {
log.debug("Copying '" + zip + "' to '" + destZip + "' and adding " + Arrays.asList(entries) + ".");
}
OutputStream destOut = null;
try {
destOut = new BufferedOutputStream(new FileOutputStream(destZip));
addEntries(zip, entries, destOut);
}
catch (IOException e) {
ZipExceptionUtil.rethrow(e);
}
finally {
IOUtils.closeQuietly(destOut);
}
} | [
"public",
"static",
"void",
"addEntries",
"(",
"File",
"zip",
",",
"ZipEntrySource",
"[",
"]",
"entries",
",",
"File",
"destZip",
")",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Copying '\"",
"+",
"zip",
"+",
"\"' to '\"",
"+",
"destZip",
"+",
"\"' and adding \"",
"+",
"Arrays",
".",
"asList",
"(",
"entries",
")",
"+",
"\".\"",
")",
";",
"}",
"OutputStream",
"destOut",
"=",
"null",
";",
"try",
"{",
"destOut",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"destZip",
")",
")",
";",
"addEntries",
"(",
"zip",
",",
"entries",
",",
"destOut",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"ZipExceptionUtil",
".",
"rethrow",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"IOUtils",
".",
"closeQuietly",
"(",
"destOut",
")",
";",
"}",
"}"
] | Copies an existing ZIP file and appends it with new entries.
@param zip
an existing ZIP file (only read).
@param entries
new ZIP entries appended.
@param destZip
new ZIP file created. | [
"Copies",
"an",
"existing",
"ZIP",
"file",
"and",
"appends",
"it",
"with",
"new",
"entries",
"."
] | train | https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/ZipUtil.java#L2164-L2180 |
52inc/android-52Kit | library/src/main/java/com/ftinc/kit/util/Utils.java | Utils.parseInt | public static int parseInt(String val, int defValue){
if(TextUtils.isEmpty(val)) return defValue;
try{
return Integer.parseInt(val);
}catch (NumberFormatException e){
return defValue;
}
} | java | public static int parseInt(String val, int defValue){
if(TextUtils.isEmpty(val)) return defValue;
try{
return Integer.parseInt(val);
}catch (NumberFormatException e){
return defValue;
}
} | [
"public",
"static",
"int",
"parseInt",
"(",
"String",
"val",
",",
"int",
"defValue",
")",
"{",
"if",
"(",
"TextUtils",
".",
"isEmpty",
"(",
"val",
")",
")",
"return",
"defValue",
";",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"val",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"return",
"defValue",
";",
"}",
"}"
] | Parse a int from a String in a safe manner.
@param val the string to parse
@param defValue the default value to return if parsing fails
@return the parsed int, or default value | [
"Parse",
"a",
"int",
"from",
"a",
"String",
"in",
"a",
"safe",
"manner",
"."
] | train | https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/Utils.java#L262-L269 |
khipu/lib-java | src/main/java/com/khipu/lib/java/Khipu.java | Khipu.getPaymentButton | public static String getPaymentButton(int receiverId, String secret, String email, String bankId, String subject, String body, int amount, Date expiresDate, String notifyUrl, String returnUrl, String cancelUrl, String pictureUrl, String custom, String transactionId, String button) {
StringBuilder builder = new StringBuilder();
builder.append("<form action=\"" + API_URL + CREATE_PAYMENT_PAGE_ENDPOINT + "\" method=\"post\">\n");
builder.append("<input type=\"hidden\" name=\"receiver_id\" value=\"").append(receiverId).append("\">\n");
builder.append("<input type=\"hidden\" name=\"subject\" value=\"").append(subject != null ? subject : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"body\" value=\"").append(body != null ? body : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"amount\" value=\"").append(amount).append("\">\n");
builder.append("<input type=\"hidden\" name=\"expires_date\" value=\"").append(expiresDate != null ? expiresDate.getTime() / 1000 : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"notify_url\" value=\"").append(notifyUrl != null ? notifyUrl : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"return_url\" value=\"").append(returnUrl != null ? returnUrl : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"cancel_url\" value=\"").append(cancelUrl != null ? cancelUrl : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"custom\" value=\"").append(custom != null ? custom : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"transaction_id\" value=\"").append(transactionId != null ? transactionId : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"payer_email\" value=\"").append(email != null ? email : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"bank_id\" value=\"").append(bankId != null ? bankId : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"picture_url\" value=\"").append(pictureUrl != null ? pictureUrl : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"hash\" value=\"").append(KhipuService.HmacSHA256(secret, getConcatenated(receiverId, email, bankId, subject, body, amount, expiresDate, notifyUrl, returnUrl, cancelUrl, pictureUrl, custom, transactionId))).append("\">\n");
builder.append("<input type=\"image\" name=\"submit\" src=\"" + AMAZON_IMAGES_URL).append(button).append("\"/>");
builder.append("</form>");
return builder.toString();
} | java | public static String getPaymentButton(int receiverId, String secret, String email, String bankId, String subject, String body, int amount, Date expiresDate, String notifyUrl, String returnUrl, String cancelUrl, String pictureUrl, String custom, String transactionId, String button) {
StringBuilder builder = new StringBuilder();
builder.append("<form action=\"" + API_URL + CREATE_PAYMENT_PAGE_ENDPOINT + "\" method=\"post\">\n");
builder.append("<input type=\"hidden\" name=\"receiver_id\" value=\"").append(receiverId).append("\">\n");
builder.append("<input type=\"hidden\" name=\"subject\" value=\"").append(subject != null ? subject : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"body\" value=\"").append(body != null ? body : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"amount\" value=\"").append(amount).append("\">\n");
builder.append("<input type=\"hidden\" name=\"expires_date\" value=\"").append(expiresDate != null ? expiresDate.getTime() / 1000 : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"notify_url\" value=\"").append(notifyUrl != null ? notifyUrl : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"return_url\" value=\"").append(returnUrl != null ? returnUrl : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"cancel_url\" value=\"").append(cancelUrl != null ? cancelUrl : "").append("\"/>\n");
builder.append("<input type=\"hidden\" name=\"custom\" value=\"").append(custom != null ? custom : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"transaction_id\" value=\"").append(transactionId != null ? transactionId : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"payer_email\" value=\"").append(email != null ? email : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"bank_id\" value=\"").append(bankId != null ? bankId : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"picture_url\" value=\"").append(pictureUrl != null ? pictureUrl : "").append("\">\n");
builder.append("<input type=\"hidden\" name=\"hash\" value=\"").append(KhipuService.HmacSHA256(secret, getConcatenated(receiverId, email, bankId, subject, body, amount, expiresDate, notifyUrl, returnUrl, cancelUrl, pictureUrl, custom, transactionId))).append("\">\n");
builder.append("<input type=\"image\" name=\"submit\" src=\"" + AMAZON_IMAGES_URL).append(button).append("\"/>");
builder.append("</form>");
return builder.toString();
} | [
"public",
"static",
"String",
"getPaymentButton",
"(",
"int",
"receiverId",
",",
"String",
"secret",
",",
"String",
"email",
",",
"String",
"bankId",
",",
"String",
"subject",
",",
"String",
"body",
",",
"int",
"amount",
",",
"Date",
"expiresDate",
",",
"String",
"notifyUrl",
",",
"String",
"returnUrl",
",",
"String",
"cancelUrl",
",",
"String",
"pictureUrl",
",",
"String",
"custom",
",",
"String",
"transactionId",
",",
"String",
"button",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"<form action=\\\"\"",
"+",
"API_URL",
"+",
"CREATE_PAYMENT_PAGE_ENDPOINT",
"+",
"\"\\\" method=\\\"post\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"receiver_id\\\" value=\\\"\"",
")",
".",
"append",
"(",
"receiverId",
")",
".",
"append",
"(",
"\"\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"subject\\\" value=\\\"\"",
")",
".",
"append",
"(",
"subject",
"!=",
"null",
"?",
"subject",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\"/>\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"body\\\" value=\\\"\"",
")",
".",
"append",
"(",
"body",
"!=",
"null",
"?",
"body",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"amount\\\" value=\\\"\"",
")",
".",
"append",
"(",
"amount",
")",
".",
"append",
"(",
"\"\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"expires_date\\\" value=\\\"\"",
")",
".",
"append",
"(",
"expiresDate",
"!=",
"null",
"?",
"expiresDate",
".",
"getTime",
"(",
")",
"/",
"1000",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\"/>\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"notify_url\\\" value=\\\"\"",
")",
".",
"append",
"(",
"notifyUrl",
"!=",
"null",
"?",
"notifyUrl",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\"/>\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"return_url\\\" value=\\\"\"",
")",
".",
"append",
"(",
"returnUrl",
"!=",
"null",
"?",
"returnUrl",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\"/>\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"cancel_url\\\" value=\\\"\"",
")",
".",
"append",
"(",
"cancelUrl",
"!=",
"null",
"?",
"cancelUrl",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\"/>\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"custom\\\" value=\\\"\"",
")",
".",
"append",
"(",
"custom",
"!=",
"null",
"?",
"custom",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"transaction_id\\\" value=\\\"\"",
")",
".",
"append",
"(",
"transactionId",
"!=",
"null",
"?",
"transactionId",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"payer_email\\\" value=\\\"\"",
")",
".",
"append",
"(",
"email",
"!=",
"null",
"?",
"email",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"bank_id\\\" value=\\\"\"",
")",
".",
"append",
"(",
"bankId",
"!=",
"null",
"?",
"bankId",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"picture_url\\\" value=\\\"\"",
")",
".",
"append",
"(",
"pictureUrl",
"!=",
"null",
"?",
"pictureUrl",
":",
"\"\"",
")",
".",
"append",
"(",
"\"\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"hash\\\" value=\\\"\"",
")",
".",
"append",
"(",
"KhipuService",
".",
"HmacSHA256",
"(",
"secret",
",",
"getConcatenated",
"(",
"receiverId",
",",
"email",
",",
"bankId",
",",
"subject",
",",
"body",
",",
"amount",
",",
"expiresDate",
",",
"notifyUrl",
",",
"returnUrl",
",",
"cancelUrl",
",",
"pictureUrl",
",",
"custom",
",",
"transactionId",
")",
")",
")",
".",
"append",
"(",
"\"\\\">\\n\"",
")",
";",
"builder",
".",
"append",
"(",
"\"<input type=\\\"image\\\" name=\\\"submit\\\" src=\\\"\"",
"+",
"AMAZON_IMAGES_URL",
")",
".",
"append",
"(",
"button",
")",
".",
"append",
"(",
"\"\\\"/>\"",
")",
";",
"builder",
".",
"append",
"(",
"\"</form>\"",
")",
";",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | Entrega un String que contiene un botón de pago que dirije a khipu.
@param receiverId id de cobrador
@param secret llave de cobrador
@param email correo del pagador. Este correo aparecerá pre-configurado en
la página de pago (opcional).
@param bankId el identificador del banco para hacer el pago.
@param subject asunto del cobro. Con un máximo de 255 caracteres.
@param body la descripción del cobro (opcional).
@param amount el monto del cobro.
@param expiresDate la fecha de expiración para pagar.
@param notifyUrl la dirección de tu web service que utilizará khipu para
notificarte de un pago realizado (opcional).
@param returnUrl la dirección URL a donde enviar al cliente una vez que el pago
sea realizado (opcional).
@param cancelUrl la dirección URL a donde enviar al cliente si se arrepiente de
hacer la transacción (opcional)
@param pictureUrl una dirección URL de una foto de tu producto o servicio para
mostrar en la página del cobro (opcional).
@param custom variable para enviar información personalizada de la
transacción (opcional).
@param transactionId variable disponible para enviar un identificador propio de la
transacción (opcional).
@param button imagen del botón de pago.
@return el servicio para crear botones de pago
@since 2013-05-24 | [
"Entrega",
"un",
"String",
"que",
"contiene",
"un",
"botón",
"de",
"pago",
"que",
"dirije",
"a",
"khipu",
"."
] | train | https://github.com/khipu/lib-java/blob/7a56476a60c6f5012e13f342c81b5ef9dc2328e6/src/main/java/com/khipu/lib/java/Khipu.java#L214-L234 |
aws/aws-sdk-java | aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/PutMethodResponseRequest.java | PutMethodResponseRequest.withResponseModels | public PutMethodResponseRequest withResponseModels(java.util.Map<String, String> responseModels) {
setResponseModels(responseModels);
return this;
} | java | public PutMethodResponseRequest withResponseModels(java.util.Map<String, String> responseModels) {
setResponseModels(responseModels);
return this;
} | [
"public",
"PutMethodResponseRequest",
"withResponseModels",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"responseModels",
")",
"{",
"setResponseModels",
"(",
"responseModels",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Specifies the <a>Model</a> resources used for the response's content type. Response models are represented as a
key/value map, with a content type as the key and a <a>Model</a> name as the value.
</p>
@param responseModels
Specifies the <a>Model</a> resources used for the response's content type. Response models are represented
as a key/value map, with a content type as the key and a <a>Model</a> name as the value.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Specifies",
"the",
"<a",
">",
"Model<",
"/",
"a",
">",
"resources",
"used",
"for",
"the",
"response",
"s",
"content",
"type",
".",
"Response",
"models",
"are",
"represented",
"as",
"a",
"key",
"/",
"value",
"map",
"with",
"a",
"content",
"type",
"as",
"the",
"key",
"and",
"a",
"<a",
">",
"Model<",
"/",
"a",
">",
"name",
"as",
"the",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/PutMethodResponseRequest.java#L387-L390 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java | UnicodeSet.spanBack | public int spanBack(CharSequence s, SpanCondition spanCondition) {
return spanBack(s, s.length(), spanCondition);
} | java | public int spanBack(CharSequence s, SpanCondition spanCondition) {
return spanBack(s, s.length(), spanCondition);
} | [
"public",
"int",
"spanBack",
"(",
"CharSequence",
"s",
",",
"SpanCondition",
"spanCondition",
")",
"{",
"return",
"spanBack",
"(",
"s",
",",
"s",
".",
"length",
"(",
")",
",",
"spanCondition",
")",
";",
"}"
] | Span a string backwards (from the end) using this UnicodeSet.
<p>To replace, count elements, or delete spans, see {@link android.icu.text.UnicodeSetSpanner UnicodeSetSpanner}.
@param s The string to be spanned
@param spanCondition The span condition
@return The string index which starts the span (i.e. inclusive). | [
"Span",
"a",
"string",
"backwards",
"(",
"from",
"the",
"end",
")",
"using",
"this",
"UnicodeSet",
".",
"<p",
">",
"To",
"replace",
"count",
"elements",
"or",
"delete",
"spans",
"see",
"{"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L4061-L4063 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/zone/Ser.java | Ser.writeOffset | static void writeOffset(ZoneOffset offset, DataOutput out) throws IOException {
final int offsetSecs = offset.getTotalSeconds();
int offsetByte = offsetSecs % 900 == 0 ? offsetSecs / 900 : 127; // compress to -72 to +72
out.writeByte(offsetByte);
if (offsetByte == 127) {
out.writeInt(offsetSecs);
}
} | java | static void writeOffset(ZoneOffset offset, DataOutput out) throws IOException {
final int offsetSecs = offset.getTotalSeconds();
int offsetByte = offsetSecs % 900 == 0 ? offsetSecs / 900 : 127; // compress to -72 to +72
out.writeByte(offsetByte);
if (offsetByte == 127) {
out.writeInt(offsetSecs);
}
} | [
"static",
"void",
"writeOffset",
"(",
"ZoneOffset",
"offset",
",",
"DataOutput",
"out",
")",
"throws",
"IOException",
"{",
"final",
"int",
"offsetSecs",
"=",
"offset",
".",
"getTotalSeconds",
"(",
")",
";",
"int",
"offsetByte",
"=",
"offsetSecs",
"%",
"900",
"==",
"0",
"?",
"offsetSecs",
"/",
"900",
":",
"127",
";",
"// compress to -72 to +72",
"out",
".",
"writeByte",
"(",
"offsetByte",
")",
";",
"if",
"(",
"offsetByte",
"==",
"127",
")",
"{",
"out",
".",
"writeInt",
"(",
"offsetSecs",
")",
";",
"}",
"}"
] | Writes the state to the stream.
@param offset the offset, not null
@param out the output stream, not null
@throws IOException if an error occurs | [
"Writes",
"the",
"state",
"to",
"the",
"stream",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/zone/Ser.java#L221-L228 |
tvesalainen/util | util/src/main/java/org/vesalainen/math/ConvexPolygon.java | ConvexPolygon.distanceFromLine | public static double distanceFromLine(double x0, double y0, double x1, double y1, double x2, double y2)
{
double dx = x2-x1;
if (dx == 0.0)
{
return Math.abs(x1-x0);
}
double dy = y2-y1;
if (dy == 0.0)
{
return Math.abs(y1-y0);
}
return Math.abs(dy*x0-dx*y0+x2*y1-y2*x1)/Math.hypot(dx, dy);
} | java | public static double distanceFromLine(double x0, double y0, double x1, double y1, double x2, double y2)
{
double dx = x2-x1;
if (dx == 0.0)
{
return Math.abs(x1-x0);
}
double dy = y2-y1;
if (dy == 0.0)
{
return Math.abs(y1-y0);
}
return Math.abs(dy*x0-dx*y0+x2*y1-y2*x1)/Math.hypot(dx, dy);
} | [
"public",
"static",
"double",
"distanceFromLine",
"(",
"double",
"x0",
",",
"double",
"y0",
",",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"x2",
",",
"double",
"y2",
")",
"{",
"double",
"dx",
"=",
"x2",
"-",
"x1",
";",
"if",
"(",
"dx",
"==",
"0.0",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"x1",
"-",
"x0",
")",
";",
"}",
"double",
"dy",
"=",
"y2",
"-",
"y1",
";",
"if",
"(",
"dy",
"==",
"0.0",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"y1",
"-",
"y0",
")",
";",
"}",
"return",
"Math",
".",
"abs",
"(",
"dy",
"*",
"x0",
"-",
"dx",
"*",
"y0",
"+",
"x2",
"*",
"y1",
"-",
"y2",
"*",
"x1",
")",
"/",
"Math",
".",
"hypot",
"(",
"dx",
",",
"dy",
")",
";",
"}"
] | Returns distance from point (x0, y0) to line that goes through points
(x1, y1) and (x2, y2)
@param x0
@param y0
@param x1
@param y1
@param x2
@param y2
@return | [
"Returns",
"distance",
"from",
"point",
"(",
"x0",
"y0",
")",
"to",
"line",
"that",
"goes",
"through",
"points",
"(",
"x1",
"y1",
")",
"and",
"(",
"x2",
"y2",
")"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/ConvexPolygon.java#L127-L140 |
katjahahn/PortEx | src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java | Visualizer.writeImage | public void writeImage(File input, File output, String formatName)
throws IOException {
BufferedImage image = createImage(input);
ImageIO.write(image, formatName, output);
} | java | public void writeImage(File input, File output, String formatName)
throws IOException {
BufferedImage image = createImage(input);
ImageIO.write(image, formatName, output);
} | [
"public",
"void",
"writeImage",
"(",
"File",
"input",
",",
"File",
"output",
",",
"String",
"formatName",
")",
"throws",
"IOException",
"{",
"BufferedImage",
"image",
"=",
"createImage",
"(",
"input",
")",
";",
"ImageIO",
".",
"write",
"(",
"image",
",",
"formatName",
",",
"output",
")",
";",
"}"
] | Writes an image to the output file that displays the structure of the PE
file.
@param input
the PE file to create an image from
@param output
the file to write the image to
@param formatName
the format name for the output image
@throws IOException
if sections can not be read | [
"Writes",
"an",
"image",
"to",
"the",
"output",
"file",
"that",
"displays",
"the",
"structure",
"of",
"the",
"PE",
"file",
"."
] | train | https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L339-L343 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/LabsInner.java | LabsInner.update | public LabInner update(String resourceGroupName, String labAccountName, String labName, LabFragment lab) {
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, lab).toBlocking().single().body();
} | java | public LabInner update(String resourceGroupName, String labAccountName, String labName, LabFragment lab) {
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, lab).toBlocking().single().body();
} | [
"public",
"LabInner",
"update",
"(",
"String",
"resourceGroupName",
",",
"String",
"labAccountName",
",",
"String",
"labName",
",",
"LabFragment",
"lab",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"labAccountName",
",",
"labName",
",",
"lab",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Modify properties of labs.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param lab Represents a lab.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the LabInner object if successful. | [
"Modify",
"properties",
"of",
"labs",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/LabsInner.java#L835-L837 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/TaskOperations.java | TaskOperations.createTask | public void createTask(String jobId, TaskAddParameter taskToAdd) throws BatchErrorException, IOException {
createTask(jobId, taskToAdd, null);
} | java | public void createTask(String jobId, TaskAddParameter taskToAdd) throws BatchErrorException, IOException {
createTask(jobId, taskToAdd, null);
} | [
"public",
"void",
"createTask",
"(",
"String",
"jobId",
",",
"TaskAddParameter",
"taskToAdd",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"createTask",
"(",
"jobId",
",",
"taskToAdd",
",",
"null",
")",
";",
"}"
] | Adds a single task to a job.
@param jobId
The ID of the job to which to add the task.
@param taskToAdd
The {@link TaskAddParameter task} to add.
@throws BatchErrorException
Exception thrown when an error response is received from the
Batch service.
@throws IOException
Exception thrown when there is an error in
serialization/deserialization of data sent to/received from the
Batch service. | [
"Adds",
"a",
"single",
"task",
"to",
"a",
"job",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/TaskOperations.java#L94-L96 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CciConnCodeGen.java | CciConnCodeGen.writeMetaData | private void writeMetaData(Definition def, Writer out, int indent) throws IOException
{
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent,
" * Gets the information on the underlying EIS instance represented through an active connection.\n");
writeWithIndent(out, indent, " *\n");
writeWithIndent(out, indent,
" * @return ConnectionMetaData instance representing information about the EIS instance\n");
writeWithIndent(out, indent,
" * @throws ResourceException Failed to get information about the connected EIS instance. \n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent, "@Override\n");
writeWithIndent(out, indent, "public ConnectionMetaData getMetaData() throws ResourceException");
writeLeftCurlyBracket(out, indent);
writeWithIndent(out, indent + 1, "return new " + def.getMcfDefs().get(getNumOfMcf()).getConnMetaClass() + "();");
writeRightCurlyBracket(out, indent);
writeEol(out);
} | java | private void writeMetaData(Definition def, Writer out, int indent) throws IOException
{
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent,
" * Gets the information on the underlying EIS instance represented through an active connection.\n");
writeWithIndent(out, indent, " *\n");
writeWithIndent(out, indent,
" * @return ConnectionMetaData instance representing information about the EIS instance\n");
writeWithIndent(out, indent,
" * @throws ResourceException Failed to get information about the connected EIS instance. \n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent, "@Override\n");
writeWithIndent(out, indent, "public ConnectionMetaData getMetaData() throws ResourceException");
writeLeftCurlyBracket(out, indent);
writeWithIndent(out, indent + 1, "return new " + def.getMcfDefs().get(getNumOfMcf()).getConnMetaClass() + "();");
writeRightCurlyBracket(out, indent);
writeEol(out);
} | [
"private",
"void",
"writeMetaData",
"(",
"Definition",
"def",
",",
"Writer",
"out",
",",
"int",
"indent",
")",
"throws",
"IOException",
"{",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"/**\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * Gets the information on the underlying EIS instance represented through an active connection.\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" *\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * @return ConnectionMetaData instance representing information about the EIS instance\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * @throws ResourceException Failed to get information about the connected EIS instance. \\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" */\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"@Override\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"public ConnectionMetaData getMetaData() throws ResourceException\"",
")",
";",
"writeLeftCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
"+",
"1",
",",
"\"return new \"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"getNumOfMcf",
"(",
")",
")",
".",
"getConnMetaClass",
"(",
")",
"+",
"\"();\"",
")",
";",
"writeRightCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"}"
] | Output MetaData method
@param def definition
@param out Writer
@param indent space number
@throws IOException ioException | [
"Output",
"MetaData",
"method"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CciConnCodeGen.java#L202-L221 |
jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java | AbstractGenerator.addPages | public <T> I addPages(Collection<T> webPages, Function<T, WebPage> mapper) {
for (T element : webPages) {
addPage(mapper.apply(element));
}
return getThis();
} | java | public <T> I addPages(Collection<T> webPages, Function<T, WebPage> mapper) {
for (T element : webPages) {
addPage(mapper.apply(element));
}
return getThis();
} | [
"public",
"<",
"T",
">",
"I",
"addPages",
"(",
"Collection",
"<",
"T",
">",
"webPages",
",",
"Function",
"<",
"T",
",",
"WebPage",
">",
"mapper",
")",
"{",
"for",
"(",
"T",
"element",
":",
"webPages",
")",
"{",
"addPage",
"(",
"mapper",
".",
"apply",
"(",
"element",
")",
")",
";",
"}",
"return",
"getThis",
"(",
")",
";",
"}"
] | Add collection of pages to sitemap
@param <T> This is the type parameter
@param webPages Collection of pages
@param mapper Mapper function which transforms some object to WebPage
@return this | [
"Add",
"collection",
"of",
"pages",
"to",
"sitemap"
] | train | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java#L136-L141 |
YahooArchive/samoa | samoa-api/src/main/java/com/yahoo/labs/samoa/learners/classifiers/rules/distributed/AMRulesAggregatorProcessor.java | AMRulesAggregatorProcessor.newResultContentEvent | private ResultContentEvent newResultContentEvent(double[] prediction, InstanceContentEvent inEvent){
ResultContentEvent rce = new ResultContentEvent(inEvent.getInstanceIndex(), inEvent.getInstance(), inEvent.getClassId(), prediction, inEvent.isLastEvent());
rce.setClassifierIndex(this.processorId);
rce.setEvaluationIndex(inEvent.getEvaluationIndex());
return rce;
} | java | private ResultContentEvent newResultContentEvent(double[] prediction, InstanceContentEvent inEvent){
ResultContentEvent rce = new ResultContentEvent(inEvent.getInstanceIndex(), inEvent.getInstance(), inEvent.getClassId(), prediction, inEvent.isLastEvent());
rce.setClassifierIndex(this.processorId);
rce.setEvaluationIndex(inEvent.getEvaluationIndex());
return rce;
} | [
"private",
"ResultContentEvent",
"newResultContentEvent",
"(",
"double",
"[",
"]",
"prediction",
",",
"InstanceContentEvent",
"inEvent",
")",
"{",
"ResultContentEvent",
"rce",
"=",
"new",
"ResultContentEvent",
"(",
"inEvent",
".",
"getInstanceIndex",
"(",
")",
",",
"inEvent",
".",
"getInstance",
"(",
")",
",",
"inEvent",
".",
"getClassId",
"(",
")",
",",
"prediction",
",",
"inEvent",
".",
"isLastEvent",
"(",
")",
")",
";",
"rce",
".",
"setClassifierIndex",
"(",
"this",
".",
"processorId",
")",
";",
"rce",
".",
"setEvaluationIndex",
"(",
"inEvent",
".",
"getEvaluationIndex",
"(",
")",
")",
";",
"return",
"rce",
";",
"}"
] | Helper method to generate new ResultContentEvent based on an instance and
its prediction result.
@param prediction The predicted class label from the decision tree model.
@param inEvent The associated instance content event
@return ResultContentEvent to be sent into Evaluator PI or other destination PI. | [
"Helper",
"method",
"to",
"generate",
"new",
"ResultContentEvent",
"based",
"on",
"an",
"instance",
"and",
"its",
"prediction",
"result",
"."
] | train | https://github.com/YahooArchive/samoa/blob/540a2c30167ac85c432b593baabd5ca97e7e8a0f/samoa-api/src/main/java/com/yahoo/labs/samoa/learners/classifiers/rules/distributed/AMRulesAggregatorProcessor.java#L219-L224 |
stevespringett/Alpine | alpine/src/main/java/alpine/persistence/AbstractAlpineQueryManager.java | AbstractAlpineQueryManager.getObjectById | public <T> T getObjectById(Class<T> clazz, Object id) {
return pm.getObjectById(clazz, id);
} | java | public <T> T getObjectById(Class<T> clazz, Object id) {
return pm.getObjectById(clazz, id);
} | [
"public",
"<",
"T",
">",
"T",
"getObjectById",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"Object",
"id",
")",
"{",
"return",
"pm",
".",
"getObjectById",
"(",
"clazz",
",",
"id",
")",
";",
"}"
] | Retrieves an object by its ID.
@param <T> A type parameter. This type will be returned
@param clazz the persistence class to retrive the ID for
@param id the object id to retrieve
@return an object of the specified type
@since 1.0.0 | [
"Retrieves",
"an",
"object",
"by",
"its",
"ID",
"."
] | train | https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AbstractAlpineQueryManager.java#L503-L505 |
AltBeacon/android-beacon-library | lib/src/main/java/org/altbeacon/beacon/Beacon.java | Beacon.writeToParcel | @Deprecated
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mIdentifiers.size());
for (Identifier identifier: mIdentifiers) {
out.writeString(identifier == null ? null : identifier.toString());
}
out.writeDouble(getDistance());
out.writeInt(mRssi);
out.writeInt(mTxPower);
out.writeString(mBluetoothAddress);
out.writeInt(mBeaconTypeCode);
out.writeInt(mServiceUuid);
out.writeInt(mDataFields.size());
for (Long dataField: mDataFields) {
out.writeLong(dataField);
}
out.writeInt(mExtraDataFields.size());
for (Long dataField: mExtraDataFields) {
out.writeLong(dataField);
}
out.writeInt(mManufacturer);
out.writeString(mBluetoothName);
out.writeString(mParserIdentifier);
out.writeByte((byte) (mMultiFrameBeacon ? 1: 0));
out.writeValue(mRunningAverageRssi);
out.writeInt(mRssiMeasurementCount);
out.writeInt(mPacketCount);
} | java | @Deprecated
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mIdentifiers.size());
for (Identifier identifier: mIdentifiers) {
out.writeString(identifier == null ? null : identifier.toString());
}
out.writeDouble(getDistance());
out.writeInt(mRssi);
out.writeInt(mTxPower);
out.writeString(mBluetoothAddress);
out.writeInt(mBeaconTypeCode);
out.writeInt(mServiceUuid);
out.writeInt(mDataFields.size());
for (Long dataField: mDataFields) {
out.writeLong(dataField);
}
out.writeInt(mExtraDataFields.size());
for (Long dataField: mExtraDataFields) {
out.writeLong(dataField);
}
out.writeInt(mManufacturer);
out.writeString(mBluetoothName);
out.writeString(mParserIdentifier);
out.writeByte((byte) (mMultiFrameBeacon ? 1: 0));
out.writeValue(mRunningAverageRssi);
out.writeInt(mRssiMeasurementCount);
out.writeInt(mPacketCount);
} | [
"@",
"Deprecated",
"public",
"void",
"writeToParcel",
"(",
"Parcel",
"out",
",",
"int",
"flags",
")",
"{",
"out",
".",
"writeInt",
"(",
"mIdentifiers",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Identifier",
"identifier",
":",
"mIdentifiers",
")",
"{",
"out",
".",
"writeString",
"(",
"identifier",
"==",
"null",
"?",
"null",
":",
"identifier",
".",
"toString",
"(",
")",
")",
";",
"}",
"out",
".",
"writeDouble",
"(",
"getDistance",
"(",
")",
")",
";",
"out",
".",
"writeInt",
"(",
"mRssi",
")",
";",
"out",
".",
"writeInt",
"(",
"mTxPower",
")",
";",
"out",
".",
"writeString",
"(",
"mBluetoothAddress",
")",
";",
"out",
".",
"writeInt",
"(",
"mBeaconTypeCode",
")",
";",
"out",
".",
"writeInt",
"(",
"mServiceUuid",
")",
";",
"out",
".",
"writeInt",
"(",
"mDataFields",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Long",
"dataField",
":",
"mDataFields",
")",
"{",
"out",
".",
"writeLong",
"(",
"dataField",
")",
";",
"}",
"out",
".",
"writeInt",
"(",
"mExtraDataFields",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Long",
"dataField",
":",
"mExtraDataFields",
")",
"{",
"out",
".",
"writeLong",
"(",
"dataField",
")",
";",
"}",
"out",
".",
"writeInt",
"(",
"mManufacturer",
")",
";",
"out",
".",
"writeString",
"(",
"mBluetoothName",
")",
";",
"out",
".",
"writeString",
"(",
"mParserIdentifier",
")",
";",
"out",
".",
"writeByte",
"(",
"(",
"byte",
")",
"(",
"mMultiFrameBeacon",
"?",
"1",
":",
"0",
")",
")",
";",
"out",
".",
"writeValue",
"(",
"mRunningAverageRssi",
")",
";",
"out",
".",
"writeInt",
"(",
"mRssiMeasurementCount",
")",
";",
"out",
".",
"writeInt",
"(",
"mPacketCount",
")",
";",
"}"
] | Required for making object Parcelable. If you override this class, you must override this
method if you add any additional fields. | [
"Required",
"for",
"making",
"object",
"Parcelable",
".",
"If",
"you",
"override",
"this",
"class",
"you",
"must",
"override",
"this",
"method",
"if",
"you",
"add",
"any",
"additional",
"fields",
"."
] | train | https://github.com/AltBeacon/android-beacon-library/blob/f7f3a323ea7415d53e7bd695ff6a01f1501d5dc3/lib/src/main/java/org/altbeacon/beacon/Beacon.java#L612-L639 |
danidemi/jlubricant | jlubricant-embeddable-hsql/src/main/java/com/danidemi/jlubricant/embeddable/database/utils/DatasourceTemplate.java | DatasourceTemplate.queryForObject | public <T> T queryForObject(String sql, RowMapper<T> rowMapper) throws SQLException {
return (T) query(sql, rowMapper);
} | java | public <T> T queryForObject(String sql, RowMapper<T> rowMapper) throws SQLException {
return (T) query(sql, rowMapper);
} | [
"public",
"<",
"T",
">",
"T",
"queryForObject",
"(",
"String",
"sql",
",",
"RowMapper",
"<",
"T",
">",
"rowMapper",
")",
"throws",
"SQLException",
"{",
"return",
"(",
"T",
")",
"query",
"(",
"sql",
",",
"rowMapper",
")",
";",
"}"
] | Execute a query that return a single result obtained allowing the current row to be mapped through
the provided {@link RowMapper}.
@throws SQLException | [
"Execute",
"a",
"query",
"that",
"return",
"a",
"single",
"result",
"obtained",
"allowing",
"the",
"current",
"row",
"to",
"be",
"mapped",
"through",
"the",
"provided",
"{"
] | train | https://github.com/danidemi/jlubricant/blob/a9937c141c69ec34b768bd603b8093e496329b3a/jlubricant-embeddable-hsql/src/main/java/com/danidemi/jlubricant/embeddable/database/utils/DatasourceTemplate.java#L80-L82 |
liferay/com-liferay-commerce | commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationTemplatePersistenceImpl.java | CommerceNotificationTemplatePersistenceImpl.findAll | @Override
public List<CommerceNotificationTemplate> findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | java | @Override
public List<CommerceNotificationTemplate> findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceNotificationTemplate",
">",
"findAll",
"(",
")",
"{",
"return",
"findAll",
"(",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
";",
"}"
] | Returns all the commerce notification templates.
@return the commerce notification templates | [
"Returns",
"all",
"the",
"commerce",
"notification",
"templates",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationTemplatePersistenceImpl.java#L5161-L5164 |
aspectran/aspectran | core/src/main/java/com/aspectran/core/context/rule/ItemRule.java | ItemRule.addValue | public void addValue(Token[] tokens) {
if (type == null) {
type = ItemType.LIST;
}
if (!isListableType()) {
throw new IllegalArgumentException("The type of this item must be 'array', 'list' or 'set'");
}
if (tokensList == null) {
tokensList = new ArrayList<>();
}
tokensList.add(tokens);
} | java | public void addValue(Token[] tokens) {
if (type == null) {
type = ItemType.LIST;
}
if (!isListableType()) {
throw new IllegalArgumentException("The type of this item must be 'array', 'list' or 'set'");
}
if (tokensList == null) {
tokensList = new ArrayList<>();
}
tokensList.add(tokens);
} | [
"public",
"void",
"addValue",
"(",
"Token",
"[",
"]",
"tokens",
")",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"ItemType",
".",
"LIST",
";",
"}",
"if",
"(",
"!",
"isListableType",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The type of this item must be 'array', 'list' or 'set'\"",
")",
";",
"}",
"if",
"(",
"tokensList",
"==",
"null",
")",
"{",
"tokensList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"tokensList",
".",
"add",
"(",
"tokens",
")",
";",
"}"
] | Adds the specified value to this List type item.
@param tokens an array of tokens | [
"Adds",
"the",
"specified",
"value",
"to",
"this",
"List",
"type",
"item",
"."
] | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L324-L335 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/base64/Base64.java | Base64.decodeFileToFile | public static void decodeFileToFile (@Nonnull final String aInFile, @Nonnull final File aOutFile) throws IOException
{
final byte [] decoded = decodeFromFile (aInFile);
try (final OutputStream out = FileHelper.getBufferedOutputStream (aOutFile))
{
out.write (decoded);
}
} | java | public static void decodeFileToFile (@Nonnull final String aInFile, @Nonnull final File aOutFile) throws IOException
{
final byte [] decoded = decodeFromFile (aInFile);
try (final OutputStream out = FileHelper.getBufferedOutputStream (aOutFile))
{
out.write (decoded);
}
} | [
"public",
"static",
"void",
"decodeFileToFile",
"(",
"@",
"Nonnull",
"final",
"String",
"aInFile",
",",
"@",
"Nonnull",
"final",
"File",
"aOutFile",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"[",
"]",
"decoded",
"=",
"decodeFromFile",
"(",
"aInFile",
")",
";",
"try",
"(",
"final",
"OutputStream",
"out",
"=",
"FileHelper",
".",
"getBufferedOutputStream",
"(",
"aOutFile",
")",
")",
"{",
"out",
".",
"write",
"(",
"decoded",
")",
";",
"}",
"}"
] | Reads <code>infile</code> and decodes it to <code>outfile</code>.
@param aInFile
Input file
@param aOutFile
Output file
@throws IOException
if there is an error
@since 2.2 | [
"Reads",
"<code",
">",
"infile<",
"/",
"code",
">",
"and",
"decodes",
"it",
"to",
"<code",
">",
"outfile<",
"/",
"code",
">",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/base64/Base64.java#L2519-L2526 |
nguillaumin/slick2d-maven | slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java | GraphEditorWindow.registerValue | public void registerValue(LinearInterpolator value, String name) {
// add to properties combobox
properties.addItem(name);
// add to value map
values.put(name, value);
// set as current interpolator
panel.setInterpolator(value);
// enable all input fields
enableControls();
} | java | public void registerValue(LinearInterpolator value, String name) {
// add to properties combobox
properties.addItem(name);
// add to value map
values.put(name, value);
// set as current interpolator
panel.setInterpolator(value);
// enable all input fields
enableControls();
} | [
"public",
"void",
"registerValue",
"(",
"LinearInterpolator",
"value",
",",
"String",
"name",
")",
"{",
"// add to properties combobox\r",
"properties",
".",
"addItem",
"(",
"name",
")",
";",
"// add to value map\r",
"values",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"// set as current interpolator\r",
"panel",
".",
"setInterpolator",
"(",
"value",
")",
";",
"// enable all input fields\r",
"enableControls",
"(",
")",
";",
"}"
] | Register a configurable value with the graph panel
@param value The value to be registered
@param name The name to display for this value | [
"Register",
"a",
"configurable",
"value",
"with",
"the",
"graph",
"panel"
] | train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java#L260-L272 |
Alluxio/alluxio | underfs/cos/src/main/java/alluxio/underfs/cos/COSUnderFileSystem.java | COSUnderFileSystem.createInstance | public static COSUnderFileSystem createInstance(AlluxioURI uri, UnderFileSystemConfiguration conf,
AlluxioConfiguration alluxioConf)
throws Exception {
String bucketName = UnderFileSystemUtils.getBucketName(uri);
Preconditions.checkArgument(conf.isSet(PropertyKey.COS_ACCESS_KEY),
"Property %s is required to connect to COS", PropertyKey.COS_ACCESS_KEY);
Preconditions.checkArgument(conf.isSet(PropertyKey.COS_SECRET_KEY),
"Property %s is required to connect to COS", PropertyKey.COS_SECRET_KEY);
Preconditions.checkArgument(conf.isSet(PropertyKey.COS_REGION),
"Property %s is required to connect to COS", PropertyKey.COS_REGION);
Preconditions.checkArgument(conf.isSet(PropertyKey.COS_APP_ID),
"Property %s is required to connect to COS", PropertyKey.COS_APP_ID);
String accessKey = conf.get(PropertyKey.COS_ACCESS_KEY);
String secretKey = conf.get(PropertyKey.COS_SECRET_KEY);
String regionName = conf.get(PropertyKey.COS_REGION);
String appId = conf.get(PropertyKey.COS_APP_ID);
COSCredentials cred = new BasicCOSCredentials(accessKey, secretKey);
ClientConfig clientConfig = createCOSClientConfig(regionName, conf);
COSClient client = new COSClient(cred, clientConfig);
return new COSUnderFileSystem(uri, client, bucketName, appId, conf, alluxioConf);
} | java | public static COSUnderFileSystem createInstance(AlluxioURI uri, UnderFileSystemConfiguration conf,
AlluxioConfiguration alluxioConf)
throws Exception {
String bucketName = UnderFileSystemUtils.getBucketName(uri);
Preconditions.checkArgument(conf.isSet(PropertyKey.COS_ACCESS_KEY),
"Property %s is required to connect to COS", PropertyKey.COS_ACCESS_KEY);
Preconditions.checkArgument(conf.isSet(PropertyKey.COS_SECRET_KEY),
"Property %s is required to connect to COS", PropertyKey.COS_SECRET_KEY);
Preconditions.checkArgument(conf.isSet(PropertyKey.COS_REGION),
"Property %s is required to connect to COS", PropertyKey.COS_REGION);
Preconditions.checkArgument(conf.isSet(PropertyKey.COS_APP_ID),
"Property %s is required to connect to COS", PropertyKey.COS_APP_ID);
String accessKey = conf.get(PropertyKey.COS_ACCESS_KEY);
String secretKey = conf.get(PropertyKey.COS_SECRET_KEY);
String regionName = conf.get(PropertyKey.COS_REGION);
String appId = conf.get(PropertyKey.COS_APP_ID);
COSCredentials cred = new BasicCOSCredentials(accessKey, secretKey);
ClientConfig clientConfig = createCOSClientConfig(regionName, conf);
COSClient client = new COSClient(cred, clientConfig);
return new COSUnderFileSystem(uri, client, bucketName, appId, conf, alluxioConf);
} | [
"public",
"static",
"COSUnderFileSystem",
"createInstance",
"(",
"AlluxioURI",
"uri",
",",
"UnderFileSystemConfiguration",
"conf",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"throws",
"Exception",
"{",
"String",
"bucketName",
"=",
"UnderFileSystemUtils",
".",
"getBucketName",
"(",
"uri",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"COS_ACCESS_KEY",
")",
",",
"\"Property %s is required to connect to COS\"",
",",
"PropertyKey",
".",
"COS_ACCESS_KEY",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"COS_SECRET_KEY",
")",
",",
"\"Property %s is required to connect to COS\"",
",",
"PropertyKey",
".",
"COS_SECRET_KEY",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"COS_REGION",
")",
",",
"\"Property %s is required to connect to COS\"",
",",
"PropertyKey",
".",
"COS_REGION",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"COS_APP_ID",
")",
",",
"\"Property %s is required to connect to COS\"",
",",
"PropertyKey",
".",
"COS_APP_ID",
")",
";",
"String",
"accessKey",
"=",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"COS_ACCESS_KEY",
")",
";",
"String",
"secretKey",
"=",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"COS_SECRET_KEY",
")",
";",
"String",
"regionName",
"=",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"COS_REGION",
")",
";",
"String",
"appId",
"=",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"COS_APP_ID",
")",
";",
"COSCredentials",
"cred",
"=",
"new",
"BasicCOSCredentials",
"(",
"accessKey",
",",
"secretKey",
")",
";",
"ClientConfig",
"clientConfig",
"=",
"createCOSClientConfig",
"(",
"regionName",
",",
"conf",
")",
";",
"COSClient",
"client",
"=",
"new",
"COSClient",
"(",
"cred",
",",
"clientConfig",
")",
";",
"return",
"new",
"COSUnderFileSystem",
"(",
"uri",
",",
"client",
",",
"bucketName",
",",
"appId",
",",
"conf",
",",
"alluxioConf",
")",
";",
"}"
] | Constructs a new instance of {@link COSUnderFileSystem}.
@param uri the {@link AlluxioURI} for this UFS
@param conf the configuration for this UFS
@param alluxioConf Alluxio configuration
@return the created {@link COSUnderFileSystem} instance | [
"Constructs",
"a",
"new",
"instance",
"of",
"{",
"@link",
"COSUnderFileSystem",
"}",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/cos/src/main/java/alluxio/underfs/cos/COSUnderFileSystem.java#L75-L97 |
Harium/keel | src/main/java/com/harium/keel/catalano/math/distance/Distance.java | Distance.QuasiEuclidean | public static double QuasiEuclidean(IntPoint p, IntPoint q) {
return QuasiEuclidean(p.x, p.y, q.x, q.y);
} | java | public static double QuasiEuclidean(IntPoint p, IntPoint q) {
return QuasiEuclidean(p.x, p.y, q.x, q.y);
} | [
"public",
"static",
"double",
"QuasiEuclidean",
"(",
"IntPoint",
"p",
",",
"IntPoint",
"q",
")",
"{",
"return",
"QuasiEuclidean",
"(",
"p",
".",
"x",
",",
"p",
".",
"y",
",",
"q",
".",
"x",
",",
"q",
".",
"y",
")",
";",
"}"
] | Gets the Quasi-Euclidean distance between two points.
@param p IntPoint with X and Y axis coordinates.
@param q IntPoint with X and Y axis coordinates.
@return The Quasi Euclidean distance between p and q. | [
"Gets",
"the",
"Quasi",
"-",
"Euclidean",
"distance",
"between",
"two",
"points",
"."
] | train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L790-L792 |
joniles/mpxj | src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java | ProjectTreeController.addViews | private void addViews(MpxjTreeNode parentNode, ProjectFile file)
{
for (View view : file.getViews())
{
final View v = view;
MpxjTreeNode childNode = new MpxjTreeNode(view)
{
@Override public String toString()
{
return v.getName();
}
};
parentNode.add(childNode);
}
} | java | private void addViews(MpxjTreeNode parentNode, ProjectFile file)
{
for (View view : file.getViews())
{
final View v = view;
MpxjTreeNode childNode = new MpxjTreeNode(view)
{
@Override public String toString()
{
return v.getName();
}
};
parentNode.add(childNode);
}
} | [
"private",
"void",
"addViews",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectFile",
"file",
")",
"{",
"for",
"(",
"View",
"view",
":",
"file",
".",
"getViews",
"(",
")",
")",
"{",
"final",
"View",
"v",
"=",
"view",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"view",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"v",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"}",
"}"
] | Add views to the tree.
@param parentNode parent tree node
@param file views container | [
"Add",
"views",
"to",
"the",
"tree",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L398-L412 |
structurizr/java | structurizr-core/src/com/structurizr/model/Model.java | Model.addDeploymentNode | @Nonnull
public DeploymentNode addDeploymentNode(@Nullable String environment, @Nonnull String name, @Nullable String description, @Nullable String technology) {
return addDeploymentNode(environment, name, description, technology, 1);
} | java | @Nonnull
public DeploymentNode addDeploymentNode(@Nullable String environment, @Nonnull String name, @Nullable String description, @Nullable String technology) {
return addDeploymentNode(environment, name, description, technology, 1);
} | [
"@",
"Nonnull",
"public",
"DeploymentNode",
"addDeploymentNode",
"(",
"@",
"Nullable",
"String",
"environment",
",",
"@",
"Nonnull",
"String",
"name",
",",
"@",
"Nullable",
"String",
"description",
",",
"@",
"Nullable",
"String",
"technology",
")",
"{",
"return",
"addDeploymentNode",
"(",
"environment",
",",
"name",
",",
"description",
",",
"technology",
",",
"1",
")",
";",
"}"
] | Adds a top-level deployment node to this model.
@param environment the name of the deployment environment
@param name the name of the deployment node
@param description the description of the deployment node
@param technology the technology associated with the deployment node
@return a DeploymentNode instance
@throws IllegalArgumentException if the name is not specified, or a top-level deployment node with the same name already exists in the model | [
"Adds",
"a",
"top",
"-",
"level",
"deployment",
"node",
"to",
"this",
"model",
"."
] | train | https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/model/Model.java#L573-L576 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ReferenceUtil.java | ReferenceUtil.create | public static <T> Reference<T> create(ReferenceType type, T referent) {
return create(type, referent, null);
} | java | public static <T> Reference<T> create(ReferenceType type, T referent) {
return create(type, referent, null);
} | [
"public",
"static",
"<",
"T",
">",
"Reference",
"<",
"T",
">",
"create",
"(",
"ReferenceType",
"type",
",",
"T",
"referent",
")",
"{",
"return",
"create",
"(",
"type",
",",
"referent",
",",
"null",
")",
";",
"}"
] | 获得引用
@param <T> 被引用对象类型
@param type 引用类型枚举
@param referent 被引用对象
@return {@link Reference} | [
"获得引用"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReferenceUtil.java#L31-L33 |
jbundle/jbundle | app/program/screen/src/main/java/org/jbundle/app/program/screen/LayoutGridScreen.java | LayoutGridScreen.doCommand | public boolean doCommand(String strCommand, ScreenField sourceSField, int iCommandOptions)
{
if (strCommand.equalsIgnoreCase(MenuConstants.FORMDETAIL))
return (this.onForm(null, ScreenConstants.DETAIL_MODE, true, iCommandOptions, null) != null);
else if (strCommand.equalsIgnoreCase(MenuConstants.PRINT))
{
LayoutPrint layoutPrint = new LayoutPrint(this.getMainRecord(), null);
return true;
}
else
return super.doCommand(strCommand, sourceSField, iCommandOptions);
} | java | public boolean doCommand(String strCommand, ScreenField sourceSField, int iCommandOptions)
{
if (strCommand.equalsIgnoreCase(MenuConstants.FORMDETAIL))
return (this.onForm(null, ScreenConstants.DETAIL_MODE, true, iCommandOptions, null) != null);
else if (strCommand.equalsIgnoreCase(MenuConstants.PRINT))
{
LayoutPrint layoutPrint = new LayoutPrint(this.getMainRecord(), null);
return true;
}
else
return super.doCommand(strCommand, sourceSField, iCommandOptions);
} | [
"public",
"boolean",
"doCommand",
"(",
"String",
"strCommand",
",",
"ScreenField",
"sourceSField",
",",
"int",
"iCommandOptions",
")",
"{",
"if",
"(",
"strCommand",
".",
"equalsIgnoreCase",
"(",
"MenuConstants",
".",
"FORMDETAIL",
")",
")",
"return",
"(",
"this",
".",
"onForm",
"(",
"null",
",",
"ScreenConstants",
".",
"DETAIL_MODE",
",",
"true",
",",
"iCommandOptions",
",",
"null",
")",
"!=",
"null",
")",
";",
"else",
"if",
"(",
"strCommand",
".",
"equalsIgnoreCase",
"(",
"MenuConstants",
".",
"PRINT",
")",
")",
"{",
"LayoutPrint",
"layoutPrint",
"=",
"new",
"LayoutPrint",
"(",
"this",
".",
"getMainRecord",
"(",
")",
",",
"null",
")",
";",
"return",
"true",
";",
"}",
"else",
"return",
"super",
".",
"doCommand",
"(",
"strCommand",
",",
"sourceSField",
",",
"iCommandOptions",
")",
";",
"}"
] | Process the command.
<br />Step 1 - Process the command if possible and return true if processed.
<br />Step 2 - If I can't process, pass to all children (with me as the source).
<br />Step 3 - If children didn't process, pass to parent (with me as the source).
<br />Note: Never pass to a parent or child that matches the source (to avoid an endless loop).
@param strCommand The command to process.
@param sourceSField The source screen field (to avoid echos).
@param iCommandOptions If this command creates a new screen, create in a new window?
@return true if success. | [
"Process",
"the",
"command",
".",
"<br",
"/",
">",
"Step",
"1",
"-",
"Process",
"the",
"command",
"if",
"possible",
"and",
"return",
"true",
"if",
"processed",
".",
"<br",
"/",
">",
"Step",
"2",
"-",
"If",
"I",
"can",
"t",
"process",
"pass",
"to",
"all",
"children",
"(",
"with",
"me",
"as",
"the",
"source",
")",
".",
"<br",
"/",
">",
"Step",
"3",
"-",
"If",
"children",
"didn",
"t",
"process",
"pass",
"to",
"parent",
"(",
"with",
"me",
"as",
"the",
"source",
")",
".",
"<br",
"/",
">",
"Note",
":",
"Never",
"pass",
"to",
"a",
"parent",
"or",
"child",
"that",
"matches",
"the",
"source",
"(",
"to",
"avoid",
"an",
"endless",
"loop",
")",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/screen/src/main/java/org/jbundle/app/program/screen/LayoutGridScreen.java#L122-L133 |
teatrove/teatrove | tea/src/main/java/org/teatrove/tea/compiler/Compiler.java | Compiler.determineQualifiedName | private String determineQualifiedName(String name, CompilationUnit from) {
if (from != null) {
// Determine qualified name as being relative to "from"
String fromName = from.getName();
int index = fromName.lastIndexOf('.');
if (index >= 0) {
String qual = fromName.substring(0, index + 1) + name;
if (sourceExists(qual)) {
return qual;
}
}
}
if (sourceExists(name)) {
return name;
}
return null;
} | java | private String determineQualifiedName(String name, CompilationUnit from) {
if (from != null) {
// Determine qualified name as being relative to "from"
String fromName = from.getName();
int index = fromName.lastIndexOf('.');
if (index >= 0) {
String qual = fromName.substring(0, index + 1) + name;
if (sourceExists(qual)) {
return qual;
}
}
}
if (sourceExists(name)) {
return name;
}
return null;
} | [
"private",
"String",
"determineQualifiedName",
"(",
"String",
"name",
",",
"CompilationUnit",
"from",
")",
"{",
"if",
"(",
"from",
"!=",
"null",
")",
"{",
"// Determine qualified name as being relative to \"from\"",
"String",
"fromName",
"=",
"from",
".",
"getName",
"(",
")",
";",
"int",
"index",
"=",
"fromName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"String",
"qual",
"=",
"fromName",
".",
"substring",
"(",
"0",
",",
"index",
"+",
"1",
")",
"+",
"name",
";",
"if",
"(",
"sourceExists",
"(",
"qual",
")",
")",
"{",
"return",
"qual",
";",
"}",
"}",
"}",
"if",
"(",
"sourceExists",
"(",
"name",
")",
")",
"{",
"return",
"name",
";",
"}",
"return",
"null",
";",
"}"
] | Given a name, as requested by the given CompilationUnit, return a
fully qualified name or null if the name could not be found.
@param name requested name
@param from optional CompilationUnit | [
"Given",
"a",
"name",
"as",
"requested",
"by",
"the",
"given",
"CompilationUnit",
"return",
"a",
"fully",
"qualified",
"name",
"or",
"null",
"if",
"the",
"name",
"could",
"not",
"be",
"found",
"."
] | train | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Compiler.java#L793-L812 |
onelogin/onelogin-java-sdk | src/main/java/com/onelogin/sdk/conn/Client.java | Client.getUsersBatch | private String getUsersBatch(List<User> users, URIBuilder url, OAuthClientRequest bearerRequest,
OneloginOAuthJSONResourceResponse oAuthResponse) {
if (oAuthResponse.getResponseCode() == 200) {
JSONObject[] dataArray = oAuthResponse.getDataArray();
if (dataArray != null && dataArray.length > 0) {
for (JSONObject data : dataArray) {
users.add(new User(data));
}
}
return collectAfterCursor(url, bearerRequest, oAuthResponse);
} else {
error = oAuthResponse.getError();
errorDescription = oAuthResponse.getErrorDescription();
}
return null;
} | java | private String getUsersBatch(List<User> users, URIBuilder url, OAuthClientRequest bearerRequest,
OneloginOAuthJSONResourceResponse oAuthResponse) {
if (oAuthResponse.getResponseCode() == 200) {
JSONObject[] dataArray = oAuthResponse.getDataArray();
if (dataArray != null && dataArray.length > 0) {
for (JSONObject data : dataArray) {
users.add(new User(data));
}
}
return collectAfterCursor(url, bearerRequest, oAuthResponse);
} else {
error = oAuthResponse.getError();
errorDescription = oAuthResponse.getErrorDescription();
}
return null;
} | [
"private",
"String",
"getUsersBatch",
"(",
"List",
"<",
"User",
">",
"users",
",",
"URIBuilder",
"url",
",",
"OAuthClientRequest",
"bearerRequest",
",",
"OneloginOAuthJSONResourceResponse",
"oAuthResponse",
")",
"{",
"if",
"(",
"oAuthResponse",
".",
"getResponseCode",
"(",
")",
"==",
"200",
")",
"{",
"JSONObject",
"[",
"]",
"dataArray",
"=",
"oAuthResponse",
".",
"getDataArray",
"(",
")",
";",
"if",
"(",
"dataArray",
"!=",
"null",
"&&",
"dataArray",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"JSONObject",
"data",
":",
"dataArray",
")",
"{",
"users",
".",
"add",
"(",
"new",
"User",
"(",
"data",
")",
")",
";",
"}",
"}",
"return",
"collectAfterCursor",
"(",
"url",
",",
"bearerRequest",
",",
"oAuthResponse",
")",
";",
"}",
"else",
"{",
"error",
"=",
"oAuthResponse",
".",
"getError",
"(",
")",
";",
"errorDescription",
"=",
"oAuthResponse",
".",
"getErrorDescription",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get a batch of Users.
@param users
@param url
@param bearerRequest
@param oAuthResponse
@return The Batch reference
@see com.onelogin.sdk.model.User
@see <a target="_blank" href="https://developers.onelogin.com/api-docs/1/users/get-users">Get Users documentation</a> | [
"Get",
"a",
"batch",
"of",
"Users",
"."
] | train | https://github.com/onelogin/onelogin-java-sdk/blob/1570b78033dcc1c7387099e77fe41b6b0638df8c/src/main/java/com/onelogin/sdk/conn/Client.java#L418-L434 |
michel-kraemer/citeproc-java | citeproc-java/src/main/java/de/undercouch/citeproc/CSL.java | CSL.registerCitationItems | public void registerCitationItems(String... ids) {
try {
runner.callMethod(engine, "updateItems", new Object[] { ids });
} catch (ScriptRunnerException e) {
throw new IllegalArgumentException("Could not update items", e);
}
} | java | public void registerCitationItems(String... ids) {
try {
runner.callMethod(engine, "updateItems", new Object[] { ids });
} catch (ScriptRunnerException e) {
throw new IllegalArgumentException("Could not update items", e);
}
} | [
"public",
"void",
"registerCitationItems",
"(",
"String",
"...",
"ids",
")",
"{",
"try",
"{",
"runner",
".",
"callMethod",
"(",
"engine",
",",
"\"updateItems\"",
",",
"new",
"Object",
"[",
"]",
"{",
"ids",
"}",
")",
";",
"}",
"catch",
"(",
"ScriptRunnerException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Could not update items\"",
",",
"e",
")",
";",
"}",
"}"
] | Introduces the given citation IDs to the processor. The processor will
call {@link ItemDataProvider#retrieveItem(String)} for each ID to get
the respective citation item. The retrieved items will be added to the
bibliography, so you don't have to call {@link #makeCitation(String...)}
for each of them anymore.
@param ids the IDs to register
@throws IllegalArgumentException if one of the given IDs refers to
citation item data that does not exist | [
"Introduces",
"the",
"given",
"citation",
"IDs",
"to",
"the",
"processor",
".",
"The",
"processor",
"will",
"call",
"{"
] | train | https://github.com/michel-kraemer/citeproc-java/blob/1d5bf0e7bbb2bdc47309530babf0ecaba838bf10/citeproc-java/src/main/java/de/undercouch/citeproc/CSL.java#L611-L617 |
groovy/groovy-core | src/main/org/codehaus/groovy/ast/ClassNode.java | ClassNode.hasPossibleMethod | public boolean hasPossibleMethod(String name, Expression arguments) {
int count = 0;
if (arguments instanceof TupleExpression) {
TupleExpression tuple = (TupleExpression) arguments;
// TODO this won't strictly be true when using list expansion in argument calls
count = tuple.getExpressions().size();
}
ClassNode node = this;
do {
for (MethodNode method : getMethods(name)) {
if (method.getParameters().length == count && !method.isStatic()) {
return true;
}
}
node = node.getSuperClass();
}
while (node != null);
return false;
} | java | public boolean hasPossibleMethod(String name, Expression arguments) {
int count = 0;
if (arguments instanceof TupleExpression) {
TupleExpression tuple = (TupleExpression) arguments;
// TODO this won't strictly be true when using list expansion in argument calls
count = tuple.getExpressions().size();
}
ClassNode node = this;
do {
for (MethodNode method : getMethods(name)) {
if (method.getParameters().length == count && !method.isStatic()) {
return true;
}
}
node = node.getSuperClass();
}
while (node != null);
return false;
} | [
"public",
"boolean",
"hasPossibleMethod",
"(",
"String",
"name",
",",
"Expression",
"arguments",
")",
"{",
"int",
"count",
"=",
"0",
";",
"if",
"(",
"arguments",
"instanceof",
"TupleExpression",
")",
"{",
"TupleExpression",
"tuple",
"=",
"(",
"TupleExpression",
")",
"arguments",
";",
"// TODO this won't strictly be true when using list expansion in argument calls",
"count",
"=",
"tuple",
".",
"getExpressions",
"(",
")",
".",
"size",
"(",
")",
";",
"}",
"ClassNode",
"node",
"=",
"this",
";",
"do",
"{",
"for",
"(",
"MethodNode",
"method",
":",
"getMethods",
"(",
"name",
")",
")",
"{",
"if",
"(",
"method",
".",
"getParameters",
"(",
")",
".",
"length",
"==",
"count",
"&&",
"!",
"method",
".",
"isStatic",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"node",
"=",
"node",
".",
"getSuperClass",
"(",
")",
";",
"}",
"while",
"(",
"node",
"!=",
"null",
")",
";",
"return",
"false",
";",
"}"
] | Returns true if the given method has a possibly matching instance method with the given name and arguments.
@param name the name of the method of interest
@param arguments the arguments to match against
@return true if a matching method was found | [
"Returns",
"true",
"if",
"the",
"given",
"method",
"has",
"a",
"possibly",
"matching",
"instance",
"method",
"with",
"the",
"given",
"name",
"and",
"arguments",
"."
] | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/ast/ClassNode.java#L1221-L1240 |
WASdev/standards.jsr352.jbatch | com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java | JDBCPersistenceManagerImpl.createIfNotExists | private void createIfNotExists(String tableName, String createTableStatement) throws SQLException {
logger.entering(CLASSNAME, "createIfNotExists", new Object[] {tableName, createTableStatement});
Connection conn = getConnection();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getTables(null, schema, tableName, null);
PreparedStatement ps = null;
if(!rs.next()) {
logger.log(Level.INFO, tableName + " table does not exists. Trying to create it.");
ps = conn.prepareStatement(createTableStatement);
ps.executeUpdate();
}
cleanupConnection(conn, rs, ps);
logger.exiting(CLASSNAME, "createIfNotExists");
} | java | private void createIfNotExists(String tableName, String createTableStatement) throws SQLException {
logger.entering(CLASSNAME, "createIfNotExists", new Object[] {tableName, createTableStatement});
Connection conn = getConnection();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getTables(null, schema, tableName, null);
PreparedStatement ps = null;
if(!rs.next()) {
logger.log(Level.INFO, tableName + " table does not exists. Trying to create it.");
ps = conn.prepareStatement(createTableStatement);
ps.executeUpdate();
}
cleanupConnection(conn, rs, ps);
logger.exiting(CLASSNAME, "createIfNotExists");
} | [
"private",
"void",
"createIfNotExists",
"(",
"String",
"tableName",
",",
"String",
"createTableStatement",
")",
"throws",
"SQLException",
"{",
"logger",
".",
"entering",
"(",
"CLASSNAME",
",",
"\"createIfNotExists\"",
",",
"new",
"Object",
"[",
"]",
"{",
"tableName",
",",
"createTableStatement",
"}",
")",
";",
"Connection",
"conn",
"=",
"getConnection",
"(",
")",
";",
"DatabaseMetaData",
"dbmd",
"=",
"conn",
".",
"getMetaData",
"(",
")",
";",
"ResultSet",
"rs",
"=",
"dbmd",
".",
"getTables",
"(",
"null",
",",
"schema",
",",
"tableName",
",",
"null",
")",
";",
"PreparedStatement",
"ps",
"=",
"null",
";",
"if",
"(",
"!",
"rs",
".",
"next",
"(",
")",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"tableName",
"+",
"\" table does not exists. Trying to create it.\"",
")",
";",
"ps",
"=",
"conn",
".",
"prepareStatement",
"(",
"createTableStatement",
")",
";",
"ps",
".",
"executeUpdate",
"(",
")",
";",
"}",
"cleanupConnection",
"(",
"conn",
",",
"rs",
",",
"ps",
")",
";",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"createIfNotExists\"",
")",
";",
"}"
] | Creates tableName using the createTableStatement DDL.
@param tableName
@param createTableStatement
@throws SQLException | [
"Creates",
"tableName",
"using",
"the",
"createTableStatement",
"DDL",
"."
] | train | https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L238-L253 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java | SuspiciousComparatorReturnValues.visitCode | @Override
public void visitCode(Code obj) {
if (getMethod().isSynthetic()) {
return;
}
String methodName = getMethodName();
String methodSig = getMethodSig();
if (methodName.equals(methodInfo.methodName) && methodSig.endsWith(methodInfo.signatureEnding)
&& (SignatureUtils.getNumParameters(methodSig) == methodInfo.argumentCount)) {
stack.resetForMethodEntry(this);
seenNegative = false;
seenPositive = false;
seenZero = false;
seenUnconditionalNonZero = false;
furthestBranchTarget = -1;
sawConstant = null;
try {
super.visitCode(obj);
if (!seenZero || seenUnconditionalNonZero || (obj.getCode().length > 2)) {
boolean seenAll = seenNegative & seenPositive & seenZero;
if (!seenAll || seenUnconditionalNonZero) {
bugReporter.reportBug(
new BugInstance(this, BugType.SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES.name(), seenAll ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this, 0));
}
}
} catch (StopOpcodeParsingException e) {
// indeterminate
}
}
} | java | @Override
public void visitCode(Code obj) {
if (getMethod().isSynthetic()) {
return;
}
String methodName = getMethodName();
String methodSig = getMethodSig();
if (methodName.equals(methodInfo.methodName) && methodSig.endsWith(methodInfo.signatureEnding)
&& (SignatureUtils.getNumParameters(methodSig) == methodInfo.argumentCount)) {
stack.resetForMethodEntry(this);
seenNegative = false;
seenPositive = false;
seenZero = false;
seenUnconditionalNonZero = false;
furthestBranchTarget = -1;
sawConstant = null;
try {
super.visitCode(obj);
if (!seenZero || seenUnconditionalNonZero || (obj.getCode().length > 2)) {
boolean seenAll = seenNegative & seenPositive & seenZero;
if (!seenAll || seenUnconditionalNonZero) {
bugReporter.reportBug(
new BugInstance(this, BugType.SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES.name(), seenAll ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this, 0));
}
}
} catch (StopOpcodeParsingException e) {
// indeterminate
}
}
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"if",
"(",
"getMethod",
"(",
")",
".",
"isSynthetic",
"(",
")",
")",
"{",
"return",
";",
"}",
"String",
"methodName",
"=",
"getMethodName",
"(",
")",
";",
"String",
"methodSig",
"=",
"getMethodSig",
"(",
")",
";",
"if",
"(",
"methodName",
".",
"equals",
"(",
"methodInfo",
".",
"methodName",
")",
"&&",
"methodSig",
".",
"endsWith",
"(",
"methodInfo",
".",
"signatureEnding",
")",
"&&",
"(",
"SignatureUtils",
".",
"getNumParameters",
"(",
"methodSig",
")",
"==",
"methodInfo",
".",
"argumentCount",
")",
")",
"{",
"stack",
".",
"resetForMethodEntry",
"(",
"this",
")",
";",
"seenNegative",
"=",
"false",
";",
"seenPositive",
"=",
"false",
";",
"seenZero",
"=",
"false",
";",
"seenUnconditionalNonZero",
"=",
"false",
";",
"furthestBranchTarget",
"=",
"-",
"1",
";",
"sawConstant",
"=",
"null",
";",
"try",
"{",
"super",
".",
"visitCode",
"(",
"obj",
")",
";",
"if",
"(",
"!",
"seenZero",
"||",
"seenUnconditionalNonZero",
"||",
"(",
"obj",
".",
"getCode",
"(",
")",
".",
"length",
">",
"2",
")",
")",
"{",
"boolean",
"seenAll",
"=",
"seenNegative",
"&",
"seenPositive",
"&",
"seenZero",
";",
"if",
"(",
"!",
"seenAll",
"||",
"seenUnconditionalNonZero",
")",
"{",
"bugReporter",
".",
"reportBug",
"(",
"new",
"BugInstance",
"(",
"this",
",",
"BugType",
".",
"SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES",
".",
"name",
"(",
")",
",",
"seenAll",
"?",
"LOW_PRIORITY",
":",
"NORMAL_PRIORITY",
")",
".",
"addClass",
"(",
"this",
")",
".",
"addMethod",
"(",
"this",
")",
".",
"addSourceLine",
"(",
"this",
",",
"0",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"StopOpcodeParsingException",
"e",
")",
"{",
"// indeterminate",
"}",
"}",
"}"
] | implements the visitor to check to see what Const were returned from a comparator. If no Const were returned it can't determine anything, however if only
Const were returned, it looks to see if negative positive and zero was returned. It also looks to see if a non zero value is returned unconditionally.
While it is possible that later check is ok, it usually means something is wrong.
@param obj
the currently parsed code block | [
"implements",
"the",
"visitor",
"to",
"check",
"to",
"see",
"what",
"Const",
"were",
"returned",
"from",
"a",
"comparator",
".",
"If",
"no",
"Const",
"were",
"returned",
"it",
"can",
"t",
"determine",
"anything",
"however",
"if",
"only",
"Const",
"were",
"returned",
"it",
"looks",
"to",
"see",
"if",
"negative",
"positive",
"and",
"zero",
"was",
"returned",
".",
"It",
"also",
"looks",
"to",
"see",
"if",
"a",
"non",
"zero",
"value",
"is",
"returned",
"unconditionally",
".",
"While",
"it",
"is",
"possible",
"that",
"later",
"check",
"is",
"ok",
"it",
"usually",
"means",
"something",
"is",
"wrong",
"."
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java#L119-L150 |
goldmansachs/gs-collections | collections/src/main/java/com/gs/collections/impl/utility/MapIterate.java | MapIterate.injectIntoIf | public static <IV, K, V> IV injectIntoIf(
IV initialValue,
Map<K, V> map,
final Predicate<? super V> predicate,
final Function2<? super IV, ? super V, ? extends IV> function)
{
Function2<IV, ? super V, IV> ifFunction = new Function2<IV, V, IV>()
{
public IV value(IV accumulator, V item)
{
if (predicate.accept(item))
{
return function.value(accumulator, item);
}
return accumulator;
}
};
return Iterate.injectInto(initialValue, map.values(), ifFunction);
} | java | public static <IV, K, V> IV injectIntoIf(
IV initialValue,
Map<K, V> map,
final Predicate<? super V> predicate,
final Function2<? super IV, ? super V, ? extends IV> function)
{
Function2<IV, ? super V, IV> ifFunction = new Function2<IV, V, IV>()
{
public IV value(IV accumulator, V item)
{
if (predicate.accept(item))
{
return function.value(accumulator, item);
}
return accumulator;
}
};
return Iterate.injectInto(initialValue, map.values(), ifFunction);
} | [
"public",
"static",
"<",
"IV",
",",
"K",
",",
"V",
">",
"IV",
"injectIntoIf",
"(",
"IV",
"initialValue",
",",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"final",
"Predicate",
"<",
"?",
"super",
"V",
">",
"predicate",
",",
"final",
"Function2",
"<",
"?",
"super",
"IV",
",",
"?",
"super",
"V",
",",
"?",
"extends",
"IV",
">",
"function",
")",
"{",
"Function2",
"<",
"IV",
",",
"?",
"super",
"V",
",",
"IV",
">",
"ifFunction",
"=",
"new",
"Function2",
"<",
"IV",
",",
"V",
",",
"IV",
">",
"(",
")",
"{",
"public",
"IV",
"value",
"(",
"IV",
"accumulator",
",",
"V",
"item",
")",
"{",
"if",
"(",
"predicate",
".",
"accept",
"(",
"item",
")",
")",
"{",
"return",
"function",
".",
"value",
"(",
"accumulator",
",",
"item",
")",
";",
"}",
"return",
"accumulator",
";",
"}",
"}",
";",
"return",
"Iterate",
".",
"injectInto",
"(",
"initialValue",
",",
"map",
".",
"values",
"(",
")",
",",
"ifFunction",
")",
";",
"}"
] | Same as {@link #injectInto(Object, Map, Function2)}, but only applies the value to the function
if the predicate returns true for the value.
@see #injectInto(Object, Map, Function2) | [
"Same",
"as",
"{",
"@link",
"#injectInto",
"(",
"Object",
"Map",
"Function2",
")",
"}",
"but",
"only",
"applies",
"the",
"value",
"to",
"the",
"function",
"if",
"the",
"predicate",
"returns",
"true",
"for",
"the",
"value",
"."
] | train | https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/MapIterate.java#L929-L947 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.addPrebuilt | public List<PrebuiltEntityExtractor> addPrebuilt(UUID appId, String versionId, List<String> prebuiltExtractorNames) {
return addPrebuiltWithServiceResponseAsync(appId, versionId, prebuiltExtractorNames).toBlocking().single().body();
} | java | public List<PrebuiltEntityExtractor> addPrebuilt(UUID appId, String versionId, List<String> prebuiltExtractorNames) {
return addPrebuiltWithServiceResponseAsync(appId, versionId, prebuiltExtractorNames).toBlocking().single().body();
} | [
"public",
"List",
"<",
"PrebuiltEntityExtractor",
">",
"addPrebuilt",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"List",
"<",
"String",
">",
"prebuiltExtractorNames",
")",
"{",
"return",
"addPrebuiltWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"prebuiltExtractorNames",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Adds a list of prebuilt entity extractors to the application.
@param appId The application ID.
@param versionId The version ID.
@param prebuiltExtractorNames An array of prebuilt entity extractor names.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<PrebuiltEntityExtractor> object if successful. | [
"Adds",
"a",
"list",
"of",
"prebuilt",
"entity",
"extractors",
"to",
"the",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L2090-L2092 |
banq/jdonframework | src/main/java/com/jdon/container/pico/JdonPicoContainer.java | JdonPicoContainer.registerComponentImplementation | public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation) throws PicoRegistrationException {
return registerComponentImplementation(componentKey, componentImplementation, (Parameter[]) null);
} | java | public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation) throws PicoRegistrationException {
return registerComponentImplementation(componentKey, componentImplementation, (Parameter[]) null);
} | [
"public",
"ComponentAdapter",
"registerComponentImplementation",
"(",
"Object",
"componentKey",
",",
"Class",
"componentImplementation",
")",
"throws",
"PicoRegistrationException",
"{",
"return",
"registerComponentImplementation",
"(",
"componentKey",
",",
"componentImplementation",
",",
"(",
"Parameter",
"[",
"]",
")",
"null",
")",
";",
"}"
] | {@inheritDoc} The returned ComponentAdapter will be instantiated by the
{@link ComponentAdapterFactory} passed to the container's constructor. | [
"{"
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/pico/JdonPicoContainer.java#L258-L260 |
Azure/azure-sdk-for-java | network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/VirtualNetworkGatewayConnectionsInner.java | VirtualNetworkGatewayConnectionsInner.getSharedKey | public ConnectionSharedKeyInner getSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) {
return getSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().single().body();
} | java | public ConnectionSharedKeyInner getSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) {
return getSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().single().body();
} | [
"public",
"ConnectionSharedKeyInner",
"getSharedKey",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayConnectionName",
")",
"{",
"return",
"getSharedKeyWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayConnectionName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayConnectionName The virtual network gateway connection shared key name.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ConnectionSharedKeyInner object if successful. | [
"The",
"Get",
"VirtualNetworkGatewayConnectionSharedKey",
"operation",
"retrieves",
"information",
"about",
"the",
"specified",
"virtual",
"network",
"gateway",
"connection",
"shared",
"key",
"through",
"Network",
"resource",
"provider",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/VirtualNetworkGatewayConnectionsInner.java#L1025-L1027 |
cdk/cdk | tool/charges/src/main/java/org/openscience/cdk/charges/GasteigerPEPEPartialCharges.java | GasteigerPEPEPartialCharges.setAntiFlags | private IAtomContainer setAntiFlags(IAtomContainer container, IAtomContainer ac, int number, boolean b) {
IBond bond = ac.getBond(number);
if (!container.contains(bond)) {
bond.setFlag(CDKConstants.REACTIVE_CENTER, b);
bond.getBegin().setFlag(CDKConstants.REACTIVE_CENTER, b);
bond.getEnd().setFlag(CDKConstants.REACTIVE_CENTER, b);
} else
return null;
return ac;
} | java | private IAtomContainer setAntiFlags(IAtomContainer container, IAtomContainer ac, int number, boolean b) {
IBond bond = ac.getBond(number);
if (!container.contains(bond)) {
bond.setFlag(CDKConstants.REACTIVE_CENTER, b);
bond.getBegin().setFlag(CDKConstants.REACTIVE_CENTER, b);
bond.getEnd().setFlag(CDKConstants.REACTIVE_CENTER, b);
} else
return null;
return ac;
} | [
"private",
"IAtomContainer",
"setAntiFlags",
"(",
"IAtomContainer",
"container",
",",
"IAtomContainer",
"ac",
",",
"int",
"number",
",",
"boolean",
"b",
")",
"{",
"IBond",
"bond",
"=",
"ac",
".",
"getBond",
"(",
"number",
")",
";",
"if",
"(",
"!",
"container",
".",
"contains",
"(",
"bond",
")",
")",
"{",
"bond",
".",
"setFlag",
"(",
"CDKConstants",
".",
"REACTIVE_CENTER",
",",
"b",
")",
";",
"bond",
".",
"getBegin",
"(",
")",
".",
"setFlag",
"(",
"CDKConstants",
".",
"REACTIVE_CENTER",
",",
"b",
")",
";",
"bond",
".",
"getEnd",
"(",
")",
".",
"setFlag",
"(",
"CDKConstants",
".",
"REACTIVE_CENTER",
",",
"b",
")",
";",
"}",
"else",
"return",
"null",
";",
"return",
"ac",
";",
"}"
] | Set the Flags to atoms and bonds which are not contained
in an atomContainer.
@param container Container with the flags
@param ac Container to put the flags
@param b True, if the the flag is true
@return Container with added flags | [
"Set",
"the",
"Flags",
"to",
"atoms",
"and",
"bonds",
"which",
"are",
"not",
"contained",
"in",
"an",
"atomContainer",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/charges/src/main/java/org/openscience/cdk/charges/GasteigerPEPEPartialCharges.java#L497-L506 |
GerdHolz/TOVAL | src/de/invation/code/toval/graphic/renderer/DefaultTableHeaderCellRenderer.java | DefaultTableHeaderCellRenderer.getIcon | @SuppressWarnings("incomplete-switch")
protected Icon getIcon(JTable table, int column) {
SortKey sortKey = getSortKey(table, column);
if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
}
}
return null;
} | java | @SuppressWarnings("incomplete-switch")
protected Icon getIcon(JTable table, int column) {
SortKey sortKey = getSortKey(table, column);
if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
}
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"incomplete-switch\"",
")",
"protected",
"Icon",
"getIcon",
"(",
"JTable",
"table",
",",
"int",
"column",
")",
"{",
"SortKey",
"sortKey",
"=",
"getSortKey",
"(",
"table",
",",
"column",
")",
";",
"if",
"(",
"sortKey",
"!=",
"null",
"&&",
"table",
".",
"convertColumnIndexToView",
"(",
"sortKey",
".",
"getColumn",
"(",
")",
")",
"==",
"column",
")",
"{",
"switch",
"(",
"sortKey",
".",
"getSortOrder",
"(",
")",
")",
"{",
"case",
"ASCENDING",
":",
"return",
"UIManager",
".",
"getIcon",
"(",
"\"Table.ascendingSortIcon\"",
")",
";",
"case",
"DESCENDING",
":",
"return",
"UIManager",
".",
"getIcon",
"(",
"\"Table.descendingSortIcon\"",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Overloaded to return an icon suitable to the primary sorted column, or null if
the column is not the primary sort key.
@param table the <code>JTable</code>.
@param column the column index.
@return the sort icon, or null if the column is unsorted. | [
"Overloaded",
"to",
"return",
"an",
"icon",
"suitable",
"to",
"the",
"primary",
"sorted",
"column",
"or",
"null",
"if",
"the",
"column",
"is",
"not",
"the",
"primary",
"sort",
"key",
"."
] | train | https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/renderer/DefaultTableHeaderCellRenderer.java#L80-L92 |
apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/lineage/LineageInfo.java | LineageInfo.putDestination | public void putDestination(List<Descriptor> descriptors, int branchId, State state) {
if (!hasLineageInfo(state)) {
log.warn("State has no lineage info but branch " + branchId + " puts {} descriptors", descriptors.size());
return;
}
log.info(String.format("Put destination %s for branch %d", Descriptor.toJson(descriptors), branchId));
synchronized (state.getProp(getKey(NAME_KEY))) {
List<Descriptor> resolvedDescriptors = new ArrayList<>();
for (Descriptor descriptor : descriptors) {
Descriptor resolvedDescriptor = resolver.resolve(descriptor, state);
if (resolvedDescriptor == null) {
continue;
}
resolvedDescriptors.add(resolvedDescriptor);
}
String destinationKey = getKey(BRANCH, branchId, LineageEventBuilder.DESTINATION);
String currentDestinations = state.getProp(destinationKey);
List<Descriptor> allDescriptors = Lists.newArrayList();
if (StringUtils.isNotEmpty(currentDestinations)) {
allDescriptors = Descriptor.fromJsonList(currentDestinations);
}
allDescriptors.addAll(resolvedDescriptors);
state.setProp(destinationKey, Descriptor.toJson(allDescriptors));
}
} | java | public void putDestination(List<Descriptor> descriptors, int branchId, State state) {
if (!hasLineageInfo(state)) {
log.warn("State has no lineage info but branch " + branchId + " puts {} descriptors", descriptors.size());
return;
}
log.info(String.format("Put destination %s for branch %d", Descriptor.toJson(descriptors), branchId));
synchronized (state.getProp(getKey(NAME_KEY))) {
List<Descriptor> resolvedDescriptors = new ArrayList<>();
for (Descriptor descriptor : descriptors) {
Descriptor resolvedDescriptor = resolver.resolve(descriptor, state);
if (resolvedDescriptor == null) {
continue;
}
resolvedDescriptors.add(resolvedDescriptor);
}
String destinationKey = getKey(BRANCH, branchId, LineageEventBuilder.DESTINATION);
String currentDestinations = state.getProp(destinationKey);
List<Descriptor> allDescriptors = Lists.newArrayList();
if (StringUtils.isNotEmpty(currentDestinations)) {
allDescriptors = Descriptor.fromJsonList(currentDestinations);
}
allDescriptors.addAll(resolvedDescriptors);
state.setProp(destinationKey, Descriptor.toJson(allDescriptors));
}
} | [
"public",
"void",
"putDestination",
"(",
"List",
"<",
"Descriptor",
">",
"descriptors",
",",
"int",
"branchId",
",",
"State",
"state",
")",
"{",
"if",
"(",
"!",
"hasLineageInfo",
"(",
"state",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"State has no lineage info but branch \"",
"+",
"branchId",
"+",
"\" puts {} descriptors\"",
",",
"descriptors",
".",
"size",
"(",
")",
")",
";",
"return",
";",
"}",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Put destination %s for branch %d\"",
",",
"Descriptor",
".",
"toJson",
"(",
"descriptors",
")",
",",
"branchId",
")",
")",
";",
"synchronized",
"(",
"state",
".",
"getProp",
"(",
"getKey",
"(",
"NAME_KEY",
")",
")",
")",
"{",
"List",
"<",
"Descriptor",
">",
"resolvedDescriptors",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Descriptor",
"descriptor",
":",
"descriptors",
")",
"{",
"Descriptor",
"resolvedDescriptor",
"=",
"resolver",
".",
"resolve",
"(",
"descriptor",
",",
"state",
")",
";",
"if",
"(",
"resolvedDescriptor",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"resolvedDescriptors",
".",
"add",
"(",
"resolvedDescriptor",
")",
";",
"}",
"String",
"destinationKey",
"=",
"getKey",
"(",
"BRANCH",
",",
"branchId",
",",
"LineageEventBuilder",
".",
"DESTINATION",
")",
";",
"String",
"currentDestinations",
"=",
"state",
".",
"getProp",
"(",
"destinationKey",
")",
";",
"List",
"<",
"Descriptor",
">",
"allDescriptors",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"currentDestinations",
")",
")",
"{",
"allDescriptors",
"=",
"Descriptor",
".",
"fromJsonList",
"(",
"currentDestinations",
")",
";",
"}",
"allDescriptors",
".",
"addAll",
"(",
"resolvedDescriptors",
")",
";",
"state",
".",
"setProp",
"(",
"destinationKey",
",",
"Descriptor",
".",
"toJson",
"(",
"allDescriptors",
")",
")",
";",
"}",
"}"
] | Put data {@link Descriptor}s of a destination dataset to a state
@param descriptors It can be a single item list which just has the dataset descriptor or a list
of dataset partition descriptors | [
"Put",
"data",
"{",
"@link",
"Descriptor",
"}",
"s",
"of",
"a",
"destination",
"dataset",
"to",
"a",
"state"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/lineage/LineageInfo.java#L144-L173 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hllmap/CouponHashMap.java | CouponHashMap.findKey | @Override
int findKey(final byte[] key) {
final long[] hash = MurmurHash3.hash(key, SEED);
int entryIndex = getIndex(hash[0], tableEntries_);
int firstDeletedIndex = -1;
final int loopIndex = entryIndex;
do {
if (curCountsArr_[entryIndex] == 0) {
return firstDeletedIndex == -1 ? ~entryIndex : ~firstDeletedIndex; // found empty or deleted
}
if (curCountsArr_[entryIndex] == DELETED_KEY_MARKER) {
if (firstDeletedIndex == -1) {
firstDeletedIndex = entryIndex;
}
} else if (Map.arraysEqual(keysArr_, entryIndex * keySizeBytes_, key, 0, keySizeBytes_)) {
return entryIndex; // found key
}
entryIndex = (entryIndex + getStride(hash[1], tableEntries_)) % tableEntries_;
} while (entryIndex != loopIndex);
throw new SketchesArgumentException("Key not found and no empty slots!");
} | java | @Override
int findKey(final byte[] key) {
final long[] hash = MurmurHash3.hash(key, SEED);
int entryIndex = getIndex(hash[0], tableEntries_);
int firstDeletedIndex = -1;
final int loopIndex = entryIndex;
do {
if (curCountsArr_[entryIndex] == 0) {
return firstDeletedIndex == -1 ? ~entryIndex : ~firstDeletedIndex; // found empty or deleted
}
if (curCountsArr_[entryIndex] == DELETED_KEY_MARKER) {
if (firstDeletedIndex == -1) {
firstDeletedIndex = entryIndex;
}
} else if (Map.arraysEqual(keysArr_, entryIndex * keySizeBytes_, key, 0, keySizeBytes_)) {
return entryIndex; // found key
}
entryIndex = (entryIndex + getStride(hash[1], tableEntries_)) % tableEntries_;
} while (entryIndex != loopIndex);
throw new SketchesArgumentException("Key not found and no empty slots!");
} | [
"@",
"Override",
"int",
"findKey",
"(",
"final",
"byte",
"[",
"]",
"key",
")",
"{",
"final",
"long",
"[",
"]",
"hash",
"=",
"MurmurHash3",
".",
"hash",
"(",
"key",
",",
"SEED",
")",
";",
"int",
"entryIndex",
"=",
"getIndex",
"(",
"hash",
"[",
"0",
"]",
",",
"tableEntries_",
")",
";",
"int",
"firstDeletedIndex",
"=",
"-",
"1",
";",
"final",
"int",
"loopIndex",
"=",
"entryIndex",
";",
"do",
"{",
"if",
"(",
"curCountsArr_",
"[",
"entryIndex",
"]",
"==",
"0",
")",
"{",
"return",
"firstDeletedIndex",
"==",
"-",
"1",
"?",
"~",
"entryIndex",
":",
"~",
"firstDeletedIndex",
";",
"// found empty or deleted",
"}",
"if",
"(",
"curCountsArr_",
"[",
"entryIndex",
"]",
"==",
"DELETED_KEY_MARKER",
")",
"{",
"if",
"(",
"firstDeletedIndex",
"==",
"-",
"1",
")",
"{",
"firstDeletedIndex",
"=",
"entryIndex",
";",
"}",
"}",
"else",
"if",
"(",
"Map",
".",
"arraysEqual",
"(",
"keysArr_",
",",
"entryIndex",
"*",
"keySizeBytes_",
",",
"key",
",",
"0",
",",
"keySizeBytes_",
")",
")",
"{",
"return",
"entryIndex",
";",
"// found key",
"}",
"entryIndex",
"=",
"(",
"entryIndex",
"+",
"getStride",
"(",
"hash",
"[",
"1",
"]",
",",
"tableEntries_",
")",
")",
"%",
"tableEntries_",
";",
"}",
"while",
"(",
"entryIndex",
"!=",
"loopIndex",
")",
";",
"throw",
"new",
"SketchesArgumentException",
"(",
"\"Key not found and no empty slots!\"",
")",
";",
"}"
] | Returns entryIndex if the given key is found. If not found, returns one's complement index
of an empty slot for insertion, which may be over a deleted key.
@param key the given key
@return the entryIndex | [
"Returns",
"entryIndex",
"if",
"the",
"given",
"key",
"is",
"found",
".",
"If",
"not",
"found",
"returns",
"one",
"s",
"complement",
"index",
"of",
"an",
"empty",
"slot",
"for",
"insertion",
"which",
"may",
"be",
"over",
"a",
"deleted",
"key",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hllmap/CouponHashMap.java#L139-L159 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.