repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/TrmMessageFactoryImpl.java | TrmMessageFactoryImpl.createInboundTrmFirstContactMessage | public TrmFirstContactMessage createInboundTrmFirstContactMessage(byte rawMessage[], int offset, int length)
throws MessageDecodeFailedException {
"""
Create a TrmFirstContactMessage to represent an inbound message.
@param rawMessage The inbound byte array containging a complete message
@param offset The offset in the byte array at which the message begins
@param length The length of the message within the byte array
@return The new TrmFirstContactMessage
@exception MessageDecodeFailedException Thrown if the inbound message could not be decoded
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createInboundTrmFirstContactMessage", new Object[]{rawMessage, Integer.valueOf(offset), Integer.valueOf(length)});
JsMsgObject jmo = new JsMsgObject(TrmFirstContactAccess.schema, rawMessage, offset, length);
TrmFirstContactMessage message = new TrmFirstContactMessageImpl(jmo);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createInboundTrmFirstContactMessage", message);
return message;
} | java | public TrmFirstContactMessage createInboundTrmFirstContactMessage(byte rawMessage[], int offset, int length)
throws MessageDecodeFailedException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createInboundTrmFirstContactMessage", new Object[]{rawMessage, Integer.valueOf(offset), Integer.valueOf(length)});
JsMsgObject jmo = new JsMsgObject(TrmFirstContactAccess.schema, rawMessage, offset, length);
TrmFirstContactMessage message = new TrmFirstContactMessageImpl(jmo);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createInboundTrmFirstContactMessage", message);
return message;
} | [
"public",
"TrmFirstContactMessage",
"createInboundTrmFirstContactMessage",
"(",
"byte",
"rawMessage",
"[",
"]",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"MessageDecodeFailedException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"createInboundTrmFirstContactMessage\"",
",",
"new",
"Object",
"[",
"]",
"{",
"rawMessage",
",",
"Integer",
".",
"valueOf",
"(",
"offset",
")",
",",
"Integer",
".",
"valueOf",
"(",
"length",
")",
"}",
")",
";",
"JsMsgObject",
"jmo",
"=",
"new",
"JsMsgObject",
"(",
"TrmFirstContactAccess",
".",
"schema",
",",
"rawMessage",
",",
"offset",
",",
"length",
")",
";",
"TrmFirstContactMessage",
"message",
"=",
"new",
"TrmFirstContactMessageImpl",
"(",
"jmo",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"createInboundTrmFirstContactMessage\"",
",",
"message",
")",
";",
"return",
"message",
";",
"}"
] | Create a TrmFirstContactMessage to represent an inbound message.
@param rawMessage The inbound byte array containging a complete message
@param offset The offset in the byte array at which the message begins
@param length The length of the message within the byte array
@return The new TrmFirstContactMessage
@exception MessageDecodeFailedException Thrown if the inbound message could not be decoded | [
"Create",
"a",
"TrmFirstContactMessage",
"to",
"represent",
"an",
"inbound",
"message",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/TrmMessageFactoryImpl.java#L336-L346 |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/Path3d.java | Path3d.getClosestPointTo | public static Point3d getClosestPointTo(PathIterator3d pathIterator, double x, double y, double z) {
"""
Replies the point on the path that is closest to the given point.
<p>
<strong>CAUTION:</strong> This function works only on path iterators
that are replying polyline primitives, ie. if the
{@link PathIterator3d#isPolyline()} of <var>pi</var> is replying
<code>true</code>.
{@link #getClosestPointTo(Point3D)} avoids this restriction.
@param pi is the iterator on the elements of the path.
@param x
@param y
@param z
@return the closest point on the shape; or the point itself
if it is inside the shape.
"""
Point3d closest = null;
double bestDist = Double.POSITIVE_INFINITY;
Point3d candidate;
AbstractPathElement3D pe = pathIterator.next();
Path3d subPath;
if (pe.type != PathElementType.MOVE_TO) {
throw new IllegalArgumentException("missing initial moveto in path definition");
}
candidate = new Point3d(pe.getToX(), pe.getToY(), pe.getToZ());
while (pathIterator.hasNext()) {
pe = pathIterator.next();
candidate = null;
switch(pe.type) {
case MOVE_TO:
candidate = new Point3d(pe.getToX(), pe.getToY(), pe.getToZ());
break;
case LINE_TO:
candidate = new Point3d((new Segment3d(pe.getFromX(), pe.getFromY(), pe.getFromZ(), pe.getToX(), pe.getToY(), pe.getToZ())).getClosestPointTo(new Point3d(x,y,z)));
break;
case CLOSE:
if (!pe.isEmpty()) {
candidate = new Point3d((new Segment3d(pe.getFromX(), pe.getFromY(), pe.getFromZ(), pe.getToX(), pe.getToY(), pe.getToZ())).getClosestPointTo(new Point3d(x,y,z)));
}
break;
case QUAD_TO:
subPath = new Path3d();
subPath.moveTo(pe.getFromX(), pe.getFromY(), pe.getFromZ());
subPath.quadTo(
pe.getCtrlX1(), pe.getCtrlY1(), pe.getCtrlZ1(),
pe.getToX(), pe.getToY(), pe.getToZ());
candidate = subPath.getClosestPointTo(new Point3d(x,y,z));
break;
case CURVE_TO:
subPath = new Path3d();
subPath.moveTo(pe.getFromX(), pe.getFromY(), pe.getFromZ());
subPath.curveTo(
pe.getCtrlX1(), pe.getCtrlY1(), pe.getCtrlZ1(),
pe.getCtrlX2(), pe.getCtrlY2(), pe.getCtrlZ2(),
pe.getToX(), pe.getToY(), pe.getToZ());
candidate = subPath.getClosestPointTo(new Point3d(x,y,z));
break;
default:
throw new IllegalStateException(
pe.type==null ? null : pe.type.toString());
}
if (candidate!=null) {
double d = candidate.getDistanceSquared(new Point3d(x,y,z));
if (d<bestDist) {
bestDist = d;
closest = candidate;
}
}
}
return closest;
} | java | public static Point3d getClosestPointTo(PathIterator3d pathIterator, double x, double y, double z) {
Point3d closest = null;
double bestDist = Double.POSITIVE_INFINITY;
Point3d candidate;
AbstractPathElement3D pe = pathIterator.next();
Path3d subPath;
if (pe.type != PathElementType.MOVE_TO) {
throw new IllegalArgumentException("missing initial moveto in path definition");
}
candidate = new Point3d(pe.getToX(), pe.getToY(), pe.getToZ());
while (pathIterator.hasNext()) {
pe = pathIterator.next();
candidate = null;
switch(pe.type) {
case MOVE_TO:
candidate = new Point3d(pe.getToX(), pe.getToY(), pe.getToZ());
break;
case LINE_TO:
candidate = new Point3d((new Segment3d(pe.getFromX(), pe.getFromY(), pe.getFromZ(), pe.getToX(), pe.getToY(), pe.getToZ())).getClosestPointTo(new Point3d(x,y,z)));
break;
case CLOSE:
if (!pe.isEmpty()) {
candidate = new Point3d((new Segment3d(pe.getFromX(), pe.getFromY(), pe.getFromZ(), pe.getToX(), pe.getToY(), pe.getToZ())).getClosestPointTo(new Point3d(x,y,z)));
}
break;
case QUAD_TO:
subPath = new Path3d();
subPath.moveTo(pe.getFromX(), pe.getFromY(), pe.getFromZ());
subPath.quadTo(
pe.getCtrlX1(), pe.getCtrlY1(), pe.getCtrlZ1(),
pe.getToX(), pe.getToY(), pe.getToZ());
candidate = subPath.getClosestPointTo(new Point3d(x,y,z));
break;
case CURVE_TO:
subPath = new Path3d();
subPath.moveTo(pe.getFromX(), pe.getFromY(), pe.getFromZ());
subPath.curveTo(
pe.getCtrlX1(), pe.getCtrlY1(), pe.getCtrlZ1(),
pe.getCtrlX2(), pe.getCtrlY2(), pe.getCtrlZ2(),
pe.getToX(), pe.getToY(), pe.getToZ());
candidate = subPath.getClosestPointTo(new Point3d(x,y,z));
break;
default:
throw new IllegalStateException(
pe.type==null ? null : pe.type.toString());
}
if (candidate!=null) {
double d = candidate.getDistanceSquared(new Point3d(x,y,z));
if (d<bestDist) {
bestDist = d;
closest = candidate;
}
}
}
return closest;
} | [
"public",
"static",
"Point3d",
"getClosestPointTo",
"(",
"PathIterator3d",
"pathIterator",
",",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"Point3d",
"closest",
"=",
"null",
";",
"double",
"bestDist",
"=",
"Double",
".",
"POSITIVE_INFINITY",
";",
"Point3d",
"candidate",
";",
"AbstractPathElement3D",
"pe",
"=",
"pathIterator",
".",
"next",
"(",
")",
";",
"Path3d",
"subPath",
";",
"if",
"(",
"pe",
".",
"type",
"!=",
"PathElementType",
".",
"MOVE_TO",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"missing initial moveto in path definition\"",
")",
";",
"}",
"candidate",
"=",
"new",
"Point3d",
"(",
"pe",
".",
"getToX",
"(",
")",
",",
"pe",
".",
"getToY",
"(",
")",
",",
"pe",
".",
"getToZ",
"(",
")",
")",
";",
"while",
"(",
"pathIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"pe",
"=",
"pathIterator",
".",
"next",
"(",
")",
";",
"candidate",
"=",
"null",
";",
"switch",
"(",
"pe",
".",
"type",
")",
"{",
"case",
"MOVE_TO",
":",
"candidate",
"=",
"new",
"Point3d",
"(",
"pe",
".",
"getToX",
"(",
")",
",",
"pe",
".",
"getToY",
"(",
")",
",",
"pe",
".",
"getToZ",
"(",
")",
")",
";",
"break",
";",
"case",
"LINE_TO",
":",
"candidate",
"=",
"new",
"Point3d",
"(",
"(",
"new",
"Segment3d",
"(",
"pe",
".",
"getFromX",
"(",
")",
",",
"pe",
".",
"getFromY",
"(",
")",
",",
"pe",
".",
"getFromZ",
"(",
")",
",",
"pe",
".",
"getToX",
"(",
")",
",",
"pe",
".",
"getToY",
"(",
")",
",",
"pe",
".",
"getToZ",
"(",
")",
")",
")",
".",
"getClosestPointTo",
"(",
"new",
"Point3d",
"(",
"x",
",",
"y",
",",
"z",
")",
")",
")",
";",
"break",
";",
"case",
"CLOSE",
":",
"if",
"(",
"!",
"pe",
".",
"isEmpty",
"(",
")",
")",
"{",
"candidate",
"=",
"new",
"Point3d",
"(",
"(",
"new",
"Segment3d",
"(",
"pe",
".",
"getFromX",
"(",
")",
",",
"pe",
".",
"getFromY",
"(",
")",
",",
"pe",
".",
"getFromZ",
"(",
")",
",",
"pe",
".",
"getToX",
"(",
")",
",",
"pe",
".",
"getToY",
"(",
")",
",",
"pe",
".",
"getToZ",
"(",
")",
")",
")",
".",
"getClosestPointTo",
"(",
"new",
"Point3d",
"(",
"x",
",",
"y",
",",
"z",
")",
")",
")",
";",
"}",
"break",
";",
"case",
"QUAD_TO",
":",
"subPath",
"=",
"new",
"Path3d",
"(",
")",
";",
"subPath",
".",
"moveTo",
"(",
"pe",
".",
"getFromX",
"(",
")",
",",
"pe",
".",
"getFromY",
"(",
")",
",",
"pe",
".",
"getFromZ",
"(",
")",
")",
";",
"subPath",
".",
"quadTo",
"(",
"pe",
".",
"getCtrlX1",
"(",
")",
",",
"pe",
".",
"getCtrlY1",
"(",
")",
",",
"pe",
".",
"getCtrlZ1",
"(",
")",
",",
"pe",
".",
"getToX",
"(",
")",
",",
"pe",
".",
"getToY",
"(",
")",
",",
"pe",
".",
"getToZ",
"(",
")",
")",
";",
"candidate",
"=",
"subPath",
".",
"getClosestPointTo",
"(",
"new",
"Point3d",
"(",
"x",
",",
"y",
",",
"z",
")",
")",
";",
"break",
";",
"case",
"CURVE_TO",
":",
"subPath",
"=",
"new",
"Path3d",
"(",
")",
";",
"subPath",
".",
"moveTo",
"(",
"pe",
".",
"getFromX",
"(",
")",
",",
"pe",
".",
"getFromY",
"(",
")",
",",
"pe",
".",
"getFromZ",
"(",
")",
")",
";",
"subPath",
".",
"curveTo",
"(",
"pe",
".",
"getCtrlX1",
"(",
")",
",",
"pe",
".",
"getCtrlY1",
"(",
")",
",",
"pe",
".",
"getCtrlZ1",
"(",
")",
",",
"pe",
".",
"getCtrlX2",
"(",
")",
",",
"pe",
".",
"getCtrlY2",
"(",
")",
",",
"pe",
".",
"getCtrlZ2",
"(",
")",
",",
"pe",
".",
"getToX",
"(",
")",
",",
"pe",
".",
"getToY",
"(",
")",
",",
"pe",
".",
"getToZ",
"(",
")",
")",
";",
"candidate",
"=",
"subPath",
".",
"getClosestPointTo",
"(",
"new",
"Point3d",
"(",
"x",
",",
"y",
",",
"z",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"pe",
".",
"type",
"==",
"null",
"?",
"null",
":",
"pe",
".",
"type",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"candidate",
"!=",
"null",
")",
"{",
"double",
"d",
"=",
"candidate",
".",
"getDistanceSquared",
"(",
"new",
"Point3d",
"(",
"x",
",",
"y",
",",
"z",
")",
")",
";",
"if",
"(",
"d",
"<",
"bestDist",
")",
"{",
"bestDist",
"=",
"d",
";",
"closest",
"=",
"candidate",
";",
"}",
"}",
"}",
"return",
"closest",
";",
"}"
] | Replies the point on the path that is closest to the given point.
<p>
<strong>CAUTION:</strong> This function works only on path iterators
that are replying polyline primitives, ie. if the
{@link PathIterator3d#isPolyline()} of <var>pi</var> is replying
<code>true</code>.
{@link #getClosestPointTo(Point3D)} avoids this restriction.
@param pi is the iterator on the elements of the path.
@param x
@param y
@param z
@return the closest point on the shape; or the point itself
if it is inside the shape. | [
"Replies",
"the",
"point",
"on",
"the",
"path",
"that",
"is",
"closest",
"to",
"the",
"given",
"point",
".",
"<p",
">",
"<strong",
">",
"CAUTION",
":",
"<",
"/",
"strong",
">",
"This",
"function",
"works",
"only",
"on",
"path",
"iterators",
"that",
"are",
"replying",
"polyline",
"primitives",
"ie",
".",
"if",
"the",
"{",
"@link",
"PathIterator3d#isPolyline",
"()",
"}",
"of",
"<var",
">",
"pi<",
"/",
"var",
">",
"is",
"replying",
"<code",
">",
"true<",
"/",
"code",
">",
".",
"{",
"@link",
"#getClosestPointTo",
"(",
"Point3D",
")",
"}",
"avoids",
"this",
"restriction",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Path3d.java#L106-L172 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/metadata/ejb/InterceptorMetaDataHelper.java | InterceptorMetaDataHelper.validateLifeCycleSignature | public static void validateLifeCycleSignature(InterceptorMethodKind kind, String lifeCycle, Method m, boolean ejbClass, J2EEName name)
throws EJBConfigurationException {
"""
Verify that a specified life cycle event interceptor method has correct
method modifiers, parameter types, return type, and exception types for
the throws clause. Note, if parameter types is known to be valid,
then use the {@link #validateLifeCycleSignatureExceptParameters(String, Method)
method of this class to skip parameter type validation.
@param lifeCycle is a string that identifies the type of life cycle event callback.
@param m is the java reflection Method object for the life cycle interceptor method.
@param ejbClass must be boolean true if the m is a method of the EJB class.
If m is a method of an interceptor or a super class of the EJB class,
then boolean false must be specified.
@throws EJBConfigurationException is thrown if any configuration error is detected.
"""
// Validate method signature except for the parameter types,
// which is done by this method.
validateLifeCycleSignatureExceptParameters(kind, lifeCycle, m, ejbClass, name); // d450431
// Now verify method parameter types.
Class<?>[] parmTypes = m.getParameterTypes();
if (ejbClass)
{
// This is EJB class, so interceptor should have no parameters.
if (parmTypes.length != 0)
{
// CNTR0231E: "{0}" interceptor method "{1}" signature is incorrect.
String method = m.toGenericString();
Tr.error(tc, "INVALID_LIFECYCLE_SIGNATURE_CNTR0231E", new Object[] { method, lifeCycle });
throw new EJBConfigurationException(lifeCycle + " interceptor \"" + method
+ "\" must have zero parameters.");
}
}
else
{
// This is an interceptor class, so InvocationContext is a required parameter
// for the interceptor method.
if ((parmTypes.length == 1) && (parmTypes[0].equals(InvocationContext.class)))
{
// Has correct signature of 1 parameter of type InvocationContext
}
else
{
// CNTR0232E: The {0} method does not have the required
// method signature for a {1} method of a interceptor class.
String method = m.toGenericString();
Tr.error(tc, "INVALID_LIFECYCLE_SIGNATURE_CNTR0232E", new Object[] { method, lifeCycle });
throw new EJBConfigurationException("CNTR0232E: The \"" + method
+ "\" method does not have the required method signature for a \""
+ lifeCycle + "\" method of a interceptor class.");
}
}
} | java | public static void validateLifeCycleSignature(InterceptorMethodKind kind, String lifeCycle, Method m, boolean ejbClass, J2EEName name)
throws EJBConfigurationException
{
// Validate method signature except for the parameter types,
// which is done by this method.
validateLifeCycleSignatureExceptParameters(kind, lifeCycle, m, ejbClass, name); // d450431
// Now verify method parameter types.
Class<?>[] parmTypes = m.getParameterTypes();
if (ejbClass)
{
// This is EJB class, so interceptor should have no parameters.
if (parmTypes.length != 0)
{
// CNTR0231E: "{0}" interceptor method "{1}" signature is incorrect.
String method = m.toGenericString();
Tr.error(tc, "INVALID_LIFECYCLE_SIGNATURE_CNTR0231E", new Object[] { method, lifeCycle });
throw new EJBConfigurationException(lifeCycle + " interceptor \"" + method
+ "\" must have zero parameters.");
}
}
else
{
// This is an interceptor class, so InvocationContext is a required parameter
// for the interceptor method.
if ((parmTypes.length == 1) && (parmTypes[0].equals(InvocationContext.class)))
{
// Has correct signature of 1 parameter of type InvocationContext
}
else
{
// CNTR0232E: The {0} method does not have the required
// method signature for a {1} method of a interceptor class.
String method = m.toGenericString();
Tr.error(tc, "INVALID_LIFECYCLE_SIGNATURE_CNTR0232E", new Object[] { method, lifeCycle });
throw new EJBConfigurationException("CNTR0232E: The \"" + method
+ "\" method does not have the required method signature for a \""
+ lifeCycle + "\" method of a interceptor class.");
}
}
} | [
"public",
"static",
"void",
"validateLifeCycleSignature",
"(",
"InterceptorMethodKind",
"kind",
",",
"String",
"lifeCycle",
",",
"Method",
"m",
",",
"boolean",
"ejbClass",
",",
"J2EEName",
"name",
")",
"throws",
"EJBConfigurationException",
"{",
"// Validate method signature except for the parameter types,",
"// which is done by this method.",
"validateLifeCycleSignatureExceptParameters",
"(",
"kind",
",",
"lifeCycle",
",",
"m",
",",
"ejbClass",
",",
"name",
")",
";",
"// d450431",
"// Now verify method parameter types.",
"Class",
"<",
"?",
">",
"[",
"]",
"parmTypes",
"=",
"m",
".",
"getParameterTypes",
"(",
")",
";",
"if",
"(",
"ejbClass",
")",
"{",
"// This is EJB class, so interceptor should have no parameters.",
"if",
"(",
"parmTypes",
".",
"length",
"!=",
"0",
")",
"{",
"// CNTR0231E: \"{0}\" interceptor method \"{1}\" signature is incorrect.",
"String",
"method",
"=",
"m",
".",
"toGenericString",
"(",
")",
";",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"INVALID_LIFECYCLE_SIGNATURE_CNTR0231E\"",
",",
"new",
"Object",
"[",
"]",
"{",
"method",
",",
"lifeCycle",
"}",
")",
";",
"throw",
"new",
"EJBConfigurationException",
"(",
"lifeCycle",
"+",
"\" interceptor \\\"\"",
"+",
"method",
"+",
"\"\\\" must have zero parameters.\"",
")",
";",
"}",
"}",
"else",
"{",
"// This is an interceptor class, so InvocationContext is a required parameter",
"// for the interceptor method.",
"if",
"(",
"(",
"parmTypes",
".",
"length",
"==",
"1",
")",
"&&",
"(",
"parmTypes",
"[",
"0",
"]",
".",
"equals",
"(",
"InvocationContext",
".",
"class",
")",
")",
")",
"{",
"// Has correct signature of 1 parameter of type InvocationContext",
"}",
"else",
"{",
"// CNTR0232E: The {0} method does not have the required",
"// method signature for a {1} method of a interceptor class.",
"String",
"method",
"=",
"m",
".",
"toGenericString",
"(",
")",
";",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"INVALID_LIFECYCLE_SIGNATURE_CNTR0232E\"",
",",
"new",
"Object",
"[",
"]",
"{",
"method",
",",
"lifeCycle",
"}",
")",
";",
"throw",
"new",
"EJBConfigurationException",
"(",
"\"CNTR0232E: The \\\"\"",
"+",
"method",
"+",
"\"\\\" method does not have the required method signature for a \\\"\"",
"+",
"lifeCycle",
"+",
"\"\\\" method of a interceptor class.\"",
")",
";",
"}",
"}",
"}"
] | Verify that a specified life cycle event interceptor method has correct
method modifiers, parameter types, return type, and exception types for
the throws clause. Note, if parameter types is known to be valid,
then use the {@link #validateLifeCycleSignatureExceptParameters(String, Method)
method of this class to skip parameter type validation.
@param lifeCycle is a string that identifies the type of life cycle event callback.
@param m is the java reflection Method object for the life cycle interceptor method.
@param ejbClass must be boolean true if the m is a method of the EJB class.
If m is a method of an interceptor or a super class of the EJB class,
then boolean false must be specified.
@throws EJBConfigurationException is thrown if any configuration error is detected. | [
"Verify",
"that",
"a",
"specified",
"life",
"cycle",
"event",
"interceptor",
"method",
"has",
"correct",
"method",
"modifiers",
"parameter",
"types",
"return",
"type",
"and",
"exception",
"types",
"for",
"the",
"throws",
"clause",
".",
"Note",
"if",
"parameter",
"types",
"is",
"known",
"to",
"be",
"valid",
"then",
"use",
"the",
"{",
"@link",
"#validateLifeCycleSignatureExceptParameters",
"(",
"String",
"Method",
")",
"method",
"of",
"this",
"class",
"to",
"skip",
"parameter",
"type",
"validation",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ws/metadata/ejb/InterceptorMetaDataHelper.java#L787-L827 |
ops4j/org.ops4j.base | ops4j-base-spi/src/main/java/org/ops4j/spi/SafeServiceLoader.java | SafeServiceLoader.parseLine | private void parseLine( List<String> names, String line ) {
"""
Parses a single line of a META-INF/services resources. If the line contains a class name, the
name is added to the given list.
@param names list of class names
@param line line to be parsed
"""
int commentPos = line.indexOf( '#' );
if( commentPos >= 0 )
{
line = line.substring( 0, commentPos );
}
line = line.trim();
if( !line.isEmpty() && !names.contains( line ) )
{
names.add( line );
}
} | java | private void parseLine( List<String> names, String line )
{
int commentPos = line.indexOf( '#' );
if( commentPos >= 0 )
{
line = line.substring( 0, commentPos );
}
line = line.trim();
if( !line.isEmpty() && !names.contains( line ) )
{
names.add( line );
}
} | [
"private",
"void",
"parseLine",
"(",
"List",
"<",
"String",
">",
"names",
",",
"String",
"line",
")",
"{",
"int",
"commentPos",
"=",
"line",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"commentPos",
">=",
"0",
")",
"{",
"line",
"=",
"line",
".",
"substring",
"(",
"0",
",",
"commentPos",
")",
";",
"}",
"line",
"=",
"line",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"line",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"names",
".",
"contains",
"(",
"line",
")",
")",
"{",
"names",
".",
"add",
"(",
"line",
")",
";",
"}",
"}"
] | Parses a single line of a META-INF/services resources. If the line contains a class name, the
name is added to the given list.
@param names list of class names
@param line line to be parsed | [
"Parses",
"a",
"single",
"line",
"of",
"a",
"META",
"-",
"INF",
"/",
"services",
"resources",
".",
"If",
"the",
"line",
"contains",
"a",
"class",
"name",
"the",
"name",
"is",
"added",
"to",
"the",
"given",
"list",
"."
] | train | https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-spi/src/main/java/org/ops4j/spi/SafeServiceLoader.java#L180-L192 |
ehcache/ehcache3 | impl/src/main/java/org/ehcache/impl/internal/resilience/RobustLoaderWriterResilienceStrategy.java | RobustLoaderWriterResilienceStrategy.putAllFailure | @Override
public void putAllFailure(Map<? extends K, ? extends V> entries, StoreAccessException e) {
"""
Write all entries to the loader-writer.
@param entries the entries being put
@param e the triggered failure
"""
try {
loaderWriter.writeAll(entries.entrySet()); // FIXME: bad typing that we should fix
} catch(BulkCacheWritingException e1) {
throw e1;
} catch (Exception e1) {
throw ExceptionFactory.newCacheWritingException(e1, e);
} finally {
cleanup(entries.keySet(), e);
}
} | java | @Override
public void putAllFailure(Map<? extends K, ? extends V> entries, StoreAccessException e) {
try {
loaderWriter.writeAll(entries.entrySet()); // FIXME: bad typing that we should fix
} catch(BulkCacheWritingException e1) {
throw e1;
} catch (Exception e1) {
throw ExceptionFactory.newCacheWritingException(e1, e);
} finally {
cleanup(entries.keySet(), e);
}
} | [
"@",
"Override",
"public",
"void",
"putAllFailure",
"(",
"Map",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"entries",
",",
"StoreAccessException",
"e",
")",
"{",
"try",
"{",
"loaderWriter",
".",
"writeAll",
"(",
"entries",
".",
"entrySet",
"(",
")",
")",
";",
"// FIXME: bad typing that we should fix",
"}",
"catch",
"(",
"BulkCacheWritingException",
"e1",
")",
"{",
"throw",
"e1",
";",
"}",
"catch",
"(",
"Exception",
"e1",
")",
"{",
"throw",
"ExceptionFactory",
".",
"newCacheWritingException",
"(",
"e1",
",",
"e",
")",
";",
"}",
"finally",
"{",
"cleanup",
"(",
"entries",
".",
"keySet",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Write all entries to the loader-writer.
@param entries the entries being put
@param e the triggered failure | [
"Write",
"all",
"entries",
"to",
"the",
"loader",
"-",
"writer",
"."
] | train | https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/impl/src/main/java/org/ehcache/impl/internal/resilience/RobustLoaderWriterResilienceStrategy.java#L290-L301 |
sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java | AbsDiff.diffAlgorithm | private EDiff diffAlgorithm(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx,
final DepthCounter paramDepth) throws TTIOException {
"""
Main algorithm to compute diffs between two nodes.
@param paramNewRtx
{@link IReadTransaction} on new revision
@param paramOldRtx
{@link IReadTransaction} on old revision
@param paramDepth
{@link DepthCounter} container for current depths of both
transaction cursors
@return kind of diff
@throws TTIOException
"""
EDiff diff = null;
// Check if node has been deleted.
if (paramDepth.getOldDepth() > paramDepth.getNewDepth()) {
diff = EDiff.DELETED;
} else if (checkUpdate(paramNewRtx, paramOldRtx)) { // Check if node has
// been updated.
diff = EDiff.UPDATED;
} else {
// See if one of the right sibling matches.
EFoundEqualNode found = EFoundEqualNode.FALSE;
final long key = paramOldRtx.getNode().getDataKey();
while (((ITreeStructData)paramOldRtx.getNode()).hasRightSibling()
&& paramOldRtx.moveTo(((ITreeStructData)paramOldRtx.getNode()).getRightSiblingKey())
&& found == EFoundEqualNode.FALSE) {
if (checkNodes(paramNewRtx, paramOldRtx)) {
found = EFoundEqualNode.TRUE;
}
}
paramOldRtx.moveTo(key);
diff = found.kindOfDiff();
}
assert diff != null;
return diff;
} | java | private EDiff diffAlgorithm(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx,
final DepthCounter paramDepth) throws TTIOException {
EDiff diff = null;
// Check if node has been deleted.
if (paramDepth.getOldDepth() > paramDepth.getNewDepth()) {
diff = EDiff.DELETED;
} else if (checkUpdate(paramNewRtx, paramOldRtx)) { // Check if node has
// been updated.
diff = EDiff.UPDATED;
} else {
// See if one of the right sibling matches.
EFoundEqualNode found = EFoundEqualNode.FALSE;
final long key = paramOldRtx.getNode().getDataKey();
while (((ITreeStructData)paramOldRtx.getNode()).hasRightSibling()
&& paramOldRtx.moveTo(((ITreeStructData)paramOldRtx.getNode()).getRightSiblingKey())
&& found == EFoundEqualNode.FALSE) {
if (checkNodes(paramNewRtx, paramOldRtx)) {
found = EFoundEqualNode.TRUE;
}
}
paramOldRtx.moveTo(key);
diff = found.kindOfDiff();
}
assert diff != null;
return diff;
} | [
"private",
"EDiff",
"diffAlgorithm",
"(",
"final",
"INodeReadTrx",
"paramNewRtx",
",",
"final",
"INodeReadTrx",
"paramOldRtx",
",",
"final",
"DepthCounter",
"paramDepth",
")",
"throws",
"TTIOException",
"{",
"EDiff",
"diff",
"=",
"null",
";",
"// Check if node has been deleted.",
"if",
"(",
"paramDepth",
".",
"getOldDepth",
"(",
")",
">",
"paramDepth",
".",
"getNewDepth",
"(",
")",
")",
"{",
"diff",
"=",
"EDiff",
".",
"DELETED",
";",
"}",
"else",
"if",
"(",
"checkUpdate",
"(",
"paramNewRtx",
",",
"paramOldRtx",
")",
")",
"{",
"// Check if node has",
"// been updated.",
"diff",
"=",
"EDiff",
".",
"UPDATED",
";",
"}",
"else",
"{",
"// See if one of the right sibling matches.",
"EFoundEqualNode",
"found",
"=",
"EFoundEqualNode",
".",
"FALSE",
";",
"final",
"long",
"key",
"=",
"paramOldRtx",
".",
"getNode",
"(",
")",
".",
"getDataKey",
"(",
")",
";",
"while",
"(",
"(",
"(",
"ITreeStructData",
")",
"paramOldRtx",
".",
"getNode",
"(",
")",
")",
".",
"hasRightSibling",
"(",
")",
"&&",
"paramOldRtx",
".",
"moveTo",
"(",
"(",
"(",
"ITreeStructData",
")",
"paramOldRtx",
".",
"getNode",
"(",
")",
")",
".",
"getRightSiblingKey",
"(",
")",
")",
"&&",
"found",
"==",
"EFoundEqualNode",
".",
"FALSE",
")",
"{",
"if",
"(",
"checkNodes",
"(",
"paramNewRtx",
",",
"paramOldRtx",
")",
")",
"{",
"found",
"=",
"EFoundEqualNode",
".",
"TRUE",
";",
"}",
"}",
"paramOldRtx",
".",
"moveTo",
"(",
"key",
")",
";",
"diff",
"=",
"found",
".",
"kindOfDiff",
"(",
")",
";",
"}",
"assert",
"diff",
"!=",
"null",
";",
"return",
"diff",
";",
"}"
] | Main algorithm to compute diffs between two nodes.
@param paramNewRtx
{@link IReadTransaction} on new revision
@param paramOldRtx
{@link IReadTransaction} on old revision
@param paramDepth
{@link DepthCounter} container for current depths of both
transaction cursors
@return kind of diff
@throws TTIOException | [
"Main",
"algorithm",
"to",
"compute",
"diffs",
"between",
"two",
"nodes",
"."
] | train | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java#L381-L410 |
deeplearning4j/deeplearning4j | datavec/datavec-spark/src/main/java/org/datavec/spark/transform/DataFrames.java | DataFrames.std | public static Column std(DataRowsFacade dataFrame, String columnName) {
"""
Standard deviation for a column
@param dataFrame the dataframe to
get the column from
@param columnName the name of the column to get the standard
deviation for
@return the column that represents the standard deviation
"""
return functions.sqrt(var(dataFrame, columnName));
} | java | public static Column std(DataRowsFacade dataFrame, String columnName) {
return functions.sqrt(var(dataFrame, columnName));
} | [
"public",
"static",
"Column",
"std",
"(",
"DataRowsFacade",
"dataFrame",
",",
"String",
"columnName",
")",
"{",
"return",
"functions",
".",
"sqrt",
"(",
"var",
"(",
"dataFrame",
",",
"columnName",
")",
")",
";",
"}"
] | Standard deviation for a column
@param dataFrame the dataframe to
get the column from
@param columnName the name of the column to get the standard
deviation for
@return the column that represents the standard deviation | [
"Standard",
"deviation",
"for",
"a",
"column"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-spark/src/main/java/org/datavec/spark/transform/DataFrames.java#L74-L76 |
hypercube1024/firefly | firefly/src/main/java/com/firefly/codec/http2/model/DateGenerator.java | DateGenerator.doFormatCookieDate | public void doFormatCookieDate(StringBuilder buf, long date) {
"""
Format "EEE, dd-MMM-yy HH:mm:ss 'GMT'" for cookies
@param buf the buffer to format the date into
@param date the date in milliseconds
"""
gc.setTimeInMillis(date);
int day_of_week = gc.get(Calendar.DAY_OF_WEEK);
int day_of_month = gc.get(Calendar.DAY_OF_MONTH);
int month = gc.get(Calendar.MONTH);
int year = gc.get(Calendar.YEAR);
year = year % 10000;
int epoch = (int) ((date / 1000) % (60 * 60 * 24));
int seconds = epoch % 60;
epoch = epoch / 60;
int minutes = epoch % 60;
int hours = epoch / 60;
buf.append(DAYS[day_of_week]);
buf.append(',');
buf.append(' ');
StringUtils.append2digits(buf, day_of_month);
buf.append('-');
buf.append(MONTHS[month]);
buf.append('-');
StringUtils.append2digits(buf, year / 100);
StringUtils.append2digits(buf, year % 100);
buf.append(' ');
StringUtils.append2digits(buf, hours);
buf.append(':');
StringUtils.append2digits(buf, minutes);
buf.append(':');
StringUtils.append2digits(buf, seconds);
buf.append(" GMT");
} | java | public void doFormatCookieDate(StringBuilder buf, long date) {
gc.setTimeInMillis(date);
int day_of_week = gc.get(Calendar.DAY_OF_WEEK);
int day_of_month = gc.get(Calendar.DAY_OF_MONTH);
int month = gc.get(Calendar.MONTH);
int year = gc.get(Calendar.YEAR);
year = year % 10000;
int epoch = (int) ((date / 1000) % (60 * 60 * 24));
int seconds = epoch % 60;
epoch = epoch / 60;
int minutes = epoch % 60;
int hours = epoch / 60;
buf.append(DAYS[day_of_week]);
buf.append(',');
buf.append(' ');
StringUtils.append2digits(buf, day_of_month);
buf.append('-');
buf.append(MONTHS[month]);
buf.append('-');
StringUtils.append2digits(buf, year / 100);
StringUtils.append2digits(buf, year % 100);
buf.append(' ');
StringUtils.append2digits(buf, hours);
buf.append(':');
StringUtils.append2digits(buf, minutes);
buf.append(':');
StringUtils.append2digits(buf, seconds);
buf.append(" GMT");
} | [
"public",
"void",
"doFormatCookieDate",
"(",
"StringBuilder",
"buf",
",",
"long",
"date",
")",
"{",
"gc",
".",
"setTimeInMillis",
"(",
"date",
")",
";",
"int",
"day_of_week",
"=",
"gc",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_WEEK",
")",
";",
"int",
"day_of_month",
"=",
"gc",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
")",
";",
"int",
"month",
"=",
"gc",
".",
"get",
"(",
"Calendar",
".",
"MONTH",
")",
";",
"int",
"year",
"=",
"gc",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
";",
"year",
"=",
"year",
"%",
"10000",
";",
"int",
"epoch",
"=",
"(",
"int",
")",
"(",
"(",
"date",
"/",
"1000",
")",
"%",
"(",
"60",
"*",
"60",
"*",
"24",
")",
")",
";",
"int",
"seconds",
"=",
"epoch",
"%",
"60",
";",
"epoch",
"=",
"epoch",
"/",
"60",
";",
"int",
"minutes",
"=",
"epoch",
"%",
"60",
";",
"int",
"hours",
"=",
"epoch",
"/",
"60",
";",
"buf",
".",
"append",
"(",
"DAYS",
"[",
"day_of_week",
"]",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"StringUtils",
".",
"append2digits",
"(",
"buf",
",",
"day_of_month",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"buf",
".",
"append",
"(",
"MONTHS",
"[",
"month",
"]",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"StringUtils",
".",
"append2digits",
"(",
"buf",
",",
"year",
"/",
"100",
")",
";",
"StringUtils",
".",
"append2digits",
"(",
"buf",
",",
"year",
"%",
"100",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"StringUtils",
".",
"append2digits",
"(",
"buf",
",",
"hours",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"StringUtils",
".",
"append2digits",
"(",
"buf",
",",
"minutes",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"StringUtils",
".",
"append2digits",
"(",
"buf",
",",
"seconds",
")",
";",
"buf",
".",
"append",
"(",
"\" GMT\"",
")",
";",
"}"
] | Format "EEE, dd-MMM-yy HH:mm:ss 'GMT'" for cookies
@param buf the buffer to format the date into
@param date the date in milliseconds | [
"Format",
"EEE",
"dd",
"-",
"MMM",
"-",
"yy",
"HH",
":",
"mm",
":",
"ss",
"GMT",
"for",
"cookies"
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/DateGenerator.java#L115-L148 |
vtatai/srec | core/src/main/java/com/github/srec/command/method/MethodCommand.java | MethodCommand.callMethod | public Value callMethod(ExecutionContext context, Map<String, Value> params) {
"""
Executes the method call.
@param context The execution context
@param params The parameters to run the method
@return The return value from the method call
"""
validateParameters(params);
fillDefaultValues(params);
return internalCallMethod(context, params);
} | java | public Value callMethod(ExecutionContext context, Map<String, Value> params) {
validateParameters(params);
fillDefaultValues(params);
return internalCallMethod(context, params);
} | [
"public",
"Value",
"callMethod",
"(",
"ExecutionContext",
"context",
",",
"Map",
"<",
"String",
",",
"Value",
">",
"params",
")",
"{",
"validateParameters",
"(",
"params",
")",
";",
"fillDefaultValues",
"(",
"params",
")",
";",
"return",
"internalCallMethod",
"(",
"context",
",",
"params",
")",
";",
"}"
] | Executes the method call.
@param context The execution context
@param params The parameters to run the method
@return The return value from the method call | [
"Executes",
"the",
"method",
"call",
"."
] | train | https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/method/MethodCommand.java#L77-L81 |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java | DeLiClu.expandNodes | private void expandNodes(DeLiCluTree index, SpatialPrimitiveDistanceFunction<V> distFunction, SpatialObjectPair nodePair, DataStore<KNNList> knns) {
"""
Expands the spatial nodes of the specified pair.
@param index the index storing the objects
@param distFunction the spatial distance function of this algorithm
@param nodePair the pair of nodes to be expanded
@param knns the knn list
"""
DeLiCluNode node1 = index.getNode(((SpatialDirectoryEntry) nodePair.entry1).getPageID());
DeLiCluNode node2 = index.getNode(((SpatialDirectoryEntry) nodePair.entry2).getPageID());
if(node1.isLeaf()) {
expandLeafNodes(distFunction, node1, node2, knns);
}
else {
expandDirNodes(distFunction, node1, node2);
}
index.setExpanded(nodePair.entry2, nodePair.entry1);
} | java | private void expandNodes(DeLiCluTree index, SpatialPrimitiveDistanceFunction<V> distFunction, SpatialObjectPair nodePair, DataStore<KNNList> knns) {
DeLiCluNode node1 = index.getNode(((SpatialDirectoryEntry) nodePair.entry1).getPageID());
DeLiCluNode node2 = index.getNode(((SpatialDirectoryEntry) nodePair.entry2).getPageID());
if(node1.isLeaf()) {
expandLeafNodes(distFunction, node1, node2, knns);
}
else {
expandDirNodes(distFunction, node1, node2);
}
index.setExpanded(nodePair.entry2, nodePair.entry1);
} | [
"private",
"void",
"expandNodes",
"(",
"DeLiCluTree",
"index",
",",
"SpatialPrimitiveDistanceFunction",
"<",
"V",
">",
"distFunction",
",",
"SpatialObjectPair",
"nodePair",
",",
"DataStore",
"<",
"KNNList",
">",
"knns",
")",
"{",
"DeLiCluNode",
"node1",
"=",
"index",
".",
"getNode",
"(",
"(",
"(",
"SpatialDirectoryEntry",
")",
"nodePair",
".",
"entry1",
")",
".",
"getPageID",
"(",
")",
")",
";",
"DeLiCluNode",
"node2",
"=",
"index",
".",
"getNode",
"(",
"(",
"(",
"SpatialDirectoryEntry",
")",
"nodePair",
".",
"entry2",
")",
".",
"getPageID",
"(",
")",
")",
";",
"if",
"(",
"node1",
".",
"isLeaf",
"(",
")",
")",
"{",
"expandLeafNodes",
"(",
"distFunction",
",",
"node1",
",",
"node2",
",",
"knns",
")",
";",
"}",
"else",
"{",
"expandDirNodes",
"(",
"distFunction",
",",
"node1",
",",
"node2",
")",
";",
"}",
"index",
".",
"setExpanded",
"(",
"nodePair",
".",
"entry2",
",",
"nodePair",
".",
"entry1",
")",
";",
"}"
] | Expands the spatial nodes of the specified pair.
@param index the index storing the objects
@param distFunction the spatial distance function of this algorithm
@param nodePair the pair of nodes to be expanded
@param knns the knn list | [
"Expands",
"the",
"spatial",
"nodes",
"of",
"the",
"specified",
"pair",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/DeLiClu.java#L209-L221 |
samskivert/pythagoras | src/main/java/pythagoras/f/Line.java | Line.setLine | public void setLine (float x1, float y1, float x2, float y2) {
"""
Sets the start and end point of this line to the specified values.
"""
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
} | java | public void setLine (float x1, float y1, float x2, float y2) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
} | [
"public",
"void",
"setLine",
"(",
"float",
"x1",
",",
"float",
"y1",
",",
"float",
"x2",
",",
"float",
"y2",
")",
"{",
"this",
".",
"x1",
"=",
"x1",
";",
"this",
".",
"y1",
"=",
"y1",
";",
"this",
".",
"x2",
"=",
"x2",
";",
"this",
".",
"y2",
"=",
"y2",
";",
"}"
] | Sets the start and end point of this line to the specified values. | [
"Sets",
"the",
"start",
"and",
"end",
"point",
"of",
"this",
"line",
"to",
"the",
"specified",
"values",
"."
] | train | https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/f/Line.java#L51-L56 |
mabe02/lanterna | src/main/java/com/googlecode/lanterna/TerminalTextUtils.java | TerminalTextUtils.getANSIControlSequenceLength | public static int getANSIControlSequenceLength(String string, int index) {
"""
Given a string and an index in that string, returns the number of characters starting at index that make up
a complete ANSI control sequence. If there is no control sequence starting there, the method will return 0.
@param string String to scan for control sequences
@param index Index in the string where the control sequence begins
@return {@code 0} if there was no control sequence starting at the specified index, otherwise the length
of the entire control sequence
"""
int len = 0, restlen = string.length() - index;
if (restlen >= 3) { // Control sequences require a minimum of three characters
char esc = string.charAt(index),
bracket = string.charAt(index+1);
if (esc == 0x1B && bracket == '[') { // escape & open bracket
len = 3; // esc,bracket and (later)terminator.
// digits or semicolons can still precede the terminator:
for (int i = 2; i < restlen; i++) {
char ch = string.charAt(i + index);
// only ascii-digits or semicolons allowed here:
if ( (ch >= '0' && ch <= '9') || ch == ';') {
len++;
} else {
break;
}
}
// if string ends in digits/semicolons, then it's not a sequence.
if (len > restlen) {
len = 0;
}
}
}
return len;
} | java | public static int getANSIControlSequenceLength(String string, int index) {
int len = 0, restlen = string.length() - index;
if (restlen >= 3) { // Control sequences require a minimum of three characters
char esc = string.charAt(index),
bracket = string.charAt(index+1);
if (esc == 0x1B && bracket == '[') { // escape & open bracket
len = 3; // esc,bracket and (later)terminator.
// digits or semicolons can still precede the terminator:
for (int i = 2; i < restlen; i++) {
char ch = string.charAt(i + index);
// only ascii-digits or semicolons allowed here:
if ( (ch >= '0' && ch <= '9') || ch == ';') {
len++;
} else {
break;
}
}
// if string ends in digits/semicolons, then it's not a sequence.
if (len > restlen) {
len = 0;
}
}
}
return len;
} | [
"public",
"static",
"int",
"getANSIControlSequenceLength",
"(",
"String",
"string",
",",
"int",
"index",
")",
"{",
"int",
"len",
"=",
"0",
",",
"restlen",
"=",
"string",
".",
"length",
"(",
")",
"-",
"index",
";",
"if",
"(",
"restlen",
">=",
"3",
")",
"{",
"// Control sequences require a minimum of three characters",
"char",
"esc",
"=",
"string",
".",
"charAt",
"(",
"index",
")",
",",
"bracket",
"=",
"string",
".",
"charAt",
"(",
"index",
"+",
"1",
")",
";",
"if",
"(",
"esc",
"==",
"0x1B",
"&&",
"bracket",
"==",
"'",
"'",
")",
"{",
"// escape & open bracket",
"len",
"=",
"3",
";",
"// esc,bracket and (later)terminator.",
"// digits or semicolons can still precede the terminator:",
"for",
"(",
"int",
"i",
"=",
"2",
";",
"i",
"<",
"restlen",
";",
"i",
"++",
")",
"{",
"char",
"ch",
"=",
"string",
".",
"charAt",
"(",
"i",
"+",
"index",
")",
";",
"// only ascii-digits or semicolons allowed here:",
"if",
"(",
"(",
"ch",
">=",
"'",
"'",
"&&",
"ch",
"<=",
"'",
"'",
")",
"||",
"ch",
"==",
"'",
"'",
")",
"{",
"len",
"++",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"// if string ends in digits/semicolons, then it's not a sequence.",
"if",
"(",
"len",
">",
"restlen",
")",
"{",
"len",
"=",
"0",
";",
"}",
"}",
"}",
"return",
"len",
";",
"}"
] | Given a string and an index in that string, returns the number of characters starting at index that make up
a complete ANSI control sequence. If there is no control sequence starting there, the method will return 0.
@param string String to scan for control sequences
@param index Index in the string where the control sequence begins
@return {@code 0} if there was no control sequence starting at the specified index, otherwise the length
of the entire control sequence | [
"Given",
"a",
"string",
"and",
"an",
"index",
"in",
"that",
"string",
"returns",
"the",
"number",
"of",
"characters",
"starting",
"at",
"index",
"that",
"make",
"up",
"a",
"complete",
"ANSI",
"control",
"sequence",
".",
"If",
"there",
"is",
"no",
"control",
"sequence",
"starting",
"there",
"the",
"method",
"will",
"return",
"0",
"."
] | train | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TerminalTextUtils.java#L64-L88 |
joniles/mpxj | src/main/java/net/sf/mpxj/utility/TimephasedUtility.java | TimephasedUtility.getRangeCost | private Double getRangeCost(ProjectCalendar projectCalendar, TimescaleUnits rangeUnits, DateRange range, List<TimephasedCost> assignments, int startIndex) {
"""
For a given date range, determine the cost, based on the
timephased resource assignment data.
@param projectCalendar calendar used for the resource assignment calendar
@param rangeUnits timescale units
@param range target date range
@param assignments timephased resource assignments
@param startIndex index at which to start searching through the timephased resource assignments
@return work duration
"""
Double result;
switch (rangeUnits)
{
case MINUTES:
case HOURS:
{
result = getRangeCostSubDay(projectCalendar, rangeUnits, range, assignments, startIndex);
break;
}
default:
{
result = getRangeCostWholeDay(projectCalendar, rangeUnits, range, assignments, startIndex);
break;
}
}
return result;
} | java | private Double getRangeCost(ProjectCalendar projectCalendar, TimescaleUnits rangeUnits, DateRange range, List<TimephasedCost> assignments, int startIndex)
{
Double result;
switch (rangeUnits)
{
case MINUTES:
case HOURS:
{
result = getRangeCostSubDay(projectCalendar, rangeUnits, range, assignments, startIndex);
break;
}
default:
{
result = getRangeCostWholeDay(projectCalendar, rangeUnits, range, assignments, startIndex);
break;
}
}
return result;
} | [
"private",
"Double",
"getRangeCost",
"(",
"ProjectCalendar",
"projectCalendar",
",",
"TimescaleUnits",
"rangeUnits",
",",
"DateRange",
"range",
",",
"List",
"<",
"TimephasedCost",
">",
"assignments",
",",
"int",
"startIndex",
")",
"{",
"Double",
"result",
";",
"switch",
"(",
"rangeUnits",
")",
"{",
"case",
"MINUTES",
":",
"case",
"HOURS",
":",
"{",
"result",
"=",
"getRangeCostSubDay",
"(",
"projectCalendar",
",",
"rangeUnits",
",",
"range",
",",
"assignments",
",",
"startIndex",
")",
";",
"break",
";",
"}",
"default",
":",
"{",
"result",
"=",
"getRangeCostWholeDay",
"(",
"projectCalendar",
",",
"rangeUnits",
",",
"range",
",",
"assignments",
",",
"startIndex",
")",
";",
"break",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | For a given date range, determine the cost, based on the
timephased resource assignment data.
@param projectCalendar calendar used for the resource assignment calendar
@param rangeUnits timescale units
@param range target date range
@param assignments timephased resource assignments
@param startIndex index at which to start searching through the timephased resource assignments
@return work duration | [
"For",
"a",
"given",
"date",
"range",
"determine",
"the",
"cost",
"based",
"on",
"the",
"timephased",
"resource",
"assignment",
"data",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/utility/TimephasedUtility.java#L396-L417 |
UrielCh/ovh-java-sdk | ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java | ApiOvhDomain.zone_zoneName_dynHost_login_login_GET | public OvhDynHostLogin zone_zoneName_dynHost_login_login_GET(String zoneName, String login) throws IOException {
"""
Get this object properties
REST: GET /domain/zone/{zoneName}/dynHost/login/{login}
@param zoneName [required] The internal name of your zone
@param login [required] Login
"""
String qPath = "/domain/zone/{zoneName}/dynHost/login/{login}";
StringBuilder sb = path(qPath, zoneName, login);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDynHostLogin.class);
} | java | public OvhDynHostLogin zone_zoneName_dynHost_login_login_GET(String zoneName, String login) throws IOException {
String qPath = "/domain/zone/{zoneName}/dynHost/login/{login}";
StringBuilder sb = path(qPath, zoneName, login);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDynHostLogin.class);
} | [
"public",
"OvhDynHostLogin",
"zone_zoneName_dynHost_login_login_GET",
"(",
"String",
"zoneName",
",",
"String",
"login",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/domain/zone/{zoneName}/dynHost/login/{login}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"zoneName",
",",
"login",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDynHostLogin",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /domain/zone/{zoneName}/dynHost/login/{login}
@param zoneName [required] The internal name of your zone
@param login [required] Login | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java#L438-L443 |
graphql-java/graphql-java | src/main/java/graphql/schema/diff/DiffSet.java | DiffSet.diffSet | public static DiffSet diffSet(GraphQLSchema schemaOld, GraphQLSchema schemaNew) {
"""
Creates a diff set out of the result of 2 schemas.
@param schemaOld the older schema
@param schemaNew the newer schema
@return a diff set representing them
"""
Map<String, Object> introspectionOld = introspect(schemaOld);
Map<String, Object> introspectionNew = introspect(schemaNew);
return diffSet(introspectionOld, introspectionNew);
} | java | public static DiffSet diffSet(GraphQLSchema schemaOld, GraphQLSchema schemaNew) {
Map<String, Object> introspectionOld = introspect(schemaOld);
Map<String, Object> introspectionNew = introspect(schemaNew);
return diffSet(introspectionOld, introspectionNew);
} | [
"public",
"static",
"DiffSet",
"diffSet",
"(",
"GraphQLSchema",
"schemaOld",
",",
"GraphQLSchema",
"schemaNew",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"introspectionOld",
"=",
"introspect",
"(",
"schemaOld",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"introspectionNew",
"=",
"introspect",
"(",
"schemaNew",
")",
";",
"return",
"diffSet",
"(",
"introspectionOld",
",",
"introspectionNew",
")",
";",
"}"
] | Creates a diff set out of the result of 2 schemas.
@param schemaOld the older schema
@param schemaNew the newer schema
@return a diff set representing them | [
"Creates",
"a",
"diff",
"set",
"out",
"of",
"the",
"result",
"of",
"2",
"schemas",
"."
] | train | https://github.com/graphql-java/graphql-java/blob/9214b6044317849388bd88a14b54fc1c18c9f29f/src/main/java/graphql/schema/diff/DiffSet.java#L63-L67 |
gallandarakhneorg/afc | advanced/nodefx/src/main/java/org/arakhne/afc/nodefx/ZoomableGraphicsContext.java | ZoomableGraphicsContext.quadraticCurveTo | public void quadraticCurveTo(double xc, double yc, double x1, double y1) {
"""
Adds segments to the current path to make a quadratic Bezier curve.
The coordinates are transformed by the current transform as they are
added to the path and unaffected by subsequent changes to the transform.
The current path is a path attribute
used for any of the path methods as specified in the
Rendering Attributes Table of {@link GraphicsContext}
and <b>is not affected</b> by the {@link #save()} and
{@link #restore()} operations.
@param xc the X coordinate of the control point
@param yc the Y coordinate of the control point
@param x1 the X coordinate of the end point
@param y1 the Y coordinate of the end point
"""
this.gc.quadraticCurveTo(
doc2fxX(xc), doc2fxY(yc),
doc2fxX(x1), doc2fxY(y1));
} | java | public void quadraticCurveTo(double xc, double yc, double x1, double y1) {
this.gc.quadraticCurveTo(
doc2fxX(xc), doc2fxY(yc),
doc2fxX(x1), doc2fxY(y1));
} | [
"public",
"void",
"quadraticCurveTo",
"(",
"double",
"xc",
",",
"double",
"yc",
",",
"double",
"x1",
",",
"double",
"y1",
")",
"{",
"this",
".",
"gc",
".",
"quadraticCurveTo",
"(",
"doc2fxX",
"(",
"xc",
")",
",",
"doc2fxY",
"(",
"yc",
")",
",",
"doc2fxX",
"(",
"x1",
")",
",",
"doc2fxY",
"(",
"y1",
")",
")",
";",
"}"
] | Adds segments to the current path to make a quadratic Bezier curve.
The coordinates are transformed by the current transform as they are
added to the path and unaffected by subsequent changes to the transform.
The current path is a path attribute
used for any of the path methods as specified in the
Rendering Attributes Table of {@link GraphicsContext}
and <b>is not affected</b> by the {@link #save()} and
{@link #restore()} operations.
@param xc the X coordinate of the control point
@param yc the Y coordinate of the control point
@param x1 the X coordinate of the end point
@param y1 the Y coordinate of the end point | [
"Adds",
"segments",
"to",
"the",
"current",
"path",
"to",
"make",
"a",
"quadratic",
"Bezier",
"curve",
".",
"The",
"coordinates",
"are",
"transformed",
"by",
"the",
"current",
"transform",
"as",
"they",
"are",
"added",
"to",
"the",
"path",
"and",
"unaffected",
"by",
"subsequent",
"changes",
"to",
"the",
"transform",
".",
"The",
"current",
"path",
"is",
"a",
"path",
"attribute",
"used",
"for",
"any",
"of",
"the",
"path",
"methods",
"as",
"specified",
"in",
"the",
"Rendering",
"Attributes",
"Table",
"of",
"{",
"@link",
"GraphicsContext",
"}",
"and",
"<b",
">",
"is",
"not",
"affected<",
"/",
"b",
">",
"by",
"the",
"{",
"@link",
"#save",
"()",
"}",
"and",
"{",
"@link",
"#restore",
"()",
"}",
"operations",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/nodefx/src/main/java/org/arakhne/afc/nodefx/ZoomableGraphicsContext.java#L1248-L1252 |
rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneak | public static <T, E extends Exception> T sneak(SneakySupplier<T, E> supplier) {
"""
returns a value from a lambda (Supplier) that can potentially throw an exception.
@param supplier Supplier that can throw an exception
@param <T> type of supplier's return value
@return a Supplier as defined in java.util.function
"""
return sneaked(supplier).get();
} | java | public static <T, E extends Exception> T sneak(SneakySupplier<T, E> supplier) {
return sneaked(supplier).get();
} | [
"public",
"static",
"<",
"T",
",",
"E",
"extends",
"Exception",
">",
"T",
"sneak",
"(",
"SneakySupplier",
"<",
"T",
",",
"E",
">",
"supplier",
")",
"{",
"return",
"sneaked",
"(",
"supplier",
")",
".",
"get",
"(",
")",
";",
"}"
] | returns a value from a lambda (Supplier) that can potentially throw an exception.
@param supplier Supplier that can throw an exception
@param <T> type of supplier's return value
@return a Supplier as defined in java.util.function | [
"returns",
"a",
"value",
"from",
"a",
"lambda",
"(",
"Supplier",
")",
"that",
"can",
"potentially",
"throw",
"an",
"exception",
"."
] | train | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L83-L85 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/os/BundleUtils.java | BundleUtils.optSize | @Nullable
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Size optSize(@Nullable Bundle bundle, @Nullable String key) {
"""
Returns a optional {@link android.util.Size} value. In other words, returns the value mapped by key if it exists and is a {@link android.util.Size}.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns null.
@param bundle a bundle. If the bundle is null, this method will return null.
@param key a key for the value.
@return a {@link android.util.Size} value if exists, null otherwise.
@see android.os.Bundle#getSize(String)
"""
return optSize(bundle, key, null);
} | java | @Nullable
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Size optSize(@Nullable Bundle bundle, @Nullable String key) {
return optSize(bundle, key, null);
} | [
"@",
"Nullable",
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"LOLLIPOP",
")",
"public",
"static",
"Size",
"optSize",
"(",
"@",
"Nullable",
"Bundle",
"bundle",
",",
"@",
"Nullable",
"String",
"key",
")",
"{",
"return",
"optSize",
"(",
"bundle",
",",
"key",
",",
"null",
")",
";",
"}"
] | Returns a optional {@link android.util.Size} value. In other words, returns the value mapped by key if it exists and is a {@link android.util.Size}.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns null.
@param bundle a bundle. If the bundle is null, this method will return null.
@param key a key for the value.
@return a {@link android.util.Size} value if exists, null otherwise.
@see android.os.Bundle#getSize(String) | [
"Returns",
"a",
"optional",
"{"
] | train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/os/BundleUtils.java#L871-L875 |
Baidu-AIP/java-sdk | src/main/java/com/baidu/aip/face/AipFace.java | AipFace.videoFaceliveness | public JSONObject videoFaceliveness(String sessionId, String video, HashMap<String, String> options) {
"""
视频活体检测接口接口
@param sessionId - 语音校验码会话id,使用此接口的前提是已经调用了语音校验码接口
@param video - 本地图片路径
@param options - 可选参数对象,key: value都为string类型
options - options列表:
@return JSONObject
"""
try {
byte[] data = Util.readFileByBytes(video);
return videoFaceliveness(sessionId, data, options);
} catch (IOException e) {
e.printStackTrace();
return AipError.IMAGE_READ_ERROR.toJsonResult();
}
} | java | public JSONObject videoFaceliveness(String sessionId, String video, HashMap<String, String> options) {
try {
byte[] data = Util.readFileByBytes(video);
return videoFaceliveness(sessionId, data, options);
} catch (IOException e) {
e.printStackTrace();
return AipError.IMAGE_READ_ERROR.toJsonResult();
}
} | [
"public",
"JSONObject",
"videoFaceliveness",
"(",
"String",
"sessionId",
",",
"String",
"video",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"options",
")",
"{",
"try",
"{",
"byte",
"[",
"]",
"data",
"=",
"Util",
".",
"readFileByBytes",
"(",
"video",
")",
";",
"return",
"videoFaceliveness",
"(",
"sessionId",
",",
"data",
",",
"options",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"AipError",
".",
"IMAGE_READ_ERROR",
".",
"toJsonResult",
"(",
")",
";",
"}",
"}"
] | 视频活体检测接口接口
@param sessionId - 语音校验码会话id,使用此接口的前提是已经调用了语音校验码接口
@param video - 本地图片路径
@param options - 可选参数对象,key: value都为string类型
options - options列表:
@return JSONObject | [
"视频活体检测接口接口"
] | train | https://github.com/Baidu-AIP/java-sdk/blob/16bb8b7bb8f9bbcb7c8af62d0a67a1e79eecad90/src/main/java/com/baidu/aip/face/AipFace.java#L466-L474 |
orhanobut/dialogplus | dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java | DialogPlus.onAttached | private void onAttached(View view) {
"""
It is called when the show() method is called
@param view is the dialog plus view
"""
decorView.addView(view);
contentContainer.startAnimation(inAnim);
contentContainer.requestFocus();
holder.setOnKeyListener(new View.OnKeyListener() {
@Override public boolean onKey(View v, int keyCode, KeyEvent event) {
switch (event.getAction()) {
case KeyEvent.ACTION_UP:
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (onBackPressListener != null) {
onBackPressListener.onBackPressed(DialogPlus.this);
}
if (isCancelable) {
onBackPressed(DialogPlus.this);
}
return true;
}
break;
default:
break;
}
return false;
}
});
} | java | private void onAttached(View view) {
decorView.addView(view);
contentContainer.startAnimation(inAnim);
contentContainer.requestFocus();
holder.setOnKeyListener(new View.OnKeyListener() {
@Override public boolean onKey(View v, int keyCode, KeyEvent event) {
switch (event.getAction()) {
case KeyEvent.ACTION_UP:
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (onBackPressListener != null) {
onBackPressListener.onBackPressed(DialogPlus.this);
}
if (isCancelable) {
onBackPressed(DialogPlus.this);
}
return true;
}
break;
default:
break;
}
return false;
}
});
} | [
"private",
"void",
"onAttached",
"(",
"View",
"view",
")",
"{",
"decorView",
".",
"addView",
"(",
"view",
")",
";",
"contentContainer",
".",
"startAnimation",
"(",
"inAnim",
")",
";",
"contentContainer",
".",
"requestFocus",
"(",
")",
";",
"holder",
".",
"setOnKeyListener",
"(",
"new",
"View",
".",
"OnKeyListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"onKey",
"(",
"View",
"v",
",",
"int",
"keyCode",
",",
"KeyEvent",
"event",
")",
"{",
"switch",
"(",
"event",
".",
"getAction",
"(",
")",
")",
"{",
"case",
"KeyEvent",
".",
"ACTION_UP",
":",
"if",
"(",
"keyCode",
"==",
"KeyEvent",
".",
"KEYCODE_BACK",
")",
"{",
"if",
"(",
"onBackPressListener",
"!=",
"null",
")",
"{",
"onBackPressListener",
".",
"onBackPressed",
"(",
"DialogPlus",
".",
"this",
")",
";",
"}",
"if",
"(",
"isCancelable",
")",
"{",
"onBackPressed",
"(",
"DialogPlus",
".",
"this",
")",
";",
"}",
"return",
"true",
";",
"}",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"false",
";",
"}",
"}",
")",
";",
"}"
] | It is called when the show() method is called
@param view is the dialog plus view | [
"It",
"is",
"called",
"when",
"the",
"show",
"()",
"method",
"is",
"called"
] | train | https://github.com/orhanobut/dialogplus/blob/291bf4daaa3c81bf5537125f547913beb8ee2c17/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java#L343-L368 |
spring-projects/spring-android | spring-android-core/src/main/java/org/springframework/core/BridgeMethodResolver.java | BridgeMethodResolver.isBridgedCandidateFor | private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) {
"""
Returns {@code true} if the supplied '{@code candidateMethod}' can be
consider a validate candidate for the {@link Method} that is {@link Method#isBridge() bridged}
by the supplied {@link Method bridge Method}. This method performs inexpensive
checks and can be used quickly filter for a set of possible matches.
"""
return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) &&
candidateMethod.getName().equals(bridgeMethod.getName()) &&
candidateMethod.getParameterTypes().length == bridgeMethod.getParameterTypes().length);
} | java | private static boolean isBridgedCandidateFor(Method candidateMethod, Method bridgeMethod) {
return (!candidateMethod.isBridge() && !candidateMethod.equals(bridgeMethod) &&
candidateMethod.getName().equals(bridgeMethod.getName()) &&
candidateMethod.getParameterTypes().length == bridgeMethod.getParameterTypes().length);
} | [
"private",
"static",
"boolean",
"isBridgedCandidateFor",
"(",
"Method",
"candidateMethod",
",",
"Method",
"bridgeMethod",
")",
"{",
"return",
"(",
"!",
"candidateMethod",
".",
"isBridge",
"(",
")",
"&&",
"!",
"candidateMethod",
".",
"equals",
"(",
"bridgeMethod",
")",
"&&",
"candidateMethod",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"bridgeMethod",
".",
"getName",
"(",
")",
")",
"&&",
"candidateMethod",
".",
"getParameterTypes",
"(",
")",
".",
"length",
"==",
"bridgeMethod",
".",
"getParameterTypes",
"(",
")",
".",
"length",
")",
";",
"}"
] | Returns {@code true} if the supplied '{@code candidateMethod}' can be
consider a validate candidate for the {@link Method} that is {@link Method#isBridge() bridged}
by the supplied {@link Method bridge Method}. This method performs inexpensive
checks and can be used quickly filter for a set of possible matches. | [
"Returns",
"{"
] | train | https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-core/src/main/java/org/springframework/core/BridgeMethodResolver.java#L121-L125 |
opengeospatial/teamengine | teamengine-core/src/main/java/com/occamlab/te/util/DocumentationHelper.java | DocumentationHelper.prettyprint | private void prettyprint(String xmlLogsFile, FileOutputStream htmlReportFile)
throws Exception {
"""
Apply xslt stylesheet to xml logs file and crate an HTML report file.
@param xmlLogsFile
@param htmlReportFile
"""
TransformerFactory tFactory = TransformerFactory.newInstance();
// Fortify Mod: prevent external entity injection
tFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// Fortify Mod: prevent external entity injection
factory.setExpandEntityReferences(false);
factory.setNamespaceAware(true);
factory.setXIncludeAware(true);
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse(xmlLogsFile);
Transformer transformer = tFactory.newTransformer(new StreamSource(
xsltFileHandler));
transformer.transform(new DOMSource(document), new StreamResult(
htmlReportFile));
} | java | private void prettyprint(String xmlLogsFile, FileOutputStream htmlReportFile)
throws Exception {
TransformerFactory tFactory = TransformerFactory.newInstance();
// Fortify Mod: prevent external entity injection
tFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// Fortify Mod: prevent external entity injection
factory.setExpandEntityReferences(false);
factory.setNamespaceAware(true);
factory.setXIncludeAware(true);
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse(xmlLogsFile);
Transformer transformer = tFactory.newTransformer(new StreamSource(
xsltFileHandler));
transformer.transform(new DOMSource(document), new StreamResult(
htmlReportFile));
} | [
"private",
"void",
"prettyprint",
"(",
"String",
"xmlLogsFile",
",",
"FileOutputStream",
"htmlReportFile",
")",
"throws",
"Exception",
"{",
"TransformerFactory",
"tFactory",
"=",
"TransformerFactory",
".",
"newInstance",
"(",
")",
";",
"// Fortify Mod: prevent external entity injection",
"tFactory",
".",
"setFeature",
"(",
"XMLConstants",
".",
"FEATURE_SECURE_PROCESSING",
",",
"true",
")",
";",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"// Fortify Mod: prevent external entity injection",
"factory",
".",
"setExpandEntityReferences",
"(",
"false",
")",
";",
"factory",
".",
"setNamespaceAware",
"(",
"true",
")",
";",
"factory",
".",
"setXIncludeAware",
"(",
"true",
")",
";",
"DocumentBuilder",
"parser",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
";",
"Document",
"document",
"=",
"parser",
".",
"parse",
"(",
"xmlLogsFile",
")",
";",
"Transformer",
"transformer",
"=",
"tFactory",
".",
"newTransformer",
"(",
"new",
"StreamSource",
"(",
"xsltFileHandler",
")",
")",
";",
"transformer",
".",
"transform",
"(",
"new",
"DOMSource",
"(",
"document",
")",
",",
"new",
"StreamResult",
"(",
"htmlReportFile",
")",
")",
";",
"}"
] | Apply xslt stylesheet to xml logs file and crate an HTML report file.
@param xmlLogsFile
@param htmlReportFile | [
"Apply",
"xslt",
"stylesheet",
"to",
"xml",
"logs",
"file",
"and",
"crate",
"an",
"HTML",
"report",
"file",
"."
] | train | https://github.com/opengeospatial/teamengine/blob/b6b890214b6784bbe19460bf753bdf28a9514bee/teamengine-core/src/main/java/com/occamlab/te/util/DocumentationHelper.java#L92-L108 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/Parameterized.java | Parameterized.setParameters | protected final void setParameters(Map<String, String> parameters) {
"""
Sets the parameters with name-value pairs from the supplied Map. This is
protected because it is intended to only be called by subclasses where
super(Map m) is not possible to call at the start of the constructor.
Server.java:Server(URL) is an example of this.
@param parameters
The map from which to derive the name-value pairs.
"""
if (parameters == null) {
m_parameters.clear();
}
else {
m_parameters.clear();
Parameter p;
for (String key:parameters.keySet()) {
p = new Parameter(key);
p.setValue(parameters.get(key));
m_parameters.put(key, p);
}
}
} | java | protected final void setParameters(Map<String, String> parameters) {
if (parameters == null) {
m_parameters.clear();
}
else {
m_parameters.clear();
Parameter p;
for (String key:parameters.keySet()) {
p = new Parameter(key);
p.setValue(parameters.get(key));
m_parameters.put(key, p);
}
}
} | [
"protected",
"final",
"void",
"setParameters",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"if",
"(",
"parameters",
"==",
"null",
")",
"{",
"m_parameters",
".",
"clear",
"(",
")",
";",
"}",
"else",
"{",
"m_parameters",
".",
"clear",
"(",
")",
";",
"Parameter",
"p",
";",
"for",
"(",
"String",
"key",
":",
"parameters",
".",
"keySet",
"(",
")",
")",
"{",
"p",
"=",
"new",
"Parameter",
"(",
"key",
")",
";",
"p",
".",
"setValue",
"(",
"parameters",
".",
"get",
"(",
"key",
")",
")",
";",
"m_parameters",
".",
"put",
"(",
"key",
",",
"p",
")",
";",
"}",
"}",
"}"
] | Sets the parameters with name-value pairs from the supplied Map. This is
protected because it is intended to only be called by subclasses where
super(Map m) is not possible to call at the start of the constructor.
Server.java:Server(URL) is an example of this.
@param parameters
The map from which to derive the name-value pairs. | [
"Sets",
"the",
"parameters",
"with",
"name",
"-",
"value",
"pairs",
"from",
"the",
"supplied",
"Map",
".",
"This",
"is",
"protected",
"because",
"it",
"is",
"intended",
"to",
"only",
"be",
"called",
"by",
"subclasses",
"where",
"super",
"(",
"Map",
"m",
")",
"is",
"not",
"possible",
"to",
"call",
"at",
"the",
"start",
"of",
"the",
"constructor",
".",
"Server",
".",
"java",
":",
"Server",
"(",
"URL",
")",
"is",
"an",
"example",
"of",
"this",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/Parameterized.java#L62-L75 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/restrictor/policy/MBeanPolicyConfig.java | MBeanPolicyConfig.addValues | void addValues(ObjectName pOName, Set<String> pReadAttributes, Set<String> pWriteAttributes, Set<String> pOperations) {
"""
Add for a given MBean a set of read/write attributes and operations
@param pOName MBean name (which should not be pattern)
@param pReadAttributes read attributes
@param pWriteAttributes write attributes
@param pOperations operations
"""
readAttributes.put(pOName,pReadAttributes);
writeAttributes.put(pOName,pWriteAttributes);
operations.put(pOName,pOperations);
if (pOName.isPattern()) {
addPattern(pOName);
}
} | java | void addValues(ObjectName pOName, Set<String> pReadAttributes, Set<String> pWriteAttributes, Set<String> pOperations) {
readAttributes.put(pOName,pReadAttributes);
writeAttributes.put(pOName,pWriteAttributes);
operations.put(pOName,pOperations);
if (pOName.isPattern()) {
addPattern(pOName);
}
} | [
"void",
"addValues",
"(",
"ObjectName",
"pOName",
",",
"Set",
"<",
"String",
">",
"pReadAttributes",
",",
"Set",
"<",
"String",
">",
"pWriteAttributes",
",",
"Set",
"<",
"String",
">",
"pOperations",
")",
"{",
"readAttributes",
".",
"put",
"(",
"pOName",
",",
"pReadAttributes",
")",
";",
"writeAttributes",
".",
"put",
"(",
"pOName",
",",
"pWriteAttributes",
")",
";",
"operations",
".",
"put",
"(",
"pOName",
",",
"pOperations",
")",
";",
"if",
"(",
"pOName",
".",
"isPattern",
"(",
")",
")",
"{",
"addPattern",
"(",
"pOName",
")",
";",
"}",
"}"
] | Add for a given MBean a set of read/write attributes and operations
@param pOName MBean name (which should not be pattern)
@param pReadAttributes read attributes
@param pWriteAttributes write attributes
@param pOperations operations | [
"Add",
"for",
"a",
"given",
"MBean",
"a",
"set",
"of",
"read",
"/",
"write",
"attributes",
"and",
"operations"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/restrictor/policy/MBeanPolicyConfig.java#L57-L64 |
cdk/cdk | base/core/src/main/java/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java | CDKAtomTypeMatcher.countAttachedBonds | private int countAttachedBonds(List<IBond> connectedBonds, IAtom atom, IBond.Order order, String symbol) {
"""
Count the number of doubly bonded atoms.
@param connectedBonds bonds connected to the atom
@param atom the atom being looked at
@param order the desired bond order of the attached bonds
@param symbol If not null, then it only counts the double bonded atoms which
match the given symbol.
@return the number of doubly bonded atoms
"""
// count the number of double bonded oxygens
int neighborcount = connectedBonds.size();
int doubleBondedAtoms = 0;
for (int i = neighborcount - 1; i >= 0; i--) {
IBond bond = connectedBonds.get(i);
if (bond.getOrder() == order) {
if (bond.getAtomCount() == 2) {
if (symbol != null) {
// if other atom is of the given element (by its symbol)
if (bond.getOther(atom).getSymbol().equals(symbol)) {
doubleBondedAtoms++;
}
} else {
doubleBondedAtoms++;
}
}
}
}
return doubleBondedAtoms;
} | java | private int countAttachedBonds(List<IBond> connectedBonds, IAtom atom, IBond.Order order, String symbol) {
// count the number of double bonded oxygens
int neighborcount = connectedBonds.size();
int doubleBondedAtoms = 0;
for (int i = neighborcount - 1; i >= 0; i--) {
IBond bond = connectedBonds.get(i);
if (bond.getOrder() == order) {
if (bond.getAtomCount() == 2) {
if (symbol != null) {
// if other atom is of the given element (by its symbol)
if (bond.getOther(atom).getSymbol().equals(symbol)) {
doubleBondedAtoms++;
}
} else {
doubleBondedAtoms++;
}
}
}
}
return doubleBondedAtoms;
} | [
"private",
"int",
"countAttachedBonds",
"(",
"List",
"<",
"IBond",
">",
"connectedBonds",
",",
"IAtom",
"atom",
",",
"IBond",
".",
"Order",
"order",
",",
"String",
"symbol",
")",
"{",
"// count the number of double bonded oxygens",
"int",
"neighborcount",
"=",
"connectedBonds",
".",
"size",
"(",
")",
";",
"int",
"doubleBondedAtoms",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"neighborcount",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"IBond",
"bond",
"=",
"connectedBonds",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"bond",
".",
"getOrder",
"(",
")",
"==",
"order",
")",
"{",
"if",
"(",
"bond",
".",
"getAtomCount",
"(",
")",
"==",
"2",
")",
"{",
"if",
"(",
"symbol",
"!=",
"null",
")",
"{",
"// if other atom is of the given element (by its symbol)",
"if",
"(",
"bond",
".",
"getOther",
"(",
"atom",
")",
".",
"getSymbol",
"(",
")",
".",
"equals",
"(",
"symbol",
")",
")",
"{",
"doubleBondedAtoms",
"++",
";",
"}",
"}",
"else",
"{",
"doubleBondedAtoms",
"++",
";",
"}",
"}",
"}",
"}",
"return",
"doubleBondedAtoms",
";",
"}"
] | Count the number of doubly bonded atoms.
@param connectedBonds bonds connected to the atom
@param atom the atom being looked at
@param order the desired bond order of the attached bonds
@param symbol If not null, then it only counts the double bonded atoms which
match the given symbol.
@return the number of doubly bonded atoms | [
"Count",
"the",
"number",
"of",
"doubly",
"bonded",
"atoms",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/core/src/main/java/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java#L2451-L2471 |
milaboratory/milib | src/main/java/com/milaboratory/core/sequence/SequenceQuality.java | SequenceQuality.create | public static SequenceQuality create(QualityFormat format, byte[] data, int from, int length, boolean check) {
"""
Factory method for the SequenceQualityPhred object. It performs all necessary range checks if required.
@param format format of encoded quality values
@param data byte with encoded quality values
@param from starting position in {@code data}
@param length number of bytes to parse
@param check determines whether range check is required
@return quality line object
@throws WrongQualityFormat if encoded value are out of range and checking is enabled
"""
if (from + length >= data.length || from < 0 || length < 0)
throw new IllegalArgumentException();
//For performance
final byte valueOffset = format.getOffset(),
minValue = format.getMinValue(),
maxValue = format.getMaxValue();
byte[] res = new byte[length];
int pointer = from;
for (int i = 0; i < length; i++) {
res[i] = (byte) (data[pointer++] - valueOffset);
if (check &&
(res[i] < minValue || res[i] > maxValue))
throw new WrongQualityFormat(((char) (data[i])) + " [" + res[i] + "]");
}
return new SequenceQuality(res, true);
} | java | public static SequenceQuality create(QualityFormat format, byte[] data, int from, int length, boolean check) {
if (from + length >= data.length || from < 0 || length < 0)
throw new IllegalArgumentException();
//For performance
final byte valueOffset = format.getOffset(),
minValue = format.getMinValue(),
maxValue = format.getMaxValue();
byte[] res = new byte[length];
int pointer = from;
for (int i = 0; i < length; i++) {
res[i] = (byte) (data[pointer++] - valueOffset);
if (check &&
(res[i] < minValue || res[i] > maxValue))
throw new WrongQualityFormat(((char) (data[i])) + " [" + res[i] + "]");
}
return new SequenceQuality(res, true);
} | [
"public",
"static",
"SequenceQuality",
"create",
"(",
"QualityFormat",
"format",
",",
"byte",
"[",
"]",
"data",
",",
"int",
"from",
",",
"int",
"length",
",",
"boolean",
"check",
")",
"{",
"if",
"(",
"from",
"+",
"length",
">=",
"data",
".",
"length",
"||",
"from",
"<",
"0",
"||",
"length",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"//For performance",
"final",
"byte",
"valueOffset",
"=",
"format",
".",
"getOffset",
"(",
")",
",",
"minValue",
"=",
"format",
".",
"getMinValue",
"(",
")",
",",
"maxValue",
"=",
"format",
".",
"getMaxValue",
"(",
")",
";",
"byte",
"[",
"]",
"res",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"int",
"pointer",
"=",
"from",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"res",
"[",
"i",
"]",
"=",
"(",
"byte",
")",
"(",
"data",
"[",
"pointer",
"++",
"]",
"-",
"valueOffset",
")",
";",
"if",
"(",
"check",
"&&",
"(",
"res",
"[",
"i",
"]",
"<",
"minValue",
"||",
"res",
"[",
"i",
"]",
">",
"maxValue",
")",
")",
"throw",
"new",
"WrongQualityFormat",
"(",
"(",
"(",
"char",
")",
"(",
"data",
"[",
"i",
"]",
")",
")",
"+",
"\" [\"",
"+",
"res",
"[",
"i",
"]",
"+",
"\"]\"",
")",
";",
"}",
"return",
"new",
"SequenceQuality",
"(",
"res",
",",
"true",
")",
";",
"}"
] | Factory method for the SequenceQualityPhred object. It performs all necessary range checks if required.
@param format format of encoded quality values
@param data byte with encoded quality values
@param from starting position in {@code data}
@param length number of bytes to parse
@param check determines whether range check is required
@return quality line object
@throws WrongQualityFormat if encoded value are out of range and checking is enabled | [
"Factory",
"method",
"for",
"the",
"SequenceQualityPhred",
"object",
".",
"It",
"performs",
"all",
"necessary",
"range",
"checks",
"if",
"required",
"."
] | train | https://github.com/milaboratory/milib/blob/2349b3dccdd3c7948643760e570238d6e30d5a34/src/main/java/com/milaboratory/core/sequence/SequenceQuality.java#L348-L365 |
OpenLiberty/open-liberty | dev/com.ibm.ws.clientcontainer/src/com/ibm/ws/clientcontainer/internal/LifecycleCallbackHelper.java | LifecycleCallbackHelper.doPostConstruct | public void doPostConstruct(Object instance, List<LifecycleCallback> postConstructs) throws InjectionException {
"""
Processes the PostConstruct callback method for the login callback handler class
@param instance the instance object of the login callback handler class
@param postConstructs a list of PostConstruct metadata in the application client module
@throws InjectionException
"""
doPostConstruct(instance.getClass(), postConstructs, instance);
} | java | public void doPostConstruct(Object instance, List<LifecycleCallback> postConstructs) throws InjectionException {
doPostConstruct(instance.getClass(), postConstructs, instance);
} | [
"public",
"void",
"doPostConstruct",
"(",
"Object",
"instance",
",",
"List",
"<",
"LifecycleCallback",
">",
"postConstructs",
")",
"throws",
"InjectionException",
"{",
"doPostConstruct",
"(",
"instance",
".",
"getClass",
"(",
")",
",",
"postConstructs",
",",
"instance",
")",
";",
"}"
] | Processes the PostConstruct callback method for the login callback handler class
@param instance the instance object of the login callback handler class
@param postConstructs a list of PostConstruct metadata in the application client module
@throws InjectionException | [
"Processes",
"the",
"PostConstruct",
"callback",
"method",
"for",
"the",
"login",
"callback",
"handler",
"class"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.clientcontainer/src/com/ibm/ws/clientcontainer/internal/LifecycleCallbackHelper.java#L60-L62 |
googlegenomics/utils-java | src/main/java/com/google/cloud/genomics/utils/grpc/ReadStreamIterator.java | ReadStreamIterator.enforceShardBoundary | public static ReadStreamIterator enforceShardBoundary(ManagedChannel channel,
StreamReadsRequest request, Requirement shardBoundary, String fields) {
"""
Create a stream iterator that can enforce shard boundary semantics.
@param channel The ManagedChannel.
@param request The request for the shard of data.
@param shardBoundary The shard boundary semantics to enforce.
@param fields Used to check whether the specified fields would meet the minimum required
fields for the shard boundary predicate, if applicable.
"""
Predicate<Read> shardPredicate =
(ShardBoundary.Requirement.STRICT == shardBoundary) ? ShardBoundary
.getStrictReadPredicate(request.getStart(), fields) : null;
return new ReadStreamIterator(channel, request, shardPredicate);
} | java | public static ReadStreamIterator enforceShardBoundary(ManagedChannel channel,
StreamReadsRequest request, Requirement shardBoundary, String fields) {
Predicate<Read> shardPredicate =
(ShardBoundary.Requirement.STRICT == shardBoundary) ? ShardBoundary
.getStrictReadPredicate(request.getStart(), fields) : null;
return new ReadStreamIterator(channel, request, shardPredicate);
} | [
"public",
"static",
"ReadStreamIterator",
"enforceShardBoundary",
"(",
"ManagedChannel",
"channel",
",",
"StreamReadsRequest",
"request",
",",
"Requirement",
"shardBoundary",
",",
"String",
"fields",
")",
"{",
"Predicate",
"<",
"Read",
">",
"shardPredicate",
"=",
"(",
"ShardBoundary",
".",
"Requirement",
".",
"STRICT",
"==",
"shardBoundary",
")",
"?",
"ShardBoundary",
".",
"getStrictReadPredicate",
"(",
"request",
".",
"getStart",
"(",
")",
",",
"fields",
")",
":",
"null",
";",
"return",
"new",
"ReadStreamIterator",
"(",
"channel",
",",
"request",
",",
"shardPredicate",
")",
";",
"}"
] | Create a stream iterator that can enforce shard boundary semantics.
@param channel The ManagedChannel.
@param request The request for the shard of data.
@param shardBoundary The shard boundary semantics to enforce.
@param fields Used to check whether the specified fields would meet the minimum required
fields for the shard boundary predicate, if applicable. | [
"Create",
"a",
"stream",
"iterator",
"that",
"can",
"enforce",
"shard",
"boundary",
"semantics",
"."
] | train | https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/grpc/ReadStreamIterator.java#L70-L76 |
podio/podio-java | src/main/java/com/podio/tag/TagAPI.java | TagAPI.getTagsOnSpace | public List<TagCount> getTagsOnSpace(int spaceId, int limit, String text) {
"""
Returns the tags on the given space. This includes both items and
statuses. The tags are ordered firstly by the number of uses, secondly by
the tag text.
@param spaceId
The id of the space to return tags from
@param limit
limit on number of tags returned (max 250)
@param text
text of tag to search for
@return The list of tags with their count
"""
MultivaluedMap<String, String> params=new MultivaluedMapImpl();
params.add("limit", new Integer(limit).toString());
if ((text != null) && (!text.isEmpty())) {
params.add("text", text);
}
return getTagsOnSpace(spaceId, params);
} | java | public List<TagCount> getTagsOnSpace(int spaceId, int limit, String text) {
MultivaluedMap<String, String> params=new MultivaluedMapImpl();
params.add("limit", new Integer(limit).toString());
if ((text != null) && (!text.isEmpty())) {
params.add("text", text);
}
return getTagsOnSpace(spaceId, params);
} | [
"public",
"List",
"<",
"TagCount",
">",
"getTagsOnSpace",
"(",
"int",
"spaceId",
",",
"int",
"limit",
",",
"String",
"text",
")",
"{",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"MultivaluedMapImpl",
"(",
")",
";",
"params",
".",
"add",
"(",
"\"limit\"",
",",
"new",
"Integer",
"(",
"limit",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"(",
"text",
"!=",
"null",
")",
"&&",
"(",
"!",
"text",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"params",
".",
"add",
"(",
"\"text\"",
",",
"text",
")",
";",
"}",
"return",
"getTagsOnSpace",
"(",
"spaceId",
",",
"params",
")",
";",
"}"
] | Returns the tags on the given space. This includes both items and
statuses. The tags are ordered firstly by the number of uses, secondly by
the tag text.
@param spaceId
The id of the space to return tags from
@param limit
limit on number of tags returned (max 250)
@param text
text of tag to search for
@return The list of tags with their count | [
"Returns",
"the",
"tags",
"on",
"the",
"given",
"space",
".",
"This",
"includes",
"both",
"items",
"and",
"statuses",
".",
"The",
"tags",
"are",
"ordered",
"firstly",
"by",
"the",
"number",
"of",
"uses",
"secondly",
"by",
"the",
"tag",
"text",
"."
] | train | https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/tag/TagAPI.java#L255-L262 |
albfernandez/itext2 | src/main/java/com/lowagie/text/FontFactory.java | FontFactory.getFont | public static Font getFont(String fontname, String encoding, float size, int style, Color color) {
"""
Constructs a <CODE>Font</CODE>-object.
@param fontname the name of the font
@param encoding the encoding of the font
@param size the size of this font
@param style the style of this font
@param color the <CODE>Color</CODE> of this font.
@return the Font constructed based on the parameters
"""
return getFont(fontname, encoding, defaultEmbedding, size, style, color);
} | java | public static Font getFont(String fontname, String encoding, float size, int style, Color color) {
return getFont(fontname, encoding, defaultEmbedding, size, style, color);
} | [
"public",
"static",
"Font",
"getFont",
"(",
"String",
"fontname",
",",
"String",
"encoding",
",",
"float",
"size",
",",
"int",
"style",
",",
"Color",
"color",
")",
"{",
"return",
"getFont",
"(",
"fontname",
",",
"encoding",
",",
"defaultEmbedding",
",",
"size",
",",
"style",
",",
"color",
")",
";",
"}"
] | Constructs a <CODE>Font</CODE>-object.
@param fontname the name of the font
@param encoding the encoding of the font
@param size the size of this font
@param style the style of this font
@param color the <CODE>Color</CODE> of this font.
@return the Font constructed based on the parameters | [
"Constructs",
"a",
"<CODE",
">",
"Font<",
"/",
"CODE",
">",
"-",
"object",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/FontFactory.java#L225-L227 |
b3log/latke | latke-core/src/main/java/org/b3log/latke/repository/jdbc/util/JdbcUtil.java | JdbcUtil.executeSql | public static boolean executeSql(final String sql, final Connection connection, final boolean isDebug) throws SQLException {
"""
Executes the specified SQL with the specified connection.
@param sql the specified SQL
@param connection connection the specified connection
@param isDebug the specified debug flag
@return {@code true} if success, returns {@false} otherwise
@throws SQLException SQLException
"""
if (isDebug || LOGGER.isTraceEnabled()) {
LOGGER.log(Level.INFO, "Executing SQL [" + sql + "]");
}
final Statement statement = connection.createStatement();
final boolean isSuccess = !statement.execute(sql);
statement.close();
return isSuccess;
} | java | public static boolean executeSql(final String sql, final Connection connection, final boolean isDebug) throws SQLException {
if (isDebug || LOGGER.isTraceEnabled()) {
LOGGER.log(Level.INFO, "Executing SQL [" + sql + "]");
}
final Statement statement = connection.createStatement();
final boolean isSuccess = !statement.execute(sql);
statement.close();
return isSuccess;
} | [
"public",
"static",
"boolean",
"executeSql",
"(",
"final",
"String",
"sql",
",",
"final",
"Connection",
"connection",
",",
"final",
"boolean",
"isDebug",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"isDebug",
"||",
"LOGGER",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Executing SQL [\"",
"+",
"sql",
"+",
"\"]\"",
")",
";",
"}",
"final",
"Statement",
"statement",
"=",
"connection",
".",
"createStatement",
"(",
")",
";",
"final",
"boolean",
"isSuccess",
"=",
"!",
"statement",
".",
"execute",
"(",
"sql",
")",
";",
"statement",
".",
"close",
"(",
")",
";",
"return",
"isSuccess",
";",
"}"
] | Executes the specified SQL with the specified connection.
@param sql the specified SQL
@param connection connection the specified connection
@param isDebug the specified debug flag
@return {@code true} if success, returns {@false} otherwise
@throws SQLException SQLException | [
"Executes",
"the",
"specified",
"SQL",
"with",
"the",
"specified",
"connection",
"."
] | train | https://github.com/b3log/latke/blob/f7e08a47eeecea5f7c94006382c24f353585de33/latke-core/src/main/java/org/b3log/latke/repository/jdbc/util/JdbcUtil.java#L60-L70 |
salesforce/Argus | ArgusCore/src/main/java/com/salesforce/dva/argus/entity/PrincipalUser.java | PrincipalUser.createDefaultUser | private static PrincipalUser createDefaultUser() {
"""
/* Method provided to be called using reflection to discretely create the admin user if needed.
"""
PrincipalUser result = new PrincipalUser("default", "[email protected]");
result.id = BigInteger.valueOf(2);
result.setPrivileged(false);
return result;
} | java | private static PrincipalUser createDefaultUser() {
PrincipalUser result = new PrincipalUser("default", "[email protected]");
result.id = BigInteger.valueOf(2);
result.setPrivileged(false);
return result;
} | [
"private",
"static",
"PrincipalUser",
"createDefaultUser",
"(",
")",
"{",
"PrincipalUser",
"result",
"=",
"new",
"PrincipalUser",
"(",
"\"default\"",
",",
"\"[email protected]\"",
")",
";",
"result",
".",
"id",
"=",
"BigInteger",
".",
"valueOf",
"(",
"2",
")",
";",
"result",
".",
"setPrivileged",
"(",
"false",
")",
";",
"return",
"result",
";",
"}"
] | /* Method provided to be called using reflection to discretely create the admin user if needed. | [
"/",
"*",
"Method",
"provided",
"to",
"be",
"called",
"using",
"reflection",
"to",
"discretely",
"create",
"the",
"admin",
"user",
"if",
"needed",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusCore/src/main/java/com/salesforce/dva/argus/entity/PrincipalUser.java#L281-L287 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJSHome.java | EJSHome.createRemoteBusinessObject | public Object createRemoteBusinessObject(String interfaceName, boolean useSupporting)
throws RemoteException,
CreateException,
ClassNotFoundException,
EJBConfigurationException {
"""
Returns an Object (wrapper) representing the specified EJB 3.0
Business Remote Interface, managed by this home. <p>
This method provides a Business Object (wrapper) factory capability,
for use during business interface injection or lookup. It is
called directly for Stateless Session beans, or through the
basic wrapper for Stateful Session beans. <p>
For Stateless Session beans, a 'singleton' (per home) wrapper instance
is returned, since all Stateless Session beans are interchangeable.
Since no customer code is invoked, no pre or postInvoke calls are
required. <p>
For Stateful Session beans, a new instance of a Stateful Session bean
is created, and the corresponding new wrapper instance is returned.
Since a new instance will be constructed, this method must be wrapped
with pre and postInvoke calls. <p>
@param interfaceName One of the remote business interfaces for this
session bean
@param useSupporting whether or not to try to match the passed in interface
to a known sublcass (ejb-link / beanName situation)
@return The business object (wrapper) corresponding to the given
business interface.
@throws RemoteException
@throws CreateException
@throws ClassNotFoundException
@throws EJBConfigurationException
"""
final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
if (isTraceOn && tc.isEntryEnabled())
Tr.entry(tc, "createRemoteBusinessObject: " + interfaceName); // d367572.7
int interfaceIndex;
if (useSupporting)
{
interfaceIndex = beanMetaData.getSupportingRemoteBusinessInterfaceIndex(interfaceName);
}
else
{
interfaceIndex = beanMetaData.getRemoteBusinessInterfaceIndex(interfaceName);
if (interfaceIndex == -1)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "createRemoteBusinessObject : IllegalStateException : " +
"Requested business interface not found : " +
interfaceName);
throw new IllegalStateException("Requested business interface not found : " + interfaceName);
}
}
Object result = createRemoteBusinessObject(interfaceIndex, null);
if (isTraceOn && tc.isEntryEnabled())
Tr.exit(tc,
"createRemoteBusinessObject returning: " + Util.identity(result)); // d367572.7
return result;
} | java | public Object createRemoteBusinessObject(String interfaceName, boolean useSupporting)
throws RemoteException,
CreateException,
ClassNotFoundException,
EJBConfigurationException
{
final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
if (isTraceOn && tc.isEntryEnabled())
Tr.entry(tc, "createRemoteBusinessObject: " + interfaceName); // d367572.7
int interfaceIndex;
if (useSupporting)
{
interfaceIndex = beanMetaData.getSupportingRemoteBusinessInterfaceIndex(interfaceName);
}
else
{
interfaceIndex = beanMetaData.getRemoteBusinessInterfaceIndex(interfaceName);
if (interfaceIndex == -1)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "createRemoteBusinessObject : IllegalStateException : " +
"Requested business interface not found : " +
interfaceName);
throw new IllegalStateException("Requested business interface not found : " + interfaceName);
}
}
Object result = createRemoteBusinessObject(interfaceIndex, null);
if (isTraceOn && tc.isEntryEnabled())
Tr.exit(tc,
"createRemoteBusinessObject returning: " + Util.identity(result)); // d367572.7
return result;
} | [
"public",
"Object",
"createRemoteBusinessObject",
"(",
"String",
"interfaceName",
",",
"boolean",
"useSupporting",
")",
"throws",
"RemoteException",
",",
"CreateException",
",",
"ClassNotFoundException",
",",
"EJBConfigurationException",
"{",
"final",
"boolean",
"isTraceOn",
"=",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
";",
"if",
"(",
"isTraceOn",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"createRemoteBusinessObject: \"",
"+",
"interfaceName",
")",
";",
"// d367572.7",
"int",
"interfaceIndex",
";",
"if",
"(",
"useSupporting",
")",
"{",
"interfaceIndex",
"=",
"beanMetaData",
".",
"getSupportingRemoteBusinessInterfaceIndex",
"(",
"interfaceName",
")",
";",
"}",
"else",
"{",
"interfaceIndex",
"=",
"beanMetaData",
".",
"getRemoteBusinessInterfaceIndex",
"(",
"interfaceName",
")",
";",
"if",
"(",
"interfaceIndex",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"createRemoteBusinessObject : IllegalStateException : \"",
"+",
"\"Requested business interface not found : \"",
"+",
"interfaceName",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"\"Requested business interface not found : \"",
"+",
"interfaceName",
")",
";",
"}",
"}",
"Object",
"result",
"=",
"createRemoteBusinessObject",
"(",
"interfaceIndex",
",",
"null",
")",
";",
"if",
"(",
"isTraceOn",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"exit",
"(",
"tc",
",",
"\"createRemoteBusinessObject returning: \"",
"+",
"Util",
".",
"identity",
"(",
"result",
")",
")",
";",
"// d367572.7",
"return",
"result",
";",
"}"
] | Returns an Object (wrapper) representing the specified EJB 3.0
Business Remote Interface, managed by this home. <p>
This method provides a Business Object (wrapper) factory capability,
for use during business interface injection or lookup. It is
called directly for Stateless Session beans, or through the
basic wrapper for Stateful Session beans. <p>
For Stateless Session beans, a 'singleton' (per home) wrapper instance
is returned, since all Stateless Session beans are interchangeable.
Since no customer code is invoked, no pre or postInvoke calls are
required. <p>
For Stateful Session beans, a new instance of a Stateful Session bean
is created, and the corresponding new wrapper instance is returned.
Since a new instance will be constructed, this method must be wrapped
with pre and postInvoke calls. <p>
@param interfaceName One of the remote business interfaces for this
session bean
@param useSupporting whether or not to try to match the passed in interface
to a known sublcass (ejb-link / beanName situation)
@return The business object (wrapper) corresponding to the given
business interface.
@throws RemoteException
@throws CreateException
@throws ClassNotFoundException
@throws EJBConfigurationException | [
"Returns",
"an",
"Object",
"(",
"wrapper",
")",
"representing",
"the",
"specified",
"EJB",
"3",
".",
"0",
"Business",
"Remote",
"Interface",
"managed",
"by",
"this",
"home",
".",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJSHome.java#L1611-L1650 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/tools/io/ListFiles.java | ListFiles.listFiles | public void listFiles(File directory, String indent) {
"""
Lists the contents of the given {@link File directory} displayed from the given {@link String indent}.
@param directory {@link File} referring to the directory for which the contents will be listed.
@param indent {@link String} containing the characters of the indent in which to begin the view
of the directory hierarchy/tree.
@throws IllegalArgumentException if the given {@link File} is not a valid directory.
@see #validateDirectory(File)
@see java.io.File
"""
directory = validateDirectory(directory);
indent = Optional.ofNullable(indent).filter(StringUtils::hasText).orElse(StringUtils.EMPTY_STRING);
printDirectoryName(indent, directory);
String directoryContentIndent = buildDirectoryContentIndent(indent);
stream(sort(nullSafeArray(directory.listFiles(), File.class))).forEach(file -> {
if (FileSystemUtils.isDirectory(file)) {
listFiles(file, directoryContentIndent);
}
else {
printFileName(directoryContentIndent, file);
}
});
} | java | public void listFiles(File directory, String indent) {
directory = validateDirectory(directory);
indent = Optional.ofNullable(indent).filter(StringUtils::hasText).orElse(StringUtils.EMPTY_STRING);
printDirectoryName(indent, directory);
String directoryContentIndent = buildDirectoryContentIndent(indent);
stream(sort(nullSafeArray(directory.listFiles(), File.class))).forEach(file -> {
if (FileSystemUtils.isDirectory(file)) {
listFiles(file, directoryContentIndent);
}
else {
printFileName(directoryContentIndent, file);
}
});
} | [
"public",
"void",
"listFiles",
"(",
"File",
"directory",
",",
"String",
"indent",
")",
"{",
"directory",
"=",
"validateDirectory",
"(",
"directory",
")",
";",
"indent",
"=",
"Optional",
".",
"ofNullable",
"(",
"indent",
")",
".",
"filter",
"(",
"StringUtils",
"::",
"hasText",
")",
".",
"orElse",
"(",
"StringUtils",
".",
"EMPTY_STRING",
")",
";",
"printDirectoryName",
"(",
"indent",
",",
"directory",
")",
";",
"String",
"directoryContentIndent",
"=",
"buildDirectoryContentIndent",
"(",
"indent",
")",
";",
"stream",
"(",
"sort",
"(",
"nullSafeArray",
"(",
"directory",
".",
"listFiles",
"(",
")",
",",
"File",
".",
"class",
")",
")",
")",
".",
"forEach",
"(",
"file",
"->",
"{",
"if",
"(",
"FileSystemUtils",
".",
"isDirectory",
"(",
"file",
")",
")",
"{",
"listFiles",
"(",
"file",
",",
"directoryContentIndent",
")",
";",
"}",
"else",
"{",
"printFileName",
"(",
"directoryContentIndent",
",",
"file",
")",
";",
"}",
"}",
")",
";",
"}"
] | Lists the contents of the given {@link File directory} displayed from the given {@link String indent}.
@param directory {@link File} referring to the directory for which the contents will be listed.
@param indent {@link String} containing the characters of the indent in which to begin the view
of the directory hierarchy/tree.
@throws IllegalArgumentException if the given {@link File} is not a valid directory.
@see #validateDirectory(File)
@see java.io.File | [
"Lists",
"the",
"contents",
"of",
"the",
"given",
"{",
"@link",
"File",
"directory",
"}",
"displayed",
"from",
"the",
"given",
"{",
"@link",
"String",
"indent",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/tools/io/ListFiles.java#L158-L175 |
cryptomator/cryptolib | src/main/java/org/cryptomator/cryptolib/Cryptors.java | Cryptors.ciphertextSize | public static long ciphertextSize(long cleartextSize, Cryptor cryptor) {
"""
Calculates the size of the ciphertext resulting from the given cleartext encrypted with the given cryptor.
@param cleartextSize Length of a unencrypted payload.
@param cryptor The cryptor which defines the cleartext/ciphertext ratio
@return Ciphertext length of a <code>cleartextSize</code>-sized cleartext encrypted with <code>cryptor</code>.
Not including the {@link FileHeader#getFilesize() length of the header}.
"""
checkArgument(cleartextSize >= 0, "expected cleartextSize to be positive, but was %s", cleartextSize);
long cleartextChunkSize = cryptor.fileContentCryptor().cleartextChunkSize();
long ciphertextChunkSize = cryptor.fileContentCryptor().ciphertextChunkSize();
long overheadPerChunk = ciphertextChunkSize - cleartextChunkSize;
long numFullChunks = cleartextSize / cleartextChunkSize; // floor by int-truncation
long additionalCleartextBytes = cleartextSize % cleartextChunkSize;
long additionalCiphertextBytes = (additionalCleartextBytes == 0) ? 0 : additionalCleartextBytes + overheadPerChunk;
assert additionalCiphertextBytes >= 0;
return ciphertextChunkSize * numFullChunks + additionalCiphertextBytes;
} | java | public static long ciphertextSize(long cleartextSize, Cryptor cryptor) {
checkArgument(cleartextSize >= 0, "expected cleartextSize to be positive, but was %s", cleartextSize);
long cleartextChunkSize = cryptor.fileContentCryptor().cleartextChunkSize();
long ciphertextChunkSize = cryptor.fileContentCryptor().ciphertextChunkSize();
long overheadPerChunk = ciphertextChunkSize - cleartextChunkSize;
long numFullChunks = cleartextSize / cleartextChunkSize; // floor by int-truncation
long additionalCleartextBytes = cleartextSize % cleartextChunkSize;
long additionalCiphertextBytes = (additionalCleartextBytes == 0) ? 0 : additionalCleartextBytes + overheadPerChunk;
assert additionalCiphertextBytes >= 0;
return ciphertextChunkSize * numFullChunks + additionalCiphertextBytes;
} | [
"public",
"static",
"long",
"ciphertextSize",
"(",
"long",
"cleartextSize",
",",
"Cryptor",
"cryptor",
")",
"{",
"checkArgument",
"(",
"cleartextSize",
">=",
"0",
",",
"\"expected cleartextSize to be positive, but was %s\"",
",",
"cleartextSize",
")",
";",
"long",
"cleartextChunkSize",
"=",
"cryptor",
".",
"fileContentCryptor",
"(",
")",
".",
"cleartextChunkSize",
"(",
")",
";",
"long",
"ciphertextChunkSize",
"=",
"cryptor",
".",
"fileContentCryptor",
"(",
")",
".",
"ciphertextChunkSize",
"(",
")",
";",
"long",
"overheadPerChunk",
"=",
"ciphertextChunkSize",
"-",
"cleartextChunkSize",
";",
"long",
"numFullChunks",
"=",
"cleartextSize",
"/",
"cleartextChunkSize",
";",
"// floor by int-truncation",
"long",
"additionalCleartextBytes",
"=",
"cleartextSize",
"%",
"cleartextChunkSize",
";",
"long",
"additionalCiphertextBytes",
"=",
"(",
"additionalCleartextBytes",
"==",
"0",
")",
"?",
"0",
":",
"additionalCleartextBytes",
"+",
"overheadPerChunk",
";",
"assert",
"additionalCiphertextBytes",
">=",
"0",
";",
"return",
"ciphertextChunkSize",
"*",
"numFullChunks",
"+",
"additionalCiphertextBytes",
";",
"}"
] | Calculates the size of the ciphertext resulting from the given cleartext encrypted with the given cryptor.
@param cleartextSize Length of a unencrypted payload.
@param cryptor The cryptor which defines the cleartext/ciphertext ratio
@return Ciphertext length of a <code>cleartextSize</code>-sized cleartext encrypted with <code>cryptor</code>.
Not including the {@link FileHeader#getFilesize() length of the header}. | [
"Calculates",
"the",
"size",
"of",
"the",
"ciphertext",
"resulting",
"from",
"the",
"given",
"cleartext",
"encrypted",
"with",
"the",
"given",
"cryptor",
"."
] | train | https://github.com/cryptomator/cryptolib/blob/33bc881f6ee7d4924043ea6309efd2c063ec3638/src/main/java/org/cryptomator/cryptolib/Cryptors.java#L65-L75 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java | ApiOvhEmaildomain.domain_redirection_POST | public OvhTaskSpecialAccount domain_redirection_POST(String domain, String from, Boolean localCopy, String to) throws IOException {
"""
Create new redirection in server
REST: POST /email/domain/{domain}/redirection
@param from [required] Name of redirection
@param localCopy [required] If true keep a local copy
@param to [required] Target of account
@param domain [required] Name of your domain name
"""
String qPath = "/email/domain/{domain}/redirection";
StringBuilder sb = path(qPath, domain);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "from", from);
addBody(o, "localCopy", localCopy);
addBody(o, "to", to);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTaskSpecialAccount.class);
} | java | public OvhTaskSpecialAccount domain_redirection_POST(String domain, String from, Boolean localCopy, String to) throws IOException {
String qPath = "/email/domain/{domain}/redirection";
StringBuilder sb = path(qPath, domain);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "from", from);
addBody(o, "localCopy", localCopy);
addBody(o, "to", to);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTaskSpecialAccount.class);
} | [
"public",
"OvhTaskSpecialAccount",
"domain_redirection_POST",
"(",
"String",
"domain",
",",
"String",
"from",
",",
"Boolean",
"localCopy",
",",
"String",
"to",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/domain/{domain}/redirection\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"domain",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"from\"",
",",
"from",
")",
";",
"addBody",
"(",
"o",
",",
"\"localCopy\"",
",",
"localCopy",
")",
";",
"addBody",
"(",
"o",
",",
"\"to\"",
",",
"to",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTaskSpecialAccount",
".",
"class",
")",
";",
"}"
] | Create new redirection in server
REST: POST /email/domain/{domain}/redirection
@param from [required] Name of redirection
@param localCopy [required] If true keep a local copy
@param to [required] Target of account
@param domain [required] Name of your domain name | [
"Create",
"new",
"redirection",
"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#L1071-L1080 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java | ParseUtils.missingRequired | public static XMLStreamException missingRequired(final XMLExtendedStreamReader reader, final Set<?> required) {
"""
Get an exception reporting a missing, required XML attribute.
@param reader the stream reader
@param required a set of enums whose toString method returns the
attribute name
@return the exception
"""
Set<String> set = new HashSet<>();
for (Object o : required) {
String toString = o.toString();
set.add(toString);
}
return wrapMissingRequiredAttribute(ControllerLogger.ROOT_LOGGER.missingRequiredAttributes(asStringList(required),
reader.getLocation()),
reader,
set);
} | java | public static XMLStreamException missingRequired(final XMLExtendedStreamReader reader, final Set<?> required) {
Set<String> set = new HashSet<>();
for (Object o : required) {
String toString = o.toString();
set.add(toString);
}
return wrapMissingRequiredAttribute(ControllerLogger.ROOT_LOGGER.missingRequiredAttributes(asStringList(required),
reader.getLocation()),
reader,
set);
} | [
"public",
"static",
"XMLStreamException",
"missingRequired",
"(",
"final",
"XMLExtendedStreamReader",
"reader",
",",
"final",
"Set",
"<",
"?",
">",
"required",
")",
"{",
"Set",
"<",
"String",
">",
"set",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"Object",
"o",
":",
"required",
")",
"{",
"String",
"toString",
"=",
"o",
".",
"toString",
"(",
")",
";",
"set",
".",
"add",
"(",
"toString",
")",
";",
"}",
"return",
"wrapMissingRequiredAttribute",
"(",
"ControllerLogger",
".",
"ROOT_LOGGER",
".",
"missingRequiredAttributes",
"(",
"asStringList",
"(",
"required",
")",
",",
"reader",
".",
"getLocation",
"(",
")",
")",
",",
"reader",
",",
"set",
")",
";",
"}"
] | Get an exception reporting a missing, required XML attribute.
@param reader the stream reader
@param required a set of enums whose toString method returns the
attribute name
@return the exception | [
"Get",
"an",
"exception",
"reporting",
"a",
"missing",
"required",
"XML",
"attribute",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java#L206-L216 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java | PackageSummaryBuilder.buildErrorSummary | public void buildErrorSummary(XMLNode node, Content summaryContentTree) {
"""
Build the summary for the errors in this package.
@param node the XML element that specifies which components to document
@param summaryContentTree the summary tree to which the error summary will
be added
"""
String errorTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Error_Summary"),
configuration.getText("doclet.errors"));
String[] errorTableHeader = new String[] {
configuration.getText("doclet.Error"),
configuration.getText("doclet.Description")
};
ClassDoc[] errors =
packageDoc.isIncluded()
? packageDoc.errors()
: configuration.classDocCatalog.errors(
Util.getPackageName(packageDoc));
errors = Util.filterOutPrivateClasses(errors, configuration.javafx);
if (errors.length > 0) {
packageWriter.addClassesSummary(
errors,
configuration.getText("doclet.Error_Summary"),
errorTableSummary, errorTableHeader, summaryContentTree);
}
} | java | public void buildErrorSummary(XMLNode node, Content summaryContentTree) {
String errorTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Error_Summary"),
configuration.getText("doclet.errors"));
String[] errorTableHeader = new String[] {
configuration.getText("doclet.Error"),
configuration.getText("doclet.Description")
};
ClassDoc[] errors =
packageDoc.isIncluded()
? packageDoc.errors()
: configuration.classDocCatalog.errors(
Util.getPackageName(packageDoc));
errors = Util.filterOutPrivateClasses(errors, configuration.javafx);
if (errors.length > 0) {
packageWriter.addClassesSummary(
errors,
configuration.getText("doclet.Error_Summary"),
errorTableSummary, errorTableHeader, summaryContentTree);
}
} | [
"public",
"void",
"buildErrorSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"summaryContentTree",
")",
"{",
"String",
"errorTableSummary",
"=",
"configuration",
".",
"getText",
"(",
"\"doclet.Member_Table_Summary\"",
",",
"configuration",
".",
"getText",
"(",
"\"doclet.Error_Summary\"",
")",
",",
"configuration",
".",
"getText",
"(",
"\"doclet.errors\"",
")",
")",
";",
"String",
"[",
"]",
"errorTableHeader",
"=",
"new",
"String",
"[",
"]",
"{",
"configuration",
".",
"getText",
"(",
"\"doclet.Error\"",
")",
",",
"configuration",
".",
"getText",
"(",
"\"doclet.Description\"",
")",
"}",
";",
"ClassDoc",
"[",
"]",
"errors",
"=",
"packageDoc",
".",
"isIncluded",
"(",
")",
"?",
"packageDoc",
".",
"errors",
"(",
")",
":",
"configuration",
".",
"classDocCatalog",
".",
"errors",
"(",
"Util",
".",
"getPackageName",
"(",
"packageDoc",
")",
")",
";",
"errors",
"=",
"Util",
".",
"filterOutPrivateClasses",
"(",
"errors",
",",
"configuration",
".",
"javafx",
")",
";",
"if",
"(",
"errors",
".",
"length",
">",
"0",
")",
"{",
"packageWriter",
".",
"addClassesSummary",
"(",
"errors",
",",
"configuration",
".",
"getText",
"(",
"\"doclet.Error_Summary\"",
")",
",",
"errorTableSummary",
",",
"errorTableHeader",
",",
"summaryContentTree",
")",
";",
"}",
"}"
] | Build the summary for the errors in this package.
@param node the XML element that specifies which components to document
@param summaryContentTree the summary tree to which the error summary will
be added | [
"Build",
"the",
"summary",
"for",
"the",
"errors",
"in",
"this",
"package",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java#L284-L305 |
apache/incubator-shardingsphere | sharding-proxy/sharding-proxy-frontend/sharding-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/shardingproxy/frontend/mysql/command/MySQLCommandExecutorFactory.java | MySQLCommandExecutorFactory.newInstance | public static CommandExecutor newInstance(final MySQLCommandPacketType commandPacketType, final CommandPacket commandPacket, final BackendConnection backendConnection) {
"""
Create new instance of packet executor.
@param commandPacketType command packet type for MySQL
@param commandPacket command packet for MySQL
@param backendConnection backend connection
@return command executor
"""
log.debug("Execute packet type: {}, value: {}", commandPacketType, commandPacket);
switch (commandPacketType) {
case COM_QUIT:
return new MySQLComQuitExecutor();
case COM_INIT_DB:
return new MySQLComInitDbExecutor((MySQLComInitDbPacket) commandPacket, backendConnection);
case COM_FIELD_LIST:
return new MySQLComFieldListPacketExecutor((MySQLComFieldListPacket) commandPacket, backendConnection);
case COM_QUERY:
return new MySQLComQueryPacketExecutor((MySQLComQueryPacket) commandPacket, backendConnection);
case COM_STMT_PREPARE:
return new MySQLComStmtPrepareExecutor((MySQLComStmtPreparePacket) commandPacket, backendConnection);
case COM_STMT_EXECUTE:
return new MySQLComStmtExecuteExecutor((MySQLComStmtExecutePacket) commandPacket, backendConnection);
case COM_STMT_CLOSE:
return new MySQLComStmtCloseExecutor((MySQLComStmtClosePacket) commandPacket);
case COM_PING:
return new MySQLComPingExecutor();
default:
return new MySQLUnsupportedCommandExecutor(commandPacketType);
}
} | java | public static CommandExecutor newInstance(final MySQLCommandPacketType commandPacketType, final CommandPacket commandPacket, final BackendConnection backendConnection) {
log.debug("Execute packet type: {}, value: {}", commandPacketType, commandPacket);
switch (commandPacketType) {
case COM_QUIT:
return new MySQLComQuitExecutor();
case COM_INIT_DB:
return new MySQLComInitDbExecutor((MySQLComInitDbPacket) commandPacket, backendConnection);
case COM_FIELD_LIST:
return new MySQLComFieldListPacketExecutor((MySQLComFieldListPacket) commandPacket, backendConnection);
case COM_QUERY:
return new MySQLComQueryPacketExecutor((MySQLComQueryPacket) commandPacket, backendConnection);
case COM_STMT_PREPARE:
return new MySQLComStmtPrepareExecutor((MySQLComStmtPreparePacket) commandPacket, backendConnection);
case COM_STMT_EXECUTE:
return new MySQLComStmtExecuteExecutor((MySQLComStmtExecutePacket) commandPacket, backendConnection);
case COM_STMT_CLOSE:
return new MySQLComStmtCloseExecutor((MySQLComStmtClosePacket) commandPacket);
case COM_PING:
return new MySQLComPingExecutor();
default:
return new MySQLUnsupportedCommandExecutor(commandPacketType);
}
} | [
"public",
"static",
"CommandExecutor",
"newInstance",
"(",
"final",
"MySQLCommandPacketType",
"commandPacketType",
",",
"final",
"CommandPacket",
"commandPacket",
",",
"final",
"BackendConnection",
"backendConnection",
")",
"{",
"log",
".",
"debug",
"(",
"\"Execute packet type: {}, value: {}\"",
",",
"commandPacketType",
",",
"commandPacket",
")",
";",
"switch",
"(",
"commandPacketType",
")",
"{",
"case",
"COM_QUIT",
":",
"return",
"new",
"MySQLComQuitExecutor",
"(",
")",
";",
"case",
"COM_INIT_DB",
":",
"return",
"new",
"MySQLComInitDbExecutor",
"(",
"(",
"MySQLComInitDbPacket",
")",
"commandPacket",
",",
"backendConnection",
")",
";",
"case",
"COM_FIELD_LIST",
":",
"return",
"new",
"MySQLComFieldListPacketExecutor",
"(",
"(",
"MySQLComFieldListPacket",
")",
"commandPacket",
",",
"backendConnection",
")",
";",
"case",
"COM_QUERY",
":",
"return",
"new",
"MySQLComQueryPacketExecutor",
"(",
"(",
"MySQLComQueryPacket",
")",
"commandPacket",
",",
"backendConnection",
")",
";",
"case",
"COM_STMT_PREPARE",
":",
"return",
"new",
"MySQLComStmtPrepareExecutor",
"(",
"(",
"MySQLComStmtPreparePacket",
")",
"commandPacket",
",",
"backendConnection",
")",
";",
"case",
"COM_STMT_EXECUTE",
":",
"return",
"new",
"MySQLComStmtExecuteExecutor",
"(",
"(",
"MySQLComStmtExecutePacket",
")",
"commandPacket",
",",
"backendConnection",
")",
";",
"case",
"COM_STMT_CLOSE",
":",
"return",
"new",
"MySQLComStmtCloseExecutor",
"(",
"(",
"MySQLComStmtClosePacket",
")",
"commandPacket",
")",
";",
"case",
"COM_PING",
":",
"return",
"new",
"MySQLComPingExecutor",
"(",
")",
";",
"default",
":",
"return",
"new",
"MySQLUnsupportedCommandExecutor",
"(",
"commandPacketType",
")",
";",
"}",
"}"
] | Create new instance of packet executor.
@param commandPacketType command packet type for MySQL
@param commandPacket command packet for MySQL
@param backendConnection backend connection
@return command executor | [
"Create",
"new",
"instance",
"of",
"packet",
"executor",
"."
] | train | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-proxy/sharding-proxy-frontend/sharding-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/shardingproxy/frontend/mysql/command/MySQLCommandExecutorFactory.java#L60-L82 |
aws/aws-sdk-java | aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/GetIntegrationResponseResult.java | GetIntegrationResponseResult.withResponseTemplates | public GetIntegrationResponseResult withResponseTemplates(java.util.Map<String, String> responseTemplates) {
"""
<p>
The collection of response templates for the integration response as a string-to-string map of key-value pairs.
Response templates are represented as a key/value map, with a content-type as the key and a template as the
value.
</p>
@param responseTemplates
The collection of response templates for the integration response as a string-to-string map of key-value
pairs. Response templates are represented as a key/value map, with a content-type as the key and a
template as the value.
@return Returns a reference to this object so that method calls can be chained together.
"""
setResponseTemplates(responseTemplates);
return this;
} | java | public GetIntegrationResponseResult withResponseTemplates(java.util.Map<String, String> responseTemplates) {
setResponseTemplates(responseTemplates);
return this;
} | [
"public",
"GetIntegrationResponseResult",
"withResponseTemplates",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"responseTemplates",
")",
"{",
"setResponseTemplates",
"(",
"responseTemplates",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The collection of response templates for the integration response as a string-to-string map of key-value pairs.
Response templates are represented as a key/value map, with a content-type as the key and a template as the
value.
</p>
@param responseTemplates
The collection of response templates for the integration response as a string-to-string map of key-value
pairs. Response templates are represented as a key/value map, with a content-type as the key and a
template as the value.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"collection",
"of",
"response",
"templates",
"for",
"the",
"integration",
"response",
"as",
"a",
"string",
"-",
"to",
"-",
"string",
"map",
"of",
"key",
"-",
"value",
"pairs",
".",
"Response",
"templates",
"are",
"represented",
"as",
"a",
"key",
"/",
"value",
"map",
"with",
"a",
"content",
"-",
"type",
"as",
"the",
"key",
"and",
"a",
"template",
"as",
"the",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/GetIntegrationResponseResult.java#L448-L451 |
johncarl81/transfuse | transfuse/src/main/java/org/androidtransfuse/analysis/module/ModuleTransactionWorker.java | ModuleTransactionWorker.createConfigurationsForModuleType | private void createConfigurationsForModuleType(ImmutableList.Builder<ModuleConfiguration> configurations, ASTType module, ASTType scanTarget, Set<MethodSignature> scanned, Map<String, Set<MethodSignature>> packagePrivateScanned) {
"""
Recursive method that finds module methods and annotations on all parents of moduleAncestor and moduleAncestor, but creates configuration based on the module.
This allows any class in the module hierarchy to contribute annotations or providers that can be overridden by subclasses.
@param configurations the holder for annotation and method configurations
@param module the module type we are configuring
"""
configureModuleAnnotations(configurations, module, scanTarget, scanTarget.getAnnotations());
configureModuleMethods(configurations, module, scanTarget, scanTarget.getMethods(), scanned, packagePrivateScanned);
// Add scanned methods to allow for method overriding.
for (ASTMethod astMethod : scanTarget.getMethods()) {
MethodSignature signature = new MethodSignature(astMethod);
if(astMethod.getAccessModifier() == ASTAccessModifier.PUBLIC || astMethod.getAccessModifier() == ASTAccessModifier.PROTECTED){
scanned.add(signature);
}
else if(astMethod.getAccessModifier() == ASTAccessModifier.PACKAGE_PRIVATE){
if(!packagePrivateScanned.containsKey(scanTarget.getPackageClass().getPackage())){
packagePrivateScanned.put(scanTarget.getPackageClass().getPackage(), new HashSet<MethodSignature>());
}
packagePrivateScanned.get(scanTarget.getPackageClass().getPackage()).add(signature);
}
}
// if super type is null, we are at the top of the inheritance hierarchy and we can unwind.
if(scanTarget.getSuperClass() != null) {
// recurse our way up the tree so we add the top most providers first and clobber them on the way down
createConfigurationsForModuleType(configurations, module, scanTarget.getSuperClass(), scanned, packagePrivateScanned);
}
} | java | private void createConfigurationsForModuleType(ImmutableList.Builder<ModuleConfiguration> configurations, ASTType module, ASTType scanTarget, Set<MethodSignature> scanned, Map<String, Set<MethodSignature>> packagePrivateScanned) {
configureModuleAnnotations(configurations, module, scanTarget, scanTarget.getAnnotations());
configureModuleMethods(configurations, module, scanTarget, scanTarget.getMethods(), scanned, packagePrivateScanned);
// Add scanned methods to allow for method overriding.
for (ASTMethod astMethod : scanTarget.getMethods()) {
MethodSignature signature = new MethodSignature(astMethod);
if(astMethod.getAccessModifier() == ASTAccessModifier.PUBLIC || astMethod.getAccessModifier() == ASTAccessModifier.PROTECTED){
scanned.add(signature);
}
else if(astMethod.getAccessModifier() == ASTAccessModifier.PACKAGE_PRIVATE){
if(!packagePrivateScanned.containsKey(scanTarget.getPackageClass().getPackage())){
packagePrivateScanned.put(scanTarget.getPackageClass().getPackage(), new HashSet<MethodSignature>());
}
packagePrivateScanned.get(scanTarget.getPackageClass().getPackage()).add(signature);
}
}
// if super type is null, we are at the top of the inheritance hierarchy and we can unwind.
if(scanTarget.getSuperClass() != null) {
// recurse our way up the tree so we add the top most providers first and clobber them on the way down
createConfigurationsForModuleType(configurations, module, scanTarget.getSuperClass(), scanned, packagePrivateScanned);
}
} | [
"private",
"void",
"createConfigurationsForModuleType",
"(",
"ImmutableList",
".",
"Builder",
"<",
"ModuleConfiguration",
">",
"configurations",
",",
"ASTType",
"module",
",",
"ASTType",
"scanTarget",
",",
"Set",
"<",
"MethodSignature",
">",
"scanned",
",",
"Map",
"<",
"String",
",",
"Set",
"<",
"MethodSignature",
">",
">",
"packagePrivateScanned",
")",
"{",
"configureModuleAnnotations",
"(",
"configurations",
",",
"module",
",",
"scanTarget",
",",
"scanTarget",
".",
"getAnnotations",
"(",
")",
")",
";",
"configureModuleMethods",
"(",
"configurations",
",",
"module",
",",
"scanTarget",
",",
"scanTarget",
".",
"getMethods",
"(",
")",
",",
"scanned",
",",
"packagePrivateScanned",
")",
";",
"// Add scanned methods to allow for method overriding.",
"for",
"(",
"ASTMethod",
"astMethod",
":",
"scanTarget",
".",
"getMethods",
"(",
")",
")",
"{",
"MethodSignature",
"signature",
"=",
"new",
"MethodSignature",
"(",
"astMethod",
")",
";",
"if",
"(",
"astMethod",
".",
"getAccessModifier",
"(",
")",
"==",
"ASTAccessModifier",
".",
"PUBLIC",
"||",
"astMethod",
".",
"getAccessModifier",
"(",
")",
"==",
"ASTAccessModifier",
".",
"PROTECTED",
")",
"{",
"scanned",
".",
"add",
"(",
"signature",
")",
";",
"}",
"else",
"if",
"(",
"astMethod",
".",
"getAccessModifier",
"(",
")",
"==",
"ASTAccessModifier",
".",
"PACKAGE_PRIVATE",
")",
"{",
"if",
"(",
"!",
"packagePrivateScanned",
".",
"containsKey",
"(",
"scanTarget",
".",
"getPackageClass",
"(",
")",
".",
"getPackage",
"(",
")",
")",
")",
"{",
"packagePrivateScanned",
".",
"put",
"(",
"scanTarget",
".",
"getPackageClass",
"(",
")",
".",
"getPackage",
"(",
")",
",",
"new",
"HashSet",
"<",
"MethodSignature",
">",
"(",
")",
")",
";",
"}",
"packagePrivateScanned",
".",
"get",
"(",
"scanTarget",
".",
"getPackageClass",
"(",
")",
".",
"getPackage",
"(",
")",
")",
".",
"add",
"(",
"signature",
")",
";",
"}",
"}",
"// if super type is null, we are at the top of the inheritance hierarchy and we can unwind.",
"if",
"(",
"scanTarget",
".",
"getSuperClass",
"(",
")",
"!=",
"null",
")",
"{",
"// recurse our way up the tree so we add the top most providers first and clobber them on the way down",
"createConfigurationsForModuleType",
"(",
"configurations",
",",
"module",
",",
"scanTarget",
".",
"getSuperClass",
"(",
")",
",",
"scanned",
",",
"packagePrivateScanned",
")",
";",
"}",
"}"
] | Recursive method that finds module methods and annotations on all parents of moduleAncestor and moduleAncestor, but creates configuration based on the module.
This allows any class in the module hierarchy to contribute annotations or providers that can be overridden by subclasses.
@param configurations the holder for annotation and method configurations
@param module the module type we are configuring | [
"Recursive",
"method",
"that",
"finds",
"module",
"methods",
"and",
"annotations",
"on",
"all",
"parents",
"of",
"moduleAncestor",
"and",
"moduleAncestor",
"but",
"creates",
"configuration",
"based",
"on",
"the",
"module",
".",
"This",
"allows",
"any",
"class",
"in",
"the",
"module",
"hierarchy",
"to",
"contribute",
"annotations",
"or",
"providers",
"that",
"can",
"be",
"overridden",
"by",
"subclasses",
"."
] | train | https://github.com/johncarl81/transfuse/blob/a5f837504797a6c4f8628f7e1dde09b8e6368c8b/transfuse/src/main/java/org/androidtransfuse/analysis/module/ModuleTransactionWorker.java#L124-L148 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueStoragePlugin.java | ValueStoragePlugin.createURL | public URL createURL(String resourceId) throws MalformedURLException {
"""
Creates an {@link URL} corresponding to the given resource within the context of
the current {@link ValueStoragePlugin}
@param resourceId the id of the resource for which we want the corresponding URL
@return the URL corresponding to the given resource id
@throws MalformedURLException if the URL was not properly formed
"""
StringBuilder url = new StringBuilder(64);
url.append(ValueStorageURLStreamHandler.PROTOCOL);
url.append(":/");
url.append(repository);
url.append('/');
url.append(workspace);
url.append('/');
url.append(id);
url.append('/');
url.append(resourceId);
return new URL(null, url.toString(), getURLStreamHandler());
} | java | public URL createURL(String resourceId) throws MalformedURLException
{
StringBuilder url = new StringBuilder(64);
url.append(ValueStorageURLStreamHandler.PROTOCOL);
url.append(":/");
url.append(repository);
url.append('/');
url.append(workspace);
url.append('/');
url.append(id);
url.append('/');
url.append(resourceId);
return new URL(null, url.toString(), getURLStreamHandler());
} | [
"public",
"URL",
"createURL",
"(",
"String",
"resourceId",
")",
"throws",
"MalformedURLException",
"{",
"StringBuilder",
"url",
"=",
"new",
"StringBuilder",
"(",
"64",
")",
";",
"url",
".",
"append",
"(",
"ValueStorageURLStreamHandler",
".",
"PROTOCOL",
")",
";",
"url",
".",
"append",
"(",
"\":/\"",
")",
";",
"url",
".",
"append",
"(",
"repository",
")",
";",
"url",
".",
"append",
"(",
"'",
"'",
")",
";",
"url",
".",
"append",
"(",
"workspace",
")",
";",
"url",
".",
"append",
"(",
"'",
"'",
")",
";",
"url",
".",
"append",
"(",
"id",
")",
";",
"url",
".",
"append",
"(",
"'",
"'",
")",
";",
"url",
".",
"append",
"(",
"resourceId",
")",
";",
"return",
"new",
"URL",
"(",
"null",
",",
"url",
".",
"toString",
"(",
")",
",",
"getURLStreamHandler",
"(",
")",
")",
";",
"}"
] | Creates an {@link URL} corresponding to the given resource within the context of
the current {@link ValueStoragePlugin}
@param resourceId the id of the resource for which we want the corresponding URL
@return the URL corresponding to the given resource id
@throws MalformedURLException if the URL was not properly formed | [
"Creates",
"an",
"{"
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueStoragePlugin.java#L195-L208 |
micronaut-projects/micronaut-core | tracing/src/main/java/io/micronaut/tracing/instrument/http/AbstractOpenTracingFilter.java | AbstractOpenTracingFilter.setErrorTags | protected void setErrorTags(Span span, Throwable error) {
"""
Sets the error tags to use on the span.
@param span The span
@param error The error
"""
if (error != null) {
String message = error.getMessage();
if (message == null) {
message = error.getClass().getSimpleName();
}
span.setTag(TAG_ERROR, message);
}
} | java | protected void setErrorTags(Span span, Throwable error) {
if (error != null) {
String message = error.getMessage();
if (message == null) {
message = error.getClass().getSimpleName();
}
span.setTag(TAG_ERROR, message);
}
} | [
"protected",
"void",
"setErrorTags",
"(",
"Span",
"span",
",",
"Throwable",
"error",
")",
"{",
"if",
"(",
"error",
"!=",
"null",
")",
"{",
"String",
"message",
"=",
"error",
".",
"getMessage",
"(",
")",
";",
"if",
"(",
"message",
"==",
"null",
")",
"{",
"message",
"=",
"error",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
";",
"}",
"span",
".",
"setTag",
"(",
"TAG_ERROR",
",",
"message",
")",
";",
"}",
"}"
] | Sets the error tags to use on the span.
@param span The span
@param error The error | [
"Sets",
"the",
"error",
"tags",
"to",
"use",
"on",
"the",
"span",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/tracing/src/main/java/io/micronaut/tracing/instrument/http/AbstractOpenTracingFilter.java#L80-L88 |
tango-controls/JTango | client/src/main/java/org/tango/client/database/Database.java | Database.setClassProperties | @Override
public void setClassProperties(final String name, final Map<String, String[]> properties) throws DevFailed {
"""
Set a tango class properties. (execute DbPutClassProperty on DB device)
@param name
The class name
@param properties
The properties names and values.
@throws DevFailed
"""
cache.setClassProperties(name, properties);
} | java | @Override
public void setClassProperties(final String name, final Map<String, String[]> properties) throws DevFailed {
cache.setClassProperties(name, properties);
} | [
"@",
"Override",
"public",
"void",
"setClassProperties",
"(",
"final",
"String",
"name",
",",
"final",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"properties",
")",
"throws",
"DevFailed",
"{",
"cache",
".",
"setClassProperties",
"(",
"name",
",",
"properties",
")",
";",
"}"
] | Set a tango class properties. (execute DbPutClassProperty on DB device)
@param name
The class name
@param properties
The properties names and values.
@throws DevFailed | [
"Set",
"a",
"tango",
"class",
"properties",
".",
"(",
"execute",
"DbPutClassProperty",
"on",
"DB",
"device",
")"
] | train | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/client/src/main/java/org/tango/client/database/Database.java#L173-L176 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/time/DateUtils.java | DateUtils.setMilliseconds | public static Date setMilliseconds(final Date date, final int amount) {
"""
Sets the milliseconds field to a date returning a new object.
The original {@code Date} is unchanged.
@param date the date, not null
@param amount the amount to set
@return a new {@code Date} set with the specified value
@throws IllegalArgumentException if the date is null
@since 2.4
"""
return set(date, Calendar.MILLISECOND, amount);
} | java | public static Date setMilliseconds(final Date date, final int amount) {
return set(date, Calendar.MILLISECOND, amount);
} | [
"public",
"static",
"Date",
"setMilliseconds",
"(",
"final",
"Date",
"date",
",",
"final",
"int",
"amount",
")",
"{",
"return",
"set",
"(",
"date",
",",
"Calendar",
".",
"MILLISECOND",
",",
"amount",
")",
";",
"}"
] | Sets the milliseconds field to a date returning a new object.
The original {@code Date} is unchanged.
@param date the date, not null
@param amount the amount to set
@return a new {@code Date} set with the specified value
@throws IllegalArgumentException if the date is null
@since 2.4 | [
"Sets",
"the",
"milliseconds",
"field",
"to",
"a",
"date",
"returning",
"a",
"new",
"object",
".",
"The",
"original",
"{",
"@code",
"Date",
"}",
"is",
"unchanged",
"."
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/time/DateUtils.java#L631-L633 |
line/centraldogma | server/src/main/java/com/linecorp/centraldogma/server/internal/api/RepositoryServiceV1.java | RepositoryServiceV1.patchRepository | @Consumes("application/json-patch+json")
@Patch("/projects/ {
"""
PATCH /projects/{projectName}/repos/{repoName}
<p>Patches a repository with the JSON_PATCH. Currently, only unremove repository operation is supported.
"""projectName}/repos/{repoName}")
@RequiresRole(roles = ProjectRole.OWNER)
public CompletableFuture<RepositoryDto> patchRepository(@Param("repoName") String repoName,
Project project,
JsonNode node,
Author author) {
checkUnremoveArgument(node);
return execute(Command.unremoveRepository(author, project.name(), repoName))
.thenCompose(unused -> mds.restoreRepo(author, project.name(), repoName))
.handle(returnOrThrow(() -> DtoConverter.convert(project.repos().get(repoName))));
} | java | @Consumes("application/json-patch+json")
@Patch("/projects/{projectName}/repos/{repoName}")
@RequiresRole(roles = ProjectRole.OWNER)
public CompletableFuture<RepositoryDto> patchRepository(@Param("repoName") String repoName,
Project project,
JsonNode node,
Author author) {
checkUnremoveArgument(node);
return execute(Command.unremoveRepository(author, project.name(), repoName))
.thenCompose(unused -> mds.restoreRepo(author, project.name(), repoName))
.handle(returnOrThrow(() -> DtoConverter.convert(project.repos().get(repoName))));
} | [
"@",
"Consumes",
"(",
"\"application/json-patch+json\"",
")",
"@",
"Patch",
"(",
"\"/projects/{projectName}/repos/{repoName}\"",
")",
"@",
"RequiresRole",
"(",
"roles",
"=",
"ProjectRole",
".",
"OWNER",
")",
"public",
"CompletableFuture",
"<",
"RepositoryDto",
">",
"patchRepository",
"(",
"@",
"Param",
"(",
"\"repoName\"",
")",
"String",
"repoName",
",",
"Project",
"project",
",",
"JsonNode",
"node",
",",
"Author",
"author",
")",
"{",
"checkUnremoveArgument",
"(",
"node",
")",
";",
"return",
"execute",
"(",
"Command",
".",
"unremoveRepository",
"(",
"author",
",",
"project",
".",
"name",
"(",
")",
",",
"repoName",
")",
")",
".",
"thenCompose",
"(",
"unused",
"->",
"mds",
".",
"restoreRepo",
"(",
"author",
",",
"project",
".",
"name",
"(",
")",
",",
"repoName",
")",
")",
".",
"handle",
"(",
"returnOrThrow",
"(",
"(",
")",
"->",
"DtoConverter",
".",
"convert",
"(",
"project",
".",
"repos",
"(",
")",
".",
"get",
"(",
"repoName",
")",
")",
")",
")",
";",
"}"
] | PATCH /projects/{projectName}/repos/{repoName}
<p>Patches a repository with the JSON_PATCH. Currently, only unremove repository operation is supported. | [
"PATCH",
"/",
"projects",
"/",
"{",
"projectName",
"}",
"/",
"repos",
"/",
"{",
"repoName",
"}"
] | train | https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/api/RepositoryServiceV1.java#L149-L160 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/comms/common/CommsByteBuffer.java | CommsByteBuffer.getXid | public synchronized Xid getXid() {
"""
Reads an Xid from the current position in the buffer.
@return Returns an Xid
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getXid");
checkReleased();
int formatId = getInt();
int glidLength = getInt();
byte[] globalTransactionId = get(glidLength);
int blqfLength = getInt();
byte[] branchQualifier = get(blqfLength);
XidProxy xidProxy = new XidProxy(formatId, globalTransactionId, branchQualifier);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getXid", xidProxy);
return xidProxy;
} | java | public synchronized Xid getXid()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getXid");
checkReleased();
int formatId = getInt();
int glidLength = getInt();
byte[] globalTransactionId = get(glidLength);
int blqfLength = getInt();
byte[] branchQualifier = get(blqfLength);
XidProxy xidProxy = new XidProxy(formatId, globalTransactionId, branchQualifier);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getXid", xidProxy);
return xidProxy;
} | [
"public",
"synchronized",
"Xid",
"getXid",
"(",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"getXid\"",
")",
";",
"checkReleased",
"(",
")",
";",
"int",
"formatId",
"=",
"getInt",
"(",
")",
";",
"int",
"glidLength",
"=",
"getInt",
"(",
")",
";",
"byte",
"[",
"]",
"globalTransactionId",
"=",
"get",
"(",
"glidLength",
")",
";",
"int",
"blqfLength",
"=",
"getInt",
"(",
")",
";",
"byte",
"[",
"]",
"branchQualifier",
"=",
"get",
"(",
"blqfLength",
")",
";",
"XidProxy",
"xidProxy",
"=",
"new",
"XidProxy",
"(",
"formatId",
",",
"globalTransactionId",
",",
"branchQualifier",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"getXid\"",
",",
"xidProxy",
")",
";",
"return",
"xidProxy",
";",
"}"
] | Reads an Xid from the current position in the buffer.
@return Returns an Xid | [
"Reads",
"an",
"Xid",
"from",
"the",
"current",
"position",
"in",
"the",
"buffer",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.comms.client/src/com/ibm/ws/sib/comms/common/CommsByteBuffer.java#L917-L933 |
wealthfront/kawala | kawala-converters/src/main/java/com/kaching/platform/converters/ConstructorAnalysis.java | ConstructorAnalysis.analyse | static AnalysisResult analyse(
Class<?> klass, Constructor<?> constructor) throws IOException {
"""
Produces an assignment or field names to values or fails.
@throws IllegalConstructorException
"""
Class<?>[] parameterTypes = constructor.getParameterTypes();
InputStream in = klass.getResourceAsStream("/" + klass.getName().replace('.', '/') + ".class");
if (in == null) {
throw new IllegalArgumentException(format("can not find bytecode for %s", klass));
}
return analyse(in, klass.getName().replace('.', '/'),
klass.getSuperclass().getName().replace('.', '/'),
parameterTypes);
} | java | static AnalysisResult analyse(
Class<?> klass, Constructor<?> constructor) throws IOException {
Class<?>[] parameterTypes = constructor.getParameterTypes();
InputStream in = klass.getResourceAsStream("/" + klass.getName().replace('.', '/') + ".class");
if (in == null) {
throw new IllegalArgumentException(format("can not find bytecode for %s", klass));
}
return analyse(in, klass.getName().replace('.', '/'),
klass.getSuperclass().getName().replace('.', '/'),
parameterTypes);
} | [
"static",
"AnalysisResult",
"analyse",
"(",
"Class",
"<",
"?",
">",
"klass",
",",
"Constructor",
"<",
"?",
">",
"constructor",
")",
"throws",
"IOException",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"parameterTypes",
"=",
"constructor",
".",
"getParameterTypes",
"(",
")",
";",
"InputStream",
"in",
"=",
"klass",
".",
"getResourceAsStream",
"(",
"\"/\"",
"+",
"klass",
".",
"getName",
"(",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
"+",
"\".class\"",
")",
";",
"if",
"(",
"in",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"format",
"(",
"\"can not find bytecode for %s\"",
",",
"klass",
")",
")",
";",
"}",
"return",
"analyse",
"(",
"in",
",",
"klass",
".",
"getName",
"(",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
",",
"klass",
".",
"getSuperclass",
"(",
")",
".",
"getName",
"(",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
",",
"parameterTypes",
")",
";",
"}"
] | Produces an assignment or field names to values or fails.
@throws IllegalConstructorException | [
"Produces",
"an",
"assignment",
"or",
"field",
"names",
"to",
"values",
"or",
"fails",
"."
] | train | https://github.com/wealthfront/kawala/blob/acf24b7a9ef6e2f0fc1e862d44cfa4dcc4da8f6e/kawala-converters/src/main/java/com/kaching/platform/converters/ConstructorAnalysis.java#L61-L71 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpp/FieldMap.java | FieldMap.getFieldData | protected Object getFieldData(Integer id, FieldType type, byte[][] fixedData, Var2Data varData) {
"""
Retrieve a single field value.
@param id parent entity ID
@param type field type
@param fixedData fixed data block
@param varData var data block
@return field value
"""
Object result = null;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.read(id, fixedData, varData);
}
return result;
} | java | protected Object getFieldData(Integer id, FieldType type, byte[][] fixedData, Var2Data varData)
{
Object result = null;
FieldItem item = m_map.get(type);
if (item != null)
{
result = item.read(id, fixedData, varData);
}
return result;
} | [
"protected",
"Object",
"getFieldData",
"(",
"Integer",
"id",
",",
"FieldType",
"type",
",",
"byte",
"[",
"]",
"[",
"]",
"fixedData",
",",
"Var2Data",
"varData",
")",
"{",
"Object",
"result",
"=",
"null",
";",
"FieldItem",
"item",
"=",
"m_map",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"item",
"!=",
"null",
")",
"{",
"result",
"=",
"item",
".",
"read",
"(",
"id",
",",
"fixedData",
",",
"varData",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Retrieve a single field value.
@param id parent entity ID
@param type field type
@param fixedData fixed data block
@param varData var data block
@return field value | [
"Retrieve",
"a",
"single",
"field",
"value",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FieldMap.java#L542-L553 |
apache/spark | core/src/main/java/org/apache/spark/memory/TaskMemoryManager.java | TaskMemoryManager.encodePageNumberAndOffset | public long encodePageNumberAndOffset(MemoryBlock page, long offsetInPage) {
"""
Given a memory page and offset within that page, encode this address into a 64-bit long.
This address will remain valid as long as the corresponding page has not been freed.
@param page a data page allocated by {@link TaskMemoryManager#allocatePage}/
@param offsetInPage an offset in this page which incorporates the base offset. In other words,
this should be the value that you would pass as the base offset into an
UNSAFE call (e.g. page.baseOffset() + something).
@return an encoded page address.
"""
if (tungstenMemoryMode == MemoryMode.OFF_HEAP) {
// In off-heap mode, an offset is an absolute address that may require a full 64 bits to
// encode. Due to our page size limitation, though, we can convert this into an offset that's
// relative to the page's base offset; this relative offset will fit in 51 bits.
offsetInPage -= page.getBaseOffset();
}
return encodePageNumberAndOffset(page.pageNumber, offsetInPage);
} | java | public long encodePageNumberAndOffset(MemoryBlock page, long offsetInPage) {
if (tungstenMemoryMode == MemoryMode.OFF_HEAP) {
// In off-heap mode, an offset is an absolute address that may require a full 64 bits to
// encode. Due to our page size limitation, though, we can convert this into an offset that's
// relative to the page's base offset; this relative offset will fit in 51 bits.
offsetInPage -= page.getBaseOffset();
}
return encodePageNumberAndOffset(page.pageNumber, offsetInPage);
} | [
"public",
"long",
"encodePageNumberAndOffset",
"(",
"MemoryBlock",
"page",
",",
"long",
"offsetInPage",
")",
"{",
"if",
"(",
"tungstenMemoryMode",
"==",
"MemoryMode",
".",
"OFF_HEAP",
")",
"{",
"// In off-heap mode, an offset is an absolute address that may require a full 64 bits to",
"// encode. Due to our page size limitation, though, we can convert this into an offset that's",
"// relative to the page's base offset; this relative offset will fit in 51 bits.",
"offsetInPage",
"-=",
"page",
".",
"getBaseOffset",
"(",
")",
";",
"}",
"return",
"encodePageNumberAndOffset",
"(",
"page",
".",
"pageNumber",
",",
"offsetInPage",
")",
";",
"}"
] | Given a memory page and offset within that page, encode this address into a 64-bit long.
This address will remain valid as long as the corresponding page has not been freed.
@param page a data page allocated by {@link TaskMemoryManager#allocatePage}/
@param offsetInPage an offset in this page which incorporates the base offset. In other words,
this should be the value that you would pass as the base offset into an
UNSAFE call (e.g. page.baseOffset() + something).
@return an encoded page address. | [
"Given",
"a",
"memory",
"page",
"and",
"offset",
"within",
"that",
"page",
"encode",
"this",
"address",
"into",
"a",
"64",
"-",
"bit",
"long",
".",
"This",
"address",
"will",
"remain",
"valid",
"as",
"long",
"as",
"the",
"corresponding",
"page",
"has",
"not",
"been",
"freed",
"."
] | train | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/core/src/main/java/org/apache/spark/memory/TaskMemoryManager.java#L363-L371 |
phax/ph-oton | ph-oton-jscode/src/main/java/com/helger/html/jscode/AbstractJSBlock.java | AbstractJSBlock.staticInvoke | @Nonnull
public JSInvocation staticInvoke (@Nullable final AbstractJSClass aType, @Nonnull final JSMethod aMethod) {
"""
Creates a static invocation statement.
@param aType
Type to use
@param aMethod
Method to invoke
@return Never <code>null</code>.
"""
final JSInvocation aInvocation = new JSInvocation (aType, aMethod);
return addStatement (aInvocation);
} | java | @Nonnull
public JSInvocation staticInvoke (@Nullable final AbstractJSClass aType, @Nonnull final JSMethod aMethod)
{
final JSInvocation aInvocation = new JSInvocation (aType, aMethod);
return addStatement (aInvocation);
} | [
"@",
"Nonnull",
"public",
"JSInvocation",
"staticInvoke",
"(",
"@",
"Nullable",
"final",
"AbstractJSClass",
"aType",
",",
"@",
"Nonnull",
"final",
"JSMethod",
"aMethod",
")",
"{",
"final",
"JSInvocation",
"aInvocation",
"=",
"new",
"JSInvocation",
"(",
"aType",
",",
"aMethod",
")",
";",
"return",
"addStatement",
"(",
"aInvocation",
")",
";",
"}"
] | Creates a static invocation statement.
@param aType
Type to use
@param aMethod
Method to invoke
@return Never <code>null</code>. | [
"Creates",
"a",
"static",
"invocation",
"statement",
"."
] | train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-jscode/src/main/java/com/helger/html/jscode/AbstractJSBlock.java#L551-L556 |
JodaOrg/joda-time | src/main/java/org/joda/time/field/FieldUtils.java | FieldUtils.getWrappedValue | public static int getWrappedValue(int value, int minValue, int maxValue) {
"""
Utility method that ensures the given value lies within the field's
legal value range.
@param value the value to fit into the wrapped value range
@param minValue the wrap range minimum value.
@param maxValue the wrap range maximum value. This must be
greater than minValue (checked by the method).
@return the wrapped value
@throws IllegalArgumentException if minValue is greater
than or equal to maxValue
"""
if (minValue >= maxValue) {
throw new IllegalArgumentException("MIN > MAX");
}
int wrapRange = maxValue - minValue + 1;
value -= minValue;
if (value >= 0) {
return (value % wrapRange) + minValue;
}
int remByRange = (-value) % wrapRange;
if (remByRange == 0) {
return 0 + minValue;
}
return (wrapRange - remByRange) + minValue;
} | java | public static int getWrappedValue(int value, int minValue, int maxValue) {
if (minValue >= maxValue) {
throw new IllegalArgumentException("MIN > MAX");
}
int wrapRange = maxValue - minValue + 1;
value -= minValue;
if (value >= 0) {
return (value % wrapRange) + minValue;
}
int remByRange = (-value) % wrapRange;
if (remByRange == 0) {
return 0 + minValue;
}
return (wrapRange - remByRange) + minValue;
} | [
"public",
"static",
"int",
"getWrappedValue",
"(",
"int",
"value",
",",
"int",
"minValue",
",",
"int",
"maxValue",
")",
"{",
"if",
"(",
"minValue",
">=",
"maxValue",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"MIN > MAX\"",
")",
";",
"}",
"int",
"wrapRange",
"=",
"maxValue",
"-",
"minValue",
"+",
"1",
";",
"value",
"-=",
"minValue",
";",
"if",
"(",
"value",
">=",
"0",
")",
"{",
"return",
"(",
"value",
"%",
"wrapRange",
")",
"+",
"minValue",
";",
"}",
"int",
"remByRange",
"=",
"(",
"-",
"value",
")",
"%",
"wrapRange",
";",
"if",
"(",
"remByRange",
"==",
"0",
")",
"{",
"return",
"0",
"+",
"minValue",
";",
"}",
"return",
"(",
"wrapRange",
"-",
"remByRange",
")",
"+",
"minValue",
";",
"}"
] | Utility method that ensures the given value lies within the field's
legal value range.
@param value the value to fit into the wrapped value range
@param minValue the wrap range minimum value.
@param maxValue the wrap range maximum value. This must be
greater than minValue (checked by the method).
@return the wrapped value
@throws IllegalArgumentException if minValue is greater
than or equal to maxValue | [
"Utility",
"method",
"that",
"ensures",
"the",
"given",
"value",
"lies",
"within",
"the",
"field",
"s",
"legal",
"value",
"range",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/FieldUtils.java#L330-L348 |
sarl/sarl | main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/core/Capacities.java | Capacities.createSkillDelegatorIfPossible | @Pure
public static <C extends Capacity> C createSkillDelegatorIfPossible(Skill originalSkill, Class<C> capacity, AgentTrait capacityCaller)
throws ClassCastException {
"""
Create a delegator for the given skill when it is possible.
<p>The delegator is wrapping the original skill in order to set the value of the caller
that will be replied by {@link #getCaller()}. The associated caller is given as argument.
<p>The delegator is an instance of an specific inner type, sub-type of {@link Capacity.ContextAwareCapacityWrapper},
which is declared in the given {@code capacity}.
<p>This functions assumes that the name of the definition type is the same as {@link Capacity.ContextAwareCapacityWrapper},
and this definition extends the delegator definition of the first super type of the {@code capacity}, and implements
all the super types of the {@code capacity}. The expected constructor for this inner type has the same
signature as the one of {@link Capacity.ContextAwareCapacityWrapper}.
If the delegator instance cannot be created due to to inner type not found, invalid constructor signature,
run-time exception when creating the instance, this function replies the original skill.
<p>The function {@link #createSkillDelegator(Skill, Class, AgentTrait)} is a similar function than this
function, except that it fails when the delegator instance cannot be created.
@param <C> the type of the capacity.
@param originalSkill the skill to delegate to after ensure the capacity caller is correctly set.
@param capacity the capacity that contains the definition of the delegator.
@param capacityCaller the caller of the capacity functions.
@return the delegator, or the original skill.
@throws ClassCastException if the skill is not implementing the capacity.
@see #createSkillDelegator(Skill, Class, AgentTrait)
"""
try {
return Capacities.createSkillDelegator(originalSkill, capacity, capacityCaller);
} catch (Exception e) {
return capacity.cast(originalSkill);
}
} | java | @Pure
public static <C extends Capacity> C createSkillDelegatorIfPossible(Skill originalSkill, Class<C> capacity, AgentTrait capacityCaller)
throws ClassCastException {
try {
return Capacities.createSkillDelegator(originalSkill, capacity, capacityCaller);
} catch (Exception e) {
return capacity.cast(originalSkill);
}
} | [
"@",
"Pure",
"public",
"static",
"<",
"C",
"extends",
"Capacity",
">",
"C",
"createSkillDelegatorIfPossible",
"(",
"Skill",
"originalSkill",
",",
"Class",
"<",
"C",
">",
"capacity",
",",
"AgentTrait",
"capacityCaller",
")",
"throws",
"ClassCastException",
"{",
"try",
"{",
"return",
"Capacities",
".",
"createSkillDelegator",
"(",
"originalSkill",
",",
"capacity",
",",
"capacityCaller",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"capacity",
".",
"cast",
"(",
"originalSkill",
")",
";",
"}",
"}"
] | Create a delegator for the given skill when it is possible.
<p>The delegator is wrapping the original skill in order to set the value of the caller
that will be replied by {@link #getCaller()}. The associated caller is given as argument.
<p>The delegator is an instance of an specific inner type, sub-type of {@link Capacity.ContextAwareCapacityWrapper},
which is declared in the given {@code capacity}.
<p>This functions assumes that the name of the definition type is the same as {@link Capacity.ContextAwareCapacityWrapper},
and this definition extends the delegator definition of the first super type of the {@code capacity}, and implements
all the super types of the {@code capacity}. The expected constructor for this inner type has the same
signature as the one of {@link Capacity.ContextAwareCapacityWrapper}.
If the delegator instance cannot be created due to to inner type not found, invalid constructor signature,
run-time exception when creating the instance, this function replies the original skill.
<p>The function {@link #createSkillDelegator(Skill, Class, AgentTrait)} is a similar function than this
function, except that it fails when the delegator instance cannot be created.
@param <C> the type of the capacity.
@param originalSkill the skill to delegate to after ensure the capacity caller is correctly set.
@param capacity the capacity that contains the definition of the delegator.
@param capacityCaller the caller of the capacity functions.
@return the delegator, or the original skill.
@throws ClassCastException if the skill is not implementing the capacity.
@see #createSkillDelegator(Skill, Class, AgentTrait) | [
"Create",
"a",
"delegator",
"for",
"the",
"given",
"skill",
"when",
"it",
"is",
"possible",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.core/src/io/sarl/lang/core/Capacities.java#L122-L130 |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/natures/AddSarlNatureHandler.java | AddSarlNatureHandler.doConvert | protected void doConvert(IProject project, IProgressMonitor monitor) throws ExecutionException {
"""
Convert the given project.
@param project the project to convert..
@param monitor the progress monitor.
@throws ExecutionException if something going wrong.
"""
monitor.setTaskName(MessageFormat.format(Messages.AddSarlNatureHandler_2, project.getName()));
final SubMonitor mon = SubMonitor.convert(monitor, 2);
if (this.configurator.canConfigure(project, Collections.emptySet(), mon.newChild(1))) {
this.configurator.configure(project, Collections.emptySet(), mon.newChild(1));
}
monitor.done();
} | java | protected void doConvert(IProject project, IProgressMonitor monitor) throws ExecutionException {
monitor.setTaskName(MessageFormat.format(Messages.AddSarlNatureHandler_2, project.getName()));
final SubMonitor mon = SubMonitor.convert(monitor, 2);
if (this.configurator.canConfigure(project, Collections.emptySet(), mon.newChild(1))) {
this.configurator.configure(project, Collections.emptySet(), mon.newChild(1));
}
monitor.done();
} | [
"protected",
"void",
"doConvert",
"(",
"IProject",
"project",
",",
"IProgressMonitor",
"monitor",
")",
"throws",
"ExecutionException",
"{",
"monitor",
".",
"setTaskName",
"(",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"AddSarlNatureHandler_2",
",",
"project",
".",
"getName",
"(",
")",
")",
")",
";",
"final",
"SubMonitor",
"mon",
"=",
"SubMonitor",
".",
"convert",
"(",
"monitor",
",",
"2",
")",
";",
"if",
"(",
"this",
".",
"configurator",
".",
"canConfigure",
"(",
"project",
",",
"Collections",
".",
"emptySet",
"(",
")",
",",
"mon",
".",
"newChild",
"(",
"1",
")",
")",
")",
"{",
"this",
".",
"configurator",
".",
"configure",
"(",
"project",
",",
"Collections",
".",
"emptySet",
"(",
")",
",",
"mon",
".",
"newChild",
"(",
"1",
")",
")",
";",
"}",
"monitor",
".",
"done",
"(",
")",
";",
"}"
] | Convert the given project.
@param project the project to convert..
@param monitor the progress monitor.
@throws ExecutionException if something going wrong. | [
"Convert",
"the",
"given",
"project",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/natures/AddSarlNatureHandler.java#L116-L123 |
pravega/pravega | common/src/main/java/io/pravega/common/lang/ProcessStarter.java | ProcessStarter.sysProp | public ProcessStarter sysProp(String name, Object value) {
"""
Includes the given System Property as part of the start.
@param name The System Property Name.
@param value The System Property Value. This will have toString() invoked on it.
@return This object instance.
"""
this.systemProps.put(name, value.toString());
return this;
} | java | public ProcessStarter sysProp(String name, Object value) {
this.systemProps.put(name, value.toString());
return this;
} | [
"public",
"ProcessStarter",
"sysProp",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"this",
".",
"systemProps",
".",
"put",
"(",
"name",
",",
"value",
".",
"toString",
"(",
")",
")",
";",
"return",
"this",
";",
"}"
] | Includes the given System Property as part of the start.
@param name The System Property Name.
@param value The System Property Value. This will have toString() invoked on it.
@return This object instance. | [
"Includes",
"the",
"given",
"System",
"Property",
"as",
"part",
"of",
"the",
"start",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/common/src/main/java/io/pravega/common/lang/ProcessStarter.java#L70-L73 |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java | CausticUtil.checkVersion | public static void checkVersion(GLVersioned required, GLVersioned object) {
"""
Checks if two OpenGL versioned object have compatible version. Throws an exception if that's not the case. A version is determined to be compatible with another is it's lower than the said
version. This isn't always true when deprecation is involved, but it's an acceptable way of doing this in most implementations.
@param required The required version
@param object The object to check the version of
@throws IllegalStateException If the object versions are not compatible
"""
if (!debug) {
return;
}
final GLVersion requiredVersion = required.getGLVersion();
final GLVersion objectVersion = object.getGLVersion();
if (objectVersion.getMajor() > requiredVersion.getMajor() && objectVersion.getMinor() > requiredVersion.getMinor()) {
throw new IllegalStateException("Versions not compatible: expected " + requiredVersion + " or lower, got " + objectVersion);
}
} | java | public static void checkVersion(GLVersioned required, GLVersioned object) {
if (!debug) {
return;
}
final GLVersion requiredVersion = required.getGLVersion();
final GLVersion objectVersion = object.getGLVersion();
if (objectVersion.getMajor() > requiredVersion.getMajor() && objectVersion.getMinor() > requiredVersion.getMinor()) {
throw new IllegalStateException("Versions not compatible: expected " + requiredVersion + " or lower, got " + objectVersion);
}
} | [
"public",
"static",
"void",
"checkVersion",
"(",
"GLVersioned",
"required",
",",
"GLVersioned",
"object",
")",
"{",
"if",
"(",
"!",
"debug",
")",
"{",
"return",
";",
"}",
"final",
"GLVersion",
"requiredVersion",
"=",
"required",
".",
"getGLVersion",
"(",
")",
";",
"final",
"GLVersion",
"objectVersion",
"=",
"object",
".",
"getGLVersion",
"(",
")",
";",
"if",
"(",
"objectVersion",
".",
"getMajor",
"(",
")",
">",
"requiredVersion",
".",
"getMajor",
"(",
")",
"&&",
"objectVersion",
".",
"getMinor",
"(",
")",
">",
"requiredVersion",
".",
"getMinor",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Versions not compatible: expected \"",
"+",
"requiredVersion",
"+",
"\" or lower, got \"",
"+",
"objectVersion",
")",
";",
"}",
"}"
] | Checks if two OpenGL versioned object have compatible version. Throws an exception if that's not the case. A version is determined to be compatible with another is it's lower than the said
version. This isn't always true when deprecation is involved, but it's an acceptable way of doing this in most implementations.
@param required The required version
@param object The object to check the version of
@throws IllegalStateException If the object versions are not compatible | [
"Checks",
"if",
"two",
"OpenGL",
"versioned",
"object",
"have",
"compatible",
"version",
".",
"Throws",
"an",
"exception",
"if",
"that",
"s",
"not",
"the",
"case",
".",
"A",
"version",
"is",
"determined",
"to",
"be",
"compatible",
"with",
"another",
"is",
"it",
"s",
"lower",
"than",
"the",
"said",
"version",
".",
"This",
"isn",
"t",
"always",
"true",
"when",
"deprecation",
"is",
"involved",
"but",
"it",
"s",
"an",
"acceptable",
"way",
"of",
"doing",
"this",
"in",
"most",
"implementations",
"."
] | train | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java#L106-L115 |
liferay/com-liferay-commerce | commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehouseItemPersistenceImpl.java | CommerceWarehouseItemPersistenceImpl.countByCPI_CPIU | @Override
public int countByCPI_CPIU(long CProductId, String CPInstanceUuid) {
"""
Returns the number of commerce warehouse items where CProductId = ? and CPInstanceUuid = ?.
@param CProductId the c product ID
@param CPInstanceUuid the cp instance uuid
@return the number of matching commerce warehouse items
"""
FinderPath finderPath = FINDER_PATH_COUNT_BY_CPI_CPIU;
Object[] finderArgs = new Object[] { CProductId, CPInstanceUuid };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_COMMERCEWAREHOUSEITEM_WHERE);
query.append(_FINDER_COLUMN_CPI_CPIU_CPRODUCTID_2);
boolean bindCPInstanceUuid = false;
if (CPInstanceUuid == null) {
query.append(_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_1);
}
else if (CPInstanceUuid.equals("")) {
query.append(_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_3);
}
else {
bindCPInstanceUuid = true;
query.append(_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(CProductId);
if (bindCPInstanceUuid) {
qPos.add(CPInstanceUuid);
}
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
} | java | @Override
public int countByCPI_CPIU(long CProductId, String CPInstanceUuid) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_CPI_CPIU;
Object[] finderArgs = new Object[] { CProductId, CPInstanceUuid };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_COUNT_COMMERCEWAREHOUSEITEM_WHERE);
query.append(_FINDER_COLUMN_CPI_CPIU_CPRODUCTID_2);
boolean bindCPInstanceUuid = false;
if (CPInstanceUuid == null) {
query.append(_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_1);
}
else if (CPInstanceUuid.equals("")) {
query.append(_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_3);
}
else {
bindCPInstanceUuid = true;
query.append(_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(CProductId);
if (bindCPInstanceUuid) {
qPos.add(CPInstanceUuid);
}
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
} | [
"@",
"Override",
"public",
"int",
"countByCPI_CPIU",
"(",
"long",
"CProductId",
",",
"String",
"CPInstanceUuid",
")",
"{",
"FinderPath",
"finderPath",
"=",
"FINDER_PATH_COUNT_BY_CPI_CPIU",
";",
"Object",
"[",
"]",
"finderArgs",
"=",
"new",
"Object",
"[",
"]",
"{",
"CProductId",
",",
"CPInstanceUuid",
"}",
";",
"Long",
"count",
"=",
"(",
"Long",
")",
"finderCache",
".",
"getResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"this",
")",
";",
"if",
"(",
"count",
"==",
"null",
")",
"{",
"StringBundler",
"query",
"=",
"new",
"StringBundler",
"(",
"3",
")",
";",
"query",
".",
"append",
"(",
"_SQL_COUNT_COMMERCEWAREHOUSEITEM_WHERE",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_CPI_CPIU_CPRODUCTID_2",
")",
";",
"boolean",
"bindCPInstanceUuid",
"=",
"false",
";",
"if",
"(",
"CPInstanceUuid",
"==",
"null",
")",
"{",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_1",
")",
";",
"}",
"else",
"if",
"(",
"CPInstanceUuid",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_3",
")",
";",
"}",
"else",
"{",
"bindCPInstanceUuid",
"=",
"true",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_CPI_CPIU_CPINSTANCEUUID_2",
")",
";",
"}",
"String",
"sql",
"=",
"query",
".",
"toString",
"(",
")",
";",
"Session",
"session",
"=",
"null",
";",
"try",
"{",
"session",
"=",
"openSession",
"(",
")",
";",
"Query",
"q",
"=",
"session",
".",
"createQuery",
"(",
"sql",
")",
";",
"QueryPos",
"qPos",
"=",
"QueryPos",
".",
"getInstance",
"(",
"q",
")",
";",
"qPos",
".",
"add",
"(",
"CProductId",
")",
";",
"if",
"(",
"bindCPInstanceUuid",
")",
"{",
"qPos",
".",
"add",
"(",
"CPInstanceUuid",
")",
";",
"}",
"count",
"=",
"(",
"Long",
")",
"q",
".",
"uniqueResult",
"(",
")",
";",
"finderCache",
".",
"putResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"count",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"finderCache",
".",
"removeResult",
"(",
"finderPath",
",",
"finderArgs",
")",
";",
"throw",
"processException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closeSession",
"(",
"session",
")",
";",
"}",
"}",
"return",
"count",
".",
"intValue",
"(",
")",
";",
"}"
] | Returns the number of commerce warehouse items where CProductId = ? and CPInstanceUuid = ?.
@param CProductId the c product ID
@param CPInstanceUuid the cp instance uuid
@return the number of matching commerce warehouse items | [
"Returns",
"the",
"number",
"of",
"commerce",
"warehouse",
"items",
"where",
"CProductId",
"=",
"?",
";",
"and",
"CPInstanceUuid",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehouseItemPersistenceImpl.java#L1409-L1470 |
elki-project/elki | elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/Logging.java | Logging.debugFine | public void debugFine(CharSequence message, Throwable e) {
"""
Log a message at the 'fine' debugging level.
You should check isDebugging() before building the message.
@param message Informational log message.
@param e Exception
"""
log(Level.FINE, message, e);
} | java | public void debugFine(CharSequence message, Throwable e) {
log(Level.FINE, message, e);
} | [
"public",
"void",
"debugFine",
"(",
"CharSequence",
"message",
",",
"Throwable",
"e",
")",
"{",
"log",
"(",
"Level",
".",
"FINE",
",",
"message",
",",
"e",
")",
";",
"}"
] | Log a message at the 'fine' debugging level.
You should check isDebugging() before building the message.
@param message Informational log message.
@param e Exception | [
"Log",
"a",
"message",
"at",
"the",
"fine",
"debugging",
"level",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/Logging.java#L445-L447 |
cdk/cdk | tool/group/src/main/java/org/openscience/cdk/group/Partition.java | Partition.splitBefore | public Partition splitBefore(int cellIndex, int splitElement) {
"""
Splits this partition by taking the cell at cellIndex and making two
new cells - the first with the singleton splitElement and the second
with the rest of the elements from that cell.
@param cellIndex the index of the cell to split on
@param splitElement the element to put in its own cell
@return a new (finer) Partition
"""
Partition r = new Partition();
// copy the cells up to cellIndex
for (int j = 0; j < cellIndex; j++) {
r.addCell(this.copyBlock(j));
}
// split the block at block index
r.addSingletonCell(splitElement);
SortedSet<Integer> splitBlock = this.copyBlock(cellIndex);
splitBlock.remove(splitElement);
r.addCell(splitBlock);
// copy the blocks after blockIndex, shuffled up by one
for (int j = cellIndex + 1; j < this.size(); j++) {
r.addCell(this.copyBlock(j));
}
return r;
} | java | public Partition splitBefore(int cellIndex, int splitElement) {
Partition r = new Partition();
// copy the cells up to cellIndex
for (int j = 0; j < cellIndex; j++) {
r.addCell(this.copyBlock(j));
}
// split the block at block index
r.addSingletonCell(splitElement);
SortedSet<Integer> splitBlock = this.copyBlock(cellIndex);
splitBlock.remove(splitElement);
r.addCell(splitBlock);
// copy the blocks after blockIndex, shuffled up by one
for (int j = cellIndex + 1; j < this.size(); j++) {
r.addCell(this.copyBlock(j));
}
return r;
} | [
"public",
"Partition",
"splitBefore",
"(",
"int",
"cellIndex",
",",
"int",
"splitElement",
")",
"{",
"Partition",
"r",
"=",
"new",
"Partition",
"(",
")",
";",
"// copy the cells up to cellIndex",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"cellIndex",
";",
"j",
"++",
")",
"{",
"r",
".",
"addCell",
"(",
"this",
".",
"copyBlock",
"(",
"j",
")",
")",
";",
"}",
"// split the block at block index",
"r",
".",
"addSingletonCell",
"(",
"splitElement",
")",
";",
"SortedSet",
"<",
"Integer",
">",
"splitBlock",
"=",
"this",
".",
"copyBlock",
"(",
"cellIndex",
")",
";",
"splitBlock",
".",
"remove",
"(",
"splitElement",
")",
";",
"r",
".",
"addCell",
"(",
"splitBlock",
")",
";",
"// copy the blocks after blockIndex, shuffled up by one",
"for",
"(",
"int",
"j",
"=",
"cellIndex",
"+",
"1",
";",
"j",
"<",
"this",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"r",
".",
"addCell",
"(",
"this",
".",
"copyBlock",
"(",
"j",
")",
")",
";",
"}",
"return",
"r",
";",
"}"
] | Splits this partition by taking the cell at cellIndex and making two
new cells - the first with the singleton splitElement and the second
with the rest of the elements from that cell.
@param cellIndex the index of the cell to split on
@param splitElement the element to put in its own cell
@return a new (finer) Partition | [
"Splits",
"this",
"partition",
"by",
"taking",
"the",
"cell",
"at",
"cellIndex",
"and",
"making",
"two",
"new",
"cells",
"-",
"the",
"first",
"with",
"the",
"singleton",
"splitElement",
"and",
"the",
"second",
"with",
"the",
"rest",
"of",
"the",
"elements",
"from",
"that",
"cell",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/group/src/main/java/org/openscience/cdk/group/Partition.java#L222-L240 |
alkacon/opencms-core | src-modules/org/opencms/workplace/commons/CmsPreferences.java | CmsPreferences.buildSelectDeleteFileMode | public String buildSelectDeleteFileMode(String htmlAttributes) {
"""
Builds the html for the default delete file mode select box.<p>
@param htmlAttributes optional html attributes for the &lgt;select> tag
@return the html for the default delete file mode select box
"""
List<String> options = new ArrayList<String>(2);
options.add(key(Messages.GUI_PREF_PRESERVE_SIBLINGS_0));
options.add(key(Messages.GUI_PREF_DELETE_SIBLINGS_0));
List<String> values = new ArrayList<String>(2);
values.add(String.valueOf(CmsResource.DELETE_PRESERVE_SIBLINGS));
values.add(String.valueOf(CmsResource.DELETE_REMOVE_SIBLINGS));
int selectedIndex = values.indexOf(getParamTabDiDeleteFileMode());
return buildSelect(htmlAttributes, options, values, selectedIndex);
} | java | public String buildSelectDeleteFileMode(String htmlAttributes) {
List<String> options = new ArrayList<String>(2);
options.add(key(Messages.GUI_PREF_PRESERVE_SIBLINGS_0));
options.add(key(Messages.GUI_PREF_DELETE_SIBLINGS_0));
List<String> values = new ArrayList<String>(2);
values.add(String.valueOf(CmsResource.DELETE_PRESERVE_SIBLINGS));
values.add(String.valueOf(CmsResource.DELETE_REMOVE_SIBLINGS));
int selectedIndex = values.indexOf(getParamTabDiDeleteFileMode());
return buildSelect(htmlAttributes, options, values, selectedIndex);
} | [
"public",
"String",
"buildSelectDeleteFileMode",
"(",
"String",
"htmlAttributes",
")",
"{",
"List",
"<",
"String",
">",
"options",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"2",
")",
";",
"options",
".",
"add",
"(",
"key",
"(",
"Messages",
".",
"GUI_PREF_PRESERVE_SIBLINGS_0",
")",
")",
";",
"options",
".",
"add",
"(",
"key",
"(",
"Messages",
".",
"GUI_PREF_DELETE_SIBLINGS_0",
")",
")",
";",
"List",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"2",
")",
";",
"values",
".",
"add",
"(",
"String",
".",
"valueOf",
"(",
"CmsResource",
".",
"DELETE_PRESERVE_SIBLINGS",
")",
")",
";",
"values",
".",
"add",
"(",
"String",
".",
"valueOf",
"(",
"CmsResource",
".",
"DELETE_REMOVE_SIBLINGS",
")",
")",
";",
"int",
"selectedIndex",
"=",
"values",
".",
"indexOf",
"(",
"getParamTabDiDeleteFileMode",
"(",
")",
")",
";",
"return",
"buildSelect",
"(",
"htmlAttributes",
",",
"options",
",",
"values",
",",
"selectedIndex",
")",
";",
"}"
] | Builds the html for the default delete file mode select box.<p>
@param htmlAttributes optional html attributes for the &lgt;select> tag
@return the html for the default delete file mode select box | [
"Builds",
"the",
"html",
"for",
"the",
"default",
"delete",
"file",
"mode",
"select",
"box",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/commons/CmsPreferences.java#L627-L637 |
knightliao/disconf | disconf-core/src/main/java/org/apache/zookeeper/recipes/lock/ProtocolSupport.java | ProtocolSupport.ensureExists | protected void ensureExists(final String path, final byte[] data, final List<ACL> acl, final CreateMode flags) {
"""
Ensures that the given path exists with the given data, ACL and flags
@param path
@param acl
@param flags
"""
try {
retryOperation(new ZooKeeperOperation() {
public boolean execute() throws KeeperException, InterruptedException {
Stat stat = zookeeper.exists(path, false);
if (stat != null) {
return true;
}
zookeeper.create(path, data, acl, flags);
return true;
}
});
} catch (KeeperException e) {
LOG.warn("Caught: " + e, e);
} catch (InterruptedException e) {
LOG.warn("Caught: " + e, e);
}
} | java | protected void ensureExists(final String path, final byte[] data, final List<ACL> acl, final CreateMode flags) {
try {
retryOperation(new ZooKeeperOperation() {
public boolean execute() throws KeeperException, InterruptedException {
Stat stat = zookeeper.exists(path, false);
if (stat != null) {
return true;
}
zookeeper.create(path, data, acl, flags);
return true;
}
});
} catch (KeeperException e) {
LOG.warn("Caught: " + e, e);
} catch (InterruptedException e) {
LOG.warn("Caught: " + e, e);
}
} | [
"protected",
"void",
"ensureExists",
"(",
"final",
"String",
"path",
",",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"List",
"<",
"ACL",
">",
"acl",
",",
"final",
"CreateMode",
"flags",
")",
"{",
"try",
"{",
"retryOperation",
"(",
"new",
"ZooKeeperOperation",
"(",
")",
"{",
"public",
"boolean",
"execute",
"(",
")",
"throws",
"KeeperException",
",",
"InterruptedException",
"{",
"Stat",
"stat",
"=",
"zookeeper",
".",
"exists",
"(",
"path",
",",
"false",
")",
";",
"if",
"(",
"stat",
"!=",
"null",
")",
"{",
"return",
"true",
";",
"}",
"zookeeper",
".",
"create",
"(",
"path",
",",
"data",
",",
"acl",
",",
"flags",
")",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"KeeperException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Caught: \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Caught: \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"}"
] | Ensures that the given path exists with the given data, ACL and flags
@param path
@param acl
@param flags | [
"Ensures",
"that",
"the",
"given",
"path",
"exists",
"with",
"the",
"given",
"data",
"ACL",
"and",
"flags"
] | train | https://github.com/knightliao/disconf/blob/d413cbce9334fe38a5a24982ce4db3a6ed8e98ea/disconf-core/src/main/java/org/apache/zookeeper/recipes/lock/ProtocolSupport.java#L155-L172 |
mlhartme/sushi | src/main/java/net/oneandone/sushi/xml/Builder.java | Builder.parseString | public Document parseString(String text) throws SAXException {
"""
This method is not called "parse" to avoid confusion with file parsing methods
"""
try {
return parse(new InputSource(new StringReader(text)));
} catch (IOException e) {
throw new RuntimeException("unexpected world exception while reading memory stream", e);
}
} | java | public Document parseString(String text) throws SAXException {
try {
return parse(new InputSource(new StringReader(text)));
} catch (IOException e) {
throw new RuntimeException("unexpected world exception while reading memory stream", e);
}
} | [
"public",
"Document",
"parseString",
"(",
"String",
"text",
")",
"throws",
"SAXException",
"{",
"try",
"{",
"return",
"parse",
"(",
"new",
"InputSource",
"(",
"new",
"StringReader",
"(",
"text",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"unexpected world exception while reading memory stream\"",
",",
"e",
")",
";",
"}",
"}"
] | This method is not called "parse" to avoid confusion with file parsing methods | [
"This",
"method",
"is",
"not",
"called",
"parse",
"to",
"avoid",
"confusion",
"with",
"file",
"parsing",
"methods"
] | train | https://github.com/mlhartme/sushi/blob/4af33414b04bd58584d4febe5cc63ef6c7346a75/src/main/java/net/oneandone/sushi/xml/Builder.java#L53-L59 |
aehrc/ontology-core | ontology-import/src/main/java/au/csiro/ontology/importer/rf2/RF2Importer.java | RF2Importer.loadModuleDependencies | protected IModuleDependencyRefset loadModuleDependencies(RF2Input input) throws ImportException {
"""
Loads all the module dependency information from all RF2 inputs into a single {@link IModuleDependencyRefset}.
@return
@throws ImportException
"""
Set<InputStream> iss = new HashSet<>();
InputType inputType = input.getInputType();
for(String md : input.getModuleDependenciesRefsetFiles()) {
try {
iss.add(input.getInputStream(md));
} catch (NullPointerException | IOException e) {
final String message = StructuredLog.ModuleLoadFailure.error(log, inputType, md, e);
throw new ImportException(message, e);
}
}
IModuleDependencyRefset res = RefsetImporter.importModuleDependencyRefset(iss);
return res;
} | java | protected IModuleDependencyRefset loadModuleDependencies(RF2Input input) throws ImportException {
Set<InputStream> iss = new HashSet<>();
InputType inputType = input.getInputType();
for(String md : input.getModuleDependenciesRefsetFiles()) {
try {
iss.add(input.getInputStream(md));
} catch (NullPointerException | IOException e) {
final String message = StructuredLog.ModuleLoadFailure.error(log, inputType, md, e);
throw new ImportException(message, e);
}
}
IModuleDependencyRefset res = RefsetImporter.importModuleDependencyRefset(iss);
return res;
} | [
"protected",
"IModuleDependencyRefset",
"loadModuleDependencies",
"(",
"RF2Input",
"input",
")",
"throws",
"ImportException",
"{",
"Set",
"<",
"InputStream",
">",
"iss",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"InputType",
"inputType",
"=",
"input",
".",
"getInputType",
"(",
")",
";",
"for",
"(",
"String",
"md",
":",
"input",
".",
"getModuleDependenciesRefsetFiles",
"(",
")",
")",
"{",
"try",
"{",
"iss",
".",
"add",
"(",
"input",
".",
"getInputStream",
"(",
"md",
")",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"|",
"IOException",
"e",
")",
"{",
"final",
"String",
"message",
"=",
"StructuredLog",
".",
"ModuleLoadFailure",
".",
"error",
"(",
"log",
",",
"inputType",
",",
"md",
",",
"e",
")",
";",
"throw",
"new",
"ImportException",
"(",
"message",
",",
"e",
")",
";",
"}",
"}",
"IModuleDependencyRefset",
"res",
"=",
"RefsetImporter",
".",
"importModuleDependencyRefset",
"(",
"iss",
")",
";",
"return",
"res",
";",
"}"
] | Loads all the module dependency information from all RF2 inputs into a single {@link IModuleDependencyRefset}.
@return
@throws ImportException | [
"Loads",
"all",
"the",
"module",
"dependency",
"information",
"from",
"all",
"RF2",
"inputs",
"into",
"a",
"single",
"{",
"@link",
"IModuleDependencyRefset",
"}",
"."
] | train | https://github.com/aehrc/ontology-core/blob/446aa691119f2bbcb8d184566084b8da7a07a44e/ontology-import/src/main/java/au/csiro/ontology/importer/rf2/RF2Importer.java#L138-L152 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLSubClassOfAxiomImpl_CustomFieldSerializer.java | OWLSubClassOfAxiomImpl_CustomFieldSerializer.deserializeInstance | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLSubClassOfAxiomImpl instance) throws SerializationException {
"""
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
"""
deserialize(streamReader, instance);
} | java | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLSubClassOfAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | [
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLSubClassOfAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] | Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful | [
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLSubClassOfAxiomImpl_CustomFieldSerializer.java#L97-L100 |
cloudant/java-cloudant | cloudant-client/src/main/java/com/cloudant/client/api/Database.java | Database.invokeUpdateHandler | public String invokeUpdateHandler(String updateHandlerUri, String docId,
Params params) {
"""
Invokes an Update Handler.
<P>Example usage:</P>
<pre>
{@code
final String newValue = "foo bar";
Params params = new Params()
.addParam("field", "title")
.addParam("value", newValue);
String output = db.invokeUpdateHandler("example/example_update", "exampleId", params);
}
</pre>
<pre>
Params params = new Params()
.addParam("field", "foo")
.addParam("value", "bar");
String output = dbClient.invokeUpdateHandler("designDoc/update1", "docId", params);
</pre>
@param updateHandlerUri The Update Handler URI, in the format: <code>designDoc/update1</code>
@param docId The document id to update.
If no id is provided, then a document will be created.
@param params The query parameters as {@link Params}.
@return The output of the request.
@see <a
href="https://console.bluemix.net/docs/services/Cloudant/api/design_documents.html#update-handlers"
target="_blank">Design documents - update handlers</a>
"""
assertNotEmpty(params, "params");
return db.invokeUpdateHandler(updateHandlerUri, docId, params.getInternalParams());
} | java | public String invokeUpdateHandler(String updateHandlerUri, String docId,
Params params) {
assertNotEmpty(params, "params");
return db.invokeUpdateHandler(updateHandlerUri, docId, params.getInternalParams());
} | [
"public",
"String",
"invokeUpdateHandler",
"(",
"String",
"updateHandlerUri",
",",
"String",
"docId",
",",
"Params",
"params",
")",
"{",
"assertNotEmpty",
"(",
"params",
",",
"\"params\"",
")",
";",
"return",
"db",
".",
"invokeUpdateHandler",
"(",
"updateHandlerUri",
",",
"docId",
",",
"params",
".",
"getInternalParams",
"(",
")",
")",
";",
"}"
] | Invokes an Update Handler.
<P>Example usage:</P>
<pre>
{@code
final String newValue = "foo bar";
Params params = new Params()
.addParam("field", "title")
.addParam("value", newValue);
String output = db.invokeUpdateHandler("example/example_update", "exampleId", params);
}
</pre>
<pre>
Params params = new Params()
.addParam("field", "foo")
.addParam("value", "bar");
String output = dbClient.invokeUpdateHandler("designDoc/update1", "docId", params);
</pre>
@param updateHandlerUri The Update Handler URI, in the format: <code>designDoc/update1</code>
@param docId The document id to update.
If no id is provided, then a document will be created.
@param params The query parameters as {@link Params}.
@return The output of the request.
@see <a
href="https://console.bluemix.net/docs/services/Cloudant/api/design_documents.html#update-handlers"
target="_blank">Design documents - update handlers</a> | [
"Invokes",
"an",
"Update",
"Handler",
".",
"<P",
">",
"Example",
"usage",
":",
"<",
"/",
"P",
">",
"<pre",
">",
"{",
"@code",
"final",
"String",
"newValue",
"=",
"foo",
"bar",
";",
"Params",
"params",
"=",
"new",
"Params",
"()",
".",
"addParam",
"(",
"field",
"title",
")",
".",
"addParam",
"(",
"value",
"newValue",
")",
";",
"String",
"output",
"=",
"db",
".",
"invokeUpdateHandler",
"(",
"example",
"/",
"example_update",
"exampleId",
"params",
")",
";"
] | train | https://github.com/cloudant/java-cloudant/blob/42c438654945361bded2cc0827afc046d535b31b/cloudant-client/src/main/java/com/cloudant/client/api/Database.java#L1378-L1382 |
riversun/d6 | src/main/java/org/riversun/d6/core/D6Crud.java | D6Crud.execSelectTable | public <T extends D6Model> T[] execSelectTable(String preparedSql, Class<T> modelClazz) {
"""
Execute select statement for the single table.
@param preparedSql
@param modelClazz
@return
"""
return execSelectTable(preparedSql, null, modelClazz);
} | java | public <T extends D6Model> T[] execSelectTable(String preparedSql, Class<T> modelClazz) {
return execSelectTable(preparedSql, null, modelClazz);
} | [
"public",
"<",
"T",
"extends",
"D6Model",
">",
"T",
"[",
"]",
"execSelectTable",
"(",
"String",
"preparedSql",
",",
"Class",
"<",
"T",
">",
"modelClazz",
")",
"{",
"return",
"execSelectTable",
"(",
"preparedSql",
",",
"null",
",",
"modelClazz",
")",
";",
"}"
] | Execute select statement for the single table.
@param preparedSql
@param modelClazz
@return | [
"Execute",
"select",
"statement",
"for",
"the",
"single",
"table",
"."
] | train | https://github.com/riversun/d6/blob/2798bd876b9380dbfea8182d11ad306cb1b0e114/src/main/java/org/riversun/d6/core/D6Crud.java#L770-L772 |
petergeneric/stdlib | guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/OAuth2SessionRef.java | OAuth2SessionRef.getAuthFlowStartEndpoint | public URI getAuthFlowStartEndpoint(final String returnTo, final String scope) {
"""
Get the endpoint to redirect a client to in order to start an OAuth2 Authorisation Flow
@param returnTo
The URI to redirect the user back to once the authorisation flow completes successfully. If not specified then the user
will be directed to the root of this webapp.
@return
"""
final String oauthServiceRoot = (oauthServiceRedirectEndpoint != null) ?
oauthServiceRedirectEndpoint :
oauthServiceEndpoint;
final String endpoint = oauthServiceRoot + "/oauth2/authorize";
UriBuilder builder = UriBuilder.fromUri(endpoint);
builder.replaceQueryParam("response_type", "code");
builder.replaceQueryParam("client_id", clientId);
builder.replaceQueryParam("redirect_uri", getOwnCallbackUri());
if (scope != null)
builder.replaceQueryParam("scope", scope);
if (returnTo != null)
builder.replaceQueryParam("state", encodeState(callbackNonce + " " + returnTo));
return builder.build();
} | java | public URI getAuthFlowStartEndpoint(final String returnTo, final String scope)
{
final String oauthServiceRoot = (oauthServiceRedirectEndpoint != null) ?
oauthServiceRedirectEndpoint :
oauthServiceEndpoint;
final String endpoint = oauthServiceRoot + "/oauth2/authorize";
UriBuilder builder = UriBuilder.fromUri(endpoint);
builder.replaceQueryParam("response_type", "code");
builder.replaceQueryParam("client_id", clientId);
builder.replaceQueryParam("redirect_uri", getOwnCallbackUri());
if (scope != null)
builder.replaceQueryParam("scope", scope);
if (returnTo != null)
builder.replaceQueryParam("state", encodeState(callbackNonce + " " + returnTo));
return builder.build();
} | [
"public",
"URI",
"getAuthFlowStartEndpoint",
"(",
"final",
"String",
"returnTo",
",",
"final",
"String",
"scope",
")",
"{",
"final",
"String",
"oauthServiceRoot",
"=",
"(",
"oauthServiceRedirectEndpoint",
"!=",
"null",
")",
"?",
"oauthServiceRedirectEndpoint",
":",
"oauthServiceEndpoint",
";",
"final",
"String",
"endpoint",
"=",
"oauthServiceRoot",
"+",
"\"/oauth2/authorize\"",
";",
"UriBuilder",
"builder",
"=",
"UriBuilder",
".",
"fromUri",
"(",
"endpoint",
")",
";",
"builder",
".",
"replaceQueryParam",
"(",
"\"response_type\"",
",",
"\"code\"",
")",
";",
"builder",
".",
"replaceQueryParam",
"(",
"\"client_id\"",
",",
"clientId",
")",
";",
"builder",
".",
"replaceQueryParam",
"(",
"\"redirect_uri\"",
",",
"getOwnCallbackUri",
"(",
")",
")",
";",
"if",
"(",
"scope",
"!=",
"null",
")",
"builder",
".",
"replaceQueryParam",
"(",
"\"scope\"",
",",
"scope",
")",
";",
"if",
"(",
"returnTo",
"!=",
"null",
")",
"builder",
".",
"replaceQueryParam",
"(",
"\"state\"",
",",
"encodeState",
"(",
"callbackNonce",
"+",
"\" \"",
"+",
"returnTo",
")",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] | Get the endpoint to redirect a client to in order to start an OAuth2 Authorisation Flow
@param returnTo
The URI to redirect the user back to once the authorisation flow completes successfully. If not specified then the user
will be directed to the root of this webapp.
@return | [
"Get",
"the",
"endpoint",
"to",
"redirect",
"a",
"client",
"to",
"in",
"order",
"to",
"start",
"an",
"OAuth2",
"Authorisation",
"Flow"
] | train | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/webapp/src/main/java/com/peterphi/std/guice/web/rest/auth/oauth2/OAuth2SessionRef.java#L140-L159 |
matthewhorridge/owlapi-gwt | owlapi-gwt-client-side-emul/src/main/java/org/semanticweb/owlapi/util/SimpleRenderer.java | SimpleRenderer.setPrefix | public void setPrefix(@Nonnull String prefixName, @Nonnull String prefix) {
"""
Sets a prefix name for a given prefix. Note that prefix names MUST end
with a colon.
@param prefixName
The prefix name (ending with a colon)
@param prefix
The prefix that the prefix name maps to
"""
if (!isUsingDefaultShortFormProvider()) {
resetShortFormProvider();
}
((DefaultPrefixManager) shortFormProvider).setPrefix(prefixName, prefix);
} | java | public void setPrefix(@Nonnull String prefixName, @Nonnull String prefix) {
if (!isUsingDefaultShortFormProvider()) {
resetShortFormProvider();
}
((DefaultPrefixManager) shortFormProvider).setPrefix(prefixName, prefix);
} | [
"public",
"void",
"setPrefix",
"(",
"@",
"Nonnull",
"String",
"prefixName",
",",
"@",
"Nonnull",
"String",
"prefix",
")",
"{",
"if",
"(",
"!",
"isUsingDefaultShortFormProvider",
"(",
")",
")",
"{",
"resetShortFormProvider",
"(",
")",
";",
"}",
"(",
"(",
"DefaultPrefixManager",
")",
"shortFormProvider",
")",
".",
"setPrefix",
"(",
"prefixName",
",",
"prefix",
")",
";",
"}"
] | Sets a prefix name for a given prefix. Note that prefix names MUST end
with a colon.
@param prefixName
The prefix name (ending with a colon)
@param prefix
The prefix that the prefix name maps to | [
"Sets",
"a",
"prefix",
"name",
"for",
"a",
"given",
"prefix",
".",
"Note",
"that",
"prefix",
"names",
"MUST",
"end",
"with",
"a",
"colon",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-client-side-emul/src/main/java/org/semanticweb/owlapi/util/SimpleRenderer.java#L74-L79 |
codelibs/fess | src/main/java/org/codelibs/fess/mylasta/action/FessMessages.java | FessMessages.addSuccessDeleteFile | public FessMessages addSuccessDeleteFile(String property, String arg0) {
"""
Add the created action message for the key 'success.delete_file' with parameters.
<pre>
message: Deleted {0} file.
</pre>
@param property The property name for the message. (NotNull)
@param arg0 The parameter arg0 for message. (NotNull)
@return this. (NotNull)
"""
assertPropertyNotNull(property);
add(property, new UserMessage(SUCCESS_delete_file, arg0));
return this;
} | java | public FessMessages addSuccessDeleteFile(String property, String arg0) {
assertPropertyNotNull(property);
add(property, new UserMessage(SUCCESS_delete_file, arg0));
return this;
} | [
"public",
"FessMessages",
"addSuccessDeleteFile",
"(",
"String",
"property",
",",
"String",
"arg0",
")",
"{",
"assertPropertyNotNull",
"(",
"property",
")",
";",
"add",
"(",
"property",
",",
"new",
"UserMessage",
"(",
"SUCCESS_delete_file",
",",
"arg0",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add the created action message for the key 'success.delete_file' with parameters.
<pre>
message: Deleted {0} file.
</pre>
@param property The property name for the message. (NotNull)
@param arg0 The parameter arg0 for message. (NotNull)
@return this. (NotNull) | [
"Add",
"the",
"created",
"action",
"message",
"for",
"the",
"key",
"success",
".",
"delete_file",
"with",
"parameters",
".",
"<pre",
">",
"message",
":",
"Deleted",
"{",
"0",
"}",
"file",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/codelibs/fess/blob/e5e4b722549d32a4958dfd94965b21937bfe64cf/src/main/java/org/codelibs/fess/mylasta/action/FessMessages.java#L2390-L2394 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java | SpoofChecker.getNumerics | private void getNumerics(String input, UnicodeSet result) {
"""
Computes the set of numerics for a string, according to UTS 39 section 5.3.
"""
result.clear();
for (int utf16Offset = 0; utf16Offset < input.length();) {
int codePoint = Character.codePointAt(input, utf16Offset);
utf16Offset += Character.charCount(codePoint);
// Store a representative character for each kind of decimal digit
if (UCharacter.getType(codePoint) == UCharacterCategory.DECIMAL_DIGIT_NUMBER) {
// Store the zero character as a representative for comparison.
// Unicode guarantees it is codePoint - value
result.add(codePoint - UCharacter.getNumericValue(codePoint));
}
}
} | java | private void getNumerics(String input, UnicodeSet result) {
result.clear();
for (int utf16Offset = 0; utf16Offset < input.length();) {
int codePoint = Character.codePointAt(input, utf16Offset);
utf16Offset += Character.charCount(codePoint);
// Store a representative character for each kind of decimal digit
if (UCharacter.getType(codePoint) == UCharacterCategory.DECIMAL_DIGIT_NUMBER) {
// Store the zero character as a representative for comparison.
// Unicode guarantees it is codePoint - value
result.add(codePoint - UCharacter.getNumericValue(codePoint));
}
}
} | [
"private",
"void",
"getNumerics",
"(",
"String",
"input",
",",
"UnicodeSet",
"result",
")",
"{",
"result",
".",
"clear",
"(",
")",
";",
"for",
"(",
"int",
"utf16Offset",
"=",
"0",
";",
"utf16Offset",
"<",
"input",
".",
"length",
"(",
")",
";",
")",
"{",
"int",
"codePoint",
"=",
"Character",
".",
"codePointAt",
"(",
"input",
",",
"utf16Offset",
")",
";",
"utf16Offset",
"+=",
"Character",
".",
"charCount",
"(",
"codePoint",
")",
";",
"// Store a representative character for each kind of decimal digit",
"if",
"(",
"UCharacter",
".",
"getType",
"(",
"codePoint",
")",
"==",
"UCharacterCategory",
".",
"DECIMAL_DIGIT_NUMBER",
")",
"{",
"// Store the zero character as a representative for comparison.",
"// Unicode guarantees it is codePoint - value",
"result",
".",
"add",
"(",
"codePoint",
"-",
"UCharacter",
".",
"getNumericValue",
"(",
"codePoint",
")",
")",
";",
"}",
"}",
"}"
] | Computes the set of numerics for a string, according to UTS 39 section 5.3. | [
"Computes",
"the",
"set",
"of",
"numerics",
"for",
"a",
"string",
"according",
"to",
"UTS",
"39",
"section",
"5",
".",
"3",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/SpoofChecker.java#L1549-L1563 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/ds/PGConnectionPoolDataSource.java | PGConnectionPoolDataSource.getPooledConnection | public PooledConnection getPooledConnection(String user, String password) throws SQLException {
"""
Gets a connection which may be pooled by the app server or middleware implementation of
DataSource.
@throws java.sql.SQLException Occurs when the physical database connection cannot be
established.
"""
return new PGPooledConnection(getConnection(user, password), defaultAutoCommit);
} | java | public PooledConnection getPooledConnection(String user, String password) throws SQLException {
return new PGPooledConnection(getConnection(user, password), defaultAutoCommit);
} | [
"public",
"PooledConnection",
"getPooledConnection",
"(",
"String",
"user",
",",
"String",
"password",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"PGPooledConnection",
"(",
"getConnection",
"(",
"user",
",",
"password",
")",
",",
"defaultAutoCommit",
")",
";",
"}"
] | Gets a connection which may be pooled by the app server or middleware implementation of
DataSource.
@throws java.sql.SQLException Occurs when the physical database connection cannot be
established. | [
"Gets",
"a",
"connection",
"which",
"may",
"be",
"pooled",
"by",
"the",
"app",
"server",
"or",
"middleware",
"implementation",
"of",
"DataSource",
"."
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/ds/PGConnectionPoolDataSource.java#L68-L70 |
rythmengine/rythmengine | src/main/java/org/rythmengine/RythmEngine.java | RythmEngine.registerTemplate | public void registerTemplate(String name, ITemplate template) {
"""
Register a tag using the given name
<p/>
<p>Not an API for user application</p>
@param name
@param template
"""
if (null == template) throw new NullPointerException();
// if (_templates.containsKey(name)) {
// return false;
// }
_templates.put(name, template);
return;
} | java | public void registerTemplate(String name, ITemplate template) {
if (null == template) throw new NullPointerException();
// if (_templates.containsKey(name)) {
// return false;
// }
_templates.put(name, template);
return;
} | [
"public",
"void",
"registerTemplate",
"(",
"String",
"name",
",",
"ITemplate",
"template",
")",
"{",
"if",
"(",
"null",
"==",
"template",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"// if (_templates.containsKey(name)) {",
"// return false;",
"// }",
"_templates",
".",
"put",
"(",
"name",
",",
"template",
")",
";",
"return",
";",
"}"
] | Register a tag using the given name
<p/>
<p>Not an API for user application</p>
@param name
@param template | [
"Register",
"a",
"tag",
"using",
"the",
"given",
"name",
"<p",
"/",
">",
"<p",
">",
"Not",
"an",
"API",
"for",
"user",
"application<",
"/",
"p",
">"
] | train | https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/RythmEngine.java#L1653-L1660 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringHelper.java | StringHelper.getUntilFirstExcl | @Nullable
public static String getUntilFirstExcl (@Nullable final String sStr, @Nullable final String sSearch) {
"""
Get everything from the string up to and excluding the first passed string.
@param sStr
The source string. May be <code>null</code>.
@param sSearch
The string to search. May be <code>null</code>.
@return <code>null</code> if the passed string does not contain the search
string. If the search string is empty, the empty string is returned.
"""
return _getUntilFirst (sStr, sSearch, false);
} | java | @Nullable
public static String getUntilFirstExcl (@Nullable final String sStr, @Nullable final String sSearch)
{
return _getUntilFirst (sStr, sSearch, false);
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getUntilFirstExcl",
"(",
"@",
"Nullable",
"final",
"String",
"sStr",
",",
"@",
"Nullable",
"final",
"String",
"sSearch",
")",
"{",
"return",
"_getUntilFirst",
"(",
"sStr",
",",
"sSearch",
",",
"false",
")",
";",
"}"
] | Get everything from the string up to and excluding the first passed string.
@param sStr
The source string. May be <code>null</code>.
@param sSearch
The string to search. May be <code>null</code>.
@return <code>null</code> if the passed string does not contain the search
string. If the search string is empty, the empty string is returned. | [
"Get",
"everything",
"from",
"the",
"string",
"up",
"to",
"and",
"excluding",
"the",
"first",
"passed",
"string",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L4818-L4822 |
opsbears/owc-dic | src/main/java/com/opsbears/webcomponents/dic/InjectorConfiguration.java | InjectorConfiguration.withScopedAlias | public <TAbstract, TImplementation extends TAbstract> InjectorConfiguration withScopedAlias(
Class scope,
Class<TAbstract> abstractDefinition,
Class<TImplementation> implementationDefinition
) {
"""
Defines that instead of the class/interface passed in abstractDefinition, the class specified in
implementationDefinition should be used. The specified replacement class must be defined as injectable.
@param abstractDefinition the abstract class or interface to replace.
@param implementationDefinition the implementation class
@param <TAbstract> type of the abstract class/interface
@param <TImplementation> type if the implementation
@return a modified copy of this injection configuration.
"""
if (abstractDefinition.equals(Injector.class)) {
throw new DependencyInjectionFailedException("Cowardly refusing to define a global alias for Injector since that would lead to a Service Locator pattern. If you need the injector, please define it on a per-class or per-method basis.");
}
//noinspection unchecked
return new InjectorConfiguration(
scopes, definedClasses,
factories,
factoryClasses,
sharedClasses,
sharedInstances,
aliases.withModified(scope, (value) -> value.with(abstractDefinition, implementationDefinition)),
collectedAliases,
namedParameterValues
);
} | java | public <TAbstract, TImplementation extends TAbstract> InjectorConfiguration withScopedAlias(
Class scope,
Class<TAbstract> abstractDefinition,
Class<TImplementation> implementationDefinition
) {
if (abstractDefinition.equals(Injector.class)) {
throw new DependencyInjectionFailedException("Cowardly refusing to define a global alias for Injector since that would lead to a Service Locator pattern. If you need the injector, please define it on a per-class or per-method basis.");
}
//noinspection unchecked
return new InjectorConfiguration(
scopes, definedClasses,
factories,
factoryClasses,
sharedClasses,
sharedInstances,
aliases.withModified(scope, (value) -> value.with(abstractDefinition, implementationDefinition)),
collectedAliases,
namedParameterValues
);
} | [
"public",
"<",
"TAbstract",
",",
"TImplementation",
"extends",
"TAbstract",
">",
"InjectorConfiguration",
"withScopedAlias",
"(",
"Class",
"scope",
",",
"Class",
"<",
"TAbstract",
">",
"abstractDefinition",
",",
"Class",
"<",
"TImplementation",
">",
"implementationDefinition",
")",
"{",
"if",
"(",
"abstractDefinition",
".",
"equals",
"(",
"Injector",
".",
"class",
")",
")",
"{",
"throw",
"new",
"DependencyInjectionFailedException",
"(",
"\"Cowardly refusing to define a global alias for Injector since that would lead to a Service Locator pattern. If you need the injector, please define it on a per-class or per-method basis.\"",
")",
";",
"}",
"//noinspection unchecked",
"return",
"new",
"InjectorConfiguration",
"(",
"scopes",
",",
"definedClasses",
",",
"factories",
",",
"factoryClasses",
",",
"sharedClasses",
",",
"sharedInstances",
",",
"aliases",
".",
"withModified",
"(",
"scope",
",",
"(",
"value",
")",
"-",
">",
"value",
".",
"with",
"(",
"abstractDefinition",
",",
"implementationDefinition",
")",
")",
",",
"collectedAliases",
",",
"namedParameterValues",
")",
";",
"}"
] | Defines that instead of the class/interface passed in abstractDefinition, the class specified in
implementationDefinition should be used. The specified replacement class must be defined as injectable.
@param abstractDefinition the abstract class or interface to replace.
@param implementationDefinition the implementation class
@param <TAbstract> type of the abstract class/interface
@param <TImplementation> type if the implementation
@return a modified copy of this injection configuration. | [
"Defines",
"that",
"instead",
"of",
"the",
"class",
"/",
"interface",
"passed",
"in",
"abstractDefinition",
"the",
"class",
"specified",
"in",
"implementationDefinition",
"should",
"be",
"used",
".",
"The",
"specified",
"replacement",
"class",
"must",
"be",
"defined",
"as",
"injectable",
"."
] | train | https://github.com/opsbears/owc-dic/blob/eb254ca993b26c299292a01598b358a31f323566/src/main/java/com/opsbears/webcomponents/dic/InjectorConfiguration.java#L914-L933 |
xwiki/xwiki-rendering | xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java | IconTransformation.mergeTree | private void mergeTree(Block targetTree, Block sourceTree) {
"""
Merged two XDOM trees.
@param targetTree the tree to merge into
@param sourceTree the tree to merge
"""
for (Block block : sourceTree.getChildren()) {
// Check if the current block exists in the target tree at the same place in the tree
int pos = indexOf(targetTree.getChildren(), block);
if (pos > -1) {
Block foundBlock = targetTree.getChildren().get(pos);
mergeTree(foundBlock, block);
} else {
targetTree.addChild(block);
}
}
} | java | private void mergeTree(Block targetTree, Block sourceTree)
{
for (Block block : sourceTree.getChildren()) {
// Check if the current block exists in the target tree at the same place in the tree
int pos = indexOf(targetTree.getChildren(), block);
if (pos > -1) {
Block foundBlock = targetTree.getChildren().get(pos);
mergeTree(foundBlock, block);
} else {
targetTree.addChild(block);
}
}
} | [
"private",
"void",
"mergeTree",
"(",
"Block",
"targetTree",
",",
"Block",
"sourceTree",
")",
"{",
"for",
"(",
"Block",
"block",
":",
"sourceTree",
".",
"getChildren",
"(",
")",
")",
"{",
"// Check if the current block exists in the target tree at the same place in the tree",
"int",
"pos",
"=",
"indexOf",
"(",
"targetTree",
".",
"getChildren",
"(",
")",
",",
"block",
")",
";",
"if",
"(",
"pos",
">",
"-",
"1",
")",
"{",
"Block",
"foundBlock",
"=",
"targetTree",
".",
"getChildren",
"(",
")",
".",
"get",
"(",
"pos",
")",
";",
"mergeTree",
"(",
"foundBlock",
",",
"block",
")",
";",
"}",
"else",
"{",
"targetTree",
".",
"addChild",
"(",
"block",
")",
";",
"}",
"}",
"}"
] | Merged two XDOM trees.
@param targetTree the tree to merge into
@param sourceTree the tree to merge | [
"Merged",
"two",
"XDOM",
"trees",
"."
] | train | https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java#L155-L167 |
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/config/DefaultGosuProfilingService.java | DefaultGosuProfilingService.completed | public void completed(long startTime, long endTime, String path, String location, int count, long waitTime) {
"""
This will log a profiling event, note that the start time and end times should have been captured
from the same clock, for example IEntityAccess.getCurrentTime().
@param startTime the start of the profiled code
@param endTime the end of the profiled code (if 0 will use IEntityAccess.getCurrentTime())
@param path the path that was taken to reach this place (A called B called C could be A->B->C)
@param location this would be the location (maybe file#linenumb)
@param count the number of times this time represented
@param waitTime any wait times that were consumed during this execution
"""
ILogger logger = CommonServices.getEntityAccess().getLogger();
if (logger.isDebugEnabled()) {
if (endTime <= 0) {
endTime = CommonServices.getEntityAccess().getCurrentTime().getTime();
}
logger.debug("At " + (endTime - _time0) + " msecs: executed '"
+ path + "' (" + location + ") "
+ (count > 1 ? count + " times " : "")
+ "in " + (endTime - startTime) + " msecs"
+ (waitTime > 0 ? " wait=" + waitTime + " msecs " : "")
);
}
} | java | public void completed(long startTime, long endTime, String path, String location, int count, long waitTime) {
ILogger logger = CommonServices.getEntityAccess().getLogger();
if (logger.isDebugEnabled()) {
if (endTime <= 0) {
endTime = CommonServices.getEntityAccess().getCurrentTime().getTime();
}
logger.debug("At " + (endTime - _time0) + " msecs: executed '"
+ path + "' (" + location + ") "
+ (count > 1 ? count + " times " : "")
+ "in " + (endTime - startTime) + " msecs"
+ (waitTime > 0 ? " wait=" + waitTime + " msecs " : "")
);
}
} | [
"public",
"void",
"completed",
"(",
"long",
"startTime",
",",
"long",
"endTime",
",",
"String",
"path",
",",
"String",
"location",
",",
"int",
"count",
",",
"long",
"waitTime",
")",
"{",
"ILogger",
"logger",
"=",
"CommonServices",
".",
"getEntityAccess",
"(",
")",
".",
"getLogger",
"(",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"if",
"(",
"endTime",
"<=",
"0",
")",
"{",
"endTime",
"=",
"CommonServices",
".",
"getEntityAccess",
"(",
")",
".",
"getCurrentTime",
"(",
")",
".",
"getTime",
"(",
")",
";",
"}",
"logger",
".",
"debug",
"(",
"\"At \"",
"+",
"(",
"endTime",
"-",
"_time0",
")",
"+",
"\" msecs: executed '\"",
"+",
"path",
"+",
"\"' (\"",
"+",
"location",
"+",
"\") \"",
"+",
"(",
"count",
">",
"1",
"?",
"count",
"+",
"\" times \"",
":",
"\"\"",
")",
"+",
"\"in \"",
"+",
"(",
"endTime",
"-",
"startTime",
")",
"+",
"\" msecs\"",
"+",
"(",
"waitTime",
">",
"0",
"?",
"\" wait=\"",
"+",
"waitTime",
"+",
"\" msecs \"",
":",
"\"\"",
")",
")",
";",
"}",
"}"
] | This will log a profiling event, note that the start time and end times should have been captured
from the same clock, for example IEntityAccess.getCurrentTime().
@param startTime the start of the profiled code
@param endTime the end of the profiled code (if 0 will use IEntityAccess.getCurrentTime())
@param path the path that was taken to reach this place (A called B called C could be A->B->C)
@param location this would be the location (maybe file#linenumb)
@param count the number of times this time represented
@param waitTime any wait times that were consumed during this execution | [
"This",
"will",
"log",
"a",
"profiling",
"event",
"note",
"that",
"the",
"start",
"time",
"and",
"end",
"times",
"should",
"have",
"been",
"captured",
"from",
"the",
"same",
"clock",
"for",
"example",
"IEntityAccess",
".",
"getCurrentTime",
"()",
"."
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/config/DefaultGosuProfilingService.java#L25-L38 |
samskivert/samskivert | src/main/java/com/samskivert/servlet/util/RequestUtils.java | RequestUtils.getServletURL | public static String getServletURL (HttpServletRequest req, String path) {
"""
Prepends the server, port and servlet context path to the supplied
path, resulting in a fully-formed URL for requesting a servlet.
"""
StringBuffer buf = req.getRequestURL();
String sname = req.getServletPath();
buf.delete(buf.length() - sname.length(), buf.length());
if (!path.startsWith("/")) {
buf.append("/");
}
buf.append(path);
return buf.toString();
} | java | public static String getServletURL (HttpServletRequest req, String path)
{
StringBuffer buf = req.getRequestURL();
String sname = req.getServletPath();
buf.delete(buf.length() - sname.length(), buf.length());
if (!path.startsWith("/")) {
buf.append("/");
}
buf.append(path);
return buf.toString();
} | [
"public",
"static",
"String",
"getServletURL",
"(",
"HttpServletRequest",
"req",
",",
"String",
"path",
")",
"{",
"StringBuffer",
"buf",
"=",
"req",
".",
"getRequestURL",
"(",
")",
";",
"String",
"sname",
"=",
"req",
".",
"getServletPath",
"(",
")",
";",
"buf",
".",
"delete",
"(",
"buf",
".",
"length",
"(",
")",
"-",
"sname",
".",
"length",
"(",
")",
",",
"buf",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"!",
"path",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"buf",
".",
"append",
"(",
"\"/\"",
")",
";",
"}",
"buf",
".",
"append",
"(",
"path",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Prepends the server, port and servlet context path to the supplied
path, resulting in a fully-formed URL for requesting a servlet. | [
"Prepends",
"the",
"server",
"port",
"and",
"servlet",
"context",
"path",
"to",
"the",
"supplied",
"path",
"resulting",
"in",
"a",
"fully",
"-",
"formed",
"URL",
"for",
"requesting",
"a",
"servlet",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/RequestUtils.java#L75-L85 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfStamper.java | PdfStamper.createSignature | public static PdfStamper createSignature(PdfReader reader, OutputStream os, char pdfVersion, File tempFile, boolean append) throws DocumentException, IOException {
"""
Applies a digital signature to a document, possibly as a new revision, making
possible multiple signatures. The returned PdfStamper
can be used normally as the signature is only applied when closing.
<p>
A possible use for adding a signature without invalidating an existing one is:
<p>
<pre>
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader("original.pdf");
FileOutputStream fout = new FileOutputStream("signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', new
File("/temp"), true);
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Lisbon");
// comment next line to have an invisible signature
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();
</pre>
@param reader the original document
@param os the output stream or <CODE>null</CODE> to keep the document in the temporary file
@param pdfVersion the new pdf version or '\0' to keep the same version as the original
document
@param tempFile location of the temporary file. If it's a directory a temporary file will be created there.
If it's a file it will be used directly. The file will be deleted on exit unless <CODE>os</CODE> is null.
In that case the document can be retrieved directly from the temporary file. If it's <CODE>null</CODE>
no temporary file will be created and memory will be used
@param append if <CODE>true</CODE> the signature and all the other content will be added as a
new revision thus not invalidating existing signatures
@return a <CODE>PdfStamper</CODE>
@throws DocumentException on error
@throws IOException on error
"""
PdfStamper stp;
if (tempFile == null) {
ByteBuffer bout = new ByteBuffer();
stp = new PdfStamper(reader, bout, pdfVersion, append);
stp.sigApp = new PdfSignatureAppearance(stp.stamper);
stp.sigApp.setSigout(bout);
}
else {
if (tempFile.isDirectory())
tempFile = File.createTempFile("pdf", null, tempFile);
FileOutputStream fout = new FileOutputStream(tempFile);
stp = new PdfStamper(reader, fout, pdfVersion, append);
stp.sigApp = new PdfSignatureAppearance(stp.stamper);
stp.sigApp.setTempFile(tempFile);
}
stp.sigApp.setOriginalout(os);
stp.sigApp.setStamper(stp);
stp.hasSignature = true;
PdfDictionary catalog = reader.getCatalog();
PdfDictionary acroForm = (PdfDictionary)PdfReader.getPdfObject(catalog.get(PdfName.ACROFORM), catalog);
if (acroForm != null) {
acroForm.remove(PdfName.NEEDAPPEARANCES);
stp.stamper.markUsed(acroForm);
}
return stp;
} | java | public static PdfStamper createSignature(PdfReader reader, OutputStream os, char pdfVersion, File tempFile, boolean append) throws DocumentException, IOException {
PdfStamper stp;
if (tempFile == null) {
ByteBuffer bout = new ByteBuffer();
stp = new PdfStamper(reader, bout, pdfVersion, append);
stp.sigApp = new PdfSignatureAppearance(stp.stamper);
stp.sigApp.setSigout(bout);
}
else {
if (tempFile.isDirectory())
tempFile = File.createTempFile("pdf", null, tempFile);
FileOutputStream fout = new FileOutputStream(tempFile);
stp = new PdfStamper(reader, fout, pdfVersion, append);
stp.sigApp = new PdfSignatureAppearance(stp.stamper);
stp.sigApp.setTempFile(tempFile);
}
stp.sigApp.setOriginalout(os);
stp.sigApp.setStamper(stp);
stp.hasSignature = true;
PdfDictionary catalog = reader.getCatalog();
PdfDictionary acroForm = (PdfDictionary)PdfReader.getPdfObject(catalog.get(PdfName.ACROFORM), catalog);
if (acroForm != null) {
acroForm.remove(PdfName.NEEDAPPEARANCES);
stp.stamper.markUsed(acroForm);
}
return stp;
} | [
"public",
"static",
"PdfStamper",
"createSignature",
"(",
"PdfReader",
"reader",
",",
"OutputStream",
"os",
",",
"char",
"pdfVersion",
",",
"File",
"tempFile",
",",
"boolean",
"append",
")",
"throws",
"DocumentException",
",",
"IOException",
"{",
"PdfStamper",
"stp",
";",
"if",
"(",
"tempFile",
"==",
"null",
")",
"{",
"ByteBuffer",
"bout",
"=",
"new",
"ByteBuffer",
"(",
")",
";",
"stp",
"=",
"new",
"PdfStamper",
"(",
"reader",
",",
"bout",
",",
"pdfVersion",
",",
"append",
")",
";",
"stp",
".",
"sigApp",
"=",
"new",
"PdfSignatureAppearance",
"(",
"stp",
".",
"stamper",
")",
";",
"stp",
".",
"sigApp",
".",
"setSigout",
"(",
"bout",
")",
";",
"}",
"else",
"{",
"if",
"(",
"tempFile",
".",
"isDirectory",
"(",
")",
")",
"tempFile",
"=",
"File",
".",
"createTempFile",
"(",
"\"pdf\"",
",",
"null",
",",
"tempFile",
")",
";",
"FileOutputStream",
"fout",
"=",
"new",
"FileOutputStream",
"(",
"tempFile",
")",
";",
"stp",
"=",
"new",
"PdfStamper",
"(",
"reader",
",",
"fout",
",",
"pdfVersion",
",",
"append",
")",
";",
"stp",
".",
"sigApp",
"=",
"new",
"PdfSignatureAppearance",
"(",
"stp",
".",
"stamper",
")",
";",
"stp",
".",
"sigApp",
".",
"setTempFile",
"(",
"tempFile",
")",
";",
"}",
"stp",
".",
"sigApp",
".",
"setOriginalout",
"(",
"os",
")",
";",
"stp",
".",
"sigApp",
".",
"setStamper",
"(",
"stp",
")",
";",
"stp",
".",
"hasSignature",
"=",
"true",
";",
"PdfDictionary",
"catalog",
"=",
"reader",
".",
"getCatalog",
"(",
")",
";",
"PdfDictionary",
"acroForm",
"=",
"(",
"PdfDictionary",
")",
"PdfReader",
".",
"getPdfObject",
"(",
"catalog",
".",
"get",
"(",
"PdfName",
".",
"ACROFORM",
")",
",",
"catalog",
")",
";",
"if",
"(",
"acroForm",
"!=",
"null",
")",
"{",
"acroForm",
".",
"remove",
"(",
"PdfName",
".",
"NEEDAPPEARANCES",
")",
";",
"stp",
".",
"stamper",
".",
"markUsed",
"(",
"acroForm",
")",
";",
"}",
"return",
"stp",
";",
"}"
] | Applies a digital signature to a document, possibly as a new revision, making
possible multiple signatures. The returned PdfStamper
can be used normally as the signature is only applied when closing.
<p>
A possible use for adding a signature without invalidating an existing one is:
<p>
<pre>
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader("original.pdf");
FileOutputStream fout = new FileOutputStream("signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', new
File("/temp"), true);
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Lisbon");
// comment next line to have an invisible signature
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();
</pre>
@param reader the original document
@param os the output stream or <CODE>null</CODE> to keep the document in the temporary file
@param pdfVersion the new pdf version or '\0' to keep the same version as the original
document
@param tempFile location of the temporary file. If it's a directory a temporary file will be created there.
If it's a file it will be used directly. The file will be deleted on exit unless <CODE>os</CODE> is null.
In that case the document can be retrieved directly from the temporary file. If it's <CODE>null</CODE>
no temporary file will be created and memory will be used
@param append if <CODE>true</CODE> the signature and all the other content will be added as a
new revision thus not invalidating existing signatures
@return a <CODE>PdfStamper</CODE>
@throws DocumentException on error
@throws IOException on error | [
"Applies",
"a",
"digital",
"signature",
"to",
"a",
"document",
"possibly",
"as",
"a",
"new",
"revision",
"making",
"possible",
"multiple",
"signatures",
".",
"The",
"returned",
"PdfStamper",
"can",
"be",
"used",
"normally",
"as",
"the",
"signature",
"is",
"only",
"applied",
"when",
"closing",
".",
"<p",
">",
"A",
"possible",
"use",
"for",
"adding",
"a",
"signature",
"without",
"invalidating",
"an",
"existing",
"one",
"is",
":",
"<p",
">",
"<pre",
">",
"KeyStore",
"ks",
"=",
"KeyStore",
".",
"getInstance",
"(",
"pkcs12",
")",
";",
"ks",
".",
"load",
"(",
"new",
"FileInputStream",
"(",
"my_private_key",
".",
"pfx",
")",
"my_password",
".",
"toCharArray",
"()",
")",
";",
"String",
"alias",
"=",
"(",
"String",
")",
"ks",
".",
"aliases",
"()",
".",
"nextElement",
"()",
";",
"PrivateKey",
"key",
"=",
"(",
"PrivateKey",
")",
"ks",
".",
"getKey",
"(",
"alias",
"my_password",
".",
"toCharArray",
"()",
")",
";",
"Certificate",
"[]",
"chain",
"=",
"ks",
".",
"getCertificateChain",
"(",
"alias",
")",
";",
"PdfReader",
"reader",
"=",
"new",
"PdfReader",
"(",
"original",
".",
"pdf",
")",
";",
"FileOutputStream",
"fout",
"=",
"new",
"FileOutputStream",
"(",
"signed",
".",
"pdf",
")",
";",
"PdfStamper",
"stp",
"=",
"PdfStamper",
".",
"createSignature",
"(",
"reader",
"fout",
"\\",
"0",
"new",
"File",
"(",
"/",
"temp",
")",
"true",
")",
";",
"PdfSignatureAppearance",
"sap",
"=",
"stp",
".",
"getSignatureAppearance",
"()",
";",
"sap",
".",
"setCrypto",
"(",
"key",
"chain",
"null",
"PdfSignatureAppearance",
".",
"WINCER_SIGNED",
")",
";",
"sap",
".",
"setReason",
"(",
"I",
"m",
"the",
"author",
")",
";",
"sap",
".",
"setLocation",
"(",
"Lisbon",
")",
";",
"//",
"comment",
"next",
"line",
"to",
"have",
"an",
"invisible",
"signature",
"sap",
".",
"setVisibleSignature",
"(",
"new",
"Rectangle",
"(",
"100",
"100",
"200",
"200",
")",
"1",
"null",
")",
";",
"stp",
".",
"close",
"()",
";",
"<",
"/",
"pre",
">"
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfStamper.java#L657-L683 |
threerings/nenya | core/src/main/java/com/threerings/media/image/ImageUtil.java | ImageUtil.createTracedImage | public static BufferedImage createTracedImage (
ImageCreator isrc, BufferedImage src, Color tcolor, int thickness) {
"""
Creates and returns a new image consisting of the supplied image traced with the given
color and thickness.
"""
return createTracedImage(isrc, src, tcolor, thickness, 1.0f, 1.0f);
} | java | public static BufferedImage createTracedImage (
ImageCreator isrc, BufferedImage src, Color tcolor, int thickness)
{
return createTracedImage(isrc, src, tcolor, thickness, 1.0f, 1.0f);
} | [
"public",
"static",
"BufferedImage",
"createTracedImage",
"(",
"ImageCreator",
"isrc",
",",
"BufferedImage",
"src",
",",
"Color",
"tcolor",
",",
"int",
"thickness",
")",
"{",
"return",
"createTracedImage",
"(",
"isrc",
",",
"src",
",",
"tcolor",
",",
"thickness",
",",
"1.0f",
",",
"1.0f",
")",
";",
"}"
] | Creates and returns a new image consisting of the supplied image traced with the given
color and thickness. | [
"Creates",
"and",
"returns",
"a",
"new",
"image",
"consisting",
"of",
"the",
"supplied",
"image",
"traced",
"with",
"the",
"given",
"color",
"and",
"thickness",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageUtil.java#L261-L265 |
box/box-android-sdk | box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiMetadata.java | BoxApiMetadata.getFolderMetadataRequest | public BoxRequestsMetadata.GetItemMetadata getFolderMetadataRequest(String id, String template) {
"""
Gets a request that retrieves the metadata for a specific template on a folder
@param id id of the folder to retrieve metadata for
@param template metadata template requested
@return request to retrieve metadata on a folder
"""
BoxRequestsMetadata.GetItemMetadata request = new BoxRequestsMetadata.GetItemMetadata(getFolderMetadataUrl(id, template), mSession);
return request;
} | java | public BoxRequestsMetadata.GetItemMetadata getFolderMetadataRequest(String id, String template) {
BoxRequestsMetadata.GetItemMetadata request = new BoxRequestsMetadata.GetItemMetadata(getFolderMetadataUrl(id, template), mSession);
return request;
} | [
"public",
"BoxRequestsMetadata",
".",
"GetItemMetadata",
"getFolderMetadataRequest",
"(",
"String",
"id",
",",
"String",
"template",
")",
"{",
"BoxRequestsMetadata",
".",
"GetItemMetadata",
"request",
"=",
"new",
"BoxRequestsMetadata",
".",
"GetItemMetadata",
"(",
"getFolderMetadataUrl",
"(",
"id",
",",
"template",
")",
",",
"mSession",
")",
";",
"return",
"request",
";",
"}"
] | Gets a request that retrieves the metadata for a specific template on a folder
@param id id of the folder to retrieve metadata for
@param template metadata template requested
@return request to retrieve metadata on a folder | [
"Gets",
"a",
"request",
"that",
"retrieves",
"the",
"metadata",
"for",
"a",
"specific",
"template",
"on",
"a",
"folder"
] | train | https://github.com/box/box-android-sdk/blob/a621ad5ddebf23067fec27529130d72718fc0e88/box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiMetadata.java#L201-L204 |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/domain/builders/CrosstabBuilder.java | CrosstabBuilder.setColumnStyles | public CrosstabBuilder setColumnStyles(Style headerStyle, Style totalStyle, Style totalHeaderStyle) {
"""
Should be called after all columns have been created
@param headerStyle
@param totalStyle
@param totalHeaderStyle
@return
"""
crosstab.setColumnHeaderStyle(headerStyle);
crosstab.setColumnTotalheaderStyle(totalHeaderStyle);
crosstab.setColumnTotalStyle(totalStyle);
return this;
} | java | public CrosstabBuilder setColumnStyles(Style headerStyle, Style totalStyle, Style totalHeaderStyle) {
crosstab.setColumnHeaderStyle(headerStyle);
crosstab.setColumnTotalheaderStyle(totalHeaderStyle);
crosstab.setColumnTotalStyle(totalStyle);
return this;
} | [
"public",
"CrosstabBuilder",
"setColumnStyles",
"(",
"Style",
"headerStyle",
",",
"Style",
"totalStyle",
",",
"Style",
"totalHeaderStyle",
")",
"{",
"crosstab",
".",
"setColumnHeaderStyle",
"(",
"headerStyle",
")",
";",
"crosstab",
".",
"setColumnTotalheaderStyle",
"(",
"totalHeaderStyle",
")",
";",
"crosstab",
".",
"setColumnTotalStyle",
"(",
"totalStyle",
")",
";",
"return",
"this",
";",
"}"
] | Should be called after all columns have been created
@param headerStyle
@param totalStyle
@param totalHeaderStyle
@return | [
"Should",
"be",
"called",
"after",
"all",
"columns",
"have",
"been",
"created"
] | train | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/builders/CrosstabBuilder.java#L399-L404 |
mnlipp/jgrapes | org.jgrapes.http/src/org/jgrapes/http/HttpServer.java | HttpServer.onPurge | @Handler(channels = NetworkChannel.class)
public void onPurge(Purge event, IOSubchannel netChannel) {
"""
Forwards a {@link Purge} event to the application channel.
@param event the event
@param netChannel the net channel
"""
LinkedIOSubchannel.downstreamChannel(this, netChannel,
WebAppMsgChannel.class).ifPresent(appChannel -> {
appChannel.handlePurge(event);
});
} | java | @Handler(channels = NetworkChannel.class)
public void onPurge(Purge event, IOSubchannel netChannel) {
LinkedIOSubchannel.downstreamChannel(this, netChannel,
WebAppMsgChannel.class).ifPresent(appChannel -> {
appChannel.handlePurge(event);
});
} | [
"@",
"Handler",
"(",
"channels",
"=",
"NetworkChannel",
".",
"class",
")",
"public",
"void",
"onPurge",
"(",
"Purge",
"event",
",",
"IOSubchannel",
"netChannel",
")",
"{",
"LinkedIOSubchannel",
".",
"downstreamChannel",
"(",
"this",
",",
"netChannel",
",",
"WebAppMsgChannel",
".",
"class",
")",
".",
"ifPresent",
"(",
"appChannel",
"->",
"{",
"appChannel",
".",
"handlePurge",
"(",
"event",
")",
";",
"}",
")",
";",
"}"
] | Forwards a {@link Purge} event to the application channel.
@param event the event
@param netChannel the net channel | [
"Forwards",
"a",
"{",
"@link",
"Purge",
"}",
"event",
"to",
"the",
"application",
"channel",
"."
] | train | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http/src/org/jgrapes/http/HttpServer.java#L284-L290 |
igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java | StringUtils.requireNotNullNorEmpty | public static <CS extends CharSequence> CS requireNotNullNorEmpty(CS cs, String message) {
"""
Require a {@link CharSequence} to be neither null, nor empty.
@param cs CharSequence
@param message error message
@param <CS> CharSequence type
@return cs
"""
if (isNullOrEmpty(cs)) {
throw new IllegalArgumentException(message);
}
return cs;
} | java | public static <CS extends CharSequence> CS requireNotNullNorEmpty(CS cs, String message) {
if (isNullOrEmpty(cs)) {
throw new IllegalArgumentException(message);
}
return cs;
} | [
"public",
"static",
"<",
"CS",
"extends",
"CharSequence",
">",
"CS",
"requireNotNullNorEmpty",
"(",
"CS",
"cs",
",",
"String",
"message",
")",
"{",
"if",
"(",
"isNullOrEmpty",
"(",
"cs",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"return",
"cs",
";",
"}"
] | Require a {@link CharSequence} to be neither null, nor empty.
@param cs CharSequence
@param message error message
@param <CS> CharSequence type
@return cs | [
"Require",
"a",
"{",
"@link",
"CharSequence",
"}",
"to",
"be",
"neither",
"null",
"nor",
"empty",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java#L449-L454 |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.insertArg | public Signature insertArg(String beforeName, String name, Class<?> type) {
"""
Insert an argument (name + type) into the signature before the argument
with the given name.
@param beforeName the name of the argument before which to insert
@param name the name of the new argument
@param type the type of the new argument
@return a new signature with the added arguments
"""
return insertArgs(argOffset(beforeName), new String[]{name}, new Class<?>[]{type});
} | java | public Signature insertArg(String beforeName, String name, Class<?> type) {
return insertArgs(argOffset(beforeName), new String[]{name}, new Class<?>[]{type});
} | [
"public",
"Signature",
"insertArg",
"(",
"String",
"beforeName",
",",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"insertArgs",
"(",
"argOffset",
"(",
"beforeName",
")",
",",
"new",
"String",
"[",
"]",
"{",
"name",
"}",
",",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"type",
"}",
")",
";",
"}"
] | Insert an argument (name + type) into the signature before the argument
with the given name.
@param beforeName the name of the argument before which to insert
@param name the name of the new argument
@param type the type of the new argument
@return a new signature with the added arguments | [
"Insert",
"an",
"argument",
"(",
"name",
"+",
"type",
")",
"into",
"the",
"signature",
"before",
"the",
"argument",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L263-L265 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java | ElementsExceptionsFactory.newResourceNotFoundException | public static ResourceNotFoundException newResourceNotFoundException(Throwable cause,
String message, Object... args) {
"""
Constructs and initializes a new {@link ResourceNotFoundException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link ResourceNotFoundException} was thrown.
@param message {@link String} describing the {@link ResourceNotFoundException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link ResourceNotFoundException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.lang.ResourceNotFoundException
"""
return new ResourceNotFoundException(format(message, args), cause);
} | java | public static ResourceNotFoundException newResourceNotFoundException(Throwable cause,
String message, Object... args) {
return new ResourceNotFoundException(format(message, args), cause);
} | [
"public",
"static",
"ResourceNotFoundException",
"newResourceNotFoundException",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"ResourceNotFoundException",
"(",
"format",
"(",
"message",
",",
"args",
")",
",",
"cause",
")",
";",
"}"
] | Constructs and initializes a new {@link ResourceNotFoundException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link ResourceNotFoundException} was thrown.
@param message {@link String} describing the {@link ResourceNotFoundException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link ResourceNotFoundException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.lang.ResourceNotFoundException | [
"Constructs",
"and",
"initializes",
"a",
"new",
"{",
"@link",
"ResourceNotFoundException",
"}",
"with",
"the",
"given",
"{",
"@link",
"Throwable",
"cause",
"}",
"and",
"{",
"@link",
"String",
"message",
"}",
"formatted",
"with",
"the",
"given",
"{",
"@link",
"Object",
"[]",
"arguments",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java#L509-L513 |
snowflakedb/snowflake-jdbc | src/main/java/net/snowflake/client/core/SFStatement.java | SFStatement.addProperty | public void addProperty(String propertyName, Object propertyValue)
throws SFException {
"""
Add a statement parameter
<p>
Make sure a property is not added more than once and the number of
properties does not exceed limit.
@param propertyName property name
@param propertyValue property value
@throws SFException if too many parameters for a statement
"""
statementParametersMap.put(propertyName, propertyValue);
// for query timeout, we implement it on client side for now
if ("query_timeout".equalsIgnoreCase(propertyName))
{
queryTimeout = (Integer) propertyValue;
}
// check if the number of session properties exceed limit
if (statementParametersMap.size() > MAX_STATEMENT_PARAMETERS)
{
throw new SFException(
ErrorCode.TOO_MANY_STATEMENT_PARAMETERS, MAX_STATEMENT_PARAMETERS);
}
} | java | public void addProperty(String propertyName, Object propertyValue)
throws SFException
{
statementParametersMap.put(propertyName, propertyValue);
// for query timeout, we implement it on client side for now
if ("query_timeout".equalsIgnoreCase(propertyName))
{
queryTimeout = (Integer) propertyValue;
}
// check if the number of session properties exceed limit
if (statementParametersMap.size() > MAX_STATEMENT_PARAMETERS)
{
throw new SFException(
ErrorCode.TOO_MANY_STATEMENT_PARAMETERS, MAX_STATEMENT_PARAMETERS);
}
} | [
"public",
"void",
"addProperty",
"(",
"String",
"propertyName",
",",
"Object",
"propertyValue",
")",
"throws",
"SFException",
"{",
"statementParametersMap",
".",
"put",
"(",
"propertyName",
",",
"propertyValue",
")",
";",
"// for query timeout, we implement it on client side for now",
"if",
"(",
"\"query_timeout\"",
".",
"equalsIgnoreCase",
"(",
"propertyName",
")",
")",
"{",
"queryTimeout",
"=",
"(",
"Integer",
")",
"propertyValue",
";",
"}",
"// check if the number of session properties exceed limit",
"if",
"(",
"statementParametersMap",
".",
"size",
"(",
")",
">",
"MAX_STATEMENT_PARAMETERS",
")",
"{",
"throw",
"new",
"SFException",
"(",
"ErrorCode",
".",
"TOO_MANY_STATEMENT_PARAMETERS",
",",
"MAX_STATEMENT_PARAMETERS",
")",
";",
"}",
"}"
] | Add a statement parameter
<p>
Make sure a property is not added more than once and the number of
properties does not exceed limit.
@param propertyName property name
@param propertyValue property value
@throws SFException if too many parameters for a statement | [
"Add",
"a",
"statement",
"parameter",
"<p",
">",
"Make",
"sure",
"a",
"property",
"is",
"not",
"added",
"more",
"than",
"once",
"and",
"the",
"number",
"of",
"properties",
"does",
"not",
"exceed",
"limit",
"."
] | train | https://github.com/snowflakedb/snowflake-jdbc/blob/98567b5a57753f29d51446809640b969a099658f/src/main/java/net/snowflake/client/core/SFStatement.java#L101-L118 |
jmeetsma/Iglu-Util | src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java | StringSupport.getRootStackTrace | public static String getRootStackTrace(Throwable t, int depth) {
"""
Retrieves stack trace from throwable.
@param t
@param depth
@return
"""
while(t.getCause() != null) {
t = t.getCause();
}
return getStackTrace(t, depth, null);
} | java | public static String getRootStackTrace(Throwable t, int depth) {
while(t.getCause() != null) {
t = t.getCause();
}
return getStackTrace(t, depth, null);
} | [
"public",
"static",
"String",
"getRootStackTrace",
"(",
"Throwable",
"t",
",",
"int",
"depth",
")",
"{",
"while",
"(",
"t",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"t",
"=",
"t",
".",
"getCause",
"(",
")",
";",
"}",
"return",
"getStackTrace",
"(",
"t",
",",
"depth",
",",
"null",
")",
";",
"}"
] | Retrieves stack trace from throwable.
@param t
@param depth
@return | [
"Retrieves",
"stack",
"trace",
"from",
"throwable",
"."
] | train | https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/misc/StringSupport.java#L960-L966 |
taskadapter/redmine-java-api | src/main/java/com/taskadapter/redmineapi/RedmineManagerFactory.java | RedmineManagerFactory.createUnauthenticated | public static RedmineManager createUnauthenticated(String uri,
HttpClient httpClient) {
"""
Creates a non-authenticating redmine manager.
@param uri redmine manager URI.
@param httpClient you can provide your own pre-configured HttpClient if you want
to control connection pooling, manage connections eviction, closing, etc.
"""
return createWithUserAuth(uri, null, null, httpClient);
} | java | public static RedmineManager createUnauthenticated(String uri,
HttpClient httpClient) {
return createWithUserAuth(uri, null, null, httpClient);
} | [
"public",
"static",
"RedmineManager",
"createUnauthenticated",
"(",
"String",
"uri",
",",
"HttpClient",
"httpClient",
")",
"{",
"return",
"createWithUserAuth",
"(",
"uri",
",",
"null",
",",
"null",
",",
"httpClient",
")",
";",
"}"
] | Creates a non-authenticating redmine manager.
@param uri redmine manager URI.
@param httpClient you can provide your own pre-configured HttpClient if you want
to control connection pooling, manage connections eviction, closing, etc. | [
"Creates",
"a",
"non",
"-",
"authenticating",
"redmine",
"manager",
"."
] | train | https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/RedmineManagerFactory.java#L75-L78 |
JOML-CI/JOML | src/org/joml/Intersectionf.java | Intersectionf.findClosestPointOnTriangle | public static int findClosestPointOnTriangle(Vector2fc v0, Vector2fc v1, Vector2fc v2, Vector2fc p, Vector2f result) {
"""
Determine the closest point on the triangle with the vertices <code>v0</code>, <code>v1</code>, <code>v2</code>
between that triangle and the given point <code>p</code> and store that point into the given <code>result</code>.
<p>
Additionally, this method returns whether the closest point is a vertex ({@link #POINT_ON_TRIANGLE_VERTEX_0}, {@link #POINT_ON_TRIANGLE_VERTEX_1}, {@link #POINT_ON_TRIANGLE_VERTEX_2})
of the triangle, lies on an edge ({@link #POINT_ON_TRIANGLE_EDGE_01}, {@link #POINT_ON_TRIANGLE_EDGE_12}, {@link #POINT_ON_TRIANGLE_EDGE_20})
or on the {@link #POINT_ON_TRIANGLE_FACE face} of the triangle.
<p>
Reference: Book "Real-Time Collision Detection" chapter 5.1.5 "Closest Point on Triangle to Point"
@param v0
the first vertex of the triangle
@param v1
the second vertex of the triangle
@param v2
the third vertex of the triangle
@param p
the point
@param result
will hold the closest point
@return one of {@link #POINT_ON_TRIANGLE_VERTEX_0}, {@link #POINT_ON_TRIANGLE_VERTEX_1}, {@link #POINT_ON_TRIANGLE_VERTEX_2},
{@link #POINT_ON_TRIANGLE_EDGE_01}, {@link #POINT_ON_TRIANGLE_EDGE_12}, {@link #POINT_ON_TRIANGLE_EDGE_20} or
{@link #POINT_ON_TRIANGLE_FACE}
"""
return findClosestPointOnTriangle(v0.x(), v0.y(), v1.x(), v1.y(), v2.x(), v2.y(), p.x(), p.y(), result);
} | java | public static int findClosestPointOnTriangle(Vector2fc v0, Vector2fc v1, Vector2fc v2, Vector2fc p, Vector2f result) {
return findClosestPointOnTriangle(v0.x(), v0.y(), v1.x(), v1.y(), v2.x(), v2.y(), p.x(), p.y(), result);
} | [
"public",
"static",
"int",
"findClosestPointOnTriangle",
"(",
"Vector2fc",
"v0",
",",
"Vector2fc",
"v1",
",",
"Vector2fc",
"v2",
",",
"Vector2fc",
"p",
",",
"Vector2f",
"result",
")",
"{",
"return",
"findClosestPointOnTriangle",
"(",
"v0",
".",
"x",
"(",
")",
",",
"v0",
".",
"y",
"(",
")",
",",
"v1",
".",
"x",
"(",
")",
",",
"v1",
".",
"y",
"(",
")",
",",
"v2",
".",
"x",
"(",
")",
",",
"v2",
".",
"y",
"(",
")",
",",
"p",
".",
"x",
"(",
")",
",",
"p",
".",
"y",
"(",
")",
",",
"result",
")",
";",
"}"
] | Determine the closest point on the triangle with the vertices <code>v0</code>, <code>v1</code>, <code>v2</code>
between that triangle and the given point <code>p</code> and store that point into the given <code>result</code>.
<p>
Additionally, this method returns whether the closest point is a vertex ({@link #POINT_ON_TRIANGLE_VERTEX_0}, {@link #POINT_ON_TRIANGLE_VERTEX_1}, {@link #POINT_ON_TRIANGLE_VERTEX_2})
of the triangle, lies on an edge ({@link #POINT_ON_TRIANGLE_EDGE_01}, {@link #POINT_ON_TRIANGLE_EDGE_12}, {@link #POINT_ON_TRIANGLE_EDGE_20})
or on the {@link #POINT_ON_TRIANGLE_FACE face} of the triangle.
<p>
Reference: Book "Real-Time Collision Detection" chapter 5.1.5 "Closest Point on Triangle to Point"
@param v0
the first vertex of the triangle
@param v1
the second vertex of the triangle
@param v2
the third vertex of the triangle
@param p
the point
@param result
will hold the closest point
@return one of {@link #POINT_ON_TRIANGLE_VERTEX_0}, {@link #POINT_ON_TRIANGLE_VERTEX_1}, {@link #POINT_ON_TRIANGLE_VERTEX_2},
{@link #POINT_ON_TRIANGLE_EDGE_01}, {@link #POINT_ON_TRIANGLE_EDGE_12}, {@link #POINT_ON_TRIANGLE_EDGE_20} or
{@link #POINT_ON_TRIANGLE_FACE} | [
"Determine",
"the",
"closest",
"point",
"on",
"the",
"triangle",
"with",
"the",
"vertices",
"<code",
">",
"v0<",
"/",
"code",
">",
"<code",
">",
"v1<",
"/",
"code",
">",
"<code",
">",
"v2<",
"/",
"code",
">",
"between",
"that",
"triangle",
"and",
"the",
"given",
"point",
"<code",
">",
"p<",
"/",
"code",
">",
"and",
"store",
"that",
"point",
"into",
"the",
"given",
"<code",
">",
"result<",
"/",
"code",
">",
".",
"<p",
">",
"Additionally",
"this",
"method",
"returns",
"whether",
"the",
"closest",
"point",
"is",
"a",
"vertex",
"(",
"{",
"@link",
"#POINT_ON_TRIANGLE_VERTEX_0",
"}",
"{",
"@link",
"#POINT_ON_TRIANGLE_VERTEX_1",
"}",
"{",
"@link",
"#POINT_ON_TRIANGLE_VERTEX_2",
"}",
")",
"of",
"the",
"triangle",
"lies",
"on",
"an",
"edge",
"(",
"{",
"@link",
"#POINT_ON_TRIANGLE_EDGE_01",
"}",
"{",
"@link",
"#POINT_ON_TRIANGLE_EDGE_12",
"}",
"{",
"@link",
"#POINT_ON_TRIANGLE_EDGE_20",
"}",
")",
"or",
"on",
"the",
"{",
"@link",
"#POINT_ON_TRIANGLE_FACE",
"face",
"}",
"of",
"the",
"triangle",
".",
"<p",
">",
"Reference",
":",
"Book",
"Real",
"-",
"Time",
"Collision",
"Detection",
"chapter",
"5",
".",
"1",
".",
"5",
"Closest",
"Point",
"on",
"Triangle",
"to",
"Point"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Intersectionf.java#L4192-L4194 |
GoogleCloudPlatform/appengine-pipelines | java/src/main/java/com/google/appengine/tools/pipeline/impl/model/Barrier.java | Barrier.getEgParentKey | private static Key getEgParentKey(Type type, Key jobKey) {
"""
Returns the entity group parent of a Barrier of the specified type.
<p>
According to our <a href="http://goto/java-pipeline-model">transactional
model</a>: If B is the finalize barrier of a Job J, then the entity group
parent of B is J. Run barriers do not have an entity group parent.
"""
switch (type) {
case RUN:
return null;
case FINALIZE:
if (null == jobKey) {
throw new IllegalArgumentException("jobKey is null");
}
break;
}
return jobKey;
} | java | private static Key getEgParentKey(Type type, Key jobKey) {
switch (type) {
case RUN:
return null;
case FINALIZE:
if (null == jobKey) {
throw new IllegalArgumentException("jobKey is null");
}
break;
}
return jobKey;
} | [
"private",
"static",
"Key",
"getEgParentKey",
"(",
"Type",
"type",
",",
"Key",
"jobKey",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"RUN",
":",
"return",
"null",
";",
"case",
"FINALIZE",
":",
"if",
"(",
"null",
"==",
"jobKey",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"jobKey is null\"",
")",
";",
"}",
"break",
";",
"}",
"return",
"jobKey",
";",
"}"
] | Returns the entity group parent of a Barrier of the specified type.
<p>
According to our <a href="http://goto/java-pipeline-model">transactional
model</a>: If B is the finalize barrier of a Job J, then the entity group
parent of B is J. Run barriers do not have an entity group parent. | [
"Returns",
"the",
"entity",
"group",
"parent",
"of",
"a",
"Barrier",
"of",
"the",
"specified",
"type",
".",
"<p",
">",
"According",
"to",
"our",
"<a",
"href",
"=",
"http",
":",
"//",
"goto",
"/",
"java",
"-",
"pipeline",
"-",
"model",
">",
"transactional",
"model<",
"/",
"a",
">",
":",
"If",
"B",
"is",
"the",
"finalize",
"barrier",
"of",
"a",
"Job",
"J",
"then",
"the",
"entity",
"group",
"parent",
"of",
"B",
"is",
"J",
".",
"Run",
"barriers",
"do",
"not",
"have",
"an",
"entity",
"group",
"parent",
"."
] | train | https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/java/src/main/java/com/google/appengine/tools/pipeline/impl/model/Barrier.java#L82-L93 |
ngageoint/geopackage-android-map | geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeConverter.java | GoogleMapShapeConverter.toMultiLineStringFromOptions | public MultiLineString toMultiLineStringFromOptions(
MultiPolylineOptions multiPolylineOptions, boolean hasZ,
boolean hasM) {
"""
Convert a {@link MultiPolylineOptions} to a {@link MultiLineString}
@param multiPolylineOptions multi polyline options
@param hasZ has z flag
@param hasM has m flag
@return multi line string
"""
MultiLineString multiLineString = new MultiLineString(hasZ, hasM);
for (PolylineOptions polyline : multiPolylineOptions
.getPolylineOptions()) {
LineString lineString = toLineString(polyline);
multiLineString.addLineString(lineString);
}
return multiLineString;
} | java | public MultiLineString toMultiLineStringFromOptions(
MultiPolylineOptions multiPolylineOptions, boolean hasZ,
boolean hasM) {
MultiLineString multiLineString = new MultiLineString(hasZ, hasM);
for (PolylineOptions polyline : multiPolylineOptions
.getPolylineOptions()) {
LineString lineString = toLineString(polyline);
multiLineString.addLineString(lineString);
}
return multiLineString;
} | [
"public",
"MultiLineString",
"toMultiLineStringFromOptions",
"(",
"MultiPolylineOptions",
"multiPolylineOptions",
",",
"boolean",
"hasZ",
",",
"boolean",
"hasM",
")",
"{",
"MultiLineString",
"multiLineString",
"=",
"new",
"MultiLineString",
"(",
"hasZ",
",",
"hasM",
")",
";",
"for",
"(",
"PolylineOptions",
"polyline",
":",
"multiPolylineOptions",
".",
"getPolylineOptions",
"(",
")",
")",
"{",
"LineString",
"lineString",
"=",
"toLineString",
"(",
"polyline",
")",
";",
"multiLineString",
".",
"addLineString",
"(",
"lineString",
")",
";",
"}",
"return",
"multiLineString",
";",
"}"
] | Convert a {@link MultiPolylineOptions} to a {@link MultiLineString}
@param multiPolylineOptions multi polyline options
@param hasZ has z flag
@param hasM has m flag
@return multi line string | [
"Convert",
"a",
"{",
"@link",
"MultiPolylineOptions",
"}",
"to",
"a",
"{",
"@link",
"MultiLineString",
"}"
] | train | https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeConverter.java#L935-L948 |
apache/flink | flink-core/src/main/java/org/apache/flink/util/StringUtils.java | StringUtils.getRandomString | public static String getRandomString(Random rnd, int minLength, int maxLength, char minValue, char maxValue) {
"""
Creates a random string with a length within the given interval. The string contains only characters that
can be represented as a single code point.
@param rnd The random used to create the strings.
@param minLength The minimum string length.
@param maxLength The maximum string length (inclusive).
@param minValue The minimum character value to occur.
@param maxValue The maximum character value to occur.
@return A random String.
"""
int len = rnd.nextInt(maxLength - minLength + 1) + minLength;
char[] data = new char[len];
int diff = maxValue - minValue + 1;
for (int i = 0; i < data.length; i++) {
data[i] = (char) (rnd.nextInt(diff) + minValue);
}
return new String(data);
} | java | public static String getRandomString(Random rnd, int minLength, int maxLength, char minValue, char maxValue) {
int len = rnd.nextInt(maxLength - minLength + 1) + minLength;
char[] data = new char[len];
int diff = maxValue - minValue + 1;
for (int i = 0; i < data.length; i++) {
data[i] = (char) (rnd.nextInt(diff) + minValue);
}
return new String(data);
} | [
"public",
"static",
"String",
"getRandomString",
"(",
"Random",
"rnd",
",",
"int",
"minLength",
",",
"int",
"maxLength",
",",
"char",
"minValue",
",",
"char",
"maxValue",
")",
"{",
"int",
"len",
"=",
"rnd",
".",
"nextInt",
"(",
"maxLength",
"-",
"minLength",
"+",
"1",
")",
"+",
"minLength",
";",
"char",
"[",
"]",
"data",
"=",
"new",
"char",
"[",
"len",
"]",
";",
"int",
"diff",
"=",
"maxValue",
"-",
"minValue",
"+",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"++",
")",
"{",
"data",
"[",
"i",
"]",
"=",
"(",
"char",
")",
"(",
"rnd",
".",
"nextInt",
"(",
"diff",
")",
"+",
"minValue",
")",
";",
"}",
"return",
"new",
"String",
"(",
"data",
")",
";",
"}"
] | Creates a random string with a length within the given interval. The string contains only characters that
can be represented as a single code point.
@param rnd The random used to create the strings.
@param minLength The minimum string length.
@param maxLength The maximum string length (inclusive).
@param minValue The minimum character value to occur.
@param maxValue The maximum character value to occur.
@return A random String. | [
"Creates",
"a",
"random",
"string",
"with",
"a",
"length",
"within",
"the",
"given",
"interval",
".",
"The",
"string",
"contains",
"only",
"characters",
"that",
"can",
"be",
"represented",
"as",
"a",
"single",
"code",
"point",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/StringUtils.java#L240-L250 |
dkpro/dkpro-jwpl | de.tudarmstadt.ukp.wikipedia.api/src/main/java/de/tudarmstadt/ukp/wikipedia/api/CategoryGraph.java | CategoryGraph.getPathLengthInNodes | public int getPathLengthInNodes(Category node1, Category node2) throws WikiApiException {
"""
Gets the path length between two category nodes - measured in "nodes".
@param node1 The first node.
@param node2 The second node.
@return The number of nodes of the path between node1 and node2. 0, if the nodes are identical or neighbors. -1, if no path exists.
"""
int retValue = getPathLengthInEdges(node1, node2);
if (retValue == 0) {
return 0;
}
else if (retValue > 0) {
return (--retValue);
}
else if (retValue == -1) {
return -1;
}
else {
throw new WikiApiException("Unknown return value.");
}
} | java | public int getPathLengthInNodes(Category node1, Category node2) throws WikiApiException {
int retValue = getPathLengthInEdges(node1, node2);
if (retValue == 0) {
return 0;
}
else if (retValue > 0) {
return (--retValue);
}
else if (retValue == -1) {
return -1;
}
else {
throw new WikiApiException("Unknown return value.");
}
} | [
"public",
"int",
"getPathLengthInNodes",
"(",
"Category",
"node1",
",",
"Category",
"node2",
")",
"throws",
"WikiApiException",
"{",
"int",
"retValue",
"=",
"getPathLengthInEdges",
"(",
"node1",
",",
"node2",
")",
";",
"if",
"(",
"retValue",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"retValue",
">",
"0",
")",
"{",
"return",
"(",
"--",
"retValue",
")",
";",
"}",
"else",
"if",
"(",
"retValue",
"==",
"-",
"1",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"{",
"throw",
"new",
"WikiApiException",
"(",
"\"Unknown return value.\"",
")",
";",
"}",
"}"
] | Gets the path length between two category nodes - measured in "nodes".
@param node1 The first node.
@param node2 The second node.
@return The number of nodes of the path between node1 and node2. 0, if the nodes are identical or neighbors. -1, if no path exists. | [
"Gets",
"the",
"path",
"length",
"between",
"two",
"category",
"nodes",
"-",
"measured",
"in",
"nodes",
"."
] | train | https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.api/src/main/java/de/tudarmstadt/ukp/wikipedia/api/CategoryGraph.java#L779-L795 |
sebastiangraf/jSCSI | bundles/targetExtensions/scsi/src/org/jscsi/scsi/tasks/management/DefaultTaskSet.java | DefaultTaskSet.poll | public Task poll(long timeout, TimeUnit unit) throws InterruptedException {
"""
Retrieves and removes the task at the head of the queue. Blocks on both an empty set and all
blocking boundaries specified in SAM-2.
<p>
The maximum wait time is twice the timeout. This occurs because first we wait for the set to
be not empty, then we wait for the task to be unblocked.
"""
lock.lockInterruptibly();
try
{
// wait for the set to be not empty
timeout = unit.toNanos(timeout);
while (this.dormant.size() == 0)
{
_logger.trace("Task set empty; waiting for new task to be added");
if (timeout > 0)
{
// "notEmpty" is notified whenever a task is added to the set
timeout = notEmpty.awaitNanos(timeout);
}
else
{
return null;
}
}
// wait until the next task is not blocked
while (this.blocked(this.dormant.get(0)))
{
_logger.trace("Next task blocked; waiting for other tasks to finish");
if (timeout > 0)
{
// "unblocked" is notified whenever a task is finished or a new task is
// added to the set. We wait on that before checking if this task is still
// blocked.
timeout = unblocked.awaitNanos(timeout);
}
else
{
return null; // a timeout occurred
}
}
TaskContainer container = this.dormant.remove(0);
this.enabled.add(container);
if (_logger.isDebugEnabled())
{
_logger.debug("Enabling command: " + container.getCommand());
_logger.debug("Dormant task set: " + this.dormant);
}
return container;
}
finally
{
lock.unlock();
}
} | java | public Task poll(long timeout, TimeUnit unit) throws InterruptedException
{
lock.lockInterruptibly();
try
{
// wait for the set to be not empty
timeout = unit.toNanos(timeout);
while (this.dormant.size() == 0)
{
_logger.trace("Task set empty; waiting for new task to be added");
if (timeout > 0)
{
// "notEmpty" is notified whenever a task is added to the set
timeout = notEmpty.awaitNanos(timeout);
}
else
{
return null;
}
}
// wait until the next task is not blocked
while (this.blocked(this.dormant.get(0)))
{
_logger.trace("Next task blocked; waiting for other tasks to finish");
if (timeout > 0)
{
// "unblocked" is notified whenever a task is finished or a new task is
// added to the set. We wait on that before checking if this task is still
// blocked.
timeout = unblocked.awaitNanos(timeout);
}
else
{
return null; // a timeout occurred
}
}
TaskContainer container = this.dormant.remove(0);
this.enabled.add(container);
if (_logger.isDebugEnabled())
{
_logger.debug("Enabling command: " + container.getCommand());
_logger.debug("Dormant task set: " + this.dormant);
}
return container;
}
finally
{
lock.unlock();
}
} | [
"public",
"Task",
"poll",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"lock",
".",
"lockInterruptibly",
"(",
")",
";",
"try",
"{",
"// wait for the set to be not empty\r",
"timeout",
"=",
"unit",
".",
"toNanos",
"(",
"timeout",
")",
";",
"while",
"(",
"this",
".",
"dormant",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"_logger",
".",
"trace",
"(",
"\"Task set empty; waiting for new task to be added\"",
")",
";",
"if",
"(",
"timeout",
">",
"0",
")",
"{",
"// \"notEmpty\" is notified whenever a task is added to the set\r",
"timeout",
"=",
"notEmpty",
".",
"awaitNanos",
"(",
"timeout",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"// wait until the next task is not blocked\r",
"while",
"(",
"this",
".",
"blocked",
"(",
"this",
".",
"dormant",
".",
"get",
"(",
"0",
")",
")",
")",
"{",
"_logger",
".",
"trace",
"(",
"\"Next task blocked; waiting for other tasks to finish\"",
")",
";",
"if",
"(",
"timeout",
">",
"0",
")",
"{",
"// \"unblocked\" is notified whenever a task is finished or a new task is\r",
"// added to the set. We wait on that before checking if this task is still\r",
"// blocked.\r",
"timeout",
"=",
"unblocked",
".",
"awaitNanos",
"(",
"timeout",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"// a timeout occurred\r",
"}",
"}",
"TaskContainer",
"container",
"=",
"this",
".",
"dormant",
".",
"remove",
"(",
"0",
")",
";",
"this",
".",
"enabled",
".",
"add",
"(",
"container",
")",
";",
"if",
"(",
"_logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"_logger",
".",
"debug",
"(",
"\"Enabling command: \"",
"+",
"container",
".",
"getCommand",
"(",
")",
")",
";",
"_logger",
".",
"debug",
"(",
"\"Dormant task set: \"",
"+",
"this",
".",
"dormant",
")",
";",
"}",
"return",
"container",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Retrieves and removes the task at the head of the queue. Blocks on both an empty set and all
blocking boundaries specified in SAM-2.
<p>
The maximum wait time is twice the timeout. This occurs because first we wait for the set to
be not empty, then we wait for the task to be unblocked. | [
"Retrieves",
"and",
"removes",
"the",
"task",
"at",
"the",
"head",
"of",
"the",
"queue",
".",
"Blocks",
"on",
"both",
"an",
"empty",
"set",
"and",
"all",
"blocking",
"boundaries",
"specified",
"in",
"SAM",
"-",
"2",
".",
"<p",
">",
"The",
"maximum",
"wait",
"time",
"is",
"twice",
"the",
"timeout",
".",
"This",
"occurs",
"because",
"first",
"we",
"wait",
"for",
"the",
"set",
"to",
"be",
"not",
"empty",
"then",
"we",
"wait",
"for",
"the",
"task",
"to",
"be",
"unblocked",
"."
] | train | https://github.com/sebastiangraf/jSCSI/blob/6169bfe73f0b15de7d6485453555389e782ae888/bundles/targetExtensions/scsi/src/org/jscsi/scsi/tasks/management/DefaultTaskSet.java#L350-L404 |
saxsys/SynchronizeFX | transmitter/websocket-transmitter/src/main/java/de/saxsys/synchronizefx/websocket/SychronizeFXWebsocketServer.java | SychronizeFXWebsocketServer.onOpen | public void onOpen(final Session session, final String channelName) {
"""
Pass {@link OnOpen} events of the Websocket API to this method to handle new clients.
@param session The client that has connected.
@param channelName The name of the channel this client connected too.
@throws IllegalArgumentException If the channel passed as argument does not exist.
"""
final SynchronizeFXWebsocketChannel channel;
synchronized (channels) {
channel = getChannelOrFail(channelName);
clients.put(session, channel);
}
channel.newClient(session);
} | java | public void onOpen(final Session session, final String channelName) {
final SynchronizeFXWebsocketChannel channel;
synchronized (channels) {
channel = getChannelOrFail(channelName);
clients.put(session, channel);
}
channel.newClient(session);
} | [
"public",
"void",
"onOpen",
"(",
"final",
"Session",
"session",
",",
"final",
"String",
"channelName",
")",
"{",
"final",
"SynchronizeFXWebsocketChannel",
"channel",
";",
"synchronized",
"(",
"channels",
")",
"{",
"channel",
"=",
"getChannelOrFail",
"(",
"channelName",
")",
";",
"clients",
".",
"put",
"(",
"session",
",",
"channel",
")",
";",
"}",
"channel",
".",
"newClient",
"(",
"session",
")",
";",
"}"
] | Pass {@link OnOpen} events of the Websocket API to this method to handle new clients.
@param session The client that has connected.
@param channelName The name of the channel this client connected too.
@throws IllegalArgumentException If the channel passed as argument does not exist. | [
"Pass",
"{",
"@link",
"OnOpen",
"}",
"events",
"of",
"the",
"Websocket",
"API",
"to",
"this",
"method",
"to",
"handle",
"new",
"clients",
"."
] | train | https://github.com/saxsys/SynchronizeFX/blob/f3683020e4749110b38514eb5bc73a247998b579/transmitter/websocket-transmitter/src/main/java/de/saxsys/synchronizefx/websocket/SychronizeFXWebsocketServer.java#L172-L179 |
ReactiveX/RxNetty | rxnetty-http/src/main/java/io/reactivex/netty/protocol/http/TrailingHeaders.java | TrailingHeaders.addHeader | public TrailingHeaders addHeader(CharSequence name, Object value) {
"""
Adds an HTTP trailing header with the passed {@code name} and {@code value} to this request.
@param name Name of the header.
@param value Value for the header.
@return {@code this}.
"""
lastHttpContent.trailingHeaders().add(name, value);
return this;
} | java | public TrailingHeaders addHeader(CharSequence name, Object value) {
lastHttpContent.trailingHeaders().add(name, value);
return this;
} | [
"public",
"TrailingHeaders",
"addHeader",
"(",
"CharSequence",
"name",
",",
"Object",
"value",
")",
"{",
"lastHttpContent",
".",
"trailingHeaders",
"(",
")",
".",
"add",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Adds an HTTP trailing header with the passed {@code name} and {@code value} to this request.
@param name Name of the header.
@param value Value for the header.
@return {@code this}. | [
"Adds",
"an",
"HTTP",
"trailing",
"header",
"with",
"the",
"passed",
"{",
"@code",
"name",
"}",
"and",
"{",
"@code",
"value",
"}",
"to",
"this",
"request",
"."
] | train | https://github.com/ReactiveX/RxNetty/blob/a7ca9a9c1d544a79c82f7b17036daf6958bf1cd6/rxnetty-http/src/main/java/io/reactivex/netty/protocol/http/TrailingHeaders.java#L49-L52 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringParser.java | StringParser.parseDoubleObj | @Nullable
public static Double parseDoubleObj (@Nullable final String sStr, @Nullable final Double aDefault) {
"""
Parse the given {@link String} as {@link Double}. Note: both the locale
independent form of a double can be parsed here (e.g. 4.523) as well as a
localized form using the comma as the decimal separator (e.g. the German
4,523).
@param sStr
The string to parse. May be <code>null</code>.
@param aDefault
The default value to be returned if the parsed string cannot be
converted to a double. May be <code>null</code>.
@return <code>aDefault</code> if the object does not represent a valid
value.
"""
final double dValue = parseDouble (sStr, Double.NaN);
return Double.isNaN (dValue) ? aDefault : Double.valueOf (dValue);
} | java | @Nullable
public static Double parseDoubleObj (@Nullable final String sStr, @Nullable final Double aDefault)
{
final double dValue = parseDouble (sStr, Double.NaN);
return Double.isNaN (dValue) ? aDefault : Double.valueOf (dValue);
} | [
"@",
"Nullable",
"public",
"static",
"Double",
"parseDoubleObj",
"(",
"@",
"Nullable",
"final",
"String",
"sStr",
",",
"@",
"Nullable",
"final",
"Double",
"aDefault",
")",
"{",
"final",
"double",
"dValue",
"=",
"parseDouble",
"(",
"sStr",
",",
"Double",
".",
"NaN",
")",
";",
"return",
"Double",
".",
"isNaN",
"(",
"dValue",
")",
"?",
"aDefault",
":",
"Double",
".",
"valueOf",
"(",
"dValue",
")",
";",
"}"
] | Parse the given {@link String} as {@link Double}. Note: both the locale
independent form of a double can be parsed here (e.g. 4.523) as well as a
localized form using the comma as the decimal separator (e.g. the German
4,523).
@param sStr
The string to parse. May be <code>null</code>.
@param aDefault
The default value to be returned if the parsed string cannot be
converted to a double. May be <code>null</code>.
@return <code>aDefault</code> if the object does not represent a valid
value. | [
"Parse",
"the",
"given",
"{",
"@link",
"String",
"}",
"as",
"{",
"@link",
"Double",
"}",
".",
"Note",
":",
"both",
"the",
"locale",
"independent",
"form",
"of",
"a",
"double",
"can",
"be",
"parsed",
"here",
"(",
"e",
".",
"g",
".",
"4",
".",
"523",
")",
"as",
"well",
"as",
"a",
"localized",
"form",
"using",
"the",
"comma",
"as",
"the",
"decimal",
"separator",
"(",
"e",
".",
"g",
".",
"the",
"German",
"4",
"523",
")",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringParser.java#L567-L572 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/parser/lexparser/MLEDependencyGrammar.java | MLEDependencyGrammar.addRule | public void addRule(IntDependency dependency, double count) {
"""
Add this dependency with the given count to the grammar.
This is the main entry point of MLEDependencyGrammarExtractor.
This is a dependency represented in the full tag space.
"""
if ( ! directional) {
dependency = new IntDependency(dependency.head, dependency.arg, false, dependency.distance);
}
if (verbose) System.err.println("Adding dep " + dependency);
// coreDependencies.incrementCount(dependency, count);
/*new IntDependency(dependency.head.word,
dependency.head.tag,
dependency.arg.word,
dependency.arg.tag,
dependency.leftHeaded,
dependency.distance), count);
*/
expandDependency(dependency, count);
// System.err.println("stopCounter: " + stopCounter);
// System.err.println("argCounter: " + argCounter);
} | java | public void addRule(IntDependency dependency, double count) {
if ( ! directional) {
dependency = new IntDependency(dependency.head, dependency.arg, false, dependency.distance);
}
if (verbose) System.err.println("Adding dep " + dependency);
// coreDependencies.incrementCount(dependency, count);
/*new IntDependency(dependency.head.word,
dependency.head.tag,
dependency.arg.word,
dependency.arg.tag,
dependency.leftHeaded,
dependency.distance), count);
*/
expandDependency(dependency, count);
// System.err.println("stopCounter: " + stopCounter);
// System.err.println("argCounter: " + argCounter);
} | [
"public",
"void",
"addRule",
"(",
"IntDependency",
"dependency",
",",
"double",
"count",
")",
"{",
"if",
"(",
"!",
"directional",
")",
"{",
"dependency",
"=",
"new",
"IntDependency",
"(",
"dependency",
".",
"head",
",",
"dependency",
".",
"arg",
",",
"false",
",",
"dependency",
".",
"distance",
")",
";",
"}",
"if",
"(",
"verbose",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"Adding dep \"",
"+",
"dependency",
")",
";",
"// coreDependencies.incrementCount(dependency, count);\r",
"/*new IntDependency(dependency.head.word,\r\n dependency.head.tag,\r\n dependency.arg.word,\r\n dependency.arg.tag,\r\n dependency.leftHeaded,\r\n dependency.distance), count);\r\n */",
"expandDependency",
"(",
"dependency",
",",
"count",
")",
";",
"// System.err.println(\"stopCounter: \" + stopCounter);\r",
"// System.err.println(\"argCounter: \" + argCounter);\r",
"}"
] | Add this dependency with the given count to the grammar.
This is the main entry point of MLEDependencyGrammarExtractor.
This is a dependency represented in the full tag space. | [
"Add",
"this",
"dependency",
"with",
"the",
"given",
"count",
"to",
"the",
"grammar",
".",
"This",
"is",
"the",
"main",
"entry",
"point",
"of",
"MLEDependencyGrammarExtractor",
".",
"This",
"is",
"a",
"dependency",
"represented",
"in",
"the",
"full",
"tag",
"space",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/parser/lexparser/MLEDependencyGrammar.java#L343-L359 |
grpc/grpc-java | stub/src/main/java/io/grpc/stub/AbstractStub.java | AbstractStub.withOption | @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1869")
public final <T> S withOption(CallOptions.Key<T> key, T value) {
"""
Sets a custom option to be passed to client interceptors on the channel
{@link io.grpc.ClientInterceptor} via the CallOptions parameter.
@since 1.0.0
@param key the option being set
@param value the value for the key
"""
return build(channel, callOptions.withOption(key, value));
} | java | @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1869")
public final <T> S withOption(CallOptions.Key<T> key, T value) {
return build(channel, callOptions.withOption(key, value));
} | [
"@",
"ExperimentalApi",
"(",
"\"https://github.com/grpc/grpc-java/issues/1869\"",
")",
"public",
"final",
"<",
"T",
">",
"S",
"withOption",
"(",
"CallOptions",
".",
"Key",
"<",
"T",
">",
"key",
",",
"T",
"value",
")",
"{",
"return",
"build",
"(",
"channel",
",",
"callOptions",
".",
"withOption",
"(",
"key",
",",
"value",
")",
")",
";",
"}"
] | Sets a custom option to be passed to client interceptors on the channel
{@link io.grpc.ClientInterceptor} via the CallOptions parameter.
@since 1.0.0
@param key the option being set
@param value the value for the key | [
"Sets",
"a",
"custom",
"option",
"to",
"be",
"passed",
"to",
"client",
"interceptors",
"on",
"the",
"channel",
"{",
"@link",
"io",
".",
"grpc",
".",
"ClientInterceptor",
"}",
"via",
"the",
"CallOptions",
"parameter",
"."
] | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/stub/src/main/java/io/grpc/stub/AbstractStub.java#L174-L177 |
operasoftware/operaprestodriver | src/com/opera/core/systems/QuickWidget.java | QuickWidget.dragAndDropOn | public void dragAndDropOn(QuickWidget widget, DropPosition dropPos) {
"""
Drags this widget onto the specified widget at the given drop position
@param widget the widget to drop this widget onto
@param dropPos the position to drop this widget into, CENTER, EDGE or BETWEEN
"""
/*
* FIXME: Handle MousePosition
*/
Point currentLocation = getCenterLocation();
Point dropPoint = getDropPoint(widget, dropPos);
List<ModifierPressed> alist = new ArrayList<ModifierPressed>();
alist.add(ModifierPressed.NONE);
getSystemInputManager().mouseDown(currentLocation, MouseButton.LEFT, alist);
getSystemInputManager().mouseMove(dropPoint, MouseButton.LEFT, alist);
getSystemInputManager().mouseUp(dropPoint, MouseButton.LEFT, alist);
} | java | public void dragAndDropOn(QuickWidget widget, DropPosition dropPos) {
/*
* FIXME: Handle MousePosition
*/
Point currentLocation = getCenterLocation();
Point dropPoint = getDropPoint(widget, dropPos);
List<ModifierPressed> alist = new ArrayList<ModifierPressed>();
alist.add(ModifierPressed.NONE);
getSystemInputManager().mouseDown(currentLocation, MouseButton.LEFT, alist);
getSystemInputManager().mouseMove(dropPoint, MouseButton.LEFT, alist);
getSystemInputManager().mouseUp(dropPoint, MouseButton.LEFT, alist);
} | [
"public",
"void",
"dragAndDropOn",
"(",
"QuickWidget",
"widget",
",",
"DropPosition",
"dropPos",
")",
"{",
"/*\n * FIXME: Handle MousePosition\n */",
"Point",
"currentLocation",
"=",
"getCenterLocation",
"(",
")",
";",
"Point",
"dropPoint",
"=",
"getDropPoint",
"(",
"widget",
",",
"dropPos",
")",
";",
"List",
"<",
"ModifierPressed",
">",
"alist",
"=",
"new",
"ArrayList",
"<",
"ModifierPressed",
">",
"(",
")",
";",
"alist",
".",
"add",
"(",
"ModifierPressed",
".",
"NONE",
")",
";",
"getSystemInputManager",
"(",
")",
".",
"mouseDown",
"(",
"currentLocation",
",",
"MouseButton",
".",
"LEFT",
",",
"alist",
")",
";",
"getSystemInputManager",
"(",
")",
".",
"mouseMove",
"(",
"dropPoint",
",",
"MouseButton",
".",
"LEFT",
",",
"alist",
")",
";",
"getSystemInputManager",
"(",
")",
".",
"mouseUp",
"(",
"dropPoint",
",",
"MouseButton",
".",
"LEFT",
",",
"alist",
")",
";",
"}"
] | Drags this widget onto the specified widget at the given drop position
@param widget the widget to drop this widget onto
@param dropPos the position to drop this widget into, CENTER, EDGE or BETWEEN | [
"Drags",
"this",
"widget",
"onto",
"the",
"specified",
"widget",
"at",
"the",
"given",
"drop",
"position"
] | train | https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/QuickWidget.java#L136-L149 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.