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
|
---|---|---|---|---|---|---|---|---|---|---|
alkacon/opencms-core | src/org/opencms/ui/dialogs/permissions/CmsPermissionView.java | CmsPermissionView.getCheckBoxLabel | private Label getCheckBoxLabel(Boolean value) {
"""
Generates a check box label.<p>
@param value the value to display
@return the label
"""
String content;
if (value.booleanValue()) {
content = "<input type='checkbox' disabled='true' checked='true' />";
} else {
content = "<input type='checkbox' disabled='true' />";
}
return new Label(content, ContentMode.HTML);
} | java | private Label getCheckBoxLabel(Boolean value) {
String content;
if (value.booleanValue()) {
content = "<input type='checkbox' disabled='true' checked='true' />";
} else {
content = "<input type='checkbox' disabled='true' />";
}
return new Label(content, ContentMode.HTML);
} | [
"private",
"Label",
"getCheckBoxLabel",
"(",
"Boolean",
"value",
")",
"{",
"String",
"content",
";",
"if",
"(",
"value",
".",
"booleanValue",
"(",
")",
")",
"{",
"content",
"=",
"\"<input type='checkbox' disabled='true' checked='true' />\"",
";",
"}",
"else",
"{",
"content",
"=",
"\"<input type='checkbox' disabled='true' />\"",
";",
"}",
"return",
"new",
"Label",
"(",
"content",
",",
"ContentMode",
".",
"HTML",
")",
";",
"}"
]
| Generates a check box label.<p>
@param value the value to display
@return the label | [
"Generates",
"a",
"check",
"box",
"label",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/dialogs/permissions/CmsPermissionView.java#L553-L563 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/cluster/clusternodegroup_binding.java | clusternodegroup_binding.get | public static clusternodegroup_binding get(nitro_service service, String name) throws Exception {
"""
Use this API to fetch clusternodegroup_binding resource of given name .
"""
clusternodegroup_binding obj = new clusternodegroup_binding();
obj.set_name(name);
clusternodegroup_binding response = (clusternodegroup_binding) obj.get_resource(service);
return response;
} | java | public static clusternodegroup_binding get(nitro_service service, String name) throws Exception{
clusternodegroup_binding obj = new clusternodegroup_binding();
obj.set_name(name);
clusternodegroup_binding response = (clusternodegroup_binding) obj.get_resource(service);
return response;
} | [
"public",
"static",
"clusternodegroup_binding",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"clusternodegroup_binding",
"obj",
"=",
"new",
"clusternodegroup_binding",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";",
"clusternodegroup_binding",
"response",
"=",
"(",
"clusternodegroup_binding",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
]
| Use this API to fetch clusternodegroup_binding resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"clusternodegroup_binding",
"resource",
"of",
"given",
"name",
"."
]
| train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/cluster/clusternodegroup_binding.java#L169-L174 |
netty/netty | codec/src/main/java/io/netty/handler/codec/compression/Snappy.java | Snappy.encodeCopy | private static void encodeCopy(ByteBuf out, int offset, int length) {
"""
Encodes a series of copies, each at most 64 bytes in length.
@param out The output buffer to write the copy pointer to
@param offset The offset at which the original instance lies
@param length The length of the original instance
"""
while (length >= 68) {
encodeCopyWithOffset(out, offset, 64);
length -= 64;
}
if (length > 64) {
encodeCopyWithOffset(out, offset, 60);
length -= 60;
}
encodeCopyWithOffset(out, offset, length);
} | java | private static void encodeCopy(ByteBuf out, int offset, int length) {
while (length >= 68) {
encodeCopyWithOffset(out, offset, 64);
length -= 64;
}
if (length > 64) {
encodeCopyWithOffset(out, offset, 60);
length -= 60;
}
encodeCopyWithOffset(out, offset, length);
} | [
"private",
"static",
"void",
"encodeCopy",
"(",
"ByteBuf",
"out",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"while",
"(",
"length",
">=",
"68",
")",
"{",
"encodeCopyWithOffset",
"(",
"out",
",",
"offset",
",",
"64",
")",
";",
"length",
"-=",
"64",
";",
"}",
"if",
"(",
"length",
">",
"64",
")",
"{",
"encodeCopyWithOffset",
"(",
"out",
",",
"offset",
",",
"60",
")",
";",
"length",
"-=",
"60",
";",
"}",
"encodeCopyWithOffset",
"(",
"out",
",",
"offset",
",",
"length",
")",
";",
"}"
]
| Encodes a series of copies, each at most 64 bytes in length.
@param out The output buffer to write the copy pointer to
@param offset The offset at which the original instance lies
@param length The length of the original instance | [
"Encodes",
"a",
"series",
"of",
"copies",
"each",
"at",
"most",
"64",
"bytes",
"in",
"length",
"."
]
| train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/compression/Snappy.java#L256-L268 |
unbescape/unbescape | src/main/java/org/unbescape/uri/UriEscape.java | UriEscape.unescapeUriPath | public static String unescapeUriPath(final String text, final String encoding) {
"""
<p>
Perform am URI path <strong>unescape</strong> operation
on a <tt>String</tt> input.
</p>
<p>
This method will unescape every percent-encoded (<tt>%HH</tt>) sequences present in input,
even for those characters that do not need to be percent-encoded in this context (unreserved characters
can be percent-encoded even if/when this is not required, though it is not generally considered a
good practice).
</p>
<p>
This method will use the specified <tt>encoding</tt> in order to determine the characters specified in the
percent-encoded byte sequences.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>String</tt> to be unescaped.
@param encoding the encoding to be used for unescaping.
@return The unescaped result <tt>String</tt>. As a memory-performance improvement, will return the exact
same object as the <tt>text</tt> input argument if no unescaping modifications were required (and
no additional <tt>String</tt> objects will be created during processing). Will
return <tt>null</tt> if input is <tt>null</tt>.
"""
if (encoding == null) {
throw new IllegalArgumentException("Argument 'encoding' cannot be null");
}
return UriEscapeUtil.unescape(text, UriEscapeUtil.UriEscapeType.PATH, encoding);
} | java | public static String unescapeUriPath(final String text, final String encoding) {
if (encoding == null) {
throw new IllegalArgumentException("Argument 'encoding' cannot be null");
}
return UriEscapeUtil.unescape(text, UriEscapeUtil.UriEscapeType.PATH, encoding);
} | [
"public",
"static",
"String",
"unescapeUriPath",
"(",
"final",
"String",
"text",
",",
"final",
"String",
"encoding",
")",
"{",
"if",
"(",
"encoding",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument 'encoding' cannot be null\"",
")",
";",
"}",
"return",
"UriEscapeUtil",
".",
"unescape",
"(",
"text",
",",
"UriEscapeUtil",
".",
"UriEscapeType",
".",
"PATH",
",",
"encoding",
")",
";",
"}"
]
| <p>
Perform am URI path <strong>unescape</strong> operation
on a <tt>String</tt> input.
</p>
<p>
This method will unescape every percent-encoded (<tt>%HH</tt>) sequences present in input,
even for those characters that do not need to be percent-encoded in this context (unreserved characters
can be percent-encoded even if/when this is not required, though it is not generally considered a
good practice).
</p>
<p>
This method will use the specified <tt>encoding</tt> in order to determine the characters specified in the
percent-encoded byte sequences.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>String</tt> to be unescaped.
@param encoding the encoding to be used for unescaping.
@return The unescaped result <tt>String</tt>. As a memory-performance improvement, will return the exact
same object as the <tt>text</tt> input argument if no unescaping modifications were required (and
no additional <tt>String</tt> objects will be created during processing). Will
return <tt>null</tt> if input is <tt>null</tt>. | [
"<p",
">",
"Perform",
"am",
"URI",
"path",
"<strong",
">",
"unescape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"String<",
"/",
"tt",
">",
"input",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"will",
"unescape",
"every",
"percent",
"-",
"encoded",
"(",
"<tt",
">",
"%HH<",
"/",
"tt",
">",
")",
"sequences",
"present",
"in",
"input",
"even",
"for",
"those",
"characters",
"that",
"do",
"not",
"need",
"to",
"be",
"percent",
"-",
"encoded",
"in",
"this",
"context",
"(",
"unreserved",
"characters",
"can",
"be",
"percent",
"-",
"encoded",
"even",
"if",
"/",
"when",
"this",
"is",
"not",
"required",
"though",
"it",
"is",
"not",
"generally",
"considered",
"a",
"good",
"practice",
")",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"will",
"use",
"the",
"specified",
"<tt",
">",
"encoding<",
"/",
"tt",
">",
"in",
"order",
"to",
"determine",
"the",
"characters",
"specified",
"in",
"the",
"percent",
"-",
"encoded",
"byte",
"sequences",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/uri/UriEscape.java#L1568-L1573 |
Alluxio/alluxio | underfs/s3a/src/main/java/alluxio/underfs/s3a/S3AInputStream.java | S3AInputStream.openStream | private void openStream() throws IOException {
"""
Opens a new stream at mPos if the wrapped stream mIn is null.
"""
if (mIn != null) { // stream is already open
return;
}
GetObjectRequest getReq = new GetObjectRequest(mBucketName, mKey);
// If the position is 0, setting range is redundant and causes an error if the file is 0 length
if (mPos > 0) {
getReq.setRange(mPos);
}
AmazonS3Exception lastException = null;
while (mRetryPolicy.attempt()) {
try {
mIn = mClient.getObject(getReq).getObjectContent();
return;
} catch (AmazonS3Exception e) {
LOG.warn("Attempt {} to open key {} in bucket {} failed with exception : {}",
mRetryPolicy.getAttemptCount(), mKey, mBucketName, e.toString());
if (e.getStatusCode() != HttpStatus.SC_NOT_FOUND) {
throw new IOException(e);
}
// Key does not exist
lastException = e;
}
}
// Failed after retrying key does not exist
throw new IOException(lastException);
} | java | private void openStream() throws IOException {
if (mIn != null) { // stream is already open
return;
}
GetObjectRequest getReq = new GetObjectRequest(mBucketName, mKey);
// If the position is 0, setting range is redundant and causes an error if the file is 0 length
if (mPos > 0) {
getReq.setRange(mPos);
}
AmazonS3Exception lastException = null;
while (mRetryPolicy.attempt()) {
try {
mIn = mClient.getObject(getReq).getObjectContent();
return;
} catch (AmazonS3Exception e) {
LOG.warn("Attempt {} to open key {} in bucket {} failed with exception : {}",
mRetryPolicy.getAttemptCount(), mKey, mBucketName, e.toString());
if (e.getStatusCode() != HttpStatus.SC_NOT_FOUND) {
throw new IOException(e);
}
// Key does not exist
lastException = e;
}
}
// Failed after retrying key does not exist
throw new IOException(lastException);
} | [
"private",
"void",
"openStream",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mIn",
"!=",
"null",
")",
"{",
"// stream is already open",
"return",
";",
"}",
"GetObjectRequest",
"getReq",
"=",
"new",
"GetObjectRequest",
"(",
"mBucketName",
",",
"mKey",
")",
";",
"// If the position is 0, setting range is redundant and causes an error if the file is 0 length",
"if",
"(",
"mPos",
">",
"0",
")",
"{",
"getReq",
".",
"setRange",
"(",
"mPos",
")",
";",
"}",
"AmazonS3Exception",
"lastException",
"=",
"null",
";",
"while",
"(",
"mRetryPolicy",
".",
"attempt",
"(",
")",
")",
"{",
"try",
"{",
"mIn",
"=",
"mClient",
".",
"getObject",
"(",
"getReq",
")",
".",
"getObjectContent",
"(",
")",
";",
"return",
";",
"}",
"catch",
"(",
"AmazonS3Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Attempt {} to open key {} in bucket {} failed with exception : {}\"",
",",
"mRetryPolicy",
".",
"getAttemptCount",
"(",
")",
",",
"mKey",
",",
"mBucketName",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"e",
".",
"getStatusCode",
"(",
")",
"!=",
"HttpStatus",
".",
"SC_NOT_FOUND",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"// Key does not exist",
"lastException",
"=",
"e",
";",
"}",
"}",
"// Failed after retrying key does not exist",
"throw",
"new",
"IOException",
"(",
"lastException",
")",
";",
"}"
]
| Opens a new stream at mPos if the wrapped stream mIn is null. | [
"Opens",
"a",
"new",
"stream",
"at",
"mPos",
"if",
"the",
"wrapped",
"stream",
"mIn",
"is",
"null",
"."
]
| train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3AInputStream.java#L136-L162 |
EdwardRaff/JSAT | JSAT/src/jsat/linear/vectorcollection/lsh/RandomProjectionLSH.java | RandomProjectionLSH.projectVector | private void projectVector(Vec vec, int slot, int[] projLocation, Vec projected) {
"""
Projects a given vector into the array of integers.
@param vecs the vector to project
@param slot the index into the array to start placing the bit values
@param projected a vector full of zeros of the same length as
{@link #getSignatureBitLength() } to use as a temp space.
"""
randProjMatrix.multiply(vec, 1.0, projected);
int pos = 0;
int bitsLeft = Integer.SIZE;
int curVal = 0;
while(pos < slotsPerEntry)
{
while(bitsLeft > 0)
{
curVal <<= 1;
if(projected.get(pos*Integer.SIZE+(Integer.SIZE-bitsLeft)) >= 0)
curVal |= 1;
bitsLeft--;
}
projLocation[slot+pos] = curVal;
curVal = 0;
bitsLeft = Integer.SIZE;
pos++;
}
} | java | private void projectVector(Vec vec, int slot, int[] projLocation, Vec projected)
{
randProjMatrix.multiply(vec, 1.0, projected);
int pos = 0;
int bitsLeft = Integer.SIZE;
int curVal = 0;
while(pos < slotsPerEntry)
{
while(bitsLeft > 0)
{
curVal <<= 1;
if(projected.get(pos*Integer.SIZE+(Integer.SIZE-bitsLeft)) >= 0)
curVal |= 1;
bitsLeft--;
}
projLocation[slot+pos] = curVal;
curVal = 0;
bitsLeft = Integer.SIZE;
pos++;
}
} | [
"private",
"void",
"projectVector",
"(",
"Vec",
"vec",
",",
"int",
"slot",
",",
"int",
"[",
"]",
"projLocation",
",",
"Vec",
"projected",
")",
"{",
"randProjMatrix",
".",
"multiply",
"(",
"vec",
",",
"1.0",
",",
"projected",
")",
";",
"int",
"pos",
"=",
"0",
";",
"int",
"bitsLeft",
"=",
"Integer",
".",
"SIZE",
";",
"int",
"curVal",
"=",
"0",
";",
"while",
"(",
"pos",
"<",
"slotsPerEntry",
")",
"{",
"while",
"(",
"bitsLeft",
">",
"0",
")",
"{",
"curVal",
"<<=",
"1",
";",
"if",
"(",
"projected",
".",
"get",
"(",
"pos",
"*",
"Integer",
".",
"SIZE",
"+",
"(",
"Integer",
".",
"SIZE",
"-",
"bitsLeft",
")",
")",
">=",
"0",
")",
"curVal",
"|=",
"1",
";",
"bitsLeft",
"--",
";",
"}",
"projLocation",
"[",
"slot",
"+",
"pos",
"]",
"=",
"curVal",
";",
"curVal",
"=",
"0",
";",
"bitsLeft",
"=",
"Integer",
".",
"SIZE",
";",
"pos",
"++",
";",
"}",
"}"
]
| Projects a given vector into the array of integers.
@param vecs the vector to project
@param slot the index into the array to start placing the bit values
@param projected a vector full of zeros of the same length as
{@link #getSignatureBitLength() } to use as a temp space. | [
"Projects",
"a",
"given",
"vector",
"into",
"the",
"array",
"of",
"integers",
"."
]
| train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/linear/vectorcollection/lsh/RandomProjectionLSH.java#L223-L244 |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java | BusItinerary.putHaltOnRoad | @SuppressWarnings("checkstyle:nestedifdepth")
public boolean putHaltOnRoad(BusItineraryHalt halt, RoadSegment road) {
"""
Put the given bus itinerary halt on the nearest
point on road.
@param halt is the halt to put on the road.
@param road is the road.
@return <code>false</code> if the road was not found;
otherwise <code>true</code>. If the bus halt is not binded
to a valid bus stop, replies <code>true</code> also.
"""
if (contains(halt)) {
final BusStop stop = halt.getBusStop();
if (stop != null) {
final Point2d stopPosition = stop.getPosition2D();
if (stopPosition != null) {
final int idx = indexOf(road);
if (idx >= 0) {
final Point1d pos = road.getNearestPosition(stopPosition);
if (pos != null) {
halt.setRoadSegmentIndex(idx);
halt.setPositionOnSegment(pos.getCurvilineCoordinate());
halt.checkPrimitiveValidity();
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_CHANGED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
return true;
}
}
return false;
}
}
}
return true;
} | java | @SuppressWarnings("checkstyle:nestedifdepth")
public boolean putHaltOnRoad(BusItineraryHalt halt, RoadSegment road) {
if (contains(halt)) {
final BusStop stop = halt.getBusStop();
if (stop != null) {
final Point2d stopPosition = stop.getPosition2D();
if (stopPosition != null) {
final int idx = indexOf(road);
if (idx >= 0) {
final Point1d pos = road.getNearestPosition(stopPosition);
if (pos != null) {
halt.setRoadSegmentIndex(idx);
halt.setPositionOnSegment(pos.getCurvilineCoordinate());
halt.checkPrimitiveValidity();
fireShapeChanged(new BusChangeEvent(this,
BusChangeEventType.ITINERARY_CHANGED,
null,
-1,
"shape", //$NON-NLS-1$
null,
null));
checkPrimitiveValidity();
return true;
}
}
return false;
}
}
}
return true;
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:nestedifdepth\"",
")",
"public",
"boolean",
"putHaltOnRoad",
"(",
"BusItineraryHalt",
"halt",
",",
"RoadSegment",
"road",
")",
"{",
"if",
"(",
"contains",
"(",
"halt",
")",
")",
"{",
"final",
"BusStop",
"stop",
"=",
"halt",
".",
"getBusStop",
"(",
")",
";",
"if",
"(",
"stop",
"!=",
"null",
")",
"{",
"final",
"Point2d",
"stopPosition",
"=",
"stop",
".",
"getPosition2D",
"(",
")",
";",
"if",
"(",
"stopPosition",
"!=",
"null",
")",
"{",
"final",
"int",
"idx",
"=",
"indexOf",
"(",
"road",
")",
";",
"if",
"(",
"idx",
">=",
"0",
")",
"{",
"final",
"Point1d",
"pos",
"=",
"road",
".",
"getNearestPosition",
"(",
"stopPosition",
")",
";",
"if",
"(",
"pos",
"!=",
"null",
")",
"{",
"halt",
".",
"setRoadSegmentIndex",
"(",
"idx",
")",
";",
"halt",
".",
"setPositionOnSegment",
"(",
"pos",
".",
"getCurvilineCoordinate",
"(",
")",
")",
";",
"halt",
".",
"checkPrimitiveValidity",
"(",
")",
";",
"fireShapeChanged",
"(",
"new",
"BusChangeEvent",
"(",
"this",
",",
"BusChangeEventType",
".",
"ITINERARY_CHANGED",
",",
"null",
",",
"-",
"1",
",",
"\"shape\"",
",",
"//$NON-NLS-1$",
"null",
",",
"null",
")",
")",
";",
"checkPrimitiveValidity",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
]
| Put the given bus itinerary halt on the nearest
point on road.
@param halt is the halt to put on the road.
@param road is the road.
@return <code>false</code> if the road was not found;
otherwise <code>true</code>. If the bus halt is not binded
to a valid bus stop, replies <code>true</code> also. | [
"Put",
"the",
"given",
"bus",
"itinerary",
"halt",
"on",
"the",
"nearest",
"point",
"on",
"road",
"."
]
| train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusItinerary.java#L2068-L2098 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/ValidationUtils.java | ValidationUtils.validate6NonNegative | public static int[] validate6NonNegative(int[] data, String paramName) {
"""
Reformats the input array to a length 6 array and checks that all values >= 0.
If the array is length 1, returns [a, a, a, a, a, a]
If the array is length 3, return [a, a, b, b, c, c]
If the array is length 6, returns the array.
@param data An array
@param paramName The param name, for error reporting
@return An int array of length 6 that represents the input
"""
validateNonNegative(data, paramName);
return validate6(data, paramName);
} | java | public static int[] validate6NonNegative(int[] data, String paramName){
validateNonNegative(data, paramName);
return validate6(data, paramName);
} | [
"public",
"static",
"int",
"[",
"]",
"validate6NonNegative",
"(",
"int",
"[",
"]",
"data",
",",
"String",
"paramName",
")",
"{",
"validateNonNegative",
"(",
"data",
",",
"paramName",
")",
";",
"return",
"validate6",
"(",
"data",
",",
"paramName",
")",
";",
"}"
]
| Reformats the input array to a length 6 array and checks that all values >= 0.
If the array is length 1, returns [a, a, a, a, a, a]
If the array is length 3, return [a, a, b, b, c, c]
If the array is length 6, returns the array.
@param data An array
@param paramName The param name, for error reporting
@return An int array of length 6 that represents the input | [
"Reformats",
"the",
"input",
"array",
"to",
"a",
"length",
"6",
"array",
"and",
"checks",
"that",
"all",
"values",
">",
"=",
"0",
"."
]
| train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/ValidationUtils.java#L317-L320 |
google/error-prone-javac | src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsFilter.java | JdepsFilter.isJDKInternalPackage | public boolean isJDKInternalPackage(Module module, String pn) {
"""
Tests if the package is an internal package of the given module.
"""
if (module.isJDKUnsupported()) {
// its exported APIs are unsupported
return true;
}
return module.isJDK() && !module.isExported(pn);
} | java | public boolean isJDKInternalPackage(Module module, String pn) {
if (module.isJDKUnsupported()) {
// its exported APIs are unsupported
return true;
}
return module.isJDK() && !module.isExported(pn);
} | [
"public",
"boolean",
"isJDKInternalPackage",
"(",
"Module",
"module",
",",
"String",
"pn",
")",
"{",
"if",
"(",
"module",
".",
"isJDKUnsupported",
"(",
")",
")",
"{",
"// its exported APIs are unsupported",
"return",
"true",
";",
"}",
"return",
"module",
".",
"isJDK",
"(",
")",
"&&",
"!",
"module",
".",
"isExported",
"(",
"pn",
")",
";",
"}"
]
| Tests if the package is an internal package of the given module. | [
"Tests",
"if",
"the",
"package",
"is",
"an",
"internal",
"package",
"of",
"the",
"given",
"module",
"."
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsFilter.java#L166-L173 |
alkacon/opencms-core | src/org/opencms/staticexport/CmsDefaultLinkSubstitutionHandler.java | CmsDefaultLinkSubstitutionHandler.getDetailRootPath | private String getDetailRootPath(CmsObject cms, String result) {
"""
Tries to interpret the given URI as a detail page URI and returns the detail content's root path if possible.<p>
If the given URI is not a detail URI, null will be returned.<p>
@param cms the CMS context to use
@param result the detail root path, or null if the given uri is not a detail page URI
@return the detail content root path
"""
if (result == null) {
return null;
}
try {
URI uri = new URI(result);
String path = uri.getPath();
if (CmsStringUtil.isEmptyOrWhitespaceOnly(path) || !OpenCms.getADEManager().isInitialized()) {
return null;
}
String name = CmsFileUtil.removeTrailingSeparator(CmsResource.getName(path));
CmsUUID detailId = OpenCms.getADEManager().getDetailIdCache(
cms.getRequestContext().getCurrentProject().isOnlineProject()).getDetailId(name);
if (detailId == null) {
return null;
}
String origSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot("");
// real root paths have priority over detail contents
if (cms.existsResource(path)) {
return null;
}
} finally {
cms.getRequestContext().setSiteRoot(origSiteRoot);
}
CmsResource detailResource = cms.readResource(detailId, CmsResourceFilter.ALL);
return detailResource.getRootPath() + getSuffix(uri);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return null;
}
} | java | private String getDetailRootPath(CmsObject cms, String result) {
if (result == null) {
return null;
}
try {
URI uri = new URI(result);
String path = uri.getPath();
if (CmsStringUtil.isEmptyOrWhitespaceOnly(path) || !OpenCms.getADEManager().isInitialized()) {
return null;
}
String name = CmsFileUtil.removeTrailingSeparator(CmsResource.getName(path));
CmsUUID detailId = OpenCms.getADEManager().getDetailIdCache(
cms.getRequestContext().getCurrentProject().isOnlineProject()).getDetailId(name);
if (detailId == null) {
return null;
}
String origSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot("");
// real root paths have priority over detail contents
if (cms.existsResource(path)) {
return null;
}
} finally {
cms.getRequestContext().setSiteRoot(origSiteRoot);
}
CmsResource detailResource = cms.readResource(detailId, CmsResourceFilter.ALL);
return detailResource.getRootPath() + getSuffix(uri);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return null;
}
} | [
"private",
"String",
"getDetailRootPath",
"(",
"CmsObject",
"cms",
",",
"String",
"result",
")",
"{",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"URI",
"uri",
"=",
"new",
"URI",
"(",
"result",
")",
";",
"String",
"path",
"=",
"uri",
".",
"getPath",
"(",
")",
";",
"if",
"(",
"CmsStringUtil",
".",
"isEmptyOrWhitespaceOnly",
"(",
"path",
")",
"||",
"!",
"OpenCms",
".",
"getADEManager",
"(",
")",
".",
"isInitialized",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"String",
"name",
"=",
"CmsFileUtil",
".",
"removeTrailingSeparator",
"(",
"CmsResource",
".",
"getName",
"(",
"path",
")",
")",
";",
"CmsUUID",
"detailId",
"=",
"OpenCms",
".",
"getADEManager",
"(",
")",
".",
"getDetailIdCache",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentProject",
"(",
")",
".",
"isOnlineProject",
"(",
")",
")",
".",
"getDetailId",
"(",
"name",
")",
";",
"if",
"(",
"detailId",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"origSiteRoot",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getSiteRoot",
"(",
")",
";",
"try",
"{",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"\"\"",
")",
";",
"// real root paths have priority over detail contents",
"if",
"(",
"cms",
".",
"existsResource",
"(",
"path",
")",
")",
"{",
"return",
"null",
";",
"}",
"}",
"finally",
"{",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"origSiteRoot",
")",
";",
"}",
"CmsResource",
"detailResource",
"=",
"cms",
".",
"readResource",
"(",
"detailId",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"return",
"detailResource",
".",
"getRootPath",
"(",
")",
"+",
"getSuffix",
"(",
"uri",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
]
| Tries to interpret the given URI as a detail page URI and returns the detail content's root path if possible.<p>
If the given URI is not a detail URI, null will be returned.<p>
@param cms the CMS context to use
@param result the detail root path, or null if the given uri is not a detail page URI
@return the detail content root path | [
"Tries",
"to",
"interpret",
"the",
"given",
"URI",
"as",
"a",
"detail",
"page",
"URI",
"and",
"returns",
"the",
"detail",
"content",
"s",
"root",
"path",
"if",
"possible",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/staticexport/CmsDefaultLinkSubstitutionHandler.java#L746-L779 |
TNG/JGiven | jgiven-core/src/main/java/com/tngtech/jgiven/config/AbstractJGivenConfiguration.java | AbstractJGivenConfiguration.setFormatter | public <T> void setFormatter( Class<T> typeToBeFormatted, Formatter<T> formatter ) {
"""
Sets the formatter for the given type.
<p>
When choosing a formatter, JGiven will take the formatter defined for the most specific
super type of a given type.
<p>
If no formatter can be found for a type, the {@link com.tngtech.jgiven.format.DefaultFormatter} is taken.
<p>
For example,
given the following formatter are defined:
<pre>
setFormatter( Object.class, formatterA );
setFormatter( String.class, formatterB );
</pre>
When formatting a String,<br>
Then {@code formatterB} will be taken.
<p>
If formatter for multiple super types of a type are defined, but these types have no subtype relation, then an arbitrary
formatter is taken in a non-deterministic way. Thus you should avoid this situation.
<p>
For example,
given the following formatter are defined:
<pre>
setFormatter( Cloneable.class, formatterA );
setFormatter( Serializable.class, formatterB );
</pre>
When formatting a String,<br>
Then either {@code formatterA} or {@code formatterB} will be taken non-deterministically.
<p>
The order in which the formatter are defined, does not make a difference.
<p>
Note that the formatter can still be overridden by using a formatting annotation.
@param typeToBeFormatted the type for which the formatter should be defined
@param formatter the formatter to format instances of that type
"""
formatterCache.setFormatter( typeToBeFormatted, formatter );
} | java | public <T> void setFormatter( Class<T> typeToBeFormatted, Formatter<T> formatter ) {
formatterCache.setFormatter( typeToBeFormatted, formatter );
} | [
"public",
"<",
"T",
">",
"void",
"setFormatter",
"(",
"Class",
"<",
"T",
">",
"typeToBeFormatted",
",",
"Formatter",
"<",
"T",
">",
"formatter",
")",
"{",
"formatterCache",
".",
"setFormatter",
"(",
"typeToBeFormatted",
",",
"formatter",
")",
";",
"}"
]
| Sets the formatter for the given type.
<p>
When choosing a formatter, JGiven will take the formatter defined for the most specific
super type of a given type.
<p>
If no formatter can be found for a type, the {@link com.tngtech.jgiven.format.DefaultFormatter} is taken.
<p>
For example,
given the following formatter are defined:
<pre>
setFormatter( Object.class, formatterA );
setFormatter( String.class, formatterB );
</pre>
When formatting a String,<br>
Then {@code formatterB} will be taken.
<p>
If formatter for multiple super types of a type are defined, but these types have no subtype relation, then an arbitrary
formatter is taken in a non-deterministic way. Thus you should avoid this situation.
<p>
For example,
given the following formatter are defined:
<pre>
setFormatter( Cloneable.class, formatterA );
setFormatter( Serializable.class, formatterB );
</pre>
When formatting a String,<br>
Then either {@code formatterA} or {@code formatterB} will be taken non-deterministically.
<p>
The order in which the formatter are defined, does not make a difference.
<p>
Note that the formatter can still be overridden by using a formatting annotation.
@param typeToBeFormatted the type for which the formatter should be defined
@param formatter the formatter to format instances of that type | [
"Sets",
"the",
"formatter",
"for",
"the",
"given",
"type",
".",
"<p",
">",
"When",
"choosing",
"a",
"formatter",
"JGiven",
"will",
"take",
"the",
"formatter",
"defined",
"for",
"the",
"most",
"specific",
"super",
"type",
"of",
"a",
"given",
"type",
".",
"<p",
">",
"If",
"no",
"formatter",
"can",
"be",
"found",
"for",
"a",
"type",
"the",
"{",
"@link",
"com",
".",
"tngtech",
".",
"jgiven",
".",
"format",
".",
"DefaultFormatter",
"}",
"is",
"taken",
".",
"<p",
">",
"For",
"example",
"given",
"the",
"following",
"formatter",
"are",
"defined",
":"
]
| train | https://github.com/TNG/JGiven/blob/1a69248fc6d7eb380cdc4542e3be273842889748/jgiven-core/src/main/java/com/tngtech/jgiven/config/AbstractJGivenConfiguration.java#L76-L78 |
phax/ph-datetime | ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManagerJapan.java | XMLHolidayManagerJapan.getHolidays | @Override
public HolidayMap getHolidays (final int nYear, @Nullable final String... aArgs) {
"""
Implements the rule which requests if two holidays have one non holiday
between each other than this day is also a holiday.
"""
final HolidayMap aHolidays = super.getHolidays (nYear, aArgs);
final HolidayMap aAdditionalHolidays = new HolidayMap ();
for (final Map.Entry <LocalDate, ISingleHoliday> aEntry : aHolidays.getMap ().entrySet ())
{
final LocalDate aTwoDaysLater = aEntry.getKey ().plusDays (2);
if (aHolidays.containsHolidayForDate (aTwoDaysLater))
{
final LocalDate aBridgingDate = aTwoDaysLater.minusDays (1);
aAdditionalHolidays.add (aBridgingDate,
new ResourceBundleHoliday (EHolidayType.OFFICIAL_HOLIDAY,
BRIDGING_HOLIDAY_PROPERTIES_KEY));
}
}
aHolidays.addAll (aAdditionalHolidays);
return aHolidays;
} | java | @Override
public HolidayMap getHolidays (final int nYear, @Nullable final String... aArgs)
{
final HolidayMap aHolidays = super.getHolidays (nYear, aArgs);
final HolidayMap aAdditionalHolidays = new HolidayMap ();
for (final Map.Entry <LocalDate, ISingleHoliday> aEntry : aHolidays.getMap ().entrySet ())
{
final LocalDate aTwoDaysLater = aEntry.getKey ().plusDays (2);
if (aHolidays.containsHolidayForDate (aTwoDaysLater))
{
final LocalDate aBridgingDate = aTwoDaysLater.minusDays (1);
aAdditionalHolidays.add (aBridgingDate,
new ResourceBundleHoliday (EHolidayType.OFFICIAL_HOLIDAY,
BRIDGING_HOLIDAY_PROPERTIES_KEY));
}
}
aHolidays.addAll (aAdditionalHolidays);
return aHolidays;
} | [
"@",
"Override",
"public",
"HolidayMap",
"getHolidays",
"(",
"final",
"int",
"nYear",
",",
"@",
"Nullable",
"final",
"String",
"...",
"aArgs",
")",
"{",
"final",
"HolidayMap",
"aHolidays",
"=",
"super",
".",
"getHolidays",
"(",
"nYear",
",",
"aArgs",
")",
";",
"final",
"HolidayMap",
"aAdditionalHolidays",
"=",
"new",
"HolidayMap",
"(",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"LocalDate",
",",
"ISingleHoliday",
">",
"aEntry",
":",
"aHolidays",
".",
"getMap",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"LocalDate",
"aTwoDaysLater",
"=",
"aEntry",
".",
"getKey",
"(",
")",
".",
"plusDays",
"(",
"2",
")",
";",
"if",
"(",
"aHolidays",
".",
"containsHolidayForDate",
"(",
"aTwoDaysLater",
")",
")",
"{",
"final",
"LocalDate",
"aBridgingDate",
"=",
"aTwoDaysLater",
".",
"minusDays",
"(",
"1",
")",
";",
"aAdditionalHolidays",
".",
"add",
"(",
"aBridgingDate",
",",
"new",
"ResourceBundleHoliday",
"(",
"EHolidayType",
".",
"OFFICIAL_HOLIDAY",
",",
"BRIDGING_HOLIDAY_PROPERTIES_KEY",
")",
")",
";",
"}",
"}",
"aHolidays",
".",
"addAll",
"(",
"aAdditionalHolidays",
")",
";",
"return",
"aHolidays",
";",
"}"
]
| Implements the rule which requests if two holidays have one non holiday
between each other than this day is also a holiday. | [
"Implements",
"the",
"rule",
"which",
"requests",
"if",
"two",
"holidays",
"have",
"one",
"non",
"holiday",
"between",
"each",
"other",
"than",
"this",
"day",
"is",
"also",
"a",
"holiday",
"."
]
| train | https://github.com/phax/ph-datetime/blob/cfaff01cb76d9affb934800ff55734b5a7d8983e/ph-holiday/src/main/java/com/helger/holiday/mgr/XMLHolidayManagerJapan.java#L51-L69 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/DefaultCommandRegistry.java | DefaultCommandRegistry.fireCommandRegistered | protected void fireCommandRegistered(AbstractCommand command) {
"""
Fires a 'commandRegistered' {@link CommandRegistryEvent} for the given command to all
registered listeners.
@param command The command that has been registered. Must not be null.
@throws IllegalArgumentException if {@code command} is null.
"""
Assert.notNull(command, "command");
if (commandRegistryListeners.isEmpty()) {
return;
}
CommandRegistryEvent event = new CommandRegistryEvent(this, command);
for (Iterator i = commandRegistryListeners.iterator(); i.hasNext();) {
((CommandRegistryListener)i.next()).commandRegistered(event);
}
} | java | protected void fireCommandRegistered(AbstractCommand command) {
Assert.notNull(command, "command");
if (commandRegistryListeners.isEmpty()) {
return;
}
CommandRegistryEvent event = new CommandRegistryEvent(this, command);
for (Iterator i = commandRegistryListeners.iterator(); i.hasNext();) {
((CommandRegistryListener)i.next()).commandRegistered(event);
}
} | [
"protected",
"void",
"fireCommandRegistered",
"(",
"AbstractCommand",
"command",
")",
"{",
"Assert",
".",
"notNull",
"(",
"command",
",",
"\"command\"",
")",
";",
"if",
"(",
"commandRegistryListeners",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"CommandRegistryEvent",
"event",
"=",
"new",
"CommandRegistryEvent",
"(",
"this",
",",
"command",
")",
";",
"for",
"(",
"Iterator",
"i",
"=",
"commandRegistryListeners",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"(",
"(",
"CommandRegistryListener",
")",
"i",
".",
"next",
"(",
")",
")",
".",
"commandRegistered",
"(",
"event",
")",
";",
"}",
"}"
]
| Fires a 'commandRegistered' {@link CommandRegistryEvent} for the given command to all
registered listeners.
@param command The command that has been registered. Must not be null.
@throws IllegalArgumentException if {@code command} is null. | [
"Fires",
"a",
"commandRegistered",
"{",
"@link",
"CommandRegistryEvent",
"}",
"for",
"the",
"given",
"command",
"to",
"all",
"registered",
"listeners",
"."
]
| train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/DefaultCommandRegistry.java#L215-L229 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/DateTime.java | DateTime.toCalendar | public Calendar toCalendar(TimeZone zone, Locale locale) {
"""
转换为Calendar
@param zone 时区 {@link TimeZone}
@param locale 地域 {@link Locale}
@return {@link Calendar}
"""
if (null == locale) {
locale = Locale.getDefault(Locale.Category.FORMAT);
}
final Calendar cal = (null != zone) ? Calendar.getInstance(zone, locale) : Calendar.getInstance(locale);
cal.setFirstDayOfWeek(firstDayOfWeek.getValue());
cal.setTime(this);
return cal;
} | java | public Calendar toCalendar(TimeZone zone, Locale locale) {
if (null == locale) {
locale = Locale.getDefault(Locale.Category.FORMAT);
}
final Calendar cal = (null != zone) ? Calendar.getInstance(zone, locale) : Calendar.getInstance(locale);
cal.setFirstDayOfWeek(firstDayOfWeek.getValue());
cal.setTime(this);
return cal;
} | [
"public",
"Calendar",
"toCalendar",
"(",
"TimeZone",
"zone",
",",
"Locale",
"locale",
")",
"{",
"if",
"(",
"null",
"==",
"locale",
")",
"{",
"locale",
"=",
"Locale",
".",
"getDefault",
"(",
"Locale",
".",
"Category",
".",
"FORMAT",
")",
";",
"}",
"final",
"Calendar",
"cal",
"=",
"(",
"null",
"!=",
"zone",
")",
"?",
"Calendar",
".",
"getInstance",
"(",
"zone",
",",
"locale",
")",
":",
"Calendar",
".",
"getInstance",
"(",
"locale",
")",
";",
"cal",
".",
"setFirstDayOfWeek",
"(",
"firstDayOfWeek",
".",
"getValue",
"(",
")",
")",
";",
"cal",
".",
"setTime",
"(",
"this",
")",
";",
"return",
"cal",
";",
"}"
]
| 转换为Calendar
@param zone 时区 {@link TimeZone}
@param locale 地域 {@link Locale}
@return {@link Calendar} | [
"转换为Calendar"
]
| train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/DateTime.java#L541-L549 |
AltBeacon/android-beacon-library | lib/src/main/java/org/altbeacon/beacon/Identifier.java | Identifier.fromBytes | @TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static Identifier fromBytes(byte[] bytes, int start, int end, boolean littleEndian) {
"""
Creates an Identifier from the specified byte array.
@param bytes array to copy from
@param start the start index, inclusive
@param end the end index, exclusive
@param littleEndian whether the bytes are ordered in little endian
@return a new Identifier
@throws java.lang.NullPointerException <code>bytes</code> must not be <code>null</code>
@throws java.lang.ArrayIndexOutOfBoundsException start or end are outside the bounds of the array
@throws java.lang.IllegalArgumentException start is larger than end
"""
if (bytes == null) {
throw new NullPointerException("Identifiers cannot be constructed from null pointers but \"bytes\" is null.");
}
if (start < 0 || start > bytes.length) {
throw new ArrayIndexOutOfBoundsException("start < 0 || start > bytes.length");
}
if (end > bytes.length) {
throw new ArrayIndexOutOfBoundsException("end > bytes.length");
}
if (start > end) {
throw new IllegalArgumentException("start > end");
}
byte[] byteRange = Arrays.copyOfRange(bytes, start, end);
if (littleEndian) {
reverseArray(byteRange);
}
return new Identifier(byteRange);
} | java | @TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static Identifier fromBytes(byte[] bytes, int start, int end, boolean littleEndian) {
if (bytes == null) {
throw new NullPointerException("Identifiers cannot be constructed from null pointers but \"bytes\" is null.");
}
if (start < 0 || start > bytes.length) {
throw new ArrayIndexOutOfBoundsException("start < 0 || start > bytes.length");
}
if (end > bytes.length) {
throw new ArrayIndexOutOfBoundsException("end > bytes.length");
}
if (start > end) {
throw new IllegalArgumentException("start > end");
}
byte[] byteRange = Arrays.copyOfRange(bytes, start, end);
if (littleEndian) {
reverseArray(byteRange);
}
return new Identifier(byteRange);
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"GINGERBREAD",
")",
"public",
"static",
"Identifier",
"fromBytes",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"start",
",",
"int",
"end",
",",
"boolean",
"littleEndian",
")",
"{",
"if",
"(",
"bytes",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Identifiers cannot be constructed from null pointers but \\\"bytes\\\" is null.\"",
")",
";",
"}",
"if",
"(",
"start",
"<",
"0",
"||",
"start",
">",
"bytes",
".",
"length",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
"\"start < 0 || start > bytes.length\"",
")",
";",
"}",
"if",
"(",
"end",
">",
"bytes",
".",
"length",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
"\"end > bytes.length\"",
")",
";",
"}",
"if",
"(",
"start",
">",
"end",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"start > end\"",
")",
";",
"}",
"byte",
"[",
"]",
"byteRange",
"=",
"Arrays",
".",
"copyOfRange",
"(",
"bytes",
",",
"start",
",",
"end",
")",
";",
"if",
"(",
"littleEndian",
")",
"{",
"reverseArray",
"(",
"byteRange",
")",
";",
"}",
"return",
"new",
"Identifier",
"(",
"byteRange",
")",
";",
"}"
]
| Creates an Identifier from the specified byte array.
@param bytes array to copy from
@param start the start index, inclusive
@param end the end index, exclusive
@param littleEndian whether the bytes are ordered in little endian
@return a new Identifier
@throws java.lang.NullPointerException <code>bytes</code> must not be <code>null</code>
@throws java.lang.ArrayIndexOutOfBoundsException start or end are outside the bounds of the array
@throws java.lang.IllegalArgumentException start is larger than end | [
"Creates",
"an",
"Identifier",
"from",
"the",
"specified",
"byte",
"array",
"."
]
| train | https://github.com/AltBeacon/android-beacon-library/blob/f7f3a323ea7415d53e7bd695ff6a01f1501d5dc3/lib/src/main/java/org/altbeacon/beacon/Identifier.java#L171-L191 |
liferay/com-liferay-commerce | commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceListPersistenceImpl.java | CommercePriceListPersistenceImpl.findByUUID_G | @Override
public CommercePriceList findByUUID_G(String uuid, long groupId)
throws NoSuchPriceListException {
"""
Returns the commerce price list where uuid = ? and groupId = ? or throws a {@link NoSuchPriceListException} if it could not be found.
@param uuid the uuid
@param groupId the group ID
@return the matching commerce price list
@throws NoSuchPriceListException if a matching commerce price list could not be found
"""
CommercePriceList commercePriceList = fetchByUUID_G(uuid, groupId);
if (commercePriceList == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchPriceListException(msg.toString());
}
return commercePriceList;
} | java | @Override
public CommercePriceList findByUUID_G(String uuid, long groupId)
throws NoSuchPriceListException {
CommercePriceList commercePriceList = fetchByUUID_G(uuid, groupId);
if (commercePriceList == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchPriceListException(msg.toString());
}
return commercePriceList;
} | [
"@",
"Override",
"public",
"CommercePriceList",
"findByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"NoSuchPriceListException",
"{",
"CommercePriceList",
"commercePriceList",
"=",
"fetchByUUID_G",
"(",
"uuid",
",",
"groupId",
")",
";",
"if",
"(",
"commercePriceList",
"==",
"null",
")",
"{",
"StringBundler",
"msg",
"=",
"new",
"StringBundler",
"(",
"6",
")",
";",
"msg",
".",
"append",
"(",
"_NO_SUCH_ENTITY_WITH_KEY",
")",
";",
"msg",
".",
"append",
"(",
"\"uuid=\"",
")",
";",
"msg",
".",
"append",
"(",
"uuid",
")",
";",
"msg",
".",
"append",
"(",
"\", groupId=\"",
")",
";",
"msg",
".",
"append",
"(",
"groupId",
")",
";",
"msg",
".",
"append",
"(",
"\"}\"",
")",
";",
"if",
"(",
"_log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"_log",
".",
"debug",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"throw",
"new",
"NoSuchPriceListException",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"commercePriceList",
";",
"}"
]
| Returns the commerce price list where uuid = ? and groupId = ? or throws a {@link NoSuchPriceListException} if it could not be found.
@param uuid the uuid
@param groupId the group ID
@return the matching commerce price list
@throws NoSuchPriceListException if a matching commerce price list could not be found | [
"Returns",
"the",
"commerce",
"price",
"list",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"or",
"throws",
"a",
"{",
"@link",
"NoSuchPriceListException",
"}",
"if",
"it",
"could",
"not",
"be",
"found",
"."
]
| train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceListPersistenceImpl.java#L672-L698 |
FasterXML/woodstox | src/main/java/com/ctc/wstx/io/InputSourceFactory.java | InputSourceFactory.constructCharArraySource | public static WstxInputSource constructCharArraySource
(WstxInputSource parent, String fromEntity,
char[] text, int offset, int len, Location loc, URL src) {
"""
Factory method usually used to expand internal parsed entities; in
which case context remains mostly the same.
"""
SystemId sysId = SystemId.construct(loc.getSystemId(), src);
return new CharArraySource(parent, fromEntity, text, offset, len, loc, sysId);
} | java | public static WstxInputSource constructCharArraySource
(WstxInputSource parent, String fromEntity,
char[] text, int offset, int len, Location loc, URL src)
{
SystemId sysId = SystemId.construct(loc.getSystemId(), src);
return new CharArraySource(parent, fromEntity, text, offset, len, loc, sysId);
} | [
"public",
"static",
"WstxInputSource",
"constructCharArraySource",
"(",
"WstxInputSource",
"parent",
",",
"String",
"fromEntity",
",",
"char",
"[",
"]",
"text",
",",
"int",
"offset",
",",
"int",
"len",
",",
"Location",
"loc",
",",
"URL",
"src",
")",
"{",
"SystemId",
"sysId",
"=",
"SystemId",
".",
"construct",
"(",
"loc",
".",
"getSystemId",
"(",
")",
",",
"src",
")",
";",
"return",
"new",
"CharArraySource",
"(",
"parent",
",",
"fromEntity",
",",
"text",
",",
"offset",
",",
"len",
",",
"loc",
",",
"sysId",
")",
";",
"}"
]
| Factory method usually used to expand internal parsed entities; in
which case context remains mostly the same. | [
"Factory",
"method",
"usually",
"used",
"to",
"expand",
"internal",
"parsed",
"entities",
";",
"in",
"which",
"case",
"context",
"remains",
"mostly",
"the",
"same",
"."
]
| train | https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/io/InputSourceFactory.java#L69-L75 |
alkacon/opencms-core | src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageController.java | CmsContainerpageController.copyElement | public void copyElement(final String id, final I_CmsSimpleCallback<CmsUUID> callback) {
"""
Copies an element and asynchronously returns the structure id of the copy.<p>
@param id the element id
@param callback the callback for the result
"""
CmsRpcAction<CmsUUID> action = new CmsRpcAction<CmsUUID>() {
@Override
public void execute() {
start(200, false);
getContainerpageService().copyElement(
CmsCoreProvider.get().getStructureId(),
new CmsUUID(id),
getData().getLocale(),
this);
}
@Override
protected void onResponse(CmsUUID result) {
stop(false);
callback.execute(result);
}
};
action.execute();
} | java | public void copyElement(final String id, final I_CmsSimpleCallback<CmsUUID> callback) {
CmsRpcAction<CmsUUID> action = new CmsRpcAction<CmsUUID>() {
@Override
public void execute() {
start(200, false);
getContainerpageService().copyElement(
CmsCoreProvider.get().getStructureId(),
new CmsUUID(id),
getData().getLocale(),
this);
}
@Override
protected void onResponse(CmsUUID result) {
stop(false);
callback.execute(result);
}
};
action.execute();
} | [
"public",
"void",
"copyElement",
"(",
"final",
"String",
"id",
",",
"final",
"I_CmsSimpleCallback",
"<",
"CmsUUID",
">",
"callback",
")",
"{",
"CmsRpcAction",
"<",
"CmsUUID",
">",
"action",
"=",
"new",
"CmsRpcAction",
"<",
"CmsUUID",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"{",
"start",
"(",
"200",
",",
"false",
")",
";",
"getContainerpageService",
"(",
")",
".",
"copyElement",
"(",
"CmsCoreProvider",
".",
"get",
"(",
")",
".",
"getStructureId",
"(",
")",
",",
"new",
"CmsUUID",
"(",
"id",
")",
",",
"getData",
"(",
")",
".",
"getLocale",
"(",
")",
",",
"this",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"onResponse",
"(",
"CmsUUID",
"result",
")",
"{",
"stop",
"(",
"false",
")",
";",
"callback",
".",
"execute",
"(",
"result",
")",
";",
"}",
"}",
";",
"action",
".",
"execute",
"(",
")",
";",
"}"
]
| Copies an element and asynchronously returns the structure id of the copy.<p>
@param id the element id
@param callback the callback for the result | [
"Copies",
"an",
"element",
"and",
"asynchronously",
"returns",
"the",
"structure",
"id",
"of",
"the",
"copy",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageController.java#L958-L982 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/beaneditor/BeanEditorPanel.java | BeanEditorPanel.newSubmitButton | protected Button newSubmitButton(final String id, final Form<?> form) {
"""
Factory method for creating the Button. This method is invoked in the constructor from the
derived classes and can be overridden so users can provide their own version of a Button.
@param id
the id
@param form
the form
@return the Button
"""
final Button button = new AjaxFallbackButton(id, form)
{
/**
* The serialVersionUID
*/
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form)
{
BeanEditorPanel.this.onSubmit(target, form);
}
/**
* {@inheritDoc}
*/
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form)
{
BeanEditorPanel.this.onSubmit(target, form);
}
};
return button;
} | java | protected Button newSubmitButton(final String id, final Form<?> form)
{
final Button button = new AjaxFallbackButton(id, form)
{
/**
* The serialVersionUID
*/
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form)
{
BeanEditorPanel.this.onSubmit(target, form);
}
/**
* {@inheritDoc}
*/
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form)
{
BeanEditorPanel.this.onSubmit(target, form);
}
};
return button;
} | [
"protected",
"Button",
"newSubmitButton",
"(",
"final",
"String",
"id",
",",
"final",
"Form",
"<",
"?",
">",
"form",
")",
"{",
"final",
"Button",
"button",
"=",
"new",
"AjaxFallbackButton",
"(",
"id",
",",
"form",
")",
"{",
"/**\r\n\t\t\t * The serialVersionUID\r\n\t\t\t */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\r\n\t\t\t * {@inheritDoc}\r\n\t\t\t */",
"@",
"Override",
"protected",
"void",
"onError",
"(",
"final",
"AjaxRequestTarget",
"target",
",",
"final",
"Form",
"<",
"?",
">",
"form",
")",
"{",
"BeanEditorPanel",
".",
"this",
".",
"onSubmit",
"(",
"target",
",",
"form",
")",
";",
"}",
"/**\r\n\t\t\t * {@inheritDoc}\r\n\t\t\t */",
"@",
"Override",
"protected",
"void",
"onSubmit",
"(",
"final",
"AjaxRequestTarget",
"target",
",",
"final",
"Form",
"<",
"?",
">",
"form",
")",
"{",
"BeanEditorPanel",
".",
"this",
".",
"onSubmit",
"(",
"target",
",",
"form",
")",
";",
"}",
"}",
";",
"return",
"button",
";",
"}"
]
| Factory method for creating the Button. This method is invoked in the constructor from the
derived classes and can be overridden so users can provide their own version of a Button.
@param id
the id
@param form
the form
@return the Button | [
"Factory",
"method",
"for",
"creating",
"the",
"Button",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"Button",
"."
]
| train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/beaneditor/BeanEditorPanel.java#L156-L184 |
Azure/azure-sdk-for-java | batchai/resource-manager/v2018_03_01/src/main/java/com/microsoft/azure/management/batchai/v2018_03_01/implementation/JobsInner.java | JobsInner.getByResourceGroupAsync | public Observable<JobInner> getByResourceGroupAsync(String resourceGroupName, String jobName) {
"""
Gets information about the specified Batch AI job.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param jobName The name of the job within the specified resource group. Job names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the JobInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, jobName).map(new Func1<ServiceResponse<JobInner>, JobInner>() {
@Override
public JobInner call(ServiceResponse<JobInner> response) {
return response.body();
}
});
} | java | public Observable<JobInner> getByResourceGroupAsync(String resourceGroupName, String jobName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, jobName).map(new Func1<ServiceResponse<JobInner>, JobInner>() {
@Override
public JobInner call(ServiceResponse<JobInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"JobInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"jobName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"jobName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"JobInner",
">",
",",
"JobInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"JobInner",
"call",
"(",
"ServiceResponse",
"<",
"JobInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Gets information about the specified Batch AI job.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param jobName The name of the job within the specified resource group. Job names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the JobInner object | [
"Gets",
"information",
"about",
"the",
"specified",
"Batch",
"AI",
"job",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batchai/resource-manager/v2018_03_01/src/main/java/com/microsoft/azure/management/batchai/v2018_03_01/implementation/JobsInner.java#L496-L503 |
LGoodDatePicker/LGoodDatePicker | Project/src/main/java/com/github/lgooddatepicker/components/TimePicker.java | TimePicker.getBaseline | @Override
public int getBaseline(int width, int height) {
"""
getBaseline, This returns the baseline value of the timeTextField.
"""
if (timeTextField.isVisible()) {
return timeTextField.getBaseline(width, height);
}
return super.getBaseline(width, height);
} | java | @Override
public int getBaseline(int width, int height) {
if (timeTextField.isVisible()) {
return timeTextField.getBaseline(width, height);
}
return super.getBaseline(width, height);
} | [
"@",
"Override",
"public",
"int",
"getBaseline",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"if",
"(",
"timeTextField",
".",
"isVisible",
"(",
")",
")",
"{",
"return",
"timeTextField",
".",
"getBaseline",
"(",
"width",
",",
"height",
")",
";",
"}",
"return",
"super",
".",
"getBaseline",
"(",
"width",
",",
"height",
")",
";",
"}"
]
| getBaseline, This returns the baseline value of the timeTextField. | [
"getBaseline",
"This",
"returns",
"the",
"baseline",
"value",
"of",
"the",
"timeTextField",
"."
]
| train | https://github.com/LGoodDatePicker/LGoodDatePicker/blob/c7df05a5fe382e1e08a6237e9391d8dc5fd48692/Project/src/main/java/com/github/lgooddatepicker/components/TimePicker.java#L260-L266 |
Erudika/para | para-client/src/main/java/com/erudika/para/client/ParaClient.java | ParaClient.appSettings | public Map<String, Object> appSettings(String key) {
"""
Returns the value of a specific app setting (property).
@param key a key
@return a map containing one element {"value": "the_value"} or an empty map.
"""
if (StringUtils.isBlank(key)) {
return appSettings();
}
return getEntity(invokeGet(Utils.formatMessage("_settings/{0}", key), null), Map.class);
} | java | public Map<String, Object> appSettings(String key) {
if (StringUtils.isBlank(key)) {
return appSettings();
}
return getEntity(invokeGet(Utils.formatMessage("_settings/{0}", key), null), Map.class);
} | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"appSettings",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"key",
")",
")",
"{",
"return",
"appSettings",
"(",
")",
";",
"}",
"return",
"getEntity",
"(",
"invokeGet",
"(",
"Utils",
".",
"formatMessage",
"(",
"\"_settings/{0}\"",
",",
"key",
")",
",",
"null",
")",
",",
"Map",
".",
"class",
")",
";",
"}"
]
| Returns the value of a specific app setting (property).
@param key a key
@return a map containing one element {"value": "the_value"} or an empty map. | [
"Returns",
"the",
"value",
"of",
"a",
"specific",
"app",
"setting",
"(",
"property",
")",
"."
]
| train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-client/src/main/java/com/erudika/para/client/ParaClient.java#L1518-L1523 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_service_serviceName_changeOfBillingAccount_POST | public void billingAccount_service_serviceName_changeOfBillingAccount_POST(String billingAccount, String serviceName, String billingAccountDestination) throws IOException {
"""
Move a service of billing account. Source and destination nics should be the same.
REST: POST /telephony/{billingAccount}/service/{serviceName}/changeOfBillingAccount
@param billingAccountDestination [required] Billing account destination target
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
"""
String qPath = "/telephony/{billingAccount}/service/{serviceName}/changeOfBillingAccount";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "billingAccountDestination", billingAccountDestination);
exec(qPath, "POST", sb.toString(), o);
} | java | public void billingAccount_service_serviceName_changeOfBillingAccount_POST(String billingAccount, String serviceName, String billingAccountDestination) throws IOException {
String qPath = "/telephony/{billingAccount}/service/{serviceName}/changeOfBillingAccount";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "billingAccountDestination", billingAccountDestination);
exec(qPath, "POST", sb.toString(), o);
} | [
"public",
"void",
"billingAccount_service_serviceName_changeOfBillingAccount_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"String",
"billingAccountDestination",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/service/{serviceName}/changeOfBillingAccount\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"billingAccountDestination\"",
",",
"billingAccountDestination",
")",
";",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"}"
]
| Move a service of billing account. Source and destination nics should be the same.
REST: POST /telephony/{billingAccount}/service/{serviceName}/changeOfBillingAccount
@param billingAccountDestination [required] Billing account destination target
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] | [
"Move",
"a",
"service",
"of",
"billing",
"account",
".",
"Source",
"and",
"destination",
"nics",
"should",
"be",
"the",
"same",
"."
]
| train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L3705-L3711 |
LearnLib/automatalib | util/src/main/java/net/automatalib/util/minimizer/Minimizer.java | Minimizer.removeFromSplitterQueue | private boolean removeFromSplitterQueue(Block<S, L> block) {
"""
Removes a block from the splitter queue. This is done when it is split completely and thus no longer existant.
"""
ElementReference ref = block.getSplitterQueueReference();
if (ref == null) {
return false;
}
splitters.remove(ref);
block.setSplitterQueueReference(null);
return true;
} | java | private boolean removeFromSplitterQueue(Block<S, L> block) {
ElementReference ref = block.getSplitterQueueReference();
if (ref == null) {
return false;
}
splitters.remove(ref);
block.setSplitterQueueReference(null);
return true;
} | [
"private",
"boolean",
"removeFromSplitterQueue",
"(",
"Block",
"<",
"S",
",",
"L",
">",
"block",
")",
"{",
"ElementReference",
"ref",
"=",
"block",
".",
"getSplitterQueueReference",
"(",
")",
";",
"if",
"(",
"ref",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"splitters",
".",
"remove",
"(",
"ref",
")",
";",
"block",
".",
"setSplitterQueueReference",
"(",
"null",
")",
";",
"return",
"true",
";",
"}"
]
| Removes a block from the splitter queue. This is done when it is split completely and thus no longer existant. | [
"Removes",
"a",
"block",
"from",
"the",
"splitter",
"queue",
".",
"This",
"is",
"done",
"when",
"it",
"is",
"split",
"completely",
"and",
"thus",
"no",
"longer",
"existant",
"."
]
| train | https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/util/src/main/java/net/automatalib/util/minimizer/Minimizer.java#L237-L247 |
protegeproject/jpaul | src/main/java/jpaul/DataStructs/DSUtil.java | DSUtil.iterableSizeEq | public static <E> boolean iterableSizeEq(Iterable<E> itrbl, int k) {
"""
Checks whether the iterable <code>itrbl</code> has exactly
<code>k</code> elements. Instead of computing the length of
<code>itrbl</code> (complexity: linear in the length) and
comparing it with <code>k</code>, we try to iterate exactly
<code>k</code> times and next check that <code>itrbl</code> is
exhausted.
Complexity: linear in <code>k</code>. Hence, this test is
very fast for small <code>k</code>s.
"""
// 1) try to iterate k times over itrbl;
Iterator<E> it = itrbl.iterator();
for(int i = 0; i < k; i++) {
if(!it.hasNext()) return false;
it.next();
}
// 2) next check that there are no more elements in itrbl
return !it.hasNext();
} | java | public static <E> boolean iterableSizeEq(Iterable<E> itrbl, int k) {
// 1) try to iterate k times over itrbl;
Iterator<E> it = itrbl.iterator();
for(int i = 0; i < k; i++) {
if(!it.hasNext()) return false;
it.next();
}
// 2) next check that there are no more elements in itrbl
return !it.hasNext();
} | [
"public",
"static",
"<",
"E",
">",
"boolean",
"iterableSizeEq",
"(",
"Iterable",
"<",
"E",
">",
"itrbl",
",",
"int",
"k",
")",
"{",
"// 1) try to iterate k times over itrbl;",
"Iterator",
"<",
"E",
">",
"it",
"=",
"itrbl",
".",
"iterator",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"k",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"it",
".",
"hasNext",
"(",
")",
")",
"return",
"false",
";",
"it",
".",
"next",
"(",
")",
";",
"}",
"// 2) next check that there are no more elements in itrbl",
"return",
"!",
"it",
".",
"hasNext",
"(",
")",
";",
"}"
]
| Checks whether the iterable <code>itrbl</code> has exactly
<code>k</code> elements. Instead of computing the length of
<code>itrbl</code> (complexity: linear in the length) and
comparing it with <code>k</code>, we try to iterate exactly
<code>k</code> times and next check that <code>itrbl</code> is
exhausted.
Complexity: linear in <code>k</code>. Hence, this test is
very fast for small <code>k</code>s. | [
"Checks",
"whether",
"the",
"iterable",
"<code",
">",
"itrbl<",
"/",
"code",
">",
"has",
"exactly",
"<code",
">",
"k<",
"/",
"code",
">",
"elements",
".",
"Instead",
"of",
"computing",
"the",
"length",
"of",
"<code",
">",
"itrbl<",
"/",
"code",
">",
"(",
"complexity",
":",
"linear",
"in",
"the",
"length",
")",
"and",
"comparing",
"it",
"with",
"<code",
">",
"k<",
"/",
"code",
">",
"we",
"try",
"to",
"iterate",
"exactly",
"<code",
">",
"k<",
"/",
"code",
">",
"times",
"and",
"next",
"check",
"that",
"<code",
">",
"itrbl<",
"/",
"code",
">",
"is",
"exhausted",
"."
]
| train | https://github.com/protegeproject/jpaul/blob/db579ffb16faaa4b0c577ec82c246f7349427714/src/main/java/jpaul/DataStructs/DSUtil.java#L97-L106 |
google/closure-compiler | src/com/google/javascript/jscomp/J2clChecksPass.java | J2clChecksPass.checkReferenceEquality | private void checkReferenceEquality(Node n, String typeName, String fileName) {
"""
Reports an error if the node is a reference equality check of the specified type.
"""
if (n.getToken() == Token.SHEQ
|| n.getToken() == Token.EQ
|| n.getToken() == Token.SHNE
|| n.getToken() == Token.NE) {
JSType firstJsType = n.getFirstChild().getJSType();
JSType lastJsType = n.getLastChild().getJSType();
boolean hasType = isType(firstJsType, fileName) || isType(lastJsType, fileName);
boolean hasNullType = isNullType(firstJsType) || isNullType(lastJsType);
if (hasType && !hasNullType) {
compiler.report(JSError.make(n, J2CL_REFERENCE_EQUALITY, typeName));
}
}
} | java | private void checkReferenceEquality(Node n, String typeName, String fileName) {
if (n.getToken() == Token.SHEQ
|| n.getToken() == Token.EQ
|| n.getToken() == Token.SHNE
|| n.getToken() == Token.NE) {
JSType firstJsType = n.getFirstChild().getJSType();
JSType lastJsType = n.getLastChild().getJSType();
boolean hasType = isType(firstJsType, fileName) || isType(lastJsType, fileName);
boolean hasNullType = isNullType(firstJsType) || isNullType(lastJsType);
if (hasType && !hasNullType) {
compiler.report(JSError.make(n, J2CL_REFERENCE_EQUALITY, typeName));
}
}
} | [
"private",
"void",
"checkReferenceEquality",
"(",
"Node",
"n",
",",
"String",
"typeName",
",",
"String",
"fileName",
")",
"{",
"if",
"(",
"n",
".",
"getToken",
"(",
")",
"==",
"Token",
".",
"SHEQ",
"||",
"n",
".",
"getToken",
"(",
")",
"==",
"Token",
".",
"EQ",
"||",
"n",
".",
"getToken",
"(",
")",
"==",
"Token",
".",
"SHNE",
"||",
"n",
".",
"getToken",
"(",
")",
"==",
"Token",
".",
"NE",
")",
"{",
"JSType",
"firstJsType",
"=",
"n",
".",
"getFirstChild",
"(",
")",
".",
"getJSType",
"(",
")",
";",
"JSType",
"lastJsType",
"=",
"n",
".",
"getLastChild",
"(",
")",
".",
"getJSType",
"(",
")",
";",
"boolean",
"hasType",
"=",
"isType",
"(",
"firstJsType",
",",
"fileName",
")",
"||",
"isType",
"(",
"lastJsType",
",",
"fileName",
")",
";",
"boolean",
"hasNullType",
"=",
"isNullType",
"(",
"firstJsType",
")",
"||",
"isNullType",
"(",
"lastJsType",
")",
";",
"if",
"(",
"hasType",
"&&",
"!",
"hasNullType",
")",
"{",
"compiler",
".",
"report",
"(",
"JSError",
".",
"make",
"(",
"n",
",",
"J2CL_REFERENCE_EQUALITY",
",",
"typeName",
")",
")",
";",
"}",
"}",
"}"
]
| Reports an error if the node is a reference equality check of the specified type. | [
"Reports",
"an",
"error",
"if",
"the",
"node",
"is",
"a",
"reference",
"equality",
"check",
"of",
"the",
"specified",
"type",
"."
]
| train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/J2clChecksPass.java#L56-L69 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/StringUtils.java | StringUtils.indexOf | public static int indexOf(final CharSequence seq, final CharSequence searchSeq) {
"""
<p>Finds the first index within a CharSequence, handling {@code null}.
This method uses {@link String#indexOf(String, int)} if possible.</p>
<p>A {@code null} CharSequence will return {@code -1}.</p>
<pre>
StringUtils.indexOf(null, *) = -1
StringUtils.indexOf(*, null) = -1
StringUtils.indexOf("", "") = 0
StringUtils.indexOf("", *) = -1 (except when * = "")
StringUtils.indexOf("aabaabaa", "a") = 0
StringUtils.indexOf("aabaabaa", "b") = 2
StringUtils.indexOf("aabaabaa", "ab") = 1
StringUtils.indexOf("aabaabaa", "") = 0
</pre>
@param seq the CharSequence to check, may be null
@param searchSeq the CharSequence to find, may be null
@return the first index of the search CharSequence,
-1 if no match or {@code null} string input
@since 2.0
@since 3.0 Changed signature from indexOf(String, String) to indexOf(CharSequence, CharSequence)
"""
if (seq == null || searchSeq == null) {
return INDEX_NOT_FOUND;
}
return CharSequenceUtils.indexOf(seq, searchSeq, 0);
} | java | public static int indexOf(final CharSequence seq, final CharSequence searchSeq) {
if (seq == null || searchSeq == null) {
return INDEX_NOT_FOUND;
}
return CharSequenceUtils.indexOf(seq, searchSeq, 0);
} | [
"public",
"static",
"int",
"indexOf",
"(",
"final",
"CharSequence",
"seq",
",",
"final",
"CharSequence",
"searchSeq",
")",
"{",
"if",
"(",
"seq",
"==",
"null",
"||",
"searchSeq",
"==",
"null",
")",
"{",
"return",
"INDEX_NOT_FOUND",
";",
"}",
"return",
"CharSequenceUtils",
".",
"indexOf",
"(",
"seq",
",",
"searchSeq",
",",
"0",
")",
";",
"}"
]
| <p>Finds the first index within a CharSequence, handling {@code null}.
This method uses {@link String#indexOf(String, int)} if possible.</p>
<p>A {@code null} CharSequence will return {@code -1}.</p>
<pre>
StringUtils.indexOf(null, *) = -1
StringUtils.indexOf(*, null) = -1
StringUtils.indexOf("", "") = 0
StringUtils.indexOf("", *) = -1 (except when * = "")
StringUtils.indexOf("aabaabaa", "a") = 0
StringUtils.indexOf("aabaabaa", "b") = 2
StringUtils.indexOf("aabaabaa", "ab") = 1
StringUtils.indexOf("aabaabaa", "") = 0
</pre>
@param seq the CharSequence to check, may be null
@param searchSeq the CharSequence to find, may be null
@return the first index of the search CharSequence,
-1 if no match or {@code null} string input
@since 2.0
@since 3.0 Changed signature from indexOf(String, String) to indexOf(CharSequence, CharSequence) | [
"<p",
">",
"Finds",
"the",
"first",
"index",
"within",
"a",
"CharSequence",
"handling",
"{",
"@code",
"null",
"}",
".",
"This",
"method",
"uses",
"{",
"@link",
"String#indexOf",
"(",
"String",
"int",
")",
"}",
"if",
"possible",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/StringUtils.java#L1415-L1420 |
synchronoss/cpo-api | cpo-jdbc/src/main/java/org/synchronoss/cpo/jdbc/JdbcCpoAdapter.java | JdbcCpoAdapter.updateObjects | @Override
public <T> long updateObjects(Collection<T> coll) throws CpoException {
"""
Updates a collection of Objects in the datasource. The assumption is that the objects contained in the collection
exist in the datasource. This method stores the object in the datasource. The objects in the collection will be
treated as one transaction, meaning that if one of the objects fail being updated in the datasource then the entire
collection will be rolled back, if supported by the datasource.
<p/>
<pre>Example:
<code>
<p/>
class SomeObject so = null;
class CpoAdapter cpo = null;
<p/>
try {
cpo = new JdbcCpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
} catch (CpoException ce) {
// Handle the error
cpo = null;
}
<p/>
if (cpo!=null) {
ArrayList al = new ArrayList();
for (int i=0; i<3; i++){
so = new SomeObject();
so.setId(1);
so.setName("SomeName");
al.add(so);
}
try{
cpo.updateObjects(al);
} catch (CpoException ce) {
// Handle the error
}
}
</code>
</pre>
@param coll This is a collection of objects that have been defined within the metadata of the datasource. If the
class is not defined an exception will be thrown.
@return The number of objects updated in the datasource
@throws CpoException Thrown if there are errors accessing the datasource
"""
return processUpdateGroup(coll, JdbcCpoAdapter.UPDATE_GROUP, null, null, null, null);
} | java | @Override
public <T> long updateObjects(Collection<T> coll) throws CpoException {
return processUpdateGroup(coll, JdbcCpoAdapter.UPDATE_GROUP, null, null, null, null);
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"long",
"updateObjects",
"(",
"Collection",
"<",
"T",
">",
"coll",
")",
"throws",
"CpoException",
"{",
"return",
"processUpdateGroup",
"(",
"coll",
",",
"JdbcCpoAdapter",
".",
"UPDATE_GROUP",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}"
]
| Updates a collection of Objects in the datasource. The assumption is that the objects contained in the collection
exist in the datasource. This method stores the object in the datasource. The objects in the collection will be
treated as one transaction, meaning that if one of the objects fail being updated in the datasource then the entire
collection will be rolled back, if supported by the datasource.
<p/>
<pre>Example:
<code>
<p/>
class SomeObject so = null;
class CpoAdapter cpo = null;
<p/>
try {
cpo = new JdbcCpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
} catch (CpoException ce) {
// Handle the error
cpo = null;
}
<p/>
if (cpo!=null) {
ArrayList al = new ArrayList();
for (int i=0; i<3; i++){
so = new SomeObject();
so.setId(1);
so.setName("SomeName");
al.add(so);
}
try{
cpo.updateObjects(al);
} catch (CpoException ce) {
// Handle the error
}
}
</code>
</pre>
@param coll This is a collection of objects that have been defined within the metadata of the datasource. If the
class is not defined an exception will be thrown.
@return The number of objects updated in the datasource
@throws CpoException Thrown if there are errors accessing the datasource | [
"Updates",
"a",
"collection",
"of",
"Objects",
"in",
"the",
"datasource",
".",
"The",
"assumption",
"is",
"that",
"the",
"objects",
"contained",
"in",
"the",
"collection",
"exist",
"in",
"the",
"datasource",
".",
"This",
"method",
"stores",
"the",
"object",
"in",
"the",
"datasource",
".",
"The",
"objects",
"in",
"the",
"collection",
"will",
"be",
"treated",
"as",
"one",
"transaction",
"meaning",
"that",
"if",
"one",
"of",
"the",
"objects",
"fail",
"being",
"updated",
"in",
"the",
"datasource",
"then",
"the",
"entire",
"collection",
"will",
"be",
"rolled",
"back",
"if",
"supported",
"by",
"the",
"datasource",
".",
"<p",
"/",
">",
"<pre",
">",
"Example",
":",
"<code",
">",
"<p",
"/",
">",
"class",
"SomeObject",
"so",
"=",
"null",
";",
"class",
"CpoAdapter",
"cpo",
"=",
"null",
";",
"<p",
"/",
">",
"try",
"{",
"cpo",
"=",
"new",
"JdbcCpoAdapter",
"(",
"new",
"JdbcDataSourceInfo",
"(",
"driver",
"url",
"user",
"password",
"1",
"1",
"false",
"))",
";",
"}",
"catch",
"(",
"CpoException",
"ce",
")",
"{",
"//",
"Handle",
"the",
"error",
"cpo",
"=",
"null",
";",
"}",
"<p",
"/",
">",
"if",
"(",
"cpo!",
"=",
"null",
")",
"{",
"ArrayList",
"al",
"=",
"new",
"ArrayList",
"()",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i<3",
";",
"i",
"++",
")",
"{",
"so",
"=",
"new",
"SomeObject",
"()",
";",
"so",
".",
"setId",
"(",
"1",
")",
";",
"so",
".",
"setName",
"(",
"SomeName",
")",
";",
"al",
".",
"add",
"(",
"so",
")",
";",
"}",
"try",
"{",
"cpo",
".",
"updateObjects",
"(",
"al",
")",
";",
"}",
"catch",
"(",
"CpoException",
"ce",
")",
"{",
"//",
"Handle",
"the",
"error",
"}",
"}",
"<",
"/",
"code",
">",
"<",
"/",
"pre",
">"
]
| train | https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-jdbc/src/main/java/org/synchronoss/cpo/jdbc/JdbcCpoAdapter.java#L1878-L1881 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/word2vec/wordstore/inmemory/AbstractCache.java | AbstractCache.incrementWordCount | @Override
public void incrementWordCount(String word, int increment) {
"""
Increment frequency for specified label by specified value
@param word the word to increment the count for
@param increment the amount to increment by
"""
T element = extendedVocabulary.get(word);
if (element != null) {
element.increaseElementFrequency(increment);
totalWordCount.addAndGet(increment);
}
} | java | @Override
public void incrementWordCount(String word, int increment) {
T element = extendedVocabulary.get(word);
if (element != null) {
element.increaseElementFrequency(increment);
totalWordCount.addAndGet(increment);
}
} | [
"@",
"Override",
"public",
"void",
"incrementWordCount",
"(",
"String",
"word",
",",
"int",
"increment",
")",
"{",
"T",
"element",
"=",
"extendedVocabulary",
".",
"get",
"(",
"word",
")",
";",
"if",
"(",
"element",
"!=",
"null",
")",
"{",
"element",
".",
"increaseElementFrequency",
"(",
"increment",
")",
";",
"totalWordCount",
".",
"addAndGet",
"(",
"increment",
")",
";",
"}",
"}"
]
| Increment frequency for specified label by specified value
@param word the word to increment the count for
@param increment the amount to increment by | [
"Increment",
"frequency",
"for",
"specified",
"label",
"by",
"specified",
"value"
]
| train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/word2vec/wordstore/inmemory/AbstractCache.java#L143-L150 |
cdk/cdk | base/standard/src/main/java/org/openscience/cdk/tools/manipulator/AtomContainerManipulator.java | AtomContainerManipulator.getAtomById | public static IAtom getAtomById(IAtomContainer ac, String id) throws CDKException {
"""
Returns an atom in an atomcontainer identified by id
@param ac The AtomContainer to search in
@param id The id to search for
@return An atom having id id
@throws CDKException There is no such atom
"""
for (int i = 0; i < ac.getAtomCount(); i++) {
if (ac.getAtom(i).getID() != null && ac.getAtom(i).getID().equals(id)) return ac.getAtom(i);
}
throw new CDKException("no suc atom");
} | java | public static IAtom getAtomById(IAtomContainer ac, String id) throws CDKException {
for (int i = 0; i < ac.getAtomCount(); i++) {
if (ac.getAtom(i).getID() != null && ac.getAtom(i).getID().equals(id)) return ac.getAtom(i);
}
throw new CDKException("no suc atom");
} | [
"public",
"static",
"IAtom",
"getAtomById",
"(",
"IAtomContainer",
"ac",
",",
"String",
"id",
")",
"throws",
"CDKException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ac",
".",
"getAtomCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"ac",
".",
"getAtom",
"(",
"i",
")",
".",
"getID",
"(",
")",
"!=",
"null",
"&&",
"ac",
".",
"getAtom",
"(",
"i",
")",
".",
"getID",
"(",
")",
".",
"equals",
"(",
"id",
")",
")",
"return",
"ac",
".",
"getAtom",
"(",
"i",
")",
";",
"}",
"throw",
"new",
"CDKException",
"(",
"\"no suc atom\"",
")",
";",
"}"
]
| Returns an atom in an atomcontainer identified by id
@param ac The AtomContainer to search in
@param id The id to search for
@return An atom having id id
@throws CDKException There is no such atom | [
"Returns",
"an",
"atom",
"in",
"an",
"atomcontainer",
"identified",
"by",
"id"
]
| train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/standard/src/main/java/org/openscience/cdk/tools/manipulator/AtomContainerManipulator.java#L166-L171 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.hpel/src/com/ibm/websphere/logging/hpel/reader/RepositoryReaderImpl.java | RepositoryReaderImpl.getLogListForServerInstance | public ServerInstanceLogRecordList getLogListForServerInstance(Date time, final LogRecordHeaderFilter filter) {
"""
returns log records from the binary repository which satisfy condition of the filter as specified by the parameter. The returned logs
will be from the same server instance. The server instance will be determined by the time as specified by the parameter.
@param time the {@link Date} time value used to determine the server instance where the server start time occurs before this value
and the server stop time occurs after this value
@param filter an instance implementing {@link LogRecordHeaderFilter} interface to verify one record at a time.
@return the iterable list of log records
"""
ServerInstanceByTime instance = new ServerInstanceByTime(time == null ? -1 : time.getTime());
if (instance.logs == null && instance.traces == null) {
return EMPTY_LIST;
} else {
return new ServerInstanceLogRecordListImpl(instance.logs, instance.traces, false) {
@Override
public OnePidRecordListImpl queryResult(LogRepositoryBrowser browser) {
return new LogRecordBrowser(browser).recordsInProcess(-1, -1, filter);
}
};
}
} | java | public ServerInstanceLogRecordList getLogListForServerInstance(Date time, final LogRecordHeaderFilter filter) {
ServerInstanceByTime instance = new ServerInstanceByTime(time == null ? -1 : time.getTime());
if (instance.logs == null && instance.traces == null) {
return EMPTY_LIST;
} else {
return new ServerInstanceLogRecordListImpl(instance.logs, instance.traces, false) {
@Override
public OnePidRecordListImpl queryResult(LogRepositoryBrowser browser) {
return new LogRecordBrowser(browser).recordsInProcess(-1, -1, filter);
}
};
}
} | [
"public",
"ServerInstanceLogRecordList",
"getLogListForServerInstance",
"(",
"Date",
"time",
",",
"final",
"LogRecordHeaderFilter",
"filter",
")",
"{",
"ServerInstanceByTime",
"instance",
"=",
"new",
"ServerInstanceByTime",
"(",
"time",
"==",
"null",
"?",
"-",
"1",
":",
"time",
".",
"getTime",
"(",
")",
")",
";",
"if",
"(",
"instance",
".",
"logs",
"==",
"null",
"&&",
"instance",
".",
"traces",
"==",
"null",
")",
"{",
"return",
"EMPTY_LIST",
";",
"}",
"else",
"{",
"return",
"new",
"ServerInstanceLogRecordListImpl",
"(",
"instance",
".",
"logs",
",",
"instance",
".",
"traces",
",",
"false",
")",
"{",
"@",
"Override",
"public",
"OnePidRecordListImpl",
"queryResult",
"(",
"LogRepositoryBrowser",
"browser",
")",
"{",
"return",
"new",
"LogRecordBrowser",
"(",
"browser",
")",
".",
"recordsInProcess",
"(",
"-",
"1",
",",
"-",
"1",
",",
"filter",
")",
";",
"}",
"}",
";",
"}",
"}"
]
| returns log records from the binary repository which satisfy condition of the filter as specified by the parameter. The returned logs
will be from the same server instance. The server instance will be determined by the time as specified by the parameter.
@param time the {@link Date} time value used to determine the server instance where the server start time occurs before this value
and the server stop time occurs after this value
@param filter an instance implementing {@link LogRecordHeaderFilter} interface to verify one record at a time.
@return the iterable list of log records | [
"returns",
"log",
"records",
"from",
"the",
"binary",
"repository",
"which",
"satisfy",
"condition",
"of",
"the",
"filter",
"as",
"specified",
"by",
"the",
"parameter",
".",
"The",
"returned",
"logs",
"will",
"be",
"from",
"the",
"same",
"server",
"instance",
".",
"The",
"server",
"instance",
"will",
"be",
"determined",
"by",
"the",
"time",
"as",
"specified",
"by",
"the",
"parameter",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/websphere/logging/hpel/reader/RepositoryReaderImpl.java#L822-L835 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/os/BundleUtils.java | BundleUtils.optDouble | public static double optDouble(@Nullable Bundle bundle, @Nullable String key, double fallback) {
"""
Returns a optional double value. In other words, returns the value mapped by key if it exists and is a double.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns a fallback value.
@param bundle a bundle. If the bundle is null, this method will return a fallback value.
@param key a key for the value.
@param fallback fallback value.
@return a double value if exists, fallback value otherwise.
@see android.os.Bundle#getDouble(String, double)
"""
if (bundle == null) {
return 0.d;
}
return bundle.getDouble(key, fallback);
} | java | public static double optDouble(@Nullable Bundle bundle, @Nullable String key, double fallback) {
if (bundle == null) {
return 0.d;
}
return bundle.getDouble(key, fallback);
} | [
"public",
"static",
"double",
"optDouble",
"(",
"@",
"Nullable",
"Bundle",
"bundle",
",",
"@",
"Nullable",
"String",
"key",
",",
"double",
"fallback",
")",
"{",
"if",
"(",
"bundle",
"==",
"null",
")",
"{",
"return",
"0.d",
";",
"}",
"return",
"bundle",
".",
"getDouble",
"(",
"key",
",",
"fallback",
")",
";",
"}"
]
| Returns a optional double value. In other words, returns the value mapped by key if it exists and is a double.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns a fallback value.
@param bundle a bundle. If the bundle is null, this method will return a fallback value.
@param key a key for the value.
@param fallback fallback value.
@return a double value if exists, fallback value otherwise.
@see android.os.Bundle#getDouble(String, double) | [
"Returns",
"a",
"optional",
"double",
"value",
".",
"In",
"other",
"words",
"returns",
"the",
"value",
"mapped",
"by",
"key",
"if",
"it",
"exists",
"and",
"is",
"a",
"double",
".",
"The",
"bundle",
"argument",
"is",
"allowed",
"to",
"be",
"{"
]
| train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/os/BundleUtils.java#L438-L443 |
codegist/crest | core/src/main/java/org/codegist/crest/CRest.java | CRest.getOAuthInstance | public static CRest getOAuthInstance(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret, String sessionHandle, String accessTokenRefreshUrl) {
"""
<p>Build a <b>CRest</b> instance that authenticate all request using OAuth.</p>
@param consumerKey consumer key to use
@param consumerSecret consumer secret to use
@param accessToken access token to use
@param accessTokenSecret access token secret to use
@param sessionHandle session handle to use to refresh an expired access token
@param accessTokenRefreshUrl url to use to refresh an expired access token
@return a <b>CRest</b> instance
@see org.codegist.crest.CRestBuilder#oauth(String, String, String, String, String, String)
"""
return oauth(consumerKey, consumerSecret, accessToken, accessTokenSecret, sessionHandle, accessTokenRefreshUrl).build();
} | java | public static CRest getOAuthInstance(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret, String sessionHandle, String accessTokenRefreshUrl) {
return oauth(consumerKey, consumerSecret, accessToken, accessTokenSecret, sessionHandle, accessTokenRefreshUrl).build();
} | [
"public",
"static",
"CRest",
"getOAuthInstance",
"(",
"String",
"consumerKey",
",",
"String",
"consumerSecret",
",",
"String",
"accessToken",
",",
"String",
"accessTokenSecret",
",",
"String",
"sessionHandle",
",",
"String",
"accessTokenRefreshUrl",
")",
"{",
"return",
"oauth",
"(",
"consumerKey",
",",
"consumerSecret",
",",
"accessToken",
",",
"accessTokenSecret",
",",
"sessionHandle",
",",
"accessTokenRefreshUrl",
")",
".",
"build",
"(",
")",
";",
"}"
]
| <p>Build a <b>CRest</b> instance that authenticate all request using OAuth.</p>
@param consumerKey consumer key to use
@param consumerSecret consumer secret to use
@param accessToken access token to use
@param accessTokenSecret access token secret to use
@param sessionHandle session handle to use to refresh an expired access token
@param accessTokenRefreshUrl url to use to refresh an expired access token
@return a <b>CRest</b> instance
@see org.codegist.crest.CRestBuilder#oauth(String, String, String, String, String, String) | [
"<p",
">",
"Build",
"a",
"<b",
">",
"CRest<",
"/",
"b",
">",
"instance",
"that",
"authenticate",
"all",
"request",
"using",
"OAuth",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/codegist/crest/blob/e99ba7728b27d2ddb2c247261350f1b6fa7a6698/core/src/main/java/org/codegist/crest/CRest.java#L115-L117 |
Pi4J/pi4j | pi4j-core/src/main/java/com/pi4j/temperature/TemperatureConversion.java | TemperatureConversion.convertFromFarenheit | public static double convertFromFarenheit (TemperatureScale to, double temperature) {
"""
Convert a temperature value from the Farenheit temperature scale to another.
@param to TemperatureScale
@param temperature value in degrees Farenheit
@return converted temperature value in the requested to scale
"""
switch(to) {
case FARENHEIT:
return temperature;
case CELSIUS:
return convertFarenheitToCelsius(temperature);
case KELVIN:
return convertFarenheitToKelvin(temperature);
case RANKINE:
return convertFarenheitToRankine(temperature);
default:
throw(new RuntimeException("Invalid termpature conversion"));
}
} | java | public static double convertFromFarenheit (TemperatureScale to, double temperature) {
switch(to) {
case FARENHEIT:
return temperature;
case CELSIUS:
return convertFarenheitToCelsius(temperature);
case KELVIN:
return convertFarenheitToKelvin(temperature);
case RANKINE:
return convertFarenheitToRankine(temperature);
default:
throw(new RuntimeException("Invalid termpature conversion"));
}
} | [
"public",
"static",
"double",
"convertFromFarenheit",
"(",
"TemperatureScale",
"to",
",",
"double",
"temperature",
")",
"{",
"switch",
"(",
"to",
")",
"{",
"case",
"FARENHEIT",
":",
"return",
"temperature",
";",
"case",
"CELSIUS",
":",
"return",
"convertFarenheitToCelsius",
"(",
"temperature",
")",
";",
"case",
"KELVIN",
":",
"return",
"convertFarenheitToKelvin",
"(",
"temperature",
")",
";",
"case",
"RANKINE",
":",
"return",
"convertFarenheitToRankine",
"(",
"temperature",
")",
";",
"default",
":",
"throw",
"(",
"new",
"RuntimeException",
"(",
"\"Invalid termpature conversion\"",
")",
")",
";",
"}",
"}"
]
| Convert a temperature value from the Farenheit temperature scale to another.
@param to TemperatureScale
@param temperature value in degrees Farenheit
@return converted temperature value in the requested to scale | [
"Convert",
"a",
"temperature",
"value",
"from",
"the",
"Farenheit",
"temperature",
"scale",
"to",
"another",
"."
]
| train | https://github.com/Pi4J/pi4j/blob/03cacc62223cc59b3118bfcefadabab979fd84c7/pi4j-core/src/main/java/com/pi4j/temperature/TemperatureConversion.java#L73-L88 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java | Types.closureCollector | public Collector<Type, ClosureHolder, List<Type>> closureCollector(boolean minClosure, BiPredicate<Type, Type> shouldSkip) {
"""
Collect types into a new closure (using a @code{ClosureHolder})
"""
return Collector.of(() -> new ClosureHolder(minClosure, shouldSkip),
ClosureHolder::add,
ClosureHolder::merge,
ClosureHolder::closure);
} | java | public Collector<Type, ClosureHolder, List<Type>> closureCollector(boolean minClosure, BiPredicate<Type, Type> shouldSkip) {
return Collector.of(() -> new ClosureHolder(minClosure, shouldSkip),
ClosureHolder::add,
ClosureHolder::merge,
ClosureHolder::closure);
} | [
"public",
"Collector",
"<",
"Type",
",",
"ClosureHolder",
",",
"List",
"<",
"Type",
">",
">",
"closureCollector",
"(",
"boolean",
"minClosure",
",",
"BiPredicate",
"<",
"Type",
",",
"Type",
">",
"shouldSkip",
")",
"{",
"return",
"Collector",
".",
"of",
"(",
"(",
")",
"->",
"new",
"ClosureHolder",
"(",
"minClosure",
",",
"shouldSkip",
")",
",",
"ClosureHolder",
"::",
"add",
",",
"ClosureHolder",
"::",
"merge",
",",
"ClosureHolder",
"::",
"closure",
")",
";",
"}"
]
| Collect types into a new closure (using a @code{ClosureHolder}) | [
"Collect",
"types",
"into",
"a",
"new",
"closure",
"(",
"using",
"a"
]
| train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java#L3436-L3441 |
jbundle/jbundle | base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XButtonBox.java | XButtonBox.printDisplayControl | public void printDisplayControl(PrintWriter out, String strFieldDesc, String strFieldName, String strFieldType) {
"""
Get the current string value in HTML.
@exception DBException File exception.
"""
if (this.getScreenField().getConverter() != null)
{
this.printInputControl(out, strFieldDesc, strFieldName, null, null, null, "button", strFieldType); // Button that does nothing?
}
else if (this.getScreenField().getParentScreen() instanceof GridScreen)
{ // These are command buttons such as "Form" or "Detail"
this.printInputControl(out, null, strFieldName, null, null, null, "button", strFieldType); // Button that does nothing?
}
} | java | public void printDisplayControl(PrintWriter out, String strFieldDesc, String strFieldName, String strFieldType)
{
if (this.getScreenField().getConverter() != null)
{
this.printInputControl(out, strFieldDesc, strFieldName, null, null, null, "button", strFieldType); // Button that does nothing?
}
else if (this.getScreenField().getParentScreen() instanceof GridScreen)
{ // These are command buttons such as "Form" or "Detail"
this.printInputControl(out, null, strFieldName, null, null, null, "button", strFieldType); // Button that does nothing?
}
} | [
"public",
"void",
"printDisplayControl",
"(",
"PrintWriter",
"out",
",",
"String",
"strFieldDesc",
",",
"String",
"strFieldName",
",",
"String",
"strFieldType",
")",
"{",
"if",
"(",
"this",
".",
"getScreenField",
"(",
")",
".",
"getConverter",
"(",
")",
"!=",
"null",
")",
"{",
"this",
".",
"printInputControl",
"(",
"out",
",",
"strFieldDesc",
",",
"strFieldName",
",",
"null",
",",
"null",
",",
"null",
",",
"\"button\"",
",",
"strFieldType",
")",
";",
"// Button that does nothing?",
"}",
"else",
"if",
"(",
"this",
".",
"getScreenField",
"(",
")",
".",
"getParentScreen",
"(",
")",
"instanceof",
"GridScreen",
")",
"{",
"// These are command buttons such as \"Form\" or \"Detail\"",
"this",
".",
"printInputControl",
"(",
"out",
",",
"null",
",",
"strFieldName",
",",
"null",
",",
"null",
",",
"null",
",",
"\"button\"",
",",
"strFieldType",
")",
";",
"// Button that does nothing?",
"}",
"}"
]
| Get the current string value in HTML.
@exception DBException File exception. | [
"Get",
"the",
"current",
"string",
"value",
"in",
"HTML",
"."
]
| train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XButtonBox.java#L200-L210 |
joniles/mpxj | src/main/java/net/sf/mpxj/mspdi/MSPDIWriter.java | MSPDIWriter.writeExceptions12 | private void writeExceptions12(Project.Calendars.Calendar calendar, List<ProjectCalendarException> exceptions) {
"""
Write exceptions into the format used by MSPDI files from
Project 2007 onwards.
@param calendar parent calendar
@param exceptions list of exceptions
"""
Exceptions ce = m_factory.createProjectCalendarsCalendarExceptions();
calendar.setExceptions(ce);
List<Exceptions.Exception> el = ce.getException();
for (ProjectCalendarException exception : exceptions)
{
Exceptions.Exception ex = m_factory.createProjectCalendarsCalendarExceptionsException();
el.add(ex);
ex.setName(exception.getName());
boolean working = exception.getWorking();
ex.setDayWorking(Boolean.valueOf(working));
if (exception.getRecurring() == null)
{
ex.setEnteredByOccurrences(Boolean.FALSE);
ex.setOccurrences(BigInteger.ONE);
ex.setType(BigInteger.ONE);
}
else
{
populateRecurringException(exception, ex);
}
Project.Calendars.Calendar.Exceptions.Exception.TimePeriod period = m_factory.createProjectCalendarsCalendarExceptionsExceptionTimePeriod();
ex.setTimePeriod(period);
period.setFromDate(exception.getFromDate());
period.setToDate(exception.getToDate());
if (working)
{
Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes times = m_factory.createProjectCalendarsCalendarExceptionsExceptionWorkingTimes();
ex.setWorkingTimes(times);
List<Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime> timesList = times.getWorkingTime();
for (DateRange range : exception)
{
Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime time = m_factory.createProjectCalendarsCalendarExceptionsExceptionWorkingTimesWorkingTime();
timesList.add(time);
time.setFromTime(range.getStart());
time.setToTime(range.getEnd());
}
}
}
} | java | private void writeExceptions12(Project.Calendars.Calendar calendar, List<ProjectCalendarException> exceptions)
{
Exceptions ce = m_factory.createProjectCalendarsCalendarExceptions();
calendar.setExceptions(ce);
List<Exceptions.Exception> el = ce.getException();
for (ProjectCalendarException exception : exceptions)
{
Exceptions.Exception ex = m_factory.createProjectCalendarsCalendarExceptionsException();
el.add(ex);
ex.setName(exception.getName());
boolean working = exception.getWorking();
ex.setDayWorking(Boolean.valueOf(working));
if (exception.getRecurring() == null)
{
ex.setEnteredByOccurrences(Boolean.FALSE);
ex.setOccurrences(BigInteger.ONE);
ex.setType(BigInteger.ONE);
}
else
{
populateRecurringException(exception, ex);
}
Project.Calendars.Calendar.Exceptions.Exception.TimePeriod period = m_factory.createProjectCalendarsCalendarExceptionsExceptionTimePeriod();
ex.setTimePeriod(period);
period.setFromDate(exception.getFromDate());
period.setToDate(exception.getToDate());
if (working)
{
Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes times = m_factory.createProjectCalendarsCalendarExceptionsExceptionWorkingTimes();
ex.setWorkingTimes(times);
List<Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime> timesList = times.getWorkingTime();
for (DateRange range : exception)
{
Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime time = m_factory.createProjectCalendarsCalendarExceptionsExceptionWorkingTimesWorkingTime();
timesList.add(time);
time.setFromTime(range.getStart());
time.setToTime(range.getEnd());
}
}
}
} | [
"private",
"void",
"writeExceptions12",
"(",
"Project",
".",
"Calendars",
".",
"Calendar",
"calendar",
",",
"List",
"<",
"ProjectCalendarException",
">",
"exceptions",
")",
"{",
"Exceptions",
"ce",
"=",
"m_factory",
".",
"createProjectCalendarsCalendarExceptions",
"(",
")",
";",
"calendar",
".",
"setExceptions",
"(",
"ce",
")",
";",
"List",
"<",
"Exceptions",
".",
"Exception",
">",
"el",
"=",
"ce",
".",
"getException",
"(",
")",
";",
"for",
"(",
"ProjectCalendarException",
"exception",
":",
"exceptions",
")",
"{",
"Exceptions",
".",
"Exception",
"ex",
"=",
"m_factory",
".",
"createProjectCalendarsCalendarExceptionsException",
"(",
")",
";",
"el",
".",
"add",
"(",
"ex",
")",
";",
"ex",
".",
"setName",
"(",
"exception",
".",
"getName",
"(",
")",
")",
";",
"boolean",
"working",
"=",
"exception",
".",
"getWorking",
"(",
")",
";",
"ex",
".",
"setDayWorking",
"(",
"Boolean",
".",
"valueOf",
"(",
"working",
")",
")",
";",
"if",
"(",
"exception",
".",
"getRecurring",
"(",
")",
"==",
"null",
")",
"{",
"ex",
".",
"setEnteredByOccurrences",
"(",
"Boolean",
".",
"FALSE",
")",
";",
"ex",
".",
"setOccurrences",
"(",
"BigInteger",
".",
"ONE",
")",
";",
"ex",
".",
"setType",
"(",
"BigInteger",
".",
"ONE",
")",
";",
"}",
"else",
"{",
"populateRecurringException",
"(",
"exception",
",",
"ex",
")",
";",
"}",
"Project",
".",
"Calendars",
".",
"Calendar",
".",
"Exceptions",
".",
"Exception",
".",
"TimePeriod",
"period",
"=",
"m_factory",
".",
"createProjectCalendarsCalendarExceptionsExceptionTimePeriod",
"(",
")",
";",
"ex",
".",
"setTimePeriod",
"(",
"period",
")",
";",
"period",
".",
"setFromDate",
"(",
"exception",
".",
"getFromDate",
"(",
")",
")",
";",
"period",
".",
"setToDate",
"(",
"exception",
".",
"getToDate",
"(",
")",
")",
";",
"if",
"(",
"working",
")",
"{",
"Project",
".",
"Calendars",
".",
"Calendar",
".",
"Exceptions",
".",
"Exception",
".",
"WorkingTimes",
"times",
"=",
"m_factory",
".",
"createProjectCalendarsCalendarExceptionsExceptionWorkingTimes",
"(",
")",
";",
"ex",
".",
"setWorkingTimes",
"(",
"times",
")",
";",
"List",
"<",
"Project",
".",
"Calendars",
".",
"Calendar",
".",
"Exceptions",
".",
"Exception",
".",
"WorkingTimes",
".",
"WorkingTime",
">",
"timesList",
"=",
"times",
".",
"getWorkingTime",
"(",
")",
";",
"for",
"(",
"DateRange",
"range",
":",
"exception",
")",
"{",
"Project",
".",
"Calendars",
".",
"Calendar",
".",
"Exceptions",
".",
"Exception",
".",
"WorkingTimes",
".",
"WorkingTime",
"time",
"=",
"m_factory",
".",
"createProjectCalendarsCalendarExceptionsExceptionWorkingTimesWorkingTime",
"(",
")",
";",
"timesList",
".",
"add",
"(",
"time",
")",
";",
"time",
".",
"setFromTime",
"(",
"range",
".",
"getStart",
"(",
")",
")",
";",
"time",
".",
"setToTime",
"(",
"range",
".",
"getEnd",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
]
| Write exceptions into the format used by MSPDI files from
Project 2007 onwards.
@param calendar parent calendar
@param exceptions list of exceptions | [
"Write",
"exceptions",
"into",
"the",
"format",
"used",
"by",
"MSPDI",
"files",
"from",
"Project",
"2007",
"onwards",
"."
]
| train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mspdi/MSPDIWriter.java#L529-L576 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ImageModerationsImpl.java | ImageModerationsImpl.oCRMethodWithServiceResponseAsync | public Observable<ServiceResponse<OCR>> oCRMethodWithServiceResponseAsync(String language, OCRMethodOptionalParameter oCRMethodOptionalParameter) {
"""
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
@param language Language of the terms.
@param oCRMethodOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OCR object
"""
if (this.client.baseUrl() == null) {
throw new IllegalArgumentException("Parameter this.client.baseUrl() is required and cannot be null.");
}
if (language == null) {
throw new IllegalArgumentException("Parameter language is required and cannot be null.");
}
final Boolean cacheImage = oCRMethodOptionalParameter != null ? oCRMethodOptionalParameter.cacheImage() : null;
final Boolean enhanced = oCRMethodOptionalParameter != null ? oCRMethodOptionalParameter.enhanced() : null;
return oCRMethodWithServiceResponseAsync(language, cacheImage, enhanced);
} | java | public Observable<ServiceResponse<OCR>> oCRMethodWithServiceResponseAsync(String language, OCRMethodOptionalParameter oCRMethodOptionalParameter) {
if (this.client.baseUrl() == null) {
throw new IllegalArgumentException("Parameter this.client.baseUrl() is required and cannot be null.");
}
if (language == null) {
throw new IllegalArgumentException("Parameter language is required and cannot be null.");
}
final Boolean cacheImage = oCRMethodOptionalParameter != null ? oCRMethodOptionalParameter.cacheImage() : null;
final Boolean enhanced = oCRMethodOptionalParameter != null ? oCRMethodOptionalParameter.enhanced() : null;
return oCRMethodWithServiceResponseAsync(language, cacheImage, enhanced);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"OCR",
">",
">",
"oCRMethodWithServiceResponseAsync",
"(",
"String",
"language",
",",
"OCRMethodOptionalParameter",
"oCRMethodOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"baseUrl",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.baseUrl() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"language",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter language is required and cannot be null.\"",
")",
";",
"}",
"final",
"Boolean",
"cacheImage",
"=",
"oCRMethodOptionalParameter",
"!=",
"null",
"?",
"oCRMethodOptionalParameter",
".",
"cacheImage",
"(",
")",
":",
"null",
";",
"final",
"Boolean",
"enhanced",
"=",
"oCRMethodOptionalParameter",
"!=",
"null",
"?",
"oCRMethodOptionalParameter",
".",
"enhanced",
"(",
")",
":",
"null",
";",
"return",
"oCRMethodWithServiceResponseAsync",
"(",
"language",
",",
"cacheImage",
",",
"enhanced",
")",
";",
"}"
]
| Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
@param language Language of the terms.
@param oCRMethodOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OCR object | [
"Returns",
"any",
"text",
"found",
"in",
"the",
"image",
"for",
"the",
"language",
"specified",
".",
"If",
"no",
"language",
"is",
"specified",
"in",
"input",
"then",
"the",
"detection",
"defaults",
"to",
"English",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ImageModerationsImpl.java#L312-L323 |
DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/webhook/WebhookMessageBuilder.java | WebhookMessageBuilder.addFile | public WebhookMessageBuilder addFile(String name, byte[] data) {
"""
Adds the provided file to the resulting message.
@param name
The name to use for this file
@param data
The file data to add
@throws IllegalArgumentException
If the provided name data is null
@throws IllegalStateException
If the file limit has already been reached
@return The current WebhookMessageBuilder for chaining convenience
@see #resetFiles()
"""
Checks.notNull(data, "Data");
Checks.notBlank(name, "Name");
if (fileIndex >= MAX_FILES)
throw new IllegalStateException("Cannot add more than " + MAX_FILES + " attachments to a message");
MessageAttachment attachment = new MessageAttachment(name, data);
files[fileIndex++] = attachment;
return this;
} | java | public WebhookMessageBuilder addFile(String name, byte[] data)
{
Checks.notNull(data, "Data");
Checks.notBlank(name, "Name");
if (fileIndex >= MAX_FILES)
throw new IllegalStateException("Cannot add more than " + MAX_FILES + " attachments to a message");
MessageAttachment attachment = new MessageAttachment(name, data);
files[fileIndex++] = attachment;
return this;
} | [
"public",
"WebhookMessageBuilder",
"addFile",
"(",
"String",
"name",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"Checks",
".",
"notNull",
"(",
"data",
",",
"\"Data\"",
")",
";",
"Checks",
".",
"notBlank",
"(",
"name",
",",
"\"Name\"",
")",
";",
"if",
"(",
"fileIndex",
">=",
"MAX_FILES",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot add more than \"",
"+",
"MAX_FILES",
"+",
"\" attachments to a message\"",
")",
";",
"MessageAttachment",
"attachment",
"=",
"new",
"MessageAttachment",
"(",
"name",
",",
"data",
")",
";",
"files",
"[",
"fileIndex",
"++",
"]",
"=",
"attachment",
";",
"return",
"this",
";",
"}"
]
| Adds the provided file to the resulting message.
@param name
The name to use for this file
@param data
The file data to add
@throws IllegalArgumentException
If the provided name data is null
@throws IllegalStateException
If the file limit has already been reached
@return The current WebhookMessageBuilder for chaining convenience
@see #resetFiles() | [
"Adds",
"the",
"provided",
"file",
"to",
"the",
"resulting",
"message",
"."
]
| train | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/webhook/WebhookMessageBuilder.java#L343-L353 |
GwtMaterialDesign/gwt-material | gwt-material/src/main/java/gwt/material/design/client/ui/MaterialRange.java | MaterialRange.setIntToRangeElement | protected void setIntToRangeElement(String attribute, Integer val) {
"""
Set the given Integer value to the attribute of the range element.
"""
Element ele = $(rangeInputElement).asElement();
if (ele != null) {
ele.setPropertyInt(attribute, val);
}
} | java | protected void setIntToRangeElement(String attribute, Integer val) {
Element ele = $(rangeInputElement).asElement();
if (ele != null) {
ele.setPropertyInt(attribute, val);
}
} | [
"protected",
"void",
"setIntToRangeElement",
"(",
"String",
"attribute",
",",
"Integer",
"val",
")",
"{",
"Element",
"ele",
"=",
"$",
"(",
"rangeInputElement",
")",
".",
"asElement",
"(",
")",
";",
"if",
"(",
"ele",
"!=",
"null",
")",
"{",
"ele",
".",
"setPropertyInt",
"(",
"attribute",
",",
"val",
")",
";",
"}",
"}"
]
| Set the given Integer value to the attribute of the range element. | [
"Set",
"the",
"given",
"Integer",
"value",
"to",
"the",
"attribute",
"of",
"the",
"range",
"element",
"."
]
| train | https://github.com/GwtMaterialDesign/gwt-material/blob/86feefb282b007c0a44784c09e651a50f257138e/gwt-material/src/main/java/gwt/material/design/client/ui/MaterialRange.java#L131-L136 |
Scout24/appmon4j | core/src/main/java/de/is24/util/monitoring/wrapper/GenericMonitoringWrapper.java | GenericMonitoringWrapper.wrapObject | @SuppressWarnings("unchecked")
public static <E> E wrapObject(final Class<E> clazz, final Object target, final TimingReporter timingReporter) {
"""
Wraps the given object and returns the reporting proxy. Uses the given
timing reporter to report timings.
@param <E>
the type of the public interface of the wrapped object
@param clazz
the class object to the interface
@param target
the object to wrap
@param timingReporter
the reporter to report timing information to
@return the monitoring wrapper
"""
return (E) Proxy.newProxyInstance(GenericMonitoringWrapper.class.getClassLoader(),
new Class[] { clazz },
new GenericMonitoringWrapper<E>(clazz, target, timingReporter));
} | java | @SuppressWarnings("unchecked")
public static <E> E wrapObject(final Class<E> clazz, final Object target, final TimingReporter timingReporter) {
return (E) Proxy.newProxyInstance(GenericMonitoringWrapper.class.getClassLoader(),
new Class[] { clazz },
new GenericMonitoringWrapper<E>(clazz, target, timingReporter));
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"E",
">",
"E",
"wrapObject",
"(",
"final",
"Class",
"<",
"E",
">",
"clazz",
",",
"final",
"Object",
"target",
",",
"final",
"TimingReporter",
"timingReporter",
")",
"{",
"return",
"(",
"E",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"GenericMonitoringWrapper",
".",
"class",
".",
"getClassLoader",
"(",
")",
",",
"new",
"Class",
"[",
"]",
"{",
"clazz",
"}",
",",
"new",
"GenericMonitoringWrapper",
"<",
"E",
">",
"(",
"clazz",
",",
"target",
",",
"timingReporter",
")",
")",
";",
"}"
]
| Wraps the given object and returns the reporting proxy. Uses the given
timing reporter to report timings.
@param <E>
the type of the public interface of the wrapped object
@param clazz
the class object to the interface
@param target
the object to wrap
@param timingReporter
the reporter to report timing information to
@return the monitoring wrapper | [
"Wraps",
"the",
"given",
"object",
"and",
"returns",
"the",
"reporting",
"proxy",
".",
"Uses",
"the",
"given",
"timing",
"reporter",
"to",
"report",
"timings",
"."
]
| train | https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/wrapper/GenericMonitoringWrapper.java#L86-L91 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/util/SequentialWriter.java | SequentialWriter.writeAtMost | private int writeAtMost(byte[] data, int offset, int length) {
"""
/*
Write at most "length" bytes from "data" starting at position "offset", and
return the number of bytes written. caller is responsible for setting
isDirty.
"""
if (current >= bufferOffset + buffer.length)
reBuffer();
assert current < bufferOffset + buffer.length
: String.format("File (%s) offset %d, buffer offset %d.", getPath(), current, bufferOffset);
int toCopy = Math.min(length, buffer.length - bufferCursor());
// copy bytes from external buffer
System.arraycopy(data, offset, buffer, bufferCursor(), toCopy);
assert current <= bufferOffset + buffer.length
: String.format("File (%s) offset %d, buffer offset %d.", getPath(), current, bufferOffset);
validBufferBytes = Math.max(validBufferBytes, bufferCursor() + toCopy);
current += toCopy;
return toCopy;
} | java | private int writeAtMost(byte[] data, int offset, int length)
{
if (current >= bufferOffset + buffer.length)
reBuffer();
assert current < bufferOffset + buffer.length
: String.format("File (%s) offset %d, buffer offset %d.", getPath(), current, bufferOffset);
int toCopy = Math.min(length, buffer.length - bufferCursor());
// copy bytes from external buffer
System.arraycopy(data, offset, buffer, bufferCursor(), toCopy);
assert current <= bufferOffset + buffer.length
: String.format("File (%s) offset %d, buffer offset %d.", getPath(), current, bufferOffset);
validBufferBytes = Math.max(validBufferBytes, bufferCursor() + toCopy);
current += toCopy;
return toCopy;
} | [
"private",
"int",
"writeAtMost",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"if",
"(",
"current",
">=",
"bufferOffset",
"+",
"buffer",
".",
"length",
")",
"reBuffer",
"(",
")",
";",
"assert",
"current",
"<",
"bufferOffset",
"+",
"buffer",
".",
"length",
":",
"String",
".",
"format",
"(",
"\"File (%s) offset %d, buffer offset %d.\"",
",",
"getPath",
"(",
")",
",",
"current",
",",
"bufferOffset",
")",
";",
"int",
"toCopy",
"=",
"Math",
".",
"min",
"(",
"length",
",",
"buffer",
".",
"length",
"-",
"bufferCursor",
"(",
")",
")",
";",
"// copy bytes from external buffer",
"System",
".",
"arraycopy",
"(",
"data",
",",
"offset",
",",
"buffer",
",",
"bufferCursor",
"(",
")",
",",
"toCopy",
")",
";",
"assert",
"current",
"<=",
"bufferOffset",
"+",
"buffer",
".",
"length",
":",
"String",
".",
"format",
"(",
"\"File (%s) offset %d, buffer offset %d.\"",
",",
"getPath",
"(",
")",
",",
"current",
",",
"bufferOffset",
")",
";",
"validBufferBytes",
"=",
"Math",
".",
"max",
"(",
"validBufferBytes",
",",
"bufferCursor",
"(",
")",
"+",
"toCopy",
")",
";",
"current",
"+=",
"toCopy",
";",
"return",
"toCopy",
";",
"}"
]
| /*
Write at most "length" bytes from "data" starting at position "offset", and
return the number of bytes written. caller is responsible for setting
isDirty. | [
"/",
"*",
"Write",
"at",
"most",
"length",
"bytes",
"from",
"data",
"starting",
"at",
"position",
"offset",
"and",
"return",
"the",
"number",
"of",
"bytes",
"written",
".",
"caller",
"is",
"responsible",
"for",
"setting",
"isDirty",
"."
]
| train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/util/SequentialWriter.java#L215-L236 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/chains/EndPointMgrImpl.java | EndPointMgrImpl.updateEndpointMBean | private EndPointInfoImpl updateEndpointMBean(String name, String host, int port) {
"""
Update an existing endpoint MBean, which will emit change notifications.
@param name The name of the EndPoint which was updated
@param host The current host value (may or may not have changed)
@param port The current port value (may or may not have changed)
"""
EndPointInfoImpl existingEP = endpoints.get(name);
existingEP.updateHost(host);
existingEP.updatePort(port);
return existingEP;
} | java | private EndPointInfoImpl updateEndpointMBean(String name, String host, int port) {
EndPointInfoImpl existingEP = endpoints.get(name);
existingEP.updateHost(host);
existingEP.updatePort(port);
return existingEP;
} | [
"private",
"EndPointInfoImpl",
"updateEndpointMBean",
"(",
"String",
"name",
",",
"String",
"host",
",",
"int",
"port",
")",
"{",
"EndPointInfoImpl",
"existingEP",
"=",
"endpoints",
".",
"get",
"(",
"name",
")",
";",
"existingEP",
".",
"updateHost",
"(",
"host",
")",
";",
"existingEP",
".",
"updatePort",
"(",
"port",
")",
";",
"return",
"existingEP",
";",
"}"
]
| Update an existing endpoint MBean, which will emit change notifications.
@param name The name of the EndPoint which was updated
@param host The current host value (may or may not have changed)
@param port The current port value (may or may not have changed) | [
"Update",
"an",
"existing",
"endpoint",
"MBean",
"which",
"will",
"emit",
"change",
"notifications",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/chains/EndPointMgrImpl.java#L145-L150 |
h2oai/h2o-3 | h2o-parsers/h2o-orc-parser/src/main/java/water/parser/orc/OrcParser.java | OrcParser.write1column | private void write1column(ColumnVector oneColumn, String columnType, int cIdx, int rowNumber,ParseWriter dout) {
"""
This method writes one column of H2O data frame at a time.
@param oneColumn
@param columnType
@param cIdx
@param rowNumber
@param dout
"""
if(oneColumn.isRepeating && !oneColumn.noNulls) { // ALL NAs
for(int i = 0; i < rowNumber; ++i)
dout.addInvalidCol(cIdx);
} else switch (columnType.toLowerCase()) {
case "bigint":
case "boolean":
case "int":
case "smallint":
case "tinyint":
writeLongcolumn((LongColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
case "float":
case "double":
writeDoublecolumn((DoubleColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
case "numeric":
case "real":
if (oneColumn instanceof LongColumnVector)
writeLongcolumn((LongColumnVector)oneColumn, cIdx, rowNumber, dout);
else
writeDoublecolumn((DoubleColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
case "string":
case "varchar":
case "char":
// case "binary": //FIXME: only reading it as string right now.
writeStringcolumn((BytesColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
case "date":
case "timestamp":
writeTimecolumn((LongColumnVector)oneColumn, columnType, cIdx, rowNumber, dout);
break;
case "decimal":
writeDecimalcolumn((DecimalColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
default:
throw new IllegalArgumentException("Unsupported Orc schema type: " + columnType);
}
} | java | private void write1column(ColumnVector oneColumn, String columnType, int cIdx, int rowNumber,ParseWriter dout) {
if(oneColumn.isRepeating && !oneColumn.noNulls) { // ALL NAs
for(int i = 0; i < rowNumber; ++i)
dout.addInvalidCol(cIdx);
} else switch (columnType.toLowerCase()) {
case "bigint":
case "boolean":
case "int":
case "smallint":
case "tinyint":
writeLongcolumn((LongColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
case "float":
case "double":
writeDoublecolumn((DoubleColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
case "numeric":
case "real":
if (oneColumn instanceof LongColumnVector)
writeLongcolumn((LongColumnVector)oneColumn, cIdx, rowNumber, dout);
else
writeDoublecolumn((DoubleColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
case "string":
case "varchar":
case "char":
// case "binary": //FIXME: only reading it as string right now.
writeStringcolumn((BytesColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
case "date":
case "timestamp":
writeTimecolumn((LongColumnVector)oneColumn, columnType, cIdx, rowNumber, dout);
break;
case "decimal":
writeDecimalcolumn((DecimalColumnVector)oneColumn, cIdx, rowNumber, dout);
break;
default:
throw new IllegalArgumentException("Unsupported Orc schema type: " + columnType);
}
} | [
"private",
"void",
"write1column",
"(",
"ColumnVector",
"oneColumn",
",",
"String",
"columnType",
",",
"int",
"cIdx",
",",
"int",
"rowNumber",
",",
"ParseWriter",
"dout",
")",
"{",
"if",
"(",
"oneColumn",
".",
"isRepeating",
"&&",
"!",
"oneColumn",
".",
"noNulls",
")",
"{",
"// ALL NAs",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"rowNumber",
";",
"++",
"i",
")",
"dout",
".",
"addInvalidCol",
"(",
"cIdx",
")",
";",
"}",
"else",
"switch",
"(",
"columnType",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"\"bigint\"",
":",
"case",
"\"boolean\"",
":",
"case",
"\"int\"",
":",
"case",
"\"smallint\"",
":",
"case",
"\"tinyint\"",
":",
"writeLongcolumn",
"(",
"(",
"LongColumnVector",
")",
"oneColumn",
",",
"cIdx",
",",
"rowNumber",
",",
"dout",
")",
";",
"break",
";",
"case",
"\"float\"",
":",
"case",
"\"double\"",
":",
"writeDoublecolumn",
"(",
"(",
"DoubleColumnVector",
")",
"oneColumn",
",",
"cIdx",
",",
"rowNumber",
",",
"dout",
")",
";",
"break",
";",
"case",
"\"numeric\"",
":",
"case",
"\"real\"",
":",
"if",
"(",
"oneColumn",
"instanceof",
"LongColumnVector",
")",
"writeLongcolumn",
"(",
"(",
"LongColumnVector",
")",
"oneColumn",
",",
"cIdx",
",",
"rowNumber",
",",
"dout",
")",
";",
"else",
"writeDoublecolumn",
"(",
"(",
"DoubleColumnVector",
")",
"oneColumn",
",",
"cIdx",
",",
"rowNumber",
",",
"dout",
")",
";",
"break",
";",
"case",
"\"string\"",
":",
"case",
"\"varchar\"",
":",
"case",
"\"char\"",
":",
"// case \"binary\": //FIXME: only reading it as string right now.",
"writeStringcolumn",
"(",
"(",
"BytesColumnVector",
")",
"oneColumn",
",",
"cIdx",
",",
"rowNumber",
",",
"dout",
")",
";",
"break",
";",
"case",
"\"date\"",
":",
"case",
"\"timestamp\"",
":",
"writeTimecolumn",
"(",
"(",
"LongColumnVector",
")",
"oneColumn",
",",
"columnType",
",",
"cIdx",
",",
"rowNumber",
",",
"dout",
")",
";",
"break",
";",
"case",
"\"decimal\"",
":",
"writeDecimalcolumn",
"(",
"(",
"DecimalColumnVector",
")",
"oneColumn",
",",
"cIdx",
",",
"rowNumber",
",",
"dout",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported Orc schema type: \"",
"+",
"columnType",
")",
";",
"}",
"}"
]
| This method writes one column of H2O data frame at a time.
@param oneColumn
@param columnType
@param cIdx
@param rowNumber
@param dout | [
"This",
"method",
"writes",
"one",
"column",
"of",
"H2O",
"data",
"frame",
"at",
"a",
"time",
"."
]
| train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-parsers/h2o-orc-parser/src/main/java/water/parser/orc/OrcParser.java#L165-L204 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/TaiwanCalendar.java | TaiwanCalendar.handleGetLimit | protected int handleGetLimit(int field, int limitType) {
"""
Override GregorianCalendar. There is only one Taiwan ERA. We
should really handle YEAR, YEAR_WOY, and EXTENDED_YEAR here too to
implement the 1..5000000 range, but it's not critical.
"""
if (field == ERA) {
if (limitType == MINIMUM || limitType == GREATEST_MINIMUM) {
return BEFORE_MINGUO;
} else {
return MINGUO;
}
}
return super.handleGetLimit(field, limitType);
} | java | protected int handleGetLimit(int field, int limitType) {
if (field == ERA) {
if (limitType == MINIMUM || limitType == GREATEST_MINIMUM) {
return BEFORE_MINGUO;
} else {
return MINGUO;
}
}
return super.handleGetLimit(field, limitType);
} | [
"protected",
"int",
"handleGetLimit",
"(",
"int",
"field",
",",
"int",
"limitType",
")",
"{",
"if",
"(",
"field",
"==",
"ERA",
")",
"{",
"if",
"(",
"limitType",
"==",
"MINIMUM",
"||",
"limitType",
"==",
"GREATEST_MINIMUM",
")",
"{",
"return",
"BEFORE_MINGUO",
";",
"}",
"else",
"{",
"return",
"MINGUO",
";",
"}",
"}",
"return",
"super",
".",
"handleGetLimit",
"(",
"field",
",",
"limitType",
")",
";",
"}"
]
| Override GregorianCalendar. There is only one Taiwan ERA. We
should really handle YEAR, YEAR_WOY, and EXTENDED_YEAR here too to
implement the 1..5000000 range, but it's not critical. | [
"Override",
"GregorianCalendar",
".",
"There",
"is",
"only",
"one",
"Taiwan",
"ERA",
".",
"We",
"should",
"really",
"handle",
"YEAR",
"YEAR_WOY",
"and",
"EXTENDED_YEAR",
"here",
"too",
"to",
"implement",
"the",
"1",
"..",
"5000000",
"range",
"but",
"it",
"s",
"not",
"critical",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/TaiwanCalendar.java#L221-L230 |
Sciss/abc4j | abc/src/main/java/abc/ui/swing/JTune.java | JTune.newControl | static protected Point2D newControl (Point2D start, Point2D ctrl, Point2D end) {
"""
implementation found at
http://forum.java.sun.com/thread.jspa?threadID=609888&messageID=3362448
This enables the bezier curve to be tangent to the control point.
"""
Point2D.Double newCtrl = new Point2D.Double();
newCtrl.x = 2 * ctrl.getX() - (start.getX() + end.getX()) / 2;
newCtrl.y = 2 * ctrl.getY() - (start.getY() + end.getY()) / 2;
return newCtrl;
} | java | static protected Point2D newControl (Point2D start, Point2D ctrl, Point2D end) {
Point2D.Double newCtrl = new Point2D.Double();
newCtrl.x = 2 * ctrl.getX() - (start.getX() + end.getX()) / 2;
newCtrl.y = 2 * ctrl.getY() - (start.getY() + end.getY()) / 2;
return newCtrl;
} | [
"static",
"protected",
"Point2D",
"newControl",
"(",
"Point2D",
"start",
",",
"Point2D",
"ctrl",
",",
"Point2D",
"end",
")",
"{",
"Point2D",
".",
"Double",
"newCtrl",
"=",
"new",
"Point2D",
".",
"Double",
"(",
")",
";",
"newCtrl",
".",
"x",
"=",
"2",
"*",
"ctrl",
".",
"getX",
"(",
")",
"-",
"(",
"start",
".",
"getX",
"(",
")",
"+",
"end",
".",
"getX",
"(",
")",
")",
"/",
"2",
";",
"newCtrl",
".",
"y",
"=",
"2",
"*",
"ctrl",
".",
"getY",
"(",
")",
"-",
"(",
"start",
".",
"getY",
"(",
")",
"+",
"end",
".",
"getY",
"(",
")",
")",
"/",
"2",
";",
"return",
"newCtrl",
";",
"}"
]
| implementation found at
http://forum.java.sun.com/thread.jspa?threadID=609888&messageID=3362448
This enables the bezier curve to be tangent to the control point. | [
"implementation",
"found",
"at",
"http",
":",
"//",
"forum",
".",
"java",
".",
"sun",
".",
"com",
"/",
"thread",
".",
"jspa?threadID",
"=",
"609888&messageID",
"=",
"3362448",
"This",
"enables",
"the",
"bezier",
"curve",
"to",
"be",
"tangent",
"to",
"the",
"control",
"point",
"."
]
| train | https://github.com/Sciss/abc4j/blob/117b405642c84a7bfca4e3e13668838258b90ca7/abc/src/main/java/abc/ui/swing/JTune.java#L1630-L1635 |
tempodb/tempodb-java | src/main/java/com/tempodb/Client.java | Client.readDataPoints | public Cursor<DataPoint> readDataPoints(Series series, Interval interval, DateTimeZone timezone, Rollup rollup, Interpolation interpolation) {
"""
Returns a cursor of datapoints specified by series.
@param series The series
@param interval An interval of time for the query (start/end datetimes)
@param timezone The time zone for the returned datapoints.
@param rollup The rollup for the read query. This can be null.
@param interpolation The interpolation for the read query. This can be null.
@return A Cursor of DataPoints. The cursor.iterator().next() may throw a {@link TempoDBException} if an error occurs while making a request.
@see Cursor
@since 1.0.0
"""
checkNotNull(series);
checkNotNull(interval);
checkNotNull(timezone);
URI uri = null;
try {
URIBuilder builder = new URIBuilder(String.format("/%s/series/key/%s/segment/", API_VERSION, urlencode(series.getKey())));
addInterpolationToURI(builder, interpolation);
addIntervalToURI(builder, interval);
addRollupToURI(builder, rollup);
addTimeZoneToURI(builder, timezone);
uri = builder.build();
} catch (URISyntaxException e) {
String message = String.format("Could not build URI with inputs: key: %s, interval: %s, rollup: %s, timezone: %s", series.getKey(), interval, rollup, timezone);
throw new IllegalArgumentException(message, e);
}
Cursor<DataPoint> cursor = new DataPointCursor(uri, this);
return cursor;
} | java | public Cursor<DataPoint> readDataPoints(Series series, Interval interval, DateTimeZone timezone, Rollup rollup, Interpolation interpolation) {
checkNotNull(series);
checkNotNull(interval);
checkNotNull(timezone);
URI uri = null;
try {
URIBuilder builder = new URIBuilder(String.format("/%s/series/key/%s/segment/", API_VERSION, urlencode(series.getKey())));
addInterpolationToURI(builder, interpolation);
addIntervalToURI(builder, interval);
addRollupToURI(builder, rollup);
addTimeZoneToURI(builder, timezone);
uri = builder.build();
} catch (URISyntaxException e) {
String message = String.format("Could not build URI with inputs: key: %s, interval: %s, rollup: %s, timezone: %s", series.getKey(), interval, rollup, timezone);
throw new IllegalArgumentException(message, e);
}
Cursor<DataPoint> cursor = new DataPointCursor(uri, this);
return cursor;
} | [
"public",
"Cursor",
"<",
"DataPoint",
">",
"readDataPoints",
"(",
"Series",
"series",
",",
"Interval",
"interval",
",",
"DateTimeZone",
"timezone",
",",
"Rollup",
"rollup",
",",
"Interpolation",
"interpolation",
")",
"{",
"checkNotNull",
"(",
"series",
")",
";",
"checkNotNull",
"(",
"interval",
")",
";",
"checkNotNull",
"(",
"timezone",
")",
";",
"URI",
"uri",
"=",
"null",
";",
"try",
"{",
"URIBuilder",
"builder",
"=",
"new",
"URIBuilder",
"(",
"String",
".",
"format",
"(",
"\"/%s/series/key/%s/segment/\"",
",",
"API_VERSION",
",",
"urlencode",
"(",
"series",
".",
"getKey",
"(",
")",
")",
")",
")",
";",
"addInterpolationToURI",
"(",
"builder",
",",
"interpolation",
")",
";",
"addIntervalToURI",
"(",
"builder",
",",
"interval",
")",
";",
"addRollupToURI",
"(",
"builder",
",",
"rollup",
")",
";",
"addTimeZoneToURI",
"(",
"builder",
",",
"timezone",
")",
";",
"uri",
"=",
"builder",
".",
"build",
"(",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Could not build URI with inputs: key: %s, interval: %s, rollup: %s, timezone: %s\"",
",",
"series",
".",
"getKey",
"(",
")",
",",
"interval",
",",
"rollup",
",",
"timezone",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
",",
"e",
")",
";",
"}",
"Cursor",
"<",
"DataPoint",
">",
"cursor",
"=",
"new",
"DataPointCursor",
"(",
"uri",
",",
"this",
")",
";",
"return",
"cursor",
";",
"}"
]
| Returns a cursor of datapoints specified by series.
@param series The series
@param interval An interval of time for the query (start/end datetimes)
@param timezone The time zone for the returned datapoints.
@param rollup The rollup for the read query. This can be null.
@param interpolation The interpolation for the read query. This can be null.
@return A Cursor of DataPoints. The cursor.iterator().next() may throw a {@link TempoDBException} if an error occurs while making a request.
@see Cursor
@since 1.0.0 | [
"Returns",
"a",
"cursor",
"of",
"datapoints",
"specified",
"by",
"series",
"."
]
| train | https://github.com/tempodb/tempodb-java/blob/5733f204fe4c8dda48916ba1f67cf44f5a3f9c69/src/main/java/com/tempodb/Client.java#L655-L675 |
spotbugs/spotbugs | eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/util/ASTUtil.java | ASTUtil.getASTNode | public static ASTNode getASTNode(CompilationUnit compilationUnit, int startLine, int endLine) throws ASTNodeNotFoundException {
"""
Searchs the first <CODE>ASTNode</CODE> between the specified
<CODE>startLine</CODE> and <CODE>endLine</CODE>. If the source line
doesn't contain an <CODE>ASTNode</CODE>, a
<CODE>ASTNodeNotFoundException</CODE> is thrown.
@param compilationUnit
the <CODE>CompilationUnit</CODE>, that contains the
<CODE>ASTNode</CODE>.
@param startLine
the starting source line number.
@param endLine
the ending source line number.
@throws ASTNodeNotFoundException
if no <CODE>ASTNode</CODE> found between the specifed start
and end line.
"""
requireNonNull(compilationUnit, "compilation unit");
ASTNode node = searchASTNode(compilationUnit, startLine, endLine);
if (node == null) {
throw new ASTNodeNotFoundException("No ast node found between " + startLine + " and " + endLine + ".");
}
return node;
} | java | public static ASTNode getASTNode(CompilationUnit compilationUnit, int startLine, int endLine) throws ASTNodeNotFoundException {
requireNonNull(compilationUnit, "compilation unit");
ASTNode node = searchASTNode(compilationUnit, startLine, endLine);
if (node == null) {
throw new ASTNodeNotFoundException("No ast node found between " + startLine + " and " + endLine + ".");
}
return node;
} | [
"public",
"static",
"ASTNode",
"getASTNode",
"(",
"CompilationUnit",
"compilationUnit",
",",
"int",
"startLine",
",",
"int",
"endLine",
")",
"throws",
"ASTNodeNotFoundException",
"{",
"requireNonNull",
"(",
"compilationUnit",
",",
"\"compilation unit\"",
")",
";",
"ASTNode",
"node",
"=",
"searchASTNode",
"(",
"compilationUnit",
",",
"startLine",
",",
"endLine",
")",
";",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"throw",
"new",
"ASTNodeNotFoundException",
"(",
"\"No ast node found between \"",
"+",
"startLine",
"+",
"\" and \"",
"+",
"endLine",
"+",
"\".\"",
")",
";",
"}",
"return",
"node",
";",
"}"
]
| Searchs the first <CODE>ASTNode</CODE> between the specified
<CODE>startLine</CODE> and <CODE>endLine</CODE>. If the source line
doesn't contain an <CODE>ASTNode</CODE>, a
<CODE>ASTNodeNotFoundException</CODE> is thrown.
@param compilationUnit
the <CODE>CompilationUnit</CODE>, that contains the
<CODE>ASTNode</CODE>.
@param startLine
the starting source line number.
@param endLine
the ending source line number.
@throws ASTNodeNotFoundException
if no <CODE>ASTNode</CODE> found between the specifed start
and end line. | [
"Searchs",
"the",
"first",
"<CODE",
">",
"ASTNode<",
"/",
"CODE",
">",
"between",
"the",
"specified",
"<CODE",
">",
"startLine<",
"/",
"CODE",
">",
"and",
"<CODE",
">",
"endLine<",
"/",
"CODE",
">",
".",
"If",
"the",
"source",
"line",
"doesn",
"t",
"contain",
"an",
"<CODE",
">",
"ASTNode<",
"/",
"CODE",
">",
"a",
"<CODE",
">",
"ASTNodeNotFoundException<",
"/",
"CODE",
">",
"is",
"thrown",
"."
]
| train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/util/ASTUtil.java#L202-L210 |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java | PROCLUS.computeBadMedoids | private DBIDs computeBadMedoids(ArrayDBIDs m_current, ArrayList<PROCLUSCluster> clusters, int threshold) {
"""
Computes the bad medoids, where the medoid of a cluster with less than the
specified threshold of objects is bad.
@param m_current Current medoids
@param clusters the clusters
@param threshold the threshold
@return the bad medoids
"""
ModifiableDBIDs badMedoids = DBIDUtil.newHashSet(m_current.size());
int i = 0;
for(DBIDIter it = m_current.iter(); it.valid(); it.advance(), i++) {
PROCLUSCluster c_i = clusters.get(i);
if(c_i == null || c_i.objectIDs.size() < threshold) {
badMedoids.add(it);
}
}
return badMedoids;
} | java | private DBIDs computeBadMedoids(ArrayDBIDs m_current, ArrayList<PROCLUSCluster> clusters, int threshold) {
ModifiableDBIDs badMedoids = DBIDUtil.newHashSet(m_current.size());
int i = 0;
for(DBIDIter it = m_current.iter(); it.valid(); it.advance(), i++) {
PROCLUSCluster c_i = clusters.get(i);
if(c_i == null || c_i.objectIDs.size() < threshold) {
badMedoids.add(it);
}
}
return badMedoids;
} | [
"private",
"DBIDs",
"computeBadMedoids",
"(",
"ArrayDBIDs",
"m_current",
",",
"ArrayList",
"<",
"PROCLUSCluster",
">",
"clusters",
",",
"int",
"threshold",
")",
"{",
"ModifiableDBIDs",
"badMedoids",
"=",
"DBIDUtil",
".",
"newHashSet",
"(",
"m_current",
".",
"size",
"(",
")",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"DBIDIter",
"it",
"=",
"m_current",
".",
"iter",
"(",
")",
";",
"it",
".",
"valid",
"(",
")",
";",
"it",
".",
"advance",
"(",
")",
",",
"i",
"++",
")",
"{",
"PROCLUSCluster",
"c_i",
"=",
"clusters",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"c_i",
"==",
"null",
"||",
"c_i",
".",
"objectIDs",
".",
"size",
"(",
")",
"<",
"threshold",
")",
"{",
"badMedoids",
".",
"add",
"(",
"it",
")",
";",
"}",
"}",
"return",
"badMedoids",
";",
"}"
]
| Computes the bad medoids, where the medoid of a cluster with less than the
specified threshold of objects is bad.
@param m_current Current medoids
@param clusters the clusters
@param threshold the threshold
@return the bad medoids | [
"Computes",
"the",
"bad",
"medoids",
"where",
"the",
"medoid",
"of",
"a",
"cluster",
"with",
"less",
"than",
"the",
"specified",
"threshold",
"of",
"objects",
"is",
"bad",
"."
]
| train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/subspace/PROCLUS.java#L707-L717 |
pryzach/midao | midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java | TypeHandlerUtils.copy | private static long copy(Reader input, StringBuilder output, char[] buffer)
throws IOException {
"""
Transfers data from Reader into StringBuilder
@param input Reader which would be read
@param output StringBuilder which would be filled
@param buffer buffer which is used for read/write operations
@return amount of bytes transferred
@throws IOException
"""
long bytesTransferred = 0;
int bytesRead = 0;
while (EOF != (bytesRead = input.read(buffer))) {
output.append(buffer, 0, bytesRead);
bytesTransferred += bytesRead;
}
return bytesTransferred;
} | java | private static long copy(Reader input, StringBuilder output, char[] buffer)
throws IOException {
long bytesTransferred = 0;
int bytesRead = 0;
while (EOF != (bytesRead = input.read(buffer))) {
output.append(buffer, 0, bytesRead);
bytesTransferred += bytesRead;
}
return bytesTransferred;
} | [
"private",
"static",
"long",
"copy",
"(",
"Reader",
"input",
",",
"StringBuilder",
"output",
",",
"char",
"[",
"]",
"buffer",
")",
"throws",
"IOException",
"{",
"long",
"bytesTransferred",
"=",
"0",
";",
"int",
"bytesRead",
"=",
"0",
";",
"while",
"(",
"EOF",
"!=",
"(",
"bytesRead",
"=",
"input",
".",
"read",
"(",
"buffer",
")",
")",
")",
"{",
"output",
".",
"append",
"(",
"buffer",
",",
"0",
",",
"bytesRead",
")",
";",
"bytesTransferred",
"+=",
"bytesRead",
";",
"}",
"return",
"bytesTransferred",
";",
"}"
]
| Transfers data from Reader into StringBuilder
@param input Reader which would be read
@param output StringBuilder which would be filled
@param buffer buffer which is used for read/write operations
@return amount of bytes transferred
@throws IOException | [
"Transfers",
"data",
"from",
"Reader",
"into",
"StringBuilder"
]
| train | https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java#L728-L737 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/processor/XSLTAttributeDef.java | XSLTAttributeDef.processNUMBER | Object processNUMBER(
StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner)
throws org.xml.sax.SAXException {
"""
Process an attribute string of type T_NUMBER into
a double value.
@param handler non-null reference to current StylesheetHandler that is constructing the Templates.
@param uri The Namespace URI, or an empty string.
@param name The local name (without prefix), or empty string if not namespace processing.
@param rawName The qualified name (with prefix).
@param value A string that can be parsed into a double value.
@param number
@return A Double object.
@throws org.xml.sax.SAXException that wraps a
{@link javax.xml.transform.TransformerException}
if the string does not contain a parsable number.
"""
if (getSupportsAVT())
{
Double val;
AVT avt = null;
try
{
avt = new AVT(handler, uri, name, rawName, value, owner);
// If this attribute used an avt, then we can't validate at this time.
if (avt.isSimple())
{
val = Double.valueOf(value);
}
}
catch (TransformerException te)
{
throw new org.xml.sax.SAXException(te);
}
catch (NumberFormatException nfe)
{
handleError(handler,XSLTErrorResources.INVALID_NUMBER, new Object[] {name, value}, nfe);
return null;
}
return avt;
}
else
{
try
{
return Double.valueOf(value);
}
catch (NumberFormatException nfe)
{
handleError(handler,XSLTErrorResources.INVALID_NUMBER, new Object[] {name, value}, nfe);
return null;
}
}
} | java | Object processNUMBER(
StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner)
throws org.xml.sax.SAXException
{
if (getSupportsAVT())
{
Double val;
AVT avt = null;
try
{
avt = new AVT(handler, uri, name, rawName, value, owner);
// If this attribute used an avt, then we can't validate at this time.
if (avt.isSimple())
{
val = Double.valueOf(value);
}
}
catch (TransformerException te)
{
throw new org.xml.sax.SAXException(te);
}
catch (NumberFormatException nfe)
{
handleError(handler,XSLTErrorResources.INVALID_NUMBER, new Object[] {name, value}, nfe);
return null;
}
return avt;
}
else
{
try
{
return Double.valueOf(value);
}
catch (NumberFormatException nfe)
{
handleError(handler,XSLTErrorResources.INVALID_NUMBER, new Object[] {name, value}, nfe);
return null;
}
}
} | [
"Object",
"processNUMBER",
"(",
"StylesheetHandler",
"handler",
",",
"String",
"uri",
",",
"String",
"name",
",",
"String",
"rawName",
",",
"String",
"value",
",",
"ElemTemplateElement",
"owner",
")",
"throws",
"org",
".",
"xml",
".",
"sax",
".",
"SAXException",
"{",
"if",
"(",
"getSupportsAVT",
"(",
")",
")",
"{",
"Double",
"val",
";",
"AVT",
"avt",
"=",
"null",
";",
"try",
"{",
"avt",
"=",
"new",
"AVT",
"(",
"handler",
",",
"uri",
",",
"name",
",",
"rawName",
",",
"value",
",",
"owner",
")",
";",
"// If this attribute used an avt, then we can't validate at this time.",
"if",
"(",
"avt",
".",
"isSimple",
"(",
")",
")",
"{",
"val",
"=",
"Double",
".",
"valueOf",
"(",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"TransformerException",
"te",
")",
"{",
"throw",
"new",
"org",
".",
"xml",
".",
"sax",
".",
"SAXException",
"(",
"te",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"handleError",
"(",
"handler",
",",
"XSLTErrorResources",
".",
"INVALID_NUMBER",
",",
"new",
"Object",
"[",
"]",
"{",
"name",
",",
"value",
"}",
",",
"nfe",
")",
";",
"return",
"null",
";",
"}",
"return",
"avt",
";",
"}",
"else",
"{",
"try",
"{",
"return",
"Double",
".",
"valueOf",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"handleError",
"(",
"handler",
",",
"XSLTErrorResources",
".",
"INVALID_NUMBER",
",",
"new",
"Object",
"[",
"]",
"{",
"name",
",",
"value",
"}",
",",
"nfe",
")",
";",
"return",
"null",
";",
"}",
"}",
"}"
]
| Process an attribute string of type T_NUMBER into
a double value.
@param handler non-null reference to current StylesheetHandler that is constructing the Templates.
@param uri The Namespace URI, or an empty string.
@param name The local name (without prefix), or empty string if not namespace processing.
@param rawName The qualified name (with prefix).
@param value A string that can be parsed into a double value.
@param number
@return A Double object.
@throws org.xml.sax.SAXException that wraps a
{@link javax.xml.transform.TransformerException}
if the string does not contain a parsable number. | [
"Process",
"an",
"attribute",
"string",
"of",
"type",
"T_NUMBER",
"into",
"a",
"double",
"value",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/processor/XSLTAttributeDef.java#L868-L912 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/ling/TaggedWordFactory.java | TaggedWordFactory.newLabel | public Label newLabel(String labelStr, int options) {
"""
Make a new label with this <code>String</code> as a value component.
Any other fields of the label would normally be null.
@param labelStr The String that will be used for value
@param options what to make (use labelStr as word or tag)
@return The new TaggedWord (tag or word will be <code>null</code>)
"""
if (options == TAG_LABEL) {
return new TaggedWord(null, labelStr);
}
return new TaggedWord(labelStr);
} | java | public Label newLabel(String labelStr, int options) {
if (options == TAG_LABEL) {
return new TaggedWord(null, labelStr);
}
return new TaggedWord(labelStr);
} | [
"public",
"Label",
"newLabel",
"(",
"String",
"labelStr",
",",
"int",
"options",
")",
"{",
"if",
"(",
"options",
"==",
"TAG_LABEL",
")",
"{",
"return",
"new",
"TaggedWord",
"(",
"null",
",",
"labelStr",
")",
";",
"}",
"return",
"new",
"TaggedWord",
"(",
"labelStr",
")",
";",
"}"
]
| Make a new label with this <code>String</code> as a value component.
Any other fields of the label would normally be null.
@param labelStr The String that will be used for value
@param options what to make (use labelStr as word or tag)
@return The new TaggedWord (tag or word will be <code>null</code>) | [
"Make",
"a",
"new",
"label",
"with",
"this",
"<code",
">",
"String<",
"/",
"code",
">",
"as",
"a",
"value",
"component",
".",
"Any",
"other",
"fields",
"of",
"the",
"label",
"would",
"normally",
"be",
"null",
"."
]
| train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/ling/TaggedWordFactory.java#L60-L65 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ClassUtil.java | ClassUtil.getClassName | public static String getClassName(Class<?> clazz, boolean isSimple) {
"""
获取类名<br>
类名并不包含“.class”这个扩展名<br>
例如:ClassUtil这个类<br>
<pre>
isSimple为false: "com.xiaoleilu.hutool.util.ClassUtil"
isSimple为true: "ClassUtil"
</pre>
@param clazz 类
@param isSimple 是否简单类名,如果为true,返回不带包名的类名
@return 类名
@since 3.0.7
"""
if (null == clazz) {
return null;
}
return isSimple ? clazz.getSimpleName() : clazz.getName();
} | java | public static String getClassName(Class<?> clazz, boolean isSimple) {
if (null == clazz) {
return null;
}
return isSimple ? clazz.getSimpleName() : clazz.getName();
} | [
"public",
"static",
"String",
"getClassName",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"boolean",
"isSimple",
")",
"{",
"if",
"(",
"null",
"==",
"clazz",
")",
"{",
"return",
"null",
";",
"}",
"return",
"isSimple",
"?",
"clazz",
".",
"getSimpleName",
"(",
")",
":",
"clazz",
".",
"getName",
"(",
")",
";",
"}"
]
| 获取类名<br>
类名并不包含“.class”这个扩展名<br>
例如:ClassUtil这个类<br>
<pre>
isSimple为false: "com.xiaoleilu.hutool.util.ClassUtil"
isSimple为true: "ClassUtil"
</pre>
@param clazz 类
@param isSimple 是否简单类名,如果为true,返回不带包名的类名
@return 类名
@since 3.0.7 | [
"获取类名<br",
">",
"类名并不包含“",
".",
"class”这个扩展名<br",
">",
"例如:ClassUtil这个类<br",
">"
]
| train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ClassUtil.java#L104-L109 |
jamel/dbf | dbf-reader/src/main/java/org/jamel/dbf/utils/DbfUtils.java | DbfUtils.parseLong | public static long parseLong(byte[] bytes, int from, int to) {
"""
parses only positive numbers
@param bytes bytes of string value
@param from index to start from
@param to index to end at
@return integer value
"""
long result = 0;
for (int i = from; i < to && i < bytes.length; i++) {
result *= 10;
result += (bytes[i] - (byte) '0');
}
return result;
} | java | public static long parseLong(byte[] bytes, int from, int to) {
long result = 0;
for (int i = from; i < to && i < bytes.length; i++) {
result *= 10;
result += (bytes[i] - (byte) '0');
}
return result;
} | [
"public",
"static",
"long",
"parseLong",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"from",
",",
"int",
"to",
")",
"{",
"long",
"result",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"from",
";",
"i",
"<",
"to",
"&&",
"i",
"<",
"bytes",
".",
"length",
";",
"i",
"++",
")",
"{",
"result",
"*=",
"10",
";",
"result",
"+=",
"(",
"bytes",
"[",
"i",
"]",
"-",
"(",
"byte",
")",
"'",
"'",
")",
";",
"}",
"return",
"result",
";",
"}"
]
| parses only positive numbers
@param bytes bytes of string value
@param from index to start from
@param to index to end at
@return integer value | [
"parses",
"only",
"positive",
"numbers"
]
| train | https://github.com/jamel/dbf/blob/5f065f8a13d9a4ffe27c617e7ec321771c95da7f/dbf-reader/src/main/java/org/jamel/dbf/utils/DbfUtils.java#L105-L112 |
neoremind/fluent-validator | fluent-validator/src/main/java/com/baidu/unbiz/fluentvalidator/util/ReflectionUtil.java | ReflectionUtil.invokeMethod | public static <T> T invokeMethod(Method method, Object target, Object... args) {
"""
方法调用,如果<code>clazz</code>为<code>null</code>,返回<code>null</code>;
<p/>
如果<code>method</code>为<code>null</code>,返回<code>null</code>
<p/>
如果<code>target</code>为<code>null</code>,则为静态方法
@param method 调用的方法
@param target 目标对象
@param args 方法的参数值
@return 调用结果
"""
if (method == null) {
return null;
}
method.setAccessible(true);
try {
@SuppressWarnings("unchecked")
T result = (T) method.invoke(target, args);
return result;
} catch (Exception e) {
throw new RuntimeValidateException(e);
}
} | java | public static <T> T invokeMethod(Method method, Object target, Object... args) {
if (method == null) {
return null;
}
method.setAccessible(true);
try {
@SuppressWarnings("unchecked")
T result = (T) method.invoke(target, args);
return result;
} catch (Exception e) {
throw new RuntimeValidateException(e);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"invokeMethod",
"(",
"Method",
"method",
",",
"Object",
"target",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"method",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"method",
".",
"setAccessible",
"(",
"true",
")",
";",
"try",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T",
"result",
"=",
"(",
"T",
")",
"method",
".",
"invoke",
"(",
"target",
",",
"args",
")",
";",
"return",
"result",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeValidateException",
"(",
"e",
")",
";",
"}",
"}"
]
| 方法调用,如果<code>clazz</code>为<code>null</code>,返回<code>null</code>;
<p/>
如果<code>method</code>为<code>null</code>,返回<code>null</code>
<p/>
如果<code>target</code>为<code>null</code>,则为静态方法
@param method 调用的方法
@param target 目标对象
@param args 方法的参数值
@return 调用结果 | [
"方法调用,如果<code",
">",
"clazz<",
"/",
"code",
">",
"为<code",
">",
"null<",
"/",
"code",
">",
",返回<code",
">",
"null<",
"/",
"code",
">",
";",
"<p",
"/",
">",
"如果<code",
">",
"method<",
"/",
"code",
">",
"为<code",
">",
"null<",
"/",
"code",
">",
",返回<code",
">",
"null<",
"/",
"code",
">",
"<p",
"/",
">",
"如果<code",
">",
"target<",
"/",
"code",
">",
"为<code",
">",
"null<",
"/",
"code",
">",
",则为静态方法"
]
| train | https://github.com/neoremind/fluent-validator/blob/b516970591aa9468b44ba63938b98ec341fd6ead/fluent-validator/src/main/java/com/baidu/unbiz/fluentvalidator/util/ReflectionUtil.java#L174-L187 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/ResourceBundle.java | ResourceBundle.getBundle | public static ResourceBundle getBundle(String bundleName, Locale locale) {
"""
Finds the named {@code ResourceBundle} for the specified {@code Locale} and the caller
{@code ClassLoader}.
@param bundleName
the name of the {@code ResourceBundle}.
@param locale
the {@code Locale}.
@return the requested resource bundle.
@throws MissingResourceException
if the resource bundle cannot be found.
"""
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
if (classLoader == null) {
classLoader = getLoader();
}
return getBundle(bundleName, locale, classLoader);
} | java | public static ResourceBundle getBundle(String bundleName, Locale locale) {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
if (classLoader == null) {
classLoader = getLoader();
}
return getBundle(bundleName, locale, classLoader);
} | [
"public",
"static",
"ResourceBundle",
"getBundle",
"(",
"String",
"bundleName",
",",
"Locale",
"locale",
")",
"{",
"ClassLoader",
"classLoader",
"=",
"ClassLoader",
".",
"getSystemClassLoader",
"(",
")",
";",
"if",
"(",
"classLoader",
"==",
"null",
")",
"{",
"classLoader",
"=",
"getLoader",
"(",
")",
";",
"}",
"return",
"getBundle",
"(",
"bundleName",
",",
"locale",
",",
"classLoader",
")",
";",
"}"
]
| Finds the named {@code ResourceBundle} for the specified {@code Locale} and the caller
{@code ClassLoader}.
@param bundleName
the name of the {@code ResourceBundle}.
@param locale
the {@code Locale}.
@return the requested resource bundle.
@throws MissingResourceException
if the resource bundle cannot be found. | [
"Finds",
"the",
"named",
"{",
"@code",
"ResourceBundle",
"}",
"for",
"the",
"specified",
"{",
"@code",
"Locale",
"}",
"and",
"the",
"caller",
"{",
"@code",
"ClassLoader",
"}",
"."
]
| train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/ResourceBundle.java#L154-L160 |
opencypher/openCypher | tools/grammar/src/main/java/org/opencypher/grammar/Description.java | Description.emitLine | private static int emitLine( StringBuilder target, char[] buffer, int start, int end, int indentation ) {
"""
Emits the line that starts at {@code start} position, and ends at a newline or the {@code end} position.
@return the start position of the next line (the {@code end} position
"""
int last = start;
for ( int pos = start, cp; pos < end; pos += charCount( cp ) )
{
cp = codePointAt( buffer, pos );
if ( cp == '\n' )
{
end = pos + 1;
}
if ( indentation > 0 )
{
if ( --indentation == 0 )
{
start = pos + 1;
}
last = pos;
}
else if ( !isWhitespace( cp ) )
{
last = pos + 1;
}
}
target.append( buffer, start, last - start );
return end;
} | java | private static int emitLine( StringBuilder target, char[] buffer, int start, int end, int indentation )
{
int last = start;
for ( int pos = start, cp; pos < end; pos += charCount( cp ) )
{
cp = codePointAt( buffer, pos );
if ( cp == '\n' )
{
end = pos + 1;
}
if ( indentation > 0 )
{
if ( --indentation == 0 )
{
start = pos + 1;
}
last = pos;
}
else if ( !isWhitespace( cp ) )
{
last = pos + 1;
}
}
target.append( buffer, start, last - start );
return end;
} | [
"private",
"static",
"int",
"emitLine",
"(",
"StringBuilder",
"target",
",",
"char",
"[",
"]",
"buffer",
",",
"int",
"start",
",",
"int",
"end",
",",
"int",
"indentation",
")",
"{",
"int",
"last",
"=",
"start",
";",
"for",
"(",
"int",
"pos",
"=",
"start",
",",
"cp",
";",
"pos",
"<",
"end",
";",
"pos",
"+=",
"charCount",
"(",
"cp",
")",
")",
"{",
"cp",
"=",
"codePointAt",
"(",
"buffer",
",",
"pos",
")",
";",
"if",
"(",
"cp",
"==",
"'",
"'",
")",
"{",
"end",
"=",
"pos",
"+",
"1",
";",
"}",
"if",
"(",
"indentation",
">",
"0",
")",
"{",
"if",
"(",
"--",
"indentation",
"==",
"0",
")",
"{",
"start",
"=",
"pos",
"+",
"1",
";",
"}",
"last",
"=",
"pos",
";",
"}",
"else",
"if",
"(",
"!",
"isWhitespace",
"(",
"cp",
")",
")",
"{",
"last",
"=",
"pos",
"+",
"1",
";",
"}",
"}",
"target",
".",
"append",
"(",
"buffer",
",",
"start",
",",
"last",
"-",
"start",
")",
";",
"return",
"end",
";",
"}"
]
| Emits the line that starts at {@code start} position, and ends at a newline or the {@code end} position.
@return the start position of the next line (the {@code end} position | [
"Emits",
"the",
"line",
"that",
"starts",
"at",
"{",
"@code",
"start",
"}",
"position",
"and",
"ends",
"at",
"a",
"newline",
"or",
"the",
"{",
"@code",
"end",
"}",
"position",
"."
]
| train | https://github.com/opencypher/openCypher/blob/eb780caea625900ddbedd28a1eac9a5dbe09c5f0/tools/grammar/src/main/java/org/opencypher/grammar/Description.java#L140-L165 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.findResult | public static Object findResult(Object self, Object defaultResult, Closure condition) {
"""
Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns the defaultResult.
<p>
<pre class="groovyTestCase">
int[] numbers = [1, 2, 3]
assert numbers.findResult(5) { if(it {@code >} 1) return it } == 2
assert numbers.findResult(5) { if(it {@code >} 4) return it } == 5
</pre>
@param self an Object with an iterator returning its values
@param defaultResult an Object that should be returned if all closure results are null
@param condition a closure that returns a non-null value to indicate that processing should stop and the value should be returned
@return the first non-null result of the closure, otherwise the default value
@since 1.7.5
"""
Object result = findResult(self, condition);
if (result == null) return defaultResult;
return result;
} | java | public static Object findResult(Object self, Object defaultResult, Closure condition) {
Object result = findResult(self, condition);
if (result == null) return defaultResult;
return result;
} | [
"public",
"static",
"Object",
"findResult",
"(",
"Object",
"self",
",",
"Object",
"defaultResult",
",",
"Closure",
"condition",
")",
"{",
"Object",
"result",
"=",
"findResult",
"(",
"self",
",",
"condition",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"return",
"defaultResult",
";",
"return",
"result",
";",
"}"
]
| Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns the defaultResult.
<p>
<pre class="groovyTestCase">
int[] numbers = [1, 2, 3]
assert numbers.findResult(5) { if(it {@code >} 1) return it } == 2
assert numbers.findResult(5) { if(it {@code >} 4) return it } == 5
</pre>
@param self an Object with an iterator returning its values
@param defaultResult an Object that should be returned if all closure results are null
@param condition a closure that returns a non-null value to indicate that processing should stop and the value should be returned
@return the first non-null result of the closure, otherwise the default value
@since 1.7.5 | [
"Treats",
"the",
"object",
"as",
"iterable",
"iterating",
"through",
"the",
"values",
"it",
"represents",
"and",
"returns",
"the",
"first",
"non",
"-",
"null",
"result",
"obtained",
"from",
"calling",
"the",
"closure",
"otherwise",
"returns",
"the",
"defaultResult",
".",
"<p",
">",
"<pre",
"class",
"=",
"groovyTestCase",
">",
"int",
"[]",
"numbers",
"=",
"[",
"1",
"2",
"3",
"]",
"assert",
"numbers",
".",
"findResult",
"(",
"5",
")",
"{",
"if",
"(",
"it",
"{",
"@code",
">",
"}",
"1",
")",
"return",
"it",
"}",
"==",
"2",
"assert",
"numbers",
".",
"findResult",
"(",
"5",
")",
"{",
"if",
"(",
"it",
"{",
"@code",
">",
"}",
"4",
")",
"return",
"it",
"}",
"==",
"5",
"<",
"/",
"pre",
">"
]
| train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4435-L4439 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webserver.plugin.utility/src/com/ibm/ws/webserver/plugin/utility/tasks/BasePluginConfigCommandTask.java | BasePluginConfigCommandTask.getArgumentValue | protected String getArgumentValue(String arg, String[] args, String defalt) {
"""
Gets the value for the specified argument String. If the default
value argument is null, it indicates the argument is required.
No validation is done in the format of args as it was done previously.
@param arg Argument name to resolve a value for
@param args List of arguments
@param defalt Default value if the argument is not specified
@return Value of the argument, or null if there was no value.
@throws IllegalArgumentException if the argument is defined but no value
is given.
"""
String argName = getArgName(arg);
for (int i = 1; i < args.length; i++) {
String currentArgName = getArgName(args[i]); // return what's to left of = if there is one
if (currentArgName.equalsIgnoreCase(argName)) {
return getValue(args[i]);
}
}
return defalt;
} | java | protected String getArgumentValue(String arg, String[] args, String defalt) {
String argName = getArgName(arg);
for (int i = 1; i < args.length; i++) {
String currentArgName = getArgName(args[i]); // return what's to left of = if there is one
if (currentArgName.equalsIgnoreCase(argName)) {
return getValue(args[i]);
}
}
return defalt;
} | [
"protected",
"String",
"getArgumentValue",
"(",
"String",
"arg",
",",
"String",
"[",
"]",
"args",
",",
"String",
"defalt",
")",
"{",
"String",
"argName",
"=",
"getArgName",
"(",
"arg",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"currentArgName",
"=",
"getArgName",
"(",
"args",
"[",
"i",
"]",
")",
";",
"// return what's to left of = if there is one",
"if",
"(",
"currentArgName",
".",
"equalsIgnoreCase",
"(",
"argName",
")",
")",
"{",
"return",
"getValue",
"(",
"args",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"defalt",
";",
"}"
]
| Gets the value for the specified argument String. If the default
value argument is null, it indicates the argument is required.
No validation is done in the format of args as it was done previously.
@param arg Argument name to resolve a value for
@param args List of arguments
@param defalt Default value if the argument is not specified
@return Value of the argument, or null if there was no value.
@throws IllegalArgumentException if the argument is defined but no value
is given. | [
"Gets",
"the",
"value",
"for",
"the",
"specified",
"argument",
"String",
".",
"If",
"the",
"default",
"value",
"argument",
"is",
"null",
"it",
"indicates",
"the",
"argument",
"is",
"required",
"."
]
| train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webserver.plugin.utility/src/com/ibm/ws/webserver/plugin/utility/tasks/BasePluginConfigCommandTask.java#L270-L279 |
JOML-CI/JOML | src/org/joml/Matrix4x3f.java | Matrix4x3f.orthoSymmetricLH | public Matrix4x3f orthoSymmetricLH(float width, float height, float zNear, float zFar, boolean zZeroToOne) {
"""
Apply a symmetric orthographic projection transformation for a left-handed coordinate system
using the given NDC z range to this matrix.
<p>
This method is equivalent to calling {@link #orthoLH(float, float, float, float, float, float, boolean) orthoLH()} with
<code>left=-width/2</code>, <code>right=+width/2</code>, <code>bottom=-height/2</code> and <code>top=+height/2</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>O</code> the orthographic projection matrix,
then the new matrix will be <code>M * O</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * O * v</code>, the
orthographic projection transformation will be applied first!
<p>
In order to set the matrix to a symmetric orthographic projection without post-multiplying it,
use {@link #setOrthoSymmetricLH(float, float, float, float, boolean) setOrthoSymmetricLH()}.
<p>
Reference: <a href="http://www.songho.ca/opengl/gl_projectionmatrix.html#ortho">http://www.songho.ca</a>
@see #setOrthoSymmetricLH(float, float, float, float, boolean)
@param width
the distance between the right and left frustum edges
@param height
the distance between the top and bottom frustum edges
@param zNear
near clipping plane distance
@param zFar
far clipping plane distance
@param zZeroToOne
whether to use Vulkan's and Direct3D's NDC z range of <code>[0..+1]</code> when <code>true</code>
or whether to use OpenGL's NDC z range of <code>[-1..+1]</code> when <code>false</code>
@return this
"""
return orthoSymmetricLH(width, height, zNear, zFar, zZeroToOne, this);
} | java | public Matrix4x3f orthoSymmetricLH(float width, float height, float zNear, float zFar, boolean zZeroToOne) {
return orthoSymmetricLH(width, height, zNear, zFar, zZeroToOne, this);
} | [
"public",
"Matrix4x3f",
"orthoSymmetricLH",
"(",
"float",
"width",
",",
"float",
"height",
",",
"float",
"zNear",
",",
"float",
"zFar",
",",
"boolean",
"zZeroToOne",
")",
"{",
"return",
"orthoSymmetricLH",
"(",
"width",
",",
"height",
",",
"zNear",
",",
"zFar",
",",
"zZeroToOne",
",",
"this",
")",
";",
"}"
]
| Apply a symmetric orthographic projection transformation for a left-handed coordinate system
using the given NDC z range to this matrix.
<p>
This method is equivalent to calling {@link #orthoLH(float, float, float, float, float, float, boolean) orthoLH()} with
<code>left=-width/2</code>, <code>right=+width/2</code>, <code>bottom=-height/2</code> and <code>top=+height/2</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>O</code> the orthographic projection matrix,
then the new matrix will be <code>M * O</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * O * v</code>, the
orthographic projection transformation will be applied first!
<p>
In order to set the matrix to a symmetric orthographic projection without post-multiplying it,
use {@link #setOrthoSymmetricLH(float, float, float, float, boolean) setOrthoSymmetricLH()}.
<p>
Reference: <a href="http://www.songho.ca/opengl/gl_projectionmatrix.html#ortho">http://www.songho.ca</a>
@see #setOrthoSymmetricLH(float, float, float, float, boolean)
@param width
the distance between the right and left frustum edges
@param height
the distance between the top and bottom frustum edges
@param zNear
near clipping plane distance
@param zFar
far clipping plane distance
@param zZeroToOne
whether to use Vulkan's and Direct3D's NDC z range of <code>[0..+1]</code> when <code>true</code>
or whether to use OpenGL's NDC z range of <code>[-1..+1]</code> when <code>false</code>
@return this | [
"Apply",
"a",
"symmetric",
"orthographic",
"projection",
"transformation",
"for",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"using",
"the",
"given",
"NDC",
"z",
"range",
"to",
"this",
"matrix",
".",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
"{",
"@link",
"#orthoLH",
"(",
"float",
"float",
"float",
"float",
"float",
"float",
"boolean",
")",
"orthoLH",
"()",
"}",
"with",
"<code",
">",
"left",
"=",
"-",
"width",
"/",
"2<",
"/",
"code",
">",
"<code",
">",
"right",
"=",
"+",
"width",
"/",
"2<",
"/",
"code",
">",
"<code",
">",
"bottom",
"=",
"-",
"height",
"/",
"2<",
"/",
"code",
">",
"and",
"<code",
">",
"top",
"=",
"+",
"height",
"/",
"2<",
"/",
"code",
">",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"O<",
"/",
"code",
">",
"the",
"orthographic",
"projection",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"O<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"O",
"*",
"v<",
"/",
"code",
">",
"the",
"orthographic",
"projection",
"transformation",
"will",
"be",
"applied",
"first!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"symmetric",
"orthographic",
"projection",
"without",
"post",
"-",
"multiplying",
"it",
"use",
"{",
"@link",
"#setOrthoSymmetricLH",
"(",
"float",
"float",
"float",
"float",
"boolean",
")",
"setOrthoSymmetricLH",
"()",
"}",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"songho",
".",
"ca",
"/",
"opengl",
"/",
"gl_projectionmatrix",
".",
"html#ortho",
">",
"http",
":",
"//",
"www",
".",
"songho",
".",
"ca<",
"/",
"a",
">"
]
| train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4x3f.java#L5487-L5489 |
JOML-CI/JOML | src/org/joml/Matrix4f.java | Matrix4f.lookAt | public Matrix4f lookAt(Vector3fc eye, Vector3fc center, Vector3fc up, Matrix4f dest) {
"""
Apply a "lookat" transformation to this matrix for a right-handed coordinate system,
that aligns <code>-z</code> with <code>center - eye</code> and store the result in <code>dest</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>L</code> the lookat matrix,
then the new matrix will be <code>M * L</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * L * v</code>,
the lookat transformation will be applied first!
<p>
In order to set the matrix to a lookat transformation without post-multiplying it,
use {@link #setLookAt(Vector3fc, Vector3fc, Vector3fc)}.
@see #lookAt(float, float, float, float, float, float, float, float, float)
@see #setLookAlong(Vector3fc, Vector3fc)
@param eye
the position of the camera
@param center
the point in space to look at
@param up
the direction of 'up'
@param dest
will hold the result
@return dest
"""
return lookAt(eye.x(), eye.y(), eye.z(), center.x(), center.y(), center.z(), up.x(), up.y(), up.z(), dest);
} | java | public Matrix4f lookAt(Vector3fc eye, Vector3fc center, Vector3fc up, Matrix4f dest) {
return lookAt(eye.x(), eye.y(), eye.z(), center.x(), center.y(), center.z(), up.x(), up.y(), up.z(), dest);
} | [
"public",
"Matrix4f",
"lookAt",
"(",
"Vector3fc",
"eye",
",",
"Vector3fc",
"center",
",",
"Vector3fc",
"up",
",",
"Matrix4f",
"dest",
")",
"{",
"return",
"lookAt",
"(",
"eye",
".",
"x",
"(",
")",
",",
"eye",
".",
"y",
"(",
")",
",",
"eye",
".",
"z",
"(",
")",
",",
"center",
".",
"x",
"(",
")",
",",
"center",
".",
"y",
"(",
")",
",",
"center",
".",
"z",
"(",
")",
",",
"up",
".",
"x",
"(",
")",
",",
"up",
".",
"y",
"(",
")",
",",
"up",
".",
"z",
"(",
")",
",",
"dest",
")",
";",
"}"
]
| Apply a "lookat" transformation to this matrix for a right-handed coordinate system,
that aligns <code>-z</code> with <code>center - eye</code> and store the result in <code>dest</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>L</code> the lookat matrix,
then the new matrix will be <code>M * L</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * L * v</code>,
the lookat transformation will be applied first!
<p>
In order to set the matrix to a lookat transformation without post-multiplying it,
use {@link #setLookAt(Vector3fc, Vector3fc, Vector3fc)}.
@see #lookAt(float, float, float, float, float, float, float, float, float)
@see #setLookAlong(Vector3fc, Vector3fc)
@param eye
the position of the camera
@param center
the point in space to look at
@param up
the direction of 'up'
@param dest
will hold the result
@return dest | [
"Apply",
"a",
"lookat",
"transformation",
"to",
"this",
"matrix",
"for",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"that",
"aligns",
"<code",
">",
"-",
"z<",
"/",
"code",
">",
"with",
"<code",
">",
"center",
"-",
"eye<",
"/",
"code",
">",
"and",
"store",
"the",
"result",
"in",
"<code",
">",
"dest<",
"/",
"code",
">",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"L<",
"/",
"code",
">",
"the",
"lookat",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"L<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"L",
"*",
"v<",
"/",
"code",
">",
"the",
"lookat",
"transformation",
"will",
"be",
"applied",
"first!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"lookat",
"transformation",
"without",
"post",
"-",
"multiplying",
"it",
"use",
"{",
"@link",
"#setLookAt",
"(",
"Vector3fc",
"Vector3fc",
"Vector3fc",
")",
"}",
"."
]
| train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4f.java#L8465-L8467 |
tinosteinort/beanrepository | src/main/java/com/github/tinosteinort/beanrepository/BeanRepository.java | BeanRepository.getPrototypeBean | public <T, P1> T getPrototypeBean(final ConstructorWithBeansAnd1Parameter<T, P1> creator,
final P1 param1) {
"""
Returns a new {@code prototype} Bean, created by the given Function. It is possible to pass Parameter
to the Constructor of the Bean, and determine Dependencies with the {@link BeanAccessor}. The Method
{@link PostConstructible#onPostConstruct(BeanRepository)} is executed for every Call of this Method, if
the Interface is implemented.
@param creator The Code to create the new Object
@param param1 The 1st Parameter
@param <T> The Type of the Bean
@param <P1> The Type of the 1st Parameter
@see BeanAccessor
@see PostConstructible
@return a new created Object
"""
final PrototypeProvider provider = new PrototypeProvider(name, beans -> creator.create(beans, param1));
return provider.getBean(this, dryRun);
} | java | public <T, P1> T getPrototypeBean(final ConstructorWithBeansAnd1Parameter<T, P1> creator,
final P1 param1) {
final PrototypeProvider provider = new PrototypeProvider(name, beans -> creator.create(beans, param1));
return provider.getBean(this, dryRun);
} | [
"public",
"<",
"T",
",",
"P1",
">",
"T",
"getPrototypeBean",
"(",
"final",
"ConstructorWithBeansAnd1Parameter",
"<",
"T",
",",
"P1",
">",
"creator",
",",
"final",
"P1",
"param1",
")",
"{",
"final",
"PrototypeProvider",
"provider",
"=",
"new",
"PrototypeProvider",
"(",
"name",
",",
"beans",
"->",
"creator",
".",
"create",
"(",
"beans",
",",
"param1",
")",
")",
";",
"return",
"provider",
".",
"getBean",
"(",
"this",
",",
"dryRun",
")",
";",
"}"
]
| Returns a new {@code prototype} Bean, created by the given Function. It is possible to pass Parameter
to the Constructor of the Bean, and determine Dependencies with the {@link BeanAccessor}. The Method
{@link PostConstructible#onPostConstruct(BeanRepository)} is executed for every Call of this Method, if
the Interface is implemented.
@param creator The Code to create the new Object
@param param1 The 1st Parameter
@param <T> The Type of the Bean
@param <P1> The Type of the 1st Parameter
@see BeanAccessor
@see PostConstructible
@return a new created Object | [
"Returns",
"a",
"new",
"{",
"@code",
"prototype",
"}",
"Bean",
"created",
"by",
"the",
"given",
"Function",
".",
"It",
"is",
"possible",
"to",
"pass",
"Parameter",
"to",
"the",
"Constructor",
"of",
"the",
"Bean",
"and",
"determine",
"Dependencies",
"with",
"the",
"{",
"@link",
"BeanAccessor",
"}",
".",
"The",
"Method",
"{",
"@link",
"PostConstructible#onPostConstruct",
"(",
"BeanRepository",
")",
"}",
"is",
"executed",
"for",
"every",
"Call",
"of",
"this",
"Method",
"if",
"the",
"Interface",
"is",
"implemented",
"."
]
| train | https://github.com/tinosteinort/beanrepository/blob/4131d1e380ebc511392f3bda9d0966997bb34a62/src/main/java/com/github/tinosteinort/beanrepository/BeanRepository.java#L237-L241 |
LearnLib/automatalib | util/src/main/java/net/automatalib/util/automata/minimizer/hopcroft/HopcroftMinimization.java | HopcroftMinimization.minimizeDFA | public static <S, I, A extends DFA<S, I> & InputAlphabetHolder<I>> CompactDFA<I> minimizeDFA(A dfa,
PruningMode pruningMode) {
"""
Minimizes the given DFA. The result is returned in the form of a {@link CompactDFA}, using the input alphabet
obtained via <code>dfa.{@link InputAlphabetHolder#getInputAlphabet() getInputAlphabet()}</code>.
@param dfa
the DFA to minimize
@param pruningMode
the pruning mode (see above)
@return a minimized version of the specified DFA
"""
return doMinimizeDFA(dfa, dfa.getInputAlphabet(), new CompactDFA.Creator<>(), pruningMode);
} | java | public static <S, I, A extends DFA<S, I> & InputAlphabetHolder<I>> CompactDFA<I> minimizeDFA(A dfa,
PruningMode pruningMode) {
return doMinimizeDFA(dfa, dfa.getInputAlphabet(), new CompactDFA.Creator<>(), pruningMode);
} | [
"public",
"static",
"<",
"S",
",",
"I",
",",
"A",
"extends",
"DFA",
"<",
"S",
",",
"I",
">",
"&",
"InputAlphabetHolder",
"<",
"I",
">",
">",
"CompactDFA",
"<",
"I",
">",
"minimizeDFA",
"(",
"A",
"dfa",
",",
"PruningMode",
"pruningMode",
")",
"{",
"return",
"doMinimizeDFA",
"(",
"dfa",
",",
"dfa",
".",
"getInputAlphabet",
"(",
")",
",",
"new",
"CompactDFA",
".",
"Creator",
"<>",
"(",
")",
",",
"pruningMode",
")",
";",
"}"
]
| Minimizes the given DFA. The result is returned in the form of a {@link CompactDFA}, using the input alphabet
obtained via <code>dfa.{@link InputAlphabetHolder#getInputAlphabet() getInputAlphabet()}</code>.
@param dfa
the DFA to minimize
@param pruningMode
the pruning mode (see above)
@return a minimized version of the specified DFA | [
"Minimizes",
"the",
"given",
"DFA",
".",
"The",
"result",
"is",
"returned",
"in",
"the",
"form",
"of",
"a",
"{",
"@link",
"CompactDFA",
"}",
"using",
"the",
"input",
"alphabet",
"obtained",
"via",
"<code",
">",
"dfa",
".",
"{",
"@link",
"InputAlphabetHolder#getInputAlphabet",
"()",
"getInputAlphabet",
"()",
"}",
"<",
"/",
"code",
">",
"."
]
| train | https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/util/src/main/java/net/automatalib/util/automata/minimizer/hopcroft/HopcroftMinimization.java#L205-L208 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java | MultiViewOps.constraintHomography | public static Point2D_F64 constraintHomography( DMatrixRMaj H , Point2D_F64 p1 , Point2D_F64 outputP2 ) {
"""
<p>
Applies the homography constraints to two points:<br>
z*p2 = H*p1<br>
where z is a scale factor and (p1,p2) are point observations. Note that since 2D points are inputted
translation and normalization to homogeneous coordinates with z=1 is automatically handled.
</p>
@param H Input: 3x3 Homography matrix.
@param p1 Input: Point in view 1.
@param outputP2 Output: storage for point in view 2.
@return Predicted point in view 2
"""
if( outputP2 == null )
outputP2 = new Point2D_F64();
GeometryMath_F64.mult(H,p1,outputP2);
return outputP2;
} | java | public static Point2D_F64 constraintHomography( DMatrixRMaj H , Point2D_F64 p1 , Point2D_F64 outputP2 ) {
if( outputP2 == null )
outputP2 = new Point2D_F64();
GeometryMath_F64.mult(H,p1,outputP2);
return outputP2;
} | [
"public",
"static",
"Point2D_F64",
"constraintHomography",
"(",
"DMatrixRMaj",
"H",
",",
"Point2D_F64",
"p1",
",",
"Point2D_F64",
"outputP2",
")",
"{",
"if",
"(",
"outputP2",
"==",
"null",
")",
"outputP2",
"=",
"new",
"Point2D_F64",
"(",
")",
";",
"GeometryMath_F64",
".",
"mult",
"(",
"H",
",",
"p1",
",",
"outputP2",
")",
";",
"return",
"outputP2",
";",
"}"
]
| <p>
Applies the homography constraints to two points:<br>
z*p2 = H*p1<br>
where z is a scale factor and (p1,p2) are point observations. Note that since 2D points are inputted
translation and normalization to homogeneous coordinates with z=1 is automatically handled.
</p>
@param H Input: 3x3 Homography matrix.
@param p1 Input: Point in view 1.
@param outputP2 Output: storage for point in view 2.
@return Predicted point in view 2 | [
"<p",
">",
"Applies",
"the",
"homography",
"constraints",
"to",
"two",
"points",
":",
"<br",
">",
"z",
"*",
"p2",
"=",
"H",
"*",
"p1<br",
">",
"where",
"z",
"is",
"a",
"scale",
"factor",
"and",
"(",
"p1",
"p2",
")",
"are",
"point",
"observations",
".",
"Note",
"that",
"since",
"2D",
"points",
"are",
"inputted",
"translation",
"and",
"normalization",
"to",
"homogeneous",
"coordinates",
"with",
"z",
"=",
"1",
"is",
"automatically",
"handled",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L417-L424 |
brettwooldridge/HikariCP | src/main/java/com/zaxxer/hikari/util/UtilityElf.java | UtilityElf.createInstance | public static <T> T createInstance(final String className, final Class<T> clazz, final Object... args) {
"""
Create and instance of the specified class using the constructor matching the specified
arguments.
@param <T> the class type
@param className the name of the class to instantiate
@param clazz a class to cast the result as
@param args arguments to a constructor
@return an instance of the specified class
"""
if (className == null) {
return null;
}
try {
Class<?> loaded = UtilityElf.class.getClassLoader().loadClass(className);
if (args.length == 0) {
return clazz.cast(loaded.newInstance());
}
Class<?>[] argClasses = new Class<?>[args.length];
for (int i = 0; i < args.length; i++) {
argClasses[i] = args[i].getClass();
}
Constructor<?> constructor = loaded.getConstructor(argClasses);
return clazz.cast(constructor.newInstance(args));
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | java | public static <T> T createInstance(final String className, final Class<T> clazz, final Object... args)
{
if (className == null) {
return null;
}
try {
Class<?> loaded = UtilityElf.class.getClassLoader().loadClass(className);
if (args.length == 0) {
return clazz.cast(loaded.newInstance());
}
Class<?>[] argClasses = new Class<?>[args.length];
for (int i = 0; i < args.length; i++) {
argClasses[i] = args[i].getClass();
}
Constructor<?> constructor = loaded.getConstructor(argClasses);
return clazz.cast(constructor.newInstance(args));
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"createInstance",
"(",
"final",
"String",
"className",
",",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"className",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"Class",
"<",
"?",
">",
"loaded",
"=",
"UtilityElf",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"loadClass",
"(",
"className",
")",
";",
"if",
"(",
"args",
".",
"length",
"==",
"0",
")",
"{",
"return",
"clazz",
".",
"cast",
"(",
"loaded",
".",
"newInstance",
"(",
")",
")",
";",
"}",
"Class",
"<",
"?",
">",
"[",
"]",
"argClasses",
"=",
"new",
"Class",
"<",
"?",
">",
"[",
"args",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"argClasses",
"[",
"i",
"]",
"=",
"args",
"[",
"i",
"]",
".",
"getClass",
"(",
")",
";",
"}",
"Constructor",
"<",
"?",
">",
"constructor",
"=",
"loaded",
".",
"getConstructor",
"(",
"argClasses",
")",
";",
"return",
"clazz",
".",
"cast",
"(",
"constructor",
".",
"newInstance",
"(",
"args",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
]
| Create and instance of the specified class using the constructor matching the specified
arguments.
@param <T> the class type
@param className the name of the class to instantiate
@param clazz a class to cast the result as
@param args arguments to a constructor
@return an instance of the specified class | [
"Create",
"and",
"instance",
"of",
"the",
"specified",
"class",
"using",
"the",
"constructor",
"matching",
"the",
"specified",
"arguments",
"."
]
| train | https://github.com/brettwooldridge/HikariCP/blob/c509ec1a3f1e19769ee69323972f339cf098ff4b/src/main/java/com/zaxxer/hikari/util/UtilityElf.java#L92-L114 |
facebookarchive/hadoop-20 | src/contrib/namespace-notifier/src/java/org/apache/hadoop/hdfs/notifier/NamespaceNotifierClient.java | NamespaceNotifierClient.removeWatch | public void removeWatch(String path, EventType watchType)
throws NotConnectedToServerException, InterruptedException,
WatchNotPlacedException {
"""
Removes a previously placed watch for a particular event type from the
given path. If the watch is not actually present at that path before
calling the method, nothing will happen.
To remove the watch for all event types at this path, use
{@link #removeAllWatches(String)}.
@param path the path from which the watch is removed. For the FILE_ADDED event
type, this represents the path of the directory under which the
file will be created.
@param watchType the type of the event for which don't want to receive
notifications from now on.
@return true if successfully removed watch. false if the watch wasn't
placed before calling this method.
@throws WatchNotPlacedException if the watch wasn't placed before calling
this method.
@throws NotConnectedToServerException when the Watcher.connectionSuccessful
method was not called (the connection to the server isn't
established yet) at start-up or after a Watcher.connectionFailed
call. The Watcher.connectionFailed could of happened anytime
since the last Watcher.connectionSuccessfull call until this
method returns.
"""
NamespaceEvent event = new NamespaceEvent(path, watchType.getByteValue());
NamespaceEventKey eventKey = new NamespaceEventKey(path, watchType);
Object connectionLock = connectionManager.getConnectionLock();
ServerHandler.Client server;
LOG.info(listeningPort + ": removeWatch: Removing watch from " +
NotifierUtils.asString(eventKey) + " ...");
if (!watchedEvents.containsKey(eventKey)) {
LOG.warn(listeningPort + ": removeWatch: watch doesen't exist at " +
NotifierUtils.asString(eventKey) + " ...");
throw new WatchNotPlacedException();
}
synchronized (connectionLock) {
connectionManager.waitForTransparentConnect();
server = connectionManager.getServer();
try {
server.unsubscribe(connectionManager.getId(), event);
} catch (InvalidClientIdException e1) {
LOG.warn(listeningPort + ": removeWatch: server deleted us", e1);
connectionManager.failConnection(true);
} catch (ClientNotSubscribedException e2) {
LOG.error(listeningPort + ": removeWatch: event not subscribed", e2);
} catch (TException e3) {
LOG.error(listeningPort + ": removeWatch: failed communicating to" +
" server", e3);
connectionManager.failConnection(true);
}
watchedEvents.remove(eventKey);
}
if (LOG.isDebugEnabled()) {
LOG.debug(listeningPort + ": Unsubscribed from " +
NotifierUtils.asString(eventKey));
}
} | java | public void removeWatch(String path, EventType watchType)
throws NotConnectedToServerException, InterruptedException,
WatchNotPlacedException {
NamespaceEvent event = new NamespaceEvent(path, watchType.getByteValue());
NamespaceEventKey eventKey = new NamespaceEventKey(path, watchType);
Object connectionLock = connectionManager.getConnectionLock();
ServerHandler.Client server;
LOG.info(listeningPort + ": removeWatch: Removing watch from " +
NotifierUtils.asString(eventKey) + " ...");
if (!watchedEvents.containsKey(eventKey)) {
LOG.warn(listeningPort + ": removeWatch: watch doesen't exist at " +
NotifierUtils.asString(eventKey) + " ...");
throw new WatchNotPlacedException();
}
synchronized (connectionLock) {
connectionManager.waitForTransparentConnect();
server = connectionManager.getServer();
try {
server.unsubscribe(connectionManager.getId(), event);
} catch (InvalidClientIdException e1) {
LOG.warn(listeningPort + ": removeWatch: server deleted us", e1);
connectionManager.failConnection(true);
} catch (ClientNotSubscribedException e2) {
LOG.error(listeningPort + ": removeWatch: event not subscribed", e2);
} catch (TException e3) {
LOG.error(listeningPort + ": removeWatch: failed communicating to" +
" server", e3);
connectionManager.failConnection(true);
}
watchedEvents.remove(eventKey);
}
if (LOG.isDebugEnabled()) {
LOG.debug(listeningPort + ": Unsubscribed from " +
NotifierUtils.asString(eventKey));
}
} | [
"public",
"void",
"removeWatch",
"(",
"String",
"path",
",",
"EventType",
"watchType",
")",
"throws",
"NotConnectedToServerException",
",",
"InterruptedException",
",",
"WatchNotPlacedException",
"{",
"NamespaceEvent",
"event",
"=",
"new",
"NamespaceEvent",
"(",
"path",
",",
"watchType",
".",
"getByteValue",
"(",
")",
")",
";",
"NamespaceEventKey",
"eventKey",
"=",
"new",
"NamespaceEventKey",
"(",
"path",
",",
"watchType",
")",
";",
"Object",
"connectionLock",
"=",
"connectionManager",
".",
"getConnectionLock",
"(",
")",
";",
"ServerHandler",
".",
"Client",
"server",
";",
"LOG",
".",
"info",
"(",
"listeningPort",
"+",
"\": removeWatch: Removing watch from \"",
"+",
"NotifierUtils",
".",
"asString",
"(",
"eventKey",
")",
"+",
"\" ...\"",
")",
";",
"if",
"(",
"!",
"watchedEvents",
".",
"containsKey",
"(",
"eventKey",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"listeningPort",
"+",
"\": removeWatch: watch doesen't exist at \"",
"+",
"NotifierUtils",
".",
"asString",
"(",
"eventKey",
")",
"+",
"\" ...\"",
")",
";",
"throw",
"new",
"WatchNotPlacedException",
"(",
")",
";",
"}",
"synchronized",
"(",
"connectionLock",
")",
"{",
"connectionManager",
".",
"waitForTransparentConnect",
"(",
")",
";",
"server",
"=",
"connectionManager",
".",
"getServer",
"(",
")",
";",
"try",
"{",
"server",
".",
"unsubscribe",
"(",
"connectionManager",
".",
"getId",
"(",
")",
",",
"event",
")",
";",
"}",
"catch",
"(",
"InvalidClientIdException",
"e1",
")",
"{",
"LOG",
".",
"warn",
"(",
"listeningPort",
"+",
"\": removeWatch: server deleted us\"",
",",
"e1",
")",
";",
"connectionManager",
".",
"failConnection",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"ClientNotSubscribedException",
"e2",
")",
"{",
"LOG",
".",
"error",
"(",
"listeningPort",
"+",
"\": removeWatch: event not subscribed\"",
",",
"e2",
")",
";",
"}",
"catch",
"(",
"TException",
"e3",
")",
"{",
"LOG",
".",
"error",
"(",
"listeningPort",
"+",
"\": removeWatch: failed communicating to\"",
"+",
"\" server\"",
",",
"e3",
")",
";",
"connectionManager",
".",
"failConnection",
"(",
"true",
")",
";",
"}",
"watchedEvents",
".",
"remove",
"(",
"eventKey",
")",
";",
"}",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"listeningPort",
"+",
"\": Unsubscribed from \"",
"+",
"NotifierUtils",
".",
"asString",
"(",
"eventKey",
")",
")",
";",
"}",
"}"
]
| Removes a previously placed watch for a particular event type from the
given path. If the watch is not actually present at that path before
calling the method, nothing will happen.
To remove the watch for all event types at this path, use
{@link #removeAllWatches(String)}.
@param path the path from which the watch is removed. For the FILE_ADDED event
type, this represents the path of the directory under which the
file will be created.
@param watchType the type of the event for which don't want to receive
notifications from now on.
@return true if successfully removed watch. false if the watch wasn't
placed before calling this method.
@throws WatchNotPlacedException if the watch wasn't placed before calling
this method.
@throws NotConnectedToServerException when the Watcher.connectionSuccessful
method was not called (the connection to the server isn't
established yet) at start-up or after a Watcher.connectionFailed
call. The Watcher.connectionFailed could of happened anytime
since the last Watcher.connectionSuccessfull call until this
method returns. | [
"Removes",
"a",
"previously",
"placed",
"watch",
"for",
"a",
"particular",
"event",
"type",
"from",
"the",
"given",
"path",
".",
"If",
"the",
"watch",
"is",
"not",
"actually",
"present",
"at",
"that",
"path",
"before",
"calling",
"the",
"method",
"nothing",
"will",
"happen",
"."
]
| train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/namespace-notifier/src/java/org/apache/hadoop/hdfs/notifier/NamespaceNotifierClient.java#L356-L396 |
rapidoid/rapidoid | rapidoid-rest/src/main/java/org/rapidoid/setup/App.java | App.bootstrap | public static synchronized void bootstrap(String[] args, String... extraArgs) {
"""
Initializes the app in non-atomic way.
Then scans the classpath for beans.
Then starts serving requests immediately when routes are configured.
"""
AppStarter.startUp(args, extraArgs);
boot();
App.scan(); // scan classpath for beans
// finish initialization and start the application
onAppReady();
boot();
} | java | public static synchronized void bootstrap(String[] args, String... extraArgs) {
AppStarter.startUp(args, extraArgs);
boot();
App.scan(); // scan classpath for beans
// finish initialization and start the application
onAppReady();
boot();
} | [
"public",
"static",
"synchronized",
"void",
"bootstrap",
"(",
"String",
"[",
"]",
"args",
",",
"String",
"...",
"extraArgs",
")",
"{",
"AppStarter",
".",
"startUp",
"(",
"args",
",",
"extraArgs",
")",
";",
"boot",
"(",
")",
";",
"App",
".",
"scan",
"(",
")",
";",
"// scan classpath for beans",
"// finish initialization and start the application",
"onAppReady",
"(",
")",
";",
"boot",
"(",
")",
";",
"}"
]
| Initializes the app in non-atomic way.
Then scans the classpath for beans.
Then starts serving requests immediately when routes are configured. | [
"Initializes",
"the",
"app",
"in",
"non",
"-",
"atomic",
"way",
".",
"Then",
"scans",
"the",
"classpath",
"for",
"beans",
".",
"Then",
"starts",
"serving",
"requests",
"immediately",
"when",
"routes",
"are",
"configured",
"."
]
| train | https://github.com/rapidoid/rapidoid/blob/1775344bcf4abbee289d474b34d553ff6bc821b0/rapidoid-rest/src/main/java/org/rapidoid/setup/App.java#L107-L118 |
knowm/XChart | xchart/src/main/java/org/knowm/xchart/CSVExporter.java | CSVExporter.writeCSVColumns | public static void writeCSVColumns(XYSeries series, String path2Dir) {
"""
Export a Chart series in columns in a CSV file.
@param series
@param path2Dir - ex. "./path/to/directory/" *make sure you have the '/' on the end
"""
File newFile = new File(path2Dir + series.getName() + ".csv");
Writer out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), "UTF8"));
double[] xData = series.getXData();
double[] yData = series.getYData();
double[] errorBarData = series.getExtraValues();
for (int i = 0; i < xData.length; i++) {
StringBuilder sb = new StringBuilder();
sb.append(xData[i]).append(",");
sb.append(yData[i]).append(",");
if (errorBarData != null) {
sb.append(errorBarData[i]).append(",");
}
sb.setLength(sb.length() - 1);
sb.append(System.getProperty("line.separator"));
// String csv = xDataPoint + "," + yDataPoint + errorBarValue == null ? "" : ("," +
// errorBarValue) + System.getProperty("line.separator");
// String csv = + yDataPoint + System.getProperty("line.separator");
out.write(sb.toString());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (IOException e) {
// NOP
}
}
}
} | java | public static void writeCSVColumns(XYSeries series, String path2Dir) {
File newFile = new File(path2Dir + series.getName() + ".csv");
Writer out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), "UTF8"));
double[] xData = series.getXData();
double[] yData = series.getYData();
double[] errorBarData = series.getExtraValues();
for (int i = 0; i < xData.length; i++) {
StringBuilder sb = new StringBuilder();
sb.append(xData[i]).append(",");
sb.append(yData[i]).append(",");
if (errorBarData != null) {
sb.append(errorBarData[i]).append(",");
}
sb.setLength(sb.length() - 1);
sb.append(System.getProperty("line.separator"));
// String csv = xDataPoint + "," + yDataPoint + errorBarValue == null ? "" : ("," +
// errorBarValue) + System.getProperty("line.separator");
// String csv = + yDataPoint + System.getProperty("line.separator");
out.write(sb.toString());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (IOException e) {
// NOP
}
}
}
} | [
"public",
"static",
"void",
"writeCSVColumns",
"(",
"XYSeries",
"series",
",",
"String",
"path2Dir",
")",
"{",
"File",
"newFile",
"=",
"new",
"File",
"(",
"path2Dir",
"+",
"series",
".",
"getName",
"(",
")",
"+",
"\".csv\"",
")",
";",
"Writer",
"out",
"=",
"null",
";",
"try",
"{",
"out",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"newFile",
")",
",",
"\"UTF8\"",
")",
")",
";",
"double",
"[",
"]",
"xData",
"=",
"series",
".",
"getXData",
"(",
")",
";",
"double",
"[",
"]",
"yData",
"=",
"series",
".",
"getYData",
"(",
")",
";",
"double",
"[",
"]",
"errorBarData",
"=",
"series",
".",
"getExtraValues",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"xData",
".",
"length",
";",
"i",
"++",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"xData",
"[",
"i",
"]",
")",
".",
"append",
"(",
"\",\"",
")",
";",
"sb",
".",
"append",
"(",
"yData",
"[",
"i",
"]",
")",
".",
"append",
"(",
"\",\"",
")",
";",
"if",
"(",
"errorBarData",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"errorBarData",
"[",
"i",
"]",
")",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"sb",
".",
"setLength",
"(",
"sb",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"sb",
".",
"append",
"(",
"System",
".",
"getProperty",
"(",
"\"line.separator\"",
")",
")",
";",
"// String csv = xDataPoint + \",\" + yDataPoint + errorBarValue == null ? \"\" : (\",\" +",
"// errorBarValue) + System.getProperty(\"line.separator\");",
"// String csv = + yDataPoint + System.getProperty(\"line.separator\");",
"out",
".",
"write",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"out",
"!=",
"null",
")",
"{",
"try",
"{",
"out",
".",
"flush",
"(",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// NOP",
"}",
"}",
"}",
"}"
]
| Export a Chart series in columns in a CSV file.
@param series
@param path2Dir - ex. "./path/to/directory/" *make sure you have the '/' on the end | [
"Export",
"a",
"Chart",
"series",
"in",
"columns",
"in",
"a",
"CSV",
"file",
"."
]
| train | https://github.com/knowm/XChart/blob/677a105753a855edf24782fab1bf1f5aec3e642b/xchart/src/main/java/org/knowm/xchart/CSVExporter.java#L104-L142 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/rectify/RectifyCalibrated.java | RectifyCalibrated.process | public void process( DMatrixRMaj K1 , Se3_F64 worldToCamera1 ,
DMatrixRMaj K2 , Se3_F64 worldToCamera2 ) {
"""
Computes rectification transforms for both cameras and optionally a single calibration
matrix.
@param K1 Calibration matrix for first camera.
@param worldToCamera1 Location of the first camera.
@param K2 Calibration matrix for second camera.
@param worldToCamera2 Location of the second camera.
"""
SimpleMatrix sK1 = SimpleMatrix.wrap(K1);
SimpleMatrix sK2 = SimpleMatrix.wrap(K2);
SimpleMatrix R1 = SimpleMatrix.wrap(worldToCamera1.getR());
SimpleMatrix R2 = SimpleMatrix.wrap(worldToCamera2.getR());
SimpleMatrix T1 = new SimpleMatrix(3,1,true,
new double[]{worldToCamera1.getT().x,worldToCamera1.getT().y,worldToCamera1.getT().z});
SimpleMatrix T2 = new SimpleMatrix(3,1,true,
new double[]{worldToCamera2.getT().x,worldToCamera2.getT().y,worldToCamera2.getT().z});
// P = K*[R|T]
SimpleMatrix KR1 = sK1.mult(R1);
SimpleMatrix KR2 = sK2.mult(R2);
// compute optical centers in world reference frame
// c = -R'*T
SimpleMatrix c1 = R1.transpose().mult(T1.scale(-1));
SimpleMatrix c2 = R2.transpose().mult(T2.scale(-1));
// new coordinate system axises
selectAxises(R1,R2, c1, c2);
// new extrinsic parameters, rotation matrix with rows of camera 1's coordinate system in
// the world frame
SimpleMatrix RR = new SimpleMatrix(3,3,true,
new double[]{
v1.x,v1.y,v1.z,
v2.x,v2.y,v2.z,
v3.x,v3.y,v3.z});
// new calibration matrix that is an average of the original
K = sK1.plus(sK2).scale(0.5);
K.set(0,1,0);// set skew to zero
// new projection rotation matrices
SimpleMatrix KRR = K.mult(RR);
// rectification transforms
rect1.set(KRR.mult(KR1.invert()).getDDRM());
rect2.set(KRR.mult(KR2.invert()).getDDRM());
rectifiedR = RR.getDDRM();
} | java | public void process( DMatrixRMaj K1 , Se3_F64 worldToCamera1 ,
DMatrixRMaj K2 , Se3_F64 worldToCamera2 )
{
SimpleMatrix sK1 = SimpleMatrix.wrap(K1);
SimpleMatrix sK2 = SimpleMatrix.wrap(K2);
SimpleMatrix R1 = SimpleMatrix.wrap(worldToCamera1.getR());
SimpleMatrix R2 = SimpleMatrix.wrap(worldToCamera2.getR());
SimpleMatrix T1 = new SimpleMatrix(3,1,true,
new double[]{worldToCamera1.getT().x,worldToCamera1.getT().y,worldToCamera1.getT().z});
SimpleMatrix T2 = new SimpleMatrix(3,1,true,
new double[]{worldToCamera2.getT().x,worldToCamera2.getT().y,worldToCamera2.getT().z});
// P = K*[R|T]
SimpleMatrix KR1 = sK1.mult(R1);
SimpleMatrix KR2 = sK2.mult(R2);
// compute optical centers in world reference frame
// c = -R'*T
SimpleMatrix c1 = R1.transpose().mult(T1.scale(-1));
SimpleMatrix c2 = R2.transpose().mult(T2.scale(-1));
// new coordinate system axises
selectAxises(R1,R2, c1, c2);
// new extrinsic parameters, rotation matrix with rows of camera 1's coordinate system in
// the world frame
SimpleMatrix RR = new SimpleMatrix(3,3,true,
new double[]{
v1.x,v1.y,v1.z,
v2.x,v2.y,v2.z,
v3.x,v3.y,v3.z});
// new calibration matrix that is an average of the original
K = sK1.plus(sK2).scale(0.5);
K.set(0,1,0);// set skew to zero
// new projection rotation matrices
SimpleMatrix KRR = K.mult(RR);
// rectification transforms
rect1.set(KRR.mult(KR1.invert()).getDDRM());
rect2.set(KRR.mult(KR2.invert()).getDDRM());
rectifiedR = RR.getDDRM();
} | [
"public",
"void",
"process",
"(",
"DMatrixRMaj",
"K1",
",",
"Se3_F64",
"worldToCamera1",
",",
"DMatrixRMaj",
"K2",
",",
"Se3_F64",
"worldToCamera2",
")",
"{",
"SimpleMatrix",
"sK1",
"=",
"SimpleMatrix",
".",
"wrap",
"(",
"K1",
")",
";",
"SimpleMatrix",
"sK2",
"=",
"SimpleMatrix",
".",
"wrap",
"(",
"K2",
")",
";",
"SimpleMatrix",
"R1",
"=",
"SimpleMatrix",
".",
"wrap",
"(",
"worldToCamera1",
".",
"getR",
"(",
")",
")",
";",
"SimpleMatrix",
"R2",
"=",
"SimpleMatrix",
".",
"wrap",
"(",
"worldToCamera2",
".",
"getR",
"(",
")",
")",
";",
"SimpleMatrix",
"T1",
"=",
"new",
"SimpleMatrix",
"(",
"3",
",",
"1",
",",
"true",
",",
"new",
"double",
"[",
"]",
"{",
"worldToCamera1",
".",
"getT",
"(",
")",
".",
"x",
",",
"worldToCamera1",
".",
"getT",
"(",
")",
".",
"y",
",",
"worldToCamera1",
".",
"getT",
"(",
")",
".",
"z",
"}",
")",
";",
"SimpleMatrix",
"T2",
"=",
"new",
"SimpleMatrix",
"(",
"3",
",",
"1",
",",
"true",
",",
"new",
"double",
"[",
"]",
"{",
"worldToCamera2",
".",
"getT",
"(",
")",
".",
"x",
",",
"worldToCamera2",
".",
"getT",
"(",
")",
".",
"y",
",",
"worldToCamera2",
".",
"getT",
"(",
")",
".",
"z",
"}",
")",
";",
"// P = K*[R|T]",
"SimpleMatrix",
"KR1",
"=",
"sK1",
".",
"mult",
"(",
"R1",
")",
";",
"SimpleMatrix",
"KR2",
"=",
"sK2",
".",
"mult",
"(",
"R2",
")",
";",
"// compute optical centers in world reference frame",
"// c = -R'*T",
"SimpleMatrix",
"c1",
"=",
"R1",
".",
"transpose",
"(",
")",
".",
"mult",
"(",
"T1",
".",
"scale",
"(",
"-",
"1",
")",
")",
";",
"SimpleMatrix",
"c2",
"=",
"R2",
".",
"transpose",
"(",
")",
".",
"mult",
"(",
"T2",
".",
"scale",
"(",
"-",
"1",
")",
")",
";",
"// new coordinate system axises",
"selectAxises",
"(",
"R1",
",",
"R2",
",",
"c1",
",",
"c2",
")",
";",
"// new extrinsic parameters, rotation matrix with rows of camera 1's coordinate system in",
"// the world frame",
"SimpleMatrix",
"RR",
"=",
"new",
"SimpleMatrix",
"(",
"3",
",",
"3",
",",
"true",
",",
"new",
"double",
"[",
"]",
"{",
"v1",
".",
"x",
",",
"v1",
".",
"y",
",",
"v1",
".",
"z",
",",
"v2",
".",
"x",
",",
"v2",
".",
"y",
",",
"v2",
".",
"z",
",",
"v3",
".",
"x",
",",
"v3",
".",
"y",
",",
"v3",
".",
"z",
"}",
")",
";",
"// new calibration matrix that is an average of the original",
"K",
"=",
"sK1",
".",
"plus",
"(",
"sK2",
")",
".",
"scale",
"(",
"0.5",
")",
";",
"K",
".",
"set",
"(",
"0",
",",
"1",
",",
"0",
")",
";",
"// set skew to zero",
"// new projection rotation matrices",
"SimpleMatrix",
"KRR",
"=",
"K",
".",
"mult",
"(",
"RR",
")",
";",
"// rectification transforms",
"rect1",
".",
"set",
"(",
"KRR",
".",
"mult",
"(",
"KR1",
".",
"invert",
"(",
")",
")",
".",
"getDDRM",
"(",
")",
")",
";",
"rect2",
".",
"set",
"(",
"KRR",
".",
"mult",
"(",
"KR2",
".",
"invert",
"(",
")",
")",
".",
"getDDRM",
"(",
")",
")",
";",
"rectifiedR",
"=",
"RR",
".",
"getDDRM",
"(",
")",
";",
"}"
]
| Computes rectification transforms for both cameras and optionally a single calibration
matrix.
@param K1 Calibration matrix for first camera.
@param worldToCamera1 Location of the first camera.
@param K2 Calibration matrix for second camera.
@param worldToCamera2 Location of the second camera. | [
"Computes",
"rectification",
"transforms",
"for",
"both",
"cameras",
"and",
"optionally",
"a",
"single",
"calibration",
"matrix",
"."
]
| train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/rectify/RectifyCalibrated.java#L79-L123 |
apache/flink | flink-core/src/main/java/org/apache/flink/core/fs/EntropyInjector.java | EntropyInjector.createEntropyAware | public static OutputStreamAndPath createEntropyAware(
FileSystem fs,
Path path,
WriteMode writeMode) throws IOException {
"""
Handles entropy injection across regular and entropy-aware file systems.
<p>If the given file system is entropy-aware (a implements {@link EntropyInjectingFileSystem}),
then this method replaces the entropy marker in the path with random characters.
The entropy marker is defined by {@link EntropyInjectingFileSystem#getEntropyInjectionKey()}.
<p>If the given file system does not implement {@code EntropyInjectingFileSystem},
then this method delegates to {@link FileSystem#create(Path, WriteMode)} and
returns the same path in the resulting {@code OutputStreamAndPath}.
"""
// check and possibly inject entropy into the path
final EntropyInjectingFileSystem efs = getEntropyFs(fs);
final Path processedPath = efs == null ? path : resolveEntropy(path, efs, true);
// create the stream on the original file system to let the safety net
// take its effect
final FSDataOutputStream out = fs.create(processedPath, writeMode);
return new OutputStreamAndPath(out, processedPath);
} | java | public static OutputStreamAndPath createEntropyAware(
FileSystem fs,
Path path,
WriteMode writeMode) throws IOException {
// check and possibly inject entropy into the path
final EntropyInjectingFileSystem efs = getEntropyFs(fs);
final Path processedPath = efs == null ? path : resolveEntropy(path, efs, true);
// create the stream on the original file system to let the safety net
// take its effect
final FSDataOutputStream out = fs.create(processedPath, writeMode);
return new OutputStreamAndPath(out, processedPath);
} | [
"public",
"static",
"OutputStreamAndPath",
"createEntropyAware",
"(",
"FileSystem",
"fs",
",",
"Path",
"path",
",",
"WriteMode",
"writeMode",
")",
"throws",
"IOException",
"{",
"// check and possibly inject entropy into the path",
"final",
"EntropyInjectingFileSystem",
"efs",
"=",
"getEntropyFs",
"(",
"fs",
")",
";",
"final",
"Path",
"processedPath",
"=",
"efs",
"==",
"null",
"?",
"path",
":",
"resolveEntropy",
"(",
"path",
",",
"efs",
",",
"true",
")",
";",
"// create the stream on the original file system to let the safety net",
"// take its effect",
"final",
"FSDataOutputStream",
"out",
"=",
"fs",
".",
"create",
"(",
"processedPath",
",",
"writeMode",
")",
";",
"return",
"new",
"OutputStreamAndPath",
"(",
"out",
",",
"processedPath",
")",
";",
"}"
]
| Handles entropy injection across regular and entropy-aware file systems.
<p>If the given file system is entropy-aware (a implements {@link EntropyInjectingFileSystem}),
then this method replaces the entropy marker in the path with random characters.
The entropy marker is defined by {@link EntropyInjectingFileSystem#getEntropyInjectionKey()}.
<p>If the given file system does not implement {@code EntropyInjectingFileSystem},
then this method delegates to {@link FileSystem#create(Path, WriteMode)} and
returns the same path in the resulting {@code OutputStreamAndPath}. | [
"Handles",
"entropy",
"injection",
"across",
"regular",
"and",
"entropy",
"-",
"aware",
"file",
"systems",
"."
]
| train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/core/fs/EntropyInjector.java#L50-L63 |
google/closure-compiler | src/com/google/javascript/jscomp/deps/PathUtil.java | PathUtil.makeAbsolute | public static String makeAbsolute(String path, String rootPath) {
"""
Converts the given path into an absolute one. This prepends the given
rootPath and removes all .'s from the path. If an absolute path is given,
it will not be prefixed.
<p>Unlike File.getAbsolutePath(), this function does remove .'s from the
path and unlike File.getCanonicalPath(), this function does not resolve
symlinks and does not use filesystem calls.</p>
@param rootPath The path to prefix to path if path is not already absolute.
@param path The path to make absolute.
@return The path made absolute.
"""
if (!isAbsolute(path)) {
path = rootPath + "/" + path;
}
return collapseDots(path);
} | java | public static String makeAbsolute(String path, String rootPath) {
if (!isAbsolute(path)) {
path = rootPath + "/" + path;
}
return collapseDots(path);
} | [
"public",
"static",
"String",
"makeAbsolute",
"(",
"String",
"path",
",",
"String",
"rootPath",
")",
"{",
"if",
"(",
"!",
"isAbsolute",
"(",
"path",
")",
")",
"{",
"path",
"=",
"rootPath",
"+",
"\"/\"",
"+",
"path",
";",
"}",
"return",
"collapseDots",
"(",
"path",
")",
";",
"}"
]
| Converts the given path into an absolute one. This prepends the given
rootPath and removes all .'s from the path. If an absolute path is given,
it will not be prefixed.
<p>Unlike File.getAbsolutePath(), this function does remove .'s from the
path and unlike File.getCanonicalPath(), this function does not resolve
symlinks and does not use filesystem calls.</p>
@param rootPath The path to prefix to path if path is not already absolute.
@param path The path to make absolute.
@return The path made absolute. | [
"Converts",
"the",
"given",
"path",
"into",
"an",
"absolute",
"one",
".",
"This",
"prepends",
"the",
"given",
"rootPath",
"and",
"removes",
"all",
".",
"s",
"from",
"the",
"path",
".",
"If",
"an",
"absolute",
"path",
"is",
"given",
"it",
"will",
"not",
"be",
"prefixed",
"."
]
| train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/deps/PathUtil.java#L138-L143 |
olivergondza/dumpling | core/src/main/java/com/github/olivergondza/dumpling/factory/jmx/JmxLocalProcessConnector.java | JmxLocalProcessConnector.getServerConnection | @SuppressWarnings("unused")
private static MBeanServerConnection getServerConnection(int pid) {
"""
This has to be called by reflection so it can as well be private to stress this is not an API
"""
try {
JMXServiceURL serviceURL = new JMXServiceURL(connectorAddress(pid));
return JMXConnectorFactory.connect(serviceURL).getMBeanServerConnection();
} catch (MalformedURLException ex) {
throw failed("JMX connection failed", ex);
} catch (IOException ex) {
throw failed("JMX connection failed", ex);
}
} | java | @SuppressWarnings("unused")
private static MBeanServerConnection getServerConnection(int pid) {
try {
JMXServiceURL serviceURL = new JMXServiceURL(connectorAddress(pid));
return JMXConnectorFactory.connect(serviceURL).getMBeanServerConnection();
} catch (MalformedURLException ex) {
throw failed("JMX connection failed", ex);
} catch (IOException ex) {
throw failed("JMX connection failed", ex);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"private",
"static",
"MBeanServerConnection",
"getServerConnection",
"(",
"int",
"pid",
")",
"{",
"try",
"{",
"JMXServiceURL",
"serviceURL",
"=",
"new",
"JMXServiceURL",
"(",
"connectorAddress",
"(",
"pid",
")",
")",
";",
"return",
"JMXConnectorFactory",
".",
"connect",
"(",
"serviceURL",
")",
".",
"getMBeanServerConnection",
"(",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"ex",
")",
"{",
"throw",
"failed",
"(",
"\"JMX connection failed\"",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"failed",
"(",
"\"JMX connection failed\"",
",",
"ex",
")",
";",
"}",
"}"
]
| This has to be called by reflection so it can as well be private to stress this is not an API | [
"This",
"has",
"to",
"be",
"called",
"by",
"reflection",
"so",
"it",
"can",
"as",
"well",
"be",
"private",
"to",
"stress",
"this",
"is",
"not",
"an",
"API"
]
| train | https://github.com/olivergondza/dumpling/blob/ac698735fcc7c023db0c1637cc1f522cb3576c7f/core/src/main/java/com/github/olivergondza/dumpling/factory/jmx/JmxLocalProcessConnector.java#L61-L73 |
lessthanoptimal/ejml | main/ejml-core/src/org/ejml/ops/MatrixFeatures_D.java | MatrixFeatures_D.isIdentical | public static boolean isIdentical(DMatrix a, DMatrix b , double tol ) {
"""
<p>
Checks to see if each corresponding element in the two matrices are
within tolerance of each other or have the some symbolic meaning. This
can handle NaN and Infinite numbers.
<p>
<p>
If both elements are countable then the following equality test is used:<br>
|a<sub>ij</sub> - b<sub>ij</sub>| ≤ tol.<br>
Otherwise both numbers must both be Double.NaN, Double.POSITIVE_INFINITY, or
Double.NEGATIVE_INFINITY to be identical.
</p>
@param a A matrix. Not modified.
@param b A matrix. Not modified.
@param tol Tolerance for equality.
@return true if identical and false otherwise.
"""
if( a.getNumRows() != b.getNumRows() || a.getNumCols() != b.getNumCols() ) {
return false;
}
if( tol < 0 )
throw new IllegalArgumentException("Tolerance must be greater than or equal to zero.");
final int numRows = a.getNumRows();
final int numCols = a.getNumCols();
for (int row = 0; row < numRows; row++) {
for (int col = 0; col < numCols; col++) {
if( !UtilEjml.isIdentical(a.unsafe_get(row,col),b.unsafe_get(row,col), tol))
return false;
}
}
return true;
} | java | public static boolean isIdentical(DMatrix a, DMatrix b , double tol ) {
if( a.getNumRows() != b.getNumRows() || a.getNumCols() != b.getNumCols() ) {
return false;
}
if( tol < 0 )
throw new IllegalArgumentException("Tolerance must be greater than or equal to zero.");
final int numRows = a.getNumRows();
final int numCols = a.getNumCols();
for (int row = 0; row < numRows; row++) {
for (int col = 0; col < numCols; col++) {
if( !UtilEjml.isIdentical(a.unsafe_get(row,col),b.unsafe_get(row,col), tol))
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isIdentical",
"(",
"DMatrix",
"a",
",",
"DMatrix",
"b",
",",
"double",
"tol",
")",
"{",
"if",
"(",
"a",
".",
"getNumRows",
"(",
")",
"!=",
"b",
".",
"getNumRows",
"(",
")",
"||",
"a",
".",
"getNumCols",
"(",
")",
"!=",
"b",
".",
"getNumCols",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"tol",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Tolerance must be greater than or equal to zero.\"",
")",
";",
"final",
"int",
"numRows",
"=",
"a",
".",
"getNumRows",
"(",
")",
";",
"final",
"int",
"numCols",
"=",
"a",
".",
"getNumCols",
"(",
")",
";",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"numRows",
";",
"row",
"++",
")",
"{",
"for",
"(",
"int",
"col",
"=",
"0",
";",
"col",
"<",
"numCols",
";",
"col",
"++",
")",
"{",
"if",
"(",
"!",
"UtilEjml",
".",
"isIdentical",
"(",
"a",
".",
"unsafe_get",
"(",
"row",
",",
"col",
")",
",",
"b",
".",
"unsafe_get",
"(",
"row",
",",
"col",
")",
",",
"tol",
")",
")",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
]
| <p>
Checks to see if each corresponding element in the two matrices are
within tolerance of each other or have the some symbolic meaning. This
can handle NaN and Infinite numbers.
<p>
<p>
If both elements are countable then the following equality test is used:<br>
|a<sub>ij</sub> - b<sub>ij</sub>| ≤ tol.<br>
Otherwise both numbers must both be Double.NaN, Double.POSITIVE_INFINITY, or
Double.NEGATIVE_INFINITY to be identical.
</p>
@param a A matrix. Not modified.
@param b A matrix. Not modified.
@param tol Tolerance for equality.
@return true if identical and false otherwise. | [
"<p",
">",
"Checks",
"to",
"see",
"if",
"each",
"corresponding",
"element",
"in",
"the",
"two",
"matrices",
"are",
"within",
"tolerance",
"of",
"each",
"other",
"or",
"have",
"the",
"some",
"symbolic",
"meaning",
".",
"This",
"can",
"handle",
"NaN",
"and",
"Infinite",
"numbers",
".",
"<p",
">"
]
| train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/ops/MatrixFeatures_D.java#L81-L98 |
square/wire | wire-schema/src/main/java/com/squareup/wire/schema/Schema.java | Schema.protoAdapter | public ProtoAdapter<Object> protoAdapter(String typeName, boolean includeUnknown) {
"""
Returns a wire adapter for the message or enum type named {@code typeName}. The returned type
adapter doesn't have model classes to encode and decode from, so instead it uses scalar types
({@linkplain String}, {@linkplain okio.ByteString ByteString}, {@linkplain Integer}, etc.),
{@linkplain Map maps}, and {@linkplain java.util.List lists}. It can both encode and decode
these objects. Map keys are field names.
@param includeUnknown true to include values for unknown tags in the returned model. Map keys
for such values is the unknown value's tag name as a string. Unknown values are decoded to
{@linkplain Long}, {@linkplain Long}, {@linkplain Integer}, or {@linkplain okio.ByteString
ByteString} for {@linkplain com.squareup.wire.FieldEncoding#VARINT VARINT}, {@linkplain
com.squareup.wire.FieldEncoding#FIXED64 FIXED64}, {@linkplain
com.squareup.wire.FieldEncoding#FIXED32 FIXED32}, or {@linkplain
com.squareup.wire.FieldEncoding#LENGTH_DELIMITED LENGTH_DELIMITED} respectively.
"""
Type type = getType(typeName);
if (type == null) throw new IllegalArgumentException("unexpected type " + typeName);
return new SchemaProtoAdapterFactory(this, includeUnknown).get(type.type());
} | java | public ProtoAdapter<Object> protoAdapter(String typeName, boolean includeUnknown) {
Type type = getType(typeName);
if (type == null) throw new IllegalArgumentException("unexpected type " + typeName);
return new SchemaProtoAdapterFactory(this, includeUnknown).get(type.type());
} | [
"public",
"ProtoAdapter",
"<",
"Object",
">",
"protoAdapter",
"(",
"String",
"typeName",
",",
"boolean",
"includeUnknown",
")",
"{",
"Type",
"type",
"=",
"getType",
"(",
"typeName",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"unexpected type \"",
"+",
"typeName",
")",
";",
"return",
"new",
"SchemaProtoAdapterFactory",
"(",
"this",
",",
"includeUnknown",
")",
".",
"get",
"(",
"type",
".",
"type",
"(",
")",
")",
";",
"}"
]
| Returns a wire adapter for the message or enum type named {@code typeName}. The returned type
adapter doesn't have model classes to encode and decode from, so instead it uses scalar types
({@linkplain String}, {@linkplain okio.ByteString ByteString}, {@linkplain Integer}, etc.),
{@linkplain Map maps}, and {@linkplain java.util.List lists}. It can both encode and decode
these objects. Map keys are field names.
@param includeUnknown true to include values for unknown tags in the returned model. Map keys
for such values is the unknown value's tag name as a string. Unknown values are decoded to
{@linkplain Long}, {@linkplain Long}, {@linkplain Integer}, or {@linkplain okio.ByteString
ByteString} for {@linkplain com.squareup.wire.FieldEncoding#VARINT VARINT}, {@linkplain
com.squareup.wire.FieldEncoding#FIXED64 FIXED64}, {@linkplain
com.squareup.wire.FieldEncoding#FIXED32 FIXED32}, or {@linkplain
com.squareup.wire.FieldEncoding#LENGTH_DELIMITED LENGTH_DELIMITED} respectively. | [
"Returns",
"a",
"wire",
"adapter",
"for",
"the",
"message",
"or",
"enum",
"type",
"named",
"{",
"@code",
"typeName",
"}",
".",
"The",
"returned",
"type",
"adapter",
"doesn",
"t",
"have",
"model",
"classes",
"to",
"encode",
"and",
"decode",
"from",
"so",
"instead",
"it",
"uses",
"scalar",
"types",
"(",
"{",
"@linkplain",
"String",
"}",
"{",
"@linkplain",
"okio",
".",
"ByteString",
"ByteString",
"}",
"{",
"@linkplain",
"Integer",
"}",
"etc",
".",
")",
"{",
"@linkplain",
"Map",
"maps",
"}",
"and",
"{",
"@linkplain",
"java",
".",
"util",
".",
"List",
"lists",
"}",
".",
"It",
"can",
"both",
"encode",
"and",
"decode",
"these",
"objects",
".",
"Map",
"keys",
"are",
"field",
"names",
"."
]
| train | https://github.com/square/wire/blob/4a9a00dfadfc14d6a0780b85810418f9cbc78a49/wire-schema/src/main/java/com/squareup/wire/schema/Schema.java#L154-L158 |
jbundle/jbundle | base/message/core/src/main/java/org/jbundle/base/message/core/tree/TreeMessageFilterList.java | TreeMessageFilterList.removeMessageFilter | public boolean removeMessageFilter(Integer intFilterID, boolean bFreeFilter) {
"""
Remove this message filter from this queue.
Note: This will remove a filter that equals this filter, accounting for a copy
passed from a remote client.
@param messageFilter The message filter to remove.
@param bFreeFilter If true, free this filter.
@return True if successful.
"""
BaseMessageFilter messageFilter = this.getMessageFilter(intFilterID);
if (messageFilter == null)
return false; // It is possible for a client to try to remove it's remote filter that was removed as a duplicate filter.
boolean bRemoved = this.getRegistry().removeMessageFilter(messageFilter);
if (!bRemoved)
System.out.println("Filter not found on remove");
bRemoved = super.removeMessageFilter(intFilterID, bFreeFilter);
return bRemoved; // Success.
} | java | public boolean removeMessageFilter(Integer intFilterID, boolean bFreeFilter)
{
BaseMessageFilter messageFilter = this.getMessageFilter(intFilterID);
if (messageFilter == null)
return false; // It is possible for a client to try to remove it's remote filter that was removed as a duplicate filter.
boolean bRemoved = this.getRegistry().removeMessageFilter(messageFilter);
if (!bRemoved)
System.out.println("Filter not found on remove");
bRemoved = super.removeMessageFilter(intFilterID, bFreeFilter);
return bRemoved; // Success.
} | [
"public",
"boolean",
"removeMessageFilter",
"(",
"Integer",
"intFilterID",
",",
"boolean",
"bFreeFilter",
")",
"{",
"BaseMessageFilter",
"messageFilter",
"=",
"this",
".",
"getMessageFilter",
"(",
"intFilterID",
")",
";",
"if",
"(",
"messageFilter",
"==",
"null",
")",
"return",
"false",
";",
"// It is possible for a client to try to remove it's remote filter that was removed as a duplicate filter.",
"boolean",
"bRemoved",
"=",
"this",
".",
"getRegistry",
"(",
")",
".",
"removeMessageFilter",
"(",
"messageFilter",
")",
";",
"if",
"(",
"!",
"bRemoved",
")",
"System",
".",
"out",
".",
"println",
"(",
"\"Filter not found on remove\"",
")",
";",
"bRemoved",
"=",
"super",
".",
"removeMessageFilter",
"(",
"intFilterID",
",",
"bFreeFilter",
")",
";",
"return",
"bRemoved",
";",
"// Success.",
"}"
]
| Remove this message filter from this queue.
Note: This will remove a filter that equals this filter, accounting for a copy
passed from a remote client.
@param messageFilter The message filter to remove.
@param bFreeFilter If true, free this filter.
@return True if successful. | [
"Remove",
"this",
"message",
"filter",
"from",
"this",
"queue",
".",
"Note",
":",
"This",
"will",
"remove",
"a",
"filter",
"that",
"equals",
"this",
"filter",
"accounting",
"for",
"a",
"copy",
"passed",
"from",
"a",
"remote",
"client",
"."
]
| train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/core/src/main/java/org/jbundle/base/message/core/tree/TreeMessageFilterList.java#L74-L84 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/WebhooksInner.java | WebhooksInner.createOrUpdate | public WebhookInner createOrUpdate(String resourceGroupName, String automationAccountName, String webhookName, WebhookCreateOrUpdateParameters parameters) {
"""
Create the webhook identified by webhook name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param webhookName The webhook name.
@param parameters The create or update parameters for webhook.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the WebhookInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, automationAccountName, webhookName, parameters).toBlocking().single().body();
} | java | public WebhookInner createOrUpdate(String resourceGroupName, String automationAccountName, String webhookName, WebhookCreateOrUpdateParameters parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, automationAccountName, webhookName, parameters).toBlocking().single().body();
} | [
"public",
"WebhookInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"webhookName",
",",
"WebhookCreateOrUpdateParameters",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"webhookName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
]
| Create the webhook identified by webhook name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param webhookName The webhook name.
@param parameters The create or update parameters for webhook.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the WebhookInner object if successful. | [
"Create",
"the",
"webhook",
"identified",
"by",
"webhook",
"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/WebhooksInner.java#L375-L377 |
strator-dev/greenpepper | greenpepper/greenpepper-client/src/main/java/com/greenpepper/server/domain/Repository.java | Repository.removeSpecification | public void removeSpecification(Specification specification) throws GreenPepperServerException {
"""
<p>removeSpecification.</p>
@param specification a {@link com.greenpepper.server.domain.Specification} object.
@throws com.greenpepper.server.GreenPepperServerException if any.
"""
if(!specifications.contains(specification))
throw new GreenPepperServerException( GreenPepperServerErrorKey.SPECIFICATION_NOT_FOUND, "Specification not found");
specifications.remove(specification);
specification.setRepository(null);
} | java | public void removeSpecification(Specification specification) throws GreenPepperServerException
{
if(!specifications.contains(specification))
throw new GreenPepperServerException( GreenPepperServerErrorKey.SPECIFICATION_NOT_FOUND, "Specification not found");
specifications.remove(specification);
specification.setRepository(null);
} | [
"public",
"void",
"removeSpecification",
"(",
"Specification",
"specification",
")",
"throws",
"GreenPepperServerException",
"{",
"if",
"(",
"!",
"specifications",
".",
"contains",
"(",
"specification",
")",
")",
"throw",
"new",
"GreenPepperServerException",
"(",
"GreenPepperServerErrorKey",
".",
"SPECIFICATION_NOT_FOUND",
",",
"\"Specification not found\"",
")",
";",
"specifications",
".",
"remove",
"(",
"specification",
")",
";",
"specification",
".",
"setRepository",
"(",
"null",
")",
";",
"}"
]
| <p>removeSpecification.</p>
@param specification a {@link com.greenpepper.server.domain.Specification} object.
@throws com.greenpepper.server.GreenPepperServerException if any. | [
"<p",
">",
"removeSpecification",
".",
"<",
"/",
"p",
">"
]
| train | https://github.com/strator-dev/greenpepper/blob/2a61e6c179b74085babcc559d677490b0cad2d30/greenpepper/greenpepper-client/src/main/java/com/greenpepper/server/domain/Repository.java#L393-L400 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/view/MotionEventUtils.java | MotionEventUtils.getVerticalMotionDirection | public static MotionDirection getVerticalMotionDirection(float delta, float threshold) {
"""
Calculate the vertical move motion direction.
@param delta moved delta.
@param threshold threshold to detect the motion.
@return the motion direction for the vertical axis.
"""
if (threshold < 0) {
throw new IllegalArgumentException("threshold should be positive or zero.");
}
return delta < -threshold ? MotionDirection.DOWN : delta > threshold ? MotionDirection.UP : MotionDirection.FIX;
} | java | public static MotionDirection getVerticalMotionDirection(float delta, float threshold) {
if (threshold < 0) {
throw new IllegalArgumentException("threshold should be positive or zero.");
}
return delta < -threshold ? MotionDirection.DOWN : delta > threshold ? MotionDirection.UP : MotionDirection.FIX;
} | [
"public",
"static",
"MotionDirection",
"getVerticalMotionDirection",
"(",
"float",
"delta",
",",
"float",
"threshold",
")",
"{",
"if",
"(",
"threshold",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"threshold should be positive or zero.\"",
")",
";",
"}",
"return",
"delta",
"<",
"-",
"threshold",
"?",
"MotionDirection",
".",
"DOWN",
":",
"delta",
">",
"threshold",
"?",
"MotionDirection",
".",
"UP",
":",
"MotionDirection",
".",
"FIX",
";",
"}"
]
| Calculate the vertical move motion direction.
@param delta moved delta.
@param threshold threshold to detect the motion.
@return the motion direction for the vertical axis. | [
"Calculate",
"the",
"vertical",
"move",
"motion",
"direction",
"."
]
| train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/view/MotionEventUtils.java#L116-L121 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/lss/LssClient.java | LssClient.listAppStreams | public ListAppStreamsResponse listAppStreams(ListAppStreamsRequest request) {
"""
list your streams by app name and stream status
@param request The request object containing all parameters for list app streams.
@return this object
"""
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string.");
InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_APP,
request.getApp(), LIVE_SESSION);
if (request.getStatus() != null) {
internalRequest.addParameter("status", request.getStatus());
}
return invokeHttpClient(internalRequest, ListAppStreamsResponse.class);
} | java | public ListAppStreamsResponse listAppStreams(ListAppStreamsRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string.");
InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_APP,
request.getApp(), LIVE_SESSION);
if (request.getStatus() != null) {
internalRequest.addParameter("status", request.getStatus());
}
return invokeHttpClient(internalRequest, ListAppStreamsResponse.class);
} | [
"public",
"ListAppStreamsResponse",
"listAppStreams",
"(",
"ListAppStreamsRequest",
"request",
")",
"{",
"checkNotNull",
"(",
"request",
",",
"\"The parameter request should NOT be null.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getApp",
"(",
")",
",",
"\"The parameter app should NOT be null or empty string.\"",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"createRequest",
"(",
"HttpMethodName",
".",
"GET",
",",
"request",
",",
"LIVE_APP",
",",
"request",
".",
"getApp",
"(",
")",
",",
"LIVE_SESSION",
")",
";",
"if",
"(",
"request",
".",
"getStatus",
"(",
")",
"!=",
"null",
")",
"{",
"internalRequest",
".",
"addParameter",
"(",
"\"status\"",
",",
"request",
".",
"getStatus",
"(",
")",
")",
";",
"}",
"return",
"invokeHttpClient",
"(",
"internalRequest",
",",
"ListAppStreamsResponse",
".",
"class",
")",
";",
"}"
]
| list your streams by app name and stream status
@param request The request object containing all parameters for list app streams.
@return this object | [
"list",
"your",
"streams",
"by",
"app",
"name",
"and",
"stream",
"status"
]
| train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/lss/LssClient.java#L889-L898 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscConfigurationsInner.java | DscConfigurationsInner.updateAsync | public Observable<DscConfigurationInner> updateAsync(String resourceGroupName, String automationAccountName, String configurationName, DscConfigurationUpdateParameters parameters) {
"""
Create the configuration identified by configuration name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param configurationName The create or update parameters for configuration.
@param parameters The create or update parameters for configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DscConfigurationInner object
"""
return updateWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName, parameters).map(new Func1<ServiceResponse<DscConfigurationInner>, DscConfigurationInner>() {
@Override
public DscConfigurationInner call(ServiceResponse<DscConfigurationInner> response) {
return response.body();
}
});
} | java | public Observable<DscConfigurationInner> updateAsync(String resourceGroupName, String automationAccountName, String configurationName, DscConfigurationUpdateParameters parameters) {
return updateWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName, parameters).map(new Func1<ServiceResponse<DscConfigurationInner>, DscConfigurationInner>() {
@Override
public DscConfigurationInner call(ServiceResponse<DscConfigurationInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DscConfigurationInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"configurationName",
",",
"DscConfigurationUpdateParameters",
"parameters",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"configurationName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DscConfigurationInner",
">",
",",
"DscConfigurationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DscConfigurationInner",
"call",
"(",
"ServiceResponse",
"<",
"DscConfigurationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Create the configuration identified by configuration name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param configurationName The create or update parameters for configuration.
@param parameters The create or update parameters for configuration.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DscConfigurationInner object | [
"Create",
"the",
"configuration",
"identified",
"by",
"configuration",
"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/DscConfigurationsInner.java#L505-L512 |
Alluxio/alluxio | core/server/common/src/main/java/alluxio/cli/validation/Utils.java | Utils.getResultFromProcess | public static ProcessExecutionResult getResultFromProcess(String[] args) {
"""
Executes a command in another process and check for its execution result.
@param args array representation of the command to execute
@return {@link ProcessExecutionResult} including the process's exit value, output and error
"""
try {
Process process = Runtime.getRuntime().exec(args);
StringBuilder outputSb = new StringBuilder();
try (BufferedReader processOutputReader = new BufferedReader(
new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = processOutputReader.readLine()) != null) {
outputSb.append(line);
outputSb.append(LINE_SEPARATOR);
}
}
StringBuilder errorSb = new StringBuilder();
try (BufferedReader processErrorReader = new BufferedReader(
new InputStreamReader(process.getErrorStream()))) {
String line;
while ((line = processErrorReader.readLine()) != null) {
errorSb.append(line);
errorSb.append(LINE_SEPARATOR);
}
}
process.waitFor();
return new ProcessExecutionResult(process.exitValue(), outputSb.toString().trim(),
errorSb.toString().trim());
} catch (IOException e) {
System.err.println("Failed to execute command.");
return new ProcessExecutionResult(1, "", e.getMessage());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.err.println("Interrupted.");
return new ProcessExecutionResult(1, "", e.getMessage());
}
} | java | public static ProcessExecutionResult getResultFromProcess(String[] args) {
try {
Process process = Runtime.getRuntime().exec(args);
StringBuilder outputSb = new StringBuilder();
try (BufferedReader processOutputReader = new BufferedReader(
new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = processOutputReader.readLine()) != null) {
outputSb.append(line);
outputSb.append(LINE_SEPARATOR);
}
}
StringBuilder errorSb = new StringBuilder();
try (BufferedReader processErrorReader = new BufferedReader(
new InputStreamReader(process.getErrorStream()))) {
String line;
while ((line = processErrorReader.readLine()) != null) {
errorSb.append(line);
errorSb.append(LINE_SEPARATOR);
}
}
process.waitFor();
return new ProcessExecutionResult(process.exitValue(), outputSb.toString().trim(),
errorSb.toString().trim());
} catch (IOException e) {
System.err.println("Failed to execute command.");
return new ProcessExecutionResult(1, "", e.getMessage());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.err.println("Interrupted.");
return new ProcessExecutionResult(1, "", e.getMessage());
}
} | [
"public",
"static",
"ProcessExecutionResult",
"getResultFromProcess",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"try",
"{",
"Process",
"process",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
"args",
")",
";",
"StringBuilder",
"outputSb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"try",
"(",
"BufferedReader",
"processOutputReader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"process",
".",
"getInputStream",
"(",
")",
")",
")",
")",
"{",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"processOutputReader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"outputSb",
".",
"append",
"(",
"line",
")",
";",
"outputSb",
".",
"append",
"(",
"LINE_SEPARATOR",
")",
";",
"}",
"}",
"StringBuilder",
"errorSb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"try",
"(",
"BufferedReader",
"processErrorReader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"process",
".",
"getErrorStream",
"(",
")",
")",
")",
")",
"{",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"processErrorReader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"errorSb",
".",
"append",
"(",
"line",
")",
";",
"errorSb",
".",
"append",
"(",
"LINE_SEPARATOR",
")",
";",
"}",
"}",
"process",
".",
"waitFor",
"(",
")",
";",
"return",
"new",
"ProcessExecutionResult",
"(",
"process",
".",
"exitValue",
"(",
")",
",",
"outputSb",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
",",
"errorSb",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Failed to execute command.\"",
")",
";",
"return",
"new",
"ProcessExecutionResult",
"(",
"1",
",",
"\"\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"\"Interrupted.\"",
")",
";",
"return",
"new",
"ProcessExecutionResult",
"(",
"1",
",",
"\"\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
]
| Executes a command in another process and check for its execution result.
@param args array representation of the command to execute
@return {@link ProcessExecutionResult} including the process's exit value, output and error | [
"Executes",
"a",
"command",
"in",
"another",
"process",
"and",
"check",
"for",
"its",
"execution",
"result",
"."
]
| train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/cli/validation/Utils.java#L137-L169 |
jsonld-java/jsonld-java | core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java | JsonLdApi.generateNodeMap | void generateNodeMap(Object element, Map<String, Object> nodeMap) throws JsonLdError {
"""
*
_____ _ _ _ _ _ _ _ _ | ___| | __ _| |_| |_ ___ _ __ / \ | | __ _ ___ _
__(_) |_| |__ _ __ ___ | |_ | |/ _` | __| __/ _ \ '_ \ / _ \ | |/ _` |/ _
\| '__| | __| '_ \| '_ ` _ \ | _| | | (_| | |_| || __/ | | | / ___ \| |
(_| | (_) | | | | |_| | | | | | | | | |_| |_|\__,_|\__|\__\___|_| |_| /_/
\_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_| |___/
"""
generateNodeMap(element, nodeMap, JsonLdConsts.DEFAULT, null, null, null);
} | java | void generateNodeMap(Object element, Map<String, Object> nodeMap) throws JsonLdError {
generateNodeMap(element, nodeMap, JsonLdConsts.DEFAULT, null, null, null);
} | [
"void",
"generateNodeMap",
"(",
"Object",
"element",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"nodeMap",
")",
"throws",
"JsonLdError",
"{",
"generateNodeMap",
"(",
"element",
",",
"nodeMap",
",",
"JsonLdConsts",
".",
"DEFAULT",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}"
]
| *
_____ _ _ _ _ _ _ _ _ | ___| | __ _| |_| |_ ___ _ __ / \ | | __ _ ___ _
__(_) |_| |__ _ __ ___ | |_ | |/ _` | __| __/ _ \ '_ \ / _ \ | |/ _` |/ _
\| '__| | __| '_ \| '_ ` _ \ | _| | | (_| | |_| || __/ | | | / ___ \| |
(_| | (_) | | | | |_| | | | | | | | | |_| |_|\__,_|\__|\__\___|_| |_| /_/
\_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_| |___/ | [
"*",
"_____",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"|",
"___|",
"|",
"__",
"_|",
"|_|",
"|_",
"___",
"_",
"__",
"/",
"\\",
"|",
"|",
"__",
"_",
"___",
"_",
"__",
"(",
"_",
")",
"|_|",
"|__",
"_",
"__",
"___",
"|",
"|_",
"|",
"|",
"/",
"_",
"|",
"__|",
"__",
"/",
"_",
"\\",
"_",
"\\",
"/",
"_",
"\\",
"|",
"|",
"/",
"_",
"|",
"/",
"_",
"\\",
"|",
"__|",
"|",
"__|",
"_",
"\\",
"|",
"_",
"_",
"\\",
"|",
"_|",
"|",
"|",
"(",
"_|",
"|",
"|_|",
"||",
"__",
"/",
"|",
"|",
"|",
"/",
"___",
"\\",
"|",
"|",
"(",
"_|",
"|",
"(",
"_",
")",
"|",
"|",
"|",
"|",
"|_|",
"|",
"|",
"|",
"|",
"|",
"|",
"|",
"|",
"|_|",
"|_|",
"\\",
"__",
"_|",
"\\",
"__|",
"\\",
"__",
"\\",
"___|_|",
"|_|",
"/",
"_",
"/",
"\\",
"_",
"\\",
"_|",
"\\",
"__",
"|",
"\\",
"___",
"/",
"|_|",
"|_|",
"\\",
"__|_|",
"|_|_|",
"|_|",
"|_|",
"|___",
"/"
]
| train | https://github.com/jsonld-java/jsonld-java/blob/efeef6ee96029a0011649633457035fa6be42da1/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java#L1038-L1040 |
hawkular/hawkular-inventory | hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Configuration.java | Configuration.prefixedWith | public Configuration prefixedWith(String... prefixes) {
"""
Filters out all the configuration entries whose keys don't start with any of the white-listed prefixes
@param prefixes
@return
"""
if (prefixes == null || prefixes.length == 0) {
return this;
}
Map<String, String> filteredConfig = implementationConfiguration.entrySet().stream()
.filter(e -> Arrays.stream(prefixes).anyMatch(p -> e.getKey()
.startsWith(p))).collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
return new Configuration(feedIdStrategy, resultFilter, filteredConfig);
} | java | public Configuration prefixedWith(String... prefixes) {
if (prefixes == null || prefixes.length == 0) {
return this;
}
Map<String, String> filteredConfig = implementationConfiguration.entrySet().stream()
.filter(e -> Arrays.stream(prefixes).anyMatch(p -> e.getKey()
.startsWith(p))).collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
return new Configuration(feedIdStrategy, resultFilter, filteredConfig);
} | [
"public",
"Configuration",
"prefixedWith",
"(",
"String",
"...",
"prefixes",
")",
"{",
"if",
"(",
"prefixes",
"==",
"null",
"||",
"prefixes",
".",
"length",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"Map",
"<",
"String",
",",
"String",
">",
"filteredConfig",
"=",
"implementationConfiguration",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"e",
"->",
"Arrays",
".",
"stream",
"(",
"prefixes",
")",
".",
"anyMatch",
"(",
"p",
"->",
"e",
".",
"getKey",
"(",
")",
".",
"startsWith",
"(",
"p",
")",
")",
")",
".",
"collect",
"(",
"toMap",
"(",
"Map",
".",
"Entry",
"::",
"getKey",
",",
"Map",
".",
"Entry",
"::",
"getValue",
")",
")",
";",
"return",
"new",
"Configuration",
"(",
"feedIdStrategy",
",",
"resultFilter",
",",
"filteredConfig",
")",
";",
"}"
]
| Filters out all the configuration entries whose keys don't start with any of the white-listed prefixes
@param prefixes
@return | [
"Filters",
"out",
"all",
"the",
"configuration",
"entries",
"whose",
"keys",
"don",
"t",
"start",
"with",
"any",
"of",
"the",
"white",
"-",
"listed",
"prefixes"
]
| train | https://github.com/hawkular/hawkular-inventory/blob/f56dc10323dca21777feb5b609a9e9cc70ffaf62/hawkular-inventory-api/src/main/java/org/hawkular/inventory/api/Configuration.java#L121-L129 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/CmsListItem.java | CmsListItem.removeDecorationWidget | protected void removeDecorationWidget(Widget widget, int width) {
"""
Removes a decoration widget.<p>
@param widget the widget to remove
@param width the widget width
"""
if ((widget != null) && m_decorationWidgets.remove(widget)) {
m_decorationWidth -= width;
initContent();
}
} | java | protected void removeDecorationWidget(Widget widget, int width) {
if ((widget != null) && m_decorationWidgets.remove(widget)) {
m_decorationWidth -= width;
initContent();
}
} | [
"protected",
"void",
"removeDecorationWidget",
"(",
"Widget",
"widget",
",",
"int",
"width",
")",
"{",
"if",
"(",
"(",
"widget",
"!=",
"null",
")",
"&&",
"m_decorationWidgets",
".",
"remove",
"(",
"widget",
")",
")",
"{",
"m_decorationWidth",
"-=",
"width",
";",
"initContent",
"(",
")",
";",
"}",
"}"
]
| Removes a decoration widget.<p>
@param widget the widget to remove
@param width the widget width | [
"Removes",
"a",
"decoration",
"widget",
".",
"<p",
">"
]
| train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/CmsListItem.java#L688-L694 |
citrusframework/citrus | modules/citrus-ws/src/main/java/com/consol/citrus/ws/config/xml/SendSoapFaultActionParser.java | SendSoapFaultActionParser.parseFault | private void parseFault(BeanDefinitionBuilder builder, Element faultElement) {
"""
Parses the SOAP fault information.
@param builder
@param faultElement
"""
if (faultElement != null) {
Element faultCodeElement = DomUtils.getChildElementByTagName(faultElement, "fault-code");
if (faultCodeElement != null) {
builder.addPropertyValue("faultCode", DomUtils.getTextValue(faultCodeElement).trim());
}
Element faultStringElement = DomUtils.getChildElementByTagName(faultElement, "fault-string");
if (faultStringElement != null) {
builder.addPropertyValue("faultString", DomUtils.getTextValue(faultStringElement).trim());
}
Element faultActorElement = DomUtils.getChildElementByTagName(faultElement, "fault-actor");
if (faultActorElement != null) {
builder.addPropertyValue("faultActor", DomUtils.getTextValue(faultActorElement).trim());
}
parseFaultDetail(builder, faultElement);
}
} | java | private void parseFault(BeanDefinitionBuilder builder, Element faultElement) {
if (faultElement != null) {
Element faultCodeElement = DomUtils.getChildElementByTagName(faultElement, "fault-code");
if (faultCodeElement != null) {
builder.addPropertyValue("faultCode", DomUtils.getTextValue(faultCodeElement).trim());
}
Element faultStringElement = DomUtils.getChildElementByTagName(faultElement, "fault-string");
if (faultStringElement != null) {
builder.addPropertyValue("faultString", DomUtils.getTextValue(faultStringElement).trim());
}
Element faultActorElement = DomUtils.getChildElementByTagName(faultElement, "fault-actor");
if (faultActorElement != null) {
builder.addPropertyValue("faultActor", DomUtils.getTextValue(faultActorElement).trim());
}
parseFaultDetail(builder, faultElement);
}
} | [
"private",
"void",
"parseFault",
"(",
"BeanDefinitionBuilder",
"builder",
",",
"Element",
"faultElement",
")",
"{",
"if",
"(",
"faultElement",
"!=",
"null",
")",
"{",
"Element",
"faultCodeElement",
"=",
"DomUtils",
".",
"getChildElementByTagName",
"(",
"faultElement",
",",
"\"fault-code\"",
")",
";",
"if",
"(",
"faultCodeElement",
"!=",
"null",
")",
"{",
"builder",
".",
"addPropertyValue",
"(",
"\"faultCode\"",
",",
"DomUtils",
".",
"getTextValue",
"(",
"faultCodeElement",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"Element",
"faultStringElement",
"=",
"DomUtils",
".",
"getChildElementByTagName",
"(",
"faultElement",
",",
"\"fault-string\"",
")",
";",
"if",
"(",
"faultStringElement",
"!=",
"null",
")",
"{",
"builder",
".",
"addPropertyValue",
"(",
"\"faultString\"",
",",
"DomUtils",
".",
"getTextValue",
"(",
"faultStringElement",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"Element",
"faultActorElement",
"=",
"DomUtils",
".",
"getChildElementByTagName",
"(",
"faultElement",
",",
"\"fault-actor\"",
")",
";",
"if",
"(",
"faultActorElement",
"!=",
"null",
")",
"{",
"builder",
".",
"addPropertyValue",
"(",
"\"faultActor\"",
",",
"DomUtils",
".",
"getTextValue",
"(",
"faultActorElement",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"parseFaultDetail",
"(",
"builder",
",",
"faultElement",
")",
";",
"}",
"}"
]
| Parses the SOAP fault information.
@param builder
@param faultElement | [
"Parses",
"the",
"SOAP",
"fault",
"information",
"."
]
| train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-ws/src/main/java/com/consol/citrus/ws/config/xml/SendSoapFaultActionParser.java#L52-L71 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupsImpl.java | PersonGroupsImpl.updateAsync | public Observable<Void> updateAsync(String personGroupId, UpdatePersonGroupsOptionalParameter updateOptionalParameter) {
"""
Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated.
@param personGroupId Id referencing a particular person group.
@param updateOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return updateWithServiceResponseAsync(personGroupId, updateOptionalParameter).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> updateAsync(String personGroupId, UpdatePersonGroupsOptionalParameter updateOptionalParameter) {
return updateWithServiceResponseAsync(personGroupId, updateOptionalParameter).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"updateAsync",
"(",
"String",
"personGroupId",
",",
"UpdatePersonGroupsOptionalParameter",
"updateOptionalParameter",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"personGroupId",
",",
"updateOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated.
@param personGroupId Id referencing a particular person group.
@param updateOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Update",
"an",
"existing",
"person",
"group",
"s",
"display",
"name",
"and",
"userData",
".",
"The",
"properties",
"which",
"does",
"not",
"appear",
"in",
"request",
"body",
"will",
"not",
"be",
"updated",
"."
]
| train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupsImpl.java#L448-L455 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/script/Script.java | Script.correctlySpends | public void correctlySpends(Transaction txContainingThis, int scriptSigIndex, @Nullable TransactionWitness witness, @Nullable Coin value,
Script scriptPubKey, Set<VerifyFlag> verifyFlags) throws ScriptException {
"""
Verifies that this script (interpreted as a scriptSig) correctly spends the given scriptPubKey.
@param txContainingThis The transaction in which this input scriptSig resides.
Accessing txContainingThis from another thread while this method runs results in undefined behavior.
@param scriptSigIndex The index in txContainingThis of the scriptSig (note: NOT the index of the scriptPubKey).
@param scriptPubKey The connected scriptPubKey containing the conditions needed to claim the value.
@param witness Transaction witness belonging to the transaction input containing this script. Needed for SegWit.
@param value Value of the output. Needed for SegWit scripts.
@param verifyFlags Each flag enables one validation rule.
"""
if (ScriptPattern.isP2WPKH(scriptPubKey)) {
// For SegWit, full validation isn't implemented. So we simply check the signature. P2SH_P2WPKH is handled
// by the P2SH code for now.
if (witness.getPushCount() < 2)
throw new ScriptException(ScriptError.SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY, witness.toString());
TransactionSignature signature;
try {
signature = TransactionSignature.decodeFromBitcoin(witness.getPush(0), true, true);
} catch (SignatureDecodeException x) {
throw new ScriptException(ScriptError.SCRIPT_ERR_SIG_DER, "Cannot decode", x);
}
ECKey pubkey = ECKey.fromPublicOnly(witness.getPush(1));
Script scriptCode = new ScriptBuilder().data(ScriptBuilder.createP2PKHOutputScript(pubkey).getProgram())
.build();
Sha256Hash sigHash = txContainingThis.hashForWitnessSignature(scriptSigIndex, scriptCode, value,
signature.sigHashMode(), false);
boolean validSig = pubkey.verify(sigHash, signature);
if (!validSig)
throw new ScriptException(ScriptError.SCRIPT_ERR_CHECKSIGVERIFY, "Invalid signature");
} else {
correctlySpends(txContainingThis, scriptSigIndex, scriptPubKey, verifyFlags);
}
} | java | public void correctlySpends(Transaction txContainingThis, int scriptSigIndex, @Nullable TransactionWitness witness, @Nullable Coin value,
Script scriptPubKey, Set<VerifyFlag> verifyFlags) throws ScriptException {
if (ScriptPattern.isP2WPKH(scriptPubKey)) {
// For SegWit, full validation isn't implemented. So we simply check the signature. P2SH_P2WPKH is handled
// by the P2SH code for now.
if (witness.getPushCount() < 2)
throw new ScriptException(ScriptError.SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY, witness.toString());
TransactionSignature signature;
try {
signature = TransactionSignature.decodeFromBitcoin(witness.getPush(0), true, true);
} catch (SignatureDecodeException x) {
throw new ScriptException(ScriptError.SCRIPT_ERR_SIG_DER, "Cannot decode", x);
}
ECKey pubkey = ECKey.fromPublicOnly(witness.getPush(1));
Script scriptCode = new ScriptBuilder().data(ScriptBuilder.createP2PKHOutputScript(pubkey).getProgram())
.build();
Sha256Hash sigHash = txContainingThis.hashForWitnessSignature(scriptSigIndex, scriptCode, value,
signature.sigHashMode(), false);
boolean validSig = pubkey.verify(sigHash, signature);
if (!validSig)
throw new ScriptException(ScriptError.SCRIPT_ERR_CHECKSIGVERIFY, "Invalid signature");
} else {
correctlySpends(txContainingThis, scriptSigIndex, scriptPubKey, verifyFlags);
}
} | [
"public",
"void",
"correctlySpends",
"(",
"Transaction",
"txContainingThis",
",",
"int",
"scriptSigIndex",
",",
"@",
"Nullable",
"TransactionWitness",
"witness",
",",
"@",
"Nullable",
"Coin",
"value",
",",
"Script",
"scriptPubKey",
",",
"Set",
"<",
"VerifyFlag",
">",
"verifyFlags",
")",
"throws",
"ScriptException",
"{",
"if",
"(",
"ScriptPattern",
".",
"isP2WPKH",
"(",
"scriptPubKey",
")",
")",
"{",
"// For SegWit, full validation isn't implemented. So we simply check the signature. P2SH_P2WPKH is handled",
"// by the P2SH code for now.",
"if",
"(",
"witness",
".",
"getPushCount",
"(",
")",
"<",
"2",
")",
"throw",
"new",
"ScriptException",
"(",
"ScriptError",
".",
"SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY",
",",
"witness",
".",
"toString",
"(",
")",
")",
";",
"TransactionSignature",
"signature",
";",
"try",
"{",
"signature",
"=",
"TransactionSignature",
".",
"decodeFromBitcoin",
"(",
"witness",
".",
"getPush",
"(",
"0",
")",
",",
"true",
",",
"true",
")",
";",
"}",
"catch",
"(",
"SignatureDecodeException",
"x",
")",
"{",
"throw",
"new",
"ScriptException",
"(",
"ScriptError",
".",
"SCRIPT_ERR_SIG_DER",
",",
"\"Cannot decode\"",
",",
"x",
")",
";",
"}",
"ECKey",
"pubkey",
"=",
"ECKey",
".",
"fromPublicOnly",
"(",
"witness",
".",
"getPush",
"(",
"1",
")",
")",
";",
"Script",
"scriptCode",
"=",
"new",
"ScriptBuilder",
"(",
")",
".",
"data",
"(",
"ScriptBuilder",
".",
"createP2PKHOutputScript",
"(",
"pubkey",
")",
".",
"getProgram",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"Sha256Hash",
"sigHash",
"=",
"txContainingThis",
".",
"hashForWitnessSignature",
"(",
"scriptSigIndex",
",",
"scriptCode",
",",
"value",
",",
"signature",
".",
"sigHashMode",
"(",
")",
",",
"false",
")",
";",
"boolean",
"validSig",
"=",
"pubkey",
".",
"verify",
"(",
"sigHash",
",",
"signature",
")",
";",
"if",
"(",
"!",
"validSig",
")",
"throw",
"new",
"ScriptException",
"(",
"ScriptError",
".",
"SCRIPT_ERR_CHECKSIGVERIFY",
",",
"\"Invalid signature\"",
")",
";",
"}",
"else",
"{",
"correctlySpends",
"(",
"txContainingThis",
",",
"scriptSigIndex",
",",
"scriptPubKey",
",",
"verifyFlags",
")",
";",
"}",
"}"
]
| Verifies that this script (interpreted as a scriptSig) correctly spends the given scriptPubKey.
@param txContainingThis The transaction in which this input scriptSig resides.
Accessing txContainingThis from another thread while this method runs results in undefined behavior.
@param scriptSigIndex The index in txContainingThis of the scriptSig (note: NOT the index of the scriptPubKey).
@param scriptPubKey The connected scriptPubKey containing the conditions needed to claim the value.
@param witness Transaction witness belonging to the transaction input containing this script. Needed for SegWit.
@param value Value of the output. Needed for SegWit scripts.
@param verifyFlags Each flag enables one validation rule. | [
"Verifies",
"that",
"this",
"script",
"(",
"interpreted",
"as",
"a",
"scriptSig",
")",
"correctly",
"spends",
"the",
"given",
"scriptPubKey",
"."
]
| train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/script/Script.java#L1576-L1600 |
JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMFiles.java | JMFiles.readString | public static String readString(Path targetPath, String charsetName) {
"""
Read string string.
@param targetPath the target path
@param charsetName the charset name
@return the string
"""
try {
return new String(Files.readAllBytes(targetPath),
Charset.forName(charsetName));
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturnNull(log, e,
"readString", charsetName);
}
} | java | public static String readString(Path targetPath, String charsetName) {
try {
return new String(Files.readAllBytes(targetPath),
Charset.forName(charsetName));
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturnNull(log, e,
"readString", charsetName);
}
} | [
"public",
"static",
"String",
"readString",
"(",
"Path",
"targetPath",
",",
"String",
"charsetName",
")",
"{",
"try",
"{",
"return",
"new",
"String",
"(",
"Files",
".",
"readAllBytes",
"(",
"targetPath",
")",
",",
"Charset",
".",
"forName",
"(",
"charsetName",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"JMExceptionManager",
".",
"handleExceptionAndReturnNull",
"(",
"log",
",",
"e",
",",
"\"readString\"",
",",
"charsetName",
")",
";",
"}",
"}"
]
| Read string string.
@param targetPath the target path
@param charsetName the charset name
@return the string | [
"Read",
"string",
"string",
"."
]
| train | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMFiles.java#L146-L154 |
cerner/beadledom | common/src/main/java/com/cerner/beadledom/metadata/BuildInfo.java | BuildInfo.load | public static BuildInfo load(InputStream propertiesStream) {
"""
Creates an instance using properties from the given stream (which must be in property file
format).
<p>See {@link #create(Properties)} for a list of required properties.
<p>For convenience, this method throws a runtime exception if an IOException occurs. If you
plan to do anything other than crash in the event of an error, you should use
{@link #create(Properties)} instead.
"""
Properties properties = new Properties();
try {
properties.load(propertiesStream);
} catch (IOException e) {
throw new IllegalStateException("Unable to load build info properties", e);
} finally {
try {
propertiesStream.close();
} catch (IOException e) {
LOGGER.warn("Unable to close properties stream", e);
}
}
return create(properties);
} | java | public static BuildInfo load(InputStream propertiesStream) {
Properties properties = new Properties();
try {
properties.load(propertiesStream);
} catch (IOException e) {
throw new IllegalStateException("Unable to load build info properties", e);
} finally {
try {
propertiesStream.close();
} catch (IOException e) {
LOGGER.warn("Unable to close properties stream", e);
}
}
return create(properties);
} | [
"public",
"static",
"BuildInfo",
"load",
"(",
"InputStream",
"propertiesStream",
")",
"{",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"try",
"{",
"properties",
".",
"load",
"(",
"propertiesStream",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unable to load build info properties\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"propertiesStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Unable to close properties stream\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"create",
"(",
"properties",
")",
";",
"}"
]
| Creates an instance using properties from the given stream (which must be in property file
format).
<p>See {@link #create(Properties)} for a list of required properties.
<p>For convenience, this method throws a runtime exception if an IOException occurs. If you
plan to do anything other than crash in the event of an error, you should use
{@link #create(Properties)} instead. | [
"Creates",
"an",
"instance",
"using",
"properties",
"from",
"the",
"given",
"stream",
"(",
"which",
"must",
"be",
"in",
"property",
"file",
"format",
")",
"."
]
| train | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/common/src/main/java/com/cerner/beadledom/metadata/BuildInfo.java#L128-L143 |
primefaces-extensions/core | src/main/java/org/primefaces/extensions/util/RequestParameterBuilder.java | RequestParameterBuilder.paramJson | public RequestParameterBuilder paramJson(String name, Object value, String type) throws UnsupportedEncodingException {
"""
Adds a request parameter to the URL with specifying a data type of the given parameter value. Data type is sometimes required, especially for Java
generic types, because type information is erased at runtime and the conversion to JSON will not work properly. Parameter's value is converted to JSON
notation when adding. Furthermore, it will be encoded according to the acquired encoding.
@param name name of the request parameter
@param value value of the request parameter
@param type data type of the value object. Any primitive type, array, non generic or generic type is supported. Data type is sometimes required to
convert a value to a JSON representation. All data types should be fully qualified. Examples: "boolean" "int" "long[]" "java.lang.String"
"java.util.Date" "java.util.Collection<java.lang.Integer>" "java.util.Map<java.lang.String, com.durr.FooPair<java.lang.Integer,
java.util.Date>>" "com.durr.FooNonGenericClass" "com.durr.FooGenericClass<java.lang.String, java.lang.Integer>"
"com.durr.FooGenericClass<int[], com.durr.FooGenericClass<com.durr.FooNonGenericClass, java.lang.Boolean>>".
@return RequestParameterBuilder updated this instance which can be reused
@throws UnsupportedEncodingException DOCUMENT_ME
"""
String encodedJsonValue = encodeJson(value, type);
if (added || originalUrl.contains("?")) {
buffer.append("&");
}
else {
buffer.append("?");
}
buffer.append(name);
buffer.append("=");
buffer.append(encodedJsonValue);
// set a flag that at least one request parameter was added
added = true;
return this;
} | java | public RequestParameterBuilder paramJson(String name, Object value, String type) throws UnsupportedEncodingException {
String encodedJsonValue = encodeJson(value, type);
if (added || originalUrl.contains("?")) {
buffer.append("&");
}
else {
buffer.append("?");
}
buffer.append(name);
buffer.append("=");
buffer.append(encodedJsonValue);
// set a flag that at least one request parameter was added
added = true;
return this;
} | [
"public",
"RequestParameterBuilder",
"paramJson",
"(",
"String",
"name",
",",
"Object",
"value",
",",
"String",
"type",
")",
"throws",
"UnsupportedEncodingException",
"{",
"String",
"encodedJsonValue",
"=",
"encodeJson",
"(",
"value",
",",
"type",
")",
";",
"if",
"(",
"added",
"||",
"originalUrl",
".",
"contains",
"(",
"\"?\"",
")",
")",
"{",
"buffer",
".",
"append",
"(",
"\"&\"",
")",
";",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"\"?\"",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"name",
")",
";",
"buffer",
".",
"append",
"(",
"\"=\"",
")",
";",
"buffer",
".",
"append",
"(",
"encodedJsonValue",
")",
";",
"// set a flag that at least one request parameter was added",
"added",
"=",
"true",
";",
"return",
"this",
";",
"}"
]
| Adds a request parameter to the URL with specifying a data type of the given parameter value. Data type is sometimes required, especially for Java
generic types, because type information is erased at runtime and the conversion to JSON will not work properly. Parameter's value is converted to JSON
notation when adding. Furthermore, it will be encoded according to the acquired encoding.
@param name name of the request parameter
@param value value of the request parameter
@param type data type of the value object. Any primitive type, array, non generic or generic type is supported. Data type is sometimes required to
convert a value to a JSON representation. All data types should be fully qualified. Examples: "boolean" "int" "long[]" "java.lang.String"
"java.util.Date" "java.util.Collection<java.lang.Integer>" "java.util.Map<java.lang.String, com.durr.FooPair<java.lang.Integer,
java.util.Date>>" "com.durr.FooNonGenericClass" "com.durr.FooGenericClass<java.lang.String, java.lang.Integer>"
"com.durr.FooGenericClass<int[], com.durr.FooGenericClass<com.durr.FooNonGenericClass, java.lang.Boolean>>".
@return RequestParameterBuilder updated this instance which can be reused
@throws UnsupportedEncodingException DOCUMENT_ME | [
"Adds",
"a",
"request",
"parameter",
"to",
"the",
"URL",
"with",
"specifying",
"a",
"data",
"type",
"of",
"the",
"given",
"parameter",
"value",
".",
"Data",
"type",
"is",
"sometimes",
"required",
"especially",
"for",
"Java",
"generic",
"types",
"because",
"type",
"information",
"is",
"erased",
"at",
"runtime",
"and",
"the",
"conversion",
"to",
"JSON",
"will",
"not",
"work",
"properly",
".",
"Parameter",
"s",
"value",
"is",
"converted",
"to",
"JSON",
"notation",
"when",
"adding",
".",
"Furthermore",
"it",
"will",
"be",
"encoded",
"according",
"to",
"the",
"acquired",
"encoding",
"."
]
| train | https://github.com/primefaces-extensions/core/blob/afdbca591f60f47898e3517e1e939bc2f63d5355/src/main/java/org/primefaces/extensions/util/RequestParameterBuilder.java#L120-L138 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java | ExtendedMessageFormat.seekNonWs | private void seekNonWs(final String pattern, final ParsePosition pos) {
"""
Consume whitespace from the current parse position.
@param pattern String to read
@param pos current position
"""
int len = 0;
final char[] buffer = pattern.toCharArray();
do {
len = StrMatcher.splitMatcher().isMatch(buffer, pos.getIndex());
pos.setIndex(pos.getIndex() + len);
} while (len > 0 && pos.getIndex() < pattern.length());
} | java | private void seekNonWs(final String pattern, final ParsePosition pos) {
int len = 0;
final char[] buffer = pattern.toCharArray();
do {
len = StrMatcher.splitMatcher().isMatch(buffer, pos.getIndex());
pos.setIndex(pos.getIndex() + len);
} while (len > 0 && pos.getIndex() < pattern.length());
} | [
"private",
"void",
"seekNonWs",
"(",
"final",
"String",
"pattern",
",",
"final",
"ParsePosition",
"pos",
")",
"{",
"int",
"len",
"=",
"0",
";",
"final",
"char",
"[",
"]",
"buffer",
"=",
"pattern",
".",
"toCharArray",
"(",
")",
";",
"do",
"{",
"len",
"=",
"StrMatcher",
".",
"splitMatcher",
"(",
")",
".",
"isMatch",
"(",
"buffer",
",",
"pos",
".",
"getIndex",
"(",
")",
")",
";",
"pos",
".",
"setIndex",
"(",
"pos",
".",
"getIndex",
"(",
")",
"+",
"len",
")",
";",
"}",
"while",
"(",
"len",
">",
"0",
"&&",
"pos",
".",
"getIndex",
"(",
")",
"<",
"pattern",
".",
"length",
"(",
")",
")",
";",
"}"
]
| Consume whitespace from the current parse position.
@param pattern String to read
@param pos current position | [
"Consume",
"whitespace",
"from",
"the",
"current",
"parse",
"position",
"."
]
| train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java#L449-L456 |
Bandwidth/java-bandwidth | src/main/java/com/bandwidth/sdk/model/Domain.java | Domain.get | public static Domain get(final BandwidthClient client, final String id) throws ParseException, Exception {
"""
Convenience method to return a Domain
@param client the client.
@param id the domain id.
@return the domain object.
@throws ParseException Error parsing data
@throws Exception error
"""
assert(client != null);
final String domainsUri = client.getUserResourceInstanceUri(BandwidthConstants.DOMAINS_URI_PATH, id);
final JSONObject jsonObject = toJSONObject(client.get(domainsUri, null));
return new Domain(client, jsonObject);
} | java | public static Domain get(final BandwidthClient client, final String id) throws ParseException, Exception {
assert(client != null);
final String domainsUri = client.getUserResourceInstanceUri(BandwidthConstants.DOMAINS_URI_PATH, id);
final JSONObject jsonObject = toJSONObject(client.get(domainsUri, null));
return new Domain(client, jsonObject);
} | [
"public",
"static",
"Domain",
"get",
"(",
"final",
"BandwidthClient",
"client",
",",
"final",
"String",
"id",
")",
"throws",
"ParseException",
",",
"Exception",
"{",
"assert",
"(",
"client",
"!=",
"null",
")",
";",
"final",
"String",
"domainsUri",
"=",
"client",
".",
"getUserResourceInstanceUri",
"(",
"BandwidthConstants",
".",
"DOMAINS_URI_PATH",
",",
"id",
")",
";",
"final",
"JSONObject",
"jsonObject",
"=",
"toJSONObject",
"(",
"client",
".",
"get",
"(",
"domainsUri",
",",
"null",
")",
")",
";",
"return",
"new",
"Domain",
"(",
"client",
",",
"jsonObject",
")",
";",
"}"
]
| Convenience method to return a Domain
@param client the client.
@param id the domain id.
@return the domain object.
@throws ParseException Error parsing data
@throws Exception error | [
"Convenience",
"method",
"to",
"return",
"a",
"Domain"
]
| train | https://github.com/Bandwidth/java-bandwidth/blob/2124c85148ad6a54d2f2949cb952eb3985830e2a/src/main/java/com/bandwidth/sdk/model/Domain.java#L118-L123 |
teatrove/teatrove | teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java | TeaServlet.doGet | protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
"""
Process the user's http get request. Process the template that maps to
the URI that was hit.
@param request the user's http request
@param response the user's http response
"""
if (processStatus(request, response)) {
return;
}
if (!isRunning()) {
int errorCode = mProperties.getInt("startup.codes.error", 503);
response.sendError(errorCode);
return;
}
if (mUseSpiderableRequest) {
request = new SpiderableRequest(request,
mQuerySeparator,
mParameterSeparator,
mValueSeparator);
}
// start transaction
TeaServletTransaction tsTrans =
getEngine().createTransaction(request, response, true);
// load associated request/response
ApplicationRequest appRequest = tsTrans.getRequest();
ApplicationResponse appResponse = tsTrans.getResponse();
// process template
processTemplate(appRequest, appResponse);
appResponse.finish();
// flush the output
response.flushBuffer();
} | java | protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
if (processStatus(request, response)) {
return;
}
if (!isRunning()) {
int errorCode = mProperties.getInt("startup.codes.error", 503);
response.sendError(errorCode);
return;
}
if (mUseSpiderableRequest) {
request = new SpiderableRequest(request,
mQuerySeparator,
mParameterSeparator,
mValueSeparator);
}
// start transaction
TeaServletTransaction tsTrans =
getEngine().createTransaction(request, response, true);
// load associated request/response
ApplicationRequest appRequest = tsTrans.getRequest();
ApplicationResponse appResponse = tsTrans.getResponse();
// process template
processTemplate(appRequest, appResponse);
appResponse.finish();
// flush the output
response.flushBuffer();
} | [
"protected",
"void",
"doGet",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"if",
"(",
"processStatus",
"(",
"request",
",",
"response",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"isRunning",
"(",
")",
")",
"{",
"int",
"errorCode",
"=",
"mProperties",
".",
"getInt",
"(",
"\"startup.codes.error\"",
",",
"503",
")",
";",
"response",
".",
"sendError",
"(",
"errorCode",
")",
";",
"return",
";",
"}",
"if",
"(",
"mUseSpiderableRequest",
")",
"{",
"request",
"=",
"new",
"SpiderableRequest",
"(",
"request",
",",
"mQuerySeparator",
",",
"mParameterSeparator",
",",
"mValueSeparator",
")",
";",
"}",
"// start transaction",
"TeaServletTransaction",
"tsTrans",
"=",
"getEngine",
"(",
")",
".",
"createTransaction",
"(",
"request",
",",
"response",
",",
"true",
")",
";",
"// load associated request/response",
"ApplicationRequest",
"appRequest",
"=",
"tsTrans",
".",
"getRequest",
"(",
")",
";",
"ApplicationResponse",
"appResponse",
"=",
"tsTrans",
".",
"getResponse",
"(",
")",
";",
"// process template",
"processTemplate",
"(",
"appRequest",
",",
"appResponse",
")",
";",
"appResponse",
".",
"finish",
"(",
")",
";",
"// flush the output",
"response",
".",
"flushBuffer",
"(",
")",
";",
"}"
]
| Process the user's http get request. Process the template that maps to
the URI that was hit.
@param request the user's http request
@param response the user's http response | [
"Process",
"the",
"user",
"s",
"http",
"get",
"request",
".",
"Process",
"the",
"template",
"that",
"maps",
"to",
"the",
"URI",
"that",
"was",
"hit",
"."
]
| train | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/TeaServlet.java#L458-L493 |
tomgibara/streams | src/main/java/com/tomgibara/streams/Streams.java | Streams.concatWriteStreams | public static WriteStream concatWriteStreams(StreamCloser closer, WriteStream... streams) {
"""
<p>
A stream that writes byte data to a fixed sequence of underlying streams.
<p>
This is a multi-stream analogue of
{@link WriteStream#andThen(StreamCloser, WriteStream)} or
{@link WriteStream#butFirst(StreamCloser, WriteStream)} methods. Each
stream is closed after it has been filled, with the last stream being
closed on an end of stream condition.
<p>
All unclosed streams are operated on by the {@link StreamCloser} when
{@link CloseableStream#close()} is called.
@param streams
streams to which byte data is to be written
@param closer
logic to be performed on each stream before writing data to
the next stream
@return a stream that splits its writing across multiple streams
"""
if (closer == null) throw new IllegalArgumentException("null closer");
if (streams == null) throw new IllegalArgumentException("null streams");
for (WriteStream stream : streams) {
if (stream == null) throw new IllegalArgumentException("null stream");
}
return new SeqWriteStream(closer, streams);
} | java | public static WriteStream concatWriteStreams(StreamCloser closer, WriteStream... streams) {
if (closer == null) throw new IllegalArgumentException("null closer");
if (streams == null) throw new IllegalArgumentException("null streams");
for (WriteStream stream : streams) {
if (stream == null) throw new IllegalArgumentException("null stream");
}
return new SeqWriteStream(closer, streams);
} | [
"public",
"static",
"WriteStream",
"concatWriteStreams",
"(",
"StreamCloser",
"closer",
",",
"WriteStream",
"...",
"streams",
")",
"{",
"if",
"(",
"closer",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"null closer\"",
")",
";",
"if",
"(",
"streams",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"null streams\"",
")",
";",
"for",
"(",
"WriteStream",
"stream",
":",
"streams",
")",
"{",
"if",
"(",
"stream",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"null stream\"",
")",
";",
"}",
"return",
"new",
"SeqWriteStream",
"(",
"closer",
",",
"streams",
")",
";",
"}"
]
| <p>
A stream that writes byte data to a fixed sequence of underlying streams.
<p>
This is a multi-stream analogue of
{@link WriteStream#andThen(StreamCloser, WriteStream)} or
{@link WriteStream#butFirst(StreamCloser, WriteStream)} methods. Each
stream is closed after it has been filled, with the last stream being
closed on an end of stream condition.
<p>
All unclosed streams are operated on by the {@link StreamCloser} when
{@link CloseableStream#close()} is called.
@param streams
streams to which byte data is to be written
@param closer
logic to be performed on each stream before writing data to
the next stream
@return a stream that splits its writing across multiple streams | [
"<p",
">",
"A",
"stream",
"that",
"writes",
"byte",
"data",
"to",
"a",
"fixed",
"sequence",
"of",
"underlying",
"streams",
"."
]
| train | https://github.com/tomgibara/streams/blob/553dc97293a1f1fd2d88e08d26e19369e9ffa6d3/src/main/java/com/tomgibara/streams/Streams.java#L528-L535 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java | ApiOvhEmaildomain.domain_responder_account_DELETE | public OvhTaskSpecialAccount domain_responder_account_DELETE(String domain, String account) throws IOException {
"""
Delete an existing responder in server
REST: DELETE /email/domain/{domain}/responder/{account}
@param domain [required] Name of your domain name
@param account [required] Name of account
"""
String qPath = "/email/domain/{domain}/responder/{account}";
StringBuilder sb = path(qPath, domain, account);
String resp = exec(qPath, "DELETE", sb.toString(), null);
return convertTo(resp, OvhTaskSpecialAccount.class);
} | java | public OvhTaskSpecialAccount domain_responder_account_DELETE(String domain, String account) throws IOException {
String qPath = "/email/domain/{domain}/responder/{account}";
StringBuilder sb = path(qPath, domain, account);
String resp = exec(qPath, "DELETE", sb.toString(), null);
return convertTo(resp, OvhTaskSpecialAccount.class);
} | [
"public",
"OvhTaskSpecialAccount",
"domain_responder_account_DELETE",
"(",
"String",
"domain",
",",
"String",
"account",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/domain/{domain}/responder/{account}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"domain",
",",
"account",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTaskSpecialAccount",
".",
"class",
")",
";",
"}"
]
| Delete an existing responder in server
REST: DELETE /email/domain/{domain}/responder/{account}
@param domain [required] Name of your domain name
@param account [required] Name of account | [
"Delete",
"an",
"existing",
"responder",
"in",
"server"
]
| train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java#L978-L983 |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java | ParserUtil.parseHeadersLine | public static SubstitutedLine parseHeadersLine(String commandLine, final CommandLineParser.CallbackHandler handler, final CommandContext ctx) throws CommandFormatException {
"""
Returns the string which was actually parsed with all the substitutions
performed
"""
if (commandLine == null) {
return null;
}
final ParsingStateCallbackHandler callbackHandler = getCallbackHandler(handler);
return StateParser.parseLine(commandLine, callbackHandler, HeaderListState.INSTANCE, ctx);
} | java | public static SubstitutedLine parseHeadersLine(String commandLine, final CommandLineParser.CallbackHandler handler, final CommandContext ctx) throws CommandFormatException {
if (commandLine == null) {
return null;
}
final ParsingStateCallbackHandler callbackHandler = getCallbackHandler(handler);
return StateParser.parseLine(commandLine, callbackHandler, HeaderListState.INSTANCE, ctx);
} | [
"public",
"static",
"SubstitutedLine",
"parseHeadersLine",
"(",
"String",
"commandLine",
",",
"final",
"CommandLineParser",
".",
"CallbackHandler",
"handler",
",",
"final",
"CommandContext",
"ctx",
")",
"throws",
"CommandFormatException",
"{",
"if",
"(",
"commandLine",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"ParsingStateCallbackHandler",
"callbackHandler",
"=",
"getCallbackHandler",
"(",
"handler",
")",
";",
"return",
"StateParser",
".",
"parseLine",
"(",
"commandLine",
",",
"callbackHandler",
",",
"HeaderListState",
".",
"INSTANCE",
",",
"ctx",
")",
";",
"}"
]
| Returns the string which was actually parsed with all the substitutions
performed | [
"Returns",
"the",
"string",
"which",
"was",
"actually",
"parsed",
"with",
"all",
"the",
"substitutions",
"performed"
]
| train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java#L159-L165 |
EdwardRaff/JSAT | JSAT/src/jsat/distributions/kernels/KernelPoints.java | KernelPoints.setMaxBudget | public void setMaxBudget(int maxBudget) {
"""
Sets the maximum budget for support vectors to allow. Setting to
{@link Integer#MAX_VALUE} is essentially an unbounded number of support
vectors. Increasing the budget after adding the first vector is always
allowed, but it may not be possible to reduce the number of current
support vectors is above the desired budget.
@param maxBudget the maximum number of allowed support vectors
"""
if(maxBudget < 1)
throw new IllegalArgumentException("Budget must be positive, not " + maxBudget);
this.maxBudget = maxBudget;
for(KernelPoint kp : points)
kp.setMaxBudget(maxBudget);
} | java | public void setMaxBudget(int maxBudget)
{
if(maxBudget < 1)
throw new IllegalArgumentException("Budget must be positive, not " + maxBudget);
this.maxBudget = maxBudget;
for(KernelPoint kp : points)
kp.setMaxBudget(maxBudget);
} | [
"public",
"void",
"setMaxBudget",
"(",
"int",
"maxBudget",
")",
"{",
"if",
"(",
"maxBudget",
"<",
"1",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Budget must be positive, not \"",
"+",
"maxBudget",
")",
";",
"this",
".",
"maxBudget",
"=",
"maxBudget",
";",
"for",
"(",
"KernelPoint",
"kp",
":",
"points",
")",
"kp",
".",
"setMaxBudget",
"(",
"maxBudget",
")",
";",
"}"
]
| Sets the maximum budget for support vectors to allow. Setting to
{@link Integer#MAX_VALUE} is essentially an unbounded number of support
vectors. Increasing the budget after adding the first vector is always
allowed, but it may not be possible to reduce the number of current
support vectors is above the desired budget.
@param maxBudget the maximum number of allowed support vectors | [
"Sets",
"the",
"maximum",
"budget",
"for",
"support",
"vectors",
"to",
"allow",
".",
"Setting",
"to",
"{",
"@link",
"Integer#MAX_VALUE",
"}",
"is",
"essentially",
"an",
"unbounded",
"number",
"of",
"support",
"vectors",
".",
"Increasing",
"the",
"budget",
"after",
"adding",
"the",
"first",
"vector",
"is",
"always",
"allowed",
"but",
"it",
"may",
"not",
"be",
"possible",
"to",
"reduce",
"the",
"number",
"of",
"current",
"support",
"vectors",
"is",
"above",
"the",
"desired",
"budget",
"."
]
| train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/KernelPoints.java#L156-L163 |
lettuce-io/lettuce-core | src/main/java/io/lettuce/core/RedisClient.java | RedisClient.connectPubSub | public <K, V> StatefulRedisPubSubConnection<K, V> connectPubSub(RedisCodec<K, V> codec) {
"""
Open a new pub/sub connection to the Redis server using the supplied {@link RedisURI} and use the supplied
{@link RedisCodec codec} to encode/decode keys and values.
@param codec Use this codec to encode/decode keys and values, must not be {@literal null}
@param <K> Key type
@param <V> Value type
@return A new stateful pub/sub connection
"""
checkForRedisURI();
return getConnection(connectPubSubAsync(codec, redisURI, timeout));
} | java | public <K, V> StatefulRedisPubSubConnection<K, V> connectPubSub(RedisCodec<K, V> codec) {
checkForRedisURI();
return getConnection(connectPubSubAsync(codec, redisURI, timeout));
} | [
"public",
"<",
"K",
",",
"V",
">",
"StatefulRedisPubSubConnection",
"<",
"K",
",",
"V",
">",
"connectPubSub",
"(",
"RedisCodec",
"<",
"K",
",",
"V",
">",
"codec",
")",
"{",
"checkForRedisURI",
"(",
")",
";",
"return",
"getConnection",
"(",
"connectPubSubAsync",
"(",
"codec",
",",
"redisURI",
",",
"timeout",
")",
")",
";",
"}"
]
| Open a new pub/sub connection to the Redis server using the supplied {@link RedisURI} and use the supplied
{@link RedisCodec codec} to encode/decode keys and values.
@param codec Use this codec to encode/decode keys and values, must not be {@literal null}
@param <K> Key type
@param <V> Value type
@return A new stateful pub/sub connection | [
"Open",
"a",
"new",
"pub",
"/",
"sub",
"connection",
"to",
"the",
"Redis",
"server",
"using",
"the",
"supplied",
"{",
"@link",
"RedisURI",
"}",
"and",
"use",
"the",
"supplied",
"{",
"@link",
"RedisCodec",
"codec",
"}",
"to",
"encode",
"/",
"decode",
"keys",
"and",
"values",
"."
]
| train | https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/RedisClient.java#L381-L384 |
UrielCh/ovh-java-sdk | ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java | ApiOvhDomain.data_claimNotice_GET | public OvhClaimNotice data_claimNotice_GET(String domain) throws IOException {
"""
Retrieve claim notices associated to a domain
REST: GET /domain/data/claimNotice
@param domain [required] Domain name
"""
String qPath = "/domain/data/claimNotice";
StringBuilder sb = path(qPath);
query(sb, "domain", domain);
String resp = execN(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhClaimNotice.class);
} | java | public OvhClaimNotice data_claimNotice_GET(String domain) throws IOException {
String qPath = "/domain/data/claimNotice";
StringBuilder sb = path(qPath);
query(sb, "domain", domain);
String resp = execN(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhClaimNotice.class);
} | [
"public",
"OvhClaimNotice",
"data_claimNotice_GET",
"(",
"String",
"domain",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/domain/data/claimNotice\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"query",
"(",
"sb",
",",
"\"domain\"",
",",
"domain",
")",
";",
"String",
"resp",
"=",
"execN",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhClaimNotice",
".",
"class",
")",
";",
"}"
]
| Retrieve claim notices associated to a domain
REST: GET /domain/data/claimNotice
@param domain [required] Domain name | [
"Retrieve",
"claim",
"notices",
"associated",
"to",
"a",
"domain"
]
| train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java#L245-L251 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfAction.java | PdfAction.gotoLocalPage | public static PdfAction gotoLocalPage(String dest, boolean isName) {
"""
Creates a GoTo action to a named destination.
@param dest the named destination
@param isName if true sets the destination as a name, if false sets it as a String
@return a GoTo action
"""
PdfAction action = new PdfAction();
action.put(PdfName.S, PdfName.GOTO);
if (isName)
action.put(PdfName.D, new PdfName(dest));
else
action.put(PdfName.D, new PdfString(dest, null));
return action;
} | java | public static PdfAction gotoLocalPage(String dest, boolean isName) {
PdfAction action = new PdfAction();
action.put(PdfName.S, PdfName.GOTO);
if (isName)
action.put(PdfName.D, new PdfName(dest));
else
action.put(PdfName.D, new PdfString(dest, null));
return action;
} | [
"public",
"static",
"PdfAction",
"gotoLocalPage",
"(",
"String",
"dest",
",",
"boolean",
"isName",
")",
"{",
"PdfAction",
"action",
"=",
"new",
"PdfAction",
"(",
")",
";",
"action",
".",
"put",
"(",
"PdfName",
".",
"S",
",",
"PdfName",
".",
"GOTO",
")",
";",
"if",
"(",
"isName",
")",
"action",
".",
"put",
"(",
"PdfName",
".",
"D",
",",
"new",
"PdfName",
"(",
"dest",
")",
")",
";",
"else",
"action",
".",
"put",
"(",
"PdfName",
".",
"D",
",",
"new",
"PdfString",
"(",
"dest",
",",
"null",
")",
")",
";",
"return",
"action",
";",
"}"
]
| Creates a GoTo action to a named destination.
@param dest the named destination
@param isName if true sets the destination as a name, if false sets it as a String
@return a GoTo action | [
"Creates",
"a",
"GoTo",
"action",
"to",
"a",
"named",
"destination",
"."
]
| train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfAction.java#L470-L478 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.