repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/IgnoredNonAffectedServerGroupsUtil.java | IgnoredNonAffectedServerGroupsUtil.ignoreOperation | public boolean ignoreOperation(final Resource domainResource, final Collection<ServerConfigInfo> serverConfigs, final PathAddress pathAddress) {
"""
For the DC to check whether an operation should be ignored on the slave, if the slave is set up to ignore config not relevant to it
@param domainResource the domain root resource
@param serverConfigs the server configs the slave is known to have
@param pathAddress the address of the operation to check if should be ignored or not
"""
if (pathAddress.size() == 0) {
return false;
}
boolean ignore = ignoreResourceInternal(domainResource, serverConfigs, pathAddress);
return ignore;
} | java | public boolean ignoreOperation(final Resource domainResource, final Collection<ServerConfigInfo> serverConfigs, final PathAddress pathAddress) {
if (pathAddress.size() == 0) {
return false;
}
boolean ignore = ignoreResourceInternal(domainResource, serverConfigs, pathAddress);
return ignore;
} | [
"public",
"boolean",
"ignoreOperation",
"(",
"final",
"Resource",
"domainResource",
",",
"final",
"Collection",
"<",
"ServerConfigInfo",
">",
"serverConfigs",
",",
"final",
"PathAddress",
"pathAddress",
")",
"{",
"if",
"(",
"pathAddress",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"boolean",
"ignore",
"=",
"ignoreResourceInternal",
"(",
"domainResource",
",",
"serverConfigs",
",",
"pathAddress",
")",
";",
"return",
"ignore",
";",
"}"
] | For the DC to check whether an operation should be ignored on the slave, if the slave is set up to ignore config not relevant to it
@param domainResource the domain root resource
@param serverConfigs the server configs the slave is known to have
@param pathAddress the address of the operation to check if should be ignored or not | [
"For",
"the",
"DC",
"to",
"check",
"whether",
"an",
"operation",
"should",
"be",
"ignored",
"on",
"the",
"slave",
"if",
"the",
"slave",
"is",
"set",
"up",
"to",
"ignore",
"config",
"not",
"relevant",
"to",
"it"
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/IgnoredNonAffectedServerGroupsUtil.java#L128-L134 |
geomajas/geomajas-project-client-gwt2 | impl/src/main/java/org/geomajas/gwt2/client/service/JsonService.java | JsonService.getDoubleValue | public static Double getDoubleValue(JSONObject jsonObject, String key) throws JSONException {
"""
Get a double value from a {@link JSONObject}.
@param jsonObject The object to get the key value from.
@param key The name of the key to search the value for.
@return Returns the value for the key in the object .
@throws JSONException Thrown in case the key could not be found in the JSON object.
"""
checkArguments(jsonObject, key);
JSONValue value = jsonObject.get(key);
if (value != null && value.isNumber() != null) {
double number = ((JSONNumber) value).doubleValue();
return number;
}
return null;
} | java | public static Double getDoubleValue(JSONObject jsonObject, String key) throws JSONException {
checkArguments(jsonObject, key);
JSONValue value = jsonObject.get(key);
if (value != null && value.isNumber() != null) {
double number = ((JSONNumber) value).doubleValue();
return number;
}
return null;
} | [
"public",
"static",
"Double",
"getDoubleValue",
"(",
"JSONObject",
"jsonObject",
",",
"String",
"key",
")",
"throws",
"JSONException",
"{",
"checkArguments",
"(",
"jsonObject",
",",
"key",
")",
";",
"JSONValue",
"value",
"=",
"jsonObject",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"!=",
"null",
"&&",
"value",
".",
"isNumber",
"(",
")",
"!=",
"null",
")",
"{",
"double",
"number",
"=",
"(",
"(",
"JSONNumber",
")",
"value",
")",
".",
"doubleValue",
"(",
")",
";",
"return",
"number",
";",
"}",
"return",
"null",
";",
"}"
] | Get a double value from a {@link JSONObject}.
@param jsonObject The object to get the key value from.
@param key The name of the key to search the value for.
@return Returns the value for the key in the object .
@throws JSONException Thrown in case the key could not be found in the JSON object. | [
"Get",
"a",
"double",
"value",
"from",
"a",
"{",
"@link",
"JSONObject",
"}",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/impl/src/main/java/org/geomajas/gwt2/client/service/JsonService.java#L277-L285 |
datacleaner/AnalyzerBeans | core/src/main/java/org/eobjects/analyzer/util/SystemProperties.java | SystemProperties.getString | public static String getString(String key, String valueIfNull) {
"""
Gets a system property string, or a replacement value if the property is
null or blank.
@param key
@param valueIfNull
@return
"""
String value = System.getProperty(key);
if (Strings.isNullOrEmpty(value)) {
return valueIfNull;
}
return value;
} | java | public static String getString(String key, String valueIfNull) {
String value = System.getProperty(key);
if (Strings.isNullOrEmpty(value)) {
return valueIfNull;
}
return value;
} | [
"public",
"static",
"String",
"getString",
"(",
"String",
"key",
",",
"String",
"valueIfNull",
")",
"{",
"String",
"value",
"=",
"System",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"value",
")",
")",
"{",
"return",
"valueIfNull",
";",
"}",
"return",
"value",
";",
"}"
] | Gets a system property string, or a replacement value if the property is
null or blank.
@param key
@param valueIfNull
@return | [
"Gets",
"a",
"system",
"property",
"string",
"or",
"a",
"replacement",
"value",
"if",
"the",
"property",
"is",
"null",
"or",
"blank",
"."
] | train | https://github.com/datacleaner/AnalyzerBeans/blob/f82dae080d80d2a647b706a5fb22b3ea250613b3/core/src/main/java/org/eobjects/analyzer/util/SystemProperties.java#L47-L53 |
mpetazzoni/ttorrent | common/src/main/java/com/turn/ttorrent/common/creation/MetadataBuilder.java | MetadataBuilder.addDataSource | public MetadataBuilder addDataSource(@NotNull InputStream dataSource, String path, boolean closeAfterBuild) {
"""
add custom source in torrent with custom path. Path can be separated with any slash.
@param closeAfterBuild if true then source stream will be closed after {@link #build()} invocation
"""
checkHashingResultIsNotSet();
filesPaths.add(path);
dataSources.add(new StreamBasedHolderImpl(dataSource, closeAfterBuild));
return this;
} | java | public MetadataBuilder addDataSource(@NotNull InputStream dataSource, String path, boolean closeAfterBuild) {
checkHashingResultIsNotSet();
filesPaths.add(path);
dataSources.add(new StreamBasedHolderImpl(dataSource, closeAfterBuild));
return this;
} | [
"public",
"MetadataBuilder",
"addDataSource",
"(",
"@",
"NotNull",
"InputStream",
"dataSource",
",",
"String",
"path",
",",
"boolean",
"closeAfterBuild",
")",
"{",
"checkHashingResultIsNotSet",
"(",
")",
";",
"filesPaths",
".",
"add",
"(",
"path",
")",
";",
"dataSources",
".",
"add",
"(",
"new",
"StreamBasedHolderImpl",
"(",
"dataSource",
",",
"closeAfterBuild",
")",
")",
";",
"return",
"this",
";",
"}"
] | add custom source in torrent with custom path. Path can be separated with any slash.
@param closeAfterBuild if true then source stream will be closed after {@link #build()} invocation | [
"add",
"custom",
"source",
"in",
"torrent",
"with",
"custom",
"path",
".",
"Path",
"can",
"be",
"separated",
"with",
"any",
"slash",
"."
] | train | https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/common/src/main/java/com/turn/ttorrent/common/creation/MetadataBuilder.java#L197-L202 |
jamesagnew/hapi-fhir | hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java | StopWatch.getEstimatedTimeRemaining | public String getEstimatedTimeRemaining(double theCompleteToDate, double theTotal) {
"""
Given an amount of something completed so far, and a total amount, calculates how long it will take for something to complete
@param theCompleteToDate The amount so far
@param theTotal The total (must be higher than theCompleteToDate
@return A formatted amount of time
"""
double millis = getMillis();
long millisRemaining = (long) (((theTotal / theCompleteToDate) * millis) - (millis));
return formatMillis(millisRemaining);
} | java | public String getEstimatedTimeRemaining(double theCompleteToDate, double theTotal) {
double millis = getMillis();
long millisRemaining = (long) (((theTotal / theCompleteToDate) * millis) - (millis));
return formatMillis(millisRemaining);
} | [
"public",
"String",
"getEstimatedTimeRemaining",
"(",
"double",
"theCompleteToDate",
",",
"double",
"theTotal",
")",
"{",
"double",
"millis",
"=",
"getMillis",
"(",
")",
";",
"long",
"millisRemaining",
"=",
"(",
"long",
")",
"(",
"(",
"(",
"theTotal",
"/",
"theCompleteToDate",
")",
"*",
"millis",
")",
"-",
"(",
"millis",
")",
")",
";",
"return",
"formatMillis",
"(",
"millisRemaining",
")",
";",
"}"
] | Given an amount of something completed so far, and a total amount, calculates how long it will take for something to complete
@param theCompleteToDate The amount so far
@param theTotal The total (must be higher than theCompleteToDate
@return A formatted amount of time | [
"Given",
"an",
"amount",
"of",
"something",
"completed",
"so",
"far",
"and",
"a",
"total",
"amount",
"calculates",
"how",
"long",
"it",
"will",
"take",
"for",
"something",
"to",
"complete"
] | train | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java#L180-L184 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java | JsonUtil.getFloat | public static float getFloat(JsonObject object, String field, float defaultValue) {
"""
Returns a field in a Json object as a float.
@param object the Json Object
@param field the field in the Json object to return
@param defaultValue a default value for the field if the field value is null
@return the Json field value as a float
"""
final JsonValue value = object.get(field);
if (value == null || value.isNull()) {
return defaultValue;
} else {
return value.asFloat();
}
} | java | public static float getFloat(JsonObject object, String field, float defaultValue) {
final JsonValue value = object.get(field);
if (value == null || value.isNull()) {
return defaultValue;
} else {
return value.asFloat();
}
} | [
"public",
"static",
"float",
"getFloat",
"(",
"JsonObject",
"object",
",",
"String",
"field",
",",
"float",
"defaultValue",
")",
"{",
"final",
"JsonValue",
"value",
"=",
"object",
".",
"get",
"(",
"field",
")",
";",
"if",
"(",
"value",
"==",
"null",
"||",
"value",
".",
"isNull",
"(",
")",
")",
"{",
"return",
"defaultValue",
";",
"}",
"else",
"{",
"return",
"value",
".",
"asFloat",
"(",
")",
";",
"}",
"}"
] | Returns a field in a Json object as a float.
@param object the Json Object
@param field the field in the Json object to return
@param defaultValue a default value for the field if the field value is null
@return the Json field value as a float | [
"Returns",
"a",
"field",
"in",
"a",
"Json",
"object",
"as",
"a",
"float",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L151-L158 |
probedock/probedock-rt-java | src/main/java/io/probedock/rt/client/Connector.java | Connector.notifyEnd | public void notifyEnd(String projectApiId, String projectVersion, String category, long duration) {
"""
Send a ending notification to the agent
@param projectApiId The project API ID
@param projectVersion The project version
@param category The category
@param duration The duration of the test run
"""
try {
if (isStarted()) {
JSONObject endNotification = new JSONObject().
put("project", new JSONObject().
put("apiId", projectApiId).
put("version", projectVersion)
).
put("category", category).
put("duration", duration);
socket.emit("run:end", endNotification);
}
else {
LOGGER.log(Level.WARNING, "Probe Dock RT is not available to send the end notification");
}
}
catch (Exception e) {
LOGGER.log(Level.INFO, "Unable to send the end notification to the agent. Cause: " + e.getMessage());
if (LOGGER.getLevel() == Level.FINEST) {
LOGGER.log(Level.FINEST, "Exception:", e);
}
}
} | java | public void notifyEnd(String projectApiId, String projectVersion, String category, long duration) {
try {
if (isStarted()) {
JSONObject endNotification = new JSONObject().
put("project", new JSONObject().
put("apiId", projectApiId).
put("version", projectVersion)
).
put("category", category).
put("duration", duration);
socket.emit("run:end", endNotification);
}
else {
LOGGER.log(Level.WARNING, "Probe Dock RT is not available to send the end notification");
}
}
catch (Exception e) {
LOGGER.log(Level.INFO, "Unable to send the end notification to the agent. Cause: " + e.getMessage());
if (LOGGER.getLevel() == Level.FINEST) {
LOGGER.log(Level.FINEST, "Exception:", e);
}
}
} | [
"public",
"void",
"notifyEnd",
"(",
"String",
"projectApiId",
",",
"String",
"projectVersion",
",",
"String",
"category",
",",
"long",
"duration",
")",
"{",
"try",
"{",
"if",
"(",
"isStarted",
"(",
")",
")",
"{",
"JSONObject",
"endNotification",
"=",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"project\"",
",",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"apiId\"",
",",
"projectApiId",
")",
".",
"put",
"(",
"\"version\"",
",",
"projectVersion",
")",
")",
".",
"put",
"(",
"\"category\"",
",",
"category",
")",
".",
"put",
"(",
"\"duration\"",
",",
"duration",
")",
";",
"socket",
".",
"emit",
"(",
"\"run:end\"",
",",
"endNotification",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Probe Dock RT is not available to send the end notification\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Unable to send the end notification to the agent. Cause: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"if",
"(",
"LOGGER",
".",
"getLevel",
"(",
")",
"==",
"Level",
".",
"FINEST",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINEST",
",",
"\"Exception:\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Send a ending notification to the agent
@param projectApiId The project API ID
@param projectVersion The project version
@param category The category
@param duration The duration of the test run | [
"Send",
"a",
"ending",
"notification",
"to",
"the",
"agent"
] | train | https://github.com/probedock/probedock-rt-java/blob/67b44b64303b15eb2d4808f9560a1c9554ccf3ba/src/main/java/io/probedock/rt/client/Connector.java#L132-L156 |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/output/ReportWriterFactory.java | ReportWriterFactory.getReportWriter | public ReportWriter getReportWriter(final JasperPrint _jasperPrint, final String _format, final Map<JRExporterParameter,Object> _parameters) {
"""
Returns a ReportWriter that which will use memory or a file depending on the parameter PAGES_THRESHOLD
@param _jasperPrint
@param _format
@param _parameters
@return
"""
final JRExporter exporter = FormatInfoRegistry.getInstance().getExporter(_format);
exporter.setParameters(_parameters);
if (_jasperPrint.getPages().size() > PAGES_THRESHHOLD) {
return new FileReportWriter(_jasperPrint, exporter);
} else {
return new MemoryReportWriter(_jasperPrint, exporter);
}
} | java | public ReportWriter getReportWriter(final JasperPrint _jasperPrint, final String _format, final Map<JRExporterParameter,Object> _parameters) {
final JRExporter exporter = FormatInfoRegistry.getInstance().getExporter(_format);
exporter.setParameters(_parameters);
if (_jasperPrint.getPages().size() > PAGES_THRESHHOLD) {
return new FileReportWriter(_jasperPrint, exporter);
} else {
return new MemoryReportWriter(_jasperPrint, exporter);
}
} | [
"public",
"ReportWriter",
"getReportWriter",
"(",
"final",
"JasperPrint",
"_jasperPrint",
",",
"final",
"String",
"_format",
",",
"final",
"Map",
"<",
"JRExporterParameter",
",",
"Object",
">",
"_parameters",
")",
"{",
"final",
"JRExporter",
"exporter",
"=",
"FormatInfoRegistry",
".",
"getInstance",
"(",
")",
".",
"getExporter",
"(",
"_format",
")",
";",
"exporter",
".",
"setParameters",
"(",
"_parameters",
")",
";",
"if",
"(",
"_jasperPrint",
".",
"getPages",
"(",
")",
".",
"size",
"(",
")",
">",
"PAGES_THRESHHOLD",
")",
"{",
"return",
"new",
"FileReportWriter",
"(",
"_jasperPrint",
",",
"exporter",
")",
";",
"}",
"else",
"{",
"return",
"new",
"MemoryReportWriter",
"(",
"_jasperPrint",
",",
"exporter",
")",
";",
"}",
"}"
] | Returns a ReportWriter that which will use memory or a file depending on the parameter PAGES_THRESHOLD
@param _jasperPrint
@param _format
@param _parameters
@return | [
"Returns",
"a",
"ReportWriter",
"that",
"which",
"will",
"use",
"memory",
"or",
"a",
"file",
"depending",
"on",
"the",
"parameter",
"PAGES_THRESHOLD"
] | train | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/output/ReportWriterFactory.java#L64-L73 |
algolia/instantsearch-android | core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java | Searcher.addFacet | @SuppressWarnings( {
"""
Adds a facet refinement for the next queries.
@param attribute the facet name.
@param isDisjunctive if {@code true}, the facet will be added as a disjunctive facet.
@param values an eventual list of values to refine on.
@deprecated this will be removed in v2.0, use {@link #addFacetRefinement(String, List, boolean)} instead.
""""WeakerAccess", "unused"}) // For library users
@Deprecated // TODO Remove in 2.0
public void addFacet(@NonNull String attribute, boolean isDisjunctive, @Nullable List<String> values) {
addFacetRefinement(attribute, values, isDisjunctive);
} | java | @SuppressWarnings({"WeakerAccess", "unused"}) // For library users
@Deprecated // TODO Remove in 2.0
public void addFacet(@NonNull String attribute, boolean isDisjunctive, @Nullable List<String> values) {
addFacetRefinement(attribute, values, isDisjunctive);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"@",
"Deprecated",
"// TODO Remove in 2.0",
"public",
"void",
"addFacet",
"(",
"@",
"NonNull",
"String",
"attribute",
",",
"boolean",
"isDisjunctive",
",",
"@",
"Nullable",
"List",
"<",
"String",
">",
"values",
")",
"{",
"addFacetRefinement",
"(",
"attribute",
",",
"values",
",",
"isDisjunctive",
")",
";",
"}"
] | Adds a facet refinement for the next queries.
@param attribute the facet name.
@param isDisjunctive if {@code true}, the facet will be added as a disjunctive facet.
@param values an eventual list of values to refine on.
@deprecated this will be removed in v2.0, use {@link #addFacetRefinement(String, List, boolean)} instead. | [
"Adds",
"a",
"facet",
"refinement",
"for",
"the",
"next",
"queries",
"."
] | train | https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java#L515-L519 |
keenon/loglinear | src/main/java/com/github/keenon/loglinear/storage/ModelBatch.java | ModelBatch.readFrom | private void readFrom(InputStream inputStream, Consumer<GraphicalModel> featurizer) throws IOException {
"""
Load a batch of models from disk, while running the function "featurizer" on each of the models before adding it
to the batch. This gives the loader a chance to experiment with new featurization techniques.
@param inputStream the input stream to load from
@param featurizer a function that gets run on every GraphicalModel, and has a chance to edit them (eg by adding
or changing features)
"""
GraphicalModel read;
while ((read = GraphicalModel.readFromStream(inputStream)) != null) {
featurizer.accept(read);
add(read);
}
} | java | private void readFrom(InputStream inputStream, Consumer<GraphicalModel> featurizer) throws IOException {
GraphicalModel read;
while ((read = GraphicalModel.readFromStream(inputStream)) != null) {
featurizer.accept(read);
add(read);
}
} | [
"private",
"void",
"readFrom",
"(",
"InputStream",
"inputStream",
",",
"Consumer",
"<",
"GraphicalModel",
">",
"featurizer",
")",
"throws",
"IOException",
"{",
"GraphicalModel",
"read",
";",
"while",
"(",
"(",
"read",
"=",
"GraphicalModel",
".",
"readFromStream",
"(",
"inputStream",
")",
")",
"!=",
"null",
")",
"{",
"featurizer",
".",
"accept",
"(",
"read",
")",
";",
"add",
"(",
"read",
")",
";",
"}",
"}"
] | Load a batch of models from disk, while running the function "featurizer" on each of the models before adding it
to the batch. This gives the loader a chance to experiment with new featurization techniques.
@param inputStream the input stream to load from
@param featurizer a function that gets run on every GraphicalModel, and has a chance to edit them (eg by adding
or changing features) | [
"Load",
"a",
"batch",
"of",
"models",
"from",
"disk",
"while",
"running",
"the",
"function",
"featurizer",
"on",
"each",
"of",
"the",
"models",
"before",
"adding",
"it",
"to",
"the",
"batch",
".",
"This",
"gives",
"the",
"loader",
"a",
"chance",
"to",
"experiment",
"with",
"new",
"featurization",
"techniques",
"."
] | train | https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/storage/ModelBatch.java#L84-L90 |
landawn/AbacusUtil | src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java | PoolablePreparedStatement.setRowId | @Override
public void setRowId(int parameterIndex, RowId x) throws SQLException {
"""
Method setRowId.
@param parameterIndex
@param x
@throws SQLException
@see java.sql.PreparedStatement#setRowId(int, RowId)
"""
internalStmt.setRowId(parameterIndex, x);
} | java | @Override
public void setRowId(int parameterIndex, RowId x) throws SQLException {
internalStmt.setRowId(parameterIndex, x);
} | [
"@",
"Override",
"public",
"void",
"setRowId",
"(",
"int",
"parameterIndex",
",",
"RowId",
"x",
")",
"throws",
"SQLException",
"{",
"internalStmt",
".",
"setRowId",
"(",
"parameterIndex",
",",
"x",
")",
";",
"}"
] | Method setRowId.
@param parameterIndex
@param x
@throws SQLException
@see java.sql.PreparedStatement#setRowId(int, RowId) | [
"Method",
"setRowId",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java#L952-L955 |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspContentAttachmentsBean.java | CmsJspContentAttachmentsBean.getAttachmentsForCurrentPage | public static CmsJspContentAttachmentsBean getAttachmentsForCurrentPage(CmsObject cms, CmsResource content)
throws CmsException {
"""
Gets the attachments / detail-only contents for the current page (i.e. cms.getRequestContext().getUri()).<p>
@param cms the CMS context
@param content the content for which to get the attachments
@return a bean providing access to the attachments for the resource
@throws CmsException if something goes wrong
"""
CmsResource page = cms.readResource(cms.getRequestContext().getUri(), CmsResourceFilter.IGNORE_EXPIRATION);
String locale = CmsDetailOnlyContainerUtil.getDetailContainerLocale(
cms,
cms.getRequestContext().getLocale().toString(),
page);
Optional<CmsResource> detailOnly = CmsDetailOnlyContainerUtil.getDetailOnlyPage(cms, content, locale);
if (detailOnly.isPresent()) {
try {
return new CmsJspContentAttachmentsBean(cms, detailOnly.get());
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return new CmsJspContentAttachmentsBean();
}
} else {
return new CmsJspContentAttachmentsBean();
}
} | java | public static CmsJspContentAttachmentsBean getAttachmentsForCurrentPage(CmsObject cms, CmsResource content)
throws CmsException {
CmsResource page = cms.readResource(cms.getRequestContext().getUri(), CmsResourceFilter.IGNORE_EXPIRATION);
String locale = CmsDetailOnlyContainerUtil.getDetailContainerLocale(
cms,
cms.getRequestContext().getLocale().toString(),
page);
Optional<CmsResource> detailOnly = CmsDetailOnlyContainerUtil.getDetailOnlyPage(cms, content, locale);
if (detailOnly.isPresent()) {
try {
return new CmsJspContentAttachmentsBean(cms, detailOnly.get());
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return new CmsJspContentAttachmentsBean();
}
} else {
return new CmsJspContentAttachmentsBean();
}
} | [
"public",
"static",
"CmsJspContentAttachmentsBean",
"getAttachmentsForCurrentPage",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"content",
")",
"throws",
"CmsException",
"{",
"CmsResource",
"page",
"=",
"cms",
".",
"readResource",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getUri",
"(",
")",
",",
"CmsResourceFilter",
".",
"IGNORE_EXPIRATION",
")",
";",
"String",
"locale",
"=",
"CmsDetailOnlyContainerUtil",
".",
"getDetailContainerLocale",
"(",
"cms",
",",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getLocale",
"(",
")",
".",
"toString",
"(",
")",
",",
"page",
")",
";",
"Optional",
"<",
"CmsResource",
">",
"detailOnly",
"=",
"CmsDetailOnlyContainerUtil",
".",
"getDetailOnlyPage",
"(",
"cms",
",",
"content",
",",
"locale",
")",
";",
"if",
"(",
"detailOnly",
".",
"isPresent",
"(",
")",
")",
"{",
"try",
"{",
"return",
"new",
"CmsJspContentAttachmentsBean",
"(",
"cms",
",",
"detailOnly",
".",
"get",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"new",
"CmsJspContentAttachmentsBean",
"(",
")",
";",
"}",
"}",
"else",
"{",
"return",
"new",
"CmsJspContentAttachmentsBean",
"(",
")",
";",
"}",
"}"
] | Gets the attachments / detail-only contents for the current page (i.e. cms.getRequestContext().getUri()).<p>
@param cms the CMS context
@param content the content for which to get the attachments
@return a bean providing access to the attachments for the resource
@throws CmsException if something goes wrong | [
"Gets",
"the",
"attachments",
"/",
"detail",
"-",
"only",
"contents",
"for",
"the",
"current",
"page",
"(",
"i",
".",
"e",
".",
"cms",
".",
"getRequestContext",
"()",
".",
"getUri",
"()",
")",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspContentAttachmentsBean.java#L146-L165 |
sebastiangraf/treetank | interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java | PipelineBuilder.addAndExpression | public void addAndExpression(final INodeReadTrx mTransaction) {
"""
Adds a and expression to the pipeline.
@param mTransaction
Transaction to operate with.
"""
assert getPipeStack().size() >= 2;
final AbsAxis mOperand2 = getPipeStack().pop().getExpr();
final AbsAxis operand1 = getPipeStack().pop().getExpr();
if (getPipeStack().empty() || getExpression().getSize() != 0) {
addExpressionSingle();
}
getExpression().add(new AndExpr(mTransaction, operand1, mOperand2));
} | java | public void addAndExpression(final INodeReadTrx mTransaction) {
assert getPipeStack().size() >= 2;
final AbsAxis mOperand2 = getPipeStack().pop().getExpr();
final AbsAxis operand1 = getPipeStack().pop().getExpr();
if (getPipeStack().empty() || getExpression().getSize() != 0) {
addExpressionSingle();
}
getExpression().add(new AndExpr(mTransaction, operand1, mOperand2));
} | [
"public",
"void",
"addAndExpression",
"(",
"final",
"INodeReadTrx",
"mTransaction",
")",
"{",
"assert",
"getPipeStack",
"(",
")",
".",
"size",
"(",
")",
">=",
"2",
";",
"final",
"AbsAxis",
"mOperand2",
"=",
"getPipeStack",
"(",
")",
".",
"pop",
"(",
")",
".",
"getExpr",
"(",
")",
";",
"final",
"AbsAxis",
"operand1",
"=",
"getPipeStack",
"(",
")",
".",
"pop",
"(",
")",
".",
"getExpr",
"(",
")",
";",
"if",
"(",
"getPipeStack",
"(",
")",
".",
"empty",
"(",
")",
"||",
"getExpression",
"(",
")",
".",
"getSize",
"(",
")",
"!=",
"0",
")",
"{",
"addExpressionSingle",
"(",
")",
";",
"}",
"getExpression",
"(",
")",
".",
"add",
"(",
"new",
"AndExpr",
"(",
"mTransaction",
",",
"operand1",
",",
"mOperand2",
")",
")",
";",
"}"
] | Adds a and expression to the pipeline.
@param mTransaction
Transaction to operate with. | [
"Adds",
"a",
"and",
"expression",
"to",
"the",
"pipeline",
"."
] | train | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L420-L429 |
pravega/pravega | segmentstore/server/src/main/java/io/pravega/segmentstore/server/containers/MetadataStore.java | MetadataStore.assignSegmentId | private void assignSegmentId(String segmentName, Duration timeout) {
"""
Attempts to map a Segment to an Id, by first trying to retrieve an existing id, and, should that not exist,
assign a new one.
@param segmentName The name of the Segment to assign id for.
@param timeout Timeout for the operation.
"""
TimeoutTimer timer = new TimeoutTimer(timeout);
Futures.exceptionListener(
getSegmentInfoInternal(segmentName, timer.getRemaining())
.thenComposeAsync(si -> submitAssignmentWithRetry(SegmentInfo.deserialize(si), timer.getRemaining()), this.executor),
ex -> failAssignment(segmentName, ex));
} | java | private void assignSegmentId(String segmentName, Duration timeout) {
TimeoutTimer timer = new TimeoutTimer(timeout);
Futures.exceptionListener(
getSegmentInfoInternal(segmentName, timer.getRemaining())
.thenComposeAsync(si -> submitAssignmentWithRetry(SegmentInfo.deserialize(si), timer.getRemaining()), this.executor),
ex -> failAssignment(segmentName, ex));
} | [
"private",
"void",
"assignSegmentId",
"(",
"String",
"segmentName",
",",
"Duration",
"timeout",
")",
"{",
"TimeoutTimer",
"timer",
"=",
"new",
"TimeoutTimer",
"(",
"timeout",
")",
";",
"Futures",
".",
"exceptionListener",
"(",
"getSegmentInfoInternal",
"(",
"segmentName",
",",
"timer",
".",
"getRemaining",
"(",
")",
")",
".",
"thenComposeAsync",
"(",
"si",
"->",
"submitAssignmentWithRetry",
"(",
"SegmentInfo",
".",
"deserialize",
"(",
"si",
")",
",",
"timer",
".",
"getRemaining",
"(",
")",
")",
",",
"this",
".",
"executor",
")",
",",
"ex",
"->",
"failAssignment",
"(",
"segmentName",
",",
"ex",
")",
")",
";",
"}"
] | Attempts to map a Segment to an Id, by first trying to retrieve an existing id, and, should that not exist,
assign a new one.
@param segmentName The name of the Segment to assign id for.
@param timeout Timeout for the operation. | [
"Attempts",
"to",
"map",
"a",
"Segment",
"to",
"an",
"Id",
"by",
"first",
"trying",
"to",
"retrieve",
"an",
"existing",
"id",
"and",
"should",
"that",
"not",
"exist",
"assign",
"a",
"new",
"one",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/containers/MetadataStore.java#L381-L387 |
vkostyukov/la4j | src/main/java/org/la4j/vector/SparseVector.java | SparseVector.random | public static SparseVector random(int length, double density, Random random) {
"""
Creates a constant {@link SparseVector} of the given {@code length} with
the given {@code value}.
"""
return CompressedVector.random(length, density, random);
} | java | public static SparseVector random(int length, double density, Random random) {
return CompressedVector.random(length, density, random);
} | [
"public",
"static",
"SparseVector",
"random",
"(",
"int",
"length",
",",
"double",
"density",
",",
"Random",
"random",
")",
"{",
"return",
"CompressedVector",
".",
"random",
"(",
"length",
",",
"density",
",",
"random",
")",
";",
"}"
] | Creates a constant {@link SparseVector} of the given {@code length} with
the given {@code value}. | [
"Creates",
"a",
"constant",
"{"
] | train | https://github.com/vkostyukov/la4j/blob/dd1b917caf9606399a49afa6b0d738934cd3a7b3/src/main/java/org/la4j/vector/SparseVector.java#L90-L92 |
alkacon/opencms-core | src/org/opencms/ade/upload/CmsUploadService.java | CmsUploadService.isDeletedResource | private boolean isDeletedResource(String path, boolean rootPath) {
"""
Checks if a the resource exists but is marked as deleted.<p>
@param path the path
@param rootPath in case the path is a root path
@return true is the resource exists but is marked as deleted
"""
CmsObject cms = getCmsObject();
CmsResource res = null;
try {
if (rootPath) {
String origSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot("");
res = cms.readResource(path, CmsResourceFilter.ALL);
} finally {
cms.getRequestContext().setSiteRoot(origSiteRoot);
}
} else {
res = cms.readResource(path, CmsResourceFilter.ALL);
}
} catch (CmsException e) {
// ignore
}
return (res != null) && res.getState().isDeleted();
} | java | private boolean isDeletedResource(String path, boolean rootPath) {
CmsObject cms = getCmsObject();
CmsResource res = null;
try {
if (rootPath) {
String origSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot("");
res = cms.readResource(path, CmsResourceFilter.ALL);
} finally {
cms.getRequestContext().setSiteRoot(origSiteRoot);
}
} else {
res = cms.readResource(path, CmsResourceFilter.ALL);
}
} catch (CmsException e) {
// ignore
}
return (res != null) && res.getState().isDeleted();
} | [
"private",
"boolean",
"isDeletedResource",
"(",
"String",
"path",
",",
"boolean",
"rootPath",
")",
"{",
"CmsObject",
"cms",
"=",
"getCmsObject",
"(",
")",
";",
"CmsResource",
"res",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"rootPath",
")",
"{",
"String",
"origSiteRoot",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getSiteRoot",
"(",
")",
";",
"try",
"{",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"\"\"",
")",
";",
"res",
"=",
"cms",
".",
"readResource",
"(",
"path",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"}",
"finally",
"{",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"origSiteRoot",
")",
";",
"}",
"}",
"else",
"{",
"res",
"=",
"cms",
".",
"readResource",
"(",
"path",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"}",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"// ignore",
"}",
"return",
"(",
"res",
"!=",
"null",
")",
"&&",
"res",
".",
"getState",
"(",
")",
".",
"isDeleted",
"(",
")",
";",
"}"
] | Checks if a the resource exists but is marked as deleted.<p>
@param path the path
@param rootPath in case the path is a root path
@return true is the resource exists but is marked as deleted | [
"Checks",
"if",
"a",
"the",
"resource",
"exists",
"but",
"is",
"marked",
"as",
"deleted",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/upload/CmsUploadService.java#L169-L190 |
osmdroid/osmdroid | osmdroid-android/src/main/java/org/osmdroid/util/TileSystem.java | TileSystem.QuadKeyToTileXY | public static Point QuadKeyToTileXY(final String quadKey, final Point reuse) {
"""
Use {@link MapTileIndex#getX(long)} and {@link MapTileIndex#getY(long)} instead
Quadkey principles can be found at https://msdn.microsoft.com/en-us/library/bb259689.aspx
"""
final Point out = reuse == null ? new Point() : reuse;
if (quadKey == null || quadKey.length() == 0) {
throw new IllegalArgumentException("Invalid QuadKey: " + quadKey);
}
int tileX = 0;
int tileY = 0;
final int zoom = quadKey.length();
for (int i = 0 ; i < zoom; i++) {
final int value = 1 << i;
switch (quadKey.charAt(zoom - i - 1)) {
case '0':
break;
case '1':
tileX += value;
break;
case '2':
tileY += value;
break;
case '3':
tileX += value;
tileY += value;
break;
default:
throw new IllegalArgumentException("Invalid QuadKey: " + quadKey);
}
}
out.x = tileX;
out.y = tileY;
return out;
} | java | public static Point QuadKeyToTileXY(final String quadKey, final Point reuse) {
final Point out = reuse == null ? new Point() : reuse;
if (quadKey == null || quadKey.length() == 0) {
throw new IllegalArgumentException("Invalid QuadKey: " + quadKey);
}
int tileX = 0;
int tileY = 0;
final int zoom = quadKey.length();
for (int i = 0 ; i < zoom; i++) {
final int value = 1 << i;
switch (quadKey.charAt(zoom - i - 1)) {
case '0':
break;
case '1':
tileX += value;
break;
case '2':
tileY += value;
break;
case '3':
tileX += value;
tileY += value;
break;
default:
throw new IllegalArgumentException("Invalid QuadKey: " + quadKey);
}
}
out.x = tileX;
out.y = tileY;
return out;
} | [
"public",
"static",
"Point",
"QuadKeyToTileXY",
"(",
"final",
"String",
"quadKey",
",",
"final",
"Point",
"reuse",
")",
"{",
"final",
"Point",
"out",
"=",
"reuse",
"==",
"null",
"?",
"new",
"Point",
"(",
")",
":",
"reuse",
";",
"if",
"(",
"quadKey",
"==",
"null",
"||",
"quadKey",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid QuadKey: \"",
"+",
"quadKey",
")",
";",
"}",
"int",
"tileX",
"=",
"0",
";",
"int",
"tileY",
"=",
"0",
";",
"final",
"int",
"zoom",
"=",
"quadKey",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"zoom",
";",
"i",
"++",
")",
"{",
"final",
"int",
"value",
"=",
"1",
"<<",
"i",
";",
"switch",
"(",
"quadKey",
".",
"charAt",
"(",
"zoom",
"-",
"i",
"-",
"1",
")",
")",
"{",
"case",
"'",
"'",
":",
"break",
";",
"case",
"'",
"'",
":",
"tileX",
"+=",
"value",
";",
"break",
";",
"case",
"'",
"'",
":",
"tileY",
"+=",
"value",
";",
"break",
";",
"case",
"'",
"'",
":",
"tileX",
"+=",
"value",
";",
"tileY",
"+=",
"value",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid QuadKey: \"",
"+",
"quadKey",
")",
";",
"}",
"}",
"out",
".",
"x",
"=",
"tileX",
";",
"out",
".",
"y",
"=",
"tileY",
";",
"return",
"out",
";",
"}"
] | Use {@link MapTileIndex#getX(long)} and {@link MapTileIndex#getY(long)} instead
Quadkey principles can be found at https://msdn.microsoft.com/en-us/library/bb259689.aspx | [
"Use",
"{"
] | train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/util/TileSystem.java#L362-L392 |
Azure/azure-sdk-for-java | keyvault/resource-manager/v2016_10_01/src/main/java/com/microsoft/azure/management/keyvault/v2016_10_01/implementation/VaultsInner.java | VaultsInner.createOrUpdateAsync | public Observable<VaultInner> createOrUpdateAsync(String resourceGroupName, String vaultName, VaultCreateOrUpdateParameters parameters) {
"""
Create or update a key vault in the specified subscription.
@param resourceGroupName The name of the Resource Group to which the server belongs.
@param vaultName Name of the vault
@param parameters Parameters to create or update the vault
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VaultInner object
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, vaultName, parameters).map(new Func1<ServiceResponse<VaultInner>, VaultInner>() {
@Override
public VaultInner call(ServiceResponse<VaultInner> response) {
return response.body();
}
});
} | java | public Observable<VaultInner> createOrUpdateAsync(String resourceGroupName, String vaultName, VaultCreateOrUpdateParameters parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, vaultName, parameters).map(new Func1<ServiceResponse<VaultInner>, VaultInner>() {
@Override
public VaultInner call(ServiceResponse<VaultInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VaultInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"vaultName",
",",
"VaultCreateOrUpdateParameters",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vaultName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VaultInner",
">",
",",
"VaultInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VaultInner",
"call",
"(",
"ServiceResponse",
"<",
"VaultInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create or update a key vault in the specified subscription.
@param resourceGroupName The name of the Resource Group to which the server belongs.
@param vaultName Name of the vault
@param parameters Parameters to create or update the vault
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VaultInner object | [
"Create",
"or",
"update",
"a",
"key",
"vault",
"in",
"the",
"specified",
"subscription",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/resource-manager/v2016_10_01/src/main/java/com/microsoft/azure/management/keyvault/v2016_10_01/implementation/VaultsInner.java#L182-L189 |
opengeospatial/teamengine | teamengine-core/src/main/java/com/occamlab/te/parsers/ImageParser.java | ImageParser.getBase64Data | private static String getBase64Data(BufferedImage buffImage,
String formatName, Node node) throws Exception {
"""
/*
2011-09-08 PwD
@return image data as a base64 encoded string
"""
int numBytes = buffImage.getWidth() * buffImage.getHeight() * 4;
ByteArrayOutputStream baos = new ByteArrayOutputStream(numBytes);
ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
boolean status = ImageIO.write(buffImage, formatName, ios);
if (!status) {
throw new Exception(
"No suitable ImageIO writer found by ImageParser.getBase64Data() for image format "
+ formatName);
}
byte[] imageData = baos.toByteArray();
// String base64String = Base64.encodeBase64String(imageData); this is
// unchunked (no line breaks) which is unwieldy
byte[] base64Data = Base64.encodeBase64Chunked(imageData);
// 2011-11-15 PwD uncomment for Java 1.7 String base64String = new
// String(base64Data, StandardCharsets.UTF_8);
String base64String = new String(base64Data, "UTF-8"); // 2011-11-15 PwD
// for Java 1.6;
// remove for
// Java 1.7
return base64String;
} | java | private static String getBase64Data(BufferedImage buffImage,
String formatName, Node node) throws Exception {
int numBytes = buffImage.getWidth() * buffImage.getHeight() * 4;
ByteArrayOutputStream baos = new ByteArrayOutputStream(numBytes);
ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
boolean status = ImageIO.write(buffImage, formatName, ios);
if (!status) {
throw new Exception(
"No suitable ImageIO writer found by ImageParser.getBase64Data() for image format "
+ formatName);
}
byte[] imageData = baos.toByteArray();
// String base64String = Base64.encodeBase64String(imageData); this is
// unchunked (no line breaks) which is unwieldy
byte[] base64Data = Base64.encodeBase64Chunked(imageData);
// 2011-11-15 PwD uncomment for Java 1.7 String base64String = new
// String(base64Data, StandardCharsets.UTF_8);
String base64String = new String(base64Data, "UTF-8"); // 2011-11-15 PwD
// for Java 1.6;
// remove for
// Java 1.7
return base64String;
} | [
"private",
"static",
"String",
"getBase64Data",
"(",
"BufferedImage",
"buffImage",
",",
"String",
"formatName",
",",
"Node",
"node",
")",
"throws",
"Exception",
"{",
"int",
"numBytes",
"=",
"buffImage",
".",
"getWidth",
"(",
")",
"*",
"buffImage",
".",
"getHeight",
"(",
")",
"*",
"4",
";",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
"numBytes",
")",
";",
"ImageOutputStream",
"ios",
"=",
"ImageIO",
".",
"createImageOutputStream",
"(",
"baos",
")",
";",
"boolean",
"status",
"=",
"ImageIO",
".",
"write",
"(",
"buffImage",
",",
"formatName",
",",
"ios",
")",
";",
"if",
"(",
"!",
"status",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"No suitable ImageIO writer found by ImageParser.getBase64Data() for image format \"",
"+",
"formatName",
")",
";",
"}",
"byte",
"[",
"]",
"imageData",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"// String base64String = Base64.encodeBase64String(imageData); this is",
"// unchunked (no line breaks) which is unwieldy",
"byte",
"[",
"]",
"base64Data",
"=",
"Base64",
".",
"encodeBase64Chunked",
"(",
"imageData",
")",
";",
"// 2011-11-15 PwD uncomment for Java 1.7 String base64String = new",
"// String(base64Data, StandardCharsets.UTF_8);",
"String",
"base64String",
"=",
"new",
"String",
"(",
"base64Data",
",",
"\"UTF-8\"",
")",
";",
"// 2011-11-15 PwD",
"// for Java 1.6;",
"// remove for",
"// Java 1.7",
"return",
"base64String",
";",
"}"
] | /*
2011-09-08 PwD
@return image data as a base64 encoded string | [
"/",
"*",
"2011",
"-",
"09",
"-",
"08",
"PwD"
] | train | https://github.com/opengeospatial/teamengine/blob/b6b890214b6784bbe19460bf753bdf28a9514bee/teamengine-core/src/main/java/com/occamlab/te/parsers/ImageParser.java#L118-L140 |
Harium/keel | src/main/java/com/harium/keel/effect/helper/Curve.java | Curve.Spline | public static float Spline(float x, int numKnots, float[] knots) {
"""
compute a Catmull-Rom spline.
@param x the input parameter
@param numKnots the number of knots in the spline
@param knots the array of knots
@return the spline value
"""
int span;
int numSpans = numKnots - 3;
float k0, k1, k2, k3;
float c0, c1, c2, c3;
if (numSpans < 1)
throw new IllegalArgumentException("Too few knots in spline");
x = x > 1 ? 1 : x;
x = x < 0 ? 0 : x;
x *= numSpans;
span = (int) x;
if (span > numKnots - 4)
span = numKnots - 4;
x -= span;
k0 = knots[span];
k1 = knots[span + 1];
k2 = knots[span + 2];
k3 = knots[span + 3];
c3 = -0.5f * k0 + 1.5f * k1 + -1.5f * k2 + 0.5f * k3;
c2 = 1f * k0 + -2.5f * k1 + 2f * k2 + -0.5f * k3;
c1 = -0.5f * k0 + 0f * k1 + 0.5f * k2 + 0f * k3;
c0 = 0f * k0 + 1f * k1 + 0f * k2 + 0f * k3;
return ((c3 * x + c2) * x + c1) * x + c0;
} | java | public static float Spline(float x, int numKnots, float[] knots) {
int span;
int numSpans = numKnots - 3;
float k0, k1, k2, k3;
float c0, c1, c2, c3;
if (numSpans < 1)
throw new IllegalArgumentException("Too few knots in spline");
x = x > 1 ? 1 : x;
x = x < 0 ? 0 : x;
x *= numSpans;
span = (int) x;
if (span > numKnots - 4)
span = numKnots - 4;
x -= span;
k0 = knots[span];
k1 = knots[span + 1];
k2 = knots[span + 2];
k3 = knots[span + 3];
c3 = -0.5f * k0 + 1.5f * k1 + -1.5f * k2 + 0.5f * k3;
c2 = 1f * k0 + -2.5f * k1 + 2f * k2 + -0.5f * k3;
c1 = -0.5f * k0 + 0f * k1 + 0.5f * k2 + 0f * k3;
c0 = 0f * k0 + 1f * k1 + 0f * k2 + 0f * k3;
return ((c3 * x + c2) * x + c1) * x + c0;
} | [
"public",
"static",
"float",
"Spline",
"(",
"float",
"x",
",",
"int",
"numKnots",
",",
"float",
"[",
"]",
"knots",
")",
"{",
"int",
"span",
";",
"int",
"numSpans",
"=",
"numKnots",
"-",
"3",
";",
"float",
"k0",
",",
"k1",
",",
"k2",
",",
"k3",
";",
"float",
"c0",
",",
"c1",
",",
"c2",
",",
"c3",
";",
"if",
"(",
"numSpans",
"<",
"1",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Too few knots in spline\"",
")",
";",
"x",
"=",
"x",
">",
"1",
"?",
"1",
":",
"x",
";",
"x",
"=",
"x",
"<",
"0",
"?",
"0",
":",
"x",
";",
"x",
"*=",
"numSpans",
";",
"span",
"=",
"(",
"int",
")",
"x",
";",
"if",
"(",
"span",
">",
"numKnots",
"-",
"4",
")",
"span",
"=",
"numKnots",
"-",
"4",
";",
"x",
"-=",
"span",
";",
"k0",
"=",
"knots",
"[",
"span",
"]",
";",
"k1",
"=",
"knots",
"[",
"span",
"+",
"1",
"]",
";",
"k2",
"=",
"knots",
"[",
"span",
"+",
"2",
"]",
";",
"k3",
"=",
"knots",
"[",
"span",
"+",
"3",
"]",
";",
"c3",
"=",
"-",
"0.5f",
"*",
"k0",
"+",
"1.5f",
"*",
"k1",
"+",
"-",
"1.5f",
"*",
"k2",
"+",
"0.5f",
"*",
"k3",
";",
"c2",
"=",
"1f",
"*",
"k0",
"+",
"-",
"2.5f",
"*",
"k1",
"+",
"2f",
"*",
"k2",
"+",
"-",
"0.5f",
"*",
"k3",
";",
"c1",
"=",
"-",
"0.5f",
"*",
"k0",
"+",
"0f",
"*",
"k1",
"+",
"0.5f",
"*",
"k2",
"+",
"0f",
"*",
"k3",
";",
"c0",
"=",
"0f",
"*",
"k0",
"+",
"1f",
"*",
"k1",
"+",
"0f",
"*",
"k2",
"+",
"0f",
"*",
"k3",
";",
"return",
"(",
"(",
"c3",
"*",
"x",
"+",
"c2",
")",
"*",
"x",
"+",
"c1",
")",
"*",
"x",
"+",
"c0",
";",
"}"
] | compute a Catmull-Rom spline.
@param x the input parameter
@param numKnots the number of knots in the spline
@param knots the array of knots
@return the spline value | [
"compute",
"a",
"Catmull",
"-",
"Rom",
"spline",
"."
] | train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/effect/helper/Curve.java#L239-L267 |
Impetus/Kundera | src/kundera-cassandra/cassandra-ds-driver/src/main/java/com/impetus/kundera/client/cassandra/dsdriver/DSClientUtilities.java | DSClientUtilities.setFieldValue | private static void setFieldValue(Object entity, Field member, Object retVal) {
"""
Sets the field value.
@param entity
the entity
@param member
the member
@param retVal
the ret val
"""
if (member != null && retVal != null && entity != null)
{
PropertyAccessorHelper.set(entity, member, retVal);
}
} | java | private static void setFieldValue(Object entity, Field member, Object retVal)
{
if (member != null && retVal != null && entity != null)
{
PropertyAccessorHelper.set(entity, member, retVal);
}
} | [
"private",
"static",
"void",
"setFieldValue",
"(",
"Object",
"entity",
",",
"Field",
"member",
",",
"Object",
"retVal",
")",
"{",
"if",
"(",
"member",
"!=",
"null",
"&&",
"retVal",
"!=",
"null",
"&&",
"entity",
"!=",
"null",
")",
"{",
"PropertyAccessorHelper",
".",
"set",
"(",
"entity",
",",
"member",
",",
"retVal",
")",
";",
"}",
"}"
] | Sets the field value.
@param entity
the entity
@param member
the member
@param retVal
the ret val | [
"Sets",
"the",
"field",
"value",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-ds-driver/src/main/java/com/impetus/kundera/client/cassandra/dsdriver/DSClientUtilities.java#L790-L796 |
alibaba/ARouter | arouter-api/src/main/java/com/alibaba/android/arouter/core/InterceptorServiceImpl.java | InterceptorServiceImpl._excute | private static void _excute(final int index, final CancelableCountDownLatch counter, final Postcard postcard) {
"""
Excute interceptor
@param index current interceptor index
@param counter interceptor counter
@param postcard routeMeta
"""
if (index < Warehouse.interceptors.size()) {
IInterceptor iInterceptor = Warehouse.interceptors.get(index);
iInterceptor.process(postcard, new InterceptorCallback() {
@Override
public void onContinue(Postcard postcard) {
// Last interceptor excute over with no exception.
counter.countDown();
_excute(index + 1, counter, postcard); // When counter is down, it will be execute continue ,but index bigger than interceptors size, then U know.
}
@Override
public void onInterrupt(Throwable exception) {
// Last interceptor excute over with fatal exception.
postcard.setTag(null == exception ? new HandlerException("No message.") : exception.getMessage()); // save the exception message for backup.
counter.cancel();
// Be attention, maybe the thread in callback has been changed,
// then the catch block(L207) will be invalid.
// The worst is the thread changed to main thread, then the app will be crash, if you throw this exception!
// if (!Looper.getMainLooper().equals(Looper.myLooper())) { // You shouldn't throw the exception if the thread is main thread.
// throw new HandlerException(exception.getMessage());
// }
}
});
}
} | java | private static void _excute(final int index, final CancelableCountDownLatch counter, final Postcard postcard) {
if (index < Warehouse.interceptors.size()) {
IInterceptor iInterceptor = Warehouse.interceptors.get(index);
iInterceptor.process(postcard, new InterceptorCallback() {
@Override
public void onContinue(Postcard postcard) {
// Last interceptor excute over with no exception.
counter.countDown();
_excute(index + 1, counter, postcard); // When counter is down, it will be execute continue ,but index bigger than interceptors size, then U know.
}
@Override
public void onInterrupt(Throwable exception) {
// Last interceptor excute over with fatal exception.
postcard.setTag(null == exception ? new HandlerException("No message.") : exception.getMessage()); // save the exception message for backup.
counter.cancel();
// Be attention, maybe the thread in callback has been changed,
// then the catch block(L207) will be invalid.
// The worst is the thread changed to main thread, then the app will be crash, if you throw this exception!
// if (!Looper.getMainLooper().equals(Looper.myLooper())) { // You shouldn't throw the exception if the thread is main thread.
// throw new HandlerException(exception.getMessage());
// }
}
});
}
} | [
"private",
"static",
"void",
"_excute",
"(",
"final",
"int",
"index",
",",
"final",
"CancelableCountDownLatch",
"counter",
",",
"final",
"Postcard",
"postcard",
")",
"{",
"if",
"(",
"index",
"<",
"Warehouse",
".",
"interceptors",
".",
"size",
"(",
")",
")",
"{",
"IInterceptor",
"iInterceptor",
"=",
"Warehouse",
".",
"interceptors",
".",
"get",
"(",
"index",
")",
";",
"iInterceptor",
".",
"process",
"(",
"postcard",
",",
"new",
"InterceptorCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onContinue",
"(",
"Postcard",
"postcard",
")",
"{",
"// Last interceptor excute over with no exception.",
"counter",
".",
"countDown",
"(",
")",
";",
"_excute",
"(",
"index",
"+",
"1",
",",
"counter",
",",
"postcard",
")",
";",
"// When counter is down, it will be execute continue ,but index bigger than interceptors size, then U know.",
"}",
"@",
"Override",
"public",
"void",
"onInterrupt",
"(",
"Throwable",
"exception",
")",
"{",
"// Last interceptor excute over with fatal exception.",
"postcard",
".",
"setTag",
"(",
"null",
"==",
"exception",
"?",
"new",
"HandlerException",
"(",
"\"No message.\"",
")",
":",
"exception",
".",
"getMessage",
"(",
")",
")",
";",
"// save the exception message for backup.",
"counter",
".",
"cancel",
"(",
")",
";",
"// Be attention, maybe the thread in callback has been changed,",
"// then the catch block(L207) will be invalid.",
"// The worst is the thread changed to main thread, then the app will be crash, if you throw this exception!",
"// if (!Looper.getMainLooper().equals(Looper.myLooper())) { // You shouldn't throw the exception if the thread is main thread.",
"// throw new HandlerException(exception.getMessage());",
"// }",
"}",
"}",
")",
";",
"}",
"}"
] | Excute interceptor
@param index current interceptor index
@param counter interceptor counter
@param postcard routeMeta | [
"Excute",
"interceptor"
] | train | https://github.com/alibaba/ARouter/blob/1a06912a6e14a57112db1204b43f81c43d721732/arouter-api/src/main/java/com/alibaba/android/arouter/core/InterceptorServiceImpl.java#L74-L100 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ReUtil.java | ReUtil.findAll | public static <T extends Collection<String>> T findAll(String regex, CharSequence content, int group, T collection) {
"""
取得内容中匹配的所有结果
@param <T> 集合类型
@param regex 正则
@param content 被查找的内容
@param group 正则的分组
@param collection 返回的集合类型
@return 结果集
"""
if (null == regex) {
return collection;
}
return findAll(Pattern.compile(regex, Pattern.DOTALL), content, group, collection);
} | java | public static <T extends Collection<String>> T findAll(String regex, CharSequence content, int group, T collection) {
if (null == regex) {
return collection;
}
return findAll(Pattern.compile(regex, Pattern.DOTALL), content, group, collection);
} | [
"public",
"static",
"<",
"T",
"extends",
"Collection",
"<",
"String",
">",
">",
"T",
"findAll",
"(",
"String",
"regex",
",",
"CharSequence",
"content",
",",
"int",
"group",
",",
"T",
"collection",
")",
"{",
"if",
"(",
"null",
"==",
"regex",
")",
"{",
"return",
"collection",
";",
"}",
"return",
"findAll",
"(",
"Pattern",
".",
"compile",
"(",
"regex",
",",
"Pattern",
".",
"DOTALL",
")",
",",
"content",
",",
"group",
",",
"collection",
")",
";",
"}"
] | 取得内容中匹配的所有结果
@param <T> 集合类型
@param regex 正则
@param content 被查找的内容
@param group 正则的分组
@param collection 返回的集合类型
@return 结果集 | [
"取得内容中匹配的所有结果"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReUtil.java#L402-L408 |
fhoeben/hsac-fitnesse-fixtures | src/main/java/nl/hsac/fitnesse/fixture/util/MapHelper.java | MapHelper.getValue | public Object getValue(Map<String, Object> map, String name) {
"""
Gets value from map.
@param map map to get value from.
@param name name of (possibly nested) property to get value from.
@return value found, if it could be found, null otherwise.
"""
String cleanName = htmlCleaner.cleanupValue(name);
return getValueImpl(map, cleanName, true);
} | java | public Object getValue(Map<String, Object> map, String name) {
String cleanName = htmlCleaner.cleanupValue(name);
return getValueImpl(map, cleanName, true);
} | [
"public",
"Object",
"getValue",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
",",
"String",
"name",
")",
"{",
"String",
"cleanName",
"=",
"htmlCleaner",
".",
"cleanupValue",
"(",
"name",
")",
";",
"return",
"getValueImpl",
"(",
"map",
",",
"cleanName",
",",
"true",
")",
";",
"}"
] | Gets value from map.
@param map map to get value from.
@param name name of (possibly nested) property to get value from.
@return value found, if it could be found, null otherwise. | [
"Gets",
"value",
"from",
"map",
"."
] | train | https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/util/MapHelper.java#L24-L27 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/database/CmsHtmlImport.java | CmsHtmlImport.getBasePath | private String getBasePath(String path1, String path2) {
"""
Compares two path's for the base part which have both equal.<p>
@param path1 the first path to compare
@param path2 the second path to compare
@return the base path of both which are equal
"""
StringBuffer base = new StringBuffer();
path1 = path1.replace('\\', '/');
path2 = path2.replace('\\', '/');
String[] parts1 = path1.split("/");
String[] parts2 = path2.split("/");
for (int i = 0; i < parts1.length; i++) {
if (i >= parts2.length) {
break;
}
if (parts1[i].equals(parts2[i])) {
base.append(parts1[i] + "/");
}
}
return base.toString();
} | java | private String getBasePath(String path1, String path2) {
StringBuffer base = new StringBuffer();
path1 = path1.replace('\\', '/');
path2 = path2.replace('\\', '/');
String[] parts1 = path1.split("/");
String[] parts2 = path2.split("/");
for (int i = 0; i < parts1.length; i++) {
if (i >= parts2.length) {
break;
}
if (parts1[i].equals(parts2[i])) {
base.append(parts1[i] + "/");
}
}
return base.toString();
} | [
"private",
"String",
"getBasePath",
"(",
"String",
"path1",
",",
"String",
"path2",
")",
"{",
"StringBuffer",
"base",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"path1",
"=",
"path1",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"path2",
"=",
"path2",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"String",
"[",
"]",
"parts1",
"=",
"path1",
".",
"split",
"(",
"\"/\"",
")",
";",
"String",
"[",
"]",
"parts2",
"=",
"path2",
".",
"split",
"(",
"\"/\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parts1",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">=",
"parts2",
".",
"length",
")",
"{",
"break",
";",
"}",
"if",
"(",
"parts1",
"[",
"i",
"]",
".",
"equals",
"(",
"parts2",
"[",
"i",
"]",
")",
")",
"{",
"base",
".",
"append",
"(",
"parts1",
"[",
"i",
"]",
"+",
"\"/\"",
")",
";",
"}",
"}",
"return",
"base",
".",
"toString",
"(",
")",
";",
"}"
] | Compares two path's for the base part which have both equal.<p>
@param path1 the first path to compare
@param path2 the second path to compare
@return the base path of both which are equal | [
"Compares",
"two",
"path",
"s",
"for",
"the",
"base",
"part",
"which",
"have",
"both",
"equal",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/database/CmsHtmlImport.java#L1321-L1340 |
vakinge/jeesuite-libs | jeesuite-common/src/main/java/com/jeesuite/common/util/DateUtils.java | DateUtils.formatDateStr | public static String formatDateStr(String dateStr, String... patterns) {
"""
格式化日期字符串<br>
generate by: vakin jiang at 2012-3-7
@param dateStr
@param patterns
@return
"""
String pattern = TIMESTAMP_PATTERN;
if (patterns != null && patterns.length > 0
&& StringUtils.isNotBlank(patterns[0])) {
pattern = patterns[0];
}
return DateFormatUtils.format(parseDate(dateStr), pattern);
} | java | public static String formatDateStr(String dateStr, String... patterns) {
String pattern = TIMESTAMP_PATTERN;
if (patterns != null && patterns.length > 0
&& StringUtils.isNotBlank(patterns[0])) {
pattern = patterns[0];
}
return DateFormatUtils.format(parseDate(dateStr), pattern);
} | [
"public",
"static",
"String",
"formatDateStr",
"(",
"String",
"dateStr",
",",
"String",
"...",
"patterns",
")",
"{",
"String",
"pattern",
"=",
"TIMESTAMP_PATTERN",
";",
"if",
"(",
"patterns",
"!=",
"null",
"&&",
"patterns",
".",
"length",
">",
"0",
"&&",
"StringUtils",
".",
"isNotBlank",
"(",
"patterns",
"[",
"0",
"]",
")",
")",
"{",
"pattern",
"=",
"patterns",
"[",
"0",
"]",
";",
"}",
"return",
"DateFormatUtils",
".",
"format",
"(",
"parseDate",
"(",
"dateStr",
")",
",",
"pattern",
")",
";",
"}"
] | 格式化日期字符串<br>
generate by: vakin jiang at 2012-3-7
@param dateStr
@param patterns
@return | [
"格式化日期字符串<br",
">",
"generate",
"by",
":",
"vakin",
"jiang",
"at",
"2012",
"-",
"3",
"-",
"7"
] | train | https://github.com/vakinge/jeesuite-libs/blob/c48fe2c7fbd294892cf4030dbec96e744dd3e386/jeesuite-common/src/main/java/com/jeesuite/common/util/DateUtils.java#L159-L166 |
Samsung/GearVRf | GVRf/Extensions/x3d/src/main/java/org/gearvrf/x3d/TimeSensor.java | TimeSensor.setLoop | public void setLoop(boolean doLoop, GVRContext gvrContext) {
"""
SetLoop will either set the GVRNodeAnimation's Repeat Mode to REPEATED if loop is true.
or it will set the GVRNodeAnimation's Repeat Mode to ONCE if loop is false
if loop is set to TRUE, when it was previously FALSE, then start the Animation.
@param doLoop
@param gvrContext
"""
if (this.loop != doLoop ) {
// a change in the loop
for (GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations) {
if (doLoop) gvrKeyFrameAnimation.setRepeatMode(GVRRepeatMode.REPEATED);
else gvrKeyFrameAnimation.setRepeatMode(GVRRepeatMode.ONCE);
}
// be sure to start the animations if loop is true
if ( doLoop ) {
for (GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations) {
gvrKeyFrameAnimation.start(gvrContext.getAnimationEngine() );
}
}
this.loop = doLoop;
}
} | java | public void setLoop(boolean doLoop, GVRContext gvrContext) {
if (this.loop != doLoop ) {
// a change in the loop
for (GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations) {
if (doLoop) gvrKeyFrameAnimation.setRepeatMode(GVRRepeatMode.REPEATED);
else gvrKeyFrameAnimation.setRepeatMode(GVRRepeatMode.ONCE);
}
// be sure to start the animations if loop is true
if ( doLoop ) {
for (GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations) {
gvrKeyFrameAnimation.start(gvrContext.getAnimationEngine() );
}
}
this.loop = doLoop;
}
} | [
"public",
"void",
"setLoop",
"(",
"boolean",
"doLoop",
",",
"GVRContext",
"gvrContext",
")",
"{",
"if",
"(",
"this",
".",
"loop",
"!=",
"doLoop",
")",
"{",
"// a change in the loop",
"for",
"(",
"GVRNodeAnimation",
"gvrKeyFrameAnimation",
":",
"gvrKeyFrameAnimations",
")",
"{",
"if",
"(",
"doLoop",
")",
"gvrKeyFrameAnimation",
".",
"setRepeatMode",
"(",
"GVRRepeatMode",
".",
"REPEATED",
")",
";",
"else",
"gvrKeyFrameAnimation",
".",
"setRepeatMode",
"(",
"GVRRepeatMode",
".",
"ONCE",
")",
";",
"}",
"// be sure to start the animations if loop is true",
"if",
"(",
"doLoop",
")",
"{",
"for",
"(",
"GVRNodeAnimation",
"gvrKeyFrameAnimation",
":",
"gvrKeyFrameAnimations",
")",
"{",
"gvrKeyFrameAnimation",
".",
"start",
"(",
"gvrContext",
".",
"getAnimationEngine",
"(",
")",
")",
";",
"}",
"}",
"this",
".",
"loop",
"=",
"doLoop",
";",
"}",
"}"
] | SetLoop will either set the GVRNodeAnimation's Repeat Mode to REPEATED if loop is true.
or it will set the GVRNodeAnimation's Repeat Mode to ONCE if loop is false
if loop is set to TRUE, when it was previously FALSE, then start the Animation.
@param doLoop
@param gvrContext | [
"SetLoop",
"will",
"either",
"set",
"the",
"GVRNodeAnimation",
"s",
"Repeat",
"Mode",
"to",
"REPEATED",
"if",
"loop",
"is",
"true",
".",
"or",
"it",
"will",
"set",
"the",
"GVRNodeAnimation",
"s",
"Repeat",
"Mode",
"to",
"ONCE",
"if",
"loop",
"is",
"false",
"if",
"loop",
"is",
"set",
"to",
"TRUE",
"when",
"it",
"was",
"previously",
"FALSE",
"then",
"start",
"the",
"Animation",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/x3d/src/main/java/org/gearvrf/x3d/TimeSensor.java#L96-L111 |
carewebframework/carewebframework-core | org.carewebframework.shell/src/main/java/org/carewebframework/shell/plugins/PluginXmlParser.java | PluginXmlParser.parseConfig | private void parseConfig(Element property, BeanDefinitionBuilder propertyBuilder) {
"""
Parses out configuration settings for current property descriptor.
@param property Root element
@param propertyBuilder Bean definition builder.
"""
Element config = (Element) getTagChildren("config", property).item(0);
if (config != null) {
Properties properties = new Properties();
NodeList entries = getTagChildren("entry", config);
for (int i = 0; i < entries.getLength(); i++) {
Element entry = (Element) entries.item(i);
String key = entry.getAttribute("key");
String value = entry.getTextContent().trim();
properties.put(key, value);
}
propertyBuilder.addPropertyValue("config", properties);
}
} | java | private void parseConfig(Element property, BeanDefinitionBuilder propertyBuilder) {
Element config = (Element) getTagChildren("config", property).item(0);
if (config != null) {
Properties properties = new Properties();
NodeList entries = getTagChildren("entry", config);
for (int i = 0; i < entries.getLength(); i++) {
Element entry = (Element) entries.item(i);
String key = entry.getAttribute("key");
String value = entry.getTextContent().trim();
properties.put(key, value);
}
propertyBuilder.addPropertyValue("config", properties);
}
} | [
"private",
"void",
"parseConfig",
"(",
"Element",
"property",
",",
"BeanDefinitionBuilder",
"propertyBuilder",
")",
"{",
"Element",
"config",
"=",
"(",
"Element",
")",
"getTagChildren",
"(",
"\"config\"",
",",
"property",
")",
".",
"item",
"(",
"0",
")",
";",
"if",
"(",
"config",
"!=",
"null",
")",
"{",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"NodeList",
"entries",
"=",
"getTagChildren",
"(",
"\"entry\"",
",",
"config",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"entries",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Element",
"entry",
"=",
"(",
"Element",
")",
"entries",
".",
"item",
"(",
"i",
")",
";",
"String",
"key",
"=",
"entry",
".",
"getAttribute",
"(",
"\"key\"",
")",
";",
"String",
"value",
"=",
"entry",
".",
"getTextContent",
"(",
")",
".",
"trim",
"(",
")",
";",
"properties",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"propertyBuilder",
".",
"addPropertyValue",
"(",
"\"config\"",
",",
"properties",
")",
";",
"}",
"}"
] | Parses out configuration settings for current property descriptor.
@param property Root element
@param propertyBuilder Bean definition builder. | [
"Parses",
"out",
"configuration",
"settings",
"for",
"current",
"property",
"descriptor",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.shell/src/main/java/org/carewebframework/shell/plugins/PluginXmlParser.java#L230-L246 |
craftercms/commons | utilities/src/main/java/org/craftercms/commons/http/HttpUtils.java | HttpUtils.getQueryStringFromParams | public static String getQueryStringFromParams(MultiValueMap<String, String> queryParams, boolean encodeValues) {
"""
Builds a query string from the specified params. The param names are always encoded, but the values are only encoded
if {@code encodeValues} is true. UTF-8 is used as the encoding charset.
@param queryParams the params to build the query string with
@param encodeValues if the param values should be encoded
@return the query string
"""
try {
return getQueryStringFromParams(queryParams, "UTF-8", encodeValues);
} catch (UnsupportedEncodingException e) {
// Should NEVER happen
throw new IllegalStateException("UTF-8 should always be supported by the JVM", e);
}
} | java | public static String getQueryStringFromParams(MultiValueMap<String, String> queryParams, boolean encodeValues) {
try {
return getQueryStringFromParams(queryParams, "UTF-8", encodeValues);
} catch (UnsupportedEncodingException e) {
// Should NEVER happen
throw new IllegalStateException("UTF-8 should always be supported by the JVM", e);
}
} | [
"public",
"static",
"String",
"getQueryStringFromParams",
"(",
"MultiValueMap",
"<",
"String",
",",
"String",
">",
"queryParams",
",",
"boolean",
"encodeValues",
")",
"{",
"try",
"{",
"return",
"getQueryStringFromParams",
"(",
"queryParams",
",",
"\"UTF-8\"",
",",
"encodeValues",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"// Should NEVER happen",
"throw",
"new",
"IllegalStateException",
"(",
"\"UTF-8 should always be supported by the JVM\"",
",",
"e",
")",
";",
"}",
"}"
] | Builds a query string from the specified params. The param names are always encoded, but the values are only encoded
if {@code encodeValues} is true. UTF-8 is used as the encoding charset.
@param queryParams the params to build the query string with
@param encodeValues if the param values should be encoded
@return the query string | [
"Builds",
"a",
"query",
"string",
"from",
"the",
"specified",
"params",
".",
"The",
"param",
"names",
"are",
"always",
"encoded",
"but",
"the",
"values",
"are",
"only",
"encoded",
"if",
"{",
"@code",
"encodeValues",
"}",
"is",
"true",
".",
"UTF",
"-",
"8",
"is",
"used",
"as",
"the",
"encoding",
"charset",
"."
] | train | https://github.com/craftercms/commons/blob/3074fe49e56c2a4aae0832f40b17ae563335dc83/utilities/src/main/java/org/craftercms/commons/http/HttpUtils.java#L267-L274 |
lucee/Lucee | core/src/main/java/lucee/runtime/db/Executer.java | Executer.executeExp | private Object executeExp(PageContext pc, SQL sql, Query qr, ZExp exp, int row) throws PageException {
"""
Executes a ZEXp
@param sql
@param qr Query Result
@param exp expression to execute
@param row current row of resultset
@return result
@throws PageException
"""
if (exp instanceof ZConstant) return executeConstant(sql, qr, (ZConstant) exp, row);
else if (exp instanceof ZExpression) return executeExpression(pc, sql, qr, (ZExpression) exp, row);
throw new DatabaseException("unsupported sql statement [" + exp + "]", null, sql, null);
} | java | private Object executeExp(PageContext pc, SQL sql, Query qr, ZExp exp, int row) throws PageException {
if (exp instanceof ZConstant) return executeConstant(sql, qr, (ZConstant) exp, row);
else if (exp instanceof ZExpression) return executeExpression(pc, sql, qr, (ZExpression) exp, row);
throw new DatabaseException("unsupported sql statement [" + exp + "]", null, sql, null);
} | [
"private",
"Object",
"executeExp",
"(",
"PageContext",
"pc",
",",
"SQL",
"sql",
",",
"Query",
"qr",
",",
"ZExp",
"exp",
",",
"int",
"row",
")",
"throws",
"PageException",
"{",
"if",
"(",
"exp",
"instanceof",
"ZConstant",
")",
"return",
"executeConstant",
"(",
"sql",
",",
"qr",
",",
"(",
"ZConstant",
")",
"exp",
",",
"row",
")",
";",
"else",
"if",
"(",
"exp",
"instanceof",
"ZExpression",
")",
"return",
"executeExpression",
"(",
"pc",
",",
"sql",
",",
"qr",
",",
"(",
"ZExpression",
")",
"exp",
",",
"row",
")",
";",
"throw",
"new",
"DatabaseException",
"(",
"\"unsupported sql statement [\"",
"+",
"exp",
"+",
"\"]\"",
",",
"null",
",",
"sql",
",",
"null",
")",
";",
"}"
] | Executes a ZEXp
@param sql
@param qr Query Result
@param exp expression to execute
@param row current row of resultset
@return result
@throws PageException | [
"Executes",
"a",
"ZEXp"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/db/Executer.java#L240-L245 |
smartsheet-platform/smartsheet-java-sdk | src/main/java/com/smartsheet/api/internal/RowAttachmentResourcesImpl.java | RowAttachmentResourcesImpl.attachFile | public Attachment attachFile(long sheetId, long rowId, InputStream inputStream, String contentType, long contentLength, String attachmentName)
throws SmartsheetException {
"""
Attach file for simple upload.
@param sheetId the sheet id
@param rowId the row id
@param contentType the content type
@param contentLength the content length
@param attachmentName the name of the attachment
@return the attachment
@throws FileNotFoundException the file not found exception
@throws SmartsheetException the smartsheet exception
@throws UnsupportedEncodingException the unsupported encoding exception
"""
Util.throwIfNull(inputStream, contentType);
return super.attachFile("sheets/" + sheetId + "/rows/" + rowId + "/attachments", inputStream, contentType, contentLength, attachmentName);
} | java | public Attachment attachFile(long sheetId, long rowId, InputStream inputStream, String contentType, long contentLength, String attachmentName)
throws SmartsheetException {
Util.throwIfNull(inputStream, contentType);
return super.attachFile("sheets/" + sheetId + "/rows/" + rowId + "/attachments", inputStream, contentType, contentLength, attachmentName);
} | [
"public",
"Attachment",
"attachFile",
"(",
"long",
"sheetId",
",",
"long",
"rowId",
",",
"InputStream",
"inputStream",
",",
"String",
"contentType",
",",
"long",
"contentLength",
",",
"String",
"attachmentName",
")",
"throws",
"SmartsheetException",
"{",
"Util",
".",
"throwIfNull",
"(",
"inputStream",
",",
"contentType",
")",
";",
"return",
"super",
".",
"attachFile",
"(",
"\"sheets/\"",
"+",
"sheetId",
"+",
"\"/rows/\"",
"+",
"rowId",
"+",
"\"/attachments\"",
",",
"inputStream",
",",
"contentType",
",",
"contentLength",
",",
"attachmentName",
")",
";",
"}"
] | Attach file for simple upload.
@param sheetId the sheet id
@param rowId the row id
@param contentType the content type
@param contentLength the content length
@param attachmentName the name of the attachment
@return the attachment
@throws FileNotFoundException the file not found exception
@throws SmartsheetException the smartsheet exception
@throws UnsupportedEncodingException the unsupported encoding exception | [
"Attach",
"file",
"for",
"simple",
"upload",
"."
] | train | https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/f60e264412076271f83b65889ef9b891fad83df8/src/main/java/com/smartsheet/api/internal/RowAttachmentResourcesImpl.java#L135-L139 |
smartsheet-platform/smartsheet-java-sdk | src/main/java/com/smartsheet/api/internal/WorkspaceResourcesImpl.java | WorkspaceResourcesImpl.copyWorkspace | public Workspace copyWorkspace(long workspaceId, ContainerDestination containerDestination, EnumSet<WorkspaceCopyInclusion> includes, EnumSet<WorkspaceRemapExclusion> skipRemap) throws SmartsheetException {
"""
Creates a copy of the specified workspace.
It mirrors to the following Smartsheet REST API method: POST /workspaces/{workspaceId}/copy
Exceptions:
IllegalArgumentException : if folder is null
InvalidRequestException : if there is any problem with the REST API request
AuthorizationException : if there is any problem with the REST API authorization(access token)
ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
SmartsheetRestException : if there is any other REST API related error occurred during the operation
SmartsheetException : if there is any other error occurred during the operation
@param workspaceId the folder id
@param containerDestination describes the destination container
@param includes optional parameters to include
@param skipRemap optional parameters to exclude
@return the folder
@throws SmartsheetException the smartsheet exception
"""
return copyWorkspace(workspaceId, containerDestination, includes, skipRemap, null);
} | java | public Workspace copyWorkspace(long workspaceId, ContainerDestination containerDestination, EnumSet<WorkspaceCopyInclusion> includes, EnumSet<WorkspaceRemapExclusion> skipRemap) throws SmartsheetException {
return copyWorkspace(workspaceId, containerDestination, includes, skipRemap, null);
} | [
"public",
"Workspace",
"copyWorkspace",
"(",
"long",
"workspaceId",
",",
"ContainerDestination",
"containerDestination",
",",
"EnumSet",
"<",
"WorkspaceCopyInclusion",
">",
"includes",
",",
"EnumSet",
"<",
"WorkspaceRemapExclusion",
">",
"skipRemap",
")",
"throws",
"SmartsheetException",
"{",
"return",
"copyWorkspace",
"(",
"workspaceId",
",",
"containerDestination",
",",
"includes",
",",
"skipRemap",
",",
"null",
")",
";",
"}"
] | Creates a copy of the specified workspace.
It mirrors to the following Smartsheet REST API method: POST /workspaces/{workspaceId}/copy
Exceptions:
IllegalArgumentException : if folder is null
InvalidRequestException : if there is any problem with the REST API request
AuthorizationException : if there is any problem with the REST API authorization(access token)
ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
SmartsheetRestException : if there is any other REST API related error occurred during the operation
SmartsheetException : if there is any other error occurred during the operation
@param workspaceId the folder id
@param containerDestination describes the destination container
@param includes optional parameters to include
@param skipRemap optional parameters to exclude
@return the folder
@throws SmartsheetException the smartsheet exception | [
"Creates",
"a",
"copy",
"of",
"the",
"specified",
"workspace",
"."
] | train | https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/f60e264412076271f83b65889ef9b891fad83df8/src/main/java/com/smartsheet/api/internal/WorkspaceResourcesImpl.java#L245-L247 |
versionone/VersionOne.SDK.Java.ObjectModel | src/main/java/com/versionone/om/Project.java | Project.createEpic | public Epic createEpic(String name, Map<String, Object> attributes) {
"""
Create a new Epic in this Project.
@param name The initial name of the Epic.
@param attributes additional attributes for the Epic.
@return A new Epic.
"""
return getInstance().create().epic(name, this, attributes);
} | java | public Epic createEpic(String name, Map<String, Object> attributes) {
return getInstance().create().epic(name, this, attributes);
} | [
"public",
"Epic",
"createEpic",
"(",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
")",
"{",
"return",
"getInstance",
"(",
")",
".",
"create",
"(",
")",
".",
"epic",
"(",
"name",
",",
"this",
",",
"attributes",
")",
";",
"}"
] | Create a new Epic in this Project.
@param name The initial name of the Epic.
@param attributes additional attributes for the Epic.
@return A new Epic. | [
"Create",
"a",
"new",
"Epic",
"in",
"this",
"Project",
"."
] | train | https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/Project.java#L195-L197 |
VoltDB/voltdb | src/frontend/org/voltcore/messaging/HostMessenger.java | HostMessenger.putForeignHost | private void putForeignHost(int hostId, ForeignHost fh) {
"""
/*
Convenience method for doing the verbose COW insert into the map
"""
synchronized (m_mapLock) {
m_foreignHosts = ImmutableMultimap.<Integer, ForeignHost>builder()
.putAll(m_foreignHosts)
.put(hostId, fh)
.build();
}
} | java | private void putForeignHost(int hostId, ForeignHost fh) {
synchronized (m_mapLock) {
m_foreignHosts = ImmutableMultimap.<Integer, ForeignHost>builder()
.putAll(m_foreignHosts)
.put(hostId, fh)
.build();
}
} | [
"private",
"void",
"putForeignHost",
"(",
"int",
"hostId",
",",
"ForeignHost",
"fh",
")",
"{",
"synchronized",
"(",
"m_mapLock",
")",
"{",
"m_foreignHosts",
"=",
"ImmutableMultimap",
".",
"<",
"Integer",
",",
"ForeignHost",
">",
"builder",
"(",
")",
".",
"putAll",
"(",
"m_foreignHosts",
")",
".",
"put",
"(",
"hostId",
",",
"fh",
")",
".",
"build",
"(",
")",
";",
"}",
"}"
] | /*
Convenience method for doing the verbose COW insert into the map | [
"/",
"*",
"Convenience",
"method",
"for",
"doing",
"the",
"verbose",
"COW",
"insert",
"into",
"the",
"map"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltcore/messaging/HostMessenger.java#L843-L850 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/renderer/animation/transformation/AlphaTransform.java | AlphaTransform.doTransform | @Override
protected void doTransform(ITransformable.Alpha transformable, float comp) {
"""
Calculates the transformation.
@param transformable the transformable
@param comp the comp
"""
if (comp <= 0)
return;
float from = reversed ? toAlpha : fromAlpha;
float to = reversed ? fromAlpha : toAlpha;
transformable.setAlpha((int) (from + (to - from) * comp));
} | java | @Override
protected void doTransform(ITransformable.Alpha transformable, float comp)
{
if (comp <= 0)
return;
float from = reversed ? toAlpha : fromAlpha;
float to = reversed ? fromAlpha : toAlpha;
transformable.setAlpha((int) (from + (to - from) * comp));
} | [
"@",
"Override",
"protected",
"void",
"doTransform",
"(",
"ITransformable",
".",
"Alpha",
"transformable",
",",
"float",
"comp",
")",
"{",
"if",
"(",
"comp",
"<=",
"0",
")",
"return",
";",
"float",
"from",
"=",
"reversed",
"?",
"toAlpha",
":",
"fromAlpha",
";",
"float",
"to",
"=",
"reversed",
"?",
"fromAlpha",
":",
"toAlpha",
";",
"transformable",
".",
"setAlpha",
"(",
"(",
"int",
")",
"(",
"from",
"+",
"(",
"to",
"-",
"from",
")",
"*",
"comp",
")",
")",
";",
"}"
] | Calculates the transformation.
@param transformable the transformable
@param comp the comp | [
"Calculates",
"the",
"transformation",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/renderer/animation/transformation/AlphaTransform.java#L91-L101 |
fommil/matrix-toolkits-java | src/main/java/no/uib/cipr/matrix/io/MatrixVectorWriter.java | MatrixVectorWriter.printCoordinate | public void printCoordinate(int[] row, int[] column, long[] data, int offset) {
"""
Prints the coordinate format to the underlying stream. One index pair and
entry on each line. The offset is added to each index, typically, this
can transform from a 0-based indicing to a 1-based.
"""
int size = row.length;
if (size != column.length || size != data.length)
throw new IllegalArgumentException(
"All arrays must be of the same size");
for (int i = 0; i < size; ++i)
format(Locale.ENGLISH, "%10d %10d %19d%n", row[i] + offset,
column[i] + offset, data[i]);
} | java | public void printCoordinate(int[] row, int[] column, long[] data, int offset) {
int size = row.length;
if (size != column.length || size != data.length)
throw new IllegalArgumentException(
"All arrays must be of the same size");
for (int i = 0; i < size; ++i)
format(Locale.ENGLISH, "%10d %10d %19d%n", row[i] + offset,
column[i] + offset, data[i]);
} | [
"public",
"void",
"printCoordinate",
"(",
"int",
"[",
"]",
"row",
",",
"int",
"[",
"]",
"column",
",",
"long",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"{",
"int",
"size",
"=",
"row",
".",
"length",
";",
"if",
"(",
"size",
"!=",
"column",
".",
"length",
"||",
"size",
"!=",
"data",
".",
"length",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"All arrays must be of the same size\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"++",
"i",
")",
"format",
"(",
"Locale",
".",
"ENGLISH",
"",
",",
"\"%10d %10d %19d%n\"",
",",
"row",
"[",
"i",
"]",
"+",
"offset",
",",
"column",
"[",
"i",
"]",
"+",
"offset",
",",
"data",
"[",
"i",
"]",
")",
";",
"}"
] | Prints the coordinate format to the underlying stream. One index pair and
entry on each line. The offset is added to each index, typically, this
can transform from a 0-based indicing to a 1-based. | [
"Prints",
"the",
"coordinate",
"format",
"to",
"the",
"underlying",
"stream",
".",
"One",
"index",
"pair",
"and",
"entry",
"on",
"each",
"line",
".",
"The",
"offset",
"is",
"added",
"to",
"each",
"index",
"typically",
"this",
"can",
"transform",
"from",
"a",
"0",
"-",
"based",
"indicing",
"to",
"a",
"1",
"-",
"based",
"."
] | train | https://github.com/fommil/matrix-toolkits-java/blob/6157618bc86bcda3749af2a60bf869d8f3292960/src/main/java/no/uib/cipr/matrix/io/MatrixVectorWriter.java#L370-L378 |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java | EsMarshalling.unmarshallGateway | public static GatewayBean unmarshallGateway(Map<String, Object> source) {
"""
Unmarshals the given map source into a bean.
@param source the source
@return the gateway bean
"""
if (source == null) {
return null;
}
GatewayBean bean = new GatewayBean();
bean.setId(asString(source.get("id")));
bean.setName(asString(source.get("name")));
bean.setDescription(asString(source.get("description")));
bean.setType(asEnum(source.get("type"), GatewayType.class));
bean.setConfiguration(asString(source.get("configuration")));
bean.setCreatedBy(asString(source.get("createdBy")));
bean.setCreatedOn(asDate(source.get("createdOn")));
bean.setModifiedBy(asString(source.get("modifiedBy")));
bean.setModifiedOn(asDate(source.get("modifiedOn")));
postMarshall(bean);
return bean;
} | java | public static GatewayBean unmarshallGateway(Map<String, Object> source) {
if (source == null) {
return null;
}
GatewayBean bean = new GatewayBean();
bean.setId(asString(source.get("id")));
bean.setName(asString(source.get("name")));
bean.setDescription(asString(source.get("description")));
bean.setType(asEnum(source.get("type"), GatewayType.class));
bean.setConfiguration(asString(source.get("configuration")));
bean.setCreatedBy(asString(source.get("createdBy")));
bean.setCreatedOn(asDate(source.get("createdOn")));
bean.setModifiedBy(asString(source.get("modifiedBy")));
bean.setModifiedOn(asDate(source.get("modifiedOn")));
postMarshall(bean);
return bean;
} | [
"public",
"static",
"GatewayBean",
"unmarshallGateway",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"GatewayBean",
"bean",
"=",
"new",
"GatewayBean",
"(",
")",
";",
"bean",
".",
"setId",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"id\"",
")",
")",
")",
";",
"bean",
".",
"setName",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"name\"",
")",
")",
")",
";",
"bean",
".",
"setDescription",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"description\"",
")",
")",
")",
";",
"bean",
".",
"setType",
"(",
"asEnum",
"(",
"source",
".",
"get",
"(",
"\"type\"",
")",
",",
"GatewayType",
".",
"class",
")",
")",
";",
"bean",
".",
"setConfiguration",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"configuration\"",
")",
")",
")",
";",
"bean",
".",
"setCreatedBy",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"createdBy\"",
")",
")",
")",
";",
"bean",
".",
"setCreatedOn",
"(",
"asDate",
"(",
"source",
".",
"get",
"(",
"\"createdOn\"",
")",
")",
")",
";",
"bean",
".",
"setModifiedBy",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"modifiedBy\"",
")",
")",
")",
";",
"bean",
".",
"setModifiedOn",
"(",
"asDate",
"(",
"source",
".",
"get",
"(",
"\"modifiedOn\"",
")",
")",
")",
";",
"postMarshall",
"(",
"bean",
")",
";",
"return",
"bean",
";",
"}"
] | Unmarshals the given map source into a bean.
@param source the source
@return the gateway bean | [
"Unmarshals",
"the",
"given",
"map",
"source",
"into",
"a",
"bean",
"."
] | train | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java#L701-L717 |
mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/RendererJob.java | RendererJob.otherTile | public RendererJob otherTile(Tile tile) {
"""
Just a way of generating a hash key for a tile if only the RendererJob is known.
@param tile the tile that changes
@return a RendererJob based on the current one, only tile changes
"""
return new RendererJob(tile, this.mapDataStore, this.renderThemeFuture, this.displayModel, this.textScale, this.hasAlpha, this.labelsOnly);
} | java | public RendererJob otherTile(Tile tile) {
return new RendererJob(tile, this.mapDataStore, this.renderThemeFuture, this.displayModel, this.textScale, this.hasAlpha, this.labelsOnly);
} | [
"public",
"RendererJob",
"otherTile",
"(",
"Tile",
"tile",
")",
"{",
"return",
"new",
"RendererJob",
"(",
"tile",
",",
"this",
".",
"mapDataStore",
",",
"this",
".",
"renderThemeFuture",
",",
"this",
".",
"displayModel",
",",
"this",
".",
"textScale",
",",
"this",
".",
"hasAlpha",
",",
"this",
".",
"labelsOnly",
")",
";",
"}"
] | Just a way of generating a hash key for a tile if only the RendererJob is known.
@param tile the tile that changes
@return a RendererJob based on the current one, only tile changes | [
"Just",
"a",
"way",
"of",
"generating",
"a",
"hash",
"key",
"for",
"a",
"tile",
"if",
"only",
"the",
"RendererJob",
"is",
"known",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/RendererJob.java#L88-L90 |
wanglinsong/thx-webservice | src/main/java/com/tascape/qa/th/ws/comm/WebServiceCommunication.java | WebServiceCommunication.postJson | public String postJson(String endpoint, JSONObject json) throws IOException {
"""
Issues HTTP POST request, returns response body as string.
@param endpoint endpoint of request url
@param json request body
@return response body
@throws IOException in case of any IO related issue
"""
return this.postJson(endpoint, "", json);
} | java | public String postJson(String endpoint, JSONObject json) throws IOException {
return this.postJson(endpoint, "", json);
} | [
"public",
"String",
"postJson",
"(",
"String",
"endpoint",
",",
"JSONObject",
"json",
")",
"throws",
"IOException",
"{",
"return",
"this",
".",
"postJson",
"(",
"endpoint",
",",
"\"\"",
",",
"json",
")",
";",
"}"
] | Issues HTTP POST request, returns response body as string.
@param endpoint endpoint of request url
@param json request body
@return response body
@throws IOException in case of any IO related issue | [
"Issues",
"HTTP",
"POST",
"request",
"returns",
"response",
"body",
"as",
"string",
"."
] | train | https://github.com/wanglinsong/thx-webservice/blob/29bc084b09ad35b012eb7c6b5c9ee55337ddee28/src/main/java/com/tascape/qa/th/ws/comm/WebServiceCommunication.java#L847-L849 |
Azure/azure-sdk-for-java | datamigration/resource-manager/v2017_11_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2017_11_15_preview/implementation/ServicesInner.java | ServicesInner.startAsync | public Observable<Void> startAsync(String groupName, String serviceName) {
"""
Start service.
The services resource is the top-level resource that represents the Data Migration Service. This action starts the service and the service can be used for data migration.
@param groupName Name of the resource group
@param serviceName Name of the service
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return startWithServiceResponseAsync(groupName, serviceName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> startAsync(String groupName, String serviceName) {
return startWithServiceResponseAsync(groupName, serviceName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"startAsync",
"(",
"String",
"groupName",
",",
"String",
"serviceName",
")",
"{",
"return",
"startWithServiceResponseAsync",
"(",
"groupName",
",",
"serviceName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Start service.
The services resource is the top-level resource that represents the Data Migration Service. This action starts the service and the service can be used for data migration.
@param groupName Name of the resource group
@param serviceName Name of the service
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Start",
"service",
".",
"The",
"services",
"resource",
"is",
"the",
"top",
"-",
"level",
"resource",
"that",
"represents",
"the",
"Data",
"Migration",
"Service",
".",
"This",
"action",
"starts",
"the",
"service",
"and",
"the",
"service",
"can",
"be",
"used",
"for",
"data",
"migration",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datamigration/resource-manager/v2017_11_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2017_11_15_preview/implementation/ServicesInner.java#L1056-L1063 |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/LongTermRetentionBackupsInner.java | LongTermRetentionBackupsInner.listByServerWithServiceResponseAsync | public Observable<ServiceResponse<Page<LongTermRetentionBackupInner>>> listByServerWithServiceResponseAsync(final String locationName, final String longTermRetentionServerName, final Boolean onlyLatestPerDatabase, final LongTermRetentionDatabaseState databaseState) {
"""
Lists the long term retention backups for a given server.
@param locationName The location of the database
@param longTermRetentionServerName the String value
@param onlyLatestPerDatabase Whether or not to only get the latest backup for each database.
@param databaseState Whether to query against just live databases, just deleted databases, or all databases. Possible values include: 'All', 'Live', 'Deleted'
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<LongTermRetentionBackupInner> object
"""
return listByServerSinglePageAsync(locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState)
.concatMap(new Func1<ServiceResponse<Page<LongTermRetentionBackupInner>>, Observable<ServiceResponse<Page<LongTermRetentionBackupInner>>>>() {
@Override
public Observable<ServiceResponse<Page<LongTermRetentionBackupInner>>> call(ServiceResponse<Page<LongTermRetentionBackupInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listByServerNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<LongTermRetentionBackupInner>>> listByServerWithServiceResponseAsync(final String locationName, final String longTermRetentionServerName, final Boolean onlyLatestPerDatabase, final LongTermRetentionDatabaseState databaseState) {
return listByServerSinglePageAsync(locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState)
.concatMap(new Func1<ServiceResponse<Page<LongTermRetentionBackupInner>>, Observable<ServiceResponse<Page<LongTermRetentionBackupInner>>>>() {
@Override
public Observable<ServiceResponse<Page<LongTermRetentionBackupInner>>> call(ServiceResponse<Page<LongTermRetentionBackupInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listByServerNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
">",
">",
"listByServerWithServiceResponseAsync",
"(",
"final",
"String",
"locationName",
",",
"final",
"String",
"longTermRetentionServerName",
",",
"final",
"Boolean",
"onlyLatestPerDatabase",
",",
"final",
"LongTermRetentionDatabaseState",
"databaseState",
")",
"{",
"return",
"listByServerSinglePageAsync",
"(",
"locationName",
",",
"longTermRetentionServerName",
",",
"onlyLatestPerDatabase",
",",
"databaseState",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listByServerNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Lists the long term retention backups for a given server.
@param locationName The location of the database
@param longTermRetentionServerName the String value
@param onlyLatestPerDatabase Whether or not to only get the latest backup for each database.
@param databaseState Whether to query against just live databases, just deleted databases, or all databases. Possible values include: 'All', 'Live', 'Deleted'
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<LongTermRetentionBackupInner> object | [
"Lists",
"the",
"long",
"term",
"retention",
"backups",
"for",
"a",
"given",
"server",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/LongTermRetentionBackupsInner.java#L1077-L1089 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/JBBPParser.java | JBBPParser.assertArrayLength | private static void assertArrayLength(final int length, final JBBPNamedFieldInfo name) {
"""
Ensure that an array length is not a negative one.
@param length the array length to be checked
@param name the name information of a field, it can be null
"""
if (length < 0) {
throw new JBBPParsingException("Detected negative calculated array length for field '" + (name == null ? "<NO NAME>" : name.getFieldPath()) + "\' [" + JBBPUtils.int2msg(length) + ']');
}
} | java | private static void assertArrayLength(final int length, final JBBPNamedFieldInfo name) {
if (length < 0) {
throw new JBBPParsingException("Detected negative calculated array length for field '" + (name == null ? "<NO NAME>" : name.getFieldPath()) + "\' [" + JBBPUtils.int2msg(length) + ']');
}
} | [
"private",
"static",
"void",
"assertArrayLength",
"(",
"final",
"int",
"length",
",",
"final",
"JBBPNamedFieldInfo",
"name",
")",
"{",
"if",
"(",
"length",
"<",
"0",
")",
"{",
"throw",
"new",
"JBBPParsingException",
"(",
"\"Detected negative calculated array length for field '\"",
"+",
"(",
"name",
"==",
"null",
"?",
"\"<NO NAME>\"",
":",
"name",
".",
"getFieldPath",
"(",
")",
")",
"+",
"\"\\' [\"",
"+",
"JBBPUtils",
".",
"int2msg",
"(",
"length",
")",
"+",
"'",
"'",
")",
";",
"}",
"}"
] | Ensure that an array length is not a negative one.
@param length the array length to be checked
@param name the name information of a field, it can be null | [
"Ensure",
"that",
"an",
"array",
"length",
"is",
"not",
"a",
"negative",
"one",
"."
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/JBBPParser.java#L146-L150 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/Deflater.java | Deflater.setDictionary | public void setDictionary(byte[] b, int off, int len) {
"""
Sets preset dictionary for compression. A preset dictionary is used
when the history buffer can be predetermined. When the data is later
uncompressed with Inflater.inflate(), Inflater.getAdler() can be called
in order to get the Adler-32 value of the dictionary required for
decompression.
@param b the dictionary data bytes
@param off the start offset of the data
@param len the length of the data
@see Inflater#inflate
@see Inflater#getAdler
"""
if (b == null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
synchronized (zsRef) {
ensureOpen();
setDictionary(zsRef.address(), b, off, len);
}
} | java | public void setDictionary(byte[] b, int off, int len) {
if (b == null) {
throw new NullPointerException();
}
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
synchronized (zsRef) {
ensureOpen();
setDictionary(zsRef.address(), b, off, len);
}
} | [
"public",
"void",
"setDictionary",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"if",
"(",
"b",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"if",
"(",
"off",
"<",
"0",
"||",
"len",
"<",
"0",
"||",
"off",
">",
"b",
".",
"length",
"-",
"len",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
")",
";",
"}",
"synchronized",
"(",
"zsRef",
")",
"{",
"ensureOpen",
"(",
")",
";",
"setDictionary",
"(",
"zsRef",
".",
"address",
"(",
")",
",",
"b",
",",
"off",
",",
"len",
")",
";",
"}",
"}"
] | Sets preset dictionary for compression. A preset dictionary is used
when the history buffer can be predetermined. When the data is later
uncompressed with Inflater.inflate(), Inflater.getAdler() can be called
in order to get the Adler-32 value of the dictionary required for
decompression.
@param b the dictionary data bytes
@param off the start offset of the data
@param len the length of the data
@see Inflater#inflate
@see Inflater#getAdler | [
"Sets",
"preset",
"dictionary",
"for",
"compression",
".",
"A",
"preset",
"dictionary",
"is",
"used",
"when",
"the",
"history",
"buffer",
"can",
"be",
"predetermined",
".",
"When",
"the",
"data",
"is",
"later",
"uncompressed",
"with",
"Inflater",
".",
"inflate",
"()",
"Inflater",
".",
"getAdler",
"()",
"can",
"be",
"called",
"in",
"order",
"to",
"get",
"the",
"Adler",
"-",
"32",
"value",
"of",
"the",
"dictionary",
"required",
"for",
"decompression",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/zip/Deflater.java#L237-L248 |
jeremylong/DependencyCheck | utils/src/main/java/org/owasp/dependencycheck/utils/Settings.java | Settings.setBooleanIfNotNull | public void setBooleanIfNotNull(@NotNull final String key, @Nullable final Boolean value) {
"""
Sets a property value only if the value is not null.
@param key the key for the property
@param value the value for the property
"""
if (null != value) {
setBoolean(key, value);
}
} | java | public void setBooleanIfNotNull(@NotNull final String key, @Nullable final Boolean value) {
if (null != value) {
setBoolean(key, value);
}
} | [
"public",
"void",
"setBooleanIfNotNull",
"(",
"@",
"NotNull",
"final",
"String",
"key",
",",
"@",
"Nullable",
"final",
"Boolean",
"value",
")",
"{",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"setBoolean",
"(",
"key",
",",
"value",
")",
";",
"}",
"}"
] | Sets a property value only if the value is not null.
@param key the key for the property
@param value the value for the property | [
"Sets",
"a",
"property",
"value",
"only",
"if",
"the",
"value",
"is",
"not",
"null",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/Settings.java#L734-L738 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/SearchFilter.java | SearchFilter.matchSet | public void matchSet(String[] ElementNames, String[] ElementValues, int op) throws DBException {
"""
Change the search filter to one that specifies a set of elements and their values
that must match, and the operator to use to combine the elements.
Each element name is compared for an equal match to the value, and all
comparisons are combined by the specified logical operator (OR or AND).
The old search filter is deleted.
@param ElementNames is an array of names of elements to be tested
@param ElementValues is an array of values for the corresponding element
@param op is the logical operator to be used to combine the comparisons
@exception DBException
"""
// Delete the old search filter
m_filter = null;
// If this is not a logical operator, throw an exception
if ((op & LOGICAL_OPER_MASK) == 0)
{
throw new DBException();
// Create a vector that will hold the leaf nodes for all elements in the hashtable
}
Vector leafVector = new Vector();
// For each of the elements in the array, create a leaf node for the match
int numnames = ElementNames.length;
for (int i = 0; i < numnames; i++)
{
// Create a leaf node for this list and store it as the filter
SearchBaseLeaf leafnode = new SearchBaseLeaf(ElementNames[i], IN, ElementValues[i]);
// Add this leaf node to the vector
leafVector.addElement(leafnode);
}
// Now return a node that holds this set of leaf nodes
m_filter = new SearchBaseNode(op, leafVector);
} | java | public void matchSet(String[] ElementNames, String[] ElementValues, int op) throws DBException
{
// Delete the old search filter
m_filter = null;
// If this is not a logical operator, throw an exception
if ((op & LOGICAL_OPER_MASK) == 0)
{
throw new DBException();
// Create a vector that will hold the leaf nodes for all elements in the hashtable
}
Vector leafVector = new Vector();
// For each of the elements in the array, create a leaf node for the match
int numnames = ElementNames.length;
for (int i = 0; i < numnames; i++)
{
// Create a leaf node for this list and store it as the filter
SearchBaseLeaf leafnode = new SearchBaseLeaf(ElementNames[i], IN, ElementValues[i]);
// Add this leaf node to the vector
leafVector.addElement(leafnode);
}
// Now return a node that holds this set of leaf nodes
m_filter = new SearchBaseNode(op, leafVector);
} | [
"public",
"void",
"matchSet",
"(",
"String",
"[",
"]",
"ElementNames",
",",
"String",
"[",
"]",
"ElementValues",
",",
"int",
"op",
")",
"throws",
"DBException",
"{",
"// Delete the old search filter\r",
"m_filter",
"=",
"null",
";",
"// If this is not a logical operator, throw an exception\r",
"if",
"(",
"(",
"op",
"&",
"LOGICAL_OPER_MASK",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"DBException",
"(",
")",
";",
"// Create a vector that will hold the leaf nodes for all elements in the hashtable\r",
"}",
"Vector",
"leafVector",
"=",
"new",
"Vector",
"(",
")",
";",
"// For each of the elements in the array, create a leaf node for the match\r",
"int",
"numnames",
"=",
"ElementNames",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numnames",
";",
"i",
"++",
")",
"{",
"// Create a leaf node for this list and store it as the filter\r",
"SearchBaseLeaf",
"leafnode",
"=",
"new",
"SearchBaseLeaf",
"(",
"ElementNames",
"[",
"i",
"]",
",",
"IN",
",",
"ElementValues",
"[",
"i",
"]",
")",
";",
"// Add this leaf node to the vector\r",
"leafVector",
".",
"addElement",
"(",
"leafnode",
")",
";",
"}",
"// Now return a node that holds this set of leaf nodes\r",
"m_filter",
"=",
"new",
"SearchBaseNode",
"(",
"op",
",",
"leafVector",
")",
";",
"}"
] | Change the search filter to one that specifies a set of elements and their values
that must match, and the operator to use to combine the elements.
Each element name is compared for an equal match to the value, and all
comparisons are combined by the specified logical operator (OR or AND).
The old search filter is deleted.
@param ElementNames is an array of names of elements to be tested
@param ElementValues is an array of values for the corresponding element
@param op is the logical operator to be used to combine the comparisons
@exception DBException | [
"Change",
"the",
"search",
"filter",
"to",
"one",
"that",
"specifies",
"a",
"set",
"of",
"elements",
"and",
"their",
"values",
"that",
"must",
"match",
"and",
"the",
"operator",
"to",
"use",
"to",
"combine",
"the",
"elements",
".",
"Each",
"element",
"name",
"is",
"compared",
"for",
"an",
"equal",
"match",
"to",
"the",
"value",
"and",
"all",
"comparisons",
"are",
"combined",
"by",
"the",
"specified",
"logical",
"operator",
"(",
"OR",
"or",
"AND",
")",
".",
"The",
"old",
"search",
"filter",
"is",
"deleted",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/SearchFilter.java#L266-L288 |
apiman/apiman | manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java | AuditUtils.organizationCreated | public static AuditEntryBean organizationCreated(OrganizationBean bean, ISecurityContext securityContext) {
"""
Creates an {@link AuditEntryBean} for the 'organization created' event.
@param bean the bean
@param securityContext the security context
@return the audit entry
"""
AuditEntryBean entry = newEntry(bean.getId(), AuditEntityType.Organization, securityContext);
entry.setEntityId(null);
entry.setEntityVersion(null);
entry.setWhat(AuditEntryType.Create);
return entry;
} | java | public static AuditEntryBean organizationCreated(OrganizationBean bean, ISecurityContext securityContext) {
AuditEntryBean entry = newEntry(bean.getId(), AuditEntityType.Organization, securityContext);
entry.setEntityId(null);
entry.setEntityVersion(null);
entry.setWhat(AuditEntryType.Create);
return entry;
} | [
"public",
"static",
"AuditEntryBean",
"organizationCreated",
"(",
"OrganizationBean",
"bean",
",",
"ISecurityContext",
"securityContext",
")",
"{",
"AuditEntryBean",
"entry",
"=",
"newEntry",
"(",
"bean",
".",
"getId",
"(",
")",
",",
"AuditEntityType",
".",
"Organization",
",",
"securityContext",
")",
";",
"entry",
".",
"setEntityId",
"(",
"null",
")",
";",
"entry",
".",
"setEntityVersion",
"(",
"null",
")",
";",
"entry",
".",
"setWhat",
"(",
"AuditEntryType",
".",
"Create",
")",
";",
"return",
"entry",
";",
"}"
] | Creates an {@link AuditEntryBean} for the 'organization created' event.
@param bean the bean
@param securityContext the security context
@return the audit entry | [
"Creates",
"an",
"{"
] | train | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L188-L194 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/string/Levenshtein.java | Levenshtein.sorensenDice | public static <T extends Levenshtein> T sorensenDice(String baseTarget, String compareTarget) {
"""
Returns a new Sorensen-Dice coefficient instance with compare target string
@see SorensenDice
@param baseTarget
@param compareTarget
@return
"""
return sorensenDice(baseTarget, compareTarget, null);
} | java | public static <T extends Levenshtein> T sorensenDice(String baseTarget, String compareTarget) {
return sorensenDice(baseTarget, compareTarget, null);
} | [
"public",
"static",
"<",
"T",
"extends",
"Levenshtein",
">",
"T",
"sorensenDice",
"(",
"String",
"baseTarget",
",",
"String",
"compareTarget",
")",
"{",
"return",
"sorensenDice",
"(",
"baseTarget",
",",
"compareTarget",
",",
"null",
")",
";",
"}"
] | Returns a new Sorensen-Dice coefficient instance with compare target string
@see SorensenDice
@param baseTarget
@param compareTarget
@return | [
"Returns",
"a",
"new",
"Sorensen",
"-",
"Dice",
"coefficient",
"instance",
"with",
"compare",
"target",
"string"
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/string/Levenshtein.java#L295-L297 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_voicemail_serviceName_settings_changePassword_POST | public void billingAccount_voicemail_serviceName_settings_changePassword_POST(String billingAccount, String serviceName, String password) throws IOException {
"""
Change the voicemail password. It must be 4 digit
REST: POST /telephony/{billingAccount}/voicemail/{serviceName}/settings/changePassword
@param password [required] The password
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
"""
String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/settings/changePassword";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "password", password);
exec(qPath, "POST", sb.toString(), o);
} | java | public void billingAccount_voicemail_serviceName_settings_changePassword_POST(String billingAccount, String serviceName, String password) throws IOException {
String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/settings/changePassword";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "password", password);
exec(qPath, "POST", sb.toString(), o);
} | [
"public",
"void",
"billingAccount_voicemail_serviceName_settings_changePassword_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"String",
"password",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/voicemail/{serviceName}/settings/changePassword\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"password\"",
",",
"password",
")",
";",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"}"
] | Change the voicemail password. It must be 4 digit
REST: POST /telephony/{billingAccount}/voicemail/{serviceName}/settings/changePassword
@param password [required] The password
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] | [
"Change",
"the",
"voicemail",
"password",
".",
"It",
"must",
"be",
"4",
"digit"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L7971-L7977 |
apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/util/JobStateToJsonConverter.java | JobStateToJsonConverter.writeJobState | private void writeJobState(JsonWriter jsonWriter, JobState jobState) throws IOException {
"""
Write a single {@link JobState} to json document.
@param jsonWriter {@link com.google.gson.stream.JsonWriter}
@param jobState {@link JobState} to write to json document
@throws IOException
"""
jobState.toJson(jsonWriter, this.keepConfig);
} | java | private void writeJobState(JsonWriter jsonWriter, JobState jobState) throws IOException {
jobState.toJson(jsonWriter, this.keepConfig);
} | [
"private",
"void",
"writeJobState",
"(",
"JsonWriter",
"jsonWriter",
",",
"JobState",
"jobState",
")",
"throws",
"IOException",
"{",
"jobState",
".",
"toJson",
"(",
"jsonWriter",
",",
"this",
".",
"keepConfig",
")",
";",
"}"
] | Write a single {@link JobState} to json document.
@param jsonWriter {@link com.google.gson.stream.JsonWriter}
@param jobState {@link JobState} to write to json document
@throws IOException | [
"Write",
"a",
"single",
"{",
"@link",
"JobState",
"}",
"to",
"json",
"document",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/util/JobStateToJsonConverter.java#L137-L139 |
Graylog2/graylog2-server | graylog2-server/src/main/java/org/graylog2/indexer/cluster/Cluster.java | Cluster.waitForConnectedAndDeflectorHealthy | public void waitForConnectedAndDeflectorHealthy(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
"""
Blocks until the Elasticsearch cluster and current write index is healthy again or the given timeout fires.
@param timeout the timeout value
@param unit the timeout unit
@throws InterruptedException
@throws TimeoutException
"""
LOG.debug("Waiting until the write-active index is healthy again, checking once per second.");
final CountDownLatch latch = new CountDownLatch(1);
final ScheduledFuture<?> scheduledFuture = scheduler.scheduleAtFixedRate(() -> {
try {
if (isConnected() && isDeflectorHealthy()) {
LOG.debug("Write-active index is healthy again, unblocking waiting threads.");
latch.countDown();
}
} catch (Exception ignore) {
} // to not cancel the schedule
}, 0, 1, TimeUnit.SECONDS); // TODO should this be configurable?
final boolean waitSuccess = latch.await(timeout, unit);
scheduledFuture.cancel(true); // Make sure to cancel the task to avoid task leaks!
if (!waitSuccess) {
throw new TimeoutException("Write-active index didn't get healthy within timeout");
}
} | java | public void waitForConnectedAndDeflectorHealthy(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
LOG.debug("Waiting until the write-active index is healthy again, checking once per second.");
final CountDownLatch latch = new CountDownLatch(1);
final ScheduledFuture<?> scheduledFuture = scheduler.scheduleAtFixedRate(() -> {
try {
if (isConnected() && isDeflectorHealthy()) {
LOG.debug("Write-active index is healthy again, unblocking waiting threads.");
latch.countDown();
}
} catch (Exception ignore) {
} // to not cancel the schedule
}, 0, 1, TimeUnit.SECONDS); // TODO should this be configurable?
final boolean waitSuccess = latch.await(timeout, unit);
scheduledFuture.cancel(true); // Make sure to cancel the task to avoid task leaks!
if (!waitSuccess) {
throw new TimeoutException("Write-active index didn't get healthy within timeout");
}
} | [
"public",
"void",
"waitForConnectedAndDeflectorHealthy",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
",",
"TimeoutException",
"{",
"LOG",
".",
"debug",
"(",
"\"Waiting until the write-active index is healthy again, checking once per second.\"",
")",
";",
"final",
"CountDownLatch",
"latch",
"=",
"new",
"CountDownLatch",
"(",
"1",
")",
";",
"final",
"ScheduledFuture",
"<",
"?",
">",
"scheduledFuture",
"=",
"scheduler",
".",
"scheduleAtFixedRate",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"if",
"(",
"isConnected",
"(",
")",
"&&",
"isDeflectorHealthy",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Write-active index is healthy again, unblocking waiting threads.\"",
")",
";",
"latch",
".",
"countDown",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ignore",
")",
"{",
"}",
"// to not cancel the schedule",
"}",
",",
"0",
",",
"1",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"// TODO should this be configurable?",
"final",
"boolean",
"waitSuccess",
"=",
"latch",
".",
"await",
"(",
"timeout",
",",
"unit",
")",
";",
"scheduledFuture",
".",
"cancel",
"(",
"true",
")",
";",
"// Make sure to cancel the task to avoid task leaks!",
"if",
"(",
"!",
"waitSuccess",
")",
"{",
"throw",
"new",
"TimeoutException",
"(",
"\"Write-active index didn't get healthy within timeout\"",
")",
";",
"}",
"}"
] | Blocks until the Elasticsearch cluster and current write index is healthy again or the given timeout fires.
@param timeout the timeout value
@param unit the timeout unit
@throws InterruptedException
@throws TimeoutException | [
"Blocks",
"until",
"the",
"Elasticsearch",
"cluster",
"and",
"current",
"write",
"index",
"is",
"healthy",
"again",
"or",
"the",
"given",
"timeout",
"fires",
"."
] | train | https://github.com/Graylog2/graylog2-server/blob/50b565dcead6e0a372236d5c2f8530dc5726fa9b/graylog2-server/src/main/java/org/graylog2/indexer/cluster/Cluster.java#L215-L235 |
OpenLiberty/open-liberty | dev/com.ibm.ws.event/src/com/ibm/ws/event/internal/EventEngineImpl.java | EventEngineImpl.checkTopicPublishPermission | void checkTopicPublishPermission(String topic) {
"""
Check if the caller has permission to publish events to the specified
topic.
@param topic
the topic the event is being published to
"""
SecurityManager sm = System.getSecurityManager();
if (sm == null)
return;
sm.checkPermission(new TopicPermission(topic, PUBLISH));
} | java | void checkTopicPublishPermission(String topic) {
SecurityManager sm = System.getSecurityManager();
if (sm == null)
return;
sm.checkPermission(new TopicPermission(topic, PUBLISH));
} | [
"void",
"checkTopicPublishPermission",
"(",
"String",
"topic",
")",
"{",
"SecurityManager",
"sm",
"=",
"System",
".",
"getSecurityManager",
"(",
")",
";",
"if",
"(",
"sm",
"==",
"null",
")",
"return",
";",
"sm",
".",
"checkPermission",
"(",
"new",
"TopicPermission",
"(",
"topic",
",",
"PUBLISH",
")",
")",
";",
"}"
] | Check if the caller has permission to publish events to the specified
topic.
@param topic
the topic the event is being published to | [
"Check",
"if",
"the",
"caller",
"has",
"permission",
"to",
"publish",
"events",
"to",
"the",
"specified",
"topic",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.event/src/com/ibm/ws/event/internal/EventEngineImpl.java#L323-L329 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java | Utils.toLightweightTypeReference | public static LightweightTypeReference toLightweightTypeReference(
JvmTypeReference typeRef, CommonTypeComputationServices services,
boolean keepUnboundWildcardInformation) {
"""
Convert a type reference to a lightweight type reference.
@param typeRef - reference to convert.
@param services - services used for the conversion
@param keepUnboundWildcardInformation - indicates if the unbound wild card
information must be keeped in the lightweight reference.
@return the lightweight type reference.
"""
if (typeRef == null) {
return null;
}
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, typeRef);
final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner,
keepUnboundWildcardInformation);
final LightweightTypeReference reference = factory.toLightweightReference(typeRef);
return reference;
} | java | public static LightweightTypeReference toLightweightTypeReference(
JvmTypeReference typeRef, CommonTypeComputationServices services,
boolean keepUnboundWildcardInformation) {
if (typeRef == null) {
return null;
}
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, typeRef);
final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner,
keepUnboundWildcardInformation);
final LightweightTypeReference reference = factory.toLightweightReference(typeRef);
return reference;
} | [
"public",
"static",
"LightweightTypeReference",
"toLightweightTypeReference",
"(",
"JvmTypeReference",
"typeRef",
",",
"CommonTypeComputationServices",
"services",
",",
"boolean",
"keepUnboundWildcardInformation",
")",
"{",
"if",
"(",
"typeRef",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"StandardTypeReferenceOwner",
"owner",
"=",
"new",
"StandardTypeReferenceOwner",
"(",
"services",
",",
"typeRef",
")",
";",
"final",
"LightweightTypeReferenceFactory",
"factory",
"=",
"new",
"LightweightTypeReferenceFactory",
"(",
"owner",
",",
"keepUnboundWildcardInformation",
")",
";",
"final",
"LightweightTypeReference",
"reference",
"=",
"factory",
".",
"toLightweightReference",
"(",
"typeRef",
")",
";",
"return",
"reference",
";",
"}"
] | Convert a type reference to a lightweight type reference.
@param typeRef - reference to convert.
@param services - services used for the conversion
@param keepUnboundWildcardInformation - indicates if the unbound wild card
information must be keeped in the lightweight reference.
@return the lightweight type reference. | [
"Convert",
"a",
"type",
"reference",
"to",
"a",
"lightweight",
"type",
"reference",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/util/Utils.java#L608-L619 |
Trilarion/java-vorbis-support | src/main/java/com/github/trilarion/sound/sampled/spi/TAudioFileReader.java | TAudioFileReader.getAudioFileFormat | @Override
public AudioFileFormat getAudioFileFormat(InputStream inputStream)
throws UnsupportedAudioFileException, IOException {
"""
Get an AudioFileFormat object for an InputStream. This method calls
getAudioFileFormat(InputStream, long). Subclasses should not override
this method unless there are really severe reasons. Normally, it is
sufficient to implement getAudioFileFormat(InputStream, long).
@param inputStream the stream to read from.
@return an AudioFileFormat instance containing information from the
header of the stream passed in.
@throws javax.sound.sampled.UnsupportedAudioFileException
@throws java.io.IOException
"""
LOG.log(Level.FINE, "TAudioFileReader.getAudioFileFormat(InputStream): begin (class: {0})", getClass().getSimpleName());
long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED;
if (!inputStream.markSupported()) {
inputStream = new BufferedInputStream(inputStream, getMarkLimit());
}
inputStream.mark(getMarkLimit());
AudioFileFormat audioFileFormat;
try {
audioFileFormat = getAudioFileFormat(inputStream, lFileLengthInBytes);
} finally {
/* TODO: required semantics is unclear: should reset()
be executed only when there is an exception or
should it be done always?
*/
inputStream.reset();
}
LOG.log(Level.FINE, "TAudioFileReader.getAudioFileFormat(InputStream): end");
return audioFileFormat;
} | java | @Override
public AudioFileFormat getAudioFileFormat(InputStream inputStream)
throws UnsupportedAudioFileException, IOException {
LOG.log(Level.FINE, "TAudioFileReader.getAudioFileFormat(InputStream): begin (class: {0})", getClass().getSimpleName());
long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED;
if (!inputStream.markSupported()) {
inputStream = new BufferedInputStream(inputStream, getMarkLimit());
}
inputStream.mark(getMarkLimit());
AudioFileFormat audioFileFormat;
try {
audioFileFormat = getAudioFileFormat(inputStream, lFileLengthInBytes);
} finally {
/* TODO: required semantics is unclear: should reset()
be executed only when there is an exception or
should it be done always?
*/
inputStream.reset();
}
LOG.log(Level.FINE, "TAudioFileReader.getAudioFileFormat(InputStream): end");
return audioFileFormat;
} | [
"@",
"Override",
"public",
"AudioFileFormat",
"getAudioFileFormat",
"(",
"InputStream",
"inputStream",
")",
"throws",
"UnsupportedAudioFileException",
",",
"IOException",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"TAudioFileReader.getAudioFileFormat(InputStream): begin (class: {0})\"",
",",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"long",
"lFileLengthInBytes",
"=",
"AudioSystem",
".",
"NOT_SPECIFIED",
";",
"if",
"(",
"!",
"inputStream",
".",
"markSupported",
"(",
")",
")",
"{",
"inputStream",
"=",
"new",
"BufferedInputStream",
"(",
"inputStream",
",",
"getMarkLimit",
"(",
")",
")",
";",
"}",
"inputStream",
".",
"mark",
"(",
"getMarkLimit",
"(",
")",
")",
";",
"AudioFileFormat",
"audioFileFormat",
";",
"try",
"{",
"audioFileFormat",
"=",
"getAudioFileFormat",
"(",
"inputStream",
",",
"lFileLengthInBytes",
")",
";",
"}",
"finally",
"{",
"/* TODO: required semantics is unclear: should reset()\n be executed only when there is an exception or\n should it be done always?\n */",
"inputStream",
".",
"reset",
"(",
")",
";",
"}",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"TAudioFileReader.getAudioFileFormat(InputStream): end\"",
")",
";",
"return",
"audioFileFormat",
";",
"}"
] | Get an AudioFileFormat object for an InputStream. This method calls
getAudioFileFormat(InputStream, long). Subclasses should not override
this method unless there are really severe reasons. Normally, it is
sufficient to implement getAudioFileFormat(InputStream, long).
@param inputStream the stream to read from.
@return an AudioFileFormat instance containing information from the
header of the stream passed in.
@throws javax.sound.sampled.UnsupportedAudioFileException
@throws java.io.IOException | [
"Get",
"an",
"AudioFileFormat",
"object",
"for",
"an",
"InputStream",
".",
"This",
"method",
"calls",
"getAudioFileFormat",
"(",
"InputStream",
"long",
")",
".",
"Subclasses",
"should",
"not",
"override",
"this",
"method",
"unless",
"there",
"are",
"really",
"severe",
"reasons",
".",
"Normally",
"it",
"is",
"sufficient",
"to",
"implement",
"getAudioFileFormat",
"(",
"InputStream",
"long",
")",
"."
] | train | https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/sampled/spi/TAudioFileReader.java#L132-L153 |
salesforce/Argus | ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/resources/AlertResources.java | AlertResources.deleteAlert | @DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("/ {
"""
Deletes the alert.
@param req The HttpServlet request object. Cannot be null.
@param alertId The alert Id. Cannot be null and must be a positive non-zero number.
@return REST response indicating whether the alert deletion was successful.
@throws WebApplicationException The exception with 404 status will be thrown if an alert does not exist.
"""alertId}")
@Description("Deletes the alert having the given ID along with all its triggers and notifications.")
public Response deleteAlert(@Context HttpServletRequest req,
@PathParam("alertId") BigInteger alertId) {
if (alertId == null || alertId.compareTo(BigInteger.ZERO) < 1) {
throw new WebApplicationException("Alert Id cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
}
Alert alert = alertService.findAlertByPrimaryKey(alertId);
if (alert != null) {
validateResourceAuthorization(req, alert.getOwner(), getRemoteUser(req));
alertService.markAlertForDeletion(alert);
return Response.status(Status.OK).build();
}
throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
} | java | @DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("/{alertId}")
@Description("Deletes the alert having the given ID along with all its triggers and notifications.")
public Response deleteAlert(@Context HttpServletRequest req,
@PathParam("alertId") BigInteger alertId) {
if (alertId == null || alertId.compareTo(BigInteger.ZERO) < 1) {
throw new WebApplicationException("Alert Id cannot be null and must be a positive non-zero number.", Status.BAD_REQUEST);
}
Alert alert = alertService.findAlertByPrimaryKey(alertId);
if (alert != null) {
validateResourceAuthorization(req, alert.getOwner(), getRemoteUser(req));
alertService.markAlertForDeletion(alert);
return Response.status(Status.OK).build();
}
throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
} | [
"@",
"DELETE",
"@",
"Produces",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"@",
"Path",
"(",
"\"/{alertId}\"",
")",
"@",
"Description",
"(",
"\"Deletes the alert having the given ID along with all its triggers and notifications.\"",
")",
"public",
"Response",
"deleteAlert",
"(",
"@",
"Context",
"HttpServletRequest",
"req",
",",
"@",
"PathParam",
"(",
"\"alertId\"",
")",
"BigInteger",
"alertId",
")",
"{",
"if",
"(",
"alertId",
"==",
"null",
"||",
"alertId",
".",
"compareTo",
"(",
"BigInteger",
".",
"ZERO",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"Alert Id cannot be null and must be a positive non-zero number.\"",
",",
"Status",
".",
"BAD_REQUEST",
")",
";",
"}",
"Alert",
"alert",
"=",
"alertService",
".",
"findAlertByPrimaryKey",
"(",
"alertId",
")",
";",
"if",
"(",
"alert",
"!=",
"null",
")",
"{",
"validateResourceAuthorization",
"(",
"req",
",",
"alert",
".",
"getOwner",
"(",
")",
",",
"getRemoteUser",
"(",
"req",
")",
")",
";",
"alertService",
".",
"markAlertForDeletion",
"(",
"alert",
")",
";",
"return",
"Response",
".",
"status",
"(",
"Status",
".",
"OK",
")",
".",
"build",
"(",
")",
";",
"}",
"throw",
"new",
"WebApplicationException",
"(",
"Response",
".",
"Status",
".",
"NOT_FOUND",
".",
"getReasonPhrase",
"(",
")",
",",
"Response",
".",
"Status",
".",
"NOT_FOUND",
")",
";",
"}"
] | Deletes the alert.
@param req The HttpServlet request object. Cannot be null.
@param alertId The alert Id. Cannot be null and must be a positive non-zero number.
@return REST response indicating whether the alert deletion was successful.
@throws WebApplicationException The exception with 404 status will be thrown if an alert does not exist. | [
"Deletes",
"the",
"alert",
"."
] | train | https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/resources/AlertResources.java#L980-L998 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/time/DateUtils.java | DateUtils.setYears | public static Date setYears(final Date date, final int amount) {
"""
Sets the years field to a date returning a new object.
The original {@code Date} is unchanged.
@param date the date, not null
@param amount the amount to set
@return a new {@code Date} set with the specified value
@throws IllegalArgumentException if the date is null
@since 2.4
"""
return set(date, Calendar.YEAR, amount);
} | java | public static Date setYears(final Date date, final int amount) {
return set(date, Calendar.YEAR, amount);
} | [
"public",
"static",
"Date",
"setYears",
"(",
"final",
"Date",
"date",
",",
"final",
"int",
"amount",
")",
"{",
"return",
"set",
"(",
"date",
",",
"Calendar",
".",
"YEAR",
",",
"amount",
")",
";",
"}"
] | Sets the years field to a date returning a new object.
The original {@code Date} is unchanged.
@param date the date, not null
@param amount the amount to set
@return a new {@code Date} set with the specified value
@throws IllegalArgumentException if the date is null
@since 2.4 | [
"Sets",
"the",
"years",
"field",
"to",
"a",
"date",
"returning",
"a",
"new",
"object",
".",
"The",
"original",
"{",
"@code",
"Date",
"}",
"is",
"unchanged",
"."
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/time/DateUtils.java#L540-L542 |
kite-sdk/kite | kite-data/kite-data-core/src/main/java/org/kitesdk/data/spi/Compatibility.java | Compatibility.checkAndWarn | public static void checkAndWarn(String namespace, String datasetName, Schema schema) {
"""
Checks the name and schema for known compatibility issues and warns.
If the column names are not compatible across components, this will warn
the user.
@param namespace a String namespace
@param datasetName a String dataset name
@param schema a {@link Schema}
"""
try {
checkDatasetName(namespace, datasetName);
checkSchema(schema);
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage());
} catch (IllegalStateException e) {
LOG.warn(e.getMessage());
}
} | java | public static void checkAndWarn(String namespace, String datasetName, Schema schema) {
try {
checkDatasetName(namespace, datasetName);
checkSchema(schema);
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage());
} catch (IllegalStateException e) {
LOG.warn(e.getMessage());
}
} | [
"public",
"static",
"void",
"checkAndWarn",
"(",
"String",
"namespace",
",",
"String",
"datasetName",
",",
"Schema",
"schema",
")",
"{",
"try",
"{",
"checkDatasetName",
"(",
"namespace",
",",
"datasetName",
")",
";",
"checkSchema",
"(",
"schema",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Checks the name and schema for known compatibility issues and warns.
If the column names are not compatible across components, this will warn
the user.
@param namespace a String namespace
@param datasetName a String dataset name
@param schema a {@link Schema} | [
"Checks",
"the",
"name",
"and",
"schema",
"for",
"known",
"compatibility",
"issues",
"and",
"warns",
"."
] | train | https://github.com/kite-sdk/kite/blob/72bfb4b1a881af85808cd7f14bc3e15160a1e811/kite-data/kite-data-core/src/main/java/org/kitesdk/data/spi/Compatibility.java#L82-L91 |
JRebirth/JRebirth | org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/facade/JRebirthEventBase.java | JRebirthEventBase.parseString | private void parseString(final String eventSerialized) {
"""
Parse the serialized string.
@param eventSerialized the serialized string
"""
final StringTokenizer st = new StringTokenizer(eventSerialized, ClassUtility.SEPARATOR);
if (st.countTokens() >= 5) {
sequence(Integer.parseInt(st.nextToken()))
.eventType(JRebirthEventType.valueOf(st.nextToken()))
.source(st.nextToken())
.target(st.nextToken())
.eventData(st.nextToken());
}
} | java | private void parseString(final String eventSerialized) {
final StringTokenizer st = new StringTokenizer(eventSerialized, ClassUtility.SEPARATOR);
if (st.countTokens() >= 5) {
sequence(Integer.parseInt(st.nextToken()))
.eventType(JRebirthEventType.valueOf(st.nextToken()))
.source(st.nextToken())
.target(st.nextToken())
.eventData(st.nextToken());
}
} | [
"private",
"void",
"parseString",
"(",
"final",
"String",
"eventSerialized",
")",
"{",
"final",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"eventSerialized",
",",
"ClassUtility",
".",
"SEPARATOR",
")",
";",
"if",
"(",
"st",
".",
"countTokens",
"(",
")",
">=",
"5",
")",
"{",
"sequence",
"(",
"Integer",
".",
"parseInt",
"(",
"st",
".",
"nextToken",
"(",
")",
")",
")",
".",
"eventType",
"(",
"JRebirthEventType",
".",
"valueOf",
"(",
"st",
".",
"nextToken",
"(",
")",
")",
")",
".",
"source",
"(",
"st",
".",
"nextToken",
"(",
")",
")",
".",
"target",
"(",
"st",
".",
"nextToken",
"(",
")",
")",
".",
"eventData",
"(",
"st",
".",
"nextToken",
"(",
")",
")",
";",
"}",
"}"
] | Parse the serialized string.
@param eventSerialized the serialized string | [
"Parse",
"the",
"serialized",
"string",
"."
] | train | https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/facade/JRebirthEventBase.java#L181-L190 |
pryzach/midao | midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java | QueryParameters.updateType | public QueryParameters updateType(String key, Integer type) {
"""
Updates type of specified key
@param key Key
@param type SQL Type
@return this instance of QueryParameters
"""
this.types.put(processKey(key), type);
return this;
} | java | public QueryParameters updateType(String key, Integer type) {
this.types.put(processKey(key), type);
return this;
} | [
"public",
"QueryParameters",
"updateType",
"(",
"String",
"key",
",",
"Integer",
"type",
")",
"{",
"this",
".",
"types",
".",
"put",
"(",
"processKey",
"(",
"key",
")",
",",
"type",
")",
";",
"return",
"this",
";",
"}"
] | Updates type of specified key
@param key Key
@param type SQL Type
@return this instance of QueryParameters | [
"Updates",
"type",
"of",
"specified",
"key"
] | train | https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/model/QueryParameters.java#L288-L292 |
FasterXML/woodstox | src/main/java/com/ctc/wstx/sr/BasicStreamReader.java | BasicStreamReader.checkCDataEnd | private boolean checkCDataEnd(char[] outBuf, int outPtr)
throws XMLStreamException {
"""
Method that will check, given the starting ']', whether there is
ending ']]>' (including optional extra ']'s); if so, will updated
output buffer with extra ]s, if not, will make sure input and output
are positioned for further checking.
@return True, if we hit the end marker; false if not.
"""
int bracketCount = 0;
char c;
do {
++bracketCount;
c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++]
: getNextCharFromCurrent(SUFFIX_IN_CDATA);
} while (c == ']');
boolean match = (bracketCount >= 2 && c == '>');
if (match) {
bracketCount -= 2;
}
while (bracketCount > 0) {
--bracketCount;
outBuf[outPtr++] = ']';
if (outPtr >= outBuf.length) {
/* Can't really easily return, even if we have enough
* stuff here, since we've more than one char...
*/
outBuf = mTextBuffer.finishCurrentSegment();
outPtr = 0;
}
}
mTextBuffer.setCurrentLength(outPtr);
// Match? Can break, then:
if (match) {
return true;
}
// No match, need to push the last char back and admit defeat...
--mInputPtr;
return false;
} | java | private boolean checkCDataEnd(char[] outBuf, int outPtr)
throws XMLStreamException
{
int bracketCount = 0;
char c;
do {
++bracketCount;
c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++]
: getNextCharFromCurrent(SUFFIX_IN_CDATA);
} while (c == ']');
boolean match = (bracketCount >= 2 && c == '>');
if (match) {
bracketCount -= 2;
}
while (bracketCount > 0) {
--bracketCount;
outBuf[outPtr++] = ']';
if (outPtr >= outBuf.length) {
/* Can't really easily return, even if we have enough
* stuff here, since we've more than one char...
*/
outBuf = mTextBuffer.finishCurrentSegment();
outPtr = 0;
}
}
mTextBuffer.setCurrentLength(outPtr);
// Match? Can break, then:
if (match) {
return true;
}
// No match, need to push the last char back and admit defeat...
--mInputPtr;
return false;
} | [
"private",
"boolean",
"checkCDataEnd",
"(",
"char",
"[",
"]",
"outBuf",
",",
"int",
"outPtr",
")",
"throws",
"XMLStreamException",
"{",
"int",
"bracketCount",
"=",
"0",
";",
"char",
"c",
";",
"do",
"{",
"++",
"bracketCount",
";",
"c",
"=",
"(",
"mInputPtr",
"<",
"mInputEnd",
")",
"?",
"mInputBuffer",
"[",
"mInputPtr",
"++",
"]",
":",
"getNextCharFromCurrent",
"(",
"SUFFIX_IN_CDATA",
")",
";",
"}",
"while",
"(",
"c",
"==",
"'",
"'",
")",
";",
"boolean",
"match",
"=",
"(",
"bracketCount",
">=",
"2",
"&&",
"c",
"==",
"'",
"'",
")",
";",
"if",
"(",
"match",
")",
"{",
"bracketCount",
"-=",
"2",
";",
"}",
"while",
"(",
"bracketCount",
">",
"0",
")",
"{",
"--",
"bracketCount",
";",
"outBuf",
"[",
"outPtr",
"++",
"]",
"=",
"'",
"'",
";",
"if",
"(",
"outPtr",
">=",
"outBuf",
".",
"length",
")",
"{",
"/* Can't really easily return, even if we have enough\n * stuff here, since we've more than one char...\n */",
"outBuf",
"=",
"mTextBuffer",
".",
"finishCurrentSegment",
"(",
")",
";",
"outPtr",
"=",
"0",
";",
"}",
"}",
"mTextBuffer",
".",
"setCurrentLength",
"(",
"outPtr",
")",
";",
"// Match? Can break, then:",
"if",
"(",
"match",
")",
"{",
"return",
"true",
";",
"}",
"// No match, need to push the last char back and admit defeat...",
"--",
"mInputPtr",
";",
"return",
"false",
";",
"}"
] | Method that will check, given the starting ']', whether there is
ending ']]>' (including optional extra ']'s); if so, will updated
output buffer with extra ]s, if not, will make sure input and output
are positioned for further checking.
@return True, if we hit the end marker; false if not. | [
"Method",
"that",
"will",
"check",
"given",
"the",
"starting",
"]",
"whether",
"there",
"is",
"ending",
"]]",
">",
"(",
"including",
"optional",
"extra",
"]",
"s",
")",
";",
"if",
"so",
"will",
"updated",
"output",
"buffer",
"with",
"extra",
"]",
"s",
"if",
"not",
"will",
"make",
"sure",
"input",
"and",
"output",
"are",
"positioned",
"for",
"further",
"checking",
"."
] | train | https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/sr/BasicStreamReader.java#L4497-L4531 |
igniterealtime/Smack | smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/IoTControlManager.java | IoTControlManager.setUsingIq | public IoTSetResponse setUsingIq(FullJid jid, SetData data) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
"""
Control a thing by sending a collection of {@link SetData} instructions.
@param jid
@param data
@return a IoTSetResponse
@throws NoResponseException
@throws XMPPErrorException
@throws NotConnectedException
@throws InterruptedException
@see #setUsingIq(FullJid, Collection)
"""
return setUsingIq(jid, Collections.singleton(data));
} | java | public IoTSetResponse setUsingIq(FullJid jid, SetData data) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return setUsingIq(jid, Collections.singleton(data));
} | [
"public",
"IoTSetResponse",
"setUsingIq",
"(",
"FullJid",
"jid",
",",
"SetData",
"data",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"return",
"setUsingIq",
"(",
"jid",
",",
"Collections",
".",
"singleton",
"(",
"data",
")",
")",
";",
"}"
] | Control a thing by sending a collection of {@link SetData} instructions.
@param jid
@param data
@return a IoTSetResponse
@throws NoResponseException
@throws XMPPErrorException
@throws NotConnectedException
@throws InterruptedException
@see #setUsingIq(FullJid, Collection) | [
"Control",
"a",
"thing",
"by",
"sending",
"a",
"collection",
"of",
"{",
"@link",
"SetData",
"}",
"instructions",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/IoTControlManager.java#L113-L115 |
Waikato/jclasslocator | src/main/java/nz/ac/waikato/cms/locator/ClassLocator.java | ClassLocator.main | public static void main(String[] args) {
"""
Possible calls:
<ul>
<li>
adams.core.ClassLocator <packages><br>
Prints all the packages in the current classpath
</li>
<li>
adams.core.ClassLocator <classname> <packagename(s)><br>
Prints the classes it found.
</li>
</ul>
@param args the commandline arguments
"""
List<String> list;
List<String> packages;
int i;
StringTokenizer tok;
if ((args.length == 1) && (args[0].equals("packages"))) {
list = getSingleton().findPackages();
for (i = 0; i < list.size(); i++)
System.out.println(list.get(i));
}
else if (args.length == 2) {
// packages
packages = new ArrayList<>();
tok = new StringTokenizer(args[1], ",");
while (tok.hasMoreTokens())
packages.add(tok.nextToken());
// search
list = getSingleton().findNames(
args[0],
packages.toArray(new String[packages.size()]));
// print result, if any
System.out.println(
"Searching for '" + args[0] + "' in '" + args[1] + "':\n"
+ " " + list.size() + " found.");
for (i = 0; i < list.size(); i++)
System.out.println(" " + (i+1) + ". " + list.get(i));
}
else {
System.out.println("\nUsage:");
System.out.println(
ClassLocator.class.getName() + " packages");
System.out.println("\tlists all packages in the classpath");
System.out.println(
ClassLocator.class.getName() + " <classname> <packagename(s)>");
System.out.println("\tlists classes derived from/implementing 'classname' that");
System.out.println("\tcan be found in 'packagename(s)' (comma-separated list)");
System.out.println();
System.exit(1);
}
} | java | public static void main(String[] args) {
List<String> list;
List<String> packages;
int i;
StringTokenizer tok;
if ((args.length == 1) && (args[0].equals("packages"))) {
list = getSingleton().findPackages();
for (i = 0; i < list.size(); i++)
System.out.println(list.get(i));
}
else if (args.length == 2) {
// packages
packages = new ArrayList<>();
tok = new StringTokenizer(args[1], ",");
while (tok.hasMoreTokens())
packages.add(tok.nextToken());
// search
list = getSingleton().findNames(
args[0],
packages.toArray(new String[packages.size()]));
// print result, if any
System.out.println(
"Searching for '" + args[0] + "' in '" + args[1] + "':\n"
+ " " + list.size() + " found.");
for (i = 0; i < list.size(); i++)
System.out.println(" " + (i+1) + ". " + list.get(i));
}
else {
System.out.println("\nUsage:");
System.out.println(
ClassLocator.class.getName() + " packages");
System.out.println("\tlists all packages in the classpath");
System.out.println(
ClassLocator.class.getName() + " <classname> <packagename(s)>");
System.out.println("\tlists classes derived from/implementing 'classname' that");
System.out.println("\tcan be found in 'packagename(s)' (comma-separated list)");
System.out.println();
System.exit(1);
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"List",
"<",
"String",
">",
"list",
";",
"List",
"<",
"String",
">",
"packages",
";",
"int",
"i",
";",
"StringTokenizer",
"tok",
";",
"if",
"(",
"(",
"args",
".",
"length",
"==",
"1",
")",
"&&",
"(",
"args",
"[",
"0",
"]",
".",
"equals",
"(",
"\"packages\"",
")",
")",
")",
"{",
"list",
"=",
"getSingleton",
"(",
")",
".",
"findPackages",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"System",
".",
"out",
".",
"println",
"(",
"list",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"else",
"if",
"(",
"args",
".",
"length",
"==",
"2",
")",
"{",
"// packages",
"packages",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"tok",
"=",
"new",
"StringTokenizer",
"(",
"args",
"[",
"1",
"]",
",",
"\",\"",
")",
";",
"while",
"(",
"tok",
".",
"hasMoreTokens",
"(",
")",
")",
"packages",
".",
"add",
"(",
"tok",
".",
"nextToken",
"(",
")",
")",
";",
"// search",
"list",
"=",
"getSingleton",
"(",
")",
".",
"findNames",
"(",
"args",
"[",
"0",
"]",
",",
"packages",
".",
"toArray",
"(",
"new",
"String",
"[",
"packages",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"// print result, if any",
"System",
".",
"out",
".",
"println",
"(",
"\"Searching for '\"",
"+",
"args",
"[",
"0",
"]",
"+",
"\"' in '\"",
"+",
"args",
"[",
"1",
"]",
"+",
"\"':\\n\"",
"+",
"\" \"",
"+",
"list",
".",
"size",
"(",
")",
"+",
"\" found.\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"System",
".",
"out",
".",
"println",
"(",
"\" \"",
"+",
"(",
"i",
"+",
"1",
")",
"+",
"\". \"",
"+",
"list",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\\nUsage:\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"ClassLocator",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\" packages\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\tlists all packages in the classpath\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"ClassLocator",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\" <classname> <packagename(s)>\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\tlists classes derived from/implementing 'classname' that\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\\tcan be found in 'packagename(s)' (comma-separated list)\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"}"
] | Possible calls:
<ul>
<li>
adams.core.ClassLocator <packages><br>
Prints all the packages in the current classpath
</li>
<li>
adams.core.ClassLocator <classname> <packagename(s)><br>
Prints the classes it found.
</li>
</ul>
@param args the commandline arguments | [
"Possible",
"calls",
":",
"<ul",
">",
"<li",
">",
"adams",
".",
"core",
".",
"ClassLocator",
"<",
";",
"packages>",
";",
"<br",
">",
"Prints",
"all",
"the",
"packages",
"in",
"the",
"current",
"classpath",
"<",
"/",
"li",
">",
"<li",
">",
"adams",
".",
"core",
".",
"ClassLocator",
"<",
";",
"classname>",
";",
"<",
";",
"packagename",
"(",
"s",
")",
">",
";",
"<br",
">",
"Prints",
"the",
"classes",
"it",
"found",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
] | train | https://github.com/Waikato/jclasslocator/blob/c899072fff607a56ee7f8c2d01fbeb15157ad144/src/main/java/nz/ac/waikato/cms/locator/ClassLocator.java#L722-L764 |
google/closure-compiler | src/com/google/javascript/jscomp/ClosureRewriteModule.java | ClosureRewriteModule.maybeAddAliasToSymbolTable | private void maybeAddAliasToSymbolTable(Node n, String module) {
"""
Add alias nodes to the symbol table as they going to be removed by rewriter. Example aliases:
const Foo = goog.require('my.project.Foo');
const bar = goog.require('my.project.baz');
const {baz} = goog.require('my.project.utils');
"""
if (preprocessorSymbolTable != null) {
n.putBooleanProp(Node.MODULE_ALIAS, true);
// Alias can be used in js types. Types have node type STRING and not NAME so we have to
// use their name as string.
String nodeName =
n.getToken() == Token.STRING
? n.getString()
: preprocessorSymbolTable.getQualifiedName(n);
// We need to include module as part of the name because aliases are local to current module.
// Aliases with the same name from different module should be completely different entities.
String name = "alias_" + module + "_" + nodeName;
preprocessorSymbolTable.addReference(n, name);
}
} | java | private void maybeAddAliasToSymbolTable(Node n, String module) {
if (preprocessorSymbolTable != null) {
n.putBooleanProp(Node.MODULE_ALIAS, true);
// Alias can be used in js types. Types have node type STRING and not NAME so we have to
// use their name as string.
String nodeName =
n.getToken() == Token.STRING
? n.getString()
: preprocessorSymbolTable.getQualifiedName(n);
// We need to include module as part of the name because aliases are local to current module.
// Aliases with the same name from different module should be completely different entities.
String name = "alias_" + module + "_" + nodeName;
preprocessorSymbolTable.addReference(n, name);
}
} | [
"private",
"void",
"maybeAddAliasToSymbolTable",
"(",
"Node",
"n",
",",
"String",
"module",
")",
"{",
"if",
"(",
"preprocessorSymbolTable",
"!=",
"null",
")",
"{",
"n",
".",
"putBooleanProp",
"(",
"Node",
".",
"MODULE_ALIAS",
",",
"true",
")",
";",
"// Alias can be used in js types. Types have node type STRING and not NAME so we have to",
"// use their name as string.",
"String",
"nodeName",
"=",
"n",
".",
"getToken",
"(",
")",
"==",
"Token",
".",
"STRING",
"?",
"n",
".",
"getString",
"(",
")",
":",
"preprocessorSymbolTable",
".",
"getQualifiedName",
"(",
"n",
")",
";",
"// We need to include module as part of the name because aliases are local to current module.",
"// Aliases with the same name from different module should be completely different entities.",
"String",
"name",
"=",
"\"alias_\"",
"+",
"module",
"+",
"\"_\"",
"+",
"nodeName",
";",
"preprocessorSymbolTable",
".",
"addReference",
"(",
"n",
",",
"name",
")",
";",
"}",
"}"
] | Add alias nodes to the symbol table as they going to be removed by rewriter. Example aliases:
const Foo = goog.require('my.project.Foo');
const bar = goog.require('my.project.baz');
const {baz} = goog.require('my.project.utils'); | [
"Add",
"alias",
"nodes",
"to",
"the",
"symbol",
"table",
"as",
"they",
"going",
"to",
"be",
"removed",
"by",
"rewriter",
".",
"Example",
"aliases",
":"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ClosureRewriteModule.java#L1811-L1825 |
poetix/protonpack | src/main/java/com/codepoetics/protonpack/StreamUtils.java | StreamUtils.mergeToList | @SafeVarargs
public static <T> Stream<List<T>> mergeToList(Stream<T>...streams) {
"""
Construct a stream which merges together values from the supplied streams into lists of values, somewhat in the manner of the
stream constructed by {@link com.codepoetics.protonpack.StreamUtils#zip(java.util.stream.Stream, java.util.stream.Stream, java.util.function.BiFunction)},
but for an arbitrary number of streams.
@param streams The streams to merge.
@param <T> The type over which the merged streams stream.
@return A merging stream of lists of T.
"""
return merge(ArrayList::new, (l, x) -> {
l.add(x);
return l;
}, streams);
} | java | @SafeVarargs
public static <T> Stream<List<T>> mergeToList(Stream<T>...streams) {
return merge(ArrayList::new, (l, x) -> {
l.add(x);
return l;
}, streams);
} | [
"@",
"SafeVarargs",
"public",
"static",
"<",
"T",
">",
"Stream",
"<",
"List",
"<",
"T",
">",
">",
"mergeToList",
"(",
"Stream",
"<",
"T",
">",
"...",
"streams",
")",
"{",
"return",
"merge",
"(",
"ArrayList",
"::",
"new",
",",
"(",
"l",
",",
"x",
")",
"->",
"{",
"l",
".",
"add",
"(",
"x",
")",
";",
"return",
"l",
";",
"}",
",",
"streams",
")",
";",
"}"
] | Construct a stream which merges together values from the supplied streams into lists of values, somewhat in the manner of the
stream constructed by {@link com.codepoetics.protonpack.StreamUtils#zip(java.util.stream.Stream, java.util.stream.Stream, java.util.function.BiFunction)},
but for an arbitrary number of streams.
@param streams The streams to merge.
@param <T> The type over which the merged streams stream.
@return A merging stream of lists of T. | [
"Construct",
"a",
"stream",
"which",
"merges",
"together",
"values",
"from",
"the",
"supplied",
"streams",
"into",
"lists",
"of",
"values",
"somewhat",
"in",
"the",
"manner",
"of",
"the",
"stream",
"constructed",
"by",
"{",
"@link",
"com",
".",
"codepoetics",
".",
"protonpack",
".",
"StreamUtils#zip",
"(",
"java",
".",
"util",
".",
"stream",
".",
"Stream",
"java",
".",
"util",
".",
"stream",
".",
"Stream",
"java",
".",
"util",
".",
"function",
".",
"BiFunction",
")",
"}",
"but",
"for",
"an",
"arbitrary",
"number",
"of",
"streams",
"."
] | train | https://github.com/poetix/protonpack/blob/00c55a05a4779926d02d5f4e6c820560a773f9f1/src/main/java/com/codepoetics/protonpack/StreamUtils.java#L394-L400 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java | TreeUtil.findComponentsByClass | public static List<ComponentWithContext> findComponentsByClass(final WComponent root, final String className) {
"""
Search for components implementing a particular class name.
<p>
Only search visible components and include the root component in the matching logic.
</p>
@param root the root component to search from
@param className the class name to search for
@return the list of components implementing the class name
"""
return findComponentsByClass(root, className, true, true);
} | java | public static List<ComponentWithContext> findComponentsByClass(final WComponent root, final String className) {
return findComponentsByClass(root, className, true, true);
} | [
"public",
"static",
"List",
"<",
"ComponentWithContext",
">",
"findComponentsByClass",
"(",
"final",
"WComponent",
"root",
",",
"final",
"String",
"className",
")",
"{",
"return",
"findComponentsByClass",
"(",
"root",
",",
"className",
",",
"true",
",",
"true",
")",
";",
"}"
] | Search for components implementing a particular class name.
<p>
Only search visible components and include the root component in the matching logic.
</p>
@param root the root component to search from
@param className the class name to search for
@return the list of components implementing the class name | [
"Search",
"for",
"components",
"implementing",
"a",
"particular",
"class",
"name",
".",
"<p",
">",
"Only",
"search",
"visible",
"components",
"and",
"include",
"the",
"root",
"component",
"in",
"the",
"matching",
"logic",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java#L93-L95 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterName.java | UCharacterName.setToken | boolean setToken(char token[], byte tokenstring[]) {
"""
Sets the token data
@param token array of tokens
@param tokenstring array of string values of the tokens
@return false if there is a data error
"""
if (token != null && tokenstring != null && token.length > 0 &&
tokenstring.length > 0) {
m_tokentable_ = token;
m_tokenstring_ = tokenstring;
return true;
}
return false;
} | java | boolean setToken(char token[], byte tokenstring[])
{
if (token != null && tokenstring != null && token.length > 0 &&
tokenstring.length > 0) {
m_tokentable_ = token;
m_tokenstring_ = tokenstring;
return true;
}
return false;
} | [
"boolean",
"setToken",
"(",
"char",
"token",
"[",
"]",
",",
"byte",
"tokenstring",
"[",
"]",
")",
"{",
"if",
"(",
"token",
"!=",
"null",
"&&",
"tokenstring",
"!=",
"null",
"&&",
"token",
".",
"length",
">",
"0",
"&&",
"tokenstring",
".",
"length",
">",
"0",
")",
"{",
"m_tokentable_",
"=",
"token",
";",
"m_tokenstring_",
"=",
"tokenstring",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Sets the token data
@param token array of tokens
@param tokenstring array of string values of the tokens
@return false if there is a data error | [
"Sets",
"the",
"token",
"data"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterName.java#L965-L974 |
cybazeitalia/emaze-dysfunctional | src/main/java/net/emaze/dysfunctional/ranges/Densify.java | Densify.canBeMerged | private boolean canBeMerged(DenseRange<T> current, DenseRange<T> next) {
"""
<code>
|-----------|
|-----|
</code> or
<code>
|-----------|
|------|
</code>
@param current the current range
@param next the next range
@return true if the two ranges can be merged
"""
return Order.of(comparator, current.end(), Optional.of(next.begin())) == Order.EQ || current.overlaps(next);
} | java | private boolean canBeMerged(DenseRange<T> current, DenseRange<T> next) {
return Order.of(comparator, current.end(), Optional.of(next.begin())) == Order.EQ || current.overlaps(next);
} | [
"private",
"boolean",
"canBeMerged",
"(",
"DenseRange",
"<",
"T",
">",
"current",
",",
"DenseRange",
"<",
"T",
">",
"next",
")",
"{",
"return",
"Order",
".",
"of",
"(",
"comparator",
",",
"current",
".",
"end",
"(",
")",
",",
"Optional",
".",
"of",
"(",
"next",
".",
"begin",
"(",
")",
")",
")",
"==",
"Order",
".",
"EQ",
"||",
"current",
".",
"overlaps",
"(",
"next",
")",
";",
"}"
] | <code>
|-----------|
|-----|
</code> or
<code>
|-----------|
|------|
</code>
@param current the current range
@param next the next range
@return true if the two ranges can be merged | [
"<code",
">",
"|",
"-----------",
"|",
"|",
"-----",
"|",
"<",
"/",
"code",
">",
"or",
"<code",
">",
"|",
"-----------",
"|",
"|",
"------",
"|",
"<",
"/",
"code",
">"
] | train | https://github.com/cybazeitalia/emaze-dysfunctional/blob/98115a436e35335c5e8831f9fdc12f6d93d524be/src/main/java/net/emaze/dysfunctional/ranges/Densify.java#L72-L74 |
amzn/ion-java | src/com/amazon/ion/impl/bin/IonRawBinaryWriter.java | IonRawBinaryWriter.writeBytes | public void writeBytes(byte[] data, int offset, int length) throws IOException {
"""
Writes a raw value into the buffer, updating lengths appropriately.
<p>
The implication here is that the caller is dumping some valid Ion payload with the correct context.
"""
prepareValue();
updateLength(length);
buffer.writeBytes(data, offset, length);
finishValue();
} | java | public void writeBytes(byte[] data, int offset, int length) throws IOException
{
prepareValue();
updateLength(length);
buffer.writeBytes(data, offset, length);
finishValue();
} | [
"public",
"void",
"writeBytes",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"prepareValue",
"(",
")",
";",
"updateLength",
"(",
"length",
")",
";",
"buffer",
".",
"writeBytes",
"(",
"data",
",",
"offset",
",",
"length",
")",
";",
"finishValue",
"(",
")",
";",
"}"
] | Writes a raw value into the buffer, updating lengths appropriately.
<p>
The implication here is that the caller is dumping some valid Ion payload with the correct context. | [
"Writes",
"a",
"raw",
"value",
"into",
"the",
"buffer",
"updating",
"lengths",
"appropriately",
".",
"<p",
">",
"The",
"implication",
"here",
"is",
"that",
"the",
"caller",
"is",
"dumping",
"some",
"valid",
"Ion",
"payload",
"with",
"the",
"correct",
"context",
"."
] | train | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/bin/IonRawBinaryWriter.java#L1468-L1474 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContactSet.java | GroupContactSet.hasContact | public boolean hasContact(ResidueIdentifier resId1, ResidueIdentifier resId2) {
"""
Tell whether the given pair is a contact in this GroupContactSet,
in a chain-identifier independent way: contacts happening between different copies of
the same Compound(Entity) will be considered equal as long as they have the same
residue numbers.
@param resId1
@param resId2
@return
"""
return contacts.containsKey(new Pair<ResidueIdentifier>(resId1, resId2));
} | java | public boolean hasContact(ResidueIdentifier resId1, ResidueIdentifier resId2) {
return contacts.containsKey(new Pair<ResidueIdentifier>(resId1, resId2));
} | [
"public",
"boolean",
"hasContact",
"(",
"ResidueIdentifier",
"resId1",
",",
"ResidueIdentifier",
"resId2",
")",
"{",
"return",
"contacts",
".",
"containsKey",
"(",
"new",
"Pair",
"<",
"ResidueIdentifier",
">",
"(",
"resId1",
",",
"resId2",
")",
")",
";",
"}"
] | Tell whether the given pair is a contact in this GroupContactSet,
in a chain-identifier independent way: contacts happening between different copies of
the same Compound(Entity) will be considered equal as long as they have the same
residue numbers.
@param resId1
@param resId2
@return | [
"Tell",
"whether",
"the",
"given",
"pair",
"is",
"a",
"contact",
"in",
"this",
"GroupContactSet",
"in",
"a",
"chain",
"-",
"identifier",
"independent",
"way",
":",
"contacts",
"happening",
"between",
"different",
"copies",
"of",
"the",
"same",
"Compound",
"(",
"Entity",
")",
"will",
"be",
"considered",
"equal",
"as",
"long",
"as",
"they",
"have",
"the",
"same",
"residue",
"numbers",
"."
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContactSet.java#L129-L132 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java | AbstractTreeWriter.addPartialInfo | protected void addPartialInfo(ClassDoc cd, Content contentTree) {
"""
Add information about the class kind, if it's a "class" or "interface".
@param cd the class being documented
@param contentTree the content tree to which the information will be added
"""
addPreQualifiedStrongClassLink(LinkInfoImpl.Kind.TREE, cd, contentTree);
} | java | protected void addPartialInfo(ClassDoc cd, Content contentTree) {
addPreQualifiedStrongClassLink(LinkInfoImpl.Kind.TREE, cd, contentTree);
} | [
"protected",
"void",
"addPartialInfo",
"(",
"ClassDoc",
"cd",
",",
"Content",
"contentTree",
")",
"{",
"addPreQualifiedStrongClassLink",
"(",
"LinkInfoImpl",
".",
"Kind",
".",
"TREE",
",",
"cd",
",",
"contentTree",
")",
";",
"}"
] | Add information about the class kind, if it's a "class" or "interface".
@param cd the class being documented
@param contentTree the content tree to which the information will be added | [
"Add",
"information",
"about",
"the",
"class",
"kind",
"if",
"it",
"s",
"a",
"class",
"or",
"interface",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java#L179-L181 |
liferay/com-liferay-commerce | commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceOrderPersistenceImpl.java | CommerceOrderPersistenceImpl.removeByUUID_G | @Override
public CommerceOrder removeByUUID_G(String uuid, long groupId)
throws NoSuchOrderException {
"""
Removes the commerce order where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the commerce order that was removed
"""
CommerceOrder commerceOrder = findByUUID_G(uuid, groupId);
return remove(commerceOrder);
} | java | @Override
public CommerceOrder removeByUUID_G(String uuid, long groupId)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByUUID_G(uuid, groupId);
return remove(commerceOrder);
} | [
"@",
"Override",
"public",
"CommerceOrder",
"removeByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"NoSuchOrderException",
"{",
"CommerceOrder",
"commerceOrder",
"=",
"findByUUID_G",
"(",
"uuid",
",",
"groupId",
")",
";",
"return",
"remove",
"(",
"commerceOrder",
")",
";",
"}"
] | Removes the commerce order where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the commerce order that was removed | [
"Removes",
"the",
"commerce",
"order",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceOrderPersistenceImpl.java#L811-L817 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/UsersInner.java | UsersInner.createOrUpdateAsync | public Observable<UserInner> createOrUpdateAsync(String resourceGroupName, String labAccountName, String labName, String userName, UserInner user) {
"""
Create or replace an existing User.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param userName The name of the user.
@param user The User registered to a lab
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the UserInner object
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, userName, user).map(new Func1<ServiceResponse<UserInner>, UserInner>() {
@Override
public UserInner call(ServiceResponse<UserInner> response) {
return response.body();
}
});
} | java | public Observable<UserInner> createOrUpdateAsync(String resourceGroupName, String labAccountName, String labName, String userName, UserInner user) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, labAccountName, labName, userName, user).map(new Func1<ServiceResponse<UserInner>, UserInner>() {
@Override
public UserInner call(ServiceResponse<UserInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"UserInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"labAccountName",
",",
"String",
"labName",
",",
"String",
"userName",
",",
"UserInner",
"user",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"labAccountName",
",",
"labName",
",",
"userName",
",",
"user",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"UserInner",
">",
",",
"UserInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"UserInner",
"call",
"(",
"ServiceResponse",
"<",
"UserInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create or replace an existing User.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labName The name of the lab.
@param userName The name of the user.
@param user The User registered to a lab
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the UserInner object | [
"Create",
"or",
"replace",
"an",
"existing",
"User",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/UsersInner.java#L617-L624 |
netty/netty | transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java | AbstractEpollStreamChannel.doWriteMultiple | private int doWriteMultiple(ChannelOutboundBuffer in) throws Exception {
"""
Attempt to write multiple {@link ByteBuf} objects.
@param in the collection which contains objects to write.
@return The value that should be decremented from the write quantum which starts at
{@link ChannelConfig#getWriteSpinCount()}. The typical use cases are as follows:
<ul>
<li>0 - if no write was attempted. This is appropriate if an empty {@link ByteBuf} (or other empty content)
is encountered</li>
<li>1 - if a single call to write data was made to the OS</li>
<li>{@link ChannelUtils#WRITE_STATUS_SNDBUF_FULL} - if an attempt to write data was made to the OS, but
no data was accepted</li>
</ul>
@throws Exception If an I/O error occurs.
"""
final long maxBytesPerGatheringWrite = config().getMaxBytesPerGatheringWrite();
IovArray array = ((EpollEventLoop) eventLoop()).cleanIovArray();
array.maxBytes(maxBytesPerGatheringWrite);
in.forEachFlushedMessage(array);
if (array.count() >= 1) {
// TODO: Handle the case where cnt == 1 specially.
return writeBytesMultiple(in, array);
}
// cnt == 0, which means the outbound buffer contained empty buffers only.
in.removeBytes(0);
return 0;
} | java | private int doWriteMultiple(ChannelOutboundBuffer in) throws Exception {
final long maxBytesPerGatheringWrite = config().getMaxBytesPerGatheringWrite();
IovArray array = ((EpollEventLoop) eventLoop()).cleanIovArray();
array.maxBytes(maxBytesPerGatheringWrite);
in.forEachFlushedMessage(array);
if (array.count() >= 1) {
// TODO: Handle the case where cnt == 1 specially.
return writeBytesMultiple(in, array);
}
// cnt == 0, which means the outbound buffer contained empty buffers only.
in.removeBytes(0);
return 0;
} | [
"private",
"int",
"doWriteMultiple",
"(",
"ChannelOutboundBuffer",
"in",
")",
"throws",
"Exception",
"{",
"final",
"long",
"maxBytesPerGatheringWrite",
"=",
"config",
"(",
")",
".",
"getMaxBytesPerGatheringWrite",
"(",
")",
";",
"IovArray",
"array",
"=",
"(",
"(",
"EpollEventLoop",
")",
"eventLoop",
"(",
")",
")",
".",
"cleanIovArray",
"(",
")",
";",
"array",
".",
"maxBytes",
"(",
"maxBytesPerGatheringWrite",
")",
";",
"in",
".",
"forEachFlushedMessage",
"(",
"array",
")",
";",
"if",
"(",
"array",
".",
"count",
"(",
")",
">=",
"1",
")",
"{",
"// TODO: Handle the case where cnt == 1 specially.",
"return",
"writeBytesMultiple",
"(",
"in",
",",
"array",
")",
";",
"}",
"// cnt == 0, which means the outbound buffer contained empty buffers only.",
"in",
".",
"removeBytes",
"(",
"0",
")",
";",
"return",
"0",
";",
"}"
] | Attempt to write multiple {@link ByteBuf} objects.
@param in the collection which contains objects to write.
@return The value that should be decremented from the write quantum which starts at
{@link ChannelConfig#getWriteSpinCount()}. The typical use cases are as follows:
<ul>
<li>0 - if no write was attempted. This is appropriate if an empty {@link ByteBuf} (or other empty content)
is encountered</li>
<li>1 - if a single call to write data was made to the OS</li>
<li>{@link ChannelUtils#WRITE_STATUS_SNDBUF_FULL} - if an attempt to write data was made to the OS, but
no data was accepted</li>
</ul>
@throws Exception If an I/O error occurs. | [
"Attempt",
"to",
"write",
"multiple",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java#L511-L524 |
arquillian/arquillian-core | container/spi/src/main/java/org/jboss/arquillian/container/spi/client/deployment/Validate.java | Validate.notNullOrEmpty | public static void notNullOrEmpty(final String string, final String message) throws IllegalArgumentException {
"""
Checks that the specified String is not null or empty,
throws exception if it is.
@param string
The object to check
@param message
The exception message
@throws IllegalArgumentException
Thrown if obj is null
"""
if (string == null || string.length() == 0) {
throw new IllegalArgumentException(message);
}
} | java | public static void notNullOrEmpty(final String string, final String message) throws IllegalArgumentException {
if (string == null || string.length() == 0) {
throw new IllegalArgumentException(message);
}
} | [
"public",
"static",
"void",
"notNullOrEmpty",
"(",
"final",
"String",
"string",
",",
"final",
"String",
"message",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"string",
"==",
"null",
"||",
"string",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"}"
] | Checks that the specified String is not null or empty,
throws exception if it is.
@param string
The object to check
@param message
The exception message
@throws IllegalArgumentException
Thrown if obj is null | [
"Checks",
"that",
"the",
"specified",
"String",
"is",
"not",
"null",
"or",
"empty",
"throws",
"exception",
"if",
"it",
"is",
"."
] | train | https://github.com/arquillian/arquillian-core/blob/a85b91789b80cc77e0f0c2e2abac65c2255c0a81/container/spi/src/main/java/org/jboss/arquillian/container/spi/client/deployment/Validate.java#L103-L107 |
google/closure-templates | java/src/com/google/template/soy/base/SourceLocation.java | SourceLocation.extend | public SourceLocation extend(int lines, int cols) {
"""
Returns a new SourceLocation that starts where this SourceLocation starts and ends {@code
lines} and {@code cols} further than where it ends.
"""
return new SourceLocation(filePath, begin, end.offset(lines, cols));
} | java | public SourceLocation extend(int lines, int cols) {
return new SourceLocation(filePath, begin, end.offset(lines, cols));
} | [
"public",
"SourceLocation",
"extend",
"(",
"int",
"lines",
",",
"int",
"cols",
")",
"{",
"return",
"new",
"SourceLocation",
"(",
"filePath",
",",
"begin",
",",
"end",
".",
"offset",
"(",
"lines",
",",
"cols",
")",
")",
";",
"}"
] | Returns a new SourceLocation that starts where this SourceLocation starts and ends {@code
lines} and {@code cols} further than where it ends. | [
"Returns",
"a",
"new",
"SourceLocation",
"that",
"starts",
"where",
"this",
"SourceLocation",
"starts",
"and",
"ends",
"{"
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/base/SourceLocation.java#L200-L202 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpp/MPP8Reader.java | MPP8Reader.populateMemberData | private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws IOException {
"""
Populate member data used by the rest of the reader.
@param reader parent file reader
@param file parent MPP file
@param root Root of the POI file system.
"""
m_reader = reader;
m_root = root;
m_file = file;
m_eventManager = file.getEventManager();
m_calendarMap = new HashMap<Integer, ProjectCalendar>();
m_projectDir = (DirectoryEntry) root.getEntry(" 1");
m_viewDir = (DirectoryEntry) root.getEntry(" 2");
m_file.getProjectProperties().setMppFileType(Integer.valueOf(8));
} | java | private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws IOException
{
m_reader = reader;
m_root = root;
m_file = file;
m_eventManager = file.getEventManager();
m_calendarMap = new HashMap<Integer, ProjectCalendar>();
m_projectDir = (DirectoryEntry) root.getEntry(" 1");
m_viewDir = (DirectoryEntry) root.getEntry(" 2");
m_file.getProjectProperties().setMppFileType(Integer.valueOf(8));
} | [
"private",
"void",
"populateMemberData",
"(",
"MPPReader",
"reader",
",",
"ProjectFile",
"file",
",",
"DirectoryEntry",
"root",
")",
"throws",
"IOException",
"{",
"m_reader",
"=",
"reader",
";",
"m_root",
"=",
"root",
";",
"m_file",
"=",
"file",
";",
"m_eventManager",
"=",
"file",
".",
"getEventManager",
"(",
")",
";",
"m_calendarMap",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"ProjectCalendar",
">",
"(",
")",
";",
"m_projectDir",
"=",
"(",
"DirectoryEntry",
")",
"root",
".",
"getEntry",
"(",
"\" 1\"",
")",
";",
"m_viewDir",
"=",
"(",
"DirectoryEntry",
")",
"root",
".",
"getEntry",
"(",
"\" 2\"",
")",
";",
"m_file",
".",
"getProjectProperties",
"(",
")",
".",
"setMppFileType",
"(",
"Integer",
".",
"valueOf",
"(",
"8",
")",
")",
";",
"}"
] | Populate member data used by the rest of the reader.
@param reader parent file reader
@param file parent MPP file
@param root Root of the POI file system. | [
"Populate",
"member",
"data",
"used",
"by",
"the",
"rest",
"of",
"the",
"reader",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPP8Reader.java#L125-L137 |
NoraUi/NoraUi | src/main/java/com/github/noraui/application/steps/Step.java | Step.checkElementPresence | protected void checkElementPresence(PageElement pageElement, boolean present) throws FailureException {
"""
Checks if an html element (PageElement) is displayed.
@param pageElement
Is target element
@param present
Is target element supposed to be present
@throws FailureException
if the scenario encounters a functional error. Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT} message
(with screenshot, with exception)
"""
if (present) {
try {
Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(pageElement)));
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, pageElement.getPage().getCallBack());
}
} else {
try {
Context.waitUntil(ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(Utilities.getLocator(pageElement))));
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.getMessage(Messages.FAIL_MESSAGE_ELEMENT_STILL_VISIBLE), true, pageElement.getPage().getCallBack());
}
}
} | java | protected void checkElementPresence(PageElement pageElement, boolean present) throws FailureException {
if (present) {
try {
Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(pageElement)));
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, pageElement.getPage().getCallBack());
}
} else {
try {
Context.waitUntil(ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(Utilities.getLocator(pageElement))));
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.getMessage(Messages.FAIL_MESSAGE_ELEMENT_STILL_VISIBLE), true, pageElement.getPage().getCallBack());
}
}
} | [
"protected",
"void",
"checkElementPresence",
"(",
"PageElement",
"pageElement",
",",
"boolean",
"present",
")",
"throws",
"FailureException",
"{",
"if",
"(",
"present",
")",
"{",
"try",
"{",
"Context",
".",
"waitUntil",
"(",
"ExpectedConditions",
".",
"presenceOfElementLocated",
"(",
"Utilities",
".",
"getLocator",
"(",
"pageElement",
")",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"new",
"Result",
".",
"Failure",
"<>",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"Messages",
".",
"getMessage",
"(",
"Messages",
".",
"FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT",
")",
",",
"true",
",",
"pageElement",
".",
"getPage",
"(",
")",
".",
"getCallBack",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"Context",
".",
"waitUntil",
"(",
"ExpectedConditions",
".",
"not",
"(",
"ExpectedConditions",
".",
"presenceOfAllElementsLocatedBy",
"(",
"Utilities",
".",
"getLocator",
"(",
"pageElement",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"new",
"Result",
".",
"Failure",
"<>",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"Messages",
".",
"getMessage",
"(",
"Messages",
".",
"FAIL_MESSAGE_ELEMENT_STILL_VISIBLE",
")",
",",
"true",
",",
"pageElement",
".",
"getPage",
"(",
")",
".",
"getCallBack",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Checks if an html element (PageElement) is displayed.
@param pageElement
Is target element
@param present
Is target element supposed to be present
@throws FailureException
if the scenario encounters a functional error. Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT} message
(with screenshot, with exception) | [
"Checks",
"if",
"an",
"html",
"element",
"(",
"PageElement",
")",
"is",
"displayed",
"."
] | train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/application/steps/Step.java#L426-L440 |
lucee/Lucee | core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java | ResourceUtil.getResource | public static Resource getResource(PageContext pc, PageSource ps) throws PageException {
"""
if the pageSource is based on a archive, translate the source to a zip:// Resource
@return return the Resource matching this PageSource
@param pc the Page Context Object
@deprecated use instead <code>PageSource.getResourceTranslated(PageContext)</code>
"""
return ps.getResourceTranslated(pc);
} | java | public static Resource getResource(PageContext pc, PageSource ps) throws PageException {
return ps.getResourceTranslated(pc);
} | [
"public",
"static",
"Resource",
"getResource",
"(",
"PageContext",
"pc",
",",
"PageSource",
"ps",
")",
"throws",
"PageException",
"{",
"return",
"ps",
".",
"getResourceTranslated",
"(",
"pc",
")",
";",
"}"
] | if the pageSource is based on a archive, translate the source to a zip:// Resource
@return return the Resource matching this PageSource
@param pc the Page Context Object
@deprecated use instead <code>PageSource.getResourceTranslated(PageContext)</code> | [
"if",
"the",
"pageSource",
"is",
"based",
"on",
"a",
"archive",
"translate",
"the",
"source",
"to",
"a",
"zip",
":",
"//",
"Resource"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java#L1410-L1412 |
jbundle/jbundle | thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageFilter.java | BaseMessageFilter.updateFilterMap | public final void updateFilterMap(Map<String,Object> propFilter) {
"""
Update this object's filter with this new map information.
@param propFilter New filter information (ie, bookmark=345) pass null to sync the local and remote filters.
"""
if (propFilter == null)
propFilter = new HashMap<String,Object>(); // Then handleUpdateFilterMap can modify the filter
propFilter = this.handleUpdateFilterMap(propFilter); // Update this object's local filter.
this.setFilterMap(propFilter); // Update any remote copy of this.
} | java | public final void updateFilterMap(Map<String,Object> propFilter)
{
if (propFilter == null)
propFilter = new HashMap<String,Object>(); // Then handleUpdateFilterMap can modify the filter
propFilter = this.handleUpdateFilterMap(propFilter); // Update this object's local filter.
this.setFilterMap(propFilter); // Update any remote copy of this.
} | [
"public",
"final",
"void",
"updateFilterMap",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"propFilter",
")",
"{",
"if",
"(",
"propFilter",
"==",
"null",
")",
"propFilter",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"// Then handleUpdateFilterMap can modify the filter",
"propFilter",
"=",
"this",
".",
"handleUpdateFilterMap",
"(",
"propFilter",
")",
";",
"// Update this object's local filter.",
"this",
".",
"setFilterMap",
"(",
"propFilter",
")",
";",
"// Update any remote copy of this.",
"}"
] | Update this object's filter with this new map information.
@param propFilter New filter information (ie, bookmark=345) pass null to sync the local and remote filters. | [
"Update",
"this",
"object",
"s",
"filter",
"with",
"this",
"new",
"map",
"information",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/BaseMessageFilter.java#L435-L441 |
bazaarvoice/emodb | databus-client-common/src/main/java/com/bazaarvoice/emodb/databus/client/DatabusClient.java | DatabusClient.moveAsync | @Override
public String moveAsync(String apiKey, String from, String to) {
"""
Any server can initiate a move request, no need for @PartitionKey
"""
checkNotNull(from, "from");
checkNotNull(to, "to");
try {
URI uri = _databus.clone()
.segment("_move")
.queryParam("from", from)
.queryParam("to", to)
.build();
Map<String, Object> response = _client.resource(uri)
.header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey)
.post(new TypeReference<Map<String, Object>>(){}, null);
return response.get("id").toString();
} catch (EmoClientException e) {
throw convertException(e);
}
} | java | @Override
public String moveAsync(String apiKey, String from, String to) {
checkNotNull(from, "from");
checkNotNull(to, "to");
try {
URI uri = _databus.clone()
.segment("_move")
.queryParam("from", from)
.queryParam("to", to)
.build();
Map<String, Object> response = _client.resource(uri)
.header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey)
.post(new TypeReference<Map<String, Object>>(){}, null);
return response.get("id").toString();
} catch (EmoClientException e) {
throw convertException(e);
}
} | [
"@",
"Override",
"public",
"String",
"moveAsync",
"(",
"String",
"apiKey",
",",
"String",
"from",
",",
"String",
"to",
")",
"{",
"checkNotNull",
"(",
"from",
",",
"\"from\"",
")",
";",
"checkNotNull",
"(",
"to",
",",
"\"to\"",
")",
";",
"try",
"{",
"URI",
"uri",
"=",
"_databus",
".",
"clone",
"(",
")",
".",
"segment",
"(",
"\"_move\"",
")",
".",
"queryParam",
"(",
"\"from\"",
",",
"from",
")",
".",
"queryParam",
"(",
"\"to\"",
",",
"to",
")",
".",
"build",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"response",
"=",
"_client",
".",
"resource",
"(",
"uri",
")",
".",
"header",
"(",
"ApiKeyRequest",
".",
"AUTHENTICATION_HEADER",
",",
"apiKey",
")",
".",
"post",
"(",
"new",
"TypeReference",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
"{",
"}",
",",
"null",
")",
";",
"return",
"response",
".",
"get",
"(",
"\"id\"",
")",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"EmoClientException",
"e",
")",
"{",
"throw",
"convertException",
"(",
"e",
")",
";",
"}",
"}"
] | Any server can initiate a move request, no need for @PartitionKey | [
"Any",
"server",
"can",
"initiate",
"a",
"move",
"request",
"no",
"need",
"for"
] | train | https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/databus-client-common/src/main/java/com/bazaarvoice/emodb/databus/client/DatabusClient.java#L332-L349 |
lessthanoptimal/BoofCV | integration/boofcv-swing/src/main/java/boofcv/gui/feature/VisualizeShapes.java | VisualizeShapes.drawRectangle | public static void drawRectangle( Rectangle2D_I32 rect , Graphics2D g2 ) {
"""
Draws an axis aligned rectangle
@param rect Rectangle
@param g2 Graphics object
"""
g2.drawLine(rect.x0, rect.y0, rect.x1, rect.y0);
g2.drawLine(rect.x1, rect.y0, rect.x1, rect.y1);
g2.drawLine(rect.x0, rect.y1, rect.x1, rect.y1);
g2.drawLine(rect.x0, rect.y1, rect.x0, rect.y0);
} | java | public static void drawRectangle( Rectangle2D_I32 rect , Graphics2D g2 ) {
g2.drawLine(rect.x0, rect.y0, rect.x1, rect.y0);
g2.drawLine(rect.x1, rect.y0, rect.x1, rect.y1);
g2.drawLine(rect.x0, rect.y1, rect.x1, rect.y1);
g2.drawLine(rect.x0, rect.y1, rect.x0, rect.y0);
} | [
"public",
"static",
"void",
"drawRectangle",
"(",
"Rectangle2D_I32",
"rect",
",",
"Graphics2D",
"g2",
")",
"{",
"g2",
".",
"drawLine",
"(",
"rect",
".",
"x0",
",",
"rect",
".",
"y0",
",",
"rect",
".",
"x1",
",",
"rect",
".",
"y0",
")",
";",
"g2",
".",
"drawLine",
"(",
"rect",
".",
"x1",
",",
"rect",
".",
"y0",
",",
"rect",
".",
"x1",
",",
"rect",
".",
"y1",
")",
";",
"g2",
".",
"drawLine",
"(",
"rect",
".",
"x0",
",",
"rect",
".",
"y1",
",",
"rect",
".",
"x1",
",",
"rect",
".",
"y1",
")",
";",
"g2",
".",
"drawLine",
"(",
"rect",
".",
"x0",
",",
"rect",
".",
"y1",
",",
"rect",
".",
"x0",
",",
"rect",
".",
"y0",
")",
";",
"}"
] | Draws an axis aligned rectangle
@param rect Rectangle
@param g2 Graphics object | [
"Draws",
"an",
"axis",
"aligned",
"rectangle"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/feature/VisualizeShapes.java#L335-L340 |
GoogleCloudPlatform/bigdata-interop | gcsio/src/main/java/com/google/cloud/hadoop/gcsio/PrefixMappedItemCache.java | PrefixMappedItemCache.putList | public synchronized void putList(
String bucket, @Nullable String objectNamePrefix, List<GoogleCloudStorageItemInfo> items) {
"""
Inserts a list entry and the given items into the cache. If a list entry under the same
bucket/objectNamePrefix is present, its expiration time is reset. If an item with the same
resource id is present, it is overwritten by the new item.
@param bucket the bucket to index the items by.
@param objectNamePrefix the object name prefix to index the items by. If this is null, it will
be converted to empty string.
@param items the list of items to insert.
"""
// Give all entries the same creation time so they expire at the same time.
long creationTime = ticker.read();
PrefixKey key = new PrefixKey(bucket, objectNamePrefix);
// The list being inserted is always fresher than any child lists.
getPrefixSubMap(itemMap, key).clear();
getPrefixSubMap(prefixMap, key).clear();
// Populate the maps.
prefixMap.put(key, new CacheValue<Object>(null, creationTime));
for (GoogleCloudStorageItemInfo item : items) {
StorageResourceId itemId = item.getResourceId();
PrefixKey itemKey = new PrefixKey(itemId.getBucketName(), itemId.getObjectName());
CacheValue<GoogleCloudStorageItemInfo> itemValue =
new CacheValue<GoogleCloudStorageItemInfo>(item, creationTime);
itemMap.put(itemKey, itemValue);
}
} | java | public synchronized void putList(
String bucket, @Nullable String objectNamePrefix, List<GoogleCloudStorageItemInfo> items) {
// Give all entries the same creation time so they expire at the same time.
long creationTime = ticker.read();
PrefixKey key = new PrefixKey(bucket, objectNamePrefix);
// The list being inserted is always fresher than any child lists.
getPrefixSubMap(itemMap, key).clear();
getPrefixSubMap(prefixMap, key).clear();
// Populate the maps.
prefixMap.put(key, new CacheValue<Object>(null, creationTime));
for (GoogleCloudStorageItemInfo item : items) {
StorageResourceId itemId = item.getResourceId();
PrefixKey itemKey = new PrefixKey(itemId.getBucketName(), itemId.getObjectName());
CacheValue<GoogleCloudStorageItemInfo> itemValue =
new CacheValue<GoogleCloudStorageItemInfo>(item, creationTime);
itemMap.put(itemKey, itemValue);
}
} | [
"public",
"synchronized",
"void",
"putList",
"(",
"String",
"bucket",
",",
"@",
"Nullable",
"String",
"objectNamePrefix",
",",
"List",
"<",
"GoogleCloudStorageItemInfo",
">",
"items",
")",
"{",
"// Give all entries the same creation time so they expire at the same time.",
"long",
"creationTime",
"=",
"ticker",
".",
"read",
"(",
")",
";",
"PrefixKey",
"key",
"=",
"new",
"PrefixKey",
"(",
"bucket",
",",
"objectNamePrefix",
")",
";",
"// The list being inserted is always fresher than any child lists.",
"getPrefixSubMap",
"(",
"itemMap",
",",
"key",
")",
".",
"clear",
"(",
")",
";",
"getPrefixSubMap",
"(",
"prefixMap",
",",
"key",
")",
".",
"clear",
"(",
")",
";",
"// Populate the maps.",
"prefixMap",
".",
"put",
"(",
"key",
",",
"new",
"CacheValue",
"<",
"Object",
">",
"(",
"null",
",",
"creationTime",
")",
")",
";",
"for",
"(",
"GoogleCloudStorageItemInfo",
"item",
":",
"items",
")",
"{",
"StorageResourceId",
"itemId",
"=",
"item",
".",
"getResourceId",
"(",
")",
";",
"PrefixKey",
"itemKey",
"=",
"new",
"PrefixKey",
"(",
"itemId",
".",
"getBucketName",
"(",
")",
",",
"itemId",
".",
"getObjectName",
"(",
")",
")",
";",
"CacheValue",
"<",
"GoogleCloudStorageItemInfo",
">",
"itemValue",
"=",
"new",
"CacheValue",
"<",
"GoogleCloudStorageItemInfo",
">",
"(",
"item",
",",
"creationTime",
")",
";",
"itemMap",
".",
"put",
"(",
"itemKey",
",",
"itemValue",
")",
";",
"}",
"}"
] | Inserts a list entry and the given items into the cache. If a list entry under the same
bucket/objectNamePrefix is present, its expiration time is reset. If an item with the same
resource id is present, it is overwritten by the new item.
@param bucket the bucket to index the items by.
@param objectNamePrefix the object name prefix to index the items by. If this is null, it will
be converted to empty string.
@param items the list of items to insert. | [
"Inserts",
"a",
"list",
"entry",
"and",
"the",
"given",
"items",
"into",
"the",
"cache",
".",
"If",
"a",
"list",
"entry",
"under",
"the",
"same",
"bucket",
"/",
"objectNamePrefix",
"is",
"present",
"its",
"expiration",
"time",
"is",
"reset",
".",
"If",
"an",
"item",
"with",
"the",
"same",
"resource",
"id",
"is",
"present",
"it",
"is",
"overwritten",
"by",
"the",
"new",
"item",
"."
] | train | https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/gcsio/src/main/java/com/google/cloud/hadoop/gcsio/PrefixMappedItemCache.java#L164-L183 |
jtrfp/javamod | src/main/java/de/quippy/javamod/multimedia/mod/mixer/BasicModMixer.java | BasicModMixer.fillRampDataIntoBuffers | private void fillRampDataIntoBuffers(final int[] leftBuffer, final int[] rightBuffer, final ChannelMemory aktMemo) {
"""
Retrieves Sample Data without manipulating the currentSamplePos and currentTuningPos and currentDirection
(a kind of read ahead)
@since 18.06.2006
@param leftBuffer
@param rightBuffer
@param aktMemo
"""
// Remember changeable values
final int currentTuningPos = aktMemo.currentTuningPos;
final int currentSamplePos = aktMemo.currentSamplePos;
final int currentDirection = aktMemo.currentDirection;
final boolean instrumentFinished = aktMemo.instrumentFinished;
final int actRampVolLeft = aktMemo.actRampVolLeft;
final int actRampVolRight = aktMemo.actRampVolRight;
mixChannelIntoBuffers(leftBuffer, rightBuffer, 0, Helpers.VOL_RAMP_LEN, aktMemo);
// set them back
aktMemo.currentTuningPos = currentTuningPos;
aktMemo.currentSamplePos = currentSamplePos;
aktMemo.instrumentFinished = instrumentFinished;
aktMemo.currentDirection = currentDirection;
aktMemo.actRampVolLeft = actRampVolLeft;
aktMemo.actRampVolRight = actRampVolRight;
} | java | private void fillRampDataIntoBuffers(final int[] leftBuffer, final int[] rightBuffer, final ChannelMemory aktMemo)
{
// Remember changeable values
final int currentTuningPos = aktMemo.currentTuningPos;
final int currentSamplePos = aktMemo.currentSamplePos;
final int currentDirection = aktMemo.currentDirection;
final boolean instrumentFinished = aktMemo.instrumentFinished;
final int actRampVolLeft = aktMemo.actRampVolLeft;
final int actRampVolRight = aktMemo.actRampVolRight;
mixChannelIntoBuffers(leftBuffer, rightBuffer, 0, Helpers.VOL_RAMP_LEN, aktMemo);
// set them back
aktMemo.currentTuningPos = currentTuningPos;
aktMemo.currentSamplePos = currentSamplePos;
aktMemo.instrumentFinished = instrumentFinished;
aktMemo.currentDirection = currentDirection;
aktMemo.actRampVolLeft = actRampVolLeft;
aktMemo.actRampVolRight = actRampVolRight;
} | [
"private",
"void",
"fillRampDataIntoBuffers",
"(",
"final",
"int",
"[",
"]",
"leftBuffer",
",",
"final",
"int",
"[",
"]",
"rightBuffer",
",",
"final",
"ChannelMemory",
"aktMemo",
")",
"{",
"// Remember changeable values",
"final",
"int",
"currentTuningPos",
"=",
"aktMemo",
".",
"currentTuningPos",
";",
"final",
"int",
"currentSamplePos",
"=",
"aktMemo",
".",
"currentSamplePos",
";",
"final",
"int",
"currentDirection",
"=",
"aktMemo",
".",
"currentDirection",
";",
"final",
"boolean",
"instrumentFinished",
"=",
"aktMemo",
".",
"instrumentFinished",
";",
"final",
"int",
"actRampVolLeft",
"=",
"aktMemo",
".",
"actRampVolLeft",
";",
"final",
"int",
"actRampVolRight",
"=",
"aktMemo",
".",
"actRampVolRight",
";",
"mixChannelIntoBuffers",
"(",
"leftBuffer",
",",
"rightBuffer",
",",
"0",
",",
"Helpers",
".",
"VOL_RAMP_LEN",
",",
"aktMemo",
")",
";",
"// set them back",
"aktMemo",
".",
"currentTuningPos",
"=",
"currentTuningPos",
";",
"aktMemo",
".",
"currentSamplePos",
"=",
"currentSamplePos",
";",
"aktMemo",
".",
"instrumentFinished",
"=",
"instrumentFinished",
";",
"aktMemo",
".",
"currentDirection",
"=",
"currentDirection",
";",
"aktMemo",
".",
"actRampVolLeft",
"=",
"actRampVolLeft",
";",
"aktMemo",
".",
"actRampVolRight",
"=",
"actRampVolRight",
";",
"}"
] | Retrieves Sample Data without manipulating the currentSamplePos and currentTuningPos and currentDirection
(a kind of read ahead)
@since 18.06.2006
@param leftBuffer
@param rightBuffer
@param aktMemo | [
"Retrieves",
"Sample",
"Data",
"without",
"manipulating",
"the",
"currentSamplePos",
"and",
"currentTuningPos",
"and",
"currentDirection",
"(",
"a",
"kind",
"of",
"read",
"ahead",
")"
] | train | https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/javamod/multimedia/mod/mixer/BasicModMixer.java#L1292-L1311 |
GoogleCloudPlatform/bigdata-interop | util-hadoop/src/main/java/com/google/cloud/hadoop/util/ConfigurationUtil.java | ConfigurationUtil.getMandatoryConfig | public static String getMandatoryConfig(Configuration config, String key)
throws IOException {
"""
Gets value for the given key or throws if value is not found.
"""
String value = config.get(key);
if (Strings.isNullOrEmpty(value)) {
throw new IOException("Must supply a value for configuration setting: " + key);
}
return value;
} | java | public static String getMandatoryConfig(Configuration config, String key)
throws IOException {
String value = config.get(key);
if (Strings.isNullOrEmpty(value)) {
throw new IOException("Must supply a value for configuration setting: " + key);
}
return value;
} | [
"public",
"static",
"String",
"getMandatoryConfig",
"(",
"Configuration",
"config",
",",
"String",
"key",
")",
"throws",
"IOException",
"{",
"String",
"value",
"=",
"config",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Must supply a value for configuration setting: \"",
"+",
"key",
")",
";",
"}",
"return",
"value",
";",
"}"
] | Gets value for the given key or throws if value is not found. | [
"Gets",
"value",
"for",
"the",
"given",
"key",
"or",
"throws",
"if",
"value",
"is",
"not",
"found",
"."
] | train | https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/util-hadoop/src/main/java/com/google/cloud/hadoop/util/ConfigurationUtil.java#L35-L42 |
rampatra/jbot | jbot-example/src/main/java/example/jbot/slack/SlackBot.java | SlackBot.askWhetherToRepeat | @Controller
public void askWhetherToRepeat(WebSocketSession session, Event event) {
"""
This method will be invoked after {@link SlackBot#askTimeForMeeting(WebSocketSession, Event)}.
@param session
@param event
"""
if (event.getText().contains("yes")) {
reply(session, event, "Great! I will remind you tomorrow before the meeting.");
} else {
reply(session, event, "Okay, don't forget to attend the meeting tomorrow :)");
}
stopConversation(event); // stop conversation
} | java | @Controller
public void askWhetherToRepeat(WebSocketSession session, Event event) {
if (event.getText().contains("yes")) {
reply(session, event, "Great! I will remind you tomorrow before the meeting.");
} else {
reply(session, event, "Okay, don't forget to attend the meeting tomorrow :)");
}
stopConversation(event); // stop conversation
} | [
"@",
"Controller",
"public",
"void",
"askWhetherToRepeat",
"(",
"WebSocketSession",
"session",
",",
"Event",
"event",
")",
"{",
"if",
"(",
"event",
".",
"getText",
"(",
")",
".",
"contains",
"(",
"\"yes\"",
")",
")",
"{",
"reply",
"(",
"session",
",",
"event",
",",
"\"Great! I will remind you tomorrow before the meeting.\"",
")",
";",
"}",
"else",
"{",
"reply",
"(",
"session",
",",
"event",
",",
"\"Okay, don't forget to attend the meeting tomorrow :)\"",
")",
";",
"}",
"stopConversation",
"(",
"event",
")",
";",
"// stop conversation",
"}"
] | This method will be invoked after {@link SlackBot#askTimeForMeeting(WebSocketSession, Event)}.
@param session
@param event | [
"This",
"method",
"will",
"be",
"invoked",
"after",
"{",
"@link",
"SlackBot#askTimeForMeeting",
"(",
"WebSocketSession",
"Event",
")",
"}",
"."
] | train | https://github.com/rampatra/jbot/blob/0f42e1a6ec4dcbc5d1257e1307704903e771f7b5/jbot-example/src/main/java/example/jbot/slack/SlackBot.java#L155-L163 |
TheCoder4eu/BootsFaces-OSP | src/main/java/net/bootsfaces/component/button/ButtonRenderer.java | ButtonRenderer.determineTargetURL | private String determineTargetURL(FacesContext context, Button button, String outcome) {
"""
Translate the outcome attribute value to the target URL.
@param context
the current FacesContext
@param outcome
the value of the outcome attribute
@return the target URL of the navigation rule (or the outcome if there's
not navigation rule)
"""
ConfigurableNavigationHandler cnh = (ConfigurableNavigationHandler) context.getApplication()
.getNavigationHandler();
NavigationCase navCase = cnh.getNavigationCase(context, null, outcome);
/*
* Param Name: javax.faces.PROJECT_STAGE Default Value: The default
* value is ProjectStage#Production but IDE can set it differently in
* web.xml Expected Values: Development, Production, SystemTest,
* UnitTest Since: 2.0
*
* If we cannot get an outcome we use an Alert to give a feedback to the
* Developer if this build is in the Development Stage
*/
if (navCase == null) {
if (FacesContext.getCurrentInstance().getApplication().getProjectStage().equals(ProjectStage.Development)) {
return "alert('WARNING! " + C.W_NONAVCASE_BUTTON + "');";
} else {
return "";
}
} // throw new FacesException("The outcome '"+outcome+"' cannot be
// resolved."); }
String vId = navCase.getToViewId(context);
Map<String, List<String>> params = getParams(navCase, button);
String url;
url = context.getApplication().getViewHandler().getBookmarkableURL(context, vId, params,
button.isIncludeViewParams() || navCase.isIncludeViewParams());
return url;
} | java | private String determineTargetURL(FacesContext context, Button button, String outcome) {
ConfigurableNavigationHandler cnh = (ConfigurableNavigationHandler) context.getApplication()
.getNavigationHandler();
NavigationCase navCase = cnh.getNavigationCase(context, null, outcome);
/*
* Param Name: javax.faces.PROJECT_STAGE Default Value: The default
* value is ProjectStage#Production but IDE can set it differently in
* web.xml Expected Values: Development, Production, SystemTest,
* UnitTest Since: 2.0
*
* If we cannot get an outcome we use an Alert to give a feedback to the
* Developer if this build is in the Development Stage
*/
if (navCase == null) {
if (FacesContext.getCurrentInstance().getApplication().getProjectStage().equals(ProjectStage.Development)) {
return "alert('WARNING! " + C.W_NONAVCASE_BUTTON + "');";
} else {
return "";
}
} // throw new FacesException("The outcome '"+outcome+"' cannot be
// resolved."); }
String vId = navCase.getToViewId(context);
Map<String, List<String>> params = getParams(navCase, button);
String url;
url = context.getApplication().getViewHandler().getBookmarkableURL(context, vId, params,
button.isIncludeViewParams() || navCase.isIncludeViewParams());
return url;
} | [
"private",
"String",
"determineTargetURL",
"(",
"FacesContext",
"context",
",",
"Button",
"button",
",",
"String",
"outcome",
")",
"{",
"ConfigurableNavigationHandler",
"cnh",
"=",
"(",
"ConfigurableNavigationHandler",
")",
"context",
".",
"getApplication",
"(",
")",
".",
"getNavigationHandler",
"(",
")",
";",
"NavigationCase",
"navCase",
"=",
"cnh",
".",
"getNavigationCase",
"(",
"context",
",",
"null",
",",
"outcome",
")",
";",
"/*\n\t\t * Param Name: javax.faces.PROJECT_STAGE Default Value: The default\n\t\t * value is ProjectStage#Production but IDE can set it differently in\n\t\t * web.xml Expected Values: Development, Production, SystemTest,\n\t\t * UnitTest Since: 2.0\n\t\t *\n\t\t * If we cannot get an outcome we use an Alert to give a feedback to the\n\t\t * Developer if this build is in the Development Stage\n\t\t */",
"if",
"(",
"navCase",
"==",
"null",
")",
"{",
"if",
"(",
"FacesContext",
".",
"getCurrentInstance",
"(",
")",
".",
"getApplication",
"(",
")",
".",
"getProjectStage",
"(",
")",
".",
"equals",
"(",
"ProjectStage",
".",
"Development",
")",
")",
"{",
"return",
"\"alert('WARNING! \"",
"+",
"C",
".",
"W_NONAVCASE_BUTTON",
"+",
"\"');\"",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}",
"// throw new FacesException(\"The outcome '\"+outcome+\"' cannot be",
"// resolved.\"); }",
"String",
"vId",
"=",
"navCase",
".",
"getToViewId",
"(",
"context",
")",
";",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"params",
"=",
"getParams",
"(",
"navCase",
",",
"button",
")",
";",
"String",
"url",
";",
"url",
"=",
"context",
".",
"getApplication",
"(",
")",
".",
"getViewHandler",
"(",
")",
".",
"getBookmarkableURL",
"(",
"context",
",",
"vId",
",",
"params",
",",
"button",
".",
"isIncludeViewParams",
"(",
")",
"||",
"navCase",
".",
"isIncludeViewParams",
"(",
")",
")",
";",
"return",
"url",
";",
"}"
] | Translate the outcome attribute value to the target URL.
@param context
the current FacesContext
@param outcome
the value of the outcome attribute
@return the target URL of the navigation rule (or the outcome if there's
not navigation rule) | [
"Translate",
"the",
"outcome",
"attribute",
"value",
"to",
"the",
"target",
"URL",
"."
] | train | https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/component/button/ButtonRenderer.java#L297-L325 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java | NormOps_DDRM.fastElementP | public static double fastElementP(DMatrixD1 A , double p ) {
"""
Same as {@link #elementP} but runs faster by not mitigating overflow/underflow related problems.
@param A Matrix. Not modified.
@param p p value.
@return The norm's value.
"""
if( p == 2 ) {
return fastNormF(A);
} else {
double total = 0;
int size = A.getNumElements();
for( int i = 0; i < size; i++ ) {
double a = A.get(i);
total += Math.pow(Math.abs(a),p);
}
return Math.pow(total,1.0/p);
}
} | java | public static double fastElementP(DMatrixD1 A , double p ) {
if( p == 2 ) {
return fastNormF(A);
} else {
double total = 0;
int size = A.getNumElements();
for( int i = 0; i < size; i++ ) {
double a = A.get(i);
total += Math.pow(Math.abs(a),p);
}
return Math.pow(total,1.0/p);
}
} | [
"public",
"static",
"double",
"fastElementP",
"(",
"DMatrixD1",
"A",
",",
"double",
"p",
")",
"{",
"if",
"(",
"p",
"==",
"2",
")",
"{",
"return",
"fastNormF",
"(",
"A",
")",
";",
"}",
"else",
"{",
"double",
"total",
"=",
"0",
";",
"int",
"size",
"=",
"A",
".",
"getNumElements",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"double",
"a",
"=",
"A",
".",
"get",
"(",
"i",
")",
";",
"total",
"+=",
"Math",
".",
"pow",
"(",
"Math",
".",
"abs",
"(",
"a",
")",
",",
"p",
")",
";",
"}",
"return",
"Math",
".",
"pow",
"(",
"total",
",",
"1.0",
"/",
"p",
")",
";",
"}",
"}"
] | Same as {@link #elementP} but runs faster by not mitigating overflow/underflow related problems.
@param A Matrix. Not modified.
@param p p value.
@return The norm's value. | [
"Same",
"as",
"{",
"@link",
"#elementP",
"}",
"but",
"runs",
"faster",
"by",
"not",
"mitigating",
"overflow",
"/",
"underflow",
"related",
"problems",
"."
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L259-L275 |
moparisthebest/beehive | beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/FlowController.java | FlowController.invokeActionMethod | protected ActionForward invokeActionMethod( Method method, Object arg )
throws Exception {
"""
Invoke the given action handler method, passing it an argument if appropriate.
@param method the action handler method to invoke.
@param arg the form-bean to pass; may be <code>null</code>.
@return the ActionForward returned by the action handler method.
@throws Exception if an Exception was raised in user code.
"""
return invokeActionMethod( method, arg, getRequest(), getActionMapping() );
} | java | protected ActionForward invokeActionMethod( Method method, Object arg )
throws Exception
{
return invokeActionMethod( method, arg, getRequest(), getActionMapping() );
} | [
"protected",
"ActionForward",
"invokeActionMethod",
"(",
"Method",
"method",
",",
"Object",
"arg",
")",
"throws",
"Exception",
"{",
"return",
"invokeActionMethod",
"(",
"method",
",",
"arg",
",",
"getRequest",
"(",
")",
",",
"getActionMapping",
"(",
")",
")",
";",
"}"
] | Invoke the given action handler method, passing it an argument if appropriate.
@param method the action handler method to invoke.
@param arg the form-bean to pass; may be <code>null</code>.
@return the ActionForward returned by the action handler method.
@throws Exception if an Exception was raised in user code. | [
"Invoke",
"the",
"given",
"action",
"handler",
"method",
"passing",
"it",
"an",
"argument",
"if",
"appropriate",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/FlowController.java#L842-L846 |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/KeeperException.java | KeeperException.create | public static KeeperException create(Code code, String path) {
"""
All non-specific keeper exceptions should be constructed via this factory
method in order to guarantee consistency in error codes and such. If you
know the error code, then you should construct the special purpose
exception directly. That will allow you to have the most specific
possible declarations of what exceptions might actually be thrown.
@param code
The error code.
@param path
The ZooKeeper path being operated on.
@return The specialized exception, presumably to be thrown by the caller.
"""
KeeperException r = create(code);
r.path = path;
return r;
} | java | public static KeeperException create(Code code, String path) {
KeeperException r = create(code);
r.path = path;
return r;
} | [
"public",
"static",
"KeeperException",
"create",
"(",
"Code",
"code",
",",
"String",
"path",
")",
"{",
"KeeperException",
"r",
"=",
"create",
"(",
"code",
")",
";",
"r",
".",
"path",
"=",
"path",
";",
"return",
"r",
";",
"}"
] | All non-specific keeper exceptions should be constructed via this factory
method in order to guarantee consistency in error codes and such. If you
know the error code, then you should construct the special purpose
exception directly. That will allow you to have the most specific
possible declarations of what exceptions might actually be thrown.
@param code
The error code.
@param path
The ZooKeeper path being operated on.
@return The specialized exception, presumably to be thrown by the caller. | [
"All",
"non",
"-",
"specific",
"keeper",
"exceptions",
"should",
"be",
"constructed",
"via",
"this",
"factory",
"method",
"in",
"order",
"to",
"guarantee",
"consistency",
"in",
"error",
"codes",
"and",
"such",
".",
"If",
"you",
"know",
"the",
"error",
"code",
"then",
"you",
"should",
"construct",
"the",
"special",
"purpose",
"exception",
"directly",
".",
"That",
"will",
"allow",
"you",
"to",
"have",
"the",
"most",
"specific",
"possible",
"declarations",
"of",
"what",
"exceptions",
"might",
"actually",
"be",
"thrown",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/KeeperException.java#L43-L47 |
libgdx/gdx-ai | gdx-ai/src/com/badlogic/gdx/ai/utils/random/TriangularDoubleDistribution.java | TriangularDoubleDistribution.randomTriangular | static double randomTriangular (double low, double high, double mode) {
"""
Returns a triangularly distributed random number between {@code low} (inclusive) and {@code high} (exclusive), where values
around {@code mode} are more likely.
@param low the lower limit
@param high the upper limit
@param mode the point around which the values are more likely
"""
double u = MathUtils.random.nextDouble();
double d = high - low;
if (u <= (mode - low) / d) return low + Math.sqrt(u * d * (mode - low));
return high - Math.sqrt((1 - u) * d * (high - mode));
} | java | static double randomTriangular (double low, double high, double mode) {
double u = MathUtils.random.nextDouble();
double d = high - low;
if (u <= (mode - low) / d) return low + Math.sqrt(u * d * (mode - low));
return high - Math.sqrt((1 - u) * d * (high - mode));
} | [
"static",
"double",
"randomTriangular",
"(",
"double",
"low",
",",
"double",
"high",
",",
"double",
"mode",
")",
"{",
"double",
"u",
"=",
"MathUtils",
".",
"random",
".",
"nextDouble",
"(",
")",
";",
"double",
"d",
"=",
"high",
"-",
"low",
";",
"if",
"(",
"u",
"<=",
"(",
"mode",
"-",
"low",
")",
"/",
"d",
")",
"return",
"low",
"+",
"Math",
".",
"sqrt",
"(",
"u",
"*",
"d",
"*",
"(",
"mode",
"-",
"low",
")",
")",
";",
"return",
"high",
"-",
"Math",
".",
"sqrt",
"(",
"(",
"1",
"-",
"u",
")",
"*",
"d",
"*",
"(",
"high",
"-",
"mode",
")",
")",
";",
"}"
] | Returns a triangularly distributed random number between {@code low} (inclusive) and {@code high} (exclusive), where values
around {@code mode} are more likely.
@param low the lower limit
@param high the upper limit
@param mode the point around which the values are more likely | [
"Returns",
"a",
"triangularly",
"distributed",
"random",
"number",
"between",
"{"
] | train | https://github.com/libgdx/gdx-ai/blob/2d1523a97193a45e18e11a4837c6800d08f177c5/gdx-ai/src/com/badlogic/gdx/ai/utils/random/TriangularDoubleDistribution.java#L74-L79 |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java | StreamExecutionEnvironment.readFile | @PublicEvolving
public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
String filePath,
FileProcessingMode watchType,
long interval,
TypeInformation<OUT> typeInformation) {
"""
Reads the contents of the user-specified {@code filePath} based on the given {@link FileInputFormat}.
Depending on the provided {@link FileProcessingMode}, the source may periodically monitor (every {@code interval} ms)
the path for new data ({@link FileProcessingMode#PROCESS_CONTINUOUSLY}), or process once the data currently in the
path and exit ({@link FileProcessingMode#PROCESS_ONCE}). In addition, if the path contains files not to be processed,
the user can specify a custom {@link FilePathFilter}. As a default implementation you can use
{@link FilePathFilter#createDefaultFilter()}.
<p><b>NOTES ON CHECKPOINTING: </b> If the {@code watchType} is set to {@link FileProcessingMode#PROCESS_ONCE},
the source monitors the path <b>once</b>, creates the {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits}
to be processed, forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
and exits, without waiting for the readers to finish reading. This implies that no more checkpoint barriers
are going to be forwarded after the source exits, thus having no checkpoints after that point.
@param inputFormat
The input format used to create the data stream
@param filePath
The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
@param watchType
The mode in which the source should operate, i.e. monitor path and react to new data, or process once and exit
@param typeInformation
Information on the type of the elements in the output stream
@param interval
In the case of periodic path monitoring, this specifies the interval (in millis) between consecutive path scans
@param <OUT>
The type of the returned data stream
@return The data stream that represents the data read from the given file
"""
Preconditions.checkNotNull(inputFormat, "InputFormat must not be null.");
Preconditions.checkArgument(!StringUtils.isNullOrWhitespaceOnly(filePath), "The file path must not be null or blank.");
inputFormat.setFilePath(filePath);
return createFileInput(inputFormat, typeInformation, "Custom File Source", watchType, interval);
} | java | @PublicEvolving
public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
String filePath,
FileProcessingMode watchType,
long interval,
TypeInformation<OUT> typeInformation) {
Preconditions.checkNotNull(inputFormat, "InputFormat must not be null.");
Preconditions.checkArgument(!StringUtils.isNullOrWhitespaceOnly(filePath), "The file path must not be null or blank.");
inputFormat.setFilePath(filePath);
return createFileInput(inputFormat, typeInformation, "Custom File Source", watchType, interval);
} | [
"@",
"PublicEvolving",
"public",
"<",
"OUT",
">",
"DataStreamSource",
"<",
"OUT",
">",
"readFile",
"(",
"FileInputFormat",
"<",
"OUT",
">",
"inputFormat",
",",
"String",
"filePath",
",",
"FileProcessingMode",
"watchType",
",",
"long",
"interval",
",",
"TypeInformation",
"<",
"OUT",
">",
"typeInformation",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"inputFormat",
",",
"\"InputFormat must not be null.\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"StringUtils",
".",
"isNullOrWhitespaceOnly",
"(",
"filePath",
")",
",",
"\"The file path must not be null or blank.\"",
")",
";",
"inputFormat",
".",
"setFilePath",
"(",
"filePath",
")",
";",
"return",
"createFileInput",
"(",
"inputFormat",
",",
"typeInformation",
",",
"\"Custom File Source\"",
",",
"watchType",
",",
"interval",
")",
";",
"}"
] | Reads the contents of the user-specified {@code filePath} based on the given {@link FileInputFormat}.
Depending on the provided {@link FileProcessingMode}, the source may periodically monitor (every {@code interval} ms)
the path for new data ({@link FileProcessingMode#PROCESS_CONTINUOUSLY}), or process once the data currently in the
path and exit ({@link FileProcessingMode#PROCESS_ONCE}). In addition, if the path contains files not to be processed,
the user can specify a custom {@link FilePathFilter}. As a default implementation you can use
{@link FilePathFilter#createDefaultFilter()}.
<p><b>NOTES ON CHECKPOINTING: </b> If the {@code watchType} is set to {@link FileProcessingMode#PROCESS_ONCE},
the source monitors the path <b>once</b>, creates the {@link org.apache.flink.core.fs.FileInputSplit FileInputSplits}
to be processed, forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
and exits, without waiting for the readers to finish reading. This implies that no more checkpoint barriers
are going to be forwarded after the source exits, thus having no checkpoints after that point.
@param inputFormat
The input format used to create the data stream
@param filePath
The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
@param watchType
The mode in which the source should operate, i.e. monitor path and react to new data, or process once and exit
@param typeInformation
Information on the type of the elements in the output stream
@param interval
In the case of periodic path monitoring, this specifies the interval (in millis) between consecutive path scans
@param <OUT>
The type of the returned data stream
@return The data stream that represents the data read from the given file | [
"Reads",
"the",
"contents",
"of",
"the",
"user",
"-",
"specified",
"{",
"@code",
"filePath",
"}",
"based",
"on",
"the",
"given",
"{",
"@link",
"FileInputFormat",
"}",
".",
"Depending",
"on",
"the",
"provided",
"{",
"@link",
"FileProcessingMode",
"}",
"the",
"source",
"may",
"periodically",
"monitor",
"(",
"every",
"{",
"@code",
"interval",
"}",
"ms",
")",
"the",
"path",
"for",
"new",
"data",
"(",
"{",
"@link",
"FileProcessingMode#PROCESS_CONTINUOUSLY",
"}",
")",
"or",
"process",
"once",
"the",
"data",
"currently",
"in",
"the",
"path",
"and",
"exit",
"(",
"{",
"@link",
"FileProcessingMode#PROCESS_ONCE",
"}",
")",
".",
"In",
"addition",
"if",
"the",
"path",
"contains",
"files",
"not",
"to",
"be",
"processed",
"the",
"user",
"can",
"specify",
"a",
"custom",
"{",
"@link",
"FilePathFilter",
"}",
".",
"As",
"a",
"default",
"implementation",
"you",
"can",
"use",
"{",
"@link",
"FilePathFilter#createDefaultFilter",
"()",
"}",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java#L1149-L1161 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/io/util/SequentialWriter.java | SequentialWriter.writeAtMost | private int writeAtMost(ByteBuffer data, int offset, int length) {
"""
/*
Write at most "length" bytes from "data" starting at position "offset", and
return the number of bytes written. caller is responsible for setting
isDirty.
"""
if (current >= bufferOffset + buffer.length)
reBuffer();
assert current < bufferOffset + buffer.length
: String.format("File (%s) offset %d, buffer offset %d.", getPath(), current, bufferOffset);
int toCopy = Math.min(length, buffer.length - bufferCursor());
// copy bytes from external buffer
ByteBufferUtil.arrayCopy(data, offset, buffer, bufferCursor(), toCopy);
assert current <= bufferOffset + buffer.length
: String.format("File (%s) offset %d, buffer offset %d.", getPath(), current, bufferOffset);
validBufferBytes = Math.max(validBufferBytes, bufferCursor() + toCopy);
current += toCopy;
return toCopy;
} | java | private int writeAtMost(ByteBuffer data, int offset, int length)
{
if (current >= bufferOffset + buffer.length)
reBuffer();
assert current < bufferOffset + buffer.length
: String.format("File (%s) offset %d, buffer offset %d.", getPath(), current, bufferOffset);
int toCopy = Math.min(length, buffer.length - bufferCursor());
// copy bytes from external buffer
ByteBufferUtil.arrayCopy(data, offset, buffer, bufferCursor(), toCopy);
assert current <= bufferOffset + buffer.length
: String.format("File (%s) offset %d, buffer offset %d.", getPath(), current, bufferOffset);
validBufferBytes = Math.max(validBufferBytes, bufferCursor() + toCopy);
current += toCopy;
return toCopy;
} | [
"private",
"int",
"writeAtMost",
"(",
"ByteBuffer",
"data",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"if",
"(",
"current",
">=",
"bufferOffset",
"+",
"buffer",
".",
"length",
")",
"reBuffer",
"(",
")",
";",
"assert",
"current",
"<",
"bufferOffset",
"+",
"buffer",
".",
"length",
":",
"String",
".",
"format",
"(",
"\"File (%s) offset %d, buffer offset %d.\"",
",",
"getPath",
"(",
")",
",",
"current",
",",
"bufferOffset",
")",
";",
"int",
"toCopy",
"=",
"Math",
".",
"min",
"(",
"length",
",",
"buffer",
".",
"length",
"-",
"bufferCursor",
"(",
")",
")",
";",
"// copy bytes from external buffer",
"ByteBufferUtil",
".",
"arrayCopy",
"(",
"data",
",",
"offset",
",",
"buffer",
",",
"bufferCursor",
"(",
")",
",",
"toCopy",
")",
";",
"assert",
"current",
"<=",
"bufferOffset",
"+",
"buffer",
".",
"length",
":",
"String",
".",
"format",
"(",
"\"File (%s) offset %d, buffer offset %d.\"",
",",
"getPath",
"(",
")",
",",
"current",
",",
"bufferOffset",
")",
";",
"validBufferBytes",
"=",
"Math",
".",
"max",
"(",
"validBufferBytes",
",",
"bufferCursor",
"(",
")",
"+",
"toCopy",
")",
";",
"current",
"+=",
"toCopy",
";",
"return",
"toCopy",
";",
"}"
] | /*
Write at most "length" bytes from "data" starting at position "offset", and
return the number of bytes written. caller is responsible for setting
isDirty. | [
"/",
"*",
"Write",
"at",
"most",
"length",
"bytes",
"from",
"data",
"starting",
"at",
"position",
"offset",
"and",
"return",
"the",
"number",
"of",
"bytes",
"written",
".",
"caller",
"is",
"responsible",
"for",
"setting",
"isDirty",
"."
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/util/SequentialWriter.java#L187-L208 |
agmip/agmip-common-functions | src/main/java/org/agmip/common/Event.java | Event.addEvent | public HashMap addEvent(String date, boolean useTemp) {
"""
Add a new event into array with selected event type and input date.
@param date The event date
@param useTemp True for using template to create new data
@return The generated event data map
"""
HashMap ret = new HashMap();
if (useTemp) {
ret.putAll(template);
} else {
ret.put("event", eventType);
}
ret.put("date", date);
getInertIndex(ret);
events.add(next, ret);
return ret;
} | java | public HashMap addEvent(String date, boolean useTemp) {
HashMap ret = new HashMap();
if (useTemp) {
ret.putAll(template);
} else {
ret.put("event", eventType);
}
ret.put("date", date);
getInertIndex(ret);
events.add(next, ret);
return ret;
} | [
"public",
"HashMap",
"addEvent",
"(",
"String",
"date",
",",
"boolean",
"useTemp",
")",
"{",
"HashMap",
"ret",
"=",
"new",
"HashMap",
"(",
")",
";",
"if",
"(",
"useTemp",
")",
"{",
"ret",
".",
"putAll",
"(",
"template",
")",
";",
"}",
"else",
"{",
"ret",
".",
"put",
"(",
"\"event\"",
",",
"eventType",
")",
";",
"}",
"ret",
".",
"put",
"(",
"\"date\"",
",",
"date",
")",
";",
"getInertIndex",
"(",
"ret",
")",
";",
"events",
".",
"add",
"(",
"next",
",",
"ret",
")",
";",
"return",
"ret",
";",
"}"
] | Add a new event into array with selected event type and input date.
@param date The event date
@param useTemp True for using template to create new data
@return The generated event data map | [
"Add",
"a",
"new",
"event",
"into",
"array",
"with",
"selected",
"event",
"type",
"and",
"input",
"date",
"."
] | train | https://github.com/agmip/agmip-common-functions/blob/4efa3042178841b026ca6fba9c96da02fbfb9a8e/src/main/java/org/agmip/common/Event.java#L123-L134 |
alkacon/opencms-core | src/org/opencms/file/CmsObject.java | CmsObject.restoreResourceVersion | public void restoreResourceVersion(CmsUUID structureId, int version) throws CmsException {
"""
Restores a resource in the current project with a version from the historical archive.<p>
@param structureId the structure id of the resource to restore from the archive
@param version the desired version of the resource to be restored
@throws CmsException if something goes wrong
@see #readResource(CmsUUID, int)
"""
CmsResource resource = readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
getResourceType(resource).restoreResource(this, m_securityManager, resource, version);
} | java | public void restoreResourceVersion(CmsUUID structureId, int version) throws CmsException {
CmsResource resource = readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION);
getResourceType(resource).restoreResource(this, m_securityManager, resource, version);
} | [
"public",
"void",
"restoreResourceVersion",
"(",
"CmsUUID",
"structureId",
",",
"int",
"version",
")",
"throws",
"CmsException",
"{",
"CmsResource",
"resource",
"=",
"readResource",
"(",
"structureId",
",",
"CmsResourceFilter",
".",
"IGNORE_EXPIRATION",
")",
";",
"getResourceType",
"(",
"resource",
")",
".",
"restoreResource",
"(",
"this",
",",
"m_securityManager",
",",
"resource",
",",
"version",
")",
";",
"}"
] | Restores a resource in the current project with a version from the historical archive.<p>
@param structureId the structure id of the resource to restore from the archive
@param version the desired version of the resource to be restored
@throws CmsException if something goes wrong
@see #readResource(CmsUUID, int) | [
"Restores",
"a",
"resource",
"in",
"the",
"current",
"project",
"with",
"a",
"version",
"from",
"the",
"historical",
"archive",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/CmsObject.java#L3699-L3703 |
apache/flink | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/windowing/delta/ExtractionAwareDeltaFunction.java | ExtractionAwareDeltaFunction.getDelta | @SuppressWarnings("unchecked")
@Override
public double getDelta(DATA oldDataPoint, DATA newDataPoint) {
"""
This method takes the two data point and runs the set extractor on it.
The delta function implemented at {@link #getNestedDelta} is then called
with the extracted data. In case no extractor is set the input data gets
passes to {@link #getNestedDelta} as-is. The return value is just
forwarded from {@link #getNestedDelta}.
@param oldDataPoint
the older data point as raw data (before extraction).
@param newDataPoint
the new data point as raw data (before extraction).
@return the delta between the two points.
"""
if (converter == null) {
// In case no conversion/extraction is required, we can cast DATA to
// TO
// => Therefore, "unchecked" warning is suppressed for this method.
return getNestedDelta((TO) oldDataPoint, (TO) newDataPoint);
} else {
return getNestedDelta(converter.extract(oldDataPoint), converter.extract(newDataPoint));
}
} | java | @SuppressWarnings("unchecked")
@Override
public double getDelta(DATA oldDataPoint, DATA newDataPoint) {
if (converter == null) {
// In case no conversion/extraction is required, we can cast DATA to
// TO
// => Therefore, "unchecked" warning is suppressed for this method.
return getNestedDelta((TO) oldDataPoint, (TO) newDataPoint);
} else {
return getNestedDelta(converter.extract(oldDataPoint), converter.extract(newDataPoint));
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"public",
"double",
"getDelta",
"(",
"DATA",
"oldDataPoint",
",",
"DATA",
"newDataPoint",
")",
"{",
"if",
"(",
"converter",
"==",
"null",
")",
"{",
"// In case no conversion/extraction is required, we can cast DATA to",
"// TO",
"// => Therefore, \"unchecked\" warning is suppressed for this method.",
"return",
"getNestedDelta",
"(",
"(",
"TO",
")",
"oldDataPoint",
",",
"(",
"TO",
")",
"newDataPoint",
")",
";",
"}",
"else",
"{",
"return",
"getNestedDelta",
"(",
"converter",
".",
"extract",
"(",
"oldDataPoint",
")",
",",
"converter",
".",
"extract",
"(",
"newDataPoint",
")",
")",
";",
"}",
"}"
] | This method takes the two data point and runs the set extractor on it.
The delta function implemented at {@link #getNestedDelta} is then called
with the extracted data. In case no extractor is set the input data gets
passes to {@link #getNestedDelta} as-is. The return value is just
forwarded from {@link #getNestedDelta}.
@param oldDataPoint
the older data point as raw data (before extraction).
@param newDataPoint
the new data point as raw data (before extraction).
@return the delta between the two points. | [
"This",
"method",
"takes",
"the",
"two",
"data",
"point",
"and",
"runs",
"the",
"set",
"extractor",
"on",
"it",
".",
"The",
"delta",
"function",
"implemented",
"at",
"{",
"@link",
"#getNestedDelta",
"}",
"is",
"then",
"called",
"with",
"the",
"extracted",
"data",
".",
"In",
"case",
"no",
"extractor",
"is",
"set",
"the",
"input",
"data",
"gets",
"passes",
"to",
"{",
"@link",
"#getNestedDelta",
"}",
"as",
"-",
"is",
".",
"The",
"return",
"value",
"is",
"just",
"forwarded",
"from",
"{",
"@link",
"#getNestedDelta",
"}",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/windowing/delta/ExtractionAwareDeltaFunction.java#L61-L73 |
knowm/XChart | xchart/src/main/java/org/knowm/xchart/CSVExporter.java | CSVExporter.writeCSVColumns | public static void writeCSVColumns(XYChart chart, String path2Dir) {
"""
Export all XYChart series as columns in separate CSV files.
@param chart
@param path2Dir
"""
for (XYSeries xySeries : chart.getSeriesMap().values()) {
writeCSVColumns(xySeries, path2Dir);
}
} | java | public static void writeCSVColumns(XYChart chart, String path2Dir) {
for (XYSeries xySeries : chart.getSeriesMap().values()) {
writeCSVColumns(xySeries, path2Dir);
}
} | [
"public",
"static",
"void",
"writeCSVColumns",
"(",
"XYChart",
"chart",
",",
"String",
"path2Dir",
")",
"{",
"for",
"(",
"XYSeries",
"xySeries",
":",
"chart",
".",
"getSeriesMap",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"writeCSVColumns",
"(",
"xySeries",
",",
"path2Dir",
")",
";",
"}",
"}"
] | Export all XYChart series as columns in separate CSV files.
@param chart
@param path2Dir | [
"Export",
"all",
"XYChart",
"series",
"as",
"columns",
"in",
"separate",
"CSV",
"files",
"."
] | train | https://github.com/knowm/XChart/blob/677a105753a855edf24782fab1bf1f5aec3e642b/xchart/src/main/java/org/knowm/xchart/CSVExporter.java#L91-L96 |
bazaarvoice/emodb | event/src/main/java/com/bazaarvoice/emodb/event/db/astyanax/AstyanaxEventId.java | AstyanaxEventId.computeChecksum | private static int computeChecksum(byte[] buf, int offset, int length, String channel) {
"""
Computes a 16-bit checksum of the contents of the specific ByteBuffer and channel name.
"""
Hasher hasher = Hashing.murmur3_32().newHasher();
hasher.putBytes(buf, offset, length);
hasher.putUnencodedChars(channel);
return hasher.hash().asInt() & 0xffff;
} | java | private static int computeChecksum(byte[] buf, int offset, int length, String channel) {
Hasher hasher = Hashing.murmur3_32().newHasher();
hasher.putBytes(buf, offset, length);
hasher.putUnencodedChars(channel);
return hasher.hash().asInt() & 0xffff;
} | [
"private",
"static",
"int",
"computeChecksum",
"(",
"byte",
"[",
"]",
"buf",
",",
"int",
"offset",
",",
"int",
"length",
",",
"String",
"channel",
")",
"{",
"Hasher",
"hasher",
"=",
"Hashing",
".",
"murmur3_32",
"(",
")",
".",
"newHasher",
"(",
")",
";",
"hasher",
".",
"putBytes",
"(",
"buf",
",",
"offset",
",",
"length",
")",
";",
"hasher",
".",
"putUnencodedChars",
"(",
"channel",
")",
";",
"return",
"hasher",
".",
"hash",
"(",
")",
".",
"asInt",
"(",
")",
"&",
"0xffff",
";",
"}"
] | Computes a 16-bit checksum of the contents of the specific ByteBuffer and channel name. | [
"Computes",
"a",
"16",
"-",
"bit",
"checksum",
"of",
"the",
"contents",
"of",
"the",
"specific",
"ByteBuffer",
"and",
"channel",
"name",
"."
] | train | https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/event/src/main/java/com/bazaarvoice/emodb/event/db/astyanax/AstyanaxEventId.java#L75-L80 |
Metatavu/edelphi | edelphi/src/main/java/fi/metatavu/edelphi/query/thesis/AbstractScaleThesisQueryPageHandler.java | AbstractScaleThesisQueryPageHandler.synchronizeField | protected void synchronizeField(Map<String, String> settings, QueryPage queryPage, QueryOption optionsOption, String fieldName, String fieldCaption, Boolean mandatory) {
"""
Synchronizes field meta. Should not be used when field already contains replies
@param settings settings map
@param queryPage query page
@param optionsOption page option
@param fieldName field name
@param fieldCaption field caption
@param mandatory whether field is mandatory
"""
List<String> options = QueryPageUtils.parseSerializedList(settings.get(optionsOption.getName()));
synchronizeField(queryPage, options, fieldName, fieldCaption, mandatory);
} | java | protected void synchronizeField(Map<String, String> settings, QueryPage queryPage, QueryOption optionsOption, String fieldName, String fieldCaption, Boolean mandatory) {
List<String> options = QueryPageUtils.parseSerializedList(settings.get(optionsOption.getName()));
synchronizeField(queryPage, options, fieldName, fieldCaption, mandatory);
} | [
"protected",
"void",
"synchronizeField",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"settings",
",",
"QueryPage",
"queryPage",
",",
"QueryOption",
"optionsOption",
",",
"String",
"fieldName",
",",
"String",
"fieldCaption",
",",
"Boolean",
"mandatory",
")",
"{",
"List",
"<",
"String",
">",
"options",
"=",
"QueryPageUtils",
".",
"parseSerializedList",
"(",
"settings",
".",
"get",
"(",
"optionsOption",
".",
"getName",
"(",
")",
")",
")",
";",
"synchronizeField",
"(",
"queryPage",
",",
"options",
",",
"fieldName",
",",
"fieldCaption",
",",
"mandatory",
")",
";",
"}"
] | Synchronizes field meta. Should not be used when field already contains replies
@param settings settings map
@param queryPage query page
@param optionsOption page option
@param fieldName field name
@param fieldCaption field caption
@param mandatory whether field is mandatory | [
"Synchronizes",
"field",
"meta",
".",
"Should",
"not",
"be",
"used",
"when",
"field",
"already",
"contains",
"replies"
] | train | https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/query/thesis/AbstractScaleThesisQueryPageHandler.java#L131-L134 |
Gagravarr/VorbisJava | core/src/main/java/org/gagravarr/vorbis/VorbisStyleComments.java | VorbisStyleComments.setComments | public void setComments(String tag, List<String> comments) {
"""
Removes any existing comments for a given tag,
and replaces them with the supplied list
"""
String nt = normaliseTag(tag);
if(this.comments.containsKey(nt)) {
this.comments.remove(nt);
}
this.comments.put(nt, comments);
} | java | public void setComments(String tag, List<String> comments) {
String nt = normaliseTag(tag);
if(this.comments.containsKey(nt)) {
this.comments.remove(nt);
}
this.comments.put(nt, comments);
} | [
"public",
"void",
"setComments",
"(",
"String",
"tag",
",",
"List",
"<",
"String",
">",
"comments",
")",
"{",
"String",
"nt",
"=",
"normaliseTag",
"(",
"tag",
")",
";",
"if",
"(",
"this",
".",
"comments",
".",
"containsKey",
"(",
"nt",
")",
")",
"{",
"this",
".",
"comments",
".",
"remove",
"(",
"nt",
")",
";",
"}",
"this",
".",
"comments",
".",
"put",
"(",
"nt",
",",
"comments",
")",
";",
"}"
] | Removes any existing comments for a given tag,
and replaces them with the supplied list | [
"Removes",
"any",
"existing",
"comments",
"for",
"a",
"given",
"tag",
"and",
"replaces",
"them",
"with",
"the",
"supplied",
"list"
] | train | https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/vorbis/VorbisStyleComments.java#L220-L226 |
zaproxy/zaproxy | src/org/zaproxy/zap/extension/autoupdate/AddOnWrapper.java | AddOnWrapper.setUpdateIssues | public void setUpdateIssues(String updateIssues, boolean addOnIssues) {
"""
Sets the issues that the newer version of the wrapped add-on or its extensions might have that prevents them from being
run.
<p>
The contents should be in HTML.
@param updateIssues the running issues of the add-on or its extensions, empty if there's no issues.
@param addOnIssues {@code true} if the issues are caused by the add-on, {@code false} if are caused by the extensions
@since 2.4.0
@see #getUpdateIssues()
"""
Validate.notNull(updateIssues, "Parameter updateIssues must not be null.");
this.updateIssues = updateIssues;
this.addOnUpdateIssues = addOnIssues;
} | java | public void setUpdateIssues(String updateIssues, boolean addOnIssues) {
Validate.notNull(updateIssues, "Parameter updateIssues must not be null.");
this.updateIssues = updateIssues;
this.addOnUpdateIssues = addOnIssues;
} | [
"public",
"void",
"setUpdateIssues",
"(",
"String",
"updateIssues",
",",
"boolean",
"addOnIssues",
")",
"{",
"Validate",
".",
"notNull",
"(",
"updateIssues",
",",
"\"Parameter updateIssues must not be null.\"",
")",
";",
"this",
".",
"updateIssues",
"=",
"updateIssues",
";",
"this",
".",
"addOnUpdateIssues",
"=",
"addOnIssues",
";",
"}"
] | Sets the issues that the newer version of the wrapped add-on or its extensions might have that prevents them from being
run.
<p>
The contents should be in HTML.
@param updateIssues the running issues of the add-on or its extensions, empty if there's no issues.
@param addOnIssues {@code true} if the issues are caused by the add-on, {@code false} if are caused by the extensions
@since 2.4.0
@see #getUpdateIssues() | [
"Sets",
"the",
"issues",
"that",
"the",
"newer",
"version",
"of",
"the",
"wrapped",
"add",
"-",
"on",
"or",
"its",
"extensions",
"might",
"have",
"that",
"prevents",
"them",
"from",
"being",
"run",
".",
"<p",
">",
"The",
"contents",
"should",
"be",
"in",
"HTML",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/autoupdate/AddOnWrapper.java#L274-L279 |
Guichaguri/MinimalFTP | src/main/java/com/guichaguri/minimalftp/FTPConnection.java | FTPConnection.addCommand | protected void addCommand(String label, String help, Command cmd, boolean needsAuth) {
"""
Internally registers a command
@param label The command name
@param help The help message
@param cmd The command function
@param needsAuth Whether authentication is required to run this command
"""
commands.put(label.toUpperCase(), new CommandInfo(cmd, help, needsAuth));
} | java | protected void addCommand(String label, String help, Command cmd, boolean needsAuth) {
commands.put(label.toUpperCase(), new CommandInfo(cmd, help, needsAuth));
} | [
"protected",
"void",
"addCommand",
"(",
"String",
"label",
",",
"String",
"help",
",",
"Command",
"cmd",
",",
"boolean",
"needsAuth",
")",
"{",
"commands",
".",
"put",
"(",
"label",
".",
"toUpperCase",
"(",
")",
",",
"new",
"CommandInfo",
"(",
"cmd",
",",
"help",
",",
"needsAuth",
")",
")",
";",
"}"
] | Internally registers a command
@param label The command name
@param help The help message
@param cmd The command function
@param needsAuth Whether authentication is required to run this command | [
"Internally",
"registers",
"a",
"command"
] | train | https://github.com/Guichaguri/MinimalFTP/blob/ddd81e26ec88079ee4c37fe53d8efe420996e9b1/src/main/java/com/guichaguri/minimalftp/FTPConnection.java#L422-L424 |
Subsets and Splits