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
|
---|---|---|---|---|---|---|---|---|---|---|
looly/hutool | hutool-system/src/main/java/cn/hutool/system/SystemUtil.java | SystemUtil.get | public static String get(String name, String defaultValue) {
"""
取得系统属性,如果因为Java安全的限制而失败,则将错误打在Log中,然后返回 <code>null</code>。
@param name 属性名
@param defaultValue 默认值
@return 属性值或<code>null</code>
"""
return StrUtil.nullToDefault(get(name, false), defaultValue);
} | java | public static String get(String name, String defaultValue) {
return StrUtil.nullToDefault(get(name, false), defaultValue);
} | [
"public",
"static",
"String",
"get",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"{",
"return",
"StrUtil",
".",
"nullToDefault",
"(",
"get",
"(",
"name",
",",
"false",
")",
",",
"defaultValue",
")",
";",
"}"
] | 取得系统属性,如果因为Java安全的限制而失败,则将错误打在Log中,然后返回 <code>null</code>。
@param name 属性名
@param defaultValue 默认值
@return 属性值或<code>null</code> | [
"取得系统属性,如果因为Java安全的限制而失败,则将错误打在Log中,然后返回",
"<code",
">",
"null<",
"/",
"code",
">",
"。"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-system/src/main/java/cn/hutool/system/SystemUtil.java#L106-L108 |
janus-project/guava.janusproject.io | guava/src/com/google/common/collect/ImmutableSortedMultiset.java | ImmutableSortedMultiset.naturalOrder | public static <E extends Comparable<E>> Builder<E> naturalOrder() {
"""
Returns a builder that creates immutable sorted multisets whose elements are ordered by their
natural ordering. The sorted multisets use {@link Ordering#natural()} as the comparator. This
method provides more type-safety than {@link #builder}, as it can be called only for classes
that implement {@link Comparable}.
<p>Note: the type parameter {@code E} extends {@code Comparable<E>} rather than {@code
Comparable<? super E>} as a workaround for javac <a
href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6468354">bug 6468354</a>.
"""
return new Builder<E>(Ordering.natural());
} | java | public static <E extends Comparable<E>> Builder<E> naturalOrder() {
return new Builder<E>(Ordering.natural());
} | [
"public",
"static",
"<",
"E",
"extends",
"Comparable",
"<",
"E",
">",
">",
"Builder",
"<",
"E",
">",
"naturalOrder",
"(",
")",
"{",
"return",
"new",
"Builder",
"<",
"E",
">",
"(",
"Ordering",
".",
"natural",
"(",
")",
")",
";",
"}"
] | Returns a builder that creates immutable sorted multisets whose elements are ordered by their
natural ordering. The sorted multisets use {@link Ordering#natural()} as the comparator. This
method provides more type-safety than {@link #builder}, as it can be called only for classes
that implement {@link Comparable}.
<p>Note: the type parameter {@code E} extends {@code Comparable<E>} rather than {@code
Comparable<? super E>} as a workaround for javac <a
href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6468354">bug 6468354</a>. | [
"Returns",
"a",
"builder",
"that",
"creates",
"immutable",
"sorted",
"multisets",
"whose",
"elements",
"are",
"ordered",
"by",
"their",
"natural",
"ordering",
".",
"The",
"sorted",
"multisets",
"use",
"{",
"@link",
"Ordering#natural",
"()",
"}",
"as",
"the",
"comparator",
".",
"This",
"method",
"provides",
"more",
"type",
"-",
"safety",
"than",
"{",
"@link",
"#builder",
"}",
"as",
"it",
"can",
"be",
"called",
"only",
"for",
"classes",
"that",
"implement",
"{",
"@link",
"Comparable",
"}",
"."
] | train | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/collect/ImmutableSortedMultiset.java#L415-L417 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/vod/VodClient.java | VodClient.deleteMediaResource | public DeleteMediaResourceResponse deleteMediaResource(DeleteMediaResourceRequest request) {
"""
Delete the specific media resource managed by VOD service.
<p>
The caller <i>must</i> authenticate with a valid BCE Access Key / Private Key pair.
@param request The request object containing all the options on how to
@return empty response will be returned
"""
checkStringNotEmpty(request.getMediaId(), "Media ID should not be null or empty!");
InternalRequest internalRequest =
createRequest(HttpMethodName.DELETE, request, PATH_MEDIA, request.getMediaId());
return invokeHttpClient(internalRequest, DeleteMediaResourceResponse.class);
} | java | public DeleteMediaResourceResponse deleteMediaResource(DeleteMediaResourceRequest request) {
checkStringNotEmpty(request.getMediaId(), "Media ID should not be null or empty!");
InternalRequest internalRequest =
createRequest(HttpMethodName.DELETE, request, PATH_MEDIA, request.getMediaId());
return invokeHttpClient(internalRequest, DeleteMediaResourceResponse.class);
} | [
"public",
"DeleteMediaResourceResponse",
"deleteMediaResource",
"(",
"DeleteMediaResourceRequest",
"request",
")",
"{",
"checkStringNotEmpty",
"(",
"request",
".",
"getMediaId",
"(",
")",
",",
"\"Media ID should not be null or empty!\"",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"createRequest",
"(",
"HttpMethodName",
".",
"DELETE",
",",
"request",
",",
"PATH_MEDIA",
",",
"request",
".",
"getMediaId",
"(",
")",
")",
";",
"return",
"invokeHttpClient",
"(",
"internalRequest",
",",
"DeleteMediaResourceResponse",
".",
"class",
")",
";",
"}"
] | Delete the specific media resource managed by VOD service.
<p>
The caller <i>must</i> authenticate with a valid BCE Access Key / Private Key pair.
@param request The request object containing all the options on how to
@return empty response will be returned | [
"Delete",
"the",
"specific",
"media",
"resource",
"managed",
"by",
"VOD",
"service",
".",
"<p",
">",
"The",
"caller",
"<i",
">",
"must<",
"/",
"i",
">",
"authenticate",
"with",
"a",
"valid",
"BCE",
"Access",
"Key",
"/",
"Private",
"Key",
"pair",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/vod/VodClient.java#L740-L745 |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTree.java | MkCoPTree.createNewDirectoryEntry | @Override
protected MkCoPEntry createNewDirectoryEntry(MkCoPTreeNode<O> node, DBID routingObjectID, double parentDistance) {
"""
Creates a new directory entry representing the specified node.
@param node the node to be represented by the new entry
@param routingObjectID the id of the routing object of the node
@param parentDistance the distance from the routing object of the node to
the routing object of the parent node
"""
return new MkCoPDirectoryEntry(routingObjectID, parentDistance, node.getPageID(), node.coveringRadiusFromEntries(routingObjectID, this), null);
// node.conservativeKnnDistanceApproximation(k_max));
} | java | @Override
protected MkCoPEntry createNewDirectoryEntry(MkCoPTreeNode<O> node, DBID routingObjectID, double parentDistance) {
return new MkCoPDirectoryEntry(routingObjectID, parentDistance, node.getPageID(), node.coveringRadiusFromEntries(routingObjectID, this), null);
// node.conservativeKnnDistanceApproximation(k_max));
} | [
"@",
"Override",
"protected",
"MkCoPEntry",
"createNewDirectoryEntry",
"(",
"MkCoPTreeNode",
"<",
"O",
">",
"node",
",",
"DBID",
"routingObjectID",
",",
"double",
"parentDistance",
")",
"{",
"return",
"new",
"MkCoPDirectoryEntry",
"(",
"routingObjectID",
",",
"parentDistance",
",",
"node",
".",
"getPageID",
"(",
")",
",",
"node",
".",
"coveringRadiusFromEntries",
"(",
"routingObjectID",
",",
"this",
")",
",",
"null",
")",
";",
"// node.conservativeKnnDistanceApproximation(k_max));",
"}"
] | Creates a new directory entry representing the specified node.
@param node the node to be represented by the new entry
@param routingObjectID the id of the routing object of the node
@param parentDistance the distance from the routing object of the node to
the routing object of the parent node | [
"Creates",
"a",
"new",
"directory",
"entry",
"representing",
"the",
"specified",
"node",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTree.java#L720-L724 |
alkacon/opencms-core | src/org/opencms/search/solr/CmsSolrIndex.java | CmsSolrIndex.getType | public static final String getType(CmsObject cms, String rootPath) {
"""
Returns the resource type for the given root path.<p>
@param cms the current CMS context
@param rootPath the root path of the resource to get the type for
@return the resource type for the given root path
"""
String type = null;
CmsSolrIndex index = CmsSearchManager.getIndexSolr(cms, null);
if (index != null) {
I_CmsSearchDocument doc = index.getDocument(CmsSearchField.FIELD_PATH, rootPath);
if (doc != null) {
type = doc.getFieldValueAsString(CmsSearchField.FIELD_TYPE);
}
}
return type;
} | java | public static final String getType(CmsObject cms, String rootPath) {
String type = null;
CmsSolrIndex index = CmsSearchManager.getIndexSolr(cms, null);
if (index != null) {
I_CmsSearchDocument doc = index.getDocument(CmsSearchField.FIELD_PATH, rootPath);
if (doc != null) {
type = doc.getFieldValueAsString(CmsSearchField.FIELD_TYPE);
}
}
return type;
} | [
"public",
"static",
"final",
"String",
"getType",
"(",
"CmsObject",
"cms",
",",
"String",
"rootPath",
")",
"{",
"String",
"type",
"=",
"null",
";",
"CmsSolrIndex",
"index",
"=",
"CmsSearchManager",
".",
"getIndexSolr",
"(",
"cms",
",",
"null",
")",
";",
"if",
"(",
"index",
"!=",
"null",
")",
"{",
"I_CmsSearchDocument",
"doc",
"=",
"index",
".",
"getDocument",
"(",
"CmsSearchField",
".",
"FIELD_PATH",
",",
"rootPath",
")",
";",
"if",
"(",
"doc",
"!=",
"null",
")",
"{",
"type",
"=",
"doc",
".",
"getFieldValueAsString",
"(",
"CmsSearchField",
".",
"FIELD_TYPE",
")",
";",
"}",
"}",
"return",
"type",
";",
"}"
] | Returns the resource type for the given root path.<p>
@param cms the current CMS context
@param rootPath the root path of the resource to get the type for
@return the resource type for the given root path | [
"Returns",
"the",
"resource",
"type",
"for",
"the",
"given",
"root",
"path",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/CmsSolrIndex.java#L278-L289 |
tonilopezmr/Android-EasySQLite | easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteHelper.java | SQLiteHelper.onUpgrade | @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
"""
Called when the database needs to be upgraded. The implementation
should use this method to drop tables, add tables, or do anything else it
needs to upgrade to the new schema version.
@param db The database.
@param oldVersion The old database version.
@param newVersion The new database version.
"""
try {
if (builder.tableNames == null) {
throw new SQLiteHelperException("The array of String tableNames can't be null!!");
}
builder.onUpgradeCallback.onUpgrade(db, oldVersion, newVersion);
} catch (SQLiteHelperException e) {
Log.e(this.getClass().toString(), Log.getStackTraceString(e), e);
}
} | java | @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
try {
if (builder.tableNames == null) {
throw new SQLiteHelperException("The array of String tableNames can't be null!!");
}
builder.onUpgradeCallback.onUpgrade(db, oldVersion, newVersion);
} catch (SQLiteHelperException e) {
Log.e(this.getClass().toString(), Log.getStackTraceString(e), e);
}
} | [
"@",
"Override",
"public",
"void",
"onUpgrade",
"(",
"SQLiteDatabase",
"db",
",",
"int",
"oldVersion",
",",
"int",
"newVersion",
")",
"{",
"try",
"{",
"if",
"(",
"builder",
".",
"tableNames",
"==",
"null",
")",
"{",
"throw",
"new",
"SQLiteHelperException",
"(",
"\"The array of String tableNames can't be null!!\"",
")",
";",
"}",
"builder",
".",
"onUpgradeCallback",
".",
"onUpgrade",
"(",
"db",
",",
"oldVersion",
",",
"newVersion",
")",
";",
"}",
"catch",
"(",
"SQLiteHelperException",
"e",
")",
"{",
"Log",
".",
"e",
"(",
"this",
".",
"getClass",
"(",
")",
".",
"toString",
"(",
")",
",",
"Log",
".",
"getStackTraceString",
"(",
"e",
")",
",",
"e",
")",
";",
"}",
"}"
] | Called when the database needs to be upgraded. The implementation
should use this method to drop tables, add tables, or do anything else it
needs to upgrade to the new schema version.
@param db The database.
@param oldVersion The old database version.
@param newVersion The new database version. | [
"Called",
"when",
"the",
"database",
"needs",
"to",
"be",
"upgraded",
".",
"The",
"implementation",
"should",
"use",
"this",
"method",
"to",
"drop",
"tables",
"add",
"tables",
"or",
"do",
"anything",
"else",
"it",
"needs",
"to",
"upgrade",
"to",
"the",
"new",
"schema",
"version",
"."
] | train | https://github.com/tonilopezmr/Android-EasySQLite/blob/bb991a43c9fa11522e5367570ee2335b99bca7c0/easysqlite/src/main/java/com/tonilopezmr/easysqlite/SQLiteHelper.java#L101-L112 |
LAW-Unimi/BUbiNG | src/it/unimi/di/law/bubing/frontier/WorkbenchVirtualizer.java | WorkbenchVirtualizer.enqueueURL | public void enqueueURL(VisitState visitState, final ByteArrayList url) throws IOException {
"""
Enqueues the given URL as a path+query associated to the scheme+authority of the given visit state.
@param visitState the visitState to which the URL must be added.
@param url a {@link BURL BUbiNG URL}.
@throws IOException
"""
final byte[] urlBuffer = url.elements();
final int pathQueryStart = BURL.startOfpathAndQuery(urlBuffer);
byteArrayDiskQueues.enqueue(visitState, urlBuffer, pathQueryStart, url.size() - pathQueryStart);
} | java | public void enqueueURL(VisitState visitState, final ByteArrayList url) throws IOException {
final byte[] urlBuffer = url.elements();
final int pathQueryStart = BURL.startOfpathAndQuery(urlBuffer);
byteArrayDiskQueues.enqueue(visitState, urlBuffer, pathQueryStart, url.size() - pathQueryStart);
} | [
"public",
"void",
"enqueueURL",
"(",
"VisitState",
"visitState",
",",
"final",
"ByteArrayList",
"url",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"[",
"]",
"urlBuffer",
"=",
"url",
".",
"elements",
"(",
")",
";",
"final",
"int",
"pathQueryStart",
"=",
"BURL",
".",
"startOfpathAndQuery",
"(",
"urlBuffer",
")",
";",
"byteArrayDiskQueues",
".",
"enqueue",
"(",
"visitState",
",",
"urlBuffer",
",",
"pathQueryStart",
",",
"url",
".",
"size",
"(",
")",
"-",
"pathQueryStart",
")",
";",
"}"
] | Enqueues the given URL as a path+query associated to the scheme+authority of the given visit state.
@param visitState the visitState to which the URL must be added.
@param url a {@link BURL BUbiNG URL}.
@throws IOException | [
"Enqueues",
"the",
"given",
"URL",
"as",
"a",
"path",
"+",
"query",
"associated",
"to",
"the",
"scheme",
"+",
"authority",
"of",
"the",
"given",
"visit",
"state",
"."
] | train | https://github.com/LAW-Unimi/BUbiNG/blob/e148acc90031a4f3967422705a9fb07ddaf155e4/src/it/unimi/di/law/bubing/frontier/WorkbenchVirtualizer.java#L126-L130 |
jeremybrooks/jinx | src/main/java/net/jeremybrooks/jinx/api/PhotosPeopleApi.java | PhotosPeopleApi.editCoords | public Response editCoords(String photoId, String userId, Integer x, Integer y, Integer width, Integer height) throws JinxException {
"""
Edit the bounding box of an existing person on a photo.
<br>
This method requires authentication with 'write' permission.
@param photoId (Required) The id of the photo to edit a person in.
@param userId (Required) The user id of the person to edit in a photo.
@param x (Required) The left-most pixel co-ordinate of the box around the person.
@param y (Required) The top-most pixel co-ordinate of the box around the person.
@param width (Required) The width (in pixels) of the box around the person.
@param height (Required) The height (in pixels) of the box around the person.
@return object with the status of the requested operation.
@throws JinxException if any required parameters are missing, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.photos.people.editCoords.html">flickr.photos.people.editCoords</a>
"""
JinxUtils.validateParams(photoId, userId, x, y, width, height);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.people.editCoords");
params.put("photo_id", photoId);
params.put("user_id", userId);
params.put("person_x", x.toString());
params.put("person_y", y.toString());
params.put("person_w", width.toString());
params.put("person_h", height.toString());
return jinx.flickrPost(params, Response.class);
} | java | public Response editCoords(String photoId, String userId, Integer x, Integer y, Integer width, Integer height) throws JinxException {
JinxUtils.validateParams(photoId, userId, x, y, width, height);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.people.editCoords");
params.put("photo_id", photoId);
params.put("user_id", userId);
params.put("person_x", x.toString());
params.put("person_y", y.toString());
params.put("person_w", width.toString());
params.put("person_h", height.toString());
return jinx.flickrPost(params, Response.class);
} | [
"public",
"Response",
"editCoords",
"(",
"String",
"photoId",
",",
"String",
"userId",
",",
"Integer",
"x",
",",
"Integer",
"y",
",",
"Integer",
"width",
",",
"Integer",
"height",
")",
"throws",
"JinxException",
"{",
"JinxUtils",
".",
"validateParams",
"(",
"photoId",
",",
"userId",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"method\"",
",",
"\"flickr.photos.people.editCoords\"",
")",
";",
"params",
".",
"put",
"(",
"\"photo_id\"",
",",
"photoId",
")",
";",
"params",
".",
"put",
"(",
"\"user_id\"",
",",
"userId",
")",
";",
"params",
".",
"put",
"(",
"\"person_x\"",
",",
"x",
".",
"toString",
"(",
")",
")",
";",
"params",
".",
"put",
"(",
"\"person_y\"",
",",
"y",
".",
"toString",
"(",
")",
")",
";",
"params",
".",
"put",
"(",
"\"person_w\"",
",",
"width",
".",
"toString",
"(",
")",
")",
";",
"params",
".",
"put",
"(",
"\"person_h\"",
",",
"height",
".",
"toString",
"(",
")",
")",
";",
"return",
"jinx",
".",
"flickrPost",
"(",
"params",
",",
"Response",
".",
"class",
")",
";",
"}"
] | Edit the bounding box of an existing person on a photo.
<br>
This method requires authentication with 'write' permission.
@param photoId (Required) The id of the photo to edit a person in.
@param userId (Required) The user id of the person to edit in a photo.
@param x (Required) The left-most pixel co-ordinate of the box around the person.
@param y (Required) The top-most pixel co-ordinate of the box around the person.
@param width (Required) The width (in pixels) of the box around the person.
@param height (Required) The height (in pixels) of the box around the person.
@return object with the status of the requested operation.
@throws JinxException if any required parameters are missing, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.photos.people.editCoords.html">flickr.photos.people.editCoords</a> | [
"Edit",
"the",
"bounding",
"box",
"of",
"an",
"existing",
"person",
"on",
"a",
"photo",
".",
"<br",
">",
"This",
"method",
"requires",
"authentication",
"with",
"write",
"permission",
"."
] | train | https://github.com/jeremybrooks/jinx/blob/ab7a4b7462d08bcbfd9b98bd3f5029771c20f6c6/src/main/java/net/jeremybrooks/jinx/api/PhotosPeopleApi.java#L140-L151 |
wildfly/wildfly-core | launcher/src/main/java/org/wildfly/core/launcher/Jvm.java | Jvm.of | static Jvm of(final Path javaHome) {
"""
Creates a new JVM. If the {@code javaHome} is {@code null} the {@linkplain #current() current} JVM is returned.
@param javaHome the path to the Java home
@return a JVM descriptor based on the Java home path
"""
if (javaHome == null || javaHome.equals(JAVA_HOME)) {
return DEFAULT;
}
final Path path = validateJavaHome(javaHome);
return new Jvm(path, isModularJavaHome(path));
} | java | static Jvm of(final Path javaHome) {
if (javaHome == null || javaHome.equals(JAVA_HOME)) {
return DEFAULT;
}
final Path path = validateJavaHome(javaHome);
return new Jvm(path, isModularJavaHome(path));
} | [
"static",
"Jvm",
"of",
"(",
"final",
"Path",
"javaHome",
")",
"{",
"if",
"(",
"javaHome",
"==",
"null",
"||",
"javaHome",
".",
"equals",
"(",
"JAVA_HOME",
")",
")",
"{",
"return",
"DEFAULT",
";",
"}",
"final",
"Path",
"path",
"=",
"validateJavaHome",
"(",
"javaHome",
")",
";",
"return",
"new",
"Jvm",
"(",
"path",
",",
"isModularJavaHome",
"(",
"path",
")",
")",
";",
"}"
] | Creates a new JVM. If the {@code javaHome} is {@code null} the {@linkplain #current() current} JVM is returned.
@param javaHome the path to the Java home
@return a JVM descriptor based on the Java home path | [
"Creates",
"a",
"new",
"JVM",
".",
"If",
"the",
"{",
"@code",
"javaHome",
"}",
"is",
"{",
"@code",
"null",
"}",
"the",
"{",
"@linkplain",
"#current",
"()",
"current",
"}",
"JVM",
"is",
"returned",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/launcher/src/main/java/org/wildfly/core/launcher/Jvm.java#L110-L116 |
Alluxio/alluxio | core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationStore.java | ServerConfigurationStore.registerNewConf | public synchronized void registerNewConf(Address address, List<ConfigProperty> configList) {
"""
Registers new configuration information.
@param address the node address
@param configList the configuration of this node
"""
Preconditions.checkNotNull(address, "address should not be null");
Preconditions.checkNotNull(configList, "configuration list should not be null");
// Instead of recording property name, we record property key.
mConfMap.put(address, configList.stream().map(c -> new ConfigRecord()
.setKey(toPropertyKey(c.getName())).setSource(c.getSource())
.setValue(c.getValue())).collect(Collectors.toList()));
mLostNodes.remove(address);
for (Runnable function : mChangeListeners) {
function.run();
}
} | java | public synchronized void registerNewConf(Address address, List<ConfigProperty> configList) {
Preconditions.checkNotNull(address, "address should not be null");
Preconditions.checkNotNull(configList, "configuration list should not be null");
// Instead of recording property name, we record property key.
mConfMap.put(address, configList.stream().map(c -> new ConfigRecord()
.setKey(toPropertyKey(c.getName())).setSource(c.getSource())
.setValue(c.getValue())).collect(Collectors.toList()));
mLostNodes.remove(address);
for (Runnable function : mChangeListeners) {
function.run();
}
} | [
"public",
"synchronized",
"void",
"registerNewConf",
"(",
"Address",
"address",
",",
"List",
"<",
"ConfigProperty",
">",
"configList",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"address",
",",
"\"address should not be null\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"configList",
",",
"\"configuration list should not be null\"",
")",
";",
"// Instead of recording property name, we record property key.",
"mConfMap",
".",
"put",
"(",
"address",
",",
"configList",
".",
"stream",
"(",
")",
".",
"map",
"(",
"c",
"->",
"new",
"ConfigRecord",
"(",
")",
".",
"setKey",
"(",
"toPropertyKey",
"(",
"c",
".",
"getName",
"(",
")",
")",
")",
".",
"setSource",
"(",
"c",
".",
"getSource",
"(",
")",
")",
".",
"setValue",
"(",
"c",
".",
"getValue",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"mLostNodes",
".",
"remove",
"(",
"address",
")",
";",
"for",
"(",
"Runnable",
"function",
":",
"mChangeListeners",
")",
"{",
"function",
".",
"run",
"(",
")",
";",
"}",
"}"
] | Registers new configuration information.
@param address the node address
@param configList the configuration of this node | [
"Registers",
"new",
"configuration",
"information",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationStore.java#L64-L75 |
rythmengine/rythmengine | src/main/java/org/rythmengine/internal/parser/build_in/ExpressionParser.java | ExpressionParser.assertBasic | public static String assertBasic(String symbol, IContext context) {
"""
Return symbol with transformer extension stripped off
@param symbol
@param context
@return the symbol
"""
if (symbol.contains("_utils.sep(\"")) return symbol;// Rythm builtin expression TODO: generalize
//String s = Token.stripJavaExtension(symbol, context);
//s = S.stripBrace(s);
String s = symbol;
boolean isSimple = Patterns.VarName.matches(s);
IContext ctx = context;
if (!isSimple) {
throw new TemplateParser.ComplexExpressionException(ctx);
}
return s;
} | java | public static String assertBasic(String symbol, IContext context) {
if (symbol.contains("_utils.sep(\"")) return symbol;// Rythm builtin expression TODO: generalize
//String s = Token.stripJavaExtension(symbol, context);
//s = S.stripBrace(s);
String s = symbol;
boolean isSimple = Patterns.VarName.matches(s);
IContext ctx = context;
if (!isSimple) {
throw new TemplateParser.ComplexExpressionException(ctx);
}
return s;
} | [
"public",
"static",
"String",
"assertBasic",
"(",
"String",
"symbol",
",",
"IContext",
"context",
")",
"{",
"if",
"(",
"symbol",
".",
"contains",
"(",
"\"_utils.sep(\\\"\"",
")",
")",
"return",
"symbol",
";",
"// Rythm builtin expression TODO: generalize",
"//String s = Token.stripJavaExtension(symbol, context);",
"//s = S.stripBrace(s);",
"String",
"s",
"=",
"symbol",
";",
"boolean",
"isSimple",
"=",
"Patterns",
".",
"VarName",
".",
"matches",
"(",
"s",
")",
";",
"IContext",
"ctx",
"=",
"context",
";",
"if",
"(",
"!",
"isSimple",
")",
"{",
"throw",
"new",
"TemplateParser",
".",
"ComplexExpressionException",
"(",
"ctx",
")",
";",
"}",
"return",
"s",
";",
"}"
] | Return symbol with transformer extension stripped off
@param symbol
@param context
@return the symbol | [
"Return",
"symbol",
"with",
"transformer",
"extension",
"stripped",
"off"
] | train | https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/parser/build_in/ExpressionParser.java#L33-L44 |
rzwitserloot/lombok | src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java | EclipseProductLocationProvider.findIdes | @Override
public void findIdes(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) {
"""
Calls the OS-dependent 'find Eclipse' routine. If the local OS doesn't have a routine written for it,
null is returned.
@param locations
List of valid eclipse locations - provide an empty list; this
method will fill it.
@param problems
List of eclipse locations that seem to contain half-baked
eclipses that can't be installed. Provide an empty list; this
method will fill it.
"""
switch (OsUtils.getOS()) {
case WINDOWS:
new WindowsFinder().findEclipse(locations, problems);
break;
case MAC_OS_X:
new MacFinder().findEclipse(locations, problems);
break;
default:
case UNIX:
new UnixFinder().findEclipse(locations, problems);
break;
}
} | java | @Override
public void findIdes(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) {
switch (OsUtils.getOS()) {
case WINDOWS:
new WindowsFinder().findEclipse(locations, problems);
break;
case MAC_OS_X:
new MacFinder().findEclipse(locations, problems);
break;
default:
case UNIX:
new UnixFinder().findEclipse(locations, problems);
break;
}
} | [
"@",
"Override",
"public",
"void",
"findIdes",
"(",
"List",
"<",
"IdeLocation",
">",
"locations",
",",
"List",
"<",
"CorruptedIdeLocationException",
">",
"problems",
")",
"{",
"switch",
"(",
"OsUtils",
".",
"getOS",
"(",
")",
")",
"{",
"case",
"WINDOWS",
":",
"new",
"WindowsFinder",
"(",
")",
".",
"findEclipse",
"(",
"locations",
",",
"problems",
")",
";",
"break",
";",
"case",
"MAC_OS_X",
":",
"new",
"MacFinder",
"(",
")",
".",
"findEclipse",
"(",
"locations",
",",
"problems",
")",
";",
"break",
";",
"default",
":",
"case",
"UNIX",
":",
"new",
"UnixFinder",
"(",
")",
".",
"findEclipse",
"(",
"locations",
",",
"problems",
")",
";",
"break",
";",
"}",
"}"
] | Calls the OS-dependent 'find Eclipse' routine. If the local OS doesn't have a routine written for it,
null is returned.
@param locations
List of valid eclipse locations - provide an empty list; this
method will fill it.
@param problems
List of eclipse locations that seem to contain half-baked
eclipses that can't be installed. Provide an empty list; this
method will fill it. | [
"Calls",
"the",
"OS",
"-",
"dependent",
"find",
"Eclipse",
"routine",
".",
"If",
"the",
"local",
"OS",
"doesn",
"t",
"have",
"a",
"routine",
"written",
"for",
"it",
"null",
"is",
"returned",
"."
] | train | https://github.com/rzwitserloot/lombok/blob/75601240760bd81ff95fcde7a1b8185769ce64e8/src/installer/lombok/installer/eclipse/EclipseProductLocationProvider.java#L164-L178 |
joestelmach/natty | src/main/java/com/joestelmach/natty/WalkerState.java | WalkerState.seekToSeason | public void seekToSeason(String seasonString, String direction, String seekAmount) {
"""
Seeks forward or backwards to a particular season based on the current date
@param seasonString The season to seek to
@param direction The direction to seek
@param seekAmount The number of years to seek
"""
Season season = Season.valueOf(seasonString);
assert(season!= null);
seekToIcsEvent(SEASON_ICS_FILE, season.getSummary(), direction, seekAmount);
} | java | public void seekToSeason(String seasonString, String direction, String seekAmount) {
Season season = Season.valueOf(seasonString);
assert(season!= null);
seekToIcsEvent(SEASON_ICS_FILE, season.getSummary(), direction, seekAmount);
} | [
"public",
"void",
"seekToSeason",
"(",
"String",
"seasonString",
",",
"String",
"direction",
",",
"String",
"seekAmount",
")",
"{",
"Season",
"season",
"=",
"Season",
".",
"valueOf",
"(",
"seasonString",
")",
";",
"assert",
"(",
"season",
"!=",
"null",
")",
";",
"seekToIcsEvent",
"(",
"SEASON_ICS_FILE",
",",
"season",
".",
"getSummary",
"(",
")",
",",
"direction",
",",
"seekAmount",
")",
";",
"}"
] | Seeks forward or backwards to a particular season based on the current date
@param seasonString The season to seek to
@param direction The direction to seek
@param seekAmount The number of years to seek | [
"Seeks",
"forward",
"or",
"backwards",
"to",
"a",
"particular",
"season",
"based",
"on",
"the",
"current",
"date"
] | train | https://github.com/joestelmach/natty/blob/74389feb4c9372e51cd51eb0800a0177fec3e5a0/src/main/java/com/joestelmach/natty/WalkerState.java#L416-L421 |
alibaba/jstorm | jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/trident/HdfsState.java | HdfsState.getTxnRecord | private TxnRecord getTxnRecord(Path indexFilePath) throws IOException {
"""
Reads the last txn record from index file if it exists, if not
from .tmp file if exists.
@param indexFilePath the index file path
@return the txn record from the index file or a default initial record.
@throws IOException
"""
Path tmpPath = tmpFilePath(indexFilePath.toString());
if (this.options.fs.exists(indexFilePath)) {
return readTxnRecord(indexFilePath);
} else if (this.options.fs.exists(tmpPath)) {
return readTxnRecord(tmpPath);
}
return new TxnRecord(0, options.currentFile.toString(), 0);
} | java | private TxnRecord getTxnRecord(Path indexFilePath) throws IOException {
Path tmpPath = tmpFilePath(indexFilePath.toString());
if (this.options.fs.exists(indexFilePath)) {
return readTxnRecord(indexFilePath);
} else if (this.options.fs.exists(tmpPath)) {
return readTxnRecord(tmpPath);
}
return new TxnRecord(0, options.currentFile.toString(), 0);
} | [
"private",
"TxnRecord",
"getTxnRecord",
"(",
"Path",
"indexFilePath",
")",
"throws",
"IOException",
"{",
"Path",
"tmpPath",
"=",
"tmpFilePath",
"(",
"indexFilePath",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"this",
".",
"options",
".",
"fs",
".",
"exists",
"(",
"indexFilePath",
")",
")",
"{",
"return",
"readTxnRecord",
"(",
"indexFilePath",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"options",
".",
"fs",
".",
"exists",
"(",
"tmpPath",
")",
")",
"{",
"return",
"readTxnRecord",
"(",
"tmpPath",
")",
";",
"}",
"return",
"new",
"TxnRecord",
"(",
"0",
",",
"options",
".",
"currentFile",
".",
"toString",
"(",
")",
",",
"0",
")",
";",
"}"
] | Reads the last txn record from index file if it exists, if not
from .tmp file if exists.
@param indexFilePath the index file path
@return the txn record from the index file or a default initial record.
@throws IOException | [
"Reads",
"the",
"last",
"txn",
"record",
"from",
"index",
"file",
"if",
"it",
"exists",
"if",
"not",
"from",
".",
"tmp",
"file",
"if",
"exists",
"."
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/trident/HdfsState.java#L470-L478 |
grpc/grpc-java | api/src/main/java/io/grpc/ClientInterceptors.java | ClientInterceptors.interceptForward | public static Channel interceptForward(Channel channel, ClientInterceptor... interceptors) {
"""
Create a new {@link Channel} that will call {@code interceptors} before starting a call on the
given channel. The first interceptor will have its {@link ClientInterceptor#interceptCall}
called first.
@param channel the underlying channel to intercept.
@param interceptors array of interceptors to bind to {@code channel}.
@return a new channel instance with the interceptors applied.
"""
return interceptForward(channel, Arrays.asList(interceptors));
} | java | public static Channel interceptForward(Channel channel, ClientInterceptor... interceptors) {
return interceptForward(channel, Arrays.asList(interceptors));
} | [
"public",
"static",
"Channel",
"interceptForward",
"(",
"Channel",
"channel",
",",
"ClientInterceptor",
"...",
"interceptors",
")",
"{",
"return",
"interceptForward",
"(",
"channel",
",",
"Arrays",
".",
"asList",
"(",
"interceptors",
")",
")",
";",
"}"
] | Create a new {@link Channel} that will call {@code interceptors} before starting a call on the
given channel. The first interceptor will have its {@link ClientInterceptor#interceptCall}
called first.
@param channel the underlying channel to intercept.
@param interceptors array of interceptors to bind to {@code channel}.
@return a new channel instance with the interceptors applied. | [
"Create",
"a",
"new",
"{",
"@link",
"Channel",
"}",
"that",
"will",
"call",
"{",
"@code",
"interceptors",
"}",
"before",
"starting",
"a",
"call",
"on",
"the",
"given",
"channel",
".",
"The",
"first",
"interceptor",
"will",
"have",
"its",
"{",
"@link",
"ClientInterceptor#interceptCall",
"}",
"called",
"first",
"."
] | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/ClientInterceptors.java#L44-L46 |
james-hu/jabb-core | src/main/java/net/sf/jabb/util/db/dao/AbstractHibernateDao.java | AbstractHibernateDao.getAllBySql | public List< T> getAllBySql(String fullSql, Object paramValue1, Type paramType1, Object paramValue2, Type paramType2, Object paramValue3, Type paramType3) {
"""
Get all by SQL with three pairs of parameterType-value
@param fullSql
@param paramValue1
@param paramType1
@param paramValue2
@param paramType2
@param paramValue3
@param paramType3
@return the query result
"""
return getAllBySql(fullSql, new Object[]{paramValue1, paramValue2, paramValue3}, new Type[]{paramType1, paramType2, paramType3}, null, null);
} | java | public List< T> getAllBySql(String fullSql, Object paramValue1, Type paramType1, Object paramValue2, Type paramType2, Object paramValue3, Type paramType3) {
return getAllBySql(fullSql, new Object[]{paramValue1, paramValue2, paramValue3}, new Type[]{paramType1, paramType2, paramType3}, null, null);
} | [
"public",
"List",
"<",
"T",
">",
"getAllBySql",
"(",
"String",
"fullSql",
",",
"Object",
"paramValue1",
",",
"Type",
"paramType1",
",",
"Object",
"paramValue2",
",",
"Type",
"paramType2",
",",
"Object",
"paramValue3",
",",
"Type",
"paramType3",
")",
"{",
"return",
"getAllBySql",
"(",
"fullSql",
",",
"new",
"Object",
"[",
"]",
"{",
"paramValue1",
",",
"paramValue2",
",",
"paramValue3",
"}",
",",
"new",
"Type",
"[",
"]",
"{",
"paramType1",
",",
"paramType2",
",",
"paramType3",
"}",
",",
"null",
",",
"null",
")",
";",
"}"
] | Get all by SQL with three pairs of parameterType-value
@param fullSql
@param paramValue1
@param paramType1
@param paramValue2
@param paramType2
@param paramValue3
@param paramType3
@return the query result | [
"Get",
"all",
"by",
"SQL",
"with",
"three",
"pairs",
"of",
"parameterType",
"-",
"value"
] | train | https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/db/dao/AbstractHibernateDao.java#L282-L284 |
tvesalainen/util | util/src/main/java/org/vesalainen/ui/ScanlineFiller.java | ScanlineFiller.floodFill | public void floodFill(int xx, int yy, IntPredicate target, int replacement) {
"""
Fills area starting at xx,yy. Pixels fullfilling target are replaced with
replacement color.
@param xx
@param yy
@param target
@param replacement
"""
floodFill(xx, yy, 0, 0, width, height, target, replacement);
} | java | public void floodFill(int xx, int yy, IntPredicate target, int replacement)
{
floodFill(xx, yy, 0, 0, width, height, target, replacement);
} | [
"public",
"void",
"floodFill",
"(",
"int",
"xx",
",",
"int",
"yy",
",",
"IntPredicate",
"target",
",",
"int",
"replacement",
")",
"{",
"floodFill",
"(",
"xx",
",",
"yy",
",",
"0",
",",
"0",
",",
"width",
",",
"height",
",",
"target",
",",
"replacement",
")",
";",
"}"
] | Fills area starting at xx,yy. Pixels fullfilling target are replaced with
replacement color.
@param xx
@param yy
@param target
@param replacement | [
"Fills",
"area",
"starting",
"at",
"xx",
"yy",
".",
"Pixels",
"fullfilling",
"target",
"are",
"replaced",
"with",
"replacement",
"color",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/ui/ScanlineFiller.java#L87-L90 |
DDTH/ddth-commons | ddth-commons-core/src/main/java/com/github/ddth/commons/rocksdb/RocksDbWrapper.java | RocksDbWrapper.openReadOnly | public static RocksDbWrapper openReadOnly(File directory, DBOptions dbOptions,
ReadOptions readOptions) throws RocksDbException, IOException {
"""
Open a {@link RocksDB} with specified options in read-only mode.
@param directory
existing {@link RocksDB} data directory
@param dbOptions
@param readOptions
@return
@throws RocksDBException
@throws IOException
"""
RocksDbWrapper rocksDbWrapper = new RocksDbWrapper(directory, true);
rocksDbWrapper.setDbOptions(dbOptions).setReadOptions(readOptions);
rocksDbWrapper.init();
return rocksDbWrapper;
} | java | public static RocksDbWrapper openReadOnly(File directory, DBOptions dbOptions,
ReadOptions readOptions) throws RocksDbException, IOException {
RocksDbWrapper rocksDbWrapper = new RocksDbWrapper(directory, true);
rocksDbWrapper.setDbOptions(dbOptions).setReadOptions(readOptions);
rocksDbWrapper.init();
return rocksDbWrapper;
} | [
"public",
"static",
"RocksDbWrapper",
"openReadOnly",
"(",
"File",
"directory",
",",
"DBOptions",
"dbOptions",
",",
"ReadOptions",
"readOptions",
")",
"throws",
"RocksDbException",
",",
"IOException",
"{",
"RocksDbWrapper",
"rocksDbWrapper",
"=",
"new",
"RocksDbWrapper",
"(",
"directory",
",",
"true",
")",
";",
"rocksDbWrapper",
".",
"setDbOptions",
"(",
"dbOptions",
")",
".",
"setReadOptions",
"(",
"readOptions",
")",
";",
"rocksDbWrapper",
".",
"init",
"(",
")",
";",
"return",
"rocksDbWrapper",
";",
"}"
] | Open a {@link RocksDB} with specified options in read-only mode.
@param directory
existing {@link RocksDB} data directory
@param dbOptions
@param readOptions
@return
@throws RocksDBException
@throws IOException | [
"Open",
"a",
"{",
"@link",
"RocksDB",
"}",
"with",
"specified",
"options",
"in",
"read",
"-",
"only",
"mode",
"."
] | train | https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/rocksdb/RocksDbWrapper.java#L85-L91 |
tzaeschke/zoodb | src/org/zoodb/tools/internal/DataSerializer.java | DataSerializer.serializeObjectNoSCO | private final void serializeObjectNoSCO(Object v, ZooFieldDef def) {
"""
Method for serializing data with constant size so that it can be stored in the object header
where the field offsets are valid.
"""
// Write class/null info
if (v == null) {
writeClassInfo(null, null);
return;
}
//Persistent capable objects do not need to be serialized here.
//If they should be serialized, then it will happen in serializeFields()
Class<? extends Object> cls = v.getClass();
writeClassInfo(cls, v);
if (isPersistentCapable(cls)) {
serializeOid(v);
return;
} else if (String.class == cls) {
String s = (String)v;
out.writeString(s);
return;
} else if (Date.class == cls) {
out.writeLong(((Date) v).getTime());
return;
} else if (GenericObject.class == cls) {
serializeOidGo((GenericObject) v);
return;
}
throw new IllegalArgumentException("Illegal class: " + cls + " from " + def);
} | java | private final void serializeObjectNoSCO(Object v, ZooFieldDef def) {
// Write class/null info
if (v == null) {
writeClassInfo(null, null);
return;
}
//Persistent capable objects do not need to be serialized here.
//If they should be serialized, then it will happen in serializeFields()
Class<? extends Object> cls = v.getClass();
writeClassInfo(cls, v);
if (isPersistentCapable(cls)) {
serializeOid(v);
return;
} else if (String.class == cls) {
String s = (String)v;
out.writeString(s);
return;
} else if (Date.class == cls) {
out.writeLong(((Date) v).getTime());
return;
} else if (GenericObject.class == cls) {
serializeOidGo((GenericObject) v);
return;
}
throw new IllegalArgumentException("Illegal class: " + cls + " from " + def);
} | [
"private",
"final",
"void",
"serializeObjectNoSCO",
"(",
"Object",
"v",
",",
"ZooFieldDef",
"def",
")",
"{",
"// Write class/null info",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"writeClassInfo",
"(",
"null",
",",
"null",
")",
";",
"return",
";",
"}",
"//Persistent capable objects do not need to be serialized here.",
"//If they should be serialized, then it will happen in serializeFields()",
"Class",
"<",
"?",
"extends",
"Object",
">",
"cls",
"=",
"v",
".",
"getClass",
"(",
")",
";",
"writeClassInfo",
"(",
"cls",
",",
"v",
")",
";",
"if",
"(",
"isPersistentCapable",
"(",
"cls",
")",
")",
"{",
"serializeOid",
"(",
"v",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"String",
".",
"class",
"==",
"cls",
")",
"{",
"String",
"s",
"=",
"(",
"String",
")",
"v",
";",
"out",
".",
"writeString",
"(",
"s",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"Date",
".",
"class",
"==",
"cls",
")",
"{",
"out",
".",
"writeLong",
"(",
"(",
"(",
"Date",
")",
"v",
")",
".",
"getTime",
"(",
")",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"GenericObject",
".",
"class",
"==",
"cls",
")",
"{",
"serializeOidGo",
"(",
"(",
"GenericObject",
")",
"v",
")",
";",
"return",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Illegal class: \"",
"+",
"cls",
"+",
"\" from \"",
"+",
"def",
")",
";",
"}"
] | Method for serializing data with constant size so that it can be stored in the object header
where the field offsets are valid. | [
"Method",
"for",
"serializing",
"data",
"with",
"constant",
"size",
"so",
"that",
"it",
"can",
"be",
"stored",
"in",
"the",
"object",
"header",
"where",
"the",
"field",
"offsets",
"are",
"valid",
"."
] | train | https://github.com/tzaeschke/zoodb/blob/058d0ff161a8ee9d53244c433aca97ee9c654410/src/org/zoodb/tools/internal/DataSerializer.java#L233-L261 |
groupon/odo | proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java | PathOverrideService.addPathToRequestResponseTable | public void addPathToRequestResponseTable(int profileId, String clientUUID, int pathId) throws Exception {
"""
Adds a path to the request response table with the specified values
@param profileId ID of profile
@param clientUUID UUID of client
@param pathId ID of path
@throws Exception exception
"""
PreparedStatement statement = null;
try (Connection sqlConnection = sqlService.getConnection()) {
statement = sqlConnection
.prepareStatement("INSERT INTO " + Constants.DB_TABLE_REQUEST_RESPONSE +
"(" + Constants.REQUEST_RESPONSE_PATH_ID + ","
+ Constants.GENERIC_PROFILE_ID + ","
+ Constants.GENERIC_CLIENT_UUID + ","
+ Constants.REQUEST_RESPONSE_REPEAT_NUMBER + ","
+ Constants.REQUEST_RESPONSE_RESPONSE_ENABLED + ","
+ Constants.REQUEST_RESPONSE_REQUEST_ENABLED + ","
+ Constants.REQUEST_RESPONSE_CUSTOM_RESPONSE + ","
+ Constants.REQUEST_RESPONSE_CUSTOM_REQUEST + ")"
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
statement.setInt(1, pathId);
statement.setInt(2, profileId);
statement.setString(3, clientUUID);
statement.setInt(4, -1);
statement.setInt(5, 0);
statement.setInt(6, 0);
statement.setString(7, "");
statement.setString(8, "");
statement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (Exception e) {
}
}
} | java | public void addPathToRequestResponseTable(int profileId, String clientUUID, int pathId) throws Exception {
PreparedStatement statement = null;
try (Connection sqlConnection = sqlService.getConnection()) {
statement = sqlConnection
.prepareStatement("INSERT INTO " + Constants.DB_TABLE_REQUEST_RESPONSE +
"(" + Constants.REQUEST_RESPONSE_PATH_ID + ","
+ Constants.GENERIC_PROFILE_ID + ","
+ Constants.GENERIC_CLIENT_UUID + ","
+ Constants.REQUEST_RESPONSE_REPEAT_NUMBER + ","
+ Constants.REQUEST_RESPONSE_RESPONSE_ENABLED + ","
+ Constants.REQUEST_RESPONSE_REQUEST_ENABLED + ","
+ Constants.REQUEST_RESPONSE_CUSTOM_RESPONSE + ","
+ Constants.REQUEST_RESPONSE_CUSTOM_REQUEST + ")"
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
statement.setInt(1, pathId);
statement.setInt(2, profileId);
statement.setString(3, clientUUID);
statement.setInt(4, -1);
statement.setInt(5, 0);
statement.setInt(6, 0);
statement.setString(7, "");
statement.setString(8, "");
statement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (Exception e) {
}
}
} | [
"public",
"void",
"addPathToRequestResponseTable",
"(",
"int",
"profileId",
",",
"String",
"clientUUID",
",",
"int",
"pathId",
")",
"throws",
"Exception",
"{",
"PreparedStatement",
"statement",
"=",
"null",
";",
"try",
"(",
"Connection",
"sqlConnection",
"=",
"sqlService",
".",
"getConnection",
"(",
")",
")",
"{",
"statement",
"=",
"sqlConnection",
".",
"prepareStatement",
"(",
"\"INSERT INTO \"",
"+",
"Constants",
".",
"DB_TABLE_REQUEST_RESPONSE",
"+",
"\"(\"",
"+",
"Constants",
".",
"REQUEST_RESPONSE_PATH_ID",
"+",
"\",\"",
"+",
"Constants",
".",
"GENERIC_PROFILE_ID",
"+",
"\",\"",
"+",
"Constants",
".",
"GENERIC_CLIENT_UUID",
"+",
"\",\"",
"+",
"Constants",
".",
"REQUEST_RESPONSE_REPEAT_NUMBER",
"+",
"\",\"",
"+",
"Constants",
".",
"REQUEST_RESPONSE_RESPONSE_ENABLED",
"+",
"\",\"",
"+",
"Constants",
".",
"REQUEST_RESPONSE_REQUEST_ENABLED",
"+",
"\",\"",
"+",
"Constants",
".",
"REQUEST_RESPONSE_CUSTOM_RESPONSE",
"+",
"\",\"",
"+",
"Constants",
".",
"REQUEST_RESPONSE_CUSTOM_REQUEST",
"+",
"\")\"",
"+",
"\" VALUES (?, ?, ?, ?, ?, ?, ?, ?);\"",
")",
";",
"statement",
".",
"setInt",
"(",
"1",
",",
"pathId",
")",
";",
"statement",
".",
"setInt",
"(",
"2",
",",
"profileId",
")",
";",
"statement",
".",
"setString",
"(",
"3",
",",
"clientUUID",
")",
";",
"statement",
".",
"setInt",
"(",
"4",
",",
"-",
"1",
")",
";",
"statement",
".",
"setInt",
"(",
"5",
",",
"0",
")",
";",
"statement",
".",
"setInt",
"(",
"6",
",",
"0",
")",
";",
"statement",
".",
"setString",
"(",
"7",
",",
"\"\"",
")",
";",
"statement",
".",
"setString",
"(",
"8",
",",
"\"\"",
")",
";",
"statement",
".",
"executeUpdate",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"statement",
"!=",
"null",
")",
"{",
"statement",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"}"
] | Adds a path to the request response table with the specified values
@param profileId ID of profile
@param clientUUID UUID of client
@param pathId ID of path
@throws Exception exception | [
"Adds",
"a",
"path",
"to",
"the",
"request",
"response",
"table",
"with",
"the",
"specified",
"values"
] | train | https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L186-L219 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringHelper.java | StringHelper.trimStartAndEnd | @Nullable
@CheckReturnValue
public static String trimStartAndEnd (@Nullable final String sSrc,
@Nullable final String sLead,
@Nullable final String sTail) {
"""
Trim the passed lead and tail from the source value. If the source value does
not start with the passed lead and does not end with the passed tail, nothing
happens.
@param sSrc
The input source string
@param sLead
The string to be trimmed of the beginning
@param sTail
The string to be trimmed of the end
@return The trimmed string, or the original input string, if the lead and the
tail were not found
@see #trimStart(String, String)
@see #trimEnd(String, String)
@see #trimStartAndEnd(String, String)
"""
final String sInbetween = trimStart (sSrc, sLead);
return trimEnd (sInbetween, sTail);
} | java | @Nullable
@CheckReturnValue
public static String trimStartAndEnd (@Nullable final String sSrc,
@Nullable final String sLead,
@Nullable final String sTail)
{
final String sInbetween = trimStart (sSrc, sLead);
return trimEnd (sInbetween, sTail);
} | [
"@",
"Nullable",
"@",
"CheckReturnValue",
"public",
"static",
"String",
"trimStartAndEnd",
"(",
"@",
"Nullable",
"final",
"String",
"sSrc",
",",
"@",
"Nullable",
"final",
"String",
"sLead",
",",
"@",
"Nullable",
"final",
"String",
"sTail",
")",
"{",
"final",
"String",
"sInbetween",
"=",
"trimStart",
"(",
"sSrc",
",",
"sLead",
")",
";",
"return",
"trimEnd",
"(",
"sInbetween",
",",
"sTail",
")",
";",
"}"
] | Trim the passed lead and tail from the source value. If the source value does
not start with the passed lead and does not end with the passed tail, nothing
happens.
@param sSrc
The input source string
@param sLead
The string to be trimmed of the beginning
@param sTail
The string to be trimmed of the end
@return The trimmed string, or the original input string, if the lead and the
tail were not found
@see #trimStart(String, String)
@see #trimEnd(String, String)
@see #trimStartAndEnd(String, String) | [
"Trim",
"the",
"passed",
"lead",
"and",
"tail",
"from",
"the",
"source",
"value",
".",
"If",
"the",
"source",
"value",
"does",
"not",
"start",
"with",
"the",
"passed",
"lead",
"and",
"does",
"not",
"end",
"with",
"the",
"passed",
"tail",
"nothing",
"happens",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L3492-L3500 |
GCRC/nunaliit | nunaliit2-couch-date/src/main/java/ca/carleton/gcrc/couch/date/cluster/TreeInsertProcess.java | TreeInsertProcess.insertElements | static public Result insertElements(Tree tree, List<TreeElement> elements, NowReference now) throws Exception {
"""
Modifies a cluster tree as a result of adding a new elements in the
tree.
@param tree Tree where the element is inserted.
@param elements Elements to be inserted in the tree
@return Results of inserting the elements
@throws Exception
"""
ResultImpl result = new ResultImpl(tree);
TreeNodeRegular regularRootNode = tree.getRegularRootNode();
TreeNodeOngoing ongoingRootNode = tree.getOngoingRootNode();
for(TreeElement element : elements){
TimeInterval elementInterval = element.getInterval();
if( elementInterval.isOngoing() ){
ongoingRootNode.insertElement(element, result, tree.getOperations(), now);
} else {
regularRootNode.insertElement(element, result, tree.getOperations(), now);
}
}
return result;
} | java | static public Result insertElements(Tree tree, List<TreeElement> elements, NowReference now) throws Exception {
ResultImpl result = new ResultImpl(tree);
TreeNodeRegular regularRootNode = tree.getRegularRootNode();
TreeNodeOngoing ongoingRootNode = tree.getOngoingRootNode();
for(TreeElement element : elements){
TimeInterval elementInterval = element.getInterval();
if( elementInterval.isOngoing() ){
ongoingRootNode.insertElement(element, result, tree.getOperations(), now);
} else {
regularRootNode.insertElement(element, result, tree.getOperations(), now);
}
}
return result;
} | [
"static",
"public",
"Result",
"insertElements",
"(",
"Tree",
"tree",
",",
"List",
"<",
"TreeElement",
">",
"elements",
",",
"NowReference",
"now",
")",
"throws",
"Exception",
"{",
"ResultImpl",
"result",
"=",
"new",
"ResultImpl",
"(",
"tree",
")",
";",
"TreeNodeRegular",
"regularRootNode",
"=",
"tree",
".",
"getRegularRootNode",
"(",
")",
";",
"TreeNodeOngoing",
"ongoingRootNode",
"=",
"tree",
".",
"getOngoingRootNode",
"(",
")",
";",
"for",
"(",
"TreeElement",
"element",
":",
"elements",
")",
"{",
"TimeInterval",
"elementInterval",
"=",
"element",
".",
"getInterval",
"(",
")",
";",
"if",
"(",
"elementInterval",
".",
"isOngoing",
"(",
")",
")",
"{",
"ongoingRootNode",
".",
"insertElement",
"(",
"element",
",",
"result",
",",
"tree",
".",
"getOperations",
"(",
")",
",",
"now",
")",
";",
"}",
"else",
"{",
"regularRootNode",
".",
"insertElement",
"(",
"element",
",",
"result",
",",
"tree",
".",
"getOperations",
"(",
")",
",",
"now",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Modifies a cluster tree as a result of adding a new elements in the
tree.
@param tree Tree where the element is inserted.
@param elements Elements to be inserted in the tree
@return Results of inserting the elements
@throws Exception | [
"Modifies",
"a",
"cluster",
"tree",
"as",
"a",
"result",
"of",
"adding",
"a",
"new",
"elements",
"in",
"the",
"tree",
"."
] | train | https://github.com/GCRC/nunaliit/blob/0b4abfc64eef2eb8b94f852ce697de2e851d8e67/nunaliit2-couch-date/src/main/java/ca/carleton/gcrc/couch/date/cluster/TreeInsertProcess.java#L80-L97 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/core/image/ConvertImage.java | ConvertImage.convertF32U8 | public static InterleavedU8 convertF32U8( Planar<GrayF32> input , InterleavedU8 output ) {
"""
Converts a {@link Planar} into the equivalent {@link InterleavedU8}
@param input (Input) Planar image that is being converted. Not modified.
@param output (Optional) The output image. If null a new image is created. Modified.
@return Converted image.
"""
if (output == null) {
output = new InterleavedU8(input.width, input.height,input.getNumBands());
} else {
output.reshape(input.width,input.height,input.getNumBands());
}
if( BoofConcurrency.USE_CONCURRENT ) {
ImplConvertImage_MT.convertF32U8(input,output);
} else {
ImplConvertImage.convertF32U8(input,output);
}
return output;
} | java | public static InterleavedU8 convertF32U8( Planar<GrayF32> input , InterleavedU8 output ) {
if (output == null) {
output = new InterleavedU8(input.width, input.height,input.getNumBands());
} else {
output.reshape(input.width,input.height,input.getNumBands());
}
if( BoofConcurrency.USE_CONCURRENT ) {
ImplConvertImage_MT.convertF32U8(input,output);
} else {
ImplConvertImage.convertF32U8(input,output);
}
return output;
} | [
"public",
"static",
"InterleavedU8",
"convertF32U8",
"(",
"Planar",
"<",
"GrayF32",
">",
"input",
",",
"InterleavedU8",
"output",
")",
"{",
"if",
"(",
"output",
"==",
"null",
")",
"{",
"output",
"=",
"new",
"InterleavedU8",
"(",
"input",
".",
"width",
",",
"input",
".",
"height",
",",
"input",
".",
"getNumBands",
"(",
")",
")",
";",
"}",
"else",
"{",
"output",
".",
"reshape",
"(",
"input",
".",
"width",
",",
"input",
".",
"height",
",",
"input",
".",
"getNumBands",
"(",
")",
")",
";",
"}",
"if",
"(",
"BoofConcurrency",
".",
"USE_CONCURRENT",
")",
"{",
"ImplConvertImage_MT",
".",
"convertF32U8",
"(",
"input",
",",
"output",
")",
";",
"}",
"else",
"{",
"ImplConvertImage",
".",
"convertF32U8",
"(",
"input",
",",
"output",
")",
";",
"}",
"return",
"output",
";",
"}"
] | Converts a {@link Planar} into the equivalent {@link InterleavedU8}
@param input (Input) Planar image that is being converted. Not modified.
@param output (Optional) The output image. If null a new image is created. Modified.
@return Converted image. | [
"Converts",
"a",
"{",
"@link",
"Planar",
"}",
"into",
"the",
"equivalent",
"{",
"@link",
"InterleavedU8",
"}"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/core/image/ConvertImage.java#L3604-L3618 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/tm/tmtrafficaction.java | tmtrafficaction.get | public static tmtrafficaction get(nitro_service service, String name) throws Exception {
"""
Use this API to fetch tmtrafficaction resource of given name .
"""
tmtrafficaction obj = new tmtrafficaction();
obj.set_name(name);
tmtrafficaction response = (tmtrafficaction) obj.get_resource(service);
return response;
} | java | public static tmtrafficaction get(nitro_service service, String name) throws Exception{
tmtrafficaction obj = new tmtrafficaction();
obj.set_name(name);
tmtrafficaction response = (tmtrafficaction) obj.get_resource(service);
return response;
} | [
"public",
"static",
"tmtrafficaction",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"tmtrafficaction",
"obj",
"=",
"new",
"tmtrafficaction",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";",
"tmtrafficaction",
"response",
"=",
"(",
"tmtrafficaction",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch tmtrafficaction resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"tmtrafficaction",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/tm/tmtrafficaction.java#L429-L434 |
microfocus-idol/haven-search-components | hod/src/main/java/com/hp/autonomy/searchcomponents/hod/search/HodDocumentsServiceImpl.java | HodDocumentsServiceImpl.addDomain | private HodSearchResult addDomain(final Iterable<ResourceName> indexIdentifiers, final HodSearchResult document) {
"""
Add a domain to a FindDocument, given the collection of indexes which were queried against to return it from HOD
"""
// HOD does not return the domain for documents yet, but it does return the index
final String index = document.getIndex();
String domain = null;
// It's most likely that the returned documents will be in one of the indexes we are querying (hopefully the
// names are unique between the domains...)
for(final ResourceName indexIdentifier : indexIdentifiers) {
if(index.equals(indexIdentifier.getName())) {
domain = indexIdentifier.getDomain();
break;
}
}
if(domain == null) {
// If not, it might be a public index
domain = PUBLIC_INDEX_NAMES.contains(index) ? ResourceName.PUBLIC_INDEXES_DOMAIN : getDomain();
}
return document.toBuilder()
.domain(domain)
.build();
} | java | private HodSearchResult addDomain(final Iterable<ResourceName> indexIdentifiers, final HodSearchResult document) {
// HOD does not return the domain for documents yet, but it does return the index
final String index = document.getIndex();
String domain = null;
// It's most likely that the returned documents will be in one of the indexes we are querying (hopefully the
// names are unique between the domains...)
for(final ResourceName indexIdentifier : indexIdentifiers) {
if(index.equals(indexIdentifier.getName())) {
domain = indexIdentifier.getDomain();
break;
}
}
if(domain == null) {
// If not, it might be a public index
domain = PUBLIC_INDEX_NAMES.contains(index) ? ResourceName.PUBLIC_INDEXES_DOMAIN : getDomain();
}
return document.toBuilder()
.domain(domain)
.build();
} | [
"private",
"HodSearchResult",
"addDomain",
"(",
"final",
"Iterable",
"<",
"ResourceName",
">",
"indexIdentifiers",
",",
"final",
"HodSearchResult",
"document",
")",
"{",
"// HOD does not return the domain for documents yet, but it does return the index",
"final",
"String",
"index",
"=",
"document",
".",
"getIndex",
"(",
")",
";",
"String",
"domain",
"=",
"null",
";",
"// It's most likely that the returned documents will be in one of the indexes we are querying (hopefully the",
"// names are unique between the domains...)",
"for",
"(",
"final",
"ResourceName",
"indexIdentifier",
":",
"indexIdentifiers",
")",
"{",
"if",
"(",
"index",
".",
"equals",
"(",
"indexIdentifier",
".",
"getName",
"(",
")",
")",
")",
"{",
"domain",
"=",
"indexIdentifier",
".",
"getDomain",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"domain",
"==",
"null",
")",
"{",
"// If not, it might be a public index",
"domain",
"=",
"PUBLIC_INDEX_NAMES",
".",
"contains",
"(",
"index",
")",
"?",
"ResourceName",
".",
"PUBLIC_INDEXES_DOMAIN",
":",
"getDomain",
"(",
")",
";",
"}",
"return",
"document",
".",
"toBuilder",
"(",
")",
".",
"domain",
"(",
"domain",
")",
".",
"build",
"(",
")",
";",
"}"
] | Add a domain to a FindDocument, given the collection of indexes which were queried against to return it from HOD | [
"Add",
"a",
"domain",
"to",
"a",
"FindDocument",
"given",
"the",
"collection",
"of",
"indexes",
"which",
"were",
"queried",
"against",
"to",
"return",
"it",
"from",
"HOD"
] | train | https://github.com/microfocus-idol/haven-search-components/blob/6f5df74ba67ec0d3f86e73bc1dd0d6edd01a8e44/hod/src/main/java/com/hp/autonomy/searchcomponents/hod/search/HodDocumentsServiceImpl.java#L230-L252 |
EMCECS/nfs-client-java | src/main/java/com/emc/ecs/nfsclient/rpc/Xdr.java | Xdr.putBytes | public void putBytes(byte[] b, int boff, int len) {
"""
Put a counted array of bytes into the buffer. The length is not encoded.
@param b
byte array
@param boff
offset into byte array
@param len
number of bytes to encode
"""
System.arraycopy(b, boff, _buffer, _offset, len);
skip(len);
} | java | public void putBytes(byte[] b, int boff, int len) {
System.arraycopy(b, boff, _buffer, _offset, len);
skip(len);
} | [
"public",
"void",
"putBytes",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"boff",
",",
"int",
"len",
")",
"{",
"System",
".",
"arraycopy",
"(",
"b",
",",
"boff",
",",
"_buffer",
",",
"_offset",
",",
"len",
")",
";",
"skip",
"(",
"len",
")",
";",
"}"
] | Put a counted array of bytes into the buffer. The length is not encoded.
@param b
byte array
@param boff
offset into byte array
@param len
number of bytes to encode | [
"Put",
"a",
"counted",
"array",
"of",
"bytes",
"into",
"the",
"buffer",
".",
"The",
"length",
"is",
"not",
"encoded",
"."
] | train | https://github.com/EMCECS/nfs-client-java/blob/7ba25bad5052b95cd286052745327729288b2843/src/main/java/com/emc/ecs/nfsclient/rpc/Xdr.java#L375-L378 |
akquinet/androlog | androlog/src/main/java/de/akquinet/android/androlog/Log.java | Log.wtf | public static int wtf(String tag, Throwable tr) {
"""
What a Terrible Failure: Report a condition that should never happen. The
error will always be logged at level Constants.ASSERT despite the logging is
disabled. Depending on system configuration, and on Android 2.2+, a
report may be added to the DropBoxManager and/or the process may be
terminated immediately with an error dialog.
On older Android version (before 2.2), the message is logged with the
Assert level. Those log messages will always be logged.
@param tag
Used to identify the source of a log message. It usually
identifies the class or activity where the log call occurs.
@param tr
The exception to log
"""
collectLogEntry(Constants.VERBOSE, tag, "", tr);
if (isLoggable(tag, Constants.ASSERT)) {
if (useWTF) {
try {
return (Integer) wtfTagErrorMethod.invoke(null,
new Object[] { tag, tr });
} catch (Exception e) {
return LogHelper.println(Constants.ASSERT, tag, LogHelper.getStackTraceString(tr));
}
} else {
return LogHelper.println(Constants.ASSERT, tag, LogHelper.getStackTraceString(tr));
}
}
return 0;
} | java | public static int wtf(String tag, Throwable tr) {
collectLogEntry(Constants.VERBOSE, tag, "", tr);
if (isLoggable(tag, Constants.ASSERT)) {
if (useWTF) {
try {
return (Integer) wtfTagErrorMethod.invoke(null,
new Object[] { tag, tr });
} catch (Exception e) {
return LogHelper.println(Constants.ASSERT, tag, LogHelper.getStackTraceString(tr));
}
} else {
return LogHelper.println(Constants.ASSERT, tag, LogHelper.getStackTraceString(tr));
}
}
return 0;
} | [
"public",
"static",
"int",
"wtf",
"(",
"String",
"tag",
",",
"Throwable",
"tr",
")",
"{",
"collectLogEntry",
"(",
"Constants",
".",
"VERBOSE",
",",
"tag",
",",
"\"\"",
",",
"tr",
")",
";",
"if",
"(",
"isLoggable",
"(",
"tag",
",",
"Constants",
".",
"ASSERT",
")",
")",
"{",
"if",
"(",
"useWTF",
")",
"{",
"try",
"{",
"return",
"(",
"Integer",
")",
"wtfTagErrorMethod",
".",
"invoke",
"(",
"null",
",",
"new",
"Object",
"[",
"]",
"{",
"tag",
",",
"tr",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"LogHelper",
".",
"println",
"(",
"Constants",
".",
"ASSERT",
",",
"tag",
",",
"LogHelper",
".",
"getStackTraceString",
"(",
"tr",
")",
")",
";",
"}",
"}",
"else",
"{",
"return",
"LogHelper",
".",
"println",
"(",
"Constants",
".",
"ASSERT",
",",
"tag",
",",
"LogHelper",
".",
"getStackTraceString",
"(",
"tr",
")",
")",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | What a Terrible Failure: Report a condition that should never happen. The
error will always be logged at level Constants.ASSERT despite the logging is
disabled. Depending on system configuration, and on Android 2.2+, a
report may be added to the DropBoxManager and/or the process may be
terminated immediately with an error dialog.
On older Android version (before 2.2), the message is logged with the
Assert level. Those log messages will always be logged.
@param tag
Used to identify the source of a log message. It usually
identifies the class or activity where the log call occurs.
@param tr
The exception to log | [
"What",
"a",
"Terrible",
"Failure",
":",
"Report",
"a",
"condition",
"that",
"should",
"never",
"happen",
".",
"The",
"error",
"will",
"always",
"be",
"logged",
"at",
"level",
"Constants",
".",
"ASSERT",
"despite",
"the",
"logging",
"is",
"disabled",
".",
"Depending",
"on",
"system",
"configuration",
"and",
"on",
"Android",
"2",
".",
"2",
"+",
"a",
"report",
"may",
"be",
"added",
"to",
"the",
"DropBoxManager",
"and",
"/",
"or",
"the",
"process",
"may",
"be",
"terminated",
"immediately",
"with",
"an",
"error",
"dialog",
"."
] | train | https://github.com/akquinet/androlog/blob/82fa81354c01c9b1d1928062b634ba21f14be560/androlog/src/main/java/de/akquinet/android/androlog/Log.java#L1009-L1024 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TimeZoneFormat.java | TimeZoneFormat.parseZoneID | private static String parseZoneID(String text, ParsePosition pos) {
"""
Parse a zone ID.
@param text the text contains a time zone ID string at the position.
@param pos the position.
@return The zone ID parsed.
"""
String resolvedID = null;
if (ZONE_ID_TRIE == null) {
synchronized (TimeZoneFormat.class) {
if (ZONE_ID_TRIE == null) {
// Build zone ID trie
TextTrieMap<String> trie = new TextTrieMap<String>(true);
String[] ids = TimeZone.getAvailableIDs();
for (String id : ids) {
trie.put(id, id);
}
ZONE_ID_TRIE = trie;
}
}
}
int[] matchLen = new int[] {0};
Iterator<String> itr = ZONE_ID_TRIE.get(text, pos.getIndex(), matchLen);
if (itr != null) {
resolvedID = itr.next();
pos.setIndex(pos.getIndex() + matchLen[0]);
} else {
// TODO
// We many need to handle rule based custom zone ID (See ZoneMeta.parseCustomID),
// such as GM+05:00. However, the public parse method in this class also calls
// parseOffsetLocalizedGMT and custom zone IDs are likely supported by the parser,
// so we might not need to handle them here.
pos.setErrorIndex(pos.getIndex());
}
return resolvedID;
} | java | private static String parseZoneID(String text, ParsePosition pos) {
String resolvedID = null;
if (ZONE_ID_TRIE == null) {
synchronized (TimeZoneFormat.class) {
if (ZONE_ID_TRIE == null) {
// Build zone ID trie
TextTrieMap<String> trie = new TextTrieMap<String>(true);
String[] ids = TimeZone.getAvailableIDs();
for (String id : ids) {
trie.put(id, id);
}
ZONE_ID_TRIE = trie;
}
}
}
int[] matchLen = new int[] {0};
Iterator<String> itr = ZONE_ID_TRIE.get(text, pos.getIndex(), matchLen);
if (itr != null) {
resolvedID = itr.next();
pos.setIndex(pos.getIndex() + matchLen[0]);
} else {
// TODO
// We many need to handle rule based custom zone ID (See ZoneMeta.parseCustomID),
// such as GM+05:00. However, the public parse method in this class also calls
// parseOffsetLocalizedGMT and custom zone IDs are likely supported by the parser,
// so we might not need to handle them here.
pos.setErrorIndex(pos.getIndex());
}
return resolvedID;
} | [
"private",
"static",
"String",
"parseZoneID",
"(",
"String",
"text",
",",
"ParsePosition",
"pos",
")",
"{",
"String",
"resolvedID",
"=",
"null",
";",
"if",
"(",
"ZONE_ID_TRIE",
"==",
"null",
")",
"{",
"synchronized",
"(",
"TimeZoneFormat",
".",
"class",
")",
"{",
"if",
"(",
"ZONE_ID_TRIE",
"==",
"null",
")",
"{",
"// Build zone ID trie",
"TextTrieMap",
"<",
"String",
">",
"trie",
"=",
"new",
"TextTrieMap",
"<",
"String",
">",
"(",
"true",
")",
";",
"String",
"[",
"]",
"ids",
"=",
"TimeZone",
".",
"getAvailableIDs",
"(",
")",
";",
"for",
"(",
"String",
"id",
":",
"ids",
")",
"{",
"trie",
".",
"put",
"(",
"id",
",",
"id",
")",
";",
"}",
"ZONE_ID_TRIE",
"=",
"trie",
";",
"}",
"}",
"}",
"int",
"[",
"]",
"matchLen",
"=",
"new",
"int",
"[",
"]",
"{",
"0",
"}",
";",
"Iterator",
"<",
"String",
">",
"itr",
"=",
"ZONE_ID_TRIE",
".",
"get",
"(",
"text",
",",
"pos",
".",
"getIndex",
"(",
")",
",",
"matchLen",
")",
";",
"if",
"(",
"itr",
"!=",
"null",
")",
"{",
"resolvedID",
"=",
"itr",
".",
"next",
"(",
")",
";",
"pos",
".",
"setIndex",
"(",
"pos",
".",
"getIndex",
"(",
")",
"+",
"matchLen",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"// TODO",
"// We many need to handle rule based custom zone ID (See ZoneMeta.parseCustomID),",
"// such as GM+05:00. However, the public parse method in this class also calls",
"// parseOffsetLocalizedGMT and custom zone IDs are likely supported by the parser,",
"// so we might not need to handle them here.",
"pos",
".",
"setErrorIndex",
"(",
"pos",
".",
"getIndex",
"(",
")",
")",
";",
"}",
"return",
"resolvedID",
";",
"}"
] | Parse a zone ID.
@param text the text contains a time zone ID string at the position.
@param pos the position.
@return The zone ID parsed. | [
"Parse",
"a",
"zone",
"ID",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TimeZoneFormat.java#L2928-L2958 |
lucee/Lucee | core/src/main/java/lucee/runtime/converter/ScriptConverter.java | ScriptConverter._serializeStruct | public void _serializeStruct(Struct struct, StringBuilder sb, Set<Object> done) throws ConverterException {
"""
serialize a Struct
@param struct Struct to serialize
@param sb
@param done
@throws ConverterException
"""
sb.append(goIn());
sb.append('{');
Iterator it = struct.keyIterator();
boolean doIt = false;
deep++;
while (it.hasNext()) {
String key = Caster.toString(it.next(), "");
if (doIt) sb.append(',');
doIt = true;
sb.append(QUOTE_CHR);
sb.append(escape(key));
sb.append(QUOTE_CHR);
sb.append(':');
_serialize(struct.get(key, null), sb, done);
}
deep--;
sb.append('}');
} | java | public void _serializeStruct(Struct struct, StringBuilder sb, Set<Object> done) throws ConverterException {
sb.append(goIn());
sb.append('{');
Iterator it = struct.keyIterator();
boolean doIt = false;
deep++;
while (it.hasNext()) {
String key = Caster.toString(it.next(), "");
if (doIt) sb.append(',');
doIt = true;
sb.append(QUOTE_CHR);
sb.append(escape(key));
sb.append(QUOTE_CHR);
sb.append(':');
_serialize(struct.get(key, null), sb, done);
}
deep--;
sb.append('}');
} | [
"public",
"void",
"_serializeStruct",
"(",
"Struct",
"struct",
",",
"StringBuilder",
"sb",
",",
"Set",
"<",
"Object",
">",
"done",
")",
"throws",
"ConverterException",
"{",
"sb",
".",
"append",
"(",
"goIn",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"Iterator",
"it",
"=",
"struct",
".",
"keyIterator",
"(",
")",
";",
"boolean",
"doIt",
"=",
"false",
";",
"deep",
"++",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"key",
"=",
"Caster",
".",
"toString",
"(",
"it",
".",
"next",
"(",
")",
",",
"\"\"",
")",
";",
"if",
"(",
"doIt",
")",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"doIt",
"=",
"true",
";",
"sb",
".",
"append",
"(",
"QUOTE_CHR",
")",
";",
"sb",
".",
"append",
"(",
"escape",
"(",
"key",
")",
")",
";",
"sb",
".",
"append",
"(",
"QUOTE_CHR",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"_serialize",
"(",
"struct",
".",
"get",
"(",
"key",
",",
"null",
")",
",",
"sb",
",",
"done",
")",
";",
"}",
"deep",
"--",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"}"
] | serialize a Struct
@param struct Struct to serialize
@param sb
@param done
@throws ConverterException | [
"serialize",
"a",
"Struct"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/converter/ScriptConverter.java#L186-L205 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/JobApi.java | JobApi.downloadSingleArtifactsFile | public File downloadSingleArtifactsFile(Object projectIdOrPath, Integer jobId, Path artifactPath, File directory) throws GitLabApiException {
"""
Download a single artifact file from within the job's artifacts archive.
Only a single file is going to be extracted from the archive and streamed to a client.
<pre><code>GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts/*artifact_path</code></pre>
@param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@param jobId the unique job identifier
@param artifactPath the Path to a file inside the artifacts archive
@param directory the File instance of the directory to save the file to, if null will use "java.io.tmpdir"
@return a File instance pointing to the download of the specified artifacts file
@throws GitLabApiException if any exception occurs
"""
String path = artifactPath.toString().replace("\\", "/");
Response response = get(Response.Status.OK, getDefaultPerPageParam(),
"projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts", path);
try {
if (directory == null)
directory = new File(System.getProperty("java.io.tmpdir"));
String filename = artifactPath.getFileName().toString();
File file = new File(directory, filename);
InputStream in = response.readEntity(InputStream.class);
Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
return (file);
} catch (IOException ioe) {
throw new GitLabApiException(ioe);
}
} | java | public File downloadSingleArtifactsFile(Object projectIdOrPath, Integer jobId, Path artifactPath, File directory) throws GitLabApiException {
String path = artifactPath.toString().replace("\\", "/");
Response response = get(Response.Status.OK, getDefaultPerPageParam(),
"projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "artifacts", path);
try {
if (directory == null)
directory = new File(System.getProperty("java.io.tmpdir"));
String filename = artifactPath.getFileName().toString();
File file = new File(directory, filename);
InputStream in = response.readEntity(InputStream.class);
Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
return (file);
} catch (IOException ioe) {
throw new GitLabApiException(ioe);
}
} | [
"public",
"File",
"downloadSingleArtifactsFile",
"(",
"Object",
"projectIdOrPath",
",",
"Integer",
"jobId",
",",
"Path",
"artifactPath",
",",
"File",
"directory",
")",
"throws",
"GitLabApiException",
"{",
"String",
"path",
"=",
"artifactPath",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
")",
";",
"Response",
"response",
"=",
"get",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"getDefaultPerPageParam",
"(",
")",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"jobs\"",
",",
"jobId",
",",
"\"artifacts\"",
",",
"path",
")",
";",
"try",
"{",
"if",
"(",
"directory",
"==",
"null",
")",
"directory",
"=",
"new",
"File",
"(",
"System",
".",
"getProperty",
"(",
"\"java.io.tmpdir\"",
")",
")",
";",
"String",
"filename",
"=",
"artifactPath",
".",
"getFileName",
"(",
")",
".",
"toString",
"(",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"directory",
",",
"filename",
")",
";",
"InputStream",
"in",
"=",
"response",
".",
"readEntity",
"(",
"InputStream",
".",
"class",
")",
";",
"Files",
".",
"copy",
"(",
"in",
",",
"file",
".",
"toPath",
"(",
")",
",",
"StandardCopyOption",
".",
"REPLACE_EXISTING",
")",
";",
"return",
"(",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"GitLabApiException",
"(",
"ioe",
")",
";",
"}",
"}"
] | Download a single artifact file from within the job's artifacts archive.
Only a single file is going to be extracted from the archive and streamed to a client.
<pre><code>GitLab Endpoint: GET /projects/:id/jobs/:job_id/artifacts/*artifact_path</code></pre>
@param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@param jobId the unique job identifier
@param artifactPath the Path to a file inside the artifacts archive
@param directory the File instance of the directory to save the file to, if null will use "java.io.tmpdir"
@return a File instance pointing to the download of the specified artifacts file
@throws GitLabApiException if any exception occurs | [
"Download",
"a",
"single",
"artifact",
"file",
"from",
"within",
"the",
"job",
"s",
"artifacts",
"archive",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/JobApi.java#L372-L392 |
QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/Utils.java | Utils.getMD5 | public static byte[] getMD5(byte[] src) {
"""
Compute the MD5 of the given byte[] array. If the MD5 algorithm is not available
from the MessageDigest registry, an IllegalArgumentException will be thrown.
@param src Binary value to compute the MD5 digest for. Can be empty but not null.
@return 16-byte MD5 digest value.
"""
assert src != null;
try {
return MessageDigest.getInstance("MD5").digest(src);
} catch (NoSuchAlgorithmException ex) {
throw new IllegalArgumentException("Missing 'MD5' algorithm", ex);
}
} | java | public static byte[] getMD5(byte[] src) {
assert src != null;
try {
return MessageDigest.getInstance("MD5").digest(src);
} catch (NoSuchAlgorithmException ex) {
throw new IllegalArgumentException("Missing 'MD5' algorithm", ex);
}
} | [
"public",
"static",
"byte",
"[",
"]",
"getMD5",
"(",
"byte",
"[",
"]",
"src",
")",
"{",
"assert",
"src",
"!=",
"null",
";",
"try",
"{",
"return",
"MessageDigest",
".",
"getInstance",
"(",
"\"MD5\"",
")",
".",
"digest",
"(",
"src",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Missing 'MD5' algorithm\"",
",",
"ex",
")",
";",
"}",
"}"
] | Compute the MD5 of the given byte[] array. If the MD5 algorithm is not available
from the MessageDigest registry, an IllegalArgumentException will be thrown.
@param src Binary value to compute the MD5 digest for. Can be empty but not null.
@return 16-byte MD5 digest value. | [
"Compute",
"the",
"MD5",
"of",
"the",
"given",
"byte",
"[]",
"array",
".",
"If",
"the",
"MD5",
"algorithm",
"is",
"not",
"available",
"from",
"the",
"MessageDigest",
"registry",
"an",
"IllegalArgumentException",
"will",
"be",
"thrown",
"."
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/Utils.java#L968-L975 |
negusoft/holoaccent | HoloAccent/src/com/negusoft/holoaccent/AccentResources.java | AccentResources.getTintTransformationResourceStream | private InputStream getTintTransformationResourceStream(int id, TypedValue value, int color) {
"""
Get a reference to a resource that is equivalent to the one requested,
but changing the tint from the original red to the given color.
"""
Bitmap bitmap = getBitmapFromResource(id, value);
bitmap = BitmapUtils.processTintTransformationMap(bitmap, color);
return getStreamFromBitmap(bitmap);
} | java | private InputStream getTintTransformationResourceStream(int id, TypedValue value, int color) {
Bitmap bitmap = getBitmapFromResource(id, value);
bitmap = BitmapUtils.processTintTransformationMap(bitmap, color);
return getStreamFromBitmap(bitmap);
} | [
"private",
"InputStream",
"getTintTransformationResourceStream",
"(",
"int",
"id",
",",
"TypedValue",
"value",
",",
"int",
"color",
")",
"{",
"Bitmap",
"bitmap",
"=",
"getBitmapFromResource",
"(",
"id",
",",
"value",
")",
";",
"bitmap",
"=",
"BitmapUtils",
".",
"processTintTransformationMap",
"(",
"bitmap",
",",
"color",
")",
";",
"return",
"getStreamFromBitmap",
"(",
"bitmap",
")",
";",
"}"
] | Get a reference to a resource that is equivalent to the one requested,
but changing the tint from the original red to the given color. | [
"Get",
"a",
"reference",
"to",
"a",
"resource",
"that",
"is",
"equivalent",
"to",
"the",
"one",
"requested",
"but",
"changing",
"the",
"tint",
"from",
"the",
"original",
"red",
"to",
"the",
"given",
"color",
"."
] | train | https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/AccentResources.java#L376-L380 |
raphw/byte-buddy | byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java | ElementMatchers.nameContains | public static <T extends NamedElement> ElementMatcher.Junction<T> nameContains(String infix) {
"""
Matches a {@link NamedElement} for an infix of its name.
@param infix The expected infix of the name.
@param <T> The type of the matched object.
@return An element matcher for a named element's name's infix.
"""
return new NameMatcher<T>(new StringMatcher(infix, StringMatcher.Mode.CONTAINS));
} | java | public static <T extends NamedElement> ElementMatcher.Junction<T> nameContains(String infix) {
return new NameMatcher<T>(new StringMatcher(infix, StringMatcher.Mode.CONTAINS));
} | [
"public",
"static",
"<",
"T",
"extends",
"NamedElement",
">",
"ElementMatcher",
".",
"Junction",
"<",
"T",
">",
"nameContains",
"(",
"String",
"infix",
")",
"{",
"return",
"new",
"NameMatcher",
"<",
"T",
">",
"(",
"new",
"StringMatcher",
"(",
"infix",
",",
"StringMatcher",
".",
"Mode",
".",
"CONTAINS",
")",
")",
";",
"}"
] | Matches a {@link NamedElement} for an infix of its name.
@param infix The expected infix of the name.
@param <T> The type of the matched object.
@return An element matcher for a named element's name's infix. | [
"Matches",
"a",
"{",
"@link",
"NamedElement",
"}",
"for",
"an",
"infix",
"of",
"its",
"name",
"."
] | train | https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L723-L725 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java | ApiOvhDedicatedserver.serviceName_features_ipmi_access_POST | public OvhTask serviceName_features_ipmi_access_POST(String serviceName, String ipToAllow, String sshKey, OvhCacheTTLEnum ttl, OvhIpmiAccessTypeEnum type) throws IOException {
"""
Request an acces on KVM IPMI interface
REST: POST /dedicated/server/{serviceName}/features/ipmi/access
@param ttl [required] Session access time to live in minutes
@param type [required] IPMI console access
@param ipToAllow [required] IP to allow connection from for this IPMI session
@param sshKey [required] SSH key name to allow access on KVM/IP interface with (name from /me/sshKey)
@param serviceName [required] The internal name of your dedicated server
"""
String qPath = "/dedicated/server/{serviceName}/features/ipmi/access";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "ipToAllow", ipToAllow);
addBody(o, "sshKey", sshKey);
addBody(o, "ttl", ttl);
addBody(o, "type", type);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | java | public OvhTask serviceName_features_ipmi_access_POST(String serviceName, String ipToAllow, String sshKey, OvhCacheTTLEnum ttl, OvhIpmiAccessTypeEnum type) throws IOException {
String qPath = "/dedicated/server/{serviceName}/features/ipmi/access";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "ipToAllow", ipToAllow);
addBody(o, "sshKey", sshKey);
addBody(o, "ttl", ttl);
addBody(o, "type", type);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | [
"public",
"OvhTask",
"serviceName_features_ipmi_access_POST",
"(",
"String",
"serviceName",
",",
"String",
"ipToAllow",
",",
"String",
"sshKey",
",",
"OvhCacheTTLEnum",
"ttl",
",",
"OvhIpmiAccessTypeEnum",
"type",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicated/server/{serviceName}/features/ipmi/access\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"ipToAllow\"",
",",
"ipToAllow",
")",
";",
"addBody",
"(",
"o",
",",
"\"sshKey\"",
",",
"sshKey",
")",
";",
"addBody",
"(",
"o",
",",
"\"ttl\"",
",",
"ttl",
")",
";",
"addBody",
"(",
"o",
",",
"\"type\"",
",",
"type",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTask",
".",
"class",
")",
";",
"}"
] | Request an acces on KVM IPMI interface
REST: POST /dedicated/server/{serviceName}/features/ipmi/access
@param ttl [required] Session access time to live in minutes
@param type [required] IPMI console access
@param ipToAllow [required] IP to allow connection from for this IPMI session
@param sshKey [required] SSH key name to allow access on KVM/IP interface with (name from /me/sshKey)
@param serviceName [required] The internal name of your dedicated server | [
"Request",
"an",
"acces",
"on",
"KVM",
"IPMI",
"interface"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L1080-L1090 |
mbeiter/util | db/src/main/java/org/beiter/michael/db/propsbuilder/MapBasedConnPropsBuilder.java | MapBasedConnPropsBuilder.logDefault | private static void logDefault(final String key, final String defaultValue) {
"""
Create a log entry when a default value is being used in case the propsbuilder key has not been provided in the
configuration.
@param key The configuration key
@param defaultValue The default value that is being used
"""
// Fortify will report a violation here because of disclosure of potentially confidential information.
// However, neither the configuration keys nor the default propsbuilder values are confidential, which makes
// this a non-issue / false positive.
if (LOG.isInfoEnabled()) {
final StringBuilder msg = new StringBuilder("Key is not configured ('")
.append(key)
.append("'), using default value ('");
if (defaultValue == null) {
msg.append("null')");
} else {
msg.append(defaultValue).append("')");
}
LOG.info(msg.toString());
}
} | java | private static void logDefault(final String key, final String defaultValue) {
// Fortify will report a violation here because of disclosure of potentially confidential information.
// However, neither the configuration keys nor the default propsbuilder values are confidential, which makes
// this a non-issue / false positive.
if (LOG.isInfoEnabled()) {
final StringBuilder msg = new StringBuilder("Key is not configured ('")
.append(key)
.append("'), using default value ('");
if (defaultValue == null) {
msg.append("null')");
} else {
msg.append(defaultValue).append("')");
}
LOG.info(msg.toString());
}
} | [
"private",
"static",
"void",
"logDefault",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"defaultValue",
")",
"{",
"// Fortify will report a violation here because of disclosure of potentially confidential information.",
"// However, neither the configuration keys nor the default propsbuilder values are confidential, which makes",
"// this a non-issue / false positive.",
"if",
"(",
"LOG",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"final",
"StringBuilder",
"msg",
"=",
"new",
"StringBuilder",
"(",
"\"Key is not configured ('\"",
")",
".",
"append",
"(",
"key",
")",
".",
"append",
"(",
"\"'), using default value ('\"",
")",
";",
"if",
"(",
"defaultValue",
"==",
"null",
")",
"{",
"msg",
".",
"append",
"(",
"\"null')\"",
")",
";",
"}",
"else",
"{",
"msg",
".",
"append",
"(",
"defaultValue",
")",
".",
"append",
"(",
"\"')\"",
")",
";",
"}",
"LOG",
".",
"info",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Create a log entry when a default value is being used in case the propsbuilder key has not been provided in the
configuration.
@param key The configuration key
@param defaultValue The default value that is being used | [
"Create",
"a",
"log",
"entry",
"when",
"a",
"default",
"value",
"is",
"being",
"used",
"in",
"case",
"the",
"propsbuilder",
"key",
"has",
"not",
"been",
"provided",
"in",
"the",
"configuration",
"."
] | train | https://github.com/mbeiter/util/blob/490fcebecb936e00c2f2ce2096b679b2fd10865e/db/src/main/java/org/beiter/michael/db/propsbuilder/MapBasedConnPropsBuilder.java#L663-L679 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java | ResourceGroovyMethods.eachFileRecurse | public static void eachFileRecurse(final File self, final FileType fileType, @ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure)
throws FileNotFoundException, IllegalArgumentException {
"""
Processes each descendant file in this directory and any sub-directories.
Processing consists of potentially calling <code>closure</code> passing it the current
file (which may be a normal file or subdirectory) and then if a subdirectory was encountered,
recursively processing the subdirectory. Whether the closure is called is determined by whether
the file was a normal file or subdirectory and the value of fileType.
@param self a File (that happens to be a folder/directory)
@param fileType if normal files or directories or both should be processed
@param closure the closure to invoke on each file
@throws FileNotFoundException if the given directory does not exist
@throws IllegalArgumentException if the provided File object does not represent a directory
@since 1.7.1
"""
checkDir(self);
final File[] files = self.listFiles();
// null check because of http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4803836
if (files == null) return;
for (File file : files) {
if (file.isDirectory()) {
if (fileType != FileType.FILES) closure.call(file);
eachFileRecurse(file, fileType, closure);
} else if (fileType != FileType.DIRECTORIES) {
closure.call(file);
}
}
} | java | public static void eachFileRecurse(final File self, final FileType fileType, @ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure)
throws FileNotFoundException, IllegalArgumentException {
checkDir(self);
final File[] files = self.listFiles();
// null check because of http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4803836
if (files == null) return;
for (File file : files) {
if (file.isDirectory()) {
if (fileType != FileType.FILES) closure.call(file);
eachFileRecurse(file, fileType, closure);
} else if (fileType != FileType.DIRECTORIES) {
closure.call(file);
}
}
} | [
"public",
"static",
"void",
"eachFileRecurse",
"(",
"final",
"File",
"self",
",",
"final",
"FileType",
"fileType",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"SimpleType",
".",
"class",
",",
"options",
"=",
"\"java.io.File\"",
")",
"final",
"Closure",
"closure",
")",
"throws",
"FileNotFoundException",
",",
"IllegalArgumentException",
"{",
"checkDir",
"(",
"self",
")",
";",
"final",
"File",
"[",
"]",
"files",
"=",
"self",
".",
"listFiles",
"(",
")",
";",
"// null check because of http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4803836",
"if",
"(",
"files",
"==",
"null",
")",
"return",
";",
"for",
"(",
"File",
"file",
":",
"files",
")",
"{",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"fileType",
"!=",
"FileType",
".",
"FILES",
")",
"closure",
".",
"call",
"(",
"file",
")",
";",
"eachFileRecurse",
"(",
"file",
",",
"fileType",
",",
"closure",
")",
";",
"}",
"else",
"if",
"(",
"fileType",
"!=",
"FileType",
".",
"DIRECTORIES",
")",
"{",
"closure",
".",
"call",
"(",
"file",
")",
";",
"}",
"}",
"}"
] | Processes each descendant file in this directory and any sub-directories.
Processing consists of potentially calling <code>closure</code> passing it the current
file (which may be a normal file or subdirectory) and then if a subdirectory was encountered,
recursively processing the subdirectory. Whether the closure is called is determined by whether
the file was a normal file or subdirectory and the value of fileType.
@param self a File (that happens to be a folder/directory)
@param fileType if normal files or directories or both should be processed
@param closure the closure to invoke on each file
@throws FileNotFoundException if the given directory does not exist
@throws IllegalArgumentException if the provided File object does not represent a directory
@since 1.7.1 | [
"Processes",
"each",
"descendant",
"file",
"in",
"this",
"directory",
"and",
"any",
"sub",
"-",
"directories",
".",
"Processing",
"consists",
"of",
"potentially",
"calling",
"<code",
">",
"closure<",
"/",
"code",
">",
"passing",
"it",
"the",
"current",
"file",
"(",
"which",
"may",
"be",
"a",
"normal",
"file",
"or",
"subdirectory",
")",
"and",
"then",
"if",
"a",
"subdirectory",
"was",
"encountered",
"recursively",
"processing",
"the",
"subdirectory",
".",
"Whether",
"the",
"closure",
"is",
"called",
"is",
"determined",
"by",
"whether",
"the",
"file",
"was",
"a",
"normal",
"file",
"or",
"subdirectory",
"and",
"the",
"value",
"of",
"fileType",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L1238-L1252 |
interedition/collatex | collatex-core/src/main/java/eu/interedition/collatex/suffixarray/DivSufSort.java | DivSufSort.ssCompare | private int ssCompare(int pa, int pb, int p2, int depth) {
"""
special version of ss_compare for handling
<code>ss_compare(T, &(PAi[0]), PA + *a, depth)</code> situation.
"""
int U1, U2, U1n, U2n;// pointers to T
for (U1 = depth + pa, U2 = depth + SA[p2], U1n = pb + 2, U2n = SA[p2 + 1] + 2; (U1 < U1n)
&& (U2 < U2n) && (T[start + U1] == T[start + U2]); ++U1, ++U2) {
}
return U1 < U1n ? (U2 < U2n ? T[start + U1] - T[start + U2] : 1) : (U2 < U2n ? -1
: 0);
} | java | private int ssCompare(int pa, int pb, int p2, int depth) {
int U1, U2, U1n, U2n;// pointers to T
for (U1 = depth + pa, U2 = depth + SA[p2], U1n = pb + 2, U2n = SA[p2 + 1] + 2; (U1 < U1n)
&& (U2 < U2n) && (T[start + U1] == T[start + U2]); ++U1, ++U2) {
}
return U1 < U1n ? (U2 < U2n ? T[start + U1] - T[start + U2] : 1) : (U2 < U2n ? -1
: 0);
} | [
"private",
"int",
"ssCompare",
"(",
"int",
"pa",
",",
"int",
"pb",
",",
"int",
"p2",
",",
"int",
"depth",
")",
"{",
"int",
"U1",
",",
"U2",
",",
"U1n",
",",
"U2n",
";",
"// pointers to T",
"for",
"(",
"U1",
"=",
"depth",
"+",
"pa",
",",
"U2",
"=",
"depth",
"+",
"SA",
"[",
"p2",
"]",
",",
"U1n",
"=",
"pb",
"+",
"2",
",",
"U2n",
"=",
"SA",
"[",
"p2",
"+",
"1",
"]",
"+",
"2",
";",
"(",
"U1",
"<",
"U1n",
")",
"&&",
"(",
"U2",
"<",
"U2n",
")",
"&&",
"(",
"T",
"[",
"start",
"+",
"U1",
"]",
"==",
"T",
"[",
"start",
"+",
"U2",
"]",
")",
";",
"++",
"U1",
",",
"++",
"U2",
")",
"{",
"}",
"return",
"U1",
"<",
"U1n",
"?",
"(",
"U2",
"<",
"U2n",
"?",
"T",
"[",
"start",
"+",
"U1",
"]",
"-",
"T",
"[",
"start",
"+",
"U2",
"]",
":",
"1",
")",
":",
"(",
"U2",
"<",
"U2n",
"?",
"-",
"1",
":",
"0",
")",
";",
"}"
] | special version of ss_compare for handling
<code>ss_compare(T, &(PAi[0]), PA + *a, depth)</code> situation. | [
"special",
"version",
"of",
"ss_compare",
"for",
"handling",
"<code",
">",
"ss_compare",
"(",
"T",
"&",
"(",
"PAi",
"[",
"0",
"]",
")",
"PA",
"+",
"*",
"a",
"depth",
")",
"<",
"/",
"code",
">",
"situation",
"."
] | train | https://github.com/interedition/collatex/blob/76dd1fcc36047bc66a87d31142e72e98b5347821/collatex-core/src/main/java/eu/interedition/collatex/suffixarray/DivSufSort.java#L453-L462 |
jbundle/jbundle | main/screen/src/main/java/org/jbundle/main/user/screen/UserInfoGridScreen.java | UserInfoGridScreen.doCommand | public boolean doCommand(String strCommand, ScreenField sourceSField, int iCommandOptions) {
"""
Process the command.
<br />Step 1 - Process the command if possible and return true if processed.
<br />Step 2 - If I can't process, pass to all children (with me as the source).
<br />Step 3 - If children didn't process, pass to parent (with me as the source).
<br />Note: Never pass to a parent or child that matches the source (to avoid an endless loop).
@param strCommand The command to process.
@param sourceSField The source screen field (to avoid echos).
@param iCommandOptions If this command creates a new screen, create in a new window?
@return true if success.
"""
if ((MenuConstants.FORM.equalsIgnoreCase(strCommand))
|| (MenuConstants.FORMLINK.equalsIgnoreCase(strCommand)))
{
return this.handleCommand(UserInfo.VERBOSE_MAINT_SCREEN, sourceSField, iCommandOptions);
}
return super.doCommand(strCommand, sourceSField, iCommandOptions);
} | java | public boolean doCommand(String strCommand, ScreenField sourceSField, int iCommandOptions)
{
if ((MenuConstants.FORM.equalsIgnoreCase(strCommand))
|| (MenuConstants.FORMLINK.equalsIgnoreCase(strCommand)))
{
return this.handleCommand(UserInfo.VERBOSE_MAINT_SCREEN, sourceSField, iCommandOptions);
}
return super.doCommand(strCommand, sourceSField, iCommandOptions);
} | [
"public",
"boolean",
"doCommand",
"(",
"String",
"strCommand",
",",
"ScreenField",
"sourceSField",
",",
"int",
"iCommandOptions",
")",
"{",
"if",
"(",
"(",
"MenuConstants",
".",
"FORM",
".",
"equalsIgnoreCase",
"(",
"strCommand",
")",
")",
"||",
"(",
"MenuConstants",
".",
"FORMLINK",
".",
"equalsIgnoreCase",
"(",
"strCommand",
")",
")",
")",
"{",
"return",
"this",
".",
"handleCommand",
"(",
"UserInfo",
".",
"VERBOSE_MAINT_SCREEN",
",",
"sourceSField",
",",
"iCommandOptions",
")",
";",
"}",
"return",
"super",
".",
"doCommand",
"(",
"strCommand",
",",
"sourceSField",
",",
"iCommandOptions",
")",
";",
"}"
] | Process the command.
<br />Step 1 - Process the command if possible and return true if processed.
<br />Step 2 - If I can't process, pass to all children (with me as the source).
<br />Step 3 - If children didn't process, pass to parent (with me as the source).
<br />Note: Never pass to a parent or child that matches the source (to avoid an endless loop).
@param strCommand The command to process.
@param sourceSField The source screen field (to avoid echos).
@param iCommandOptions If this command creates a new screen, create in a new window?
@return true if success. | [
"Process",
"the",
"command",
".",
"<br",
"/",
">",
"Step",
"1",
"-",
"Process",
"the",
"command",
"if",
"possible",
"and",
"return",
"true",
"if",
"processed",
".",
"<br",
"/",
">",
"Step",
"2",
"-",
"If",
"I",
"can",
"t",
"process",
"pass",
"to",
"all",
"children",
"(",
"with",
"me",
"as",
"the",
"source",
")",
".",
"<br",
"/",
">",
"Step",
"3",
"-",
"If",
"children",
"didn",
"t",
"process",
"pass",
"to",
"parent",
"(",
"with",
"me",
"as",
"the",
"source",
")",
".",
"<br",
"/",
">",
"Note",
":",
"Never",
"pass",
"to",
"a",
"parent",
"or",
"child",
"that",
"matches",
"the",
"source",
"(",
"to",
"avoid",
"an",
"endless",
"loop",
")",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/screen/src/main/java/org/jbundle/main/user/screen/UserInfoGridScreen.java#L145-L153 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/RecommendationsInner.java | RecommendationsInner.listAsync | public Observable<Page<RecommendationInner>> listAsync(final Boolean featured, final String filter) {
"""
List all recommendations for a subscription.
List all recommendations for a subscription.
@param featured Specify <code>true</code> to return only the most critical recommendations. The default is <code>false</code>, which returns all recommendations.
@param filter Filter is specified by using OData syntax. Example: $filter=channels eq 'Api' or channel eq 'Notification' and startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' and timeGrain eq duration'[PT1H|PT1M|P1D]
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<RecommendationInner> object
"""
return listWithServiceResponseAsync(featured, filter)
.map(new Func1<ServiceResponse<Page<RecommendationInner>>, Page<RecommendationInner>>() {
@Override
public Page<RecommendationInner> call(ServiceResponse<Page<RecommendationInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<RecommendationInner>> listAsync(final Boolean featured, final String filter) {
return listWithServiceResponseAsync(featured, filter)
.map(new Func1<ServiceResponse<Page<RecommendationInner>>, Page<RecommendationInner>>() {
@Override
public Page<RecommendationInner> call(ServiceResponse<Page<RecommendationInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"RecommendationInner",
">",
">",
"listAsync",
"(",
"final",
"Boolean",
"featured",
",",
"final",
"String",
"filter",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"featured",
",",
"filter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"RecommendationInner",
">",
">",
",",
"Page",
"<",
"RecommendationInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"RecommendationInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"RecommendationInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | List all recommendations for a subscription.
List all recommendations for a subscription.
@param featured Specify <code>true</code> to return only the most critical recommendations. The default is <code>false</code>, which returns all recommendations.
@param filter Filter is specified by using OData syntax. Example: $filter=channels eq 'Api' or channel eq 'Notification' and startTime eq '2014-01-01T00:00:00Z' and endTime eq '2014-12-31T23:59:59Z' and timeGrain eq duration'[PT1H|PT1M|P1D]
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<RecommendationInner> object | [
"List",
"all",
"recommendations",
"for",
"a",
"subscription",
".",
"List",
"all",
"recommendations",
"for",
"a",
"subscription",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/RecommendationsInner.java#L271-L279 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/methods/TmdbAuthentication.java | TmdbAuthentication.getGuestSessionToken | public TokenSession getGuestSessionToken() throws MovieDbException {
"""
This method is used to generate a guest session id.
A guest session can be used to rate movies without having a registered
TMDb user account.
You should only generate a single guest session per user (or device) as
you will be able to attach the ratings to a TMDb user account in the
future.
There are also IP limits in place so you should always make sure it's the
end user doing the guest session actions.
If a guest session is not used for the first time within 24 hours, it
will be automatically discarded.
@return
@throws MovieDbException
"""
URL url = new ApiUrl(apiKey, MethodBase.AUTH).subMethod(MethodSub.GUEST_SESSION).buildUrl();
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, TokenSession.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Guest Session Token", url, ex);
}
} | java | public TokenSession getGuestSessionToken() throws MovieDbException {
URL url = new ApiUrl(apiKey, MethodBase.AUTH).subMethod(MethodSub.GUEST_SESSION).buildUrl();
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, TokenSession.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Guest Session Token", url, ex);
}
} | [
"public",
"TokenSession",
"getGuestSessionToken",
"(",
")",
"throws",
"MovieDbException",
"{",
"URL",
"url",
"=",
"new",
"ApiUrl",
"(",
"apiKey",
",",
"MethodBase",
".",
"AUTH",
")",
".",
"subMethod",
"(",
"MethodSub",
".",
"GUEST_SESSION",
")",
".",
"buildUrl",
"(",
")",
";",
"String",
"webpage",
"=",
"httpTools",
".",
"getRequest",
"(",
"url",
")",
";",
"try",
"{",
"return",
"MAPPER",
".",
"readValue",
"(",
"webpage",
",",
"TokenSession",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"MovieDbException",
"(",
"ApiExceptionType",
".",
"MAPPING_FAILED",
",",
"\"Failed to get Guest Session Token\"",
",",
"url",
",",
"ex",
")",
";",
"}",
"}"
] | This method is used to generate a guest session id.
A guest session can be used to rate movies without having a registered
TMDb user account.
You should only generate a single guest session per user (or device) as
you will be able to attach the ratings to a TMDb user account in the
future.
There are also IP limits in place so you should always make sure it's the
end user doing the guest session actions.
If a guest session is not used for the first time within 24 hours, it
will be automatically discarded.
@return
@throws MovieDbException | [
"This",
"method",
"is",
"used",
"to",
"generate",
"a",
"guest",
"session",
"id",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbAuthentication.java#L160-L169 |
Alluxio/alluxio | core/common/src/main/java/alluxio/util/UnderFileSystemUtils.java | UnderFileSystemUtils.approximateContentHash | public static String approximateContentHash(long length, long modTime) {
"""
Returns an approximate content hash, using the length and modification time.
@param length the content length
@param modTime the content last modification time
@return the content hash
"""
// approximating the content hash with the file length and modtime.
StringBuilder sb = new StringBuilder();
sb.append('(');
sb.append("len:");
sb.append(length);
sb.append(", ");
sb.append("modtime:");
sb.append(modTime);
sb.append(')');
return sb.toString();
} | java | public static String approximateContentHash(long length, long modTime) {
// approximating the content hash with the file length and modtime.
StringBuilder sb = new StringBuilder();
sb.append('(');
sb.append("len:");
sb.append(length);
sb.append(", ");
sb.append("modtime:");
sb.append(modTime);
sb.append(')');
return sb.toString();
} | [
"public",
"static",
"String",
"approximateContentHash",
"(",
"long",
"length",
",",
"long",
"modTime",
")",
"{",
"// approximating the content hash with the file length and modtime.",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"\"len:\"",
")",
";",
"sb",
".",
"append",
"(",
"length",
")",
";",
"sb",
".",
"append",
"(",
"\", \"",
")",
";",
"sb",
".",
"append",
"(",
"\"modtime:\"",
")",
";",
"sb",
".",
"append",
"(",
"modTime",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Returns an approximate content hash, using the length and modification time.
@param length the content length
@param modTime the content last modification time
@return the content hash | [
"Returns",
"an",
"approximate",
"content",
"hash",
"using",
"the",
"length",
"and",
"modification",
"time",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/UnderFileSystemUtils.java#L147-L158 |
codelibs/jcifs | src/main/java/jcifs/smb/NtlmAuthenticator.java | NtlmAuthenticator.requestNtlmPasswordAuthentication | public static NtlmPasswordAuthenticator requestNtlmPasswordAuthentication ( String url, SmbAuthException sae ) {
"""
Used internally by jCIFS when an <tt>SmbAuthException</tt> is trapped to retrieve new user credentials.
@param url
@param sae
@return credentials returned by prompt
"""
return requestNtlmPasswordAuthentication(auth, url, sae);
} | java | public static NtlmPasswordAuthenticator requestNtlmPasswordAuthentication ( String url, SmbAuthException sae ) {
return requestNtlmPasswordAuthentication(auth, url, sae);
} | [
"public",
"static",
"NtlmPasswordAuthenticator",
"requestNtlmPasswordAuthentication",
"(",
"String",
"url",
",",
"SmbAuthException",
"sae",
")",
"{",
"return",
"requestNtlmPasswordAuthentication",
"(",
"auth",
",",
"url",
",",
"sae",
")",
";",
"}"
] | Used internally by jCIFS when an <tt>SmbAuthException</tt> is trapped to retrieve new user credentials.
@param url
@param sae
@return credentials returned by prompt | [
"Used",
"internally",
"by",
"jCIFS",
"when",
"an",
"<tt",
">",
"SmbAuthException<",
"/",
"tt",
">",
"is",
"trapped",
"to",
"retrieve",
"new",
"user",
"credentials",
"."
] | train | https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb/NtlmAuthenticator.java#L77-L79 |
JodaOrg/joda-time | src/main/java/org/joda/time/convert/ReadableInstantConverter.java | ReadableInstantConverter.getChronology | public Chronology getChronology(Object object, Chronology chrono) {
"""
Gets the chronology, which is taken from the ReadableInstant.
<p>
If the passed in chronology is non-null, it is used.
Otherwise the chronology from the instant is used.
@param object the ReadableInstant to convert, must not be null
@param chrono the chronology to use, null means use that from object
@return the chronology, never null
"""
if (chrono == null) {
chrono = ((ReadableInstant) object).getChronology();
chrono = DateTimeUtils.getChronology(chrono);
}
return chrono;
} | java | public Chronology getChronology(Object object, Chronology chrono) {
if (chrono == null) {
chrono = ((ReadableInstant) object).getChronology();
chrono = DateTimeUtils.getChronology(chrono);
}
return chrono;
} | [
"public",
"Chronology",
"getChronology",
"(",
"Object",
"object",
",",
"Chronology",
"chrono",
")",
"{",
"if",
"(",
"chrono",
"==",
"null",
")",
"{",
"chrono",
"=",
"(",
"(",
"ReadableInstant",
")",
"object",
")",
".",
"getChronology",
"(",
")",
";",
"chrono",
"=",
"DateTimeUtils",
".",
"getChronology",
"(",
"chrono",
")",
";",
"}",
"return",
"chrono",
";",
"}"
] | Gets the chronology, which is taken from the ReadableInstant.
<p>
If the passed in chronology is non-null, it is used.
Otherwise the chronology from the instant is used.
@param object the ReadableInstant to convert, must not be null
@param chrono the chronology to use, null means use that from object
@return the chronology, never null | [
"Gets",
"the",
"chronology",
"which",
"is",
"taken",
"from",
"the",
"ReadableInstant",
".",
"<p",
">",
"If",
"the",
"passed",
"in",
"chronology",
"is",
"non",
"-",
"null",
"it",
"is",
"used",
".",
"Otherwise",
"the",
"chronology",
"from",
"the",
"instant",
"is",
"used",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/ReadableInstantConverter.java#L82-L88 |
googleads/googleads-java-lib | examples/adwords_axis/src/main/java/adwords/axis/v201809/migration/MigrateToExtensionSettings.java | MigrateToExtensionSettings.getFeedItemIdsForCampaign | private static Set<Long> getFeedItemIdsForCampaign(CampaignFeed campaignFeed)
throws RemoteException {
"""
Returns the list of feed item IDs that are used by a campaign through a given campaign feed.
"""
Set<Long> feedItemIds = Sets.newHashSet();
FunctionOperator functionOperator = campaignFeed.getMatchingFunction().getOperator();
if (FunctionOperator.IN.equals(functionOperator)) {
// Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
// Extract feed items if applicable.
feedItemIds.addAll(getFeedItemIdsFromArgument(campaignFeed.getMatchingFunction()));
} else if (FunctionOperator.AND.equals(functionOperator)) {
// Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
// Extract feed items if applicable.
Arrays.stream(campaignFeed.getMatchingFunction().getLhsOperand())
.filter(FunctionOperand.class::isInstance)
.map(argument -> (FunctionOperand) argument)
.filter(operand -> FunctionOperator.IN.equals(operand.getValue().getOperator()))
.forEach(operand -> feedItemIds.addAll(getFeedItemIdsFromArgument(operand.getValue())));
} else {
// There are no other matching functions involving feed item IDs.
}
return feedItemIds;
} | java | private static Set<Long> getFeedItemIdsForCampaign(CampaignFeed campaignFeed)
throws RemoteException {
Set<Long> feedItemIds = Sets.newHashSet();
FunctionOperator functionOperator = campaignFeed.getMatchingFunction().getOperator();
if (FunctionOperator.IN.equals(functionOperator)) {
// Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
// Extract feed items if applicable.
feedItemIds.addAll(getFeedItemIdsFromArgument(campaignFeed.getMatchingFunction()));
} else if (FunctionOperator.AND.equals(functionOperator)) {
// Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
// Extract feed items if applicable.
Arrays.stream(campaignFeed.getMatchingFunction().getLhsOperand())
.filter(FunctionOperand.class::isInstance)
.map(argument -> (FunctionOperand) argument)
.filter(operand -> FunctionOperator.IN.equals(operand.getValue().getOperator()))
.forEach(operand -> feedItemIds.addAll(getFeedItemIdsFromArgument(operand.getValue())));
} else {
// There are no other matching functions involving feed item IDs.
}
return feedItemIds;
} | [
"private",
"static",
"Set",
"<",
"Long",
">",
"getFeedItemIdsForCampaign",
"(",
"CampaignFeed",
"campaignFeed",
")",
"throws",
"RemoteException",
"{",
"Set",
"<",
"Long",
">",
"feedItemIds",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"FunctionOperator",
"functionOperator",
"=",
"campaignFeed",
".",
"getMatchingFunction",
"(",
")",
".",
"getOperator",
"(",
")",
";",
"if",
"(",
"FunctionOperator",
".",
"IN",
".",
"equals",
"(",
"functionOperator",
")",
")",
"{",
"// Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).",
"// Extract feed items if applicable.",
"feedItemIds",
".",
"addAll",
"(",
"getFeedItemIdsFromArgument",
"(",
"campaignFeed",
".",
"getMatchingFunction",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"FunctionOperator",
".",
"AND",
".",
"equals",
"(",
"functionOperator",
")",
")",
"{",
"// Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).",
"// Extract feed items if applicable.",
"Arrays",
".",
"stream",
"(",
"campaignFeed",
".",
"getMatchingFunction",
"(",
")",
".",
"getLhsOperand",
"(",
")",
")",
".",
"filter",
"(",
"FunctionOperand",
".",
"class",
"::",
"isInstance",
")",
".",
"map",
"(",
"argument",
"->",
"(",
"FunctionOperand",
")",
"argument",
")",
".",
"filter",
"(",
"operand",
"->",
"FunctionOperator",
".",
"IN",
".",
"equals",
"(",
"operand",
".",
"getValue",
"(",
")",
".",
"getOperator",
"(",
")",
")",
")",
".",
"forEach",
"(",
"operand",
"->",
"feedItemIds",
".",
"addAll",
"(",
"getFeedItemIdsFromArgument",
"(",
"operand",
".",
"getValue",
"(",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"// There are no other matching functions involving feed item IDs.",
"}",
"return",
"feedItemIds",
";",
"}"
] | Returns the list of feed item IDs that are used by a campaign through a given campaign feed. | [
"Returns",
"the",
"list",
"of",
"feed",
"item",
"IDs",
"that",
"are",
"used",
"by",
"a",
"campaign",
"through",
"a",
"given",
"campaign",
"feed",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/examples/adwords_axis/src/main/java/adwords/axis/v201809/migration/MigrateToExtensionSettings.java#L506-L529 |
LearnLib/automatalib | util/src/main/java/net/automatalib/util/minimizer/Block.java | Block.addToSubBlock | void addToSubBlock(State<S, L> state) {
"""
Adds a state to the current sub block.
@param state
the state to be added.
"""
if (currSubBlock == null) {
throw new IllegalStateException("No current sub block");
}
currSubBlock.referencedAdd(state);
elementsInSubBlocks++;
} | java | void addToSubBlock(State<S, L> state) {
if (currSubBlock == null) {
throw new IllegalStateException("No current sub block");
}
currSubBlock.referencedAdd(state);
elementsInSubBlocks++;
} | [
"void",
"addToSubBlock",
"(",
"State",
"<",
"S",
",",
"L",
">",
"state",
")",
"{",
"if",
"(",
"currSubBlock",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"No current sub block\"",
")",
";",
"}",
"currSubBlock",
".",
"referencedAdd",
"(",
"state",
")",
";",
"elementsInSubBlocks",
"++",
";",
"}"
] | Adds a state to the current sub block.
@param state
the state to be added. | [
"Adds",
"a",
"state",
"to",
"the",
"current",
"sub",
"block",
"."
] | train | https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/util/src/main/java/net/automatalib/util/minimizer/Block.java#L137-L143 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java | KeyVaultClientCustomImpl.listSecrets | public PagedList<SecretItem> listSecrets(final String vaultBaseUrl, final Integer maxresults) {
"""
List secrets in the specified vault.
@param vaultBaseUrl
The vault name, e.g. https://myvault.vault.azure.net
@param maxresults
Maximum number of results to return in a page. If not specified
the service will return up to 25 results.
@return the PagedList<SecretItem> if successful.
"""
return getSecrets(vaultBaseUrl, maxresults);
} | java | public PagedList<SecretItem> listSecrets(final String vaultBaseUrl, final Integer maxresults) {
return getSecrets(vaultBaseUrl, maxresults);
} | [
"public",
"PagedList",
"<",
"SecretItem",
">",
"listSecrets",
"(",
"final",
"String",
"vaultBaseUrl",
",",
"final",
"Integer",
"maxresults",
")",
"{",
"return",
"getSecrets",
"(",
"vaultBaseUrl",
",",
"maxresults",
")",
";",
"}"
] | List secrets in the specified vault.
@param vaultBaseUrl
The vault name, e.g. https://myvault.vault.azure.net
@param maxresults
Maximum number of results to return in a page. If not specified
the service will return up to 25 results.
@return the PagedList<SecretItem> if successful. | [
"List",
"secrets",
"in",
"the",
"specified",
"vault",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java#L1198-L1200 |
alkacon/opencms-core | src/org/opencms/ui/apps/dbmanager/sqlconsole/CmsSqlConsoleExecutor.java | CmsSqlConsoleExecutor.writeError | private void writeError(I_CmsReport report, Throwable e) {
"""
Writes the given error to the report,
and, if enabled, to the opencms log file.<p>
@param report the report to write to
@param e the exception
"""
report.println(e);
if (LOG.isWarnEnabled()) {
LOG.warn("SQLConsole", e);
}
} | java | private void writeError(I_CmsReport report, Throwable e) {
report.println(e);
if (LOG.isWarnEnabled()) {
LOG.warn("SQLConsole", e);
}
} | [
"private",
"void",
"writeError",
"(",
"I_CmsReport",
"report",
",",
"Throwable",
"e",
")",
"{",
"report",
".",
"println",
"(",
"e",
")",
";",
"if",
"(",
"LOG",
".",
"isWarnEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"SQLConsole\"",
",",
"e",
")",
";",
"}",
"}"
] | Writes the given error to the report,
and, if enabled, to the opencms log file.<p>
@param report the report to write to
@param e the exception | [
"Writes",
"the",
"given",
"error",
"to",
"the",
"report",
"and",
"if",
"enabled",
"to",
"the",
"opencms",
"log",
"file",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/dbmanager/sqlconsole/CmsSqlConsoleExecutor.java#L295-L301 |
onelogin/onelogin-java-sdk | src/main/java/com/onelogin/sdk/conn/Client.java | Client.getUsersAssignedToPrivileges | public List<Long> getUsersAssignedToPrivileges(String id) throws OAuthSystemException, OAuthProblemException, URISyntaxException {
"""
Gets a list of the user Ids assigned to a privilege.
@param id
Id of the privilege
@return List of user Ids
@throws OAuthSystemException - if there is a IOException reading parameters of the httpURLConnection
@throws OAuthProblemException - if there are errors validating the OneloginOAuthJSONResourceResponse and throwOAuthProblemException is enabled
@throws URISyntaxException - if there is an error when generating the target URL at the getResource call
@see <a target="_blank" href="https://developers.onelogin.com/api-docs/1/privileges/get-users">Get Assigned Users documentation</a>
"""
int maxResults = this.maxResults > 1000? this.maxResults : 1000;
return getUsersAssignedToPrivileges(id, maxResults);
} | java | public List<Long> getUsersAssignedToPrivileges(String id) throws OAuthSystemException, OAuthProblemException, URISyntaxException {
int maxResults = this.maxResults > 1000? this.maxResults : 1000;
return getUsersAssignedToPrivileges(id, maxResults);
} | [
"public",
"List",
"<",
"Long",
">",
"getUsersAssignedToPrivileges",
"(",
"String",
"id",
")",
"throws",
"OAuthSystemException",
",",
"OAuthProblemException",
",",
"URISyntaxException",
"{",
"int",
"maxResults",
"=",
"this",
".",
"maxResults",
">",
"1000",
"?",
"this",
".",
"maxResults",
":",
"1000",
";",
"return",
"getUsersAssignedToPrivileges",
"(",
"id",
",",
"maxResults",
")",
";",
"}"
] | Gets a list of the user Ids assigned to a privilege.
@param id
Id of the privilege
@return List of user Ids
@throws OAuthSystemException - if there is a IOException reading parameters of the httpURLConnection
@throws OAuthProblemException - if there are errors validating the OneloginOAuthJSONResourceResponse and throwOAuthProblemException is enabled
@throws URISyntaxException - if there is an error when generating the target URL at the getResource call
@see <a target="_blank" href="https://developers.onelogin.com/api-docs/1/privileges/get-users">Get Assigned Users documentation</a> | [
"Gets",
"a",
"list",
"of",
"the",
"user",
"Ids",
"assigned",
"to",
"a",
"privilege",
"."
] | train | https://github.com/onelogin/onelogin-java-sdk/blob/1570b78033dcc1c7387099e77fe41b6b0638df8c/src/main/java/com/onelogin/sdk/conn/Client.java#L3700-L3704 |
jlinn/quartz-redis-jobstore | src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java | AbstractRedisStorage.retrieveJob | public JobDetail retrieveJob(JobKey jobKey, T jedis) throws JobPersistenceException, ClassNotFoundException {
"""
Retrieve a job from redis
@param jobKey the job key detailing the identity of the job to be retrieved
@param jedis a thread-safe Redis connection
@return the {@link org.quartz.JobDetail} of the desired job
@throws JobPersistenceException if the desired job does not exist
@throws ClassNotFoundException
"""
final String jobHashKey = redisSchema.jobHashKey(jobKey);
final String jobDataMapHashKey = redisSchema.jobDataMapHashKey(jobKey);
final Map<String, String> jobDetailMap = jedis.hgetAll(jobHashKey);
if(jobDetailMap == null || jobDetailMap.size() == 0){
// desired job does not exist
return null;
}
JobDetailImpl jobDetail = mapper.convertValue(jobDetailMap, JobDetailImpl.class);
jobDetail.setKey(jobKey);
final Map<String, String> jobData = jedis.hgetAll(jobDataMapHashKey);
if(jobData != null && !jobData.isEmpty()){
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.putAll(jobData);
jobDetail.setJobDataMap(jobDataMap);
}
return jobDetail;
} | java | public JobDetail retrieveJob(JobKey jobKey, T jedis) throws JobPersistenceException, ClassNotFoundException{
final String jobHashKey = redisSchema.jobHashKey(jobKey);
final String jobDataMapHashKey = redisSchema.jobDataMapHashKey(jobKey);
final Map<String, String> jobDetailMap = jedis.hgetAll(jobHashKey);
if(jobDetailMap == null || jobDetailMap.size() == 0){
// desired job does not exist
return null;
}
JobDetailImpl jobDetail = mapper.convertValue(jobDetailMap, JobDetailImpl.class);
jobDetail.setKey(jobKey);
final Map<String, String> jobData = jedis.hgetAll(jobDataMapHashKey);
if(jobData != null && !jobData.isEmpty()){
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.putAll(jobData);
jobDetail.setJobDataMap(jobDataMap);
}
return jobDetail;
} | [
"public",
"JobDetail",
"retrieveJob",
"(",
"JobKey",
"jobKey",
",",
"T",
"jedis",
")",
"throws",
"JobPersistenceException",
",",
"ClassNotFoundException",
"{",
"final",
"String",
"jobHashKey",
"=",
"redisSchema",
".",
"jobHashKey",
"(",
"jobKey",
")",
";",
"final",
"String",
"jobDataMapHashKey",
"=",
"redisSchema",
".",
"jobDataMapHashKey",
"(",
"jobKey",
")",
";",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"jobDetailMap",
"=",
"jedis",
".",
"hgetAll",
"(",
"jobHashKey",
")",
";",
"if",
"(",
"jobDetailMap",
"==",
"null",
"||",
"jobDetailMap",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// desired job does not exist",
"return",
"null",
";",
"}",
"JobDetailImpl",
"jobDetail",
"=",
"mapper",
".",
"convertValue",
"(",
"jobDetailMap",
",",
"JobDetailImpl",
".",
"class",
")",
";",
"jobDetail",
".",
"setKey",
"(",
"jobKey",
")",
";",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"jobData",
"=",
"jedis",
".",
"hgetAll",
"(",
"jobDataMapHashKey",
")",
";",
"if",
"(",
"jobData",
"!=",
"null",
"&&",
"!",
"jobData",
".",
"isEmpty",
"(",
")",
")",
"{",
"JobDataMap",
"jobDataMap",
"=",
"new",
"JobDataMap",
"(",
")",
";",
"jobDataMap",
".",
"putAll",
"(",
"jobData",
")",
";",
"jobDetail",
".",
"setJobDataMap",
"(",
"jobDataMap",
")",
";",
"}",
"return",
"jobDetail",
";",
"}"
] | Retrieve a job from redis
@param jobKey the job key detailing the identity of the job to be retrieved
@param jedis a thread-safe Redis connection
@return the {@link org.quartz.JobDetail} of the desired job
@throws JobPersistenceException if the desired job does not exist
@throws ClassNotFoundException | [
"Retrieve",
"a",
"job",
"from",
"redis"
] | train | https://github.com/jlinn/quartz-redis-jobstore/blob/be9a52ee776d8a09866fe99fd9718bc13a0cb992/src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java#L186-L206 |
igniterealtime/Smack | smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java | MultiUserChatLight.getAffiliations | public HashMap<Jid, MUCLightAffiliation> getAffiliations(String version)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
"""
Get the MUC Light affiliations.
@param version
@return the room affiliations
@throws NoResponseException
@throws XMPPErrorException
@throws NotConnectedException
@throws InterruptedException
"""
MUCLightGetAffiliationsIQ mucLightGetAffiliationsIQ = new MUCLightGetAffiliationsIQ(room, version);
IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetAffiliationsIQ).nextResultOrThrow();
MUCLightAffiliationsIQ mucLightAffiliationsIQ = (MUCLightAffiliationsIQ) responseIq;
return mucLightAffiliationsIQ.getAffiliations();
} | java | public HashMap<Jid, MUCLightAffiliation> getAffiliations(String version)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCLightGetAffiliationsIQ mucLightGetAffiliationsIQ = new MUCLightGetAffiliationsIQ(room, version);
IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetAffiliationsIQ).nextResultOrThrow();
MUCLightAffiliationsIQ mucLightAffiliationsIQ = (MUCLightAffiliationsIQ) responseIq;
return mucLightAffiliationsIQ.getAffiliations();
} | [
"public",
"HashMap",
"<",
"Jid",
",",
"MUCLightAffiliation",
">",
"getAffiliations",
"(",
"String",
"version",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"MUCLightGetAffiliationsIQ",
"mucLightGetAffiliationsIQ",
"=",
"new",
"MUCLightGetAffiliationsIQ",
"(",
"room",
",",
"version",
")",
";",
"IQ",
"responseIq",
"=",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"mucLightGetAffiliationsIQ",
")",
".",
"nextResultOrThrow",
"(",
")",
";",
"MUCLightAffiliationsIQ",
"mucLightAffiliationsIQ",
"=",
"(",
"MUCLightAffiliationsIQ",
")",
"responseIq",
";",
"return",
"mucLightAffiliationsIQ",
".",
"getAffiliations",
"(",
")",
";",
"}"
] | Get the MUC Light affiliations.
@param version
@return the room affiliations
@throws NoResponseException
@throws XMPPErrorException
@throws NotConnectedException
@throws InterruptedException | [
"Get",
"the",
"MUC",
"Light",
"affiliations",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L388-L396 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/stream/StreamHelper.java | StreamHelper.skipFully | public static void skipFully (@Nonnull final InputStream aIS, @Nonnegative final long nBytesToSkip) throws IOException {
"""
Fully skip the passed amounts in the input stream. Only forward skipping is
possible!
@param aIS
The input stream to skip in.
@param nBytesToSkip
The number of bytes to skip. Must be ≥ 0.
@throws IOException
In case something goes wrong internally
"""
ValueEnforcer.notNull (aIS, "InputStream");
ValueEnforcer.isGE0 (nBytesToSkip, "BytesToSkip");
long nRemaining = nBytesToSkip;
while (nRemaining > 0)
{
// May only return a partial skip
final long nSkipped = aIS.skip (nRemaining);
if (nSkipped == 0)
{
// Check if we're at the end of the file or not
// -> blocking read!
if (aIS.read () == -1)
{
throw new EOFException ("Failed to skip a total of " +
nBytesToSkip +
" bytes on input stream. Only skipped " +
(nBytesToSkip - nRemaining) +
" bytes so far!");
}
nRemaining--;
}
else
{
// Skipped at least one char
nRemaining -= nSkipped;
}
}
} | java | public static void skipFully (@Nonnull final InputStream aIS, @Nonnegative final long nBytesToSkip) throws IOException
{
ValueEnforcer.notNull (aIS, "InputStream");
ValueEnforcer.isGE0 (nBytesToSkip, "BytesToSkip");
long nRemaining = nBytesToSkip;
while (nRemaining > 0)
{
// May only return a partial skip
final long nSkipped = aIS.skip (nRemaining);
if (nSkipped == 0)
{
// Check if we're at the end of the file or not
// -> blocking read!
if (aIS.read () == -1)
{
throw new EOFException ("Failed to skip a total of " +
nBytesToSkip +
" bytes on input stream. Only skipped " +
(nBytesToSkip - nRemaining) +
" bytes so far!");
}
nRemaining--;
}
else
{
// Skipped at least one char
nRemaining -= nSkipped;
}
}
} | [
"public",
"static",
"void",
"skipFully",
"(",
"@",
"Nonnull",
"final",
"InputStream",
"aIS",
",",
"@",
"Nonnegative",
"final",
"long",
"nBytesToSkip",
")",
"throws",
"IOException",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aIS",
",",
"\"InputStream\"",
")",
";",
"ValueEnforcer",
".",
"isGE0",
"(",
"nBytesToSkip",
",",
"\"BytesToSkip\"",
")",
";",
"long",
"nRemaining",
"=",
"nBytesToSkip",
";",
"while",
"(",
"nRemaining",
">",
"0",
")",
"{",
"// May only return a partial skip",
"final",
"long",
"nSkipped",
"=",
"aIS",
".",
"skip",
"(",
"nRemaining",
")",
";",
"if",
"(",
"nSkipped",
"==",
"0",
")",
"{",
"// Check if we're at the end of the file or not",
"// -> blocking read!",
"if",
"(",
"aIS",
".",
"read",
"(",
")",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"EOFException",
"(",
"\"Failed to skip a total of \"",
"+",
"nBytesToSkip",
"+",
"\" bytes on input stream. Only skipped \"",
"+",
"(",
"nBytesToSkip",
"-",
"nRemaining",
")",
"+",
"\" bytes so far!\"",
")",
";",
"}",
"nRemaining",
"--",
";",
"}",
"else",
"{",
"// Skipped at least one char",
"nRemaining",
"-=",
"nSkipped",
";",
"}",
"}",
"}"
] | Fully skip the passed amounts in the input stream. Only forward skipping is
possible!
@param aIS
The input stream to skip in.
@param nBytesToSkip
The number of bytes to skip. Must be ≥ 0.
@throws IOException
In case something goes wrong internally | [
"Fully",
"skip",
"the",
"passed",
"amounts",
"in",
"the",
"input",
"stream",
".",
"Only",
"forward",
"skipping",
"is",
"possible!"
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/stream/StreamHelper.java#L1369-L1399 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/UriEscaper.java | UriEscaper.escapeQuery | public static String escapeQuery(final String query, final boolean strict) {
"""
Escapes a string as a URI query
@param query the path to escape
@param strict whether or not to do strict escaping
@return the escaped string
"""
return (strict ? STRICT_ESCAPER : ESCAPER).escapeQuery(query);
} | java | public static String escapeQuery(final String query, final boolean strict) {
return (strict ? STRICT_ESCAPER : ESCAPER).escapeQuery(query);
} | [
"public",
"static",
"String",
"escapeQuery",
"(",
"final",
"String",
"query",
",",
"final",
"boolean",
"strict",
")",
"{",
"return",
"(",
"strict",
"?",
"STRICT_ESCAPER",
":",
"ESCAPER",
")",
".",
"escapeQuery",
"(",
"query",
")",
";",
"}"
] | Escapes a string as a URI query
@param query the path to escape
@param strict whether or not to do strict escaping
@return the escaped string | [
"Escapes",
"a",
"string",
"as",
"a",
"URI",
"query"
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/UriEscaper.java#L250-L252 |
fcrepo3/fcrepo | fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java | FedoraClient.getTuples | public TupleIterator getTuples(Map<String, String> params)
throws IOException {
"""
Get tuples from the remote resource index. The map contains
<em>String</em> values for parameters that should be passed to the
service. Two parameters are required: 1) lang 2) query Two parameters to
the risearch service are implied: 1) type = tuples 2) format = sparql See
http
://www.fedora.info/download/2.0/userdocs/server/webservices/risearch/#
app.tuples
"""
params.put("type", "tuples");
params.put("format", RDFFormat.SPARQL.getName());
try {
String url = getRIQueryURL(params);
return TupleIterator.fromStream(get(url, true, true),
RDFFormat.SPARQL);
} catch (TrippiException e) {
throw new IOException("Error getting tuple iterator: "
+ e.getMessage());
}
} | java | public TupleIterator getTuples(Map<String, String> params)
throws IOException {
params.put("type", "tuples");
params.put("format", RDFFormat.SPARQL.getName());
try {
String url = getRIQueryURL(params);
return TupleIterator.fromStream(get(url, true, true),
RDFFormat.SPARQL);
} catch (TrippiException e) {
throw new IOException("Error getting tuple iterator: "
+ e.getMessage());
}
} | [
"public",
"TupleIterator",
"getTuples",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"IOException",
"{",
"params",
".",
"put",
"(",
"\"type\"",
",",
"\"tuples\"",
")",
";",
"params",
".",
"put",
"(",
"\"format\"",
",",
"RDFFormat",
".",
"SPARQL",
".",
"getName",
"(",
")",
")",
";",
"try",
"{",
"String",
"url",
"=",
"getRIQueryURL",
"(",
"params",
")",
";",
"return",
"TupleIterator",
".",
"fromStream",
"(",
"get",
"(",
"url",
",",
"true",
",",
"true",
")",
",",
"RDFFormat",
".",
"SPARQL",
")",
";",
"}",
"catch",
"(",
"TrippiException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Error getting tuple iterator: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Get tuples from the remote resource index. The map contains
<em>String</em> values for parameters that should be passed to the
service. Two parameters are required: 1) lang 2) query Two parameters to
the risearch service are implied: 1) type = tuples 2) format = sparql See
http
://www.fedora.info/download/2.0/userdocs/server/webservices/risearch/#
app.tuples | [
"Get",
"tuples",
"from",
"the",
"remote",
"resource",
"index",
".",
"The",
"map",
"contains",
"<em",
">",
"String<",
"/",
"em",
">",
"values",
"for",
"parameters",
"that",
"should",
"be",
"passed",
"to",
"the",
"service",
".",
"Two",
"parameters",
"are",
"required",
":",
"1",
")",
"lang",
"2",
")",
"query",
"Two",
"parameters",
"to",
"the",
"risearch",
"service",
"are",
"implied",
":",
"1",
")",
"type",
"=",
"tuples",
"2",
")",
"format",
"=",
"sparql",
"See",
"http",
":",
"//",
"www",
".",
"fedora",
".",
"info",
"/",
"download",
"/",
"2",
".",
"0",
"/",
"userdocs",
"/",
"server",
"/",
"webservices",
"/",
"risearch",
"/",
"#",
"app",
".",
"tuples"
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-client/fcrepo-client-admin/src/main/java/org/fcrepo/client/FedoraClient.java#L808-L820 |
vvakame/JsonPullParser | jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonUtil.java | JsonUtil.putLongList | public static void putLongList(Writer writer, List<Long> values) throws IOException {
"""
Writes the given value with the given writer.
@param writer
@param values
@throws IOException
@author vvakame
"""
if (values == null) {
writer.write("null");
} else {
startArray(writer);
for (int i = 0; i < values.size(); i++) {
put(writer, values.get(i));
if (i != values.size() - 1) {
addSeparator(writer);
}
}
endArray(writer);
}
} | java | public static void putLongList(Writer writer, List<Long> values) throws IOException {
if (values == null) {
writer.write("null");
} else {
startArray(writer);
for (int i = 0; i < values.size(); i++) {
put(writer, values.get(i));
if (i != values.size() - 1) {
addSeparator(writer);
}
}
endArray(writer);
}
} | [
"public",
"static",
"void",
"putLongList",
"(",
"Writer",
"writer",
",",
"List",
"<",
"Long",
">",
"values",
")",
"throws",
"IOException",
"{",
"if",
"(",
"values",
"==",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"\"null\"",
")",
";",
"}",
"else",
"{",
"startArray",
"(",
"writer",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"put",
"(",
"writer",
",",
"values",
".",
"get",
"(",
"i",
")",
")",
";",
"if",
"(",
"i",
"!=",
"values",
".",
"size",
"(",
")",
"-",
"1",
")",
"{",
"addSeparator",
"(",
"writer",
")",
";",
"}",
"}",
"endArray",
"(",
"writer",
")",
";",
"}",
"}"
] | Writes the given value with the given writer.
@param writer
@param values
@throws IOException
@author vvakame | [
"Writes",
"the",
"given",
"value",
"with",
"the",
"given",
"writer",
"."
] | train | https://github.com/vvakame/JsonPullParser/blob/fce183ca66354723323a77f2ae8cb5222b5836bc/jsonpullparser-core/src/main/java/net/vvakame/util/jsonpullparser/util/JsonUtil.java#L404-L417 |
apache/incubator-gobblin | gobblin-service/src/main/java/org/apache/gobblin/service/modules/flow/MultiHopsFlowToJobSpecCompiler.java | MultiHopsFlowToJobSpecCompiler.jobSpecURIGenerator | @Override
public URI jobSpecURIGenerator(Object... objects) {
"""
A naive implementation of generating a jobSpec's URI within a multi-hop logical Flow.
"""
FlowSpec flowSpec = (FlowSpec) objects[0];
ServiceNode sourceNode = (ServiceNode) objects[1];
ServiceNode targetNode = (ServiceNode) objects[2];
try {
return new URI(JobSpec.Builder.DEFAULT_JOB_CATALOG_SCHEME, flowSpec.getUri().getAuthority(),
StringUtils.appendIfMissing(StringUtils.prependIfMissing(flowSpec.getUri().getPath(), "/"),"/")
+ sourceNode.getNodeName() + "-" + targetNode.getNodeName(), null);
} catch (URISyntaxException e) {
log.error(
"URI construction failed when jobSpec from " + sourceNode.getNodeName() + " to " + targetNode.getNodeName());
throw new RuntimeException();
}
} | java | @Override
public URI jobSpecURIGenerator(Object... objects) {
FlowSpec flowSpec = (FlowSpec) objects[0];
ServiceNode sourceNode = (ServiceNode) objects[1];
ServiceNode targetNode = (ServiceNode) objects[2];
try {
return new URI(JobSpec.Builder.DEFAULT_JOB_CATALOG_SCHEME, flowSpec.getUri().getAuthority(),
StringUtils.appendIfMissing(StringUtils.prependIfMissing(flowSpec.getUri().getPath(), "/"),"/")
+ sourceNode.getNodeName() + "-" + targetNode.getNodeName(), null);
} catch (URISyntaxException e) {
log.error(
"URI construction failed when jobSpec from " + sourceNode.getNodeName() + " to " + targetNode.getNodeName());
throw new RuntimeException();
}
} | [
"@",
"Override",
"public",
"URI",
"jobSpecURIGenerator",
"(",
"Object",
"...",
"objects",
")",
"{",
"FlowSpec",
"flowSpec",
"=",
"(",
"FlowSpec",
")",
"objects",
"[",
"0",
"]",
";",
"ServiceNode",
"sourceNode",
"=",
"(",
"ServiceNode",
")",
"objects",
"[",
"1",
"]",
";",
"ServiceNode",
"targetNode",
"=",
"(",
"ServiceNode",
")",
"objects",
"[",
"2",
"]",
";",
"try",
"{",
"return",
"new",
"URI",
"(",
"JobSpec",
".",
"Builder",
".",
"DEFAULT_JOB_CATALOG_SCHEME",
",",
"flowSpec",
".",
"getUri",
"(",
")",
".",
"getAuthority",
"(",
")",
",",
"StringUtils",
".",
"appendIfMissing",
"(",
"StringUtils",
".",
"prependIfMissing",
"(",
"flowSpec",
".",
"getUri",
"(",
")",
".",
"getPath",
"(",
")",
",",
"\"/\"",
")",
",",
"\"/\"",
")",
"+",
"sourceNode",
".",
"getNodeName",
"(",
")",
"+",
"\"-\"",
"+",
"targetNode",
".",
"getNodeName",
"(",
")",
",",
"null",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"URI construction failed when jobSpec from \"",
"+",
"sourceNode",
".",
"getNodeName",
"(",
")",
"+",
"\" to \"",
"+",
"targetNode",
".",
"getNodeName",
"(",
")",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
")",
";",
"}",
"}"
] | A naive implementation of generating a jobSpec's URI within a multi-hop logical Flow. | [
"A",
"naive",
"implementation",
"of",
"generating",
"a",
"jobSpec",
"s",
"URI",
"within",
"a",
"multi",
"-",
"hop",
"logical",
"Flow",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-service/src/main/java/org/apache/gobblin/service/modules/flow/MultiHopsFlowToJobSpecCompiler.java#L343-L357 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/filemgr/FileManagerImpl.java | FileManagerImpl.storeUserData | public boolean storeUserData(long instanceid, long data)
throws IOException,
FileManagerException {
"""
************************************************************************
Save userdata in parm 1 under unique serial number from parm2.
@param instanceid This is the unique identifier for this userdata
@param data This is the data associated with the instanceid
@return true if the data is stored, false if the serial number is 0
@throws IOException if disk write fails.
@throws FileManagerException if there are no slots available for the
userdata.
***********************************************************************
"""
if ( instanceid == 0 ) {
return false;
}
for ( int i = 0; i < NUM_USER_WORDS; i++ ) {
if ( userData[i][0] == instanceid ) {
userData[i][1] = data;
writeUserData(i);
return true;
}
}
//
// If we fall through then this is the first time. Now search for an
// opening.
//
for ( int i = 0; i < NUM_USER_WORDS; i++ ) {
if ( userData[i][0] == 0 ) {
userData[i][0] = instanceid;
userData[i][1] = data;
writeUserData(i);
return true;
}
}
//
// If we fall through then all userdata slots are filled. Throw an
// exception so caller knows why he's hosed.
//
throw new FileManagerException("storeUserdata: No remaining slots");
} | java | public boolean storeUserData(long instanceid, long data)
throws IOException,
FileManagerException
{
if ( instanceid == 0 ) {
return false;
}
for ( int i = 0; i < NUM_USER_WORDS; i++ ) {
if ( userData[i][0] == instanceid ) {
userData[i][1] = data;
writeUserData(i);
return true;
}
}
//
// If we fall through then this is the first time. Now search for an
// opening.
//
for ( int i = 0; i < NUM_USER_WORDS; i++ ) {
if ( userData[i][0] == 0 ) {
userData[i][0] = instanceid;
userData[i][1] = data;
writeUserData(i);
return true;
}
}
//
// If we fall through then all userdata slots are filled. Throw an
// exception so caller knows why he's hosed.
//
throw new FileManagerException("storeUserdata: No remaining slots");
} | [
"public",
"boolean",
"storeUserData",
"(",
"long",
"instanceid",
",",
"long",
"data",
")",
"throws",
"IOException",
",",
"FileManagerException",
"{",
"if",
"(",
"instanceid",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"NUM_USER_WORDS",
";",
"i",
"++",
")",
"{",
"if",
"(",
"userData",
"[",
"i",
"]",
"[",
"0",
"]",
"==",
"instanceid",
")",
"{",
"userData",
"[",
"i",
"]",
"[",
"1",
"]",
"=",
"data",
";",
"writeUserData",
"(",
"i",
")",
";",
"return",
"true",
";",
"}",
"}",
"//",
"// If we fall through then this is the first time. Now search for an",
"// opening.",
"//",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"NUM_USER_WORDS",
";",
"i",
"++",
")",
"{",
"if",
"(",
"userData",
"[",
"i",
"]",
"[",
"0",
"]",
"==",
"0",
")",
"{",
"userData",
"[",
"i",
"]",
"[",
"0",
"]",
"=",
"instanceid",
";",
"userData",
"[",
"i",
"]",
"[",
"1",
"]",
"=",
"data",
";",
"writeUserData",
"(",
"i",
")",
";",
"return",
"true",
";",
"}",
"}",
"//",
"// If we fall through then all userdata slots are filled. Throw an",
"// exception so caller knows why he's hosed.",
"//",
"throw",
"new",
"FileManagerException",
"(",
"\"storeUserdata: No remaining slots\"",
")",
";",
"}"
] | ************************************************************************
Save userdata in parm 1 under unique serial number from parm2.
@param instanceid This is the unique identifier for this userdata
@param data This is the data associated with the instanceid
@return true if the data is stored, false if the serial number is 0
@throws IOException if disk write fails.
@throws FileManagerException if there are no slots available for the
userdata.
*********************************************************************** | [
"************************************************************************",
"Save",
"userdata",
"in",
"parm",
"1",
"under",
"unique",
"serial",
"number",
"from",
"parm2",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/persistent/filemgr/FileManagerImpl.java#L272-L305 |
aws/aws-sdk-java | aws-java-sdk-robomaker/src/main/java/com/amazonaws/services/robomaker/model/CreateRobotApplicationResult.java | CreateRobotApplicationResult.withTags | public CreateRobotApplicationResult withTags(java.util.Map<String, String> tags) {
"""
<p>
The list of all tags added to the robot application.
</p>
@param tags
The list of all tags added to the robot application.
@return Returns a reference to this object so that method calls can be chained together.
"""
setTags(tags);
return this;
} | java | public CreateRobotApplicationResult withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
} | [
"public",
"CreateRobotApplicationResult",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The list of all tags added to the robot application.
</p>
@param tags
The list of all tags added to the robot application.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"list",
"of",
"all",
"tags",
"added",
"to",
"the",
"robot",
"application",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-robomaker/src/main/java/com/amazonaws/services/robomaker/model/CreateRobotApplicationResult.java#L420-L423 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/Calendar.java | Calendar.getDateTimeFormat | public DateFormat getDateTimeFormat(int dateStyle, int timeStyle, ULocale loc) {
"""
<strong>[icu]</strong> Returns a <code>DateFormat</code> appropriate to this calendar.
Subclasses wishing to specialize this behavior should override
{@link #handleGetDateFormat}.
"""
return formatHelper(this, loc, dateStyle, timeStyle);
} | java | public DateFormat getDateTimeFormat(int dateStyle, int timeStyle, ULocale loc) {
return formatHelper(this, loc, dateStyle, timeStyle);
} | [
"public",
"DateFormat",
"getDateTimeFormat",
"(",
"int",
"dateStyle",
",",
"int",
"timeStyle",
",",
"ULocale",
"loc",
")",
"{",
"return",
"formatHelper",
"(",
"this",
",",
"loc",
",",
"dateStyle",
",",
"timeStyle",
")",
";",
"}"
] | <strong>[icu]</strong> Returns a <code>DateFormat</code> appropriate to this calendar.
Subclasses wishing to specialize this behavior should override
{@link #handleGetDateFormat}. | [
"<strong",
">",
"[",
"icu",
"]",
"<",
"/",
"strong",
">",
"Returns",
"a",
"<code",
">",
"DateFormat<",
"/",
"code",
">",
"appropriate",
"to",
"this",
"calendar",
".",
"Subclasses",
"wishing",
"to",
"specialize",
"this",
"behavior",
"should",
"override",
"{"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/Calendar.java#L3341-L3343 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/misc/FDBigInteger.java | FDBigInteger.multByPow52 | public FDBigInteger multByPow52(int p5, int p2) {
"""
/*@
@ requires this.value() == 0 || p5 == 0 && p2 == 0;
@ assignable \nothing;
@ ensures \result == this;
@
@ also
@
@ requires this.value() > 0 && (p5 > 0 && p2 >= 0 || p5 == 0 && p2 > 0 && this.isImmutable);
@ assignable \nothing;
@ ensures \result.value() == \old(this.value() * pow52(p5, p2));
@
@ also
@
@ requires this.value() > 0 && p5 == 0 && p2 > 0 && !this.isImmutable;
@ assignable this.nWords, this.data, this.data[*];
@ ensures \result == this;
@ ensures \result.value() == \old(this.value() * pow52(p5, p2));
@
"""
if (this.nWords == 0) {
return this;
}
FDBigInteger res = this;
if (p5 != 0) {
int[] r;
int extraSize = (p2 != 0) ? 1 : 0;
if (p5 < SMALL_5_POW.length) {
r = new int[this.nWords + 1 + extraSize];
mult(this.data, this.nWords, SMALL_5_POW[p5], r);
res = new FDBigInteger(r, this.offset);
} else {
FDBigInteger pow5 = big5pow(p5);
r = new int[this.nWords + pow5.size() + extraSize];
mult(this.data, this.nWords, pow5.data, pow5.nWords, r);
res = new FDBigInteger(r, this.offset + pow5.offset);
}
}
return res.leftShift(p2);
} | java | public FDBigInteger multByPow52(int p5, int p2) {
if (this.nWords == 0) {
return this;
}
FDBigInteger res = this;
if (p5 != 0) {
int[] r;
int extraSize = (p2 != 0) ? 1 : 0;
if (p5 < SMALL_5_POW.length) {
r = new int[this.nWords + 1 + extraSize];
mult(this.data, this.nWords, SMALL_5_POW[p5], r);
res = new FDBigInteger(r, this.offset);
} else {
FDBigInteger pow5 = big5pow(p5);
r = new int[this.nWords + pow5.size() + extraSize];
mult(this.data, this.nWords, pow5.data, pow5.nWords, r);
res = new FDBigInteger(r, this.offset + pow5.offset);
}
}
return res.leftShift(p2);
} | [
"public",
"FDBigInteger",
"multByPow52",
"(",
"int",
"p5",
",",
"int",
"p2",
")",
"{",
"if",
"(",
"this",
".",
"nWords",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"FDBigInteger",
"res",
"=",
"this",
";",
"if",
"(",
"p5",
"!=",
"0",
")",
"{",
"int",
"[",
"]",
"r",
";",
"int",
"extraSize",
"=",
"(",
"p2",
"!=",
"0",
")",
"?",
"1",
":",
"0",
";",
"if",
"(",
"p5",
"<",
"SMALL_5_POW",
".",
"length",
")",
"{",
"r",
"=",
"new",
"int",
"[",
"this",
".",
"nWords",
"+",
"1",
"+",
"extraSize",
"]",
";",
"mult",
"(",
"this",
".",
"data",
",",
"this",
".",
"nWords",
",",
"SMALL_5_POW",
"[",
"p5",
"]",
",",
"r",
")",
";",
"res",
"=",
"new",
"FDBigInteger",
"(",
"r",
",",
"this",
".",
"offset",
")",
";",
"}",
"else",
"{",
"FDBigInteger",
"pow5",
"=",
"big5pow",
"(",
"p5",
")",
";",
"r",
"=",
"new",
"int",
"[",
"this",
".",
"nWords",
"+",
"pow5",
".",
"size",
"(",
")",
"+",
"extraSize",
"]",
";",
"mult",
"(",
"this",
".",
"data",
",",
"this",
".",
"nWords",
",",
"pow5",
".",
"data",
",",
"pow5",
".",
"nWords",
",",
"r",
")",
";",
"res",
"=",
"new",
"FDBigInteger",
"(",
"r",
",",
"this",
".",
"offset",
"+",
"pow5",
".",
"offset",
")",
";",
"}",
"}",
"return",
"res",
".",
"leftShift",
"(",
"p2",
")",
";",
"}"
] | /*@
@ requires this.value() == 0 || p5 == 0 && p2 == 0;
@ assignable \nothing;
@ ensures \result == this;
@
@ also
@
@ requires this.value() > 0 && (p5 > 0 && p2 >= 0 || p5 == 0 && p2 > 0 && this.isImmutable);
@ assignable \nothing;
@ ensures \result.value() == \old(this.value() * pow52(p5, p2));
@
@ also
@
@ requires this.value() > 0 && p5 == 0 && p2 > 0 && !this.isImmutable;
@ assignable this.nWords, this.data, this.data[*];
@ ensures \result == this;
@ ensures \result.value() == \old(this.value() * pow52(p5, p2));
@ | [
"/",
"*"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/misc/FDBigInteger.java#L708-L728 |
lightblue-platform/lightblue-migrator | migrator/src/main/java/com/redhat/lightblue/migrator/Controller.java | Controller.createControllers | public void createControllers(MigrationConfiguration[] configurations) throws Exception {
"""
Creates controller threads for migrators and consistency checkers based
on the configuration loaded from the db.
For each configuration item, a migrator controller thread is created and
started.
Once created, each thread manages its own lifecycle. If the corresponding
configuration is removed, thread terminates, or it is modified, thread
behaves accordingly.
"""
for (MigrationConfiguration cfg : configurations) {
MigrationProcess process = migrationMap.get(cfg.get_id());
if (process == null) {
LOGGER.debug("Creating a controller thread for configuration {}: {}", cfg.get_id(), cfg.getConfigurationName());
MigratorController c = new MigratorController(this, cfg);
if (c instanceof MonitoredThread) {
((MonitoredThread) c).registerThreadMonitor(threadMonitor);
}
AbstractController ccc = getConsistencyCheckerController(cfg);;
if (ccc instanceof MonitoredThread) {
((MonitoredThread) ccc).registerThreadMonitor(threadMonitor);
}
migrationMap.put(cfg.get_id(), new MigrationProcess(cfg, c, ccc));
c.start();
if (ccc != null) {
ccc.start();
}
} else {
healthcheck(cfg);
}
}
} | java | public void createControllers(MigrationConfiguration[] configurations) throws Exception {
for (MigrationConfiguration cfg : configurations) {
MigrationProcess process = migrationMap.get(cfg.get_id());
if (process == null) {
LOGGER.debug("Creating a controller thread for configuration {}: {}", cfg.get_id(), cfg.getConfigurationName());
MigratorController c = new MigratorController(this, cfg);
if (c instanceof MonitoredThread) {
((MonitoredThread) c).registerThreadMonitor(threadMonitor);
}
AbstractController ccc = getConsistencyCheckerController(cfg);;
if (ccc instanceof MonitoredThread) {
((MonitoredThread) ccc).registerThreadMonitor(threadMonitor);
}
migrationMap.put(cfg.get_id(), new MigrationProcess(cfg, c, ccc));
c.start();
if (ccc != null) {
ccc.start();
}
} else {
healthcheck(cfg);
}
}
} | [
"public",
"void",
"createControllers",
"(",
"MigrationConfiguration",
"[",
"]",
"configurations",
")",
"throws",
"Exception",
"{",
"for",
"(",
"MigrationConfiguration",
"cfg",
":",
"configurations",
")",
"{",
"MigrationProcess",
"process",
"=",
"migrationMap",
".",
"get",
"(",
"cfg",
".",
"get_id",
"(",
")",
")",
";",
"if",
"(",
"process",
"==",
"null",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Creating a controller thread for configuration {}: {}\"",
",",
"cfg",
".",
"get_id",
"(",
")",
",",
"cfg",
".",
"getConfigurationName",
"(",
")",
")",
";",
"MigratorController",
"c",
"=",
"new",
"MigratorController",
"(",
"this",
",",
"cfg",
")",
";",
"if",
"(",
"c",
"instanceof",
"MonitoredThread",
")",
"{",
"(",
"(",
"MonitoredThread",
")",
"c",
")",
".",
"registerThreadMonitor",
"(",
"threadMonitor",
")",
";",
"}",
"AbstractController",
"ccc",
"=",
"getConsistencyCheckerController",
"(",
"cfg",
")",
";",
";",
"if",
"(",
"ccc",
"instanceof",
"MonitoredThread",
")",
"{",
"(",
"(",
"MonitoredThread",
")",
"ccc",
")",
".",
"registerThreadMonitor",
"(",
"threadMonitor",
")",
";",
"}",
"migrationMap",
".",
"put",
"(",
"cfg",
".",
"get_id",
"(",
")",
",",
"new",
"MigrationProcess",
"(",
"cfg",
",",
"c",
",",
"ccc",
")",
")",
";",
"c",
".",
"start",
"(",
")",
";",
"if",
"(",
"ccc",
"!=",
"null",
")",
"{",
"ccc",
".",
"start",
"(",
")",
";",
"}",
"}",
"else",
"{",
"healthcheck",
"(",
"cfg",
")",
";",
"}",
"}",
"}"
] | Creates controller threads for migrators and consistency checkers based
on the configuration loaded from the db.
For each configuration item, a migrator controller thread is created and
started.
Once created, each thread manages its own lifecycle. If the corresponding
configuration is removed, thread terminates, or it is modified, thread
behaves accordingly. | [
"Creates",
"controller",
"threads",
"for",
"migrators",
"and",
"consistency",
"checkers",
"based",
"on",
"the",
"configuration",
"loaded",
"from",
"the",
"db",
"."
] | train | https://github.com/lightblue-platform/lightblue-migrator/blob/ec20748557b40d1f7851e1816d1b76dae48d2027/migrator/src/main/java/com/redhat/lightblue/migrator/Controller.java#L154-L176 |
ThreeTen/threetenbp | src/main/java/org/threeten/bp/ZonedDateTime.java | ZonedDateTime.ofInstant | public static ZonedDateTime ofInstant(Instant instant, ZoneId zone) {
"""
Obtains an instance of {@code ZonedDateTime} from an {@code Instant}.
<p>
This creates a zoned date-time with the same instant as that specified.
Calling {@link #toInstant()} will return an instant equal to the one used here.
<p>
Converting an instant to a zoned date-time is simple as there is only one valid
offset for each instant.
@param instant the instant to create the date-time from, not null
@param zone the time-zone, not null
@return the zoned date-time, not null
@throws DateTimeException if the result exceeds the supported range
"""
Jdk8Methods.requireNonNull(instant, "instant");
Jdk8Methods.requireNonNull(zone, "zone");
return create(instant.getEpochSecond(), instant.getNano(), zone);
} | java | public static ZonedDateTime ofInstant(Instant instant, ZoneId zone) {
Jdk8Methods.requireNonNull(instant, "instant");
Jdk8Methods.requireNonNull(zone, "zone");
return create(instant.getEpochSecond(), instant.getNano(), zone);
} | [
"public",
"static",
"ZonedDateTime",
"ofInstant",
"(",
"Instant",
"instant",
",",
"ZoneId",
"zone",
")",
"{",
"Jdk8Methods",
".",
"requireNonNull",
"(",
"instant",
",",
"\"instant\"",
")",
";",
"Jdk8Methods",
".",
"requireNonNull",
"(",
"zone",
",",
"\"zone\"",
")",
";",
"return",
"create",
"(",
"instant",
".",
"getEpochSecond",
"(",
")",
",",
"instant",
".",
"getNano",
"(",
")",
",",
"zone",
")",
";",
"}"
] | Obtains an instance of {@code ZonedDateTime} from an {@code Instant}.
<p>
This creates a zoned date-time with the same instant as that specified.
Calling {@link #toInstant()} will return an instant equal to the one used here.
<p>
Converting an instant to a zoned date-time is simple as there is only one valid
offset for each instant.
@param instant the instant to create the date-time from, not null
@param zone the time-zone, not null
@return the zoned date-time, not null
@throws DateTimeException if the result exceeds the supported range | [
"Obtains",
"an",
"instance",
"of",
"{",
"@code",
"ZonedDateTime",
"}",
"from",
"an",
"{",
"@code",
"Instant",
"}",
".",
"<p",
">",
"This",
"creates",
"a",
"zoned",
"date",
"-",
"time",
"with",
"the",
"same",
"instant",
"as",
"that",
"specified",
".",
"Calling",
"{",
"@link",
"#toInstant",
"()",
"}",
"will",
"return",
"an",
"instant",
"equal",
"to",
"the",
"one",
"used",
"here",
".",
"<p",
">",
"Converting",
"an",
"instant",
"to",
"a",
"zoned",
"date",
"-",
"time",
"is",
"simple",
"as",
"there",
"is",
"only",
"one",
"valid",
"offset",
"for",
"each",
"instant",
"."
] | train | https://github.com/ThreeTen/threetenbp/blob/5f05b649f89f205aabd96b2f83c36796ec616fe6/src/main/java/org/threeten/bp/ZonedDateTime.java#L375-L379 |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/Strings.java | Strings.webContextPath | public static String webContextPath(final String first, final String... more) {
"""
Creates a web context path from components. Concatenates all path components
using '/' character as delimiter and the result is then:
<ol>
<li>prefixed with '/' character</li>
<li>stripped from all multiple consecutive occurrences of '/' characters</li>
<li>stripped from trailing '/' character(s)</li>
</ol>
@param components
web context path components
@return empty string or string which starts with a "/" character but does not
end with a "/" character
"""
if (more.length == 0 && (first == null || first.isEmpty())) {
return "";
}
final StringBuilder b = new StringBuilder();
if (first != null) {
if (!first.startsWith("/")) {
b.append('/');
}
b.append(first);
}
for (final String s : more) {
if (s != null && !s.isEmpty()) {
b.append('/');
b.append(s);
}
}
final String cleanedPath = cleanPath(b.toString());
return cleanedPath.length() == 1 ? "" : cleanedPath;
} | java | public static String webContextPath(final String first, final String... more) {
if (more.length == 0 && (first == null || first.isEmpty())) {
return "";
}
final StringBuilder b = new StringBuilder();
if (first != null) {
if (!first.startsWith("/")) {
b.append('/');
}
b.append(first);
}
for (final String s : more) {
if (s != null && !s.isEmpty()) {
b.append('/');
b.append(s);
}
}
final String cleanedPath = cleanPath(b.toString());
return cleanedPath.length() == 1 ? "" : cleanedPath;
} | [
"public",
"static",
"String",
"webContextPath",
"(",
"final",
"String",
"first",
",",
"final",
"String",
"...",
"more",
")",
"{",
"if",
"(",
"more",
".",
"length",
"==",
"0",
"&&",
"(",
"first",
"==",
"null",
"||",
"first",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"final",
"StringBuilder",
"b",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"first",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"first",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"b",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"b",
".",
"append",
"(",
"first",
")",
";",
"}",
"for",
"(",
"final",
"String",
"s",
":",
"more",
")",
"{",
"if",
"(",
"s",
"!=",
"null",
"&&",
"!",
"s",
".",
"isEmpty",
"(",
")",
")",
"{",
"b",
".",
"append",
"(",
"'",
"'",
")",
";",
"b",
".",
"append",
"(",
"s",
")",
";",
"}",
"}",
"final",
"String",
"cleanedPath",
"=",
"cleanPath",
"(",
"b",
".",
"toString",
"(",
")",
")",
";",
"return",
"cleanedPath",
".",
"length",
"(",
")",
"==",
"1",
"?",
"\"\"",
":",
"cleanedPath",
";",
"}"
] | Creates a web context path from components. Concatenates all path components
using '/' character as delimiter and the result is then:
<ol>
<li>prefixed with '/' character</li>
<li>stripped from all multiple consecutive occurrences of '/' characters</li>
<li>stripped from trailing '/' character(s)</li>
</ol>
@param components
web context path components
@return empty string or string which starts with a "/" character but does not
end with a "/" character | [
"Creates",
"a",
"web",
"context",
"path",
"from",
"components",
".",
"Concatenates",
"all",
"path",
"components",
"using",
"/",
"character",
"as",
"delimiter",
"and",
"the",
"result",
"is",
"then",
":",
"<ol",
">",
"<li",
">",
"prefixed",
"with",
"/",
"character<",
"/",
"li",
">",
"<li",
">",
"stripped",
"from",
"all",
"multiple",
"consecutive",
"occurrences",
"of",
"/",
"characters<",
"/",
"li",
">",
"<li",
">",
"stripped",
"from",
"trailing",
"/",
"character",
"(",
"s",
")",
"<",
"/",
"li",
">",
"<",
"/",
"ol",
">"
] | train | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Strings.java#L98-L120 |
recommenders/rival | rival-evaluate/src/main/java/net/recommenders/rival/evaluation/metric/ranking/NDCG.java | NDCG.computeDCG | protected double computeDCG(final double rel, final int rank) {
"""
Method that computes the discounted cumulative gain of a specific item,
taking into account its ranking in a user's list and its relevance value.
@param rel the item's relevance
@param rank the item's rank in a user's list (sorted by predicted rating)
@return the dcg of the item
"""
double dcg = 0.0;
if (rel >= getRelevanceThreshold()) {
switch (type) {
default:
case EXP:
dcg = (Math.pow(2.0, rel) - 1.0) / (Math.log(rank + 1) / Math.log(2));
break;
case LIN:
dcg = rel;
if (rank > 1) {
dcg /= (Math.log(rank) / Math.log(2));
}
break;
case TREC_EVAL:
dcg = rel / (Math.log(rank + 1) / Math.log(2));
break;
}
}
return dcg;
} | java | protected double computeDCG(final double rel, final int rank) {
double dcg = 0.0;
if (rel >= getRelevanceThreshold()) {
switch (type) {
default:
case EXP:
dcg = (Math.pow(2.0, rel) - 1.0) / (Math.log(rank + 1) / Math.log(2));
break;
case LIN:
dcg = rel;
if (rank > 1) {
dcg /= (Math.log(rank) / Math.log(2));
}
break;
case TREC_EVAL:
dcg = rel / (Math.log(rank + 1) / Math.log(2));
break;
}
}
return dcg;
} | [
"protected",
"double",
"computeDCG",
"(",
"final",
"double",
"rel",
",",
"final",
"int",
"rank",
")",
"{",
"double",
"dcg",
"=",
"0.0",
";",
"if",
"(",
"rel",
">=",
"getRelevanceThreshold",
"(",
")",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"default",
":",
"case",
"EXP",
":",
"dcg",
"=",
"(",
"Math",
".",
"pow",
"(",
"2.0",
",",
"rel",
")",
"-",
"1.0",
")",
"/",
"(",
"Math",
".",
"log",
"(",
"rank",
"+",
"1",
")",
"/",
"Math",
".",
"log",
"(",
"2",
")",
")",
";",
"break",
";",
"case",
"LIN",
":",
"dcg",
"=",
"rel",
";",
"if",
"(",
"rank",
">",
"1",
")",
"{",
"dcg",
"/=",
"(",
"Math",
".",
"log",
"(",
"rank",
")",
"/",
"Math",
".",
"log",
"(",
"2",
")",
")",
";",
"}",
"break",
";",
"case",
"TREC_EVAL",
":",
"dcg",
"=",
"rel",
"/",
"(",
"Math",
".",
"log",
"(",
"rank",
"+",
"1",
")",
"/",
"Math",
".",
"log",
"(",
"2",
")",
")",
";",
"break",
";",
"}",
"}",
"return",
"dcg",
";",
"}"
] | Method that computes the discounted cumulative gain of a specific item,
taking into account its ranking in a user's list and its relevance value.
@param rel the item's relevance
@param rank the item's rank in a user's list (sorted by predicted rating)
@return the dcg of the item | [
"Method",
"that",
"computes",
"the",
"discounted",
"cumulative",
"gain",
"of",
"a",
"specific",
"item",
"taking",
"into",
"account",
"its",
"ranking",
"in",
"a",
"user",
"s",
"list",
"and",
"its",
"relevance",
"value",
"."
] | train | https://github.com/recommenders/rival/blob/6ee8223e91810ae1c6052899595af3906e0c34c6/rival-evaluate/src/main/java/net/recommenders/rival/evaluation/metric/ranking/NDCG.java#L178-L198 |
alkacon/opencms-core | src/org/opencms/xml/content/CmsXmlContent.java | CmsXmlContent.synchronizeLocaleIndependentValues | public void synchronizeLocaleIndependentValues(CmsObject cms, Collection<String> skipPaths, Locale sourceLocale) {
"""
Synchronizes the locale independent fields for the given locale.<p>
@param cms the cms context
@param skipPaths the paths to skip
@param sourceLocale the source locale
"""
if (getContentDefinition().getContentHandler().hasSynchronizedElements() && (getLocales().size() > 1)) {
for (String elementPath : getContentDefinition().getContentHandler().getSynchronizations()) {
synchronizeElement(cms, elementPath, skipPaths, sourceLocale);
}
}
} | java | public void synchronizeLocaleIndependentValues(CmsObject cms, Collection<String> skipPaths, Locale sourceLocale) {
if (getContentDefinition().getContentHandler().hasSynchronizedElements() && (getLocales().size() > 1)) {
for (String elementPath : getContentDefinition().getContentHandler().getSynchronizations()) {
synchronizeElement(cms, elementPath, skipPaths, sourceLocale);
}
}
} | [
"public",
"void",
"synchronizeLocaleIndependentValues",
"(",
"CmsObject",
"cms",
",",
"Collection",
"<",
"String",
">",
"skipPaths",
",",
"Locale",
"sourceLocale",
")",
"{",
"if",
"(",
"getContentDefinition",
"(",
")",
".",
"getContentHandler",
"(",
")",
".",
"hasSynchronizedElements",
"(",
")",
"&&",
"(",
"getLocales",
"(",
")",
".",
"size",
"(",
")",
">",
"1",
")",
")",
"{",
"for",
"(",
"String",
"elementPath",
":",
"getContentDefinition",
"(",
")",
".",
"getContentHandler",
"(",
")",
".",
"getSynchronizations",
"(",
")",
")",
"{",
"synchronizeElement",
"(",
"cms",
",",
"elementPath",
",",
"skipPaths",
",",
"sourceLocale",
")",
";",
"}",
"}",
"}"
] | Synchronizes the locale independent fields for the given locale.<p>
@param cms the cms context
@param skipPaths the paths to skip
@param sourceLocale the source locale | [
"Synchronizes",
"the",
"locale",
"independent",
"fields",
"for",
"the",
"given",
"locale",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsXmlContent.java#L771-L778 |
bugsnag/bugsnag-java | bugsnag/src/main/java/com/bugsnag/Bugsnag.java | Bugsnag.clearThreadMetaData | public static void clearThreadMetaData(String tabName, String key) {
"""
Clears a metadata key/value pair from a tab on the current thread
@param tabName the name of the tab to that the metadata is in
@param key the key of the metadata to remove
"""
THREAD_METADATA.get().clearKey(tabName, key);
} | java | public static void clearThreadMetaData(String tabName, String key) {
THREAD_METADATA.get().clearKey(tabName, key);
} | [
"public",
"static",
"void",
"clearThreadMetaData",
"(",
"String",
"tabName",
",",
"String",
"key",
")",
"{",
"THREAD_METADATA",
".",
"get",
"(",
")",
".",
"clearKey",
"(",
"tabName",
",",
"key",
")",
";",
"}"
] | Clears a metadata key/value pair from a tab on the current thread
@param tabName the name of the tab to that the metadata is in
@param key the key of the metadata to remove | [
"Clears",
"a",
"metadata",
"key",
"/",
"value",
"pair",
"from",
"a",
"tab",
"on",
"the",
"current",
"thread"
] | train | https://github.com/bugsnag/bugsnag-java/blob/11817d63949bcf2b2b6b765a1d37305cdec356f2/bugsnag/src/main/java/com/bugsnag/Bugsnag.java#L642-L644 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/RepairJob.java | RepairJob.addTree | public synchronized int addTree(InetAddress endpoint, MerkleTree tree) {
"""
Add a new received tree and return the number of remaining tree to
be received for the job to be complete.
Callers may assume exactly one addTree call will result in zero remaining endpoints.
@param endpoint address of the endpoint that sent response
@param tree sent Merkle tree or null if validation failed on endpoint
@return the number of responses waiting to receive
"""
// Wait for all request to have been performed (see #3400)
try
{
requestsSent.await();
}
catch (InterruptedException e)
{
throw new AssertionError("Interrupted while waiting for requests to be sent");
}
if (tree == null)
failed = true;
else
trees.add(new TreeResponse(endpoint, tree));
return treeRequests.completed(endpoint);
} | java | public synchronized int addTree(InetAddress endpoint, MerkleTree tree)
{
// Wait for all request to have been performed (see #3400)
try
{
requestsSent.await();
}
catch (InterruptedException e)
{
throw new AssertionError("Interrupted while waiting for requests to be sent");
}
if (tree == null)
failed = true;
else
trees.add(new TreeResponse(endpoint, tree));
return treeRequests.completed(endpoint);
} | [
"public",
"synchronized",
"int",
"addTree",
"(",
"InetAddress",
"endpoint",
",",
"MerkleTree",
"tree",
")",
"{",
"// Wait for all request to have been performed (see #3400)",
"try",
"{",
"requestsSent",
".",
"await",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"\"Interrupted while waiting for requests to be sent\"",
")",
";",
"}",
"if",
"(",
"tree",
"==",
"null",
")",
"failed",
"=",
"true",
";",
"else",
"trees",
".",
"add",
"(",
"new",
"TreeResponse",
"(",
"endpoint",
",",
"tree",
")",
")",
";",
"return",
"treeRequests",
".",
"completed",
"(",
"endpoint",
")",
";",
"}"
] | Add a new received tree and return the number of remaining tree to
be received for the job to be complete.
Callers may assume exactly one addTree call will result in zero remaining endpoints.
@param endpoint address of the endpoint that sent response
@param tree sent Merkle tree or null if validation failed on endpoint
@return the number of responses waiting to receive | [
"Add",
"a",
"new",
"received",
"tree",
"and",
"return",
"the",
"number",
"of",
"remaining",
"tree",
"to",
"be",
"received",
"for",
"the",
"job",
"to",
"be",
"complete",
"."
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/RepairJob.java#L178-L195 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/util/RequestUtil.java | RequestUtil.getIntSelector | public static int getIntSelector(SlingHttpServletRequest request, Pattern groupPattern, int defaultValue) {
"""
Retrieves a number in the selectors and returns it if present otherwise the default value.
@param request the request object with the selector info
@param groupPattern the regex to extract the value - as group '1'; e.g. 'key([\d]+)'
@param defaultValue the default number value
"""
String[] selectors = request.getRequestPathInfo().getSelectors();
for (String selector : selectors) {
Matcher matcher = groupPattern.matcher(selector);
if (matcher.matches()) {
try {
return Integer.parseInt(matcher.group(1));
} catch (NumberFormatException nfex) {
// ok, try next
}
}
}
return defaultValue;
} | java | public static int getIntSelector(SlingHttpServletRequest request, Pattern groupPattern, int defaultValue) {
String[] selectors = request.getRequestPathInfo().getSelectors();
for (String selector : selectors) {
Matcher matcher = groupPattern.matcher(selector);
if (matcher.matches()) {
try {
return Integer.parseInt(matcher.group(1));
} catch (NumberFormatException nfex) {
// ok, try next
}
}
}
return defaultValue;
} | [
"public",
"static",
"int",
"getIntSelector",
"(",
"SlingHttpServletRequest",
"request",
",",
"Pattern",
"groupPattern",
",",
"int",
"defaultValue",
")",
"{",
"String",
"[",
"]",
"selectors",
"=",
"request",
".",
"getRequestPathInfo",
"(",
")",
".",
"getSelectors",
"(",
")",
";",
"for",
"(",
"String",
"selector",
":",
"selectors",
")",
"{",
"Matcher",
"matcher",
"=",
"groupPattern",
".",
"matcher",
"(",
"selector",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"matcher",
".",
"group",
"(",
"1",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfex",
")",
"{",
"// ok, try next",
"}",
"}",
"}",
"return",
"defaultValue",
";",
"}"
] | Retrieves a number in the selectors and returns it if present otherwise the default value.
@param request the request object with the selector info
@param groupPattern the regex to extract the value - as group '1'; e.g. 'key([\d]+)'
@param defaultValue the default number value | [
"Retrieves",
"a",
"number",
"in",
"the",
"selectors",
"and",
"returns",
"it",
"if",
"present",
"otherwise",
"the",
"default",
"value",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/util/RequestUtil.java#L108-L121 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/transform/pyramid/impl/ImplPyramidOps.java | ImplPyramidOps.scaleDown2 | public static void scaleDown2(GrayF32 input , GrayF32 output ) {
"""
Scales down the input by a factor of 2. Every other pixel along both axises is skipped.
"""
output.reshape(input.width / 2, input.height / 2);
for (int y = 0; y < output.height; y++) {
int indexInput = 2*y*input.stride;
int indexOutput = y*output.stride;
for (int x = 0; x < output.width; x++,indexInput+=2) {
output.data[indexOutput++] = input.data[indexInput];
}
}
} | java | public static void scaleDown2(GrayF32 input , GrayF32 output ) {
output.reshape(input.width / 2, input.height / 2);
for (int y = 0; y < output.height; y++) {
int indexInput = 2*y*input.stride;
int indexOutput = y*output.stride;
for (int x = 0; x < output.width; x++,indexInput+=2) {
output.data[indexOutput++] = input.data[indexInput];
}
}
} | [
"public",
"static",
"void",
"scaleDown2",
"(",
"GrayF32",
"input",
",",
"GrayF32",
"output",
")",
"{",
"output",
".",
"reshape",
"(",
"input",
".",
"width",
"/",
"2",
",",
"input",
".",
"height",
"/",
"2",
")",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"output",
".",
"height",
";",
"y",
"++",
")",
"{",
"int",
"indexInput",
"=",
"2",
"*",
"y",
"*",
"input",
".",
"stride",
";",
"int",
"indexOutput",
"=",
"y",
"*",
"output",
".",
"stride",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"output",
".",
"width",
";",
"x",
"++",
",",
"indexInput",
"+=",
"2",
")",
"{",
"output",
".",
"data",
"[",
"indexOutput",
"++",
"]",
"=",
"input",
".",
"data",
"[",
"indexInput",
"]",
";",
"}",
"}",
"}"
] | Scales down the input by a factor of 2. Every other pixel along both axises is skipped. | [
"Scales",
"down",
"the",
"input",
"by",
"a",
"factor",
"of",
"2",
".",
"Every",
"other",
"pixel",
"along",
"both",
"axises",
"is",
"skipped",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/transform/pyramid/impl/ImplPyramidOps.java#L63-L74 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java | FSNamesystem.addToInvalidates | void addToInvalidates(Block b, DatanodeInfo n, boolean ackRequired) {
"""
Adds block to list of blocks which will be invalidated on
specified datanode and log the move
@param b block
@param n datanode
"""
addToInvalidatesNoLog(b, n, ackRequired);
if (isInitialized && !isInSafeModeInternal()) {
// do not log in startup phase
NameNode.stateChangeLog.info("BLOCK* NameSystem.addToInvalidates: "
+ b.getBlockName() + " is added to invalidSet of " + n.getName());
}
} | java | void addToInvalidates(Block b, DatanodeInfo n, boolean ackRequired) {
addToInvalidatesNoLog(b, n, ackRequired);
if (isInitialized && !isInSafeModeInternal()) {
// do not log in startup phase
NameNode.stateChangeLog.info("BLOCK* NameSystem.addToInvalidates: "
+ b.getBlockName() + " is added to invalidSet of " + n.getName());
}
} | [
"void",
"addToInvalidates",
"(",
"Block",
"b",
",",
"DatanodeInfo",
"n",
",",
"boolean",
"ackRequired",
")",
"{",
"addToInvalidatesNoLog",
"(",
"b",
",",
"n",
",",
"ackRequired",
")",
";",
"if",
"(",
"isInitialized",
"&&",
"!",
"isInSafeModeInternal",
"(",
")",
")",
"{",
"// do not log in startup phase",
"NameNode",
".",
"stateChangeLog",
".",
"info",
"(",
"\"BLOCK* NameSystem.addToInvalidates: \"",
"+",
"b",
".",
"getBlockName",
"(",
")",
"+",
"\" is added to invalidSet of \"",
"+",
"n",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Adds block to list of blocks which will be invalidated on
specified datanode and log the move
@param b block
@param n datanode | [
"Adds",
"block",
"to",
"list",
"of",
"blocks",
"which",
"will",
"be",
"invalidated",
"on",
"specified",
"datanode",
"and",
"log",
"the",
"move"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java#L3400-L3407 |
google/closure-templates | java/src/com/google/template/soy/jssrc/dsl/Expression.java | Expression.fromExpr | public static Expression fromExpr(JsExpr expr, Iterable<GoogRequire> requires) {
"""
Creates a new code chunk from the given expression. The expression's precedence is preserved.
"""
return Leaf.create(expr, /* isCheap= */ false, requires);
} | java | public static Expression fromExpr(JsExpr expr, Iterable<GoogRequire> requires) {
return Leaf.create(expr, /* isCheap= */ false, requires);
} | [
"public",
"static",
"Expression",
"fromExpr",
"(",
"JsExpr",
"expr",
",",
"Iterable",
"<",
"GoogRequire",
">",
"requires",
")",
"{",
"return",
"Leaf",
".",
"create",
"(",
"expr",
",",
"/* isCheap= */",
"false",
",",
"requires",
")",
";",
"}"
] | Creates a new code chunk from the given expression. The expression's precedence is preserved. | [
"Creates",
"a",
"new",
"code",
"chunk",
"from",
"the",
"given",
"expression",
".",
"The",
"expression",
"s",
"precedence",
"is",
"preserved",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jssrc/dsl/Expression.java#L73-L75 |
killbilling/recurly-java-library | src/main/java/com/ning/billing/recurly/RecurlyClient.java | RecurlyClient.deleteShippingAddress | public void deleteShippingAddress(final String accountCode, final long shippingAddressId) {
"""
Delete an existing shipping address
<p>
@param accountCode recurly account id
@param shippingAddressId the shipping address id to delete
"""
doDELETE(Accounts.ACCOUNTS_RESOURCE + "/" + accountCode + ShippingAddresses.SHIPPING_ADDRESSES_RESOURCE + "/" + shippingAddressId);
} | java | public void deleteShippingAddress(final String accountCode, final long shippingAddressId) {
doDELETE(Accounts.ACCOUNTS_RESOURCE + "/" + accountCode + ShippingAddresses.SHIPPING_ADDRESSES_RESOURCE + "/" + shippingAddressId);
} | [
"public",
"void",
"deleteShippingAddress",
"(",
"final",
"String",
"accountCode",
",",
"final",
"long",
"shippingAddressId",
")",
"{",
"doDELETE",
"(",
"Accounts",
".",
"ACCOUNTS_RESOURCE",
"+",
"\"/\"",
"+",
"accountCode",
"+",
"ShippingAddresses",
".",
"SHIPPING_ADDRESSES_RESOURCE",
"+",
"\"/\"",
"+",
"shippingAddressId",
")",
";",
"}"
] | Delete an existing shipping address
<p>
@param accountCode recurly account id
@param shippingAddressId the shipping address id to delete | [
"Delete",
"an",
"existing",
"shipping",
"address",
"<p",
">"
] | train | https://github.com/killbilling/recurly-java-library/blob/5e05eedd91885a51e1aa8293bd41139d082cf7f4/src/main/java/com/ning/billing/recurly/RecurlyClient.java#L1231-L1233 |
lets-blade/blade | src/main/java/com/blade/kit/UUID.java | UUID.captchaChar | public static String captchaChar(int length, boolean caseSensitivity) {
"""
返回指定长度随机数字+字母(大小写敏感)组成的字符串
@param length 指定长度
@param caseSensitivity 是否区分大小写
@return 随机字符串
"""
StringBuilder sb = new StringBuilder();
Random rand = new Random();// 随机用以下三个随机生成器
Random randdata = new Random();
int data = 0;
for (int i = 0; i < length; i++) {
int index = rand.nextInt(caseSensitivity ? 3 : 2);
// 目的是随机选择生成数字,大小写字母
switch (index) {
case 0:
data = randdata.nextInt(10);// 仅仅会生成0~9, 0~9的ASCII为48~57
sb.append(data);
break;
case 1:
data = randdata.nextInt(26) + 97;// 保证只会产生ASCII为97~122(a-z)之间的整数,
sb.append((char) data);
break;
case 2: // caseSensitivity为true的时候, 才会有大写字母
data = randdata.nextInt(26) + 65;// 保证只会产生ASCII为65~90(A~Z)之间的整数
sb.append((char) data);
break;
default:
break;
}
}
return sb.toString();
} | java | public static String captchaChar(int length, boolean caseSensitivity) {
StringBuilder sb = new StringBuilder();
Random rand = new Random();// 随机用以下三个随机生成器
Random randdata = new Random();
int data = 0;
for (int i = 0; i < length; i++) {
int index = rand.nextInt(caseSensitivity ? 3 : 2);
// 目的是随机选择生成数字,大小写字母
switch (index) {
case 0:
data = randdata.nextInt(10);// 仅仅会生成0~9, 0~9的ASCII为48~57
sb.append(data);
break;
case 1:
data = randdata.nextInt(26) + 97;// 保证只会产生ASCII为97~122(a-z)之间的整数,
sb.append((char) data);
break;
case 2: // caseSensitivity为true的时候, 才会有大写字母
data = randdata.nextInt(26) + 65;// 保证只会产生ASCII为65~90(A~Z)之间的整数
sb.append((char) data);
break;
default:
break;
}
}
return sb.toString();
} | [
"public",
"static",
"String",
"captchaChar",
"(",
"int",
"length",
",",
"boolean",
"caseSensitivity",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Random",
"rand",
"=",
"new",
"Random",
"(",
")",
";",
"// 随机用以下三个随机生成器",
"Random",
"randdata",
"=",
"new",
"Random",
"(",
")",
";",
"int",
"data",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"int",
"index",
"=",
"rand",
".",
"nextInt",
"(",
"caseSensitivity",
"?",
"3",
":",
"2",
")",
";",
"// 目的是随机选择生成数字,大小写字母",
"switch",
"(",
"index",
")",
"{",
"case",
"0",
":",
"data",
"=",
"randdata",
".",
"nextInt",
"(",
"10",
")",
";",
"// 仅仅会生成0~9, 0~9的ASCII为48~57",
"sb",
".",
"append",
"(",
"data",
")",
";",
"break",
";",
"case",
"1",
":",
"data",
"=",
"randdata",
".",
"nextInt",
"(",
"26",
")",
"+",
"97",
";",
"// 保证只会产生ASCII为97~122(a-z)之间的整数,",
"sb",
".",
"append",
"(",
"(",
"char",
")",
"data",
")",
";",
"break",
";",
"case",
"2",
":",
"// caseSensitivity为true的时候, 才会有大写字母",
"data",
"=",
"randdata",
".",
"nextInt",
"(",
"26",
")",
"+",
"65",
";",
"// 保证只会产生ASCII为65~90(A~Z)之间的整数",
"sb",
".",
"append",
"(",
"(",
"char",
")",
"data",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | 返回指定长度随机数字+字母(大小写敏感)组成的字符串
@param length 指定长度
@param caseSensitivity 是否区分大小写
@return 随机字符串 | [
"返回指定长度随机数字",
"+",
"字母",
"(",
"大小写敏感",
")",
"组成的字符串"
] | train | https://github.com/lets-blade/blade/blob/60624ee528be12122c49a9ad1713e336b959e59a/src/main/java/com/blade/kit/UUID.java#L216-L242 |
orbisgis/h2gis | postgis-jts/src/main/java/org/h2gis/postgis_jts/JtsBinaryParser.java | JtsBinaryParser.parsePoint | private Point parsePoint(ValueGetter data, boolean haveZ, boolean haveM) {
"""
Parse the given {@link org.postgis.binary.ValueGetter} into a JTS {@link org.locationtech.jts.geom.Point}.
@param data {@link org.postgis.binary.ValueGetter} to parse.
@param haveZ True if the {@link org.locationtech.jts.geom.Point} has a Z component.
@param haveM True if the {@link org.locationtech.jts.geom.Point} has a M component.
@return The parsed {@link org.locationtech.jts.geom.Point}.
"""
double X = data.getDouble();
double Y = data.getDouble();
Point result;
if (haveZ) {
double Z = data.getDouble();
result = JtsGeometry.geofac.createPoint(new Coordinate(X, Y, Z));
} else {
result = JtsGeometry.geofac.createPoint(new Coordinate(X, Y));
}
if (haveM) {
data.getDouble();
}
return result;
} | java | private Point parsePoint(ValueGetter data, boolean haveZ, boolean haveM) {
double X = data.getDouble();
double Y = data.getDouble();
Point result;
if (haveZ) {
double Z = data.getDouble();
result = JtsGeometry.geofac.createPoint(new Coordinate(X, Y, Z));
} else {
result = JtsGeometry.geofac.createPoint(new Coordinate(X, Y));
}
if (haveM) {
data.getDouble();
}
return result;
} | [
"private",
"Point",
"parsePoint",
"(",
"ValueGetter",
"data",
",",
"boolean",
"haveZ",
",",
"boolean",
"haveM",
")",
"{",
"double",
"X",
"=",
"data",
".",
"getDouble",
"(",
")",
";",
"double",
"Y",
"=",
"data",
".",
"getDouble",
"(",
")",
";",
"Point",
"result",
";",
"if",
"(",
"haveZ",
")",
"{",
"double",
"Z",
"=",
"data",
".",
"getDouble",
"(",
")",
";",
"result",
"=",
"JtsGeometry",
".",
"geofac",
".",
"createPoint",
"(",
"new",
"Coordinate",
"(",
"X",
",",
"Y",
",",
"Z",
")",
")",
";",
"}",
"else",
"{",
"result",
"=",
"JtsGeometry",
".",
"geofac",
".",
"createPoint",
"(",
"new",
"Coordinate",
"(",
"X",
",",
"Y",
")",
")",
";",
"}",
"if",
"(",
"haveM",
")",
"{",
"data",
".",
"getDouble",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Parse the given {@link org.postgis.binary.ValueGetter} into a JTS {@link org.locationtech.jts.geom.Point}.
@param data {@link org.postgis.binary.ValueGetter} to parse.
@param haveZ True if the {@link org.locationtech.jts.geom.Point} has a Z component.
@param haveM True if the {@link org.locationtech.jts.geom.Point} has a M component.
@return The parsed {@link org.locationtech.jts.geom.Point}. | [
"Parse",
"the",
"given",
"{",
"@link",
"org",
".",
"postgis",
".",
"binary",
".",
"ValueGetter",
"}",
"into",
"a",
"JTS",
"{",
"@link",
"org",
".",
"locationtech",
".",
"jts",
".",
"geom",
".",
"Point",
"}",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/postgis-jts/src/main/java/org/h2gis/postgis_jts/JtsBinaryParser.java#L167-L183 |
gsi-upm/Shanks | shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/movement/Location.java | Location.isNearTo | public boolean isNearTo(Location location, double distance) {
"""
Compare two locations and return if the locations are near or not
@param location Location to compare with
@param distance The distance between two locations
@return true is the real distance is lower or equals than the distance parameter
"""
if (this.is2DLocation() && location.is2DLocation()) {
return this.isNearTo(location.getLocation2D(), distance);
} else if (this.is3DLocation() && location.is3DLocation()) {
return this.isNearTo(location.getLocation3D(), distance);
} else {
return false;
}
} | java | public boolean isNearTo(Location location, double distance) {
if (this.is2DLocation() && location.is2DLocation()) {
return this.isNearTo(location.getLocation2D(), distance);
} else if (this.is3DLocation() && location.is3DLocation()) {
return this.isNearTo(location.getLocation3D(), distance);
} else {
return false;
}
} | [
"public",
"boolean",
"isNearTo",
"(",
"Location",
"location",
",",
"double",
"distance",
")",
"{",
"if",
"(",
"this",
".",
"is2DLocation",
"(",
")",
"&&",
"location",
".",
"is2DLocation",
"(",
")",
")",
"{",
"return",
"this",
".",
"isNearTo",
"(",
"location",
".",
"getLocation2D",
"(",
")",
",",
"distance",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"is3DLocation",
"(",
")",
"&&",
"location",
".",
"is3DLocation",
"(",
")",
")",
"{",
"return",
"this",
".",
"isNearTo",
"(",
"location",
".",
"getLocation3D",
"(",
")",
",",
"distance",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Compare two locations and return if the locations are near or not
@param location Location to compare with
@param distance The distance between two locations
@return true is the real distance is lower or equals than the distance parameter | [
"Compare",
"two",
"locations",
"and",
"return",
"if",
"the",
"locations",
"are",
"near",
"or",
"not"
] | train | https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/movement/Location.java#L136-L144 |
aboutsip/pkts | pkts-sip/src/main/java/io/pkts/packet/sip/impl/SipMessageBuilder.java | SipMessageBuilder.addTrackedHeader | private short addTrackedHeader(final short index, final SipHeader header) {
"""
There are several headers that we want to know their position
and in that case we use this method to add them since we want
to either add them to a particular position or we want to
remember which index we added them to.
"""
if (index != -1) {
headers.set(index, header.ensure());
return index;
}
return addHeader(header.ensure());
} | java | private short addTrackedHeader(final short index, final SipHeader header) {
if (index != -1) {
headers.set(index, header.ensure());
return index;
}
return addHeader(header.ensure());
} | [
"private",
"short",
"addTrackedHeader",
"(",
"final",
"short",
"index",
",",
"final",
"SipHeader",
"header",
")",
"{",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"headers",
".",
"set",
"(",
"index",
",",
"header",
".",
"ensure",
"(",
")",
")",
";",
"return",
"index",
";",
"}",
"return",
"addHeader",
"(",
"header",
".",
"ensure",
"(",
")",
")",
";",
"}"
] | There are several headers that we want to know their position
and in that case we use this method to add them since we want
to either add them to a particular position or we want to
remember which index we added them to. | [
"There",
"are",
"several",
"headers",
"that",
"we",
"want",
"to",
"know",
"their",
"position",
"and",
"in",
"that",
"case",
"we",
"use",
"this",
"method",
"to",
"add",
"them",
"since",
"we",
"want",
"to",
"either",
"add",
"them",
"to",
"a",
"particular",
"position",
"or",
"we",
"want",
"to",
"remember",
"which",
"index",
"we",
"added",
"them",
"to",
"."
] | train | https://github.com/aboutsip/pkts/blob/0f06bb0dac76c812187829f580a8d476ca99a1a1/pkts-sip/src/main/java/io/pkts/packet/sip/impl/SipMessageBuilder.java#L167-L173 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java | QueryReferenceBroker.getReferencedObjectIdentity | private Identity getReferencedObjectIdentity(Object obj, ObjectReferenceDescriptor rds, ClassDescriptor cld) {
"""
retrieves an Object reference's Identity.
<br>
Null is returned if all foreign keys are null
"""
Object[] fkValues = rds.getForeignKeyValues(obj, cld);
FieldDescriptor[] fkFieldDescriptors = rds.getForeignKeyFieldDescriptors(cld);
boolean hasNullifiedFKValue = hasNullifiedFK(fkFieldDescriptors, fkValues);
/*
BRJ: if all fk values are null there's no referenced object
arminw: Supposed the given object has nullified FK values but the referenced
object still exists. This could happend after serialization of the main object. In
this case all anonymous field (AK) information is lost, because AnonymousPersistentField class
use the object identity to cache the AK values. But we can build Identity anyway from the reference
*/
if (hasNullifiedFKValue)
{
if(BrokerHelper.hasAnonymousKeyReference(cld, rds))
{
Object referencedObject = rds.getPersistentField().get(obj);
if(referencedObject != null)
{
return pb.serviceIdentity().buildIdentity(referencedObject);
}
}
}
else
{
// ensure that top-level extents are used for Identities
return pb.serviceIdentity().buildIdentity(rds.getItemClass(), pb.getTopLevelClass(rds.getItemClass()), fkValues);
}
return null;
} | java | private Identity getReferencedObjectIdentity(Object obj, ObjectReferenceDescriptor rds, ClassDescriptor cld)
{
Object[] fkValues = rds.getForeignKeyValues(obj, cld);
FieldDescriptor[] fkFieldDescriptors = rds.getForeignKeyFieldDescriptors(cld);
boolean hasNullifiedFKValue = hasNullifiedFK(fkFieldDescriptors, fkValues);
/*
BRJ: if all fk values are null there's no referenced object
arminw: Supposed the given object has nullified FK values but the referenced
object still exists. This could happend after serialization of the main object. In
this case all anonymous field (AK) information is lost, because AnonymousPersistentField class
use the object identity to cache the AK values. But we can build Identity anyway from the reference
*/
if (hasNullifiedFKValue)
{
if(BrokerHelper.hasAnonymousKeyReference(cld, rds))
{
Object referencedObject = rds.getPersistentField().get(obj);
if(referencedObject != null)
{
return pb.serviceIdentity().buildIdentity(referencedObject);
}
}
}
else
{
// ensure that top-level extents are used for Identities
return pb.serviceIdentity().buildIdentity(rds.getItemClass(), pb.getTopLevelClass(rds.getItemClass()), fkValues);
}
return null;
} | [
"private",
"Identity",
"getReferencedObjectIdentity",
"(",
"Object",
"obj",
",",
"ObjectReferenceDescriptor",
"rds",
",",
"ClassDescriptor",
"cld",
")",
"{",
"Object",
"[",
"]",
"fkValues",
"=",
"rds",
".",
"getForeignKeyValues",
"(",
"obj",
",",
"cld",
")",
";",
"FieldDescriptor",
"[",
"]",
"fkFieldDescriptors",
"=",
"rds",
".",
"getForeignKeyFieldDescriptors",
"(",
"cld",
")",
";",
"boolean",
"hasNullifiedFKValue",
"=",
"hasNullifiedFK",
"(",
"fkFieldDescriptors",
",",
"fkValues",
")",
";",
"/*\r\n BRJ: if all fk values are null there's no referenced object\r\n\r\n arminw: Supposed the given object has nullified FK values but the referenced\r\n object still exists. This could happend after serialization of the main object. In\r\n this case all anonymous field (AK) information is lost, because AnonymousPersistentField class\r\n use the object identity to cache the AK values. But we can build Identity anyway from the reference\r\n */",
"if",
"(",
"hasNullifiedFKValue",
")",
"{",
"if",
"(",
"BrokerHelper",
".",
"hasAnonymousKeyReference",
"(",
"cld",
",",
"rds",
")",
")",
"{",
"Object",
"referencedObject",
"=",
"rds",
".",
"getPersistentField",
"(",
")",
".",
"get",
"(",
"obj",
")",
";",
"if",
"(",
"referencedObject",
"!=",
"null",
")",
"{",
"return",
"pb",
".",
"serviceIdentity",
"(",
")",
".",
"buildIdentity",
"(",
"referencedObject",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// ensure that top-level extents are used for Identities\r",
"return",
"pb",
".",
"serviceIdentity",
"(",
")",
".",
"buildIdentity",
"(",
"rds",
".",
"getItemClass",
"(",
")",
",",
"pb",
".",
"getTopLevelClass",
"(",
"rds",
".",
"getItemClass",
"(",
")",
")",
",",
"fkValues",
")",
";",
"}",
"return",
"null",
";",
"}"
] | retrieves an Object reference's Identity.
<br>
Null is returned if all foreign keys are null | [
"retrieves",
"an",
"Object",
"reference",
"s",
"Identity",
".",
"<br",
">",
"Null",
"is",
"returned",
"if",
"all",
"foreign",
"keys",
"are",
"null"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java#L596-L626 |
OpenLiberty/open-liberty | dev/com.ibm.ws.repository/src/com/ibm/ws/repository/transport/client/DirectoryClient.java | DirectoryClient.getSubsystemManifest | protected Manifest getSubsystemManifest(String assetId) throws IOException {
"""
Gets the manifest file from an ESA
@param assetId
@return
@throws IOException
"""
ZipFile zip = null;
try {
zip = DirectoryUtils.createZipFile(new File(_root, assetId));
Enumeration<? extends ZipEntry> zipEntries = zip.entries();
ZipEntry subsystemEntry = null;
while (zipEntries.hasMoreElements()) {
ZipEntry nextEntry = zipEntries.nextElement();
if ("OSGI-INF/SUBSYSTEM.MF".equalsIgnoreCase(nextEntry.getName())) {
subsystemEntry = nextEntry;
break;
}
}
if (subsystemEntry == null) {
return null;
} else {
return ManifestProcessor.parseManifest(zip.getInputStream(subsystemEntry));
}
} finally {
if (zip != null) {
zip.close();
}
}
} | java | protected Manifest getSubsystemManifest(String assetId) throws IOException {
ZipFile zip = null;
try {
zip = DirectoryUtils.createZipFile(new File(_root, assetId));
Enumeration<? extends ZipEntry> zipEntries = zip.entries();
ZipEntry subsystemEntry = null;
while (zipEntries.hasMoreElements()) {
ZipEntry nextEntry = zipEntries.nextElement();
if ("OSGI-INF/SUBSYSTEM.MF".equalsIgnoreCase(nextEntry.getName())) {
subsystemEntry = nextEntry;
break;
}
}
if (subsystemEntry == null) {
return null;
} else {
return ManifestProcessor.parseManifest(zip.getInputStream(subsystemEntry));
}
} finally {
if (zip != null) {
zip.close();
}
}
} | [
"protected",
"Manifest",
"getSubsystemManifest",
"(",
"String",
"assetId",
")",
"throws",
"IOException",
"{",
"ZipFile",
"zip",
"=",
"null",
";",
"try",
"{",
"zip",
"=",
"DirectoryUtils",
".",
"createZipFile",
"(",
"new",
"File",
"(",
"_root",
",",
"assetId",
")",
")",
";",
"Enumeration",
"<",
"?",
"extends",
"ZipEntry",
">",
"zipEntries",
"=",
"zip",
".",
"entries",
"(",
")",
";",
"ZipEntry",
"subsystemEntry",
"=",
"null",
";",
"while",
"(",
"zipEntries",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"ZipEntry",
"nextEntry",
"=",
"zipEntries",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"\"OSGI-INF/SUBSYSTEM.MF\"",
".",
"equalsIgnoreCase",
"(",
"nextEntry",
".",
"getName",
"(",
")",
")",
")",
"{",
"subsystemEntry",
"=",
"nextEntry",
";",
"break",
";",
"}",
"}",
"if",
"(",
"subsystemEntry",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"ManifestProcessor",
".",
"parseManifest",
"(",
"zip",
".",
"getInputStream",
"(",
"subsystemEntry",
")",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"zip",
"!=",
"null",
")",
"{",
"zip",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Gets the manifest file from an ESA
@param assetId
@return
@throws IOException | [
"Gets",
"the",
"manifest",
"file",
"from",
"an",
"ESA"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.repository/src/com/ibm/ws/repository/transport/client/DirectoryClient.java#L236-L259 |
intive-FDV/DynamicJasper | src/main/java/ar/com/fdvs/dj/domain/chart/builder/DJTimeSeriesChartBuilder.java | DJTimeSeriesChartBuilder.addSerie | public DJTimeSeriesChartBuilder addSerie(AbstractColumn column, String label) {
"""
Adds the specified serie column to the dataset with custom label.
@param column the serie column
@param label column the custom label
"""
getDataset().addSerie(column, label);
return this;
} | java | public DJTimeSeriesChartBuilder addSerie(AbstractColumn column, String label) {
getDataset().addSerie(column, label);
return this;
} | [
"public",
"DJTimeSeriesChartBuilder",
"addSerie",
"(",
"AbstractColumn",
"column",
",",
"String",
"label",
")",
"{",
"getDataset",
"(",
")",
".",
"addSerie",
"(",
"column",
",",
"label",
")",
";",
"return",
"this",
";",
"}"
] | Adds the specified serie column to the dataset with custom label.
@param column the serie column
@param label column the custom label | [
"Adds",
"the",
"specified",
"serie",
"column",
"to",
"the",
"dataset",
"with",
"custom",
"label",
"."
] | train | https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/chart/builder/DJTimeSeriesChartBuilder.java#L374-L377 |
aws/aws-sdk-java | aws-java-sdk-ssm/src/main/java/com/amazonaws/services/simplesystemsmanagement/model/ListInventoryEntriesResult.java | ListInventoryEntriesResult.withEntries | public ListInventoryEntriesResult withEntries(java.util.Map<String, String>... entries) {
"""
<p>
A list of inventory items on the instance(s).
</p>
<p>
<b>NOTE:</b> This method appends the values to the existing list (if any). Use
{@link #setEntries(java.util.Collection)} or {@link #withEntries(java.util.Collection)} if you want to override
the existing values.
</p>
@param entries
A list of inventory items on the instance(s).
@return Returns a reference to this object so that method calls can be chained together.
"""
if (this.entries == null) {
setEntries(new com.amazonaws.internal.SdkInternalList<java.util.Map<String, String>>(entries.length));
}
for (java.util.Map<String, String> ele : entries) {
this.entries.add(ele);
}
return this;
} | java | public ListInventoryEntriesResult withEntries(java.util.Map<String, String>... entries) {
if (this.entries == null) {
setEntries(new com.amazonaws.internal.SdkInternalList<java.util.Map<String, String>>(entries.length));
}
for (java.util.Map<String, String> ele : entries) {
this.entries.add(ele);
}
return this;
} | [
"public",
"ListInventoryEntriesResult",
"withEntries",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"...",
"entries",
")",
"{",
"if",
"(",
"this",
".",
"entries",
"==",
"null",
")",
"{",
"setEntries",
"(",
"new",
"com",
".",
"amazonaws",
".",
"internal",
".",
"SdkInternalList",
"<",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
">",
"(",
"entries",
".",
"length",
")",
")",
";",
"}",
"for",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"ele",
":",
"entries",
")",
"{",
"this",
".",
"entries",
".",
"add",
"(",
"ele",
")",
";",
"}",
"return",
"this",
";",
"}"
] | <p>
A list of inventory items on the instance(s).
</p>
<p>
<b>NOTE:</b> This method appends the values to the existing list (if any). Use
{@link #setEntries(java.util.Collection)} or {@link #withEntries(java.util.Collection)} if you want to override
the existing values.
</p>
@param entries
A list of inventory items on the instance(s).
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"A",
"list",
"of",
"inventory",
"items",
"on",
"the",
"instance",
"(",
"s",
")",
".",
"<",
"/",
"p",
">",
"<p",
">",
"<b",
">",
"NOTE",
":",
"<",
"/",
"b",
">",
"This",
"method",
"appends",
"the",
"values",
"to",
"the",
"existing",
"list",
"(",
"if",
"any",
")",
".",
"Use",
"{",
"@link",
"#setEntries",
"(",
"java",
".",
"util",
".",
"Collection",
")",
"}",
"or",
"{",
"@link",
"#withEntries",
"(",
"java",
".",
"util",
".",
"Collection",
")",
"}",
"if",
"you",
"want",
"to",
"override",
"the",
"existing",
"values",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-ssm/src/main/java/com/amazonaws/services/simplesystemsmanagement/model/ListInventoryEntriesResult.java#L272-L280 |
Frostman/dropbox4j | src/main/java/ru/frostman/dropbox/api/DropboxClient.java | DropboxClient.getMetadata | @SuppressWarnings( {
"""
Returns metadata information about specified resource with
checking for its hash with specified max child entries count.
If nothing changes (hash isn't changed) then 304 will returns.
@param path to file or directory
@param fileLimit max child entries count
@param hash to check smth changed
@param list true to include child entries and false to not
@return metadata of specified resource
@see Entry
@see DropboxDefaults
""""PointlessBooleanExpression"})
public Entry getMetadata(String path, int fileLimit, @Nullable String hash, boolean list) {
OAuthRequest request = new OAuthRequest(Verb.GET, METADATA_URL + encode(path));
if (fileLimit != FILE_LIMIT)
request.addQuerystringParameter("file_limit", Integer.toString(fileLimit));
if (hash != null) {
request.addQuerystringParameter("hash", hash);
}
if (list != LIST) {
request.addQuerystringParameter("list", Boolean.toString(list));
}
service.signRequest(accessToken, request);
String content = checkMetadata(request.send()).getBody();
return Json.parse(content, Entry.class);
} | java | @SuppressWarnings({"PointlessBooleanExpression"})
public Entry getMetadata(String path, int fileLimit, @Nullable String hash, boolean list) {
OAuthRequest request = new OAuthRequest(Verb.GET, METADATA_URL + encode(path));
if (fileLimit != FILE_LIMIT)
request.addQuerystringParameter("file_limit", Integer.toString(fileLimit));
if (hash != null) {
request.addQuerystringParameter("hash", hash);
}
if (list != LIST) {
request.addQuerystringParameter("list", Boolean.toString(list));
}
service.signRequest(accessToken, request);
String content = checkMetadata(request.send()).getBody();
return Json.parse(content, Entry.class);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"PointlessBooleanExpression\"",
"}",
")",
"public",
"Entry",
"getMetadata",
"(",
"String",
"path",
",",
"int",
"fileLimit",
",",
"@",
"Nullable",
"String",
"hash",
",",
"boolean",
"list",
")",
"{",
"OAuthRequest",
"request",
"=",
"new",
"OAuthRequest",
"(",
"Verb",
".",
"GET",
",",
"METADATA_URL",
"+",
"encode",
"(",
"path",
")",
")",
";",
"if",
"(",
"fileLimit",
"!=",
"FILE_LIMIT",
")",
"request",
".",
"addQuerystringParameter",
"(",
"\"file_limit\"",
",",
"Integer",
".",
"toString",
"(",
"fileLimit",
")",
")",
";",
"if",
"(",
"hash",
"!=",
"null",
")",
"{",
"request",
".",
"addQuerystringParameter",
"(",
"\"hash\"",
",",
"hash",
")",
";",
"}",
"if",
"(",
"list",
"!=",
"LIST",
")",
"{",
"request",
".",
"addQuerystringParameter",
"(",
"\"list\"",
",",
"Boolean",
".",
"toString",
"(",
"list",
")",
")",
";",
"}",
"service",
".",
"signRequest",
"(",
"accessToken",
",",
"request",
")",
";",
"String",
"content",
"=",
"checkMetadata",
"(",
"request",
".",
"send",
"(",
")",
")",
".",
"getBody",
"(",
")",
";",
"return",
"Json",
".",
"parse",
"(",
"content",
",",
"Entry",
".",
"class",
")",
";",
"}"
] | Returns metadata information about specified resource with
checking for its hash with specified max child entries count.
If nothing changes (hash isn't changed) then 304 will returns.
@param path to file or directory
@param fileLimit max child entries count
@param hash to check smth changed
@param list true to include child entries and false to not
@return metadata of specified resource
@see Entry
@see DropboxDefaults | [
"Returns",
"metadata",
"information",
"about",
"specified",
"resource",
"with",
"checking",
"for",
"its",
"hash",
"with",
"specified",
"max",
"child",
"entries",
"count",
".",
"If",
"nothing",
"changes",
"(",
"hash",
"isn",
"t",
"changed",
")",
"then",
"304",
"will",
"returns",
"."
] | train | https://github.com/Frostman/dropbox4j/blob/774c817e5bf294d0139ecb5ac81399be50ada5e0/src/main/java/ru/frostman/dropbox/api/DropboxClient.java#L169-L188 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_trunk_serviceName_externalDisplayedNumber_number_DELETE | public void billingAccount_trunk_serviceName_externalDisplayedNumber_number_DELETE(String billingAccount, String serviceName, String number) throws IOException {
"""
Delete an external displayed number for a given trunk
REST: DELETE /telephony/{billingAccount}/trunk/{serviceName}/externalDisplayedNumber/{number}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] Name of the service
@param number [required] External displayed number linked to a trunk
"""
String qPath = "/telephony/{billingAccount}/trunk/{serviceName}/externalDisplayedNumber/{number}";
StringBuilder sb = path(qPath, billingAccount, serviceName, number);
exec(qPath, "DELETE", sb.toString(), null);
} | java | public void billingAccount_trunk_serviceName_externalDisplayedNumber_number_DELETE(String billingAccount, String serviceName, String number) throws IOException {
String qPath = "/telephony/{billingAccount}/trunk/{serviceName}/externalDisplayedNumber/{number}";
StringBuilder sb = path(qPath, billingAccount, serviceName, number);
exec(qPath, "DELETE", sb.toString(), null);
} | [
"public",
"void",
"billingAccount_trunk_serviceName_externalDisplayedNumber_number_DELETE",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"String",
"number",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/trunk/{serviceName}/externalDisplayedNumber/{number}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
",",
"number",
")",
";",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] | Delete an external displayed number for a given trunk
REST: DELETE /telephony/{billingAccount}/trunk/{serviceName}/externalDisplayedNumber/{number}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] Name of the service
@param number [required] External displayed number linked to a trunk | [
"Delete",
"an",
"external",
"displayed",
"number",
"for",
"a",
"given",
"trunk"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L8150-L8154 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java | JBBPDslBuilder.VarArray | public JBBPDslBuilder VarArray(final String name, final String sizeExpression) {
"""
Create named var array with fixed size.
@param name name of the array, can be null for anonymous one
@param sizeExpression expression to calculate size of the array, must not be null.
@return the builder instance, must not be null
"""
return this.VarArray(name, sizeExpression, null);
} | java | public JBBPDslBuilder VarArray(final String name, final String sizeExpression) {
return this.VarArray(name, sizeExpression, null);
} | [
"public",
"JBBPDslBuilder",
"VarArray",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"sizeExpression",
")",
"{",
"return",
"this",
".",
"VarArray",
"(",
"name",
",",
"sizeExpression",
",",
"null",
")",
";",
"}"
] | Create named var array with fixed size.
@param name name of the array, can be null for anonymous one
@param sizeExpression expression to calculate size of the array, must not be null.
@return the builder instance, must not be null | [
"Create",
"named",
"var",
"array",
"with",
"fixed",
"size",
"."
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L450-L452 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.telephony_billingAccount_numberNogeographic_POST | public OvhOrder telephony_billingAccount_numberNogeographic_POST(String billingAccount, String ape, String city, OvhNumberCountryEnum country, Boolean displayUniversalDirectory, String email, String firstname, OvhLegalFormEnum legalform, String name, OvhNumberOffer offer, String organisation, String phone, OvhNumberPoolEnum pool, Boolean retractation, String siret, String socialNomination, String specificNumber, String streetName, String streetNumber, String zip) throws IOException {
"""
Create order
REST: POST /order/telephony/{billingAccount}/numberNogeographic
@param firstname [required] Contact firstname
@param streetName [required] Street name
@param email [required]
@param organisation [required] Contact organisation
@param pool [required] Number of alias in case of pool
@param socialNomination [required] Company social nomination
@param zip [required] Contact zip
@param name [required] Contact name
@param country [required] Number country
@param retractation [required] Retractation rights if set
@param displayUniversalDirectory [required] Publish contact informations on universal directories
@param siret [required] Companu siret
@param phone [required] Contact phone
@param specificNumber [required] Preselected standard number
@param streetNumber [required] Street number
@param legalform [required] Legal form
@param offer [required] Number offer
@param city [required] Contact city
@param ape [required] Company ape
@param billingAccount [required] The name of your billingAccount
"""
String qPath = "/order/telephony/{billingAccount}/numberNogeographic";
StringBuilder sb = path(qPath, billingAccount);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "ape", ape);
addBody(o, "city", city);
addBody(o, "country", country);
addBody(o, "displayUniversalDirectory", displayUniversalDirectory);
addBody(o, "email", email);
addBody(o, "firstname", firstname);
addBody(o, "legalform", legalform);
addBody(o, "name", name);
addBody(o, "offer", offer);
addBody(o, "organisation", organisation);
addBody(o, "phone", phone);
addBody(o, "pool", pool);
addBody(o, "retractation", retractation);
addBody(o, "siret", siret);
addBody(o, "socialNomination", socialNomination);
addBody(o, "specificNumber", specificNumber);
addBody(o, "streetName", streetName);
addBody(o, "streetNumber", streetNumber);
addBody(o, "zip", zip);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder telephony_billingAccount_numberNogeographic_POST(String billingAccount, String ape, String city, OvhNumberCountryEnum country, Boolean displayUniversalDirectory, String email, String firstname, OvhLegalFormEnum legalform, String name, OvhNumberOffer offer, String organisation, String phone, OvhNumberPoolEnum pool, Boolean retractation, String siret, String socialNomination, String specificNumber, String streetName, String streetNumber, String zip) throws IOException {
String qPath = "/order/telephony/{billingAccount}/numberNogeographic";
StringBuilder sb = path(qPath, billingAccount);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "ape", ape);
addBody(o, "city", city);
addBody(o, "country", country);
addBody(o, "displayUniversalDirectory", displayUniversalDirectory);
addBody(o, "email", email);
addBody(o, "firstname", firstname);
addBody(o, "legalform", legalform);
addBody(o, "name", name);
addBody(o, "offer", offer);
addBody(o, "organisation", organisation);
addBody(o, "phone", phone);
addBody(o, "pool", pool);
addBody(o, "retractation", retractation);
addBody(o, "siret", siret);
addBody(o, "socialNomination", socialNomination);
addBody(o, "specificNumber", specificNumber);
addBody(o, "streetName", streetName);
addBody(o, "streetNumber", streetNumber);
addBody(o, "zip", zip);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"telephony_billingAccount_numberNogeographic_POST",
"(",
"String",
"billingAccount",
",",
"String",
"ape",
",",
"String",
"city",
",",
"OvhNumberCountryEnum",
"country",
",",
"Boolean",
"displayUniversalDirectory",
",",
"String",
"email",
",",
"String",
"firstname",
",",
"OvhLegalFormEnum",
"legalform",
",",
"String",
"name",
",",
"OvhNumberOffer",
"offer",
",",
"String",
"organisation",
",",
"String",
"phone",
",",
"OvhNumberPoolEnum",
"pool",
",",
"Boolean",
"retractation",
",",
"String",
"siret",
",",
"String",
"socialNomination",
",",
"String",
"specificNumber",
",",
"String",
"streetName",
",",
"String",
"streetNumber",
",",
"String",
"zip",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/telephony/{billingAccount}/numberNogeographic\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"ape\"",
",",
"ape",
")",
";",
"addBody",
"(",
"o",
",",
"\"city\"",
",",
"city",
")",
";",
"addBody",
"(",
"o",
",",
"\"country\"",
",",
"country",
")",
";",
"addBody",
"(",
"o",
",",
"\"displayUniversalDirectory\"",
",",
"displayUniversalDirectory",
")",
";",
"addBody",
"(",
"o",
",",
"\"email\"",
",",
"email",
")",
";",
"addBody",
"(",
"o",
",",
"\"firstname\"",
",",
"firstname",
")",
";",
"addBody",
"(",
"o",
",",
"\"legalform\"",
",",
"legalform",
")",
";",
"addBody",
"(",
"o",
",",
"\"name\"",
",",
"name",
")",
";",
"addBody",
"(",
"o",
",",
"\"offer\"",
",",
"offer",
")",
";",
"addBody",
"(",
"o",
",",
"\"organisation\"",
",",
"organisation",
")",
";",
"addBody",
"(",
"o",
",",
"\"phone\"",
",",
"phone",
")",
";",
"addBody",
"(",
"o",
",",
"\"pool\"",
",",
"pool",
")",
";",
"addBody",
"(",
"o",
",",
"\"retractation\"",
",",
"retractation",
")",
";",
"addBody",
"(",
"o",
",",
"\"siret\"",
",",
"siret",
")",
";",
"addBody",
"(",
"o",
",",
"\"socialNomination\"",
",",
"socialNomination",
")",
";",
"addBody",
"(",
"o",
",",
"\"specificNumber\"",
",",
"specificNumber",
")",
";",
"addBody",
"(",
"o",
",",
"\"streetName\"",
",",
"streetName",
")",
";",
"addBody",
"(",
"o",
",",
"\"streetNumber\"",
",",
"streetNumber",
")",
";",
"addBody",
"(",
"o",
",",
"\"zip\"",
",",
"zip",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] | Create order
REST: POST /order/telephony/{billingAccount}/numberNogeographic
@param firstname [required] Contact firstname
@param streetName [required] Street name
@param email [required]
@param organisation [required] Contact organisation
@param pool [required] Number of alias in case of pool
@param socialNomination [required] Company social nomination
@param zip [required] Contact zip
@param name [required] Contact name
@param country [required] Number country
@param retractation [required] Retractation rights if set
@param displayUniversalDirectory [required] Publish contact informations on universal directories
@param siret [required] Companu siret
@param phone [required] Contact phone
@param specificNumber [required] Preselected standard number
@param streetNumber [required] Street number
@param legalform [required] Legal form
@param offer [required] Number offer
@param city [required] Contact city
@param ape [required] Company ape
@param billingAccount [required] The name of your billingAccount | [
"Create",
"order"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L6291-L6316 |
jaxio/celerio | celerio-engine/src/main/java/com/jaxio/celerio/template/PreviousEngine.java | PreviousEngine.setCurrentFilename | private String setCurrentFilename(String relativePathOrPackage, String filename, String domain) throws Exception {
"""
called within the velocity script.<br>
see $velocity.setJavaFilename(...)<br>
this allows us to generate dynamically the filename.
@param relativePathOrPackage
@param filename
@param domain
@throws Exception
"""
currentFullFilename = convertToFullFilename(relativePathOrPackage, filename, domain);
return "";
} | java | private String setCurrentFilename(String relativePathOrPackage, String filename, String domain) throws Exception {
currentFullFilename = convertToFullFilename(relativePathOrPackage, filename, domain);
return "";
} | [
"private",
"String",
"setCurrentFilename",
"(",
"String",
"relativePathOrPackage",
",",
"String",
"filename",
",",
"String",
"domain",
")",
"throws",
"Exception",
"{",
"currentFullFilename",
"=",
"convertToFullFilename",
"(",
"relativePathOrPackage",
",",
"filename",
",",
"domain",
")",
";",
"return",
"\"\"",
";",
"}"
] | called within the velocity script.<br>
see $velocity.setJavaFilename(...)<br>
this allows us to generate dynamically the filename.
@param relativePathOrPackage
@param filename
@param domain
@throws Exception | [
"called",
"within",
"the",
"velocity",
"script",
".",
"<br",
">",
"see",
"$velocity",
".",
"setJavaFilename",
"(",
"...",
")",
"<br",
">",
"this",
"allows",
"us",
"to",
"generate",
"dynamically",
"the",
"filename",
"."
] | train | https://github.com/jaxio/celerio/blob/fbfacb639e286f9f3f3a18986f74ea275bebd887/celerio-engine/src/main/java/com/jaxio/celerio/template/PreviousEngine.java#L118-L121 |
stratosphere/stratosphere | stratosphere-core/src/main/java/eu/stratosphere/configuration/Configuration.java | Configuration.getFloat | public float getFloat(final String key, final float defaultValue) {
"""
Returns the value associated with the given key as a float.
@param key
the key pointing to the associated value
@param defaultValue
the default value which is returned in case there is no value associated with the given key
@return the (default) value associated with the given key
"""
String val = getStringInternal(key);
if (val == null) {
return defaultValue;
} else {
return Float.parseFloat(val);
}
} | java | public float getFloat(final String key, final float defaultValue) {
String val = getStringInternal(key);
if (val == null) {
return defaultValue;
} else {
return Float.parseFloat(val);
}
} | [
"public",
"float",
"getFloat",
"(",
"final",
"String",
"key",
",",
"final",
"float",
"defaultValue",
")",
"{",
"String",
"val",
"=",
"getStringInternal",
"(",
"key",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"return",
"defaultValue",
";",
"}",
"else",
"{",
"return",
"Float",
".",
"parseFloat",
"(",
"val",
")",
";",
"}",
"}"
] | Returns the value associated with the given key as a float.
@param key
the key pointing to the associated value
@param defaultValue
the default value which is returned in case there is no value associated with the given key
@return the (default) value associated with the given key | [
"Returns",
"the",
"value",
"associated",
"with",
"the",
"given",
"key",
"as",
"a",
"float",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-core/src/main/java/eu/stratosphere/configuration/Configuration.java#L272-L279 |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/provisioning/UsersApi.java | UsersApi.getUsers | public List<User> getUsers(Integer limit, Integer offset, String order, String sortBy, String filterName, String filterParameters, String roles, String skills, Boolean userEnabled, String userValid) throws ProvisioningApiException {
"""
Get users.
Get [CfgPerson](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgPerson) objects based on the specified filters.
@param limit Limit the number of users the Provisioning API should return. (optional)
@param offset The number of matches the Provisioning API should skip in the returned users. (optional)
@param order The sort order. (optional)
@param sortBy A comma-separated list of fields to sort on. Possible values are firstName, lastName, and userName. (optional)
@param filterName The name of a filter to use on the results. (optional)
@param filterParameters A part of the users first or last name, if you use the FirstNameOrLastNameMatches filter. (optional)
@param roles Return only users who have the Workspace Web Edition roles. The roles can be specified in a comma-separated list. Possible values are ROLE_AGENT and ROLE_ADMIN,ROLE_SUPERVISOR. (optional)
@param skills Return only users who have these skills. The skills can be specified in a comma-separated list. (optional)
@param userEnabled Return only enabled or disabled users. (optional)
@param userValid Return only valid or invalid users. (optional)
@return The list of users found for the given parameters.
@throws ProvisioningApiException if the call is unsuccessful.
"""
List<User> out = new ArrayList();
try {
GetUsersSuccessResponse resp = usersApi.getUsers(limit, offset, order, sortBy, filterName, filterParameters, roles, skills, userEnabled, userValid);
if (!resp.getStatus().getCode().equals(0)) {
throw new ProvisioningApiException("Error getting users. Code: " + resp.getStatus().getCode());
}
for(Object i:resp.getData().getUsers()) {
out.add(new User((Map<String, Object>)i));
}
} catch(ApiException e) {
throw new ProvisioningApiException("Error getting users", e);
}
return out;
} | java | public List<User> getUsers(Integer limit, Integer offset, String order, String sortBy, String filterName, String filterParameters, String roles, String skills, Boolean userEnabled, String userValid) throws ProvisioningApiException {
List<User> out = new ArrayList();
try {
GetUsersSuccessResponse resp = usersApi.getUsers(limit, offset, order, sortBy, filterName, filterParameters, roles, skills, userEnabled, userValid);
if (!resp.getStatus().getCode().equals(0)) {
throw new ProvisioningApiException("Error getting users. Code: " + resp.getStatus().getCode());
}
for(Object i:resp.getData().getUsers()) {
out.add(new User((Map<String, Object>)i));
}
} catch(ApiException e) {
throw new ProvisioningApiException("Error getting users", e);
}
return out;
} | [
"public",
"List",
"<",
"User",
">",
"getUsers",
"(",
"Integer",
"limit",
",",
"Integer",
"offset",
",",
"String",
"order",
",",
"String",
"sortBy",
",",
"String",
"filterName",
",",
"String",
"filterParameters",
",",
"String",
"roles",
",",
"String",
"skills",
",",
"Boolean",
"userEnabled",
",",
"String",
"userValid",
")",
"throws",
"ProvisioningApiException",
"{",
"List",
"<",
"User",
">",
"out",
"=",
"new",
"ArrayList",
"(",
")",
";",
"try",
"{",
"GetUsersSuccessResponse",
"resp",
"=",
"usersApi",
".",
"getUsers",
"(",
"limit",
",",
"offset",
",",
"order",
",",
"sortBy",
",",
"filterName",
",",
"filterParameters",
",",
"roles",
",",
"skills",
",",
"userEnabled",
",",
"userValid",
")",
";",
"if",
"(",
"!",
"resp",
".",
"getStatus",
"(",
")",
".",
"getCode",
"(",
")",
".",
"equals",
"(",
"0",
")",
")",
"{",
"throw",
"new",
"ProvisioningApiException",
"(",
"\"Error getting users. Code: \"",
"+",
"resp",
".",
"getStatus",
"(",
")",
".",
"getCode",
"(",
")",
")",
";",
"}",
"for",
"(",
"Object",
"i",
":",
"resp",
".",
"getData",
"(",
")",
".",
"getUsers",
"(",
")",
")",
"{",
"out",
".",
"add",
"(",
"new",
"User",
"(",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"i",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ApiException",
"e",
")",
"{",
"throw",
"new",
"ProvisioningApiException",
"(",
"\"Error getting users\"",
",",
"e",
")",
";",
"}",
"return",
"out",
";",
"}"
] | Get users.
Get [CfgPerson](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgPerson) objects based on the specified filters.
@param limit Limit the number of users the Provisioning API should return. (optional)
@param offset The number of matches the Provisioning API should skip in the returned users. (optional)
@param order The sort order. (optional)
@param sortBy A comma-separated list of fields to sort on. Possible values are firstName, lastName, and userName. (optional)
@param filterName The name of a filter to use on the results. (optional)
@param filterParameters A part of the users first or last name, if you use the FirstNameOrLastNameMatches filter. (optional)
@param roles Return only users who have the Workspace Web Edition roles. The roles can be specified in a comma-separated list. Possible values are ROLE_AGENT and ROLE_ADMIN,ROLE_SUPERVISOR. (optional)
@param skills Return only users who have these skills. The skills can be specified in a comma-separated list. (optional)
@param userEnabled Return only enabled or disabled users. (optional)
@param userValid Return only valid or invalid users. (optional)
@return The list of users found for the given parameters.
@throws ProvisioningApiException if the call is unsuccessful. | [
"Get",
"users",
".",
"Get",
"[",
"CfgPerson",
"]",
"(",
"https",
":",
"//",
"docs",
".",
"genesys",
".",
"com",
"/",
"Documentation",
"/",
"PSDK",
"/",
"latest",
"/",
"ConfigLayerRef",
"/",
"CfgPerson",
")",
"objects",
"based",
"on",
"the",
"specified",
"filters",
"."
] | train | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/provisioning/UsersApi.java#L98-L117 |
osiam/connector4java | src/main/java/org/osiam/client/OsiamConnector.java | OsiamConnector.replaceUser | public User replaceUser(String id, User user, AccessToken accessToken) {
"""
replaces the {@link User} with the given id with the given {@link User}
@param id The id of the User to be replaced
@param user The {@link User} who will repleace the old {@link User}
@param accessToken the OSIAM access token from for the current session
@return the replaced User
@throws InvalidAttributeException in case the id or the User is null or empty
@throws UnauthorizedException if the request could not be authorized.
@throws ConflictException if the User could not be replaced
@throws NoResultException if no user with the given id can be found
@throws ForbiddenException if the scope doesn't allow this request
@throws ConnectionInitializationException if the connection to the given OSIAM service could not be initialized
@throws IllegalStateException if OSIAM's endpoint(s) are not properly configured
"""
return getUserService().replaceUser(id, user, accessToken);
} | java | public User replaceUser(String id, User user, AccessToken accessToken) {
return getUserService().replaceUser(id, user, accessToken);
} | [
"public",
"User",
"replaceUser",
"(",
"String",
"id",
",",
"User",
"user",
",",
"AccessToken",
"accessToken",
")",
"{",
"return",
"getUserService",
"(",
")",
".",
"replaceUser",
"(",
"id",
",",
"user",
",",
"accessToken",
")",
";",
"}"
] | replaces the {@link User} with the given id with the given {@link User}
@param id The id of the User to be replaced
@param user The {@link User} who will repleace the old {@link User}
@param accessToken the OSIAM access token from for the current session
@return the replaced User
@throws InvalidAttributeException in case the id or the User is null or empty
@throws UnauthorizedException if the request could not be authorized.
@throws ConflictException if the User could not be replaced
@throws NoResultException if no user with the given id can be found
@throws ForbiddenException if the scope doesn't allow this request
@throws ConnectionInitializationException if the connection to the given OSIAM service could not be initialized
@throws IllegalStateException if OSIAM's endpoint(s) are not properly configured | [
"replaces",
"the",
"{",
"@link",
"User",
"}",
"with",
"the",
"given",
"id",
"with",
"the",
"given",
"{",
"@link",
"User",
"}"
] | train | https://github.com/osiam/connector4java/blob/a5e6ae1e706f4889d662a069fe2f3bf8e3848d12/src/main/java/org/osiam/client/OsiamConnector.java#L544-L546 |
carewebframework/carewebframework-core | org.carewebframework.shell/src/main/java/org/carewebframework/shell/elements/ElementPlugin.java | ElementPlugin.registerProperties | public void registerProperties(Object instance, String... propertyNames) {
"""
Registers one or more named properties to the container. Using this, a plugin can expose
properties for serialization and deserialization.
@param instance The object instance holding the property accessors. If null, any existing
registration will be removed.
@param propertyNames One or more property names to register.
"""
for (String propertyName : propertyNames) {
registerProperty(instance, propertyName, true);
}
} | java | public void registerProperties(Object instance, String... propertyNames) {
for (String propertyName : propertyNames) {
registerProperty(instance, propertyName, true);
}
} | [
"public",
"void",
"registerProperties",
"(",
"Object",
"instance",
",",
"String",
"...",
"propertyNames",
")",
"{",
"for",
"(",
"String",
"propertyName",
":",
"propertyNames",
")",
"{",
"registerProperty",
"(",
"instance",
",",
"propertyName",
",",
"true",
")",
";",
"}",
"}"
] | Registers one or more named properties to the container. Using this, a plugin can expose
properties for serialization and deserialization.
@param instance The object instance holding the property accessors. If null, any existing
registration will be removed.
@param propertyNames One or more property names to register. | [
"Registers",
"one",
"or",
"more",
"named",
"properties",
"to",
"the",
"container",
".",
"Using",
"this",
"a",
"plugin",
"can",
"expose",
"properties",
"for",
"serialization",
"and",
"deserialization",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.shell/src/main/java/org/carewebframework/shell/elements/ElementPlugin.java#L752-L756 |
playn/playn | html/src/playn/super/java/nio/DoubleBuffer.java | DoubleBuffer.put | public DoubleBuffer put (double[] src, int off, int len) {
"""
Writes doubles from the given double array, starting from the specified offset, to the
current position and increases the position by the number of doubles written.
@param src the source double array.
@param off the offset of double array, must not be negative and not greater than {@code
src.length}.
@param len the number of doubles to write, must be no less than zero and not greater than
{@code src.length - off}.
@return this buffer.
@exception BufferOverflowException if {@code remaining()} is less than {@code len}.
@exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid.
@exception ReadOnlyBufferException if no changes may be made to the contents of this buffer.
"""
int length = src.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
for (int i = off; i < off + len; i++) {
put(src[i]);
}
return this;
} | java | public DoubleBuffer put (double[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
for (int i = off; i < off + len; i++) {
put(src[i]);
}
return this;
} | [
"public",
"DoubleBuffer",
"put",
"(",
"double",
"[",
"]",
"src",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"int",
"length",
"=",
"src",
".",
"length",
";",
"if",
"(",
"off",
"<",
"0",
"||",
"len",
"<",
"0",
"||",
"(",
"long",
")",
"off",
"+",
"(",
"long",
")",
"len",
">",
"length",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"if",
"(",
"len",
">",
"remaining",
"(",
")",
")",
"{",
"throw",
"new",
"BufferOverflowException",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"off",
";",
"i",
"<",
"off",
"+",
"len",
";",
"i",
"++",
")",
"{",
"put",
"(",
"src",
"[",
"i",
"]",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Writes doubles from the given double array, starting from the specified offset, to the
current position and increases the position by the number of doubles written.
@param src the source double array.
@param off the offset of double array, must not be negative and not greater than {@code
src.length}.
@param len the number of doubles to write, must be no less than zero and not greater than
{@code src.length - off}.
@return this buffer.
@exception BufferOverflowException if {@code remaining()} is less than {@code len}.
@exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid.
@exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. | [
"Writes",
"doubles",
"from",
"the",
"given",
"double",
"array",
"starting",
"from",
"the",
"specified",
"offset",
"to",
"the",
"current",
"position",
"and",
"increases",
"the",
"position",
"by",
"the",
"number",
"of",
"doubles",
"written",
"."
] | train | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/DoubleBuffer.java#L316-L329 |
sdl/Testy | src/main/java/com/sdl/selenium/extjs3/form/DateField.java | DateField.setDate | private boolean setDate(String day, String month, String year) {
"""
example new DataField().setDate("19", "05", "2013")
@param day String 'dd'
@param month String 'MMM'
@param year String 'yyyy'
@return true if is selected date, false when DataField doesn't exist
"""
click();
String fullDate = monthYearButton.getText().trim();
if (!fullDate.contains(month) || !fullDate.contains(year)) {
monthYearButton.click();
goToYear(year, fullDate);
WebLocator yearEl = new WebLocator(yearContainer).setText(year, SearchType.EQUALS).setInfoMessage("year " + year);
yearEl.click();
WebLocator yearContainer1 = new WebLocator(yearAndMonth).setClasses("x-date-mp-year", "x-date-mp-sel");
WebLocator yearEl1 = new WebLocator(yearContainer1).setText(year, SearchType.EQUALS);
if (!yearEl1.ready(1)) {
yearEl.click();
}
WebLocator monthEl = new WebLocator(monthContainer).setText(month, SearchType.EQUALS).setInfoMessage("month " + month);
monthEl.click();
selectOkButton.click();
}
WebLocator dayEl = new WebLocator(dayContainer).setText(day, SearchType.EQUALS).setInfoMessage("day " + day);
dayEl.click();
return true;
} | java | private boolean setDate(String day, String month, String year) {
click();
String fullDate = monthYearButton.getText().trim();
if (!fullDate.contains(month) || !fullDate.contains(year)) {
monthYearButton.click();
goToYear(year, fullDate);
WebLocator yearEl = new WebLocator(yearContainer).setText(year, SearchType.EQUALS).setInfoMessage("year " + year);
yearEl.click();
WebLocator yearContainer1 = new WebLocator(yearAndMonth).setClasses("x-date-mp-year", "x-date-mp-sel");
WebLocator yearEl1 = new WebLocator(yearContainer1).setText(year, SearchType.EQUALS);
if (!yearEl1.ready(1)) {
yearEl.click();
}
WebLocator monthEl = new WebLocator(monthContainer).setText(month, SearchType.EQUALS).setInfoMessage("month " + month);
monthEl.click();
selectOkButton.click();
}
WebLocator dayEl = new WebLocator(dayContainer).setText(day, SearchType.EQUALS).setInfoMessage("day " + day);
dayEl.click();
return true;
} | [
"private",
"boolean",
"setDate",
"(",
"String",
"day",
",",
"String",
"month",
",",
"String",
"year",
")",
"{",
"click",
"(",
")",
";",
"String",
"fullDate",
"=",
"monthYearButton",
".",
"getText",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"fullDate",
".",
"contains",
"(",
"month",
")",
"||",
"!",
"fullDate",
".",
"contains",
"(",
"year",
")",
")",
"{",
"monthYearButton",
".",
"click",
"(",
")",
";",
"goToYear",
"(",
"year",
",",
"fullDate",
")",
";",
"WebLocator",
"yearEl",
"=",
"new",
"WebLocator",
"(",
"yearContainer",
")",
".",
"setText",
"(",
"year",
",",
"SearchType",
".",
"EQUALS",
")",
".",
"setInfoMessage",
"(",
"\"year \"",
"+",
"year",
")",
";",
"yearEl",
".",
"click",
"(",
")",
";",
"WebLocator",
"yearContainer1",
"=",
"new",
"WebLocator",
"(",
"yearAndMonth",
")",
".",
"setClasses",
"(",
"\"x-date-mp-year\"",
",",
"\"x-date-mp-sel\"",
")",
";",
"WebLocator",
"yearEl1",
"=",
"new",
"WebLocator",
"(",
"yearContainer1",
")",
".",
"setText",
"(",
"year",
",",
"SearchType",
".",
"EQUALS",
")",
";",
"if",
"(",
"!",
"yearEl1",
".",
"ready",
"(",
"1",
")",
")",
"{",
"yearEl",
".",
"click",
"(",
")",
";",
"}",
"WebLocator",
"monthEl",
"=",
"new",
"WebLocator",
"(",
"monthContainer",
")",
".",
"setText",
"(",
"month",
",",
"SearchType",
".",
"EQUALS",
")",
".",
"setInfoMessage",
"(",
"\"month \"",
"+",
"month",
")",
";",
"monthEl",
".",
"click",
"(",
")",
";",
"selectOkButton",
".",
"click",
"(",
")",
";",
"}",
"WebLocator",
"dayEl",
"=",
"new",
"WebLocator",
"(",
"dayContainer",
")",
".",
"setText",
"(",
"day",
",",
"SearchType",
".",
"EQUALS",
")",
".",
"setInfoMessage",
"(",
"\"day \"",
"+",
"day",
")",
";",
"dayEl",
".",
"click",
"(",
")",
";",
"return",
"true",
";",
"}"
] | example new DataField().setDate("19", "05", "2013")
@param day String 'dd'
@param month String 'MMM'
@param year String 'yyyy'
@return true if is selected date, false when DataField doesn't exist | [
"example",
"new",
"DataField",
"()",
".",
"setDate",
"(",
"19",
"05",
"2013",
")"
] | train | https://github.com/sdl/Testy/blob/b3ae061554016f926f04694a39ff00dab7576609/src/main/java/com/sdl/selenium/extjs3/form/DateField.java#L55-L75 |
iron-io/iron_mq_java | src/main/java/io/iron/ironmq/Queue.java | Queue.releaseMessage | public void releaseMessage(Message message, int delay) throws IOException {
"""
Release reserved message after specified time. If there is no message with such id on the queue, an
EmptyQueueException is thrown.
@param message The message to release.
@param delay The time after which the message will be released.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server.
"""
releaseMessage(message.getId(), message.getReservationId(), new Long(delay));
} | java | public void releaseMessage(Message message, int delay) throws IOException {
releaseMessage(message.getId(), message.getReservationId(), new Long(delay));
} | [
"public",
"void",
"releaseMessage",
"(",
"Message",
"message",
",",
"int",
"delay",
")",
"throws",
"IOException",
"{",
"releaseMessage",
"(",
"message",
".",
"getId",
"(",
")",
",",
"message",
".",
"getReservationId",
"(",
")",
",",
"new",
"Long",
"(",
"delay",
")",
")",
";",
"}"
] | Release reserved message after specified time. If there is no message with such id on the queue, an
EmptyQueueException is thrown.
@param message The message to release.
@param delay The time after which the message will be released.
@throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
@throws java.io.IOException If there is an error accessing the IronMQ server. | [
"Release",
"reserved",
"message",
"after",
"specified",
"time",
".",
"If",
"there",
"is",
"no",
"message",
"with",
"such",
"id",
"on",
"the",
"queue",
"an",
"EmptyQueueException",
"is",
"thrown",
"."
] | train | https://github.com/iron-io/iron_mq_java/blob/62d6a86545ca7ef31b7b4797aae0c5b31394a507/src/main/java/io/iron/ironmq/Queue.java#L503-L505 |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java | FormatUtil.nextPosition | private static int nextPosition(int a, int b) {
"""
Helper that is similar to {@code Math.min(a,b)}, except that negative
values are considered "invalid".
@param a String position
@param b String position
@return {@code Math.min(a,b)} if {@code a >= 0} and {@code b >= 0},
otherwise whichever is not negative.
"""
return a < 0 ? b : b < 0 ? a : a < b ? a : b;
} | java | private static int nextPosition(int a, int b) {
return a < 0 ? b : b < 0 ? a : a < b ? a : b;
} | [
"private",
"static",
"int",
"nextPosition",
"(",
"int",
"a",
",",
"int",
"b",
")",
"{",
"return",
"a",
"<",
"0",
"?",
"b",
":",
"b",
"<",
"0",
"?",
"a",
":",
"a",
"<",
"b",
"?",
"a",
":",
"b",
";",
"}"
] | Helper that is similar to {@code Math.min(a,b)}, except that negative
values are considered "invalid".
@param a String position
@param b String position
@return {@code Math.min(a,b)} if {@code a >= 0} and {@code b >= 0},
otherwise whichever is not negative. | [
"Helper",
"that",
"is",
"similar",
"to",
"{",
"@code",
"Math",
".",
"min",
"(",
"a",
"b",
")",
"}",
"except",
"that",
"negative",
"values",
"are",
"considered",
"invalid",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L796-L798 |
camunda/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/application/impl/ProcessApplicationScriptEnvironment.java | ProcessApplicationScriptEnvironment.getScriptEngineForName | public ScriptEngine getScriptEngineForName(String scriptEngineName, boolean cache) {
"""
<p>Returns an instance of {@link ScriptEngine} for the given <code>scriptEngineName</code>.</p>
<p>Iff the given parameter <code>cache</code> is set <code>true</code>,
then the instance {@link ScriptEngine} will be cached.</p>
@param scriptEngineName the name of the {@link ScriptEngine} to return
@param cache a boolean value which indicates whether the {@link ScriptEngine} should
be cached or not.
@return a {@link ScriptEngine}
"""
if(processApplicationScriptEngineResolver == null) {
synchronized (this) {
if(processApplicationScriptEngineResolver == null) {
processApplicationScriptEngineResolver = new ScriptEngineResolver(new ScriptEngineManager(getProcessApplicationClassloader()));
}
}
}
return processApplicationScriptEngineResolver.getScriptEngine(scriptEngineName, cache);
} | java | public ScriptEngine getScriptEngineForName(String scriptEngineName, boolean cache) {
if(processApplicationScriptEngineResolver == null) {
synchronized (this) {
if(processApplicationScriptEngineResolver == null) {
processApplicationScriptEngineResolver = new ScriptEngineResolver(new ScriptEngineManager(getProcessApplicationClassloader()));
}
}
}
return processApplicationScriptEngineResolver.getScriptEngine(scriptEngineName, cache);
} | [
"public",
"ScriptEngine",
"getScriptEngineForName",
"(",
"String",
"scriptEngineName",
",",
"boolean",
"cache",
")",
"{",
"if",
"(",
"processApplicationScriptEngineResolver",
"==",
"null",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"processApplicationScriptEngineResolver",
"==",
"null",
")",
"{",
"processApplicationScriptEngineResolver",
"=",
"new",
"ScriptEngineResolver",
"(",
"new",
"ScriptEngineManager",
"(",
"getProcessApplicationClassloader",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"return",
"processApplicationScriptEngineResolver",
".",
"getScriptEngine",
"(",
"scriptEngineName",
",",
"cache",
")",
";",
"}"
] | <p>Returns an instance of {@link ScriptEngine} for the given <code>scriptEngineName</code>.</p>
<p>Iff the given parameter <code>cache</code> is set <code>true</code>,
then the instance {@link ScriptEngine} will be cached.</p>
@param scriptEngineName the name of the {@link ScriptEngine} to return
@param cache a boolean value which indicates whether the {@link ScriptEngine} should
be cached or not.
@return a {@link ScriptEngine} | [
"<p",
">",
"Returns",
"an",
"instance",
"of",
"{",
"@link",
"ScriptEngine",
"}",
"for",
"the",
"given",
"<code",
">",
"scriptEngineName<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/application/impl/ProcessApplicationScriptEnvironment.java#L57-L66 |
DDTH/ddth-dao | ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java | BaseDao.addProfiling | public static ProfilingRecord addProfiling(long execTimeMs, String command, long durationMs) {
"""
Adds a new profiling record.
@param execTimeMs
@param command
@return
"""
ProfilingRecord record = new ProfilingRecord(execTimeMs, command, durationMs);
List<ProfilingRecord> records = profilingRecords.get();
records.add(record);
while (records.size() > 100) {
records.remove(0);
}
return record;
} | java | public static ProfilingRecord addProfiling(long execTimeMs, String command, long durationMs) {
ProfilingRecord record = new ProfilingRecord(execTimeMs, command, durationMs);
List<ProfilingRecord> records = profilingRecords.get();
records.add(record);
while (records.size() > 100) {
records.remove(0);
}
return record;
} | [
"public",
"static",
"ProfilingRecord",
"addProfiling",
"(",
"long",
"execTimeMs",
",",
"String",
"command",
",",
"long",
"durationMs",
")",
"{",
"ProfilingRecord",
"record",
"=",
"new",
"ProfilingRecord",
"(",
"execTimeMs",
",",
"command",
",",
"durationMs",
")",
";",
"List",
"<",
"ProfilingRecord",
">",
"records",
"=",
"profilingRecords",
".",
"get",
"(",
")",
";",
"records",
".",
"add",
"(",
"record",
")",
";",
"while",
"(",
"records",
".",
"size",
"(",
")",
">",
"100",
")",
"{",
"records",
".",
"remove",
"(",
"0",
")",
";",
"}",
"return",
"record",
";",
"}"
] | Adds a new profiling record.
@param execTimeMs
@param command
@return | [
"Adds",
"a",
"new",
"profiling",
"record",
"."
] | train | https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/BaseDao.java#L63-L71 |
google/closure-compiler | src/com/google/javascript/jscomp/CollapseProperties.java | CollapseProperties.warnAboutNamespaceAliasing | private void warnAboutNamespaceAliasing(Name nameObj, Ref ref) {
"""
Reports a warning because a namespace was aliased.
@param nameObj A namespace that is being aliased
@param ref The reference that forced the alias
"""
compiler.report(JSError.make(ref.getNode(), UNSAFE_NAMESPACE_WARNING, nameObj.getFullName()));
} | java | private void warnAboutNamespaceAliasing(Name nameObj, Ref ref) {
compiler.report(JSError.make(ref.getNode(), UNSAFE_NAMESPACE_WARNING, nameObj.getFullName()));
} | [
"private",
"void",
"warnAboutNamespaceAliasing",
"(",
"Name",
"nameObj",
",",
"Ref",
"ref",
")",
"{",
"compiler",
".",
"report",
"(",
"JSError",
".",
"make",
"(",
"ref",
".",
"getNode",
"(",
")",
",",
"UNSAFE_NAMESPACE_WARNING",
",",
"nameObj",
".",
"getFullName",
"(",
")",
")",
")",
";",
"}"
] | Reports a warning because a namespace was aliased.
@param nameObj A namespace that is being aliased
@param ref The reference that forced the alias | [
"Reports",
"a",
"warning",
"because",
"a",
"namespace",
"was",
"aliased",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CollapseProperties.java#L224-L226 |
zaproxy/zaproxy | src/org/zaproxy/zap/control/AddOn.java | AddOn.calculateExtensionRunRequirements | public AddOnRunRequirements calculateExtensionRunRequirements(Extension extension, Collection<AddOn> availableAddOns) {
"""
Calculates the requirements to run the given {@code extension}, in the current ZAP and Java versions and with the given
{@code availableAddOns}.
<p>
If the extension depends on other add-ons, those add-ons are checked if are also runnable.
<p>
<strong>Note:</strong> All the given {@code availableAddOns} are expected to be loadable in the currently running ZAP
version, that is, the method {@code AddOn.canLoadInCurrentVersion()}, returns {@code true}.
@param extension the extension that will be checked
@param availableAddOns the add-ons available
@return the requirements to run the extension, and if not runnable the reason why it's not.
@since 2.4.0
@see AddOnRunRequirements#getExtensionRequirements()
"""
return calculateExtensionRunRequirements(extension.getClass().getCanonicalName(), availableAddOns);
} | java | public AddOnRunRequirements calculateExtensionRunRequirements(Extension extension, Collection<AddOn> availableAddOns) {
return calculateExtensionRunRequirements(extension.getClass().getCanonicalName(), availableAddOns);
} | [
"public",
"AddOnRunRequirements",
"calculateExtensionRunRequirements",
"(",
"Extension",
"extension",
",",
"Collection",
"<",
"AddOn",
">",
"availableAddOns",
")",
"{",
"return",
"calculateExtensionRunRequirements",
"(",
"extension",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
",",
"availableAddOns",
")",
";",
"}"
] | Calculates the requirements to run the given {@code extension}, in the current ZAP and Java versions and with the given
{@code availableAddOns}.
<p>
If the extension depends on other add-ons, those add-ons are checked if are also runnable.
<p>
<strong>Note:</strong> All the given {@code availableAddOns} are expected to be loadable in the currently running ZAP
version, that is, the method {@code AddOn.canLoadInCurrentVersion()}, returns {@code true}.
@param extension the extension that will be checked
@param availableAddOns the add-ons available
@return the requirements to run the extension, and if not runnable the reason why it's not.
@since 2.4.0
@see AddOnRunRequirements#getExtensionRequirements() | [
"Calculates",
"the",
"requirements",
"to",
"run",
"the",
"given",
"{",
"@code",
"extension",
"}",
"in",
"the",
"current",
"ZAP",
"and",
"Java",
"versions",
"and",
"with",
"the",
"given",
"{",
"@code",
"availableAddOns",
"}",
".",
"<p",
">",
"If",
"the",
"extension",
"depends",
"on",
"other",
"add",
"-",
"ons",
"those",
"add",
"-",
"ons",
"are",
"checked",
"if",
"are",
"also",
"runnable",
".",
"<p",
">",
"<strong",
">",
"Note",
":",
"<",
"/",
"strong",
">",
"All",
"the",
"given",
"{",
"@code",
"availableAddOns",
"}",
"are",
"expected",
"to",
"be",
"loadable",
"in",
"the",
"currently",
"running",
"ZAP",
"version",
"that",
"is",
"the",
"method",
"{",
"@code",
"AddOn",
".",
"canLoadInCurrentVersion",
"()",
"}",
"returns",
"{",
"@code",
"true",
"}",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/control/AddOn.java#L1353-L1355 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/io/async/AsyncLibrary.java | AsyncLibrary.getIOException | public static IOException getIOException(String desc, int code) {
"""
Get an IOException instance for the input description and native
AIO return coded.
@param desc
@param code
@return IOException
"""
return new IOException(desc + ErrorMessageCache.get(code));
} | java | public static IOException getIOException(String desc, int code) {
return new IOException(desc + ErrorMessageCache.get(code));
} | [
"public",
"static",
"IOException",
"getIOException",
"(",
"String",
"desc",
",",
"int",
"code",
")",
"{",
"return",
"new",
"IOException",
"(",
"desc",
"+",
"ErrorMessageCache",
".",
"get",
"(",
"code",
")",
")",
";",
"}"
] | Get an IOException instance for the input description and native
AIO return coded.
@param desc
@param code
@return IOException | [
"Get",
"an",
"IOException",
"instance",
"for",
"the",
"input",
"description",
"and",
"native",
"AIO",
"return",
"coded",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/io/async/AsyncLibrary.java#L816-L818 |
Impetus/Kundera | src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBObjectMapper.java | CouchDBObjectMapper.getObjectFromJson | static Object getObjectFromJson(JsonObject jsonObj, Class clazz, Set<Attribute> columns) {
"""
Gets the object from json.
@param jsonObj
the json obj
@param clazz
the clazz
@param columns
the columns
@return the object from json
"""
Object obj = KunderaCoreUtils.createNewInstance(clazz);
for (Attribute column : columns)
{
JsonElement value = jsonObj.get(((AbstractAttribute) column).getJPAColumnName());
setFieldValue(obj, column, value);
}
return obj;
} | java | static Object getObjectFromJson(JsonObject jsonObj, Class clazz, Set<Attribute> columns)
{
Object obj = KunderaCoreUtils.createNewInstance(clazz);
for (Attribute column : columns)
{
JsonElement value = jsonObj.get(((AbstractAttribute) column).getJPAColumnName());
setFieldValue(obj, column, value);
}
return obj;
} | [
"static",
"Object",
"getObjectFromJson",
"(",
"JsonObject",
"jsonObj",
",",
"Class",
"clazz",
",",
"Set",
"<",
"Attribute",
">",
"columns",
")",
"{",
"Object",
"obj",
"=",
"KunderaCoreUtils",
".",
"createNewInstance",
"(",
"clazz",
")",
";",
"for",
"(",
"Attribute",
"column",
":",
"columns",
")",
"{",
"JsonElement",
"value",
"=",
"jsonObj",
".",
"get",
"(",
"(",
"(",
"AbstractAttribute",
")",
"column",
")",
".",
"getJPAColumnName",
"(",
")",
")",
";",
"setFieldValue",
"(",
"obj",
",",
"column",
",",
"value",
")",
";",
"}",
"return",
"obj",
";",
"}"
] | Gets the object from json.
@param jsonObj
the json obj
@param clazz
the clazz
@param columns
the columns
@return the object from json | [
"Gets",
"the",
"object",
"from",
"json",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBObjectMapper.java#L420-L429 |
netty/netty | common/src/main/java/io/netty/util/AsciiString.java | AsciiString.trim | public AsciiString trim() {
"""
Duplicates this string removing white space characters from the beginning and end of the
string, without copying.
@return a new string with characters {@code <= \\u0020} removed from the beginning and the end.
"""
int start = arrayOffset(), last = arrayOffset() + length() - 1;
int end = last;
while (start <= end && value[start] <= ' ') {
start++;
}
while (end >= start && value[end] <= ' ') {
end--;
}
if (start == 0 && end == last) {
return this;
}
return new AsciiString(value, start, end - start + 1, false);
} | java | public AsciiString trim() {
int start = arrayOffset(), last = arrayOffset() + length() - 1;
int end = last;
while (start <= end && value[start] <= ' ') {
start++;
}
while (end >= start && value[end] <= ' ') {
end--;
}
if (start == 0 && end == last) {
return this;
}
return new AsciiString(value, start, end - start + 1, false);
} | [
"public",
"AsciiString",
"trim",
"(",
")",
"{",
"int",
"start",
"=",
"arrayOffset",
"(",
")",
",",
"last",
"=",
"arrayOffset",
"(",
")",
"+",
"length",
"(",
")",
"-",
"1",
";",
"int",
"end",
"=",
"last",
";",
"while",
"(",
"start",
"<=",
"end",
"&&",
"value",
"[",
"start",
"]",
"<=",
"'",
"'",
")",
"{",
"start",
"++",
";",
"}",
"while",
"(",
"end",
">=",
"start",
"&&",
"value",
"[",
"end",
"]",
"<=",
"'",
"'",
")",
"{",
"end",
"--",
";",
"}",
"if",
"(",
"start",
"==",
"0",
"&&",
"end",
"==",
"last",
")",
"{",
"return",
"this",
";",
"}",
"return",
"new",
"AsciiString",
"(",
"value",
",",
"start",
",",
"end",
"-",
"start",
"+",
"1",
",",
"false",
")",
";",
"}"
] | Duplicates this string removing white space characters from the beginning and end of the
string, without copying.
@return a new string with characters {@code <= \\u0020} removed from the beginning and the end. | [
"Duplicates",
"this",
"string",
"removing",
"white",
"space",
"characters",
"from",
"the",
"beginning",
"and",
"end",
"of",
"the",
"string",
"without",
"copying",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/AsciiString.java#L1017-L1030 |
minio/minio-java | api/src/main/java/io/minio/MinioClient.java | MinioClient.putObject | public void putObject(String bucketName, String objectName, ServerSideEncryption sse, String fileName)
throws InvalidBucketNameException, NoSuchAlgorithmException, IOException,
InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException,
InternalException, InvalidArgumentException, InsufficientDataException {
"""
Uploads given file as object in given bucket and encrypt with a sse key.
<p>
If the object is larger than 5MB, the client will automatically use a multipart session.
</p>
<p>
If the session fails, the user may attempt to re-upload the object by attempting to create
the exact same object again.
</p>
<p>
If the multipart session fails, we abort the uploaded parts automatically.
</p>
@param bucketName Bucket name.
@param objectName Object name to create in the bucket.
@param fileName File name to upload.
@param sse encryption metadata.
@throws InvalidBucketNameException upon invalid bucket name is given
@throws NoSuchAlgorithmException
upon requested algorithm was not found during signature calculation
@throws IOException upon connection error
@throws InvalidKeyException
upon an invalid access key or secret key
@throws NoResponseException upon no response from server
@throws XmlPullParserException upon parsing response xml
@throws ErrorResponseException upon unsuccessful execution
@throws InternalException upon internal library error
@throws InvalidArgumentException upon invalid value is passed to a method.
@throws InsufficientDataException upon getting EOFException while reading given
@see #putObject(String bucketName, String objectName, String fileName)
"""
if (sse.getType() == ServerSideEncryption.Type.SSE_C && !this.baseUrl.isHttps()) {
throw new InvalidArgumentException("SSE_C operations must be performed over a secure connection.");
} else if (sse.getType() == ServerSideEncryption.Type.SSE_KMS && !this.baseUrl.isHttps()) {
throw new InvalidArgumentException("SSE_KMS operations must be performed over a secure connection.");
}
if (fileName == null || "".equals(fileName)) {
throw new InvalidArgumentException("empty file name is not allowed");
}
Path filePath = Paths.get(fileName);
if (!Files.isRegularFile(filePath)) {
throw new InvalidArgumentException("'" + fileName + "': not a regular file");
}
String contentType = Files.probeContentType(filePath);
long size = Files.size(filePath);
RandomAccessFile file = new RandomAccessFile(filePath.toFile(), "r");
// Set the contentType
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Content-Type", contentType);
try {
putObject(bucketName, objectName, size, file, headerMap, sse);
} finally {
file.close();
}
} | java | public void putObject(String bucketName, String objectName, ServerSideEncryption sse, String fileName)
throws InvalidBucketNameException, NoSuchAlgorithmException, IOException,
InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException,
InternalException, InvalidArgumentException, InsufficientDataException {
if (sse.getType() == ServerSideEncryption.Type.SSE_C && !this.baseUrl.isHttps()) {
throw new InvalidArgumentException("SSE_C operations must be performed over a secure connection.");
} else if (sse.getType() == ServerSideEncryption.Type.SSE_KMS && !this.baseUrl.isHttps()) {
throw new InvalidArgumentException("SSE_KMS operations must be performed over a secure connection.");
}
if (fileName == null || "".equals(fileName)) {
throw new InvalidArgumentException("empty file name is not allowed");
}
Path filePath = Paths.get(fileName);
if (!Files.isRegularFile(filePath)) {
throw new InvalidArgumentException("'" + fileName + "': not a regular file");
}
String contentType = Files.probeContentType(filePath);
long size = Files.size(filePath);
RandomAccessFile file = new RandomAccessFile(filePath.toFile(), "r");
// Set the contentType
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Content-Type", contentType);
try {
putObject(bucketName, objectName, size, file, headerMap, sse);
} finally {
file.close();
}
} | [
"public",
"void",
"putObject",
"(",
"String",
"bucketName",
",",
"String",
"objectName",
",",
"ServerSideEncryption",
"sse",
",",
"String",
"fileName",
")",
"throws",
"InvalidBucketNameException",
",",
"NoSuchAlgorithmException",
",",
"IOException",
",",
"InvalidKeyException",
",",
"NoResponseException",
",",
"XmlPullParserException",
",",
"ErrorResponseException",
",",
"InternalException",
",",
"InvalidArgumentException",
",",
"InsufficientDataException",
"{",
"if",
"(",
"sse",
".",
"getType",
"(",
")",
"==",
"ServerSideEncryption",
".",
"Type",
".",
"SSE_C",
"&&",
"!",
"this",
".",
"baseUrl",
".",
"isHttps",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"SSE_C operations must be performed over a secure connection.\"",
")",
";",
"}",
"else",
"if",
"(",
"sse",
".",
"getType",
"(",
")",
"==",
"ServerSideEncryption",
".",
"Type",
".",
"SSE_KMS",
"&&",
"!",
"this",
".",
"baseUrl",
".",
"isHttps",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"SSE_KMS operations must be performed over a secure connection.\"",
")",
";",
"}",
"if",
"(",
"fileName",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"fileName",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"empty file name is not allowed\"",
")",
";",
"}",
"Path",
"filePath",
"=",
"Paths",
".",
"get",
"(",
"fileName",
")",
";",
"if",
"(",
"!",
"Files",
".",
"isRegularFile",
"(",
"filePath",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"'\"",
"+",
"fileName",
"+",
"\"': not a regular file\"",
")",
";",
"}",
"String",
"contentType",
"=",
"Files",
".",
"probeContentType",
"(",
"filePath",
")",
";",
"long",
"size",
"=",
"Files",
".",
"size",
"(",
"filePath",
")",
";",
"RandomAccessFile",
"file",
"=",
"new",
"RandomAccessFile",
"(",
"filePath",
".",
"toFile",
"(",
")",
",",
"\"r\"",
")",
";",
"// Set the contentType",
"Map",
"<",
"String",
",",
"String",
">",
"headerMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"headerMap",
".",
"put",
"(",
"\"Content-Type\"",
",",
"contentType",
")",
";",
"try",
"{",
"putObject",
"(",
"bucketName",
",",
"objectName",
",",
"size",
",",
"file",
",",
"headerMap",
",",
"sse",
")",
";",
"}",
"finally",
"{",
"file",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Uploads given file as object in given bucket and encrypt with a sse key.
<p>
If the object is larger than 5MB, the client will automatically use a multipart session.
</p>
<p>
If the session fails, the user may attempt to re-upload the object by attempting to create
the exact same object again.
</p>
<p>
If the multipart session fails, we abort the uploaded parts automatically.
</p>
@param bucketName Bucket name.
@param objectName Object name to create in the bucket.
@param fileName File name to upload.
@param sse encryption metadata.
@throws InvalidBucketNameException upon invalid bucket name is given
@throws NoSuchAlgorithmException
upon requested algorithm was not found during signature calculation
@throws IOException upon connection error
@throws InvalidKeyException
upon an invalid access key or secret key
@throws NoResponseException upon no response from server
@throws XmlPullParserException upon parsing response xml
@throws ErrorResponseException upon unsuccessful execution
@throws InternalException upon internal library error
@throws InvalidArgumentException upon invalid value is passed to a method.
@throws InsufficientDataException upon getting EOFException while reading given
@see #putObject(String bucketName, String objectName, String fileName) | [
"Uploads",
"given",
"file",
"as",
"object",
"in",
"given",
"bucket",
"and",
"encrypt",
"with",
"a",
"sse",
"key",
".",
"<p",
">",
"If",
"the",
"object",
"is",
"larger",
"than",
"5MB",
"the",
"client",
"will",
"automatically",
"use",
"a",
"multipart",
"session",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"the",
"session",
"fails",
"the",
"user",
"may",
"attempt",
"to",
"re",
"-",
"upload",
"the",
"object",
"by",
"attempting",
"to",
"create",
"the",
"exact",
"same",
"object",
"again",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"the",
"multipart",
"session",
"fails",
"we",
"abort",
"the",
"uploaded",
"parts",
"automatically",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L3860-L3894 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.