repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
oboehm/jfachwert | src/main/java/de/jfachwert/bank/Geldbetrag.java | Geldbetrag.validate | public static String validate(String zahl) {
"""
Validiert die uebergebene Zahl, ob sie sich als Geldbetrag eignet.
@param zahl als String
@return die Zahl zur Weitervarabeitung
"""
try {
return Geldbetrag.valueOf(zahl).toString();
} catch (IllegalArgumentException ex) {
throw new InvalidValueException(zahl, "money_amount", ex);
}
} | java | public static String validate(String zahl) {
try {
return Geldbetrag.valueOf(zahl).toString();
} catch (IllegalArgumentException ex) {
throw new InvalidValueException(zahl, "money_amount", ex);
}
} | [
"public",
"static",
"String",
"validate",
"(",
"String",
"zahl",
")",
"{",
"try",
"{",
"return",
"Geldbetrag",
".",
"valueOf",
"(",
"zahl",
")",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ex",
")",
"{",
"throw",
"new",
"InvalidValueException",
"(",
"zahl",
",",
"\"money_amount\"",
",",
"ex",
")",
";",
"}",
"}"
] | Validiert die uebergebene Zahl, ob sie sich als Geldbetrag eignet.
@param zahl als String
@return die Zahl zur Weitervarabeitung | [
"Validiert",
"die",
"uebergebene",
"Zahl",
"ob",
"sie",
"sich",
"als",
"Geldbetrag",
"eignet",
"."
] | train | https://github.com/oboehm/jfachwert/blob/67b513d29e3114c7aee65cd1ea7a5b7e540b0d1b/src/main/java/de/jfachwert/bank/Geldbetrag.java#L553-L559 |
hibernate/hibernate-ogm | core/src/main/java/org/hibernate/ogm/datastore/document/association/impl/DocumentHelpers.java | DocumentHelpers.getColumnSharedPrefix | public static String getColumnSharedPrefix(String[] associationKeyColumns) {
"""
Returns the shared prefix of these columns. Null otherwise.
@param associationKeyColumns the columns sharing a prefix
@return the shared prefix of these columns. {@code null} otherwise.
"""
String prefix = null;
for ( String column : associationKeyColumns ) {
String newPrefix = getPrefix( column );
if ( prefix == null ) { // first iteration
prefix = newPrefix;
if ( prefix == null ) { // no prefix, quit
break;
}
}
else { // subsequent iterations
if ( ! equals( prefix, newPrefix ) ) { // different prefixes
prefix = null;
break;
}
}
}
return prefix;
} | java | public static String getColumnSharedPrefix(String[] associationKeyColumns) {
String prefix = null;
for ( String column : associationKeyColumns ) {
String newPrefix = getPrefix( column );
if ( prefix == null ) { // first iteration
prefix = newPrefix;
if ( prefix == null ) { // no prefix, quit
break;
}
}
else { // subsequent iterations
if ( ! equals( prefix, newPrefix ) ) { // different prefixes
prefix = null;
break;
}
}
}
return prefix;
} | [
"public",
"static",
"String",
"getColumnSharedPrefix",
"(",
"String",
"[",
"]",
"associationKeyColumns",
")",
"{",
"String",
"prefix",
"=",
"null",
";",
"for",
"(",
"String",
"column",
":",
"associationKeyColumns",
")",
"{",
"String",
"newPrefix",
"=",
"getPrefix",
"(",
"column",
")",
";",
"if",
"(",
"prefix",
"==",
"null",
")",
"{",
"// first iteration",
"prefix",
"=",
"newPrefix",
";",
"if",
"(",
"prefix",
"==",
"null",
")",
"{",
"// no prefix, quit",
"break",
";",
"}",
"}",
"else",
"{",
"// subsequent iterations",
"if",
"(",
"!",
"equals",
"(",
"prefix",
",",
"newPrefix",
")",
")",
"{",
"// different prefixes",
"prefix",
"=",
"null",
";",
"break",
";",
"}",
"}",
"}",
"return",
"prefix",
";",
"}"
] | Returns the shared prefix of these columns. Null otherwise.
@param associationKeyColumns the columns sharing a prefix
@return the shared prefix of these columns. {@code null} otherwise. | [
"Returns",
"the",
"shared",
"prefix",
"of",
"these",
"columns",
".",
"Null",
"otherwise",
"."
] | train | https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/document/association/impl/DocumentHelpers.java#L36-L54 |
apache/flink | flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java | DateTimeUtils.parseFraction | private static int parseFraction(String v, int multiplier) {
"""
Parses a fraction, multiplying the first character by {@code multiplier},
the second character by {@code multiplier / 10},
the third character by {@code multiplier / 100}, and so forth.
<p>For example, {@code parseFraction("1234", 100)} yields {@code 123}.
"""
int r = 0;
for (int i = 0; i < v.length(); i++) {
char c = v.charAt(i);
int x = c < '0' || c > '9' ? 0 : (c - '0');
r += multiplier * x;
if (multiplier < 10) {
// We're at the last digit. Check for rounding.
if (i + 1 < v.length()
&& v.charAt(i + 1) >= '5') {
++r;
}
break;
}
multiplier /= 10;
}
return r;
} | java | private static int parseFraction(String v, int multiplier) {
int r = 0;
for (int i = 0; i < v.length(); i++) {
char c = v.charAt(i);
int x = c < '0' || c > '9' ? 0 : (c - '0');
r += multiplier * x;
if (multiplier < 10) {
// We're at the last digit. Check for rounding.
if (i + 1 < v.length()
&& v.charAt(i + 1) >= '5') {
++r;
}
break;
}
multiplier /= 10;
}
return r;
} | [
"private",
"static",
"int",
"parseFraction",
"(",
"String",
"v",
",",
"int",
"multiplier",
")",
"{",
"int",
"r",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"v",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"v",
".",
"charAt",
"(",
"i",
")",
";",
"int",
"x",
"=",
"c",
"<",
"'",
"'",
"||",
"c",
">",
"'",
"'",
"?",
"0",
":",
"(",
"c",
"-",
"'",
"'",
")",
";",
"r",
"+=",
"multiplier",
"*",
"x",
";",
"if",
"(",
"multiplier",
"<",
"10",
")",
"{",
"// We're at the last digit. Check for rounding.",
"if",
"(",
"i",
"+",
"1",
"<",
"v",
".",
"length",
"(",
")",
"&&",
"v",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
">=",
"'",
"'",
")",
"{",
"++",
"r",
";",
"}",
"break",
";",
"}",
"multiplier",
"/=",
"10",
";",
"}",
"return",
"r",
";",
"}"
] | Parses a fraction, multiplying the first character by {@code multiplier},
the second character by {@code multiplier / 10},
the third character by {@code multiplier / 100}, and so forth.
<p>For example, {@code parseFraction("1234", 100)} yields {@code 123}. | [
"Parses",
"a",
"fraction",
"multiplying",
"the",
"first",
"character",
"by",
"{",
"@code",
"multiplier",
"}",
"the",
"second",
"character",
"by",
"{",
"@code",
"multiplier",
"/",
"10",
"}",
"the",
"third",
"character",
"by",
"{",
"@code",
"multiplier",
"/",
"100",
"}",
"and",
"so",
"forth",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-planner-blink/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java#L838-L855 |
zeromq/jeromq | src/main/java/org/zeromq/ZProxy.java | ZProxy.newZProxy | @Deprecated
public static ZProxy newZProxy(ZContext ctx, String name, SelectorCreator selector, Proxy sockets,
String motdelafin, Object... args) {
"""
Creates a new proxy in a ZeroMQ way.
This proxy will be less efficient than the
{@link #newZProxy(ZContext, String, org.zeromq.ZProxy.Proxy, String, Object...) low-level one}.
@param ctx the context used for the proxy.
Possibly null, in this case a new context will be created and automatically destroyed afterwards.
@param name the name of the proxy. Possibly null.
@param selector the creator of the selector used for the internal polling. Not null.
@param sockets the sockets creator of the proxy. Not null.
@param motdelafin the final word used to mark the end of the proxy. Null to disable this mechanism.
@param args an optional array of arguments that will be passed at the creation.
@return the created proxy.
@deprecated use {@link #newZProxy(ZContext, String, Proxy, String, Object...)} instead.
"""
return newZProxy(ctx, name, sockets, motdelafin, args);
} | java | @Deprecated
public static ZProxy newZProxy(ZContext ctx, String name, SelectorCreator selector, Proxy sockets,
String motdelafin, Object... args)
{
return newZProxy(ctx, name, sockets, motdelafin, args);
} | [
"@",
"Deprecated",
"public",
"static",
"ZProxy",
"newZProxy",
"(",
"ZContext",
"ctx",
",",
"String",
"name",
",",
"SelectorCreator",
"selector",
",",
"Proxy",
"sockets",
",",
"String",
"motdelafin",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"newZProxy",
"(",
"ctx",
",",
"name",
",",
"sockets",
",",
"motdelafin",
",",
"args",
")",
";",
"}"
] | Creates a new proxy in a ZeroMQ way.
This proxy will be less efficient than the
{@link #newZProxy(ZContext, String, org.zeromq.ZProxy.Proxy, String, Object...) low-level one}.
@param ctx the context used for the proxy.
Possibly null, in this case a new context will be created and automatically destroyed afterwards.
@param name the name of the proxy. Possibly null.
@param selector the creator of the selector used for the internal polling. Not null.
@param sockets the sockets creator of the proxy. Not null.
@param motdelafin the final word used to mark the end of the proxy. Null to disable this mechanism.
@param args an optional array of arguments that will be passed at the creation.
@return the created proxy.
@deprecated use {@link #newZProxy(ZContext, String, Proxy, String, Object...)} instead. | [
"Creates",
"a",
"new",
"proxy",
"in",
"a",
"ZeroMQ",
"way",
".",
"This",
"proxy",
"will",
"be",
"less",
"efficient",
"than",
"the",
"{",
"@link",
"#newZProxy",
"(",
"ZContext",
"String",
"org",
".",
"zeromq",
".",
"ZProxy",
".",
"Proxy",
"String",
"Object",
"...",
")",
"low",
"-",
"level",
"one",
"}",
"."
] | train | https://github.com/zeromq/jeromq/blob/8b4a2960b468d08b7aebb0d40bfb947e08fed040/src/main/java/org/zeromq/ZProxy.java#L239-L244 |
structurizr/java | structurizr-core/src/com/structurizr/view/ViewSet.java | ViewSet.createDeploymentView | public DeploymentView createDeploymentView(SoftwareSystem softwareSystem, String key, String description) {
"""
Creates a deployment view, where the scope of the view is the specified software system.
@param softwareSystem the SoftwareSystem object representing the scope of the view
@param key the key for the deployment view (must be unique)
@param description a description of the view
@return a DeploymentView object
@throws IllegalArgumentException if the software system is null or the key is not unique
"""
assertThatTheSoftwareSystemIsNotNull(softwareSystem);
assertThatTheViewKeyIsSpecifiedAndUnique(key);
DeploymentView view = new DeploymentView(softwareSystem, key, description);
view.setViewSet(this);
deploymentViews.add(view);
return view;
} | java | public DeploymentView createDeploymentView(SoftwareSystem softwareSystem, String key, String description) {
assertThatTheSoftwareSystemIsNotNull(softwareSystem);
assertThatTheViewKeyIsSpecifiedAndUnique(key);
DeploymentView view = new DeploymentView(softwareSystem, key, description);
view.setViewSet(this);
deploymentViews.add(view);
return view;
} | [
"public",
"DeploymentView",
"createDeploymentView",
"(",
"SoftwareSystem",
"softwareSystem",
",",
"String",
"key",
",",
"String",
"description",
")",
"{",
"assertThatTheSoftwareSystemIsNotNull",
"(",
"softwareSystem",
")",
";",
"assertThatTheViewKeyIsSpecifiedAndUnique",
"(",
"key",
")",
";",
"DeploymentView",
"view",
"=",
"new",
"DeploymentView",
"(",
"softwareSystem",
",",
"key",
",",
"description",
")",
";",
"view",
".",
"setViewSet",
"(",
"this",
")",
";",
"deploymentViews",
".",
"add",
"(",
"view",
")",
";",
"return",
"view",
";",
"}"
] | Creates a deployment view, where the scope of the view is the specified software system.
@param softwareSystem the SoftwareSystem object representing the scope of the view
@param key the key for the deployment view (must be unique)
@param description a description of the view
@return a DeploymentView object
@throws IllegalArgumentException if the software system is null or the key is not unique | [
"Creates",
"a",
"deployment",
"view",
"where",
"the",
"scope",
"of",
"the",
"view",
"is",
"the",
"specified",
"software",
"system",
"."
] | train | https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/view/ViewSet.java#L215-L223 |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.equalsIgnoreCaseAccents | @Pure
@Inline(value = "TextUtil.removeAccents($1, $3).equalsIgnoreCase(TextUtil.removeAccents($2, $3))",
imported = {
"""
Compares this <code>String</code> to another <code>String</code>,
ignoring case and accent considerations. Two strings are considered equal
ignoring case and accents if they are of the same length, and corresponding
characters in the two strings are equal ignoring case and accents.
<p>This method is equivalent to:
<pre><code>
TextUtil.removeAccents(s1,map).equalsIgnoreCase(TextUtil.removeAccents(s2,map));
</code></pre>
@param s1 is the first string to compare.
@param s2 is the second string to compare.
@param map is the translation table from an accentuated character to an
unaccentuated character.
@return <code>true</code> if the argument is not <code>null</code>
and the <code>String</code>s are equal,
ignoring case; <code>false</code> otherwise.
@see #removeAccents(String, Map)
"""TextUtil.class})
public static boolean equalsIgnoreCaseAccents(String s1, String s2, Map<Character, String> map) {
return removeAccents(s1, map).equalsIgnoreCase(removeAccents(s2, map));
} | java | @Pure
@Inline(value = "TextUtil.removeAccents($1, $3).equalsIgnoreCase(TextUtil.removeAccents($2, $3))",
imported = {TextUtil.class})
public static boolean equalsIgnoreCaseAccents(String s1, String s2, Map<Character, String> map) {
return removeAccents(s1, map).equalsIgnoreCase(removeAccents(s2, map));
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"TextUtil.removeAccents($1, $3).equalsIgnoreCase(TextUtil.removeAccents($2, $3))\"",
",",
"imported",
"=",
"{",
"TextUtil",
".",
"class",
"}",
")",
"public",
"static",
"boolean",
"equalsIgnoreCaseAccents",
"(",
"String",
"s1",
",",
"String",
"s2",
",",
"Map",
"<",
"Character",
",",
"String",
">",
"map",
")",
"{",
"return",
"removeAccents",
"(",
"s1",
",",
"map",
")",
".",
"equalsIgnoreCase",
"(",
"removeAccents",
"(",
"s2",
",",
"map",
")",
")",
";",
"}"
] | Compares this <code>String</code> to another <code>String</code>,
ignoring case and accent considerations. Two strings are considered equal
ignoring case and accents if they are of the same length, and corresponding
characters in the two strings are equal ignoring case and accents.
<p>This method is equivalent to:
<pre><code>
TextUtil.removeAccents(s1,map).equalsIgnoreCase(TextUtil.removeAccents(s2,map));
</code></pre>
@param s1 is the first string to compare.
@param s2 is the second string to compare.
@param map is the translation table from an accentuated character to an
unaccentuated character.
@return <code>true</code> if the argument is not <code>null</code>
and the <code>String</code>s are equal,
ignoring case; <code>false</code> otherwise.
@see #removeAccents(String, Map) | [
"Compares",
"this",
"<code",
">",
"String<",
"/",
"code",
">",
"to",
"another",
"<code",
">",
"String<",
"/",
"code",
">",
"ignoring",
"case",
"and",
"accent",
"considerations",
".",
"Two",
"strings",
"are",
"considered",
"equal",
"ignoring",
"case",
"and",
"accents",
"if",
"they",
"are",
"of",
"the",
"same",
"length",
"and",
"corresponding",
"characters",
"in",
"the",
"two",
"strings",
"are",
"equal",
"ignoring",
"case",
"and",
"accents",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L1376-L1381 |
xmlet/XsdAsmFaster | src/main/java/org/xmlet/xsdasmfaster/classes/XsdSupportingStructure.java | XsdSupportingStructure.textGroupMethod | private static void textGroupMethod(ClassWriter classWriter, String varName, String visitName) {
"""
Creates a method present in the TextGroup interface.
Code:
getVisitor().visitComment(new Text<>(self(), getVisitor(), text));
return this.self();
@param classWriter The TextGroup {@link ClassWriter} object.
@param varName The name of the method, i.e. text or comment.
@param visitName The name of the visit method to invoke on the method, i.e. visitText or visitComment.
"""
MethodVisitor mVisitor = classWriter.visitMethod(ACC_PUBLIC, varName, "(" + JAVA_OBJECT_DESC + ")" + elementTypeDesc, "<R:" + JAVA_OBJECT_DESC + ">(TR;)TT;", null);
mVisitor.visitLocalVariable(varName, JAVA_STRING_DESC, null, new Label(), new Label(),1);
mVisitor.visitCode();
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "getVisitor", "()" + elementVisitorTypeDesc, true);
mVisitor.visitTypeInsn(NEW, textType);
mVisitor.visitInsn(DUP);
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "self", "()" + elementTypeDesc, true);
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "getVisitor", "()" + elementVisitorTypeDesc, true);
mVisitor.visitVarInsn(ALOAD, 1);
mVisitor.visitMethodInsn(INVOKESPECIAL, textType, CONSTRUCTOR, "(" + elementTypeDesc + elementVisitorTypeDesc + JAVA_OBJECT_DESC + ")V", false);
mVisitor.visitMethodInsn(INVOKEVIRTUAL, elementVisitorType, visitName, "(" + textTypeDesc + ")V", false);
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "self", "()" + elementTypeDesc, true);
mVisitor.visitInsn(ARETURN);
mVisitor.visitMaxs(6, 2);
mVisitor.visitEnd();
} | java | private static void textGroupMethod(ClassWriter classWriter, String varName, String visitName){
MethodVisitor mVisitor = classWriter.visitMethod(ACC_PUBLIC, varName, "(" + JAVA_OBJECT_DESC + ")" + elementTypeDesc, "<R:" + JAVA_OBJECT_DESC + ">(TR;)TT;", null);
mVisitor.visitLocalVariable(varName, JAVA_STRING_DESC, null, new Label(), new Label(),1);
mVisitor.visitCode();
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "getVisitor", "()" + elementVisitorTypeDesc, true);
mVisitor.visitTypeInsn(NEW, textType);
mVisitor.visitInsn(DUP);
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "self", "()" + elementTypeDesc, true);
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "getVisitor", "()" + elementVisitorTypeDesc, true);
mVisitor.visitVarInsn(ALOAD, 1);
mVisitor.visitMethodInsn(INVOKESPECIAL, textType, CONSTRUCTOR, "(" + elementTypeDesc + elementVisitorTypeDesc + JAVA_OBJECT_DESC + ")V", false);
mVisitor.visitMethodInsn(INVOKEVIRTUAL, elementVisitorType, visitName, "(" + textTypeDesc + ")V", false);
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, textGroupType, "self", "()" + elementTypeDesc, true);
mVisitor.visitInsn(ARETURN);
mVisitor.visitMaxs(6, 2);
mVisitor.visitEnd();
} | [
"private",
"static",
"void",
"textGroupMethod",
"(",
"ClassWriter",
"classWriter",
",",
"String",
"varName",
",",
"String",
"visitName",
")",
"{",
"MethodVisitor",
"mVisitor",
"=",
"classWriter",
".",
"visitMethod",
"(",
"ACC_PUBLIC",
",",
"varName",
",",
"\"(\"",
"+",
"JAVA_OBJECT_DESC",
"+",
"\")\"",
"+",
"elementTypeDesc",
",",
"\"<R:\"",
"+",
"JAVA_OBJECT_DESC",
"+",
"\">(TR;)TT;\"",
",",
"null",
")",
";",
"mVisitor",
".",
"visitLocalVariable",
"(",
"varName",
",",
"JAVA_STRING_DESC",
",",
"null",
",",
"new",
"Label",
"(",
")",
",",
"new",
"Label",
"(",
")",
",",
"1",
")",
";",
"mVisitor",
".",
"visitCode",
"(",
")",
";",
"mVisitor",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"mVisitor",
".",
"visitMethodInsn",
"(",
"INVOKEINTERFACE",
",",
"textGroupType",
",",
"\"getVisitor\"",
",",
"\"()\"",
"+",
"elementVisitorTypeDesc",
",",
"true",
")",
";",
"mVisitor",
".",
"visitTypeInsn",
"(",
"NEW",
",",
"textType",
")",
";",
"mVisitor",
".",
"visitInsn",
"(",
"DUP",
")",
";",
"mVisitor",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"mVisitor",
".",
"visitMethodInsn",
"(",
"INVOKEINTERFACE",
",",
"textGroupType",
",",
"\"self\"",
",",
"\"()\"",
"+",
"elementTypeDesc",
",",
"true",
")",
";",
"mVisitor",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"mVisitor",
".",
"visitMethodInsn",
"(",
"INVOKEINTERFACE",
",",
"textGroupType",
",",
"\"getVisitor\"",
",",
"\"()\"",
"+",
"elementVisitorTypeDesc",
",",
"true",
")",
";",
"mVisitor",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"1",
")",
";",
"mVisitor",
".",
"visitMethodInsn",
"(",
"INVOKESPECIAL",
",",
"textType",
",",
"CONSTRUCTOR",
",",
"\"(\"",
"+",
"elementTypeDesc",
"+",
"elementVisitorTypeDesc",
"+",
"JAVA_OBJECT_DESC",
"+",
"\")V\"",
",",
"false",
")",
";",
"mVisitor",
".",
"visitMethodInsn",
"(",
"INVOKEVIRTUAL",
",",
"elementVisitorType",
",",
"visitName",
",",
"\"(\"",
"+",
"textTypeDesc",
"+",
"\")V\"",
",",
"false",
")",
";",
"mVisitor",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"mVisitor",
".",
"visitMethodInsn",
"(",
"INVOKEINTERFACE",
",",
"textGroupType",
",",
"\"self\"",
",",
"\"()\"",
"+",
"elementTypeDesc",
",",
"true",
")",
";",
"mVisitor",
".",
"visitInsn",
"(",
"ARETURN",
")",
";",
"mVisitor",
".",
"visitMaxs",
"(",
"6",
",",
"2",
")",
";",
"mVisitor",
".",
"visitEnd",
"(",
")",
";",
"}"
] | Creates a method present in the TextGroup interface.
Code:
getVisitor().visitComment(new Text<>(self(), getVisitor(), text));
return this.self();
@param classWriter The TextGroup {@link ClassWriter} object.
@param varName The name of the method, i.e. text or comment.
@param visitName The name of the visit method to invoke on the method, i.e. visitText or visitComment. | [
"Creates",
"a",
"method",
"present",
"in",
"the",
"TextGroup",
"interface",
".",
"Code",
":",
"getVisitor",
"()",
".",
"visitComment",
"(",
"new",
"Text<",
">",
"(",
"self",
"()",
"getVisitor",
"()",
"text",
"))",
";",
"return",
"this",
".",
"self",
"()",
";"
] | train | https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdSupportingStructure.java#L181-L201 |
jqno/equalsverifier | src/main/java/nl/jqno/equalsverifier/internal/reflection/ObjectAccessor.java | ObjectAccessor.shallowScramble | public void shallowScramble(PrefabValues prefabValues, TypeTag enclosingType) {
"""
Modifies all fields of the wrapped object that are declared in T, but
not those inherited from superclasses.
This method is consistent: given two equal objects; after scrambling
both objects, they remain equal to each other.
It cannot modifiy:
1. static final fields, and
2. final fields that are initialized to a compile-time constant in the
field declaration.
These fields will be left unmodified.
@param prefabValues Prefabricated values to take values from.
@param enclosingType Describes the type that contains this object as a
field, to determine any generic parameters it may
contain.
"""
for (Field field : FieldIterable.ofIgnoringSuper(type)) {
FieldAccessor accessor = new FieldAccessor(object, field);
accessor.changeField(prefabValues, enclosingType);
}
} | java | public void shallowScramble(PrefabValues prefabValues, TypeTag enclosingType) {
for (Field field : FieldIterable.ofIgnoringSuper(type)) {
FieldAccessor accessor = new FieldAccessor(object, field);
accessor.changeField(prefabValues, enclosingType);
}
} | [
"public",
"void",
"shallowScramble",
"(",
"PrefabValues",
"prefabValues",
",",
"TypeTag",
"enclosingType",
")",
"{",
"for",
"(",
"Field",
"field",
":",
"FieldIterable",
".",
"ofIgnoringSuper",
"(",
"type",
")",
")",
"{",
"FieldAccessor",
"accessor",
"=",
"new",
"FieldAccessor",
"(",
"object",
",",
"field",
")",
";",
"accessor",
".",
"changeField",
"(",
"prefabValues",
",",
"enclosingType",
")",
";",
"}",
"}"
] | Modifies all fields of the wrapped object that are declared in T, but
not those inherited from superclasses.
This method is consistent: given two equal objects; after scrambling
both objects, they remain equal to each other.
It cannot modifiy:
1. static final fields, and
2. final fields that are initialized to a compile-time constant in the
field declaration.
These fields will be left unmodified.
@param prefabValues Prefabricated values to take values from.
@param enclosingType Describes the type that contains this object as a
field, to determine any generic parameters it may
contain. | [
"Modifies",
"all",
"fields",
"of",
"the",
"wrapped",
"object",
"that",
"are",
"declared",
"in",
"T",
"but",
"not",
"those",
"inherited",
"from",
"superclasses",
"."
] | train | https://github.com/jqno/equalsverifier/blob/25d73c9cb801c8b20b257d1d1283ac6e0585ef1d/src/main/java/nl/jqno/equalsverifier/internal/reflection/ObjectAccessor.java#L165-L170 |
contentful/contentful-management.java | src/main/java/com/contentful/java/cma/AbsModule.java | AbsModule.getSpaceIdOrThrow | String getSpaceIdOrThrow(CMAResource resource, String param) {
"""
Extracts the Space ID from the given {@code resource} of name {@code param}.
Throws {@link IllegalArgumentException} if the value is not present.
"""
final String spaceId = resource.getSpaceId();
if (spaceId == null) {
throw new IllegalArgumentException(String.format(
"%s must have a space associated.", param));
}
return spaceId;
} | java | String getSpaceIdOrThrow(CMAResource resource, String param) {
final String spaceId = resource.getSpaceId();
if (spaceId == null) {
throw new IllegalArgumentException(String.format(
"%s must have a space associated.", param));
}
return spaceId;
} | [
"String",
"getSpaceIdOrThrow",
"(",
"CMAResource",
"resource",
",",
"String",
"param",
")",
"{",
"final",
"String",
"spaceId",
"=",
"resource",
".",
"getSpaceId",
"(",
")",
";",
"if",
"(",
"spaceId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"%s must have a space associated.\"",
",",
"param",
")",
")",
";",
"}",
"return",
"spaceId",
";",
"}"
] | Extracts the Space ID from the given {@code resource} of name {@code param}.
Throws {@link IllegalArgumentException} if the value is not present. | [
"Extracts",
"the",
"Space",
"ID",
"from",
"the",
"given",
"{"
] | train | https://github.com/contentful/contentful-management.java/blob/ca310fb9ea9577fcff0ca57949ab7c2315fa2534/src/main/java/com/contentful/java/cma/AbsModule.java#L84-L91 |
mijecu25/dsa | src/main/java/com/mijecu25/dsa/algorithms/sort/linearlogarithmic/Quicksort.java | Quicksort.partition | private static int partition(float[] floatArray, int start, int end) {
"""
Routine that arranges the elements in ascending order around a pivot. This routine
runs in O(n) time.
@param floatArray array that we want to sort
@param start index of the starting point to sort
@param end index of the end point to sort
@return an integer that represent the index of the pivot
"""
float pivot = floatArray[end];
int index = start - 1;
for(int j = start; j < end; j++) {
if(floatArray[j] <= pivot) {
index++;
TrivialSwap.swap(floatArray, index, j);
}
}
TrivialSwap.swap(floatArray, index + 1, end);
return index + 1;
} | java | private static int partition(float[] floatArray, int start, int end) {
float pivot = floatArray[end];
int index = start - 1;
for(int j = start; j < end; j++) {
if(floatArray[j] <= pivot) {
index++;
TrivialSwap.swap(floatArray, index, j);
}
}
TrivialSwap.swap(floatArray, index + 1, end);
return index + 1;
} | [
"private",
"static",
"int",
"partition",
"(",
"float",
"[",
"]",
"floatArray",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"float",
"pivot",
"=",
"floatArray",
"[",
"end",
"]",
";",
"int",
"index",
"=",
"start",
"-",
"1",
";",
"for",
"(",
"int",
"j",
"=",
"start",
";",
"j",
"<",
"end",
";",
"j",
"++",
")",
"{",
"if",
"(",
"floatArray",
"[",
"j",
"]",
"<=",
"pivot",
")",
"{",
"index",
"++",
";",
"TrivialSwap",
".",
"swap",
"(",
"floatArray",
",",
"index",
",",
"j",
")",
";",
"}",
"}",
"TrivialSwap",
".",
"swap",
"(",
"floatArray",
",",
"index",
"+",
"1",
",",
"end",
")",
";",
"return",
"index",
"+",
"1",
";",
"}"
] | Routine that arranges the elements in ascending order around a pivot. This routine
runs in O(n) time.
@param floatArray array that we want to sort
@param start index of the starting point to sort
@param end index of the end point to sort
@return an integer that represent the index of the pivot | [
"Routine",
"that",
"arranges",
"the",
"elements",
"in",
"ascending",
"order",
"around",
"a",
"pivot",
".",
"This",
"routine",
"runs",
"in",
"O",
"(",
"n",
")",
"time",
"."
] | train | https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/sort/linearlogarithmic/Quicksort.java#L650-L664 |
netty/netty | transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueStreamChannel.java | AbstractKQueueStreamChannel.writeBytesMultiple | private int writeBytesMultiple(ChannelOutboundBuffer in, IovArray array) throws IOException {
"""
Write multiple bytes via {@link IovArray}.
@param in the collection which contains objects to write.
@param array The array which contains the content to write.
@return The value that should be decremented from the write quantum which starts at
{@link ChannelConfig#getWriteSpinCount()}. The typical use cases are as follows:
<ul>
<li>0 - if no write was attempted. This is appropriate if an empty {@link ByteBuf} (or other empty content)
is encountered</li>
<li>1 - if a single call to write data was made to the OS</li>
<li>{@link ChannelUtils#WRITE_STATUS_SNDBUF_FULL} - if an attempt to write data was made to the OS, but
no data was accepted</li>
</ul>
@throws IOException If an I/O exception occurs during write.
"""
final long expectedWrittenBytes = array.size();
assert expectedWrittenBytes != 0;
final int cnt = array.count();
assert cnt != 0;
final long localWrittenBytes = socket.writevAddresses(array.memoryAddress(0), cnt);
if (localWrittenBytes > 0) {
adjustMaxBytesPerGatheringWrite(expectedWrittenBytes, localWrittenBytes, array.maxBytes());
in.removeBytes(localWrittenBytes);
return 1;
}
return WRITE_STATUS_SNDBUF_FULL;
} | java | private int writeBytesMultiple(ChannelOutboundBuffer in, IovArray array) throws IOException {
final long expectedWrittenBytes = array.size();
assert expectedWrittenBytes != 0;
final int cnt = array.count();
assert cnt != 0;
final long localWrittenBytes = socket.writevAddresses(array.memoryAddress(0), cnt);
if (localWrittenBytes > 0) {
adjustMaxBytesPerGatheringWrite(expectedWrittenBytes, localWrittenBytes, array.maxBytes());
in.removeBytes(localWrittenBytes);
return 1;
}
return WRITE_STATUS_SNDBUF_FULL;
} | [
"private",
"int",
"writeBytesMultiple",
"(",
"ChannelOutboundBuffer",
"in",
",",
"IovArray",
"array",
")",
"throws",
"IOException",
"{",
"final",
"long",
"expectedWrittenBytes",
"=",
"array",
".",
"size",
"(",
")",
";",
"assert",
"expectedWrittenBytes",
"!=",
"0",
";",
"final",
"int",
"cnt",
"=",
"array",
".",
"count",
"(",
")",
";",
"assert",
"cnt",
"!=",
"0",
";",
"final",
"long",
"localWrittenBytes",
"=",
"socket",
".",
"writevAddresses",
"(",
"array",
".",
"memoryAddress",
"(",
"0",
")",
",",
"cnt",
")",
";",
"if",
"(",
"localWrittenBytes",
">",
"0",
")",
"{",
"adjustMaxBytesPerGatheringWrite",
"(",
"expectedWrittenBytes",
",",
"localWrittenBytes",
",",
"array",
".",
"maxBytes",
"(",
")",
")",
";",
"in",
".",
"removeBytes",
"(",
"localWrittenBytes",
")",
";",
"return",
"1",
";",
"}",
"return",
"WRITE_STATUS_SNDBUF_FULL",
";",
"}"
] | Write multiple bytes via {@link IovArray}.
@param in the collection which contains objects to write.
@param array The array which contains the content to write.
@return The value that should be decremented from the write quantum which starts at
{@link ChannelConfig#getWriteSpinCount()}. The typical use cases are as follows:
<ul>
<li>0 - if no write was attempted. This is appropriate if an empty {@link ByteBuf} (or other empty content)
is encountered</li>
<li>1 - if a single call to write data was made to the OS</li>
<li>{@link ChannelUtils#WRITE_STATUS_SNDBUF_FULL} - if an attempt to write data was made to the OS, but
no data was accepted</li>
</ul>
@throws IOException If an I/O exception occurs during write. | [
"Write",
"multiple",
"bytes",
"via",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueStreamChannel.java#L147-L160 |
att/AAF | authz/authz-cass/src/main/java/com/att/dao/CachedDAO.java | CachedDAO.read | public Result<List<DATA>> read(final String key, final TRANS trans, final Object ... objs) {
"""
Slight Improved performance available when String and Obj versions are known.
"""
DAOGetter getter = new DAOGetter(trans,dao,objs);
return get(trans, key, getter);
// if(ld!=null) {
// return Result.ok(ld);//.emptyList(ld.isEmpty());
// }
// // Result Result if exists
// if(getter.result==null) {
// return Result.err(Status.ERR_NotFound, "No Cache or Lookup found on [%s]",dao.table());
// }
// return getter.result;
} | java | public Result<List<DATA>> read(final String key, final TRANS trans, final Object ... objs) {
DAOGetter getter = new DAOGetter(trans,dao,objs);
return get(trans, key, getter);
// if(ld!=null) {
// return Result.ok(ld);//.emptyList(ld.isEmpty());
// }
// // Result Result if exists
// if(getter.result==null) {
// return Result.err(Status.ERR_NotFound, "No Cache or Lookup found on [%s]",dao.table());
// }
// return getter.result;
} | [
"public",
"Result",
"<",
"List",
"<",
"DATA",
">",
">",
"read",
"(",
"final",
"String",
"key",
",",
"final",
"TRANS",
"trans",
",",
"final",
"Object",
"...",
"objs",
")",
"{",
"DAOGetter",
"getter",
"=",
"new",
"DAOGetter",
"(",
"trans",
",",
"dao",
",",
"objs",
")",
";",
"return",
"get",
"(",
"trans",
",",
"key",
",",
"getter",
")",
";",
"//\t\tif(ld!=null) {",
"//\t\t\treturn Result.ok(ld);//.emptyList(ld.isEmpty());",
"//\t\t}",
"//\t\t// Result Result if exists",
"//\t\tif(getter.result==null) {",
"//\t\t\treturn Result.err(Status.ERR_NotFound, \"No Cache or Lookup found on [%s]\",dao.table());",
"//\t\t}",
"//\t\treturn getter.result;",
"}"
] | Slight Improved performance available when String and Obj versions are known. | [
"Slight",
"Improved",
"performance",
"available",
"when",
"String",
"and",
"Obj",
"versions",
"are",
"known",
"."
] | train | https://github.com/att/AAF/blob/090562e956c0035db972aafba844dc6d3fc948ee/authz/authz-cass/src/main/java/com/att/dao/CachedDAO.java#L141-L152 |
moparisthebest/beehive | beehive-controls/src/main/java/org/apache/beehive/controls/runtime/generator/AptPropertySet.java | AptPropertySet.initProperties | protected ArrayList<AptProperty> initProperties() {
"""
Initializes the list of ControlProperties associated with this ControlPropertySet
"""
ArrayList<AptProperty> properties = new ArrayList<AptProperty>();
if (_propertySet == null || _propertySet.getMethods() == null )
return properties;
// Add all declared method, but ignore the mystery <clinit> methods
for (MethodDeclaration methodDecl : _propertySet.getMethods())
if (!methodDecl.toString().equals("<clinit>()"))
properties.add(
new AptProperty(this,(AnnotationTypeElementDeclaration)methodDecl,_ap));
return properties;
} | java | protected ArrayList<AptProperty> initProperties()
{
ArrayList<AptProperty> properties = new ArrayList<AptProperty>();
if (_propertySet == null || _propertySet.getMethods() == null )
return properties;
// Add all declared method, but ignore the mystery <clinit> methods
for (MethodDeclaration methodDecl : _propertySet.getMethods())
if (!methodDecl.toString().equals("<clinit>()"))
properties.add(
new AptProperty(this,(AnnotationTypeElementDeclaration)methodDecl,_ap));
return properties;
} | [
"protected",
"ArrayList",
"<",
"AptProperty",
">",
"initProperties",
"(",
")",
"{",
"ArrayList",
"<",
"AptProperty",
">",
"properties",
"=",
"new",
"ArrayList",
"<",
"AptProperty",
">",
"(",
")",
";",
"if",
"(",
"_propertySet",
"==",
"null",
"||",
"_propertySet",
".",
"getMethods",
"(",
")",
"==",
"null",
")",
"return",
"properties",
";",
"// Add all declared method, but ignore the mystery <clinit> methods",
"for",
"(",
"MethodDeclaration",
"methodDecl",
":",
"_propertySet",
".",
"getMethods",
"(",
")",
")",
"if",
"(",
"!",
"methodDecl",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"\"<clinit>()\"",
")",
")",
"properties",
".",
"add",
"(",
"new",
"AptProperty",
"(",
"this",
",",
"(",
"AnnotationTypeElementDeclaration",
")",
"methodDecl",
",",
"_ap",
")",
")",
";",
"return",
"properties",
";",
"}"
] | Initializes the list of ControlProperties associated with this ControlPropertySet | [
"Initializes",
"the",
"list",
"of",
"ControlProperties",
"associated",
"with",
"this",
"ControlPropertySet"
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-controls/src/main/java/org/apache/beehive/controls/runtime/generator/AptPropertySet.java#L67-L81 |
knowm/Yank | src/main/java/org/knowm/yank/Yank.java | Yank.queryColumnSQLKey | public static <T> List<T> queryColumnSQLKey(
String poolName, String sqlKey, String columnName, Class<T> columnType, Object[] params)
throws SQLStatementNotFoundException, YankSQLException {
"""
Return a List of Objects from a single table column given a SQL Key using an SQL statement
matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
@param poolName The name of the connection pool to query against
@param sqlKey The SQL Key found in a properties file corresponding to the desired SQL statement
value
@param params The replacement parameters
@param columnType The Class of the desired return Objects matching the table
@return The Column as a List
@throws SQLStatementNotFoundException if an SQL statement could not be found for the given
sqlKey String
"""
String sql = YANK_POOL_MANAGER.getMergedSqlProperties().getProperty(sqlKey);
if (sql == null || sql.equalsIgnoreCase("")) {
throw new SQLStatementNotFoundException();
} else {
return queryColumn(poolName, sql, columnName, columnType, params);
}
} | java | public static <T> List<T> queryColumnSQLKey(
String poolName, String sqlKey, String columnName, Class<T> columnType, Object[] params)
throws SQLStatementNotFoundException, YankSQLException {
String sql = YANK_POOL_MANAGER.getMergedSqlProperties().getProperty(sqlKey);
if (sql == null || sql.equalsIgnoreCase("")) {
throw new SQLStatementNotFoundException();
} else {
return queryColumn(poolName, sql, columnName, columnType, params);
}
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"queryColumnSQLKey",
"(",
"String",
"poolName",
",",
"String",
"sqlKey",
",",
"String",
"columnName",
",",
"Class",
"<",
"T",
">",
"columnType",
",",
"Object",
"[",
"]",
"params",
")",
"throws",
"SQLStatementNotFoundException",
",",
"YankSQLException",
"{",
"String",
"sql",
"=",
"YANK_POOL_MANAGER",
".",
"getMergedSqlProperties",
"(",
")",
".",
"getProperty",
"(",
"sqlKey",
")",
";",
"if",
"(",
"sql",
"==",
"null",
"||",
"sql",
".",
"equalsIgnoreCase",
"(",
"\"\"",
")",
")",
"{",
"throw",
"new",
"SQLStatementNotFoundException",
"(",
")",
";",
"}",
"else",
"{",
"return",
"queryColumn",
"(",
"poolName",
",",
"sql",
",",
"columnName",
",",
"columnType",
",",
"params",
")",
";",
"}",
"}"
] | Return a List of Objects from a single table column given a SQL Key using an SQL statement
matching the sqlKey String in a properties file loaded via Yank.addSQLStatements(...).
@param poolName The name of the connection pool to query against
@param sqlKey The SQL Key found in a properties file corresponding to the desired SQL statement
value
@param params The replacement parameters
@param columnType The Class of the desired return Objects matching the table
@return The Column as a List
@throws SQLStatementNotFoundException if an SQL statement could not be found for the given
sqlKey String | [
"Return",
"a",
"List",
"of",
"Objects",
"from",
"a",
"single",
"table",
"column",
"given",
"a",
"SQL",
"Key",
"using",
"an",
"SQL",
"statement",
"matching",
"the",
"sqlKey",
"String",
"in",
"a",
"properties",
"file",
"loaded",
"via",
"Yank",
".",
"addSQLStatements",
"(",
"...",
")",
"."
] | train | https://github.com/knowm/Yank/blob/b2071dcd94da99db6904355f9557456b8b292a6b/src/main/java/org/knowm/yank/Yank.java#L543-L553 |
alkacon/opencms-core | src/org/opencms/ui/contextmenu/CmsContextMenu.java | CmsContextMenu.addItem | public ContextMenuItem addItem(String caption, Resource icon) {
"""
Adds new item to context menu root with given caption and icon.<p>
@param caption the caption
@param icon the icon
@return reference to newly added item
"""
ContextMenuItem item = addItem(caption);
item.setIcon(icon);
return item;
} | java | public ContextMenuItem addItem(String caption, Resource icon) {
ContextMenuItem item = addItem(caption);
item.setIcon(icon);
return item;
} | [
"public",
"ContextMenuItem",
"addItem",
"(",
"String",
"caption",
",",
"Resource",
"icon",
")",
"{",
"ContextMenuItem",
"item",
"=",
"addItem",
"(",
"caption",
")",
";",
"item",
".",
"setIcon",
"(",
"icon",
")",
";",
"return",
"item",
";",
"}"
] | Adds new item to context menu root with given caption and icon.<p>
@param caption the caption
@param icon the icon
@return reference to newly added item | [
"Adds",
"new",
"item",
"to",
"context",
"menu",
"root",
"with",
"given",
"caption",
"and",
"icon",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/contextmenu/CmsContextMenu.java#L1041-L1046 |
hypfvieh/java-utils | src/main/java/com/github/hypfvieh/util/StringUtil.java | StringUtil.endsWithAny | public static boolean endsWithAny(boolean _ignoreCase, String _str, String... _args) {
"""
Checks if given string in _str ends with any of the given strings in _args.
@param _ignoreCase true to ignore case, false to be case sensitive
@param _str string to check
@param _args patterns to find
@return true if given string in _str ends with any of the given strings in _args, false if not or _str/_args is null
"""
if (_str == null || _args == null || _args.length == 0) {
return false;
}
String heystack = _str;
if (_ignoreCase) {
heystack = _str.toLowerCase();
}
for (String s : _args) {
String needle = _ignoreCase ? s.toLowerCase() : s;
if (heystack.endsWith(needle)) {
return true;
}
}
return false;
} | java | public static boolean endsWithAny(boolean _ignoreCase, String _str, String... _args) {
if (_str == null || _args == null || _args.length == 0) {
return false;
}
String heystack = _str;
if (_ignoreCase) {
heystack = _str.toLowerCase();
}
for (String s : _args) {
String needle = _ignoreCase ? s.toLowerCase() : s;
if (heystack.endsWith(needle)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"endsWithAny",
"(",
"boolean",
"_ignoreCase",
",",
"String",
"_str",
",",
"String",
"...",
"_args",
")",
"{",
"if",
"(",
"_str",
"==",
"null",
"||",
"_args",
"==",
"null",
"||",
"_args",
".",
"length",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"String",
"heystack",
"=",
"_str",
";",
"if",
"(",
"_ignoreCase",
")",
"{",
"heystack",
"=",
"_str",
".",
"toLowerCase",
"(",
")",
";",
"}",
"for",
"(",
"String",
"s",
":",
"_args",
")",
"{",
"String",
"needle",
"=",
"_ignoreCase",
"?",
"s",
".",
"toLowerCase",
"(",
")",
":",
"s",
";",
"if",
"(",
"heystack",
".",
"endsWith",
"(",
"needle",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if given string in _str ends with any of the given strings in _args.
@param _ignoreCase true to ignore case, false to be case sensitive
@param _str string to check
@param _args patterns to find
@return true if given string in _str ends with any of the given strings in _args, false if not or _str/_args is null | [
"Checks",
"if",
"given",
"string",
"in",
"_str",
"ends",
"with",
"any",
"of",
"the",
"given",
"strings",
"in",
"_args",
"."
] | train | https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L521-L538 |
DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/utils/PermissionUtil.java | PermissionUtil.getEffectivePermission | public static long getEffectivePermission(Channel channel, Role role) {
"""
Gets the {@code long} representation of the effective permissions allowed for this {@link net.dv8tion.jda.core.entities.Role Role}
in this {@link net.dv8tion.jda.core.entities.Channel Channel}. This can be used in conjunction with
{@link net.dv8tion.jda.core.Permission#getPermissions(long) Permission.getPermissions(long)} to easily get a list of all
{@link net.dv8tion.jda.core.Permission Permissions} that this role can use in this {@link net.dv8tion.jda.core.entities.Channel Channel}.
@param channel
The {@link net.dv8tion.jda.core.entities.Channel Channel} in which permissions are being checked.
@param role
The {@link net.dv8tion.jda.core.entities.Role Role} whose permissions are being checked.
@throws IllegalArgumentException
if any of the provided parameters is {@code null}
or the provided entities are not from the same guild
@return The {@code long} representation of the effective permissions that this {@link net.dv8tion.jda.core.entities.Role Role}
has in this {@link net.dv8tion.jda.core.entities.Channel Channel}
"""
Checks.notNull(channel, "Channel");
Checks.notNull(role, "Role");
Guild guild = channel.getGuild();
if (!guild.equals(role.getGuild()))
throw new IllegalArgumentException("Provided channel and role are not of the same guild!");
long permissions = role.getPermissionsRaw() | guild.getPublicRole().getPermissionsRaw();
PermissionOverride publicOverride = channel.getPermissionOverride(guild.getPublicRole());
PermissionOverride roleOverride = channel.getPermissionOverride(role);
if (publicOverride != null)
{
permissions &= ~publicOverride.getDeniedRaw();
permissions |= publicOverride.getAllowedRaw();
}
if (roleOverride != null)
{
permissions &= ~roleOverride.getDeniedRaw();
permissions |= roleOverride.getAllowedRaw();
}
return permissions;
} | java | public static long getEffectivePermission(Channel channel, Role role)
{
Checks.notNull(channel, "Channel");
Checks.notNull(role, "Role");
Guild guild = channel.getGuild();
if (!guild.equals(role.getGuild()))
throw new IllegalArgumentException("Provided channel and role are not of the same guild!");
long permissions = role.getPermissionsRaw() | guild.getPublicRole().getPermissionsRaw();
PermissionOverride publicOverride = channel.getPermissionOverride(guild.getPublicRole());
PermissionOverride roleOverride = channel.getPermissionOverride(role);
if (publicOverride != null)
{
permissions &= ~publicOverride.getDeniedRaw();
permissions |= publicOverride.getAllowedRaw();
}
if (roleOverride != null)
{
permissions &= ~roleOverride.getDeniedRaw();
permissions |= roleOverride.getAllowedRaw();
}
return permissions;
} | [
"public",
"static",
"long",
"getEffectivePermission",
"(",
"Channel",
"channel",
",",
"Role",
"role",
")",
"{",
"Checks",
".",
"notNull",
"(",
"channel",
",",
"\"Channel\"",
")",
";",
"Checks",
".",
"notNull",
"(",
"role",
",",
"\"Role\"",
")",
";",
"Guild",
"guild",
"=",
"channel",
".",
"getGuild",
"(",
")",
";",
"if",
"(",
"!",
"guild",
".",
"equals",
"(",
"role",
".",
"getGuild",
"(",
")",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Provided channel and role are not of the same guild!\"",
")",
";",
"long",
"permissions",
"=",
"role",
".",
"getPermissionsRaw",
"(",
")",
"|",
"guild",
".",
"getPublicRole",
"(",
")",
".",
"getPermissionsRaw",
"(",
")",
";",
"PermissionOverride",
"publicOverride",
"=",
"channel",
".",
"getPermissionOverride",
"(",
"guild",
".",
"getPublicRole",
"(",
")",
")",
";",
"PermissionOverride",
"roleOverride",
"=",
"channel",
".",
"getPermissionOverride",
"(",
"role",
")",
";",
"if",
"(",
"publicOverride",
"!=",
"null",
")",
"{",
"permissions",
"&=",
"~",
"publicOverride",
".",
"getDeniedRaw",
"(",
")",
";",
"permissions",
"|=",
"publicOverride",
".",
"getAllowedRaw",
"(",
")",
";",
"}",
"if",
"(",
"roleOverride",
"!=",
"null",
")",
"{",
"permissions",
"&=",
"~",
"roleOverride",
".",
"getDeniedRaw",
"(",
")",
";",
"permissions",
"|=",
"roleOverride",
".",
"getAllowedRaw",
"(",
")",
";",
"}",
"return",
"permissions",
";",
"}"
] | Gets the {@code long} representation of the effective permissions allowed for this {@link net.dv8tion.jda.core.entities.Role Role}
in this {@link net.dv8tion.jda.core.entities.Channel Channel}. This can be used in conjunction with
{@link net.dv8tion.jda.core.Permission#getPermissions(long) Permission.getPermissions(long)} to easily get a list of all
{@link net.dv8tion.jda.core.Permission Permissions} that this role can use in this {@link net.dv8tion.jda.core.entities.Channel Channel}.
@param channel
The {@link net.dv8tion.jda.core.entities.Channel Channel} in which permissions are being checked.
@param role
The {@link net.dv8tion.jda.core.entities.Role Role} whose permissions are being checked.
@throws IllegalArgumentException
if any of the provided parameters is {@code null}
or the provided entities are not from the same guild
@return The {@code long} representation of the effective permissions that this {@link net.dv8tion.jda.core.entities.Role Role}
has in this {@link net.dv8tion.jda.core.entities.Channel Channel} | [
"Gets",
"the",
"{",
"@code",
"long",
"}",
"representation",
"of",
"the",
"effective",
"permissions",
"allowed",
"for",
"this",
"{",
"@link",
"net",
".",
"dv8tion",
".",
"jda",
".",
"core",
".",
"entities",
".",
"Role",
"Role",
"}",
"in",
"this",
"{",
"@link",
"net",
".",
"dv8tion",
".",
"jda",
".",
"core",
".",
"entities",
".",
"Channel",
"Channel",
"}",
".",
"This",
"can",
"be",
"used",
"in",
"conjunction",
"with",
"{",
"@link",
"net",
".",
"dv8tion",
".",
"jda",
".",
"core",
".",
"Permission#getPermissions",
"(",
"long",
")",
"Permission",
".",
"getPermissions",
"(",
"long",
")",
"}",
"to",
"easily",
"get",
"a",
"list",
"of",
"all",
"{",
"@link",
"net",
".",
"dv8tion",
".",
"jda",
".",
"core",
".",
"Permission",
"Permissions",
"}",
"that",
"this",
"role",
"can",
"use",
"in",
"this",
"{",
"@link",
"net",
".",
"dv8tion",
".",
"jda",
".",
"core",
".",
"entities",
".",
"Channel",
"Channel",
"}",
"."
] | train | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/utils/PermissionUtil.java#L424-L451 |
JoeKerouac/utils | src/main/java/com/joe/utils/common/DateUtil.java | DateUtil.getFormatDate | public static String getFormatDate(String format, Date date) {
"""
获取指定日期的指定格式的字符串
@param format 日期格式
@param date 指定日期
@return 指定日期的指定格式的字符串
"""
return getFormatDate(format, date, ZoneId.systemDefault().getId());
} | java | public static String getFormatDate(String format, Date date) {
return getFormatDate(format, date, ZoneId.systemDefault().getId());
} | [
"public",
"static",
"String",
"getFormatDate",
"(",
"String",
"format",
",",
"Date",
"date",
")",
"{",
"return",
"getFormatDate",
"(",
"format",
",",
"date",
",",
"ZoneId",
".",
"systemDefault",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"}"
] | 获取指定日期的指定格式的字符串
@param format 日期格式
@param date 指定日期
@return 指定日期的指定格式的字符串 | [
"获取指定日期的指定格式的字符串"
] | train | https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/common/DateUtil.java#L192-L194 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/CmsPopup.java | CmsPopup.addButton | public void addButton(Widget button, int position) {
"""
Adds a button widget to the button panel before the given position.<p>
@param button the button widget
@param position the position to insert the button
"""
m_buttonPanel.insert(button, position);
m_buttonPanel.setStyleName(I_CmsLayoutBundle.INSTANCE.dialogCss().popupButtonPanel());
} | java | public void addButton(Widget button, int position) {
m_buttonPanel.insert(button, position);
m_buttonPanel.setStyleName(I_CmsLayoutBundle.INSTANCE.dialogCss().popupButtonPanel());
} | [
"public",
"void",
"addButton",
"(",
"Widget",
"button",
",",
"int",
"position",
")",
"{",
"m_buttonPanel",
".",
"insert",
"(",
"button",
",",
"position",
")",
";",
"m_buttonPanel",
".",
"setStyleName",
"(",
"I_CmsLayoutBundle",
".",
"INSTANCE",
".",
"dialogCss",
"(",
")",
".",
"popupButtonPanel",
"(",
")",
")",
";",
"}"
] | Adds a button widget to the button panel before the given position.<p>
@param button the button widget
@param position the position to insert the button | [
"Adds",
"a",
"button",
"widget",
"to",
"the",
"button",
"panel",
"before",
"the",
"given",
"position",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/CmsPopup.java#L498-L502 |
aws/aws-sdk-java | aws-java-sdk-glacier/src/main/java/com/amazonaws/services/glacier/TreeHashGenerator.java | TreeHashGenerator.calculateTreeHash | public static String calculateTreeHash(InputStream input)
throws AmazonClientException {
"""
Calculates a hex encoded binary hash using a tree hashing algorithm for
the data in the specified input stream. The method will consume all the
inputStream and close it when returned.
@param input
The input stream containing the data to hash.
@return The hex encoded binary tree hash for the data in the specified
input stream.
@throws AmazonClientException
If problems were encountered reading the data or calculating
the hash.
"""
try {
TreeHashInputStream treeHashInputStream =
new TreeHashInputStream(input);
byte[] buffer = new byte[1024];
while (treeHashInputStream.read(buffer, 0, buffer.length) != -1);
// closing is currently required to compute the checksum
treeHashInputStream.close();
return calculateTreeHash(treeHashInputStream.getChecksums());
} catch (Exception e) {
throw new AmazonClientException("Unable to compute hash", e);
}
} | java | public static String calculateTreeHash(InputStream input)
throws AmazonClientException {
try {
TreeHashInputStream treeHashInputStream =
new TreeHashInputStream(input);
byte[] buffer = new byte[1024];
while (treeHashInputStream.read(buffer, 0, buffer.length) != -1);
// closing is currently required to compute the checksum
treeHashInputStream.close();
return calculateTreeHash(treeHashInputStream.getChecksums());
} catch (Exception e) {
throw new AmazonClientException("Unable to compute hash", e);
}
} | [
"public",
"static",
"String",
"calculateTreeHash",
"(",
"InputStream",
"input",
")",
"throws",
"AmazonClientException",
"{",
"try",
"{",
"TreeHashInputStream",
"treeHashInputStream",
"=",
"new",
"TreeHashInputStream",
"(",
"input",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"while",
"(",
"treeHashInputStream",
".",
"read",
"(",
"buffer",
",",
"0",
",",
"buffer",
".",
"length",
")",
"!=",
"-",
"1",
")",
";",
"// closing is currently required to compute the checksum \r",
"treeHashInputStream",
".",
"close",
"(",
")",
";",
"return",
"calculateTreeHash",
"(",
"treeHashInputStream",
".",
"getChecksums",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"AmazonClientException",
"(",
"\"Unable to compute hash\"",
",",
"e",
")",
";",
"}",
"}"
] | Calculates a hex encoded binary hash using a tree hashing algorithm for
the data in the specified input stream. The method will consume all the
inputStream and close it when returned.
@param input
The input stream containing the data to hash.
@return The hex encoded binary tree hash for the data in the specified
input stream.
@throws AmazonClientException
If problems were encountered reading the data or calculating
the hash. | [
"Calculates",
"a",
"hex",
"encoded",
"binary",
"hash",
"using",
"a",
"tree",
"hashing",
"algorithm",
"for",
"the",
"data",
"in",
"the",
"specified",
"input",
"stream",
".",
"The",
"method",
"will",
"consume",
"all",
"the",
"inputStream",
"and",
"close",
"it",
"when",
"returned",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-glacier/src/main/java/com/amazonaws/services/glacier/TreeHashGenerator.java#L84-L97 |
mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java | ArrayAdapterCompat.addAll | public void addAll(int index, T... items) {
"""
Inserts the specified objects at the specified index in the array.
@param items The objects to insert into the array.
@param index The index at which the object must be inserted.
"""
List<T> collection = Arrays.asList(items);
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.addAll(index, collection);
} else {
mObjects.addAll(index, collection);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | java | public void addAll(int index, T... items) {
List<T> collection = Arrays.asList(items);
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.addAll(index, collection);
} else {
mObjects.addAll(index, collection);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | [
"public",
"void",
"addAll",
"(",
"int",
"index",
",",
"T",
"...",
"items",
")",
"{",
"List",
"<",
"T",
">",
"collection",
"=",
"Arrays",
".",
"asList",
"(",
"items",
")",
";",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"mOriginalValues",
"!=",
"null",
")",
"{",
"mOriginalValues",
".",
"addAll",
"(",
"index",
",",
"collection",
")",
";",
"}",
"else",
"{",
"mObjects",
".",
"addAll",
"(",
"index",
",",
"collection",
")",
";",
"}",
"}",
"if",
"(",
"mNotifyOnChange",
")",
"notifyDataSetChanged",
"(",
")",
";",
"}"
] | Inserts the specified objects at the specified index in the array.
@param items The objects to insert into the array.
@param index The index at which the object must be inserted. | [
"Inserts",
"the",
"specified",
"objects",
"at",
"the",
"specified",
"index",
"in",
"the",
"array",
"."
] | train | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java#L228-L238 |
Clivern/Racter | src/main/java/com/clivern/racter/senders/templates/MessageTemplate.java | MessageTemplate.setQuickReply | public void setQuickReply(String content_type, String title, String payload, String image_url) {
"""
Set Quick Reply
@param content_type the content type
@param title the title
@param payload the payload flag
@param image_url the image URL
"""
HashMap<String, String> quick_reply = new HashMap<String, String>();
quick_reply.put("content_type", content_type);
quick_reply.put("title", title);
quick_reply.put("payload", payload);
quick_reply.put("image_url", image_url);
this.message_quick_replies.add(quick_reply);
} | java | public void setQuickReply(String content_type, String title, String payload, String image_url)
{
HashMap<String, String> quick_reply = new HashMap<String, String>();
quick_reply.put("content_type", content_type);
quick_reply.put("title", title);
quick_reply.put("payload", payload);
quick_reply.put("image_url", image_url);
this.message_quick_replies.add(quick_reply);
} | [
"public",
"void",
"setQuickReply",
"(",
"String",
"content_type",
",",
"String",
"title",
",",
"String",
"payload",
",",
"String",
"image_url",
")",
"{",
"HashMap",
"<",
"String",
",",
"String",
">",
"quick_reply",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"quick_reply",
".",
"put",
"(",
"\"content_type\"",
",",
"content_type",
")",
";",
"quick_reply",
".",
"put",
"(",
"\"title\"",
",",
"title",
")",
";",
"quick_reply",
".",
"put",
"(",
"\"payload\"",
",",
"payload",
")",
";",
"quick_reply",
".",
"put",
"(",
"\"image_url\"",
",",
"image_url",
")",
";",
"this",
".",
"message_quick_replies",
".",
"add",
"(",
"quick_reply",
")",
";",
"}"
] | Set Quick Reply
@param content_type the content type
@param title the title
@param payload the payload flag
@param image_url the image URL | [
"Set",
"Quick",
"Reply"
] | train | https://github.com/Clivern/Racter/blob/bbde02f0c2a8a80653ad6b1607376d8408acd71c/src/main/java/com/clivern/racter/senders/templates/MessageTemplate.java#L117-L125 |
mgm-tp/jfunk | jfunk-web/src/main/java/com/mgmtp/jfunk/web/util/WebDriverTool.java | WebDriverTool.getElementText | public String getElementText(final By by, final boolean normalizeSpace) {
"""
Delegates to {@link #findElement(By)} and then calls {@link WebElement#getText()
getText()} on the returned element. If {@code normalizeSpace} is {@code true}, the
element's text is passed to {@link JFunkUtils#normalizeSpace(String)}.
@param by
the {@link By} used to locate the element
@param normalizeSpace
specifies whether whitespace in the element text are to be normalized
@return the text
"""
WebElement element = findElement(by);
String text = element.getText();
return normalizeSpace ? JFunkUtils.normalizeSpace(text) : text;
} | java | public String getElementText(final By by, final boolean normalizeSpace) {
WebElement element = findElement(by);
String text = element.getText();
return normalizeSpace ? JFunkUtils.normalizeSpace(text) : text;
} | [
"public",
"String",
"getElementText",
"(",
"final",
"By",
"by",
",",
"final",
"boolean",
"normalizeSpace",
")",
"{",
"WebElement",
"element",
"=",
"findElement",
"(",
"by",
")",
";",
"String",
"text",
"=",
"element",
".",
"getText",
"(",
")",
";",
"return",
"normalizeSpace",
"?",
"JFunkUtils",
".",
"normalizeSpace",
"(",
"text",
")",
":",
"text",
";",
"}"
] | Delegates to {@link #findElement(By)} and then calls {@link WebElement#getText()
getText()} on the returned element. If {@code normalizeSpace} is {@code true}, the
element's text is passed to {@link JFunkUtils#normalizeSpace(String)}.
@param by
the {@link By} used to locate the element
@param normalizeSpace
specifies whether whitespace in the element text are to be normalized
@return the text | [
"Delegates",
"to",
"{",
"@link",
"#findElement",
"(",
"By",
")",
"}",
"and",
"then",
"calls",
"{",
"@link",
"WebElement#getText",
"()",
"getText",
"()",
"}",
"on",
"the",
"returned",
"element",
".",
"If",
"{",
"@code",
"normalizeSpace",
"}",
"is",
"{",
"@code",
"true",
"}",
"the",
"element",
"s",
"text",
"is",
"passed",
"to",
"{",
"@link",
"JFunkUtils#normalizeSpace",
"(",
"String",
")",
"}",
"."
] | train | https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-web/src/main/java/com/mgmtp/jfunk/web/util/WebDriverTool.java#L572-L576 |
cloudant/java-cloudant | cloudant-client/src/main/java/com/cloudant/client/internal/query/Helpers.java | Helpers.encloseWithKey | public static String encloseWithKey(String key, Selector selector) {
"""
<P>
Returns the string form of a JSON object with the specified key mapping to a JSON object
enclosing the selector.
</P>
<pre>
{@code
Selector selector = eq("year", 2017);
System.out.println(selector.toString());
// Output: "year": {"$eq" : 2017}
System.out.println(SelectorUtils.encloseWithKey("selector", selector));
// Output: {"selector": {"year": {"$eq": 2017}}}
}
</pre>
@param key key to use for the selector (usually "selector" or "partial_filter_selector")
@param selector the selector to enclose
@return the string form of the selector enclosed in a JSON object with the specified key
"""
return String.format("{%s}", withKey(key, selector));
} | java | public static String encloseWithKey(String key, Selector selector) {
return String.format("{%s}", withKey(key, selector));
} | [
"public",
"static",
"String",
"encloseWithKey",
"(",
"String",
"key",
",",
"Selector",
"selector",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"{%s}\"",
",",
"withKey",
"(",
"key",
",",
"selector",
")",
")",
";",
"}"
] | <P>
Returns the string form of a JSON object with the specified key mapping to a JSON object
enclosing the selector.
</P>
<pre>
{@code
Selector selector = eq("year", 2017);
System.out.println(selector.toString());
// Output: "year": {"$eq" : 2017}
System.out.println(SelectorUtils.encloseWithKey("selector", selector));
// Output: {"selector": {"year": {"$eq": 2017}}}
}
</pre>
@param key key to use for the selector (usually "selector" or "partial_filter_selector")
@param selector the selector to enclose
@return the string form of the selector enclosed in a JSON object with the specified key | [
"<P",
">",
"Returns",
"the",
"string",
"form",
"of",
"a",
"JSON",
"object",
"with",
"the",
"specified",
"key",
"mapping",
"to",
"a",
"JSON",
"object",
"enclosing",
"the",
"selector",
".",
"<",
"/",
"P",
">",
"<pre",
">",
"{",
"@code",
"Selector",
"selector",
"=",
"eq",
"(",
"year",
"2017",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"selector",
".",
"toString",
"()",
")",
";",
"//",
"Output",
":",
"year",
":",
"{",
"$eq",
":",
"2017",
"}",
"System",
".",
"out",
".",
"println",
"(",
"SelectorUtils",
".",
"encloseWithKey",
"(",
"selector",
"selector",
"))",
";",
"//",
"Output",
":",
"{",
"selector",
":",
"{",
"year",
":",
"{",
"$eq",
":",
"2017",
"}}}",
"}",
"<",
"/",
"pre",
">"
] | train | https://github.com/cloudant/java-cloudant/blob/42c438654945361bded2cc0827afc046d535b31b/cloudant-client/src/main/java/com/cloudant/client/internal/query/Helpers.java#L167-L169 |
sarxos/win-registry | src/main/java/com/github/sarxos/winreg/WindowsRegistry.java | WindowsRegistry.readStringSubKeys | public List<String> readStringSubKeys(HKey hk, String key) throws RegistryException {
"""
Read the value name(s) from a given key
@param hk the HKEY
@param key the key
@return the value name(s)
@throws RegistryException when something is not right
"""
return readStringSubKeys(hk, key, null);
} | java | public List<String> readStringSubKeys(HKey hk, String key) throws RegistryException {
return readStringSubKeys(hk, key, null);
} | [
"public",
"List",
"<",
"String",
">",
"readStringSubKeys",
"(",
"HKey",
"hk",
",",
"String",
"key",
")",
"throws",
"RegistryException",
"{",
"return",
"readStringSubKeys",
"(",
"hk",
",",
"key",
",",
"null",
")",
";",
"}"
] | Read the value name(s) from a given key
@param hk the HKEY
@param key the key
@return the value name(s)
@throws RegistryException when something is not right | [
"Read",
"the",
"value",
"name",
"(",
"s",
")",
"from",
"a",
"given",
"key"
] | train | https://github.com/sarxos/win-registry/blob/5ccbe2157ae0ee894de7c41bec4bd7b1e0f5c437/src/main/java/com/github/sarxos/winreg/WindowsRegistry.java#L104-L106 |
haraldk/TwelveMonkeys | common/common-image/src/main/java/com/twelvemonkeys/image/GrayFilter.java | GrayFilter.filterRGB | public int filterRGB(int pX, int pY, int pARGB) {
"""
Filters one pixel using ITU color-conversion.
@param pX x
@param pY y
@param pARGB pixel value in default color space
@return the filtered pixel value in the default color space
"""
// Get color components
int r = pARGB >> 16 & 0xFF;
int g = pARGB >> 8 & 0xFF;
int b = pARGB & 0xFF;
// ITU standard: Gray scale=(222*Red+707*Green+71*Blue)/1000
int gray = (222 * r + 707 * g + 71 * b) / 1000;
//int gray = (int) ((float) (r + g + b) / 3.0f);
if (range != 1.0f) {
// Apply range
gray = low + (int) (gray * range);
}
// Return ARGB pixel
return (pARGB & 0xFF000000) | (gray << 16) | (gray << 8) | gray;
} | java | public int filterRGB(int pX, int pY, int pARGB) {
// Get color components
int r = pARGB >> 16 & 0xFF;
int g = pARGB >> 8 & 0xFF;
int b = pARGB & 0xFF;
// ITU standard: Gray scale=(222*Red+707*Green+71*Blue)/1000
int gray = (222 * r + 707 * g + 71 * b) / 1000;
//int gray = (int) ((float) (r + g + b) / 3.0f);
if (range != 1.0f) {
// Apply range
gray = low + (int) (gray * range);
}
// Return ARGB pixel
return (pARGB & 0xFF000000) | (gray << 16) | (gray << 8) | gray;
} | [
"public",
"int",
"filterRGB",
"(",
"int",
"pX",
",",
"int",
"pY",
",",
"int",
"pARGB",
")",
"{",
"// Get color components\r",
"int",
"r",
"=",
"pARGB",
">>",
"16",
"&",
"0xFF",
";",
"int",
"g",
"=",
"pARGB",
">>",
"8",
"&",
"0xFF",
";",
"int",
"b",
"=",
"pARGB",
"&",
"0xFF",
";",
"// ITU standard: Gray scale=(222*Red+707*Green+71*Blue)/1000\r",
"int",
"gray",
"=",
"(",
"222",
"*",
"r",
"+",
"707",
"*",
"g",
"+",
"71",
"*",
"b",
")",
"/",
"1000",
";",
"//int gray = (int) ((float) (r + g + b) / 3.0f);\r",
"if",
"(",
"range",
"!=",
"1.0f",
")",
"{",
"// Apply range\r",
"gray",
"=",
"low",
"+",
"(",
"int",
")",
"(",
"gray",
"*",
"range",
")",
";",
"}",
"// Return ARGB pixel\r",
"return",
"(",
"pARGB",
"&",
"0xFF000000",
")",
"|",
"(",
"gray",
"<<",
"16",
")",
"|",
"(",
"gray",
"<<",
"8",
")",
"|",
"gray",
";",
"}"
] | Filters one pixel using ITU color-conversion.
@param pX x
@param pY y
@param pARGB pixel value in default color space
@return the filtered pixel value in the default color space | [
"Filters",
"one",
"pixel",
"using",
"ITU",
"color",
"-",
"conversion",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-image/src/main/java/com/twelvemonkeys/image/GrayFilter.java#L112-L130 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java | CommonOps_DDRM.elementDiv | public static void elementDiv(DMatrixD1 a , DMatrixD1 b ) {
"""
<p>Performs the an element by element division operation:<br>
<br>
a<sub>ij</sub> = a<sub>ij</sub> / b<sub>ij</sub> <br>
</p>
@param a The left matrix in the division operation. Modified.
@param b The right matrix in the division operation. Not modified.
"""
if( a.numCols != b.numCols || a.numRows != b.numRows ) {
throw new MatrixDimensionException("The 'a' and 'b' matrices do not have compatible dimensions");
}
int length = a.getNumElements();
for( int i = 0; i < length; i++ ) {
a.div(i, b.get(i));
}
} | java | public static void elementDiv(DMatrixD1 a , DMatrixD1 b )
{
if( a.numCols != b.numCols || a.numRows != b.numRows ) {
throw new MatrixDimensionException("The 'a' and 'b' matrices do not have compatible dimensions");
}
int length = a.getNumElements();
for( int i = 0; i < length; i++ ) {
a.div(i, b.get(i));
}
} | [
"public",
"static",
"void",
"elementDiv",
"(",
"DMatrixD1",
"a",
",",
"DMatrixD1",
"b",
")",
"{",
"if",
"(",
"a",
".",
"numCols",
"!=",
"b",
".",
"numCols",
"||",
"a",
".",
"numRows",
"!=",
"b",
".",
"numRows",
")",
"{",
"throw",
"new",
"MatrixDimensionException",
"(",
"\"The 'a' and 'b' matrices do not have compatible dimensions\"",
")",
";",
"}",
"int",
"length",
"=",
"a",
".",
"getNumElements",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"a",
".",
"div",
"(",
"i",
",",
"b",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"}"
] | <p>Performs the an element by element division operation:<br>
<br>
a<sub>ij</sub> = a<sub>ij</sub> / b<sub>ij</sub> <br>
</p>
@param a The left matrix in the division operation. Modified.
@param b The right matrix in the division operation. Not modified. | [
"<p",
">",
"Performs",
"the",
"an",
"element",
"by",
"element",
"division",
"operation",
":",
"<br",
">",
"<br",
">",
"a<sub",
">",
"ij<",
"/",
"sub",
">",
"=",
"a<sub",
">",
"ij<",
"/",
"sub",
">",
"/",
"b<sub",
">",
"ij<",
"/",
"sub",
">",
"<br",
">",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java#L1551-L1562 |
Azure/azure-sdk-for-java | redis/resource-manager/v2018_03_01/src/main/java/com/microsoft/azure/management/redis/v2018_03_01/implementation/LinkedServersInner.java | LinkedServersInner.listAsync | public Observable<Page<RedisLinkedServerWithPropertiesInner>> listAsync(final String resourceGroupName, final String name) {
"""
Gets the list of linked servers associated with this redis cache (requires Premium SKU).
@param resourceGroupName The name of the resource group.
@param name The name of the redis cache.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<RedisLinkedServerWithPropertiesInner> object
"""
return listWithServiceResponseAsync(resourceGroupName, name)
.map(new Func1<ServiceResponse<Page<RedisLinkedServerWithPropertiesInner>>, Page<RedisLinkedServerWithPropertiesInner>>() {
@Override
public Page<RedisLinkedServerWithPropertiesInner> call(ServiceResponse<Page<RedisLinkedServerWithPropertiesInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<RedisLinkedServerWithPropertiesInner>> listAsync(final String resourceGroupName, final String name) {
return listWithServiceResponseAsync(resourceGroupName, name)
.map(new Func1<ServiceResponse<Page<RedisLinkedServerWithPropertiesInner>>, Page<RedisLinkedServerWithPropertiesInner>>() {
@Override
public Page<RedisLinkedServerWithPropertiesInner> call(ServiceResponse<Page<RedisLinkedServerWithPropertiesInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"RedisLinkedServerWithPropertiesInner",
">",
">",
"listAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"RedisLinkedServerWithPropertiesInner",
">",
">",
",",
"Page",
"<",
"RedisLinkedServerWithPropertiesInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"RedisLinkedServerWithPropertiesInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"RedisLinkedServerWithPropertiesInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the list of linked servers associated with this redis cache (requires Premium SKU).
@param resourceGroupName The name of the resource group.
@param name The name of the redis cache.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<RedisLinkedServerWithPropertiesInner> object | [
"Gets",
"the",
"list",
"of",
"linked",
"servers",
"associated",
"with",
"this",
"redis",
"cache",
"(",
"requires",
"Premium",
"SKU",
")",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/redis/resource-manager/v2018_03_01/src/main/java/com/microsoft/azure/management/redis/v2018_03_01/implementation/LinkedServersInner.java#L511-L519 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTemplateMatching.java | TldTemplateMatching.addDescriptor | public void addDescriptor( boolean positive , ImageRectangle rect ) {
"""
Creates a new descriptor for the specified region
@param positive if it is a positive or negative example
"""
addDescriptor(positive, rect.x0, rect.y0, rect.x1, rect.y1);
} | java | public void addDescriptor( boolean positive , ImageRectangle rect ) {
addDescriptor(positive, rect.x0, rect.y0, rect.x1, rect.y1);
} | [
"public",
"void",
"addDescriptor",
"(",
"boolean",
"positive",
",",
"ImageRectangle",
"rect",
")",
"{",
"addDescriptor",
"(",
"positive",
",",
"rect",
".",
"x0",
",",
"rect",
".",
"y0",
",",
"rect",
".",
"x1",
",",
"rect",
".",
"y1",
")",
";",
"}"
] | Creates a new descriptor for the specified region
@param positive if it is a positive or negative example | [
"Creates",
"a",
"new",
"descriptor",
"for",
"the",
"specified",
"region"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTemplateMatching.java#L84-L87 |
spring-projects/spring-boot | spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/AstUtils.java | AstUtils.hasAtLeastOneFieldOrMethod | public static boolean hasAtLeastOneFieldOrMethod(ClassNode node, String... types) {
"""
Determine if a {@link ClassNode} has one or more fields of the specified types or
method returning one or more of the specified types. N.B. the type names are not
normally fully qualified.
@param node the class to examine
@param types the types to look for
@return {@code true} if at least one of the types is found, otherwise {@code false}
"""
Set<String> typesSet = new HashSet<>(Arrays.asList(types));
for (FieldNode field : node.getFields()) {
if (typesSet.contains(field.getType().getName())) {
return true;
}
}
for (MethodNode method : node.getMethods()) {
if (typesSet.contains(method.getReturnType().getName())) {
return true;
}
}
return false;
} | java | public static boolean hasAtLeastOneFieldOrMethod(ClassNode node, String... types) {
Set<String> typesSet = new HashSet<>(Arrays.asList(types));
for (FieldNode field : node.getFields()) {
if (typesSet.contains(field.getType().getName())) {
return true;
}
}
for (MethodNode method : node.getMethods()) {
if (typesSet.contains(method.getReturnType().getName())) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasAtLeastOneFieldOrMethod",
"(",
"ClassNode",
"node",
",",
"String",
"...",
"types",
")",
"{",
"Set",
"<",
"String",
">",
"typesSet",
"=",
"new",
"HashSet",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"types",
")",
")",
";",
"for",
"(",
"FieldNode",
"field",
":",
"node",
".",
"getFields",
"(",
")",
")",
"{",
"if",
"(",
"typesSet",
".",
"contains",
"(",
"field",
".",
"getType",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"for",
"(",
"MethodNode",
"method",
":",
"node",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"typesSet",
".",
"contains",
"(",
"method",
".",
"getReturnType",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Determine if a {@link ClassNode} has one or more fields of the specified types or
method returning one or more of the specified types. N.B. the type names are not
normally fully qualified.
@param node the class to examine
@param types the types to look for
@return {@code true} if at least one of the types is found, otherwise {@code false} | [
"Determine",
"if",
"a",
"{"
] | train | https://github.com/spring-projects/spring-boot/blob/0b27f7c70e164b2b1a96477f1d9c1acba56790c1/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/AstUtils.java#L100-L113 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java | TheMovieDbApi.searchCompanies | public ResultList<Company> searchCompanies(String query, Integer page) throws MovieDbException {
"""
Search Companies.
You can use this method to search for production companies that are part
of TMDb. The company IDs will map to those returned on movie calls.
http://help.themoviedb.org/kb/api/search-companies
@param query query
@param page page
@return
@throws MovieDbException exception
"""
return tmdbSearch.searchCompanies(query, page);
} | java | public ResultList<Company> searchCompanies(String query, Integer page) throws MovieDbException {
return tmdbSearch.searchCompanies(query, page);
} | [
"public",
"ResultList",
"<",
"Company",
">",
"searchCompanies",
"(",
"String",
"query",
",",
"Integer",
"page",
")",
"throws",
"MovieDbException",
"{",
"return",
"tmdbSearch",
".",
"searchCompanies",
"(",
"query",
",",
"page",
")",
";",
"}"
] | Search Companies.
You can use this method to search for production companies that are part
of TMDb. The company IDs will map to those returned on movie calls.
http://help.themoviedb.org/kb/api/search-companies
@param query query
@param page page
@return
@throws MovieDbException exception | [
"Search",
"Companies",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java#L1317-L1319 |
digipost/signature-api-client-java | src/main/java/no/digipost/signature/client/direct/DirectJobStatusResponse.java | DirectJobStatusResponse.noUpdatedStatus | static DirectJobStatusResponse noUpdatedStatus(Instant nextPermittedPollTime) {
"""
This instance indicates that there has been no status updates since the last poll request for
{@link DirectJobStatusResponse}. Its status is {@link DirectJobStatus#NO_CHANGES NO_CHANGES}.
"""
return new DirectJobStatusResponse(null, null, NO_CHANGES, null, null, null, null, nextPermittedPollTime) {
@Override public long getSignatureJobId() {
throw new IllegalStateException(
"There were " + this + ", and querying the job ID is a programming error. " +
"Use the method is(" + DirectJobStatusResponse.class.getSimpleName() + "." + NO_CHANGES.name() + ") " +
"to check if there were any status change before attempting to get any further information.");
}
@Override public String toString() {
return "no direct jobs with updated status";
}
};
} | java | static DirectJobStatusResponse noUpdatedStatus(Instant nextPermittedPollTime) {
return new DirectJobStatusResponse(null, null, NO_CHANGES, null, null, null, null, nextPermittedPollTime) {
@Override public long getSignatureJobId() {
throw new IllegalStateException(
"There were " + this + ", and querying the job ID is a programming error. " +
"Use the method is(" + DirectJobStatusResponse.class.getSimpleName() + "." + NO_CHANGES.name() + ") " +
"to check if there were any status change before attempting to get any further information.");
}
@Override public String toString() {
return "no direct jobs with updated status";
}
};
} | [
"static",
"DirectJobStatusResponse",
"noUpdatedStatus",
"(",
"Instant",
"nextPermittedPollTime",
")",
"{",
"return",
"new",
"DirectJobStatusResponse",
"(",
"null",
",",
"null",
",",
"NO_CHANGES",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"nextPermittedPollTime",
")",
"{",
"@",
"Override",
"public",
"long",
"getSignatureJobId",
"(",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"There were \"",
"+",
"this",
"+",
"\", and querying the job ID is a programming error. \"",
"+",
"\"Use the method is(\"",
"+",
"DirectJobStatusResponse",
".",
"class",
".",
"getSimpleName",
"(",
")",
"+",
"\".\"",
"+",
"NO_CHANGES",
".",
"name",
"(",
")",
"+",
"\") \"",
"+",
"\"to check if there were any status change before attempting to get any further information.\"",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"no direct jobs with updated status\"",
";",
"}",
"}",
";",
"}"
] | This instance indicates that there has been no status updates since the last poll request for
{@link DirectJobStatusResponse}. Its status is {@link DirectJobStatus#NO_CHANGES NO_CHANGES}. | [
"This",
"instance",
"indicates",
"that",
"there",
"has",
"been",
"no",
"status",
"updates",
"since",
"the",
"last",
"poll",
"request",
"for",
"{"
] | train | https://github.com/digipost/signature-api-client-java/blob/246207571641fbac6beda5ffc585eec188825c45/src/main/java/no/digipost/signature/client/direct/DirectJobStatusResponse.java#L21-L35 |
google/closure-compiler | src/com/google/javascript/rhino/jstype/JSTypeRegistry.java | JSTypeRegistry.createTemplateTypeMap | public TemplateTypeMap createTemplateTypeMap(
ImmutableList<TemplateType> templateKeys,
ImmutableList<JSType> templateValues) {
"""
Creates a template type map from the specified list of template keys and
template value types.
"""
if (templateKeys == null) {
templateKeys = ImmutableList.of();
}
if (templateValues == null) {
templateValues = ImmutableList.of();
}
return (templateKeys.isEmpty() && templateValues.isEmpty())
? emptyTemplateTypeMap
: new TemplateTypeMap(this, templateKeys, templateValues);
} | java | public TemplateTypeMap createTemplateTypeMap(
ImmutableList<TemplateType> templateKeys,
ImmutableList<JSType> templateValues) {
if (templateKeys == null) {
templateKeys = ImmutableList.of();
}
if (templateValues == null) {
templateValues = ImmutableList.of();
}
return (templateKeys.isEmpty() && templateValues.isEmpty())
? emptyTemplateTypeMap
: new TemplateTypeMap(this, templateKeys, templateValues);
} | [
"public",
"TemplateTypeMap",
"createTemplateTypeMap",
"(",
"ImmutableList",
"<",
"TemplateType",
">",
"templateKeys",
",",
"ImmutableList",
"<",
"JSType",
">",
"templateValues",
")",
"{",
"if",
"(",
"templateKeys",
"==",
"null",
")",
"{",
"templateKeys",
"=",
"ImmutableList",
".",
"of",
"(",
")",
";",
"}",
"if",
"(",
"templateValues",
"==",
"null",
")",
"{",
"templateValues",
"=",
"ImmutableList",
".",
"of",
"(",
")",
";",
"}",
"return",
"(",
"templateKeys",
".",
"isEmpty",
"(",
")",
"&&",
"templateValues",
".",
"isEmpty",
"(",
")",
")",
"?",
"emptyTemplateTypeMap",
":",
"new",
"TemplateTypeMap",
"(",
"this",
",",
"templateKeys",
",",
"templateValues",
")",
";",
"}"
] | Creates a template type map from the specified list of template keys and
template value types. | [
"Creates",
"a",
"template",
"type",
"map",
"from",
"the",
"specified",
"list",
"of",
"template",
"keys",
"and",
"template",
"value",
"types",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSTypeRegistry.java#L1855-L1867 |
abel533/EasyXls | src/main/java/com/github/abel533/easyxls/common/XlsUtil.java | XlsUtil.list2Xls | public static boolean list2Xls(List<?> list, String xmlPath, OutputStream outputStream) throws Exception {
"""
导出list对象到excel
@param list 导出的list
@param xmlPath xml完整路径
@param outputStream 输出流
@return 处理结果,true成功,false失败
@throws Exception
"""
try {
ExcelConfig config = getEasyExcel(xmlPath);
return list2Xls(config, list, outputStream);
} catch (Exception e1) {
return false;
}
} | java | public static boolean list2Xls(List<?> list, String xmlPath, OutputStream outputStream) throws Exception {
try {
ExcelConfig config = getEasyExcel(xmlPath);
return list2Xls(config, list, outputStream);
} catch (Exception e1) {
return false;
}
} | [
"public",
"static",
"boolean",
"list2Xls",
"(",
"List",
"<",
"?",
">",
"list",
",",
"String",
"xmlPath",
",",
"OutputStream",
"outputStream",
")",
"throws",
"Exception",
"{",
"try",
"{",
"ExcelConfig",
"config",
"=",
"getEasyExcel",
"(",
"xmlPath",
")",
";",
"return",
"list2Xls",
"(",
"config",
",",
"list",
",",
"outputStream",
")",
";",
"}",
"catch",
"(",
"Exception",
"e1",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | 导出list对象到excel
@param list 导出的list
@param xmlPath xml完整路径
@param outputStream 输出流
@return 处理结果,true成功,false失败
@throws Exception | [
"导出list对象到excel"
] | train | https://github.com/abel533/EasyXls/blob/f73be23745c2180d7c0b8f0a510e72e61cc37d5d/src/main/java/com/github/abel533/easyxls/common/XlsUtil.java#L338-L345 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/query/dsl/functions/DateFunctions.java | DateFunctions.dateDiffStr | public static Expression dateDiffStr(String expression1, String expression2, DatePart part) {
"""
Returned expression results in Performs Date arithmetic.
Returns the elapsed time between two date strings in a supported format, as an integer whose unit is part.
"""
return dateDiffStr(x(expression1), x(expression2), part);
} | java | public static Expression dateDiffStr(String expression1, String expression2, DatePart part) {
return dateDiffStr(x(expression1), x(expression2), part);
} | [
"public",
"static",
"Expression",
"dateDiffStr",
"(",
"String",
"expression1",
",",
"String",
"expression2",
",",
"DatePart",
"part",
")",
"{",
"return",
"dateDiffStr",
"(",
"x",
"(",
"expression1",
")",
",",
"x",
"(",
"expression2",
")",
",",
"part",
")",
";",
"}"
] | Returned expression results in Performs Date arithmetic.
Returns the elapsed time between two date strings in a supported format, as an integer whose unit is part. | [
"Returned",
"expression",
"results",
"in",
"Performs",
"Date",
"arithmetic",
".",
"Returns",
"the",
"elapsed",
"time",
"between",
"two",
"date",
"strings",
"in",
"a",
"supported",
"format",
"as",
"an",
"integer",
"whose",
"unit",
"is",
"part",
"."
] | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/dsl/functions/DateFunctions.java#L132-L134 |
jcuda/jcuda | JCudaJava/src/main/java/jcuda/runtime/JCuda.java | JCuda.cudaBindSurfaceToArray | public static int cudaBindSurfaceToArray(surfaceReference surfref, cudaArray array, cudaChannelFormatDesc desc) {
"""
[C++ API] Binds an array to a surface
<pre>
template < class T, int dim > cudaError_t cudaBindSurfaceToArray (
const surface < T,
dim > & surf,
cudaArray_const_t array,
const cudaChannelFormatDesc& desc ) [inline]
</pre>
<div>
<p>[C++ API] Binds an array to a surface
Binds the CUDA array <tt>array</tt> to the surface reference <tt>surf</tt>. <tt>desc</tt> describes how the memory is interpreted when
dealing with the surface. Any CUDA array previously bound to <tt>surf</tt> is unbound.
</p>
<div>
<span>Note:</span>
<p>Note that this
function may also return error codes from previous, asynchronous
launches.
</p>
</div>
</p>
</div>
@param surfref Surface to bind
@param array Memory array on device
@param desc Channel format
@param surf Surface to bind
@param array Memory array on device
@param surf Surface to bind
@param array Memory array on device
@param desc Channel format
@return cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSurface
@see JCuda#cudaBindSurfaceToArray
@see JCuda#cudaBindSurfaceToArray
"""
return checkResult(cudaBindSurfaceToArrayNative(surfref, array, desc));
} | java | public static int cudaBindSurfaceToArray(surfaceReference surfref, cudaArray array, cudaChannelFormatDesc desc)
{
return checkResult(cudaBindSurfaceToArrayNative(surfref, array, desc));
} | [
"public",
"static",
"int",
"cudaBindSurfaceToArray",
"(",
"surfaceReference",
"surfref",
",",
"cudaArray",
"array",
",",
"cudaChannelFormatDesc",
"desc",
")",
"{",
"return",
"checkResult",
"(",
"cudaBindSurfaceToArrayNative",
"(",
"surfref",
",",
"array",
",",
"desc",
")",
")",
";",
"}"
] | [C++ API] Binds an array to a surface
<pre>
template < class T, int dim > cudaError_t cudaBindSurfaceToArray (
const surface < T,
dim > & surf,
cudaArray_const_t array,
const cudaChannelFormatDesc& desc ) [inline]
</pre>
<div>
<p>[C++ API] Binds an array to a surface
Binds the CUDA array <tt>array</tt> to the surface reference <tt>surf</tt>. <tt>desc</tt> describes how the memory is interpreted when
dealing with the surface. Any CUDA array previously bound to <tt>surf</tt> is unbound.
</p>
<div>
<span>Note:</span>
<p>Note that this
function may also return error codes from previous, asynchronous
launches.
</p>
</div>
</p>
</div>
@param surfref Surface to bind
@param array Memory array on device
@param desc Channel format
@param surf Surface to bind
@param array Memory array on device
@param surf Surface to bind
@param array Memory array on device
@param desc Channel format
@return cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSurface
@see JCuda#cudaBindSurfaceToArray
@see JCuda#cudaBindSurfaceToArray | [
"[",
"C",
"++",
"API",
"]",
"Binds",
"an",
"array",
"to",
"a",
"surface"
] | train | https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/runtime/JCuda.java#L9477-L9480 |
bozaro/git-lfs-java | gitlfs-client/src/main/java/ru/bozaro/gitlfs/client/Client.java | Client.getObject | @NotNull
public <T> T getObject(@Nullable final Meta meta, @NotNull final Links links, @NotNull final StreamHandler<T> handler) throws IOException {
"""
Download object by metadata.
@param meta Object metadata for stream validation.
@param links Object links.
@param handler Stream handler.
@return Stream handler result.
@throws FileNotFoundException File not found exception if object don't exists on LFS server.
@throws IOException On some errors.
"""
final Link link = links.getLinks().get(LinkType.Download);
if (link == null) {
throw new FileNotFoundException();
}
return doRequest(link, new ObjectGet<>(inputStream -> handler.accept(meta != null ? new InputStreamValidator(inputStream, meta) : inputStream)), link.getHref());
} | java | @NotNull
public <T> T getObject(@Nullable final Meta meta, @NotNull final Links links, @NotNull final StreamHandler<T> handler) throws IOException {
final Link link = links.getLinks().get(LinkType.Download);
if (link == null) {
throw new FileNotFoundException();
}
return doRequest(link, new ObjectGet<>(inputStream -> handler.accept(meta != null ? new InputStreamValidator(inputStream, meta) : inputStream)), link.getHref());
} | [
"@",
"NotNull",
"public",
"<",
"T",
">",
"T",
"getObject",
"(",
"@",
"Nullable",
"final",
"Meta",
"meta",
",",
"@",
"NotNull",
"final",
"Links",
"links",
",",
"@",
"NotNull",
"final",
"StreamHandler",
"<",
"T",
">",
"handler",
")",
"throws",
"IOException",
"{",
"final",
"Link",
"link",
"=",
"links",
".",
"getLinks",
"(",
")",
".",
"get",
"(",
"LinkType",
".",
"Download",
")",
";",
"if",
"(",
"link",
"==",
"null",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
")",
";",
"}",
"return",
"doRequest",
"(",
"link",
",",
"new",
"ObjectGet",
"<>",
"(",
"inputStream",
"->",
"handler",
".",
"accept",
"(",
"meta",
"!=",
"null",
"?",
"new",
"InputStreamValidator",
"(",
"inputStream",
",",
"meta",
")",
":",
"inputStream",
")",
")",
",",
"link",
".",
"getHref",
"(",
")",
")",
";",
"}"
] | Download object by metadata.
@param meta Object metadata for stream validation.
@param links Object links.
@param handler Stream handler.
@return Stream handler result.
@throws FileNotFoundException File not found exception if object don't exists on LFS server.
@throws IOException On some errors. | [
"Download",
"object",
"by",
"metadata",
"."
] | train | https://github.com/bozaro/git-lfs-java/blob/ee05bf0472ee61bf362cf93d283e5ee5d44ef685/gitlfs-client/src/main/java/ru/bozaro/gitlfs/client/Client.java#L151-L158 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/NetworkConfig.java | NetworkConfig.extractPemString | private static String extractPemString(JsonObject json, String fieldName, String msgPrefix) throws NetworkConfigurationException {
"""
Returns the PEM (as a String) from either a path or a pem field
"""
String path = null;
String pemString = null;
JsonObject jsonField = getJsonValueAsObject(json.get(fieldName));
if (jsonField != null) {
path = getJsonValueAsString(jsonField.get("path"));
pemString = getJsonValueAsString(jsonField.get("pem"));
}
if (path != null && pemString != null) {
throw new NetworkConfigurationException(format("%s should not specify both %s path and pem", msgPrefix, fieldName));
}
if (path != null) {
// Determine full pathname and ensure the file exists
File pemFile = new File(path);
String fullPathname = pemFile.getAbsolutePath();
if (!pemFile.exists()) {
throw new NetworkConfigurationException(format("%s: %s file %s does not exist", msgPrefix, fieldName, fullPathname));
}
try (FileInputStream stream = new FileInputStream(pemFile)) {
pemString = IOUtils.toString(stream, "UTF-8");
} catch (IOException ioe) {
throw new NetworkConfigurationException(format("Failed to read file: %s", fullPathname), ioe);
}
}
return pemString;
} | java | private static String extractPemString(JsonObject json, String fieldName, String msgPrefix) throws NetworkConfigurationException {
String path = null;
String pemString = null;
JsonObject jsonField = getJsonValueAsObject(json.get(fieldName));
if (jsonField != null) {
path = getJsonValueAsString(jsonField.get("path"));
pemString = getJsonValueAsString(jsonField.get("pem"));
}
if (path != null && pemString != null) {
throw new NetworkConfigurationException(format("%s should not specify both %s path and pem", msgPrefix, fieldName));
}
if (path != null) {
// Determine full pathname and ensure the file exists
File pemFile = new File(path);
String fullPathname = pemFile.getAbsolutePath();
if (!pemFile.exists()) {
throw new NetworkConfigurationException(format("%s: %s file %s does not exist", msgPrefix, fieldName, fullPathname));
}
try (FileInputStream stream = new FileInputStream(pemFile)) {
pemString = IOUtils.toString(stream, "UTF-8");
} catch (IOException ioe) {
throw new NetworkConfigurationException(format("Failed to read file: %s", fullPathname), ioe);
}
}
return pemString;
} | [
"private",
"static",
"String",
"extractPemString",
"(",
"JsonObject",
"json",
",",
"String",
"fieldName",
",",
"String",
"msgPrefix",
")",
"throws",
"NetworkConfigurationException",
"{",
"String",
"path",
"=",
"null",
";",
"String",
"pemString",
"=",
"null",
";",
"JsonObject",
"jsonField",
"=",
"getJsonValueAsObject",
"(",
"json",
".",
"get",
"(",
"fieldName",
")",
")",
";",
"if",
"(",
"jsonField",
"!=",
"null",
")",
"{",
"path",
"=",
"getJsonValueAsString",
"(",
"jsonField",
".",
"get",
"(",
"\"path\"",
")",
")",
";",
"pemString",
"=",
"getJsonValueAsString",
"(",
"jsonField",
".",
"get",
"(",
"\"pem\"",
")",
")",
";",
"}",
"if",
"(",
"path",
"!=",
"null",
"&&",
"pemString",
"!=",
"null",
")",
"{",
"throw",
"new",
"NetworkConfigurationException",
"(",
"format",
"(",
"\"%s should not specify both %s path and pem\"",
",",
"msgPrefix",
",",
"fieldName",
")",
")",
";",
"}",
"if",
"(",
"path",
"!=",
"null",
")",
"{",
"// Determine full pathname and ensure the file exists",
"File",
"pemFile",
"=",
"new",
"File",
"(",
"path",
")",
";",
"String",
"fullPathname",
"=",
"pemFile",
".",
"getAbsolutePath",
"(",
")",
";",
"if",
"(",
"!",
"pemFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"NetworkConfigurationException",
"(",
"format",
"(",
"\"%s: %s file %s does not exist\"",
",",
"msgPrefix",
",",
"fieldName",
",",
"fullPathname",
")",
")",
";",
"}",
"try",
"(",
"FileInputStream",
"stream",
"=",
"new",
"FileInputStream",
"(",
"pemFile",
")",
")",
"{",
"pemString",
"=",
"IOUtils",
".",
"toString",
"(",
"stream",
",",
"\"UTF-8\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"NetworkConfigurationException",
"(",
"format",
"(",
"\"Failed to read file: %s\"",
",",
"fullPathname",
")",
",",
"ioe",
")",
";",
"}",
"}",
"return",
"pemString",
";",
"}"
] | Returns the PEM (as a String) from either a path or a pem field | [
"Returns",
"the",
"PEM",
"(",
"as",
"a",
"String",
")",
"from",
"either",
"a",
"path",
"or",
"a",
"pem",
"field"
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/NetworkConfig.java#L933-L964 |
thymeleaf/thymeleaf | src/main/java/org/thymeleaf/expression/Uris.java | Uris.escapeFragmentId | public String escapeFragmentId(final String text, final String encoding) {
"""
<p>
Perform am URI fragment identifier <strong>escape</strong> operation
on a {@code String} input.
</p>
<p>
This method simply calls the equivalent method in the {@code UriEscape} class from the
<a href="http://www.unbescape.org">Unbescape</a> library.
</p>
<p>
The following are the only allowed chars in an URI fragment identifier (will not be escaped):
</p>
<ul>
<li>{@code A-Z a-z 0-9}</li>
<li>{@code - . _ ~}</li>
<li>{@code ! $ & ' ( ) * + , ; =}</li>
<li>{@code : @}</li>
<li>{@code / ?}</li>
</ul>
<p>
All other chars will be escaped by converting them to the sequence of bytes that
represents them in the specified <em>encoding</em> and then representing each byte
in {@code %HH} syntax, being {@code HH} the hexadecimal representation of the byte.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the {@code String} to be escaped.
@param encoding the encoding to be used for escaping.
@return The escaped result {@code String}. As a memory-performance improvement, will return the exact
same object as the {@code text} input argument if no escaping modifications were required (and
no additional {@code String} objects will be created during processing). Will
return {@code null} if {@code text} is {@code null}.
"""
return UriEscape.escapeUriFragmentId(text, encoding);
} | java | public String escapeFragmentId(final String text, final String encoding) {
return UriEscape.escapeUriFragmentId(text, encoding);
} | [
"public",
"String",
"escapeFragmentId",
"(",
"final",
"String",
"text",
",",
"final",
"String",
"encoding",
")",
"{",
"return",
"UriEscape",
".",
"escapeUriFragmentId",
"(",
"text",
",",
"encoding",
")",
";",
"}"
] | <p>
Perform am URI fragment identifier <strong>escape</strong> operation
on a {@code String} input.
</p>
<p>
This method simply calls the equivalent method in the {@code UriEscape} class from the
<a href="http://www.unbescape.org">Unbescape</a> library.
</p>
<p>
The following are the only allowed chars in an URI fragment identifier (will not be escaped):
</p>
<ul>
<li>{@code A-Z a-z 0-9}</li>
<li>{@code - . _ ~}</li>
<li>{@code ! $ & ' ( ) * + , ; =}</li>
<li>{@code : @}</li>
<li>{@code / ?}</li>
</ul>
<p>
All other chars will be escaped by converting them to the sequence of bytes that
represents them in the specified <em>encoding</em> and then representing each byte
in {@code %HH} syntax, being {@code HH} the hexadecimal representation of the byte.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the {@code String} to be escaped.
@param encoding the encoding to be used for escaping.
@return The escaped result {@code String}. As a memory-performance improvement, will return the exact
same object as the {@code text} input argument if no escaping modifications were required (and
no additional {@code String} objects will be created during processing). Will
return {@code null} if {@code text} is {@code null}. | [
"<p",
">",
"Perform",
"am",
"URI",
"fragment",
"identifier",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"{",
"@code",
"String",
"}",
"input",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"simply",
"calls",
"the",
"equivalent",
"method",
"in",
"the",
"{",
"@code",
"UriEscape",
"}",
"class",
"from",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"unbescape",
".",
"org",
">",
"Unbescape<",
"/",
"a",
">",
"library",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"following",
"are",
"the",
"only",
"allowed",
"chars",
"in",
"an",
"URI",
"fragment",
"identifier",
"(",
"will",
"not",
"be",
"escaped",
")",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"{",
"@code",
"A",
"-",
"Z",
"a",
"-",
"z",
"0",
"-",
"9",
"}",
"<",
"/",
"li",
">",
"<li",
">",
"{",
"@code",
"-",
".",
"_",
"~",
"}",
"<",
"/",
"li",
">",
"<li",
">",
"{",
"@code",
"!",
"$",
"&",
"(",
")",
"*",
"+",
";",
"=",
"}",
"<",
"/",
"li",
">",
"<li",
">",
"{",
"@code",
":",
"@",
"}",
"<",
"/",
"li",
">",
"<li",
">",
"{",
"@code",
"/",
"?",
"}",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<p",
">",
"All",
"other",
"chars",
"will",
"be",
"escaped",
"by",
"converting",
"them",
"to",
"the",
"sequence",
"of",
"bytes",
"that",
"represents",
"them",
"in",
"the",
"specified",
"<em",
">",
"encoding<",
"/",
"em",
">",
"and",
"then",
"representing",
"each",
"byte",
"in",
"{",
"@code",
"%HH",
"}",
"syntax",
"being",
"{",
"@code",
"HH",
"}",
"the",
"hexadecimal",
"representation",
"of",
"the",
"byte",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/thymeleaf/thymeleaf/blob/2b0e6d6d7571fbe638904b5fd222fc9e77188879/src/main/java/org/thymeleaf/expression/Uris.java#L443-L445 |
xiancloud/xian | xian-zookeeper/xian-curator/xian-curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/Revoker.java | Revoker.attemptRevoke | public static void attemptRevoke(CuratorFramework client, String path) throws Exception {
"""
Utility to mark a lock for revocation. Assuming that the lock has been registered with
a {@link RevocationListener}, it will get called and the lock should be released. Note,
however, that revocation is cooperative.
@param client the client
@param path the path of the lock - usually from something like
{@link InterProcessMutex#getParticipantNodes()}
@throws Exception errors
"""
try
{
client.setData().forPath(path, LockInternals.REVOKE_MESSAGE);
}
catch ( KeeperException.NoNodeException ignore )
{
// ignore
}
} | java | public static void attemptRevoke(CuratorFramework client, String path) throws Exception
{
try
{
client.setData().forPath(path, LockInternals.REVOKE_MESSAGE);
}
catch ( KeeperException.NoNodeException ignore )
{
// ignore
}
} | [
"public",
"static",
"void",
"attemptRevoke",
"(",
"CuratorFramework",
"client",
",",
"String",
"path",
")",
"throws",
"Exception",
"{",
"try",
"{",
"client",
".",
"setData",
"(",
")",
".",
"forPath",
"(",
"path",
",",
"LockInternals",
".",
"REVOKE_MESSAGE",
")",
";",
"}",
"catch",
"(",
"KeeperException",
".",
"NoNodeException",
"ignore",
")",
"{",
"// ignore",
"}",
"}"
] | Utility to mark a lock for revocation. Assuming that the lock has been registered with
a {@link RevocationListener}, it will get called and the lock should be released. Note,
however, that revocation is cooperative.
@param client the client
@param path the path of the lock - usually from something like
{@link InterProcessMutex#getParticipantNodes()}
@throws Exception errors | [
"Utility",
"to",
"mark",
"a",
"lock",
"for",
"revocation",
".",
"Assuming",
"that",
"the",
"lock",
"has",
"been",
"registered",
"with",
"a",
"{",
"@link",
"RevocationListener",
"}",
"it",
"will",
"get",
"called",
"and",
"the",
"lock",
"should",
"be",
"released",
".",
"Note",
"however",
"that",
"revocation",
"is",
"cooperative",
"."
] | train | https://github.com/xiancloud/xian/blob/1948e088545553d2745b2c86d8b5a64988bb850e/xian-zookeeper/xian-curator/xian-curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/Revoker.java#L36-L46 |
google/closure-compiler | src/com/google/javascript/jscomp/ControlFlowAnalysis.java | ControlFlowAnalysis.matchLabel | private static boolean matchLabel(Node target, String label) {
"""
Check if label is actually referencing the target control structure. If
label is null, it always returns true.
"""
if (label == null) {
return true;
}
while (target.isLabel()) {
if (target.getFirstChild().getString().equals(label)) {
return true;
}
target = target.getParent();
}
return false;
} | java | private static boolean matchLabel(Node target, String label) {
if (label == null) {
return true;
}
while (target.isLabel()) {
if (target.getFirstChild().getString().equals(label)) {
return true;
}
target = target.getParent();
}
return false;
} | [
"private",
"static",
"boolean",
"matchLabel",
"(",
"Node",
"target",
",",
"String",
"label",
")",
"{",
"if",
"(",
"label",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"while",
"(",
"target",
".",
"isLabel",
"(",
")",
")",
"{",
"if",
"(",
"target",
".",
"getFirstChild",
"(",
")",
".",
"getString",
"(",
")",
".",
"equals",
"(",
"label",
")",
")",
"{",
"return",
"true",
";",
"}",
"target",
"=",
"target",
".",
"getParent",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Check if label is actually referencing the target control structure. If
label is null, it always returns true. | [
"Check",
"if",
"label",
"is",
"actually",
"referencing",
"the",
"target",
"control",
"structure",
".",
"If",
"label",
"is",
"null",
"it",
"always",
"returns",
"true",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ControlFlowAnalysis.java#L946-L957 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/prediction/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/prediction/CustomVisionPredictionManager.java | CustomVisionPredictionManager.authenticate | public static PredictionEndpoint authenticate(String baseUrl, ServiceClientCredentials credentials, final String apiKey) {
"""
Initializes an instance of Custom Vision Prediction API client.
@param baseUrl the base URL of the service
@param credentials the management credentials for Azure
@param apiKey the Custom Vision Prediction API key
@return the Custom Vision Prediction API client
"""
return new PredictionEndpointImpl(baseUrl, credentials).withApiKey(apiKey);
} | java | public static PredictionEndpoint authenticate(String baseUrl, ServiceClientCredentials credentials, final String apiKey) {
return new PredictionEndpointImpl(baseUrl, credentials).withApiKey(apiKey);
} | [
"public",
"static",
"PredictionEndpoint",
"authenticate",
"(",
"String",
"baseUrl",
",",
"ServiceClientCredentials",
"credentials",
",",
"final",
"String",
"apiKey",
")",
"{",
"return",
"new",
"PredictionEndpointImpl",
"(",
"baseUrl",
",",
"credentials",
")",
".",
"withApiKey",
"(",
"apiKey",
")",
";",
"}"
] | Initializes an instance of Custom Vision Prediction API client.
@param baseUrl the base URL of the service
@param credentials the management credentials for Azure
@param apiKey the Custom Vision Prediction API key
@return the Custom Vision Prediction API client | [
"Initializes",
"an",
"instance",
"of",
"Custom",
"Vision",
"Prediction",
"API",
"client",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/prediction/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/prediction/CustomVisionPredictionManager.java#L63-L65 |
google/error-prone | check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java | ASTHelpers.constValue | @Nullable
public static <T> T constValue(Tree tree, Class<? extends T> clazz) {
"""
Returns the compile-time constant value of a tree if it is of type clazz, or {@code null}.
"""
Object value = constValue(tree);
return clazz.isInstance(value) ? clazz.cast(value) : null;
} | java | @Nullable
public static <T> T constValue(Tree tree, Class<? extends T> clazz) {
Object value = constValue(tree);
return clazz.isInstance(value) ? clazz.cast(value) : null;
} | [
"@",
"Nullable",
"public",
"static",
"<",
"T",
">",
"T",
"constValue",
"(",
"Tree",
"tree",
",",
"Class",
"<",
"?",
"extends",
"T",
">",
"clazz",
")",
"{",
"Object",
"value",
"=",
"constValue",
"(",
"tree",
")",
";",
"return",
"clazz",
".",
"isInstance",
"(",
"value",
")",
"?",
"clazz",
".",
"cast",
"(",
"value",
")",
":",
"null",
";",
"}"
] | Returns the compile-time constant value of a tree if it is of type clazz, or {@code null}. | [
"Returns",
"the",
"compile",
"-",
"time",
"constant",
"value",
"of",
"a",
"tree",
"if",
"it",
"is",
"of",
"type",
"clazz",
"or",
"{"
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java#L931-L935 |
fengwenyi/JavaLib | bak/HttpsClientUtil.java | HttpsClientUtil.doPost | public static String doPost(String url, Map<String, String> header, String param) throws KeyManagementException,
NoSuchAlgorithmException, IOException {
"""
POST方式向Http(s)提交数据并获取返回结果
@param url URL
@param header Header
@param param 参数(String)
@return 服务器数据
@throws KeyManagementException [ellipsis]
@throws NoSuchAlgorithmException [ellipsis]
@throws IOException [ellipsis]
"""
String result = null;
HttpClient httpClient = new SSLClient();
httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Constant.DEFAULT_CONN_TIMEOUT);
httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, Constant.DEFAULT_READ_TIMEOUT);
HttpPost httpPost = new HttpPost(url);
Iterator iterator;
if (header != null) {
Set<String> keys = header.keySet();
iterator = keys.iterator();
while(iterator.hasNext()) {
String key = (String)iterator.next();
httpPost.setHeader(key, header.get(key));
}
}
httpPost.setEntity(new StringEntity(param, Constant.DEFAULT_CHARSET));
HttpResponse response = httpClient.execute(httpPost);
if (response != null) {
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
result = EntityUtils.toString(resEntity, Constant.DEFAULT_CHARSET);
}
}
return result;
} | java | public static String doPost(String url, Map<String, String> header, String param) throws KeyManagementException,
NoSuchAlgorithmException, IOException {
String result = null;
HttpClient httpClient = new SSLClient();
httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Constant.DEFAULT_CONN_TIMEOUT);
httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, Constant.DEFAULT_READ_TIMEOUT);
HttpPost httpPost = new HttpPost(url);
Iterator iterator;
if (header != null) {
Set<String> keys = header.keySet();
iterator = keys.iterator();
while(iterator.hasNext()) {
String key = (String)iterator.next();
httpPost.setHeader(key, header.get(key));
}
}
httpPost.setEntity(new StringEntity(param, Constant.DEFAULT_CHARSET));
HttpResponse response = httpClient.execute(httpPost);
if (response != null) {
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
result = EntityUtils.toString(resEntity, Constant.DEFAULT_CHARSET);
}
}
return result;
} | [
"public",
"static",
"String",
"doPost",
"(",
"String",
"url",
",",
"Map",
"<",
"String",
",",
"String",
">",
"header",
",",
"String",
"param",
")",
"throws",
"KeyManagementException",
",",
"NoSuchAlgorithmException",
",",
"IOException",
"{",
"String",
"result",
"=",
"null",
";",
"HttpClient",
"httpClient",
"=",
"new",
"SSLClient",
"(",
")",
";",
"httpClient",
".",
"getParams",
"(",
")",
".",
"setParameter",
"(",
"CoreConnectionPNames",
".",
"CONNECTION_TIMEOUT",
",",
"Constant",
".",
"DEFAULT_CONN_TIMEOUT",
")",
";",
"httpClient",
".",
"getParams",
"(",
")",
".",
"setParameter",
"(",
"CoreConnectionPNames",
".",
"SO_TIMEOUT",
",",
"Constant",
".",
"DEFAULT_READ_TIMEOUT",
")",
";",
"HttpPost",
"httpPost",
"=",
"new",
"HttpPost",
"(",
"url",
")",
";",
"Iterator",
"iterator",
";",
"if",
"(",
"header",
"!=",
"null",
")",
"{",
"Set",
"<",
"String",
">",
"keys",
"=",
"header",
".",
"keySet",
"(",
")",
";",
"iterator",
"=",
"keys",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"key",
"=",
"(",
"String",
")",
"iterator",
".",
"next",
"(",
")",
";",
"httpPost",
".",
"setHeader",
"(",
"key",
",",
"header",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"}",
"httpPost",
".",
"setEntity",
"(",
"new",
"StringEntity",
"(",
"param",
",",
"Constant",
".",
"DEFAULT_CHARSET",
")",
")",
";",
"HttpResponse",
"response",
"=",
"httpClient",
".",
"execute",
"(",
"httpPost",
")",
";",
"if",
"(",
"response",
"!=",
"null",
")",
"{",
"HttpEntity",
"resEntity",
"=",
"response",
".",
"getEntity",
"(",
")",
";",
"if",
"(",
"resEntity",
"!=",
"null",
")",
"{",
"result",
"=",
"EntityUtils",
".",
"toString",
"(",
"resEntity",
",",
"Constant",
".",
"DEFAULT_CHARSET",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | POST方式向Http(s)提交数据并获取返回结果
@param url URL
@param header Header
@param param 参数(String)
@return 服务器数据
@throws KeyManagementException [ellipsis]
@throws NoSuchAlgorithmException [ellipsis]
@throws IOException [ellipsis] | [
"POST方式向Http",
"(",
"s",
")",
"提交数据并获取返回结果"
] | train | https://github.com/fengwenyi/JavaLib/blob/14838b13fb11c024e41be766aa3e13ead4be1703/bak/HttpsClientUtil.java#L91-L122 |
landawn/AbacusUtil | src/com/landawn/abacus/util/N.java | N.removeAll | @SafeVarargs
public static <T> T[] removeAll(final T[] a, final Object... elements) {
"""
Returns a new array with removes all the occurrences of specified elements from <code>a</code>
@param a
@param elements
@return
@see Collection#removeAll(Collection)
"""
if (N.isNullOrEmpty(a)) {
return a;
} else if (N.isNullOrEmpty(elements)) {
return a.clone();
} else if (elements.length == 1) {
return removeAllOccurrences(a, elements[0]);
}
final Set<Object> set = N.asSet(elements);
final List<T> result = new ArrayList<>();
for (T e : a) {
if (!set.contains(e)) {
result.add(e);
}
}
return result.toArray((T[]) N.newArray(a.getClass().getComponentType(), result.size()));
} | java | @SafeVarargs
public static <T> T[] removeAll(final T[] a, final Object... elements) {
if (N.isNullOrEmpty(a)) {
return a;
} else if (N.isNullOrEmpty(elements)) {
return a.clone();
} else if (elements.length == 1) {
return removeAllOccurrences(a, elements[0]);
}
final Set<Object> set = N.asSet(elements);
final List<T> result = new ArrayList<>();
for (T e : a) {
if (!set.contains(e)) {
result.add(e);
}
}
return result.toArray((T[]) N.newArray(a.getClass().getComponentType(), result.size()));
} | [
"@",
"SafeVarargs",
"public",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"removeAll",
"(",
"final",
"T",
"[",
"]",
"a",
",",
"final",
"Object",
"...",
"elements",
")",
"{",
"if",
"(",
"N",
".",
"isNullOrEmpty",
"(",
"a",
")",
")",
"{",
"return",
"a",
";",
"}",
"else",
"if",
"(",
"N",
".",
"isNullOrEmpty",
"(",
"elements",
")",
")",
"{",
"return",
"a",
".",
"clone",
"(",
")",
";",
"}",
"else",
"if",
"(",
"elements",
".",
"length",
"==",
"1",
")",
"{",
"return",
"removeAllOccurrences",
"(",
"a",
",",
"elements",
"[",
"0",
"]",
")",
";",
"}",
"final",
"Set",
"<",
"Object",
">",
"set",
"=",
"N",
".",
"asSet",
"(",
"elements",
")",
";",
"final",
"List",
"<",
"T",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"T",
"e",
":",
"a",
")",
"{",
"if",
"(",
"!",
"set",
".",
"contains",
"(",
"e",
")",
")",
"{",
"result",
".",
"add",
"(",
"e",
")",
";",
"}",
"}",
"return",
"result",
".",
"toArray",
"(",
"(",
"T",
"[",
"]",
")",
"N",
".",
"newArray",
"(",
"a",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
",",
"result",
".",
"size",
"(",
")",
")",
")",
";",
"}"
] | Returns a new array with removes all the occurrences of specified elements from <code>a</code>
@param a
@param elements
@return
@see Collection#removeAll(Collection) | [
"Returns",
"a",
"new",
"array",
"with",
"removes",
"all",
"the",
"occurrences",
"of",
"specified",
"elements",
"from",
"<code",
">",
"a<",
"/",
"code",
">"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/N.java#L23535-L23555 |
openbase/jul | extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/MultiLanguageTextProcessor.java | MultiLanguageTextProcessor.getBestMatch | public static String getBestMatch(final Locale locale, final MultiLanguageTextOrBuilder multiLanguageText) throws NotAvailableException {
"""
Get the first multiLanguageText for a languageCode from a multiLanguageText type. This is equivalent to calling
{@link #getMultiLanguageTextByLanguage(String, MultiLanguageTextOrBuilder)} but the language code is extracted from the locale by calling
{@link Locale#getLanguage()}. If no multiLanguageText matches the languageCode, than the first multiLanguageText of any other provided language is returned.
@param locale the locale from which a language code is extracted
@param multiLanguageText the multiLanguageText type which is searched for multiLanguageTexts in the language
@return the first multiLanguageText from the multiLanguageText type for the locale
@throws NotAvailableException if no multiLanguageText is provided by the {@code multiLanguageText} argument.
"""
try {
// resolve multiLanguageText via preferred locale.
return getMultiLanguageTextByLanguage(locale.getLanguage(), multiLanguageText);
} catch (NotAvailableException ex) {
try {
// resolve world language multiLanguageText.
return getMultiLanguageTextByLanguage(Locale.ENGLISH, multiLanguageText);
} catch (NotAvailableException exx) {
// resolve any multiLanguageText.
return getFirstMultiLanguageText(multiLanguageText);
}
}
} | java | public static String getBestMatch(final Locale locale, final MultiLanguageTextOrBuilder multiLanguageText) throws NotAvailableException {
try {
// resolve multiLanguageText via preferred locale.
return getMultiLanguageTextByLanguage(locale.getLanguage(), multiLanguageText);
} catch (NotAvailableException ex) {
try {
// resolve world language multiLanguageText.
return getMultiLanguageTextByLanguage(Locale.ENGLISH, multiLanguageText);
} catch (NotAvailableException exx) {
// resolve any multiLanguageText.
return getFirstMultiLanguageText(multiLanguageText);
}
}
} | [
"public",
"static",
"String",
"getBestMatch",
"(",
"final",
"Locale",
"locale",
",",
"final",
"MultiLanguageTextOrBuilder",
"multiLanguageText",
")",
"throws",
"NotAvailableException",
"{",
"try",
"{",
"// resolve multiLanguageText via preferred locale.",
"return",
"getMultiLanguageTextByLanguage",
"(",
"locale",
".",
"getLanguage",
"(",
")",
",",
"multiLanguageText",
")",
";",
"}",
"catch",
"(",
"NotAvailableException",
"ex",
")",
"{",
"try",
"{",
"// resolve world language multiLanguageText.",
"return",
"getMultiLanguageTextByLanguage",
"(",
"Locale",
".",
"ENGLISH",
",",
"multiLanguageText",
")",
";",
"}",
"catch",
"(",
"NotAvailableException",
"exx",
")",
"{",
"// resolve any multiLanguageText.",
"return",
"getFirstMultiLanguageText",
"(",
"multiLanguageText",
")",
";",
"}",
"}",
"}"
] | Get the first multiLanguageText for a languageCode from a multiLanguageText type. This is equivalent to calling
{@link #getMultiLanguageTextByLanguage(String, MultiLanguageTextOrBuilder)} but the language code is extracted from the locale by calling
{@link Locale#getLanguage()}. If no multiLanguageText matches the languageCode, than the first multiLanguageText of any other provided language is returned.
@param locale the locale from which a language code is extracted
@param multiLanguageText the multiLanguageText type which is searched for multiLanguageTexts in the language
@return the first multiLanguageText from the multiLanguageText type for the locale
@throws NotAvailableException if no multiLanguageText is provided by the {@code multiLanguageText} argument. | [
"Get",
"the",
"first",
"multiLanguageText",
"for",
"a",
"languageCode",
"from",
"a",
"multiLanguageText",
"type",
".",
"This",
"is",
"equivalent",
"to",
"calling",
"{",
"@link",
"#getMultiLanguageTextByLanguage",
"(",
"String",
"MultiLanguageTextOrBuilder",
")",
"}",
"but",
"the",
"language",
"code",
"is",
"extracted",
"from",
"the",
"locale",
"by",
"calling",
"{",
"@link",
"Locale#getLanguage",
"()",
"}",
".",
"If",
"no",
"multiLanguageText",
"matches",
"the",
"languageCode",
"than",
"the",
"first",
"multiLanguageText",
"of",
"any",
"other",
"provided",
"language",
"is",
"returned",
"."
] | train | https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/MultiLanguageTextProcessor.java#L184-L197 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServicePlansInner.java | AppServicePlansInner.listUsagesWithServiceResponseAsync | public Observable<ServiceResponse<Page<CsmUsageQuotaInner>>> listUsagesWithServiceResponseAsync(final String resourceGroupName, final String name, final String filter) {
"""
Gets server farm usage information.
Gets server farm usage information.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of App Service Plan
@param filter Return only usages/metrics specified in the filter. Filter conforms to odata syntax. Example: $filter=(name.value eq 'Metric1' or name.value eq 'Metric2').
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<CsmUsageQuotaInner> object
"""
return listUsagesSinglePageAsync(resourceGroupName, name, filter)
.concatMap(new Func1<ServiceResponse<Page<CsmUsageQuotaInner>>, Observable<ServiceResponse<Page<CsmUsageQuotaInner>>>>() {
@Override
public Observable<ServiceResponse<Page<CsmUsageQuotaInner>>> call(ServiceResponse<Page<CsmUsageQuotaInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listUsagesNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<CsmUsageQuotaInner>>> listUsagesWithServiceResponseAsync(final String resourceGroupName, final String name, final String filter) {
return listUsagesSinglePageAsync(resourceGroupName, name, filter)
.concatMap(new Func1<ServiceResponse<Page<CsmUsageQuotaInner>>, Observable<ServiceResponse<Page<CsmUsageQuotaInner>>>>() {
@Override
public Observable<ServiceResponse<Page<CsmUsageQuotaInner>>> call(ServiceResponse<Page<CsmUsageQuotaInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listUsagesNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"CsmUsageQuotaInner",
">",
">",
">",
"listUsagesWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
",",
"final",
"String",
"filter",
")",
"{",
"return",
"listUsagesSinglePageAsync",
"(",
"resourceGroupName",
",",
"name",
",",
"filter",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"CsmUsageQuotaInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"CsmUsageQuotaInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"CsmUsageQuotaInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"CsmUsageQuotaInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listUsagesNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets server farm usage information.
Gets server farm usage information.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of App Service Plan
@param filter Return only usages/metrics specified in the filter. Filter conforms to odata syntax. Example: $filter=(name.value eq 'Metric1' or name.value eq 'Metric2').
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<CsmUsageQuotaInner> object | [
"Gets",
"server",
"farm",
"usage",
"information",
".",
"Gets",
"server",
"farm",
"usage",
"information",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServicePlansInner.java#L2915-L2927 |
blinkfox/zealot | src/main/java/com/blinkfox/zealot/core/ZealotKhala.java | ZealotKhala.andNotEqual | public ZealotKhala andNotEqual(String field, Object value) {
"""
生成带" AND "前缀不等查询的SQL片段.
@param field 数据库字段
@param value 值
@return ZealotKhala实例
"""
return this.doNormal(ZealotConst.AND_PREFIX, field, value, ZealotConst.NOT_EQUAL_SUFFIX, true);
} | java | public ZealotKhala andNotEqual(String field, Object value) {
return this.doNormal(ZealotConst.AND_PREFIX, field, value, ZealotConst.NOT_EQUAL_SUFFIX, true);
} | [
"public",
"ZealotKhala",
"andNotEqual",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"this",
".",
"doNormal",
"(",
"ZealotConst",
".",
"AND_PREFIX",
",",
"field",
",",
"value",
",",
"ZealotConst",
".",
"NOT_EQUAL_SUFFIX",
",",
"true",
")",
";",
"}"
] | 生成带" AND "前缀不等查询的SQL片段.
@param field 数据库字段
@param value 值
@return ZealotKhala实例 | [
"生成带",
"AND",
"前缀不等查询的SQL片段",
"."
] | train | https://github.com/blinkfox/zealot/blob/21b00fa3e4ed42188eef3116d494e112e7a4194c/src/main/java/com/blinkfox/zealot/core/ZealotKhala.java#L606-L608 |
gwtplus/google-gin | src/main/java/com/google/gwt/inject/rebind/util/GuiceUtil.java | GuiceUtil.hasInject | public static boolean hasInject(MemberLiteral<?, ?> member) {
"""
Returns {@code true} if the passed member has a inject annotation.
"""
return member.isAnnotationPresent(Inject.class)
|| member.isAnnotationPresent(javax.inject.Inject.class);
} | java | public static boolean hasInject(MemberLiteral<?, ?> member) {
return member.isAnnotationPresent(Inject.class)
|| member.isAnnotationPresent(javax.inject.Inject.class);
} | [
"public",
"static",
"boolean",
"hasInject",
"(",
"MemberLiteral",
"<",
"?",
",",
"?",
">",
"member",
")",
"{",
"return",
"member",
".",
"isAnnotationPresent",
"(",
"Inject",
".",
"class",
")",
"||",
"member",
".",
"isAnnotationPresent",
"(",
"javax",
".",
"inject",
".",
"Inject",
".",
"class",
")",
";",
"}"
] | Returns {@code true} if the passed member has a inject annotation. | [
"Returns",
"{"
] | train | https://github.com/gwtplus/google-gin/blob/595e61ee0d2fa508815c016e924ec0e5cea2a2aa/src/main/java/com/google/gwt/inject/rebind/util/GuiceUtil.java#L177-L180 |
JavaMoney/jsr354-ri | moneta-core/src/main/java/org/javamoney/moneta/internal/loader/LoadableResource.java | LoadableResource.loadRemote | public boolean loadRemote() {
"""
Try to load the resource from the remote locations.
@return true, on success.
"""
for (URI itemToLoad : remoteResources) {
try {
return load(itemToLoad, false);
} catch (Exception e) {
LOG.log(Level.INFO, "Failed to load resource: " + itemToLoad, e);
}
}
return false;
} | java | public boolean loadRemote() {
for (URI itemToLoad : remoteResources) {
try {
return load(itemToLoad, false);
} catch (Exception e) {
LOG.log(Level.INFO, "Failed to load resource: " + itemToLoad, e);
}
}
return false;
} | [
"public",
"boolean",
"loadRemote",
"(",
")",
"{",
"for",
"(",
"URI",
"itemToLoad",
":",
"remoteResources",
")",
"{",
"try",
"{",
"return",
"load",
"(",
"itemToLoad",
",",
"false",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Failed to load resource: \"",
"+",
"itemToLoad",
",",
"e",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Try to load the resource from the remote locations.
@return true, on success. | [
"Try",
"to",
"load",
"the",
"resource",
"from",
"the",
"remote",
"locations",
"."
] | train | https://github.com/JavaMoney/jsr354-ri/blob/cf8ff2bbaf9b115acc05eb9b0c76c8397c308284/moneta-core/src/main/java/org/javamoney/moneta/internal/loader/LoadableResource.java#L225-L234 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraSchemaManager.java | CassandraSchemaManager.onSetReplicateOnWrite | private void onSetReplicateOnWrite(CfDef cfDef, Properties cfProperties, StringBuilder builder) {
"""
On set replicate on write.
@param cfDef
the cf def
@param cfProperties
the cf properties
@param builder
the builder
"""
String replicateOnWrite = cfProperties.getProperty(CassandraConstants.REPLICATE_ON_WRITE);
if (builder != null)
{
String replicateOn_Write = CQLTranslator.getKeyword(CassandraConstants.REPLICATE_ON_WRITE);
builder.append(replicateOn_Write);
builder.append(CQLTranslator.EQ_CLAUSE);
builder.append(Boolean.parseBoolean(replicateOnWrite));
builder.append(CQLTranslator.AND_CLAUSE);
}
else if (cfDef != null)
{
cfDef.setReplicate_on_write(false);
}
} | java | private void onSetReplicateOnWrite(CfDef cfDef, Properties cfProperties, StringBuilder builder)
{
String replicateOnWrite = cfProperties.getProperty(CassandraConstants.REPLICATE_ON_WRITE);
if (builder != null)
{
String replicateOn_Write = CQLTranslator.getKeyword(CassandraConstants.REPLICATE_ON_WRITE);
builder.append(replicateOn_Write);
builder.append(CQLTranslator.EQ_CLAUSE);
builder.append(Boolean.parseBoolean(replicateOnWrite));
builder.append(CQLTranslator.AND_CLAUSE);
}
else if (cfDef != null)
{
cfDef.setReplicate_on_write(false);
}
} | [
"private",
"void",
"onSetReplicateOnWrite",
"(",
"CfDef",
"cfDef",
",",
"Properties",
"cfProperties",
",",
"StringBuilder",
"builder",
")",
"{",
"String",
"replicateOnWrite",
"=",
"cfProperties",
".",
"getProperty",
"(",
"CassandraConstants",
".",
"REPLICATE_ON_WRITE",
")",
";",
"if",
"(",
"builder",
"!=",
"null",
")",
"{",
"String",
"replicateOn_Write",
"=",
"CQLTranslator",
".",
"getKeyword",
"(",
"CassandraConstants",
".",
"REPLICATE_ON_WRITE",
")",
";",
"builder",
".",
"append",
"(",
"replicateOn_Write",
")",
";",
"builder",
".",
"append",
"(",
"CQLTranslator",
".",
"EQ_CLAUSE",
")",
";",
"builder",
".",
"append",
"(",
"Boolean",
".",
"parseBoolean",
"(",
"replicateOnWrite",
")",
")",
";",
"builder",
".",
"append",
"(",
"CQLTranslator",
".",
"AND_CLAUSE",
")",
";",
"}",
"else",
"if",
"(",
"cfDef",
"!=",
"null",
")",
"{",
"cfDef",
".",
"setReplicate_on_write",
"(",
"false",
")",
";",
"}",
"}"
] | On set replicate on write.
@param cfDef
the cf def
@param cfProperties
the cf properties
@param builder
the builder | [
"On",
"set",
"replicate",
"on",
"write",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/schemamanager/CassandraSchemaManager.java#L2597-L2612 |
apache/flink | flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/DefaultConfigurableOptionsFactory.java | DefaultConfigurableOptionsFactory.setInternal | private void setInternal(String key, String value) {
"""
Sets the configuration with (key, value) if the key is predefined, otherwise throws IllegalArgumentException.
@param key The configuration key, if key is not predefined, throws IllegalArgumentException out.
@param value The configuration value.
"""
Preconditions.checkArgument(value != null && !value.isEmpty(),
"The configuration value must not be empty.");
configuredOptions.put(key, value);
} | java | private void setInternal(String key, String value) {
Preconditions.checkArgument(value != null && !value.isEmpty(),
"The configuration value must not be empty.");
configuredOptions.put(key, value);
} | [
"private",
"void",
"setInternal",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"value",
"!=",
"null",
"&&",
"!",
"value",
".",
"isEmpty",
"(",
")",
",",
"\"The configuration value must not be empty.\"",
")",
";",
"configuredOptions",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}"
] | Sets the configuration with (key, value) if the key is predefined, otherwise throws IllegalArgumentException.
@param key The configuration key, if key is not predefined, throws IllegalArgumentException out.
@param value The configuration value. | [
"Sets",
"the",
"configuration",
"with",
"(",
"key",
"value",
")",
"if",
"the",
"key",
"is",
"predefined",
"otherwise",
"throws",
"IllegalArgumentException",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/DefaultConfigurableOptionsFactory.java#L407-L412 |
LearnLib/learnlib | oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/SampleSetEQOracle.java | SampleSetEQOracle.addAll | @SafeVarargs
public final SampleSetEQOracle<I, D> addAll(MembershipOracle<I, D> oracle, Word<I>... words) {
"""
Adds several query words to the sample set. The expected output is determined by means of the specified
membership oracle.
@param oracle
the membership oracle used to determine expected outputs
@param words
the words to be added to the sample set
@return {@code this}, to enable chained {@code add} or {@code addAll} calls
"""
return addAll(oracle, Arrays.asList(words));
} | java | @SafeVarargs
public final SampleSetEQOracle<I, D> addAll(MembershipOracle<I, D> oracle, Word<I>... words) {
return addAll(oracle, Arrays.asList(words));
} | [
"@",
"SafeVarargs",
"public",
"final",
"SampleSetEQOracle",
"<",
"I",
",",
"D",
">",
"addAll",
"(",
"MembershipOracle",
"<",
"I",
",",
"D",
">",
"oracle",
",",
"Word",
"<",
"I",
">",
"...",
"words",
")",
"{",
"return",
"addAll",
"(",
"oracle",
",",
"Arrays",
".",
"asList",
"(",
"words",
")",
")",
";",
"}"
] | Adds several query words to the sample set. The expected output is determined by means of the specified
membership oracle.
@param oracle
the membership oracle used to determine expected outputs
@param words
the words to be added to the sample set
@return {@code this}, to enable chained {@code add} or {@code addAll} calls | [
"Adds",
"several",
"query",
"words",
"to",
"the",
"sample",
"set",
".",
"The",
"expected",
"output",
"is",
"determined",
"by",
"means",
"of",
"the",
"specified",
"membership",
"oracle",
"."
] | train | https://github.com/LearnLib/learnlib/blob/fa38a14adcc0664099f180d671ffa42480318d7b/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/SampleSetEQOracle.java#L100-L103 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/Configurer.java | Configurer.getImplementation | public static final <T> T getImplementation(ClassLoader loader,
Class<T> type,
Class<?>[] paramsType,
Collection<?> paramsValue,
String className) {
"""
Get the class implementation from its name by using a custom constructor.
@param <T> The instance type.
@param loader The class loader to use.
@param type The class type.
@param paramsType The parameters type.
@param paramsValue The parameters value.
@param className The class name.
@return The typed class instance.
@throws LionEngineException If invalid class.
"""
try
{
if (!CLASS_CACHE.containsKey(className))
{
final Class<?> clazz = loader.loadClass(className);
CLASS_CACHE.put(className, clazz);
}
final Class<?> clazz = CLASS_CACHE.get(className);
final Constructor<?> constructor = UtilReflection.getCompatibleConstructor(clazz, paramsType);
UtilReflection.setAccessible(constructor, true);
return type.cast(constructor.newInstance(paramsValue.toArray()));
}
catch (final InstantiationException | IllegalArgumentException | InvocationTargetException exception)
{
throw new LionEngineException(exception, ERROR_CLASS_INSTANCE + className);
}
catch (final NoSuchMethodException | IllegalAccessException exception)
{
throw new LionEngineException(exception, ERROR_CLASS_CONSTRUCTOR + className);
}
catch (final ClassNotFoundException exception)
{
throw new LionEngineException(exception, ERROR_CLASS_PRESENCE + className);
}
} | java | public static final <T> T getImplementation(ClassLoader loader,
Class<T> type,
Class<?>[] paramsType,
Collection<?> paramsValue,
String className)
{
try
{
if (!CLASS_CACHE.containsKey(className))
{
final Class<?> clazz = loader.loadClass(className);
CLASS_CACHE.put(className, clazz);
}
final Class<?> clazz = CLASS_CACHE.get(className);
final Constructor<?> constructor = UtilReflection.getCompatibleConstructor(clazz, paramsType);
UtilReflection.setAccessible(constructor, true);
return type.cast(constructor.newInstance(paramsValue.toArray()));
}
catch (final InstantiationException | IllegalArgumentException | InvocationTargetException exception)
{
throw new LionEngineException(exception, ERROR_CLASS_INSTANCE + className);
}
catch (final NoSuchMethodException | IllegalAccessException exception)
{
throw new LionEngineException(exception, ERROR_CLASS_CONSTRUCTOR + className);
}
catch (final ClassNotFoundException exception)
{
throw new LionEngineException(exception, ERROR_CLASS_PRESENCE + className);
}
} | [
"public",
"static",
"final",
"<",
"T",
">",
"T",
"getImplementation",
"(",
"ClassLoader",
"loader",
",",
"Class",
"<",
"T",
">",
"type",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"paramsType",
",",
"Collection",
"<",
"?",
">",
"paramsValue",
",",
"String",
"className",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"CLASS_CACHE",
".",
"containsKey",
"(",
"className",
")",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"clazz",
"=",
"loader",
".",
"loadClass",
"(",
"className",
")",
";",
"CLASS_CACHE",
".",
"put",
"(",
"className",
",",
"clazz",
")",
";",
"}",
"final",
"Class",
"<",
"?",
">",
"clazz",
"=",
"CLASS_CACHE",
".",
"get",
"(",
"className",
")",
";",
"final",
"Constructor",
"<",
"?",
">",
"constructor",
"=",
"UtilReflection",
".",
"getCompatibleConstructor",
"(",
"clazz",
",",
"paramsType",
")",
";",
"UtilReflection",
".",
"setAccessible",
"(",
"constructor",
",",
"true",
")",
";",
"return",
"type",
".",
"cast",
"(",
"constructor",
".",
"newInstance",
"(",
"paramsValue",
".",
"toArray",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"final",
"InstantiationException",
"|",
"IllegalArgumentException",
"|",
"InvocationTargetException",
"exception",
")",
"{",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_CLASS_INSTANCE",
"+",
"className",
")",
";",
"}",
"catch",
"(",
"final",
"NoSuchMethodException",
"|",
"IllegalAccessException",
"exception",
")",
"{",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_CLASS_CONSTRUCTOR",
"+",
"className",
")",
";",
"}",
"catch",
"(",
"final",
"ClassNotFoundException",
"exception",
")",
"{",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_CLASS_PRESENCE",
"+",
"className",
")",
";",
"}",
"}"
] | Get the class implementation from its name by using a custom constructor.
@param <T> The instance type.
@param loader The class loader to use.
@param type The class type.
@param paramsType The parameters type.
@param paramsValue The parameters value.
@param className The class name.
@return The typed class instance.
@throws LionEngineException If invalid class. | [
"Get",
"the",
"class",
"implementation",
"from",
"its",
"name",
"by",
"using",
"a",
"custom",
"constructor",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/Configurer.java#L387-L418 |
Bearded-Hen/Android-Bootstrap | AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/utils/ColorUtils.java | ColorUtils.resolveColor | @SuppressWarnings("deprecation")
public static @ColorInt int resolveColor(@ColorRes int color, Context context) {
"""
Resolves a color resource.
@param color the color resource
@param context the current context
@return a color int
"""
if (Build.VERSION.SDK_INT >= 23) {
return context.getResources().getColor(color, context.getTheme());
}
else {
return context.getResources().getColor(color);
}
} | java | @SuppressWarnings("deprecation")
public static @ColorInt int resolveColor(@ColorRes int color, Context context) {
if (Build.VERSION.SDK_INT >= 23) {
return context.getResources().getColor(color, context.getTheme());
}
else {
return context.getResources().getColor(color);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"@",
"ColorInt",
"int",
"resolveColor",
"(",
"@",
"ColorRes",
"int",
"color",
",",
"Context",
"context",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"23",
")",
"{",
"return",
"context",
".",
"getResources",
"(",
")",
".",
"getColor",
"(",
"color",
",",
"context",
".",
"getTheme",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"context",
".",
"getResources",
"(",
")",
".",
"getColor",
"(",
"color",
")",
";",
"}",
"}"
] | Resolves a color resource.
@param color the color resource
@param context the current context
@return a color int | [
"Resolves",
"a",
"color",
"resource",
"."
] | train | https://github.com/Bearded-Hen/Android-Bootstrap/blob/b3d62cc1847e26d420c53c92665a4fe1e6ee7ecf/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/utils/ColorUtils.java#L26-L34 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_voicemail_serviceName_directories_id_GET | public OvhVoicemailMessages billingAccount_voicemail_serviceName_directories_id_GET(String billingAccount, String serviceName, Long id) throws IOException {
"""
Get this object properties
REST: GET /telephony/{billingAccount}/voicemail/{serviceName}/directories/{id}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param id [required] Id of the object
"""
String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/directories/{id}";
StringBuilder sb = path(qPath, billingAccount, serviceName, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhVoicemailMessages.class);
} | java | public OvhVoicemailMessages billingAccount_voicemail_serviceName_directories_id_GET(String billingAccount, String serviceName, Long id) throws IOException {
String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/directories/{id}";
StringBuilder sb = path(qPath, billingAccount, serviceName, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhVoicemailMessages.class);
} | [
"public",
"OvhVoicemailMessages",
"billingAccount_voicemail_serviceName_directories_id_GET",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"Long",
"id",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/voicemail/{serviceName}/directories/{id}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
",",
"id",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhVoicemailMessages",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /telephony/{billingAccount}/voicemail/{serviceName}/directories/{id}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param id [required] Id of the object | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L7942-L7947 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/AbstractInputHandler.java | AbstractInputHandler.handleControlMessage | public void handleControlMessage(SIBUuid8 sourceMEUuid, ControlMessage cMsg)
throws SIIncorrectCallException, SIErrorException, SIResourceException {
"""
/* (non-Javadoc)
@see com.ibm.ws.sib.processor.impl.interfaces.ControlHandler#handleControlMessage(com.ibm.ws.sib.trm.topology.Cellule, com.ibm.ws.sib.mfp.control.ControlMessage)
Handle all downstream control messages i.e. target control messages
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "handleControlMessage", new Object[] { sourceMEUuid, cMsg });
// Next work out type of ControlMessage and process it
ControlMessageType type = cMsg.getControlMessageType();
// First check to see whether this is an "are you flushed" reply.
// Such messages will not be mappable to a stream ID since we
// don't yet have a stream data structure (that's why we sent the
// query in the first place). Or...these could be stale messages
// for streams we don't care about. Either way, handle them
// elsewhere.
if(type == ControlMessageType.FLUSHED)
{
_targetStreamManager.handleFlushedMessage((ControlFlushed)cMsg);
}
else if(type == ControlMessageType.NOTFLUSHED)
{
_targetStreamManager.handleNotFlushedMessage((ControlNotFlushed)cMsg);
}
else if (type == ControlMessageType.SILENCE)
{
_targetStreamManager.handleSilenceMessage((ControlSilence) cMsg);
}
else if (type == ControlMessageType.ACKEXPECTED)
{
_targetStreamManager.handleAckExpectedMessage((ControlAckExpected) cMsg);
}
else
{
// Not a recognised type
// throw exception
}
} | java | public void handleControlMessage(SIBUuid8 sourceMEUuid, ControlMessage cMsg)
throws SIIncorrectCallException, SIErrorException, SIResourceException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "handleControlMessage", new Object[] { sourceMEUuid, cMsg });
// Next work out type of ControlMessage and process it
ControlMessageType type = cMsg.getControlMessageType();
// First check to see whether this is an "are you flushed" reply.
// Such messages will not be mappable to a stream ID since we
// don't yet have a stream data structure (that's why we sent the
// query in the first place). Or...these could be stale messages
// for streams we don't care about. Either way, handle them
// elsewhere.
if(type == ControlMessageType.FLUSHED)
{
_targetStreamManager.handleFlushedMessage((ControlFlushed)cMsg);
}
else if(type == ControlMessageType.NOTFLUSHED)
{
_targetStreamManager.handleNotFlushedMessage((ControlNotFlushed)cMsg);
}
else if (type == ControlMessageType.SILENCE)
{
_targetStreamManager.handleSilenceMessage((ControlSilence) cMsg);
}
else if (type == ControlMessageType.ACKEXPECTED)
{
_targetStreamManager.handleAckExpectedMessage((ControlAckExpected) cMsg);
}
else
{
// Not a recognised type
// throw exception
}
} | [
"public",
"void",
"handleControlMessage",
"(",
"SIBUuid8",
"sourceMEUuid",
",",
"ControlMessage",
"cMsg",
")",
"throws",
"SIIncorrectCallException",
",",
"SIErrorException",
",",
"SIResourceException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"handleControlMessage\"",
",",
"new",
"Object",
"[",
"]",
"{",
"sourceMEUuid",
",",
"cMsg",
"}",
")",
";",
"// Next work out type of ControlMessage and process it",
"ControlMessageType",
"type",
"=",
"cMsg",
".",
"getControlMessageType",
"(",
")",
";",
"// First check to see whether this is an \"are you flushed\" reply.",
"// Such messages will not be mappable to a stream ID since we",
"// don't yet have a stream data structure (that's why we sent the",
"// query in the first place). Or...these could be stale messages",
"// for streams we don't care about. Either way, handle them",
"// elsewhere.",
"if",
"(",
"type",
"==",
"ControlMessageType",
".",
"FLUSHED",
")",
"{",
"_targetStreamManager",
".",
"handleFlushedMessage",
"(",
"(",
"ControlFlushed",
")",
"cMsg",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"ControlMessageType",
".",
"NOTFLUSHED",
")",
"{",
"_targetStreamManager",
".",
"handleNotFlushedMessage",
"(",
"(",
"ControlNotFlushed",
")",
"cMsg",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"ControlMessageType",
".",
"SILENCE",
")",
"{",
"_targetStreamManager",
".",
"handleSilenceMessage",
"(",
"(",
"ControlSilence",
")",
"cMsg",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"ControlMessageType",
".",
"ACKEXPECTED",
")",
"{",
"_targetStreamManager",
".",
"handleAckExpectedMessage",
"(",
"(",
"ControlAckExpected",
")",
"cMsg",
")",
";",
"}",
"else",
"{",
"// Not a recognised type",
"// throw exception",
"}",
"}"
] | /* (non-Javadoc)
@see com.ibm.ws.sib.processor.impl.interfaces.ControlHandler#handleControlMessage(com.ibm.ws.sib.trm.topology.Cellule, com.ibm.ws.sib.mfp.control.ControlMessage)
Handle all downstream control messages i.e. target control messages | [
"/",
"*",
"(",
"non",
"-",
"Javadoc",
")",
"@see",
"com",
".",
"ibm",
".",
"ws",
".",
"sib",
".",
"processor",
".",
"impl",
".",
"interfaces",
".",
"ControlHandler#handleControlMessage",
"(",
"com",
".",
"ibm",
".",
"ws",
".",
"sib",
".",
"trm",
".",
"topology",
".",
"Cellule",
"com",
".",
"ibm",
".",
"ws",
".",
"sib",
".",
"mfp",
".",
"control",
".",
"ControlMessage",
")"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/impl/AbstractInputHandler.java#L674-L710 |
netheosgithub/pcs_api | java/src/main/java/net/netheos/pcsapi/storage/StorageBuilder.java | StorageBuilder.setUserCredentialsRepository | public StorageBuilder setUserCredentialsRepository( UserCredentialsRepository userCredentialsRepo, String userId ) {
"""
Set the user credentials repository. This setter must always be called during the build
@param userCredentialsRepo The repository
@param userId The user identifier (may be null if the identifier is unknown)
@return The builder
"""
this.userCredentialsRepo = userCredentialsRepo;
this.userId = userId;
return this;
} | java | public StorageBuilder setUserCredentialsRepository( UserCredentialsRepository userCredentialsRepo, String userId )
{
this.userCredentialsRepo = userCredentialsRepo;
this.userId = userId;
return this;
} | [
"public",
"StorageBuilder",
"setUserCredentialsRepository",
"(",
"UserCredentialsRepository",
"userCredentialsRepo",
",",
"String",
"userId",
")",
"{",
"this",
".",
"userCredentialsRepo",
"=",
"userCredentialsRepo",
";",
"this",
".",
"userId",
"=",
"userId",
";",
"return",
"this",
";",
"}"
] | Set the user credentials repository. This setter must always be called during the build
@param userCredentialsRepo The repository
@param userId The user identifier (may be null if the identifier is unknown)
@return The builder | [
"Set",
"the",
"user",
"credentials",
"repository",
".",
"This",
"setter",
"must",
"always",
"be",
"called",
"during",
"the",
"build"
] | train | https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/storage/StorageBuilder.java#L81-L87 |
googleapis/google-http-java-client | google-http-client/src/main/java/com/google/api/client/http/ByteArrayContent.java | ByteArrayContent.fromString | public static ByteArrayContent fromString(String type, String contentString) {
"""
Returns a new instance with the UTF-8 encoding (using {@link StringUtils#getBytesUtf8(String)})
of the given content string.
<p>Sample use:
<pre>
<code>
static void setJsonContent(HttpRequest request, String json) {
request.setContent(ByteArrayContent.fromString("application/json", json));
}
</code>
</pre>
@param type content type or {@code null} for none
@param contentString content string
@since 1.5
"""
return new ByteArrayContent(type, StringUtils.getBytesUtf8(contentString));
} | java | public static ByteArrayContent fromString(String type, String contentString) {
return new ByteArrayContent(type, StringUtils.getBytesUtf8(contentString));
} | [
"public",
"static",
"ByteArrayContent",
"fromString",
"(",
"String",
"type",
",",
"String",
"contentString",
")",
"{",
"return",
"new",
"ByteArrayContent",
"(",
"type",
",",
"StringUtils",
".",
"getBytesUtf8",
"(",
"contentString",
")",
")",
";",
"}"
] | Returns a new instance with the UTF-8 encoding (using {@link StringUtils#getBytesUtf8(String)})
of the given content string.
<p>Sample use:
<pre>
<code>
static void setJsonContent(HttpRequest request, String json) {
request.setContent(ByteArrayContent.fromString("application/json", json));
}
</code>
</pre>
@param type content type or {@code null} for none
@param contentString content string
@since 1.5 | [
"Returns",
"a",
"new",
"instance",
"with",
"the",
"UTF",
"-",
"8",
"encoding",
"(",
"using",
"{",
"@link",
"StringUtils#getBytesUtf8",
"(",
"String",
")",
"}",
")",
"of",
"the",
"given",
"content",
"string",
"."
] | train | https://github.com/googleapis/google-http-java-client/blob/0988ae4e0f26a80f579b6adb2b276dd8254928de/google-http-client/src/main/java/com/google/api/client/http/ByteArrayContent.java#L104-L106 |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java | PropertyHelper.isPropertyAllowed | public static boolean isPropertyAllowed(Class defClass, String propertyName) {
"""
Checks whether the property of the given name is allowed for the model element.
@param defClass The class of the model element
@param propertyName The name of the property
@return <code>true</code> if the property is allowed for this type of model elements
"""
HashMap props = (HashMap)_properties.get(defClass);
return (props == null ? true : props.containsKey(propertyName));
} | java | public static boolean isPropertyAllowed(Class defClass, String propertyName)
{
HashMap props = (HashMap)_properties.get(defClass);
return (props == null ? true : props.containsKey(propertyName));
} | [
"public",
"static",
"boolean",
"isPropertyAllowed",
"(",
"Class",
"defClass",
",",
"String",
"propertyName",
")",
"{",
"HashMap",
"props",
"=",
"(",
"HashMap",
")",
"_properties",
".",
"get",
"(",
"defClass",
")",
";",
"return",
"(",
"props",
"==",
"null",
"?",
"true",
":",
"props",
".",
"containsKey",
"(",
"propertyName",
")",
")",
";",
"}"
] | Checks whether the property of the given name is allowed for the model element.
@param defClass The class of the model element
@param propertyName The name of the property
@return <code>true</code> if the property is allowed for this type of model elements | [
"Checks",
"whether",
"the",
"property",
"of",
"the",
"given",
"name",
"is",
"allowed",
"for",
"the",
"model",
"element",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java#L242-L247 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/ByteArrayUtil.java | ByteArrayUtil.putLongLE | public static void putLongLE(final byte[] array, final int offset, final long value) {
"""
Put the source <i>long</i> into the destination byte array starting at the given offset
in little endian order.
There is no bounds checking.
@param array destination byte array
@param offset destination offset
@param value source <i>long</i>
"""
array[offset ] = (byte) (value );
array[offset + 1] = (byte) (value >>> 8);
array[offset + 2] = (byte) (value >>> 16);
array[offset + 3] = (byte) (value >>> 24);
array[offset + 4] = (byte) (value >>> 32);
array[offset + 5] = (byte) (value >>> 40);
array[offset + 6] = (byte) (value >>> 48);
array[offset + 7] = (byte) (value >>> 56);
} | java | public static void putLongLE(final byte[] array, final int offset, final long value) {
array[offset ] = (byte) (value );
array[offset + 1] = (byte) (value >>> 8);
array[offset + 2] = (byte) (value >>> 16);
array[offset + 3] = (byte) (value >>> 24);
array[offset + 4] = (byte) (value >>> 32);
array[offset + 5] = (byte) (value >>> 40);
array[offset + 6] = (byte) (value >>> 48);
array[offset + 7] = (byte) (value >>> 56);
} | [
"public",
"static",
"void",
"putLongLE",
"(",
"final",
"byte",
"[",
"]",
"array",
",",
"final",
"int",
"offset",
",",
"final",
"long",
"value",
")",
"{",
"array",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
")",
";",
"array",
"[",
"offset",
"+",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"8",
")",
";",
"array",
"[",
"offset",
"+",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"16",
")",
";",
"array",
"[",
"offset",
"+",
"3",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"24",
")",
";",
"array",
"[",
"offset",
"+",
"4",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"32",
")",
";",
"array",
"[",
"offset",
"+",
"5",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"40",
")",
";",
"array",
"[",
"offset",
"+",
"6",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"48",
")",
";",
"array",
"[",
"offset",
"+",
"7",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>>",
"56",
")",
";",
"}"
] | Put the source <i>long</i> into the destination byte array starting at the given offset
in little endian order.
There is no bounds checking.
@param array destination byte array
@param offset destination offset
@param value source <i>long</i> | [
"Put",
"the",
"source",
"<i",
">",
"long<",
"/",
"i",
">",
"into",
"the",
"destination",
"byte",
"array",
"starting",
"at",
"the",
"given",
"offset",
"in",
"little",
"endian",
"order",
".",
"There",
"is",
"no",
"bounds",
"checking",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/ByteArrayUtil.java#L144-L153 |
DDTH/ddth-commons | ddth-commons-core/src/main/java/com/github/ddth/commons/utils/UnsignedUtils.java | UnsignedUtils.digit | public static int digit(char c, int radix) {
"""
Returns the numeric value of the character {@code c} in the specified
radix.
@param c
@param radix
@return
@see #MAX_RADIX
"""
for (int i = 0; i < MAX_RADIX && i < radix; i++) {
if (digits[i] == c) {
return i;
}
}
return -1;
} | java | public static int digit(char c, int radix) {
for (int i = 0; i < MAX_RADIX && i < radix; i++) {
if (digits[i] == c) {
return i;
}
}
return -1;
} | [
"public",
"static",
"int",
"digit",
"(",
"char",
"c",
",",
"int",
"radix",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"MAX_RADIX",
"&&",
"i",
"<",
"radix",
";",
"i",
"++",
")",
"{",
"if",
"(",
"digits",
"[",
"i",
"]",
"==",
"c",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Returns the numeric value of the character {@code c} in the specified
radix.
@param c
@param radix
@return
@see #MAX_RADIX | [
"Returns",
"the",
"numeric",
"value",
"of",
"the",
"character",
"{",
"@code",
"c",
"}",
"in",
"the",
"specified",
"radix",
"."
] | train | https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/UnsignedUtils.java#L55-L62 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java | TimestampUtils.appendTime | private static void appendTime(StringBuilder sb, int hours, int minutes, int seconds, int nanos) {
"""
Appends time part to the {@code StringBuilder} in PostgreSQL-compatible format.
The function truncates {@param nanos} to microseconds. The value is expected to be rounded
beforehand.
@param sb destination
@param hours hours
@param minutes minutes
@param seconds seconds
@param nanos nanoseconds
"""
sb.append(NUMBERS[hours]);
sb.append(':');
sb.append(NUMBERS[minutes]);
sb.append(':');
sb.append(NUMBERS[seconds]);
// Add nanoseconds.
// This won't work for server versions < 7.2 which only want
// a two digit fractional second, but we don't need to support 7.1
// anymore and getting the version number here is difficult.
//
if (nanos < 1000) {
return;
}
sb.append('.');
int len = sb.length();
sb.append(nanos / 1000); // append microseconds
int needZeros = 6 - (sb.length() - len);
if (needZeros > 0) {
sb.insert(len, ZEROS, 0, needZeros);
}
int end = sb.length() - 1;
while (sb.charAt(end) == '0') {
sb.deleteCharAt(end);
end--;
}
} | java | private static void appendTime(StringBuilder sb, int hours, int minutes, int seconds, int nanos) {
sb.append(NUMBERS[hours]);
sb.append(':');
sb.append(NUMBERS[minutes]);
sb.append(':');
sb.append(NUMBERS[seconds]);
// Add nanoseconds.
// This won't work for server versions < 7.2 which only want
// a two digit fractional second, but we don't need to support 7.1
// anymore and getting the version number here is difficult.
//
if (nanos < 1000) {
return;
}
sb.append('.');
int len = sb.length();
sb.append(nanos / 1000); // append microseconds
int needZeros = 6 - (sb.length() - len);
if (needZeros > 0) {
sb.insert(len, ZEROS, 0, needZeros);
}
int end = sb.length() - 1;
while (sb.charAt(end) == '0') {
sb.deleteCharAt(end);
end--;
}
} | [
"private",
"static",
"void",
"appendTime",
"(",
"StringBuilder",
"sb",
",",
"int",
"hours",
",",
"int",
"minutes",
",",
"int",
"seconds",
",",
"int",
"nanos",
")",
"{",
"sb",
".",
"append",
"(",
"NUMBERS",
"[",
"hours",
"]",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"NUMBERS",
"[",
"minutes",
"]",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"NUMBERS",
"[",
"seconds",
"]",
")",
";",
"// Add nanoseconds.",
"// This won't work for server versions < 7.2 which only want",
"// a two digit fractional second, but we don't need to support 7.1",
"// anymore and getting the version number here is difficult.",
"//",
"if",
"(",
"nanos",
"<",
"1000",
")",
"{",
"return",
";",
"}",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"int",
"len",
"=",
"sb",
".",
"length",
"(",
")",
";",
"sb",
".",
"append",
"(",
"nanos",
"/",
"1000",
")",
";",
"// append microseconds",
"int",
"needZeros",
"=",
"6",
"-",
"(",
"sb",
".",
"length",
"(",
")",
"-",
"len",
")",
";",
"if",
"(",
"needZeros",
">",
"0",
")",
"{",
"sb",
".",
"insert",
"(",
"len",
",",
"ZEROS",
",",
"0",
",",
"needZeros",
")",
";",
"}",
"int",
"end",
"=",
"sb",
".",
"length",
"(",
")",
"-",
"1",
";",
"while",
"(",
"sb",
".",
"charAt",
"(",
"end",
")",
"==",
"'",
"'",
")",
"{",
"sb",
".",
"deleteCharAt",
"(",
"end",
")",
";",
"end",
"--",
";",
"}",
"}"
] | Appends time part to the {@code StringBuilder} in PostgreSQL-compatible format.
The function truncates {@param nanos} to microseconds. The value is expected to be rounded
beforehand.
@param sb destination
@param hours hours
@param minutes minutes
@param seconds seconds
@param nanos nanoseconds | [
"Appends",
"time",
"part",
"to",
"the",
"{"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java#L690-L720 |
versionone/VersionOne.SDK.Java.ObjectModel | src/main/java/com/versionone/util/V1Util.java | V1Util.copyStream | public static void copyStream(Reader input, Writer output, int buffersize)
throws IOException, IllegalArgumentException {
"""
Coping data(character type) from {@code input} reader to {@code output} writer.
@param input input source of data.
@param output destination of data.
@param buffersize size of buffer with is using for data copy.
@throws IOException if any errors occur during copying process.
@throws IllegalArgumentException if {@code buffersize} less then 1.
"""
if (buffersize < 1) {
throw new IllegalArgumentException(
"buffersize must be greater than 0");
}
char[] buffer = new char[buffersize];
int n;
while ((n = input.read(buffer)) >= 0) {
output.write(buffer, 0, n);
}
} | java | public static void copyStream(Reader input, Writer output, int buffersize)
throws IOException, IllegalArgumentException {
if (buffersize < 1) {
throw new IllegalArgumentException(
"buffersize must be greater than 0");
}
char[] buffer = new char[buffersize];
int n;
while ((n = input.read(buffer)) >= 0) {
output.write(buffer, 0, n);
}
} | [
"public",
"static",
"void",
"copyStream",
"(",
"Reader",
"input",
",",
"Writer",
"output",
",",
"int",
"buffersize",
")",
"throws",
"IOException",
",",
"IllegalArgumentException",
"{",
"if",
"(",
"buffersize",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"buffersize must be greater than 0\"",
")",
";",
"}",
"char",
"[",
"]",
"buffer",
"=",
"new",
"char",
"[",
"buffersize",
"]",
";",
"int",
"n",
";",
"while",
"(",
"(",
"n",
"=",
"input",
".",
"read",
"(",
"buffer",
")",
")",
">=",
"0",
")",
"{",
"output",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"n",
")",
";",
"}",
"}"
] | Coping data(character type) from {@code input} reader to {@code output} writer.
@param input input source of data.
@param output destination of data.
@param buffersize size of buffer with is using for data copy.
@throws IOException if any errors occur during copying process.
@throws IllegalArgumentException if {@code buffersize} less then 1. | [
"Coping",
"data",
"(",
"character",
"type",
")",
"from",
"{",
"@code",
"input",
"}",
"reader",
"to",
"{",
"@code",
"output",
"}",
"writer",
"."
] | train | https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/util/V1Util.java#L65-L76 |
powermock/powermock | powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java | WhiteboxImpl.getFirstParentConstructor | public static Constructor<?> getFirstParentConstructor(Class<?> klass) {
"""
Get the first parent constructor defined in a super class of
{@code klass}.
@param klass The class where the constructor is located. {@code null}
).
@return A .
"""
try {
return getOriginalUnmockedType(klass).getSuperclass().getDeclaredConstructors()[0];
} catch (Exception e) {
throw new ConstructorNotFoundException("Failed to lookup constructor.", e);
}
} | java | public static Constructor<?> getFirstParentConstructor(Class<?> klass) {
try {
return getOriginalUnmockedType(klass).getSuperclass().getDeclaredConstructors()[0];
} catch (Exception e) {
throw new ConstructorNotFoundException("Failed to lookup constructor.", e);
}
} | [
"public",
"static",
"Constructor",
"<",
"?",
">",
"getFirstParentConstructor",
"(",
"Class",
"<",
"?",
">",
"klass",
")",
"{",
"try",
"{",
"return",
"getOriginalUnmockedType",
"(",
"klass",
")",
".",
"getSuperclass",
"(",
")",
".",
"getDeclaredConstructors",
"(",
")",
"[",
"0",
"]",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ConstructorNotFoundException",
"(",
"\"Failed to lookup constructor.\"",
",",
"e",
")",
";",
"}",
"}"
] | Get the first parent constructor defined in a super class of
{@code klass}.
@param klass The class where the constructor is located. {@code null}
).
@return A . | [
"Get",
"the",
"first",
"parent",
"constructor",
"defined",
"in",
"a",
"super",
"class",
"of",
"{",
"@code",
"klass",
"}",
"."
] | train | https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-reflect/src/main/java/org/powermock/reflect/internal/WhiteboxImpl.java#L1563-L1569 |
alipay/sofa-rpc | extension-impl/registry-zk/src/main/java/com/alipay/sofa/rpc/registry/zk/ZookeeperProviderObserver.java | ZookeeperProviderObserver.addProviderListener | public void addProviderListener(ConsumerConfig consumerConfig, ProviderInfoListener listener) {
"""
Add provider listener.
@param consumerConfig the consumer config
@param listener the listener
"""
if (listener != null) {
RegistryUtils.initOrAddList(providerListenerMap, consumerConfig, listener);
}
} | java | public void addProviderListener(ConsumerConfig consumerConfig, ProviderInfoListener listener) {
if (listener != null) {
RegistryUtils.initOrAddList(providerListenerMap, consumerConfig, listener);
}
} | [
"public",
"void",
"addProviderListener",
"(",
"ConsumerConfig",
"consumerConfig",
",",
"ProviderInfoListener",
"listener",
")",
"{",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"RegistryUtils",
".",
"initOrAddList",
"(",
"providerListenerMap",
",",
"consumerConfig",
",",
"listener",
")",
";",
"}",
"}"
] | Add provider listener.
@param consumerConfig the consumer config
@param listener the listener | [
"Add",
"provider",
"listener",
"."
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/extension-impl/registry-zk/src/main/java/com/alipay/sofa/rpc/registry/zk/ZookeeperProviderObserver.java#L59-L63 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java | MapUtil.sort | public static <K, V> TreeMap<K, V> sort(Map<K, V> map) {
"""
排序已有Map,Key有序的Map,使用默认Key排序方式(字母顺序)
@param map Map
@return TreeMap
@since 4.0.1
@see #newTreeMap(Map, Comparator)
"""
return sort(map, null);
} | java | public static <K, V> TreeMap<K, V> sort(Map<K, V> map) {
return sort(map, null);
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"TreeMap",
"<",
"K",
",",
"V",
">",
"sort",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
")",
"{",
"return",
"sort",
"(",
"map",
",",
"null",
")",
";",
"}"
] | 排序已有Map,Key有序的Map,使用默认Key排序方式(字母顺序)
@param map Map
@return TreeMap
@since 4.0.1
@see #newTreeMap(Map, Comparator) | [
"排序已有Map,Key有序的Map,使用默认Key排序方式(字母顺序)"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java#L638-L640 |
knowm/XChange | xchange-ccex/src/main/java/org/knowm/xchange/ccex/CCEXAdapters.java | CCEXAdapters.adaptOrderBook | public static OrderBook adaptOrderBook(
CCEXGetorderbook ccexOrderBook, CurrencyPair currencyPair) {
"""
Adapts a org.knowm.xchange.ccex.api.model.OrderBook to a OrderBook Object
@param currencyPair (e.g. BTC/USD)
@return The C-Cex OrderBook
"""
List<LimitOrder> asks =
createOrders(currencyPair, Order.OrderType.ASK, ccexOrderBook.getAsks());
List<LimitOrder> bids =
createOrders(currencyPair, Order.OrderType.BID, ccexOrderBook.getBids());
Date date = new Date();
return new OrderBook(date, asks, bids);
} | java | public static OrderBook adaptOrderBook(
CCEXGetorderbook ccexOrderBook, CurrencyPair currencyPair) {
List<LimitOrder> asks =
createOrders(currencyPair, Order.OrderType.ASK, ccexOrderBook.getAsks());
List<LimitOrder> bids =
createOrders(currencyPair, Order.OrderType.BID, ccexOrderBook.getBids());
Date date = new Date();
return new OrderBook(date, asks, bids);
} | [
"public",
"static",
"OrderBook",
"adaptOrderBook",
"(",
"CCEXGetorderbook",
"ccexOrderBook",
",",
"CurrencyPair",
"currencyPair",
")",
"{",
"List",
"<",
"LimitOrder",
">",
"asks",
"=",
"createOrders",
"(",
"currencyPair",
",",
"Order",
".",
"OrderType",
".",
"ASK",
",",
"ccexOrderBook",
".",
"getAsks",
"(",
")",
")",
";",
"List",
"<",
"LimitOrder",
">",
"bids",
"=",
"createOrders",
"(",
"currencyPair",
",",
"Order",
".",
"OrderType",
".",
"BID",
",",
"ccexOrderBook",
".",
"getBids",
"(",
")",
")",
";",
"Date",
"date",
"=",
"new",
"Date",
"(",
")",
";",
"return",
"new",
"OrderBook",
"(",
"date",
",",
"asks",
",",
"bids",
")",
";",
"}"
] | Adapts a org.knowm.xchange.ccex.api.model.OrderBook to a OrderBook Object
@param currencyPair (e.g. BTC/USD)
@return The C-Cex OrderBook | [
"Adapts",
"a",
"org",
".",
"knowm",
".",
"xchange",
".",
"ccex",
".",
"api",
".",
"model",
".",
"OrderBook",
"to",
"a",
"OrderBook",
"Object"
] | train | https://github.com/knowm/XChange/blob/e45f437ac8e0b89cd66cdcb3258bdb1bf3d88186/xchange-ccex/src/main/java/org/knowm/xchange/ccex/CCEXAdapters.java#L78-L87 |
WiQuery/wiquery | wiquery-core/src/main/java/org/odlabs/wiquery/core/options/Options.java | Options.putFloat | public Options putFloat(String key, IModel<Float> value) {
"""
<p>
Puts an IModel <Double> value for the given option name.
</p>
@param key
the option name.
@param value
the float double.
"""
putOption(key, new FloatOption(value));
return this;
} | java | public Options putFloat(String key, IModel<Float> value)
{
putOption(key, new FloatOption(value));
return this;
} | [
"public",
"Options",
"putFloat",
"(",
"String",
"key",
",",
"IModel",
"<",
"Float",
">",
"value",
")",
"{",
"putOption",
"(",
"key",
",",
"new",
"FloatOption",
"(",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Puts an IModel <Double> value for the given option name.
</p>
@param key
the option name.
@param value
the float double. | [
"<p",
">",
"Puts",
"an",
"IModel",
"<",
";",
"Double>",
";",
"value",
"for",
"the",
"given",
"option",
"name",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/WiQuery/wiquery/blob/1b8d60c7a3c37b90fd68c9cd0ff97178fcbcbb08/wiquery-core/src/main/java/org/odlabs/wiquery/core/options/Options.java#L420-L424 |
JoeKerouac/utils | src/main/java/com/joe/utils/secure/impl/SignatureUtilImpl.java | SignatureUtilImpl.checkSign | @Override
public boolean checkSign(byte[] content, byte[] data) {
"""
使用公钥校验签名
@param content 原文
@param data 签名数据(BASE64 encode过的)
@return 返回true表示校验成功
"""
try (PooledObject<SignatureHolder> holder = CACHE.get(id).get()) {
Signature signature = holder.get().getVerify();
signature.update(content);
return signature.verify(BASE_64.decrypt(data));
} catch (Exception e) {
throw new SecureException("加密失败", e);
}
} | java | @Override
public boolean checkSign(byte[] content, byte[] data) {
try (PooledObject<SignatureHolder> holder = CACHE.get(id).get()) {
Signature signature = holder.get().getVerify();
signature.update(content);
return signature.verify(BASE_64.decrypt(data));
} catch (Exception e) {
throw new SecureException("加密失败", e);
}
} | [
"@",
"Override",
"public",
"boolean",
"checkSign",
"(",
"byte",
"[",
"]",
"content",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"try",
"(",
"PooledObject",
"<",
"SignatureHolder",
">",
"holder",
"=",
"CACHE",
".",
"get",
"(",
"id",
")",
".",
"get",
"(",
")",
")",
"{",
"Signature",
"signature",
"=",
"holder",
".",
"get",
"(",
")",
".",
"getVerify",
"(",
")",
";",
"signature",
".",
"update",
"(",
"content",
")",
";",
"return",
"signature",
".",
"verify",
"(",
"BASE_64",
".",
"decrypt",
"(",
"data",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SecureException",
"(",
"\"加密失败\", e);",
"",
"",
"",
"",
"}",
"}"
] | 使用公钥校验签名
@param content 原文
@param data 签名数据(BASE64 encode过的)
@return 返回true表示校验成功 | [
"使用公钥校验签名"
] | train | https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/secure/impl/SignatureUtilImpl.java#L119-L128 |
Azure/azure-sdk-for-java | eventgrid/resource-manager/v2019_01_01/src/main/java/com/microsoft/azure/management/eventgrid/v2019_01_01/implementation/TopicsInner.java | TopicsInner.beginUpdate | public TopicInner beginUpdate(String resourceGroupName, String topicName, Map<String, String> tags) {
"""
Update a topic.
Asynchronously updates a topic with the specified parameters.
@param resourceGroupName The name of the resource group within the user's subscription.
@param topicName Name of the topic
@param tags Tags of the resource
@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 TopicInner object if successful.
"""
return beginUpdateWithServiceResponseAsync(resourceGroupName, topicName, tags).toBlocking().single().body();
} | java | public TopicInner beginUpdate(String resourceGroupName, String topicName, Map<String, String> tags) {
return beginUpdateWithServiceResponseAsync(resourceGroupName, topicName, tags).toBlocking().single().body();
} | [
"public",
"TopicInner",
"beginUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"topicName",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"beginUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"topicName",
",",
"tags",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Update a topic.
Asynchronously updates a topic with the specified parameters.
@param resourceGroupName The name of the resource group within the user's subscription.
@param topicName Name of the topic
@param tags Tags of the resource
@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 TopicInner object if successful. | [
"Update",
"a",
"topic",
".",
"Asynchronously",
"updates",
"a",
"topic",
"with",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/resource-manager/v2019_01_01/src/main/java/com/microsoft/azure/management/eventgrid/v2019_01_01/implementation/TopicsInner.java#L803-L805 |
QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/TableDefinition.java | TableDefinition.extractLinkValue | public boolean extractLinkValue(String colName, Map<String, Set<String>> mvLinkValueMap) {
"""
Examine the given column name and, if it represents an MV link value, add it to the
given MV link value map. If a link value is successfully extracted, true is returned.
If the column name is not in the format used for MV link values, false is returned.
@param colName Column name from an object record belonging to this table (in
string form).
@param mvLinkValueMap Link value map to be updated if the column represents a valid
link value.
@return True if a link value is extracted and added to the map; false
means the column name was not a link value.
"""
// Link column names always begin with '~'.
if (colName.length() == 0 || colName.charAt(0) != '~') {
return false;
}
// A '/' should separate the field name and object value.
int slashInx = colName.indexOf('/');
if (slashInx < 0) {
return false;
}
// Extract the field name and ensure we know about this field.
String fieldName = colName.substring(1, slashInx);
// Extract the link value's target object ID and add it to the value set for the field.
String linkValue = colName.substring(slashInx + 1);
Set<String> valueSet = mvLinkValueMap.get(fieldName);
if (valueSet == null) {
// First value for this field.
valueSet = new HashSet<String>();
mvLinkValueMap.put(fieldName, valueSet);
}
valueSet.add(linkValue);
return true;
} | java | public boolean extractLinkValue(String colName, Map<String, Set<String>> mvLinkValueMap) {
// Link column names always begin with '~'.
if (colName.length() == 0 || colName.charAt(0) != '~') {
return false;
}
// A '/' should separate the field name and object value.
int slashInx = colName.indexOf('/');
if (slashInx < 0) {
return false;
}
// Extract the field name and ensure we know about this field.
String fieldName = colName.substring(1, slashInx);
// Extract the link value's target object ID and add it to the value set for the field.
String linkValue = colName.substring(slashInx + 1);
Set<String> valueSet = mvLinkValueMap.get(fieldName);
if (valueSet == null) {
// First value for this field.
valueSet = new HashSet<String>();
mvLinkValueMap.put(fieldName, valueSet);
}
valueSet.add(linkValue);
return true;
} | [
"public",
"boolean",
"extractLinkValue",
"(",
"String",
"colName",
",",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"mvLinkValueMap",
")",
"{",
"// Link column names always begin with '~'.\r",
"if",
"(",
"colName",
".",
"length",
"(",
")",
"==",
"0",
"||",
"colName",
".",
"charAt",
"(",
"0",
")",
"!=",
"'",
"'",
")",
"{",
"return",
"false",
";",
"}",
"// A '/' should separate the field name and object value.\r",
"int",
"slashInx",
"=",
"colName",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"slashInx",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"// Extract the field name and ensure we know about this field.\r",
"String",
"fieldName",
"=",
"colName",
".",
"substring",
"(",
"1",
",",
"slashInx",
")",
";",
"// Extract the link value's target object ID and add it to the value set for the field.\r",
"String",
"linkValue",
"=",
"colName",
".",
"substring",
"(",
"slashInx",
"+",
"1",
")",
";",
"Set",
"<",
"String",
">",
"valueSet",
"=",
"mvLinkValueMap",
".",
"get",
"(",
"fieldName",
")",
";",
"if",
"(",
"valueSet",
"==",
"null",
")",
"{",
"// First value for this field.\r",
"valueSet",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"mvLinkValueMap",
".",
"put",
"(",
"fieldName",
",",
"valueSet",
")",
";",
"}",
"valueSet",
".",
"add",
"(",
"linkValue",
")",
";",
"return",
"true",
";",
"}"
] | Examine the given column name and, if it represents an MV link value, add it to the
given MV link value map. If a link value is successfully extracted, true is returned.
If the column name is not in the format used for MV link values, false is returned.
@param colName Column name from an object record belonging to this table (in
string form).
@param mvLinkValueMap Link value map to be updated if the column represents a valid
link value.
@return True if a link value is extracted and added to the map; false
means the column name was not a link value. | [
"Examine",
"the",
"given",
"column",
"name",
"and",
"if",
"it",
"represents",
"an",
"MV",
"link",
"value",
"add",
"it",
"to",
"the",
"given",
"MV",
"link",
"value",
"map",
".",
"If",
"a",
"link",
"value",
"is",
"successfully",
"extracted",
"true",
"is",
"returned",
".",
"If",
"the",
"column",
"name",
"is",
"not",
"in",
"the",
"format",
"used",
"for",
"MV",
"link",
"values",
"false",
"is",
"returned",
"."
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/TableDefinition.java#L672-L697 |
micronaut-projects/micronaut-core | http-client/src/main/java/io/micronaut/http/client/interceptor/HttpClientIntroductionAdvice.java | HttpClientIntroductionAdvice.resolveTemplate | private String resolveTemplate(AnnotationValue<Client> clientAnnotation, String templateString) {
"""
Resolve the template for the client annotation.
@param clientAnnotation client annotation reference
@param templateString template to be applied
@return resolved template contents
"""
String path = clientAnnotation.get("path", String.class).orElse(null);
if (StringUtils.isNotEmpty(path)) {
return path + templateString;
} else {
String value = clientAnnotation.getValue(String.class).orElse(null);
if (StringUtils.isNotEmpty(value)) {
if (value.startsWith("/")) {
return value + templateString;
}
}
return templateString;
}
} | java | private String resolveTemplate(AnnotationValue<Client> clientAnnotation, String templateString) {
String path = clientAnnotation.get("path", String.class).orElse(null);
if (StringUtils.isNotEmpty(path)) {
return path + templateString;
} else {
String value = clientAnnotation.getValue(String.class).orElse(null);
if (StringUtils.isNotEmpty(value)) {
if (value.startsWith("/")) {
return value + templateString;
}
}
return templateString;
}
} | [
"private",
"String",
"resolveTemplate",
"(",
"AnnotationValue",
"<",
"Client",
">",
"clientAnnotation",
",",
"String",
"templateString",
")",
"{",
"String",
"path",
"=",
"clientAnnotation",
".",
"get",
"(",
"\"path\"",
",",
"String",
".",
"class",
")",
".",
"orElse",
"(",
"null",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"path",
")",
")",
"{",
"return",
"path",
"+",
"templateString",
";",
"}",
"else",
"{",
"String",
"value",
"=",
"clientAnnotation",
".",
"getValue",
"(",
"String",
".",
"class",
")",
".",
"orElse",
"(",
"null",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"value",
")",
")",
"{",
"if",
"(",
"value",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"return",
"value",
"+",
"templateString",
";",
"}",
"}",
"return",
"templateString",
";",
"}",
"}"
] | Resolve the template for the client annotation.
@param clientAnnotation client annotation reference
@param templateString template to be applied
@return resolved template contents | [
"Resolve",
"the",
"template",
"for",
"the",
"client",
"annotation",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/http-client/src/main/java/io/micronaut/http/client/interceptor/HttpClientIntroductionAdvice.java#L580-L593 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java | ByteArrayUtil.readUnsignedShort | public static int readUnsignedShort(byte[] array, int offset) {
"""
Read an unsigned short from the byte array at the given offset.
@param array Array to read from
@param offset Offset to read at
@return short
"""
// First make integers to resolve signed vs. unsigned issues.
int b0 = array[offset + 0] & 0xFF;
int b1 = array[offset + 1] & 0xFF;
return ((b0 << 8) + (b1 << 0));
} | java | public static int readUnsignedShort(byte[] array, int offset) {
// First make integers to resolve signed vs. unsigned issues.
int b0 = array[offset + 0] & 0xFF;
int b1 = array[offset + 1] & 0xFF;
return ((b0 << 8) + (b1 << 0));
} | [
"public",
"static",
"int",
"readUnsignedShort",
"(",
"byte",
"[",
"]",
"array",
",",
"int",
"offset",
")",
"{",
"// First make integers to resolve signed vs. unsigned issues.",
"int",
"b0",
"=",
"array",
"[",
"offset",
"+",
"0",
"]",
"&",
"0xFF",
";",
"int",
"b1",
"=",
"array",
"[",
"offset",
"+",
"1",
"]",
"&",
"0xFF",
";",
"return",
"(",
"(",
"b0",
"<<",
"8",
")",
"+",
"(",
"b1",
"<<",
"0",
")",
")",
";",
"}"
] | Read an unsigned short from the byte array at the given offset.
@param array Array to read from
@param offset Offset to read at
@return short | [
"Read",
"an",
"unsigned",
"short",
"from",
"the",
"byte",
"array",
"at",
"the",
"given",
"offset",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/ByteArrayUtil.java#L193-L198 |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLArgumentsTab.java | SARLArgumentsTab.createSREArgsBlock | protected void createSREArgsBlock(Composite parent, Font font) {
"""
Create the block for the SRE arguments.
@param parent the parent composite.
@param font the font for the block.
"""
// Create the block for the SRE
final Group group = new Group(parent, SWT.NONE);
group.setFont(font);
final GridLayout layout = new GridLayout();
group.setLayout(layout);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
// Move the SRE argument block before the JVM argument block
group.moveAbove(this.fVMArgumentsBlock.getControl());
group.setText(Messages.SARLArgumentsTab_1);
createSREArgsText(group, font);
createSREArgsVariableButton(group);
} | java | protected void createSREArgsBlock(Composite parent, Font font) {
// Create the block for the SRE
final Group group = new Group(parent, SWT.NONE);
group.setFont(font);
final GridLayout layout = new GridLayout();
group.setLayout(layout);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
// Move the SRE argument block before the JVM argument block
group.moveAbove(this.fVMArgumentsBlock.getControl());
group.setText(Messages.SARLArgumentsTab_1);
createSREArgsText(group, font);
createSREArgsVariableButton(group);
} | [
"protected",
"void",
"createSREArgsBlock",
"(",
"Composite",
"parent",
",",
"Font",
"font",
")",
"{",
"// Create the block for the SRE",
"final",
"Group",
"group",
"=",
"new",
"Group",
"(",
"parent",
",",
"SWT",
".",
"NONE",
")",
";",
"group",
".",
"setFont",
"(",
"font",
")",
";",
"final",
"GridLayout",
"layout",
"=",
"new",
"GridLayout",
"(",
")",
";",
"group",
".",
"setLayout",
"(",
"layout",
")",
";",
"group",
".",
"setLayoutData",
"(",
"new",
"GridData",
"(",
"GridData",
".",
"FILL_BOTH",
")",
")",
";",
"// Move the SRE argument block before the JVM argument block",
"group",
".",
"moveAbove",
"(",
"this",
".",
"fVMArgumentsBlock",
".",
"getControl",
"(",
")",
")",
";",
"group",
".",
"setText",
"(",
"Messages",
".",
"SARLArgumentsTab_1",
")",
";",
"createSREArgsText",
"(",
"group",
",",
"font",
")",
";",
"createSREArgsVariableButton",
"(",
"group",
")",
";",
"}"
] | Create the block for the SRE arguments.
@param parent the parent composite.
@param font the font for the block. | [
"Create",
"the",
"block",
"for",
"the",
"SRE",
"arguments",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/launching/dialog/SARLArgumentsTab.java#L103-L117 |
DDTH/ddth-commons | ddth-commons-core/src/main/java/com/github/ddth/commons/utils/JacksonUtils.java | JacksonUtils.fromJson | public static <T> T fromJson(JsonNode json, Class<T> clazz, ClassLoader classLoader) {
"""
Deserialize a {@link JsonNode}, with custom class loader.
@param json
@param clazz
@return
"""
return SerializationUtils.fromJson(json, clazz, classLoader);
} | java | public static <T> T fromJson(JsonNode json, Class<T> clazz, ClassLoader classLoader) {
return SerializationUtils.fromJson(json, clazz, classLoader);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"fromJson",
"(",
"JsonNode",
"json",
",",
"Class",
"<",
"T",
">",
"clazz",
",",
"ClassLoader",
"classLoader",
")",
"{",
"return",
"SerializationUtils",
".",
"fromJson",
"(",
"json",
",",
"clazz",
",",
"classLoader",
")",
";",
"}"
] | Deserialize a {@link JsonNode}, with custom class loader.
@param json
@param clazz
@return | [
"Deserialize",
"a",
"{",
"@link",
"JsonNode",
"}",
"with",
"custom",
"class",
"loader",
"."
] | train | https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/JacksonUtils.java#L96-L98 |
finmath/finmath-lib | src/main/java/net/finmath/modelling/descriptor/xmlparser/FIPXMLParser.java | FIPXMLParser.getSwapLegProductDescriptor | private static InterestRateSwapLegProductDescriptor getSwapLegProductDescriptor(Element leg, String forwardCurveName, String discountCurveName,
DayCountConvention daycountConvention) {
"""
Construct an InterestRateSwapLegProductDescriptor from a node in a FIPXML file.
@param leg The node containing the leg.
@param forwardCurveName Forward curve name form outside the node.
@param discountCurveName Discount curve name form outside the node.
@param daycountConvention Daycount convention from outside the node.
@return Descriptor of the swap leg.
"""
boolean isFixed = leg.getElementsByTagName("interestType").item(0).getTextContent().equalsIgnoreCase("FIX");
ArrayList<Period> periods = new ArrayList<>();
ArrayList<Double> notionalsList = new ArrayList<>();
ArrayList<Double> rates = new ArrayList<>();
//extracting data for each period
NodeList periodsXML = leg.getElementsByTagName("incomePayment");
for(int periodIndex = 0; periodIndex < periodsXML.getLength(); periodIndex++) {
Element periodXML = (Element) periodsXML.item(periodIndex);
LocalDate startDate = LocalDate.parse(periodXML.getElementsByTagName("startDate").item(0).getTextContent());
LocalDate endDate = LocalDate.parse(periodXML.getElementsByTagName("endDate").item(0).getTextContent());
LocalDate fixingDate = startDate;
LocalDate paymentDate = LocalDate.parse(periodXML.getElementsByTagName("payDate").item(0).getTextContent());
if(! isFixed) {
fixingDate = LocalDate.parse(periodXML.getElementsByTagName("fixingDate").item(0).getTextContent());
}
periods.add(new Period(fixingDate, paymentDate, startDate, endDate));
double notional = Double.parseDouble(periodXML.getElementsByTagName("nominal").item(0).getTextContent());
notionalsList.add(new Double(notional));
if(isFixed) {
double fixedRate = Double.parseDouble(periodXML.getElementsByTagName("fixedRate").item(0).getTextContent());
rates.add(new Double(fixedRate));
} else {
rates.add(new Double(0));
}
}
ScheduleDescriptor schedule = new ScheduleDescriptor(periods, daycountConvention);
double[] notionals = notionalsList.stream().mapToDouble(Double::doubleValue).toArray();
double[] spreads = rates.stream().mapToDouble(Double::doubleValue).toArray();
return new InterestRateSwapLegProductDescriptor(forwardCurveName, discountCurveName, schedule, notionals, spreads, false);
} | java | private static InterestRateSwapLegProductDescriptor getSwapLegProductDescriptor(Element leg, String forwardCurveName, String discountCurveName,
DayCountConvention daycountConvention) {
boolean isFixed = leg.getElementsByTagName("interestType").item(0).getTextContent().equalsIgnoreCase("FIX");
ArrayList<Period> periods = new ArrayList<>();
ArrayList<Double> notionalsList = new ArrayList<>();
ArrayList<Double> rates = new ArrayList<>();
//extracting data for each period
NodeList periodsXML = leg.getElementsByTagName("incomePayment");
for(int periodIndex = 0; periodIndex < periodsXML.getLength(); periodIndex++) {
Element periodXML = (Element) periodsXML.item(periodIndex);
LocalDate startDate = LocalDate.parse(periodXML.getElementsByTagName("startDate").item(0).getTextContent());
LocalDate endDate = LocalDate.parse(periodXML.getElementsByTagName("endDate").item(0).getTextContent());
LocalDate fixingDate = startDate;
LocalDate paymentDate = LocalDate.parse(periodXML.getElementsByTagName("payDate").item(0).getTextContent());
if(! isFixed) {
fixingDate = LocalDate.parse(periodXML.getElementsByTagName("fixingDate").item(0).getTextContent());
}
periods.add(new Period(fixingDate, paymentDate, startDate, endDate));
double notional = Double.parseDouble(periodXML.getElementsByTagName("nominal").item(0).getTextContent());
notionalsList.add(new Double(notional));
if(isFixed) {
double fixedRate = Double.parseDouble(periodXML.getElementsByTagName("fixedRate").item(0).getTextContent());
rates.add(new Double(fixedRate));
} else {
rates.add(new Double(0));
}
}
ScheduleDescriptor schedule = new ScheduleDescriptor(periods, daycountConvention);
double[] notionals = notionalsList.stream().mapToDouble(Double::doubleValue).toArray();
double[] spreads = rates.stream().mapToDouble(Double::doubleValue).toArray();
return new InterestRateSwapLegProductDescriptor(forwardCurveName, discountCurveName, schedule, notionals, spreads, false);
} | [
"private",
"static",
"InterestRateSwapLegProductDescriptor",
"getSwapLegProductDescriptor",
"(",
"Element",
"leg",
",",
"String",
"forwardCurveName",
",",
"String",
"discountCurveName",
",",
"DayCountConvention",
"daycountConvention",
")",
"{",
"boolean",
"isFixed",
"=",
"leg",
".",
"getElementsByTagName",
"(",
"\"interestType\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"\"FIX\"",
")",
";",
"ArrayList",
"<",
"Period",
">",
"periods",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"ArrayList",
"<",
"Double",
">",
"notionalsList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"ArrayList",
"<",
"Double",
">",
"rates",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"//extracting data for each period\r",
"NodeList",
"periodsXML",
"=",
"leg",
".",
"getElementsByTagName",
"(",
"\"incomePayment\"",
")",
";",
"for",
"(",
"int",
"periodIndex",
"=",
"0",
";",
"periodIndex",
"<",
"periodsXML",
".",
"getLength",
"(",
")",
";",
"periodIndex",
"++",
")",
"{",
"Element",
"periodXML",
"=",
"(",
"Element",
")",
"periodsXML",
".",
"item",
"(",
"periodIndex",
")",
";",
"LocalDate",
"startDate",
"=",
"LocalDate",
".",
"parse",
"(",
"periodXML",
".",
"getElementsByTagName",
"(",
"\"startDate\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"LocalDate",
"endDate",
"=",
"LocalDate",
".",
"parse",
"(",
"periodXML",
".",
"getElementsByTagName",
"(",
"\"endDate\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"LocalDate",
"fixingDate",
"=",
"startDate",
";",
"LocalDate",
"paymentDate",
"=",
"LocalDate",
".",
"parse",
"(",
"periodXML",
".",
"getElementsByTagName",
"(",
"\"payDate\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"if",
"(",
"!",
"isFixed",
")",
"{",
"fixingDate",
"=",
"LocalDate",
".",
"parse",
"(",
"periodXML",
".",
"getElementsByTagName",
"(",
"\"fixingDate\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"}",
"periods",
".",
"add",
"(",
"new",
"Period",
"(",
"fixingDate",
",",
"paymentDate",
",",
"startDate",
",",
"endDate",
")",
")",
";",
"double",
"notional",
"=",
"Double",
".",
"parseDouble",
"(",
"periodXML",
".",
"getElementsByTagName",
"(",
"\"nominal\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"notionalsList",
".",
"add",
"(",
"new",
"Double",
"(",
"notional",
")",
")",
";",
"if",
"(",
"isFixed",
")",
"{",
"double",
"fixedRate",
"=",
"Double",
".",
"parseDouble",
"(",
"periodXML",
".",
"getElementsByTagName",
"(",
"\"fixedRate\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"rates",
".",
"add",
"(",
"new",
"Double",
"(",
"fixedRate",
")",
")",
";",
"}",
"else",
"{",
"rates",
".",
"add",
"(",
"new",
"Double",
"(",
"0",
")",
")",
";",
"}",
"}",
"ScheduleDescriptor",
"schedule",
"=",
"new",
"ScheduleDescriptor",
"(",
"periods",
",",
"daycountConvention",
")",
";",
"double",
"[",
"]",
"notionals",
"=",
"notionalsList",
".",
"stream",
"(",
")",
".",
"mapToDouble",
"(",
"Double",
"::",
"doubleValue",
")",
".",
"toArray",
"(",
")",
";",
"double",
"[",
"]",
"spreads",
"=",
"rates",
".",
"stream",
"(",
")",
".",
"mapToDouble",
"(",
"Double",
"::",
"doubleValue",
")",
".",
"toArray",
"(",
")",
";",
"return",
"new",
"InterestRateSwapLegProductDescriptor",
"(",
"forwardCurveName",
",",
"discountCurveName",
",",
"schedule",
",",
"notionals",
",",
"spreads",
",",
"false",
")",
";",
"}"
] | Construct an InterestRateSwapLegProductDescriptor from a node in a FIPXML file.
@param leg The node containing the leg.
@param forwardCurveName Forward curve name form outside the node.
@param discountCurveName Discount curve name form outside the node.
@param daycountConvention Daycount convention from outside the node.
@return Descriptor of the swap leg. | [
"Construct",
"an",
"InterestRateSwapLegProductDescriptor",
"from",
"a",
"node",
"in",
"a",
"FIPXML",
"file",
"."
] | train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java/net/finmath/modelling/descriptor/xmlparser/FIPXMLParser.java#L152-L196 |
Activiti/Activiti | activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java | MultiInstanceActivityBehavior.trigger | public void trigger(DelegateExecution execution, String signalName, Object signalData) {
"""
Intercepts signals, and delegates it to the wrapped {@link ActivityBehavior}.
"""
innerActivityBehavior.trigger(execution, signalName, signalData);
} | java | public void trigger(DelegateExecution execution, String signalName, Object signalData) {
innerActivityBehavior.trigger(execution, signalName, signalData);
} | [
"public",
"void",
"trigger",
"(",
"DelegateExecution",
"execution",
",",
"String",
"signalName",
",",
"Object",
"signalData",
")",
"{",
"innerActivityBehavior",
".",
"trigger",
"(",
"execution",
",",
"signalName",
",",
"signalData",
")",
";",
"}"
] | Intercepts signals, and delegates it to the wrapped {@link ActivityBehavior}. | [
"Intercepts",
"signals",
"and",
"delegates",
"it",
"to",
"the",
"wrapped",
"{"
] | train | https://github.com/Activiti/Activiti/blob/82e2b2cd2083b2f734ca0efc7815389c0f2517d9/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java#L156-L158 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/widget/attribute/AttributeFormFieldRegistry.java | AttributeFormFieldRegistry.createFormItem | public static FormItem createFormItem(AbstractReadOnlyAttributeInfo info, VectorLayer layer) {
"""
Create a new {@link FormItem} instance for the given attribute info (top level attribute).<br/>
If the attribute info object has the <code>formInputType</code> set, than that will be used to search for the
correct field type, otherwise the attribute TYPE name is used (i.e. PrimitiveType.INTEGER.name()).
@param info The actual attribute info to create a form item for
@param layer The layer to create a form item for (needed to fetch association values)
@return The new form item instance associated with the type of attribute.
"""
return createFormItem(info, new DefaultAttributeProvider(layer, info.getName()));
} | java | public static FormItem createFormItem(AbstractReadOnlyAttributeInfo info, VectorLayer layer) {
return createFormItem(info, new DefaultAttributeProvider(layer, info.getName()));
} | [
"public",
"static",
"FormItem",
"createFormItem",
"(",
"AbstractReadOnlyAttributeInfo",
"info",
",",
"VectorLayer",
"layer",
")",
"{",
"return",
"createFormItem",
"(",
"info",
",",
"new",
"DefaultAttributeProvider",
"(",
"layer",
",",
"info",
".",
"getName",
"(",
")",
")",
")",
";",
"}"
] | Create a new {@link FormItem} instance for the given attribute info (top level attribute).<br/>
If the attribute info object has the <code>formInputType</code> set, than that will be used to search for the
correct field type, otherwise the attribute TYPE name is used (i.e. PrimitiveType.INTEGER.name()).
@param info The actual attribute info to create a form item for
@param layer The layer to create a form item for (needed to fetch association values)
@return The new form item instance associated with the type of attribute. | [
"Create",
"a",
"new",
"{",
"@link",
"FormItem",
"}",
"instance",
"for",
"the",
"given",
"attribute",
"info",
"(",
"top",
"level",
"attribute",
")",
".",
"<br",
"/",
">",
"If",
"the",
"attribute",
"info",
"object",
"has",
"the",
"<code",
">",
"formInputType<",
"/",
"code",
">",
"set",
"than",
"that",
"will",
"be",
"used",
"to",
"search",
"for",
"the",
"correct",
"field",
"type",
"otherwise",
"the",
"attribute",
"TYPE",
"name",
"is",
"used",
"(",
"i",
".",
"e",
".",
"PrimitiveType",
".",
"INTEGER",
".",
"name",
"()",
")",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/widget/attribute/AttributeFormFieldRegistry.java#L403-L405 |
unbescape/unbescape | src/main/java/org/unbescape/css/CssEscape.java | CssEscape.unescapeCss | public static void unescapeCss(final char[] text, final int offset, final int len, final Writer writer)
throws IOException {
"""
<p>
Perform a CSS <strong>unescape</strong> operation on a <tt>char[]</tt> input.
</p>
<p>
No additional configuration arguments are required. Unescape operations
will always perform <em>complete</em> CSS unescape of backslash and hexadecimal escape
sequences.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>char[]</tt> to be unescaped.
@param offset the position in <tt>text</tt> at which the unescape operation should start.
@param len the number of characters in <tt>text</tt> that should be unescaped.
@param writer the <tt>java.io.Writer</tt> to which the unescaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@throws IOException if an input/output exception occurs
"""
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
final int textLen = (text == null? 0 : text.length);
if (offset < 0 || offset > textLen) {
throw new IllegalArgumentException(
"Invalid (offset, len). offset=" + offset + ", len=" + len + ", text.length=" + textLen);
}
if (len < 0 || (offset + len) > textLen) {
throw new IllegalArgumentException(
"Invalid (offset, len). offset=" + offset + ", len=" + len + ", text.length=" + textLen);
}
CssUnescapeUtil.unescape(text, offset, len, writer);
} | java | public static void unescapeCss(final char[] text, final int offset, final int len, final Writer writer)
throws IOException{
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
final int textLen = (text == null? 0 : text.length);
if (offset < 0 || offset > textLen) {
throw new IllegalArgumentException(
"Invalid (offset, len). offset=" + offset + ", len=" + len + ", text.length=" + textLen);
}
if (len < 0 || (offset + len) > textLen) {
throw new IllegalArgumentException(
"Invalid (offset, len). offset=" + offset + ", len=" + len + ", text.length=" + textLen);
}
CssUnescapeUtil.unescape(text, offset, len, writer);
} | [
"public",
"static",
"void",
"unescapeCss",
"(",
"final",
"char",
"[",
"]",
"text",
",",
"final",
"int",
"offset",
",",
"final",
"int",
"len",
",",
"final",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"if",
"(",
"writer",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument 'writer' cannot be null\"",
")",
";",
"}",
"final",
"int",
"textLen",
"=",
"(",
"text",
"==",
"null",
"?",
"0",
":",
"text",
".",
"length",
")",
";",
"if",
"(",
"offset",
"<",
"0",
"||",
"offset",
">",
"textLen",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid (offset, len). offset=\"",
"+",
"offset",
"+",
"\", len=\"",
"+",
"len",
"+",
"\", text.length=\"",
"+",
"textLen",
")",
";",
"}",
"if",
"(",
"len",
"<",
"0",
"||",
"(",
"offset",
"+",
"len",
")",
">",
"textLen",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid (offset, len). offset=\"",
"+",
"offset",
"+",
"\", len=\"",
"+",
"len",
"+",
"\", text.length=\"",
"+",
"textLen",
")",
";",
"}",
"CssUnescapeUtil",
".",
"unescape",
"(",
"text",
",",
"offset",
",",
"len",
",",
"writer",
")",
";",
"}"
] | <p>
Perform a CSS <strong>unescape</strong> operation on a <tt>char[]</tt> input.
</p>
<p>
No additional configuration arguments are required. Unescape operations
will always perform <em>complete</em> CSS unescape of backslash and hexadecimal escape
sequences.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>char[]</tt> to be unescaped.
@param offset the position in <tt>text</tt> at which the unescape operation should start.
@param len the number of characters in <tt>text</tt> that should be unescaped.
@param writer the <tt>java.io.Writer</tt> to which the unescaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@throws IOException if an input/output exception occurs | [
"<p",
">",
"Perform",
"a",
"CSS",
"<strong",
">",
"unescape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"char",
"[]",
"<",
"/",
"tt",
">",
"input",
".",
"<",
"/",
"p",
">",
"<p",
">",
"No",
"additional",
"configuration",
"arguments",
"are",
"required",
".",
"Unescape",
"operations",
"will",
"always",
"perform",
"<em",
">",
"complete<",
"/",
"em",
">",
"CSS",
"unescape",
"of",
"backslash",
"and",
"hexadecimal",
"escape",
"sequences",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/css/CssEscape.java#L1840-L1861 |
comapi/comapi-sdk-android | COMAPI/foundation/src/main/java/com/comapi/internal/network/ServiceApiWrapper.java | ServiceApiWrapper.doQueryEvents | Observable<ComapiResult<EventsQueryResponse>> doQueryEvents(@NonNull final String token, @NonNull final String conversationId, @NonNull final Long from, @NonNull final Integer limit) {
"""
Query events. Use {@link #doQueryConversationEvents(String, String, Long, Integer)} for better visibility of possible events.
@param token Comapi access token.
@param conversationId ID of a conversation to query events in it.
@param from ID of the event to start from.
@param limit Limit of events to obtain in this call.
@return Observable to get events in a conversation.
"""
return addLogging(service.queryEvents(AuthManager.addAuthPrefix(token), apiSpaceId, conversationId, from, limit).map(mapToComapiResult()), log, "Querying events in " + conversationId)
.flatMap(result -> {
EventsQueryResponse newResult = new EventsQueryResponse(result.getResult(), new Parser());
return wrapObservable(Observable.just(new ComapiResult<>(result, newResult)));
});
} | java | Observable<ComapiResult<EventsQueryResponse>> doQueryEvents(@NonNull final String token, @NonNull final String conversationId, @NonNull final Long from, @NonNull final Integer limit) {
return addLogging(service.queryEvents(AuthManager.addAuthPrefix(token), apiSpaceId, conversationId, from, limit).map(mapToComapiResult()), log, "Querying events in " + conversationId)
.flatMap(result -> {
EventsQueryResponse newResult = new EventsQueryResponse(result.getResult(), new Parser());
return wrapObservable(Observable.just(new ComapiResult<>(result, newResult)));
});
} | [
"Observable",
"<",
"ComapiResult",
"<",
"EventsQueryResponse",
">",
">",
"doQueryEvents",
"(",
"@",
"NonNull",
"final",
"String",
"token",
",",
"@",
"NonNull",
"final",
"String",
"conversationId",
",",
"@",
"NonNull",
"final",
"Long",
"from",
",",
"@",
"NonNull",
"final",
"Integer",
"limit",
")",
"{",
"return",
"addLogging",
"(",
"service",
".",
"queryEvents",
"(",
"AuthManager",
".",
"addAuthPrefix",
"(",
"token",
")",
",",
"apiSpaceId",
",",
"conversationId",
",",
"from",
",",
"limit",
")",
".",
"map",
"(",
"mapToComapiResult",
"(",
")",
")",
",",
"log",
",",
"\"Querying events in \"",
"+",
"conversationId",
")",
".",
"flatMap",
"(",
"result",
"->",
"{",
"EventsQueryResponse",
"newResult",
"=",
"new",
"EventsQueryResponse",
"(",
"result",
".",
"getResult",
"(",
")",
",",
"new",
"Parser",
"(",
")",
")",
";",
"return",
"wrapObservable",
"(",
"Observable",
".",
"just",
"(",
"new",
"ComapiResult",
"<>",
"(",
"result",
",",
"newResult",
")",
")",
")",
";",
"}",
")",
";",
"}"
] | Query events. Use {@link #doQueryConversationEvents(String, String, Long, Integer)} for better visibility of possible events.
@param token Comapi access token.
@param conversationId ID of a conversation to query events in it.
@param from ID of the event to start from.
@param limit Limit of events to obtain in this call.
@return Observable to get events in a conversation. | [
"Query",
"events",
".",
"Use",
"{",
"@link",
"#doQueryConversationEvents",
"(",
"String",
"String",
"Long",
"Integer",
")",
"}",
"for",
"better",
"visibility",
"of",
"possible",
"events",
"."
] | train | https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/ServiceApiWrapper.java#L273-L279 |
santhosh-tekuri/jlibs | core/src/main/java/jlibs/core/lang/Noun.java | Noun.addSingular | public static void addSingular(String match, String rule, boolean insensitive) {
"""
<p>Add a match pattern and replacement rule for converting addSingular
forms to addPlural forms.</p>
@param match Match pattern regular expression
@param rule Replacement rule
@param insensitive Flag indicating this match should be case insensitive
"""
singulars.add(0, new Replacer(match, rule, insensitive));
} | java | public static void addSingular(String match, String rule, boolean insensitive){
singulars.add(0, new Replacer(match, rule, insensitive));
} | [
"public",
"static",
"void",
"addSingular",
"(",
"String",
"match",
",",
"String",
"rule",
",",
"boolean",
"insensitive",
")",
"{",
"singulars",
".",
"add",
"(",
"0",
",",
"new",
"Replacer",
"(",
"match",
",",
"rule",
",",
"insensitive",
")",
")",
";",
"}"
] | <p>Add a match pattern and replacement rule for converting addSingular
forms to addPlural forms.</p>
@param match Match pattern regular expression
@param rule Replacement rule
@param insensitive Flag indicating this match should be case insensitive | [
"<p",
">",
"Add",
"a",
"match",
"pattern",
"and",
"replacement",
"rule",
"for",
"converting",
"addSingular",
"forms",
"to",
"addPlural",
"forms",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/santhosh-tekuri/jlibs/blob/59c28719f054123cf778278154e1b92e943ad232/core/src/main/java/jlibs/core/lang/Noun.java#L106-L108 |
dnsjava/dnsjava | org/xbill/DNS/TSIG.java | TSIG.verify | public int
verify(Message m, byte [] b, TSIGRecord old) {
"""
Verifies a TSIG record on an incoming message. Since this is only called
in the context where a TSIG is expected to be present, it is an error
if one is not present. After calling this routine, Message.isVerified() may
be called on this message.
@param m The message
@param b The message in unparsed form. This is necessary since TSIG
signs the message in wire format, and we can't recreate the exact wire
format (with the same name compression).
@param old If this message is a response, the TSIG from the request
@return The result of the verification (as an Rcode)
@see Rcode
"""
return verify(m, b, b.length, old);
} | java | public int
verify(Message m, byte [] b, TSIGRecord old) {
return verify(m, b, b.length, old);
} | [
"public",
"int",
"verify",
"(",
"Message",
"m",
",",
"byte",
"[",
"]",
"b",
",",
"TSIGRecord",
"old",
")",
"{",
"return",
"verify",
"(",
"m",
",",
"b",
",",
"b",
".",
"length",
",",
"old",
")",
";",
"}"
] | Verifies a TSIG record on an incoming message. Since this is only called
in the context where a TSIG is expected to be present, it is an error
if one is not present. After calling this routine, Message.isVerified() may
be called on this message.
@param m The message
@param b The message in unparsed form. This is necessary since TSIG
signs the message in wire format, and we can't recreate the exact wire
format (with the same name compression).
@param old If this message is a response, the TSIG from the request
@return The result of the verification (as an Rcode)
@see Rcode | [
"Verifies",
"a",
"TSIG",
"record",
"on",
"an",
"incoming",
"message",
".",
"Since",
"this",
"is",
"only",
"called",
"in",
"the",
"context",
"where",
"a",
"TSIG",
"is",
"expected",
"to",
"be",
"present",
"it",
"is",
"an",
"error",
"if",
"one",
"is",
"not",
"present",
".",
"After",
"calling",
"this",
"routine",
"Message",
".",
"isVerified",
"()",
"may",
"be",
"called",
"on",
"this",
"message",
"."
] | train | https://github.com/dnsjava/dnsjava/blob/d97b6a0685d59143372bb392ab591dd8dd840b61/org/xbill/DNS/TSIG.java#L526-L529 |
roboconf/roboconf-platform | core/roboconf-core/src/main/java/net/roboconf/core/userdata/UserDataHelpers.java | UserDataHelpers.readUserData | public static Properties readUserData( String rawProperties, File outputDirectory ) throws IOException {
"""
Reads user data from a string and processes with with #{@link UserDataHelpers#processUserData(Properties, File)}.
@param rawProperties the user data as a string
@param outputDirectory a directory into which files should be written
<p>
If null, files sent with {@link #ENCODE_FILE_CONTENT_PREFIX} will not be written.
</p>
@return a non-null object
@throws IOException if something went wrong
"""
Properties result = new Properties();
StringReader reader = new StringReader( rawProperties );
result.load( reader );
return processUserData( result, outputDirectory );
} | java | public static Properties readUserData( String rawProperties, File outputDirectory ) throws IOException {
Properties result = new Properties();
StringReader reader = new StringReader( rawProperties );
result.load( reader );
return processUserData( result, outputDirectory );
} | [
"public",
"static",
"Properties",
"readUserData",
"(",
"String",
"rawProperties",
",",
"File",
"outputDirectory",
")",
"throws",
"IOException",
"{",
"Properties",
"result",
"=",
"new",
"Properties",
"(",
")",
";",
"StringReader",
"reader",
"=",
"new",
"StringReader",
"(",
"rawProperties",
")",
";",
"result",
".",
"load",
"(",
"reader",
")",
";",
"return",
"processUserData",
"(",
"result",
",",
"outputDirectory",
")",
";",
"}"
] | Reads user data from a string and processes with with #{@link UserDataHelpers#processUserData(Properties, File)}.
@param rawProperties the user data as a string
@param outputDirectory a directory into which files should be written
<p>
If null, files sent with {@link #ENCODE_FILE_CONTENT_PREFIX} will not be written.
</p>
@return a non-null object
@throws IOException if something went wrong | [
"Reads",
"user",
"data",
"from",
"a",
"string",
"and",
"processes",
"with",
"with",
"#",
"{",
"@link",
"UserDataHelpers#processUserData",
"(",
"Properties",
"File",
")",
"}",
".",
"@param",
"rawProperties",
"the",
"user",
"data",
"as",
"a",
"string",
"@param",
"outputDirectory",
"a",
"directory",
"into",
"which",
"files",
"should",
"be",
"written",
"<p",
">",
"If",
"null",
"files",
"sent",
"with",
"{",
"@link",
"#ENCODE_FILE_CONTENT_PREFIX",
"}",
"will",
"not",
"be",
"written",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/userdata/UserDataHelpers.java#L166-L173 |
finmath/finmath-lib | src/main/java6/net/finmath/montecarlo/interestrate/products/BermudanSwaption.java | BermudanSwaption.getConditionalExpectationEstimator | public ConditionalExpectationEstimatorInterface getConditionalExpectationEstimator(double fixingDate, LIBORModelMonteCarloSimulationInterface model) throws CalculationException {
"""
Return the conditional expectation estimator suitable for this product.
@param fixingDate The condition time.
@param model The model
@return The conditional expectation estimator suitable for this product
@throws net.finmath.exception.CalculationException Thrown if the valuation fails, specific cause may be available via the <code>cause()</code> method.
"""
MonteCarloConditionalExpectationRegression condExpEstimator = new MonteCarloConditionalExpectationRegression(
getRegressionBasisFunctions(fixingDate, model)
);
return condExpEstimator;
} | java | public ConditionalExpectationEstimatorInterface getConditionalExpectationEstimator(double fixingDate, LIBORModelMonteCarloSimulationInterface model) throws CalculationException {
MonteCarloConditionalExpectationRegression condExpEstimator = new MonteCarloConditionalExpectationRegression(
getRegressionBasisFunctions(fixingDate, model)
);
return condExpEstimator;
} | [
"public",
"ConditionalExpectationEstimatorInterface",
"getConditionalExpectationEstimator",
"(",
"double",
"fixingDate",
",",
"LIBORModelMonteCarloSimulationInterface",
"model",
")",
"throws",
"CalculationException",
"{",
"MonteCarloConditionalExpectationRegression",
"condExpEstimator",
"=",
"new",
"MonteCarloConditionalExpectationRegression",
"(",
"getRegressionBasisFunctions",
"(",
"fixingDate",
",",
"model",
")",
")",
";",
"return",
"condExpEstimator",
";",
"}"
] | Return the conditional expectation estimator suitable for this product.
@param fixingDate The condition time.
@param model The model
@return The conditional expectation estimator suitable for this product
@throws net.finmath.exception.CalculationException Thrown if the valuation fails, specific cause may be available via the <code>cause()</code> method. | [
"Return",
"the",
"conditional",
"expectation",
"estimator",
"suitable",
"for",
"this",
"product",
"."
] | train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java6/net/finmath/montecarlo/interestrate/products/BermudanSwaption.java#L160-L165 |
apache/flink | flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/streaming/data/PythonReceiver.java | PythonReceiver.collectBuffer | @SuppressWarnings( {
"""
Reads a buffer of the given size from the memory-mapped file, and collects all records contained. This method
assumes that all values in the buffer are of the same type. This method does NOT take care of synchronization.
The user must guarantee that the buffer was completely written before calling this method.
@param c Collector to collect records
@param bufferSize size of the buffer
@throws IOException
""" "rawtypes", "unchecked" })
public void collectBuffer(Collector<OUT> c, int bufferSize) throws IOException {
fileBuffer.position(0);
while (fileBuffer.position() < bufferSize) {
c.collect(deserializer.deserialize());
}
} | java | @SuppressWarnings({ "rawtypes", "unchecked" })
public void collectBuffer(Collector<OUT> c, int bufferSize) throws IOException {
fileBuffer.position(0);
while (fileBuffer.position() < bufferSize) {
c.collect(deserializer.deserialize());
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"public",
"void",
"collectBuffer",
"(",
"Collector",
"<",
"OUT",
">",
"c",
",",
"int",
"bufferSize",
")",
"throws",
"IOException",
"{",
"fileBuffer",
".",
"position",
"(",
"0",
")",
";",
"while",
"(",
"fileBuffer",
".",
"position",
"(",
")",
"<",
"bufferSize",
")",
"{",
"c",
".",
"collect",
"(",
"deserializer",
".",
"deserialize",
"(",
")",
")",
";",
"}",
"}"
] | Reads a buffer of the given size from the memory-mapped file, and collects all records contained. This method
assumes that all values in the buffer are of the same type. This method does NOT take care of synchronization.
The user must guarantee that the buffer was completely written before calling this method.
@param c Collector to collect records
@param bufferSize size of the buffer
@throws IOException | [
"Reads",
"a",
"buffer",
"of",
"the",
"given",
"size",
"from",
"the",
"memory",
"-",
"mapped",
"file",
"and",
"collects",
"all",
"records",
"contained",
".",
"This",
"method",
"assumes",
"that",
"all",
"values",
"in",
"the",
"buffer",
"are",
"of",
"the",
"same",
"type",
".",
"This",
"method",
"does",
"NOT",
"take",
"care",
"of",
"synchronization",
".",
"The",
"user",
"must",
"guarantee",
"that",
"the",
"buffer",
"was",
"completely",
"written",
"before",
"calling",
"this",
"method",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/streaming/data/PythonReceiver.java#L91-L98 |
reactor/reactor-netty | src/main/java/reactor/netty/tcp/TcpServer.java | TcpServer.bindUntilJavaShutdown | public final void bindUntilJavaShutdown(Duration timeout, @Nullable Consumer<DisposableServer> onStart) {
"""
Start the server in a fully blocking fashion, not only waiting for it to initialize
but also blocking during the full lifecycle of the server. Since most
servers will be long-lived, this is more adapted to running a server out of a main
method, only allowing shutdown of the servers through {@code sigkill}.
<p>
Note: {@link Runtime#addShutdownHook(Thread) JVM shutdown hook} is added by
this method in order to properly disconnect the server upon receiving a
{@code sigkill} signal.</p>
@param timeout a timeout for server shutdown
@param onStart an optional callback on server start
"""
Objects.requireNonNull(timeout, "timeout");
DisposableServer facade = bindNow();
Objects.requireNonNull(facade, "facade");
if (onStart != null) {
onStart.accept(facade);
}
Runtime.getRuntime()
.addShutdownHook(new Thread(() -> facade.disposeNow(timeout)));
facade.onDispose()
.block();
} | java | public final void bindUntilJavaShutdown(Duration timeout, @Nullable Consumer<DisposableServer> onStart) {
Objects.requireNonNull(timeout, "timeout");
DisposableServer facade = bindNow();
Objects.requireNonNull(facade, "facade");
if (onStart != null) {
onStart.accept(facade);
}
Runtime.getRuntime()
.addShutdownHook(new Thread(() -> facade.disposeNow(timeout)));
facade.onDispose()
.block();
} | [
"public",
"final",
"void",
"bindUntilJavaShutdown",
"(",
"Duration",
"timeout",
",",
"@",
"Nullable",
"Consumer",
"<",
"DisposableServer",
">",
"onStart",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"timeout",
",",
"\"timeout\"",
")",
";",
"DisposableServer",
"facade",
"=",
"bindNow",
"(",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"facade",
",",
"\"facade\"",
")",
";",
"if",
"(",
"onStart",
"!=",
"null",
")",
"{",
"onStart",
".",
"accept",
"(",
"facade",
")",
";",
"}",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"addShutdownHook",
"(",
"new",
"Thread",
"(",
"(",
")",
"->",
"facade",
".",
"disposeNow",
"(",
"timeout",
")",
")",
")",
";",
"facade",
".",
"onDispose",
"(",
")",
".",
"block",
"(",
")",
";",
"}"
] | Start the server in a fully blocking fashion, not only waiting for it to initialize
but also blocking during the full lifecycle of the server. Since most
servers will be long-lived, this is more adapted to running a server out of a main
method, only allowing shutdown of the servers through {@code sigkill}.
<p>
Note: {@link Runtime#addShutdownHook(Thread) JVM shutdown hook} is added by
this method in order to properly disconnect the server upon receiving a
{@code sigkill} signal.</p>
@param timeout a timeout for server shutdown
@param onStart an optional callback on server start | [
"Start",
"the",
"server",
"in",
"a",
"fully",
"blocking",
"fashion",
"not",
"only",
"waiting",
"for",
"it",
"to",
"initialize",
"but",
"also",
"blocking",
"during",
"the",
"full",
"lifecycle",
"of",
"the",
"server",
".",
"Since",
"most",
"servers",
"will",
"be",
"long",
"-",
"lived",
"this",
"is",
"more",
"adapted",
"to",
"running",
"a",
"server",
"out",
"of",
"a",
"main",
"method",
"only",
"allowing",
"shutdown",
"of",
"the",
"servers",
"through",
"{",
"@code",
"sigkill",
"}",
".",
"<p",
">",
"Note",
":",
"{",
"@link",
"Runtime#addShutdownHook",
"(",
"Thread",
")",
"JVM",
"shutdown",
"hook",
"}",
"is",
"added",
"by",
"this",
"method",
"in",
"order",
"to",
"properly",
"disconnect",
"the",
"server",
"upon",
"receiving",
"a",
"{",
"@code",
"sigkill",
"}",
"signal",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/reactor/reactor-netty/blob/4ed14316e1d7fca3cecd18d6caa5f2251e159e49/src/main/java/reactor/netty/tcp/TcpServer.java#L211-L227 |
pippo-java/pippo | pippo-core/src/main/java/ro/pippo/core/Response.java | Response.send | public void send(String format, Object... args) {
"""
Replaces '{}' in the format string with the supplied arguments and
writes the string content directly to the response.
<p>This method commits the response.</p>
@param format
@param args
"""
checkCommitted();
commit(StringUtils.format(format, args));
} | java | public void send(String format, Object... args) {
checkCommitted();
commit(StringUtils.format(format, args));
} | [
"public",
"void",
"send",
"(",
"String",
"format",
",",
"Object",
"...",
"args",
")",
"{",
"checkCommitted",
"(",
")",
";",
"commit",
"(",
"StringUtils",
".",
"format",
"(",
"format",
",",
"args",
")",
")",
";",
"}"
] | Replaces '{}' in the format string with the supplied arguments and
writes the string content directly to the response.
<p>This method commits the response.</p>
@param format
@param args | [
"Replaces",
"{}",
"in",
"the",
"format",
"string",
"with",
"the",
"supplied",
"arguments",
"and",
"writes",
"the",
"string",
"content",
"directly",
"to",
"the",
"response",
".",
"<p",
">",
"This",
"method",
"commits",
"the",
"response",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/pippo-java/pippo/blob/cb5ccb453bffcc3cf386adc660674812d10b9726/pippo-core/src/main/java/ro/pippo/core/Response.java#L848-L852 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/registry/AtomicMapFieldUpdater.java | AtomicMapFieldUpdater.putAtomic | public boolean putAtomic(C instance, K key, V value, Map<K, V> snapshot) {
"""
Put a value if and only if the map has not changed since the given snapshot was taken. If the put fails,
it is the caller's responsibility to retry.
@param instance the instance with the map field
@param key the key
@param value the value
@param snapshot the map snapshot
@return {@code false} if the snapshot is out of date and we could not update, {@code true} if the put succeeded
"""
Assert.checkNotNullParam("key", key);
final Map<K, V> newMap;
final int oldSize = snapshot.size();
if (oldSize == 0) {
newMap = Collections.singletonMap(key, value);
} else if (oldSize == 1) {
final Map.Entry<K, V> entry = snapshot.entrySet().iterator().next();
final K oldKey = entry.getKey();
if (oldKey.equals(key)) {
return false;
} else {
newMap = new FastCopyHashMap<K, V>(snapshot);
newMap.put(key, value);
}
} else {
newMap = new FastCopyHashMap<K, V>(snapshot);
newMap.put(key, value);
}
return updater.compareAndSet(instance, snapshot, newMap);
} | java | public boolean putAtomic(C instance, K key, V value, Map<K, V> snapshot) {
Assert.checkNotNullParam("key", key);
final Map<K, V> newMap;
final int oldSize = snapshot.size();
if (oldSize == 0) {
newMap = Collections.singletonMap(key, value);
} else if (oldSize == 1) {
final Map.Entry<K, V> entry = snapshot.entrySet().iterator().next();
final K oldKey = entry.getKey();
if (oldKey.equals(key)) {
return false;
} else {
newMap = new FastCopyHashMap<K, V>(snapshot);
newMap.put(key, value);
}
} else {
newMap = new FastCopyHashMap<K, V>(snapshot);
newMap.put(key, value);
}
return updater.compareAndSet(instance, snapshot, newMap);
} | [
"public",
"boolean",
"putAtomic",
"(",
"C",
"instance",
",",
"K",
"key",
",",
"V",
"value",
",",
"Map",
"<",
"K",
",",
"V",
">",
"snapshot",
")",
"{",
"Assert",
".",
"checkNotNullParam",
"(",
"\"key\"",
",",
"key",
")",
";",
"final",
"Map",
"<",
"K",
",",
"V",
">",
"newMap",
";",
"final",
"int",
"oldSize",
"=",
"snapshot",
".",
"size",
"(",
")",
";",
"if",
"(",
"oldSize",
"==",
"0",
")",
"{",
"newMap",
"=",
"Collections",
".",
"singletonMap",
"(",
"key",
",",
"value",
")",
";",
"}",
"else",
"if",
"(",
"oldSize",
"==",
"1",
")",
"{",
"final",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
"entry",
"=",
"snapshot",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"final",
"K",
"oldKey",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"oldKey",
".",
"equals",
"(",
"key",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"newMap",
"=",
"new",
"FastCopyHashMap",
"<",
"K",
",",
"V",
">",
"(",
"snapshot",
")",
";",
"newMap",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"else",
"{",
"newMap",
"=",
"new",
"FastCopyHashMap",
"<",
"K",
",",
"V",
">",
"(",
"snapshot",
")",
";",
"newMap",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"return",
"updater",
".",
"compareAndSet",
"(",
"instance",
",",
"snapshot",
",",
"newMap",
")",
";",
"}"
] | Put a value if and only if the map has not changed since the given snapshot was taken. If the put fails,
it is the caller's responsibility to retry.
@param instance the instance with the map field
@param key the key
@param value the value
@param snapshot the map snapshot
@return {@code false} if the snapshot is out of date and we could not update, {@code true} if the put succeeded | [
"Put",
"a",
"value",
"if",
"and",
"only",
"if",
"the",
"map",
"has",
"not",
"changed",
"since",
"the",
"given",
"snapshot",
"was",
"taken",
".",
"If",
"the",
"put",
"fails",
"it",
"is",
"the",
"caller",
"s",
"responsibility",
"to",
"retry",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/registry/AtomicMapFieldUpdater.java#L97-L117 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpx/TimeUnitUtility.java | TimeUnitUtility.getInstance | @SuppressWarnings("unchecked") public static TimeUnit getInstance(String units, Locale locale) throws MPXJException {
"""
This method is used to parse a string representation of a time
unit, and return the appropriate constant value.
@param units string representation of a time unit
@param locale target locale
@return numeric constant
@throws MPXJException normally thrown when parsing fails
"""
Map<String, Integer> map = LocaleData.getMap(locale, LocaleData.TIME_UNITS_MAP);
Integer result = map.get(units.toLowerCase());
if (result == null)
{
throw new MPXJException(MPXJException.INVALID_TIME_UNIT + " " + units);
}
return (TimeUnit.getInstance(result.intValue()));
} | java | @SuppressWarnings("unchecked") public static TimeUnit getInstance(String units, Locale locale) throws MPXJException
{
Map<String, Integer> map = LocaleData.getMap(locale, LocaleData.TIME_UNITS_MAP);
Integer result = map.get(units.toLowerCase());
if (result == null)
{
throw new MPXJException(MPXJException.INVALID_TIME_UNIT + " " + units);
}
return (TimeUnit.getInstance(result.intValue()));
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"TimeUnit",
"getInstance",
"(",
"String",
"units",
",",
"Locale",
"locale",
")",
"throws",
"MPXJException",
"{",
"Map",
"<",
"String",
",",
"Integer",
">",
"map",
"=",
"LocaleData",
".",
"getMap",
"(",
"locale",
",",
"LocaleData",
".",
"TIME_UNITS_MAP",
")",
";",
"Integer",
"result",
"=",
"map",
".",
"get",
"(",
"units",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"throw",
"new",
"MPXJException",
"(",
"MPXJException",
".",
"INVALID_TIME_UNIT",
"+",
"\" \"",
"+",
"units",
")",
";",
"}",
"return",
"(",
"TimeUnit",
".",
"getInstance",
"(",
"result",
".",
"intValue",
"(",
")",
")",
")",
";",
"}"
] | This method is used to parse a string representation of a time
unit, and return the appropriate constant value.
@param units string representation of a time unit
@param locale target locale
@return numeric constant
@throws MPXJException normally thrown when parsing fails | [
"This",
"method",
"is",
"used",
"to",
"parse",
"a",
"string",
"representation",
"of",
"a",
"time",
"unit",
"and",
"return",
"the",
"appropriate",
"constant",
"value",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/TimeUnitUtility.java#L55-L64 |
Azure/azure-sdk-for-java | streamanalytics/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/streamanalytics/v2016_03_01/implementation/InputsInner.java | InputsInner.createOrReplaceAsync | public Observable<InputInner> createOrReplaceAsync(String resourceGroupName, String jobName, String inputName, InputInner input, String ifMatch, String ifNoneMatch) {
"""
Creates an input or replaces an already existing input under an existing streaming job.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param jobName The name of the streaming job.
@param inputName The name of the input.
@param input The definition of the input that will be used to create a new input or replace the existing one under the streaming job.
@param ifMatch The ETag of the input. Omit this value to always overwrite the current input. Specify the last-seen ETag value to prevent accidentally overwritting concurrent changes.
@param ifNoneMatch Set to '*' to allow a new input to be created, but to prevent updating an existing input. Other values will result in a 412 Pre-condition Failed response.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the InputInner object
"""
return createOrReplaceWithServiceResponseAsync(resourceGroupName, jobName, inputName, input, ifMatch, ifNoneMatch).map(new Func1<ServiceResponseWithHeaders<InputInner, InputsCreateOrReplaceHeaders>, InputInner>() {
@Override
public InputInner call(ServiceResponseWithHeaders<InputInner, InputsCreateOrReplaceHeaders> response) {
return response.body();
}
});
} | java | public Observable<InputInner> createOrReplaceAsync(String resourceGroupName, String jobName, String inputName, InputInner input, String ifMatch, String ifNoneMatch) {
return createOrReplaceWithServiceResponseAsync(resourceGroupName, jobName, inputName, input, ifMatch, ifNoneMatch).map(new Func1<ServiceResponseWithHeaders<InputInner, InputsCreateOrReplaceHeaders>, InputInner>() {
@Override
public InputInner call(ServiceResponseWithHeaders<InputInner, InputsCreateOrReplaceHeaders> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"InputInner",
">",
"createOrReplaceAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"jobName",
",",
"String",
"inputName",
",",
"InputInner",
"input",
",",
"String",
"ifMatch",
",",
"String",
"ifNoneMatch",
")",
"{",
"return",
"createOrReplaceWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"jobName",
",",
"inputName",
",",
"input",
",",
"ifMatch",
",",
"ifNoneMatch",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponseWithHeaders",
"<",
"InputInner",
",",
"InputsCreateOrReplaceHeaders",
">",
",",
"InputInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"InputInner",
"call",
"(",
"ServiceResponseWithHeaders",
"<",
"InputInner",
",",
"InputsCreateOrReplaceHeaders",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates an input or replaces an already existing input under an existing streaming job.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param jobName The name of the streaming job.
@param inputName The name of the input.
@param input The definition of the input that will be used to create a new input or replace the existing one under the streaming job.
@param ifMatch The ETag of the input. Omit this value to always overwrite the current input. Specify the last-seen ETag value to prevent accidentally overwritting concurrent changes.
@param ifNoneMatch Set to '*' to allow a new input to be created, but to prevent updating an existing input. Other values will result in a 412 Pre-condition Failed response.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the InputInner object | [
"Creates",
"an",
"input",
"or",
"replaces",
"an",
"already",
"existing",
"input",
"under",
"an",
"existing",
"streaming",
"job",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/streamanalytics/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/streamanalytics/v2016_03_01/implementation/InputsInner.java#L247-L254 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/PoissonDistribution.java | PoissonDistribution.rawProbability | public static double rawProbability(double x, double lambda) {
"""
Poisson distribution probability, but also for non-integer arguments.
<p>
lb^x exp(-lb) / x!
@param x X
@param lambda lambda
@return Poisson distribution probability
"""
// Extreme lambda
if(lambda == 0) {
return ((x == 0) ? 1. : 0.);
}
// Extreme values
if(Double.isInfinite(lambda) || x < 0) {
return 0.;
}
if(x <= lambda * Double.MIN_NORMAL) {
return FastMath.exp(-lambda);
}
if(lambda < x * Double.MIN_NORMAL) {
double r = -lambda + x * FastMath.log(lambda) - GammaDistribution.logGamma(x + 1);
return FastMath.exp(r);
}
final double f = MathUtil.TWOPI * x;
final double y = -stirlingError(x) - devianceTerm(x, lambda);
return FastMath.exp(y) / FastMath.sqrt(f);
} | java | public static double rawProbability(double x, double lambda) {
// Extreme lambda
if(lambda == 0) {
return ((x == 0) ? 1. : 0.);
}
// Extreme values
if(Double.isInfinite(lambda) || x < 0) {
return 0.;
}
if(x <= lambda * Double.MIN_NORMAL) {
return FastMath.exp(-lambda);
}
if(lambda < x * Double.MIN_NORMAL) {
double r = -lambda + x * FastMath.log(lambda) - GammaDistribution.logGamma(x + 1);
return FastMath.exp(r);
}
final double f = MathUtil.TWOPI * x;
final double y = -stirlingError(x) - devianceTerm(x, lambda);
return FastMath.exp(y) / FastMath.sqrt(f);
} | [
"public",
"static",
"double",
"rawProbability",
"(",
"double",
"x",
",",
"double",
"lambda",
")",
"{",
"// Extreme lambda",
"if",
"(",
"lambda",
"==",
"0",
")",
"{",
"return",
"(",
"(",
"x",
"==",
"0",
")",
"?",
"1.",
":",
"0.",
")",
";",
"}",
"// Extreme values",
"if",
"(",
"Double",
".",
"isInfinite",
"(",
"lambda",
")",
"||",
"x",
"<",
"0",
")",
"{",
"return",
"0.",
";",
"}",
"if",
"(",
"x",
"<=",
"lambda",
"*",
"Double",
".",
"MIN_NORMAL",
")",
"{",
"return",
"FastMath",
".",
"exp",
"(",
"-",
"lambda",
")",
";",
"}",
"if",
"(",
"lambda",
"<",
"x",
"*",
"Double",
".",
"MIN_NORMAL",
")",
"{",
"double",
"r",
"=",
"-",
"lambda",
"+",
"x",
"*",
"FastMath",
".",
"log",
"(",
"lambda",
")",
"-",
"GammaDistribution",
".",
"logGamma",
"(",
"x",
"+",
"1",
")",
";",
"return",
"FastMath",
".",
"exp",
"(",
"r",
")",
";",
"}",
"final",
"double",
"f",
"=",
"MathUtil",
".",
"TWOPI",
"*",
"x",
";",
"final",
"double",
"y",
"=",
"-",
"stirlingError",
"(",
"x",
")",
"-",
"devianceTerm",
"(",
"x",
",",
"lambda",
")",
";",
"return",
"FastMath",
".",
"exp",
"(",
"y",
")",
"/",
"FastMath",
".",
"sqrt",
"(",
"f",
")",
";",
"}"
] | Poisson distribution probability, but also for non-integer arguments.
<p>
lb^x exp(-lb) / x!
@param x X
@param lambda lambda
@return Poisson distribution probability | [
"Poisson",
"distribution",
"probability",
"but",
"also",
"for",
"non",
"-",
"integer",
"arguments",
".",
"<p",
">",
"lb^x",
"exp",
"(",
"-",
"lb",
")",
"/",
"x!"
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/PoissonDistribution.java#L434-L453 |
aws/aws-sdk-java | aws-java-sdk-signer/src/main/java/com/amazonaws/services/signer/model/DescribeSigningJobResult.java | DescribeSigningJobResult.withSigningParameters | public DescribeSigningJobResult withSigningParameters(java.util.Map<String, String> signingParameters) {
"""
<p>
Map of user-assigned key-value pairs used during signing. These values contain any information that you specified
for use in your signing job.
</p>
@param signingParameters
Map of user-assigned key-value pairs used during signing. These values contain any information that you
specified for use in your signing job.
@return Returns a reference to this object so that method calls can be chained together.
"""
setSigningParameters(signingParameters);
return this;
} | java | public DescribeSigningJobResult withSigningParameters(java.util.Map<String, String> signingParameters) {
setSigningParameters(signingParameters);
return this;
} | [
"public",
"DescribeSigningJobResult",
"withSigningParameters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"signingParameters",
")",
"{",
"setSigningParameters",
"(",
"signingParameters",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Map of user-assigned key-value pairs used during signing. These values contain any information that you specified
for use in your signing job.
</p>
@param signingParameters
Map of user-assigned key-value pairs used during signing. These values contain any information that you
specified for use in your signing job.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Map",
"of",
"user",
"-",
"assigned",
"key",
"-",
"value",
"pairs",
"used",
"during",
"signing",
".",
"These",
"values",
"contain",
"any",
"information",
"that",
"you",
"specified",
"for",
"use",
"in",
"your",
"signing",
"job",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-signer/src/main/java/com/amazonaws/services/signer/model/DescribeSigningJobResult.java#L387-L390 |
r0adkll/Slidr | library/src/main/java/com/r0adkll/slidr/util/ViewDragHelper.java | ViewDragHelper.smoothSlideViewTo | public boolean smoothSlideViewTo(View child, int finalLeft, int finalTop) {
"""
Animate the view <code>child</code> to the given (left, top) position.
If this method returns true, the caller should invoke {@link #continueSettling(boolean)}
on each subsequent frame to continue the motion until it returns false. If this method
returns false there is no further work to do to complete the movement.
<p>
<p>This operation does not count as a capture event, though {@link #getCapturedView()}
will still report the sliding view while the slide is in progress.</p>
@param child Child view to capture and animate
@param finalLeft Final left position of child
@param finalTop Final top position of child
@return true if animation should continue through {@link #continueSettling(boolean)} calls
"""
mCapturedView = child;
mActivePointerId = INVALID_POINTER;
boolean continueSliding = forceSettleCapturedViewAt(finalLeft, finalTop, 0, 0);
if (!continueSliding && mDragState == STATE_IDLE && mCapturedView != null) {
// If we're in an IDLE state to begin with and aren't moving anywhere, we
// end up having a non-null capturedView with an IDLE dragState
mCapturedView = null;
}
return continueSliding;
} | java | public boolean smoothSlideViewTo(View child, int finalLeft, int finalTop) {
mCapturedView = child;
mActivePointerId = INVALID_POINTER;
boolean continueSliding = forceSettleCapturedViewAt(finalLeft, finalTop, 0, 0);
if (!continueSliding && mDragState == STATE_IDLE && mCapturedView != null) {
// If we're in an IDLE state to begin with and aren't moving anywhere, we
// end up having a non-null capturedView with an IDLE dragState
mCapturedView = null;
}
return continueSliding;
} | [
"public",
"boolean",
"smoothSlideViewTo",
"(",
"View",
"child",
",",
"int",
"finalLeft",
",",
"int",
"finalTop",
")",
"{",
"mCapturedView",
"=",
"child",
";",
"mActivePointerId",
"=",
"INVALID_POINTER",
";",
"boolean",
"continueSliding",
"=",
"forceSettleCapturedViewAt",
"(",
"finalLeft",
",",
"finalTop",
",",
"0",
",",
"0",
")",
";",
"if",
"(",
"!",
"continueSliding",
"&&",
"mDragState",
"==",
"STATE_IDLE",
"&&",
"mCapturedView",
"!=",
"null",
")",
"{",
"// If we're in an IDLE state to begin with and aren't moving anywhere, we",
"// end up having a non-null capturedView with an IDLE dragState",
"mCapturedView",
"=",
"null",
";",
"}",
"return",
"continueSliding",
";",
"}"
] | Animate the view <code>child</code> to the given (left, top) position.
If this method returns true, the caller should invoke {@link #continueSettling(boolean)}
on each subsequent frame to continue the motion until it returns false. If this method
returns false there is no further work to do to complete the movement.
<p>
<p>This operation does not count as a capture event, though {@link #getCapturedView()}
will still report the sliding view while the slide is in progress.</p>
@param child Child view to capture and animate
@param finalLeft Final left position of child
@param finalTop Final top position of child
@return true if animation should continue through {@link #continueSettling(boolean)} calls | [
"Animate",
"the",
"view",
"<code",
">",
"child<",
"/",
"code",
">",
"to",
"the",
"given",
"(",
"left",
"top",
")",
"position",
".",
"If",
"this",
"method",
"returns",
"true",
"the",
"caller",
"should",
"invoke",
"{",
"@link",
"#continueSettling",
"(",
"boolean",
")",
"}",
"on",
"each",
"subsequent",
"frame",
"to",
"continue",
"the",
"motion",
"until",
"it",
"returns",
"false",
".",
"If",
"this",
"method",
"returns",
"false",
"there",
"is",
"no",
"further",
"work",
"to",
"do",
"to",
"complete",
"the",
"movement",
".",
"<p",
">",
"<p",
">",
"This",
"operation",
"does",
"not",
"count",
"as",
"a",
"capture",
"event",
"though",
"{",
"@link",
"#getCapturedView",
"()",
"}",
"will",
"still",
"report",
"the",
"sliding",
"view",
"while",
"the",
"slide",
"is",
"in",
"progress",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/r0adkll/Slidr/blob/737db115eb68435764648fbd905b1dea4b52f039/library/src/main/java/com/r0adkll/slidr/util/ViewDragHelper.java#L501-L511 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java | AbstractIndexWriter.addMemberDesc | protected void addMemberDesc(Element member, Content contentTree) {
"""
Add description about the Static Variable/Method/Constructor for a
member.
@param member MemberDoc for the member within the Class Kind
@param contentTree the content tree to which the member description will be added
"""
TypeElement containing = utils.getEnclosingTypeElement(member);
String classdesc = utils.getTypeElementName(containing, true) + " ";
if (utils.isField(member)) {
Content resource = contents.getContent(utils.isStatic(member)
? "doclet.Static_variable_in"
: "doclet.Variable_in", classdesc);
contentTree.addContent(resource);
} else if (utils.isConstructor(member)) {
contentTree.addContent(
contents.getContent("doclet.Constructor_for", classdesc));
} else if (utils.isMethod(member)) {
Content resource = contents.getContent(utils.isStatic(member)
? "doclet.Static_method_in"
: "doclet.Method_in", classdesc);
contentTree.addContent(resource);
}
addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing,
false, contentTree);
} | java | protected void addMemberDesc(Element member, Content contentTree) {
TypeElement containing = utils.getEnclosingTypeElement(member);
String classdesc = utils.getTypeElementName(containing, true) + " ";
if (utils.isField(member)) {
Content resource = contents.getContent(utils.isStatic(member)
? "doclet.Static_variable_in"
: "doclet.Variable_in", classdesc);
contentTree.addContent(resource);
} else if (utils.isConstructor(member)) {
contentTree.addContent(
contents.getContent("doclet.Constructor_for", classdesc));
} else if (utils.isMethod(member)) {
Content resource = contents.getContent(utils.isStatic(member)
? "doclet.Static_method_in"
: "doclet.Method_in", classdesc);
contentTree.addContent(resource);
}
addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing,
false, contentTree);
} | [
"protected",
"void",
"addMemberDesc",
"(",
"Element",
"member",
",",
"Content",
"contentTree",
")",
"{",
"TypeElement",
"containing",
"=",
"utils",
".",
"getEnclosingTypeElement",
"(",
"member",
")",
";",
"String",
"classdesc",
"=",
"utils",
".",
"getTypeElementName",
"(",
"containing",
",",
"true",
")",
"+",
"\" \"",
";",
"if",
"(",
"utils",
".",
"isField",
"(",
"member",
")",
")",
"{",
"Content",
"resource",
"=",
"contents",
".",
"getContent",
"(",
"utils",
".",
"isStatic",
"(",
"member",
")",
"?",
"\"doclet.Static_variable_in\"",
":",
"\"doclet.Variable_in\"",
",",
"classdesc",
")",
";",
"contentTree",
".",
"addContent",
"(",
"resource",
")",
";",
"}",
"else",
"if",
"(",
"utils",
".",
"isConstructor",
"(",
"member",
")",
")",
"{",
"contentTree",
".",
"addContent",
"(",
"contents",
".",
"getContent",
"(",
"\"doclet.Constructor_for\"",
",",
"classdesc",
")",
")",
";",
"}",
"else",
"if",
"(",
"utils",
".",
"isMethod",
"(",
"member",
")",
")",
"{",
"Content",
"resource",
"=",
"contents",
".",
"getContent",
"(",
"utils",
".",
"isStatic",
"(",
"member",
")",
"?",
"\"doclet.Static_method_in\"",
":",
"\"doclet.Method_in\"",
",",
"classdesc",
")",
";",
"contentTree",
".",
"addContent",
"(",
"resource",
")",
";",
"}",
"addPreQualifiedClassLink",
"(",
"LinkInfoImpl",
".",
"Kind",
".",
"INDEX",
",",
"containing",
",",
"false",
",",
"contentTree",
")",
";",
"}"
] | Add description about the Static Variable/Method/Constructor for a
member.
@param member MemberDoc for the member within the Class Kind
@param contentTree the content tree to which the member description will be added | [
"Add",
"description",
"about",
"the",
"Static",
"Variable",
"/",
"Method",
"/",
"Constructor",
"for",
"a",
"member",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java#L395-L414 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java | Hierarchy.isSubtype | public static boolean isSubtype(ReferenceType t, ReferenceType possibleSupertype) throws ClassNotFoundException {
"""
Determine if one reference type is a subtype of another.
@param t
a reference type
@param possibleSupertype
the possible supertype
@return true if t is a subtype of possibleSupertype, false if not
"""
return Global.getAnalysisCache().getDatabase(Subtypes2.class).isSubtype(t, possibleSupertype);
} | java | public static boolean isSubtype(ReferenceType t, ReferenceType possibleSupertype) throws ClassNotFoundException {
return Global.getAnalysisCache().getDatabase(Subtypes2.class).isSubtype(t, possibleSupertype);
} | [
"public",
"static",
"boolean",
"isSubtype",
"(",
"ReferenceType",
"t",
",",
"ReferenceType",
"possibleSupertype",
")",
"throws",
"ClassNotFoundException",
"{",
"return",
"Global",
".",
"getAnalysisCache",
"(",
")",
".",
"getDatabase",
"(",
"Subtypes2",
".",
"class",
")",
".",
"isSubtype",
"(",
"t",
",",
"possibleSupertype",
")",
";",
"}"
] | Determine if one reference type is a subtype of another.
@param t
a reference type
@param possibleSupertype
the possible supertype
@return true if t is a subtype of possibleSupertype, false if not | [
"Determine",
"if",
"one",
"reference",
"type",
"is",
"a",
"subtype",
"of",
"another",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L109-L111 |
pravega/pravega | segmentstore/storage/impl/src/main/java/io/pravega/segmentstore/storage/impl/bookkeeper/LogMetadata.java | LogMetadata.removeEmptyLedgers | LogMetadata removeEmptyLedgers(int skipCountFromEnd) {
"""
Removes LedgerMetadata instances for those Ledgers that are known to be empty.
@param skipCountFromEnd The number of Ledgers to spare, counting from the end of the LedgerMetadata list.
@return A new instance of LogMetadata with the updated ledger list.
"""
val newLedgers = new ArrayList<LedgerMetadata>();
int cutoffIndex = this.ledgers.size() - skipCountFromEnd;
for (int i = 0; i < cutoffIndex; i++) {
LedgerMetadata lm = this.ledgers.get(i);
if (lm.getStatus() != LedgerMetadata.Status.Empty) {
// Not Empty or Unknown: keep it!
newLedgers.add(lm);
}
}
// Add the ones from the end, as instructed.
for (int i = cutoffIndex; i < this.ledgers.size(); i++) {
newLedgers.add(this.ledgers.get(i));
}
return new LogMetadata(this.epoch, this.enabled, Collections.unmodifiableList(newLedgers), this.truncationAddress, this.updateVersion.get());
} | java | LogMetadata removeEmptyLedgers(int skipCountFromEnd) {
val newLedgers = new ArrayList<LedgerMetadata>();
int cutoffIndex = this.ledgers.size() - skipCountFromEnd;
for (int i = 0; i < cutoffIndex; i++) {
LedgerMetadata lm = this.ledgers.get(i);
if (lm.getStatus() != LedgerMetadata.Status.Empty) {
// Not Empty or Unknown: keep it!
newLedgers.add(lm);
}
}
// Add the ones from the end, as instructed.
for (int i = cutoffIndex; i < this.ledgers.size(); i++) {
newLedgers.add(this.ledgers.get(i));
}
return new LogMetadata(this.epoch, this.enabled, Collections.unmodifiableList(newLedgers), this.truncationAddress, this.updateVersion.get());
} | [
"LogMetadata",
"removeEmptyLedgers",
"(",
"int",
"skipCountFromEnd",
")",
"{",
"val",
"newLedgers",
"=",
"new",
"ArrayList",
"<",
"LedgerMetadata",
">",
"(",
")",
";",
"int",
"cutoffIndex",
"=",
"this",
".",
"ledgers",
".",
"size",
"(",
")",
"-",
"skipCountFromEnd",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cutoffIndex",
";",
"i",
"++",
")",
"{",
"LedgerMetadata",
"lm",
"=",
"this",
".",
"ledgers",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"lm",
".",
"getStatus",
"(",
")",
"!=",
"LedgerMetadata",
".",
"Status",
".",
"Empty",
")",
"{",
"// Not Empty or Unknown: keep it!",
"newLedgers",
".",
"add",
"(",
"lm",
")",
";",
"}",
"}",
"// Add the ones from the end, as instructed.",
"for",
"(",
"int",
"i",
"=",
"cutoffIndex",
";",
"i",
"<",
"this",
".",
"ledgers",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"newLedgers",
".",
"add",
"(",
"this",
".",
"ledgers",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"return",
"new",
"LogMetadata",
"(",
"this",
".",
"epoch",
",",
"this",
".",
"enabled",
",",
"Collections",
".",
"unmodifiableList",
"(",
"newLedgers",
")",
",",
"this",
".",
"truncationAddress",
",",
"this",
".",
"updateVersion",
".",
"get",
"(",
")",
")",
";",
"}"
] | Removes LedgerMetadata instances for those Ledgers that are known to be empty.
@param skipCountFromEnd The number of Ledgers to spare, counting from the end of the LedgerMetadata list.
@return A new instance of LogMetadata with the updated ledger list. | [
"Removes",
"LedgerMetadata",
"instances",
"for",
"those",
"Ledgers",
"that",
"are",
"known",
"to",
"be",
"empty",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/storage/impl/src/main/java/io/pravega/segmentstore/storage/impl/bookkeeper/LogMetadata.java#L165-L182 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBScanExpression.java | DynamoDBScanExpression.addFilterCondition | public void addFilterCondition(String attributeName, Condition condition) {
"""
Adds a new filter condition to the current scan filter.
@param attributeName
The name of the attribute on which the specified condition
operates.
@param condition
The condition which describes how the specified attribute is
compared and if a row of data is included in the results
returned by the scan operation.
"""
if ( scanFilter == null )
scanFilter = new HashMap<String, Condition>();
scanFilter.put(attributeName, condition);
} | java | public void addFilterCondition(String attributeName, Condition condition) {
if ( scanFilter == null )
scanFilter = new HashMap<String, Condition>();
scanFilter.put(attributeName, condition);
} | [
"public",
"void",
"addFilterCondition",
"(",
"String",
"attributeName",
",",
"Condition",
"condition",
")",
"{",
"if",
"(",
"scanFilter",
"==",
"null",
")",
"scanFilter",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Condition",
">",
"(",
")",
";",
"scanFilter",
".",
"put",
"(",
"attributeName",
",",
"condition",
")",
";",
"}"
] | Adds a new filter condition to the current scan filter.
@param attributeName
The name of the attribute on which the specified condition
operates.
@param condition
The condition which describes how the specified attribute is
compared and if a row of data is included in the results
returned by the scan operation. | [
"Adds",
"a",
"new",
"filter",
"condition",
"to",
"the",
"current",
"scan",
"filter",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBScanExpression.java#L253-L258 |
jbundle/jbundle | thin/base/db/base/src/main/java/org/jbundle/thin/base/db/KeyAreaInfo.java | KeyAreaInfo.setupKeyBuffer | public void setupKeyBuffer(BaseBuffer destBuffer, int iAreaDesc) {
"""
Set up the key area indicated.
<br />Note: The thin implementation is completely different from the thick implementation
here, the areadesc is ignored and the thin data data area is set up instead.
@param destBuffer (Always ignored for the thin implementation).
@param iAreaDesc (Always ignored for the thin implementation).
"""
int iKeyFields = this.getKeyFields();
m_rgobjTempData = new Object[iKeyFields];
for (int iKeyFieldSeq = Constants.MAIN_KEY_FIELD; iKeyFieldSeq < iKeyFields + Constants.MAIN_KEY_FIELD; iKeyFieldSeq++)
{
m_rgobjTempData[iKeyFieldSeq] = this.getField(iKeyFieldSeq).getData();
}
} | java | public void setupKeyBuffer(BaseBuffer destBuffer, int iAreaDesc)
{
int iKeyFields = this.getKeyFields();
m_rgobjTempData = new Object[iKeyFields];
for (int iKeyFieldSeq = Constants.MAIN_KEY_FIELD; iKeyFieldSeq < iKeyFields + Constants.MAIN_KEY_FIELD; iKeyFieldSeq++)
{
m_rgobjTempData[iKeyFieldSeq] = this.getField(iKeyFieldSeq).getData();
}
} | [
"public",
"void",
"setupKeyBuffer",
"(",
"BaseBuffer",
"destBuffer",
",",
"int",
"iAreaDesc",
")",
"{",
"int",
"iKeyFields",
"=",
"this",
".",
"getKeyFields",
"(",
")",
";",
"m_rgobjTempData",
"=",
"new",
"Object",
"[",
"iKeyFields",
"]",
";",
"for",
"(",
"int",
"iKeyFieldSeq",
"=",
"Constants",
".",
"MAIN_KEY_FIELD",
";",
"iKeyFieldSeq",
"<",
"iKeyFields",
"+",
"Constants",
".",
"MAIN_KEY_FIELD",
";",
"iKeyFieldSeq",
"++",
")",
"{",
"m_rgobjTempData",
"[",
"iKeyFieldSeq",
"]",
"=",
"this",
".",
"getField",
"(",
"iKeyFieldSeq",
")",
".",
"getData",
"(",
")",
";",
"}",
"}"
] | Set up the key area indicated.
<br />Note: The thin implementation is completely different from the thick implementation
here, the areadesc is ignored and the thin data data area is set up instead.
@param destBuffer (Always ignored for the thin implementation).
@param iAreaDesc (Always ignored for the thin implementation). | [
"Set",
"up",
"the",
"key",
"area",
"indicated",
".",
"<br",
"/",
">",
"Note",
":",
"The",
"thin",
"implementation",
"is",
"completely",
"different",
"from",
"the",
"thick",
"implementation",
"here",
"the",
"areadesc",
"is",
"ignored",
"and",
"the",
"thin",
"data",
"data",
"area",
"is",
"set",
"up",
"instead",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/KeyAreaInfo.java#L236-L244 |
base2Services/kagura | shared/reporting-core/src/main/java/com/base2/kagura/core/storage/ReportsProvider.java | ReportsProvider.loadReport | protected boolean loadReport(ReportsConfig result, InputStream report, String reportName) {
"""
Loads a report, this does the deserialization, this method can be substituted with another, called by child
classes. Once it has deserialized it, it put it into the map.
@param result
@param report
@param reportName
@return
"""
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
ReportConfig reportConfig = null;
try {
reportConfig = mapper.readValue(report, ReportConfig.class);
} catch (IOException e) {
e.printStackTrace();
errors.add("Error parsing " + reportName + " " + e.getMessage());
return false;
}
reportConfig.setReportId(reportName);
result.getReports().put(reportName, reportConfig);
return true;
} | java | protected boolean loadReport(ReportsConfig result, InputStream report, String reportName) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
ReportConfig reportConfig = null;
try {
reportConfig = mapper.readValue(report, ReportConfig.class);
} catch (IOException e) {
e.printStackTrace();
errors.add("Error parsing " + reportName + " " + e.getMessage());
return false;
}
reportConfig.setReportId(reportName);
result.getReports().put(reportName, reportConfig);
return true;
} | [
"protected",
"boolean",
"loadReport",
"(",
"ReportsConfig",
"result",
",",
"InputStream",
"report",
",",
"String",
"reportName",
")",
"{",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
"new",
"YAMLFactory",
"(",
")",
")",
";",
"ReportConfig",
"reportConfig",
"=",
"null",
";",
"try",
"{",
"reportConfig",
"=",
"mapper",
".",
"readValue",
"(",
"report",
",",
"ReportConfig",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"errors",
".",
"add",
"(",
"\"Error parsing \"",
"+",
"reportName",
"+",
"\" \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"reportConfig",
".",
"setReportId",
"(",
"reportName",
")",
";",
"result",
".",
"getReports",
"(",
")",
".",
"put",
"(",
"reportName",
",",
"reportConfig",
")",
";",
"return",
"true",
";",
"}"
] | Loads a report, this does the deserialization, this method can be substituted with another, called by child
classes. Once it has deserialized it, it put it into the map.
@param result
@param report
@param reportName
@return | [
"Loads",
"a",
"report",
"this",
"does",
"the",
"deserialization",
"this",
"method",
"can",
"be",
"substituted",
"with",
"another",
"called",
"by",
"child",
"classes",
".",
"Once",
"it",
"has",
"deserialized",
"it",
"it",
"put",
"it",
"into",
"the",
"map",
"."
] | train | https://github.com/base2Services/kagura/blob/5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee/shared/reporting-core/src/main/java/com/base2/kagura/core/storage/ReportsProvider.java#L64-L77 |