repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
sarl/sarl
|
main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/SarlCompiler.java
|
SarlCompiler._toJavaStatement
|
@SuppressWarnings("static-method")
protected void _toJavaStatement(SarlBreakExpression breakExpression, ITreeAppendable appendable, boolean isReferenced) {
"""
Generate the Java code related to the preparation statements for the break keyword.
@param breakExpression the expression.
@param appendable the output.
@param isReferenced indicates if the expression is referenced.
"""
appendable.newLine().append("break;"); //$NON-NLS-1$
}
|
java
|
@SuppressWarnings("static-method")
protected void _toJavaStatement(SarlBreakExpression breakExpression, ITreeAppendable appendable, boolean isReferenced) {
appendable.newLine().append("break;"); //$NON-NLS-1$
}
|
[
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"void",
"_toJavaStatement",
"(",
"SarlBreakExpression",
"breakExpression",
",",
"ITreeAppendable",
"appendable",
",",
"boolean",
"isReferenced",
")",
"{",
"appendable",
".",
"newLine",
"(",
")",
".",
"append",
"(",
"\"break;\"",
")",
";",
"//$NON-NLS-1$",
"}"
] |
Generate the Java code related to the preparation statements for the break keyword.
@param breakExpression the expression.
@param appendable the output.
@param isReferenced indicates if the expression is referenced.
|
[
"Generate",
"the",
"Java",
"code",
"related",
"to",
"the",
"preparation",
"statements",
"for",
"the",
"break",
"keyword",
"."
] |
train
|
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/SarlCompiler.java#L528-L531
|
Azure/azure-sdk-for-java
|
marketplaceordering/resource-manager/v2015_06_01/src/main/java/com/microsoft/azure/management/marketplaceordering/v2015_06_01/implementation/MarketplaceAgreementsInner.java
|
MarketplaceAgreementsInner.signAsync
|
public Observable<AgreementTermsInner> signAsync(String publisherId, String offerId, String planId) {
"""
Sign marketplace terms.
@param publisherId Publisher identifier string of image being deployed.
@param offerId Offer identifier string of image being deployed.
@param planId Plan identifier string of image being deployed.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AgreementTermsInner object
"""
return signWithServiceResponseAsync(publisherId, offerId, planId).map(new Func1<ServiceResponse<AgreementTermsInner>, AgreementTermsInner>() {
@Override
public AgreementTermsInner call(ServiceResponse<AgreementTermsInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<AgreementTermsInner> signAsync(String publisherId, String offerId, String planId) {
return signWithServiceResponseAsync(publisherId, offerId, planId).map(new Func1<ServiceResponse<AgreementTermsInner>, AgreementTermsInner>() {
@Override
public AgreementTermsInner call(ServiceResponse<AgreementTermsInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"AgreementTermsInner",
">",
"signAsync",
"(",
"String",
"publisherId",
",",
"String",
"offerId",
",",
"String",
"planId",
")",
"{",
"return",
"signWithServiceResponseAsync",
"(",
"publisherId",
",",
"offerId",
",",
"planId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"AgreementTermsInner",
">",
",",
"AgreementTermsInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"AgreementTermsInner",
"call",
"(",
"ServiceResponse",
"<",
"AgreementTermsInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Sign marketplace terms.
@param publisherId Publisher identifier string of image being deployed.
@param offerId Offer identifier string of image being deployed.
@param planId Plan identifier string of image being deployed.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AgreementTermsInner object
|
[
"Sign",
"marketplace",
"terms",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/marketplaceordering/resource-manager/v2015_06_01/src/main/java/com/microsoft/azure/management/marketplaceordering/v2015_06_01/implementation/MarketplaceAgreementsInner.java#L322-L329
|
TheHortonMachine/hortonmachine
|
gears/src/main/java/org/hortonmachine/gears/libs/modules/HMModel.java
|
HMModel.dumpRaster
|
public void dumpRaster( GridCoverage2D raster, String source ) throws Exception {
"""
Fast default writing of raster to source.
<p>Mind that if either raster or source are <code>null</code>, the method will
return without warning.</p>
@param raster the {@link GridCoverage2D} to write.
@param source the source to which to write to.
@throws Exception
"""
if (raster == null || source == null)
return;
OmsRasterWriter writer = new OmsRasterWriter();
writer.pm = pm;
writer.inRaster = raster;
writer.file = source;
writer.process();
}
|
java
|
public void dumpRaster( GridCoverage2D raster, String source ) throws Exception {
if (raster == null || source == null)
return;
OmsRasterWriter writer = new OmsRasterWriter();
writer.pm = pm;
writer.inRaster = raster;
writer.file = source;
writer.process();
}
|
[
"public",
"void",
"dumpRaster",
"(",
"GridCoverage2D",
"raster",
",",
"String",
"source",
")",
"throws",
"Exception",
"{",
"if",
"(",
"raster",
"==",
"null",
"||",
"source",
"==",
"null",
")",
"return",
";",
"OmsRasterWriter",
"writer",
"=",
"new",
"OmsRasterWriter",
"(",
")",
";",
"writer",
".",
"pm",
"=",
"pm",
";",
"writer",
".",
"inRaster",
"=",
"raster",
";",
"writer",
".",
"file",
"=",
"source",
";",
"writer",
".",
"process",
"(",
")",
";",
"}"
] |
Fast default writing of raster to source.
<p>Mind that if either raster or source are <code>null</code>, the method will
return without warning.</p>
@param raster the {@link GridCoverage2D} to write.
@param source the source to which to write to.
@throws Exception
|
[
"Fast",
"default",
"writing",
"of",
"raster",
"to",
"source",
"."
] |
train
|
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/libs/modules/HMModel.java#L321-L329
|
JosePaumard/streams-utils
|
src/main/java/org/paumard/streams/StreamsUtils.java
|
StreamsUtils.shiftingWindowSummarizingDouble
|
public static <E> Stream<DoubleSummaryStatistics> shiftingWindowSummarizingDouble(Stream<E> stream, int rollingFactor, ToDoubleFunction<? super E> mapper) {
"""
<p>Generates a stream that is computed from a provided stream following two steps.</p>
<p>The first steps maps this stream to a <code>DoubleStream</code> that is then rolled following
the same principle as the <code>roll()</code> method. This steps builds a <code>Stream<DoubleStream></code>.
</p>
<p>Then double summary statistics are computed on each <code>DoubleStream</code> using a <code>collect()</code> call,
and a <code>Stream<DoubleSummaryStatistics></code> is returned.</p>
<p>The resulting stream has the same number of elements as the provided stream,
minus the size of the window width, to preserve consistency of each collection. </p>
<p>A <code>NullPointerException</code> will be thrown if the provided stream is null.</p>
@param stream the processed stream
@param rollingFactor the size of the window to apply the collector on
@param mapper the mapper applied
@param <E> the type of the provided stream
@return a stream in which each value is the collection of the provided stream
"""
Objects.requireNonNull(stream);
Objects.requireNonNull(mapper);
DoubleStream doubleStream = stream.mapToDouble(mapper);
return shiftingWindowSummarizingLong(doubleStream, rollingFactor);
}
|
java
|
public static <E> Stream<DoubleSummaryStatistics> shiftingWindowSummarizingDouble(Stream<E> stream, int rollingFactor, ToDoubleFunction<? super E> mapper) {
Objects.requireNonNull(stream);
Objects.requireNonNull(mapper);
DoubleStream doubleStream = stream.mapToDouble(mapper);
return shiftingWindowSummarizingLong(doubleStream, rollingFactor);
}
|
[
"public",
"static",
"<",
"E",
">",
"Stream",
"<",
"DoubleSummaryStatistics",
">",
"shiftingWindowSummarizingDouble",
"(",
"Stream",
"<",
"E",
">",
"stream",
",",
"int",
"rollingFactor",
",",
"ToDoubleFunction",
"<",
"?",
"super",
"E",
">",
"mapper",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"stream",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"mapper",
")",
";",
"DoubleStream",
"doubleStream",
"=",
"stream",
".",
"mapToDouble",
"(",
"mapper",
")",
";",
"return",
"shiftingWindowSummarizingLong",
"(",
"doubleStream",
",",
"rollingFactor",
")",
";",
"}"
] |
<p>Generates a stream that is computed from a provided stream following two steps.</p>
<p>The first steps maps this stream to a <code>DoubleStream</code> that is then rolled following
the same principle as the <code>roll()</code> method. This steps builds a <code>Stream<DoubleStream></code>.
</p>
<p>Then double summary statistics are computed on each <code>DoubleStream</code> using a <code>collect()</code> call,
and a <code>Stream<DoubleSummaryStatistics></code> is returned.</p>
<p>The resulting stream has the same number of elements as the provided stream,
minus the size of the window width, to preserve consistency of each collection. </p>
<p>A <code>NullPointerException</code> will be thrown if the provided stream is null.</p>
@param stream the processed stream
@param rollingFactor the size of the window to apply the collector on
@param mapper the mapper applied
@param <E> the type of the provided stream
@return a stream in which each value is the collection of the provided stream
|
[
"<p",
">",
"Generates",
"a",
"stream",
"that",
"is",
"computed",
"from",
"a",
"provided",
"stream",
"following",
"two",
"steps",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"first",
"steps",
"maps",
"this",
"stream",
"to",
"a",
"<code",
">",
"DoubleStream<",
"/",
"code",
">",
"that",
"is",
"then",
"rolled",
"following",
"the",
"same",
"principle",
"as",
"the",
"<code",
">",
"roll",
"()",
"<",
"/",
"code",
">",
"method",
".",
"This",
"steps",
"builds",
"a",
"<code",
">",
"Stream<",
";",
"DoubleStream>",
";",
"<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Then",
"double",
"summary",
"statistics",
"are",
"computed",
"on",
"each",
"<code",
">",
"DoubleStream<",
"/",
"code",
">",
"using",
"a",
"<code",
">",
"collect",
"()",
"<",
"/",
"code",
">",
"call",
"and",
"a",
"<code",
">",
"Stream<",
";",
"DoubleSummaryStatistics>",
";",
"<",
"/",
"code",
">",
"is",
"returned",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"resulting",
"stream",
"has",
"the",
"same",
"number",
"of",
"elements",
"as",
"the",
"provided",
"stream",
"minus",
"the",
"size",
"of",
"the",
"window",
"width",
"to",
"preserve",
"consistency",
"of",
"each",
"collection",
".",
"<",
"/",
"p",
">",
"<p",
">",
"A",
"<code",
">",
"NullPointerException<",
"/",
"code",
">",
"will",
"be",
"thrown",
"if",
"the",
"provided",
"stream",
"is",
"null",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/JosePaumard/streams-utils/blob/56152574af0aca44c5f679761202a8f90984ab73/src/main/java/org/paumard/streams/StreamsUtils.java#L804-L810
|
rwl/CSparseJ
|
src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_utsolve.java
|
Dcs_utsolve.cs_utsolve
|
public static boolean cs_utsolve(Dcs U, double[] x) {
"""
Solves a lower triangular system U'x=b, where x and b are dense vectors.
The diagonal of U must be the last entry of each column.
@param U
upper triangular matrix in column-compressed form
@param x
size n, right hand side on input, solution on output
@return true if successful, false on error
"""
int p, j, n, Up[], Ui[];
double Ux[];
if (!Dcs_util.CS_CSC(U) || x == null)
return (false); /* check inputs */
n = U.n;
Up = U.p;
Ui = U.i;
Ux = U.x;
for (j = 0; j < n; j++) {
for (p = Up[j]; p < Up[j + 1] - 1; p++) {
x[j] -= Ux[p] * x[Ui[p]];
}
x[j] /= Ux[Up[j + 1] - 1];
}
return (true);
}
|
java
|
public static boolean cs_utsolve(Dcs U, double[] x) {
int p, j, n, Up[], Ui[];
double Ux[];
if (!Dcs_util.CS_CSC(U) || x == null)
return (false); /* check inputs */
n = U.n;
Up = U.p;
Ui = U.i;
Ux = U.x;
for (j = 0; j < n; j++) {
for (p = Up[j]; p < Up[j + 1] - 1; p++) {
x[j] -= Ux[p] * x[Ui[p]];
}
x[j] /= Ux[Up[j + 1] - 1];
}
return (true);
}
|
[
"public",
"static",
"boolean",
"cs_utsolve",
"(",
"Dcs",
"U",
",",
"double",
"[",
"]",
"x",
")",
"{",
"int",
"p",
",",
"j",
",",
"n",
",",
"Up",
"[",
"]",
",",
"Ui",
"[",
"]",
";",
"double",
"Ux",
"[",
"]",
";",
"if",
"(",
"!",
"Dcs_util",
".",
"CS_CSC",
"(",
"U",
")",
"||",
"x",
"==",
"null",
")",
"return",
"(",
"false",
")",
";",
"/* check inputs */",
"n",
"=",
"U",
".",
"n",
";",
"Up",
"=",
"U",
".",
"p",
";",
"Ui",
"=",
"U",
".",
"i",
";",
"Ux",
"=",
"U",
".",
"x",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"for",
"(",
"p",
"=",
"Up",
"[",
"j",
"]",
";",
"p",
"<",
"Up",
"[",
"j",
"+",
"1",
"]",
"-",
"1",
";",
"p",
"++",
")",
"{",
"x",
"[",
"j",
"]",
"-=",
"Ux",
"[",
"p",
"]",
"*",
"x",
"[",
"Ui",
"[",
"p",
"]",
"]",
";",
"}",
"x",
"[",
"j",
"]",
"/=",
"Ux",
"[",
"Up",
"[",
"j",
"+",
"1",
"]",
"-",
"1",
"]",
";",
"}",
"return",
"(",
"true",
")",
";",
"}"
] |
Solves a lower triangular system U'x=b, where x and b are dense vectors.
The diagonal of U must be the last entry of each column.
@param U
upper triangular matrix in column-compressed form
@param x
size n, right hand side on input, solution on output
@return true if successful, false on error
|
[
"Solves",
"a",
"lower",
"triangular",
"system",
"U",
"x",
"=",
"b",
"where",
"x",
"and",
"b",
"are",
"dense",
"vectors",
".",
"The",
"diagonal",
"of",
"U",
"must",
"be",
"the",
"last",
"entry",
"of",
"each",
"column",
"."
] |
train
|
https://github.com/rwl/CSparseJ/blob/6a6f66bccce1558156a961494358952603b0ac84/src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_utsolve.java#L47-L63
|
Azure/azure-sdk-for-java
|
appservice/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/appservice/v2016_03_01/implementation/CertificatesInner.java
|
CertificatesInner.getByResourceGroupAsync
|
public Observable<CertificateInner> getByResourceGroupAsync(String resourceGroupName, String name) {
"""
Get a certificate.
Get a certificate.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the certificate.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, name).map(new Func1<ServiceResponse<CertificateInner>, CertificateInner>() {
@Override
public CertificateInner call(ServiceResponse<CertificateInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<CertificateInner> getByResourceGroupAsync(String resourceGroupName, String name) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, name).map(new Func1<ServiceResponse<CertificateInner>, CertificateInner>() {
@Override
public CertificateInner call(ServiceResponse<CertificateInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"CertificateInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"CertificateInner",
">",
",",
"CertificateInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CertificateInner",
"call",
"(",
"ServiceResponse",
"<",
"CertificateInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Get a certificate.
Get a certificate.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the certificate.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateInner object
|
[
"Get",
"a",
"certificate",
".",
"Get",
"a",
"certificate",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/appservice/v2016_03_01/implementation/CertificatesInner.java#L373-L380
|
apereo/cas
|
core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java
|
AbstractCasWebflowConfigurer.createExpression
|
public Expression createExpression(final String expression, final Class expectedType) {
"""
Create expression expression.
@param expression the expression
@param expectedType the expected type
@return the expression
"""
val parserContext = new FluentParserContext().expectResult(expectedType);
return getSpringExpressionParser().parseExpression(expression, parserContext);
}
|
java
|
public Expression createExpression(final String expression, final Class expectedType) {
val parserContext = new FluentParserContext().expectResult(expectedType);
return getSpringExpressionParser().parseExpression(expression, parserContext);
}
|
[
"public",
"Expression",
"createExpression",
"(",
"final",
"String",
"expression",
",",
"final",
"Class",
"expectedType",
")",
"{",
"val",
"parserContext",
"=",
"new",
"FluentParserContext",
"(",
")",
".",
"expectResult",
"(",
"expectedType",
")",
";",
"return",
"getSpringExpressionParser",
"(",
")",
".",
"parseExpression",
"(",
"expression",
",",
"parserContext",
")",
";",
"}"
] |
Create expression expression.
@param expression the expression
@param expectedType the expected type
@return the expression
|
[
"Create",
"expression",
"expression",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java#L363-L366
|
haraldk/TwelveMonkeys
|
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java
|
PICTImageReader.readRectangle
|
private void readRectangle(DataInput pStream, Rectangle pDestRect) throws IOException {
"""
Reads the rectangle location and size from an 8-byte rectangle stream.
@param pStream the stream to read from
@param pDestRect the rectangle to read into
@throws NullPointerException if {@code pDestRect} is {@code null}
@throws IOException if an I/O error occurs while reading the image.
"""
int y = pStream.readUnsignedShort();
int x = pStream.readUnsignedShort();
int h = pStream.readUnsignedShort();
int w = pStream.readUnsignedShort();
pDestRect.setLocation(getXPtCoord(x), getYPtCoord(y));
pDestRect.setSize(getXPtCoord(w - x), getYPtCoord(h - y));
}
|
java
|
private void readRectangle(DataInput pStream, Rectangle pDestRect) throws IOException {
int y = pStream.readUnsignedShort();
int x = pStream.readUnsignedShort();
int h = pStream.readUnsignedShort();
int w = pStream.readUnsignedShort();
pDestRect.setLocation(getXPtCoord(x), getYPtCoord(y));
pDestRect.setSize(getXPtCoord(w - x), getYPtCoord(h - y));
}
|
[
"private",
"void",
"readRectangle",
"(",
"DataInput",
"pStream",
",",
"Rectangle",
"pDestRect",
")",
"throws",
"IOException",
"{",
"int",
"y",
"=",
"pStream",
".",
"readUnsignedShort",
"(",
")",
";",
"int",
"x",
"=",
"pStream",
".",
"readUnsignedShort",
"(",
")",
";",
"int",
"h",
"=",
"pStream",
".",
"readUnsignedShort",
"(",
")",
";",
"int",
"w",
"=",
"pStream",
".",
"readUnsignedShort",
"(",
")",
";",
"pDestRect",
".",
"setLocation",
"(",
"getXPtCoord",
"(",
"x",
")",
",",
"getYPtCoord",
"(",
"y",
")",
")",
";",
"pDestRect",
".",
"setSize",
"(",
"getXPtCoord",
"(",
"w",
"-",
"x",
")",
",",
"getYPtCoord",
"(",
"h",
"-",
"y",
")",
")",
";",
"}"
] |
Reads the rectangle location and size from an 8-byte rectangle stream.
@param pStream the stream to read from
@param pDestRect the rectangle to read into
@throws NullPointerException if {@code pDestRect} is {@code null}
@throws IOException if an I/O error occurs while reading the image.
|
[
"Reads",
"the",
"rectangle",
"location",
"and",
"size",
"from",
"an",
"8",
"-",
"byte",
"rectangle",
"stream",
"."
] |
train
|
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java#L2366-L2374
|
actorapp/actor-platform
|
actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/crypto/Curve25519.java
|
Curve25519.verifySignature
|
public static boolean verifySignature(byte[] publicKey, byte[] message, byte[] signature) {
"""
Verification of signature
@param publicKey public key of signature
@param message message
@param signature signature of a message
@return true if signature correct
"""
return curve_sigs.curve25519_verify(SHA512Provider, signature, publicKey, message, message.length) == 0;
}
|
java
|
public static boolean verifySignature(byte[] publicKey, byte[] message, byte[] signature) {
return curve_sigs.curve25519_verify(SHA512Provider, signature, publicKey, message, message.length) == 0;
}
|
[
"public",
"static",
"boolean",
"verifySignature",
"(",
"byte",
"[",
"]",
"publicKey",
",",
"byte",
"[",
"]",
"message",
",",
"byte",
"[",
"]",
"signature",
")",
"{",
"return",
"curve_sigs",
".",
"curve25519_verify",
"(",
"SHA512Provider",
",",
"signature",
",",
"publicKey",
",",
"message",
",",
"message",
".",
"length",
")",
"==",
"0",
";",
"}"
] |
Verification of signature
@param publicKey public key of signature
@param message message
@param signature signature of a message
@return true if signature correct
|
[
"Verification",
"of",
"signature"
] |
train
|
https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/crypto/Curve25519.java#L107-L109
|
elki-project/elki
|
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/query/knn/LinearScanEuclideanDistanceKNNQuery.java
|
LinearScanEuclideanDistanceKNNQuery.linearScanBatchKNN
|
@Override
protected void linearScanBatchKNN(List<O> objs, List<KNNHeap> heaps) {
"""
Perform a linear scan batch kNN for primitive distance functions.
@param objs Objects list
@param heaps Heaps array
"""
final SquaredEuclideanDistanceFunction squared = SquaredEuclideanDistanceFunction.STATIC;
final Relation<? extends O> relation = getRelation();
final int size = objs.size();
// Linear scan style KNN.
for(DBIDIter iter = relation.getDBIDs().iter(); iter.valid(); iter.advance()) {
O candidate = relation.get(iter);
for(int index = 0; index < size; index++) {
final KNNHeap heap = heaps.get(index);
final double dist = squared.distance(objs.get(index), candidate);
if(dist <= heap.getKNNDistance()) {
heap.insert(dist, iter);
}
}
}
}
|
java
|
@Override
protected void linearScanBatchKNN(List<O> objs, List<KNNHeap> heaps) {
final SquaredEuclideanDistanceFunction squared = SquaredEuclideanDistanceFunction.STATIC;
final Relation<? extends O> relation = getRelation();
final int size = objs.size();
// Linear scan style KNN.
for(DBIDIter iter = relation.getDBIDs().iter(); iter.valid(); iter.advance()) {
O candidate = relation.get(iter);
for(int index = 0; index < size; index++) {
final KNNHeap heap = heaps.get(index);
final double dist = squared.distance(objs.get(index), candidate);
if(dist <= heap.getKNNDistance()) {
heap.insert(dist, iter);
}
}
}
}
|
[
"@",
"Override",
"protected",
"void",
"linearScanBatchKNN",
"(",
"List",
"<",
"O",
">",
"objs",
",",
"List",
"<",
"KNNHeap",
">",
"heaps",
")",
"{",
"final",
"SquaredEuclideanDistanceFunction",
"squared",
"=",
"SquaredEuclideanDistanceFunction",
".",
"STATIC",
";",
"final",
"Relation",
"<",
"?",
"extends",
"O",
">",
"relation",
"=",
"getRelation",
"(",
")",
";",
"final",
"int",
"size",
"=",
"objs",
".",
"size",
"(",
")",
";",
"// Linear scan style KNN.",
"for",
"(",
"DBIDIter",
"iter",
"=",
"relation",
".",
"getDBIDs",
"(",
")",
".",
"iter",
"(",
")",
";",
"iter",
".",
"valid",
"(",
")",
";",
"iter",
".",
"advance",
"(",
")",
")",
"{",
"O",
"candidate",
"=",
"relation",
".",
"get",
"(",
"iter",
")",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"size",
";",
"index",
"++",
")",
"{",
"final",
"KNNHeap",
"heap",
"=",
"heaps",
".",
"get",
"(",
"index",
")",
";",
"final",
"double",
"dist",
"=",
"squared",
".",
"distance",
"(",
"objs",
".",
"get",
"(",
"index",
")",
",",
"candidate",
")",
";",
"if",
"(",
"dist",
"<=",
"heap",
".",
"getKNNDistance",
"(",
")",
")",
"{",
"heap",
".",
"insert",
"(",
"dist",
",",
"iter",
")",
";",
"}",
"}",
"}",
"}"
] |
Perform a linear scan batch kNN for primitive distance functions.
@param objs Objects list
@param heaps Heaps array
|
[
"Perform",
"a",
"linear",
"scan",
"batch",
"kNN",
"for",
"primitive",
"distance",
"functions",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/query/knn/LinearScanEuclideanDistanceKNNQuery.java#L122-L138
|
kuali/ojb-1.0.4
|
src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
|
PersistenceBrokerImpl.commitTransaction
|
public synchronized void commitTransaction() throws TransactionNotInProgressException, TransactionAbortedException {
"""
Commit and close the transaction.
Calling <code>commit</code> commits to the database all
UPDATE, INSERT and DELETE statements called within the transaction and
releases any locks held by the transaction.
If beginTransaction() has not been called before a
TransactionNotInProgressException exception is thrown.
If the transaction cannot be commited a TransactionAbortedException exception is thrown.
"""
if (!isInTransaction())
{
throw new TransactionNotInProgressException("PersistenceBroker is NOT in transaction, can't commit");
}
fireBrokerEvent(BEFORE_COMMIT_EVENT);
setInTransaction(false);
clearRegistrationLists();
referencesBroker.removePrefetchingListeners();
/*
arminw:
In managed environments it should be possible to close a used connection before
the tx was commited, thus it will be possible that the PB instance is in PB-tx, but
the connection is already closed. To avoid problems check if CM is in local tx before
do the CM.commit call
*/
if(connectionManager.isInLocalTransaction())
{
this.connectionManager.localCommit();
}
fireBrokerEvent(AFTER_COMMIT_EVENT);
}
|
java
|
public synchronized void commitTransaction() throws TransactionNotInProgressException, TransactionAbortedException
{
if (!isInTransaction())
{
throw new TransactionNotInProgressException("PersistenceBroker is NOT in transaction, can't commit");
}
fireBrokerEvent(BEFORE_COMMIT_EVENT);
setInTransaction(false);
clearRegistrationLists();
referencesBroker.removePrefetchingListeners();
/*
arminw:
In managed environments it should be possible to close a used connection before
the tx was commited, thus it will be possible that the PB instance is in PB-tx, but
the connection is already closed. To avoid problems check if CM is in local tx before
do the CM.commit call
*/
if(connectionManager.isInLocalTransaction())
{
this.connectionManager.localCommit();
}
fireBrokerEvent(AFTER_COMMIT_EVENT);
}
|
[
"public",
"synchronized",
"void",
"commitTransaction",
"(",
")",
"throws",
"TransactionNotInProgressException",
",",
"TransactionAbortedException",
"{",
"if",
"(",
"!",
"isInTransaction",
"(",
")",
")",
"{",
"throw",
"new",
"TransactionNotInProgressException",
"(",
"\"PersistenceBroker is NOT in transaction, can't commit\"",
")",
";",
"}",
"fireBrokerEvent",
"(",
"BEFORE_COMMIT_EVENT",
")",
";",
"setInTransaction",
"(",
"false",
")",
";",
"clearRegistrationLists",
"(",
")",
";",
"referencesBroker",
".",
"removePrefetchingListeners",
"(",
")",
";",
"/*\n arminw:\n In managed environments it should be possible to close a used connection before\n the tx was commited, thus it will be possible that the PB instance is in PB-tx, but\n the connection is already closed. To avoid problems check if CM is in local tx before\n do the CM.commit call\n */",
"if",
"(",
"connectionManager",
".",
"isInLocalTransaction",
"(",
")",
")",
"{",
"this",
".",
"connectionManager",
".",
"localCommit",
"(",
")",
";",
"}",
"fireBrokerEvent",
"(",
"AFTER_COMMIT_EVENT",
")",
";",
"}"
] |
Commit and close the transaction.
Calling <code>commit</code> commits to the database all
UPDATE, INSERT and DELETE statements called within the transaction and
releases any locks held by the transaction.
If beginTransaction() has not been called before a
TransactionNotInProgressException exception is thrown.
If the transaction cannot be commited a TransactionAbortedException exception is thrown.
|
[
"Commit",
"and",
"close",
"the",
"transaction",
".",
"Calling",
"<code",
">",
"commit<",
"/",
"code",
">",
"commits",
"to",
"the",
"database",
"all",
"UPDATE",
"INSERT",
"and",
"DELETE",
"statements",
"called",
"within",
"the",
"transaction",
"and",
"releases",
"any",
"locks",
"held",
"by",
"the",
"transaction",
".",
"If",
"beginTransaction",
"()",
"has",
"not",
"been",
"called",
"before",
"a",
"TransactionNotInProgressException",
"exception",
"is",
"thrown",
".",
"If",
"the",
"transaction",
"cannot",
"be",
"commited",
"a",
"TransactionAbortedException",
"exception",
"is",
"thrown",
"."
] |
train
|
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java#L455-L477
|
ehcache/ehcache3
|
impl/src/main/java/org/ehcache/impl/config/serializer/DefaultSerializationProviderConfiguration.java
|
DefaultSerializationProviderConfiguration.addSerializerFor
|
public <T> DefaultSerializationProviderConfiguration addSerializerFor(Class<T> serializableClass, Class<? extends Serializer<T>> serializerClass, boolean overwrite) {
"""
Adds a new {@link Serializer} mapping for the class {@code serializableClass}
@param serializableClass the {@code Class} to add the mapping for
@param serializerClass the {@link Serializer} type to use
@param overwrite indicates if an existing mapping is to be overwritten
@param <T> the type of instances to be serialized / deserialized
@return this configuration object
@throws NullPointerException if any argument is null
@throws IllegalArgumentException if a mapping for {@code serializableClass} already exists and {@code overwrite} is {@code false}
"""
if (serializableClass == null) {
throw new NullPointerException("Serializable class cannot be null");
}
if (serializerClass == null) {
throw new NullPointerException("Serializer class cannot be null");
}
if(!isConstructorPresent(serializerClass, ClassLoader.class)) {
throw new IllegalArgumentException("The serializer: " + serializerClass.getName() + " does not have a constructor that takes in a ClassLoader.");
}
if (isConstructorPresent(serializerClass, ClassLoader.class, FileBasedPersistenceContext.class)) {
LOGGER.warn(serializerClass.getName() + " class has a constructor that takes in a FileBasedPersistenceContext. " +
"Support for this constructor has been removed since version 3.2. Consider removing it.");
}
if (defaultSerializers.containsKey(serializableClass) && !overwrite) {
throw new IllegalArgumentException("Duplicate serializer for class : " + serializableClass.getName());
} else {
defaultSerializers.put(serializableClass, serializerClass);
}
return this;
}
|
java
|
public <T> DefaultSerializationProviderConfiguration addSerializerFor(Class<T> serializableClass, Class<? extends Serializer<T>> serializerClass, boolean overwrite) {
if (serializableClass == null) {
throw new NullPointerException("Serializable class cannot be null");
}
if (serializerClass == null) {
throw new NullPointerException("Serializer class cannot be null");
}
if(!isConstructorPresent(serializerClass, ClassLoader.class)) {
throw new IllegalArgumentException("The serializer: " + serializerClass.getName() + " does not have a constructor that takes in a ClassLoader.");
}
if (isConstructorPresent(serializerClass, ClassLoader.class, FileBasedPersistenceContext.class)) {
LOGGER.warn(serializerClass.getName() + " class has a constructor that takes in a FileBasedPersistenceContext. " +
"Support for this constructor has been removed since version 3.2. Consider removing it.");
}
if (defaultSerializers.containsKey(serializableClass) && !overwrite) {
throw new IllegalArgumentException("Duplicate serializer for class : " + serializableClass.getName());
} else {
defaultSerializers.put(serializableClass, serializerClass);
}
return this;
}
|
[
"public",
"<",
"T",
">",
"DefaultSerializationProviderConfiguration",
"addSerializerFor",
"(",
"Class",
"<",
"T",
">",
"serializableClass",
",",
"Class",
"<",
"?",
"extends",
"Serializer",
"<",
"T",
">",
">",
"serializerClass",
",",
"boolean",
"overwrite",
")",
"{",
"if",
"(",
"serializableClass",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Serializable class cannot be null\"",
")",
";",
"}",
"if",
"(",
"serializerClass",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Serializer class cannot be null\"",
")",
";",
"}",
"if",
"(",
"!",
"isConstructorPresent",
"(",
"serializerClass",
",",
"ClassLoader",
".",
"class",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The serializer: \"",
"+",
"serializerClass",
".",
"getName",
"(",
")",
"+",
"\" does not have a constructor that takes in a ClassLoader.\"",
")",
";",
"}",
"if",
"(",
"isConstructorPresent",
"(",
"serializerClass",
",",
"ClassLoader",
".",
"class",
",",
"FileBasedPersistenceContext",
".",
"class",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"serializerClass",
".",
"getName",
"(",
")",
"+",
"\" class has a constructor that takes in a FileBasedPersistenceContext. \"",
"+",
"\"Support for this constructor has been removed since version 3.2. Consider removing it.\"",
")",
";",
"}",
"if",
"(",
"defaultSerializers",
".",
"containsKey",
"(",
"serializableClass",
")",
"&&",
"!",
"overwrite",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Duplicate serializer for class : \"",
"+",
"serializableClass",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"defaultSerializers",
".",
"put",
"(",
"serializableClass",
",",
"serializerClass",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Adds a new {@link Serializer} mapping for the class {@code serializableClass}
@param serializableClass the {@code Class} to add the mapping for
@param serializerClass the {@link Serializer} type to use
@param overwrite indicates if an existing mapping is to be overwritten
@param <T> the type of instances to be serialized / deserialized
@return this configuration object
@throws NullPointerException if any argument is null
@throws IllegalArgumentException if a mapping for {@code serializableClass} already exists and {@code overwrite} is {@code false}
|
[
"Adds",
"a",
"new",
"{",
"@link",
"Serializer",
"}",
"mapping",
"for",
"the",
"class",
"{",
"@code",
"serializableClass",
"}"
] |
train
|
https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/impl/src/main/java/org/ehcache/impl/config/serializer/DefaultSerializationProviderConfiguration.java#L90-L114
|
lessthanoptimal/BoofCV
|
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodePositionPatternDetector.java
|
QrCodePositionPatternDetector.checkPositionPatternAppearance
|
boolean checkPositionPatternAppearance( Polygon2D_F64 square , float grayThreshold ) {
"""
Determines if the found polygon looks like a position pattern. A horizontal and vertical line are sampled.
At each sample point it is marked if it is above or below the binary threshold for this square. Location
of sample points is found by "removing" perspective distortion.
@param square Position pattern square.
"""
return( checkLine(square,grayThreshold,0) || checkLine(square,grayThreshold,1));
}
|
java
|
boolean checkPositionPatternAppearance( Polygon2D_F64 square , float grayThreshold ) {
return( checkLine(square,grayThreshold,0) || checkLine(square,grayThreshold,1));
}
|
[
"boolean",
"checkPositionPatternAppearance",
"(",
"Polygon2D_F64",
"square",
",",
"float",
"grayThreshold",
")",
"{",
"return",
"(",
"checkLine",
"(",
"square",
",",
"grayThreshold",
",",
"0",
")",
"||",
"checkLine",
"(",
"square",
",",
"grayThreshold",
",",
"1",
")",
")",
";",
"}"
] |
Determines if the found polygon looks like a position pattern. A horizontal and vertical line are sampled.
At each sample point it is marked if it is above or below the binary threshold for this square. Location
of sample points is found by "removing" perspective distortion.
@param square Position pattern square.
|
[
"Determines",
"if",
"the",
"found",
"polygon",
"looks",
"like",
"a",
"position",
"pattern",
".",
"A",
"horizontal",
"and",
"vertical",
"line",
"are",
"sampled",
".",
"At",
"each",
"sample",
"point",
"it",
"is",
"marked",
"if",
"it",
"is",
"above",
"or",
"below",
"the",
"binary",
"threshold",
"for",
"this",
"square",
".",
"Location",
"of",
"sample",
"points",
"is",
"found",
"by",
"removing",
"perspective",
"distortion",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodePositionPatternDetector.java#L331-L333
|
ironjacamar/ironjacamar
|
core/src/main/java/org/ironjacamar/core/tracer/Tracer.java
|
Tracer.createManagedConnectionPool
|
public static synchronized void createManagedConnectionPool(String poolName, Object mcp) {
"""
Create managed connection pool
@param poolName The name of the pool
@param mcp The managed connection pool
"""
log.tracef("%s", new TraceEvent(poolName,
Integer.toHexString(System.identityHashCode(mcp)),
TraceEvent.MANAGED_CONNECTION_POOL_CREATE,
"NONE"));
}
|
java
|
public static synchronized void createManagedConnectionPool(String poolName, Object mcp)
{
log.tracef("%s", new TraceEvent(poolName,
Integer.toHexString(System.identityHashCode(mcp)),
TraceEvent.MANAGED_CONNECTION_POOL_CREATE,
"NONE"));
}
|
[
"public",
"static",
"synchronized",
"void",
"createManagedConnectionPool",
"(",
"String",
"poolName",
",",
"Object",
"mcp",
")",
"{",
"log",
".",
"tracef",
"(",
"\"%s\"",
",",
"new",
"TraceEvent",
"(",
"poolName",
",",
"Integer",
".",
"toHexString",
"(",
"System",
".",
"identityHashCode",
"(",
"mcp",
")",
")",
",",
"TraceEvent",
".",
"MANAGED_CONNECTION_POOL_CREATE",
",",
"\"NONE\"",
")",
")",
";",
"}"
] |
Create managed connection pool
@param poolName The name of the pool
@param mcp The managed connection pool
|
[
"Create",
"managed",
"connection",
"pool"
] |
train
|
https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/core/src/main/java/org/ironjacamar/core/tracer/Tracer.java#L558-L564
|
EsotericSoftware/kryo
|
src/com/esotericsoftware/kryo/Kryo.java
|
Kryo.addDefaultSerializer
|
public void addDefaultSerializer (Class type, Serializer serializer) {
"""
Instances of the specified class will use the specified serializer when {@link #register(Class)} or
{@link #register(Class, int)} are called.
@see #setDefaultSerializer(Class)
"""
if (type == null) throw new IllegalArgumentException("type cannot be null.");
if (serializer == null) throw new IllegalArgumentException("serializer cannot be null.");
insertDefaultSerializer(type, new SingletonSerializerFactory(serializer));
}
|
java
|
public void addDefaultSerializer (Class type, Serializer serializer) {
if (type == null) throw new IllegalArgumentException("type cannot be null.");
if (serializer == null) throw new IllegalArgumentException("serializer cannot be null.");
insertDefaultSerializer(type, new SingletonSerializerFactory(serializer));
}
|
[
"public",
"void",
"addDefaultSerializer",
"(",
"Class",
"type",
",",
"Serializer",
"serializer",
")",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"type cannot be null.\"",
")",
";",
"if",
"(",
"serializer",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"serializer cannot be null.\"",
")",
";",
"insertDefaultSerializer",
"(",
"type",
",",
"new",
"SingletonSerializerFactory",
"(",
"serializer",
")",
")",
";",
"}"
] |
Instances of the specified class will use the specified serializer when {@link #register(Class)} or
{@link #register(Class, int)} are called.
@see #setDefaultSerializer(Class)
|
[
"Instances",
"of",
"the",
"specified",
"class",
"will",
"use",
"the",
"specified",
"serializer",
"when",
"{"
] |
train
|
https://github.com/EsotericSoftware/kryo/blob/a8be1ab26f347f299a3c3f7171d6447dd5390845/src/com/esotericsoftware/kryo/Kryo.java#L260-L264
|
google/error-prone
|
check_api/src/main/java/com/google/errorprone/dataflow/ConstantPropagationAnalysis.java
|
ConstantPropagationAnalysis.numberValue
|
@Nullable
public static Number numberValue(TreePath exprPath, Context context) {
"""
Returns the value of the leaf of {@code exprPath}, if it is determined to be a constant (always
evaluates to the same numeric value), and null otherwise. Note that returning null does not
necessarily mean the expression is *not* a constant.
"""
Constant val = DataFlow.expressionDataflow(exprPath, context, CONSTANT_PROPAGATION);
if (val == null || !val.isConstant()) {
return null;
}
return val.getValue();
}
|
java
|
@Nullable
public static Number numberValue(TreePath exprPath, Context context) {
Constant val = DataFlow.expressionDataflow(exprPath, context, CONSTANT_PROPAGATION);
if (val == null || !val.isConstant()) {
return null;
}
return val.getValue();
}
|
[
"@",
"Nullable",
"public",
"static",
"Number",
"numberValue",
"(",
"TreePath",
"exprPath",
",",
"Context",
"context",
")",
"{",
"Constant",
"val",
"=",
"DataFlow",
".",
"expressionDataflow",
"(",
"exprPath",
",",
"context",
",",
"CONSTANT_PROPAGATION",
")",
";",
"if",
"(",
"val",
"==",
"null",
"||",
"!",
"val",
".",
"isConstant",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"val",
".",
"getValue",
"(",
")",
";",
"}"
] |
Returns the value of the leaf of {@code exprPath}, if it is determined to be a constant (always
evaluates to the same numeric value), and null otherwise. Note that returning null does not
necessarily mean the expression is *not* a constant.
|
[
"Returns",
"the",
"value",
"of",
"the",
"leaf",
"of",
"{"
] |
train
|
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/dataflow/ConstantPropagationAnalysis.java#L36-L43
|
infinispan/infinispan
|
core/src/main/java/org/infinispan/commands/AbstractVisitor.java
|
AbstractVisitor.visitCollection
|
public void visitCollection(InvocationContext ctx, Collection<? extends VisitableCommand> toVisit) throws Throwable {
"""
Helper method to visit a collection of VisitableCommands.
@param ctx Invocation context
@param toVisit collection of commands to visit
@throws Throwable in the event of problems
"""
for (VisitableCommand command : toVisit) {
command.acceptVisitor(ctx, this);
}
}
|
java
|
public void visitCollection(InvocationContext ctx, Collection<? extends VisitableCommand> toVisit) throws Throwable {
for (VisitableCommand command : toVisit) {
command.acceptVisitor(ctx, this);
}
}
|
[
"public",
"void",
"visitCollection",
"(",
"InvocationContext",
"ctx",
",",
"Collection",
"<",
"?",
"extends",
"VisitableCommand",
">",
"toVisit",
")",
"throws",
"Throwable",
"{",
"for",
"(",
"VisitableCommand",
"command",
":",
"toVisit",
")",
"{",
"command",
".",
"acceptVisitor",
"(",
"ctx",
",",
"this",
")",
";",
"}",
"}"
] |
Helper method to visit a collection of VisitableCommands.
@param ctx Invocation context
@param toVisit collection of commands to visit
@throws Throwable in the event of problems
|
[
"Helper",
"method",
"to",
"visit",
"a",
"collection",
"of",
"VisitableCommands",
"."
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/commands/AbstractVisitor.java#L169-L173
|
couchbase/couchbase-java-client
|
src/main/java/com/couchbase/client/java/query/dsl/functions/DateFunctions.java
|
DateFunctions.datePartMillis
|
public static Expression datePartMillis(Expression expression, DatePartExt part) {
"""
Returned expression results in Date part as an integer.
The date expression is a number representing UNIX milliseconds, and part is a {@link DatePartExt}.
"""
return x("DATE_PART_MILLIS(" + expression.toString() + ", \"" + part.toString() + "\")");
}
|
java
|
public static Expression datePartMillis(Expression expression, DatePartExt part) {
return x("DATE_PART_MILLIS(" + expression.toString() + ", \"" + part.toString() + "\")");
}
|
[
"public",
"static",
"Expression",
"datePartMillis",
"(",
"Expression",
"expression",
",",
"DatePartExt",
"part",
")",
"{",
"return",
"x",
"(",
"\"DATE_PART_MILLIS(\"",
"+",
"expression",
".",
"toString",
"(",
")",
"+",
"\", \\\"\"",
"+",
"part",
".",
"toString",
"(",
")",
"+",
"\"\\\")\"",
")",
";",
"}"
] |
Returned expression results in Date part as an integer.
The date expression is a number representing UNIX milliseconds, and part is a {@link DatePartExt}.
|
[
"Returned",
"expression",
"results",
"in",
"Date",
"part",
"as",
"an",
"integer",
".",
"The",
"date",
"expression",
"is",
"a",
"number",
"representing",
"UNIX",
"milliseconds",
"and",
"part",
"is",
"a",
"{"
] |
train
|
https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/dsl/functions/DateFunctions.java#L140-L142
|
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/TypeUtils.java
|
TypeUtils.isAssignable
|
public static boolean isAssignable(final Type what, final Type toType) {
"""
Checks if type could be casted to type. Generally, method is supposed to answer: if this type could be tried
to set on that place (defined by second type). Not resolved type variables are resolved to Object. Object is
considered as unknown type: everything is assignable to Object and Object is assignable to everything.
Note that {@code T<String, Object>} is assignable to {@code T<String, String>} as Object considered as unknown
type and so could be compatible (in opposite way is also assignable as anything is assignable to Object).
<p>
Of course, actual value used instead of Object may be incompatible, but method intended only to
check all available types information (if nothing stops me yet). Use exact types to get more correct
result. Example usage scenario: check field type before trying to assign something with reflection.
<p>
Java wildcard rules are generally not honored because at runtime they are meaningless.
{@code List == List<Object> == List<? super Object> == List<? extends Object>}. All upper bounds are used for
comparison (multiple upper bounds in wildcard could be from repackaging of generic declaration
{@code T<extends A&B>}. Lower bounds are taken into account as: if both have lower bound then
right's type bound must be higher ({@code ? extends Number and ? extends Integer}). If only left
type is lower bounded wildcard then it is not assignable (except Object).
<p>
Primitive types are checked as wrappers (for example, int is more specific then Number).
@param what type to check
@param toType type to check assignability for
@return true if types are equal or type is more specific, false if can't be casted or types incompatible
@see AssignabilityTypesVisitor for implementation details
"""
final AssignabilityTypesVisitor visitor = new AssignabilityTypesVisitor();
TypesWalker.walk(what, toType, visitor);
return visitor.isAssignable();
}
|
java
|
public static boolean isAssignable(final Type what, final Type toType) {
final AssignabilityTypesVisitor visitor = new AssignabilityTypesVisitor();
TypesWalker.walk(what, toType, visitor);
return visitor.isAssignable();
}
|
[
"public",
"static",
"boolean",
"isAssignable",
"(",
"final",
"Type",
"what",
",",
"final",
"Type",
"toType",
")",
"{",
"final",
"AssignabilityTypesVisitor",
"visitor",
"=",
"new",
"AssignabilityTypesVisitor",
"(",
")",
";",
"TypesWalker",
".",
"walk",
"(",
"what",
",",
"toType",
",",
"visitor",
")",
";",
"return",
"visitor",
".",
"isAssignable",
"(",
")",
";",
"}"
] |
Checks if type could be casted to type. Generally, method is supposed to answer: if this type could be tried
to set on that place (defined by second type). Not resolved type variables are resolved to Object. Object is
considered as unknown type: everything is assignable to Object and Object is assignable to everything.
Note that {@code T<String, Object>} is assignable to {@code T<String, String>} as Object considered as unknown
type and so could be compatible (in opposite way is also assignable as anything is assignable to Object).
<p>
Of course, actual value used instead of Object may be incompatible, but method intended only to
check all available types information (if nothing stops me yet). Use exact types to get more correct
result. Example usage scenario: check field type before trying to assign something with reflection.
<p>
Java wildcard rules are generally not honored because at runtime they are meaningless.
{@code List == List<Object> == List<? super Object> == List<? extends Object>}. All upper bounds are used for
comparison (multiple upper bounds in wildcard could be from repackaging of generic declaration
{@code T<extends A&B>}. Lower bounds are taken into account as: if both have lower bound then
right's type bound must be higher ({@code ? extends Number and ? extends Integer}). If only left
type is lower bounded wildcard then it is not assignable (except Object).
<p>
Primitive types are checked as wrappers (for example, int is more specific then Number).
@param what type to check
@param toType type to check assignability for
@return true if types are equal or type is more specific, false if can't be casted or types incompatible
@see AssignabilityTypesVisitor for implementation details
|
[
"Checks",
"if",
"type",
"could",
"be",
"casted",
"to",
"type",
".",
"Generally",
"method",
"is",
"supposed",
"to",
"answer",
":",
"if",
"this",
"type",
"could",
"be",
"tried",
"to",
"set",
"on",
"that",
"place",
"(",
"defined",
"by",
"second",
"type",
")",
".",
"Not",
"resolved",
"type",
"variables",
"are",
"resolved",
"to",
"Object",
".",
"Object",
"is",
"considered",
"as",
"unknown",
"type",
":",
"everything",
"is",
"assignable",
"to",
"Object",
"and",
"Object",
"is",
"assignable",
"to",
"everything",
".",
"Note",
"that",
"{",
"@code",
"T<String",
"Object",
">",
"}",
"is",
"assignable",
"to",
"{",
"@code",
"T<String",
"String",
">",
"}",
"as",
"Object",
"considered",
"as",
"unknown",
"type",
"and",
"so",
"could",
"be",
"compatible",
"(",
"in",
"opposite",
"way",
"is",
"also",
"assignable",
"as",
"anything",
"is",
"assignable",
"to",
"Object",
")",
".",
"<p",
">",
"Of",
"course",
"actual",
"value",
"used",
"instead",
"of",
"Object",
"may",
"be",
"incompatible",
"but",
"method",
"intended",
"only",
"to",
"check",
"all",
"available",
"types",
"information",
"(",
"if",
"nothing",
"stops",
"me",
"yet",
")",
".",
"Use",
"exact",
"types",
"to",
"get",
"more",
"correct",
"result",
".",
"Example",
"usage",
"scenario",
":",
"check",
"field",
"type",
"before",
"trying",
"to",
"assign",
"something",
"with",
"reflection",
".",
"<p",
">",
"Java",
"wildcard",
"rules",
"are",
"generally",
"not",
"honored",
"because",
"at",
"runtime",
"they",
"are",
"meaningless",
".",
"{",
"@code",
"List",
"==",
"List<Object",
">",
"==",
"List<?",
"super",
"Object",
">",
"==",
"List<?",
"extends",
"Object",
">",
"}",
".",
"All",
"upper",
"bounds",
"are",
"used",
"for",
"comparison",
"(",
"multiple",
"upper",
"bounds",
"in",
"wildcard",
"could",
"be",
"from",
"repackaging",
"of",
"generic",
"declaration",
"{",
"@code",
"T<extends",
"A&B",
">",
"}",
".",
"Lower",
"bounds",
"are",
"taken",
"into",
"account",
"as",
":",
"if",
"both",
"have",
"lower",
"bound",
"then",
"right",
"s",
"type",
"bound",
"must",
"be",
"higher",
"(",
"{",
"@code",
"?",
"extends",
"Number",
"and",
"?",
"extends",
"Integer",
"}",
")",
".",
"If",
"only",
"left",
"type",
"is",
"lower",
"bounded",
"wildcard",
"then",
"it",
"is",
"not",
"assignable",
"(",
"except",
"Object",
")",
".",
"<p",
">",
"Primitive",
"types",
"are",
"checked",
"as",
"wrappers",
"(",
"for",
"example",
"int",
"is",
"more",
"specific",
"then",
"Number",
")",
"."
] |
train
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/TypeUtils.java#L113-L118
|
OpenBEL/openbel-framework
|
org.openbel.framework.common/src/main/java/org/openbel/framework/common/lock/LockAdviser.java
|
LockAdviser.createLock
|
private Lock createLock(boolean writer) {
"""
Creates a {@link Lock lock} on the this instance of the
{@link LockAdviser}. If <tt>writer</tt> is false then a {@link File read
lock file} is created, otherwise a {@link File write lock file is
created}.
@param writer, <tt>true</tt> if a {@link File write lock file} should be
created, <tt>false</tt> otherwise
@return the created {@link Lock}
@throws IllegalStateException Thrown if the {@link File lock file} could
not be created
"""
final int pid = getPID();
final String baseLock;
if (!writer) {
baseLock = READER_LOCK_PREFIX + pid + LOCK_EXTENSION;
} else {
baseLock = WRITER_LOCK_PREFIX + pid + LOCK_EXTENSION;
}
int i = 0;
while (locks.containsKey(baseLock + (++i))) {
// no logic needed
}
final String lockName = baseLock + i;
final Lock lock = new Lock(lockName);
final File lockFile = new File(lockPath, lockName);
try {
if (!lockFile.createNewFile()) {
throw new IllegalStateException("could not create lock");
}
} catch (IOException e) {
throw new IllegalStateException("could not create lock", e);
}
locks.put(lockName, lock);
return lock;
}
|
java
|
private Lock createLock(boolean writer) {
final int pid = getPID();
final String baseLock;
if (!writer) {
baseLock = READER_LOCK_PREFIX + pid + LOCK_EXTENSION;
} else {
baseLock = WRITER_LOCK_PREFIX + pid + LOCK_EXTENSION;
}
int i = 0;
while (locks.containsKey(baseLock + (++i))) {
// no logic needed
}
final String lockName = baseLock + i;
final Lock lock = new Lock(lockName);
final File lockFile = new File(lockPath, lockName);
try {
if (!lockFile.createNewFile()) {
throw new IllegalStateException("could not create lock");
}
} catch (IOException e) {
throw new IllegalStateException("could not create lock", e);
}
locks.put(lockName, lock);
return lock;
}
|
[
"private",
"Lock",
"createLock",
"(",
"boolean",
"writer",
")",
"{",
"final",
"int",
"pid",
"=",
"getPID",
"(",
")",
";",
"final",
"String",
"baseLock",
";",
"if",
"(",
"!",
"writer",
")",
"{",
"baseLock",
"=",
"READER_LOCK_PREFIX",
"+",
"pid",
"+",
"LOCK_EXTENSION",
";",
"}",
"else",
"{",
"baseLock",
"=",
"WRITER_LOCK_PREFIX",
"+",
"pid",
"+",
"LOCK_EXTENSION",
";",
"}",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"locks",
".",
"containsKey",
"(",
"baseLock",
"+",
"(",
"++",
"i",
")",
")",
")",
"{",
"// no logic needed",
"}",
"final",
"String",
"lockName",
"=",
"baseLock",
"+",
"i",
";",
"final",
"Lock",
"lock",
"=",
"new",
"Lock",
"(",
"lockName",
")",
";",
"final",
"File",
"lockFile",
"=",
"new",
"File",
"(",
"lockPath",
",",
"lockName",
")",
";",
"try",
"{",
"if",
"(",
"!",
"lockFile",
".",
"createNewFile",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"could not create lock\"",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"could not create lock\"",
",",
"e",
")",
";",
"}",
"locks",
".",
"put",
"(",
"lockName",
",",
"lock",
")",
";",
"return",
"lock",
";",
"}"
] |
Creates a {@link Lock lock} on the this instance of the
{@link LockAdviser}. If <tt>writer</tt> is false then a {@link File read
lock file} is created, otherwise a {@link File write lock file is
created}.
@param writer, <tt>true</tt> if a {@link File write lock file} should be
created, <tt>false</tt> otherwise
@return the created {@link Lock}
@throws IllegalStateException Thrown if the {@link File lock file} could
not be created
|
[
"Creates",
"a",
"{",
"@link",
"Lock",
"lock",
"}",
"on",
"the",
"this",
"instance",
"of",
"the",
"{",
"@link",
"LockAdviser",
"}",
".",
"If",
"<tt",
">",
"writer<",
"/",
"tt",
">",
"is",
"false",
"then",
"a",
"{",
"@link",
"File",
"read",
"lock",
"file",
"}",
"is",
"created",
"otherwise",
"a",
"{",
"@link",
"File",
"write",
"lock",
"file",
"is",
"created",
"}",
"."
] |
train
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.common/src/main/java/org/openbel/framework/common/lock/LockAdviser.java#L272-L301
|
boncey/Flickr4Java
|
src/main/java/com/flickr4java/flickr/stats/StatsInterface.java
|
StatsInterface.getPhotosetStats
|
public Stats getPhotosetStats(String photosetId, Date date) throws FlickrException {
"""
Get the number of views, comments and favorites on a photoset for a given date.
@param date
(Required) Stats will be returned for this date. A day according to Flickr Stats starts at midnight GMT for all users, and timestamps will
automatically be rounded down to the start of the day.
@param photosetId
(Required) The id of the photoset to get stats for.
@see "http://www.flickr.com/services/api/flickr.stats.getPhotosetStats.htm"
"""
return getStats(METHOD_GET_PHOTOSET_STATS, "photoset_id", photosetId, date);
}
|
java
|
public Stats getPhotosetStats(String photosetId, Date date) throws FlickrException {
return getStats(METHOD_GET_PHOTOSET_STATS, "photoset_id", photosetId, date);
}
|
[
"public",
"Stats",
"getPhotosetStats",
"(",
"String",
"photosetId",
",",
"Date",
"date",
")",
"throws",
"FlickrException",
"{",
"return",
"getStats",
"(",
"METHOD_GET_PHOTOSET_STATS",
",",
"\"photoset_id\"",
",",
"photosetId",
",",
"date",
")",
";",
"}"
] |
Get the number of views, comments and favorites on a photoset for a given date.
@param date
(Required) Stats will be returned for this date. A day according to Flickr Stats starts at midnight GMT for all users, and timestamps will
automatically be rounded down to the start of the day.
@param photosetId
(Required) The id of the photoset to get stats for.
@see "http://www.flickr.com/services/api/flickr.stats.getPhotosetStats.htm"
|
[
"Get",
"the",
"number",
"of",
"views",
"comments",
"and",
"favorites",
"on",
"a",
"photoset",
"for",
"a",
"given",
"date",
"."
] |
train
|
https://github.com/boncey/Flickr4Java/blob/f66987ba0e360e5fb7730efbbb8c51f3d978fc25/src/main/java/com/flickr4java/flickr/stats/StatsInterface.java#L254-L256
|
virgo47/javasimon
|
core/src/main/java/org/javasimon/callback/timeline/StopwatchTimeRange.java
|
StopwatchTimeRange.addSplit
|
public void addSplit(long timestampInMs, long durationInNs) {
"""
Add stopwatch split information.
@param timestampInMs when the split started, expressed in milliseconds
@param durationInNs how long the split was, expressed in nanoseconds
"""
last = durationInNs;
total += durationInNs;
squareTotal += durationInNs * durationInNs;
if (durationInNs > max) {
max = durationInNs;
}
if (durationInNs < min) {
min = durationInNs;
}
counter++;
lastTimestamp = timestampInMs;
}
|
java
|
public void addSplit(long timestampInMs, long durationInNs) {
last = durationInNs;
total += durationInNs;
squareTotal += durationInNs * durationInNs;
if (durationInNs > max) {
max = durationInNs;
}
if (durationInNs < min) {
min = durationInNs;
}
counter++;
lastTimestamp = timestampInMs;
}
|
[
"public",
"void",
"addSplit",
"(",
"long",
"timestampInMs",
",",
"long",
"durationInNs",
")",
"{",
"last",
"=",
"durationInNs",
";",
"total",
"+=",
"durationInNs",
";",
"squareTotal",
"+=",
"durationInNs",
"*",
"durationInNs",
";",
"if",
"(",
"durationInNs",
">",
"max",
")",
"{",
"max",
"=",
"durationInNs",
";",
"}",
"if",
"(",
"durationInNs",
"<",
"min",
")",
"{",
"min",
"=",
"durationInNs",
";",
"}",
"counter",
"++",
";",
"lastTimestamp",
"=",
"timestampInMs",
";",
"}"
] |
Add stopwatch split information.
@param timestampInMs when the split started, expressed in milliseconds
@param durationInNs how long the split was, expressed in nanoseconds
|
[
"Add",
"stopwatch",
"split",
"information",
"."
] |
train
|
https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/core/src/main/java/org/javasimon/callback/timeline/StopwatchTimeRange.java#L42-L54
|
phax/ph-masterdata
|
ph-masterdata/src/main/java/com/helger/masterdata/currency/CurrencyHelper.java
|
CurrencyHelper.parseCurrencyFormat
|
@Nullable
public static BigDecimal parseCurrencyFormat (@Nullable final ECurrency eCurrency,
@Nullable final String sTextValue,
@Nullable final BigDecimal aDefault) {
"""
Try to parse a string value formatted by the {@link NumberFormat} object
returned from {@link #getCurrencyFormat(ECurrency)}. E.g.
<code>€ 5,00</code>
@param eCurrency
The currency it is about. If <code>null</code> is provided
{@link #DEFAULT_CURRENCY} is used instead.
@param sTextValue
The string value. It will be trimmed, and the decimal separator will
be adopted.
@param aDefault
The default value to be used in case parsing fails. May be
<code>null</code>.
@return The {@link BigDecimal} value matching the string value or the
passed default value.
"""
final PerCurrencySettings aPCS = getSettings (eCurrency);
final DecimalFormat aCurrencyFormat = aPCS.getCurrencyFormat ();
// Adopt the decimal separator
final String sRealTextValue;
// In Java 9 onwards, this the separators may be null (e.g. for AED)
if (aPCS.getDecimalSeparator () != null && aPCS.getGroupingSeparator () != null)
sRealTextValue = _getTextValueForDecimalSeparator (sTextValue,
aPCS.getDecimalSeparator (),
aPCS.getGroupingSeparator ());
else
sRealTextValue = sTextValue;
return parseCurrency (sRealTextValue, aCurrencyFormat, aDefault, aPCS.getRoundingMode ());
}
|
java
|
@Nullable
public static BigDecimal parseCurrencyFormat (@Nullable final ECurrency eCurrency,
@Nullable final String sTextValue,
@Nullable final BigDecimal aDefault)
{
final PerCurrencySettings aPCS = getSettings (eCurrency);
final DecimalFormat aCurrencyFormat = aPCS.getCurrencyFormat ();
// Adopt the decimal separator
final String sRealTextValue;
// In Java 9 onwards, this the separators may be null (e.g. for AED)
if (aPCS.getDecimalSeparator () != null && aPCS.getGroupingSeparator () != null)
sRealTextValue = _getTextValueForDecimalSeparator (sTextValue,
aPCS.getDecimalSeparator (),
aPCS.getGroupingSeparator ());
else
sRealTextValue = sTextValue;
return parseCurrency (sRealTextValue, aCurrencyFormat, aDefault, aPCS.getRoundingMode ());
}
|
[
"@",
"Nullable",
"public",
"static",
"BigDecimal",
"parseCurrencyFormat",
"(",
"@",
"Nullable",
"final",
"ECurrency",
"eCurrency",
",",
"@",
"Nullable",
"final",
"String",
"sTextValue",
",",
"@",
"Nullable",
"final",
"BigDecimal",
"aDefault",
")",
"{",
"final",
"PerCurrencySettings",
"aPCS",
"=",
"getSettings",
"(",
"eCurrency",
")",
";",
"final",
"DecimalFormat",
"aCurrencyFormat",
"=",
"aPCS",
".",
"getCurrencyFormat",
"(",
")",
";",
"// Adopt the decimal separator",
"final",
"String",
"sRealTextValue",
";",
"// In Java 9 onwards, this the separators may be null (e.g. for AED)",
"if",
"(",
"aPCS",
".",
"getDecimalSeparator",
"(",
")",
"!=",
"null",
"&&",
"aPCS",
".",
"getGroupingSeparator",
"(",
")",
"!=",
"null",
")",
"sRealTextValue",
"=",
"_getTextValueForDecimalSeparator",
"(",
"sTextValue",
",",
"aPCS",
".",
"getDecimalSeparator",
"(",
")",
",",
"aPCS",
".",
"getGroupingSeparator",
"(",
")",
")",
";",
"else",
"sRealTextValue",
"=",
"sTextValue",
";",
"return",
"parseCurrency",
"(",
"sRealTextValue",
",",
"aCurrencyFormat",
",",
"aDefault",
",",
"aPCS",
".",
"getRoundingMode",
"(",
")",
")",
";",
"}"
] |
Try to parse a string value formatted by the {@link NumberFormat} object
returned from {@link #getCurrencyFormat(ECurrency)}. E.g.
<code>€ 5,00</code>
@param eCurrency
The currency it is about. If <code>null</code> is provided
{@link #DEFAULT_CURRENCY} is used instead.
@param sTextValue
The string value. It will be trimmed, and the decimal separator will
be adopted.
@param aDefault
The default value to be used in case parsing fails. May be
<code>null</code>.
@return The {@link BigDecimal} value matching the string value or the
passed default value.
|
[
"Try",
"to",
"parse",
"a",
"string",
"value",
"formatted",
"by",
"the",
"{",
"@link",
"NumberFormat",
"}",
"object",
"returned",
"from",
"{",
"@link",
"#getCurrencyFormat",
"(",
"ECurrency",
")",
"}",
".",
"E",
".",
"g",
".",
"<code",
">",
"&euro",
";",
"5",
"00<",
"/",
"code",
">"
] |
train
|
https://github.com/phax/ph-masterdata/blob/ca5e0b03c735b30b47930c018bfb5e71f00d0ff4/ph-masterdata/src/main/java/com/helger/masterdata/currency/CurrencyHelper.java#L466-L484
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/pdf/PdfContentByte.java
|
PdfContentByte.createGraphics
|
public java.awt.Graphics2D createGraphics(float width, float height) {
"""
Gets a <CODE>Graphics2D</CODE> to write on. The graphics
are translated to PDF commands.
@param width the width of the panel
@param height the height of the panel
@return a <CODE>Graphics2D</CODE>
"""
return new PdfGraphics2D(this, width, height, null, false, false, 0);
}
|
java
|
public java.awt.Graphics2D createGraphics(float width, float height) {
return new PdfGraphics2D(this, width, height, null, false, false, 0);
}
|
[
"public",
"java",
".",
"awt",
".",
"Graphics2D",
"createGraphics",
"(",
"float",
"width",
",",
"float",
"height",
")",
"{",
"return",
"new",
"PdfGraphics2D",
"(",
"this",
",",
"width",
",",
"height",
",",
"null",
",",
"false",
",",
"false",
",",
"0",
")",
";",
"}"
] |
Gets a <CODE>Graphics2D</CODE> to write on. The graphics
are translated to PDF commands.
@param width the width of the panel
@param height the height of the panel
@return a <CODE>Graphics2D</CODE>
|
[
"Gets",
"a",
"<CODE",
">",
"Graphics2D<",
"/",
"CODE",
">",
"to",
"write",
"on",
".",
"The",
"graphics",
"are",
"translated",
"to",
"PDF",
"commands",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfContentByte.java#L2812-L2814
|
alkacon/opencms-core
|
src/org/opencms/db/CmsDriverManager.java
|
CmsDriverManager.deleteRelationsWithSiblings
|
protected void deleteRelationsWithSiblings(CmsDbContext dbc, CmsResource resource) throws CmsException {
"""
Deletes all relations for the given resource and all its siblings.<p>
@param dbc the current database context
@param resource the resource to delete the resource for
@throws CmsException if something goes wrong
"""
// get all siblings
List<CmsResource> siblings;
if (resource.getSiblingCount() > 1) {
siblings = readSiblings(dbc, resource, CmsResourceFilter.ALL);
} else {
siblings = new ArrayList<CmsResource>();
siblings.add(resource);
}
// clean the relations in content for all siblings
I_CmsVfsDriver vfsDriver = getVfsDriver(dbc);
Iterator<CmsResource> it = siblings.iterator();
while (it.hasNext()) {
CmsResource sibling = it.next();
// clean the relation information for this sibling
vfsDriver.deleteRelations(
dbc,
dbc.currentProject().getUuid(),
sibling,
CmsRelationFilter.TARGETS.filterDefinedInContent());
}
}
|
java
|
protected void deleteRelationsWithSiblings(CmsDbContext dbc, CmsResource resource) throws CmsException {
// get all siblings
List<CmsResource> siblings;
if (resource.getSiblingCount() > 1) {
siblings = readSiblings(dbc, resource, CmsResourceFilter.ALL);
} else {
siblings = new ArrayList<CmsResource>();
siblings.add(resource);
}
// clean the relations in content for all siblings
I_CmsVfsDriver vfsDriver = getVfsDriver(dbc);
Iterator<CmsResource> it = siblings.iterator();
while (it.hasNext()) {
CmsResource sibling = it.next();
// clean the relation information for this sibling
vfsDriver.deleteRelations(
dbc,
dbc.currentProject().getUuid(),
sibling,
CmsRelationFilter.TARGETS.filterDefinedInContent());
}
}
|
[
"protected",
"void",
"deleteRelationsWithSiblings",
"(",
"CmsDbContext",
"dbc",
",",
"CmsResource",
"resource",
")",
"throws",
"CmsException",
"{",
"// get all siblings",
"List",
"<",
"CmsResource",
">",
"siblings",
";",
"if",
"(",
"resource",
".",
"getSiblingCount",
"(",
")",
">",
"1",
")",
"{",
"siblings",
"=",
"readSiblings",
"(",
"dbc",
",",
"resource",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"}",
"else",
"{",
"siblings",
"=",
"new",
"ArrayList",
"<",
"CmsResource",
">",
"(",
")",
";",
"siblings",
".",
"add",
"(",
"resource",
")",
";",
"}",
"// clean the relations in content for all siblings",
"I_CmsVfsDriver",
"vfsDriver",
"=",
"getVfsDriver",
"(",
"dbc",
")",
";",
"Iterator",
"<",
"CmsResource",
">",
"it",
"=",
"siblings",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"CmsResource",
"sibling",
"=",
"it",
".",
"next",
"(",
")",
";",
"// clean the relation information for this sibling",
"vfsDriver",
".",
"deleteRelations",
"(",
"dbc",
",",
"dbc",
".",
"currentProject",
"(",
")",
".",
"getUuid",
"(",
")",
",",
"sibling",
",",
"CmsRelationFilter",
".",
"TARGETS",
".",
"filterDefinedInContent",
"(",
")",
")",
";",
"}",
"}"
] |
Deletes all relations for the given resource and all its siblings.<p>
@param dbc the current database context
@param resource the resource to delete the resource for
@throws CmsException if something goes wrong
|
[
"Deletes",
"all",
"relations",
"for",
"the",
"given",
"resource",
"and",
"all",
"its",
"siblings",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L10352-L10374
|
Azure/azure-sdk-for-java
|
compute/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/compute/v2017_12_01/implementation/VirtualMachineExtensionsInner.java
|
VirtualMachineExtensionsInner.getAsync
|
public Observable<VirtualMachineExtensionInner> getAsync(String resourceGroupName, String vmName, String vmExtensionName) {
"""
The operation to get the extension.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine containing the extension.
@param vmExtensionName The name of the virtual machine extension.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualMachineExtensionInner object
"""
return getWithServiceResponseAsync(resourceGroupName, vmName, vmExtensionName).map(new Func1<ServiceResponse<VirtualMachineExtensionInner>, VirtualMachineExtensionInner>() {
@Override
public VirtualMachineExtensionInner call(ServiceResponse<VirtualMachineExtensionInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<VirtualMachineExtensionInner> getAsync(String resourceGroupName, String vmName, String vmExtensionName) {
return getWithServiceResponseAsync(resourceGroupName, vmName, vmExtensionName).map(new Func1<ServiceResponse<VirtualMachineExtensionInner>, VirtualMachineExtensionInner>() {
@Override
public VirtualMachineExtensionInner call(ServiceResponse<VirtualMachineExtensionInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"VirtualMachineExtensionInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"vmName",
",",
"String",
"vmExtensionName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vmName",
",",
"vmExtensionName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VirtualMachineExtensionInner",
">",
",",
"VirtualMachineExtensionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VirtualMachineExtensionInner",
"call",
"(",
"ServiceResponse",
"<",
"VirtualMachineExtensionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
The operation to get the extension.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine containing the extension.
@param vmExtensionName The name of the virtual machine extension.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualMachineExtensionInner object
|
[
"The",
"operation",
"to",
"get",
"the",
"extension",
"."
] |
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/VirtualMachineExtensionsInner.java#L670-L677
|
Hygieia/Hygieia
|
collectors/feature/jira/src/main/java/com/capitalone/dashboard/collector/FeatureCollectorTask.java
|
FeatureCollectorTask.refreshValidIssues
|
private void refreshValidIssues(FeatureCollector collector, List<Team> teams, Set<Scope> scopes) {
"""
Get a list of all issue ids for a given board or project and delete ones that are not in JIRA anymore
@param collector
@param teams
@param scopes
"""
long refreshValidIssuesStart = System.currentTimeMillis();
List<String> lookUpIds = Objects.equals(collector.getMode(), JiraMode.Board) ? teams.stream().map(Team::getTeamId).collect(Collectors.toList()) : scopes.stream().map(Scope::getpId).collect(Collectors.toList());
lookUpIds.forEach(l -> {
LOGGER.info("Refreshing issues for " + collector.getMode() + " ID:" + l);
List<String> issueIds = jiraClient.getAllIssueIds(l, collector.getMode());
List<Feature> existingFeatures = Objects.equals(collector.getMode(), JiraMode.Board) ? featureRepository.findAllByCollectorIdAndSTeamID(collector.getId(), l) : featureRepository.findAllByCollectorIdAndSProjectID(collector.getId(), l);
List<Feature> deletedFeatures = existingFeatures.stream().filter(e -> !issueIds.contains(e.getsId())).collect(Collectors.toList());
deletedFeatures.forEach(d -> {
LOGGER.info("Deleting Feature " + d.getsId() + ':' + d.getsName());
featureRepository.delete(d);
});
});
log(collector.getMode() + " Issues Refreshed ", refreshValidIssuesStart);
}
|
java
|
private void refreshValidIssues(FeatureCollector collector, List<Team> teams, Set<Scope> scopes) {
long refreshValidIssuesStart = System.currentTimeMillis();
List<String> lookUpIds = Objects.equals(collector.getMode(), JiraMode.Board) ? teams.stream().map(Team::getTeamId).collect(Collectors.toList()) : scopes.stream().map(Scope::getpId).collect(Collectors.toList());
lookUpIds.forEach(l -> {
LOGGER.info("Refreshing issues for " + collector.getMode() + " ID:" + l);
List<String> issueIds = jiraClient.getAllIssueIds(l, collector.getMode());
List<Feature> existingFeatures = Objects.equals(collector.getMode(), JiraMode.Board) ? featureRepository.findAllByCollectorIdAndSTeamID(collector.getId(), l) : featureRepository.findAllByCollectorIdAndSProjectID(collector.getId(), l);
List<Feature> deletedFeatures = existingFeatures.stream().filter(e -> !issueIds.contains(e.getsId())).collect(Collectors.toList());
deletedFeatures.forEach(d -> {
LOGGER.info("Deleting Feature " + d.getsId() + ':' + d.getsName());
featureRepository.delete(d);
});
});
log(collector.getMode() + " Issues Refreshed ", refreshValidIssuesStart);
}
|
[
"private",
"void",
"refreshValidIssues",
"(",
"FeatureCollector",
"collector",
",",
"List",
"<",
"Team",
">",
"teams",
",",
"Set",
"<",
"Scope",
">",
"scopes",
")",
"{",
"long",
"refreshValidIssuesStart",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"List",
"<",
"String",
">",
"lookUpIds",
"=",
"Objects",
".",
"equals",
"(",
"collector",
".",
"getMode",
"(",
")",
",",
"JiraMode",
".",
"Board",
")",
"?",
"teams",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Team",
"::",
"getTeamId",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
":",
"scopes",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Scope",
"::",
"getpId",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"lookUpIds",
".",
"forEach",
"(",
"l",
"->",
"{",
"LOGGER",
".",
"info",
"(",
"\"Refreshing issues for \"",
"+",
"collector",
".",
"getMode",
"(",
")",
"+",
"\" ID:\"",
"+",
"l",
")",
";",
"List",
"<",
"String",
">",
"issueIds",
"=",
"jiraClient",
".",
"getAllIssueIds",
"(",
"l",
",",
"collector",
".",
"getMode",
"(",
")",
")",
";",
"List",
"<",
"Feature",
">",
"existingFeatures",
"=",
"Objects",
".",
"equals",
"(",
"collector",
".",
"getMode",
"(",
")",
",",
"JiraMode",
".",
"Board",
")",
"?",
"featureRepository",
".",
"findAllByCollectorIdAndSTeamID",
"(",
"collector",
".",
"getId",
"(",
")",
",",
"l",
")",
":",
"featureRepository",
".",
"findAllByCollectorIdAndSProjectID",
"(",
"collector",
".",
"getId",
"(",
")",
",",
"l",
")",
";",
"List",
"<",
"Feature",
">",
"deletedFeatures",
"=",
"existingFeatures",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"e",
"->",
"!",
"issueIds",
".",
"contains",
"(",
"e",
".",
"getsId",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"deletedFeatures",
".",
"forEach",
"(",
"d",
"->",
"{",
"LOGGER",
".",
"info",
"(",
"\"Deleting Feature \"",
"+",
"d",
".",
"getsId",
"(",
")",
"+",
"'",
"'",
"+",
"d",
".",
"getsName",
"(",
")",
")",
";",
"featureRepository",
".",
"delete",
"(",
"d",
")",
";",
"}",
")",
";",
"}",
")",
";",
"log",
"(",
"collector",
".",
"getMode",
"(",
")",
"+",
"\" Issues Refreshed \"",
",",
"refreshValidIssuesStart",
")",
";",
"}"
] |
Get a list of all issue ids for a given board or project and delete ones that are not in JIRA anymore
@param collector
@param teams
@param scopes
|
[
"Get",
"a",
"list",
"of",
"all",
"issue",
"ids",
"for",
"a",
"given",
"board",
"or",
"project",
"and",
"delete",
"ones",
"that",
"are",
"not",
"in",
"JIRA",
"anymore"
] |
train
|
https://github.com/Hygieia/Hygieia/blob/d8b67a590da2744acf59bcd99d9b34ef1bb84890/collectors/feature/jira/src/main/java/com/capitalone/dashboard/collector/FeatureCollectorTask.java#L377-L391
|
alkacon/opencms-core
|
src-modules/org/opencms/workplace/tools/modules/CmsCloneModuleThread.java
|
CmsCloneModuleThread.lockResource
|
private boolean lockResource(CmsObject cms, CmsResource cmsResource) throws CmsException {
"""
Locks the current resource.<p>
@param cms the current CmsObject
@param cmsResource the resource to lock
@return <code>true</code> if the given resource was locked was successfully
@throws CmsException if some goes wrong
"""
CmsLock lock = cms.getLock(cms.getSitePath(cmsResource));
// check the lock
if ((lock != null)
&& lock.isOwnedBy(cms.getRequestContext().getCurrentUser())
&& lock.isOwnedInProjectBy(
cms.getRequestContext().getCurrentUser(),
cms.getRequestContext().getCurrentProject())) {
// prove is current lock from current user in current project
return true;
} else if ((lock != null) && !lock.isUnlocked() && !lock.isOwnedBy(cms.getRequestContext().getCurrentUser())) {
// the resource is not locked by the current user, so can not lock it
return false;
} else if ((lock != null)
&& !lock.isUnlocked()
&& lock.isOwnedBy(cms.getRequestContext().getCurrentUser())
&& !lock.isOwnedInProjectBy(
cms.getRequestContext().getCurrentUser(),
cms.getRequestContext().getCurrentProject())) {
// prove is current lock from current user but not in current project
// file is locked by current user but not in current project
cms.changeLock(cms.getSitePath(cmsResource));
} else if ((lock != null) && lock.isUnlocked()) {
// lock resource from current user in current project
cms.lockResource(cms.getSitePath(cmsResource));
}
lock = cms.getLock(cms.getSitePath(cmsResource));
if ((lock != null)
&& lock.isOwnedBy(cms.getRequestContext().getCurrentUser())
&& !lock.isOwnedInProjectBy(
cms.getRequestContext().getCurrentUser(),
cms.getRequestContext().getCurrentProject())) {
// resource could not be locked
return false;
}
// resource is locked successfully
return true;
}
|
java
|
private boolean lockResource(CmsObject cms, CmsResource cmsResource) throws CmsException {
CmsLock lock = cms.getLock(cms.getSitePath(cmsResource));
// check the lock
if ((lock != null)
&& lock.isOwnedBy(cms.getRequestContext().getCurrentUser())
&& lock.isOwnedInProjectBy(
cms.getRequestContext().getCurrentUser(),
cms.getRequestContext().getCurrentProject())) {
// prove is current lock from current user in current project
return true;
} else if ((lock != null) && !lock.isUnlocked() && !lock.isOwnedBy(cms.getRequestContext().getCurrentUser())) {
// the resource is not locked by the current user, so can not lock it
return false;
} else if ((lock != null)
&& !lock.isUnlocked()
&& lock.isOwnedBy(cms.getRequestContext().getCurrentUser())
&& !lock.isOwnedInProjectBy(
cms.getRequestContext().getCurrentUser(),
cms.getRequestContext().getCurrentProject())) {
// prove is current lock from current user but not in current project
// file is locked by current user but not in current project
cms.changeLock(cms.getSitePath(cmsResource));
} else if ((lock != null) && lock.isUnlocked()) {
// lock resource from current user in current project
cms.lockResource(cms.getSitePath(cmsResource));
}
lock = cms.getLock(cms.getSitePath(cmsResource));
if ((lock != null)
&& lock.isOwnedBy(cms.getRequestContext().getCurrentUser())
&& !lock.isOwnedInProjectBy(
cms.getRequestContext().getCurrentUser(),
cms.getRequestContext().getCurrentProject())) {
// resource could not be locked
return false;
}
// resource is locked successfully
return true;
}
|
[
"private",
"boolean",
"lockResource",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"cmsResource",
")",
"throws",
"CmsException",
"{",
"CmsLock",
"lock",
"=",
"cms",
".",
"getLock",
"(",
"cms",
".",
"getSitePath",
"(",
"cmsResource",
")",
")",
";",
"// check the lock",
"if",
"(",
"(",
"lock",
"!=",
"null",
")",
"&&",
"lock",
".",
"isOwnedBy",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
")",
"&&",
"lock",
".",
"isOwnedInProjectBy",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
",",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentProject",
"(",
")",
")",
")",
"{",
"// prove is current lock from current user in current project",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"(",
"lock",
"!=",
"null",
")",
"&&",
"!",
"lock",
".",
"isUnlocked",
"(",
")",
"&&",
"!",
"lock",
".",
"isOwnedBy",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
")",
")",
"{",
"// the resource is not locked by the current user, so can not lock it",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"(",
"lock",
"!=",
"null",
")",
"&&",
"!",
"lock",
".",
"isUnlocked",
"(",
")",
"&&",
"lock",
".",
"isOwnedBy",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
")",
"&&",
"!",
"lock",
".",
"isOwnedInProjectBy",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
",",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentProject",
"(",
")",
")",
")",
"{",
"// prove is current lock from current user but not in current project",
"// file is locked by current user but not in current project",
"cms",
".",
"changeLock",
"(",
"cms",
".",
"getSitePath",
"(",
"cmsResource",
")",
")",
";",
"}",
"else",
"if",
"(",
"(",
"lock",
"!=",
"null",
")",
"&&",
"lock",
".",
"isUnlocked",
"(",
")",
")",
"{",
"// lock resource from current user in current project",
"cms",
".",
"lockResource",
"(",
"cms",
".",
"getSitePath",
"(",
"cmsResource",
")",
")",
";",
"}",
"lock",
"=",
"cms",
".",
"getLock",
"(",
"cms",
".",
"getSitePath",
"(",
"cmsResource",
")",
")",
";",
"if",
"(",
"(",
"lock",
"!=",
"null",
")",
"&&",
"lock",
".",
"isOwnedBy",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
")",
"&&",
"!",
"lock",
".",
"isOwnedInProjectBy",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
",",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentProject",
"(",
")",
")",
")",
"{",
"// resource could not be locked",
"return",
"false",
";",
"}",
"// resource is locked successfully",
"return",
"true",
";",
"}"
] |
Locks the current resource.<p>
@param cms the current CmsObject
@param cmsResource the resource to lock
@return <code>true</code> if the given resource was locked was successfully
@throws CmsException if some goes wrong
|
[
"Locks",
"the",
"current",
"resource",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/modules/CmsCloneModuleThread.java#L844-L883
|
pravega/pravega
|
controller/src/main/java/io/pravega/controller/store/stream/PersistentStreamBase.java
|
PersistentStreamBase.findSegmentSplitsMerges
|
private long findSegmentSplitsMerges(List<StreamSegmentRecord> referenceSegmentsList, List<StreamSegmentRecord> targetSegmentsList) {
"""
Method to calculate number of splits and merges.
Principle to calculate the number of splits and merges:
1- An event has occurred if a reference range is present (overlaps) in at least two consecutive target ranges.
2- If the direction of the check in 1 is forward, then it is a split, otherwise it is a merge.
@param referenceSegmentsList Reference segment list.
@param targetSegmentsList Target segment list.
@return Number of splits/merges.
"""
return referenceSegmentsList.stream().filter(
segment -> targetSegmentsList.stream().filter(target -> target.overlaps(segment)).count() > 1 ).count();
}
|
java
|
private long findSegmentSplitsMerges(List<StreamSegmentRecord> referenceSegmentsList, List<StreamSegmentRecord> targetSegmentsList) {
return referenceSegmentsList.stream().filter(
segment -> targetSegmentsList.stream().filter(target -> target.overlaps(segment)).count() > 1 ).count();
}
|
[
"private",
"long",
"findSegmentSplitsMerges",
"(",
"List",
"<",
"StreamSegmentRecord",
">",
"referenceSegmentsList",
",",
"List",
"<",
"StreamSegmentRecord",
">",
"targetSegmentsList",
")",
"{",
"return",
"referenceSegmentsList",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"segment",
"->",
"targetSegmentsList",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"target",
"->",
"target",
".",
"overlaps",
"(",
"segment",
")",
")",
".",
"count",
"(",
")",
">",
"1",
")",
".",
"count",
"(",
")",
";",
"}"
] |
Method to calculate number of splits and merges.
Principle to calculate the number of splits and merges:
1- An event has occurred if a reference range is present (overlaps) in at least two consecutive target ranges.
2- If the direction of the check in 1 is forward, then it is a split, otherwise it is a merge.
@param referenceSegmentsList Reference segment list.
@param targetSegmentsList Target segment list.
@return Number of splits/merges.
|
[
"Method",
"to",
"calculate",
"number",
"of",
"splits",
"and",
"merges",
"."
] |
train
|
https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/controller/src/main/java/io/pravega/controller/store/stream/PersistentStreamBase.java#L391-L394
|
VoltDB/voltdb
|
src/frontend/org/voltdb/VoltTable.java
|
VoltTable.toJSONString
|
@Override
public String toJSONString() {
"""
Get a JSON representation of this table.
@return A string containing a JSON representation of this table.
"""
JSONStringer js = new JSONStringer();
try {
js.object();
// status code (1 byte)
js.keySymbolValuePair(JSON_STATUS_KEY, getStatusCode());
// column schema
js.key(JSON_SCHEMA_KEY).array();
for (int i = 0; i < getColumnCount(); i++) {
js.object();
js.keySymbolValuePair(JSON_NAME_KEY, getColumnName(i));
js.keySymbolValuePair(JSON_TYPE_KEY, getColumnType(i).getValue());
js.endObject();
}
js.endArray();
// row data
js.key(JSON_DATA_KEY).array();
VoltTableRow row = cloneRow();
row.resetRowPosition();
while (row.advanceRow()) {
js.array();
for (int i = 0; i < getColumnCount(); i++) {
row.putJSONRep(i, js);
}
js.endArray();
}
js.endArray();
js.endObject();
}
catch (JSONException e) {
e.printStackTrace();
throw new RuntimeException("Failed to serialized a table to JSON.", e);
}
return js.toString();
}
|
java
|
@Override
public String toJSONString() {
JSONStringer js = new JSONStringer();
try {
js.object();
// status code (1 byte)
js.keySymbolValuePair(JSON_STATUS_KEY, getStatusCode());
// column schema
js.key(JSON_SCHEMA_KEY).array();
for (int i = 0; i < getColumnCount(); i++) {
js.object();
js.keySymbolValuePair(JSON_NAME_KEY, getColumnName(i));
js.keySymbolValuePair(JSON_TYPE_KEY, getColumnType(i).getValue());
js.endObject();
}
js.endArray();
// row data
js.key(JSON_DATA_KEY).array();
VoltTableRow row = cloneRow();
row.resetRowPosition();
while (row.advanceRow()) {
js.array();
for (int i = 0; i < getColumnCount(); i++) {
row.putJSONRep(i, js);
}
js.endArray();
}
js.endArray();
js.endObject();
}
catch (JSONException e) {
e.printStackTrace();
throw new RuntimeException("Failed to serialized a table to JSON.", e);
}
return js.toString();
}
|
[
"@",
"Override",
"public",
"String",
"toJSONString",
"(",
")",
"{",
"JSONStringer",
"js",
"=",
"new",
"JSONStringer",
"(",
")",
";",
"try",
"{",
"js",
".",
"object",
"(",
")",
";",
"// status code (1 byte)",
"js",
".",
"keySymbolValuePair",
"(",
"JSON_STATUS_KEY",
",",
"getStatusCode",
"(",
")",
")",
";",
"// column schema",
"js",
".",
"key",
"(",
"JSON_SCHEMA_KEY",
")",
".",
"array",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getColumnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"js",
".",
"object",
"(",
")",
";",
"js",
".",
"keySymbolValuePair",
"(",
"JSON_NAME_KEY",
",",
"getColumnName",
"(",
"i",
")",
")",
";",
"js",
".",
"keySymbolValuePair",
"(",
"JSON_TYPE_KEY",
",",
"getColumnType",
"(",
"i",
")",
".",
"getValue",
"(",
")",
")",
";",
"js",
".",
"endObject",
"(",
")",
";",
"}",
"js",
".",
"endArray",
"(",
")",
";",
"// row data",
"js",
".",
"key",
"(",
"JSON_DATA_KEY",
")",
".",
"array",
"(",
")",
";",
"VoltTableRow",
"row",
"=",
"cloneRow",
"(",
")",
";",
"row",
".",
"resetRowPosition",
"(",
")",
";",
"while",
"(",
"row",
".",
"advanceRow",
"(",
")",
")",
"{",
"js",
".",
"array",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"getColumnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"row",
".",
"putJSONRep",
"(",
"i",
",",
"js",
")",
";",
"}",
"js",
".",
"endArray",
"(",
")",
";",
"}",
"js",
".",
"endArray",
"(",
")",
";",
"js",
".",
"endObject",
"(",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to serialized a table to JSON.\"",
",",
"e",
")",
";",
"}",
"return",
"js",
".",
"toString",
"(",
")",
";",
"}"
] |
Get a JSON representation of this table.
@return A string containing a JSON representation of this table.
|
[
"Get",
"a",
"JSON",
"representation",
"of",
"this",
"table",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltTable.java#L1722-L1762
|
ManfredTremmel/gwt-commons-lang3
|
src/main/java/org/apache/commons/lang3/concurrent/Memoizer.java
|
Memoizer.launderException
|
private RuntimeException launderException(final Throwable throwable) {
"""
<p>
This method launders a Throwable to either a RuntimeException, Error or
any other Exception wrapped in an IllegalStateException.
</p>
@param throwable
the throwable to laundered
@return a RuntimeException, Error or an IllegalStateException
"""
if (throwable instanceof RuntimeException) {
return (RuntimeException) throwable;
} else if (throwable instanceof Error) {
throw (Error) throwable;
} else {
throw new IllegalStateException("Unchecked exception", throwable);
}
}
|
java
|
private RuntimeException launderException(final Throwable throwable) {
if (throwable instanceof RuntimeException) {
return (RuntimeException) throwable;
} else if (throwable instanceof Error) {
throw (Error) throwable;
} else {
throw new IllegalStateException("Unchecked exception", throwable);
}
}
|
[
"private",
"RuntimeException",
"launderException",
"(",
"final",
"Throwable",
"throwable",
")",
"{",
"if",
"(",
"throwable",
"instanceof",
"RuntimeException",
")",
"{",
"return",
"(",
"RuntimeException",
")",
"throwable",
";",
"}",
"else",
"if",
"(",
"throwable",
"instanceof",
"Error",
")",
"{",
"throw",
"(",
"Error",
")",
"throwable",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unchecked exception\"",
",",
"throwable",
")",
";",
"}",
"}"
] |
<p>
This method launders a Throwable to either a RuntimeException, Error or
any other Exception wrapped in an IllegalStateException.
</p>
@param throwable
the throwable to laundered
@return a RuntimeException, Error or an IllegalStateException
|
[
"<p",
">",
"This",
"method",
"launders",
"a",
"Throwable",
"to",
"either",
"a",
"RuntimeException",
"Error",
"or",
"any",
"other",
"Exception",
"wrapped",
"in",
"an",
"IllegalStateException",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/concurrent/Memoizer.java#L159-L167
|
Azure/azure-sdk-for-java
|
eventgrid/resource-manager/v2018_09_15_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_09_15_preview/implementation/EventSubscriptionsInner.java
|
EventSubscriptionsInner.listByDomainTopicAsync
|
public Observable<List<EventSubscriptionInner>> listByDomainTopicAsync(String resourceGroupName, String domainName, String topicName) {
"""
List all event subscriptions for a specific domain topic.
List all event subscriptions that have been created for a specific domain topic.
@param resourceGroupName The name of the resource group within the user's subscription.
@param domainName Name of the top level domain
@param topicName Name of the domain topic
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<EventSubscriptionInner> object
"""
return listByDomainTopicWithServiceResponseAsync(resourceGroupName, domainName, topicName).map(new Func1<ServiceResponse<List<EventSubscriptionInner>>, List<EventSubscriptionInner>>() {
@Override
public List<EventSubscriptionInner> call(ServiceResponse<List<EventSubscriptionInner>> response) {
return response.body();
}
});
}
|
java
|
public Observable<List<EventSubscriptionInner>> listByDomainTopicAsync(String resourceGroupName, String domainName, String topicName) {
return listByDomainTopicWithServiceResponseAsync(resourceGroupName, domainName, topicName).map(new Func1<ServiceResponse<List<EventSubscriptionInner>>, List<EventSubscriptionInner>>() {
@Override
public List<EventSubscriptionInner> call(ServiceResponse<List<EventSubscriptionInner>> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"List",
"<",
"EventSubscriptionInner",
">",
">",
"listByDomainTopicAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"domainName",
",",
"String",
"topicName",
")",
"{",
"return",
"listByDomainTopicWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"domainName",
",",
"topicName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"EventSubscriptionInner",
">",
">",
",",
"List",
"<",
"EventSubscriptionInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"EventSubscriptionInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"EventSubscriptionInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
List all event subscriptions for a specific domain topic.
List all event subscriptions that have been created for a specific domain topic.
@param resourceGroupName The name of the resource group within the user's subscription.
@param domainName Name of the top level domain
@param topicName Name of the domain topic
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<EventSubscriptionInner> object
|
[
"List",
"all",
"event",
"subscriptions",
"for",
"a",
"specific",
"domain",
"topic",
".",
"List",
"all",
"event",
"subscriptions",
"that",
"have",
"been",
"created",
"for",
"a",
"specific",
"domain",
"topic",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/resource-manager/v2018_09_15_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_09_15_preview/implementation/EventSubscriptionsInner.java#L1707-L1714
|
eclipse/xtext-extras
|
org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/util/TypeParameterSubstitutor.java
|
TypeParameterSubstitutor.visitTypeArgument
|
protected LightweightTypeReference visitTypeArgument(LightweightTypeReference reference, Visiting visiting) {
"""
This is equivalent to {@code visitTypeArgument(reference, visiting, false)}.
@see #visitTypeArgument(LightweightTypeReference, Object, boolean)
"""
return visitTypeArgument(reference, visiting, false);
}
|
java
|
protected LightweightTypeReference visitTypeArgument(LightweightTypeReference reference, Visiting visiting) {
return visitTypeArgument(reference, visiting, false);
}
|
[
"protected",
"LightweightTypeReference",
"visitTypeArgument",
"(",
"LightweightTypeReference",
"reference",
",",
"Visiting",
"visiting",
")",
"{",
"return",
"visitTypeArgument",
"(",
"reference",
",",
"visiting",
",",
"false",
")",
";",
"}"
] |
This is equivalent to {@code visitTypeArgument(reference, visiting, false)}.
@see #visitTypeArgument(LightweightTypeReference, Object, boolean)
|
[
"This",
"is",
"equivalent",
"to",
"{",
"@code",
"visitTypeArgument",
"(",
"reference",
"visiting",
"false",
")",
"}",
"."
] |
train
|
https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/util/TypeParameterSubstitutor.java#L95-L97
|
jbundle/jbundle
|
thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/transport/ServletMessage.java
|
ServletMessage.sendMessage
|
public InputStream sendMessage(Properties args, int method)
throws IOException {
"""
Send the request. Return the input stream with the response if
the request succeeds.
@param args the arguments to send to the servlet
@param method GET or POST
@exception IOException if error sending request
@return the response from the servlet to this message
"""
// Set this up any way you want -- POST can be used for all calls,
// but request headers cannot be set in JDK 1.0.2 so the query
// string still must be used to pass arguments.
if (method == GET)
{
URL url = new URL(servlet.toExternalForm() + "?" + toEncodedString(args));
return url.openStream();
}
else
{
URLConnection conn = servlet.openConnection();
conn.setDoOutput(true);
conn.setUseCaches(false);
// POST the request data (html form encoded)
PrintStream out = new PrintStream(conn.getOutputStream());
if (args != null && args.size() > 0)
{
out.print(toEncodedString(args));
}
out.close(); // ESSENTIAL for this to work!
// Read the POST response data
return conn.getInputStream();
}
}
|
java
|
public InputStream sendMessage(Properties args, int method)
throws IOException {
// Set this up any way you want -- POST can be used for all calls,
// but request headers cannot be set in JDK 1.0.2 so the query
// string still must be used to pass arguments.
if (method == GET)
{
URL url = new URL(servlet.toExternalForm() + "?" + toEncodedString(args));
return url.openStream();
}
else
{
URLConnection conn = servlet.openConnection();
conn.setDoOutput(true);
conn.setUseCaches(false);
// POST the request data (html form encoded)
PrintStream out = new PrintStream(conn.getOutputStream());
if (args != null && args.size() > 0)
{
out.print(toEncodedString(args));
}
out.close(); // ESSENTIAL for this to work!
// Read the POST response data
return conn.getInputStream();
}
}
|
[
"public",
"InputStream",
"sendMessage",
"(",
"Properties",
"args",
",",
"int",
"method",
")",
"throws",
"IOException",
"{",
"// Set this up any way you want -- POST can be used for all calls,",
"// but request headers cannot be set in JDK 1.0.2 so the query",
"// string still must be used to pass arguments.",
"if",
"(",
"method",
"==",
"GET",
")",
"{",
"URL",
"url",
"=",
"new",
"URL",
"(",
"servlet",
".",
"toExternalForm",
"(",
")",
"+",
"\"?\"",
"+",
"toEncodedString",
"(",
"args",
")",
")",
";",
"return",
"url",
".",
"openStream",
"(",
")",
";",
"}",
"else",
"{",
"URLConnection",
"conn",
"=",
"servlet",
".",
"openConnection",
"(",
")",
";",
"conn",
".",
"setDoOutput",
"(",
"true",
")",
";",
"conn",
".",
"setUseCaches",
"(",
"false",
")",
";",
"// POST the request data (html form encoded)",
"PrintStream",
"out",
"=",
"new",
"PrintStream",
"(",
"conn",
".",
"getOutputStream",
"(",
")",
")",
";",
"if",
"(",
"args",
"!=",
"null",
"&&",
"args",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"out",
".",
"print",
"(",
"toEncodedString",
"(",
"args",
")",
")",
";",
"}",
"out",
".",
"close",
"(",
")",
";",
"// ESSENTIAL for this to work!",
"// Read the POST response data",
"return",
"conn",
".",
"getInputStream",
"(",
")",
";",
"}",
"}"
] |
Send the request. Return the input stream with the response if
the request succeeds.
@param args the arguments to send to the servlet
@param method GET or POST
@exception IOException if error sending request
@return the response from the servlet to this message
|
[
"Send",
"the",
"request",
".",
"Return",
"the",
"input",
"stream",
"with",
"the",
"response",
"if",
"the",
"request",
"succeeds",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/transport/ServletMessage.java#L68-L96
|
javagl/Common
|
src/main/java/de/javagl/common/collections/Maps.java
|
Maps.getCount
|
public static <K> Integer getCount(Map<K, Integer> map, K k) {
"""
Returns the value that is stored for the given key in the given map.
If there is no value stored, then 0 will be inserted into the map
and returned
@param <K> The key type
@param map The map
@param k The key
@return The value
"""
Integer count = map.get(k);
if (count == null)
{
count = 0;
map.put(k, count);
}
return count;
}
|
java
|
public static <K> Integer getCount(Map<K, Integer> map, K k)
{
Integer count = map.get(k);
if (count == null)
{
count = 0;
map.put(k, count);
}
return count;
}
|
[
"public",
"static",
"<",
"K",
">",
"Integer",
"getCount",
"(",
"Map",
"<",
"K",
",",
"Integer",
">",
"map",
",",
"K",
"k",
")",
"{",
"Integer",
"count",
"=",
"map",
".",
"get",
"(",
"k",
")",
";",
"if",
"(",
"count",
"==",
"null",
")",
"{",
"count",
"=",
"0",
";",
"map",
".",
"put",
"(",
"k",
",",
"count",
")",
";",
"}",
"return",
"count",
";",
"}"
] |
Returns the value that is stored for the given key in the given map.
If there is no value stored, then 0 will be inserted into the map
and returned
@param <K> The key type
@param map The map
@param k The key
@return The value
|
[
"Returns",
"the",
"value",
"that",
"is",
"stored",
"for",
"the",
"given",
"key",
"in",
"the",
"given",
"map",
".",
"If",
"there",
"is",
"no",
"value",
"stored",
"then",
"0",
"will",
"be",
"inserted",
"into",
"the",
"map",
"and",
"returned"
] |
train
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/collections/Maps.java#L67-L76
|
stephenc/java-iso-tools
|
iso9660-writer/src/main/java/com/github/stephenc/javaisotools/rockridge/impl/RockRidgeConfig.java
|
RockRidgeConfig.addModeForPattern
|
public void addModeForPattern(String pattern, Integer mode) {
"""
Add a new mode for a specific file pattern.
@param pattern the pattern to be matched
@param mode the POSIX file mode for matching filenames
"""
System.out.println(String.format("*** Recording pattern \"%s\" with mode %o", pattern, mode));
patternToModeMap.put(pattern, mode);
}
|
java
|
public void addModeForPattern(String pattern, Integer mode) {
System.out.println(String.format("*** Recording pattern \"%s\" with mode %o", pattern, mode));
patternToModeMap.put(pattern, mode);
}
|
[
"public",
"void",
"addModeForPattern",
"(",
"String",
"pattern",
",",
"Integer",
"mode",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"*** Recording pattern \\\"%s\\\" with mode %o\"",
",",
"pattern",
",",
"mode",
")",
")",
";",
"patternToModeMap",
".",
"put",
"(",
"pattern",
",",
"mode",
")",
";",
"}"
] |
Add a new mode for a specific file pattern.
@param pattern the pattern to be matched
@param mode the POSIX file mode for matching filenames
|
[
"Add",
"a",
"new",
"mode",
"for",
"a",
"specific",
"file",
"pattern",
"."
] |
train
|
https://github.com/stephenc/java-iso-tools/blob/828c50b02eb311a14dde0dab43462a0d0c9dfb06/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/rockridge/impl/RockRidgeConfig.java#L95-L98
|
alkacon/opencms-core
|
src/org/opencms/ui/apps/sitemanager/CmsGlobalForm.java
|
CmsGlobalForm.setServerLayout
|
private void setServerLayout(final List<CmsSite> sites) {
"""
Fills the layout with combo boxes for all setted workplace servers + one combo box for adding further urls.<p>
@param sites from sitemanager
"""
m_workplaceServerGroup = new CmsEditableGroup(m_serverLayout, new Supplier<Component>() {
public Component get() {
CmsWorkplaceServerWidget row = new CmsWorkplaceServerWidget(sites, null);
return row;
}
}, "Add");
for (String server : OpenCms.getSiteManager().getWorkplaceServers()) {
CmsWorkplaceServerWidget row = new CmsWorkplaceServerWidget(sites, server);
m_workplaceServerGroup.addRow(row);
}
}
|
java
|
private void setServerLayout(final List<CmsSite> sites) {
m_workplaceServerGroup = new CmsEditableGroup(m_serverLayout, new Supplier<Component>() {
public Component get() {
CmsWorkplaceServerWidget row = new CmsWorkplaceServerWidget(sites, null);
return row;
}
}, "Add");
for (String server : OpenCms.getSiteManager().getWorkplaceServers()) {
CmsWorkplaceServerWidget row = new CmsWorkplaceServerWidget(sites, server);
m_workplaceServerGroup.addRow(row);
}
}
|
[
"private",
"void",
"setServerLayout",
"(",
"final",
"List",
"<",
"CmsSite",
">",
"sites",
")",
"{",
"m_workplaceServerGroup",
"=",
"new",
"CmsEditableGroup",
"(",
"m_serverLayout",
",",
"new",
"Supplier",
"<",
"Component",
">",
"(",
")",
"{",
"public",
"Component",
"get",
"(",
")",
"{",
"CmsWorkplaceServerWidget",
"row",
"=",
"new",
"CmsWorkplaceServerWidget",
"(",
"sites",
",",
"null",
")",
";",
"return",
"row",
";",
"}",
"}",
",",
"\"Add\"",
")",
";",
"for",
"(",
"String",
"server",
":",
"OpenCms",
".",
"getSiteManager",
"(",
")",
".",
"getWorkplaceServers",
"(",
")",
")",
"{",
"CmsWorkplaceServerWidget",
"row",
"=",
"new",
"CmsWorkplaceServerWidget",
"(",
"sites",
",",
"server",
")",
";",
"m_workplaceServerGroup",
".",
"addRow",
"(",
"row",
")",
";",
"}",
"}"
] |
Fills the layout with combo boxes for all setted workplace servers + one combo box for adding further urls.<p>
@param sites from sitemanager
|
[
"Fills",
"the",
"layout",
"with",
"combo",
"boxes",
"for",
"all",
"setted",
"workplace",
"servers",
"+",
"one",
"combo",
"box",
"for",
"adding",
"further",
"urls",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/sitemanager/CmsGlobalForm.java#L236-L251
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/AreaUtils.java
|
AreaUtils.isNeighbor
|
public static boolean isNeighbor(Area a1, Area a2) {
"""
Checks if the given areas are in the same visual group (i.e. "are near each other").
@param a1
@param a2
@return
"""
if (isOnSameLine(a1, a2))
return true; //on the same line
else
{
//the Y difference is less than half the line height
int dy = a2.getBounds().getY1() - a1.getBounds().getY2();
if (dy < 0)
dy = a1.getBounds().getY1() - a2.getBounds().getY2();
return dy < a1.getBounds().getHeight() / 2;
}
}
|
java
|
public static boolean isNeighbor(Area a1, Area a2)
{
if (isOnSameLine(a1, a2))
return true; //on the same line
else
{
//the Y difference is less than half the line height
int dy = a2.getBounds().getY1() - a1.getBounds().getY2();
if (dy < 0)
dy = a1.getBounds().getY1() - a2.getBounds().getY2();
return dy < a1.getBounds().getHeight() / 2;
}
}
|
[
"public",
"static",
"boolean",
"isNeighbor",
"(",
"Area",
"a1",
",",
"Area",
"a2",
")",
"{",
"if",
"(",
"isOnSameLine",
"(",
"a1",
",",
"a2",
")",
")",
"return",
"true",
";",
"//on the same line",
"else",
"{",
"//the Y difference is less than half the line height",
"int",
"dy",
"=",
"a2",
".",
"getBounds",
"(",
")",
".",
"getY1",
"(",
")",
"-",
"a1",
".",
"getBounds",
"(",
")",
".",
"getY2",
"(",
")",
";",
"if",
"(",
"dy",
"<",
"0",
")",
"dy",
"=",
"a1",
".",
"getBounds",
"(",
")",
".",
"getY1",
"(",
")",
"-",
"a2",
".",
"getBounds",
"(",
")",
".",
"getY2",
"(",
")",
";",
"return",
"dy",
"<",
"a1",
".",
"getBounds",
"(",
")",
".",
"getHeight",
"(",
")",
"/",
"2",
";",
"}",
"}"
] |
Checks if the given areas are in the same visual group (i.e. "are near each other").
@param a1
@param a2
@return
|
[
"Checks",
"if",
"the",
"given",
"areas",
"are",
"in",
"the",
"same",
"visual",
"group",
"(",
"i",
".",
"e",
".",
"are",
"near",
"each",
"other",
")",
"."
] |
train
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/AreaUtils.java#L28-L40
|
wisdom-framework/wisdom
|
framework/thymeleaf-template-engine/src/main/java/org/wisdom/template/thymeleaf/ThymeleafTemplateCollector.java
|
ThymeleafTemplateCollector.updatedTemplate
|
public void updatedTemplate(Bundle bundle, File templateFile) {
"""
Updates the template object using the given file as backend.
@param bundle the bundle containing the template, use system bundle for external templates.
@param templateFile the template file
"""
ThymeLeafTemplateImplementation template = getTemplateByFile(templateFile);
if (template != null) {
LOGGER.debug("Thymeleaf template updated for {} ({})", templateFile.getAbsoluteFile(), template.fullName());
updatedTemplate();
} else {
try {
addTemplate(bundle, templateFile.toURI().toURL());
} catch (MalformedURLException e) { //NOSONAR
// Ignored.
}
}
}
|
java
|
public void updatedTemplate(Bundle bundle, File templateFile) {
ThymeLeafTemplateImplementation template = getTemplateByFile(templateFile);
if (template != null) {
LOGGER.debug("Thymeleaf template updated for {} ({})", templateFile.getAbsoluteFile(), template.fullName());
updatedTemplate();
} else {
try {
addTemplate(bundle, templateFile.toURI().toURL());
} catch (MalformedURLException e) { //NOSONAR
// Ignored.
}
}
}
|
[
"public",
"void",
"updatedTemplate",
"(",
"Bundle",
"bundle",
",",
"File",
"templateFile",
")",
"{",
"ThymeLeafTemplateImplementation",
"template",
"=",
"getTemplateByFile",
"(",
"templateFile",
")",
";",
"if",
"(",
"template",
"!=",
"null",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Thymeleaf template updated for {} ({})\"",
",",
"templateFile",
".",
"getAbsoluteFile",
"(",
")",
",",
"template",
".",
"fullName",
"(",
")",
")",
";",
"updatedTemplate",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"addTemplate",
"(",
"bundle",
",",
"templateFile",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"//NOSONAR",
"// Ignored.",
"}",
"}",
"}"
] |
Updates the template object using the given file as backend.
@param bundle the bundle containing the template, use system bundle for external templates.
@param templateFile the template file
|
[
"Updates",
"the",
"template",
"object",
"using",
"the",
"given",
"file",
"as",
"backend",
"."
] |
train
|
https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/framework/thymeleaf-template-engine/src/main/java/org/wisdom/template/thymeleaf/ThymeleafTemplateCollector.java#L125-L137
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/ResourceAssignment.java
|
ResourceAssignment.setBaselineFinish
|
public void setBaselineFinish(int baselineNumber, Date value) {
"""
Set a baseline value.
@param baselineNumber baseline index (1-10)
@param value baseline value
"""
set(selectField(AssignmentFieldLists.BASELINE_FINISHES, baselineNumber), value);
}
|
java
|
public void setBaselineFinish(int baselineNumber, Date value)
{
set(selectField(AssignmentFieldLists.BASELINE_FINISHES, baselineNumber), value);
}
|
[
"public",
"void",
"setBaselineFinish",
"(",
"int",
"baselineNumber",
",",
"Date",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"AssignmentFieldLists",
".",
"BASELINE_FINISHES",
",",
"baselineNumber",
")",
",",
"value",
")",
";",
"}"
] |
Set a baseline value.
@param baselineNumber baseline index (1-10)
@param value baseline value
|
[
"Set",
"a",
"baseline",
"value",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ResourceAssignment.java#L1452-L1455
|
Azure/azure-sdk-for-java
|
batch/data-plane/src/main/java/com/microsoft/azure/batch/JobOperations.java
|
JobOperations.disableJob
|
public void disableJob(String jobId, DisableJobOption disableJobOption, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
"""
Disables the specified job. Disabled jobs do not run new tasks, but may be re-enabled later.
@param jobId The ID of the job.
@param disableJobOption Specifies what to do with running tasks associated with the job.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
"""
JobDisableOptions options = new JobDisableOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
this.parentBatchClient.protocolLayer().jobs().disable(jobId, disableJobOption, options);
}
|
java
|
public void disableJob(String jobId, DisableJobOption disableJobOption, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
JobDisableOptions options = new JobDisableOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
this.parentBatchClient.protocolLayer().jobs().disable(jobId, disableJobOption, options);
}
|
[
"public",
"void",
"disableJob",
"(",
"String",
"jobId",
",",
"DisableJobOption",
"disableJobOption",
",",
"Iterable",
"<",
"BatchClientBehavior",
">",
"additionalBehaviors",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"JobDisableOptions",
"options",
"=",
"new",
"JobDisableOptions",
"(",
")",
";",
"BehaviorManager",
"bhMgr",
"=",
"new",
"BehaviorManager",
"(",
"this",
".",
"customBehaviors",
"(",
")",
",",
"additionalBehaviors",
")",
";",
"bhMgr",
".",
"applyRequestBehaviors",
"(",
"options",
")",
";",
"this",
".",
"parentBatchClient",
".",
"protocolLayer",
"(",
")",
".",
"jobs",
"(",
")",
".",
"disable",
"(",
"jobId",
",",
"disableJobOption",
",",
"options",
")",
";",
"}"
] |
Disables the specified job. Disabled jobs do not run new tasks, but may be re-enabled later.
@param jobId The ID of the job.
@param disableJobOption Specifies what to do with running tasks associated with the job.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
|
[
"Disables",
"the",
"specified",
"job",
".",
"Disabled",
"jobs",
"do",
"not",
"run",
"new",
"tasks",
"but",
"may",
"be",
"re",
"-",
"enabled",
"later",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/JobOperations.java#L439-L445
|
Azure/azure-sdk-for-java
|
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java
|
KeyVaultClientBaseImpl.updateStorageAccountAsync
|
public ServiceFuture<StorageBundle> updateStorageAccountAsync(String vaultBaseUrl, String storageAccountName, String activeKeyName, Boolean autoRegenerateKey, String regenerationPeriod, StorageAccountAttributes storageAccountAttributes, Map<String, String> tags, final ServiceCallback<StorageBundle> serviceCallback) {
"""
Updates the specified attributes associated with the given storage account. This operation requires the storage/set/update permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@param activeKeyName The current active storage account key name.
@param autoRegenerateKey whether keyvault should manage the storage account for the user.
@param regenerationPeriod The key regeneration time duration specified in ISO-8601 format.
@param storageAccountAttributes The attributes of the storage account.
@param tags Application specific metadata in the form of key-value pairs.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return ServiceFuture.fromResponse(updateStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName, activeKeyName, autoRegenerateKey, regenerationPeriod, storageAccountAttributes, tags), serviceCallback);
}
|
java
|
public ServiceFuture<StorageBundle> updateStorageAccountAsync(String vaultBaseUrl, String storageAccountName, String activeKeyName, Boolean autoRegenerateKey, String regenerationPeriod, StorageAccountAttributes storageAccountAttributes, Map<String, String> tags, final ServiceCallback<StorageBundle> serviceCallback) {
return ServiceFuture.fromResponse(updateStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName, activeKeyName, autoRegenerateKey, regenerationPeriod, storageAccountAttributes, tags), serviceCallback);
}
|
[
"public",
"ServiceFuture",
"<",
"StorageBundle",
">",
"updateStorageAccountAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"storageAccountName",
",",
"String",
"activeKeyName",
",",
"Boolean",
"autoRegenerateKey",
",",
"String",
"regenerationPeriod",
",",
"StorageAccountAttributes",
"storageAccountAttributes",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
",",
"final",
"ServiceCallback",
"<",
"StorageBundle",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"updateStorageAccountWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"storageAccountName",
",",
"activeKeyName",
",",
"autoRegenerateKey",
",",
"regenerationPeriod",
",",
"storageAccountAttributes",
",",
"tags",
")",
",",
"serviceCallback",
")",
";",
"}"
] |
Updates the specified attributes associated with the given storage account. This operation requires the storage/set/update permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@param activeKeyName The current active storage account key name.
@param autoRegenerateKey whether keyvault should manage the storage account for the user.
@param regenerationPeriod The key regeneration time duration specified in ISO-8601 format.
@param storageAccountAttributes The attributes of the storage account.
@param tags Application specific metadata in the form of key-value pairs.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
|
[
"Updates",
"the",
"specified",
"attributes",
"associated",
"with",
"the",
"given",
"storage",
"account",
".",
"This",
"operation",
"requires",
"the",
"storage",
"/",
"set",
"/",
"update",
"permission",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L10204-L10206
|
OpenTSDB/opentsdb
|
src/tree/TreeBuilder.java
|
TreeBuilder.processParsedValue
|
private void processParsedValue(final String parsed_value) {
"""
Routes the parsed value to the proper processing method for altering the
display name depending on the current rule. This can route to the regex
handler or the split processor. Or if neither splits or regex are specified
for the rule, the parsed value is set as the branch name.
@param parsed_value The value parsed from the calling parser method
@throws IllegalStateException if a valid processor couldn't be found. This
should never happen but you never know.
"""
if (rule.getCompiledRegex() == null &&
(rule.getSeparator() == null || rule.getSeparator().isEmpty())) {
// we don't have a regex and we don't need to separate, so just use the
// name of the timseries
setCurrentName(parsed_value, parsed_value);
} else if (rule.getCompiledRegex() != null) {
// we have a regex rule, so deal with it
processRegexRule(parsed_value);
} else if (rule.getSeparator() != null && !rule.getSeparator().isEmpty()) {
// we have a split rule, so deal with it
processSplit(parsed_value);
} else {
throw new IllegalStateException("Unable to find a processor for rule: " +
rule);
}
}
|
java
|
private void processParsedValue(final String parsed_value) {
if (rule.getCompiledRegex() == null &&
(rule.getSeparator() == null || rule.getSeparator().isEmpty())) {
// we don't have a regex and we don't need to separate, so just use the
// name of the timseries
setCurrentName(parsed_value, parsed_value);
} else if (rule.getCompiledRegex() != null) {
// we have a regex rule, so deal with it
processRegexRule(parsed_value);
} else if (rule.getSeparator() != null && !rule.getSeparator().isEmpty()) {
// we have a split rule, so deal with it
processSplit(parsed_value);
} else {
throw new IllegalStateException("Unable to find a processor for rule: " +
rule);
}
}
|
[
"private",
"void",
"processParsedValue",
"(",
"final",
"String",
"parsed_value",
")",
"{",
"if",
"(",
"rule",
".",
"getCompiledRegex",
"(",
")",
"==",
"null",
"&&",
"(",
"rule",
".",
"getSeparator",
"(",
")",
"==",
"null",
"||",
"rule",
".",
"getSeparator",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"// we don't have a regex and we don't need to separate, so just use the",
"// name of the timseries",
"setCurrentName",
"(",
"parsed_value",
",",
"parsed_value",
")",
";",
"}",
"else",
"if",
"(",
"rule",
".",
"getCompiledRegex",
"(",
")",
"!=",
"null",
")",
"{",
"// we have a regex rule, so deal with it",
"processRegexRule",
"(",
"parsed_value",
")",
";",
"}",
"else",
"if",
"(",
"rule",
".",
"getSeparator",
"(",
")",
"!=",
"null",
"&&",
"!",
"rule",
".",
"getSeparator",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"// we have a split rule, so deal with it",
"processSplit",
"(",
"parsed_value",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unable to find a processor for rule: \"",
"+",
"rule",
")",
";",
"}",
"}"
] |
Routes the parsed value to the proper processing method for altering the
display name depending on the current rule. This can route to the regex
handler or the split processor. Or if neither splits or regex are specified
for the rule, the parsed value is set as the branch name.
@param parsed_value The value parsed from the calling parser method
@throws IllegalStateException if a valid processor couldn't be found. This
should never happen but you never know.
|
[
"Routes",
"the",
"parsed",
"value",
"to",
"the",
"proper",
"processing",
"method",
"for",
"altering",
"the",
"display",
"name",
"depending",
"on",
"the",
"current",
"rule",
".",
"This",
"can",
"route",
"to",
"the",
"regex",
"handler",
"or",
"the",
"split",
"processor",
".",
"Or",
"if",
"neither",
"splits",
"or",
"regex",
"are",
"specified",
"for",
"the",
"rule",
"the",
"parsed",
"value",
"is",
"set",
"as",
"the",
"branch",
"name",
"."
] |
train
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tree/TreeBuilder.java#L932-L948
|
ldapchai/ldapchai
|
src/main/java/com/novell/ldapchai/util/SearchHelper.java
|
SearchHelper.setFilterNot
|
public void setFilterNot( final String attributeName, final String value ) {
"""
Set up a not exists filter for an attribute name and value pair.
<table border="1"><caption>Example Values</caption>
<tr><td><b>Attribute</b></td><td><b>Value</b></td></tr>
<tr><td>givenName</td><td>John</td></tr>
</table>
<p><i>Result</i></p>
<code>(!(givenName=John))</code>
@param attributeName A valid attribute name
@param value A value that, if it exists, will cause the object to be excluded from the result set.
"""
this.setFilter( attributeName, value );
filter = "(!" + filter + ")";
}
|
java
|
public void setFilterNot( final String attributeName, final String value )
{
this.setFilter( attributeName, value );
filter = "(!" + filter + ")";
}
|
[
"public",
"void",
"setFilterNot",
"(",
"final",
"String",
"attributeName",
",",
"final",
"String",
"value",
")",
"{",
"this",
".",
"setFilter",
"(",
"attributeName",
",",
"value",
")",
";",
"filter",
"=",
"\"(!\"",
"+",
"filter",
"+",
"\")\"",
";",
"}"
] |
Set up a not exists filter for an attribute name and value pair.
<table border="1"><caption>Example Values</caption>
<tr><td><b>Attribute</b></td><td><b>Value</b></td></tr>
<tr><td>givenName</td><td>John</td></tr>
</table>
<p><i>Result</i></p>
<code>(!(givenName=John))</code>
@param attributeName A valid attribute name
@param value A value that, if it exists, will cause the object to be excluded from the result set.
|
[
"Set",
"up",
"a",
"not",
"exists",
"filter",
"for",
"an",
"attribute",
"name",
"and",
"value",
"pair",
"."
] |
train
|
https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/SearchHelper.java#L575-L579
|
elki-project/elki
|
elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java
|
KernelMatrix.centerMatrix
|
public static double[][] centerMatrix(final double[][] matrix) {
"""
Centers the matrix in feature space according to Smola et Schoelkopf,
Learning with Kernels p. 431 Alters the input matrix. If you still need the
original matrix, use
<code>centeredMatrix = centerKernelMatrix(uncenteredMatrix.copy()) {</code>
@param matrix the matrix to be centered
@return centered matrix (for convenience)
"""
// FIXME: implement more efficiently. Maybe in matrix class itself?
final double[][] normalizingMatrix = new double[matrix.length][matrix[0].length];
for(double[] row : normalizingMatrix) {
Arrays.fill(row, 1.0 / matrix[0].length);
}
return times(plusEquals(minusEquals(minus(matrix, times(normalizingMatrix, matrix)), times(matrix, normalizingMatrix)), times(normalizingMatrix, matrix)), normalizingMatrix);
}
|
java
|
public static double[][] centerMatrix(final double[][] matrix) {
// FIXME: implement more efficiently. Maybe in matrix class itself?
final double[][] normalizingMatrix = new double[matrix.length][matrix[0].length];
for(double[] row : normalizingMatrix) {
Arrays.fill(row, 1.0 / matrix[0].length);
}
return times(plusEquals(minusEquals(minus(matrix, times(normalizingMatrix, matrix)), times(matrix, normalizingMatrix)), times(normalizingMatrix, matrix)), normalizingMatrix);
}
|
[
"public",
"static",
"double",
"[",
"]",
"[",
"]",
"centerMatrix",
"(",
"final",
"double",
"[",
"]",
"[",
"]",
"matrix",
")",
"{",
"// FIXME: implement more efficiently. Maybe in matrix class itself?",
"final",
"double",
"[",
"]",
"[",
"]",
"normalizingMatrix",
"=",
"new",
"double",
"[",
"matrix",
".",
"length",
"]",
"[",
"matrix",
"[",
"0",
"]",
".",
"length",
"]",
";",
"for",
"(",
"double",
"[",
"]",
"row",
":",
"normalizingMatrix",
")",
"{",
"Arrays",
".",
"fill",
"(",
"row",
",",
"1.0",
"/",
"matrix",
"[",
"0",
"]",
".",
"length",
")",
";",
"}",
"return",
"times",
"(",
"plusEquals",
"(",
"minusEquals",
"(",
"minus",
"(",
"matrix",
",",
"times",
"(",
"normalizingMatrix",
",",
"matrix",
")",
")",
",",
"times",
"(",
"matrix",
",",
"normalizingMatrix",
")",
")",
",",
"times",
"(",
"normalizingMatrix",
",",
"matrix",
")",
")",
",",
"normalizingMatrix",
")",
";",
"}"
] |
Centers the matrix in feature space according to Smola et Schoelkopf,
Learning with Kernels p. 431 Alters the input matrix. If you still need the
original matrix, use
<code>centeredMatrix = centerKernelMatrix(uncenteredMatrix.copy()) {</code>
@param matrix the matrix to be centered
@return centered matrix (for convenience)
|
[
"Centers",
"the",
"matrix",
"in",
"feature",
"space",
"according",
"to",
"Smola",
"et",
"Schoelkopf",
"Learning",
"with",
"Kernels",
"p",
".",
"431",
"Alters",
"the",
"input",
"matrix",
".",
"If",
"you",
"still",
"need",
"the",
"original",
"matrix",
"use",
"<code",
">",
"centeredMatrix",
"=",
"centerKernelMatrix",
"(",
"uncenteredMatrix",
".",
"copy",
"()",
")",
"{",
"<",
"/",
"code",
">"
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java#L243-L250
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java
|
ApiOvhIpLoadbalancing.serviceName_tcp_route_POST
|
public OvhRouteTcp serviceName_tcp_route_POST(String serviceName, OvhRouteTcpAction action, String displayName, Long frontendId, Long weight) throws IOException {
"""
Add a new TCP route to your frontend
REST: POST /ipLoadbalancing/{serviceName}/tcp/route
@param weight [required] Route priority ([0..255]). 0 if null. Highest priority routes are evaluated last. Only the first matching route will trigger an action
@param frontendId [required] Route traffic for this frontend
@param action [required] Action triggered when all rules match
@param displayName [required] Human readable name for your route, this field is for you
@param serviceName [required] The internal name of your IP load balancing
"""
String qPath = "/ipLoadbalancing/{serviceName}/tcp/route";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "action", action);
addBody(o, "displayName", displayName);
addBody(o, "frontendId", frontendId);
addBody(o, "weight", weight);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhRouteTcp.class);
}
|
java
|
public OvhRouteTcp serviceName_tcp_route_POST(String serviceName, OvhRouteTcpAction action, String displayName, Long frontendId, Long weight) throws IOException {
String qPath = "/ipLoadbalancing/{serviceName}/tcp/route";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "action", action);
addBody(o, "displayName", displayName);
addBody(o, "frontendId", frontendId);
addBody(o, "weight", weight);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhRouteTcp.class);
}
|
[
"public",
"OvhRouteTcp",
"serviceName_tcp_route_POST",
"(",
"String",
"serviceName",
",",
"OvhRouteTcpAction",
"action",
",",
"String",
"displayName",
",",
"Long",
"frontendId",
",",
"Long",
"weight",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ipLoadbalancing/{serviceName}/tcp/route\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"action\"",
",",
"action",
")",
";",
"addBody",
"(",
"o",
",",
"\"displayName\"",
",",
"displayName",
")",
";",
"addBody",
"(",
"o",
",",
"\"frontendId\"",
",",
"frontendId",
")",
";",
"addBody",
"(",
"o",
",",
"\"weight\"",
",",
"weight",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhRouteTcp",
".",
"class",
")",
";",
"}"
] |
Add a new TCP route to your frontend
REST: POST /ipLoadbalancing/{serviceName}/tcp/route
@param weight [required] Route priority ([0..255]). 0 if null. Highest priority routes are evaluated last. Only the first matching route will trigger an action
@param frontendId [required] Route traffic for this frontend
@param action [required] Action triggered when all rules match
@param displayName [required] Human readable name for your route, this field is for you
@param serviceName [required] The internal name of your IP load balancing
|
[
"Add",
"a",
"new",
"TCP",
"route",
"to",
"your",
"frontend"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java#L1287-L1297
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/NetworkInterfacesInner.java
|
NetworkInterfacesInner.beginUpdateTags
|
public NetworkInterfaceInner beginUpdateTags(String resourceGroupName, String networkInterfaceName) {
"""
Updates a network interface tags.
@param resourceGroupName The name of the resource group.
@param networkInterfaceName The name of the network interface.
@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 NetworkInterfaceInner object if successful.
"""
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, networkInterfaceName).toBlocking().single().body();
}
|
java
|
public NetworkInterfaceInner beginUpdateTags(String resourceGroupName, String networkInterfaceName) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, networkInterfaceName).toBlocking().single().body();
}
|
[
"public",
"NetworkInterfaceInner",
"beginUpdateTags",
"(",
"String",
"resourceGroupName",
",",
"String",
"networkInterfaceName",
")",
"{",
"return",
"beginUpdateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"networkInterfaceName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Updates a network interface tags.
@param resourceGroupName The name of the resource group.
@param networkInterfaceName The name of the network interface.
@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 NetworkInterfaceInner object if successful.
|
[
"Updates",
"a",
"network",
"interface",
"tags",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/NetworkInterfacesInner.java#L803-L805
|
killbilling/recurly-java-library
|
src/main/java/com/ning/billing/recurly/RecurlyClient.java
|
RecurlyClient.getAccountSubscriptions
|
@Deprecated
public Subscriptions getAccountSubscriptions(final String accountCode, final String status) {
"""
Get the subscriptions for an account.
This is deprecated. Please use getAccountSubscriptions(String, Subscriptions.State, QueryParams)
<p>
Returns information about a single account.
@param accountCode recurly account id
@param status Only accounts in this status will be returned
@return Subscriptions on the account
"""
final QueryParams params = new QueryParams();
if (status != null) params.put("state", status);
return doGET(Account.ACCOUNT_RESOURCE
+ "/" + accountCode
+ Subscriptions.SUBSCRIPTIONS_RESOURCE,
Subscriptions.class, params);
}
|
java
|
@Deprecated
public Subscriptions getAccountSubscriptions(final String accountCode, final String status) {
final QueryParams params = new QueryParams();
if (status != null) params.put("state", status);
return doGET(Account.ACCOUNT_RESOURCE
+ "/" + accountCode
+ Subscriptions.SUBSCRIPTIONS_RESOURCE,
Subscriptions.class, params);
}
|
[
"@",
"Deprecated",
"public",
"Subscriptions",
"getAccountSubscriptions",
"(",
"final",
"String",
"accountCode",
",",
"final",
"String",
"status",
")",
"{",
"final",
"QueryParams",
"params",
"=",
"new",
"QueryParams",
"(",
")",
";",
"if",
"(",
"status",
"!=",
"null",
")",
"params",
".",
"put",
"(",
"\"state\"",
",",
"status",
")",
";",
"return",
"doGET",
"(",
"Account",
".",
"ACCOUNT_RESOURCE",
"+",
"\"/\"",
"+",
"accountCode",
"+",
"Subscriptions",
".",
"SUBSCRIPTIONS_RESOURCE",
",",
"Subscriptions",
".",
"class",
",",
"params",
")",
";",
"}"
] |
Get the subscriptions for an account.
This is deprecated. Please use getAccountSubscriptions(String, Subscriptions.State, QueryParams)
<p>
Returns information about a single account.
@param accountCode recurly account id
@param status Only accounts in this status will be returned
@return Subscriptions on the account
|
[
"Get",
"the",
"subscriptions",
"for",
"an",
"account",
".",
"This",
"is",
"deprecated",
".",
"Please",
"use",
"getAccountSubscriptions",
"(",
"String",
"Subscriptions",
".",
"State",
"QueryParams",
")",
"<p",
">",
"Returns",
"information",
"about",
"a",
"single",
"account",
"."
] |
train
|
https://github.com/killbilling/recurly-java-library/blob/5e05eedd91885a51e1aa8293bd41139d082cf7f4/src/main/java/com/ning/billing/recurly/RecurlyClient.java#L749-L758
|
lessthanoptimal/ejml
|
examples/src/org/ejml/example/StatisticsMatrix.java
|
StatisticsMatrix.createMatrix
|
@Override
protected StatisticsMatrix createMatrix(int numRows, int numCols, MatrixType type) {
"""
Returns a matrix of StatisticsMatrix type so that SimpleMatrix functions create matrices
of the correct type.
"""
return new StatisticsMatrix(numRows,numCols);
}
|
java
|
@Override
protected StatisticsMatrix createMatrix(int numRows, int numCols, MatrixType type) {
return new StatisticsMatrix(numRows,numCols);
}
|
[
"@",
"Override",
"protected",
"StatisticsMatrix",
"createMatrix",
"(",
"int",
"numRows",
",",
"int",
"numCols",
",",
"MatrixType",
"type",
")",
"{",
"return",
"new",
"StatisticsMatrix",
"(",
"numRows",
",",
"numCols",
")",
";",
"}"
] |
Returns a matrix of StatisticsMatrix type so that SimpleMatrix functions create matrices
of the correct type.
|
[
"Returns",
"a",
"matrix",
"of",
"StatisticsMatrix",
"type",
"so",
"that",
"SimpleMatrix",
"functions",
"create",
"matrices",
"of",
"the",
"correct",
"type",
"."
] |
train
|
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/examples/src/org/ejml/example/StatisticsMatrix.java#L103-L106
|
dwdyer/uncommons-maths
|
core/src/java/main/org/uncommons/maths/binary/BinaryUtils.java
|
BinaryUtils.convertBytesToLong
|
public static long convertBytesToLong(byte[] bytes, int offset) {
"""
Utility method to convert an array of bytes into a long. Byte ordered is
assumed to be big-endian.
@param bytes The data to read from.
@param offset The position to start reading the 8-byte long from.
@return The 64-bit integer represented by the eight bytes.
@since 1.1
"""
long value = 0;
for (int i = offset; i < offset + 8; i++)
{
byte b = bytes[i];
value <<= 8;
value |= b;
}
return value;
}
|
java
|
public static long convertBytesToLong(byte[] bytes, int offset)
{
long value = 0;
for (int i = offset; i < offset + 8; i++)
{
byte b = bytes[i];
value <<= 8;
value |= b;
}
return value;
}
|
[
"public",
"static",
"long",
"convertBytesToLong",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
")",
"{",
"long",
"value",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"offset",
";",
"i",
"<",
"offset",
"+",
"8",
";",
"i",
"++",
")",
"{",
"byte",
"b",
"=",
"bytes",
"[",
"i",
"]",
";",
"value",
"<<=",
"8",
";",
"value",
"|=",
"b",
";",
"}",
"return",
"value",
";",
"}"
] |
Utility method to convert an array of bytes into a long. Byte ordered is
assumed to be big-endian.
@param bytes The data to read from.
@param offset The position to start reading the 8-byte long from.
@return The 64-bit integer represented by the eight bytes.
@since 1.1
|
[
"Utility",
"method",
"to",
"convert",
"an",
"array",
"of",
"bytes",
"into",
"a",
"long",
".",
"Byte",
"ordered",
"is",
"assumed",
"to",
"be",
"big",
"-",
"endian",
"."
] |
train
|
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/binary/BinaryUtils.java#L124-L135
|
wcm-io-caravan/caravan-commons
|
httpclient/src/main/java/io/wcm/caravan/commons/httpclient/impl/helpers/BeanUtil.java
|
BeanUtil.getMaskedBeanProperties
|
public static SortedMap<String, Object> getMaskedBeanProperties(Object beanObject, String[] maskProperties) {
"""
Get map with key/value pairs for properties of a java bean (using {@link BeanUtils#describe(Object)}).
An array of property names can be passed that should be masked with "***" because they contain sensitive
information.
@param beanObject Bean object
@param maskProperties List of property names
@return Map with masked key/value pairs
"""
try {
SortedMap<String, Object> configProperties = new TreeMap<String, Object>(BeanUtils.describe(beanObject));
// always ignore "class" properties which is added by BeanUtils.describe by default
configProperties.remove("class");
// Mask some properties with confidential information (if set to any value)
if (maskProperties != null) {
for (String propertyName : maskProperties) {
if (configProperties.containsKey(propertyName) && configProperties.get(propertyName) != null) {
configProperties.put(propertyName, "***");
}
}
}
return configProperties;
}
catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
throw new IllegalArgumentException("Unable to get properties from: " + beanObject, ex);
}
}
|
java
|
public static SortedMap<String, Object> getMaskedBeanProperties(Object beanObject, String[] maskProperties) {
try {
SortedMap<String, Object> configProperties = new TreeMap<String, Object>(BeanUtils.describe(beanObject));
// always ignore "class" properties which is added by BeanUtils.describe by default
configProperties.remove("class");
// Mask some properties with confidential information (if set to any value)
if (maskProperties != null) {
for (String propertyName : maskProperties) {
if (configProperties.containsKey(propertyName) && configProperties.get(propertyName) != null) {
configProperties.put(propertyName, "***");
}
}
}
return configProperties;
}
catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
throw new IllegalArgumentException("Unable to get properties from: " + beanObject, ex);
}
}
|
[
"public",
"static",
"SortedMap",
"<",
"String",
",",
"Object",
">",
"getMaskedBeanProperties",
"(",
"Object",
"beanObject",
",",
"String",
"[",
"]",
"maskProperties",
")",
"{",
"try",
"{",
"SortedMap",
"<",
"String",
",",
"Object",
">",
"configProperties",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"Object",
">",
"(",
"BeanUtils",
".",
"describe",
"(",
"beanObject",
")",
")",
";",
"// always ignore \"class\" properties which is added by BeanUtils.describe by default",
"configProperties",
".",
"remove",
"(",
"\"class\"",
")",
";",
"// Mask some properties with confidential information (if set to any value)",
"if",
"(",
"maskProperties",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"propertyName",
":",
"maskProperties",
")",
"{",
"if",
"(",
"configProperties",
".",
"containsKey",
"(",
"propertyName",
")",
"&&",
"configProperties",
".",
"get",
"(",
"propertyName",
")",
"!=",
"null",
")",
"{",
"configProperties",
".",
"put",
"(",
"propertyName",
",",
"\"***\"",
")",
";",
"}",
"}",
"}",
"return",
"configProperties",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"|",
"InvocationTargetException",
"|",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unable to get properties from: \"",
"+",
"beanObject",
",",
"ex",
")",
";",
"}",
"}"
] |
Get map with key/value pairs for properties of a java bean (using {@link BeanUtils#describe(Object)}).
An array of property names can be passed that should be masked with "***" because they contain sensitive
information.
@param beanObject Bean object
@param maskProperties List of property names
@return Map with masked key/value pairs
|
[
"Get",
"map",
"with",
"key",
"/",
"value",
"pairs",
"for",
"properties",
"of",
"a",
"java",
"bean",
"(",
"using",
"{"
] |
train
|
https://github.com/wcm-io-caravan/caravan-commons/blob/12e605bdfeb5a1ce7404e30d9f32274552cb8ce8/httpclient/src/main/java/io/wcm/caravan/commons/httpclient/impl/helpers/BeanUtil.java#L45-L66
|
EsupPortail/esup-smsu-api
|
src/main/java/org/esupportail/smsuapi/business/stats/StatisticBuilder.java
|
StatisticBuilder.buildAllStatistics
|
public void buildAllStatistics() {
"""
Build all non already computed statistic whatever the application, account or date.
"""
for (Map<String,?> map : daoService.getAppsAndCountsToTreat()) {
// get the date of older SMS for this app and account
final Application application = (Application) map.get(Sms.PROP_APP);
final Account account = (Account) map.get(Sms.PROP_ACC);
final Date olderSmsDate = daoService.getDateOfOlderSmsByApplicationAndAccount(application, account);
// if there is not at least 1 sms in db for the specified app / account, the
// previous method returns null, so we have to check it.
if (olderSmsDate != null) {
// get the list of month where stats was not computed since the date of the older SMS in DB
for (Date monthToComputeStats : getListOfMarkerDateForNonComputedStats(application, account, olderSmsDate)) {
// compute the stats for this specific app, account and month
buildStatisticForAMonth(application, account, monthToComputeStats);
}
}
}
}
|
java
|
public void buildAllStatistics() {
for (Map<String,?> map : daoService.getAppsAndCountsToTreat()) {
// get the date of older SMS for this app and account
final Application application = (Application) map.get(Sms.PROP_APP);
final Account account = (Account) map.get(Sms.PROP_ACC);
final Date olderSmsDate = daoService.getDateOfOlderSmsByApplicationAndAccount(application, account);
// if there is not at least 1 sms in db for the specified app / account, the
// previous method returns null, so we have to check it.
if (olderSmsDate != null) {
// get the list of month where stats was not computed since the date of the older SMS in DB
for (Date monthToComputeStats : getListOfMarkerDateForNonComputedStats(application, account, olderSmsDate)) {
// compute the stats for this specific app, account and month
buildStatisticForAMonth(application, account, monthToComputeStats);
}
}
}
}
|
[
"public",
"void",
"buildAllStatistics",
"(",
")",
"{",
"for",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"map",
":",
"daoService",
".",
"getAppsAndCountsToTreat",
"(",
")",
")",
"{",
"// get the date of older SMS for this app and account\r",
"final",
"Application",
"application",
"=",
"(",
"Application",
")",
"map",
".",
"get",
"(",
"Sms",
".",
"PROP_APP",
")",
";",
"final",
"Account",
"account",
"=",
"(",
"Account",
")",
"map",
".",
"get",
"(",
"Sms",
".",
"PROP_ACC",
")",
";",
"final",
"Date",
"olderSmsDate",
"=",
"daoService",
".",
"getDateOfOlderSmsByApplicationAndAccount",
"(",
"application",
",",
"account",
")",
";",
"// if there is not at least 1 sms in db for the specified app / account, the \r",
"// previous method returns null, so we have to check it.\r",
"if",
"(",
"olderSmsDate",
"!=",
"null",
")",
"{",
"// get the list of month where stats was not computed since the date of the older SMS in DB\r",
"for",
"(",
"Date",
"monthToComputeStats",
":",
"getListOfMarkerDateForNonComputedStats",
"(",
"application",
",",
"account",
",",
"olderSmsDate",
")",
")",
"{",
"// compute the stats for this specific app, account and month\r",
"buildStatisticForAMonth",
"(",
"application",
",",
"account",
",",
"monthToComputeStats",
")",
";",
"}",
"}",
"}",
"}"
] |
Build all non already computed statistic whatever the application, account or date.
|
[
"Build",
"all",
"non",
"already",
"computed",
"statistic",
"whatever",
"the",
"application",
"account",
"or",
"date",
"."
] |
train
|
https://github.com/EsupPortail/esup-smsu-api/blob/7b6a4388065adfd84655dbc83f37080874953b20/src/main/java/org/esupportail/smsuapi/business/stats/StatisticBuilder.java#L40-L57
|
elki-project/elki
|
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/DatabaseEventManager.java
|
DatabaseEventManager.fireResultAdded
|
public void fireResultAdded(Result r, Result parent) {
"""
Informs all registered <code>ResultListener</code> that a new result was
added.
@param r New child result added
@param parent Parent result that was added to
"""
for(int i = resultListenerList.size(); --i >= 0;) {
resultListenerList.get(i).resultAdded(r, parent);
}
}
|
java
|
public void fireResultAdded(Result r, Result parent) {
for(int i = resultListenerList.size(); --i >= 0;) {
resultListenerList.get(i).resultAdded(r, parent);
}
}
|
[
"public",
"void",
"fireResultAdded",
"(",
"Result",
"r",
",",
"Result",
"parent",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"resultListenerList",
".",
"size",
"(",
")",
";",
"--",
"i",
">=",
"0",
";",
")",
"{",
"resultListenerList",
".",
"get",
"(",
"i",
")",
".",
"resultAdded",
"(",
"r",
",",
"parent",
")",
";",
"}",
"}"
] |
Informs all registered <code>ResultListener</code> that a new result was
added.
@param r New child result added
@param parent Parent result that was added to
|
[
"Informs",
"all",
"registered",
"<code",
">",
"ResultListener<",
"/",
"code",
">",
"that",
"a",
"new",
"result",
"was",
"added",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/DatabaseEventManager.java#L312-L316
|
jtmelton/appsensor
|
appsensor-core/src/main/java/org/owasp/appsensor/core/util/XmlUtils.java
|
XmlUtils.validateXMLSchema
|
public static void validateXMLSchema(InputStream xsdStream, InputStream xmlStream) throws IOException, SAXException {
"""
Validate XML matches XSD. Stream-based method.
@param xsdStream resource based path to XSD file
@param xmlStream resource based path to XML file
@throws IOException io exception for loading files
@throws SAXException sax exception for parsing files
"""
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema(new StreamSource(xsdStream));
Validator validator = schema.newValidator();
validator.validate(new StreamSource(xmlStream));
}
|
java
|
public static void validateXMLSchema(InputStream xsdStream, InputStream xmlStream) throws IOException, SAXException {
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema(new StreamSource(xsdStream));
Validator validator = schema.newValidator();
validator.validate(new StreamSource(xmlStream));
}
|
[
"public",
"static",
"void",
"validateXMLSchema",
"(",
"InputStream",
"xsdStream",
",",
"InputStream",
"xmlStream",
")",
"throws",
"IOException",
",",
"SAXException",
"{",
"SchemaFactory",
"factory",
"=",
"SchemaFactory",
".",
"newInstance",
"(",
"XMLConstants",
".",
"W3C_XML_SCHEMA_NS_URI",
")",
";",
"Schema",
"schema",
"=",
"factory",
".",
"newSchema",
"(",
"new",
"StreamSource",
"(",
"xsdStream",
")",
")",
";",
"Validator",
"validator",
"=",
"schema",
".",
"newValidator",
"(",
")",
";",
"validator",
".",
"validate",
"(",
"new",
"StreamSource",
"(",
"xmlStream",
")",
")",
";",
"}"
] |
Validate XML matches XSD. Stream-based method.
@param xsdStream resource based path to XSD file
@param xmlStream resource based path to XML file
@throws IOException io exception for loading files
@throws SAXException sax exception for parsing files
|
[
"Validate",
"XML",
"matches",
"XSD",
".",
"Stream",
"-",
"based",
"method",
"."
] |
train
|
https://github.com/jtmelton/appsensor/blob/c3b4e9ada50fdee974e0d618ec4bdfabc2163798/appsensor-core/src/main/java/org/owasp/appsensor/core/util/XmlUtils.java#L83-L88
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java
|
ApiOvhEmaildomain.delegatedAccount_email_GET
|
public OvhAccountDelegated delegatedAccount_email_GET(String email) throws IOException {
"""
Get this object properties
REST: GET /email/domain/delegatedAccount/{email}
@param email [required] Email
"""
String qPath = "/email/domain/delegatedAccount/{email}";
StringBuilder sb = path(qPath, email);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAccountDelegated.class);
}
|
java
|
public OvhAccountDelegated delegatedAccount_email_GET(String email) throws IOException {
String qPath = "/email/domain/delegatedAccount/{email}";
StringBuilder sb = path(qPath, email);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAccountDelegated.class);
}
|
[
"public",
"OvhAccountDelegated",
"delegatedAccount_email_GET",
"(",
"String",
"email",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/domain/delegatedAccount/{email}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"email",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhAccountDelegated",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /email/domain/delegatedAccount/{email}
@param email [required] Email
|
[
"Get",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java#L271-L276
|
facebookarchive/hadoop-20
|
src/contrib/corona/src/java/org/apache/hadoop/corona/TypePoolInfoMap.java
|
TypePoolInfoMap.containsKey
|
public boolean containsKey(ResourceType type, PoolInfo poolInfo) {
"""
Is the value set with the appropriate keys?
@param type Resource type
@param poolInfo Pool info
@return True if this map contains a mapping for the specified key, false
otherwise
"""
Map<PoolInfo, V> poolInfoMap = typePoolInfoMap.get(type);
if (poolInfoMap == null) {
return false;
}
return poolInfoMap.containsKey(poolInfo);
}
|
java
|
public boolean containsKey(ResourceType type, PoolInfo poolInfo) {
Map<PoolInfo, V> poolInfoMap = typePoolInfoMap.get(type);
if (poolInfoMap == null) {
return false;
}
return poolInfoMap.containsKey(poolInfo);
}
|
[
"public",
"boolean",
"containsKey",
"(",
"ResourceType",
"type",
",",
"PoolInfo",
"poolInfo",
")",
"{",
"Map",
"<",
"PoolInfo",
",",
"V",
">",
"poolInfoMap",
"=",
"typePoolInfoMap",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"poolInfoMap",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"poolInfoMap",
".",
"containsKey",
"(",
"poolInfo",
")",
";",
"}"
] |
Is the value set with the appropriate keys?
@param type Resource type
@param poolInfo Pool info
@return True if this map contains a mapping for the specified key, false
otherwise
|
[
"Is",
"the",
"value",
"set",
"with",
"the",
"appropriate",
"keys?"
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/corona/src/java/org/apache/hadoop/corona/TypePoolInfoMap.java#L77-L83
|
micwin/ticino
|
events/src/main/java/net/micwin/ticino/events/EventScope.java
|
EventScope.dispatchAsynchronous
|
public synchronized <Q extends T> void dispatchAsynchronous(final Q event, final IPostProcessor<Q> pPostProcessor) {
"""
Dispatch an event to receivers asynchronously. Does start a thread and
then return immediately.
@param event
The event object to dispatch.
@param pPostProcessor
The postprocessor to call when the event doispatchment
returns.
"""
new Thread(new Runnable() {
@Override
public void run() {
try {
// delegate dispatch result
pPostProcessor.done(dispatch(event));
} catch (DispatchException lEx) {
// delegate exception handling as well
pPostProcessor.done(lEx);
}
}
}).start();
}
|
java
|
public synchronized <Q extends T> void dispatchAsynchronous(final Q event, final IPostProcessor<Q> pPostProcessor) {
new Thread(new Runnable() {
@Override
public void run() {
try {
// delegate dispatch result
pPostProcessor.done(dispatch(event));
} catch (DispatchException lEx) {
// delegate exception handling as well
pPostProcessor.done(lEx);
}
}
}).start();
}
|
[
"public",
"synchronized",
"<",
"Q",
"extends",
"T",
">",
"void",
"dispatchAsynchronous",
"(",
"final",
"Q",
"event",
",",
"final",
"IPostProcessor",
"<",
"Q",
">",
"pPostProcessor",
")",
"{",
"new",
"Thread",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"// delegate dispatch result",
"pPostProcessor",
".",
"done",
"(",
"dispatch",
"(",
"event",
")",
")",
";",
"}",
"catch",
"(",
"DispatchException",
"lEx",
")",
"{",
"// delegate exception handling as well",
"pPostProcessor",
".",
"done",
"(",
"lEx",
")",
";",
"}",
"}",
"}",
")",
".",
"start",
"(",
")",
";",
"}"
] |
Dispatch an event to receivers asynchronously. Does start a thread and
then return immediately.
@param event
The event object to dispatch.
@param pPostProcessor
The postprocessor to call when the event doispatchment
returns.
|
[
"Dispatch",
"an",
"event",
"to",
"receivers",
"asynchronously",
".",
"Does",
"start",
"a",
"thread",
"and",
"then",
"return",
"immediately",
"."
] |
train
|
https://github.com/micwin/ticino/blob/4d143093500cd2fb9767ebe8cd05ddda23e35613/events/src/main/java/net/micwin/ticino/events/EventScope.java#L391-L412
|
google/error-prone-javac
|
src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/SerializedForm.java
|
SerializedForm.addMethodIfExist
|
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
"""
/*
Catalog Serializable method if it exists in current ClassSymbol.
Do not look for method in superclasses.
Serialization requires these methods to be non-static.
@param method should be an unqualified Serializable method
name either READOBJECT, WRITEOBJECT, READRESOLVE
or WRITEREPLACE.
@param visibility the visibility flag for the given method.
"""
Names names = def.name.table.names;
for (Symbol sym : def.members().getSymbolsByName(names.fromString(methodName))) {
if (sym.kind == MTH) {
MethodSymbol md = (MethodSymbol)sym;
if ((md.flags() & Flags.STATIC) == 0) {
/*
* WARNING: not robust if unqualifiedMethodName is overloaded
* method. Signature checking could make more robust.
* READOBJECT takes a single parameter, java.io.ObjectInputStream.
* WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
*/
methods.append(env.getMethodDoc(md));
}
}
}
}
|
java
|
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
Names names = def.name.table.names;
for (Symbol sym : def.members().getSymbolsByName(names.fromString(methodName))) {
if (sym.kind == MTH) {
MethodSymbol md = (MethodSymbol)sym;
if ((md.flags() & Flags.STATIC) == 0) {
/*
* WARNING: not robust if unqualifiedMethodName is overloaded
* method. Signature checking could make more robust.
* READOBJECT takes a single parameter, java.io.ObjectInputStream.
* WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
*/
methods.append(env.getMethodDoc(md));
}
}
}
}
|
[
"private",
"void",
"addMethodIfExist",
"(",
"DocEnv",
"env",
",",
"ClassSymbol",
"def",
",",
"String",
"methodName",
")",
"{",
"Names",
"names",
"=",
"def",
".",
"name",
".",
"table",
".",
"names",
";",
"for",
"(",
"Symbol",
"sym",
":",
"def",
".",
"members",
"(",
")",
".",
"getSymbolsByName",
"(",
"names",
".",
"fromString",
"(",
"methodName",
")",
")",
")",
"{",
"if",
"(",
"sym",
".",
"kind",
"==",
"MTH",
")",
"{",
"MethodSymbol",
"md",
"=",
"(",
"MethodSymbol",
")",
"sym",
";",
"if",
"(",
"(",
"md",
".",
"flags",
"(",
")",
"&",
"Flags",
".",
"STATIC",
")",
"==",
"0",
")",
"{",
"/*\n * WARNING: not robust if unqualifiedMethodName is overloaded\n * method. Signature checking could make more robust.\n * READOBJECT takes a single parameter, java.io.ObjectInputStream.\n * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.\n */",
"methods",
".",
"append",
"(",
"env",
".",
"getMethodDoc",
"(",
"md",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
/*
Catalog Serializable method if it exists in current ClassSymbol.
Do not look for method in superclasses.
Serialization requires these methods to be non-static.
@param method should be an unqualified Serializable method
name either READOBJECT, WRITEOBJECT, READRESOLVE
or WRITEREPLACE.
@param visibility the visibility flag for the given method.
|
[
"/",
"*",
"Catalog",
"Serializable",
"method",
"if",
"it",
"exists",
"in",
"current",
"ClassSymbol",
".",
"Do",
"not",
"look",
"for",
"method",
"in",
"superclasses",
"."
] |
train
|
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/SerializedForm.java#L209-L226
|
citiususc/hipster
|
hipster-core/src/main/java/es/usc/citius/hipster/model/impl/ADStarNodeImpl.java
|
ADStarNodeImpl.compareTo
|
@Override
public int compareTo(ADStarNodeImpl<A, S, C> o) {
"""
Compares ADSTarNode instances attending to their {@link es.usc.citius.hipster.model.ADStarNode.Key}
values.
@param o ADStarNode instance
@return usual comparison value
"""
return this.key.compareTo(o.key);
}
|
java
|
@Override
public int compareTo(ADStarNodeImpl<A, S, C> o) {
return this.key.compareTo(o.key);
}
|
[
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"ADStarNodeImpl",
"<",
"A",
",",
"S",
",",
"C",
">",
"o",
")",
"{",
"return",
"this",
".",
"key",
".",
"compareTo",
"(",
"o",
".",
"key",
")",
";",
"}"
] |
Compares ADSTarNode instances attending to their {@link es.usc.citius.hipster.model.ADStarNode.Key}
values.
@param o ADStarNode instance
@return usual comparison value
|
[
"Compares",
"ADSTarNode",
"instances",
"attending",
"to",
"their",
"{",
"@link",
"es",
".",
"usc",
".",
"citius",
".",
"hipster",
".",
"model",
".",
"ADStarNode",
".",
"Key",
"}",
"values",
"."
] |
train
|
https://github.com/citiususc/hipster/blob/9ab1236abb833a27641ae73ba9ca890d5c17598e/hipster-core/src/main/java/es/usc/citius/hipster/model/impl/ADStarNodeImpl.java#L151-L154
|
Azure/azure-sdk-for-java
|
appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java
|
AppServiceEnvironmentsInner.beginSuspendWithServiceResponseAsync
|
public Observable<ServiceResponse<Page<SiteInner>>> beginSuspendWithServiceResponseAsync(final String resourceGroupName, final String name) {
"""
Suspend an App Service Environment.
Suspend an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<SiteInner> object
"""
return beginSuspendSinglePageAsync(resourceGroupName, name)
.concatMap(new Func1<ServiceResponse<Page<SiteInner>>, Observable<ServiceResponse<Page<SiteInner>>>>() {
@Override
public Observable<ServiceResponse<Page<SiteInner>>> call(ServiceResponse<Page<SiteInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(beginSuspendNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
java
|
public Observable<ServiceResponse<Page<SiteInner>>> beginSuspendWithServiceResponseAsync(final String resourceGroupName, final String name) {
return beginSuspendSinglePageAsync(resourceGroupName, name)
.concatMap(new Func1<ServiceResponse<Page<SiteInner>>, Observable<ServiceResponse<Page<SiteInner>>>>() {
@Override
public Observable<ServiceResponse<Page<SiteInner>>> call(ServiceResponse<Page<SiteInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(beginSuspendNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
[
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
">",
"beginSuspendWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
")",
"{",
"return",
"beginSuspendSinglePageAsync",
"(",
"resourceGroupName",
",",
"name",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"SiteInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"beginSuspendNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Suspend an App Service Environment.
Suspend an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<SiteInner> object
|
[
"Suspend",
"an",
"App",
"Service",
"Environment",
".",
"Suspend",
"an",
"App",
"Service",
"Environment",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L4639-L4651
|
killbill/killbill
|
invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsInterval.java
|
ItemsInterval.createNewItem
|
private Item createNewItem(@Nullable final LocalDate startDate, @Nullable final LocalDate endDate, @Nullable final UUID targetInvoiceId, final boolean mergeMode) {
"""
Create a new item based on the existing items and new service period
<p/>
<ul>
<li>During the build phase, we only consider ADD items. This happens when for instance an existing item was partially repaired
and there is a need to create a new item which represents the part left -- that was not repaired.
<li>During the merge phase, we create new items that are the missing repaired items (CANCEL).
</ul>
@param startDate start date of the new item to create
@param endDate end date of the new item to create
@param mergeMode mode to consider.
@return new item for this service period or null
"""
// Find the ADD (build phase) or CANCEL (merge phase) item of this interval
final Item item = getResultingItem(mergeMode);
if (item == null || startDate == null || endDate == null || targetInvoiceId == null) {
return item;
}
// Prorate (build phase) or repair (merge phase) this item, as needed
final InvoiceItem proratedInvoiceItem = item.toProratedInvoiceItem(startDate, endDate);
if (proratedInvoiceItem == null) {
return null;
} else {
// Keep track of the repaired amount for this item
item.incrementCurrentRepairedAmount(proratedInvoiceItem.getAmount().abs());
return new Item(proratedInvoiceItem, targetInvoiceId, item.getAction());
}
}
|
java
|
private Item createNewItem(@Nullable final LocalDate startDate, @Nullable final LocalDate endDate, @Nullable final UUID targetInvoiceId, final boolean mergeMode) {
// Find the ADD (build phase) or CANCEL (merge phase) item of this interval
final Item item = getResultingItem(mergeMode);
if (item == null || startDate == null || endDate == null || targetInvoiceId == null) {
return item;
}
// Prorate (build phase) or repair (merge phase) this item, as needed
final InvoiceItem proratedInvoiceItem = item.toProratedInvoiceItem(startDate, endDate);
if (proratedInvoiceItem == null) {
return null;
} else {
// Keep track of the repaired amount for this item
item.incrementCurrentRepairedAmount(proratedInvoiceItem.getAmount().abs());
return new Item(proratedInvoiceItem, targetInvoiceId, item.getAction());
}
}
|
[
"private",
"Item",
"createNewItem",
"(",
"@",
"Nullable",
"final",
"LocalDate",
"startDate",
",",
"@",
"Nullable",
"final",
"LocalDate",
"endDate",
",",
"@",
"Nullable",
"final",
"UUID",
"targetInvoiceId",
",",
"final",
"boolean",
"mergeMode",
")",
"{",
"// Find the ADD (build phase) or CANCEL (merge phase) item of this interval",
"final",
"Item",
"item",
"=",
"getResultingItem",
"(",
"mergeMode",
")",
";",
"if",
"(",
"item",
"==",
"null",
"||",
"startDate",
"==",
"null",
"||",
"endDate",
"==",
"null",
"||",
"targetInvoiceId",
"==",
"null",
")",
"{",
"return",
"item",
";",
"}",
"// Prorate (build phase) or repair (merge phase) this item, as needed",
"final",
"InvoiceItem",
"proratedInvoiceItem",
"=",
"item",
".",
"toProratedInvoiceItem",
"(",
"startDate",
",",
"endDate",
")",
";",
"if",
"(",
"proratedInvoiceItem",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"// Keep track of the repaired amount for this item",
"item",
".",
"incrementCurrentRepairedAmount",
"(",
"proratedInvoiceItem",
".",
"getAmount",
"(",
")",
".",
"abs",
"(",
")",
")",
";",
"return",
"new",
"Item",
"(",
"proratedInvoiceItem",
",",
"targetInvoiceId",
",",
"item",
".",
"getAction",
"(",
")",
")",
";",
"}",
"}"
] |
Create a new item based on the existing items and new service period
<p/>
<ul>
<li>During the build phase, we only consider ADD items. This happens when for instance an existing item was partially repaired
and there is a need to create a new item which represents the part left -- that was not repaired.
<li>During the merge phase, we create new items that are the missing repaired items (CANCEL).
</ul>
@param startDate start date of the new item to create
@param endDate end date of the new item to create
@param mergeMode mode to consider.
@return new item for this service period or null
|
[
"Create",
"a",
"new",
"item",
"based",
"on",
"the",
"existing",
"items",
"and",
"new",
"service",
"period",
"<p",
"/",
">",
"<ul",
">",
"<li",
">",
"During",
"the",
"build",
"phase",
"we",
"only",
"consider",
"ADD",
"items",
".",
"This",
"happens",
"when",
"for",
"instance",
"an",
"existing",
"item",
"was",
"partially",
"repaired",
"and",
"there",
"is",
"a",
"need",
"to",
"create",
"a",
"new",
"item",
"which",
"represents",
"the",
"part",
"left",
"--",
"that",
"was",
"not",
"repaired",
".",
"<li",
">",
"During",
"the",
"merge",
"phase",
"we",
"create",
"new",
"items",
"that",
"are",
"the",
"missing",
"repaired",
"items",
"(",
"CANCEL",
")",
".",
"<",
"/",
"ul",
">"
] |
train
|
https://github.com/killbill/killbill/blob/6457b485fb32a182c76197a83f428123331f1380/invoice/src/main/java/org/killbill/billing/invoice/tree/ItemsInterval.java#L178-L194
|
jeremiehuchet/acrachilisync
|
acrachilisync-core/src/main/java/fr/dudie/acrachilisync/utils/IssueDescriptionReader.java
|
IssueDescriptionReader.parseStacktrace
|
private String parseStacktrace(final String pDescription, final String pStacktraceMD5)
throws IssueParseException {
"""
Extracts the bug stacktrace from the description.
@param pDescription
the issue description
@param pStacktraceMD5
the stacktrace MD5 hash the issue is related to
@return the stacktrace
@throws IssueParseException
malformed issue description
"""
String stacktrace = null;
// escape braces { and } to use strings in regexp
final String start = "<pre class=\"javastacktrace\">";
final String qStart = Pattern.quote(start);
final String end = "</pre>";
final String qEnd = Pattern.quote(end);
final Pattern p = Pattern.compile(qStart + "(.*)" + qEnd, Pattern.DOTALL
| Pattern.CASE_INSENSITIVE);
final Matcher m = p.matcher(pDescription);
if (m.find()) {
stacktrace = m.group(1);
// if a start tag or an end tag is found in the stacktrace, then there is a problem
if (StringUtils.contains(stacktrace, start) || StringUtils.contains(stacktrace, end)) {
throw new IssueParseException("Invalid stacktrace block");
}
} else {
throw new IssueParseException("0 stacktrace block found in the description");
}
return stacktrace;
}
|
java
|
private String parseStacktrace(final String pDescription, final String pStacktraceMD5)
throws IssueParseException {
String stacktrace = null;
// escape braces { and } to use strings in regexp
final String start = "<pre class=\"javastacktrace\">";
final String qStart = Pattern.quote(start);
final String end = "</pre>";
final String qEnd = Pattern.quote(end);
final Pattern p = Pattern.compile(qStart + "(.*)" + qEnd, Pattern.DOTALL
| Pattern.CASE_INSENSITIVE);
final Matcher m = p.matcher(pDescription);
if (m.find()) {
stacktrace = m.group(1);
// if a start tag or an end tag is found in the stacktrace, then there is a problem
if (StringUtils.contains(stacktrace, start) || StringUtils.contains(stacktrace, end)) {
throw new IssueParseException("Invalid stacktrace block");
}
} else {
throw new IssueParseException("0 stacktrace block found in the description");
}
return stacktrace;
}
|
[
"private",
"String",
"parseStacktrace",
"(",
"final",
"String",
"pDescription",
",",
"final",
"String",
"pStacktraceMD5",
")",
"throws",
"IssueParseException",
"{",
"String",
"stacktrace",
"=",
"null",
";",
"// escape braces { and } to use strings in regexp\r",
"final",
"String",
"start",
"=",
"\"<pre class=\\\"javastacktrace\\\">\"",
";",
"final",
"String",
"qStart",
"=",
"Pattern",
".",
"quote",
"(",
"start",
")",
";",
"final",
"String",
"end",
"=",
"\"</pre>\"",
";",
"final",
"String",
"qEnd",
"=",
"Pattern",
".",
"quote",
"(",
"end",
")",
";",
"final",
"Pattern",
"p",
"=",
"Pattern",
".",
"compile",
"(",
"qStart",
"+",
"\"(.*)\"",
"+",
"qEnd",
",",
"Pattern",
".",
"DOTALL",
"|",
"Pattern",
".",
"CASE_INSENSITIVE",
")",
";",
"final",
"Matcher",
"m",
"=",
"p",
".",
"matcher",
"(",
"pDescription",
")",
";",
"if",
"(",
"m",
".",
"find",
"(",
")",
")",
"{",
"stacktrace",
"=",
"m",
".",
"group",
"(",
"1",
")",
";",
"// if a start tag or an end tag is found in the stacktrace, then there is a problem\r",
"if",
"(",
"StringUtils",
".",
"contains",
"(",
"stacktrace",
",",
"start",
")",
"||",
"StringUtils",
".",
"contains",
"(",
"stacktrace",
",",
"end",
")",
")",
"{",
"throw",
"new",
"IssueParseException",
"(",
"\"Invalid stacktrace block\"",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"IssueParseException",
"(",
"\"0 stacktrace block found in the description\"",
")",
";",
"}",
"return",
"stacktrace",
";",
"}"
] |
Extracts the bug stacktrace from the description.
@param pDescription
the issue description
@param pStacktraceMD5
the stacktrace MD5 hash the issue is related to
@return the stacktrace
@throws IssueParseException
malformed issue description
|
[
"Extracts",
"the",
"bug",
"stacktrace",
"from",
"the",
"description",
"."
] |
train
|
https://github.com/jeremiehuchet/acrachilisync/blob/4eadb0218623e77e0d92b5a08515eea2db51e988/acrachilisync-core/src/main/java/fr/dudie/acrachilisync/utils/IssueDescriptionReader.java#L252-L278
|
Azure/azure-sdk-for-java
|
automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/RunbookDraftsInner.java
|
RunbookDraftsInner.getAsync
|
public Observable<RunbookDraftInner> getAsync(String resourceGroupName, String automationAccountName, String runbookName) {
"""
Retrieve the runbook draft identified by runbook name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param runbookName The runbook name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the RunbookDraftInner object
"""
return getWithServiceResponseAsync(resourceGroupName, automationAccountName, runbookName).map(new Func1<ServiceResponse<RunbookDraftInner>, RunbookDraftInner>() {
@Override
public RunbookDraftInner call(ServiceResponse<RunbookDraftInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<RunbookDraftInner> getAsync(String resourceGroupName, String automationAccountName, String runbookName) {
return getWithServiceResponseAsync(resourceGroupName, automationAccountName, runbookName).map(new Func1<ServiceResponse<RunbookDraftInner>, RunbookDraftInner>() {
@Override
public RunbookDraftInner call(ServiceResponse<RunbookDraftInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"RunbookDraftInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"runbookName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"runbookName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"RunbookDraftInner",
">",
",",
"RunbookDraftInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"RunbookDraftInner",
"call",
"(",
"ServiceResponse",
"<",
"RunbookDraftInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Retrieve the runbook draft identified by runbook name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param runbookName The runbook name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the RunbookDraftInner object
|
[
"Retrieve",
"the",
"runbook",
"draft",
"identified",
"by",
"runbook",
"name",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/RunbookDraftsInner.java#L400-L407
|
sarxos/webcam-capture
|
webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDriverUtils.java
|
WebcamDriverUtils.getClasses
|
protected static Class<?>[] getClasses(String pkgname, boolean flat) {
"""
Scans all classes accessible from the context class loader which belong
to the given package and subpackages.
@param packageName The base package
@param flat scan only one package level, do not dive into subdirectories
@return The classes
@throws ClassNotFoundException
@throws IOException
"""
List<File> dirs = new ArrayList<File>();
List<Class<?>> classes = new ArrayList<Class<?>>();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
String path = pkgname.replace('.', '/');
Enumeration<URL> resources = null;
try {
resources = classLoader.getResources(path);
} catch (IOException e) {
throw new RuntimeException("Cannot read path " + path, e);
}
while (resources.hasMoreElements()) {
URL resource = resources.nextElement();
dirs.add(new File(resource.getFile()));
}
for (File directory : dirs) {
try {
classes.addAll(findClasses(directory, pkgname, flat));
} catch (ClassNotFoundException e) {
throw new RuntimeException("Class not found", e);
}
}
return classes.toArray(new Class<?>[classes.size()]);
}
|
java
|
protected static Class<?>[] getClasses(String pkgname, boolean flat) {
List<File> dirs = new ArrayList<File>();
List<Class<?>> classes = new ArrayList<Class<?>>();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
String path = pkgname.replace('.', '/');
Enumeration<URL> resources = null;
try {
resources = classLoader.getResources(path);
} catch (IOException e) {
throw new RuntimeException("Cannot read path " + path, e);
}
while (resources.hasMoreElements()) {
URL resource = resources.nextElement();
dirs.add(new File(resource.getFile()));
}
for (File directory : dirs) {
try {
classes.addAll(findClasses(directory, pkgname, flat));
} catch (ClassNotFoundException e) {
throw new RuntimeException("Class not found", e);
}
}
return classes.toArray(new Class<?>[classes.size()]);
}
|
[
"protected",
"static",
"Class",
"<",
"?",
">",
"[",
"]",
"getClasses",
"(",
"String",
"pkgname",
",",
"boolean",
"flat",
")",
"{",
"List",
"<",
"File",
">",
"dirs",
"=",
"new",
"ArrayList",
"<",
"File",
">",
"(",
")",
";",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"classes",
"=",
"new",
"ArrayList",
"<",
"Class",
"<",
"?",
">",
">",
"(",
")",
";",
"ClassLoader",
"classLoader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"String",
"path",
"=",
"pkgname",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"Enumeration",
"<",
"URL",
">",
"resources",
"=",
"null",
";",
"try",
"{",
"resources",
"=",
"classLoader",
".",
"getResources",
"(",
"path",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Cannot read path \"",
"+",
"path",
",",
"e",
")",
";",
"}",
"while",
"(",
"resources",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"URL",
"resource",
"=",
"resources",
".",
"nextElement",
"(",
")",
";",
"dirs",
".",
"add",
"(",
"new",
"File",
"(",
"resource",
".",
"getFile",
"(",
")",
")",
")",
";",
"}",
"for",
"(",
"File",
"directory",
":",
"dirs",
")",
"{",
"try",
"{",
"classes",
".",
"addAll",
"(",
"findClasses",
"(",
"directory",
",",
"pkgname",
",",
"flat",
")",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Class not found\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"classes",
".",
"toArray",
"(",
"new",
"Class",
"<",
"?",
">",
"[",
"classes",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Scans all classes accessible from the context class loader which belong
to the given package and subpackages.
@param packageName The base package
@param flat scan only one package level, do not dive into subdirectories
@return The classes
@throws ClassNotFoundException
@throws IOException
|
[
"Scans",
"all",
"classes",
"accessible",
"from",
"the",
"context",
"class",
"loader",
"which",
"belong",
"to",
"the",
"given",
"package",
"and",
"subpackages",
"."
] |
train
|
https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamDriverUtils.java#L81-L110
|
xcesco/kripton
|
kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLBuilder.java
|
JQLBuilder.forEachFields
|
private static String forEachFields(final Set<String> fields, OnFieldListener listener) {
"""
For each fields.
@param fields
the fields
@param listener
the listener
@return the string
"""
StringBuilder builder = new StringBuilder();
{
String comma = "";
for (String item : fields) {
builder.append(comma + listener.onField(item));
comma = ", ";
}
}
return builder.toString();
}
|
java
|
private static String forEachFields(final Set<String> fields, OnFieldListener listener) {
StringBuilder builder = new StringBuilder();
{
String comma = "";
for (String item : fields) {
builder.append(comma + listener.onField(item));
comma = ", ";
}
}
return builder.toString();
}
|
[
"private",
"static",
"String",
"forEachFields",
"(",
"final",
"Set",
"<",
"String",
">",
"fields",
",",
"OnFieldListener",
"listener",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"{",
"String",
"comma",
"=",
"\"\"",
";",
"for",
"(",
"String",
"item",
":",
"fields",
")",
"{",
"builder",
".",
"append",
"(",
"comma",
"+",
"listener",
".",
"onField",
"(",
"item",
")",
")",
";",
"comma",
"=",
"\", \"",
";",
"}",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
For each fields.
@param fields
the fields
@param listener
the listener
@return the string
|
[
"For",
"each",
"fields",
"."
] |
train
|
https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLBuilder.java#L1071-L1082
|
beanshell/beanshell
|
src/main/java/bsh/classpath/ClassManagerImpl.java
|
ClassManagerImpl.defineClass
|
@Override
public Class defineClass( String name, byte [] code ) {
"""
/*
Impl Notes:
We add the bytecode source and the "reload" the class, which causes the
BshClassLoader to be initialized and create a DiscreteFilesClassLoader
for the bytecode.
@exception ClassPathException can be thrown by reloadClasses
"""
baseClassPath.setClassSource( name, new GeneratedClassSource( code ) );
try {
reloadClasses( new String [] { name } );
} catch ( ClassPathException e ) {
throw new bsh.InterpreterError("defineClass: "+e, e);
}
return classForName( name );
}
|
java
|
@Override
public Class defineClass( String name, byte [] code )
{
baseClassPath.setClassSource( name, new GeneratedClassSource( code ) );
try {
reloadClasses( new String [] { name } );
} catch ( ClassPathException e ) {
throw new bsh.InterpreterError("defineClass: "+e, e);
}
return classForName( name );
}
|
[
"@",
"Override",
"public",
"Class",
"defineClass",
"(",
"String",
"name",
",",
"byte",
"[",
"]",
"code",
")",
"{",
"baseClassPath",
".",
"setClassSource",
"(",
"name",
",",
"new",
"GeneratedClassSource",
"(",
"code",
")",
")",
";",
"try",
"{",
"reloadClasses",
"(",
"new",
"String",
"[",
"]",
"{",
"name",
"}",
")",
";",
"}",
"catch",
"(",
"ClassPathException",
"e",
")",
"{",
"throw",
"new",
"bsh",
".",
"InterpreterError",
"(",
"\"defineClass: \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"return",
"classForName",
"(",
"name",
")",
";",
"}"
] |
/*
Impl Notes:
We add the bytecode source and the "reload" the class, which causes the
BshClassLoader to be initialized and create a DiscreteFilesClassLoader
for the bytecode.
@exception ClassPathException can be thrown by reloadClasses
|
[
"/",
"*",
"Impl",
"Notes",
":",
"We",
"add",
"the",
"bytecode",
"source",
"and",
"the",
"reload",
"the",
"class",
"which",
"causes",
"the",
"BshClassLoader",
"to",
"be",
"initialized",
"and",
"create",
"a",
"DiscreteFilesClassLoader",
"for",
"the",
"bytecode",
"."
] |
train
|
https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/classpath/ClassManagerImpl.java#L554-L564
|
stevespringett/Alpine
|
alpine/src/main/java/alpine/util/HttpUtil.java
|
HttpUtil.getSessionAttribute
|
@SuppressWarnings("unchecked")
public static <T> T getSessionAttribute(final HttpSession session, final String key) {
"""
Returns a session attribute as the type of object stored.
@param session session where the attribute is stored
@param key the attributes key
@param <T> the type of object expected
@return the requested object
@since 1.0.0
"""
if (session != null) {
return (T) session.getAttribute(key);
}
return null;
}
|
java
|
@SuppressWarnings("unchecked")
public static <T> T getSessionAttribute(final HttpSession session, final String key) {
if (session != null) {
return (T) session.getAttribute(key);
}
return null;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"getSessionAttribute",
"(",
"final",
"HttpSession",
"session",
",",
"final",
"String",
"key",
")",
"{",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"return",
"(",
"T",
")",
"session",
".",
"getAttribute",
"(",
"key",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns a session attribute as the type of object stored.
@param session session where the attribute is stored
@param key the attributes key
@param <T> the type of object expected
@return the requested object
@since 1.0.0
|
[
"Returns",
"a",
"session",
"attribute",
"as",
"the",
"type",
"of",
"object",
"stored",
"."
] |
train
|
https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/util/HttpUtil.java#L41-L47
|
sdaschner/jaxrs-analyzer
|
src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/methods/MethodIdentifier.java
|
MethodIdentifier.ofNonStatic
|
public static MethodIdentifier ofNonStatic(final String containingClass, final String methodName, final String returnType, final String... parameterTypes) {
"""
Creates an identifier of a non-static method.
@param containingClass The class name
@param methodName The method name
@param returnType The return type
@param parameterTypes The parameter types
@return The method identifier
"""
return of(containingClass, methodName, returnType, false, parameterTypes);
}
|
java
|
public static MethodIdentifier ofNonStatic(final String containingClass, final String methodName, final String returnType, final String... parameterTypes) {
return of(containingClass, methodName, returnType, false, parameterTypes);
}
|
[
"public",
"static",
"MethodIdentifier",
"ofNonStatic",
"(",
"final",
"String",
"containingClass",
",",
"final",
"String",
"methodName",
",",
"final",
"String",
"returnType",
",",
"final",
"String",
"...",
"parameterTypes",
")",
"{",
"return",
"of",
"(",
"containingClass",
",",
"methodName",
",",
"returnType",
",",
"false",
",",
"parameterTypes",
")",
";",
"}"
] |
Creates an identifier of a non-static method.
@param containingClass The class name
@param methodName The method name
@param returnType The return type
@param parameterTypes The parameter types
@return The method identifier
|
[
"Creates",
"an",
"identifier",
"of",
"a",
"non",
"-",
"static",
"method",
"."
] |
train
|
https://github.com/sdaschner/jaxrs-analyzer/blob/4ac62942202d05632977d6c14d3cd7e2d27e2b9b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/model/methods/MethodIdentifier.java#L160-L162
|
artikcloud/artikcloud-java
|
src/main/java/cloud/artik/api/DevicesStatusApi.java
|
DevicesStatusApi.putDeviceStatus
|
public DeviceStatus putDeviceStatus(String deviceId, DeviceStatusPut body) throws ApiException {
"""
Update Device Status
Update Device Status
@param deviceId Device ID. (required)
@param body Body (optional)
@return DeviceStatus
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<DeviceStatus> resp = putDeviceStatusWithHttpInfo(deviceId, body);
return resp.getData();
}
|
java
|
public DeviceStatus putDeviceStatus(String deviceId, DeviceStatusPut body) throws ApiException {
ApiResponse<DeviceStatus> resp = putDeviceStatusWithHttpInfo(deviceId, body);
return resp.getData();
}
|
[
"public",
"DeviceStatus",
"putDeviceStatus",
"(",
"String",
"deviceId",
",",
"DeviceStatusPut",
"body",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"DeviceStatus",
">",
"resp",
"=",
"putDeviceStatusWithHttpInfo",
"(",
"deviceId",
",",
"body",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] |
Update Device Status
Update Device Status
@param deviceId Device ID. (required)
@param body Body (optional)
@return DeviceStatus
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
[
"Update",
"Device",
"Status",
"Update",
"Device",
"Status"
] |
train
|
https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/DevicesStatusApi.java#L386-L389
|
lettuce-io/lettuce-core
|
src/main/java/io/lettuce/core/internal/LettuceClassUtils.java
|
LettuceClassUtils.findClass
|
public static Class<?> findClass(String className) {
"""
Loads a class using the {@link #getDefaultClassLoader()}.
@param className
@return
"""
try {
return forName(className, getDefaultClassLoader());
} catch (ClassNotFoundException e) {
return null;
}
}
|
java
|
public static Class<?> findClass(String className) {
try {
return forName(className, getDefaultClassLoader());
} catch (ClassNotFoundException e) {
return null;
}
}
|
[
"public",
"static",
"Class",
"<",
"?",
">",
"findClass",
"(",
"String",
"className",
")",
"{",
"try",
"{",
"return",
"forName",
"(",
"className",
",",
"getDefaultClassLoader",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Loads a class using the {@link #getDefaultClassLoader()}.
@param className
@return
|
[
"Loads",
"a",
"class",
"using",
"the",
"{",
"@link",
"#getDefaultClassLoader",
"()",
"}",
"."
] |
train
|
https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/internal/LettuceClassUtils.java#L80-L86
|
hawkular/hawkular-apm
|
api/src/main/java/org/hawkular/apm/api/services/Criteria.java
|
Criteria.addProperty
|
public Criteria addProperty(String name, String value, Operator operator) {
"""
This method adds a new property criteria.
@param name The property name
@param value The property value
@param operator The property operator
@return The criteria
"""
properties.add(new PropertyCriteria(name, value, operator));
return this;
}
|
java
|
public Criteria addProperty(String name, String value, Operator operator) {
properties.add(new PropertyCriteria(name, value, operator));
return this;
}
|
[
"public",
"Criteria",
"addProperty",
"(",
"String",
"name",
",",
"String",
"value",
",",
"Operator",
"operator",
")",
"{",
"properties",
".",
"add",
"(",
"new",
"PropertyCriteria",
"(",
"name",
",",
"value",
",",
"operator",
")",
")",
";",
"return",
"this",
";",
"}"
] |
This method adds a new property criteria.
@param name The property name
@param value The property value
@param operator The property operator
@return The criteria
|
[
"This",
"method",
"adds",
"a",
"new",
"property",
"criteria",
"."
] |
train
|
https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/api/src/main/java/org/hawkular/apm/api/services/Criteria.java#L196-L199
|
gallandarakhneorg/afc
|
advanced/nodefx/src/main/java/org/arakhne/afc/nodefx/ZoomableGraphicsContext.java
|
ZoomableGraphicsContext.fillRoundRect
|
public void fillRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight) {
"""
Fills a rounded rectangle using the current fill paint.
<p>This method will be affected by any of the
global common or fill attributes as specified in the
Rendering Attributes Table of {@link GraphicsContext}.
@param x the X coordinate of the upper left bound of the oval.
@param y the Y coordinate of the upper left bound of the oval.
@param width the width at the center of the oval.
@param height the height at the center of the oval.
@param arcWidth the arc width of the rectangle corners.
@param arcHeight the arc height of the rectangle corners.
"""
this.gc.fillRoundRect(
doc2fxX(x), doc2fxY(y),
doc2fxSize(width), doc2fxSize(height),
doc2fxSize(arcWidth), doc2fxSize(arcHeight));
}
|
java
|
public void fillRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight) {
this.gc.fillRoundRect(
doc2fxX(x), doc2fxY(y),
doc2fxSize(width), doc2fxSize(height),
doc2fxSize(arcWidth), doc2fxSize(arcHeight));
}
|
[
"public",
"void",
"fillRoundRect",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"width",
",",
"double",
"height",
",",
"double",
"arcWidth",
",",
"double",
"arcHeight",
")",
"{",
"this",
".",
"gc",
".",
"fillRoundRect",
"(",
"doc2fxX",
"(",
"x",
")",
",",
"doc2fxY",
"(",
"y",
")",
",",
"doc2fxSize",
"(",
"width",
")",
",",
"doc2fxSize",
"(",
"height",
")",
",",
"doc2fxSize",
"(",
"arcWidth",
")",
",",
"doc2fxSize",
"(",
"arcHeight",
")",
")",
";",
"}"
] |
Fills a rounded rectangle using the current fill paint.
<p>This method will be affected by any of the
global common or fill attributes as specified in the
Rendering Attributes Table of {@link GraphicsContext}.
@param x the X coordinate of the upper left bound of the oval.
@param y the Y coordinate of the upper left bound of the oval.
@param width the width at the center of the oval.
@param height the height at the center of the oval.
@param arcWidth the arc width of the rectangle corners.
@param arcHeight the arc height of the rectangle corners.
|
[
"Fills",
"a",
"rounded",
"rectangle",
"using",
"the",
"current",
"fill",
"paint",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/nodefx/src/main/java/org/arakhne/afc/nodefx/ZoomableGraphicsContext.java#L1600-L1605
|
lecousin/java-framework-core
|
net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/synch/JoinPoint.java
|
JoinPoint.timeout
|
public synchronized void timeout(long millis, Runnable callback) {
"""
Should be used only for debugging purpose, as a JoinPoint is supposed to always become unblocked.<br/>
This method will wait for the given milliseconds, if at this time the JoinPoint is already unblocked,
nothing is done, else we force it to become unblocked, and the given callback is called if any.
"""
if (isUnblocked()) return;
Task<Void,NoException> task = new Task.Cpu<Void,NoException>("JoinPoint timeout", Task.PRIORITY_RATHER_LOW) {
@Override
public Void run() {
synchronized (JoinPoint.this) {
if (isUnblocked()) return null;
if (callback != null)
try { callback.run(); }
catch (Throwable t) {
LCCore.getApplication().getDefaultLogger().error("Error in callback of JoinPoint timeout", t);
}
unblock();
return null;
}
}
};
task.executeIn(millis);
if (isUnblocked()) return;
task.start();
}
|
java
|
public synchronized void timeout(long millis, Runnable callback) {
if (isUnblocked()) return;
Task<Void,NoException> task = new Task.Cpu<Void,NoException>("JoinPoint timeout", Task.PRIORITY_RATHER_LOW) {
@Override
public Void run() {
synchronized (JoinPoint.this) {
if (isUnblocked()) return null;
if (callback != null)
try { callback.run(); }
catch (Throwable t) {
LCCore.getApplication().getDefaultLogger().error("Error in callback of JoinPoint timeout", t);
}
unblock();
return null;
}
}
};
task.executeIn(millis);
if (isUnblocked()) return;
task.start();
}
|
[
"public",
"synchronized",
"void",
"timeout",
"(",
"long",
"millis",
",",
"Runnable",
"callback",
")",
"{",
"if",
"(",
"isUnblocked",
"(",
")",
")",
"return",
";",
"Task",
"<",
"Void",
",",
"NoException",
">",
"task",
"=",
"new",
"Task",
".",
"Cpu",
"<",
"Void",
",",
"NoException",
">",
"(",
"\"JoinPoint timeout\"",
",",
"Task",
".",
"PRIORITY_RATHER_LOW",
")",
"{",
"@",
"Override",
"public",
"Void",
"run",
"(",
")",
"{",
"synchronized",
"(",
"JoinPoint",
".",
"this",
")",
"{",
"if",
"(",
"isUnblocked",
"(",
")",
")",
"return",
"null",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"try",
"{",
"callback",
".",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"LCCore",
".",
"getApplication",
"(",
")",
".",
"getDefaultLogger",
"(",
")",
".",
"error",
"(",
"\"Error in callback of JoinPoint timeout\"",
",",
"t",
")",
";",
"}",
"unblock",
"(",
")",
";",
"return",
"null",
";",
"}",
"}",
"}",
";",
"task",
".",
"executeIn",
"(",
"millis",
")",
";",
"if",
"(",
"isUnblocked",
"(",
")",
")",
"return",
";",
"task",
".",
"start",
"(",
")",
";",
"}"
] |
Should be used only for debugging purpose, as a JoinPoint is supposed to always become unblocked.<br/>
This method will wait for the given milliseconds, if at this time the JoinPoint is already unblocked,
nothing is done, else we force it to become unblocked, and the given callback is called if any.
|
[
"Should",
"be",
"used",
"only",
"for",
"debugging",
"purpose",
"as",
"a",
"JoinPoint",
"is",
"supposed",
"to",
"always",
"become",
"unblocked",
".",
"<br",
"/",
">",
"This",
"method",
"will",
"wait",
"for",
"the",
"given",
"milliseconds",
"if",
"at",
"this",
"time",
"the",
"JoinPoint",
"is",
"already",
"unblocked",
"nothing",
"is",
"done",
"else",
"we",
"force",
"it",
"to",
"become",
"unblocked",
"and",
"the",
"given",
"callback",
"is",
"called",
"if",
"any",
"."
] |
train
|
https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/synch/JoinPoint.java#L143-L163
|
frostwire/frostwire-jlibtorrent
|
src/main/java/com/frostwire/jlibtorrent/SessionHandle.java
|
SessionHandle.removeTorrent
|
public void removeTorrent(TorrentHandle th, remove_flags_t options) {
"""
This method will close all peer connections associated with the torrent and tell the
tracker that we've stopped participating in the swarm. This operation cannot fail.
When it completes, you will receive a torrent_removed_alert.
<p>
The optional second argument options can be used to delete all the files downloaded
by this torrent. To do so, pass in the value session::delete_files. The removal of
the torrent is asynchronous, there is no guarantee that adding the same torrent immediately
after it was removed will not throw a libtorrent_exception exception. Once the torrent
is deleted, a torrent_deleted_alert is posted.
@param th the handle
"""
if (th.isValid()) {
s.remove_torrent(th.swig(), options);
}
}
|
java
|
public void removeTorrent(TorrentHandle th, remove_flags_t options) {
if (th.isValid()) {
s.remove_torrent(th.swig(), options);
}
}
|
[
"public",
"void",
"removeTorrent",
"(",
"TorrentHandle",
"th",
",",
"remove_flags_t",
"options",
")",
"{",
"if",
"(",
"th",
".",
"isValid",
"(",
")",
")",
"{",
"s",
".",
"remove_torrent",
"(",
"th",
".",
"swig",
"(",
")",
",",
"options",
")",
";",
"}",
"}"
] |
This method will close all peer connections associated with the torrent and tell the
tracker that we've stopped participating in the swarm. This operation cannot fail.
When it completes, you will receive a torrent_removed_alert.
<p>
The optional second argument options can be used to delete all the files downloaded
by this torrent. To do so, pass in the value session::delete_files. The removal of
the torrent is asynchronous, there is no guarantee that adding the same torrent immediately
after it was removed will not throw a libtorrent_exception exception. Once the torrent
is deleted, a torrent_deleted_alert is posted.
@param th the handle
|
[
"This",
"method",
"will",
"close",
"all",
"peer",
"connections",
"associated",
"with",
"the",
"torrent",
"and",
"tell",
"the",
"tracker",
"that",
"we",
"ve",
"stopped",
"participating",
"in",
"the",
"swarm",
".",
"This",
"operation",
"cannot",
"fail",
".",
"When",
"it",
"completes",
"you",
"will",
"receive",
"a",
"torrent_removed_alert",
".",
"<p",
">",
"The",
"optional",
"second",
"argument",
"options",
"can",
"be",
"used",
"to",
"delete",
"all",
"the",
"files",
"downloaded",
"by",
"this",
"torrent",
".",
"To",
"do",
"so",
"pass",
"in",
"the",
"value",
"session",
"::",
"delete_files",
".",
"The",
"removal",
"of",
"the",
"torrent",
"is",
"asynchronous",
"there",
"is",
"no",
"guarantee",
"that",
"adding",
"the",
"same",
"torrent",
"immediately",
"after",
"it",
"was",
"removed",
"will",
"not",
"throw",
"a",
"libtorrent_exception",
"exception",
".",
"Once",
"the",
"torrent",
"is",
"deleted",
"a",
"torrent_deleted_alert",
"is",
"posted",
"."
] |
train
|
https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/SessionHandle.java#L282-L286
|
haraldk/TwelveMonkeys
|
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java
|
QuickDrawContext.paintRoundRect
|
public void paintRoundRect(final Rectangle2D pRectangle, int pArcW, int pArcH) {
"""
PaintRooundRect(r,int,int) // fills a rectangle's interior with the pattern of the
graphics pen, using the pattern mode of the graphics pen.
@param pRectangle the rectangle to paint
@param pArcW width of the oval defining the rounded corner.
@param pArcH height of the oval defining the rounded corner.
"""
paintShape(toRoundRect(pRectangle, pArcW, pArcH));
}
|
java
|
public void paintRoundRect(final Rectangle2D pRectangle, int pArcW, int pArcH) {
paintShape(toRoundRect(pRectangle, pArcW, pArcH));
}
|
[
"public",
"void",
"paintRoundRect",
"(",
"final",
"Rectangle2D",
"pRectangle",
",",
"int",
"pArcW",
",",
"int",
"pArcH",
")",
"{",
"paintShape",
"(",
"toRoundRect",
"(",
"pRectangle",
",",
"pArcW",
",",
"pArcH",
")",
")",
";",
"}"
] |
PaintRooundRect(r,int,int) // fills a rectangle's interior with the pattern of the
graphics pen, using the pattern mode of the graphics pen.
@param pRectangle the rectangle to paint
@param pArcW width of the oval defining the rounded corner.
@param pArcH height of the oval defining the rounded corner.
|
[
"PaintRooundRect",
"(",
"r",
"int",
"int",
")",
"//",
"fills",
"a",
"rectangle",
"s",
"interior",
"with",
"the",
"pattern",
"of",
"the",
"graphics",
"pen",
"using",
"the",
"pattern",
"mode",
"of",
"the",
"graphics",
"pen",
"."
] |
train
|
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java#L606-L608
|
alexvasilkov/GestureViews
|
library/src/main/java/com/alexvasilkov/gestures/animation/ViewPosition.java
|
ViewPosition.unpack
|
@SuppressWarnings("unused") // Public API
public static ViewPosition unpack(String str) {
"""
Restores ViewPosition from the string created by {@link #pack()} method.
@param str Serialized position string
@return De-serialized position
"""
String[] parts = TextUtils.split(str, SPLIT_PATTERN);
if (parts.length != 4) {
throw new IllegalArgumentException("Wrong ViewPosition string: " + str);
}
Rect view = Rect.unflattenFromString(parts[0]);
Rect viewport = Rect.unflattenFromString(parts[1]);
Rect visible = Rect.unflattenFromString(parts[2]);
Rect image = Rect.unflattenFromString(parts[3]);
if (view == null || viewport == null || image == null) {
throw new IllegalArgumentException("Wrong ViewPosition string: " + str);
}
return new ViewPosition(view, viewport, visible, image);
}
|
java
|
@SuppressWarnings("unused") // Public API
public static ViewPosition unpack(String str) {
String[] parts = TextUtils.split(str, SPLIT_PATTERN);
if (parts.length != 4) {
throw new IllegalArgumentException("Wrong ViewPosition string: " + str);
}
Rect view = Rect.unflattenFromString(parts[0]);
Rect viewport = Rect.unflattenFromString(parts[1]);
Rect visible = Rect.unflattenFromString(parts[2]);
Rect image = Rect.unflattenFromString(parts[3]);
if (view == null || viewport == null || image == null) {
throw new IllegalArgumentException("Wrong ViewPosition string: " + str);
}
return new ViewPosition(view, viewport, visible, image);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"// Public API",
"public",
"static",
"ViewPosition",
"unpack",
"(",
"String",
"str",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"TextUtils",
".",
"split",
"(",
"str",
",",
"SPLIT_PATTERN",
")",
";",
"if",
"(",
"parts",
".",
"length",
"!=",
"4",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Wrong ViewPosition string: \"",
"+",
"str",
")",
";",
"}",
"Rect",
"view",
"=",
"Rect",
".",
"unflattenFromString",
"(",
"parts",
"[",
"0",
"]",
")",
";",
"Rect",
"viewport",
"=",
"Rect",
".",
"unflattenFromString",
"(",
"parts",
"[",
"1",
"]",
")",
";",
"Rect",
"visible",
"=",
"Rect",
".",
"unflattenFromString",
"(",
"parts",
"[",
"2",
"]",
")",
";",
"Rect",
"image",
"=",
"Rect",
".",
"unflattenFromString",
"(",
"parts",
"[",
"3",
"]",
")",
";",
"if",
"(",
"view",
"==",
"null",
"||",
"viewport",
"==",
"null",
"||",
"image",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Wrong ViewPosition string: \"",
"+",
"str",
")",
";",
"}",
"return",
"new",
"ViewPosition",
"(",
"view",
",",
"viewport",
",",
"visible",
",",
"image",
")",
";",
"}"
] |
Restores ViewPosition from the string created by {@link #pack()} method.
@param str Serialized position string
@return De-serialized position
|
[
"Restores",
"ViewPosition",
"from",
"the",
"string",
"created",
"by",
"{",
"@link",
"#pack",
"()",
"}",
"method",
"."
] |
train
|
https://github.com/alexvasilkov/GestureViews/blob/f0a4c266e31dcad23bd0d9013531bc1c501b9c9f/library/src/main/java/com/alexvasilkov/gestures/animation/ViewPosition.java#L197-L214
|
google/error-prone-javac
|
src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
|
PackageSummaryBuilder.buildSummary
|
public void buildSummary(XMLNode node, Content packageContentTree) {
"""
Build the package summary.
@param node the XML element that specifies which components to document
@param packageContentTree the package content tree to which the summaries will
be added
"""
Content summaryContentTree = packageWriter.getSummaryHeader();
buildChildren(node, summaryContentTree);
packageContentTree.addContent(summaryContentTree);
}
|
java
|
public void buildSummary(XMLNode node, Content packageContentTree) {
Content summaryContentTree = packageWriter.getSummaryHeader();
buildChildren(node, summaryContentTree);
packageContentTree.addContent(summaryContentTree);
}
|
[
"public",
"void",
"buildSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"packageContentTree",
")",
"{",
"Content",
"summaryContentTree",
"=",
"packageWriter",
".",
"getSummaryHeader",
"(",
")",
";",
"buildChildren",
"(",
"node",
",",
"summaryContentTree",
")",
";",
"packageContentTree",
".",
"addContent",
"(",
"summaryContentTree",
")",
";",
"}"
] |
Build the package summary.
@param node the XML element that specifies which components to document
@param packageContentTree the package content tree to which the summaries will
be added
|
[
"Build",
"the",
"package",
"summary",
"."
] |
train
|
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java#L151-L155
|
BlueBrain/bluima
|
modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/maxent/TwoPassDataIndexer.java
|
TwoPassDataIndexer.computeEventCounts
|
private int computeEventCounts(EventStream eventStream, Writer eventStore, TObjectIntHashMap predicatesInOut, int cutoff) throws IOException {
"""
Reads events from <tt>eventStream</tt> into a linked list. The
predicates associated with each event are counted and any which
occur at least <tt>cutoff</tt> times are added to the
<tt>predicatesInOut</tt> map along with a unique integer index.
@param eventStream an <code>EventStream</code> value
@param eventStore a writer to which the events are written to for later processing.
@param predicatesInOut a <code>TObjectIntHashMap</code> value
@param cutoff an <code>int</code> value
"""
TObjectIntHashMap counter = new TObjectIntHashMap();
int predicateIndex = 0;
int eventCount = 0;
while (eventStream.hasNext()) {
Event ev = eventStream.nextEvent();
eventCount++;
eventStore.write(FileEventStream.toLine(ev));
String[] ec = ev.getContext();
for (int j = 0; j < ec.length; j++) {
if (!predicatesInOut.containsKey(ec[j])) {
if (counter.increment(ec[j])) {}
else {
counter.put(ec[j], 1);
}
if (counter.get(ec[j]) >= cutoff) {
predicatesInOut.put(ec[j], predicateIndex++);
counter.remove(ec[j]);
}
}
}
}
predicatesInOut.trimToSize();
eventStore.close();
return eventCount;
}
|
java
|
private int computeEventCounts(EventStream eventStream, Writer eventStore, TObjectIntHashMap predicatesInOut, int cutoff) throws IOException {
TObjectIntHashMap counter = new TObjectIntHashMap();
int predicateIndex = 0;
int eventCount = 0;
while (eventStream.hasNext()) {
Event ev = eventStream.nextEvent();
eventCount++;
eventStore.write(FileEventStream.toLine(ev));
String[] ec = ev.getContext();
for (int j = 0; j < ec.length; j++) {
if (!predicatesInOut.containsKey(ec[j])) {
if (counter.increment(ec[j])) {}
else {
counter.put(ec[j], 1);
}
if (counter.get(ec[j]) >= cutoff) {
predicatesInOut.put(ec[j], predicateIndex++);
counter.remove(ec[j]);
}
}
}
}
predicatesInOut.trimToSize();
eventStore.close();
return eventCount;
}
|
[
"private",
"int",
"computeEventCounts",
"(",
"EventStream",
"eventStream",
",",
"Writer",
"eventStore",
",",
"TObjectIntHashMap",
"predicatesInOut",
",",
"int",
"cutoff",
")",
"throws",
"IOException",
"{",
"TObjectIntHashMap",
"counter",
"=",
"new",
"TObjectIntHashMap",
"(",
")",
";",
"int",
"predicateIndex",
"=",
"0",
";",
"int",
"eventCount",
"=",
"0",
";",
"while",
"(",
"eventStream",
".",
"hasNext",
"(",
")",
")",
"{",
"Event",
"ev",
"=",
"eventStream",
".",
"nextEvent",
"(",
")",
";",
"eventCount",
"++",
";",
"eventStore",
".",
"write",
"(",
"FileEventStream",
".",
"toLine",
"(",
"ev",
")",
")",
";",
"String",
"[",
"]",
"ec",
"=",
"ev",
".",
"getContext",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"ec",
".",
"length",
";",
"j",
"++",
")",
"{",
"if",
"(",
"!",
"predicatesInOut",
".",
"containsKey",
"(",
"ec",
"[",
"j",
"]",
")",
")",
"{",
"if",
"(",
"counter",
".",
"increment",
"(",
"ec",
"[",
"j",
"]",
")",
")",
"{",
"}",
"else",
"{",
"counter",
".",
"put",
"(",
"ec",
"[",
"j",
"]",
",",
"1",
")",
";",
"}",
"if",
"(",
"counter",
".",
"get",
"(",
"ec",
"[",
"j",
"]",
")",
">=",
"cutoff",
")",
"{",
"predicatesInOut",
".",
"put",
"(",
"ec",
"[",
"j",
"]",
",",
"predicateIndex",
"++",
")",
";",
"counter",
".",
"remove",
"(",
"ec",
"[",
"j",
"]",
")",
";",
"}",
"}",
"}",
"}",
"predicatesInOut",
".",
"trimToSize",
"(",
")",
";",
"eventStore",
".",
"close",
"(",
")",
";",
"return",
"eventCount",
";",
"}"
] |
Reads events from <tt>eventStream</tt> into a linked list. The
predicates associated with each event are counted and any which
occur at least <tt>cutoff</tt> times are added to the
<tt>predicatesInOut</tt> map along with a unique integer index.
@param eventStream an <code>EventStream</code> value
@param eventStore a writer to which the events are written to for later processing.
@param predicatesInOut a <code>TObjectIntHashMap</code> value
@param cutoff an <code>int</code> value
|
[
"Reads",
"events",
"from",
"<tt",
">",
"eventStream<",
"/",
"tt",
">",
"into",
"a",
"linked",
"list",
".",
"The",
"predicates",
"associated",
"with",
"each",
"event",
"are",
"counted",
"and",
"any",
"which",
"occur",
"at",
"least",
"<tt",
">",
"cutoff<",
"/",
"tt",
">",
"times",
"are",
"added",
"to",
"the",
"<tt",
">",
"predicatesInOut<",
"/",
"tt",
">",
"map",
"along",
"with",
"a",
"unique",
"integer",
"index",
"."
] |
train
|
https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/maxent/TwoPassDataIndexer.java#L104-L129
|
pressgang-ccms/PressGangCCMSContentSpec
|
src/main/java/org/jboss/pressgang/ccms/contentspec/utils/ContentSpecUtilities.java
|
ContentSpecUtilities.replaceChecksum
|
public static String replaceChecksum(final String contentSpecString, final String checksum) {
"""
Replaces the checksum of a Content Spec with a new checksum value
@param contentSpecString The content spec to replace the checksum for.
@param checksum The new checksum to be set in the Content Spec.
@return The fixed content spec string.
"""
Matcher matcher = CS_CHECKSUM_PATTERN.matcher(contentSpecString);
if (matcher.find()) {
return matcher.replaceFirst("CHECKSUM=" + checksum + "\n");
}
return contentSpecString;
}
|
java
|
public static String replaceChecksum(final String contentSpecString, final String checksum) {
Matcher matcher = CS_CHECKSUM_PATTERN.matcher(contentSpecString);
if (matcher.find()) {
return matcher.replaceFirst("CHECKSUM=" + checksum + "\n");
}
return contentSpecString;
}
|
[
"public",
"static",
"String",
"replaceChecksum",
"(",
"final",
"String",
"contentSpecString",
",",
"final",
"String",
"checksum",
")",
"{",
"Matcher",
"matcher",
"=",
"CS_CHECKSUM_PATTERN",
".",
"matcher",
"(",
"contentSpecString",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"return",
"matcher",
".",
"replaceFirst",
"(",
"\"CHECKSUM=\"",
"+",
"checksum",
"+",
"\"\\n\"",
")",
";",
"}",
"return",
"contentSpecString",
";",
"}"
] |
Replaces the checksum of a Content Spec with a new checksum value
@param contentSpecString The content spec to replace the checksum for.
@param checksum The new checksum to be set in the Content Spec.
@return The fixed content spec string.
|
[
"Replaces",
"the",
"checksum",
"of",
"a",
"Content",
"Spec",
"with",
"a",
"new",
"checksum",
"value"
] |
train
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/utils/ContentSpecUtilities.java#L151-L158
|
japgolly/svg-android
|
src/main/java/com/larvalabs/svgandroid/SVGBuilder.java
|
SVGBuilder.setColorSwap
|
public SVGBuilder setColorSwap(int searchColor, int replaceColor, boolean overideOpacity) {
"""
Replaces a single colour with another, affecting the opacity.
@param searchColor The colour in the SVG.
@param replaceColor The desired colour.
@param overideOpacity If true, combines the opacity defined in the SVG resource with the alpha of replaceColor.
"""
this.searchColor = searchColor;
this.replaceColor = replaceColor;
this.overideOpacity = overideOpacity;
return this;
}
|
java
|
public SVGBuilder setColorSwap(int searchColor, int replaceColor, boolean overideOpacity) {
this.searchColor = searchColor;
this.replaceColor = replaceColor;
this.overideOpacity = overideOpacity;
return this;
}
|
[
"public",
"SVGBuilder",
"setColorSwap",
"(",
"int",
"searchColor",
",",
"int",
"replaceColor",
",",
"boolean",
"overideOpacity",
")",
"{",
"this",
".",
"searchColor",
"=",
"searchColor",
";",
"this",
".",
"replaceColor",
"=",
"replaceColor",
";",
"this",
".",
"overideOpacity",
"=",
"overideOpacity",
";",
"return",
"this",
";",
"}"
] |
Replaces a single colour with another, affecting the opacity.
@param searchColor The colour in the SVG.
@param replaceColor The desired colour.
@param overideOpacity If true, combines the opacity defined in the SVG resource with the alpha of replaceColor.
|
[
"Replaces",
"a",
"single",
"colour",
"with",
"another",
"affecting",
"the",
"opacity",
"."
] |
train
|
https://github.com/japgolly/svg-android/blob/823affb6110292abcb8c5f783f86217643307f27/src/main/java/com/larvalabs/svgandroid/SVGBuilder.java#L99-L104
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/event/InitOnceFieldHandler.java
|
InitOnceFieldHandler.syncClonedListener
|
public boolean syncClonedListener(BaseField field, FieldListener listener, boolean bInitCalled) {
"""
Set this cloned listener to the same state at this listener.
@param field The field this new listener will be added to.
@param The new listener to sync to this.
@param Has the init method been called?
@return True if I called init.
"""
bInitCalled = super.syncClonedListener(field, listener, bInitCalled);
((InitOnceFieldHandler)listener).setFirstTime(m_bFirstTime);
return bInitCalled;
}
|
java
|
public boolean syncClonedListener(BaseField field, FieldListener listener, boolean bInitCalled)
{
bInitCalled = super.syncClonedListener(field, listener, bInitCalled);
((InitOnceFieldHandler)listener).setFirstTime(m_bFirstTime);
return bInitCalled;
}
|
[
"public",
"boolean",
"syncClonedListener",
"(",
"BaseField",
"field",
",",
"FieldListener",
"listener",
",",
"boolean",
"bInitCalled",
")",
"{",
"bInitCalled",
"=",
"super",
".",
"syncClonedListener",
"(",
"field",
",",
"listener",
",",
"bInitCalled",
")",
";",
"(",
"(",
"InitOnceFieldHandler",
")",
"listener",
")",
".",
"setFirstTime",
"(",
"m_bFirstTime",
")",
";",
"return",
"bInitCalled",
";",
"}"
] |
Set this cloned listener to the same state at this listener.
@param field The field this new listener will be added to.
@param The new listener to sync to this.
@param Has the init method been called?
@return True if I called init.
|
[
"Set",
"this",
"cloned",
"listener",
"to",
"the",
"same",
"state",
"at",
"this",
"listener",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/InitOnceFieldHandler.java#L80-L85
|
cdapio/tephra
|
tephra-core/src/main/java/co/cask/tephra/util/TxUtils.java
|
TxUtils.getOldestVisibleTimestamp
|
public static long getOldestVisibleTimestamp(Map<byte[], Long> ttlByFamily, Transaction tx) {
"""
Returns the oldest visible timestamp for the given transaction, based on the TTLs configured for each column
family. If no TTL is set on any column family, the oldest visible timestamp will be {@code 0}.
@param ttlByFamily A map of column family name to TTL value (in milliseconds)
@param tx The current transaction
@return The oldest timestamp that will be visible for the given transaction and TTL configuration
"""
long maxTTL = getMaxTTL(ttlByFamily);
// we know that data will not be cleaned up while this tx is running up to this point as janitor uses it
return maxTTL < Long.MAX_VALUE ? tx.getVisibilityUpperBound() - maxTTL * TxConstants.MAX_TX_PER_MS : 0;
}
|
java
|
public static long getOldestVisibleTimestamp(Map<byte[], Long> ttlByFamily, Transaction tx) {
long maxTTL = getMaxTTL(ttlByFamily);
// we know that data will not be cleaned up while this tx is running up to this point as janitor uses it
return maxTTL < Long.MAX_VALUE ? tx.getVisibilityUpperBound() - maxTTL * TxConstants.MAX_TX_PER_MS : 0;
}
|
[
"public",
"static",
"long",
"getOldestVisibleTimestamp",
"(",
"Map",
"<",
"byte",
"[",
"]",
",",
"Long",
">",
"ttlByFamily",
",",
"Transaction",
"tx",
")",
"{",
"long",
"maxTTL",
"=",
"getMaxTTL",
"(",
"ttlByFamily",
")",
";",
"// we know that data will not be cleaned up while this tx is running up to this point as janitor uses it",
"return",
"maxTTL",
"<",
"Long",
".",
"MAX_VALUE",
"?",
"tx",
".",
"getVisibilityUpperBound",
"(",
")",
"-",
"maxTTL",
"*",
"TxConstants",
".",
"MAX_TX_PER_MS",
":",
"0",
";",
"}"
] |
Returns the oldest visible timestamp for the given transaction, based on the TTLs configured for each column
family. If no TTL is set on any column family, the oldest visible timestamp will be {@code 0}.
@param ttlByFamily A map of column family name to TTL value (in milliseconds)
@param tx The current transaction
@return The oldest timestamp that will be visible for the given transaction and TTL configuration
|
[
"Returns",
"the",
"oldest",
"visible",
"timestamp",
"for",
"the",
"given",
"transaction",
"based",
"on",
"the",
"TTLs",
"configured",
"for",
"each",
"column",
"family",
".",
"If",
"no",
"TTL",
"is",
"set",
"on",
"any",
"column",
"family",
"the",
"oldest",
"visible",
"timestamp",
"will",
"be",
"{"
] |
train
|
https://github.com/cdapio/tephra/blob/082c56c15c6ece15002631ff6f89206a00d8915c/tephra-core/src/main/java/co/cask/tephra/util/TxUtils.java#L61-L65
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-native-api/src/main/java/org/nd4j/rng/deallocator/NativeRandomDeallocator.java
|
NativeRandomDeallocator.trackStatePointer
|
public void trackStatePointer(NativePack random) {
"""
This method is used internally from NativeRandom deallocators
This method doesn't accept Random interface implementations intentionally.
@param random
"""
if (random.getStatePointer() != null) {
GarbageStateReference reference = new GarbageStateReference(random, queue);
referenceMap.put(random.getStatePointer().address(), reference);
}
}
|
java
|
public void trackStatePointer(NativePack random) {
if (random.getStatePointer() != null) {
GarbageStateReference reference = new GarbageStateReference(random, queue);
referenceMap.put(random.getStatePointer().address(), reference);
}
}
|
[
"public",
"void",
"trackStatePointer",
"(",
"NativePack",
"random",
")",
"{",
"if",
"(",
"random",
".",
"getStatePointer",
"(",
")",
"!=",
"null",
")",
"{",
"GarbageStateReference",
"reference",
"=",
"new",
"GarbageStateReference",
"(",
"random",
",",
"queue",
")",
";",
"referenceMap",
".",
"put",
"(",
"random",
".",
"getStatePointer",
"(",
")",
".",
"address",
"(",
")",
",",
"reference",
")",
";",
"}",
"}"
] |
This method is used internally from NativeRandom deallocators
This method doesn't accept Random interface implementations intentionally.
@param random
|
[
"This",
"method",
"is",
"used",
"internally",
"from",
"NativeRandom",
"deallocators",
"This",
"method",
"doesn",
"t",
"accept",
"Random",
"interface",
"implementations",
"intentionally",
"."
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-native-api/src/main/java/org/nd4j/rng/deallocator/NativeRandomDeallocator.java#L65-L70
|
xmlunit/xmlunit
|
xmlunit-core/src/main/java/org/xmlunit/diff/DefaultComparisonFormatter.java
|
DefaultComparisonFormatter.getDetails
|
@Override
public String getDetails(Comparison.Detail difference, ComparisonType type, boolean formatXml) {
"""
Return the xml node from {@link Detail#getTarget()} as formatted String.
<p>Delegates to {@link #getFullFormattedXml} unless the {@code Comparison.Detail}'s {@code target} is null.</p>
@param difference The {@link Comparison#getControlDetails()} or {@link Comparison#getTestDetails()}.
@param type the implementation can return different details depending on the ComparisonType.
@param formatXml set this to true if the Comparison was generated with {@link
org.xmlunit.builder.DiffBuilder#ignoreWhitespace()} - this affects the indentation of the generated output.
@return the full xml node.
"""
if (difference.getTarget() == null) {
return "<NULL>";
}
return getFullFormattedXml(difference.getTarget(), type, formatXml);
}
|
java
|
@Override
public String getDetails(Comparison.Detail difference, ComparisonType type, boolean formatXml) {
if (difference.getTarget() == null) {
return "<NULL>";
}
return getFullFormattedXml(difference.getTarget(), type, formatXml);
}
|
[
"@",
"Override",
"public",
"String",
"getDetails",
"(",
"Comparison",
".",
"Detail",
"difference",
",",
"ComparisonType",
"type",
",",
"boolean",
"formatXml",
")",
"{",
"if",
"(",
"difference",
".",
"getTarget",
"(",
")",
"==",
"null",
")",
"{",
"return",
"\"<NULL>\"",
";",
"}",
"return",
"getFullFormattedXml",
"(",
"difference",
".",
"getTarget",
"(",
")",
",",
"type",
",",
"formatXml",
")",
";",
"}"
] |
Return the xml node from {@link Detail#getTarget()} as formatted String.
<p>Delegates to {@link #getFullFormattedXml} unless the {@code Comparison.Detail}'s {@code target} is null.</p>
@param difference The {@link Comparison#getControlDetails()} or {@link Comparison#getTestDetails()}.
@param type the implementation can return different details depending on the ComparisonType.
@param formatXml set this to true if the Comparison was generated with {@link
org.xmlunit.builder.DiffBuilder#ignoreWhitespace()} - this affects the indentation of the generated output.
@return the full xml node.
|
[
"Return",
"the",
"xml",
"node",
"from",
"{",
"@link",
"Detail#getTarget",
"()",
"}",
"as",
"formatted",
"String",
"."
] |
train
|
https://github.com/xmlunit/xmlunit/blob/fe3d701d43f57ee83dcba336e4c1555619d3084b/xmlunit-core/src/main/java/org/xmlunit/diff/DefaultComparisonFormatter.java#L336-L342
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.messaging.utils/src/com/ibm/ws/sib/utils/ras/SibTr.java
|
SibTr.formatSliceToSB
|
private static void formatSliceToSB(StringBuilder sb, DataSlice slice, int max) {
"""
Produce a formatted view of a DataSlice. Duplicate output lines are
suppressed to save space.
<p>
@param sb the StringBuilder to the end of which the slice will be formatted
@param slice The DataSlice to be formatted
@param max The maximum amount of data to format for the slice
@return the formatted data slice
"""
if (slice != null)
{
if (slice.getBytes() != null)
{
formatBytesToSB(sb, slice.getBytes(), slice.getOffset(), slice.getLength(), true, max);
}
else
{
sb.append("empty slice"+ls);
}
}
else
{
sb.append("slice is null"+ls);
}
}
|
java
|
private static void formatSliceToSB(StringBuilder sb, DataSlice slice, int max)
{
if (slice != null)
{
if (slice.getBytes() != null)
{
formatBytesToSB(sb, slice.getBytes(), slice.getOffset(), slice.getLength(), true, max);
}
else
{
sb.append("empty slice"+ls);
}
}
else
{
sb.append("slice is null"+ls);
}
}
|
[
"private",
"static",
"void",
"formatSliceToSB",
"(",
"StringBuilder",
"sb",
",",
"DataSlice",
"slice",
",",
"int",
"max",
")",
"{",
"if",
"(",
"slice",
"!=",
"null",
")",
"{",
"if",
"(",
"slice",
".",
"getBytes",
"(",
")",
"!=",
"null",
")",
"{",
"formatBytesToSB",
"(",
"sb",
",",
"slice",
".",
"getBytes",
"(",
")",
",",
"slice",
".",
"getOffset",
"(",
")",
",",
"slice",
".",
"getLength",
"(",
")",
",",
"true",
",",
"max",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\"empty slice\"",
"+",
"ls",
")",
";",
"}",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\"slice is null\"",
"+",
"ls",
")",
";",
"}",
"}"
] |
Produce a formatted view of a DataSlice. Duplicate output lines are
suppressed to save space.
<p>
@param sb the StringBuilder to the end of which the slice will be formatted
@param slice The DataSlice to be formatted
@param max The maximum amount of data to format for the slice
@return the formatted data slice
|
[
"Produce",
"a",
"formatted",
"view",
"of",
"a",
"DataSlice",
".",
"Duplicate",
"output",
"lines",
"are",
"suppressed",
"to",
"save",
"space",
".",
"<p",
">"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.utils/src/com/ibm/ws/sib/utils/ras/SibTr.java#L1327-L1344
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java
|
AnalysisContext.lookupSystemClass
|
public static JavaClass lookupSystemClass(@Nonnull String className) throws ClassNotFoundException {
"""
This is equivalent to Repository.lookupClass() or this.lookupClass(),
except it uses the original Repository instead of the current one.
This can be important because URLClassPathRepository objects are closed
after an analysis, so JavaClass objects obtained from them are no good on
subsequent runs.
@param className
the name of the class
@return the JavaClass representing the class
@throws ClassNotFoundException
"""
// TODO: eventually we should move to our own thread-safe repository
// implementation
requireNonNull (className, "className is null");
if (originalRepository == null) {
throw new IllegalStateException("originalRepository is null");
}
JavaClass clazz = originalRepository.findClass(className);
if(clazz != null){
return clazz;
}
// XXX workaround for system classes missing on Java 9
// Not sure if we BCEL update, but this seem to work in simple cases
return AnalysisContext.currentAnalysisContext().lookupClass(className);
}
|
java
|
public static JavaClass lookupSystemClass(@Nonnull String className) throws ClassNotFoundException {
// TODO: eventually we should move to our own thread-safe repository
// implementation
requireNonNull (className, "className is null");
if (originalRepository == null) {
throw new IllegalStateException("originalRepository is null");
}
JavaClass clazz = originalRepository.findClass(className);
if(clazz != null){
return clazz;
}
// XXX workaround for system classes missing on Java 9
// Not sure if we BCEL update, but this seem to work in simple cases
return AnalysisContext.currentAnalysisContext().lookupClass(className);
}
|
[
"public",
"static",
"JavaClass",
"lookupSystemClass",
"(",
"@",
"Nonnull",
"String",
"className",
")",
"throws",
"ClassNotFoundException",
"{",
"// TODO: eventually we should move to our own thread-safe repository",
"// implementation",
"requireNonNull",
"(",
"className",
",",
"\"className is null\"",
")",
";",
"if",
"(",
"originalRepository",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"originalRepository is null\"",
")",
";",
"}",
"JavaClass",
"clazz",
"=",
"originalRepository",
".",
"findClass",
"(",
"className",
")",
";",
"if",
"(",
"clazz",
"!=",
"null",
")",
"{",
"return",
"clazz",
";",
"}",
"// XXX workaround for system classes missing on Java 9",
"// Not sure if we BCEL update, but this seem to work in simple cases",
"return",
"AnalysisContext",
".",
"currentAnalysisContext",
"(",
")",
".",
"lookupClass",
"(",
"className",
")",
";",
"}"
] |
This is equivalent to Repository.lookupClass() or this.lookupClass(),
except it uses the original Repository instead of the current one.
This can be important because URLClassPathRepository objects are closed
after an analysis, so JavaClass objects obtained from them are no good on
subsequent runs.
@param className
the name of the class
@return the JavaClass representing the class
@throws ClassNotFoundException
|
[
"This",
"is",
"equivalent",
"to",
"Repository",
".",
"lookupClass",
"()",
"or",
"this",
".",
"lookupClass",
"()",
"except",
"it",
"uses",
"the",
"original",
"Repository",
"instead",
"of",
"the",
"current",
"one",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/AnalysisContext.java#L540-L555
|
couchbase/couchbase-java-client
|
src/main/java/com/couchbase/client/java/query/dsl/functions/ConditionalFunctions.java
|
ConditionalFunctions.nanIf
|
public static Expression nanIf(Expression expression1, Expression expression2) {
"""
Returned expression results in NaN if expression1 = expression2, otherwise returns expression1.
Returns MISSING or NULL if either input is MISSING or NULL.
"""
return x("NANIF(" + expression1.toString() + ", " + expression2.toString() + ")");
}
|
java
|
public static Expression nanIf(Expression expression1, Expression expression2) {
return x("NANIF(" + expression1.toString() + ", " + expression2.toString() + ")");
}
|
[
"public",
"static",
"Expression",
"nanIf",
"(",
"Expression",
"expression1",
",",
"Expression",
"expression2",
")",
"{",
"return",
"x",
"(",
"\"NANIF(\"",
"+",
"expression1",
".",
"toString",
"(",
")",
"+",
"\", \"",
"+",
"expression2",
".",
"toString",
"(",
")",
"+",
"\")\"",
")",
";",
"}"
] |
Returned expression results in NaN if expression1 = expression2, otherwise returns expression1.
Returns MISSING or NULL if either input is MISSING or NULL.
|
[
"Returned",
"expression",
"results",
"in",
"NaN",
"if",
"expression1",
"=",
"expression2",
"otherwise",
"returns",
"expression1",
".",
"Returns",
"MISSING",
"or",
"NULL",
"if",
"either",
"input",
"is",
"MISSING",
"or",
"NULL",
"."
] |
train
|
https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/query/dsl/functions/ConditionalFunctions.java#L124-L126
|
deephacks/confit
|
core/src/main/java/org/deephacks/confit/internal/core/property/typesafe/ConfigValueFactory.java
|
ConfigValueFactory.fromAnyRef
|
public static ConfigValue fromAnyRef(Object object, String originDescription) {
"""
Creates a ConfigValue from a plain Java boxed value, which may be a
Boolean, Number, String, Map, Iterable, or null. A Map must be a Map from
String to more values that can be supplied to fromAnyRef(). An Iterable
must iterate over more values that can be supplied to fromAnyRef(). A Map
will become a ConfigObject and an Iterable will become a ConfigList. If
the Iterable is not an ordered collection, results could be strange,
since ConfigList is ordered.
<p>
In a Map passed to fromAnyRef(), the map's keys are plain keys, not path
expressions. So if your Map has a key "foo.bar" then you will lookup one
object with a key called "foo.bar", rather than an object with a key
"foo" containing another object with a key "bar".
<p>
The originDescription will be used to set the origin() field on the
ConfigValue. It should normally be the name of the file the values came
from, or something short describing the value such as "default settings".
The originDescription is prefixed to error messages so users can tell
where problematic values are coming from.
<p>
Supplying the result of ConfigValue.unwrapped() to this function is
guaranteed to work and should give you back a ConfigValue that matches
the one you unwrapped. The re-wrapped ConfigValue will lose some
information that was present in the original such as its origin, but it
will have matching values.
<p>
This function throws if you supply a value that cannot be converted to a
ConfigValue, but supplying such a value is a bug in your program, so you
should never handle the exception. Just fix your program (or report a bug
against this library).
@param object
object to convert to ConfigValue
@param originDescription
name of origin file or brief description of what the value is
@return a new value
"""
return ConfigImpl.fromAnyRef(object, originDescription);
}
|
java
|
public static ConfigValue fromAnyRef(Object object, String originDescription) {
return ConfigImpl.fromAnyRef(object, originDescription);
}
|
[
"public",
"static",
"ConfigValue",
"fromAnyRef",
"(",
"Object",
"object",
",",
"String",
"originDescription",
")",
"{",
"return",
"ConfigImpl",
".",
"fromAnyRef",
"(",
"object",
",",
"originDescription",
")",
";",
"}"
] |
Creates a ConfigValue from a plain Java boxed value, which may be a
Boolean, Number, String, Map, Iterable, or null. A Map must be a Map from
String to more values that can be supplied to fromAnyRef(). An Iterable
must iterate over more values that can be supplied to fromAnyRef(). A Map
will become a ConfigObject and an Iterable will become a ConfigList. If
the Iterable is not an ordered collection, results could be strange,
since ConfigList is ordered.
<p>
In a Map passed to fromAnyRef(), the map's keys are plain keys, not path
expressions. So if your Map has a key "foo.bar" then you will lookup one
object with a key called "foo.bar", rather than an object with a key
"foo" containing another object with a key "bar".
<p>
The originDescription will be used to set the origin() field on the
ConfigValue. It should normally be the name of the file the values came
from, or something short describing the value such as "default settings".
The originDescription is prefixed to error messages so users can tell
where problematic values are coming from.
<p>
Supplying the result of ConfigValue.unwrapped() to this function is
guaranteed to work and should give you back a ConfigValue that matches
the one you unwrapped. The re-wrapped ConfigValue will lose some
information that was present in the original such as its origin, but it
will have matching values.
<p>
This function throws if you supply a value that cannot be converted to a
ConfigValue, but supplying such a value is a bug in your program, so you
should never handle the exception. Just fix your program (or report a bug
against this library).
@param object
object to convert to ConfigValue
@param originDescription
name of origin file or brief description of what the value is
@return a new value
|
[
"Creates",
"a",
"ConfigValue",
"from",
"a",
"plain",
"Java",
"boxed",
"value",
"which",
"may",
"be",
"a",
"Boolean",
"Number",
"String",
"Map",
"Iterable",
"or",
"null",
".",
"A",
"Map",
"must",
"be",
"a",
"Map",
"from",
"String",
"to",
"more",
"values",
"that",
"can",
"be",
"supplied",
"to",
"fromAnyRef",
"()",
".",
"An",
"Iterable",
"must",
"iterate",
"over",
"more",
"values",
"that",
"can",
"be",
"supplied",
"to",
"fromAnyRef",
"()",
".",
"A",
"Map",
"will",
"become",
"a",
"ConfigObject",
"and",
"an",
"Iterable",
"will",
"become",
"a",
"ConfigList",
".",
"If",
"the",
"Iterable",
"is",
"not",
"an",
"ordered",
"collection",
"results",
"could",
"be",
"strange",
"since",
"ConfigList",
"is",
"ordered",
"."
] |
train
|
https://github.com/deephacks/confit/blob/4e6d4ee5fed32cbc5104433e61de1bcf1b360832/core/src/main/java/org/deephacks/confit/internal/core/property/typesafe/ConfigValueFactory.java#L60-L62
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/VirtualNetworkGatewayConnectionsInner.java
|
VirtualNetworkGatewayConnectionsInner.beginCreateOrUpdateAsync
|
public Observable<VirtualNetworkGatewayConnectionInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnectionInner parameters) {
"""
Creates or updates a virtual network gateway connection in the specified resource group.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayConnectionName The name of the virtual network gateway connection.
@param parameters Parameters supplied to the create or update virtual network gateway connection operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualNetworkGatewayConnectionInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).map(new Func1<ServiceResponse<VirtualNetworkGatewayConnectionInner>, VirtualNetworkGatewayConnectionInner>() {
@Override
public VirtualNetworkGatewayConnectionInner call(ServiceResponse<VirtualNetworkGatewayConnectionInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<VirtualNetworkGatewayConnectionInner> beginCreateOrUpdateAsync(String resourceGroupName, String virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnectionInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName, parameters).map(new Func1<ServiceResponse<VirtualNetworkGatewayConnectionInner>, VirtualNetworkGatewayConnectionInner>() {
@Override
public VirtualNetworkGatewayConnectionInner call(ServiceResponse<VirtualNetworkGatewayConnectionInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"VirtualNetworkGatewayConnectionInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayConnectionName",
",",
"VirtualNetworkGatewayConnectionInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayConnectionName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VirtualNetworkGatewayConnectionInner",
">",
",",
"VirtualNetworkGatewayConnectionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VirtualNetworkGatewayConnectionInner",
"call",
"(",
"ServiceResponse",
"<",
"VirtualNetworkGatewayConnectionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates or updates a virtual network gateway connection in the specified resource group.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayConnectionName The name of the virtual network gateway connection.
@param parameters Parameters supplied to the create or update virtual network gateway connection operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualNetworkGatewayConnectionInner object
|
[
"Creates",
"or",
"updates",
"a",
"virtual",
"network",
"gateway",
"connection",
"in",
"the",
"specified",
"resource",
"group",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/VirtualNetworkGatewayConnectionsInner.java#L241-L248
|
RoaringBitmap/RoaringBitmap
|
roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java
|
BufferUtil.setBitmapRangeAndCardinalityChange
|
@Deprecated
public static int setBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) {
"""
set bits at start, start+1,..., end-1 and report the cardinality change
@param bitmap array of words to be modified
@param start first index to be modified (inclusive)
@param end last index to be modified (exclusive)
@return cardinality change
"""
if (BufferUtil.isBackedBySimpleArray(bitmap)) {
return Util.setBitmapRangeAndCardinalityChange(bitmap.array(), start, end);
}
int cardbefore = cardinalityInBitmapWordRange(bitmap, start, end);
setBitmapRange(bitmap, start, end);
int cardafter = cardinalityInBitmapWordRange(bitmap, start, end);
return cardafter - cardbefore;
}
|
java
|
@Deprecated
public static int setBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) {
if (BufferUtil.isBackedBySimpleArray(bitmap)) {
return Util.setBitmapRangeAndCardinalityChange(bitmap.array(), start, end);
}
int cardbefore = cardinalityInBitmapWordRange(bitmap, start, end);
setBitmapRange(bitmap, start, end);
int cardafter = cardinalityInBitmapWordRange(bitmap, start, end);
return cardafter - cardbefore;
}
|
[
"@",
"Deprecated",
"public",
"static",
"int",
"setBitmapRangeAndCardinalityChange",
"(",
"LongBuffer",
"bitmap",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"BufferUtil",
".",
"isBackedBySimpleArray",
"(",
"bitmap",
")",
")",
"{",
"return",
"Util",
".",
"setBitmapRangeAndCardinalityChange",
"(",
"bitmap",
".",
"array",
"(",
")",
",",
"start",
",",
"end",
")",
";",
"}",
"int",
"cardbefore",
"=",
"cardinalityInBitmapWordRange",
"(",
"bitmap",
",",
"start",
",",
"end",
")",
";",
"setBitmapRange",
"(",
"bitmap",
",",
"start",
",",
"end",
")",
";",
"int",
"cardafter",
"=",
"cardinalityInBitmapWordRange",
"(",
"bitmap",
",",
"start",
",",
"end",
")",
";",
"return",
"cardafter",
"-",
"cardbefore",
";",
"}"
] |
set bits at start, start+1,..., end-1 and report the cardinality change
@param bitmap array of words to be modified
@param start first index to be modified (inclusive)
@param end last index to be modified (exclusive)
@return cardinality change
|
[
"set",
"bits",
"at",
"start",
"start",
"+",
"1",
"...",
"end",
"-",
"1",
"and",
"report",
"the",
"cardinality",
"change"
] |
train
|
https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java#L431-L440
|
ModeShape/modeshape
|
modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java
|
CheckArg.isLessThan
|
public static void isLessThan( int argument,
int lessThanValue,
String name ) {
"""
Check that the argument is less than the supplied value
@param argument The argument
@param lessThanValue the value that is to be used to check the value
@param name The name of the argument
@throws IllegalArgumentException If argument is not less than the supplied value
"""
if (argument >= lessThanValue) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeLessThan.text(name, argument, lessThanValue));
}
}
|
java
|
public static void isLessThan( int argument,
int lessThanValue,
String name ) {
if (argument >= lessThanValue) {
throw new IllegalArgumentException(CommonI18n.argumentMustBeLessThan.text(name, argument, lessThanValue));
}
}
|
[
"public",
"static",
"void",
"isLessThan",
"(",
"int",
"argument",
",",
"int",
"lessThanValue",
",",
"String",
"name",
")",
"{",
"if",
"(",
"argument",
">=",
"lessThanValue",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"CommonI18n",
".",
"argumentMustBeLessThan",
".",
"text",
"(",
"name",
",",
"argument",
",",
"lessThanValue",
")",
")",
";",
"}",
"}"
] |
Check that the argument is less than the supplied value
@param argument The argument
@param lessThanValue the value that is to be used to check the value
@param name The name of the argument
@throws IllegalArgumentException If argument is not less than the supplied value
|
[
"Check",
"that",
"the",
"argument",
"is",
"less",
"than",
"the",
"supplied",
"value"
] |
train
|
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/CheckArg.java#L105-L111
|
googleapis/google-cloud-java
|
google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SubnetworkClient.java
|
SubnetworkClient.insertSubnetwork
|
@BetaApi
public final Operation insertSubnetwork(ProjectRegionName region, Subnetwork subnetworkResource) {
"""
Creates a subnetwork in the specified project using the data included in the request.
<p>Sample code:
<pre><code>
try (SubnetworkClient subnetworkClient = SubnetworkClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
Subnetwork subnetworkResource = Subnetwork.newBuilder().build();
Operation response = subnetworkClient.insertSubnetwork(region, subnetworkResource);
}
</code></pre>
@param region Name of the region scoping this request.
@param subnetworkResource A Subnetwork resource. (== resource_for beta.subnetworks ==) (==
resource_for v1.subnetworks ==)
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
InsertSubnetworkHttpRequest request =
InsertSubnetworkHttpRequest.newBuilder()
.setRegion(region == null ? null : region.toString())
.setSubnetworkResource(subnetworkResource)
.build();
return insertSubnetwork(request);
}
|
java
|
@BetaApi
public final Operation insertSubnetwork(ProjectRegionName region, Subnetwork subnetworkResource) {
InsertSubnetworkHttpRequest request =
InsertSubnetworkHttpRequest.newBuilder()
.setRegion(region == null ? null : region.toString())
.setSubnetworkResource(subnetworkResource)
.build();
return insertSubnetwork(request);
}
|
[
"@",
"BetaApi",
"public",
"final",
"Operation",
"insertSubnetwork",
"(",
"ProjectRegionName",
"region",
",",
"Subnetwork",
"subnetworkResource",
")",
"{",
"InsertSubnetworkHttpRequest",
"request",
"=",
"InsertSubnetworkHttpRequest",
".",
"newBuilder",
"(",
")",
".",
"setRegion",
"(",
"region",
"==",
"null",
"?",
"null",
":",
"region",
".",
"toString",
"(",
")",
")",
".",
"setSubnetworkResource",
"(",
"subnetworkResource",
")",
".",
"build",
"(",
")",
";",
"return",
"insertSubnetwork",
"(",
"request",
")",
";",
"}"
] |
Creates a subnetwork in the specified project using the data included in the request.
<p>Sample code:
<pre><code>
try (SubnetworkClient subnetworkClient = SubnetworkClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
Subnetwork subnetworkResource = Subnetwork.newBuilder().build();
Operation response = subnetworkClient.insertSubnetwork(region, subnetworkResource);
}
</code></pre>
@param region Name of the region scoping this request.
@param subnetworkResource A Subnetwork resource. (== resource_for beta.subnetworks ==) (==
resource_for v1.subnetworks ==)
@throws com.google.api.gax.rpc.ApiException if the remote call fails
|
[
"Creates",
"a",
"subnetwork",
"in",
"the",
"specified",
"project",
"using",
"the",
"data",
"included",
"in",
"the",
"request",
"."
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/SubnetworkClient.java#L726-L735
|
jglobus/JGlobus
|
gridftp/src/main/java/org/globus/ftp/dc/TransferThreadManager.java
|
TransferThreadManager.activeConnect
|
public void activeConnect(HostPort hp, int connections) {
"""
Act as the active side. Connect to the server and
store the newly connected sockets in the socketPool.
"""
for (int i = 0; i < connections; i++) {
SocketBox sbox = new ManagedSocketBox();
logger.debug("adding new empty socketBox to the socket pool");
socketPool.add(sbox);
logger.debug(
"connecting active socket "
+ i
+ "; total cached sockets = "
+ socketPool.count());
Task task =
new GridFTPActiveConnectTask(
hp,
localControlChannel,
sbox,
gSession);
runTask(task);
}
}
|
java
|
public void activeConnect(HostPort hp, int connections) {
for (int i = 0; i < connections; i++) {
SocketBox sbox = new ManagedSocketBox();
logger.debug("adding new empty socketBox to the socket pool");
socketPool.add(sbox);
logger.debug(
"connecting active socket "
+ i
+ "; total cached sockets = "
+ socketPool.count());
Task task =
new GridFTPActiveConnectTask(
hp,
localControlChannel,
sbox,
gSession);
runTask(task);
}
}
|
[
"public",
"void",
"activeConnect",
"(",
"HostPort",
"hp",
",",
"int",
"connections",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"connections",
";",
"i",
"++",
")",
"{",
"SocketBox",
"sbox",
"=",
"new",
"ManagedSocketBox",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"adding new empty socketBox to the socket pool\"",
")",
";",
"socketPool",
".",
"add",
"(",
"sbox",
")",
";",
"logger",
".",
"debug",
"(",
"\"connecting active socket \"",
"+",
"i",
"+",
"\"; total cached sockets = \"",
"+",
"socketPool",
".",
"count",
"(",
")",
")",
";",
"Task",
"task",
"=",
"new",
"GridFTPActiveConnectTask",
"(",
"hp",
",",
"localControlChannel",
",",
"sbox",
",",
"gSession",
")",
";",
"runTask",
"(",
"task",
")",
";",
"}",
"}"
] |
Act as the active side. Connect to the server and
store the newly connected sockets in the socketPool.
|
[
"Act",
"as",
"the",
"active",
"side",
".",
"Connect",
"to",
"the",
"server",
"and",
"store",
"the",
"newly",
"connected",
"sockets",
"in",
"the",
"socketPool",
"."
] |
train
|
https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/gridftp/src/main/java/org/globus/ftp/dc/TransferThreadManager.java#L59-L81
|
aws/aws-sdk-java
|
aws-java-sdk-codedeploy/src/main/java/com/amazonaws/services/codedeploy/model/CreateDeploymentGroupRequest.java
|
CreateDeploymentGroupRequest.getTriggerConfigurations
|
public java.util.List<TriggerConfig> getTriggerConfigurations() {
"""
<p>
Information about triggers to create when the deployment group is created. For examples, see <a
href="https://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-notify-sns.html">Create a Trigger for an AWS
CodeDeploy Event</a> in the AWS CodeDeploy User Guide.
</p>
@return Information about triggers to create when the deployment group is created. For examples, see <a
href="https://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-notify-sns.html">Create a Trigger
for an AWS CodeDeploy Event</a> in the AWS CodeDeploy User Guide.
"""
if (triggerConfigurations == null) {
triggerConfigurations = new com.amazonaws.internal.SdkInternalList<TriggerConfig>();
}
return triggerConfigurations;
}
|
java
|
public java.util.List<TriggerConfig> getTriggerConfigurations() {
if (triggerConfigurations == null) {
triggerConfigurations = new com.amazonaws.internal.SdkInternalList<TriggerConfig>();
}
return triggerConfigurations;
}
|
[
"public",
"java",
".",
"util",
".",
"List",
"<",
"TriggerConfig",
">",
"getTriggerConfigurations",
"(",
")",
"{",
"if",
"(",
"triggerConfigurations",
"==",
"null",
")",
"{",
"triggerConfigurations",
"=",
"new",
"com",
".",
"amazonaws",
".",
"internal",
".",
"SdkInternalList",
"<",
"TriggerConfig",
">",
"(",
")",
";",
"}",
"return",
"triggerConfigurations",
";",
"}"
] |
<p>
Information about triggers to create when the deployment group is created. For examples, see <a
href="https://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-notify-sns.html">Create a Trigger for an AWS
CodeDeploy Event</a> in the AWS CodeDeploy User Guide.
</p>
@return Information about triggers to create when the deployment group is created. For examples, see <a
href="https://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-notify-sns.html">Create a Trigger
for an AWS CodeDeploy Event</a> in the AWS CodeDeploy User Guide.
|
[
"<p",
">",
"Information",
"about",
"triggers",
"to",
"create",
"when",
"the",
"deployment",
"group",
"is",
"created",
".",
"For",
"examples",
"see",
"<a",
"href",
"=",
"https",
":",
"//",
"docs",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"codedeploy",
"/",
"latest",
"/",
"userguide",
"/",
"how",
"-",
"to",
"-",
"notify",
"-",
"sns",
".",
"html",
">",
"Create",
"a",
"Trigger",
"for",
"an",
"AWS",
"CodeDeploy",
"Event<",
"/",
"a",
">",
"in",
"the",
"AWS",
"CodeDeploy",
"User",
"Guide",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-codedeploy/src/main/java/com/amazonaws/services/codedeploy/model/CreateDeploymentGroupRequest.java#L621-L626
|
ironjacamar/ironjacamar
|
common/src/main/java/org/ironjacamar/common/metadata/common/AbstractParser.java
|
AbstractParser.attributeAsBoolean
|
protected Boolean attributeAsBoolean(XMLStreamReader reader, String attributeName, Boolean defaultValue,
Map<String, String> expressions)
throws XMLStreamException, ParserException {
"""
convert an xml attribute in boolean value. Empty elements results in default value
@param reader the StAX reader
@param attributeName the name of the attribute
@param defaultValue defaultValue
@param expressions The expressions
@return the boolean representing element
@throws XMLStreamException StAX exception
@throws ParserException in case of not valid boolean for given attribute
"""
String attributeString = rawAttributeText(reader, attributeName);
if (attributeName != null && expressions != null && attributeString != null &&
attributeString.indexOf("${") != -1)
expressions.put(attributeName, attributeString);
String stringValue = getSubstitutionValue(attributeString);
if (StringUtils.isEmpty(stringValue) || stringValue.trim().equalsIgnoreCase("true") ||
stringValue.trim().equalsIgnoreCase("false"))
{
return StringUtils.isEmpty(stringValue) ? defaultValue : Boolean.valueOf(stringValue.trim());
}
else
{
throw new ParserException(bundle.attributeAsBoolean(attributeString, reader.getLocalName()));
}
}
|
java
|
protected Boolean attributeAsBoolean(XMLStreamReader reader, String attributeName, Boolean defaultValue,
Map<String, String> expressions)
throws XMLStreamException, ParserException
{
String attributeString = rawAttributeText(reader, attributeName);
if (attributeName != null && expressions != null && attributeString != null &&
attributeString.indexOf("${") != -1)
expressions.put(attributeName, attributeString);
String stringValue = getSubstitutionValue(attributeString);
if (StringUtils.isEmpty(stringValue) || stringValue.trim().equalsIgnoreCase("true") ||
stringValue.trim().equalsIgnoreCase("false"))
{
return StringUtils.isEmpty(stringValue) ? defaultValue : Boolean.valueOf(stringValue.trim());
}
else
{
throw new ParserException(bundle.attributeAsBoolean(attributeString, reader.getLocalName()));
}
}
|
[
"protected",
"Boolean",
"attributeAsBoolean",
"(",
"XMLStreamReader",
"reader",
",",
"String",
"attributeName",
",",
"Boolean",
"defaultValue",
",",
"Map",
"<",
"String",
",",
"String",
">",
"expressions",
")",
"throws",
"XMLStreamException",
",",
"ParserException",
"{",
"String",
"attributeString",
"=",
"rawAttributeText",
"(",
"reader",
",",
"attributeName",
")",
";",
"if",
"(",
"attributeName",
"!=",
"null",
"&&",
"expressions",
"!=",
"null",
"&&",
"attributeString",
"!=",
"null",
"&&",
"attributeString",
".",
"indexOf",
"(",
"\"${\"",
")",
"!=",
"-",
"1",
")",
"expressions",
".",
"put",
"(",
"attributeName",
",",
"attributeString",
")",
";",
"String",
"stringValue",
"=",
"getSubstitutionValue",
"(",
"attributeString",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"stringValue",
")",
"||",
"stringValue",
".",
"trim",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"\"true\"",
")",
"||",
"stringValue",
".",
"trim",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"\"false\"",
")",
")",
"{",
"return",
"StringUtils",
".",
"isEmpty",
"(",
"stringValue",
")",
"?",
"defaultValue",
":",
"Boolean",
".",
"valueOf",
"(",
"stringValue",
".",
"trim",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ParserException",
"(",
"bundle",
".",
"attributeAsBoolean",
"(",
"attributeString",
",",
"reader",
".",
"getLocalName",
"(",
")",
")",
")",
";",
"}",
"}"
] |
convert an xml attribute in boolean value. Empty elements results in default value
@param reader the StAX reader
@param attributeName the name of the attribute
@param defaultValue defaultValue
@param expressions The expressions
@return the boolean representing element
@throws XMLStreamException StAX exception
@throws ParserException in case of not valid boolean for given attribute
|
[
"convert",
"an",
"xml",
"attribute",
"in",
"boolean",
"value",
".",
"Empty",
"elements",
"results",
"in",
"default",
"value"
] |
train
|
https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/common/src/main/java/org/ironjacamar/common/metadata/common/AbstractParser.java#L128-L148
|
elki-project/elki
|
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/CASH.java
|
CASH.buildDerivatorDB
|
private Database buildDerivatorDB(Relation<ParameterizationFunction> relation, DBIDs ids) {
"""
Builds a database for the derivator consisting of the ids in the specified
interval.
@param relation the database storing the parameterization functions
@param ids the ids to build the database from
@return a database for the derivator consisting of the ids in the specified
interval
"""
ProxyDatabase proxy = new ProxyDatabase(ids);
int dim = dimensionality(relation);
SimpleTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<>(DoubleVector.FACTORY, dim);
MaterializedRelation<DoubleVector> prep = new MaterializedRelation<>(type, ids);
proxy.addRelation(prep);
// Project
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
prep.insert(iter, DoubleVector.wrap(relation.get(iter).getColumnVector()));
}
return proxy;
}
|
java
|
private Database buildDerivatorDB(Relation<ParameterizationFunction> relation, DBIDs ids) {
ProxyDatabase proxy = new ProxyDatabase(ids);
int dim = dimensionality(relation);
SimpleTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<>(DoubleVector.FACTORY, dim);
MaterializedRelation<DoubleVector> prep = new MaterializedRelation<>(type, ids);
proxy.addRelation(prep);
// Project
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
prep.insert(iter, DoubleVector.wrap(relation.get(iter).getColumnVector()));
}
return proxy;
}
|
[
"private",
"Database",
"buildDerivatorDB",
"(",
"Relation",
"<",
"ParameterizationFunction",
">",
"relation",
",",
"DBIDs",
"ids",
")",
"{",
"ProxyDatabase",
"proxy",
"=",
"new",
"ProxyDatabase",
"(",
"ids",
")",
";",
"int",
"dim",
"=",
"dimensionality",
"(",
"relation",
")",
";",
"SimpleTypeInformation",
"<",
"DoubleVector",
">",
"type",
"=",
"new",
"VectorFieldTypeInformation",
"<>",
"(",
"DoubleVector",
".",
"FACTORY",
",",
"dim",
")",
";",
"MaterializedRelation",
"<",
"DoubleVector",
">",
"prep",
"=",
"new",
"MaterializedRelation",
"<>",
"(",
"type",
",",
"ids",
")",
";",
"proxy",
".",
"addRelation",
"(",
"prep",
")",
";",
"// Project",
"for",
"(",
"DBIDIter",
"iter",
"=",
"ids",
".",
"iter",
"(",
")",
";",
"iter",
".",
"valid",
"(",
")",
";",
"iter",
".",
"advance",
"(",
")",
")",
"{",
"prep",
".",
"insert",
"(",
"iter",
",",
"DoubleVector",
".",
"wrap",
"(",
"relation",
".",
"get",
"(",
"iter",
")",
".",
"getColumnVector",
"(",
")",
")",
")",
";",
"}",
"return",
"proxy",
";",
"}"
] |
Builds a database for the derivator consisting of the ids in the specified
interval.
@param relation the database storing the parameterization functions
@param ids the ids to build the database from
@return a database for the derivator consisting of the ids in the specified
interval
|
[
"Builds",
"a",
"database",
"for",
"the",
"derivator",
"consisting",
"of",
"the",
"ids",
"in",
"the",
"specified",
"interval",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/CASH.java#L719-L731
|
sshtools/j2ssh-maverick
|
j2ssh-maverick/src/main/java/com/sshtools/ssh2/Ssh2Channel.java
|
Ssh2Channel.channelRequest
|
protected void channelRequest(String requesttype, boolean wantreply,
byte[] requestdata) throws SshException {
"""
Called when a channel request is received, by default this method sends a
failure message if the remote side requests a reply. Overidden methods
should ALWAYS call this superclass method.
@param requesttype
the name of the request
@param wantreply
specifies whether the remote side requires a success/failure
message
@param requestdata
the request data
@throws IOException
"""
if (wantreply) {
ByteArrayWriter msg = new ByteArrayWriter();
try {
msg.write((byte) SSH_MSG_CHANNEL_FAILURE);
msg.writeInt(remoteid);
connection.sendMessage(msg.toByteArray(), true);
} catch (IOException e) {
throw new SshException(e, SshException.INTERNAL_ERROR);
} finally {
try {
msg.close();
} catch (IOException e) {
}
}
}
}
|
java
|
protected void channelRequest(String requesttype, boolean wantreply,
byte[] requestdata) throws SshException {
if (wantreply) {
ByteArrayWriter msg = new ByteArrayWriter();
try {
msg.write((byte) SSH_MSG_CHANNEL_FAILURE);
msg.writeInt(remoteid);
connection.sendMessage(msg.toByteArray(), true);
} catch (IOException e) {
throw new SshException(e, SshException.INTERNAL_ERROR);
} finally {
try {
msg.close();
} catch (IOException e) {
}
}
}
}
|
[
"protected",
"void",
"channelRequest",
"(",
"String",
"requesttype",
",",
"boolean",
"wantreply",
",",
"byte",
"[",
"]",
"requestdata",
")",
"throws",
"SshException",
"{",
"if",
"(",
"wantreply",
")",
"{",
"ByteArrayWriter",
"msg",
"=",
"new",
"ByteArrayWriter",
"(",
")",
";",
"try",
"{",
"msg",
".",
"write",
"(",
"(",
"byte",
")",
"SSH_MSG_CHANNEL_FAILURE",
")",
";",
"msg",
".",
"writeInt",
"(",
"remoteid",
")",
";",
"connection",
".",
"sendMessage",
"(",
"msg",
".",
"toByteArray",
"(",
")",
",",
"true",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SshException",
"(",
"e",
",",
"SshException",
".",
"INTERNAL_ERROR",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"msg",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"}",
"}",
"}",
"}"
] |
Called when a channel request is received, by default this method sends a
failure message if the remote side requests a reply. Overidden methods
should ALWAYS call this superclass method.
@param requesttype
the name of the request
@param wantreply
specifies whether the remote side requires a success/failure
message
@param requestdata
the request data
@throws IOException
|
[
"Called",
"when",
"a",
"channel",
"request",
"is",
"received",
"by",
"default",
"this",
"method",
"sends",
"a",
"failure",
"message",
"if",
"the",
"remote",
"side",
"requests",
"a",
"reply",
".",
"Overidden",
"methods",
"should",
"ALWAYS",
"call",
"this",
"superclass",
"method",
"."
] |
train
|
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/ssh2/Ssh2Channel.java#L943-L961
|
vladmihalcea/flexy-pool
|
flexy-pool-core/src/main/java/com/vladmihalcea/flexypool/util/ReflectionUtils.java
|
ReflectionUtils.hasMethod
|
public static boolean hasMethod(Class<?> targetClass, String methodName, Class... parameterTypes) {
"""
Check if target class has the given method
@param targetClass target class
@param methodName method name
@param parameterTypes method parameter types
@return method availability
"""
try {
targetClass.getMethod(methodName, parameterTypes);
return true;
} catch (NoSuchMethodException e) {
return false;
}
}
|
java
|
public static boolean hasMethod(Class<?> targetClass, String methodName, Class... parameterTypes) {
try {
targetClass.getMethod(methodName, parameterTypes);
return true;
} catch (NoSuchMethodException e) {
return false;
}
}
|
[
"public",
"static",
"boolean",
"hasMethod",
"(",
"Class",
"<",
"?",
">",
"targetClass",
",",
"String",
"methodName",
",",
"Class",
"...",
"parameterTypes",
")",
"{",
"try",
"{",
"targetClass",
".",
"getMethod",
"(",
"methodName",
",",
"parameterTypes",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Check if target class has the given method
@param targetClass target class
@param methodName method name
@param parameterTypes method parameter types
@return method availability
|
[
"Check",
"if",
"target",
"class",
"has",
"the",
"given",
"method"
] |
train
|
https://github.com/vladmihalcea/flexy-pool/blob/d763d359e68299c2b4e28e4b67770581ae083431/flexy-pool-core/src/main/java/com/vladmihalcea/flexypool/util/ReflectionUtils.java#L92-L99
|
apache/incubator-druid
|
core/src/main/java/org/apache/druid/java/util/common/FileUtils.java
|
FileUtils.writeAtomically
|
public static <T> T writeAtomically(final File file, OutputStreamConsumer<T> f) throws IOException {
"""
Write to a file atomically, by first writing to a temporary file in the same directory and then moving it to
the target location. This function attempts to clean up its temporary files when possible, but they may stick
around (for example, if the JVM crashes partway through executing the function). In any case, the target file
should be unharmed.
The OutputStream passed to the consumer is uncloseable; calling close on it will do nothing. This is to ensure
that the stream stays open so we can fsync it here before closing. Hopefully, this doesn't cause any problems
for callers.
This method is not just thread-safe, but is also safe to use from multiple processes on the same machine.
"""
return writeAtomically(file, file.getParentFile(), f);
}
|
java
|
public static <T> T writeAtomically(final File file, OutputStreamConsumer<T> f) throws IOException
{
return writeAtomically(file, file.getParentFile(), f);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"writeAtomically",
"(",
"final",
"File",
"file",
",",
"OutputStreamConsumer",
"<",
"T",
">",
"f",
")",
"throws",
"IOException",
"{",
"return",
"writeAtomically",
"(",
"file",
",",
"file",
".",
"getParentFile",
"(",
")",
",",
"f",
")",
";",
"}"
] |
Write to a file atomically, by first writing to a temporary file in the same directory and then moving it to
the target location. This function attempts to clean up its temporary files when possible, but they may stick
around (for example, if the JVM crashes partway through executing the function). In any case, the target file
should be unharmed.
The OutputStream passed to the consumer is uncloseable; calling close on it will do nothing. This is to ensure
that the stream stays open so we can fsync it here before closing. Hopefully, this doesn't cause any problems
for callers.
This method is not just thread-safe, but is also safe to use from multiple processes on the same machine.
|
[
"Write",
"to",
"a",
"file",
"atomically",
"by",
"first",
"writing",
"to",
"a",
"temporary",
"file",
"in",
"the",
"same",
"directory",
"and",
"then",
"moving",
"it",
"to",
"the",
"target",
"location",
".",
"This",
"function",
"attempts",
"to",
"clean",
"up",
"its",
"temporary",
"files",
"when",
"possible",
"but",
"they",
"may",
"stick",
"around",
"(",
"for",
"example",
"if",
"the",
"JVM",
"crashes",
"partway",
"through",
"executing",
"the",
"function",
")",
".",
"In",
"any",
"case",
"the",
"target",
"file",
"should",
"be",
"unharmed",
"."
] |
train
|
https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/core/src/main/java/org/apache/druid/java/util/common/FileUtils.java#L189-L192
|
sshtools/j2ssh-maverick
|
j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshKeyPair.java
|
SshKeyPair.getKeyPair
|
public static SshKeyPair getKeyPair(SshPrivateKey prv, SshPublicKey pub) {
"""
Wraps a public/private key pair into an SshKeyPair instance.
@param prv
@param pub
@return SshKeyPair
"""
SshKeyPair pair = new SshKeyPair();
pair.publickey = pub;
pair.privatekey = prv;
return pair;
}
|
java
|
public static SshKeyPair getKeyPair(SshPrivateKey prv, SshPublicKey pub) {
SshKeyPair pair = new SshKeyPair();
pair.publickey = pub;
pair.privatekey = prv;
return pair;
}
|
[
"public",
"static",
"SshKeyPair",
"getKeyPair",
"(",
"SshPrivateKey",
"prv",
",",
"SshPublicKey",
"pub",
")",
"{",
"SshKeyPair",
"pair",
"=",
"new",
"SshKeyPair",
"(",
")",
";",
"pair",
".",
"publickey",
"=",
"pub",
";",
"pair",
".",
"privatekey",
"=",
"prv",
";",
"return",
"pair",
";",
"}"
] |
Wraps a public/private key pair into an SshKeyPair instance.
@param prv
@param pub
@return SshKeyPair
|
[
"Wraps",
"a",
"public",
"/",
"private",
"key",
"pair",
"into",
"an",
"SshKeyPair",
"instance",
"."
] |
train
|
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/ssh/components/SshKeyPair.java#L57-L62
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.