repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/helpers/Highlighter.java
|
Highlighter.setInput
|
@SuppressWarnings( {
"""
Sets the input to highlight.
@param result a JSONObject containing our attribute.
@param attribute the attribute to highlight.
@return a {@link Styler} to specify the style before rendering.
""""WeakerAccess", "unused"}) // For library users
public Styler setInput(@NonNull JSONObject result, @NonNull String attribute) {
return setInput(result, attribute, false);
}
|
java
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Styler setInput(@NonNull JSONObject result, @NonNull String attribute) {
return setInput(result, attribute, false);
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"Styler",
"setInput",
"(",
"@",
"NonNull",
"JSONObject",
"result",
",",
"@",
"NonNull",
"String",
"attribute",
")",
"{",
"return",
"setInput",
"(",
"result",
",",
"attribute",
",",
"false",
")",
";",
"}"
] |
Sets the input to highlight.
@param result a JSONObject containing our attribute.
@param attribute the attribute to highlight.
@return a {@link Styler} to specify the style before rendering.
|
[
"Sets",
"the",
"input",
"to",
"highlight",
"."
] |
train
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/helpers/Highlighter.java#L140-L143
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/stats/JMStats.java
|
JMStats.calStats
|
public static Number calStats(String statsString, LongStream numberStream) {
"""
Cal stats number.
@param statsString the stats string
@param numberStream the number stream
@return the number
"""
return StatsField.valueOfAlias(statsString).calStats(numberStream);
}
|
java
|
public static Number calStats(String statsString, LongStream numberStream) {
return StatsField.valueOfAlias(statsString).calStats(numberStream);
}
|
[
"public",
"static",
"Number",
"calStats",
"(",
"String",
"statsString",
",",
"LongStream",
"numberStream",
")",
"{",
"return",
"StatsField",
".",
"valueOfAlias",
"(",
"statsString",
")",
".",
"calStats",
"(",
"numberStream",
")",
";",
"}"
] |
Cal stats number.
@param statsString the stats string
@param numberStream the number stream
@return the number
|
[
"Cal",
"stats",
"number",
"."
] |
train
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/JMStats.java#L75-L77
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java
|
ManifestUtil.getConectorName
|
public static String getConectorName(String pathManifest) throws InitializationException {
"""
Recovered the ConecrtorName form Manifest.
@param pathManifest the manifest path.
@return the ConectionName.
@throws InitializationException if an error happens while XML is reading.
"""
String connectionName = "";
try {
Document document = getDocument(pathManifest);
Object result = getResult(document, "//ConnectorName/text()");
connectionName = ((NodeList) result).item(0).getNodeValue();
} catch (SAXException | XPathExpressionException | IOException | ParserConfigurationException e) {
String msg = "Impossible to read DataStoreName in Manifest with the connector configuration."
+ e.getCause();
LOGGER.error(msg);
throw new InitializationException(msg, e);
}
return connectionName;
}
|
java
|
public static String getConectorName(String pathManifest) throws InitializationException {
String connectionName = "";
try {
Document document = getDocument(pathManifest);
Object result = getResult(document, "//ConnectorName/text()");
connectionName = ((NodeList) result).item(0).getNodeValue();
} catch (SAXException | XPathExpressionException | IOException | ParserConfigurationException e) {
String msg = "Impossible to read DataStoreName in Manifest with the connector configuration."
+ e.getCause();
LOGGER.error(msg);
throw new InitializationException(msg, e);
}
return connectionName;
}
|
[
"public",
"static",
"String",
"getConectorName",
"(",
"String",
"pathManifest",
")",
"throws",
"InitializationException",
"{",
"String",
"connectionName",
"=",
"\"\"",
";",
"try",
"{",
"Document",
"document",
"=",
"getDocument",
"(",
"pathManifest",
")",
";",
"Object",
"result",
"=",
"getResult",
"(",
"document",
",",
"\"//ConnectorName/text()\"",
")",
";",
"connectionName",
"=",
"(",
"(",
"NodeList",
")",
"result",
")",
".",
"item",
"(",
"0",
")",
".",
"getNodeValue",
"(",
")",
";",
"}",
"catch",
"(",
"SAXException",
"|",
"XPathExpressionException",
"|",
"IOException",
"|",
"ParserConfigurationException",
"e",
")",
"{",
"String",
"msg",
"=",
"\"Impossible to read DataStoreName in Manifest with the connector configuration.\"",
"+",
"e",
".",
"getCause",
"(",
")",
";",
"LOGGER",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"InitializationException",
"(",
"msg",
",",
"e",
")",
";",
"}",
"return",
"connectionName",
";",
"}"
] |
Recovered the ConecrtorName form Manifest.
@param pathManifest the manifest path.
@return the ConectionName.
@throws InitializationException if an error happens while XML is reading.
|
[
"Recovered",
"the",
"ConecrtorName",
"form",
"Manifest",
"."
] |
train
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/util/ManifestUtil.java#L86-L103
|
ManfredTremmel/gwt-commons-lang3
|
src/main/java/org/apache/commons/lang3/text/StrBuilder.java
|
StrBuilder.rightString
|
public String rightString(final int length) {
"""
Extracts the rightmost characters from the string builder without
throwing an exception.
<p>
This method extracts the right <code>length</code> characters from
the builder. If this many characters are not available, the whole
builder is returned. Thus the returned string may be shorter than the
length requested.
@param length the number of characters to extract, negative returns empty string
@return the new string
"""
if (length <= 0) {
return StringUtils.EMPTY;
} else if (length >= size) {
return new String(buffer, 0, size);
} else {
return new String(buffer, size - length, length);
}
}
|
java
|
public String rightString(final int length) {
if (length <= 0) {
return StringUtils.EMPTY;
} else if (length >= size) {
return new String(buffer, 0, size);
} else {
return new String(buffer, size - length, length);
}
}
|
[
"public",
"String",
"rightString",
"(",
"final",
"int",
"length",
")",
"{",
"if",
"(",
"length",
"<=",
"0",
")",
"{",
"return",
"StringUtils",
".",
"EMPTY",
";",
"}",
"else",
"if",
"(",
"length",
">=",
"size",
")",
"{",
"return",
"new",
"String",
"(",
"buffer",
",",
"0",
",",
"size",
")",
";",
"}",
"else",
"{",
"return",
"new",
"String",
"(",
"buffer",
",",
"size",
"-",
"length",
",",
"length",
")",
";",
"}",
"}"
] |
Extracts the rightmost characters from the string builder without
throwing an exception.
<p>
This method extracts the right <code>length</code> characters from
the builder. If this many characters are not available, the whole
builder is returned. Thus the returned string may be shorter than the
length requested.
@param length the number of characters to extract, negative returns empty string
@return the new string
|
[
"Extracts",
"the",
"rightmost",
"characters",
"from",
"the",
"string",
"builder",
"without",
"throwing",
"an",
"exception",
".",
"<p",
">",
"This",
"method",
"extracts",
"the",
"right",
"<code",
">",
"length<",
"/",
"code",
">",
"characters",
"from",
"the",
"builder",
".",
"If",
"this",
"many",
"characters",
"are",
"not",
"available",
"the",
"whole",
"builder",
"is",
"returned",
".",
"Thus",
"the",
"returned",
"string",
"may",
"be",
"shorter",
"than",
"the",
"length",
"requested",
"."
] |
train
|
https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/text/StrBuilder.java#L2318-L2326
|
pushtorefresh/storio
|
storio-content-resolver/src/main/java/com/pushtorefresh/storio3/contentresolver/operations/delete/DeleteResult.java
|
DeleteResult.newInstance
|
@NonNull
public static DeleteResult newInstance(int numberOfRowsDeleted, @NonNull Set<Uri> affectedUris) {
"""
Creates new instance of immutable container for results of Delete Operation.
@param numberOfRowsDeleted number of rows that were deleted.
@param affectedUris non-null set of Uris that wer affected.
@return new instance of immutable container for results of Delete Operation.
"""
checkNotNull(affectedUris, "Please specify affected Uris");
return new DeleteResult(numberOfRowsDeleted, affectedUris);
}
|
java
|
@NonNull
public static DeleteResult newInstance(int numberOfRowsDeleted, @NonNull Set<Uri> affectedUris) {
checkNotNull(affectedUris, "Please specify affected Uris");
return new DeleteResult(numberOfRowsDeleted, affectedUris);
}
|
[
"@",
"NonNull",
"public",
"static",
"DeleteResult",
"newInstance",
"(",
"int",
"numberOfRowsDeleted",
",",
"@",
"NonNull",
"Set",
"<",
"Uri",
">",
"affectedUris",
")",
"{",
"checkNotNull",
"(",
"affectedUris",
",",
"\"Please specify affected Uris\"",
")",
";",
"return",
"new",
"DeleteResult",
"(",
"numberOfRowsDeleted",
",",
"affectedUris",
")",
";",
"}"
] |
Creates new instance of immutable container for results of Delete Operation.
@param numberOfRowsDeleted number of rows that were deleted.
@param affectedUris non-null set of Uris that wer affected.
@return new instance of immutable container for results of Delete Operation.
|
[
"Creates",
"new",
"instance",
"of",
"immutable",
"container",
"for",
"results",
"of",
"Delete",
"Operation",
"."
] |
train
|
https://github.com/pushtorefresh/storio/blob/58f53d81bcc7b069c8bb271c46a90e37775abe8d/storio-content-resolver/src/main/java/com/pushtorefresh/storio3/contentresolver/operations/delete/DeleteResult.java#L35-L39
|
prestodb/presto
|
presto-main/src/main/java/com/facebook/presto/sql/planner/EqualityInference.java
|
EqualityInference.rewriteExpressionAllowNonDeterministic
|
public Expression rewriteExpressionAllowNonDeterministic(Expression expression, Predicate<Symbol> symbolScope) {
"""
Attempts to rewrite an Expression in terms of the symbols allowed by the symbol scope
given the known equalities. Returns null if unsuccessful.
This method allows rewriting non-deterministic expressions.
"""
return rewriteExpression(expression, symbolScope, true);
}
|
java
|
public Expression rewriteExpressionAllowNonDeterministic(Expression expression, Predicate<Symbol> symbolScope)
{
return rewriteExpression(expression, symbolScope, true);
}
|
[
"public",
"Expression",
"rewriteExpressionAllowNonDeterministic",
"(",
"Expression",
"expression",
",",
"Predicate",
"<",
"Symbol",
">",
"symbolScope",
")",
"{",
"return",
"rewriteExpression",
"(",
"expression",
",",
"symbolScope",
",",
"true",
")",
";",
"}"
] |
Attempts to rewrite an Expression in terms of the symbols allowed by the symbol scope
given the known equalities. Returns null if unsuccessful.
This method allows rewriting non-deterministic expressions.
|
[
"Attempts",
"to",
"rewrite",
"an",
"Expression",
"in",
"terms",
"of",
"the",
"symbols",
"allowed",
"by",
"the",
"symbol",
"scope",
"given",
"the",
"known",
"equalities",
".",
"Returns",
"null",
"if",
"unsuccessful",
".",
"This",
"method",
"allows",
"rewriting",
"non",
"-",
"deterministic",
"expressions",
"."
] |
train
|
https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-main/src/main/java/com/facebook/presto/sql/planner/EqualityInference.java#L110-L113
|
gallandarakhneorg/afc
|
core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java
|
XMLUtil.getAttributeDouble
|
@Pure
public static double getAttributeDouble(Node document, String... path) {
"""
Replies the double value that corresponds to the specified attribute's path.
<p>The path is an ordered list of tag's names and ended by the name of
the attribute.
Be careful about the fact that the names are case sensitives.
@param document is the XML document to explore.
@param path is the list of and ended by the attribute's name.
@return the double value of the specified attribute or <code>0</code>.
"""
assert document != null : AssertMessages.notNullParameter(0);
return getAttributeDoubleWithDefault(document, true, 0., path);
}
|
java
|
@Pure
public static double getAttributeDouble(Node document, String... path) {
assert document != null : AssertMessages.notNullParameter(0);
return getAttributeDoubleWithDefault(document, true, 0., path);
}
|
[
"@",
"Pure",
"public",
"static",
"double",
"getAttributeDouble",
"(",
"Node",
"document",
",",
"String",
"...",
"path",
")",
"{",
"assert",
"document",
"!=",
"null",
":",
"AssertMessages",
".",
"notNullParameter",
"(",
"0",
")",
";",
"return",
"getAttributeDoubleWithDefault",
"(",
"document",
",",
"true",
",",
"0.",
",",
"path",
")",
";",
"}"
] |
Replies the double value that corresponds to the specified attribute's path.
<p>The path is an ordered list of tag's names and ended by the name of
the attribute.
Be careful about the fact that the names are case sensitives.
@param document is the XML document to explore.
@param path is the list of and ended by the attribute's name.
@return the double value of the specified attribute or <code>0</code>.
|
[
"Replies",
"the",
"double",
"value",
"that",
"corresponds",
"to",
"the",
"specified",
"attribute",
"s",
"path",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java#L592-L596
|
ziccardi/jnrpe
|
jnrpe-lib/src/main/java/it/jnrpe/utils/LoadedClassCache.java
|
LoadedClassCache.saveClass
|
private static void saveClass(final ClassLoader cl, final Class c) {
"""
Stores a class in the cache.
@param cl
The classloader
@param c
the class to be stored
"""
if (LOADED_PLUGINS.get(cl) == null) {
LOADED_PLUGINS.put(cl, new ClassesData());
}
ClassesData cd = LOADED_PLUGINS.get(cl);
cd.addClass(c);
}
|
java
|
private static void saveClass(final ClassLoader cl, final Class c) {
if (LOADED_PLUGINS.get(cl) == null) {
LOADED_PLUGINS.put(cl, new ClassesData());
}
ClassesData cd = LOADED_PLUGINS.get(cl);
cd.addClass(c);
}
|
[
"private",
"static",
"void",
"saveClass",
"(",
"final",
"ClassLoader",
"cl",
",",
"final",
"Class",
"c",
")",
"{",
"if",
"(",
"LOADED_PLUGINS",
".",
"get",
"(",
"cl",
")",
"==",
"null",
")",
"{",
"LOADED_PLUGINS",
".",
"put",
"(",
"cl",
",",
"new",
"ClassesData",
"(",
")",
")",
";",
"}",
"ClassesData",
"cd",
"=",
"LOADED_PLUGINS",
".",
"get",
"(",
"cl",
")",
";",
"cd",
".",
"addClass",
"(",
"c",
")",
";",
"}"
] |
Stores a class in the cache.
@param cl
The classloader
@param c
the class to be stored
|
[
"Stores",
"a",
"class",
"in",
"the",
"cache",
"."
] |
train
|
https://github.com/ziccardi/jnrpe/blob/ac9046355851136994388442b01ba4063305f9c4/jnrpe-lib/src/main/java/it/jnrpe/utils/LoadedClassCache.java#L118-L125
|
mfornos/humanize
|
humanize-slim/src/main/java/humanize/Humanize.java
|
Humanize.naturalDay
|
public static String naturalDay(int style, Date then) {
"""
For dates that are the current day or within one day, return 'today',
'tomorrow' or 'yesterday', as appropriate. Otherwise, returns a string
formatted according to a locale sensitive DateFormat.
@param style
The style of the Date
@param then
The date (GMT)
@return String with 'today', 'tomorrow' or 'yesterday' compared to
current day. Otherwise, returns a string formatted according to a
locale sensitive DateFormat.
"""
Date today = new Date();
long delta = then.getTime() - today.getTime();
long days = delta / ND_FACTOR;
if (days == 0)
return context.get().getMessage("today");
else if (days == 1)
return context.get().getMessage("tomorrow");
else if (days == -1)
return context.get().getMessage("yesterday");
return formatDate(style, then);
}
|
java
|
public static String naturalDay(int style, Date then)
{
Date today = new Date();
long delta = then.getTime() - today.getTime();
long days = delta / ND_FACTOR;
if (days == 0)
return context.get().getMessage("today");
else if (days == 1)
return context.get().getMessage("tomorrow");
else if (days == -1)
return context.get().getMessage("yesterday");
return formatDate(style, then);
}
|
[
"public",
"static",
"String",
"naturalDay",
"(",
"int",
"style",
",",
"Date",
"then",
")",
"{",
"Date",
"today",
"=",
"new",
"Date",
"(",
")",
";",
"long",
"delta",
"=",
"then",
".",
"getTime",
"(",
")",
"-",
"today",
".",
"getTime",
"(",
")",
";",
"long",
"days",
"=",
"delta",
"/",
"ND_FACTOR",
";",
"if",
"(",
"days",
"==",
"0",
")",
"return",
"context",
".",
"get",
"(",
")",
".",
"getMessage",
"(",
"\"today\"",
")",
";",
"else",
"if",
"(",
"days",
"==",
"1",
")",
"return",
"context",
".",
"get",
"(",
")",
".",
"getMessage",
"(",
"\"tomorrow\"",
")",
";",
"else",
"if",
"(",
"days",
"==",
"-",
"1",
")",
"return",
"context",
".",
"get",
"(",
")",
".",
"getMessage",
"(",
"\"yesterday\"",
")",
";",
"return",
"formatDate",
"(",
"style",
",",
"then",
")",
";",
"}"
] |
For dates that are the current day or within one day, return 'today',
'tomorrow' or 'yesterday', as appropriate. Otherwise, returns a string
formatted according to a locale sensitive DateFormat.
@param style
The style of the Date
@param then
The date (GMT)
@return String with 'today', 'tomorrow' or 'yesterday' compared to
current day. Otherwise, returns a string formatted according to a
locale sensitive DateFormat.
|
[
"For",
"dates",
"that",
"are",
"the",
"current",
"day",
"or",
"within",
"one",
"day",
"return",
"today",
"tomorrow",
"or",
"yesterday",
"as",
"appropriate",
".",
"Otherwise",
"returns",
"a",
"string",
"formatted",
"according",
"to",
"a",
"locale",
"sensitive",
"DateFormat",
"."
] |
train
|
https://github.com/mfornos/humanize/blob/59fc103045de9d217c9e77dbcb7621f992f46c63/humanize-slim/src/main/java/humanize/Humanize.java#L1492-L1506
|
kuujo/vertigo
|
core/src/main/java/net/kuujo/vertigo/Vertigo.java
|
Vertigo.undeployNetwork
|
public Vertigo undeployNetwork(String cluster, NetworkConfig network) {
"""
Undeploys a network from the given cluster.<p>
This method supports both partial and complete undeployment of networks. When
undeploying networks by specifying a {@link NetworkConfig}, the network configuration
should contain all components and connections that are being undeployed. If the
configuration's components and connections match all deployed components and
connections then the entire network will be undeployed.
@param cluster The cluster from which to undeploy the network.
@param network The network configuration to undeploy.
@return The Vertigo instance.
"""
return undeployNetwork(cluster, network, null);
}
|
java
|
public Vertigo undeployNetwork(String cluster, NetworkConfig network) {
return undeployNetwork(cluster, network, null);
}
|
[
"public",
"Vertigo",
"undeployNetwork",
"(",
"String",
"cluster",
",",
"NetworkConfig",
"network",
")",
"{",
"return",
"undeployNetwork",
"(",
"cluster",
",",
"network",
",",
"null",
")",
";",
"}"
] |
Undeploys a network from the given cluster.<p>
This method supports both partial and complete undeployment of networks. When
undeploying networks by specifying a {@link NetworkConfig}, the network configuration
should contain all components and connections that are being undeployed. If the
configuration's components and connections match all deployed components and
connections then the entire network will be undeployed.
@param cluster The cluster from which to undeploy the network.
@param network The network configuration to undeploy.
@return The Vertigo instance.
|
[
"Undeploys",
"a",
"network",
"from",
"the",
"given",
"cluster",
".",
"<p",
">"
] |
train
|
https://github.com/kuujo/vertigo/blob/c5869dbc5fff89eb5262e83f7a81719b01a5ba6f/core/src/main/java/net/kuujo/vertigo/Vertigo.java#L693-L695
|
dkpro/dkpro-jwpl
|
de.tudarmstadt.ukp.wikipedia.util/src/main/java/de/tudarmstadt/ukp/wikipedia/util/templates/WikipediaTemplateInfo.java
|
WikipediaTemplateInfo.getRevisionIdsNotContainingTemplateNames
|
public List<Integer> getRevisionIdsNotContainingTemplateNames(List<String> templateNames) throws WikiApiException {
"""
Returns a list containing the ids of all revisions that do not contain a template
the name of which equals any of the given Strings.
@param templateNames
the names of the template that we want to match
@return A list with the ids of all revisions that do not contain any of the the
specified templates
@throws WikiApiException
If there was any error retrieving the page object (most
likely if the templates are corrupted)
"""
return getFilteredRevisionIds(templateNames, false);
}
|
java
|
public List<Integer> getRevisionIdsNotContainingTemplateNames(List<String> templateNames) throws WikiApiException{
return getFilteredRevisionIds(templateNames, false);
}
|
[
"public",
"List",
"<",
"Integer",
">",
"getRevisionIdsNotContainingTemplateNames",
"(",
"List",
"<",
"String",
">",
"templateNames",
")",
"throws",
"WikiApiException",
"{",
"return",
"getFilteredRevisionIds",
"(",
"templateNames",
",",
"false",
")",
";",
"}"
] |
Returns a list containing the ids of all revisions that do not contain a template
the name of which equals any of the given Strings.
@param templateNames
the names of the template that we want to match
@return A list with the ids of all revisions that do not contain any of the the
specified templates
@throws WikiApiException
If there was any error retrieving the page object (most
likely if the templates are corrupted)
|
[
"Returns",
"a",
"list",
"containing",
"the",
"ids",
"of",
"all",
"revisions",
"that",
"do",
"not",
"contain",
"a",
"template",
"the",
"name",
"of",
"which",
"equals",
"any",
"of",
"the",
"given",
"Strings",
"."
] |
train
|
https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.util/src/main/java/de/tudarmstadt/ukp/wikipedia/util/templates/WikipediaTemplateInfo.java#L1096-L1098
|
lessthanoptimal/BoofCV
|
examples/src/main/java/boofcv/examples/sfm/ExampleMultiviewSceneReconstruction.java
|
ExampleMultiviewSceneReconstruction.visualizeResults
|
private void visualizeResults( SceneStructureMetric structure,
List<BufferedImage> colorImages ) {
"""
Opens a window showing the found point cloud. Points are colorized using the pixel value inside
one of the input images
"""
List<Point3D_F64> cloudXyz = new ArrayList<>();
GrowQueue_I32 cloudRgb = new GrowQueue_I32();
Point3D_F64 world = new Point3D_F64();
Point3D_F64 camera = new Point3D_F64();
Point2D_F64 pixel = new Point2D_F64();
for( int i = 0; i < structure.points.length; i++ ) {
// Get 3D location
SceneStructureMetric.Point p = structure.points[i];
p.get(world);
// Project point into an arbitrary view
for (int j = 0; j < p.views.size; j++) {
int viewIdx = p.views.get(j);
SePointOps_F64.transform(structure.views[viewIdx].worldToView,world,camera);
int cameraIdx = structure.views[viewIdx].camera;
structure.cameras[cameraIdx].model.project(camera.x,camera.y,camera.z,pixel);
// Get the points color
BufferedImage image = colorImages.get(viewIdx);
int x = (int)pixel.x;
int y = (int)pixel.y;
// After optimization it might have been moved out of the camera's original FOV.
// hopefully this isn't too common
if( x < 0 || y < 0 || x >= image.getWidth() || y >= image.getHeight() )
continue;
cloudXyz.add( world.copy() );
cloudRgb.add(image.getRGB((int)pixel.x,(int)pixel.y));
break;
}
}
PointCloudViewer viewer = VisualizeData.createPointCloudViewer();
viewer.setTranslationStep(0.05);
viewer.addCloud(cloudXyz,cloudRgb.data);
viewer.setCameraHFov(UtilAngle.radian(60));
SwingUtilities.invokeLater(()->{
viewer.getComponent().setPreferredSize(new Dimension(500,500));
ShowImages.showWindow(viewer.getComponent(), "Reconstruction Points", true);
});
}
|
java
|
private void visualizeResults( SceneStructureMetric structure,
List<BufferedImage> colorImages ) {
List<Point3D_F64> cloudXyz = new ArrayList<>();
GrowQueue_I32 cloudRgb = new GrowQueue_I32();
Point3D_F64 world = new Point3D_F64();
Point3D_F64 camera = new Point3D_F64();
Point2D_F64 pixel = new Point2D_F64();
for( int i = 0; i < structure.points.length; i++ ) {
// Get 3D location
SceneStructureMetric.Point p = structure.points[i];
p.get(world);
// Project point into an arbitrary view
for (int j = 0; j < p.views.size; j++) {
int viewIdx = p.views.get(j);
SePointOps_F64.transform(structure.views[viewIdx].worldToView,world,camera);
int cameraIdx = structure.views[viewIdx].camera;
structure.cameras[cameraIdx].model.project(camera.x,camera.y,camera.z,pixel);
// Get the points color
BufferedImage image = colorImages.get(viewIdx);
int x = (int)pixel.x;
int y = (int)pixel.y;
// After optimization it might have been moved out of the camera's original FOV.
// hopefully this isn't too common
if( x < 0 || y < 0 || x >= image.getWidth() || y >= image.getHeight() )
continue;
cloudXyz.add( world.copy() );
cloudRgb.add(image.getRGB((int)pixel.x,(int)pixel.y));
break;
}
}
PointCloudViewer viewer = VisualizeData.createPointCloudViewer();
viewer.setTranslationStep(0.05);
viewer.addCloud(cloudXyz,cloudRgb.data);
viewer.setCameraHFov(UtilAngle.radian(60));
SwingUtilities.invokeLater(()->{
viewer.getComponent().setPreferredSize(new Dimension(500,500));
ShowImages.showWindow(viewer.getComponent(), "Reconstruction Points", true);
});
}
|
[
"private",
"void",
"visualizeResults",
"(",
"SceneStructureMetric",
"structure",
",",
"List",
"<",
"BufferedImage",
">",
"colorImages",
")",
"{",
"List",
"<",
"Point3D_F64",
">",
"cloudXyz",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"GrowQueue_I32",
"cloudRgb",
"=",
"new",
"GrowQueue_I32",
"(",
")",
";",
"Point3D_F64",
"world",
"=",
"new",
"Point3D_F64",
"(",
")",
";",
"Point3D_F64",
"camera",
"=",
"new",
"Point3D_F64",
"(",
")",
";",
"Point2D_F64",
"pixel",
"=",
"new",
"Point2D_F64",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"structure",
".",
"points",
".",
"length",
";",
"i",
"++",
")",
"{",
"// Get 3D location",
"SceneStructureMetric",
".",
"Point",
"p",
"=",
"structure",
".",
"points",
"[",
"i",
"]",
";",
"p",
".",
"get",
"(",
"world",
")",
";",
"// Project point into an arbitrary view",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"p",
".",
"views",
".",
"size",
";",
"j",
"++",
")",
"{",
"int",
"viewIdx",
"=",
"p",
".",
"views",
".",
"get",
"(",
"j",
")",
";",
"SePointOps_F64",
".",
"transform",
"(",
"structure",
".",
"views",
"[",
"viewIdx",
"]",
".",
"worldToView",
",",
"world",
",",
"camera",
")",
";",
"int",
"cameraIdx",
"=",
"structure",
".",
"views",
"[",
"viewIdx",
"]",
".",
"camera",
";",
"structure",
".",
"cameras",
"[",
"cameraIdx",
"]",
".",
"model",
".",
"project",
"(",
"camera",
".",
"x",
",",
"camera",
".",
"y",
",",
"camera",
".",
"z",
",",
"pixel",
")",
";",
"// Get the points color",
"BufferedImage",
"image",
"=",
"colorImages",
".",
"get",
"(",
"viewIdx",
")",
";",
"int",
"x",
"=",
"(",
"int",
")",
"pixel",
".",
"x",
";",
"int",
"y",
"=",
"(",
"int",
")",
"pixel",
".",
"y",
";",
"// After optimization it might have been moved out of the camera's original FOV.",
"// hopefully this isn't too common",
"if",
"(",
"x",
"<",
"0",
"||",
"y",
"<",
"0",
"||",
"x",
">=",
"image",
".",
"getWidth",
"(",
")",
"||",
"y",
">=",
"image",
".",
"getHeight",
"(",
")",
")",
"continue",
";",
"cloudXyz",
".",
"add",
"(",
"world",
".",
"copy",
"(",
")",
")",
";",
"cloudRgb",
".",
"add",
"(",
"image",
".",
"getRGB",
"(",
"(",
"int",
")",
"pixel",
".",
"x",
",",
"(",
"int",
")",
"pixel",
".",
"y",
")",
")",
";",
"break",
";",
"}",
"}",
"PointCloudViewer",
"viewer",
"=",
"VisualizeData",
".",
"createPointCloudViewer",
"(",
")",
";",
"viewer",
".",
"setTranslationStep",
"(",
"0.05",
")",
";",
"viewer",
".",
"addCloud",
"(",
"cloudXyz",
",",
"cloudRgb",
".",
"data",
")",
";",
"viewer",
".",
"setCameraHFov",
"(",
"UtilAngle",
".",
"radian",
"(",
"60",
")",
")",
";",
"SwingUtilities",
".",
"invokeLater",
"(",
"(",
")",
"->",
"{",
"viewer",
".",
"getComponent",
"(",
")",
".",
"setPreferredSize",
"(",
"new",
"Dimension",
"(",
"500",
",",
"500",
")",
")",
";",
"ShowImages",
".",
"showWindow",
"(",
"viewer",
".",
"getComponent",
"(",
")",
",",
"\"Reconstruction Points\"",
",",
"true",
")",
";",
"}",
")",
";",
"}"
] |
Opens a window showing the found point cloud. Points are colorized using the pixel value inside
one of the input images
|
[
"Opens",
"a",
"window",
"showing",
"the",
"found",
"point",
"cloud",
".",
"Points",
"are",
"colorized",
"using",
"the",
"pixel",
"value",
"inside",
"one",
"of",
"the",
"input",
"images"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/sfm/ExampleMultiviewSceneReconstruction.java#L153-L198
|
VoltDB/voltdb
|
src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java
|
JDBC4CallableStatement.getTime
|
@Override
public Time getTime(String parameterName, Calendar cal) throws SQLException {
"""
Retrieves the value of a JDBC TIME parameter as a java.sql.Time object, using the given Calendar object to construct the time.
"""
checkClosed();
throw SQLError.noSupport();
}
|
java
|
@Override
public Time getTime(String parameterName, Calendar cal) throws SQLException
{
checkClosed();
throw SQLError.noSupport();
}
|
[
"@",
"Override",
"public",
"Time",
"getTime",
"(",
"String",
"parameterName",
",",
"Calendar",
"cal",
")",
"throws",
"SQLException",
"{",
"checkClosed",
"(",
")",
";",
"throw",
"SQLError",
".",
"noSupport",
"(",
")",
";",
"}"
] |
Retrieves the value of a JDBC TIME parameter as a java.sql.Time object, using the given Calendar object to construct the time.
|
[
"Retrieves",
"the",
"value",
"of",
"a",
"JDBC",
"TIME",
"parameter",
"as",
"a",
"java",
".",
"sql",
".",
"Time",
"object",
"using",
"the",
"given",
"Calendar",
"object",
"to",
"construct",
"the",
"time",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java#L463-L468
|
FasterXML/woodstox
|
src/main/java/com/ctc/wstx/util/DataUtil.java
|
DataUtil.anyValuesInCommon
|
public static <T> boolean anyValuesInCommon(Collection<T> c1, Collection<T> c2) {
"""
Method that can be used to efficiently check if 2 collections
share at least one common element.
@return True if there is at least one element that's common
to both Collections, ie. that is contained in both of them.
"""
// Let's always iterate over smaller collection:
if (c1.size() > c2.size()) {
Collection<T> tmp = c1;
c1 = c2;
c2 = tmp;
}
Iterator<T> it = c1.iterator();
while (it.hasNext()) {
if (c2.contains(it.next())) {
return true;
}
}
return false;
}
|
java
|
public static <T> boolean anyValuesInCommon(Collection<T> c1, Collection<T> c2)
{
// Let's always iterate over smaller collection:
if (c1.size() > c2.size()) {
Collection<T> tmp = c1;
c1 = c2;
c2 = tmp;
}
Iterator<T> it = c1.iterator();
while (it.hasNext()) {
if (c2.contains(it.next())) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"<",
"T",
">",
"boolean",
"anyValuesInCommon",
"(",
"Collection",
"<",
"T",
">",
"c1",
",",
"Collection",
"<",
"T",
">",
"c2",
")",
"{",
"// Let's always iterate over smaller collection:",
"if",
"(",
"c1",
".",
"size",
"(",
")",
">",
"c2",
".",
"size",
"(",
")",
")",
"{",
"Collection",
"<",
"T",
">",
"tmp",
"=",
"c1",
";",
"c1",
"=",
"c2",
";",
"c2",
"=",
"tmp",
";",
"}",
"Iterator",
"<",
"T",
">",
"it",
"=",
"c1",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"c2",
".",
"contains",
"(",
"it",
".",
"next",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Method that can be used to efficiently check if 2 collections
share at least one common element.
@return True if there is at least one element that's common
to both Collections, ie. that is contained in both of them.
|
[
"Method",
"that",
"can",
"be",
"used",
"to",
"efficiently",
"check",
"if",
"2",
"collections",
"share",
"at",
"least",
"one",
"common",
"element",
"."
] |
train
|
https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/util/DataUtil.java#L83-L98
|
bbottema/simple-java-mail
|
modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/MailerBuilder.java
|
MailerBuilder.withSMTPServer
|
@SuppressWarnings("deprecation")
public static MailerRegularBuilderImpl withSMTPServer(@Nullable final String host, @Nullable final Integer port, @Nullable final String username, @Nullable final String password) {
"""
Delegates to {@link MailerRegularBuilder#withSMTPServer(String, Integer, String, String)}.
"""
return new MailerRegularBuilderImpl().withSMTPServer(host, port, username, password);
}
|
java
|
@SuppressWarnings("deprecation")
public static MailerRegularBuilderImpl withSMTPServer(@Nullable final String host, @Nullable final Integer port, @Nullable final String username, @Nullable final String password) {
return new MailerRegularBuilderImpl().withSMTPServer(host, port, username, password);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"MailerRegularBuilderImpl",
"withSMTPServer",
"(",
"@",
"Nullable",
"final",
"String",
"host",
",",
"@",
"Nullable",
"final",
"Integer",
"port",
",",
"@",
"Nullable",
"final",
"String",
"username",
",",
"@",
"Nullable",
"final",
"String",
"password",
")",
"{",
"return",
"new",
"MailerRegularBuilderImpl",
"(",
")",
".",
"withSMTPServer",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
")",
";",
"}"
] |
Delegates to {@link MailerRegularBuilder#withSMTPServer(String, Integer, String, String)}.
|
[
"Delegates",
"to",
"{"
] |
train
|
https://github.com/bbottema/simple-java-mail/blob/b03635328aeecd525e35eddfef8f5b9a184559d8/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/MailerBuilder.java#L48-L51
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/vna/ValueNumberCache.java
|
ValueNumberCache.addOutputValues
|
public void addOutputValues(Entry entry, ValueNumber[] outputValueList) {
"""
Add output values for given entry. Assumes that lookupOutputValues() has
determined that the entry is not in the cache.
@param entry
the entry
@param outputValueList
the list of output values produced by the entry's instruction
and input values
"""
ValueNumber[] old = entryToOutputMap.put(entry, outputValueList);
if (old != null) {
throw new IllegalStateException("overwriting output values for entry!");
}
}
|
java
|
public void addOutputValues(Entry entry, ValueNumber[] outputValueList) {
ValueNumber[] old = entryToOutputMap.put(entry, outputValueList);
if (old != null) {
throw new IllegalStateException("overwriting output values for entry!");
}
}
|
[
"public",
"void",
"addOutputValues",
"(",
"Entry",
"entry",
",",
"ValueNumber",
"[",
"]",
"outputValueList",
")",
"{",
"ValueNumber",
"[",
"]",
"old",
"=",
"entryToOutputMap",
".",
"put",
"(",
"entry",
",",
"outputValueList",
")",
";",
"if",
"(",
"old",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"overwriting output values for entry!\"",
")",
";",
"}",
"}"
] |
Add output values for given entry. Assumes that lookupOutputValues() has
determined that the entry is not in the cache.
@param entry
the entry
@param outputValueList
the list of output values produced by the entry's instruction
and input values
|
[
"Add",
"output",
"values",
"for",
"given",
"entry",
".",
"Assumes",
"that",
"lookupOutputValues",
"()",
"has",
"determined",
"that",
"the",
"entry",
"is",
"not",
"in",
"the",
"cache",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/vna/ValueNumberCache.java#L141-L146
|
apache/incubator-shardingsphere
|
sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/rule/BindingTableRule.java
|
BindingTableRule.getBindingActualTable
|
public String getBindingActualTable(final String dataSource, final String logicTable, final String otherActualTable) {
"""
Deduce actual table name from other actual table name in same binding table rule.
@param dataSource data source name
@param logicTable logic table name
@param otherActualTable other actual table name in same binding table rule
@return actual table name
"""
int index = -1;
for (TableRule each : tableRules) {
index = each.findActualTableIndex(dataSource, otherActualTable);
if (-1 != index) {
break;
}
}
if (-1 == index) {
throw new ShardingConfigurationException("Actual table [%s].[%s] is not in table config", dataSource, otherActualTable);
}
for (TableRule each : tableRules) {
if (each.getLogicTable().equals(logicTable.toLowerCase())) {
return each.getActualDataNodes().get(index).getTableName().toLowerCase();
}
}
throw new ShardingConfigurationException("Cannot find binding actual table, data source: %s, logic table: %s, other actual table: %s", dataSource, logicTable, otherActualTable);
}
|
java
|
public String getBindingActualTable(final String dataSource, final String logicTable, final String otherActualTable) {
int index = -1;
for (TableRule each : tableRules) {
index = each.findActualTableIndex(dataSource, otherActualTable);
if (-1 != index) {
break;
}
}
if (-1 == index) {
throw new ShardingConfigurationException("Actual table [%s].[%s] is not in table config", dataSource, otherActualTable);
}
for (TableRule each : tableRules) {
if (each.getLogicTable().equals(logicTable.toLowerCase())) {
return each.getActualDataNodes().get(index).getTableName().toLowerCase();
}
}
throw new ShardingConfigurationException("Cannot find binding actual table, data source: %s, logic table: %s, other actual table: %s", dataSource, logicTable, otherActualTable);
}
|
[
"public",
"String",
"getBindingActualTable",
"(",
"final",
"String",
"dataSource",
",",
"final",
"String",
"logicTable",
",",
"final",
"String",
"otherActualTable",
")",
"{",
"int",
"index",
"=",
"-",
"1",
";",
"for",
"(",
"TableRule",
"each",
":",
"tableRules",
")",
"{",
"index",
"=",
"each",
".",
"findActualTableIndex",
"(",
"dataSource",
",",
"otherActualTable",
")",
";",
"if",
"(",
"-",
"1",
"!=",
"index",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"-",
"1",
"==",
"index",
")",
"{",
"throw",
"new",
"ShardingConfigurationException",
"(",
"\"Actual table [%s].[%s] is not in table config\"",
",",
"dataSource",
",",
"otherActualTable",
")",
";",
"}",
"for",
"(",
"TableRule",
"each",
":",
"tableRules",
")",
"{",
"if",
"(",
"each",
".",
"getLogicTable",
"(",
")",
".",
"equals",
"(",
"logicTable",
".",
"toLowerCase",
"(",
")",
")",
")",
"{",
"return",
"each",
".",
"getActualDataNodes",
"(",
")",
".",
"get",
"(",
"index",
")",
".",
"getTableName",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"}",
"}",
"throw",
"new",
"ShardingConfigurationException",
"(",
"\"Cannot find binding actual table, data source: %s, logic table: %s, other actual table: %s\"",
",",
"dataSource",
",",
"logicTable",
",",
"otherActualTable",
")",
";",
"}"
] |
Deduce actual table name from other actual table name in same binding table rule.
@param dataSource data source name
@param logicTable logic table name
@param otherActualTable other actual table name in same binding table rule
@return actual table name
|
[
"Deduce",
"actual",
"table",
"name",
"from",
"other",
"actual",
"table",
"name",
"in",
"same",
"binding",
"table",
"rule",
"."
] |
train
|
https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/rule/BindingTableRule.java#L65-L82
|
aws/aws-sdk-java
|
aws-java-sdk-sagemaker/src/main/java/com/amazonaws/services/sagemaker/model/HyperParameterTrainingJobSummary.java
|
HyperParameterTrainingJobSummary.withTunedHyperParameters
|
public HyperParameterTrainingJobSummary withTunedHyperParameters(java.util.Map<String, String> tunedHyperParameters) {
"""
<p>
A list of the hyperparameters for which you specified ranges to search.
</p>
@param tunedHyperParameters
A list of the hyperparameters for which you specified ranges to search.
@return Returns a reference to this object so that method calls can be chained together.
"""
setTunedHyperParameters(tunedHyperParameters);
return this;
}
|
java
|
public HyperParameterTrainingJobSummary withTunedHyperParameters(java.util.Map<String, String> tunedHyperParameters) {
setTunedHyperParameters(tunedHyperParameters);
return this;
}
|
[
"public",
"HyperParameterTrainingJobSummary",
"withTunedHyperParameters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tunedHyperParameters",
")",
"{",
"setTunedHyperParameters",
"(",
"tunedHyperParameters",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
A list of the hyperparameters for which you specified ranges to search.
</p>
@param tunedHyperParameters
A list of the hyperparameters for which you specified ranges to search.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"A",
"list",
"of",
"the",
"hyperparameters",
"for",
"which",
"you",
"specified",
"ranges",
"to",
"search",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-sagemaker/src/main/java/com/amazonaws/services/sagemaker/model/HyperParameterTrainingJobSummary.java#L477-L480
|
voldemort/voldemort
|
src/java/voldemort/tools/admin/command/AdminCommandCleanup.java
|
AdminCommandCleanup.executeHelp
|
public static void executeHelp(String[] args, PrintStream stream) throws Exception {
"""
Parses command-line input and prints help menu.
@throws Exception
"""
String subCmd = (args.length > 0) ? args[0] : "";
if(subCmd.equals("orphaned-data")) {
SubCommandCleanupOrphanedData.printHelp(stream);
} else if(subCmd.equals("vector-clocks")) {
SubCommandCleanupVectorClocks.printHelp(stream);
} else if(subCmd.equals("slops")) {
SubCommandCleanupSlops.printHelp(stream);
} else {
printHelp(stream);
}
}
|
java
|
public static void executeHelp(String[] args, PrintStream stream) throws Exception {
String subCmd = (args.length > 0) ? args[0] : "";
if(subCmd.equals("orphaned-data")) {
SubCommandCleanupOrphanedData.printHelp(stream);
} else if(subCmd.equals("vector-clocks")) {
SubCommandCleanupVectorClocks.printHelp(stream);
} else if(subCmd.equals("slops")) {
SubCommandCleanupSlops.printHelp(stream);
} else {
printHelp(stream);
}
}
|
[
"public",
"static",
"void",
"executeHelp",
"(",
"String",
"[",
"]",
"args",
",",
"PrintStream",
"stream",
")",
"throws",
"Exception",
"{",
"String",
"subCmd",
"=",
"(",
"args",
".",
"length",
">",
"0",
")",
"?",
"args",
"[",
"0",
"]",
":",
"\"\"",
";",
"if",
"(",
"subCmd",
".",
"equals",
"(",
"\"orphaned-data\"",
")",
")",
"{",
"SubCommandCleanupOrphanedData",
".",
"printHelp",
"(",
"stream",
")",
";",
"}",
"else",
"if",
"(",
"subCmd",
".",
"equals",
"(",
"\"vector-clocks\"",
")",
")",
"{",
"SubCommandCleanupVectorClocks",
".",
"printHelp",
"(",
"stream",
")",
";",
"}",
"else",
"if",
"(",
"subCmd",
".",
"equals",
"(",
"\"slops\"",
")",
")",
"{",
"SubCommandCleanupSlops",
".",
"printHelp",
"(",
"stream",
")",
";",
"}",
"else",
"{",
"printHelp",
"(",
"stream",
")",
";",
"}",
"}"
] |
Parses command-line input and prints help menu.
@throws Exception
|
[
"Parses",
"command",
"-",
"line",
"input",
"and",
"prints",
"help",
"menu",
"."
] |
train
|
https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/tools/admin/command/AdminCommandCleanup.java#L77-L88
|
sshtools/j2ssh-maverick
|
j2ssh-maverick/src/main/java/socks/server/ServerAuthenticatorNone.java
|
ServerAuthenticatorNone.startSession
|
public ServerAuthenticator startSession(Socket s)
throws IOException {
"""
Grants access to everyone.Removes authentication related bytes from
the stream, when a SOCKS5 connection is being made, selects an
authentication NONE.
"""
PushbackInputStream in = new PushbackInputStream(s.getInputStream());
OutputStream out = s.getOutputStream();
int version = in.read();
if(version == 5){
if(!selectSocks5Authentication(in,out,0))
return null;
}else if(version == 4){
//Else it is the request message allready, version 4
in.unread(version);
}else
return null;
return new ServerAuthenticatorNone(in,out);
}
|
java
|
public ServerAuthenticator startSession(Socket s)
throws IOException{
PushbackInputStream in = new PushbackInputStream(s.getInputStream());
OutputStream out = s.getOutputStream();
int version = in.read();
if(version == 5){
if(!selectSocks5Authentication(in,out,0))
return null;
}else if(version == 4){
//Else it is the request message allready, version 4
in.unread(version);
}else
return null;
return new ServerAuthenticatorNone(in,out);
}
|
[
"public",
"ServerAuthenticator",
"startSession",
"(",
"Socket",
"s",
")",
"throws",
"IOException",
"{",
"PushbackInputStream",
"in",
"=",
"new",
"PushbackInputStream",
"(",
"s",
".",
"getInputStream",
"(",
")",
")",
";",
"OutputStream",
"out",
"=",
"s",
".",
"getOutputStream",
"(",
")",
";",
"int",
"version",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"version",
"==",
"5",
")",
"{",
"if",
"(",
"!",
"selectSocks5Authentication",
"(",
"in",
",",
"out",
",",
"0",
")",
")",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"version",
"==",
"4",
")",
"{",
"//Else it is the request message allready, version 4",
"in",
".",
"unread",
"(",
"version",
")",
";",
"}",
"else",
"return",
"null",
";",
"return",
"new",
"ServerAuthenticatorNone",
"(",
"in",
",",
"out",
")",
";",
"}"
] |
Grants access to everyone.Removes authentication related bytes from
the stream, when a SOCKS5 connection is being made, selects an
authentication NONE.
|
[
"Grants",
"access",
"to",
"everyone",
".",
"Removes",
"authentication",
"related",
"bytes",
"from",
"the",
"stream",
"when",
"a",
"SOCKS5",
"connection",
"is",
"being",
"made",
"selects",
"an",
"authentication",
"NONE",
"."
] |
train
|
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/socks/server/ServerAuthenticatorNone.java#L89-L107
|
netplex/json-smart-v2
|
accessors-smart/src/main/java/net/minidev/asm/BeansAccessConfig.java
|
BeansAccessConfig.addTypeMapper
|
public static void addTypeMapper(Class<?> clz, Class<?> mapper) {
"""
Field type convertor for all classes
Convertor classes should contains mapping method Prototyped as:
public static DestinationType Method(Object data);
@see DefaultConverter
"""
synchronized (classMapper) {
LinkedHashSet<Class<?>> h = classMapper.get(clz);
if (h == null) {
h = new LinkedHashSet<Class<?>>();
classMapper.put(clz, h);
}
h.add(mapper);
}
}
|
java
|
public static void addTypeMapper(Class<?> clz, Class<?> mapper) {
synchronized (classMapper) {
LinkedHashSet<Class<?>> h = classMapper.get(clz);
if (h == null) {
h = new LinkedHashSet<Class<?>>();
classMapper.put(clz, h);
}
h.add(mapper);
}
}
|
[
"public",
"static",
"void",
"addTypeMapper",
"(",
"Class",
"<",
"?",
">",
"clz",
",",
"Class",
"<",
"?",
">",
"mapper",
")",
"{",
"synchronized",
"(",
"classMapper",
")",
"{",
"LinkedHashSet",
"<",
"Class",
"<",
"?",
">",
">",
"h",
"=",
"classMapper",
".",
"get",
"(",
"clz",
")",
";",
"if",
"(",
"h",
"==",
"null",
")",
"{",
"h",
"=",
"new",
"LinkedHashSet",
"<",
"Class",
"<",
"?",
">",
">",
"(",
")",
";",
"classMapper",
".",
"put",
"(",
"clz",
",",
"h",
")",
";",
"}",
"h",
".",
"add",
"(",
"mapper",
")",
";",
"}",
"}"
] |
Field type convertor for all classes
Convertor classes should contains mapping method Prototyped as:
public static DestinationType Method(Object data);
@see DefaultConverter
|
[
"Field",
"type",
"convertor",
"for",
"all",
"classes"
] |
train
|
https://github.com/netplex/json-smart-v2/blob/bfb3daef039e22a7bbff5f76bf14ea23330cd70e/accessors-smart/src/main/java/net/minidev/asm/BeansAccessConfig.java#L63-L73
|
Azure/azure-sdk-for-java
|
resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java
|
ResourcesInner.beginDeleteById
|
public void beginDeleteById(String resourceId, String apiVersion) {
"""
Deletes a resource by ID.
@param resourceId The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
@param apiVersion The API version to use for the operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
beginDeleteByIdWithServiceResponseAsync(resourceId, apiVersion).toBlocking().single().body();
}
|
java
|
public void beginDeleteById(String resourceId, String apiVersion) {
beginDeleteByIdWithServiceResponseAsync(resourceId, apiVersion).toBlocking().single().body();
}
|
[
"public",
"void",
"beginDeleteById",
"(",
"String",
"resourceId",
",",
"String",
"apiVersion",
")",
"{",
"beginDeleteByIdWithServiceResponseAsync",
"(",
"resourceId",
",",
"apiVersion",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Deletes a resource by ID.
@param resourceId The fully qualified ID of the resource, including the resource name and resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
@param apiVersion The API version to use for the operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
|
[
"Deletes",
"a",
"resource",
"by",
"ID",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java#L1987-L1989
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
|
MetaClassRegistryImpl.setMetaClass
|
private void setMetaClass(Class theClass, MetaClass oldMc, MetaClass newMc) {
"""
if oldMc is null, newMc will replace whatever meta class was used before.
if oldMc is not null, then newMc will be used only if he stored mc is
the same as oldMc
"""
final ClassInfo info = ClassInfo.getClassInfo(theClass);
MetaClass mc = null;
info.lock();
try {
mc = info.getStrongMetaClass();
info.setStrongMetaClass(newMc);
} finally {
info.unlock();
}
if ((oldMc == null && mc != newMc) || (oldMc != null && mc != newMc && mc != oldMc)) {
fireConstantMetaClassUpdate(null, theClass, mc, newMc);
}
}
|
java
|
private void setMetaClass(Class theClass, MetaClass oldMc, MetaClass newMc) {
final ClassInfo info = ClassInfo.getClassInfo(theClass);
MetaClass mc = null;
info.lock();
try {
mc = info.getStrongMetaClass();
info.setStrongMetaClass(newMc);
} finally {
info.unlock();
}
if ((oldMc == null && mc != newMc) || (oldMc != null && mc != newMc && mc != oldMc)) {
fireConstantMetaClassUpdate(null, theClass, mc, newMc);
}
}
|
[
"private",
"void",
"setMetaClass",
"(",
"Class",
"theClass",
",",
"MetaClass",
"oldMc",
",",
"MetaClass",
"newMc",
")",
"{",
"final",
"ClassInfo",
"info",
"=",
"ClassInfo",
".",
"getClassInfo",
"(",
"theClass",
")",
";",
"MetaClass",
"mc",
"=",
"null",
";",
"info",
".",
"lock",
"(",
")",
";",
"try",
"{",
"mc",
"=",
"info",
".",
"getStrongMetaClass",
"(",
")",
";",
"info",
".",
"setStrongMetaClass",
"(",
"newMc",
")",
";",
"}",
"finally",
"{",
"info",
".",
"unlock",
"(",
")",
";",
"}",
"if",
"(",
"(",
"oldMc",
"==",
"null",
"&&",
"mc",
"!=",
"newMc",
")",
"||",
"(",
"oldMc",
"!=",
"null",
"&&",
"mc",
"!=",
"newMc",
"&&",
"mc",
"!=",
"oldMc",
")",
")",
"{",
"fireConstantMetaClassUpdate",
"(",
"null",
",",
"theClass",
",",
"mc",
",",
"newMc",
")",
";",
"}",
"}"
] |
if oldMc is null, newMc will replace whatever meta class was used before.
if oldMc is not null, then newMc will be used only if he stored mc is
the same as oldMc
|
[
"if",
"oldMc",
"is",
"null",
"newMc",
"will",
"replace",
"whatever",
"meta",
"class",
"was",
"used",
"before",
".",
"if",
"oldMc",
"is",
"not",
"null",
"then",
"newMc",
"will",
"be",
"used",
"only",
"if",
"he",
"stored",
"mc",
"is",
"the",
"same",
"as",
"oldMc"
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java#L283-L297
|
stephenc/simple-java-mail
|
src/main/java/org/codemonkey/simplejavamail/EmailValidationUtil.java
|
EmailValidationUtil.isValid
|
public static boolean isValid(final String email, final EmailAddressValidationCriteria emailAddressValidationCriteria) {
"""
Validates an e-mail with given validation flags.
@param email A complete email address.
@param emailAddressValidationCriteria A set of flags that restrict or relax RFC 2822 compliance.
@return Whether the e-mail address is compliant with RFC 2822, configured using the passed in {@link EmailAddressValidationCriteria}.
@see EmailAddressValidationCriteria#EmailAddressValidationCriteria(boolean, boolean)
"""
return buildValidEmailPattern(emailAddressValidationCriteria).matcher(email).matches();
}
|
java
|
public static boolean isValid(final String email, final EmailAddressValidationCriteria emailAddressValidationCriteria) {
return buildValidEmailPattern(emailAddressValidationCriteria).matcher(email).matches();
}
|
[
"public",
"static",
"boolean",
"isValid",
"(",
"final",
"String",
"email",
",",
"final",
"EmailAddressValidationCriteria",
"emailAddressValidationCriteria",
")",
"{",
"return",
"buildValidEmailPattern",
"(",
"emailAddressValidationCriteria",
")",
".",
"matcher",
"(",
"email",
")",
".",
"matches",
"(",
")",
";",
"}"
] |
Validates an e-mail with given validation flags.
@param email A complete email address.
@param emailAddressValidationCriteria A set of flags that restrict or relax RFC 2822 compliance.
@return Whether the e-mail address is compliant with RFC 2822, configured using the passed in {@link EmailAddressValidationCriteria}.
@see EmailAddressValidationCriteria#EmailAddressValidationCriteria(boolean, boolean)
|
[
"Validates",
"an",
"e",
"-",
"mail",
"with",
"given",
"validation",
"flags",
"."
] |
train
|
https://github.com/stephenc/simple-java-mail/blob/8c5897e6bbc23c11e7c7eb5064f407625c653923/src/main/java/org/codemonkey/simplejavamail/EmailValidationUtil.java#L54-L56
|
pravega/pravega
|
segmentstore/server/src/main/java/io/pravega/segmentstore/server/tables/TableCompactor.java
|
TableCompactor.calculateTruncationOffset
|
long calculateTruncationOffset(SegmentProperties info, long highestCopiedOffset) {
"""
Calculates the offset in the Segment where it is safe to truncate based on the current state of the Segment and
the highest copied offset encountered during an index update.
This method is invoked from the {@link WriterTableProcessor} after indexing. Since compaction is loosely coupled
with indexing, the {@link WriterTableProcessor} does not have too many insights into what has been compacted or not;
it can only decide based on the current state of the Table Segment and what it has just indexed. As such:
- If recently indexed Table Entries indicate they were copied as part of a compaction, then it is safe to truncate
at the highest copied offset encountered (since they are copied in order, by offset). Everything prior to this
offset is guaranteed not to exist in the index anymore.
- If no recently indexed Table Entry indicates it was copied as a result of compaction, then it may not be safe to
truncate at {@link TableAttributes#COMPACTION_OFFSET}, because there may exist unindexed Table Entries that the
indexer hasn't gotten to yet. As such, it is only safe to truncate at {@link TableAttributes#COMPACTION_OFFSET}
if the indexer has indexed all the entries in the Table Segment.
@param info The {@link SegmentProperties} associated with the Table Segment to inquire about.
@param highestCopiedOffset The highest offset that was copied from a lower offset during a compaction. If the copied
entry has already been index then it is guaranteed that every entry prior to this
offset is no longer part of the index and can be safely truncated away.
@return The calculated truncation offset or a negative number if no truncation is required or possible given the
arguments provided.
"""
long truncateOffset = -1;
if (highestCopiedOffset > 0) {
// Due to the nature of compaction (all entries are copied in order of their original versions), if we encounter
// any copied Table Entries then the highest explicit version defined on any of them is where we can truncate.
truncateOffset = highestCopiedOffset;
} else if (this.indexReader.getLastIndexedOffset(info) >= info.getLength()) {
// Did not encounter any copied entries. If we were able to index the whole segment, then we should be safe
// to truncate at wherever the compaction last finished.
truncateOffset = this.indexReader.getCompactionOffset(info);
}
if (truncateOffset <= info.getStartOffset()) {
// The segment is already truncated at the compaction offset; no need for more.
truncateOffset = -1;
}
return truncateOffset;
}
|
java
|
long calculateTruncationOffset(SegmentProperties info, long highestCopiedOffset) {
long truncateOffset = -1;
if (highestCopiedOffset > 0) {
// Due to the nature of compaction (all entries are copied in order of their original versions), if we encounter
// any copied Table Entries then the highest explicit version defined on any of them is where we can truncate.
truncateOffset = highestCopiedOffset;
} else if (this.indexReader.getLastIndexedOffset(info) >= info.getLength()) {
// Did not encounter any copied entries. If we were able to index the whole segment, then we should be safe
// to truncate at wherever the compaction last finished.
truncateOffset = this.indexReader.getCompactionOffset(info);
}
if (truncateOffset <= info.getStartOffset()) {
// The segment is already truncated at the compaction offset; no need for more.
truncateOffset = -1;
}
return truncateOffset;
}
|
[
"long",
"calculateTruncationOffset",
"(",
"SegmentProperties",
"info",
",",
"long",
"highestCopiedOffset",
")",
"{",
"long",
"truncateOffset",
"=",
"-",
"1",
";",
"if",
"(",
"highestCopiedOffset",
">",
"0",
")",
"{",
"// Due to the nature of compaction (all entries are copied in order of their original versions), if we encounter",
"// any copied Table Entries then the highest explicit version defined on any of them is where we can truncate.",
"truncateOffset",
"=",
"highestCopiedOffset",
";",
"}",
"else",
"if",
"(",
"this",
".",
"indexReader",
".",
"getLastIndexedOffset",
"(",
"info",
")",
">=",
"info",
".",
"getLength",
"(",
")",
")",
"{",
"// Did not encounter any copied entries. If we were able to index the whole segment, then we should be safe",
"// to truncate at wherever the compaction last finished.",
"truncateOffset",
"=",
"this",
".",
"indexReader",
".",
"getCompactionOffset",
"(",
"info",
")",
";",
"}",
"if",
"(",
"truncateOffset",
"<=",
"info",
".",
"getStartOffset",
"(",
")",
")",
"{",
"// The segment is already truncated at the compaction offset; no need for more.",
"truncateOffset",
"=",
"-",
"1",
";",
"}",
"return",
"truncateOffset",
";",
"}"
] |
Calculates the offset in the Segment where it is safe to truncate based on the current state of the Segment and
the highest copied offset encountered during an index update.
This method is invoked from the {@link WriterTableProcessor} after indexing. Since compaction is loosely coupled
with indexing, the {@link WriterTableProcessor} does not have too many insights into what has been compacted or not;
it can only decide based on the current state of the Table Segment and what it has just indexed. As such:
- If recently indexed Table Entries indicate they were copied as part of a compaction, then it is safe to truncate
at the highest copied offset encountered (since they are copied in order, by offset). Everything prior to this
offset is guaranteed not to exist in the index anymore.
- If no recently indexed Table Entry indicates it was copied as a result of compaction, then it may not be safe to
truncate at {@link TableAttributes#COMPACTION_OFFSET}, because there may exist unindexed Table Entries that the
indexer hasn't gotten to yet. As such, it is only safe to truncate at {@link TableAttributes#COMPACTION_OFFSET}
if the indexer has indexed all the entries in the Table Segment.
@param info The {@link SegmentProperties} associated with the Table Segment to inquire about.
@param highestCopiedOffset The highest offset that was copied from a lower offset during a compaction. If the copied
entry has already been index then it is guaranteed that every entry prior to this
offset is no longer part of the index and can be safely truncated away.
@return The calculated truncation offset or a negative number if no truncation is required or possible given the
arguments provided.
|
[
"Calculates",
"the",
"offset",
"in",
"the",
"Segment",
"where",
"it",
"is",
"safe",
"to",
"truncate",
"based",
"on",
"the",
"current",
"state",
"of",
"the",
"Segment",
"and",
"the",
"highest",
"copied",
"offset",
"encountered",
"during",
"an",
"index",
"update",
"."
] |
train
|
https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/tables/TableCompactor.java#L125-L143
|
livetribe/livetribe-slp
|
core/src/main/java/org/livetribe/slp/sa/StandardServiceAgentServer.java
|
StandardServiceAgentServer.handleTCPSrvRqst
|
protected void handleTCPSrvRqst(SrvRqst srvRqst, Socket socket) {
"""
Handles a unicast TCP SrvRqst message arrived to this service agent.
<br />
This service agent will reply with a list of matching services.
@param srvRqst the SrvRqst message to handle
@param socket the socket connected to the client where to write the reply
"""
// Match scopes
if (!getScopes().weakMatch(srvRqst.getScopes()))
{
if (logger.isLoggable(Level.FINE))
logger.fine("ServiceAgent server " + this + " dropping message " + srvRqst + ": no scopes match among agent scopes " + getScopes() + " and message scopes " + srvRqst.getScopes());
return;
}
List<ServiceInfo> matchingServices = matchServices(srvRqst.getServiceType(), srvRqst.getLanguage(), srvRqst.getScopes(), srvRqst.getFilter());
if (logger.isLoggable(Level.FINE))
logger.fine("ServiceAgent server " + this + " returning " + matchingServices.size() + " services of type " + srvRqst.getServiceType());
tcpSrvRply.perform(socket, srvRqst, matchingServices);
}
|
java
|
protected void handleTCPSrvRqst(SrvRqst srvRqst, Socket socket)
{
// Match scopes
if (!getScopes().weakMatch(srvRqst.getScopes()))
{
if (logger.isLoggable(Level.FINE))
logger.fine("ServiceAgent server " + this + " dropping message " + srvRqst + ": no scopes match among agent scopes " + getScopes() + " and message scopes " + srvRqst.getScopes());
return;
}
List<ServiceInfo> matchingServices = matchServices(srvRqst.getServiceType(), srvRqst.getLanguage(), srvRqst.getScopes(), srvRqst.getFilter());
if (logger.isLoggable(Level.FINE))
logger.fine("ServiceAgent server " + this + " returning " + matchingServices.size() + " services of type " + srvRqst.getServiceType());
tcpSrvRply.perform(socket, srvRqst, matchingServices);
}
|
[
"protected",
"void",
"handleTCPSrvRqst",
"(",
"SrvRqst",
"srvRqst",
",",
"Socket",
"socket",
")",
"{",
"// Match scopes",
"if",
"(",
"!",
"getScopes",
"(",
")",
".",
"weakMatch",
"(",
"srvRqst",
".",
"getScopes",
"(",
")",
")",
")",
"{",
"if",
"(",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"logger",
".",
"fine",
"(",
"\"ServiceAgent server \"",
"+",
"this",
"+",
"\" dropping message \"",
"+",
"srvRqst",
"+",
"\": no scopes match among agent scopes \"",
"+",
"getScopes",
"(",
")",
"+",
"\" and message scopes \"",
"+",
"srvRqst",
".",
"getScopes",
"(",
")",
")",
";",
"return",
";",
"}",
"List",
"<",
"ServiceInfo",
">",
"matchingServices",
"=",
"matchServices",
"(",
"srvRqst",
".",
"getServiceType",
"(",
")",
",",
"srvRqst",
".",
"getLanguage",
"(",
")",
",",
"srvRqst",
".",
"getScopes",
"(",
")",
",",
"srvRqst",
".",
"getFilter",
"(",
")",
")",
";",
"if",
"(",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"logger",
".",
"fine",
"(",
"\"ServiceAgent server \"",
"+",
"this",
"+",
"\" returning \"",
"+",
"matchingServices",
".",
"size",
"(",
")",
"+",
"\" services of type \"",
"+",
"srvRqst",
".",
"getServiceType",
"(",
")",
")",
";",
"tcpSrvRply",
".",
"perform",
"(",
"socket",
",",
"srvRqst",
",",
"matchingServices",
")",
";",
"}"
] |
Handles a unicast TCP SrvRqst message arrived to this service agent.
<br />
This service agent will reply with a list of matching services.
@param srvRqst the SrvRqst message to handle
@param socket the socket connected to the client where to write the reply
|
[
"Handles",
"a",
"unicast",
"TCP",
"SrvRqst",
"message",
"arrived",
"to",
"this",
"service",
"agent",
".",
"<br",
"/",
">",
"This",
"service",
"agent",
"will",
"reply",
"with",
"a",
"list",
"of",
"matching",
"services",
"."
] |
train
|
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/sa/StandardServiceAgentServer.java#L216-L230
|
foundation-runtime/logging
|
logging-log4j/src/main/java/com/cisco/oss/foundation/logging/LoggingHelper.java
|
LoggingHelper.formatConnectionTerminationMessage
|
public static String formatConnectionTerminationMessage(final String connectionName, final String host, final String connectionReason, final String terminationReason) {
"""
Helper method for formatting connection termination messages.
@param connectionName
The name of the connection
@param host
The remote host
@param connectionReason
The reason for establishing the connection
@param terminationReason
The reason for terminating the connection
@return A formatted message in the format:
"[<connectionName>] remote host[<host>] <connectionReason> - <terminationReason>"
<br/>
e.g. [con1] remote host[123.123.123.123] connection to ECMG -
terminated by remote host.
"""
return CON_TERMINATION_FORMAT.format(new Object[] { connectionName, host, connectionReason, terminationReason });
}
|
java
|
public static String formatConnectionTerminationMessage(final String connectionName, final String host, final String connectionReason, final String terminationReason) {
return CON_TERMINATION_FORMAT.format(new Object[] { connectionName, host, connectionReason, terminationReason });
}
|
[
"public",
"static",
"String",
"formatConnectionTerminationMessage",
"(",
"final",
"String",
"connectionName",
",",
"final",
"String",
"host",
",",
"final",
"String",
"connectionReason",
",",
"final",
"String",
"terminationReason",
")",
"{",
"return",
"CON_TERMINATION_FORMAT",
".",
"format",
"(",
"new",
"Object",
"[",
"]",
"{",
"connectionName",
",",
"host",
",",
"connectionReason",
",",
"terminationReason",
"}",
")",
";",
"}"
] |
Helper method for formatting connection termination messages.
@param connectionName
The name of the connection
@param host
The remote host
@param connectionReason
The reason for establishing the connection
@param terminationReason
The reason for terminating the connection
@return A formatted message in the format:
"[<connectionName>] remote host[<host>] <connectionReason> - <terminationReason>"
<br/>
e.g. [con1] remote host[123.123.123.123] connection to ECMG -
terminated by remote host.
|
[
"Helper",
"method",
"for",
"formatting",
"connection",
"termination",
"messages",
"."
] |
train
|
https://github.com/foundation-runtime/logging/blob/cd0a07b3c5b458ecf90ab92a1e0c72a067f5cbd6/logging-log4j/src/main/java/com/cisco/oss/foundation/logging/LoggingHelper.java#L486-L488
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/lang/Assert.java
|
Assert.notEmpty
|
public static <K, V> Map<K, V> notEmpty(Map<K, V> map) throws IllegalArgumentException {
"""
断言给定Map非空
<pre class="code">
Assert.notEmpty(map, "Map must have entries");
</pre>
@param <K> Key类型
@param <V> Value类型
@param map 被检查的Map
@return 被检查的Map
@throws IllegalArgumentException if the map is {@code null} or has no entries
"""
return notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
}
|
java
|
public static <K, V> Map<K, V> notEmpty(Map<K, V> map) throws IllegalArgumentException {
return notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"notEmpty",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
")",
"throws",
"IllegalArgumentException",
"{",
"return",
"notEmpty",
"(",
"map",
",",
"\"[Assertion failed] - this map must not be empty; it must contain at least one entry\"",
")",
";",
"}"
] |
断言给定Map非空
<pre class="code">
Assert.notEmpty(map, "Map must have entries");
</pre>
@param <K> Key类型
@param <V> Value类型
@param map 被检查的Map
@return 被检查的Map
@throws IllegalArgumentException if the map is {@code null} or has no entries
|
[
"断言给定Map非空"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/Assert.java#L411-L413
|
gmessner/gitlab4j-api
|
src/main/java/org/gitlab4j/api/JobApi.java
|
JobApi.downloadArtifactsFile
|
public InputStream downloadArtifactsFile(Object projectIdOrPath, Integer jobId) throws GitLabApiException {
"""
Get an InputStream pointing to the job artifacts file for the specified job ID.
<pre><code>GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts</code></pre>
@param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@param jobId the job ID to get the artifacts for
@return an InputStream to read the specified job artifacts file
@throws GitLabApiException if any exception occurs
"""
Response response = getWithAccepts(Response.Status.OK, null, MediaType.MEDIA_TYPE_WILDCARD,
"projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts");
return (response.readEntity(InputStream.class));
}
|
java
|
public InputStream downloadArtifactsFile(Object projectIdOrPath, Integer jobId) throws GitLabApiException {
Response response = getWithAccepts(Response.Status.OK, null, MediaType.MEDIA_TYPE_WILDCARD,
"projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts");
return (response.readEntity(InputStream.class));
}
|
[
"public",
"InputStream",
"downloadArtifactsFile",
"(",
"Object",
"projectIdOrPath",
",",
"Integer",
"jobId",
")",
"throws",
"GitLabApiException",
"{",
"Response",
"response",
"=",
"getWithAccepts",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"null",
",",
"MediaType",
".",
"MEDIA_TYPE_WILDCARD",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"jobs\"",
",",
"jobId",
",",
"\"artifacts\"",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"InputStream",
".",
"class",
")",
")",
";",
"}"
] |
Get an InputStream pointing to the job artifacts file for the specified job ID.
<pre><code>GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts</code></pre>
@param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@param jobId the job ID to get the artifacts for
@return an InputStream to read the specified job artifacts file
@throws GitLabApiException if any exception occurs
|
[
"Get",
"an",
"InputStream",
"pointing",
"to",
"the",
"job",
"artifacts",
"file",
"for",
"the",
"specified",
"job",
"ID",
"."
] |
train
|
https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/JobApi.java#L298-L302
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/application/NavigationHandlerImpl.java
|
NavigationHandlerImpl.getViewId
|
public String getViewId(FacesContext context, String fromAction, String outcome) {
"""
Returns the view ID that would be created for the given action and outcome
"""
return this.getNavigationCase(context, fromAction, outcome).getToViewId(context);
}
|
java
|
public String getViewId(FacesContext context, String fromAction, String outcome)
{
return this.getNavigationCase(context, fromAction, outcome).getToViewId(context);
}
|
[
"public",
"String",
"getViewId",
"(",
"FacesContext",
"context",
",",
"String",
"fromAction",
",",
"String",
"outcome",
")",
"{",
"return",
"this",
".",
"getNavigationCase",
"(",
"context",
",",
"fromAction",
",",
"outcome",
")",
".",
"getToViewId",
"(",
"context",
")",
";",
"}"
] |
Returns the view ID that would be created for the given action and outcome
|
[
"Returns",
"the",
"view",
"ID",
"that",
"would",
"be",
"created",
"for",
"the",
"given",
"action",
"and",
"outcome"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/application/NavigationHandlerImpl.java#L1155-L1158
|
osglworks/java-tool
|
src/main/java/org/osgl/util/E.java
|
E.NPE
|
public static void NPE(Object o1, Object o2, Object o3, Object... objects) {
"""
Throw out NullPointerException if any one of the passed objects is null.
@param o1
the first object to be evaluated
@param o2
the second object to be evaluated
@param o3
the third object to be evaluated
@param objects
other object instances to be evaluated
"""
NPE(o1, o2, o3);
for (Object o : objects) {
if (null == o) {
throw new NullPointerException();
}
}
}
|
java
|
public static void NPE(Object o1, Object o2, Object o3, Object... objects) {
NPE(o1, o2, o3);
for (Object o : objects) {
if (null == o) {
throw new NullPointerException();
}
}
}
|
[
"public",
"static",
"void",
"NPE",
"(",
"Object",
"o1",
",",
"Object",
"o2",
",",
"Object",
"o3",
",",
"Object",
"...",
"objects",
")",
"{",
"NPE",
"(",
"o1",
",",
"o2",
",",
"o3",
")",
";",
"for",
"(",
"Object",
"o",
":",
"objects",
")",
"{",
"if",
"(",
"null",
"==",
"o",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"}",
"}"
] |
Throw out NullPointerException if any one of the passed objects is null.
@param o1
the first object to be evaluated
@param o2
the second object to be evaluated
@param o3
the third object to be evaluated
@param objects
other object instances to be evaluated
|
[
"Throw",
"out",
"NullPointerException",
"if",
"any",
"one",
"of",
"the",
"passed",
"objects",
"is",
"null",
"."
] |
train
|
https://github.com/osglworks/java-tool/blob/8b6eee2bccb067eb32e6a7bc4a4dfef7a7d9008b/src/main/java/org/osgl/util/E.java#L150-L157
|
threerings/gwt-utils
|
src/main/java/com/threerings/gwt/ui/WidgetUtil.java
|
WidgetUtil.createApplet
|
public static HTML createApplet (String ident, String archive, String clazz, int width,
int height, boolean mayScript, String[] params) {
"""
Creates the HTML to display a Java applet for the browser on which we're running.
"""
return createApplet(ident, archive, clazz, ""+width, ""+height, mayScript, params);
}
|
java
|
public static HTML createApplet (String ident, String archive, String clazz, int width,
int height, boolean mayScript, String[] params)
{
return createApplet(ident, archive, clazz, ""+width, ""+height, mayScript, params);
}
|
[
"public",
"static",
"HTML",
"createApplet",
"(",
"String",
"ident",
",",
"String",
"archive",
",",
"String",
"clazz",
",",
"int",
"width",
",",
"int",
"height",
",",
"boolean",
"mayScript",
",",
"String",
"[",
"]",
"params",
")",
"{",
"return",
"createApplet",
"(",
"ident",
",",
"archive",
",",
"clazz",
",",
"\"\"",
"+",
"width",
",",
"\"\"",
"+",
"height",
",",
"mayScript",
",",
"params",
")",
";",
"}"
] |
Creates the HTML to display a Java applet for the browser on which we're running.
|
[
"Creates",
"the",
"HTML",
"to",
"display",
"a",
"Java",
"applet",
"for",
"the",
"browser",
"on",
"which",
"we",
"re",
"running",
"."
] |
train
|
https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/WidgetUtil.java#L219-L223
|
FlyingHe/UtilsMaven
|
src/main/java/com/github/flyinghe/tools/WriteExcelUtils.java
|
WriteExcelUtils.writeWorkBook
|
public static <T> Workbook writeWorkBook(Workbook workbook, List<T> beans) {
"""
将Beans写入WorkBook中,默认以bean中的所有属性作为标题且写入第0行,0-based
@param workbook 指定工作簿
@param beans 指定写入的Beans(或者泛型为Map)
@return 返回传入的WorkBook
"""
return WriteExcelUtils.writeWorkBook(workbook, beans, null);
}
|
java
|
public static <T> Workbook writeWorkBook(Workbook workbook, List<T> beans) {
return WriteExcelUtils.writeWorkBook(workbook, beans, null);
}
|
[
"public",
"static",
"<",
"T",
">",
"Workbook",
"writeWorkBook",
"(",
"Workbook",
"workbook",
",",
"List",
"<",
"T",
">",
"beans",
")",
"{",
"return",
"WriteExcelUtils",
".",
"writeWorkBook",
"(",
"workbook",
",",
"beans",
",",
"null",
")",
";",
"}"
] |
将Beans写入WorkBook中,默认以bean中的所有属性作为标题且写入第0行,0-based
@param workbook 指定工作簿
@param beans 指定写入的Beans(或者泛型为Map)
@return 返回传入的WorkBook
|
[
"将Beans写入WorkBook中",
"默认以bean中的所有属性作为标题且写入第0行,0",
"-",
"based"
] |
train
|
https://github.com/FlyingHe/UtilsMaven/blob/d9605b7bfe0c28a05289252e12d163e114080b4a/src/main/java/com/github/flyinghe/tools/WriteExcelUtils.java#L353-L355
|
eclipse/hawkbit
|
hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java
|
SPUIComponentProvider.getHelpLink
|
public static Link getHelpLink(final VaadinMessageSource i18n, final String uri) {
"""
Generates help/documentation links from within management UI.
@param i18n
the i18n
@param uri
to documentation site
@return generated link
"""
final Link link = new Link("", new ExternalResource(uri));
link.setTargetName("_blank");
link.setIcon(FontAwesome.QUESTION_CIRCLE);
link.setDescription(i18n.getMessage("tooltip.documentation.link"));
return link;
}
|
java
|
public static Link getHelpLink(final VaadinMessageSource i18n, final String uri) {
final Link link = new Link("", new ExternalResource(uri));
link.setTargetName("_blank");
link.setIcon(FontAwesome.QUESTION_CIRCLE);
link.setDescription(i18n.getMessage("tooltip.documentation.link"));
return link;
}
|
[
"public",
"static",
"Link",
"getHelpLink",
"(",
"final",
"VaadinMessageSource",
"i18n",
",",
"final",
"String",
"uri",
")",
"{",
"final",
"Link",
"link",
"=",
"new",
"Link",
"(",
"\"\"",
",",
"new",
"ExternalResource",
"(",
"uri",
")",
")",
";",
"link",
".",
"setTargetName",
"(",
"\"_blank\"",
")",
";",
"link",
".",
"setIcon",
"(",
"FontAwesome",
".",
"QUESTION_CIRCLE",
")",
";",
"link",
".",
"setDescription",
"(",
"i18n",
".",
"getMessage",
"(",
"\"tooltip.documentation.link\"",
")",
")",
";",
"return",
"link",
";",
"}"
] |
Generates help/documentation links from within management UI.
@param i18n
the i18n
@param uri
to documentation site
@return generated link
|
[
"Generates",
"help",
"/",
"documentation",
"links",
"from",
"within",
"management",
"UI",
"."
] |
train
|
https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java#L343-L351
|
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/AirlineItineraryTemplateBuilder.java
|
AirlineItineraryTemplateBuilder.addPriceInfo
|
public AirlineItineraryTemplateBuilder addPriceInfo(String title,
BigDecimal amount) {
"""
Adds a {@link PriceInfo} object to this template. This field is optional.
There can be at most 4 price info objects per template.
@param title
the price info title. It can't be empty.
@param amount
the price amount.
@return this builder.
"""
PriceInfo priceInfo = new PriceInfo(title, amount);
this.payload.addPriceInfo(priceInfo);
return this;
}
|
java
|
public AirlineItineraryTemplateBuilder addPriceInfo(String title,
BigDecimal amount) {
PriceInfo priceInfo = new PriceInfo(title, amount);
this.payload.addPriceInfo(priceInfo);
return this;
}
|
[
"public",
"AirlineItineraryTemplateBuilder",
"addPriceInfo",
"(",
"String",
"title",
",",
"BigDecimal",
"amount",
")",
"{",
"PriceInfo",
"priceInfo",
"=",
"new",
"PriceInfo",
"(",
"title",
",",
"amount",
")",
";",
"this",
".",
"payload",
".",
"addPriceInfo",
"(",
"priceInfo",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a {@link PriceInfo} object to this template. This field is optional.
There can be at most 4 price info objects per template.
@param title
the price info title. It can't be empty.
@param amount
the price amount.
@return this builder.
|
[
"Adds",
"a",
"{",
"@link",
"PriceInfo",
"}",
"object",
"to",
"this",
"template",
".",
"This",
"field",
"is",
"optional",
".",
"There",
"can",
"be",
"at",
"most",
"4",
"price",
"info",
"objects",
"per",
"template",
"."
] |
train
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/AirlineItineraryTemplateBuilder.java#L216-L221
|
groupon/robo-remote
|
RoboRemoteServer/apklib/src/main/com/groupon/roboremote/roboremoteserver/robotium/Solo2.java
|
Solo2.getLocalizedResource
|
public String getLocalizedResource(String namespace, String resourceId) throws Exception {
"""
Returns a string for a resourceId in the specified namespace
@param namespace
@param resourceId
@return
@throws Exception
"""
String resourceValue = "";
Class r = Class.forName(namespace + "$string");
Field f = r.getField(resourceId);
resourceValue = getCurrentActivity().getResources().getString(f.getInt(f));
return resourceValue;
}
|
java
|
public String getLocalizedResource(String namespace, String resourceId) throws Exception {
String resourceValue = "";
Class r = Class.forName(namespace + "$string");
Field f = r.getField(resourceId);
resourceValue = getCurrentActivity().getResources().getString(f.getInt(f));
return resourceValue;
}
|
[
"public",
"String",
"getLocalizedResource",
"(",
"String",
"namespace",
",",
"String",
"resourceId",
")",
"throws",
"Exception",
"{",
"String",
"resourceValue",
"=",
"\"\"",
";",
"Class",
"r",
"=",
"Class",
".",
"forName",
"(",
"namespace",
"+",
"\"$string\"",
")",
";",
"Field",
"f",
"=",
"r",
".",
"getField",
"(",
"resourceId",
")",
";",
"resourceValue",
"=",
"getCurrentActivity",
"(",
")",
".",
"getResources",
"(",
")",
".",
"getString",
"(",
"f",
".",
"getInt",
"(",
"f",
")",
")",
";",
"return",
"resourceValue",
";",
"}"
] |
Returns a string for a resourceId in the specified namespace
@param namespace
@param resourceId
@return
@throws Exception
|
[
"Returns",
"a",
"string",
"for",
"a",
"resourceId",
"in",
"the",
"specified",
"namespace"
] |
train
|
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/RoboRemoteServer/apklib/src/main/com/groupon/roboremote/roboremoteserver/robotium/Solo2.java#L288-L296
|
actorapp/actor-platform
|
actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/actors/ActorRef.java
|
ActorRef.sendFirst
|
public void sendFirst(Object message, ActorRef sender) {
"""
Sending message before all other messages
@param message message
@param sender sender
"""
endpoint.getMailbox().scheduleFirst(new Envelope(message, endpoint.getScope(), endpoint.getMailbox(), sender));
}
|
java
|
public void sendFirst(Object message, ActorRef sender) {
endpoint.getMailbox().scheduleFirst(new Envelope(message, endpoint.getScope(), endpoint.getMailbox(), sender));
}
|
[
"public",
"void",
"sendFirst",
"(",
"Object",
"message",
",",
"ActorRef",
"sender",
")",
"{",
"endpoint",
".",
"getMailbox",
"(",
")",
".",
"scheduleFirst",
"(",
"new",
"Envelope",
"(",
"message",
",",
"endpoint",
".",
"getScope",
"(",
")",
",",
"endpoint",
".",
"getMailbox",
"(",
")",
",",
"sender",
")",
")",
";",
"}"
] |
Sending message before all other messages
@param message message
@param sender sender
|
[
"Sending",
"message",
"before",
"all",
"other",
"messages"
] |
train
|
https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/actors/ActorRef.java#L75-L77
|
jboss/jboss-saaj-api_spec
|
src/main/java/javax/xml/soap/MimeHeaders.java
|
MimeHeaders.setHeader
|
public void setHeader(String name, String value) {
"""
Replaces the current value of the first header entry whose name matches
the given name with the given value, adding a new header if no existing header
name matches. This method also removes all matching headers after the first one.
<P>
Note that RFC822 headers can contain only US-ASCII characters.
@param name a <code>String</code> with the name of the header for
which to search
@param value a <code>String</code> with the value that will replace the
current value of the specified header
@exception IllegalArgumentException if there was a problem in the
mime header name or the value being set
@see #getHeader
"""
boolean found = false;
if ((name == null) || name.equals(""))
throw new IllegalArgumentException("Illegal MimeHeader name");
for(int i = 0; i < headers.size(); i++) {
MimeHeader hdr = (MimeHeader) headers.elementAt(i);
if (hdr.getName().equalsIgnoreCase(name)) {
if (!found) {
headers.setElementAt(new MimeHeader(hdr.getName(),
value), i);
found = true;
}
else
headers.removeElementAt(i--);
}
}
if (!found)
addHeader(name, value);
}
|
java
|
public void setHeader(String name, String value)
{
boolean found = false;
if ((name == null) || name.equals(""))
throw new IllegalArgumentException("Illegal MimeHeader name");
for(int i = 0; i < headers.size(); i++) {
MimeHeader hdr = (MimeHeader) headers.elementAt(i);
if (hdr.getName().equalsIgnoreCase(name)) {
if (!found) {
headers.setElementAt(new MimeHeader(hdr.getName(),
value), i);
found = true;
}
else
headers.removeElementAt(i--);
}
}
if (!found)
addHeader(name, value);
}
|
[
"public",
"void",
"setHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"boolean",
"found",
"=",
"false",
";",
"if",
"(",
"(",
"name",
"==",
"null",
")",
"||",
"name",
".",
"equals",
"(",
"\"\"",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Illegal MimeHeader name\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"headers",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"MimeHeader",
"hdr",
"=",
"(",
"MimeHeader",
")",
"headers",
".",
"elementAt",
"(",
"i",
")",
";",
"if",
"(",
"hdr",
".",
"getName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"name",
")",
")",
"{",
"if",
"(",
"!",
"found",
")",
"{",
"headers",
".",
"setElementAt",
"(",
"new",
"MimeHeader",
"(",
"hdr",
".",
"getName",
"(",
")",
",",
"value",
")",
",",
"i",
")",
";",
"found",
"=",
"true",
";",
"}",
"else",
"headers",
".",
"removeElementAt",
"(",
"i",
"--",
")",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"addHeader",
"(",
"name",
",",
"value",
")",
";",
"}"
] |
Replaces the current value of the first header entry whose name matches
the given name with the given value, adding a new header if no existing header
name matches. This method also removes all matching headers after the first one.
<P>
Note that RFC822 headers can contain only US-ASCII characters.
@param name a <code>String</code> with the name of the header for
which to search
@param value a <code>String</code> with the value that will replace the
current value of the specified header
@exception IllegalArgumentException if there was a problem in the
mime header name or the value being set
@see #getHeader
|
[
"Replaces",
"the",
"current",
"value",
"of",
"the",
"first",
"header",
"entry",
"whose",
"name",
"matches",
"the",
"given",
"name",
"with",
"the",
"given",
"value",
"adding",
"a",
"new",
"header",
"if",
"no",
"existing",
"header",
"name",
"matches",
".",
"This",
"method",
"also",
"removes",
"all",
"matching",
"headers",
"after",
"the",
"first",
"one",
".",
"<P",
">",
"Note",
"that",
"RFC822",
"headers",
"can",
"contain",
"only",
"US",
"-",
"ASCII",
"characters",
"."
] |
train
|
https://github.com/jboss/jboss-saaj-api_spec/blob/2dda4e662e4f99b289f3a8d944a68cf537c78dd4/src/main/java/javax/xml/soap/MimeHeaders.java#L99-L121
|
pedrovgs/Nox
|
nox/src/main/java/com/github/pedrovgs/nox/NoxItemCatalog.java
|
NoxItemCatalog.loadNoxItem
|
private void loadNoxItem(final int position, NoxItem noxItem, boolean useCircularTransformation) {
"""
Starts the resource download given a NoxItem instance and a given position.
"""
imageLoader.load(noxItem.getUrl())
.load(noxItem.getResourceId())
.withPlaceholder(noxItem.getPlaceholderId())
.size(noxItemSize)
.useCircularTransformation(useCircularTransformation)
.notify(getImageLoaderListener(position));
}
|
java
|
private void loadNoxItem(final int position, NoxItem noxItem, boolean useCircularTransformation) {
imageLoader.load(noxItem.getUrl())
.load(noxItem.getResourceId())
.withPlaceholder(noxItem.getPlaceholderId())
.size(noxItemSize)
.useCircularTransformation(useCircularTransformation)
.notify(getImageLoaderListener(position));
}
|
[
"private",
"void",
"loadNoxItem",
"(",
"final",
"int",
"position",
",",
"NoxItem",
"noxItem",
",",
"boolean",
"useCircularTransformation",
")",
"{",
"imageLoader",
".",
"load",
"(",
"noxItem",
".",
"getUrl",
"(",
")",
")",
".",
"load",
"(",
"noxItem",
".",
"getResourceId",
"(",
")",
")",
".",
"withPlaceholder",
"(",
"noxItem",
".",
"getPlaceholderId",
"(",
")",
")",
".",
"size",
"(",
"noxItemSize",
")",
".",
"useCircularTransformation",
"(",
"useCircularTransformation",
")",
".",
"notify",
"(",
"getImageLoaderListener",
"(",
"position",
")",
")",
";",
"}"
] |
Starts the resource download given a NoxItem instance and a given position.
|
[
"Starts",
"the",
"resource",
"download",
"given",
"a",
"NoxItem",
"instance",
"and",
"a",
"given",
"position",
"."
] |
train
|
https://github.com/pedrovgs/Nox/blob/b4dfe37895e1b7bf2084d60139931dd4fb12f3f4/nox/src/main/java/com/github/pedrovgs/nox/NoxItemCatalog.java#L237-L244
|
h2oai/h2o-2
|
src/main/java/water/TimeLine.java
|
TimeLine.record_IOclose
|
public static void record_IOclose( long start_ns, long start_io_ms, int r_w, long size, int flavor ) {
"""
/* Record an I/O call without using an AutoBuffer / NIO.
Used by e.g. HDFS & S3
@param block_ns - ns of blocking i/o call,
@param io_msg - ms of overall i/o time
@param r_w - 1 for read, 0 for write
@param size - bytes read/written
@param flavor - Value.HDFS or Value.S3
"""
long block_ns = System.nanoTime() - start_ns;
long io_ms = System.currentTimeMillis() - start_io_ms;
// First long word going out has sender-port and a 'bad' control packet
long b0 = UDP.udp.i_o.ordinal(); // Special flag to indicate io-record and not a rpc-record
b0 |= H2O.SELF._key.udp_port()<<8;
b0 |= flavor<<24; // I/O flavor; one of the Value.persist backends
b0 |= io_ms<<32; // msec from start-to-finish, including non-i/o overheads
record2(H2O.SELF,block_ns,true,r_w,0,b0,size);
}
|
java
|
public static void record_IOclose( long start_ns, long start_io_ms, int r_w, long size, int flavor ) {
long block_ns = System.nanoTime() - start_ns;
long io_ms = System.currentTimeMillis() - start_io_ms;
// First long word going out has sender-port and a 'bad' control packet
long b0 = UDP.udp.i_o.ordinal(); // Special flag to indicate io-record and not a rpc-record
b0 |= H2O.SELF._key.udp_port()<<8;
b0 |= flavor<<24; // I/O flavor; one of the Value.persist backends
b0 |= io_ms<<32; // msec from start-to-finish, including non-i/o overheads
record2(H2O.SELF,block_ns,true,r_w,0,b0,size);
}
|
[
"public",
"static",
"void",
"record_IOclose",
"(",
"long",
"start_ns",
",",
"long",
"start_io_ms",
",",
"int",
"r_w",
",",
"long",
"size",
",",
"int",
"flavor",
")",
"{",
"long",
"block_ns",
"=",
"System",
".",
"nanoTime",
"(",
")",
"-",
"start_ns",
";",
"long",
"io_ms",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start_io_ms",
";",
"// First long word going out has sender-port and a 'bad' control packet",
"long",
"b0",
"=",
"UDP",
".",
"udp",
".",
"i_o",
".",
"ordinal",
"(",
")",
";",
"// Special flag to indicate io-record and not a rpc-record",
"b0",
"|=",
"H2O",
".",
"SELF",
".",
"_key",
".",
"udp_port",
"(",
")",
"<<",
"8",
";",
"b0",
"|=",
"flavor",
"<<",
"24",
";",
"// I/O flavor; one of the Value.persist backends",
"b0",
"|=",
"io_ms",
"<<",
"32",
";",
"// msec from start-to-finish, including non-i/o overheads",
"record2",
"(",
"H2O",
".",
"SELF",
",",
"block_ns",
",",
"true",
",",
"r_w",
",",
"0",
",",
"b0",
",",
"size",
")",
";",
"}"
] |
/* Record an I/O call without using an AutoBuffer / NIO.
Used by e.g. HDFS & S3
@param block_ns - ns of blocking i/o call,
@param io_msg - ms of overall i/o time
@param r_w - 1 for read, 0 for write
@param size - bytes read/written
@param flavor - Value.HDFS or Value.S3
|
[
"/",
"*",
"Record",
"an",
"I",
"/",
"O",
"call",
"without",
"using",
"an",
"AutoBuffer",
"/",
"NIO",
".",
"Used",
"by",
"e",
".",
"g",
".",
"HDFS",
"&",
"S3"
] |
train
|
https://github.com/h2oai/h2o-2/blob/be350f3f2c2fb6f135cc07c41f83fd0e4f521ac1/src/main/java/water/TimeLine.java#L125-L134
|
Azure/azure-sdk-for-java
|
resources/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/resources/v2016_09_01/implementation/DeploymentOperationsInner.java
|
DeploymentOperationsInner.getAsync
|
public Observable<DeploymentOperationInner> getAsync(String resourceGroupName, String deploymentName, String operationId) {
"""
Gets a deployments operation.
@param resourceGroupName The name of the resource group. The name is case insensitive.
@param deploymentName The name of the deployment.
@param operationId The ID of the operation to get.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DeploymentOperationInner object
"""
return getWithServiceResponseAsync(resourceGroupName, deploymentName, operationId).map(new Func1<ServiceResponse<DeploymentOperationInner>, DeploymentOperationInner>() {
@Override
public DeploymentOperationInner call(ServiceResponse<DeploymentOperationInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<DeploymentOperationInner> getAsync(String resourceGroupName, String deploymentName, String operationId) {
return getWithServiceResponseAsync(resourceGroupName, deploymentName, operationId).map(new Func1<ServiceResponse<DeploymentOperationInner>, DeploymentOperationInner>() {
@Override
public DeploymentOperationInner call(ServiceResponse<DeploymentOperationInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"DeploymentOperationInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"deploymentName",
",",
"String",
"operationId",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"deploymentName",
",",
"operationId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DeploymentOperationInner",
">",
",",
"DeploymentOperationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DeploymentOperationInner",
"call",
"(",
"ServiceResponse",
"<",
"DeploymentOperationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets a deployments operation.
@param resourceGroupName The name of the resource group. The name is case insensitive.
@param deploymentName The name of the deployment.
@param operationId The ID of the operation to get.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DeploymentOperationInner object
|
[
"Gets",
"a",
"deployments",
"operation",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/resources/v2016_09_01/implementation/DeploymentOperationsInner.java#L112-L119
|
jakenjarvis/Android-OrmLiteContentProvider
|
ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/MatcherController.java
|
MatcherController.setDefaultContentUri
|
public MatcherController setDefaultContentUri(String authority, String path) {
"""
Set the DefaultContentUri. If you did not use the DefaultContentUri annotation, you must call
this method.
@see com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri
@param authority
@param path
@return Instance of the MatcherController class.
"""
if (this.lastAddTableInfo == null) {
throw new IllegalStateException("There is a problem with the order of function call.");
}
this.lastAddTableInfo.setDefaultContentUriInfo(new ContentUriInfo(authority, path));
return this;
}
|
java
|
public MatcherController setDefaultContentUri(String authority, String path) {
if (this.lastAddTableInfo == null) {
throw new IllegalStateException("There is a problem with the order of function call.");
}
this.lastAddTableInfo.setDefaultContentUriInfo(new ContentUriInfo(authority, path));
return this;
}
|
[
"public",
"MatcherController",
"setDefaultContentUri",
"(",
"String",
"authority",
",",
"String",
"path",
")",
"{",
"if",
"(",
"this",
".",
"lastAddTableInfo",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"There is a problem with the order of function call.\"",
")",
";",
"}",
"this",
".",
"lastAddTableInfo",
".",
"setDefaultContentUriInfo",
"(",
"new",
"ContentUriInfo",
"(",
"authority",
",",
"path",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Set the DefaultContentUri. If you did not use the DefaultContentUri annotation, you must call
this method.
@see com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri
@param authority
@param path
@return Instance of the MatcherController class.
|
[
"Set",
"the",
"DefaultContentUri",
".",
"If",
"you",
"did",
"not",
"use",
"the",
"DefaultContentUri",
"annotation",
"you",
"must",
"call",
"this",
"method",
"."
] |
train
|
https://github.com/jakenjarvis/Android-OrmLiteContentProvider/blob/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/MatcherController.java#L144-L150
|
aNNiMON/Lightweight-Stream-API
|
stream/src/main/java/com/annimon/stream/RandomCompat.java
|
RandomCompat.ints
|
@NotNull
public IntStream ints(long streamSize, final int randomNumberOrigin, final int randomNumberBound) {
"""
Returns a stream producing the given {@code streamSize} number
of pseudorandom {@code int} values, each conforming to the given
origin (inclusive) and bound (exclusive).
@param streamSize the number of values to generate
@param randomNumberOrigin the origin (inclusive) of each random value
@param randomNumberBound the bound (exclusive) if each random value
@return a stream of pseudorandom {@code int} values,
each with the given origin (inclusive) and bound (exclusive)
@throws IllegalArgumentException if {@code streamSize} is
less than zero, or {@code randomNumberOrigin} is
greater than or equal to {@code randomNumberBound}
"""
if (streamSize < 0L) throw new IllegalArgumentException();
if (streamSize == 0L) {
return IntStream.empty();
}
return ints(randomNumberOrigin, randomNumberBound).limit(streamSize);
}
|
java
|
@NotNull
public IntStream ints(long streamSize, final int randomNumberOrigin, final int randomNumberBound) {
if (streamSize < 0L) throw new IllegalArgumentException();
if (streamSize == 0L) {
return IntStream.empty();
}
return ints(randomNumberOrigin, randomNumberBound).limit(streamSize);
}
|
[
"@",
"NotNull",
"public",
"IntStream",
"ints",
"(",
"long",
"streamSize",
",",
"final",
"int",
"randomNumberOrigin",
",",
"final",
"int",
"randomNumberBound",
")",
"{",
"if",
"(",
"streamSize",
"<",
"0L",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"if",
"(",
"streamSize",
"==",
"0L",
")",
"{",
"return",
"IntStream",
".",
"empty",
"(",
")",
";",
"}",
"return",
"ints",
"(",
"randomNumberOrigin",
",",
"randomNumberBound",
")",
".",
"limit",
"(",
"streamSize",
")",
";",
"}"
] |
Returns a stream producing the given {@code streamSize} number
of pseudorandom {@code int} values, each conforming to the given
origin (inclusive) and bound (exclusive).
@param streamSize the number of values to generate
@param randomNumberOrigin the origin (inclusive) of each random value
@param randomNumberBound the bound (exclusive) if each random value
@return a stream of pseudorandom {@code int} values,
each with the given origin (inclusive) and bound (exclusive)
@throws IllegalArgumentException if {@code streamSize} is
less than zero, or {@code randomNumberOrigin} is
greater than or equal to {@code randomNumberBound}
|
[
"Returns",
"a",
"stream",
"producing",
"the",
"given",
"{",
"@code",
"streamSize",
"}",
"number",
"of",
"pseudorandom",
"{",
"@code",
"int",
"}",
"values",
"each",
"conforming",
"to",
"the",
"given",
"origin",
"(",
"inclusive",
")",
"and",
"bound",
"(",
"exclusive",
")",
"."
] |
train
|
https://github.com/aNNiMON/Lightweight-Stream-API/blob/f29fd57208c20252a4549b084d55ed082c3e58f0/stream/src/main/java/com/annimon/stream/RandomCompat.java#L190-L197
|
groovy/groovy-core
|
subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
|
Sql.eachRow
|
public void eachRow(String sql, Map map, Closure metaClosure, int offset, int maxRows, Closure rowClosure) throws SQLException {
"""
A variant of {@link #eachRow(String, java.util.List, groovy.lang.Closure, int, int, groovy.lang.Closure)}
allowing the named parameters to be supplied in a map.
@param sql the sql statement
@param map a map containing the named parameters
@param offset the 1-based offset for the first row to be processed
@param maxRows the maximum number of rows to be processed
@param metaClosure called for meta data (only once after sql execution)
@param rowClosure called for each row with a GroovyResultSet
@throws SQLException if a database access error occurs
@since 1.8.7
"""
eachRow(sql, singletonList(map), metaClosure, offset, maxRows, rowClosure);
}
|
java
|
public void eachRow(String sql, Map map, Closure metaClosure, int offset, int maxRows, Closure rowClosure) throws SQLException {
eachRow(sql, singletonList(map), metaClosure, offset, maxRows, rowClosure);
}
|
[
"public",
"void",
"eachRow",
"(",
"String",
"sql",
",",
"Map",
"map",
",",
"Closure",
"metaClosure",
",",
"int",
"offset",
",",
"int",
"maxRows",
",",
"Closure",
"rowClosure",
")",
"throws",
"SQLException",
"{",
"eachRow",
"(",
"sql",
",",
"singletonList",
"(",
"map",
")",
",",
"metaClosure",
",",
"offset",
",",
"maxRows",
",",
"rowClosure",
")",
";",
"}"
] |
A variant of {@link #eachRow(String, java.util.List, groovy.lang.Closure, int, int, groovy.lang.Closure)}
allowing the named parameters to be supplied in a map.
@param sql the sql statement
@param map a map containing the named parameters
@param offset the 1-based offset for the first row to be processed
@param maxRows the maximum number of rows to be processed
@param metaClosure called for meta data (only once after sql execution)
@param rowClosure called for each row with a GroovyResultSet
@throws SQLException if a database access error occurs
@since 1.8.7
|
[
"A",
"variant",
"of",
"{",
"@link",
"#eachRow",
"(",
"String",
"java",
".",
"util",
".",
"List",
"groovy",
".",
"lang",
".",
"Closure",
"int",
"int",
"groovy",
".",
"lang",
".",
"Closure",
")",
"}",
"allowing",
"the",
"named",
"parameters",
"to",
"be",
"supplied",
"in",
"a",
"map",
"."
] |
train
|
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java#L1281-L1283
|
MariaDB/mariadb-connector-j
|
src/main/java/org/mariadb/jdbc/BasePrepareStatement.java
|
BasePrepareStatement.setDate
|
public void setDate(final int parameterIndex, final Date date, final Calendar cal)
throws SQLException {
"""
Sets the designated parameter to the given <code>java.sql.Date</code> value, using the given
<code>Calendar</code> object. The driver uses the <code>Calendar</code> object to construct
an SQL
<code>DATE</code> value, which the driver then sends to the database. With a
<code>Calendar</code> object, the
driver can calculate the date taking into account a custom timezone. If no
<code>Calendar</code> object is specified, the driver uses the default timezone, which is that
of the virtual machine running the application.
@param parameterIndex the first parameter is 1, the second is 2, ...
@param date the parameter value
@param cal the <code>Calendar</code> object the driver will use to construct the
date
@throws SQLException if parameterIndex does not correspond to a parameter marker in the SQL
statement; if a database access error occurs or this method is called on a
closed
<code>PreparedStatement</code>
"""
if (date == null) {
setNull(parameterIndex, Types.DATE);
return;
}
setParameter(parameterIndex,
new DateParameter(date, cal != null ? cal.getTimeZone() : TimeZone.getDefault(),
protocol.getOptions()));
}
|
java
|
public void setDate(final int parameterIndex, final Date date, final Calendar cal)
throws SQLException {
if (date == null) {
setNull(parameterIndex, Types.DATE);
return;
}
setParameter(parameterIndex,
new DateParameter(date, cal != null ? cal.getTimeZone() : TimeZone.getDefault(),
protocol.getOptions()));
}
|
[
"public",
"void",
"setDate",
"(",
"final",
"int",
"parameterIndex",
",",
"final",
"Date",
"date",
",",
"final",
"Calendar",
"cal",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"date",
"==",
"null",
")",
"{",
"setNull",
"(",
"parameterIndex",
",",
"Types",
".",
"DATE",
")",
";",
"return",
";",
"}",
"setParameter",
"(",
"parameterIndex",
",",
"new",
"DateParameter",
"(",
"date",
",",
"cal",
"!=",
"null",
"?",
"cal",
".",
"getTimeZone",
"(",
")",
":",
"TimeZone",
".",
"getDefault",
"(",
")",
",",
"protocol",
".",
"getOptions",
"(",
")",
")",
")",
";",
"}"
] |
Sets the designated parameter to the given <code>java.sql.Date</code> value, using the given
<code>Calendar</code> object. The driver uses the <code>Calendar</code> object to construct
an SQL
<code>DATE</code> value, which the driver then sends to the database. With a
<code>Calendar</code> object, the
driver can calculate the date taking into account a custom timezone. If no
<code>Calendar</code> object is specified, the driver uses the default timezone, which is that
of the virtual machine running the application.
@param parameterIndex the first parameter is 1, the second is 2, ...
@param date the parameter value
@param cal the <code>Calendar</code> object the driver will use to construct the
date
@throws SQLException if parameterIndex does not correspond to a parameter marker in the SQL
statement; if a database access error occurs or this method is called on a
closed
<code>PreparedStatement</code>
|
[
"Sets",
"the",
"designated",
"parameter",
"to",
"the",
"given",
"<code",
">",
"java",
".",
"sql",
".",
"Date<",
"/",
"code",
">",
"value",
"using",
"the",
"given",
"<code",
">",
"Calendar<",
"/",
"code",
">",
"object",
".",
"The",
"driver",
"uses",
"the",
"<code",
">",
"Calendar<",
"/",
"code",
">",
"object",
"to",
"construct",
"an",
"SQL",
"<code",
">",
"DATE<",
"/",
"code",
">",
"value",
"which",
"the",
"driver",
"then",
"sends",
"to",
"the",
"database",
".",
"With",
"a",
"<code",
">",
"Calendar<",
"/",
"code",
">",
"object",
"the",
"driver",
"can",
"calculate",
"the",
"date",
"taking",
"into",
"account",
"a",
"custom",
"timezone",
".",
"If",
"no",
"<code",
">",
"Calendar<",
"/",
"code",
">",
"object",
"is",
"specified",
"the",
"driver",
"uses",
"the",
"default",
"timezone",
"which",
"is",
"that",
"of",
"the",
"virtual",
"machine",
"running",
"the",
"application",
"."
] |
train
|
https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/BasePrepareStatement.java#L490-L499
|
alkacon/opencms-core
|
src/org/opencms/workplace/editors/CmsXmlContentEditor.java
|
CmsXmlContentEditor.buildSubChoices
|
public String buildSubChoices() {
"""
Returns the available sub choices for a nested choice element.<p>
@return the available sub choices for a nested choice element as JSON array string
"""
String elementPath = getParamElementName();
// we have to add a choice element, first check if the element to add itself is part of a choice or not
boolean choiceType = Boolean.valueOf(getParamChoiceType()).booleanValue();
I_CmsXmlSchemaType elemType = m_content.getContentDefinition().getSchemaType(elementPath);
if (!choiceType || (elemType.isChoiceOption() && elemType.isChoiceType())) {
// this is a choice option or a nested choice type to add, remove last element name from xpath
elementPath = CmsXmlUtils.removeLastXpathElement(elementPath);
}
elementPath = CmsXmlUtils.concatXpath(elementPath, getParamChoiceElement());
return buildElementChoices(elementPath, choiceType, false).toString();
}
|
java
|
public String buildSubChoices() {
String elementPath = getParamElementName();
// we have to add a choice element, first check if the element to add itself is part of a choice or not
boolean choiceType = Boolean.valueOf(getParamChoiceType()).booleanValue();
I_CmsXmlSchemaType elemType = m_content.getContentDefinition().getSchemaType(elementPath);
if (!choiceType || (elemType.isChoiceOption() && elemType.isChoiceType())) {
// this is a choice option or a nested choice type to add, remove last element name from xpath
elementPath = CmsXmlUtils.removeLastXpathElement(elementPath);
}
elementPath = CmsXmlUtils.concatXpath(elementPath, getParamChoiceElement());
return buildElementChoices(elementPath, choiceType, false).toString();
}
|
[
"public",
"String",
"buildSubChoices",
"(",
")",
"{",
"String",
"elementPath",
"=",
"getParamElementName",
"(",
")",
";",
"// we have to add a choice element, first check if the element to add itself is part of a choice or not",
"boolean",
"choiceType",
"=",
"Boolean",
".",
"valueOf",
"(",
"getParamChoiceType",
"(",
")",
")",
".",
"booleanValue",
"(",
")",
";",
"I_CmsXmlSchemaType",
"elemType",
"=",
"m_content",
".",
"getContentDefinition",
"(",
")",
".",
"getSchemaType",
"(",
"elementPath",
")",
";",
"if",
"(",
"!",
"choiceType",
"||",
"(",
"elemType",
".",
"isChoiceOption",
"(",
")",
"&&",
"elemType",
".",
"isChoiceType",
"(",
")",
")",
")",
"{",
"// this is a choice option or a nested choice type to add, remove last element name from xpath",
"elementPath",
"=",
"CmsXmlUtils",
".",
"removeLastXpathElement",
"(",
"elementPath",
")",
";",
"}",
"elementPath",
"=",
"CmsXmlUtils",
".",
"concatXpath",
"(",
"elementPath",
",",
"getParamChoiceElement",
"(",
")",
")",
";",
"return",
"buildElementChoices",
"(",
"elementPath",
",",
"choiceType",
",",
"false",
")",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns the available sub choices for a nested choice element.<p>
@return the available sub choices for a nested choice element as JSON array string
|
[
"Returns",
"the",
"available",
"sub",
"choices",
"for",
"a",
"nested",
"choice",
"element",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/editors/CmsXmlContentEditor.java#L791-L804
|
Azure/azure-sdk-for-java
|
appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java
|
AppServiceEnvironmentsInner.getWorkerPoolAsync
|
public Observable<WorkerPoolResourceInner> getWorkerPoolAsync(String resourceGroupName, String name, String workerPoolName) {
"""
Get properties of a worker pool.
Get properties of a worker pool.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param workerPoolName Name of the worker pool.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the WorkerPoolResourceInner object
"""
return getWorkerPoolWithServiceResponseAsync(resourceGroupName, name, workerPoolName).map(new Func1<ServiceResponse<WorkerPoolResourceInner>, WorkerPoolResourceInner>() {
@Override
public WorkerPoolResourceInner call(ServiceResponse<WorkerPoolResourceInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<WorkerPoolResourceInner> getWorkerPoolAsync(String resourceGroupName, String name, String workerPoolName) {
return getWorkerPoolWithServiceResponseAsync(resourceGroupName, name, workerPoolName).map(new Func1<ServiceResponse<WorkerPoolResourceInner>, WorkerPoolResourceInner>() {
@Override
public WorkerPoolResourceInner call(ServiceResponse<WorkerPoolResourceInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"WorkerPoolResourceInner",
">",
"getWorkerPoolAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
",",
"String",
"workerPoolName",
")",
"{",
"return",
"getWorkerPoolWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
",",
"workerPoolName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"WorkerPoolResourceInner",
">",
",",
"WorkerPoolResourceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"WorkerPoolResourceInner",
"call",
"(",
"ServiceResponse",
"<",
"WorkerPoolResourceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Get properties of a worker pool.
Get properties of a worker pool.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@param workerPoolName Name of the worker pool.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the WorkerPoolResourceInner object
|
[
"Get",
"properties",
"of",
"a",
"worker",
"pool",
".",
"Get",
"properties",
"of",
"a",
"worker",
"pool",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L5121-L5128
|
fcrepo3/fcrepo
|
fcrepo-common/src/main/java/org/fcrepo/utilities/xml/XercesXmlSerializers.java
|
XercesXmlSerializers.writeXmlToUTF8
|
public static void writeXmlToUTF8(Element ele, Writer out)
throws IOException {
"""
method: "XML"
charset: "UTF-8"
indenting: FALSE
indent-width: 0
line-width: 0
preserve-space: FALSE
omit-XML-declaration: FALSE
omit-DOCTYPE: FALSE
@param ele
@param out
@throws IOException
"""
XMLSerializer serializer =
new XMLSerializer(out, XML_TO_UTF8);
serializer.serialize(ele);
}
|
java
|
public static void writeXmlToUTF8(Element ele, Writer out)
throws IOException {
XMLSerializer serializer =
new XMLSerializer(out, XML_TO_UTF8);
serializer.serialize(ele);
}
|
[
"public",
"static",
"void",
"writeXmlToUTF8",
"(",
"Element",
"ele",
",",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"XMLSerializer",
"serializer",
"=",
"new",
"XMLSerializer",
"(",
"out",
",",
"XML_TO_UTF8",
")",
";",
"serializer",
".",
"serialize",
"(",
"ele",
")",
";",
"}"
] |
method: "XML"
charset: "UTF-8"
indenting: FALSE
indent-width: 0
line-width: 0
preserve-space: FALSE
omit-XML-declaration: FALSE
omit-DOCTYPE: FALSE
@param ele
@param out
@throws IOException
|
[
"method",
":",
"XML",
"charset",
":",
"UTF",
"-",
"8",
"indenting",
":",
"FALSE",
"indent",
"-",
"width",
":",
"0",
"line",
"-",
"width",
":",
"0",
"preserve",
"-",
"space",
":",
"FALSE",
"omit",
"-",
"XML",
"-",
"declaration",
":",
"FALSE",
"omit",
"-",
"DOCTYPE",
":",
"FALSE"
] |
train
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/utilities/xml/XercesXmlSerializers.java#L78-L83
|
devcon5io/common
|
passwords/src/main/java/io/devcon5/password/Passwords.java
|
Passwords.validatePassword
|
public static boolean validatePassword(String password, String goodHash) throws NoSuchAlgorithmException, InvalidKeySpecException {
"""
Validates a password using a hash.
@param password
the password to check
@param goodHash
the hash of the valid password
@return true if the password is correct, false if not
"""
return validatePassword(password.toCharArray(), goodHash);
}
|
java
|
public static boolean validatePassword(String password, String goodHash) throws NoSuchAlgorithmException, InvalidKeySpecException {
return validatePassword(password.toCharArray(), goodHash);
}
|
[
"public",
"static",
"boolean",
"validatePassword",
"(",
"String",
"password",
",",
"String",
"goodHash",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeySpecException",
"{",
"return",
"validatePassword",
"(",
"password",
".",
"toCharArray",
"(",
")",
",",
"goodHash",
")",
";",
"}"
] |
Validates a password using a hash.
@param password
the password to check
@param goodHash
the hash of the valid password
@return true if the password is correct, false if not
|
[
"Validates",
"a",
"password",
"using",
"a",
"hash",
"."
] |
train
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/passwords/src/main/java/io/devcon5/password/Passwords.java#L92-L95
|
gallandarakhneorg/afc
|
core/maths/mathgeom/tobeincluded/src/d3/continuous/Path3f.java
|
Path3f.lineTo
|
public void lineTo(double x, double y, double z) {
"""
Adds a point to the path by drawing a straight line from the
current coordinates to the new specified coordinates
specified in double precision.
@param x the specified X coordinate
@param y the specified Y coordinate
@param z the specified Z coordinate
"""
ensureSlots(true, 3);
this.types[this.numTypes++] = PathElementType.LINE_TO;
this.coords[this.numCoords++] = x;
this.coords[this.numCoords++] = y;
this.coords[this.numCoords++] = z;
this.isEmpty = null;
this.graphicalBounds = null;
this.logicalBounds = null;
}
|
java
|
public void lineTo(double x, double y, double z) {
ensureSlots(true, 3);
this.types[this.numTypes++] = PathElementType.LINE_TO;
this.coords[this.numCoords++] = x;
this.coords[this.numCoords++] = y;
this.coords[this.numCoords++] = z;
this.isEmpty = null;
this.graphicalBounds = null;
this.logicalBounds = null;
}
|
[
"public",
"void",
"lineTo",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
")",
"{",
"ensureSlots",
"(",
"true",
",",
"3",
")",
";",
"this",
".",
"types",
"[",
"this",
".",
"numTypes",
"++",
"]",
"=",
"PathElementType",
".",
"LINE_TO",
";",
"this",
".",
"coords",
"[",
"this",
".",
"numCoords",
"++",
"]",
"=",
"x",
";",
"this",
".",
"coords",
"[",
"this",
".",
"numCoords",
"++",
"]",
"=",
"y",
";",
"this",
".",
"coords",
"[",
"this",
".",
"numCoords",
"++",
"]",
"=",
"z",
";",
"this",
".",
"isEmpty",
"=",
"null",
";",
"this",
".",
"graphicalBounds",
"=",
"null",
";",
"this",
".",
"logicalBounds",
"=",
"null",
";",
"}"
] |
Adds a point to the path by drawing a straight line from the
current coordinates to the new specified coordinates
specified in double precision.
@param x the specified X coordinate
@param y the specified Y coordinate
@param z the specified Z coordinate
|
[
"Adds",
"a",
"point",
"to",
"the",
"path",
"by",
"drawing",
"a",
"straight",
"line",
"from",
"the",
"current",
"coordinates",
"to",
"the",
"new",
"specified",
"coordinates",
"specified",
"in",
"double",
"precision",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/tobeincluded/src/d3/continuous/Path3f.java#L1873-L1882
|
datumbox/datumbox-framework
|
datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/distributions/ContinuousDistributions.java
|
ContinuousDistributions.exponentialCdf
|
public static double exponentialCdf(double x, double lamda) {
"""
Calculates the probability from 0 to X under Exponential Distribution
@param x
@param lamda
@return
"""
if(x<0 || lamda<=0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
double probability = 1.0 - Math.exp(-lamda*x);
return probability;
}
|
java
|
public static double exponentialCdf(double x, double lamda) {
if(x<0 || lamda<=0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
double probability = 1.0 - Math.exp(-lamda*x);
return probability;
}
|
[
"public",
"static",
"double",
"exponentialCdf",
"(",
"double",
"x",
",",
"double",
"lamda",
")",
"{",
"if",
"(",
"x",
"<",
"0",
"||",
"lamda",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"All the parameters must be positive.\"",
")",
";",
"}",
"double",
"probability",
"=",
"1.0",
"-",
"Math",
".",
"exp",
"(",
"-",
"lamda",
"*",
"x",
")",
";",
"return",
"probability",
";",
"}"
] |
Calculates the probability from 0 to X under Exponential Distribution
@param x
@param lamda
@return
|
[
"Calculates",
"the",
"probability",
"from",
"0",
"to",
"X",
"under",
"Exponential",
"Distribution"
] |
train
|
https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/distributions/ContinuousDistributions.java#L195-L203
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/Image.java
|
Image.getInstance
|
public static Image getInstance(PdfContentByte cb, java.awt.Image awtImage, float quality) throws BadElementException, IOException {
"""
Gets an instance of a Image from a java.awt.Image.
The image is added as a JPEG with a user defined quality.
@param cb
the <CODE>PdfContentByte</CODE> object to which the image will be added
@param awtImage
the <CODE>java.awt.Image</CODE> to convert
@param quality
a float value between 0 and 1
@return an object of type <CODE>PdfTemplate</CODE>
@throws BadElementException
on error
@throws IOException
"""
java.awt.image.PixelGrabber pg = new java.awt.image.PixelGrabber(awtImage,
0, 0, -1, -1, true);
try {
pg.grabPixels();
} catch (InterruptedException e) {
throw new IOException(
"java.awt.Image Interrupted waiting for pixels!");
}
if ((pg.getStatus() & java.awt.image.ImageObserver.ABORT) != 0) {
throw new IOException("java.awt.Image fetch aborted or errored");
}
int w = pg.getWidth();
int h = pg.getHeight();
PdfTemplate tp = cb.createTemplate(w, h);
Graphics2D g2d = tp.createGraphics(w, h, true, quality);
g2d.drawImage(awtImage, 0, 0, null);
g2d.dispose();
return getInstance(tp);
}
|
java
|
public static Image getInstance(PdfContentByte cb, java.awt.Image awtImage, float quality) throws BadElementException, IOException {
java.awt.image.PixelGrabber pg = new java.awt.image.PixelGrabber(awtImage,
0, 0, -1, -1, true);
try {
pg.grabPixels();
} catch (InterruptedException e) {
throw new IOException(
"java.awt.Image Interrupted waiting for pixels!");
}
if ((pg.getStatus() & java.awt.image.ImageObserver.ABORT) != 0) {
throw new IOException("java.awt.Image fetch aborted or errored");
}
int w = pg.getWidth();
int h = pg.getHeight();
PdfTemplate tp = cb.createTemplate(w, h);
Graphics2D g2d = tp.createGraphics(w, h, true, quality);
g2d.drawImage(awtImage, 0, 0, null);
g2d.dispose();
return getInstance(tp);
}
|
[
"public",
"static",
"Image",
"getInstance",
"(",
"PdfContentByte",
"cb",
",",
"java",
".",
"awt",
".",
"Image",
"awtImage",
",",
"float",
"quality",
")",
"throws",
"BadElementException",
",",
"IOException",
"{",
"java",
".",
"awt",
".",
"image",
".",
"PixelGrabber",
"pg",
"=",
"new",
"java",
".",
"awt",
".",
"image",
".",
"PixelGrabber",
"(",
"awtImage",
",",
"0",
",",
"0",
",",
"-",
"1",
",",
"-",
"1",
",",
"true",
")",
";",
"try",
"{",
"pg",
".",
"grabPixels",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"java.awt.Image Interrupted waiting for pixels!\"",
")",
";",
"}",
"if",
"(",
"(",
"pg",
".",
"getStatus",
"(",
")",
"&",
"java",
".",
"awt",
".",
"image",
".",
"ImageObserver",
".",
"ABORT",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"java.awt.Image fetch aborted or errored\"",
")",
";",
"}",
"int",
"w",
"=",
"pg",
".",
"getWidth",
"(",
")",
";",
"int",
"h",
"=",
"pg",
".",
"getHeight",
"(",
")",
";",
"PdfTemplate",
"tp",
"=",
"cb",
".",
"createTemplate",
"(",
"w",
",",
"h",
")",
";",
"Graphics2D",
"g2d",
"=",
"tp",
".",
"createGraphics",
"(",
"w",
",",
"h",
",",
"true",
",",
"quality",
")",
";",
"g2d",
".",
"drawImage",
"(",
"awtImage",
",",
"0",
",",
"0",
",",
"null",
")",
";",
"g2d",
".",
"dispose",
"(",
")",
";",
"return",
"getInstance",
"(",
"tp",
")",
";",
"}"
] |
Gets an instance of a Image from a java.awt.Image.
The image is added as a JPEG with a user defined quality.
@param cb
the <CODE>PdfContentByte</CODE> object to which the image will be added
@param awtImage
the <CODE>java.awt.Image</CODE> to convert
@param quality
a float value between 0 and 1
@return an object of type <CODE>PdfTemplate</CODE>
@throws BadElementException
on error
@throws IOException
|
[
"Gets",
"an",
"instance",
"of",
"a",
"Image",
"from",
"a",
"java",
".",
"awt",
".",
"Image",
".",
"The",
"image",
"is",
"added",
"as",
"a",
"JPEG",
"with",
"a",
"user",
"defined",
"quality",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Image.java#L830-L849
|
Harium/keel
|
src/main/java/com/harium/keel/catalano/core/DoublePoint.java
|
DoublePoint.Subtract
|
public DoublePoint Subtract(DoublePoint point1, DoublePoint point2) {
"""
Subtract values of two points.
@param point1 DoublePoint.
@param point2 DoublePoint.
@return A new DoublePoint with the subtraction operation.
"""
DoublePoint result = new DoublePoint(point1);
result.Subtract(point2);
return result;
}
|
java
|
public DoublePoint Subtract(DoublePoint point1, DoublePoint point2) {
DoublePoint result = new DoublePoint(point1);
result.Subtract(point2);
return result;
}
|
[
"public",
"DoublePoint",
"Subtract",
"(",
"DoublePoint",
"point1",
",",
"DoublePoint",
"point2",
")",
"{",
"DoublePoint",
"result",
"=",
"new",
"DoublePoint",
"(",
"point1",
")",
";",
"result",
".",
"Subtract",
"(",
"point2",
")",
";",
"return",
"result",
";",
"}"
] |
Subtract values of two points.
@param point1 DoublePoint.
@param point2 DoublePoint.
@return A new DoublePoint with the subtraction operation.
|
[
"Subtract",
"values",
"of",
"two",
"points",
"."
] |
train
|
https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/core/DoublePoint.java#L172-L176
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/block/meta/MasterWorkerInfo.java
|
MasterWorkerInfo.generateWorkerInfo
|
public WorkerInfo generateWorkerInfo(Set<WorkerInfoField> fieldRange, boolean isLiveWorker) {
"""
Gets the selected field information for this worker.
@param fieldRange the client selected fields
@param isLiveWorker the worker is live or not
@return generated worker information
"""
WorkerInfo info = new WorkerInfo();
Set<WorkerInfoField> checkedFieldRange = fieldRange != null ? fieldRange :
new HashSet<>(Arrays.asList(WorkerInfoField.values()));
for (WorkerInfoField field : checkedFieldRange) {
switch (field) {
case ADDRESS:
info.setAddress(mWorkerAddress);
break;
case WORKER_CAPACITY_BYTES:
info.setCapacityBytes(mCapacityBytes);
break;
case WORKER_CAPACITY_BYTES_ON_TIERS:
info.setCapacityBytesOnTiers(mTotalBytesOnTiers);
break;
case ID:
info.setId(mId);
break;
case LAST_CONTACT_SEC:
info.setLastContactSec(
(int) ((CommonUtils.getCurrentMs() - mLastUpdatedTimeMs) / Constants.SECOND_MS));
break;
case START_TIME_MS:
info.setStartTimeMs(mStartTimeMs);
break;
case STATE:
if (isLiveWorker) {
info.setState(LIVE_WORKER_STATE);
} else {
info.setState(LOST_WORKER_STATE);
}
break;
case WORKER_USED_BYTES:
info.setUsedBytes(mUsedBytes);
break;
case WORKER_USED_BYTES_ON_TIERS:
info.setUsedBytesOnTiers(mUsedBytesOnTiers);
break;
default:
LOG.warn("Unrecognized worker info field: " + field);
}
}
return info;
}
|
java
|
public WorkerInfo generateWorkerInfo(Set<WorkerInfoField> fieldRange, boolean isLiveWorker) {
WorkerInfo info = new WorkerInfo();
Set<WorkerInfoField> checkedFieldRange = fieldRange != null ? fieldRange :
new HashSet<>(Arrays.asList(WorkerInfoField.values()));
for (WorkerInfoField field : checkedFieldRange) {
switch (field) {
case ADDRESS:
info.setAddress(mWorkerAddress);
break;
case WORKER_CAPACITY_BYTES:
info.setCapacityBytes(mCapacityBytes);
break;
case WORKER_CAPACITY_BYTES_ON_TIERS:
info.setCapacityBytesOnTiers(mTotalBytesOnTiers);
break;
case ID:
info.setId(mId);
break;
case LAST_CONTACT_SEC:
info.setLastContactSec(
(int) ((CommonUtils.getCurrentMs() - mLastUpdatedTimeMs) / Constants.SECOND_MS));
break;
case START_TIME_MS:
info.setStartTimeMs(mStartTimeMs);
break;
case STATE:
if (isLiveWorker) {
info.setState(LIVE_WORKER_STATE);
} else {
info.setState(LOST_WORKER_STATE);
}
break;
case WORKER_USED_BYTES:
info.setUsedBytes(mUsedBytes);
break;
case WORKER_USED_BYTES_ON_TIERS:
info.setUsedBytesOnTiers(mUsedBytesOnTiers);
break;
default:
LOG.warn("Unrecognized worker info field: " + field);
}
}
return info;
}
|
[
"public",
"WorkerInfo",
"generateWorkerInfo",
"(",
"Set",
"<",
"WorkerInfoField",
">",
"fieldRange",
",",
"boolean",
"isLiveWorker",
")",
"{",
"WorkerInfo",
"info",
"=",
"new",
"WorkerInfo",
"(",
")",
";",
"Set",
"<",
"WorkerInfoField",
">",
"checkedFieldRange",
"=",
"fieldRange",
"!=",
"null",
"?",
"fieldRange",
":",
"new",
"HashSet",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"WorkerInfoField",
".",
"values",
"(",
")",
")",
")",
";",
"for",
"(",
"WorkerInfoField",
"field",
":",
"checkedFieldRange",
")",
"{",
"switch",
"(",
"field",
")",
"{",
"case",
"ADDRESS",
":",
"info",
".",
"setAddress",
"(",
"mWorkerAddress",
")",
";",
"break",
";",
"case",
"WORKER_CAPACITY_BYTES",
":",
"info",
".",
"setCapacityBytes",
"(",
"mCapacityBytes",
")",
";",
"break",
";",
"case",
"WORKER_CAPACITY_BYTES_ON_TIERS",
":",
"info",
".",
"setCapacityBytesOnTiers",
"(",
"mTotalBytesOnTiers",
")",
";",
"break",
";",
"case",
"ID",
":",
"info",
".",
"setId",
"(",
"mId",
")",
";",
"break",
";",
"case",
"LAST_CONTACT_SEC",
":",
"info",
".",
"setLastContactSec",
"(",
"(",
"int",
")",
"(",
"(",
"CommonUtils",
".",
"getCurrentMs",
"(",
")",
"-",
"mLastUpdatedTimeMs",
")",
"/",
"Constants",
".",
"SECOND_MS",
")",
")",
";",
"break",
";",
"case",
"START_TIME_MS",
":",
"info",
".",
"setStartTimeMs",
"(",
"mStartTimeMs",
")",
";",
"break",
";",
"case",
"STATE",
":",
"if",
"(",
"isLiveWorker",
")",
"{",
"info",
".",
"setState",
"(",
"LIVE_WORKER_STATE",
")",
";",
"}",
"else",
"{",
"info",
".",
"setState",
"(",
"LOST_WORKER_STATE",
")",
";",
"}",
"break",
";",
"case",
"WORKER_USED_BYTES",
":",
"info",
".",
"setUsedBytes",
"(",
"mUsedBytes",
")",
";",
"break",
";",
"case",
"WORKER_USED_BYTES_ON_TIERS",
":",
"info",
".",
"setUsedBytesOnTiers",
"(",
"mUsedBytesOnTiers",
")",
";",
"break",
";",
"default",
":",
"LOG",
".",
"warn",
"(",
"\"Unrecognized worker info field: \"",
"+",
"field",
")",
";",
"}",
"}",
"return",
"info",
";",
"}"
] |
Gets the selected field information for this worker.
@param fieldRange the client selected fields
@param isLiveWorker the worker is live or not
@return generated worker information
|
[
"Gets",
"the",
"selected",
"field",
"information",
"for",
"this",
"worker",
"."
] |
train
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/block/meta/MasterWorkerInfo.java#L214-L257
|
lessthanoptimal/ejml
|
main/ejml-core/src/org/ejml/ops/ConvertDMatrixStruct.java
|
ConvertDMatrixStruct.convert
|
public static void convert(DMatrix input , DMatrix output ) {
"""
Generic, but slow, conversion function.
@param input Input matrix.
@param output Output matrix.
"""
if( output instanceof ReshapeMatrix ) {
((ReshapeMatrix)output).reshape(input.getNumRows(),input.getNumCols());
} else {
if (input.getNumRows() != output.getNumRows())
throw new IllegalArgumentException("Number of rows do not match");
if (input.getNumCols() != output.getNumCols())
throw new IllegalArgumentException("Number of columns do not match");
}
for( int i = 0; i < input.getNumRows(); i++ ) {
for( int j = 0; j < input.getNumCols(); j++ ) {
output.unsafe_set(i,j,input.unsafe_get(i,j));
}
}
}
|
java
|
public static void convert(DMatrix input , DMatrix output ) {
if( output instanceof ReshapeMatrix ) {
((ReshapeMatrix)output).reshape(input.getNumRows(),input.getNumCols());
} else {
if (input.getNumRows() != output.getNumRows())
throw new IllegalArgumentException("Number of rows do not match");
if (input.getNumCols() != output.getNumCols())
throw new IllegalArgumentException("Number of columns do not match");
}
for( int i = 0; i < input.getNumRows(); i++ ) {
for( int j = 0; j < input.getNumCols(); j++ ) {
output.unsafe_set(i,j,input.unsafe_get(i,j));
}
}
}
|
[
"public",
"static",
"void",
"convert",
"(",
"DMatrix",
"input",
",",
"DMatrix",
"output",
")",
"{",
"if",
"(",
"output",
"instanceof",
"ReshapeMatrix",
")",
"{",
"(",
"(",
"ReshapeMatrix",
")",
"output",
")",
".",
"reshape",
"(",
"input",
".",
"getNumRows",
"(",
")",
",",
"input",
".",
"getNumCols",
"(",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"input",
".",
"getNumRows",
"(",
")",
"!=",
"output",
".",
"getNumRows",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Number of rows do not match\"",
")",
";",
"if",
"(",
"input",
".",
"getNumCols",
"(",
")",
"!=",
"output",
".",
"getNumCols",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Number of columns do not match\"",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"input",
".",
"getNumRows",
"(",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"input",
".",
"getNumCols",
"(",
")",
";",
"j",
"++",
")",
"{",
"output",
".",
"unsafe_set",
"(",
"i",
",",
"j",
",",
"input",
".",
"unsafe_get",
"(",
"i",
",",
"j",
")",
")",
";",
"}",
"}",
"}"
] |
Generic, but slow, conversion function.
@param input Input matrix.
@param output Output matrix.
|
[
"Generic",
"but",
"slow",
"conversion",
"function",
"."
] |
train
|
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/ops/ConvertDMatrixStruct.java#L39-L54
|
igniterealtime/Smack
|
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
|
OmemoService.sendRatchetUpdate
|
private void sendRatchetUpdate(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice contactsDevice)
throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException,
NoSuchAlgorithmException, SmackException.NotConnectedException, CryptoFailedException,
CannotEstablishOmemoSessionException {
"""
Send an empty OMEMO message to contactsDevice in order to forward the ratchet.
@param managerGuard
@param contactsDevice
@throws CorruptedOmemoKeyException if our or their OMEMO key is corrupted.
@throws InterruptedException
@throws SmackException.NoResponseException
@throws NoSuchAlgorithmException if AES encryption fails
@throws SmackException.NotConnectedException
@throws CryptoFailedException if encryption fails (should not happen though, but who knows...)
@throws CannotEstablishOmemoSessionException if we cannot establish a session with contactsDevice.
"""
OmemoManager manager = managerGuard.get();
OmemoElement ratchetUpdate = createRatchetUpdateElement(managerGuard, contactsDevice);
Message m = new Message();
m.setTo(contactsDevice.getJid());
m.addExtension(ratchetUpdate);
manager.getConnection().sendStanza(m);
}
|
java
|
private void sendRatchetUpdate(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice contactsDevice)
throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException,
NoSuchAlgorithmException, SmackException.NotConnectedException, CryptoFailedException,
CannotEstablishOmemoSessionException {
OmemoManager manager = managerGuard.get();
OmemoElement ratchetUpdate = createRatchetUpdateElement(managerGuard, contactsDevice);
Message m = new Message();
m.setTo(contactsDevice.getJid());
m.addExtension(ratchetUpdate);
manager.getConnection().sendStanza(m);
}
|
[
"private",
"void",
"sendRatchetUpdate",
"(",
"OmemoManager",
".",
"LoggedInOmemoManager",
"managerGuard",
",",
"OmemoDevice",
"contactsDevice",
")",
"throws",
"CorruptedOmemoKeyException",
",",
"InterruptedException",
",",
"SmackException",
".",
"NoResponseException",
",",
"NoSuchAlgorithmException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"CryptoFailedException",
",",
"CannotEstablishOmemoSessionException",
"{",
"OmemoManager",
"manager",
"=",
"managerGuard",
".",
"get",
"(",
")",
";",
"OmemoElement",
"ratchetUpdate",
"=",
"createRatchetUpdateElement",
"(",
"managerGuard",
",",
"contactsDevice",
")",
";",
"Message",
"m",
"=",
"new",
"Message",
"(",
")",
";",
"m",
".",
"setTo",
"(",
"contactsDevice",
".",
"getJid",
"(",
")",
")",
";",
"m",
".",
"addExtension",
"(",
"ratchetUpdate",
")",
";",
"manager",
".",
"getConnection",
"(",
")",
".",
"sendStanza",
"(",
"m",
")",
";",
"}"
] |
Send an empty OMEMO message to contactsDevice in order to forward the ratchet.
@param managerGuard
@param contactsDevice
@throws CorruptedOmemoKeyException if our or their OMEMO key is corrupted.
@throws InterruptedException
@throws SmackException.NoResponseException
@throws NoSuchAlgorithmException if AES encryption fails
@throws SmackException.NotConnectedException
@throws CryptoFailedException if encryption fails (should not happen though, but who knows...)
@throws CannotEstablishOmemoSessionException if we cannot establish a session with contactsDevice.
|
[
"Send",
"an",
"empty",
"OMEMO",
"message",
"to",
"contactsDevice",
"in",
"order",
"to",
"forward",
"the",
"ratchet",
"."
] |
train
|
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L1317-L1328
|
basho/riak-java-client
|
src/main/java/com/basho/riak/client/core/query/functions/Function.java
|
Function.newStoredJsFunction
|
public static Function newStoredJsFunction(String bucket, String key) {
"""
Static factory method for Stored Javascript Functions.
@param bucket The bucket where the JS function is stored
@param key the key for the object containing the JS function
@return a Function representing a stored JS function.
"""
return new Builder().withBucket(bucket).withKey(key).build();
}
|
java
|
public static Function newStoredJsFunction(String bucket, String key)
{
return new Builder().withBucket(bucket).withKey(key).build();
}
|
[
"public",
"static",
"Function",
"newStoredJsFunction",
"(",
"String",
"bucket",
",",
"String",
"key",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
".",
"withBucket",
"(",
"bucket",
")",
".",
"withKey",
"(",
"key",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Static factory method for Stored Javascript Functions.
@param bucket The bucket where the JS function is stored
@param key the key for the object containing the JS function
@return a Function representing a stored JS function.
|
[
"Static",
"factory",
"method",
"for",
"Stored",
"Javascript",
"Functions",
"."
] |
train
|
https://github.com/basho/riak-java-client/blob/bed6cd60f360bacf1b873ab92dd74f2526651e71/src/main/java/com/basho/riak/client/core/query/functions/Function.java#L167-L170
|
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/GenericsUtils.java
|
GenericsUtils.trackGenerics
|
public static Type trackGenerics(final Type type, final Type source) {
"""
Shortcut for {@link GenericsTrackingUtils} to simplify tracking generics from known middle class.
For example, knowing {@code List<String>} we can track generic for {@code ArrayList<T>}.
<p>
In order to start generics resolution known type must be:
<ul>
<li>{@link ParameterizedType} - then parametrization used for tracking</li>
<li>{@link WildcardType} containing {@link ParameterizedType} - then all such types will be tracked
and the most specific generics selected</li>
<li>{@link GenericArrayType} - then component types are compared according to first two rules.</li>
</ul>
In all other cases, type is simply returned as is (no source to track from).
<p>
Target type may be any type (for usage simplicity), but only class declaration will be taken from it
(in order to build {@link ParameterizedType} with tracked generics). If target type
is already {@link ParameterizedType} and contain some generics - they will be used too in order to not
lower declaration specificity. If target class does not have declared generics at all - type is returned back
as is.
@param type class to resolve generics for
@param source sub type with known generics
@return {@link ParameterizedType} with tracked generics or original type if no declared generics or known
type is not {@link ParameterizedType}
@throws IllegalArgumentException if type is not assignable to known type.
@see GenericsTrackingUtils#track(Class, Class, LinkedHashMap) for more specific cases
"""
return TrackedTypeFactory.build(type, source);
}
|
java
|
public static Type trackGenerics(final Type type, final Type source) {
return TrackedTypeFactory.build(type, source);
}
|
[
"public",
"static",
"Type",
"trackGenerics",
"(",
"final",
"Type",
"type",
",",
"final",
"Type",
"source",
")",
"{",
"return",
"TrackedTypeFactory",
".",
"build",
"(",
"type",
",",
"source",
")",
";",
"}"
] |
Shortcut for {@link GenericsTrackingUtils} to simplify tracking generics from known middle class.
For example, knowing {@code List<String>} we can track generic for {@code ArrayList<T>}.
<p>
In order to start generics resolution known type must be:
<ul>
<li>{@link ParameterizedType} - then parametrization used for tracking</li>
<li>{@link WildcardType} containing {@link ParameterizedType} - then all such types will be tracked
and the most specific generics selected</li>
<li>{@link GenericArrayType} - then component types are compared according to first two rules.</li>
</ul>
In all other cases, type is simply returned as is (no source to track from).
<p>
Target type may be any type (for usage simplicity), but only class declaration will be taken from it
(in order to build {@link ParameterizedType} with tracked generics). If target type
is already {@link ParameterizedType} and contain some generics - they will be used too in order to not
lower declaration specificity. If target class does not have declared generics at all - type is returned back
as is.
@param type class to resolve generics for
@param source sub type with known generics
@return {@link ParameterizedType} with tracked generics or original type if no declared generics or known
type is not {@link ParameterizedType}
@throws IllegalArgumentException if type is not assignable to known type.
@see GenericsTrackingUtils#track(Class, Class, LinkedHashMap) for more specific cases
|
[
"Shortcut",
"for",
"{",
"@link",
"GenericsTrackingUtils",
"}",
"to",
"simplify",
"tracking",
"generics",
"from",
"known",
"middle",
"class",
".",
"For",
"example",
"knowing",
"{",
"@code",
"List<String",
">",
"}",
"we",
"can",
"track",
"generic",
"for",
"{",
"@code",
"ArrayList<T",
">",
"}",
".",
"<p",
">",
"In",
"order",
"to",
"start",
"generics",
"resolution",
"known",
"type",
"must",
"be",
":",
"<ul",
">",
"<li",
">",
"{",
"@link",
"ParameterizedType",
"}",
"-",
"then",
"parametrization",
"used",
"for",
"tracking<",
"/",
"li",
">",
"<li",
">",
"{",
"@link",
"WildcardType",
"}",
"containing",
"{",
"@link",
"ParameterizedType",
"}",
"-",
"then",
"all",
"such",
"types",
"will",
"be",
"tracked",
"and",
"the",
"most",
"specific",
"generics",
"selected<",
"/",
"li",
">",
"<li",
">",
"{",
"@link",
"GenericArrayType",
"}",
"-",
"then",
"component",
"types",
"are",
"compared",
"according",
"to",
"first",
"two",
"rules",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"In",
"all",
"other",
"cases",
"type",
"is",
"simply",
"returned",
"as",
"is",
"(",
"no",
"source",
"to",
"track",
"from",
")",
".",
"<p",
">",
"Target",
"type",
"may",
"be",
"any",
"type",
"(",
"for",
"usage",
"simplicity",
")",
"but",
"only",
"class",
"declaration",
"will",
"be",
"taken",
"from",
"it",
"(",
"in",
"order",
"to",
"build",
"{",
"@link",
"ParameterizedType",
"}",
"with",
"tracked",
"generics",
")",
".",
"If",
"target",
"type",
"is",
"already",
"{",
"@link",
"ParameterizedType",
"}",
"and",
"contain",
"some",
"generics",
"-",
"they",
"will",
"be",
"used",
"too",
"in",
"order",
"to",
"not",
"lower",
"declaration",
"specificity",
".",
"If",
"target",
"class",
"does",
"not",
"have",
"declared",
"generics",
"at",
"all",
"-",
"type",
"is",
"returned",
"back",
"as",
"is",
"."
] |
train
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/GenericsUtils.java#L55-L57
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/util/ClassUtil.java
|
ClassUtil.getDeclaredField
|
public static Field getDeclaredField(Class<?> clazz, String fieldName) throws SecurityException {
"""
查找指定类中的所有字段(包括非public字段), 字段不存在则返回<code>null</code>
@param clazz 被查找字段的类
@param fieldName 字段名
@return 字段
@throws SecurityException 安全异常
"""
if (null == clazz || StrUtil.isBlank(fieldName)) {
return null;
}
try {
return clazz.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
// e.printStackTrace();
}
return null;
}
|
java
|
public static Field getDeclaredField(Class<?> clazz, String fieldName) throws SecurityException {
if (null == clazz || StrUtil.isBlank(fieldName)) {
return null;
}
try {
return clazz.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
// e.printStackTrace();
}
return null;
}
|
[
"public",
"static",
"Field",
"getDeclaredField",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"fieldName",
")",
"throws",
"SecurityException",
"{",
"if",
"(",
"null",
"==",
"clazz",
"||",
"StrUtil",
".",
"isBlank",
"(",
"fieldName",
")",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"return",
"clazz",
".",
"getDeclaredField",
"(",
"fieldName",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"// e.printStackTrace();\r",
"}",
"return",
"null",
";",
"}"
] |
查找指定类中的所有字段(包括非public字段), 字段不存在则返回<code>null</code>
@param clazz 被查找字段的类
@param fieldName 字段名
@return 字段
@throws SecurityException 安全异常
|
[
"查找指定类中的所有字段(包括非public字段),",
"字段不存在则返回<code",
">",
"null<",
"/",
"code",
">"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ClassUtil.java#L354-L364
|
openengsb/openengsb
|
components/weaver/service/src/main/java/org/openengsb/core/weaver/service/internal/model/ManipulationUtils.java
|
ManipulationUtils.enhanceModel
|
public static byte[] enhanceModel(byte[] byteCode, ClassLoader... loaders) throws IOException,
CannotCompileException {
"""
Try to enhance the object defined by the given byte code. Returns the enhanced class or null, if the given class
is no model, as byte array. The version of the model will be set statical to 1.0.0. There may be class loaders
appended, if needed.
"""
return enhanceModel(byteCode, new Version("1.0.0"), loaders);
}
|
java
|
public static byte[] enhanceModel(byte[] byteCode, ClassLoader... loaders) throws IOException,
CannotCompileException {
return enhanceModel(byteCode, new Version("1.0.0"), loaders);
}
|
[
"public",
"static",
"byte",
"[",
"]",
"enhanceModel",
"(",
"byte",
"[",
"]",
"byteCode",
",",
"ClassLoader",
"...",
"loaders",
")",
"throws",
"IOException",
",",
"CannotCompileException",
"{",
"return",
"enhanceModel",
"(",
"byteCode",
",",
"new",
"Version",
"(",
"\"1.0.0\"",
")",
",",
"loaders",
")",
";",
"}"
] |
Try to enhance the object defined by the given byte code. Returns the enhanced class or null, if the given class
is no model, as byte array. The version of the model will be set statical to 1.0.0. There may be class loaders
appended, if needed.
|
[
"Try",
"to",
"enhance",
"the",
"object",
"defined",
"by",
"the",
"given",
"byte",
"code",
".",
"Returns",
"the",
"enhanced",
"class",
"or",
"null",
"if",
"the",
"given",
"class",
"is",
"no",
"model",
"as",
"byte",
"array",
".",
"The",
"version",
"of",
"the",
"model",
"will",
"be",
"set",
"statical",
"to",
"1",
".",
"0",
".",
"0",
".",
"There",
"may",
"be",
"class",
"loaders",
"appended",
"if",
"needed",
"."
] |
train
|
https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/weaver/service/src/main/java/org/openengsb/core/weaver/service/internal/model/ManipulationUtils.java#L82-L85
|
JodaOrg/joda-convert
|
src/main/java/org/joda/convert/StringConvert.java
|
StringConvert.loadType
|
static Class<?> loadType(String fullName) throws ClassNotFoundException {
"""
loads a type avoiding nulls, context class loader if available
"""
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
return loader != null ? loader.loadClass(fullName) : Class.forName(fullName);
} catch (ClassNotFoundException ex) {
return loadPrimitiveType(fullName, ex);
}
}
|
java
|
static Class<?> loadType(String fullName) throws ClassNotFoundException {
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
return loader != null ? loader.loadClass(fullName) : Class.forName(fullName);
} catch (ClassNotFoundException ex) {
return loadPrimitiveType(fullName, ex);
}
}
|
[
"static",
"Class",
"<",
"?",
">",
"loadType",
"(",
"String",
"fullName",
")",
"throws",
"ClassNotFoundException",
"{",
"try",
"{",
"ClassLoader",
"loader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"return",
"loader",
"!=",
"null",
"?",
"loader",
".",
"loadClass",
"(",
"fullName",
")",
":",
"Class",
".",
"forName",
"(",
"fullName",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"ex",
")",
"{",
"return",
"loadPrimitiveType",
"(",
"fullName",
",",
"ex",
")",
";",
"}",
"}"
] |
loads a type avoiding nulls, context class loader if available
|
[
"loads",
"a",
"type",
"avoiding",
"nulls",
"context",
"class",
"loader",
"if",
"available"
] |
train
|
https://github.com/JodaOrg/joda-convert/blob/266bd825f4550590d5dafdf4225c548559e0633b/src/main/java/org/joda/convert/StringConvert.java#L854-L861
|
Azure/azure-sdk-for-java
|
resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java
|
ResourcesInner.createOrUpdate
|
public GenericResourceInner createOrUpdate(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) {
"""
Creates a resource.
@param resourceGroupName The name of the resource group for the resource. The name is case insensitive.
@param resourceProviderNamespace The namespace of the resource provider.
@param parentResourcePath The parent resource identity.
@param resourceType The resource type of the resource to create.
@param resourceName The name of the resource to create.
@param apiVersion The API version to use for the operation.
@param parameters Parameters for creating or updating the resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the GenericResourceInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).toBlocking().last().body();
}
|
java
|
public GenericResourceInner createOrUpdate(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion, GenericResourceInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).toBlocking().last().body();
}
|
[
"public",
"GenericResourceInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceProviderNamespace",
",",
"String",
"parentResourcePath",
",",
"String",
"resourceType",
",",
"String",
"resourceName",
",",
"String",
"apiVersion",
",",
"GenericResourceInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceProviderNamespace",
",",
"parentResourcePath",
",",
"resourceType",
",",
"resourceName",
",",
"apiVersion",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Creates a resource.
@param resourceGroupName The name of the resource group for the resource. The name is case insensitive.
@param resourceProviderNamespace The namespace of the resource provider.
@param parentResourcePath The parent resource identity.
@param resourceType The resource type of the resource to create.
@param resourceName The name of the resource to create.
@param apiVersion The API version to use for the operation.
@param parameters Parameters for creating or updating the resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the GenericResourceInner object if successful.
|
[
"Creates",
"a",
"resource",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/resources/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/resources/v2018_02_01/implementation/ResourcesInner.java#L1294-L1296
|
EdwardRaff/JSAT
|
JSAT/src/jsat/parameters/Parameter.java
|
Parameter.toParameterMap
|
public static Map<String, Parameter> toParameterMap(List<Parameter> params) {
"""
Creates a map of all possible parameter names to their corresponding object. No two parameters may have the same name.
@param params the list of parameters to create a map for
@return a map of string names to their parameters
@throws RuntimeException if two parameters have the same name
"""
Map<String, Parameter> map = new HashMap<String, Parameter>(params.size());
for(Parameter param : params)
{
if(map.put(param.getASCIIName(), param) != null)
throw new RuntimeException("Name collision, two parameters use the name '" + param.getASCIIName() + "'");
if(!param.getName().equals(param.getASCIIName()))//Dont put it in again
if(map.put(param.getName(), param) != null)
throw new RuntimeException("Name collision, two parameters use the name '" + param.getName() + "'");
}
return map;
}
|
java
|
public static Map<String, Parameter> toParameterMap(List<Parameter> params)
{
Map<String, Parameter> map = new HashMap<String, Parameter>(params.size());
for(Parameter param : params)
{
if(map.put(param.getASCIIName(), param) != null)
throw new RuntimeException("Name collision, two parameters use the name '" + param.getASCIIName() + "'");
if(!param.getName().equals(param.getASCIIName()))//Dont put it in again
if(map.put(param.getName(), param) != null)
throw new RuntimeException("Name collision, two parameters use the name '" + param.getName() + "'");
}
return map;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Parameter",
">",
"toParameterMap",
"(",
"List",
"<",
"Parameter",
">",
"params",
")",
"{",
"Map",
"<",
"String",
",",
"Parameter",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Parameter",
">",
"(",
"params",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Parameter",
"param",
":",
"params",
")",
"{",
"if",
"(",
"map",
".",
"put",
"(",
"param",
".",
"getASCIIName",
"(",
")",
",",
"param",
")",
"!=",
"null",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Name collision, two parameters use the name '\"",
"+",
"param",
".",
"getASCIIName",
"(",
")",
"+",
"\"'\"",
")",
";",
"if",
"(",
"!",
"param",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"param",
".",
"getASCIIName",
"(",
")",
")",
")",
"//Dont put it in again",
"if",
"(",
"map",
".",
"put",
"(",
"param",
".",
"getName",
"(",
")",
",",
"param",
")",
"!=",
"null",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Name collision, two parameters use the name '\"",
"+",
"param",
".",
"getName",
"(",
")",
"+",
"\"'\"",
")",
";",
"}",
"return",
"map",
";",
"}"
] |
Creates a map of all possible parameter names to their corresponding object. No two parameters may have the same name.
@param params the list of parameters to create a map for
@return a map of string names to their parameters
@throws RuntimeException if two parameters have the same name
|
[
"Creates",
"a",
"map",
"of",
"all",
"possible",
"parameter",
"names",
"to",
"their",
"corresponding",
"object",
".",
"No",
"two",
"parameters",
"may",
"have",
"the",
"same",
"name",
"."
] |
train
|
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/parameters/Parameter.java#L172-L184
|
grpc/grpc-java
|
okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/ConnectionSpec.java
|
ConnectionSpec.nonEmptyIntersection
|
private static boolean nonEmptyIntersection(String[] a, String[] b) {
"""
An N*M intersection that terminates if any intersection is found. The sizes of both
arguments are assumed to be so small, and the likelihood of an intersection so great, that it
is not worth the CPU cost of sorting or the memory cost of hashing.
"""
if (a == null || b == null || a.length == 0 || b.length == 0) {
return false;
}
for (String toFind : a) {
if (contains(b, toFind)) {
return true;
}
}
return false;
}
|
java
|
private static boolean nonEmptyIntersection(String[] a, String[] b) {
if (a == null || b == null || a.length == 0 || b.length == 0) {
return false;
}
for (String toFind : a) {
if (contains(b, toFind)) {
return true;
}
}
return false;
}
|
[
"private",
"static",
"boolean",
"nonEmptyIntersection",
"(",
"String",
"[",
"]",
"a",
",",
"String",
"[",
"]",
"b",
")",
"{",
"if",
"(",
"a",
"==",
"null",
"||",
"b",
"==",
"null",
"||",
"a",
".",
"length",
"==",
"0",
"||",
"b",
".",
"length",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"String",
"toFind",
":",
"a",
")",
"{",
"if",
"(",
"contains",
"(",
"b",
",",
"toFind",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
An N*M intersection that terminates if any intersection is found. The sizes of both
arguments are assumed to be so small, and the likelihood of an intersection so great, that it
is not worth the CPU cost of sorting or the memory cost of hashing.
|
[
"An",
"N",
"*",
"M",
"intersection",
"that",
"terminates",
"if",
"any",
"intersection",
"is",
"found",
".",
"The",
"sizes",
"of",
"both",
"arguments",
"are",
"assumed",
"to",
"be",
"so",
"small",
"and",
"the",
"likelihood",
"of",
"an",
"intersection",
"so",
"great",
"that",
"it",
"is",
"not",
"worth",
"the",
"CPU",
"cost",
"of",
"sorting",
"or",
"the",
"memory",
"cost",
"of",
"hashing",
"."
] |
train
|
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/okhttp/third_party/okhttp/main/java/io/grpc/okhttp/internal/ConnectionSpec.java#L214-L224
|
drallgood/jpasskit
|
jpasskit/src/main/java/de/brendamour/jpasskit/signing/PKSigningInformationUtil.java
|
PKSigningInformationUtil.loadPKCS12File
|
@Deprecated
public KeyStore loadPKCS12File(String pathToP12, String password) throws CertificateException, IOException {
"""
Load PKCS12 keystore file from file (will try to load it from the classpath)
@param pathToP12
path to PKCS 12 file (on the filesystem or classpath)
@param password
password to access the key store
@return Key store loaded from the provided files
@throws IOException
@throws CertificateException
@throws IllegalArgumentException
@deprecated
"""
try (InputStream keystoreInputStream = CertUtils.toInputStream(pathToP12)) {
return loadPKCS12File(keystoreInputStream, password);
}
}
|
java
|
@Deprecated
public KeyStore loadPKCS12File(String pathToP12, String password) throws CertificateException, IOException {
try (InputStream keystoreInputStream = CertUtils.toInputStream(pathToP12)) {
return loadPKCS12File(keystoreInputStream, password);
}
}
|
[
"@",
"Deprecated",
"public",
"KeyStore",
"loadPKCS12File",
"(",
"String",
"pathToP12",
",",
"String",
"password",
")",
"throws",
"CertificateException",
",",
"IOException",
"{",
"try",
"(",
"InputStream",
"keystoreInputStream",
"=",
"CertUtils",
".",
"toInputStream",
"(",
"pathToP12",
")",
")",
"{",
"return",
"loadPKCS12File",
"(",
"keystoreInputStream",
",",
"password",
")",
";",
"}",
"}"
] |
Load PKCS12 keystore file from file (will try to load it from the classpath)
@param pathToP12
path to PKCS 12 file (on the filesystem or classpath)
@param password
password to access the key store
@return Key store loaded from the provided files
@throws IOException
@throws CertificateException
@throws IllegalArgumentException
@deprecated
|
[
"Load",
"PKCS12",
"keystore",
"file",
"from",
"file",
"(",
"will",
"try",
"to",
"load",
"it",
"from",
"the",
"classpath",
")"
] |
train
|
https://github.com/drallgood/jpasskit/blob/63bfa8abbdb85c2d7596c60eed41ed8e374cbd01/jpasskit/src/main/java/de/brendamour/jpasskit/signing/PKSigningInformationUtil.java#L124-L129
|
atomix/copycat
|
server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java
|
ServerStateMachine.sequenceCommand
|
private void sequenceCommand(long sequence, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
"""
Sequences a command according to the command sequence number.
"""
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
return;
}
Result result = session.getResult(sequence);
if (result == null) {
LOGGER.debug("Missing command result for {}:{}", session.id(), sequence);
}
context.executor().execute(() -> future.complete(result));
}
|
java
|
private void sequenceCommand(long sequence, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
if (!log.isOpen()) {
context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
return;
}
Result result = session.getResult(sequence);
if (result == null) {
LOGGER.debug("Missing command result for {}:{}", session.id(), sequence);
}
context.executor().execute(() -> future.complete(result));
}
|
[
"private",
"void",
"sequenceCommand",
"(",
"long",
"sequence",
",",
"ServerSessionContext",
"session",
",",
"CompletableFuture",
"<",
"Result",
">",
"future",
",",
"ThreadContext",
"context",
")",
"{",
"if",
"(",
"!",
"log",
".",
"isOpen",
"(",
")",
")",
"{",
"context",
".",
"executor",
"(",
")",
".",
"execute",
"(",
"(",
")",
"->",
"future",
".",
"completeExceptionally",
"(",
"new",
"IllegalStateException",
"(",
"\"log closed\"",
")",
")",
")",
";",
"return",
";",
"}",
"Result",
"result",
"=",
"session",
".",
"getResult",
"(",
"sequence",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Missing command result for {}:{}\"",
",",
"session",
".",
"id",
"(",
")",
",",
"sequence",
")",
";",
"}",
"context",
".",
"executor",
"(",
")",
".",
"execute",
"(",
"(",
")",
"->",
"future",
".",
"complete",
"(",
"result",
")",
")",
";",
"}"
] |
Sequences a command according to the command sequence number.
|
[
"Sequences",
"a",
"command",
"according",
"to",
"the",
"command",
"sequence",
"number",
"."
] |
train
|
https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/server/src/main/java/io/atomix/copycat/server/state/ServerStateMachine.java#L817-L828
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/logging/Logger.java
|
Logger.exiting
|
public void exiting(String sourceClass, String sourceMethod, Object result) {
"""
Log a method return, with result object.
<p>
This is a convenience method that can be used to log returning
from a method. A LogRecord with message "RETURN {0}", log level
FINER, and the gives sourceMethod, sourceClass, and result
object is logged.
<p>
@param sourceClass name of class that issued the logging request
@param sourceMethod name of the method
@param result Object that is being returned
"""
if (Level.FINER.intValue() < levelValue) {
return;
}
Object params[] = { result };
logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", result);
}
|
java
|
public void exiting(String sourceClass, String sourceMethod, Object result) {
if (Level.FINER.intValue() < levelValue) {
return;
}
Object params[] = { result };
logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", result);
}
|
[
"public",
"void",
"exiting",
"(",
"String",
"sourceClass",
",",
"String",
"sourceMethod",
",",
"Object",
"result",
")",
"{",
"if",
"(",
"Level",
".",
"FINER",
".",
"intValue",
"(",
")",
"<",
"levelValue",
")",
"{",
"return",
";",
"}",
"Object",
"params",
"[",
"]",
"=",
"{",
"result",
"}",
";",
"logp",
"(",
"Level",
".",
"FINER",
",",
"sourceClass",
",",
"sourceMethod",
",",
"\"RETURN {0}\"",
",",
"result",
")",
";",
"}"
] |
Log a method return, with result object.
<p>
This is a convenience method that can be used to log returning
from a method. A LogRecord with message "RETURN {0}", log level
FINER, and the gives sourceMethod, sourceClass, and result
object is logged.
<p>
@param sourceClass name of class that issued the logging request
@param sourceMethod name of the method
@param result Object that is being returned
|
[
"Log",
"a",
"method",
"return",
"with",
"result",
"object",
".",
"<p",
">",
"This",
"is",
"a",
"convenience",
"method",
"that",
"can",
"be",
"used",
"to",
"log",
"returning",
"from",
"a",
"method",
".",
"A",
"LogRecord",
"with",
"message",
"RETURN",
"{",
"0",
"}",
"log",
"level",
"FINER",
"and",
"the",
"gives",
"sourceMethod",
"sourceClass",
"and",
"result",
"object",
"is",
"logged",
".",
"<p",
">"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/logging/Logger.java#L1111-L1117
|
GistLabs/mechanize
|
src/main/java/com/gistlabs/mechanize/document/json/hypermedia/JsonLink.java
|
JsonLink.lookupVar
|
protected Object lookupVar(JsonNode node, String var) {
"""
Return an Object that is either String or List<String> or Map<String, String>
@param var maybe null if not found
@return
"""
List<? extends JsonNode> children = node.getChildren(var);
if (children.size()>1) { // multiple with name, treat as list of values
List<String> result = new ArrayList<String>();
for (JsonNode child : children) {
result.add(child.getValue());
}
return result;
} else if (children.size()==1) {
JsonNode child = children.get(0);
List<String> attributeNames = child.getAttributeNames();
Collections.sort(attributeNames);
if (attributeNames.size()==0) { // treat child as the attribute value
return child.getValue();
} else { // treat child as object with map values
Map<String, String> result = new LinkedHashMap<String, String>();
for (String attrName : attributeNames) {
result.put(attrName, child.getAttribute(attrName));
}
return result;
}
} else { // return null
return null;
}
}
|
java
|
protected Object lookupVar(JsonNode node, String var) {
List<? extends JsonNode> children = node.getChildren(var);
if (children.size()>1) { // multiple with name, treat as list of values
List<String> result = new ArrayList<String>();
for (JsonNode child : children) {
result.add(child.getValue());
}
return result;
} else if (children.size()==1) {
JsonNode child = children.get(0);
List<String> attributeNames = child.getAttributeNames();
Collections.sort(attributeNames);
if (attributeNames.size()==0) { // treat child as the attribute value
return child.getValue();
} else { // treat child as object with map values
Map<String, String> result = new LinkedHashMap<String, String>();
for (String attrName : attributeNames) {
result.put(attrName, child.getAttribute(attrName));
}
return result;
}
} else { // return null
return null;
}
}
|
[
"protected",
"Object",
"lookupVar",
"(",
"JsonNode",
"node",
",",
"String",
"var",
")",
"{",
"List",
"<",
"?",
"extends",
"JsonNode",
">",
"children",
"=",
"node",
".",
"getChildren",
"(",
"var",
")",
";",
"if",
"(",
"children",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"// multiple with name, treat as list of values",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"JsonNode",
"child",
":",
"children",
")",
"{",
"result",
".",
"add",
"(",
"child",
".",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}",
"else",
"if",
"(",
"children",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"JsonNode",
"child",
"=",
"children",
".",
"get",
"(",
"0",
")",
";",
"List",
"<",
"String",
">",
"attributeNames",
"=",
"child",
".",
"getAttributeNames",
"(",
")",
";",
"Collections",
".",
"sort",
"(",
"attributeNames",
")",
";",
"if",
"(",
"attributeNames",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// treat child as the attribute value",
"return",
"child",
".",
"getValue",
"(",
")",
";",
"}",
"else",
"{",
"// treat child as object with map values",
"Map",
"<",
"String",
",",
"String",
">",
"result",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"attrName",
":",
"attributeNames",
")",
"{",
"result",
".",
"put",
"(",
"attrName",
",",
"child",
".",
"getAttribute",
"(",
"attrName",
")",
")",
";",
"}",
"return",
"result",
";",
"}",
"}",
"else",
"{",
"// return null",
"return",
"null",
";",
"}",
"}"
] |
Return an Object that is either String or List<String> or Map<String, String>
@param var maybe null if not found
@return
|
[
"Return",
"an",
"Object",
"that",
"is",
"either",
"String",
"or",
"List<String",
">",
"or",
"Map<String",
"String",
">"
] |
train
|
https://github.com/GistLabs/mechanize/blob/32ddd0774439a4c08513c05d7ac7416a3899efed/src/main/java/com/gistlabs/mechanize/document/json/hypermedia/JsonLink.java#L162-L187
|
bushidowallet/bushido-java-service
|
bushido-service-lib/src/main/java/com/bccapi/bitlib/crypto/PrivateKeyRing.java
|
PrivateKeyRing.addPrivateKey
|
public void addPrivateKey(PrivateKey key, NetworkParameters network) {
"""
Add a private key to the key ring.
@param key private key
@param network bitcoin network to talk to
"""
_privateKeys.put(key.getPublicKey(), key);
addPublicKey(key.getPublicKey(), network);
}
|
java
|
public void addPrivateKey(PrivateKey key, NetworkParameters network) {
_privateKeys.put(key.getPublicKey(), key);
addPublicKey(key.getPublicKey(), network);
}
|
[
"public",
"void",
"addPrivateKey",
"(",
"PrivateKey",
"key",
",",
"NetworkParameters",
"network",
")",
"{",
"_privateKeys",
".",
"put",
"(",
"key",
".",
"getPublicKey",
"(",
")",
",",
"key",
")",
";",
"addPublicKey",
"(",
"key",
".",
"getPublicKey",
"(",
")",
",",
"network",
")",
";",
"}"
] |
Add a private key to the key ring.
@param key private key
@param network bitcoin network to talk to
|
[
"Add",
"a",
"private",
"key",
"to",
"the",
"key",
"ring",
"."
] |
train
|
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/crypto/PrivateKeyRing.java#L22-L25
|
geomajas/geomajas-project-client-gwt2
|
common-gwt/common-gwt/src/main/java/org/geomajas/gwt/client/util/Dom.java
|
Dom.assembleId
|
public static String assembleId(String id, String... suffixes) {
"""
Assemble an DOM id.
@param id base id
@param suffixes suffixes to add
@return id
"""
return IMPL.assembleId(id, suffixes);
}
|
java
|
public static String assembleId(String id, String... suffixes) {
return IMPL.assembleId(id, suffixes);
}
|
[
"public",
"static",
"String",
"assembleId",
"(",
"String",
"id",
",",
"String",
"...",
"suffixes",
")",
"{",
"return",
"IMPL",
".",
"assembleId",
"(",
"id",
",",
"suffixes",
")",
";",
"}"
] |
Assemble an DOM id.
@param id base id
@param suffixes suffixes to add
@return id
|
[
"Assemble",
"an",
"DOM",
"id",
"."
] |
train
|
https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/common-gwt/common-gwt/src/main/java/org/geomajas/gwt/client/util/Dom.java#L79-L81
|
moparisthebest/beehive
|
beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/scoping/internal/ParseUtils.java
|
ParseUtils.parseQueryString
|
public static void parseQueryString( String str, Map res, String encoding ) {
"""
Parses an RFC1630 query string into an existing Map.
@param str Query string
@param res Map into which insert the values.
@param encoding Encoding to be used for stored Strings
"""
// "Within the query string, the plus sign is reserved as
// shorthand notation for a space. Therefore, real plus signs must
// be encoded. This method was used to make query URIs easier to
// pass in systems which did not allow spaces." -- RFC 1630
int i = str.indexOf( '#' );
if ( i > 0 )
{
str = str.substring( 0, i );
}
StringTokenizer st = new StringTokenizer( str.replace( '+', ' ' ), "&" );
while ( st.hasMoreTokens() )
{
String qp = st.nextToken();
String[] pair = qp.split( "=" ); // was String[] pair = StringUtils.split(qp, '=');
//String s = unescape(pair[1], encoding);
res.put( unescape( pair[0], encoding ), unescape( pair[1], encoding ) );
}
}
|
java
|
public static void parseQueryString( String str, Map res, String encoding )
{
// "Within the query string, the plus sign is reserved as
// shorthand notation for a space. Therefore, real plus signs must
// be encoded. This method was used to make query URIs easier to
// pass in systems which did not allow spaces." -- RFC 1630
int i = str.indexOf( '#' );
if ( i > 0 )
{
str = str.substring( 0, i );
}
StringTokenizer st = new StringTokenizer( str.replace( '+', ' ' ), "&" );
while ( st.hasMoreTokens() )
{
String qp = st.nextToken();
String[] pair = qp.split( "=" ); // was String[] pair = StringUtils.split(qp, '=');
//String s = unescape(pair[1], encoding);
res.put( unescape( pair[0], encoding ), unescape( pair[1], encoding ) );
}
}
|
[
"public",
"static",
"void",
"parseQueryString",
"(",
"String",
"str",
",",
"Map",
"res",
",",
"String",
"encoding",
")",
"{",
"// \"Within the query string, the plus sign is reserved as",
"// shorthand notation for a space. Therefore, real plus signs must",
"// be encoded. This method was used to make query URIs easier to",
"// pass in systems which did not allow spaces.\" -- RFC 1630",
"int",
"i",
"=",
"str",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"i",
">",
"0",
")",
"{",
"str",
"=",
"str",
".",
"substring",
"(",
"0",
",",
"i",
")",
";",
"}",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"str",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
",",
"\"&\"",
")",
";",
"while",
"(",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"qp",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"String",
"[",
"]",
"pair",
"=",
"qp",
".",
"split",
"(",
"\"=\"",
")",
";",
"// was String[] pair = StringUtils.split(qp, '=');",
"//String s = unescape(pair[1], encoding);",
"res",
".",
"put",
"(",
"unescape",
"(",
"pair",
"[",
"0",
"]",
",",
"encoding",
")",
",",
"unescape",
"(",
"pair",
"[",
"1",
"]",
",",
"encoding",
")",
")",
";",
"}",
"}"
] |
Parses an RFC1630 query string into an existing Map.
@param str Query string
@param res Map into which insert the values.
@param encoding Encoding to be used for stored Strings
|
[
"Parses",
"an",
"RFC1630",
"query",
"string",
"into",
"an",
"existing",
"Map",
"."
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/scoping/internal/ParseUtils.java#L38-L59
|
sahan/ZombieLink
|
zombielink/src/main/java/com/lonepulse/zombielink/response/ResponseProcessorChain.java
|
ResponseProcessorChain.onInitiate
|
@Override
protected Object onInitiate(ProcessorChainLink<Object, ResponseProcessorException> root, Object... args) {
"""
<p>Executed for the root link which runs the {@link HeaderProcessor}. Takes the argument array which
was provided in {@link #run(Object...)} and invokes the root link, i.e. the {@link HeaderProcessor}
and returns the deserialized response content passed down from the successive processor.</p>
<p>See {@link AbstractResponseProcessor}.</p>
{@inheritDoc}
"""
return root.getProcessor().run(args); //allow any exceptions to elevate to a chain-wide failure
}
|
java
|
@Override
protected Object onInitiate(ProcessorChainLink<Object, ResponseProcessorException> root, Object... args) {
return root.getProcessor().run(args); //allow any exceptions to elevate to a chain-wide failure
}
|
[
"@",
"Override",
"protected",
"Object",
"onInitiate",
"(",
"ProcessorChainLink",
"<",
"Object",
",",
"ResponseProcessorException",
">",
"root",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"root",
".",
"getProcessor",
"(",
")",
".",
"run",
"(",
"args",
")",
";",
"//allow any exceptions to elevate to a chain-wide failure",
"}"
] |
<p>Executed for the root link which runs the {@link HeaderProcessor}. Takes the argument array which
was provided in {@link #run(Object...)} and invokes the root link, i.e. the {@link HeaderProcessor}
and returns the deserialized response content passed down from the successive processor.</p>
<p>See {@link AbstractResponseProcessor}.</p>
{@inheritDoc}
|
[
"<p",
">",
"Executed",
"for",
"the",
"root",
"link",
"which",
"runs",
"the",
"{",
"@link",
"HeaderProcessor",
"}",
".",
"Takes",
"the",
"argument",
"array",
"which",
"was",
"provided",
"in",
"{",
"@link",
"#run",
"(",
"Object",
"...",
")",
"}",
"and",
"invokes",
"the",
"root",
"link",
"i",
".",
"e",
".",
"the",
"{",
"@link",
"HeaderProcessor",
"}",
"and",
"returns",
"the",
"deserialized",
"response",
"content",
"passed",
"down",
"from",
"the",
"successive",
"processor",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/sahan/ZombieLink/blob/a9971add56d4f6919a4a5e84c78e9220011d8982/zombielink/src/main/java/com/lonepulse/zombielink/response/ResponseProcessorChain.java#L86-L90
|
authlete/authlete-java-common
|
src/main/java/com/authlete/common/dto/TokenRequest.java
|
TokenRequest.setParameters
|
public TokenRequest setParameters(Map<String, String[]> parameters) {
"""
Set the value of {@code parameters} which are the request
parameters that the OAuth 2.0 token endpoint of the service
implementation received from the client application.
<p>
This method converts the given map into a string in {@code
x-www-form-urlencoded} and passes it to {@link
#setParameters(String)} method.
</p>
@param parameters
Request parameters.
@return
{@code this} object.
@since 1.24
"""
return setParameters(URLCoder.formUrlEncode(parameters));
}
|
java
|
public TokenRequest setParameters(Map<String, String[]> parameters)
{
return setParameters(URLCoder.formUrlEncode(parameters));
}
|
[
"public",
"TokenRequest",
"setParameters",
"(",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"parameters",
")",
"{",
"return",
"setParameters",
"(",
"URLCoder",
".",
"formUrlEncode",
"(",
"parameters",
")",
")",
";",
"}"
] |
Set the value of {@code parameters} which are the request
parameters that the OAuth 2.0 token endpoint of the service
implementation received from the client application.
<p>
This method converts the given map into a string in {@code
x-www-form-urlencoded} and passes it to {@link
#setParameters(String)} method.
</p>
@param parameters
Request parameters.
@return
{@code this} object.
@since 1.24
|
[
"Set",
"the",
"value",
"of",
"{",
"@code",
"parameters",
"}",
"which",
"are",
"the",
"request",
"parameters",
"that",
"the",
"OAuth",
"2",
".",
"0",
"token",
"endpoint",
"of",
"the",
"service",
"implementation",
"received",
"from",
"the",
"client",
"application",
"."
] |
train
|
https://github.com/authlete/authlete-java-common/blob/49c94c483713cbf5a04d805ff7dbd83766c9c964/src/main/java/com/authlete/common/dto/TokenRequest.java#L192-L195
|
TheCoder4eu/BootsFaces-OSP
|
src/main/java/net/bootsfaces/component/panel/PanelRenderer.java
|
PanelRenderer.encodeEnd
|
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
"""
This methods generates the HTML code of the current b:panel.
<code>encodeBegin</code> generates the start of the component. After the,
the JSF framework calls <code>encodeChildren()</code> to generate the
HTML code between the beginning and the end of the component. For
instance, in the case of a panel component the content of the panel is
generated by <code>encodeChildren()</code>. After that,
<code>encodeEnd()</code> is called to generate the rest of the HTML code.
@param context
the FacesContext.
@param component
the current b:panel.
@throws IOException
thrown if something goes wrong when writing the HTML code.
"""
if (!component.isRendered()) {
return;
}
Panel panel = (Panel) component;
ResponseWriter rw = context.getResponseWriter();
if (panel.isContentDisabled()) {
rw.endElement("fieldset");
}
String clientId = panel.getClientId();
rw.endElement("div"); // panel-body
UIComponent foot = panel.getFacet("footer");
if (foot != null) {
rw.startElement("div", panel); // modal-footer
rw.writeAttribute("class", "panel-footer", "class");
foot.encodeAll(context);
rw.endElement("div"); // panel-footer
}
rw.endElement("div");
rw.endElement("div"); // panel-body
boolean isCollapsible = panel.isCollapsible();
String accordionParent = panel.getAccordionParent();
String responsiveCSS = Responsive.getResponsiveStyleClass(panel, false).trim();
boolean isResponsive = responsiveCSS.length() > 0;
if ((isCollapsible||isResponsive) && null == accordionParent) {
rw.endElement("div");
if (isCollapsible) {
String jQueryClientID = clientId.replace(":", "_");
rw.startElement("input", panel);
rw.writeAttribute("type", "hidden", null);
String hiddenInputFieldID = jQueryClientID + "_collapsed";
rw.writeAttribute("name", hiddenInputFieldID, "name");
rw.writeAttribute("id", hiddenInputFieldID, "id");
rw.writeAttribute("value", String.valueOf(panel.isCollapsed()), "value");
rw.endElement("input");
Map<String, String> eventHandlers = new HashMap<String, String>();
eventHandlers.put("expand", "document.getElementById('" + hiddenInputFieldID
+ "').value='false';");
eventHandlers.put("collapse", "document.getElementById('" + hiddenInputFieldID
+ "').value='true';");
new AJAXRenderer().generateBootsFacesAJAXAndJavaScriptForJQuery(context, component, rw, "#"+jQueryClientID+"content", eventHandlers);
}
}
Tooltip.activateTooltips(context, panel);
}
|
java
|
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
if (!component.isRendered()) {
return;
}
Panel panel = (Panel) component;
ResponseWriter rw = context.getResponseWriter();
if (panel.isContentDisabled()) {
rw.endElement("fieldset");
}
String clientId = panel.getClientId();
rw.endElement("div"); // panel-body
UIComponent foot = panel.getFacet("footer");
if (foot != null) {
rw.startElement("div", panel); // modal-footer
rw.writeAttribute("class", "panel-footer", "class");
foot.encodeAll(context);
rw.endElement("div"); // panel-footer
}
rw.endElement("div");
rw.endElement("div"); // panel-body
boolean isCollapsible = panel.isCollapsible();
String accordionParent = panel.getAccordionParent();
String responsiveCSS = Responsive.getResponsiveStyleClass(panel, false).trim();
boolean isResponsive = responsiveCSS.length() > 0;
if ((isCollapsible||isResponsive) && null == accordionParent) {
rw.endElement("div");
if (isCollapsible) {
String jQueryClientID = clientId.replace(":", "_");
rw.startElement("input", panel);
rw.writeAttribute("type", "hidden", null);
String hiddenInputFieldID = jQueryClientID + "_collapsed";
rw.writeAttribute("name", hiddenInputFieldID, "name");
rw.writeAttribute("id", hiddenInputFieldID, "id");
rw.writeAttribute("value", String.valueOf(panel.isCollapsed()), "value");
rw.endElement("input");
Map<String, String> eventHandlers = new HashMap<String, String>();
eventHandlers.put("expand", "document.getElementById('" + hiddenInputFieldID
+ "').value='false';");
eventHandlers.put("collapse", "document.getElementById('" + hiddenInputFieldID
+ "').value='true';");
new AJAXRenderer().generateBootsFacesAJAXAndJavaScriptForJQuery(context, component, rw, "#"+jQueryClientID+"content", eventHandlers);
}
}
Tooltip.activateTooltips(context, panel);
}
|
[
"@",
"Override",
"public",
"void",
"encodeEnd",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"component",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"component",
".",
"isRendered",
"(",
")",
")",
"{",
"return",
";",
"}",
"Panel",
"panel",
"=",
"(",
"Panel",
")",
"component",
";",
"ResponseWriter",
"rw",
"=",
"context",
".",
"getResponseWriter",
"(",
")",
";",
"if",
"(",
"panel",
".",
"isContentDisabled",
"(",
")",
")",
"{",
"rw",
".",
"endElement",
"(",
"\"fieldset\"",
")",
";",
"}",
"String",
"clientId",
"=",
"panel",
".",
"getClientId",
"(",
")",
";",
"rw",
".",
"endElement",
"(",
"\"div\"",
")",
";",
"// panel-body",
"UIComponent",
"foot",
"=",
"panel",
".",
"getFacet",
"(",
"\"footer\"",
")",
";",
"if",
"(",
"foot",
"!=",
"null",
")",
"{",
"rw",
".",
"startElement",
"(",
"\"div\"",
",",
"panel",
")",
";",
"// modal-footer",
"rw",
".",
"writeAttribute",
"(",
"\"class\"",
",",
"\"panel-footer\"",
",",
"\"class\"",
")",
";",
"foot",
".",
"encodeAll",
"(",
"context",
")",
";",
"rw",
".",
"endElement",
"(",
"\"div\"",
")",
";",
"// panel-footer",
"}",
"rw",
".",
"endElement",
"(",
"\"div\"",
")",
";",
"rw",
".",
"endElement",
"(",
"\"div\"",
")",
";",
"// panel-body",
"boolean",
"isCollapsible",
"=",
"panel",
".",
"isCollapsible",
"(",
")",
";",
"String",
"accordionParent",
"=",
"panel",
".",
"getAccordionParent",
"(",
")",
";",
"String",
"responsiveCSS",
"=",
"Responsive",
".",
"getResponsiveStyleClass",
"(",
"panel",
",",
"false",
")",
".",
"trim",
"(",
")",
";",
"boolean",
"isResponsive",
"=",
"responsiveCSS",
".",
"length",
"(",
")",
">",
"0",
";",
"if",
"(",
"(",
"isCollapsible",
"||",
"isResponsive",
")",
"&&",
"null",
"==",
"accordionParent",
")",
"{",
"rw",
".",
"endElement",
"(",
"\"div\"",
")",
";",
"if",
"(",
"isCollapsible",
")",
"{",
"String",
"jQueryClientID",
"=",
"clientId",
".",
"replace",
"(",
"\":\"",
",",
"\"_\"",
")",
";",
"rw",
".",
"startElement",
"(",
"\"input\"",
",",
"panel",
")",
";",
"rw",
".",
"writeAttribute",
"(",
"\"type\"",
",",
"\"hidden\"",
",",
"null",
")",
";",
"String",
"hiddenInputFieldID",
"=",
"jQueryClientID",
"+",
"\"_collapsed\"",
";",
"rw",
".",
"writeAttribute",
"(",
"\"name\"",
",",
"hiddenInputFieldID",
",",
"\"name\"",
")",
";",
"rw",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"hiddenInputFieldID",
",",
"\"id\"",
")",
";",
"rw",
".",
"writeAttribute",
"(",
"\"value\"",
",",
"String",
".",
"valueOf",
"(",
"panel",
".",
"isCollapsed",
"(",
")",
")",
",",
"\"value\"",
")",
";",
"rw",
".",
"endElement",
"(",
"\"input\"",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"eventHandlers",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"eventHandlers",
".",
"put",
"(",
"\"expand\"",
",",
"\"document.getElementById('\"",
"+",
"hiddenInputFieldID",
"+",
"\"').value='false';\"",
")",
";",
"eventHandlers",
".",
"put",
"(",
"\"collapse\"",
",",
"\"document.getElementById('\"",
"+",
"hiddenInputFieldID",
"+",
"\"').value='true';\"",
")",
";",
"new",
"AJAXRenderer",
"(",
")",
".",
"generateBootsFacesAJAXAndJavaScriptForJQuery",
"(",
"context",
",",
"component",
",",
"rw",
",",
"\"#\"",
"+",
"jQueryClientID",
"+",
"\"content\"",
",",
"eventHandlers",
")",
";",
"}",
"}",
"Tooltip",
".",
"activateTooltips",
"(",
"context",
",",
"panel",
")",
";",
"}"
] |
This methods generates the HTML code of the current b:panel.
<code>encodeBegin</code> generates the start of the component. After the,
the JSF framework calls <code>encodeChildren()</code> to generate the
HTML code between the beginning and the end of the component. For
instance, in the case of a panel component the content of the panel is
generated by <code>encodeChildren()</code>. After that,
<code>encodeEnd()</code> is called to generate the rest of the HTML code.
@param context
the FacesContext.
@param component
the current b:panel.
@throws IOException
thrown if something goes wrong when writing the HTML code.
|
[
"This",
"methods",
"generates",
"the",
"HTML",
"code",
"of",
"the",
"current",
"b",
":",
"panel",
".",
"<code",
">",
"encodeBegin<",
"/",
"code",
">",
"generates",
"the",
"start",
"of",
"the",
"component",
".",
"After",
"the",
"the",
"JSF",
"framework",
"calls",
"<code",
">",
"encodeChildren",
"()",
"<",
"/",
"code",
">",
"to",
"generate",
"the",
"HTML",
"code",
"between",
"the",
"beginning",
"and",
"the",
"end",
"of",
"the",
"component",
".",
"For",
"instance",
"in",
"the",
"case",
"of",
"a",
"panel",
"component",
"the",
"content",
"of",
"the",
"panel",
"is",
"generated",
"by",
"<code",
">",
"encodeChildren",
"()",
"<",
"/",
"code",
">",
".",
"After",
"that",
"<code",
">",
"encodeEnd",
"()",
"<",
"/",
"code",
">",
"is",
"called",
"to",
"generate",
"the",
"rest",
"of",
"the",
"HTML",
"code",
"."
] |
train
|
https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/component/panel/PanelRenderer.java#L279-L328
|
Tristan971/EasyFXML
|
easyfxml/src/main/java/moe/tristan/easyfxml/util/Clipping.java
|
Clipping.getSquareClip
|
public static Rectangle getSquareClip(final double side, final double roundedRadius) {
"""
Builds a clip-ready rounded corners {@link Rectangle} that is square.
@param side The size of the size of this square
@param roundedRadius The radius of this square's corners rounding
@return A square with the given side size and rounded corners with the given radius
"""
final Rectangle rectangle = new Rectangle();
rectangle.setHeight(side);
rectangle.setWidth(side);
rectangle.setArcWidth(roundedRadius);
rectangle.setArcHeight(roundedRadius);
return rectangle;
}
|
java
|
public static Rectangle getSquareClip(final double side, final double roundedRadius) {
final Rectangle rectangle = new Rectangle();
rectangle.setHeight(side);
rectangle.setWidth(side);
rectangle.setArcWidth(roundedRadius);
rectangle.setArcHeight(roundedRadius);
return rectangle;
}
|
[
"public",
"static",
"Rectangle",
"getSquareClip",
"(",
"final",
"double",
"side",
",",
"final",
"double",
"roundedRadius",
")",
"{",
"final",
"Rectangle",
"rectangle",
"=",
"new",
"Rectangle",
"(",
")",
";",
"rectangle",
".",
"setHeight",
"(",
"side",
")",
";",
"rectangle",
".",
"setWidth",
"(",
"side",
")",
";",
"rectangle",
".",
"setArcWidth",
"(",
"roundedRadius",
")",
";",
"rectangle",
".",
"setArcHeight",
"(",
"roundedRadius",
")",
";",
"return",
"rectangle",
";",
"}"
] |
Builds a clip-ready rounded corners {@link Rectangle} that is square.
@param side The size of the size of this square
@param roundedRadius The radius of this square's corners rounding
@return A square with the given side size and rounded corners with the given radius
|
[
"Builds",
"a",
"clip",
"-",
"ready",
"rounded",
"corners",
"{",
"@link",
"Rectangle",
"}",
"that",
"is",
"square",
"."
] |
train
|
https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Clipping.java#L40-L47
|
aws/aws-sdk-java
|
aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/internal/Utils.java
|
Utils.getRequiredSystemProperty
|
public static String getRequiredSystemProperty(String propertyName, String errorMsgIfNotFound) {
"""
Retrieve system property by name, failing if it's not found
@param propertyName
@param errorMsgIfNotFound
@return Value of property if it exists
"""
String propertyValue = System.getProperty(propertyName);
if (propertyValue == null) {
throw new RuntimeException(errorMsgIfNotFound);
}
return propertyValue;
}
|
java
|
public static String getRequiredSystemProperty(String propertyName, String errorMsgIfNotFound) {
String propertyValue = System.getProperty(propertyName);
if (propertyValue == null) {
throw new RuntimeException(errorMsgIfNotFound);
}
return propertyValue;
}
|
[
"public",
"static",
"String",
"getRequiredSystemProperty",
"(",
"String",
"propertyName",
",",
"String",
"errorMsgIfNotFound",
")",
"{",
"String",
"propertyValue",
"=",
"System",
".",
"getProperty",
"(",
"propertyName",
")",
";",
"if",
"(",
"propertyValue",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"errorMsgIfNotFound",
")",
";",
"}",
"return",
"propertyValue",
";",
"}"
] |
Retrieve system property by name, failing if it's not found
@param propertyName
@param errorMsgIfNotFound
@return Value of property if it exists
|
[
"Retrieve",
"system",
"property",
"by",
"name",
"failing",
"if",
"it",
"s",
"not",
"found"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/internal/Utils.java#L231-L237
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java
|
ApiOvhOrder.cart_cartId_item_itemId_configuration_configurationId_GET
|
public OvhConfigurationItem cart_cartId_item_itemId_configuration_configurationId_GET(String cartId, Long itemId, Long configurationId) throws IOException {
"""
Retrieve configuration item
REST: GET /order/cart/{cartId}/item/{itemId}/configuration/{configurationId}
@param cartId [required] Cart identifier
@param itemId [required] Product item identifier
@param configurationId [required] Configuration item identifier
"""
String qPath = "/order/cart/{cartId}/item/{itemId}/configuration/{configurationId}";
StringBuilder sb = path(qPath, cartId, itemId, configurationId);
String resp = execN(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhConfigurationItem.class);
}
|
java
|
public OvhConfigurationItem cart_cartId_item_itemId_configuration_configurationId_GET(String cartId, Long itemId, Long configurationId) throws IOException {
String qPath = "/order/cart/{cartId}/item/{itemId}/configuration/{configurationId}";
StringBuilder sb = path(qPath, cartId, itemId, configurationId);
String resp = execN(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhConfigurationItem.class);
}
|
[
"public",
"OvhConfigurationItem",
"cart_cartId_item_itemId_configuration_configurationId_GET",
"(",
"String",
"cartId",
",",
"Long",
"itemId",
",",
"Long",
"configurationId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/cart/{cartId}/item/{itemId}/configuration/{configurationId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"cartId",
",",
"itemId",
",",
"configurationId",
")",
";",
"String",
"resp",
"=",
"execN",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhConfigurationItem",
".",
"class",
")",
";",
"}"
] |
Retrieve configuration item
REST: GET /order/cart/{cartId}/item/{itemId}/configuration/{configurationId}
@param cartId [required] Cart identifier
@param itemId [required] Product item identifier
@param configurationId [required] Configuration item identifier
|
[
"Retrieve",
"configuration",
"item"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L8088-L8093
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/metadata/StandardMatchingStrategy.java
|
StandardMatchingStrategy.getMatchResponse
|
@Override
protected MatchResponse getMatchResponse(SecurityConstraint securityConstraint, String resourceName, String method) {
"""
Gets the response object that contains the roles, the SSL required
and access precluded indicators. Gets the response using the standard method algorithm.
@param resourceName The resource name.
@param method The HTTP method.
@return
"""
CollectionMatch collectionMatch = getCollectionMatch(securityConstraint.getWebResourceCollections(), resourceName, method);
if (CollectionMatch.RESPONSE_NO_MATCH.equals(collectionMatch)) {
return MatchResponse.NO_MATCH_RESPONSE;
}
if (com.ibm.ws.webcontainer.osgi.WebContainer.getServletContainerSpecLevel() >= 31) {
if (collectionMatch.isExactMatch() && securityConstraint.isAccessUncovered() && securityConstraint.isFromHttpConstraint()) {
return new MatchResponse(securityConstraint.getRoles(), securityConstraint.isSSLRequired(),
securityConstraint.isAccessPrecluded(), CollectionMatch.RESPONSE_PERMIT);
}
}
return new MatchResponse(securityConstraint.getRoles(), securityConstraint.isSSLRequired(),
securityConstraint.isAccessPrecluded(), collectionMatch);
}
|
java
|
@Override
protected MatchResponse getMatchResponse(SecurityConstraint securityConstraint, String resourceName, String method) {
CollectionMatch collectionMatch = getCollectionMatch(securityConstraint.getWebResourceCollections(), resourceName, method);
if (CollectionMatch.RESPONSE_NO_MATCH.equals(collectionMatch)) {
return MatchResponse.NO_MATCH_RESPONSE;
}
if (com.ibm.ws.webcontainer.osgi.WebContainer.getServletContainerSpecLevel() >= 31) {
if (collectionMatch.isExactMatch() && securityConstraint.isAccessUncovered() && securityConstraint.isFromHttpConstraint()) {
return new MatchResponse(securityConstraint.getRoles(), securityConstraint.isSSLRequired(),
securityConstraint.isAccessPrecluded(), CollectionMatch.RESPONSE_PERMIT);
}
}
return new MatchResponse(securityConstraint.getRoles(), securityConstraint.isSSLRequired(),
securityConstraint.isAccessPrecluded(), collectionMatch);
}
|
[
"@",
"Override",
"protected",
"MatchResponse",
"getMatchResponse",
"(",
"SecurityConstraint",
"securityConstraint",
",",
"String",
"resourceName",
",",
"String",
"method",
")",
"{",
"CollectionMatch",
"collectionMatch",
"=",
"getCollectionMatch",
"(",
"securityConstraint",
".",
"getWebResourceCollections",
"(",
")",
",",
"resourceName",
",",
"method",
")",
";",
"if",
"(",
"CollectionMatch",
".",
"RESPONSE_NO_MATCH",
".",
"equals",
"(",
"collectionMatch",
")",
")",
"{",
"return",
"MatchResponse",
".",
"NO_MATCH_RESPONSE",
";",
"}",
"if",
"(",
"com",
".",
"ibm",
".",
"ws",
".",
"webcontainer",
".",
"osgi",
".",
"WebContainer",
".",
"getServletContainerSpecLevel",
"(",
")",
">=",
"31",
")",
"{",
"if",
"(",
"collectionMatch",
".",
"isExactMatch",
"(",
")",
"&&",
"securityConstraint",
".",
"isAccessUncovered",
"(",
")",
"&&",
"securityConstraint",
".",
"isFromHttpConstraint",
"(",
")",
")",
"{",
"return",
"new",
"MatchResponse",
"(",
"securityConstraint",
".",
"getRoles",
"(",
")",
",",
"securityConstraint",
".",
"isSSLRequired",
"(",
")",
",",
"securityConstraint",
".",
"isAccessPrecluded",
"(",
")",
",",
"CollectionMatch",
".",
"RESPONSE_PERMIT",
")",
";",
"}",
"}",
"return",
"new",
"MatchResponse",
"(",
"securityConstraint",
".",
"getRoles",
"(",
")",
",",
"securityConstraint",
".",
"isSSLRequired",
"(",
")",
",",
"securityConstraint",
".",
"isAccessPrecluded",
"(",
")",
",",
"collectionMatch",
")",
";",
"}"
] |
Gets the response object that contains the roles, the SSL required
and access precluded indicators. Gets the response using the standard method algorithm.
@param resourceName The resource name.
@param method The HTTP method.
@return
|
[
"Gets",
"the",
"response",
"object",
"that",
"contains",
"the",
"roles",
"the",
"SSL",
"required",
"and",
"access",
"precluded",
"indicators",
".",
"Gets",
"the",
"response",
"using",
"the",
"standard",
"method",
"algorithm",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/metadata/StandardMatchingStrategy.java#L47-L64
|
mlhartme/sushi
|
src/main/java/net/oneandone/sushi/fs/ssh/SshNode.java
|
SshNode.copyFileFrom
|
public void copyFileFrom(InputStream src, boolean append) throws CopyFileFromException {
"""
This is the core function to write an ssh node. Does not close src.
"""
ChannelSftp sftp;
try {
sftp = alloc();
try {
sftp.put(src, escape(slashPath), append ? ChannelSftp.APPEND : ChannelSftp.OVERWRITE);
} finally {
free(sftp);
}
} catch (SftpException | JSchException e) {
throw new CopyFileFromException(this, e);
}
}
|
java
|
public void copyFileFrom(InputStream src, boolean append) throws CopyFileFromException {
ChannelSftp sftp;
try {
sftp = alloc();
try {
sftp.put(src, escape(slashPath), append ? ChannelSftp.APPEND : ChannelSftp.OVERWRITE);
} finally {
free(sftp);
}
} catch (SftpException | JSchException e) {
throw new CopyFileFromException(this, e);
}
}
|
[
"public",
"void",
"copyFileFrom",
"(",
"InputStream",
"src",
",",
"boolean",
"append",
")",
"throws",
"CopyFileFromException",
"{",
"ChannelSftp",
"sftp",
";",
"try",
"{",
"sftp",
"=",
"alloc",
"(",
")",
";",
"try",
"{",
"sftp",
".",
"put",
"(",
"src",
",",
"escape",
"(",
"slashPath",
")",
",",
"append",
"?",
"ChannelSftp",
".",
"APPEND",
":",
"ChannelSftp",
".",
"OVERWRITE",
")",
";",
"}",
"finally",
"{",
"free",
"(",
"sftp",
")",
";",
"}",
"}",
"catch",
"(",
"SftpException",
"|",
"JSchException",
"e",
")",
"{",
"throw",
"new",
"CopyFileFromException",
"(",
"this",
",",
"e",
")",
";",
"}",
"}"
] |
This is the core function to write an ssh node. Does not close src.
|
[
"This",
"is",
"the",
"core",
"function",
"to",
"write",
"an",
"ssh",
"node",
".",
"Does",
"not",
"close",
"src",
"."
] |
train
|
https://github.com/mlhartme/sushi/blob/4af33414b04bd58584d4febe5cc63ef6c7346a75/src/main/java/net/oneandone/sushi/fs/ssh/SshNode.java#L738-L751
|
b3dgs/lionengine
|
lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/transition/MapTransitionExtractor.java
|
MapTransitionExtractor.getOtherGroup
|
private String getOtherGroup(Tile tile, Tile neighbor) {
"""
Get the other transition group, excluding the current group and transition itself.
@param tile The tile reference.
@param neighbor The neighbor reference.
@return The third group, excluding transition group and tile reference group, <code>null</code> if none.
"""
final String group = mapGroup.getGroup(tile);
for (final Tile shared : getSharedNeigbors(tile, neighbor))
{
final String sharedNeighborGroup = mapGroup.getGroup(shared);
if (!group.equals(sharedNeighborGroup) && !isTransition(shared))
{
return sharedNeighborGroup;
}
}
return null;
}
|
java
|
private String getOtherGroup(Tile tile, Tile neighbor)
{
final String group = mapGroup.getGroup(tile);
for (final Tile shared : getSharedNeigbors(tile, neighbor))
{
final String sharedNeighborGroup = mapGroup.getGroup(shared);
if (!group.equals(sharedNeighborGroup) && !isTransition(shared))
{
return sharedNeighborGroup;
}
}
return null;
}
|
[
"private",
"String",
"getOtherGroup",
"(",
"Tile",
"tile",
",",
"Tile",
"neighbor",
")",
"{",
"final",
"String",
"group",
"=",
"mapGroup",
".",
"getGroup",
"(",
"tile",
")",
";",
"for",
"(",
"final",
"Tile",
"shared",
":",
"getSharedNeigbors",
"(",
"tile",
",",
"neighbor",
")",
")",
"{",
"final",
"String",
"sharedNeighborGroup",
"=",
"mapGroup",
".",
"getGroup",
"(",
"shared",
")",
";",
"if",
"(",
"!",
"group",
".",
"equals",
"(",
"sharedNeighborGroup",
")",
"&&",
"!",
"isTransition",
"(",
"shared",
")",
")",
"{",
"return",
"sharedNeighborGroup",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the other transition group, excluding the current group and transition itself.
@param tile The tile reference.
@param neighbor The neighbor reference.
@return The third group, excluding transition group and tile reference group, <code>null</code> if none.
|
[
"Get",
"the",
"other",
"transition",
"group",
"excluding",
"the",
"current",
"group",
"and",
"transition",
"itself",
"."
] |
train
|
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/transition/MapTransitionExtractor.java#L212-L224
|
Whiley/WhileyCompiler
|
src/main/java/wyil/interpreter/Interpreter.java
|
Interpreter.executeIf
|
private Status executeIf(Stmt.IfElse stmt, CallStack frame, EnclosingScope scope) {
"""
Execute an if statement at a given point in the function or method body.
This will proceed done either the true or false branch.
@param stmt
--- The if statement to execute
@param frame
--- The current stack frame
@return
"""
RValue.Bool operand = executeExpression(BOOL_T, stmt.getCondition(), frame);
if (operand == RValue.True) {
// branch taken, so execute true branch
return executeBlock(stmt.getTrueBranch(), frame, scope);
} else if (stmt.hasFalseBranch()) {
// branch not taken, so execute false branch
return executeBlock(stmt.getFalseBranch(), frame, scope);
} else {
return Status.NEXT;
}
}
|
java
|
private Status executeIf(Stmt.IfElse stmt, CallStack frame, EnclosingScope scope) {
RValue.Bool operand = executeExpression(BOOL_T, stmt.getCondition(), frame);
if (operand == RValue.True) {
// branch taken, so execute true branch
return executeBlock(stmt.getTrueBranch(), frame, scope);
} else if (stmt.hasFalseBranch()) {
// branch not taken, so execute false branch
return executeBlock(stmt.getFalseBranch(), frame, scope);
} else {
return Status.NEXT;
}
}
|
[
"private",
"Status",
"executeIf",
"(",
"Stmt",
".",
"IfElse",
"stmt",
",",
"CallStack",
"frame",
",",
"EnclosingScope",
"scope",
")",
"{",
"RValue",
".",
"Bool",
"operand",
"=",
"executeExpression",
"(",
"BOOL_T",
",",
"stmt",
".",
"getCondition",
"(",
")",
",",
"frame",
")",
";",
"if",
"(",
"operand",
"==",
"RValue",
".",
"True",
")",
"{",
"// branch taken, so execute true branch",
"return",
"executeBlock",
"(",
"stmt",
".",
"getTrueBranch",
"(",
")",
",",
"frame",
",",
"scope",
")",
";",
"}",
"else",
"if",
"(",
"stmt",
".",
"hasFalseBranch",
"(",
")",
")",
"{",
"// branch not taken, so execute false branch",
"return",
"executeBlock",
"(",
"stmt",
".",
"getFalseBranch",
"(",
")",
",",
"frame",
",",
"scope",
")",
";",
"}",
"else",
"{",
"return",
"Status",
".",
"NEXT",
";",
"}",
"}"
] |
Execute an if statement at a given point in the function or method body.
This will proceed done either the true or false branch.
@param stmt
--- The if statement to execute
@param frame
--- The current stack frame
@return
|
[
"Execute",
"an",
"if",
"statement",
"at",
"a",
"given",
"point",
"in",
"the",
"function",
"or",
"method",
"body",
".",
"This",
"will",
"proceed",
"done",
"either",
"the",
"true",
"or",
"false",
"branch",
"."
] |
train
|
https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/interpreter/Interpreter.java#L380-L391
|
jayantk/jklol
|
src/com/jayantkrish/jklol/models/FactorGraph.java
|
FactorGraph.addFactor
|
public FactorGraph addFactor(String factorName, Factor factor) {
"""
Gets a new {@code FactorGraph} identical to this one, except with
an additional factor. {@code factor} must be defined over
variables which are already in {@code this} graph.
"""
Preconditions.checkArgument(getVariables().containsAll(factor.getVars()));
Factor[] newFactors = Arrays.copyOf(factors, factors.length + 1);
String[] newFactorNames = Arrays.copyOf(factorNames, factorNames.length + 1);
;
newFactors[factors.length] = factor;
newFactorNames[factors.length] = factorName;
return new FactorGraph(variables, newFactors, newFactorNames, conditionedVariables,
conditionedValues, inferenceHint);
}
|
java
|
public FactorGraph addFactor(String factorName, Factor factor) {
Preconditions.checkArgument(getVariables().containsAll(factor.getVars()));
Factor[] newFactors = Arrays.copyOf(factors, factors.length + 1);
String[] newFactorNames = Arrays.copyOf(factorNames, factorNames.length + 1);
;
newFactors[factors.length] = factor;
newFactorNames[factors.length] = factorName;
return new FactorGraph(variables, newFactors, newFactorNames, conditionedVariables,
conditionedValues, inferenceHint);
}
|
[
"public",
"FactorGraph",
"addFactor",
"(",
"String",
"factorName",
",",
"Factor",
"factor",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"getVariables",
"(",
")",
".",
"containsAll",
"(",
"factor",
".",
"getVars",
"(",
")",
")",
")",
";",
"Factor",
"[",
"]",
"newFactors",
"=",
"Arrays",
".",
"copyOf",
"(",
"factors",
",",
"factors",
".",
"length",
"+",
"1",
")",
";",
"String",
"[",
"]",
"newFactorNames",
"=",
"Arrays",
".",
"copyOf",
"(",
"factorNames",
",",
"factorNames",
".",
"length",
"+",
"1",
")",
";",
";",
"newFactors",
"[",
"factors",
".",
"length",
"]",
"=",
"factor",
";",
"newFactorNames",
"[",
"factors",
".",
"length",
"]",
"=",
"factorName",
";",
"return",
"new",
"FactorGraph",
"(",
"variables",
",",
"newFactors",
",",
"newFactorNames",
",",
"conditionedVariables",
",",
"conditionedValues",
",",
"inferenceHint",
")",
";",
"}"
] |
Gets a new {@code FactorGraph} identical to this one, except with
an additional factor. {@code factor} must be defined over
variables which are already in {@code this} graph.
|
[
"Gets",
"a",
"new",
"{"
] |
train
|
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/models/FactorGraph.java#L474-L484
|
javalite/activejdbc
|
activejdbc/src/main/java/org/javalite/activejdbc/Model.java
|
Model.validateRegexpOf
|
protected static ValidationBuilder validateRegexpOf(String attributeName, String pattern) {
"""
Validates an attribite format with a ree hand regular expression.
@param attributeName attribute to validate.
@param pattern regexp pattern which must match the value.
"""
return ModelDelegate.validateRegexpOf(modelClass(), attributeName, pattern);
}
|
java
|
protected static ValidationBuilder validateRegexpOf(String attributeName, String pattern) {
return ModelDelegate.validateRegexpOf(modelClass(), attributeName, pattern);
}
|
[
"protected",
"static",
"ValidationBuilder",
"validateRegexpOf",
"(",
"String",
"attributeName",
",",
"String",
"pattern",
")",
"{",
"return",
"ModelDelegate",
".",
"validateRegexpOf",
"(",
"modelClass",
"(",
")",
",",
"attributeName",
",",
"pattern",
")",
";",
"}"
] |
Validates an attribite format with a ree hand regular expression.
@param attributeName attribute to validate.
@param pattern regexp pattern which must match the value.
|
[
"Validates",
"an",
"attribite",
"format",
"with",
"a",
"ree",
"hand",
"regular",
"expression",
"."
] |
train
|
https://github.com/javalite/activejdbc/blob/ffcf5457cace19622a8f71e856cbbbe9e7dd5fcc/activejdbc/src/main/java/org/javalite/activejdbc/Model.java#L2007-L2009
|
acromusashi/acromusashi-stream
|
src/main/java/acromusashi/stream/bolt/hdfs/HdfsPreProcessor.java
|
HdfsPreProcessor.renameTmpFile
|
private static void renameTmpFile(FileSystem hdfs, String targetTmpPath, String tmpSuffix) {
"""
前処理対象ファイルをリネームする。<br>
リネーム先にファイルが存在していた場合はリネームをスキップする。
@param hdfs ファイルシステム
@param targetTmpPath 前処理対象ファイルパス
@param tmpSuffix 一時ファイル名称パターン
"""
String basePath = extractBasePath(targetTmpPath, tmpSuffix);
boolean isFileExists = true;
try
{
isFileExists = hdfs.exists(new Path(basePath));
}
catch (IOException ioex)
{
String logFormat = "Failed to search target file exists. Skip file rename. : TargetUri={0}";
String logMessage = MessageFormat.format(logFormat, basePath);
logger.warn(logMessage, ioex);
return;
}
if (isFileExists)
{
String logFormat = "File exists renamed target. Skip file rename. : BeforeUri={0} , AfterUri={1}";
String logMessage = MessageFormat.format(logFormat, targetTmpPath, basePath);
logger.warn(logMessage);
}
else
{
try
{
hdfs.rename(new Path(targetTmpPath), new Path(basePath));
}
catch (IOException ioex)
{
String logFormat = "Failed to HDFS file rename. Skip rename file and continue preprocess. : BeforeUri={0} , AfterUri={1}";
String logMessage = MessageFormat.format(logFormat, targetTmpPath, basePath);
logger.warn(logMessage, ioex);
}
}
}
|
java
|
private static void renameTmpFile(FileSystem hdfs, String targetTmpPath, String tmpSuffix)
{
String basePath = extractBasePath(targetTmpPath, tmpSuffix);
boolean isFileExists = true;
try
{
isFileExists = hdfs.exists(new Path(basePath));
}
catch (IOException ioex)
{
String logFormat = "Failed to search target file exists. Skip file rename. : TargetUri={0}";
String logMessage = MessageFormat.format(logFormat, basePath);
logger.warn(logMessage, ioex);
return;
}
if (isFileExists)
{
String logFormat = "File exists renamed target. Skip file rename. : BeforeUri={0} , AfterUri={1}";
String logMessage = MessageFormat.format(logFormat, targetTmpPath, basePath);
logger.warn(logMessage);
}
else
{
try
{
hdfs.rename(new Path(targetTmpPath), new Path(basePath));
}
catch (IOException ioex)
{
String logFormat = "Failed to HDFS file rename. Skip rename file and continue preprocess. : BeforeUri={0} , AfterUri={1}";
String logMessage = MessageFormat.format(logFormat, targetTmpPath, basePath);
logger.warn(logMessage, ioex);
}
}
}
|
[
"private",
"static",
"void",
"renameTmpFile",
"(",
"FileSystem",
"hdfs",
",",
"String",
"targetTmpPath",
",",
"String",
"tmpSuffix",
")",
"{",
"String",
"basePath",
"=",
"extractBasePath",
"(",
"targetTmpPath",
",",
"tmpSuffix",
")",
";",
"boolean",
"isFileExists",
"=",
"true",
";",
"try",
"{",
"isFileExists",
"=",
"hdfs",
".",
"exists",
"(",
"new",
"Path",
"(",
"basePath",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioex",
")",
"{",
"String",
"logFormat",
"=",
"\"Failed to search target file exists. Skip file rename. : TargetUri={0}\"",
";",
"String",
"logMessage",
"=",
"MessageFormat",
".",
"format",
"(",
"logFormat",
",",
"basePath",
")",
";",
"logger",
".",
"warn",
"(",
"logMessage",
",",
"ioex",
")",
";",
"return",
";",
"}",
"if",
"(",
"isFileExists",
")",
"{",
"String",
"logFormat",
"=",
"\"File exists renamed target. Skip file rename. : BeforeUri={0} , AfterUri={1}\"",
";",
"String",
"logMessage",
"=",
"MessageFormat",
".",
"format",
"(",
"logFormat",
",",
"targetTmpPath",
",",
"basePath",
")",
";",
"logger",
".",
"warn",
"(",
"logMessage",
")",
";",
"}",
"else",
"{",
"try",
"{",
"hdfs",
".",
"rename",
"(",
"new",
"Path",
"(",
"targetTmpPath",
")",
",",
"new",
"Path",
"(",
"basePath",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioex",
")",
"{",
"String",
"logFormat",
"=",
"\"Failed to HDFS file rename. Skip rename file and continue preprocess. : BeforeUri={0} , AfterUri={1}\"",
";",
"String",
"logMessage",
"=",
"MessageFormat",
".",
"format",
"(",
"logFormat",
",",
"targetTmpPath",
",",
"basePath",
")",
";",
"logger",
".",
"warn",
"(",
"logMessage",
",",
"ioex",
")",
";",
"}",
"}",
"}"
] |
前処理対象ファイルをリネームする。<br>
リネーム先にファイルが存在していた場合はリネームをスキップする。
@param hdfs ファイルシステム
@param targetTmpPath 前処理対象ファイルパス
@param tmpSuffix 一時ファイル名称パターン
|
[
"前処理対象ファイルをリネームする。<br",
">",
"リネーム先にファイルが存在していた場合はリネームをスキップする。"
] |
train
|
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/bolt/hdfs/HdfsPreProcessor.java#L120-L157
|
apache/incubator-gobblin
|
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
|
HiveMetaStoreBasedRegister.ensureHiveDbExistence
|
private boolean ensureHiveDbExistence(String hiveDbName, IMetaStoreClient client) throws IOException {
"""
If databse existed on Hive side will return false;
Or will create the table thru. RPC and return retVal from remote MetaStore.
@param hiveDbName is the hive databases to be checked for existence
"""
try (AutoCloseableLock lock = this.locks.getDbLock(hiveDbName)) {
Database db = new Database();
db.setName(hiveDbName);
try {
try (Timer.Context context = this.metricContext.timer(GET_HIVE_DATABASE).time()) {
client.getDatabase(db.getName());
}
return false;
} catch (NoSuchObjectException nsoe) {
// proceed with create
} catch (TException te) {
throw new IOException(te);
}
Preconditions.checkState(this.hiveDbRootDir.isPresent(),
"Missing required property " + HiveRegProps.HIVE_DB_ROOT_DIR);
db.setLocationUri(new Path(this.hiveDbRootDir.get(), hiveDbName + HIVE_DB_EXTENSION).toString());
try {
try (Timer.Context context = this.metricContext.timer(CREATE_HIVE_DATABASE).time()) {
client.createDatabase(db);
}
log.info("Created database " + hiveDbName);
HiveMetaStoreEventHelper.submitSuccessfulDBCreation(this.eventSubmitter, hiveDbName);
return true;
} catch (AlreadyExistsException e) {
return false;
} catch (TException e) {
HiveMetaStoreEventHelper.submitFailedDBCreation(this.eventSubmitter, hiveDbName, e);
throw new IOException("Unable to create Hive database " + hiveDbName, e);
}
}
}
|
java
|
private boolean ensureHiveDbExistence(String hiveDbName, IMetaStoreClient client) throws IOException{
try (AutoCloseableLock lock = this.locks.getDbLock(hiveDbName)) {
Database db = new Database();
db.setName(hiveDbName);
try {
try (Timer.Context context = this.metricContext.timer(GET_HIVE_DATABASE).time()) {
client.getDatabase(db.getName());
}
return false;
} catch (NoSuchObjectException nsoe) {
// proceed with create
} catch (TException te) {
throw new IOException(te);
}
Preconditions.checkState(this.hiveDbRootDir.isPresent(),
"Missing required property " + HiveRegProps.HIVE_DB_ROOT_DIR);
db.setLocationUri(new Path(this.hiveDbRootDir.get(), hiveDbName + HIVE_DB_EXTENSION).toString());
try {
try (Timer.Context context = this.metricContext.timer(CREATE_HIVE_DATABASE).time()) {
client.createDatabase(db);
}
log.info("Created database " + hiveDbName);
HiveMetaStoreEventHelper.submitSuccessfulDBCreation(this.eventSubmitter, hiveDbName);
return true;
} catch (AlreadyExistsException e) {
return false;
} catch (TException e) {
HiveMetaStoreEventHelper.submitFailedDBCreation(this.eventSubmitter, hiveDbName, e);
throw new IOException("Unable to create Hive database " + hiveDbName, e);
}
}
}
|
[
"private",
"boolean",
"ensureHiveDbExistence",
"(",
"String",
"hiveDbName",
",",
"IMetaStoreClient",
"client",
")",
"throws",
"IOException",
"{",
"try",
"(",
"AutoCloseableLock",
"lock",
"=",
"this",
".",
"locks",
".",
"getDbLock",
"(",
"hiveDbName",
")",
")",
"{",
"Database",
"db",
"=",
"new",
"Database",
"(",
")",
";",
"db",
".",
"setName",
"(",
"hiveDbName",
")",
";",
"try",
"{",
"try",
"(",
"Timer",
".",
"Context",
"context",
"=",
"this",
".",
"metricContext",
".",
"timer",
"(",
"GET_HIVE_DATABASE",
")",
".",
"time",
"(",
")",
")",
"{",
"client",
".",
"getDatabase",
"(",
"db",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"NoSuchObjectException",
"nsoe",
")",
"{",
"// proceed with create",
"}",
"catch",
"(",
"TException",
"te",
")",
"{",
"throw",
"new",
"IOException",
"(",
"te",
")",
";",
"}",
"Preconditions",
".",
"checkState",
"(",
"this",
".",
"hiveDbRootDir",
".",
"isPresent",
"(",
")",
",",
"\"Missing required property \"",
"+",
"HiveRegProps",
".",
"HIVE_DB_ROOT_DIR",
")",
";",
"db",
".",
"setLocationUri",
"(",
"new",
"Path",
"(",
"this",
".",
"hiveDbRootDir",
".",
"get",
"(",
")",
",",
"hiveDbName",
"+",
"HIVE_DB_EXTENSION",
")",
".",
"toString",
"(",
")",
")",
";",
"try",
"{",
"try",
"(",
"Timer",
".",
"Context",
"context",
"=",
"this",
".",
"metricContext",
".",
"timer",
"(",
"CREATE_HIVE_DATABASE",
")",
".",
"time",
"(",
")",
")",
"{",
"client",
".",
"createDatabase",
"(",
"db",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"Created database \"",
"+",
"hiveDbName",
")",
";",
"HiveMetaStoreEventHelper",
".",
"submitSuccessfulDBCreation",
"(",
"this",
".",
"eventSubmitter",
",",
"hiveDbName",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"AlreadyExistsException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"TException",
"e",
")",
"{",
"HiveMetaStoreEventHelper",
".",
"submitFailedDBCreation",
"(",
"this",
".",
"eventSubmitter",
",",
"hiveDbName",
",",
"e",
")",
";",
"throw",
"new",
"IOException",
"(",
"\"Unable to create Hive database \"",
"+",
"hiveDbName",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
If databse existed on Hive side will return false;
Or will create the table thru. RPC and return retVal from remote MetaStore.
@param hiveDbName is the hive databases to be checked for existence
|
[
"If",
"databse",
"existed",
"on",
"Hive",
"side",
"will",
"return",
"false",
";",
"Or",
"will",
"create",
"the",
"table",
"thru",
".",
"RPC",
"and",
"return",
"retVal",
"from",
"remote",
"MetaStore",
"."
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java#L217-L251
|
gallandarakhneorg/afc
|
core/text/src/main/java/org/arakhne/afc/text/TextUtil.java
|
TextUtil.removeAccents
|
@Pure
public static String removeAccents(String text) {
"""
Remove the accents inside the specified string.
@param text is the string into which the accents must be removed.
@return the given string without the accents
"""
final Map<Character, String> map = getAccentTranslationTable();
if ((map == null) || (map.isEmpty())) {
return text;
}
return removeAccents(text, map);
}
|
java
|
@Pure
public static String removeAccents(String text) {
final Map<Character, String> map = getAccentTranslationTable();
if ((map == null) || (map.isEmpty())) {
return text;
}
return removeAccents(text, map);
}
|
[
"@",
"Pure",
"public",
"static",
"String",
"removeAccents",
"(",
"String",
"text",
")",
"{",
"final",
"Map",
"<",
"Character",
",",
"String",
">",
"map",
"=",
"getAccentTranslationTable",
"(",
")",
";",
"if",
"(",
"(",
"map",
"==",
"null",
")",
"||",
"(",
"map",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"return",
"text",
";",
"}",
"return",
"removeAccents",
"(",
"text",
",",
"map",
")",
";",
"}"
] |
Remove the accents inside the specified string.
@param text is the string into which the accents must be removed.
@return the given string without the accents
|
[
"Remove",
"the",
"accents",
"inside",
"the",
"specified",
"string",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L563-L570
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/metadata/MatchingStrategy.java
|
MatchingStrategy.performMatch
|
public MatchResponse performMatch(SecurityConstraintCollection securityConstraintCollection, String resourceName, String method) {
"""
Common iteration to get the best constraint match response from the security constraints.
<pre>
To get the aggregated match response,
1. For each security constraint,
1a. Ask security constraint for its match response for the resource access.
1b. Optionally set the default match response of the aggregate after receiving a response for a security constraint.
1c. Aggregate the responses. See {@link com.ibm.ws.webcontainer.security.metadata.MatchResponse#aggregateResponse(ResponseAggregate)}.
2. Finally, select from the aggregate the response.
</pre>
@param securityConstraintCollection the security constraints to iterate through.
@param resourceName the resource name.
@param method the HTTP method.
@return the match response.
"""
MatchResponse currentResponse = null;
ResponseAggregate responseAggregate = createResponseAggregate();
for (SecurityConstraint securityConstraint : securityConstraintCollection.getSecurityConstraints()) {
currentResponse = getMatchResponse(securityConstraint, resourceName, method);
optionallySetAggregateResponseDefault(currentResponse, responseAggregate);
if (isMatch(currentResponse)) {
responseAggregate = currentResponse.aggregateResponse(responseAggregate);
}
}
return responseAggregate.selectMatchResponse();
}
|
java
|
public MatchResponse performMatch(SecurityConstraintCollection securityConstraintCollection, String resourceName, String method) {
MatchResponse currentResponse = null;
ResponseAggregate responseAggregate = createResponseAggregate();
for (SecurityConstraint securityConstraint : securityConstraintCollection.getSecurityConstraints()) {
currentResponse = getMatchResponse(securityConstraint, resourceName, method);
optionallySetAggregateResponseDefault(currentResponse, responseAggregate);
if (isMatch(currentResponse)) {
responseAggregate = currentResponse.aggregateResponse(responseAggregate);
}
}
return responseAggregate.selectMatchResponse();
}
|
[
"public",
"MatchResponse",
"performMatch",
"(",
"SecurityConstraintCollection",
"securityConstraintCollection",
",",
"String",
"resourceName",
",",
"String",
"method",
")",
"{",
"MatchResponse",
"currentResponse",
"=",
"null",
";",
"ResponseAggregate",
"responseAggregate",
"=",
"createResponseAggregate",
"(",
")",
";",
"for",
"(",
"SecurityConstraint",
"securityConstraint",
":",
"securityConstraintCollection",
".",
"getSecurityConstraints",
"(",
")",
")",
"{",
"currentResponse",
"=",
"getMatchResponse",
"(",
"securityConstraint",
",",
"resourceName",
",",
"method",
")",
";",
"optionallySetAggregateResponseDefault",
"(",
"currentResponse",
",",
"responseAggregate",
")",
";",
"if",
"(",
"isMatch",
"(",
"currentResponse",
")",
")",
"{",
"responseAggregate",
"=",
"currentResponse",
".",
"aggregateResponse",
"(",
"responseAggregate",
")",
";",
"}",
"}",
"return",
"responseAggregate",
".",
"selectMatchResponse",
"(",
")",
";",
"}"
] |
Common iteration to get the best constraint match response from the security constraints.
<pre>
To get the aggregated match response,
1. For each security constraint,
1a. Ask security constraint for its match response for the resource access.
1b. Optionally set the default match response of the aggregate after receiving a response for a security constraint.
1c. Aggregate the responses. See {@link com.ibm.ws.webcontainer.security.metadata.MatchResponse#aggregateResponse(ResponseAggregate)}.
2. Finally, select from the aggregate the response.
</pre>
@param securityConstraintCollection the security constraints to iterate through.
@param resourceName the resource name.
@param method the HTTP method.
@return the match response.
|
[
"Common",
"iteration",
"to",
"get",
"the",
"best",
"constraint",
"match",
"response",
"from",
"the",
"security",
"constraints",
".",
"<pre",
">",
"To",
"get",
"the",
"aggregated",
"match",
"response"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/metadata/MatchingStrategy.java#L99-L113
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/HubVirtualNetworkConnectionsInner.java
|
HubVirtualNetworkConnectionsInner.getAsync
|
public Observable<HubVirtualNetworkConnectionInner> getAsync(String resourceGroupName, String virtualHubName, String connectionName) {
"""
Retrieves the details of a HubVirtualNetworkConnection.
@param resourceGroupName The resource group name of the VirtualHub.
@param virtualHubName The name of the VirtualHub.
@param connectionName The name of the vpn connection.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the HubVirtualNetworkConnectionInner object
"""
return getWithServiceResponseAsync(resourceGroupName, virtualHubName, connectionName).map(new Func1<ServiceResponse<HubVirtualNetworkConnectionInner>, HubVirtualNetworkConnectionInner>() {
@Override
public HubVirtualNetworkConnectionInner call(ServiceResponse<HubVirtualNetworkConnectionInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<HubVirtualNetworkConnectionInner> getAsync(String resourceGroupName, String virtualHubName, String connectionName) {
return getWithServiceResponseAsync(resourceGroupName, virtualHubName, connectionName).map(new Func1<ServiceResponse<HubVirtualNetworkConnectionInner>, HubVirtualNetworkConnectionInner>() {
@Override
public HubVirtualNetworkConnectionInner call(ServiceResponse<HubVirtualNetworkConnectionInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"HubVirtualNetworkConnectionInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualHubName",
",",
"String",
"connectionName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualHubName",
",",
"connectionName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"HubVirtualNetworkConnectionInner",
">",
",",
"HubVirtualNetworkConnectionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"HubVirtualNetworkConnectionInner",
"call",
"(",
"ServiceResponse",
"<",
"HubVirtualNetworkConnectionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Retrieves the details of a HubVirtualNetworkConnection.
@param resourceGroupName The resource group name of the VirtualHub.
@param virtualHubName The name of the VirtualHub.
@param connectionName The name of the vpn connection.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the HubVirtualNetworkConnectionInner object
|
[
"Retrieves",
"the",
"details",
"of",
"a",
"HubVirtualNetworkConnection",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/HubVirtualNetworkConnectionsInner.java#L112-L119
|
apache/flink
|
flink-core/src/main/java/org/apache/flink/api/common/operators/Operator.java
|
Operator.setResources
|
@PublicEvolving
public void setResources(ResourceSpec minResources, ResourceSpec preferredResources) {
"""
Sets the minimum and preferred resources for this contract instance. The resource denotes
how many memories and cpu cores of the user function will be consumed during the execution.
@param minResources The minimum resource of this operator.
@param preferredResources The preferred resource of this operator.
"""
this.minResources = minResources;
this.preferredResources = preferredResources;
}
|
java
|
@PublicEvolving
public void setResources(ResourceSpec minResources, ResourceSpec preferredResources) {
this.minResources = minResources;
this.preferredResources = preferredResources;
}
|
[
"@",
"PublicEvolving",
"public",
"void",
"setResources",
"(",
"ResourceSpec",
"minResources",
",",
"ResourceSpec",
"preferredResources",
")",
"{",
"this",
".",
"minResources",
"=",
"minResources",
";",
"this",
".",
"preferredResources",
"=",
"preferredResources",
";",
"}"
] |
Sets the minimum and preferred resources for this contract instance. The resource denotes
how many memories and cpu cores of the user function will be consumed during the execution.
@param minResources The minimum resource of this operator.
@param preferredResources The preferred resource of this operator.
|
[
"Sets",
"the",
"minimum",
"and",
"preferred",
"resources",
"for",
"this",
"contract",
"instance",
".",
"The",
"resource",
"denotes",
"how",
"many",
"memories",
"and",
"cpu",
"cores",
"of",
"the",
"user",
"function",
"will",
"be",
"consumed",
"during",
"the",
"execution",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/operators/Operator.java#L221-L225
|
datastax/java-driver
|
core/src/main/java/com/datastax/oss/driver/internal/core/metadata/token/ByteOrderedTokenRange.java
|
ByteOrderedTokenRange.toBytes
|
protected ByteBuffer toBytes(BigInteger value, int significantBytes) {
"""
expected result is 0x0001 (a simple conversion would produce 0x01).
"""
byte[] rawBytes = value.toByteArray();
byte[] result;
if (rawBytes.length == significantBytes) {
result = rawBytes;
} else {
result = new byte[significantBytes];
int start, length;
if (rawBytes[0] == 0) {
// that's a sign byte, ignore (it can cause rawBytes.length == significantBytes + 1)
start = 1;
length = rawBytes.length - 1;
} else {
start = 0;
length = rawBytes.length;
}
System.arraycopy(rawBytes, start, result, significantBytes - length, length);
}
return ByteBuffer.wrap(result);
}
|
java
|
protected ByteBuffer toBytes(BigInteger value, int significantBytes) {
byte[] rawBytes = value.toByteArray();
byte[] result;
if (rawBytes.length == significantBytes) {
result = rawBytes;
} else {
result = new byte[significantBytes];
int start, length;
if (rawBytes[0] == 0) {
// that's a sign byte, ignore (it can cause rawBytes.length == significantBytes + 1)
start = 1;
length = rawBytes.length - 1;
} else {
start = 0;
length = rawBytes.length;
}
System.arraycopy(rawBytes, start, result, significantBytes - length, length);
}
return ByteBuffer.wrap(result);
}
|
[
"protected",
"ByteBuffer",
"toBytes",
"(",
"BigInteger",
"value",
",",
"int",
"significantBytes",
")",
"{",
"byte",
"[",
"]",
"rawBytes",
"=",
"value",
".",
"toByteArray",
"(",
")",
";",
"byte",
"[",
"]",
"result",
";",
"if",
"(",
"rawBytes",
".",
"length",
"==",
"significantBytes",
")",
"{",
"result",
"=",
"rawBytes",
";",
"}",
"else",
"{",
"result",
"=",
"new",
"byte",
"[",
"significantBytes",
"]",
";",
"int",
"start",
",",
"length",
";",
"if",
"(",
"rawBytes",
"[",
"0",
"]",
"==",
"0",
")",
"{",
"// that's a sign byte, ignore (it can cause rawBytes.length == significantBytes + 1)",
"start",
"=",
"1",
";",
"length",
"=",
"rawBytes",
".",
"length",
"-",
"1",
";",
"}",
"else",
"{",
"start",
"=",
"0",
";",
"length",
"=",
"rawBytes",
".",
"length",
";",
"}",
"System",
".",
"arraycopy",
"(",
"rawBytes",
",",
"start",
",",
"result",
",",
"significantBytes",
"-",
"length",
",",
"length",
")",
";",
"}",
"return",
"ByteBuffer",
".",
"wrap",
"(",
"result",
")",
";",
"}"
] |
expected result is 0x0001 (a simple conversion would produce 0x01).
|
[
"expected",
"result",
"is",
"0x0001",
"(",
"a",
"simple",
"conversion",
"would",
"produce",
"0x01",
")",
"."
] |
train
|
https://github.com/datastax/java-driver/blob/612a63f2525618e2020e86c9ad75ab37adba6132/core/src/main/java/com/datastax/oss/driver/internal/core/metadata/token/ByteOrderedTokenRange.java#L123-L142
|
line/armeria
|
core/src/main/java/com/linecorp/armeria/common/util/EventLoopGroups.java
|
EventLoopGroups.newEventLoopGroup
|
public static EventLoopGroup newEventLoopGroup(int numThreads, ThreadFactory threadFactory) {
"""
Returns a newly-created {@link EventLoopGroup}.
@param numThreads the number of event loop threads
@param threadFactory the factory of event loop threads
"""
checkArgument(numThreads > 0, "numThreads: %s (expected: > 0)", numThreads);
requireNonNull(threadFactory, "threadFactory");
final TransportType type = TransportType.detectTransportType();
return type.newEventLoopGroup(numThreads, unused -> threadFactory);
}
|
java
|
public static EventLoopGroup newEventLoopGroup(int numThreads, ThreadFactory threadFactory) {
checkArgument(numThreads > 0, "numThreads: %s (expected: > 0)", numThreads);
requireNonNull(threadFactory, "threadFactory");
final TransportType type = TransportType.detectTransportType();
return type.newEventLoopGroup(numThreads, unused -> threadFactory);
}
|
[
"public",
"static",
"EventLoopGroup",
"newEventLoopGroup",
"(",
"int",
"numThreads",
",",
"ThreadFactory",
"threadFactory",
")",
"{",
"checkArgument",
"(",
"numThreads",
">",
"0",
",",
"\"numThreads: %s (expected: > 0)\"",
",",
"numThreads",
")",
";",
"requireNonNull",
"(",
"threadFactory",
",",
"\"threadFactory\"",
")",
";",
"final",
"TransportType",
"type",
"=",
"TransportType",
".",
"detectTransportType",
"(",
")",
";",
"return",
"type",
".",
"newEventLoopGroup",
"(",
"numThreads",
",",
"unused",
"->",
"threadFactory",
")",
";",
"}"
] |
Returns a newly-created {@link EventLoopGroup}.
@param numThreads the number of event loop threads
@param threadFactory the factory of event loop threads
|
[
"Returns",
"a",
"newly",
"-",
"created",
"{",
"@link",
"EventLoopGroup",
"}",
"."
] |
train
|
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/common/util/EventLoopGroups.java#L101-L108
|
Talend/tesb-rt-se
|
job/controller/src/main/java/org/talend/esb/job/controller/internal/Configuration.java
|
Configuration.setProperties
|
public void setProperties(Dictionary<?, ?> properties) throws ConfigurationException {
"""
Back this <code>Configuration</code> by the given properties from ConfigurationAdmin.
@param properties the properties from ConfigurationAdmin, may be <code>null</code>.
@throws ConfigurationException thrown if the property values are not of type String
"""
List<String> newArgumentList = new ArrayList<String>();
if (properties != null) {
for (Enumeration<?> keysEnum = properties.keys(); keysEnum.hasMoreElements();) {
String key = (String) keysEnum.nextElement();
Object val = properties.get(key);
if (val instanceof String) {
String value = (String) val;
if(PropertyValueEncryptionUtils.isEncryptedValue(value)) {
StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor();
EnvironmentStringPBEConfig env = new EnvironmentStringPBEConfig();
env.setProvider(new BouncyCastleProvider());
env.setProviderName(PROVIDER_NAME);
env.setAlgorithm(ALGORITHM);
env.setPasswordEnvName(PASSWORD_ENV_NAME);
enc.setConfig(env);
val = PropertyValueEncryptionUtils.decrypt(value, enc);
}
String strval = convertArgument(key, (String)val);
if (strval != null) {
newArgumentList.add(strval);
}
} else {
throw new ConfigurationException(key, "Value is not of type String.");
}
}
}
argumentList = newArgumentList;
configAvailable.countDown();
}
|
java
|
public void setProperties(Dictionary<?, ?> properties) throws ConfigurationException {
List<String> newArgumentList = new ArrayList<String>();
if (properties != null) {
for (Enumeration<?> keysEnum = properties.keys(); keysEnum.hasMoreElements();) {
String key = (String) keysEnum.nextElement();
Object val = properties.get(key);
if (val instanceof String) {
String value = (String) val;
if(PropertyValueEncryptionUtils.isEncryptedValue(value)) {
StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor();
EnvironmentStringPBEConfig env = new EnvironmentStringPBEConfig();
env.setProvider(new BouncyCastleProvider());
env.setProviderName(PROVIDER_NAME);
env.setAlgorithm(ALGORITHM);
env.setPasswordEnvName(PASSWORD_ENV_NAME);
enc.setConfig(env);
val = PropertyValueEncryptionUtils.decrypt(value, enc);
}
String strval = convertArgument(key, (String)val);
if (strval != null) {
newArgumentList.add(strval);
}
} else {
throw new ConfigurationException(key, "Value is not of type String.");
}
}
}
argumentList = newArgumentList;
configAvailable.countDown();
}
|
[
"public",
"void",
"setProperties",
"(",
"Dictionary",
"<",
"?",
",",
"?",
">",
"properties",
")",
"throws",
"ConfigurationException",
"{",
"List",
"<",
"String",
">",
"newArgumentList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"properties",
"!=",
"null",
")",
"{",
"for",
"(",
"Enumeration",
"<",
"?",
">",
"keysEnum",
"=",
"properties",
".",
"keys",
"(",
")",
";",
"keysEnum",
".",
"hasMoreElements",
"(",
")",
";",
")",
"{",
"String",
"key",
"=",
"(",
"String",
")",
"keysEnum",
".",
"nextElement",
"(",
")",
";",
"Object",
"val",
"=",
"properties",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"val",
"instanceof",
"String",
")",
"{",
"String",
"value",
"=",
"(",
"String",
")",
"val",
";",
"if",
"(",
"PropertyValueEncryptionUtils",
".",
"isEncryptedValue",
"(",
"value",
")",
")",
"{",
"StandardPBEStringEncryptor",
"enc",
"=",
"new",
"StandardPBEStringEncryptor",
"(",
")",
";",
"EnvironmentStringPBEConfig",
"env",
"=",
"new",
"EnvironmentStringPBEConfig",
"(",
")",
";",
"env",
".",
"setProvider",
"(",
"new",
"BouncyCastleProvider",
"(",
")",
")",
";",
"env",
".",
"setProviderName",
"(",
"PROVIDER_NAME",
")",
";",
"env",
".",
"setAlgorithm",
"(",
"ALGORITHM",
")",
";",
"env",
".",
"setPasswordEnvName",
"(",
"PASSWORD_ENV_NAME",
")",
";",
"enc",
".",
"setConfig",
"(",
"env",
")",
";",
"val",
"=",
"PropertyValueEncryptionUtils",
".",
"decrypt",
"(",
"value",
",",
"enc",
")",
";",
"}",
"String",
"strval",
"=",
"convertArgument",
"(",
"key",
",",
"(",
"String",
")",
"val",
")",
";",
"if",
"(",
"strval",
"!=",
"null",
")",
"{",
"newArgumentList",
".",
"add",
"(",
"strval",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"key",
",",
"\"Value is not of type String.\"",
")",
";",
"}",
"}",
"}",
"argumentList",
"=",
"newArgumentList",
";",
"configAvailable",
".",
"countDown",
"(",
")",
";",
"}"
] |
Back this <code>Configuration</code> by the given properties from ConfigurationAdmin.
@param properties the properties from ConfigurationAdmin, may be <code>null</code>.
@throws ConfigurationException thrown if the property values are not of type String
|
[
"Back",
"this",
"<code",
">",
"Configuration<",
"/",
"code",
">",
"by",
"the",
"given",
"properties",
"from",
"ConfigurationAdmin",
"."
] |
train
|
https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/job/controller/src/main/java/org/talend/esb/job/controller/internal/Configuration.java#L128-L158
|
livetribe/livetribe-slp
|
osgi/bundle/src/main/java/org/livetribe/slp/osgi/ByServicePropertiesServiceTracker.java
|
ByServicePropertiesServiceTracker.removedService
|
@Override
public void removedService(ServiceReference reference, Object service) {
"""
Deregister the instance of {@link ServiceInfo} from the {@link ServiceAgent},
effectively unregistering the SLP service URL.
@param reference The reference to the OSGi service that implicitly registered the SLP service URL.
@param service The instance of {@link ServiceInfo} to deregister.
@see org.osgi.util.tracker.ServiceTracker#removedService(ServiceReference, Object)
@see org.livetribe.slp.sa.ServiceAgent#deregister(org.livetribe.slp.ServiceURL, String)
"""
LOGGER.entering(CLASS_NAME, "removedService", new Object[]{reference, service});
context.ungetService(reference);
ServiceInfo serviceInfo = (ServiceInfo)service;
serviceAgent.deregister(serviceInfo.getServiceURL(), serviceInfo.getLanguage());
LOGGER.exiting(CLASS_NAME, "removedService");
}
|
java
|
@Override
public void removedService(ServiceReference reference, Object service)
{
LOGGER.entering(CLASS_NAME, "removedService", new Object[]{reference, service});
context.ungetService(reference);
ServiceInfo serviceInfo = (ServiceInfo)service;
serviceAgent.deregister(serviceInfo.getServiceURL(), serviceInfo.getLanguage());
LOGGER.exiting(CLASS_NAME, "removedService");
}
|
[
"@",
"Override",
"public",
"void",
"removedService",
"(",
"ServiceReference",
"reference",
",",
"Object",
"service",
")",
"{",
"LOGGER",
".",
"entering",
"(",
"CLASS_NAME",
",",
"\"removedService\"",
",",
"new",
"Object",
"[",
"]",
"{",
"reference",
",",
"service",
"}",
")",
";",
"context",
".",
"ungetService",
"(",
"reference",
")",
";",
"ServiceInfo",
"serviceInfo",
"=",
"(",
"ServiceInfo",
")",
"service",
";",
"serviceAgent",
".",
"deregister",
"(",
"serviceInfo",
".",
"getServiceURL",
"(",
")",
",",
"serviceInfo",
".",
"getLanguage",
"(",
")",
")",
";",
"LOGGER",
".",
"exiting",
"(",
"CLASS_NAME",
",",
"\"removedService\"",
")",
";",
"}"
] |
Deregister the instance of {@link ServiceInfo} from the {@link ServiceAgent},
effectively unregistering the SLP service URL.
@param reference The reference to the OSGi service that implicitly registered the SLP service URL.
@param service The instance of {@link ServiceInfo} to deregister.
@see org.osgi.util.tracker.ServiceTracker#removedService(ServiceReference, Object)
@see org.livetribe.slp.sa.ServiceAgent#deregister(org.livetribe.slp.ServiceURL, String)
|
[
"Deregister",
"the",
"instance",
"of",
"{",
"@link",
"ServiceInfo",
"}",
"from",
"the",
"{",
"@link",
"ServiceAgent",
"}",
"effectively",
"unregistering",
"the",
"SLP",
"service",
"URL",
"."
] |
train
|
https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/osgi/bundle/src/main/java/org/livetribe/slp/osgi/ByServicePropertiesServiceTracker.java#L204-L216
|
looly/hutool
|
hutool-db/src/main/java/cn/hutool/db/AbstractDb.java
|
AbstractDb.queryString
|
public String queryString(String sql, Object... params) throws SQLException {
"""
查询单条单个字段记录,并将其转换为String
@param sql 查询语句
@param params 参数
@return 结果对象
@throws SQLException SQL执行异常
"""
return query(sql, new StringHandler(), params);
}
|
java
|
public String queryString(String sql, Object... params) throws SQLException {
return query(sql, new StringHandler(), params);
}
|
[
"public",
"String",
"queryString",
"(",
"String",
"sql",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
"{",
"return",
"query",
"(",
"sql",
",",
"new",
"StringHandler",
"(",
")",
",",
"params",
")",
";",
"}"
] |
查询单条单个字段记录,并将其转换为String
@param sql 查询语句
@param params 参数
@return 结果对象
@throws SQLException SQL执行异常
|
[
"查询单条单个字段记录",
"并将其转换为String"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java#L130-L132
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/errors/ApplicationException.java
|
ApplicationException.wrapException
|
public static ApplicationException wrapException(ApplicationException error, Throwable cause) {
"""
Wraps another exception into specified application exception object.
If original exception is of ApplicationException type it is returned without
changes. Otherwise the original error is set as a cause to specified
ApplicationException object.
@param error an ApplicationException object to wrap the cause
@param cause an original error object
@return an original or newly created ApplicationException
"""
if (cause instanceof ApplicationException)
return (ApplicationException) cause;
error.withCause(cause);
return error;
}
|
java
|
public static ApplicationException wrapException(ApplicationException error, Throwable cause) {
if (cause instanceof ApplicationException)
return (ApplicationException) cause;
error.withCause(cause);
return error;
}
|
[
"public",
"static",
"ApplicationException",
"wrapException",
"(",
"ApplicationException",
"error",
",",
"Throwable",
"cause",
")",
"{",
"if",
"(",
"cause",
"instanceof",
"ApplicationException",
")",
"return",
"(",
"ApplicationException",
")",
"cause",
";",
"error",
".",
"withCause",
"(",
"cause",
")",
";",
"return",
"error",
";",
"}"
] |
Wraps another exception into specified application exception object.
If original exception is of ApplicationException type it is returned without
changes. Otherwise the original error is set as a cause to specified
ApplicationException object.
@param error an ApplicationException object to wrap the cause
@param cause an original error object
@return an original or newly created ApplicationException
|
[
"Wraps",
"another",
"exception",
"into",
"specified",
"application",
"exception",
"object",
"."
] |
train
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ApplicationException.java#L320-L327
|
Azure/azure-sdk-for-java
|
batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java
|
ComputeNodesImpl.disableScheduling
|
public void disableScheduling(String poolId, String nodeId, DisableComputeNodeSchedulingOption nodeDisableSchedulingOption, ComputeNodeDisableSchedulingOptions computeNodeDisableSchedulingOptions) {
"""
Disables task scheduling on the specified compute node.
You can disable task scheduling on a node only if its current scheduling state is enabled.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node on which you want to disable task scheduling.
@param nodeDisableSchedulingOption What to do with currently running tasks when disabling task scheduling on the compute node. The default value is requeue. Possible values include: 'requeue', 'terminate', 'taskCompletion'
@param computeNodeDisableSchedulingOptions Additional parameters for the operation
@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
"""
disableSchedulingWithServiceResponseAsync(poolId, nodeId, nodeDisableSchedulingOption, computeNodeDisableSchedulingOptions).toBlocking().single().body();
}
|
java
|
public void disableScheduling(String poolId, String nodeId, DisableComputeNodeSchedulingOption nodeDisableSchedulingOption, ComputeNodeDisableSchedulingOptions computeNodeDisableSchedulingOptions) {
disableSchedulingWithServiceResponseAsync(poolId, nodeId, nodeDisableSchedulingOption, computeNodeDisableSchedulingOptions).toBlocking().single().body();
}
|
[
"public",
"void",
"disableScheduling",
"(",
"String",
"poolId",
",",
"String",
"nodeId",
",",
"DisableComputeNodeSchedulingOption",
"nodeDisableSchedulingOption",
",",
"ComputeNodeDisableSchedulingOptions",
"computeNodeDisableSchedulingOptions",
")",
"{",
"disableSchedulingWithServiceResponseAsync",
"(",
"poolId",
",",
"nodeId",
",",
"nodeDisableSchedulingOption",
",",
"computeNodeDisableSchedulingOptions",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Disables task scheduling on the specified compute node.
You can disable task scheduling on a node only if its current scheduling state is enabled.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node on which you want to disable task scheduling.
@param nodeDisableSchedulingOption What to do with currently running tasks when disabling task scheduling on the compute node. The default value is requeue. Possible values include: 'requeue', 'terminate', 'taskCompletion'
@param computeNodeDisableSchedulingOptions Additional parameters for the operation
@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
|
[
"Disables",
"task",
"scheduling",
"on",
"the",
"specified",
"compute",
"node",
".",
"You",
"can",
"disable",
"task",
"scheduling",
"on",
"a",
"node",
"only",
"if",
"its",
"current",
"scheduling",
"state",
"is",
"enabled",
"."
] |
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#L1599-L1601
|
mapsforge/mapsforge
|
mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/TileDependencies.java
|
TileDependencies.removeTileData
|
void removeTileData(Tile from, Tile to) {
"""
Cache maintenance operation to remove data for a tile from the cache. This should be excuted
if a tile is removed from the TileCache and will be drawn again.
@param from
"""
if (overlapData.containsKey(from)) {
overlapData.get(from).remove(to);
}
}
|
java
|
void removeTileData(Tile from, Tile to) {
if (overlapData.containsKey(from)) {
overlapData.get(from).remove(to);
}
}
|
[
"void",
"removeTileData",
"(",
"Tile",
"from",
",",
"Tile",
"to",
")",
"{",
"if",
"(",
"overlapData",
".",
"containsKey",
"(",
"from",
")",
")",
"{",
"overlapData",
".",
"get",
"(",
"from",
")",
".",
"remove",
"(",
"to",
")",
";",
"}",
"}"
] |
Cache maintenance operation to remove data for a tile from the cache. This should be excuted
if a tile is removed from the TileCache and will be drawn again.
@param from
|
[
"Cache",
"maintenance",
"operation",
"to",
"remove",
"data",
"for",
"a",
"tile",
"from",
"the",
"cache",
".",
"This",
"should",
"be",
"excuted",
"if",
"a",
"tile",
"is",
"removed",
"from",
"the",
"TileCache",
"and",
"will",
"be",
"drawn",
"again",
"."
] |
train
|
https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/TileDependencies.java#L81-L86
|
gallandarakhneorg/afc
|
core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java
|
FileSystem.removeExtension
|
@Pure
public static File removeExtension(File filename) {
"""
Remove the extension from the specified filename.
@param filename is the filename to parse.
@return the filename without the extension.
"""
if (filename == null) {
return null;
}
final File dir = filename.getParentFile();
final String name = filename.getName();
final int idx = name.lastIndexOf(getFileExtensionCharacter());
if (idx < 0) {
return filename;
}
return new File(dir, name.substring(0, idx));
}
|
java
|
@Pure
public static File removeExtension(File filename) {
if (filename == null) {
return null;
}
final File dir = filename.getParentFile();
final String name = filename.getName();
final int idx = name.lastIndexOf(getFileExtensionCharacter());
if (idx < 0) {
return filename;
}
return new File(dir, name.substring(0, idx));
}
|
[
"@",
"Pure",
"public",
"static",
"File",
"removeExtension",
"(",
"File",
"filename",
")",
"{",
"if",
"(",
"filename",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"File",
"dir",
"=",
"filename",
".",
"getParentFile",
"(",
")",
";",
"final",
"String",
"name",
"=",
"filename",
".",
"getName",
"(",
")",
";",
"final",
"int",
"idx",
"=",
"name",
".",
"lastIndexOf",
"(",
"getFileExtensionCharacter",
"(",
")",
")",
";",
"if",
"(",
"idx",
"<",
"0",
")",
"{",
"return",
"filename",
";",
"}",
"return",
"new",
"File",
"(",
"dir",
",",
"name",
".",
"substring",
"(",
"0",
",",
"idx",
")",
")",
";",
"}"
] |
Remove the extension from the specified filename.
@param filename is the filename to parse.
@return the filename without the extension.
|
[
"Remove",
"the",
"extension",
"from",
"the",
"specified",
"filename",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/FileSystem.java#L1221-L1233
|
alkacon/opencms-core
|
src-gwt/org/opencms/gwt/client/property/CmsSimplePropertyEditorHandler.java
|
CmsSimplePropertyEditorHandler.saveProperties
|
protected void saveProperties(CmsPropertyChangeSet changes, AsyncCallback<Void> callback) {
"""
Save properties.<p>
@param changes the property changes
@param callback the result callback
"""
if (m_propertySaver != null) {
m_propertySaver.saveProperties(changes, callback);
} else {
CmsCoreProvider.getVfsService().saveProperties(changes, callback);
}
}
|
java
|
protected void saveProperties(CmsPropertyChangeSet changes, AsyncCallback<Void> callback) {
if (m_propertySaver != null) {
m_propertySaver.saveProperties(changes, callback);
} else {
CmsCoreProvider.getVfsService().saveProperties(changes, callback);
}
}
|
[
"protected",
"void",
"saveProperties",
"(",
"CmsPropertyChangeSet",
"changes",
",",
"AsyncCallback",
"<",
"Void",
">",
"callback",
")",
"{",
"if",
"(",
"m_propertySaver",
"!=",
"null",
")",
"{",
"m_propertySaver",
".",
"saveProperties",
"(",
"changes",
",",
"callback",
")",
";",
"}",
"else",
"{",
"CmsCoreProvider",
".",
"getVfsService",
"(",
")",
".",
"saveProperties",
"(",
"changes",
",",
"callback",
")",
";",
"}",
"}"
] |
Save properties.<p>
@param changes the property changes
@param callback the result callback
|
[
"Save",
"properties",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/property/CmsSimplePropertyEditorHandler.java#L331-L338
|
weld/core
|
impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
|
ProxyFactory.addConstructedGuardToMethodBody
|
protected void addConstructedGuardToMethodBody(final ClassMethod classMethod, String className) {
"""
Adds the following code to a delegating method:
<p/>
<code>
if(!this.constructed) return super.thisMethod()
</code>
<p/>
This means that the proxy will not start to delegate to the underlying
bean instance until after the constructor has finished.
"""
if (!useConstructedFlag()) {
return;
}
// now create the conditional
final CodeAttribute cond = classMethod.getCodeAttribute();
cond.aload(0);
cond.getfield(classMethod.getClassFile().getName(), CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR);
// jump if the proxy constructor has finished
BranchEnd jumpMarker = cond.ifne();
// generate the invokespecial call to the super class method
// this is run when the proxy is being constructed
cond.aload(0);
cond.loadMethodParameters();
cond.invokespecial(className, classMethod.getName(), classMethod.getDescriptor());
cond.returnInstruction();
cond.branchEnd(jumpMarker);
}
|
java
|
protected void addConstructedGuardToMethodBody(final ClassMethod classMethod, String className) {
if (!useConstructedFlag()) {
return;
}
// now create the conditional
final CodeAttribute cond = classMethod.getCodeAttribute();
cond.aload(0);
cond.getfield(classMethod.getClassFile().getName(), CONSTRUCTED_FLAG_NAME, BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR);
// jump if the proxy constructor has finished
BranchEnd jumpMarker = cond.ifne();
// generate the invokespecial call to the super class method
// this is run when the proxy is being constructed
cond.aload(0);
cond.loadMethodParameters();
cond.invokespecial(className, classMethod.getName(), classMethod.getDescriptor());
cond.returnInstruction();
cond.branchEnd(jumpMarker);
}
|
[
"protected",
"void",
"addConstructedGuardToMethodBody",
"(",
"final",
"ClassMethod",
"classMethod",
",",
"String",
"className",
")",
"{",
"if",
"(",
"!",
"useConstructedFlag",
"(",
")",
")",
"{",
"return",
";",
"}",
"// now create the conditional",
"final",
"CodeAttribute",
"cond",
"=",
"classMethod",
".",
"getCodeAttribute",
"(",
")",
";",
"cond",
".",
"aload",
"(",
"0",
")",
";",
"cond",
".",
"getfield",
"(",
"classMethod",
".",
"getClassFile",
"(",
")",
".",
"getName",
"(",
")",
",",
"CONSTRUCTED_FLAG_NAME",
",",
"BytecodeUtils",
".",
"BOOLEAN_CLASS_DESCRIPTOR",
")",
";",
"// jump if the proxy constructor has finished",
"BranchEnd",
"jumpMarker",
"=",
"cond",
".",
"ifne",
"(",
")",
";",
"// generate the invokespecial call to the super class method",
"// this is run when the proxy is being constructed",
"cond",
".",
"aload",
"(",
"0",
")",
";",
"cond",
".",
"loadMethodParameters",
"(",
")",
";",
"cond",
".",
"invokespecial",
"(",
"className",
",",
"classMethod",
".",
"getName",
"(",
")",
",",
"classMethod",
".",
"getDescriptor",
"(",
")",
")",
";",
"cond",
".",
"returnInstruction",
"(",
")",
";",
"cond",
".",
"branchEnd",
"(",
"jumpMarker",
")",
";",
"}"
] |
Adds the following code to a delegating method:
<p/>
<code>
if(!this.constructed) return super.thisMethod()
</code>
<p/>
This means that the proxy will not start to delegate to the underlying
bean instance until after the constructor has finished.
|
[
"Adds",
"the",
"following",
"code",
"to",
"a",
"delegating",
"method",
":",
"<p",
"/",
">",
"<code",
">",
"if",
"(",
"!this",
".",
"constructed",
")",
"return",
"super",
".",
"thisMethod",
"()",
"<",
"/",
"code",
">",
"<p",
"/",
">",
"This",
"means",
"that",
"the",
"proxy",
"will",
"not",
"start",
"to",
"delegate",
"to",
"the",
"underlying",
"bean",
"instance",
"until",
"after",
"the",
"constructor",
"has",
"finished",
"."
] |
train
|
https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java#L696-L714
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.