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
|
---|---|---|---|---|---|---|---|---|---|---|
ansell/csvstream | src/main/java/com/github/ansell/csv/stream/CSVStream.java | CSVStream.parse | public static <T> void parse(final InputStream inputStream, final Consumer<List<String>> headersValidator,
final BiFunction<List<String>, List<String>, T> lineConverter, final Consumer<T> resultConsumer)
throws IOException, CSVStreamException {
"""
Stream a CSV file from the given InputStream through the header validator,
line checker, and if the line checker succeeds, send the checked/converted
line to the consumer.
@param inputStream
The {@link InputStream} containing the CSV file.
@param headersValidator
The validator of the header line. Throwing
IllegalArgumentException or other RuntimeExceptions causes the
parsing process to short-circuit after parsing the header line,
with a CSVStreamException being rethrown by this code.
@param lineConverter
The validator and converter of lines, based on the header line. If
the lineChecker returns null, the line will not be passed to the
writer.
@param resultConsumer
The consumer of the checked lines.
@param <T>
The type of the results that will be created by the lineChecker
and pushed into the writer {@link Consumer}.
@throws IOException
If an error occurred accessing the input.
@throws CSVStreamException
If an error occurred validating the input.
"""
try (final Reader inputStreamReader = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8));) {
parse(inputStreamReader, headersValidator, lineConverter, resultConsumer);
}
} | java | public static <T> void parse(final InputStream inputStream, final Consumer<List<String>> headersValidator,
final BiFunction<List<String>, List<String>, T> lineConverter, final Consumer<T> resultConsumer)
throws IOException, CSVStreamException {
try (final Reader inputStreamReader = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8));) {
parse(inputStreamReader, headersValidator, lineConverter, resultConsumer);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"parse",
"(",
"final",
"InputStream",
"inputStream",
",",
"final",
"Consumer",
"<",
"List",
"<",
"String",
">",
">",
"headersValidator",
",",
"final",
"BiFunction",
"<",
"List",
"<",
"String",
">",
",",
"List",
"<",
"String",
">",
",",
"T",
">",
"lineConverter",
",",
"final",
"Consumer",
"<",
"T",
">",
"resultConsumer",
")",
"throws",
"IOException",
",",
"CSVStreamException",
"{",
"try",
"(",
"final",
"Reader",
"inputStreamReader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"inputStream",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
")",
"{",
"parse",
"(",
"inputStreamReader",
",",
"headersValidator",
",",
"lineConverter",
",",
"resultConsumer",
")",
";",
"}",
"}"
] | Stream a CSV file from the given InputStream through the header validator,
line checker, and if the line checker succeeds, send the checked/converted
line to the consumer.
@param inputStream
The {@link InputStream} containing the CSV file.
@param headersValidator
The validator of the header line. Throwing
IllegalArgumentException or other RuntimeExceptions causes the
parsing process to short-circuit after parsing the header line,
with a CSVStreamException being rethrown by this code.
@param lineConverter
The validator and converter of lines, based on the header line. If
the lineChecker returns null, the line will not be passed to the
writer.
@param resultConsumer
The consumer of the checked lines.
@param <T>
The type of the results that will be created by the lineChecker
and pushed into the writer {@link Consumer}.
@throws IOException
If an error occurred accessing the input.
@throws CSVStreamException
If an error occurred validating the input. | [
"Stream",
"a",
"CSV",
"file",
"from",
"the",
"given",
"InputStream",
"through",
"the",
"header",
"validator",
"line",
"checker",
"and",
"if",
"the",
"line",
"checker",
"succeeds",
"send",
"the",
"checked",
"/",
"converted",
"line",
"to",
"the",
"consumer",
"."
] | train | https://github.com/ansell/csvstream/blob/9468bfbd6997fbc4237eafc990ba811cd5905dc1/src/main/java/com/github/ansell/csv/stream/CSVStream.java#L95-L102 |
kiegroup/drools | drools-compiler/src/main/java/org/drools/compiler/lang/DRL6Expressions.java | DRL6Expressions.xpathSeparator | public final void xpathSeparator() throws RecognitionException {
"""
src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:559:1: xpathSeparator : ( DIV | QUESTION_DIV );
"""
try {
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:560:5: ( DIV | QUESTION_DIV )
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:
{
if ( input.LA(1)==DIV||input.LA(1)==QUESTION_DIV ) {
input.consume();
state.errorRecovery=false;
state.failed=false;
}
else {
if (state.backtracking>0) {state.failed=true; return;}
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
}
}
catch (RecognitionException re) {
throw re;
}
finally {
// do for sure before leaving
}
} | java | public final void xpathSeparator() throws RecognitionException {
try {
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:560:5: ( DIV | QUESTION_DIV )
// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:
{
if ( input.LA(1)==DIV||input.LA(1)==QUESTION_DIV ) {
input.consume();
state.errorRecovery=false;
state.failed=false;
}
else {
if (state.backtracking>0) {state.failed=true; return;}
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
}
}
catch (RecognitionException re) {
throw re;
}
finally {
// do for sure before leaving
}
} | [
"public",
"final",
"void",
"xpathSeparator",
"(",
")",
"throws",
"RecognitionException",
"{",
"try",
"{",
"// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:560:5: ( DIV | QUESTION_DIV )",
"// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:",
"{",
"if",
"(",
"input",
".",
"LA",
"(",
"1",
")",
"==",
"DIV",
"||",
"input",
".",
"LA",
"(",
"1",
")",
"==",
"QUESTION_DIV",
")",
"{",
"input",
".",
"consume",
"(",
")",
";",
"state",
".",
"errorRecovery",
"=",
"false",
";",
"state",
".",
"failed",
"=",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"state",
".",
"backtracking",
">",
"0",
")",
"{",
"state",
".",
"failed",
"=",
"true",
";",
"return",
";",
"}",
"MismatchedSetException",
"mse",
"=",
"new",
"MismatchedSetException",
"(",
"null",
",",
"input",
")",
";",
"throw",
"mse",
";",
"}",
"}",
"}",
"catch",
"(",
"RecognitionException",
"re",
")",
"{",
"throw",
"re",
";",
"}",
"finally",
"{",
"// do for sure before leaving",
"}",
"}"
] | src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:559:1: xpathSeparator : ( DIV | QUESTION_DIV ); | [
"src",
"/",
"main",
"/",
"resources",
"/",
"org",
"/",
"drools",
"/",
"compiler",
"/",
"lang",
"/",
"DRL6Expressions",
".",
"g",
":",
"559",
":",
"1",
":",
"xpathSeparator",
":",
"(",
"DIV",
"|",
"QUESTION_DIV",
")",
";"
] | train | https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL6Expressions.java#L4023-L4049 |
WASdev/tool.accelerate.core | liberty-starter-application/src/main/java/com/ibm/liberty/starter/StarterUtil.java | StarterUtil.populateFilesList | public static void populateFilesList(File dir, List<File> filesListInDir) {
"""
Generate the list of files in the directory and all of its sub-directories (recursive)
@param dir - The directory
@param filesListInDir - List to store the files
"""
File[] files = dir.listFiles();
for(File file : files){
if(file.isFile()){
filesListInDir.add(file);
}else{
populateFilesList(file, filesListInDir);
}
}
} | java | public static void populateFilesList(File dir, List<File> filesListInDir) {
File[] files = dir.listFiles();
for(File file : files){
if(file.isFile()){
filesListInDir.add(file);
}else{
populateFilesList(file, filesListInDir);
}
}
} | [
"public",
"static",
"void",
"populateFilesList",
"(",
"File",
"dir",
",",
"List",
"<",
"File",
">",
"filesListInDir",
")",
"{",
"File",
"[",
"]",
"files",
"=",
"dir",
".",
"listFiles",
"(",
")",
";",
"for",
"(",
"File",
"file",
":",
"files",
")",
"{",
"if",
"(",
"file",
".",
"isFile",
"(",
")",
")",
"{",
"filesListInDir",
".",
"add",
"(",
"file",
")",
";",
"}",
"else",
"{",
"populateFilesList",
"(",
"file",
",",
"filesListInDir",
")",
";",
"}",
"}",
"}"
] | Generate the list of files in the directory and all of its sub-directories (recursive)
@param dir - The directory
@param filesListInDir - List to store the files | [
"Generate",
"the",
"list",
"of",
"files",
"in",
"the",
"directory",
"and",
"all",
"of",
"its",
"sub",
"-",
"directories",
"(",
"recursive",
")"
] | train | https://github.com/WASdev/tool.accelerate.core/blob/6511da654a69a25a76573eb76eefff349d9c4d80/liberty-starter-application/src/main/java/com/ibm/liberty/starter/StarterUtil.java#L74-L83 |
haifengl/smile | core/src/main/java/smile/neighbor/MPLSH.java | MPLSH.learn | public void learn(RNNSearch<double[], double[]> range, double[][] samples, double radius, int Nz) {
"""
Train the posteriori multiple probe algorithm.
@param range the neighborhood search data structure.
@param radius the radius for range search.
@param Nz the number of quantized values.
"""
learn(range, samples, radius, Nz, 0.2);
} | java | public void learn(RNNSearch<double[], double[]> range, double[][] samples, double radius, int Nz) {
learn(range, samples, radius, Nz, 0.2);
} | [
"public",
"void",
"learn",
"(",
"RNNSearch",
"<",
"double",
"[",
"]",
",",
"double",
"[",
"]",
">",
"range",
",",
"double",
"[",
"]",
"[",
"]",
"samples",
",",
"double",
"radius",
",",
"int",
"Nz",
")",
"{",
"learn",
"(",
"range",
",",
"samples",
",",
"radius",
",",
"Nz",
",",
"0.2",
")",
";",
"}"
] | Train the posteriori multiple probe algorithm.
@param range the neighborhood search data structure.
@param radius the radius for range search.
@param Nz the number of quantized values. | [
"Train",
"the",
"posteriori",
"multiple",
"probe",
"algorithm",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/neighbor/MPLSH.java#L858-L860 |
threerings/nenya | core/src/main/java/com/threerings/geom/GeomUtil.java | GeomUtil.whichSide | public static int whichSide (Point p1, double theta, Point p2) {
"""
Returns less than zero if <code>p2</code> is on the left hand side of the line created by
<code>p1</code> and <code>theta</code> and greater than zero if it is on the right hand
side. In theory, it will return zero if the point is on the line, but due to rounding errors
it almost always decides that it's not exactly on the line.
@param p1 the point on the line whose side we're checking.
@param theta the (logical) angle defining the line.
@param p2 the point that lies on one side or the other of the line.
"""
// obtain the point defining the right hand normal (N)
theta += Math.PI/2;
int x = p1.x + (int)Math.round(1000*Math.cos(theta)),
y = p1.y + (int)Math.round(1000*Math.sin(theta));
// now dot the vector from p1->p2 with the vector from p1->N, if it's positive, we're on
// the right hand side, if it's negative we're on the left hand side and if it's zero,
// we're on the line
return dot(p1.x, p1.y, p2.x, p2.y, x, y);
} | java | public static int whichSide (Point p1, double theta, Point p2)
{
// obtain the point defining the right hand normal (N)
theta += Math.PI/2;
int x = p1.x + (int)Math.round(1000*Math.cos(theta)),
y = p1.y + (int)Math.round(1000*Math.sin(theta));
// now dot the vector from p1->p2 with the vector from p1->N, if it's positive, we're on
// the right hand side, if it's negative we're on the left hand side and if it's zero,
// we're on the line
return dot(p1.x, p1.y, p2.x, p2.y, x, y);
} | [
"public",
"static",
"int",
"whichSide",
"(",
"Point",
"p1",
",",
"double",
"theta",
",",
"Point",
"p2",
")",
"{",
"// obtain the point defining the right hand normal (N)",
"theta",
"+=",
"Math",
".",
"PI",
"/",
"2",
";",
"int",
"x",
"=",
"p1",
".",
"x",
"+",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"1000",
"*",
"Math",
".",
"cos",
"(",
"theta",
")",
")",
",",
"y",
"=",
"p1",
".",
"y",
"+",
"(",
"int",
")",
"Math",
".",
"round",
"(",
"1000",
"*",
"Math",
".",
"sin",
"(",
"theta",
")",
")",
";",
"// now dot the vector from p1->p2 with the vector from p1->N, if it's positive, we're on",
"// the right hand side, if it's negative we're on the left hand side and if it's zero,",
"// we're on the line",
"return",
"dot",
"(",
"p1",
".",
"x",
",",
"p1",
".",
"y",
",",
"p2",
".",
"x",
",",
"p2",
".",
"y",
",",
"x",
",",
"y",
")",
";",
"}"
] | Returns less than zero if <code>p2</code> is on the left hand side of the line created by
<code>p1</code> and <code>theta</code> and greater than zero if it is on the right hand
side. In theory, it will return zero if the point is on the line, but due to rounding errors
it almost always decides that it's not exactly on the line.
@param p1 the point on the line whose side we're checking.
@param theta the (logical) angle defining the line.
@param p2 the point that lies on one side or the other of the line. | [
"Returns",
"less",
"than",
"zero",
"if",
"<code",
">",
"p2<",
"/",
"code",
">",
"is",
"on",
"the",
"left",
"hand",
"side",
"of",
"the",
"line",
"created",
"by",
"<code",
">",
"p1<",
"/",
"code",
">",
"and",
"<code",
">",
"theta<",
"/",
"code",
">",
"and",
"greater",
"than",
"zero",
"if",
"it",
"is",
"on",
"the",
"right",
"hand",
"side",
".",
"In",
"theory",
"it",
"will",
"return",
"zero",
"if",
"the",
"point",
"is",
"on",
"the",
"line",
"but",
"due",
"to",
"rounding",
"errors",
"it",
"almost",
"always",
"decides",
"that",
"it",
"s",
"not",
"exactly",
"on",
"the",
"line",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/geom/GeomUtil.java#L160-L171 |
tzaeschke/zoodb | src/org/zoodb/internal/DataDeSerializer.java | DataDeSerializer.readObject | public ZooPC readObject(int page, int offs, boolean skipIfCached) {
"""
This method returns an object that is read from the input
stream.
@param page page id
@param offs offset in page
@param skipIfCached Set 'true' to skip objects that are already in the cache
@return The read object.
"""
long clsOid = in.startReading(page, offs);
long ts = in.getHeaderTimestamp();
//Read first object:
long oid = in.readLong();
//check cache
ZooPC pc = cache.findCoByOID(oid);
if (skipIfCached && pc != null) {
if (pc.jdoZooIsDeleted() || !pc.jdoZooIsStateHollow()) {
//isDeleted() are filtered out later.
return pc;
}
}
ZooClassDef clsDef = cache.getSchema(clsOid);
ObjectReader or = in;
boolean isEvolved = false;
if (clsDef.getNextVersion() != null) {
isEvolved = true;
GenericObject go = GenericObject.newInstance(clsDef, oid, false, cache);
readGOPrivate(go, clsDef);
clsDef = go.ensureLatestVersion();
in = go.toStream();
if (oid != in.readLong()) {
throw new IllegalStateException();
}
}
ZooPC pObj = getInstance(clsDef, oid, pc);
pObj.jdoZooSetTimestamp(ts);
readObjPrivate(pObj, clsDef);
in = or;
if (isEvolved) {
//force object to be stored again
//TODO is this necessary?
pObj.jdoZooMarkDirty();
}
return pObj;
} | java | public ZooPC readObject(int page, int offs, boolean skipIfCached) {
long clsOid = in.startReading(page, offs);
long ts = in.getHeaderTimestamp();
//Read first object:
long oid = in.readLong();
//check cache
ZooPC pc = cache.findCoByOID(oid);
if (skipIfCached && pc != null) {
if (pc.jdoZooIsDeleted() || !pc.jdoZooIsStateHollow()) {
//isDeleted() are filtered out later.
return pc;
}
}
ZooClassDef clsDef = cache.getSchema(clsOid);
ObjectReader or = in;
boolean isEvolved = false;
if (clsDef.getNextVersion() != null) {
isEvolved = true;
GenericObject go = GenericObject.newInstance(clsDef, oid, false, cache);
readGOPrivate(go, clsDef);
clsDef = go.ensureLatestVersion();
in = go.toStream();
if (oid != in.readLong()) {
throw new IllegalStateException();
}
}
ZooPC pObj = getInstance(clsDef, oid, pc);
pObj.jdoZooSetTimestamp(ts);
readObjPrivate(pObj, clsDef);
in = or;
if (isEvolved) {
//force object to be stored again
//TODO is this necessary?
pObj.jdoZooMarkDirty();
}
return pObj;
} | [
"public",
"ZooPC",
"readObject",
"(",
"int",
"page",
",",
"int",
"offs",
",",
"boolean",
"skipIfCached",
")",
"{",
"long",
"clsOid",
"=",
"in",
".",
"startReading",
"(",
"page",
",",
"offs",
")",
";",
"long",
"ts",
"=",
"in",
".",
"getHeaderTimestamp",
"(",
")",
";",
"//Read first object:",
"long",
"oid",
"=",
"in",
".",
"readLong",
"(",
")",
";",
"//check cache",
"ZooPC",
"pc",
"=",
"cache",
".",
"findCoByOID",
"(",
"oid",
")",
";",
"if",
"(",
"skipIfCached",
"&&",
"pc",
"!=",
"null",
")",
"{",
"if",
"(",
"pc",
".",
"jdoZooIsDeleted",
"(",
")",
"||",
"!",
"pc",
".",
"jdoZooIsStateHollow",
"(",
")",
")",
"{",
"//isDeleted() are filtered out later.",
"return",
"pc",
";",
"}",
"}",
"ZooClassDef",
"clsDef",
"=",
"cache",
".",
"getSchema",
"(",
"clsOid",
")",
";",
"ObjectReader",
"or",
"=",
"in",
";",
"boolean",
"isEvolved",
"=",
"false",
";",
"if",
"(",
"clsDef",
".",
"getNextVersion",
"(",
")",
"!=",
"null",
")",
"{",
"isEvolved",
"=",
"true",
";",
"GenericObject",
"go",
"=",
"GenericObject",
".",
"newInstance",
"(",
"clsDef",
",",
"oid",
",",
"false",
",",
"cache",
")",
";",
"readGOPrivate",
"(",
"go",
",",
"clsDef",
")",
";",
"clsDef",
"=",
"go",
".",
"ensureLatestVersion",
"(",
")",
";",
"in",
"=",
"go",
".",
"toStream",
"(",
")",
";",
"if",
"(",
"oid",
"!=",
"in",
".",
"readLong",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"}",
"}",
"ZooPC",
"pObj",
"=",
"getInstance",
"(",
"clsDef",
",",
"oid",
",",
"pc",
")",
";",
"pObj",
".",
"jdoZooSetTimestamp",
"(",
"ts",
")",
";",
"readObjPrivate",
"(",
"pObj",
",",
"clsDef",
")",
";",
"in",
"=",
"or",
";",
"if",
"(",
"isEvolved",
")",
"{",
"//force object to be stored again",
"//TODO is this necessary?",
"pObj",
".",
"jdoZooMarkDirty",
"(",
")",
";",
"}",
"return",
"pObj",
";",
"}"
] | This method returns an object that is read from the input
stream.
@param page page id
@param offs offset in page
@param skipIfCached Set 'true' to skip objects that are already in the cache
@return The read object. | [
"This",
"method",
"returns",
"an",
"object",
"that",
"is",
"read",
"from",
"the",
"input",
"stream",
"."
] | train | https://github.com/tzaeschke/zoodb/blob/058d0ff161a8ee9d53244c433aca97ee9c654410/src/org/zoodb/internal/DataDeSerializer.java#L152-L194 |
mnlipp/jgrapes | org.jgrapes.http/src/org/jgrapes/http/HttpServer.java | HttpServer.onAccepted | @Handler(channels = NetworkChannel.class)
public void onAccepted(Accepted event, IOSubchannel netChannel) {
"""
Creates a new downstream connection as {@link LinkedIOSubchannel}
of the network connection, a {@link HttpRequestDecoder} and a
{@link HttpResponseEncoder}.
@param event
the accepted event
"""
new WebAppMsgChannel(event, netChannel);
} | java | @Handler(channels = NetworkChannel.class)
public void onAccepted(Accepted event, IOSubchannel netChannel) {
new WebAppMsgChannel(event, netChannel);
} | [
"@",
"Handler",
"(",
"channels",
"=",
"NetworkChannel",
".",
"class",
")",
"public",
"void",
"onAccepted",
"(",
"Accepted",
"event",
",",
"IOSubchannel",
"netChannel",
")",
"{",
"new",
"WebAppMsgChannel",
"(",
"event",
",",
"netChannel",
")",
";",
"}"
] | Creates a new downstream connection as {@link LinkedIOSubchannel}
of the network connection, a {@link HttpRequestDecoder} and a
{@link HttpResponseEncoder}.
@param event
the accepted event | [
"Creates",
"a",
"new",
"downstream",
"connection",
"as",
"{",
"@link",
"LinkedIOSubchannel",
"}",
"of",
"the",
"network",
"connection",
"a",
"{",
"@link",
"HttpRequestDecoder",
"}",
"and",
"a",
"{",
"@link",
"HttpResponseEncoder",
"}",
"."
] | train | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http/src/org/jgrapes/http/HttpServer.java#L237-L240 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/fieldaccessor/FieldAccessor.java | FieldAccessor.setLabel | public void setLabel(final Object targetObj, final String label) {
"""
ラベル情報を設定します。
<p>ラベル情報を保持するフィールドがない場合は、処理はスキップされます。</p>
@param targetObj フィールドが定義されているクラスのインスタンス
@param label ラベル情報
@throws IllegalArgumentException {@literal targetObj == null or label == null}
@throws IllegalArgumentException {@literal label is empty}
"""
ArgUtils.notNull(targetObj, "targetObj");
ArgUtils.notEmpty(label, "label");
labelSetter.ifPresent(setter -> setter.set(targetObj, label));
} | java | public void setLabel(final Object targetObj, final String label) {
ArgUtils.notNull(targetObj, "targetObj");
ArgUtils.notEmpty(label, "label");
labelSetter.ifPresent(setter -> setter.set(targetObj, label));
} | [
"public",
"void",
"setLabel",
"(",
"final",
"Object",
"targetObj",
",",
"final",
"String",
"label",
")",
"{",
"ArgUtils",
".",
"notNull",
"(",
"targetObj",
",",
"\"targetObj\"",
")",
";",
"ArgUtils",
".",
"notEmpty",
"(",
"label",
",",
"\"label\"",
")",
";",
"labelSetter",
".",
"ifPresent",
"(",
"setter",
"->",
"setter",
".",
"set",
"(",
"targetObj",
",",
"label",
")",
")",
";",
"}"
] | ラベル情報を設定します。
<p>ラベル情報を保持するフィールドがない場合は、処理はスキップされます。</p>
@param targetObj フィールドが定義されているクラスのインスタンス
@param label ラベル情報
@throws IllegalArgumentException {@literal targetObj == null or label == null}
@throws IllegalArgumentException {@literal label is empty} | [
"ラベル情報を設定します。",
"<p",
">",
"ラベル情報を保持するフィールドがない場合は、処理はスキップされます。<",
"/",
"p",
">"
] | train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/fieldaccessor/FieldAccessor.java#L423-L429 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPDefinitionOptionRelPersistenceImpl.java | CPDefinitionOptionRelPersistenceImpl.findByC_C | @Override
public CPDefinitionOptionRel findByC_C(long CPDefinitionId, long CPOptionId)
throws NoSuchCPDefinitionOptionRelException {
"""
Returns the cp definition option rel where CPDefinitionId = ? and CPOptionId = ? or throws a {@link NoSuchCPDefinitionOptionRelException} if it could not be found.
@param CPDefinitionId the cp definition ID
@param CPOptionId the cp option ID
@return the matching cp definition option rel
@throws NoSuchCPDefinitionOptionRelException if a matching cp definition option rel could not be found
"""
CPDefinitionOptionRel cpDefinitionOptionRel = fetchByC_C(CPDefinitionId,
CPOptionId);
if (cpDefinitionOptionRel == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("CPDefinitionId=");
msg.append(CPDefinitionId);
msg.append(", CPOptionId=");
msg.append(CPOptionId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCPDefinitionOptionRelException(msg.toString());
}
return cpDefinitionOptionRel;
} | java | @Override
public CPDefinitionOptionRel findByC_C(long CPDefinitionId, long CPOptionId)
throws NoSuchCPDefinitionOptionRelException {
CPDefinitionOptionRel cpDefinitionOptionRel = fetchByC_C(CPDefinitionId,
CPOptionId);
if (cpDefinitionOptionRel == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("CPDefinitionId=");
msg.append(CPDefinitionId);
msg.append(", CPOptionId=");
msg.append(CPOptionId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCPDefinitionOptionRelException(msg.toString());
}
return cpDefinitionOptionRel;
} | [
"@",
"Override",
"public",
"CPDefinitionOptionRel",
"findByC_C",
"(",
"long",
"CPDefinitionId",
",",
"long",
"CPOptionId",
")",
"throws",
"NoSuchCPDefinitionOptionRelException",
"{",
"CPDefinitionOptionRel",
"cpDefinitionOptionRel",
"=",
"fetchByC_C",
"(",
"CPDefinitionId",
",",
"CPOptionId",
")",
";",
"if",
"(",
"cpDefinitionOptionRel",
"==",
"null",
")",
"{",
"StringBundler",
"msg",
"=",
"new",
"StringBundler",
"(",
"6",
")",
";",
"msg",
".",
"append",
"(",
"_NO_SUCH_ENTITY_WITH_KEY",
")",
";",
"msg",
".",
"append",
"(",
"\"CPDefinitionId=\"",
")",
";",
"msg",
".",
"append",
"(",
"CPDefinitionId",
")",
";",
"msg",
".",
"append",
"(",
"\", CPOptionId=\"",
")",
";",
"msg",
".",
"append",
"(",
"CPOptionId",
")",
";",
"msg",
".",
"append",
"(",
"\"}\"",
")",
";",
"if",
"(",
"_log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"_log",
".",
"debug",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"throw",
"new",
"NoSuchCPDefinitionOptionRelException",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"cpDefinitionOptionRel",
";",
"}"
] | Returns the cp definition option rel where CPDefinitionId = ? and CPOptionId = ? or throws a {@link NoSuchCPDefinitionOptionRelException} if it could not be found.
@param CPDefinitionId the cp definition ID
@param CPOptionId the cp option ID
@return the matching cp definition option rel
@throws NoSuchCPDefinitionOptionRelException if a matching cp definition option rel could not be found | [
"Returns",
"the",
"cp",
"definition",
"option",
"rel",
"where",
"CPDefinitionId",
"=",
"?",
";",
"and",
"CPOptionId",
"=",
"?",
";",
"or",
"throws",
"a",
"{",
"@link",
"NoSuchCPDefinitionOptionRelException",
"}",
"if",
"it",
"could",
"not",
"be",
"found",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPDefinitionOptionRelPersistenceImpl.java#L3063-L3090 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/file/FileWriter.java | FileWriter.writeLines | public <T> File writeLines(Collection<T> list, LineSeparator lineSeparator, boolean isAppend) throws IORuntimeException {
"""
将列表写入文件
@param <T> 集合元素类型
@param list 列表
@param lineSeparator 换行符枚举(Windows、Mac或Linux换行符)
@param isAppend 是否追加
@return 目标文件
@throws IORuntimeException IO异常
@since 3.1.0
"""
try (PrintWriter writer = getPrintWriter(isAppend)){
for (T t : list) {
if (null != t) {
writer.print(t.toString());
printNewLine(writer, lineSeparator);
writer.flush();
}
}
}
return this.file;
} | java | public <T> File writeLines(Collection<T> list, LineSeparator lineSeparator, boolean isAppend) throws IORuntimeException {
try (PrintWriter writer = getPrintWriter(isAppend)){
for (T t : list) {
if (null != t) {
writer.print(t.toString());
printNewLine(writer, lineSeparator);
writer.flush();
}
}
}
return this.file;
} | [
"public",
"<",
"T",
">",
"File",
"writeLines",
"(",
"Collection",
"<",
"T",
">",
"list",
",",
"LineSeparator",
"lineSeparator",
",",
"boolean",
"isAppend",
")",
"throws",
"IORuntimeException",
"{",
"try",
"(",
"PrintWriter",
"writer",
"=",
"getPrintWriter",
"(",
"isAppend",
")",
")",
"{",
"for",
"(",
"T",
"t",
":",
"list",
")",
"{",
"if",
"(",
"null",
"!=",
"t",
")",
"{",
"writer",
".",
"print",
"(",
"t",
".",
"toString",
"(",
")",
")",
";",
"printNewLine",
"(",
"writer",
",",
"lineSeparator",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"}",
"}",
"}",
"return",
"this",
".",
"file",
";",
"}"
] | 将列表写入文件
@param <T> 集合元素类型
@param list 列表
@param lineSeparator 换行符枚举(Windows、Mac或Linux换行符)
@param isAppend 是否追加
@return 目标文件
@throws IORuntimeException IO异常
@since 3.1.0 | [
"将列表写入文件"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/file/FileWriter.java#L197-L208 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java | AbstractXmlReader.readCharactersUntilEndTag | protected String readCharactersUntilEndTag(XMLEventReader reader,
QName tagName)
throws XMLStreamException, JournalException {
"""
Loop through a series of character events, accumulating the data into a
String. The character events should be terminated by an EndTagEvent with
the expected tag name.
"""
StringBuffer stringValue = new StringBuffer();
while (true) {
XMLEvent event = reader.nextEvent();
if (event.isCharacters()) {
stringValue.append(event.asCharacters().getData());
} else if (isEndTagEvent(event, tagName)) {
break;
} else {
throw getNotCharactersException(tagName, event);
}
}
return stringValue.toString();
} | java | protected String readCharactersUntilEndTag(XMLEventReader reader,
QName tagName)
throws XMLStreamException, JournalException {
StringBuffer stringValue = new StringBuffer();
while (true) {
XMLEvent event = reader.nextEvent();
if (event.isCharacters()) {
stringValue.append(event.asCharacters().getData());
} else if (isEndTagEvent(event, tagName)) {
break;
} else {
throw getNotCharactersException(tagName, event);
}
}
return stringValue.toString();
} | [
"protected",
"String",
"readCharactersUntilEndTag",
"(",
"XMLEventReader",
"reader",
",",
"QName",
"tagName",
")",
"throws",
"XMLStreamException",
",",
"JournalException",
"{",
"StringBuffer",
"stringValue",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"XMLEvent",
"event",
"=",
"reader",
".",
"nextEvent",
"(",
")",
";",
"if",
"(",
"event",
".",
"isCharacters",
"(",
")",
")",
"{",
"stringValue",
".",
"append",
"(",
"event",
".",
"asCharacters",
"(",
")",
".",
"getData",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"isEndTagEvent",
"(",
"event",
",",
"tagName",
")",
")",
"{",
"break",
";",
"}",
"else",
"{",
"throw",
"getNotCharactersException",
"(",
"tagName",
",",
"event",
")",
";",
"}",
"}",
"return",
"stringValue",
".",
"toString",
"(",
")",
";",
"}"
] | Loop through a series of character events, accumulating the data into a
String. The character events should be terminated by an EndTagEvent with
the expected tag name. | [
"Loop",
"through",
"a",
"series",
"of",
"character",
"events",
"accumulating",
"the",
"data",
"into",
"a",
"String",
".",
"The",
"character",
"events",
"should",
"be",
"terminated",
"by",
"an",
"EndTagEvent",
"with",
"the",
"expected",
"tag",
"name",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/AbstractXmlReader.java#L103-L118 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java | JDBCResultSet.updateShort | public void updateShort(int columnIndex, short x) throws SQLException {
"""
<!-- start generic documentation -->
Updates the designated column with a <code>short</code> value.
The updater methods are used to update column values in the
current row or the insert row. The updater methods do not
update the underlying database; instead the <code>updateRow</code> or
<code>insertRow</code> methods are called to update the database.
<!-- end generic documentation -->
<!-- start release-specific documentation -->
<div class="ReleaseSpecificDocumentation">
<h3>HSQLDB-Specific Information:</h3> <p>
HSQLDB supports this feature. <p>
</div>
<!-- end release-specific documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@param x the new column value
@exception SQLException if a database access error occurs,
the result set concurrency is <code>CONCUR_READ_ONLY</code>
or this method is called on a closed result set
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
@since JDK 1.2 (JDK 1.1.x developers: read the overview for
JDBCResultSet)
"""
startUpdate(columnIndex);
preparedStatement.setIntParameter(columnIndex, x);
} | java | public void updateShort(int columnIndex, short x) throws SQLException {
startUpdate(columnIndex);
preparedStatement.setIntParameter(columnIndex, x);
} | [
"public",
"void",
"updateShort",
"(",
"int",
"columnIndex",
",",
"short",
"x",
")",
"throws",
"SQLException",
"{",
"startUpdate",
"(",
"columnIndex",
")",
";",
"preparedStatement",
".",
"setIntParameter",
"(",
"columnIndex",
",",
"x",
")",
";",
"}"
] | <!-- start generic documentation -->
Updates the designated column with a <code>short</code> value.
The updater methods are used to update column values in the
current row or the insert row. The updater methods do not
update the underlying database; instead the <code>updateRow</code> or
<code>insertRow</code> methods are called to update the database.
<!-- end generic documentation -->
<!-- start release-specific documentation -->
<div class="ReleaseSpecificDocumentation">
<h3>HSQLDB-Specific Information:</h3> <p>
HSQLDB supports this feature. <p>
</div>
<!-- end release-specific documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@param x the new column value
@exception SQLException if a database access error occurs,
the result set concurrency is <code>CONCUR_READ_ONLY</code>
or this method is called on a closed result set
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
@since JDK 1.2 (JDK 1.1.x developers: read the overview for
JDBCResultSet) | [
"<!",
"--",
"start",
"generic",
"documentation",
"--",
">",
"Updates",
"the",
"designated",
"column",
"with",
"a",
"<code",
">",
"short<",
"/",
"code",
">",
"value",
".",
"The",
"updater",
"methods",
"are",
"used",
"to",
"update",
"column",
"values",
"in",
"the",
"current",
"row",
"or",
"the",
"insert",
"row",
".",
"The",
"updater",
"methods",
"do",
"not",
"update",
"the",
"underlying",
"database",
";",
"instead",
"the",
"<code",
">",
"updateRow<",
"/",
"code",
">",
"or",
"<code",
">",
"insertRow<",
"/",
"code",
">",
"methods",
"are",
"called",
"to",
"update",
"the",
"database",
".",
"<!",
"--",
"end",
"generic",
"documentation",
"--",
">"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java#L2717-L2720 |
mguymon/naether | src/main/java/com/tobedevoured/naether/PathClassLoader.java | PathClassLoader.execStaticMethod | public Object execStaticMethod( String className, String methodName, List params ) throws ClassLoaderException {
"""
Helper for executing static methods on a Class
@param className String fully qualified class
@param methodName String method name
@param params List of method parameters
@return Object result
@throws ClassLoaderException exception
"""
return execStaticMethod( className, methodName, params, null );
} | java | public Object execStaticMethod( String className, String methodName, List params ) throws ClassLoaderException {
return execStaticMethod( className, methodName, params, null );
} | [
"public",
"Object",
"execStaticMethod",
"(",
"String",
"className",
",",
"String",
"methodName",
",",
"List",
"params",
")",
"throws",
"ClassLoaderException",
"{",
"return",
"execStaticMethod",
"(",
"className",
",",
"methodName",
",",
"params",
",",
"null",
")",
";",
"}"
] | Helper for executing static methods on a Class
@param className String fully qualified class
@param methodName String method name
@param params List of method parameters
@return Object result
@throws ClassLoaderException exception | [
"Helper",
"for",
"executing",
"static",
"methods",
"on",
"a",
"Class"
] | train | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/java/com/tobedevoured/naether/PathClassLoader.java#L220-L222 |
jbundle/jbundle | base/screen/model/src/main/java/org/jbundle/base/screen/model/BasePanel.java | BasePanel.setProperty | public void setProperty(String strProperty, String strValue) {
"""
Set this property.
@param strProperty The property key.
@param strValue The property value.
"""
if (this.getTask() != null)
this.getTask().setProperty(strProperty, strValue);
} | java | public void setProperty(String strProperty, String strValue)
{
if (this.getTask() != null)
this.getTask().setProperty(strProperty, strValue);
} | [
"public",
"void",
"setProperty",
"(",
"String",
"strProperty",
",",
"String",
"strValue",
")",
"{",
"if",
"(",
"this",
".",
"getTask",
"(",
")",
"!=",
"null",
")",
"this",
".",
"getTask",
"(",
")",
".",
"setProperty",
"(",
"strProperty",
",",
"strValue",
")",
";",
"}"
] | Set this property.
@param strProperty The property key.
@param strValue The property value. | [
"Set",
"this",
"property",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/BasePanel.java#L1364-L1368 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/compute/v2017_12_01/implementation/VirtualMachineScaleSetVMsInner.java | VirtualMachineScaleSetVMsInner.beginUpdate | public VirtualMachineScaleSetVMInner beginUpdate(String resourceGroupName, String vmScaleSetName, String instanceId, VirtualMachineScaleSetVMInner parameters) {
"""
Updates a virtual machine of a VM scale set.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set where the extension should be create or updated.
@param instanceId The instance ID of the virtual machine.
@param parameters Parameters supplied to the Update Virtual Machine Scale Sets VM operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VirtualMachineScaleSetVMInner object if successful.
"""
return beginUpdateWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId, parameters).toBlocking().single().body();
} | java | public VirtualMachineScaleSetVMInner beginUpdate(String resourceGroupName, String vmScaleSetName, String instanceId, VirtualMachineScaleSetVMInner parameters) {
return beginUpdateWithServiceResponseAsync(resourceGroupName, vmScaleSetName, instanceId, parameters).toBlocking().single().body();
} | [
"public",
"VirtualMachineScaleSetVMInner",
"beginUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"vmScaleSetName",
",",
"String",
"instanceId",
",",
"VirtualMachineScaleSetVMInner",
"parameters",
")",
"{",
"return",
"beginUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vmScaleSetName",
",",
"instanceId",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates a virtual machine of a VM scale set.
@param resourceGroupName The name of the resource group.
@param vmScaleSetName The name of the VM scale set where the extension should be create or updated.
@param instanceId The instance ID of the virtual machine.
@param parameters Parameters supplied to the Update Virtual Machine Scale Sets VM operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VirtualMachineScaleSetVMInner object if successful. | [
"Updates",
"a",
"virtual",
"machine",
"of",
"a",
"VM",
"scale",
"set",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/compute/v2017_12_01/implementation/VirtualMachineScaleSetVMsInner.java#L769-L771 |
camunda/camunda-commons | utils/src/main/java/org/camunda/commons/utils/EnsureUtil.java | EnsureUtil.ensureNotNull | public static void ensureNotNull(String parameterName, Object value) {
"""
Ensures that the parameter is not null.
@param parameterName the parameter name
@param value the value to ensure to be not null
@throws IllegalArgumentException if the parameter value is null
"""
if(value == null) {
throw LOG.parameterIsNullException(parameterName);
}
} | java | public static void ensureNotNull(String parameterName, Object value) {
if(value == null) {
throw LOG.parameterIsNullException(parameterName);
}
} | [
"public",
"static",
"void",
"ensureNotNull",
"(",
"String",
"parameterName",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"LOG",
".",
"parameterIsNullException",
"(",
"parameterName",
")",
";",
"}",
"}"
] | Ensures that the parameter is not null.
@param parameterName the parameter name
@param value the value to ensure to be not null
@throws IllegalArgumentException if the parameter value is null | [
"Ensures",
"that",
"the",
"parameter",
"is",
"not",
"null",
"."
] | train | https://github.com/camunda/camunda-commons/blob/bd3195db47c92c25717288fe9e6735f8e882f247/utils/src/main/java/org/camunda/commons/utils/EnsureUtil.java#L33-L37 |
camunda/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/ProcessDefinitionManager.java | ProcessDefinitionManager.cascadeDeleteProcessInstancesForProcessDefinition | protected void cascadeDeleteProcessInstancesForProcessDefinition(String processDefinitionId, boolean skipCustomListeners, boolean skipIoMappings) {
"""
Cascades the deletion of the process definition to the process instances.
Skips the custom listeners if the flag was set to true.
@param processDefinitionId the process definition id
@param skipCustomListeners true if the custom listeners should be skipped at process instance deletion
@param skipIoMappings specifies whether input/output mappings for tasks should be invoked
"""
getProcessInstanceManager()
.deleteProcessInstancesByProcessDefinition(processDefinitionId, "deleted process definition", true, skipCustomListeners, skipIoMappings);
} | java | protected void cascadeDeleteProcessInstancesForProcessDefinition(String processDefinitionId, boolean skipCustomListeners, boolean skipIoMappings) {
getProcessInstanceManager()
.deleteProcessInstancesByProcessDefinition(processDefinitionId, "deleted process definition", true, skipCustomListeners, skipIoMappings);
} | [
"protected",
"void",
"cascadeDeleteProcessInstancesForProcessDefinition",
"(",
"String",
"processDefinitionId",
",",
"boolean",
"skipCustomListeners",
",",
"boolean",
"skipIoMappings",
")",
"{",
"getProcessInstanceManager",
"(",
")",
".",
"deleteProcessInstancesByProcessDefinition",
"(",
"processDefinitionId",
",",
"\"deleted process definition\"",
",",
"true",
",",
"skipCustomListeners",
",",
"skipIoMappings",
")",
";",
"}"
] | Cascades the deletion of the process definition to the process instances.
Skips the custom listeners if the flag was set to true.
@param processDefinitionId the process definition id
@param skipCustomListeners true if the custom listeners should be skipped at process instance deletion
@param skipIoMappings specifies whether input/output mappings for tasks should be invoked | [
"Cascades",
"the",
"deletion",
"of",
"the",
"process",
"definition",
"to",
"the",
"process",
"instances",
".",
"Skips",
"the",
"custom",
"listeners",
"if",
"the",
"flag",
"was",
"set",
"to",
"true",
"."
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/ProcessDefinitionManager.java#L238-L241 |
apache/incubator-druid | core/src/main/java/org/apache/druid/java/util/metrics/Monitors.java | Monitors.createCompoundJvmMonitor | public static Monitor createCompoundJvmMonitor(Map<String, String[]> dimensions, String feed) {
"""
Creates a JVM monitor, configured with the given dimensions, that gathers all currently available JVM-wide
monitors: {@link JvmMonitor}, {@link JvmCpuMonitor} and {@link JvmThreadsMonitor} (this list may
change in any future release of this library, including a minor release).
@param dimensions common dimensions to configure the JVM monitor with
@param feed feed for all emitted events
@return a universally useful JVM-wide monitor
"""
// This list doesn't include SysMonitor because it should probably be run only in one JVM, if several JVMs are
// running on the same instance, so most of the time SysMonitor should be configured/set up differently than
// "simple" JVM monitors, created below.
return and(// Could equally be or(), because all member monitors always return true from their monitor() methods.
new JvmMonitor(dimensions, feed),
new JvmCpuMonitor(dimensions, feed),
new JvmThreadsMonitor(dimensions, feed)
);
} | java | public static Monitor createCompoundJvmMonitor(Map<String, String[]> dimensions, String feed)
{
// This list doesn't include SysMonitor because it should probably be run only in one JVM, if several JVMs are
// running on the same instance, so most of the time SysMonitor should be configured/set up differently than
// "simple" JVM monitors, created below.
return and(// Could equally be or(), because all member monitors always return true from their monitor() methods.
new JvmMonitor(dimensions, feed),
new JvmCpuMonitor(dimensions, feed),
new JvmThreadsMonitor(dimensions, feed)
);
} | [
"public",
"static",
"Monitor",
"createCompoundJvmMonitor",
"(",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"dimensions",
",",
"String",
"feed",
")",
"{",
"// This list doesn't include SysMonitor because it should probably be run only in one JVM, if several JVMs are",
"// running on the same instance, so most of the time SysMonitor should be configured/set up differently than",
"// \"simple\" JVM monitors, created below.",
"return",
"and",
"(",
"// Could equally be or(), because all member monitors always return true from their monitor() methods.",
"new",
"JvmMonitor",
"(",
"dimensions",
",",
"feed",
")",
",",
"new",
"JvmCpuMonitor",
"(",
"dimensions",
",",
"feed",
")",
",",
"new",
"JvmThreadsMonitor",
"(",
"dimensions",
",",
"feed",
")",
")",
";",
"}"
] | Creates a JVM monitor, configured with the given dimensions, that gathers all currently available JVM-wide
monitors: {@link JvmMonitor}, {@link JvmCpuMonitor} and {@link JvmThreadsMonitor} (this list may
change in any future release of this library, including a minor release).
@param dimensions common dimensions to configure the JVM monitor with
@param feed feed for all emitted events
@return a universally useful JVM-wide monitor | [
"Creates",
"a",
"JVM",
"monitor",
"configured",
"with",
"the",
"given",
"dimensions",
"that",
"gathers",
"all",
"currently",
"available",
"JVM",
"-",
"wide",
"monitors",
":",
"{",
"@link",
"JvmMonitor",
"}",
"{",
"@link",
"JvmCpuMonitor",
"}",
"and",
"{",
"@link",
"JvmThreadsMonitor",
"}",
"(",
"this",
"list",
"may",
"change",
"in",
"any",
"future",
"release",
"of",
"this",
"library",
"including",
"a",
"minor",
"release",
")",
"."
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/core/src/main/java/org/apache/druid/java/util/metrics/Monitors.java#L51-L61 |
alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java | Node.freeTopology | public void freeTopology(String topId, Cluster cluster) {
"""
Frees all the slots for a topology.
@param topId the topology to free slots for
@param cluster the cluster to update
"""
Set<WorkerSlot> slots = _topIdToUsedSlots.get(topId);
if (slots == null || slots.isEmpty())
return;
for (WorkerSlot ws : slots) {
cluster.freeSlot(ws);
if (_isAlive) {
_freeSlots.add(ws);
}
}
_topIdToUsedSlots.remove(topId);
} | java | public void freeTopology(String topId, Cluster cluster) {
Set<WorkerSlot> slots = _topIdToUsedSlots.get(topId);
if (slots == null || slots.isEmpty())
return;
for (WorkerSlot ws : slots) {
cluster.freeSlot(ws);
if (_isAlive) {
_freeSlots.add(ws);
}
}
_topIdToUsedSlots.remove(topId);
} | [
"public",
"void",
"freeTopology",
"(",
"String",
"topId",
",",
"Cluster",
"cluster",
")",
"{",
"Set",
"<",
"WorkerSlot",
">",
"slots",
"=",
"_topIdToUsedSlots",
".",
"get",
"(",
"topId",
")",
";",
"if",
"(",
"slots",
"==",
"null",
"||",
"slots",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"for",
"(",
"WorkerSlot",
"ws",
":",
"slots",
")",
"{",
"cluster",
".",
"freeSlot",
"(",
"ws",
")",
";",
"if",
"(",
"_isAlive",
")",
"{",
"_freeSlots",
".",
"add",
"(",
"ws",
")",
";",
"}",
"}",
"_topIdToUsedSlots",
".",
"remove",
"(",
"topId",
")",
";",
"}"
] | Frees all the slots for a topology.
@param topId the topology to free slots for
@param cluster the cluster to update | [
"Frees",
"all",
"the",
"slots",
"for",
"a",
"topology",
"."
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java#L204-L215 |
amzn/ion-java | src/com/amazon/ion/impl/_Private_IonTextAppender.java | _Private_IonTextAppender.printSymbol | public final void printSymbol(CharSequence text)
throws IOException {
"""
Print an Ion Symbol type. This method will check if symbol needs quoting
@param text
@throws IOException
"""
if (text == null)
{
appendAscii("null.symbol");
}
else if (symbolNeedsQuoting(text, true)) {
appendAscii('\'');
printCodePoints(text, SYMBOL_ESCAPE_CODES);
appendAscii('\'');
}
else
{
appendAscii(text);
}
} | java | public final void printSymbol(CharSequence text)
throws IOException
{
if (text == null)
{
appendAscii("null.symbol");
}
else if (symbolNeedsQuoting(text, true)) {
appendAscii('\'');
printCodePoints(text, SYMBOL_ESCAPE_CODES);
appendAscii('\'');
}
else
{
appendAscii(text);
}
} | [
"public",
"final",
"void",
"printSymbol",
"(",
"CharSequence",
"text",
")",
"throws",
"IOException",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"appendAscii",
"(",
"\"null.symbol\"",
")",
";",
"}",
"else",
"if",
"(",
"symbolNeedsQuoting",
"(",
"text",
",",
"true",
")",
")",
"{",
"appendAscii",
"(",
"'",
"'",
")",
";",
"printCodePoints",
"(",
"text",
",",
"SYMBOL_ESCAPE_CODES",
")",
";",
"appendAscii",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"appendAscii",
"(",
"text",
")",
";",
"}",
"}"
] | Print an Ion Symbol type. This method will check if symbol needs quoting
@param text
@throws IOException | [
"Print",
"an",
"Ion",
"Symbol",
"type",
".",
"This",
"method",
"will",
"check",
"if",
"symbol",
"needs",
"quoting"
] | train | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_IonTextAppender.java#L535-L551 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java | ShapeFittingOps.fitEllipse_F64 | public static FitData<EllipseRotated_F64> fitEllipse_F64( List<Point2D_F64> points, int iterations ,
boolean computeError ,
FitData<EllipseRotated_F64> outputStorage ) {
"""
Computes the best fit ellipse based on minimizing Euclidean distance. An estimate is initially provided
using algebraic algorithm which is then refined using non-linear optimization. The amount of non-linear
optimization can be controlled using 'iterations' parameter. Will work with partial and complete contours
of objects.
<p>NOTE: To improve speed, make calls directly to classes in Georegression. Look at the code for details.</p>
@param points (Input) Set of unordered points. Not modified.
@param iterations Number of iterations used to refine the fit. If set to zero then an algebraic solution
is returned.
@param computeError If true it will compute the average Euclidean distance error
@param outputStorage (Output/Optional) Storage for the ellipse. Can be null.
@return Found ellipse.
"""
if( outputStorage == null ) {
outputStorage = new FitData<>(new EllipseRotated_F64());
}
// Compute the optimal algebraic error
FitEllipseAlgebraic_F64 algebraic = new FitEllipseAlgebraic_F64();
if( !algebraic.process(points)) {
// could be a line or some other weird case. Create a crude estimate instead
FitData<Circle2D_F64> circleData = averageCircle_F64(points,null,null);
Circle2D_F64 circle = circleData.shape;
outputStorage.shape.set(circle.center.x,circle.center.y,circle.radius,circle.radius,0);
} else {
UtilEllipse_F64.convert(algebraic.getEllipse(),outputStorage.shape);
}
// Improve the solution from algebraic into Euclidean
if( iterations > 0 ) {
RefineEllipseEuclideanLeastSquares_F64 leastSquares = new RefineEllipseEuclideanLeastSquares_F64();
leastSquares.setMaxIterations(iterations);
leastSquares.refine(outputStorage.shape,points);
outputStorage.shape.set( leastSquares.getFound() );
}
// compute the average Euclidean error if the user requests it
if( computeError ) {
ClosestPointEllipseAngle_F64 closestPoint = new ClosestPointEllipseAngle_F64(1e-8,100);
closestPoint.setEllipse(outputStorage.shape);
double total = 0;
for( Point2D_F64 p : points ) {
closestPoint.process(p);
total += p.distance(closestPoint.getClosest());
}
outputStorage.error = total/points.size();
} else {
outputStorage.error = 0;
}
return outputStorage;
} | java | public static FitData<EllipseRotated_F64> fitEllipse_F64( List<Point2D_F64> points, int iterations ,
boolean computeError ,
FitData<EllipseRotated_F64> outputStorage ) {
if( outputStorage == null ) {
outputStorage = new FitData<>(new EllipseRotated_F64());
}
// Compute the optimal algebraic error
FitEllipseAlgebraic_F64 algebraic = new FitEllipseAlgebraic_F64();
if( !algebraic.process(points)) {
// could be a line or some other weird case. Create a crude estimate instead
FitData<Circle2D_F64> circleData = averageCircle_F64(points,null,null);
Circle2D_F64 circle = circleData.shape;
outputStorage.shape.set(circle.center.x,circle.center.y,circle.radius,circle.radius,0);
} else {
UtilEllipse_F64.convert(algebraic.getEllipse(),outputStorage.shape);
}
// Improve the solution from algebraic into Euclidean
if( iterations > 0 ) {
RefineEllipseEuclideanLeastSquares_F64 leastSquares = new RefineEllipseEuclideanLeastSquares_F64();
leastSquares.setMaxIterations(iterations);
leastSquares.refine(outputStorage.shape,points);
outputStorage.shape.set( leastSquares.getFound() );
}
// compute the average Euclidean error if the user requests it
if( computeError ) {
ClosestPointEllipseAngle_F64 closestPoint = new ClosestPointEllipseAngle_F64(1e-8,100);
closestPoint.setEllipse(outputStorage.shape);
double total = 0;
for( Point2D_F64 p : points ) {
closestPoint.process(p);
total += p.distance(closestPoint.getClosest());
}
outputStorage.error = total/points.size();
} else {
outputStorage.error = 0;
}
return outputStorage;
} | [
"public",
"static",
"FitData",
"<",
"EllipseRotated_F64",
">",
"fitEllipse_F64",
"(",
"List",
"<",
"Point2D_F64",
">",
"points",
",",
"int",
"iterations",
",",
"boolean",
"computeError",
",",
"FitData",
"<",
"EllipseRotated_F64",
">",
"outputStorage",
")",
"{",
"if",
"(",
"outputStorage",
"==",
"null",
")",
"{",
"outputStorage",
"=",
"new",
"FitData",
"<>",
"(",
"new",
"EllipseRotated_F64",
"(",
")",
")",
";",
"}",
"// Compute the optimal algebraic error",
"FitEllipseAlgebraic_F64",
"algebraic",
"=",
"new",
"FitEllipseAlgebraic_F64",
"(",
")",
";",
"if",
"(",
"!",
"algebraic",
".",
"process",
"(",
"points",
")",
")",
"{",
"// could be a line or some other weird case. Create a crude estimate instead",
"FitData",
"<",
"Circle2D_F64",
">",
"circleData",
"=",
"averageCircle_F64",
"(",
"points",
",",
"null",
",",
"null",
")",
";",
"Circle2D_F64",
"circle",
"=",
"circleData",
".",
"shape",
";",
"outputStorage",
".",
"shape",
".",
"set",
"(",
"circle",
".",
"center",
".",
"x",
",",
"circle",
".",
"center",
".",
"y",
",",
"circle",
".",
"radius",
",",
"circle",
".",
"radius",
",",
"0",
")",
";",
"}",
"else",
"{",
"UtilEllipse_F64",
".",
"convert",
"(",
"algebraic",
".",
"getEllipse",
"(",
")",
",",
"outputStorage",
".",
"shape",
")",
";",
"}",
"// Improve the solution from algebraic into Euclidean",
"if",
"(",
"iterations",
">",
"0",
")",
"{",
"RefineEllipseEuclideanLeastSquares_F64",
"leastSquares",
"=",
"new",
"RefineEllipseEuclideanLeastSquares_F64",
"(",
")",
";",
"leastSquares",
".",
"setMaxIterations",
"(",
"iterations",
")",
";",
"leastSquares",
".",
"refine",
"(",
"outputStorage",
".",
"shape",
",",
"points",
")",
";",
"outputStorage",
".",
"shape",
".",
"set",
"(",
"leastSquares",
".",
"getFound",
"(",
")",
")",
";",
"}",
"// compute the average Euclidean error if the user requests it",
"if",
"(",
"computeError",
")",
"{",
"ClosestPointEllipseAngle_F64",
"closestPoint",
"=",
"new",
"ClosestPointEllipseAngle_F64",
"(",
"1e-8",
",",
"100",
")",
";",
"closestPoint",
".",
"setEllipse",
"(",
"outputStorage",
".",
"shape",
")",
";",
"double",
"total",
"=",
"0",
";",
"for",
"(",
"Point2D_F64",
"p",
":",
"points",
")",
"{",
"closestPoint",
".",
"process",
"(",
"p",
")",
";",
"total",
"+=",
"p",
".",
"distance",
"(",
"closestPoint",
".",
"getClosest",
"(",
")",
")",
";",
"}",
"outputStorage",
".",
"error",
"=",
"total",
"/",
"points",
".",
"size",
"(",
")",
";",
"}",
"else",
"{",
"outputStorage",
".",
"error",
"=",
"0",
";",
"}",
"return",
"outputStorage",
";",
"}"
] | Computes the best fit ellipse based on minimizing Euclidean distance. An estimate is initially provided
using algebraic algorithm which is then refined using non-linear optimization. The amount of non-linear
optimization can be controlled using 'iterations' parameter. Will work with partial and complete contours
of objects.
<p>NOTE: To improve speed, make calls directly to classes in Georegression. Look at the code for details.</p>
@param points (Input) Set of unordered points. Not modified.
@param iterations Number of iterations used to refine the fit. If set to zero then an algebraic solution
is returned.
@param computeError If true it will compute the average Euclidean distance error
@param outputStorage (Output/Optional) Storage for the ellipse. Can be null.
@return Found ellipse. | [
"Computes",
"the",
"best",
"fit",
"ellipse",
"based",
"on",
"minimizing",
"Euclidean",
"distance",
".",
"An",
"estimate",
"is",
"initially",
"provided",
"using",
"algebraic",
"algorithm",
"which",
"is",
"then",
"refined",
"using",
"non",
"-",
"linear",
"optimization",
".",
"The",
"amount",
"of",
"non",
"-",
"linear",
"optimization",
"can",
"be",
"controlled",
"using",
"iterations",
"parameter",
".",
"Will",
"work",
"with",
"partial",
"and",
"complete",
"contours",
"of",
"objects",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java#L104-L148 |
goldmansachs/gs-collections | collections/src/main/java/com/gs/collections/impl/utility/StringIterate.java | StringIterate.rejectCodePoint | public static String rejectCodePoint(String string, CodePointPredicate predicate) {
"""
@return a new string excluding all of the code points that return true for the specified {@code predicate}.
@since 7.0
"""
int size = string.length();
StringBuilder buffer = new StringBuilder(string.length());
for (int i = 0; i < size; )
{
int codePoint = string.codePointAt(i);
if (!predicate.accept(codePoint))
{
buffer.appendCodePoint(codePoint);
}
i += Character.charCount(codePoint);
}
return buffer.toString();
} | java | public static String rejectCodePoint(String string, CodePointPredicate predicate)
{
int size = string.length();
StringBuilder buffer = new StringBuilder(string.length());
for (int i = 0; i < size; )
{
int codePoint = string.codePointAt(i);
if (!predicate.accept(codePoint))
{
buffer.appendCodePoint(codePoint);
}
i += Character.charCount(codePoint);
}
return buffer.toString();
} | [
"public",
"static",
"String",
"rejectCodePoint",
"(",
"String",
"string",
",",
"CodePointPredicate",
"predicate",
")",
"{",
"int",
"size",
"=",
"string",
".",
"length",
"(",
")",
";",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
"string",
".",
"length",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
")",
"{",
"int",
"codePoint",
"=",
"string",
".",
"codePointAt",
"(",
"i",
")",
";",
"if",
"(",
"!",
"predicate",
".",
"accept",
"(",
"codePoint",
")",
")",
"{",
"buffer",
".",
"appendCodePoint",
"(",
"codePoint",
")",
";",
"}",
"i",
"+=",
"Character",
".",
"charCount",
"(",
"codePoint",
")",
";",
"}",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | @return a new string excluding all of the code points that return true for the specified {@code predicate}.
@since 7.0 | [
"@return",
"a",
"new",
"string",
"excluding",
"all",
"of",
"the",
"code",
"points",
"that",
"return",
"true",
"for",
"the",
"specified",
"{",
"@code",
"predicate",
"}",
"."
] | train | https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/StringIterate.java#L1075-L1089 |
querydsl/querydsl | querydsl-core/src/main/java/com/querydsl/core/types/dsl/PathBuilder.java | PathBuilder.get | @SuppressWarnings("unchecked")
public <A extends Number & Comparable<?>> NumberPath<A> get(NumberPath<A> path) {
"""
Create a new Number typed path
@param <A>
@param path existing path
@return property path
"""
NumberPath<A> newPath = getNumber(toString(path), (Class<A>) path.getType());
return addMetadataOf(newPath, path);
} | java | @SuppressWarnings("unchecked")
public <A extends Number & Comparable<?>> NumberPath<A> get(NumberPath<A> path) {
NumberPath<A> newPath = getNumber(toString(path), (Class<A>) path.getType());
return addMetadataOf(newPath, path);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"A",
"extends",
"Number",
"&",
"Comparable",
"<",
"?",
">",
">",
"NumberPath",
"<",
"A",
">",
"get",
"(",
"NumberPath",
"<",
"A",
">",
"path",
")",
"{",
"NumberPath",
"<",
"A",
">",
"newPath",
"=",
"getNumber",
"(",
"toString",
"(",
"path",
")",
",",
"(",
"Class",
"<",
"A",
">",
")",
"path",
".",
"getType",
"(",
")",
")",
";",
"return",
"addMetadataOf",
"(",
"newPath",
",",
"path",
")",
";",
"}"
] | Create a new Number typed path
@param <A>
@param path existing path
@return property path | [
"Create",
"a",
"new",
"Number",
"typed",
"path"
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/PathBuilder.java#L398-L402 |
Jasig/uPortal | uPortal-security/uPortal-security-permissions/src/main/java/org/apereo/portal/security/provider/AuthorizationImpl.java | AuthorizationImpl.getPrincipal | @Override
public IAuthorizationPrincipal getPrincipal(IPermission permission)
throws AuthorizationException {
"""
Returns <code>IAuthorizationPrincipal</code> associated with the <code>IPermission</code>.
@return IAuthorizationPrincipal
@param permission IPermission
"""
String principalString = permission.getPrincipal();
int idx = principalString.indexOf(PRINCIPAL_SEPARATOR);
Integer typeId = Integer.valueOf(principalString.substring(0, idx));
Class type = EntityTypesLocator.getEntityTypes().getEntityTypeFromID(typeId);
String key = principalString.substring(idx + 1);
return newPrincipal(key, type);
} | java | @Override
public IAuthorizationPrincipal getPrincipal(IPermission permission)
throws AuthorizationException {
String principalString = permission.getPrincipal();
int idx = principalString.indexOf(PRINCIPAL_SEPARATOR);
Integer typeId = Integer.valueOf(principalString.substring(0, idx));
Class type = EntityTypesLocator.getEntityTypes().getEntityTypeFromID(typeId);
String key = principalString.substring(idx + 1);
return newPrincipal(key, type);
} | [
"@",
"Override",
"public",
"IAuthorizationPrincipal",
"getPrincipal",
"(",
"IPermission",
"permission",
")",
"throws",
"AuthorizationException",
"{",
"String",
"principalString",
"=",
"permission",
".",
"getPrincipal",
"(",
")",
";",
"int",
"idx",
"=",
"principalString",
".",
"indexOf",
"(",
"PRINCIPAL_SEPARATOR",
")",
";",
"Integer",
"typeId",
"=",
"Integer",
".",
"valueOf",
"(",
"principalString",
".",
"substring",
"(",
"0",
",",
"idx",
")",
")",
";",
"Class",
"type",
"=",
"EntityTypesLocator",
".",
"getEntityTypes",
"(",
")",
".",
"getEntityTypeFromID",
"(",
"typeId",
")",
";",
"String",
"key",
"=",
"principalString",
".",
"substring",
"(",
"idx",
"+",
"1",
")",
";",
"return",
"newPrincipal",
"(",
"key",
",",
"type",
")",
";",
"}"
] | Returns <code>IAuthorizationPrincipal</code> associated with the <code>IPermission</code>.
@return IAuthorizationPrincipal
@param permission IPermission | [
"Returns",
"<code",
">",
"IAuthorizationPrincipal<",
"/",
"code",
">",
"associated",
"with",
"the",
"<code",
">",
"IPermission<",
"/",
"code",
">",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-security/uPortal-security-permissions/src/main/java/org/apereo/portal/security/provider/AuthorizationImpl.java#L817-L826 |
wcm-io/wcm-io-tooling | maven/plugins/json-dialog-conversion-plugin/src/main/java/io/wcm/maven/plugins/jsondlgcnv/DialogConverter.java | DialogConverter.addCommonAttrMappings | private void addCommonAttrMappings(JSONObject root, JSONObject node) throws JSONException {
"""
Adds property mappings on a replacement node for Granite common attributes.
@param root the root node
@param node the replacement node
@throws JSONException
"""
for (String property : GRANITE_COMMON_ATTR_PROPERTIES) {
String[] mapping = { "${./" + property + "}", "${\'./granite:" + property + "\'}" };
mapProperty(root, node, "granite:" + property, mapping);
}
if (root.has(NN_GRANITE_DATA)) {
// the root has granite:data defined, copy it before applying data-* properties
node.put(NN_GRANITE_DATA, root.get(NN_GRANITE_DATA));
}
// map data-* prefixed properties to granite:data child
for (Map.Entry<String, Object> entry : getProperties(root).entrySet()) {
if (!StringUtils.startsWith(entry.getKey(), DATA_PREFIX)) {
continue;
}
// add the granite:data child if necessary
JSONObject dataNode;
if (!node.has(NN_GRANITE_DATA)) {
dataNode = new JSONObject();
node.put(NN_GRANITE_DATA, dataNode);
}
else {
dataNode = node.getJSONObject(NN_GRANITE_DATA);
}
// set up the property mapping
String nameWithoutPrefix = entry.getKey().substring(DATA_PREFIX.length());
mapProperty(root, dataNode, nameWithoutPrefix, "${./" + entry.getKey() + "}");
}
} | java | private void addCommonAttrMappings(JSONObject root, JSONObject node) throws JSONException {
for (String property : GRANITE_COMMON_ATTR_PROPERTIES) {
String[] mapping = { "${./" + property + "}", "${\'./granite:" + property + "\'}" };
mapProperty(root, node, "granite:" + property, mapping);
}
if (root.has(NN_GRANITE_DATA)) {
// the root has granite:data defined, copy it before applying data-* properties
node.put(NN_GRANITE_DATA, root.get(NN_GRANITE_DATA));
}
// map data-* prefixed properties to granite:data child
for (Map.Entry<String, Object> entry : getProperties(root).entrySet()) {
if (!StringUtils.startsWith(entry.getKey(), DATA_PREFIX)) {
continue;
}
// add the granite:data child if necessary
JSONObject dataNode;
if (!node.has(NN_GRANITE_DATA)) {
dataNode = new JSONObject();
node.put(NN_GRANITE_DATA, dataNode);
}
else {
dataNode = node.getJSONObject(NN_GRANITE_DATA);
}
// set up the property mapping
String nameWithoutPrefix = entry.getKey().substring(DATA_PREFIX.length());
mapProperty(root, dataNode, nameWithoutPrefix, "${./" + entry.getKey() + "}");
}
} | [
"private",
"void",
"addCommonAttrMappings",
"(",
"JSONObject",
"root",
",",
"JSONObject",
"node",
")",
"throws",
"JSONException",
"{",
"for",
"(",
"String",
"property",
":",
"GRANITE_COMMON_ATTR_PROPERTIES",
")",
"{",
"String",
"[",
"]",
"mapping",
"=",
"{",
"\"${./\"",
"+",
"property",
"+",
"\"}\"",
",",
"\"${\\'./granite:\"",
"+",
"property",
"+",
"\"\\'}\"",
"}",
";",
"mapProperty",
"(",
"root",
",",
"node",
",",
"\"granite:\"",
"+",
"property",
",",
"mapping",
")",
";",
"}",
"if",
"(",
"root",
".",
"has",
"(",
"NN_GRANITE_DATA",
")",
")",
"{",
"// the root has granite:data defined, copy it before applying data-* properties",
"node",
".",
"put",
"(",
"NN_GRANITE_DATA",
",",
"root",
".",
"get",
"(",
"NN_GRANITE_DATA",
")",
")",
";",
"}",
"// map data-* prefixed properties to granite:data child",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"getProperties",
"(",
"root",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"StringUtils",
".",
"startsWith",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"DATA_PREFIX",
")",
")",
"{",
"continue",
";",
"}",
"// add the granite:data child if necessary",
"JSONObject",
"dataNode",
";",
"if",
"(",
"!",
"node",
".",
"has",
"(",
"NN_GRANITE_DATA",
")",
")",
"{",
"dataNode",
"=",
"new",
"JSONObject",
"(",
")",
";",
"node",
".",
"put",
"(",
"NN_GRANITE_DATA",
",",
"dataNode",
")",
";",
"}",
"else",
"{",
"dataNode",
"=",
"node",
".",
"getJSONObject",
"(",
"NN_GRANITE_DATA",
")",
";",
"}",
"// set up the property mapping",
"String",
"nameWithoutPrefix",
"=",
"entry",
".",
"getKey",
"(",
")",
".",
"substring",
"(",
"DATA_PREFIX",
".",
"length",
"(",
")",
")",
";",
"mapProperty",
"(",
"root",
",",
"dataNode",
",",
"nameWithoutPrefix",
",",
"\"${./\"",
"+",
"entry",
".",
"getKey",
"(",
")",
"+",
"\"}\"",
")",
";",
"}",
"}"
] | Adds property mappings on a replacement node for Granite common attributes.
@param root the root node
@param node the replacement node
@throws JSONException | [
"Adds",
"property",
"mappings",
"on",
"a",
"replacement",
"node",
"for",
"Granite",
"common",
"attributes",
"."
] | train | https://github.com/wcm-io/wcm-io-tooling/blob/1abcd01dd3ad4cc248f03b431f929573d84fa9b4/maven/plugins/json-dialog-conversion-plugin/src/main/java/io/wcm/maven/plugins/jsondlgcnv/DialogConverter.java#L370-L401 |
OpenNTF/JavascriptAggregator | jaggr-core/src/main/java/com/ibm/jaggr/core/impl/modulebuilder/less/LessModuleBuilder.java | LessModuleBuilder._inlineImports | protected String _inlineImports(HttpServletRequest req, String css, IResource res, String path) throws IOException {
"""
Called by our <code>postcss</code> method to inline imports not processed by the LESS compiler
(i.e. CSS imports) <b>after</b> the LESS compiler has processed the input.
@param req
The request associated with the call.
@param css
The current CSS containing @import statements to be
processed
@param res
The resource for the CSS file.
@param path
The path, as specified in the @import statement used to
import the current CSS, or null if this is the top level CSS.
@return The input CSS with @import statements replaced with the
contents of the imported files.
@throws IOException
"""
return super.inlineImports(req, css, res, path);
} | java | protected String _inlineImports(HttpServletRequest req, String css, IResource res, String path) throws IOException {
return super.inlineImports(req, css, res, path);
} | [
"protected",
"String",
"_inlineImports",
"(",
"HttpServletRequest",
"req",
",",
"String",
"css",
",",
"IResource",
"res",
",",
"String",
"path",
")",
"throws",
"IOException",
"{",
"return",
"super",
".",
"inlineImports",
"(",
"req",
",",
"css",
",",
"res",
",",
"path",
")",
";",
"}"
] | Called by our <code>postcss</code> method to inline imports not processed by the LESS compiler
(i.e. CSS imports) <b>after</b> the LESS compiler has processed the input.
@param req
The request associated with the call.
@param css
The current CSS containing @import statements to be
processed
@param res
The resource for the CSS file.
@param path
The path, as specified in the @import statement used to
import the current CSS, or null if this is the top level CSS.
@return The input CSS with @import statements replaced with the
contents of the imported files.
@throws IOException | [
"Called",
"by",
"our",
"<code",
">",
"postcss<",
"/",
"code",
">",
"method",
"to",
"inline",
"imports",
"not",
"processed",
"by",
"the",
"LESS",
"compiler",
"(",
"i",
".",
"e",
".",
"CSS",
"imports",
")",
"<b",
">",
"after<",
"/",
"b",
">",
"the",
"LESS",
"compiler",
"has",
"processed",
"the",
"input",
"."
] | train | https://github.com/OpenNTF/JavascriptAggregator/blob/9f47a96d778251638b1df9a368462176216d5b29/jaggr-core/src/main/java/com/ibm/jaggr/core/impl/modulebuilder/less/LessModuleBuilder.java#L233-L235 |
cloudant/java-cloudant | cloudant-client/src/main/java/com/cloudant/client/api/Database.java | Database.findByIndex | @Deprecated
public <T> List<T> findByIndex(String selectorJson, Class<T> classOfT) {
"""
Find documents using an index
@param selectorJson String representation of a JSON object describing criteria used to
select documents. For example:
{@code "{ \"selector\": {<your data here>} }"}.
@param classOfT The class of Java objects to be returned
@param <T> the type of the Java object to be returned
@return List of classOfT objects
@see #findByIndex(String, Class, FindByIndexOptions)
@see <a
href="https://console.bluemix.net/docs/services/Cloudant/api/cloudant_query.html#selector-syntax"
target="_blank">selector syntax</a>
@deprecated Use {@link #query(String, Class)} instead
"""
return findByIndex(selectorJson, classOfT, new FindByIndexOptions());
} | java | @Deprecated
public <T> List<T> findByIndex(String selectorJson, Class<T> classOfT) {
return findByIndex(selectorJson, classOfT, new FindByIndexOptions());
} | [
"@",
"Deprecated",
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"findByIndex",
"(",
"String",
"selectorJson",
",",
"Class",
"<",
"T",
">",
"classOfT",
")",
"{",
"return",
"findByIndex",
"(",
"selectorJson",
",",
"classOfT",
",",
"new",
"FindByIndexOptions",
"(",
")",
")",
";",
"}"
] | Find documents using an index
@param selectorJson String representation of a JSON object describing criteria used to
select documents. For example:
{@code "{ \"selector\": {<your data here>} }"}.
@param classOfT The class of Java objects to be returned
@param <T> the type of the Java object to be returned
@return List of classOfT objects
@see #findByIndex(String, Class, FindByIndexOptions)
@see <a
href="https://console.bluemix.net/docs/services/Cloudant/api/cloudant_query.html#selector-syntax"
target="_blank">selector syntax</a>
@deprecated Use {@link #query(String, Class)} instead | [
"Find",
"documents",
"using",
"an",
"index"
] | train | https://github.com/cloudant/java-cloudant/blob/42c438654945361bded2cc0827afc046d535b31b/cloudant-client/src/main/java/com/cloudant/client/api/Database.java#L419-L422 |
aws/aws-sdk-java | aws-java-sdk-costexplorer/src/main/java/com/amazonaws/services/costexplorer/model/ReservationUtilizationGroup.java | ReservationUtilizationGroup.withAttributes | public ReservationUtilizationGroup withAttributes(java.util.Map<String, String> attributes) {
"""
<p>
The attributes for this group of reservations.
</p>
@param attributes
The attributes for this group of reservations.
@return Returns a reference to this object so that method calls can be chained together.
"""
setAttributes(attributes);
return this;
} | java | public ReservationUtilizationGroup withAttributes(java.util.Map<String, String> attributes) {
setAttributes(attributes);
return this;
} | [
"public",
"ReservationUtilizationGroup",
"withAttributes",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
")",
"{",
"setAttributes",
"(",
"attributes",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The attributes for this group of reservations.
</p>
@param attributes
The attributes for this group of reservations.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"attributes",
"for",
"this",
"group",
"of",
"reservations",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-costexplorer/src/main/java/com/amazonaws/services/costexplorer/model/ReservationUtilizationGroup.java#L171-L174 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_GeomFromText.java | ST_GeomFromText.toGeometry | public static Geometry toGeometry(String wkt, int srid) throws SQLException {
"""
Convert well known text parameter into a Geometry
@param wkt Well known text
@param srid Geometry SRID
@return Geometry instance
@throws SQLException If wkt is invalid
"""
if(wkt == null) {
return null;
}
try {
WKTReader wktReaderSRID = new WKTReader(new GeometryFactory(new PrecisionModel(),srid));
return wktReaderSRID.read(wkt);
} catch (ParseException ex) {
throw new SQLException(ex);
}
} | java | public static Geometry toGeometry(String wkt, int srid) throws SQLException {
if(wkt == null) {
return null;
}
try {
WKTReader wktReaderSRID = new WKTReader(new GeometryFactory(new PrecisionModel(),srid));
return wktReaderSRID.read(wkt);
} catch (ParseException ex) {
throw new SQLException(ex);
}
} | [
"public",
"static",
"Geometry",
"toGeometry",
"(",
"String",
"wkt",
",",
"int",
"srid",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"wkt",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"WKTReader",
"wktReaderSRID",
"=",
"new",
"WKTReader",
"(",
"new",
"GeometryFactory",
"(",
"new",
"PrecisionModel",
"(",
")",
",",
"srid",
")",
")",
";",
"return",
"wktReaderSRID",
".",
"read",
"(",
"wkt",
")",
";",
"}",
"catch",
"(",
"ParseException",
"ex",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"ex",
")",
";",
"}",
"}"
] | Convert well known text parameter into a Geometry
@param wkt Well known text
@param srid Geometry SRID
@return Geometry instance
@throws SQLException If wkt is invalid | [
"Convert",
"well",
"known",
"text",
"parameter",
"into",
"a",
"Geometry"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/convert/ST_GeomFromText.java#L76-L86 |
threerings/nenya | core/src/main/java/com/threerings/miso/util/MisoUtil.java | MisoUtil.getProjectedIsoDirection | public static int getProjectedIsoDirection (int ax, int ay, int bx, int by) {
"""
Given two points in screen coordinates, return the isometrically
projected compass direction that point B lies in from point A.
@param ax the x-position of point A.
@param ay the y-position of point A.
@param bx the x-position of point B.
@param by the y-position of point B.
@return the direction specified as one of the <code>Sprite</code>
class's direction constants, or <code>DirectionCodes.NONE</code> if
point B is equivalent to point A.
"""
return toIsoDirection(DirectionUtil.getDirection(ax, ay, bx, by));
} | java | public static int getProjectedIsoDirection (int ax, int ay, int bx, int by)
{
return toIsoDirection(DirectionUtil.getDirection(ax, ay, bx, by));
} | [
"public",
"static",
"int",
"getProjectedIsoDirection",
"(",
"int",
"ax",
",",
"int",
"ay",
",",
"int",
"bx",
",",
"int",
"by",
")",
"{",
"return",
"toIsoDirection",
"(",
"DirectionUtil",
".",
"getDirection",
"(",
"ax",
",",
"ay",
",",
"bx",
",",
"by",
")",
")",
";",
"}"
] | Given two points in screen coordinates, return the isometrically
projected compass direction that point B lies in from point A.
@param ax the x-position of point A.
@param ay the y-position of point A.
@param bx the x-position of point B.
@param by the y-position of point B.
@return the direction specified as one of the <code>Sprite</code>
class's direction constants, or <code>DirectionCodes.NONE</code> if
point B is equivalent to point A. | [
"Given",
"two",
"points",
"in",
"screen",
"coordinates",
"return",
"the",
"isometrically",
"projected",
"compass",
"direction",
"that",
"point",
"B",
"lies",
"in",
"from",
"point",
"A",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/util/MisoUtil.java#L149-L152 |
apache/flink | flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java | SqlDateTimeUtils.timestampCeil | public static long timestampCeil(TimeUnitRange range, long ts, TimeZone tz) {
"""
Keep the algorithm consistent with Calcite DateTimeUtils.julianDateFloor, but here
we take time zone into account.
"""
// assume that we are at UTC timezone, just for algorithm performance
long offset = tz.getOffset(ts);
long utcTs = ts + offset;
switch (range) {
case HOUR:
return ceil(utcTs, MILLIS_PER_HOUR) - offset;
case DAY:
return ceil(utcTs, MILLIS_PER_DAY) - offset;
case MONTH:
case YEAR:
case QUARTER:
int days = (int) (utcTs / MILLIS_PER_DAY + EPOCH_JULIAN);
return julianDateFloor(range, days, false) * MILLIS_PER_DAY - offset;
default:
// for MINUTE and SECONDS etc...,
// it is more effective to use arithmetic Method
throw new AssertionError(range);
}
} | java | public static long timestampCeil(TimeUnitRange range, long ts, TimeZone tz) {
// assume that we are at UTC timezone, just for algorithm performance
long offset = tz.getOffset(ts);
long utcTs = ts + offset;
switch (range) {
case HOUR:
return ceil(utcTs, MILLIS_PER_HOUR) - offset;
case DAY:
return ceil(utcTs, MILLIS_PER_DAY) - offset;
case MONTH:
case YEAR:
case QUARTER:
int days = (int) (utcTs / MILLIS_PER_DAY + EPOCH_JULIAN);
return julianDateFloor(range, days, false) * MILLIS_PER_DAY - offset;
default:
// for MINUTE and SECONDS etc...,
// it is more effective to use arithmetic Method
throw new AssertionError(range);
}
} | [
"public",
"static",
"long",
"timestampCeil",
"(",
"TimeUnitRange",
"range",
",",
"long",
"ts",
",",
"TimeZone",
"tz",
")",
"{",
"// assume that we are at UTC timezone, just for algorithm performance",
"long",
"offset",
"=",
"tz",
".",
"getOffset",
"(",
"ts",
")",
";",
"long",
"utcTs",
"=",
"ts",
"+",
"offset",
";",
"switch",
"(",
"range",
")",
"{",
"case",
"HOUR",
":",
"return",
"ceil",
"(",
"utcTs",
",",
"MILLIS_PER_HOUR",
")",
"-",
"offset",
";",
"case",
"DAY",
":",
"return",
"ceil",
"(",
"utcTs",
",",
"MILLIS_PER_DAY",
")",
"-",
"offset",
";",
"case",
"MONTH",
":",
"case",
"YEAR",
":",
"case",
"QUARTER",
":",
"int",
"days",
"=",
"(",
"int",
")",
"(",
"utcTs",
"/",
"MILLIS_PER_DAY",
"+",
"EPOCH_JULIAN",
")",
";",
"return",
"julianDateFloor",
"(",
"range",
",",
"days",
",",
"false",
")",
"*",
"MILLIS_PER_DAY",
"-",
"offset",
";",
"default",
":",
"// for MINUTE and SECONDS etc...,",
"// it is more effective to use arithmetic Method",
"throw",
"new",
"AssertionError",
"(",
"range",
")",
";",
"}",
"}"
] | Keep the algorithm consistent with Calcite DateTimeUtils.julianDateFloor, but here
we take time zone into account. | [
"Keep",
"the",
"algorithm",
"consistent",
"with",
"Calcite",
"DateTimeUtils",
".",
"julianDateFloor",
"but",
"here",
"we",
"take",
"time",
"zone",
"into",
"account",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlDateTimeUtils.java#L627-L647 |
tvesalainen/lpg | src/main/java/org/vesalainen/parser/util/Input.java | Input.getInput | protected static InputReader getInput(InputSource input, int size, Charset cs, Set<ParserFeature> fea) throws IOException {
"""
Creates an InputReader
@param input
@param size Ringbuffer size
@return
@throws IOException
"""
EnumSet<ParserFeature> features = EnumSet.of(UseInclude, UsePushback, UseModifiableCharset);
InputReader inputReader = null;
Reader reader = input.getCharacterStream();
if (reader != null)
{
inputReader = new ReadableInput(getFeaturedReader(reader, size, features), size, features);
}
else
{
InputStream is = input.getByteStream();
String encoding = input.getEncoding();
if (is != null)
{
if (encoding != null)
{
inputReader = getInstance(is, size, encoding, features);
}
else
{
inputReader = getInstance(is, size, StandardCharsets.US_ASCII, features);
}
}
else
{
String sysId = input.getSystemId();
try
{
URI uri = new URI(sysId);
if (encoding != null)
{
inputReader = getInstance(uri, size, encoding, features);
}
else
{
inputReader = getInstance(uri, size, StandardCharsets.US_ASCII, features);
}
}
catch (URISyntaxException ex)
{
throw new IOException(ex);
}
}
}
inputReader.setSource(input.getSystemId());
return inputReader;
} | java | protected static InputReader getInput(InputSource input, int size, Charset cs, Set<ParserFeature> fea) throws IOException
{
EnumSet<ParserFeature> features = EnumSet.of(UseInclude, UsePushback, UseModifiableCharset);
InputReader inputReader = null;
Reader reader = input.getCharacterStream();
if (reader != null)
{
inputReader = new ReadableInput(getFeaturedReader(reader, size, features), size, features);
}
else
{
InputStream is = input.getByteStream();
String encoding = input.getEncoding();
if (is != null)
{
if (encoding != null)
{
inputReader = getInstance(is, size, encoding, features);
}
else
{
inputReader = getInstance(is, size, StandardCharsets.US_ASCII, features);
}
}
else
{
String sysId = input.getSystemId();
try
{
URI uri = new URI(sysId);
if (encoding != null)
{
inputReader = getInstance(uri, size, encoding, features);
}
else
{
inputReader = getInstance(uri, size, StandardCharsets.US_ASCII, features);
}
}
catch (URISyntaxException ex)
{
throw new IOException(ex);
}
}
}
inputReader.setSource(input.getSystemId());
return inputReader;
} | [
"protected",
"static",
"InputReader",
"getInput",
"(",
"InputSource",
"input",
",",
"int",
"size",
",",
"Charset",
"cs",
",",
"Set",
"<",
"ParserFeature",
">",
"fea",
")",
"throws",
"IOException",
"{",
"EnumSet",
"<",
"ParserFeature",
">",
"features",
"=",
"EnumSet",
".",
"of",
"(",
"UseInclude",
",",
"UsePushback",
",",
"UseModifiableCharset",
")",
";",
"InputReader",
"inputReader",
"=",
"null",
";",
"Reader",
"reader",
"=",
"input",
".",
"getCharacterStream",
"(",
")",
";",
"if",
"(",
"reader",
"!=",
"null",
")",
"{",
"inputReader",
"=",
"new",
"ReadableInput",
"(",
"getFeaturedReader",
"(",
"reader",
",",
"size",
",",
"features",
")",
",",
"size",
",",
"features",
")",
";",
"}",
"else",
"{",
"InputStream",
"is",
"=",
"input",
".",
"getByteStream",
"(",
")",
";",
"String",
"encoding",
"=",
"input",
".",
"getEncoding",
"(",
")",
";",
"if",
"(",
"is",
"!=",
"null",
")",
"{",
"if",
"(",
"encoding",
"!=",
"null",
")",
"{",
"inputReader",
"=",
"getInstance",
"(",
"is",
",",
"size",
",",
"encoding",
",",
"features",
")",
";",
"}",
"else",
"{",
"inputReader",
"=",
"getInstance",
"(",
"is",
",",
"size",
",",
"StandardCharsets",
".",
"US_ASCII",
",",
"features",
")",
";",
"}",
"}",
"else",
"{",
"String",
"sysId",
"=",
"input",
".",
"getSystemId",
"(",
")",
";",
"try",
"{",
"URI",
"uri",
"=",
"new",
"URI",
"(",
"sysId",
")",
";",
"if",
"(",
"encoding",
"!=",
"null",
")",
"{",
"inputReader",
"=",
"getInstance",
"(",
"uri",
",",
"size",
",",
"encoding",
",",
"features",
")",
";",
"}",
"else",
"{",
"inputReader",
"=",
"getInstance",
"(",
"uri",
",",
"size",
",",
"StandardCharsets",
".",
"US_ASCII",
",",
"features",
")",
";",
"}",
"}",
"catch",
"(",
"URISyntaxException",
"ex",
")",
"{",
"throw",
"new",
"IOException",
"(",
"ex",
")",
";",
"}",
"}",
"}",
"inputReader",
".",
"setSource",
"(",
"input",
".",
"getSystemId",
"(",
")",
")",
";",
"return",
"inputReader",
";",
"}"
] | Creates an InputReader
@param input
@param size Ringbuffer size
@return
@throws IOException | [
"Creates",
"an",
"InputReader"
] | train | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/parser/util/Input.java#L448-L495 |
segmentio/analytics-android | analytics/src/main/java/com/segment/analytics/QueueFile.java | QueueFile.writeHeader | private void writeHeader(int fileLength, int elementCount, int firstPosition, int lastPosition)
throws IOException {
"""
Writes header atomically. The arguments contain the updated values. The class member fields
should not have changed yet. This only updates the state in the file. It's up to the caller to
update the class member variables *after* this call succeeds. Assumes segment writes are atomic
in the underlying file system.
"""
writeInt(buffer, 0, fileLength);
writeInt(buffer, 4, elementCount);
writeInt(buffer, 8, firstPosition);
writeInt(buffer, 12, lastPosition);
raf.seek(0);
raf.write(buffer);
} | java | private void writeHeader(int fileLength, int elementCount, int firstPosition, int lastPosition)
throws IOException {
writeInt(buffer, 0, fileLength);
writeInt(buffer, 4, elementCount);
writeInt(buffer, 8, firstPosition);
writeInt(buffer, 12, lastPosition);
raf.seek(0);
raf.write(buffer);
} | [
"private",
"void",
"writeHeader",
"(",
"int",
"fileLength",
",",
"int",
"elementCount",
",",
"int",
"firstPosition",
",",
"int",
"lastPosition",
")",
"throws",
"IOException",
"{",
"writeInt",
"(",
"buffer",
",",
"0",
",",
"fileLength",
")",
";",
"writeInt",
"(",
"buffer",
",",
"4",
",",
"elementCount",
")",
";",
"writeInt",
"(",
"buffer",
",",
"8",
",",
"firstPosition",
")",
";",
"writeInt",
"(",
"buffer",
",",
"12",
",",
"lastPosition",
")",
";",
"raf",
".",
"seek",
"(",
"0",
")",
";",
"raf",
".",
"write",
"(",
"buffer",
")",
";",
"}"
] | Writes header atomically. The arguments contain the updated values. The class member fields
should not have changed yet. This only updates the state in the file. It's up to the caller to
update the class member variables *after* this call succeeds. Assumes segment writes are atomic
in the underlying file system. | [
"Writes",
"header",
"atomically",
".",
"The",
"arguments",
"contain",
"the",
"updated",
"values",
".",
"The",
"class",
"member",
"fields",
"should",
"not",
"have",
"changed",
"yet",
".",
"This",
"only",
"updates",
"the",
"state",
"in",
"the",
"file",
".",
"It",
"s",
"up",
"to",
"the",
"caller",
"to",
"update",
"the",
"class",
"member",
"variables",
"*",
"after",
"*",
"this",
"call",
"succeeds",
".",
"Assumes",
"segment",
"writes",
"are",
"atomic",
"in",
"the",
"underlying",
"file",
"system",
"."
] | train | https://github.com/segmentio/analytics-android/blob/93c7d5bb09b593440a2347a6089db3e9f74012da/analytics/src/main/java/com/segment/analytics/QueueFile.java#L177-L185 |
geomajas/geomajas-project-client-gwt | common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java | HtmlBuilder.divClass | public static String divClass(String clazz, String... content) {
"""
Build a HTML DIV with given CSS class for a string.
Given content does <b>not</b> consists of HTML snippets and
as such is being prepared with {@link HtmlBuilder#htmlEncode(String)}.
@param clazz class for div element
@param content content string
@return HTML DIV element as string
"""
return tagClass(Html.Tag.DIV, clazz, content);
} | java | public static String divClass(String clazz, String... content) {
return tagClass(Html.Tag.DIV, clazz, content);
} | [
"public",
"static",
"String",
"divClass",
"(",
"String",
"clazz",
",",
"String",
"...",
"content",
")",
"{",
"return",
"tagClass",
"(",
"Html",
".",
"Tag",
".",
"DIV",
",",
"clazz",
",",
"content",
")",
";",
"}"
] | Build a HTML DIV with given CSS class for a string.
Given content does <b>not</b> consists of HTML snippets and
as such is being prepared with {@link HtmlBuilder#htmlEncode(String)}.
@param clazz class for div element
@param content content string
@return HTML DIV element as string | [
"Build",
"a",
"HTML",
"DIV",
"with",
"given",
"CSS",
"class",
"for",
"a",
"string",
".",
"Given",
"content",
"does",
"<b",
">",
"not<",
"/",
"b",
">",
"consists",
"of",
"HTML",
"snippets",
"and",
"as",
"such",
"is",
"being",
"prepared",
"with",
"{",
"@link",
"HtmlBuilder#htmlEncode",
"(",
"String",
")",
"}",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/util/HtmlBuilder.java#L251-L253 |
QSFT/Doradus | doradus-server/src/main/java/com/dell/doradus/search/util/HeapList.java | HeapList.AddEx | public T AddEx(T value) {
"""
/ If no object was thrown (heap was not yes populated) return null
"""
if (m_Count < m_Capacity) {
m_Array[++m_Count] = value;
UpHeap();
return null;
}
else if (m_Capacity == 0) return value;
else if (greaterThan(m_Array[1], value)) {
T retVal = m_Array[1];
m_Array[1] = value;
DownHeap();
return retVal;
}
else return value;
} | java | public T AddEx(T value) {
if (m_Count < m_Capacity) {
m_Array[++m_Count] = value;
UpHeap();
return null;
}
else if (m_Capacity == 0) return value;
else if (greaterThan(m_Array[1], value)) {
T retVal = m_Array[1];
m_Array[1] = value;
DownHeap();
return retVal;
}
else return value;
} | [
"public",
"T",
"AddEx",
"(",
"T",
"value",
")",
"{",
"if",
"(",
"m_Count",
"<",
"m_Capacity",
")",
"{",
"m_Array",
"[",
"++",
"m_Count",
"]",
"=",
"value",
";",
"UpHeap",
"(",
")",
";",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"m_Capacity",
"==",
"0",
")",
"return",
"value",
";",
"else",
"if",
"(",
"greaterThan",
"(",
"m_Array",
"[",
"1",
"]",
",",
"value",
")",
")",
"{",
"T",
"retVal",
"=",
"m_Array",
"[",
"1",
"]",
";",
"m_Array",
"[",
"1",
"]",
"=",
"value",
";",
"DownHeap",
"(",
")",
";",
"return",
"retVal",
";",
"}",
"else",
"return",
"value",
";",
"}"
] | / If no object was thrown (heap was not yes populated) return null | [
"/",
"If",
"no",
"object",
"was",
"thrown",
"(",
"heap",
"was",
"not",
"yes",
"populated",
")",
"return",
"null"
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/util/HeapList.java#L95-L109 |
vanilladb/vanillacore | src/main/java/org/vanilladb/core/query/planner/opt/TablePlanner.java | TablePlanner.makeProductPlan | public Plan makeProductPlan(Plan trunk) {
"""
Constructs a product plan of the specified trunk and this table.
<p>
The select predicate applicable to this table is pushed down below the
product.
</p>
@param trunk
the specified trunk of join
@return a product plan of the trunk and this table
"""
Plan p = makeSelectPlan();
return new MultiBufferProductPlan(trunk, p, tx);
} | java | public Plan makeProductPlan(Plan trunk) {
Plan p = makeSelectPlan();
return new MultiBufferProductPlan(trunk, p, tx);
} | [
"public",
"Plan",
"makeProductPlan",
"(",
"Plan",
"trunk",
")",
"{",
"Plan",
"p",
"=",
"makeSelectPlan",
"(",
")",
";",
"return",
"new",
"MultiBufferProductPlan",
"(",
"trunk",
",",
"p",
",",
"tx",
")",
";",
"}"
] | Constructs a product plan of the specified trunk and this table.
<p>
The select predicate applicable to this table is pushed down below the
product.
</p>
@param trunk
the specified trunk of join
@return a product plan of the trunk and this table | [
"Constructs",
"a",
"product",
"plan",
"of",
"the",
"specified",
"trunk",
"and",
"this",
"table",
"."
] | train | https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/planner/opt/TablePlanner.java#L138-L141 |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDUserDaoImpl.java | GeneratedDUserDaoImpl.queryByUpdatedBy | public Iterable<DUser> queryByUpdatedBy(java.lang.String updatedBy) {
"""
query-by method for field updatedBy
@param updatedBy the specified attribute
@return an Iterable of DUsers for the specified updatedBy
"""
return queryByField(null, DUserMapper.Field.UPDATEDBY.getFieldName(), updatedBy);
} | java | public Iterable<DUser> queryByUpdatedBy(java.lang.String updatedBy) {
return queryByField(null, DUserMapper.Field.UPDATEDBY.getFieldName(), updatedBy);
} | [
"public",
"Iterable",
"<",
"DUser",
">",
"queryByUpdatedBy",
"(",
"java",
".",
"lang",
".",
"String",
"updatedBy",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"DUserMapper",
".",
"Field",
".",
"UPDATEDBY",
".",
"getFieldName",
"(",
")",
",",
"updatedBy",
")",
";",
"}"
] | query-by method for field updatedBy
@param updatedBy the specified attribute
@return an Iterable of DUsers for the specified updatedBy | [
"query",
"-",
"by",
"method",
"for",
"field",
"updatedBy"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDUserDaoImpl.java#L259-L261 |
ngageoint/geopackage-java | src/main/java/mil/nga/geopackage/tiles/user/TileDao.java | TileDao.queryForTilesInRow | public TileResultSet queryForTilesInRow(long row, long zoomLevel) {
"""
Query for Tiles at a zoom level and row
@param row
row
@param zoomLevel
zoom level
@return tile result set
"""
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put(TileTable.COLUMN_TILE_ROW, row);
fieldValues.put(TileTable.COLUMN_ZOOM_LEVEL, zoomLevel);
return queryForFieldValues(fieldValues);
} | java | public TileResultSet queryForTilesInRow(long row, long zoomLevel) {
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put(TileTable.COLUMN_TILE_ROW, row);
fieldValues.put(TileTable.COLUMN_ZOOM_LEVEL, zoomLevel);
return queryForFieldValues(fieldValues);
} | [
"public",
"TileResultSet",
"queryForTilesInRow",
"(",
"long",
"row",
",",
"long",
"zoomLevel",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"fieldValues",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"fieldValues",
".",
"put",
"(",
"TileTable",
".",
"COLUMN_TILE_ROW",
",",
"row",
")",
";",
"fieldValues",
".",
"put",
"(",
"TileTable",
".",
"COLUMN_ZOOM_LEVEL",
",",
"zoomLevel",
")",
";",
"return",
"queryForFieldValues",
"(",
"fieldValues",
")",
";",
"}"
] | Query for Tiles at a zoom level and row
@param row
row
@param zoomLevel
zoom level
@return tile result set | [
"Query",
"for",
"Tiles",
"at",
"a",
"zoom",
"level",
"and",
"row"
] | train | https://github.com/ngageoint/geopackage-java/blob/889bffb5d18330a3f4bd89443acf7959ebe3a376/src/main/java/mil/nga/geopackage/tiles/user/TileDao.java#L342-L349 |
infinispan/infinispan | hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/access/InvalidationCacheAccessDelegate.java | InvalidationCacheAccessDelegate.get | @Override
@SuppressWarnings("UnusedParameters")
public Object get(Object session, Object key, long txTimestamp) throws CacheException {
"""
Attempt to retrieve an object from the cache.
@param session
@param key The key of the item to be retrieved
@param txTimestamp a timestamp prior to the transaction start time
@return the cached object or <tt>null</tt>
@throws CacheException if the cache retrieval failed
"""
if ( !region.checkValid() ) {
return null;
}
final Object val = cache.get( key );
if (val == null && session != null) {
putValidator.registerPendingPut(session, key, txTimestamp );
}
return val;
} | java | @Override
@SuppressWarnings("UnusedParameters")
public Object get(Object session, Object key, long txTimestamp) throws CacheException {
if ( !region.checkValid() ) {
return null;
}
final Object val = cache.get( key );
if (val == null && session != null) {
putValidator.registerPendingPut(session, key, txTimestamp );
}
return val;
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"UnusedParameters\"",
")",
"public",
"Object",
"get",
"(",
"Object",
"session",
",",
"Object",
"key",
",",
"long",
"txTimestamp",
")",
"throws",
"CacheException",
"{",
"if",
"(",
"!",
"region",
".",
"checkValid",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
"Object",
"val",
"=",
"cache",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"val",
"==",
"null",
"&&",
"session",
"!=",
"null",
")",
"{",
"putValidator",
".",
"registerPendingPut",
"(",
"session",
",",
"key",
",",
"txTimestamp",
")",
";",
"}",
"return",
"val",
";",
"}"
] | Attempt to retrieve an object from the cache.
@param session
@param key The key of the item to be retrieved
@param txTimestamp a timestamp prior to the transaction start time
@return the cached object or <tt>null</tt>
@throws CacheException if the cache retrieval failed | [
"Attempt",
"to",
"retrieve",
"an",
"object",
"from",
"the",
"cache",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/hibernate/cache-commons/src/main/java/org/infinispan/hibernate/cache/commons/access/InvalidationCacheAccessDelegate.java#L54-L65 |
micronaut-projects/micronaut-core | cli/src/main/groovy/io/micronaut/cli/console/logging/MicronautConsole.java | MicronautConsole.showPrompt | private String showPrompt(String prompt) {
"""
Shows the prompt to request user input.
@param prompt The prompt to use
@return The user input prompt
"""
verifySystemOut();
cursorMove = 0;
if (!userInputActive) {
return readLine(prompt, false);
}
out.print(prompt);
out.flush();
return null;
} | java | private String showPrompt(String prompt) {
verifySystemOut();
cursorMove = 0;
if (!userInputActive) {
return readLine(prompt, false);
}
out.print(prompt);
out.flush();
return null;
} | [
"private",
"String",
"showPrompt",
"(",
"String",
"prompt",
")",
"{",
"verifySystemOut",
"(",
")",
";",
"cursorMove",
"=",
"0",
";",
"if",
"(",
"!",
"userInputActive",
")",
"{",
"return",
"readLine",
"(",
"prompt",
",",
"false",
")",
";",
"}",
"out",
".",
"print",
"(",
"prompt",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"return",
"null",
";",
"}"
] | Shows the prompt to request user input.
@param prompt The prompt to use
@return The user input prompt | [
"Shows",
"the",
"prompt",
"to",
"request",
"user",
"input",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/cli/src/main/groovy/io/micronaut/cli/console/logging/MicronautConsole.java#L994-L1004 |
sebastiangraf/treetank | interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/RestXPathProcessor.java | RestXPathProcessor.doXPathRes | private void doXPathRes(final String resource, final Long revision, final OutputStream output,
final boolean nodeid, final String xpath) throws TTException {
"""
This method performs an XPath evaluation and writes it to a given output
stream.
@param resource
The existing resource.
@param revision
The revision of the requested document.
@param output
The output stream where the results are written.
@param nodeid
<code>true</code> if node id's have to be delivered. <code>false</code> otherwise.
@param xpath
The XPath expression.
@throws TTException
"""
// Storage connection to treetank
ISession session = null;
INodeReadTrx rtx = null;
try {
if (mDatabase.existsResource(resource)) {
session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY));
// Creating a transaction
if (revision == null) {
rtx = new NodeReadTrx(session.beginBucketRtx(session.getMostRecentVersion()));
} else {
rtx = new NodeReadTrx(session.beginBucketRtx(revision));
}
final AbsAxis axis = new XPathAxis(rtx, xpath);
for (final long key : axis) {
WorkerHelper.serializeXML(session, output, false, nodeid, key, revision).call();
}
}
} catch (final Exception globExcep) {
throw new WebApplicationException(globExcep, Response.Status.INTERNAL_SERVER_ERROR);
} finally {
WorkerHelper.closeRTX(rtx, session);
}
} | java | private void doXPathRes(final String resource, final Long revision, final OutputStream output,
final boolean nodeid, final String xpath) throws TTException {
// Storage connection to treetank
ISession session = null;
INodeReadTrx rtx = null;
try {
if (mDatabase.existsResource(resource)) {
session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY));
// Creating a transaction
if (revision == null) {
rtx = new NodeReadTrx(session.beginBucketRtx(session.getMostRecentVersion()));
} else {
rtx = new NodeReadTrx(session.beginBucketRtx(revision));
}
final AbsAxis axis = new XPathAxis(rtx, xpath);
for (final long key : axis) {
WorkerHelper.serializeXML(session, output, false, nodeid, key, revision).call();
}
}
} catch (final Exception globExcep) {
throw new WebApplicationException(globExcep, Response.Status.INTERNAL_SERVER_ERROR);
} finally {
WorkerHelper.closeRTX(rtx, session);
}
} | [
"private",
"void",
"doXPathRes",
"(",
"final",
"String",
"resource",
",",
"final",
"Long",
"revision",
",",
"final",
"OutputStream",
"output",
",",
"final",
"boolean",
"nodeid",
",",
"final",
"String",
"xpath",
")",
"throws",
"TTException",
"{",
"// Storage connection to treetank",
"ISession",
"session",
"=",
"null",
";",
"INodeReadTrx",
"rtx",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"mDatabase",
".",
"existsResource",
"(",
"resource",
")",
")",
"{",
"session",
"=",
"mDatabase",
".",
"getSession",
"(",
"new",
"SessionConfiguration",
"(",
"resource",
",",
"StandardSettings",
".",
"KEY",
")",
")",
";",
"// Creating a transaction",
"if",
"(",
"revision",
"==",
"null",
")",
"{",
"rtx",
"=",
"new",
"NodeReadTrx",
"(",
"session",
".",
"beginBucketRtx",
"(",
"session",
".",
"getMostRecentVersion",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"rtx",
"=",
"new",
"NodeReadTrx",
"(",
"session",
".",
"beginBucketRtx",
"(",
"revision",
")",
")",
";",
"}",
"final",
"AbsAxis",
"axis",
"=",
"new",
"XPathAxis",
"(",
"rtx",
",",
"xpath",
")",
";",
"for",
"(",
"final",
"long",
"key",
":",
"axis",
")",
"{",
"WorkerHelper",
".",
"serializeXML",
"(",
"session",
",",
"output",
",",
"false",
",",
"nodeid",
",",
"key",
",",
"revision",
")",
".",
"call",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"final",
"Exception",
"globExcep",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"globExcep",
",",
"Response",
".",
"Status",
".",
"INTERNAL_SERVER_ERROR",
")",
";",
"}",
"finally",
"{",
"WorkerHelper",
".",
"closeRTX",
"(",
"rtx",
",",
"session",
")",
";",
"}",
"}"
] | This method performs an XPath evaluation and writes it to a given output
stream.
@param resource
The existing resource.
@param revision
The revision of the requested document.
@param output
The output stream where the results are written.
@param nodeid
<code>true</code> if node id's have to be delivered. <code>false</code> otherwise.
@param xpath
The XPath expression.
@throws TTException | [
"This",
"method",
"performs",
"an",
"XPath",
"evaluation",
"and",
"writes",
"it",
"to",
"a",
"given",
"output",
"stream",
"."
] | train | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/RestXPathProcessor.java#L216-L242 |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDOAuth2UserDaoImpl.java | GeneratedDOAuth2UserDaoImpl.queryByProfileLink | public Iterable<DOAuth2User> queryByProfileLink(java.lang.String profileLink) {
"""
query-by method for field profileLink
@param profileLink the specified attribute
@return an Iterable of DOAuth2Users for the specified profileLink
"""
return queryByField(null, DOAuth2UserMapper.Field.PROFILELINK.getFieldName(), profileLink);
} | java | public Iterable<DOAuth2User> queryByProfileLink(java.lang.String profileLink) {
return queryByField(null, DOAuth2UserMapper.Field.PROFILELINK.getFieldName(), profileLink);
} | [
"public",
"Iterable",
"<",
"DOAuth2User",
">",
"queryByProfileLink",
"(",
"java",
".",
"lang",
".",
"String",
"profileLink",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"DOAuth2UserMapper",
".",
"Field",
".",
"PROFILELINK",
".",
"getFieldName",
"(",
")",
",",
"profileLink",
")",
";",
"}"
] | query-by method for field profileLink
@param profileLink the specified attribute
@return an Iterable of DOAuth2Users for the specified profileLink | [
"query",
"-",
"by",
"method",
"for",
"field",
"profileLink"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDOAuth2UserDaoImpl.java#L106-L108 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/ThreadContext.java | ThreadContext.setInboundConnectionInfo | public void setInboundConnectionInfo(Map<String, Object> connectionInfo) {
"""
Set the inbound connection info on this context to the input value.
@param connectionInfo
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "setInboundConnectionInfo");
this.inboundConnectionInfo = connectionInfo;
} | java | public void setInboundConnectionInfo(Map<String, Object> connectionInfo) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "setInboundConnectionInfo");
this.inboundConnectionInfo = connectionInfo;
} | [
"public",
"void",
"setInboundConnectionInfo",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"connectionInfo",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"setInboundConnectionInfo\"",
")",
";",
"this",
".",
"inboundConnectionInfo",
"=",
"connectionInfo",
";",
"}"
] | Set the inbound connection info on this context to the input value.
@param connectionInfo | [
"Set",
"the",
"inbound",
"connection",
"info",
"on",
"this",
"context",
"to",
"the",
"input",
"value",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/ThreadContext.java#L180-L184 |
febit/wit | wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java | ClassWriter.newField | public int newField(
final String owner,
final String name,
final String desc) {
"""
Adds a field reference to the constant pool of the class being build. Does nothing if the constant pool already
contains a similar item.
<i>This method is intended for {@link Attribute} sub classes, and is normally not needed by class generators or
adapters.</i>
@param owner the internal name of the field's owner class.
@param name the field's name.
@param desc the field's descriptor.
@return the index of a new or already existing field reference item.
"""
Item result = get(key3.set(FIELD, owner, name, desc));
if (result == null) {
put122(FIELD, newClass(owner), newNameType(name, desc));
result = new Item(poolIndex++, key3);
put(result);
}
return result.index;
} | java | public int newField(
final String owner,
final String name,
final String desc) {
Item result = get(key3.set(FIELD, owner, name, desc));
if (result == null) {
put122(FIELD, newClass(owner), newNameType(name, desc));
result = new Item(poolIndex++, key3);
put(result);
}
return result.index;
} | [
"public",
"int",
"newField",
"(",
"final",
"String",
"owner",
",",
"final",
"String",
"name",
",",
"final",
"String",
"desc",
")",
"{",
"Item",
"result",
"=",
"get",
"(",
"key3",
".",
"set",
"(",
"FIELD",
",",
"owner",
",",
"name",
",",
"desc",
")",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"put122",
"(",
"FIELD",
",",
"newClass",
"(",
"owner",
")",
",",
"newNameType",
"(",
"name",
",",
"desc",
")",
")",
";",
"result",
"=",
"new",
"Item",
"(",
"poolIndex",
"++",
",",
"key3",
")",
";",
"put",
"(",
"result",
")",
";",
"}",
"return",
"result",
".",
"index",
";",
"}"
] | Adds a field reference to the constant pool of the class being build. Does nothing if the constant pool already
contains a similar item.
<i>This method is intended for {@link Attribute} sub classes, and is normally not needed by class generators or
adapters.</i>
@param owner the internal name of the field's owner class.
@param name the field's name.
@param desc the field's descriptor.
@return the index of a new or already existing field reference item. | [
"Adds",
"a",
"field",
"reference",
"to",
"the",
"constant",
"pool",
"of",
"the",
"class",
"being",
"build",
".",
"Does",
"nothing",
"if",
"the",
"constant",
"pool",
"already",
"contains",
"a",
"similar",
"item",
".",
"<i",
">",
"This",
"method",
"is",
"intended",
"for",
"{",
"@link",
"Attribute",
"}",
"sub",
"classes",
"and",
"is",
"normally",
"not",
"needed",
"by",
"class",
"generators",
"or",
"adapters",
".",
"<",
"/",
"i",
">"
] | train | https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit_shaded/asm/ClassWriter.java#L570-L581 |
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/util/GosuObjectUtil.java | GosuObjectUtil.max | public static Object max(Comparable c1, Comparable c2) {
"""
Null safe comparison of Comparables.
@param c1 the first comparable, may be null
@param c2 the second comparable, may be null
@return <ul>
<li>If both objects are non-null and unequal, the greater object.
<li>If both objects are non-null and equal, c1.
<li>If one of the comparables is null, the non-null object.
<li>If both the comparables are null, null is returned.
</ul>
"""
if (c1 != null && c2 != null) {
return c1.compareTo(c2) >= 0 ? c1 : c2;
} else {
return c1 != null ? c1 : c2;
}
} | java | public static Object max(Comparable c1, Comparable c2) {
if (c1 != null && c2 != null) {
return c1.compareTo(c2) >= 0 ? c1 : c2;
} else {
return c1 != null ? c1 : c2;
}
} | [
"public",
"static",
"Object",
"max",
"(",
"Comparable",
"c1",
",",
"Comparable",
"c2",
")",
"{",
"if",
"(",
"c1",
"!=",
"null",
"&&",
"c2",
"!=",
"null",
")",
"{",
"return",
"c1",
".",
"compareTo",
"(",
"c2",
")",
">=",
"0",
"?",
"c1",
":",
"c2",
";",
"}",
"else",
"{",
"return",
"c1",
"!=",
"null",
"?",
"c1",
":",
"c2",
";",
"}",
"}"
] | Null safe comparison of Comparables.
@param c1 the first comparable, may be null
@param c2 the second comparable, may be null
@return <ul>
<li>If both objects are non-null and unequal, the greater object.
<li>If both objects are non-null and equal, c1.
<li>If one of the comparables is null, the non-null object.
<li>If both the comparables are null, null is returned.
</ul> | [
"Null",
"safe",
"comparison",
"of",
"Comparables",
"."
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/util/GosuObjectUtil.java#L280-L286 |
grpc/grpc-java | examples/src/main/java/io/grpc/examples/errorhandling/ErrorHandlingClient.java | ErrorHandlingClient.advancedAsyncCall | void advancedAsyncCall() {
"""
This is more advanced and does not make use of the stub. You should not normally need to do
this, but here is how you would.
"""
ClientCall<HelloRequest, HelloReply> call =
channel.newCall(GreeterGrpc.getSayHelloMethod(), CallOptions.DEFAULT);
final CountDownLatch latch = new CountDownLatch(1);
call.start(new ClientCall.Listener<HelloReply>() {
@Override
public void onClose(Status status, Metadata trailers) {
Verify.verify(status.getCode() == Status.Code.INTERNAL);
Verify.verify(status.getDescription().contains("Narwhal"));
// Cause is not transmitted over the wire.
latch.countDown();
}
}, new Metadata());
call.sendMessage(HelloRequest.newBuilder().setName("Marge").build());
call.halfClose();
if (!Uninterruptibles.awaitUninterruptibly(latch, 1, TimeUnit.SECONDS)) {
throw new RuntimeException("timeout!");
}
} | java | void advancedAsyncCall() {
ClientCall<HelloRequest, HelloReply> call =
channel.newCall(GreeterGrpc.getSayHelloMethod(), CallOptions.DEFAULT);
final CountDownLatch latch = new CountDownLatch(1);
call.start(new ClientCall.Listener<HelloReply>() {
@Override
public void onClose(Status status, Metadata trailers) {
Verify.verify(status.getCode() == Status.Code.INTERNAL);
Verify.verify(status.getDescription().contains("Narwhal"));
// Cause is not transmitted over the wire.
latch.countDown();
}
}, new Metadata());
call.sendMessage(HelloRequest.newBuilder().setName("Marge").build());
call.halfClose();
if (!Uninterruptibles.awaitUninterruptibly(latch, 1, TimeUnit.SECONDS)) {
throw new RuntimeException("timeout!");
}
} | [
"void",
"advancedAsyncCall",
"(",
")",
"{",
"ClientCall",
"<",
"HelloRequest",
",",
"HelloReply",
">",
"call",
"=",
"channel",
".",
"newCall",
"(",
"GreeterGrpc",
".",
"getSayHelloMethod",
"(",
")",
",",
"CallOptions",
".",
"DEFAULT",
")",
";",
"final",
"CountDownLatch",
"latch",
"=",
"new",
"CountDownLatch",
"(",
"1",
")",
";",
"call",
".",
"start",
"(",
"new",
"ClientCall",
".",
"Listener",
"<",
"HelloReply",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onClose",
"(",
"Status",
"status",
",",
"Metadata",
"trailers",
")",
"{",
"Verify",
".",
"verify",
"(",
"status",
".",
"getCode",
"(",
")",
"==",
"Status",
".",
"Code",
".",
"INTERNAL",
")",
";",
"Verify",
".",
"verify",
"(",
"status",
".",
"getDescription",
"(",
")",
".",
"contains",
"(",
"\"Narwhal\"",
")",
")",
";",
"// Cause is not transmitted over the wire.",
"latch",
".",
"countDown",
"(",
")",
";",
"}",
"}",
",",
"new",
"Metadata",
"(",
")",
")",
";",
"call",
".",
"sendMessage",
"(",
"HelloRequest",
".",
"newBuilder",
"(",
")",
".",
"setName",
"(",
"\"Marge\"",
")",
".",
"build",
"(",
")",
")",
";",
"call",
".",
"halfClose",
"(",
")",
";",
"if",
"(",
"!",
"Uninterruptibles",
".",
"awaitUninterruptibly",
"(",
"latch",
",",
"1",
",",
"TimeUnit",
".",
"SECONDS",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"timeout!\"",
")",
";",
"}",
"}"
] | This is more advanced and does not make use of the stub. You should not normally need to do
this, but here is how you would. | [
"This",
"is",
"more",
"advanced",
"and",
"does",
"not",
"make",
"use",
"of",
"the",
"stub",
".",
"You",
"should",
"not",
"normally",
"need",
"to",
"do",
"this",
"but",
"here",
"is",
"how",
"you",
"would",
"."
] | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/examples/src/main/java/io/grpc/examples/errorhandling/ErrorHandlingClient.java#L178-L201 |
pressgang-ccms/PressGangCCMSContentSpecProcessor | src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java | ContentSpecProcessor.processAssignedWriter | protected void processAssignedWriter(final TagProvider tagProvider, final ITopicNode topicNode, final TopicWrapper topic) {
"""
Processes a Spec Topic and adds the assigned writer for the topic it represents.
@param tagProvider
@param topicNode The topic node object that contains the assigned writer.
@param topic The topic entity to be updated.
@return True if anything in the topic entity was changed, otherwise false.
"""
LOG.debug("Processing assigned writer");
// See if a new tag collection needs to be created
if (topic.getTags() == null) {
topic.setTags(tagProvider.newTagCollection());
}
// Set the assigned writer (Tag Table)
final TagWrapper writerTag = tagProvider.getTagByName(topicNode.getAssignedWriter(true));
// Save a new assigned writer
topic.getTags().addNewItem(writerTag);
// Some providers need the collection to be set to set flags for saving
topic.setTags(topic.getTags());
} | java | protected void processAssignedWriter(final TagProvider tagProvider, final ITopicNode topicNode, final TopicWrapper topic) {
LOG.debug("Processing assigned writer");
// See if a new tag collection needs to be created
if (topic.getTags() == null) {
topic.setTags(tagProvider.newTagCollection());
}
// Set the assigned writer (Tag Table)
final TagWrapper writerTag = tagProvider.getTagByName(topicNode.getAssignedWriter(true));
// Save a new assigned writer
topic.getTags().addNewItem(writerTag);
// Some providers need the collection to be set to set flags for saving
topic.setTags(topic.getTags());
} | [
"protected",
"void",
"processAssignedWriter",
"(",
"final",
"TagProvider",
"tagProvider",
",",
"final",
"ITopicNode",
"topicNode",
",",
"final",
"TopicWrapper",
"topic",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Processing assigned writer\"",
")",
";",
"// See if a new tag collection needs to be created",
"if",
"(",
"topic",
".",
"getTags",
"(",
")",
"==",
"null",
")",
"{",
"topic",
".",
"setTags",
"(",
"tagProvider",
".",
"newTagCollection",
"(",
")",
")",
";",
"}",
"// Set the assigned writer (Tag Table)",
"final",
"TagWrapper",
"writerTag",
"=",
"tagProvider",
".",
"getTagByName",
"(",
"topicNode",
".",
"getAssignedWriter",
"(",
"true",
")",
")",
";",
"// Save a new assigned writer",
"topic",
".",
"getTags",
"(",
")",
".",
"addNewItem",
"(",
"writerTag",
")",
";",
"// Some providers need the collection to be set to set flags for saving",
"topic",
".",
"setTags",
"(",
"topic",
".",
"getTags",
"(",
")",
")",
";",
"}"
] | Processes a Spec Topic and adds the assigned writer for the topic it represents.
@param tagProvider
@param topicNode The topic node object that contains the assigned writer.
@param topic The topic entity to be updated.
@return True if anything in the topic entity was changed, otherwise false. | [
"Processes",
"a",
"Spec",
"Topic",
"and",
"adds",
"the",
"assigned",
"writer",
"for",
"the",
"topic",
"it",
"represents",
"."
] | train | https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L936-L950 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/AssertKripton.java | AssertKripton.assertTrue | public static void assertTrue(boolean expression, String messageFormat, Object... args) {
"""
Assertion which generate an exception if expression is not true.
@param expression
the expression
@param messageFormat
the message format
@param args
the args
"""
if (!expression)
throw (new KriptonProcessorException(String.format(messageFormat, args)));
} | java | public static void assertTrue(boolean expression, String messageFormat, Object... args) {
if (!expression)
throw (new KriptonProcessorException(String.format(messageFormat, args)));
} | [
"public",
"static",
"void",
"assertTrue",
"(",
"boolean",
"expression",
",",
"String",
"messageFormat",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"!",
"expression",
")",
"throw",
"(",
"new",
"KriptonProcessorException",
"(",
"String",
".",
"format",
"(",
"messageFormat",
",",
"args",
")",
")",
")",
";",
"}"
] | Assertion which generate an exception if expression is not true.
@param expression
the expression
@param messageFormat
the message format
@param args
the args | [
"Assertion",
"which",
"generate",
"an",
"exception",
"if",
"expression",
"is",
"not",
"true",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/AssertKripton.java#L69-L73 |
ironjacamar/ironjacamar | core/src/main/java/org/ironjacamar/core/tx/narayana/SecurityActions.java | SecurityActions.createSubject | static Subject createSubject(final SubjectFactory subjectFactory, final String domain) {
"""
Get a Subject instance
@param subjectFactory The subject factory
@param domain The domain
@return The instance
"""
if (System.getSecurityManager() == null)
return subjectFactory.createSubject(domain);
return AccessController.doPrivileged(new PrivilegedAction<Subject>()
{
public Subject run()
{
return subjectFactory.createSubject(domain);
}
});
} | java | static Subject createSubject(final SubjectFactory subjectFactory, final String domain)
{
if (System.getSecurityManager() == null)
return subjectFactory.createSubject(domain);
return AccessController.doPrivileged(new PrivilegedAction<Subject>()
{
public Subject run()
{
return subjectFactory.createSubject(domain);
}
});
} | [
"static",
"Subject",
"createSubject",
"(",
"final",
"SubjectFactory",
"subjectFactory",
",",
"final",
"String",
"domain",
")",
"{",
"if",
"(",
"System",
".",
"getSecurityManager",
"(",
")",
"==",
"null",
")",
"return",
"subjectFactory",
".",
"createSubject",
"(",
"domain",
")",
";",
"return",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedAction",
"<",
"Subject",
">",
"(",
")",
"{",
"public",
"Subject",
"run",
"(",
")",
"{",
"return",
"subjectFactory",
".",
"createSubject",
"(",
"domain",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get a Subject instance
@param subjectFactory The subject factory
@param domain The domain
@return The instance | [
"Get",
"a",
"Subject",
"instance"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/core/src/main/java/org/ironjacamar/core/tx/narayana/SecurityActions.java#L112-L124 |
wisdom-framework/wisdom | core/crypto/src/main/java/org/wisdom/crypto/CryptoServiceSingleton.java | CryptoServiceSingleton.generateAESKey | private SecretKey generateAESKey(String privateKey, String salt) {
"""
Generate the AES key from the salt and the private key.
@param salt the salt (hexadecimal)
@param privateKey the private key
@return the generated key.
"""
try {
byte[] raw = decodeHex(salt);
KeySpec spec = new PBEKeySpec(privateKey.toCharArray(), raw, iterationCount, keySize);
SecretKeyFactory factory = SecretKeyFactory.getInstance(PBKDF_2_WITH_HMAC_SHA_1);
return new SecretKeySpec(factory.generateSecret(spec).getEncoded(), AES_ECB_ALGORITHM);
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new IllegalStateException(e);
}
} | java | private SecretKey generateAESKey(String privateKey, String salt) {
try {
byte[] raw = decodeHex(salt);
KeySpec spec = new PBEKeySpec(privateKey.toCharArray(), raw, iterationCount, keySize);
SecretKeyFactory factory = SecretKeyFactory.getInstance(PBKDF_2_WITH_HMAC_SHA_1);
return new SecretKeySpec(factory.generateSecret(spec).getEncoded(), AES_ECB_ALGORITHM);
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new IllegalStateException(e);
}
} | [
"private",
"SecretKey",
"generateAESKey",
"(",
"String",
"privateKey",
",",
"String",
"salt",
")",
"{",
"try",
"{",
"byte",
"[",
"]",
"raw",
"=",
"decodeHex",
"(",
"salt",
")",
";",
"KeySpec",
"spec",
"=",
"new",
"PBEKeySpec",
"(",
"privateKey",
".",
"toCharArray",
"(",
")",
",",
"raw",
",",
"iterationCount",
",",
"keySize",
")",
";",
"SecretKeyFactory",
"factory",
"=",
"SecretKeyFactory",
".",
"getInstance",
"(",
"PBKDF_2_WITH_HMAC_SHA_1",
")",
";",
"return",
"new",
"SecretKeySpec",
"(",
"factory",
".",
"generateSecret",
"(",
"spec",
")",
".",
"getEncoded",
"(",
")",
",",
"AES_ECB_ALGORITHM",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"|",
"InvalidKeySpecException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}"
] | Generate the AES key from the salt and the private key.
@param salt the salt (hexadecimal)
@param privateKey the private key
@return the generated key. | [
"Generate",
"the",
"AES",
"key",
"from",
"the",
"salt",
"and",
"the",
"private",
"key",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/crypto/src/main/java/org/wisdom/crypto/CryptoServiceSingleton.java#L99-L108 |
cloudinary/cloudinary_java | cloudinary-core/src/main/java/com/cloudinary/Api.java | Api.createStreamingProfile | public ApiResponse createStreamingProfile(String name, String displayName, List<Map> representations, Map options) throws Exception {
"""
Create a new streaming profile
@param name the of the profile
@param displayName the display name of the profile
@param representations a collection of Maps with a transformation key
@param options additional options
@return the new streaming profile
@throws Exception an exception
"""
if (options == null)
options = ObjectUtils.emptyMap();
List<Map> serializedRepresentations = new ArrayList<Map>(representations.size());
for (Map t : representations) {
final Object transformation = t.get("transformation");
serializedRepresentations.add(ObjectUtils.asMap("transformation", transformation.toString()));
}
List<String> uri = Collections.singletonList("streaming_profiles");
final Map params = ObjectUtils.asMap(
"name", name,
"representations", new JSONArray(serializedRepresentations.toArray())
);
if (displayName != null) {
params.put("display_name", displayName);
}
return callApi(HttpMethod.POST, uri, params, options);
} | java | public ApiResponse createStreamingProfile(String name, String displayName, List<Map> representations, Map options) throws Exception {
if (options == null)
options = ObjectUtils.emptyMap();
List<Map> serializedRepresentations = new ArrayList<Map>(representations.size());
for (Map t : representations) {
final Object transformation = t.get("transformation");
serializedRepresentations.add(ObjectUtils.asMap("transformation", transformation.toString()));
}
List<String> uri = Collections.singletonList("streaming_profiles");
final Map params = ObjectUtils.asMap(
"name", name,
"representations", new JSONArray(serializedRepresentations.toArray())
);
if (displayName != null) {
params.put("display_name", displayName);
}
return callApi(HttpMethod.POST, uri, params, options);
} | [
"public",
"ApiResponse",
"createStreamingProfile",
"(",
"String",
"name",
",",
"String",
"displayName",
",",
"List",
"<",
"Map",
">",
"representations",
",",
"Map",
"options",
")",
"throws",
"Exception",
"{",
"if",
"(",
"options",
"==",
"null",
")",
"options",
"=",
"ObjectUtils",
".",
"emptyMap",
"(",
")",
";",
"List",
"<",
"Map",
">",
"serializedRepresentations",
"=",
"new",
"ArrayList",
"<",
"Map",
">",
"(",
"representations",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Map",
"t",
":",
"representations",
")",
"{",
"final",
"Object",
"transformation",
"=",
"t",
".",
"get",
"(",
"\"transformation\"",
")",
";",
"serializedRepresentations",
".",
"add",
"(",
"ObjectUtils",
".",
"asMap",
"(",
"\"transformation\"",
",",
"transformation",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"List",
"<",
"String",
">",
"uri",
"=",
"Collections",
".",
"singletonList",
"(",
"\"streaming_profiles\"",
")",
";",
"final",
"Map",
"params",
"=",
"ObjectUtils",
".",
"asMap",
"(",
"\"name\"",
",",
"name",
",",
"\"representations\"",
",",
"new",
"JSONArray",
"(",
"serializedRepresentations",
".",
"toArray",
"(",
")",
")",
")",
";",
"if",
"(",
"displayName",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"display_name\"",
",",
"displayName",
")",
";",
"}",
"return",
"callApi",
"(",
"HttpMethod",
".",
"POST",
",",
"uri",
",",
"params",
",",
"options",
")",
";",
"}"
] | Create a new streaming profile
@param name the of the profile
@param displayName the display name of the profile
@param representations a collection of Maps with a transformation key
@param options additional options
@return the new streaming profile
@throws Exception an exception | [
"Create",
"a",
"new",
"streaming",
"profile"
] | train | https://github.com/cloudinary/cloudinary_java/blob/58ee1823180da2dea6a2eb7e5cf00d5a760f8aef/cloudinary-core/src/main/java/com/cloudinary/Api.java#L347-L364 |
sarl/sarl | main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/extralanguage/preferences/ExtraLanguagePreferenceAccess.java | ExtraLanguagePreferenceAccess.getPrefixedKey | public static String getPrefixedKey(String preferenceContainerID, String preferenceName) {
"""
Create a preference key.
@param preferenceContainerID the identifier of the generator's preference container.
@param preferenceName the name of the preference.
@return the key.
"""
return getXtextKey(getPropertyPrefix(preferenceContainerID), preferenceName);
} | java | public static String getPrefixedKey(String preferenceContainerID, String preferenceName) {
return getXtextKey(getPropertyPrefix(preferenceContainerID), preferenceName);
} | [
"public",
"static",
"String",
"getPrefixedKey",
"(",
"String",
"preferenceContainerID",
",",
"String",
"preferenceName",
")",
"{",
"return",
"getXtextKey",
"(",
"getPropertyPrefix",
"(",
"preferenceContainerID",
")",
",",
"preferenceName",
")",
";",
"}"
] | Create a preference key.
@param preferenceContainerID the identifier of the generator's preference container.
@param preferenceName the name of the preference.
@return the key. | [
"Create",
"a",
"preference",
"key",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/extralanguage/preferences/ExtraLanguagePreferenceAccess.java#L111-L113 |
mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.validateSql | public void validateSql(String sql, CancellationSignal cancellationSignal) {
"""
Verifies that a SQL SELECT statement is valid by compiling it.
If the SQL statement is not valid, this method will throw a {@link SQLiteException}.
@param sql SQL to be validated
@param cancellationSignal A signal to cancel the operation in progress, or null if none.
If the operation is canceled, then {@link OperationCanceledException} will be thrown
when the query is executed.
@throws SQLiteException if {@code sql} is invalid
"""
getThreadSession().prepare(sql,
getThreadDefaultConnectionFlags(/* readOnly =*/ true), cancellationSignal, null);
} | java | public void validateSql(String sql, CancellationSignal cancellationSignal) {
getThreadSession().prepare(sql,
getThreadDefaultConnectionFlags(/* readOnly =*/ true), cancellationSignal, null);
} | [
"public",
"void",
"validateSql",
"(",
"String",
"sql",
",",
"CancellationSignal",
"cancellationSignal",
")",
"{",
"getThreadSession",
"(",
")",
".",
"prepare",
"(",
"sql",
",",
"getThreadDefaultConnectionFlags",
"(",
"/* readOnly =*/",
"true",
")",
",",
"cancellationSignal",
",",
"null",
")",
";",
"}"
] | Verifies that a SQL SELECT statement is valid by compiling it.
If the SQL statement is not valid, this method will throw a {@link SQLiteException}.
@param sql SQL to be validated
@param cancellationSignal A signal to cancel the operation in progress, or null if none.
If the operation is canceled, then {@link OperationCanceledException} will be thrown
when the query is executed.
@throws SQLiteException if {@code sql} is invalid | [
"Verifies",
"that",
"a",
"SQL",
"SELECT",
"statement",
"is",
"valid",
"by",
"compiling",
"it",
".",
"If",
"the",
"SQL",
"statement",
"is",
"not",
"valid",
"this",
"method",
"will",
"throw",
"a",
"{",
"@link",
"SQLiteException",
"}",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L1700-L1703 |
centic9/commons-dost | src/main/java/org/dstadler/commons/http/HttpClientWrapper.java | HttpClientWrapper.retrieveData | public static String retrieveData(String url, String user, String password, int timeoutMs) throws IOException {
"""
Small helper method to simply query the URL without password and
return the resulting data.
@param url The URL to query data from.
@param user The username to send
@param password The password to send
@param timeoutMs How long in milliseconds to wait for the request
@return The resulting data read from the URL
@throws IOException If the URL is not accessible or the query returns
a HTTP code other than 200.
"""
try (HttpClientWrapper wrapper = new HttpClientWrapper(user, password, timeoutMs)) {
return wrapper.simpleGet(url);
}
} | java | public static String retrieveData(String url, String user, String password, int timeoutMs) throws IOException {
try (HttpClientWrapper wrapper = new HttpClientWrapper(user, password, timeoutMs)) {
return wrapper.simpleGet(url);
}
} | [
"public",
"static",
"String",
"retrieveData",
"(",
"String",
"url",
",",
"String",
"user",
",",
"String",
"password",
",",
"int",
"timeoutMs",
")",
"throws",
"IOException",
"{",
"try",
"(",
"HttpClientWrapper",
"wrapper",
"=",
"new",
"HttpClientWrapper",
"(",
"user",
",",
"password",
",",
"timeoutMs",
")",
")",
"{",
"return",
"wrapper",
".",
"simpleGet",
"(",
"url",
")",
";",
"}",
"}"
] | Small helper method to simply query the URL without password and
return the resulting data.
@param url The URL to query data from.
@param user The username to send
@param password The password to send
@param timeoutMs How long in milliseconds to wait for the request
@return The resulting data read from the URL
@throws IOException If the URL is not accessible or the query returns
a HTTP code other than 200. | [
"Small",
"helper",
"method",
"to",
"simply",
"query",
"the",
"URL",
"without",
"password",
"and",
"return",
"the",
"resulting",
"data",
"."
] | train | https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/http/HttpClientWrapper.java#L336-L340 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/UnsynchronizedOverridesSynchronized.java | UnsynchronizedOverridesSynchronized.ignore | private static boolean ignore(MethodTree method, VisitorState state) {
"""
Don't flag methods that are empty or trivially delegate to a super-implementation.
"""
return firstNonNull(
new TreeScanner<Boolean, Void>() {
@Override
public Boolean visitBlock(BlockTree tree, Void unused) {
switch (tree.getStatements().size()) {
case 0:
return true;
case 1:
return scan(getOnlyElement(tree.getStatements()), null);
default:
return false;
}
}
@Override
public Boolean visitReturn(ReturnTree tree, Void unused) {
return scan(tree.getExpression(), null);
}
@Override
public Boolean visitExpressionStatement(ExpressionStatementTree tree, Void unused) {
return scan(tree.getExpression(), null);
}
@Override
public Boolean visitTypeCast(TypeCastTree tree, Void unused) {
return scan(tree.getExpression(), null);
}
@Override
public Boolean visitMethodInvocation(MethodInvocationTree node, Void aVoid) {
ExpressionTree receiver = ASTHelpers.getReceiver(node);
return receiver instanceof IdentifierTree
&& ((IdentifierTree) receiver).getName().contentEquals("super")
&& overrides(ASTHelpers.getSymbol(method), ASTHelpers.getSymbol(node));
}
private boolean overrides(MethodSymbol sym, MethodSymbol other) {
return !sym.isStatic()
&& !other.isStatic()
&& (((sym.flags() | other.flags()) & Flags.SYNTHETIC) == 0)
&& sym.name.contentEquals(other.name)
&& sym.overrides(
other, sym.owner.enclClass(), state.getTypes(), /* checkResult= */ false);
}
}.scan(method.getBody(), null),
false);
} | java | private static boolean ignore(MethodTree method, VisitorState state) {
return firstNonNull(
new TreeScanner<Boolean, Void>() {
@Override
public Boolean visitBlock(BlockTree tree, Void unused) {
switch (tree.getStatements().size()) {
case 0:
return true;
case 1:
return scan(getOnlyElement(tree.getStatements()), null);
default:
return false;
}
}
@Override
public Boolean visitReturn(ReturnTree tree, Void unused) {
return scan(tree.getExpression(), null);
}
@Override
public Boolean visitExpressionStatement(ExpressionStatementTree tree, Void unused) {
return scan(tree.getExpression(), null);
}
@Override
public Boolean visitTypeCast(TypeCastTree tree, Void unused) {
return scan(tree.getExpression(), null);
}
@Override
public Boolean visitMethodInvocation(MethodInvocationTree node, Void aVoid) {
ExpressionTree receiver = ASTHelpers.getReceiver(node);
return receiver instanceof IdentifierTree
&& ((IdentifierTree) receiver).getName().contentEquals("super")
&& overrides(ASTHelpers.getSymbol(method), ASTHelpers.getSymbol(node));
}
private boolean overrides(MethodSymbol sym, MethodSymbol other) {
return !sym.isStatic()
&& !other.isStatic()
&& (((sym.flags() | other.flags()) & Flags.SYNTHETIC) == 0)
&& sym.name.contentEquals(other.name)
&& sym.overrides(
other, sym.owner.enclClass(), state.getTypes(), /* checkResult= */ false);
}
}.scan(method.getBody(), null),
false);
} | [
"private",
"static",
"boolean",
"ignore",
"(",
"MethodTree",
"method",
",",
"VisitorState",
"state",
")",
"{",
"return",
"firstNonNull",
"(",
"new",
"TreeScanner",
"<",
"Boolean",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Boolean",
"visitBlock",
"(",
"BlockTree",
"tree",
",",
"Void",
"unused",
")",
"{",
"switch",
"(",
"tree",
".",
"getStatements",
"(",
")",
".",
"size",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"true",
";",
"case",
"1",
":",
"return",
"scan",
"(",
"getOnlyElement",
"(",
"tree",
".",
"getStatements",
"(",
")",
")",
",",
"null",
")",
";",
"default",
":",
"return",
"false",
";",
"}",
"}",
"@",
"Override",
"public",
"Boolean",
"visitReturn",
"(",
"ReturnTree",
"tree",
",",
"Void",
"unused",
")",
"{",
"return",
"scan",
"(",
"tree",
".",
"getExpression",
"(",
")",
",",
"null",
")",
";",
"}",
"@",
"Override",
"public",
"Boolean",
"visitExpressionStatement",
"(",
"ExpressionStatementTree",
"tree",
",",
"Void",
"unused",
")",
"{",
"return",
"scan",
"(",
"tree",
".",
"getExpression",
"(",
")",
",",
"null",
")",
";",
"}",
"@",
"Override",
"public",
"Boolean",
"visitTypeCast",
"(",
"TypeCastTree",
"tree",
",",
"Void",
"unused",
")",
"{",
"return",
"scan",
"(",
"tree",
".",
"getExpression",
"(",
")",
",",
"null",
")",
";",
"}",
"@",
"Override",
"public",
"Boolean",
"visitMethodInvocation",
"(",
"MethodInvocationTree",
"node",
",",
"Void",
"aVoid",
")",
"{",
"ExpressionTree",
"receiver",
"=",
"ASTHelpers",
".",
"getReceiver",
"(",
"node",
")",
";",
"return",
"receiver",
"instanceof",
"IdentifierTree",
"&&",
"(",
"(",
"IdentifierTree",
")",
"receiver",
")",
".",
"getName",
"(",
")",
".",
"contentEquals",
"(",
"\"super\"",
")",
"&&",
"overrides",
"(",
"ASTHelpers",
".",
"getSymbol",
"(",
"method",
")",
",",
"ASTHelpers",
".",
"getSymbol",
"(",
"node",
")",
")",
";",
"}",
"private",
"boolean",
"overrides",
"(",
"MethodSymbol",
"sym",
",",
"MethodSymbol",
"other",
")",
"{",
"return",
"!",
"sym",
".",
"isStatic",
"(",
")",
"&&",
"!",
"other",
".",
"isStatic",
"(",
")",
"&&",
"(",
"(",
"(",
"sym",
".",
"flags",
"(",
")",
"|",
"other",
".",
"flags",
"(",
")",
")",
"&",
"Flags",
".",
"SYNTHETIC",
")",
"==",
"0",
")",
"&&",
"sym",
".",
"name",
".",
"contentEquals",
"(",
"other",
".",
"name",
")",
"&&",
"sym",
".",
"overrides",
"(",
"other",
",",
"sym",
".",
"owner",
".",
"enclClass",
"(",
")",
",",
"state",
".",
"getTypes",
"(",
")",
",",
"/* checkResult= */",
"false",
")",
";",
"}",
"}",
".",
"scan",
"(",
"method",
".",
"getBody",
"(",
")",
",",
"null",
")",
",",
"false",
")",
";",
"}"
] | Don't flag methods that are empty or trivially delegate to a super-implementation. | [
"Don",
"t",
"flag",
"methods",
"that",
"are",
"empty",
"or",
"trivially",
"delegate",
"to",
"a",
"super",
"-",
"implementation",
"."
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/UnsynchronizedOverridesSynchronized.java#L88-L136 |
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.wrapDriverInProfilingProxy | private Object wrapDriverInProfilingProxy(Object newDriverInstance) {
"""
Wraps a driver object with a dynamic proxy that counts method calls and their durations.<p>
@param newDriverInstance the driver instance to wrap
@return the proxy
"""
Class<?> cls = getDriverInterfaceForProxy(newDriverInstance);
if (cls == null) {
return newDriverInstance;
}
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class[] {cls},
new CmsProfilingInvocationHandler(newDriverInstance, CmsDefaultProfilingHandler.INSTANCE));
} | java | private Object wrapDriverInProfilingProxy(Object newDriverInstance) {
Class<?> cls = getDriverInterfaceForProxy(newDriverInstance);
if (cls == null) {
return newDriverInstance;
}
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class[] {cls},
new CmsProfilingInvocationHandler(newDriverInstance, CmsDefaultProfilingHandler.INSTANCE));
} | [
"private",
"Object",
"wrapDriverInProfilingProxy",
"(",
"Object",
"newDriverInstance",
")",
"{",
"Class",
"<",
"?",
">",
"cls",
"=",
"getDriverInterfaceForProxy",
"(",
"newDriverInstance",
")",
";",
"if",
"(",
"cls",
"==",
"null",
")",
"{",
"return",
"newDriverInstance",
";",
"}",
"return",
"Proxy",
".",
"newProxyInstance",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
",",
"new",
"Class",
"[",
"]",
"{",
"cls",
"}",
",",
"new",
"CmsProfilingInvocationHandler",
"(",
"newDriverInstance",
",",
"CmsDefaultProfilingHandler",
".",
"INSTANCE",
")",
")",
";",
"}"
] | Wraps a driver object with a dynamic proxy that counts method calls and their durations.<p>
@param newDriverInstance the driver instance to wrap
@return the proxy | [
"Wraps",
"a",
"driver",
"object",
"with",
"a",
"dynamic",
"proxy",
"that",
"counts",
"method",
"calls",
"and",
"their",
"durations",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L11984-L11994 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/connmgmt/ConnectionType.java | ConnectionType.setVCConnectionType | public static void setVCConnectionType(VirtualConnection vc, ConnectionType connType) {
"""
Set the connection type on the virtual connection. This will overlay
any preset value.
@param vc
VirtualConnection containing simple state for this connection
@param connType
ConnectionType for the VirtualConnection
"""
if (vc == null || connType == null) {
return;
}
Map<Object, Object> map = vc.getStateMap();
// Internal connections are both inbound and outbound (they're connections
// to ourselves)
// so while we prevent setting Outbound ConnTypes for inbound connections
// and vice versa,
// we don't prevent internal types from being set as either.
if (vc instanceof InboundVirtualConnection && ConnectionType.isOutbound(connType.type)) {
throw new IllegalStateException("Cannot set outbound ConnectionType on inbound VirtualConnection");
} else if (vc instanceof OutboundVirtualConnection && ConnectionType.isInbound(connType.type)) {
throw new IllegalStateException("Cannot set inbound ConnectionType on outbound VirtualConnection");
}
map.put(CONNECTION_TYPE_VC_KEY, connType);
} | java | public static void setVCConnectionType(VirtualConnection vc, ConnectionType connType) {
if (vc == null || connType == null) {
return;
}
Map<Object, Object> map = vc.getStateMap();
// Internal connections are both inbound and outbound (they're connections
// to ourselves)
// so while we prevent setting Outbound ConnTypes for inbound connections
// and vice versa,
// we don't prevent internal types from being set as either.
if (vc instanceof InboundVirtualConnection && ConnectionType.isOutbound(connType.type)) {
throw new IllegalStateException("Cannot set outbound ConnectionType on inbound VirtualConnection");
} else if (vc instanceof OutboundVirtualConnection && ConnectionType.isInbound(connType.type)) {
throw new IllegalStateException("Cannot set inbound ConnectionType on outbound VirtualConnection");
}
map.put(CONNECTION_TYPE_VC_KEY, connType);
} | [
"public",
"static",
"void",
"setVCConnectionType",
"(",
"VirtualConnection",
"vc",
",",
"ConnectionType",
"connType",
")",
"{",
"if",
"(",
"vc",
"==",
"null",
"||",
"connType",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Map",
"<",
"Object",
",",
"Object",
">",
"map",
"=",
"vc",
".",
"getStateMap",
"(",
")",
";",
"// Internal connections are both inbound and outbound (they're connections",
"// to ourselves)",
"// so while we prevent setting Outbound ConnTypes for inbound connections",
"// and vice versa,",
"// we don't prevent internal types from being set as either.",
"if",
"(",
"vc",
"instanceof",
"InboundVirtualConnection",
"&&",
"ConnectionType",
".",
"isOutbound",
"(",
"connType",
".",
"type",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot set outbound ConnectionType on inbound VirtualConnection\"",
")",
";",
"}",
"else",
"if",
"(",
"vc",
"instanceof",
"OutboundVirtualConnection",
"&&",
"ConnectionType",
".",
"isInbound",
"(",
"connType",
".",
"type",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot set inbound ConnectionType on outbound VirtualConnection\"",
")",
";",
"}",
"map",
".",
"put",
"(",
"CONNECTION_TYPE_VC_KEY",
",",
"connType",
")",
";",
"}"
] | Set the connection type on the virtual connection. This will overlay
any preset value.
@param vc
VirtualConnection containing simple state for this connection
@param connType
ConnectionType for the VirtualConnection | [
"Set",
"the",
"connection",
"type",
"on",
"the",
"virtual",
"connection",
".",
"This",
"will",
"overlay",
"any",
"preset",
"value",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/connmgmt/ConnectionType.java#L50-L69 |
kejunxia/AndroidMvc | library/android-mvc-core/src/main/java/com/shipdream/lib/android/mvc/Controller.java | Controller.runTask | protected <RESULT> Task.Monitor<RESULT> runTask(final Task<RESULT> task) {
"""
Run a task on threads supplied by injected {@link ExecutorService} without a callback. By
default it runs tasks on separate threads by {@link ExecutorService} injected from AndroidMvc
framework. A simple {@link ExecutorService} that runs tasks on the same thread in test cases
to make the test easier.
<p><b>
User the protected property {@link UiThreadRunner} to post action back to main UI thread
in the method block of {@link Task#execute(Task.Monitor)}.
</b></p>
<pre>
uiThreadRunner.post(new Runnable() {
@Override
public void run() {
view.update();
}
});
</pre>
@param task The task
@return The monitor to track the state of the execution of the task. It also can cancel the
task.
"""
return runTask(executorService, task, null);
} | java | protected <RESULT> Task.Monitor<RESULT> runTask(final Task<RESULT> task) {
return runTask(executorService, task, null);
} | [
"protected",
"<",
"RESULT",
">",
"Task",
".",
"Monitor",
"<",
"RESULT",
">",
"runTask",
"(",
"final",
"Task",
"<",
"RESULT",
">",
"task",
")",
"{",
"return",
"runTask",
"(",
"executorService",
",",
"task",
",",
"null",
")",
";",
"}"
] | Run a task on threads supplied by injected {@link ExecutorService} without a callback. By
default it runs tasks on separate threads by {@link ExecutorService} injected from AndroidMvc
framework. A simple {@link ExecutorService} that runs tasks on the same thread in test cases
to make the test easier.
<p><b>
User the protected property {@link UiThreadRunner} to post action back to main UI thread
in the method block of {@link Task#execute(Task.Monitor)}.
</b></p>
<pre>
uiThreadRunner.post(new Runnable() {
@Override
public void run() {
view.update();
}
});
</pre>
@param task The task
@return The monitor to track the state of the execution of the task. It also can cancel the
task. | [
"Run",
"a",
"task",
"on",
"threads",
"supplied",
"by",
"injected",
"{",
"@link",
"ExecutorService",
"}",
"without",
"a",
"callback",
".",
"By",
"default",
"it",
"runs",
"tasks",
"on",
"separate",
"threads",
"by",
"{",
"@link",
"ExecutorService",
"}",
"injected",
"from",
"AndroidMvc",
"framework",
".",
"A",
"simple",
"{",
"@link",
"ExecutorService",
"}",
"that",
"runs",
"tasks",
"on",
"the",
"same",
"thread",
"in",
"test",
"cases",
"to",
"make",
"the",
"test",
"easier",
"."
] | train | https://github.com/kejunxia/AndroidMvc/blob/c7893f0a13119d64297b9eb2988f7323b7da5bbc/library/android-mvc-core/src/main/java/com/shipdream/lib/android/mvc/Controller.java#L158-L160 |
zaproxy/zaproxy | src/org/apache/commons/httpclient/HttpMethodBase.java | HttpMethodBase.readResponseBody | protected void readResponseBody(HttpState state, HttpConnection conn)
throws IOException, HttpException {
"""
Read the response body from the given {@link HttpConnection}.
<p>
The current implementation wraps the socket level stream with
an appropriate stream for the type of response (chunked, content-length,
or auto-close). If there is no response body, the connection associated
with the request will be returned to the connection manager.
</p>
<p>
Subclasses may want to override this method to to customize the
processing.
</p>
@param state the {@link HttpState state} information associated with this method
@param conn the {@link HttpConnection connection} used to execute
this HTTP method
@throws IOException if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.
@throws HttpException if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.
@see #readResponse
@see #processResponseBody
"""
LOG.trace(
"enter HttpMethodBase.readResponseBody(HttpState, HttpConnection)");
// assume we are not done with the connection if we get a stream
InputStream stream = readResponseBody(conn);
if (stream == null) {
// done using the connection!
responseBodyConsumed();
} else {
conn.setLastResponseInputStream(stream);
setResponseStream(stream);
}
} | java | protected void readResponseBody(HttpState state, HttpConnection conn)
throws IOException, HttpException {
LOG.trace(
"enter HttpMethodBase.readResponseBody(HttpState, HttpConnection)");
// assume we are not done with the connection if we get a stream
InputStream stream = readResponseBody(conn);
if (stream == null) {
// done using the connection!
responseBodyConsumed();
} else {
conn.setLastResponseInputStream(stream);
setResponseStream(stream);
}
} | [
"protected",
"void",
"readResponseBody",
"(",
"HttpState",
"state",
",",
"HttpConnection",
"conn",
")",
"throws",
"IOException",
",",
"HttpException",
"{",
"LOG",
".",
"trace",
"(",
"\"enter HttpMethodBase.readResponseBody(HttpState, HttpConnection)\"",
")",
";",
"// assume we are not done with the connection if we get a stream",
"InputStream",
"stream",
"=",
"readResponseBody",
"(",
"conn",
")",
";",
"if",
"(",
"stream",
"==",
"null",
")",
"{",
"// done using the connection!",
"responseBodyConsumed",
"(",
")",
";",
"}",
"else",
"{",
"conn",
".",
"setLastResponseInputStream",
"(",
"stream",
")",
";",
"setResponseStream",
"(",
"stream",
")",
";",
"}",
"}"
] | Read the response body from the given {@link HttpConnection}.
<p>
The current implementation wraps the socket level stream with
an appropriate stream for the type of response (chunked, content-length,
or auto-close). If there is no response body, the connection associated
with the request will be returned to the connection manager.
</p>
<p>
Subclasses may want to override this method to to customize the
processing.
</p>
@param state the {@link HttpState state} information associated with this method
@param conn the {@link HttpConnection connection} used to execute
this HTTP method
@throws IOException if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.
@throws HttpException if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.
@see #readResponse
@see #processResponseBody | [
"Read",
"the",
"response",
"body",
"from",
"the",
"given",
"{",
"@link",
"HttpConnection",
"}",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/apache/commons/httpclient/HttpMethodBase.java#L1913-L1927 |
infinispan/infinispan | lock/src/main/java/org/infinispan/lock/impl/lock/RequestExpirationScheduler.java | RequestExpirationScheduler.scheduleForCompletion | public void scheduleForCompletion(String requestId, CompletableFuture<Boolean> request, long time, TimeUnit unit) {
"""
Schedules a request for completion
@param requestId, the unique identifier if the request
@param request, the request
@param time, time expressed in long
@param unit, {@link TimeUnit}
"""
if (request.isDone()) {
if (trace) {
log.tracef("Request[%s] is not scheduled because is already done", requestId);
}
return;
}
if (scheduledRequests.containsKey(requestId)) {
String message = String.format("Request[%s] is not scheduled because it is already scheduled", requestId);
log.error(message);
throw new IllegalStateException(message);
}
if (trace) {
log.tracef("Request[%s] being scheduled to be completed in [%d, %s]", requestId, time, unit);
}
ScheduledFuture<?> scheduledFuture = scheduledExecutorService.schedule(() -> {
request.complete(false);
scheduledRequests.remove(requestId);
}, time, unit);
scheduledRequests.putIfAbsent(requestId, new ScheduledRequest(request, scheduledFuture));
} | java | public void scheduleForCompletion(String requestId, CompletableFuture<Boolean> request, long time, TimeUnit unit) {
if (request.isDone()) {
if (trace) {
log.tracef("Request[%s] is not scheduled because is already done", requestId);
}
return;
}
if (scheduledRequests.containsKey(requestId)) {
String message = String.format("Request[%s] is not scheduled because it is already scheduled", requestId);
log.error(message);
throw new IllegalStateException(message);
}
if (trace) {
log.tracef("Request[%s] being scheduled to be completed in [%d, %s]", requestId, time, unit);
}
ScheduledFuture<?> scheduledFuture = scheduledExecutorService.schedule(() -> {
request.complete(false);
scheduledRequests.remove(requestId);
}, time, unit);
scheduledRequests.putIfAbsent(requestId, new ScheduledRequest(request, scheduledFuture));
} | [
"public",
"void",
"scheduleForCompletion",
"(",
"String",
"requestId",
",",
"CompletableFuture",
"<",
"Boolean",
">",
"request",
",",
"long",
"time",
",",
"TimeUnit",
"unit",
")",
"{",
"if",
"(",
"request",
".",
"isDone",
"(",
")",
")",
"{",
"if",
"(",
"trace",
")",
"{",
"log",
".",
"tracef",
"(",
"\"Request[%s] is not scheduled because is already done\"",
",",
"requestId",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"scheduledRequests",
".",
"containsKey",
"(",
"requestId",
")",
")",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Request[%s] is not scheduled because it is already scheduled\"",
",",
"requestId",
")",
";",
"log",
".",
"error",
"(",
"message",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"message",
")",
";",
"}",
"if",
"(",
"trace",
")",
"{",
"log",
".",
"tracef",
"(",
"\"Request[%s] being scheduled to be completed in [%d, %s]\"",
",",
"requestId",
",",
"time",
",",
"unit",
")",
";",
"}",
"ScheduledFuture",
"<",
"?",
">",
"scheduledFuture",
"=",
"scheduledExecutorService",
".",
"schedule",
"(",
"(",
")",
"->",
"{",
"request",
".",
"complete",
"(",
"false",
")",
";",
"scheduledRequests",
".",
"remove",
"(",
"requestId",
")",
";",
"}",
",",
"time",
",",
"unit",
")",
";",
"scheduledRequests",
".",
"putIfAbsent",
"(",
"requestId",
",",
"new",
"ScheduledRequest",
"(",
"request",
",",
"scheduledFuture",
")",
")",
";",
"}"
] | Schedules a request for completion
@param requestId, the unique identifier if the request
@param request, the request
@param time, time expressed in long
@param unit, {@link TimeUnit} | [
"Schedules",
"a",
"request",
"for",
"completion"
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/lock/src/main/java/org/infinispan/lock/impl/lock/RequestExpirationScheduler.java#L58-L82 |
alkacon/opencms-core | src-setup/org/opencms/setup/db/update6to7/postgresql/CmsUpdateDBAlterTables.java | CmsUpdateDBAlterTables.initReplacer | private void initReplacer(Map<String, String> replacer, String tableName, String fieldName) {
"""
Initializes the replacer.<p>
@param replacer the replacer
@param tableName the table name
@param fieldName the field name
"""
replacer.clear();
replacer.put(REPLACEMENT_TABLENAME, tableName);
replacer.put(REPLACEMENT_FIELD_NAME, fieldName);
} | java | private void initReplacer(Map<String, String> replacer, String tableName, String fieldName) {
replacer.clear();
replacer.put(REPLACEMENT_TABLENAME, tableName);
replacer.put(REPLACEMENT_FIELD_NAME, fieldName);
} | [
"private",
"void",
"initReplacer",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"replacer",
",",
"String",
"tableName",
",",
"String",
"fieldName",
")",
"{",
"replacer",
".",
"clear",
"(",
")",
";",
"replacer",
".",
"put",
"(",
"REPLACEMENT_TABLENAME",
",",
"tableName",
")",
";",
"replacer",
".",
"put",
"(",
"REPLACEMENT_FIELD_NAME",
",",
"fieldName",
")",
";",
"}"
] | Initializes the replacer.<p>
@param replacer the replacer
@param tableName the table name
@param fieldName the field name | [
"Initializes",
"the",
"replacer",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-setup/org/opencms/setup/db/update6to7/postgresql/CmsUpdateDBAlterTables.java#L178-L183 |
DDTH/ddth-commons | ddth-commons-core/src/main/java/com/github/ddth/commons/utils/DPathUtils.java | DPathUtils.getValue | public static <T> T getValue(JsonNode node, String dPath, Class<T> clazz) {
"""
Extract a value from the target {@link JsonNode} using DPath expression (generic
version).
@param node
@param dPath
@param clazz
@return
@since 0.6.2
"""
if (clazz == null) {
throw new NullPointerException("Class parameter is null!");
}
JsonNode temp = getValue(node, dPath);
return ValueUtils.convertValue(temp, clazz);
} | java | public static <T> T getValue(JsonNode node, String dPath, Class<T> clazz) {
if (clazz == null) {
throw new NullPointerException("Class parameter is null!");
}
JsonNode temp = getValue(node, dPath);
return ValueUtils.convertValue(temp, clazz);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"getValue",
"(",
"JsonNode",
"node",
",",
"String",
"dPath",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Class parameter is null!\"",
")",
";",
"}",
"JsonNode",
"temp",
"=",
"getValue",
"(",
"node",
",",
"dPath",
")",
";",
"return",
"ValueUtils",
".",
"convertValue",
"(",
"temp",
",",
"clazz",
")",
";",
"}"
] | Extract a value from the target {@link JsonNode} using DPath expression (generic
version).
@param node
@param dPath
@param clazz
@return
@since 0.6.2 | [
"Extract",
"a",
"value",
"from",
"the",
"target",
"{",
"@link",
"JsonNode",
"}",
"using",
"DPath",
"expression",
"(",
"generic",
"version",
")",
"."
] | train | https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/DPathUtils.java#L462-L468 |
buschmais/extended-objects | impl/src/main/java/com/buschmais/xo/impl/AbstractInstanceManager.java | AbstractInstanceManager.getInstance | private <T> T getInstance(DatastoreType datastoreType, TransactionalCache.Mode cacheMode) {
"""
Return the proxy instance which corresponds to the given datastore type.
@param datastoreType
The datastore type.
@param <T>
The instance type.
@return The instance.
"""
DatastoreId id = getDatastoreId(datastoreType);
Object instance = cache.get(id, cacheMode);
if (instance == null) {
DynamicType<?> types = getTypes(datastoreType);
instance = newInstance(id, datastoreType, types, cacheMode);
if (TransactionalCache.Mode.READ.equals(cacheMode)) {
instanceListenerService.postLoad(instance);
}
}
return (T) instance;
} | java | private <T> T getInstance(DatastoreType datastoreType, TransactionalCache.Mode cacheMode) {
DatastoreId id = getDatastoreId(datastoreType);
Object instance = cache.get(id, cacheMode);
if (instance == null) {
DynamicType<?> types = getTypes(datastoreType);
instance = newInstance(id, datastoreType, types, cacheMode);
if (TransactionalCache.Mode.READ.equals(cacheMode)) {
instanceListenerService.postLoad(instance);
}
}
return (T) instance;
} | [
"private",
"<",
"T",
">",
"T",
"getInstance",
"(",
"DatastoreType",
"datastoreType",
",",
"TransactionalCache",
".",
"Mode",
"cacheMode",
")",
"{",
"DatastoreId",
"id",
"=",
"getDatastoreId",
"(",
"datastoreType",
")",
";",
"Object",
"instance",
"=",
"cache",
".",
"get",
"(",
"id",
",",
"cacheMode",
")",
";",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"DynamicType",
"<",
"?",
">",
"types",
"=",
"getTypes",
"(",
"datastoreType",
")",
";",
"instance",
"=",
"newInstance",
"(",
"id",
",",
"datastoreType",
",",
"types",
",",
"cacheMode",
")",
";",
"if",
"(",
"TransactionalCache",
".",
"Mode",
".",
"READ",
".",
"equals",
"(",
"cacheMode",
")",
")",
"{",
"instanceListenerService",
".",
"postLoad",
"(",
"instance",
")",
";",
"}",
"}",
"return",
"(",
"T",
")",
"instance",
";",
"}"
] | Return the proxy instance which corresponds to the given datastore type.
@param datastoreType
The datastore type.
@param <T>
The instance type.
@return The instance. | [
"Return",
"the",
"proxy",
"instance",
"which",
"corresponds",
"to",
"the",
"given",
"datastore",
"type",
"."
] | train | https://github.com/buschmais/extended-objects/blob/186431e81f3d8d26c511cfe1143dee59b03c2e7a/impl/src/main/java/com/buschmais/xo/impl/AbstractInstanceManager.java#L89-L100 |
alkacon/opencms-core | src/org/opencms/webdav/CmsWebdavServlet.java | CmsWebdavServlet.doProppatch | protected void doProppatch(HttpServletRequest req, HttpServletResponse resp) {
"""
Process a PROPPATCH WebDAV request for the specified resource.<p>
Not implemented yet.<p>
@param req the servlet request we are processing
@param resp the servlet response we are creating
"""
// Check if Webdav is read only
if (m_readOnly) {
resp.setStatus(CmsWebdavStatus.SC_FORBIDDEN);
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_WEBDAV_READ_ONLY_0));
}
return;
}
// Check if resource is locked
if (isLocked(req)) {
resp.setStatus(CmsWebdavStatus.SC_LOCKED);
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_ITEM_LOCKED_1, getRelativePath(req)));
}
return;
}
resp.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED);
} | java | protected void doProppatch(HttpServletRequest req, HttpServletResponse resp) {
// Check if Webdav is read only
if (m_readOnly) {
resp.setStatus(CmsWebdavStatus.SC_FORBIDDEN);
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_WEBDAV_READ_ONLY_0));
}
return;
}
// Check if resource is locked
if (isLocked(req)) {
resp.setStatus(CmsWebdavStatus.SC_LOCKED);
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(Messages.LOG_ITEM_LOCKED_1, getRelativePath(req)));
}
return;
}
resp.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED);
} | [
"protected",
"void",
"doProppatch",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"resp",
")",
"{",
"// Check if Webdav is read only",
"if",
"(",
"m_readOnly",
")",
"{",
"resp",
".",
"setStatus",
"(",
"CmsWebdavStatus",
".",
"SC_FORBIDDEN",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"LOG_WEBDAV_READ_ONLY_0",
")",
")",
";",
"}",
"return",
";",
"}",
"// Check if resource is locked",
"if",
"(",
"isLocked",
"(",
"req",
")",
")",
"{",
"resp",
".",
"setStatus",
"(",
"CmsWebdavStatus",
".",
"SC_LOCKED",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"LOG_ITEM_LOCKED_1",
",",
"getRelativePath",
"(",
"req",
")",
")",
")",
";",
"}",
"return",
";",
"}",
"resp",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_IMPLEMENTED",
")",
";",
"}"
] | Process a PROPPATCH WebDAV request for the specified resource.<p>
Not implemented yet.<p>
@param req the servlet request we are processing
@param resp the servlet response we are creating | [
"Process",
"a",
"PROPPATCH",
"WebDAV",
"request",
"for",
"the",
"specified",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/webdav/CmsWebdavServlet.java#L1973-L2000 |
CloudSlang/cs-actions | cs-powershell/src/main/java/io/cloudslang/content/services/WSManRemoteShellService.java | WSManRemoteShellService.deleteShell | private void deleteShell(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String shellId, WSManRequestInputs wsManRequestInputs)
throws RuntimeException, IOException, URISyntaxException, TransformerException, XPathExpressionException, SAXException, ParserConfigurationException {
"""
Deletes the remote shell.
@param csHttpClient
@param httpClientInputs
@param shellId
@param wsManRequestInputs
@throws RuntimeException
@throws IOException
@throws URISyntaxException
@throws TransformerException
@throws XPathExpressionException
@throws SAXException
@throws ParserConfigurationException
"""
String documentStr = ResourceLoader.loadAsString(DELETE_SHELL_REQUEST_XML);
documentStr = createDeleteShellRequestBody(documentStr, httpClientInputs.getUrl(), shellId, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout()));
Map<String, String> deleteShellResult = executeRequestWithBody(csHttpClient, httpClientInputs, documentStr);
if (WSManUtils.isSpecificResponseAction(deleteShellResult.get(RETURN_RESULT), DELETE_RESPONSE_ACTION)) {
return;
} else if (WSManUtils.isFaultResponse(deleteShellResult.get(RETURN_RESULT))) {
throw new RuntimeException(WSManUtils.getResponseFault(deleteShellResult.get(RETURN_RESULT)));
} else {
throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + deleteShellResult.get(RETURN_RESULT));
}
} | java | private void deleteShell(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String shellId, WSManRequestInputs wsManRequestInputs)
throws RuntimeException, IOException, URISyntaxException, TransformerException, XPathExpressionException, SAXException, ParserConfigurationException {
String documentStr = ResourceLoader.loadAsString(DELETE_SHELL_REQUEST_XML);
documentStr = createDeleteShellRequestBody(documentStr, httpClientInputs.getUrl(), shellId, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout()));
Map<String, String> deleteShellResult = executeRequestWithBody(csHttpClient, httpClientInputs, documentStr);
if (WSManUtils.isSpecificResponseAction(deleteShellResult.get(RETURN_RESULT), DELETE_RESPONSE_ACTION)) {
return;
} else if (WSManUtils.isFaultResponse(deleteShellResult.get(RETURN_RESULT))) {
throw new RuntimeException(WSManUtils.getResponseFault(deleteShellResult.get(RETURN_RESULT)));
} else {
throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + deleteShellResult.get(RETURN_RESULT));
}
} | [
"private",
"void",
"deleteShell",
"(",
"HttpClientService",
"csHttpClient",
",",
"HttpClientInputs",
"httpClientInputs",
",",
"String",
"shellId",
",",
"WSManRequestInputs",
"wsManRequestInputs",
")",
"throws",
"RuntimeException",
",",
"IOException",
",",
"URISyntaxException",
",",
"TransformerException",
",",
"XPathExpressionException",
",",
"SAXException",
",",
"ParserConfigurationException",
"{",
"String",
"documentStr",
"=",
"ResourceLoader",
".",
"loadAsString",
"(",
"DELETE_SHELL_REQUEST_XML",
")",
";",
"documentStr",
"=",
"createDeleteShellRequestBody",
"(",
"documentStr",
",",
"httpClientInputs",
".",
"getUrl",
"(",
")",
",",
"shellId",
",",
"String",
".",
"valueOf",
"(",
"wsManRequestInputs",
".",
"getMaxEnvelopeSize",
"(",
")",
")",
",",
"wsManRequestInputs",
".",
"getWinrmLocale",
"(",
")",
",",
"String",
".",
"valueOf",
"(",
"wsManRequestInputs",
".",
"getOperationTimeout",
"(",
")",
")",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"deleteShellResult",
"=",
"executeRequestWithBody",
"(",
"csHttpClient",
",",
"httpClientInputs",
",",
"documentStr",
")",
";",
"if",
"(",
"WSManUtils",
".",
"isSpecificResponseAction",
"(",
"deleteShellResult",
".",
"get",
"(",
"RETURN_RESULT",
")",
",",
"DELETE_RESPONSE_ACTION",
")",
")",
"{",
"return",
";",
"}",
"else",
"if",
"(",
"WSManUtils",
".",
"isFaultResponse",
"(",
"deleteShellResult",
".",
"get",
"(",
"RETURN_RESULT",
")",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"WSManUtils",
".",
"getResponseFault",
"(",
"deleteShellResult",
".",
"get",
"(",
"RETURN_RESULT",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"UNEXPECTED_SERVICE_RESPONSE",
"+",
"deleteShellResult",
".",
"get",
"(",
"RETURN_RESULT",
")",
")",
";",
"}",
"}"
] | Deletes the remote shell.
@param csHttpClient
@param httpClientInputs
@param shellId
@param wsManRequestInputs
@throws RuntimeException
@throws IOException
@throws URISyntaxException
@throws TransformerException
@throws XPathExpressionException
@throws SAXException
@throws ParserConfigurationException | [
"Deletes",
"the",
"remote",
"shell",
"."
] | train | https://github.com/CloudSlang/cs-actions/blob/9a1be1e99ad88286a6c153d5f2275df6ae1a57a1/cs-powershell/src/main/java/io/cloudslang/content/services/WSManRemoteShellService.java#L319-L331 |
youngmonkeys/ezyfox-sfs2x | src/main/java/com/tvd12/ezyfox/sfs2x/clienthandler/ClientEventHandler.java | ClientEventHandler.responseClient | private void responseClient(RequestResponseClass clazz, Object listener, User user) {
"""
Response information to client
@param clazz structure of listener class
@param listener listener object
@param user smartfox user
"""
if(!clazz.isResponseToClient()) return;
String command = clazz.getResponseCommand();
ISFSObject params = (ISFSObject) new ParamTransformer(context)
.transform(listener).getObject();
send(command, params, user);
} | java | private void responseClient(RequestResponseClass clazz, Object listener, User user) {
if(!clazz.isResponseToClient()) return;
String command = clazz.getResponseCommand();
ISFSObject params = (ISFSObject) new ParamTransformer(context)
.transform(listener).getObject();
send(command, params, user);
} | [
"private",
"void",
"responseClient",
"(",
"RequestResponseClass",
"clazz",
",",
"Object",
"listener",
",",
"User",
"user",
")",
"{",
"if",
"(",
"!",
"clazz",
".",
"isResponseToClient",
"(",
")",
")",
"return",
";",
"String",
"command",
"=",
"clazz",
".",
"getResponseCommand",
"(",
")",
";",
"ISFSObject",
"params",
"=",
"(",
"ISFSObject",
")",
"new",
"ParamTransformer",
"(",
"context",
")",
".",
"transform",
"(",
"listener",
")",
".",
"getObject",
"(",
")",
";",
"send",
"(",
"command",
",",
"params",
",",
"user",
")",
";",
"}"
] | Response information to client
@param clazz structure of listener class
@param listener listener object
@param user smartfox user | [
"Response",
"information",
"to",
"client"
] | train | https://github.com/youngmonkeys/ezyfox-sfs2x/blob/7e004033a3b551c3ae970a0c8f45db7b1ec144de/src/main/java/com/tvd12/ezyfox/sfs2x/clienthandler/ClientEventHandler.java#L146-L152 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java | NumberUtil.div | public static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale, RoundingMode roundingMode) {
"""
提供(相对)精确的除法运算,当发生除不尽的情况时,由scale指定精确度
@param v1 被除数
@param v2 除数
@param scale 精确度,如果为负值,取绝对值
@param roundingMode 保留小数的模式 {@link RoundingMode}
@return 两个参数的商
@since 3.0.9
"""
Assert.notNull(v2, "Divisor must be not null !");
if (null == v1) {
return BigDecimal.ZERO;
}
if (scale < 0) {
scale = -scale;
}
return v1.divide(v2, scale, roundingMode);
} | java | public static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale, RoundingMode roundingMode) {
Assert.notNull(v2, "Divisor must be not null !");
if (null == v1) {
return BigDecimal.ZERO;
}
if (scale < 0) {
scale = -scale;
}
return v1.divide(v2, scale, roundingMode);
} | [
"public",
"static",
"BigDecimal",
"div",
"(",
"BigDecimal",
"v1",
",",
"BigDecimal",
"v2",
",",
"int",
"scale",
",",
"RoundingMode",
"roundingMode",
")",
"{",
"Assert",
".",
"notNull",
"(",
"v2",
",",
"\"Divisor must be not null !\"",
")",
";",
"if",
"(",
"null",
"==",
"v1",
")",
"{",
"return",
"BigDecimal",
".",
"ZERO",
";",
"}",
"if",
"(",
"scale",
"<",
"0",
")",
"{",
"scale",
"=",
"-",
"scale",
";",
"}",
"return",
"v1",
".",
"divide",
"(",
"v2",
",",
"scale",
",",
"roundingMode",
")",
";",
"}"
] | 提供(相对)精确的除法运算,当发生除不尽的情况时,由scale指定精确度
@param v1 被除数
@param v2 除数
@param scale 精确度,如果为负值,取绝对值
@param roundingMode 保留小数的模式 {@link RoundingMode}
@return 两个参数的商
@since 3.0.9 | [
"提供",
"(",
"相对",
")",
"精确的除法运算",
"当发生除不尽的情况时",
"由scale指定精确度"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java#L741-L750 |
Coveros/selenified | src/main/java/com/coveros/selenified/utilities/Reporter.java | Reporter.formatKeyPair | public static String formatKeyPair(Map<String, Object> keyPairs) {
"""
From an object map passed in, building a key value set, properly html
formatted for used in reporting
@param keyPairs - the key value set
@return String: an html formatting string
"""
if (keyPairs == null) {
return "";
}
StringBuilder stringBuilder = new StringBuilder();
for (Map.Entry<String, Object> entry : keyPairs.entrySet()) {
stringBuilder.append(DIV);
stringBuilder.append(entry.getKey());
stringBuilder.append(" : ");
stringBuilder.append(Reporter.formatHTML(String.valueOf(entry.getValue())));
stringBuilder.append(END_DIV);
}
return stringBuilder.toString();
} | java | public static String formatKeyPair(Map<String, Object> keyPairs) {
if (keyPairs == null) {
return "";
}
StringBuilder stringBuilder = new StringBuilder();
for (Map.Entry<String, Object> entry : keyPairs.entrySet()) {
stringBuilder.append(DIV);
stringBuilder.append(entry.getKey());
stringBuilder.append(" : ");
stringBuilder.append(Reporter.formatHTML(String.valueOf(entry.getValue())));
stringBuilder.append(END_DIV);
}
return stringBuilder.toString();
} | [
"public",
"static",
"String",
"formatKeyPair",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"keyPairs",
")",
"{",
"if",
"(",
"keyPairs",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"StringBuilder",
"stringBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"keyPairs",
".",
"entrySet",
"(",
")",
")",
"{",
"stringBuilder",
".",
"append",
"(",
"DIV",
")",
";",
"stringBuilder",
".",
"append",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"stringBuilder",
".",
"append",
"(",
"\" : \"",
")",
";",
"stringBuilder",
".",
"append",
"(",
"Reporter",
".",
"formatHTML",
"(",
"String",
".",
"valueOf",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
")",
";",
"stringBuilder",
".",
"append",
"(",
"END_DIV",
")",
";",
"}",
"return",
"stringBuilder",
".",
"toString",
"(",
")",
";",
"}"
] | From an object map passed in, building a key value set, properly html
formatted for used in reporting
@param keyPairs - the key value set
@return String: an html formatting string | [
"From",
"an",
"object",
"map",
"passed",
"in",
"building",
"a",
"key",
"value",
"set",
"properly",
"html",
"formatted",
"for",
"used",
"in",
"reporting"
] | train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/utilities/Reporter.java#L875-L888 |
getsentry/sentry-java | sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java | SentryAppender.createAppender | @PluginFactory
@SuppressWarnings("checkstyle:parameternumber")
public static SentryAppender createAppender(@PluginAttribute("name") final String name,
@PluginElement("filter") final Filter filter) {
"""
Create a Sentry Appender.
@param name The name of the Appender.
@param filter The filter, if any, to use.
@return The SentryAppender.
"""
if (name == null) {
LOGGER.error("No name provided for SentryAppender");
return null;
}
return new SentryAppender(name, filter);
} | java | @PluginFactory
@SuppressWarnings("checkstyle:parameternumber")
public static SentryAppender createAppender(@PluginAttribute("name") final String name,
@PluginElement("filter") final Filter filter) {
if (name == null) {
LOGGER.error("No name provided for SentryAppender");
return null;
}
return new SentryAppender(name, filter);
} | [
"@",
"PluginFactory",
"@",
"SuppressWarnings",
"(",
"\"checkstyle:parameternumber\"",
")",
"public",
"static",
"SentryAppender",
"createAppender",
"(",
"@",
"PluginAttribute",
"(",
"\"name\"",
")",
"final",
"String",
"name",
",",
"@",
"PluginElement",
"(",
"\"filter\"",
")",
"final",
"Filter",
"filter",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"No name provided for SentryAppender\"",
")",
";",
"return",
"null",
";",
"}",
"return",
"new",
"SentryAppender",
"(",
"name",
",",
"filter",
")",
";",
"}"
] | Create a Sentry Appender.
@param name The name of the Appender.
@param filter The filter, if any, to use.
@return The SentryAppender. | [
"Create",
"a",
"Sentry",
"Appender",
"."
] | train | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java#L75-L85 |
cybazeitalia/emaze-dysfunctional | src/main/java/net/emaze/dysfunctional/Spies.java | Spies.spy3rd | public static <T1, T2, T3> TriPredicate<T1, T2, T3> spy3rd(TriPredicate<T1, T2, T3> predicate, Box<T3> param3) {
"""
Proxies a ternary predicate spying for third parameter.
@param <T1> the predicate first parameter type
@param <T2> the predicate second parameter type
@param <T3> the predicate third parameter type
@param predicate the predicate that will be spied
@param param3 a box that will be containing the third spied parameter
@return the proxied predicate
"""
return spy(predicate, Box.<Boolean>empty(), Box.<T1>empty(), Box.<T2>empty(), param3);
} | java | public static <T1, T2, T3> TriPredicate<T1, T2, T3> spy3rd(TriPredicate<T1, T2, T3> predicate, Box<T3> param3) {
return spy(predicate, Box.<Boolean>empty(), Box.<T1>empty(), Box.<T2>empty(), param3);
} | [
"public",
"static",
"<",
"T1",
",",
"T2",
",",
"T3",
">",
"TriPredicate",
"<",
"T1",
",",
"T2",
",",
"T3",
">",
"spy3rd",
"(",
"TriPredicate",
"<",
"T1",
",",
"T2",
",",
"T3",
">",
"predicate",
",",
"Box",
"<",
"T3",
">",
"param3",
")",
"{",
"return",
"spy",
"(",
"predicate",
",",
"Box",
".",
"<",
"Boolean",
">",
"empty",
"(",
")",
",",
"Box",
".",
"<",
"T1",
">",
"empty",
"(",
")",
",",
"Box",
".",
"<",
"T2",
">",
"empty",
"(",
")",
",",
"param3",
")",
";",
"}"
] | Proxies a ternary predicate spying for third parameter.
@param <T1> the predicate first parameter type
@param <T2> the predicate second parameter type
@param <T3> the predicate third parameter type
@param predicate the predicate that will be spied
@param param3 a box that will be containing the third spied parameter
@return the proxied predicate | [
"Proxies",
"a",
"ternary",
"predicate",
"spying",
"for",
"third",
"parameter",
"."
] | train | https://github.com/cybazeitalia/emaze-dysfunctional/blob/98115a436e35335c5e8831f9fdc12f6d93d524be/src/main/java/net/emaze/dysfunctional/Spies.java#L443-L445 |
googlegenomics/utils-java | src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java | GenomicsFactory.fromServiceAccount | public <T extends AbstractGoogleJsonClient.Builder> T fromServiceAccount(T builder,
String serviceAccountId, File p12File) throws GeneralSecurityException, IOException {
"""
Prepare an AbstractGoogleJsonClient.Builder with the given service account ID
and private key {@link File}.
@param builder The builder to be prepared.
@param serviceAccountId The service account ID (typically an email address)
@param p12File The file on disk containing the private key
@return The passed in builder, for easy chaining.
@throws GeneralSecurityException
@throws IOException
"""
Preconditions.checkNotNull(builder);
GoogleCredential creds = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountId)
.setServiceAccountScopes(scopes)
.setServiceAccountPrivateKeyFromP12File(p12File)
.build();
creds.refreshToken();
return prepareBuilder(builder, creds, null);
} | java | public <T extends AbstractGoogleJsonClient.Builder> T fromServiceAccount(T builder,
String serviceAccountId, File p12File) throws GeneralSecurityException, IOException {
Preconditions.checkNotNull(builder);
GoogleCredential creds = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountId)
.setServiceAccountScopes(scopes)
.setServiceAccountPrivateKeyFromP12File(p12File)
.build();
creds.refreshToken();
return prepareBuilder(builder, creds, null);
} | [
"public",
"<",
"T",
"extends",
"AbstractGoogleJsonClient",
".",
"Builder",
">",
"T",
"fromServiceAccount",
"(",
"T",
"builder",
",",
"String",
"serviceAccountId",
",",
"File",
"p12File",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"builder",
")",
";",
"GoogleCredential",
"creds",
"=",
"new",
"GoogleCredential",
".",
"Builder",
"(",
")",
".",
"setTransport",
"(",
"httpTransport",
")",
".",
"setJsonFactory",
"(",
"jsonFactory",
")",
".",
"setServiceAccountId",
"(",
"serviceAccountId",
")",
".",
"setServiceAccountScopes",
"(",
"scopes",
")",
".",
"setServiceAccountPrivateKeyFromP12File",
"(",
"p12File",
")",
".",
"build",
"(",
")",
";",
"creds",
".",
"refreshToken",
"(",
")",
";",
"return",
"prepareBuilder",
"(",
"builder",
",",
"creds",
",",
"null",
")",
";",
"}"
] | Prepare an AbstractGoogleJsonClient.Builder with the given service account ID
and private key {@link File}.
@param builder The builder to be prepared.
@param serviceAccountId The service account ID (typically an email address)
@param p12File The file on disk containing the private key
@return The passed in builder, for easy chaining.
@throws GeneralSecurityException
@throws IOException | [
"Prepare",
"an",
"AbstractGoogleJsonClient",
".",
"Builder",
"with",
"the",
"given",
"service",
"account",
"ID",
"and",
"private",
"key",
"{",
"@link",
"File",
"}",
"."
] | train | https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java#L458-L470 |
JOML-CI/JOML | src/org/joml/Matrix4f.java | Matrix4f.translationRotateTowards | public Matrix4f translationRotateTowards(float posX, float posY, float posZ, float dirX, float dirY, float dirZ, float upX, float upY, float upZ) {
"""
Set this matrix to a model transformation for a right-handed coordinate system,
that translates to the given <code>(posX, posY, posZ)</code> and aligns the local <code>-z</code>
axis with <code>(dirX, dirY, dirZ)</code>.
<p>
This method is equivalent to calling: <code>translation(posX, posY, posZ).rotateTowards(dirX, dirY, dirZ, upX, upY, upZ)</code>
@see #translation(float, float, float)
@see #rotateTowards(float, float, float, float, float, float)
@param posX
the x-coordinate of the position to translate to
@param posY
the y-coordinate of the position to translate to
@param posZ
the z-coordinate of the position to translate to
@param dirX
the x-coordinate of the direction to rotate towards
@param dirY
the y-coordinate of the direction to rotate towards
@param dirZ
the z-coordinate of the direction to rotate towards
@param upX
the x-coordinate of the up vector
@param upY
the y-coordinate of the up vector
@param upZ
the z-coordinate of the up vector
@return this
"""
// Normalize direction
float invDirLength = 1.0f / (float) Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
float ndirX = dirX * invDirLength;
float ndirY = dirY * invDirLength;
float ndirZ = dirZ * invDirLength;
// left = up x direction
float leftX, leftY, leftZ;
leftX = upY * ndirZ - upZ * ndirY;
leftY = upZ * ndirX - upX * ndirZ;
leftZ = upX * ndirY - upY * ndirX;
// normalize left
float invLeftLength = 1.0f / (float) Math.sqrt(leftX * leftX + leftY * leftY + leftZ * leftZ);
leftX *= invLeftLength;
leftY *= invLeftLength;
leftZ *= invLeftLength;
// up = direction x left
float upnX = ndirY * leftZ - ndirZ * leftY;
float upnY = ndirZ * leftX - ndirX * leftZ;
float upnZ = ndirX * leftY - ndirY * leftX;
this._m00(leftX);
this._m01(leftY);
this._m02(leftZ);
this._m03(0.0f);
this._m10(upnX);
this._m11(upnY);
this._m12(upnZ);
this._m13(0.0f);
this._m20(ndirX);
this._m21(ndirY);
this._m22(ndirZ);
this._m23(0.0f);
this._m30(posX);
this._m31(posY);
this._m32(posZ);
this._m33(1.0f);
_properties(PROPERTY_AFFINE | PROPERTY_ORTHONORMAL);
return this;
} | java | public Matrix4f translationRotateTowards(float posX, float posY, float posZ, float dirX, float dirY, float dirZ, float upX, float upY, float upZ) {
// Normalize direction
float invDirLength = 1.0f / (float) Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
float ndirX = dirX * invDirLength;
float ndirY = dirY * invDirLength;
float ndirZ = dirZ * invDirLength;
// left = up x direction
float leftX, leftY, leftZ;
leftX = upY * ndirZ - upZ * ndirY;
leftY = upZ * ndirX - upX * ndirZ;
leftZ = upX * ndirY - upY * ndirX;
// normalize left
float invLeftLength = 1.0f / (float) Math.sqrt(leftX * leftX + leftY * leftY + leftZ * leftZ);
leftX *= invLeftLength;
leftY *= invLeftLength;
leftZ *= invLeftLength;
// up = direction x left
float upnX = ndirY * leftZ - ndirZ * leftY;
float upnY = ndirZ * leftX - ndirX * leftZ;
float upnZ = ndirX * leftY - ndirY * leftX;
this._m00(leftX);
this._m01(leftY);
this._m02(leftZ);
this._m03(0.0f);
this._m10(upnX);
this._m11(upnY);
this._m12(upnZ);
this._m13(0.0f);
this._m20(ndirX);
this._m21(ndirY);
this._m22(ndirZ);
this._m23(0.0f);
this._m30(posX);
this._m31(posY);
this._m32(posZ);
this._m33(1.0f);
_properties(PROPERTY_AFFINE | PROPERTY_ORTHONORMAL);
return this;
} | [
"public",
"Matrix4f",
"translationRotateTowards",
"(",
"float",
"posX",
",",
"float",
"posY",
",",
"float",
"posZ",
",",
"float",
"dirX",
",",
"float",
"dirY",
",",
"float",
"dirZ",
",",
"float",
"upX",
",",
"float",
"upY",
",",
"float",
"upZ",
")",
"{",
"// Normalize direction",
"float",
"invDirLength",
"=",
"1.0f",
"/",
"(",
"float",
")",
"Math",
".",
"sqrt",
"(",
"dirX",
"*",
"dirX",
"+",
"dirY",
"*",
"dirY",
"+",
"dirZ",
"*",
"dirZ",
")",
";",
"float",
"ndirX",
"=",
"dirX",
"*",
"invDirLength",
";",
"float",
"ndirY",
"=",
"dirY",
"*",
"invDirLength",
";",
"float",
"ndirZ",
"=",
"dirZ",
"*",
"invDirLength",
";",
"// left = up x direction",
"float",
"leftX",
",",
"leftY",
",",
"leftZ",
";",
"leftX",
"=",
"upY",
"*",
"ndirZ",
"-",
"upZ",
"*",
"ndirY",
";",
"leftY",
"=",
"upZ",
"*",
"ndirX",
"-",
"upX",
"*",
"ndirZ",
";",
"leftZ",
"=",
"upX",
"*",
"ndirY",
"-",
"upY",
"*",
"ndirX",
";",
"// normalize left",
"float",
"invLeftLength",
"=",
"1.0f",
"/",
"(",
"float",
")",
"Math",
".",
"sqrt",
"(",
"leftX",
"*",
"leftX",
"+",
"leftY",
"*",
"leftY",
"+",
"leftZ",
"*",
"leftZ",
")",
";",
"leftX",
"*=",
"invLeftLength",
";",
"leftY",
"*=",
"invLeftLength",
";",
"leftZ",
"*=",
"invLeftLength",
";",
"// up = direction x left",
"float",
"upnX",
"=",
"ndirY",
"*",
"leftZ",
"-",
"ndirZ",
"*",
"leftY",
";",
"float",
"upnY",
"=",
"ndirZ",
"*",
"leftX",
"-",
"ndirX",
"*",
"leftZ",
";",
"float",
"upnZ",
"=",
"ndirX",
"*",
"leftY",
"-",
"ndirY",
"*",
"leftX",
";",
"this",
".",
"_m00",
"(",
"leftX",
")",
";",
"this",
".",
"_m01",
"(",
"leftY",
")",
";",
"this",
".",
"_m02",
"(",
"leftZ",
")",
";",
"this",
".",
"_m03",
"(",
"0.0f",
")",
";",
"this",
".",
"_m10",
"(",
"upnX",
")",
";",
"this",
".",
"_m11",
"(",
"upnY",
")",
";",
"this",
".",
"_m12",
"(",
"upnZ",
")",
";",
"this",
".",
"_m13",
"(",
"0.0f",
")",
";",
"this",
".",
"_m20",
"(",
"ndirX",
")",
";",
"this",
".",
"_m21",
"(",
"ndirY",
")",
";",
"this",
".",
"_m22",
"(",
"ndirZ",
")",
";",
"this",
".",
"_m23",
"(",
"0.0f",
")",
";",
"this",
".",
"_m30",
"(",
"posX",
")",
";",
"this",
".",
"_m31",
"(",
"posY",
")",
";",
"this",
".",
"_m32",
"(",
"posZ",
")",
";",
"this",
".",
"_m33",
"(",
"1.0f",
")",
";",
"_properties",
"(",
"PROPERTY_AFFINE",
"|",
"PROPERTY_ORTHONORMAL",
")",
";",
"return",
"this",
";",
"}"
] | Set this matrix to a model transformation for a right-handed coordinate system,
that translates to the given <code>(posX, posY, posZ)</code> and aligns the local <code>-z</code>
axis with <code>(dirX, dirY, dirZ)</code>.
<p>
This method is equivalent to calling: <code>translation(posX, posY, posZ).rotateTowards(dirX, dirY, dirZ, upX, upY, upZ)</code>
@see #translation(float, float, float)
@see #rotateTowards(float, float, float, float, float, float)
@param posX
the x-coordinate of the position to translate to
@param posY
the y-coordinate of the position to translate to
@param posZ
the z-coordinate of the position to translate to
@param dirX
the x-coordinate of the direction to rotate towards
@param dirY
the y-coordinate of the direction to rotate towards
@param dirZ
the z-coordinate of the direction to rotate towards
@param upX
the x-coordinate of the up vector
@param upY
the y-coordinate of the up vector
@param upZ
the z-coordinate of the up vector
@return this | [
"Set",
"this",
"matrix",
"to",
"a",
"model",
"transformation",
"for",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"that",
"translates",
"to",
"the",
"given",
"<code",
">",
"(",
"posX",
"posY",
"posZ",
")",
"<",
"/",
"code",
">",
"and",
"aligns",
"the",
"local",
"<code",
">",
"-",
"z<",
"/",
"code",
">",
"axis",
"with",
"<code",
">",
"(",
"dirX",
"dirY",
"dirZ",
")",
"<",
"/",
"code",
">",
".",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
":",
"<code",
">",
"translation",
"(",
"posX",
"posY",
"posZ",
")",
".",
"rotateTowards",
"(",
"dirX",
"dirY",
"dirZ",
"upX",
"upY",
"upZ",
")",
"<",
"/",
"code",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4f.java#L14423-L14461 |
facebookarchive/hadoop-20 | src/contrib/corona/src/java/org/apache/hadoop/mapred/CoronaTaskLauncher.java | CoronaTaskLauncher.launchTask | public void launchTask(Task task, String trackerName, InetAddress addr) {
"""
Enqueue a launch task action.
@param task The task to launch.
@param trackerName The name of the tracker to send the task to.
@param addr The address of the tracker to send the task to.
"""
CoronaSessionInfo info = new CoronaSessionInfo(
coronaJT.getSessionId(), coronaJT.getJobTrackerAddress(),
coronaJT.getSecondaryTrackerAddress());
LaunchTaskAction action = new LaunchTaskAction(task, info);
String description = "LaunchTaskAction " + action.getTask().getTaskID();
ActionToSend actionToSend =
new ActionToSend(trackerName, addr, action, description);
LOG.info("Queueing " + description + " to worker " +
trackerName + "(" + addr.host + ":" + addr.port + ")");
allWorkQueues.enqueueAction(actionToSend);
} | java | public void launchTask(Task task, String trackerName, InetAddress addr) {
CoronaSessionInfo info = new CoronaSessionInfo(
coronaJT.getSessionId(), coronaJT.getJobTrackerAddress(),
coronaJT.getSecondaryTrackerAddress());
LaunchTaskAction action = new LaunchTaskAction(task, info);
String description = "LaunchTaskAction " + action.getTask().getTaskID();
ActionToSend actionToSend =
new ActionToSend(trackerName, addr, action, description);
LOG.info("Queueing " + description + " to worker " +
trackerName + "(" + addr.host + ":" + addr.port + ")");
allWorkQueues.enqueueAction(actionToSend);
} | [
"public",
"void",
"launchTask",
"(",
"Task",
"task",
",",
"String",
"trackerName",
",",
"InetAddress",
"addr",
")",
"{",
"CoronaSessionInfo",
"info",
"=",
"new",
"CoronaSessionInfo",
"(",
"coronaJT",
".",
"getSessionId",
"(",
")",
",",
"coronaJT",
".",
"getJobTrackerAddress",
"(",
")",
",",
"coronaJT",
".",
"getSecondaryTrackerAddress",
"(",
")",
")",
";",
"LaunchTaskAction",
"action",
"=",
"new",
"LaunchTaskAction",
"(",
"task",
",",
"info",
")",
";",
"String",
"description",
"=",
"\"LaunchTaskAction \"",
"+",
"action",
".",
"getTask",
"(",
")",
".",
"getTaskID",
"(",
")",
";",
"ActionToSend",
"actionToSend",
"=",
"new",
"ActionToSend",
"(",
"trackerName",
",",
"addr",
",",
"action",
",",
"description",
")",
";",
"LOG",
".",
"info",
"(",
"\"Queueing \"",
"+",
"description",
"+",
"\" to worker \"",
"+",
"trackerName",
"+",
"\"(\"",
"+",
"addr",
".",
"host",
"+",
"\":\"",
"+",
"addr",
".",
"port",
"+",
"\")\"",
")",
";",
"allWorkQueues",
".",
"enqueueAction",
"(",
"actionToSend",
")",
";",
"}"
] | Enqueue a launch task action.
@param task The task to launch.
@param trackerName The name of the tracker to send the task to.
@param addr The address of the tracker to send the task to. | [
"Enqueue",
"a",
"launch",
"task",
"action",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/corona/src/java/org/apache/hadoop/mapred/CoronaTaskLauncher.java#L154-L165 |
JetBrains/xodus | environment/src/main/java/jetbrains/exodus/tree/btree/BTreeBalancePolicy.java | BTreeBalancePolicy.needMerge | public boolean needMerge(@NotNull final BasePage left, @NotNull final BasePage right) {
"""
Is invoked on the leaf deletion only.
@param left left page.
@param right right page.
@return true if the left page ought to be merged with the right one.
"""
final int leftSize = left.getSize();
final int rightSize = right.getSize();
return leftSize == 0 || rightSize == 0 ||
leftSize + rightSize <= (((isDupTree(left) ? getDupPageMaxSize() : getPageMaxSize()) * 7) >> 3);
} | java | public boolean needMerge(@NotNull final BasePage left, @NotNull final BasePage right) {
final int leftSize = left.getSize();
final int rightSize = right.getSize();
return leftSize == 0 || rightSize == 0 ||
leftSize + rightSize <= (((isDupTree(left) ? getDupPageMaxSize() : getPageMaxSize()) * 7) >> 3);
} | [
"public",
"boolean",
"needMerge",
"(",
"@",
"NotNull",
"final",
"BasePage",
"left",
",",
"@",
"NotNull",
"final",
"BasePage",
"right",
")",
"{",
"final",
"int",
"leftSize",
"=",
"left",
".",
"getSize",
"(",
")",
";",
"final",
"int",
"rightSize",
"=",
"right",
".",
"getSize",
"(",
")",
";",
"return",
"leftSize",
"==",
"0",
"||",
"rightSize",
"==",
"0",
"||",
"leftSize",
"+",
"rightSize",
"<=",
"(",
"(",
"(",
"isDupTree",
"(",
"left",
")",
"?",
"getDupPageMaxSize",
"(",
")",
":",
"getPageMaxSize",
"(",
")",
")",
"*",
"7",
")",
">>",
"3",
")",
";",
"}"
] | Is invoked on the leaf deletion only.
@param left left page.
@param right right page.
@return true if the left page ought to be merged with the right one. | [
"Is",
"invoked",
"on",
"the",
"leaf",
"deletion",
"only",
"."
] | train | https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/tree/btree/BTreeBalancePolicy.java#L70-L75 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/EvaluationUtils.java | EvaluationUtils.matthewsCorrelation | public static double matthewsCorrelation(long tp, long fp, long fn, long tn) {
"""
Calculate the binary Matthews correlation coefficient from counts
@param tp True positive count
@param fp False positive counts
@param fn False negative counts
@param tn True negative count
@return Matthews correlation coefficient
"""
double numerator = ((double) tp) * tn - ((double) fp) * fn;
double denominator = Math.sqrt(((double) tp + fp) * (tp + fn) * (tn + fp) * (tn + fn));
return numerator / denominator;
} | java | public static double matthewsCorrelation(long tp, long fp, long fn, long tn) {
double numerator = ((double) tp) * tn - ((double) fp) * fn;
double denominator = Math.sqrt(((double) tp + fp) * (tp + fn) * (tn + fp) * (tn + fn));
return numerator / denominator;
} | [
"public",
"static",
"double",
"matthewsCorrelation",
"(",
"long",
"tp",
",",
"long",
"fp",
",",
"long",
"fn",
",",
"long",
"tn",
")",
"{",
"double",
"numerator",
"=",
"(",
"(",
"double",
")",
"tp",
")",
"*",
"tn",
"-",
"(",
"(",
"double",
")",
"fp",
")",
"*",
"fn",
";",
"double",
"denominator",
"=",
"Math",
".",
"sqrt",
"(",
"(",
"(",
"double",
")",
"tp",
"+",
"fp",
")",
"*",
"(",
"tp",
"+",
"fn",
")",
"*",
"(",
"tn",
"+",
"fp",
")",
"*",
"(",
"tn",
"+",
"fn",
")",
")",
";",
"return",
"numerator",
"/",
"denominator",
";",
"}"
] | Calculate the binary Matthews correlation coefficient from counts
@param tp True positive count
@param fp False positive counts
@param fn False negative counts
@param tn True negative count
@return Matthews correlation coefficient | [
"Calculate",
"the",
"binary",
"Matthews",
"correlation",
"coefficient",
"from",
"counts"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/EvaluationUtils.java#L153-L157 |
alkacon/opencms-core | src-gwt/org/opencms/ade/galleries/client/preview/CmsCroppingParamBean.java | CmsCroppingParamBean.getRestrictedSizeScaleParam | public String getRestrictedSizeScaleParam(int maxHeight, int maxWidth) {
"""
Returns the scale parameter to this bean for a restricted maximum target size.<p>
@param maxHeight the max height
@param maxWidth the max width
@return the scale parameter
"""
String result = toString();
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(result)) {
return getRestrictedSizeParam(maxHeight, maxWidth).toString();
}
if ((getOrgWidth() < maxWidth) && (getOrgHeight() < maxHeight)) {
return "";
}
CmsCroppingParamBean restricted = new CmsCroppingParamBean();
restricted.setTargetHeight(maxHeight);
restricted.setTargetWidth(maxWidth);
return restricted.toString();
} | java | public String getRestrictedSizeScaleParam(int maxHeight, int maxWidth) {
String result = toString();
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(result)) {
return getRestrictedSizeParam(maxHeight, maxWidth).toString();
}
if ((getOrgWidth() < maxWidth) && (getOrgHeight() < maxHeight)) {
return "";
}
CmsCroppingParamBean restricted = new CmsCroppingParamBean();
restricted.setTargetHeight(maxHeight);
restricted.setTargetWidth(maxWidth);
return restricted.toString();
} | [
"public",
"String",
"getRestrictedSizeScaleParam",
"(",
"int",
"maxHeight",
",",
"int",
"maxWidth",
")",
"{",
"String",
"result",
"=",
"toString",
"(",
")",
";",
"if",
"(",
"CmsStringUtil",
".",
"isNotEmptyOrWhitespaceOnly",
"(",
"result",
")",
")",
"{",
"return",
"getRestrictedSizeParam",
"(",
"maxHeight",
",",
"maxWidth",
")",
".",
"toString",
"(",
")",
";",
"}",
"if",
"(",
"(",
"getOrgWidth",
"(",
")",
"<",
"maxWidth",
")",
"&&",
"(",
"getOrgHeight",
"(",
")",
"<",
"maxHeight",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"CmsCroppingParamBean",
"restricted",
"=",
"new",
"CmsCroppingParamBean",
"(",
")",
";",
"restricted",
".",
"setTargetHeight",
"(",
"maxHeight",
")",
";",
"restricted",
".",
"setTargetWidth",
"(",
"maxWidth",
")",
";",
"return",
"restricted",
".",
"toString",
"(",
")",
";",
"}"
] | Returns the scale parameter to this bean for a restricted maximum target size.<p>
@param maxHeight the max height
@param maxWidth the max width
@return the scale parameter | [
"Returns",
"the",
"scale",
"parameter",
"to",
"this",
"bean",
"for",
"a",
"restricted",
"maximum",
"target",
"size",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/preview/CmsCroppingParamBean.java#L363-L376 |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java | Contents.exportXML | public void exportXML(String name, boolean skipBinary, boolean noRecurse) {
"""
Exports contents to the given file.
@param name the name of the file.
@param skipBinary
@param noRecurse
"""
console.jcrService().export(repository, workspace(), path(), name, true, true, new AsyncCallback<Object>() {
@Override
public void onFailure(Throwable caught) {
SC.say(caught.getMessage());
}
@Override
public void onSuccess(Object result) {
SC.say("Complete");
}
});
} | java | public void exportXML(String name, boolean skipBinary, boolean noRecurse) {
console.jcrService().export(repository, workspace(), path(), name, true, true, new AsyncCallback<Object>() {
@Override
public void onFailure(Throwable caught) {
SC.say(caught.getMessage());
}
@Override
public void onSuccess(Object result) {
SC.say("Complete");
}
});
} | [
"public",
"void",
"exportXML",
"(",
"String",
"name",
",",
"boolean",
"skipBinary",
",",
"boolean",
"noRecurse",
")",
"{",
"console",
".",
"jcrService",
"(",
")",
".",
"export",
"(",
"repository",
",",
"workspace",
"(",
")",
",",
"path",
"(",
")",
",",
"name",
",",
"true",
",",
"true",
",",
"new",
"AsyncCallback",
"<",
"Object",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onFailure",
"(",
"Throwable",
"caught",
")",
"{",
"SC",
".",
"say",
"(",
"caught",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onSuccess",
"(",
"Object",
"result",
")",
"{",
"SC",
".",
"say",
"(",
"\"Complete\"",
")",
";",
"}",
"}",
")",
";",
"}"
] | Exports contents to the given file.
@param name the name of the file.
@param skipBinary
@param noRecurse | [
"Exports",
"contents",
"to",
"the",
"given",
"file",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/client/contents/Contents.java#L349-L361 |
ontop/ontop | core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java | OntologyBuilderImpl.addSubPropertyOfAxiom | @Override
public void addSubPropertyOfAxiom(DataPropertyExpression dpe1, DataPropertyExpression dpe2) throws InconsistentOntologyException {
"""
Normalizes and adds a data subproperty axiom
<p>
SubDataPropertyOf := 'SubDataPropertyOf' '(' axiomAnnotations
subDataPropertyExpression superDataPropertyExpression ')'<br>
subDataPropertyExpression := DataPropertyExpression<br>
superDataPropertyExpression := DataPropertyExpression
<p>
implements rule [D1]:<br>
- ignore the axiom if the first argument is owl:bottomDataProperty
or the second argument is owl:topDataProperty<br>
- replace by a disjointness axiom if the second argument is owl:bottomDataProperty
but the first one is not owl:topDataProperty<br>
- inconsistency if the first is owl:topDataProperty but the second is owl:bottomDataProperty
@throws InconsistentOntologyException
"""
checkSignature(dpe1);
checkSignature(dpe2);
dataPropertyAxioms.addInclusion(dpe1, dpe2);
} | java | @Override
public void addSubPropertyOfAxiom(DataPropertyExpression dpe1, DataPropertyExpression dpe2) throws InconsistentOntologyException {
checkSignature(dpe1);
checkSignature(dpe2);
dataPropertyAxioms.addInclusion(dpe1, dpe2);
} | [
"@",
"Override",
"public",
"void",
"addSubPropertyOfAxiom",
"(",
"DataPropertyExpression",
"dpe1",
",",
"DataPropertyExpression",
"dpe2",
")",
"throws",
"InconsistentOntologyException",
"{",
"checkSignature",
"(",
"dpe1",
")",
";",
"checkSignature",
"(",
"dpe2",
")",
";",
"dataPropertyAxioms",
".",
"addInclusion",
"(",
"dpe1",
",",
"dpe2",
")",
";",
"}"
] | Normalizes and adds a data subproperty axiom
<p>
SubDataPropertyOf := 'SubDataPropertyOf' '(' axiomAnnotations
subDataPropertyExpression superDataPropertyExpression ')'<br>
subDataPropertyExpression := DataPropertyExpression<br>
superDataPropertyExpression := DataPropertyExpression
<p>
implements rule [D1]:<br>
- ignore the axiom if the first argument is owl:bottomDataProperty
or the second argument is owl:topDataProperty<br>
- replace by a disjointness axiom if the second argument is owl:bottomDataProperty
but the first one is not owl:topDataProperty<br>
- inconsistency if the first is owl:topDataProperty but the second is owl:bottomDataProperty
@throws InconsistentOntologyException | [
"Normalizes",
"and",
"adds",
"a",
"data",
"subproperty",
"axiom",
"<p",
">",
"SubDataPropertyOf",
":",
"=",
"SubDataPropertyOf",
"(",
"axiomAnnotations",
"subDataPropertyExpression",
"superDataPropertyExpression",
")",
"<br",
">",
"subDataPropertyExpression",
":",
"=",
"DataPropertyExpression<br",
">",
"superDataPropertyExpression",
":",
"=",
"DataPropertyExpression",
"<p",
">",
"implements",
"rule",
"[",
"D1",
"]",
":",
"<br",
">",
"-",
"ignore",
"the",
"axiom",
"if",
"the",
"first",
"argument",
"is",
"owl",
":",
"bottomDataProperty",
"or",
"the",
"second",
"argument",
"is",
"owl",
":",
"topDataProperty<br",
">",
"-",
"replace",
"by",
"a",
"disjointness",
"axiom",
"if",
"the",
"second",
"argument",
"is",
"owl",
":",
"bottomDataProperty",
"but",
"the",
"first",
"one",
"is",
"not",
"owl",
":",
"topDataProperty<br",
">",
"-",
"inconsistency",
"if",
"the",
"first",
"is",
"owl",
":",
"topDataProperty",
"but",
"the",
"second",
"is",
"owl",
":",
"bottomDataProperty"
] | train | https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java#L293-L298 |
loldevs/riotapi | rest/src/main/java/net/boreeas/riotapi/rest/ThrottledApiHandler.java | ThrottledApiHandler.getMaps | public Future<MapDataOverview> getMaps(String version, String locale) {
"""
<p>
Retrieve map information
</p>
This method does not count towards the rate limit
@param version The data dragon version.
@param locale The locale information.
@return The list of all available maps.
@see <a href="https://developer.riotgames.com/api/methods#!/931">The official api documentation</a>
"""
return new DummyFuture<>(handler.getMaps(version, locale));
} | java | public Future<MapDataOverview> getMaps(String version, String locale) {
return new DummyFuture<>(handler.getMaps(version, locale));
} | [
"public",
"Future",
"<",
"MapDataOverview",
">",
"getMaps",
"(",
"String",
"version",
",",
"String",
"locale",
")",
"{",
"return",
"new",
"DummyFuture",
"<>",
"(",
"handler",
".",
"getMaps",
"(",
"version",
",",
"locale",
")",
")",
";",
"}"
] | <p>
Retrieve map information
</p>
This method does not count towards the rate limit
@param version The data dragon version.
@param locale The locale information.
@return The list of all available maps.
@see <a href="https://developer.riotgames.com/api/methods#!/931">The official api documentation</a> | [
"<p",
">",
"Retrieve",
"map",
"information",
"<",
"/",
"p",
">",
"This",
"method",
"does",
"not",
"count",
"towards",
"the",
"rate",
"limit"
] | train | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/rest/src/main/java/net/boreeas/riotapi/rest/ThrottledApiHandler.java#L867-L869 |
contentful/contentful-management.java | src/main/java/com/contentful/java/cma/ModuleAssets.java | ModuleAssets.fetchAll | public CMAArray<CMAAsset> fetchAll(Map<String, String> map) {
"""
Fetch all Assets matching a query using configured space id and environment id.
<p>
This fetch uses the default parameter defined in {@link DefaultQueryParameter#FETCH}
@param map the query to narrow down the results.
@return matching assets.
@throws IllegalArgumentException if configured space id is null.
@throws IllegalArgumentException if configured environment id is null.
@see CMAClient.Builder#setSpaceId(String)
@see CMAClient.Builder#setEnvironmentId(String)
"""
return fetchAll(spaceId, environmentId, map);
} | java | public CMAArray<CMAAsset> fetchAll(Map<String, String> map) {
return fetchAll(spaceId, environmentId, map);
} | [
"public",
"CMAArray",
"<",
"CMAAsset",
">",
"fetchAll",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"map",
")",
"{",
"return",
"fetchAll",
"(",
"spaceId",
",",
"environmentId",
",",
"map",
")",
";",
"}"
] | Fetch all Assets matching a query using configured space id and environment id.
<p>
This fetch uses the default parameter defined in {@link DefaultQueryParameter#FETCH}
@param map the query to narrow down the results.
@return matching assets.
@throws IllegalArgumentException if configured space id is null.
@throws IllegalArgumentException if configured environment id is null.
@see CMAClient.Builder#setSpaceId(String)
@see CMAClient.Builder#setEnvironmentId(String) | [
"Fetch",
"all",
"Assets",
"matching",
"a",
"query",
"using",
"configured",
"space",
"id",
"and",
"environment",
"id",
".",
"<p",
">",
"This",
"fetch",
"uses",
"the",
"default",
"parameter",
"defined",
"in",
"{",
"@link",
"DefaultQueryParameter#FETCH",
"}"
] | train | https://github.com/contentful/contentful-management.java/blob/ca310fb9ea9577fcff0ca57949ab7c2315fa2534/src/main/java/com/contentful/java/cma/ModuleAssets.java#L179-L181 |
jhunters/jprotobuf | v3/src/main/java/com/baidu/bjf/remoting/protobuf/ProtobufIDLProxy.java | ProtobufIDLProxy.generateProtobufDefinedForField | private static void generateProtobufDefinedForField(StringBuilder code, FieldElement field, Set<String> enumNames) {
"""
to generate @Protobuf defined code for target field.
@param code the code
@param field the field
@param enumNames the enum names
"""
code.append("@").append(Protobuf.class.getSimpleName()).append("(");
String fieldType = fieldTypeMapping.get(getTypeName(field));
if (fieldType == null) {
if (enumNames.contains(getTypeName(field))) {
fieldType = "FieldType.ENUM";
} else {
if (field.type().kind() == DataType.Kind.MAP) {
fieldType = "FieldType.MAP";
} else {
fieldType = "FieldType.OBJECT";
}
}
}
code.append("fieldType=").append(fieldType);
code.append(", order=").append(field.tag());
if (FieldElement.Label.OPTIONAL == field.label()) {
code.append(", required=false");
} else if (Label.REQUIRED == field.label()) {
code.append(", required=true");
}
code.append(")\n");
} | java | private static void generateProtobufDefinedForField(StringBuilder code, FieldElement field, Set<String> enumNames) {
code.append("@").append(Protobuf.class.getSimpleName()).append("(");
String fieldType = fieldTypeMapping.get(getTypeName(field));
if (fieldType == null) {
if (enumNames.contains(getTypeName(field))) {
fieldType = "FieldType.ENUM";
} else {
if (field.type().kind() == DataType.Kind.MAP) {
fieldType = "FieldType.MAP";
} else {
fieldType = "FieldType.OBJECT";
}
}
}
code.append("fieldType=").append(fieldType);
code.append(", order=").append(field.tag());
if (FieldElement.Label.OPTIONAL == field.label()) {
code.append(", required=false");
} else if (Label.REQUIRED == field.label()) {
code.append(", required=true");
}
code.append(")\n");
} | [
"private",
"static",
"void",
"generateProtobufDefinedForField",
"(",
"StringBuilder",
"code",
",",
"FieldElement",
"field",
",",
"Set",
"<",
"String",
">",
"enumNames",
")",
"{",
"code",
".",
"append",
"(",
"\"@\"",
")",
".",
"append",
"(",
"Protobuf",
".",
"class",
".",
"getSimpleName",
"(",
")",
")",
".",
"append",
"(",
"\"(\"",
")",
";",
"String",
"fieldType",
"=",
"fieldTypeMapping",
".",
"get",
"(",
"getTypeName",
"(",
"field",
")",
")",
";",
"if",
"(",
"fieldType",
"==",
"null",
")",
"{",
"if",
"(",
"enumNames",
".",
"contains",
"(",
"getTypeName",
"(",
"field",
")",
")",
")",
"{",
"fieldType",
"=",
"\"FieldType.ENUM\"",
";",
"}",
"else",
"{",
"if",
"(",
"field",
".",
"type",
"(",
")",
".",
"kind",
"(",
")",
"==",
"DataType",
".",
"Kind",
".",
"MAP",
")",
"{",
"fieldType",
"=",
"\"FieldType.MAP\"",
";",
"}",
"else",
"{",
"fieldType",
"=",
"\"FieldType.OBJECT\"",
";",
"}",
"}",
"}",
"code",
".",
"append",
"(",
"\"fieldType=\"",
")",
".",
"append",
"(",
"fieldType",
")",
";",
"code",
".",
"append",
"(",
"\", order=\"",
")",
".",
"append",
"(",
"field",
".",
"tag",
"(",
")",
")",
";",
"if",
"(",
"FieldElement",
".",
"Label",
".",
"OPTIONAL",
"==",
"field",
".",
"label",
"(",
")",
")",
"{",
"code",
".",
"append",
"(",
"\", required=false\"",
")",
";",
"}",
"else",
"if",
"(",
"Label",
".",
"REQUIRED",
"==",
"field",
".",
"label",
"(",
")",
")",
"{",
"code",
".",
"append",
"(",
"\", required=true\"",
")",
";",
"}",
"code",
".",
"append",
"(",
"\")\\n\"",
")",
";",
"}"
] | to generate @Protobuf defined code for target field.
@param code the code
@param field the field
@param enumNames the enum names | [
"to",
"generate",
"@Protobuf",
"defined",
"code",
"for",
"target",
"field",
"."
] | train | https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/v3/src/main/java/com/baidu/bjf/remoting/protobuf/ProtobufIDLProxy.java#L1397-L1423 |
mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java | MapFile.readPoiData | @Override
public MapReadResult readPoiData(Tile upperLeft, Tile lowerRight) {
"""
Reads POI data for an area defined by the tile in the upper left and the tile in
the lower right corner.
This implementation takes the data storage of a MapFile into account for greater efficiency.
@param upperLeft tile that defines the upper left corner of the requested area.
@param lowerRight tile that defines the lower right corner of the requested area.
@return map data for the tile.
"""
return readMapData(upperLeft, lowerRight, Selector.POIS);
} | java | @Override
public MapReadResult readPoiData(Tile upperLeft, Tile lowerRight) {
return readMapData(upperLeft, lowerRight, Selector.POIS);
} | [
"@",
"Override",
"public",
"MapReadResult",
"readPoiData",
"(",
"Tile",
"upperLeft",
",",
"Tile",
"lowerRight",
")",
"{",
"return",
"readMapData",
"(",
"upperLeft",
",",
"lowerRight",
",",
"Selector",
".",
"POIS",
")",
";",
"}"
] | Reads POI data for an area defined by the tile in the upper left and the tile in
the lower right corner.
This implementation takes the data storage of a MapFile into account for greater efficiency.
@param upperLeft tile that defines the upper left corner of the requested area.
@param lowerRight tile that defines the lower right corner of the requested area.
@return map data for the tile. | [
"Reads",
"POI",
"data",
"for",
"an",
"area",
"defined",
"by",
"the",
"tile",
"in",
"the",
"upper",
"left",
"and",
"the",
"tile",
"in",
"the",
"lower",
"right",
"corner",
".",
"This",
"implementation",
"takes",
"the",
"data",
"storage",
"of",
"a",
"MapFile",
"into",
"account",
"for",
"greater",
"efficiency",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java#L951-L954 |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/user/UserManager.java | UserManager.areUserIDAndPasswordValid | public boolean areUserIDAndPasswordValid (@Nullable final String sUserID, @Nullable final String sPlainTextPassword) {
"""
Check if the passed combination of user ID and password matches.
@param sUserID
The ID of the user
@param sPlainTextPassword
The plan text password to validate.
@return <code>true</code> if the password hash matches the stored hash for
the specified user, <code>false</code> otherwise.
"""
// No password is not allowed
if (sPlainTextPassword == null)
return false;
// Is there such a user?
final IUser aUser = getOfID (sUserID);
if (aUser == null)
return false;
// Now compare the hashes
final String sPasswordHashAlgorithm = aUser.getPasswordHash ().getAlgorithmName ();
final IPasswordSalt aSalt = aUser.getPasswordHash ().getSalt ();
final PasswordHash aPasswordHash = GlobalPasswordSettings.createUserPasswordHash (sPasswordHashAlgorithm,
aSalt,
sPlainTextPassword);
return aUser.getPasswordHash ().equals (aPasswordHash);
} | java | public boolean areUserIDAndPasswordValid (@Nullable final String sUserID, @Nullable final String sPlainTextPassword)
{
// No password is not allowed
if (sPlainTextPassword == null)
return false;
// Is there such a user?
final IUser aUser = getOfID (sUserID);
if (aUser == null)
return false;
// Now compare the hashes
final String sPasswordHashAlgorithm = aUser.getPasswordHash ().getAlgorithmName ();
final IPasswordSalt aSalt = aUser.getPasswordHash ().getSalt ();
final PasswordHash aPasswordHash = GlobalPasswordSettings.createUserPasswordHash (sPasswordHashAlgorithm,
aSalt,
sPlainTextPassword);
return aUser.getPasswordHash ().equals (aPasswordHash);
} | [
"public",
"boolean",
"areUserIDAndPasswordValid",
"(",
"@",
"Nullable",
"final",
"String",
"sUserID",
",",
"@",
"Nullable",
"final",
"String",
"sPlainTextPassword",
")",
"{",
"// No password is not allowed",
"if",
"(",
"sPlainTextPassword",
"==",
"null",
")",
"return",
"false",
";",
"// Is there such a user?",
"final",
"IUser",
"aUser",
"=",
"getOfID",
"(",
"sUserID",
")",
";",
"if",
"(",
"aUser",
"==",
"null",
")",
"return",
"false",
";",
"// Now compare the hashes",
"final",
"String",
"sPasswordHashAlgorithm",
"=",
"aUser",
".",
"getPasswordHash",
"(",
")",
".",
"getAlgorithmName",
"(",
")",
";",
"final",
"IPasswordSalt",
"aSalt",
"=",
"aUser",
".",
"getPasswordHash",
"(",
")",
".",
"getSalt",
"(",
")",
";",
"final",
"PasswordHash",
"aPasswordHash",
"=",
"GlobalPasswordSettings",
".",
"createUserPasswordHash",
"(",
"sPasswordHashAlgorithm",
",",
"aSalt",
",",
"sPlainTextPassword",
")",
";",
"return",
"aUser",
".",
"getPasswordHash",
"(",
")",
".",
"equals",
"(",
"aPasswordHash",
")",
";",
"}"
] | Check if the passed combination of user ID and password matches.
@param sUserID
The ID of the user
@param sPlainTextPassword
The plan text password to validate.
@return <code>true</code> if the password hash matches the stored hash for
the specified user, <code>false</code> otherwise. | [
"Check",
"if",
"the",
"passed",
"combination",
"of",
"user",
"ID",
"and",
"password",
"matches",
"."
] | train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/user/UserManager.java#L749-L767 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen_health_monitor_misc.java | xen_health_monitor_misc.get_nitro_bulk_response | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception {
"""
<pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre>
"""
xen_health_monitor_misc_responses result = (xen_health_monitor_misc_responses) service.get_payload_formatter().string_to_resource(xen_health_monitor_misc_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.xen_health_monitor_misc_response_array);
}
xen_health_monitor_misc[] result_xen_health_monitor_misc = new xen_health_monitor_misc[result.xen_health_monitor_misc_response_array.length];
for(int i = 0; i < result.xen_health_monitor_misc_response_array.length; i++)
{
result_xen_health_monitor_misc[i] = result.xen_health_monitor_misc_response_array[i].xen_health_monitor_misc[0];
}
return result_xen_health_monitor_misc;
} | java | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
xen_health_monitor_misc_responses result = (xen_health_monitor_misc_responses) service.get_payload_formatter().string_to_resource(xen_health_monitor_misc_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.xen_health_monitor_misc_response_array);
}
xen_health_monitor_misc[] result_xen_health_monitor_misc = new xen_health_monitor_misc[result.xen_health_monitor_misc_response_array.length];
for(int i = 0; i < result.xen_health_monitor_misc_response_array.length; i++)
{
result_xen_health_monitor_misc[i] = result.xen_health_monitor_misc_response_array[i].xen_health_monitor_misc[0];
}
return result_xen_health_monitor_misc;
} | [
"protected",
"base_resource",
"[",
"]",
"get_nitro_bulk_response",
"(",
"nitro_service",
"service",
",",
"String",
"response",
")",
"throws",
"Exception",
"{",
"xen_health_monitor_misc_responses",
"result",
"=",
"(",
"xen_health_monitor_misc_responses",
")",
"service",
".",
"get_payload_formatter",
"(",
")",
".",
"string_to_resource",
"(",
"xen_health_monitor_misc_responses",
".",
"class",
",",
"response",
")",
";",
"if",
"(",
"result",
".",
"errorcode",
"!=",
"0",
")",
"{",
"if",
"(",
"result",
".",
"errorcode",
"==",
"SESSION_NOT_EXISTS",
")",
"service",
".",
"clear_session",
"(",
")",
";",
"throw",
"new",
"nitro_exception",
"(",
"result",
".",
"message",
",",
"result",
".",
"errorcode",
",",
"(",
"base_response",
"[",
"]",
")",
"result",
".",
"xen_health_monitor_misc_response_array",
")",
";",
"}",
"xen_health_monitor_misc",
"[",
"]",
"result_xen_health_monitor_misc",
"=",
"new",
"xen_health_monitor_misc",
"[",
"result",
".",
"xen_health_monitor_misc_response_array",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"xen_health_monitor_misc_response_array",
".",
"length",
";",
"i",
"++",
")",
"{",
"result_xen_health_monitor_misc",
"[",
"i",
"]",
"=",
"result",
".",
"xen_health_monitor_misc_response_array",
"[",
"i",
"]",
".",
"xen_health_monitor_misc",
"[",
"0",
"]",
";",
"}",
"return",
"result_xen_health_monitor_misc",
";",
"}"
] | <pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre> | [
"<pre",
">",
"Converts",
"API",
"response",
"of",
"bulk",
"operation",
"into",
"object",
"and",
"returns",
"the",
"object",
"array",
"in",
"case",
"of",
"get",
"request",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen_health_monitor_misc.java#L173-L190 |
datacleaner/AnalyzerBeans | core/src/main/java/org/eobjects/analyzer/lifecycle/LifeCycleHelper.java | LifeCycleHelper.assignProvidedProperties | public void assignProvidedProperties(ComponentDescriptor<?> descriptor, Object component) {
"""
Assigns/injects {@link Provided} property values to a component.
@param descriptor
@param component
"""
AssignProvidedCallback callback = new AssignProvidedCallback(_injectionManager);
callback.onEvent(component, descriptor);
} | java | public void assignProvidedProperties(ComponentDescriptor<?> descriptor, Object component) {
AssignProvidedCallback callback = new AssignProvidedCallback(_injectionManager);
callback.onEvent(component, descriptor);
} | [
"public",
"void",
"assignProvidedProperties",
"(",
"ComponentDescriptor",
"<",
"?",
">",
"descriptor",
",",
"Object",
"component",
")",
"{",
"AssignProvidedCallback",
"callback",
"=",
"new",
"AssignProvidedCallback",
"(",
"_injectionManager",
")",
";",
"callback",
".",
"onEvent",
"(",
"component",
",",
"descriptor",
")",
";",
"}"
] | Assigns/injects {@link Provided} property values to a component.
@param descriptor
@param component | [
"Assigns",
"/",
"injects",
"{",
"@link",
"Provided",
"}",
"property",
"values",
"to",
"a",
"component",
"."
] | train | https://github.com/datacleaner/AnalyzerBeans/blob/f82dae080d80d2a647b706a5fb22b3ea250613b3/core/src/main/java/org/eobjects/analyzer/lifecycle/LifeCycleHelper.java#L134-L137 |
loldevs/riotapi | rest/src/main/java/net/boreeas/riotapi/rest/ThrottledApiHandler.java | ThrottledApiHandler.getRune | public Future<Item> getRune(int id, ItemData data, String version, String locale) {
"""
<p>
Retrieve a specific runes
</p>
This method does not count towards the rate limit and is not affected by the throttle
@param id The id of the runes
@param data Additional information to retrieve
@param version Data dragon version for returned data
@param locale Locale code for returned data
@return The runes
@see <a href=https://developer.riotgames.com/api/methods#!/649/2168>Official API documentation</a>
"""
return new DummyFuture<>(handler.getRune(id, data, version, locale));
} | java | public Future<Item> getRune(int id, ItemData data, String version, String locale) {
return new DummyFuture<>(handler.getRune(id, data, version, locale));
} | [
"public",
"Future",
"<",
"Item",
">",
"getRune",
"(",
"int",
"id",
",",
"ItemData",
"data",
",",
"String",
"version",
",",
"String",
"locale",
")",
"{",
"return",
"new",
"DummyFuture",
"<>",
"(",
"handler",
".",
"getRune",
"(",
"id",
",",
"data",
",",
"version",
",",
"locale",
")",
")",
";",
"}"
] | <p>
Retrieve a specific runes
</p>
This method does not count towards the rate limit and is not affected by the throttle
@param id The id of the runes
@param data Additional information to retrieve
@param version Data dragon version for returned data
@param locale Locale code for returned data
@return The runes
@see <a href=https://developer.riotgames.com/api/methods#!/649/2168>Official API documentation</a> | [
"<p",
">",
"Retrieve",
"a",
"specific",
"runes",
"<",
"/",
"p",
">",
"This",
"method",
"does",
"not",
"count",
"towards",
"the",
"rate",
"limit",
"and",
"is",
"not",
"affected",
"by",
"the",
"throttle"
] | train | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/rest/src/main/java/net/boreeas/riotapi/rest/ThrottledApiHandler.java#L700-L702 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java | HtmlTree.TABLE | public static HtmlTree TABLE(HtmlStyle styleClass, int border, int cellPadding,
int cellSpacing, String summary, Content body) {
"""
Generates a Table tag with style class, border, cell padding,
cellspacing and summary attributes and some content.
@param styleClass style of the table
@param border border for the table
@param cellPadding cell padding for the table
@param cellSpacing cell spacing for the table
@param summary summary for the table
@param body content for the table
@return an HtmlTree object for the TABLE tag
"""
HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body));
if (styleClass != null)
htmltree.addStyle(styleClass);
htmltree.addAttr(HtmlAttr.BORDER, Integer.toString(border));
htmltree.addAttr(HtmlAttr.CELLPADDING, Integer.toString(cellPadding));
htmltree.addAttr(HtmlAttr.CELLSPACING, Integer.toString(cellSpacing));
htmltree.addAttr(HtmlAttr.SUMMARY, nullCheck(summary));
return htmltree;
} | java | public static HtmlTree TABLE(HtmlStyle styleClass, int border, int cellPadding,
int cellSpacing, String summary, Content body) {
HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body));
if (styleClass != null)
htmltree.addStyle(styleClass);
htmltree.addAttr(HtmlAttr.BORDER, Integer.toString(border));
htmltree.addAttr(HtmlAttr.CELLPADDING, Integer.toString(cellPadding));
htmltree.addAttr(HtmlAttr.CELLSPACING, Integer.toString(cellSpacing));
htmltree.addAttr(HtmlAttr.SUMMARY, nullCheck(summary));
return htmltree;
} | [
"public",
"static",
"HtmlTree",
"TABLE",
"(",
"HtmlStyle",
"styleClass",
",",
"int",
"border",
",",
"int",
"cellPadding",
",",
"int",
"cellSpacing",
",",
"String",
"summary",
",",
"Content",
"body",
")",
"{",
"HtmlTree",
"htmltree",
"=",
"new",
"HtmlTree",
"(",
"HtmlTag",
".",
"TABLE",
",",
"nullCheck",
"(",
"body",
")",
")",
";",
"if",
"(",
"styleClass",
"!=",
"null",
")",
"htmltree",
".",
"addStyle",
"(",
"styleClass",
")",
";",
"htmltree",
".",
"addAttr",
"(",
"HtmlAttr",
".",
"BORDER",
",",
"Integer",
".",
"toString",
"(",
"border",
")",
")",
";",
"htmltree",
".",
"addAttr",
"(",
"HtmlAttr",
".",
"CELLPADDING",
",",
"Integer",
".",
"toString",
"(",
"cellPadding",
")",
")",
";",
"htmltree",
".",
"addAttr",
"(",
"HtmlAttr",
".",
"CELLSPACING",
",",
"Integer",
".",
"toString",
"(",
"cellSpacing",
")",
")",
";",
"htmltree",
".",
"addAttr",
"(",
"HtmlAttr",
".",
"SUMMARY",
",",
"nullCheck",
"(",
"summary",
")",
")",
";",
"return",
"htmltree",
";",
"}"
] | Generates a Table tag with style class, border, cell padding,
cellspacing and summary attributes and some content.
@param styleClass style of the table
@param border border for the table
@param cellPadding cell padding for the table
@param cellSpacing cell spacing for the table
@param summary summary for the table
@param body content for the table
@return an HtmlTree object for the TABLE tag | [
"Generates",
"a",
"Table",
"tag",
"with",
"style",
"class",
"border",
"cell",
"padding",
"cellspacing",
"and",
"summary",
"attributes",
"and",
"some",
"content",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java#L638-L648 |
wildfly/wildfly-core | launcher/src/main/java/org/wildfly/core/launcher/StandaloneCommandBuilder.java | StandaloneCommandBuilder.addSecurityProperty | public StandaloneCommandBuilder addSecurityProperty(final String key, final String value) {
"""
Adds a security property to be passed to the server.
@param key the property key
@param value the property value
@return the builder
"""
securityProperties.put(key, value);
return this;
} | java | public StandaloneCommandBuilder addSecurityProperty(final String key, final String value) {
securityProperties.put(key, value);
return this;
} | [
"public",
"StandaloneCommandBuilder",
"addSecurityProperty",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"value",
")",
"{",
"securityProperties",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Adds a security property to be passed to the server.
@param key the property key
@param value the property value
@return the builder | [
"Adds",
"a",
"security",
"property",
"to",
"be",
"passed",
"to",
"the",
"server",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/launcher/src/main/java/org/wildfly/core/launcher/StandaloneCommandBuilder.java#L390-L393 |
DependencyWatcher/agent | src/main/java/com/dependencywatcher/collector/DataArchiver.java | DataArchiver.add | public void add(String file, String contents) throws IOException {
"""
Create new file in the data archive
@param file File name
@param contents File contents
@throws IOException
"""
FileUtils.writeStringToFile(tempDir.resolve(file).toFile(), contents);
} | java | public void add(String file, String contents) throws IOException {
FileUtils.writeStringToFile(tempDir.resolve(file).toFile(), contents);
} | [
"public",
"void",
"add",
"(",
"String",
"file",
",",
"String",
"contents",
")",
"throws",
"IOException",
"{",
"FileUtils",
".",
"writeStringToFile",
"(",
"tempDir",
".",
"resolve",
"(",
"file",
")",
".",
"toFile",
"(",
")",
",",
"contents",
")",
";",
"}"
] | Create new file in the data archive
@param file File name
@param contents File contents
@throws IOException | [
"Create",
"new",
"file",
"in",
"the",
"data",
"archive"
] | train | https://github.com/DependencyWatcher/agent/blob/6a082650275f9555993f5607d1f0bbe7aceceee1/src/main/java/com/dependencywatcher/collector/DataArchiver.java#L56-L58 |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/Includer.java | Includer.sendError | public static void sendError(HttpServletRequest request, HttpServletResponse response, int status, String message) throws IOException {
"""
Sends an error. When not in an included page, calls sendError directly.
When inside of an include will set request attribute so outermost include can call sendError.
"""
if(request.getAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME) == null) {
// Not included, sendError directly
if(message == null) {
response.sendError(status);
} else {
response.sendError(status, message);
}
} else {
// Is included, set attributes so top level tag can perform actual sendError call
request.setAttribute(STATUS_REQUEST_ATTRIBUTE_NAME, status);
request.setAttribute(MESSAGE_REQUEST_ATTRIBUTE_NAME, message);
}
} | java | public static void sendError(HttpServletRequest request, HttpServletResponse response, int status, String message) throws IOException {
if(request.getAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME) == null) {
// Not included, sendError directly
if(message == null) {
response.sendError(status);
} else {
response.sendError(status, message);
}
} else {
// Is included, set attributes so top level tag can perform actual sendError call
request.setAttribute(STATUS_REQUEST_ATTRIBUTE_NAME, status);
request.setAttribute(MESSAGE_REQUEST_ATTRIBUTE_NAME, message);
}
} | [
"public",
"static",
"void",
"sendError",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"int",
"status",
",",
"String",
"message",
")",
"throws",
"IOException",
"{",
"if",
"(",
"request",
".",
"getAttribute",
"(",
"IS_INCLUDED_REQUEST_ATTRIBUTE_NAME",
")",
"==",
"null",
")",
"{",
"// Not included, sendError directly",
"if",
"(",
"message",
"==",
"null",
")",
"{",
"response",
".",
"sendError",
"(",
"status",
")",
";",
"}",
"else",
"{",
"response",
".",
"sendError",
"(",
"status",
",",
"message",
")",
";",
"}",
"}",
"else",
"{",
"// Is included, set attributes so top level tag can perform actual sendError call",
"request",
".",
"setAttribute",
"(",
"STATUS_REQUEST_ATTRIBUTE_NAME",
",",
"status",
")",
";",
"request",
".",
"setAttribute",
"(",
"MESSAGE_REQUEST_ATTRIBUTE_NAME",
",",
"message",
")",
";",
"}",
"}"
] | Sends an error. When not in an included page, calls sendError directly.
When inside of an include will set request attribute so outermost include can call sendError. | [
"Sends",
"an",
"error",
".",
"When",
"not",
"in",
"an",
"included",
"page",
"calls",
"sendError",
"directly",
".",
"When",
"inside",
"of",
"an",
"include",
"will",
"set",
"request",
"attribute",
"so",
"outermost",
"include",
"can",
"call",
"sendError",
"."
] | train | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/Includer.java#L141-L154 |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/Nodes.java | Nodes.centerNode | public static void centerNode(final Node node, final Double marginSize) {
"""
Centers a node that is inside an enclosing {@link AnchorPane}.
@param node The node to center
@param marginSize The margins to keep on the sides
"""
AnchorPane.setTopAnchor(node, marginSize);
AnchorPane.setBottomAnchor(node, marginSize);
AnchorPane.setLeftAnchor(node, marginSize);
AnchorPane.setRightAnchor(node, marginSize);
} | java | public static void centerNode(final Node node, final Double marginSize) {
AnchorPane.setTopAnchor(node, marginSize);
AnchorPane.setBottomAnchor(node, marginSize);
AnchorPane.setLeftAnchor(node, marginSize);
AnchorPane.setRightAnchor(node, marginSize);
} | [
"public",
"static",
"void",
"centerNode",
"(",
"final",
"Node",
"node",
",",
"final",
"Double",
"marginSize",
")",
"{",
"AnchorPane",
".",
"setTopAnchor",
"(",
"node",
",",
"marginSize",
")",
";",
"AnchorPane",
".",
"setBottomAnchor",
"(",
"node",
",",
"marginSize",
")",
";",
"AnchorPane",
".",
"setLeftAnchor",
"(",
"node",
",",
"marginSize",
")",
";",
"AnchorPane",
".",
"setRightAnchor",
"(",
"node",
",",
"marginSize",
")",
";",
"}"
] | Centers a node that is inside an enclosing {@link AnchorPane}.
@param node The node to center
@param marginSize The margins to keep on the sides | [
"Centers",
"a",
"node",
"that",
"is",
"inside",
"an",
"enclosing",
"{",
"@link",
"AnchorPane",
"}",
"."
] | train | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Nodes.java#L21-L26 |
Azure/azure-sdk-for-java | logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/WorkflowsInner.java | WorkflowsInner.listCallbackUrl | public WorkflowTriggerCallbackUrlInner listCallbackUrl(String resourceGroupName, String workflowName, GetCallbackUrlParameters listCallbackUrl) {
"""
Get the workflow callback Url.
@param resourceGroupName The resource group name.
@param workflowName The workflow name.
@param listCallbackUrl Which callback url to list.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the WorkflowTriggerCallbackUrlInner object if successful.
"""
return listCallbackUrlWithServiceResponseAsync(resourceGroupName, workflowName, listCallbackUrl).toBlocking().single().body();
} | java | public WorkflowTriggerCallbackUrlInner listCallbackUrl(String resourceGroupName, String workflowName, GetCallbackUrlParameters listCallbackUrl) {
return listCallbackUrlWithServiceResponseAsync(resourceGroupName, workflowName, listCallbackUrl).toBlocking().single().body();
} | [
"public",
"WorkflowTriggerCallbackUrlInner",
"listCallbackUrl",
"(",
"String",
"resourceGroupName",
",",
"String",
"workflowName",
",",
"GetCallbackUrlParameters",
"listCallbackUrl",
")",
"{",
"return",
"listCallbackUrlWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"workflowName",
",",
"listCallbackUrl",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Get the workflow callback Url.
@param resourceGroupName The resource group name.
@param workflowName The workflow name.
@param listCallbackUrl Which callback url to list.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the WorkflowTriggerCallbackUrlInner object if successful. | [
"Get",
"the",
"workflow",
"callback",
"Url",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/WorkflowsInner.java#L1313-L1315 |
liferay/com-liferay-commerce | commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountRelPersistenceImpl.java | CommerceDiscountRelPersistenceImpl.findByCN_CPK | @Override
public List<CommerceDiscountRel> findByCN_CPK(long classNameId,
long classPK, int start, int end) {
"""
Returns a range of all the commerce discount rels where classNameId = ? and classPK = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceDiscountRelModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param classNameId the class name ID
@param classPK the class pk
@param start the lower bound of the range of commerce discount rels
@param end the upper bound of the range of commerce discount rels (not inclusive)
@return the range of matching commerce discount rels
"""
return findByCN_CPK(classNameId, classPK, start, end, null);
} | java | @Override
public List<CommerceDiscountRel> findByCN_CPK(long classNameId,
long classPK, int start, int end) {
return findByCN_CPK(classNameId, classPK, start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceDiscountRel",
">",
"findByCN_CPK",
"(",
"long",
"classNameId",
",",
"long",
"classPK",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByCN_CPK",
"(",
"classNameId",
",",
"classPK",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the commerce discount rels where classNameId = ? and classPK = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceDiscountRelModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param classNameId the class name ID
@param classPK the class pk
@param start the lower bound of the range of commerce discount rels
@param end the upper bound of the range of commerce discount rels (not inclusive)
@return the range of matching commerce discount rels | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"discount",
"rels",
"where",
"classNameId",
"=",
"?",
";",
"and",
"classPK",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountRelPersistenceImpl.java#L1225-L1229 |
maven-nar/nar-maven-plugin | src/main/java/com/github/maven_nar/cpptasks/DistributerMap.java | DistributerMap.toRemote | public String toRemote(final String host, final File localFile) {
"""
Converts the local file name to the remote name for the same file.
@param host
host
@param localFile
local file
@return remote name for local file, null if unknown.
"""
if (this.remoteName != null && (this.hosts == null || this.hosts.contains(host))) {
try {
final String canonical = localFile.getCanonicalPath();
if (canonical.startsWith(this.canonicalPath) && isActive()) {
return this.remoteName
+ canonical.substring(this.canonicalPath.length()).replace(File.separatorChar, this.remoteSeparator);
}
} catch (final IOException ex) {
return null;
}
}
return null;
} | java | public String toRemote(final String host, final File localFile) {
if (this.remoteName != null && (this.hosts == null || this.hosts.contains(host))) {
try {
final String canonical = localFile.getCanonicalPath();
if (canonical.startsWith(this.canonicalPath) && isActive()) {
return this.remoteName
+ canonical.substring(this.canonicalPath.length()).replace(File.separatorChar, this.remoteSeparator);
}
} catch (final IOException ex) {
return null;
}
}
return null;
} | [
"public",
"String",
"toRemote",
"(",
"final",
"String",
"host",
",",
"final",
"File",
"localFile",
")",
"{",
"if",
"(",
"this",
".",
"remoteName",
"!=",
"null",
"&&",
"(",
"this",
".",
"hosts",
"==",
"null",
"||",
"this",
".",
"hosts",
".",
"contains",
"(",
"host",
")",
")",
")",
"{",
"try",
"{",
"final",
"String",
"canonical",
"=",
"localFile",
".",
"getCanonicalPath",
"(",
")",
";",
"if",
"(",
"canonical",
".",
"startsWith",
"(",
"this",
".",
"canonicalPath",
")",
"&&",
"isActive",
"(",
")",
")",
"{",
"return",
"this",
".",
"remoteName",
"+",
"canonical",
".",
"substring",
"(",
"this",
".",
"canonicalPath",
".",
"length",
"(",
")",
")",
".",
"replace",
"(",
"File",
".",
"separatorChar",
",",
"this",
".",
"remoteSeparator",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Converts the local file name to the remote name for the same file.
@param host
host
@param localFile
local file
@return remote name for local file, null if unknown. | [
"Converts",
"the",
"local",
"file",
"name",
"to",
"the",
"remote",
"name",
"for",
"the",
"same",
"file",
"."
] | train | https://github.com/maven-nar/nar-maven-plugin/blob/3c622e2024296b4203431bbae3bde290a01dac00/src/main/java/com/github/maven_nar/cpptasks/DistributerMap.java#L210-L223 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/SourceLineAnnotation.java | SourceLineAnnotation.forEntireMethod | public static SourceLineAnnotation forEntireMethod(JavaClass javaClass, @CheckForNull Method method) {
"""
Create a SourceLineAnnotation covering an entire method.
@param javaClass
JavaClass containing the method
@param method
the method
@return a SourceLineAnnotation for the entire method
"""
String sourceFile = javaClass.getSourceFileName();
if (method == null) {
return createUnknown(javaClass.getClassName(), sourceFile);
}
Code code = method.getCode();
LineNumberTable lineNumberTable = method.getLineNumberTable();
if (code == null || lineNumberTable == null) {
return createUnknown(javaClass.getClassName(), sourceFile);
}
return forEntireMethod(javaClass.getClassName(), sourceFile, lineNumberTable, code.getLength());
} | java | public static SourceLineAnnotation forEntireMethod(JavaClass javaClass, @CheckForNull Method method) {
String sourceFile = javaClass.getSourceFileName();
if (method == null) {
return createUnknown(javaClass.getClassName(), sourceFile);
}
Code code = method.getCode();
LineNumberTable lineNumberTable = method.getLineNumberTable();
if (code == null || lineNumberTable == null) {
return createUnknown(javaClass.getClassName(), sourceFile);
}
return forEntireMethod(javaClass.getClassName(), sourceFile, lineNumberTable, code.getLength());
} | [
"public",
"static",
"SourceLineAnnotation",
"forEntireMethod",
"(",
"JavaClass",
"javaClass",
",",
"@",
"CheckForNull",
"Method",
"method",
")",
"{",
"String",
"sourceFile",
"=",
"javaClass",
".",
"getSourceFileName",
"(",
")",
";",
"if",
"(",
"method",
"==",
"null",
")",
"{",
"return",
"createUnknown",
"(",
"javaClass",
".",
"getClassName",
"(",
")",
",",
"sourceFile",
")",
";",
"}",
"Code",
"code",
"=",
"method",
".",
"getCode",
"(",
")",
";",
"LineNumberTable",
"lineNumberTable",
"=",
"method",
".",
"getLineNumberTable",
"(",
")",
";",
"if",
"(",
"code",
"==",
"null",
"||",
"lineNumberTable",
"==",
"null",
")",
"{",
"return",
"createUnknown",
"(",
"javaClass",
".",
"getClassName",
"(",
")",
",",
"sourceFile",
")",
";",
"}",
"return",
"forEntireMethod",
"(",
"javaClass",
".",
"getClassName",
"(",
")",
",",
"sourceFile",
",",
"lineNumberTable",
",",
"code",
".",
"getLength",
"(",
")",
")",
";",
"}"
] | Create a SourceLineAnnotation covering an entire method.
@param javaClass
JavaClass containing the method
@param method
the method
@return a SourceLineAnnotation for the entire method | [
"Create",
"a",
"SourceLineAnnotation",
"covering",
"an",
"entire",
"method",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/SourceLineAnnotation.java#L281-L293 |
undertow-io/undertow | core/src/main/java/io/undertow/Handlers.java | Handlers.virtualHost | public static NameVirtualHostHandler virtualHost(final HttpHandler hostHandler, String... hostnames) {
"""
Creates a new virtual host handler that uses the provided handler as the root handler for the given hostnames.
@param hostHandler The host handler
@param hostnames The host names
@return A new virtual host handler
"""
NameVirtualHostHandler handler = new NameVirtualHostHandler();
for (String host : hostnames) {
handler.addHost(host, hostHandler);
}
return handler;
} | java | public static NameVirtualHostHandler virtualHost(final HttpHandler hostHandler, String... hostnames) {
NameVirtualHostHandler handler = new NameVirtualHostHandler();
for (String host : hostnames) {
handler.addHost(host, hostHandler);
}
return handler;
} | [
"public",
"static",
"NameVirtualHostHandler",
"virtualHost",
"(",
"final",
"HttpHandler",
"hostHandler",
",",
"String",
"...",
"hostnames",
")",
"{",
"NameVirtualHostHandler",
"handler",
"=",
"new",
"NameVirtualHostHandler",
"(",
")",
";",
"for",
"(",
"String",
"host",
":",
"hostnames",
")",
"{",
"handler",
".",
"addHost",
"(",
"host",
",",
"hostHandler",
")",
";",
"}",
"return",
"handler",
";",
"}"
] | Creates a new virtual host handler that uses the provided handler as the root handler for the given hostnames.
@param hostHandler The host handler
@param hostnames The host names
@return A new virtual host handler | [
"Creates",
"a",
"new",
"virtual",
"host",
"handler",
"that",
"uses",
"the",
"provided",
"handler",
"as",
"the",
"root",
"handler",
"for",
"the",
"given",
"hostnames",
"."
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/Handlers.java#L151-L157 |
micronaut-projects/micronaut-core | core/src/main/java/io/micronaut/core/annotation/AnnotationValue.java | AnnotationValue.getRequiredValue | public @Nonnull final <T> T getRequiredValue(String member, Class<T> type) {
"""
Get the value of the {@code value} member of the annotation.
@param member The member
@param type The type
@param <T> The type
@throws IllegalStateException If no member is available that conforms to the given name and type
@return The result
"""
return get(member, ConversionContext.of(type)).orElseThrow(() -> new IllegalStateException("No value available for annotation member @" + annotationName + "[" + member + "] of type: " + type));
} | java | public @Nonnull final <T> T getRequiredValue(String member, Class<T> type) {
return get(member, ConversionContext.of(type)).orElseThrow(() -> new IllegalStateException("No value available for annotation member @" + annotationName + "[" + member + "] of type: " + type));
} | [
"public",
"@",
"Nonnull",
"final",
"<",
"T",
">",
"T",
"getRequiredValue",
"(",
"String",
"member",
",",
"Class",
"<",
"T",
">",
"type",
")",
"{",
"return",
"get",
"(",
"member",
",",
"ConversionContext",
".",
"of",
"(",
"type",
")",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalStateException",
"(",
"\"No value available for annotation member @\"",
"+",
"annotationName",
"+",
"\"[\"",
"+",
"member",
"+",
"\"] of type: \"",
"+",
"type",
")",
")",
";",
"}"
] | Get the value of the {@code value} member of the annotation.
@param member The member
@param type The type
@param <T> The type
@throws IllegalStateException If no member is available that conforms to the given name and type
@return The result | [
"Get",
"the",
"value",
"of",
"the",
"{",
"@code",
"value",
"}",
"member",
"of",
"the",
"annotation",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/core/src/main/java/io/micronaut/core/annotation/AnnotationValue.java#L223-L225 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/br/br_configuresyslog.java | br_configuresyslog.get_nitro_bulk_response | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception {
"""
<pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre>
"""
br_configuresyslog_responses result = (br_configuresyslog_responses) service.get_payload_formatter().string_to_resource(br_configuresyslog_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.br_configuresyslog_response_array);
}
br_configuresyslog[] result_br_configuresyslog = new br_configuresyslog[result.br_configuresyslog_response_array.length];
for(int i = 0; i < result.br_configuresyslog_response_array.length; i++)
{
result_br_configuresyslog[i] = result.br_configuresyslog_response_array[i].br_configuresyslog[0];
}
return result_br_configuresyslog;
} | java | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
br_configuresyslog_responses result = (br_configuresyslog_responses) service.get_payload_formatter().string_to_resource(br_configuresyslog_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.br_configuresyslog_response_array);
}
br_configuresyslog[] result_br_configuresyslog = new br_configuresyslog[result.br_configuresyslog_response_array.length];
for(int i = 0; i < result.br_configuresyslog_response_array.length; i++)
{
result_br_configuresyslog[i] = result.br_configuresyslog_response_array[i].br_configuresyslog[0];
}
return result_br_configuresyslog;
} | [
"protected",
"base_resource",
"[",
"]",
"get_nitro_bulk_response",
"(",
"nitro_service",
"service",
",",
"String",
"response",
")",
"throws",
"Exception",
"{",
"br_configuresyslog_responses",
"result",
"=",
"(",
"br_configuresyslog_responses",
")",
"service",
".",
"get_payload_formatter",
"(",
")",
".",
"string_to_resource",
"(",
"br_configuresyslog_responses",
".",
"class",
",",
"response",
")",
";",
"if",
"(",
"result",
".",
"errorcode",
"!=",
"0",
")",
"{",
"if",
"(",
"result",
".",
"errorcode",
"==",
"SESSION_NOT_EXISTS",
")",
"service",
".",
"clear_session",
"(",
")",
";",
"throw",
"new",
"nitro_exception",
"(",
"result",
".",
"message",
",",
"result",
".",
"errorcode",
",",
"(",
"base_response",
"[",
"]",
")",
"result",
".",
"br_configuresyslog_response_array",
")",
";",
"}",
"br_configuresyslog",
"[",
"]",
"result_br_configuresyslog",
"=",
"new",
"br_configuresyslog",
"[",
"result",
".",
"br_configuresyslog_response_array",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"br_configuresyslog_response_array",
".",
"length",
";",
"i",
"++",
")",
"{",
"result_br_configuresyslog",
"[",
"i",
"]",
"=",
"result",
".",
"br_configuresyslog_response_array",
"[",
"i",
"]",
".",
"br_configuresyslog",
"[",
"0",
"]",
";",
"}",
"return",
"result_br_configuresyslog",
";",
"}"
] | <pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre> | [
"<pre",
">",
"Converts",
"API",
"response",
"of",
"bulk",
"operation",
"into",
"object",
"and",
"returns",
"the",
"object",
"array",
"in",
"case",
"of",
"get",
"request",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/br/br_configuresyslog.java#L178-L195 |
Nexmo/nexmo-java | src/main/java/com/nexmo/client/voice/VoiceClient.java | VoiceClient.startTalk | public TalkResponse startTalk(String uuid, String text) throws IOException, NexmoClientException {
"""
Send a synthesized speech message to an ongoing call.
<p>
The message will only play once, spoken with the default voice of Kimberly.
@param uuid The UUID of the call, obtained from the object returned by {@link #createCall(Call)}. This value can
be obtained with {@link CallEvent#getUuid()}
@param text The message to be spoken to the call participants.
@return The data returned from the Voice API.
@throws IOException if a network error occurred contacting the Nexmo Voice API.
@throws NexmoClientException if there was a problem with the Nexmo request or response objects.
"""
return talk.put(new TalkRequest(uuid, text));
} | java | public TalkResponse startTalk(String uuid, String text) throws IOException, NexmoClientException {
return talk.put(new TalkRequest(uuid, text));
} | [
"public",
"TalkResponse",
"startTalk",
"(",
"String",
"uuid",
",",
"String",
"text",
")",
"throws",
"IOException",
",",
"NexmoClientException",
"{",
"return",
"talk",
".",
"put",
"(",
"new",
"TalkRequest",
"(",
"uuid",
",",
"text",
")",
")",
";",
"}"
] | Send a synthesized speech message to an ongoing call.
<p>
The message will only play once, spoken with the default voice of Kimberly.
@param uuid The UUID of the call, obtained from the object returned by {@link #createCall(Call)}. This value can
be obtained with {@link CallEvent#getUuid()}
@param text The message to be spoken to the call participants.
@return The data returned from the Voice API.
@throws IOException if a network error occurred contacting the Nexmo Voice API.
@throws NexmoClientException if there was a problem with the Nexmo request or response objects. | [
"Send",
"a",
"synthesized",
"speech",
"message",
"to",
"an",
"ongoing",
"call",
".",
"<p",
">",
"The",
"message",
"will",
"only",
"play",
"once",
"spoken",
"with",
"the",
"default",
"voice",
"of",
"Kimberly",
"."
] | train | https://github.com/Nexmo/nexmo-java/blob/7427eff6d6baa5a5bd9197fa096bcf2564191cf5/src/main/java/com/nexmo/client/voice/VoiceClient.java#L255-L257 |
upwork/java-upwork | src/com/Upwork/api/Routers/Messages.java | Messages.updateRoomMetadata | public JSONObject updateRoomMetadata(String company, String roomId, HashMap<String, String> params) throws JSONException {
"""
Update the metadata of a room
@param company Company ID
@param roomId Room ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject}
"""
return oClient.put("/messages/v3/" + company + "/rooms/" + roomId, params);
} | java | public JSONObject updateRoomMetadata(String company, String roomId, HashMap<String, String> params) throws JSONException {
return oClient.put("/messages/v3/" + company + "/rooms/" + roomId, params);
} | [
"public",
"JSONObject",
"updateRoomMetadata",
"(",
"String",
"company",
",",
"String",
"roomId",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"JSONException",
"{",
"return",
"oClient",
".",
"put",
"(",
"\"/messages/v3/\"",
"+",
"company",
"+",
"\"/rooms/\"",
"+",
"roomId",
",",
"params",
")",
";",
"}"
] | Update the metadata of a room
@param company Company ID
@param roomId Room ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject} | [
"Update",
"the",
"metadata",
"of",
"a",
"room"
] | train | https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Messages.java#L153-L155 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.