repository_name stringlengths 7 58 | func_path_in_repository stringlengths 11 204 | func_name stringlengths 5 103 | whole_func_string stringlengths 87 3.44k | language stringclasses 1
value | func_code_string stringlengths 87 3.44k | func_code_tokens listlengths 21 714 | func_documentation_string stringlengths 61 1.95k | func_documentation_tokens listlengths 1 482 | split_name stringclasses 1
value | func_code_url stringlengths 102 309 |
|---|---|---|---|---|---|---|---|---|---|---|
graphhopper/graphhopper | core/src/main/java/com/graphhopper/storage/index/LocationIndexTree.java | LocationIndexTree.createReverseKey | final long createReverseKey(double lat, double lon) {
return BitUtil.BIG.reverse(keyAlgo.encode(lat, lon), keyAlgo.getBits());
} | java | final long createReverseKey(double lat, double lon) {
return BitUtil.BIG.reverse(keyAlgo.encode(lat, lon), keyAlgo.getBits());
} | [
"final",
"long",
"createReverseKey",
"(",
"double",
"lat",
",",
"double",
"lon",
")",
"{",
"return",
"BitUtil",
".",
"BIG",
".",
"reverse",
"(",
"keyAlgo",
".",
"encode",
"(",
"lat",
",",
"lon",
")",
",",
"keyAlgo",
".",
"getBits",
"(",
")",
")",
";"... | this method returns the spatial key in reverse order for easier right-shifting | [
"this",
"method",
"returns",
"the",
"spatial",
"key",
"in",
"reverse",
"order",
"for",
"easier",
"right",
"-",
"shifting"
] | train | https://github.com/graphhopper/graphhopper/blob/c235e306e6e823043cadcc41ead0e685bdebf737/core/src/main/java/com/graphhopper/storage/index/LocationIndexTree.java#L377-L379 |
gallandarakhneorg/afc | core/maths/mathgeom/tobeincluded/src/d3/continuous/OrientedBox3f.java | OrientedBox3f.setFirstAxis | @Override
public void setFirstAxis(double x, double y, double z, double extent, CoordinateSystem3D system) {
this.axis1.set(x, y, z);
assert(this.axis1.isUnitVector());
if (system.isLeftHanded()) {
this.axis3.set(this.axis1.crossLeftHand(this.axis2));
} else {
this.axis3.set(this.axis3.crossRightHand(this.axis2));
}
this.extent1 = extent;
} | java | @Override
public void setFirstAxis(double x, double y, double z, double extent, CoordinateSystem3D system) {
this.axis1.set(x, y, z);
assert(this.axis1.isUnitVector());
if (system.isLeftHanded()) {
this.axis3.set(this.axis1.crossLeftHand(this.axis2));
} else {
this.axis3.set(this.axis3.crossRightHand(this.axis2));
}
this.extent1 = extent;
} | [
"@",
"Override",
"public",
"void",
"setFirstAxis",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
",",
"double",
"extent",
",",
"CoordinateSystem3D",
"system",
")",
"{",
"this",
".",
"axis1",
".",
"set",
"(",
"x",
",",
"y",
",",
"z",
")"... | Set the first axis of the second .
The third axis is updated to be perpendicular to the two other axis.
@param x
@param y
@param z
@param extent
@param system | [
"Set",
"the",
"first",
"axis",
"of",
"the",
"second",
".",
"The",
"third",
"axis",
"is",
"updated",
"to",
"be",
"perpendicular",
"to",
"the",
"two",
"other",
"axis",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/OrientedBox3f.java#L453-L463 |
algolia/instantsearch-android | core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java | Searcher.removeNumericRefinement | @SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher removeNumericRefinement(@NonNull String attribute) {
return removeNumericRefinement(new NumericRefinement(attribute, NumericRefinement.OPERATOR_UNKNOWN, NumericRefinement.VALUE_UNKNOWN));
} | java | @SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher removeNumericRefinement(@NonNull String attribute) {
return removeNumericRefinement(new NumericRefinement(attribute, NumericRefinement.OPERATOR_UNKNOWN, NumericRefinement.VALUE_UNKNOWN));
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"Searcher",
"removeNumericRefinement",
"(",
"@",
"NonNull",
"String",
"attribute",
")",
"{",
"return",
"removeNumericRefinement",
"(",
"new",
"Numeric... | Removes any numeric refinements relative to a specific attribute for the next queries.
@param attribute the attribute that may have a refinement.
@return this {@link Searcher} for chaining. | [
"Removes",
"any",
"numeric",
"refinements",
"relative",
"to",
"a",
"specific",
"attribute",
"for",
"the",
"next",
"queries",
"."
] | train | https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java#L718-L721 |
acromusashi/acromusashi-stream | src/main/java/acromusashi/stream/resource/ResourceResolver.java | ResourceResolver.readResource | public static String readResource(Class<?> clazz, String path)
{
File targetFile = resolve(clazz, path);
if (targetFile == null)
{
return null;
}
String result;
try
{
result = FileUtils.readFileToString(targetFile, "UTF-8");
}
catch (IOException ex)
{
return null;
}
return result;
} | java | public static String readResource(Class<?> clazz, String path)
{
File targetFile = resolve(clazz, path);
if (targetFile == null)
{
return null;
}
String result;
try
{
result = FileUtils.readFileToString(targetFile, "UTF-8");
}
catch (IOException ex)
{
return null;
}
return result;
} | [
"public",
"static",
"String",
"readResource",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"path",
")",
"{",
"File",
"targetFile",
"=",
"resolve",
"(",
"clazz",
",",
"path",
")",
";",
"if",
"(",
"targetFile",
"==",
"null",
")",
"{",
"return",
... | Return target file's content from class and resource's path.<br>
@param clazz Target class
@param path resource's path
@return read result | [
"Return",
"target",
"file",
"s",
"content",
"from",
"class",
"and",
"resource",
"s",
"path",
".",
"<br",
">"
] | train | https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/resource/ResourceResolver.java#L119-L139 |
jcuda/jcusparse | JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java | JCusparse.cusparseXcoo2csr | public static int cusparseXcoo2csr(
cusparseHandle handle,
Pointer cooRowInd,
int nnz,
int m,
Pointer csrSortedRowPtr,
int idxBase)
{
return checkResult(cusparseXcoo2csrNative(handle, cooRowInd, nnz, m, csrSortedRowPtr, idxBase));
} | java | public static int cusparseXcoo2csr(
cusparseHandle handle,
Pointer cooRowInd,
int nnz,
int m,
Pointer csrSortedRowPtr,
int idxBase)
{
return checkResult(cusparseXcoo2csrNative(handle, cooRowInd, nnz, m, csrSortedRowPtr, idxBase));
} | [
"public",
"static",
"int",
"cusparseXcoo2csr",
"(",
"cusparseHandle",
"handle",
",",
"Pointer",
"cooRowInd",
",",
"int",
"nnz",
",",
"int",
"m",
",",
"Pointer",
"csrSortedRowPtr",
",",
"int",
"idxBase",
")",
"{",
"return",
"checkResult",
"(",
"cusparseXcoo2csrNa... | Description: This routine compresses the indecis of rows or columns.
It can be interpreted as a conversion from COO to CSR sparse storage
format. | [
"Description",
":",
"This",
"routine",
"compresses",
"the",
"indecis",
"of",
"rows",
"or",
"columns",
".",
"It",
"can",
"be",
"interpreted",
"as",
"a",
"conversion",
"from",
"COO",
"to",
"CSR",
"sparse",
"storage",
"format",
"."
] | train | https://github.com/jcuda/jcusparse/blob/7687a62a4ef6b76cb91cf7da93d4cf5ade96a791/JCusparseJava/src/main/java/jcuda/jcusparse/JCusparse.java#L11600-L11609 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/renderer/font/MalisisFont.java | MalisisFont.getCharPosition | public float getCharPosition(String str, FontOptions options, int position, int charOffset)
{
if (StringUtils.isEmpty(str))
return 0;
str = processString(str, options);
//float fx = position / (fro != null ? fro.fontScale : 1); //factor the position instead of the char widths
StringWalker walker = new StringWalker(str, options);
//walker.startIndex(charOffset);
walker.skipChars(true);
return 0;//walker.walkToCoord(position);
} | java | public float getCharPosition(String str, FontOptions options, int position, int charOffset)
{
if (StringUtils.isEmpty(str))
return 0;
str = processString(str, options);
//float fx = position / (fro != null ? fro.fontScale : 1); //factor the position instead of the char widths
StringWalker walker = new StringWalker(str, options);
//walker.startIndex(charOffset);
walker.skipChars(true);
return 0;//walker.walkToCoord(position);
} | [
"public",
"float",
"getCharPosition",
"(",
"String",
"str",
",",
"FontOptions",
"options",
",",
"int",
"position",
",",
"int",
"charOffset",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"str",
")",
")",
"return",
"0",
";",
"str",
"=",
"proces... | Determines the character for a given X coordinate.
@param str the str
@param options the options
@param position the position
@param charOffset the char offset
@return position | [
"Determines",
"the",
"character",
"for",
"a",
"given",
"X",
"coordinate",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/font/MalisisFont.java#L554-L566 |
soarcn/COCOQuery | query/src/main/java/com/cocosw/query/AbstractViewQuery.java | AbstractViewQuery.animate | public T animate(int animId, Animation.AnimationListener listener) {
Animation anim = AnimationUtils.loadAnimation(context, animId);
anim.setAnimationListener(listener);
return animate(anim);
} | java | public T animate(int animId, Animation.AnimationListener listener) {
Animation anim = AnimationUtils.loadAnimation(context, animId);
anim.setAnimationListener(listener);
return animate(anim);
} | [
"public",
"T",
"animate",
"(",
"int",
"animId",
",",
"Animation",
".",
"AnimationListener",
"listener",
")",
"{",
"Animation",
"anim",
"=",
"AnimationUtils",
".",
"loadAnimation",
"(",
"context",
",",
"animId",
")",
";",
"anim",
".",
"setAnimationListener",
"(... | Starts an animation on the view.
<p/>
<br>
contributed by: marcosbeirigo
@param animId Id of the desired animation.
@param listener The listener to recieve notifications from the animation on its events.
@return self | [
"Starts",
"an",
"animation",
"on",
"the",
"view",
".",
"<p",
"/",
">",
"<br",
">",
"contributed",
"by",
":",
"marcosbeirigo"
] | train | https://github.com/soarcn/COCOQuery/blob/712eac37ab65ef3dbdf55dbfae28750edfc36608/query/src/main/java/com/cocosw/query/AbstractViewQuery.java#L884-L888 |
beanshell/beanshell | src/main/java/bsh/ClassGenerator.java | ClassGenerator.invokeSuperclassMethod | public Object invokeSuperclassMethod(BshClassManager bcm, Object instance, String methodName, Object[] args) throws UtilEvalError, ReflectError, InvocationTargetException {
// Delegate to the static method
return invokeSuperclassMethodImpl(bcm, instance, methodName, args);
} | java | public Object invokeSuperclassMethod(BshClassManager bcm, Object instance, String methodName, Object[] args) throws UtilEvalError, ReflectError, InvocationTargetException {
// Delegate to the static method
return invokeSuperclassMethodImpl(bcm, instance, methodName, args);
} | [
"public",
"Object",
"invokeSuperclassMethod",
"(",
"BshClassManager",
"bcm",
",",
"Object",
"instance",
",",
"String",
"methodName",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"UtilEvalError",
",",
"ReflectError",
",",
"InvocationTargetException",
"{",
"// Dele... | Invoke a super.method() style superclass method on an object instance.
This is not a normal function of the Java reflection API and is
provided by generated class accessor methods. | [
"Invoke",
"a",
"super",
".",
"method",
"()",
"style",
"superclass",
"method",
"on",
"an",
"object",
"instance",
".",
"This",
"is",
"not",
"a",
"normal",
"function",
"of",
"the",
"Java",
"reflection",
"API",
"and",
"is",
"provided",
"by",
"generated",
"clas... | train | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/ClassGenerator.java#L63-L66 |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java | MemorizeTransactionProxy.memorize | protected static Connection memorize(final Connection target, final ConnectionHandle connectionHandle) {
return (Connection) Proxy.newProxyInstance(
ConnectionProxy.class.getClassLoader(),
new Class[] {ConnectionProxy.class},
new MemorizeTransactionProxy(target, connectionHandle));
} | java | protected static Connection memorize(final Connection target, final ConnectionHandle connectionHandle) {
return (Connection) Proxy.newProxyInstance(
ConnectionProxy.class.getClassLoader(),
new Class[] {ConnectionProxy.class},
new MemorizeTransactionProxy(target, connectionHandle));
} | [
"protected",
"static",
"Connection",
"memorize",
"(",
"final",
"Connection",
"target",
",",
"final",
"ConnectionHandle",
"connectionHandle",
")",
"{",
"return",
"(",
"Connection",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"ConnectionProxy",
".",
"class",
".",
"g... | Wrap connection with a proxy.
@param target connection handle
@param connectionHandle originating bonecp connection
@return Proxy to a connection. | [
"Wrap",
"connection",
"with",
"a",
"proxy",
"."
] | train | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java#L79-L85 |
aws/aws-sdk-java | aws-java-sdk-cloudwatchmetrics/src/main/java/com/amazonaws/metrics/internal/cloudwatch/MachineMetricFactory.java | MachineMetricFactory.fdMetricValues | private MetricValues fdMetricValues(Set<MachineMetric> customSet,
List<Long> values) {
return metricValues(customSet, MachineMetricFactory.fdMetrics, values);
} | java | private MetricValues fdMetricValues(Set<MachineMetric> customSet,
List<Long> values) {
return metricValues(customSet, MachineMetricFactory.fdMetrics, values);
} | [
"private",
"MetricValues",
"fdMetricValues",
"(",
"Set",
"<",
"MachineMetric",
">",
"customSet",
",",
"List",
"<",
"Long",
">",
"values",
")",
"{",
"return",
"metricValues",
"(",
"customSet",
",",
"MachineMetricFactory",
".",
"fdMetrics",
",",
"values",
")",
"... | Returns the set of file-descriptor metrics and the corresponding values based on
the default and the customized set of metrics, if any.
@param customSet
a non-null customized set of metrics
@param values
a non-null list of values corresponding to the list of default
file-descriptor metrics | [
"Returns",
"the",
"set",
"of",
"file",
"-",
"descriptor",
"metrics",
"and",
"the",
"corresponding",
"values",
"based",
"on",
"the",
"default",
"and",
"the",
"customized",
"set",
"of",
"metrics",
"if",
"any",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cloudwatchmetrics/src/main/java/com/amazonaws/metrics/internal/cloudwatch/MachineMetricFactory.java#L231-L234 |
jbundle/jbundle | base/screen/model/src/main/java/org/jbundle/base/screen/model/MenuScreen.java | MenuScreen.setProperty | public void setProperty(String strProperty, String strValue)
{
if (DBParams.MENU.equalsIgnoreCase(strProperty))
this.setMenuProperty(strValue); // Special case
else
super.setProperty(strProperty, strValue);
} | java | public void setProperty(String strProperty, String strValue)
{
if (DBParams.MENU.equalsIgnoreCase(strProperty))
this.setMenuProperty(strValue); // Special case
else
super.setProperty(strProperty, strValue);
} | [
"public",
"void",
"setProperty",
"(",
"String",
"strProperty",
",",
"String",
"strValue",
")",
"{",
"if",
"(",
"DBParams",
".",
"MENU",
".",
"equalsIgnoreCase",
"(",
"strProperty",
")",
")",
"this",
".",
"setMenuProperty",
"(",
"strValue",
")",
";",
"// Spec... | Set this property.
@param strProperty The property key.
@param strValue The property value. | [
"Set",
"this",
"property",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/MenuScreen.java#L122-L128 |
qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/ResultSetXMLConverter.java | ResultSetXMLConverter.getResultSetAsXML | public static Document getResultSetAsXML(ResultSet rs, String tableName) throws Exception {
return getResultSetAsXML(rs, tableName, "");
} | java | public static Document getResultSetAsXML(ResultSet rs, String tableName) throws Exception {
return getResultSetAsXML(rs, tableName, "");
} | [
"public",
"static",
"Document",
"getResultSetAsXML",
"(",
"ResultSet",
"rs",
",",
"String",
"tableName",
")",
"throws",
"Exception",
"{",
"return",
"getResultSetAsXML",
"(",
"rs",
",",
"tableName",
",",
"\"\"",
")",
";",
"}"
] | Return an XML document containing the specified ResultSet.
@param rs The specified ResultSet
@return the XML document
@throws java.lang.Exception | [
"Return",
"an",
"XML",
"document",
"containing",
"the",
"specified",
"ResultSet",
"."
] | train | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/ResultSetXMLConverter.java#L156-L158 |
apache/flink | flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java | FieldParser.delimiterNext | public static final boolean delimiterNext(byte[] bytes, int startPos, byte[] delim) {
for(int pos = 0; pos < delim.length; pos++) {
// check each position
if(delim[pos] != bytes[startPos+pos]) {
return false;
}
}
return true;
} | java | public static final boolean delimiterNext(byte[] bytes, int startPos, byte[] delim) {
for(int pos = 0; pos < delim.length; pos++) {
// check each position
if(delim[pos] != bytes[startPos+pos]) {
return false;
}
}
return true;
} | [
"public",
"static",
"final",
"boolean",
"delimiterNext",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"startPos",
",",
"byte",
"[",
"]",
"delim",
")",
"{",
"for",
"(",
"int",
"pos",
"=",
"0",
";",
"pos",
"<",
"delim",
".",
"length",
";",
"pos",
"++"... | Checks if the delimiter starts at the given start position of the byte array.
Attention: This method assumes that enough characters follow the start position for the delimiter check!
@param bytes The byte array that holds the value.
@param startPos The index of the byte array where the check for the delimiter starts.
@param delim The delimiter to check for.
@return true if a delimiter starts at the given start position, false otherwise. | [
"Checks",
"if",
"the",
"delimiter",
"starts",
"at",
"the",
"given",
"start",
"position",
"of",
"the",
"byte",
"array",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java#L148-L158 |
igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.notifyOmemoMessageReceived | void notifyOmemoMessageReceived(Stanza stanza, OmemoMessage.Received decryptedMessage) {
for (OmemoMessageListener l : omemoMessageListeners) {
l.onOmemoMessageReceived(stanza, decryptedMessage);
}
} | java | void notifyOmemoMessageReceived(Stanza stanza, OmemoMessage.Received decryptedMessage) {
for (OmemoMessageListener l : omemoMessageListeners) {
l.onOmemoMessageReceived(stanza, decryptedMessage);
}
} | [
"void",
"notifyOmemoMessageReceived",
"(",
"Stanza",
"stanza",
",",
"OmemoMessage",
".",
"Received",
"decryptedMessage",
")",
"{",
"for",
"(",
"OmemoMessageListener",
"l",
":",
"omemoMessageListeners",
")",
"{",
"l",
".",
"onOmemoMessageReceived",
"(",
"stanza",
","... | Notify all registered OmemoMessageListeners about a received OmemoMessage.
@param stanza original stanza
@param decryptedMessage decrypted OmemoMessage. | [
"Notify",
"all",
"registered",
"OmemoMessageListeners",
"about",
"a",
"received",
"OmemoMessage",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L834-L838 |
victims/victims-lib-java | src/main/java/com/redhat/victims/database/VictimsSQL.java | VictimsSQL.constructInStringsQuery | protected String constructInStringsQuery(String query, Set<String> values) {
String replace = "IN (?)";
assert query.lastIndexOf(replace) == query.indexOf(replace);
String sql = query.replace("IN (?)", "IN (%s)");
StringBuffer list = new StringBuffer();
for (String value : values) {
if (list.length() > 0) {
list.append(",");
}
value = String.format("'%s'", StringEscapeUtils.escapeSql(value));
list.append(value);
}
return String.format(sql, list.toString());
} | java | protected String constructInStringsQuery(String query, Set<String> values) {
String replace = "IN (?)";
assert query.lastIndexOf(replace) == query.indexOf(replace);
String sql = query.replace("IN (?)", "IN (%s)");
StringBuffer list = new StringBuffer();
for (String value : values) {
if (list.length() > 0) {
list.append(",");
}
value = String.format("'%s'", StringEscapeUtils.escapeSql(value));
list.append(value);
}
return String.format(sql, list.toString());
} | [
"protected",
"String",
"constructInStringsQuery",
"(",
"String",
"query",
",",
"Set",
"<",
"String",
">",
"values",
")",
"{",
"String",
"replace",
"=",
"\"IN (?)\"",
";",
"assert",
"query",
".",
"lastIndexOf",
"(",
"replace",
")",
"==",
"query",
".",
"indexO... | Given a an sql query containing the string "IN (?)" and a set of strings,
this method constructs a query by safely replacing the first occurence of
"IN (?)" with "IN ('v1','v2'...)", where v1,v2,.. are in values.
@param query
@param values
@return | [
"Given",
"a",
"an",
"sql",
"query",
"containing",
"the",
"string",
"IN",
"(",
"?",
")",
"and",
"a",
"set",
"of",
"strings",
"this",
"method",
"constructs",
"a",
"query",
"by",
"safely",
"replacing",
"the",
"first",
"occurence",
"of",
"IN",
"(",
"?",
")... | train | https://github.com/victims/victims-lib-java/blob/ccd0e2fcc409bb6cdfc5de411c3bb202c9095f8b/src/main/java/com/redhat/victims/database/VictimsSQL.java#L177-L192 |
UrielCh/ovh-java-sdk | ovh-java-sdk-msServices/src/main/java/net/minidev/ovh/api/ApiOvhMsServices.java | ApiOvhMsServices.serviceName_account_userPrincipalName_PUT | public void serviceName_account_userPrincipalName_PUT(String serviceName, String userPrincipalName, OvhAccount body) throws IOException {
String qPath = "/msServices/{serviceName}/account/{userPrincipalName}";
StringBuilder sb = path(qPath, serviceName, userPrincipalName);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_account_userPrincipalName_PUT(String serviceName, String userPrincipalName, OvhAccount body) throws IOException {
String qPath = "/msServices/{serviceName}/account/{userPrincipalName}";
StringBuilder sb = path(qPath, serviceName, userPrincipalName);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_account_userPrincipalName_PUT",
"(",
"String",
"serviceName",
",",
"String",
"userPrincipalName",
",",
"OvhAccount",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/msServices/{serviceName}/account/{userPrincipalName}\"",
... | Alter this object properties
REST: PUT /msServices/{serviceName}/account/{userPrincipalName}
@param body [required] New object properties
@param serviceName [required] The internal name of your Active Directory organization
@param userPrincipalName [required] User Principal Name
API beta | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-msServices/src/main/java/net/minidev/ovh/api/ApiOvhMsServices.java#L451-L455 |
wcm-io-caravan/caravan-hal | docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java | GenerateHalDocsJsonMojo.buildJsonSchemaRefForModel | private String buildJsonSchemaRefForModel(Class<?> modelClass, File artifactFile) {
try {
ZipFile zipFile = new ZipFile(artifactFile);
String halDocsDomainPath = getHalDocsDomainPath(zipFile);
if (halDocsDomainPath != null && hasJsonSchemaFile(zipFile, modelClass)) {
return JsonSchemaBundleTracker.SCHEMA_URI_PREFIX + halDocsDomainPath
+ "/" + modelClass.getName() + ".json";
}
return null;
}
catch (IOException ex) {
throw new RuntimeException("Unable to read artifact file: " + artifactFile.getAbsolutePath() + "\n" + ex.getMessage(), ex);
}
} | java | private String buildJsonSchemaRefForModel(Class<?> modelClass, File artifactFile) {
try {
ZipFile zipFile = new ZipFile(artifactFile);
String halDocsDomainPath = getHalDocsDomainPath(zipFile);
if (halDocsDomainPath != null && hasJsonSchemaFile(zipFile, modelClass)) {
return JsonSchemaBundleTracker.SCHEMA_URI_PREFIX + halDocsDomainPath
+ "/" + modelClass.getName() + ".json";
}
return null;
}
catch (IOException ex) {
throw new RuntimeException("Unable to read artifact file: " + artifactFile.getAbsolutePath() + "\n" + ex.getMessage(), ex);
}
} | [
"private",
"String",
"buildJsonSchemaRefForModel",
"(",
"Class",
"<",
"?",
">",
"modelClass",
",",
"File",
"artifactFile",
")",
"{",
"try",
"{",
"ZipFile",
"zipFile",
"=",
"new",
"ZipFile",
"(",
"artifactFile",
")",
";",
"String",
"halDocsDomainPath",
"=",
"ge... | Check if JAR file has a doc domain path and corresponding schema file and then builds a documenation path for it.
@param modelClass Model calss
@param artifactFile JAR artifact's file
@return JSON schema path or null | [
"Check",
"if",
"JAR",
"file",
"has",
"a",
"doc",
"domain",
"path",
"and",
"corresponding",
"schema",
"file",
"and",
"then",
"builds",
"a",
"documenation",
"path",
"for",
"it",
"."
] | train | https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java#L266-L279 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/collidable/CollidableUpdater.java | CollidableUpdater.getOffsetY | private static int getOffsetY(Collision collision, Mirror mirror)
{
if (mirror == Mirror.VERTICAL)
{
return -collision.getOffsetY();
}
return collision.getOffsetY();
} | java | private static int getOffsetY(Collision collision, Mirror mirror)
{
if (mirror == Mirror.VERTICAL)
{
return -collision.getOffsetY();
}
return collision.getOffsetY();
} | [
"private",
"static",
"int",
"getOffsetY",
"(",
"Collision",
"collision",
",",
"Mirror",
"mirror",
")",
"{",
"if",
"(",
"mirror",
"==",
"Mirror",
".",
"VERTICAL",
")",
"{",
"return",
"-",
"collision",
".",
"getOffsetY",
"(",
")",
";",
"}",
"return",
"coll... | Get the vertical offset.
@param collision The collision reference.
@param mirror The mirror used.
@return The offset value depending of mirror. | [
"Get",
"the",
"vertical",
"offset",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/collidable/CollidableUpdater.java#L156-L163 |
alkacon/opencms-core | src/org/opencms/ade/configuration/formatters/CmsFormatterConfigurationCache.java | CmsFormatterConfigurationCache.parseSettingsConfig | private void parseSettingsConfig(CmsResource resource, Map<CmsUUID, List<CmsXmlContentProperty>> settingConfigs) {
List<CmsXmlContentProperty> settingConfig = new ArrayList<>();
try {
CmsFile settingFile = m_cms.readFile(resource);
CmsXmlContent settingContent = CmsXmlContentFactory.unmarshal(m_cms, settingFile);
CmsXmlContentRootLocation location = new CmsXmlContentRootLocation(settingContent, Locale.ENGLISH);
for (I_CmsXmlContentValueLocation settingLoc : location.getSubValues(CmsFormatterBeanParser.N_SETTING)) {
CmsXmlContentProperty setting = CmsConfigurationReader.parseProperty(
m_cms,
settingLoc).getPropertyData();
settingConfig.add(setting);
}
settingConfigs.put(resource.getStructureId(), settingConfig);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
}
} | java | private void parseSettingsConfig(CmsResource resource, Map<CmsUUID, List<CmsXmlContentProperty>> settingConfigs) {
List<CmsXmlContentProperty> settingConfig = new ArrayList<>();
try {
CmsFile settingFile = m_cms.readFile(resource);
CmsXmlContent settingContent = CmsXmlContentFactory.unmarshal(m_cms, settingFile);
CmsXmlContentRootLocation location = new CmsXmlContentRootLocation(settingContent, Locale.ENGLISH);
for (I_CmsXmlContentValueLocation settingLoc : location.getSubValues(CmsFormatterBeanParser.N_SETTING)) {
CmsXmlContentProperty setting = CmsConfigurationReader.parseProperty(
m_cms,
settingLoc).getPropertyData();
settingConfig.add(setting);
}
settingConfigs.put(resource.getStructureId(), settingConfig);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
}
} | [
"private",
"void",
"parseSettingsConfig",
"(",
"CmsResource",
"resource",
",",
"Map",
"<",
"CmsUUID",
",",
"List",
"<",
"CmsXmlContentProperty",
">",
">",
"settingConfigs",
")",
"{",
"List",
"<",
"CmsXmlContentProperty",
">",
"settingConfig",
"=",
"new",
"ArrayLis... | Helper method for parsing a settings configuration file.<p>
@param resource the resource to parse
@param settingConfigs the map in which the result should be stored, with the structure id of the resource as the key | [
"Helper",
"method",
"for",
"parsing",
"a",
"settings",
"configuration",
"file",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/formatters/CmsFormatterConfigurationCache.java#L407-L425 |
headius/invokebinder | src/main/java/com/headius/invokebinder/transform/Transform.java | Transform.buildPrimitiveJava | protected static void buildPrimitiveJava(StringBuilder builder, Object value) {
builder.append(value.toString());
if (value.getClass() == Float.class) builder.append('F');
if (value.getClass() == Long.class) builder.append('L');
} | java | protected static void buildPrimitiveJava(StringBuilder builder, Object value) {
builder.append(value.toString());
if (value.getClass() == Float.class) builder.append('F');
if (value.getClass() == Long.class) builder.append('L');
} | [
"protected",
"static",
"void",
"buildPrimitiveJava",
"(",
"StringBuilder",
"builder",
",",
"Object",
"value",
")",
"{",
"builder",
".",
"append",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"value",
".",
"getClass",
"(",
")",
"==",
"Flo... | Build Java code to represent a literal primitive.
This will append L or F as appropriate for long and float primitives.
@param builder the builder in which to generate the code
@param value the primitive value to generate from | [
"Build",
"Java",
"code",
"to",
"represent",
"a",
"literal",
"primitive",
"."
] | train | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/transform/Transform.java#L109-L113 |
VoltDB/voltdb | src/frontend/org/voltdb/PostgreSQLBackend.java | PostgreSQLBackend.runDML | protected VoltTable runDML(String dml, boolean transformDml) {
String modifiedDml = (transformDml ? transformDML(dml) : dml);
printTransformedSql(dml, modifiedDml);
return super.runDML(modifiedDml);
} | java | protected VoltTable runDML(String dml, boolean transformDml) {
String modifiedDml = (transformDml ? transformDML(dml) : dml);
printTransformedSql(dml, modifiedDml);
return super.runDML(modifiedDml);
} | [
"protected",
"VoltTable",
"runDML",
"(",
"String",
"dml",
",",
"boolean",
"transformDml",
")",
"{",
"String",
"modifiedDml",
"=",
"(",
"transformDml",
"?",
"transformDML",
"(",
"dml",
")",
":",
"dml",
")",
";",
"printTransformedSql",
"(",
"dml",
",",
"modifi... | Optionally, modifies queries in such a way that PostgreSQL results will
match VoltDB results; and then passes the remaining work to the base
class version. | [
"Optionally",
"modifies",
"queries",
"in",
"such",
"a",
"way",
"that",
"PostgreSQL",
"results",
"will",
"match",
"VoltDB",
"results",
";",
"and",
"then",
"passes",
"the",
"remaining",
"work",
"to",
"the",
"base",
"class",
"version",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/PostgreSQLBackend.java#L1066-L1070 |
mbenson/uelbox | src/main/java/uelbox/IterableELResolver.java | IterableELResolver.getValue | @Override
public Object getValue(ELContext context, Object base, Object property) throws NullPointerException,
PropertyNotFoundException, ELException {
Iterator<?> pos;
try {
pos = seek(context, base, property);
} catch(PropertyNotFoundException e) {
pos = null;
}
return pos == null ? null : pos.next();
} | java | @Override
public Object getValue(ELContext context, Object base, Object property) throws NullPointerException,
PropertyNotFoundException, ELException {
Iterator<?> pos;
try {
pos = seek(context, base, property);
} catch(PropertyNotFoundException e) {
pos = null;
}
return pos == null ? null : pos.next();
} | [
"@",
"Override",
"public",
"Object",
"getValue",
"(",
"ELContext",
"context",
",",
"Object",
"base",
",",
"Object",
"property",
")",
"throws",
"NullPointerException",
",",
"PropertyNotFoundException",
",",
"ELException",
"{",
"Iterator",
"<",
"?",
">",
"pos",
";... | Like {@link ListELResolver}, returns {@code null} for an illegal index. | [
"Like",
"{"
] | train | https://github.com/mbenson/uelbox/blob/b0c2df2c738295bddfd3c16a916e67c9c7c512ef/src/main/java/uelbox/IterableELResolver.java#L53-L64 |
joniles/mpxj | src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java | FastTrackUtility.getLong | public static final long getLong(byte[] data, int offset)
{
if (data.length != 8)
{
throw new UnexpectedStructureException();
}
long result = 0;
int i = offset;
for (int shiftBy = 0; shiftBy < 64; shiftBy += 8)
{
result |= ((long) (data[i] & 0xff)) << shiftBy;
++i;
}
return result;
} | java | public static final long getLong(byte[] data, int offset)
{
if (data.length != 8)
{
throw new UnexpectedStructureException();
}
long result = 0;
int i = offset;
for (int shiftBy = 0; shiftBy < 64; shiftBy += 8)
{
result |= ((long) (data[i] & 0xff)) << shiftBy;
++i;
}
return result;
} | [
"public",
"static",
"final",
"long",
"getLong",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"{",
"if",
"(",
"data",
".",
"length",
"!=",
"8",
")",
"{",
"throw",
"new",
"UnexpectedStructureException",
"(",
")",
";",
"}",
"long",
"result",
... | This method reads an eight byte integer from the input array.
@param data the input array
@param offset offset of integer data in the array
@return integer value | [
"This",
"method",
"reads",
"an",
"eight",
"byte",
"integer",
"from",
"the",
"input",
"array",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java#L107-L122 |
classgraph/classgraph | src/main/java/nonapi/io/github/classgraph/types/Parser.java | Parser.peekExpect | public void peekExpect(final char expectedChar) throws ParseException {
if (position == string.length()) {
throw new ParseException(this, "Expected '" + expectedChar + "'; reached end of string");
}
final char next = string.charAt(position);
if (next != expectedChar) {
throw new ParseException(this, "Expected '" + expectedChar + "'; got '" + next + "'");
}
} | java | public void peekExpect(final char expectedChar) throws ParseException {
if (position == string.length()) {
throw new ParseException(this, "Expected '" + expectedChar + "'; reached end of string");
}
final char next = string.charAt(position);
if (next != expectedChar) {
throw new ParseException(this, "Expected '" + expectedChar + "'; got '" + next + "'");
}
} | [
"public",
"void",
"peekExpect",
"(",
"final",
"char",
"expectedChar",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"position",
"==",
"string",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"this",
",",
"\"Expected '\"",
"+",
... | Get the next character, throwing a {@link ParseException} if the next character is not the expected
character.
@param expectedChar
The expected next character.
@throws ParseException
If the next character is not the expected next character. | [
"Get",
"the",
"next",
"character",
"throwing",
"a",
"{",
"@link",
"ParseException",
"}",
"if",
"the",
"next",
"character",
"is",
"not",
"the",
"expected",
"character",
"."
] | train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/types/Parser.java#L152-L160 |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/FilterUtils.java | FilterUtils.getLabelValue | private String getLabelValue(final QName propName, final String attrPropsValue) {
if (attrPropsValue != null) {
int propStart = -1;
if (attrPropsValue.startsWith(propName + "(") || attrPropsValue.contains(" " + propName + "(")) {
propStart = attrPropsValue.indexOf(propName + "(");
}
if (propStart != -1) {
propStart = propStart + propName.toString().length() + 1;
}
final int propEnd = attrPropsValue.indexOf(")", propStart);
if (propStart != -1 && propEnd != -1) {
return attrPropsValue.substring(propStart, propEnd).trim();
}
}
return null;
} | java | private String getLabelValue(final QName propName, final String attrPropsValue) {
if (attrPropsValue != null) {
int propStart = -1;
if (attrPropsValue.startsWith(propName + "(") || attrPropsValue.contains(" " + propName + "(")) {
propStart = attrPropsValue.indexOf(propName + "(");
}
if (propStart != -1) {
propStart = propStart + propName.toString().length() + 1;
}
final int propEnd = attrPropsValue.indexOf(")", propStart);
if (propStart != -1 && propEnd != -1) {
return attrPropsValue.substring(propStart, propEnd).trim();
}
}
return null;
} | [
"private",
"String",
"getLabelValue",
"(",
"final",
"QName",
"propName",
",",
"final",
"String",
"attrPropsValue",
")",
"{",
"if",
"(",
"attrPropsValue",
"!=",
"null",
")",
"{",
"int",
"propStart",
"=",
"-",
"1",
";",
"if",
"(",
"attrPropsValue",
".",
"sta... | Get labelled props value.
@param propName attribute name
@param attrPropsValue attribute value
@return props value, {@code null} if not available | [
"Get",
"labelled",
"props",
"value",
"."
] | train | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/FilterUtils.java#L373-L388 |
voldemort/voldemort | src/java/voldemort/utils/ByteUtils.java | ByteUtils.writeShort | public static void writeShort(byte[] bytes, short value, int offset) {
bytes[offset] = (byte) (0xFF & (value >> 8));
bytes[offset + 1] = (byte) (0xFF & value);
} | java | public static void writeShort(byte[] bytes, short value, int offset) {
bytes[offset] = (byte) (0xFF & (value >> 8));
bytes[offset + 1] = (byte) (0xFF & value);
} | [
"public",
"static",
"void",
"writeShort",
"(",
"byte",
"[",
"]",
"bytes",
",",
"short",
"value",
",",
"int",
"offset",
")",
"{",
"bytes",
"[",
"offset",
"]",
"=",
"(",
"byte",
")",
"(",
"0xFF",
"&",
"(",
"value",
">>",
"8",
")",
")",
";",
"bytes"... | Write a short to the byte array starting at the given offset
@param bytes The byte array
@param value The short to write
@param offset The offset to begin writing at | [
"Write",
"a",
"short",
"to",
"the",
"byte",
"array",
"starting",
"at",
"the",
"given",
"offset"
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/ByteUtils.java#L238-L241 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java | ComputeNodesImpl.reboot | public void reboot(String poolId, String nodeId) {
rebootWithServiceResponseAsync(poolId, nodeId).toBlocking().single().body();
} | java | public void reboot(String poolId, String nodeId) {
rebootWithServiceResponseAsync(poolId, nodeId).toBlocking().single().body();
} | [
"public",
"void",
"reboot",
"(",
"String",
"poolId",
",",
"String",
"nodeId",
")",
"{",
"rebootWithServiceResponseAsync",
"(",
"poolId",
",",
"nodeId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Restarts the specified compute node.
You can restart a node only if it is in an idle or running state.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node that you want to restart.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws BatchErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Restarts",
"the",
"specified",
"compute",
"node",
".",
"You",
"can",
"restart",
"a",
"node",
"only",
"if",
"it",
"is",
"in",
"an",
"idle",
"or",
"running",
"state",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java#L1064-L1066 |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsFormatterConfiguration.java | CmsFormatterConfiguration.getDefaultFormatter | public I_CmsFormatterBean getDefaultFormatter(final String containerTypes, final int containerWidth) {
Optional<I_CmsFormatterBean> result = Iterables.tryFind(
m_allFormatters,
new MatchesTypeOrWidth(containerTypes, containerWidth));
return result.orNull();
} | java | public I_CmsFormatterBean getDefaultFormatter(final String containerTypes, final int containerWidth) {
Optional<I_CmsFormatterBean> result = Iterables.tryFind(
m_allFormatters,
new MatchesTypeOrWidth(containerTypes, containerWidth));
return result.orNull();
} | [
"public",
"I_CmsFormatterBean",
"getDefaultFormatter",
"(",
"final",
"String",
"containerTypes",
",",
"final",
"int",
"containerWidth",
")",
"{",
"Optional",
"<",
"I_CmsFormatterBean",
">",
"result",
"=",
"Iterables",
".",
"tryFind",
"(",
"m_allFormatters",
",",
"ne... | Selects the best matching formatter for the provided type and width from this configuration.<p>
This method first tries to find the formatter for the provided container type.
If this fails, it returns the width based formatter that matched the container width.<p>
@param containerTypes the container types (comma separated)
@param containerWidth the container width
@return the matching formatter, or <code>null</code> if none was found | [
"Selects",
"the",
"best",
"matching",
"formatter",
"for",
"the",
"provided",
"type",
"and",
"width",
"from",
"this",
"configuration",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsFormatterConfiguration.java#L298-L304 |
unbescape/unbescape | src/main/java/org/unbescape/xml/XmlEscape.java | XmlEscape.escapeXml10Attribute | public static String escapeXml10Attribute(final String text, final XmlEscapeType type, final XmlEscapeLevel level) {
return escapeXml(text, XmlEscapeSymbols.XML10_ATTRIBUTE_SYMBOLS, type, level);
} | java | public static String escapeXml10Attribute(final String text, final XmlEscapeType type, final XmlEscapeLevel level) {
return escapeXml(text, XmlEscapeSymbols.XML10_ATTRIBUTE_SYMBOLS, type, level);
} | [
"public",
"static",
"String",
"escapeXml10Attribute",
"(",
"final",
"String",
"text",
",",
"final",
"XmlEscapeType",
"type",
",",
"final",
"XmlEscapeLevel",
"level",
")",
"{",
"return",
"escapeXml",
"(",
"text",
",",
"XmlEscapeSymbols",
".",
"XML10_ATTRIBUTE_SYMBOLS... | <p>
Perform a (configurable) XML 1.0 <strong>escape</strong> operation on a <tt>String</tt> input
meant to be an XML attribute value.
</p>
<p>
This method will perform an escape operation according to the specified
{@link org.unbescape.xml.XmlEscapeType} and {@link org.unbescape.xml.XmlEscapeLevel}
argument values.
</p>
<p>
Besides, being an attribute value also <tt>\t</tt>, <tt>\n</tt> and <tt>\r</tt> will
be escaped to avoid white-space normalization from removing line feeds (turning them into white
spaces) during future parsing operations.
</p>
<p>
All other <tt>String</tt>-based <tt>escapeXml10*(...)</tt> methods call this one with preconfigured
<tt>type</tt> and <tt>level</tt> values.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>String</tt> to be escaped.
@param type the type of escape operation to be performed, see {@link org.unbescape.xml.XmlEscapeType}.
@param level the escape level to be applied, see {@link org.unbescape.xml.XmlEscapeLevel}.
@return The escaped result <tt>String</tt>. As a memory-performance improvement, will return the exact
same object as the <tt>text</tt> input argument if no escaping modifications were required (and
no additional <tt>String</tt> objects will be created during processing). Will
return <tt>null</tt> if input is <tt>null</tt>.
@since 1.1.5 | [
"<p",
">",
"Perform",
"a",
"(",
"configurable",
")",
"XML",
"1",
".",
"0",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"String<",
"/",
"tt",
">",
"input",
"meant",
"to",
"be",
"an",
"XML",
"attribute",
"value",
... | train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/xml/XmlEscape.java#L598-L600 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/rules/Rules.java | Rules.conditionsRule | public static Rule conditionsRule(final Set<Condition> conditions, String key, String value) {
HashMap<String, String> results = new HashMap<>();
results.put(key, value);
return conditionsRule(conditions, results);
} | java | public static Rule conditionsRule(final Set<Condition> conditions, String key, String value) {
HashMap<String, String> results = new HashMap<>();
results.put(key, value);
return conditionsRule(conditions, results);
} | [
"public",
"static",
"Rule",
"conditionsRule",
"(",
"final",
"Set",
"<",
"Condition",
">",
"conditions",
",",
"String",
"key",
",",
"String",
"value",
")",
"{",
"HashMap",
"<",
"String",
",",
"String",
">",
"results",
"=",
"new",
"HashMap",
"<>",
"(",
")"... | Create a rule: predicate(conditions) => new state(results)
@param conditions conditions
@param key key
@param value value
@return rule | [
"Create",
"a",
"rule",
":",
"predicate",
"(",
"conditions",
")",
"=",
">",
"new",
"state",
"(",
"results",
")"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/Rules.java#L126-L130 |
ironjacamar/ironjacamar | common/src/main/java/org/ironjacamar/common/metadata/common/AbstractParser.java | AbstractParser.storeExtension | protected void storeExtension(Extension e, XMLStreamWriter writer, String elementName) throws XMLStreamException
{
writer.writeStartElement(elementName);
writer.writeAttribute(CommonXML.ATTRIBUTE_CLASS_NAME,
e.getValue(CommonXML.ATTRIBUTE_CLASS_NAME,
e.getClassName()));
if (e.getModuleName() != null)
writer.writeAttribute(CommonXML.ATTRIBUTE_MODULE_NAME,
e.getValue(CommonXML.ATTRIBUTE_MODULE_NAME, e.getModuleName()));
if (e.getModuleSlot() != null)
writer.writeAttribute(CommonXML.ATTRIBUTE_MODULE_SLOT,
e.getValue(CommonXML.ATTRIBUTE_MODULE_SLOT, e.getModuleSlot()));
if (!e.getConfigPropertiesMap().isEmpty())
{
Iterator<Map.Entry<String, String>> it =
e.getConfigPropertiesMap().entrySet().iterator();
while (it.hasNext())
{
Map.Entry<String, String> entry = it.next();
writer.writeStartElement(CommonXML.ELEMENT_CONFIG_PROPERTY);
writer.writeAttribute(CommonXML.ATTRIBUTE_NAME, entry.getKey());
writer.writeCharacters(e.getValue(CommonXML.ELEMENT_CONFIG_PROPERTY,
entry.getKey(), entry.getValue()));
writer.writeEndElement();
}
}
writer.writeEndElement();
} | java | protected void storeExtension(Extension e, XMLStreamWriter writer, String elementName) throws XMLStreamException
{
writer.writeStartElement(elementName);
writer.writeAttribute(CommonXML.ATTRIBUTE_CLASS_NAME,
e.getValue(CommonXML.ATTRIBUTE_CLASS_NAME,
e.getClassName()));
if (e.getModuleName() != null)
writer.writeAttribute(CommonXML.ATTRIBUTE_MODULE_NAME,
e.getValue(CommonXML.ATTRIBUTE_MODULE_NAME, e.getModuleName()));
if (e.getModuleSlot() != null)
writer.writeAttribute(CommonXML.ATTRIBUTE_MODULE_SLOT,
e.getValue(CommonXML.ATTRIBUTE_MODULE_SLOT, e.getModuleSlot()));
if (!e.getConfigPropertiesMap().isEmpty())
{
Iterator<Map.Entry<String, String>> it =
e.getConfigPropertiesMap().entrySet().iterator();
while (it.hasNext())
{
Map.Entry<String, String> entry = it.next();
writer.writeStartElement(CommonXML.ELEMENT_CONFIG_PROPERTY);
writer.writeAttribute(CommonXML.ATTRIBUTE_NAME, entry.getKey());
writer.writeCharacters(e.getValue(CommonXML.ELEMENT_CONFIG_PROPERTY,
entry.getKey(), entry.getValue()));
writer.writeEndElement();
}
}
writer.writeEndElement();
} | [
"protected",
"void",
"storeExtension",
"(",
"Extension",
"e",
",",
"XMLStreamWriter",
"writer",
",",
"String",
"elementName",
")",
"throws",
"XMLStreamException",
"{",
"writer",
".",
"writeStartElement",
"(",
"elementName",
")",
";",
"writer",
".",
"writeAttribute",... | Store capacity
@param e The extension
@param writer The writer
@param elementName the element name
@exception XMLStreamException Thrown if an error occurs | [
"Store",
"capacity"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/common/src/main/java/org/ironjacamar/common/metadata/common/AbstractParser.java#L1056-L1087 |
kite-sdk/kite | kite-data/kite-data-core/src/main/java/org/kitesdk/data/ValidationException.java | ValidationException.check | public static void check(boolean isValid, String message, Object... args) {
if (!isValid) {
String[] argStrings = new String[args.length];
for (int i = 0; i < args.length; i += 1) {
argStrings[i] = String.valueOf(args[i]);
}
throw new ValidationException(
String.format(String.valueOf(message), (Object[]) argStrings));
}
} | java | public static void check(boolean isValid, String message, Object... args) {
if (!isValid) {
String[] argStrings = new String[args.length];
for (int i = 0; i < args.length; i += 1) {
argStrings[i] = String.valueOf(args[i]);
}
throw new ValidationException(
String.format(String.valueOf(message), (Object[]) argStrings));
}
} | [
"public",
"static",
"void",
"check",
"(",
"boolean",
"isValid",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"!",
"isValid",
")",
"{",
"String",
"[",
"]",
"argStrings",
"=",
"new",
"String",
"[",
"args",
".",
"length",
... | Precondition-style validation that throws a {@link ValidationException}.
@param isValid
{@code true} if valid, {@code false} if an exception should be
thrown
@param message
A String message for the exception. | [
"Precondition",
"-",
"style",
"validation",
"that",
"throws",
"a",
"{",
"@link",
"ValidationException",
"}",
"."
] | train | https://github.com/kite-sdk/kite/blob/72bfb4b1a881af85808cd7f14bc3e15160a1e811/kite-data/kite-data-core/src/main/java/org/kitesdk/data/ValidationException.java#L49-L58 |
JodaOrg/joda-time | src/main/java/org/joda/time/Period.java | Period.multipliedBy | public Period multipliedBy(int scalar) {
if (this == ZERO || scalar == 1) {
return this;
}
int[] values = getValues(); // cloned
for (int i = 0; i < values.length; i++) {
values[i] = FieldUtils.safeMultiply(values[i], scalar);
}
return new Period(values, getPeriodType());
} | java | public Period multipliedBy(int scalar) {
if (this == ZERO || scalar == 1) {
return this;
}
int[] values = getValues(); // cloned
for (int i = 0; i < values.length; i++) {
values[i] = FieldUtils.safeMultiply(values[i], scalar);
}
return new Period(values, getPeriodType());
} | [
"public",
"Period",
"multipliedBy",
"(",
"int",
"scalar",
")",
"{",
"if",
"(",
"this",
"==",
"ZERO",
"||",
"scalar",
"==",
"1",
")",
"{",
"return",
"this",
";",
"}",
"int",
"[",
"]",
"values",
"=",
"getValues",
"(",
")",
";",
"// cloned",
"for",
"(... | Returns a new instance with each element in this period multiplied
by the specified scalar.
@param scalar the scalar to multiply by, not null
@return a {@code Period} based on this period with the amounts multiplied by the scalar, never null
@throws ArithmeticException if the capacity of any field is exceeded
@since 2.1 | [
"Returns",
"a",
"new",
"instance",
"with",
"each",
"element",
"in",
"this",
"period",
"multiplied",
"by",
"the",
"specified",
"scalar",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Period.java#L1353-L1362 |
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/lang/reflect/BeanInfoUtil.java | BeanInfoUtil.isVisible | public static boolean isVisible( FeatureDescriptor descriptor, IScriptabilityModifier constraint )
{
if( constraint == null )
{
return true;
}
IScriptabilityModifier modifier = getVisibilityModifier( descriptor );
if( modifier == null )
{
return true;
}
return modifier.satisfiesConstraint( constraint );
} | java | public static boolean isVisible( FeatureDescriptor descriptor, IScriptabilityModifier constraint )
{
if( constraint == null )
{
return true;
}
IScriptabilityModifier modifier = getVisibilityModifier( descriptor );
if( modifier == null )
{
return true;
}
return modifier.satisfiesConstraint( constraint );
} | [
"public",
"static",
"boolean",
"isVisible",
"(",
"FeatureDescriptor",
"descriptor",
",",
"IScriptabilityModifier",
"constraint",
")",
"{",
"if",
"(",
"constraint",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"IScriptabilityModifier",
"modifier",
"=",
"getV... | Determine if the descriptor is visible given a visibility constraint. | [
"Determine",
"if",
"the",
"descriptor",
"is",
"visible",
"given",
"a",
"visibility",
"constraint",
"."
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/reflect/BeanInfoUtil.java#L148-L162 |
Viascom/groundwork | foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java | FoxHttpRequestBuilder.addRequestQueryEntry | public FoxHttpRequestBuilder addRequestQueryEntry(String name, String value) {
foxHttpRequest.getRequestQuery().addQueryEntry(name, value);
return this;
} | java | public FoxHttpRequestBuilder addRequestQueryEntry(String name, String value) {
foxHttpRequest.getRequestQuery().addQueryEntry(name, value);
return this;
} | [
"public",
"FoxHttpRequestBuilder",
"addRequestQueryEntry",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"foxHttpRequest",
".",
"getRequestQuery",
"(",
")",
".",
"addQueryEntry",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Add a new query entry
@param name name of the query entry
@param value value of the query entry
@return FoxHttpRequestBuilder (this) | [
"Add",
"a",
"new",
"query",
"entry"
] | train | https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/builder/FoxHttpRequestBuilder.java#L146-L149 |
aws/aws-sdk-java | aws-java-sdk-mediaconvert/src/main/java/com/amazonaws/services/mediaconvert/model/ResourceTags.java | ResourceTags.withTags | public ResourceTags withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
} | java | public ResourceTags withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
} | [
"public",
"ResourceTags",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] | The tags for the resource.
@param tags
The tags for the resource.
@return Returns a reference to this object so that method calls can be chained together. | [
"The",
"tags",
"for",
"the",
"resource",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-mediaconvert/src/main/java/com/amazonaws/services/mediaconvert/model/ResourceTags.java#L97-L100 |
docusign/docusign-java-client | src/main/java/com/docusign/esign/api/PowerFormsApi.java | PowerFormsApi.getPowerFormData | public PowerFormsFormDataResponse getPowerFormData(String accountId, String powerFormId) throws ApiException {
return getPowerFormData(accountId, powerFormId, null);
} | java | public PowerFormsFormDataResponse getPowerFormData(String accountId, String powerFormId) throws ApiException {
return getPowerFormData(accountId, powerFormId, null);
} | [
"public",
"PowerFormsFormDataResponse",
"getPowerFormData",
"(",
"String",
"accountId",
",",
"String",
"powerFormId",
")",
"throws",
"ApiException",
"{",
"return",
"getPowerFormData",
"(",
"accountId",
",",
"powerFormId",
",",
"null",
")",
";",
"}"
] | Returns the form data associated with the usage of a PowerForm.
@param accountId The external account number (int) or account ID Guid. (required)
@param powerFormId (required)
@return PowerFormsFormDataResponse | [
"Returns",
"the",
"form",
"data",
"associated",
"with",
"the",
"usage",
"of",
"a",
"PowerForm",
"."
] | train | https://github.com/docusign/docusign-java-client/blob/17ae82ace0f023e98edf813be832950568212e34/src/main/java/com/docusign/esign/api/PowerFormsApi.java#L273-L275 |
RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java | BufferUtil.resetBitmapRangeAndCardinalityChange | @Deprecated
public static int resetBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) {
if (BufferUtil.isBackedBySimpleArray(bitmap)) {
return Util.resetBitmapRangeAndCardinalityChange(bitmap.array(), start, end);
}
int cardbefore = cardinalityInBitmapWordRange(bitmap, start, end);
resetBitmapRange(bitmap, start, end);
int cardafter = cardinalityInBitmapWordRange(bitmap, start, end);
return cardafter - cardbefore;
} | java | @Deprecated
public static int resetBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) {
if (BufferUtil.isBackedBySimpleArray(bitmap)) {
return Util.resetBitmapRangeAndCardinalityChange(bitmap.array(), start, end);
}
int cardbefore = cardinalityInBitmapWordRange(bitmap, start, end);
resetBitmapRange(bitmap, start, end);
int cardafter = cardinalityInBitmapWordRange(bitmap, start, end);
return cardafter - cardbefore;
} | [
"@",
"Deprecated",
"public",
"static",
"int",
"resetBitmapRangeAndCardinalityChange",
"(",
"LongBuffer",
"bitmap",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"BufferUtil",
".",
"isBackedBySimpleArray",
"(",
"bitmap",
")",
")",
"{",
"return",
... | reset bits at start, start+1,..., end-1 and report the cardinality change
@param bitmap array of words to be modified
@param start first index to be modified (inclusive)
@param end last index to be modified (exclusive)
@return cardinality change | [
"reset",
"bits",
"at",
"start",
"start",
"+",
"1",
"...",
"end",
"-",
"1",
"and",
"report",
"the",
"cardinality",
"change"
] | train | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java#L471-L480 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/string/AbstrStrMatcher.java | AbstrStrMatcher.indexs | public int indexs(final Integer fromIndex, String... indexWith) {
int index = INDEX_NONE_EXISTS;
final String target = ignoreCase ? delegate.get().toLowerCase() : delegate.get();
for (String input : indexWith) {
String target2 = ignoreCase ? input.toLowerCase() : input;
if ((index = target.indexOf(target2, fromIndex)) >= 0) {
return index;
}
}
return index;
} | java | public int indexs(final Integer fromIndex, String... indexWith) {
int index = INDEX_NONE_EXISTS;
final String target = ignoreCase ? delegate.get().toLowerCase() : delegate.get();
for (String input : indexWith) {
String target2 = ignoreCase ? input.toLowerCase() : input;
if ((index = target.indexOf(target2, fromIndex)) >= 0) {
return index;
}
}
return index;
} | [
"public",
"int",
"indexs",
"(",
"final",
"Integer",
"fromIndex",
",",
"String",
"...",
"indexWith",
")",
"{",
"int",
"index",
"=",
"INDEX_NONE_EXISTS",
";",
"final",
"String",
"target",
"=",
"ignoreCase",
"?",
"delegate",
".",
"get",
"(",
")",
".",
"toLowe... | Search delegate string to find the first index of any string in
the given string list, starting at the specified index
@param fromIndex
@param indexWith
@return | [
"Search",
"delegate",
"string",
"to",
"find",
"the",
"first",
"index",
"of",
"any",
"string",
"in",
"the",
"given",
"string",
"list",
"starting",
"at",
"the",
"specified",
"index"
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/string/AbstrStrMatcher.java#L222-L234 |
Viascom/groundwork | foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/header/FoxHttpHeader.java | FoxHttpHeader.addHeader | public void addHeader(String name, String value) {
headerEntries.add(new HeaderEntry(name, value));
} | java | public void addHeader(String name, String value) {
headerEntries.add(new HeaderEntry(name, value));
} | [
"public",
"void",
"addHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"headerEntries",
".",
"add",
"(",
"new",
"HeaderEntry",
"(",
"name",
",",
"value",
")",
")",
";",
"}"
] | Add a new header entry
@param name name of the header entry
@param value value of the header entry | [
"Add",
"a",
"new",
"header",
"entry"
] | train | https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/header/FoxHttpHeader.java#L32-L34 |
cdk/cdk | base/data/src/main/java/org/openscience/cdk/Polymer.java | Polymer.addAtom | @Override
public void addAtom(IAtom oAtom, IMonomer oMonomer) {
if (!contains(oAtom)) {
super.addAtom(oAtom);
if (oMonomer != null) { // Not sure what's better here...throw nullpointer exception?
oMonomer.addAtom(oAtom);
if (!monomers.containsKey(oMonomer.getMonomerName())) {
monomers.put(oMonomer.getMonomerName(), oMonomer);
}
}
}
/*
* notifyChanged() is called by addAtom in AtomContainer
*/
} | java | @Override
public void addAtom(IAtom oAtom, IMonomer oMonomer) {
if (!contains(oAtom)) {
super.addAtom(oAtom);
if (oMonomer != null) { // Not sure what's better here...throw nullpointer exception?
oMonomer.addAtom(oAtom);
if (!monomers.containsKey(oMonomer.getMonomerName())) {
monomers.put(oMonomer.getMonomerName(), oMonomer);
}
}
}
/*
* notifyChanged() is called by addAtom in AtomContainer
*/
} | [
"@",
"Override",
"public",
"void",
"addAtom",
"(",
"IAtom",
"oAtom",
",",
"IMonomer",
"oMonomer",
")",
"{",
"if",
"(",
"!",
"contains",
"(",
"oAtom",
")",
")",
"{",
"super",
".",
"addAtom",
"(",
"oAtom",
")",
";",
"if",
"(",
"oMonomer",
"!=",
"null",... | Adds the atom oAtom to a specified Monomer.
@param oAtom The atom to add
@param oMonomer The monomer the atom belongs to | [
"Adds",
"the",
"atom",
"oAtom",
"to",
"a",
"specified",
"Monomer",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/data/src/main/java/org/openscience/cdk/Polymer.java#L79-L95 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/collection/trie/DoubleArrayTrie.java | DoubleArrayTrie.set | public boolean set(String key, V value)
{
int index = exactMatchSearch(key);
if (index >= 0)
{
v[index] = value;
return true;
}
return false;
} | java | public boolean set(String key, V value)
{
int index = exactMatchSearch(key);
if (index >= 0)
{
v[index] = value;
return true;
}
return false;
} | [
"public",
"boolean",
"set",
"(",
"String",
"key",
",",
"V",
"value",
")",
"{",
"int",
"index",
"=",
"exactMatchSearch",
"(",
"key",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"v",
"[",
"index",
"]",
"=",
"value",
";",
"return",
"true",
";... | 更新某个键对应的值
@param key 键
@param value 值
@return 是否成功(失败的原因是没有这个键) | [
"更新某个键对应的值"
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/trie/DoubleArrayTrie.java#L1410-L1420 |
EasyinnovaSL/Tiff-Library-4J | src/main/java/com/easyinnova/tiff/profiles/TiffEPProfile.java | TiffEPProfile.checkForbiddenTag | private void checkForbiddenTag(IfdTags metadata, String tagName, String ext) {
int tagid = TiffTags.getTagId(tagName);
if (metadata.containsTagId(tagid)) {
validation.addErrorLoc("Forbidden tag for TiffEP found " + tagName, ext);
}
} | java | private void checkForbiddenTag(IfdTags metadata, String tagName, String ext) {
int tagid = TiffTags.getTagId(tagName);
if (metadata.containsTagId(tagid)) {
validation.addErrorLoc("Forbidden tag for TiffEP found " + tagName, ext);
}
} | [
"private",
"void",
"checkForbiddenTag",
"(",
"IfdTags",
"metadata",
",",
"String",
"tagName",
",",
"String",
"ext",
")",
"{",
"int",
"tagid",
"=",
"TiffTags",
".",
"getTagId",
"(",
"tagName",
")",
";",
"if",
"(",
"metadata",
".",
"containsTagId",
"(",
"tag... | Check a forbidden tag is not present.
@param metadata the metadata
@param tagName the tag name
@param ext string extension | [
"Check",
"a",
"forbidden",
"tag",
"is",
"not",
"present",
"."
] | train | https://github.com/EasyinnovaSL/Tiff-Library-4J/blob/682605d3ed207a66213278c054c98f1b909472b7/src/main/java/com/easyinnova/tiff/profiles/TiffEPProfile.java#L372-L377 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/ConsumedCapacity.java | ConsumedCapacity.withLocalSecondaryIndexes | public ConsumedCapacity withLocalSecondaryIndexes(java.util.Map<String, Capacity> localSecondaryIndexes) {
setLocalSecondaryIndexes(localSecondaryIndexes);
return this;
} | java | public ConsumedCapacity withLocalSecondaryIndexes(java.util.Map<String, Capacity> localSecondaryIndexes) {
setLocalSecondaryIndexes(localSecondaryIndexes);
return this;
} | [
"public",
"ConsumedCapacity",
"withLocalSecondaryIndexes",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"Capacity",
">",
"localSecondaryIndexes",
")",
"{",
"setLocalSecondaryIndexes",
"(",
"localSecondaryIndexes",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The amount of throughput consumed on each local index affected by the operation.
</p>
@param localSecondaryIndexes
The amount of throughput consumed on each local index affected by the operation.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"amount",
"of",
"throughput",
"consumed",
"on",
"each",
"local",
"index",
"affected",
"by",
"the",
"operation",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/ConsumedCapacity.java#L313-L316 |
hdbeukel/james-core | src/main/java/org/jamesframework/core/util/SetUtilities.java | SetUtilities.getRandomElement | public static <T> T getRandomElement(Set<? extends T> set, Random rg){
Iterator<? extends T> it = set.iterator();
int r = rg.nextInt(set.size());
T selected = it.next();
for(int i=0; i<r; i++){
selected = it.next();
}
return selected;
} | java | public static <T> T getRandomElement(Set<? extends T> set, Random rg){
Iterator<? extends T> it = set.iterator();
int r = rg.nextInt(set.size());
T selected = it.next();
for(int i=0; i<r; i++){
selected = it.next();
}
return selected;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"getRandomElement",
"(",
"Set",
"<",
"?",
"extends",
"T",
">",
"set",
",",
"Random",
"rg",
")",
"{",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"it",
"=",
"set",
".",
"iterator",
"(",
")",
";",
"int",
"r",
... | Select a random element from a given set (uniformly distributed). This implementation generates
a random number r in [0,|set|-1] and traverses the set using an iterator, where the element obtained
after r+1 applications of {@link Iterator#next()} is returned. In the worst case, this algorithm has
linear time complexity with respect to the size of the given set.
@param <T> type of randomly selected element
@param set set from which to select a random element
@param rg random generator
@return random element (uniformly distributed) | [
"Select",
"a",
"random",
"element",
"from",
"a",
"given",
"set",
"(",
"uniformly",
"distributed",
")",
".",
"This",
"implementation",
"generates",
"a",
"random",
"number",
"r",
"in",
"[",
"0",
"|set|",
"-",
"1",
"]",
"and",
"traverses",
"the",
"set",
"us... | train | https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/util/SetUtilities.java#L43-L51 |
teatrove/teatrove | teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java | StringContext.convertToEncoding | public String convertToEncoding(String subject, String encoding)
throws UnsupportedEncodingException {
return new String(subject.getBytes(encoding), encoding);
} | java | public String convertToEncoding(String subject, String encoding)
throws UnsupportedEncodingException {
return new String(subject.getBytes(encoding), encoding);
} | [
"public",
"String",
"convertToEncoding",
"(",
"String",
"subject",
",",
"String",
"encoding",
")",
"throws",
"UnsupportedEncodingException",
"{",
"return",
"new",
"String",
"(",
"subject",
".",
"getBytes",
"(",
"encoding",
")",
",",
"encoding",
")",
";",
"}"
] | Convert the given string to the given encoding.
@param subject The value to convert
@param encoding The name of the encoding/character set
@return A new string in the given encoding
@throws UnsupportedEncodingException if the encoding is invalid | [
"Convert",
"the",
"given",
"string",
"to",
"the",
"given",
"encoding",
"."
] | train | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L735-L739 |
BrunoEberhard/minimal-j | src/main/java/org/minimalj/util/IdUtils.java | IdUtils.setVersion | public static void setVersion(Object object, int version) {
try {
Field versionField = object.getClass().getField("version");
versionField.set(object, version);
} catch (NoSuchFieldException | SecurityException | IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java | public static void setVersion(Object object, int version) {
try {
Field versionField = object.getClass().getField("version");
versionField.set(object, version);
} catch (NoSuchFieldException | SecurityException | IllegalAccessException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"void",
"setVersion",
"(",
"Object",
"object",
",",
"int",
"version",
")",
"{",
"try",
"{",
"Field",
"versionField",
"=",
"object",
".",
"getClass",
"(",
")",
".",
"getField",
"(",
"\"version\"",
")",
";",
"versionField",
".",
"set",
... | Set the value of the <code>version</code> in the given object
@param object object containing a public <code>version</code> field. Must not be <code>null</code>
@param version the new value. | [
"Set",
"the",
"value",
"of",
"the",
"<code",
">",
"version<",
"/",
"code",
">",
"in",
"the",
"given",
"object"
] | train | https://github.com/BrunoEberhard/minimal-j/blob/f7c5461b2b47a10b383aee1e2f1f150f6773703b/src/main/java/org/minimalj/util/IdUtils.java#L122-L129 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/theta/AnotB.java | AnotB.aNotB | public CompactSketch aNotB(final Sketch a, final Sketch b) {
return aNotB(a, b, true, null);
} | java | public CompactSketch aNotB(final Sketch a, final Sketch b) {
return aNotB(a, b, true, null);
} | [
"public",
"CompactSketch",
"aNotB",
"(",
"final",
"Sketch",
"a",
",",
"final",
"Sketch",
"b",
")",
"{",
"return",
"aNotB",
"(",
"a",
",",
"b",
",",
"true",
",",
"null",
")",
";",
"}"
] | Perform A-and-not-B set operation on the two given sketches and return the result as an
ordered CompactSketch on the heap.
@param a The incoming sketch for the first argument
@param b The incoming sketch for the second argument
@return an ordered CompactSketch on the heap | [
"Perform",
"A",
"-",
"and",
"-",
"not",
"-",
"B",
"set",
"operation",
"on",
"the",
"two",
"given",
"sketches",
"and",
"return",
"the",
"result",
"as",
"an",
"ordered",
"CompactSketch",
"on",
"the",
"heap",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/theta/AnotB.java#L69-L71 |
rey5137/material | material/src/main/java/com/rey/material/widget/DatePicker.java | DatePicker.setDate | public void setDate(int day, int month, int year){
if(mAdapter.getYear() == year && mAdapter.getMonth() == month && mAdapter.getDay() == day)
return;
mAdapter.setDate(day, month, year, false);
goTo(month, year);
} | java | public void setDate(int day, int month, int year){
if(mAdapter.getYear() == year && mAdapter.getMonth() == month && mAdapter.getDay() == day)
return;
mAdapter.setDate(day, month, year, false);
goTo(month, year);
} | [
"public",
"void",
"setDate",
"(",
"int",
"day",
",",
"int",
"month",
",",
"int",
"year",
")",
"{",
"if",
"(",
"mAdapter",
".",
"getYear",
"(",
")",
"==",
"year",
"&&",
"mAdapter",
".",
"getMonth",
"(",
")",
"==",
"month",
"&&",
"mAdapter",
".",
"ge... | Set the selected date of this DatePicker.
@param day The day value of selected date.
@param month The month value of selected date.
@param year The year value of selected date. | [
"Set",
"the",
"selected",
"date",
"of",
"this",
"DatePicker",
"."
] | train | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/DatePicker.java#L418-L424 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/file/SimpleFileIO.java | SimpleFileIO.getFileAsString | @Nullable
public static String getFileAsString (@Nullable final File aFile, @Nonnull final Charset aCharset)
{
return aFile == null ? null : StreamHelper.getAllBytesAsString (FileHelper.getInputStream (aFile), aCharset);
} | java | @Nullable
public static String getFileAsString (@Nullable final File aFile, @Nonnull final Charset aCharset)
{
return aFile == null ? null : StreamHelper.getAllBytesAsString (FileHelper.getInputStream (aFile), aCharset);
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getFileAsString",
"(",
"@",
"Nullable",
"final",
"File",
"aFile",
",",
"@",
"Nonnull",
"final",
"Charset",
"aCharset",
")",
"{",
"return",
"aFile",
"==",
"null",
"?",
"null",
":",
"StreamHelper",
".",
"getAllBy... | Get the content of the passed file as a string using the system line
separator. Note: the last line does not end with the passed line separator.
@param aFile
The file to read. May be <code>null</code>.
@param aCharset
The character set to use. May not be <code>null</code>.
@return <code>null</code> if the file does not exist, the content
otherwise. | [
"Get",
"the",
"content",
"of",
"the",
"passed",
"file",
"as",
"a",
"string",
"using",
"the",
"system",
"line",
"separator",
".",
"Note",
":",
"the",
"last",
"line",
"does",
"not",
"end",
"with",
"the",
"passed",
"line",
"separator",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/file/SimpleFileIO.java#L147-L151 |
VoltDB/voltdb | src/frontend/org/voltdb/ProcedurePartitionData.java | ProcedurePartitionData.fromPartitionInfoString | public static ProcedurePartitionData fromPartitionInfoString(String partitionInfoString) {
if (partitionInfoString == null || partitionInfoString.trim().isEmpty()) {
return new ProcedurePartitionData();
}
String[] partitionInfoParts = new String[0];
partitionInfoParts = partitionInfoString.split(",");
assert(partitionInfoParts.length <= 2);
if (partitionInfoParts.length == 2) {
ProcedurePartitionData partitionInfo = fromPartitionInfoString(partitionInfoParts[0]);
ProcedurePartitionData partitionInfo2 = fromPartitionInfoString(partitionInfoParts[1]);
partitionInfo.addSecondPartitionInfo(partitionInfo2);
return partitionInfo;
}
String subClause = partitionInfoParts[0];
// split on the colon
String[] parts = subClause.split(":");
assert(parts.length == 2);
// relabel the parts for code readability
String columnInfo = parts[0].trim();
String paramIndex = parts[1].trim();
// split the columninfo
parts = columnInfo.split("\\.");
assert(parts.length == 2);
// relabel the parts for code readability
String tableName = parts[0].trim();
String columnName = parts[1].trim();
return new ProcedurePartitionData(tableName, columnName, paramIndex);
} | java | public static ProcedurePartitionData fromPartitionInfoString(String partitionInfoString) {
if (partitionInfoString == null || partitionInfoString.trim().isEmpty()) {
return new ProcedurePartitionData();
}
String[] partitionInfoParts = new String[0];
partitionInfoParts = partitionInfoString.split(",");
assert(partitionInfoParts.length <= 2);
if (partitionInfoParts.length == 2) {
ProcedurePartitionData partitionInfo = fromPartitionInfoString(partitionInfoParts[0]);
ProcedurePartitionData partitionInfo2 = fromPartitionInfoString(partitionInfoParts[1]);
partitionInfo.addSecondPartitionInfo(partitionInfo2);
return partitionInfo;
}
String subClause = partitionInfoParts[0];
// split on the colon
String[] parts = subClause.split(":");
assert(parts.length == 2);
// relabel the parts for code readability
String columnInfo = parts[0].trim();
String paramIndex = parts[1].trim();
// split the columninfo
parts = columnInfo.split("\\.");
assert(parts.length == 2);
// relabel the parts for code readability
String tableName = parts[0].trim();
String columnName = parts[1].trim();
return new ProcedurePartitionData(tableName, columnName, paramIndex);
} | [
"public",
"static",
"ProcedurePartitionData",
"fromPartitionInfoString",
"(",
"String",
"partitionInfoString",
")",
"{",
"if",
"(",
"partitionInfoString",
"==",
"null",
"||",
"partitionInfoString",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return... | For Testing usage ONLY.
From a partition information string to @ProcedurePartitionData
string format:
1) String.format("%s.%s: %s", tableName, columnName, parameterNo)
1) String.format("%s.%s: %s, %s.%s: %s", tableName, columnName, parameterNo, tableName2, columnName2, parameterNo2)
@return | [
"For",
"Testing",
"usage",
"ONLY",
".",
"From",
"a",
"partition",
"information",
"string",
"to"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/ProcedurePartitionData.java#L107-L141 |
ModeShape/modeshape | modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java | JcrTools.findOrCreateNode | public Node findOrCreateNode( Session session,
String path,
String defaultNodeType,
String finalNodeType ) throws RepositoryException {
isNotNull(session, "session");
Node root = session.getRootNode();
return findOrCreateNode(root, path, defaultNodeType, finalNodeType);
} | java | public Node findOrCreateNode( Session session,
String path,
String defaultNodeType,
String finalNodeType ) throws RepositoryException {
isNotNull(session, "session");
Node root = session.getRootNode();
return findOrCreateNode(root, path, defaultNodeType, finalNodeType);
} | [
"public",
"Node",
"findOrCreateNode",
"(",
"Session",
"session",
",",
"String",
"path",
",",
"String",
"defaultNodeType",
",",
"String",
"finalNodeType",
")",
"throws",
"RepositoryException",
"{",
"isNotNull",
"(",
"session",
",",
"\"session\"",
")",
";",
"Node",
... | Get or create a node at the specified path.
@param session the JCR session. may not be null
@param path the path of the desired node to be found or created. may not be null
@param defaultNodeType the default node type. may be null
@param finalNodeType the optional final node type. may be null
@return the existing or newly created node
@throws RepositoryException
@throws IllegalArgumentException if either the session or path argument is null | [
"Get",
"or",
"create",
"a",
"node",
"at",
"the",
"specified",
"path",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr-api/src/main/java/org/modeshape/jcr/api/JcrTools.java#L371-L378 |
TheCoder4eu/BootsFaces-OSP | src/main/java/net/bootsfaces/utils/BsfUtils.java | BsfUtils.selectJavaDateTimeFormatFromMomentJSFormatOrDefault | public static String selectJavaDateTimeFormatFromMomentJSFormatOrDefault(Locale locale, String momentJSFormat, boolean withDate, boolean withTime) {
if (momentJSFormat == null) {
String dateFormat = "";
if (withDate) {
dateFormat = ((SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale)).toPattern();
}
String timeFormat = "";
if (withTime) {
timeFormat = ((SimpleDateFormat)DateFormat.getTimeInstance(DateFormat.MEDIUM, locale)).toPattern();
}
// Since DateFormat.SHORT is silly, return a smart format
if (dateFormat.equals("M/d/yy")) {
dateFormat = "MM/dd/yyyy";
}
else if (dateFormat.equals("d/M/yy")) {
dateFormat = "dd/MM/yyyy";
}
return (dateFormat + " " + timeFormat).trim();
} else {
return LocaleUtils.momentToJavaFormat(momentJSFormat);
}
} | java | public static String selectJavaDateTimeFormatFromMomentJSFormatOrDefault(Locale locale, String momentJSFormat, boolean withDate, boolean withTime) {
if (momentJSFormat == null) {
String dateFormat = "";
if (withDate) {
dateFormat = ((SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale)).toPattern();
}
String timeFormat = "";
if (withTime) {
timeFormat = ((SimpleDateFormat)DateFormat.getTimeInstance(DateFormat.MEDIUM, locale)).toPattern();
}
// Since DateFormat.SHORT is silly, return a smart format
if (dateFormat.equals("M/d/yy")) {
dateFormat = "MM/dd/yyyy";
}
else if (dateFormat.equals("d/M/yy")) {
dateFormat = "dd/MM/yyyy";
}
return (dateFormat + " " + timeFormat).trim();
} else {
return LocaleUtils.momentToJavaFormat(momentJSFormat);
}
} | [
"public",
"static",
"String",
"selectJavaDateTimeFormatFromMomentJSFormatOrDefault",
"(",
"Locale",
"locale",
",",
"String",
"momentJSFormat",
",",
"boolean",
"withDate",
",",
"boolean",
"withTime",
")",
"{",
"if",
"(",
"momentJSFormat",
"==",
"null",
")",
"{",
"Str... | Selects the Date Pattern to use based on the given Locale if the input
format is null
@param locale
Locale (may be the result of a call to selectLocale)
@param momentJSFormat
Input format String
@return Date Pattern eg. dd/MM/yyyy | [
"Selects",
"the",
"Date",
"Pattern",
"to",
"use",
"based",
"on",
"the",
"given",
"Locale",
"if",
"the",
"input",
"format",
"is",
"null"
] | train | https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/utils/BsfUtils.java#L537-L558 |
sagiegurari/fax4j | src/main/java/org/fax4j/bridge/AbstractVendorPolicy.java | AbstractVendorPolicy.invokePolicyForResponse | public boolean invokePolicyForResponse(Object requestDataHolder,FaxJob faxJob)
{
if(requestDataHolder==null)
{
throw new FaxException("Request data holder not provided.");
}
if(faxJob==null)
{
throw new FaxException("Fax job not provided.");
}
//invoke policy
boolean continueFlow=this.invokePolicyForResponseImpl(requestDataHolder,faxJob);
return continueFlow;
} | java | public boolean invokePolicyForResponse(Object requestDataHolder,FaxJob faxJob)
{
if(requestDataHolder==null)
{
throw new FaxException("Request data holder not provided.");
}
if(faxJob==null)
{
throw new FaxException("Fax job not provided.");
}
//invoke policy
boolean continueFlow=this.invokePolicyForResponseImpl(requestDataHolder,faxJob);
return continueFlow;
} | [
"public",
"boolean",
"invokePolicyForResponse",
"(",
"Object",
"requestDataHolder",
",",
"FaxJob",
"faxJob",
")",
"{",
"if",
"(",
"requestDataHolder",
"==",
"null",
")",
"{",
"throw",
"new",
"FaxException",
"(",
"\"Request data holder not provided.\"",
")",
";",
"}"... | This function invokes the vendor policy.<br>
The policy may charge a customer for the service, or validate the user
has permissions to invoke the action and so on.<br>
In case the policy takes over the flow and the fax bridge should not
be invoked, this method should return false.
@param requestDataHolder
The request data holder
@param faxJob
The submitted fax job
@return True if to continue the flow, else false (in case the policy sends the response) | [
"This",
"function",
"invokes",
"the",
"vendor",
"policy",
".",
"<br",
">",
"The",
"policy",
"may",
"charge",
"a",
"customer",
"for",
"the",
"service",
"or",
"validate",
"the",
"user",
"has",
"permissions",
"to",
"invoke",
"the",
"action",
"and",
"so",
"on"... | train | https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/bridge/AbstractVendorPolicy.java#L132-L147 |
icode/ameba | src/main/java/ameba/db/ebean/support/ModelResourceStructure.java | ModelResourceStructure.deleteModel | protected boolean deleteModel(MODEL_ID id, boolean permanent) throws Exception {
if (permanent) {
server.deletePermanent(modelType, id);
} else {
server.delete(modelType, id);
}
return permanent;
} | java | protected boolean deleteModel(MODEL_ID id, boolean permanent) throws Exception {
if (permanent) {
server.deletePermanent(modelType, id);
} else {
server.delete(modelType, id);
}
return permanent;
} | [
"protected",
"boolean",
"deleteModel",
"(",
"MODEL_ID",
"id",
",",
"boolean",
"permanent",
")",
"throws",
"Exception",
"{",
"if",
"(",
"permanent",
")",
"{",
"server",
".",
"deletePermanent",
"(",
"modelType",
",",
"id",
")",
";",
"}",
"else",
"{",
"server... | delete a model
@param id model id
@param permanent a boolean.
@return if true delete from physical device, if logical delete return false, response status 202
@throws java.lang.Exception if any. | [
"delete",
"a",
"model"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/db/ebean/support/ModelResourceStructure.java#L521-L528 |
googlegenomics/dataflow-java | src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/Solver.java | Solver.gridSearch | static Interval gridSearch(UnivariateFunction fn, double start,
double end, double step) {
double lowMax = start; // lower bound on interval surrounding alphaMax
double alphaMax = start - step;
double likMax = 0.0;
double lastAlpha = start;
double alpha = start;
while (alpha < end) {
double likelihood = fn.value(alpha);
if (alphaMax < start || likelihood > likMax) {
lowMax = lastAlpha;
alphaMax = alpha;
likMax = likelihood;
}
lastAlpha = alpha;
alpha += step;
}
// make sure we've checked the rightmost endpoint (won't happen if
// end - start is not an integer multiple of step, because of roundoff
// errors, etc)
double likelihood = fn.value(end);
if (likelihood > likMax) {
lowMax = lastAlpha;
alphaMax = end;
likMax = likelihood;
}
return new Interval(lowMax, Math.min(end, alphaMax + step));
} | java | static Interval gridSearch(UnivariateFunction fn, double start,
double end, double step) {
double lowMax = start; // lower bound on interval surrounding alphaMax
double alphaMax = start - step;
double likMax = 0.0;
double lastAlpha = start;
double alpha = start;
while (alpha < end) {
double likelihood = fn.value(alpha);
if (alphaMax < start || likelihood > likMax) {
lowMax = lastAlpha;
alphaMax = alpha;
likMax = likelihood;
}
lastAlpha = alpha;
alpha += step;
}
// make sure we've checked the rightmost endpoint (won't happen if
// end - start is not an integer multiple of step, because of roundoff
// errors, etc)
double likelihood = fn.value(end);
if (likelihood > likMax) {
lowMax = lastAlpha;
alphaMax = end;
likMax = likelihood;
}
return new Interval(lowMax, Math.min(end, alphaMax + step));
} | [
"static",
"Interval",
"gridSearch",
"(",
"UnivariateFunction",
"fn",
",",
"double",
"start",
",",
"double",
"end",
",",
"double",
"step",
")",
"{",
"double",
"lowMax",
"=",
"start",
";",
"// lower bound on interval surrounding alphaMax",
"double",
"alphaMax",
"=",
... | Runs a grid search for the maximum value of a univariate function.
@param fn the likelihood function to minimize
@param start lower bound of the interval to search
@param end upper bound of the interval to search
@param step grid step size
@return an Interval bracketing the minimum | [
"Runs",
"a",
"grid",
"search",
"for",
"the",
"maximum",
"value",
"of",
"a",
"univariate",
"function",
"."
] | train | https://github.com/googlegenomics/dataflow-java/blob/ef2c56ed1a6397843c55102748b8c2b12aaa4772/src/main/java/com/google/cloud/genomics/dataflow/functions/verifybamid/Solver.java#L42-L70 |
mapcode-foundation/mapcode-java | src/main/java/com/mapcode/Point.java | Point.distanceInMeters | public static double distanceInMeters(@Nonnull final Point p1, @Nonnull final Point p2) {
checkNonnull("p1", p1);
checkNonnull("p2", p2);
final Point from;
final Point to;
if (p1.getLonDeg() <= p2.getLonDeg()) {
from = p1;
to = p2;
} else {
from = p2;
to = p1;
}
// Calculate mid point of 2 latitudes.
final double avgLat = (from.getLatDeg() + to.getLatDeg()) / 2.0;
final double deltaLatDeg = Math.abs(to.getLatDeg() - from.getLatDeg());
final double deltaLonDeg360 = Math.abs(to.getLonDeg() - from.getLonDeg());
final double deltaLonDeg = ((deltaLonDeg360 <= 180.0) ? deltaLonDeg360 : (360.0 - deltaLonDeg360));
// Meters per longitude is fixed; per latitude requires * cos(avg(lat)).
final double deltaXMeters = degreesLonToMetersAtLat(deltaLonDeg, avgLat);
final double deltaYMeters = degreesLatToMeters(deltaLatDeg);
// Calculate length through Earth. This is an approximation, but works fine for short distances.
return Math.sqrt((deltaXMeters * deltaXMeters) + (deltaYMeters * deltaYMeters));
} | java | public static double distanceInMeters(@Nonnull final Point p1, @Nonnull final Point p2) {
checkNonnull("p1", p1);
checkNonnull("p2", p2);
final Point from;
final Point to;
if (p1.getLonDeg() <= p2.getLonDeg()) {
from = p1;
to = p2;
} else {
from = p2;
to = p1;
}
// Calculate mid point of 2 latitudes.
final double avgLat = (from.getLatDeg() + to.getLatDeg()) / 2.0;
final double deltaLatDeg = Math.abs(to.getLatDeg() - from.getLatDeg());
final double deltaLonDeg360 = Math.abs(to.getLonDeg() - from.getLonDeg());
final double deltaLonDeg = ((deltaLonDeg360 <= 180.0) ? deltaLonDeg360 : (360.0 - deltaLonDeg360));
// Meters per longitude is fixed; per latitude requires * cos(avg(lat)).
final double deltaXMeters = degreesLonToMetersAtLat(deltaLonDeg, avgLat);
final double deltaYMeters = degreesLatToMeters(deltaLatDeg);
// Calculate length through Earth. This is an approximation, but works fine for short distances.
return Math.sqrt((deltaXMeters * deltaXMeters) + (deltaYMeters * deltaYMeters));
} | [
"public",
"static",
"double",
"distanceInMeters",
"(",
"@",
"Nonnull",
"final",
"Point",
"p1",
",",
"@",
"Nonnull",
"final",
"Point",
"p2",
")",
"{",
"checkNonnull",
"(",
"\"p1\"",
",",
"p1",
")",
";",
"checkNonnull",
"(",
"\"p2\"",
",",
"p2",
")",
";",
... | Calculate the distance between two points. This algorithm does not take the curvature of the Earth into
account, so it only works for small distance up to, say 200 km, and not too close to the poles.
@param p1 Point 1.
@param p2 Point 2.
@return Straight distance between p1 and p2. Only accurate for small distances up to 200 km. | [
"Calculate",
"the",
"distance",
"between",
"two",
"points",
".",
"This",
"algorithm",
"does",
"not",
"take",
"the",
"curvature",
"of",
"the",
"Earth",
"into",
"account",
"so",
"it",
"only",
"works",
"for",
"small",
"distance",
"up",
"to",
"say",
"200",
"km... | train | https://github.com/mapcode-foundation/mapcode-java/blob/f12d4d9fbd460472ac0fff1f702f2ac716bc0ab8/src/main/java/com/mapcode/Point.java#L173-L201 |
kaazing/gateway | util/src/main/java/org/kaazing/gateway/util/turn/TurnUtils.java | TurnUtils.generatePassword | public static char[] generatePassword(String username, Key sharedSecret, String algorithm) {
byte[] key = sharedSecret.getEncoded();
Mac hmac;
try {
hmac = Mac.getInstance(algorithm);
SecretKeySpec signingKey = new SecretKeySpec(key, algorithm);
hmac.init(signingKey);
} catch (InvalidKeyException | NoSuchAlgorithmException e) {
throw new TurnException("Unable to generate password", e);
}
return Base64.getEncoder().encodeToString(hmac.doFinal(username.getBytes())).toCharArray();
} | java | public static char[] generatePassword(String username, Key sharedSecret, String algorithm) {
byte[] key = sharedSecret.getEncoded();
Mac hmac;
try {
hmac = Mac.getInstance(algorithm);
SecretKeySpec signingKey = new SecretKeySpec(key, algorithm);
hmac.init(signingKey);
} catch (InvalidKeyException | NoSuchAlgorithmException e) {
throw new TurnException("Unable to generate password", e);
}
return Base64.getEncoder().encodeToString(hmac.doFinal(username.getBytes())).toCharArray();
} | [
"public",
"static",
"char",
"[",
"]",
"generatePassword",
"(",
"String",
"username",
",",
"Key",
"sharedSecret",
",",
"String",
"algorithm",
")",
"{",
"byte",
"[",
"]",
"key",
"=",
"sharedSecret",
".",
"getEncoded",
"(",
")",
";",
"Mac",
"hmac",
";",
"tr... | This function generates the secret key based on the procedure described in
https://tools.ietf.org/html/draft-uberti-rtcweb-turn-rest-00#section-2.2
@param username - the username of the API
@param sharedSecret - the shared secret used by the TURN server as well
@param algorithm - the algorithm. COTURN only supports HmacSHA1 as of 2016/08/18
@return - the actual password | [
"This",
"function",
"generates",
"the",
"secret",
"key",
"based",
"on",
"the",
"procedure",
"described",
"in",
"https",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"draft",
"-",
"uberti",
"-",
"rtcweb",
"-",
"turn",
"-",
"rest",
"-",... | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/util/src/main/java/org/kaazing/gateway/util/turn/TurnUtils.java#L55-L67 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/core/urls/URLRewriterService.java | URLRewriterService.unregisterURLRewriter | public static void unregisterURLRewriter( ServletRequest request, URLRewriter rewriter )
{
if ( rewriter == null ) { return; }
ArrayList/*< URLRewriter >*/ rewriters = getRewriters( request );
if ( rewriters == null )
{
return;
}
else
{
rewriters.remove( rewriter );
if ( rewriters.size() == 0 )
{
request.removeAttribute( URL_REWRITERS_KEY );
}
}
} | java | public static void unregisterURLRewriter( ServletRequest request, URLRewriter rewriter )
{
if ( rewriter == null ) { return; }
ArrayList/*< URLRewriter >*/ rewriters = getRewriters( request );
if ( rewriters == null )
{
return;
}
else
{
rewriters.remove( rewriter );
if ( rewriters.size() == 0 )
{
request.removeAttribute( URL_REWRITERS_KEY );
}
}
} | [
"public",
"static",
"void",
"unregisterURLRewriter",
"(",
"ServletRequest",
"request",
",",
"URLRewriter",
"rewriter",
")",
"{",
"if",
"(",
"rewriter",
"==",
"null",
")",
"{",
"return",
";",
"}",
"ArrayList",
"/*< URLRewriter >*/",
"rewriters",
"=",
"getRewriters"... | Unregister the URLRewriter (remove from the list) from the request.
@param request the current ServletRequest.
@param rewriter the URLRewriter to unregister
@see #registerURLRewriter | [
"Unregister",
"the",
"URLRewriter",
"(",
"remove",
"from",
"the",
"list",
")",
"from",
"the",
"request",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/core/urls/URLRewriterService.java#L296-L315 |
structurizr/java | structurizr-core/src/com/structurizr/model/SoftwareSystem.java | SoftwareSystem.addContainer | @Nonnull
public Container addContainer(@Nonnull String name, String description, String technology) {
return getModel().addContainer(this, name, description, technology);
} | java | @Nonnull
public Container addContainer(@Nonnull String name, String description, String technology) {
return getModel().addContainer(this, name, description, technology);
} | [
"@",
"Nonnull",
"public",
"Container",
"addContainer",
"(",
"@",
"Nonnull",
"String",
"name",
",",
"String",
"description",
",",
"String",
"technology",
")",
"{",
"return",
"getModel",
"(",
")",
".",
"addContainer",
"(",
"this",
",",
"name",
",",
"descriptio... | Adds a container with the specified name, description and technology
@param name the name of the container (e.g. "Web Application")
@param description a short description/list of responsibilities
@param technology the technoogy choice (e.g. "Spring MVC", "Java EE", etc)
@return the newly created Container instance added to the model (or null)
@throws IllegalArgumentException if a container with the same name exists already | [
"Adds",
"a",
"container",
"with",
"the",
"specified",
"name",
"description",
"and",
"technology"
] | train | https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/model/SoftwareSystem.java#L86-L89 |
jbundle/jbundle | base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBasePanel.java | HBasePanel.printDataEndField | public void printDataEndField(PrintWriter out, int iPrintOptions)
{
if ((iPrintOptions & HtmlConstants.MAIN_SCREEN) == HtmlConstants.MAIN_SCREEN)
{
}
else
out.println("</tr>");
} | java | public void printDataEndField(PrintWriter out, int iPrintOptions)
{
if ((iPrintOptions & HtmlConstants.MAIN_SCREEN) == HtmlConstants.MAIN_SCREEN)
{
}
else
out.println("</tr>");
} | [
"public",
"void",
"printDataEndField",
"(",
"PrintWriter",
"out",
",",
"int",
"iPrintOptions",
")",
"{",
"if",
"(",
"(",
"iPrintOptions",
"&",
"HtmlConstants",
".",
"MAIN_SCREEN",
")",
"==",
"HtmlConstants",
".",
"MAIN_SCREEN",
")",
"{",
"}",
"else",
"out",
... | Display the start form in input format.
@param out The out stream.
@param iPrintOptions The view specific attributes. | [
"Display",
"the",
"start",
"form",
"in",
"input",
"format",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBasePanel.java#L587-L594 |
square/phrase | src/main/java/com/squareup/phrase/Phrase.java | Phrase.from | public static Phrase from(View v, @StringRes int patternResourceId) {
return from(v.getResources(), patternResourceId);
} | java | public static Phrase from(View v, @StringRes int patternResourceId) {
return from(v.getResources(), patternResourceId);
} | [
"public",
"static",
"Phrase",
"from",
"(",
"View",
"v",
",",
"@",
"StringRes",
"int",
"patternResourceId",
")",
"{",
"return",
"from",
"(",
"v",
".",
"getResources",
"(",
")",
",",
"patternResourceId",
")",
";",
"}"
] | Entry point into this API.
@throws IllegalArgumentException if pattern contains any syntax errors. | [
"Entry",
"point",
"into",
"this",
"API",
"."
] | train | https://github.com/square/phrase/blob/d91f18e80790832db11b811c462f8e5cd492d97e/src/main/java/com/squareup/phrase/Phrase.java#L87-L89 |
albfernandez/itext2 | src/main/java/com/lowagie/text/Section.java | Section.constructTitle | public static Paragraph constructTitle(Paragraph title, ArrayList numbers, int numberDepth, int numberStyle) {
if (title == null) {
return null;
}
int depth = Math.min(numbers.size(), numberDepth);
if (depth < 1) {
return title;
}
StringBuffer buf = new StringBuffer(" ");
for (int i = 0; i < depth; i++) {
buf.insert(0, ".");
buf.insert(0, ((Integer) numbers.get(i)).intValue());
}
if (numberStyle == NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT) {
buf.deleteCharAt(buf.length() - 2);
}
Paragraph result = new Paragraph(title);
result.add(0, new Chunk(buf.toString(), title.getFont()));
return result;
} | java | public static Paragraph constructTitle(Paragraph title, ArrayList numbers, int numberDepth, int numberStyle) {
if (title == null) {
return null;
}
int depth = Math.min(numbers.size(), numberDepth);
if (depth < 1) {
return title;
}
StringBuffer buf = new StringBuffer(" ");
for (int i = 0; i < depth; i++) {
buf.insert(0, ".");
buf.insert(0, ((Integer) numbers.get(i)).intValue());
}
if (numberStyle == NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT) {
buf.deleteCharAt(buf.length() - 2);
}
Paragraph result = new Paragraph(title);
result.add(0, new Chunk(buf.toString(), title.getFont()));
return result;
} | [
"public",
"static",
"Paragraph",
"constructTitle",
"(",
"Paragraph",
"title",
",",
"ArrayList",
"numbers",
",",
"int",
"numberDepth",
",",
"int",
"numberStyle",
")",
"{",
"if",
"(",
"title",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"int",
"depth... | Constructs a Paragraph that will be used as title for a Section or Chapter.
@param title the title of the section
@param numbers a list of sectionnumbers
@param numberDepth how many numbers have to be shown
@param numberStyle the numbering style
@return a Paragraph object
@since iText 2.0.8 | [
"Constructs",
"a",
"Paragraph",
"that",
"will",
"be",
"used",
"as",
"title",
"for",
"a",
"Section",
"or",
"Chapter",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Section.java#L470-L490 |
sdaschner/jaxrs-analyzer | src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/PathNormalizer.java | PathNormalizer.addNonBlank | private static void addNonBlank(final String string, final List<String> strings) {
if (!StringUtils.isBlank(string) && !"/".equals(string))
strings.add(string);
} | java | private static void addNonBlank(final String string, final List<String> strings) {
if (!StringUtils.isBlank(string) && !"/".equals(string))
strings.add(string);
} | [
"private",
"static",
"void",
"addNonBlank",
"(",
"final",
"String",
"string",
",",
"final",
"List",
"<",
"String",
">",
"strings",
")",
"{",
"if",
"(",
"!",
"StringUtils",
".",
"isBlank",
"(",
"string",
")",
"&&",
"!",
"\"/\"",
".",
"equals",
"(",
"str... | Adds the string to the list if it is not blank.
@param string The string to add
@param strings The list | [
"Adds",
"the",
"string",
"to",
"the",
"list",
"if",
"it",
"is",
"not",
"blank",
"."
] | train | https://github.com/sdaschner/jaxrs-analyzer/blob/4ac62942202d05632977d6c14d3cd7e2d27e2b9b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/results/PathNormalizer.java#L94-L97 |
aws/aws-sdk-java | aws-java-sdk-securityhub/src/main/java/com/amazonaws/services/securityhub/model/StandardsSubscriptionRequest.java | StandardsSubscriptionRequest.withStandardsInput | public StandardsSubscriptionRequest withStandardsInput(java.util.Map<String, String> standardsInput) {
setStandardsInput(standardsInput);
return this;
} | java | public StandardsSubscriptionRequest withStandardsInput(java.util.Map<String, String> standardsInput) {
setStandardsInput(standardsInput);
return this;
} | [
"public",
"StandardsSubscriptionRequest",
"withStandardsInput",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"standardsInput",
")",
"{",
"setStandardsInput",
"(",
"standardsInput",
")",
";",
"return",
"this",
";",
"}"
] | <p/>
@param standardsInput
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
"/",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-securityhub/src/main/java/com/amazonaws/services/securityhub/model/StandardsSubscriptionRequest.java#L157-L160 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/Update.java | Update.withExpressionAttributeNames | public Update withExpressionAttributeNames(java.util.Map<String, String> expressionAttributeNames) {
setExpressionAttributeNames(expressionAttributeNames);
return this;
} | java | public Update withExpressionAttributeNames(java.util.Map<String, String> expressionAttributeNames) {
setExpressionAttributeNames(expressionAttributeNames);
return this;
} | [
"public",
"Update",
"withExpressionAttributeNames",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"expressionAttributeNames",
")",
"{",
"setExpressionAttributeNames",
"(",
"expressionAttributeNames",
")",
";",
"return",
"this",
";",
"}"
] | <p>
One or more substitution tokens for attribute names in an expression.
</p>
@param expressionAttributeNames
One or more substitution tokens for attribute names in an expression.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"One",
"or",
"more",
"substitution",
"tokens",
"for",
"attribute",
"names",
"in",
"an",
"expression",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/Update.java#L306-L309 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/util/BufferedWriter.java | BufferedWriter.initNewBuffer | void initNewBuffer(Writer out, int bufSize)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{ // 306998.15
Tr.debug(tc, "initNewBuffer, size --> " + bufSize + " this --> " + this);
}
this.out = out;
this.except = null;
bufferSize = bufSize;
buf = new char[bufferSize];
} | java | void initNewBuffer(Writer out, int bufSize)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{ // 306998.15
Tr.debug(tc, "initNewBuffer, size --> " + bufSize + " this --> " + this);
}
this.out = out;
this.except = null;
bufferSize = bufSize;
buf = new char[bufferSize];
} | [
"void",
"initNewBuffer",
"(",
"Writer",
"out",
",",
"int",
"bufSize",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"// 306998.15",
"Tr",
".",
"debug",
"(",
"tc",
",",
... | Initializes the output stream with the specified raw output stream.
@param out
the raw output stream | [
"Initializes",
"the",
"output",
"stream",
"with",
"the",
"specified",
"raw",
"output",
"stream",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer/src/com/ibm/wsspi/webcontainer/util/BufferedWriter.java#L161-L171 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ExpressRoutePortsInner.java | ExpressRoutePortsInner.updateTagsAsync | public Observable<ExpressRoutePortInner> updateTagsAsync(String resourceGroupName, String expressRoutePortName) {
return updateTagsWithServiceResponseAsync(resourceGroupName, expressRoutePortName).map(new Func1<ServiceResponse<ExpressRoutePortInner>, ExpressRoutePortInner>() {
@Override
public ExpressRoutePortInner call(ServiceResponse<ExpressRoutePortInner> response) {
return response.body();
}
});
} | java | public Observable<ExpressRoutePortInner> updateTagsAsync(String resourceGroupName, String expressRoutePortName) {
return updateTagsWithServiceResponseAsync(resourceGroupName, expressRoutePortName).map(new Func1<ServiceResponse<ExpressRoutePortInner>, ExpressRoutePortInner>() {
@Override
public ExpressRoutePortInner call(ServiceResponse<ExpressRoutePortInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ExpressRoutePortInner",
">",
"updateTagsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"expressRoutePortName",
")",
"{",
"return",
"updateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"expressRoutePortName",
")",
"."... | Update ExpressRoutePort tags.
@param resourceGroupName The name of the resource group.
@param expressRoutePortName The name of the ExpressRoutePort resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Update",
"ExpressRoutePort",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ExpressRoutePortsInner.java#L554-L561 |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/util/SerializationUtil.java | SerializationUtil.deserialize | public <T> T deserialize(Class<T> clazz, String stringContainingSerialisedInput) {
T instance;
try {
instance = storageSerializer.deserialize(clazz, stringContainingSerialisedInput);
} catch (SerializationException e) {
throw new IllegalStateException("unable to serialise", e);
}
return instance;
} | java | public <T> T deserialize(Class<T> clazz, String stringContainingSerialisedInput) {
T instance;
try {
instance = storageSerializer.deserialize(clazz, stringContainingSerialisedInput);
} catch (SerializationException e) {
throw new IllegalStateException("unable to serialise", e);
}
return instance;
} | [
"public",
"<",
"T",
">",
"T",
"deserialize",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"String",
"stringContainingSerialisedInput",
")",
"{",
"T",
"instance",
";",
"try",
"{",
"instance",
"=",
"storageSerializer",
".",
"deserialize",
"(",
"clazz",
",",
"s... | Returns an object from a serialised string
@param clazz Class.name value
@param stringContainingSerialisedInput
@param <T>
@return | [
"Returns",
"an",
"object",
"from",
"a",
"serialised",
"string"
] | train | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/util/SerializationUtil.java#L65-L73 |
sjamesr/jfreesane | src/main/java/au/com/southsky/jfreesane/RateLimitingScanListeners.java | RateLimitingScanListeners.noMoreFrequentlyThan | public static ScanListener noMoreFrequentlyThan(
final ScanListener listener, final long time, final TimeUnit timeUnit) {
return new ScanListener() {
// Most users will only scan from one device at a time.
private Map<SaneDevice, Long> lastSentTime = Maps.newHashMapWithExpectedSize(1);
@Override
public void scanningStarted(SaneDevice device) {
listener.scanningStarted(device);
}
@Override
public void frameAcquisitionStarted(
SaneDevice device, SaneParameters parameters, int currentFrame, int likelyTotalFrames) {
listener.frameAcquisitionStarted(device, parameters, currentFrame, likelyTotalFrames);
}
@Override
public void recordRead(SaneDevice device, int totalBytesRead, int imageSizeBytes) {
long currentTime = System.currentTimeMillis();
if (!lastSentTime.containsKey(device)) {
lastSentTime.put(device, 0L);
}
if (currentTime - lastSentTime.get(device) > timeUnit.toMillis(time)) {
lastSentTime.put(device, currentTime);
listener.recordRead(device, totalBytesRead, imageSizeBytes);
}
}
@Override
public void scanningFinished(SaneDevice device) {
listener.scanningFinished(device);
}
};
} | java | public static ScanListener noMoreFrequentlyThan(
final ScanListener listener, final long time, final TimeUnit timeUnit) {
return new ScanListener() {
// Most users will only scan from one device at a time.
private Map<SaneDevice, Long> lastSentTime = Maps.newHashMapWithExpectedSize(1);
@Override
public void scanningStarted(SaneDevice device) {
listener.scanningStarted(device);
}
@Override
public void frameAcquisitionStarted(
SaneDevice device, SaneParameters parameters, int currentFrame, int likelyTotalFrames) {
listener.frameAcquisitionStarted(device, parameters, currentFrame, likelyTotalFrames);
}
@Override
public void recordRead(SaneDevice device, int totalBytesRead, int imageSizeBytes) {
long currentTime = System.currentTimeMillis();
if (!lastSentTime.containsKey(device)) {
lastSentTime.put(device, 0L);
}
if (currentTime - lastSentTime.get(device) > timeUnit.toMillis(time)) {
lastSentTime.put(device, currentTime);
listener.recordRead(device, totalBytesRead, imageSizeBytes);
}
}
@Override
public void scanningFinished(SaneDevice device) {
listener.scanningFinished(device);
}
};
} | [
"public",
"static",
"ScanListener",
"noMoreFrequentlyThan",
"(",
"final",
"ScanListener",
"listener",
",",
"final",
"long",
"time",
",",
"final",
"TimeUnit",
"timeUnit",
")",
"{",
"return",
"new",
"ScanListener",
"(",
")",
"{",
"// Most users will only scan from one d... | Returns {@link ScanListener} that calls the given listener {@link ScanListener#recordRead}
method no more frequently than the given time any one device. Record read events from one
device that occur more frequently are simply discarded. | [
"Returns",
"{"
] | train | https://github.com/sjamesr/jfreesane/blob/15ad0f73df0a8d0efec5167a2141cbd53afd862d/src/main/java/au/com/southsky/jfreesane/RateLimitingScanListeners.java#L47-L82 |
spotbugs/spotbugs | eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/util/ASTUtil.java | ASTUtil.addImports | public static void addImports(ASTRewrite rewrite, CompilationUnit compilationUnit, SortedSet<ImportDeclaration> imports) {
requireNonNull(rewrite, "ast-rewrite");
requireNonNull(compilationUnit, "compilation-unit");
requireNonNull(imports, "imports");
ListRewrite importRewrite = rewrite.getListRewrite(compilationUnit, CompilationUnit.IMPORTS_PROPERTY);
addImports(importRewrite, imports.comparator(), imports.iterator());
} | java | public static void addImports(ASTRewrite rewrite, CompilationUnit compilationUnit, SortedSet<ImportDeclaration> imports) {
requireNonNull(rewrite, "ast-rewrite");
requireNonNull(compilationUnit, "compilation-unit");
requireNonNull(imports, "imports");
ListRewrite importRewrite = rewrite.getListRewrite(compilationUnit, CompilationUnit.IMPORTS_PROPERTY);
addImports(importRewrite, imports.comparator(), imports.iterator());
} | [
"public",
"static",
"void",
"addImports",
"(",
"ASTRewrite",
"rewrite",
",",
"CompilationUnit",
"compilationUnit",
",",
"SortedSet",
"<",
"ImportDeclaration",
">",
"imports",
")",
"{",
"requireNonNull",
"(",
"rewrite",
",",
"\"ast-rewrite\"",
")",
";",
"requireNonNu... | Adds <CODE>ImportDeclaration</CODE>s to the list of imports in the
specified <CODE>CompilationUnit</CODE>. If an import already exists, the
import will not be inserted. The imports are inserted in an ordered way.
The <CODE>Comparator</CODE> of the <CODE>SortedSet</CODE> is used to sort
the imports.
@param rewrite
the <CODE>ASTRewrite</CODE>, that stores the edits.
@param compilationUnit
the <CODE>CompilationUnit</CODE>.
@param imports
the new <CODE>ImportDeclaration</CODE>s to add. | [
"Adds",
"<CODE",
">",
"ImportDeclaration<",
"/",
"CODE",
">",
"s",
"to",
"the",
"list",
"of",
"imports",
"in",
"the",
"specified",
"<CODE",
">",
"CompilationUnit<",
"/",
"CODE",
">",
".",
"If",
"an",
"import",
"already",
"exists",
"the",
"import",
"will",
... | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/edu/umd/cs/findbugs/plugin/eclipse/quickfix/util/ASTUtil.java#L146-L152 |
couchbase/couchbase-jvm-core | src/main/java/com/couchbase/client/core/utils/Events.java | Events.toJson | public static String toJson(CouchbaseEvent source, boolean pretty) {
try {
if (pretty) {
return DefaultObjectMapper.prettyWriter().writeValueAsString(source.toMap());
} else {
return DefaultObjectMapper.writeValueAsString(source.toMap());
}
} catch (JsonProcessingException e) {
throw new CouchbaseException("Could not convert CouchbaseEvent " + source.toString() + " to JSON: ", e);
}
} | java | public static String toJson(CouchbaseEvent source, boolean pretty) {
try {
if (pretty) {
return DefaultObjectMapper.prettyWriter().writeValueAsString(source.toMap());
} else {
return DefaultObjectMapper.writeValueAsString(source.toMap());
}
} catch (JsonProcessingException e) {
throw new CouchbaseException("Could not convert CouchbaseEvent " + source.toString() + " to JSON: ", e);
}
} | [
"public",
"static",
"String",
"toJson",
"(",
"CouchbaseEvent",
"source",
",",
"boolean",
"pretty",
")",
"{",
"try",
"{",
"if",
"(",
"pretty",
")",
"{",
"return",
"DefaultObjectMapper",
".",
"prettyWriter",
"(",
")",
".",
"writeValueAsString",
"(",
"source",
... | Takes a {@link CouchbaseEvent} and generates a JSON string.
@param source the source event.
@param pretty if pretty print should be used.
@return the generated json string. | [
"Takes",
"a",
"{",
"@link",
"CouchbaseEvent",
"}",
"and",
"generates",
"a",
"JSON",
"string",
"."
] | train | https://github.com/couchbase/couchbase-jvm-core/blob/97f0427112c2168fee1d6499904f5fa0e24c6797/src/main/java/com/couchbase/client/core/utils/Events.java#L57-L67 |
Coveros/selenified | src/main/java/com/coveros/selenified/element/Element.java | Element.isNotPresent | private boolean isNotPresent(String action, String expected, String extra) {
// wait for element to be present
if (!is.present()) {
waitForState.present();
}
if (!is.present()) {
reporter.fail(action, expected, extra + prettyOutput() + NOT_PRESENT);
// indicates element not present
return true;
}
return false;
} | java | private boolean isNotPresent(String action, String expected, String extra) {
// wait for element to be present
if (!is.present()) {
waitForState.present();
}
if (!is.present()) {
reporter.fail(action, expected, extra + prettyOutput() + NOT_PRESENT);
// indicates element not present
return true;
}
return false;
} | [
"private",
"boolean",
"isNotPresent",
"(",
"String",
"action",
",",
"String",
"expected",
",",
"String",
"extra",
")",
"{",
"// wait for element to be present",
"if",
"(",
"!",
"is",
".",
"present",
"(",
")",
")",
"{",
"waitForState",
".",
"present",
"(",
")... | Determines if the element is present. If it isn't, it'll wait up to the
default time (5 seconds) for the element to be present
@param action - what action is occurring
@param expected - what is the expected result
@param extra - what actually is occurring
@return Boolean: is the element present? | [
"Determines",
"if",
"the",
"element",
"is",
"present",
".",
"If",
"it",
"isn",
"t",
"it",
"ll",
"wait",
"up",
"to",
"the",
"default",
"time",
"(",
"5",
"seconds",
")",
"for",
"the",
"element",
"to",
"be",
"present"
] | train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/element/Element.java#L593-L604 |
dequelabs/axe-selenium-java | src/main/java/com/deque/axe/AXE.java | AXE.injectIntoFrames | private static void injectIntoFrames(final WebDriver driver, final String script, final ArrayList<WebElement> parents) {
final JavascriptExecutor js = (JavascriptExecutor) driver;
final List<WebElement> frames = driver.findElements(By.tagName("iframe"));
for (WebElement frame : frames) {
driver.switchTo().defaultContent();
if (parents != null) {
for (WebElement parent : parents) {
driver.switchTo().frame(parent);
}
}
driver.switchTo().frame(frame);
js.executeScript(script);
ArrayList<WebElement> localParents = (ArrayList<WebElement>) parents.clone();
localParents.add(frame);
injectIntoFrames(driver, script, localParents);
}
} | java | private static void injectIntoFrames(final WebDriver driver, final String script, final ArrayList<WebElement> parents) {
final JavascriptExecutor js = (JavascriptExecutor) driver;
final List<WebElement> frames = driver.findElements(By.tagName("iframe"));
for (WebElement frame : frames) {
driver.switchTo().defaultContent();
if (parents != null) {
for (WebElement parent : parents) {
driver.switchTo().frame(parent);
}
}
driver.switchTo().frame(frame);
js.executeScript(script);
ArrayList<WebElement> localParents = (ArrayList<WebElement>) parents.clone();
localParents.add(frame);
injectIntoFrames(driver, script, localParents);
}
} | [
"private",
"static",
"void",
"injectIntoFrames",
"(",
"final",
"WebDriver",
"driver",
",",
"final",
"String",
"script",
",",
"final",
"ArrayList",
"<",
"WebElement",
">",
"parents",
")",
"{",
"final",
"JavascriptExecutor",
"js",
"=",
"(",
"JavascriptExecutor",
"... | Recursively find frames and inject a script into them.
@param driver An initialized WebDriver
@param script Script to inject
@param parents A list of all toplevel frames | [
"Recursively",
"find",
"frames",
"and",
"inject",
"a",
"script",
"into",
"them",
"."
] | train | https://github.com/dequelabs/axe-selenium-java/blob/68b35ff46c59111b0e9a9f573380c3d250bcfd65/src/main/java/com/deque/axe/AXE.java#L97-L118 |
tvbarthel/Cheerleader | library/src/main/java/fr/tvbarthel/cheerleader/library/player/NotificationManager.java | NotificationManager.initializePendingIntent | private void initializePendingIntent(Context context) {
// toggle playback
Intent togglePlaybackIntent = new Intent(context, PlaybackService.class);
togglePlaybackIntent.setAction(PlaybackService.ACTION_TOGGLE_PLAYBACK);
mTogglePlaybackPendingIntent = PendingIntent.getService(context, REQUEST_CODE_PLAYBACK,
togglePlaybackIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// next track
Intent nextPrendingIntent = new Intent(context, PlaybackService.class);
nextPrendingIntent.setAction(PlaybackService.ACTION_NEXT_TRACK);
mNextPendingIntent = PendingIntent.getService(context, REQUEST_CODE_NEXT,
nextPrendingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// previous track
Intent previousPendingIntent = new Intent(context, PlaybackService.class);
previousPendingIntent.setAction(PlaybackService.ACTION_PREVIOUS_TRACK);
mPreviousPendingIntent = PendingIntent.getService(context, REQUEST_CODE_PREVIOUS,
previousPendingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// clear notification
Intent clearPendingIntent = new Intent(context, PlaybackService.class);
clearPendingIntent.setAction(PlaybackService.ACTION_CLEAR_NOTIFICATION);
mClearPendingIntent = PendingIntent.getService(context, REQUEST_CODE_CLEAR,
clearPendingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
} | java | private void initializePendingIntent(Context context) {
// toggle playback
Intent togglePlaybackIntent = new Intent(context, PlaybackService.class);
togglePlaybackIntent.setAction(PlaybackService.ACTION_TOGGLE_PLAYBACK);
mTogglePlaybackPendingIntent = PendingIntent.getService(context, REQUEST_CODE_PLAYBACK,
togglePlaybackIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// next track
Intent nextPrendingIntent = new Intent(context, PlaybackService.class);
nextPrendingIntent.setAction(PlaybackService.ACTION_NEXT_TRACK);
mNextPendingIntent = PendingIntent.getService(context, REQUEST_CODE_NEXT,
nextPrendingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// previous track
Intent previousPendingIntent = new Intent(context, PlaybackService.class);
previousPendingIntent.setAction(PlaybackService.ACTION_PREVIOUS_TRACK);
mPreviousPendingIntent = PendingIntent.getService(context, REQUEST_CODE_PREVIOUS,
previousPendingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// clear notification
Intent clearPendingIntent = new Intent(context, PlaybackService.class);
clearPendingIntent.setAction(PlaybackService.ACTION_CLEAR_NOTIFICATION);
mClearPendingIntent = PendingIntent.getService(context, REQUEST_CODE_CLEAR,
clearPendingIntent, PendingIntent.FLAG_UPDATE_CURRENT);
} | [
"private",
"void",
"initializePendingIntent",
"(",
"Context",
"context",
")",
"{",
"// toggle playback",
"Intent",
"togglePlaybackIntent",
"=",
"new",
"Intent",
"(",
"context",
",",
"PlaybackService",
".",
"class",
")",
";",
"togglePlaybackIntent",
".",
"setAction",
... | Initialize {@link android.app.PendingIntent} used for notification actions.
@param context context used to instantiate intent. | [
"Initialize",
"{",
"@link",
"android",
".",
"app",
".",
"PendingIntent",
"}",
"used",
"for",
"notification",
"actions",
"."
] | train | https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/player/NotificationManager.java#L256-L281 |
pwall567/jsonutil | src/main/java/net/pwall/json/JSONObject.java | JSONObject.putAlways | public JSONObject putAlways(String key, CharSequence value) {
put(key, value == null ? null : new JSONString(value));
return this;
} | java | public JSONObject putAlways(String key, CharSequence value) {
put(key, value == null ? null : new JSONString(value));
return this;
} | [
"public",
"JSONObject",
"putAlways",
"(",
"String",
"key",
",",
"CharSequence",
"value",
")",
"{",
"put",
"(",
"key",
",",
"value",
"==",
"null",
"?",
"null",
":",
"new",
"JSONString",
"(",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add a {@link JSONString} representing the supplied {@link CharSequence} ({@link String},
{@link StringBuilder} etc.) to the {@code JSONObject}, storing a {@code null} if the
value is {@code null}.
@param key the key to use when storing the value
@param value the value (may be {@code null})
@return {@code this} (for chaining)
@throws NullPointerException if key is {@code null} | [
"Add",
"a",
"{",
"@link",
"JSONString",
"}",
"representing",
"the",
"supplied",
"{",
"@link",
"CharSequence",
"}",
"(",
"{",
"@link",
"String",
"}",
"{",
"@link",
"StringBuilder",
"}",
"etc",
".",
")",
"to",
"the",
"{",
"@code",
"JSONObject",
"}",
"stori... | train | https://github.com/pwall567/jsonutil/blob/dd5960b9b0bcc9acfe6c52b884fffd9ee5f422fe/src/main/java/net/pwall/json/JSONObject.java#L87-L90 |
Alluxio/alluxio | integration/yarn/src/main/java/alluxio/yarn/ApplicationMaster.java | ApplicationMaster.runApplicationMaster | private static void runApplicationMaster(final CommandLine cliParser,
AlluxioConfiguration alluxioConf) throws Exception {
int numWorkers = Integer.parseInt(cliParser.getOptionValue("num_workers", "1"));
String masterAddress = cliParser.getOptionValue("master_address");
String resourcePath = cliParser.getOptionValue("resource_path");
ApplicationMaster applicationMaster =
new ApplicationMaster(numWorkers, masterAddress, resourcePath, alluxioConf);
applicationMaster.start();
applicationMaster.requestAndLaunchContainers();
applicationMaster.waitForShutdown();
applicationMaster.stop();
} | java | private static void runApplicationMaster(final CommandLine cliParser,
AlluxioConfiguration alluxioConf) throws Exception {
int numWorkers = Integer.parseInt(cliParser.getOptionValue("num_workers", "1"));
String masterAddress = cliParser.getOptionValue("master_address");
String resourcePath = cliParser.getOptionValue("resource_path");
ApplicationMaster applicationMaster =
new ApplicationMaster(numWorkers, masterAddress, resourcePath, alluxioConf);
applicationMaster.start();
applicationMaster.requestAndLaunchContainers();
applicationMaster.waitForShutdown();
applicationMaster.stop();
} | [
"private",
"static",
"void",
"runApplicationMaster",
"(",
"final",
"CommandLine",
"cliParser",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"throws",
"Exception",
"{",
"int",
"numWorkers",
"=",
"Integer",
".",
"parseInt",
"(",
"cliParser",
".",
"getOptionValue",
... | Run the application master.
@param cliParser client arguments parser | [
"Run",
"the",
"application",
"master",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/yarn/src/main/java/alluxio/yarn/ApplicationMaster.java#L233-L245 |
pressgang-ccms/PressGangCCMSQuery | src/main/java/org/jboss/pressgang/ccms/filter/base/BaseFilterQueryBuilder.java | BaseFilterQueryBuilder.addIdInCommaSeparatedListCondition | protected void addIdInCommaSeparatedListCondition(final String propertyName, final String value) throws NumberFormatException {
addIdInArrayCondition(propertyName, value.split(","));
} | java | protected void addIdInCommaSeparatedListCondition(final String propertyName, final String value) throws NumberFormatException {
addIdInArrayCondition(propertyName, value.split(","));
} | [
"protected",
"void",
"addIdInCommaSeparatedListCondition",
"(",
"final",
"String",
"propertyName",
",",
"final",
"String",
"value",
")",
"throws",
"NumberFormatException",
"{",
"addIdInArrayCondition",
"(",
"propertyName",
",",
"value",
".",
"split",
"(",
"\",\"",
")"... | Add a Field Search Condition that will check if the id field exists in a comma separated list of ids. eg.
{@code field IN (value)}
@param propertyName The name of the field id as defined in the Entity mapping class.
@param value The comma separated list of ids.
@throws NumberFormatException Thrown if one of the Strings cannot be converted to an Integer. | [
"Add",
"a",
"Field",
"Search",
"Condition",
"that",
"will",
"check",
"if",
"the",
"id",
"field",
"exists",
"in",
"a",
"comma",
"separated",
"list",
"of",
"ids",
".",
"eg",
".",
"{",
"@code",
"field",
"IN",
"(",
"value",
")",
"}"
] | train | https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/base/BaseFilterQueryBuilder.java#L347-L349 |
jcuda/jcusolver | JCusolverJava/src/main/java/jcuda/jcusolver/JCusolverSp.java | JCusolverSp.cusolverSpScsreigvsi | public static int cusolverSpScsreigvsi(
cusolverSpHandle handle,
int m,
int nnz,
cusparseMatDescr descrA,
Pointer csrValA,
Pointer csrRowPtrA,
Pointer csrColIndA,
float mu0,
Pointer x0,
int maxite,
float eps,
Pointer mu,
Pointer x)
{
return checkResult(cusolverSpScsreigvsiNative(handle, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, mu0, x0, maxite, eps, mu, x));
} | java | public static int cusolverSpScsreigvsi(
cusolverSpHandle handle,
int m,
int nnz,
cusparseMatDescr descrA,
Pointer csrValA,
Pointer csrRowPtrA,
Pointer csrColIndA,
float mu0,
Pointer x0,
int maxite,
float eps,
Pointer mu,
Pointer x)
{
return checkResult(cusolverSpScsreigvsiNative(handle, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, mu0, x0, maxite, eps, mu, x));
} | [
"public",
"static",
"int",
"cusolverSpScsreigvsi",
"(",
"cusolverSpHandle",
"handle",
",",
"int",
"m",
",",
"int",
"nnz",
",",
"cusparseMatDescr",
"descrA",
",",
"Pointer",
"csrValA",
",",
"Pointer",
"csrRowPtrA",
",",
"Pointer",
"csrColIndA",
",",
"float",
"mu0... | <pre>
--------- GPU eigenvalue solver by shift inverse
solve A*x = lambda * x
where lambda is the eigenvalue nearest mu0.
[eig] stands for eigenvalue solver
[si] stands for shift-inverse
</pre> | [
"<pre",
">",
"---------",
"GPU",
"eigenvalue",
"solver",
"by",
"shift",
"inverse",
"solve",
"A",
"*",
"x",
"=",
"lambda",
"*",
"x",
"where",
"lambda",
"is",
"the",
"eigenvalue",
"nearest",
"mu0",
".",
"[",
"eig",
"]",
"stands",
"for",
"eigenvalue",
"solv... | train | https://github.com/jcuda/jcusolver/blob/2600c7eca36a92a60ebcc78cae6e028e0c1d00b9/JCusolverJava/src/main/java/jcuda/jcusolver/JCusolverSp.java#L1106-L1122 |
Mozu/mozu-java | mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/DiscountUrl.java | DiscountUrl.getDiscountContentUrl | public static MozuUrl getDiscountContentUrl(Integer discountId, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/discounts/{discountId}/content?responseFields={responseFields}");
formatter.formatUrl("discountId", discountId);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl getDiscountContentUrl(Integer discountId, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/discounts/{discountId}/content?responseFields={responseFields}");
formatter.formatUrl("discountId", discountId);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"getDiscountContentUrl",
"(",
"Integer",
"discountId",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/catalog/admin/discounts/{discountId}/content?responseFields={responseFie... | Get Resource Url for GetDiscountContent
@param discountId discountId parameter description DOCUMENT_HERE
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"GetDiscountContent"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/commerce/catalog/admin/DiscountUrl.java#L42-L48 |
sarl/sarl | main/externalmaven/io.sarl.maven.sre/src/main/java/io/sarl/maven/sre/AbstractSREMojo.java | AbstractSREMojo.createSREManifest | protected Manifest createSREManifest() throws MojoExecutionException, MojoFailureException {
final Manifest manifest = new Manifest();
final String mainClass = getMainClass();
if (mainClass.isEmpty()) {
throw new MojoFailureException("the main class of the SRE is missed"); //$NON-NLS-1$
}
ManifestUpdater updater = getManifestUpdater();
if (updater == null) {
updater = new ManifestUpdater() {
@Override
public void addSREAttribute(String name, String value) {
assert name != null && !name.isEmpty();
if (value != null && !value.isEmpty()) {
getLog().debug("Adding to SRE manifest: " + name + " = " + value); //$NON-NLS-1$//$NON-NLS-2$
final Map<String, Attributes> entries = manifest.getEntries();
Attributes attrs = entries.get(SREConstants.MANIFEST_SECTION_SRE);
if (attrs == null) {
attrs = new Attributes();
entries.put(SREConstants.MANIFEST_SECTION_SRE, attrs);
}
attrs.put(new Attributes.Name(name), value);
}
}
@Override
public void addMainAttribute(String name, String value) {
assert name != null && !name.isEmpty();
if (value != null && !value.isEmpty()) {
getLog().debug("Adding to SRE manifest: " + name + " = " + value); //$NON-NLS-1$//$NON-NLS-2$
manifest.getMainAttributes().put(new Attributes.Name(name), value);
}
}
};
}
buildManifest(updater, mainClass);
return manifest;
} | java | protected Manifest createSREManifest() throws MojoExecutionException, MojoFailureException {
final Manifest manifest = new Manifest();
final String mainClass = getMainClass();
if (mainClass.isEmpty()) {
throw new MojoFailureException("the main class of the SRE is missed"); //$NON-NLS-1$
}
ManifestUpdater updater = getManifestUpdater();
if (updater == null) {
updater = new ManifestUpdater() {
@Override
public void addSREAttribute(String name, String value) {
assert name != null && !name.isEmpty();
if (value != null && !value.isEmpty()) {
getLog().debug("Adding to SRE manifest: " + name + " = " + value); //$NON-NLS-1$//$NON-NLS-2$
final Map<String, Attributes> entries = manifest.getEntries();
Attributes attrs = entries.get(SREConstants.MANIFEST_SECTION_SRE);
if (attrs == null) {
attrs = new Attributes();
entries.put(SREConstants.MANIFEST_SECTION_SRE, attrs);
}
attrs.put(new Attributes.Name(name), value);
}
}
@Override
public void addMainAttribute(String name, String value) {
assert name != null && !name.isEmpty();
if (value != null && !value.isEmpty()) {
getLog().debug("Adding to SRE manifest: " + name + " = " + value); //$NON-NLS-1$//$NON-NLS-2$
manifest.getMainAttributes().put(new Attributes.Name(name), value);
}
}
};
}
buildManifest(updater, mainClass);
return manifest;
} | [
"protected",
"Manifest",
"createSREManifest",
"(",
")",
"throws",
"MojoExecutionException",
",",
"MojoFailureException",
"{",
"final",
"Manifest",
"manifest",
"=",
"new",
"Manifest",
"(",
")",
";",
"final",
"String",
"mainClass",
"=",
"getMainClass",
"(",
")",
";"... | Create the manifest of the SRE.
@return the created manifest.
@throws MojoExecutionException if the mojo fails.
@throws MojoFailureException if the generation fails. | [
"Create",
"the",
"manifest",
"of",
"the",
"SRE",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/externalmaven/io.sarl.maven.sre/src/main/java/io/sarl/maven/sre/AbstractSREMojo.java#L325-L367 |
MenoData/Time4J | base/src/main/java/net/time4j/clock/DaytimeClock.java | DaytimeClock.getRawTimestamp | public String getRawTimestamp() throws IOException {
final NetTimeConfiguration config = this.getNetTimeConfiguration();
String address = config.getTimeServerAddress();
int port = config.getTimeServerPort();
int timeout = config.getConnectionTimeout();
return getDaytimeReply(address, port, timeout);
} | java | public String getRawTimestamp() throws IOException {
final NetTimeConfiguration config = this.getNetTimeConfiguration();
String address = config.getTimeServerAddress();
int port = config.getTimeServerPort();
int timeout = config.getConnectionTimeout();
return getDaytimeReply(address, port, timeout);
} | [
"public",
"String",
"getRawTimestamp",
"(",
")",
"throws",
"IOException",
"{",
"final",
"NetTimeConfiguration",
"config",
"=",
"this",
".",
"getNetTimeConfiguration",
"(",
")",
";",
"String",
"address",
"=",
"config",
".",
"getTimeServerAddress",
"(",
")",
";",
... | /*[deutsch]
<p>Versucht, den Original-Server-Zeitstempel zu lesen. </p>
@return unparsed server reply
@throws IOException if connection fails
@since 2.1 | [
"/",
"*",
"[",
"deutsch",
"]",
"<p",
">",
"Versucht",
"den",
"Original",
"-",
"Server",
"-",
"Zeitstempel",
"zu",
"lesen",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/clock/DaytimeClock.java#L175-L185 |
Stratio/bdt | src/main/java/com/stratio/qa/specs/RestSpec.java | RestSpec.sendRequestNoDataTable | @When("^I send a '(.+?)' request to '(.+?)'( with user and password '(.+:.+?)')?( based on '([^:]+?)')?( as '(json|string|gov)')?$")
public void sendRequestNoDataTable(String requestType, String endPoint, String foo, String loginInfo, String bar, String baseData, String baz, String type) throws Exception {
Future<Response> response;
String user = null;
String password = null;
if (loginInfo != null) {
user = loginInfo.substring(0, loginInfo.indexOf(':'));
password = loginInfo.substring(loginInfo.indexOf(':') + 1, loginInfo.length());
}
if (baseData != null) {
// Retrieve data
String retrievedData = commonspec.retrieveData(baseData, type);
// Generate request
response = commonspec.generateRequest(requestType, false, user, password, endPoint, retrievedData, type, "");
} else {
// Generate request
response = commonspec.generateRequest(requestType, false, user, password, endPoint, "", type, "");
}
// Save response
commonspec.setResponse(requestType, response.get());
} | java | @When("^I send a '(.+?)' request to '(.+?)'( with user and password '(.+:.+?)')?( based on '([^:]+?)')?( as '(json|string|gov)')?$")
public void sendRequestNoDataTable(String requestType, String endPoint, String foo, String loginInfo, String bar, String baseData, String baz, String type) throws Exception {
Future<Response> response;
String user = null;
String password = null;
if (loginInfo != null) {
user = loginInfo.substring(0, loginInfo.indexOf(':'));
password = loginInfo.substring(loginInfo.indexOf(':') + 1, loginInfo.length());
}
if (baseData != null) {
// Retrieve data
String retrievedData = commonspec.retrieveData(baseData, type);
// Generate request
response = commonspec.generateRequest(requestType, false, user, password, endPoint, retrievedData, type, "");
} else {
// Generate request
response = commonspec.generateRequest(requestType, false, user, password, endPoint, "", type, "");
}
// Save response
commonspec.setResponse(requestType, response.get());
} | [
"@",
"When",
"(",
"\"^I send a '(.+?)' request to '(.+?)'( with user and password '(.+:.+?)')?( based on '([^:]+?)')?( as '(json|string|gov)')?$\"",
")",
"public",
"void",
"sendRequestNoDataTable",
"(",
"String",
"requestType",
",",
"String",
"endPoint",
",",
"String",
"foo",
",",
... | Same sendRequest, but in this case, we do not receive a data table with modifications.
Besides, the data and request header are optional as well.
In case we want to simulate sending a json request with empty data, we just to avoid baseData
@param requestType
@param endPoint
@param foo
@param baseData
@param bar
@param type
@throws Exception | [
"Same",
"sendRequest",
"but",
"in",
"this",
"case",
"we",
"do",
"not",
"receive",
"a",
"data",
"table",
"with",
"modifications",
".",
"Besides",
"the",
"data",
"and",
"request",
"header",
"are",
"optional",
"as",
"well",
".",
"In",
"case",
"we",
"want",
... | train | https://github.com/Stratio/bdt/blob/55324d19e7497764ad3dd7139923e13eb9841d75/src/main/java/com/stratio/qa/specs/RestSpec.java#L242-L265 |
headius/invokebinder | src/main/java/com/headius/invokebinder/Signature.java | Signature.appendArg | public Signature appendArg(String name, Class<?> type) {
String[] newArgNames = new String[argNames.length + 1];
System.arraycopy(argNames, 0, newArgNames, 0, argNames.length);
newArgNames[argNames.length] = name;
MethodType newMethodType = methodType.appendParameterTypes(type);
return new Signature(newMethodType, newArgNames);
} | java | public Signature appendArg(String name, Class<?> type) {
String[] newArgNames = new String[argNames.length + 1];
System.arraycopy(argNames, 0, newArgNames, 0, argNames.length);
newArgNames[argNames.length] = name;
MethodType newMethodType = methodType.appendParameterTypes(type);
return new Signature(newMethodType, newArgNames);
} | [
"public",
"Signature",
"appendArg",
"(",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"String",
"[",
"]",
"newArgNames",
"=",
"new",
"String",
"[",
"argNames",
".",
"length",
"+",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"a... | Append an argument (name + type) to the signature.
@param name the name of the argument
@param type the type of the argument
@return a new signature with the added arguments | [
"Append",
"an",
"argument",
"(",
"name",
"+",
"type",
")",
"to",
"the",
"signature",
"."
] | train | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Signature.java#L187-L193 |
ag-gipp/MathMLTools | mathml-similarity/src/main/java/com/formulasearchengine/mathmltools/similarity/SubTreeComparison.java | SubTreeComparison.getCoverage | public static double getCoverage(List<MathNode> refLeafs, List<MathNode> compLeafs) {
if (compLeafs.size() == 0) {
return 1.;
}
HashMultiset<MathNode> tmp = HashMultiset.create();
tmp.addAll(compLeafs);
tmp.removeAll(refLeafs);
return 1 - (double) tmp.size() / (double) compLeafs.size();
} | java | public static double getCoverage(List<MathNode> refLeafs, List<MathNode> compLeafs) {
if (compLeafs.size() == 0) {
return 1.;
}
HashMultiset<MathNode> tmp = HashMultiset.create();
tmp.addAll(compLeafs);
tmp.removeAll(refLeafs);
return 1 - (double) tmp.size() / (double) compLeafs.size();
} | [
"public",
"static",
"double",
"getCoverage",
"(",
"List",
"<",
"MathNode",
">",
"refLeafs",
",",
"List",
"<",
"MathNode",
">",
"compLeafs",
")",
"{",
"if",
"(",
"compLeafs",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"1.",
";",
"}",
"HashM... | Calculate the coverage factor between two trees, whereas only their leafs
are considered. Leafs are typically identifiers or constants.
@param refLeafs all leafs from the partial (or full) reference tree
@param compLeafs all leafs from the partial (or full) comparison tree
@return coverage factor between 0 to 1, 1 is a full-match | [
"Calculate",
"the",
"coverage",
"factor",
"between",
"two",
"trees",
"whereas",
"only",
"their",
"leafs",
"are",
"considered",
".",
"Leafs",
"are",
"typically",
"identifiers",
"or",
"constants",
"."
] | train | https://github.com/ag-gipp/MathMLTools/blob/77c69b6366a5b8720796d1cd9d155ba26c2f1b20/mathml-similarity/src/main/java/com/formulasearchengine/mathmltools/similarity/SubTreeComparison.java#L153-L161 |
twitter/cloudhopper-commons | ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/util/PropertiesReplacementUtil.java | PropertiesReplacementUtil.replace | static public InputStream replace(File file, File props) throws IOException, SubstitutionException{
return replace(file, props, null, false);
} | java | static public InputStream replace(File file, File props) throws IOException, SubstitutionException{
return replace(file, props, null, false);
} | [
"static",
"public",
"InputStream",
"replace",
"(",
"File",
"file",
",",
"File",
"props",
")",
"throws",
"IOException",
",",
"SubstitutionException",
"{",
"return",
"replace",
"(",
"file",
",",
"props",
",",
"null",
",",
"false",
")",
";",
"}"
] | Creates an InputStream containing the document resulting from replacing template
parameters in the given file.
@param file The template file
@param props The properties file
@return An InputStream containing the resulting document. | [
"Creates",
"an",
"InputStream",
"containing",
"the",
"document",
"resulting",
"from",
"replacing",
"template",
"parameters",
"in",
"the",
"given",
"file",
"."
] | train | https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/util/PropertiesReplacementUtil.java#L74-L76 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/factory/feature/detect/interest/FactoryInterestPointAlgs.java | FactoryInterestPointAlgs.hessianLaplace | public static <T extends ImageGray<T>, D extends ImageGray<D>>
FeatureLaplacePyramid<T, D> hessianLaplace(int extractRadius,
float detectThreshold,
int maxFeatures,
Class<T> imageType,
Class<D> derivType) {
GeneralFeatureIntensity<T, D> intensity = new WrapperHessianBlobIntensity<>(HessianBlobIntensity.Type.DETERMINANT, derivType);
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(
new ConfigExtract(extractRadius, detectThreshold, extractRadius, true));
GeneralFeatureDetector<T, D> detector = new GeneralFeatureDetector<>(intensity, extractor);
detector.setMaxFeatures(maxFeatures);
AnyImageDerivative<T, D> deriv = GImageDerivativeOps.derivativeForScaleSpace(imageType, derivType);
ImageFunctionSparse<T> sparseLaplace = FactoryDerivativeSparse.createLaplacian(imageType, null);
return new FeatureLaplacePyramid<>(detector, sparseLaplace, deriv, 2);
} | java | public static <T extends ImageGray<T>, D extends ImageGray<D>>
FeatureLaplacePyramid<T, D> hessianLaplace(int extractRadius,
float detectThreshold,
int maxFeatures,
Class<T> imageType,
Class<D> derivType) {
GeneralFeatureIntensity<T, D> intensity = new WrapperHessianBlobIntensity<>(HessianBlobIntensity.Type.DETERMINANT, derivType);
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(
new ConfigExtract(extractRadius, detectThreshold, extractRadius, true));
GeneralFeatureDetector<T, D> detector = new GeneralFeatureDetector<>(intensity, extractor);
detector.setMaxFeatures(maxFeatures);
AnyImageDerivative<T, D> deriv = GImageDerivativeOps.derivativeForScaleSpace(imageType, derivType);
ImageFunctionSparse<T> sparseLaplace = FactoryDerivativeSparse.createLaplacian(imageType, null);
return new FeatureLaplacePyramid<>(detector, sparseLaplace, deriv, 2);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
",",
"D",
"extends",
"ImageGray",
"<",
"D",
">",
">",
"FeatureLaplacePyramid",
"<",
"T",
",",
"D",
">",
"hessianLaplace",
"(",
"int",
"extractRadius",
",",
"float",
"detectThreshold",
","... | Creates a {@link boofcv.alg.feature.detect.interest.FeatureLaplacePyramid} which is uses a hessian blob detector.
@param extractRadius Size of the feature used to detect the corners.
@param detectThreshold Minimum corner intensity required
@param maxFeatures Max number of features that can be found.
@param imageType Type of input image.
@param derivType Image derivative type.
@return CornerLaplaceScaleSpace | [
"Creates",
"a",
"{",
"@link",
"boofcv",
".",
"alg",
".",
"feature",
".",
"detect",
".",
"interest",
".",
"FeatureLaplacePyramid",
"}",
"which",
"is",
"uses",
"a",
"hessian",
"blob",
"detector",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/detect/interest/FactoryInterestPointAlgs.java#L115-L132 |
kiswanij/jk-util | src/main/java/com/jk/util/JKDateTimeUtil.java | JKDateTimeUtil.isDateEqaualed | public static boolean isDateEqaualed(final java.util.Date date1, final java.util.Date date2) {
final String d1 = JKFormatUtil.formatDate(date1, JKFormatUtil.MYSQL_DATE_DB_PATTERN);
final String d2 = JKFormatUtil.formatDate(date2, JKFormatUtil.MYSQL_DATE_DB_PATTERN);
return d1.equalsIgnoreCase(d2);
} | java | public static boolean isDateEqaualed(final java.util.Date date1, final java.util.Date date2) {
final String d1 = JKFormatUtil.formatDate(date1, JKFormatUtil.MYSQL_DATE_DB_PATTERN);
final String d2 = JKFormatUtil.formatDate(date2, JKFormatUtil.MYSQL_DATE_DB_PATTERN);
return d1.equalsIgnoreCase(d2);
} | [
"public",
"static",
"boolean",
"isDateEqaualed",
"(",
"final",
"java",
".",
"util",
".",
"Date",
"date1",
",",
"final",
"java",
".",
"util",
".",
"Date",
"date2",
")",
"{",
"final",
"String",
"d1",
"=",
"JKFormatUtil",
".",
"formatDate",
"(",
"date1",
",... | Checks if is date eqaualed.
@param date1 the date 1
@param date2 the date 2
@return true, if is date eqaualed | [
"Checks",
"if",
"is",
"date",
"eqaualed",
"."
] | train | https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/JKDateTimeUtil.java#L514-L518 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/util/ComparatorUtils.java | ComparatorUtils.compareIgnoreNull | @NullSafe
public static <T extends Comparable<T>> int compareIgnoreNull(T obj1, T obj2) {
return (obj1 == null ? 1 : (obj2 == null ? -1 : obj1.compareTo(obj2)));
} | java | @NullSafe
public static <T extends Comparable<T>> int compareIgnoreNull(T obj1, T obj2) {
return (obj1 == null ? 1 : (obj2 == null ? -1 : obj1.compareTo(obj2)));
} | [
"@",
"NullSafe",
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"T",
">",
">",
"int",
"compareIgnoreNull",
"(",
"T",
"obj1",
",",
"T",
"obj2",
")",
"{",
"return",
"(",
"obj1",
"==",
"null",
"?",
"1",
":",
"(",
"obj2",
"==",
"null",
"?"... | Compares two {@link Comparable} objects for absolute ordering, ignoring possible {@literal null} values.
Sorts (orders) {@literal null} values last.
@param <T> {@link Class} type of {@link Comparable} objects in the comparison.
@param obj1 {@link Comparable} object being compared with {@code obj2}.
@param obj2 {@link Comparable} object being compared with {@code obj1}.
@return a integer value indicating the absolute ordering of the {@link Comparable} objects
as defined by their declared, natural ordering.
@see java.lang.Comparable | [
"Compares",
"two",
"{",
"@link",
"Comparable",
"}",
"objects",
"for",
"absolute",
"ordering",
"ignoring",
"possible",
"{",
"@literal",
"null",
"}",
"values",
".",
"Sorts",
"(",
"orders",
")",
"{",
"@literal",
"null",
"}",
"values",
"last",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/ComparatorUtils.java#L46-L49 |
biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/util/StringManipulationHelper.java | StringManipulationHelper.equalsToIgnoreEndline | public static boolean equalsToIgnoreEndline(String expected, String actual) {
if (expected == null && actual == null) {
return true;
}
if (expected != null ^ actual != null) {
return false;
}
Scanner scanner1 = new Scanner(expected);
Scanner scanner2 = new Scanner(actual);
String line1, line2;
while (scanner1.hasNextLine()) {
line1 = scanner1.nextLine();
line2 = scanner2.nextLine();
if (! line1.equals(line2)) {
scanner1.close();
scanner2.close();
return false;
}
}
if (scanner2.hasNextLine()) {
scanner1.close();
scanner2.close();
return false;
}
scanner1.close();
scanner2.close();
return true;
} | java | public static boolean equalsToIgnoreEndline(String expected, String actual) {
if (expected == null && actual == null) {
return true;
}
if (expected != null ^ actual != null) {
return false;
}
Scanner scanner1 = new Scanner(expected);
Scanner scanner2 = new Scanner(actual);
String line1, line2;
while (scanner1.hasNextLine()) {
line1 = scanner1.nextLine();
line2 = scanner2.nextLine();
if (! line1.equals(line2)) {
scanner1.close();
scanner2.close();
return false;
}
}
if (scanner2.hasNextLine()) {
scanner1.close();
scanner2.close();
return false;
}
scanner1.close();
scanner2.close();
return true;
} | [
"public",
"static",
"boolean",
"equalsToIgnoreEndline",
"(",
"String",
"expected",
",",
"String",
"actual",
")",
"{",
"if",
"(",
"expected",
"==",
"null",
"&&",
"actual",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"expected",
"!=",
"n... | compares two strings for equality, line by line, ignoring any difference
of end line delimiters contained within the 2 Strings. This method should
be used if and only if two Strings are considered identical when all nodes
are identical including their relative order. Generally useful when
asserting identity of <b>automatically regenerated</b> XML or PDB.
@param expected
@param actual | [
"compares",
"two",
"strings",
"for",
"equality",
"line",
"by",
"line",
"ignoring",
"any",
"difference",
"of",
"end",
"line",
"delimiters",
"contained",
"within",
"the",
"2",
"Strings",
".",
"This",
"method",
"should",
"be",
"used",
"if",
"and",
"only",
"if",... | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/util/StringManipulationHelper.java#L107-L135 |
VoltDB/voltdb | src/frontend/org/voltdb/expressions/AbstractExpression.java | AbstractExpression.isValidExprForIndexesAndMVs | public boolean isValidExprForIndexesAndMVs(StringBuffer msg, boolean isMV) {
if (containsFunctionById(FunctionSQL.voltGetCurrentTimestampId())) {
msg.append("cannot include the function NOW or CURRENT_TIMESTAMP.");
return false;
} else if (hasAnySubexpressionOfClass(AggregateExpression.class)) {
msg.append("cannot contain aggregate expressions.");
return false;
} else if (hasAnySubexpressionOfClass(AbstractSubqueryExpression.class)) {
// There may not be any of these in HSQL1.9.3b. However, in
// HSQL2.3.2 subqueries are stored as expressions. So, we may
// find some here. We will keep it here for the moment.
if (isMV) {
msg.append("cannot contain subquery sources.");
} else {
msg.append("cannot contain subqueries.");
}
return false;
} else if (hasUserDefinedFunctionExpression()) {
msg.append("cannot contain calls to user defined functions.");
return false;
} else {
return true;
}
} | java | public boolean isValidExprForIndexesAndMVs(StringBuffer msg, boolean isMV) {
if (containsFunctionById(FunctionSQL.voltGetCurrentTimestampId())) {
msg.append("cannot include the function NOW or CURRENT_TIMESTAMP.");
return false;
} else if (hasAnySubexpressionOfClass(AggregateExpression.class)) {
msg.append("cannot contain aggregate expressions.");
return false;
} else if (hasAnySubexpressionOfClass(AbstractSubqueryExpression.class)) {
// There may not be any of these in HSQL1.9.3b. However, in
// HSQL2.3.2 subqueries are stored as expressions. So, we may
// find some here. We will keep it here for the moment.
if (isMV) {
msg.append("cannot contain subquery sources.");
} else {
msg.append("cannot contain subqueries.");
}
return false;
} else if (hasUserDefinedFunctionExpression()) {
msg.append("cannot contain calls to user defined functions.");
return false;
} else {
return true;
}
} | [
"public",
"boolean",
"isValidExprForIndexesAndMVs",
"(",
"StringBuffer",
"msg",
",",
"boolean",
"isMV",
")",
"{",
"if",
"(",
"containsFunctionById",
"(",
"FunctionSQL",
".",
"voltGetCurrentTimestampId",
"(",
")",
")",
")",
"{",
"msg",
".",
"append",
"(",
"\"cann... | Return true if the given expression usable as part of an index or MV's
group by and where clause expression.
If false, put the tail of an error message in the string buffer. The
string buffer will be initialized with the name of the index.
@param expr The expression to check
@param msg The StringBuffer to pack with the error message tail.
@return true iff the expression can be part of an index. | [
"Return",
"true",
"if",
"the",
"given",
"expression",
"usable",
"as",
"part",
"of",
"an",
"index",
"or",
"MV",
"s",
"group",
"by",
"and",
"where",
"clause",
"expression",
".",
"If",
"false",
"put",
"the",
"tail",
"of",
"an",
"error",
"message",
"in",
"... | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/expressions/AbstractExpression.java#L1301-L1324 |
doanduyhai/Achilles | achilles-core/src/main/java/info/archinnov/achilles/internals/dsl/raw/TypedQuery.java | TypedQuery.withRowAsyncListeners | public TypedQuery<ENTITY> withRowAsyncListeners(List<Function<Row, Row>> rowAsyncListeners) {
this.options.setRowAsyncListeners(Optional.of(rowAsyncListeners));
return this;
} | java | public TypedQuery<ENTITY> withRowAsyncListeners(List<Function<Row, Row>> rowAsyncListeners) {
this.options.setRowAsyncListeners(Optional.of(rowAsyncListeners));
return this;
} | [
"public",
"TypedQuery",
"<",
"ENTITY",
">",
"withRowAsyncListeners",
"(",
"List",
"<",
"Function",
"<",
"Row",
",",
"Row",
">",
">",
"rowAsyncListeners",
")",
"{",
"this",
".",
"options",
".",
"setRowAsyncListeners",
"(",
"Optional",
".",
"of",
"(",
"rowAsyn... | Add the given list of async listeners on the {@link com.datastax.driver.core.Row} object.
Example of usage:
<pre class="code"><code class="java">
.withRowAsyncListeners(Arrays.asList(row -> {
//Do something with the row object here
}))
</code></pre>
Remark: <strong>You can inspect and read values from the row object</strong> | [
"Add",
"the",
"given",
"list",
"of",
"async",
"listeners",
"on",
"the",
"{",
"@link",
"com",
".",
"datastax",
".",
"driver",
".",
"core",
".",
"Row",
"}",
"object",
".",
"Example",
"of",
"usage",
":",
"<pre",
"class",
"=",
"code",
">",
"<code",
"clas... | train | https://github.com/doanduyhai/Achilles/blob/8281c33100e72c993e570592ae1a5306afac6813/achilles-core/src/main/java/info/archinnov/achilles/internals/dsl/raw/TypedQuery.java#L119-L122 |
docusign/docusign-java-client | src/main/java/com/docusign/esign/api/WorkspacesApi.java | WorkspacesApi.getWorkspaceFile | public void getWorkspaceFile(String accountId, String workspaceId, String folderId, String fileId) throws ApiException {
getWorkspaceFile(accountId, workspaceId, folderId, fileId, null);
} | java | public void getWorkspaceFile(String accountId, String workspaceId, String folderId, String fileId) throws ApiException {
getWorkspaceFile(accountId, workspaceId, folderId, fileId, null);
} | [
"public",
"void",
"getWorkspaceFile",
"(",
"String",
"accountId",
",",
"String",
"workspaceId",
",",
"String",
"folderId",
",",
"String",
"fileId",
")",
"throws",
"ApiException",
"{",
"getWorkspaceFile",
"(",
"accountId",
",",
"workspaceId",
",",
"folderId",
",",
... | Get Workspace File
Retrieves a workspace file (the binary).
@param accountId The external account number (int) or account ID Guid. (required)
@param workspaceId Specifies the workspace ID GUID. (required)
@param folderId The ID of the folder being accessed. (required)
@param fileId Specifies the room file ID GUID. (required)
@return void | [
"Get",
"Workspace",
"File",
"Retrieves",
"a",
"workspace",
"file",
"(",
"the",
"binary",
")",
"."
] | train | https://github.com/docusign/docusign-java-client/blob/17ae82ace0f023e98edf813be832950568212e34/src/main/java/com/docusign/esign/api/WorkspacesApi.java#L336-L338 |
aws/aws-sdk-java | aws-java-sdk-signer/src/main/java/com/amazonaws/services/signer/model/GetSigningProfileResult.java | GetSigningProfileResult.withSigningParameters | public GetSigningProfileResult withSigningParameters(java.util.Map<String, String> signingParameters) {
setSigningParameters(signingParameters);
return this;
} | java | public GetSigningProfileResult withSigningParameters(java.util.Map<String, String> signingParameters) {
setSigningParameters(signingParameters);
return this;
} | [
"public",
"GetSigningProfileResult",
"withSigningParameters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"signingParameters",
")",
"{",
"setSigningParameters",
"(",
"signingParameters",
")",
";",
"return",
"this",
";",
"}"
] | <p>
A map of key-value pairs for signing operations that is attached to the target signing profile.
</p>
@param signingParameters
A map of key-value pairs for signing operations that is attached to the target signing profile.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"A",
"map",
"of",
"key",
"-",
"value",
"pairs",
"for",
"signing",
"operations",
"that",
"is",
"attached",
"to",
"the",
"target",
"signing",
"profile",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-signer/src/main/java/com/amazonaws/services/signer/model/GetSigningProfileResult.java#L258-L261 |
UrielCh/ovh-java-sdk | ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java | ApiOvhPrice.dedicated_nasha_model_modelName_GET | public OvhPrice dedicated_nasha_model_modelName_GET(net.minidev.ovh.api.price.dedicated.nasha.OvhModelEnum modelName) throws IOException {
String qPath = "/price/dedicated/nasha/model/{modelName}";
StringBuilder sb = path(qPath, modelName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | java | public OvhPrice dedicated_nasha_model_modelName_GET(net.minidev.ovh.api.price.dedicated.nasha.OvhModelEnum modelName) throws IOException {
String qPath = "/price/dedicated/nasha/model/{modelName}";
StringBuilder sb = path(qPath, modelName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | [
"public",
"OvhPrice",
"dedicated_nasha_model_modelName_GET",
"(",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"price",
".",
"dedicated",
".",
"nasha",
".",
"OvhModelEnum",
"modelName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/price/... | Get the price of Nas HA offers
REST: GET /price/dedicated/nasha/model/{modelName}
@param modelName [required] capacity in gigabit of Nas Ha | [
"Get",
"the",
"price",
"of",
"Nas",
"HA",
"offers"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java#L154-L159 |
DDTH/ddth-dao | ddth-dao-core/src/main/java/com/github/ddth/dao/jdbc/impl/JdbcTemplateJdbcHelper.java | JdbcTemplateJdbcHelper.jdbcTemplate | protected JdbcTemplate jdbcTemplate(Connection conn) {
DataSource ds = new SingleConnectionDataSource(conn, true);
return new JdbcTemplate(ds);
} | java | protected JdbcTemplate jdbcTemplate(Connection conn) {
DataSource ds = new SingleConnectionDataSource(conn, true);
return new JdbcTemplate(ds);
} | [
"protected",
"JdbcTemplate",
"jdbcTemplate",
"(",
"Connection",
"conn",
")",
"{",
"DataSource",
"ds",
"=",
"new",
"SingleConnectionDataSource",
"(",
"conn",
",",
"true",
")",
";",
"return",
"new",
"JdbcTemplate",
"(",
"ds",
")",
";",
"}"
] | Get {@link JdbcTemplate} instance for a given {@link Connection}.
Note: the returned {@link JdbcTemplate} will not automatically close the
{@link Connection}.
@param conn
@return | [
"Get",
"{",
"@link",
"JdbcTemplate",
"}",
"instance",
"for",
"a",
"given",
"{",
"@link",
"Connection",
"}",
"."
] | train | https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/jdbc/impl/JdbcTemplateJdbcHelper.java#L43-L46 |
sonyxperiadev/gerrit-events | src/main/java/com/sonymobile/tools/gerrit/gerritevents/ssh/SshConnectionImpl.java | SshConnectionImpl.executeCommandChannel | @Override
public synchronized ChannelExec executeCommandChannel(String command, Boolean establishConnection)
throws SshException, IOException {
if (!isConnected()) {
throw new IOException("Not connected!");
}
try {
ChannelExec channel = (ChannelExec)connectSession.openChannel("exec");
channel.setCommand(command);
if (establishConnection) {
channel.connect();
}
return channel;
} catch (JSchException ex) {
throw new SshException(ex);
}
} | java | @Override
public synchronized ChannelExec executeCommandChannel(String command, Boolean establishConnection)
throws SshException, IOException {
if (!isConnected()) {
throw new IOException("Not connected!");
}
try {
ChannelExec channel = (ChannelExec)connectSession.openChannel("exec");
channel.setCommand(command);
if (establishConnection) {
channel.connect();
}
return channel;
} catch (JSchException ex) {
throw new SshException(ex);
}
} | [
"@",
"Override",
"public",
"synchronized",
"ChannelExec",
"executeCommandChannel",
"(",
"String",
"command",
",",
"Boolean",
"establishConnection",
")",
"throws",
"SshException",
",",
"IOException",
"{",
"if",
"(",
"!",
"isConnected",
"(",
")",
")",
"{",
"throw",
... | This version takes a command to run, and then returns a wrapper instance
that exposes all the standard state of the channel (stdin, stdout,
stderr, exit status, etc). Channel connection is established if establishConnection
is true.
@param command the command to execute.
@param establishConnection true if establish channel connetction within this method.
@return a Channel with access to all streams and the exit code.
@throws IOException if it is so.
@throws SshException if there are any ssh problems.
@see #executeCommandReader(String) | [
"This",
"version",
"takes",
"a",
"command",
"to",
"run",
"and",
"then",
"returns",
"a",
"wrapper",
"instance",
"that",
"exposes",
"all",
"the",
"standard",
"state",
"of",
"the",
"channel",
"(",
"stdin",
"stdout",
"stderr",
"exit",
"status",
"etc",
")",
"."... | train | https://github.com/sonyxperiadev/gerrit-events/blob/9a443d13dded85cc4709136ac33989f2bbb34fe2/src/main/java/com/sonymobile/tools/gerrit/gerritevents/ssh/SshConnectionImpl.java#L376-L392 |
apereo/cas | support/cas-server-support-saml-idp-metadata/src/main/java/org/apereo/cas/support/saml/services/idp/metadata/cache/resolver/BaseSamlRegisteredServiceMetadataResolver.java | BaseSamlRegisteredServiceMetadataResolver.addMetadataFiltersToMetadataResolver | protected void addMetadataFiltersToMetadataResolver(final AbstractMetadataResolver metadataProvider, final List<MetadataFilter> metadataFilterList) {
val metadataFilterChain = new MetadataFilterChain();
metadataFilterChain.setFilters(metadataFilterList);
LOGGER.debug("Metadata filter chain initialized with [{}] filters", metadataFilterList.size());
metadataProvider.setMetadataFilter(metadataFilterChain);
} | java | protected void addMetadataFiltersToMetadataResolver(final AbstractMetadataResolver metadataProvider, final List<MetadataFilter> metadataFilterList) {
val metadataFilterChain = new MetadataFilterChain();
metadataFilterChain.setFilters(metadataFilterList);
LOGGER.debug("Metadata filter chain initialized with [{}] filters", metadataFilterList.size());
metadataProvider.setMetadataFilter(metadataFilterChain);
} | [
"protected",
"void",
"addMetadataFiltersToMetadataResolver",
"(",
"final",
"AbstractMetadataResolver",
"metadataProvider",
",",
"final",
"List",
"<",
"MetadataFilter",
">",
"metadataFilterList",
")",
"{",
"val",
"metadataFilterChain",
"=",
"new",
"MetadataFilterChain",
"(",... | Add metadata filters to metadata resolver.
@param metadataProvider the metadata provider
@param metadataFilterList the metadata filter list | [
"Add",
"metadata",
"filters",
"to",
"metadata",
"resolver",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-saml-idp-metadata/src/main/java/org/apereo/cas/support/saml/services/idp/metadata/cache/resolver/BaseSamlRegisteredServiceMetadataResolver.java#L192-L198 |
CodeNarc/CodeNarc | src/main/java/org/codenarc/util/AstUtil.java | AstUtil.isVariable | public static boolean isVariable(ASTNode expression, String pattern) {
return (expression instanceof VariableExpression && ((VariableExpression) expression).getName().matches(pattern));
} | java | public static boolean isVariable(ASTNode expression, String pattern) {
return (expression instanceof VariableExpression && ((VariableExpression) expression).getName().matches(pattern));
} | [
"public",
"static",
"boolean",
"isVariable",
"(",
"ASTNode",
"expression",
",",
"String",
"pattern",
")",
"{",
"return",
"(",
"expression",
"instanceof",
"VariableExpression",
"&&",
"(",
"(",
"VariableExpression",
")",
"expression",
")",
".",
"getName",
"(",
")"... | Tells you if the given ASTNode is a VariableExpression with the given name.
@param expression
any AST Node
@param pattern
a string pattern to match
@return
true if the node is a variable with the specified name | [
"Tells",
"you",
"if",
"the",
"given",
"ASTNode",
"is",
"a",
"VariableExpression",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/CodeNarc/CodeNarc/blob/9a7cec02cb8cbaf845030f2434309e8968f5d7a7/src/main/java/org/codenarc/util/AstUtil.java#L874-L876 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/input/CmsSelectBox.java | CmsSelectBox.addOption | public void addOption(String value, String text) {
String title = getTitle(value, text);
CmsLabelSelectCell cell = new CmsLabelSelectCell(value, text, title);
addOption(cell);
} | java | public void addOption(String value, String text) {
String title = getTitle(value, text);
CmsLabelSelectCell cell = new CmsLabelSelectCell(value, text, title);
addOption(cell);
} | [
"public",
"void",
"addOption",
"(",
"String",
"value",
",",
"String",
"text",
")",
"{",
"String",
"title",
"=",
"getTitle",
"(",
"value",
",",
"text",
")",
";",
"CmsLabelSelectCell",
"cell",
"=",
"new",
"CmsLabelSelectCell",
"(",
"value",
",",
"text",
",",... | Adds a new selection cell.<p>
@param value the value of the select option
@param text the text to be displayed for the select option | [
"Adds",
"a",
"new",
"selection",
"cell",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/CmsSelectBox.java#L173-L178 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.