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
|
---|---|---|---|---|---|---|---|---|---|---|
vtatai/srec | core/src/main/java/com/github/srec/command/method/MethodCommand.java | MethodCommand.asBoolean | protected Boolean asBoolean(String name, Map<String, Value> params) {
"""
Gets a parameter value as a Java Boolean.
@param name The parameter name
@param params The parameters
@return The boolean
"""
return coerceToBoolean(params.get(name));
} | java | protected Boolean asBoolean(String name, Map<String, Value> params) {
return coerceToBoolean(params.get(name));
} | [
"protected",
"Boolean",
"asBoolean",
"(",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"Value",
">",
"params",
")",
"{",
"return",
"coerceToBoolean",
"(",
"params",
".",
"get",
"(",
"name",
")",
")",
";",
"}"
] | Gets a parameter value as a Java Boolean.
@param name The parameter name
@param params The parameters
@return The boolean | [
"Gets",
"a",
"parameter",
"value",
"as",
"a",
"Java",
"Boolean",
"."
] | train | https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/method/MethodCommand.java#L174-L176 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/MilestonesApi.java | MilestonesApi.activateMilestone | public Milestone activateMilestone(Object projectIdOrPath, Integer milestoneId) throws GitLabApiException {
"""
Activate a milestone.
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param milestoneId the milestone ID to activate
@return the activated Milestone instance
@throws GitLabApiException if any exception occurs
"""
if (milestoneId == null) {
throw new RuntimeException("milestoneId cannot be null");
}
GitLabApiForm formData = new GitLabApiForm().withParam("state_event", MilestoneState.ACTIVATE);
Response response = put(Response.Status.OK, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "milestones", milestoneId);
return (response.readEntity(Milestone.class));
} | java | public Milestone activateMilestone(Object projectIdOrPath, Integer milestoneId) throws GitLabApiException {
if (milestoneId == null) {
throw new RuntimeException("milestoneId cannot be null");
}
GitLabApiForm formData = new GitLabApiForm().withParam("state_event", MilestoneState.ACTIVATE);
Response response = put(Response.Status.OK, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "milestones", milestoneId);
return (response.readEntity(Milestone.class));
} | [
"public",
"Milestone",
"activateMilestone",
"(",
"Object",
"projectIdOrPath",
",",
"Integer",
"milestoneId",
")",
"throws",
"GitLabApiException",
"{",
"if",
"(",
"milestoneId",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"milestoneId cannot be null\"",
")",
";",
"}",
"GitLabApiForm",
"formData",
"=",
"new",
"GitLabApiForm",
"(",
")",
".",
"withParam",
"(",
"\"state_event\"",
",",
"MilestoneState",
".",
"ACTIVATE",
")",
";",
"Response",
"response",
"=",
"put",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"formData",
".",
"asMap",
"(",
")",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"milestones\"",
",",
"milestoneId",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"Milestone",
".",
"class",
")",
")",
";",
"}"
] | Activate a milestone.
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param milestoneId the milestone ID to activate
@return the activated Milestone instance
@throws GitLabApiException if any exception occurs | [
"Activate",
"a",
"milestone",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/MilestonesApi.java#L449-L459 |
mockito/mockito | src/main/java/org/mockito/internal/matchers/apachecommons/EqualsBuilder.java | EqualsBuilder.reflectionEquals | public static boolean reflectionEquals(Object lhs, Object rhs) {
"""
<p>This method uses reflection to determine if the two <code>Object</code>s
are equal.</p>
<p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private
fields. This means that it will throw a security exception if run under
a security manager, if the permissions are not set up correctly. It is also
not as efficient as testing explicitly.</p>
<p>Transient members will be not be tested, as they are likely derived
fields, and not part of the value of the Object.</p>
<p>Static fields will not be tested. Superclass fields will be included.</p>
@param lhs <code>this</code> object
@param rhs the other object
@return <code>true</code> if the two Objects have tested equals.
"""
return reflectionEquals(lhs, rhs, false, null, null);
} | java | public static boolean reflectionEquals(Object lhs, Object rhs) {
return reflectionEquals(lhs, rhs, false, null, null);
} | [
"public",
"static",
"boolean",
"reflectionEquals",
"(",
"Object",
"lhs",
",",
"Object",
"rhs",
")",
"{",
"return",
"reflectionEquals",
"(",
"lhs",
",",
"rhs",
",",
"false",
",",
"null",
",",
"null",
")",
";",
"}"
] | <p>This method uses reflection to determine if the two <code>Object</code>s
are equal.</p>
<p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private
fields. This means that it will throw a security exception if run under
a security manager, if the permissions are not set up correctly. It is also
not as efficient as testing explicitly.</p>
<p>Transient members will be not be tested, as they are likely derived
fields, and not part of the value of the Object.</p>
<p>Static fields will not be tested. Superclass fields will be included.</p>
@param lhs <code>this</code> object
@param rhs the other object
@return <code>true</code> if the two Objects have tested equals. | [
"<p",
">",
"This",
"method",
"uses",
"reflection",
"to",
"determine",
"if",
"the",
"two",
"<code",
">",
"Object<",
"/",
"code",
">",
"s",
"are",
"equal",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/mockito/mockito/blob/c5e2b80af76e3192cae7c9550b70c4d1ab312034/src/main/java/org/mockito/internal/matchers/apachecommons/EqualsBuilder.java#L115-L117 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java | Hierarchy.findMethod | public static @CheckForNull
JavaClassAndMethod findMethod(JavaClass javaClass, String methodName, String methodSig) {
"""
Find a method in given class.
@param javaClass
the class
@param methodName
the name of the method
@param methodSig
the signature of the method
@return the JavaClassAndMethod, or null if no such method exists in the
class
"""
return findMethod(javaClass, methodName, methodSig, ANY_METHOD);
} | java | public static @CheckForNull
JavaClassAndMethod findMethod(JavaClass javaClass, String methodName, String methodSig) {
return findMethod(javaClass, methodName, methodSig, ANY_METHOD);
} | [
"public",
"static",
"@",
"CheckForNull",
"JavaClassAndMethod",
"findMethod",
"(",
"JavaClass",
"javaClass",
",",
"String",
"methodName",
",",
"String",
"methodSig",
")",
"{",
"return",
"findMethod",
"(",
"javaClass",
",",
"methodName",
",",
"methodSig",
",",
"ANY_METHOD",
")",
";",
"}"
] | Find a method in given class.
@param javaClass
the class
@param methodName
the name of the method
@param methodSig
the signature of the method
@return the JavaClassAndMethod, or null if no such method exists in the
class | [
"Find",
"a",
"method",
"in",
"given",
"class",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L427-L430 |
opsmatters/newrelic-api | src/main/java/com/opsmatters/newrelic/api/model/plugins/Component.java | Component.addMetric | public <T> void addMetric(String name, MetricTimeslice<T> timeslice) {
"""
Adds a metric to the set of metrics.
@param <T> The type parameter used for the timeslice
@param name The name of the metric
@param timeslice The values representing the metric timeslice
"""
metrics.put(name, timeslice);
} | java | public <T> void addMetric(String name, MetricTimeslice<T> timeslice)
{
metrics.put(name, timeslice);
} | [
"public",
"<",
"T",
">",
"void",
"addMetric",
"(",
"String",
"name",
",",
"MetricTimeslice",
"<",
"T",
">",
"timeslice",
")",
"{",
"metrics",
".",
"put",
"(",
"name",
",",
"timeslice",
")",
";",
"}"
] | Adds a metric to the set of metrics.
@param <T> The type parameter used for the timeslice
@param name The name of the metric
@param timeslice The values representing the metric timeslice | [
"Adds",
"a",
"metric",
"to",
"the",
"set",
"of",
"metrics",
"."
] | train | https://github.com/opsmatters/newrelic-api/blob/5bc2ea62ec368db891e4fd5fe3dcdf529d086b5e/src/main/java/com/opsmatters/newrelic/api/model/plugins/Component.java#L154-L157 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/MetatypeUtils.java | MetatypeUtils.collapseWhitespace | @Trivial
private static String collapseWhitespace(String value) {
"""
Collapses contiguous sequences of whitespace to a single 0x20.
Leading and trailing whitespace is removed.
"""
final int length = value.length();
for (int i = 0; i < length; ++i) {
if (isSpace(value.charAt(i))) {
return collapse0(value, i, length);
}
}
return value;
} | java | @Trivial
private static String collapseWhitespace(String value) {
final int length = value.length();
for (int i = 0; i < length; ++i) {
if (isSpace(value.charAt(i))) {
return collapse0(value, i, length);
}
}
return value;
} | [
"@",
"Trivial",
"private",
"static",
"String",
"collapseWhitespace",
"(",
"String",
"value",
")",
"{",
"final",
"int",
"length",
"=",
"value",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"isSpace",
"(",
"value",
".",
"charAt",
"(",
"i",
")",
")",
")",
"{",
"return",
"collapse0",
"(",
"value",
",",
"i",
",",
"length",
")",
";",
"}",
"}",
"return",
"value",
";",
"}"
] | Collapses contiguous sequences of whitespace to a single 0x20.
Leading and trailing whitespace is removed. | [
"Collapses",
"contiguous",
"sequences",
"of",
"whitespace",
"to",
"a",
"single",
"0x20",
".",
"Leading",
"and",
"trailing",
"whitespace",
"is",
"removed",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/MetatypeUtils.java#L557-L566 |
tropo/tropo-webapi-java | src/main/java/com/voxeo/tropo/Key.java | Key.SAY_OF_ON | public static Key SAY_OF_ON(com.voxeo.tropo.actions.OnAction.Say... says) {
"""
<p>
This determines what is played or sent to the caller. This can be a single
object or an array of objects.
</p>
"""
return createKey("say", says);
} | java | public static Key SAY_OF_ON(com.voxeo.tropo.actions.OnAction.Say... says) {
return createKey("say", says);
} | [
"public",
"static",
"Key",
"SAY_OF_ON",
"(",
"com",
".",
"voxeo",
".",
"tropo",
".",
"actions",
".",
"OnAction",
".",
"Say",
"...",
"says",
")",
"{",
"return",
"createKey",
"(",
"\"say\"",
",",
"says",
")",
";",
"}"
] | <p>
This determines what is played or sent to the caller. This can be a single
object or an array of objects.
</p> | [
"<p",
">",
"This",
"determines",
"what",
"is",
"played",
"or",
"sent",
"to",
"the",
"caller",
".",
"This",
"can",
"be",
"a",
"single",
"object",
"or",
"an",
"array",
"of",
"objects",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/tropo/tropo-webapi-java/blob/96af1fa292c1d4b6321d85a559d9718d33eec7e0/src/main/java/com/voxeo/tropo/Key.java#L783-L786 |
Impetus/Kundera | src/kundera-kudu/src/main/java/com/impetus/client/kudu/KuduDBDataHandler.java | KuduDBDataHandler.getColumnValue | public static Object getColumnValue(RowResult result, String jpaColumnName) {
"""
Gets the column value.
@param result
the result
@param jpaColumnName
the jpa column name
@return the column value
"""
if (result.isNull(jpaColumnName))
{
return null;
}
switch (result.getColumnType(jpaColumnName))
{
case BINARY:
return result.getBinary(jpaColumnName);
case BOOL:
return result.getBoolean(jpaColumnName);
case DOUBLE:
return result.getDouble(jpaColumnName);
case FLOAT:
return result.getFloat(jpaColumnName);
case INT16:
return result.getShort(jpaColumnName);
case INT32:
return result.getInt(jpaColumnName);
case INT64:
return result.getLong(jpaColumnName);
case INT8:
return result.getByte(jpaColumnName);
case STRING:
return result.getString(jpaColumnName);
case UNIXTIME_MICROS:
default:
logger.error(jpaColumnName + " type is not supported by Kudu");
throw new KunderaException(jpaColumnName + " type is not supported by Kudu");
}
} | java | public static Object getColumnValue(RowResult result, String jpaColumnName)
{
if (result.isNull(jpaColumnName))
{
return null;
}
switch (result.getColumnType(jpaColumnName))
{
case BINARY:
return result.getBinary(jpaColumnName);
case BOOL:
return result.getBoolean(jpaColumnName);
case DOUBLE:
return result.getDouble(jpaColumnName);
case FLOAT:
return result.getFloat(jpaColumnName);
case INT16:
return result.getShort(jpaColumnName);
case INT32:
return result.getInt(jpaColumnName);
case INT64:
return result.getLong(jpaColumnName);
case INT8:
return result.getByte(jpaColumnName);
case STRING:
return result.getString(jpaColumnName);
case UNIXTIME_MICROS:
default:
logger.error(jpaColumnName + " type is not supported by Kudu");
throw new KunderaException(jpaColumnName + " type is not supported by Kudu");
}
} | [
"public",
"static",
"Object",
"getColumnValue",
"(",
"RowResult",
"result",
",",
"String",
"jpaColumnName",
")",
"{",
"if",
"(",
"result",
".",
"isNull",
"(",
"jpaColumnName",
")",
")",
"{",
"return",
"null",
";",
"}",
"switch",
"(",
"result",
".",
"getColumnType",
"(",
"jpaColumnName",
")",
")",
"{",
"case",
"BINARY",
":",
"return",
"result",
".",
"getBinary",
"(",
"jpaColumnName",
")",
";",
"case",
"BOOL",
":",
"return",
"result",
".",
"getBoolean",
"(",
"jpaColumnName",
")",
";",
"case",
"DOUBLE",
":",
"return",
"result",
".",
"getDouble",
"(",
"jpaColumnName",
")",
";",
"case",
"FLOAT",
":",
"return",
"result",
".",
"getFloat",
"(",
"jpaColumnName",
")",
";",
"case",
"INT16",
":",
"return",
"result",
".",
"getShort",
"(",
"jpaColumnName",
")",
";",
"case",
"INT32",
":",
"return",
"result",
".",
"getInt",
"(",
"jpaColumnName",
")",
";",
"case",
"INT64",
":",
"return",
"result",
".",
"getLong",
"(",
"jpaColumnName",
")",
";",
"case",
"INT8",
":",
"return",
"result",
".",
"getByte",
"(",
"jpaColumnName",
")",
";",
"case",
"STRING",
":",
"return",
"result",
".",
"getString",
"(",
"jpaColumnName",
")",
";",
"case",
"UNIXTIME_MICROS",
":",
"default",
":",
"logger",
".",
"error",
"(",
"jpaColumnName",
"+",
"\" type is not supported by Kudu\"",
")",
";",
"throw",
"new",
"KunderaException",
"(",
"jpaColumnName",
"+",
"\" type is not supported by Kudu\"",
")",
";",
"}",
"}"
] | Gets the column value.
@param result
the result
@param jpaColumnName
the jpa column name
@return the column value | [
"Gets",
"the",
"column",
"value",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-kudu/src/main/java/com/impetus/client/kudu/KuduDBDataHandler.java#L183-L217 |
DDTH/ddth-dao | ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java | BoUtils.fromBytes | public static <T extends BaseBo> T fromBytes(byte[] bytes, Class<T> clazz) {
"""
De-serialize a BO from byte array.
@param bytes
the byte array obtained from {@link #toBytes(BaseBo)}
@param clazz
@return
"""
return fromBytes(bytes, clazz, null);
} | java | public static <T extends BaseBo> T fromBytes(byte[] bytes, Class<T> clazz) {
return fromBytes(bytes, clazz, null);
} | [
"public",
"static",
"<",
"T",
"extends",
"BaseBo",
">",
"T",
"fromBytes",
"(",
"byte",
"[",
"]",
"bytes",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"return",
"fromBytes",
"(",
"bytes",
",",
"clazz",
",",
"null",
")",
";",
"}"
] | De-serialize a BO from byte array.
@param bytes
the byte array obtained from {@link #toBytes(BaseBo)}
@param clazz
@return | [
"De",
"-",
"serialize",
"a",
"BO",
"from",
"byte",
"array",
"."
] | train | https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/utils/BoUtils.java#L195-L197 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java | CoverageUtilities.getWritableRandomIterator | public static WritableRandomIter getWritableRandomIterator( int width, int height ) {
"""
Creates a {@link WritableRandomIter}.
<p>It is important to use this method since it supports also
large GRASS rasters.
<p>If the size would throw an integer overflow, a {@link GrassLegacyRandomIter}
will be proposed to try to save the saveable.
@param raster the coverage on which to wrap a {@link WritableRandomIter}.
@return the iterator.
"""
if (doesOverFlow(width, height)) {
GrassLegacyRandomIter iter = new GrassLegacyRandomIter(new double[height][width]);
return iter;
}
WritableRaster pitRaster = CoverageUtilities.createWritableRaster(width, height, null, null, null);
WritableRandomIter iter = RandomIterFactory.createWritable(pitRaster, null);
return iter;
} | java | public static WritableRandomIter getWritableRandomIterator( int width, int height ) {
if (doesOverFlow(width, height)) {
GrassLegacyRandomIter iter = new GrassLegacyRandomIter(new double[height][width]);
return iter;
}
WritableRaster pitRaster = CoverageUtilities.createWritableRaster(width, height, null, null, null);
WritableRandomIter iter = RandomIterFactory.createWritable(pitRaster, null);
return iter;
} | [
"public",
"static",
"WritableRandomIter",
"getWritableRandomIterator",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"if",
"(",
"doesOverFlow",
"(",
"width",
",",
"height",
")",
")",
"{",
"GrassLegacyRandomIter",
"iter",
"=",
"new",
"GrassLegacyRandomIter",
"(",
"new",
"double",
"[",
"height",
"]",
"[",
"width",
"]",
")",
";",
"return",
"iter",
";",
"}",
"WritableRaster",
"pitRaster",
"=",
"CoverageUtilities",
".",
"createWritableRaster",
"(",
"width",
",",
"height",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"WritableRandomIter",
"iter",
"=",
"RandomIterFactory",
".",
"createWritable",
"(",
"pitRaster",
",",
"null",
")",
";",
"return",
"iter",
";",
"}"
] | Creates a {@link WritableRandomIter}.
<p>It is important to use this method since it supports also
large GRASS rasters.
<p>If the size would throw an integer overflow, a {@link GrassLegacyRandomIter}
will be proposed to try to save the saveable.
@param raster the coverage on which to wrap a {@link WritableRandomIter}.
@return the iterator. | [
"Creates",
"a",
"{",
"@link",
"WritableRandomIter",
"}",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/coverage/CoverageUtilities.java#L143-L151 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/odmg/TransactionImpl.java | TransactionImpl.lockAndRegister | public void lockAndRegister(RuntimeObject rtObject, int lockMode, List registeredObjects) {
"""
Lock and register the specified object, make sure that when cascading locking and register
is enabled to specify a List to register the already processed object Identiy.
"""
lockAndRegister(rtObject, lockMode, isImplicitLocking(), registeredObjects);
} | java | public void lockAndRegister(RuntimeObject rtObject, int lockMode, List registeredObjects)
{
lockAndRegister(rtObject, lockMode, isImplicitLocking(), registeredObjects);
} | [
"public",
"void",
"lockAndRegister",
"(",
"RuntimeObject",
"rtObject",
",",
"int",
"lockMode",
",",
"List",
"registeredObjects",
")",
"{",
"lockAndRegister",
"(",
"rtObject",
",",
"lockMode",
",",
"isImplicitLocking",
"(",
")",
",",
"registeredObjects",
")",
";",
"}"
] | Lock and register the specified object, make sure that when cascading locking and register
is enabled to specify a List to register the already processed object Identiy. | [
"Lock",
"and",
"register",
"the",
"specified",
"object",
"make",
"sure",
"that",
"when",
"cascading",
"locking",
"and",
"register",
"is",
"enabled",
"to",
"specify",
"a",
"List",
"to",
"register",
"the",
"already",
"processed",
"object",
"Identiy",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/TransactionImpl.java#L254-L257 |
cdk/cdk | tool/sdg/src/main/java/org/openscience/cdk/layout/RingPlacer.java | RingPlacer.completePartiallyPlacedRing | boolean completePartiallyPlacedRing(IRingSet rset, IRing ring, double bondLength) {
"""
Completes the layout of a partially laid out ring.
@param rset ring set
@param ring the ring to complete
@param bondLength the bond length
"""
if (ring.getFlag(CDKConstants.ISPLACED))
return true;
IRing partiallyPlacedRing = molecule.getBuilder().newInstance(IRing.class);
for (IAtom atom : ring.atoms())
if (atom.getPoint2d() != null)
atom.setFlag(CDKConstants.ISPLACED, true);
AtomPlacer.copyPlaced(partiallyPlacedRing, ring);
if (partiallyPlacedRing.getAtomCount() > 1 &&
partiallyPlacedRing.getAtomCount() < ring.getAtomCount()) {
placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.FUSED, bondLength);
placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.BRIDGED, bondLength);
placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.SPIRO, bondLength);
ring.setFlag(CDKConstants.ISPLACED, true);
return true;
} else {
return false;
}
} | java | boolean completePartiallyPlacedRing(IRingSet rset, IRing ring, double bondLength) {
if (ring.getFlag(CDKConstants.ISPLACED))
return true;
IRing partiallyPlacedRing = molecule.getBuilder().newInstance(IRing.class);
for (IAtom atom : ring.atoms())
if (atom.getPoint2d() != null)
atom.setFlag(CDKConstants.ISPLACED, true);
AtomPlacer.copyPlaced(partiallyPlacedRing, ring);
if (partiallyPlacedRing.getAtomCount() > 1 &&
partiallyPlacedRing.getAtomCount() < ring.getAtomCount()) {
placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.FUSED, bondLength);
placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.BRIDGED, bondLength);
placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.SPIRO, bondLength);
ring.setFlag(CDKConstants.ISPLACED, true);
return true;
} else {
return false;
}
} | [
"boolean",
"completePartiallyPlacedRing",
"(",
"IRingSet",
"rset",
",",
"IRing",
"ring",
",",
"double",
"bondLength",
")",
"{",
"if",
"(",
"ring",
".",
"getFlag",
"(",
"CDKConstants",
".",
"ISPLACED",
")",
")",
"return",
"true",
";",
"IRing",
"partiallyPlacedRing",
"=",
"molecule",
".",
"getBuilder",
"(",
")",
".",
"newInstance",
"(",
"IRing",
".",
"class",
")",
";",
"for",
"(",
"IAtom",
"atom",
":",
"ring",
".",
"atoms",
"(",
")",
")",
"if",
"(",
"atom",
".",
"getPoint2d",
"(",
")",
"!=",
"null",
")",
"atom",
".",
"setFlag",
"(",
"CDKConstants",
".",
"ISPLACED",
",",
"true",
")",
";",
"AtomPlacer",
".",
"copyPlaced",
"(",
"partiallyPlacedRing",
",",
"ring",
")",
";",
"if",
"(",
"partiallyPlacedRing",
".",
"getAtomCount",
"(",
")",
">",
"1",
"&&",
"partiallyPlacedRing",
".",
"getAtomCount",
"(",
")",
"<",
"ring",
".",
"getAtomCount",
"(",
")",
")",
"{",
"placeConnectedRings",
"(",
"rset",
",",
"partiallyPlacedRing",
",",
"RingPlacer",
".",
"FUSED",
",",
"bondLength",
")",
";",
"placeConnectedRings",
"(",
"rset",
",",
"partiallyPlacedRing",
",",
"RingPlacer",
".",
"BRIDGED",
",",
"bondLength",
")",
";",
"placeConnectedRings",
"(",
"rset",
",",
"partiallyPlacedRing",
",",
"RingPlacer",
".",
"SPIRO",
",",
"bondLength",
")",
";",
"ring",
".",
"setFlag",
"(",
"CDKConstants",
".",
"ISPLACED",
",",
"true",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Completes the layout of a partially laid out ring.
@param rset ring set
@param ring the ring to complete
@param bondLength the bond length | [
"Completes",
"the",
"layout",
"of",
"a",
"partially",
"laid",
"out",
"ring",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/sdg/src/main/java/org/openscience/cdk/layout/RingPlacer.java#L543-L562 |
google/closure-templates | java/src/com/google/template/soy/shared/internal/Sanitizers.java | Sanitizers.cleanHtml | public static SanitizedContent cleanHtml(
String value, Collection<? extends OptionalSafeTag> optionalSafeTags) {
"""
Normalizes the input HTML while preserving "safe" tags. The content directionality is unknown.
@param optionalSafeTags to add to the basic whitelist of formatting safe tags
@return the normalized input, in the form of {@link SanitizedContent} of {@link
ContentKind#HTML}
"""
return cleanHtml(value, null, optionalSafeTags);
} | java | public static SanitizedContent cleanHtml(
String value, Collection<? extends OptionalSafeTag> optionalSafeTags) {
return cleanHtml(value, null, optionalSafeTags);
} | [
"public",
"static",
"SanitizedContent",
"cleanHtml",
"(",
"String",
"value",
",",
"Collection",
"<",
"?",
"extends",
"OptionalSafeTag",
">",
"optionalSafeTags",
")",
"{",
"return",
"cleanHtml",
"(",
"value",
",",
"null",
",",
"optionalSafeTags",
")",
";",
"}"
] | Normalizes the input HTML while preserving "safe" tags. The content directionality is unknown.
@param optionalSafeTags to add to the basic whitelist of formatting safe tags
@return the normalized input, in the form of {@link SanitizedContent} of {@link
ContentKind#HTML} | [
"Normalizes",
"the",
"input",
"HTML",
"while",
"preserving",
"safe",
"tags",
".",
"The",
"content",
"directionality",
"is",
"unknown",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/shared/internal/Sanitizers.java#L211-L214 |
apereo/cas | support/cas-server-support-validation/src/main/java/org/apereo/cas/web/AbstractServiceValidateController.java | AbstractServiceValidateController.verifyRegisteredServiceProperties | private static void verifyRegisteredServiceProperties(final RegisteredService registeredService, final Service service) {
"""
Ensure that the service is found and enabled in the service registry.
@param registeredService the located entry in the registry
@param service authenticating service
@throws UnauthorizedServiceException if service is determined to be unauthorized
"""
if (registeredService == null) {
val msg = String.format("Service [%s] is not found in service registry.", service.getId());
LOGGER.warn(msg);
throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, msg);
}
if (!registeredService.getAccessStrategy().isServiceAccessAllowed()) {
val msg = String.format("ServiceManagement: Unauthorized Service Access. " + "Service [%s] is not enabled in service registry.", service.getId());
LOGGER.warn(msg);
throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, msg);
}
} | java | private static void verifyRegisteredServiceProperties(final RegisteredService registeredService, final Service service) {
if (registeredService == null) {
val msg = String.format("Service [%s] is not found in service registry.", service.getId());
LOGGER.warn(msg);
throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, msg);
}
if (!registeredService.getAccessStrategy().isServiceAccessAllowed()) {
val msg = String.format("ServiceManagement: Unauthorized Service Access. " + "Service [%s] is not enabled in service registry.", service.getId());
LOGGER.warn(msg);
throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, msg);
}
} | [
"private",
"static",
"void",
"verifyRegisteredServiceProperties",
"(",
"final",
"RegisteredService",
"registeredService",
",",
"final",
"Service",
"service",
")",
"{",
"if",
"(",
"registeredService",
"==",
"null",
")",
"{",
"val",
"msg",
"=",
"String",
".",
"format",
"(",
"\"Service [%s] is not found in service registry.\"",
",",
"service",
".",
"getId",
"(",
")",
")",
";",
"LOGGER",
".",
"warn",
"(",
"msg",
")",
";",
"throw",
"new",
"UnauthorizedServiceException",
"(",
"UnauthorizedServiceException",
".",
"CODE_UNAUTHZ_SERVICE",
",",
"msg",
")",
";",
"}",
"if",
"(",
"!",
"registeredService",
".",
"getAccessStrategy",
"(",
")",
".",
"isServiceAccessAllowed",
"(",
")",
")",
"{",
"val",
"msg",
"=",
"String",
".",
"format",
"(",
"\"ServiceManagement: Unauthorized Service Access. \"",
"+",
"\"Service [%s] is not enabled in service registry.\"",
",",
"service",
".",
"getId",
"(",
")",
")",
";",
"LOGGER",
".",
"warn",
"(",
"msg",
")",
";",
"throw",
"new",
"UnauthorizedServiceException",
"(",
"UnauthorizedServiceException",
".",
"CODE_UNAUTHZ_SERVICE",
",",
"msg",
")",
";",
"}",
"}"
] | Ensure that the service is found and enabled in the service registry.
@param registeredService the located entry in the registry
@param service authenticating service
@throws UnauthorizedServiceException if service is determined to be unauthorized | [
"Ensure",
"that",
"the",
"service",
"is",
"found",
"and",
"enabled",
"in",
"the",
"service",
"registry",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-validation/src/main/java/org/apereo/cas/web/AbstractServiceValidateController.java#L67-L78 |
titorenko/quick-csv-streamer | src/main/java/uk/elementarysoftware/quickcsv/api/CSVParserBuilder.java | CSVParserBuilder.usingSeparatorWithNoQuotes | public CSVParserBuilder<T, K> usingSeparatorWithNoQuotes(char separator) {
"""
Use specified character as field separator.
@param separator - field separator character
@return this parser builder
"""
this.metadata = new CSVFileMetadata(separator, Optional.empty());
return this;
} | java | public CSVParserBuilder<T, K> usingSeparatorWithNoQuotes(char separator) {
this.metadata = new CSVFileMetadata(separator, Optional.empty());
return this;
} | [
"public",
"CSVParserBuilder",
"<",
"T",
",",
"K",
">",
"usingSeparatorWithNoQuotes",
"(",
"char",
"separator",
")",
"{",
"this",
".",
"metadata",
"=",
"new",
"CSVFileMetadata",
"(",
"separator",
",",
"Optional",
".",
"empty",
"(",
")",
")",
";",
"return",
"this",
";",
"}"
] | Use specified character as field separator.
@param separator - field separator character
@return this parser builder | [
"Use",
"specified",
"character",
"as",
"field",
"separator",
"."
] | train | https://github.com/titorenko/quick-csv-streamer/blob/cc11f6e9db6df4f3aac57ca72c4176501667f41d/src/main/java/uk/elementarysoftware/quickcsv/api/CSVParserBuilder.java#L108-L111 |
lastaflute/lastaflute | src/main/java/org/lastaflute/web/response/HtmlResponse.java | HtmlResponse.useForm | public <FORM> HtmlResponse useForm(Class<FORM> formType, PushedFormOpCall<FORM> opLambda) {
"""
Set up the HTML response as using action form with internal initial value. <br>
And you can use the action form in your HTML template.
<pre>
<span style="color: #3F7E5E">// case of internal initial value</span>
@Execute
<span style="color: #70226C">public</span> HtmlResponse index() {
<span style="color: #70226C">return</span> asHtml(<span style="color: #0000C0">path_Sea_SeaJsp</span>).<span style="color: #CC4747">useForm</span>(SeaForm.<span style="color: #70226C">class</span>, op <span style="color: #90226C; font-weight: bold"><span style="font-size: 120%">-</span>></span> op.<span style="color: #994747">setup</span>(form <span style="color: #90226C; font-weight: bold"><span style="font-size: 120%">-</span>></span> ...));
}
</pre>
@param formType The type of action form. (NotNull)
@param opLambda The callback for option of the form, provides new-created form instance, so you can setup it. (NotNull)
@return this. (NotNull)
"""
assertArgumentNotNull("formType", formType);
assertArgumentNotNull("opLambda", opLambda);
this.pushedFormInfo = createPushedFormInfo(formType, createPushedFormOption(opLambda));
return this;
} | java | public <FORM> HtmlResponse useForm(Class<FORM> formType, PushedFormOpCall<FORM> opLambda) {
assertArgumentNotNull("formType", formType);
assertArgumentNotNull("opLambda", opLambda);
this.pushedFormInfo = createPushedFormInfo(formType, createPushedFormOption(opLambda));
return this;
} | [
"public",
"<",
"FORM",
">",
"HtmlResponse",
"useForm",
"(",
"Class",
"<",
"FORM",
">",
"formType",
",",
"PushedFormOpCall",
"<",
"FORM",
">",
"opLambda",
")",
"{",
"assertArgumentNotNull",
"(",
"\"formType\"",
",",
"formType",
")",
";",
"assertArgumentNotNull",
"(",
"\"opLambda\"",
",",
"opLambda",
")",
";",
"this",
".",
"pushedFormInfo",
"=",
"createPushedFormInfo",
"(",
"formType",
",",
"createPushedFormOption",
"(",
"opLambda",
")",
")",
";",
"return",
"this",
";",
"}"
] | Set up the HTML response as using action form with internal initial value. <br>
And you can use the action form in your HTML template.
<pre>
<span style="color: #3F7E5E">// case of internal initial value</span>
@Execute
<span style="color: #70226C">public</span> HtmlResponse index() {
<span style="color: #70226C">return</span> asHtml(<span style="color: #0000C0">path_Sea_SeaJsp</span>).<span style="color: #CC4747">useForm</span>(SeaForm.<span style="color: #70226C">class</span>, op <span style="color: #90226C; font-weight: bold"><span style="font-size: 120%">-</span>></span> op.<span style="color: #994747">setup</span>(form <span style="color: #90226C; font-weight: bold"><span style="font-size: 120%">-</span>></span> ...));
}
</pre>
@param formType The type of action form. (NotNull)
@param opLambda The callback for option of the form, provides new-created form instance, so you can setup it. (NotNull)
@return this. (NotNull) | [
"Set",
"up",
"the",
"HTML",
"response",
"as",
"using",
"action",
"form",
"with",
"internal",
"initial",
"value",
".",
"<br",
">",
"And",
"you",
"can",
"use",
"the",
"action",
"form",
"in",
"your",
"HTML",
"template",
".",
"<pre",
">",
"<span",
"style",
"=",
"color",
":",
"#3F7E5E",
">",
"//",
"case",
"of",
"internal",
"initial",
"value<",
"/",
"span",
">",
"@",
";",
"Execute",
"<span",
"style",
"=",
"color",
":",
"#70226C",
">",
"public<",
"/",
"span",
">",
"HtmlResponse",
"index",
"()",
"{",
"<span",
"style",
"=",
"color",
":",
"#70226C",
">",
"return<",
"/",
"span",
">",
"asHtml",
"(",
"<span",
"style",
"=",
"color",
":",
"#0000C0",
">",
"path_Sea_SeaJsp<",
"/",
"span",
">",
")",
".",
"<span",
"style",
"=",
"color",
":",
"#CC4747",
">",
"useForm<",
"/",
"span",
">",
"(",
"SeaForm",
".",
"<span",
"style",
"=",
"color",
":",
"#70226C",
">",
"class<",
"/",
"span",
">",
"op",
"<span",
"style",
"=",
"color",
":",
"#90226C",
";",
"font",
"-",
"weight",
":",
"bold",
">",
"<span",
"style",
"=",
"font",
"-",
"size",
":",
"120%",
">",
"-",
"<",
"/",
"span",
">",
">",
";",
"<",
"/",
"span",
">",
"op",
".",
"<span",
"style",
"=",
"color",
":",
"#994747",
">",
"setup<",
"/",
"span",
">",
"(",
"form",
"<span",
"style",
"=",
"color",
":",
"#90226C",
";",
"font",
"-",
"weight",
":",
"bold",
">",
"<span",
"style",
"=",
"font",
"-",
"size",
":",
"120%",
">",
"-",
"<",
"/",
"span",
">",
">",
";",
"<",
"/",
"span",
">",
"...",
"))",
";",
"}",
"<",
"/",
"pre",
">"
] | train | https://github.com/lastaflute/lastaflute/blob/17b56dda8322e4c6d79043532c1dda917d6b60a8/src/main/java/org/lastaflute/web/response/HtmlResponse.java#L247-L252 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/chains/EndPointInfoImpl.java | EndPointInfoImpl.updatePort | public int updatePort(final int newPort) {
"""
Update the port value for this end point.
Will emit an AttributeChangeNotification if the value changed.
@param newPort The new (or current) port value. If no change, no notification is sent.
@return int The previous port value
"""
int oldPort = this.port;
this.port = newPort;
if (oldPort != newPort) {
sendNotification(new AttributeChangeNotification(this, sequenceNum.incrementAndGet(), System.currentTimeMillis(), this.toString()
+ " port value changed", "Port", "java.lang.Integer", oldPort, newPort));
}
return oldPort;
} | java | public int updatePort(final int newPort) {
int oldPort = this.port;
this.port = newPort;
if (oldPort != newPort) {
sendNotification(new AttributeChangeNotification(this, sequenceNum.incrementAndGet(), System.currentTimeMillis(), this.toString()
+ " port value changed", "Port", "java.lang.Integer", oldPort, newPort));
}
return oldPort;
} | [
"public",
"int",
"updatePort",
"(",
"final",
"int",
"newPort",
")",
"{",
"int",
"oldPort",
"=",
"this",
".",
"port",
";",
"this",
".",
"port",
"=",
"newPort",
";",
"if",
"(",
"oldPort",
"!=",
"newPort",
")",
"{",
"sendNotification",
"(",
"new",
"AttributeChangeNotification",
"(",
"this",
",",
"sequenceNum",
".",
"incrementAndGet",
"(",
")",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
",",
"this",
".",
"toString",
"(",
")",
"+",
"\" port value changed\"",
",",
"\"Port\"",
",",
"\"java.lang.Integer\"",
",",
"oldPort",
",",
"newPort",
")",
")",
";",
"}",
"return",
"oldPort",
";",
"}"
] | Update the port value for this end point.
Will emit an AttributeChangeNotification if the value changed.
@param newPort The new (or current) port value. If no change, no notification is sent.
@return int The previous port value | [
"Update",
"the",
"port",
"value",
"for",
"this",
"end",
"point",
".",
"Will",
"emit",
"an",
"AttributeChangeNotification",
"if",
"the",
"value",
"changed",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/chains/EndPointInfoImpl.java#L141-L151 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/GregorianCalendar.java | GregorianCalendar.getRolledValue | private static int getRolledValue(int value, int amount, int min, int max) {
"""
Returns the new value after 'roll'ing the specified value and amount.
"""
assert value >= min && value <= max;
int range = max - min + 1;
amount %= range;
int n = value + amount;
if (n > max) {
n -= range;
} else if (n < min) {
n += range;
}
assert n >= min && n <= max;
return n;
} | java | private static int getRolledValue(int value, int amount, int min, int max) {
assert value >= min && value <= max;
int range = max - min + 1;
amount %= range;
int n = value + amount;
if (n > max) {
n -= range;
} else if (n < min) {
n += range;
}
assert n >= min && n <= max;
return n;
} | [
"private",
"static",
"int",
"getRolledValue",
"(",
"int",
"value",
",",
"int",
"amount",
",",
"int",
"min",
",",
"int",
"max",
")",
"{",
"assert",
"value",
">=",
"min",
"&&",
"value",
"<=",
"max",
";",
"int",
"range",
"=",
"max",
"-",
"min",
"+",
"1",
";",
"amount",
"%=",
"range",
";",
"int",
"n",
"=",
"value",
"+",
"amount",
";",
"if",
"(",
"n",
">",
"max",
")",
"{",
"n",
"-=",
"range",
";",
"}",
"else",
"if",
"(",
"n",
"<",
"min",
")",
"{",
"n",
"+=",
"range",
";",
"}",
"assert",
"n",
">=",
"min",
"&&",
"n",
"<=",
"max",
";",
"return",
"n",
";",
"}"
] | Returns the new value after 'roll'ing the specified value and amount. | [
"Returns",
"the",
"new",
"value",
"after",
"roll",
"ing",
"the",
"specified",
"value",
"and",
"amount",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/GregorianCalendar.java#L3350-L3362 |
alkacon/opencms-core | src/org/opencms/file/types/CmsResourceTypeXmlContainerPage.java | CmsResourceTypeXmlContainerPage.isModelCopyGroup | public static boolean isModelCopyGroup(CmsObject cms, CmsResource resource) {
"""
Checks whether the given resource is a model reuse group.<p>
@param cms the cms context
@param resource the resource
@return <code>true</code> in case the resource is a model reuse group
"""
boolean result = false;
if (isModelGroup(resource)) {
try {
CmsProperty tempElementsProp = cms.readPropertyObject(
resource,
CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS,
false);
if (!tempElementsProp.isNullProperty()
&& CmsContainerElement.USE_AS_COPY_MODEL.equals(tempElementsProp.getValue())) {
result = true;
}
} catch (CmsException e) {
LOG.warn(e.getMessage(), e);
}
}
return result;
} | java | public static boolean isModelCopyGroup(CmsObject cms, CmsResource resource) {
boolean result = false;
if (isModelGroup(resource)) {
try {
CmsProperty tempElementsProp = cms.readPropertyObject(
resource,
CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS,
false);
if (!tempElementsProp.isNullProperty()
&& CmsContainerElement.USE_AS_COPY_MODEL.equals(tempElementsProp.getValue())) {
result = true;
}
} catch (CmsException e) {
LOG.warn(e.getMessage(), e);
}
}
return result;
} | [
"public",
"static",
"boolean",
"isModelCopyGroup",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"isModelGroup",
"(",
"resource",
")",
")",
"{",
"try",
"{",
"CmsProperty",
"tempElementsProp",
"=",
"cms",
".",
"readPropertyObject",
"(",
"resource",
",",
"CmsPropertyDefinition",
".",
"PROPERTY_TEMPLATE_ELEMENTS",
",",
"false",
")",
";",
"if",
"(",
"!",
"tempElementsProp",
".",
"isNullProperty",
"(",
")",
"&&",
"CmsContainerElement",
".",
"USE_AS_COPY_MODEL",
".",
"equals",
"(",
"tempElementsProp",
".",
"getValue",
"(",
")",
")",
")",
"{",
"result",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Checks whether the given resource is a model reuse group.<p>
@param cms the cms context
@param resource the resource
@return <code>true</code> in case the resource is a model reuse group | [
"Checks",
"whether",
"the",
"given",
"resource",
"is",
"a",
"model",
"reuse",
"group",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/types/CmsResourceTypeXmlContainerPage.java#L189-L208 |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/SimpleRepository.java | SimpleRepository.configureDatabaseIdent | protected void configureDatabaseIdent (String dbident) {
"""
This is called automatically if a dbident is provided at construct time, but a derived class
can pass null to its constructor and then call this method itself later if it wishes to
obtain its database identifier from an overridable method which could not otherwise be
called at construct time.
"""
_dbident = dbident;
// give the repository a chance to do any schema migration before things get further
// underway
try {
executeUpdate(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
migrateSchema(conn, liaison);
return null;
}
});
} catch (PersistenceException pe) {
log.warning("Failure migrating schema", "dbident", _dbident, pe);
}
} | java | protected void configureDatabaseIdent (String dbident)
{
_dbident = dbident;
// give the repository a chance to do any schema migration before things get further
// underway
try {
executeUpdate(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
migrateSchema(conn, liaison);
return null;
}
});
} catch (PersistenceException pe) {
log.warning("Failure migrating schema", "dbident", _dbident, pe);
}
} | [
"protected",
"void",
"configureDatabaseIdent",
"(",
"String",
"dbident",
")",
"{",
"_dbident",
"=",
"dbident",
";",
"// give the repository a chance to do any schema migration before things get further",
"// underway",
"try",
"{",
"executeUpdate",
"(",
"new",
"Operation",
"<",
"Object",
">",
"(",
")",
"{",
"public",
"Object",
"invoke",
"(",
"Connection",
"conn",
",",
"DatabaseLiaison",
"liaison",
")",
"throws",
"SQLException",
",",
"PersistenceException",
"{",
"migrateSchema",
"(",
"conn",
",",
"liaison",
")",
";",
"return",
"null",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"PersistenceException",
"pe",
")",
"{",
"log",
".",
"warning",
"(",
"\"Failure migrating schema\"",
",",
"\"dbident\"",
",",
"_dbident",
",",
"pe",
")",
";",
"}",
"}"
] | This is called automatically if a dbident is provided at construct time, but a derived class
can pass null to its constructor and then call this method itself later if it wishes to
obtain its database identifier from an overridable method which could not otherwise be
called at construct time. | [
"This",
"is",
"called",
"automatically",
"if",
"a",
"dbident",
"is",
"provided",
"at",
"construct",
"time",
"but",
"a",
"derived",
"class",
"can",
"pass",
"null",
"to",
"its",
"constructor",
"and",
"then",
"call",
"this",
"method",
"itself",
"later",
"if",
"it",
"wishes",
"to",
"obtain",
"its",
"database",
"identifier",
"from",
"an",
"overridable",
"method",
"which",
"could",
"not",
"otherwise",
"be",
"called",
"at",
"construct",
"time",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/SimpleRepository.java#L63-L81 |
googleapis/google-cloud-java | google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/SubscriptionAdminClientSnippets.java | SubscriptionAdminClientSnippets.replacePushConfig | public void replacePushConfig(String subscriptionId, String endpoint) throws Exception {
"""
Example of replacing the push configuration of a subscription, setting the push endpoint.
"""
// [START pubsub_update_push_configuration]
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
ProjectSubscriptionName subscriptionName =
ProjectSubscriptionName.of(projectId, subscriptionId);
PushConfig pushConfig = PushConfig.newBuilder().setPushEndpoint(endpoint).build();
subscriptionAdminClient.modifyPushConfig(subscriptionName, pushConfig);
}
// [END pubsub_update_push_configuration]
} | java | public void replacePushConfig(String subscriptionId, String endpoint) throws Exception {
// [START pubsub_update_push_configuration]
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
ProjectSubscriptionName subscriptionName =
ProjectSubscriptionName.of(projectId, subscriptionId);
PushConfig pushConfig = PushConfig.newBuilder().setPushEndpoint(endpoint).build();
subscriptionAdminClient.modifyPushConfig(subscriptionName, pushConfig);
}
// [END pubsub_update_push_configuration]
} | [
"public",
"void",
"replacePushConfig",
"(",
"String",
"subscriptionId",
",",
"String",
"endpoint",
")",
"throws",
"Exception",
"{",
"// [START pubsub_update_push_configuration]",
"try",
"(",
"SubscriptionAdminClient",
"subscriptionAdminClient",
"=",
"SubscriptionAdminClient",
".",
"create",
"(",
")",
")",
"{",
"ProjectSubscriptionName",
"subscriptionName",
"=",
"ProjectSubscriptionName",
".",
"of",
"(",
"projectId",
",",
"subscriptionId",
")",
";",
"PushConfig",
"pushConfig",
"=",
"PushConfig",
".",
"newBuilder",
"(",
")",
".",
"setPushEndpoint",
"(",
"endpoint",
")",
".",
"build",
"(",
")",
";",
"subscriptionAdminClient",
".",
"modifyPushConfig",
"(",
"subscriptionName",
",",
"pushConfig",
")",
";",
"}",
"// [END pubsub_update_push_configuration]",
"}"
] | Example of replacing the push configuration of a subscription, setting the push endpoint. | [
"Example",
"of",
"replacing",
"the",
"push",
"configuration",
"of",
"a",
"subscription",
"setting",
"the",
"push",
"endpoint",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/SubscriptionAdminClientSnippets.java#L93-L102 |
apache/flink | flink-core/src/main/java/org/apache/flink/configuration/Configuration.java | Configuration.setLong | @PublicEvolving
public void setLong(ConfigOption<Long> key, long value) {
"""
Adds the given value to the configuration object.
The main key of the config option will be used to map the value.
@param key
the option specifying the key to be added
@param value
the value of the key/value pair to be added
"""
setValueInternal(key.key(), value);
} | java | @PublicEvolving
public void setLong(ConfigOption<Long> key, long value) {
setValueInternal(key.key(), value);
} | [
"@",
"PublicEvolving",
"public",
"void",
"setLong",
"(",
"ConfigOption",
"<",
"Long",
">",
"key",
",",
"long",
"value",
")",
"{",
"setValueInternal",
"(",
"key",
".",
"key",
"(",
")",
",",
"value",
")",
";",
"}"
] | Adds the given value to the configuration object.
The main key of the config option will be used to map the value.
@param key
the option specifying the key to be added
@param value
the value of the key/value pair to be added | [
"Adds",
"the",
"given",
"value",
"to",
"the",
"configuration",
"object",
".",
"The",
"main",
"key",
"of",
"the",
"config",
"option",
"will",
"be",
"used",
"to",
"map",
"the",
"value",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/configuration/Configuration.java#L338-L341 |
jMotif/SAX | src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java | SAXRecords.addAll | public void addAll(HashMap<Integer, char[]> records) {
"""
This adds all to the internal store. Used by the parallel SAX conversion engine.
@param records the data to add.
"""
for (Entry<Integer, char[]> e : records.entrySet()) {
this.add(e.getValue(), e.getKey());
}
} | java | public void addAll(HashMap<Integer, char[]> records) {
for (Entry<Integer, char[]> e : records.entrySet()) {
this.add(e.getValue(), e.getKey());
}
} | [
"public",
"void",
"addAll",
"(",
"HashMap",
"<",
"Integer",
",",
"char",
"[",
"]",
">",
"records",
")",
"{",
"for",
"(",
"Entry",
"<",
"Integer",
",",
"char",
"[",
"]",
">",
"e",
":",
"records",
".",
"entrySet",
"(",
")",
")",
"{",
"this",
".",
"add",
"(",
"e",
".",
"getValue",
"(",
")",
",",
"e",
".",
"getKey",
"(",
")",
")",
";",
"}",
"}"
] | This adds all to the internal store. Used by the parallel SAX conversion engine.
@param records the data to add. | [
"This",
"adds",
"all",
"to",
"the",
"internal",
"store",
".",
"Used",
"by",
"the",
"parallel",
"SAX",
"conversion",
"engine",
"."
] | train | https://github.com/jMotif/SAX/blob/39ee07a69facaa330def5130b8790aeda85f1061/src/main/java/net/seninp/jmotif/sax/datastructure/SAXRecords.java#L149-L153 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/Text.java | Text.getName | public static String getName(String path, boolean ignoreTrailingSlash) {
"""
Same as {@link #getName(String)} but adding the possibility to pass paths that end with a
trailing '/'
@see #getName(String)
"""
if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1)
{
path = path.substring(0, path.length() - 1);
}
return getName(path);
} | java | public static String getName(String path, boolean ignoreTrailingSlash)
{
if (ignoreTrailingSlash && path.endsWith("/") && path.length() > 1)
{
path = path.substring(0, path.length() - 1);
}
return getName(path);
} | [
"public",
"static",
"String",
"getName",
"(",
"String",
"path",
",",
"boolean",
"ignoreTrailingSlash",
")",
"{",
"if",
"(",
"ignoreTrailingSlash",
"&&",
"path",
".",
"endsWith",
"(",
"\"/\"",
")",
"&&",
"path",
".",
"length",
"(",
")",
">",
"1",
")",
"{",
"path",
"=",
"path",
".",
"substring",
"(",
"0",
",",
"path",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"getName",
"(",
"path",
")",
";",
"}"
] | Same as {@link #getName(String)} but adding the possibility to pass paths that end with a
trailing '/'
@see #getName(String) | [
"Same",
"as",
"{",
"@link",
"#getName",
"(",
"String",
")",
"}",
"but",
"adding",
"the",
"possibility",
"to",
"pass",
"paths",
"that",
"end",
"with",
"a",
"trailing",
"/"
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/Text.java#L646-L653 |
redkale/redkale | src/org/redkale/net/http/HttpRequest.java | HttpRequest.getShortParameter | public short getShortParameter(int radix, String name, short defaultValue) {
"""
获取指定的参数short值, 没有返回默认short值
@param radix 进制数
@param name 参数名
@param defaultValue 默认short值
@return 参数值
"""
parseBody();
return params.getShortValue(radix, name, defaultValue);
} | java | public short getShortParameter(int radix, String name, short defaultValue) {
parseBody();
return params.getShortValue(radix, name, defaultValue);
} | [
"public",
"short",
"getShortParameter",
"(",
"int",
"radix",
",",
"String",
"name",
",",
"short",
"defaultValue",
")",
"{",
"parseBody",
"(",
")",
";",
"return",
"params",
".",
"getShortValue",
"(",
"radix",
",",
"name",
",",
"defaultValue",
")",
";",
"}"
] | 获取指定的参数short值, 没有返回默认short值
@param radix 进制数
@param name 参数名
@param defaultValue 默认short值
@return 参数值 | [
"获取指定的参数short值",
"没有返回默认short值"
] | train | https://github.com/redkale/redkale/blob/ea5169b5c5ea7412fd762331c0c497165832e901/src/org/redkale/net/http/HttpRequest.java#L1341-L1344 |
ManfredTremmel/gwt-bean-validators | gwt-bean-validators/src/main/super/de/knightsoftnet/validators/supersource/org/apache/commons/beanutils/PropertyUtils.java | PropertyUtils.getProperty | public static Object getProperty(final Object pbean, final String pname)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
"""
<p>
Return the value of the specified property of the specified bean, no matter which property
reference format is used, with no type conversions.
</p>
<p>
For more details see <code>PropertyUtilsBean</code>.
</p>
@param pbean Bean whose property is to be extracted
@param pname Possibly indexed and/or nested name of the property to be extracted
@return the property value
@exception IllegalAccessException if the caller does not have access to the property accessor
method
@exception IllegalArgumentException if <code>bean</code> or <code>name</code> is null
@exception InvocationTargetException if the property accessor method throws an exception
@exception NoSuchMethodException if an accessor method for this propety cannot be found
@see PropertyUtilsBean#getProperty
"""
if (pbean == null) {
throw new NoSuchMethodException("A null object has no getters");
}
if (pname == null) {
throw new NoSuchMethodException("No method to get property for null");
}
final int posPoint = pname.indexOf('.');
try {
final AbstractGwtValidator validator =
(AbstractGwtValidator) Validation.buildDefaultValidatorFactory().getValidator();
if (posPoint >= 0) {
final Object subObject = validator.getProperty(pbean, pname.substring(0, posPoint));
if (subObject == null) {
throw new NestedNullException(
"Null property value for '" + pname + "' on bean class '" + pbean.getClass() + "'");
}
return getProperty(subObject, pname.substring(posPoint + 1));
}
return validator.getProperty(pbean, pname);
} catch (final ReflectiveOperationException e) {
throw new InvocationTargetException(e);
}
} | java | public static Object getProperty(final Object pbean, final String pname)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (pbean == null) {
throw new NoSuchMethodException("A null object has no getters");
}
if (pname == null) {
throw new NoSuchMethodException("No method to get property for null");
}
final int posPoint = pname.indexOf('.');
try {
final AbstractGwtValidator validator =
(AbstractGwtValidator) Validation.buildDefaultValidatorFactory().getValidator();
if (posPoint >= 0) {
final Object subObject = validator.getProperty(pbean, pname.substring(0, posPoint));
if (subObject == null) {
throw new NestedNullException(
"Null property value for '" + pname + "' on bean class '" + pbean.getClass() + "'");
}
return getProperty(subObject, pname.substring(posPoint + 1));
}
return validator.getProperty(pbean, pname);
} catch (final ReflectiveOperationException e) {
throw new InvocationTargetException(e);
}
} | [
"public",
"static",
"Object",
"getProperty",
"(",
"final",
"Object",
"pbean",
",",
"final",
"String",
"pname",
")",
"throws",
"IllegalAccessException",
",",
"InvocationTargetException",
",",
"NoSuchMethodException",
"{",
"if",
"(",
"pbean",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"A null object has no getters\"",
")",
";",
"}",
"if",
"(",
"pname",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"No method to get property for null\"",
")",
";",
"}",
"final",
"int",
"posPoint",
"=",
"pname",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"try",
"{",
"final",
"AbstractGwtValidator",
"validator",
"=",
"(",
"AbstractGwtValidator",
")",
"Validation",
".",
"buildDefaultValidatorFactory",
"(",
")",
".",
"getValidator",
"(",
")",
";",
"if",
"(",
"posPoint",
">=",
"0",
")",
"{",
"final",
"Object",
"subObject",
"=",
"validator",
".",
"getProperty",
"(",
"pbean",
",",
"pname",
".",
"substring",
"(",
"0",
",",
"posPoint",
")",
")",
";",
"if",
"(",
"subObject",
"==",
"null",
")",
"{",
"throw",
"new",
"NestedNullException",
"(",
"\"Null property value for '\"",
"+",
"pname",
"+",
"\"' on bean class '\"",
"+",
"pbean",
".",
"getClass",
"(",
")",
"+",
"\"'\"",
")",
";",
"}",
"return",
"getProperty",
"(",
"subObject",
",",
"pname",
".",
"substring",
"(",
"posPoint",
"+",
"1",
")",
")",
";",
"}",
"return",
"validator",
".",
"getProperty",
"(",
"pbean",
",",
"pname",
")",
";",
"}",
"catch",
"(",
"final",
"ReflectiveOperationException",
"e",
")",
"{",
"throw",
"new",
"InvocationTargetException",
"(",
"e",
")",
";",
"}",
"}"
] | <p>
Return the value of the specified property of the specified bean, no matter which property
reference format is used, with no type conversions.
</p>
<p>
For more details see <code>PropertyUtilsBean</code>.
</p>
@param pbean Bean whose property is to be extracted
@param pname Possibly indexed and/or nested name of the property to be extracted
@return the property value
@exception IllegalAccessException if the caller does not have access to the property accessor
method
@exception IllegalArgumentException if <code>bean</code> or <code>name</code> is null
@exception InvocationTargetException if the property accessor method throws an exception
@exception NoSuchMethodException if an accessor method for this propety cannot be found
@see PropertyUtilsBean#getProperty | [
"<p",
">",
"Return",
"the",
"value",
"of",
"the",
"specified",
"property",
"of",
"the",
"specified",
"bean",
"no",
"matter",
"which",
"property",
"reference",
"format",
"is",
"used",
"with",
"no",
"type",
"conversions",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/gwt-bean-validators/src/main/super/de/knightsoftnet/validators/supersource/org/apache/commons/beanutils/PropertyUtils.java#L55-L81 |
alkacon/opencms-core | src-gwt/org/opencms/ade/sitemap/client/alias/simple/CmsAliasPathColumn.java | CmsAliasPathColumn.getComparator | public static Comparator<CmsAliasTableRow> getComparator() {
"""
Gets the comparator used for this column.<p>
@return the comparator to use for this row
"""
return new Comparator<CmsAliasTableRow>() {
public int compare(CmsAliasTableRow o1, CmsAliasTableRow o2) {
return o1.getAliasPath().toString().compareTo(o2.getAliasPath().toString());
}
};
} | java | public static Comparator<CmsAliasTableRow> getComparator() {
return new Comparator<CmsAliasTableRow>() {
public int compare(CmsAliasTableRow o1, CmsAliasTableRow o2) {
return o1.getAliasPath().toString().compareTo(o2.getAliasPath().toString());
}
};
} | [
"public",
"static",
"Comparator",
"<",
"CmsAliasTableRow",
">",
"getComparator",
"(",
")",
"{",
"return",
"new",
"Comparator",
"<",
"CmsAliasTableRow",
">",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"CmsAliasTableRow",
"o1",
",",
"CmsAliasTableRow",
"o2",
")",
"{",
"return",
"o1",
".",
"getAliasPath",
"(",
")",
".",
"toString",
"(",
")",
".",
"compareTo",
"(",
"o2",
".",
"getAliasPath",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
";",
"}"
] | Gets the comparator used for this column.<p>
@return the comparator to use for this row | [
"Gets",
"the",
"comparator",
"used",
"for",
"this",
"column",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/sitemap/client/alias/simple/CmsAliasPathColumn.java#L75-L84 |
jayantk/jklol | src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java | HeadedSyntacticCategory.addArgument | public HeadedSyntacticCategory addArgument(HeadedSyntacticCategory argument, Direction direction,
int rootVarNum) {
"""
Gets the syntactic category and semantic variables that accepts
{@code argument} on {@code direction} and returns {@code this}.
Any semantic variables in both {@code argument} and {@code this}
are assumed to be equivalent.
@param argument
@param direction
@param rootVarNum
@return
"""
SyntacticCategory newCategory = syntacticCategory.addArgument(argument.getSyntax(), direction);
int[] newSemantics = Ints.concat(semanticVariables, new int[] { rootVarNum },
argument.semanticVariables);
int newRoot = semanticVariables.length;
return new HeadedSyntacticCategory(newCategory, newSemantics, newRoot);
} | java | public HeadedSyntacticCategory addArgument(HeadedSyntacticCategory argument, Direction direction,
int rootVarNum) {
SyntacticCategory newCategory = syntacticCategory.addArgument(argument.getSyntax(), direction);
int[] newSemantics = Ints.concat(semanticVariables, new int[] { rootVarNum },
argument.semanticVariables);
int newRoot = semanticVariables.length;
return new HeadedSyntacticCategory(newCategory, newSemantics, newRoot);
} | [
"public",
"HeadedSyntacticCategory",
"addArgument",
"(",
"HeadedSyntacticCategory",
"argument",
",",
"Direction",
"direction",
",",
"int",
"rootVarNum",
")",
"{",
"SyntacticCategory",
"newCategory",
"=",
"syntacticCategory",
".",
"addArgument",
"(",
"argument",
".",
"getSyntax",
"(",
")",
",",
"direction",
")",
";",
"int",
"[",
"]",
"newSemantics",
"=",
"Ints",
".",
"concat",
"(",
"semanticVariables",
",",
"new",
"int",
"[",
"]",
"{",
"rootVarNum",
"}",
",",
"argument",
".",
"semanticVariables",
")",
";",
"int",
"newRoot",
"=",
"semanticVariables",
".",
"length",
";",
"return",
"new",
"HeadedSyntacticCategory",
"(",
"newCategory",
",",
"newSemantics",
",",
"newRoot",
")",
";",
"}"
] | Gets the syntactic category and semantic variables that accepts
{@code argument} on {@code direction} and returns {@code this}.
Any semantic variables in both {@code argument} and {@code this}
are assumed to be equivalent.
@param argument
@param direction
@param rootVarNum
@return | [
"Gets",
"the",
"syntactic",
"category",
"and",
"semantic",
"variables",
"that",
"accepts",
"{",
"@code",
"argument",
"}",
"on",
"{",
"@code",
"direction",
"}",
"and",
"returns",
"{",
"@code",
"this",
"}",
".",
"Any",
"semantic",
"variables",
"in",
"both",
"{",
"@code",
"argument",
"}",
"and",
"{",
"@code",
"this",
"}",
"are",
"assumed",
"to",
"be",
"equivalent",
"."
] | train | https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java#L309-L316 |
Erudika/para | para-server/src/main/java/com/erudika/para/rest/RestUtils.java | RestUtils.queryParam | public static String queryParam(String param, ContainerRequestContext ctx) {
"""
Returns the query parameter value.
@param param a parameter name
@param ctx ctx
@return parameter value
"""
return ctx.getUriInfo().getQueryParameters().getFirst(param);
} | java | public static String queryParam(String param, ContainerRequestContext ctx) {
return ctx.getUriInfo().getQueryParameters().getFirst(param);
} | [
"public",
"static",
"String",
"queryParam",
"(",
"String",
"param",
",",
"ContainerRequestContext",
"ctx",
")",
"{",
"return",
"ctx",
".",
"getUriInfo",
"(",
")",
".",
"getQueryParameters",
"(",
")",
".",
"getFirst",
"(",
"param",
")",
";",
"}"
] | Returns the query parameter value.
@param param a parameter name
@param ctx ctx
@return parameter value | [
"Returns",
"the",
"query",
"parameter",
"value",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/rest/RestUtils.java#L1012-L1014 |
kaazing/gateway | mina.core/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java | AbstractProxyLogicHandler.closeSession | protected void closeSession(final String message, final Throwable t) {
"""
Closes the session.
@param message the error message
@param t the exception which caused the session closing
"""
if (t != null) {
LOGGER.error(message, t);
proxyIoSession.setAuthenticationFailed(true);
} else {
LOGGER.error(message);
}
getSession().close(true);
} | java | protected void closeSession(final String message, final Throwable t) {
if (t != null) {
LOGGER.error(message, t);
proxyIoSession.setAuthenticationFailed(true);
} else {
LOGGER.error(message);
}
getSession().close(true);
} | [
"protected",
"void",
"closeSession",
"(",
"final",
"String",
"message",
",",
"final",
"Throwable",
"t",
")",
"{",
"if",
"(",
"t",
"!=",
"null",
")",
"{",
"LOGGER",
".",
"error",
"(",
"message",
",",
"t",
")",
";",
"proxyIoSession",
".",
"setAuthenticationFailed",
"(",
"true",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"error",
"(",
"message",
")",
";",
"}",
"getSession",
"(",
")",
".",
"close",
"(",
"true",
")",
";",
"}"
] | Closes the session.
@param message the error message
@param t the exception which caused the session closing | [
"Closes",
"the",
"session",
"."
] | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.core/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java#L188-L197 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java | JDBCResultSet.updateLong | public void updateLong(int columnIndex, long x) throws SQLException {
"""
<!-- start generic documentation -->
Updates the designated column with a <code>long</code> value.
The updater methods are used to update column values in the
current row or the insert row. The updater methods do not
update the underlying database; instead the <code>updateRow</code> or
<code>insertRow</code> methods are called to update the database.
<!-- end generic documentation -->
<!-- start release-specific documentation -->
<div class="ReleaseSpecificDocumentation">
<h3>HSQLDB-Specific Information:</h3> <p>
HSQLDB supports this feature. <p>
</div>
<!-- end release-specific documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@param x the new column value
@exception SQLException if a database access error occurs,
the result set concurrency is <code>CONCUR_READ_ONLY</code>
or this method is called on a closed result set
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
@since JDK 1.2 (JDK 1.1.x developers: read the overview for
JDBCResultSet)
"""
startUpdate(columnIndex);
preparedStatement.setLongParameter(columnIndex, x);
} | java | public void updateLong(int columnIndex, long x) throws SQLException {
startUpdate(columnIndex);
preparedStatement.setLongParameter(columnIndex, x);
} | [
"public",
"void",
"updateLong",
"(",
"int",
"columnIndex",
",",
"long",
"x",
")",
"throws",
"SQLException",
"{",
"startUpdate",
"(",
"columnIndex",
")",
";",
"preparedStatement",
".",
"setLongParameter",
"(",
"columnIndex",
",",
"x",
")",
";",
"}"
] | <!-- start generic documentation -->
Updates the designated column with a <code>long</code> value.
The updater methods are used to update column values in the
current row or the insert row. The updater methods do not
update the underlying database; instead the <code>updateRow</code> or
<code>insertRow</code> methods are called to update the database.
<!-- end generic documentation -->
<!-- start release-specific documentation -->
<div class="ReleaseSpecificDocumentation">
<h3>HSQLDB-Specific Information:</h3> <p>
HSQLDB supports this feature. <p>
</div>
<!-- end release-specific documentation -->
@param columnIndex the first column is 1, the second is 2, ...
@param x the new column value
@exception SQLException if a database access error occurs,
the result set concurrency is <code>CONCUR_READ_ONLY</code>
or this method is called on a closed result set
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
@since JDK 1.2 (JDK 1.1.x developers: read the overview for
JDBCResultSet) | [
"<!",
"--",
"start",
"generic",
"documentation",
"--",
">",
"Updates",
"the",
"designated",
"column",
"with",
"a",
"<code",
">",
"long<",
"/",
"code",
">",
"value",
".",
"The",
"updater",
"methods",
"are",
"used",
"to",
"update",
"column",
"values",
"in",
"the",
"current",
"row",
"or",
"the",
"insert",
"row",
".",
"The",
"updater",
"methods",
"do",
"not",
"update",
"the",
"underlying",
"database",
";",
"instead",
"the",
"<code",
">",
"updateRow<",
"/",
"code",
">",
"or",
"<code",
">",
"insertRow<",
"/",
"code",
">",
"methods",
"are",
"called",
"to",
"update",
"the",
"database",
".",
"<!",
"--",
"end",
"generic",
"documentation",
"--",
">"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/jdbc/JDBCResultSet.java#L2781-L2784 |
grails/grails-core | grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java | GrailsASTUtils.findConstructor | public static ConstructorNode findConstructor(ClassNode classNode,Parameter[] constructorParams) {
"""
Finds a constructor for the given class node and parameter types
@param classNode The class node
@param constructorParams The parameter types
@return The located constructor or null
"""
List<ConstructorNode> declaredConstructors = classNode.getDeclaredConstructors();
for (ConstructorNode declaredConstructor : declaredConstructors) {
if (parametersEqual(constructorParams, declaredConstructor.getParameters())) {
return declaredConstructor;
}
}
return null;
} | java | public static ConstructorNode findConstructor(ClassNode classNode,Parameter[] constructorParams) {
List<ConstructorNode> declaredConstructors = classNode.getDeclaredConstructors();
for (ConstructorNode declaredConstructor : declaredConstructors) {
if (parametersEqual(constructorParams, declaredConstructor.getParameters())) {
return declaredConstructor;
}
}
return null;
} | [
"public",
"static",
"ConstructorNode",
"findConstructor",
"(",
"ClassNode",
"classNode",
",",
"Parameter",
"[",
"]",
"constructorParams",
")",
"{",
"List",
"<",
"ConstructorNode",
">",
"declaredConstructors",
"=",
"classNode",
".",
"getDeclaredConstructors",
"(",
")",
";",
"for",
"(",
"ConstructorNode",
"declaredConstructor",
":",
"declaredConstructors",
")",
"{",
"if",
"(",
"parametersEqual",
"(",
"constructorParams",
",",
"declaredConstructor",
".",
"getParameters",
"(",
")",
")",
")",
"{",
"return",
"declaredConstructor",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Finds a constructor for the given class node and parameter types
@param classNode The class node
@param constructorParams The parameter types
@return The located constructor or null | [
"Finds",
"a",
"constructor",
"for",
"the",
"given",
"class",
"node",
"and",
"parameter",
"types"
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/compiler/injection/GrailsASTUtils.java#L511-L519 |
alkacon/opencms-core | src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java | CmsDefaultXmlContentHandler.initTemplates | protected void initTemplates(Element root, CmsXmlContentDefinition contentDefinition) {
"""
Initializes the forbidden template contexts.<p>
@param root the root XML element
@param contentDefinition the content definition
"""
String strEnabledByDefault = root.attributeValue(ATTR_ENABLED_BY_DEFAULT);
m_allowedTemplates.setDefaultMembership(safeParseBoolean(strEnabledByDefault, true));
List<Node> elements = root.selectNodes(APPINFO_TEMPLATE);
for (Node elem : elements) {
boolean enabled = safeParseBoolean(((Element)elem).attributeValue(ATTR_ENABLED), true);
String templateName = elem.getText().trim();
m_allowedTemplates.setContains(templateName, enabled);
}
m_allowedTemplates.freeze();
} | java | protected void initTemplates(Element root, CmsXmlContentDefinition contentDefinition) {
String strEnabledByDefault = root.attributeValue(ATTR_ENABLED_BY_DEFAULT);
m_allowedTemplates.setDefaultMembership(safeParseBoolean(strEnabledByDefault, true));
List<Node> elements = root.selectNodes(APPINFO_TEMPLATE);
for (Node elem : elements) {
boolean enabled = safeParseBoolean(((Element)elem).attributeValue(ATTR_ENABLED), true);
String templateName = elem.getText().trim();
m_allowedTemplates.setContains(templateName, enabled);
}
m_allowedTemplates.freeze();
} | [
"protected",
"void",
"initTemplates",
"(",
"Element",
"root",
",",
"CmsXmlContentDefinition",
"contentDefinition",
")",
"{",
"String",
"strEnabledByDefault",
"=",
"root",
".",
"attributeValue",
"(",
"ATTR_ENABLED_BY_DEFAULT",
")",
";",
"m_allowedTemplates",
".",
"setDefaultMembership",
"(",
"safeParseBoolean",
"(",
"strEnabledByDefault",
",",
"true",
")",
")",
";",
"List",
"<",
"Node",
">",
"elements",
"=",
"root",
".",
"selectNodes",
"(",
"APPINFO_TEMPLATE",
")",
";",
"for",
"(",
"Node",
"elem",
":",
"elements",
")",
"{",
"boolean",
"enabled",
"=",
"safeParseBoolean",
"(",
"(",
"(",
"Element",
")",
"elem",
")",
".",
"attributeValue",
"(",
"ATTR_ENABLED",
")",
",",
"true",
")",
";",
"String",
"templateName",
"=",
"elem",
".",
"getText",
"(",
")",
".",
"trim",
"(",
")",
";",
"m_allowedTemplates",
".",
"setContains",
"(",
"templateName",
",",
"enabled",
")",
";",
"}",
"m_allowedTemplates",
".",
"freeze",
"(",
")",
";",
"}"
] | Initializes the forbidden template contexts.<p>
@param root the root XML element
@param contentDefinition the content definition | [
"Initializes",
"the",
"forbidden",
"template",
"contexts",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java#L3169-L3180 |
albfernandez/itext2 | src/main/java/com/lowagie/text/rtf/headerfooter/RtfHeaderFooterGroup.java | RtfHeaderFooterGroup.setHeaderFooter | public void setHeaderFooter(RtfHeaderFooter headerFooter, int displayAt) {
"""
Set a RtfHeaderFooter to be displayed at a certain position
@param headerFooter The RtfHeaderFooter to display
@param displayAt The display location to use
"""
this.mode = MODE_MULTIPLE;
headerFooter.setRtfDocument(this.document);
headerFooter.setType(this.type);
headerFooter.setDisplayAt(displayAt);
switch(displayAt) {
case RtfHeaderFooter.DISPLAY_ALL_PAGES:
headerAll = headerFooter;
break;
case RtfHeaderFooter.DISPLAY_FIRST_PAGE:
headerFirst = headerFooter;
break;
case RtfHeaderFooter.DISPLAY_LEFT_PAGES:
headerLeft = headerFooter;
break;
case RtfHeaderFooter.DISPLAY_RIGHT_PAGES:
headerRight = headerFooter;
break;
}
} | java | public void setHeaderFooter(RtfHeaderFooter headerFooter, int displayAt) {
this.mode = MODE_MULTIPLE;
headerFooter.setRtfDocument(this.document);
headerFooter.setType(this.type);
headerFooter.setDisplayAt(displayAt);
switch(displayAt) {
case RtfHeaderFooter.DISPLAY_ALL_PAGES:
headerAll = headerFooter;
break;
case RtfHeaderFooter.DISPLAY_FIRST_PAGE:
headerFirst = headerFooter;
break;
case RtfHeaderFooter.DISPLAY_LEFT_PAGES:
headerLeft = headerFooter;
break;
case RtfHeaderFooter.DISPLAY_RIGHT_PAGES:
headerRight = headerFooter;
break;
}
} | [
"public",
"void",
"setHeaderFooter",
"(",
"RtfHeaderFooter",
"headerFooter",
",",
"int",
"displayAt",
")",
"{",
"this",
".",
"mode",
"=",
"MODE_MULTIPLE",
";",
"headerFooter",
".",
"setRtfDocument",
"(",
"this",
".",
"document",
")",
";",
"headerFooter",
".",
"setType",
"(",
"this",
".",
"type",
")",
";",
"headerFooter",
".",
"setDisplayAt",
"(",
"displayAt",
")",
";",
"switch",
"(",
"displayAt",
")",
"{",
"case",
"RtfHeaderFooter",
".",
"DISPLAY_ALL_PAGES",
":",
"headerAll",
"=",
"headerFooter",
";",
"break",
";",
"case",
"RtfHeaderFooter",
".",
"DISPLAY_FIRST_PAGE",
":",
"headerFirst",
"=",
"headerFooter",
";",
"break",
";",
"case",
"RtfHeaderFooter",
".",
"DISPLAY_LEFT_PAGES",
":",
"headerLeft",
"=",
"headerFooter",
";",
"break",
";",
"case",
"RtfHeaderFooter",
".",
"DISPLAY_RIGHT_PAGES",
":",
"headerRight",
"=",
"headerFooter",
";",
"break",
";",
"}",
"}"
] | Set a RtfHeaderFooter to be displayed at a certain position
@param headerFooter The RtfHeaderFooter to display
@param displayAt The display location to use | [
"Set",
"a",
"RtfHeaderFooter",
"to",
"be",
"displayed",
"at",
"a",
"certain",
"position"
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/rtf/headerfooter/RtfHeaderFooterGroup.java#L247-L266 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java | TagletManager.addNewSimpleCustomTag | public void addNewSimpleCustomTag(String tagName, String header, String locations) {
"""
Add a new <code>SimpleTaglet</code>. If this tag already exists
and the header passed as an argument is null, move tag to the back of the
list. If this tag already exists and the header passed as an argument is
not null, overwrite previous tag with new one. Otherwise, add new
SimpleTaglet to list.
@param tagName the name of this tag
@param header the header to output.
@param locations the possible locations that this tag
can appear in.
"""
if (tagName == null || locations == null) {
return;
}
Taglet tag = customTags.get(tagName);
locations = StringUtils.toLowerCase(locations);
if (tag == null || header != null) {
customTags.remove(tagName);
customTags.put(tagName, new SimpleTaglet(tagName, header, locations));
if (locations != null && locations.indexOf('x') == -1) {
checkTagName(tagName);
}
} else {
//Move to back
customTags.remove(tagName);
customTags.put(tagName, tag);
}
} | java | public void addNewSimpleCustomTag(String tagName, String header, String locations) {
if (tagName == null || locations == null) {
return;
}
Taglet tag = customTags.get(tagName);
locations = StringUtils.toLowerCase(locations);
if (tag == null || header != null) {
customTags.remove(tagName);
customTags.put(tagName, new SimpleTaglet(tagName, header, locations));
if (locations != null && locations.indexOf('x') == -1) {
checkTagName(tagName);
}
} else {
//Move to back
customTags.remove(tagName);
customTags.put(tagName, tag);
}
} | [
"public",
"void",
"addNewSimpleCustomTag",
"(",
"String",
"tagName",
",",
"String",
"header",
",",
"String",
"locations",
")",
"{",
"if",
"(",
"tagName",
"==",
"null",
"||",
"locations",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Taglet",
"tag",
"=",
"customTags",
".",
"get",
"(",
"tagName",
")",
";",
"locations",
"=",
"StringUtils",
".",
"toLowerCase",
"(",
"locations",
")",
";",
"if",
"(",
"tag",
"==",
"null",
"||",
"header",
"!=",
"null",
")",
"{",
"customTags",
".",
"remove",
"(",
"tagName",
")",
";",
"customTags",
".",
"put",
"(",
"tagName",
",",
"new",
"SimpleTaglet",
"(",
"tagName",
",",
"header",
",",
"locations",
")",
")",
";",
"if",
"(",
"locations",
"!=",
"null",
"&&",
"locations",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"-",
"1",
")",
"{",
"checkTagName",
"(",
"tagName",
")",
";",
"}",
"}",
"else",
"{",
"//Move to back",
"customTags",
".",
"remove",
"(",
"tagName",
")",
";",
"customTags",
".",
"put",
"(",
"tagName",
",",
"tag",
")",
";",
"}",
"}"
] | Add a new <code>SimpleTaglet</code>. If this tag already exists
and the header passed as an argument is null, move tag to the back of the
list. If this tag already exists and the header passed as an argument is
not null, overwrite previous tag with new one. Otherwise, add new
SimpleTaglet to list.
@param tagName the name of this tag
@param header the header to output.
@param locations the possible locations that this tag
can appear in. | [
"Add",
"a",
"new",
"<code",
">",
"SimpleTaglet<",
"/",
"code",
">",
".",
"If",
"this",
"tag",
"already",
"exists",
"and",
"the",
"header",
"passed",
"as",
"an",
"argument",
"is",
"null",
"move",
"tag",
"to",
"the",
"back",
"of",
"the",
"list",
".",
"If",
"this",
"tag",
"already",
"exists",
"and",
"the",
"header",
"passed",
"as",
"an",
"argument",
"is",
"not",
"null",
"overwrite",
"previous",
"tag",
"with",
"new",
"one",
".",
"Otherwise",
"add",
"new",
"SimpleTaglet",
"to",
"list",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java#L352-L369 |
dadoonet/elasticsearch-beyonder | src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java | IndexElasticsearchUpdater.updateSettings | @Deprecated
public static void updateSettings(Client client, String root, String index) throws Exception {
"""
Update index settings in Elasticsearch. Read also _update_settings.json if exists.
@param client Elasticsearch client
@param root dir within the classpath
@param index Index name
@throws Exception if the elasticsearch API call is failing
"""
String settings = IndexSettingsReader.readUpdateSettings(root, index);
updateIndexWithSettingsInElasticsearch(client, index, settings);
} | java | @Deprecated
public static void updateSettings(Client client, String root, String index) throws Exception {
String settings = IndexSettingsReader.readUpdateSettings(root, index);
updateIndexWithSettingsInElasticsearch(client, index, settings);
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"updateSettings",
"(",
"Client",
"client",
",",
"String",
"root",
",",
"String",
"index",
")",
"throws",
"Exception",
"{",
"String",
"settings",
"=",
"IndexSettingsReader",
".",
"readUpdateSettings",
"(",
"root",
",",
"index",
")",
";",
"updateIndexWithSettingsInElasticsearch",
"(",
"client",
",",
"index",
",",
"settings",
")",
";",
"}"
] | Update index settings in Elasticsearch. Read also _update_settings.json if exists.
@param client Elasticsearch client
@param root dir within the classpath
@param index Index name
@throws Exception if the elasticsearch API call is failing | [
"Update",
"index",
"settings",
"in",
"Elasticsearch",
".",
"Read",
"also",
"_update_settings",
".",
"json",
"if",
"exists",
"."
] | train | https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java#L184-L188 |
mapbox/mapbox-java | services-turf/src/main/java/com/mapbox/turf/TurfAssertions.java | TurfAssertions.collectionOf | public static void collectionOf(FeatureCollection featureCollection, String type, String name) {
"""
Enforce expectations about types of {@link FeatureCollection} inputs for Turf. Internally
this uses {@link Feature#type()}} to judge geometry types.
@param featureCollection for which features will be judged
@param type expected GeoJson type
@param name name of calling function
@see <a href="http://turfjs.org/docs/#collectionof">Turf collectionOf documentation</a>
@since 1.2.0
"""
if (name == null || name.length() == 0) {
throw new TurfException("collectionOf() requires a name");
}
if (featureCollection == null || !featureCollection.type().equals("FeatureCollection")
|| featureCollection.features() == null) {
throw new TurfException(String.format(
"Invalid input to %s, FeatureCollection required", name));
}
for (Feature feature : featureCollection.features()) {
if (feature == null || !feature.type().equals("Feature") || feature.geometry() == null) {
throw new TurfException(String.format(
"Invalid input to %s, Feature with geometry required", name));
}
if (feature.geometry() == null || !feature.geometry().type().equals(type)) {
throw new TurfException(String.format(
"Invalid input to %s: must be a %s, given %s", name, type, feature.geometry().type()));
}
}
} | java | public static void collectionOf(FeatureCollection featureCollection, String type, String name) {
if (name == null || name.length() == 0) {
throw new TurfException("collectionOf() requires a name");
}
if (featureCollection == null || !featureCollection.type().equals("FeatureCollection")
|| featureCollection.features() == null) {
throw new TurfException(String.format(
"Invalid input to %s, FeatureCollection required", name));
}
for (Feature feature : featureCollection.features()) {
if (feature == null || !feature.type().equals("Feature") || feature.geometry() == null) {
throw new TurfException(String.format(
"Invalid input to %s, Feature with geometry required", name));
}
if (feature.geometry() == null || !feature.geometry().type().equals(type)) {
throw new TurfException(String.format(
"Invalid input to %s: must be a %s, given %s", name, type, feature.geometry().type()));
}
}
} | [
"public",
"static",
"void",
"collectionOf",
"(",
"FeatureCollection",
"featureCollection",
",",
"String",
"type",
",",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"TurfException",
"(",
"\"collectionOf() requires a name\"",
")",
";",
"}",
"if",
"(",
"featureCollection",
"==",
"null",
"||",
"!",
"featureCollection",
".",
"type",
"(",
")",
".",
"equals",
"(",
"\"FeatureCollection\"",
")",
"||",
"featureCollection",
".",
"features",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"TurfException",
"(",
"String",
".",
"format",
"(",
"\"Invalid input to %s, FeatureCollection required\"",
",",
"name",
")",
")",
";",
"}",
"for",
"(",
"Feature",
"feature",
":",
"featureCollection",
".",
"features",
"(",
")",
")",
"{",
"if",
"(",
"feature",
"==",
"null",
"||",
"!",
"feature",
".",
"type",
"(",
")",
".",
"equals",
"(",
"\"Feature\"",
")",
"||",
"feature",
".",
"geometry",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"TurfException",
"(",
"String",
".",
"format",
"(",
"\"Invalid input to %s, Feature with geometry required\"",
",",
"name",
")",
")",
";",
"}",
"if",
"(",
"feature",
".",
"geometry",
"(",
")",
"==",
"null",
"||",
"!",
"feature",
".",
"geometry",
"(",
")",
".",
"type",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"{",
"throw",
"new",
"TurfException",
"(",
"String",
".",
"format",
"(",
"\"Invalid input to %s: must be a %s, given %s\"",
",",
"name",
",",
"type",
",",
"feature",
".",
"geometry",
"(",
")",
".",
"type",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] | Enforce expectations about types of {@link FeatureCollection} inputs for Turf. Internally
this uses {@link Feature#type()}} to judge geometry types.
@param featureCollection for which features will be judged
@param type expected GeoJson type
@param name name of calling function
@see <a href="http://turfjs.org/docs/#collectionof">Turf collectionOf documentation</a>
@since 1.2.0 | [
"Enforce",
"expectations",
"about",
"types",
"of",
"{",
"@link",
"FeatureCollection",
"}",
"inputs",
"for",
"Turf",
".",
"Internally",
"this",
"uses",
"{",
"@link",
"Feature#type",
"()",
"}}",
"to",
"judge",
"geometry",
"types",
"."
] | train | https://github.com/mapbox/mapbox-java/blob/c0be138f462f91441388584c668f3760ba0e18e2/services-turf/src/main/java/com/mapbox/turf/TurfAssertions.java#L88-L107 |
lettuce-io/lettuce-core | src/main/java/io/lettuce/core/internal/AsyncConnectionProvider.java | AsyncConnectionProvider.forEach | public void forEach(BiConsumer<? super K, ? super T> action) {
"""
Execute an action for all established and pending {@link AsyncCloseable}s.
@param action the action.
"""
connections.forEach((key, sync) -> sync.doWithConnection(action));
} | java | public void forEach(BiConsumer<? super K, ? super T> action) {
connections.forEach((key, sync) -> sync.doWithConnection(action));
} | [
"public",
"void",
"forEach",
"(",
"BiConsumer",
"<",
"?",
"super",
"K",
",",
"?",
"super",
"T",
">",
"action",
")",
"{",
"connections",
".",
"forEach",
"(",
"(",
"key",
",",
"sync",
")",
"->",
"sync",
".",
"doWithConnection",
"(",
"action",
")",
")",
";",
"}"
] | Execute an action for all established and pending {@link AsyncCloseable}s.
@param action the action. | [
"Execute",
"an",
"action",
"for",
"all",
"established",
"and",
"pending",
"{",
"@link",
"AsyncCloseable",
"}",
"s",
"."
] | train | https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/internal/AsyncConnectionProvider.java#L198-L200 |
ravendb/ravendb-jvm-client | src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java | DocumentConventions.getJavaClass | public String getJavaClass(String id, ObjectNode document) {
"""
Get the java class (if exists) from the document
@param id document id
@param document document to get java class from
@return java class
"""
return _findJavaClass.apply(id, document);
} | java | public String getJavaClass(String id, ObjectNode document) {
return _findJavaClass.apply(id, document);
} | [
"public",
"String",
"getJavaClass",
"(",
"String",
"id",
",",
"ObjectNode",
"document",
")",
"{",
"return",
"_findJavaClass",
".",
"apply",
"(",
"id",
",",
"document",
")",
";",
"}"
] | Get the java class (if exists) from the document
@param id document id
@param document document to get java class from
@return java class | [
"Get",
"the",
"java",
"class",
"(",
"if",
"exists",
")",
"from",
"the",
"document"
] | train | https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/documents/conventions/DocumentConventions.java#L403-L405 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/operation/PublisherCreateOperation.java | PublisherCreateOperation.replayEventsOverResultSet | private void replayEventsOverResultSet(QueryResult queryResult) throws Exception {
"""
Replay events over the result set of initial query. These events are
received events during execution of the initial query.
"""
Map<Integer, Future<Object>> future = readAccumulators();
for (Map.Entry<Integer, Future<Object>> entry : future.entrySet()) {
int partitionId = entry.getKey();
Object eventsInOneAcc = entry.getValue().get();
if (eventsInOneAcc == null) {
continue;
}
eventsInOneAcc = mapServiceContext.toObject(eventsInOneAcc);
List<QueryCacheEventData> eventDataList = (List<QueryCacheEventData>) eventsInOneAcc;
for (QueryCacheEventData eventData : eventDataList) {
if (eventData.getDataKey() == null) {
// this means a map-wide event like clear-all or evict-all
// is inside the accumulator buffers
removePartitionResults(queryResult, partitionId);
} else {
add(queryResult, newQueryResultRow(eventData));
}
}
}
} | java | private void replayEventsOverResultSet(QueryResult queryResult) throws Exception {
Map<Integer, Future<Object>> future = readAccumulators();
for (Map.Entry<Integer, Future<Object>> entry : future.entrySet()) {
int partitionId = entry.getKey();
Object eventsInOneAcc = entry.getValue().get();
if (eventsInOneAcc == null) {
continue;
}
eventsInOneAcc = mapServiceContext.toObject(eventsInOneAcc);
List<QueryCacheEventData> eventDataList = (List<QueryCacheEventData>) eventsInOneAcc;
for (QueryCacheEventData eventData : eventDataList) {
if (eventData.getDataKey() == null) {
// this means a map-wide event like clear-all or evict-all
// is inside the accumulator buffers
removePartitionResults(queryResult, partitionId);
} else {
add(queryResult, newQueryResultRow(eventData));
}
}
}
} | [
"private",
"void",
"replayEventsOverResultSet",
"(",
"QueryResult",
"queryResult",
")",
"throws",
"Exception",
"{",
"Map",
"<",
"Integer",
",",
"Future",
"<",
"Object",
">",
">",
"future",
"=",
"readAccumulators",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"Future",
"<",
"Object",
">",
">",
"entry",
":",
"future",
".",
"entrySet",
"(",
")",
")",
"{",
"int",
"partitionId",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"Object",
"eventsInOneAcc",
"=",
"entry",
".",
"getValue",
"(",
")",
".",
"get",
"(",
")",
";",
"if",
"(",
"eventsInOneAcc",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"eventsInOneAcc",
"=",
"mapServiceContext",
".",
"toObject",
"(",
"eventsInOneAcc",
")",
";",
"List",
"<",
"QueryCacheEventData",
">",
"eventDataList",
"=",
"(",
"List",
"<",
"QueryCacheEventData",
">",
")",
"eventsInOneAcc",
";",
"for",
"(",
"QueryCacheEventData",
"eventData",
":",
"eventDataList",
")",
"{",
"if",
"(",
"eventData",
".",
"getDataKey",
"(",
")",
"==",
"null",
")",
"{",
"// this means a map-wide event like clear-all or evict-all",
"// is inside the accumulator buffers",
"removePartitionResults",
"(",
"queryResult",
",",
"partitionId",
")",
";",
"}",
"else",
"{",
"add",
"(",
"queryResult",
",",
"newQueryResultRow",
"(",
"eventData",
")",
")",
";",
"}",
"}",
"}",
"}"
] | Replay events over the result set of initial query. These events are
received events during execution of the initial query. | [
"Replay",
"events",
"over",
"the",
"result",
"set",
"of",
"initial",
"query",
".",
"These",
"events",
"are",
"received",
"events",
"during",
"execution",
"of",
"the",
"initial",
"query",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/querycache/subscriber/operation/PublisherCreateOperation.java#L171-L191 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java | CPInstancePersistenceImpl.fetchByC_C | @Override
public CPInstance fetchByC_C(long CPDefinitionId, String CPInstanceUuid) {
"""
Returns the cp instance where CPDefinitionId = ? and CPInstanceUuid = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param CPDefinitionId the cp definition ID
@param CPInstanceUuid the cp instance uuid
@return the matching cp instance, or <code>null</code> if a matching cp instance could not be found
"""
return fetchByC_C(CPDefinitionId, CPInstanceUuid, true);
} | java | @Override
public CPInstance fetchByC_C(long CPDefinitionId, String CPInstanceUuid) {
return fetchByC_C(CPDefinitionId, CPInstanceUuid, true);
} | [
"@",
"Override",
"public",
"CPInstance",
"fetchByC_C",
"(",
"long",
"CPDefinitionId",
",",
"String",
"CPInstanceUuid",
")",
"{",
"return",
"fetchByC_C",
"(",
"CPDefinitionId",
",",
"CPInstanceUuid",
",",
"true",
")",
";",
"}"
] | Returns the cp instance where CPDefinitionId = ? and CPInstanceUuid = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param CPDefinitionId the cp definition ID
@param CPInstanceUuid the cp instance uuid
@return the matching cp instance, or <code>null</code> if a matching cp instance could not be found | [
"Returns",
"the",
"cp",
"instance",
"where",
"CPDefinitionId",
"=",
"?",
";",
"and",
"CPInstanceUuid",
"=",
"?",
";",
"or",
"returns",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"it",
"could",
"not",
"be",
"found",
".",
"Uses",
"the",
"finder",
"cache",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPInstancePersistenceImpl.java#L4121-L4124 |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Request.java | Request.executeConnectionAndWait | public static List<Response> executeConnectionAndWait(HttpURLConnection connection, Collection<Request> requests) {
"""
Executes requests that have already been serialized into an HttpURLConnection. No validation is done that the
contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to
ensure that it will correctly generate the desired responses.
<p/>
This should only be called if you have transitioned off the UI thread.
@param connection
the HttpURLConnection that the requests were serialized into
@param requests
the requests represented by the HttpURLConnection
@return a list of Responses corresponding to the requests
@throws FacebookException
If there was an error in the protocol used to communicate with the service
"""
return executeConnectionAndWait(connection, new RequestBatch(requests));
} | java | public static List<Response> executeConnectionAndWait(HttpURLConnection connection, Collection<Request> requests) {
return executeConnectionAndWait(connection, new RequestBatch(requests));
} | [
"public",
"static",
"List",
"<",
"Response",
">",
"executeConnectionAndWait",
"(",
"HttpURLConnection",
"connection",
",",
"Collection",
"<",
"Request",
">",
"requests",
")",
"{",
"return",
"executeConnectionAndWait",
"(",
"connection",
",",
"new",
"RequestBatch",
"(",
"requests",
")",
")",
";",
"}"
] | Executes requests that have already been serialized into an HttpURLConnection. No validation is done that the
contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to
ensure that it will correctly generate the desired responses.
<p/>
This should only be called if you have transitioned off the UI thread.
@param connection
the HttpURLConnection that the requests were serialized into
@param requests
the requests represented by the HttpURLConnection
@return a list of Responses corresponding to the requests
@throws FacebookException
If there was an error in the protocol used to communicate with the service | [
"Executes",
"requests",
"that",
"have",
"already",
"been",
"serialized",
"into",
"an",
"HttpURLConnection",
".",
"No",
"validation",
"is",
"done",
"that",
"the",
"contents",
"of",
"the",
"connection",
"actually",
"reflect",
"the",
"serialized",
"requests",
"so",
"it",
"is",
"the",
"caller",
"s",
"responsibility",
"to",
"ensure",
"that",
"it",
"will",
"correctly",
"generate",
"the",
"desired",
"responses",
".",
"<p",
"/",
">",
"This",
"should",
"only",
"be",
"called",
"if",
"you",
"have",
"transitioned",
"off",
"the",
"UI",
"thread",
"."
] | train | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Request.java#L1532-L1534 |
zxing/zxing | core/src/main/java/com/google/zxing/qrcode/encoder/Encoder.java | Encoder.recommendVersion | private static Version recommendVersion(ErrorCorrectionLevel ecLevel,
Mode mode,
BitArray headerBits,
BitArray dataBits) throws WriterException {
"""
Decides the smallest version of QR code that will contain all of the provided data.
@throws WriterException if the data cannot fit in any version
"""
// Hard part: need to know version to know how many bits length takes. But need to know how many
// bits it takes to know version. First we take a guess at version by assuming version will be
// the minimum, 1:
int provisionalBitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, Version.getVersionForNumber(1));
Version provisionalVersion = chooseVersion(provisionalBitsNeeded, ecLevel);
// Use that guess to calculate the right version. I am still not sure this works in 100% of cases.
int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion);
return chooseVersion(bitsNeeded, ecLevel);
} | java | private static Version recommendVersion(ErrorCorrectionLevel ecLevel,
Mode mode,
BitArray headerBits,
BitArray dataBits) throws WriterException {
// Hard part: need to know version to know how many bits length takes. But need to know how many
// bits it takes to know version. First we take a guess at version by assuming version will be
// the minimum, 1:
int provisionalBitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, Version.getVersionForNumber(1));
Version provisionalVersion = chooseVersion(provisionalBitsNeeded, ecLevel);
// Use that guess to calculate the right version. I am still not sure this works in 100% of cases.
int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion);
return chooseVersion(bitsNeeded, ecLevel);
} | [
"private",
"static",
"Version",
"recommendVersion",
"(",
"ErrorCorrectionLevel",
"ecLevel",
",",
"Mode",
"mode",
",",
"BitArray",
"headerBits",
",",
"BitArray",
"dataBits",
")",
"throws",
"WriterException",
"{",
"// Hard part: need to know version to know how many bits length takes. But need to know how many",
"// bits it takes to know version. First we take a guess at version by assuming version will be",
"// the minimum, 1:",
"int",
"provisionalBitsNeeded",
"=",
"calculateBitsNeeded",
"(",
"mode",
",",
"headerBits",
",",
"dataBits",
",",
"Version",
".",
"getVersionForNumber",
"(",
"1",
")",
")",
";",
"Version",
"provisionalVersion",
"=",
"chooseVersion",
"(",
"provisionalBitsNeeded",
",",
"ecLevel",
")",
";",
"// Use that guess to calculate the right version. I am still not sure this works in 100% of cases.",
"int",
"bitsNeeded",
"=",
"calculateBitsNeeded",
"(",
"mode",
",",
"headerBits",
",",
"dataBits",
",",
"provisionalVersion",
")",
";",
"return",
"chooseVersion",
"(",
"bitsNeeded",
",",
"ecLevel",
")",
";",
"}"
] | Decides the smallest version of QR code that will contain all of the provided data.
@throws WriterException if the data cannot fit in any version | [
"Decides",
"the",
"smallest",
"version",
"of",
"QR",
"code",
"that",
"will",
"contain",
"all",
"of",
"the",
"provided",
"data",
"."
] | train | https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/core/src/main/java/com/google/zxing/qrcode/encoder/Encoder.java#L173-L186 |
roboconf/roboconf-platform | core/roboconf-core/src/main/java/net/roboconf/core/utils/DockerfileParser.java | DockerfileParser.dockerfileToCommandList | public static List<DockerCommand> dockerfileToCommandList( File dockerfile ) throws IOException {
"""
Parses a dockerfile to a list of commands.
@throws IOException
@param dockerfile a file
@return a list of Docker commands
"""
List<DockerCommand> result = new ArrayList<>();
FileInputStream in = new FileInputStream( dockerfile );
Logger logger = Logger.getLogger( DockerfileParser.class.getName());
BufferedReader br = null;
try {
br = new BufferedReader( new InputStreamReader( in, StandardCharsets.UTF_8 ));
String line;
while((line = br.readLine()) != null) {
DockerCommand cmd = DockerCommand.guess(line);
if( cmd != null )
result.add( cmd );
else
logger.fine("Ignoring unsupported Docker instruction: " + line );
}
} finally {
Utils.closeQuietly( br );
Utils.closeQuietly( in );
}
return result;
} | java | public static List<DockerCommand> dockerfileToCommandList( File dockerfile ) throws IOException {
List<DockerCommand> result = new ArrayList<>();
FileInputStream in = new FileInputStream( dockerfile );
Logger logger = Logger.getLogger( DockerfileParser.class.getName());
BufferedReader br = null;
try {
br = new BufferedReader( new InputStreamReader( in, StandardCharsets.UTF_8 ));
String line;
while((line = br.readLine()) != null) {
DockerCommand cmd = DockerCommand.guess(line);
if( cmd != null )
result.add( cmd );
else
logger.fine("Ignoring unsupported Docker instruction: " + line );
}
} finally {
Utils.closeQuietly( br );
Utils.closeQuietly( in );
}
return result;
} | [
"public",
"static",
"List",
"<",
"DockerCommand",
">",
"dockerfileToCommandList",
"(",
"File",
"dockerfile",
")",
"throws",
"IOException",
"{",
"List",
"<",
"DockerCommand",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"FileInputStream",
"in",
"=",
"new",
"FileInputStream",
"(",
"dockerfile",
")",
";",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"DockerfileParser",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"BufferedReader",
"br",
"=",
"null",
";",
"try",
"{",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"in",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"DockerCommand",
"cmd",
"=",
"DockerCommand",
".",
"guess",
"(",
"line",
")",
";",
"if",
"(",
"cmd",
"!=",
"null",
")",
"result",
".",
"add",
"(",
"cmd",
")",
";",
"else",
"logger",
".",
"fine",
"(",
"\"Ignoring unsupported Docker instruction: \"",
"+",
"line",
")",
";",
"}",
"}",
"finally",
"{",
"Utils",
".",
"closeQuietly",
"(",
"br",
")",
";",
"Utils",
".",
"closeQuietly",
"(",
"in",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Parses a dockerfile to a list of commands.
@throws IOException
@param dockerfile a file
@return a list of Docker commands | [
"Parses",
"a",
"dockerfile",
"to",
"a",
"list",
"of",
"commands",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/DockerfileParser.java#L59-L84 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.getUntaggedImageCountAsync | public Observable<Integer> getUntaggedImageCountAsync(UUID projectId, GetUntaggedImageCountOptionalParameter getUntaggedImageCountOptionalParameter) {
"""
Gets the number of untagged images.
This API returns the images which have no tags for a given project and optionally an iteration. If no iteration is specified the
current workspace is used.
@param projectId The project id
@param getUntaggedImageCountOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the Integer object
"""
return getUntaggedImageCountWithServiceResponseAsync(projectId, getUntaggedImageCountOptionalParameter).map(new Func1<ServiceResponse<Integer>, Integer>() {
@Override
public Integer call(ServiceResponse<Integer> response) {
return response.body();
}
});
} | java | public Observable<Integer> getUntaggedImageCountAsync(UUID projectId, GetUntaggedImageCountOptionalParameter getUntaggedImageCountOptionalParameter) {
return getUntaggedImageCountWithServiceResponseAsync(projectId, getUntaggedImageCountOptionalParameter).map(new Func1<ServiceResponse<Integer>, Integer>() {
@Override
public Integer call(ServiceResponse<Integer> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Integer",
">",
"getUntaggedImageCountAsync",
"(",
"UUID",
"projectId",
",",
"GetUntaggedImageCountOptionalParameter",
"getUntaggedImageCountOptionalParameter",
")",
"{",
"return",
"getUntaggedImageCountWithServiceResponseAsync",
"(",
"projectId",
",",
"getUntaggedImageCountOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Integer",
">",
",",
"Integer",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Integer",
"call",
"(",
"ServiceResponse",
"<",
"Integer",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the number of untagged images.
This API returns the images which have no tags for a given project and optionally an iteration. If no iteration is specified the
current workspace is used.
@param projectId The project id
@param getUntaggedImageCountOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the Integer object | [
"Gets",
"the",
"number",
"of",
"untagged",
"images",
".",
"This",
"API",
"returns",
"the",
"images",
"which",
"have",
"no",
"tags",
"for",
"a",
"given",
"project",
"and",
"optionally",
"an",
"iteration",
".",
"If",
"no",
"iteration",
"is",
"specified",
"the",
"current",
"workspace",
"is",
"used",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L4483-L4490 |
io7m/jaffirm | com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Invariants.java | Invariants.checkInvariantD | public static double checkInvariantD(
final double value,
final boolean condition,
final DoubleFunction<String> describer) {
"""
A {@code double} specialized version of {@link #checkInvariant(Object,
boolean, Function)}
@param value The value
@param condition The predicate
@param describer The describer of the predicate
@return value
@throws InvariantViolationException If the predicate is false
"""
return innerCheckInvariantD(value, condition, describer);
} | java | public static double checkInvariantD(
final double value,
final boolean condition,
final DoubleFunction<String> describer)
{
return innerCheckInvariantD(value, condition, describer);
} | [
"public",
"static",
"double",
"checkInvariantD",
"(",
"final",
"double",
"value",
",",
"final",
"boolean",
"condition",
",",
"final",
"DoubleFunction",
"<",
"String",
">",
"describer",
")",
"{",
"return",
"innerCheckInvariantD",
"(",
"value",
",",
"condition",
",",
"describer",
")",
";",
"}"
] | A {@code double} specialized version of {@link #checkInvariant(Object,
boolean, Function)}
@param value The value
@param condition The predicate
@param describer The describer of the predicate
@return value
@throws InvariantViolationException If the predicate is false | [
"A",
"{",
"@code",
"double",
"}",
"specialized",
"version",
"of",
"{",
"@link",
"#checkInvariant",
"(",
"Object",
"boolean",
"Function",
")",
"}"
] | train | https://github.com/io7m/jaffirm/blob/c97d246242d381e48832838737418cfe4cb57b4d/com.io7m.jaffirm.core/src/main/java/com/io7m/jaffirm/core/Invariants.java#L551-L557 |
GoSimpleLLC/nbvcxz | src/main/java/me/gosimple/nbvcxz/resources/DictionaryUtil.java | DictionaryUtil.loadRankedDictionary | public static Map<String, Integer> loadRankedDictionary(final String fileName) {
"""
Read a resource file with a list of entries (sorted by frequency) and use
it to create a ranked dictionary.
<p>
The dictionary must contain only lower case values for the matching to work properly.
@param fileName the name of the file
@return the ranked dictionary (a {@code HashMap} which associated a
rank to each entry
"""
Map<String, Integer> ranked = new HashMap<>();
String path = "/dictionaries/" + fileName;
try (InputStream is = DictionaryUtil.class.getResourceAsStream(path);
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8")))
{
String line;
int i = 1;
while ((line = br.readLine()) != null)
{
ranked.put(line, i++);
}
}
catch (IOException e)
{
System.out.println("Error while reading " + fileName);
}
return ranked;
} | java | public static Map<String, Integer> loadRankedDictionary(final String fileName)
{
Map<String, Integer> ranked = new HashMap<>();
String path = "/dictionaries/" + fileName;
try (InputStream is = DictionaryUtil.class.getResourceAsStream(path);
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8")))
{
String line;
int i = 1;
while ((line = br.readLine()) != null)
{
ranked.put(line, i++);
}
}
catch (IOException e)
{
System.out.println("Error while reading " + fileName);
}
return ranked;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Integer",
">",
"loadRankedDictionary",
"(",
"final",
"String",
"fileName",
")",
"{",
"Map",
"<",
"String",
",",
"Integer",
">",
"ranked",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"String",
"path",
"=",
"\"/dictionaries/\"",
"+",
"fileName",
";",
"try",
"(",
"InputStream",
"is",
"=",
"DictionaryUtil",
".",
"class",
".",
"getResourceAsStream",
"(",
"path",
")",
";",
"BufferedReader",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"is",
",",
"\"UTF-8\"",
")",
")",
")",
"{",
"String",
"line",
";",
"int",
"i",
"=",
"1",
";",
"while",
"(",
"(",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"ranked",
".",
"put",
"(",
"line",
",",
"i",
"++",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Error while reading \"",
"+",
"fileName",
")",
";",
"}",
"return",
"ranked",
";",
"}"
] | Read a resource file with a list of entries (sorted by frequency) and use
it to create a ranked dictionary.
<p>
The dictionary must contain only lower case values for the matching to work properly.
@param fileName the name of the file
@return the ranked dictionary (a {@code HashMap} which associated a
rank to each entry | [
"Read",
"a",
"resource",
"file",
"with",
"a",
"list",
"of",
"entries",
"(",
"sorted",
"by",
"frequency",
")",
"and",
"use",
"it",
"to",
"create",
"a",
"ranked",
"dictionary",
".",
"<p",
">",
"The",
"dictionary",
"must",
"contain",
"only",
"lower",
"case",
"values",
"for",
"the",
"matching",
"to",
"work",
"properly",
"."
] | train | https://github.com/GoSimpleLLC/nbvcxz/blob/a86fb24680e646efdf78d6fda9d68a5410145f56/src/main/java/me/gosimple/nbvcxz/resources/DictionaryUtil.java#L99-L119 |
pravega/pravega | bindings/src/main/java/io/pravega/storage/filesystem/FileSystemStorage.java | FileSystemStorage.doConcat | private Void doConcat(SegmentHandle targetHandle, long offset, String sourceSegment) throws IOException {
"""
Concatenation as currently implemented here requires that we read the data and write it back to target file.
We do not make the assumption that a native operation exists as this is not a common feature supported by file
systems. As such, a concatenation induces an important network overhead as each byte concatenated must be
read and written back when the storage is backed by a remote filesystem (through NFS).
This option was preferred as other option (of having one file per transaction) will result in server side
fragmentation and corresponding slowdown in cluster performance.
"""
long traceId = LoggerHelpers.traceEnter(log, "concat", targetHandle.getSegmentName(),
offset, sourceSegment);
Path sourcePath = Paths.get(config.getRoot(), sourceSegment);
Path targetPath = Paths.get(config.getRoot(), targetHandle.getSegmentName());
long length = Files.size(sourcePath);
try (FileChannel targetChannel = FileChannel.open(targetPath, StandardOpenOption.WRITE);
RandomAccessFile sourceFile = new RandomAccessFile(String.valueOf(sourcePath), "r")) {
if (isWritableFile(sourcePath)) {
throw new IllegalStateException(String.format("Source segment (%s) is not sealed.", sourceSegment));
}
while (length > 0) {
long bytesTransferred = targetChannel.transferFrom(sourceFile.getChannel(), offset, length);
offset += bytesTransferred;
length -= bytesTransferred;
}
targetChannel.force(false);
Files.delete(sourcePath);
LoggerHelpers.traceLeave(log, "concat", traceId);
return null;
}
} | java | private Void doConcat(SegmentHandle targetHandle, long offset, String sourceSegment) throws IOException {
long traceId = LoggerHelpers.traceEnter(log, "concat", targetHandle.getSegmentName(),
offset, sourceSegment);
Path sourcePath = Paths.get(config.getRoot(), sourceSegment);
Path targetPath = Paths.get(config.getRoot(), targetHandle.getSegmentName());
long length = Files.size(sourcePath);
try (FileChannel targetChannel = FileChannel.open(targetPath, StandardOpenOption.WRITE);
RandomAccessFile sourceFile = new RandomAccessFile(String.valueOf(sourcePath), "r")) {
if (isWritableFile(sourcePath)) {
throw new IllegalStateException(String.format("Source segment (%s) is not sealed.", sourceSegment));
}
while (length > 0) {
long bytesTransferred = targetChannel.transferFrom(sourceFile.getChannel(), offset, length);
offset += bytesTransferred;
length -= bytesTransferred;
}
targetChannel.force(false);
Files.delete(sourcePath);
LoggerHelpers.traceLeave(log, "concat", traceId);
return null;
}
} | [
"private",
"Void",
"doConcat",
"(",
"SegmentHandle",
"targetHandle",
",",
"long",
"offset",
",",
"String",
"sourceSegment",
")",
"throws",
"IOException",
"{",
"long",
"traceId",
"=",
"LoggerHelpers",
".",
"traceEnter",
"(",
"log",
",",
"\"concat\"",
",",
"targetHandle",
".",
"getSegmentName",
"(",
")",
",",
"offset",
",",
"sourceSegment",
")",
";",
"Path",
"sourcePath",
"=",
"Paths",
".",
"get",
"(",
"config",
".",
"getRoot",
"(",
")",
",",
"sourceSegment",
")",
";",
"Path",
"targetPath",
"=",
"Paths",
".",
"get",
"(",
"config",
".",
"getRoot",
"(",
")",
",",
"targetHandle",
".",
"getSegmentName",
"(",
")",
")",
";",
"long",
"length",
"=",
"Files",
".",
"size",
"(",
"sourcePath",
")",
";",
"try",
"(",
"FileChannel",
"targetChannel",
"=",
"FileChannel",
".",
"open",
"(",
"targetPath",
",",
"StandardOpenOption",
".",
"WRITE",
")",
";",
"RandomAccessFile",
"sourceFile",
"=",
"new",
"RandomAccessFile",
"(",
"String",
".",
"valueOf",
"(",
"sourcePath",
")",
",",
"\"r\"",
")",
")",
"{",
"if",
"(",
"isWritableFile",
"(",
"sourcePath",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"Source segment (%s) is not sealed.\"",
",",
"sourceSegment",
")",
")",
";",
"}",
"while",
"(",
"length",
">",
"0",
")",
"{",
"long",
"bytesTransferred",
"=",
"targetChannel",
".",
"transferFrom",
"(",
"sourceFile",
".",
"getChannel",
"(",
")",
",",
"offset",
",",
"length",
")",
";",
"offset",
"+=",
"bytesTransferred",
";",
"length",
"-=",
"bytesTransferred",
";",
"}",
"targetChannel",
".",
"force",
"(",
"false",
")",
";",
"Files",
".",
"delete",
"(",
"sourcePath",
")",
";",
"LoggerHelpers",
".",
"traceLeave",
"(",
"log",
",",
"\"concat\"",
",",
"traceId",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Concatenation as currently implemented here requires that we read the data and write it back to target file.
We do not make the assumption that a native operation exists as this is not a common feature supported by file
systems. As such, a concatenation induces an important network overhead as each byte concatenated must be
read and written back when the storage is backed by a remote filesystem (through NFS).
This option was preferred as other option (of having one file per transaction) will result in server side
fragmentation and corresponding slowdown in cluster performance. | [
"Concatenation",
"as",
"currently",
"implemented",
"here",
"requires",
"that",
"we",
"read",
"the",
"data",
"and",
"write",
"it",
"back",
"to",
"target",
"file",
".",
"We",
"do",
"not",
"make",
"the",
"assumption",
"that",
"a",
"native",
"operation",
"exists",
"as",
"this",
"is",
"not",
"a",
"common",
"feature",
"supported",
"by",
"file",
"systems",
".",
"As",
"such",
"a",
"concatenation",
"induces",
"an",
"important",
"network",
"overhead",
"as",
"each",
"byte",
"concatenated",
"must",
"be",
"read",
"and",
"written",
"back",
"when",
"the",
"storage",
"is",
"backed",
"by",
"a",
"remote",
"filesystem",
"(",
"through",
"NFS",
")",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/bindings/src/main/java/io/pravega/storage/filesystem/FileSystemStorage.java#L363-L386 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemMessage.java | ElemMessage.execute | public void execute(
TransformerImpl transformer)
throws TransformerException {
"""
Send a message to diagnostics.
The xsl:message instruction sends a message in a way that
is dependent on the XSLT transformer. The content of the xsl:message
instruction is a template. The xsl:message is instantiated by
instantiating the content to create an XML fragment. This XML
fragment is the content of the message.
@param transformer non-null reference to the the current transform-time state.
@throws TransformerException
"""
String data = transformer.transformToString(this);
transformer.getMsgMgr().message(this, data, m_terminate);
if(m_terminate)
transformer.getErrorListener().fatalError(new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_STYLESHEET_DIRECTED_TERMINATION, null))); //"Stylesheet directed termination"));
} | java | public void execute(
TransformerImpl transformer)
throws TransformerException
{
String data = transformer.transformToString(this);
transformer.getMsgMgr().message(this, data, m_terminate);
if(m_terminate)
transformer.getErrorListener().fatalError(new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_STYLESHEET_DIRECTED_TERMINATION, null))); //"Stylesheet directed termination"));
} | [
"public",
"void",
"execute",
"(",
"TransformerImpl",
"transformer",
")",
"throws",
"TransformerException",
"{",
"String",
"data",
"=",
"transformer",
".",
"transformToString",
"(",
"this",
")",
";",
"transformer",
".",
"getMsgMgr",
"(",
")",
".",
"message",
"(",
"this",
",",
"data",
",",
"m_terminate",
")",
";",
"if",
"(",
"m_terminate",
")",
"transformer",
".",
"getErrorListener",
"(",
")",
".",
"fatalError",
"(",
"new",
"TransformerException",
"(",
"XSLMessages",
".",
"createMessage",
"(",
"XSLTErrorResources",
".",
"ER_STYLESHEET_DIRECTED_TERMINATION",
",",
"null",
")",
")",
")",
";",
"//\"Stylesheet directed termination\"));",
"}"
] | Send a message to diagnostics.
The xsl:message instruction sends a message in a way that
is dependent on the XSLT transformer. The content of the xsl:message
instruction is a template. The xsl:message is instantiated by
instantiating the content to create an XML fragment. This XML
fragment is the content of the message.
@param transformer non-null reference to the the current transform-time state.
@throws TransformerException | [
"Send",
"a",
"message",
"to",
"diagnostics",
".",
"The",
"xsl",
":",
"message",
"instruction",
"sends",
"a",
"message",
"in",
"a",
"way",
"that",
"is",
"dependent",
"on",
"the",
"XSLT",
"transformer",
".",
"The",
"content",
"of",
"the",
"xsl",
":",
"message",
"instruction",
"is",
"a",
"template",
".",
"The",
"xsl",
":",
"message",
"is",
"instantiated",
"by",
"instantiating",
"the",
"content",
"to",
"create",
"an",
"XML",
"fragment",
".",
"This",
"XML",
"fragment",
"is",
"the",
"content",
"of",
"the",
"message",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemMessage.java#L112-L123 |
geomajas/geomajas-project-geometry | core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java | GeometryIndexService.getVertex | public Coordinate getVertex(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException {
"""
Given a certain geometry, get the vertex the index points to. This only works if the index actually points to a
vertex.
@param geometry
The geometry to search in.
@param index
The index that points to a vertex within the given geometry.
@return Returns the vertex if it exists.
@throws GeometryIndexNotFoundException
Thrown in case the index is of the wrong type, or if the vertex could not be found within the given
geometry.
"""
if (index.hasChild()) {
if (geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) {
return getVertex(geometry.getGeometries()[index.getValue()], index.getChild());
}
throw new GeometryIndexNotFoundException("Could not match index with given geometry");
}
if (index.getType() == GeometryIndexType.TYPE_VERTEX && geometry.getCoordinates() != null
&& geometry.getCoordinates().length > index.getValue() && index.getValue() >= 0) {
return geometry.getCoordinates()[index.getValue()];
}
throw new GeometryIndexNotFoundException("Could not match index with given geometry");
} | java | public Coordinate getVertex(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException {
if (index.hasChild()) {
if (geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) {
return getVertex(geometry.getGeometries()[index.getValue()], index.getChild());
}
throw new GeometryIndexNotFoundException("Could not match index with given geometry");
}
if (index.getType() == GeometryIndexType.TYPE_VERTEX && geometry.getCoordinates() != null
&& geometry.getCoordinates().length > index.getValue() && index.getValue() >= 0) {
return geometry.getCoordinates()[index.getValue()];
}
throw new GeometryIndexNotFoundException("Could not match index with given geometry");
} | [
"public",
"Coordinate",
"getVertex",
"(",
"Geometry",
"geometry",
",",
"GeometryIndex",
"index",
")",
"throws",
"GeometryIndexNotFoundException",
"{",
"if",
"(",
"index",
".",
"hasChild",
"(",
")",
")",
"{",
"if",
"(",
"geometry",
".",
"getGeometries",
"(",
")",
"!=",
"null",
"&&",
"geometry",
".",
"getGeometries",
"(",
")",
".",
"length",
">",
"index",
".",
"getValue",
"(",
")",
")",
"{",
"return",
"getVertex",
"(",
"geometry",
".",
"getGeometries",
"(",
")",
"[",
"index",
".",
"getValue",
"(",
")",
"]",
",",
"index",
".",
"getChild",
"(",
")",
")",
";",
"}",
"throw",
"new",
"GeometryIndexNotFoundException",
"(",
"\"Could not match index with given geometry\"",
")",
";",
"}",
"if",
"(",
"index",
".",
"getType",
"(",
")",
"==",
"GeometryIndexType",
".",
"TYPE_VERTEX",
"&&",
"geometry",
".",
"getCoordinates",
"(",
")",
"!=",
"null",
"&&",
"geometry",
".",
"getCoordinates",
"(",
")",
".",
"length",
">",
"index",
".",
"getValue",
"(",
")",
"&&",
"index",
".",
"getValue",
"(",
")",
">=",
"0",
")",
"{",
"return",
"geometry",
".",
"getCoordinates",
"(",
")",
"[",
"index",
".",
"getValue",
"(",
")",
"]",
";",
"}",
"throw",
"new",
"GeometryIndexNotFoundException",
"(",
"\"Could not match index with given geometry\"",
")",
";",
"}"
] | Given a certain geometry, get the vertex the index points to. This only works if the index actually points to a
vertex.
@param geometry
The geometry to search in.
@param index
The index that points to a vertex within the given geometry.
@return Returns the vertex if it exists.
@throws GeometryIndexNotFoundException
Thrown in case the index is of the wrong type, or if the vertex could not be found within the given
geometry. | [
"Given",
"a",
"certain",
"geometry",
"get",
"the",
"vertex",
"the",
"index",
"points",
"to",
".",
"This",
"only",
"works",
"if",
"the",
"index",
"actually",
"points",
"to",
"a",
"vertex",
"."
] | train | https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L190-L202 |
virgo47/javasimon | jdbc41/src/main/java/org/javasimon/jdbc4/SimonConnection.java | SimonConnection.createStatement | @Override
public Statement createStatement(int rsType, int rsConcurrency) throws SQLException {
"""
Calls real createStatement and wraps returned statement by Simon's statement.
@param rsType result set type
@param rsConcurrency result set concurrency
@return Simon's statement with wrapped real statement
@throws java.sql.SQLException if real operation fails
"""
return new SimonStatement(this, conn.createStatement(rsType, rsConcurrency), prefix);
} | java | @Override
public Statement createStatement(int rsType, int rsConcurrency) throws SQLException {
return new SimonStatement(this, conn.createStatement(rsType, rsConcurrency), prefix);
} | [
"@",
"Override",
"public",
"Statement",
"createStatement",
"(",
"int",
"rsType",
",",
"int",
"rsConcurrency",
")",
"throws",
"SQLException",
"{",
"return",
"new",
"SimonStatement",
"(",
"this",
",",
"conn",
".",
"createStatement",
"(",
"rsType",
",",
"rsConcurrency",
")",
",",
"prefix",
")",
";",
"}"
] | Calls real createStatement and wraps returned statement by Simon's statement.
@param rsType result set type
@param rsConcurrency result set concurrency
@return Simon's statement with wrapped real statement
@throws java.sql.SQLException if real operation fails | [
"Calls",
"real",
"createStatement",
"and",
"wraps",
"returned",
"statement",
"by",
"Simon",
"s",
"statement",
"."
] | train | https://github.com/virgo47/javasimon/blob/17dfaa93cded9ce8ef64a134b28ccbf4d0284d2f/jdbc41/src/main/java/org/javasimon/jdbc4/SimonConnection.java#L144-L147 |
beangle/beangle3 | struts/s2/src/main/java/org/beangle/struts2/action/EntityActionSupport.java | EntityActionSupport.getId | protected final <T> T getId(String name, Class<T> clazz) {
"""
Get entity's id from shortname.id,shortnameId,id
@param name
@param clazz
"""
Object[] entityIds = getAll(name + ".id");
if (Arrays.isEmpty(entityIds)) entityIds = getAll(name + "Id");
if (Arrays.isEmpty(entityIds)) entityIds = getAll("id");
if (Arrays.isEmpty(entityIds)) return null;
else {
String entityId = entityIds[0].toString();
int commaIndex = entityId.indexOf(',');
if (commaIndex != -1) entityId = entityId.substring(0, commaIndex);
return Params.converter.convert(entityId, clazz);
}
} | java | protected final <T> T getId(String name, Class<T> clazz) {
Object[] entityIds = getAll(name + ".id");
if (Arrays.isEmpty(entityIds)) entityIds = getAll(name + "Id");
if (Arrays.isEmpty(entityIds)) entityIds = getAll("id");
if (Arrays.isEmpty(entityIds)) return null;
else {
String entityId = entityIds[0].toString();
int commaIndex = entityId.indexOf(',');
if (commaIndex != -1) entityId = entityId.substring(0, commaIndex);
return Params.converter.convert(entityId, clazz);
}
} | [
"protected",
"final",
"<",
"T",
">",
"T",
"getId",
"(",
"String",
"name",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"Object",
"[",
"]",
"entityIds",
"=",
"getAll",
"(",
"name",
"+",
"\".id\"",
")",
";",
"if",
"(",
"Arrays",
".",
"isEmpty",
"(",
"entityIds",
")",
")",
"entityIds",
"=",
"getAll",
"(",
"name",
"+",
"\"Id\"",
")",
";",
"if",
"(",
"Arrays",
".",
"isEmpty",
"(",
"entityIds",
")",
")",
"entityIds",
"=",
"getAll",
"(",
"\"id\"",
")",
";",
"if",
"(",
"Arrays",
".",
"isEmpty",
"(",
"entityIds",
")",
")",
"return",
"null",
";",
"else",
"{",
"String",
"entityId",
"=",
"entityIds",
"[",
"0",
"]",
".",
"toString",
"(",
")",
";",
"int",
"commaIndex",
"=",
"entityId",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"commaIndex",
"!=",
"-",
"1",
")",
"entityId",
"=",
"entityId",
".",
"substring",
"(",
"0",
",",
"commaIndex",
")",
";",
"return",
"Params",
".",
"converter",
".",
"convert",
"(",
"entityId",
",",
"clazz",
")",
";",
"}",
"}"
] | Get entity's id from shortname.id,shortnameId,id
@param name
@param clazz | [
"Get",
"entity",
"s",
"id",
"from",
"shortname",
".",
"id",
"shortnameId",
"id"
] | train | https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/action/EntityActionSupport.java#L47-L58 |
google/closure-compiler | src/com/google/javascript/rhino/jstype/JSTypeRegistry.java | JSTypeRegistry.registerTemplateTypeNamesInScope | public void registerTemplateTypeNamesInScope(Iterable<TemplateType> keys, Node scopeRoot) {
"""
Registers template types on the given scope root. This takes a Node rather than a
StaticScope because at the time it is called, the scope has not yet been created.
"""
for (TemplateType key : keys) {
scopedNameTable.put(scopeRoot, key.getReferenceName(), key);
}
} | java | public void registerTemplateTypeNamesInScope(Iterable<TemplateType> keys, Node scopeRoot) {
for (TemplateType key : keys) {
scopedNameTable.put(scopeRoot, key.getReferenceName(), key);
}
} | [
"public",
"void",
"registerTemplateTypeNamesInScope",
"(",
"Iterable",
"<",
"TemplateType",
">",
"keys",
",",
"Node",
"scopeRoot",
")",
"{",
"for",
"(",
"TemplateType",
"key",
":",
"keys",
")",
"{",
"scopedNameTable",
".",
"put",
"(",
"scopeRoot",
",",
"key",
".",
"getReferenceName",
"(",
")",
",",
"key",
")",
";",
"}",
"}"
] | Registers template types on the given scope root. This takes a Node rather than a
StaticScope because at the time it is called, the scope has not yet been created. | [
"Registers",
"template",
"types",
"on",
"the",
"given",
"scope",
"root",
".",
"This",
"takes",
"a",
"Node",
"rather",
"than",
"a",
"StaticScope",
"because",
"at",
"the",
"time",
"it",
"is",
"called",
"the",
"scope",
"has",
"not",
"yet",
"been",
"created",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/jstype/JSTypeRegistry.java#L2257-L2261 |
apache/flink | flink-libraries/flink-streaming-python/src/main/java/org/apache/flink/streaming/python/api/environment/PythonStreamExecutionEnvironment.java | PythonStreamExecutionEnvironment.generate_sequence | public PythonDataStream generate_sequence(long from, long to) {
"""
A thin wrapper layer over {@link StreamExecutionEnvironment#generateSequence(long, long)}.
@param from The number to start at (inclusive)
@param to The number to stop at (inclusive)
@return A python data stream, containing all number in the [from, to] interval
"""
return new PythonDataStream<>(env.generateSequence(from, to).map(new AdapterMap<>()));
} | java | public PythonDataStream generate_sequence(long from, long to) {
return new PythonDataStream<>(env.generateSequence(from, to).map(new AdapterMap<>()));
} | [
"public",
"PythonDataStream",
"generate_sequence",
"(",
"long",
"from",
",",
"long",
"to",
")",
"{",
"return",
"new",
"PythonDataStream",
"<>",
"(",
"env",
".",
"generateSequence",
"(",
"from",
",",
"to",
")",
".",
"map",
"(",
"new",
"AdapterMap",
"<>",
"(",
")",
")",
")",
";",
"}"
] | A thin wrapper layer over {@link StreamExecutionEnvironment#generateSequence(long, long)}.
@param from The number to start at (inclusive)
@param to The number to stop at (inclusive)
@return A python data stream, containing all number in the [from, to] interval | [
"A",
"thin",
"wrapper",
"layer",
"over",
"{",
"@link",
"StreamExecutionEnvironment#generateSequence",
"(",
"long",
"long",
")",
"}",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-libraries/flink-streaming-python/src/main/java/org/apache/flink/streaming/python/api/environment/PythonStreamExecutionEnvironment.java#L176-L178 |
google/closure-templates | java/src/com/google/template/soy/jssrc/internal/GenJsCodeVisitor.java | GenJsCodeVisitor.handleForeachLoop | private Statement handleForeachLoop(
ForNonemptyNode node,
Expression limit,
Function<Expression, Expression> getDataItemFunction) {
"""
Example:
<pre>
{for $foo in $boo.foos}
...
{/for}
</pre>
might generate
<pre>
for (var foo2Index = 0; foo2Index < foo2ListLen; foo2Index++) {
var foo2Data = foo2List[foo2Index];
...
}
</pre>
"""
// Build some local variable names.
String varName = node.getVarName();
String varPrefix = varName + node.getForNodeId();
// TODO(b/32224284): A more consistent pattern for local variable management.
String loopIndexName = varPrefix + "Index";
String dataName = varPrefix + "Data";
Expression loopIndex = id(loopIndexName);
VariableDeclaration data =
VariableDeclaration.builder(dataName).setRhs(getDataItemFunction.apply(loopIndex)).build();
// Populate the local var translations with the translations from this node.
templateTranslationContext
.soyToJsVariableMappings()
.put(varName, id(dataName))
.put(varName + "__isFirst", loopIndex.doubleEquals(number(0)))
.put(varName + "__isLast", loopIndex.doubleEquals(limit.minus(number(1))))
.put(varName + "__index", loopIndex);
// Generate the loop body.
Statement foreachBody = Statement.of(data, visitChildrenReturningCodeChunk(node));
// Create the entire for block.
return forLoop(loopIndexName, limit, foreachBody);
} | java | private Statement handleForeachLoop(
ForNonemptyNode node,
Expression limit,
Function<Expression, Expression> getDataItemFunction) {
// Build some local variable names.
String varName = node.getVarName();
String varPrefix = varName + node.getForNodeId();
// TODO(b/32224284): A more consistent pattern for local variable management.
String loopIndexName = varPrefix + "Index";
String dataName = varPrefix + "Data";
Expression loopIndex = id(loopIndexName);
VariableDeclaration data =
VariableDeclaration.builder(dataName).setRhs(getDataItemFunction.apply(loopIndex)).build();
// Populate the local var translations with the translations from this node.
templateTranslationContext
.soyToJsVariableMappings()
.put(varName, id(dataName))
.put(varName + "__isFirst", loopIndex.doubleEquals(number(0)))
.put(varName + "__isLast", loopIndex.doubleEquals(limit.minus(number(1))))
.put(varName + "__index", loopIndex);
// Generate the loop body.
Statement foreachBody = Statement.of(data, visitChildrenReturningCodeChunk(node));
// Create the entire for block.
return forLoop(loopIndexName, limit, foreachBody);
} | [
"private",
"Statement",
"handleForeachLoop",
"(",
"ForNonemptyNode",
"node",
",",
"Expression",
"limit",
",",
"Function",
"<",
"Expression",
",",
"Expression",
">",
"getDataItemFunction",
")",
"{",
"// Build some local variable names.",
"String",
"varName",
"=",
"node",
".",
"getVarName",
"(",
")",
";",
"String",
"varPrefix",
"=",
"varName",
"+",
"node",
".",
"getForNodeId",
"(",
")",
";",
"// TODO(b/32224284): A more consistent pattern for local variable management.",
"String",
"loopIndexName",
"=",
"varPrefix",
"+",
"\"Index\"",
";",
"String",
"dataName",
"=",
"varPrefix",
"+",
"\"Data\"",
";",
"Expression",
"loopIndex",
"=",
"id",
"(",
"loopIndexName",
")",
";",
"VariableDeclaration",
"data",
"=",
"VariableDeclaration",
".",
"builder",
"(",
"dataName",
")",
".",
"setRhs",
"(",
"getDataItemFunction",
".",
"apply",
"(",
"loopIndex",
")",
")",
".",
"build",
"(",
")",
";",
"// Populate the local var translations with the translations from this node.",
"templateTranslationContext",
".",
"soyToJsVariableMappings",
"(",
")",
".",
"put",
"(",
"varName",
",",
"id",
"(",
"dataName",
")",
")",
".",
"put",
"(",
"varName",
"+",
"\"__isFirst\"",
",",
"loopIndex",
".",
"doubleEquals",
"(",
"number",
"(",
"0",
")",
")",
")",
".",
"put",
"(",
"varName",
"+",
"\"__isLast\"",
",",
"loopIndex",
".",
"doubleEquals",
"(",
"limit",
".",
"minus",
"(",
"number",
"(",
"1",
")",
")",
")",
")",
".",
"put",
"(",
"varName",
"+",
"\"__index\"",
",",
"loopIndex",
")",
";",
"// Generate the loop body.",
"Statement",
"foreachBody",
"=",
"Statement",
".",
"of",
"(",
"data",
",",
"visitChildrenReturningCodeChunk",
"(",
"node",
")",
")",
";",
"// Create the entire for block.",
"return",
"forLoop",
"(",
"loopIndexName",
",",
"limit",
",",
"foreachBody",
")",
";",
"}"
] | Example:
<pre>
{for $foo in $boo.foos}
...
{/for}
</pre>
might generate
<pre>
for (var foo2Index = 0; foo2Index < foo2ListLen; foo2Index++) {
var foo2Data = foo2List[foo2Index];
...
}
</pre> | [
"Example",
":"
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/internal/GenJsCodeVisitor.java#L1249-L1278 |
MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java | ImageHandlerBuilder.reduceQuality | public ImageHandlerBuilder reduceQuality(float qualityPercent) {
"""
Uses compression quality of <code>qualityPercent</code>.
Can be applied multiple times
@param qualityPercent the percentage of compression quality wanted. Must be between 0.0 and 1.0
@return this for chaining
"""
ImageWriter imageWriter = ImageIO.getImageWritersByFormatName(fn.extension()).next();
if (imageWriter != null) {
ImageWriteParam writeParam = imageWriter.getDefaultWriteParam();
writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParam.setCompressionQuality(qualityPercent);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageWriter.setOutput(new MemoryCacheImageOutputStream(baos));
try {
imageWriter.write(null, new IIOImage(image, null, null), writeParam);
imageWriter.dispose();
} catch (IOException e) {
throw new ControllerException(e);
}
try {
BufferedImage lowImage = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
image.flush();
image = lowImage;
} catch (IOException e) {
throw new ControllerException(e);
}
}
return this;
} | java | public ImageHandlerBuilder reduceQuality(float qualityPercent) {
ImageWriter imageWriter = ImageIO.getImageWritersByFormatName(fn.extension()).next();
if (imageWriter != null) {
ImageWriteParam writeParam = imageWriter.getDefaultWriteParam();
writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParam.setCompressionQuality(qualityPercent);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageWriter.setOutput(new MemoryCacheImageOutputStream(baos));
try {
imageWriter.write(null, new IIOImage(image, null, null), writeParam);
imageWriter.dispose();
} catch (IOException e) {
throw new ControllerException(e);
}
try {
BufferedImage lowImage = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
image.flush();
image = lowImage;
} catch (IOException e) {
throw new ControllerException(e);
}
}
return this;
} | [
"public",
"ImageHandlerBuilder",
"reduceQuality",
"(",
"float",
"qualityPercent",
")",
"{",
"ImageWriter",
"imageWriter",
"=",
"ImageIO",
".",
"getImageWritersByFormatName",
"(",
"fn",
".",
"extension",
"(",
")",
")",
".",
"next",
"(",
")",
";",
"if",
"(",
"imageWriter",
"!=",
"null",
")",
"{",
"ImageWriteParam",
"writeParam",
"=",
"imageWriter",
".",
"getDefaultWriteParam",
"(",
")",
";",
"writeParam",
".",
"setCompressionMode",
"(",
"ImageWriteParam",
".",
"MODE_EXPLICIT",
")",
";",
"writeParam",
".",
"setCompressionQuality",
"(",
"qualityPercent",
")",
";",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"imageWriter",
".",
"setOutput",
"(",
"new",
"MemoryCacheImageOutputStream",
"(",
"baos",
")",
")",
";",
"try",
"{",
"imageWriter",
".",
"write",
"(",
"null",
",",
"new",
"IIOImage",
"(",
"image",
",",
"null",
",",
"null",
")",
",",
"writeParam",
")",
";",
"imageWriter",
".",
"dispose",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ControllerException",
"(",
"e",
")",
";",
"}",
"try",
"{",
"BufferedImage",
"lowImage",
"=",
"ImageIO",
".",
"read",
"(",
"new",
"ByteArrayInputStream",
"(",
"baos",
".",
"toByteArray",
"(",
")",
")",
")",
";",
"image",
".",
"flush",
"(",
")",
";",
"image",
"=",
"lowImage",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ControllerException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Uses compression quality of <code>qualityPercent</code>.
Can be applied multiple times
@param qualityPercent the percentage of compression quality wanted. Must be between 0.0 and 1.0
@return this for chaining | [
"Uses",
"compression",
"quality",
"of",
"<code",
">",
"qualityPercent<",
"/",
"code",
">",
".",
"Can",
"be",
"applied",
"multiple",
"times"
] | train | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L220-L245 |
kite-sdk/kite | kite-data/kite-data-hbase/src/main/java/org/kitesdk/data/hbase/avro/io/MemcmpDecoder.java | MemcmpDecoder.readFixed | @Override
public void readFixed(byte[] bytes, int start, int length) throws IOException {
"""
A fixed is decoded by just reading length bytes, and placing the bytes read
into the bytes array, starting at index start.
@param bytes
The bytes array to populate.
@param start
The index in bytes to place the read bytes.
@param length
The number of bytes to read.
"""
int i = in.read(bytes, start, length);
if (i < length) {
throw new EOFException();
}
} | java | @Override
public void readFixed(byte[] bytes, int start, int length) throws IOException {
int i = in.read(bytes, start, length);
if (i < length) {
throw new EOFException();
}
} | [
"@",
"Override",
"public",
"void",
"readFixed",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"start",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"int",
"i",
"=",
"in",
".",
"read",
"(",
"bytes",
",",
"start",
",",
"length",
")",
";",
"if",
"(",
"i",
"<",
"length",
")",
"{",
"throw",
"new",
"EOFException",
"(",
")",
";",
"}",
"}"
] | A fixed is decoded by just reading length bytes, and placing the bytes read
into the bytes array, starting at index start.
@param bytes
The bytes array to populate.
@param start
The index in bytes to place the read bytes.
@param length
The number of bytes to read. | [
"A",
"fixed",
"is",
"decoded",
"by",
"just",
"reading",
"length",
"bytes",
"and",
"placing",
"the",
"bytes",
"read",
"into",
"the",
"bytes",
"array",
"starting",
"at",
"index",
"start",
"."
] | train | https://github.com/kite-sdk/kite/blob/72bfb4b1a881af85808cd7f14bc3e15160a1e811/kite-data/kite-data-hbase/src/main/java/org/kitesdk/data/hbase/avro/io/MemcmpDecoder.java#L227-L233 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/ParallelRunner.java | ParallelRunner.submitCallable | public void submitCallable(Callable<Void> callable, String name) {
"""
Submit a callable to the thread pool
<p>
This method submits a task and returns immediately
</p>
@param callable the callable to submit
@param name for the future
"""
this.futures.add(new NamedFuture(this.executor.submit(callable), name));
} | java | public void submitCallable(Callable<Void> callable, String name) {
this.futures.add(new NamedFuture(this.executor.submit(callable), name));
} | [
"public",
"void",
"submitCallable",
"(",
"Callable",
"<",
"Void",
">",
"callable",
",",
"String",
"name",
")",
"{",
"this",
".",
"futures",
".",
"add",
"(",
"new",
"NamedFuture",
"(",
"this",
".",
"executor",
".",
"submit",
"(",
"callable",
")",
",",
"name",
")",
")",
";",
"}"
] | Submit a callable to the thread pool
<p>
This method submits a task and returns immediately
</p>
@param callable the callable to submit
@param name for the future | [
"Submit",
"a",
"callable",
"to",
"the",
"thread",
"pool"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ParallelRunner.java#L349-L351 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/hadoop/cql3/CqlConfigHelper.java | CqlConfigHelper.setInputColumns | public static void setInputColumns(Configuration conf, String columns) {
"""
Set the CQL columns for the input of this job.
@param conf Job configuration you are about to run
@param columns
"""
if (columns == null || columns.isEmpty())
return;
conf.set(INPUT_CQL_COLUMNS_CONFIG, columns);
} | java | public static void setInputColumns(Configuration conf, String columns)
{
if (columns == null || columns.isEmpty())
return;
conf.set(INPUT_CQL_COLUMNS_CONFIG, columns);
} | [
"public",
"static",
"void",
"setInputColumns",
"(",
"Configuration",
"conf",
",",
"String",
"columns",
")",
"{",
"if",
"(",
"columns",
"==",
"null",
"||",
"columns",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"conf",
".",
"set",
"(",
"INPUT_CQL_COLUMNS_CONFIG",
",",
"columns",
")",
";",
"}"
] | Set the CQL columns for the input of this job.
@param conf Job configuration you are about to run
@param columns | [
"Set",
"the",
"CQL",
"columns",
"for",
"the",
"input",
"of",
"this",
"job",
"."
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/hadoop/cql3/CqlConfigHelper.java#L94-L100 |
VoltDB/voltdb | third_party/java/src/org/apache/commons_voltpatches/cli/PosixParser.java | PosixParser.processOptionToken | private void processOptionToken(String token, boolean stopAtNonOption) {
"""
<p>If an {@link Option} exists for <code>token</code> then
add the token to the processed list.</p>
<p>If an {@link Option} does not exist and <code>stopAtNonOption</code>
is set then add the remaining tokens to the processed tokens list
directly.</p>
@param token The current option token
@param stopAtNonOption Specifies whether flattening should halt
at the first non option.
"""
if (stopAtNonOption && !options.hasOption(token))
{
eatTheRest = true;
}
if (options.hasOption(token))
{
currentOption = options.getOption(token);
}
tokens.add(token);
} | java | private void processOptionToken(String token, boolean stopAtNonOption)
{
if (stopAtNonOption && !options.hasOption(token))
{
eatTheRest = true;
}
if (options.hasOption(token))
{
currentOption = options.getOption(token);
}
tokens.add(token);
} | [
"private",
"void",
"processOptionToken",
"(",
"String",
"token",
",",
"boolean",
"stopAtNonOption",
")",
"{",
"if",
"(",
"stopAtNonOption",
"&&",
"!",
"options",
".",
"hasOption",
"(",
"token",
")",
")",
"{",
"eatTheRest",
"=",
"true",
";",
"}",
"if",
"(",
"options",
".",
"hasOption",
"(",
"token",
")",
")",
"{",
"currentOption",
"=",
"options",
".",
"getOption",
"(",
"token",
")",
";",
"}",
"tokens",
".",
"add",
"(",
"token",
")",
";",
"}"
] | <p>If an {@link Option} exists for <code>token</code> then
add the token to the processed list.</p>
<p>If an {@link Option} does not exist and <code>stopAtNonOption</code>
is set then add the remaining tokens to the processed tokens list
directly.</p>
@param token The current option token
@param stopAtNonOption Specifies whether flattening should halt
at the first non option. | [
"<p",
">",
"If",
"an",
"{",
"@link",
"Option",
"}",
"exists",
"for",
"<code",
">",
"token<",
"/",
"code",
">",
"then",
"add",
"the",
"token",
"to",
"the",
"processed",
"list",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/PosixParser.java#L223-L236 |
xcesco/kripton | kripton-shared-preferences/src/main/java/com/abubusoft/kripton/common/PrefsTypeAdapterUtils.java | PrefsTypeAdapterUtils.toData | @SuppressWarnings("unchecked")
public static <D, J> D toData(Class<? extends PreferenceTypeAdapter<J, D>> clazz, J javaValue) {
"""
To data.
@param <D> the generic type
@param <J> the generic type
@param clazz the clazz
@param javaValue the java value
@return the d
"""
PreferenceTypeAdapter<J, D> adapter = cache.get(clazz);
if (adapter == null) {
try {
lock.lock();
adapter = clazz.newInstance();
cache.put(clazz, adapter);
} catch (Throwable e) {
throw (new KriptonRuntimeException(e));
} finally {
lock.unlock();
}
}
return adapter.toData(javaValue);
} | java | @SuppressWarnings("unchecked")
public static <D, J> D toData(Class<? extends PreferenceTypeAdapter<J, D>> clazz, J javaValue) {
PreferenceTypeAdapter<J, D> adapter = cache.get(clazz);
if (adapter == null) {
try {
lock.lock();
adapter = clazz.newInstance();
cache.put(clazz, adapter);
} catch (Throwable e) {
throw (new KriptonRuntimeException(e));
} finally {
lock.unlock();
}
}
return adapter.toData(javaValue);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"D",
",",
"J",
">",
"D",
"toData",
"(",
"Class",
"<",
"?",
"extends",
"PreferenceTypeAdapter",
"<",
"J",
",",
"D",
">",
">",
"clazz",
",",
"J",
"javaValue",
")",
"{",
"PreferenceTypeAdapter",
"<",
"J",
",",
"D",
">",
"adapter",
"=",
"cache",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"adapter",
"==",
"null",
")",
"{",
"try",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"adapter",
"=",
"clazz",
".",
"newInstance",
"(",
")",
";",
"cache",
".",
"put",
"(",
"clazz",
",",
"adapter",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"throw",
"(",
"new",
"KriptonRuntimeException",
"(",
"e",
")",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}",
"return",
"adapter",
".",
"toData",
"(",
"javaValue",
")",
";",
"}"
] | To data.
@param <D> the generic type
@param <J> the generic type
@param clazz the clazz
@param javaValue the java value
@return the d | [
"To",
"data",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-shared-preferences/src/main/java/com/abubusoft/kripton/common/PrefsTypeAdapterUtils.java#L105-L122 |
forge/furnace | proxy/src/main/java/org/jboss/forge/furnace/proxy/Proxies.java | Proxies.areEquivalent | public static boolean areEquivalent(Object proxiedObj, Object anotherProxiedObj) {
"""
This method tests if two proxied objects are equivalent.
It does so by comparing the class names and the hashCode, since they may be loaded from different classloaders.
"""
if (proxiedObj == null && anotherProxiedObj == null)
{
return true;
}
else if (proxiedObj == null || anotherProxiedObj == null)
{
return false;
}
else
{
Object unproxiedObj = unwrap(proxiedObj);
Object anotherUnproxiedObj = unwrap(anotherProxiedObj);
boolean sameClassName = unwrapProxyClassName(unproxiedObj.getClass()).equals(
unwrapProxyClassName(anotherUnproxiedObj.getClass()));
if (sameClassName)
{
if (unproxiedObj.getClass().isEnum())
{
// Enum hashCode is different if loaded from different classloaders and cannot be overriden.
Enum<?> enumLeft = Enum.class.cast(unproxiedObj);
Enum<?> enumRight = Enum.class.cast(anotherUnproxiedObj);
return (enumLeft.name().equals(enumRight.name())) && (enumLeft.ordinal() == enumRight.ordinal());
}
else
{
return (unproxiedObj.hashCode() == anotherUnproxiedObj.hashCode());
}
}
else
{
return false;
}
}
} | java | public static boolean areEquivalent(Object proxiedObj, Object anotherProxiedObj)
{
if (proxiedObj == null && anotherProxiedObj == null)
{
return true;
}
else if (proxiedObj == null || anotherProxiedObj == null)
{
return false;
}
else
{
Object unproxiedObj = unwrap(proxiedObj);
Object anotherUnproxiedObj = unwrap(anotherProxiedObj);
boolean sameClassName = unwrapProxyClassName(unproxiedObj.getClass()).equals(
unwrapProxyClassName(anotherUnproxiedObj.getClass()));
if (sameClassName)
{
if (unproxiedObj.getClass().isEnum())
{
// Enum hashCode is different if loaded from different classloaders and cannot be overriden.
Enum<?> enumLeft = Enum.class.cast(unproxiedObj);
Enum<?> enumRight = Enum.class.cast(anotherUnproxiedObj);
return (enumLeft.name().equals(enumRight.name())) && (enumLeft.ordinal() == enumRight.ordinal());
}
else
{
return (unproxiedObj.hashCode() == anotherUnproxiedObj.hashCode());
}
}
else
{
return false;
}
}
} | [
"public",
"static",
"boolean",
"areEquivalent",
"(",
"Object",
"proxiedObj",
",",
"Object",
"anotherProxiedObj",
")",
"{",
"if",
"(",
"proxiedObj",
"==",
"null",
"&&",
"anotherProxiedObj",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"proxiedObj",
"==",
"null",
"||",
"anotherProxiedObj",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"Object",
"unproxiedObj",
"=",
"unwrap",
"(",
"proxiedObj",
")",
";",
"Object",
"anotherUnproxiedObj",
"=",
"unwrap",
"(",
"anotherProxiedObj",
")",
";",
"boolean",
"sameClassName",
"=",
"unwrapProxyClassName",
"(",
"unproxiedObj",
".",
"getClass",
"(",
")",
")",
".",
"equals",
"(",
"unwrapProxyClassName",
"(",
"anotherUnproxiedObj",
".",
"getClass",
"(",
")",
")",
")",
";",
"if",
"(",
"sameClassName",
")",
"{",
"if",
"(",
"unproxiedObj",
".",
"getClass",
"(",
")",
".",
"isEnum",
"(",
")",
")",
"{",
"// Enum hashCode is different if loaded from different classloaders and cannot be overriden.",
"Enum",
"<",
"?",
">",
"enumLeft",
"=",
"Enum",
".",
"class",
".",
"cast",
"(",
"unproxiedObj",
")",
";",
"Enum",
"<",
"?",
">",
"enumRight",
"=",
"Enum",
".",
"class",
".",
"cast",
"(",
"anotherUnproxiedObj",
")",
";",
"return",
"(",
"enumLeft",
".",
"name",
"(",
")",
".",
"equals",
"(",
"enumRight",
".",
"name",
"(",
")",
")",
")",
"&&",
"(",
"enumLeft",
".",
"ordinal",
"(",
")",
"==",
"enumRight",
".",
"ordinal",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"(",
"unproxiedObj",
".",
"hashCode",
"(",
")",
"==",
"anotherUnproxiedObj",
".",
"hashCode",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"}"
] | This method tests if two proxied objects are equivalent.
It does so by comparing the class names and the hashCode, since they may be loaded from different classloaders. | [
"This",
"method",
"tests",
"if",
"two",
"proxied",
"objects",
"are",
"equivalent",
"."
] | train | https://github.com/forge/furnace/blob/bbe6deaa3c0d85ba43daa3e2f7d486f2dad21e0a/proxy/src/main/java/org/jboss/forge/furnace/proxy/Proxies.java#L398-L434 |
auth0/auth0-spring-security-api | lib/src/main/java/com/auth0/spring/security/api/JwtWebSecurityConfigurer.java | JwtWebSecurityConfigurer.forHS256 | @SuppressWarnings( {
"""
Configures application authorization for JWT signed with HS256
@param audience identifier of the API and must match the {@code aud} value in the token
@param issuer of the token for this API and must match the {@code iss} value in the token
@param secret used to sign and verify tokens
@return JwtWebSecurityConfigurer for further configuration
""""WeakerAccess", "SameParameterValue"})
public static JwtWebSecurityConfigurer forHS256(String audience, String issuer, byte[] secret) {
return new JwtWebSecurityConfigurer(audience, issuer, new JwtAuthenticationProvider(secret, issuer, audience));
} | java | @SuppressWarnings({"WeakerAccess", "SameParameterValue"})
public static JwtWebSecurityConfigurer forHS256(String audience, String issuer, byte[] secret) {
return new JwtWebSecurityConfigurer(audience, issuer, new JwtAuthenticationProvider(secret, issuer, audience));
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"SameParameterValue\"",
"}",
")",
"public",
"static",
"JwtWebSecurityConfigurer",
"forHS256",
"(",
"String",
"audience",
",",
"String",
"issuer",
",",
"byte",
"[",
"]",
"secret",
")",
"{",
"return",
"new",
"JwtWebSecurityConfigurer",
"(",
"audience",
",",
"issuer",
",",
"new",
"JwtAuthenticationProvider",
"(",
"secret",
",",
"issuer",
",",
"audience",
")",
")",
";",
"}"
] | Configures application authorization for JWT signed with HS256
@param audience identifier of the API and must match the {@code aud} value in the token
@param issuer of the token for this API and must match the {@code iss} value in the token
@param secret used to sign and verify tokens
@return JwtWebSecurityConfigurer for further configuration | [
"Configures",
"application",
"authorization",
"for",
"JWT",
"signed",
"with",
"HS256"
] | train | https://github.com/auth0/auth0-spring-security-api/blob/cebd4daa0125efd4da9e651cf29aa5ebdb147e2b/lib/src/main/java/com/auth0/spring/security/api/JwtWebSecurityConfigurer.java#L73-L76 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.order_orderId_paymentMeans_GET | public OvhPaymentMeans order_orderId_paymentMeans_GET(Long orderId) throws IOException {
"""
Return main data about the object the processing of the order generated
REST: GET /me/order/{orderId}/paymentMeans
@param orderId [required]
"""
String qPath = "/me/order/{orderId}/paymentMeans";
StringBuilder sb = path(qPath, orderId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPaymentMeans.class);
} | java | public OvhPaymentMeans order_orderId_paymentMeans_GET(Long orderId) throws IOException {
String qPath = "/me/order/{orderId}/paymentMeans";
StringBuilder sb = path(qPath, orderId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPaymentMeans.class);
} | [
"public",
"OvhPaymentMeans",
"order_orderId_paymentMeans_GET",
"(",
"Long",
"orderId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/order/{orderId}/paymentMeans\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"orderId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhPaymentMeans",
".",
"class",
")",
";",
"}"
] | Return main data about the object the processing of the order generated
REST: GET /me/order/{orderId}/paymentMeans
@param orderId [required] | [
"Return",
"main",
"data",
"about",
"the",
"object",
"the",
"processing",
"of",
"the",
"order",
"generated"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L1897-L1902 |
ag-gipp/MathMLTools | mathml-converters/src/main/java/com/formulasearchengine/mathmltools/converters/MathMLConverter.java | MathMLConverter.verifyMathML | String verifyMathML(String canMathML) throws MathConverterException {
"""
Just a quick scan over.
@param canMathML final mathml to be inspected
@return returns input string
@throws MathConverterException if it is not a well-structured mathml
"""
try {
Document tempDoc = XMLHelper.string2Doc(canMathML, true);
Content content = scanFormulaNode((Element) tempDoc.getFirstChild());
//verify the formula
if (content == Content.mathml) {
return canMathML;
} else {
throw new MathConverterException("could not verify produced mathml, content was: " + content.name());
}
} catch (Exception e) {
logger.error("could not verify mathml", e);
throw new MathConverterException("could not verify mathml");
}
} | java | String verifyMathML(String canMathML) throws MathConverterException {
try {
Document tempDoc = XMLHelper.string2Doc(canMathML, true);
Content content = scanFormulaNode((Element) tempDoc.getFirstChild());
//verify the formula
if (content == Content.mathml) {
return canMathML;
} else {
throw new MathConverterException("could not verify produced mathml, content was: " + content.name());
}
} catch (Exception e) {
logger.error("could not verify mathml", e);
throw new MathConverterException("could not verify mathml");
}
} | [
"String",
"verifyMathML",
"(",
"String",
"canMathML",
")",
"throws",
"MathConverterException",
"{",
"try",
"{",
"Document",
"tempDoc",
"=",
"XMLHelper",
".",
"string2Doc",
"(",
"canMathML",
",",
"true",
")",
";",
"Content",
"content",
"=",
"scanFormulaNode",
"(",
"(",
"Element",
")",
"tempDoc",
".",
"getFirstChild",
"(",
")",
")",
";",
"//verify the formula",
"if",
"(",
"content",
"==",
"Content",
".",
"mathml",
")",
"{",
"return",
"canMathML",
";",
"}",
"else",
"{",
"throw",
"new",
"MathConverterException",
"(",
"\"could not verify produced mathml, content was: \"",
"+",
"content",
".",
"name",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"could not verify mathml\"",
",",
"e",
")",
";",
"throw",
"new",
"MathConverterException",
"(",
"\"could not verify mathml\"",
")",
";",
"}",
"}"
] | Just a quick scan over.
@param canMathML final mathml to be inspected
@return returns input string
@throws MathConverterException if it is not a well-structured mathml | [
"Just",
"a",
"quick",
"scan",
"over",
"."
] | train | https://github.com/ag-gipp/MathMLTools/blob/77c69b6366a5b8720796d1cd9d155ba26c2f1b20/mathml-converters/src/main/java/com/formulasearchengine/mathmltools/converters/MathMLConverter.java#L125-L139 |
lukas-krecan/JsonUnit | json-unit-spring/src/main/java/net/javacrumbs/jsonunit/spring/JsonUnitResultMatchers.java | JsonUnitResultMatchers.isNotEqualTo | public ResultMatcher isNotEqualTo(final Object expected) {
"""
Fails if compared documents are equal. The expected object is converted to JSON
before comparison. Ignores order of sibling nodes and whitespaces.
"""
return new AbstractResultMatcher(path, configuration) {
public void doMatch(Object actual) {
Diff diff = createDiff(expected, actual);
if (diff.similar()) {
failWithMessage("JSON is equal.");
}
}
};
} | java | public ResultMatcher isNotEqualTo(final Object expected) {
return new AbstractResultMatcher(path, configuration) {
public void doMatch(Object actual) {
Diff diff = createDiff(expected, actual);
if (diff.similar()) {
failWithMessage("JSON is equal.");
}
}
};
} | [
"public",
"ResultMatcher",
"isNotEqualTo",
"(",
"final",
"Object",
"expected",
")",
"{",
"return",
"new",
"AbstractResultMatcher",
"(",
"path",
",",
"configuration",
")",
"{",
"public",
"void",
"doMatch",
"(",
"Object",
"actual",
")",
"{",
"Diff",
"diff",
"=",
"createDiff",
"(",
"expected",
",",
"actual",
")",
";",
"if",
"(",
"diff",
".",
"similar",
"(",
")",
")",
"{",
"failWithMessage",
"(",
"\"JSON is equal.\"",
")",
";",
"}",
"}",
"}",
";",
"}"
] | Fails if compared documents are equal. The expected object is converted to JSON
before comparison. Ignores order of sibling nodes and whitespaces. | [
"Fails",
"if",
"compared",
"documents",
"are",
"equal",
".",
"The",
"expected",
"object",
"is",
"converted",
"to",
"JSON",
"before",
"comparison",
".",
"Ignores",
"order",
"of",
"sibling",
"nodes",
"and",
"whitespaces",
"."
] | train | https://github.com/lukas-krecan/JsonUnit/blob/2b12ed792e8dd787bddd6f3b8eb2325737435791/json-unit-spring/src/main/java/net/javacrumbs/jsonunit/spring/JsonUnitResultMatchers.java#L126-L135 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java | Matrix.setColumn | public void setColumn(ColumnVector cv, int c)
throws MatrixException {
"""
Set a column of this matrix from a column vector.
@param cv the column vector
@param c the column index
@throws numbercruncher.MatrixException for an invalid index or
an invalid vector size
"""
if ((c < 0) || (c >= nCols)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
if (nRows != cv.nRows) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
for (int r = 0; r < nRows; ++r) {
this.values[r][c] = cv.values[r][0];
}
} | java | public void setColumn(ColumnVector cv, int c)
throws MatrixException
{
if ((c < 0) || (c >= nCols)) {
throw new MatrixException(MatrixException.INVALID_INDEX);
}
if (nRows != cv.nRows) {
throw new MatrixException(
MatrixException.INVALID_DIMENSIONS);
}
for (int r = 0; r < nRows; ++r) {
this.values[r][c] = cv.values[r][0];
}
} | [
"public",
"void",
"setColumn",
"(",
"ColumnVector",
"cv",
",",
"int",
"c",
")",
"throws",
"MatrixException",
"{",
"if",
"(",
"(",
"c",
"<",
"0",
")",
"||",
"(",
"c",
">=",
"nCols",
")",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_INDEX",
")",
";",
"}",
"if",
"(",
"nRows",
"!=",
"cv",
".",
"nRows",
")",
"{",
"throw",
"new",
"MatrixException",
"(",
"MatrixException",
".",
"INVALID_DIMENSIONS",
")",
";",
"}",
"for",
"(",
"int",
"r",
"=",
"0",
";",
"r",
"<",
"nRows",
";",
"++",
"r",
")",
"{",
"this",
".",
"values",
"[",
"r",
"]",
"[",
"c",
"]",
"=",
"cv",
".",
"values",
"[",
"r",
"]",
"[",
"0",
"]",
";",
"}",
"}"
] | Set a column of this matrix from a column vector.
@param cv the column vector
@param c the column index
@throws numbercruncher.MatrixException for an invalid index or
an invalid vector size | [
"Set",
"a",
"column",
"of",
"this",
"matrix",
"from",
"a",
"column",
"vector",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/matrixes/Matrix.java#L205-L219 |
rythmengine/rythmengine | src/main/java/org/rythmengine/internal/CodeBuilder.java | CodeBuilder.addInclude | public String addInclude(String include, int lineNo, ICodeType codeType) {
"""
add include
@param include
@param lineNo
@param codeType
@return the string
"""
TemplateTestResult testResult = engine.testTemplate(include, templateClass, codeType);
if (null == testResult) {
throw new ParseException(engine, templateClass, lineNo, "include template not found: %s", include);
}
// if there was an error in the included template - report it here
if (testResult.getError()!=null) {
String errMsg=testResult.getError().getMessage();
throw new ParseException(engine, templateClass, lineNo,errMsg, include);
}
String tmplName=testResult.getFullName();
TemplateBase includeTmpl = (TemplateBase) engine.getRegisteredTemplate(tmplName);
if (includeTmpl instanceof JavaTagBase) {
throw new ParseException(engine, templateClass, lineNo, "cannot include Java tag: %s", include);
}
// check that we didn't get any include at all
if (includeTmpl==null) {
throw new ParseException(engine, templateClass, lineNo, "include for template failed: %s ", include);
}
TemplateClass includeTc = includeTmpl.__getTemplateClass(false);
includeTc.buildSourceCode(includingClassName());
merge(includeTc.codeBuilder);
templateClass.addIncludeTemplateClass(includeTc);
return includeTc.codeBuilder.buildBody;
} | java | public String addInclude(String include, int lineNo, ICodeType codeType) {
TemplateTestResult testResult = engine.testTemplate(include, templateClass, codeType);
if (null == testResult) {
throw new ParseException(engine, templateClass, lineNo, "include template not found: %s", include);
}
// if there was an error in the included template - report it here
if (testResult.getError()!=null) {
String errMsg=testResult.getError().getMessage();
throw new ParseException(engine, templateClass, lineNo,errMsg, include);
}
String tmplName=testResult.getFullName();
TemplateBase includeTmpl = (TemplateBase) engine.getRegisteredTemplate(tmplName);
if (includeTmpl instanceof JavaTagBase) {
throw new ParseException(engine, templateClass, lineNo, "cannot include Java tag: %s", include);
}
// check that we didn't get any include at all
if (includeTmpl==null) {
throw new ParseException(engine, templateClass, lineNo, "include for template failed: %s ", include);
}
TemplateClass includeTc = includeTmpl.__getTemplateClass(false);
includeTc.buildSourceCode(includingClassName());
merge(includeTc.codeBuilder);
templateClass.addIncludeTemplateClass(includeTc);
return includeTc.codeBuilder.buildBody;
} | [
"public",
"String",
"addInclude",
"(",
"String",
"include",
",",
"int",
"lineNo",
",",
"ICodeType",
"codeType",
")",
"{",
"TemplateTestResult",
"testResult",
"=",
"engine",
".",
"testTemplate",
"(",
"include",
",",
"templateClass",
",",
"codeType",
")",
";",
"if",
"(",
"null",
"==",
"testResult",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"engine",
",",
"templateClass",
",",
"lineNo",
",",
"\"include template not found: %s\"",
",",
"include",
")",
";",
"}",
"// if there was an error in the included template - report it here",
"if",
"(",
"testResult",
".",
"getError",
"(",
")",
"!=",
"null",
")",
"{",
"String",
"errMsg",
"=",
"testResult",
".",
"getError",
"(",
")",
".",
"getMessage",
"(",
")",
";",
"throw",
"new",
"ParseException",
"(",
"engine",
",",
"templateClass",
",",
"lineNo",
",",
"errMsg",
",",
"include",
")",
";",
"}",
"String",
"tmplName",
"=",
"testResult",
".",
"getFullName",
"(",
")",
";",
"TemplateBase",
"includeTmpl",
"=",
"(",
"TemplateBase",
")",
"engine",
".",
"getRegisteredTemplate",
"(",
"tmplName",
")",
";",
"if",
"(",
"includeTmpl",
"instanceof",
"JavaTagBase",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"engine",
",",
"templateClass",
",",
"lineNo",
",",
"\"cannot include Java tag: %s\"",
",",
"include",
")",
";",
"}",
"// check that we didn't get any include at all",
"if",
"(",
"includeTmpl",
"==",
"null",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"engine",
",",
"templateClass",
",",
"lineNo",
",",
"\"include for template failed: %s \"",
",",
"include",
")",
";",
"}",
"TemplateClass",
"includeTc",
"=",
"includeTmpl",
".",
"__getTemplateClass",
"(",
"false",
")",
";",
"includeTc",
".",
"buildSourceCode",
"(",
"includingClassName",
"(",
")",
")",
";",
"merge",
"(",
"includeTc",
".",
"codeBuilder",
")",
";",
"templateClass",
".",
"addIncludeTemplateClass",
"(",
"includeTc",
")",
";",
"return",
"includeTc",
".",
"codeBuilder",
".",
"buildBody",
";",
"}"
] | add include
@param include
@param lineNo
@param codeType
@return the string | [
"add",
"include"
] | train | https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/CodeBuilder.java#L559-L584 |
alkacon/opencms-core | src-gwt/org/opencms/ade/galleries/client/A_CmsTabHandler.java | A_CmsTabHandler.selectResource | public void selectResource(String resourcePath, CmsUUID structureId, String title, String resourceType) {
"""
Selects the given resource and sets its path into the xml-content field or editor link.<p>
@param resourcePath the item resource path
@param structureId the structure id
@param title the resource title
@param resourceType the item resource type
"""
m_controller.selectResource(resourcePath, structureId, title, resourceType);
} | java | public void selectResource(String resourcePath, CmsUUID structureId, String title, String resourceType) {
m_controller.selectResource(resourcePath, structureId, title, resourceType);
} | [
"public",
"void",
"selectResource",
"(",
"String",
"resourcePath",
",",
"CmsUUID",
"structureId",
",",
"String",
"title",
",",
"String",
"resourceType",
")",
"{",
"m_controller",
".",
"selectResource",
"(",
"resourcePath",
",",
"structureId",
",",
"title",
",",
"resourceType",
")",
";",
"}"
] | Selects the given resource and sets its path into the xml-content field or editor link.<p>
@param resourcePath the item resource path
@param structureId the structure id
@param title the resource title
@param resourceType the item resource type | [
"Selects",
"the",
"given",
"resource",
"and",
"sets",
"its",
"path",
"into",
"the",
"xml",
"-",
"content",
"field",
"or",
"editor",
"link",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/galleries/client/A_CmsTabHandler.java#L151-L154 |
Trilarion/java-vorbis-support | src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/CodeBook.java | CodeBook.encodev | int encodev(int best, float[] a, Buffer b) {
"""
returns the number of bits and *modifies a* to the quantization value
"""
for (int k = 0; k < dim; k++) {
a[k] = valuelist[best * dim + k];
}
return (encode(best, b));
} | java | int encodev(int best, float[] a, Buffer b) {
for (int k = 0; k < dim; k++) {
a[k] = valuelist[best * dim + k];
}
return (encode(best, b));
} | [
"int",
"encodev",
"(",
"int",
"best",
",",
"float",
"[",
"]",
"a",
",",
"Buffer",
"b",
")",
"{",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"dim",
";",
"k",
"++",
")",
"{",
"a",
"[",
"k",
"]",
"=",
"valuelist",
"[",
"best",
"*",
"dim",
"+",
"k",
"]",
";",
"}",
"return",
"(",
"encode",
"(",
"best",
",",
"b",
")",
")",
";",
"}"
] | returns the number of bits and *modifies a* to the quantization value | [
"returns",
"the",
"number",
"of",
"bits",
"and",
"*",
"modifies",
"a",
"*",
"to",
"the",
"quantization",
"value"
] | train | https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/jcraft/jorbis/CodeBook.java#L65-L70 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jmx.connector.server.rest/src/com/ibm/ws/jmx/connector/server/rest/helpers/MBeanRoutedNotificationHelper.java | MBeanRoutedNotificationHelper.postRoutedServerNotificationListenerRegistrationEvent | private void postRoutedServerNotificationListenerRegistrationEvent(String operation, NotificationTargetInformation nti, ObjectName listener,
NotificationFilter filter, Object handback) {
"""
Post an event to EventAdmin, instructing the Target-Client Manager to register or unregister a listener MBean on a given target.
"""
Map<String, Object> props = createServerListenerRegistrationEvent(operation, nti, listener, filter, handback);
safePostEvent(new Event(REGISTER_JMX_NOTIFICATION_LISTENER_TOPIC, props));
} | java | private void postRoutedServerNotificationListenerRegistrationEvent(String operation, NotificationTargetInformation nti, ObjectName listener,
NotificationFilter filter, Object handback) {
Map<String, Object> props = createServerListenerRegistrationEvent(operation, nti, listener, filter, handback);
safePostEvent(new Event(REGISTER_JMX_NOTIFICATION_LISTENER_TOPIC, props));
} | [
"private",
"void",
"postRoutedServerNotificationListenerRegistrationEvent",
"(",
"String",
"operation",
",",
"NotificationTargetInformation",
"nti",
",",
"ObjectName",
"listener",
",",
"NotificationFilter",
"filter",
",",
"Object",
"handback",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
"=",
"createServerListenerRegistrationEvent",
"(",
"operation",
",",
"nti",
",",
"listener",
",",
"filter",
",",
"handback",
")",
";",
"safePostEvent",
"(",
"new",
"Event",
"(",
"REGISTER_JMX_NOTIFICATION_LISTENER_TOPIC",
",",
"props",
")",
")",
";",
"}"
] | Post an event to EventAdmin, instructing the Target-Client Manager to register or unregister a listener MBean on a given target. | [
"Post",
"an",
"event",
"to",
"EventAdmin",
"instructing",
"the",
"Target",
"-",
"Client",
"Manager",
"to",
"register",
"or",
"unregister",
"a",
"listener",
"MBean",
"on",
"a",
"given",
"target",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jmx.connector.server.rest/src/com/ibm/ws/jmx/connector/server/rest/helpers/MBeanRoutedNotificationHelper.java#L257-L261 |
joniles/mpxj | src/main/java/net/sf/mpxj/synchro/SynchroData.java | SynchroData.readTableHeaders | private List<SynchroTable> readTableHeaders(InputStream is) throws IOException {
"""
Read the table headers. This allows us to break the file into chunks
representing the individual tables.
@param is input stream
@return list of tables in the file
"""
// Read the headers
List<SynchroTable> tables = new ArrayList<SynchroTable>();
byte[] header = new byte[48];
while (true)
{
is.read(header);
m_offset += 48;
SynchroTable table = readTableHeader(header);
if (table == null)
{
break;
}
tables.add(table);
}
// Ensure sorted by offset
Collections.sort(tables, new Comparator<SynchroTable>()
{
@Override public int compare(SynchroTable o1, SynchroTable o2)
{
return o1.getOffset() - o2.getOffset();
}
});
// Calculate lengths
SynchroTable previousTable = null;
for (SynchroTable table : tables)
{
if (previousTable != null)
{
previousTable.setLength(table.getOffset() - previousTable.getOffset());
}
previousTable = table;
}
for (SynchroTable table : tables)
{
SynchroLogger.log("TABLE", table);
}
return tables;
} | java | private List<SynchroTable> readTableHeaders(InputStream is) throws IOException
{
// Read the headers
List<SynchroTable> tables = new ArrayList<SynchroTable>();
byte[] header = new byte[48];
while (true)
{
is.read(header);
m_offset += 48;
SynchroTable table = readTableHeader(header);
if (table == null)
{
break;
}
tables.add(table);
}
// Ensure sorted by offset
Collections.sort(tables, new Comparator<SynchroTable>()
{
@Override public int compare(SynchroTable o1, SynchroTable o2)
{
return o1.getOffset() - o2.getOffset();
}
});
// Calculate lengths
SynchroTable previousTable = null;
for (SynchroTable table : tables)
{
if (previousTable != null)
{
previousTable.setLength(table.getOffset() - previousTable.getOffset());
}
previousTable = table;
}
for (SynchroTable table : tables)
{
SynchroLogger.log("TABLE", table);
}
return tables;
} | [
"private",
"List",
"<",
"SynchroTable",
">",
"readTableHeaders",
"(",
"InputStream",
"is",
")",
"throws",
"IOException",
"{",
"// Read the headers",
"List",
"<",
"SynchroTable",
">",
"tables",
"=",
"new",
"ArrayList",
"<",
"SynchroTable",
">",
"(",
")",
";",
"byte",
"[",
"]",
"header",
"=",
"new",
"byte",
"[",
"48",
"]",
";",
"while",
"(",
"true",
")",
"{",
"is",
".",
"read",
"(",
"header",
")",
";",
"m_offset",
"+=",
"48",
";",
"SynchroTable",
"table",
"=",
"readTableHeader",
"(",
"header",
")",
";",
"if",
"(",
"table",
"==",
"null",
")",
"{",
"break",
";",
"}",
"tables",
".",
"add",
"(",
"table",
")",
";",
"}",
"// Ensure sorted by offset",
"Collections",
".",
"sort",
"(",
"tables",
",",
"new",
"Comparator",
"<",
"SynchroTable",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"SynchroTable",
"o1",
",",
"SynchroTable",
"o2",
")",
"{",
"return",
"o1",
".",
"getOffset",
"(",
")",
"-",
"o2",
".",
"getOffset",
"(",
")",
";",
"}",
"}",
")",
";",
"// Calculate lengths",
"SynchroTable",
"previousTable",
"=",
"null",
";",
"for",
"(",
"SynchroTable",
"table",
":",
"tables",
")",
"{",
"if",
"(",
"previousTable",
"!=",
"null",
")",
"{",
"previousTable",
".",
"setLength",
"(",
"table",
".",
"getOffset",
"(",
")",
"-",
"previousTable",
".",
"getOffset",
"(",
")",
")",
";",
"}",
"previousTable",
"=",
"table",
";",
"}",
"for",
"(",
"SynchroTable",
"table",
":",
"tables",
")",
"{",
"SynchroLogger",
".",
"log",
"(",
"\"TABLE\"",
",",
"table",
")",
";",
"}",
"return",
"tables",
";",
"}"
] | Read the table headers. This allows us to break the file into chunks
representing the individual tables.
@param is input stream
@return list of tables in the file | [
"Read",
"the",
"table",
"headers",
".",
"This",
"allows",
"us",
"to",
"break",
"the",
"file",
"into",
"chunks",
"representing",
"the",
"individual",
"tables",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/SynchroData.java#L88-L132 |
kaazing/gateway | mina.core/core/src/main/java/org/apache/mina/filter/statistic/ProfilerTimerFilter.java | ProfilerTimerFilter.sessionCreated | @Override
public void sessionCreated(NextFilter nextFilter, IoSession session)
throws Exception {
"""
Profile a SessionCreated event. This method will gather the following
informations :
- the method duration
- the shortest execution time
- the slowest execution time
- the average execution time
- the global number of calls
@param nextFilter The filter to call next
@param session The associated session
"""
if (profileSessionCreated) {
long start = timeNow();
nextFilter.sessionCreated(session);
long end = timeNow();
sessionCreatedTimerWorker.addNewDuration(end - start);
} else {
nextFilter.sessionCreated(session);
}
} | java | @Override
public void sessionCreated(NextFilter nextFilter, IoSession session)
throws Exception {
if (profileSessionCreated) {
long start = timeNow();
nextFilter.sessionCreated(session);
long end = timeNow();
sessionCreatedTimerWorker.addNewDuration(end - start);
} else {
nextFilter.sessionCreated(session);
}
} | [
"@",
"Override",
"public",
"void",
"sessionCreated",
"(",
"NextFilter",
"nextFilter",
",",
"IoSession",
"session",
")",
"throws",
"Exception",
"{",
"if",
"(",
"profileSessionCreated",
")",
"{",
"long",
"start",
"=",
"timeNow",
"(",
")",
";",
"nextFilter",
".",
"sessionCreated",
"(",
"session",
")",
";",
"long",
"end",
"=",
"timeNow",
"(",
")",
";",
"sessionCreatedTimerWorker",
".",
"addNewDuration",
"(",
"end",
"-",
"start",
")",
";",
"}",
"else",
"{",
"nextFilter",
".",
"sessionCreated",
"(",
"session",
")",
";",
"}",
"}"
] | Profile a SessionCreated event. This method will gather the following
informations :
- the method duration
- the shortest execution time
- the slowest execution time
- the average execution time
- the global number of calls
@param nextFilter The filter to call next
@param session The associated session | [
"Profile",
"a",
"SessionCreated",
"event",
".",
"This",
"method",
"will",
"gather",
"the",
"following",
"informations",
":",
"-",
"the",
"method",
"duration",
"-",
"the",
"shortest",
"execution",
"time",
"-",
"the",
"slowest",
"execution",
"time",
"-",
"the",
"average",
"execution",
"time",
"-",
"the",
"global",
"number",
"of",
"calls"
] | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.core/core/src/main/java/org/apache/mina/filter/statistic/ProfilerTimerFilter.java#L389-L400 |
pf4j/pf4j | pf4j/src/main/java/org/pf4j/util/DirectedGraph.java | DirectedGraph.addEdge | public void addEdge(V from, V to) {
"""
Add an edge to the graph; if either vertex does not exist, it's added.
This implementation allows the creation of multi-edges and self-loops.
"""
addVertex(from);
addVertex(to);
neighbors.get(from).add(to);
} | java | public void addEdge(V from, V to) {
addVertex(from);
addVertex(to);
neighbors.get(from).add(to);
} | [
"public",
"void",
"addEdge",
"(",
"V",
"from",
",",
"V",
"to",
")",
"{",
"addVertex",
"(",
"from",
")",
";",
"addVertex",
"(",
"to",
")",
";",
"neighbors",
".",
"get",
"(",
"from",
")",
".",
"add",
"(",
"to",
")",
";",
"}"
] | Add an edge to the graph; if either vertex does not exist, it's added.
This implementation allows the creation of multi-edges and self-loops. | [
"Add",
"an",
"edge",
"to",
"the",
"graph",
";",
"if",
"either",
"vertex",
"does",
"not",
"exist",
"it",
"s",
"added",
".",
"This",
"implementation",
"allows",
"the",
"creation",
"of",
"multi",
"-",
"edges",
"and",
"self",
"-",
"loops",
"."
] | train | https://github.com/pf4j/pf4j/blob/6dd7a6069f0e2fbd842c81e2c8c388918b88ea81/pf4j/src/main/java/org/pf4j/util/DirectedGraph.java#L65-L69 |
gondor/kbop | src/main/java/org/pacesys/kbop/internal/AbstractKeyedObjectPool.java | AbstractKeyedObjectPool.getBlockingUntilAvailableOrTimeout | E getBlockingUntilAvailableOrTimeout(final PoolKey<K> key, final long timeout, final TimeUnit unit, final PoolWaitFuture<E> future) throws InterruptedException, TimeoutException {
"""
Internal: Blocks until the object to be borrowed based on the key is available or until the max timeout specified has lapsed.
@param key the Pool Key used to lookup the Object to borrow
@param timeout the maximum time to wait
@param unit the time unit of the timeout argument
@param future the current future waiting on the object to become available
@return the Object which was successfully borrowed.
@throws InterruptedException if the thread was interrupted
@throws IllegalStateException if the pool has been shutdown
@throws TimeoutException if the wait timed out
"""
Date deadline = null;
if (timeout > 0) {
deadline = new Date(System.currentTimeMillis() + unit.toMillis(timeout));
}
lock.lock();
try
{
E entry = null;
for(;;)
{
validateShutdown();
entry = createOrAttemptToBorrow(key);
if (entry != null)
return entry.flagOwner();
if (!await(future, key, deadline) && deadline != null && deadline.getTime() <= System.currentTimeMillis()) break;
}
throw new TimeoutException("Timeout waiting for Pool for Key: " + key);
}
finally {
lock.unlock();
}
} | java | E getBlockingUntilAvailableOrTimeout(final PoolKey<K> key, final long timeout, final TimeUnit unit, final PoolWaitFuture<E> future) throws InterruptedException, TimeoutException {
Date deadline = null;
if (timeout > 0) {
deadline = new Date(System.currentTimeMillis() + unit.toMillis(timeout));
}
lock.lock();
try
{
E entry = null;
for(;;)
{
validateShutdown();
entry = createOrAttemptToBorrow(key);
if (entry != null)
return entry.flagOwner();
if (!await(future, key, deadline) && deadline != null && deadline.getTime() <= System.currentTimeMillis()) break;
}
throw new TimeoutException("Timeout waiting for Pool for Key: " + key);
}
finally {
lock.unlock();
}
} | [
"E",
"getBlockingUntilAvailableOrTimeout",
"(",
"final",
"PoolKey",
"<",
"K",
">",
"key",
",",
"final",
"long",
"timeout",
",",
"final",
"TimeUnit",
"unit",
",",
"final",
"PoolWaitFuture",
"<",
"E",
">",
"future",
")",
"throws",
"InterruptedException",
",",
"TimeoutException",
"{",
"Date",
"deadline",
"=",
"null",
";",
"if",
"(",
"timeout",
">",
"0",
")",
"{",
"deadline",
"=",
"new",
"Date",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"unit",
".",
"toMillis",
"(",
"timeout",
")",
")",
";",
"}",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"E",
"entry",
"=",
"null",
";",
"for",
"(",
";",
";",
")",
"{",
"validateShutdown",
"(",
")",
";",
"entry",
"=",
"createOrAttemptToBorrow",
"(",
"key",
")",
";",
"if",
"(",
"entry",
"!=",
"null",
")",
"return",
"entry",
".",
"flagOwner",
"(",
")",
";",
"if",
"(",
"!",
"await",
"(",
"future",
",",
"key",
",",
"deadline",
")",
"&&",
"deadline",
"!=",
"null",
"&&",
"deadline",
".",
"getTime",
"(",
")",
"<=",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
"break",
";",
"}",
"throw",
"new",
"TimeoutException",
"(",
"\"Timeout waiting for Pool for Key: \"",
"+",
"key",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Internal: Blocks until the object to be borrowed based on the key is available or until the max timeout specified has lapsed.
@param key the Pool Key used to lookup the Object to borrow
@param timeout the maximum time to wait
@param unit the time unit of the timeout argument
@param future the current future waiting on the object to become available
@return the Object which was successfully borrowed.
@throws InterruptedException if the thread was interrupted
@throws IllegalStateException if the pool has been shutdown
@throws TimeoutException if the wait timed out | [
"Internal",
":",
"Blocks",
"until",
"the",
"object",
"to",
"be",
"borrowed",
"based",
"on",
"the",
"key",
"is",
"available",
"or",
"until",
"the",
"max",
"timeout",
"specified",
"has",
"lapsed",
"."
] | train | https://github.com/gondor/kbop/blob/a176fd845f1e146610f03a1cb3cb0d661ebf4faa/src/main/java/org/pacesys/kbop/internal/AbstractKeyedObjectPool.java#L146-L172 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/FileUtilities.java | FileUtilities.deleteFileOrDir | public static boolean deleteFileOrDir( File filehandle ) {
"""
Returns true if all deletions were successful. If a deletion fails, the method stops
attempting to delete and returns false.
@param filehandle
@return true if all deletions were successful
"""
if (filehandle.isDirectory()) {
String[] children = filehandle.list();
for( int i = 0; i < children.length; i++ ) {
boolean success = deleteFileOrDir(new File(filehandle, children[i]));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
boolean isdel = filehandle.delete();
if (!isdel) {
// if it didn't work, which often happens on windows systems,
// remove on exit
filehandle.deleteOnExit();
}
return isdel;
} | java | public static boolean deleteFileOrDir( File filehandle ) {
if (filehandle.isDirectory()) {
String[] children = filehandle.list();
for( int i = 0; i < children.length; i++ ) {
boolean success = deleteFileOrDir(new File(filehandle, children[i]));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
boolean isdel = filehandle.delete();
if (!isdel) {
// if it didn't work, which often happens on windows systems,
// remove on exit
filehandle.deleteOnExit();
}
return isdel;
} | [
"public",
"static",
"boolean",
"deleteFileOrDir",
"(",
"File",
"filehandle",
")",
"{",
"if",
"(",
"filehandle",
".",
"isDirectory",
"(",
")",
")",
"{",
"String",
"[",
"]",
"children",
"=",
"filehandle",
".",
"list",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"boolean",
"success",
"=",
"deleteFileOrDir",
"(",
"new",
"File",
"(",
"filehandle",
",",
"children",
"[",
"i",
"]",
")",
")",
";",
"if",
"(",
"!",
"success",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"// The directory is now empty so delete it",
"boolean",
"isdel",
"=",
"filehandle",
".",
"delete",
"(",
")",
";",
"if",
"(",
"!",
"isdel",
")",
"{",
"// if it didn't work, which often happens on windows systems,",
"// remove on exit",
"filehandle",
".",
"deleteOnExit",
"(",
")",
";",
"}",
"return",
"isdel",
";",
"}"
] | Returns true if all deletions were successful. If a deletion fails, the method stops
attempting to delete and returns false.
@param filehandle
@return true if all deletions were successful | [
"Returns",
"true",
"if",
"all",
"deletions",
"were",
"successful",
".",
"If",
"a",
"deletion",
"fails",
"the",
"method",
"stops",
"attempting",
"to",
"delete",
"and",
"returns",
"false",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/grasslegacy/utils/FileUtilities.java#L183-L204 |
VoltDB/voltdb | third_party/java/src/com/google_voltpatches/common/primitives/UnsignedLongs.java | UnsignedLongs.parseUnsignedLong | @CanIgnoreReturnValue
public static long parseUnsignedLong(String string, int radix) {
"""
Returns the unsigned {@code long} value represented by a string with the given radix.
@param s the string containing the unsigned {@code long} representation to be parsed.
@param radix the radix to use while parsing {@code string}
@throws NumberFormatException if the string does not contain a valid unsigned {@code long} with
the given radix, or if {@code radix} is not between {@link Character#MIN_RADIX} and
{@link Character#MAX_RADIX}.
@throws NullPointerException if {@code string} is null (in contrast to
{@link Long#parseLong(String)})
"""
checkNotNull(string);
if (string.length() == 0) {
throw new NumberFormatException("empty string");
}
if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
throw new NumberFormatException("illegal radix: " + radix);
}
int maxSafePos = maxSafeDigits[radix] - 1;
long value = 0;
for (int pos = 0; pos < string.length(); pos++) {
int digit = Character.digit(string.charAt(pos), radix);
if (digit == -1) {
throw new NumberFormatException(string);
}
if (pos > maxSafePos && overflowInParse(value, digit, radix)) {
throw new NumberFormatException("Too large for unsigned long: " + string);
}
value = (value * radix) + digit;
}
return value;
} | java | @CanIgnoreReturnValue
public static long parseUnsignedLong(String string, int radix) {
checkNotNull(string);
if (string.length() == 0) {
throw new NumberFormatException("empty string");
}
if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
throw new NumberFormatException("illegal radix: " + radix);
}
int maxSafePos = maxSafeDigits[radix] - 1;
long value = 0;
for (int pos = 0; pos < string.length(); pos++) {
int digit = Character.digit(string.charAt(pos), radix);
if (digit == -1) {
throw new NumberFormatException(string);
}
if (pos > maxSafePos && overflowInParse(value, digit, radix)) {
throw new NumberFormatException("Too large for unsigned long: " + string);
}
value = (value * radix) + digit;
}
return value;
} | [
"@",
"CanIgnoreReturnValue",
"public",
"static",
"long",
"parseUnsignedLong",
"(",
"String",
"string",
",",
"int",
"radix",
")",
"{",
"checkNotNull",
"(",
"string",
")",
";",
"if",
"(",
"string",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"\"empty string\"",
")",
";",
"}",
"if",
"(",
"radix",
"<",
"Character",
".",
"MIN_RADIX",
"||",
"radix",
">",
"Character",
".",
"MAX_RADIX",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"\"illegal radix: \"",
"+",
"radix",
")",
";",
"}",
"int",
"maxSafePos",
"=",
"maxSafeDigits",
"[",
"radix",
"]",
"-",
"1",
";",
"long",
"value",
"=",
"0",
";",
"for",
"(",
"int",
"pos",
"=",
"0",
";",
"pos",
"<",
"string",
".",
"length",
"(",
")",
";",
"pos",
"++",
")",
"{",
"int",
"digit",
"=",
"Character",
".",
"digit",
"(",
"string",
".",
"charAt",
"(",
"pos",
")",
",",
"radix",
")",
";",
"if",
"(",
"digit",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"string",
")",
";",
"}",
"if",
"(",
"pos",
">",
"maxSafePos",
"&&",
"overflowInParse",
"(",
"value",
",",
"digit",
",",
"radix",
")",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"\"Too large for unsigned long: \"",
"+",
"string",
")",
";",
"}",
"value",
"=",
"(",
"value",
"*",
"radix",
")",
"+",
"digit",
";",
"}",
"return",
"value",
";",
"}"
] | Returns the unsigned {@code long} value represented by a string with the given radix.
@param s the string containing the unsigned {@code long} representation to be parsed.
@param radix the radix to use while parsing {@code string}
@throws NumberFormatException if the string does not contain a valid unsigned {@code long} with
the given radix, or if {@code radix} is not between {@link Character#MIN_RADIX} and
{@link Character#MAX_RADIX}.
@throws NullPointerException if {@code string} is null (in contrast to
{@link Long#parseLong(String)}) | [
"Returns",
"the",
"unsigned",
"{",
"@code",
"long",
"}",
"value",
"represented",
"by",
"a",
"string",
"with",
"the",
"given",
"radix",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/com/google_voltpatches/common/primitives/UnsignedLongs.java#L298-L322 |
mygreen/xlsmapper | src/main/java/com/gh/mygreen/xlsmapper/util/POIUtils.java | POIUtils.getCell | public static Cell getCell(final Sheet sheet, final CellPosition address) {
"""
シートから任意アドレスのセルを取得する。
@since 1.4
@param sheet シートオブジェクト
@param address セルのアドレス
@return セル
@throws IllegalArgumentException {@literal sheet == null or address == null.}
"""
ArgUtils.notNull(sheet, "sheet");
ArgUtils.notNull(address, "address");
return getCell(sheet, address.getColumn(), address.getRow());
} | java | public static Cell getCell(final Sheet sheet, final CellPosition address) {
ArgUtils.notNull(sheet, "sheet");
ArgUtils.notNull(address, "address");
return getCell(sheet, address.getColumn(), address.getRow());
} | [
"public",
"static",
"Cell",
"getCell",
"(",
"final",
"Sheet",
"sheet",
",",
"final",
"CellPosition",
"address",
")",
"{",
"ArgUtils",
".",
"notNull",
"(",
"sheet",
",",
"\"sheet\"",
")",
";",
"ArgUtils",
".",
"notNull",
"(",
"address",
",",
"\"address\"",
")",
";",
"return",
"getCell",
"(",
"sheet",
",",
"address",
".",
"getColumn",
"(",
")",
",",
"address",
".",
"getRow",
"(",
")",
")",
";",
"}"
] | シートから任意アドレスのセルを取得する。
@since 1.4
@param sheet シートオブジェクト
@param address セルのアドレス
@return セル
@throws IllegalArgumentException {@literal sheet == null or address == null.} | [
"シートから任意アドレスのセルを取得する。"
] | train | https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/util/POIUtils.java#L152-L156 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerCommunicationLinksInner.java | ServerCommunicationLinksInner.listByServerAsync | public Observable<List<ServerCommunicationLinkInner>> listByServerAsync(String resourceGroupName, String serverName) {
"""
Gets a list of server communication links.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ServerCommunicationLinkInner> object
"""
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<ServerCommunicationLinkInner>>, List<ServerCommunicationLinkInner>>() {
@Override
public List<ServerCommunicationLinkInner> call(ServiceResponse<List<ServerCommunicationLinkInner>> response) {
return response.body();
}
});
} | java | public Observable<List<ServerCommunicationLinkInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<ServerCommunicationLinkInner>>, List<ServerCommunicationLinkInner>>() {
@Override
public List<ServerCommunicationLinkInner> call(ServiceResponse<List<ServerCommunicationLinkInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"ServerCommunicationLinkInner",
">",
">",
"listByServerAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"ServerCommunicationLinkInner",
">",
">",
",",
"List",
"<",
"ServerCommunicationLinkInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"ServerCommunicationLinkInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"ServerCommunicationLinkInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets a list of server communication links.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ServerCommunicationLinkInner> object | [
"Gets",
"a",
"list",
"of",
"server",
"communication",
"links",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerCommunicationLinksInner.java#L488-L495 |
chhh/MSFTBX | MSFileToolbox/src/main/java/umich/ms/util/xml/XmlUtils.java | XmlUtils.advanceReaderToNext | public static boolean advanceReaderToNext(XMLStreamReader xsr, String tag)
throws javax.xml.stream.XMLStreamException {
"""
Advances the Stream Reader to the next occurrence of a user-specified tag.
@param xsr The reader to advance.
@param tag The tag to advance to. No brackets, just the name.
@return True if advanced successfully, false when the end of document was successfully reached.
@throws javax.xml.stream.XMLStreamException In all cases other than described by 'return'.
"""
if (tag == null) {
throw new IllegalArgumentException("Tag name can't be null");
}
if (xsr == null) {
throw new IllegalArgumentException("Stream Reader can't be null");
}
do {
if (xsr.next() == javax.xml.stream.XMLStreamConstants.END_DOCUMENT) {
return false;
}
} while (!(xsr.isStartElement() && xsr.getLocalName().equals(tag)));
return true;
} | java | public static boolean advanceReaderToNext(XMLStreamReader xsr, String tag)
throws javax.xml.stream.XMLStreamException {
if (tag == null) {
throw new IllegalArgumentException("Tag name can't be null");
}
if (xsr == null) {
throw new IllegalArgumentException("Stream Reader can't be null");
}
do {
if (xsr.next() == javax.xml.stream.XMLStreamConstants.END_DOCUMENT) {
return false;
}
} while (!(xsr.isStartElement() && xsr.getLocalName().equals(tag)));
return true;
} | [
"public",
"static",
"boolean",
"advanceReaderToNext",
"(",
"XMLStreamReader",
"xsr",
",",
"String",
"tag",
")",
"throws",
"javax",
".",
"xml",
".",
"stream",
".",
"XMLStreamException",
"{",
"if",
"(",
"tag",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Tag name can't be null\"",
")",
";",
"}",
"if",
"(",
"xsr",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Stream Reader can't be null\"",
")",
";",
"}",
"do",
"{",
"if",
"(",
"xsr",
".",
"next",
"(",
")",
"==",
"javax",
".",
"xml",
".",
"stream",
".",
"XMLStreamConstants",
".",
"END_DOCUMENT",
")",
"{",
"return",
"false",
";",
"}",
"}",
"while",
"(",
"!",
"(",
"xsr",
".",
"isStartElement",
"(",
")",
"&&",
"xsr",
".",
"getLocalName",
"(",
")",
".",
"equals",
"(",
"tag",
")",
")",
")",
";",
"return",
"true",
";",
"}"
] | Advances the Stream Reader to the next occurrence of a user-specified tag.
@param xsr The reader to advance.
@param tag The tag to advance to. No brackets, just the name.
@return True if advanced successfully, false when the end of document was successfully reached.
@throws javax.xml.stream.XMLStreamException In all cases other than described by 'return'. | [
"Advances",
"the",
"Stream",
"Reader",
"to",
"the",
"next",
"occurrence",
"of",
"a",
"user",
"-",
"specified",
"tag",
"."
] | train | https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/util/xml/XmlUtils.java#L256-L271 |
frostwire/frostwire-jlibtorrent | src/main/java/com/frostwire/jlibtorrent/TorrentBuilder.java | TorrentBuilder.addNode | public TorrentBuilder addNode(Pair<String, Integer> value) {
"""
This adds a DHT node to the torrent. This especially useful if you're creating a
tracker less torrent. It can be used by clients to bootstrap their DHT node from.
The node is a hostname and a port number where there is a DHT node running.
You can have any number of DHT nodes in a torrent.
@param value
@return
"""
if (value != null) {
this.nodes.add(value);
}
return this;
} | java | public TorrentBuilder addNode(Pair<String, Integer> value) {
if (value != null) {
this.nodes.add(value);
}
return this;
} | [
"public",
"TorrentBuilder",
"addNode",
"(",
"Pair",
"<",
"String",
",",
"Integer",
">",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"this",
".",
"nodes",
".",
"add",
"(",
"value",
")",
";",
"}",
"return",
"this",
";",
"}"
] | This adds a DHT node to the torrent. This especially useful if you're creating a
tracker less torrent. It can be used by clients to bootstrap their DHT node from.
The node is a hostname and a port number where there is a DHT node running.
You can have any number of DHT nodes in a torrent.
@param value
@return | [
"This",
"adds",
"a",
"DHT",
"node",
"to",
"the",
"torrent",
".",
"This",
"especially",
"useful",
"if",
"you",
"re",
"creating",
"a",
"tracker",
"less",
"torrent",
".",
"It",
"can",
"be",
"used",
"by",
"clients",
"to",
"bootstrap",
"their",
"DHT",
"node",
"from",
".",
"The",
"node",
"is",
"a",
"hostname",
"and",
"a",
"port",
"number",
"where",
"there",
"is",
"a",
"DHT",
"node",
"running",
".",
"You",
"can",
"have",
"any",
"number",
"of",
"DHT",
"nodes",
"in",
"a",
"torrent",
"."
] | train | https://github.com/frostwire/frostwire-jlibtorrent/blob/a29249a940d34aba8c4677d238b472ef01833506/src/main/java/com/frostwire/jlibtorrent/TorrentBuilder.java#L290-L295 |
EdwardRaff/JSAT | JSAT/src/jsat/io/CSV.java | CSV.readC | public static ClassificationDataSet readC(int classification_target, Reader reader, int lines_to_skip, Set<Integer> cat_cols) throws IOException {
"""
Reads in a CSV dataset as a classification dataset. Comments assumed to
start with the "#" symbol.
@param classification_target the column index (starting from zero) of the
feature that will be the categorical target value
@param reader the reader for the CSV content
@param lines_to_skip the number of lines to skip when reading in the CSV
(used to skip header information)
@param cat_cols a set of the indices to treat as categorical features.
@return the classification dataset from the given CSV file
@throws IOException
"""
return readC(classification_target, reader, DEFAULT_DELIMITER, lines_to_skip, DEFAULT_COMMENT, cat_cols);
} | java | public static ClassificationDataSet readC(int classification_target, Reader reader, int lines_to_skip, Set<Integer> cat_cols) throws IOException
{
return readC(classification_target, reader, DEFAULT_DELIMITER, lines_to_skip, DEFAULT_COMMENT, cat_cols);
} | [
"public",
"static",
"ClassificationDataSet",
"readC",
"(",
"int",
"classification_target",
",",
"Reader",
"reader",
",",
"int",
"lines_to_skip",
",",
"Set",
"<",
"Integer",
">",
"cat_cols",
")",
"throws",
"IOException",
"{",
"return",
"readC",
"(",
"classification_target",
",",
"reader",
",",
"DEFAULT_DELIMITER",
",",
"lines_to_skip",
",",
"DEFAULT_COMMENT",
",",
"cat_cols",
")",
";",
"}"
] | Reads in a CSV dataset as a classification dataset. Comments assumed to
start with the "#" symbol.
@param classification_target the column index (starting from zero) of the
feature that will be the categorical target value
@param reader the reader for the CSV content
@param lines_to_skip the number of lines to skip when reading in the CSV
(used to skip header information)
@param cat_cols a set of the indices to treat as categorical features.
@return the classification dataset from the given CSV file
@throws IOException | [
"Reads",
"in",
"a",
"CSV",
"dataset",
"as",
"a",
"classification",
"dataset",
".",
"Comments",
"assumed",
"to",
"start",
"with",
"the",
"#",
"symbol",
"."
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/io/CSV.java#L172-L175 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/format/FormatCache.java | FormatCache.getDateInstance | F getDateInstance(final int dateStyle, final TimeZone timeZone, final Locale locale) {
"""
package protected, for access from FastDateFormat; do not make public or protected
"""
return getDateTimeInstance(Integer.valueOf(dateStyle), null, timeZone, locale);
} | java | F getDateInstance(final int dateStyle, final TimeZone timeZone, final Locale locale) {
return getDateTimeInstance(Integer.valueOf(dateStyle), null, timeZone, locale);
} | [
"F",
"getDateInstance",
"(",
"final",
"int",
"dateStyle",
",",
"final",
"TimeZone",
"timeZone",
",",
"final",
"Locale",
"locale",
")",
"{",
"return",
"getDateTimeInstance",
"(",
"Integer",
".",
"valueOf",
"(",
"dateStyle",
")",
",",
"null",
",",
"timeZone",
",",
"locale",
")",
";",
"}"
] | package protected, for access from FastDateFormat; do not make public or protected | [
"package",
"protected",
"for",
"access",
"from",
"FastDateFormat",
";",
"do",
"not",
"make",
"public",
"or",
"protected"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/format/FormatCache.java#L131-L133 |
xiancloud/xian | xian-core/src/main/java/info/xiancloud/core/support/cache/api/CacheSetUtil.java | CacheSetUtil.values | public static <T> Single<Set<T>> values(CacheConfigBean cacheConfigBean, String key, Class<T> vClazz) {
"""
retrial the cached set
@param cacheConfigBean the datasource configuration
@param key the key
@param vClazz the class for the element
@param <T> generic type of the set
@return the typed value set
"""
return values(cacheConfigBean, key)
.map(values -> {
Set<T> _values = new TreeSet<>();
if (values != null && !values.isEmpty()) {
values.forEach(value -> {
_values.add(Reflection.toType(value, vClazz));
});
}
return _values;
});
} | java | public static <T> Single<Set<T>> values(CacheConfigBean cacheConfigBean, String key, Class<T> vClazz) {
return values(cacheConfigBean, key)
.map(values -> {
Set<T> _values = new TreeSet<>();
if (values != null && !values.isEmpty()) {
values.forEach(value -> {
_values.add(Reflection.toType(value, vClazz));
});
}
return _values;
});
} | [
"public",
"static",
"<",
"T",
">",
"Single",
"<",
"Set",
"<",
"T",
">",
">",
"values",
"(",
"CacheConfigBean",
"cacheConfigBean",
",",
"String",
"key",
",",
"Class",
"<",
"T",
">",
"vClazz",
")",
"{",
"return",
"values",
"(",
"cacheConfigBean",
",",
"key",
")",
".",
"map",
"(",
"values",
"->",
"{",
"Set",
"<",
"T",
">",
"_values",
"=",
"new",
"TreeSet",
"<>",
"(",
")",
";",
"if",
"(",
"values",
"!=",
"null",
"&&",
"!",
"values",
".",
"isEmpty",
"(",
")",
")",
"{",
"values",
".",
"forEach",
"(",
"value",
"->",
"{",
"_values",
".",
"add",
"(",
"Reflection",
".",
"toType",
"(",
"value",
",",
"vClazz",
")",
")",
";",
"}",
")",
";",
"}",
"return",
"_values",
";",
"}",
")",
";",
"}"
] | retrial the cached set
@param cacheConfigBean the datasource configuration
@param key the key
@param vClazz the class for the element
@param <T> generic type of the set
@return the typed value set | [
"retrial",
"the",
"cached",
"set"
] | train | https://github.com/xiancloud/xian/blob/1948e088545553d2745b2c86d8b5a64988bb850e/xian-core/src/main/java/info/xiancloud/core/support/cache/api/CacheSetUtil.java#L157-L168 |
geomajas/geomajas-project-client-gwt | common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/service/ClientConfigurationService.java | ClientConfigurationService.addCallback | private static boolean addCallback(String applicationId, DelayedCallback callback) {
"""
Add a delayed callback for the given application id. Returns whether this is the first request for the
application id.
@param applicationId application id
@param callback callback
@return true when first request for that application id
"""
boolean isFirst = false;
List<DelayedCallback> list = BACKLOG.get(applicationId);
if (null == list) {
list = new ArrayList<DelayedCallback>();
BACKLOG.put(applicationId, list);
isFirst = true;
}
list.add(callback);
return isFirst;
} | java | private static boolean addCallback(String applicationId, DelayedCallback callback) {
boolean isFirst = false;
List<DelayedCallback> list = BACKLOG.get(applicationId);
if (null == list) {
list = new ArrayList<DelayedCallback>();
BACKLOG.put(applicationId, list);
isFirst = true;
}
list.add(callback);
return isFirst;
} | [
"private",
"static",
"boolean",
"addCallback",
"(",
"String",
"applicationId",
",",
"DelayedCallback",
"callback",
")",
"{",
"boolean",
"isFirst",
"=",
"false",
";",
"List",
"<",
"DelayedCallback",
">",
"list",
"=",
"BACKLOG",
".",
"get",
"(",
"applicationId",
")",
";",
"if",
"(",
"null",
"==",
"list",
")",
"{",
"list",
"=",
"new",
"ArrayList",
"<",
"DelayedCallback",
">",
"(",
")",
";",
"BACKLOG",
".",
"put",
"(",
"applicationId",
",",
"list",
")",
";",
"isFirst",
"=",
"true",
";",
"}",
"list",
".",
"add",
"(",
"callback",
")",
";",
"return",
"isFirst",
";",
"}"
] | Add a delayed callback for the given application id. Returns whether this is the first request for the
application id.
@param applicationId application id
@param callback callback
@return true when first request for that application id | [
"Add",
"a",
"delayed",
"callback",
"for",
"the",
"given",
"application",
"id",
".",
"Returns",
"whether",
"this",
"is",
"the",
"first",
"request",
"for",
"the",
"application",
"id",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/common-gwt-smartgwt/src/main/java/org/geomajas/gwt/client/service/ClientConfigurationService.java#L107-L117 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java | ServerStatusFile.getNextMessage | private ServerStatusMessage getNextMessage(BufferedReader reader)
throws Exception {
"""
return the next message, or null if there are no more messages in the file
"""
boolean messageStarted = false;
String line = reader.readLine();
while (line != null && !messageStarted) {
if (line.equals(BEGIN_LINE)) {
messageStarted = true;
} else {
line = reader.readLine();
}
}
if (messageStarted) {
// get and parse first two required lines
ServerState state = ServerState.fromString(getNextLine(reader));
Date time = ServerStatusMessage.stringToDate(getNextLine(reader));
String detail = null;
// read optional detail lines till END_LINE
line = getNextLine(reader);
if (!line.equals(END_LINE)) {
StringBuffer buf = new StringBuffer();
while (!line.equals(END_LINE)) {
buf.append(line + "\n");
line = getNextLine(reader);
}
detail = buf.toString();
}
return new ServerStatusMessage(state, time, detail);
} else {
return null;
}
} | java | private ServerStatusMessage getNextMessage(BufferedReader reader)
throws Exception {
boolean messageStarted = false;
String line = reader.readLine();
while (line != null && !messageStarted) {
if (line.equals(BEGIN_LINE)) {
messageStarted = true;
} else {
line = reader.readLine();
}
}
if (messageStarted) {
// get and parse first two required lines
ServerState state = ServerState.fromString(getNextLine(reader));
Date time = ServerStatusMessage.stringToDate(getNextLine(reader));
String detail = null;
// read optional detail lines till END_LINE
line = getNextLine(reader);
if (!line.equals(END_LINE)) {
StringBuffer buf = new StringBuffer();
while (!line.equals(END_LINE)) {
buf.append(line + "\n");
line = getNextLine(reader);
}
detail = buf.toString();
}
return new ServerStatusMessage(state, time, detail);
} else {
return null;
}
} | [
"private",
"ServerStatusMessage",
"getNextMessage",
"(",
"BufferedReader",
"reader",
")",
"throws",
"Exception",
"{",
"boolean",
"messageStarted",
"=",
"false",
";",
"String",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"while",
"(",
"line",
"!=",
"null",
"&&",
"!",
"messageStarted",
")",
"{",
"if",
"(",
"line",
".",
"equals",
"(",
"BEGIN_LINE",
")",
")",
"{",
"messageStarted",
"=",
"true",
";",
"}",
"else",
"{",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"}",
"}",
"if",
"(",
"messageStarted",
")",
"{",
"// get and parse first two required lines",
"ServerState",
"state",
"=",
"ServerState",
".",
"fromString",
"(",
"getNextLine",
"(",
"reader",
")",
")",
";",
"Date",
"time",
"=",
"ServerStatusMessage",
".",
"stringToDate",
"(",
"getNextLine",
"(",
"reader",
")",
")",
";",
"String",
"detail",
"=",
"null",
";",
"// read optional detail lines till END_LINE",
"line",
"=",
"getNextLine",
"(",
"reader",
")",
";",
"if",
"(",
"!",
"line",
".",
"equals",
"(",
"END_LINE",
")",
")",
"{",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"while",
"(",
"!",
"line",
".",
"equals",
"(",
"END_LINE",
")",
")",
"{",
"buf",
".",
"append",
"(",
"line",
"+",
"\"\\n\"",
")",
";",
"line",
"=",
"getNextLine",
"(",
"reader",
")",
";",
"}",
"detail",
"=",
"buf",
".",
"toString",
"(",
")",
";",
"}",
"return",
"new",
"ServerStatusMessage",
"(",
"state",
",",
"time",
",",
"detail",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | return the next message, or null if there are no more messages in the file | [
"return",
"the",
"next",
"message",
"or",
"null",
"if",
"there",
"are",
"no",
"more",
"messages",
"in",
"the",
"file"
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/status/ServerStatusFile.java#L210-L248 |
jboss/jboss-jstl-api_spec | src/main/java/javax/servlet/jsp/jstl/tlv/ScriptFreeTLV.java | ScriptFreeTLV.setInitParameters | @Override
public void setInitParameters(Map<java.lang.String, java.lang.Object> initParms) {
"""
Sets the values of the initialization parameters, as supplied in the TLD.
@param initParms a mapping from the names of the initialization parameters
to their values, as specified in the TLD.
"""
super.setInitParameters(initParms);
String declarationsParm = (String) initParms.get("allowDeclarations");
String scriptletsParm = (String) initParms.get("allowScriptlets");
String expressionsParm = (String) initParms.get("allowExpressions");
String rtExpressionsParm = (String) initParms.get("allowRTExpressions");
allowDeclarations = "true".equalsIgnoreCase(declarationsParm);
allowScriptlets = "true".equalsIgnoreCase(scriptletsParm);
allowExpressions = "true".equalsIgnoreCase(expressionsParm);
allowRTExpressions = "true".equalsIgnoreCase(rtExpressionsParm);
} | java | @Override
public void setInitParameters(Map<java.lang.String, java.lang.Object> initParms) {
super.setInitParameters(initParms);
String declarationsParm = (String) initParms.get("allowDeclarations");
String scriptletsParm = (String) initParms.get("allowScriptlets");
String expressionsParm = (String) initParms.get("allowExpressions");
String rtExpressionsParm = (String) initParms.get("allowRTExpressions");
allowDeclarations = "true".equalsIgnoreCase(declarationsParm);
allowScriptlets = "true".equalsIgnoreCase(scriptletsParm);
allowExpressions = "true".equalsIgnoreCase(expressionsParm);
allowRTExpressions = "true".equalsIgnoreCase(rtExpressionsParm);
} | [
"@",
"Override",
"public",
"void",
"setInitParameters",
"(",
"Map",
"<",
"java",
".",
"lang",
".",
"String",
",",
"java",
".",
"lang",
".",
"Object",
">",
"initParms",
")",
"{",
"super",
".",
"setInitParameters",
"(",
"initParms",
")",
";",
"String",
"declarationsParm",
"=",
"(",
"String",
")",
"initParms",
".",
"get",
"(",
"\"allowDeclarations\"",
")",
";",
"String",
"scriptletsParm",
"=",
"(",
"String",
")",
"initParms",
".",
"get",
"(",
"\"allowScriptlets\"",
")",
";",
"String",
"expressionsParm",
"=",
"(",
"String",
")",
"initParms",
".",
"get",
"(",
"\"allowExpressions\"",
")",
";",
"String",
"rtExpressionsParm",
"=",
"(",
"String",
")",
"initParms",
".",
"get",
"(",
"\"allowRTExpressions\"",
")",
";",
"allowDeclarations",
"=",
"\"true\"",
".",
"equalsIgnoreCase",
"(",
"declarationsParm",
")",
";",
"allowScriptlets",
"=",
"\"true\"",
".",
"equalsIgnoreCase",
"(",
"scriptletsParm",
")",
";",
"allowExpressions",
"=",
"\"true\"",
".",
"equalsIgnoreCase",
"(",
"expressionsParm",
")",
";",
"allowRTExpressions",
"=",
"\"true\"",
".",
"equalsIgnoreCase",
"(",
"rtExpressionsParm",
")",
";",
"}"
] | Sets the values of the initialization parameters, as supplied in the TLD.
@param initParms a mapping from the names of the initialization parameters
to their values, as specified in the TLD. | [
"Sets",
"the",
"values",
"of",
"the",
"initialization",
"parameters",
"as",
"supplied",
"in",
"the",
"TLD",
"."
] | train | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/javax/servlet/jsp/jstl/tlv/ScriptFreeTLV.java#L68-L80 |
luuuis/jcalendar | src/main/java/com/toedter/calendar/JDateChooser.java | JDateChooser.main | public static void main(String[] s) {
"""
Creates a JFrame with a JDateChooser inside and can be used for testing.
@param s
The command line arguments
"""
JFrame frame = new JFrame("JDateChooser");
JDateChooser dateChooser = new JDateChooser();
// JDateChooser dateChooser = new JDateChooser(null, new Date(), null,
// null);
// dateChooser.setLocale(new Locale("de"));
// dateChooser.setDateFormatString("dd. MMMM yyyy");
// dateChooser.setPreferredSize(new Dimension(130, 20));
// dateChooser.setFont(new Font("Verdana", Font.PLAIN, 10));
// dateChooser.setDateFormatString("yyyy-MM-dd HH:mm");
// URL iconURL = dateChooser.getClass().getResource(
// "/com/toedter/calendar/images/JMonthChooserColor32.gif");
// ImageIcon icon = new ImageIcon(iconURL);
// dateChooser.setIcon(icon);
frame.getContentPane().add(dateChooser);
frame.pack();
frame.setVisible(true);
} | java | public static void main(String[] s) {
JFrame frame = new JFrame("JDateChooser");
JDateChooser dateChooser = new JDateChooser();
// JDateChooser dateChooser = new JDateChooser(null, new Date(), null,
// null);
// dateChooser.setLocale(new Locale("de"));
// dateChooser.setDateFormatString("dd. MMMM yyyy");
// dateChooser.setPreferredSize(new Dimension(130, 20));
// dateChooser.setFont(new Font("Verdana", Font.PLAIN, 10));
// dateChooser.setDateFormatString("yyyy-MM-dd HH:mm");
// URL iconURL = dateChooser.getClass().getResource(
// "/com/toedter/calendar/images/JMonthChooserColor32.gif");
// ImageIcon icon = new ImageIcon(iconURL);
// dateChooser.setIcon(icon);
frame.getContentPane().add(dateChooser);
frame.pack();
frame.setVisible(true);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"s",
")",
"{",
"JFrame",
"frame",
"=",
"new",
"JFrame",
"(",
"\"JDateChooser\"",
")",
";",
"JDateChooser",
"dateChooser",
"=",
"new",
"JDateChooser",
"(",
")",
";",
"// JDateChooser dateChooser = new JDateChooser(null, new Date(), null,",
"// null);",
"// dateChooser.setLocale(new Locale(\"de\"));",
"// dateChooser.setDateFormatString(\"dd. MMMM yyyy\");",
"// dateChooser.setPreferredSize(new Dimension(130, 20));",
"// dateChooser.setFont(new Font(\"Verdana\", Font.PLAIN, 10));",
"// dateChooser.setDateFormatString(\"yyyy-MM-dd HH:mm\");",
"// URL iconURL = dateChooser.getClass().getResource(",
"// \"/com/toedter/calendar/images/JMonthChooserColor32.gif\");",
"// ImageIcon icon = new ImageIcon(iconURL);",
"// dateChooser.setIcon(icon);",
"frame",
".",
"getContentPane",
"(",
")",
".",
"add",
"(",
"dateChooser",
")",
";",
"frame",
".",
"pack",
"(",
")",
";",
"frame",
".",
"setVisible",
"(",
"true",
")",
";",
"}"
] | Creates a JFrame with a JDateChooser inside and can be used for testing.
@param s
The command line arguments | [
"Creates",
"a",
"JFrame",
"with",
"a",
"JDateChooser",
"inside",
"and",
"can",
"be",
"used",
"for",
"testing",
"."
] | train | https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDateChooser.java#L563-L583 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ExpressRouteCircuitPeeringsInner.java | ExpressRouteCircuitPeeringsInner.listAsync | public Observable<Page<ExpressRouteCircuitPeeringInner>> listAsync(final String resourceGroupName, final String circuitName) {
"""
Gets all peerings in a specified express route circuit.
@param resourceGroupName The name of the resource group.
@param circuitName The name of the express route circuit.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ExpressRouteCircuitPeeringInner> object
"""
return listWithServiceResponseAsync(resourceGroupName, circuitName)
.map(new Func1<ServiceResponse<Page<ExpressRouteCircuitPeeringInner>>, Page<ExpressRouteCircuitPeeringInner>>() {
@Override
public Page<ExpressRouteCircuitPeeringInner> call(ServiceResponse<Page<ExpressRouteCircuitPeeringInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<ExpressRouteCircuitPeeringInner>> listAsync(final String resourceGroupName, final String circuitName) {
return listWithServiceResponseAsync(resourceGroupName, circuitName)
.map(new Func1<ServiceResponse<Page<ExpressRouteCircuitPeeringInner>>, Page<ExpressRouteCircuitPeeringInner>>() {
@Override
public Page<ExpressRouteCircuitPeeringInner> call(ServiceResponse<Page<ExpressRouteCircuitPeeringInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"ExpressRouteCircuitPeeringInner",
">",
">",
"listAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"circuitName",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"circuitName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"ExpressRouteCircuitPeeringInner",
">",
">",
",",
"Page",
"<",
"ExpressRouteCircuitPeeringInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"ExpressRouteCircuitPeeringInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"ExpressRouteCircuitPeeringInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets all peerings in a specified express route circuit.
@param resourceGroupName The name of the resource group.
@param circuitName The name of the express route circuit.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<ExpressRouteCircuitPeeringInner> object | [
"Gets",
"all",
"peerings",
"in",
"a",
"specified",
"express",
"route",
"circuit",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ExpressRouteCircuitPeeringsInner.java#L581-L589 |
windup/windup | reporting/api/src/main/java/org/jboss/windup/reporting/service/TagGraphService.java | TagGraphService.feedTagStructureToGraph | private TagModel feedTagStructureToGraph(Tag tag, Set<Tag> visited, int level) {
"""
Creates and returns the TagModel in a graph as per given Tag;
recursively creates the designated ("contained") tags.
<p>
If the Tag was already processed exists, returns the corresponding TagModel.
Doesn't check if the TagModel for given tag name already exists, assuming this method is only called once.
"""
if (visited.contains(tag))
return this.getUniqueByProperty(TagModel.PROP_NAME, tag.getName(), true);
visited.add(tag);
LOG.fine(String.format("Creating TagModel for Tag: %s%s(%d) '%s' traits: %s", StringUtils.repeat(' ', level*2),
tag.getName(), tag.getContainedTags().size(), tag.getTitle(), tag.getTraits()));
TagModel tagModel = this.create();
tagModel.setName(tag.getName());
tagModel.setTitle(tag.getTitle());
tagModel.setColor(tag.getColor());
tagModel.setRoot(tag.isPrime());
tagModel.setPseudo(tag.isPseudo());
if (null != tag.getTraits())
tagModel.putAllTraits(tag.getTraits());
tag.getContainedTags().forEach(tag2 -> {
TagModel tag2model = feedTagStructureToGraph(tag2, visited, level+1);
tagModel.addDesignatedTag(tag2model);
});
return tagModel;
} | java | private TagModel feedTagStructureToGraph(Tag tag, Set<Tag> visited, int level)
{
if (visited.contains(tag))
return this.getUniqueByProperty(TagModel.PROP_NAME, tag.getName(), true);
visited.add(tag);
LOG.fine(String.format("Creating TagModel for Tag: %s%s(%d) '%s' traits: %s", StringUtils.repeat(' ', level*2),
tag.getName(), tag.getContainedTags().size(), tag.getTitle(), tag.getTraits()));
TagModel tagModel = this.create();
tagModel.setName(tag.getName());
tagModel.setTitle(tag.getTitle());
tagModel.setColor(tag.getColor());
tagModel.setRoot(tag.isPrime());
tagModel.setPseudo(tag.isPseudo());
if (null != tag.getTraits())
tagModel.putAllTraits(tag.getTraits());
tag.getContainedTags().forEach(tag2 -> {
TagModel tag2model = feedTagStructureToGraph(tag2, visited, level+1);
tagModel.addDesignatedTag(tag2model);
});
return tagModel;
} | [
"private",
"TagModel",
"feedTagStructureToGraph",
"(",
"Tag",
"tag",
",",
"Set",
"<",
"Tag",
">",
"visited",
",",
"int",
"level",
")",
"{",
"if",
"(",
"visited",
".",
"contains",
"(",
"tag",
")",
")",
"return",
"this",
".",
"getUniqueByProperty",
"(",
"TagModel",
".",
"PROP_NAME",
",",
"tag",
".",
"getName",
"(",
")",
",",
"true",
")",
";",
"visited",
".",
"add",
"(",
"tag",
")",
";",
"LOG",
".",
"fine",
"(",
"String",
".",
"format",
"(",
"\"Creating TagModel for Tag: %s%s(%d) '%s' traits: %s\"",
",",
"StringUtils",
".",
"repeat",
"(",
"'",
"'",
",",
"level",
"*",
"2",
")",
",",
"tag",
".",
"getName",
"(",
")",
",",
"tag",
".",
"getContainedTags",
"(",
")",
".",
"size",
"(",
")",
",",
"tag",
".",
"getTitle",
"(",
")",
",",
"tag",
".",
"getTraits",
"(",
")",
")",
")",
";",
"TagModel",
"tagModel",
"=",
"this",
".",
"create",
"(",
")",
";",
"tagModel",
".",
"setName",
"(",
"tag",
".",
"getName",
"(",
")",
")",
";",
"tagModel",
".",
"setTitle",
"(",
"tag",
".",
"getTitle",
"(",
")",
")",
";",
"tagModel",
".",
"setColor",
"(",
"tag",
".",
"getColor",
"(",
")",
")",
";",
"tagModel",
".",
"setRoot",
"(",
"tag",
".",
"isPrime",
"(",
")",
")",
";",
"tagModel",
".",
"setPseudo",
"(",
"tag",
".",
"isPseudo",
"(",
")",
")",
";",
"if",
"(",
"null",
"!=",
"tag",
".",
"getTraits",
"(",
")",
")",
"tagModel",
".",
"putAllTraits",
"(",
"tag",
".",
"getTraits",
"(",
")",
")",
";",
"tag",
".",
"getContainedTags",
"(",
")",
".",
"forEach",
"(",
"tag2",
"->",
"{",
"TagModel",
"tag2model",
"=",
"feedTagStructureToGraph",
"(",
"tag2",
",",
"visited",
",",
"level",
"+",
"1",
")",
";",
"tagModel",
".",
"addDesignatedTag",
"(",
"tag2model",
")",
";",
"}",
")",
";",
"return",
"tagModel",
";",
"}"
] | Creates and returns the TagModel in a graph as per given Tag;
recursively creates the designated ("contained") tags.
<p>
If the Tag was already processed exists, returns the corresponding TagModel.
Doesn't check if the TagModel for given tag name already exists, assuming this method is only called once. | [
"Creates",
"and",
"returns",
"the",
"TagModel",
"in",
"a",
"graph",
"as",
"per",
"given",
"Tag",
";",
"recursively",
"creates",
"the",
"designated",
"(",
"contained",
")",
"tags",
".",
"<p",
">",
"If",
"the",
"Tag",
"was",
"already",
"processed",
"exists",
"returns",
"the",
"corresponding",
"TagModel",
".",
"Doesn",
"t",
"check",
"if",
"the",
"TagModel",
"for",
"given",
"tag",
"name",
"already",
"exists",
"assuming",
"this",
"method",
"is",
"only",
"called",
"once",
"."
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/TagGraphService.java#L66-L89 |
undertow-io/undertow | core/src/main/java/io/undertow/websockets/core/WebSockets.java | WebSockets.sendPong | public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) {
"""
Sends a complete pong message, invoking the callback when complete
@param data The data to send
@param wsChannel The web socket channel
@param callback The callback to invoke on completion
@param timeoutmillis the timeout in milliseconds
"""
sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, null, timeoutmillis);
} | java | public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) {
sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, null, timeoutmillis);
} | [
"public",
"static",
"void",
"sendPong",
"(",
"final",
"ByteBuffer",
"[",
"]",
"data",
",",
"final",
"WebSocketChannel",
"wsChannel",
",",
"final",
"WebSocketCallback",
"<",
"Void",
">",
"callback",
",",
"long",
"timeoutmillis",
")",
"{",
"sendInternal",
"(",
"mergeBuffers",
"(",
"data",
")",
",",
"WebSocketFrameType",
".",
"PONG",
",",
"wsChannel",
",",
"callback",
",",
"null",
",",
"timeoutmillis",
")",
";",
"}"
] | Sends a complete pong message, invoking the callback when complete
@param data The data to send
@param wsChannel The web socket channel
@param callback The callback to invoke on completion
@param timeoutmillis the timeout in milliseconds | [
"Sends",
"a",
"complete",
"pong",
"message",
"invoking",
"the",
"callback",
"when",
"complete"
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/websockets/core/WebSockets.java#L482-L484 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java | KeyVaultClientCustomImpl.listSecretVersions | public PagedList<SecretItem> listSecretVersions(final String vaultBaseUrl, final String secretName,
final Integer maxresults) {
"""
List the versions of the specified secret.
@param vaultBaseUrl
The vault name, e.g. https://myvault.vault.azure.net
@param secretName
The name of the secret in the given vault
@param maxresults
Maximum number of results to return in a page. If not specified
the service will return up to 25 results.
@return the PagedList<SecretItem> if successful.
"""
return getSecretVersions(vaultBaseUrl, secretName, maxresults);
} | java | public PagedList<SecretItem> listSecretVersions(final String vaultBaseUrl, final String secretName,
final Integer maxresults) {
return getSecretVersions(vaultBaseUrl, secretName, maxresults);
} | [
"public",
"PagedList",
"<",
"SecretItem",
">",
"listSecretVersions",
"(",
"final",
"String",
"vaultBaseUrl",
",",
"final",
"String",
"secretName",
",",
"final",
"Integer",
"maxresults",
")",
"{",
"return",
"getSecretVersions",
"(",
"vaultBaseUrl",
",",
"secretName",
",",
"maxresults",
")",
";",
"}"
] | List the versions of the specified secret.
@param vaultBaseUrl
The vault name, e.g. https://myvault.vault.azure.net
@param secretName
The name of the secret in the given vault
@param maxresults
Maximum number of results to return in a page. If not specified
the service will return up to 25 results.
@return the PagedList<SecretItem> if successful. | [
"List",
"the",
"versions",
"of",
"the",
"specified",
"secret",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java#L1262-L1265 |
iipc/openwayback | wayback-core/src/main/java/org/archive/wayback/core/UIResults.java | UIResults.getFormatter | public StringFormatter getFormatter() {
"""
return StringFormatter set-up for locale of request being
processed.
<p>deprecation recalled 2014-05-06.</p>
@return StringFormatter localized to user request
"""
if (formatter == null) {
ResourceBundle b = ResourceBundle.getBundle(UI_RESOURCE_BUNDLE_NAME, new UTF8Control());
formatter = new StringFormatter(b, getLocale());
}
return formatter;
} | java | public StringFormatter getFormatter() {
if (formatter == null) {
ResourceBundle b = ResourceBundle.getBundle(UI_RESOURCE_BUNDLE_NAME, new UTF8Control());
formatter = new StringFormatter(b, getLocale());
}
return formatter;
} | [
"public",
"StringFormatter",
"getFormatter",
"(",
")",
"{",
"if",
"(",
"formatter",
"==",
"null",
")",
"{",
"ResourceBundle",
"b",
"=",
"ResourceBundle",
".",
"getBundle",
"(",
"UI_RESOURCE_BUNDLE_NAME",
",",
"new",
"UTF8Control",
"(",
")",
")",
";",
"formatter",
"=",
"new",
"StringFormatter",
"(",
"b",
",",
"getLocale",
"(",
")",
")",
";",
"}",
"return",
"formatter",
";",
"}"
] | return StringFormatter set-up for locale of request being
processed.
<p>deprecation recalled 2014-05-06.</p>
@return StringFormatter localized to user request | [
"return",
"StringFormatter",
"set",
"-",
"up",
"for",
"locale",
"of",
"request",
"being",
"processed",
".",
"<p",
">",
"deprecation",
"recalled",
"2014",
"-",
"05",
"-",
"06",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/iipc/openwayback/blob/da74c3a59a5b5a5c365bd4702dcb45d263535794/wayback-core/src/main/java/org/archive/wayback/core/UIResults.java#L692-L698 |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDConnectionDaoImpl.java | GeneratedDConnectionDaoImpl.queryByProviderUserId | public Iterable<DConnection> queryByProviderUserId(java.lang.String providerUserId) {
"""
query-by method for field providerUserId
@param providerUserId the specified attribute
@return an Iterable of DConnections for the specified providerUserId
"""
return queryByField(null, DConnectionMapper.Field.PROVIDERUSERID.getFieldName(), providerUserId);
} | java | public Iterable<DConnection> queryByProviderUserId(java.lang.String providerUserId) {
return queryByField(null, DConnectionMapper.Field.PROVIDERUSERID.getFieldName(), providerUserId);
} | [
"public",
"Iterable",
"<",
"DConnection",
">",
"queryByProviderUserId",
"(",
"java",
".",
"lang",
".",
"String",
"providerUserId",
")",
"{",
"return",
"queryByField",
"(",
"null",
",",
"DConnectionMapper",
".",
"Field",
".",
"PROVIDERUSERID",
".",
"getFieldName",
"(",
")",
",",
"providerUserId",
")",
";",
"}"
] | query-by method for field providerUserId
@param providerUserId the specified attribute
@return an Iterable of DConnections for the specified providerUserId | [
"query",
"-",
"by",
"method",
"for",
"field",
"providerUserId"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/dao/GeneratedDConnectionDaoImpl.java#L124-L126 |
OpenLiberty/open-liberty | dev/com.ibm.ws.threading/src/com/ibm/ws/threading/internal/ThreadPoolController.java | ThreadPoolController.getThroughputDistribution | ThroughputDistribution getThroughputDistribution(int activeThreads, boolean create) {
"""
Get the throughput distribution data associated with the specified
number of active threads.
@param activeThreads the number of active threads when the data was
collected
@param create whether to create and return a new throughput distribution
if none currently exists
@return the data representing the throughput distribution for the
specified number of active threads
"""
if (activeThreads < coreThreads)
activeThreads = coreThreads;
Integer threads = Integer.valueOf(activeThreads);
ThroughputDistribution throughput = threadStats.get(threads);
if ((throughput == null) && create) {
throughput = new ThroughputDistribution();
throughput.setLastUpdate(controllerCycle);
threadStats.put(threads, throughput);
}
return throughput;
} | java | ThroughputDistribution getThroughputDistribution(int activeThreads, boolean create) {
if (activeThreads < coreThreads)
activeThreads = coreThreads;
Integer threads = Integer.valueOf(activeThreads);
ThroughputDistribution throughput = threadStats.get(threads);
if ((throughput == null) && create) {
throughput = new ThroughputDistribution();
throughput.setLastUpdate(controllerCycle);
threadStats.put(threads, throughput);
}
return throughput;
} | [
"ThroughputDistribution",
"getThroughputDistribution",
"(",
"int",
"activeThreads",
",",
"boolean",
"create",
")",
"{",
"if",
"(",
"activeThreads",
"<",
"coreThreads",
")",
"activeThreads",
"=",
"coreThreads",
";",
"Integer",
"threads",
"=",
"Integer",
".",
"valueOf",
"(",
"activeThreads",
")",
";",
"ThroughputDistribution",
"throughput",
"=",
"threadStats",
".",
"get",
"(",
"threads",
")",
";",
"if",
"(",
"(",
"throughput",
"==",
"null",
")",
"&&",
"create",
")",
"{",
"throughput",
"=",
"new",
"ThroughputDistribution",
"(",
")",
";",
"throughput",
".",
"setLastUpdate",
"(",
"controllerCycle",
")",
";",
"threadStats",
".",
"put",
"(",
"threads",
",",
"throughput",
")",
";",
"}",
"return",
"throughput",
";",
"}"
] | Get the throughput distribution data associated with the specified
number of active threads.
@param activeThreads the number of active threads when the data was
collected
@param create whether to create and return a new throughput distribution
if none currently exists
@return the data representing the throughput distribution for the
specified number of active threads | [
"Get",
"the",
"throughput",
"distribution",
"data",
"associated",
"with",
"the",
"specified",
"number",
"of",
"active",
"threads",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.threading/src/com/ibm/ws/threading/internal/ThreadPoolController.java#L752-L763 |
fuinorg/event-store-commons | eshttp/src/main/java/org/fuin/esc/eshttp/ESHttpUtils.java | ESHttpUtils.parseDocument | @NotNull
public static Document parseDocument(@NotNull final DocumentBuilder builder,
@NotNull final InputStream inputStream) {
"""
Parse the document and wraps checked exceptions into runtime exceptions.
@param builder
Builder to use.
@param inputStream
Input stream with XML.
@return Document.
"""
Contract.requireArgNotNull("builder", builder);
Contract.requireArgNotNull("inputStream", inputStream);
try {
return builder.parse(inputStream);
} catch (final SAXException | IOException ex) {
throw new RuntimeException("Failed to parse XML", ex);
}
} | java | @NotNull
public static Document parseDocument(@NotNull final DocumentBuilder builder,
@NotNull final InputStream inputStream) {
Contract.requireArgNotNull("builder", builder);
Contract.requireArgNotNull("inputStream", inputStream);
try {
return builder.parse(inputStream);
} catch (final SAXException | IOException ex) {
throw new RuntimeException("Failed to parse XML", ex);
}
} | [
"@",
"NotNull",
"public",
"static",
"Document",
"parseDocument",
"(",
"@",
"NotNull",
"final",
"DocumentBuilder",
"builder",
",",
"@",
"NotNull",
"final",
"InputStream",
"inputStream",
")",
"{",
"Contract",
".",
"requireArgNotNull",
"(",
"\"builder\"",
",",
"builder",
")",
";",
"Contract",
".",
"requireArgNotNull",
"(",
"\"inputStream\"",
",",
"inputStream",
")",
";",
"try",
"{",
"return",
"builder",
".",
"parse",
"(",
"inputStream",
")",
";",
"}",
"catch",
"(",
"final",
"SAXException",
"|",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to parse XML\"",
",",
"ex",
")",
";",
"}",
"}"
] | Parse the document and wraps checked exceptions into runtime exceptions.
@param builder
Builder to use.
@param inputStream
Input stream with XML.
@return Document. | [
"Parse",
"the",
"document",
"and",
"wraps",
"checked",
"exceptions",
"into",
"runtime",
"exceptions",
"."
] | train | https://github.com/fuinorg/event-store-commons/blob/ea175582d8cda2b5a6d2fe52bbb2f1c183eee77c/eshttp/src/main/java/org/fuin/esc/eshttp/ESHttpUtils.java#L153-L163 |
cdk/cdk | tool/forcefield/src/main/java/org/openscience/cdk/forcefield/mmff/MmffAtomTypeMatcher.java | MmffAtomTypeMatcher.fixNCNTypes | private void fixNCNTypes(String[] symbs, int[][] graph) {
"""
Special case, 'NCN+' matches entries that the validation suite say should actually be 'NC=N'.
We can achieve 100% compliance by checking if NCN+ is still next to CNN+ or CIM+ after
aromatic types are assigned
@param symbs symbolic types
@param graph adjacency list graph
"""
for (int v = 0; v < graph.length; v++) {
if ("NCN+".equals(symbs[v])) {
boolean foundCNN = false;
for (int w : graph[v]) {
foundCNN = foundCNN || "CNN+".equals(symbs[w]) || "CIM+".equals(symbs[w]);
}
if (!foundCNN) {
symbs[v] = "NC=N";
}
}
}
} | java | private void fixNCNTypes(String[] symbs, int[][] graph) {
for (int v = 0; v < graph.length; v++) {
if ("NCN+".equals(symbs[v])) {
boolean foundCNN = false;
for (int w : graph[v]) {
foundCNN = foundCNN || "CNN+".equals(symbs[w]) || "CIM+".equals(symbs[w]);
}
if (!foundCNN) {
symbs[v] = "NC=N";
}
}
}
} | [
"private",
"void",
"fixNCNTypes",
"(",
"String",
"[",
"]",
"symbs",
",",
"int",
"[",
"]",
"[",
"]",
"graph",
")",
"{",
"for",
"(",
"int",
"v",
"=",
"0",
";",
"v",
"<",
"graph",
".",
"length",
";",
"v",
"++",
")",
"{",
"if",
"(",
"\"NCN+\"",
".",
"equals",
"(",
"symbs",
"[",
"v",
"]",
")",
")",
"{",
"boolean",
"foundCNN",
"=",
"false",
";",
"for",
"(",
"int",
"w",
":",
"graph",
"[",
"v",
"]",
")",
"{",
"foundCNN",
"=",
"foundCNN",
"||",
"\"CNN+\"",
".",
"equals",
"(",
"symbs",
"[",
"w",
"]",
")",
"||",
"\"CIM+\"",
".",
"equals",
"(",
"symbs",
"[",
"w",
"]",
")",
";",
"}",
"if",
"(",
"!",
"foundCNN",
")",
"{",
"symbs",
"[",
"v",
"]",
"=",
"\"NC=N\"",
";",
"}",
"}",
"}",
"}"
] | Special case, 'NCN+' matches entries that the validation suite say should actually be 'NC=N'.
We can achieve 100% compliance by checking if NCN+ is still next to CNN+ or CIM+ after
aromatic types are assigned
@param symbs symbolic types
@param graph adjacency list graph | [
"Special",
"case",
"NCN",
"+",
"matches",
"entries",
"that",
"the",
"validation",
"suite",
"say",
"should",
"actually",
"be",
"NC",
"=",
"N",
".",
"We",
"can",
"achieve",
"100%",
"compliance",
"by",
"checking",
"if",
"NCN",
"+",
"is",
"still",
"next",
"to",
"CNN",
"+",
"or",
"CIM",
"+",
"after",
"aromatic",
"types",
"are",
"assigned"
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/forcefield/src/main/java/org/openscience/cdk/forcefield/mmff/MmffAtomTypeMatcher.java#L149-L161 |
citrusframework/citrus | modules/citrus-ws/src/main/java/com/consol/citrus/ws/server/WebServiceEndpoint.java | WebServiceEndpoint.addMimeHeaders | private void addMimeHeaders(SoapMessage response, Message replyMessage) {
"""
Adds mime headers outside of SOAP envelope. Header entries that go to this header section
must have internal http header prefix defined in {@link com.consol.citrus.ws.message.SoapMessageHeaders}.
@param response the soap response message.
@param replyMessage the internal reply message.
"""
for (Entry<String, Object> headerEntry : replyMessage.getHeaders().entrySet()) {
if (headerEntry.getKey().toLowerCase().startsWith(SoapMessageHeaders.HTTP_PREFIX)) {
String headerName = headerEntry.getKey().substring(SoapMessageHeaders.HTTP_PREFIX.length());
if (response instanceof SaajSoapMessage) {
SaajSoapMessage saajSoapMessage = (SaajSoapMessage) response;
MimeHeaders headers = saajSoapMessage.getSaajMessage().getMimeHeaders();
headers.setHeader(headerName, headerEntry.getValue().toString());
} else if (response instanceof AxiomSoapMessage) {
log.warn("Unable to set mime message header '" + headerName + "' on AxiomSoapMessage - unsupported");
} else {
log.warn("Unsupported SOAP message implementation - unable to set mime message header '" + headerName + "'");
}
}
}
} | java | private void addMimeHeaders(SoapMessage response, Message replyMessage) {
for (Entry<String, Object> headerEntry : replyMessage.getHeaders().entrySet()) {
if (headerEntry.getKey().toLowerCase().startsWith(SoapMessageHeaders.HTTP_PREFIX)) {
String headerName = headerEntry.getKey().substring(SoapMessageHeaders.HTTP_PREFIX.length());
if (response instanceof SaajSoapMessage) {
SaajSoapMessage saajSoapMessage = (SaajSoapMessage) response;
MimeHeaders headers = saajSoapMessage.getSaajMessage().getMimeHeaders();
headers.setHeader(headerName, headerEntry.getValue().toString());
} else if (response instanceof AxiomSoapMessage) {
log.warn("Unable to set mime message header '" + headerName + "' on AxiomSoapMessage - unsupported");
} else {
log.warn("Unsupported SOAP message implementation - unable to set mime message header '" + headerName + "'");
}
}
}
} | [
"private",
"void",
"addMimeHeaders",
"(",
"SoapMessage",
"response",
",",
"Message",
"replyMessage",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"headerEntry",
":",
"replyMessage",
".",
"getHeaders",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"headerEntry",
".",
"getKey",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"startsWith",
"(",
"SoapMessageHeaders",
".",
"HTTP_PREFIX",
")",
")",
"{",
"String",
"headerName",
"=",
"headerEntry",
".",
"getKey",
"(",
")",
".",
"substring",
"(",
"SoapMessageHeaders",
".",
"HTTP_PREFIX",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"response",
"instanceof",
"SaajSoapMessage",
")",
"{",
"SaajSoapMessage",
"saajSoapMessage",
"=",
"(",
"SaajSoapMessage",
")",
"response",
";",
"MimeHeaders",
"headers",
"=",
"saajSoapMessage",
".",
"getSaajMessage",
"(",
")",
".",
"getMimeHeaders",
"(",
")",
";",
"headers",
".",
"setHeader",
"(",
"headerName",
",",
"headerEntry",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"response",
"instanceof",
"AxiomSoapMessage",
")",
"{",
"log",
".",
"warn",
"(",
"\"Unable to set mime message header '\"",
"+",
"headerName",
"+",
"\"' on AxiomSoapMessage - unsupported\"",
")",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"\"Unsupported SOAP message implementation - unable to set mime message header '\"",
"+",
"headerName",
"+",
"\"'\"",
")",
";",
"}",
"}",
"}",
"}"
] | Adds mime headers outside of SOAP envelope. Header entries that go to this header section
must have internal http header prefix defined in {@link com.consol.citrus.ws.message.SoapMessageHeaders}.
@param response the soap response message.
@param replyMessage the internal reply message. | [
"Adds",
"mime",
"headers",
"outside",
"of",
"SOAP",
"envelope",
".",
"Header",
"entries",
"that",
"go",
"to",
"this",
"header",
"section",
"must",
"have",
"internal",
"http",
"header",
"prefix",
"defined",
"in",
"{"
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-ws/src/main/java/com/consol/citrus/ws/server/WebServiceEndpoint.java#L178-L194 |
Netflix/astyanax | astyanax-thrift/src/main/java/com/netflix/astyanax/thrift/ThriftClusterImpl.java | ThriftClusterImpl.getVersion | @Override
public String getVersion() throws ConnectionException {
"""
Get the version from the cluster
@return
@throws OperationException
"""
return connectionPool.executeWithFailover(
new AbstractOperationImpl<String>(tracerFactory.newTracer(CassandraOperationType.GET_VERSION)) {
@Override
public String internalExecute(Client client, ConnectionContext state) throws Exception {
return client.describe_version();
}
}, config.getRetryPolicy().duplicate()).getResult();
} | java | @Override
public String getVersion() throws ConnectionException {
return connectionPool.executeWithFailover(
new AbstractOperationImpl<String>(tracerFactory.newTracer(CassandraOperationType.GET_VERSION)) {
@Override
public String internalExecute(Client client, ConnectionContext state) throws Exception {
return client.describe_version();
}
}, config.getRetryPolicy().duplicate()).getResult();
} | [
"@",
"Override",
"public",
"String",
"getVersion",
"(",
")",
"throws",
"ConnectionException",
"{",
"return",
"connectionPool",
".",
"executeWithFailover",
"(",
"new",
"AbstractOperationImpl",
"<",
"String",
">",
"(",
"tracerFactory",
".",
"newTracer",
"(",
"CassandraOperationType",
".",
"GET_VERSION",
")",
")",
"{",
"@",
"Override",
"public",
"String",
"internalExecute",
"(",
"Client",
"client",
",",
"ConnectionContext",
"state",
")",
"throws",
"Exception",
"{",
"return",
"client",
".",
"describe_version",
"(",
")",
";",
"}",
"}",
",",
"config",
".",
"getRetryPolicy",
"(",
")",
".",
"duplicate",
"(",
")",
")",
".",
"getResult",
"(",
")",
";",
"}"
] | Get the version from the cluster
@return
@throws OperationException | [
"Get",
"the",
"version",
"from",
"the",
"cluster"
] | train | https://github.com/Netflix/astyanax/blob/bcc3fd26e2dda05a923751aa32b139f6209fecdf/astyanax-thrift/src/main/java/com/netflix/astyanax/thrift/ThriftClusterImpl.java#L130-L139 |
m-m-m/util | datatype/src/main/java/net/sf/mmm/util/datatype/api/color/GenericColor.java | GenericColor.valueOf | public static GenericColor valueOf(Red red, Green green, Blue blue, Alpha alpha) {
"""
Creates a {@link GenericColor} from the given {@link Segment}s of {@link ColorModel#RGB}.
@param red is the {@link Red} part.
@param green is the {@link Green} part.
@param blue is the {@link Blue} part.
@param alpha is the {@link Alpha} value.
@return the {@link GenericColor}.
"""
Objects.requireNonNull(red, "red");
Objects.requireNonNull(green, "green");
Objects.requireNonNull(blue, "blue");
Objects.requireNonNull(alpha, "alpha");
GenericColor genericColor = new GenericColor();
genericColor.red = red;
genericColor.green = green;
genericColor.blue = blue;
genericColor.alpha = alpha;
// calculate min/max
double r = red.getValueAsFactor();
double g = green.getValueAsFactor();
double b = blue.getValueAsFactor();
double max = r;
if (g > max) {
max = g;
}
if (b > max) {
max = b;
}
double min = r;
if (g < min) {
min = g;
}
if (b < min) {
min = b;
}
double chroma = max - min;
genericColor.chroma = new Chroma(chroma);
double hue = calculateHue(r, g, b, max, chroma);
genericColor.hue = new Hue(hue);
double s;
if (max == 0) {
s = 0;
} else {
s = chroma / max;
}
genericColor.saturationHsb = new Saturation(s);
double lightness = (max + min) / 2;
genericColor.lightness = new Lightness(lightness);
double saturationHsl = calculateSaturationHsl(chroma, lightness);
genericColor.saturationHsl = new Saturation(saturationHsl);
genericColor.brightness = new Brightness(max);
return genericColor;
} | java | public static GenericColor valueOf(Red red, Green green, Blue blue, Alpha alpha) {
Objects.requireNonNull(red, "red");
Objects.requireNonNull(green, "green");
Objects.requireNonNull(blue, "blue");
Objects.requireNonNull(alpha, "alpha");
GenericColor genericColor = new GenericColor();
genericColor.red = red;
genericColor.green = green;
genericColor.blue = blue;
genericColor.alpha = alpha;
// calculate min/max
double r = red.getValueAsFactor();
double g = green.getValueAsFactor();
double b = blue.getValueAsFactor();
double max = r;
if (g > max) {
max = g;
}
if (b > max) {
max = b;
}
double min = r;
if (g < min) {
min = g;
}
if (b < min) {
min = b;
}
double chroma = max - min;
genericColor.chroma = new Chroma(chroma);
double hue = calculateHue(r, g, b, max, chroma);
genericColor.hue = new Hue(hue);
double s;
if (max == 0) {
s = 0;
} else {
s = chroma / max;
}
genericColor.saturationHsb = new Saturation(s);
double lightness = (max + min) / 2;
genericColor.lightness = new Lightness(lightness);
double saturationHsl = calculateSaturationHsl(chroma, lightness);
genericColor.saturationHsl = new Saturation(saturationHsl);
genericColor.brightness = new Brightness(max);
return genericColor;
} | [
"public",
"static",
"GenericColor",
"valueOf",
"(",
"Red",
"red",
",",
"Green",
"green",
",",
"Blue",
"blue",
",",
"Alpha",
"alpha",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"red",
",",
"\"red\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"green",
",",
"\"green\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"blue",
",",
"\"blue\"",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"alpha",
",",
"\"alpha\"",
")",
";",
"GenericColor",
"genericColor",
"=",
"new",
"GenericColor",
"(",
")",
";",
"genericColor",
".",
"red",
"=",
"red",
";",
"genericColor",
".",
"green",
"=",
"green",
";",
"genericColor",
".",
"blue",
"=",
"blue",
";",
"genericColor",
".",
"alpha",
"=",
"alpha",
";",
"// calculate min/max",
"double",
"r",
"=",
"red",
".",
"getValueAsFactor",
"(",
")",
";",
"double",
"g",
"=",
"green",
".",
"getValueAsFactor",
"(",
")",
";",
"double",
"b",
"=",
"blue",
".",
"getValueAsFactor",
"(",
")",
";",
"double",
"max",
"=",
"r",
";",
"if",
"(",
"g",
">",
"max",
")",
"{",
"max",
"=",
"g",
";",
"}",
"if",
"(",
"b",
">",
"max",
")",
"{",
"max",
"=",
"b",
";",
"}",
"double",
"min",
"=",
"r",
";",
"if",
"(",
"g",
"<",
"min",
")",
"{",
"min",
"=",
"g",
";",
"}",
"if",
"(",
"b",
"<",
"min",
")",
"{",
"min",
"=",
"b",
";",
"}",
"double",
"chroma",
"=",
"max",
"-",
"min",
";",
"genericColor",
".",
"chroma",
"=",
"new",
"Chroma",
"(",
"chroma",
")",
";",
"double",
"hue",
"=",
"calculateHue",
"(",
"r",
",",
"g",
",",
"b",
",",
"max",
",",
"chroma",
")",
";",
"genericColor",
".",
"hue",
"=",
"new",
"Hue",
"(",
"hue",
")",
";",
"double",
"s",
";",
"if",
"(",
"max",
"==",
"0",
")",
"{",
"s",
"=",
"0",
";",
"}",
"else",
"{",
"s",
"=",
"chroma",
"/",
"max",
";",
"}",
"genericColor",
".",
"saturationHsb",
"=",
"new",
"Saturation",
"(",
"s",
")",
";",
"double",
"lightness",
"=",
"(",
"max",
"+",
"min",
")",
"/",
"2",
";",
"genericColor",
".",
"lightness",
"=",
"new",
"Lightness",
"(",
"lightness",
")",
";",
"double",
"saturationHsl",
"=",
"calculateSaturationHsl",
"(",
"chroma",
",",
"lightness",
")",
";",
"genericColor",
".",
"saturationHsl",
"=",
"new",
"Saturation",
"(",
"saturationHsl",
")",
";",
"genericColor",
".",
"brightness",
"=",
"new",
"Brightness",
"(",
"max",
")",
";",
"return",
"genericColor",
";",
"}"
] | Creates a {@link GenericColor} from the given {@link Segment}s of {@link ColorModel#RGB}.
@param red is the {@link Red} part.
@param green is the {@link Green} part.
@param blue is the {@link Blue} part.
@param alpha is the {@link Alpha} value.
@return the {@link GenericColor}. | [
"Creates",
"a",
"{",
"@link",
"GenericColor",
"}",
"from",
"the",
"given",
"{",
"@link",
"Segment",
"}",
"s",
"of",
"{",
"@link",
"ColorModel#RGB",
"}",
"."
] | train | https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/datatype/src/main/java/net/sf/mmm/util/datatype/api/color/GenericColor.java#L159-L206 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.