repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java | ClassBuilder.buildClassInfo | public void buildClassInfo(XMLNode node, Content classContentTree) {
"""
Build the class information tree documentation.
@param node the XML element that specifies which components to document
@param classContentTree the content tree to which the documentation will be added
"""
Content classInfoTree = writer.getClassInfoTreeHeader();
buildChildren(node, classInfoTree);
classContentTree.addContent(writer.getClassInfo(classInfoTree));
} | java | public void buildClassInfo(XMLNode node, Content classContentTree) {
Content classInfoTree = writer.getClassInfoTreeHeader();
buildChildren(node, classInfoTree);
classContentTree.addContent(writer.getClassInfo(classInfoTree));
} | [
"public",
"void",
"buildClassInfo",
"(",
"XMLNode",
"node",
",",
"Content",
"classContentTree",
")",
"{",
"Content",
"classInfoTree",
"=",
"writer",
".",
"getClassInfoTreeHeader",
"(",
")",
";",
"buildChildren",
"(",
"node",
",",
"classInfoTree",
")",
";",
"classContentTree",
".",
"addContent",
"(",
"writer",
".",
"getClassInfo",
"(",
"classInfoTree",
")",
")",
";",
"}"
] | Build the class information tree documentation.
@param node the XML element that specifies which components to document
@param classContentTree the content tree to which the documentation will be added | [
"Build",
"the",
"class",
"information",
"tree",
"documentation",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java#L171-L175 |
apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/task/HiveTask.java | HiveTask.addFile | public static void addFile(State state, String file) {
"""
Add the input file to the Hive session before running the task.
"""
state.setProp(ADD_FILES, state.getProp(ADD_FILES, "") + "," + file);
} | java | public static void addFile(State state, String file) {
state.setProp(ADD_FILES, state.getProp(ADD_FILES, "") + "," + file);
} | [
"public",
"static",
"void",
"addFile",
"(",
"State",
"state",
",",
"String",
"file",
")",
"{",
"state",
".",
"setProp",
"(",
"ADD_FILES",
",",
"state",
".",
"getProp",
"(",
"ADD_FILES",
",",
"\"\"",
")",
"+",
"\",\"",
"+",
"file",
")",
";",
"}"
] | Add the input file to the Hive session before running the task. | [
"Add",
"the",
"input",
"file",
"to",
"the",
"Hive",
"session",
"before",
"running",
"the",
"task",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/task/HiveTask.java#L73-L75 |
amplexus/java-flac-encoder | src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java | FLACEncoder.setOutputStream | public void setOutputStream(FLACOutputStream fos) {
"""
Set the output stream to use. This must not be called while an encode
process is active, or a flac stream is already opened.
@param fos output stream to use. This must not be null.
"""
if(fos == null)
throw new IllegalArgumentException("FLACOutputStream fos must not be null.");
if(flacWriter == null)
flacWriter = new FLACStreamController(fos,streamConfig);
else
flacWriter.setFLACOutputStream(fos);
} | java | public void setOutputStream(FLACOutputStream fos) {
if(fos == null)
throw new IllegalArgumentException("FLACOutputStream fos must not be null.");
if(flacWriter == null)
flacWriter = new FLACStreamController(fos,streamConfig);
else
flacWriter.setFLACOutputStream(fos);
} | [
"public",
"void",
"setOutputStream",
"(",
"FLACOutputStream",
"fos",
")",
"{",
"if",
"(",
"fos",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"FLACOutputStream fos must not be null.\"",
")",
";",
"if",
"(",
"flacWriter",
"==",
"null",
")",
"flacWriter",
"=",
"new",
"FLACStreamController",
"(",
"fos",
",",
"streamConfig",
")",
";",
"else",
"flacWriter",
".",
"setFLACOutputStream",
"(",
"fos",
")",
";",
"}"
] | Set the output stream to use. This must not be called while an encode
process is active, or a flac stream is already opened.
@param fos output stream to use. This must not be null. | [
"Set",
"the",
"output",
"stream",
"to",
"use",
".",
"This",
"must",
"not",
"be",
"called",
"while",
"an",
"encode",
"process",
"is",
"active",
"or",
"a",
"flac",
"stream",
"is",
"already",
"opened",
"."
] | train | https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java#L688-L695 |
ops4j/org.ops4j.pax.logging | pax-logging-api/src/main/java/org/jboss/logging/Logger.java | Logger.logv | public void logv(Level level, String format, Object... params) {
"""
Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting.
@param level the level
@param format the message format string
@param params the parameters
"""
doLog(level, FQCN, format, params, null);
} | java | public void logv(Level level, String format, Object... params) {
doLog(level, FQCN, format, params, null);
} | [
"public",
"void",
"logv",
"(",
"Level",
"level",
",",
"String",
"format",
",",
"Object",
"...",
"params",
")",
"{",
"doLog",
"(",
"level",
",",
"FQCN",
",",
"format",
",",
"params",
",",
"null",
")",
";",
"}"
] | Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting.
@param level the level
@param format the message format string
@param params the parameters | [
"Issue",
"a",
"log",
"message",
"at",
"the",
"given",
"log",
"level",
"using",
"{",
"@link",
"java",
".",
"text",
".",
"MessageFormat",
"}",
"-",
"style",
"formatting",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/jboss/logging/Logger.java#L2113-L2115 |
j256/ormlite-core | src/main/java/com/j256/ormlite/stmt/QueryBuilder.java | QueryBuilder.matchJoinedFields | private void matchJoinedFields(JoinInfo joinInfo, QueryBuilder<?, ?> joinedQueryBuilder) throws SQLException {
"""
Match up our joined fields so we can throw a nice exception immediately if you can't join with this type.
"""
for (FieldType fieldType : tableInfo.getFieldTypes()) {
// if this is a foreign field and its foreign field is the same as the other's id
FieldType foreignRefField = fieldType.getForeignRefField();
if (fieldType.isForeign() && foreignRefField.equals(joinedQueryBuilder.tableInfo.getIdField())) {
joinInfo.localField = fieldType;
joinInfo.remoteField = foreignRefField;
return;
}
}
// if this other field is a foreign field and its foreign-id field is our id
for (FieldType fieldType : joinedQueryBuilder.tableInfo.getFieldTypes()) {
if (fieldType.isForeign() && fieldType.getForeignIdField().equals(idField)) {
joinInfo.localField = idField;
joinInfo.remoteField = fieldType;
return;
}
}
throw new SQLException("Could not find a foreign " + tableInfo.getDataClass() + " field in "
+ joinedQueryBuilder.tableInfo.getDataClass() + " or vice versa");
} | java | private void matchJoinedFields(JoinInfo joinInfo, QueryBuilder<?, ?> joinedQueryBuilder) throws SQLException {
for (FieldType fieldType : tableInfo.getFieldTypes()) {
// if this is a foreign field and its foreign field is the same as the other's id
FieldType foreignRefField = fieldType.getForeignRefField();
if (fieldType.isForeign() && foreignRefField.equals(joinedQueryBuilder.tableInfo.getIdField())) {
joinInfo.localField = fieldType;
joinInfo.remoteField = foreignRefField;
return;
}
}
// if this other field is a foreign field and its foreign-id field is our id
for (FieldType fieldType : joinedQueryBuilder.tableInfo.getFieldTypes()) {
if (fieldType.isForeign() && fieldType.getForeignIdField().equals(idField)) {
joinInfo.localField = idField;
joinInfo.remoteField = fieldType;
return;
}
}
throw new SQLException("Could not find a foreign " + tableInfo.getDataClass() + " field in "
+ joinedQueryBuilder.tableInfo.getDataClass() + " or vice versa");
} | [
"private",
"void",
"matchJoinedFields",
"(",
"JoinInfo",
"joinInfo",
",",
"QueryBuilder",
"<",
"?",
",",
"?",
">",
"joinedQueryBuilder",
")",
"throws",
"SQLException",
"{",
"for",
"(",
"FieldType",
"fieldType",
":",
"tableInfo",
".",
"getFieldTypes",
"(",
")",
")",
"{",
"// if this is a foreign field and its foreign field is the same as the other's id",
"FieldType",
"foreignRefField",
"=",
"fieldType",
".",
"getForeignRefField",
"(",
")",
";",
"if",
"(",
"fieldType",
".",
"isForeign",
"(",
")",
"&&",
"foreignRefField",
".",
"equals",
"(",
"joinedQueryBuilder",
".",
"tableInfo",
".",
"getIdField",
"(",
")",
")",
")",
"{",
"joinInfo",
".",
"localField",
"=",
"fieldType",
";",
"joinInfo",
".",
"remoteField",
"=",
"foreignRefField",
";",
"return",
";",
"}",
"}",
"// if this other field is a foreign field and its foreign-id field is our id",
"for",
"(",
"FieldType",
"fieldType",
":",
"joinedQueryBuilder",
".",
"tableInfo",
".",
"getFieldTypes",
"(",
")",
")",
"{",
"if",
"(",
"fieldType",
".",
"isForeign",
"(",
")",
"&&",
"fieldType",
".",
"getForeignIdField",
"(",
")",
".",
"equals",
"(",
"idField",
")",
")",
"{",
"joinInfo",
".",
"localField",
"=",
"idField",
";",
"joinInfo",
".",
"remoteField",
"=",
"fieldType",
";",
"return",
";",
"}",
"}",
"throw",
"new",
"SQLException",
"(",
"\"Could not find a foreign \"",
"+",
"tableInfo",
".",
"getDataClass",
"(",
")",
"+",
"\" field in \"",
"+",
"joinedQueryBuilder",
".",
"tableInfo",
".",
"getDataClass",
"(",
")",
"+",
"\" or vice versa\"",
")",
";",
"}"
] | Match up our joined fields so we can throw a nice exception immediately if you can't join with this type. | [
"Match",
"up",
"our",
"joined",
"fields",
"so",
"we",
"can",
"throw",
"a",
"nice",
"exception",
"immediately",
"if",
"you",
"can",
"t",
"join",
"with",
"this",
"type",
"."
] | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/stmt/QueryBuilder.java#L612-L633 |
rolfl/MicroBench | src/main/java/net/tuis/ubench/ScaleDetect.java | ScaleDetect.newtonSolve | private static double[] newtonSolve(Function<double[], double[]> function, double[] initial, double tolerance) {
"""
Finding the best fit using least-squares method for an equation system
@param function Equation system to find fit for. Input: Parameters, Output: Residuals.
@param initial Initial 'guess' for function parameters
@param tolerance How much the function parameters may change before a solution is accepted
@return The parameters to the function that causes the least residuals
"""
RealVector dx = new ArrayRealVector(initial.length);
dx.set(tolerance + 1);
int iterations = 0;
int d = initial.length;
double[] values = Arrays.copyOf(initial, initial.length);
while (dx.getNorm() > tolerance) {
double[] fx = function.apply(values);
Array2DRowRealMatrix df = new Array2DRowRealMatrix(fx.length, d);
ArrayRealVector fxVector = new ArrayRealVector(fx);
for (int i = 0; i < d; i++) {
double originalValue = values[i];
values[i] += H;
double[] fxi = function.apply(values);
values[i] = originalValue;
ArrayRealVector fxiVector = new ArrayRealVector(fxi);
RealVector result = fxiVector.subtract(fxVector);
result = result.mapDivide(H);
df.setColumn(i, result.toArray());
}
dx = new RRQRDecomposition(df).getSolver().solve(fxVector.mapMultiply(-1));
// df has size = initial, and fx has size equal to whatever that function produces.
for (int i = 0; i < values.length; i++) {
values[i] += dx.getEntry(i);
}
iterations++;
if (iterations % 100 == 0) {
tolerance *= 10;
}
}
return values;
} | java | private static double[] newtonSolve(Function<double[], double[]> function, double[] initial, double tolerance) {
RealVector dx = new ArrayRealVector(initial.length);
dx.set(tolerance + 1);
int iterations = 0;
int d = initial.length;
double[] values = Arrays.copyOf(initial, initial.length);
while (dx.getNorm() > tolerance) {
double[] fx = function.apply(values);
Array2DRowRealMatrix df = new Array2DRowRealMatrix(fx.length, d);
ArrayRealVector fxVector = new ArrayRealVector(fx);
for (int i = 0; i < d; i++) {
double originalValue = values[i];
values[i] += H;
double[] fxi = function.apply(values);
values[i] = originalValue;
ArrayRealVector fxiVector = new ArrayRealVector(fxi);
RealVector result = fxiVector.subtract(fxVector);
result = result.mapDivide(H);
df.setColumn(i, result.toArray());
}
dx = new RRQRDecomposition(df).getSolver().solve(fxVector.mapMultiply(-1));
// df has size = initial, and fx has size equal to whatever that function produces.
for (int i = 0; i < values.length; i++) {
values[i] += dx.getEntry(i);
}
iterations++;
if (iterations % 100 == 0) {
tolerance *= 10;
}
}
return values;
} | [
"private",
"static",
"double",
"[",
"]",
"newtonSolve",
"(",
"Function",
"<",
"double",
"[",
"]",
",",
"double",
"[",
"]",
">",
"function",
",",
"double",
"[",
"]",
"initial",
",",
"double",
"tolerance",
")",
"{",
"RealVector",
"dx",
"=",
"new",
"ArrayRealVector",
"(",
"initial",
".",
"length",
")",
";",
"dx",
".",
"set",
"(",
"tolerance",
"+",
"1",
")",
";",
"int",
"iterations",
"=",
"0",
";",
"int",
"d",
"=",
"initial",
".",
"length",
";",
"double",
"[",
"]",
"values",
"=",
"Arrays",
".",
"copyOf",
"(",
"initial",
",",
"initial",
".",
"length",
")",
";",
"while",
"(",
"dx",
".",
"getNorm",
"(",
")",
">",
"tolerance",
")",
"{",
"double",
"[",
"]",
"fx",
"=",
"function",
".",
"apply",
"(",
"values",
")",
";",
"Array2DRowRealMatrix",
"df",
"=",
"new",
"Array2DRowRealMatrix",
"(",
"fx",
".",
"length",
",",
"d",
")",
";",
"ArrayRealVector",
"fxVector",
"=",
"new",
"ArrayRealVector",
"(",
"fx",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"d",
";",
"i",
"++",
")",
"{",
"double",
"originalValue",
"=",
"values",
"[",
"i",
"]",
";",
"values",
"[",
"i",
"]",
"+=",
"H",
";",
"double",
"[",
"]",
"fxi",
"=",
"function",
".",
"apply",
"(",
"values",
")",
";",
"values",
"[",
"i",
"]",
"=",
"originalValue",
";",
"ArrayRealVector",
"fxiVector",
"=",
"new",
"ArrayRealVector",
"(",
"fxi",
")",
";",
"RealVector",
"result",
"=",
"fxiVector",
".",
"subtract",
"(",
"fxVector",
")",
";",
"result",
"=",
"result",
".",
"mapDivide",
"(",
"H",
")",
";",
"df",
".",
"setColumn",
"(",
"i",
",",
"result",
".",
"toArray",
"(",
")",
")",
";",
"}",
"dx",
"=",
"new",
"RRQRDecomposition",
"(",
"df",
")",
".",
"getSolver",
"(",
")",
".",
"solve",
"(",
"fxVector",
".",
"mapMultiply",
"(",
"-",
"1",
")",
")",
";",
"// df has size = initial, and fx has size equal to whatever that function produces.",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"values",
"[",
"i",
"]",
"+=",
"dx",
".",
"getEntry",
"(",
"i",
")",
";",
"}",
"iterations",
"++",
";",
"if",
"(",
"iterations",
"%",
"100",
"==",
"0",
")",
"{",
"tolerance",
"*=",
"10",
";",
"}",
"}",
"return",
"values",
";",
"}"
] | Finding the best fit using least-squares method for an equation system
@param function Equation system to find fit for. Input: Parameters, Output: Residuals.
@param initial Initial 'guess' for function parameters
@param tolerance How much the function parameters may change before a solution is accepted
@return The parameters to the function that causes the least residuals | [
"Finding",
"the",
"best",
"fit",
"using",
"least",
"-",
"squares",
"method",
"for",
"an",
"equation",
"system"
] | train | https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/ScaleDetect.java#L32-L64 |
sculptor/sculptor | sculptor-generator/sculptor-generator-core/src/main/java/org/sculptor/generator/util/HelperBase.java | HelperBase.substringBetween | public String substringBetween(String string, String begin, String end, boolean includeBoundaries) {
"""
Gets a substring between the begin and end boundaries
@param string
original string
@param begin
start boundary
@param end
end boundary
@param includeBoundaries
include the boundaries in substring
@return substring between boundaries
"""
if (string == null || begin == null || end == null) {
return null;
}
int startPos = string.indexOf(begin);
if (startPos != -1) {
if (includeBoundaries)
startPos = startPos - begin.length();
int endPos = string.lastIndexOf(end);
if (endPos != -1) {
if (includeBoundaries)
endPos = endPos + end.length();
return string.substring(startPos + begin.length(), endPos);
}
}
return null;
} | java | public String substringBetween(String string, String begin, String end, boolean includeBoundaries) {
if (string == null || begin == null || end == null) {
return null;
}
int startPos = string.indexOf(begin);
if (startPos != -1) {
if (includeBoundaries)
startPos = startPos - begin.length();
int endPos = string.lastIndexOf(end);
if (endPos != -1) {
if (includeBoundaries)
endPos = endPos + end.length();
return string.substring(startPos + begin.length(), endPos);
}
}
return null;
} | [
"public",
"String",
"substringBetween",
"(",
"String",
"string",
",",
"String",
"begin",
",",
"String",
"end",
",",
"boolean",
"includeBoundaries",
")",
"{",
"if",
"(",
"string",
"==",
"null",
"||",
"begin",
"==",
"null",
"||",
"end",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"int",
"startPos",
"=",
"string",
".",
"indexOf",
"(",
"begin",
")",
";",
"if",
"(",
"startPos",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"includeBoundaries",
")",
"startPos",
"=",
"startPos",
"-",
"begin",
".",
"length",
"(",
")",
";",
"int",
"endPos",
"=",
"string",
".",
"lastIndexOf",
"(",
"end",
")",
";",
"if",
"(",
"endPos",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"includeBoundaries",
")",
"endPos",
"=",
"endPos",
"+",
"end",
".",
"length",
"(",
")",
";",
"return",
"string",
".",
"substring",
"(",
"startPos",
"+",
"begin",
".",
"length",
"(",
")",
",",
"endPos",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Gets a substring between the begin and end boundaries
@param string
original string
@param begin
start boundary
@param end
end boundary
@param includeBoundaries
include the boundaries in substring
@return substring between boundaries | [
"Gets",
"a",
"substring",
"between",
"the",
"begin",
"and",
"end",
"boundaries"
] | train | https://github.com/sculptor/sculptor/blob/38df06ceb7e40f5f52dbd53b1cd1d07ee11aade5/sculptor-generator/sculptor-generator-core/src/main/java/org/sculptor/generator/util/HelperBase.java#L540-L556 |
couchbase/couchbase-lite-java-core | src/main/java/com/couchbase/lite/View.java | View.setMap | @InterfaceAudience.Public
public boolean setMap(Mapper mapBlock, String version) {
"""
Defines a view that has no reduce function.
See setMapReduce() for more information.
"""
return setMapReduce(mapBlock, null, version);
} | java | @InterfaceAudience.Public
public boolean setMap(Mapper mapBlock, String version) {
return setMapReduce(mapBlock, null, version);
} | [
"@",
"InterfaceAudience",
".",
"Public",
"public",
"boolean",
"setMap",
"(",
"Mapper",
"mapBlock",
",",
"String",
"version",
")",
"{",
"return",
"setMapReduce",
"(",
"mapBlock",
",",
"null",
",",
"version",
")",
";",
"}"
] | Defines a view that has no reduce function.
See setMapReduce() for more information. | [
"Defines",
"a",
"view",
"that",
"has",
"no",
"reduce",
"function",
".",
"See",
"setMapReduce",
"()",
"for",
"more",
"information",
"."
] | train | https://github.com/couchbase/couchbase-lite-java-core/blob/3b275642e2d2f231fd155ad9def9c5e9eff3118e/src/main/java/com/couchbase/lite/View.java#L166-L169 |
CenturyLinkCloud/mdw | mdw-workflow/src/com/centurylink/mdw/workflow/activity/transform/CrossmapActivity.java | CrossmapActivity.runScript | protected void runScript(String mapperScript, Slurper slurper, Builder builder)
throws ActivityException, TransformerException {
"""
Invokes the builder object for creating new output variable value.
"""
CompilerConfiguration compilerConfig = new CompilerConfiguration();
compilerConfig.setScriptBaseClass(CrossmapScript.class.getName());
Binding binding = new Binding();
binding.setVariable("runtimeContext", getRuntimeContext());
binding.setVariable(slurper.getName(), slurper.getInput());
binding.setVariable(builder.getName(), builder);
GroovyShell shell = new GroovyShell(getPackage().getCloudClassLoader(), binding, compilerConfig);
Script gScript = shell.parse(mapperScript);
gScript.run();
} | java | protected void runScript(String mapperScript, Slurper slurper, Builder builder)
throws ActivityException, TransformerException {
CompilerConfiguration compilerConfig = new CompilerConfiguration();
compilerConfig.setScriptBaseClass(CrossmapScript.class.getName());
Binding binding = new Binding();
binding.setVariable("runtimeContext", getRuntimeContext());
binding.setVariable(slurper.getName(), slurper.getInput());
binding.setVariable(builder.getName(), builder);
GroovyShell shell = new GroovyShell(getPackage().getCloudClassLoader(), binding, compilerConfig);
Script gScript = shell.parse(mapperScript);
gScript.run();
} | [
"protected",
"void",
"runScript",
"(",
"String",
"mapperScript",
",",
"Slurper",
"slurper",
",",
"Builder",
"builder",
")",
"throws",
"ActivityException",
",",
"TransformerException",
"{",
"CompilerConfiguration",
"compilerConfig",
"=",
"new",
"CompilerConfiguration",
"(",
")",
";",
"compilerConfig",
".",
"setScriptBaseClass",
"(",
"CrossmapScript",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"Binding",
"binding",
"=",
"new",
"Binding",
"(",
")",
";",
"binding",
".",
"setVariable",
"(",
"\"runtimeContext\"",
",",
"getRuntimeContext",
"(",
")",
")",
";",
"binding",
".",
"setVariable",
"(",
"slurper",
".",
"getName",
"(",
")",
",",
"slurper",
".",
"getInput",
"(",
")",
")",
";",
"binding",
".",
"setVariable",
"(",
"builder",
".",
"getName",
"(",
")",
",",
"builder",
")",
";",
"GroovyShell",
"shell",
"=",
"new",
"GroovyShell",
"(",
"getPackage",
"(",
")",
".",
"getCloudClassLoader",
"(",
")",
",",
"binding",
",",
"compilerConfig",
")",
";",
"Script",
"gScript",
"=",
"shell",
".",
"parse",
"(",
"mapperScript",
")",
";",
"gScript",
".",
"run",
"(",
")",
";",
"}"
] | Invokes the builder object for creating new output variable value. | [
"Invokes",
"the",
"builder",
"object",
"for",
"creating",
"new",
"output",
"variable",
"value",
"."
] | train | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-workflow/src/com/centurylink/mdw/workflow/activity/transform/CrossmapActivity.java#L133-L146 |
Fleker/ChannelSurfer | library/src/main/java/com/felkertech/channelsurfer/fileio/FileParser.java | FileParser.parseGenericFileUri | public static void parseGenericFileUri(String uri, FileIdentifier identifier) {
"""
In order to determine the correct file parser, you can provide the URI and this method
will find the appropriate parser to use
@param uri The Uri of the file you are parsing
@param identifier This interface can be generated in order to handle different actions
based on the source of the file
"""
if(uri.startsWith("file://"))
identifier.onLocalFile();
else if(uri.startsWith("http://"))
identifier.onHttpFile();
else if(uri.startsWith("android.resource://"))
identifier.onAsset();
} | java | public static void parseGenericFileUri(String uri, FileIdentifier identifier) {
if(uri.startsWith("file://"))
identifier.onLocalFile();
else if(uri.startsWith("http://"))
identifier.onHttpFile();
else if(uri.startsWith("android.resource://"))
identifier.onAsset();
} | [
"public",
"static",
"void",
"parseGenericFileUri",
"(",
"String",
"uri",
",",
"FileIdentifier",
"identifier",
")",
"{",
"if",
"(",
"uri",
".",
"startsWith",
"(",
"\"file://\"",
")",
")",
"identifier",
".",
"onLocalFile",
"(",
")",
";",
"else",
"if",
"(",
"uri",
".",
"startsWith",
"(",
"\"http://\"",
")",
")",
"identifier",
".",
"onHttpFile",
"(",
")",
";",
"else",
"if",
"(",
"uri",
".",
"startsWith",
"(",
"\"android.resource://\"",
")",
")",
"identifier",
".",
"onAsset",
"(",
")",
";",
"}"
] | In order to determine the correct file parser, you can provide the URI and this method
will find the appropriate parser to use
@param uri The Uri of the file you are parsing
@param identifier This interface can be generated in order to handle different actions
based on the source of the file | [
"In",
"order",
"to",
"determine",
"the",
"correct",
"file",
"parser",
"you",
"can",
"provide",
"the",
"URI",
"and",
"this",
"method",
"will",
"find",
"the",
"appropriate",
"parser",
"to",
"use"
] | train | https://github.com/Fleker/ChannelSurfer/blob/f677beae37112f463c0c4783967fdb8fa97eb633/library/src/main/java/com/felkertech/channelsurfer/fileio/FileParser.java#L15-L22 |
Scout24/appmon4j | core/src/main/java/de/is24/util/monitoring/wrapper/GenericMonitoringWrapper.java | GenericMonitoringWrapper.wrapObject | public static <E> E wrapObject(final Class<E> clazz, final Object target) {
"""
Wraps the given object and returns the reporting proxy. Uses the
{@link InApplicationMonitorTimingReporter} to report the timings.
@param <E>
the type of the public interface of the wrapped object
@param clazz
the class object to the interface
@param target
the object to wrap
@return the monitoring wrapper
"""
return wrapObject(clazz, target, new InApplicationMonitorTimingReporter());
} | java | public static <E> E wrapObject(final Class<E> clazz, final Object target) {
return wrapObject(clazz, target, new InApplicationMonitorTimingReporter());
} | [
"public",
"static",
"<",
"E",
">",
"E",
"wrapObject",
"(",
"final",
"Class",
"<",
"E",
">",
"clazz",
",",
"final",
"Object",
"target",
")",
"{",
"return",
"wrapObject",
"(",
"clazz",
",",
"target",
",",
"new",
"InApplicationMonitorTimingReporter",
"(",
")",
")",
";",
"}"
] | Wraps the given object and returns the reporting proxy. Uses the
{@link InApplicationMonitorTimingReporter} to report the timings.
@param <E>
the type of the public interface of the wrapped object
@param clazz
the class object to the interface
@param target
the object to wrap
@return the monitoring wrapper | [
"Wraps",
"the",
"given",
"object",
"and",
"returns",
"the",
"reporting",
"proxy",
".",
"Uses",
"the",
"{",
"@link",
"InApplicationMonitorTimingReporter",
"}",
"to",
"report",
"the",
"timings",
"."
] | train | https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/wrapper/GenericMonitoringWrapper.java#L68-L70 |
Impetus/Kundera | src/kundera-mongo/src/main/java/com/impetus/client/mongodb/query/MongoDBQuery.java | MongoDBQuery.getKeys | private BasicDBObject getKeys(EntityMetadata m, String[] columns) {
"""
Gets the keys.
@param m
the m
@param columns
the columns
@return the keys
"""
BasicDBObject keys = new BasicDBObject();
if (columns != null && columns.length > 0)
{
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
.getMetamodel(m.getPersistenceUnit());
EntityType entity = metaModel.entity(m.getEntityClazz());
for (int i = 1; i < columns.length; i++)
{
if (columns[i] != null)
{
Attribute col = entity.getAttribute(columns[i]);
if (col == null)
{
throw new QueryHandlerException("column type is null for: " + columns);
}
keys.put(((AbstractAttribute) col).getJPAColumnName(), 1);
}
}
}
return keys;
} | java | private BasicDBObject getKeys(EntityMetadata m, String[] columns)
{
BasicDBObject keys = new BasicDBObject();
if (columns != null && columns.length > 0)
{
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
.getMetamodel(m.getPersistenceUnit());
EntityType entity = metaModel.entity(m.getEntityClazz());
for (int i = 1; i < columns.length; i++)
{
if (columns[i] != null)
{
Attribute col = entity.getAttribute(columns[i]);
if (col == null)
{
throw new QueryHandlerException("column type is null for: " + columns);
}
keys.put(((AbstractAttribute) col).getJPAColumnName(), 1);
}
}
}
return keys;
} | [
"private",
"BasicDBObject",
"getKeys",
"(",
"EntityMetadata",
"m",
",",
"String",
"[",
"]",
"columns",
")",
"{",
"BasicDBObject",
"keys",
"=",
"new",
"BasicDBObject",
"(",
")",
";",
"if",
"(",
"columns",
"!=",
"null",
"&&",
"columns",
".",
"length",
">",
"0",
")",
"{",
"MetamodelImpl",
"metaModel",
"=",
"(",
"MetamodelImpl",
")",
"kunderaMetadata",
".",
"getApplicationMetadata",
"(",
")",
".",
"getMetamodel",
"(",
"m",
".",
"getPersistenceUnit",
"(",
")",
")",
";",
"EntityType",
"entity",
"=",
"metaModel",
".",
"entity",
"(",
"m",
".",
"getEntityClazz",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"columns",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"columns",
"[",
"i",
"]",
"!=",
"null",
")",
"{",
"Attribute",
"col",
"=",
"entity",
".",
"getAttribute",
"(",
"columns",
"[",
"i",
"]",
")",
";",
"if",
"(",
"col",
"==",
"null",
")",
"{",
"throw",
"new",
"QueryHandlerException",
"(",
"\"column type is null for: \"",
"+",
"columns",
")",
";",
"}",
"keys",
".",
"put",
"(",
"(",
"(",
"AbstractAttribute",
")",
"col",
")",
".",
"getJPAColumnName",
"(",
")",
",",
"1",
")",
";",
"}",
"}",
"}",
"return",
"keys",
";",
"}"
] | Gets the keys.
@param m
the m
@param columns
the columns
@return the keys | [
"Gets",
"the",
"keys",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/query/MongoDBQuery.java#L804-L826 |
buyi/RecyclerViewPagerIndicator | recycler-viewpager-indicator/src/main/java/com/viewpagerindicator/as/library/pageview/RecyclerViewHeader.java | RecyclerViewHeader.attachTo | public void attachTo(RecyclerView recycler, boolean headerAlreadyAligned) {
"""
Attaches <code>RecyclerViewHeader</code> to <code>RecyclerView</code>.
Be sure that <code>setLayoutManager(...)</code> has been called for <code>RecyclerView</code> before calling this method.
Also, if you were planning to use <code>setOnScrollListener(...)</code> method for your <code>RecyclerView</code>, be sure to do it before calling this method.
@param recycler <code>RecyclerView</code> to attach <code>RecyclerViewHeader</code> to.
@param headerAlreadyAligned If set to <code>false</code>, method will perform necessary actions to properly align
the header within <code>RecyclerView</code>. If set to <code>true</code> method will assume,
that user has already aligned <code>RecyclerViewHeader</code> properly.
"""
validateRecycler(recycler, headerAlreadyAligned);
mRecycler = recycler;
mAlreadyAligned = headerAlreadyAligned;
mReversed = isLayoutManagerReversed(recycler);
setupAlignment(recycler);
setupHeader(recycler);
// final TypedArray styledAttributes = getContext().getTheme().obtainStyledAttributes(
// new int[]{android.R.attr.actionBarSize});
// int mActionBarSize = (int) styledAttributes.getDimension(0, 0);
// styledAttributes.recycle();
// int height = mActionBarSize;
recycler.addItemDecoration(new HeaderItemDecoration(this.getResources().getDrawable(R.drawable.divider),recycler.getLayoutManager(), 0), 0);
} | java | public void attachTo(RecyclerView recycler, boolean headerAlreadyAligned) {
validateRecycler(recycler, headerAlreadyAligned);
mRecycler = recycler;
mAlreadyAligned = headerAlreadyAligned;
mReversed = isLayoutManagerReversed(recycler);
setupAlignment(recycler);
setupHeader(recycler);
// final TypedArray styledAttributes = getContext().getTheme().obtainStyledAttributes(
// new int[]{android.R.attr.actionBarSize});
// int mActionBarSize = (int) styledAttributes.getDimension(0, 0);
// styledAttributes.recycle();
// int height = mActionBarSize;
recycler.addItemDecoration(new HeaderItemDecoration(this.getResources().getDrawable(R.drawable.divider),recycler.getLayoutManager(), 0), 0);
} | [
"public",
"void",
"attachTo",
"(",
"RecyclerView",
"recycler",
",",
"boolean",
"headerAlreadyAligned",
")",
"{",
"validateRecycler",
"(",
"recycler",
",",
"headerAlreadyAligned",
")",
";",
"mRecycler",
"=",
"recycler",
";",
"mAlreadyAligned",
"=",
"headerAlreadyAligned",
";",
"mReversed",
"=",
"isLayoutManagerReversed",
"(",
"recycler",
")",
";",
"setupAlignment",
"(",
"recycler",
")",
";",
"setupHeader",
"(",
"recycler",
")",
";",
"// final TypedArray styledAttributes = getContext().getTheme().obtainStyledAttributes(",
"// new int[]{android.R.attr.actionBarSize});",
"// int mActionBarSize = (int) styledAttributes.getDimension(0, 0);",
"// styledAttributes.recycle();",
"// int height = mActionBarSize;",
"recycler",
".",
"addItemDecoration",
"(",
"new",
"HeaderItemDecoration",
"(",
"this",
".",
"getResources",
"(",
")",
".",
"getDrawable",
"(",
"R",
".",
"drawable",
".",
"divider",
")",
",",
"recycler",
".",
"getLayoutManager",
"(",
")",
",",
"0",
")",
",",
"0",
")",
";",
"}"
] | Attaches <code>RecyclerViewHeader</code> to <code>RecyclerView</code>.
Be sure that <code>setLayoutManager(...)</code> has been called for <code>RecyclerView</code> before calling this method.
Also, if you were planning to use <code>setOnScrollListener(...)</code> method for your <code>RecyclerView</code>, be sure to do it before calling this method.
@param recycler <code>RecyclerView</code> to attach <code>RecyclerViewHeader</code> to.
@param headerAlreadyAligned If set to <code>false</code>, method will perform necessary actions to properly align
the header within <code>RecyclerView</code>. If set to <code>true</code> method will assume,
that user has already aligned <code>RecyclerViewHeader</code> properly. | [
"Attaches",
"<code",
">",
"RecyclerViewHeader<",
"/",
"code",
">",
"to",
"<code",
">",
"RecyclerView<",
"/",
"code",
">",
".",
"Be",
"sure",
"that",
"<code",
">",
"setLayoutManager",
"(",
"...",
")",
"<",
"/",
"code",
">",
"has",
"been",
"called",
"for",
"<code",
">",
"RecyclerView<",
"/",
"code",
">",
"before",
"calling",
"this",
"method",
".",
"Also",
"if",
"you",
"were",
"planning",
"to",
"use",
"<code",
">",
"setOnScrollListener",
"(",
"...",
")",
"<",
"/",
"code",
">",
"method",
"for",
"your",
"<code",
">",
"RecyclerView<",
"/",
"code",
">",
"be",
"sure",
"to",
"do",
"it",
"before",
"calling",
"this",
"method",
"."
] | train | https://github.com/buyi/RecyclerViewPagerIndicator/blob/b3b5283801b60d40f7325c7f590c945262194fad/recycler-viewpager-indicator/src/main/java/com/viewpagerindicator/as/library/pageview/RecyclerViewHeader.java#L109-L125 |
scottbw/spaws | src/main/java/uk/ac/bolton/spaws/ParadataManager.java | ParadataManager.getExternalStats | public List<ISubmission> getExternalStats(String resourceUrl) throws Exception {
"""
Return all stats from other submitters for the resource
@param resourceUrl
@return
@throws Exception
"""
return getExternalSubmissions(resourceUrl, IStats.VERB);
} | java | public List<ISubmission> getExternalStats(String resourceUrl) throws Exception{
return getExternalSubmissions(resourceUrl, IStats.VERB);
} | [
"public",
"List",
"<",
"ISubmission",
">",
"getExternalStats",
"(",
"String",
"resourceUrl",
")",
"throws",
"Exception",
"{",
"return",
"getExternalSubmissions",
"(",
"resourceUrl",
",",
"IStats",
".",
"VERB",
")",
";",
"}"
] | Return all stats from other submitters for the resource
@param resourceUrl
@return
@throws Exception | [
"Return",
"all",
"stats",
"from",
"other",
"submitters",
"for",
"the",
"resource"
] | train | https://github.com/scottbw/spaws/blob/9b1e07453091f6a8d60c6046d194b1a8f1236502/src/main/java/uk/ac/bolton/spaws/ParadataManager.java#L73-L75 |
aws/aws-sdk-java | aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/AddOperations.java | AddOperations.getHttpStatusCode | private Integer getHttpStatusCode(ErrorMap error, Shape shape) {
"""
Get HTTP status code either from error trait on the operation reference or the error trait on the shape.
@param error ErrorMap on operation reference.
@param shape Error shape.
@return HTTP status code or null if not present.
"""
final Integer httpStatusCode = getHttpStatusCode(error.getErrorTrait());
return httpStatusCode == null ? getHttpStatusCode(shape.getErrorTrait()) : httpStatusCode;
} | java | private Integer getHttpStatusCode(ErrorMap error, Shape shape) {
final Integer httpStatusCode = getHttpStatusCode(error.getErrorTrait());
return httpStatusCode == null ? getHttpStatusCode(shape.getErrorTrait()) : httpStatusCode;
} | [
"private",
"Integer",
"getHttpStatusCode",
"(",
"ErrorMap",
"error",
",",
"Shape",
"shape",
")",
"{",
"final",
"Integer",
"httpStatusCode",
"=",
"getHttpStatusCode",
"(",
"error",
".",
"getErrorTrait",
"(",
")",
")",
";",
"return",
"httpStatusCode",
"==",
"null",
"?",
"getHttpStatusCode",
"(",
"shape",
".",
"getErrorTrait",
"(",
")",
")",
":",
"httpStatusCode",
";",
"}"
] | Get HTTP status code either from error trait on the operation reference or the error trait on the shape.
@param error ErrorMap on operation reference.
@param shape Error shape.
@return HTTP status code or null if not present. | [
"Get",
"HTTP",
"status",
"code",
"either",
"from",
"error",
"trait",
"on",
"the",
"operation",
"reference",
"or",
"the",
"error",
"trait",
"on",
"the",
"shape",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/AddOperations.java#L130-L133 |
zeroturnaround/zt-zip | src/main/java/org/zeroturnaround/zip/ZipUtil.java | ZipUtil.replaceEntry | public static boolean replaceEntry(File zip, String path, File file, File destZip) {
"""
Copies an existing ZIP file and replaces a given entry in it.
@param zip
an existing ZIP file (only read).
@param path
new ZIP entry path.
@param file
new entry.
@param destZip
new ZIP file created.
@return <code>true</code> if the entry was replaced.
"""
return replaceEntry(zip, new FileSource(path, file), destZip);
} | java | public static boolean replaceEntry(File zip, String path, File file, File destZip) {
return replaceEntry(zip, new FileSource(path, file), destZip);
} | [
"public",
"static",
"boolean",
"replaceEntry",
"(",
"File",
"zip",
",",
"String",
"path",
",",
"File",
"file",
",",
"File",
"destZip",
")",
"{",
"return",
"replaceEntry",
"(",
"zip",
",",
"new",
"FileSource",
"(",
"path",
",",
"file",
")",
",",
"destZip",
")",
";",
"}"
] | Copies an existing ZIP file and replaces a given entry in it.
@param zip
an existing ZIP file (only read).
@param path
new ZIP entry path.
@param file
new entry.
@param destZip
new ZIP file created.
@return <code>true</code> if the entry was replaced. | [
"Copies",
"an",
"existing",
"ZIP",
"file",
"and",
"replaces",
"a",
"given",
"entry",
"in",
"it",
"."
] | train | https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/ZipUtil.java#L2502-L2504 |
Azure/azure-sdk-for-java | hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ScriptActionsInner.java | ScriptActionsInner.listByClusterAsync | public Observable<Page<RuntimeScriptActionDetailInner>> listByClusterAsync(final String resourceGroupName, final String clusterName) {
"""
Lists all the persisted script actions for the specified cluster.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<RuntimeScriptActionDetailInner> object
"""
return listByClusterWithServiceResponseAsync(resourceGroupName, clusterName)
.map(new Func1<ServiceResponse<Page<RuntimeScriptActionDetailInner>>, Page<RuntimeScriptActionDetailInner>>() {
@Override
public Page<RuntimeScriptActionDetailInner> call(ServiceResponse<Page<RuntimeScriptActionDetailInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<RuntimeScriptActionDetailInner>> listByClusterAsync(final String resourceGroupName, final String clusterName) {
return listByClusterWithServiceResponseAsync(resourceGroupName, clusterName)
.map(new Func1<ServiceResponse<Page<RuntimeScriptActionDetailInner>>, Page<RuntimeScriptActionDetailInner>>() {
@Override
public Page<RuntimeScriptActionDetailInner> call(ServiceResponse<Page<RuntimeScriptActionDetailInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"RuntimeScriptActionDetailInner",
">",
">",
"listByClusterAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"clusterName",
")",
"{",
"return",
"listByClusterWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"RuntimeScriptActionDetailInner",
">",
">",
",",
"Page",
"<",
"RuntimeScriptActionDetailInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"RuntimeScriptActionDetailInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"RuntimeScriptActionDetailInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Lists all the persisted script actions for the specified cluster.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<RuntimeScriptActionDetailInner> object | [
"Lists",
"all",
"the",
"persisted",
"script",
"actions",
"for",
"the",
"specified",
"cluster",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ScriptActionsInner.java#L220-L228 |
nguyenq/tess4j | src/main/java/net/sourceforge/tess4j/Tesseract.java | Tesseract.getRecognizedWords | private List<Word> getRecognizedWords(int pageIteratorLevel) {
"""
Gets result words at specified page iterator level from recognized pages.
@param pageIteratorLevel TessPageIteratorLevel enum
@return list of <code>Word</code>
"""
List<Word> words = new ArrayList<Word>();
try {
TessResultIterator ri = api.TessBaseAPIGetIterator(handle);
TessPageIterator pi = api.TessResultIteratorGetPageIterator(ri);
api.TessPageIteratorBegin(pi);
do {
Pointer ptr = api.TessResultIteratorGetUTF8Text(ri, pageIteratorLevel);
String text = ptr.getString(0);
api.TessDeleteText(ptr);
float confidence = api.TessResultIteratorConfidence(ri, pageIteratorLevel);
IntBuffer leftB = IntBuffer.allocate(1);
IntBuffer topB = IntBuffer.allocate(1);
IntBuffer rightB = IntBuffer.allocate(1);
IntBuffer bottomB = IntBuffer.allocate(1);
api.TessPageIteratorBoundingBox(pi, pageIteratorLevel, leftB, topB, rightB, bottomB);
int left = leftB.get();
int top = topB.get();
int right = rightB.get();
int bottom = bottomB.get();
Word word = new Word(text, confidence, new Rectangle(left, top, right - left, bottom - top));
words.add(word);
} while (api.TessPageIteratorNext(pi, pageIteratorLevel) == TRUE);
} catch (Exception e) {
logger.warn(e.getMessage(), e);
}
return words;
} | java | private List<Word> getRecognizedWords(int pageIteratorLevel) {
List<Word> words = new ArrayList<Word>();
try {
TessResultIterator ri = api.TessBaseAPIGetIterator(handle);
TessPageIterator pi = api.TessResultIteratorGetPageIterator(ri);
api.TessPageIteratorBegin(pi);
do {
Pointer ptr = api.TessResultIteratorGetUTF8Text(ri, pageIteratorLevel);
String text = ptr.getString(0);
api.TessDeleteText(ptr);
float confidence = api.TessResultIteratorConfidence(ri, pageIteratorLevel);
IntBuffer leftB = IntBuffer.allocate(1);
IntBuffer topB = IntBuffer.allocate(1);
IntBuffer rightB = IntBuffer.allocate(1);
IntBuffer bottomB = IntBuffer.allocate(1);
api.TessPageIteratorBoundingBox(pi, pageIteratorLevel, leftB, topB, rightB, bottomB);
int left = leftB.get();
int top = topB.get();
int right = rightB.get();
int bottom = bottomB.get();
Word word = new Word(text, confidence, new Rectangle(left, top, right - left, bottom - top));
words.add(word);
} while (api.TessPageIteratorNext(pi, pageIteratorLevel) == TRUE);
} catch (Exception e) {
logger.warn(e.getMessage(), e);
}
return words;
} | [
"private",
"List",
"<",
"Word",
">",
"getRecognizedWords",
"(",
"int",
"pageIteratorLevel",
")",
"{",
"List",
"<",
"Word",
">",
"words",
"=",
"new",
"ArrayList",
"<",
"Word",
">",
"(",
")",
";",
"try",
"{",
"TessResultIterator",
"ri",
"=",
"api",
".",
"TessBaseAPIGetIterator",
"(",
"handle",
")",
";",
"TessPageIterator",
"pi",
"=",
"api",
".",
"TessResultIteratorGetPageIterator",
"(",
"ri",
")",
";",
"api",
".",
"TessPageIteratorBegin",
"(",
"pi",
")",
";",
"do",
"{",
"Pointer",
"ptr",
"=",
"api",
".",
"TessResultIteratorGetUTF8Text",
"(",
"ri",
",",
"pageIteratorLevel",
")",
";",
"String",
"text",
"=",
"ptr",
".",
"getString",
"(",
"0",
")",
";",
"api",
".",
"TessDeleteText",
"(",
"ptr",
")",
";",
"float",
"confidence",
"=",
"api",
".",
"TessResultIteratorConfidence",
"(",
"ri",
",",
"pageIteratorLevel",
")",
";",
"IntBuffer",
"leftB",
"=",
"IntBuffer",
".",
"allocate",
"(",
"1",
")",
";",
"IntBuffer",
"topB",
"=",
"IntBuffer",
".",
"allocate",
"(",
"1",
")",
";",
"IntBuffer",
"rightB",
"=",
"IntBuffer",
".",
"allocate",
"(",
"1",
")",
";",
"IntBuffer",
"bottomB",
"=",
"IntBuffer",
".",
"allocate",
"(",
"1",
")",
";",
"api",
".",
"TessPageIteratorBoundingBox",
"(",
"pi",
",",
"pageIteratorLevel",
",",
"leftB",
",",
"topB",
",",
"rightB",
",",
"bottomB",
")",
";",
"int",
"left",
"=",
"leftB",
".",
"get",
"(",
")",
";",
"int",
"top",
"=",
"topB",
".",
"get",
"(",
")",
";",
"int",
"right",
"=",
"rightB",
".",
"get",
"(",
")",
";",
"int",
"bottom",
"=",
"bottomB",
".",
"get",
"(",
")",
";",
"Word",
"word",
"=",
"new",
"Word",
"(",
"text",
",",
"confidence",
",",
"new",
"Rectangle",
"(",
"left",
",",
"top",
",",
"right",
"-",
"left",
",",
"bottom",
"-",
"top",
")",
")",
";",
"words",
".",
"add",
"(",
"word",
")",
";",
"}",
"while",
"(",
"api",
".",
"TessPageIteratorNext",
"(",
"pi",
",",
"pageIteratorLevel",
")",
"==",
"TRUE",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"words",
";",
"}"
] | Gets result words at specified page iterator level from recognized pages.
@param pageIteratorLevel TessPageIteratorLevel enum
@return list of <code>Word</code> | [
"Gets",
"result",
"words",
"at",
"specified",
"page",
"iterator",
"level",
"from",
"recognized",
"pages",
"."
] | train | https://github.com/nguyenq/tess4j/blob/cfcd4a8a44042f150b4aaf7bdf5ffc485a2236e1/src/main/java/net/sourceforge/tess4j/Tesseract.java#L818-L848 |
vincentk/joptimizer | src/main/java/com/joptimizer/functions/SOCPLogarithmicBarrier.java | SOCPLogarithmicBarrier.createPhase1BarrierFunction | @Override
public BarrierFunction createPhase1BarrierFunction() {
"""
Create the barrier function for the Phase I.
It is an instance of this class for the constraints:
<br>||Ai.x+bi|| < ci.x+di+t, i=1,...,m
@see "S.Boyd and L.Vandenberghe, Convex Optimization, 11.6.2"
"""
final int dimPh1 = dim +1;
List<SOCPConstraintParameters> socpConstraintParametersPh1List = new ArrayList<SOCPConstraintParameters>();
SOCPLogarithmicBarrier bfPh1 = new SOCPLogarithmicBarrier(socpConstraintParametersPh1List, dimPh1);
for(int i=0; i<socpConstraintParametersList.size(); i++){
SOCPConstraintParameters param = socpConstraintParametersList.get(i);
RealMatrix A = param.getA();
RealVector b = param.getB();
RealVector c = param.getC();
double d = param.getD();
RealMatrix APh1 = MatrixUtils.createRealMatrix(A.getRowDimension(), dimPh1);
APh1.setSubMatrix(A.getData(), 0, 0);
RealVector bPh1 = b;
RealVector cPh1 = new ArrayRealVector(c.getDimension()+1);
cPh1.setSubVector(0, c);
cPh1.setEntry(c.getDimension(), 1);
double dPh1 = d;
SOCPConstraintParameters paramsPh1 = new SOCPConstraintParameters(APh1.getData(), bPh1.toArray(), cPh1.toArray(), dPh1);
socpConstraintParametersPh1List.add(socpConstraintParametersPh1List.size(), paramsPh1);
}
return bfPh1;
} | java | @Override
public BarrierFunction createPhase1BarrierFunction(){
final int dimPh1 = dim +1;
List<SOCPConstraintParameters> socpConstraintParametersPh1List = new ArrayList<SOCPConstraintParameters>();
SOCPLogarithmicBarrier bfPh1 = new SOCPLogarithmicBarrier(socpConstraintParametersPh1List, dimPh1);
for(int i=0; i<socpConstraintParametersList.size(); i++){
SOCPConstraintParameters param = socpConstraintParametersList.get(i);
RealMatrix A = param.getA();
RealVector b = param.getB();
RealVector c = param.getC();
double d = param.getD();
RealMatrix APh1 = MatrixUtils.createRealMatrix(A.getRowDimension(), dimPh1);
APh1.setSubMatrix(A.getData(), 0, 0);
RealVector bPh1 = b;
RealVector cPh1 = new ArrayRealVector(c.getDimension()+1);
cPh1.setSubVector(0, c);
cPh1.setEntry(c.getDimension(), 1);
double dPh1 = d;
SOCPConstraintParameters paramsPh1 = new SOCPConstraintParameters(APh1.getData(), bPh1.toArray(), cPh1.toArray(), dPh1);
socpConstraintParametersPh1List.add(socpConstraintParametersPh1List.size(), paramsPh1);
}
return bfPh1;
} | [
"@",
"Override",
"public",
"BarrierFunction",
"createPhase1BarrierFunction",
"(",
")",
"{",
"final",
"int",
"dimPh1",
"=",
"dim",
"+",
"1",
";",
"List",
"<",
"SOCPConstraintParameters",
">",
"socpConstraintParametersPh1List",
"=",
"new",
"ArrayList",
"<",
"SOCPConstraintParameters",
">",
"(",
")",
";",
"SOCPLogarithmicBarrier",
"bfPh1",
"=",
"new",
"SOCPLogarithmicBarrier",
"(",
"socpConstraintParametersPh1List",
",",
"dimPh1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"socpConstraintParametersList",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"SOCPConstraintParameters",
"param",
"=",
"socpConstraintParametersList",
".",
"get",
"(",
"i",
")",
";",
"RealMatrix",
"A",
"=",
"param",
".",
"getA",
"(",
")",
";",
"RealVector",
"b",
"=",
"param",
".",
"getB",
"(",
")",
";",
"RealVector",
"c",
"=",
"param",
".",
"getC",
"(",
")",
";",
"double",
"d",
"=",
"param",
".",
"getD",
"(",
")",
";",
"RealMatrix",
"APh1",
"=",
"MatrixUtils",
".",
"createRealMatrix",
"(",
"A",
".",
"getRowDimension",
"(",
")",
",",
"dimPh1",
")",
";",
"APh1",
".",
"setSubMatrix",
"(",
"A",
".",
"getData",
"(",
")",
",",
"0",
",",
"0",
")",
";",
"RealVector",
"bPh1",
"=",
"b",
";",
"RealVector",
"cPh1",
"=",
"new",
"ArrayRealVector",
"(",
"c",
".",
"getDimension",
"(",
")",
"+",
"1",
")",
";",
"cPh1",
".",
"setSubVector",
"(",
"0",
",",
"c",
")",
";",
"cPh1",
".",
"setEntry",
"(",
"c",
".",
"getDimension",
"(",
")",
",",
"1",
")",
";",
"double",
"dPh1",
"=",
"d",
";",
"SOCPConstraintParameters",
"paramsPh1",
"=",
"new",
"SOCPConstraintParameters",
"(",
"APh1",
".",
"getData",
"(",
")",
",",
"bPh1",
".",
"toArray",
"(",
")",
",",
"cPh1",
".",
"toArray",
"(",
")",
",",
"dPh1",
")",
";",
"socpConstraintParametersPh1List",
".",
"add",
"(",
"socpConstraintParametersPh1List",
".",
"size",
"(",
")",
",",
"paramsPh1",
")",
";",
"}",
"return",
"bfPh1",
";",
"}"
] | Create the barrier function for the Phase I.
It is an instance of this class for the constraints:
<br>||Ai.x+bi|| < ci.x+di+t, i=1,...,m
@see "S.Boyd and L.Vandenberghe, Convex Optimization, 11.6.2" | [
"Create",
"the",
"barrier",
"function",
"for",
"the",
"Phase",
"I",
".",
"It",
"is",
"an",
"instance",
"of",
"this",
"class",
"for",
"the",
"constraints",
":",
"<br",
">",
"||Ai",
".",
"x",
"+",
"bi||",
"<",
"ci",
".",
"x",
"+",
"di",
"+",
"t",
"i",
"=",
"1",
"...",
"m"
] | train | https://github.com/vincentk/joptimizer/blob/65064c1bb0b26c7261358021e4c93d06dd43564f/src/main/java/com/joptimizer/functions/SOCPLogarithmicBarrier.java#L124-L151 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jms/impl/TypeFormatter.java | TypeFormatter.formatNameTypeValue | public static String formatNameTypeValue(String name, Object value) {
"""
/*
Formats a name/object pair using the following template:
name(value-type)=value
where vale-type is a String representation of the object type of the
value passed in, and value is a String representation of the value
passed in. Binary arrays are formatted in hex, all other types are
formatted with toString().
"""
StringBuilder sb = new StringBuilder(name);
sb.append('(');
sb.append(getType(value));
sb.append(')');
sb.append('=');
sb.append(formatValue(value));
return sb.toString();
} | java | public static String formatNameTypeValue(String name, Object value) {
StringBuilder sb = new StringBuilder(name);
sb.append('(');
sb.append(getType(value));
sb.append(')');
sb.append('=');
sb.append(formatValue(value));
return sb.toString();
} | [
"public",
"static",
"String",
"formatNameTypeValue",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"name",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"getType",
"(",
"value",
")",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"formatValue",
"(",
"value",
")",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | /*
Formats a name/object pair using the following template:
name(value-type)=value
where vale-type is a String representation of the object type of the
value passed in, and value is a String representation of the value
passed in. Binary arrays are formatted in hex, all other types are
formatted with toString(). | [
"/",
"*",
"Formats",
"a",
"name",
"/",
"object",
"pair",
"using",
"the",
"following",
"template",
":"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jms/impl/TypeFormatter.java#L82-L91 |
gallandarakhneorg/afc | maven/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java | AbstractArakhneMojo.fileCopy | public final void fileCopy(URL in, File out) throws IOException {
"""
Copy a file.
@param in input file.
@param out output file.
@throws IOException on error.
"""
assert in != null;
try (InputStream inStream = in.openStream()) {
try (OutputStream outStream = new FileOutputStream(out)) {
final byte[] buf = new byte[FILE_BUFFER];
int len;
while ((len = inStream.read(buf)) > 0) {
outStream.write(buf, 0, len);
}
}
} finally {
getBuildContext().refresh(out);
}
} | java | public final void fileCopy(URL in, File out) throws IOException {
assert in != null;
try (InputStream inStream = in.openStream()) {
try (OutputStream outStream = new FileOutputStream(out)) {
final byte[] buf = new byte[FILE_BUFFER];
int len;
while ((len = inStream.read(buf)) > 0) {
outStream.write(buf, 0, len);
}
}
} finally {
getBuildContext().refresh(out);
}
} | [
"public",
"final",
"void",
"fileCopy",
"(",
"URL",
"in",
",",
"File",
"out",
")",
"throws",
"IOException",
"{",
"assert",
"in",
"!=",
"null",
";",
"try",
"(",
"InputStream",
"inStream",
"=",
"in",
".",
"openStream",
"(",
")",
")",
"{",
"try",
"(",
"OutputStream",
"outStream",
"=",
"new",
"FileOutputStream",
"(",
"out",
")",
")",
"{",
"final",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"FILE_BUFFER",
"]",
";",
"int",
"len",
";",
"while",
"(",
"(",
"len",
"=",
"inStream",
".",
"read",
"(",
"buf",
")",
")",
">",
"0",
")",
"{",
"outStream",
".",
"write",
"(",
"buf",
",",
"0",
",",
"len",
")",
";",
"}",
"}",
"}",
"finally",
"{",
"getBuildContext",
"(",
")",
".",
"refresh",
"(",
"out",
")",
";",
"}",
"}"
] | Copy a file.
@param in input file.
@param out output file.
@throws IOException on error. | [
"Copy",
"a",
"file",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/maven/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java#L356-L369 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.updateKey | public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion, List<JsonWebKeyOperation> keyOps, KeyAttributes keyAttributes, Map<String, String> tags) {
"""
The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault.
In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material of a key itself cannot be changed. This operation requires the keys/update permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name of key to update.
@param keyVersion The version of the key to update.
@param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation.
@param keyAttributes the KeyAttributes value
@param tags Application specific metadata in the form of key-value pairs.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the KeyBundle object if successful.
"""
return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single().body();
} | java | public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion, List<JsonWebKeyOperation> keyOps, KeyAttributes keyAttributes, Map<String, String> tags) {
return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single().body();
} | [
"public",
"KeyBundle",
"updateKey",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"keyName",
",",
"String",
"keyVersion",
",",
"List",
"<",
"JsonWebKeyOperation",
">",
"keyOps",
",",
"KeyAttributes",
"keyAttributes",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"updateKeyWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"keyName",
",",
"keyVersion",
",",
"keyOps",
",",
"keyAttributes",
",",
"tags",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault.
In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material of a key itself cannot be changed. This operation requires the keys/update permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name of key to update.
@param keyVersion The version of the key to update.
@param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation.
@param keyAttributes the KeyAttributes value
@param tags Application specific metadata in the form of key-value pairs.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the KeyBundle object if successful. | [
"The",
"update",
"key",
"operation",
"changes",
"specified",
"attributes",
"of",
"a",
"stored",
"key",
"and",
"can",
"be",
"applied",
"to",
"any",
"key",
"type",
"and",
"key",
"version",
"stored",
"in",
"Azure",
"Key",
"Vault",
".",
"In",
"order",
"to",
"perform",
"this",
"operation",
"the",
"key",
"must",
"already",
"exist",
"in",
"the",
"Key",
"Vault",
".",
"Note",
":",
"The",
"cryptographic",
"material",
"of",
"a",
"key",
"itself",
"cannot",
"be",
"changed",
".",
"This",
"operation",
"requires",
"the",
"keys",
"/",
"update",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L1274-L1276 |
eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest.java | MergeableManifest.write | @Override
public void write(OutputStream out) throws IOException {
"""
/*
Copied from base class to omit the call to make72Safe(..).
"""
DataOutputStream dos = new DataOutputStream(out);
// Write out the main attributes for the manifest
getMainAttributes().myWriteMain(dos);
// Now write out the pre-entry attributes
Iterator<Map.Entry<String, Attributes>> it = getEntries().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Attributes> e = it.next();
StringBuffer buffer = new StringBuffer("Name: ");
String value = e.getKey();
if (value != null) {
byte[] vb = value.getBytes("UTF8");
value = new String(vb, 0, 0, vb.length);
}
buffer.append(value);
buffer.append(lineDelimiter);
dos.writeBytes(make512Safe(buffer, lineDelimiter));
((OrderAwareAttributes) e.getValue()).myWrite(dos);
}
dos.flush();
} | java | @Override
public void write(OutputStream out) throws IOException {
DataOutputStream dos = new DataOutputStream(out);
// Write out the main attributes for the manifest
getMainAttributes().myWriteMain(dos);
// Now write out the pre-entry attributes
Iterator<Map.Entry<String, Attributes>> it = getEntries().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Attributes> e = it.next();
StringBuffer buffer = new StringBuffer("Name: ");
String value = e.getKey();
if (value != null) {
byte[] vb = value.getBytes("UTF8");
value = new String(vb, 0, 0, vb.length);
}
buffer.append(value);
buffer.append(lineDelimiter);
dos.writeBytes(make512Safe(buffer, lineDelimiter));
((OrderAwareAttributes) e.getValue()).myWrite(dos);
}
dos.flush();
} | [
"@",
"Override",
"public",
"void",
"write",
"(",
"OutputStream",
"out",
")",
"throws",
"IOException",
"{",
"DataOutputStream",
"dos",
"=",
"new",
"DataOutputStream",
"(",
"out",
")",
";",
"// Write out the main attributes for the manifest",
"getMainAttributes",
"(",
")",
".",
"myWriteMain",
"(",
"dos",
")",
";",
"// Now write out the pre-entry attributes",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"Attributes",
">",
">",
"it",
"=",
"getEntries",
"(",
")",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Map",
".",
"Entry",
"<",
"String",
",",
"Attributes",
">",
"e",
"=",
"it",
".",
"next",
"(",
")",
";",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
"\"Name: \"",
")",
";",
"String",
"value",
"=",
"e",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"byte",
"[",
"]",
"vb",
"=",
"value",
".",
"getBytes",
"(",
"\"UTF8\"",
")",
";",
"value",
"=",
"new",
"String",
"(",
"vb",
",",
"0",
",",
"0",
",",
"vb",
".",
"length",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"value",
")",
";",
"buffer",
".",
"append",
"(",
"lineDelimiter",
")",
";",
"dos",
".",
"writeBytes",
"(",
"make512Safe",
"(",
"buffer",
",",
"lineDelimiter",
")",
")",
";",
"(",
"(",
"OrderAwareAttributes",
")",
"e",
".",
"getValue",
"(",
")",
")",
".",
"myWrite",
"(",
"dos",
")",
";",
"}",
"dos",
".",
"flush",
"(",
")",
";",
"}"
] | /*
Copied from base class to omit the call to make72Safe(..). | [
"/",
"*",
"Copied",
"from",
"base",
"class",
"to",
"omit",
"the",
"call",
"to",
"make72Safe",
"(",
"..",
")",
"."
] | train | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest.java#L300-L321 |
orbisgis/h2gis | h2gis-utilities/src/main/java/org/h2gis/utilities/SFSUtilities.java | SFSUtilities.getResultSetEnvelope | public static Envelope getResultSetEnvelope(ResultSet resultSet) throws SQLException {
"""
Compute the full extend of a ResultSet using the first geometry field. If
the ResultSet does not contain any geometry field throw an exception
@param resultSet ResultSet to analyse
@return The full envelope of the ResultSet
@throws SQLException
"""
List<String> geometryFields = getGeometryFields(resultSet);
if (geometryFields.isEmpty()) {
throw new SQLException("This ResultSet doesn't contain any geometry field.");
} else {
return getResultSetEnvelope(resultSet, geometryFields.get(0));
}
} | java | public static Envelope getResultSetEnvelope(ResultSet resultSet) throws SQLException {
List<String> geometryFields = getGeometryFields(resultSet);
if (geometryFields.isEmpty()) {
throw new SQLException("This ResultSet doesn't contain any geometry field.");
} else {
return getResultSetEnvelope(resultSet, geometryFields.get(0));
}
} | [
"public",
"static",
"Envelope",
"getResultSetEnvelope",
"(",
"ResultSet",
"resultSet",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"String",
">",
"geometryFields",
"=",
"getGeometryFields",
"(",
"resultSet",
")",
";",
"if",
"(",
"geometryFields",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"\"This ResultSet doesn't contain any geometry field.\"",
")",
";",
"}",
"else",
"{",
"return",
"getResultSetEnvelope",
"(",
"resultSet",
",",
"geometryFields",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"}"
] | Compute the full extend of a ResultSet using the first geometry field. If
the ResultSet does not contain any geometry field throw an exception
@param resultSet ResultSet to analyse
@return The full envelope of the ResultSet
@throws SQLException | [
"Compute",
"the",
"full",
"extend",
"of",
"a",
"ResultSet",
"using",
"the",
"first",
"geometry",
"field",
".",
"If",
"the",
"ResultSet",
"does",
"not",
"contain",
"any",
"geometry",
"field",
"throw",
"an",
"exception"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-utilities/src/main/java/org/h2gis/utilities/SFSUtilities.java#L448-L455 |
elki-project/elki | elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java | KernelMatrix.getSquaredDistance | public double getSquaredDistance(final DBIDRef id1, final DBIDRef id2) {
"""
Returns the squared kernel distance between the two specified objects.
@param id1 first ObjectID
@param id2 second ObjectID
@return the distance between the two objects
"""
final int o1 = idmap.getOffset(id1), o2 = idmap.getOffset(id2);
return kernel[o1][o1] + kernel[o2][o2] - 2 * kernel[o1][o2];
} | java | public double getSquaredDistance(final DBIDRef id1, final DBIDRef id2) {
final int o1 = idmap.getOffset(id1), o2 = idmap.getOffset(id2);
return kernel[o1][o1] + kernel[o2][o2] - 2 * kernel[o1][o2];
} | [
"public",
"double",
"getSquaredDistance",
"(",
"final",
"DBIDRef",
"id1",
",",
"final",
"DBIDRef",
"id2",
")",
"{",
"final",
"int",
"o1",
"=",
"idmap",
".",
"getOffset",
"(",
"id1",
")",
",",
"o2",
"=",
"idmap",
".",
"getOffset",
"(",
"id2",
")",
";",
"return",
"kernel",
"[",
"o1",
"]",
"[",
"o1",
"]",
"+",
"kernel",
"[",
"o2",
"]",
"[",
"o2",
"]",
"-",
"2",
"*",
"kernel",
"[",
"o1",
"]",
"[",
"o2",
"]",
";",
"}"
] | Returns the squared kernel distance between the two specified objects.
@param id1 first ObjectID
@param id2 second ObjectID
@return the distance between the two objects | [
"Returns",
"the",
"squared",
"kernel",
"distance",
"between",
"the",
"two",
"specified",
"objects",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java#L229-L232 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/Utility.java | Utility.lookup | public static int lookup(String source, String[] target) {
"""
Look up a given string in a string array. Returns the index at
which the first occurrence of the string was found in the
array, or -1 if it was not found.
@param source the string to search for
@param target the array of zero or more strings in which to
look for source
@return the index of target at which source first occurs, or -1
if not found
"""
for (int i = 0; i < target.length; ++i) {
if (source.equals(target[i])) return i;
}
return -1;
} | java | public static int lookup(String source, String[] target) {
for (int i = 0; i < target.length; ++i) {
if (source.equals(target[i])) return i;
}
return -1;
} | [
"public",
"static",
"int",
"lookup",
"(",
"String",
"source",
",",
"String",
"[",
"]",
"target",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"target",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"source",
".",
"equals",
"(",
"target",
"[",
"i",
"]",
")",
")",
"return",
"i",
";",
"}",
"return",
"-",
"1",
";",
"}"
] | Look up a given string in a string array. Returns the index at
which the first occurrence of the string was found in the
array, or -1 if it was not found.
@param source the string to search for
@param target the array of zero or more strings in which to
look for source
@return the index of target at which source first occurs, or -1
if not found | [
"Look",
"up",
"a",
"given",
"string",
"in",
"a",
"string",
"array",
".",
"Returns",
"the",
"index",
"at",
"which",
"the",
"first",
"occurrence",
"of",
"the",
"string",
"was",
"found",
"in",
"the",
"array",
"or",
"-",
"1",
"if",
"it",
"was",
"not",
"found",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/Utility.java#L1112-L1117 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/NumberField.java | NumberField.setState | public int setState(boolean state, boolean bDisplayOption, int moveMode) {
"""
For binary fields, set the current state.
@param state The state to set this field.
@param bDisplayOption Display changed fields if true.
@param iMoveMode The move mode.
@return The error code (or NORMAL_RETURN).
"""
double value = 0;
if (state)
value = 1;
return this.setValue(value, bDisplayOption, moveMode); // Move value to this field
} | java | public int setState(boolean state, boolean bDisplayOption, int moveMode)
{
double value = 0;
if (state)
value = 1;
return this.setValue(value, bDisplayOption, moveMode); // Move value to this field
} | [
"public",
"int",
"setState",
"(",
"boolean",
"state",
",",
"boolean",
"bDisplayOption",
",",
"int",
"moveMode",
")",
"{",
"double",
"value",
"=",
"0",
";",
"if",
"(",
"state",
")",
"value",
"=",
"1",
";",
"return",
"this",
".",
"setValue",
"(",
"value",
",",
"bDisplayOption",
",",
"moveMode",
")",
";",
"// Move value to this field",
"}"
] | For binary fields, set the current state.
@param state The state to set this field.
@param bDisplayOption Display changed fields if true.
@param iMoveMode The move mode.
@return The error code (or NORMAL_RETURN). | [
"For",
"binary",
"fields",
"set",
"the",
"current",
"state",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/NumberField.java#L155-L161 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/record/meta/RecordTypeInfo.java | RecordTypeInfo.getNestedStructTypeInfo | public RecordTypeInfo getNestedStructTypeInfo(String name) {
"""
Return the type info of a nested record. We only consider nesting
to one level.
@param name Name of the nested record
"""
StructTypeID stid = sTid.findStruct(name);
if (null == stid) return null;
return new RecordTypeInfo(name, stid);
} | java | public RecordTypeInfo getNestedStructTypeInfo(String name) {
StructTypeID stid = sTid.findStruct(name);
if (null == stid) return null;
return new RecordTypeInfo(name, stid);
} | [
"public",
"RecordTypeInfo",
"getNestedStructTypeInfo",
"(",
"String",
"name",
")",
"{",
"StructTypeID",
"stid",
"=",
"sTid",
".",
"findStruct",
"(",
"name",
")",
";",
"if",
"(",
"null",
"==",
"stid",
")",
"return",
"null",
";",
"return",
"new",
"RecordTypeInfo",
"(",
"name",
",",
"stid",
")",
";",
"}"
] | Return the type info of a nested record. We only consider nesting
to one level.
@param name Name of the nested record | [
"Return",
"the",
"type",
"info",
"of",
"a",
"nested",
"record",
".",
"We",
"only",
"consider",
"nesting",
"to",
"one",
"level",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/record/meta/RecordTypeInfo.java#L109-L113 |
qiujuer/Genius-Android | caprice/kit-cmd/src/main/java/net/qiujuer/genius/kit/cmd/CommandExecutor.java | CommandExecutor.create | protected static CommandExecutor create(int timeout, String param) {
"""
Run
@param param param eg: "/system/bin/ping -c 4 -s 100 www.qiujuer.net"
"""
String[] params = param.split(" ");
CommandExecutor processModel = null;
synchronized (PRC) {
try {
Process process = PRC.command(params)
.redirectErrorStream(true)
.start();
processModel = new CommandExecutor(process, timeout);
// Sleep 10 to create next
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return processModel;
} | java | protected static CommandExecutor create(int timeout, String param) {
String[] params = param.split(" ");
CommandExecutor processModel = null;
synchronized (PRC) {
try {
Process process = PRC.command(params)
.redirectErrorStream(true)
.start();
processModel = new CommandExecutor(process, timeout);
// Sleep 10 to create next
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return processModel;
} | [
"protected",
"static",
"CommandExecutor",
"create",
"(",
"int",
"timeout",
",",
"String",
"param",
")",
"{",
"String",
"[",
"]",
"params",
"=",
"param",
".",
"split",
"(",
"\" \"",
")",
";",
"CommandExecutor",
"processModel",
"=",
"null",
";",
"synchronized",
"(",
"PRC",
")",
"{",
"try",
"{",
"Process",
"process",
"=",
"PRC",
".",
"command",
"(",
"params",
")",
".",
"redirectErrorStream",
"(",
"true",
")",
".",
"start",
"(",
")",
";",
"processModel",
"=",
"new",
"CommandExecutor",
"(",
"process",
",",
"timeout",
")",
";",
"// Sleep 10 to create next",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"10",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"return",
"processModel",
";",
"}"
] | Run
@param param param eg: "/system/bin/ping -c 4 -s 100 www.qiujuer.net" | [
"Run"
] | train | https://github.com/qiujuer/Genius-Android/blob/babefaf1321f5883a21cada582b6fa5104adc648/caprice/kit-cmd/src/main/java/net/qiujuer/genius/kit/cmd/CommandExecutor.java#L110-L131 |
Syncleus/aparapi | src/main/java/com/aparapi/internal/model/MethodModel.java | MethodModel.buildBranchGraphs | public void buildBranchGraphs(Map<Integer, Instruction> pcMap) {
"""
Here we connect the branch nodes to the instruction that they branch to.
<p>
Each branch node contains a 'target' field indended to reference the node that the branch targets. Each instruction also contain four seperate lists of branch nodes that reference it.
These lists hold forwardConditional, forwardUnconditional, reverseConditional and revereseUnconditional branches that reference it.
<p>
So assuming that we had a branch node at pc offset 100 which represented 'goto 200'.
<p>
Following this call the branch node at pc offset 100 will have a 'target' field which actually references the instruction at pc offset 200, and the instruction at pc offset 200 will
have the branch node (at 100) added to it's forwardUnconditional list.
@see InstructionSet.Branch#getTarget()
"""
for (Instruction instruction = pcHead; instruction != null; instruction = instruction.getNextPC()) {
if (instruction.isBranch()) {
final Branch branch = instruction.asBranch();
final Instruction targetInstruction = pcMap.get(branch.getAbsolute());
branch.setTarget(targetInstruction);
}
}
} | java | public void buildBranchGraphs(Map<Integer, Instruction> pcMap) {
for (Instruction instruction = pcHead; instruction != null; instruction = instruction.getNextPC()) {
if (instruction.isBranch()) {
final Branch branch = instruction.asBranch();
final Instruction targetInstruction = pcMap.get(branch.getAbsolute());
branch.setTarget(targetInstruction);
}
}
} | [
"public",
"void",
"buildBranchGraphs",
"(",
"Map",
"<",
"Integer",
",",
"Instruction",
">",
"pcMap",
")",
"{",
"for",
"(",
"Instruction",
"instruction",
"=",
"pcHead",
";",
"instruction",
"!=",
"null",
";",
"instruction",
"=",
"instruction",
".",
"getNextPC",
"(",
")",
")",
"{",
"if",
"(",
"instruction",
".",
"isBranch",
"(",
")",
")",
"{",
"final",
"Branch",
"branch",
"=",
"instruction",
".",
"asBranch",
"(",
")",
";",
"final",
"Instruction",
"targetInstruction",
"=",
"pcMap",
".",
"get",
"(",
"branch",
".",
"getAbsolute",
"(",
")",
")",
";",
"branch",
".",
"setTarget",
"(",
"targetInstruction",
")",
";",
"}",
"}",
"}"
] | Here we connect the branch nodes to the instruction that they branch to.
<p>
Each branch node contains a 'target' field indended to reference the node that the branch targets. Each instruction also contain four seperate lists of branch nodes that reference it.
These lists hold forwardConditional, forwardUnconditional, reverseConditional and revereseUnconditional branches that reference it.
<p>
So assuming that we had a branch node at pc offset 100 which represented 'goto 200'.
<p>
Following this call the branch node at pc offset 100 will have a 'target' field which actually references the instruction at pc offset 200, and the instruction at pc offset 200 will
have the branch node (at 100) added to it's forwardUnconditional list.
@see InstructionSet.Branch#getTarget() | [
"Here",
"we",
"connect",
"the",
"branch",
"nodes",
"to",
"the",
"instruction",
"that",
"they",
"branch",
"to",
".",
"<p",
">",
"Each",
"branch",
"node",
"contains",
"a",
"target",
"field",
"indended",
"to",
"reference",
"the",
"node",
"that",
"the",
"branch",
"targets",
".",
"Each",
"instruction",
"also",
"contain",
"four",
"seperate",
"lists",
"of",
"branch",
"nodes",
"that",
"reference",
"it",
".",
"These",
"lists",
"hold",
"forwardConditional",
"forwardUnconditional",
"reverseConditional",
"and",
"revereseUnconditional",
"branches",
"that",
"reference",
"it",
".",
"<p",
">",
"So",
"assuming",
"that",
"we",
"had",
"a",
"branch",
"node",
"at",
"pc",
"offset",
"100",
"which",
"represented",
"goto",
"200",
".",
"<p",
">",
"Following",
"this",
"call",
"the",
"branch",
"node",
"at",
"pc",
"offset",
"100",
"will",
"have",
"a",
"target",
"field",
"which",
"actually",
"references",
"the",
"instruction",
"at",
"pc",
"offset",
"200",
"and",
"the",
"instruction",
"at",
"pc",
"offset",
"200",
"will",
"have",
"the",
"branch",
"node",
"(",
"at",
"100",
")",
"added",
"to",
"it",
"s",
"forwardUnconditional",
"list",
"."
] | train | https://github.com/Syncleus/aparapi/blob/6d5892c8e69854b3968c541023de37cf4762bd24/src/main/java/com/aparapi/internal/model/MethodModel.java#L315-L323 |
Netflix/Hystrix | hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesFactory.java | HystrixPropertiesFactory.getCommandProperties | public static HystrixCommandProperties getCommandProperties(HystrixCommandKey key, HystrixCommandProperties.Setter builder) {
"""
Get an instance of {@link HystrixCommandProperties} with the given factory {@link HystrixPropertiesStrategy} implementation for each {@link HystrixCommand} instance.
@param key
Pass-thru to {@link HystrixPropertiesStrategy#getCommandProperties} implementation.
@param builder
Pass-thru to {@link HystrixPropertiesStrategy#getCommandProperties} implementation.
@return {@link HystrixCommandProperties} instance
"""
HystrixPropertiesStrategy hystrixPropertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
String cacheKey = hystrixPropertiesStrategy.getCommandPropertiesCacheKey(key, builder);
if (cacheKey != null) {
HystrixCommandProperties properties = commandProperties.get(cacheKey);
if (properties != null) {
return properties;
} else {
if (builder == null) {
builder = HystrixCommandProperties.Setter();
}
// create new instance
properties = hystrixPropertiesStrategy.getCommandProperties(key, builder);
// cache and return
HystrixCommandProperties existing = commandProperties.putIfAbsent(cacheKey, properties);
if (existing == null) {
return properties;
} else {
return existing;
}
}
} else {
// no cacheKey so we generate it with caching
return hystrixPropertiesStrategy.getCommandProperties(key, builder);
}
} | java | public static HystrixCommandProperties getCommandProperties(HystrixCommandKey key, HystrixCommandProperties.Setter builder) {
HystrixPropertiesStrategy hystrixPropertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
String cacheKey = hystrixPropertiesStrategy.getCommandPropertiesCacheKey(key, builder);
if (cacheKey != null) {
HystrixCommandProperties properties = commandProperties.get(cacheKey);
if (properties != null) {
return properties;
} else {
if (builder == null) {
builder = HystrixCommandProperties.Setter();
}
// create new instance
properties = hystrixPropertiesStrategy.getCommandProperties(key, builder);
// cache and return
HystrixCommandProperties existing = commandProperties.putIfAbsent(cacheKey, properties);
if (existing == null) {
return properties;
} else {
return existing;
}
}
} else {
// no cacheKey so we generate it with caching
return hystrixPropertiesStrategy.getCommandProperties(key, builder);
}
} | [
"public",
"static",
"HystrixCommandProperties",
"getCommandProperties",
"(",
"HystrixCommandKey",
"key",
",",
"HystrixCommandProperties",
".",
"Setter",
"builder",
")",
"{",
"HystrixPropertiesStrategy",
"hystrixPropertiesStrategy",
"=",
"HystrixPlugins",
".",
"getInstance",
"(",
")",
".",
"getPropertiesStrategy",
"(",
")",
";",
"String",
"cacheKey",
"=",
"hystrixPropertiesStrategy",
".",
"getCommandPropertiesCacheKey",
"(",
"key",
",",
"builder",
")",
";",
"if",
"(",
"cacheKey",
"!=",
"null",
")",
"{",
"HystrixCommandProperties",
"properties",
"=",
"commandProperties",
".",
"get",
"(",
"cacheKey",
")",
";",
"if",
"(",
"properties",
"!=",
"null",
")",
"{",
"return",
"properties",
";",
"}",
"else",
"{",
"if",
"(",
"builder",
"==",
"null",
")",
"{",
"builder",
"=",
"HystrixCommandProperties",
".",
"Setter",
"(",
")",
";",
"}",
"// create new instance",
"properties",
"=",
"hystrixPropertiesStrategy",
".",
"getCommandProperties",
"(",
"key",
",",
"builder",
")",
";",
"// cache and return",
"HystrixCommandProperties",
"existing",
"=",
"commandProperties",
".",
"putIfAbsent",
"(",
"cacheKey",
",",
"properties",
")",
";",
"if",
"(",
"existing",
"==",
"null",
")",
"{",
"return",
"properties",
";",
"}",
"else",
"{",
"return",
"existing",
";",
"}",
"}",
"}",
"else",
"{",
"// no cacheKey so we generate it with caching",
"return",
"hystrixPropertiesStrategy",
".",
"getCommandProperties",
"(",
"key",
",",
"builder",
")",
";",
"}",
"}"
] | Get an instance of {@link HystrixCommandProperties} with the given factory {@link HystrixPropertiesStrategy} implementation for each {@link HystrixCommand} instance.
@param key
Pass-thru to {@link HystrixPropertiesStrategy#getCommandProperties} implementation.
@param builder
Pass-thru to {@link HystrixPropertiesStrategy#getCommandProperties} implementation.
@return {@link HystrixCommandProperties} instance | [
"Get",
"an",
"instance",
"of",
"{",
"@link",
"HystrixCommandProperties",
"}",
"with",
"the",
"given",
"factory",
"{",
"@link",
"HystrixPropertiesStrategy",
"}",
"implementation",
"for",
"each",
"{",
"@link",
"HystrixCommand",
"}",
"instance",
"."
] | train | https://github.com/Netflix/Hystrix/blob/3cb21589895e9f8f87cfcdbc9d96d9f63d48b848/hystrix-core/src/main/java/com/netflix/hystrix/strategy/properties/HystrixPropertiesFactory.java#L61-L86 |
ops4j/org.ops4j.base | ops4j-base-util/src/main/java/org/ops4j/util/i18n/Resources.java | Resources.getDateTime | public Date getDateTime( String key, Date defaultValue )
throws MissingResourceException {
"""
Retrieve a time from bundle.
@param key the key of resource
@param defaultValue the default value if key is missing
@return the resource time
@throws MissingResourceException if the requested key is unknown
"""
try
{
return getDateTime( key );
}
catch( MissingResourceException mre )
{
return defaultValue;
}
} | java | public Date getDateTime( String key, Date defaultValue )
throws MissingResourceException
{
try
{
return getDateTime( key );
}
catch( MissingResourceException mre )
{
return defaultValue;
}
} | [
"public",
"Date",
"getDateTime",
"(",
"String",
"key",
",",
"Date",
"defaultValue",
")",
"throws",
"MissingResourceException",
"{",
"try",
"{",
"return",
"getDateTime",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"mre",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] | Retrieve a time from bundle.
@param key the key of resource
@param defaultValue the default value if key is missing
@return the resource time
@throws MissingResourceException if the requested key is unknown | [
"Retrieve",
"a",
"time",
"from",
"bundle",
"."
] | train | https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-util/src/main/java/org/ops4j/util/i18n/Resources.java#L631-L642 |
craftercms/commons | utilities/src/main/java/org/craftercms/commons/crypto/PGPUtils.java | PGPUtils.findSecretKey | protected static PGPPrivateKey findSecretKey(InputStream keyStream, long keyId, char[] password) throws Exception {
"""
Extracts the PGP private key from an encoded stream.
@param keyStream stream providing the encoded private key
@param keyId id of the secret key to extract
@param password passphrase for the secret key
@return the private key object
@throws IOException if there is an error reading from the stream
@throws PGPException if the secret key cannot be extracted
"""
PGPSecretKeyRingCollection keyRings = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyStream), new
BcKeyFingerprintCalculator());
PGPSecretKey secretKey = keyRings.getSecretKey(keyId);
if(secretKey == null) {
return null;
}
PBESecretKeyDecryptor decryptor = new JcePBESecretKeyDecryptorBuilder(
new JcaPGPDigestCalculatorProviderBuilder().setProvider(PROVIDER).build())
.setProvider(PROVIDER).build(password);
return secretKey.extractPrivateKey(decryptor);
} | java | protected static PGPPrivateKey findSecretKey(InputStream keyStream, long keyId, char[] password) throws Exception {
PGPSecretKeyRingCollection keyRings = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyStream), new
BcKeyFingerprintCalculator());
PGPSecretKey secretKey = keyRings.getSecretKey(keyId);
if(secretKey == null) {
return null;
}
PBESecretKeyDecryptor decryptor = new JcePBESecretKeyDecryptorBuilder(
new JcaPGPDigestCalculatorProviderBuilder().setProvider(PROVIDER).build())
.setProvider(PROVIDER).build(password);
return secretKey.extractPrivateKey(decryptor);
} | [
"protected",
"static",
"PGPPrivateKey",
"findSecretKey",
"(",
"InputStream",
"keyStream",
",",
"long",
"keyId",
",",
"char",
"[",
"]",
"password",
")",
"throws",
"Exception",
"{",
"PGPSecretKeyRingCollection",
"keyRings",
"=",
"new",
"PGPSecretKeyRingCollection",
"(",
"PGPUtil",
".",
"getDecoderStream",
"(",
"keyStream",
")",
",",
"new",
"BcKeyFingerprintCalculator",
"(",
")",
")",
";",
"PGPSecretKey",
"secretKey",
"=",
"keyRings",
".",
"getSecretKey",
"(",
"keyId",
")",
";",
"if",
"(",
"secretKey",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"PBESecretKeyDecryptor",
"decryptor",
"=",
"new",
"JcePBESecretKeyDecryptorBuilder",
"(",
"new",
"JcaPGPDigestCalculatorProviderBuilder",
"(",
")",
".",
"setProvider",
"(",
"PROVIDER",
")",
".",
"build",
"(",
")",
")",
".",
"setProvider",
"(",
"PROVIDER",
")",
".",
"build",
"(",
"password",
")",
";",
"return",
"secretKey",
".",
"extractPrivateKey",
"(",
"decryptor",
")",
";",
"}"
] | Extracts the PGP private key from an encoded stream.
@param keyStream stream providing the encoded private key
@param keyId id of the secret key to extract
@param password passphrase for the secret key
@return the private key object
@throws IOException if there is an error reading from the stream
@throws PGPException if the secret key cannot be extracted | [
"Extracts",
"the",
"PGP",
"private",
"key",
"from",
"an",
"encoded",
"stream",
"."
] | train | https://github.com/craftercms/commons/blob/3074fe49e56c2a4aae0832f40b17ae563335dc83/utilities/src/main/java/org/craftercms/commons/crypto/PGPUtils.java#L228-L239 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/PoolOperations.java | PoolOperations.stopResizePool | public void stopResizePool(String poolId, Iterable<BatchClientBehavior> additionalBehaviors)
throws BatchErrorException, IOException {
"""
Stops a pool resize operation.
@param poolId
The ID of the pool.
@param additionalBehaviors
A collection of {@link BatchClientBehavior} instances that are
applied to the Batch service request.
@throws BatchErrorException
Exception thrown when an error response is received from the
Batch service.
@throws IOException
Exception thrown when there is an error in
serialization/deserialization of data sent to/received from the
Batch service.
"""
PoolStopResizeOptions options = new PoolStopResizeOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
this.parentBatchClient.protocolLayer().pools().stopResize(poolId, options);
} | java | public void stopResizePool(String poolId, Iterable<BatchClientBehavior> additionalBehaviors)
throws BatchErrorException, IOException {
PoolStopResizeOptions options = new PoolStopResizeOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
this.parentBatchClient.protocolLayer().pools().stopResize(poolId, options);
} | [
"public",
"void",
"stopResizePool",
"(",
"String",
"poolId",
",",
"Iterable",
"<",
"BatchClientBehavior",
">",
"additionalBehaviors",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"PoolStopResizeOptions",
"options",
"=",
"new",
"PoolStopResizeOptions",
"(",
")",
";",
"BehaviorManager",
"bhMgr",
"=",
"new",
"BehaviorManager",
"(",
"this",
".",
"customBehaviors",
"(",
")",
",",
"additionalBehaviors",
")",
";",
"bhMgr",
".",
"applyRequestBehaviors",
"(",
"options",
")",
";",
"this",
".",
"parentBatchClient",
".",
"protocolLayer",
"(",
")",
".",
"pools",
"(",
")",
".",
"stopResize",
"(",
"poolId",
",",
"options",
")",
";",
"}"
] | Stops a pool resize operation.
@param poolId
The ID of the pool.
@param additionalBehaviors
A collection of {@link BatchClientBehavior} instances that are
applied to the Batch service request.
@throws BatchErrorException
Exception thrown when an error response is received from the
Batch service.
@throws IOException
Exception thrown when there is an error in
serialization/deserialization of data sent to/received from the
Batch service. | [
"Stops",
"a",
"pool",
"resize",
"operation",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/PoolOperations.java#L649-L656 |
http-builder-ng/http-builder-ng | http-builder-ng-core/src/main/java/groovyx/net/http/optional/Html.java | Html.neckoParse | public static Object neckoParse(final ChainedHttpConfig config, final FromServer fromServer) {
"""
Method that provides an HTML parser for response configuration (uses necko parser).
@param config the chained configuration
@param fromServer the server response adapter
@return the parsed HTML content (a {@link groovy.util.slurpersupport.GPathResult} object)
"""
try {
final XMLReader p = new org.cyberneko.html.parsers.SAXParser();
p.setEntityResolver(NativeHandlers.Parsers.catalogResolver);
return new XmlSlurper(p).parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset()));
} catch (IOException | SAXException ex) {
throw new TransportingException(ex);
}
} | java | public static Object neckoParse(final ChainedHttpConfig config, final FromServer fromServer) {
try {
final XMLReader p = new org.cyberneko.html.parsers.SAXParser();
p.setEntityResolver(NativeHandlers.Parsers.catalogResolver);
return new XmlSlurper(p).parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset()));
} catch (IOException | SAXException ex) {
throw new TransportingException(ex);
}
} | [
"public",
"static",
"Object",
"neckoParse",
"(",
"final",
"ChainedHttpConfig",
"config",
",",
"final",
"FromServer",
"fromServer",
")",
"{",
"try",
"{",
"final",
"XMLReader",
"p",
"=",
"new",
"org",
".",
"cyberneko",
".",
"html",
".",
"parsers",
".",
"SAXParser",
"(",
")",
";",
"p",
".",
"setEntityResolver",
"(",
"NativeHandlers",
".",
"Parsers",
".",
"catalogResolver",
")",
";",
"return",
"new",
"XmlSlurper",
"(",
"p",
")",
".",
"parse",
"(",
"new",
"InputStreamReader",
"(",
"fromServer",
".",
"getInputStream",
"(",
")",
",",
"fromServer",
".",
"getCharset",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"SAXException",
"ex",
")",
"{",
"throw",
"new",
"TransportingException",
"(",
"ex",
")",
";",
"}",
"}"
] | Method that provides an HTML parser for response configuration (uses necko parser).
@param config the chained configuration
@param fromServer the server response adapter
@return the parsed HTML content (a {@link groovy.util.slurpersupport.GPathResult} object) | [
"Method",
"that",
"provides",
"an",
"HTML",
"parser",
"for",
"response",
"configuration",
"(",
"uses",
"necko",
"parser",
")",
"."
] | train | https://github.com/http-builder-ng/http-builder-ng/blob/865f37732c102c748d3db8b905199dac9222a525/http-builder-ng-core/src/main/java/groovyx/net/http/optional/Html.java#L56-L64 |
fcrepo3/fcrepo | fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/Uploader.java | Uploader.main | public static void main(String[] args) {
"""
Test this class by uploading the given file three times. First, with the
provided credentials, as an InputStream. Second, with the provided
credentials, as a File. Third, with bogus credentials, as a File.
"""
try {
if (args.length == 5 || args.length == 6) {
String protocol = args[0];
int port = Integer.parseInt(args[1]);
String user = args[2];
String password = args[3];
String fileName = args[4];
String context = Constants.FEDORA_DEFAULT_APP_CONTEXT;
if (args.length == 6 && !args[5].isEmpty()) {
context = args[5];
}
Uploader uploader =
new Uploader(protocol, port, context, user, password);
File f = new File(fileName);
System.out.println(uploader.upload(new FileInputStream(f)));
System.out.println(uploader.upload(f));
uploader =
new Uploader(protocol,
port,
context,
user + "test",
password);
System.out.println(uploader.upload(f));
} else {
System.err
.println("Usage: Uploader host port user password file [context]");
}
} catch (Exception e) {
System.err.println("ERROR: " + e.getMessage());
}
} | java | public static void main(String[] args) {
try {
if (args.length == 5 || args.length == 6) {
String protocol = args[0];
int port = Integer.parseInt(args[1]);
String user = args[2];
String password = args[3];
String fileName = args[4];
String context = Constants.FEDORA_DEFAULT_APP_CONTEXT;
if (args.length == 6 && !args[5].isEmpty()) {
context = args[5];
}
Uploader uploader =
new Uploader(protocol, port, context, user, password);
File f = new File(fileName);
System.out.println(uploader.upload(new FileInputStream(f)));
System.out.println(uploader.upload(f));
uploader =
new Uploader(protocol,
port,
context,
user + "test",
password);
System.out.println(uploader.upload(f));
} else {
System.err
.println("Usage: Uploader host port user password file [context]");
}
} catch (Exception e) {
System.err.println("ERROR: " + e.getMessage());
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"try",
"{",
"if",
"(",
"args",
".",
"length",
"==",
"5",
"||",
"args",
".",
"length",
"==",
"6",
")",
"{",
"String",
"protocol",
"=",
"args",
"[",
"0",
"]",
";",
"int",
"port",
"=",
"Integer",
".",
"parseInt",
"(",
"args",
"[",
"1",
"]",
")",
";",
"String",
"user",
"=",
"args",
"[",
"2",
"]",
";",
"String",
"password",
"=",
"args",
"[",
"3",
"]",
";",
"String",
"fileName",
"=",
"args",
"[",
"4",
"]",
";",
"String",
"context",
"=",
"Constants",
".",
"FEDORA_DEFAULT_APP_CONTEXT",
";",
"if",
"(",
"args",
".",
"length",
"==",
"6",
"&&",
"!",
"args",
"[",
"5",
"]",
".",
"isEmpty",
"(",
")",
")",
"{",
"context",
"=",
"args",
"[",
"5",
"]",
";",
"}",
"Uploader",
"uploader",
"=",
"new",
"Uploader",
"(",
"protocol",
",",
"port",
",",
"context",
",",
"user",
",",
"password",
")",
";",
"File",
"f",
"=",
"new",
"File",
"(",
"fileName",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"uploader",
".",
"upload",
"(",
"new",
"FileInputStream",
"(",
"f",
")",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"uploader",
".",
"upload",
"(",
"f",
")",
")",
";",
"uploader",
"=",
"new",
"Uploader",
"(",
"protocol",
",",
"port",
",",
"context",
",",
"user",
"+",
"\"test\"",
",",
"password",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"uploader",
".",
"upload",
"(",
"f",
")",
")",
";",
"}",
"else",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Usage: Uploader host port user password file [context]\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"ERROR: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Test this class by uploading the given file three times. First, with the
provided credentials, as an InputStream. Second, with the provided
credentials, as a File. Third, with bogus credentials, as a File. | [
"Test",
"this",
"class",
"by",
"uploading",
"the",
"given",
"file",
"three",
"times",
".",
"First",
"with",
"the",
"provided",
"credentials",
"as",
"an",
"InputStream",
".",
"Second",
"with",
"the",
"provided",
"credentials",
"as",
"a",
"File",
".",
"Third",
"with",
"bogus",
"credentials",
"as",
"a",
"File",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/Uploader.java#L159-L193 |
mozilla/rhino | src/org/mozilla/javascript/NativeJavaObject.java | NativeJavaObject.coerceType | @Deprecated
public static Object coerceType(Class<?> type, Object value) {
"""
Not intended for public use. Callers should use the
public API Context.toType.
@deprecated as of 1.5 Release 4
@see org.mozilla.javascript.Context#jsToJava(Object, Class)
"""
return coerceTypeImpl(type, value);
} | java | @Deprecated
public static Object coerceType(Class<?> type, Object value)
{
return coerceTypeImpl(type, value);
} | [
"@",
"Deprecated",
"public",
"static",
"Object",
"coerceType",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Object",
"value",
")",
"{",
"return",
"coerceTypeImpl",
"(",
"type",
",",
"value",
")",
";",
"}"
] | Not intended for public use. Callers should use the
public API Context.toType.
@deprecated as of 1.5 Release 4
@see org.mozilla.javascript.Context#jsToJava(Object, Class) | [
"Not",
"intended",
"for",
"public",
"use",
".",
"Callers",
"should",
"use",
"the",
"public",
"API",
"Context",
".",
"toType",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeJavaObject.java#L496-L500 |
WolfgangFahl/Mediawiki-Japi | src/main/java/com/bitplan/mediawiki/japi/user/Crypt.java | Crypt.getRandomCrypt | public static Crypt getRandomCrypt() {
"""
get a random Crypt
@return a new crypt with a 32 byte random key and 8byte salt
"""
String lCypher=generateRandomKey(32);
String lSalt=generateRandomKey(8);
Crypt result=new Crypt(lCypher,lSalt);
return result;
} | java | public static Crypt getRandomCrypt() {
String lCypher=generateRandomKey(32);
String lSalt=generateRandomKey(8);
Crypt result=new Crypt(lCypher,lSalt);
return result;
} | [
"public",
"static",
"Crypt",
"getRandomCrypt",
"(",
")",
"{",
"String",
"lCypher",
"=",
"generateRandomKey",
"(",
"32",
")",
";",
"String",
"lSalt",
"=",
"generateRandomKey",
"(",
"8",
")",
";",
"Crypt",
"result",
"=",
"new",
"Crypt",
"(",
"lCypher",
",",
"lSalt",
")",
";",
"return",
"result",
";",
"}"
] | get a random Crypt
@return a new crypt with a 32 byte random key and 8byte salt | [
"get",
"a",
"random",
"Crypt"
] | train | https://github.com/WolfgangFahl/Mediawiki-Japi/blob/78d0177ebfe02eb05da5550839727861f1e888a5/src/main/java/com/bitplan/mediawiki/japi/user/Crypt.java#L112-L117 |
trajano/caliper | caliper/src/main/java/com/google/caliper/runner/CaliperMain.java | CaliperMain.main | public static void main(String[] args) {
"""
Entry point for the caliper benchmark runner application; run with {@code --help} for details.
"""
PrintWriter stdout = new PrintWriter(System.out, true);
PrintWriter stderr = new PrintWriter(System.err, true);
int code = 1; // pessimism!
try {
exitlessMain(args, stdout, stderr);
code = 0;
} catch (InvalidCommandException e) {
e.display(stderr);
code = e.exitCode();
} catch (InvalidBenchmarkException e) {
e.display(stderr);
} catch (InvalidConfigurationException e) {
e.display(stderr);
} catch (Throwable t) {
t.printStackTrace(stderr);
stdout.println();
stdout.println("An unexpected exception has been thrown by the caliper runner.");
stdout.println("Please see https://sites.google.com/site/caliperusers/issues");
}
stdout.flush();
stderr.flush();
System.exit(code);
} | java | public static void main(String[] args) {
PrintWriter stdout = new PrintWriter(System.out, true);
PrintWriter stderr = new PrintWriter(System.err, true);
int code = 1; // pessimism!
try {
exitlessMain(args, stdout, stderr);
code = 0;
} catch (InvalidCommandException e) {
e.display(stderr);
code = e.exitCode();
} catch (InvalidBenchmarkException e) {
e.display(stderr);
} catch (InvalidConfigurationException e) {
e.display(stderr);
} catch (Throwable t) {
t.printStackTrace(stderr);
stdout.println();
stdout.println("An unexpected exception has been thrown by the caliper runner.");
stdout.println("Please see https://sites.google.com/site/caliperusers/issues");
}
stdout.flush();
stderr.flush();
System.exit(code);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"PrintWriter",
"stdout",
"=",
"new",
"PrintWriter",
"(",
"System",
".",
"out",
",",
"true",
")",
";",
"PrintWriter",
"stderr",
"=",
"new",
"PrintWriter",
"(",
"System",
".",
"err",
",",
"true",
")",
";",
"int",
"code",
"=",
"1",
";",
"// pessimism!",
"try",
"{",
"exitlessMain",
"(",
"args",
",",
"stdout",
",",
"stderr",
")",
";",
"code",
"=",
"0",
";",
"}",
"catch",
"(",
"InvalidCommandException",
"e",
")",
"{",
"e",
".",
"display",
"(",
"stderr",
")",
";",
"code",
"=",
"e",
".",
"exitCode",
"(",
")",
";",
"}",
"catch",
"(",
"InvalidBenchmarkException",
"e",
")",
"{",
"e",
".",
"display",
"(",
"stderr",
")",
";",
"}",
"catch",
"(",
"InvalidConfigurationException",
"e",
")",
"{",
"e",
".",
"display",
"(",
"stderr",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"t",
".",
"printStackTrace",
"(",
"stderr",
")",
";",
"stdout",
".",
"println",
"(",
")",
";",
"stdout",
".",
"println",
"(",
"\"An unexpected exception has been thrown by the caliper runner.\"",
")",
";",
"stdout",
".",
"println",
"(",
"\"Please see https://sites.google.com/site/caliperusers/issues\"",
")",
";",
"}",
"stdout",
".",
"flush",
"(",
")",
";",
"stderr",
".",
"flush",
"(",
")",
";",
"System",
".",
"exit",
"(",
"code",
")",
";",
"}"
] | Entry point for the caliper benchmark runner application; run with {@code --help} for details. | [
"Entry",
"point",
"for",
"the",
"caliper",
"benchmark",
"runner",
"application",
";",
"run",
"with",
"{"
] | train | https://github.com/trajano/caliper/blob/a8bcfd84fa9d7b893b3edfadc3b13240ae5cd658/caliper/src/main/java/com/google/caliper/runner/CaliperMain.java#L73-L102 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java | TmdbSearch.searchMulti | public ResultList<MediaBasic> searchMulti(String query, Integer page, String language, Boolean includeAdult) throws MovieDbException {
"""
Search the movie, tv show and person collections with a single query.
Each item returned in the result array has a media_type field that maps to either movie, tv or person.
Each mapped result is the same response you would get from each independent search
@param query
@param page
@param language
@param includeAdult
@return
@throws MovieDbException
"""
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.QUERY, query);
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.ADULT, includeAdult);
URL url = new ApiUrl(apiKey, MethodBase.SEARCH).subMethod(MethodSub.MULTI).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperMultiSearch wrapper = MAPPER.readValue(webpage, WrapperMultiSearch.class);
ResultList<MediaBasic> results = new ResultList<>();
results.getResults().addAll(wrapper.getResults());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get multi search", url, ex);
}
} | java | public ResultList<MediaBasic> searchMulti(String query, Integer page, String language, Boolean includeAdult) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.QUERY, query);
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.ADULT, includeAdult);
URL url = new ApiUrl(apiKey, MethodBase.SEARCH).subMethod(MethodSub.MULTI).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperMultiSearch wrapper = MAPPER.readValue(webpage, WrapperMultiSearch.class);
ResultList<MediaBasic> results = new ResultList<>();
results.getResults().addAll(wrapper.getResults());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get multi search", url, ex);
}
} | [
"public",
"ResultList",
"<",
"MediaBasic",
">",
"searchMulti",
"(",
"String",
"query",
",",
"Integer",
"page",
",",
"String",
"language",
",",
"Boolean",
"includeAdult",
")",
"throws",
"MovieDbException",
"{",
"TmdbParameters",
"parameters",
"=",
"new",
"TmdbParameters",
"(",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"QUERY",
",",
"query",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"PAGE",
",",
"page",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"LANGUAGE",
",",
"language",
")",
";",
"parameters",
".",
"add",
"(",
"Param",
".",
"ADULT",
",",
"includeAdult",
")",
";",
"URL",
"url",
"=",
"new",
"ApiUrl",
"(",
"apiKey",
",",
"MethodBase",
".",
"SEARCH",
")",
".",
"subMethod",
"(",
"MethodSub",
".",
"MULTI",
")",
".",
"buildUrl",
"(",
"parameters",
")",
";",
"String",
"webpage",
"=",
"httpTools",
".",
"getRequest",
"(",
"url",
")",
";",
"try",
"{",
"WrapperMultiSearch",
"wrapper",
"=",
"MAPPER",
".",
"readValue",
"(",
"webpage",
",",
"WrapperMultiSearch",
".",
"class",
")",
";",
"ResultList",
"<",
"MediaBasic",
">",
"results",
"=",
"new",
"ResultList",
"<>",
"(",
")",
";",
"results",
".",
"getResults",
"(",
")",
".",
"addAll",
"(",
"wrapper",
".",
"getResults",
"(",
")",
")",
";",
"wrapper",
".",
"setResultProperties",
"(",
"results",
")",
";",
"return",
"results",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"MovieDbException",
"(",
"ApiExceptionType",
".",
"MAPPING_FAILED",
",",
"\"Failed to get multi search\"",
",",
"url",
",",
"ex",
")",
";",
"}",
"}"
] | Search the movie, tv show and person collections with a single query.
Each item returned in the result array has a media_type field that maps to either movie, tv or person.
Each mapped result is the same response you would get from each independent search
@param query
@param page
@param language
@param includeAdult
@return
@throws MovieDbException | [
"Search",
"the",
"movie",
"tv",
"show",
"and",
"person",
"collections",
"with",
"a",
"single",
"query",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java#L173-L192 |
js-lib-com/commons | src/main/java/js/util/Classes.java | Classes.findMethod | public static Method findMethod(Class<?> clazz, String methodName) throws NoSuchMethodException {
"""
Find method with given name and unknown parameter types. Traverses all declared methods from given class and
returns the one with specified name; if none found throws {@link NoSuchMethodException}. If there are overloaded
methods returns one of them but there is no guarantee which one. Returned method has accessibility enabled.
<p>
Implementation note: this method is inherently costly since at worst case needs to traverse all class methods. It
is recommended to be used with external method cache.
@param clazz Java class to return method from,
@param methodName method name.
@return class reflective method.
@throws NoSuchMethodException if there is no method with requested name.
"""
for(Method method : clazz.getDeclaredMethods()) {
if(method.getName().equals(methodName)) {
method.setAccessible(true);
return method;
}
}
Class<?> superclass = clazz.getSuperclass();
if(superclass != null) {
if(superclass.getPackage().equals(clazz.getPackage())) {
return findMethod(superclass, methodName);
}
}
throw new NoSuchMethodException(String.format("%s#%s", clazz.getName(), methodName));
} | java | public static Method findMethod(Class<?> clazz, String methodName) throws NoSuchMethodException
{
for(Method method : clazz.getDeclaredMethods()) {
if(method.getName().equals(methodName)) {
method.setAccessible(true);
return method;
}
}
Class<?> superclass = clazz.getSuperclass();
if(superclass != null) {
if(superclass.getPackage().equals(clazz.getPackage())) {
return findMethod(superclass, methodName);
}
}
throw new NoSuchMethodException(String.format("%s#%s", clazz.getName(), methodName));
} | [
"public",
"static",
"Method",
"findMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"methodName",
")",
"throws",
"NoSuchMethodException",
"{",
"for",
"(",
"Method",
"method",
":",
"clazz",
".",
"getDeclaredMethods",
"(",
")",
")",
"{",
"if",
"(",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"methodName",
")",
")",
"{",
"method",
".",
"setAccessible",
"(",
"true",
")",
";",
"return",
"method",
";",
"}",
"}",
"Class",
"<",
"?",
">",
"superclass",
"=",
"clazz",
".",
"getSuperclass",
"(",
")",
";",
"if",
"(",
"superclass",
"!=",
"null",
")",
"{",
"if",
"(",
"superclass",
".",
"getPackage",
"(",
")",
".",
"equals",
"(",
"clazz",
".",
"getPackage",
"(",
")",
")",
")",
"{",
"return",
"findMethod",
"(",
"superclass",
",",
"methodName",
")",
";",
"}",
"}",
"throw",
"new",
"NoSuchMethodException",
"(",
"String",
".",
"format",
"(",
"\"%s#%s\"",
",",
"clazz",
".",
"getName",
"(",
")",
",",
"methodName",
")",
")",
";",
"}"
] | Find method with given name and unknown parameter types. Traverses all declared methods from given class and
returns the one with specified name; if none found throws {@link NoSuchMethodException}. If there are overloaded
methods returns one of them but there is no guarantee which one. Returned method has accessibility enabled.
<p>
Implementation note: this method is inherently costly since at worst case needs to traverse all class methods. It
is recommended to be used with external method cache.
@param clazz Java class to return method from,
@param methodName method name.
@return class reflective method.
@throws NoSuchMethodException if there is no method with requested name. | [
"Find",
"method",
"with",
"given",
"name",
"and",
"unknown",
"parameter",
"types",
".",
"Traverses",
"all",
"declared",
"methods",
"from",
"given",
"class",
"and",
"returns",
"the",
"one",
"with",
"specified",
"name",
";",
"if",
"none",
"found",
"throws",
"{",
"@link",
"NoSuchMethodException",
"}",
".",
"If",
"there",
"are",
"overloaded",
"methods",
"returns",
"one",
"of",
"them",
"but",
"there",
"is",
"no",
"guarantee",
"which",
"one",
".",
"Returned",
"method",
"has",
"accessibility",
"enabled",
".",
"<p",
">",
"Implementation",
"note",
":",
"this",
"method",
"is",
"inherently",
"costly",
"since",
"at",
"worst",
"case",
"needs",
"to",
"traverse",
"all",
"class",
"methods",
".",
"It",
"is",
"recommended",
"to",
"be",
"used",
"with",
"external",
"method",
"cache",
"."
] | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Classes.java#L563-L580 |
zaproxy/zaproxy | src/org/zaproxy/zap/extension/dynssl/SslCertificateUtils.java | SslCertificateUtils.containsSection | private static boolean containsSection(String contents, String beginToken, String endToken) {
"""
Tells whether or not the given ({@code .pem} file) contents contain a section with the given begin and end tokens.
@param contents the ({@code .pem} file) contents to check if contains the section.
@param beginToken the begin token of the section.
@param endToken the end token of the section.
@return {@code true} if the section was found, {@code false} otherwise.
"""
int idxToken;
if ((idxToken = contents.indexOf(beginToken)) == -1 || contents.indexOf(endToken) < idxToken) {
return false;
}
return true;
} | java | private static boolean containsSection(String contents, String beginToken, String endToken) {
int idxToken;
if ((idxToken = contents.indexOf(beginToken)) == -1 || contents.indexOf(endToken) < idxToken) {
return false;
}
return true;
} | [
"private",
"static",
"boolean",
"containsSection",
"(",
"String",
"contents",
",",
"String",
"beginToken",
",",
"String",
"endToken",
")",
"{",
"int",
"idxToken",
";",
"if",
"(",
"(",
"idxToken",
"=",
"contents",
".",
"indexOf",
"(",
"beginToken",
")",
")",
"==",
"-",
"1",
"||",
"contents",
".",
"indexOf",
"(",
"endToken",
")",
"<",
"idxToken",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Tells whether or not the given ({@code .pem} file) contents contain a section with the given begin and end tokens.
@param contents the ({@code .pem} file) contents to check if contains the section.
@param beginToken the begin token of the section.
@param endToken the end token of the section.
@return {@code true} if the section was found, {@code false} otherwise. | [
"Tells",
"whether",
"or",
"not",
"the",
"given",
"(",
"{",
"@code",
".",
"pem",
"}",
"file",
")",
"contents",
"contain",
"a",
"section",
"with",
"the",
"given",
"begin",
"and",
"end",
"tokens",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/dynssl/SslCertificateUtils.java#L253-L259 |
dickschoeller/gedbrowser | geoservice-persistence/src/main/java/org/schoellerfamily/geoservice/model/builder/GeocodeResultBuilder.java | GeocodeResultBuilder.toGeoServiceGeometry | public FeatureCollection toGeoServiceGeometry(final Geometry geometry) {
"""
Create a GeoServiceGeometry from a Geometry.
@param geometry the Geometry
@return the GeoServiceGeometry
"""
if (geometry == null) {
return GeoServiceGeometry.createFeatureCollection(
toLocationFeature(new LatLng(Double.NaN, Double.NaN),
LocationType.UNKNOWN),
null, null);
}
return GeoServiceGeometry.createFeatureCollection(
toLocationFeature(geometry.location, geometry.locationType),
toBox("bounds", geometry.bounds),
toBox("viewport", geometry.viewport));
} | java | public FeatureCollection toGeoServiceGeometry(final Geometry geometry) {
if (geometry == null) {
return GeoServiceGeometry.createFeatureCollection(
toLocationFeature(new LatLng(Double.NaN, Double.NaN),
LocationType.UNKNOWN),
null, null);
}
return GeoServiceGeometry.createFeatureCollection(
toLocationFeature(geometry.location, geometry.locationType),
toBox("bounds", geometry.bounds),
toBox("viewport", geometry.viewport));
} | [
"public",
"FeatureCollection",
"toGeoServiceGeometry",
"(",
"final",
"Geometry",
"geometry",
")",
"{",
"if",
"(",
"geometry",
"==",
"null",
")",
"{",
"return",
"GeoServiceGeometry",
".",
"createFeatureCollection",
"(",
"toLocationFeature",
"(",
"new",
"LatLng",
"(",
"Double",
".",
"NaN",
",",
"Double",
".",
"NaN",
")",
",",
"LocationType",
".",
"UNKNOWN",
")",
",",
"null",
",",
"null",
")",
";",
"}",
"return",
"GeoServiceGeometry",
".",
"createFeatureCollection",
"(",
"toLocationFeature",
"(",
"geometry",
".",
"location",
",",
"geometry",
".",
"locationType",
")",
",",
"toBox",
"(",
"\"bounds\"",
",",
"geometry",
".",
"bounds",
")",
",",
"toBox",
"(",
"\"viewport\"",
",",
"geometry",
".",
"viewport",
")",
")",
";",
"}"
] | Create a GeoServiceGeometry from a Geometry.
@param geometry the Geometry
@return the GeoServiceGeometry | [
"Create",
"a",
"GeoServiceGeometry",
"from",
"a",
"Geometry",
"."
] | train | https://github.com/dickschoeller/gedbrowser/blob/e3e10b1ff3a34ebde9b7edcbfafcd5fe6fb3b3e1/geoservice-persistence/src/main/java/org/schoellerfamily/geoservice/model/builder/GeocodeResultBuilder.java#L200-L211 |
EvidentSolutions/dalesbred | dalesbred/src/main/java/org/dalesbred/Database.java | Database.findUnique | public <T> T findUnique(@NotNull Class<T> cl, @NotNull SqlQuery query) {
"""
Finds a unique result from database, converting the database row to given class using default mechanisms.
@throws NonUniqueResultException if there is more then one row
@throws EmptyResultException if there are no rows
"""
return executeQuery(rowMapperForClass(cl).unique(), query);
} | java | public <T> T findUnique(@NotNull Class<T> cl, @NotNull SqlQuery query) {
return executeQuery(rowMapperForClass(cl).unique(), query);
} | [
"public",
"<",
"T",
">",
"T",
"findUnique",
"(",
"@",
"NotNull",
"Class",
"<",
"T",
">",
"cl",
",",
"@",
"NotNull",
"SqlQuery",
"query",
")",
"{",
"return",
"executeQuery",
"(",
"rowMapperForClass",
"(",
"cl",
")",
".",
"unique",
"(",
")",
",",
"query",
")",
";",
"}"
] | Finds a unique result from database, converting the database row to given class using default mechanisms.
@throws NonUniqueResultException if there is more then one row
@throws EmptyResultException if there are no rows | [
"Finds",
"a",
"unique",
"result",
"from",
"database",
"converting",
"the",
"database",
"row",
"to",
"given",
"class",
"using",
"default",
"mechanisms",
"."
] | train | https://github.com/EvidentSolutions/dalesbred/blob/713f5b6e152d97e1672ca68b9ff9c7c6c288ceb1/dalesbred/src/main/java/org/dalesbred/Database.java#L352-L354 |
BioPAX/Paxtools | pattern/src/main/java/org/biopax/paxtools/pattern/constraint/OR.java | OR.satisfies | @Override
public boolean satisfies(Match match, int... ind) {
"""
Checks if any of the wrapped constraints satisfy.
@param match current pattern match
@param ind mapped indices
@return true if any of the wrapped constraints satisfy
"""
for (MappedConst mc : con)
{
if (mc.satisfies(match, ind)) return true;
}
return false;
} | java | @Override
public boolean satisfies(Match match, int... ind)
{
for (MappedConst mc : con)
{
if (mc.satisfies(match, ind)) return true;
}
return false;
} | [
"@",
"Override",
"public",
"boolean",
"satisfies",
"(",
"Match",
"match",
",",
"int",
"...",
"ind",
")",
"{",
"for",
"(",
"MappedConst",
"mc",
":",
"con",
")",
"{",
"if",
"(",
"mc",
".",
"satisfies",
"(",
"match",
",",
"ind",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if any of the wrapped constraints satisfy.
@param match current pattern match
@param ind mapped indices
@return true if any of the wrapped constraints satisfy | [
"Checks",
"if",
"any",
"of",
"the",
"wrapped",
"constraints",
"satisfy",
"."
] | train | https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/pattern/src/main/java/org/biopax/paxtools/pattern/constraint/OR.java#L39-L47 |
molgenis/molgenis | molgenis-r/src/main/java/org/molgenis/r/RScriptExecutor.java | RScriptExecutor.executeScriptGetFileRequest | private void executeScriptGetFileRequest(
String openCpuSessionKey, String scriptOutputFilename, String outputPathname)
throws IOException {
"""
Retrieve R script file response using OpenCPU and write to file
@param openCpuSessionKey OpenCPU session key
@param scriptOutputFilename R script output filename
@param outputPathname Output pathname
@throws IOException if error occured during script response retrieval
"""
URI scriptGetValueResponseUri =
getScriptGetFileResponseUri(openCpuSessionKey, scriptOutputFilename);
HttpGet httpGet = new HttpGet(scriptGetValueResponseUri);
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
HttpEntity entity = response.getEntity();
Files.copy(entity.getContent(), Paths.get(outputPathname));
EntityUtils.consume(entity);
} else {
throw new ClientProtocolException(format(FORMAT_UNEXPECTED_RESPONSE_STATUS, statusCode));
}
}
} | java | private void executeScriptGetFileRequest(
String openCpuSessionKey, String scriptOutputFilename, String outputPathname)
throws IOException {
URI scriptGetValueResponseUri =
getScriptGetFileResponseUri(openCpuSessionKey, scriptOutputFilename);
HttpGet httpGet = new HttpGet(scriptGetValueResponseUri);
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
HttpEntity entity = response.getEntity();
Files.copy(entity.getContent(), Paths.get(outputPathname));
EntityUtils.consume(entity);
} else {
throw new ClientProtocolException(format(FORMAT_UNEXPECTED_RESPONSE_STATUS, statusCode));
}
}
} | [
"private",
"void",
"executeScriptGetFileRequest",
"(",
"String",
"openCpuSessionKey",
",",
"String",
"scriptOutputFilename",
",",
"String",
"outputPathname",
")",
"throws",
"IOException",
"{",
"URI",
"scriptGetValueResponseUri",
"=",
"getScriptGetFileResponseUri",
"(",
"openCpuSessionKey",
",",
"scriptOutputFilename",
")",
";",
"HttpGet",
"httpGet",
"=",
"new",
"HttpGet",
"(",
"scriptGetValueResponseUri",
")",
";",
"try",
"(",
"CloseableHttpResponse",
"response",
"=",
"httpClient",
".",
"execute",
"(",
"httpGet",
")",
")",
"{",
"int",
"statusCode",
"=",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"statusCode",
">=",
"200",
"&&",
"statusCode",
"<",
"300",
")",
"{",
"HttpEntity",
"entity",
"=",
"response",
".",
"getEntity",
"(",
")",
";",
"Files",
".",
"copy",
"(",
"entity",
".",
"getContent",
"(",
")",
",",
"Paths",
".",
"get",
"(",
"outputPathname",
")",
")",
";",
"EntityUtils",
".",
"consume",
"(",
"entity",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ClientProtocolException",
"(",
"format",
"(",
"FORMAT_UNEXPECTED_RESPONSE_STATUS",
",",
"statusCode",
")",
")",
";",
"}",
"}",
"}"
] | Retrieve R script file response using OpenCPU and write to file
@param openCpuSessionKey OpenCPU session key
@param scriptOutputFilename R script output filename
@param outputPathname Output pathname
@throws IOException if error occured during script response retrieval | [
"Retrieve",
"R",
"script",
"file",
"response",
"using",
"OpenCPU",
"and",
"write",
"to",
"file"
] | train | https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-r/src/main/java/org/molgenis/r/RScriptExecutor.java#L137-L153 |
qos-ch/slf4j | slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java | ProjectConverter.scanFile | private void scanFile(File file) {
"""
Convert the specified file Read each line and ask matcher implementation
for conversion Rewrite the line returned by matcher
@param file
"""
try {
InplaceFileConverter fc = new InplaceFileConverter(ruleSet, progressListener);
fc.convert(file);
} catch (IOException exc) {
addException(new ConversionException(exc.toString()));
}
} | java | private void scanFile(File file) {
try {
InplaceFileConverter fc = new InplaceFileConverter(ruleSet, progressListener);
fc.convert(file);
} catch (IOException exc) {
addException(new ConversionException(exc.toString()));
}
} | [
"private",
"void",
"scanFile",
"(",
"File",
"file",
")",
"{",
"try",
"{",
"InplaceFileConverter",
"fc",
"=",
"new",
"InplaceFileConverter",
"(",
"ruleSet",
",",
"progressListener",
")",
";",
"fc",
".",
"convert",
"(",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"exc",
")",
"{",
"addException",
"(",
"new",
"ConversionException",
"(",
"exc",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}"
] | Convert the specified file Read each line and ask matcher implementation
for conversion Rewrite the line returned by matcher
@param file | [
"Convert",
"the",
"specified",
"file",
"Read",
"each",
"line",
"and",
"ask",
"matcher",
"implementation",
"for",
"conversion",
"Rewrite",
"the",
"line",
"returned",
"by",
"matcher"
] | train | https://github.com/qos-ch/slf4j/blob/905443f39fadd88a8dd2c467e44affd8cb072a4d/slf4j-migrator/src/main/java/org/slf4j/migrator/ProjectConverter.java#L100-L107 |
SeaCloudsEU/SeaCloudsPlatform | sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/AgreementRestEntity.java | AgreementRestEntity.getAgreementsPerTemplateAndConsumer | @GET
@Path("agreementsPerTemplateAndConsumer")
@Deprecated
public List<IAgreement> getAgreementsPerTemplateAndConsumer(
@QueryParam("consumerId") String consumerId,
@QueryParam("templateUUID") String templateUUID) {
"""
Gets a the list of available agreements from where we can get metrics,
host information, etc.
</pre>
Example:
<li>curl http://localhost:8080/sla-service/agreements</li>
<li>curl http://localhost:8080/sla-service/agreements?consumerId=user-10343</li>
@throws NotFoundException
@throws JAXBException
"""
logger.debug("StartOf getAgreementsPerTemplateAndConsumer - REQUEST for /agreementsPerTemplateAndConsumer");
AgreementHelperE agreementRestHelper = getAgreementHelper();
List<IAgreement> agreements = agreementRestHelper.getAgreementsPerTemplateAndConsumer(consumerId, templateUUID);
return agreements;
} | java | @GET
@Path("agreementsPerTemplateAndConsumer")
@Deprecated
public List<IAgreement> getAgreementsPerTemplateAndConsumer(
@QueryParam("consumerId") String consumerId,
@QueryParam("templateUUID") String templateUUID) {
logger.debug("StartOf getAgreementsPerTemplateAndConsumer - REQUEST for /agreementsPerTemplateAndConsumer");
AgreementHelperE agreementRestHelper = getAgreementHelper();
List<IAgreement> agreements = agreementRestHelper.getAgreementsPerTemplateAndConsumer(consumerId, templateUUID);
return agreements;
} | [
"@",
"GET",
"@",
"Path",
"(",
"\"agreementsPerTemplateAndConsumer\"",
")",
"@",
"Deprecated",
"public",
"List",
"<",
"IAgreement",
">",
"getAgreementsPerTemplateAndConsumer",
"(",
"@",
"QueryParam",
"(",
"\"consumerId\"",
")",
"String",
"consumerId",
",",
"@",
"QueryParam",
"(",
"\"templateUUID\"",
")",
"String",
"templateUUID",
")",
"{",
"logger",
".",
"debug",
"(",
"\"StartOf getAgreementsPerTemplateAndConsumer - REQUEST for /agreementsPerTemplateAndConsumer\"",
")",
";",
"AgreementHelperE",
"agreementRestHelper",
"=",
"getAgreementHelper",
"(",
")",
";",
"List",
"<",
"IAgreement",
">",
"agreements",
"=",
"agreementRestHelper",
".",
"getAgreementsPerTemplateAndConsumer",
"(",
"consumerId",
",",
"templateUUID",
")",
";",
"return",
"agreements",
";",
"}"
] | Gets a the list of available agreements from where we can get metrics,
host information, etc.
</pre>
Example:
<li>curl http://localhost:8080/sla-service/agreements</li>
<li>curl http://localhost:8080/sla-service/agreements?consumerId=user-10343</li>
@throws NotFoundException
@throws JAXBException | [
"Gets",
"a",
"the",
"list",
"of",
"available",
"agreements",
"from",
"where",
"we",
"can",
"get",
"metrics",
"host",
"information",
"etc",
"."
] | train | https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/AgreementRestEntity.java#L172-L183 |
ops4j/org.ops4j.pax.logging | pax-logging-api/src/main/java/org/jboss/logging/Logger.java | Logger.errorf | public void errorf(Throwable t, String format, Object... params) {
"""
Issue a formatted log message with a level of ERROR.
@param t the throwable
@param format the format string, as per {@link String#format(String, Object...)}
@param params the parameters
"""
doLogf(Level.ERROR, FQCN, format, params, t);
} | java | public void errorf(Throwable t, String format, Object... params) {
doLogf(Level.ERROR, FQCN, format, params, t);
} | [
"public",
"void",
"errorf",
"(",
"Throwable",
"t",
",",
"String",
"format",
",",
"Object",
"...",
"params",
")",
"{",
"doLogf",
"(",
"Level",
".",
"ERROR",
",",
"FQCN",
",",
"format",
",",
"params",
",",
"t",
")",
";",
"}"
] | Issue a formatted log message with a level of ERROR.
@param t the throwable
@param format the format string, as per {@link String#format(String, Object...)}
@param params the parameters | [
"Issue",
"a",
"formatted",
"log",
"message",
"with",
"a",
"level",
"of",
"ERROR",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/jboss/logging/Logger.java#L1716-L1718 |
Jasig/uPortal | uPortal-web/src/main/java/org/apereo/portal/portlet/rendering/PortletRendererImpl.java | PortletRendererImpl.constructPortletRenderResult | protected PortletRenderResult constructPortletRenderResult(
HttpServletRequest httpServletRequest, long renderTime) {
"""
Construct a {@link PortletRenderResult} from information in the {@link HttpServletRequest}.
The second argument is how long the render action took.
@param httpServletRequest
@param renderTime
@return an appropriate {@link PortletRenderResult}, never null
"""
final String title =
(String) httpServletRequest.getAttribute(IPortletRenderer.ATTRIBUTE__PORTLET_TITLE);
final String newItemCountString =
(String)
httpServletRequest.getAttribute(
IPortletRenderer.ATTRIBUTE__PORTLET_NEW_ITEM_COUNT);
final int newItemCount;
if (newItemCountString != null && StringUtils.isNumeric(newItemCountString)) {
newItemCount = Integer.parseInt(newItemCountString);
} else {
newItemCount = 0;
}
final String link =
(String) httpServletRequest.getAttribute(IPortletRenderer.ATTRIBUTE__PORTLET_LINK);
return new PortletRenderResult(title, link, newItemCount, renderTime);
} | java | protected PortletRenderResult constructPortletRenderResult(
HttpServletRequest httpServletRequest, long renderTime) {
final String title =
(String) httpServletRequest.getAttribute(IPortletRenderer.ATTRIBUTE__PORTLET_TITLE);
final String newItemCountString =
(String)
httpServletRequest.getAttribute(
IPortletRenderer.ATTRIBUTE__PORTLET_NEW_ITEM_COUNT);
final int newItemCount;
if (newItemCountString != null && StringUtils.isNumeric(newItemCountString)) {
newItemCount = Integer.parseInt(newItemCountString);
} else {
newItemCount = 0;
}
final String link =
(String) httpServletRequest.getAttribute(IPortletRenderer.ATTRIBUTE__PORTLET_LINK);
return new PortletRenderResult(title, link, newItemCount, renderTime);
} | [
"protected",
"PortletRenderResult",
"constructPortletRenderResult",
"(",
"HttpServletRequest",
"httpServletRequest",
",",
"long",
"renderTime",
")",
"{",
"final",
"String",
"title",
"=",
"(",
"String",
")",
"httpServletRequest",
".",
"getAttribute",
"(",
"IPortletRenderer",
".",
"ATTRIBUTE__PORTLET_TITLE",
")",
";",
"final",
"String",
"newItemCountString",
"=",
"(",
"String",
")",
"httpServletRequest",
".",
"getAttribute",
"(",
"IPortletRenderer",
".",
"ATTRIBUTE__PORTLET_NEW_ITEM_COUNT",
")",
";",
"final",
"int",
"newItemCount",
";",
"if",
"(",
"newItemCountString",
"!=",
"null",
"&&",
"StringUtils",
".",
"isNumeric",
"(",
"newItemCountString",
")",
")",
"{",
"newItemCount",
"=",
"Integer",
".",
"parseInt",
"(",
"newItemCountString",
")",
";",
"}",
"else",
"{",
"newItemCount",
"=",
"0",
";",
"}",
"final",
"String",
"link",
"=",
"(",
"String",
")",
"httpServletRequest",
".",
"getAttribute",
"(",
"IPortletRenderer",
".",
"ATTRIBUTE__PORTLET_LINK",
")",
";",
"return",
"new",
"PortletRenderResult",
"(",
"title",
",",
"link",
",",
"newItemCount",
",",
"renderTime",
")",
";",
"}"
] | Construct a {@link PortletRenderResult} from information in the {@link HttpServletRequest}.
The second argument is how long the render action took.
@param httpServletRequest
@param renderTime
@return an appropriate {@link PortletRenderResult}, never null | [
"Construct",
"a",
"{",
"@link",
"PortletRenderResult",
"}",
"from",
"information",
"in",
"the",
"{",
"@link",
"HttpServletRequest",
"}",
".",
"The",
"second",
"argument",
"is",
"how",
"long",
"the",
"render",
"action",
"took",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-web/src/main/java/org/apereo/portal/portlet/rendering/PortletRendererImpl.java#L612-L630 |
w3c/epubcheck | src/main/java/org/idpf/epubcheck/util/css/CssParser.java | CssParser.hasRuleSet | private boolean hasRuleSet(CssAtRule atRule, CssTokenIterator iter) {
"""
With iter.last at '{', discover the at-rule type. The
contents is a ruleset if '{' comes before ';' or '}'.
"""
int debugIndex;
if (debug)
{
checkArgument(iter.last.getChar() == '{');
debugIndex = iter.index();
}
List<CssToken> list = iter.list;
for (int i = iter.index() + 1; i < list.size(); i++)
{
CssToken tk = list.get(i);
if (MATCH_OPENBRACE.apply(tk))
{
return true;
}
else if (MATCH_SEMI_CLOSEBRACE.apply(tk))
{
return false;
}
}
if (debug)
{
checkState(iter.last.getChar() == '{');
checkState(iter.index() == debugIndex);
}
return false;
} | java | private boolean hasRuleSet(CssAtRule atRule, CssTokenIterator iter)
{
int debugIndex;
if (debug)
{
checkArgument(iter.last.getChar() == '{');
debugIndex = iter.index();
}
List<CssToken> list = iter.list;
for (int i = iter.index() + 1; i < list.size(); i++)
{
CssToken tk = list.get(i);
if (MATCH_OPENBRACE.apply(tk))
{
return true;
}
else if (MATCH_SEMI_CLOSEBRACE.apply(tk))
{
return false;
}
}
if (debug)
{
checkState(iter.last.getChar() == '{');
checkState(iter.index() == debugIndex);
}
return false;
} | [
"private",
"boolean",
"hasRuleSet",
"(",
"CssAtRule",
"atRule",
",",
"CssTokenIterator",
"iter",
")",
"{",
"int",
"debugIndex",
";",
"if",
"(",
"debug",
")",
"{",
"checkArgument",
"(",
"iter",
".",
"last",
".",
"getChar",
"(",
")",
"==",
"'",
"'",
")",
";",
"debugIndex",
"=",
"iter",
".",
"index",
"(",
")",
";",
"}",
"List",
"<",
"CssToken",
">",
"list",
"=",
"iter",
".",
"list",
";",
"for",
"(",
"int",
"i",
"=",
"iter",
".",
"index",
"(",
")",
"+",
"1",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"CssToken",
"tk",
"=",
"list",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"MATCH_OPENBRACE",
".",
"apply",
"(",
"tk",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"MATCH_SEMI_CLOSEBRACE",
".",
"apply",
"(",
"tk",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"debug",
")",
"{",
"checkState",
"(",
"iter",
".",
"last",
".",
"getChar",
"(",
")",
"==",
"'",
"'",
")",
";",
"checkState",
"(",
"iter",
".",
"index",
"(",
")",
"==",
"debugIndex",
")",
";",
"}",
"return",
"false",
";",
"}"
] | With iter.last at '{', discover the at-rule type. The
contents is a ruleset if '{' comes before ';' or '}'. | [
"With",
"iter",
".",
"last",
"at",
"{",
"discover",
"the",
"at",
"-",
"rule",
"type",
".",
"The",
"contents",
"is",
"a",
"ruleset",
"if",
"{",
"comes",
"before",
";",
"or",
"}",
"."
] | train | https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/org/idpf/epubcheck/util/css/CssParser.java#L666-L693 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/LocaleMatcher.java | LocaleMatcher.addLikelySubtags | private ULocale addLikelySubtags(ULocale languageCode) {
"""
We need to add another method to addLikelySubtags that doesn't return
null, but instead substitutes Zzzz and ZZ if unknown. There are also
a few cases where addLikelySubtags needs to have expanded data, to handle
all deprecated codes.
@param languageCode
@return "fixed" addLikelySubtags
"""
// max("und") = "en_Latn_US", and since matching is based on maximized tags, the undefined
// language would normally match English. But that would produce the counterintuitive results
// that getBestMatch("und", LocaleMatcher("it,en")) would be "en", and
// getBestMatch("en", LocaleMatcher("it,und")) would be "und".
//
// To avoid that, we change the matcher's definitions of max (AddLikelySubtagsWithDefaults)
// so that max("und")="und". That produces the following, more desirable results:
if (languageCode.equals(UNKNOWN_LOCALE)) {
return UNKNOWN_LOCALE;
}
final ULocale result = ULocale.addLikelySubtags(languageCode);
// should have method on getLikelySubtags for this
if (result == null || result.equals(languageCode)) {
final String language = languageCode.getLanguage();
final String script = languageCode.getScript();
final String region = languageCode.getCountry();
return new ULocale((language.length()==0 ? "und"
: language)
+ "_"
+ (script.length()==0 ? "Zzzz" : script)
+ "_"
+ (region.length()==0 ? "ZZ" : region));
}
return result;
} | java | private ULocale addLikelySubtags(ULocale languageCode) {
// max("und") = "en_Latn_US", and since matching is based on maximized tags, the undefined
// language would normally match English. But that would produce the counterintuitive results
// that getBestMatch("und", LocaleMatcher("it,en")) would be "en", and
// getBestMatch("en", LocaleMatcher("it,und")) would be "und".
//
// To avoid that, we change the matcher's definitions of max (AddLikelySubtagsWithDefaults)
// so that max("und")="und". That produces the following, more desirable results:
if (languageCode.equals(UNKNOWN_LOCALE)) {
return UNKNOWN_LOCALE;
}
final ULocale result = ULocale.addLikelySubtags(languageCode);
// should have method on getLikelySubtags for this
if (result == null || result.equals(languageCode)) {
final String language = languageCode.getLanguage();
final String script = languageCode.getScript();
final String region = languageCode.getCountry();
return new ULocale((language.length()==0 ? "und"
: language)
+ "_"
+ (script.length()==0 ? "Zzzz" : script)
+ "_"
+ (region.length()==0 ? "ZZ" : region));
}
return result;
} | [
"private",
"ULocale",
"addLikelySubtags",
"(",
"ULocale",
"languageCode",
")",
"{",
"// max(\"und\") = \"en_Latn_US\", and since matching is based on maximized tags, the undefined",
"// language would normally match English. But that would produce the counterintuitive results",
"// that getBestMatch(\"und\", LocaleMatcher(\"it,en\")) would be \"en\", and",
"// getBestMatch(\"en\", LocaleMatcher(\"it,und\")) would be \"und\".",
"//",
"// To avoid that, we change the matcher's definitions of max (AddLikelySubtagsWithDefaults)",
"// so that max(\"und\")=\"und\". That produces the following, more desirable results:",
"if",
"(",
"languageCode",
".",
"equals",
"(",
"UNKNOWN_LOCALE",
")",
")",
"{",
"return",
"UNKNOWN_LOCALE",
";",
"}",
"final",
"ULocale",
"result",
"=",
"ULocale",
".",
"addLikelySubtags",
"(",
"languageCode",
")",
";",
"// should have method on getLikelySubtags for this",
"if",
"(",
"result",
"==",
"null",
"||",
"result",
".",
"equals",
"(",
"languageCode",
")",
")",
"{",
"final",
"String",
"language",
"=",
"languageCode",
".",
"getLanguage",
"(",
")",
";",
"final",
"String",
"script",
"=",
"languageCode",
".",
"getScript",
"(",
")",
";",
"final",
"String",
"region",
"=",
"languageCode",
".",
"getCountry",
"(",
")",
";",
"return",
"new",
"ULocale",
"(",
"(",
"language",
".",
"length",
"(",
")",
"==",
"0",
"?",
"\"und\"",
":",
"language",
")",
"+",
"\"_\"",
"+",
"(",
"script",
".",
"length",
"(",
")",
"==",
"0",
"?",
"\"Zzzz\"",
":",
"script",
")",
"+",
"\"_\"",
"+",
"(",
"region",
".",
"length",
"(",
")",
"==",
"0",
"?",
"\"ZZ\"",
":",
"region",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | We need to add another method to addLikelySubtags that doesn't return
null, but instead substitutes Zzzz and ZZ if unknown. There are also
a few cases where addLikelySubtags needs to have expanded data, to handle
all deprecated codes.
@param languageCode
@return "fixed" addLikelySubtags | [
"We",
"need",
"to",
"add",
"another",
"method",
"to",
"addLikelySubtags",
"that",
"doesn",
"t",
"return",
"null",
"but",
"instead",
"substitutes",
"Zzzz",
"and",
"ZZ",
"if",
"unknown",
".",
"There",
"are",
"also",
"a",
"few",
"cases",
"where",
"addLikelySubtags",
"needs",
"to",
"have",
"expanded",
"data",
"to",
"handle",
"all",
"deprecated",
"codes",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/LocaleMatcher.java#L352-L377 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/logging/Logger.java | Logger.getAnonymousLogger | @CallerSensitive
public static Logger getAnonymousLogger(String resourceBundleName) {
"""
adding a new anonymous Logger object is handled by doSetParent().
"""
LogManager manager = LogManager.getLogManager();
// cleanup some Loggers that have been GC'ed
manager.drainLoggerRefQueueBounded();
// Android-changed: Use VMStack.getStackClass1.
/* J2ObjC modified.
Logger result = new Logger(null, resourceBundleName,
VMStack.getStackClass1());
*/
Logger result = new Logger(null, resourceBundleName, null);
result.anonymous = true;
Logger root = manager.getLogger("");
result.doSetParent(root);
return result;
} | java | @CallerSensitive
public static Logger getAnonymousLogger(String resourceBundleName) {
LogManager manager = LogManager.getLogManager();
// cleanup some Loggers that have been GC'ed
manager.drainLoggerRefQueueBounded();
// Android-changed: Use VMStack.getStackClass1.
/* J2ObjC modified.
Logger result = new Logger(null, resourceBundleName,
VMStack.getStackClass1());
*/
Logger result = new Logger(null, resourceBundleName, null);
result.anonymous = true;
Logger root = manager.getLogger("");
result.doSetParent(root);
return result;
} | [
"@",
"CallerSensitive",
"public",
"static",
"Logger",
"getAnonymousLogger",
"(",
"String",
"resourceBundleName",
")",
"{",
"LogManager",
"manager",
"=",
"LogManager",
".",
"getLogManager",
"(",
")",
";",
"// cleanup some Loggers that have been GC'ed",
"manager",
".",
"drainLoggerRefQueueBounded",
"(",
")",
";",
"// Android-changed: Use VMStack.getStackClass1.",
"/* J2ObjC modified.\n Logger result = new Logger(null, resourceBundleName,\n VMStack.getStackClass1());\n */",
"Logger",
"result",
"=",
"new",
"Logger",
"(",
"null",
",",
"resourceBundleName",
",",
"null",
")",
";",
"result",
".",
"anonymous",
"=",
"true",
";",
"Logger",
"root",
"=",
"manager",
".",
"getLogger",
"(",
"\"\"",
")",
";",
"result",
".",
"doSetParent",
"(",
"root",
")",
";",
"return",
"result",
";",
"}"
] | adding a new anonymous Logger object is handled by doSetParent(). | [
"adding",
"a",
"new",
"anonymous",
"Logger",
"object",
"is",
"handled",
"by",
"doSetParent",
"()",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/logging/Logger.java#L549-L564 |
arquillian/arquillian-recorder | arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/Configuration.java | Configuration.getProperty | public String getProperty(String name, String defaultValue) throws IllegalStateException {
"""
Gets value of {@code name} property. In case a value for such name does not exist or is a null object or an empty string,
{@code defaultValue} is returned.
@param name name of a property you want to get the value of
@param defaultValue value returned in case {@code name} is a null string or it is empty
@return value of a {@code name} property of {@code defaultValue} when {@code name} is null or empty string
@throws IllegalArgumentException if {@code name} is a null object or an empty string or if {@code defaultValue} is a null
object
"""
Validate.notNullOrEmpty(name, "Unable to get the configuration value of null or empty configuration key");
Validate.notNull(defaultValue, "Unable to set configuration value of " + name + " to null object.");
String found = getConfiguration().get(name);
if (found == null || found.isEmpty()) {
return defaultValue;
} else {
return found;
}
} | java | public String getProperty(String name, String defaultValue) throws IllegalStateException {
Validate.notNullOrEmpty(name, "Unable to get the configuration value of null or empty configuration key");
Validate.notNull(defaultValue, "Unable to set configuration value of " + name + " to null object.");
String found = getConfiguration().get(name);
if (found == null || found.isEmpty()) {
return defaultValue;
} else {
return found;
}
} | [
"public",
"String",
"getProperty",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"throws",
"IllegalStateException",
"{",
"Validate",
".",
"notNullOrEmpty",
"(",
"name",
",",
"\"Unable to get the configuration value of null or empty configuration key\"",
")",
";",
"Validate",
".",
"notNull",
"(",
"defaultValue",
",",
"\"Unable to set configuration value of \"",
"+",
"name",
"+",
"\" to null object.\"",
")",
";",
"String",
"found",
"=",
"getConfiguration",
"(",
")",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"found",
"==",
"null",
"||",
"found",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"defaultValue",
";",
"}",
"else",
"{",
"return",
"found",
";",
"}",
"}"
] | Gets value of {@code name} property. In case a value for such name does not exist or is a null object or an empty string,
{@code defaultValue} is returned.
@param name name of a property you want to get the value of
@param defaultValue value returned in case {@code name} is a null string or it is empty
@return value of a {@code name} property of {@code defaultValue} when {@code name} is null or empty string
@throws IllegalArgumentException if {@code name} is a null object or an empty string or if {@code defaultValue} is a null
object | [
"Gets",
"value",
"of",
"{",
"@code",
"name",
"}",
"property",
".",
"In",
"case",
"a",
"value",
"for",
"such",
"name",
"does",
"not",
"exist",
"or",
"is",
"a",
"null",
"object",
"or",
"an",
"empty",
"string",
"{",
"@code",
"defaultValue",
"}",
"is",
"returned",
"."
] | train | https://github.com/arquillian/arquillian-recorder/blob/e3417111deb03a2e2d9b96d38b986db17e2c1d19/arquillian-recorder/arquillian-recorder-api/src/main/java/org/arquillian/extension/recorder/Configuration.java#L65-L75 |
pwall567/jsonutil | src/main/java/net/pwall/json/JSONObject.java | JSONObject.putValue | public JSONObject putValue(String key, double value) {
"""
Add a {@link JSONDouble} representing the supplied {@code double} to the
{@code JSONObject}.
@param key the key to use when storing the value
@param value the value
@return {@code this} (for chaining)
@throws NullPointerException if key is {@code null}
"""
put(key, JSONDouble.valueOf(value));
return this;
} | java | public JSONObject putValue(String key, double value) {
put(key, JSONDouble.valueOf(value));
return this;
} | [
"public",
"JSONObject",
"putValue",
"(",
"String",
"key",
",",
"double",
"value",
")",
"{",
"put",
"(",
"key",
",",
"JSONDouble",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add a {@link JSONDouble} representing the supplied {@code double} to the
{@code JSONObject}.
@param key the key to use when storing the value
@param value the value
@return {@code this} (for chaining)
@throws NullPointerException if key is {@code null} | [
"Add",
"a",
"{",
"@link",
"JSONDouble",
"}",
"representing",
"the",
"supplied",
"{",
"@code",
"double",
"}",
"to",
"the",
"{",
"@code",
"JSONObject",
"}",
"."
] | train | https://github.com/pwall567/jsonutil/blob/dd5960b9b0bcc9acfe6c52b884fffd9ee5f422fe/src/main/java/net/pwall/json/JSONObject.java#L158-L161 |
google/closure-compiler | src/com/google/javascript/jscomp/Compiler.java | Compiler.resolveSibling | private static String resolveSibling(String fromPath, String toPath) {
"""
Simplistic implementation of the java.nio.file.Path resolveSibling method that works with GWT.
@param fromPath - must be a file (not directory)
@param toPath - must be a file (not directory)
"""
// If the destination is an absolute path, nothing to do.
if (toPath.startsWith("/")) {
return toPath;
}
List<String> fromPathParts = new ArrayList<>(Arrays.asList(fromPath.split("/")));
List<String> toPathParts = new ArrayList<>(Arrays.asList(toPath.split("/")));
if (!fromPathParts.isEmpty()) {
fromPathParts.remove(fromPathParts.size() - 1);
}
while (!fromPathParts.isEmpty() && !toPathParts.isEmpty()) {
if (toPathParts.get(0).equals(".")) {
toPathParts.remove(0);
} else if (toPathParts.get(0).equals("..")) {
toPathParts.remove(0);
fromPathParts.remove(fromPathParts.size() - 1);
} else {
break;
}
}
fromPathParts.addAll(toPathParts);
return String.join("/", fromPathParts);
} | java | private static String resolveSibling(String fromPath, String toPath) {
// If the destination is an absolute path, nothing to do.
if (toPath.startsWith("/")) {
return toPath;
}
List<String> fromPathParts = new ArrayList<>(Arrays.asList(fromPath.split("/")));
List<String> toPathParts = new ArrayList<>(Arrays.asList(toPath.split("/")));
if (!fromPathParts.isEmpty()) {
fromPathParts.remove(fromPathParts.size() - 1);
}
while (!fromPathParts.isEmpty() && !toPathParts.isEmpty()) {
if (toPathParts.get(0).equals(".")) {
toPathParts.remove(0);
} else if (toPathParts.get(0).equals("..")) {
toPathParts.remove(0);
fromPathParts.remove(fromPathParts.size() - 1);
} else {
break;
}
}
fromPathParts.addAll(toPathParts);
return String.join("/", fromPathParts);
} | [
"private",
"static",
"String",
"resolveSibling",
"(",
"String",
"fromPath",
",",
"String",
"toPath",
")",
"{",
"// If the destination is an absolute path, nothing to do.",
"if",
"(",
"toPath",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"return",
"toPath",
";",
"}",
"List",
"<",
"String",
">",
"fromPathParts",
"=",
"new",
"ArrayList",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"fromPath",
".",
"split",
"(",
"\"/\"",
")",
")",
")",
";",
"List",
"<",
"String",
">",
"toPathParts",
"=",
"new",
"ArrayList",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"toPath",
".",
"split",
"(",
"\"/\"",
")",
")",
")",
";",
"if",
"(",
"!",
"fromPathParts",
".",
"isEmpty",
"(",
")",
")",
"{",
"fromPathParts",
".",
"remove",
"(",
"fromPathParts",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}",
"while",
"(",
"!",
"fromPathParts",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"toPathParts",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"toPathParts",
".",
"get",
"(",
"0",
")",
".",
"equals",
"(",
"\".\"",
")",
")",
"{",
"toPathParts",
".",
"remove",
"(",
"0",
")",
";",
"}",
"else",
"if",
"(",
"toPathParts",
".",
"get",
"(",
"0",
")",
".",
"equals",
"(",
"\"..\"",
")",
")",
"{",
"toPathParts",
".",
"remove",
"(",
"0",
")",
";",
"fromPathParts",
".",
"remove",
"(",
"fromPathParts",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"fromPathParts",
".",
"addAll",
"(",
"toPathParts",
")",
";",
"return",
"String",
".",
"join",
"(",
"\"/\"",
",",
"fromPathParts",
")",
";",
"}"
] | Simplistic implementation of the java.nio.file.Path resolveSibling method that works with GWT.
@param fromPath - must be a file (not directory)
@param toPath - must be a file (not directory) | [
"Simplistic",
"implementation",
"of",
"the",
"java",
".",
"nio",
".",
"file",
".",
"Path",
"resolveSibling",
"method",
"that",
"works",
"with",
"GWT",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Compiler.java#L3618-L3643 |
datacleaner/AnalyzerBeans | core/src/main/java/org/eobjects/analyzer/job/runner/AnalysisRunnerJobDelegate.java | AnalysisRunnerJobDelegate.scheduleRowProcessing | private void scheduleRowProcessing(RowProcessingPublishers publishers, LifeCycleHelper lifeCycleHelper,
JobCompletionTaskListener jobCompletionTaskListener, AnalysisJobMetrics analysisJobMetrics) {
"""
Starts row processing job flows.
@param publishers
@param analysisJobMetrics
@param injectionManager
"""
logger.info("Created {} row processor publishers", publishers.size());
final List<TaskRunnable> finalTasks = new ArrayList<TaskRunnable>(2);
finalTasks.add(new TaskRunnable(null, jobCompletionTaskListener));
finalTasks.add(new TaskRunnable(null, new CloseReferenceDataTaskListener(lifeCycleHelper)));
final ForkTaskListener finalTaskListener = new ForkTaskListener("All row consumers finished", _taskRunner,
finalTasks);
final TaskListener rowProcessorPublishersDoneCompletionListener = new JoinTaskListener(publishers.size(),
finalTaskListener);
final Collection<RowProcessingPublisher> rowProcessingPublishers = publishers.getRowProcessingPublishers();
for (RowProcessingPublisher rowProcessingPublisher : rowProcessingPublishers) {
logger.debug("Scheduling row processing publisher: {}", rowProcessingPublisher);
rowProcessingPublisher.runRowProcessing(_resultQueue, rowProcessorPublishersDoneCompletionListener);
}
} | java | private void scheduleRowProcessing(RowProcessingPublishers publishers, LifeCycleHelper lifeCycleHelper,
JobCompletionTaskListener jobCompletionTaskListener, AnalysisJobMetrics analysisJobMetrics) {
logger.info("Created {} row processor publishers", publishers.size());
final List<TaskRunnable> finalTasks = new ArrayList<TaskRunnable>(2);
finalTasks.add(new TaskRunnable(null, jobCompletionTaskListener));
finalTasks.add(new TaskRunnable(null, new CloseReferenceDataTaskListener(lifeCycleHelper)));
final ForkTaskListener finalTaskListener = new ForkTaskListener("All row consumers finished", _taskRunner,
finalTasks);
final TaskListener rowProcessorPublishersDoneCompletionListener = new JoinTaskListener(publishers.size(),
finalTaskListener);
final Collection<RowProcessingPublisher> rowProcessingPublishers = publishers.getRowProcessingPublishers();
for (RowProcessingPublisher rowProcessingPublisher : rowProcessingPublishers) {
logger.debug("Scheduling row processing publisher: {}", rowProcessingPublisher);
rowProcessingPublisher.runRowProcessing(_resultQueue, rowProcessorPublishersDoneCompletionListener);
}
} | [
"private",
"void",
"scheduleRowProcessing",
"(",
"RowProcessingPublishers",
"publishers",
",",
"LifeCycleHelper",
"lifeCycleHelper",
",",
"JobCompletionTaskListener",
"jobCompletionTaskListener",
",",
"AnalysisJobMetrics",
"analysisJobMetrics",
")",
"{",
"logger",
".",
"info",
"(",
"\"Created {} row processor publishers\"",
",",
"publishers",
".",
"size",
"(",
")",
")",
";",
"final",
"List",
"<",
"TaskRunnable",
">",
"finalTasks",
"=",
"new",
"ArrayList",
"<",
"TaskRunnable",
">",
"(",
"2",
")",
";",
"finalTasks",
".",
"add",
"(",
"new",
"TaskRunnable",
"(",
"null",
",",
"jobCompletionTaskListener",
")",
")",
";",
"finalTasks",
".",
"add",
"(",
"new",
"TaskRunnable",
"(",
"null",
",",
"new",
"CloseReferenceDataTaskListener",
"(",
"lifeCycleHelper",
")",
")",
")",
";",
"final",
"ForkTaskListener",
"finalTaskListener",
"=",
"new",
"ForkTaskListener",
"(",
"\"All row consumers finished\"",
",",
"_taskRunner",
",",
"finalTasks",
")",
";",
"final",
"TaskListener",
"rowProcessorPublishersDoneCompletionListener",
"=",
"new",
"JoinTaskListener",
"(",
"publishers",
".",
"size",
"(",
")",
",",
"finalTaskListener",
")",
";",
"final",
"Collection",
"<",
"RowProcessingPublisher",
">",
"rowProcessingPublishers",
"=",
"publishers",
".",
"getRowProcessingPublishers",
"(",
")",
";",
"for",
"(",
"RowProcessingPublisher",
"rowProcessingPublisher",
":",
"rowProcessingPublishers",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Scheduling row processing publisher: {}\"",
",",
"rowProcessingPublisher",
")",
";",
"rowProcessingPublisher",
".",
"runRowProcessing",
"(",
"_resultQueue",
",",
"rowProcessorPublishersDoneCompletionListener",
")",
";",
"}",
"}"
] | Starts row processing job flows.
@param publishers
@param analysisJobMetrics
@param injectionManager | [
"Starts",
"row",
"processing",
"job",
"flows",
"."
] | train | https://github.com/datacleaner/AnalyzerBeans/blob/f82dae080d80d2a647b706a5fb22b3ea250613b3/core/src/main/java/org/eobjects/analyzer/job/runner/AnalysisRunnerJobDelegate.java#L157-L177 |
DiUS/pact-jvm | pact-jvm-consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java | PactDslJsonArray.maxArrayLike | @Override
public PactDslJsonBody maxArrayLike(Integer size, int numberExamples) {
"""
Element that is an array with a maximum size where each item must match the following example
@param size maximum size of the array
@param numberExamples number of examples to generate
"""
if (numberExamples > size) {
throw new IllegalArgumentException(String.format("Number of example %d is more than the maximum size of %d",
numberExamples, size));
}
matchers.addRule(rootPath + appendArrayIndex(1), matchMax(size));
PactDslJsonArray parent = new PactDslJsonArray("", "", this, true);
parent.setNumberExamples(numberExamples);
return new PactDslJsonBody(".", "", parent);
} | java | @Override
public PactDslJsonBody maxArrayLike(Integer size, int numberExamples) {
if (numberExamples > size) {
throw new IllegalArgumentException(String.format("Number of example %d is more than the maximum size of %d",
numberExamples, size));
}
matchers.addRule(rootPath + appendArrayIndex(1), matchMax(size));
PactDslJsonArray parent = new PactDslJsonArray("", "", this, true);
parent.setNumberExamples(numberExamples);
return new PactDslJsonBody(".", "", parent);
} | [
"@",
"Override",
"public",
"PactDslJsonBody",
"maxArrayLike",
"(",
"Integer",
"size",
",",
"int",
"numberExamples",
")",
"{",
"if",
"(",
"numberExamples",
">",
"size",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Number of example %d is more than the maximum size of %d\"",
",",
"numberExamples",
",",
"size",
")",
")",
";",
"}",
"matchers",
".",
"addRule",
"(",
"rootPath",
"+",
"appendArrayIndex",
"(",
"1",
")",
",",
"matchMax",
"(",
"size",
")",
")",
";",
"PactDslJsonArray",
"parent",
"=",
"new",
"PactDslJsonArray",
"(",
"\"\"",
",",
"\"\"",
",",
"this",
",",
"true",
")",
";",
"parent",
".",
"setNumberExamples",
"(",
"numberExamples",
")",
";",
"return",
"new",
"PactDslJsonBody",
"(",
"\".\"",
",",
"\"\"",
",",
"parent",
")",
";",
"}"
] | Element that is an array with a maximum size where each item must match the following example
@param size maximum size of the array
@param numberExamples number of examples to generate | [
"Element",
"that",
"is",
"an",
"array",
"with",
"a",
"maximum",
"size",
"where",
"each",
"item",
"must",
"match",
"the",
"following",
"example"
] | train | https://github.com/DiUS/pact-jvm/blob/2f447e9dd4ac152a6a36b7fcf8962d07de9ef3ef/pact-jvm-consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java#L209-L219 |
netheosgithub/pcs_api | java/src/main/java/net/netheos/pcsapi/storage/StorageBuilder.java | StorageBuilder.setAppInfoRepository | public StorageBuilder setAppInfoRepository( AppInfoRepository appInfoRepo, String appName ) {
"""
Set the app informations repository. This setter must always be called during the build
@param appInfoRepo The repository to use
@param appName The application name
@return The builder
"""
this.appInfoRepo = appInfoRepo;
this.appName = appName;
return this;
} | java | public StorageBuilder setAppInfoRepository( AppInfoRepository appInfoRepo, String appName )
{
this.appInfoRepo = appInfoRepo;
this.appName = appName;
return this;
} | [
"public",
"StorageBuilder",
"setAppInfoRepository",
"(",
"AppInfoRepository",
"appInfoRepo",
",",
"String",
"appName",
")",
"{",
"this",
".",
"appInfoRepo",
"=",
"appInfoRepo",
";",
"this",
".",
"appName",
"=",
"appName",
";",
"return",
"this",
";",
"}"
] | Set the app informations repository. This setter must always be called during the build
@param appInfoRepo The repository to use
@param appName The application name
@return The builder | [
"Set",
"the",
"app",
"informations",
"repository",
".",
"This",
"setter",
"must",
"always",
"be",
"called",
"during",
"the",
"build"
] | train | https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/storage/StorageBuilder.java#L66-L72 |
bramp/ffmpeg-cli-wrapper | src/main/java/net/bramp/ffmpeg/FFmpegUtils.java | FFmpegUtils.toTimecode | public static String toTimecode(long duration, TimeUnit units) {
"""
Convert the duration to "hh:mm:ss" timecode representation, where ss (seconds) can be decimal.
@param duration the duration.
@param units the unit the duration is in.
@return the timecode representation.
"""
// FIXME Negative durations are also supported.
// https://www.ffmpeg.org/ffmpeg-utils.html#Time-duration
checkArgument(duration >= 0, "duration must be positive");
long nanoseconds = units.toNanos(duration); // TODO This will clip at Long.MAX_VALUE
long seconds = units.toSeconds(duration);
long ns = nanoseconds - SECONDS.toNanos(seconds);
long minutes = SECONDS.toMinutes(seconds);
seconds -= MINUTES.toSeconds(minutes);
long hours = MINUTES.toHours(minutes);
minutes -= HOURS.toMinutes(hours);
if (ns == 0) {
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
}
return ZERO.trimTrailingFrom(String.format("%02d:%02d:%02d.%09d", hours, minutes, seconds, ns));
} | java | public static String toTimecode(long duration, TimeUnit units) {
// FIXME Negative durations are also supported.
// https://www.ffmpeg.org/ffmpeg-utils.html#Time-duration
checkArgument(duration >= 0, "duration must be positive");
long nanoseconds = units.toNanos(duration); // TODO This will clip at Long.MAX_VALUE
long seconds = units.toSeconds(duration);
long ns = nanoseconds - SECONDS.toNanos(seconds);
long minutes = SECONDS.toMinutes(seconds);
seconds -= MINUTES.toSeconds(minutes);
long hours = MINUTES.toHours(minutes);
minutes -= HOURS.toMinutes(hours);
if (ns == 0) {
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
}
return ZERO.trimTrailingFrom(String.format("%02d:%02d:%02d.%09d", hours, minutes, seconds, ns));
} | [
"public",
"static",
"String",
"toTimecode",
"(",
"long",
"duration",
",",
"TimeUnit",
"units",
")",
"{",
"// FIXME Negative durations are also supported.",
"// https://www.ffmpeg.org/ffmpeg-utils.html#Time-duration",
"checkArgument",
"(",
"duration",
">=",
"0",
",",
"\"duration must be positive\"",
")",
";",
"long",
"nanoseconds",
"=",
"units",
".",
"toNanos",
"(",
"duration",
")",
";",
"// TODO This will clip at Long.MAX_VALUE",
"long",
"seconds",
"=",
"units",
".",
"toSeconds",
"(",
"duration",
")",
";",
"long",
"ns",
"=",
"nanoseconds",
"-",
"SECONDS",
".",
"toNanos",
"(",
"seconds",
")",
";",
"long",
"minutes",
"=",
"SECONDS",
".",
"toMinutes",
"(",
"seconds",
")",
";",
"seconds",
"-=",
"MINUTES",
".",
"toSeconds",
"(",
"minutes",
")",
";",
"long",
"hours",
"=",
"MINUTES",
".",
"toHours",
"(",
"minutes",
")",
";",
"minutes",
"-=",
"HOURS",
".",
"toMinutes",
"(",
"hours",
")",
";",
"if",
"(",
"ns",
"==",
"0",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%02d:%02d:%02d\"",
",",
"hours",
",",
"minutes",
",",
"seconds",
")",
";",
"}",
"return",
"ZERO",
".",
"trimTrailingFrom",
"(",
"String",
".",
"format",
"(",
"\"%02d:%02d:%02d.%09d\"",
",",
"hours",
",",
"minutes",
",",
"seconds",
",",
"ns",
")",
")",
";",
"}"
] | Convert the duration to "hh:mm:ss" timecode representation, where ss (seconds) can be decimal.
@param duration the duration.
@param units the unit the duration is in.
@return the timecode representation. | [
"Convert",
"the",
"duration",
"to",
"hh",
":",
"mm",
":",
"ss",
"timecode",
"representation",
"where",
"ss",
"(",
"seconds",
")",
"can",
"be",
"decimal",
"."
] | train | https://github.com/bramp/ffmpeg-cli-wrapper/blob/3819b155edf9132acc75bb6af66dcef1b98c64b2/src/main/java/net/bramp/ffmpeg/FFmpegUtils.java#L51-L71 |
aol/cyclops | cyclops/src/main/java/com/oath/cyclops/internal/stream/FutureStreamUtils.java | FutureStreamUtils.forEachWithError | public static <T, X extends Throwable> Tuple3<CompletableFuture<Subscription>, Runnable, CompletableFuture<Boolean>> forEachWithError(
final Stream<T> stream, final Consumer<? super T> consumerElement, final Consumer<? super Throwable> consumerError) {
"""
Perform a forEach operation over the Stream capturing any elements and errors in the supplied consumers,
<pre>
{@code
Subscription next = StreanUtils.forEach(Stream.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::getValue),System.out::println, e->e.printStackTrace());
System.out.println("processed!");
//prints
1
2
RuntimeException Stack Trace on System.err
4
processed!
}
</pre>
@param stream - the Stream to consume data from
@param consumerElement To accept incoming elements from the Stream
@param consumerError To accept incoming processing errors from the Stream
@return A Tuple containing a Future with a Subscription to this publisher, a runnable to skip processing on a separate thread, and future that stores true / false depending on success
"""
return forEachEvent(stream, consumerElement, consumerError, () -> {
});
} | java | public static <T, X extends Throwable> Tuple3<CompletableFuture<Subscription>, Runnable, CompletableFuture<Boolean>> forEachWithError(
final Stream<T> stream, final Consumer<? super T> consumerElement, final Consumer<? super Throwable> consumerError) {
return forEachEvent(stream, consumerElement, consumerError, () -> {
});
} | [
"public",
"static",
"<",
"T",
",",
"X",
"extends",
"Throwable",
">",
"Tuple3",
"<",
"CompletableFuture",
"<",
"Subscription",
">",
",",
"Runnable",
",",
"CompletableFuture",
"<",
"Boolean",
">",
">",
"forEachWithError",
"(",
"final",
"Stream",
"<",
"T",
">",
"stream",
",",
"final",
"Consumer",
"<",
"?",
"super",
"T",
">",
"consumerElement",
",",
"final",
"Consumer",
"<",
"?",
"super",
"Throwable",
">",
"consumerError",
")",
"{",
"return",
"forEachEvent",
"(",
"stream",
",",
"consumerElement",
",",
"consumerError",
",",
"(",
")",
"->",
"{",
"}",
")",
";",
"}"
] | Perform a forEach operation over the Stream capturing any elements and errors in the supplied consumers,
<pre>
{@code
Subscription next = StreanUtils.forEach(Stream.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::getValue),System.out::println, e->e.printStackTrace());
System.out.println("processed!");
//prints
1
2
RuntimeException Stack Trace on System.err
4
processed!
}
</pre>
@param stream - the Stream to consume data from
@param consumerElement To accept incoming elements from the Stream
@param consumerError To accept incoming processing errors from the Stream
@return A Tuple containing a Future with a Subscription to this publisher, a runnable to skip processing on a separate thread, and future that stores true / false depending on success | [
"Perform",
"a",
"forEach",
"operation",
"over",
"the",
"Stream",
"capturing",
"any",
"elements",
"and",
"errors",
"in",
"the",
"supplied",
"consumers",
"<pre",
">",
"{",
"@code",
"Subscription",
"next",
"=",
"StreanUtils",
".",
"forEach",
"(",
"Stream",
".",
"of",
"((",
")",
"-",
">",
"1",
"()",
"-",
">",
"2",
"()",
"-",
">",
"throw",
"new",
"RuntimeException",
"()",
"()",
"-",
">",
"4",
")",
".",
"map",
"(",
"Supplier",
"::",
"getValue",
")",
"System",
".",
"out",
"::",
"println",
"e",
"-",
">",
"e",
".",
"printStackTrace",
"()",
")",
";"
] | train | https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/internal/stream/FutureStreamUtils.java#L198-L203 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/modules/CmsDependenciesEdit.java | CmsDependenciesEdit.getModules | private List getModules() {
"""
Get the list of all modules available.<p>
@return list of module names
"""
List retVal = new ArrayList();
// get all modules
Iterator i = OpenCms.getModuleManager().getModuleNames().iterator();
// add them to the list of modules
while (i.hasNext()) {
String moduleName = (String)i.next();
if (moduleName.equals(getParamDependency())) {
// check for the preselection
retVal.add(new CmsSelectWidgetOption(moduleName, true));
} else {
retVal.add(new CmsSelectWidgetOption(moduleName, false));
}
}
Collections.sort(retVal, new Comparator() {
/** Collator used / wrapped */
private Collator m_collator = Collator.getInstance(getLocale());
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(Object arg0, Object arg1) {
CmsSelectWidgetOption o1 = (CmsSelectWidgetOption)arg0;
CmsSelectWidgetOption o2 = (CmsSelectWidgetOption)arg1;
return m_collator.compare(o1.getOption(), o2.getOption());
}
});
return retVal;
} | java | private List getModules() {
List retVal = new ArrayList();
// get all modules
Iterator i = OpenCms.getModuleManager().getModuleNames().iterator();
// add them to the list of modules
while (i.hasNext()) {
String moduleName = (String)i.next();
if (moduleName.equals(getParamDependency())) {
// check for the preselection
retVal.add(new CmsSelectWidgetOption(moduleName, true));
} else {
retVal.add(new CmsSelectWidgetOption(moduleName, false));
}
}
Collections.sort(retVal, new Comparator() {
/** Collator used / wrapped */
private Collator m_collator = Collator.getInstance(getLocale());
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(Object arg0, Object arg1) {
CmsSelectWidgetOption o1 = (CmsSelectWidgetOption)arg0;
CmsSelectWidgetOption o2 = (CmsSelectWidgetOption)arg1;
return m_collator.compare(o1.getOption(), o2.getOption());
}
});
return retVal;
} | [
"private",
"List",
"getModules",
"(",
")",
"{",
"List",
"retVal",
"=",
"new",
"ArrayList",
"(",
")",
";",
"// get all modules",
"Iterator",
"i",
"=",
"OpenCms",
".",
"getModuleManager",
"(",
")",
".",
"getModuleNames",
"(",
")",
".",
"iterator",
"(",
")",
";",
"// add them to the list of modules",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"moduleName",
"=",
"(",
"String",
")",
"i",
".",
"next",
"(",
")",
";",
"if",
"(",
"moduleName",
".",
"equals",
"(",
"getParamDependency",
"(",
")",
")",
")",
"{",
"// check for the preselection",
"retVal",
".",
"add",
"(",
"new",
"CmsSelectWidgetOption",
"(",
"moduleName",
",",
"true",
")",
")",
";",
"}",
"else",
"{",
"retVal",
".",
"add",
"(",
"new",
"CmsSelectWidgetOption",
"(",
"moduleName",
",",
"false",
")",
")",
";",
"}",
"}",
"Collections",
".",
"sort",
"(",
"retVal",
",",
"new",
"Comparator",
"(",
")",
"{",
"/** Collator used / wrapped */",
"private",
"Collator",
"m_collator",
"=",
"Collator",
".",
"getInstance",
"(",
"getLocale",
"(",
")",
")",
";",
"/**\n * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)\n */",
"public",
"int",
"compare",
"(",
"Object",
"arg0",
",",
"Object",
"arg1",
")",
"{",
"CmsSelectWidgetOption",
"o1",
"=",
"(",
"CmsSelectWidgetOption",
")",
"arg0",
";",
"CmsSelectWidgetOption",
"o2",
"=",
"(",
"CmsSelectWidgetOption",
")",
"arg1",
";",
"return",
"m_collator",
".",
"compare",
"(",
"o1",
".",
"getOption",
"(",
")",
",",
"o2",
".",
"getOption",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"retVal",
";",
"}"
] | Get the list of all modules available.<p>
@return list of module names | [
"Get",
"the",
"list",
"of",
"all",
"modules",
"available",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/modules/CmsDependenciesEdit.java#L381-L413 |
wildfly/wildfly-core | logging/src/main/java/org/jboss/as/logging/LoggingSubsystemParser.java | LoggingSubsystemParser.parsePropertyElement | static void parsePropertyElement(final ModelNode operation, final XMLExtendedStreamReader reader, final String wrapperName) throws XMLStreamException {
"""
Parses a property element.
<p>
The {@code name} attribute is required. If the {@code value} attribute is not present an
{@linkplain org.jboss.dmr.ModelNode UNDEFINED ModelNode} will set on the operation.
</p>
@param operation the operation to add the parsed properties to
@param reader the reader to use
@param wrapperName the name of the attribute that wraps the key and value attributes
@throws XMLStreamException if a parsing error occurs
"""
while (reader.nextTag() != END_ELEMENT) {
final int cnt = reader.getAttributeCount();
String name = null;
String value = null;
for (int i = 0; i < cnt; i++) {
requireNoNamespaceAttribute(reader, i);
final String attrValue = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case NAME: {
name = attrValue;
break;
}
case VALUE: {
value = attrValue;
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (name == null) {
throw missingRequired(reader, Collections.singleton(Attribute.NAME.getLocalName()));
}
operation.get(wrapperName).add(name, (value == null ? new ModelNode() : new ModelNode(value)));
if (reader.nextTag() != END_ELEMENT) {
throw unexpectedElement(reader);
}
}
} | java | static void parsePropertyElement(final ModelNode operation, final XMLExtendedStreamReader reader, final String wrapperName) throws XMLStreamException {
while (reader.nextTag() != END_ELEMENT) {
final int cnt = reader.getAttributeCount();
String name = null;
String value = null;
for (int i = 0; i < cnt; i++) {
requireNoNamespaceAttribute(reader, i);
final String attrValue = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case NAME: {
name = attrValue;
break;
}
case VALUE: {
value = attrValue;
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (name == null) {
throw missingRequired(reader, Collections.singleton(Attribute.NAME.getLocalName()));
}
operation.get(wrapperName).add(name, (value == null ? new ModelNode() : new ModelNode(value)));
if (reader.nextTag() != END_ELEMENT) {
throw unexpectedElement(reader);
}
}
} | [
"static",
"void",
"parsePropertyElement",
"(",
"final",
"ModelNode",
"operation",
",",
"final",
"XMLExtendedStreamReader",
"reader",
",",
"final",
"String",
"wrapperName",
")",
"throws",
"XMLStreamException",
"{",
"while",
"(",
"reader",
".",
"nextTag",
"(",
")",
"!=",
"END_ELEMENT",
")",
"{",
"final",
"int",
"cnt",
"=",
"reader",
".",
"getAttributeCount",
"(",
")",
";",
"String",
"name",
"=",
"null",
";",
"String",
"value",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cnt",
";",
"i",
"++",
")",
"{",
"requireNoNamespaceAttribute",
"(",
"reader",
",",
"i",
")",
";",
"final",
"String",
"attrValue",
"=",
"reader",
".",
"getAttributeValue",
"(",
"i",
")",
";",
"final",
"Attribute",
"attribute",
"=",
"Attribute",
".",
"forName",
"(",
"reader",
".",
"getAttributeLocalName",
"(",
"i",
")",
")",
";",
"switch",
"(",
"attribute",
")",
"{",
"case",
"NAME",
":",
"{",
"name",
"=",
"attrValue",
";",
"break",
";",
"}",
"case",
"VALUE",
":",
"{",
"value",
"=",
"attrValue",
";",
"break",
";",
"}",
"default",
":",
"throw",
"unexpectedAttribute",
"(",
"reader",
",",
"i",
")",
";",
"}",
"}",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"throw",
"missingRequired",
"(",
"reader",
",",
"Collections",
".",
"singleton",
"(",
"Attribute",
".",
"NAME",
".",
"getLocalName",
"(",
")",
")",
")",
";",
"}",
"operation",
".",
"get",
"(",
"wrapperName",
")",
".",
"add",
"(",
"name",
",",
"(",
"value",
"==",
"null",
"?",
"new",
"ModelNode",
"(",
")",
":",
"new",
"ModelNode",
"(",
"value",
")",
")",
")",
";",
"if",
"(",
"reader",
".",
"nextTag",
"(",
")",
"!=",
"END_ELEMENT",
")",
"{",
"throw",
"unexpectedElement",
"(",
"reader",
")",
";",
"}",
"}",
"}"
] | Parses a property element.
<p>
The {@code name} attribute is required. If the {@code value} attribute is not present an
{@linkplain org.jboss.dmr.ModelNode UNDEFINED ModelNode} will set on the operation.
</p>
@param operation the operation to add the parsed properties to
@param reader the reader to use
@param wrapperName the name of the attribute that wraps the key and value attributes
@throws XMLStreamException if a parsing error occurs | [
"Parses",
"a",
"property",
"element",
".",
"<p",
">"
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/logging/src/main/java/org/jboss/as/logging/LoggingSubsystemParser.java#L140-L170 |
Netflix/denominator | route53/src/main/java/denominator/route53/Route53AllProfileResourceRecordSetApi.java | Route53AllProfileResourceRecordSetApi.iterateByName | @Override
public Iterator<ResourceRecordSet<?>> iterateByName(String name) {
"""
lists and lazily transforms all record sets for a name which are not aliases into denominator
format.
"""
Filter<ResourceRecordSet<?>> filter = andNotAlias(nameEqualTo(name));
return lazyIterateRRSets(api.listResourceRecordSets(zoneId, name), filter);
} | java | @Override
public Iterator<ResourceRecordSet<?>> iterateByName(String name) {
Filter<ResourceRecordSet<?>> filter = andNotAlias(nameEqualTo(name));
return lazyIterateRRSets(api.listResourceRecordSets(zoneId, name), filter);
} | [
"@",
"Override",
"public",
"Iterator",
"<",
"ResourceRecordSet",
"<",
"?",
">",
">",
"iterateByName",
"(",
"String",
"name",
")",
"{",
"Filter",
"<",
"ResourceRecordSet",
"<",
"?",
">",
">",
"filter",
"=",
"andNotAlias",
"(",
"nameEqualTo",
"(",
"name",
")",
")",
";",
"return",
"lazyIterateRRSets",
"(",
"api",
".",
"listResourceRecordSets",
"(",
"zoneId",
",",
"name",
")",
",",
"filter",
")",
";",
"}"
] | lists and lazily transforms all record sets for a name which are not aliases into denominator
format. | [
"lists",
"and",
"lazily",
"transforms",
"all",
"record",
"sets",
"for",
"a",
"name",
"which",
"are",
"not",
"aliases",
"into",
"denominator",
"format",
"."
] | train | https://github.com/Netflix/denominator/blob/c565e3b8c6043051252e0947029511f9ac5d306f/route53/src/main/java/denominator/route53/Route53AllProfileResourceRecordSetApi.java#L58-L62 |
JetBrains/xodus | openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java | EnvironmentConfig.setGcFilesInterval | public EnvironmentConfig setGcFilesInterval(final int files) throws InvalidSettingException {
"""
Sets the number of new {@code Log} files (.xd files) that must be created to trigger if necessary (if database
utilization is not sufficient) the next background cleaning cycle (single run of the database garbage collector)
after the previous cycle finished. Default value is {@code 3}, i.e. GC can start after each 3 newly created
{@code Log} files. Cannot be less than {@code 1}.
<p>Mutable at runtime: yes
@param files number of new .xd files that must be created to trigger the next background cleaning cycle
@return this {@code EnvironmentConfig} instance
@throws InvalidSettingException {@code files} is less than {@code 1}
"""
if (files < 1) {
throw new InvalidSettingException("Invalid number of files: " + files);
}
return setSetting(GC_FILES_INTERVAL, files);
} | java | public EnvironmentConfig setGcFilesInterval(final int files) throws InvalidSettingException {
if (files < 1) {
throw new InvalidSettingException("Invalid number of files: " + files);
}
return setSetting(GC_FILES_INTERVAL, files);
} | [
"public",
"EnvironmentConfig",
"setGcFilesInterval",
"(",
"final",
"int",
"files",
")",
"throws",
"InvalidSettingException",
"{",
"if",
"(",
"files",
"<",
"1",
")",
"{",
"throw",
"new",
"InvalidSettingException",
"(",
"\"Invalid number of files: \"",
"+",
"files",
")",
";",
"}",
"return",
"setSetting",
"(",
"GC_FILES_INTERVAL",
",",
"files",
")",
";",
"}"
] | Sets the number of new {@code Log} files (.xd files) that must be created to trigger if necessary (if database
utilization is not sufficient) the next background cleaning cycle (single run of the database garbage collector)
after the previous cycle finished. Default value is {@code 3}, i.e. GC can start after each 3 newly created
{@code Log} files. Cannot be less than {@code 1}.
<p>Mutable at runtime: yes
@param files number of new .xd files that must be created to trigger the next background cleaning cycle
@return this {@code EnvironmentConfig} instance
@throws InvalidSettingException {@code files} is less than {@code 1} | [
"Sets",
"the",
"number",
"of",
"new",
"{",
"@code",
"Log",
"}",
"files",
"(",
".",
"xd",
"files",
")",
"that",
"must",
"be",
"created",
"to",
"trigger",
"if",
"necessary",
"(",
"if",
"database",
"utilization",
"is",
"not",
"sufficient",
")",
"the",
"next",
"background",
"cleaning",
"cycle",
"(",
"single",
"run",
"of",
"the",
"database",
"garbage",
"collector",
")",
"after",
"the",
"previous",
"cycle",
"finished",
".",
"Default",
"value",
"is",
"{",
"@code",
"3",
"}",
"i",
".",
"e",
".",
"GC",
"can",
"start",
"after",
"each",
"3",
"newly",
"created",
"{",
"@code",
"Log",
"}",
"files",
".",
"Cannot",
"be",
"less",
"than",
"{",
"@code",
"1",
"}",
".",
"<p",
">",
"Mutable",
"at",
"runtime",
":",
"yes"
] | train | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java#L1956-L1961 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/capability/RuntimeCapability.java | RuntimeCapability.buildDynamicCapabilityName | public static String buildDynamicCapabilityName(String baseName, String ... dynamicNameElement) {
"""
Constructs a full capability name from a static base name and a dynamic element.
@param baseName the base name. Cannot be {@code null}
@param dynamicNameElement the dynamic portion of the name. Cannot be {@code null}
@return the full capability name. Will not return {@code null}
"""
assert baseName != null;
assert dynamicNameElement != null;
assert dynamicNameElement.length > 0;
StringBuilder sb = new StringBuilder(baseName);
for (String part:dynamicNameElement){
sb.append(".").append(part);
}
return sb.toString();
} | java | public static String buildDynamicCapabilityName(String baseName, String ... dynamicNameElement) {
assert baseName != null;
assert dynamicNameElement != null;
assert dynamicNameElement.length > 0;
StringBuilder sb = new StringBuilder(baseName);
for (String part:dynamicNameElement){
sb.append(".").append(part);
}
return sb.toString();
} | [
"public",
"static",
"String",
"buildDynamicCapabilityName",
"(",
"String",
"baseName",
",",
"String",
"...",
"dynamicNameElement",
")",
"{",
"assert",
"baseName",
"!=",
"null",
";",
"assert",
"dynamicNameElement",
"!=",
"null",
";",
"assert",
"dynamicNameElement",
".",
"length",
">",
"0",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"baseName",
")",
";",
"for",
"(",
"String",
"part",
":",
"dynamicNameElement",
")",
"{",
"sb",
".",
"append",
"(",
"\".\"",
")",
".",
"append",
"(",
"part",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Constructs a full capability name from a static base name and a dynamic element.
@param baseName the base name. Cannot be {@code null}
@param dynamicNameElement the dynamic portion of the name. Cannot be {@code null}
@return the full capability name. Will not return {@code null} | [
"Constructs",
"a",
"full",
"capability",
"name",
"from",
"a",
"static",
"base",
"name",
"and",
"a",
"dynamic",
"element",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/capability/RuntimeCapability.java#L63-L72 |
gocd/gocd | common/src/main/java/com/thoughtworks/go/util/URLService.java | URLService.getPropertiesUrl | public String getPropertiesUrl(JobIdentifier jobIdentifier, String propertyName) {
"""
/*
Agent will use this method, the baseUrl will be injected from config xml in agent side.
This is used to fix security issues with the agent uploading artifacts when security is enabled.
"""
return format("%s/%s/%s/%s",
baseRemotingURL, "remoting", "properties", jobIdentifier.propertyLocator(propertyName));
} | java | public String getPropertiesUrl(JobIdentifier jobIdentifier, String propertyName) {
return format("%s/%s/%s/%s",
baseRemotingURL, "remoting", "properties", jobIdentifier.propertyLocator(propertyName));
} | [
"public",
"String",
"getPropertiesUrl",
"(",
"JobIdentifier",
"jobIdentifier",
",",
"String",
"propertyName",
")",
"{",
"return",
"format",
"(",
"\"%s/%s/%s/%s\"",
",",
"baseRemotingURL",
",",
"\"remoting\"",
",",
"\"properties\"",
",",
"jobIdentifier",
".",
"propertyLocator",
"(",
"propertyName",
")",
")",
";",
"}"
] | /*
Agent will use this method, the baseUrl will be injected from config xml in agent side.
This is used to fix security issues with the agent uploading artifacts when security is enabled. | [
"/",
"*",
"Agent",
"will",
"use",
"this",
"method",
"the",
"baseUrl",
"will",
"be",
"injected",
"from",
"config",
"xml",
"in",
"agent",
"side",
".",
"This",
"is",
"used",
"to",
"fix",
"security",
"issues",
"with",
"the",
"agent",
"uploading",
"artifacts",
"when",
"security",
"is",
"enabled",
"."
] | train | https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/common/src/main/java/com/thoughtworks/go/util/URLService.java#L90-L93 |
cdk/cdk | tool/hash/src/main/java/org/openscience/cdk/hash/stereo/GeometricDoubleBondEncoderFactory.java | GeometricDoubleBondEncoderFactory.newEncoder | static StereoEncoder newEncoder(IAtomContainer container, IAtom left, IAtom leftParent, IAtom right,
IAtom rightParent, int[][] graph) {
"""
Create a new encoder for the specified left and right atoms. The parent
is the atom which is connected by a double bond to the left and right
atom. For simple double bonds the parent of each is the other atom, in
cumulenes the parents are not the same.
@param container the molecule
@param left the left atom
@param leftParent the left atoms parent (usually {@literal right})
@param right the right atom
@param rightParent the right atoms parent (usually {@literal left})
@param graph adjacency list representation of the molecule
@return a stereo encoder (or null)
"""
List<IBond> leftBonds = container.getConnectedBondsList(left);
List<IBond> rightBonds = container.getConnectedBondsList(right);
// check the left and right bonds are acceptable
if (accept(left, leftBonds) && accept(right, rightBonds)) {
int leftIndex = container.indexOf(left);
int rightIndex = container.indexOf(right);
int leftParentIndex = container.indexOf(leftParent);
int rightParentIndex = container.indexOf(rightParent);
// neighbors of u/v with the bonded atoms (left,right) moved
// to the back of each array. this is important as we can
// drop it when we build the permutation parity
int[] leftNeighbors = moveToBack(graph[leftIndex], leftParentIndex);
int[] rightNeighbors = moveToBack(graph[rightIndex], rightParentIndex);
int l1 = leftNeighbors[0];
int l2 = leftNeighbors[1] == leftParentIndex ? leftIndex : leftNeighbors[1];
int r1 = rightNeighbors[0];
int r2 = rightNeighbors[1] == rightParentIndex ? rightIndex : rightNeighbors[1];
// make 2D/3D geometry
GeometricParity geometric = geometric(container, leftIndex, rightIndex, l1, l2, r1, r2);
// geometric is null if there were no coordinates
if (geometric != null) {
return new GeometryEncoder(new int[]{leftIndex, rightIndex}, new CombinedPermutationParity(
permutation(leftNeighbors), permutation(rightNeighbors)), geometric);
}
}
return null;
} | java | static StereoEncoder newEncoder(IAtomContainer container, IAtom left, IAtom leftParent, IAtom right,
IAtom rightParent, int[][] graph) {
List<IBond> leftBonds = container.getConnectedBondsList(left);
List<IBond> rightBonds = container.getConnectedBondsList(right);
// check the left and right bonds are acceptable
if (accept(left, leftBonds) && accept(right, rightBonds)) {
int leftIndex = container.indexOf(left);
int rightIndex = container.indexOf(right);
int leftParentIndex = container.indexOf(leftParent);
int rightParentIndex = container.indexOf(rightParent);
// neighbors of u/v with the bonded atoms (left,right) moved
// to the back of each array. this is important as we can
// drop it when we build the permutation parity
int[] leftNeighbors = moveToBack(graph[leftIndex], leftParentIndex);
int[] rightNeighbors = moveToBack(graph[rightIndex], rightParentIndex);
int l1 = leftNeighbors[0];
int l2 = leftNeighbors[1] == leftParentIndex ? leftIndex : leftNeighbors[1];
int r1 = rightNeighbors[0];
int r2 = rightNeighbors[1] == rightParentIndex ? rightIndex : rightNeighbors[1];
// make 2D/3D geometry
GeometricParity geometric = geometric(container, leftIndex, rightIndex, l1, l2, r1, r2);
// geometric is null if there were no coordinates
if (geometric != null) {
return new GeometryEncoder(new int[]{leftIndex, rightIndex}, new CombinedPermutationParity(
permutation(leftNeighbors), permutation(rightNeighbors)), geometric);
}
}
return null;
} | [
"static",
"StereoEncoder",
"newEncoder",
"(",
"IAtomContainer",
"container",
",",
"IAtom",
"left",
",",
"IAtom",
"leftParent",
",",
"IAtom",
"right",
",",
"IAtom",
"rightParent",
",",
"int",
"[",
"]",
"[",
"]",
"graph",
")",
"{",
"List",
"<",
"IBond",
">",
"leftBonds",
"=",
"container",
".",
"getConnectedBondsList",
"(",
"left",
")",
";",
"List",
"<",
"IBond",
">",
"rightBonds",
"=",
"container",
".",
"getConnectedBondsList",
"(",
"right",
")",
";",
"// check the left and right bonds are acceptable",
"if",
"(",
"accept",
"(",
"left",
",",
"leftBonds",
")",
"&&",
"accept",
"(",
"right",
",",
"rightBonds",
")",
")",
"{",
"int",
"leftIndex",
"=",
"container",
".",
"indexOf",
"(",
"left",
")",
";",
"int",
"rightIndex",
"=",
"container",
".",
"indexOf",
"(",
"right",
")",
";",
"int",
"leftParentIndex",
"=",
"container",
".",
"indexOf",
"(",
"leftParent",
")",
";",
"int",
"rightParentIndex",
"=",
"container",
".",
"indexOf",
"(",
"rightParent",
")",
";",
"// neighbors of u/v with the bonded atoms (left,right) moved",
"// to the back of each array. this is important as we can",
"// drop it when we build the permutation parity",
"int",
"[",
"]",
"leftNeighbors",
"=",
"moveToBack",
"(",
"graph",
"[",
"leftIndex",
"]",
",",
"leftParentIndex",
")",
";",
"int",
"[",
"]",
"rightNeighbors",
"=",
"moveToBack",
"(",
"graph",
"[",
"rightIndex",
"]",
",",
"rightParentIndex",
")",
";",
"int",
"l1",
"=",
"leftNeighbors",
"[",
"0",
"]",
";",
"int",
"l2",
"=",
"leftNeighbors",
"[",
"1",
"]",
"==",
"leftParentIndex",
"?",
"leftIndex",
":",
"leftNeighbors",
"[",
"1",
"]",
";",
"int",
"r1",
"=",
"rightNeighbors",
"[",
"0",
"]",
";",
"int",
"r2",
"=",
"rightNeighbors",
"[",
"1",
"]",
"==",
"rightParentIndex",
"?",
"rightIndex",
":",
"rightNeighbors",
"[",
"1",
"]",
";",
"// make 2D/3D geometry",
"GeometricParity",
"geometric",
"=",
"geometric",
"(",
"container",
",",
"leftIndex",
",",
"rightIndex",
",",
"l1",
",",
"l2",
",",
"r1",
",",
"r2",
")",
";",
"// geometric is null if there were no coordinates",
"if",
"(",
"geometric",
"!=",
"null",
")",
"{",
"return",
"new",
"GeometryEncoder",
"(",
"new",
"int",
"[",
"]",
"{",
"leftIndex",
",",
"rightIndex",
"}",
",",
"new",
"CombinedPermutationParity",
"(",
"permutation",
"(",
"leftNeighbors",
")",
",",
"permutation",
"(",
"rightNeighbors",
")",
")",
",",
"geometric",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Create a new encoder for the specified left and right atoms. The parent
is the atom which is connected by a double bond to the left and right
atom. For simple double bonds the parent of each is the other atom, in
cumulenes the parents are not the same.
@param container the molecule
@param left the left atom
@param leftParent the left atoms parent (usually {@literal right})
@param right the right atom
@param rightParent the right atoms parent (usually {@literal left})
@param graph adjacency list representation of the molecule
@return a stereo encoder (or null) | [
"Create",
"a",
"new",
"encoder",
"for",
"the",
"specified",
"left",
"and",
"right",
"atoms",
".",
"The",
"parent",
"is",
"the",
"atom",
"which",
"is",
"connected",
"by",
"a",
"double",
"bond",
"to",
"the",
"left",
"and",
"right",
"atom",
".",
"For",
"simple",
"double",
"bonds",
"the",
"parent",
"of",
"each",
"is",
"the",
"other",
"atom",
"in",
"cumulenes",
"the",
"parents",
"are",
"not",
"the",
"same",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/hash/src/main/java/org/openscience/cdk/hash/stereo/GeometricDoubleBondEncoderFactory.java#L108-L146 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/CertificatesImpl.java | CertificatesImpl.listNextWithServiceResponseAsync | public Observable<ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders>> listNextWithServiceResponseAsync(final String nextPageLink, final CertificateListNextOptions certificateListNextOptions) {
"""
Lists all of the certificates that have been added to the specified account.
@param nextPageLink The NextLink from the previous successful call to List operation.
@param certificateListNextOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<Certificate> object
"""
return listNextSinglePageAsync(nextPageLink, certificateListNextOptions)
.concatMap(new Func1<ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders>, Observable<ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders>> call(ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, certificateListNextOptions));
}
});
} | java | public Observable<ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders>> listNextWithServiceResponseAsync(final String nextPageLink, final CertificateListNextOptions certificateListNextOptions) {
return listNextSinglePageAsync(nextPageLink, certificateListNextOptions)
.concatMap(new Func1<ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders>, Observable<ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders>> call(ServiceResponseWithHeaders<Page<Certificate>, CertificateListHeaders> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, certificateListNextOptions));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"Certificate",
">",
",",
"CertificateListHeaders",
">",
">",
"listNextWithServiceResponseAsync",
"(",
"final",
"String",
"nextPageLink",
",",
"final",
"CertificateListNextOptions",
"certificateListNextOptions",
")",
"{",
"return",
"listNextSinglePageAsync",
"(",
"nextPageLink",
",",
"certificateListNextOptions",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"Certificate",
">",
",",
"CertificateListHeaders",
">",
",",
"Observable",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"Certificate",
">",
",",
"CertificateListHeaders",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"Certificate",
">",
",",
"CertificateListHeaders",
">",
">",
"call",
"(",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"Certificate",
">",
",",
"CertificateListHeaders",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listNextWithServiceResponseAsync",
"(",
"nextPageLink",
",",
"certificateListNextOptions",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Lists all of the certificates that have been added to the specified account.
@param nextPageLink The NextLink from the previous successful call to List operation.
@param certificateListNextOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<Certificate> object | [
"Lists",
"all",
"of",
"the",
"certificates",
"that",
"have",
"been",
"added",
"to",
"the",
"specified",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/CertificatesImpl.java#L1372-L1384 |
gallandarakhneorg/afc | core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java | XMLUtil.getElementFromPath | @Pure
public static Element getElementFromPath(Node document, boolean caseSensitive, String... path) {
"""
Replies the node that corresponds to the specified path.
<p>The path is an ordered list of tag's names and ended by the name of
the desired node.
@param document is the XML document to explore.
@param caseSensitive indicates of the {@code path}'s components are case sensitive.
@param path is the list of names.
@return the node or <code>null</code> if it was not found in the document.
"""
assert document != null : AssertMessages.notNullParameter(0);
return getElementFromPath(document, caseSensitive, 0, path);
} | java | @Pure
public static Element getElementFromPath(Node document, boolean caseSensitive, String... path) {
assert document != null : AssertMessages.notNullParameter(0);
return getElementFromPath(document, caseSensitive, 0, path);
} | [
"@",
"Pure",
"public",
"static",
"Element",
"getElementFromPath",
"(",
"Node",
"document",
",",
"boolean",
"caseSensitive",
",",
"String",
"...",
"path",
")",
"{",
"assert",
"document",
"!=",
"null",
":",
"AssertMessages",
".",
"notNullParameter",
"(",
"0",
")",
";",
"return",
"getElementFromPath",
"(",
"document",
",",
"caseSensitive",
",",
"0",
",",
"path",
")",
";",
"}"
] | Replies the node that corresponds to the specified path.
<p>The path is an ordered list of tag's names and ended by the name of
the desired node.
@param document is the XML document to explore.
@param caseSensitive indicates of the {@code path}'s components are case sensitive.
@param path is the list of names.
@return the node or <code>null</code> if it was not found in the document. | [
"Replies",
"the",
"node",
"that",
"corresponds",
"to",
"the",
"specified",
"path",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java#L1386-L1390 |
arakelian/jackson-utils | src/main/java/com/arakelian/jackson/model/Coordinate.java | Coordinate.equals2D | public boolean equals2D(final Coordinate c, final double tolerance) {
"""
Tests if another coordinate has the same values for the X and Y ordinates. The Z ordinate is
ignored.
@param c
a <code>Coordinate</code> with which to do the 2D comparison.
@param tolerance
margin of error
@return true if <code>other</code> is a <code>Coordinate</code> with the same values for X
and Y.
"""
if (!equalsWithTolerance(this.getX(), c.getX(), tolerance)) {
return false;
}
if (!equalsWithTolerance(this.getY(), c.getY(), tolerance)) {
return false;
}
return true;
} | java | public boolean equals2D(final Coordinate c, final double tolerance) {
if (!equalsWithTolerance(this.getX(), c.getX(), tolerance)) {
return false;
}
if (!equalsWithTolerance(this.getY(), c.getY(), tolerance)) {
return false;
}
return true;
} | [
"public",
"boolean",
"equals2D",
"(",
"final",
"Coordinate",
"c",
",",
"final",
"double",
"tolerance",
")",
"{",
"if",
"(",
"!",
"equalsWithTolerance",
"(",
"this",
".",
"getX",
"(",
")",
",",
"c",
".",
"getX",
"(",
")",
",",
"tolerance",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"equalsWithTolerance",
"(",
"this",
".",
"getY",
"(",
")",
",",
"c",
".",
"getY",
"(",
")",
",",
"tolerance",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Tests if another coordinate has the same values for the X and Y ordinates. The Z ordinate is
ignored.
@param c
a <code>Coordinate</code> with which to do the 2D comparison.
@param tolerance
margin of error
@return true if <code>other</code> is a <code>Coordinate</code> with the same values for X
and Y. | [
"Tests",
"if",
"another",
"coordinate",
"has",
"the",
"same",
"values",
"for",
"the",
"X",
"and",
"Y",
"ordinates",
".",
"The",
"Z",
"ordinate",
"is",
"ignored",
"."
] | train | https://github.com/arakelian/jackson-utils/blob/db0028fe15c55f9dd8272e327bf67f6004011711/src/main/java/com/arakelian/jackson/model/Coordinate.java#L271-L279 |
webmetrics/browsermob-proxy | src/main/java/org/browsermob/proxy/jetty/util/Password.java | Password.getPassword | public static Password getPassword(String realm,String dft, String promptDft) {
"""
Get a password.
A password is obtained by trying <UL>
<LI>Calling <Code>System.getProperty(realm,dft)</Code>
<LI>Prompting for a password
<LI>Using promptDft if nothing was entered.
</UL>
@param realm The realm name for the password, used as a SystemProperty name.
@param dft The default password.
@param promptDft The default to use if prompting for the password.
@return Password
"""
String passwd=System.getProperty(realm,dft);
if (passwd==null || passwd.length()==0)
{
try
{
System.out.print(realm+
((promptDft!=null && promptDft.length()>0)
?" [dft]":"")+" : ");
System.out.flush();
byte[] buf = new byte[512];
int len=System.in.read(buf);
if (len>0)
passwd=new String(buf,0,len).trim();
}
catch(IOException e)
{
log.warn(LogSupport.EXCEPTION,e);
}
if (passwd==null || passwd.length()==0)
passwd=promptDft;
}
return new Password(passwd);
} | java | public static Password getPassword(String realm,String dft, String promptDft)
{
String passwd=System.getProperty(realm,dft);
if (passwd==null || passwd.length()==0)
{
try
{
System.out.print(realm+
((promptDft!=null && promptDft.length()>0)
?" [dft]":"")+" : ");
System.out.flush();
byte[] buf = new byte[512];
int len=System.in.read(buf);
if (len>0)
passwd=new String(buf,0,len).trim();
}
catch(IOException e)
{
log.warn(LogSupport.EXCEPTION,e);
}
if (passwd==null || passwd.length()==0)
passwd=promptDft;
}
return new Password(passwd);
} | [
"public",
"static",
"Password",
"getPassword",
"(",
"String",
"realm",
",",
"String",
"dft",
",",
"String",
"promptDft",
")",
"{",
"String",
"passwd",
"=",
"System",
".",
"getProperty",
"(",
"realm",
",",
"dft",
")",
";",
"if",
"(",
"passwd",
"==",
"null",
"||",
"passwd",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"try",
"{",
"System",
".",
"out",
".",
"print",
"(",
"realm",
"+",
"(",
"(",
"promptDft",
"!=",
"null",
"&&",
"promptDft",
".",
"length",
"(",
")",
">",
"0",
")",
"?",
"\" [dft]\"",
":",
"\"\"",
")",
"+",
"\" : \"",
")",
";",
"System",
".",
"out",
".",
"flush",
"(",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"512",
"]",
";",
"int",
"len",
"=",
"System",
".",
"in",
".",
"read",
"(",
"buf",
")",
";",
"if",
"(",
"len",
">",
"0",
")",
"passwd",
"=",
"new",
"String",
"(",
"buf",
",",
"0",
",",
"len",
")",
".",
"trim",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"LogSupport",
".",
"EXCEPTION",
",",
"e",
")",
";",
"}",
"if",
"(",
"passwd",
"==",
"null",
"||",
"passwd",
".",
"length",
"(",
")",
"==",
"0",
")",
"passwd",
"=",
"promptDft",
";",
"}",
"return",
"new",
"Password",
"(",
"passwd",
")",
";",
"}"
] | Get a password.
A password is obtained by trying <UL>
<LI>Calling <Code>System.getProperty(realm,dft)</Code>
<LI>Prompting for a password
<LI>Using promptDft if nothing was entered.
</UL>
@param realm The realm name for the password, used as a SystemProperty name.
@param dft The default password.
@param promptDft The default to use if prompting for the password.
@return Password | [
"Get",
"a",
"password",
".",
"A",
"password",
"is",
"obtained",
"by",
"trying",
"<UL",
">",
"<LI",
">",
"Calling",
"<Code",
">",
"System",
".",
"getProperty",
"(",
"realm",
"dft",
")",
"<",
"/",
"Code",
">",
"<LI",
">",
"Prompting",
"for",
"a",
"password",
"<LI",
">",
"Using",
"promptDft",
"if",
"nothing",
"was",
"entered",
".",
"<",
"/",
"UL",
">"
] | train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/browsermob/proxy/jetty/util/Password.java#L187-L211 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java | FacesImpl.verifyFaceToFaceAsync | public Observable<VerifyResult> verifyFaceToFaceAsync(UUID faceId1, UUID faceId2) {
"""
Verify whether two faces belong to a same person or whether one face belongs to a person.
@param faceId1 FaceId of the first face, comes from Face - Detect
@param faceId2 FaceId of the second face, comes from Face - Detect
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VerifyResult object
"""
return verifyFaceToFaceWithServiceResponseAsync(faceId1, faceId2).map(new Func1<ServiceResponse<VerifyResult>, VerifyResult>() {
@Override
public VerifyResult call(ServiceResponse<VerifyResult> response) {
return response.body();
}
});
} | java | public Observable<VerifyResult> verifyFaceToFaceAsync(UUID faceId1, UUID faceId2) {
return verifyFaceToFaceWithServiceResponseAsync(faceId1, faceId2).map(new Func1<ServiceResponse<VerifyResult>, VerifyResult>() {
@Override
public VerifyResult call(ServiceResponse<VerifyResult> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VerifyResult",
">",
"verifyFaceToFaceAsync",
"(",
"UUID",
"faceId1",
",",
"UUID",
"faceId2",
")",
"{",
"return",
"verifyFaceToFaceWithServiceResponseAsync",
"(",
"faceId1",
",",
"faceId2",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VerifyResult",
">",
",",
"VerifyResult",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VerifyResult",
"call",
"(",
"ServiceResponse",
"<",
"VerifyResult",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Verify whether two faces belong to a same person or whether one face belongs to a person.
@param faceId1 FaceId of the first face, comes from Face - Detect
@param faceId2 FaceId of the second face, comes from Face - Detect
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VerifyResult object | [
"Verify",
"whether",
"two",
"faces",
"belong",
"to",
"a",
"same",
"person",
"or",
"whether",
"one",
"face",
"belongs",
"to",
"a",
"person",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java#L594-L601 |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java | IOUtils.writeStream | public static boolean writeStream(String filePath, InputStream stream, boolean append) throws IOException {
"""
write file
@param filePath the file to be opened for writing.
@param stream the input stream
@param append if <code>true</code>, then bytes will be written to the end of the file rather than the beginning
@return return true
@throws IOException if an error occurs while operator FileOutputStream
"""
return writeStream(filePath != null ? new File(filePath) : null, stream, append);
} | java | public static boolean writeStream(String filePath, InputStream stream, boolean append) throws IOException {
return writeStream(filePath != null ? new File(filePath) : null, stream, append);
} | [
"public",
"static",
"boolean",
"writeStream",
"(",
"String",
"filePath",
",",
"InputStream",
"stream",
",",
"boolean",
"append",
")",
"throws",
"IOException",
"{",
"return",
"writeStream",
"(",
"filePath",
"!=",
"null",
"?",
"new",
"File",
"(",
"filePath",
")",
":",
"null",
",",
"stream",
",",
"append",
")",
";",
"}"
] | write file
@param filePath the file to be opened for writing.
@param stream the input stream
@param append if <code>true</code>, then bytes will be written to the end of the file rather than the beginning
@return return true
@throws IOException if an error occurs while operator FileOutputStream | [
"write",
"file"
] | train | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java#L1199-L1201 |
Microsoft/malmo | Minecraft/src/main/java/com/microsoft/Malmo/Utils/JSONWorldDataHelper.java | JSONWorldDataHelper.buildLifeStats | public static void buildLifeStats(JsonObject json, EntityPlayerMP player) {
"""
Builds the basic life world data to be used as observation signals by the listener.
@param json a JSON object into which the life stats will be added.
"""
json.addProperty("Life", player.getHealth());
json.addProperty("Score", player.getScore()); // Might always be the same as XP?
json.addProperty("Food", player.getFoodStats().getFoodLevel());
json.addProperty("XP", player.experienceTotal);
json.addProperty("IsAlive", !player.isDead);
json.addProperty("Air", player.getAir());
json.addProperty("Name", player.getName());
} | java | public static void buildLifeStats(JsonObject json, EntityPlayerMP player)
{
json.addProperty("Life", player.getHealth());
json.addProperty("Score", player.getScore()); // Might always be the same as XP?
json.addProperty("Food", player.getFoodStats().getFoodLevel());
json.addProperty("XP", player.experienceTotal);
json.addProperty("IsAlive", !player.isDead);
json.addProperty("Air", player.getAir());
json.addProperty("Name", player.getName());
} | [
"public",
"static",
"void",
"buildLifeStats",
"(",
"JsonObject",
"json",
",",
"EntityPlayerMP",
"player",
")",
"{",
"json",
".",
"addProperty",
"(",
"\"Life\"",
",",
"player",
".",
"getHealth",
"(",
")",
")",
";",
"json",
".",
"addProperty",
"(",
"\"Score\"",
",",
"player",
".",
"getScore",
"(",
")",
")",
";",
"// Might always be the same as XP?",
"json",
".",
"addProperty",
"(",
"\"Food\"",
",",
"player",
".",
"getFoodStats",
"(",
")",
".",
"getFoodLevel",
"(",
")",
")",
";",
"json",
".",
"addProperty",
"(",
"\"XP\"",
",",
"player",
".",
"experienceTotal",
")",
";",
"json",
".",
"addProperty",
"(",
"\"IsAlive\"",
",",
"!",
"player",
".",
"isDead",
")",
";",
"json",
".",
"addProperty",
"(",
"\"Air\"",
",",
"player",
".",
"getAir",
"(",
")",
")",
";",
"json",
".",
"addProperty",
"(",
"\"Name\"",
",",
"player",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Builds the basic life world data to be used as observation signals by the listener.
@param json a JSON object into which the life stats will be added. | [
"Builds",
"the",
"basic",
"life",
"world",
"data",
"to",
"be",
"used",
"as",
"observation",
"signals",
"by",
"the",
"listener",
"."
] | train | https://github.com/Microsoft/malmo/blob/4139cd6f3e52f6e893a931a1d4b70d35f8e70e5a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/JSONWorldDataHelper.java#L124-L133 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/QueryTable.java | QueryTable.init | public void init(BaseDatabase database, Record record) {
"""
QueryTable Constructor.
@param database The database for this table.
@param record The queryRecord for this table.
"""
super.init(database, record);
if (((QueryRecord)record).getBaseRecord() != null)
m_tableNext = ((QueryRecord)record).getBaseRecord().getTable(); // Pass most commands thru to the main record's table
} | java | public void init(BaseDatabase database, Record record)
{
super.init(database, record);
if (((QueryRecord)record).getBaseRecord() != null)
m_tableNext = ((QueryRecord)record).getBaseRecord().getTable(); // Pass most commands thru to the main record's table
} | [
"public",
"void",
"init",
"(",
"BaseDatabase",
"database",
",",
"Record",
"record",
")",
"{",
"super",
".",
"init",
"(",
"database",
",",
"record",
")",
";",
"if",
"(",
"(",
"(",
"QueryRecord",
")",
"record",
")",
".",
"getBaseRecord",
"(",
")",
"!=",
"null",
")",
"m_tableNext",
"=",
"(",
"(",
"QueryRecord",
")",
"record",
")",
".",
"getBaseRecord",
"(",
")",
".",
"getTable",
"(",
")",
";",
"// Pass most commands thru to the main record's table",
"}"
] | QueryTable Constructor.
@param database The database for this table.
@param record The queryRecord for this table. | [
"QueryTable",
"Constructor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryTable.java#L46-L51 |
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.unsubscribeAllDeletedResources | public void unsubscribeAllDeletedResources(CmsDbContext dbc, String poolName, long deletedTo) throws CmsException {
"""
Unsubscribes all deleted resources that were deleted before the specified time stamp.<p>
@param dbc the database context
@param poolName the name of the database pool to use
@param deletedTo the time stamp to which the resources have been deleted
@throws CmsException if something goes wrong
"""
getSubscriptionDriver().unsubscribeAllDeletedResources(dbc, poolName, deletedTo);
} | java | public void unsubscribeAllDeletedResources(CmsDbContext dbc, String poolName, long deletedTo) throws CmsException {
getSubscriptionDriver().unsubscribeAllDeletedResources(dbc, poolName, deletedTo);
} | [
"public",
"void",
"unsubscribeAllDeletedResources",
"(",
"CmsDbContext",
"dbc",
",",
"String",
"poolName",
",",
"long",
"deletedTo",
")",
"throws",
"CmsException",
"{",
"getSubscriptionDriver",
"(",
")",
".",
"unsubscribeAllDeletedResources",
"(",
"dbc",
",",
"poolName",
",",
"deletedTo",
")",
";",
"}"
] | Unsubscribes all deleted resources that were deleted before the specified time stamp.<p>
@param dbc the database context
@param poolName the name of the database pool to use
@param deletedTo the time stamp to which the resources have been deleted
@throws CmsException if something goes wrong | [
"Unsubscribes",
"all",
"deleted",
"resources",
"that",
"were",
"deleted",
"before",
"the",
"specified",
"time",
"stamp",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L9248-L9251 |
JetBrains/xodus | environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java | ReentrantTransactionDispatcher.releaseTransaction | void releaseTransaction(@NotNull final Thread thread, final int permits) {
"""
Release transaction that was acquired in a thread with specified permits.
"""
try (CriticalSection ignored = criticalSection.enter()) {
int currentThreadPermits = getThreadPermits(thread);
if (permits > currentThreadPermits) {
throw new ExodusException("Can't release more permits than it was acquired");
}
acquiredPermits -= permits;
currentThreadPermits -= permits;
if (currentThreadPermits == 0) {
threadPermits.remove(thread);
} else {
threadPermits.put(thread, currentThreadPermits);
}
notifyNextWaiters();
}
} | java | void releaseTransaction(@NotNull final Thread thread, final int permits) {
try (CriticalSection ignored = criticalSection.enter()) {
int currentThreadPermits = getThreadPermits(thread);
if (permits > currentThreadPermits) {
throw new ExodusException("Can't release more permits than it was acquired");
}
acquiredPermits -= permits;
currentThreadPermits -= permits;
if (currentThreadPermits == 0) {
threadPermits.remove(thread);
} else {
threadPermits.put(thread, currentThreadPermits);
}
notifyNextWaiters();
}
} | [
"void",
"releaseTransaction",
"(",
"@",
"NotNull",
"final",
"Thread",
"thread",
",",
"final",
"int",
"permits",
")",
"{",
"try",
"(",
"CriticalSection",
"ignored",
"=",
"criticalSection",
".",
"enter",
"(",
")",
")",
"{",
"int",
"currentThreadPermits",
"=",
"getThreadPermits",
"(",
"thread",
")",
";",
"if",
"(",
"permits",
">",
"currentThreadPermits",
")",
"{",
"throw",
"new",
"ExodusException",
"(",
"\"Can't release more permits than it was acquired\"",
")",
";",
"}",
"acquiredPermits",
"-=",
"permits",
";",
"currentThreadPermits",
"-=",
"permits",
";",
"if",
"(",
"currentThreadPermits",
"==",
"0",
")",
"{",
"threadPermits",
".",
"remove",
"(",
"thread",
")",
";",
"}",
"else",
"{",
"threadPermits",
".",
"put",
"(",
"thread",
",",
"currentThreadPermits",
")",
";",
"}",
"notifyNextWaiters",
"(",
")",
";",
"}",
"}"
] | Release transaction that was acquired in a thread with specified permits. | [
"Release",
"transaction",
"that",
"was",
"acquired",
"in",
"a",
"thread",
"with",
"specified",
"permits",
"."
] | train | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java#L121-L136 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/asn1/x509/NameConstraints.java | NameConstraints.toASN1Object | public DERObject toASN1Object() {
"""
/*
NameConstraints ::= SEQUENCE {
permittedSubtrees [0] GeneralSubtrees OPTIONAL,
excludedSubtrees [1] GeneralSubtrees OPTIONAL }
"""
ASN1EncodableVector v = new ASN1EncodableVector();
if (permitted != null)
{
v.add(new DERTaggedObject(false, 0, permitted));
}
if (excluded != null)
{
v.add(new DERTaggedObject(false, 1, excluded));
}
return new DERSequence(v);
} | java | public DERObject toASN1Object()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (permitted != null)
{
v.add(new DERTaggedObject(false, 0, permitted));
}
if (excluded != null)
{
v.add(new DERTaggedObject(false, 1, excluded));
}
return new DERSequence(v);
} | [
"public",
"DERObject",
"toASN1Object",
"(",
")",
"{",
"ASN1EncodableVector",
"v",
"=",
"new",
"ASN1EncodableVector",
"(",
")",
";",
"if",
"(",
"permitted",
"!=",
"null",
")",
"{",
"v",
".",
"add",
"(",
"new",
"DERTaggedObject",
"(",
"false",
",",
"0",
",",
"permitted",
")",
")",
";",
"}",
"if",
"(",
"excluded",
"!=",
"null",
")",
"{",
"v",
".",
"add",
"(",
"new",
"DERTaggedObject",
"(",
"false",
",",
"1",
",",
"excluded",
")",
")",
";",
"}",
"return",
"new",
"DERSequence",
"(",
"v",
")",
";",
"}"
] | /*
NameConstraints ::= SEQUENCE {
permittedSubtrees [0] GeneralSubtrees OPTIONAL,
excludedSubtrees [1] GeneralSubtrees OPTIONAL } | [
"/",
"*",
"NameConstraints",
"::",
"=",
"SEQUENCE",
"{",
"permittedSubtrees",
"[",
"0",
"]",
"GeneralSubtrees",
"OPTIONAL",
"excludedSubtrees",
"[",
"1",
"]",
"GeneralSubtrees",
"OPTIONAL",
"}"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.csiv2.common/src/com/ibm/ws/transport/iiop/asn1/x509/NameConstraints.java#L66-L81 |
aalmiray/Json-lib | src/main/java/net/sf/json/util/JSONUtils.java | JSONUtils.newDynaBean | public static DynaBean newDynaBean( JSONObject jsonObject, JsonConfig jsonConfig ) {
"""
Creates a new MorphDynaBean from a JSONObject. The MorphDynaBean will have
all the properties of the original JSONObject with the most accurate type.
Values of properties are not copied.
"""
Map props = getProperties( jsonObject );
for( Iterator entries = props.entrySet()
.iterator(); entries.hasNext(); ){
Map.Entry entry = (Map.Entry) entries.next();
String key = (String) entry.getKey();
if( !JSONUtils.isJavaIdentifier( key ) ){
String parsedKey = JSONUtils.convertToJavaIdentifier( key, jsonConfig );
if( parsedKey.compareTo( key ) != 0 ){
props.put( parsedKey, props.remove( key ) );
}
}
}
MorphDynaClass dynaClass = new MorphDynaClass( props );
MorphDynaBean dynaBean = null;
try{
dynaBean = (MorphDynaBean) dynaClass.newInstance();
dynaBean.setDynaBeanClass( dynaClass );
}catch( Exception e ){
throw new JSONException( e );
}
return dynaBean;
} | java | public static DynaBean newDynaBean( JSONObject jsonObject, JsonConfig jsonConfig ) {
Map props = getProperties( jsonObject );
for( Iterator entries = props.entrySet()
.iterator(); entries.hasNext(); ){
Map.Entry entry = (Map.Entry) entries.next();
String key = (String) entry.getKey();
if( !JSONUtils.isJavaIdentifier( key ) ){
String parsedKey = JSONUtils.convertToJavaIdentifier( key, jsonConfig );
if( parsedKey.compareTo( key ) != 0 ){
props.put( parsedKey, props.remove( key ) );
}
}
}
MorphDynaClass dynaClass = new MorphDynaClass( props );
MorphDynaBean dynaBean = null;
try{
dynaBean = (MorphDynaBean) dynaClass.newInstance();
dynaBean.setDynaBeanClass( dynaClass );
}catch( Exception e ){
throw new JSONException( e );
}
return dynaBean;
} | [
"public",
"static",
"DynaBean",
"newDynaBean",
"(",
"JSONObject",
"jsonObject",
",",
"JsonConfig",
"jsonConfig",
")",
"{",
"Map",
"props",
"=",
"getProperties",
"(",
"jsonObject",
")",
";",
"for",
"(",
"Iterator",
"entries",
"=",
"props",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"entries",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Map",
".",
"Entry",
"entry",
"=",
"(",
"Map",
".",
"Entry",
")",
"entries",
".",
"next",
"(",
")",
";",
"String",
"key",
"=",
"(",
"String",
")",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"!",
"JSONUtils",
".",
"isJavaIdentifier",
"(",
"key",
")",
")",
"{",
"String",
"parsedKey",
"=",
"JSONUtils",
".",
"convertToJavaIdentifier",
"(",
"key",
",",
"jsonConfig",
")",
";",
"if",
"(",
"parsedKey",
".",
"compareTo",
"(",
"key",
")",
"!=",
"0",
")",
"{",
"props",
".",
"put",
"(",
"parsedKey",
",",
"props",
".",
"remove",
"(",
"key",
")",
")",
";",
"}",
"}",
"}",
"MorphDynaClass",
"dynaClass",
"=",
"new",
"MorphDynaClass",
"(",
"props",
")",
";",
"MorphDynaBean",
"dynaBean",
"=",
"null",
";",
"try",
"{",
"dynaBean",
"=",
"(",
"MorphDynaBean",
")",
"dynaClass",
".",
"newInstance",
"(",
")",
";",
"dynaBean",
".",
"setDynaBeanClass",
"(",
"dynaClass",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"e",
")",
";",
"}",
"return",
"dynaBean",
";",
"}"
] | Creates a new MorphDynaBean from a JSONObject. The MorphDynaBean will have
all the properties of the original JSONObject with the most accurate type.
Values of properties are not copied. | [
"Creates",
"a",
"new",
"MorphDynaBean",
"from",
"a",
"JSONObject",
".",
"The",
"MorphDynaBean",
"will",
"have",
"all",
"the",
"properties",
"of",
"the",
"original",
"JSONObject",
"with",
"the",
"most",
"accurate",
"type",
".",
"Values",
"of",
"properties",
"are",
"not",
"copied",
"."
] | train | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/util/JSONUtils.java#L408-L430 |
threerings/nenya | core/src/main/java/com/threerings/resource/FileResourceBundle.java | FileResourceBundle.getResourceFile | public File getResourceFile (String path)
throws IOException {
"""
Returns a file from which the specified resource can be loaded. This method will unpack the
resource into a temporary directory and return a reference to that file.
@param path the path to the resource in this jar file.
@return a file from which the resource can be loaded or null if no such resource exists.
"""
if (resolveJarFile()) {
return null;
}
// if we have been unpacked, return our unpacked file
if (_cache != null) {
File cfile = new File(_cache, path);
if (cfile.exists()) {
return cfile;
} else {
return null;
}
}
// otherwise, we unpack resources as needed into a temp directory
String tpath = StringUtil.md5hex(_source.getPath() + "%" + path);
File tfile = new File(getCacheDir(), tpath);
if (tfile.exists() && (tfile.lastModified() > _sourceLastMod)) {
return tfile;
}
JarEntry entry = _jarSource.getJarEntry(path);
if (entry == null) {
// log.info("Couldn't locate path in jar", "path", path, "jar", _jarSource);
return null;
}
// copy the resource into the temporary file
BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream(tfile));
InputStream jin = _jarSource.getInputStream(entry);
StreamUtil.copy(jin, fout);
jin.close();
fout.close();
return tfile;
} | java | public File getResourceFile (String path)
throws IOException
{
if (resolveJarFile()) {
return null;
}
// if we have been unpacked, return our unpacked file
if (_cache != null) {
File cfile = new File(_cache, path);
if (cfile.exists()) {
return cfile;
} else {
return null;
}
}
// otherwise, we unpack resources as needed into a temp directory
String tpath = StringUtil.md5hex(_source.getPath() + "%" + path);
File tfile = new File(getCacheDir(), tpath);
if (tfile.exists() && (tfile.lastModified() > _sourceLastMod)) {
return tfile;
}
JarEntry entry = _jarSource.getJarEntry(path);
if (entry == null) {
// log.info("Couldn't locate path in jar", "path", path, "jar", _jarSource);
return null;
}
// copy the resource into the temporary file
BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream(tfile));
InputStream jin = _jarSource.getInputStream(entry);
StreamUtil.copy(jin, fout);
jin.close();
fout.close();
return tfile;
} | [
"public",
"File",
"getResourceFile",
"(",
"String",
"path",
")",
"throws",
"IOException",
"{",
"if",
"(",
"resolveJarFile",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"// if we have been unpacked, return our unpacked file",
"if",
"(",
"_cache",
"!=",
"null",
")",
"{",
"File",
"cfile",
"=",
"new",
"File",
"(",
"_cache",
",",
"path",
")",
";",
"if",
"(",
"cfile",
".",
"exists",
"(",
")",
")",
"{",
"return",
"cfile",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"// otherwise, we unpack resources as needed into a temp directory",
"String",
"tpath",
"=",
"StringUtil",
".",
"md5hex",
"(",
"_source",
".",
"getPath",
"(",
")",
"+",
"\"%\"",
"+",
"path",
")",
";",
"File",
"tfile",
"=",
"new",
"File",
"(",
"getCacheDir",
"(",
")",
",",
"tpath",
")",
";",
"if",
"(",
"tfile",
".",
"exists",
"(",
")",
"&&",
"(",
"tfile",
".",
"lastModified",
"(",
")",
">",
"_sourceLastMod",
")",
")",
"{",
"return",
"tfile",
";",
"}",
"JarEntry",
"entry",
"=",
"_jarSource",
".",
"getJarEntry",
"(",
"path",
")",
";",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"// log.info(\"Couldn't locate path in jar\", \"path\", path, \"jar\", _jarSource);",
"return",
"null",
";",
"}",
"// copy the resource into the temporary file",
"BufferedOutputStream",
"fout",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"tfile",
")",
")",
";",
"InputStream",
"jin",
"=",
"_jarSource",
".",
"getInputStream",
"(",
"entry",
")",
";",
"StreamUtil",
".",
"copy",
"(",
"jin",
",",
"fout",
")",
";",
"jin",
".",
"close",
"(",
")",
";",
"fout",
".",
"close",
"(",
")",
";",
"return",
"tfile",
";",
"}"
] | Returns a file from which the specified resource can be loaded. This method will unpack the
resource into a temporary directory and return a reference to that file.
@param path the path to the resource in this jar file.
@return a file from which the resource can be loaded or null if no such resource exists. | [
"Returns",
"a",
"file",
"from",
"which",
"the",
"specified",
"resource",
"can",
"be",
"loaded",
".",
"This",
"method",
"will",
"unpack",
"the",
"resource",
"into",
"a",
"temporary",
"directory",
"and",
"return",
"a",
"reference",
"to",
"that",
"file",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/resource/FileResourceBundle.java#L215-L253 |
Mozu/mozu-java | mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/OrderUrl.java | OrderUrl.deleteOrderDraftUrl | public static MozuUrl deleteOrderDraftUrl(String orderId, String version) {
"""
Get Resource Url for DeleteOrderDraft
@param orderId Unique identifier of the order.
@param version Determines whether or not to check versioning of items for concurrency purposes.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/draft?version={version}");
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("version", version);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl deleteOrderDraftUrl(String orderId, String version)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/orders/{orderId}/draft?version={version}");
formatter.formatUrl("orderId", orderId);
formatter.formatUrl("version", version);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"deleteOrderDraftUrl",
"(",
"String",
"orderId",
",",
"String",
"version",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/orders/{orderId}/draft?version={version}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"orderId\"",
",",
"orderId",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"version\"",
",",
"version",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for DeleteOrderDraft
@param orderId Unique identifier of the order.
@param version Determines whether or not to check versioning of items for concurrency purposes.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"DeleteOrderDraft"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/OrderUrl.java#L180-L186 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/BindContentProviderBuilder.java | BindContentProviderBuilder.defineJavadocForContentUri | private void defineJavadocForContentUri(MethodSpec.Builder builder, SQLiteModelMethod method) {
"""
Define javadoc for content uri.
@param builder
the builder
@param method
the method
"""
String contentUri = method.contentProviderUri().replace("*", "[*]");
classBuilder.addJavadoc("<tr><td><pre>$L</pre></td><td>{@link $LImpl#$L}</td></tr>\n", contentUri, method.getParent().getName(), method.contentProviderMethodName);
builder.addJavadoc("<tr><td><pre>$L</pre></td><td>{@link $LImpl#$L}</td></tr>\n", contentUri, method.getParent().getName(), method.contentProviderMethodName);
} | java | private void defineJavadocForContentUri(MethodSpec.Builder builder, SQLiteModelMethod method) {
String contentUri = method.contentProviderUri().replace("*", "[*]");
classBuilder.addJavadoc("<tr><td><pre>$L</pre></td><td>{@link $LImpl#$L}</td></tr>\n", contentUri, method.getParent().getName(), method.contentProviderMethodName);
builder.addJavadoc("<tr><td><pre>$L</pre></td><td>{@link $LImpl#$L}</td></tr>\n", contentUri, method.getParent().getName(), method.contentProviderMethodName);
} | [
"private",
"void",
"defineJavadocForContentUri",
"(",
"MethodSpec",
".",
"Builder",
"builder",
",",
"SQLiteModelMethod",
"method",
")",
"{",
"String",
"contentUri",
"=",
"method",
".",
"contentProviderUri",
"(",
")",
".",
"replace",
"(",
"\"*\"",
",",
"\"[*]\"",
")",
";",
"classBuilder",
".",
"addJavadoc",
"(",
"\"<tr><td><pre>$L</pre></td><td>{@link $LImpl#$L}</td></tr>\\n\"",
",",
"contentUri",
",",
"method",
".",
"getParent",
"(",
")",
".",
"getName",
"(",
")",
",",
"method",
".",
"contentProviderMethodName",
")",
";",
"builder",
".",
"addJavadoc",
"(",
"\"<tr><td><pre>$L</pre></td><td>{@link $LImpl#$L}</td></tr>\\n\"",
",",
"contentUri",
",",
"method",
".",
"getParent",
"(",
")",
".",
"getName",
"(",
")",
",",
"method",
".",
"contentProviderMethodName",
")",
";",
"}"
] | Define javadoc for content uri.
@param builder
the builder
@param method
the method | [
"Define",
"javadoc",
"for",
"content",
"uri",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/BindContentProviderBuilder.java#L489-L495 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/form/binding/swing/SwingBinderSelectionStrategy.java | SwingBinderSelectionStrategy.getIdBoundBinder | public Binder getIdBoundBinder(String id) {
"""
Try to find a binder with a specified id. If no binder is found, try
to locate it into the application context, check whether it's a binder and
add it to the id bound binder map.
@param id Id of the binder
@return Binder or <code>null</code> if not found.
"""
Binder binder = idBoundBinders.get(id);
if (binder == null) // try to locate the binder bean
{
Object binderBean = getApplicationContext().getBean(id);
if (binderBean instanceof Binder)
{
if (binderBean != null)
{
idBoundBinders.put(id, (Binder) binderBean);
binder = (Binder) binderBean;
}
}
else
{
throw new IllegalArgumentException("Bean '" + id + "' was found, but was not a binder");
}
}
return binder;
} | java | public Binder getIdBoundBinder(String id)
{
Binder binder = idBoundBinders.get(id);
if (binder == null) // try to locate the binder bean
{
Object binderBean = getApplicationContext().getBean(id);
if (binderBean instanceof Binder)
{
if (binderBean != null)
{
idBoundBinders.put(id, (Binder) binderBean);
binder = (Binder) binderBean;
}
}
else
{
throw new IllegalArgumentException("Bean '" + id + "' was found, but was not a binder");
}
}
return binder;
} | [
"public",
"Binder",
"getIdBoundBinder",
"(",
"String",
"id",
")",
"{",
"Binder",
"binder",
"=",
"idBoundBinders",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"binder",
"==",
"null",
")",
"// try to locate the binder bean",
"{",
"Object",
"binderBean",
"=",
"getApplicationContext",
"(",
")",
".",
"getBean",
"(",
"id",
")",
";",
"if",
"(",
"binderBean",
"instanceof",
"Binder",
")",
"{",
"if",
"(",
"binderBean",
"!=",
"null",
")",
"{",
"idBoundBinders",
".",
"put",
"(",
"id",
",",
"(",
"Binder",
")",
"binderBean",
")",
";",
"binder",
"=",
"(",
"Binder",
")",
"binderBean",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Bean '\"",
"+",
"id",
"+",
"\"' was found, but was not a binder\"",
")",
";",
"}",
"}",
"return",
"binder",
";",
"}"
] | Try to find a binder with a specified id. If no binder is found, try
to locate it into the application context, check whether it's a binder and
add it to the id bound binder map.
@param id Id of the binder
@return Binder or <code>null</code> if not found. | [
"Try",
"to",
"find",
"a",
"binder",
"with",
"a",
"specified",
"id",
".",
"If",
"no",
"binder",
"is",
"found",
"try",
"to",
"locate",
"it",
"into",
"the",
"application",
"context",
"check",
"whether",
"it",
"s",
"a",
"binder",
"and",
"add",
"it",
"to",
"the",
"id",
"bound",
"binder",
"map",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/form/binding/swing/SwingBinderSelectionStrategy.java#L69-L89 |
calimero-project/calimero-core | src/tuwien/auto/calimero/link/medium/RawFrameFactory.java | RawFrameFactory.createTP1 | public static RawFrame createTP1(final byte[] data, final int offset) throws KNXFormatException {
"""
Creates a raw frame out of a byte array for the TP1 communication medium.
@param data byte array containing the TP1 raw frame structure
@param offset start offset of frame structure in <code>data</code>, 0 <=
offset < <code>data.length</code>
@return the created TP1 raw frame
@throws KNXFormatException on no valid frame structure
"""
final int ctrl = data[offset] & 0xff;
// parse control field and check if valid
if ((ctrl & 0x10) == 0x10) {
if ((ctrl & 0x40) == 0x00)
return new TP1LData(data, offset);
else if (ctrl == 0xF0)
return new TP1LPollData(data, offset);
throw new KNXFormatException("invalid raw frame control field", ctrl);
}
return new TP1Ack(data, offset);
} | java | public static RawFrame createTP1(final byte[] data, final int offset) throws KNXFormatException
{
final int ctrl = data[offset] & 0xff;
// parse control field and check if valid
if ((ctrl & 0x10) == 0x10) {
if ((ctrl & 0x40) == 0x00)
return new TP1LData(data, offset);
else if (ctrl == 0xF0)
return new TP1LPollData(data, offset);
throw new KNXFormatException("invalid raw frame control field", ctrl);
}
return new TP1Ack(data, offset);
} | [
"public",
"static",
"RawFrame",
"createTP1",
"(",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"int",
"offset",
")",
"throws",
"KNXFormatException",
"{",
"final",
"int",
"ctrl",
"=",
"data",
"[",
"offset",
"]",
"&",
"0xff",
";",
"// parse control field and check if valid",
"if",
"(",
"(",
"ctrl",
"&",
"0x10",
")",
"==",
"0x10",
")",
"{",
"if",
"(",
"(",
"ctrl",
"&",
"0x40",
")",
"==",
"0x00",
")",
"return",
"new",
"TP1LData",
"(",
"data",
",",
"offset",
")",
";",
"else",
"if",
"(",
"ctrl",
"==",
"0xF0",
")",
"return",
"new",
"TP1LPollData",
"(",
"data",
",",
"offset",
")",
";",
"throw",
"new",
"KNXFormatException",
"(",
"\"invalid raw frame control field\"",
",",
"ctrl",
")",
";",
"}",
"return",
"new",
"TP1Ack",
"(",
"data",
",",
"offset",
")",
";",
"}"
] | Creates a raw frame out of a byte array for the TP1 communication medium.
@param data byte array containing the TP1 raw frame structure
@param offset start offset of frame structure in <code>data</code>, 0 <=
offset < <code>data.length</code>
@return the created TP1 raw frame
@throws KNXFormatException on no valid frame structure | [
"Creates",
"a",
"raw",
"frame",
"out",
"of",
"a",
"byte",
"array",
"for",
"the",
"TP1",
"communication",
"medium",
"."
] | train | https://github.com/calimero-project/calimero-core/blob/7e6f547c6bd75fa985bfeb5b47ba671df2ea01e8/src/tuwien/auto/calimero/link/medium/RawFrameFactory.java#L91-L103 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/logging/MyfacesLogger.java | MyfacesLogger.exiting | public void exiting(String sourceClass, String sourceMethod, Object result) {
"""
Log a method return, with result object.
<p>
This is a convenience method that can be used to log returning
from a method. A LogRecord with message "RETURN {0}", log level
FINER, and the gives sourceMethod, sourceClass, and result
object is logged.
<p>
@param sourceClass name of class that issued the logging request
@param sourceMethod name of the method
@param result Object that is being returned
"""
_log.exiting(sourceClass, sourceMethod, result);
} | java | public void exiting(String sourceClass, String sourceMethod, Object result)
{
_log.exiting(sourceClass, sourceMethod, result);
} | [
"public",
"void",
"exiting",
"(",
"String",
"sourceClass",
",",
"String",
"sourceMethod",
",",
"Object",
"result",
")",
"{",
"_log",
".",
"exiting",
"(",
"sourceClass",
",",
"sourceMethod",
",",
"result",
")",
";",
"}"
] | Log a method return, with result object.
<p>
This is a convenience method that can be used to log returning
from a method. A LogRecord with message "RETURN {0}", log level
FINER, and the gives sourceMethod, sourceClass, and result
object is logged.
<p>
@param sourceClass name of class that issued the logging request
@param sourceMethod name of the method
@param result Object that is being returned | [
"Log",
"a",
"method",
"return",
"with",
"result",
"object",
".",
"<p",
">",
"This",
"is",
"a",
"convenience",
"method",
"that",
"can",
"be",
"used",
"to",
"log",
"returning",
"from",
"a",
"method",
".",
"A",
"LogRecord",
"with",
"message",
"RETURN",
"{",
"0",
"}",
"log",
"level",
"FINER",
"and",
"the",
"gives",
"sourceMethod",
"sourceClass",
"and",
"result",
"object",
"is",
"logged",
".",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/logging/MyfacesLogger.java#L774-L777 |
http-builder-ng/http-builder-ng | http-builder-ng-core/src/main/java/groovyx/net/http/HttpBuilder.java | HttpBuilder.traceAsync | public <T> CompletableFuture<T> traceAsync(final Class<T> type, @DelegatesTo(HttpConfig.class) final Closure closure) {
"""
Executes an asynchronous TRACE request on the configured URI (asynchronous alias to the `trace(Class,Closure)` method), with additional
configuration provided by the configuration closure. The result will be cast to the specified `type`.
[source,groovy]
----
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101/date'
}
CompletableFuture future = http.traceAsync(Date){
response.success { FromServer fromServer ->
Date.parse('yyyy.MM.dd HH:mm', fromServer.headers.find { it.key == 'stamp' }.value)
}
}
Date result = future.get()
----
The configuration `closure` allows additional configuration for this request based on the {@link HttpConfig} interface.
@param type the type of the response content
@param closure the additional configuration closure (delegated to {@link HttpConfig})
@return a {@link CompletableFuture} which may be used to access the resulting content (if present)
"""
return CompletableFuture.supplyAsync(() -> trace(type, closure), getExecutor());
} | java | public <T> CompletableFuture<T> traceAsync(final Class<T> type, @DelegatesTo(HttpConfig.class) final Closure closure) {
return CompletableFuture.supplyAsync(() -> trace(type, closure), getExecutor());
} | [
"public",
"<",
"T",
">",
"CompletableFuture",
"<",
"T",
">",
"traceAsync",
"(",
"final",
"Class",
"<",
"T",
">",
"type",
",",
"@",
"DelegatesTo",
"(",
"HttpConfig",
".",
"class",
")",
"final",
"Closure",
"closure",
")",
"{",
"return",
"CompletableFuture",
".",
"supplyAsync",
"(",
"(",
")",
"->",
"trace",
"(",
"type",
",",
"closure",
")",
",",
"getExecutor",
"(",
")",
")",
";",
"}"
] | Executes an asynchronous TRACE request on the configured URI (asynchronous alias to the `trace(Class,Closure)` method), with additional
configuration provided by the configuration closure. The result will be cast to the specified `type`.
[source,groovy]
----
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101/date'
}
CompletableFuture future = http.traceAsync(Date){
response.success { FromServer fromServer ->
Date.parse('yyyy.MM.dd HH:mm', fromServer.headers.find { it.key == 'stamp' }.value)
}
}
Date result = future.get()
----
The configuration `closure` allows additional configuration for this request based on the {@link HttpConfig} interface.
@param type the type of the response content
@param closure the additional configuration closure (delegated to {@link HttpConfig})
@return a {@link CompletableFuture} which may be used to access the resulting content (if present) | [
"Executes",
"an",
"asynchronous",
"TRACE",
"request",
"on",
"the",
"configured",
"URI",
"(",
"asynchronous",
"alias",
"to",
"the",
"trace",
"(",
"Class",
"Closure",
")",
"method",
")",
"with",
"additional",
"configuration",
"provided",
"by",
"the",
"configuration",
"closure",
".",
"The",
"result",
"will",
"be",
"cast",
"to",
"the",
"specified",
"type",
"."
] | train | https://github.com/http-builder-ng/http-builder-ng/blob/865f37732c102c748d3db8b905199dac9222a525/http-builder-ng-core/src/main/java/groovyx/net/http/HttpBuilder.java#L2192-L2194 |
Azure/azure-sdk-for-java | signalr/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/signalr/v2018_03_01_preview/implementation/SignalRsInner.java | SignalRsInner.listKeysAsync | public Observable<SignalRKeysInner> listKeysAsync(String resourceGroupName, String resourceName) {
"""
Get the access keys of the SignalR resource.
@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 resourceName The name of the SignalR resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the SignalRKeysInner object
"""
return listKeysWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<SignalRKeysInner>, SignalRKeysInner>() {
@Override
public SignalRKeysInner call(ServiceResponse<SignalRKeysInner> response) {
return response.body();
}
});
} | java | public Observable<SignalRKeysInner> listKeysAsync(String resourceGroupName, String resourceName) {
return listKeysWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<SignalRKeysInner>, SignalRKeysInner>() {
@Override
public SignalRKeysInner call(ServiceResponse<SignalRKeysInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"SignalRKeysInner",
">",
"listKeysAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
")",
"{",
"return",
"listKeysWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"SignalRKeysInner",
">",
",",
"SignalRKeysInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"SignalRKeysInner",
"call",
"(",
"ServiceResponse",
"<",
"SignalRKeysInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get the access keys of the SignalR resource.
@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 resourceName The name of the SignalR resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the SignalRKeysInner object | [
"Get",
"the",
"access",
"keys",
"of",
"the",
"SignalR",
"resource",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/signalr/resource-manager/v2018_03_01_preview/src/main/java/com/microsoft/azure/management/signalr/v2018_03_01_preview/implementation/SignalRsInner.java#L538-L545 |
virgo47/javasimon | console-embed/src/main/java/org/javasimon/console/SimonConsoleRequestProcessor.java | SimonConsoleRequestProcessor.create | public static SimonConsoleRequestProcessor create(String urlPrefix, Manager manager, String pluginClasses) {
"""
Instanciate the request processor (factory method)
@param urlPrefix Url prefix (null allowed)
@param manager Manager (null allowed)
@param pluginClasses Plugin classes (null allowed)
"""
SimonConsoleRequestProcessor requestProcessor = new SimonConsoleRequestProcessor(urlPrefix);
if (manager != null) {
// Defaults to global manager
requestProcessor.setManager(manager);
}
if (pluginClasses != null) {
requestProcessor.getPluginManager().addPlugins(pluginClasses);
}
requestProcessor.initActionBindings();
return requestProcessor;
} | java | public static SimonConsoleRequestProcessor create(String urlPrefix, Manager manager, String pluginClasses) {
SimonConsoleRequestProcessor requestProcessor = new SimonConsoleRequestProcessor(urlPrefix);
if (manager != null) {
// Defaults to global manager
requestProcessor.setManager(manager);
}
if (pluginClasses != null) {
requestProcessor.getPluginManager().addPlugins(pluginClasses);
}
requestProcessor.initActionBindings();
return requestProcessor;
} | [
"public",
"static",
"SimonConsoleRequestProcessor",
"create",
"(",
"String",
"urlPrefix",
",",
"Manager",
"manager",
",",
"String",
"pluginClasses",
")",
"{",
"SimonConsoleRequestProcessor",
"requestProcessor",
"=",
"new",
"SimonConsoleRequestProcessor",
"(",
"urlPrefix",
")",
";",
"if",
"(",
"manager",
"!=",
"null",
")",
"{",
"// Defaults to global manager\r",
"requestProcessor",
".",
"setManager",
"(",
"manager",
")",
";",
"}",
"if",
"(",
"pluginClasses",
"!=",
"null",
")",
"{",
"requestProcessor",
".",
"getPluginManager",
"(",
")",
".",
"addPlugins",
"(",
"pluginClasses",
")",
";",
"}",
"requestProcessor",
".",
"initActionBindings",
"(",
")",
";",
"return",
"requestProcessor",
";",
"}"
] | Instanciate the request processor (factory method)
@param urlPrefix Url prefix (null allowed)
@param manager Manager (null allowed)
@param pluginClasses Plugin classes (null allowed) | [
"Instanciate",
"the",
"request",
"processor",
"(",
"factory",
"method",
")"
] | train | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/console-embed/src/main/java/org/javasimon/console/SimonConsoleRequestProcessor.java#L270-L281 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/gd/InternalInputStreamManager.java | InternalInputStreamManager.getStreamSet | private StreamSet getStreamSet(SIBUuid12 streamID, boolean create) {
"""
Get a StreamSet for a given streamID. Optionally create the StreamSet
if it doesn't already exit.
@param streamID The streamID to map to a StreamSet.
@param create If TRUE then create the StreamSet if it doesn't already exit.
@return An instance of StreamSet
"""
if (tc.isEntryEnabled())
SibTr.entry(tc, "getStreamSet", new Object[]{streamID, new Boolean(create)});
StreamSet streamSet = null;
synchronized (streamSets)
{
streamSet = (StreamSet) streamSets.get(streamID);
if ((streamSet == null) && create)
{
streamSet = new StreamSet(streamID, null, 0, StreamSet.Type.INTERNAL_INPUT);
streamSets.put(streamID, streamSet);
}
}
if (tc.isEntryEnabled())
SibTr.exit(tc, "getStreamSet", streamSet);
return streamSet;
} | java | private StreamSet getStreamSet(SIBUuid12 streamID, boolean create)
{
if (tc.isEntryEnabled())
SibTr.entry(tc, "getStreamSet", new Object[]{streamID, new Boolean(create)});
StreamSet streamSet = null;
synchronized (streamSets)
{
streamSet = (StreamSet) streamSets.get(streamID);
if ((streamSet == null) && create)
{
streamSet = new StreamSet(streamID, null, 0, StreamSet.Type.INTERNAL_INPUT);
streamSets.put(streamID, streamSet);
}
}
if (tc.isEntryEnabled())
SibTr.exit(tc, "getStreamSet", streamSet);
return streamSet;
} | [
"private",
"StreamSet",
"getStreamSet",
"(",
"SIBUuid12",
"streamID",
",",
"boolean",
"create",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"getStreamSet\"",
",",
"new",
"Object",
"[",
"]",
"{",
"streamID",
",",
"new",
"Boolean",
"(",
"create",
")",
"}",
")",
";",
"StreamSet",
"streamSet",
"=",
"null",
";",
"synchronized",
"(",
"streamSets",
")",
"{",
"streamSet",
"=",
"(",
"StreamSet",
")",
"streamSets",
".",
"get",
"(",
"streamID",
")",
";",
"if",
"(",
"(",
"streamSet",
"==",
"null",
")",
"&&",
"create",
")",
"{",
"streamSet",
"=",
"new",
"StreamSet",
"(",
"streamID",
",",
"null",
",",
"0",
",",
"StreamSet",
".",
"Type",
".",
"INTERNAL_INPUT",
")",
";",
"streamSets",
".",
"put",
"(",
"streamID",
",",
"streamSet",
")",
";",
"}",
"}",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"getStreamSet\"",
",",
"streamSet",
")",
";",
"return",
"streamSet",
";",
"}"
] | Get a StreamSet for a given streamID. Optionally create the StreamSet
if it doesn't already exit.
@param streamID The streamID to map to a StreamSet.
@param create If TRUE then create the StreamSet if it doesn't already exit.
@return An instance of StreamSet | [
"Get",
"a",
"StreamSet",
"for",
"a",
"given",
"streamID",
".",
"Optionally",
"create",
"the",
"StreamSet",
"if",
"it",
"doesn",
"t",
"already",
"exit",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/gd/InternalInputStreamManager.java#L277-L296 |
contentful/contentful-management.java | src/main/java/com/contentful/java/cma/gson/EntrySerializer.java | EntrySerializer.serialize | @Override
public JsonElement serialize(CMAEntry src, Type type, JsonSerializationContext context) {
"""
Make sure all fields are mapped in the locale - value way.
@param src the source to be edited.
@param type the type to be used.
@param context the json context to be changed.
@return a created json element.
"""
JsonObject fields = new JsonObject();
for (Map.Entry<String, LinkedHashMap<String, Object>> field : src.getFields().entrySet()) {
LinkedHashMap<String, Object> value = field.getValue();
if (value == null) {
continue;
}
String fieldId = field.getKey();
JsonObject jsonField = serializeField(context, field.getValue());
if (jsonField != null) {
fields.add(fieldId, jsonField);
}
}
JsonObject result = new JsonObject();
result.add("fields", fields);
final CMASystem sys = src.getSystem();
if (sys != null) {
result.add("sys", context.serialize(sys));
}
return result;
} | java | @Override
public JsonElement serialize(CMAEntry src, Type type, JsonSerializationContext context) {
JsonObject fields = new JsonObject();
for (Map.Entry<String, LinkedHashMap<String, Object>> field : src.getFields().entrySet()) {
LinkedHashMap<String, Object> value = field.getValue();
if (value == null) {
continue;
}
String fieldId = field.getKey();
JsonObject jsonField = serializeField(context, field.getValue());
if (jsonField != null) {
fields.add(fieldId, jsonField);
}
}
JsonObject result = new JsonObject();
result.add("fields", fields);
final CMASystem sys = src.getSystem();
if (sys != null) {
result.add("sys", context.serialize(sys));
}
return result;
} | [
"@",
"Override",
"public",
"JsonElement",
"serialize",
"(",
"CMAEntry",
"src",
",",
"Type",
"type",
",",
"JsonSerializationContext",
"context",
")",
"{",
"JsonObject",
"fields",
"=",
"new",
"JsonObject",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"LinkedHashMap",
"<",
"String",
",",
"Object",
">",
">",
"field",
":",
"src",
".",
"getFields",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"LinkedHashMap",
"<",
"String",
",",
"Object",
">",
"value",
"=",
"field",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"String",
"fieldId",
"=",
"field",
".",
"getKey",
"(",
")",
";",
"JsonObject",
"jsonField",
"=",
"serializeField",
"(",
"context",
",",
"field",
".",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"jsonField",
"!=",
"null",
")",
"{",
"fields",
".",
"add",
"(",
"fieldId",
",",
"jsonField",
")",
";",
"}",
"}",
"JsonObject",
"result",
"=",
"new",
"JsonObject",
"(",
")",
";",
"result",
".",
"add",
"(",
"\"fields\"",
",",
"fields",
")",
";",
"final",
"CMASystem",
"sys",
"=",
"src",
".",
"getSystem",
"(",
")",
";",
"if",
"(",
"sys",
"!=",
"null",
")",
"{",
"result",
".",
"add",
"(",
"\"sys\"",
",",
"context",
".",
"serialize",
"(",
"sys",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Make sure all fields are mapped in the locale - value way.
@param src the source to be edited.
@param type the type to be used.
@param context the json context to be changed.
@return a created json element. | [
"Make",
"sure",
"all",
"fields",
"are",
"mapped",
"in",
"the",
"locale",
"-",
"value",
"way",
"."
] | train | https://github.com/contentful/contentful-management.java/blob/ca310fb9ea9577fcff0ca57949ab7c2315fa2534/src/main/java/com/contentful/java/cma/gson/EntrySerializer.java#L44-L67 |
ksclarke/freelib-utils | src/main/java/info/freelibrary/util/FileExtFileFilter.java | FileExtFileFilter.accept | @Override
public boolean accept(final File aDir, final String aFileName) {
"""
Returns true if the supplied file name and parent directory are a match for this <code>FilenameFilter</code>.
@param aDir A parent directory for the supplied file name
@param aFileName The file name we want to check against our filter
@return True if the filter matches the supplied parent and file name; else, false
"""
for (final String extension : myExtensions) {
if (new File(aDir, aFileName).isFile() && aFileName.endsWith(extension)) {
return true;
}
}
return false;
} | java | @Override
public boolean accept(final File aDir, final String aFileName) {
for (final String extension : myExtensions) {
if (new File(aDir, aFileName).isFile() && aFileName.endsWith(extension)) {
return true;
}
}
return false;
} | [
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"final",
"File",
"aDir",
",",
"final",
"String",
"aFileName",
")",
"{",
"for",
"(",
"final",
"String",
"extension",
":",
"myExtensions",
")",
"{",
"if",
"(",
"new",
"File",
"(",
"aDir",
",",
"aFileName",
")",
".",
"isFile",
"(",
")",
"&&",
"aFileName",
".",
"endsWith",
"(",
"extension",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if the supplied file name and parent directory are a match for this <code>FilenameFilter</code>.
@param aDir A parent directory for the supplied file name
@param aFileName The file name we want to check against our filter
@return True if the filter matches the supplied parent and file name; else, false | [
"Returns",
"true",
"if",
"the",
"supplied",
"file",
"name",
"and",
"parent",
"directory",
"are",
"a",
"match",
"for",
"this",
"<code",
">",
"FilenameFilter<",
"/",
"code",
">",
"."
] | train | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/FileExtFileFilter.java#L60-L69 |
javagl/ND | nd-distance/src/main/java/de/javagl/nd/distance/tuples/j/LongTupleDistanceFunctions.java | LongTupleDistanceFunctions.computeEuclideanSquared | static double computeEuclideanSquared(LongTuple t0, LongTuple t1) {
"""
Computes the squared Euclidean distance between the given tuples
@param t0 The first tuple
@param t1 The second tuple
@return The distance
@throws IllegalArgumentException If the given tuples do not
have the same {@link Tuple#getSize() size}
"""
Utils.checkForEqualSize(t0, t1);
long sum = 0;
for (int i=0; i<t0.getSize(); i++)
{
long d = t0.get(i)-t1.get(i);
sum += d*d;
}
return sum;
} | java | static double computeEuclideanSquared(LongTuple t0, LongTuple t1)
{
Utils.checkForEqualSize(t0, t1);
long sum = 0;
for (int i=0; i<t0.getSize(); i++)
{
long d = t0.get(i)-t1.get(i);
sum += d*d;
}
return sum;
} | [
"static",
"double",
"computeEuclideanSquared",
"(",
"LongTuple",
"t0",
",",
"LongTuple",
"t1",
")",
"{",
"Utils",
".",
"checkForEqualSize",
"(",
"t0",
",",
"t1",
")",
";",
"long",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"t0",
".",
"getSize",
"(",
")",
";",
"i",
"++",
")",
"{",
"long",
"d",
"=",
"t0",
".",
"get",
"(",
"i",
")",
"-",
"t1",
".",
"get",
"(",
"i",
")",
";",
"sum",
"+=",
"d",
"*",
"d",
";",
"}",
"return",
"sum",
";",
"}"
] | Computes the squared Euclidean distance between the given tuples
@param t0 The first tuple
@param t1 The second tuple
@return The distance
@throws IllegalArgumentException If the given tuples do not
have the same {@link Tuple#getSize() size} | [
"Computes",
"the",
"squared",
"Euclidean",
"distance",
"between",
"the",
"given",
"tuples"
] | train | https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-distance/src/main/java/de/javagl/nd/distance/tuples/j/LongTupleDistanceFunctions.java#L197-L207 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/locking/LockManagerDefaultImpl.java | LockManagerDefaultImpl.checkWrite | public synchronized boolean checkWrite(TransactionImpl tx, Object obj) {
"""
checks if there is a writelock for transaction tx on object obj.
Returns true if so, else false.
"""
if (log.isDebugEnabled()) log.debug("LM.checkWrite(tx-" + tx.getGUID() + ", " + new Identity(obj, tx.getBroker()).toString() + ")");
LockStrategy lockStrategy = LockStrategyFactory.getStrategyFor(obj);
return lockStrategy.checkWrite(tx, obj);
} | java | public synchronized boolean checkWrite(TransactionImpl tx, Object obj)
{
if (log.isDebugEnabled()) log.debug("LM.checkWrite(tx-" + tx.getGUID() + ", " + new Identity(obj, tx.getBroker()).toString() + ")");
LockStrategy lockStrategy = LockStrategyFactory.getStrategyFor(obj);
return lockStrategy.checkWrite(tx, obj);
} | [
"public",
"synchronized",
"boolean",
"checkWrite",
"(",
"TransactionImpl",
"tx",
",",
"Object",
"obj",
")",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debug",
"(",
"\"LM.checkWrite(tx-\"",
"+",
"tx",
".",
"getGUID",
"(",
")",
"+",
"\", \"",
"+",
"new",
"Identity",
"(",
"obj",
",",
"tx",
".",
"getBroker",
"(",
")",
")",
".",
"toString",
"(",
")",
"+",
"\")\"",
")",
";",
"LockStrategy",
"lockStrategy",
"=",
"LockStrategyFactory",
".",
"getStrategyFor",
"(",
"obj",
")",
";",
"return",
"lockStrategy",
".",
"checkWrite",
"(",
"tx",
",",
"obj",
")",
";",
"}"
] | checks if there is a writelock for transaction tx on object obj.
Returns true if so, else false. | [
"checks",
"if",
"there",
"is",
"a",
"writelock",
"for",
"transaction",
"tx",
"on",
"object",
"obj",
".",
"Returns",
"true",
"if",
"so",
"else",
"false",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/locking/LockManagerDefaultImpl.java#L142-L147 |
infinispan/infinispan | lucene/directory-provider/src/main/java/org/infinispan/hibernate/search/util/configuration/impl/ConfigurationParseHelper.java | ConfigurationParseHelper.parseInt | public static int parseInt(String value, String errorMsgOnParseFailure) {
"""
Parses a string into an integer value.
@param value a string containing an int value to parse
@param errorMsgOnParseFailure message being wrapped in a SearchException if value is {@code null} or not an
integer
@return the parsed integer value
@throws SearchException both for null values and for Strings not containing a valid int.
"""
if (value == null) {
throw new SearchException(errorMsgOnParseFailure);
} else {
try {
return Integer.parseInt(value.trim());
} catch (NumberFormatException nfe) {
throw log.getInvalidIntegerValueException(errorMsgOnParseFailure, nfe);
}
}
} | java | public static int parseInt(String value, String errorMsgOnParseFailure) {
if (value == null) {
throw new SearchException(errorMsgOnParseFailure);
} else {
try {
return Integer.parseInt(value.trim());
} catch (NumberFormatException nfe) {
throw log.getInvalidIntegerValueException(errorMsgOnParseFailure, nfe);
}
}
} | [
"public",
"static",
"int",
"parseInt",
"(",
"String",
"value",
",",
"String",
"errorMsgOnParseFailure",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"SearchException",
"(",
"errorMsgOnParseFailure",
")",
";",
"}",
"else",
"{",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"value",
".",
"trim",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"throw",
"log",
".",
"getInvalidIntegerValueException",
"(",
"errorMsgOnParseFailure",
",",
"nfe",
")",
";",
"}",
"}",
"}"
] | Parses a string into an integer value.
@param value a string containing an int value to parse
@param errorMsgOnParseFailure message being wrapped in a SearchException if value is {@code null} or not an
integer
@return the parsed integer value
@throws SearchException both for null values and for Strings not containing a valid int. | [
"Parses",
"a",
"string",
"into",
"an",
"integer",
"value",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/lucene/directory-provider/src/main/java/org/infinispan/hibernate/search/util/configuration/impl/ConfigurationParseHelper.java#L73-L83 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/util/ClassLoaderUtil.java | ClassLoaderUtil.validateClassLoadable | public static boolean validateClassLoadable(ClassNotFoundException cnfe, ClassLoader cl) {
"""
Checks, whether the class that was not found in the given exception, can be resolved through
the given class loader.
@param cnfe The ClassNotFoundException that defines the name of the class.
@param cl The class loader to use for the class resolution.
@return True, if the class can be resolved with the given class loader, false if not.
"""
try {
String className = cnfe.getMessage();
Class.forName(className, false, cl);
return true;
}
catch (ClassNotFoundException e) {
return false;
}
catch (Exception e) {
return false;
}
} | java | public static boolean validateClassLoadable(ClassNotFoundException cnfe, ClassLoader cl) {
try {
String className = cnfe.getMessage();
Class.forName(className, false, cl);
return true;
}
catch (ClassNotFoundException e) {
return false;
}
catch (Exception e) {
return false;
}
} | [
"public",
"static",
"boolean",
"validateClassLoadable",
"(",
"ClassNotFoundException",
"cnfe",
",",
"ClassLoader",
"cl",
")",
"{",
"try",
"{",
"String",
"className",
"=",
"cnfe",
".",
"getMessage",
"(",
")",
";",
"Class",
".",
"forName",
"(",
"className",
",",
"false",
",",
"cl",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Checks, whether the class that was not found in the given exception, can be resolved through
the given class loader.
@param cnfe The ClassNotFoundException that defines the name of the class.
@param cl The class loader to use for the class resolution.
@return True, if the class can be resolved with the given class loader, false if not. | [
"Checks",
"whether",
"the",
"class",
"that",
"was",
"not",
"found",
"in",
"the",
"given",
"exception",
"can",
"be",
"resolved",
"through",
"the",
"given",
"class",
"loader",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/util/ClassLoaderUtil.java#L119-L131 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/MurmurHashUtil.java | MurmurHashUtil.hashBytes | public static int hashBytes(MemorySegment segment, int offset, int lengthInBytes) {
"""
Hash bytes in MemorySegment.
@param segment segment.
@param offset offset for MemorySegment
@param lengthInBytes length in MemorySegment
@return hash code
"""
return hashBytes(segment, offset, lengthInBytes, DEFAULT_SEED);
} | java | public static int hashBytes(MemorySegment segment, int offset, int lengthInBytes) {
return hashBytes(segment, offset, lengthInBytes, DEFAULT_SEED);
} | [
"public",
"static",
"int",
"hashBytes",
"(",
"MemorySegment",
"segment",
",",
"int",
"offset",
",",
"int",
"lengthInBytes",
")",
"{",
"return",
"hashBytes",
"(",
"segment",
",",
"offset",
",",
"lengthInBytes",
",",
"DEFAULT_SEED",
")",
";",
"}"
] | Hash bytes in MemorySegment.
@param segment segment.
@param offset offset for MemorySegment
@param lengthInBytes length in MemorySegment
@return hash code | [
"Hash",
"bytes",
"in",
"MemorySegment",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/util/MurmurHashUtil.java#L73-L75 |
apereo/cas | support/cas-server-support-openid/src/main/java/org/apereo/cas/support/openid/authentication/principal/OpenIdServiceResponseBuilder.java | OpenIdServiceResponseBuilder.buildAuthenticationResponse | protected Response buildAuthenticationResponse(final OpenIdService service,
final Map<String, String> parameters,
final boolean successFullAuthentication,
final String id,
final ParameterList parameterList) {
"""
We sign directly (final 'true') because we don't add extensions
response message can be either a DirectError or an AuthSuccess here.
Note:
The association handle returned in the Response is either the 'public'
created in a previous association, or is a 'private' handle created
specifically for the verification step when in non-association mode
@param service the service
@param parameters the parameters
@param successFullAuthentication the success full authentication
@param id the id
@param parameterList the parameter list
@return response response
"""
val response = serverManager.authResponse(parameterList, id, id, successFullAuthentication, true);
parameters.putAll(response.getParameterMap());
LOGGER.debug("Parameters passed for the OpenID response are [{}]", parameters.keySet());
return buildRedirect(service, parameters);
} | java | protected Response buildAuthenticationResponse(final OpenIdService service,
final Map<String, String> parameters,
final boolean successFullAuthentication,
final String id,
final ParameterList parameterList) {
val response = serverManager.authResponse(parameterList, id, id, successFullAuthentication, true);
parameters.putAll(response.getParameterMap());
LOGGER.debug("Parameters passed for the OpenID response are [{}]", parameters.keySet());
return buildRedirect(service, parameters);
} | [
"protected",
"Response",
"buildAuthenticationResponse",
"(",
"final",
"OpenIdService",
"service",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
",",
"final",
"boolean",
"successFullAuthentication",
",",
"final",
"String",
"id",
",",
"final",
"ParameterList",
"parameterList",
")",
"{",
"val",
"response",
"=",
"serverManager",
".",
"authResponse",
"(",
"parameterList",
",",
"id",
",",
"id",
",",
"successFullAuthentication",
",",
"true",
")",
";",
"parameters",
".",
"putAll",
"(",
"response",
".",
"getParameterMap",
"(",
")",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Parameters passed for the OpenID response are [{}]\"",
",",
"parameters",
".",
"keySet",
"(",
")",
")",
";",
"return",
"buildRedirect",
"(",
"service",
",",
"parameters",
")",
";",
"}"
] | We sign directly (final 'true') because we don't add extensions
response message can be either a DirectError or an AuthSuccess here.
Note:
The association handle returned in the Response is either the 'public'
created in a previous association, or is a 'private' handle created
specifically for the verification step when in non-association mode
@param service the service
@param parameters the parameters
@param successFullAuthentication the success full authentication
@param id the id
@param parameterList the parameter list
@return response response | [
"We",
"sign",
"directly",
"(",
"final",
"true",
")",
"because",
"we",
"don",
"t",
"add",
"extensions",
"response",
"message",
"can",
"be",
"either",
"a",
"DirectError",
"or",
"an",
"AuthSuccess",
"here",
".",
"Note",
":",
"The",
"association",
"handle",
"returned",
"in",
"the",
"Response",
"is",
"either",
"the",
"public",
"created",
"in",
"a",
"previous",
"association",
"or",
"is",
"a",
"private",
"handle",
"created",
"specifically",
"for",
"the",
"verification",
"step",
"when",
"in",
"non",
"-",
"association",
"mode"
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-openid/src/main/java/org/apereo/cas/support/openid/authentication/principal/OpenIdServiceResponseBuilder.java#L130-L139 |
ontop/ontop | core/model/src/main/java/it/unibz/inf/ontop/dbschema/ForeignKeyConstraint.java | ForeignKeyConstraint.of | public static ForeignKeyConstraint of(String name, Attribute attribute, Attribute reference) {
"""
creates a single-attribute foreign key
@param name
@param attribute
@param reference
@return
"""
return new Builder((DatabaseRelationDefinition)attribute.getRelation(),
(DatabaseRelationDefinition)reference.getRelation())
.add(attribute, reference).build(name);
} | java | public static ForeignKeyConstraint of(String name, Attribute attribute, Attribute reference) {
return new Builder((DatabaseRelationDefinition)attribute.getRelation(),
(DatabaseRelationDefinition)reference.getRelation())
.add(attribute, reference).build(name);
} | [
"public",
"static",
"ForeignKeyConstraint",
"of",
"(",
"String",
"name",
",",
"Attribute",
"attribute",
",",
"Attribute",
"reference",
")",
"{",
"return",
"new",
"Builder",
"(",
"(",
"DatabaseRelationDefinition",
")",
"attribute",
".",
"getRelation",
"(",
")",
",",
"(",
"DatabaseRelationDefinition",
")",
"reference",
".",
"getRelation",
"(",
")",
")",
".",
"add",
"(",
"attribute",
",",
"reference",
")",
".",
"build",
"(",
"name",
")",
";",
"}"
] | creates a single-attribute foreign key
@param name
@param attribute
@param reference
@return | [
"creates",
"a",
"single",
"-",
"attribute",
"foreign",
"key"
] | train | https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/core/model/src/main/java/it/unibz/inf/ontop/dbschema/ForeignKeyConstraint.java#L141-L145 |
jcuda/jcusparse | JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java | JCusparse.cusparseScsc2hyb | public static int cusparseScsc2hyb(
cusparseHandle handle,
int m,
int n,
cusparseMatDescr descrA,
Pointer cscSortedValA,
Pointer cscSortedRowIndA,
Pointer cscSortedColPtrA,
cusparseHybMat hybA,
int userEllWidth,
int partitionType) {
"""
Description: This routine converts a sparse matrix in CSC storage format
to a sparse matrix in HYB storage format.
"""
return checkResult(cusparseScsc2hybNative(handle, m, n, descrA, cscSortedValA, cscSortedRowIndA, cscSortedColPtrA, hybA, userEllWidth, partitionType));
} | java | public static int cusparseScsc2hyb(
cusparseHandle handle,
int m,
int n,
cusparseMatDescr descrA,
Pointer cscSortedValA,
Pointer cscSortedRowIndA,
Pointer cscSortedColPtrA,
cusparseHybMat hybA,
int userEllWidth,
int partitionType)
{
return checkResult(cusparseScsc2hybNative(handle, m, n, descrA, cscSortedValA, cscSortedRowIndA, cscSortedColPtrA, hybA, userEllWidth, partitionType));
} | [
"public",
"static",
"int",
"cusparseScsc2hyb",
"(",
"cusparseHandle",
"handle",
",",
"int",
"m",
",",
"int",
"n",
",",
"cusparseMatDescr",
"descrA",
",",
"Pointer",
"cscSortedValA",
",",
"Pointer",
"cscSortedRowIndA",
",",
"Pointer",
"cscSortedColPtrA",
",",
"cusparseHybMat",
"hybA",
",",
"int",
"userEllWidth",
",",
"int",
"partitionType",
")",
"{",
"return",
"checkResult",
"(",
"cusparseScsc2hybNative",
"(",
"handle",
",",
"m",
",",
"n",
",",
"descrA",
",",
"cscSortedValA",
",",
"cscSortedRowIndA",
",",
"cscSortedColPtrA",
",",
"hybA",
",",
"userEllWidth",
",",
"partitionType",
")",
")",
";",
"}"
] | Description: This routine converts a sparse matrix in CSC storage format
to a sparse matrix in HYB storage format. | [
"Description",
":",
"This",
"routine",
"converts",
"a",
"sparse",
"matrix",
"in",
"CSC",
"storage",
"format",
"to",
"a",
"sparse",
"matrix",
"in",
"HYB",
"storage",
"format",
"."
] | train | https://github.com/jcuda/jcusparse/blob/7687a62a4ef6b76cb91cf7da93d4cf5ade96a791/JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java#L12175-L12188 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.