repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/lang/reflect/TypeSystem.java | TypeSystem.parseTypeLiteral | public static IType parseTypeLiteral(String typeName) {
"""
Parses a type name such as Iterable<Claim>.
@param typeName the name to parse
@return the type
"""
try {
IType type = GosuParserFactory.createParser(typeName).parseTypeLiteral(null).getType().getType();
if (type instanceof IErrorType) {
throw new RuntimeException("Type not found: " + typeName);
}
return type;
} catch (ParseResultsException e) {
throw new RuntimeException("Type not found: " + typeName, e);
}
} | java | public static IType parseTypeLiteral(String typeName) {
try {
IType type = GosuParserFactory.createParser(typeName).parseTypeLiteral(null).getType().getType();
if (type instanceof IErrorType) {
throw new RuntimeException("Type not found: " + typeName);
}
return type;
} catch (ParseResultsException e) {
throw new RuntimeException("Type not found: " + typeName, e);
}
} | [
"public",
"static",
"IType",
"parseTypeLiteral",
"(",
"String",
"typeName",
")",
"{",
"try",
"{",
"IType",
"type",
"=",
"GosuParserFactory",
".",
"createParser",
"(",
"typeName",
")",
".",
"parseTypeLiteral",
"(",
"null",
")",
".",
"getType",
"(",
")",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
"instanceof",
"IErrorType",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Type not found: \"",
"+",
"typeName",
")",
";",
"}",
"return",
"type",
";",
"}",
"catch",
"(",
"ParseResultsException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Type not found: \"",
"+",
"typeName",
",",
"e",
")",
";",
"}",
"}"
]
| Parses a type name such as Iterable<Claim>.
@param typeName the name to parse
@return the type | [
"Parses",
"a",
"type",
"name",
"such",
"as",
"Iterable<",
";",
"Claim>",
";",
"."
]
| train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/reflect/TypeSystem.java#L709-L719 |
Harium/keel | src/main/java/com/harium/keel/catalano/math/distance/Distance.java | Distance.Euclidean | public static double Euclidean(double x1, double y1, double x2, double y2) {
"""
Gets the Euclidean distance between two points.
@param x1 X1 axis coordinate.
@param y1 Y1 axis coordinate.
@param x2 X2 axis coordinate.
@param y2 Y2 axis coordinate.
@return The Euclidean distance between x and y.
"""
double dx = Math.abs(x1 - x2);
double dy = Math.abs(y1 - y2);
return Math.sqrt(dx * dx + dy * dy);
} | java | public static double Euclidean(double x1, double y1, double x2, double y2) {
double dx = Math.abs(x1 - x2);
double dy = Math.abs(y1 - y2);
return Math.sqrt(dx * dx + dy * dy);
} | [
"public",
"static",
"double",
"Euclidean",
"(",
"double",
"x1",
",",
"double",
"y1",
",",
"double",
"x2",
",",
"double",
"y2",
")",
"{",
"double",
"dx",
"=",
"Math",
".",
"abs",
"(",
"x1",
"-",
"x2",
")",
";",
"double",
"dy",
"=",
"Math",
".",
"abs",
"(",
"y1",
"-",
"y2",
")",
";",
"return",
"Math",
".",
"sqrt",
"(",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
")",
";",
"}"
]
| Gets the Euclidean distance between two points.
@param x1 X1 axis coordinate.
@param y1 Y1 axis coordinate.
@param x2 X2 axis coordinate.
@param y2 Y2 axis coordinate.
@return The Euclidean distance between x and y. | [
"Gets",
"the",
"Euclidean",
"distance",
"between",
"two",
"points",
"."
]
| train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/distance/Distance.java#L387-L392 |
xiancloud/xian | xian-zookeeper/xian-curator/xian-curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/Reaper.java | Reaper.addPath | public void addPath(String path, Mode mode) {
"""
Add a path to be checked by the reaper. The path will be checked periodically
until the reaper is closed, or until the point specified by the Mode
@param path path to check
@param mode reaping mode
"""
PathHolder pathHolder = new PathHolder(path, mode, 0);
activePaths.put(path, pathHolder);
schedule(pathHolder, reapingThresholdMs);
} | java | public void addPath(String path, Mode mode)
{
PathHolder pathHolder = new PathHolder(path, mode, 0);
activePaths.put(path, pathHolder);
schedule(pathHolder, reapingThresholdMs);
} | [
"public",
"void",
"addPath",
"(",
"String",
"path",
",",
"Mode",
"mode",
")",
"{",
"PathHolder",
"pathHolder",
"=",
"new",
"PathHolder",
"(",
"path",
",",
"mode",
",",
"0",
")",
";",
"activePaths",
".",
"put",
"(",
"path",
",",
"pathHolder",
")",
";",
"schedule",
"(",
"pathHolder",
",",
"reapingThresholdMs",
")",
";",
"}"
]
| Add a path to be checked by the reaper. The path will be checked periodically
until the reaper is closed, or until the point specified by the Mode
@param path path to check
@param mode reaping mode | [
"Add",
"a",
"path",
"to",
"be",
"checked",
"by",
"the",
"reaper",
".",
"The",
"path",
"will",
"be",
"checked",
"periodically",
"until",
"the",
"reaper",
"is",
"closed",
"or",
"until",
"the",
"point",
"specified",
"by",
"the",
"Mode"
]
| train | https://github.com/xiancloud/xian/blob/1948e088545553d2745b2c86d8b5a64988bb850e/xian-zookeeper/xian-curator/xian-curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/Reaper.java#L205-L210 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.writeUtf8Lines | public static <T> File writeUtf8Lines(Collection<T> list, File file) throws IORuntimeException {
"""
将列表写入文件,覆盖模式,编码为UTF-8
@param <T> 集合元素类型
@param list 列表
@param file 绝对路径
@return 目标文件
@throws IORuntimeException IO异常
@since 3.2.0
"""
return writeLines(list, file, CharsetUtil.CHARSET_UTF_8);
} | java | public static <T> File writeUtf8Lines(Collection<T> list, File file) throws IORuntimeException {
return writeLines(list, file, CharsetUtil.CHARSET_UTF_8);
} | [
"public",
"static",
"<",
"T",
">",
"File",
"writeUtf8Lines",
"(",
"Collection",
"<",
"T",
">",
"list",
",",
"File",
"file",
")",
"throws",
"IORuntimeException",
"{",
"return",
"writeLines",
"(",
"list",
",",
"file",
",",
"CharsetUtil",
".",
"CHARSET_UTF_8",
")",
";",
"}"
]
| 将列表写入文件,覆盖模式,编码为UTF-8
@param <T> 集合元素类型
@param list 列表
@param file 绝对路径
@return 目标文件
@throws IORuntimeException IO异常
@since 3.2.0 | [
"将列表写入文件,覆盖模式,编码为UTF",
"-",
"8"
]
| train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2867-L2869 |
ops4j/org.ops4j.pax.logging | pax-logging-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java | AbstractLogger.enter | protected EntryMessage enter(final String fqcn, final String format, final Supplier<?>... paramSuppliers) {
"""
Logs entry to a method with location information.
@param fqcn The fully qualified class name of the <b>caller</b>.
@param format Format String for the parameters.
@param paramSuppliers The Suppliers of the parameters.
"""
EntryMessage entryMsg = null;
if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
logMessageSafely(fqcn, Level.TRACE, ENTRY_MARKER, entryMsg = entryMsg(format, paramSuppliers), null);
}
return entryMsg;
} | java | protected EntryMessage enter(final String fqcn, final String format, final Supplier<?>... paramSuppliers) {
EntryMessage entryMsg = null;
if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
logMessageSafely(fqcn, Level.TRACE, ENTRY_MARKER, entryMsg = entryMsg(format, paramSuppliers), null);
}
return entryMsg;
} | [
"protected",
"EntryMessage",
"enter",
"(",
"final",
"String",
"fqcn",
",",
"final",
"String",
"format",
",",
"final",
"Supplier",
"<",
"?",
">",
"...",
"paramSuppliers",
")",
"{",
"EntryMessage",
"entryMsg",
"=",
"null",
";",
"if",
"(",
"isEnabled",
"(",
"Level",
".",
"TRACE",
",",
"ENTRY_MARKER",
",",
"(",
"Object",
")",
"null",
",",
"null",
")",
")",
"{",
"logMessageSafely",
"(",
"fqcn",
",",
"Level",
".",
"TRACE",
",",
"ENTRY_MARKER",
",",
"entryMsg",
"=",
"entryMsg",
"(",
"format",
",",
"paramSuppliers",
")",
",",
"null",
")",
";",
"}",
"return",
"entryMsg",
";",
"}"
]
| Logs entry to a method with location information.
@param fqcn The fully qualified class name of the <b>caller</b>.
@param format Format String for the parameters.
@param paramSuppliers The Suppliers of the parameters. | [
"Logs",
"entry",
"to",
"a",
"method",
"with",
"location",
"information",
"."
]
| train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java#L507-L513 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/collision/MapTileCollisionRendererModel.java | MapTileCollisionRendererModel.createFunctionDraw | private static void createFunctionDraw(Graphic g, CollisionFormula formula, int tw, int th) {
"""
Create the function draw to buffer by computing all possible locations.
@param g The graphic buffer.
@param formula The collision formula.
@param tw The tile width.
@param th The tile height.
"""
for (int x = 0; x < tw; x++)
{
for (int y = 0; y < th; y++)
{
renderCollision(g, formula, th, x, y);
}
}
} | java | private static void createFunctionDraw(Graphic g, CollisionFormula formula, int tw, int th)
{
for (int x = 0; x < tw; x++)
{
for (int y = 0; y < th; y++)
{
renderCollision(g, formula, th, x, y);
}
}
} | [
"private",
"static",
"void",
"createFunctionDraw",
"(",
"Graphic",
"g",
",",
"CollisionFormula",
"formula",
",",
"int",
"tw",
",",
"int",
"th",
")",
"{",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"tw",
";",
"x",
"++",
")",
"{",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"th",
";",
"y",
"++",
")",
"{",
"renderCollision",
"(",
"g",
",",
"formula",
",",
"th",
",",
"x",
",",
"y",
")",
";",
"}",
"}",
"}"
]
| Create the function draw to buffer by computing all possible locations.
@param g The graphic buffer.
@param formula The collision formula.
@param tw The tile width.
@param th The tile height. | [
"Create",
"the",
"function",
"draw",
"to",
"buffer",
"by",
"computing",
"all",
"possible",
"locations",
"."
]
| train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/collision/MapTileCollisionRendererModel.java#L68-L77 |
OpenNTF/JavascriptAggregator | jaggr-core/src/main/java/com/ibm/jaggr/core/impl/resource/FileResource.java | FileResource.recurse | private void recurse(File file, IResourceVisitor visitor, String path)
throws IOException {
"""
Internal method for recursing sub directories.
@param file
The file object
@param visitor
The {@link IResourceVisitor} to call for non-folder resources
@throws IOException
"""
File[] files = file.listFiles();
if (files == null) {
return;
}
for (File child : files) {
String childName = path + (path.length() == 0 ? "" : "/") //$NON-NLS-1$ //$NON-NLS-2$
+ child.getName();
boolean result = visitor.visitResource(new VisitorResource(child,
child.lastModified(), childName), childName);
if (child.isDirectory() && result) {
recurse(child, visitor, childName);
}
}
} | java | private void recurse(File file, IResourceVisitor visitor, String path)
throws IOException {
File[] files = file.listFiles();
if (files == null) {
return;
}
for (File child : files) {
String childName = path + (path.length() == 0 ? "" : "/") //$NON-NLS-1$ //$NON-NLS-2$
+ child.getName();
boolean result = visitor.visitResource(new VisitorResource(child,
child.lastModified(), childName), childName);
if (child.isDirectory() && result) {
recurse(child, visitor, childName);
}
}
} | [
"private",
"void",
"recurse",
"(",
"File",
"file",
",",
"IResourceVisitor",
"visitor",
",",
"String",
"path",
")",
"throws",
"IOException",
"{",
"File",
"[",
"]",
"files",
"=",
"file",
".",
"listFiles",
"(",
")",
";",
"if",
"(",
"files",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"File",
"child",
":",
"files",
")",
"{",
"String",
"childName",
"=",
"path",
"+",
"(",
"path",
".",
"length",
"(",
")",
"==",
"0",
"?",
"\"\"",
":",
"\"/\"",
")",
"//$NON-NLS-1$ //$NON-NLS-2$\r",
"+",
"child",
".",
"getName",
"(",
")",
";",
"boolean",
"result",
"=",
"visitor",
".",
"visitResource",
"(",
"new",
"VisitorResource",
"(",
"child",
",",
"child",
".",
"lastModified",
"(",
")",
",",
"childName",
")",
",",
"childName",
")",
";",
"if",
"(",
"child",
".",
"isDirectory",
"(",
")",
"&&",
"result",
")",
"{",
"recurse",
"(",
"child",
",",
"visitor",
",",
"childName",
")",
";",
"}",
"}",
"}"
]
| Internal method for recursing sub directories.
@param file
The file object
@param visitor
The {@link IResourceVisitor} to call for non-folder resources
@throws IOException | [
"Internal",
"method",
"for",
"recursing",
"sub",
"directories",
"."
]
| train | https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/resource/FileResource.java#L162-L177 |
JOML-CI/JOML | src/org/joml/Quaterniond.java | Quaterniond.lookAlong | public Quaterniond lookAlong(double dirX, double dirY, double dirZ, double upX, double upY, double upZ) {
"""
Apply a rotation to this quaternion that maps the given direction to the positive Z axis.
<p>
Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain
parallel to the plane spanned by the <code>up</code> and <code>dir</code> vectors.
<p>
If <code>Q</code> is <code>this</code> quaternion and <code>R</code> the quaternion representing the
specified rotation, then the new quaternion will be <code>Q * R</code>. So when transforming a
vector <code>v</code> with the new quaternion by using <code>Q * R * v</code>, the
rotation added by this method will be applied first!
<p>
Reference: <a href="http://answers.unity3d.com/questions/467614/what-is-the-source-code-of-quaternionlookrotation.html">http://answers.unity3d.com</a>
@see #lookAlong(double, double, double, double, double, double, Quaterniond)
@param dirX
the x-coordinate of the direction to look along
@param dirY
the y-coordinate of the direction to look along
@param dirZ
the z-coordinate of the direction to look along
@param upX
the x-coordinate of the up vector
@param upY
the y-coordinate of the up vector
@param upZ
the z-coordinate of the up vector
@return this
"""
return lookAlong(dirX, dirY, dirZ, upX, upY, upZ, this);
} | java | public Quaterniond lookAlong(double dirX, double dirY, double dirZ, double upX, double upY, double upZ) {
return lookAlong(dirX, dirY, dirZ, upX, upY, upZ, this);
} | [
"public",
"Quaterniond",
"lookAlong",
"(",
"double",
"dirX",
",",
"double",
"dirY",
",",
"double",
"dirZ",
",",
"double",
"upX",
",",
"double",
"upY",
",",
"double",
"upZ",
")",
"{",
"return",
"lookAlong",
"(",
"dirX",
",",
"dirY",
",",
"dirZ",
",",
"upX",
",",
"upY",
",",
"upZ",
",",
"this",
")",
";",
"}"
]
| Apply a rotation to this quaternion that maps the given direction to the positive Z axis.
<p>
Because there are multiple possibilities for such a rotation, this method will choose the one that ensures the given up direction to remain
parallel to the plane spanned by the <code>up</code> and <code>dir</code> vectors.
<p>
If <code>Q</code> is <code>this</code> quaternion and <code>R</code> the quaternion representing the
specified rotation, then the new quaternion will be <code>Q * R</code>. So when transforming a
vector <code>v</code> with the new quaternion by using <code>Q * R * v</code>, the
rotation added by this method will be applied first!
<p>
Reference: <a href="http://answers.unity3d.com/questions/467614/what-is-the-source-code-of-quaternionlookrotation.html">http://answers.unity3d.com</a>
@see #lookAlong(double, double, double, double, double, double, Quaterniond)
@param dirX
the x-coordinate of the direction to look along
@param dirY
the y-coordinate of the direction to look along
@param dirZ
the z-coordinate of the direction to look along
@param upX
the x-coordinate of the up vector
@param upY
the y-coordinate of the up vector
@param upZ
the z-coordinate of the up vector
@return this | [
"Apply",
"a",
"rotation",
"to",
"this",
"quaternion",
"that",
"maps",
"the",
"given",
"direction",
"to",
"the",
"positive",
"Z",
"axis",
".",
"<p",
">",
"Because",
"there",
"are",
"multiple",
"possibilities",
"for",
"such",
"a",
"rotation",
"this",
"method",
"will",
"choose",
"the",
"one",
"that",
"ensures",
"the",
"given",
"up",
"direction",
"to",
"remain",
"parallel",
"to",
"the",
"plane",
"spanned",
"by",
"the",
"<code",
">",
"up<",
"/",
"code",
">",
"and",
"<code",
">",
"dir<",
"/",
"code",
">",
"vectors",
".",
"<p",
">",
"If",
"<code",
">",
"Q<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"quaternion",
"and",
"<code",
">",
"R<",
"/",
"code",
">",
"the",
"quaternion",
"representing",
"the",
"specified",
"rotation",
"then",
"the",
"new",
"quaternion",
"will",
"be",
"<code",
">",
"Q",
"*",
"R<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"quaternion",
"by",
"using",
"<code",
">",
"Q",
"*",
"R",
"*",
"v<",
"/",
"code",
">",
"the",
"rotation",
"added",
"by",
"this",
"method",
"will",
"be",
"applied",
"first!",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"answers",
".",
"unity3d",
".",
"com",
"/",
"questions",
"/",
"467614",
"/",
"what",
"-",
"is",
"-",
"the",
"-",
"source",
"-",
"code",
"-",
"of",
"-",
"quaternionlookrotation",
".",
"html",
">",
"http",
":",
"//",
"answers",
".",
"unity3d",
".",
"com<",
"/",
"a",
">"
]
| train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Quaterniond.java#L1705-L1707 |
line/armeria | core/src/main/java/com/linecorp/armeria/server/docs/DocServiceBuilder.java | DocServiceBuilder.exampleHttpHeaders | public DocServiceBuilder exampleHttpHeaders(String serviceName,
Iterable<? extends HttpHeaders> exampleHttpHeaders) {
"""
Adds the example {@link HttpHeaders} for the service with the specified name.
"""
requireNonNull(serviceName, "serviceName");
checkArgument(!serviceName.isEmpty(), "serviceName is empty.");
requireNonNull(exampleHttpHeaders, "exampleHttpHeaders");
return exampleHttpHeaders0(serviceName, "", exampleHttpHeaders);
} | java | public DocServiceBuilder exampleHttpHeaders(String serviceName,
Iterable<? extends HttpHeaders> exampleHttpHeaders) {
requireNonNull(serviceName, "serviceName");
checkArgument(!serviceName.isEmpty(), "serviceName is empty.");
requireNonNull(exampleHttpHeaders, "exampleHttpHeaders");
return exampleHttpHeaders0(serviceName, "", exampleHttpHeaders);
} | [
"public",
"DocServiceBuilder",
"exampleHttpHeaders",
"(",
"String",
"serviceName",
",",
"Iterable",
"<",
"?",
"extends",
"HttpHeaders",
">",
"exampleHttpHeaders",
")",
"{",
"requireNonNull",
"(",
"serviceName",
",",
"\"serviceName\"",
")",
";",
"checkArgument",
"(",
"!",
"serviceName",
".",
"isEmpty",
"(",
")",
",",
"\"serviceName is empty.\"",
")",
";",
"requireNonNull",
"(",
"exampleHttpHeaders",
",",
"\"exampleHttpHeaders\"",
")",
";",
"return",
"exampleHttpHeaders0",
"(",
"serviceName",
",",
"\"\"",
",",
"exampleHttpHeaders",
")",
";",
"}"
]
| Adds the example {@link HttpHeaders} for the service with the specified name. | [
"Adds",
"the",
"example",
"{"
]
| train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/docs/DocServiceBuilder.java#L113-L119 |
tvesalainen/lpg | src/main/java/org/vesalainen/grammar/state/DFA.java | DFA.minDepth | public int minDepth() {
"""
Calculates the minimum length of accepted string. For "if|while"
returns 2. For "a*" returns 0.
@return
"""
Map<DFAState<T>,Integer> indexOf = new NumMap<>();
Map<DFAState<T>,Integer> skip = new NumMap<>();
Deque<DFAState<T>> stack = new ArrayDeque<>();
DFAState<T> first = root;
return minDepth(first, indexOf, stack, 0);
} | java | public int minDepth()
{
Map<DFAState<T>,Integer> indexOf = new NumMap<>();
Map<DFAState<T>,Integer> skip = new NumMap<>();
Deque<DFAState<T>> stack = new ArrayDeque<>();
DFAState<T> first = root;
return minDepth(first, indexOf, stack, 0);
} | [
"public",
"int",
"minDepth",
"(",
")",
"{",
"Map",
"<",
"DFAState",
"<",
"T",
">",
",",
"Integer",
">",
"indexOf",
"=",
"new",
"NumMap",
"<>",
"(",
")",
";",
"Map",
"<",
"DFAState",
"<",
"T",
">",
",",
"Integer",
">",
"skip",
"=",
"new",
"NumMap",
"<>",
"(",
")",
";",
"Deque",
"<",
"DFAState",
"<",
"T",
">",
">",
"stack",
"=",
"new",
"ArrayDeque",
"<>",
"(",
")",
";",
"DFAState",
"<",
"T",
">",
"first",
"=",
"root",
";",
"return",
"minDepth",
"(",
"first",
",",
"indexOf",
",",
"stack",
",",
"0",
")",
";",
"}"
]
| Calculates the minimum length of accepted string. For "if|while"
returns 2. For "a*" returns 0.
@return | [
"Calculates",
"the",
"minimum",
"length",
"of",
"accepted",
"string",
".",
"For",
"if|while",
"returns",
"2",
".",
"For",
"a",
"*",
"returns",
"0",
"."
]
| train | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/grammar/state/DFA.java#L247-L254 |
threerings/narya | core/src/main/java/com/threerings/crowd/client/PlaceViewUtil.java | PlaceViewUtil.dispatchDidLeavePlace | public static void dispatchDidLeavePlace (Object root, PlaceObject plobj) {
"""
Dispatches a call to {@link PlaceView#didLeavePlace} to all UI elements in the hierarchy
rooted at the component provided via the <code>root</code> parameter.
@param root the component at which to start traversing the UI hierarchy.
@param plobj the place object that is about to be entered.
"""
// dispatch the call on this component if it implements PlaceView
if (root instanceof PlaceView) {
try {
((PlaceView)root).didLeavePlace(plobj);
} catch (Exception e) {
log.warning("Component choked on didLeavePlace()", "component", root,
"plobj", plobj, e);
}
}
// now traverse all of this component's children
if (root instanceof Container) {
Container cont = (Container)root;
int ccount = cont.getComponentCount();
for (int ii = 0; ii < ccount; ii++) {
dispatchDidLeavePlace(cont.getComponent(ii), plobj);
}
}
} | java | public static void dispatchDidLeavePlace (Object root, PlaceObject plobj)
{
// dispatch the call on this component if it implements PlaceView
if (root instanceof PlaceView) {
try {
((PlaceView)root).didLeavePlace(plobj);
} catch (Exception e) {
log.warning("Component choked on didLeavePlace()", "component", root,
"plobj", plobj, e);
}
}
// now traverse all of this component's children
if (root instanceof Container) {
Container cont = (Container)root;
int ccount = cont.getComponentCount();
for (int ii = 0; ii < ccount; ii++) {
dispatchDidLeavePlace(cont.getComponent(ii), plobj);
}
}
} | [
"public",
"static",
"void",
"dispatchDidLeavePlace",
"(",
"Object",
"root",
",",
"PlaceObject",
"plobj",
")",
"{",
"// dispatch the call on this component if it implements PlaceView",
"if",
"(",
"root",
"instanceof",
"PlaceView",
")",
"{",
"try",
"{",
"(",
"(",
"PlaceView",
")",
"root",
")",
".",
"didLeavePlace",
"(",
"plobj",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"warning",
"(",
"\"Component choked on didLeavePlace()\"",
",",
"\"component\"",
",",
"root",
",",
"\"plobj\"",
",",
"plobj",
",",
"e",
")",
";",
"}",
"}",
"// now traverse all of this component's children",
"if",
"(",
"root",
"instanceof",
"Container",
")",
"{",
"Container",
"cont",
"=",
"(",
"Container",
")",
"root",
";",
"int",
"ccount",
"=",
"cont",
".",
"getComponentCount",
"(",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"ccount",
";",
"ii",
"++",
")",
"{",
"dispatchDidLeavePlace",
"(",
"cont",
".",
"getComponent",
"(",
"ii",
")",
",",
"plobj",
")",
";",
"}",
"}",
"}"
]
| Dispatches a call to {@link PlaceView#didLeavePlace} to all UI elements in the hierarchy
rooted at the component provided via the <code>root</code> parameter.
@param root the component at which to start traversing the UI hierarchy.
@param plobj the place object that is about to be entered. | [
"Dispatches",
"a",
"call",
"to",
"{",
"@link",
"PlaceView#didLeavePlace",
"}",
"to",
"all",
"UI",
"elements",
"in",
"the",
"hierarchy",
"rooted",
"at",
"the",
"component",
"provided",
"via",
"the",
"<code",
">",
"root<",
"/",
"code",
">",
"parameter",
"."
]
| train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/client/PlaceViewUtil.java#L73-L93 |
Mozu/mozu-java | mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/checkouts/OrderItemUrl.java | OrderItemUrl.splitItemUrl | public static MozuUrl splitItemUrl(String checkoutId, String itemId, Integer quantity, String responseFields) {
"""
Get Resource Url for SplitItem
@param checkoutId The unique identifier of the checkout.
@param itemId The unique identifier of the item.
@param quantity The number of cart items in the shopper's active cart.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/commerce/checkouts/{checkoutId}/items/{itemId}/split?quantity={quantity}&responseFields={responseFields}");
formatter.formatUrl("checkoutId", checkoutId);
formatter.formatUrl("itemId", itemId);
formatter.formatUrl("quantity", quantity);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl splitItemUrl(String checkoutId, String itemId, Integer quantity, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/checkouts/{checkoutId}/items/{itemId}/split?quantity={quantity}&responseFields={responseFields}");
formatter.formatUrl("checkoutId", checkoutId);
formatter.formatUrl("itemId", itemId);
formatter.formatUrl("quantity", quantity);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"splitItemUrl",
"(",
"String",
"checkoutId",
",",
"String",
"itemId",
",",
"Integer",
"quantity",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/checkouts/{checkoutId}/items/{itemId}/split?quantity={quantity}&responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"checkoutId\"",
",",
"checkoutId",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"itemId\"",
",",
"itemId",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"quantity\"",
",",
"quantity",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
]
| Get Resource Url for SplitItem
@param checkoutId The unique identifier of the checkout.
@param itemId The unique identifier of the item.
@param quantity The number of cart items in the shopper's active cart.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"SplitItem"
]
| train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/checkouts/OrderItemUrl.java#L24-L32 |
pryzach/midao | midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java | TypeHandlerUtils.convertSqlXml | public static Object convertSqlXml(Object sqlXml, InputStream input) throws SQLException {
"""
Transfers data from InputStream into sql.SQLXML
<p/>
Using default locale. If different locale is required see
{@link #convertSqlXml(Object, String)}
@param sqlXml sql.SQLXML which would be filled
@param input InputStream
@return sql.SQLXML from InputStream
@throws SQLException
"""
return convertSqlXml(sqlXml, toByteArray(input));
} | java | public static Object convertSqlXml(Object sqlXml, InputStream input) throws SQLException {
return convertSqlXml(sqlXml, toByteArray(input));
} | [
"public",
"static",
"Object",
"convertSqlXml",
"(",
"Object",
"sqlXml",
",",
"InputStream",
"input",
")",
"throws",
"SQLException",
"{",
"return",
"convertSqlXml",
"(",
"sqlXml",
",",
"toByteArray",
"(",
"input",
")",
")",
";",
"}"
]
| Transfers data from InputStream into sql.SQLXML
<p/>
Using default locale. If different locale is required see
{@link #convertSqlXml(Object, String)}
@param sqlXml sql.SQLXML which would be filled
@param input InputStream
@return sql.SQLXML from InputStream
@throws SQLException | [
"Transfers",
"data",
"from",
"InputStream",
"into",
"sql",
".",
"SQLXML",
"<p",
"/",
">",
"Using",
"default",
"locale",
".",
"If",
"different",
"locale",
"is",
"required",
"see",
"{",
"@link",
"#convertSqlXml",
"(",
"Object",
"String",
")",
"}"
]
| train | https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java#L377-L379 |
killbilling/recurly-java-library | src/main/java/com/ning/billing/recurly/RecurlyClient.java | RecurlyClient.updateShippingAddress | public ShippingAddress updateShippingAddress(final String accountCode, final long shippingAddressId, ShippingAddress shippingAddress) {
"""
Update an existing shipping address
<p>
@param accountCode recurly account id
@param shippingAddressId the shipping address id to update
@param shippingAddress the shipping address request data
@return the updated shipping address on success
"""
return doPUT(Accounts.ACCOUNTS_RESOURCE + "/" + accountCode + ShippingAddresses.SHIPPING_ADDRESSES_RESOURCE + "/" + shippingAddressId, shippingAddress,
ShippingAddress.class);
} | java | public ShippingAddress updateShippingAddress(final String accountCode, final long shippingAddressId, ShippingAddress shippingAddress) {
return doPUT(Accounts.ACCOUNTS_RESOURCE + "/" + accountCode + ShippingAddresses.SHIPPING_ADDRESSES_RESOURCE + "/" + shippingAddressId, shippingAddress,
ShippingAddress.class);
} | [
"public",
"ShippingAddress",
"updateShippingAddress",
"(",
"final",
"String",
"accountCode",
",",
"final",
"long",
"shippingAddressId",
",",
"ShippingAddress",
"shippingAddress",
")",
"{",
"return",
"doPUT",
"(",
"Accounts",
".",
"ACCOUNTS_RESOURCE",
"+",
"\"/\"",
"+",
"accountCode",
"+",
"ShippingAddresses",
".",
"SHIPPING_ADDRESSES_RESOURCE",
"+",
"\"/\"",
"+",
"shippingAddressId",
",",
"shippingAddress",
",",
"ShippingAddress",
".",
"class",
")",
";",
"}"
]
| Update an existing shipping address
<p>
@param accountCode recurly account id
@param shippingAddressId the shipping address id to update
@param shippingAddress the shipping address request data
@return the updated shipping address on success | [
"Update",
"an",
"existing",
"shipping",
"address",
"<p",
">"
]
| train | https://github.com/killbilling/recurly-java-library/blob/5e05eedd91885a51e1aa8293bd41139d082cf7f4/src/main/java/com/ning/billing/recurly/RecurlyClient.java#L1219-L1222 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-properties/src/main/java/org/xwiki/properties/internal/DefaultBeanDescriptor.java | DefaultBeanDescriptor.extractPropertyDescriptor | protected void extractPropertyDescriptor(java.beans.PropertyDescriptor propertyDescriptor, Object defaultInstance) {
"""
Extract provided properties information and insert it in {@link #parameterDescriptorMap}.
@param propertyDescriptor the JAVA bean property descriptor.
@param defaultInstance the default instance of bean class.
"""
DefaultPropertyDescriptor desc = new DefaultPropertyDescriptor();
Method writeMethod = propertyDescriptor.getWriteMethod();
if (writeMethod != null) {
Method readMethod = propertyDescriptor.getReadMethod();
// is parameter hidden
PropertyHidden parameterHidden = extractPropertyAnnotation(writeMethod, readMethod, PropertyHidden.class);
if (parameterHidden == null) {
// get parameter id
PropertyId propertyId = extractPropertyAnnotation(writeMethod, readMethod, PropertyId.class);
desc.setId(propertyId != null ? propertyId.value() : propertyDescriptor.getName());
// set parameter type
Type propertyType;
if (readMethod != null) {
propertyType = readMethod.getGenericReturnType();
} else {
propertyType = writeMethod.getGenericParameterTypes()[0];
}
desc.setPropertyType(propertyType);
// get parameter display name
PropertyName parameterName = extractPropertyAnnotation(writeMethod, readMethod, PropertyName.class);
desc.setName(parameterName != null ? parameterName.value() : desc.getId());
// get parameter description
PropertyDescription parameterDescription =
extractPropertyAnnotation(writeMethod, readMethod, PropertyDescription.class);
desc.setDescription(parameterDescription != null ? parameterDescription.value() : propertyDescriptor
.getShortDescription());
Map<Class, Annotation> annotations = new HashMap<>();
COMMON_ANNOTATION_CLASSES.forEach(aClass ->
annotations.put(aClass, extractPropertyAnnotation(writeMethod, readMethod, aClass))
);
setCommonProperties(desc, annotations);
if (defaultInstance != null && readMethod != null) {
// get default value
try {
desc.setDefaultValue(readMethod.invoke(defaultInstance));
} catch (Exception e) {
LOGGER.error(MessageFormat.format(
"Failed to get default property value from getter {0} in class {1}",
readMethod.getName(),
this.beanClass), e);
}
}
desc.setWriteMethod(writeMethod);
desc.setReadMethod(readMethod);
this.parameterDescriptorMap.put(desc.getId(), desc);
}
}
} | java | protected void extractPropertyDescriptor(java.beans.PropertyDescriptor propertyDescriptor, Object defaultInstance)
{
DefaultPropertyDescriptor desc = new DefaultPropertyDescriptor();
Method writeMethod = propertyDescriptor.getWriteMethod();
if (writeMethod != null) {
Method readMethod = propertyDescriptor.getReadMethod();
// is parameter hidden
PropertyHidden parameterHidden = extractPropertyAnnotation(writeMethod, readMethod, PropertyHidden.class);
if (parameterHidden == null) {
// get parameter id
PropertyId propertyId = extractPropertyAnnotation(writeMethod, readMethod, PropertyId.class);
desc.setId(propertyId != null ? propertyId.value() : propertyDescriptor.getName());
// set parameter type
Type propertyType;
if (readMethod != null) {
propertyType = readMethod.getGenericReturnType();
} else {
propertyType = writeMethod.getGenericParameterTypes()[0];
}
desc.setPropertyType(propertyType);
// get parameter display name
PropertyName parameterName = extractPropertyAnnotation(writeMethod, readMethod, PropertyName.class);
desc.setName(parameterName != null ? parameterName.value() : desc.getId());
// get parameter description
PropertyDescription parameterDescription =
extractPropertyAnnotation(writeMethod, readMethod, PropertyDescription.class);
desc.setDescription(parameterDescription != null ? parameterDescription.value() : propertyDescriptor
.getShortDescription());
Map<Class, Annotation> annotations = new HashMap<>();
COMMON_ANNOTATION_CLASSES.forEach(aClass ->
annotations.put(aClass, extractPropertyAnnotation(writeMethod, readMethod, aClass))
);
setCommonProperties(desc, annotations);
if (defaultInstance != null && readMethod != null) {
// get default value
try {
desc.setDefaultValue(readMethod.invoke(defaultInstance));
} catch (Exception e) {
LOGGER.error(MessageFormat.format(
"Failed to get default property value from getter {0} in class {1}",
readMethod.getName(),
this.beanClass), e);
}
}
desc.setWriteMethod(writeMethod);
desc.setReadMethod(readMethod);
this.parameterDescriptorMap.put(desc.getId(), desc);
}
}
} | [
"protected",
"void",
"extractPropertyDescriptor",
"(",
"java",
".",
"beans",
".",
"PropertyDescriptor",
"propertyDescriptor",
",",
"Object",
"defaultInstance",
")",
"{",
"DefaultPropertyDescriptor",
"desc",
"=",
"new",
"DefaultPropertyDescriptor",
"(",
")",
";",
"Method",
"writeMethod",
"=",
"propertyDescriptor",
".",
"getWriteMethod",
"(",
")",
";",
"if",
"(",
"writeMethod",
"!=",
"null",
")",
"{",
"Method",
"readMethod",
"=",
"propertyDescriptor",
".",
"getReadMethod",
"(",
")",
";",
"// is parameter hidden",
"PropertyHidden",
"parameterHidden",
"=",
"extractPropertyAnnotation",
"(",
"writeMethod",
",",
"readMethod",
",",
"PropertyHidden",
".",
"class",
")",
";",
"if",
"(",
"parameterHidden",
"==",
"null",
")",
"{",
"// get parameter id",
"PropertyId",
"propertyId",
"=",
"extractPropertyAnnotation",
"(",
"writeMethod",
",",
"readMethod",
",",
"PropertyId",
".",
"class",
")",
";",
"desc",
".",
"setId",
"(",
"propertyId",
"!=",
"null",
"?",
"propertyId",
".",
"value",
"(",
")",
":",
"propertyDescriptor",
".",
"getName",
"(",
")",
")",
";",
"// set parameter type",
"Type",
"propertyType",
";",
"if",
"(",
"readMethod",
"!=",
"null",
")",
"{",
"propertyType",
"=",
"readMethod",
".",
"getGenericReturnType",
"(",
")",
";",
"}",
"else",
"{",
"propertyType",
"=",
"writeMethod",
".",
"getGenericParameterTypes",
"(",
")",
"[",
"0",
"]",
";",
"}",
"desc",
".",
"setPropertyType",
"(",
"propertyType",
")",
";",
"// get parameter display name",
"PropertyName",
"parameterName",
"=",
"extractPropertyAnnotation",
"(",
"writeMethod",
",",
"readMethod",
",",
"PropertyName",
".",
"class",
")",
";",
"desc",
".",
"setName",
"(",
"parameterName",
"!=",
"null",
"?",
"parameterName",
".",
"value",
"(",
")",
":",
"desc",
".",
"getId",
"(",
")",
")",
";",
"// get parameter description",
"PropertyDescription",
"parameterDescription",
"=",
"extractPropertyAnnotation",
"(",
"writeMethod",
",",
"readMethod",
",",
"PropertyDescription",
".",
"class",
")",
";",
"desc",
".",
"setDescription",
"(",
"parameterDescription",
"!=",
"null",
"?",
"parameterDescription",
".",
"value",
"(",
")",
":",
"propertyDescriptor",
".",
"getShortDescription",
"(",
")",
")",
";",
"Map",
"<",
"Class",
",",
"Annotation",
">",
"annotations",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"COMMON_ANNOTATION_CLASSES",
".",
"forEach",
"(",
"aClass",
"->",
"annotations",
".",
"put",
"(",
"aClass",
",",
"extractPropertyAnnotation",
"(",
"writeMethod",
",",
"readMethod",
",",
"aClass",
")",
")",
")",
";",
"setCommonProperties",
"(",
"desc",
",",
"annotations",
")",
";",
"if",
"(",
"defaultInstance",
"!=",
"null",
"&&",
"readMethod",
"!=",
"null",
")",
"{",
"// get default value",
"try",
"{",
"desc",
".",
"setDefaultValue",
"(",
"readMethod",
".",
"invoke",
"(",
"defaultInstance",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Failed to get default property value from getter {0} in class {1}\"",
",",
"readMethod",
".",
"getName",
"(",
")",
",",
"this",
".",
"beanClass",
")",
",",
"e",
")",
";",
"}",
"}",
"desc",
".",
"setWriteMethod",
"(",
"writeMethod",
")",
";",
"desc",
".",
"setReadMethod",
"(",
"readMethod",
")",
";",
"this",
".",
"parameterDescriptorMap",
".",
"put",
"(",
"desc",
".",
"getId",
"(",
")",
",",
"desc",
")",
";",
"}",
"}",
"}"
]
| Extract provided properties information and insert it in {@link #parameterDescriptorMap}.
@param propertyDescriptor the JAVA bean property descriptor.
@param defaultInstance the default instance of bean class. | [
"Extract",
"provided",
"properties",
"information",
"and",
"insert",
"it",
"in",
"{",
"@link",
"#parameterDescriptorMap",
"}",
"."
]
| train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-properties/src/main/java/org/xwiki/properties/internal/DefaultBeanDescriptor.java#L140-L204 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/Encodings.java | Encodings.getWriter | static Writer getWriter(OutputStream output, String encoding)
throws UnsupportedEncodingException {
"""
Returns a writer for the specified encoding based on
an output stream.
<p>
This is not a public API.
@param output The output stream
@param encoding The encoding MIME name, not a Java name for the encoding.
@return A suitable writer
@throws UnsupportedEncodingException There is no convertor
to support this encoding
@xsl.usage internal
"""
for (int i = 0; i < _encodings.length; ++i)
{
if (_encodings[i].name.equalsIgnoreCase(encoding))
{
try
{
String javaName = _encodings[i].javaName;
OutputStreamWriter osw = new OutputStreamWriter(output,javaName);
return osw;
}
catch (java.lang.IllegalArgumentException iae) // java 1.1.8
{
// keep trying
}
catch (UnsupportedEncodingException usee)
{
// keep trying
}
}
}
try
{
return new OutputStreamWriter(output, encoding);
}
catch (java.lang.IllegalArgumentException iae) // java 1.1.8
{
throw new UnsupportedEncodingException(encoding);
}
} | java | static Writer getWriter(OutputStream output, String encoding)
throws UnsupportedEncodingException
{
for (int i = 0; i < _encodings.length; ++i)
{
if (_encodings[i].name.equalsIgnoreCase(encoding))
{
try
{
String javaName = _encodings[i].javaName;
OutputStreamWriter osw = new OutputStreamWriter(output,javaName);
return osw;
}
catch (java.lang.IllegalArgumentException iae) // java 1.1.8
{
// keep trying
}
catch (UnsupportedEncodingException usee)
{
// keep trying
}
}
}
try
{
return new OutputStreamWriter(output, encoding);
}
catch (java.lang.IllegalArgumentException iae) // java 1.1.8
{
throw new UnsupportedEncodingException(encoding);
}
} | [
"static",
"Writer",
"getWriter",
"(",
"OutputStream",
"output",
",",
"String",
"encoding",
")",
"throws",
"UnsupportedEncodingException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"_encodings",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"_encodings",
"[",
"i",
"]",
".",
"name",
".",
"equalsIgnoreCase",
"(",
"encoding",
")",
")",
"{",
"try",
"{",
"String",
"javaName",
"=",
"_encodings",
"[",
"i",
"]",
".",
"javaName",
";",
"OutputStreamWriter",
"osw",
"=",
"new",
"OutputStreamWriter",
"(",
"output",
",",
"javaName",
")",
";",
"return",
"osw",
";",
"}",
"catch",
"(",
"java",
".",
"lang",
".",
"IllegalArgumentException",
"iae",
")",
"// java 1.1.8",
"{",
"// keep trying",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"usee",
")",
"{",
"// keep trying",
"}",
"}",
"}",
"try",
"{",
"return",
"new",
"OutputStreamWriter",
"(",
"output",
",",
"encoding",
")",
";",
"}",
"catch",
"(",
"java",
".",
"lang",
".",
"IllegalArgumentException",
"iae",
")",
"// java 1.1.8",
"{",
"throw",
"new",
"UnsupportedEncodingException",
"(",
"encoding",
")",
";",
"}",
"}"
]
| Returns a writer for the specified encoding based on
an output stream.
<p>
This is not a public API.
@param output The output stream
@param encoding The encoding MIME name, not a Java name for the encoding.
@return A suitable writer
@throws UnsupportedEncodingException There is no convertor
to support this encoding
@xsl.usage internal | [
"Returns",
"a",
"writer",
"for",
"the",
"specified",
"encoding",
"based",
"on",
"an",
"output",
"stream",
".",
"<p",
">",
"This",
"is",
"not",
"a",
"public",
"API",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/Encodings.java#L67-L101 |
alkacon/opencms-core | src/org/opencms/staticexport/CmsLinkManager.java | CmsLinkManager.getPermalink | public String getPermalink(CmsObject cms, String resourceName) {
"""
Returns the perma link for the given resource.<p>
Like
<code>http://site.enterprise.com:8080/permalink/4b65369f-1266-11db-8360-bf0f6fbae1f8.html</code>.<p>
@param cms the cms context
@param resourceName the resource to generate the perma link for
@return the perma link
"""
return getPermalink(cms, resourceName, null);
} | java | public String getPermalink(CmsObject cms, String resourceName) {
return getPermalink(cms, resourceName, null);
} | [
"public",
"String",
"getPermalink",
"(",
"CmsObject",
"cms",
",",
"String",
"resourceName",
")",
"{",
"return",
"getPermalink",
"(",
"cms",
",",
"resourceName",
",",
"null",
")",
";",
"}"
]
| Returns the perma link for the given resource.<p>
Like
<code>http://site.enterprise.com:8080/permalink/4b65369f-1266-11db-8360-bf0f6fbae1f8.html</code>.<p>
@param cms the cms context
@param resourceName the resource to generate the perma link for
@return the perma link | [
"Returns",
"the",
"perma",
"link",
"for",
"the",
"given",
"resource",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsLinkManager.java#L409-L412 |
lets-blade/blade | src/main/java/com/blade/Blade.java | Blade.webSocket | public Blade webSocket(@NonNull String path, @NonNull WebSocketHandler handler) {
"""
Register WebSocket path
@param path websocket path
@param handler websocket handler
@return return blade instance
"""
this.routeMatcher.addWebSocket(path,handler);
return this;
} | java | public Blade webSocket(@NonNull String path, @NonNull WebSocketHandler handler) {
this.routeMatcher.addWebSocket(path,handler);
return this;
} | [
"public",
"Blade",
"webSocket",
"(",
"@",
"NonNull",
"String",
"path",
",",
"@",
"NonNull",
"WebSocketHandler",
"handler",
")",
"{",
"this",
".",
"routeMatcher",
".",
"addWebSocket",
"(",
"path",
",",
"handler",
")",
";",
"return",
"this",
";",
"}"
]
| Register WebSocket path
@param path websocket path
@param handler websocket handler
@return return blade instance | [
"Register",
"WebSocket",
"path"
]
| train | https://github.com/lets-blade/blade/blob/60624ee528be12122c49a9ad1713e336b959e59a/src/main/java/com/blade/Blade.java#L955-L958 |
jcuda/jcusparse | JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java | JCusparse.cusparseShyb2csc | public static int cusparseShyb2csc(
cusparseHandle handle,
cusparseMatDescr descrA,
cusparseHybMat hybA,
Pointer cscSortedVal,
Pointer cscSortedRowInd,
Pointer cscSortedColPtr) {
"""
Description: This routine converts a sparse matrix in HYB storage format
to a sparse matrix in CSC storage format.
"""
return checkResult(cusparseShyb2cscNative(handle, descrA, hybA, cscSortedVal, cscSortedRowInd, cscSortedColPtr));
} | java | public static int cusparseShyb2csc(
cusparseHandle handle,
cusparseMatDescr descrA,
cusparseHybMat hybA,
Pointer cscSortedVal,
Pointer cscSortedRowInd,
Pointer cscSortedColPtr)
{
return checkResult(cusparseShyb2cscNative(handle, descrA, hybA, cscSortedVal, cscSortedRowInd, cscSortedColPtr));
} | [
"public",
"static",
"int",
"cusparseShyb2csc",
"(",
"cusparseHandle",
"handle",
",",
"cusparseMatDescr",
"descrA",
",",
"cusparseHybMat",
"hybA",
",",
"Pointer",
"cscSortedVal",
",",
"Pointer",
"cscSortedRowInd",
",",
"Pointer",
"cscSortedColPtr",
")",
"{",
"return",
"checkResult",
"(",
"cusparseShyb2cscNative",
"(",
"handle",
",",
"descrA",
",",
"hybA",
",",
"cscSortedVal",
",",
"cscSortedRowInd",
",",
"cscSortedColPtr",
")",
")",
";",
"}"
]
| Description: This routine converts a sparse matrix in HYB storage format
to a sparse matrix in CSC storage format. | [
"Description",
":",
"This",
"routine",
"converts",
"a",
"sparse",
"matrix",
"in",
"HYB",
"storage",
"format",
"to",
"a",
"sparse",
"matrix",
"in",
"CSC",
"storage",
"format",
"."
]
| train | https://github.com/jcuda/jcusparse/blob/7687a62a4ef6b76cb91cf7da93d4cf5ade96a791/JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java#L12285-L12294 |
molgenis/molgenis | molgenis-navigator/src/main/java/org/molgenis/navigator/copy/service/RelationTransformer.java | RelationTransformer.transformRefEntities | static void transformRefEntities(EntityType entityType, Map<String, EntityType> newEntityTypes) {
"""
Changes all references of an {@link EntityType} to point to other, new EntityTypes. Does
nothing for references whose IDs are not present in the supplied Map.
@param entityType the EntityType to update
@param newEntityTypes a Map of (old) EntityType IDs and new EntityTypes
"""
if (newEntityTypes.isEmpty()) {
return;
}
stream(entityType.getAtomicAttributes())
.filter(EntityTypeUtils::isReferenceType)
.forEach(attr -> transformRefEntity(attr, newEntityTypes));
} | java | static void transformRefEntities(EntityType entityType, Map<String, EntityType> newEntityTypes) {
if (newEntityTypes.isEmpty()) {
return;
}
stream(entityType.getAtomicAttributes())
.filter(EntityTypeUtils::isReferenceType)
.forEach(attr -> transformRefEntity(attr, newEntityTypes));
} | [
"static",
"void",
"transformRefEntities",
"(",
"EntityType",
"entityType",
",",
"Map",
"<",
"String",
",",
"EntityType",
">",
"newEntityTypes",
")",
"{",
"if",
"(",
"newEntityTypes",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"stream",
"(",
"entityType",
".",
"getAtomicAttributes",
"(",
")",
")",
".",
"filter",
"(",
"EntityTypeUtils",
"::",
"isReferenceType",
")",
".",
"forEach",
"(",
"attr",
"->",
"transformRefEntity",
"(",
"attr",
",",
"newEntityTypes",
")",
")",
";",
"}"
]
| Changes all references of an {@link EntityType} to point to other, new EntityTypes. Does
nothing for references whose IDs are not present in the supplied Map.
@param entityType the EntityType to update
@param newEntityTypes a Map of (old) EntityType IDs and new EntityTypes | [
"Changes",
"all",
"references",
"of",
"an",
"{",
"@link",
"EntityType",
"}",
"to",
"point",
"to",
"other",
"new",
"EntityTypes",
".",
"Does",
"nothing",
"for",
"references",
"whose",
"IDs",
"are",
"not",
"present",
"in",
"the",
"supplied",
"Map",
"."
]
| train | https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-navigator/src/main/java/org/molgenis/navigator/copy/service/RelationTransformer.java#L71-L79 |
VoltDB/voltdb | src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java | SnapshotUtil.getRealPath | public static String getRealPath(SnapshotPathType stype, String path) {
"""
Return path based on type if type is not CL or AUTO return provided path.
"""
if (stype == SnapshotPathType.SNAP_CL) {
return VoltDB.instance().getCommandLogSnapshotPath();
} else if (stype == SnapshotPathType.SNAP_AUTO) {
return VoltDB.instance().getSnapshotPath();
}
return path;
} | java | public static String getRealPath(SnapshotPathType stype, String path) {
if (stype == SnapshotPathType.SNAP_CL) {
return VoltDB.instance().getCommandLogSnapshotPath();
} else if (stype == SnapshotPathType.SNAP_AUTO) {
return VoltDB.instance().getSnapshotPath();
}
return path;
} | [
"public",
"static",
"String",
"getRealPath",
"(",
"SnapshotPathType",
"stype",
",",
"String",
"path",
")",
"{",
"if",
"(",
"stype",
"==",
"SnapshotPathType",
".",
"SNAP_CL",
")",
"{",
"return",
"VoltDB",
".",
"instance",
"(",
")",
".",
"getCommandLogSnapshotPath",
"(",
")",
";",
"}",
"else",
"if",
"(",
"stype",
"==",
"SnapshotPathType",
".",
"SNAP_AUTO",
")",
"{",
"return",
"VoltDB",
".",
"instance",
"(",
")",
".",
"getSnapshotPath",
"(",
")",
";",
"}",
"return",
"path",
";",
"}"
]
| Return path based on type if type is not CL or AUTO return provided path. | [
"Return",
"path",
"based",
"on",
"type",
"if",
"type",
"is",
"not",
"CL",
"or",
"AUTO",
"return",
"provided",
"path",
"."
]
| train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/sysprocs/saverestore/SnapshotUtil.java#L1664-L1671 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/ECKey.java | ECKey.fromPrivateAndPrecalculatedPublic | public static ECKey fromPrivateAndPrecalculatedPublic(byte[] priv, byte[] pub) {
"""
Creates an ECKey that simply trusts the caller to ensure that point is really the result of multiplying the
generator point by the private key. This is used to speed things up when you know you have the right values
already. The compression state of the point will be preserved.
"""
checkNotNull(priv);
checkNotNull(pub);
return new ECKey(new BigInteger(1, priv), CURVE.getCurve().decodePoint(pub));
} | java | public static ECKey fromPrivateAndPrecalculatedPublic(byte[] priv, byte[] pub) {
checkNotNull(priv);
checkNotNull(pub);
return new ECKey(new BigInteger(1, priv), CURVE.getCurve().decodePoint(pub));
} | [
"public",
"static",
"ECKey",
"fromPrivateAndPrecalculatedPublic",
"(",
"byte",
"[",
"]",
"priv",
",",
"byte",
"[",
"]",
"pub",
")",
"{",
"checkNotNull",
"(",
"priv",
")",
";",
"checkNotNull",
"(",
"pub",
")",
";",
"return",
"new",
"ECKey",
"(",
"new",
"BigInteger",
"(",
"1",
",",
"priv",
")",
",",
"CURVE",
".",
"getCurve",
"(",
")",
".",
"decodePoint",
"(",
"pub",
")",
")",
";",
"}"
]
| Creates an ECKey that simply trusts the caller to ensure that point is really the result of multiplying the
generator point by the private key. This is used to speed things up when you know you have the right values
already. The compression state of the point will be preserved. | [
"Creates",
"an",
"ECKey",
"that",
"simply",
"trusts",
"the",
"caller",
"to",
"ensure",
"that",
"point",
"is",
"really",
"the",
"result",
"of",
"multiplying",
"the",
"generator",
"point",
"by",
"the",
"private",
"key",
".",
"This",
"is",
"used",
"to",
"speed",
"things",
"up",
"when",
"you",
"know",
"you",
"have",
"the",
"right",
"values",
"already",
".",
"The",
"compression",
"state",
"of",
"the",
"point",
"will",
"be",
"preserved",
"."
]
| train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/ECKey.java#L292-L296 |
lucee/Lucee | core/src/main/java/lucee/runtime/tag/Search.java | Search.setType | public void setType(String type) throws ApplicationException {
"""
set the value type Specifies the criteria type for the search.
@param type value to set
@throws ApplicationException
"""
if (type == null) return;
type = type.toLowerCase().trim();
if (type.equals("simple")) this.type = SearchCollection.SEARCH_TYPE_SIMPLE;
else if (type.equals("explicit")) this.type = SearchCollection.SEARCH_TYPE_EXPLICIT;
else throw new ApplicationException("attribute type of tag search has an invalid value, valid values are [simple,explicit] now is [" + type + "]");
} | java | public void setType(String type) throws ApplicationException {
if (type == null) return;
type = type.toLowerCase().trim();
if (type.equals("simple")) this.type = SearchCollection.SEARCH_TYPE_SIMPLE;
else if (type.equals("explicit")) this.type = SearchCollection.SEARCH_TYPE_EXPLICIT;
else throw new ApplicationException("attribute type of tag search has an invalid value, valid values are [simple,explicit] now is [" + type + "]");
} | [
"public",
"void",
"setType",
"(",
"String",
"type",
")",
"throws",
"ApplicationException",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"return",
";",
"type",
"=",
"type",
".",
"toLowerCase",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"type",
".",
"equals",
"(",
"\"simple\"",
")",
")",
"this",
".",
"type",
"=",
"SearchCollection",
".",
"SEARCH_TYPE_SIMPLE",
";",
"else",
"if",
"(",
"type",
".",
"equals",
"(",
"\"explicit\"",
")",
")",
"this",
".",
"type",
"=",
"SearchCollection",
".",
"SEARCH_TYPE_EXPLICIT",
";",
"else",
"throw",
"new",
"ApplicationException",
"(",
"\"attribute type of tag search has an invalid value, valid values are [simple,explicit] now is [\"",
"+",
"type",
"+",
"\"]\"",
")",
";",
"}"
]
| set the value type Specifies the criteria type for the search.
@param type value to set
@throws ApplicationException | [
"set",
"the",
"value",
"type",
"Specifies",
"the",
"criteria",
"type",
"for",
"the",
"search",
"."
]
| train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/tag/Search.java#L119-L126 |
michael-rapp/AndroidPreferenceActivity | example/src/main/java/de/mrapp/android/preference/activity/example/MainActivity.java | MainActivity.createPreferenceButtonListener | private OnClickListener createPreferenceButtonListener() {
"""
Creates and returns a listener, which allows to show a default {@link PreferenceActivity}.
@return The listener, which has been created as an instance of the type {@link
OnClickListener}
"""
return new OnClickListener() {
@Override
public void onClick(final View v) {
Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
startActivity(intent);
}
};
} | java | private OnClickListener createPreferenceButtonListener() {
return new OnClickListener() {
@Override
public void onClick(final View v) {
Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
startActivity(intent);
}
};
} | [
"private",
"OnClickListener",
"createPreferenceButtonListener",
"(",
")",
"{",
"return",
"new",
"OnClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"final",
"View",
"v",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"MainActivity",
".",
"this",
",",
"SettingsActivity",
".",
"class",
")",
";",
"startActivity",
"(",
"intent",
")",
";",
"}",
"}",
";",
"}"
]
| Creates and returns a listener, which allows to show a default {@link PreferenceActivity}.
@return The listener, which has been created as an instance of the type {@link
OnClickListener} | [
"Creates",
"and",
"returns",
"a",
"listener",
"which",
"allows",
"to",
"show",
"a",
"default",
"{",
"@link",
"PreferenceActivity",
"}",
"."
]
| train | https://github.com/michael-rapp/AndroidPreferenceActivity/blob/0fcde73815b4b3bf6bcb36acd3d5733e301bbba5/example/src/main/java/de/mrapp/android/preference/activity/example/MainActivity.java#L49-L59 |
JodaOrg/joda-money | src/main/java/org/joda/money/Money.java | Money.plus | public Money plus(BigDecimal amountToAdd, RoundingMode roundingMode) {
"""
Returns a copy of this monetary value with the amount added.
<p>
This adds the specified amount to this monetary amount, returning a new object.
If the amount to add exceeds the scale of the currency, then the
rounding mode will be used to adjust the result.
<p>
This instance is immutable and unaffected by this method.
@param amountToAdd the monetary value to add, not null
@param roundingMode the rounding mode to use, not null
@return the new instance with the input amount added, never null
"""
return with(money.plusRetainScale(amountToAdd, roundingMode));
} | java | public Money plus(BigDecimal amountToAdd, RoundingMode roundingMode) {
return with(money.plusRetainScale(amountToAdd, roundingMode));
} | [
"public",
"Money",
"plus",
"(",
"BigDecimal",
"amountToAdd",
",",
"RoundingMode",
"roundingMode",
")",
"{",
"return",
"with",
"(",
"money",
".",
"plusRetainScale",
"(",
"amountToAdd",
",",
"roundingMode",
")",
")",
";",
"}"
]
| Returns a copy of this monetary value with the amount added.
<p>
This adds the specified amount to this monetary amount, returning a new object.
If the amount to add exceeds the scale of the currency, then the
rounding mode will be used to adjust the result.
<p>
This instance is immutable and unaffected by this method.
@param amountToAdd the monetary value to add, not null
@param roundingMode the rounding mode to use, not null
@return the new instance with the input amount added, never null | [
"Returns",
"a",
"copy",
"of",
"this",
"monetary",
"value",
"with",
"the",
"amount",
"added",
".",
"<p",
">",
"This",
"adds",
"the",
"specified",
"amount",
"to",
"this",
"monetary",
"amount",
"returning",
"a",
"new",
"object",
".",
"If",
"the",
"amount",
"to",
"add",
"exceeds",
"the",
"scale",
"of",
"the",
"currency",
"then",
"the",
"rounding",
"mode",
"will",
"be",
"used",
"to",
"adjust",
"the",
"result",
".",
"<p",
">",
"This",
"instance",
"is",
"immutable",
"and",
"unaffected",
"by",
"this",
"method",
"."
]
| train | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/Money.java#L777-L779 |
Jasig/uPortal | uPortal-api/uPortal-api-internal/src/main/java/org/apereo/portal/portlets/search/PortletRegistryUtil.java | PortletRegistryUtil.matches | public static boolean matches(final String query, final IPortletDefinition portlet) {
"""
Performs a case-insensitive comparison of the user's query against several important fields
from the {@link IPortletDefinition}.
@param query The user's search terms, which seem to be forced lower-case
@param portlet Definition of portlet to check name, title, and description
@return true if the query string is contained in the above 3 attributes; otherwise, false
"""
/*
* The query parameter is coming in lower case always (even when upper
* or mixed case is entered by the user). We really want a case-
* insensitive comparison here anyway; for safety, we will make certain
* it is insensitive.
*/
final String lcQuery = query.toLowerCase();
final boolean titleMatch = portlet.getTitle().toLowerCase().contains(lcQuery);
final boolean nameMatch = portlet.getName().toLowerCase().contains(lcQuery);
final boolean descMatch =
portlet.getDescription() != null
&& portlet.getDescription().toLowerCase().contains(lcQuery);
final boolean fnameMatch = portlet.getFName().toLowerCase().contains(lcQuery);
return titleMatch || nameMatch || descMatch || fnameMatch;
} | java | public static boolean matches(final String query, final IPortletDefinition portlet) {
/*
* The query parameter is coming in lower case always (even when upper
* or mixed case is entered by the user). We really want a case-
* insensitive comparison here anyway; for safety, we will make certain
* it is insensitive.
*/
final String lcQuery = query.toLowerCase();
final boolean titleMatch = portlet.getTitle().toLowerCase().contains(lcQuery);
final boolean nameMatch = portlet.getName().toLowerCase().contains(lcQuery);
final boolean descMatch =
portlet.getDescription() != null
&& portlet.getDescription().toLowerCase().contains(lcQuery);
final boolean fnameMatch = portlet.getFName().toLowerCase().contains(lcQuery);
return titleMatch || nameMatch || descMatch || fnameMatch;
} | [
"public",
"static",
"boolean",
"matches",
"(",
"final",
"String",
"query",
",",
"final",
"IPortletDefinition",
"portlet",
")",
"{",
"/*\n * The query parameter is coming in lower case always (even when upper\n * or mixed case is entered by the user). We really want a case-\n * insensitive comparison here anyway; for safety, we will make certain\n * it is insensitive.\n */",
"final",
"String",
"lcQuery",
"=",
"query",
".",
"toLowerCase",
"(",
")",
";",
"final",
"boolean",
"titleMatch",
"=",
"portlet",
".",
"getTitle",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"contains",
"(",
"lcQuery",
")",
";",
"final",
"boolean",
"nameMatch",
"=",
"portlet",
".",
"getName",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"contains",
"(",
"lcQuery",
")",
";",
"final",
"boolean",
"descMatch",
"=",
"portlet",
".",
"getDescription",
"(",
")",
"!=",
"null",
"&&",
"portlet",
".",
"getDescription",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"contains",
"(",
"lcQuery",
")",
";",
"final",
"boolean",
"fnameMatch",
"=",
"portlet",
".",
"getFName",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"contains",
"(",
"lcQuery",
")",
";",
"return",
"titleMatch",
"||",
"nameMatch",
"||",
"descMatch",
"||",
"fnameMatch",
";",
"}"
]
| Performs a case-insensitive comparison of the user's query against several important fields
from the {@link IPortletDefinition}.
@param query The user's search terms, which seem to be forced lower-case
@param portlet Definition of portlet to check name, title, and description
@return true if the query string is contained in the above 3 attributes; otherwise, false | [
"Performs",
"a",
"case",
"-",
"insensitive",
"comparison",
"of",
"the",
"user",
"s",
"query",
"against",
"several",
"important",
"fields",
"from",
"the",
"{",
"@link",
"IPortletDefinition",
"}",
"."
]
| train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-api/uPortal-api-internal/src/main/java/org/apereo/portal/portlets/search/PortletRegistryUtil.java#L63-L78 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfStamper.java | PdfStamper.addSignature | public PdfFormField addSignature(String name, int page, float llx, float lly, float urx, float ury) {
"""
Adds an empty signature.
@param name the name of the signature
@param page the page number
@param llx lower left x coordinate of the signature's position
@param lly lower left y coordinate of the signature's position
@param urx upper right x coordinate of the signature's position
@param ury upper right y coordinate of the signature's position
@return a signature form field
@since 2.1.4
"""
PdfAcroForm acroForm = stamper.getAcroForm();
PdfFormField signature = PdfFormField.createSignature(stamper);
acroForm.setSignatureParams(signature, name, llx, lly, urx, ury);
acroForm.drawSignatureAppearences(signature, llx, lly, urx, ury);
addAnnotation(signature, page);
return signature;
} | java | public PdfFormField addSignature(String name, int page, float llx, float lly, float urx, float ury) {
PdfAcroForm acroForm = stamper.getAcroForm();
PdfFormField signature = PdfFormField.createSignature(stamper);
acroForm.setSignatureParams(signature, name, llx, lly, urx, ury);
acroForm.drawSignatureAppearences(signature, llx, lly, urx, ury);
addAnnotation(signature, page);
return signature;
} | [
"public",
"PdfFormField",
"addSignature",
"(",
"String",
"name",
",",
"int",
"page",
",",
"float",
"llx",
",",
"float",
"lly",
",",
"float",
"urx",
",",
"float",
"ury",
")",
"{",
"PdfAcroForm",
"acroForm",
"=",
"stamper",
".",
"getAcroForm",
"(",
")",
";",
"PdfFormField",
"signature",
"=",
"PdfFormField",
".",
"createSignature",
"(",
"stamper",
")",
";",
"acroForm",
".",
"setSignatureParams",
"(",
"signature",
",",
"name",
",",
"llx",
",",
"lly",
",",
"urx",
",",
"ury",
")",
";",
"acroForm",
".",
"drawSignatureAppearences",
"(",
"signature",
",",
"llx",
",",
"lly",
",",
"urx",
",",
"ury",
")",
";",
"addAnnotation",
"(",
"signature",
",",
"page",
")",
";",
"return",
"signature",
";",
"}"
]
| Adds an empty signature.
@param name the name of the signature
@param page the page number
@param llx lower left x coordinate of the signature's position
@param lly lower left y coordinate of the signature's position
@param urx upper right x coordinate of the signature's position
@param ury upper right y coordinate of the signature's position
@return a signature form field
@since 2.1.4 | [
"Adds",
"an",
"empty",
"signature",
"."
]
| train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfStamper.java#L434-L441 |
alkacon/opencms-core | src/org/opencms/cmis/CmsCmisUtil.java | CmsCmisUtil.addPropertyString | public static void addPropertyString(
CmsCmisTypeManager typeManager,
PropertiesImpl props,
String typeId,
Set<String> filter,
String id,
String value) {
"""
Adds a string property to a PropertiesImpl.<p>
@param typeManager
@param props the properties
@param typeId the type id
@param filter the property filter string
@param id the property id
@param value the property value
"""
if (!checkAddProperty(typeManager, props, typeId, filter, id)) {
return;
}
PropertyStringImpl result = new PropertyStringImpl(id, value);
result.setQueryName(id);
props.addProperty(result);
} | java | public static void addPropertyString(
CmsCmisTypeManager typeManager,
PropertiesImpl props,
String typeId,
Set<String> filter,
String id,
String value) {
if (!checkAddProperty(typeManager, props, typeId, filter, id)) {
return;
}
PropertyStringImpl result = new PropertyStringImpl(id, value);
result.setQueryName(id);
props.addProperty(result);
} | [
"public",
"static",
"void",
"addPropertyString",
"(",
"CmsCmisTypeManager",
"typeManager",
",",
"PropertiesImpl",
"props",
",",
"String",
"typeId",
",",
"Set",
"<",
"String",
">",
"filter",
",",
"String",
"id",
",",
"String",
"value",
")",
"{",
"if",
"(",
"!",
"checkAddProperty",
"(",
"typeManager",
",",
"props",
",",
"typeId",
",",
"filter",
",",
"id",
")",
")",
"{",
"return",
";",
"}",
"PropertyStringImpl",
"result",
"=",
"new",
"PropertyStringImpl",
"(",
"id",
",",
"value",
")",
";",
"result",
".",
"setQueryName",
"(",
"id",
")",
";",
"props",
".",
"addProperty",
"(",
"result",
")",
";",
"}"
]
| Adds a string property to a PropertiesImpl.<p>
@param typeManager
@param props the properties
@param typeId the type id
@param filter the property filter string
@param id the property id
@param value the property value | [
"Adds",
"a",
"string",
"property",
"to",
"a",
"PropertiesImpl",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/cmis/CmsCmisUtil.java#L346-L360 |
NextFaze/power-adapters | power-adapters/src/main/java/com/nextfaze/poweradapters/binding/AbstractMapper.java | AbstractMapper.hasStableIds | @Override
public boolean hasStableIds() {
"""
By default, if only a single {@link Binder} is present, returns {@link Binder#hasStableIds()}, otherwise returns
{@code false}
"""
Collection<? extends Binder<?, ?>> allBinders = getAllBinders();
if (allBinders.size() == 1) {
// Save an allocation by checking for List first.
if (allBinders instanceof List) {
//noinspection unchecked
return ((List<Binder<?, ?>>) allBinders).get(0).hasStableIds();
}
return allBinders.iterator().next().hasStableIds();
}
// Can't possibly have stable IDs if we have multiple binders.
return false;
} | java | @Override
public boolean hasStableIds() {
Collection<? extends Binder<?, ?>> allBinders = getAllBinders();
if (allBinders.size() == 1) {
// Save an allocation by checking for List first.
if (allBinders instanceof List) {
//noinspection unchecked
return ((List<Binder<?, ?>>) allBinders).get(0).hasStableIds();
}
return allBinders.iterator().next().hasStableIds();
}
// Can't possibly have stable IDs if we have multiple binders.
return false;
} | [
"@",
"Override",
"public",
"boolean",
"hasStableIds",
"(",
")",
"{",
"Collection",
"<",
"?",
"extends",
"Binder",
"<",
"?",
",",
"?",
">",
">",
"allBinders",
"=",
"getAllBinders",
"(",
")",
";",
"if",
"(",
"allBinders",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"// Save an allocation by checking for List first.",
"if",
"(",
"allBinders",
"instanceof",
"List",
")",
"{",
"//noinspection unchecked",
"return",
"(",
"(",
"List",
"<",
"Binder",
"<",
"?",
",",
"?",
">",
">",
")",
"allBinders",
")",
".",
"get",
"(",
"0",
")",
".",
"hasStableIds",
"(",
")",
";",
"}",
"return",
"allBinders",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
".",
"hasStableIds",
"(",
")",
";",
"}",
"// Can't possibly have stable IDs if we have multiple binders.",
"return",
"false",
";",
"}"
]
| By default, if only a single {@link Binder} is present, returns {@link Binder#hasStableIds()}, otherwise returns
{@code false} | [
"By",
"default",
"if",
"only",
"a",
"single",
"{"
]
| train | https://github.com/NextFaze/power-adapters/blob/cdf00b1b723ed9d6bcd549ae9741a19dd59651e1/power-adapters/src/main/java/com/nextfaze/poweradapters/binding/AbstractMapper.java#L12-L25 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Vector.java | Vector.indexOf | public synchronized int indexOf(Object o, int index) {
"""
Returns the index of the first occurrence of the specified element in
this vector, searching forwards from {@code index}, or returns -1 if
the element is not found.
More formally, returns the lowest index {@code i} such that
<tt>(i >= index && (o==null ? get(i)==null : o.equals(get(i))))</tt>,
or -1 if there is no such index.
@param o element to search for
@param index index to start searching from
@return the index of the first occurrence of the element in
this vector at position {@code index} or later in the vector;
{@code -1} if the element is not found.
@throws IndexOutOfBoundsException if the specified index is negative
@see Object#equals(Object)
"""
if (o == null) {
for (int i = index ; i < elementCount ; i++)
if (elementData[i]==null)
return i;
} else {
for (int i = index ; i < elementCount ; i++)
if (o.equals(elementData[i]))
return i;
}
return -1;
} | java | public synchronized int indexOf(Object o, int index) {
if (o == null) {
for (int i = index ; i < elementCount ; i++)
if (elementData[i]==null)
return i;
} else {
for (int i = index ; i < elementCount ; i++)
if (o.equals(elementData[i]))
return i;
}
return -1;
} | [
"public",
"synchronized",
"int",
"indexOf",
"(",
"Object",
"o",
",",
"int",
"index",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"index",
";",
"i",
"<",
"elementCount",
";",
"i",
"++",
")",
"if",
"(",
"elementData",
"[",
"i",
"]",
"==",
"null",
")",
"return",
"i",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"index",
";",
"i",
"<",
"elementCount",
";",
"i",
"++",
")",
"if",
"(",
"o",
".",
"equals",
"(",
"elementData",
"[",
"i",
"]",
")",
")",
"return",
"i",
";",
"}",
"return",
"-",
"1",
";",
"}"
]
| Returns the index of the first occurrence of the specified element in
this vector, searching forwards from {@code index}, or returns -1 if
the element is not found.
More formally, returns the lowest index {@code i} such that
<tt>(i >= index && (o==null ? get(i)==null : o.equals(get(i))))</tt>,
or -1 if there is no such index.
@param o element to search for
@param index index to start searching from
@return the index of the first occurrence of the element in
this vector at position {@code index} or later in the vector;
{@code -1} if the element is not found.
@throws IndexOutOfBoundsException if the specified index is negative
@see Object#equals(Object) | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"of",
"the",
"specified",
"element",
"in",
"this",
"vector",
"searching",
"forwards",
"from",
"{",
"@code",
"index",
"}",
"or",
"returns",
"-",
"1",
"if",
"the",
"element",
"is",
"not",
"found",
".",
"More",
"formally",
"returns",
"the",
"lowest",
"index",
"{",
"@code",
"i",
"}",
"such",
"that",
"<tt",
">",
"(",
"i ",
";",
">",
";",
"=",
" ",
";",
"index ",
";",
"&",
";",
"&",
";",
" ",
";",
"(",
"o",
"==",
"null ",
";",
"? ",
";",
"get",
"(",
"i",
")",
"==",
"null ",
";",
":",
" ",
";",
"o",
".",
"equals",
"(",
"get",
"(",
"i",
"))))",
"<",
"/",
"tt",
">",
"or",
"-",
"1",
"if",
"there",
"is",
"no",
"such",
"index",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Vector.java#L401-L412 |
phax/ph-oton | ph-oton-uicore/src/main/java/com/helger/photon/uicore/html/swf/HCSWFObject.java | HCSWFObject.addObjectParam | @Nonnull
public final HCSWFObject addObjectParam (@Nonnull final String sName, final String sValue) {
"""
Add a <code>param</code> tag to the created <code>object</code> tag
@param sName
Parameter name
@param sValue
Parameter value
@return this
"""
if (!JSMarshaller.isJSIdentifier (sName))
throw new IllegalArgumentException ("The name '" + sName + "' is not a legal JS identifier!");
if (m_aObjectParams == null)
m_aObjectParams = new CommonsLinkedHashMap <> ();
m_aObjectParams.put (sName, sValue);
return this;
} | java | @Nonnull
public final HCSWFObject addObjectParam (@Nonnull final String sName, final String sValue)
{
if (!JSMarshaller.isJSIdentifier (sName))
throw new IllegalArgumentException ("The name '" + sName + "' is not a legal JS identifier!");
if (m_aObjectParams == null)
m_aObjectParams = new CommonsLinkedHashMap <> ();
m_aObjectParams.put (sName, sValue);
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"HCSWFObject",
"addObjectParam",
"(",
"@",
"Nonnull",
"final",
"String",
"sName",
",",
"final",
"String",
"sValue",
")",
"{",
"if",
"(",
"!",
"JSMarshaller",
".",
"isJSIdentifier",
"(",
"sName",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The name '\"",
"+",
"sName",
"+",
"\"' is not a legal JS identifier!\"",
")",
";",
"if",
"(",
"m_aObjectParams",
"==",
"null",
")",
"m_aObjectParams",
"=",
"new",
"CommonsLinkedHashMap",
"<>",
"(",
")",
";",
"m_aObjectParams",
".",
"put",
"(",
"sName",
",",
"sValue",
")",
";",
"return",
"this",
";",
"}"
]
| Add a <code>param</code> tag to the created <code>object</code> tag
@param sName
Parameter name
@param sValue
Parameter value
@return this | [
"Add",
"a",
"<code",
">",
"param<",
"/",
"code",
">",
"tag",
"to",
"the",
"created",
"<code",
">",
"object<",
"/",
"code",
">",
"tag"
]
| train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uicore/src/main/java/com/helger/photon/uicore/html/swf/HCSWFObject.java#L204-L214 |
mgormley/pacaya | src/main/java/edu/jhu/pacaya/gm/inf/CachingBpSchedule.java | CachingBpSchedule.isConstantMsg | public static boolean isConstantMsg(int edge, FactorGraph fg) {
"""
Returns true iff the edge corresponds to a message which is constant (i.e. sent from a leaf
node).
"""
BipartiteGraph<Var,Factor> bg = fg.getBipgraph();
int numNbs = bg.isT1T2(edge) ? bg.numNbsT1(bg.parentE(edge)) : bg.numNbsT2(bg.parentE(edge));
return numNbs == 1;
} | java | public static boolean isConstantMsg(int edge, FactorGraph fg) {
BipartiteGraph<Var,Factor> bg = fg.getBipgraph();
int numNbs = bg.isT1T2(edge) ? bg.numNbsT1(bg.parentE(edge)) : bg.numNbsT2(bg.parentE(edge));
return numNbs == 1;
} | [
"public",
"static",
"boolean",
"isConstantMsg",
"(",
"int",
"edge",
",",
"FactorGraph",
"fg",
")",
"{",
"BipartiteGraph",
"<",
"Var",
",",
"Factor",
">",
"bg",
"=",
"fg",
".",
"getBipgraph",
"(",
")",
";",
"int",
"numNbs",
"=",
"bg",
".",
"isT1T2",
"(",
"edge",
")",
"?",
"bg",
".",
"numNbsT1",
"(",
"bg",
".",
"parentE",
"(",
"edge",
")",
")",
":",
"bg",
".",
"numNbsT2",
"(",
"bg",
".",
"parentE",
"(",
"edge",
")",
")",
";",
"return",
"numNbs",
"==",
"1",
";",
"}"
]
| Returns true iff the edge corresponds to a message which is constant (i.e. sent from a leaf
node). | [
"Returns",
"true",
"iff",
"the",
"edge",
"corresponds",
"to",
"a",
"message",
"which",
"is",
"constant",
"(",
"i",
".",
"e",
".",
"sent",
"from",
"a",
"leaf",
"node",
")",
"."
]
| train | https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/inf/CachingBpSchedule.java#L102-L106 |
GoogleCloudPlatform/appengine-mapreduce | java/src/main/java/com/google/appengine/tools/mapreduce/impl/sort/SortWorker.java | SortWorker.writePointer | private void writePointer(int index, ByteBuffer pointer) {
"""
Write the provided pointer at the specified index.
(Assumes limit on buffer is correctly set)
(Position of the buffer changed)
"""
int limit = memoryBuffer.limit();
int pos = memoryBuffer.position();
int pointerOffset = computePointerOffset(index);
memoryBuffer.limit(pointerOffset + POINTER_SIZE_BYTES);
memoryBuffer.position(pointerOffset);
memoryBuffer.put(pointer);
memoryBuffer.limit(limit);
memoryBuffer.position(pos);
} | java | private void writePointer(int index, ByteBuffer pointer) {
int limit = memoryBuffer.limit();
int pos = memoryBuffer.position();
int pointerOffset = computePointerOffset(index);
memoryBuffer.limit(pointerOffset + POINTER_SIZE_BYTES);
memoryBuffer.position(pointerOffset);
memoryBuffer.put(pointer);
memoryBuffer.limit(limit);
memoryBuffer.position(pos);
} | [
"private",
"void",
"writePointer",
"(",
"int",
"index",
",",
"ByteBuffer",
"pointer",
")",
"{",
"int",
"limit",
"=",
"memoryBuffer",
".",
"limit",
"(",
")",
";",
"int",
"pos",
"=",
"memoryBuffer",
".",
"position",
"(",
")",
";",
"int",
"pointerOffset",
"=",
"computePointerOffset",
"(",
"index",
")",
";",
"memoryBuffer",
".",
"limit",
"(",
"pointerOffset",
"+",
"POINTER_SIZE_BYTES",
")",
";",
"memoryBuffer",
".",
"position",
"(",
"pointerOffset",
")",
";",
"memoryBuffer",
".",
"put",
"(",
"pointer",
")",
";",
"memoryBuffer",
".",
"limit",
"(",
"limit",
")",
";",
"memoryBuffer",
".",
"position",
"(",
"pos",
")",
";",
"}"
]
| Write the provided pointer at the specified index.
(Assumes limit on buffer is correctly set)
(Position of the buffer changed) | [
"Write",
"the",
"provided",
"pointer",
"at",
"the",
"specified",
"index",
".",
"(",
"Assumes",
"limit",
"on",
"buffer",
"is",
"correctly",
"set",
")",
"(",
"Position",
"of",
"the",
"buffer",
"changed",
")"
]
| train | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/java/src/main/java/com/google/appengine/tools/mapreduce/impl/sort/SortWorker.java#L307-L316 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/net/NetUtils.java | NetUtils.getConnectAddress | public static InetSocketAddress getConnectAddress(Server server) {
"""
Returns InetSocketAddress that a client can use to
connect to the server. Server.getListenerAddress() is not correct when
the server binds to "0.0.0.0". This returns "127.0.0.1:port" when
the getListenerAddress() returns "0.0.0.0:port".
@param server
@return socket address that a client can use to connect to the server.
"""
InetSocketAddress addr = server.getListenerAddress();
if (addr.getAddress().getHostAddress().equals("0.0.0.0")) {
addr = new InetSocketAddress("127.0.0.1", addr.getPort());
}
return addr;
} | java | public static InetSocketAddress getConnectAddress(Server server) {
InetSocketAddress addr = server.getListenerAddress();
if (addr.getAddress().getHostAddress().equals("0.0.0.0")) {
addr = new InetSocketAddress("127.0.0.1", addr.getPort());
}
return addr;
} | [
"public",
"static",
"InetSocketAddress",
"getConnectAddress",
"(",
"Server",
"server",
")",
"{",
"InetSocketAddress",
"addr",
"=",
"server",
".",
"getListenerAddress",
"(",
")",
";",
"if",
"(",
"addr",
".",
"getAddress",
"(",
")",
".",
"getHostAddress",
"(",
")",
".",
"equals",
"(",
"\"0.0.0.0\"",
")",
")",
"{",
"addr",
"=",
"new",
"InetSocketAddress",
"(",
"\"127.0.0.1\"",
",",
"addr",
".",
"getPort",
"(",
")",
")",
";",
"}",
"return",
"addr",
";",
"}"
]
| Returns InetSocketAddress that a client can use to
connect to the server. Server.getListenerAddress() is not correct when
the server binds to "0.0.0.0". This returns "127.0.0.1:port" when
the getListenerAddress() returns "0.0.0.0:port".
@param server
@return socket address that a client can use to connect to the server. | [
"Returns",
"InetSocketAddress",
"that",
"a",
"client",
"can",
"use",
"to",
"connect",
"to",
"the",
"server",
".",
"Server",
".",
"getListenerAddress",
"()",
"is",
"not",
"correct",
"when",
"the",
"server",
"binds",
"to",
"0",
".",
"0",
".",
"0",
".",
"0",
".",
"This",
"returns",
"127",
".",
"0",
".",
"0",
".",
"1",
":",
"port",
"when",
"the",
"getListenerAddress",
"()",
"returns",
"0",
".",
"0",
".",
"0",
".",
"0",
":",
"port",
"."
]
| train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/net/NetUtils.java#L287-L293 |
OpenBEL/openbel-framework | org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/beldata/namespace/NamespaceHeaderParser.java | NamespaceHeaderParser.parseNamespace | public NamespaceHeader parseNamespace(String resourceLocation,
File namespaceFile) throws IOException,
BELDataMissingPropertyException,
BELDataConversionException {
"""
Parses the namespace {@link File} into a {@link NamespaceHeader} object.
@param namespaceFile {@link File}, the namespace file, which cannot be
null, must exist, and must be readable
@return {@link NamespaceHeader}, the parsed namespace header
@throws IOException Thrown if an IO error occurred reading the
<tt>namespaceFile</tt>
@throws BELDataConversionException
@throws BELDataMissingPropertyException
@throws InvalidArgument Thrown if the <tt>namespaceFile</tt> is null,
does not exist, or cannot be read
"""
if (namespaceFile == null) {
throw new InvalidArgument("namespaceFile", namespaceFile);
}
if (!namespaceFile.exists()) {
throw new InvalidArgument("namespaceFile does not exist");
}
if (!namespaceFile.canRead()) {
throw new InvalidArgument("namespaceFile cannot be read");
}
Map<String, Properties> blockProperties = parse(namespaceFile);
NamespaceBlock nsblock = NamespaceBlock.create(resourceLocation,
blockProperties.get(NamespaceBlock.BLOCK_NAME));
AuthorBlock authorblock = AuthorBlock.create(resourceLocation,
blockProperties.get(AuthorBlock.BLOCK_NAME));
CitationBlock citationBlock = CitationBlock.create(resourceLocation,
blockProperties.get(CitationBlock.BLOCK_NAME));
ProcessingBlock processingBlock = ProcessingBlock.create(
resourceLocation,
blockProperties.get(ProcessingBlock.BLOCK_NAME));
return new NamespaceHeader(nsblock, authorblock, citationBlock,
processingBlock);
} | java | public NamespaceHeader parseNamespace(String resourceLocation,
File namespaceFile) throws IOException,
BELDataMissingPropertyException,
BELDataConversionException {
if (namespaceFile == null) {
throw new InvalidArgument("namespaceFile", namespaceFile);
}
if (!namespaceFile.exists()) {
throw new InvalidArgument("namespaceFile does not exist");
}
if (!namespaceFile.canRead()) {
throw new InvalidArgument("namespaceFile cannot be read");
}
Map<String, Properties> blockProperties = parse(namespaceFile);
NamespaceBlock nsblock = NamespaceBlock.create(resourceLocation,
blockProperties.get(NamespaceBlock.BLOCK_NAME));
AuthorBlock authorblock = AuthorBlock.create(resourceLocation,
blockProperties.get(AuthorBlock.BLOCK_NAME));
CitationBlock citationBlock = CitationBlock.create(resourceLocation,
blockProperties.get(CitationBlock.BLOCK_NAME));
ProcessingBlock processingBlock = ProcessingBlock.create(
resourceLocation,
blockProperties.get(ProcessingBlock.BLOCK_NAME));
return new NamespaceHeader(nsblock, authorblock, citationBlock,
processingBlock);
} | [
"public",
"NamespaceHeader",
"parseNamespace",
"(",
"String",
"resourceLocation",
",",
"File",
"namespaceFile",
")",
"throws",
"IOException",
",",
"BELDataMissingPropertyException",
",",
"BELDataConversionException",
"{",
"if",
"(",
"namespaceFile",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"namespaceFile\"",
",",
"namespaceFile",
")",
";",
"}",
"if",
"(",
"!",
"namespaceFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"namespaceFile does not exist\"",
")",
";",
"}",
"if",
"(",
"!",
"namespaceFile",
".",
"canRead",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"namespaceFile cannot be read\"",
")",
";",
"}",
"Map",
"<",
"String",
",",
"Properties",
">",
"blockProperties",
"=",
"parse",
"(",
"namespaceFile",
")",
";",
"NamespaceBlock",
"nsblock",
"=",
"NamespaceBlock",
".",
"create",
"(",
"resourceLocation",
",",
"blockProperties",
".",
"get",
"(",
"NamespaceBlock",
".",
"BLOCK_NAME",
")",
")",
";",
"AuthorBlock",
"authorblock",
"=",
"AuthorBlock",
".",
"create",
"(",
"resourceLocation",
",",
"blockProperties",
".",
"get",
"(",
"AuthorBlock",
".",
"BLOCK_NAME",
")",
")",
";",
"CitationBlock",
"citationBlock",
"=",
"CitationBlock",
".",
"create",
"(",
"resourceLocation",
",",
"blockProperties",
".",
"get",
"(",
"CitationBlock",
".",
"BLOCK_NAME",
")",
")",
";",
"ProcessingBlock",
"processingBlock",
"=",
"ProcessingBlock",
".",
"create",
"(",
"resourceLocation",
",",
"blockProperties",
".",
"get",
"(",
"ProcessingBlock",
".",
"BLOCK_NAME",
")",
")",
";",
"return",
"new",
"NamespaceHeader",
"(",
"nsblock",
",",
"authorblock",
",",
"citationBlock",
",",
"processingBlock",
")",
";",
"}"
]
| Parses the namespace {@link File} into a {@link NamespaceHeader} object.
@param namespaceFile {@link File}, the namespace file, which cannot be
null, must exist, and must be readable
@return {@link NamespaceHeader}, the parsed namespace header
@throws IOException Thrown if an IO error occurred reading the
<tt>namespaceFile</tt>
@throws BELDataConversionException
@throws BELDataMissingPropertyException
@throws InvalidArgument Thrown if the <tt>namespaceFile</tt> is null,
does not exist, or cannot be read | [
"Parses",
"the",
"namespace",
"{",
"@link",
"File",
"}",
"into",
"a",
"{",
"@link",
"NamespaceHeader",
"}",
"object",
"."
]
| train | https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/beldata/namespace/NamespaceHeaderParser.java#L72-L105 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/ShakeAroundAPI.java | ShakeAroundAPI.deviceApplyId | public static DeviceApplyIdResult deviceApplyId(String accessToken,
DeviceApplyId deviceApplyId) {
"""
设备管理-申请设备ID
@param accessToken accessToken
@param deviceApplyId deviceApplyId
@return result
"""
return deviceApplyId(accessToken, JsonUtil.toJSONString(deviceApplyId));
} | java | public static DeviceApplyIdResult deviceApplyId(String accessToken,
DeviceApplyId deviceApplyId) {
return deviceApplyId(accessToken, JsonUtil.toJSONString(deviceApplyId));
} | [
"public",
"static",
"DeviceApplyIdResult",
"deviceApplyId",
"(",
"String",
"accessToken",
",",
"DeviceApplyId",
"deviceApplyId",
")",
"{",
"return",
"deviceApplyId",
"(",
"accessToken",
",",
"JsonUtil",
".",
"toJSONString",
"(",
"deviceApplyId",
")",
")",
";",
"}"
]
| 设备管理-申请设备ID
@param accessToken accessToken
@param deviceApplyId deviceApplyId
@return result | [
"设备管理-申请设备ID"
]
| train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/ShakeAroundAPI.java#L144-L147 |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGUtil.java | SVGUtil.elementCoordinatesFromEvent | public static SVGPoint elementCoordinatesFromEvent(Document doc, Element tag, Event evt) {
"""
Convert the coordinates of an DOM Event from screen into element
coordinates.
@param doc Document context
@param tag Element containing the coordinate system
@param evt Event to interpret
@return coordinates
"""
try {
DOMMouseEvent gnme = (DOMMouseEvent) evt;
SVGMatrix mat = ((SVGLocatable) tag).getScreenCTM();
SVGMatrix imat = mat.inverse();
SVGPoint cPt = ((SVGDocument) doc).getRootElement().createSVGPoint();
cPt.setX(gnme.getClientX());
cPt.setY(gnme.getClientY());
return cPt.matrixTransform(imat);
}
catch(Exception e) {
LoggingUtil.warning("Error getting coordinates from SVG event.", e);
return null;
}
} | java | public static SVGPoint elementCoordinatesFromEvent(Document doc, Element tag, Event evt) {
try {
DOMMouseEvent gnme = (DOMMouseEvent) evt;
SVGMatrix mat = ((SVGLocatable) tag).getScreenCTM();
SVGMatrix imat = mat.inverse();
SVGPoint cPt = ((SVGDocument) doc).getRootElement().createSVGPoint();
cPt.setX(gnme.getClientX());
cPt.setY(gnme.getClientY());
return cPt.matrixTransform(imat);
}
catch(Exception e) {
LoggingUtil.warning("Error getting coordinates from SVG event.", e);
return null;
}
} | [
"public",
"static",
"SVGPoint",
"elementCoordinatesFromEvent",
"(",
"Document",
"doc",
",",
"Element",
"tag",
",",
"Event",
"evt",
")",
"{",
"try",
"{",
"DOMMouseEvent",
"gnme",
"=",
"(",
"DOMMouseEvent",
")",
"evt",
";",
"SVGMatrix",
"mat",
"=",
"(",
"(",
"SVGLocatable",
")",
"tag",
")",
".",
"getScreenCTM",
"(",
")",
";",
"SVGMatrix",
"imat",
"=",
"mat",
".",
"inverse",
"(",
")",
";",
"SVGPoint",
"cPt",
"=",
"(",
"(",
"SVGDocument",
")",
"doc",
")",
".",
"getRootElement",
"(",
")",
".",
"createSVGPoint",
"(",
")",
";",
"cPt",
".",
"setX",
"(",
"gnme",
".",
"getClientX",
"(",
")",
")",
";",
"cPt",
".",
"setY",
"(",
"gnme",
".",
"getClientY",
"(",
")",
")",
";",
"return",
"cPt",
".",
"matrixTransform",
"(",
"imat",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LoggingUtil",
".",
"warning",
"(",
"\"Error getting coordinates from SVG event.\"",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
]
| Convert the coordinates of an DOM Event from screen into element
coordinates.
@param doc Document context
@param tag Element containing the coordinate system
@param evt Event to interpret
@return coordinates | [
"Convert",
"the",
"coordinates",
"of",
"an",
"DOM",
"Event",
"from",
"screen",
"into",
"element",
"coordinates",
"."
]
| train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGUtil.java#L627-L641 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLReadServiceContext.java | SSLReadServiceContext.doHandshake | private SSLEngineResult doHandshake(boolean async) throws IOException {
"""
When data is read, there is always the change the a renegotiation will take place. If so,
this method will be called. Note, it is used by both the sync and async writes.
@param async
@return result of the handshake
@throws IOException
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "doHandshake");
}
SSLEngineResult sslResult;
// Line up all the buffers needed for the SSL handshake. Temporary so
// use indirect allocation for speed.
int appSize = getConnLink().getAppBufferSize();
int packetSize = getConnLink().getPacketBufferSize();
WsByteBuffer localNetBuffer = SSLUtils.allocateByteBuffer(packetSize, true);
WsByteBuffer decryptedNetBuffer = SSLUtils.allocateByteBuffer(appSize, false);
WsByteBuffer encryptedAppBuffer = SSLUtils.allocateByteBuffer(packetSize, true);
// Callback to be used if the request is async.
MyHandshakeCompletedCallback handshakeCallback = null;
if (async) {
handshakeCallback = new MyHandshakeCompletedCallback(this, callback, localNetBuffer, decryptedNetBuffer, encryptedAppBuffer);
}
try {
// Do the SSL handshake. Note, if synchronous the handshakeCallback is null.
sslResult = SSLUtils.handleHandshake(
getConnLink(),
localNetBuffer,
decryptedNetBuffer,
encryptedAppBuffer,
null,
handshakeCallback,
false);
} catch (IOException e) {
// Release buffers used in the handshake.
localNetBuffer.release();
localNetBuffer = null;
decryptedNetBuffer.release();
decryptedNetBuffer = null;
encryptedAppBuffer.release();
encryptedAppBuffer = null;
throw e;
}
if (sslResult != null) {
// Handshake was done synchronously.
// Release buffers used in the handshake.
localNetBuffer.release();
localNetBuffer = null;
decryptedNetBuffer.release();
decryptedNetBuffer = null;
encryptedAppBuffer.release();
encryptedAppBuffer = null;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "doHandshake");
}
return sslResult;
} | java | private SSLEngineResult doHandshake(boolean async) throws IOException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "doHandshake");
}
SSLEngineResult sslResult;
// Line up all the buffers needed for the SSL handshake. Temporary so
// use indirect allocation for speed.
int appSize = getConnLink().getAppBufferSize();
int packetSize = getConnLink().getPacketBufferSize();
WsByteBuffer localNetBuffer = SSLUtils.allocateByteBuffer(packetSize, true);
WsByteBuffer decryptedNetBuffer = SSLUtils.allocateByteBuffer(appSize, false);
WsByteBuffer encryptedAppBuffer = SSLUtils.allocateByteBuffer(packetSize, true);
// Callback to be used if the request is async.
MyHandshakeCompletedCallback handshakeCallback = null;
if (async) {
handshakeCallback = new MyHandshakeCompletedCallback(this, callback, localNetBuffer, decryptedNetBuffer, encryptedAppBuffer);
}
try {
// Do the SSL handshake. Note, if synchronous the handshakeCallback is null.
sslResult = SSLUtils.handleHandshake(
getConnLink(),
localNetBuffer,
decryptedNetBuffer,
encryptedAppBuffer,
null,
handshakeCallback,
false);
} catch (IOException e) {
// Release buffers used in the handshake.
localNetBuffer.release();
localNetBuffer = null;
decryptedNetBuffer.release();
decryptedNetBuffer = null;
encryptedAppBuffer.release();
encryptedAppBuffer = null;
throw e;
}
if (sslResult != null) {
// Handshake was done synchronously.
// Release buffers used in the handshake.
localNetBuffer.release();
localNetBuffer = null;
decryptedNetBuffer.release();
decryptedNetBuffer = null;
encryptedAppBuffer.release();
encryptedAppBuffer = null;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "doHandshake");
}
return sslResult;
} | [
"private",
"SSLEngineResult",
"doHandshake",
"(",
"boolean",
"async",
")",
"throws",
"IOException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"doHandshake\"",
")",
";",
"}",
"SSLEngineResult",
"sslResult",
";",
"// Line up all the buffers needed for the SSL handshake. Temporary so",
"// use indirect allocation for speed.",
"int",
"appSize",
"=",
"getConnLink",
"(",
")",
".",
"getAppBufferSize",
"(",
")",
";",
"int",
"packetSize",
"=",
"getConnLink",
"(",
")",
".",
"getPacketBufferSize",
"(",
")",
";",
"WsByteBuffer",
"localNetBuffer",
"=",
"SSLUtils",
".",
"allocateByteBuffer",
"(",
"packetSize",
",",
"true",
")",
";",
"WsByteBuffer",
"decryptedNetBuffer",
"=",
"SSLUtils",
".",
"allocateByteBuffer",
"(",
"appSize",
",",
"false",
")",
";",
"WsByteBuffer",
"encryptedAppBuffer",
"=",
"SSLUtils",
".",
"allocateByteBuffer",
"(",
"packetSize",
",",
"true",
")",
";",
"// Callback to be used if the request is async.",
"MyHandshakeCompletedCallback",
"handshakeCallback",
"=",
"null",
";",
"if",
"(",
"async",
")",
"{",
"handshakeCallback",
"=",
"new",
"MyHandshakeCompletedCallback",
"(",
"this",
",",
"callback",
",",
"localNetBuffer",
",",
"decryptedNetBuffer",
",",
"encryptedAppBuffer",
")",
";",
"}",
"try",
"{",
"// Do the SSL handshake. Note, if synchronous the handshakeCallback is null.",
"sslResult",
"=",
"SSLUtils",
".",
"handleHandshake",
"(",
"getConnLink",
"(",
")",
",",
"localNetBuffer",
",",
"decryptedNetBuffer",
",",
"encryptedAppBuffer",
",",
"null",
",",
"handshakeCallback",
",",
"false",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// Release buffers used in the handshake.",
"localNetBuffer",
".",
"release",
"(",
")",
";",
"localNetBuffer",
"=",
"null",
";",
"decryptedNetBuffer",
".",
"release",
"(",
")",
";",
"decryptedNetBuffer",
"=",
"null",
";",
"encryptedAppBuffer",
".",
"release",
"(",
")",
";",
"encryptedAppBuffer",
"=",
"null",
";",
"throw",
"e",
";",
"}",
"if",
"(",
"sslResult",
"!=",
"null",
")",
"{",
"// Handshake was done synchronously.",
"// Release buffers used in the handshake.",
"localNetBuffer",
".",
"release",
"(",
")",
";",
"localNetBuffer",
"=",
"null",
";",
"decryptedNetBuffer",
".",
"release",
"(",
")",
";",
"decryptedNetBuffer",
"=",
"null",
";",
"encryptedAppBuffer",
".",
"release",
"(",
")",
";",
"encryptedAppBuffer",
"=",
"null",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"doHandshake\"",
")",
";",
"}",
"return",
"sslResult",
";",
"}"
]
| When data is read, there is always the change the a renegotiation will take place. If so,
this method will be called. Note, it is used by both the sync and async writes.
@param async
@return result of the handshake
@throws IOException | [
"When",
"data",
"is",
"read",
"there",
"is",
"always",
"the",
"change",
"the",
"a",
"renegotiation",
"will",
"take",
"place",
".",
"If",
"so",
"this",
"method",
"will",
"be",
"called",
".",
"Note",
"it",
"is",
"used",
"by",
"both",
"the",
"sync",
"and",
"async",
"writes",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLReadServiceContext.java#L1489-L1543 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java | DateTimeFormatterBuilder.appendTwoDigitYear | public DateTimeFormatterBuilder appendTwoDigitYear(int pivot, boolean lenientParse) {
"""
Instructs the printer to emit a numeric year field which always prints
two digits. A pivot year is used during parsing to determine the range
of supported years as <code>(pivot - 50) .. (pivot + 49)</code>. If
parse is instructed to be lenient and the digit count is not two, it is
treated as an absolute year. With lenient parsing, specifying a positive
or negative sign before the year also makes it absolute.
@param pivot pivot year to use when parsing
@param lenientParse when true, if digit count is not two, it is treated
as an absolute year
@return this DateTimeFormatterBuilder, for chaining
@since 1.1
"""
return append0(new TwoDigitYear(DateTimeFieldType.year(), pivot, lenientParse));
} | java | public DateTimeFormatterBuilder appendTwoDigitYear(int pivot, boolean lenientParse) {
return append0(new TwoDigitYear(DateTimeFieldType.year(), pivot, lenientParse));
} | [
"public",
"DateTimeFormatterBuilder",
"appendTwoDigitYear",
"(",
"int",
"pivot",
",",
"boolean",
"lenientParse",
")",
"{",
"return",
"append0",
"(",
"new",
"TwoDigitYear",
"(",
"DateTimeFieldType",
".",
"year",
"(",
")",
",",
"pivot",
",",
"lenientParse",
")",
")",
";",
"}"
]
| Instructs the printer to emit a numeric year field which always prints
two digits. A pivot year is used during parsing to determine the range
of supported years as <code>(pivot - 50) .. (pivot + 49)</code>. If
parse is instructed to be lenient and the digit count is not two, it is
treated as an absolute year. With lenient parsing, specifying a positive
or negative sign before the year also makes it absolute.
@param pivot pivot year to use when parsing
@param lenientParse when true, if digit count is not two, it is treated
as an absolute year
@return this DateTimeFormatterBuilder, for chaining
@since 1.1 | [
"Instructs",
"the",
"printer",
"to",
"emit",
"a",
"numeric",
"year",
"field",
"which",
"always",
"prints",
"two",
"digits",
".",
"A",
"pivot",
"year",
"is",
"used",
"during",
"parsing",
"to",
"determine",
"the",
"range",
"of",
"supported",
"years",
"as",
"<code",
">",
"(",
"pivot",
"-",
"50",
")",
"..",
"(",
"pivot",
"+",
"49",
")",
"<",
"/",
"code",
">",
".",
"If",
"parse",
"is",
"instructed",
"to",
"be",
"lenient",
"and",
"the",
"digit",
"count",
"is",
"not",
"two",
"it",
"is",
"treated",
"as",
"an",
"absolute",
"year",
".",
"With",
"lenient",
"parsing",
"specifying",
"a",
"positive",
"or",
"negative",
"sign",
"before",
"the",
"year",
"also",
"makes",
"it",
"absolute",
"."
]
| train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java#L869-L871 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerCommunicationLinksInner.java | ServerCommunicationLinksInner.get | public ServerCommunicationLinkInner get(String resourceGroupName, String serverName, String communicationLinkName) {
"""
Returns a server communication link.
@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 serverName The name of the server.
@param communicationLinkName The name of the server communication link.
@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 ServerCommunicationLinkInner object if successful.
"""
return getWithServiceResponseAsync(resourceGroupName, serverName, communicationLinkName).toBlocking().single().body();
} | java | public ServerCommunicationLinkInner get(String resourceGroupName, String serverName, String communicationLinkName) {
return getWithServiceResponseAsync(resourceGroupName, serverName, communicationLinkName).toBlocking().single().body();
} | [
"public",
"ServerCommunicationLinkInner",
"get",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"communicationLinkName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"communicationLinkName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
]
| Returns a server communication link.
@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 serverName The name of the server.
@param communicationLinkName The name of the server communication link.
@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 ServerCommunicationLinkInner object if successful. | [
"Returns",
"a",
"server",
"communication",
"link",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerCommunicationLinksInner.java#L183-L185 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/IssuesApi.java | IssuesApi.resetSpentTime | public TimeStats resetSpentTime(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
"""
Resets the total spent time for this issue to 0 seconds.
<pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/reset_spent_time</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param issueIid the internal ID of a project's issue
@return a TimeSTats instance
@throws GitLabApiException if any exception occurs
"""
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
Response response = post(Response.Status.OK, new GitLabApiForm().asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "reset_spent_time");
return (response.readEntity(TimeStats.class));
} | java | public TimeStats resetSpentTime(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
Response response = post(Response.Status.OK, new GitLabApiForm().asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "reset_spent_time");
return (response.readEntity(TimeStats.class));
} | [
"public",
"TimeStats",
"resetSpentTime",
"(",
"Object",
"projectIdOrPath",
",",
"Integer",
"issueIid",
")",
"throws",
"GitLabApiException",
"{",
"if",
"(",
"issueIid",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"issue IID cannot be null\"",
")",
";",
"}",
"Response",
"response",
"=",
"post",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"new",
"GitLabApiForm",
"(",
")",
".",
"asMap",
"(",
")",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"issues\"",
",",
"issueIid",
",",
"\"reset_spent_time\"",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"TimeStats",
".",
"class",
")",
")",
";",
"}"
]
| Resets the total spent time for this issue to 0 seconds.
<pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/reset_spent_time</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param issueIid the internal ID of a project's issue
@return a TimeSTats instance
@throws GitLabApiException if any exception occurs | [
"Resets",
"the",
"total",
"spent",
"time",
"for",
"this",
"issue",
"to",
"0",
"seconds",
"."
]
| train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/IssuesApi.java#L591-L600 |
OpenTSDB/opentsdb | src/tools/OpenTSDBMain.java | OpenTSDBMain.applyCommandLine | protected static void applyCommandLine(ConfigArgP cap, ArgP argp) {
"""
Applies and processes the pre-tsd command line
@param cap The main configuration wrapper
@param argp The preped command line argument handler
"""
// --config, --include-config, --help
if(argp.has("--help")) {
if(cap.hasNonOption("extended")) {
System.out.println(cap.getExtendedUsage("tsd extended usage:"));
} else {
System.out.println(cap.getDefaultUsage("tsd usage:"));
}
System.exit(0);
}
if(argp.has("--config")) {
loadConfigSource(cap, argp.get("--config").trim());
}
if(argp.has("--include")) {
String[] sources = argp.get("--include").split(",");
for(String s: sources) {
loadConfigSource(cap, s.trim());
}
}
} | java | protected static void applyCommandLine(ConfigArgP cap, ArgP argp) {
// --config, --include-config, --help
if(argp.has("--help")) {
if(cap.hasNonOption("extended")) {
System.out.println(cap.getExtendedUsage("tsd extended usage:"));
} else {
System.out.println(cap.getDefaultUsage("tsd usage:"));
}
System.exit(0);
}
if(argp.has("--config")) {
loadConfigSource(cap, argp.get("--config").trim());
}
if(argp.has("--include")) {
String[] sources = argp.get("--include").split(",");
for(String s: sources) {
loadConfigSource(cap, s.trim());
}
}
} | [
"protected",
"static",
"void",
"applyCommandLine",
"(",
"ConfigArgP",
"cap",
",",
"ArgP",
"argp",
")",
"{",
"// --config, --include-config, --help",
"if",
"(",
"argp",
".",
"has",
"(",
"\"--help\"",
")",
")",
"{",
"if",
"(",
"cap",
".",
"hasNonOption",
"(",
"\"extended\"",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"cap",
".",
"getExtendedUsage",
"(",
"\"tsd extended usage:\"",
")",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"cap",
".",
"getDefaultUsage",
"(",
"\"tsd usage:\"",
")",
")",
";",
"}",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}",
"if",
"(",
"argp",
".",
"has",
"(",
"\"--config\"",
")",
")",
"{",
"loadConfigSource",
"(",
"cap",
",",
"argp",
".",
"get",
"(",
"\"--config\"",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"if",
"(",
"argp",
".",
"has",
"(",
"\"--include\"",
")",
")",
"{",
"String",
"[",
"]",
"sources",
"=",
"argp",
".",
"get",
"(",
"\"--include\"",
")",
".",
"split",
"(",
"\",\"",
")",
";",
"for",
"(",
"String",
"s",
":",
"sources",
")",
"{",
"loadConfigSource",
"(",
"cap",
",",
"s",
".",
"trim",
"(",
")",
")",
";",
"}",
"}",
"}"
]
| Applies and processes the pre-tsd command line
@param cap The main configuration wrapper
@param argp The preped command line argument handler | [
"Applies",
"and",
"processes",
"the",
"pre",
"-",
"tsd",
"command",
"line"
]
| train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/OpenTSDBMain.java#L181-L200 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/Assert.java | Assert.messageFormat | private static String messageFormat(String message, Object... arguments) {
"""
Formats the specified {@link String message} containing possible placeholders as defined by {@link MessageFormat}.
@param message {@link String} containing the message to format.
@param arguments array of {@link Object arguments} used when formatting the {@link String message}.
@return the {@link String message} formatted with the {@link Object arguments}.
@see java.text.MessageFormat#format(String, Object...)
"""
return (arguments == null ? message : MessageFormat.format(message, arguments));
} | java | private static String messageFormat(String message, Object... arguments) {
return (arguments == null ? message : MessageFormat.format(message, arguments));
} | [
"private",
"static",
"String",
"messageFormat",
"(",
"String",
"message",
",",
"Object",
"...",
"arguments",
")",
"{",
"return",
"(",
"arguments",
"==",
"null",
"?",
"message",
":",
"MessageFormat",
".",
"format",
"(",
"message",
",",
"arguments",
")",
")",
";",
"}"
]
| Formats the specified {@link String message} containing possible placeholders as defined by {@link MessageFormat}.
@param message {@link String} containing the message to format.
@param arguments array of {@link Object arguments} used when formatting the {@link String message}.
@return the {@link String message} formatted with the {@link Object arguments}.
@see java.text.MessageFormat#format(String, Object...) | [
"Formats",
"the",
"specified",
"{",
"@link",
"String",
"message",
"}",
"containing",
"possible",
"placeholders",
"as",
"defined",
"by",
"{",
"@link",
"MessageFormat",
"}",
"."
]
| train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/Assert.java#L1507-L1509 |
icode/ameba | src/main/java/ameba/core/Requests.java | Requests.evaluatePreconditions | public static Response.ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag) {
"""
<p>evaluatePreconditions.</p>
@param lastModified a {@link java.util.Date} object.
@param eTag a {@link javax.ws.rs.core.EntityTag} object.
@return a {@link javax.ws.rs.core.Response.ResponseBuilder} object.
"""
return getRequest().evaluatePreconditions(lastModified, eTag);
} | java | public static Response.ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag) {
return getRequest().evaluatePreconditions(lastModified, eTag);
} | [
"public",
"static",
"Response",
".",
"ResponseBuilder",
"evaluatePreconditions",
"(",
"Date",
"lastModified",
",",
"EntityTag",
"eTag",
")",
"{",
"return",
"getRequest",
"(",
")",
".",
"evaluatePreconditions",
"(",
"lastModified",
",",
"eTag",
")",
";",
"}"
]
| <p>evaluatePreconditions.</p>
@param lastModified a {@link java.util.Date} object.
@param eTag a {@link javax.ws.rs.core.EntityTag} object.
@return a {@link javax.ws.rs.core.Response.ResponseBuilder} object. | [
"<p",
">",
"evaluatePreconditions",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/core/Requests.java#L740-L742 |
alkacon/opencms-core | src-gwt/org/opencms/acacia/client/CmsEditorBase.java | CmsEditorBase.renderEntityForm | public void renderEntityForm(String entityId, List<CmsTabInfo> tabInfos, Panel context, Element scrollParent) {
"""
Renders the entity form within the given context.<p>
@param entityId the entity id
@param tabInfos the tab informations
@param context the context element
@param scrollParent the scroll element to be used for automatic scrolling during drag and drop
"""
CmsEntity entity = m_entityBackend.getEntity(entityId);
if (entity != null) {
boolean initUndo = (m_entity == null) || !entity.getId().equals(m_entity.getId());
m_entity = entity;
CmsType type = m_entityBackend.getType(m_entity.getTypeName());
m_formPanel = new FlowPanel();
context.add(m_formPanel);
CmsAttributeHandler.setScrollElement(scrollParent);
CmsButtonBarHandler.INSTANCE.setWidgetService(m_widgetService);
if (m_rootHandler == null) {
m_rootHandler = new CmsRootHandler();
} else {
m_rootHandler.clearHandlers();
}
m_tabInfos = tabInfos;
m_formTabs = m_widgetService.getRendererForType(
type).renderForm(m_entity, m_tabInfos, m_formPanel, m_rootHandler, 0);
m_validationHandler.registerEntity(m_entity);
m_validationHandler.setRootHandler(m_rootHandler);
m_validationHandler.setFormTabPanel(m_formTabs);
if (initUndo) {
CmsUndoRedoHandler.getInstance().initialize(m_entity, this, m_rootHandler);
}
// trigger validation right away
m_validationHandler.validate(m_entity);
}
} | java | public void renderEntityForm(String entityId, List<CmsTabInfo> tabInfos, Panel context, Element scrollParent) {
CmsEntity entity = m_entityBackend.getEntity(entityId);
if (entity != null) {
boolean initUndo = (m_entity == null) || !entity.getId().equals(m_entity.getId());
m_entity = entity;
CmsType type = m_entityBackend.getType(m_entity.getTypeName());
m_formPanel = new FlowPanel();
context.add(m_formPanel);
CmsAttributeHandler.setScrollElement(scrollParent);
CmsButtonBarHandler.INSTANCE.setWidgetService(m_widgetService);
if (m_rootHandler == null) {
m_rootHandler = new CmsRootHandler();
} else {
m_rootHandler.clearHandlers();
}
m_tabInfos = tabInfos;
m_formTabs = m_widgetService.getRendererForType(
type).renderForm(m_entity, m_tabInfos, m_formPanel, m_rootHandler, 0);
m_validationHandler.registerEntity(m_entity);
m_validationHandler.setRootHandler(m_rootHandler);
m_validationHandler.setFormTabPanel(m_formTabs);
if (initUndo) {
CmsUndoRedoHandler.getInstance().initialize(m_entity, this, m_rootHandler);
}
// trigger validation right away
m_validationHandler.validate(m_entity);
}
} | [
"public",
"void",
"renderEntityForm",
"(",
"String",
"entityId",
",",
"List",
"<",
"CmsTabInfo",
">",
"tabInfos",
",",
"Panel",
"context",
",",
"Element",
"scrollParent",
")",
"{",
"CmsEntity",
"entity",
"=",
"m_entityBackend",
".",
"getEntity",
"(",
"entityId",
")",
";",
"if",
"(",
"entity",
"!=",
"null",
")",
"{",
"boolean",
"initUndo",
"=",
"(",
"m_entity",
"==",
"null",
")",
"||",
"!",
"entity",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"m_entity",
".",
"getId",
"(",
")",
")",
";",
"m_entity",
"=",
"entity",
";",
"CmsType",
"type",
"=",
"m_entityBackend",
".",
"getType",
"(",
"m_entity",
".",
"getTypeName",
"(",
")",
")",
";",
"m_formPanel",
"=",
"new",
"FlowPanel",
"(",
")",
";",
"context",
".",
"add",
"(",
"m_formPanel",
")",
";",
"CmsAttributeHandler",
".",
"setScrollElement",
"(",
"scrollParent",
")",
";",
"CmsButtonBarHandler",
".",
"INSTANCE",
".",
"setWidgetService",
"(",
"m_widgetService",
")",
";",
"if",
"(",
"m_rootHandler",
"==",
"null",
")",
"{",
"m_rootHandler",
"=",
"new",
"CmsRootHandler",
"(",
")",
";",
"}",
"else",
"{",
"m_rootHandler",
".",
"clearHandlers",
"(",
")",
";",
"}",
"m_tabInfos",
"=",
"tabInfos",
";",
"m_formTabs",
"=",
"m_widgetService",
".",
"getRendererForType",
"(",
"type",
")",
".",
"renderForm",
"(",
"m_entity",
",",
"m_tabInfos",
",",
"m_formPanel",
",",
"m_rootHandler",
",",
"0",
")",
";",
"m_validationHandler",
".",
"registerEntity",
"(",
"m_entity",
")",
";",
"m_validationHandler",
".",
"setRootHandler",
"(",
"m_rootHandler",
")",
";",
"m_validationHandler",
".",
"setFormTabPanel",
"(",
"m_formTabs",
")",
";",
"if",
"(",
"initUndo",
")",
"{",
"CmsUndoRedoHandler",
".",
"getInstance",
"(",
")",
".",
"initialize",
"(",
"m_entity",
",",
"this",
",",
"m_rootHandler",
")",
";",
"}",
"// trigger validation right away\r",
"m_validationHandler",
".",
"validate",
"(",
"m_entity",
")",
";",
"}",
"}"
]
| Renders the entity form within the given context.<p>
@param entityId the entity id
@param tabInfos the tab informations
@param context the context element
@param scrollParent the scroll element to be used for automatic scrolling during drag and drop | [
"Renders",
"the",
"entity",
"form",
"within",
"the",
"given",
"context",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/CmsEditorBase.java#L384-L412 |
SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/lang/StaticResourcePool.java | StaticResourcePool.run | public <U> U run(@javax.annotation.Nonnull final Function<T, U> f, final Predicate<T> filter) {
"""
With u.
@param <U> the type parameter
@param f the f
@param filter
@return the u
"""
if (all.isEmpty()) throw new IllegalStateException();
T poll = get(filter);
try {
return f.apply(poll);
} finally {
this.pool.add(poll);
}
} | java | public <U> U run(@javax.annotation.Nonnull final Function<T, U> f, final Predicate<T> filter) {
if (all.isEmpty()) throw new IllegalStateException();
T poll = get(filter);
try {
return f.apply(poll);
} finally {
this.pool.add(poll);
}
} | [
"public",
"<",
"U",
">",
"U",
"run",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"Function",
"<",
"T",
",",
"U",
">",
"f",
",",
"final",
"Predicate",
"<",
"T",
">",
"filter",
")",
"{",
"if",
"(",
"all",
".",
"isEmpty",
"(",
")",
")",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"T",
"poll",
"=",
"get",
"(",
"filter",
")",
";",
"try",
"{",
"return",
"f",
".",
"apply",
"(",
"poll",
")",
";",
"}",
"finally",
"{",
"this",
".",
"pool",
".",
"add",
"(",
"poll",
")",
";",
"}",
"}"
]
| With u.
@param <U> the type parameter
@param f the f
@param filter
@return the u | [
"With",
"u",
"."
]
| train | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/lang/StaticResourcePool.java#L128-L136 |
facebookarchive/hadoop-20 | src/mapred/org/apache/hadoop/mapred/TaskInProgress.java | TaskInProgress.hasRunOnMachine | public boolean hasRunOnMachine(String trackerHost, String trackerName) {
"""
Was this task ever scheduled to run on this machine?
@param trackerHost The task tracker hostname
@param trackerName The tracker name
@return Was task scheduled on the tracker?
"""
return this.activeTasks.values().contains(trackerName) ||
hasFailedOnMachine(trackerHost);
} | java | public boolean hasRunOnMachine(String trackerHost, String trackerName) {
return this.activeTasks.values().contains(trackerName) ||
hasFailedOnMachine(trackerHost);
} | [
"public",
"boolean",
"hasRunOnMachine",
"(",
"String",
"trackerHost",
",",
"String",
"trackerName",
")",
"{",
"return",
"this",
".",
"activeTasks",
".",
"values",
"(",
")",
".",
"contains",
"(",
"trackerName",
")",
"||",
"hasFailedOnMachine",
"(",
"trackerHost",
")",
";",
"}"
]
| Was this task ever scheduled to run on this machine?
@param trackerHost The task tracker hostname
@param trackerName The tracker name
@return Was task scheduled on the tracker? | [
"Was",
"this",
"task",
"ever",
"scheduled",
"to",
"run",
"on",
"this",
"machine?"
]
| train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/mapred/org/apache/hadoop/mapred/TaskInProgress.java#L1374-L1377 |
phax/ph-web | ph-xservlet/src/main/java/com/helger/xservlet/XServletSettings.java | XServletSettings.setXFrameOptions | @Nonnull
public XServletSettings setXFrameOptions (@Nullable final EXFrameOptionType eType, @Nullable final ISimpleURL aDomain) {
"""
The X-Frame-Options HTTP response header can be used to indicate whether or
not a browser should be allowed to render a page in a <frame>,
<iframe> or <object> . Sites can use this to avoid clickjacking
attacks, by ensuring that their content is not embedded into other sites.
Example:
<pre>
X-Frame-Options: DENY
X-Frame-Options: SAMEORIGIN
X-Frame-Options: ALLOW-FROM https://example.com/
</pre>
@param eType
The X-Frame-Options type to be set. May be <code>null</code>.
@param aDomain
The domain URL to be used in "ALLOW-FROM". May be <code>null</code>
for the other cases.
@return this for chaining
@since 9.1.1
"""
if (eType != null && eType.isURLRequired ())
ValueEnforcer.notNull (aDomain, "Domain");
m_eXFrameOptionsType = eType;
m_aXFrameOptionsDomain = aDomain;
return this;
} | java | @Nonnull
public XServletSettings setXFrameOptions (@Nullable final EXFrameOptionType eType, @Nullable final ISimpleURL aDomain)
{
if (eType != null && eType.isURLRequired ())
ValueEnforcer.notNull (aDomain, "Domain");
m_eXFrameOptionsType = eType;
m_aXFrameOptionsDomain = aDomain;
return this;
} | [
"@",
"Nonnull",
"public",
"XServletSettings",
"setXFrameOptions",
"(",
"@",
"Nullable",
"final",
"EXFrameOptionType",
"eType",
",",
"@",
"Nullable",
"final",
"ISimpleURL",
"aDomain",
")",
"{",
"if",
"(",
"eType",
"!=",
"null",
"&&",
"eType",
".",
"isURLRequired",
"(",
")",
")",
"ValueEnforcer",
".",
"notNull",
"(",
"aDomain",
",",
"\"Domain\"",
")",
";",
"m_eXFrameOptionsType",
"=",
"eType",
";",
"m_aXFrameOptionsDomain",
"=",
"aDomain",
";",
"return",
"this",
";",
"}"
]
| The X-Frame-Options HTTP response header can be used to indicate whether or
not a browser should be allowed to render a page in a <frame>,
<iframe> or <object> . Sites can use this to avoid clickjacking
attacks, by ensuring that their content is not embedded into other sites.
Example:
<pre>
X-Frame-Options: DENY
X-Frame-Options: SAMEORIGIN
X-Frame-Options: ALLOW-FROM https://example.com/
</pre>
@param eType
The X-Frame-Options type to be set. May be <code>null</code>.
@param aDomain
The domain URL to be used in "ALLOW-FROM". May be <code>null</code>
for the other cases.
@return this for chaining
@since 9.1.1 | [
"The",
"X",
"-",
"Frame",
"-",
"Options",
"HTTP",
"response",
"header",
"can",
"be",
"used",
"to",
"indicate",
"whether",
"or",
"not",
"a",
"browser",
"should",
"be",
"allowed",
"to",
"render",
"a",
"page",
"in",
"a",
"<",
";",
"frame>",
";",
"<",
";",
"iframe>",
";",
"or",
"<",
";",
"object>",
";",
".",
"Sites",
"can",
"use",
"this",
"to",
"avoid",
"clickjacking",
"attacks",
"by",
"ensuring",
"that",
"their",
"content",
"is",
"not",
"embedded",
"into",
"other",
"sites",
".",
"Example",
":"
]
| train | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-xservlet/src/main/java/com/helger/xservlet/XServletSettings.java#L157-L166 |
arakelian/more-commons | src/main/java/com/arakelian/core/utils/MoreStringUtils.java | MoreStringUtils.asFile | public static File asFile(final File parent, final String filename) {
"""
Returns a {@link File} from the given filename.
Ensures that the incoming filename has backslashes converted to forward slashes (on Unix OS),
and vice-versa on Windows OS, otherwise, the path separation methods of {@link File} will not
work.
@param parent
parent file name
@param filename
filename to be used
@return a {@link File} from the given filename.
"""
final String normalized = normalizeSeparators(filename);
return normalized != null ? new File(parent, normalized) : parent;
} | java | public static File asFile(final File parent, final String filename) {
final String normalized = normalizeSeparators(filename);
return normalized != null ? new File(parent, normalized) : parent;
} | [
"public",
"static",
"File",
"asFile",
"(",
"final",
"File",
"parent",
",",
"final",
"String",
"filename",
")",
"{",
"final",
"String",
"normalized",
"=",
"normalizeSeparators",
"(",
"filename",
")",
";",
"return",
"normalized",
"!=",
"null",
"?",
"new",
"File",
"(",
"parent",
",",
"normalized",
")",
":",
"parent",
";",
"}"
]
| Returns a {@link File} from the given filename.
Ensures that the incoming filename has backslashes converted to forward slashes (on Unix OS),
and vice-versa on Windows OS, otherwise, the path separation methods of {@link File} will not
work.
@param parent
parent file name
@param filename
filename to be used
@return a {@link File} from the given filename. | [
"Returns",
"a",
"{",
"@link",
"File",
"}",
"from",
"the",
"given",
"filename",
"."
]
| train | https://github.com/arakelian/more-commons/blob/83c607044f64a7f6c005a67866c0ef7cb68d6e29/src/main/java/com/arakelian/core/utils/MoreStringUtils.java#L117-L120 |
twotoasters/RecyclerViewLib | library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java | RecyclerView.findChildViewUnder | public View findChildViewUnder(float x, float y) {
"""
Find the topmost view under the given point.
@param x Horizontal position in pixels to search
@param y Vertical position in pixels to search
@return The child view under (x, y) or null if no matching child is found
"""
final int count = getChildCount();
for (int i = count - 1; i >= 0; i--) {
final View child = getChildAt(i);
final float translationX = ViewCompat.getTranslationX(child);
final float translationY = ViewCompat.getTranslationY(child);
if (x >= child.getLeft() + translationX &&
x <= child.getRight() + translationX &&
y >= child.getTop() + translationY &&
y <= child.getBottom() + translationY) {
return child;
}
}
return null;
} | java | public View findChildViewUnder(float x, float y) {
final int count = getChildCount();
for (int i = count - 1; i >= 0; i--) {
final View child = getChildAt(i);
final float translationX = ViewCompat.getTranslationX(child);
final float translationY = ViewCompat.getTranslationY(child);
if (x >= child.getLeft() + translationX &&
x <= child.getRight() + translationX &&
y >= child.getTop() + translationY &&
y <= child.getBottom() + translationY) {
return child;
}
}
return null;
} | [
"public",
"View",
"findChildViewUnder",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"final",
"int",
"count",
"=",
"getChildCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"count",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"final",
"View",
"child",
"=",
"getChildAt",
"(",
"i",
")",
";",
"final",
"float",
"translationX",
"=",
"ViewCompat",
".",
"getTranslationX",
"(",
"child",
")",
";",
"final",
"float",
"translationY",
"=",
"ViewCompat",
".",
"getTranslationY",
"(",
"child",
")",
";",
"if",
"(",
"x",
">=",
"child",
".",
"getLeft",
"(",
")",
"+",
"translationX",
"&&",
"x",
"<=",
"child",
".",
"getRight",
"(",
")",
"+",
"translationX",
"&&",
"y",
">=",
"child",
".",
"getTop",
"(",
")",
"+",
"translationY",
"&&",
"y",
"<=",
"child",
".",
"getBottom",
"(",
")",
"+",
"translationY",
")",
"{",
"return",
"child",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Find the topmost view under the given point.
@param x Horizontal position in pixels to search
@param y Vertical position in pixels to search
@return The child view under (x, y) or null if no matching child is found | [
"Find",
"the",
"topmost",
"view",
"under",
"the",
"given",
"point",
"."
]
| train | https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L2035-L2049 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java | FieldBuilder.buildSignature | public void buildSignature(XMLNode node, Content fieldDocTree) {
"""
Build the signature.
@param node the XML element that specifies which components to document
@param fieldDocTree the content tree to which the documentation will be added
"""
fieldDocTree.addContent(writer.getSignature(currentElement));
} | java | public void buildSignature(XMLNode node, Content fieldDocTree) {
fieldDocTree.addContent(writer.getSignature(currentElement));
} | [
"public",
"void",
"buildSignature",
"(",
"XMLNode",
"node",
",",
"Content",
"fieldDocTree",
")",
"{",
"fieldDocTree",
".",
"addContent",
"(",
"writer",
".",
"getSignature",
"(",
"currentElement",
")",
")",
";",
"}"
]
| Build the signature.
@param node the XML element that specifies which components to document
@param fieldDocTree the content tree to which the documentation will be added | [
"Build",
"the",
"signature",
"."
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java#L163-L165 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/format/DateTimeFormatter.java | DateTimeFormatter.parseBest | public TemporalAccessor parseBest(CharSequence text, TemporalQuery<?>... queries) {
"""
Fully parses the text producing an object of one of the specified types.
<p>
This parse method is convenient for use when the parser can handle optional elements.
For example, a pattern of 'uuuu-MM-dd HH.mm[ VV]' can be fully parsed to a {@code ZonedDateTime},
or partially parsed to a {@code LocalDateTime}.
The queries must be specified in order, starting from the best matching full-parse option
and ending with the worst matching minimal parse option.
The query is typically a method reference to a {@code from(TemporalAccessor)} method.
<p>
The result is associated with the first type that successfully parses.
Normally, applications will use {@code instanceof} to check the result.
For example:
<pre>
TemporalAccessor dt = parser.parseBest(str, ZonedDateTime::from, LocalDateTime::from);
if (dt instanceof ZonedDateTime) {
...
} else {
...
}
</pre>
If the parse completes without reading the entire length of the text,
or a problem occurs during parsing or merging, then an exception is thrown.
@param text the text to parse, not null
@param queries the queries defining the types to attempt to parse to,
must implement {@code TemporalAccessor}, not null
@return the parsed date-time, not null
@throws IllegalArgumentException if less than 2 types are specified
@throws DateTimeParseException if unable to parse the requested result
"""
Objects.requireNonNull(text, "text");
Objects.requireNonNull(queries, "queries");
if (queries.length < 2) {
throw new IllegalArgumentException("At least two queries must be specified");
}
try {
TemporalAccessor resolved = parseResolved0(text, null);
for (TemporalQuery<?> query : queries) {
try {
return (TemporalAccessor) resolved.query(query);
} catch (RuntimeException ex) {
// continue
}
}
throw new DateTimeException("Unable to convert parsed text using any of the specified queries");
} catch (DateTimeParseException ex) {
throw ex;
} catch (RuntimeException ex) {
throw createError(text, ex);
}
} | java | public TemporalAccessor parseBest(CharSequence text, TemporalQuery<?>... queries) {
Objects.requireNonNull(text, "text");
Objects.requireNonNull(queries, "queries");
if (queries.length < 2) {
throw new IllegalArgumentException("At least two queries must be specified");
}
try {
TemporalAccessor resolved = parseResolved0(text, null);
for (TemporalQuery<?> query : queries) {
try {
return (TemporalAccessor) resolved.query(query);
} catch (RuntimeException ex) {
// continue
}
}
throw new DateTimeException("Unable to convert parsed text using any of the specified queries");
} catch (DateTimeParseException ex) {
throw ex;
} catch (RuntimeException ex) {
throw createError(text, ex);
}
} | [
"public",
"TemporalAccessor",
"parseBest",
"(",
"CharSequence",
"text",
",",
"TemporalQuery",
"<",
"?",
">",
"...",
"queries",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"text",
",",
"\"text\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"queries",
",",
"\"queries\"",
")",
";",
"if",
"(",
"queries",
".",
"length",
"<",
"2",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"At least two queries must be specified\"",
")",
";",
"}",
"try",
"{",
"TemporalAccessor",
"resolved",
"=",
"parseResolved0",
"(",
"text",
",",
"null",
")",
";",
"for",
"(",
"TemporalQuery",
"<",
"?",
">",
"query",
":",
"queries",
")",
"{",
"try",
"{",
"return",
"(",
"TemporalAccessor",
")",
"resolved",
".",
"query",
"(",
"query",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"ex",
")",
"{",
"// continue",
"}",
"}",
"throw",
"new",
"DateTimeException",
"(",
"\"Unable to convert parsed text using any of the specified queries\"",
")",
";",
"}",
"catch",
"(",
"DateTimeParseException",
"ex",
")",
"{",
"throw",
"ex",
";",
"}",
"catch",
"(",
"RuntimeException",
"ex",
")",
"{",
"throw",
"createError",
"(",
"text",
",",
"ex",
")",
";",
"}",
"}"
]
| Fully parses the text producing an object of one of the specified types.
<p>
This parse method is convenient for use when the parser can handle optional elements.
For example, a pattern of 'uuuu-MM-dd HH.mm[ VV]' can be fully parsed to a {@code ZonedDateTime},
or partially parsed to a {@code LocalDateTime}.
The queries must be specified in order, starting from the best matching full-parse option
and ending with the worst matching minimal parse option.
The query is typically a method reference to a {@code from(TemporalAccessor)} method.
<p>
The result is associated with the first type that successfully parses.
Normally, applications will use {@code instanceof} to check the result.
For example:
<pre>
TemporalAccessor dt = parser.parseBest(str, ZonedDateTime::from, LocalDateTime::from);
if (dt instanceof ZonedDateTime) {
...
} else {
...
}
</pre>
If the parse completes without reading the entire length of the text,
or a problem occurs during parsing or merging, then an exception is thrown.
@param text the text to parse, not null
@param queries the queries defining the types to attempt to parse to,
must implement {@code TemporalAccessor}, not null
@return the parsed date-time, not null
@throws IllegalArgumentException if less than 2 types are specified
@throws DateTimeParseException if unable to parse the requested result | [
"Fully",
"parses",
"the",
"text",
"producing",
"an",
"object",
"of",
"one",
"of",
"the",
"specified",
"types",
".",
"<p",
">",
"This",
"parse",
"method",
"is",
"convenient",
"for",
"use",
"when",
"the",
"parser",
"can",
"handle",
"optional",
"elements",
".",
"For",
"example",
"a",
"pattern",
"of",
"uuuu",
"-",
"MM",
"-",
"dd",
"HH",
".",
"mm",
"[",
"VV",
"]",
"can",
"be",
"fully",
"parsed",
"to",
"a",
"{",
"@code",
"ZonedDateTime",
"}",
"or",
"partially",
"parsed",
"to",
"a",
"{",
"@code",
"LocalDateTime",
"}",
".",
"The",
"queries",
"must",
"be",
"specified",
"in",
"order",
"starting",
"from",
"the",
"best",
"matching",
"full",
"-",
"parse",
"option",
"and",
"ending",
"with",
"the",
"worst",
"matching",
"minimal",
"parse",
"option",
".",
"The",
"query",
"is",
"typically",
"a",
"method",
"reference",
"to",
"a",
"{",
"@code",
"from",
"(",
"TemporalAccessor",
")",
"}",
"method",
".",
"<p",
">",
"The",
"result",
"is",
"associated",
"with",
"the",
"first",
"type",
"that",
"successfully",
"parses",
".",
"Normally",
"applications",
"will",
"use",
"{",
"@code",
"instanceof",
"}",
"to",
"check",
"the",
"result",
".",
"For",
"example",
":",
"<pre",
">",
"TemporalAccessor",
"dt",
"=",
"parser",
".",
"parseBest",
"(",
"str",
"ZonedDateTime",
"::",
"from",
"LocalDateTime",
"::",
"from",
")",
";",
"if",
"(",
"dt",
"instanceof",
"ZonedDateTime",
")",
"{",
"...",
"}",
"else",
"{",
"...",
"}",
"<",
"/",
"pre",
">",
"If",
"the",
"parse",
"completes",
"without",
"reading",
"the",
"entire",
"length",
"of",
"the",
"text",
"or",
"a",
"problem",
"occurs",
"during",
"parsing",
"or",
"merging",
"then",
"an",
"exception",
"is",
"thrown",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/format/DateTimeFormatter.java#L1890-L1911 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/transition/TransitionsConfig.java | TransitionsConfig.imports | public static Map<Transition, Collection<TileRef>> imports(Media config) {
"""
Import all transitions from configuration.
@param config The transitions media (must not be <code>null</code>).
@return The transitions imported with associated tiles.
@throws LionEngineException If unable to read data.
"""
final Xml root = new Xml(config);
final Collection<Xml> nodesTransition = root.getChildren(NODE_TRANSITION);
final Map<Transition, Collection<TileRef>> transitions = new HashMap<>(nodesTransition.size());
for (final Xml nodeTransition : nodesTransition)
{
final String groupIn = nodeTransition.readString(ATTRIBUTE_GROUP_IN);
final String groupOut = nodeTransition.readString(ATTRIBUTE_GROUP_OUT);
final String transitionType = nodeTransition.readString(ATTRIBUTE_TRANSITION_TYPE);
final TransitionType type = TransitionType.from(transitionType);
final Transition transition = new Transition(type, groupIn, groupOut);
final Collection<Xml> nodesTileRef = nodeTransition.getChildren(TileConfig.NODE_TILE);
final Collection<TileRef> tilesRef = importTiles(nodesTileRef);
transitions.put(transition, tilesRef);
}
return transitions;
} | java | public static Map<Transition, Collection<TileRef>> imports(Media config)
{
final Xml root = new Xml(config);
final Collection<Xml> nodesTransition = root.getChildren(NODE_TRANSITION);
final Map<Transition, Collection<TileRef>> transitions = new HashMap<>(nodesTransition.size());
for (final Xml nodeTransition : nodesTransition)
{
final String groupIn = nodeTransition.readString(ATTRIBUTE_GROUP_IN);
final String groupOut = nodeTransition.readString(ATTRIBUTE_GROUP_OUT);
final String transitionType = nodeTransition.readString(ATTRIBUTE_TRANSITION_TYPE);
final TransitionType type = TransitionType.from(transitionType);
final Transition transition = new Transition(type, groupIn, groupOut);
final Collection<Xml> nodesTileRef = nodeTransition.getChildren(TileConfig.NODE_TILE);
final Collection<TileRef> tilesRef = importTiles(nodesTileRef);
transitions.put(transition, tilesRef);
}
return transitions;
} | [
"public",
"static",
"Map",
"<",
"Transition",
",",
"Collection",
"<",
"TileRef",
">",
">",
"imports",
"(",
"Media",
"config",
")",
"{",
"final",
"Xml",
"root",
"=",
"new",
"Xml",
"(",
"config",
")",
";",
"final",
"Collection",
"<",
"Xml",
">",
"nodesTransition",
"=",
"root",
".",
"getChildren",
"(",
"NODE_TRANSITION",
")",
";",
"final",
"Map",
"<",
"Transition",
",",
"Collection",
"<",
"TileRef",
">",
">",
"transitions",
"=",
"new",
"HashMap",
"<>",
"(",
"nodesTransition",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"final",
"Xml",
"nodeTransition",
":",
"nodesTransition",
")",
"{",
"final",
"String",
"groupIn",
"=",
"nodeTransition",
".",
"readString",
"(",
"ATTRIBUTE_GROUP_IN",
")",
";",
"final",
"String",
"groupOut",
"=",
"nodeTransition",
".",
"readString",
"(",
"ATTRIBUTE_GROUP_OUT",
")",
";",
"final",
"String",
"transitionType",
"=",
"nodeTransition",
".",
"readString",
"(",
"ATTRIBUTE_TRANSITION_TYPE",
")",
";",
"final",
"TransitionType",
"type",
"=",
"TransitionType",
".",
"from",
"(",
"transitionType",
")",
";",
"final",
"Transition",
"transition",
"=",
"new",
"Transition",
"(",
"type",
",",
"groupIn",
",",
"groupOut",
")",
";",
"final",
"Collection",
"<",
"Xml",
">",
"nodesTileRef",
"=",
"nodeTransition",
".",
"getChildren",
"(",
"TileConfig",
".",
"NODE_TILE",
")",
";",
"final",
"Collection",
"<",
"TileRef",
">",
"tilesRef",
"=",
"importTiles",
"(",
"nodesTileRef",
")",
";",
"transitions",
".",
"put",
"(",
"transition",
",",
"tilesRef",
")",
";",
"}",
"return",
"transitions",
";",
"}"
]
| Import all transitions from configuration.
@param config The transitions media (must not be <code>null</code>).
@return The transitions imported with associated tiles.
@throws LionEngineException If unable to read data. | [
"Import",
"all",
"transitions",
"from",
"configuration",
"."
]
| train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/transition/TransitionsConfig.java#L64-L85 |
jboss/jboss-servlet-api_spec | src/main/java/javax/servlet/http/HttpServletResponseWrapper.java | HttpServletResponseWrapper.setHeader | @Override
public void setHeader(String name, String value) {
"""
The default behavior of this method is to return setHeader(String name, String value)
on the wrapped response object.
"""
this._getHttpServletResponse().setHeader(name, value);
} | java | @Override
public void setHeader(String name, String value) {
this._getHttpServletResponse().setHeader(name, value);
} | [
"@",
"Override",
"public",
"void",
"setHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"this",
".",
"_getHttpServletResponse",
"(",
")",
".",
"setHeader",
"(",
"name",
",",
"value",
")",
";",
"}"
]
| The default behavior of this method is to return setHeader(String name, String value)
on the wrapped response object. | [
"The",
"default",
"behavior",
"of",
"this",
"method",
"is",
"to",
"return",
"setHeader",
"(",
"String",
"name",
"String",
"value",
")",
"on",
"the",
"wrapped",
"response",
"object",
"."
]
| train | https://github.com/jboss/jboss-servlet-api_spec/blob/5bc96f2b833c072baff6eb8ae49bc7b5e503e9b2/src/main/java/javax/servlet/http/HttpServletResponseWrapper.java#L207-L210 |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ExternalChildResourcesCachedImpl.java | ExternalChildResourcesCachedImpl.prepareInlineRemove | protected final void prepareInlineRemove(String name, String key) {
"""
Prepare for inline removal of an external child resource (along with the update of parent resource).
@param name the name of the external child resource
@param key the key
"""
FluentModelTImpl childResource = find(key);
if (childResource == null
|| childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated) {
throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' not found");
}
childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeRemoved);
super.prepareForFutureCommitOrPostRun(childResource);
} | java | protected final void prepareInlineRemove(String name, String key) {
FluentModelTImpl childResource = find(key);
if (childResource == null
|| childResource.pendingOperation() == ExternalChildResourceImpl.PendingOperation.ToBeCreated) {
throw new IllegalArgumentException("A child resource ('" + childResourceName + "') with name (key) '" + name + " (" + key + ")' not found");
}
childResource.setPendingOperation(ExternalChildResourceImpl.PendingOperation.ToBeRemoved);
super.prepareForFutureCommitOrPostRun(childResource);
} | [
"protected",
"final",
"void",
"prepareInlineRemove",
"(",
"String",
"name",
",",
"String",
"key",
")",
"{",
"FluentModelTImpl",
"childResource",
"=",
"find",
"(",
"key",
")",
";",
"if",
"(",
"childResource",
"==",
"null",
"||",
"childResource",
".",
"pendingOperation",
"(",
")",
"==",
"ExternalChildResourceImpl",
".",
"PendingOperation",
".",
"ToBeCreated",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"A child resource ('\"",
"+",
"childResourceName",
"+",
"\"') with name (key) '\"",
"+",
"name",
"+",
"\" (\"",
"+",
"key",
"+",
"\")' not found\"",
")",
";",
"}",
"childResource",
".",
"setPendingOperation",
"(",
"ExternalChildResourceImpl",
".",
"PendingOperation",
".",
"ToBeRemoved",
")",
";",
"super",
".",
"prepareForFutureCommitOrPostRun",
"(",
"childResource",
")",
";",
"}"
]
| Prepare for inline removal of an external child resource (along with the update of parent resource).
@param name the name of the external child resource
@param key the key | [
"Prepare",
"for",
"inline",
"removal",
"of",
"an",
"external",
"child",
"resource",
"(",
"along",
"with",
"the",
"update",
"of",
"parent",
"resource",
")",
"."
]
| train | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ExternalChildResourcesCachedImpl.java#L146-L154 |
wisdom-framework/wisdom | extensions/wisdom-filters/src/main/java/org/wisdom/framework/csrf/AddCSRFTokenInterceptor.java | AddCSRFTokenInterceptor.call | @Override
public Result call(AddCSRFToken configuration, RequestContext context) throws Exception {
"""
Injects a CSRF token into the result if the request is eligible.
@param configuration the interception configuration
@param context the interception context
@return the result with the token if a token was added
@throws Exception if anything bad happen
"""
if (csrf.eligibleForCSRF(context.context())
&& (csrf.extractTokenFromRequest(context.context()) == null || configuration.newTokenOnEachRequest())) {
// Generate a new token, it will be stored in the request scope.
String token = csrf.generateToken(context.context());
// Add it to the response
return csrf.addTokenToResult(context.context(), token, context.proceed());
} else {
return context.proceed();
}
} | java | @Override
public Result call(AddCSRFToken configuration, RequestContext context) throws Exception {
if (csrf.eligibleForCSRF(context.context())
&& (csrf.extractTokenFromRequest(context.context()) == null || configuration.newTokenOnEachRequest())) {
// Generate a new token, it will be stored in the request scope.
String token = csrf.generateToken(context.context());
// Add it to the response
return csrf.addTokenToResult(context.context(), token, context.proceed());
} else {
return context.proceed();
}
} | [
"@",
"Override",
"public",
"Result",
"call",
"(",
"AddCSRFToken",
"configuration",
",",
"RequestContext",
"context",
")",
"throws",
"Exception",
"{",
"if",
"(",
"csrf",
".",
"eligibleForCSRF",
"(",
"context",
".",
"context",
"(",
")",
")",
"&&",
"(",
"csrf",
".",
"extractTokenFromRequest",
"(",
"context",
".",
"context",
"(",
")",
")",
"==",
"null",
"||",
"configuration",
".",
"newTokenOnEachRequest",
"(",
")",
")",
")",
"{",
"// Generate a new token, it will be stored in the request scope.",
"String",
"token",
"=",
"csrf",
".",
"generateToken",
"(",
"context",
".",
"context",
"(",
")",
")",
";",
"// Add it to the response",
"return",
"csrf",
".",
"addTokenToResult",
"(",
"context",
".",
"context",
"(",
")",
",",
"token",
",",
"context",
".",
"proceed",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"context",
".",
"proceed",
"(",
")",
";",
"}",
"}"
]
| Injects a CSRF token into the result if the request is eligible.
@param configuration the interception configuration
@param context the interception context
@return the result with the token if a token was added
@throws Exception if anything bad happen | [
"Injects",
"a",
"CSRF",
"token",
"into",
"the",
"result",
"if",
"the",
"request",
"is",
"eligible",
"."
]
| train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/extensions/wisdom-filters/src/main/java/org/wisdom/framework/csrf/AddCSRFTokenInterceptor.java#L50-L61 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/EigenOps_DDRM.java | EigenOps_DDRM.computeEigenValue | public static double computeEigenValue(DMatrixRMaj A , DMatrixRMaj eigenVector ) {
"""
<p>
Given matrix A and an eigen vector of A, compute the corresponding eigen value. This is
the Rayleigh quotient.<br>
<br>
x<sup>T</sup>Ax / x<sup>T</sup>x
</p>
@param A Matrix. Not modified.
@param eigenVector An eigen vector of A. Not modified.
@return The corresponding eigen value.
"""
double bottom = VectorVectorMult_DDRM.innerProd(eigenVector,eigenVector);
double top = VectorVectorMult_DDRM.innerProdA(eigenVector,A,eigenVector);
return top/bottom;
} | java | public static double computeEigenValue(DMatrixRMaj A , DMatrixRMaj eigenVector )
{
double bottom = VectorVectorMult_DDRM.innerProd(eigenVector,eigenVector);
double top = VectorVectorMult_DDRM.innerProdA(eigenVector,A,eigenVector);
return top/bottom;
} | [
"public",
"static",
"double",
"computeEigenValue",
"(",
"DMatrixRMaj",
"A",
",",
"DMatrixRMaj",
"eigenVector",
")",
"{",
"double",
"bottom",
"=",
"VectorVectorMult_DDRM",
".",
"innerProd",
"(",
"eigenVector",
",",
"eigenVector",
")",
";",
"double",
"top",
"=",
"VectorVectorMult_DDRM",
".",
"innerProdA",
"(",
"eigenVector",
",",
"A",
",",
"eigenVector",
")",
";",
"return",
"top",
"/",
"bottom",
";",
"}"
]
| <p>
Given matrix A and an eigen vector of A, compute the corresponding eigen value. This is
the Rayleigh quotient.<br>
<br>
x<sup>T</sup>Ax / x<sup>T</sup>x
</p>
@param A Matrix. Not modified.
@param eigenVector An eigen vector of A. Not modified.
@return The corresponding eigen value. | [
"<p",
">",
"Given",
"matrix",
"A",
"and",
"an",
"eigen",
"vector",
"of",
"A",
"compute",
"the",
"corresponding",
"eigen",
"value",
".",
"This",
"is",
"the",
"Rayleigh",
"quotient",
".",
"<br",
">",
"<br",
">",
"x<sup",
">",
"T<",
"/",
"sup",
">",
"Ax",
"/",
"x<sup",
">",
"T<",
"/",
"sup",
">",
"x",
"<",
"/",
"p",
">"
]
| train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/EigenOps_DDRM.java#L51-L57 |
Erudika/para | para-core/src/main/java/com/erudika/para/core/App.java | App.removeValidationConstraint | public boolean removeValidationConstraint(String type, String field, String constraintName) {
"""
Removes a constraint from the map.
@param type the type
@param field the field
@param constraintName the constraint name
@return true if successful
"""
if (!StringUtils.isBlank(type) && !StringUtils.isBlank(field) && constraintName != null) {
Map<String, Map<String, Map<String, ?>>> fieldsMap = getValidationConstraints().get(type);
if (fieldsMap != null && fieldsMap.containsKey(field)) {
if (fieldsMap.get(field).containsKey(constraintName)) {
fieldsMap.get(field).remove(constraintName);
}
if (fieldsMap.get(field).isEmpty()) {
getValidationConstraints().get(type).remove(field);
}
if (getValidationConstraints().get(type).isEmpty()) {
getValidationConstraints().remove(type);
}
return true;
}
}
return false;
} | java | public boolean removeValidationConstraint(String type, String field, String constraintName) {
if (!StringUtils.isBlank(type) && !StringUtils.isBlank(field) && constraintName != null) {
Map<String, Map<String, Map<String, ?>>> fieldsMap = getValidationConstraints().get(type);
if (fieldsMap != null && fieldsMap.containsKey(field)) {
if (fieldsMap.get(field).containsKey(constraintName)) {
fieldsMap.get(field).remove(constraintName);
}
if (fieldsMap.get(field).isEmpty()) {
getValidationConstraints().get(type).remove(field);
}
if (getValidationConstraints().get(type).isEmpty()) {
getValidationConstraints().remove(type);
}
return true;
}
}
return false;
} | [
"public",
"boolean",
"removeValidationConstraint",
"(",
"String",
"type",
",",
"String",
"field",
",",
"String",
"constraintName",
")",
"{",
"if",
"(",
"!",
"StringUtils",
".",
"isBlank",
"(",
"type",
")",
"&&",
"!",
"StringUtils",
".",
"isBlank",
"(",
"field",
")",
"&&",
"constraintName",
"!=",
"null",
")",
"{",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"?",
">",
">",
">",
"fieldsMap",
"=",
"getValidationConstraints",
"(",
")",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"fieldsMap",
"!=",
"null",
"&&",
"fieldsMap",
".",
"containsKey",
"(",
"field",
")",
")",
"{",
"if",
"(",
"fieldsMap",
".",
"get",
"(",
"field",
")",
".",
"containsKey",
"(",
"constraintName",
")",
")",
"{",
"fieldsMap",
".",
"get",
"(",
"field",
")",
".",
"remove",
"(",
"constraintName",
")",
";",
"}",
"if",
"(",
"fieldsMap",
".",
"get",
"(",
"field",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"getValidationConstraints",
"(",
")",
".",
"get",
"(",
"type",
")",
".",
"remove",
"(",
"field",
")",
";",
"}",
"if",
"(",
"getValidationConstraints",
"(",
")",
".",
"get",
"(",
"type",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"getValidationConstraints",
"(",
")",
".",
"remove",
"(",
"type",
")",
";",
"}",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Removes a constraint from the map.
@param type the type
@param field the field
@param constraintName the constraint name
@return true if successful | [
"Removes",
"a",
"constraint",
"from",
"the",
"map",
"."
]
| train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/core/App.java#L549-L566 |
zaproxy/zaproxy | src/org/zaproxy/zap/spider/parser/SpiderParser.java | SpiderParser.processURL | protected void processURL(HttpMessage message, int depth, String localURL, String baseURL) {
"""
Builds an url and notifies the listeners.
@param message the message
@param depth the depth
@param localURL the local url
@param baseURL the base url
"""
// Build the absolute canonical URL
String fullURL = URLCanonicalizer.getCanonicalURL(localURL, baseURL);
if (fullURL == null) {
return;
}
log.debug("Canonical URL constructed using '" + localURL + "': " + fullURL);
notifyListenersResourceFound(message, depth + 1, fullURL);
} | java | protected void processURL(HttpMessage message, int depth, String localURL, String baseURL) {
// Build the absolute canonical URL
String fullURL = URLCanonicalizer.getCanonicalURL(localURL, baseURL);
if (fullURL == null) {
return;
}
log.debug("Canonical URL constructed using '" + localURL + "': " + fullURL);
notifyListenersResourceFound(message, depth + 1, fullURL);
} | [
"protected",
"void",
"processURL",
"(",
"HttpMessage",
"message",
",",
"int",
"depth",
",",
"String",
"localURL",
",",
"String",
"baseURL",
")",
"{",
"// Build the absolute canonical URL",
"String",
"fullURL",
"=",
"URLCanonicalizer",
".",
"getCanonicalURL",
"(",
"localURL",
",",
"baseURL",
")",
";",
"if",
"(",
"fullURL",
"==",
"null",
")",
"{",
"return",
";",
"}",
"log",
".",
"debug",
"(",
"\"Canonical URL constructed using '\"",
"+",
"localURL",
"+",
"\"': \"",
"+",
"fullURL",
")",
";",
"notifyListenersResourceFound",
"(",
"message",
",",
"depth",
"+",
"1",
",",
"fullURL",
")",
";",
"}"
]
| Builds an url and notifies the listeners.
@param message the message
@param depth the depth
@param localURL the local url
@param baseURL the base url | [
"Builds",
"an",
"url",
"and",
"notifies",
"the",
"listeners",
"."
]
| train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/spider/parser/SpiderParser.java#L97-L106 |
biojava/biojava | biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java | Jronn.getDisorder | public static Range[] getDisorder(FastaSequence sequence) {
"""
Calculates the disordered regions of the sequence. More formally, the regions for which the
probability of disorder is greater then 0.50.
@param sequence an instance of FastaSequence object, holding the name and the sequence.
@return the array of ranges if there are any residues predicted to have the
probability of disorder greater then 0.5, null otherwise.
"""
float[] scores = getDisorderScores(sequence);
return scoresToRanges(scores, RonnConstraint.DEFAULT_RANGE_PROBABILITY_THRESHOLD);
} | java | public static Range[] getDisorder(FastaSequence sequence) {
float[] scores = getDisorderScores(sequence);
return scoresToRanges(scores, RonnConstraint.DEFAULT_RANGE_PROBABILITY_THRESHOLD);
} | [
"public",
"static",
"Range",
"[",
"]",
"getDisorder",
"(",
"FastaSequence",
"sequence",
")",
"{",
"float",
"[",
"]",
"scores",
"=",
"getDisorderScores",
"(",
"sequence",
")",
";",
"return",
"scoresToRanges",
"(",
"scores",
",",
"RonnConstraint",
".",
"DEFAULT_RANGE_PROBABILITY_THRESHOLD",
")",
";",
"}"
]
| Calculates the disordered regions of the sequence. More formally, the regions for which the
probability of disorder is greater then 0.50.
@param sequence an instance of FastaSequence object, holding the name and the sequence.
@return the array of ranges if there are any residues predicted to have the
probability of disorder greater then 0.5, null otherwise. | [
"Calculates",
"the",
"disordered",
"regions",
"of",
"the",
"sequence",
".",
"More",
"formally",
"the",
"regions",
"for",
"which",
"the",
"probability",
"of",
"disorder",
"is",
"greater",
"then",
"0",
".",
"50",
"."
]
| train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java#L200-L203 |
glyptodon/guacamole-client | guacamole-ext/src/main/java/org/apache/guacamole/token/StandardTokens.java | StandardTokens.addStandardTokens | public static void addStandardTokens(TokenFilter filter, AuthenticatedUser user) {
"""
Adds tokens which are standardized by guacamole-ext to the given
TokenFilter using the values from the given AuthenticatedUser object,
including any associated credentials. These standardized tokens include
the current username (GUAC_USERNAME), password (GUAC_PASSWORD), and the
server date and time (GUAC_DATE and GUAC_TIME respectively). If either
the username or password are not set within the given user or their
provided credentials, the corresponding token(s) will remain unset.
@param filter
The TokenFilter to add standard tokens to.
@param user
The AuthenticatedUser to use when populating the GUAC_USERNAME and
GUAC_PASSWORD tokens.
"""
// Default to the authenticated user's username for the GUAC_USERNAME
// token
filter.setToken(USERNAME_TOKEN, user.getIdentifier());
// Add tokens specific to credentials
addStandardTokens(filter, user.getCredentials());
} | java | public static void addStandardTokens(TokenFilter filter, AuthenticatedUser user) {
// Default to the authenticated user's username for the GUAC_USERNAME
// token
filter.setToken(USERNAME_TOKEN, user.getIdentifier());
// Add tokens specific to credentials
addStandardTokens(filter, user.getCredentials());
} | [
"public",
"static",
"void",
"addStandardTokens",
"(",
"TokenFilter",
"filter",
",",
"AuthenticatedUser",
"user",
")",
"{",
"// Default to the authenticated user's username for the GUAC_USERNAME",
"// token",
"filter",
".",
"setToken",
"(",
"USERNAME_TOKEN",
",",
"user",
".",
"getIdentifier",
"(",
")",
")",
";",
"// Add tokens specific to credentials",
"addStandardTokens",
"(",
"filter",
",",
"user",
".",
"getCredentials",
"(",
")",
")",
";",
"}"
]
| Adds tokens which are standardized by guacamole-ext to the given
TokenFilter using the values from the given AuthenticatedUser object,
including any associated credentials. These standardized tokens include
the current username (GUAC_USERNAME), password (GUAC_PASSWORD), and the
server date and time (GUAC_DATE and GUAC_TIME respectively). If either
the username or password are not set within the given user or their
provided credentials, the corresponding token(s) will remain unset.
@param filter
The TokenFilter to add standard tokens to.
@param user
The AuthenticatedUser to use when populating the GUAC_USERNAME and
GUAC_PASSWORD tokens. | [
"Adds",
"tokens",
"which",
"are",
"standardized",
"by",
"guacamole",
"-",
"ext",
"to",
"the",
"given",
"TokenFilter",
"using",
"the",
"values",
"from",
"the",
"given",
"AuthenticatedUser",
"object",
"including",
"any",
"associated",
"credentials",
".",
"These",
"standardized",
"tokens",
"include",
"the",
"current",
"username",
"(",
"GUAC_USERNAME",
")",
"password",
"(",
"GUAC_PASSWORD",
")",
"and",
"the",
"server",
"date",
"and",
"time",
"(",
"GUAC_DATE",
"and",
"GUAC_TIME",
"respectively",
")",
".",
"If",
"either",
"the",
"username",
"or",
"password",
"are",
"not",
"set",
"within",
"the",
"given",
"user",
"or",
"their",
"provided",
"credentials",
"the",
"corresponding",
"token",
"(",
"s",
")",
"will",
"remain",
"unset",
"."
]
| train | https://github.com/glyptodon/guacamole-client/blob/ea1b10e9d1e3f1fa640dff2ca64d61b44bf1ace9/guacamole-ext/src/main/java/org/apache/guacamole/token/StandardTokens.java#L163-L172 |
JoeKerouac/utils | src/main/java/com/joe/utils/reflect/asm/AsmInvokeDistributeFactory.java | AsmInvokeDistributeFactory.generateDefaultConstructor | private static void generateDefaultConstructor(ClassWriter cw, Class<?> parentClass,
String className) {
"""
为类构建默认构造器(正常编译器会自动生成,但是此处要手动生成bytecode就只能手动生成无参构造器了
@param cw ClassWriter
@param parentClass 构建类的父类,会自动调用父类的构造器
@param className 生成的新类名
"""
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, // public method
INIT, // method name
getDesc(void.class, parentClass), // descriptor
null, // signature (null means not generic)
null); // exceptions (array of strings)
mv.visitCode(); // Start the code for this method
// 调用父类构造器
mv.visitVarInsn(ALOAD, 0); // Load "this" onto the stack
mv.visitMethodInsn(INVOKESPECIAL, // Invoke an instance method (non-virtual)
convert(parentClass), // Class on which the method is defined
INIT, // Name of the method
getDesc(void.class), // Descriptor
false); // Is this class an interface?
// 设置字段值,相当于this.target = target;
mv.visitVarInsn(ALOAD, 0); // 加载this
mv.visitVarInsn(ALOAD, 1); // 加载参数
mv.visitFieldInsn(PUTFIELD, convert(className), TARGET_FIELD_NAME,
getByteCodeType(parentClass));
mv.visitMaxs(2, 1);
mv.visitInsn(RETURN); // End the constructor method
mv.visitEnd();
} | java | private static void generateDefaultConstructor(ClassWriter cw, Class<?> parentClass,
String className) {
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, // public method
INIT, // method name
getDesc(void.class, parentClass), // descriptor
null, // signature (null means not generic)
null); // exceptions (array of strings)
mv.visitCode(); // Start the code for this method
// 调用父类构造器
mv.visitVarInsn(ALOAD, 0); // Load "this" onto the stack
mv.visitMethodInsn(INVOKESPECIAL, // Invoke an instance method (non-virtual)
convert(parentClass), // Class on which the method is defined
INIT, // Name of the method
getDesc(void.class), // Descriptor
false); // Is this class an interface?
// 设置字段值,相当于this.target = target;
mv.visitVarInsn(ALOAD, 0); // 加载this
mv.visitVarInsn(ALOAD, 1); // 加载参数
mv.visitFieldInsn(PUTFIELD, convert(className), TARGET_FIELD_NAME,
getByteCodeType(parentClass));
mv.visitMaxs(2, 1);
mv.visitInsn(RETURN); // End the constructor method
mv.visitEnd();
} | [
"private",
"static",
"void",
"generateDefaultConstructor",
"(",
"ClassWriter",
"cw",
",",
"Class",
"<",
"?",
">",
"parentClass",
",",
"String",
"className",
")",
"{",
"MethodVisitor",
"mv",
"=",
"cw",
".",
"visitMethod",
"(",
"ACC_PUBLIC",
",",
"// public method",
"INIT",
",",
"// method name",
"getDesc",
"(",
"void",
".",
"class",
",",
"parentClass",
")",
",",
"// descriptor",
"null",
",",
"// signature (null means not generic)",
"null",
")",
";",
"// exceptions (array of strings)",
"mv",
".",
"visitCode",
"(",
")",
";",
"// Start the code for this method",
"// 调用父类构造器",
"mv",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"// Load \"this\" onto the stack",
"mv",
".",
"visitMethodInsn",
"(",
"INVOKESPECIAL",
",",
"// Invoke an instance method (non-virtual)",
"convert",
"(",
"parentClass",
")",
",",
"// Class on which the method is defined",
"INIT",
",",
"// Name of the method",
"getDesc",
"(",
"void",
".",
"class",
")",
",",
"// Descriptor",
"false",
")",
";",
"// Is this class an interface?",
"// 设置字段值,相当于this.target = target;",
"mv",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"// 加载this",
"mv",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"1",
")",
";",
"// 加载参数",
"mv",
".",
"visitFieldInsn",
"(",
"PUTFIELD",
",",
"convert",
"(",
"className",
")",
",",
"TARGET_FIELD_NAME",
",",
"getByteCodeType",
"(",
"parentClass",
")",
")",
";",
"mv",
".",
"visitMaxs",
"(",
"2",
",",
"1",
")",
";",
"mv",
".",
"visitInsn",
"(",
"RETURN",
")",
";",
"// End the constructor method",
"mv",
".",
"visitEnd",
"(",
")",
";",
"}"
]
| 为类构建默认构造器(正常编译器会自动生成,但是此处要手动生成bytecode就只能手动生成无参构造器了
@param cw ClassWriter
@param parentClass 构建类的父类,会自动调用父类的构造器
@param className 生成的新类名 | [
"为类构建默认构造器(正常编译器会自动生成,但是此处要手动生成bytecode就只能手动生成无参构造器了"
]
| train | https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/reflect/asm/AsmInvokeDistributeFactory.java#L285-L312 |
morimekta/utils | console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java | LineBuffer.clearLast | public void clearLast(int N) {
"""
Clear the last N lines, and move the cursor to the end of the last
remaining line.
@param N Number of lines to clear.
"""
if (N < 1) {
throw new IllegalArgumentException("Unable to clear " + N + " lines");
}
if (N > count()) {
throw new IllegalArgumentException("Count: " + N + ", Size: " + count());
}
if (N == count()) {
clear();
return;
}
terminal.format("\r%s", CURSOR_ERASE);
buffer.remove(buffer.size() - 1);
for (int i = 1; i < N; ++i) {
terminal.format("%s%s", UP, CURSOR_ERASE);
buffer.remove(buffer.size() - 1);
}
terminal.format("%s\r%s",
UP,
cursorRight(printableWidth(lastLine())));
} | java | public void clearLast(int N) {
if (N < 1) {
throw new IllegalArgumentException("Unable to clear " + N + " lines");
}
if (N > count()) {
throw new IllegalArgumentException("Count: " + N + ", Size: " + count());
}
if (N == count()) {
clear();
return;
}
terminal.format("\r%s", CURSOR_ERASE);
buffer.remove(buffer.size() - 1);
for (int i = 1; i < N; ++i) {
terminal.format("%s%s", UP, CURSOR_ERASE);
buffer.remove(buffer.size() - 1);
}
terminal.format("%s\r%s",
UP,
cursorRight(printableWidth(lastLine())));
} | [
"public",
"void",
"clearLast",
"(",
"int",
"N",
")",
"{",
"if",
"(",
"N",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unable to clear \"",
"+",
"N",
"+",
"\" lines\"",
")",
";",
"}",
"if",
"(",
"N",
">",
"count",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Count: \"",
"+",
"N",
"+",
"\", Size: \"",
"+",
"count",
"(",
")",
")",
";",
"}",
"if",
"(",
"N",
"==",
"count",
"(",
")",
")",
"{",
"clear",
"(",
")",
";",
"return",
";",
"}",
"terminal",
".",
"format",
"(",
"\"\\r%s\"",
",",
"CURSOR_ERASE",
")",
";",
"buffer",
".",
"remove",
"(",
"buffer",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"N",
";",
"++",
"i",
")",
"{",
"terminal",
".",
"format",
"(",
"\"%s%s\"",
",",
"UP",
",",
"CURSOR_ERASE",
")",
";",
"buffer",
".",
"remove",
"(",
"buffer",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}",
"terminal",
".",
"format",
"(",
"\"%s\\r%s\"",
",",
"UP",
",",
"cursorRight",
"(",
"printableWidth",
"(",
"lastLine",
"(",
")",
")",
")",
")",
";",
"}"
]
| Clear the last N lines, and move the cursor to the end of the last
remaining line.
@param N Number of lines to clear. | [
"Clear",
"the",
"last",
"N",
"lines",
"and",
"move",
"the",
"cursor",
"to",
"the",
"end",
"of",
"the",
"last",
"remaining",
"line",
"."
]
| train | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java#L167-L189 |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java | DAGraph.addDependencyGraph | public void addDependencyGraph(DAGraph<DataT, NodeT> dependencyGraph) {
"""
Mark root of this DAG depends on given DAG's root.
@param dependencyGraph the dependency DAG
"""
this.rootNode.addDependency(dependencyGraph.rootNode.key());
Map<String, NodeT> sourceNodeTable = dependencyGraph.nodeTable;
Map<String, NodeT> targetNodeTable = this.nodeTable;
this.merge(sourceNodeTable, targetNodeTable);
dependencyGraph.parentDAGs.add(this);
if (this.hasParents()) {
this.bubbleUpNodeTable(this, new LinkedList<String>());
}
} | java | public void addDependencyGraph(DAGraph<DataT, NodeT> dependencyGraph) {
this.rootNode.addDependency(dependencyGraph.rootNode.key());
Map<String, NodeT> sourceNodeTable = dependencyGraph.nodeTable;
Map<String, NodeT> targetNodeTable = this.nodeTable;
this.merge(sourceNodeTable, targetNodeTable);
dependencyGraph.parentDAGs.add(this);
if (this.hasParents()) {
this.bubbleUpNodeTable(this, new LinkedList<String>());
}
} | [
"public",
"void",
"addDependencyGraph",
"(",
"DAGraph",
"<",
"DataT",
",",
"NodeT",
">",
"dependencyGraph",
")",
"{",
"this",
".",
"rootNode",
".",
"addDependency",
"(",
"dependencyGraph",
".",
"rootNode",
".",
"key",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"NodeT",
">",
"sourceNodeTable",
"=",
"dependencyGraph",
".",
"nodeTable",
";",
"Map",
"<",
"String",
",",
"NodeT",
">",
"targetNodeTable",
"=",
"this",
".",
"nodeTable",
";",
"this",
".",
"merge",
"(",
"sourceNodeTable",
",",
"targetNodeTable",
")",
";",
"dependencyGraph",
".",
"parentDAGs",
".",
"add",
"(",
"this",
")",
";",
"if",
"(",
"this",
".",
"hasParents",
"(",
")",
")",
"{",
"this",
".",
"bubbleUpNodeTable",
"(",
"this",
",",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
")",
";",
"}",
"}"
]
| Mark root of this DAG depends on given DAG's root.
@param dependencyGraph the dependency DAG | [
"Mark",
"root",
"of",
"this",
"DAG",
"depends",
"on",
"given",
"DAG",
"s",
"root",
"."
]
| train | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGraph.java#L101-L110 |
sockeqwe/mosby | sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/DimensUtils.java | DimensUtils.pxToDp | public static int pxToDp(Context context, int px) {
"""
Converts pixel in dp
@param context The context
@param px the pixel value
@return value in dp
"""
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return (int) ((px / displayMetrics.density) + 0.5);
} | java | public static int pxToDp(Context context, int px) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return (int) ((px / displayMetrics.density) + 0.5);
} | [
"public",
"static",
"int",
"pxToDp",
"(",
"Context",
"context",
",",
"int",
"px",
")",
"{",
"DisplayMetrics",
"displayMetrics",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
";",
"return",
"(",
"int",
")",
"(",
"(",
"px",
"/",
"displayMetrics",
".",
"density",
")",
"+",
"0.5",
")",
";",
"}"
]
| Converts pixel in dp
@param context The context
@param px the pixel value
@return value in dp | [
"Converts",
"pixel",
"in",
"dp"
]
| train | https://github.com/sockeqwe/mosby/blob/7f22118c950b5e6fbba0ec42d8e97586dfb08940/sample-mail/src/main/java/com/hannesdorfmann/mosby3/sample/mail/utils/DimensUtils.java#L33-L36 |
pravega/pravega | common/src/main/java/io/pravega/common/LoggerHelpers.java | LoggerHelpers.traceLeave | public static void traceLeave(Logger log, String method, long traceEnterId, Object... args) {
"""
Traces the fact that a method has exited normally.
@param log The Logger to log to.
@param method The name of the method.
@param traceEnterId The correlation Id obtained from a traceEnter call.
@param args Additional arguments to log.
"""
if (!log.isTraceEnabled()) {
return;
}
if (args.length == 0) {
log.trace("LEAVE {}@{} (elapsed={}us).", method, traceEnterId, ELAPSED_MICRO.apply(traceEnterId));
} else {
log.trace("LEAVE {}@{} {} (elapsed={}us).", method, traceEnterId, args, ELAPSED_MICRO.apply(traceEnterId));
}
} | java | public static void traceLeave(Logger log, String method, long traceEnterId, Object... args) {
if (!log.isTraceEnabled()) {
return;
}
if (args.length == 0) {
log.trace("LEAVE {}@{} (elapsed={}us).", method, traceEnterId, ELAPSED_MICRO.apply(traceEnterId));
} else {
log.trace("LEAVE {}@{} {} (elapsed={}us).", method, traceEnterId, args, ELAPSED_MICRO.apply(traceEnterId));
}
} | [
"public",
"static",
"void",
"traceLeave",
"(",
"Logger",
"log",
",",
"String",
"method",
",",
"long",
"traceEnterId",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"!",
"log",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"args",
".",
"length",
"==",
"0",
")",
"{",
"log",
".",
"trace",
"(",
"\"LEAVE {}@{} (elapsed={}us).\"",
",",
"method",
",",
"traceEnterId",
",",
"ELAPSED_MICRO",
".",
"apply",
"(",
"traceEnterId",
")",
")",
";",
"}",
"else",
"{",
"log",
".",
"trace",
"(",
"\"LEAVE {}@{} {} (elapsed={}us).\"",
",",
"method",
",",
"traceEnterId",
",",
"args",
",",
"ELAPSED_MICRO",
".",
"apply",
"(",
"traceEnterId",
")",
")",
";",
"}",
"}"
]
| Traces the fact that a method has exited normally.
@param log The Logger to log to.
@param method The name of the method.
@param traceEnterId The correlation Id obtained from a traceEnter call.
@param args Additional arguments to log. | [
"Traces",
"the",
"fact",
"that",
"a",
"method",
"has",
"exited",
"normally",
"."
]
| train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/common/src/main/java/io/pravega/common/LoggerHelpers.java#L80-L90 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/subdoc/AsyncLookupInBuilder.java | AsyncLookupInBuilder.getCount | public AsyncLookupInBuilder getCount(String path, SubdocOptionsBuilder optionsBuilder) {
"""
Get the count of values inside the JSON document.
This method is only available with Couchbase Server 5.0 and later.
@param path the path inside the document where to get the count from.
@param optionsBuilder {@link SubdocOptionsBuilder}
@return this builder for chaining.
"""
if (path == null) {
throw new IllegalArgumentException("Path is mandatory for subdoc get count");
}
if (optionsBuilder.createPath()) {
throw new IllegalArgumentException("Options createPath are not supported for lookup");
}
this.specs.add(new LookupSpec(Lookup.GET_COUNT, path, optionsBuilder));
return this;
} | java | public AsyncLookupInBuilder getCount(String path, SubdocOptionsBuilder optionsBuilder) {
if (path == null) {
throw new IllegalArgumentException("Path is mandatory for subdoc get count");
}
if (optionsBuilder.createPath()) {
throw new IllegalArgumentException("Options createPath are not supported for lookup");
}
this.specs.add(new LookupSpec(Lookup.GET_COUNT, path, optionsBuilder));
return this;
} | [
"public",
"AsyncLookupInBuilder",
"getCount",
"(",
"String",
"path",
",",
"SubdocOptionsBuilder",
"optionsBuilder",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Path is mandatory for subdoc get count\"",
")",
";",
"}",
"if",
"(",
"optionsBuilder",
".",
"createPath",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Options createPath are not supported for lookup\"",
")",
";",
"}",
"this",
".",
"specs",
".",
"add",
"(",
"new",
"LookupSpec",
"(",
"Lookup",
".",
"GET_COUNT",
",",
"path",
",",
"optionsBuilder",
")",
")",
";",
"return",
"this",
";",
"}"
]
| Get the count of values inside the JSON document.
This method is only available with Couchbase Server 5.0 and later.
@param path the path inside the document where to get the count from.
@param optionsBuilder {@link SubdocOptionsBuilder}
@return this builder for chaining. | [
"Get",
"the",
"count",
"of",
"values",
"inside",
"the",
"JSON",
"document",
"."
]
| train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/subdoc/AsyncLookupInBuilder.java#L406-L415 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TimeZoneFormat.java | TimeZoneFormat.parseOffsetLocalizedGMTPattern | private int parseOffsetLocalizedGMTPattern(String text, int start, boolean isShort, int[] parsedLen) {
"""
Parse localized GMT format generated by the pattern used by this formatter, except
GMT Zero format.
@param text the input text
@param start the start index
@param isShort true if the short localized GMT format is parsed.
@param parsedLen the parsed length, or 0 on failure.
@return the parsed offset in milliseconds.
"""
int idx = start;
int offset = 0;
boolean parsed = false;
do {
// Prefix part
int len = _gmtPatternPrefix.length();
if (len > 0 && !text.regionMatches(true, idx, _gmtPatternPrefix, 0, len)) {
// prefix match failed
break;
}
idx += len;
// Offset part
int[] offsetLen = new int[1];
offset = parseOffsetFields(text, idx, false, offsetLen);
if (offsetLen[0] == 0) {
// offset field match failed
break;
}
idx += offsetLen[0];
// Suffix part
len = _gmtPatternSuffix.length();
if (len > 0 && !text.regionMatches(true, idx, _gmtPatternSuffix, 0, len)) {
// no suffix match
break;
}
idx += len;
parsed = true;
} while (false);
parsedLen[0] = parsed ? idx - start : 0;
return offset;
} | java | private int parseOffsetLocalizedGMTPattern(String text, int start, boolean isShort, int[] parsedLen) {
int idx = start;
int offset = 0;
boolean parsed = false;
do {
// Prefix part
int len = _gmtPatternPrefix.length();
if (len > 0 && !text.regionMatches(true, idx, _gmtPatternPrefix, 0, len)) {
// prefix match failed
break;
}
idx += len;
// Offset part
int[] offsetLen = new int[1];
offset = parseOffsetFields(text, idx, false, offsetLen);
if (offsetLen[0] == 0) {
// offset field match failed
break;
}
idx += offsetLen[0];
// Suffix part
len = _gmtPatternSuffix.length();
if (len > 0 && !text.regionMatches(true, idx, _gmtPatternSuffix, 0, len)) {
// no suffix match
break;
}
idx += len;
parsed = true;
} while (false);
parsedLen[0] = parsed ? idx - start : 0;
return offset;
} | [
"private",
"int",
"parseOffsetLocalizedGMTPattern",
"(",
"String",
"text",
",",
"int",
"start",
",",
"boolean",
"isShort",
",",
"int",
"[",
"]",
"parsedLen",
")",
"{",
"int",
"idx",
"=",
"start",
";",
"int",
"offset",
"=",
"0",
";",
"boolean",
"parsed",
"=",
"false",
";",
"do",
"{",
"// Prefix part",
"int",
"len",
"=",
"_gmtPatternPrefix",
".",
"length",
"(",
")",
";",
"if",
"(",
"len",
">",
"0",
"&&",
"!",
"text",
".",
"regionMatches",
"(",
"true",
",",
"idx",
",",
"_gmtPatternPrefix",
",",
"0",
",",
"len",
")",
")",
"{",
"// prefix match failed",
"break",
";",
"}",
"idx",
"+=",
"len",
";",
"// Offset part",
"int",
"[",
"]",
"offsetLen",
"=",
"new",
"int",
"[",
"1",
"]",
";",
"offset",
"=",
"parseOffsetFields",
"(",
"text",
",",
"idx",
",",
"false",
",",
"offsetLen",
")",
";",
"if",
"(",
"offsetLen",
"[",
"0",
"]",
"==",
"0",
")",
"{",
"// offset field match failed",
"break",
";",
"}",
"idx",
"+=",
"offsetLen",
"[",
"0",
"]",
";",
"// Suffix part",
"len",
"=",
"_gmtPatternSuffix",
".",
"length",
"(",
")",
";",
"if",
"(",
"len",
">",
"0",
"&&",
"!",
"text",
".",
"regionMatches",
"(",
"true",
",",
"idx",
",",
"_gmtPatternSuffix",
",",
"0",
",",
"len",
")",
")",
"{",
"// no suffix match",
"break",
";",
"}",
"idx",
"+=",
"len",
";",
"parsed",
"=",
"true",
";",
"}",
"while",
"(",
"false",
")",
";",
"parsedLen",
"[",
"0",
"]",
"=",
"parsed",
"?",
"idx",
"-",
"start",
":",
"0",
";",
"return",
"offset",
";",
"}"
]
| Parse localized GMT format generated by the pattern used by this formatter, except
GMT Zero format.
@param text the input text
@param start the start index
@param isShort true if the short localized GMT format is parsed.
@param parsedLen the parsed length, or 0 on failure.
@return the parsed offset in milliseconds. | [
"Parse",
"localized",
"GMT",
"format",
"generated",
"by",
"the",
"pattern",
"used",
"by",
"this",
"formatter",
"except",
"GMT",
"Zero",
"format",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TimeZoneFormat.java#L2196-L2231 |
ops4j/org.ops4j.pax.logging | pax-logging-log4j2/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java | ResolverUtil.find | public void find(final Test test, final String... packageNames) {
"""
Attempts to discover classes that pass the test. Accumulated classes can be accessed by calling
{@link #getClasses()}.
@param test
the test to determine matching classes
@param packageNames
one or more package names to scan (including subpackages) for classes
"""
if (packageNames == null) {
return;
}
for (final String pkg : packageNames) {
findInPackage(test, pkg);
}
} | java | public void find(final Test test, final String... packageNames) {
if (packageNames == null) {
return;
}
for (final String pkg : packageNames) {
findInPackage(test, pkg);
}
} | [
"public",
"void",
"find",
"(",
"final",
"Test",
"test",
",",
"final",
"String",
"...",
"packageNames",
")",
"{",
"if",
"(",
"packageNames",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"final",
"String",
"pkg",
":",
"packageNames",
")",
"{",
"findInPackage",
"(",
"test",
",",
"pkg",
")",
";",
"}",
"}"
]
| Attempts to discover classes that pass the test. Accumulated classes can be accessed by calling
{@link #getClasses()}.
@param test
the test to determine matching classes
@param packageNames
one or more package names to scan (including subpackages) for classes | [
"Attempts",
"to",
"discover",
"classes",
"that",
"pass",
"the",
"test",
".",
"Accumulated",
"classes",
"can",
"be",
"accessed",
"by",
"calling",
"{",
"@link",
"#getClasses",
"()",
"}",
"."
]
| train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-log4j2/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtil.java#L151-L159 |
brunocvcunha/inutils4j | src/main/java/org/brunocvcunha/inutils4j/MyVideoUtils.java | MyVideoUtils.getDimension | public static Dimension getDimension(File videoFile) throws IOException {
"""
Returns the dimensions for the video
@param videoFile Video file
@return the dimensions
@throws IOException
"""
try (FileInputStream fis = new FileInputStream(videoFile)) {
return getDimension(fis, new AtomicReference<ByteBuffer>());
}
} | java | public static Dimension getDimension(File videoFile) throws IOException {
try (FileInputStream fis = new FileInputStream(videoFile)) {
return getDimension(fis, new AtomicReference<ByteBuffer>());
}
} | [
"public",
"static",
"Dimension",
"getDimension",
"(",
"File",
"videoFile",
")",
"throws",
"IOException",
"{",
"try",
"(",
"FileInputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"videoFile",
")",
")",
"{",
"return",
"getDimension",
"(",
"fis",
",",
"new",
"AtomicReference",
"<",
"ByteBuffer",
">",
"(",
")",
")",
";",
"}",
"}"
]
| Returns the dimensions for the video
@param videoFile Video file
@return the dimensions
@throws IOException | [
"Returns",
"the",
"dimensions",
"for",
"the",
"video"
]
| train | https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/MyVideoUtils.java#L46-L50 |
TheBlackChamber/commons-encryption | src/main/java/net/theblackchamber/crypto/util/KeystoreUtils.java | KeystoreUtils.getSecretKey | public static SecretKey getSecretKey(File keystore, String entryName,
String keyStorePassword) throws KeyStoreException,
NoSuchAlgorithmException, CertificateException,
FileNotFoundException, IOException, UnrecoverableEntryException {
"""
Method which will load a secret key from disk with the specified entry
name.
@param keystore
{@link KeyStore} file to read.
@param entryName
Entry name of the key to be retrieved
@param keyStorePassword
Password used to open the {@link KeyStore}
@return
@throws KeyStoreException
@throws NoSuchAlgorithmException
@throws CertificateException
@throws FileNotFoundException
@throws IOException
@throws UnrecoverableEntryException
"""
KeyStore keyStore = KeyStore.getInstance("JCEKS");
FileInputStream fis = null;
if (keystore == null || !keystore.exists()
|| FileUtils.sizeOf(keystore) == 0) {
throw new FileNotFoundException();
}
if (StringUtils.isEmpty(keyStorePassword)) {
throw new KeyStoreException("No Keystore password provided.");
}
if (StringUtils.isEmpty(entryName)) {
throw new KeyStoreException("No Keystore entry name provided.");
}
fis = new FileInputStream(keystore);
return getSecretKey(fis, entryName, keyStorePassword);
} | java | public static SecretKey getSecretKey(File keystore, String entryName,
String keyStorePassword) throws KeyStoreException,
NoSuchAlgorithmException, CertificateException,
FileNotFoundException, IOException, UnrecoverableEntryException {
KeyStore keyStore = KeyStore.getInstance("JCEKS");
FileInputStream fis = null;
if (keystore == null || !keystore.exists()
|| FileUtils.sizeOf(keystore) == 0) {
throw new FileNotFoundException();
}
if (StringUtils.isEmpty(keyStorePassword)) {
throw new KeyStoreException("No Keystore password provided.");
}
if (StringUtils.isEmpty(entryName)) {
throw new KeyStoreException("No Keystore entry name provided.");
}
fis = new FileInputStream(keystore);
return getSecretKey(fis, entryName, keyStorePassword);
} | [
"public",
"static",
"SecretKey",
"getSecretKey",
"(",
"File",
"keystore",
",",
"String",
"entryName",
",",
"String",
"keyStorePassword",
")",
"throws",
"KeyStoreException",
",",
"NoSuchAlgorithmException",
",",
"CertificateException",
",",
"FileNotFoundException",
",",
"IOException",
",",
"UnrecoverableEntryException",
"{",
"KeyStore",
"keyStore",
"=",
"KeyStore",
".",
"getInstance",
"(",
"\"JCEKS\"",
")",
";",
"FileInputStream",
"fis",
"=",
"null",
";",
"if",
"(",
"keystore",
"==",
"null",
"||",
"!",
"keystore",
".",
"exists",
"(",
")",
"||",
"FileUtils",
".",
"sizeOf",
"(",
"keystore",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
")",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"keyStorePassword",
")",
")",
"{",
"throw",
"new",
"KeyStoreException",
"(",
"\"No Keystore password provided.\"",
")",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"entryName",
")",
")",
"{",
"throw",
"new",
"KeyStoreException",
"(",
"\"No Keystore entry name provided.\"",
")",
";",
"}",
"fis",
"=",
"new",
"FileInputStream",
"(",
"keystore",
")",
";",
"return",
"getSecretKey",
"(",
"fis",
",",
"entryName",
",",
"keyStorePassword",
")",
";",
"}"
]
| Method which will load a secret key from disk with the specified entry
name.
@param keystore
{@link KeyStore} file to read.
@param entryName
Entry name of the key to be retrieved
@param keyStorePassword
Password used to open the {@link KeyStore}
@return
@throws KeyStoreException
@throws NoSuchAlgorithmException
@throws CertificateException
@throws FileNotFoundException
@throws IOException
@throws UnrecoverableEntryException | [
"Method",
"which",
"will",
"load",
"a",
"secret",
"key",
"from",
"disk",
"with",
"the",
"specified",
"entry",
"name",
"."
]
| train | https://github.com/TheBlackChamber/commons-encryption/blob/0cbbf7c07ae3c133cc82b6dde7ab7af91ddf64d0/src/main/java/net/theblackchamber/crypto/util/KeystoreUtils.java#L132-L153 |
alkacon/opencms-core | src-gwt/org/opencms/ade/sitemap/client/control/CmsSitemapController.java | CmsSitemapController.getEffectiveProperty | public String getEffectiveProperty(CmsClientSitemapEntry entry, String name) {
"""
Gets the effective value of a property value for a sitemap entry.<p>
@param entry the sitemap entry
@param name the name of the property
@return the effective value
"""
CmsClientProperty prop = getEffectivePropertyObject(entry, name);
if (prop == null) {
return null;
}
return prop.getEffectiveValue();
} | java | public String getEffectiveProperty(CmsClientSitemapEntry entry, String name) {
CmsClientProperty prop = getEffectivePropertyObject(entry, name);
if (prop == null) {
return null;
}
return prop.getEffectiveValue();
} | [
"public",
"String",
"getEffectiveProperty",
"(",
"CmsClientSitemapEntry",
"entry",
",",
"String",
"name",
")",
"{",
"CmsClientProperty",
"prop",
"=",
"getEffectivePropertyObject",
"(",
"entry",
",",
"name",
")",
";",
"if",
"(",
"prop",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"prop",
".",
"getEffectiveValue",
"(",
")",
";",
"}"
]
| Gets the effective value of a property value for a sitemap entry.<p>
@param entry the sitemap entry
@param name the name of the property
@return the effective value | [
"Gets",
"the",
"effective",
"value",
"of",
"a",
"property",
"value",
"for",
"a",
"sitemap",
"entry",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/sitemap/client/control/CmsSitemapController.java#L1076-L1083 |
tvesalainen/util | util/src/main/java/org/vesalainen/math/Catenary.java | Catenary.aForXAndH | public static double aForXAndH(double x, double h) {
"""
Returns a for a catenary having height h at x. Height is distance from
vertex (a) to y.
@param x
@param h
@return
"""
return MoreMath.solve(
(xx,a)->a*Math.cosh(xx/a)-a,
x,
h,
Double.MIN_VALUE,
100);
} | java | public static double aForXAndH(double x, double h)
{
return MoreMath.solve(
(xx,a)->a*Math.cosh(xx/a)-a,
x,
h,
Double.MIN_VALUE,
100);
} | [
"public",
"static",
"double",
"aForXAndH",
"(",
"double",
"x",
",",
"double",
"h",
")",
"{",
"return",
"MoreMath",
".",
"solve",
"(",
"(",
"xx",
",",
"a",
")",
"->",
"a",
"*",
"Math",
".",
"cosh",
"(",
"xx",
"/",
"a",
")",
"-",
"a",
",",
"x",
",",
"h",
",",
"Double",
".",
"MIN_VALUE",
",",
"100",
")",
";",
"}"
]
| Returns a for a catenary having height h at x. Height is distance from
vertex (a) to y.
@param x
@param h
@return | [
"Returns",
"a",
"for",
"a",
"catenary",
"having",
"height",
"h",
"at",
"x",
".",
"Height",
"is",
"distance",
"from",
"vertex",
"(",
"a",
")",
"to",
"y",
"."
]
| train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/Catenary.java#L80-L88 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java | DefaultDisseminatorImpl.viewItemIndex | public MIMETypedStream viewItemIndex() throws ServerException {
"""
Returns an HTML rendering of the Item Index for the object. The Item
Index is a list of all datastreams in the object. The datastream items
can be data or metadata. The Item Index is returned as HTML in a
presentation-oriented format. This is accomplished by doing an XSLT
transform on the XML that is obtained from listDatastreams in API-A.
@return html packaged as a MIMETypedStream
@throws ServerException
"""
// get the item index as xml
Reader in = null;
try {
ReadableCharArrayWriter out = new ReadableCharArrayWriter(4096);
ObjectInfoAsXML
.getItemIndex(reposBaseURL,
context
.getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME),
reader,
asOfDateTime, out);
out.close();
in = out.toReader();
} catch (Exception e) {
throw new GeneralException("[DefaultDisseminatorImpl] An error has occurred. "
+ "The error was a \""
+ e.getClass().getName()
+ "\" . The " + "Reason was \"" + e.getMessage() + "\" .");
}
// convert the xml to an html view
try {
//InputStream in = getItemIndex().getStream();
ReadableByteArrayOutputStream bytes =
new ReadableByteArrayOutputStream(2048);
PrintWriter out = new PrintWriter(
new OutputStreamWriter(bytes, Charset.forName("UTF-8")));
File xslFile = new File(reposHomeDir, "access/viewItemIndex.xslt");
Templates template =
XmlTransformUtility.getTemplates(xslFile);
Transformer transformer = template.newTransformer();
transformer.setParameter("fedora", context
.getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME));
transformer.transform(new StreamSource(in), new StreamResult(out));
out.close();
return new MIMETypedStream("text/html", bytes.toInputStream(),
null, bytes.length());
} catch (Exception e) {
throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
+ "in transforming xml for viewItemIndex. "
+ "Underlying exception was: " + e.getMessage());
}
} | java | public MIMETypedStream viewItemIndex() throws ServerException {
// get the item index as xml
Reader in = null;
try {
ReadableCharArrayWriter out = new ReadableCharArrayWriter(4096);
ObjectInfoAsXML
.getItemIndex(reposBaseURL,
context
.getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME),
reader,
asOfDateTime, out);
out.close();
in = out.toReader();
} catch (Exception e) {
throw new GeneralException("[DefaultDisseminatorImpl] An error has occurred. "
+ "The error was a \""
+ e.getClass().getName()
+ "\" . The " + "Reason was \"" + e.getMessage() + "\" .");
}
// convert the xml to an html view
try {
//InputStream in = getItemIndex().getStream();
ReadableByteArrayOutputStream bytes =
new ReadableByteArrayOutputStream(2048);
PrintWriter out = new PrintWriter(
new OutputStreamWriter(bytes, Charset.forName("UTF-8")));
File xslFile = new File(reposHomeDir, "access/viewItemIndex.xslt");
Templates template =
XmlTransformUtility.getTemplates(xslFile);
Transformer transformer = template.newTransformer();
transformer.setParameter("fedora", context
.getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME));
transformer.transform(new StreamSource(in), new StreamResult(out));
out.close();
return new MIMETypedStream("text/html", bytes.toInputStream(),
null, bytes.length());
} catch (Exception e) {
throw new DisseminationException("[DefaultDisseminatorImpl] had an error "
+ "in transforming xml for viewItemIndex. "
+ "Underlying exception was: " + e.getMessage());
}
} | [
"public",
"MIMETypedStream",
"viewItemIndex",
"(",
")",
"throws",
"ServerException",
"{",
"// get the item index as xml",
"Reader",
"in",
"=",
"null",
";",
"try",
"{",
"ReadableCharArrayWriter",
"out",
"=",
"new",
"ReadableCharArrayWriter",
"(",
"4096",
")",
";",
"ObjectInfoAsXML",
".",
"getItemIndex",
"(",
"reposBaseURL",
",",
"context",
".",
"getEnvironmentValue",
"(",
"Constants",
".",
"FEDORA_APP_CONTEXT_NAME",
")",
",",
"reader",
",",
"asOfDateTime",
",",
"out",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"in",
"=",
"out",
".",
"toReader",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"GeneralException",
"(",
"\"[DefaultDisseminatorImpl] An error has occurred. \"",
"+",
"\"The error was a \\\"\"",
"+",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"\\\" . The \"",
"+",
"\"Reason was \\\"\"",
"+",
"e",
".",
"getMessage",
"(",
")",
"+",
"\"\\\" .\"",
")",
";",
"}",
"// convert the xml to an html view",
"try",
"{",
"//InputStream in = getItemIndex().getStream();",
"ReadableByteArrayOutputStream",
"bytes",
"=",
"new",
"ReadableByteArrayOutputStream",
"(",
"2048",
")",
";",
"PrintWriter",
"out",
"=",
"new",
"PrintWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"bytes",
",",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
")",
")",
";",
"File",
"xslFile",
"=",
"new",
"File",
"(",
"reposHomeDir",
",",
"\"access/viewItemIndex.xslt\"",
")",
";",
"Templates",
"template",
"=",
"XmlTransformUtility",
".",
"getTemplates",
"(",
"xslFile",
")",
";",
"Transformer",
"transformer",
"=",
"template",
".",
"newTransformer",
"(",
")",
";",
"transformer",
".",
"setParameter",
"(",
"\"fedora\"",
",",
"context",
".",
"getEnvironmentValue",
"(",
"Constants",
".",
"FEDORA_APP_CONTEXT_NAME",
")",
")",
";",
"transformer",
".",
"transform",
"(",
"new",
"StreamSource",
"(",
"in",
")",
",",
"new",
"StreamResult",
"(",
"out",
")",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"return",
"new",
"MIMETypedStream",
"(",
"\"text/html\"",
",",
"bytes",
".",
"toInputStream",
"(",
")",
",",
"null",
",",
"bytes",
".",
"length",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"DisseminationException",
"(",
"\"[DefaultDisseminatorImpl] had an error \"",
"+",
"\"in transforming xml for viewItemIndex. \"",
"+",
"\"Underlying exception was: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
]
| Returns an HTML rendering of the Item Index for the object. The Item
Index is a list of all datastreams in the object. The datastream items
can be data or metadata. The Item Index is returned as HTML in a
presentation-oriented format. This is accomplished by doing an XSLT
transform on the XML that is obtained from listDatastreams in API-A.
@return html packaged as a MIMETypedStream
@throws ServerException | [
"Returns",
"an",
"HTML",
"rendering",
"of",
"the",
"Item",
"Index",
"for",
"the",
"object",
".",
"The",
"Item",
"Index",
"is",
"a",
"list",
"of",
"all",
"datastreams",
"in",
"the",
"object",
".",
"The",
"datastream",
"items",
"can",
"be",
"data",
"or",
"metadata",
".",
"The",
"Item",
"Index",
"is",
"returned",
"as",
"HTML",
"in",
"a",
"presentation",
"-",
"oriented",
"format",
".",
"This",
"is",
"accomplished",
"by",
"doing",
"an",
"XSLT",
"transform",
"on",
"the",
"XML",
"that",
"is",
"obtained",
"from",
"listDatastreams",
"in",
"API",
"-",
"A",
"."
]
| train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/defaultdisseminator/DefaultDisseminatorImpl.java#L215-L258 |
aws/aws-sdk-java | aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/CreateIntegrationResult.java | CreateIntegrationResult.withRequestParameters | public CreateIntegrationResult withRequestParameters(java.util.Map<String, String> requestParameters) {
"""
<p>
A key-value map specifying request parameters that are passed from the method request to the backend. The key is
an integration request parameter name and the associated value is a method request parameter value or static
value that must be enclosed within single quotes and pre-encoded as required by the backend. The method request
parameter value must match the pattern of method.request.{location}.{name} , where {location} is querystring,
path, or header; and {name} must be a valid and unique method request parameter name.
</p>
@param requestParameters
A key-value map specifying request parameters that are passed from the method request to the backend. The
key is an integration request parameter name and the associated value is a method request parameter value
or static value that must be enclosed within single quotes and pre-encoded as required by the backend. The
method request parameter value must match the pattern of method.request.{location}.{name} , where
{location} is querystring, path, or header; and {name} must be a valid and unique method request parameter
name.
@return Returns a reference to this object so that method calls can be chained together.
"""
setRequestParameters(requestParameters);
return this;
} | java | public CreateIntegrationResult withRequestParameters(java.util.Map<String, String> requestParameters) {
setRequestParameters(requestParameters);
return this;
} | [
"public",
"CreateIntegrationResult",
"withRequestParameters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"requestParameters",
")",
"{",
"setRequestParameters",
"(",
"requestParameters",
")",
";",
"return",
"this",
";",
"}"
]
| <p>
A key-value map specifying request parameters that are passed from the method request to the backend. The key is
an integration request parameter name and the associated value is a method request parameter value or static
value that must be enclosed within single quotes and pre-encoded as required by the backend. The method request
parameter value must match the pattern of method.request.{location}.{name} , where {location} is querystring,
path, or header; and {name} must be a valid and unique method request parameter name.
</p>
@param requestParameters
A key-value map specifying request parameters that are passed from the method request to the backend. The
key is an integration request parameter name and the associated value is a method request parameter value
or static value that must be enclosed within single quotes and pre-encoded as required by the backend. The
method request parameter value must match the pattern of method.request.{location}.{name} , where
{location} is querystring, path, or header; and {name} must be a valid and unique method request parameter
name.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"A",
"key",
"-",
"value",
"map",
"specifying",
"request",
"parameters",
"that",
"are",
"passed",
"from",
"the",
"method",
"request",
"to",
"the",
"backend",
".",
"The",
"key",
"is",
"an",
"integration",
"request",
"parameter",
"name",
"and",
"the",
"associated",
"value",
"is",
"a",
"method",
"request",
"parameter",
"value",
"or",
"static",
"value",
"that",
"must",
"be",
"enclosed",
"within",
"single",
"quotes",
"and",
"pre",
"-",
"encoded",
"as",
"required",
"by",
"the",
"backend",
".",
"The",
"method",
"request",
"parameter",
"value",
"must",
"match",
"the",
"pattern",
"of",
"method",
".",
"request",
".",
"{",
"location",
"}",
".",
"{",
"name",
"}",
"where",
"{",
"location",
"}",
"is",
"querystring",
"path",
"or",
"header",
";",
"and",
"{",
"name",
"}",
"must",
"be",
"a",
"valid",
"and",
"unique",
"method",
"request",
"parameter",
"name",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/CreateIntegrationResult.java#L1146-L1149 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/LevelRipConverter.java | LevelRipConverter.start | public static int start(Media levelrip, MapTile map) {
"""
Run the converter.
@param levelrip The file containing the levelrip as an image.
@param map The destination map reference.
@return The total number of not found tiles.
@throws LionEngineException If media is <code>null</code> or image cannot be read.
"""
return start(levelrip, map, null, null);
} | java | public static int start(Media levelrip, MapTile map)
{
return start(levelrip, map, null, null);
} | [
"public",
"static",
"int",
"start",
"(",
"Media",
"levelrip",
",",
"MapTile",
"map",
")",
"{",
"return",
"start",
"(",
"levelrip",
",",
"map",
",",
"null",
",",
"null",
")",
";",
"}"
]
| Run the converter.
@param levelrip The file containing the levelrip as an image.
@param map The destination map reference.
@return The total number of not found tiles.
@throws LionEngineException If media is <code>null</code> or image cannot be read. | [
"Run",
"the",
"converter",
"."
]
| train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/LevelRipConverter.java#L44-L47 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.mp.jwt_fat/fat/src/com/ibm/ws/security/mp/jwt/fat/CommonMpJwtFat.java | CommonMpJwtFat.addApiOutputExpectation | public ResponseFullExpectation addApiOutputExpectation(String api, String claimIdentifier, String key, String value) throws Exception {
"""
Create a response expectation for the key/value being checked
@param api - The api that was used to retrieve the claim
@param claimIdentifier - A more descriptive identifier for the claim
@param key - the claim's key
@param value - the claims value
@return - returns a new Full Response expectation with a properly formatted string to look for the specified claim
@throws Exception
"""
return new ResponseFullExpectation(MpJwtFatConstants.STRING_MATCHES, buildStringToCheck(claimIdentifier, key, value), "API " + api + " did NOT return the correct value ("
+ value + ").");
} | java | public ResponseFullExpectation addApiOutputExpectation(String api, String claimIdentifier, String key, String value) throws Exception {
return new ResponseFullExpectation(MpJwtFatConstants.STRING_MATCHES, buildStringToCheck(claimIdentifier, key, value), "API " + api + " did NOT return the correct value ("
+ value + ").");
} | [
"public",
"ResponseFullExpectation",
"addApiOutputExpectation",
"(",
"String",
"api",
",",
"String",
"claimIdentifier",
",",
"String",
"key",
",",
"String",
"value",
")",
"throws",
"Exception",
"{",
"return",
"new",
"ResponseFullExpectation",
"(",
"MpJwtFatConstants",
".",
"STRING_MATCHES",
",",
"buildStringToCheck",
"(",
"claimIdentifier",
",",
"key",
",",
"value",
")",
",",
"\"API \"",
"+",
"api",
"+",
"\" did NOT return the correct value (\"",
"+",
"value",
"+",
"\").\"",
")",
";",
"}"
]
| Create a response expectation for the key/value being checked
@param api - The api that was used to retrieve the claim
@param claimIdentifier - A more descriptive identifier for the claim
@param key - the claim's key
@param value - the claims value
@return - returns a new Full Response expectation with a properly formatted string to look for the specified claim
@throws Exception | [
"Create",
"a",
"response",
"expectation",
"for",
"the",
"key",
"/",
"value",
"being",
"checked"
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.mp.jwt_fat/fat/src/com/ibm/ws/security/mp/jwt/fat/CommonMpJwtFat.java#L264-L268 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/client/gui/element/position/Positions.java | Positions.middleAligned | public static <T extends ISized & IChild<U>, U extends ISized> IntSupplier middleAligned(T owner, int offset) {
"""
Positions the owner to the bottom inside its parent.<br>
Respects the parent padding.
@param <T> the generic type
@param <U> the generic type
@param offset the offset
@return the int supplier
"""
return () -> {
U parent = owner.getParent();
if (owner.getParent() == null)
return 0;
return (int) (Math.ceil(((float) parent.size().height() - Padding.of(parent).vertical() - owner.size().height()) / 2) + offset);
};
} | java | public static <T extends ISized & IChild<U>, U extends ISized> IntSupplier middleAligned(T owner, int offset)
{
return () -> {
U parent = owner.getParent();
if (owner.getParent() == null)
return 0;
return (int) (Math.ceil(((float) parent.size().height() - Padding.of(parent).vertical() - owner.size().height()) / 2) + offset);
};
} | [
"public",
"static",
"<",
"T",
"extends",
"ISized",
"&",
"IChild",
"<",
"U",
">",
",",
"U",
"extends",
"ISized",
">",
"IntSupplier",
"middleAligned",
"(",
"T",
"owner",
",",
"int",
"offset",
")",
"{",
"return",
"(",
")",
"->",
"{",
"U",
"parent",
"=",
"owner",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"owner",
".",
"getParent",
"(",
")",
"==",
"null",
")",
"return",
"0",
";",
"return",
"(",
"int",
")",
"(",
"Math",
".",
"ceil",
"(",
"(",
"(",
"float",
")",
"parent",
".",
"size",
"(",
")",
".",
"height",
"(",
")",
"-",
"Padding",
".",
"of",
"(",
"parent",
")",
".",
"vertical",
"(",
")",
"-",
"owner",
".",
"size",
"(",
")",
".",
"height",
"(",
")",
")",
"/",
"2",
")",
"+",
"offset",
")",
";",
"}",
";",
"}"
]
| Positions the owner to the bottom inside its parent.<br>
Respects the parent padding.
@param <T> the generic type
@param <U> the generic type
@param offset the offset
@return the int supplier | [
"Positions",
"the",
"owner",
"to",
"the",
"bottom",
"inside",
"its",
"parent",
".",
"<br",
">",
"Respects",
"the",
"parent",
"padding",
"."
]
| train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/client/gui/element/position/Positions.java#L143-L151 |
geomajas/geomajas-project-client-gwt2 | common-gwt/command/src/main/java/org/geomajas/gwt/client/util/Log.java | Log.logServer | public static void logServer(int logLevel, String message, Throwable throwable) {
"""
Log a message in the server log.
@param logLevel log level
@param message message to log
@param throwable exception to include in message
"""
String logMessage = message;
if (null == logMessage) {
logMessage = "";
}
if (null != throwable) {
logMessage += "\n" + getMessage(throwable);
}
LogRequest logRequest = new LogRequest();
logRequest.setLevel(logLevel);
logRequest.setStatement(logMessage);
GwtCommand command = new GwtCommand(LogRequest.COMMAND);
command.setCommandRequest(logRequest);
Deferred deferred = new Deferred();
deferred.setLogCommunicationExceptions(false);
GwtCommandDispatcher.getInstance().execute(command, deferred);
} | java | public static void logServer(int logLevel, String message, Throwable throwable) {
String logMessage = message;
if (null == logMessage) {
logMessage = "";
}
if (null != throwable) {
logMessage += "\n" + getMessage(throwable);
}
LogRequest logRequest = new LogRequest();
logRequest.setLevel(logLevel);
logRequest.setStatement(logMessage);
GwtCommand command = new GwtCommand(LogRequest.COMMAND);
command.setCommandRequest(logRequest);
Deferred deferred = new Deferred();
deferred.setLogCommunicationExceptions(false);
GwtCommandDispatcher.getInstance().execute(command, deferred);
} | [
"public",
"static",
"void",
"logServer",
"(",
"int",
"logLevel",
",",
"String",
"message",
",",
"Throwable",
"throwable",
")",
"{",
"String",
"logMessage",
"=",
"message",
";",
"if",
"(",
"null",
"==",
"logMessage",
")",
"{",
"logMessage",
"=",
"\"\"",
";",
"}",
"if",
"(",
"null",
"!=",
"throwable",
")",
"{",
"logMessage",
"+=",
"\"\\n\"",
"+",
"getMessage",
"(",
"throwable",
")",
";",
"}",
"LogRequest",
"logRequest",
"=",
"new",
"LogRequest",
"(",
")",
";",
"logRequest",
".",
"setLevel",
"(",
"logLevel",
")",
";",
"logRequest",
".",
"setStatement",
"(",
"logMessage",
")",
";",
"GwtCommand",
"command",
"=",
"new",
"GwtCommand",
"(",
"LogRequest",
".",
"COMMAND",
")",
";",
"command",
".",
"setCommandRequest",
"(",
"logRequest",
")",
";",
"Deferred",
"deferred",
"=",
"new",
"Deferred",
"(",
")",
";",
"deferred",
".",
"setLogCommunicationExceptions",
"(",
"false",
")",
";",
"GwtCommandDispatcher",
".",
"getInstance",
"(",
")",
".",
"execute",
"(",
"command",
",",
"deferred",
")",
";",
"}"
]
| Log a message in the server log.
@param logLevel log level
@param message message to log
@param throwable exception to include in message | [
"Log",
"a",
"message",
"in",
"the",
"server",
"log",
"."
]
| train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/common-gwt/command/src/main/java/org/geomajas/gwt/client/util/Log.java#L179-L195 |
biezhi/webp-io | src/main/java/io/github/biezhi/webp/WebpIO.java | WebpIO.toWEBP | public void toWEBP(File src, File dest) {
"""
Convert normal image to webp file
@param src nomal image path
@param dest webp file path
"""
try {
String command = commandDir + (src.getName().endsWith(".gif") ? "/gif2webp " : "/cwebp ") + src.getPath() + " -o " + dest.getPath();
this.executeCommand(command);
} catch (Exception e) {
throw new WebpIOException(e);
}
} | java | public void toWEBP(File src, File dest) {
try {
String command = commandDir + (src.getName().endsWith(".gif") ? "/gif2webp " : "/cwebp ") + src.getPath() + " -o " + dest.getPath();
this.executeCommand(command);
} catch (Exception e) {
throw new WebpIOException(e);
}
} | [
"public",
"void",
"toWEBP",
"(",
"File",
"src",
",",
"File",
"dest",
")",
"{",
"try",
"{",
"String",
"command",
"=",
"commandDir",
"+",
"(",
"src",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".gif\"",
")",
"?",
"\"/gif2webp \"",
":",
"\"/cwebp \"",
")",
"+",
"src",
".",
"getPath",
"(",
")",
"+",
"\" -o \"",
"+",
"dest",
".",
"getPath",
"(",
")",
";",
"this",
".",
"executeCommand",
"(",
"command",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"WebpIOException",
"(",
"e",
")",
";",
"}",
"}"
]
| Convert normal image to webp file
@param src nomal image path
@param dest webp file path | [
"Convert",
"normal",
"image",
"to",
"webp",
"file"
]
| train | https://github.com/biezhi/webp-io/blob/8eefe535087b3abccacff76de2b6e27bb7301bcc/src/main/java/io/github/biezhi/webp/WebpIO.java#L107-L114 |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/tools/DependencyBasisMaker.java | DependencyBasisMaker.saveSSpace | protected void saveSSpace(SemanticSpace sspace, File outputFile)
throws IOException {
"""
Saves the {@link BasisMapping} created from the {@link
OccurrenceCounter}.
"""
BasisMapping<String, String> savedTerms = new StringBasisMapping();
for (String term : sspace.getWords())
savedTerms.getDimension(term);
ObjectOutputStream ouStream = new ObjectOutputStream(
new FileOutputStream(outputFile));
ouStream.writeObject(savedTerms);
ouStream.close();
} | java | protected void saveSSpace(SemanticSpace sspace, File outputFile)
throws IOException{
BasisMapping<String, String> savedTerms = new StringBasisMapping();
for (String term : sspace.getWords())
savedTerms.getDimension(term);
ObjectOutputStream ouStream = new ObjectOutputStream(
new FileOutputStream(outputFile));
ouStream.writeObject(savedTerms);
ouStream.close();
} | [
"protected",
"void",
"saveSSpace",
"(",
"SemanticSpace",
"sspace",
",",
"File",
"outputFile",
")",
"throws",
"IOException",
"{",
"BasisMapping",
"<",
"String",
",",
"String",
">",
"savedTerms",
"=",
"new",
"StringBasisMapping",
"(",
")",
";",
"for",
"(",
"String",
"term",
":",
"sspace",
".",
"getWords",
"(",
")",
")",
"savedTerms",
".",
"getDimension",
"(",
"term",
")",
";",
"ObjectOutputStream",
"ouStream",
"=",
"new",
"ObjectOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"outputFile",
")",
")",
";",
"ouStream",
".",
"writeObject",
"(",
"savedTerms",
")",
";",
"ouStream",
".",
"close",
"(",
")",
";",
"}"
]
| Saves the {@link BasisMapping} created from the {@link
OccurrenceCounter}. | [
"Saves",
"the",
"{"
]
| train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/tools/DependencyBasisMaker.java#L125-L135 |
ecclesia/kipeto | kipeto-core/src/main/java/de/ecclesia/kipeto/repository/FileRepositoryStrategy.java | FileRepositoryStrategy.createRepositoryDirectoryStructure | private void createRepositoryDirectoryStructure(File rootDir) {
"""
Erzeugt die Verzeichnis-Struktur des Repositorys, falls die Verzeichinsse
noch nicht existieren.
@param rootDir
Wurzelverzeichnis zur Anlage der Verzeichnis-Struktur
"""
this.objs = new File(rootDir, OBJECT_DIR);
if (!objs.exists()) {
if (!objs.mkdirs()) {
throw new RuntimeException("Could not create dir: " + objs.getAbsolutePath());
}
}
this.refs = new File(rootDir, REFERENCE_DIR);
if (!refs.exists()) {
if (!refs.mkdirs()) {
throw new RuntimeException("Could not create dir: " + refs.getAbsolutePath());
}
}
} | java | private void createRepositoryDirectoryStructure(File rootDir) {
this.objs = new File(rootDir, OBJECT_DIR);
if (!objs.exists()) {
if (!objs.mkdirs()) {
throw new RuntimeException("Could not create dir: " + objs.getAbsolutePath());
}
}
this.refs = new File(rootDir, REFERENCE_DIR);
if (!refs.exists()) {
if (!refs.mkdirs()) {
throw new RuntimeException("Could not create dir: " + refs.getAbsolutePath());
}
}
} | [
"private",
"void",
"createRepositoryDirectoryStructure",
"(",
"File",
"rootDir",
")",
"{",
"this",
".",
"objs",
"=",
"new",
"File",
"(",
"rootDir",
",",
"OBJECT_DIR",
")",
";",
"if",
"(",
"!",
"objs",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"objs",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not create dir: \"",
"+",
"objs",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"this",
".",
"refs",
"=",
"new",
"File",
"(",
"rootDir",
",",
"REFERENCE_DIR",
")",
";",
"if",
"(",
"!",
"refs",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"refs",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not create dir: \"",
"+",
"refs",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"}"
]
| Erzeugt die Verzeichnis-Struktur des Repositorys, falls die Verzeichinsse
noch nicht existieren.
@param rootDir
Wurzelverzeichnis zur Anlage der Verzeichnis-Struktur | [
"Erzeugt",
"die",
"Verzeichnis",
"-",
"Struktur",
"des",
"Repositorys",
"falls",
"die",
"Verzeichinsse",
"noch",
"nicht",
"existieren",
"."
]
| train | https://github.com/ecclesia/kipeto/blob/ea39a10ae4eaa550f71a856ab2f2845270a64913/kipeto-core/src/main/java/de/ecclesia/kipeto/repository/FileRepositoryStrategy.java#L263-L277 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/raid/RaidCodec.java | RaidCodec.checkRaidProgress | public boolean checkRaidProgress(INodeFile sourceINode,
LightWeightLinkedSet<RaidBlockInfo> raidEncodingTasks, FSNamesystem fs,
boolean forceAdd) throws IOException {
"""
Count the number of live replicas of each parity block in the raided file
If any stripe has not enough parity block replicas, add the stripe to
raidEncodingTasks to schedule encoding.
If forceAdd is true, we always add the stripe to raidEncodingTasks
without checking
@param sourceINode
@param raidTasks
@param fs
@param forceAdd
@return true if all parity blocks of the file have enough replicas
@throws IOException
"""
boolean result = true;
BlockInfo[] blocks = sourceINode.getBlocks();
for (int i = 0; i < blocks.length;
i += numStripeBlocks) {
boolean hasParity = true;
if (!forceAdd) {
for (int j = 0; j < numParityBlocks; j++) {
if (fs.countLiveNodes(blocks[i + j]) < this.parityReplication) {
hasParity = false;
break;
}
}
}
if (!hasParity || forceAdd) {
raidEncodingTasks.add(new RaidBlockInfo(blocks[i], parityReplication, i));
result = false;
}
}
return result;
} | java | public boolean checkRaidProgress(INodeFile sourceINode,
LightWeightLinkedSet<RaidBlockInfo> raidEncodingTasks, FSNamesystem fs,
boolean forceAdd) throws IOException {
boolean result = true;
BlockInfo[] blocks = sourceINode.getBlocks();
for (int i = 0; i < blocks.length;
i += numStripeBlocks) {
boolean hasParity = true;
if (!forceAdd) {
for (int j = 0; j < numParityBlocks; j++) {
if (fs.countLiveNodes(blocks[i + j]) < this.parityReplication) {
hasParity = false;
break;
}
}
}
if (!hasParity || forceAdd) {
raidEncodingTasks.add(new RaidBlockInfo(blocks[i], parityReplication, i));
result = false;
}
}
return result;
} | [
"public",
"boolean",
"checkRaidProgress",
"(",
"INodeFile",
"sourceINode",
",",
"LightWeightLinkedSet",
"<",
"RaidBlockInfo",
">",
"raidEncodingTasks",
",",
"FSNamesystem",
"fs",
",",
"boolean",
"forceAdd",
")",
"throws",
"IOException",
"{",
"boolean",
"result",
"=",
"true",
";",
"BlockInfo",
"[",
"]",
"blocks",
"=",
"sourceINode",
".",
"getBlocks",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"blocks",
".",
"length",
";",
"i",
"+=",
"numStripeBlocks",
")",
"{",
"boolean",
"hasParity",
"=",
"true",
";",
"if",
"(",
"!",
"forceAdd",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"numParityBlocks",
";",
"j",
"++",
")",
"{",
"if",
"(",
"fs",
".",
"countLiveNodes",
"(",
"blocks",
"[",
"i",
"+",
"j",
"]",
")",
"<",
"this",
".",
"parityReplication",
")",
"{",
"hasParity",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"hasParity",
"||",
"forceAdd",
")",
"{",
"raidEncodingTasks",
".",
"add",
"(",
"new",
"RaidBlockInfo",
"(",
"blocks",
"[",
"i",
"]",
",",
"parityReplication",
",",
"i",
")",
")",
";",
"result",
"=",
"false",
";",
"}",
"}",
"return",
"result",
";",
"}"
]
| Count the number of live replicas of each parity block in the raided file
If any stripe has not enough parity block replicas, add the stripe to
raidEncodingTasks to schedule encoding.
If forceAdd is true, we always add the stripe to raidEncodingTasks
without checking
@param sourceINode
@param raidTasks
@param fs
@param forceAdd
@return true if all parity blocks of the file have enough replicas
@throws IOException | [
"Count",
"the",
"number",
"of",
"live",
"replicas",
"of",
"each",
"parity",
"block",
"in",
"the",
"raided",
"file",
"If",
"any",
"stripe",
"has",
"not",
"enough",
"parity",
"block",
"replicas",
"add",
"the",
"stripe",
"to",
"raidEncodingTasks",
"to",
"schedule",
"encoding",
".",
"If",
"forceAdd",
"is",
"true",
"we",
"always",
"add",
"the",
"stripe",
"to",
"raidEncodingTasks",
"without",
"checking"
]
| train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/raid/RaidCodec.java#L421-L443 |
alkacon/opencms-core | src/org/opencms/ui/apps/sessions/CmsSessionsTable.java | CmsSessionsTable.getCloseRunnable | protected static Runnable getCloseRunnable(final Window window, final CmsSessionsTable table) {
"""
Runnable called when a window should be closed.<p>
Reinitializes the table.<p>
@param window to be closed
@param table to be updated
@return a runnable
"""
return new Runnable() {
public void run() {
window.close();
try {
table.ini();
} catch (CmsException e) {
LOG.error("Error on reading session information", e);
}
}
};
} | java | protected static Runnable getCloseRunnable(final Window window, final CmsSessionsTable table) {
return new Runnable() {
public void run() {
window.close();
try {
table.ini();
} catch (CmsException e) {
LOG.error("Error on reading session information", e);
}
}
};
} | [
"protected",
"static",
"Runnable",
"getCloseRunnable",
"(",
"final",
"Window",
"window",
",",
"final",
"CmsSessionsTable",
"table",
")",
"{",
"return",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"window",
".",
"close",
"(",
")",
";",
"try",
"{",
"table",
".",
"ini",
"(",
")",
";",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Error on reading session information\"",
",",
"e",
")",
";",
"}",
"}",
"}",
";",
"}"
]
| Runnable called when a window should be closed.<p>
Reinitializes the table.<p>
@param window to be closed
@param table to be updated
@return a runnable | [
"Runnable",
"called",
"when",
"a",
"window",
"should",
"be",
"closed",
".",
"<p",
">",
"Reinitializes",
"the",
"table",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/sessions/CmsSessionsTable.java#L457-L473 |
beangle/beangle3 | struts/s2/src/main/java/org/beangle/struts2/view/template/FreemarkerTemplateEngine.java | FreemarkerTemplateEngine.setFreemarkerManager | @Inject
public void setFreemarkerManager(FreemarkerManager mgr) {
"""
Clone configuration from FreemarkerManager,but custmize in
<ul>
<li>Disable freemarker localized lookup
<li>Cache two hour(7200s) and Strong cache
<li>Disable auto imports and includes
</ul>
"""
this.freemarkerManager = mgr;
if (null != freemarkerManager) {
Configuration old = freemarkerManager.getConfig();
if (null != old) {
config = (Configuration) freemarkerManager.getConfig().clone();
config.setTemplateLoader(new HierarchicalTemplateLoader(this, config.getTemplateLoader()));
} else {
config = new Configuration(Configuration.VERSION_2_3_28);
config.setTemplateLoader(new HierarchicalTemplateLoader(this, new BeangleClassTemplateLoader(null)));
}
// Disable freemarker localized lookup
config.setLocalizedLookup(false);
config.setEncoding(config.getLocale(), "UTF-8");
config.setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX);
// Cache one hour(7200s) and Strong cache
config.setTemplateUpdateDelayMilliseconds(7200 * 1000);
// config.setCacheStorage(new MruCacheStorage(100,250));
config.setCacheStorage(new StrongCacheStorage());
// Disable auto imports and includes
config.setAutoImports(CollectUtils.newHashMap());
config.setAutoIncludes(CollectUtils.newArrayList(0));
}
} | java | @Inject
public void setFreemarkerManager(FreemarkerManager mgr) {
this.freemarkerManager = mgr;
if (null != freemarkerManager) {
Configuration old = freemarkerManager.getConfig();
if (null != old) {
config = (Configuration) freemarkerManager.getConfig().clone();
config.setTemplateLoader(new HierarchicalTemplateLoader(this, config.getTemplateLoader()));
} else {
config = new Configuration(Configuration.VERSION_2_3_28);
config.setTemplateLoader(new HierarchicalTemplateLoader(this, new BeangleClassTemplateLoader(null)));
}
// Disable freemarker localized lookup
config.setLocalizedLookup(false);
config.setEncoding(config.getLocale(), "UTF-8");
config.setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX);
// Cache one hour(7200s) and Strong cache
config.setTemplateUpdateDelayMilliseconds(7200 * 1000);
// config.setCacheStorage(new MruCacheStorage(100,250));
config.setCacheStorage(new StrongCacheStorage());
// Disable auto imports and includes
config.setAutoImports(CollectUtils.newHashMap());
config.setAutoIncludes(CollectUtils.newArrayList(0));
}
} | [
"@",
"Inject",
"public",
"void",
"setFreemarkerManager",
"(",
"FreemarkerManager",
"mgr",
")",
"{",
"this",
".",
"freemarkerManager",
"=",
"mgr",
";",
"if",
"(",
"null",
"!=",
"freemarkerManager",
")",
"{",
"Configuration",
"old",
"=",
"freemarkerManager",
".",
"getConfig",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"old",
")",
"{",
"config",
"=",
"(",
"Configuration",
")",
"freemarkerManager",
".",
"getConfig",
"(",
")",
".",
"clone",
"(",
")",
";",
"config",
".",
"setTemplateLoader",
"(",
"new",
"HierarchicalTemplateLoader",
"(",
"this",
",",
"config",
".",
"getTemplateLoader",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"config",
"=",
"new",
"Configuration",
"(",
"Configuration",
".",
"VERSION_2_3_28",
")",
";",
"config",
".",
"setTemplateLoader",
"(",
"new",
"HierarchicalTemplateLoader",
"(",
"this",
",",
"new",
"BeangleClassTemplateLoader",
"(",
"null",
")",
")",
")",
";",
"}",
"// Disable freemarker localized lookup",
"config",
".",
"setLocalizedLookup",
"(",
"false",
")",
";",
"config",
".",
"setEncoding",
"(",
"config",
".",
"getLocale",
"(",
")",
",",
"\"UTF-8\"",
")",
";",
"config",
".",
"setTagSyntax",
"(",
"Configuration",
".",
"SQUARE_BRACKET_TAG_SYNTAX",
")",
";",
"// Cache one hour(7200s) and Strong cache",
"config",
".",
"setTemplateUpdateDelayMilliseconds",
"(",
"7200",
"*",
"1000",
")",
";",
"// config.setCacheStorage(new MruCacheStorage(100,250));",
"config",
".",
"setCacheStorage",
"(",
"new",
"StrongCacheStorage",
"(",
")",
")",
";",
"// Disable auto imports and includes",
"config",
".",
"setAutoImports",
"(",
"CollectUtils",
".",
"newHashMap",
"(",
")",
")",
";",
"config",
".",
"setAutoIncludes",
"(",
"CollectUtils",
".",
"newArrayList",
"(",
"0",
")",
")",
";",
"}",
"}"
]
| Clone configuration from FreemarkerManager,but custmize in
<ul>
<li>Disable freemarker localized lookup
<li>Cache two hour(7200s) and Strong cache
<li>Disable auto imports and includes
</ul> | [
"Clone",
"configuration",
"from",
"FreemarkerManager",
"but",
"custmize",
"in",
"<ul",
">",
"<li",
">",
"Disable",
"freemarker",
"localized",
"lookup",
"<li",
">",
"Cache",
"two",
"hour",
"(",
"7200s",
")",
"and",
"Strong",
"cache",
"<li",
">",
"Disable",
"auto",
"imports",
"and",
"includes",
"<",
"/",
"ul",
">"
]
| train | https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/view/template/FreemarkerTemplateEngine.java#L80-L105 |
operasoftware/operaprestodriver | src/com/opera/core/systems/preferences/OperaScopePreferences.java | OperaScopePreferences.updatePreferenceCache | private void updatePreferenceCache() {
"""
Invalidates the preferences cache stored locally in the driver and requests a new list of all
preferences from Opera. This should typically only be called the first time {@link
OperaScopePreferences} is instantiated.
Following that, whenever a preference is updated the driver will be responsible for keeping the
local cache up-to-date. The drawback of this is that if the user manually updates a preference
in Opera, this will not be reflected when {@link ScopePreference#getValue()} is run. We
circumvent that issue by fetching the value individually.
The reason for this is that we cannot fetch a single message "Pref" through Scope, but only
individual values.
"""
for (PrefsProtos.Pref pref : service.listPrefs(true, null)) {
preferences.add(new ScopePreference(this, pref));
}
} | java | private void updatePreferenceCache() {
for (PrefsProtos.Pref pref : service.listPrefs(true, null)) {
preferences.add(new ScopePreference(this, pref));
}
} | [
"private",
"void",
"updatePreferenceCache",
"(",
")",
"{",
"for",
"(",
"PrefsProtos",
".",
"Pref",
"pref",
":",
"service",
".",
"listPrefs",
"(",
"true",
",",
"null",
")",
")",
"{",
"preferences",
".",
"add",
"(",
"new",
"ScopePreference",
"(",
"this",
",",
"pref",
")",
")",
";",
"}",
"}"
]
| Invalidates the preferences cache stored locally in the driver and requests a new list of all
preferences from Opera. This should typically only be called the first time {@link
OperaScopePreferences} is instantiated.
Following that, whenever a preference is updated the driver will be responsible for keeping the
local cache up-to-date. The drawback of this is that if the user manually updates a preference
in Opera, this will not be reflected when {@link ScopePreference#getValue()} is run. We
circumvent that issue by fetching the value individually.
The reason for this is that we cannot fetch a single message "Pref" through Scope, but only
individual values. | [
"Invalidates",
"the",
"preferences",
"cache",
"stored",
"locally",
"in",
"the",
"driver",
"and",
"requests",
"a",
"new",
"list",
"of",
"all",
"preferences",
"from",
"Opera",
".",
"This",
"should",
"typically",
"only",
"be",
"called",
"the",
"first",
"time",
"{",
"@link",
"OperaScopePreferences",
"}",
"is",
"instantiated",
"."
]
| train | https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/preferences/OperaScopePreferences.java#L121-L125 |
Azure/azure-sdk-for-java | logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/WorkflowRunActionScopedRepetitionsInner.java | WorkflowRunActionScopedRepetitionsInner.getAsync | public Observable<WorkflowRunActionRepetitionDefinitionInner> getAsync(String resourceGroupName, String workflowName, String runName, String actionName, String repetitionName) {
"""
Get a workflow run action scoped repetition.
@param resourceGroupName The resource group name.
@param workflowName The workflow name.
@param runName The workflow run name.
@param actionName The workflow action name.
@param repetitionName The workflow repetition.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the WorkflowRunActionRepetitionDefinitionInner object
"""
return getWithServiceResponseAsync(resourceGroupName, workflowName, runName, actionName, repetitionName).map(new Func1<ServiceResponse<WorkflowRunActionRepetitionDefinitionInner>, WorkflowRunActionRepetitionDefinitionInner>() {
@Override
public WorkflowRunActionRepetitionDefinitionInner call(ServiceResponse<WorkflowRunActionRepetitionDefinitionInner> response) {
return response.body();
}
});
} | java | public Observable<WorkflowRunActionRepetitionDefinitionInner> getAsync(String resourceGroupName, String workflowName, String runName, String actionName, String repetitionName) {
return getWithServiceResponseAsync(resourceGroupName, workflowName, runName, actionName, repetitionName).map(new Func1<ServiceResponse<WorkflowRunActionRepetitionDefinitionInner>, WorkflowRunActionRepetitionDefinitionInner>() {
@Override
public WorkflowRunActionRepetitionDefinitionInner call(ServiceResponse<WorkflowRunActionRepetitionDefinitionInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"WorkflowRunActionRepetitionDefinitionInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"workflowName",
",",
"String",
"runName",
",",
"String",
"actionName",
",",
"String",
"repetitionName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"workflowName",
",",
"runName",
",",
"actionName",
",",
"repetitionName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"WorkflowRunActionRepetitionDefinitionInner",
">",
",",
"WorkflowRunActionRepetitionDefinitionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"WorkflowRunActionRepetitionDefinitionInner",
"call",
"(",
"ServiceResponse",
"<",
"WorkflowRunActionRepetitionDefinitionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Get a workflow run action scoped repetition.
@param resourceGroupName The resource group name.
@param workflowName The workflow name.
@param runName The workflow run name.
@param actionName The workflow action name.
@param repetitionName The workflow repetition.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the WorkflowRunActionRepetitionDefinitionInner object | [
"Get",
"a",
"workflow",
"run",
"action",
"scoped",
"repetition",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/WorkflowRunActionScopedRepetitionsInner.java#L208-L215 |
Pi4J/pi4j | pi4j-core/src/main/java/com/pi4j/jni/SerialInterrupt.java | SerialInterrupt.addListener | public static synchronized void addListener(int fileDescriptor, SerialInterruptListener listener) {
"""
<p>
Java consumer code can all this method to register itself as a listener for pin state
changes.
</p>
@see com.pi4j.jni.SerialInterruptListener
@see com.pi4j.jni.SerialInterruptEvent
@param fileDescriptor the serial file descriptor/handle
@param listener A class instance that implements the GpioInterruptListener interface.
"""
if (!listeners.containsKey(fileDescriptor)) {
listeners.put(fileDescriptor, listener);
enableSerialDataReceiveCallback(fileDescriptor);
}
} | java | public static synchronized void addListener(int fileDescriptor, SerialInterruptListener listener) {
if (!listeners.containsKey(fileDescriptor)) {
listeners.put(fileDescriptor, listener);
enableSerialDataReceiveCallback(fileDescriptor);
}
} | [
"public",
"static",
"synchronized",
"void",
"addListener",
"(",
"int",
"fileDescriptor",
",",
"SerialInterruptListener",
"listener",
")",
"{",
"if",
"(",
"!",
"listeners",
".",
"containsKey",
"(",
"fileDescriptor",
")",
")",
"{",
"listeners",
".",
"put",
"(",
"fileDescriptor",
",",
"listener",
")",
";",
"enableSerialDataReceiveCallback",
"(",
"fileDescriptor",
")",
";",
"}",
"}"
]
| <p>
Java consumer code can all this method to register itself as a listener for pin state
changes.
</p>
@see com.pi4j.jni.SerialInterruptListener
@see com.pi4j.jni.SerialInterruptEvent
@param fileDescriptor the serial file descriptor/handle
@param listener A class instance that implements the GpioInterruptListener interface. | [
"<p",
">",
"Java",
"consumer",
"code",
"can",
"all",
"this",
"method",
"to",
"register",
"itself",
"as",
"a",
"listener",
"for",
"pin",
"state",
"changes",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/Pi4J/pi4j/blob/03cacc62223cc59b3118bfcefadabab979fd84c7/pi4j-core/src/main/java/com/pi4j/jni/SerialInterrupt.java#L128-L133 |
m-m-m/util | validation/src/main/java/net/sf/mmm/util/validation/base/collection/AbstractMapValidatorBuilder.java | AbstractMapValidatorBuilder.withValues | public <SUB extends ObjectValidatorBuilder<V, ? extends SELF, ?>> SUB withValues(BiFunction<ObjectValidatorBuilderFactory<SELF>, V, SUB> factory) {
"""
Creates a new {@link ObjectValidatorBuilder builder} for the {@link AbstractValidator validators} to invoke for
each {@link Map#values() values} in the {@link Map}.<br/>
Use {@link #and()} to return to this builder after the sub-builder is complete.<br/>
A typical usage looks like this:
<pre>
[...].withValues((f, v) -> f.create(v)).[...].and().[...].build()
</pre>
@param <SUB> the generic type of the returned sub-builder.
@param factory lambda function used to create the returned sub-builder by calling the according {@code create}
method on the supplied {@link ObjectValidatorBuilderFactory} with the given dummy element.
@return the new sub-builder.
"""
if (this.valueSubBuilder != null) {
throw new IllegalStateException("valueSubBuilder already exists!");
}
SUB sub = factory.apply(getSubFactory(), null);
this.valueSubBuilder = sub;
return sub;
} | java | public <SUB extends ObjectValidatorBuilder<V, ? extends SELF, ?>> SUB withValues(BiFunction<ObjectValidatorBuilderFactory<SELF>, V, SUB> factory) {
if (this.valueSubBuilder != null) {
throw new IllegalStateException("valueSubBuilder already exists!");
}
SUB sub = factory.apply(getSubFactory(), null);
this.valueSubBuilder = sub;
return sub;
} | [
"public",
"<",
"SUB",
"extends",
"ObjectValidatorBuilder",
"<",
"V",
",",
"?",
"extends",
"SELF",
",",
"?",
">",
">",
"SUB",
"withValues",
"(",
"BiFunction",
"<",
"ObjectValidatorBuilderFactory",
"<",
"SELF",
">",
",",
"V",
",",
"SUB",
">",
"factory",
")",
"{",
"if",
"(",
"this",
".",
"valueSubBuilder",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"valueSubBuilder already exists!\"",
")",
";",
"}",
"SUB",
"sub",
"=",
"factory",
".",
"apply",
"(",
"getSubFactory",
"(",
")",
",",
"null",
")",
";",
"this",
".",
"valueSubBuilder",
"=",
"sub",
";",
"return",
"sub",
";",
"}"
]
| Creates a new {@link ObjectValidatorBuilder builder} for the {@link AbstractValidator validators} to invoke for
each {@link Map#values() values} in the {@link Map}.<br/>
Use {@link #and()} to return to this builder after the sub-builder is complete.<br/>
A typical usage looks like this:
<pre>
[...].withValues((f, v) -> f.create(v)).[...].and().[...].build()
</pre>
@param <SUB> the generic type of the returned sub-builder.
@param factory lambda function used to create the returned sub-builder by calling the according {@code create}
method on the supplied {@link ObjectValidatorBuilderFactory} with the given dummy element.
@return the new sub-builder. | [
"Creates",
"a",
"new",
"{",
"@link",
"ObjectValidatorBuilder",
"builder",
"}",
"for",
"the",
"{",
"@link",
"AbstractValidator",
"validators",
"}",
"to",
"invoke",
"for",
"each",
"{",
"@link",
"Map#values",
"()",
"values",
"}",
"in",
"the",
"{",
"@link",
"Map",
"}",
".",
"<br",
"/",
">",
"Use",
"{",
"@link",
"#and",
"()",
"}",
"to",
"return",
"to",
"this",
"builder",
"after",
"the",
"sub",
"-",
"builder",
"is",
"complete",
".",
"<br",
"/",
">",
"A",
"typical",
"usage",
"looks",
"like",
"this",
":"
]
| train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/validation/src/main/java/net/sf/mmm/util/validation/base/collection/AbstractMapValidatorBuilder.java#L116-L124 |
before/quality-check | modules/quality-check/src/main/java/net/sf/qualitycheck/Check.java | Check.greaterThan | @ArgumentsChecked
@Throws( {
"""
Ensures that a passed {@code Comparable} is greater than another {@code Comparable}. The comparison is made using
{@code expected.compareTo(check) >= 0}.
@param expected
Expected value
@param check
Comparable to be checked
@param message
an error message describing why the comparable must be greater than a value (will be passed to
{@code IllegalNotGreaterThanException})
@return the passed {@code Comparable} argument {@code check}
@throws IllegalNotGreaterThanException
if the argument value {@code check} is not greater than value {@code expected} when using method
{@code compareTo}
""" IllegalNullArgumentException.class, IllegalNotGreaterThanException.class })
public static <T extends Comparable<T>> T greaterThan(@Nonnull final T expected, @Nonnull final T check, @Nonnull final String message) {
Check.notNull(expected, "expected");
Check.notNull(check, "check");
if (expected.compareTo(check) >= 0) {
throw new IllegalNotGreaterThanException(message, check);
}
return check;
} | java | @ArgumentsChecked
@Throws({ IllegalNullArgumentException.class, IllegalNotGreaterThanException.class })
public static <T extends Comparable<T>> T greaterThan(@Nonnull final T expected, @Nonnull final T check, @Nonnull final String message) {
Check.notNull(expected, "expected");
Check.notNull(check, "check");
if (expected.compareTo(check) >= 0) {
throw new IllegalNotGreaterThanException(message, check);
}
return check;
} | [
"@",
"ArgumentsChecked",
"@",
"Throws",
"(",
"{",
"IllegalNullArgumentException",
".",
"class",
",",
"IllegalNotGreaterThanException",
".",
"class",
"}",
")",
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"T",
">",
">",
"T",
"greaterThan",
"(",
"@",
"Nonnull",
"final",
"T",
"expected",
",",
"@",
"Nonnull",
"final",
"T",
"check",
",",
"@",
"Nonnull",
"final",
"String",
"message",
")",
"{",
"Check",
".",
"notNull",
"(",
"expected",
",",
"\"expected\"",
")",
";",
"Check",
".",
"notNull",
"(",
"check",
",",
"\"check\"",
")",
";",
"if",
"(",
"expected",
".",
"compareTo",
"(",
"check",
")",
">=",
"0",
")",
"{",
"throw",
"new",
"IllegalNotGreaterThanException",
"(",
"message",
",",
"check",
")",
";",
"}",
"return",
"check",
";",
"}"
]
| Ensures that a passed {@code Comparable} is greater than another {@code Comparable}. The comparison is made using
{@code expected.compareTo(check) >= 0}.
@param expected
Expected value
@param check
Comparable to be checked
@param message
an error message describing why the comparable must be greater than a value (will be passed to
{@code IllegalNotGreaterThanException})
@return the passed {@code Comparable} argument {@code check}
@throws IllegalNotGreaterThanException
if the argument value {@code check} is not greater than value {@code expected} when using method
{@code compareTo} | [
"Ensures",
"that",
"a",
"passed",
"{",
"@code",
"Comparable",
"}",
"is",
"greater",
"than",
"another",
"{",
"@code",
"Comparable",
"}",
".",
"The",
"comparison",
"is",
"made",
"using",
"{",
"@code",
"expected",
".",
"compareTo",
"(",
"check",
")",
">",
"=",
"0",
"}",
"."
]
| train | https://github.com/before/quality-check/blob/a75c32c39434ddb1f89bece57acae0536724c15a/modules/quality-check/src/main/java/net/sf/qualitycheck/Check.java#L1092-L1103 |
VoltDB/voltdb | src/frontend/org/voltdb/utils/VoltTrace.java | VoltTrace.beginAsync | public static TraceEvent beginAsync(String name, Object id, Object... args) {
"""
Creates a begin async trace event. This method does not queue the
event. Call {@link TraceEventBatch#add(Supplier)} to queue the event.
"""
return new TraceEvent(TraceEventType.ASYNC_BEGIN, name, String.valueOf(id), args);
} | java | public static TraceEvent beginAsync(String name, Object id, Object... args) {
return new TraceEvent(TraceEventType.ASYNC_BEGIN, name, String.valueOf(id), args);
} | [
"public",
"static",
"TraceEvent",
"beginAsync",
"(",
"String",
"name",
",",
"Object",
"id",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"TraceEvent",
"(",
"TraceEventType",
".",
"ASYNC_BEGIN",
",",
"name",
",",
"String",
".",
"valueOf",
"(",
"id",
")",
",",
"args",
")",
";",
"}"
]
| Creates a begin async trace event. This method does not queue the
event. Call {@link TraceEventBatch#add(Supplier)} to queue the event. | [
"Creates",
"a",
"begin",
"async",
"trace",
"event",
".",
"This",
"method",
"does",
"not",
"queue",
"the",
"event",
".",
"Call",
"{"
]
| train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTrace.java#L489-L491 |
jaxio/celerio | celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java | IOUtil.inputStreamToString | public String inputStreamToString(InputStream is, String charset) throws IOException {
"""
Write to a string the bytes read from an input stream.
@param charset the charset used to read the input stream
@return the inputstream as a string
"""
InputStreamReader isr = null;
if (null == charset) {
isr = new InputStreamReader(is);
} else {
isr = new InputStreamReader(is, charset);
}
StringWriter sw = new StringWriter();
int c = -1;
while ((c = isr.read()) != -1) {
sw.write(c);
}
isr.close();
return sw.getBuffer().toString();
} | java | public String inputStreamToString(InputStream is, String charset) throws IOException {
InputStreamReader isr = null;
if (null == charset) {
isr = new InputStreamReader(is);
} else {
isr = new InputStreamReader(is, charset);
}
StringWriter sw = new StringWriter();
int c = -1;
while ((c = isr.read()) != -1) {
sw.write(c);
}
isr.close();
return sw.getBuffer().toString();
} | [
"public",
"String",
"inputStreamToString",
"(",
"InputStream",
"is",
",",
"String",
"charset",
")",
"throws",
"IOException",
"{",
"InputStreamReader",
"isr",
"=",
"null",
";",
"if",
"(",
"null",
"==",
"charset",
")",
"{",
"isr",
"=",
"new",
"InputStreamReader",
"(",
"is",
")",
";",
"}",
"else",
"{",
"isr",
"=",
"new",
"InputStreamReader",
"(",
"is",
",",
"charset",
")",
";",
"}",
"StringWriter",
"sw",
"=",
"new",
"StringWriter",
"(",
")",
";",
"int",
"c",
"=",
"-",
"1",
";",
"while",
"(",
"(",
"c",
"=",
"isr",
".",
"read",
"(",
")",
")",
"!=",
"-",
"1",
")",
"{",
"sw",
".",
"write",
"(",
"c",
")",
";",
"}",
"isr",
".",
"close",
"(",
")",
";",
"return",
"sw",
".",
"getBuffer",
"(",
")",
".",
"toString",
"(",
")",
";",
"}"
]
| Write to a string the bytes read from an input stream.
@param charset the charset used to read the input stream
@return the inputstream as a string | [
"Write",
"to",
"a",
"string",
"the",
"bytes",
"read",
"from",
"an",
"input",
"stream",
"."
]
| train | https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/util/IOUtil.java#L124-L138 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ImageModerationsImpl.java | ImageModerationsImpl.matchUrlInputWithServiceResponseAsync | public Observable<ServiceResponse<MatchResponse>> matchUrlInputWithServiceResponseAsync(String contentType, BodyModelModel imageUrl, MatchUrlInputOptionalParameter matchUrlInputOptionalParameter) {
"""
Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a> API.
Returns ID and tags of matching image.<br/>
<br/>
Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
@param contentType The content type.
@param imageUrl The image url.
@param matchUrlInputOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the MatchResponse object
"""
if (this.client.baseUrl() == null) {
throw new IllegalArgumentException("Parameter this.client.baseUrl() is required and cannot be null.");
}
if (contentType == null) {
throw new IllegalArgumentException("Parameter contentType is required and cannot be null.");
}
if (imageUrl == null) {
throw new IllegalArgumentException("Parameter imageUrl is required and cannot be null.");
}
Validator.validate(imageUrl);
final String listId = matchUrlInputOptionalParameter != null ? matchUrlInputOptionalParameter.listId() : null;
final Boolean cacheImage = matchUrlInputOptionalParameter != null ? matchUrlInputOptionalParameter.cacheImage() : null;
return matchUrlInputWithServiceResponseAsync(contentType, imageUrl, listId, cacheImage);
} | java | public Observable<ServiceResponse<MatchResponse>> matchUrlInputWithServiceResponseAsync(String contentType, BodyModelModel imageUrl, MatchUrlInputOptionalParameter matchUrlInputOptionalParameter) {
if (this.client.baseUrl() == null) {
throw new IllegalArgumentException("Parameter this.client.baseUrl() is required and cannot be null.");
}
if (contentType == null) {
throw new IllegalArgumentException("Parameter contentType is required and cannot be null.");
}
if (imageUrl == null) {
throw new IllegalArgumentException("Parameter imageUrl is required and cannot be null.");
}
Validator.validate(imageUrl);
final String listId = matchUrlInputOptionalParameter != null ? matchUrlInputOptionalParameter.listId() : null;
final Boolean cacheImage = matchUrlInputOptionalParameter != null ? matchUrlInputOptionalParameter.cacheImage() : null;
return matchUrlInputWithServiceResponseAsync(contentType, imageUrl, listId, cacheImage);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"MatchResponse",
">",
">",
"matchUrlInputWithServiceResponseAsync",
"(",
"String",
"contentType",
",",
"BodyModelModel",
"imageUrl",
",",
"MatchUrlInputOptionalParameter",
"matchUrlInputOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"baseUrl",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.baseUrl() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"contentType",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter contentType is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"imageUrl",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter imageUrl is required and cannot be null.\"",
")",
";",
"}",
"Validator",
".",
"validate",
"(",
"imageUrl",
")",
";",
"final",
"String",
"listId",
"=",
"matchUrlInputOptionalParameter",
"!=",
"null",
"?",
"matchUrlInputOptionalParameter",
".",
"listId",
"(",
")",
":",
"null",
";",
"final",
"Boolean",
"cacheImage",
"=",
"matchUrlInputOptionalParameter",
"!=",
"null",
"?",
"matchUrlInputOptionalParameter",
".",
"cacheImage",
"(",
")",
":",
"null",
";",
"return",
"matchUrlInputWithServiceResponseAsync",
"(",
"contentType",
",",
"imageUrl",
",",
"listId",
",",
"cacheImage",
")",
";",
"}"
]
| Fuzzily match an image against one of your custom Image Lists. You can create and manage your custom image lists using <a href="/docs/services/578ff44d2703741568569ab9/operations/578ff7b12703741568569abe">this</a> API.
Returns ID and tags of matching image.<br/>
<br/>
Note: Refresh Index must be run on the corresponding Image List before additions and removals are reflected in the response.
@param contentType The content type.
@param imageUrl The image url.
@param matchUrlInputOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the MatchResponse object | [
"Fuzzily",
"match",
"an",
"image",
"against",
"one",
"of",
"your",
"custom",
"Image",
"Lists",
".",
"You",
"can",
"create",
"and",
"manage",
"your",
"custom",
"image",
"lists",
"using",
"<",
";",
"a",
"href",
"=",
"/",
"docs",
"/",
"services",
"/",
"578ff44d2703741568569ab9",
"/",
"operations",
"/",
"578ff7b12703741568569abe",
">",
";",
"this<",
";",
"/",
"a>",
";",
"API",
".",
"Returns",
"ID",
"and",
"tags",
"of",
"matching",
"image",
".",
"<",
";",
"br",
"/",
">",
";",
"<",
";",
"br",
"/",
">",
";",
"Note",
":",
"Refresh",
"Index",
"must",
"be",
"run",
"on",
"the",
"corresponding",
"Image",
"List",
"before",
"additions",
"and",
"removals",
"are",
"reflected",
"in",
"the",
"response",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ImageModerationsImpl.java#L1807-L1822 |
sebastiangraf/jSCSI | bundles/initiator/src/main/java/org/jscsi/initiator/Configuration.java | Configuration.getSettings | public final SettingsMap getSettings (final String targetName, final int connectionID) {
"""
Unifies all parameters (in the right precedence) and returns one <code>SettingsMap</code>. Right order means:
default, then the session-wide, and finally the connection-wide valid parameters.
@param targetName Name of the iSCSI Target to connect.
@param connectionID The ID of the connection to retrieve.
@return All unified parameters in one single <code>SettingsMap</code>.
"""
final SettingsMap sm = new SettingsMap();
// set all default settings
synchronized (globalConfig) {
for (Map.Entry<OperationalTextKey , SettingEntry> e : globalConfig.entrySet()) {
sm.add(e.getKey(), e.getValue().getValue());
}
}
// set all further settings
final SessionConfiguration sc;
synchronized (sessionConfigs) {
sc = sessionConfigs.get(targetName);
synchronized (sc) {
if (sc != null) {
final SettingsMap furtherSettings = sc.getSettings(connectionID);
for (Map.Entry<OperationalTextKey , String> e : furtherSettings.entrySet()) {
sm.add(e.getKey(), e.getValue());
}
}
}
}
return sm;
} | java | public final SettingsMap getSettings (final String targetName, final int connectionID) {
final SettingsMap sm = new SettingsMap();
// set all default settings
synchronized (globalConfig) {
for (Map.Entry<OperationalTextKey , SettingEntry> e : globalConfig.entrySet()) {
sm.add(e.getKey(), e.getValue().getValue());
}
}
// set all further settings
final SessionConfiguration sc;
synchronized (sessionConfigs) {
sc = sessionConfigs.get(targetName);
synchronized (sc) {
if (sc != null) {
final SettingsMap furtherSettings = sc.getSettings(connectionID);
for (Map.Entry<OperationalTextKey , String> e : furtherSettings.entrySet()) {
sm.add(e.getKey(), e.getValue());
}
}
}
}
return sm;
} | [
"public",
"final",
"SettingsMap",
"getSettings",
"(",
"final",
"String",
"targetName",
",",
"final",
"int",
"connectionID",
")",
"{",
"final",
"SettingsMap",
"sm",
"=",
"new",
"SettingsMap",
"(",
")",
";",
"// set all default settings",
"synchronized",
"(",
"globalConfig",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"OperationalTextKey",
",",
"SettingEntry",
">",
"e",
":",
"globalConfig",
".",
"entrySet",
"(",
")",
")",
"{",
"sm",
".",
"add",
"(",
"e",
".",
"getKey",
"(",
")",
",",
"e",
".",
"getValue",
"(",
")",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"// set all further settings",
"final",
"SessionConfiguration",
"sc",
";",
"synchronized",
"(",
"sessionConfigs",
")",
"{",
"sc",
"=",
"sessionConfigs",
".",
"get",
"(",
"targetName",
")",
";",
"synchronized",
"(",
"sc",
")",
"{",
"if",
"(",
"sc",
"!=",
"null",
")",
"{",
"final",
"SettingsMap",
"furtherSettings",
"=",
"sc",
".",
"getSettings",
"(",
"connectionID",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"OperationalTextKey",
",",
"String",
">",
"e",
":",
"furtherSettings",
".",
"entrySet",
"(",
")",
")",
"{",
"sm",
".",
"add",
"(",
"e",
".",
"getKey",
"(",
")",
",",
"e",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"sm",
";",
"}"
]
| Unifies all parameters (in the right precedence) and returns one <code>SettingsMap</code>. Right order means:
default, then the session-wide, and finally the connection-wide valid parameters.
@param targetName Name of the iSCSI Target to connect.
@param connectionID The ID of the connection to retrieve.
@return All unified parameters in one single <code>SettingsMap</code>. | [
"Unifies",
"all",
"parameters",
"(",
"in",
"the",
"right",
"precedence",
")",
"and",
"returns",
"one",
"<code",
">",
"SettingsMap<",
"/",
"code",
">",
".",
"Right",
"order",
"means",
":",
"default",
"then",
"the",
"session",
"-",
"wide",
"and",
"finally",
"the",
"connection",
"-",
"wide",
"valid",
"parameters",
"."
]
| train | https://github.com/sebastiangraf/jSCSI/blob/6169bfe73f0b15de7d6485453555389e782ae888/bundles/initiator/src/main/java/org/jscsi/initiator/Configuration.java#L245-L272 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/plugins/BaseScriptPlugin.java | BaseScriptPlugin.createScriptArgsList | protected ExecArgList createScriptArgsList(final Map<String, Map<String, String>> dataContext) {
"""
Create the command array for the data context.
@param dataContext data
@return arglist
"""
final ScriptPluginProvider plugin = getProvider();
final File scriptfile = plugin.getScriptFile();
final String scriptargs = null != plugin.getScriptArgs() ?
DataContextUtils.replaceDataReferencesInString(plugin.getScriptArgs(), dataContext) :
null;
final String[] scriptargsarr = null!=plugin.getScriptArgsArray() ?
DataContextUtils.replaceDataReferencesInArray(plugin.getScriptArgsArray(), dataContext) :
null;
final String scriptinterpreter = plugin.getScriptInterpreter();
final boolean interpreterargsquoted = plugin.getInterpreterArgsQuoted();
return getScriptExecHelper().createScriptArgList(scriptfile.getAbsolutePath(),
scriptargs, scriptargsarr, scriptinterpreter, interpreterargsquoted);
} | java | protected ExecArgList createScriptArgsList(final Map<String, Map<String, String>> dataContext) {
final ScriptPluginProvider plugin = getProvider();
final File scriptfile = plugin.getScriptFile();
final String scriptargs = null != plugin.getScriptArgs() ?
DataContextUtils.replaceDataReferencesInString(plugin.getScriptArgs(), dataContext) :
null;
final String[] scriptargsarr = null!=plugin.getScriptArgsArray() ?
DataContextUtils.replaceDataReferencesInArray(plugin.getScriptArgsArray(), dataContext) :
null;
final String scriptinterpreter = plugin.getScriptInterpreter();
final boolean interpreterargsquoted = plugin.getInterpreterArgsQuoted();
return getScriptExecHelper().createScriptArgList(scriptfile.getAbsolutePath(),
scriptargs, scriptargsarr, scriptinterpreter, interpreterargsquoted);
} | [
"protected",
"ExecArgList",
"createScriptArgsList",
"(",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"dataContext",
")",
"{",
"final",
"ScriptPluginProvider",
"plugin",
"=",
"getProvider",
"(",
")",
";",
"final",
"File",
"scriptfile",
"=",
"plugin",
".",
"getScriptFile",
"(",
")",
";",
"final",
"String",
"scriptargs",
"=",
"null",
"!=",
"plugin",
".",
"getScriptArgs",
"(",
")",
"?",
"DataContextUtils",
".",
"replaceDataReferencesInString",
"(",
"plugin",
".",
"getScriptArgs",
"(",
")",
",",
"dataContext",
")",
":",
"null",
";",
"final",
"String",
"[",
"]",
"scriptargsarr",
"=",
"null",
"!=",
"plugin",
".",
"getScriptArgsArray",
"(",
")",
"?",
"DataContextUtils",
".",
"replaceDataReferencesInArray",
"(",
"plugin",
".",
"getScriptArgsArray",
"(",
")",
",",
"dataContext",
")",
":",
"null",
";",
"final",
"String",
"scriptinterpreter",
"=",
"plugin",
".",
"getScriptInterpreter",
"(",
")",
";",
"final",
"boolean",
"interpreterargsquoted",
"=",
"plugin",
".",
"getInterpreterArgsQuoted",
"(",
")",
";",
"return",
"getScriptExecHelper",
"(",
")",
".",
"createScriptArgList",
"(",
"scriptfile",
".",
"getAbsolutePath",
"(",
")",
",",
"scriptargs",
",",
"scriptargsarr",
",",
"scriptinterpreter",
",",
"interpreterargsquoted",
")",
";",
"}"
]
| Create the command array for the data context.
@param dataContext data
@return arglist | [
"Create",
"the",
"command",
"array",
"for",
"the",
"data",
"context",
"."
]
| train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/BaseScriptPlugin.java#L198-L214 |
samskivert/pythagoras | src/main/java/pythagoras/d/QuadCurve.java | QuadCurve.setCurve | public void setCurve (XY[] points, int offset) {
"""
Configures the start, control, and end points for this curve, using the values at the
specified offset in the {@code points} array.
"""
setCurve(points[offset + 0].x(), points[offset + 0].y(),
points[offset + 1].x(), points[offset + 1].y(),
points[offset + 2].x(), points[offset + 2].y());
} | java | public void setCurve (XY[] points, int offset) {
setCurve(points[offset + 0].x(), points[offset + 0].y(),
points[offset + 1].x(), points[offset + 1].y(),
points[offset + 2].x(), points[offset + 2].y());
} | [
"public",
"void",
"setCurve",
"(",
"XY",
"[",
"]",
"points",
",",
"int",
"offset",
")",
"{",
"setCurve",
"(",
"points",
"[",
"offset",
"+",
"0",
"]",
".",
"x",
"(",
")",
",",
"points",
"[",
"offset",
"+",
"0",
"]",
".",
"y",
"(",
")",
",",
"points",
"[",
"offset",
"+",
"1",
"]",
".",
"x",
"(",
")",
",",
"points",
"[",
"offset",
"+",
"1",
"]",
".",
"y",
"(",
")",
",",
"points",
"[",
"offset",
"+",
"2",
"]",
".",
"x",
"(",
")",
",",
"points",
"[",
"offset",
"+",
"2",
"]",
".",
"y",
"(",
")",
")",
";",
"}"
]
| Configures the start, control, and end points for this curve, using the values at the
specified offset in the {@code points} array. | [
"Configures",
"the",
"start",
"control",
"and",
"end",
"points",
"for",
"this",
"curve",
"using",
"the",
"values",
"at",
"the",
"specified",
"offset",
"in",
"the",
"{"
]
| train | https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/d/QuadCurve.java#L80-L84 |
prestodb/presto | presto-main/src/main/java/com/facebook/presto/execution/ClusterSizeMonitor.java | ClusterSizeMonitor.waitForMinimumWorkers | public synchronized ListenableFuture<?> waitForMinimumWorkers() {
"""
Returns a listener that completes when the minimum number of workers for the cluster has been met.
Note: caller should not add a listener using the direct executor, as this can delay the
notifications for other listeners.
"""
if (currentCount >= executionMinCount) {
return immediateFuture(null);
}
SettableFuture<?> future = SettableFuture.create();
futures.add(future);
// if future does not finish in wait period, complete with an exception
ScheduledFuture<?> timeoutTask = executor.schedule(
() -> {
synchronized (this) {
future.setException(new PrestoException(
GENERIC_INSUFFICIENT_RESOURCES,
format("Insufficient active worker nodes. Waited %s for at least %s workers, but only %s workers are active", executionMaxWait, executionMinCount, currentCount)));
}
},
executionMaxWait.toMillis(),
MILLISECONDS);
// remove future if finished (e.g., canceled, timed out)
future.addListener(() -> {
timeoutTask.cancel(true);
removeFuture(future);
}, executor);
return future;
} | java | public synchronized ListenableFuture<?> waitForMinimumWorkers()
{
if (currentCount >= executionMinCount) {
return immediateFuture(null);
}
SettableFuture<?> future = SettableFuture.create();
futures.add(future);
// if future does not finish in wait period, complete with an exception
ScheduledFuture<?> timeoutTask = executor.schedule(
() -> {
synchronized (this) {
future.setException(new PrestoException(
GENERIC_INSUFFICIENT_RESOURCES,
format("Insufficient active worker nodes. Waited %s for at least %s workers, but only %s workers are active", executionMaxWait, executionMinCount, currentCount)));
}
},
executionMaxWait.toMillis(),
MILLISECONDS);
// remove future if finished (e.g., canceled, timed out)
future.addListener(() -> {
timeoutTask.cancel(true);
removeFuture(future);
}, executor);
return future;
} | [
"public",
"synchronized",
"ListenableFuture",
"<",
"?",
">",
"waitForMinimumWorkers",
"(",
")",
"{",
"if",
"(",
"currentCount",
">=",
"executionMinCount",
")",
"{",
"return",
"immediateFuture",
"(",
"null",
")",
";",
"}",
"SettableFuture",
"<",
"?",
">",
"future",
"=",
"SettableFuture",
".",
"create",
"(",
")",
";",
"futures",
".",
"add",
"(",
"future",
")",
";",
"// if future does not finish in wait period, complete with an exception",
"ScheduledFuture",
"<",
"?",
">",
"timeoutTask",
"=",
"executor",
".",
"schedule",
"(",
"(",
")",
"->",
"{",
"synchronized",
"(",
"this",
")",
"{",
"future",
".",
"setException",
"(",
"new",
"PrestoException",
"(",
"GENERIC_INSUFFICIENT_RESOURCES",
",",
"format",
"(",
"\"Insufficient active worker nodes. Waited %s for at least %s workers, but only %s workers are active\"",
",",
"executionMaxWait",
",",
"executionMinCount",
",",
"currentCount",
")",
")",
")",
";",
"}",
"}",
",",
"executionMaxWait",
".",
"toMillis",
"(",
")",
",",
"MILLISECONDS",
")",
";",
"// remove future if finished (e.g., canceled, timed out)",
"future",
".",
"addListener",
"(",
"(",
")",
"->",
"{",
"timeoutTask",
".",
"cancel",
"(",
"true",
")",
";",
"removeFuture",
"(",
"future",
")",
";",
"}",
",",
"executor",
")",
";",
"return",
"future",
";",
"}"
]
| Returns a listener that completes when the minimum number of workers for the cluster has been met.
Note: caller should not add a listener using the direct executor, as this can delay the
notifications for other listeners. | [
"Returns",
"a",
"listener",
"that",
"completes",
"when",
"the",
"minimum",
"number",
"of",
"workers",
"for",
"the",
"cluster",
"has",
"been",
"met",
".",
"Note",
":",
"caller",
"should",
"not",
"add",
"a",
"listener",
"using",
"the",
"direct",
"executor",
"as",
"this",
"can",
"delay",
"the",
"notifications",
"for",
"other",
"listeners",
"."
]
| train | https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-main/src/main/java/com/facebook/presto/execution/ClusterSizeMonitor.java#L132-L160 |
actframework/actframework | src/main/java/act/event/EventBus.java | EventBus.trace | @Override
protected void trace(String msg, Object... args) {
"""
Override parent implementation so that if this
event bus is a one time event bus, it will prepend
`[once]` into the message been logged
@param msg
the message
@param args
the message arguments
"""
msg = S.fmt(msg, args);
if (once) {
msg = S.builder("[once]").append(msg).toString();
}
super.trace(msg);
} | java | @Override
protected void trace(String msg, Object... args) {
msg = S.fmt(msg, args);
if (once) {
msg = S.builder("[once]").append(msg).toString();
}
super.trace(msg);
} | [
"@",
"Override",
"protected",
"void",
"trace",
"(",
"String",
"msg",
",",
"Object",
"...",
"args",
")",
"{",
"msg",
"=",
"S",
".",
"fmt",
"(",
"msg",
",",
"args",
")",
";",
"if",
"(",
"once",
")",
"{",
"msg",
"=",
"S",
".",
"builder",
"(",
"\"[once]\"",
")",
".",
"append",
"(",
"msg",
")",
".",
"toString",
"(",
")",
";",
"}",
"super",
".",
"trace",
"(",
"msg",
")",
";",
"}"
]
| Override parent implementation so that if this
event bus is a one time event bus, it will prepend
`[once]` into the message been logged
@param msg
the message
@param args
the message arguments | [
"Override",
"parent",
"implementation",
"so",
"that",
"if",
"this",
"event",
"bus",
"is",
"a",
"one",
"time",
"event",
"bus",
"it",
"will",
"prepend",
"[",
"once",
"]",
"into",
"the",
"message",
"been",
"logged"
]
| train | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/event/EventBus.java#L587-L594 |
cdk/cdk | descriptor/qsar/src/main/java/org/openscience/cdk/qsar/AbstractAtomicDescriptor.java | AbstractAtomicDescriptor.cacheDescriptorValue | public void cacheDescriptorValue(IAtom atom, IAtomContainer container, IDescriptorResult value) {
"""
Caches a DescriptorValue for a given IAtom. This method may only
be called after setNewContainer() is called.
@param atom IAtom to cache the value for
@param value DescriptorValue for the given IAtom
"""
if (cachedDescriptorValues == null) {
cachedDescriptorValues = new HashMap();
cachedDescriptorValues.put(PREVIOUS_ATOMCONTAINER, container);
} else if (cachedDescriptorValues.get(PREVIOUS_ATOMCONTAINER) != container) {
cachedDescriptorValues.clear();
cachedDescriptorValues.put(PREVIOUS_ATOMCONTAINER, container);
}
cachedDescriptorValues.put(atom, value);
} | java | public void cacheDescriptorValue(IAtom atom, IAtomContainer container, IDescriptorResult value) {
if (cachedDescriptorValues == null) {
cachedDescriptorValues = new HashMap();
cachedDescriptorValues.put(PREVIOUS_ATOMCONTAINER, container);
} else if (cachedDescriptorValues.get(PREVIOUS_ATOMCONTAINER) != container) {
cachedDescriptorValues.clear();
cachedDescriptorValues.put(PREVIOUS_ATOMCONTAINER, container);
}
cachedDescriptorValues.put(atom, value);
} | [
"public",
"void",
"cacheDescriptorValue",
"(",
"IAtom",
"atom",
",",
"IAtomContainer",
"container",
",",
"IDescriptorResult",
"value",
")",
"{",
"if",
"(",
"cachedDescriptorValues",
"==",
"null",
")",
"{",
"cachedDescriptorValues",
"=",
"new",
"HashMap",
"(",
")",
";",
"cachedDescriptorValues",
".",
"put",
"(",
"PREVIOUS_ATOMCONTAINER",
",",
"container",
")",
";",
"}",
"else",
"if",
"(",
"cachedDescriptorValues",
".",
"get",
"(",
"PREVIOUS_ATOMCONTAINER",
")",
"!=",
"container",
")",
"{",
"cachedDescriptorValues",
".",
"clear",
"(",
")",
";",
"cachedDescriptorValues",
".",
"put",
"(",
"PREVIOUS_ATOMCONTAINER",
",",
"container",
")",
";",
"}",
"cachedDescriptorValues",
".",
"put",
"(",
"atom",
",",
"value",
")",
";",
"}"
]
| Caches a DescriptorValue for a given IAtom. This method may only
be called after setNewContainer() is called.
@param atom IAtom to cache the value for
@param value DescriptorValue for the given IAtom | [
"Caches",
"a",
"DescriptorValue",
"for",
"a",
"given",
"IAtom",
".",
"This",
"method",
"may",
"only",
"be",
"called",
"after",
"setNewContainer",
"()",
"is",
"called",
"."
]
| train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/descriptor/qsar/src/main/java/org/openscience/cdk/qsar/AbstractAtomicDescriptor.java#L72-L81 |
airbnb/lottie-android | lottie/src/main/java/com/airbnb/lottie/model/KeyPath.java | KeyPath.incrementDepthBy | @RestrictTo(RestrictTo.Scope.LIBRARY)
public int incrementDepthBy(String key, int depth) {
"""
For a given key and depth, returns how much the depth should be incremented by when
resolving a keypath to children.
This can be 0 or 2 when there is a globstar and the next key either matches or doesn't match
the current key.
"""
if (isContainer(key)) {
// If it's a container then we added programatically and it isn't a part of the keypath.
return 0;
}
if (!keys.get(depth).equals("**")) {
// If it's not a globstar then it is part of the keypath.
return 1;
}
if (depth == keys.size() - 1) {
// The last key is a globstar.
return 0;
}
if (keys.get(depth + 1).equals(key)) {
// We are a globstar and the next key is our current key so consume both.
return 2;
}
return 0;
} | java | @RestrictTo(RestrictTo.Scope.LIBRARY)
public int incrementDepthBy(String key, int depth) {
if (isContainer(key)) {
// If it's a container then we added programatically and it isn't a part of the keypath.
return 0;
}
if (!keys.get(depth).equals("**")) {
// If it's not a globstar then it is part of the keypath.
return 1;
}
if (depth == keys.size() - 1) {
// The last key is a globstar.
return 0;
}
if (keys.get(depth + 1).equals(key)) {
// We are a globstar and the next key is our current key so consume both.
return 2;
}
return 0;
} | [
"@",
"RestrictTo",
"(",
"RestrictTo",
".",
"Scope",
".",
"LIBRARY",
")",
"public",
"int",
"incrementDepthBy",
"(",
"String",
"key",
",",
"int",
"depth",
")",
"{",
"if",
"(",
"isContainer",
"(",
"key",
")",
")",
"{",
"// If it's a container then we added programatically and it isn't a part of the keypath.",
"return",
"0",
";",
"}",
"if",
"(",
"!",
"keys",
".",
"get",
"(",
"depth",
")",
".",
"equals",
"(",
"\"**\"",
")",
")",
"{",
"// If it's not a globstar then it is part of the keypath.",
"return",
"1",
";",
"}",
"if",
"(",
"depth",
"==",
"keys",
".",
"size",
"(",
")",
"-",
"1",
")",
"{",
"// The last key is a globstar.",
"return",
"0",
";",
"}",
"if",
"(",
"keys",
".",
"get",
"(",
"depth",
"+",
"1",
")",
".",
"equals",
"(",
"key",
")",
")",
"{",
"// We are a globstar and the next key is our current key so consume both.",
"return",
"2",
";",
"}",
"return",
"0",
";",
"}"
]
| For a given key and depth, returns how much the depth should be incremented by when
resolving a keypath to children.
This can be 0 or 2 when there is a globstar and the next key either matches or doesn't match
the current key. | [
"For",
"a",
"given",
"key",
"and",
"depth",
"returns",
"how",
"much",
"the",
"depth",
"should",
"be",
"incremented",
"by",
"when",
"resolving",
"a",
"keypath",
"to",
"children",
"."
]
| train | https://github.com/airbnb/lottie-android/blob/126dabdc9f586c87822f85fe1128cdad439d30fa/lottie/src/main/java/com/airbnb/lottie/model/KeyPath.java#L123-L142 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.