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
|
---|---|---|---|---|---|---|---|---|---|---|
berkesa/datatree | src/main/java/io/datatree/Tree.java | Tree.putMap | public Tree putMap(String path) {
"""
Associates the specified Map (~= JSON object) container with the
specified path. If the structure previously contained a mapping for the
path, the old value is replaced. Sample code:<br>
<br>
Tree node = new Tree();<br>
Tree map = node.putMap("a.b.c");<br>
map.put("d.e.f", 123);
@param path
path with which the specified Map is to be associated
@return Tree of the new Map
"""
return putObjectInternal(path, new LinkedHashMap<String, Object>(), false);
} | java | public Tree putMap(String path) {
return putObjectInternal(path, new LinkedHashMap<String, Object>(), false);
} | [
"public",
"Tree",
"putMap",
"(",
"String",
"path",
")",
"{",
"return",
"putObjectInternal",
"(",
"path",
",",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
",",
"false",
")",
";",
"}"
] | Associates the specified Map (~= JSON object) container with the
specified path. If the structure previously contained a mapping for the
path, the old value is replaced. Sample code:<br>
<br>
Tree node = new Tree();<br>
Tree map = node.putMap("a.b.c");<br>
map.put("d.e.f", 123);
@param path
path with which the specified Map is to be associated
@return Tree of the new Map | [
"Associates",
"the",
"specified",
"Map",
"(",
"~",
"=",
"JSON",
"object",
")",
"container",
"with",
"the",
"specified",
"path",
".",
"If",
"the",
"structure",
"previously",
"contained",
"a",
"mapping",
"for",
"the",
"path",
"the",
"old",
"value",
"is",
"replaced",
".",
"Sample",
"code",
":",
"<br",
">",
"<br",
">",
"Tree",
"node",
"=",
"new",
"Tree",
"()",
";",
"<br",
">",
"Tree",
"map",
"=",
"node",
".",
"putMap",
"(",
"a",
".",
"b",
".",
"c",
")",
";",
"<br",
">",
"map",
".",
"put",
"(",
"d",
".",
"e",
".",
"f",
"123",
")",
";"
] | train | https://github.com/berkesa/datatree/blob/79aea9b45c7b46ab28af0a09310bc01c421c6b3a/src/main/java/io/datatree/Tree.java#L2010-L2012 |
j256/ormlite-android | src/main/java/com/j256/ormlite/android/apptools/OpenHelperManager.java | OpenHelperManager.getHelper | @Deprecated
public static synchronized OrmLiteSqliteOpenHelper getHelper(Context context) {
"""
<p>
Similar to {@link #getHelper(Context, Class)} (which is recommended) except we have to find the helper class
through other means. This method requires that the Context be a class that extends one of ORMLite's Android base
classes such as {@link OrmLiteBaseActivity}. Either that or the helper class needs to be set in the strings.xml.
</p>
<p>
To find the helper class, this does the following:
</p>
<ol>
<li>If the class has been set with a call to {@link #setOpenHelperClass(Class)}, it will be used to construct a
helper.</li>
<li>If the resource class name is configured in the strings.xml file it will be used.</li>
<li>The context class hierarchy is walked looking at the generic parameters for a class extending
OrmLiteSqliteOpenHelper. This is used by the {@link OrmLiteBaseActivity} and other base classes.</li>
<li>An exception is thrown saying that it was not able to set the helper class.</li>
</ol>
@deprecated Should use {@link #getHelper(Context, Class)}
"""
if (helperClass == null) {
if (context == null) {
throw new IllegalArgumentException("context argument is null");
}
Context appContext = context.getApplicationContext();
innerSetHelperClass(lookupHelperClass(appContext, context.getClass()));
}
return loadHelper(context, helperClass);
} | java | @Deprecated
public static synchronized OrmLiteSqliteOpenHelper getHelper(Context context) {
if (helperClass == null) {
if (context == null) {
throw new IllegalArgumentException("context argument is null");
}
Context appContext = context.getApplicationContext();
innerSetHelperClass(lookupHelperClass(appContext, context.getClass()));
}
return loadHelper(context, helperClass);
} | [
"@",
"Deprecated",
"public",
"static",
"synchronized",
"OrmLiteSqliteOpenHelper",
"getHelper",
"(",
"Context",
"context",
")",
"{",
"if",
"(",
"helperClass",
"==",
"null",
")",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"context argument is null\"",
")",
";",
"}",
"Context",
"appContext",
"=",
"context",
".",
"getApplicationContext",
"(",
")",
";",
"innerSetHelperClass",
"(",
"lookupHelperClass",
"(",
"appContext",
",",
"context",
".",
"getClass",
"(",
")",
")",
")",
";",
"}",
"return",
"loadHelper",
"(",
"context",
",",
"helperClass",
")",
";",
"}"
] | <p>
Similar to {@link #getHelper(Context, Class)} (which is recommended) except we have to find the helper class
through other means. This method requires that the Context be a class that extends one of ORMLite's Android base
classes such as {@link OrmLiteBaseActivity}. Either that or the helper class needs to be set in the strings.xml.
</p>
<p>
To find the helper class, this does the following:
</p>
<ol>
<li>If the class has been set with a call to {@link #setOpenHelperClass(Class)}, it will be used to construct a
helper.</li>
<li>If the resource class name is configured in the strings.xml file it will be used.</li>
<li>The context class hierarchy is walked looking at the generic parameters for a class extending
OrmLiteSqliteOpenHelper. This is used by the {@link OrmLiteBaseActivity} and other base classes.</li>
<li>An exception is thrown saying that it was not able to set the helper class.</li>
</ol>
@deprecated Should use {@link #getHelper(Context, Class)} | [
"<p",
">",
"Similar",
"to",
"{",
"@link",
"#getHelper",
"(",
"Context",
"Class",
")",
"}",
"(",
"which",
"is",
"recommended",
")",
"except",
"we",
"have",
"to",
"find",
"the",
"helper",
"class",
"through",
"other",
"means",
".",
"This",
"method",
"requires",
"that",
"the",
"Context",
"be",
"a",
"class",
"that",
"extends",
"one",
"of",
"ORMLite",
"s",
"Android",
"base",
"classes",
"such",
"as",
"{",
"@link",
"OrmLiteBaseActivity",
"}",
".",
"Either",
"that",
"or",
"the",
"helper",
"class",
"needs",
"to",
"be",
"set",
"in",
"the",
"strings",
".",
"xml",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/j256/ormlite-android/blob/e82327a868ae242f994730fe2389f79684d7bcab/src/main/java/com/j256/ormlite/android/apptools/OpenHelperManager.java#L103-L113 |
lettuce-io/lettuce-core | src/main/java/io/lettuce/core/dynamic/support/ClassTypeInformation.java | ClassTypeInformation.getTypeVariableMap | private static Map<TypeVariable<?>, Type> getTypeVariableMap(Class<?> type) {
"""
Little helper to allow us to create a generified map, actually just to satisfy the compiler.
@param type must not be {@literal null}.
@return
"""
return getTypeVariableMap(type, new HashSet<Type>());
} | java | private static Map<TypeVariable<?>, Type> getTypeVariableMap(Class<?> type) {
return getTypeVariableMap(type, new HashSet<Type>());
} | [
"private",
"static",
"Map",
"<",
"TypeVariable",
"<",
"?",
">",
",",
"Type",
">",
"getTypeVariableMap",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"getTypeVariableMap",
"(",
"type",
",",
"new",
"HashSet",
"<",
"Type",
">",
"(",
")",
")",
";",
"}"
] | Little helper to allow us to create a generified map, actually just to satisfy the compiler.
@param type must not be {@literal null}.
@return | [
"Little",
"helper",
"to",
"allow",
"us",
"to",
"create",
"a",
"generified",
"map",
"actually",
"just",
"to",
"satisfy",
"the",
"compiler",
"."
] | train | https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/dynamic/support/ClassTypeInformation.java#L132-L134 |
maxirosson/jdroid-android | jdroid-android-google-maps/src/main/java/com/jdroid/android/google/maps/GoogleRouteParser.java | GoogleRouteParser.decodePolyLine | private List<GeoLocation> decodePolyLine(String poly) {
"""
Decode a polyline string into a list of GeoLocations. From
https://developers.google.com/maps/documentation/directions/?hl=es#Limits
@param poly polyline encoded string to decode.
@return the list of GeoLocations represented by this polystring.
"""
int len = poly.length();
int index = 0;
List<GeoLocation> decoded = new ArrayList<>();
int lat = 0;
int lng = 0;
while (index < len) {
int b;
int shift = 0;
int result = 0;
do {
b = poly.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
lat += dlat;
shift = 0;
result = 0;
do {
b = poly.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
lng += dlng;
decoded.add(new GeoLocation(lat / 1E5, lng / 1E5));
}
return decoded;
} | java | private List<GeoLocation> decodePolyLine(String poly) {
int len = poly.length();
int index = 0;
List<GeoLocation> decoded = new ArrayList<>();
int lat = 0;
int lng = 0;
while (index < len) {
int b;
int shift = 0;
int result = 0;
do {
b = poly.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
lat += dlat;
shift = 0;
result = 0;
do {
b = poly.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
lng += dlng;
decoded.add(new GeoLocation(lat / 1E5, lng / 1E5));
}
return decoded;
} | [
"private",
"List",
"<",
"GeoLocation",
">",
"decodePolyLine",
"(",
"String",
"poly",
")",
"{",
"int",
"len",
"=",
"poly",
".",
"length",
"(",
")",
";",
"int",
"index",
"=",
"0",
";",
"List",
"<",
"GeoLocation",
">",
"decoded",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"int",
"lat",
"=",
"0",
";",
"int",
"lng",
"=",
"0",
";",
"while",
"(",
"index",
"<",
"len",
")",
"{",
"int",
"b",
";",
"int",
"shift",
"=",
"0",
";",
"int",
"result",
"=",
"0",
";",
"do",
"{",
"b",
"=",
"poly",
".",
"charAt",
"(",
"index",
"++",
")",
"-",
"63",
";",
"result",
"|=",
"(",
"b",
"&",
"0x1f",
")",
"<<",
"shift",
";",
"shift",
"+=",
"5",
";",
"}",
"while",
"(",
"b",
">=",
"0x20",
")",
";",
"int",
"dlat",
"=",
"(",
"result",
"&",
"1",
")",
"!=",
"0",
"?",
"~",
"(",
"result",
">>",
"1",
")",
":",
"(",
"result",
">>",
"1",
")",
";",
"lat",
"+=",
"dlat",
";",
"shift",
"=",
"0",
";",
"result",
"=",
"0",
";",
"do",
"{",
"b",
"=",
"poly",
".",
"charAt",
"(",
"index",
"++",
")",
"-",
"63",
";",
"result",
"|=",
"(",
"b",
"&",
"0x1f",
")",
"<<",
"shift",
";",
"shift",
"+=",
"5",
";",
"}",
"while",
"(",
"b",
">=",
"0x20",
")",
";",
"int",
"dlng",
"=",
"(",
"result",
"&",
"1",
")",
"!=",
"0",
"?",
"~",
"(",
"result",
">>",
"1",
")",
":",
"(",
"result",
">>",
"1",
")",
";",
"lng",
"+=",
"dlng",
";",
"decoded",
".",
"add",
"(",
"new",
"GeoLocation",
"(",
"lat",
"/",
"1E5",
",",
"lng",
"/",
"1E5",
")",
")",
";",
"}",
"return",
"decoded",
";",
"}"
] | Decode a polyline string into a list of GeoLocations. From
https://developers.google.com/maps/documentation/directions/?hl=es#Limits
@param poly polyline encoded string to decode.
@return the list of GeoLocations represented by this polystring. | [
"Decode",
"a",
"polyline",
"string",
"into",
"a",
"list",
"of",
"GeoLocations",
".",
"From",
"https",
":",
"//",
"developers",
".",
"google",
".",
"com",
"/",
"maps",
"/",
"documentation",
"/",
"directions",
"/",
"?hl",
"=",
"es#Limits"
] | train | https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-google-maps/src/main/java/com/jdroid/android/google/maps/GoogleRouteParser.java#L55-L88 |
rzwitserloot/lombok | src/core/lombok/eclipse/handlers/HandleGetter.java | HandleGetter.generateGetterForField | public void generateGetterForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean lazy, List<Annotation> onMethod) {
"""
Generates a getter on the stated field.
Used by {@link HandleData}.
The difference between this call and the handle method is as follows:
If there is a {@code lombok.Getter} annotation on the field, it is used and the
same rules apply (e.g. warning if the method already exists, stated access level applies).
If not, the getter is still generated if it isn't already there, though there will not
be a warning if its already there. The default access level is used.
"""
if (hasAnnotation(Getter.class, fieldNode)) {
//The annotation will make it happen, so we can skip it.
return;
}
createGetterForField(level, fieldNode, fieldNode, pos, false, lazy, onMethod);
} | java | public void generateGetterForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean lazy, List<Annotation> onMethod) {
if (hasAnnotation(Getter.class, fieldNode)) {
//The annotation will make it happen, so we can skip it.
return;
}
createGetterForField(level, fieldNode, fieldNode, pos, false, lazy, onMethod);
} | [
"public",
"void",
"generateGetterForField",
"(",
"EclipseNode",
"fieldNode",
",",
"ASTNode",
"pos",
",",
"AccessLevel",
"level",
",",
"boolean",
"lazy",
",",
"List",
"<",
"Annotation",
">",
"onMethod",
")",
"{",
"if",
"(",
"hasAnnotation",
"(",
"Getter",
".",
"class",
",",
"fieldNode",
")",
")",
"{",
"//The annotation will make it happen, so we can skip it.",
"return",
";",
"}",
"createGetterForField",
"(",
"level",
",",
"fieldNode",
",",
"fieldNode",
",",
"pos",
",",
"false",
",",
"lazy",
",",
"onMethod",
")",
";",
"}"
] | Generates a getter on the stated field.
Used by {@link HandleData}.
The difference between this call and the handle method is as follows:
If there is a {@code lombok.Getter} annotation on the field, it is used and the
same rules apply (e.g. warning if the method already exists, stated access level applies).
If not, the getter is still generated if it isn't already there, though there will not
be a warning if its already there. The default access level is used. | [
"Generates",
"a",
"getter",
"on",
"the",
"stated",
"field",
"."
] | train | https://github.com/rzwitserloot/lombok/blob/75601240760bd81ff95fcde7a1b8185769ce64e8/src/core/lombok/eclipse/handlers/HandleGetter.java#L125-L132 |
igniterealtime/Smack | smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java | HttpFileUploadManager.requestSlot | public Slot requestSlot(String filename, long fileSize, String contentType, DomainBareJid uploadServiceAddress)
throws SmackException, InterruptedException, XMPPException.XMPPErrorException {
"""
Request a new upload slot with optional content type from custom upload service.
When you get slot you should upload file to PUT URL and share GET URL.
Note that this is a synchronous call -- Smack must wait for the server response.
@param filename name of file to be uploaded
@param fileSize file size in bytes.
@param contentType file content-type or null
@param uploadServiceAddress the address of the upload service to use or null for default one
@return file upload Slot in case of success
@throws IllegalArgumentException if fileSize is less than or equal to zero or greater than the maximum size
supported by the service.
@throws SmackException
@throws InterruptedException
@throws XMPPException.XMPPErrorException
"""
final XMPPConnection connection = connection();
final UploadService defaultUploadService = this.defaultUploadService;
// The upload service we are going to use.
UploadService uploadService;
if (uploadServiceAddress == null) {
uploadService = defaultUploadService;
} else {
if (defaultUploadService != null && defaultUploadService.getAddress().equals(uploadServiceAddress)) {
// Avoid performing a service discovery if we already know about the given service.
uploadService = defaultUploadService;
} else {
DiscoverInfo discoverInfo = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(uploadServiceAddress);
if (!containsHttpFileUploadNamespace(discoverInfo)) {
throw new IllegalArgumentException("There is no HTTP upload service running at the given address '"
+ uploadServiceAddress + '\'');
}
uploadService = uploadServiceFrom(discoverInfo);
}
}
if (uploadService == null) {
throw new SmackException.SmackMessageException("No upload service specified and also none discovered.");
}
if (!uploadService.acceptsFileOfSize(fileSize)) {
throw new IllegalArgumentException(
"Requested file size " + fileSize + " is greater than max allowed size " + uploadService.getMaxFileSize());
}
SlotRequest slotRequest;
switch (uploadService.getVersion()) {
case v0_3:
slotRequest = new SlotRequest(uploadService.getAddress(), filename, fileSize, contentType);
break;
case v0_2:
slotRequest = new SlotRequest_V0_2(uploadService.getAddress(), filename, fileSize, contentType);
break;
default:
throw new AssertionError();
}
return connection.createStanzaCollectorAndSend(slotRequest).nextResultOrThrow();
} | java | public Slot requestSlot(String filename, long fileSize, String contentType, DomainBareJid uploadServiceAddress)
throws SmackException, InterruptedException, XMPPException.XMPPErrorException {
final XMPPConnection connection = connection();
final UploadService defaultUploadService = this.defaultUploadService;
// The upload service we are going to use.
UploadService uploadService;
if (uploadServiceAddress == null) {
uploadService = defaultUploadService;
} else {
if (defaultUploadService != null && defaultUploadService.getAddress().equals(uploadServiceAddress)) {
// Avoid performing a service discovery if we already know about the given service.
uploadService = defaultUploadService;
} else {
DiscoverInfo discoverInfo = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(uploadServiceAddress);
if (!containsHttpFileUploadNamespace(discoverInfo)) {
throw new IllegalArgumentException("There is no HTTP upload service running at the given address '"
+ uploadServiceAddress + '\'');
}
uploadService = uploadServiceFrom(discoverInfo);
}
}
if (uploadService == null) {
throw new SmackException.SmackMessageException("No upload service specified and also none discovered.");
}
if (!uploadService.acceptsFileOfSize(fileSize)) {
throw new IllegalArgumentException(
"Requested file size " + fileSize + " is greater than max allowed size " + uploadService.getMaxFileSize());
}
SlotRequest slotRequest;
switch (uploadService.getVersion()) {
case v0_3:
slotRequest = new SlotRequest(uploadService.getAddress(), filename, fileSize, contentType);
break;
case v0_2:
slotRequest = new SlotRequest_V0_2(uploadService.getAddress(), filename, fileSize, contentType);
break;
default:
throw new AssertionError();
}
return connection.createStanzaCollectorAndSend(slotRequest).nextResultOrThrow();
} | [
"public",
"Slot",
"requestSlot",
"(",
"String",
"filename",
",",
"long",
"fileSize",
",",
"String",
"contentType",
",",
"DomainBareJid",
"uploadServiceAddress",
")",
"throws",
"SmackException",
",",
"InterruptedException",
",",
"XMPPException",
".",
"XMPPErrorException",
"{",
"final",
"XMPPConnection",
"connection",
"=",
"connection",
"(",
")",
";",
"final",
"UploadService",
"defaultUploadService",
"=",
"this",
".",
"defaultUploadService",
";",
"// The upload service we are going to use.",
"UploadService",
"uploadService",
";",
"if",
"(",
"uploadServiceAddress",
"==",
"null",
")",
"{",
"uploadService",
"=",
"defaultUploadService",
";",
"}",
"else",
"{",
"if",
"(",
"defaultUploadService",
"!=",
"null",
"&&",
"defaultUploadService",
".",
"getAddress",
"(",
")",
".",
"equals",
"(",
"uploadServiceAddress",
")",
")",
"{",
"// Avoid performing a service discovery if we already know about the given service.",
"uploadService",
"=",
"defaultUploadService",
";",
"}",
"else",
"{",
"DiscoverInfo",
"discoverInfo",
"=",
"ServiceDiscoveryManager",
".",
"getInstanceFor",
"(",
"connection",
")",
".",
"discoverInfo",
"(",
"uploadServiceAddress",
")",
";",
"if",
"(",
"!",
"containsHttpFileUploadNamespace",
"(",
"discoverInfo",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"There is no HTTP upload service running at the given address '\"",
"+",
"uploadServiceAddress",
"+",
"'",
"'",
")",
";",
"}",
"uploadService",
"=",
"uploadServiceFrom",
"(",
"discoverInfo",
")",
";",
"}",
"}",
"if",
"(",
"uploadService",
"==",
"null",
")",
"{",
"throw",
"new",
"SmackException",
".",
"SmackMessageException",
"(",
"\"No upload service specified and also none discovered.\"",
")",
";",
"}",
"if",
"(",
"!",
"uploadService",
".",
"acceptsFileOfSize",
"(",
"fileSize",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Requested file size \"",
"+",
"fileSize",
"+",
"\" is greater than max allowed size \"",
"+",
"uploadService",
".",
"getMaxFileSize",
"(",
")",
")",
";",
"}",
"SlotRequest",
"slotRequest",
";",
"switch",
"(",
"uploadService",
".",
"getVersion",
"(",
")",
")",
"{",
"case",
"v0_3",
":",
"slotRequest",
"=",
"new",
"SlotRequest",
"(",
"uploadService",
".",
"getAddress",
"(",
")",
",",
"filename",
",",
"fileSize",
",",
"contentType",
")",
";",
"break",
";",
"case",
"v0_2",
":",
"slotRequest",
"=",
"new",
"SlotRequest_V0_2",
"(",
"uploadService",
".",
"getAddress",
"(",
")",
",",
"filename",
",",
"fileSize",
",",
"contentType",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"AssertionError",
"(",
")",
";",
"}",
"return",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"slotRequest",
")",
".",
"nextResultOrThrow",
"(",
")",
";",
"}"
] | Request a new upload slot with optional content type from custom upload service.
When you get slot you should upload file to PUT URL and share GET URL.
Note that this is a synchronous call -- Smack must wait for the server response.
@param filename name of file to be uploaded
@param fileSize file size in bytes.
@param contentType file content-type or null
@param uploadServiceAddress the address of the upload service to use or null for default one
@return file upload Slot in case of success
@throws IllegalArgumentException if fileSize is less than or equal to zero or greater than the maximum size
supported by the service.
@throws SmackException
@throws InterruptedException
@throws XMPPException.XMPPErrorException | [
"Request",
"a",
"new",
"upload",
"slot",
"with",
"optional",
"content",
"type",
"from",
"custom",
"upload",
"service",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java#L328-L374 |
couchbase/couchbase-lite-java-core | src/main/java/com/couchbase/lite/replicator/PusherInternal.java | PusherInternal.findCommonAncestor | private static int findCommonAncestor(RevisionInternal rev, List<String> possibleRevIDs) {
"""
Given a revision and an array of revIDs, finds the latest common ancestor revID
and returns its generation #. If there is none, returns 0.
<p/>
int CBLFindCommonAncestor(CBL_Revision* rev, NSArray* possibleRevIDs) in CBLRestPusher.m
"""
if (possibleRevIDs == null || possibleRevIDs.size() == 0) {
return 0;
}
List<String> history = Database.parseCouchDBRevisionHistory(rev.getProperties());
//rev is missing _revisions property
assert (history != null);
boolean changed = history.retainAll(possibleRevIDs);
String ancestorID = history.size() == 0 ? null : history.get(0);
if (ancestorID == null) {
return 0;
}
int generation = RevisionUtils.parseRevIDNumber(ancestorID);
return generation;
} | java | private static int findCommonAncestor(RevisionInternal rev, List<String> possibleRevIDs) {
if (possibleRevIDs == null || possibleRevIDs.size() == 0) {
return 0;
}
List<String> history = Database.parseCouchDBRevisionHistory(rev.getProperties());
//rev is missing _revisions property
assert (history != null);
boolean changed = history.retainAll(possibleRevIDs);
String ancestorID = history.size() == 0 ? null : history.get(0);
if (ancestorID == null) {
return 0;
}
int generation = RevisionUtils.parseRevIDNumber(ancestorID);
return generation;
} | [
"private",
"static",
"int",
"findCommonAncestor",
"(",
"RevisionInternal",
"rev",
",",
"List",
"<",
"String",
">",
"possibleRevIDs",
")",
"{",
"if",
"(",
"possibleRevIDs",
"==",
"null",
"||",
"possibleRevIDs",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"List",
"<",
"String",
">",
"history",
"=",
"Database",
".",
"parseCouchDBRevisionHistory",
"(",
"rev",
".",
"getProperties",
"(",
")",
")",
";",
"//rev is missing _revisions property",
"assert",
"(",
"history",
"!=",
"null",
")",
";",
"boolean",
"changed",
"=",
"history",
".",
"retainAll",
"(",
"possibleRevIDs",
")",
";",
"String",
"ancestorID",
"=",
"history",
".",
"size",
"(",
")",
"==",
"0",
"?",
"null",
":",
"history",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"ancestorID",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"int",
"generation",
"=",
"RevisionUtils",
".",
"parseRevIDNumber",
"(",
"ancestorID",
")",
";",
"return",
"generation",
";",
"}"
] | Given a revision and an array of revIDs, finds the latest common ancestor revID
and returns its generation #. If there is none, returns 0.
<p/>
int CBLFindCommonAncestor(CBL_Revision* rev, NSArray* possibleRevIDs) in CBLRestPusher.m | [
"Given",
"a",
"revision",
"and",
"an",
"array",
"of",
"revIDs",
"finds",
"the",
"latest",
"common",
"ancestor",
"revID",
"and",
"returns",
"its",
"generation",
"#",
".",
"If",
"there",
"is",
"none",
"returns",
"0",
".",
"<p",
"/",
">",
"int",
"CBLFindCommonAncestor",
"(",
"CBL_Revision",
"*",
"rev",
"NSArray",
"*",
"possibleRevIDs",
")",
"in",
"CBLRestPusher",
".",
"m"
] | train | https://github.com/couchbase/couchbase-lite-java-core/blob/3b275642e2d2f231fd155ad9def9c5e9eff3118e/src/main/java/com/couchbase/lite/replicator/PusherInternal.java#L670-L689 |
nicoulaj/checksum-maven-plugin | src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/ArtifactsMojo.java | ArtifactsMojo.getFilesToProcess | @Override
protected List<ChecksumFile> getFilesToProcess() {
"""
Build the list of files from which digests should be generated.
<p>The list is composed of the project main and attached artifacts.</p>
@return the list of files that should be processed.
@see #hasValidFile(org.apache.maven.artifact.Artifact)
"""
List<ChecksumFile> files = new LinkedList<ChecksumFile>();
// Add project main artifact.
if ( hasValidFile( project.getArtifact() ) )
{
files.add( new ChecksumFile( "", project.getArtifact().getFile(), project.getArtifact().getType(),null ) );
}
// Add projects attached.
if ( project.getAttachedArtifacts() != null )
{
for ( Artifact artifact : (List<Artifact>) project.getAttachedArtifacts() )
{
if ( hasValidFile( artifact ) )
{
files.add( new ChecksumFile( "", artifact.getFile(), artifact.getType(), artifact.getClassifier() ) );
}
}
}
return files;
} | java | @Override
protected List<ChecksumFile> getFilesToProcess()
{
List<ChecksumFile> files = new LinkedList<ChecksumFile>();
// Add project main artifact.
if ( hasValidFile( project.getArtifact() ) )
{
files.add( new ChecksumFile( "", project.getArtifact().getFile(), project.getArtifact().getType(),null ) );
}
// Add projects attached.
if ( project.getAttachedArtifacts() != null )
{
for ( Artifact artifact : (List<Artifact>) project.getAttachedArtifacts() )
{
if ( hasValidFile( artifact ) )
{
files.add( new ChecksumFile( "", artifact.getFile(), artifact.getType(), artifact.getClassifier() ) );
}
}
}
return files;
} | [
"@",
"Override",
"protected",
"List",
"<",
"ChecksumFile",
">",
"getFilesToProcess",
"(",
")",
"{",
"List",
"<",
"ChecksumFile",
">",
"files",
"=",
"new",
"LinkedList",
"<",
"ChecksumFile",
">",
"(",
")",
";",
"// Add project main artifact.",
"if",
"(",
"hasValidFile",
"(",
"project",
".",
"getArtifact",
"(",
")",
")",
")",
"{",
"files",
".",
"add",
"(",
"new",
"ChecksumFile",
"(",
"\"\"",
",",
"project",
".",
"getArtifact",
"(",
")",
".",
"getFile",
"(",
")",
",",
"project",
".",
"getArtifact",
"(",
")",
".",
"getType",
"(",
")",
",",
"null",
")",
")",
";",
"}",
"// Add projects attached.",
"if",
"(",
"project",
".",
"getAttachedArtifacts",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"Artifact",
"artifact",
":",
"(",
"List",
"<",
"Artifact",
">",
")",
"project",
".",
"getAttachedArtifacts",
"(",
")",
")",
"{",
"if",
"(",
"hasValidFile",
"(",
"artifact",
")",
")",
"{",
"files",
".",
"add",
"(",
"new",
"ChecksumFile",
"(",
"\"\"",
",",
"artifact",
".",
"getFile",
"(",
")",
",",
"artifact",
".",
"getType",
"(",
")",
",",
"artifact",
".",
"getClassifier",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"return",
"files",
";",
"}"
] | Build the list of files from which digests should be generated.
<p>The list is composed of the project main and attached artifacts.</p>
@return the list of files that should be processed.
@see #hasValidFile(org.apache.maven.artifact.Artifact) | [
"Build",
"the",
"list",
"of",
"files",
"from",
"which",
"digests",
"should",
"be",
"generated",
"."
] | train | https://github.com/nicoulaj/checksum-maven-plugin/blob/8d8feab8a0a34e24ae41621e7372be6387e1fe55/src/main/java/net/nicoulaj/maven/plugins/checksum/mojo/ArtifactsMojo.java#L140-L163 |
xvik/guice-persist-orient | src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ExtUtils.java | ExtUtils.findResultConverter | public static Annotation findResultConverter(final Method method, final Class<?> root) {
"""
Searches for result converter annotations (annotations annotated with
{@link ru.vyarus.guice.persist.orient.repository.core.spi.result.ResultConverter}).
<p>
Annotation may be defined on method, type and probably globally on root repository type.
If annotation is defined in two places then only more prioritized will be used.
Priorities: method, direct method type, repository type (in simple cases the last two will be the same type).
@param method method to search converter
@param root root descriptor type
@return found converter annotation or null
"""
Annotation res = findSingleExtAnnotation(method, ResultConverter.class);
if (res == null) {
final List<Annotation> annotations = filterAnnotations(ResultConverter.class, root.getAnnotations());
check(annotations.size() <= 1, "Root %s must use only one annotation of: %s",
root.getName(), toStringAnnotations(annotations));
if (!annotations.isEmpty()) {
res = annotations.get(0);
}
}
return res;
} | java | public static Annotation findResultConverter(final Method method, final Class<?> root) {
Annotation res = findSingleExtAnnotation(method, ResultConverter.class);
if (res == null) {
final List<Annotation> annotations = filterAnnotations(ResultConverter.class, root.getAnnotations());
check(annotations.size() <= 1, "Root %s must use only one annotation of: %s",
root.getName(), toStringAnnotations(annotations));
if (!annotations.isEmpty()) {
res = annotations.get(0);
}
}
return res;
} | [
"public",
"static",
"Annotation",
"findResultConverter",
"(",
"final",
"Method",
"method",
",",
"final",
"Class",
"<",
"?",
">",
"root",
")",
"{",
"Annotation",
"res",
"=",
"findSingleExtAnnotation",
"(",
"method",
",",
"ResultConverter",
".",
"class",
")",
";",
"if",
"(",
"res",
"==",
"null",
")",
"{",
"final",
"List",
"<",
"Annotation",
">",
"annotations",
"=",
"filterAnnotations",
"(",
"ResultConverter",
".",
"class",
",",
"root",
".",
"getAnnotations",
"(",
")",
")",
";",
"check",
"(",
"annotations",
".",
"size",
"(",
")",
"<=",
"1",
",",
"\"Root %s must use only one annotation of: %s\"",
",",
"root",
".",
"getName",
"(",
")",
",",
"toStringAnnotations",
"(",
"annotations",
")",
")",
";",
"if",
"(",
"!",
"annotations",
".",
"isEmpty",
"(",
")",
")",
"{",
"res",
"=",
"annotations",
".",
"get",
"(",
"0",
")",
";",
"}",
"}",
"return",
"res",
";",
"}"
] | Searches for result converter annotations (annotations annotated with
{@link ru.vyarus.guice.persist.orient.repository.core.spi.result.ResultConverter}).
<p>
Annotation may be defined on method, type and probably globally on root repository type.
If annotation is defined in two places then only more prioritized will be used.
Priorities: method, direct method type, repository type (in simple cases the last two will be the same type).
@param method method to search converter
@param root root descriptor type
@return found converter annotation or null | [
"Searches",
"for",
"result",
"converter",
"annotations",
"(",
"annotations",
"annotated",
"with",
"{",
"@link",
"ru",
".",
"vyarus",
".",
"guice",
".",
"persist",
".",
"orient",
".",
"repository",
".",
"core",
".",
"spi",
".",
"result",
".",
"ResultConverter",
"}",
")",
".",
"<p",
">",
"Annotation",
"may",
"be",
"defined",
"on",
"method",
"type",
"and",
"probably",
"globally",
"on",
"root",
"repository",
"type",
".",
"If",
"annotation",
"is",
"defined",
"in",
"two",
"places",
"then",
"only",
"more",
"prioritized",
"will",
"be",
"used",
".",
"Priorities",
":",
"method",
"direct",
"method",
"type",
"repository",
"type",
"(",
"in",
"simple",
"cases",
"the",
"last",
"two",
"will",
"be",
"the",
"same",
"type",
")",
"."
] | train | https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/ext/util/ExtUtils.java#L126-L137 |
joniles/mpxj | src/main/java/net/sf/mpxj/mpp/AvailabilityFactory.java | AvailabilityFactory.process | public void process(AvailabilityTable table, byte[] data) {
"""
Populates a resource availability table.
@param table resource availability table
@param data file data
"""
if (data != null)
{
Calendar cal = DateHelper.popCalendar();
int items = MPPUtility.getShort(data, 0);
int offset = 12;
for (int loop = 0; loop < items; loop++)
{
double unitsValue = MPPUtility.getDouble(data, offset + 4);
if (unitsValue != 0)
{
Date startDate = MPPUtility.getTimestampFromTenths(data, offset);
Date endDate = MPPUtility.getTimestampFromTenths(data, offset + 20);
cal.setTime(endDate);
cal.add(Calendar.MINUTE, -1);
endDate = cal.getTime();
Double units = NumberHelper.getDouble(unitsValue / 100);
Availability item = new Availability(startDate, endDate, units);
table.add(item);
}
offset += 20;
}
DateHelper.pushCalendar(cal);
Collections.sort(table);
}
} | java | public void process(AvailabilityTable table, byte[] data)
{
if (data != null)
{
Calendar cal = DateHelper.popCalendar();
int items = MPPUtility.getShort(data, 0);
int offset = 12;
for (int loop = 0; loop < items; loop++)
{
double unitsValue = MPPUtility.getDouble(data, offset + 4);
if (unitsValue != 0)
{
Date startDate = MPPUtility.getTimestampFromTenths(data, offset);
Date endDate = MPPUtility.getTimestampFromTenths(data, offset + 20);
cal.setTime(endDate);
cal.add(Calendar.MINUTE, -1);
endDate = cal.getTime();
Double units = NumberHelper.getDouble(unitsValue / 100);
Availability item = new Availability(startDate, endDate, units);
table.add(item);
}
offset += 20;
}
DateHelper.pushCalendar(cal);
Collections.sort(table);
}
} | [
"public",
"void",
"process",
"(",
"AvailabilityTable",
"table",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"if",
"(",
"data",
"!=",
"null",
")",
"{",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
")",
";",
"int",
"items",
"=",
"MPPUtility",
".",
"getShort",
"(",
"data",
",",
"0",
")",
";",
"int",
"offset",
"=",
"12",
";",
"for",
"(",
"int",
"loop",
"=",
"0",
";",
"loop",
"<",
"items",
";",
"loop",
"++",
")",
"{",
"double",
"unitsValue",
"=",
"MPPUtility",
".",
"getDouble",
"(",
"data",
",",
"offset",
"+",
"4",
")",
";",
"if",
"(",
"unitsValue",
"!=",
"0",
")",
"{",
"Date",
"startDate",
"=",
"MPPUtility",
".",
"getTimestampFromTenths",
"(",
"data",
",",
"offset",
")",
";",
"Date",
"endDate",
"=",
"MPPUtility",
".",
"getTimestampFromTenths",
"(",
"data",
",",
"offset",
"+",
"20",
")",
";",
"cal",
".",
"setTime",
"(",
"endDate",
")",
";",
"cal",
".",
"add",
"(",
"Calendar",
".",
"MINUTE",
",",
"-",
"1",
")",
";",
"endDate",
"=",
"cal",
".",
"getTime",
"(",
")",
";",
"Double",
"units",
"=",
"NumberHelper",
".",
"getDouble",
"(",
"unitsValue",
"/",
"100",
")",
";",
"Availability",
"item",
"=",
"new",
"Availability",
"(",
"startDate",
",",
"endDate",
",",
"units",
")",
";",
"table",
".",
"add",
"(",
"item",
")",
";",
"}",
"offset",
"+=",
"20",
";",
"}",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"Collections",
".",
"sort",
"(",
"table",
")",
";",
"}",
"}"
] | Populates a resource availability table.
@param table resource availability table
@param data file data | [
"Populates",
"a",
"resource",
"availability",
"table",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/AvailabilityFactory.java#L46-L73 |
denisneuling/apitrary.jar | apitrary-api-client/src/main/java/com/apitrary/api/transport/ApiClientTransportFactory.java | ApiClientTransportFactory.newTransport | public Transport newTransport(ApitraryApi apitraryApi, Class<Transport> transportClazz) {
"""
<p>newTransport.</p>
@param apitraryApi a {@link com.apitrary.api.ApitraryApi} object.
@param transportClazz a {@link java.lang.Class} object.
@return a {@link com.apitrary.api.transport.Transport} object.
"""
try {
Transport transport = transportClazz.newInstance();
transport.setApitraryApi(apitraryApi);
return transport;
} catch (IllegalAccessException e) {
throw new ApiTransportException(e);
} catch (InstantiationException e) {
throw new ApiTransportException(e);
}
} | java | public Transport newTransport(ApitraryApi apitraryApi, Class<Transport> transportClazz) {
try {
Transport transport = transportClazz.newInstance();
transport.setApitraryApi(apitraryApi);
return transport;
} catch (IllegalAccessException e) {
throw new ApiTransportException(e);
} catch (InstantiationException e) {
throw new ApiTransportException(e);
}
} | [
"public",
"Transport",
"newTransport",
"(",
"ApitraryApi",
"apitraryApi",
",",
"Class",
"<",
"Transport",
">",
"transportClazz",
")",
"{",
"try",
"{",
"Transport",
"transport",
"=",
"transportClazz",
".",
"newInstance",
"(",
")",
";",
"transport",
".",
"setApitraryApi",
"(",
"apitraryApi",
")",
";",
"return",
"transport",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"ApiTransportException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"e",
")",
"{",
"throw",
"new",
"ApiTransportException",
"(",
"e",
")",
";",
"}",
"}"
] | <p>newTransport.</p>
@param apitraryApi a {@link com.apitrary.api.ApitraryApi} object.
@param transportClazz a {@link java.lang.Class} object.
@return a {@link com.apitrary.api.transport.Transport} object. | [
"<p",
">",
"newTransport",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/denisneuling/apitrary.jar/blob/b7f639a1e735c60ba2b1b62851926757f5de8628/apitrary-api-client/src/main/java/com/apitrary/api/transport/ApiClientTransportFactory.java#L75-L85 |
alibaba/ARouter | arouter-api/src/main/java/com/alibaba/android/arouter/facade/Postcard.java | Postcard.withString | public Postcard withString(@Nullable String key, @Nullable String value) {
"""
Inserts a String value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
@param key a String, or null
@param value a String, or null
@return current
"""
mBundle.putString(key, value);
return this;
} | java | public Postcard withString(@Nullable String key, @Nullable String value) {
mBundle.putString(key, value);
return this;
} | [
"public",
"Postcard",
"withString",
"(",
"@",
"Nullable",
"String",
"key",
",",
"@",
"Nullable",
"String",
"value",
")",
"{",
"mBundle",
".",
"putString",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Inserts a String value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
@param key a String, or null
@param value a String, or null
@return current | [
"Inserts",
"a",
"String",
"value",
"into",
"the",
"mapping",
"of",
"this",
"Bundle",
"replacing",
"any",
"existing",
"value",
"for",
"the",
"given",
"key",
".",
"Either",
"key",
"or",
"value",
"may",
"be",
"null",
"."
] | train | https://github.com/alibaba/ARouter/blob/1a06912a6e14a57112db1204b43f81c43d721732/arouter-api/src/main/java/com/alibaba/android/arouter/facade/Postcard.java#L244-L247 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java | SqlExecutor.query | public static <T> T query(Connection conn, String sql, RsHandler<T> rsh, Object... params) throws SQLException {
"""
执行查询语句<br>
此方法不会关闭Connection
@param <T> 处理结果类型
@param conn 数据库连接对象
@param sql 查询语句
@param rsh 结果集处理对象
@param params 参数
@return 结果对象
@throws SQLException SQL执行异常
"""
PreparedStatement ps = null;
try {
ps = StatementUtil.prepareStatement(conn, sql, params);
return executeQuery(ps, rsh);
} finally {
DbUtil.close(ps);
}
} | java | public static <T> T query(Connection conn, String sql, RsHandler<T> rsh, Object... params) throws SQLException {
PreparedStatement ps = null;
try {
ps = StatementUtil.prepareStatement(conn, sql, params);
return executeQuery(ps, rsh);
} finally {
DbUtil.close(ps);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"query",
"(",
"Connection",
"conn",
",",
"String",
"sql",
",",
"RsHandler",
"<",
"T",
">",
"rsh",
",",
"Object",
"...",
"params",
")",
"throws",
"SQLException",
"{",
"PreparedStatement",
"ps",
"=",
"null",
";",
"try",
"{",
"ps",
"=",
"StatementUtil",
".",
"prepareStatement",
"(",
"conn",
",",
"sql",
",",
"params",
")",
";",
"return",
"executeQuery",
"(",
"ps",
",",
"rsh",
")",
";",
"}",
"finally",
"{",
"DbUtil",
".",
"close",
"(",
"ps",
")",
";",
"}",
"}"
] | 执行查询语句<br>
此方法不会关闭Connection
@param <T> 处理结果类型
@param conn 数据库连接对象
@param sql 查询语句
@param rsh 结果集处理对象
@param params 参数
@return 结果对象
@throws SQLException SQL执行异常 | [
"执行查询语句<br",
">",
"此方法不会关闭Connection"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java#L258-L266 |
alkacon/opencms-core | src-modules/org/opencms/workplace/tools/database/CmsHtmlImportConverter.java | CmsHtmlImportConverter.printDocument | private void printDocument(Node node, Hashtable properties) {
"""
Private method to parse DOM and create user defined output.<p>
@param node Node of DOM from HTML code
@param properties the file properties
"""
// if node is empty do nothing... (Recursion)
if (node == null) {
return;
}
// initialise local variables
int type = node.getNodeType();
String name = node.getNodeName();
// detect node type
switch (type) {
case Node.DOCUMENT_NODE:
printDocument(((Document)node).getDocumentElement(), properties);
break;
case Node.ELEMENT_NODE:
// check if its the <head> node. Nothing inside the <head> node
// must be
// part of the output, but we must scan the content of this
// node to get all
// <meta> tags
if (name.equals(NODE_HEAD)) {
m_write = false;
}
// scan element node; if a block has to be removed or replaced,
// break and discard child nodes
transformStartElement(node, properties);
// test if node has children
NodeList children = node.getChildNodes();
if (children != null) {
int len = children.getLength();
for (int i = 0; i < len; i++) {
// recursively call printDocument with all child nodes
printDocument(children.item(i), properties);
}
}
break;
case Node.TEXT_NODE:
// replace subStrings in text nodes
transformTextNode(node);
break;
default:
break;
}
// end of recursion, add eventual endtags and suffixes
switch (type) {
case Node.ELEMENT_NODE:
// analyse endtags and add them to output
transformEndElement(node);
if (node.getNodeName().equals(NODE_HEAD)) {
m_write = true;
}
break;
case Node.DOCUMENT_NODE:
break;
default:
break;
}
} | java | private void printDocument(Node node, Hashtable properties) {
// if node is empty do nothing... (Recursion)
if (node == null) {
return;
}
// initialise local variables
int type = node.getNodeType();
String name = node.getNodeName();
// detect node type
switch (type) {
case Node.DOCUMENT_NODE:
printDocument(((Document)node).getDocumentElement(), properties);
break;
case Node.ELEMENT_NODE:
// check if its the <head> node. Nothing inside the <head> node
// must be
// part of the output, but we must scan the content of this
// node to get all
// <meta> tags
if (name.equals(NODE_HEAD)) {
m_write = false;
}
// scan element node; if a block has to be removed or replaced,
// break and discard child nodes
transformStartElement(node, properties);
// test if node has children
NodeList children = node.getChildNodes();
if (children != null) {
int len = children.getLength();
for (int i = 0; i < len; i++) {
// recursively call printDocument with all child nodes
printDocument(children.item(i), properties);
}
}
break;
case Node.TEXT_NODE:
// replace subStrings in text nodes
transformTextNode(node);
break;
default:
break;
}
// end of recursion, add eventual endtags and suffixes
switch (type) {
case Node.ELEMENT_NODE:
// analyse endtags and add them to output
transformEndElement(node);
if (node.getNodeName().equals(NODE_HEAD)) {
m_write = true;
}
break;
case Node.DOCUMENT_NODE:
break;
default:
break;
}
} | [
"private",
"void",
"printDocument",
"(",
"Node",
"node",
",",
"Hashtable",
"properties",
")",
"{",
"// if node is empty do nothing... (Recursion)",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"return",
";",
"}",
"// initialise local variables",
"int",
"type",
"=",
"node",
".",
"getNodeType",
"(",
")",
";",
"String",
"name",
"=",
"node",
".",
"getNodeName",
"(",
")",
";",
"// detect node type",
"switch",
"(",
"type",
")",
"{",
"case",
"Node",
".",
"DOCUMENT_NODE",
":",
"printDocument",
"(",
"(",
"(",
"Document",
")",
"node",
")",
".",
"getDocumentElement",
"(",
")",
",",
"properties",
")",
";",
"break",
";",
"case",
"Node",
".",
"ELEMENT_NODE",
":",
"// check if its the <head> node. Nothing inside the <head> node",
"// must be",
"// part of the output, but we must scan the content of this",
"// node to get all",
"// <meta> tags",
"if",
"(",
"name",
".",
"equals",
"(",
"NODE_HEAD",
")",
")",
"{",
"m_write",
"=",
"false",
";",
"}",
"// scan element node; if a block has to be removed or replaced,",
"// break and discard child nodes",
"transformStartElement",
"(",
"node",
",",
"properties",
")",
";",
"// test if node has children",
"NodeList",
"children",
"=",
"node",
".",
"getChildNodes",
"(",
")",
";",
"if",
"(",
"children",
"!=",
"null",
")",
"{",
"int",
"len",
"=",
"children",
".",
"getLength",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"// recursively call printDocument with all child nodes",
"printDocument",
"(",
"children",
".",
"item",
"(",
"i",
")",
",",
"properties",
")",
";",
"}",
"}",
"break",
";",
"case",
"Node",
".",
"TEXT_NODE",
":",
"// replace subStrings in text nodes",
"transformTextNode",
"(",
"node",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"// end of recursion, add eventual endtags and suffixes",
"switch",
"(",
"type",
")",
"{",
"case",
"Node",
".",
"ELEMENT_NODE",
":",
"// analyse endtags and add them to output",
"transformEndElement",
"(",
"node",
")",
";",
"if",
"(",
"node",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"NODE_HEAD",
")",
")",
"{",
"m_write",
"=",
"true",
";",
"}",
"break",
";",
"case",
"Node",
".",
"DOCUMENT_NODE",
":",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] | Private method to parse DOM and create user defined output.<p>
@param node Node of DOM from HTML code
@param properties the file properties | [
"Private",
"method",
"to",
"parse",
"DOM",
"and",
"create",
"user",
"defined",
"output",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/database/CmsHtmlImportConverter.java#L321-L384 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/StringUtils.java | StringUtils.argsToMap | public static Map<String, String[]> argsToMap(String[] args) {
"""
Parses command line arguments into a Map. Arguments of the form
<p/>
-flag1 arg1a arg1b ... arg1m -flag2 -flag3 arg3a ... arg3n
<p/>
will be parsed so that the flag is a key in the Map (including
the hyphen) and its value will be a {@link String}[] containing
the optional arguments (if present). The non-flag values not
captured as flag arguments are collected into a String[] array
and returned as the value of <code>null</code> in the Map. In
this invocation, flags cannot take arguments, so all the {@link
String} array values other than the value for <code>null</code>
will be zero-length.
@param args A command-line arguments array
@return a {@link Map} of flag names to flag argument {@link
String} arrays.
"""
return argsToMap(args, new HashMap<String, Integer>());
} | java | public static Map<String, String[]> argsToMap(String[] args) {
return argsToMap(args, new HashMap<String, Integer>());
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"argsToMap",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"return",
"argsToMap",
"(",
"args",
",",
"new",
"HashMap",
"<",
"String",
",",
"Integer",
">",
"(",
")",
")",
";",
"}"
] | Parses command line arguments into a Map. Arguments of the form
<p/>
-flag1 arg1a arg1b ... arg1m -flag2 -flag3 arg3a ... arg3n
<p/>
will be parsed so that the flag is a key in the Map (including
the hyphen) and its value will be a {@link String}[] containing
the optional arguments (if present). The non-flag values not
captured as flag arguments are collected into a String[] array
and returned as the value of <code>null</code> in the Map. In
this invocation, flags cannot take arguments, so all the {@link
String} array values other than the value for <code>null</code>
will be zero-length.
@param args A command-line arguments array
@return a {@link Map} of flag names to flag argument {@link
String} arrays. | [
"Parses",
"command",
"line",
"arguments",
"into",
"a",
"Map",
".",
"Arguments",
"of",
"the",
"form",
"<p",
"/",
">",
"-",
"flag1",
"arg1a",
"arg1b",
"...",
"arg1m",
"-",
"flag2",
"-",
"flag3",
"arg3a",
"...",
"arg3n",
"<p",
"/",
">",
"will",
"be",
"parsed",
"so",
"that",
"the",
"flag",
"is",
"a",
"key",
"in",
"the",
"Map",
"(",
"including",
"the",
"hyphen",
")",
"and",
"its",
"value",
"will",
"be",
"a",
"{",
"@link",
"String",
"}",
"[]",
"containing",
"the",
"optional",
"arguments",
"(",
"if",
"present",
")",
".",
"The",
"non",
"-",
"flag",
"values",
"not",
"captured",
"as",
"flag",
"arguments",
"are",
"collected",
"into",
"a",
"String",
"[]",
"array",
"and",
"returned",
"as",
"the",
"value",
"of",
"<code",
">",
"null<",
"/",
"code",
">",
"in",
"the",
"Map",
".",
"In",
"this",
"invocation",
"flags",
"cannot",
"take",
"arguments",
"so",
"all",
"the",
"{",
"@link",
"String",
"}",
"array",
"values",
"other",
"than",
"the",
"value",
"for",
"<code",
">",
"null<",
"/",
"code",
">",
"will",
"be",
"zero",
"-",
"length",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/StringUtils.java#L629-L631 |
real-logic/agrona | agrona/src/main/java/org/agrona/PrintBufferUtil.java | PrintBufferUtil.appendPrettyHexDump | public static void appendPrettyHexDump(final StringBuilder dump, final DirectBuffer buffer) {
"""
Appends the prettified multi-line hexadecimal dump of the specified {@link DirectBuffer} to the specified
{@link StringBuilder} that is easy to read by humans.
@param dump where should we append string representation of the buffer
@param buffer dumped buffer
"""
appendPrettyHexDump(dump, buffer, 0, buffer.capacity());
} | java | public static void appendPrettyHexDump(final StringBuilder dump, final DirectBuffer buffer)
{
appendPrettyHexDump(dump, buffer, 0, buffer.capacity());
} | [
"public",
"static",
"void",
"appendPrettyHexDump",
"(",
"final",
"StringBuilder",
"dump",
",",
"final",
"DirectBuffer",
"buffer",
")",
"{",
"appendPrettyHexDump",
"(",
"dump",
",",
"buffer",
",",
"0",
",",
"buffer",
".",
"capacity",
"(",
")",
")",
";",
"}"
] | Appends the prettified multi-line hexadecimal dump of the specified {@link DirectBuffer} to the specified
{@link StringBuilder} that is easy to read by humans.
@param dump where should we append string representation of the buffer
@param buffer dumped buffer | [
"Appends",
"the",
"prettified",
"multi",
"-",
"line",
"hexadecimal",
"dump",
"of",
"the",
"specified",
"{",
"@link",
"DirectBuffer",
"}",
"to",
"the",
"specified",
"{",
"@link",
"StringBuilder",
"}",
"that",
"is",
"easy",
"to",
"read",
"by",
"humans",
"."
] | train | https://github.com/real-logic/agrona/blob/d1ea76e6e3598cd6a0d34879687652ef123f639b/agrona/src/main/java/org/agrona/PrintBufferUtil.java#L135-L138 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/collection/MDAG/MDAG.java | MDAG.getStringsWithSubstring | public HashSet<String> getStringsWithSubstring(String str) {
"""
返回包含字串的key<br>
Retrieves all the Strings in the MDAG that contain a given String.
@param str a String that is contained in all the desired Strings
@return a HashSet containing all the Strings present in the MDAG that begin with {@code prefixString}
"""
HashSet<String> strHashSet = new HashSet<String>();
if (sourceNode != null) //if the MDAG hasn't been simplified
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", sourceNode.getOutgoingTransitions());
else
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", simplifiedSourceNode);
return strHashSet;
} | java | public HashSet<String> getStringsWithSubstring(String str)
{
HashSet<String> strHashSet = new HashSet<String>();
if (sourceNode != null) //if the MDAG hasn't been simplified
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", sourceNode.getOutgoingTransitions());
else
getStrings(strHashSet, SearchCondition.SUBSTRING_SEARCH_CONDITION, str, "", simplifiedSourceNode);
return strHashSet;
} | [
"public",
"HashSet",
"<",
"String",
">",
"getStringsWithSubstring",
"(",
"String",
"str",
")",
"{",
"HashSet",
"<",
"String",
">",
"strHashSet",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"sourceNode",
"!=",
"null",
")",
"//if the MDAG hasn't been simplified",
"getStrings",
"(",
"strHashSet",
",",
"SearchCondition",
".",
"SUBSTRING_SEARCH_CONDITION",
",",
"str",
",",
"\"\"",
",",
"sourceNode",
".",
"getOutgoingTransitions",
"(",
")",
")",
";",
"else",
"getStrings",
"(",
"strHashSet",
",",
"SearchCondition",
".",
"SUBSTRING_SEARCH_CONDITION",
",",
"str",
",",
"\"\"",
",",
"simplifiedSourceNode",
")",
";",
"return",
"strHashSet",
";",
"}"
] | 返回包含字串的key<br>
Retrieves all the Strings in the MDAG that contain a given String.
@param str a String that is contained in all the desired Strings
@return a HashSet containing all the Strings present in the MDAG that begin with {@code prefixString} | [
"返回包含字串的key<br",
">",
"Retrieves",
"all",
"the",
"Strings",
"in",
"the",
"MDAG",
"that",
"contain",
"a",
"given",
"String",
"."
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/collection/MDAG/MDAG.java#L976-L986 |
amaembo/streamex | src/main/java/one/util/streamex/LongStreamEx.java | LongStreamEx.zip | public static LongStreamEx zip(long[] first, long[] second, LongBinaryOperator mapper) {
"""
Returns a sequential {@code LongStreamEx} containing the results of
applying the given function to the corresponding pairs of values in given
two arrays.
@param first the first array
@param second the second array
@param mapper a non-interfering, stateless function to apply to each pair
of the corresponding array elements.
@return a new {@code LongStreamEx}
@throws IllegalArgumentException if length of the arrays differs.
@since 0.2.1
"""
return of(new RangeBasedSpliterator.ZipLong(0, checkLength(first.length, second.length), mapper, first,
second));
} | java | public static LongStreamEx zip(long[] first, long[] second, LongBinaryOperator mapper) {
return of(new RangeBasedSpliterator.ZipLong(0, checkLength(first.length, second.length), mapper, first,
second));
} | [
"public",
"static",
"LongStreamEx",
"zip",
"(",
"long",
"[",
"]",
"first",
",",
"long",
"[",
"]",
"second",
",",
"LongBinaryOperator",
"mapper",
")",
"{",
"return",
"of",
"(",
"new",
"RangeBasedSpliterator",
".",
"ZipLong",
"(",
"0",
",",
"checkLength",
"(",
"first",
".",
"length",
",",
"second",
".",
"length",
")",
",",
"mapper",
",",
"first",
",",
"second",
")",
")",
";",
"}"
] | Returns a sequential {@code LongStreamEx} containing the results of
applying the given function to the corresponding pairs of values in given
two arrays.
@param first the first array
@param second the second array
@param mapper a non-interfering, stateless function to apply to each pair
of the corresponding array elements.
@return a new {@code LongStreamEx}
@throws IllegalArgumentException if length of the arrays differs.
@since 0.2.1 | [
"Returns",
"a",
"sequential",
"{",
"@code",
"LongStreamEx",
"}",
"containing",
"the",
"results",
"of",
"applying",
"the",
"given",
"function",
"to",
"the",
"corresponding",
"pairs",
"of",
"values",
"in",
"given",
"two",
"arrays",
"."
] | train | https://github.com/amaembo/streamex/blob/936bbd1b7dfbcf64a3b990682bfc848213441d14/src/main/java/one/util/streamex/LongStreamEx.java#L2050-L2053 |
sdl/odata | odata_renderer/src/main/java/com/sdl/odata/renderer/atom/writer/AtomMetadataWriter.java | AtomMetadataWriter.writeFeedLink | void writeFeedLink(Object entity, NavigationProperty property) throws XMLStreamException, ODataEdmException {
"""
Write a feed {@code <link>} element.
@throws XMLStreamException If unable to write to stream
"""
xmlWriter.writeStartElement(ATOM_LINK);
xmlWriter.writeAttribute(REL, SELF);
if (entity == null) {
if (ODataUriUtil.isActionCallUri(oDataUri) || ODataUriUtil.isFunctionCallUri(oDataUri)) {
Option<TargetType> targetTypeOption = ODataUriUtil.resolveTargetType(oDataUri, entityDataModel);
if (targetTypeOption.isDefined()) {
TargetType targetType = targetTypeOption.get();
String entitySetName = EntityDataModelUtil.getEntitySetByEntityTypeName(entityDataModel,
targetType.typeName()).getName();
xmlWriter.writeAttribute(TITLE, entitySetName);
xmlWriter.writeAttribute(HREF, entitySetName);
} else {
throw new ODataEdmException("Failed to resolve entity target type");
}
} else {
xmlWriter.writeAttribute(TITLE, getEntitySetName(oDataUri).get());
xmlWriter.writeAttribute(HREF, getEntitySetName(oDataUri).get());
}
} else {
xmlWriter.writeAttribute(TITLE, property.getName());
xmlWriter.writeAttribute(HREF, String.format("%s/%s", getEntityWithKey(entity), property.getName()));
}
xmlWriter.writeEndElement();
} | java | void writeFeedLink(Object entity, NavigationProperty property) throws XMLStreamException, ODataEdmException {
xmlWriter.writeStartElement(ATOM_LINK);
xmlWriter.writeAttribute(REL, SELF);
if (entity == null) {
if (ODataUriUtil.isActionCallUri(oDataUri) || ODataUriUtil.isFunctionCallUri(oDataUri)) {
Option<TargetType> targetTypeOption = ODataUriUtil.resolveTargetType(oDataUri, entityDataModel);
if (targetTypeOption.isDefined()) {
TargetType targetType = targetTypeOption.get();
String entitySetName = EntityDataModelUtil.getEntitySetByEntityTypeName(entityDataModel,
targetType.typeName()).getName();
xmlWriter.writeAttribute(TITLE, entitySetName);
xmlWriter.writeAttribute(HREF, entitySetName);
} else {
throw new ODataEdmException("Failed to resolve entity target type");
}
} else {
xmlWriter.writeAttribute(TITLE, getEntitySetName(oDataUri).get());
xmlWriter.writeAttribute(HREF, getEntitySetName(oDataUri).get());
}
} else {
xmlWriter.writeAttribute(TITLE, property.getName());
xmlWriter.writeAttribute(HREF, String.format("%s/%s", getEntityWithKey(entity), property.getName()));
}
xmlWriter.writeEndElement();
} | [
"void",
"writeFeedLink",
"(",
"Object",
"entity",
",",
"NavigationProperty",
"property",
")",
"throws",
"XMLStreamException",
",",
"ODataEdmException",
"{",
"xmlWriter",
".",
"writeStartElement",
"(",
"ATOM_LINK",
")",
";",
"xmlWriter",
".",
"writeAttribute",
"(",
"REL",
",",
"SELF",
")",
";",
"if",
"(",
"entity",
"==",
"null",
")",
"{",
"if",
"(",
"ODataUriUtil",
".",
"isActionCallUri",
"(",
"oDataUri",
")",
"||",
"ODataUriUtil",
".",
"isFunctionCallUri",
"(",
"oDataUri",
")",
")",
"{",
"Option",
"<",
"TargetType",
">",
"targetTypeOption",
"=",
"ODataUriUtil",
".",
"resolveTargetType",
"(",
"oDataUri",
",",
"entityDataModel",
")",
";",
"if",
"(",
"targetTypeOption",
".",
"isDefined",
"(",
")",
")",
"{",
"TargetType",
"targetType",
"=",
"targetTypeOption",
".",
"get",
"(",
")",
";",
"String",
"entitySetName",
"=",
"EntityDataModelUtil",
".",
"getEntitySetByEntityTypeName",
"(",
"entityDataModel",
",",
"targetType",
".",
"typeName",
"(",
")",
")",
".",
"getName",
"(",
")",
";",
"xmlWriter",
".",
"writeAttribute",
"(",
"TITLE",
",",
"entitySetName",
")",
";",
"xmlWriter",
".",
"writeAttribute",
"(",
"HREF",
",",
"entitySetName",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ODataEdmException",
"(",
"\"Failed to resolve entity target type\"",
")",
";",
"}",
"}",
"else",
"{",
"xmlWriter",
".",
"writeAttribute",
"(",
"TITLE",
",",
"getEntitySetName",
"(",
"oDataUri",
")",
".",
"get",
"(",
")",
")",
";",
"xmlWriter",
".",
"writeAttribute",
"(",
"HREF",
",",
"getEntitySetName",
"(",
"oDataUri",
")",
".",
"get",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"xmlWriter",
".",
"writeAttribute",
"(",
"TITLE",
",",
"property",
".",
"getName",
"(",
")",
")",
";",
"xmlWriter",
".",
"writeAttribute",
"(",
"HREF",
",",
"String",
".",
"format",
"(",
"\"%s/%s\"",
",",
"getEntityWithKey",
"(",
"entity",
")",
",",
"property",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"xmlWriter",
".",
"writeEndElement",
"(",
")",
";",
"}"
] | Write a feed {@code <link>} element.
@throws XMLStreamException If unable to write to stream | [
"Write",
"a",
"feed",
"{",
"@code",
"<link",
">",
"}",
"element",
"."
] | train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_renderer/src/main/java/com/sdl/odata/renderer/atom/writer/AtomMetadataWriter.java#L234-L262 |
konvergeio/cofoja | src/main/java/com/google/java/contract/util/Predicates.java | Predicates.forKeys | public static <K, V> Predicate<Map<K, V>> forKeys(
final Predicate<? super Set<K>> p) {
"""
Returns a predicate that evaluates to {@code true} if the key set
of its argument satisfies {@code p}.
"""
return new Predicate<Map<K, V>>() {
@Override
public boolean apply(Map<K, V> obj) {
return p.apply(obj.keySet());
}
};
} | java | public static <K, V> Predicate<Map<K, V>> forKeys(
final Predicate<? super Set<K>> p) {
return new Predicate<Map<K, V>>() {
@Override
public boolean apply(Map<K, V> obj) {
return p.apply(obj.keySet());
}
};
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"Predicate",
"<",
"Map",
"<",
"K",
",",
"V",
">",
">",
"forKeys",
"(",
"final",
"Predicate",
"<",
"?",
"super",
"Set",
"<",
"K",
">",
">",
"p",
")",
"{",
"return",
"new",
"Predicate",
"<",
"Map",
"<",
"K",
",",
"V",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"apply",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"obj",
")",
"{",
"return",
"p",
".",
"apply",
"(",
"obj",
".",
"keySet",
"(",
")",
")",
";",
"}",
"}",
";",
"}"
] | Returns a predicate that evaluates to {@code true} if the key set
of its argument satisfies {@code p}. | [
"Returns",
"a",
"predicate",
"that",
"evaluates",
"to",
"{"
] | train | https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/util/Predicates.java#L254-L262 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hash/MurmurHash3Adaptor.java | MurmurHash3Adaptor.asInt | public static int asInt(final double datum, final int n) {
"""
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input double.
@param datum the given double.
@param n The upper exclusive bound of the integers produced. Must be > 1.
@return deterministic uniform random integer
"""
final double d = (datum == 0.0) ? 0.0 : datum; //canonicalize -0.0, 0.0
final long[] data = { Double.doubleToLongBits(d) };//canonicalize all NaN forms
return asInteger(data, n); //data is long[]
} | java | public static int asInt(final double datum, final int n) {
final double d = (datum == 0.0) ? 0.0 : datum; //canonicalize -0.0, 0.0
final long[] data = { Double.doubleToLongBits(d) };//canonicalize all NaN forms
return asInteger(data, n); //data is long[]
} | [
"public",
"static",
"int",
"asInt",
"(",
"final",
"double",
"datum",
",",
"final",
"int",
"n",
")",
"{",
"final",
"double",
"d",
"=",
"(",
"datum",
"==",
"0.0",
")",
"?",
"0.0",
":",
"datum",
";",
"//canonicalize -0.0, 0.0",
"final",
"long",
"[",
"]",
"data",
"=",
"{",
"Double",
".",
"doubleToLongBits",
"(",
"d",
")",
"}",
";",
"//canonicalize all NaN forms",
"return",
"asInteger",
"(",
"data",
",",
"n",
")",
";",
"//data is long[]",
"}"
] | Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input double.
@param datum the given double.
@param n The upper exclusive bound of the integers produced. Must be > 1.
@return deterministic uniform random integer | [
"Returns",
"a",
"deterministic",
"uniform",
"random",
"integer",
"between",
"zero",
"(",
"inclusive",
")",
"and",
"n",
"(",
"exclusive",
")",
"given",
"the",
"input",
"double",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hash/MurmurHash3Adaptor.java#L292-L296 |
RoaringBitmap/RoaringBitmap | jmh/src/main/java/org/roaringbitmap/bithacking/SelectBenchmark.java | SelectBenchmark.select | public static int select(short w, int j) {
"""
Given a word w, return the position of the jth true bit.
@param w word
@param j index
@return position of jth true bit in w
"""
int sumtotal = 0;
for (int counter = 0; counter < 16; ++counter) {
sumtotal += (w >> counter) & 1;
if (sumtotal > j)
return counter;
}
throw new IllegalArgumentException(
"cannot locate " + j + "th bit in " + w + " weight is " + Integer.bitCount(w));
} | java | public static int select(short w, int j) {
int sumtotal = 0;
for (int counter = 0; counter < 16; ++counter) {
sumtotal += (w >> counter) & 1;
if (sumtotal > j)
return counter;
}
throw new IllegalArgumentException(
"cannot locate " + j + "th bit in " + w + " weight is " + Integer.bitCount(w));
} | [
"public",
"static",
"int",
"select",
"(",
"short",
"w",
",",
"int",
"j",
")",
"{",
"int",
"sumtotal",
"=",
"0",
";",
"for",
"(",
"int",
"counter",
"=",
"0",
";",
"counter",
"<",
"16",
";",
"++",
"counter",
")",
"{",
"sumtotal",
"+=",
"(",
"w",
">>",
"counter",
")",
"&",
"1",
";",
"if",
"(",
"sumtotal",
">",
"j",
")",
"return",
"counter",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"cannot locate \"",
"+",
"j",
"+",
"\"th bit in \"",
"+",
"w",
"+",
"\" weight is \"",
"+",
"Integer",
".",
"bitCount",
"(",
"w",
")",
")",
";",
"}"
] | Given a word w, return the position of the jth true bit.
@param w word
@param j index
@return position of jth true bit in w | [
"Given",
"a",
"word",
"w",
"return",
"the",
"position",
"of",
"the",
"jth",
"true",
"bit",
"."
] | train | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/jmh/src/main/java/org/roaringbitmap/bithacking/SelectBenchmark.java#L155-L164 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServicePlansInner.java | AppServicePlansInner.rebootWorkerAsync | public Observable<Void> rebootWorkerAsync(String resourceGroupName, String name, String workerName) {
"""
Reboot a worker machine in an App Service plan.
Reboot a worker machine in an App Service plan.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service plan.
@param workerName Name of worker machine, which typically starts with RD.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return rebootWorkerWithServiceResponseAsync(resourceGroupName, name, workerName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> rebootWorkerAsync(String resourceGroupName, String name, String workerName) {
return rebootWorkerWithServiceResponseAsync(resourceGroupName, name, workerName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"rebootWorkerAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
",",
"String",
"workerName",
")",
"{",
"return",
"rebootWorkerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
",",
"workerName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Reboot a worker machine in an App Service plan.
Reboot a worker machine in an App Service plan.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service plan.
@param workerName Name of worker machine, which typically starts with RD.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Reboot",
"a",
"worker",
"machine",
"in",
"an",
"App",
"Service",
"plan",
".",
"Reboot",
"a",
"worker",
"machine",
"in",
"an",
"App",
"Service",
"plan",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServicePlansInner.java#L3951-L3958 |
Azure/azure-sdk-for-java | servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClient.java | ManagementClient.deleteSubscription | public Void deleteSubscription(String topicPath, String subscriptionName) throws ServiceBusException, InterruptedException {
"""
Deletes the subscription described by the topicPath and the subscriptionName.
@param topicPath - The name of the topic.
@param subscriptionName - The name of the subscription.
@throws IllegalArgumentException - path is not null / empty / too long / invalid.
@throws TimeoutException - The operation times out. The timeout period is initiated through ClientSettings.operationTimeout
@throws AuthorizationFailedException - No sufficient permission to perform this operation. Please check ClientSettings.tokenProvider has correct details.
@throws ServerBusyException - The server is busy. You should wait before you retry the operation.
@throws ServiceBusException - An internal error or an unexpected exception occurred.
@throws MessagingEntityNotFoundException - An entity with this name does not exist.
@throws InterruptedException if the current thread was interrupted
"""
return Utils.completeFuture(this.asyncClient.deleteSubscriptionAsync(topicPath, subscriptionName));
} | java | public Void deleteSubscription(String topicPath, String subscriptionName) throws ServiceBusException, InterruptedException {
return Utils.completeFuture(this.asyncClient.deleteSubscriptionAsync(topicPath, subscriptionName));
} | [
"public",
"Void",
"deleteSubscription",
"(",
"String",
"topicPath",
",",
"String",
"subscriptionName",
")",
"throws",
"ServiceBusException",
",",
"InterruptedException",
"{",
"return",
"Utils",
".",
"completeFuture",
"(",
"this",
".",
"asyncClient",
".",
"deleteSubscriptionAsync",
"(",
"topicPath",
",",
"subscriptionName",
")",
")",
";",
"}"
] | Deletes the subscription described by the topicPath and the subscriptionName.
@param topicPath - The name of the topic.
@param subscriptionName - The name of the subscription.
@throws IllegalArgumentException - path is not null / empty / too long / invalid.
@throws TimeoutException - The operation times out. The timeout period is initiated through ClientSettings.operationTimeout
@throws AuthorizationFailedException - No sufficient permission to perform this operation. Please check ClientSettings.tokenProvider has correct details.
@throws ServerBusyException - The server is busy. You should wait before you retry the operation.
@throws ServiceBusException - An internal error or an unexpected exception occurred.
@throws MessagingEntityNotFoundException - An entity with this name does not exist.
@throws InterruptedException if the current thread was interrupted | [
"Deletes",
"the",
"subscription",
"described",
"by",
"the",
"topicPath",
"and",
"the",
"subscriptionName",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClient.java#L598-L600 |
marklogic/java-client-api | marklogic-client-api/src/main/java/com/marklogic/client/impl/ServerEvaluationCallImpl.java | ServerEvaluationCallImpl.addVariableAs | @Override
public ServerEvaluationCall addVariableAs(String name, Object value) {
"""
Like other *As convenience methods throughout the API, the Object value
is managed by the Handle registered for that Class.
"""
if (value == null) return this;
Class<?> as = value.getClass();
AbstractWriteHandle writeHandle = null;
if (AbstractWriteHandle.class.isAssignableFrom(as)) {
writeHandle = (AbstractWriteHandle) value;
} else {
ContentHandle<?> contentHandle = handleRegistry.makeHandle(as);
Utilities.setHandleContent(contentHandle, value);
writeHandle = contentHandle;
}
return addVariable(name, writeHandle);
} | java | @Override
public ServerEvaluationCall addVariableAs(String name, Object value) {
if (value == null) return this;
Class<?> as = value.getClass();
AbstractWriteHandle writeHandle = null;
if (AbstractWriteHandle.class.isAssignableFrom(as)) {
writeHandle = (AbstractWriteHandle) value;
} else {
ContentHandle<?> contentHandle = handleRegistry.makeHandle(as);
Utilities.setHandleContent(contentHandle, value);
writeHandle = contentHandle;
}
return addVariable(name, writeHandle);
} | [
"@",
"Override",
"public",
"ServerEvaluationCall",
"addVariableAs",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"this",
";",
"Class",
"<",
"?",
">",
"as",
"=",
"value",
".",
"getClass",
"(",
")",
";",
"AbstractWriteHandle",
"writeHandle",
"=",
"null",
";",
"if",
"(",
"AbstractWriteHandle",
".",
"class",
".",
"isAssignableFrom",
"(",
"as",
")",
")",
"{",
"writeHandle",
"=",
"(",
"AbstractWriteHandle",
")",
"value",
";",
"}",
"else",
"{",
"ContentHandle",
"<",
"?",
">",
"contentHandle",
"=",
"handleRegistry",
".",
"makeHandle",
"(",
"as",
")",
";",
"Utilities",
".",
"setHandleContent",
"(",
"contentHandle",
",",
"value",
")",
";",
"writeHandle",
"=",
"contentHandle",
";",
"}",
"return",
"addVariable",
"(",
"name",
",",
"writeHandle",
")",
";",
"}"
] | Like other *As convenience methods throughout the API, the Object value
is managed by the Handle registered for that Class. | [
"Like",
"other",
"*",
"As",
"convenience",
"methods",
"throughout",
"the",
"API",
"the",
"Object",
"value",
"is",
"managed",
"by",
"the",
"Handle",
"registered",
"for",
"that",
"Class",
"."
] | train | https://github.com/marklogic/java-client-api/blob/acf60229a928abd4a8cc4b21b641d56957467da7/marklogic-client-api/src/main/java/com/marklogic/client/impl/ServerEvaluationCallImpl.java#L114-L128 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/color/ColorHsv.java | ColorHsv.rgbToHsv | public static void rgbToHsv( double r , double g , double b , double []hsv ) {
"""
Convert RGB color into HSV color
@param r red
@param g green
@param b blue
@param hsv (Output) HSV value.
"""
// Maximum value
double max = r > g ? ( r > b ? r : b) : ( g > b ? g : b );
// Minimum value
double min = r < g ? ( r < b ? r : b) : ( g < b ? g : b );
double delta = max - min;
hsv[2] = max;
if( max != 0 )
hsv[1] = delta / max;
else {
hsv[0] = Double.NaN;
hsv[1] = 0;
return;
}
double h;
if( r == max )
h = ( g - b ) / delta;
else if( g == max )
h = 2 + ( b - r ) / delta;
else
h = 4 + ( r - g ) / delta;
h *= d60_F64;
if( h < 0 )
h += PI2_F64;
hsv[0] = h;
} | java | public static void rgbToHsv( double r , double g , double b , double []hsv ) {
// Maximum value
double max = r > g ? ( r > b ? r : b) : ( g > b ? g : b );
// Minimum value
double min = r < g ? ( r < b ? r : b) : ( g < b ? g : b );
double delta = max - min;
hsv[2] = max;
if( max != 0 )
hsv[1] = delta / max;
else {
hsv[0] = Double.NaN;
hsv[1] = 0;
return;
}
double h;
if( r == max )
h = ( g - b ) / delta;
else if( g == max )
h = 2 + ( b - r ) / delta;
else
h = 4 + ( r - g ) / delta;
h *= d60_F64;
if( h < 0 )
h += PI2_F64;
hsv[0] = h;
} | [
"public",
"static",
"void",
"rgbToHsv",
"(",
"double",
"r",
",",
"double",
"g",
",",
"double",
"b",
",",
"double",
"[",
"]",
"hsv",
")",
"{",
"// Maximum value",
"double",
"max",
"=",
"r",
">",
"g",
"?",
"(",
"r",
">",
"b",
"?",
"r",
":",
"b",
")",
":",
"(",
"g",
">",
"b",
"?",
"g",
":",
"b",
")",
";",
"// Minimum value",
"double",
"min",
"=",
"r",
"<",
"g",
"?",
"(",
"r",
"<",
"b",
"?",
"r",
":",
"b",
")",
":",
"(",
"g",
"<",
"b",
"?",
"g",
":",
"b",
")",
";",
"double",
"delta",
"=",
"max",
"-",
"min",
";",
"hsv",
"[",
"2",
"]",
"=",
"max",
";",
"if",
"(",
"max",
"!=",
"0",
")",
"hsv",
"[",
"1",
"]",
"=",
"delta",
"/",
"max",
";",
"else",
"{",
"hsv",
"[",
"0",
"]",
"=",
"Double",
".",
"NaN",
";",
"hsv",
"[",
"1",
"]",
"=",
"0",
";",
"return",
";",
"}",
"double",
"h",
";",
"if",
"(",
"r",
"==",
"max",
")",
"h",
"=",
"(",
"g",
"-",
"b",
")",
"/",
"delta",
";",
"else",
"if",
"(",
"g",
"==",
"max",
")",
"h",
"=",
"2",
"+",
"(",
"b",
"-",
"r",
")",
"/",
"delta",
";",
"else",
"h",
"=",
"4",
"+",
"(",
"r",
"-",
"g",
")",
"/",
"delta",
";",
"h",
"*=",
"d60_F64",
";",
"if",
"(",
"h",
"<",
"0",
")",
"h",
"+=",
"PI2_F64",
";",
"hsv",
"[",
"0",
"]",
"=",
"h",
";",
"}"
] | Convert RGB color into HSV color
@param r red
@param g green
@param b blue
@param hsv (Output) HSV value. | [
"Convert",
"RGB",
"color",
"into",
"HSV",
"color"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/color/ColorHsv.java#L207-L237 |
amazon-archives/aws-sdk-java-resources | aws-resources-core/src/main/java/com/amazonaws/resources/internal/ReflectionUtils.java | ReflectionUtils.findAccessor | private static Method findAccessor(Object target, String propertyName) {
"""
Returns the accessor method for the specified member property.
For example, if the member property is "Foo", this method looks
for a "getFoo()" method and an "isFoo()" method.
If no accessor is found, this method throws an IllegalStateException.
@param target the object to reflect on
@param propertyName the name of the property to search for
@return the accessor method
@throws IllegalStateException if no matching method is found
"""
propertyName = propertyName.substring(0, 1).toUpperCase()
+ propertyName.substring(1);
try {
return target.getClass().getMethod("get" + propertyName);
} catch (NoSuchMethodException nsme) {
}
try {
return target.getClass().getMethod("is" + propertyName);
} catch (NoSuchMethodException nsme) {
}
LogFactory.getLog(ReflectionUtils.class).warn(
"No accessor for property '"
+ propertyName + "' " + "found in class "
+ target.getClass().getName());
return null;
} | java | private static Method findAccessor(Object target, String propertyName) {
propertyName = propertyName.substring(0, 1).toUpperCase()
+ propertyName.substring(1);
try {
return target.getClass().getMethod("get" + propertyName);
} catch (NoSuchMethodException nsme) {
}
try {
return target.getClass().getMethod("is" + propertyName);
} catch (NoSuchMethodException nsme) {
}
LogFactory.getLog(ReflectionUtils.class).warn(
"No accessor for property '"
+ propertyName + "' " + "found in class "
+ target.getClass().getName());
return null;
} | [
"private",
"static",
"Method",
"findAccessor",
"(",
"Object",
"target",
",",
"String",
"propertyName",
")",
"{",
"propertyName",
"=",
"propertyName",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"propertyName",
".",
"substring",
"(",
"1",
")",
";",
"try",
"{",
"return",
"target",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"get\"",
"+",
"propertyName",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"nsme",
")",
"{",
"}",
"try",
"{",
"return",
"target",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"is\"",
"+",
"propertyName",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"nsme",
")",
"{",
"}",
"LogFactory",
".",
"getLog",
"(",
"ReflectionUtils",
".",
"class",
")",
".",
"warn",
"(",
"\"No accessor for property '\"",
"+",
"propertyName",
"+",
"\"' \"",
"+",
"\"found in class \"",
"+",
"target",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"return",
"null",
";",
"}"
] | Returns the accessor method for the specified member property.
For example, if the member property is "Foo", this method looks
for a "getFoo()" method and an "isFoo()" method.
If no accessor is found, this method throws an IllegalStateException.
@param target the object to reflect on
@param propertyName the name of the property to search for
@return the accessor method
@throws IllegalStateException if no matching method is found | [
"Returns",
"the",
"accessor",
"method",
"for",
"the",
"specified",
"member",
"property",
".",
"For",
"example",
"if",
"the",
"member",
"property",
"is",
"Foo",
"this",
"method",
"looks",
"for",
"a",
"getFoo",
"()",
"method",
"and",
"an",
"isFoo",
"()",
"method",
"."
] | train | https://github.com/amazon-archives/aws-sdk-java-resources/blob/0f4fef2615d9687997b70a36eed1d62dd42df035/aws-resources-core/src/main/java/com/amazonaws/resources/internal/ReflectionUtils.java#L464-L485 |
michael-rapp/AndroidBottomSheet | library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java | BottomSheet.setDivider | public final void setDivider(final int index, @Nullable final CharSequence title) {
"""
Replaces the item at a specific index with a divider.
@param index
The index of the item, which should be replaced, as an {@link Integer} value
@param title
The title of the divider, which should be added, as an instance of the type {@link
CharSequence}, or null, if no title should be used
"""
Divider divider = new Divider();
divider.setTitle(title);
adapter.set(index, divider);
adaptGridViewHeight();
} | java | public final void setDivider(final int index, @Nullable final CharSequence title) {
Divider divider = new Divider();
divider.setTitle(title);
adapter.set(index, divider);
adaptGridViewHeight();
} | [
"public",
"final",
"void",
"setDivider",
"(",
"final",
"int",
"index",
",",
"@",
"Nullable",
"final",
"CharSequence",
"title",
")",
"{",
"Divider",
"divider",
"=",
"new",
"Divider",
"(",
")",
";",
"divider",
".",
"setTitle",
"(",
"title",
")",
";",
"adapter",
".",
"set",
"(",
"index",
",",
"divider",
")",
";",
"adaptGridViewHeight",
"(",
")",
";",
"}"
] | Replaces the item at a specific index with a divider.
@param index
The index of the item, which should be replaced, as an {@link Integer} value
@param title
The title of the divider, which should be added, as an instance of the type {@link
CharSequence}, or null, if no title should be used | [
"Replaces",
"the",
"item",
"at",
"a",
"specific",
"index",
"with",
"a",
"divider",
"."
] | train | https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/BottomSheet.java#L2185-L2190 |
groupe-sii/ogham | ogham-email-sendgrid/src/main/java/fr/sii/ogham/email/sender/impl/sendgrid/handler/StringContentHandler.java | StringContentHandler.setContent | @Override
public void setContent(final Email email, final Content content) throws ContentHandlerException {
"""
Reads the content and adds it into the email. This method is expected to
update the content of the {@code email} parameter.
While the method signature accepts any {@link Content} instance as
parameter, the method will fail if anything other than a
{@link StringContent} is provided.
@param email
the email to put the content in
@param content
the unprocessed content
@throws ContentHandlerException
the handler is unable to add the content to the email
@throws IllegalArgumentException
the content provided is not of the right type
"""
if (email == null) {
throw new IllegalArgumentException("[email] cannot be null");
}
if (content == null) {
throw new IllegalArgumentException("[content] cannot be null");
}
if (content instanceof StringContent) {
final String contentStr = ((StringContent) content).getContent();
try {
final String mime = mimeProvider.detect(contentStr).toString();
LOG.debug("Email content {} has detected type {}", content, mime);
setMimeContent(email, contentStr, mime);
} catch (MimeTypeDetectionException e) {
throw new ContentHandlerException("Unable to set the email content", e);
}
} else {
throw new IllegalArgumentException("This instance can only work with StringContent instances, but was passed " + content.getClass().getSimpleName());
}
} | java | @Override
public void setContent(final Email email, final Content content) throws ContentHandlerException {
if (email == null) {
throw new IllegalArgumentException("[email] cannot be null");
}
if (content == null) {
throw new IllegalArgumentException("[content] cannot be null");
}
if (content instanceof StringContent) {
final String contentStr = ((StringContent) content).getContent();
try {
final String mime = mimeProvider.detect(contentStr).toString();
LOG.debug("Email content {} has detected type {}", content, mime);
setMimeContent(email, contentStr, mime);
} catch (MimeTypeDetectionException e) {
throw new ContentHandlerException("Unable to set the email content", e);
}
} else {
throw new IllegalArgumentException("This instance can only work with StringContent instances, but was passed " + content.getClass().getSimpleName());
}
} | [
"@",
"Override",
"public",
"void",
"setContent",
"(",
"final",
"Email",
"email",
",",
"final",
"Content",
"content",
")",
"throws",
"ContentHandlerException",
"{",
"if",
"(",
"email",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"[email] cannot be null\"",
")",
";",
"}",
"if",
"(",
"content",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"[content] cannot be null\"",
")",
";",
"}",
"if",
"(",
"content",
"instanceof",
"StringContent",
")",
"{",
"final",
"String",
"contentStr",
"=",
"(",
"(",
"StringContent",
")",
"content",
")",
".",
"getContent",
"(",
")",
";",
"try",
"{",
"final",
"String",
"mime",
"=",
"mimeProvider",
".",
"detect",
"(",
"contentStr",
")",
".",
"toString",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Email content {} has detected type {}\"",
",",
"content",
",",
"mime",
")",
";",
"setMimeContent",
"(",
"email",
",",
"contentStr",
",",
"mime",
")",
";",
"}",
"catch",
"(",
"MimeTypeDetectionException",
"e",
")",
"{",
"throw",
"new",
"ContentHandlerException",
"(",
"\"Unable to set the email content\"",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"This instance can only work with StringContent instances, but was passed \"",
"+",
"content",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}",
"}"
] | Reads the content and adds it into the email. This method is expected to
update the content of the {@code email} parameter.
While the method signature accepts any {@link Content} instance as
parameter, the method will fail if anything other than a
{@link StringContent} is provided.
@param email
the email to put the content in
@param content
the unprocessed content
@throws ContentHandlerException
the handler is unable to add the content to the email
@throws IllegalArgumentException
the content provided is not of the right type | [
"Reads",
"the",
"content",
"and",
"adds",
"it",
"into",
"the",
"email",
".",
"This",
"method",
"is",
"expected",
"to",
"update",
"the",
"content",
"of",
"the",
"{",
"@code",
"email",
"}",
"parameter",
"."
] | train | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-email-sendgrid/src/main/java/fr/sii/ogham/email/sender/impl/sendgrid/handler/StringContentHandler.java#L57-L80 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/fs/ftp/FTPFileSystem.java | FTPFileSystem.exists | private boolean exists(FTPClient client, Path file) {
"""
Convenience method, so that we don't open a new connection when using this
method from within another method. Otherwise every API invocation incurs
the overhead of opening/closing a TCP connection.
"""
try {
return getFileStatus(client, file) != null;
} catch (FileNotFoundException fnfe) {
return false;
} catch (IOException ioe) {
throw new FTPException("Failed to get file status", ioe);
}
} | java | private boolean exists(FTPClient client, Path file) {
try {
return getFileStatus(client, file) != null;
} catch (FileNotFoundException fnfe) {
return false;
} catch (IOException ioe) {
throw new FTPException("Failed to get file status", ioe);
}
} | [
"private",
"boolean",
"exists",
"(",
"FTPClient",
"client",
",",
"Path",
"file",
")",
"{",
"try",
"{",
"return",
"getFileStatus",
"(",
"client",
",",
"file",
")",
"!=",
"null",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"fnfe",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"FTPException",
"(",
"\"Failed to get file status\"",
",",
"ioe",
")",
";",
"}",
"}"
] | Convenience method, so that we don't open a new connection when using this
method from within another method. Otherwise every API invocation incurs
the overhead of opening/closing a TCP connection. | [
"Convenience",
"method",
"so",
"that",
"we",
"don",
"t",
"open",
"a",
"new",
"connection",
"when",
"using",
"this",
"method",
"from",
"within",
"another",
"method",
".",
"Otherwise",
"every",
"API",
"invocation",
"incurs",
"the",
"overhead",
"of",
"opening",
"/",
"closing",
"a",
"TCP",
"connection",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/fs/ftp/FTPFileSystem.java#L258-L266 |
DiUS/pact-jvm | pact-jvm-consumer-java8/src/main/java/io/pactfoundation/consumer/dsl/LambdaDslObject.java | LambdaDslObject.minArrayLike | public LambdaDslObject minArrayLike(String name, Integer size, Consumer<LambdaDslObject> nestedObject) {
"""
Attribute that is an array with a minimum size where each item must match the following example
@param name field name
@param size minimum size of the array
"""
final PactDslJsonBody minArrayLike = object.minArrayLike(name, size);
final LambdaDslObject dslObject = new LambdaDslObject(minArrayLike);
nestedObject.accept(dslObject);
minArrayLike.closeArray();
return this;
} | java | public LambdaDslObject minArrayLike(String name, Integer size, Consumer<LambdaDslObject> nestedObject) {
final PactDslJsonBody minArrayLike = object.minArrayLike(name, size);
final LambdaDslObject dslObject = new LambdaDslObject(minArrayLike);
nestedObject.accept(dslObject);
minArrayLike.closeArray();
return this;
} | [
"public",
"LambdaDslObject",
"minArrayLike",
"(",
"String",
"name",
",",
"Integer",
"size",
",",
"Consumer",
"<",
"LambdaDslObject",
">",
"nestedObject",
")",
"{",
"final",
"PactDslJsonBody",
"minArrayLike",
"=",
"object",
".",
"minArrayLike",
"(",
"name",
",",
"size",
")",
";",
"final",
"LambdaDslObject",
"dslObject",
"=",
"new",
"LambdaDslObject",
"(",
"minArrayLike",
")",
";",
"nestedObject",
".",
"accept",
"(",
"dslObject",
")",
";",
"minArrayLike",
".",
"closeArray",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Attribute that is an array with a minimum size where each item must match the following example
@param name field name
@param size minimum size of the array | [
"Attribute",
"that",
"is",
"an",
"array",
"with",
"a",
"minimum",
"size",
"where",
"each",
"item",
"must",
"match",
"the",
"following",
"example"
] | train | https://github.com/DiUS/pact-jvm/blob/2f447e9dd4ac152a6a36b7fcf8962d07de9ef3ef/pact-jvm-consumer-java8/src/main/java/io/pactfoundation/consumer/dsl/LambdaDslObject.java#L438-L444 |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsDynamicFunctionParser.java | CmsDynamicFunctionParser.getLocaleToUse | protected Locale getLocaleToUse(CmsObject cms, CmsXmlContent xmlContent) {
"""
Gets the locale to use for parsing the dynamic function.<p>
@param cms the current CMS context
@param xmlContent the xml content from which the dynamic function should be read
@return the locale from which the dynamic function should be read
"""
Locale contextLocale = cms.getRequestContext().getLocale();
if (xmlContent.hasLocale(contextLocale)) {
return contextLocale;
}
Locale defaultLocale = CmsLocaleManager.getDefaultLocale();
if (xmlContent.hasLocale(defaultLocale)) {
return defaultLocale;
}
if (!xmlContent.getLocales().isEmpty()) {
return xmlContent.getLocales().get(0);
} else {
return defaultLocale;
}
} | java | protected Locale getLocaleToUse(CmsObject cms, CmsXmlContent xmlContent) {
Locale contextLocale = cms.getRequestContext().getLocale();
if (xmlContent.hasLocale(contextLocale)) {
return contextLocale;
}
Locale defaultLocale = CmsLocaleManager.getDefaultLocale();
if (xmlContent.hasLocale(defaultLocale)) {
return defaultLocale;
}
if (!xmlContent.getLocales().isEmpty()) {
return xmlContent.getLocales().get(0);
} else {
return defaultLocale;
}
} | [
"protected",
"Locale",
"getLocaleToUse",
"(",
"CmsObject",
"cms",
",",
"CmsXmlContent",
"xmlContent",
")",
"{",
"Locale",
"contextLocale",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getLocale",
"(",
")",
";",
"if",
"(",
"xmlContent",
".",
"hasLocale",
"(",
"contextLocale",
")",
")",
"{",
"return",
"contextLocale",
";",
"}",
"Locale",
"defaultLocale",
"=",
"CmsLocaleManager",
".",
"getDefaultLocale",
"(",
")",
";",
"if",
"(",
"xmlContent",
".",
"hasLocale",
"(",
"defaultLocale",
")",
")",
"{",
"return",
"defaultLocale",
";",
"}",
"if",
"(",
"!",
"xmlContent",
".",
"getLocales",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"xmlContent",
".",
"getLocales",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"{",
"return",
"defaultLocale",
";",
"}",
"}"
] | Gets the locale to use for parsing the dynamic function.<p>
@param cms the current CMS context
@param xmlContent the xml content from which the dynamic function should be read
@return the locale from which the dynamic function should be read | [
"Gets",
"the",
"locale",
"to",
"use",
"for",
"parsing",
"the",
"dynamic",
"function",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsDynamicFunctionParser.java#L158-L173 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java | UpgradeInputByteBufferUtil.validate | private void validate() throws IOException {
"""
This checks if we have already had an exception thrown. If so it just rethrows that exception
This check is done before any reads are done
@throws IOException
"""
if (null != _error) {
throw _error;
}
if(!_isReadLine && !_isReady){
//If there is no data available then isReady will have returned false and this throw an IllegalStateException
if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
Tr.error(tc, "read.failed.isReady.false");
throw new IllegalStateException(Tr.formatMessage(tc, "read.failed.isReady.false"));
}
} | java | private void validate() throws IOException {
if (null != _error) {
throw _error;
}
if(!_isReadLine && !_isReady){
//If there is no data available then isReady will have returned false and this throw an IllegalStateException
if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
Tr.error(tc, "read.failed.isReady.false");
throw new IllegalStateException(Tr.formatMessage(tc, "read.failed.isReady.false"));
}
} | [
"private",
"void",
"validate",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"null",
"!=",
"_error",
")",
"{",
"throw",
"_error",
";",
"}",
"if",
"(",
"!",
"_isReadLine",
"&&",
"!",
"_isReady",
")",
"{",
"//If there is no data available then isReady will have returned false and this throw an IllegalStateException",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isErrorEnabled",
"(",
")",
")",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"read.failed.isReady.false\"",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"Tr",
".",
"formatMessage",
"(",
"tc",
",",
"\"read.failed.isReady.false\"",
")",
")",
";",
"}",
"}"
] | This checks if we have already had an exception thrown. If so it just rethrows that exception
This check is done before any reads are done
@throws IOException | [
"This",
"checks",
"if",
"we",
"have",
"already",
"had",
"an",
"exception",
"thrown",
".",
"If",
"so",
"it",
"just",
"rethrows",
"that",
"exception",
"This",
"check",
"is",
"done",
"before",
"any",
"reads",
"are",
"done"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.servlet.3.1/src/com/ibm/ws/webcontainer31/util/UpgradeInputByteBufferUtil.java#L309-L320 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.replaceOptAln | public static AFPChain replaceOptAln(AFPChain afpChain, Atom[] ca1, Atom[] ca2,
Map<Integer, Integer> alignment) throws StructureException {
"""
Takes an AFPChain and replaces the optimal alignment based on an alignment map
<p>Parameters are filled with defaults (often null) or sometimes
calculated.
<p>For a way to create a new AFPChain, see
{@link AlignmentTools#createAFPChain(Atom[], Atom[], ResidueNumber[], ResidueNumber[])}
@param afpChain The alignment to be modified
@param alignment The new alignment, as a Map
@throws StructureException if an error occurred during superposition
@see AlignmentTools#createAFPChain(Atom[], Atom[], ResidueNumber[], ResidueNumber[])
"""
// Determine block lengths
// Sort ca1 indices, then start a new block whenever ca2 indices aren't
// increasing monotonically.
Integer[] res1 = alignment.keySet().toArray(new Integer[0]);
Arrays.sort(res1);
List<Integer> blockLens = new ArrayList<Integer>(2);
int optLength = 0;
Integer lastRes = alignment.get(res1[0]);
int blkLen = lastRes==null?0:1;
for(int i=1;i<res1.length;i++) {
Integer currRes = alignment.get(res1[i]); //res2 index
assert(currRes != null);// could be converted to if statement if assertion doesn't hold; just modify below as well.
if(lastRes<currRes) {
blkLen++;
} else {
// CP!
blockLens.add(blkLen);
optLength+=blkLen;
blkLen = 1;
}
lastRes = currRes;
}
blockLens.add(blkLen);
optLength+=blkLen;
// Create array structure for alignment
int[][][] optAln = new int[blockLens.size()][][];
int pos1 = 0; //index into res1
for(int blk=0;blk<blockLens.size();blk++) {
optAln[blk] = new int[2][];
blkLen = blockLens.get(blk);
optAln[blk][0] = new int[blkLen];
optAln[blk][1] = new int[blkLen];
int pos = 0; //index into optAln
while(pos<blkLen) {
optAln[blk][0][pos]=res1[pos1];
Integer currRes = alignment.get(res1[pos1]);
optAln[blk][1][pos]=currRes;
pos++;
pos1++;
}
}
assert(pos1 == optLength);
// Create length array
int[] optLens = new int[blockLens.size()];
for(int i=0;i<blockLens.size();i++) {
optLens[i] = blockLens.get(i);
}
return replaceOptAln(afpChain, ca1, ca2, blockLens.size(), optLens, optAln);
} | java | public static AFPChain replaceOptAln(AFPChain afpChain, Atom[] ca1, Atom[] ca2,
Map<Integer, Integer> alignment) throws StructureException {
// Determine block lengths
// Sort ca1 indices, then start a new block whenever ca2 indices aren't
// increasing monotonically.
Integer[] res1 = alignment.keySet().toArray(new Integer[0]);
Arrays.sort(res1);
List<Integer> blockLens = new ArrayList<Integer>(2);
int optLength = 0;
Integer lastRes = alignment.get(res1[0]);
int blkLen = lastRes==null?0:1;
for(int i=1;i<res1.length;i++) {
Integer currRes = alignment.get(res1[i]); //res2 index
assert(currRes != null);// could be converted to if statement if assertion doesn't hold; just modify below as well.
if(lastRes<currRes) {
blkLen++;
} else {
// CP!
blockLens.add(blkLen);
optLength+=blkLen;
blkLen = 1;
}
lastRes = currRes;
}
blockLens.add(blkLen);
optLength+=blkLen;
// Create array structure for alignment
int[][][] optAln = new int[blockLens.size()][][];
int pos1 = 0; //index into res1
for(int blk=0;blk<blockLens.size();blk++) {
optAln[blk] = new int[2][];
blkLen = blockLens.get(blk);
optAln[blk][0] = new int[blkLen];
optAln[blk][1] = new int[blkLen];
int pos = 0; //index into optAln
while(pos<blkLen) {
optAln[blk][0][pos]=res1[pos1];
Integer currRes = alignment.get(res1[pos1]);
optAln[blk][1][pos]=currRes;
pos++;
pos1++;
}
}
assert(pos1 == optLength);
// Create length array
int[] optLens = new int[blockLens.size()];
for(int i=0;i<blockLens.size();i++) {
optLens[i] = blockLens.get(i);
}
return replaceOptAln(afpChain, ca1, ca2, blockLens.size(), optLens, optAln);
} | [
"public",
"static",
"AFPChain",
"replaceOptAln",
"(",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
",",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"alignment",
")",
"throws",
"StructureException",
"{",
"// Determine block lengths",
"// Sort ca1 indices, then start a new block whenever ca2 indices aren't",
"// increasing monotonically.",
"Integer",
"[",
"]",
"res1",
"=",
"alignment",
".",
"keySet",
"(",
")",
".",
"toArray",
"(",
"new",
"Integer",
"[",
"0",
"]",
")",
";",
"Arrays",
".",
"sort",
"(",
"res1",
")",
";",
"List",
"<",
"Integer",
">",
"blockLens",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
"2",
")",
";",
"int",
"optLength",
"=",
"0",
";",
"Integer",
"lastRes",
"=",
"alignment",
".",
"get",
"(",
"res1",
"[",
"0",
"]",
")",
";",
"int",
"blkLen",
"=",
"lastRes",
"==",
"null",
"?",
"0",
":",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"res1",
".",
"length",
";",
"i",
"++",
")",
"{",
"Integer",
"currRes",
"=",
"alignment",
".",
"get",
"(",
"res1",
"[",
"i",
"]",
")",
";",
"//res2 index",
"assert",
"(",
"currRes",
"!=",
"null",
")",
";",
"// could be converted to if statement if assertion doesn't hold; just modify below as well.",
"if",
"(",
"lastRes",
"<",
"currRes",
")",
"{",
"blkLen",
"++",
";",
"}",
"else",
"{",
"// CP!",
"blockLens",
".",
"add",
"(",
"blkLen",
")",
";",
"optLength",
"+=",
"blkLen",
";",
"blkLen",
"=",
"1",
";",
"}",
"lastRes",
"=",
"currRes",
";",
"}",
"blockLens",
".",
"add",
"(",
"blkLen",
")",
";",
"optLength",
"+=",
"blkLen",
";",
"// Create array structure for alignment",
"int",
"[",
"]",
"[",
"]",
"[",
"]",
"optAln",
"=",
"new",
"int",
"[",
"blockLens",
".",
"size",
"(",
")",
"]",
"[",
"",
"]",
"[",
"",
"]",
";",
"int",
"pos1",
"=",
"0",
";",
"//index into res1",
"for",
"(",
"int",
"blk",
"=",
"0",
";",
"blk",
"<",
"blockLens",
".",
"size",
"(",
")",
";",
"blk",
"++",
")",
"{",
"optAln",
"[",
"blk",
"]",
"=",
"new",
"int",
"[",
"2",
"]",
"[",
"",
"]",
";",
"blkLen",
"=",
"blockLens",
".",
"get",
"(",
"blk",
")",
";",
"optAln",
"[",
"blk",
"]",
"[",
"0",
"]",
"=",
"new",
"int",
"[",
"blkLen",
"]",
";",
"optAln",
"[",
"blk",
"]",
"[",
"1",
"]",
"=",
"new",
"int",
"[",
"blkLen",
"]",
";",
"int",
"pos",
"=",
"0",
";",
"//index into optAln",
"while",
"(",
"pos",
"<",
"blkLen",
")",
"{",
"optAln",
"[",
"blk",
"]",
"[",
"0",
"]",
"[",
"pos",
"]",
"=",
"res1",
"[",
"pos1",
"]",
";",
"Integer",
"currRes",
"=",
"alignment",
".",
"get",
"(",
"res1",
"[",
"pos1",
"]",
")",
";",
"optAln",
"[",
"blk",
"]",
"[",
"1",
"]",
"[",
"pos",
"]",
"=",
"currRes",
";",
"pos",
"++",
";",
"pos1",
"++",
";",
"}",
"}",
"assert",
"(",
"pos1",
"==",
"optLength",
")",
";",
"// Create length array",
"int",
"[",
"]",
"optLens",
"=",
"new",
"int",
"[",
"blockLens",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"blockLens",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"optLens",
"[",
"i",
"]",
"=",
"blockLens",
".",
"get",
"(",
"i",
")",
";",
"}",
"return",
"replaceOptAln",
"(",
"afpChain",
",",
"ca1",
",",
"ca2",
",",
"blockLens",
".",
"size",
"(",
")",
",",
"optLens",
",",
"optAln",
")",
";",
"}"
] | Takes an AFPChain and replaces the optimal alignment based on an alignment map
<p>Parameters are filled with defaults (often null) or sometimes
calculated.
<p>For a way to create a new AFPChain, see
{@link AlignmentTools#createAFPChain(Atom[], Atom[], ResidueNumber[], ResidueNumber[])}
@param afpChain The alignment to be modified
@param alignment The new alignment, as a Map
@throws StructureException if an error occurred during superposition
@see AlignmentTools#createAFPChain(Atom[], Atom[], ResidueNumber[], ResidueNumber[]) | [
"Takes",
"an",
"AFPChain",
"and",
"replaces",
"the",
"optimal",
"alignment",
"based",
"on",
"an",
"alignment",
"map"
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L753-L807 |
cdk/cdk | descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/ProtonTotalPartialChargeDescriptor.java | ProtonTotalPartialChargeDescriptor.calculate | @Override
public DescriptorValue calculate(IAtom atom, IAtomContainer ac) {
"""
The method returns partial charges assigned to an heavy atom and its protons through Gasteiger Marsili
It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools.HydrogenAdder.
@param atom The IAtom for which the DescriptorValue is requested
@param ac AtomContainer
@return an array of doubles with partial charges of [heavy, proton_1 ... proton_n]
"""
neighboors = ac.getConnectedAtomsList(atom);
IAtomContainer clone;
try {
clone = (IAtomContainer) ac.clone();
} catch (CloneNotSupportedException e) {
return getDummyDescriptorValue(e);
}
try {
peoe = new GasteigerMarsiliPartialCharges();
peoe.setMaxGasteigerIters(6);
// HydrogenAdder hAdder = new HydrogenAdder();
// hAdder.addExplicitHydrogensToSatisfyValency(mol);
peoe.assignGasteigerMarsiliSigmaPartialCharges(clone, true);
} catch (Exception exception) {
return getDummyDescriptorValue(exception);
}
IAtom localAtom = clone.getAtom(ac.indexOf(atom));
neighboors = clone.getConnectedAtomsList(localAtom);
// we assume that an atom has a mxa number of protons = MAX_PROTON_COUNT
// if it has less, we pad with NaN
DoubleArrayResult protonPartialCharge = new DoubleArrayResult(MAX_PROTON_COUNT);
assert (neighboors.size() < MAX_PROTON_COUNT);
protonPartialCharge.add(localAtom.getCharge());
int hydrogenNeighbors = 0;
for (IAtom neighboor : neighboors) {
if (neighboor.getSymbol().equals("H")) {
hydrogenNeighbors++;
protonPartialCharge.add(neighboor.getCharge());
}
}
int remainder = MAX_PROTON_COUNT - (hydrogenNeighbors + 1);
for (int i = 0; i < remainder; i++)
protonPartialCharge.add(Double.NaN);
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), protonPartialCharge,
getDescriptorNames());
} | java | @Override
public DescriptorValue calculate(IAtom atom, IAtomContainer ac) {
neighboors = ac.getConnectedAtomsList(atom);
IAtomContainer clone;
try {
clone = (IAtomContainer) ac.clone();
} catch (CloneNotSupportedException e) {
return getDummyDescriptorValue(e);
}
try {
peoe = new GasteigerMarsiliPartialCharges();
peoe.setMaxGasteigerIters(6);
// HydrogenAdder hAdder = new HydrogenAdder();
// hAdder.addExplicitHydrogensToSatisfyValency(mol);
peoe.assignGasteigerMarsiliSigmaPartialCharges(clone, true);
} catch (Exception exception) {
return getDummyDescriptorValue(exception);
}
IAtom localAtom = clone.getAtom(ac.indexOf(atom));
neighboors = clone.getConnectedAtomsList(localAtom);
// we assume that an atom has a mxa number of protons = MAX_PROTON_COUNT
// if it has less, we pad with NaN
DoubleArrayResult protonPartialCharge = new DoubleArrayResult(MAX_PROTON_COUNT);
assert (neighboors.size() < MAX_PROTON_COUNT);
protonPartialCharge.add(localAtom.getCharge());
int hydrogenNeighbors = 0;
for (IAtom neighboor : neighboors) {
if (neighboor.getSymbol().equals("H")) {
hydrogenNeighbors++;
protonPartialCharge.add(neighboor.getCharge());
}
}
int remainder = MAX_PROTON_COUNT - (hydrogenNeighbors + 1);
for (int i = 0; i < remainder; i++)
protonPartialCharge.add(Double.NaN);
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), protonPartialCharge,
getDescriptorNames());
} | [
"@",
"Override",
"public",
"DescriptorValue",
"calculate",
"(",
"IAtom",
"atom",
",",
"IAtomContainer",
"ac",
")",
"{",
"neighboors",
"=",
"ac",
".",
"getConnectedAtomsList",
"(",
"atom",
")",
";",
"IAtomContainer",
"clone",
";",
"try",
"{",
"clone",
"=",
"(",
"IAtomContainer",
")",
"ac",
".",
"clone",
"(",
")",
";",
"}",
"catch",
"(",
"CloneNotSupportedException",
"e",
")",
"{",
"return",
"getDummyDescriptorValue",
"(",
"e",
")",
";",
"}",
"try",
"{",
"peoe",
"=",
"new",
"GasteigerMarsiliPartialCharges",
"(",
")",
";",
"peoe",
".",
"setMaxGasteigerIters",
"(",
"6",
")",
";",
"//\tHydrogenAdder hAdder = new HydrogenAdder();",
"//\thAdder.addExplicitHydrogensToSatisfyValency(mol);",
"peoe",
".",
"assignGasteigerMarsiliSigmaPartialCharges",
"(",
"clone",
",",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"exception",
")",
"{",
"return",
"getDummyDescriptorValue",
"(",
"exception",
")",
";",
"}",
"IAtom",
"localAtom",
"=",
"clone",
".",
"getAtom",
"(",
"ac",
".",
"indexOf",
"(",
"atom",
")",
")",
";",
"neighboors",
"=",
"clone",
".",
"getConnectedAtomsList",
"(",
"localAtom",
")",
";",
"// we assume that an atom has a mxa number of protons = MAX_PROTON_COUNT",
"// if it has less, we pad with NaN",
"DoubleArrayResult",
"protonPartialCharge",
"=",
"new",
"DoubleArrayResult",
"(",
"MAX_PROTON_COUNT",
")",
";",
"assert",
"(",
"neighboors",
".",
"size",
"(",
")",
"<",
"MAX_PROTON_COUNT",
")",
";",
"protonPartialCharge",
".",
"add",
"(",
"localAtom",
".",
"getCharge",
"(",
")",
")",
";",
"int",
"hydrogenNeighbors",
"=",
"0",
";",
"for",
"(",
"IAtom",
"neighboor",
":",
"neighboors",
")",
"{",
"if",
"(",
"neighboor",
".",
"getSymbol",
"(",
")",
".",
"equals",
"(",
"\"H\"",
")",
")",
"{",
"hydrogenNeighbors",
"++",
";",
"protonPartialCharge",
".",
"add",
"(",
"neighboor",
".",
"getCharge",
"(",
")",
")",
";",
"}",
"}",
"int",
"remainder",
"=",
"MAX_PROTON_COUNT",
"-",
"(",
"hydrogenNeighbors",
"+",
"1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"remainder",
";",
"i",
"++",
")",
"protonPartialCharge",
".",
"(",
"Double",
".",
"NaN",
")",
";",
"return",
"new",
"DescriptorValue",
"(",
"getSpecification",
"(",
")",
",",
"getParameterNames",
"(",
")",
",",
"getParameters",
"(",
")",
",",
"protonPartialCharge",
",",
"getDescriptorNames",
"(",
")",
")",
";",
"}"
] | The method returns partial charges assigned to an heavy atom and its protons through Gasteiger Marsili
It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools.HydrogenAdder.
@param atom The IAtom for which the DescriptorValue is requested
@param ac AtomContainer
@return an array of doubles with partial charges of [heavy, proton_1 ... proton_n] | [
"The",
"method",
"returns",
"partial",
"charges",
"assigned",
"to",
"an",
"heavy",
"atom",
"and",
"its",
"protons",
"through",
"Gasteiger",
"Marsili",
"It",
"is",
"needed",
"to",
"call",
"the",
"addExplicitHydrogensToSatisfyValency",
"method",
"from",
"the",
"class",
"tools",
".",
"HydrogenAdder",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/ProtonTotalPartialChargeDescriptor.java#L116-L159 |
exoplatform/jcr | exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/lnkproducer/LinkGenerator.java | LinkGenerator.simpleWriteString | private void simpleWriteString(String outString, OutputStream outStream) throws IOException {
"""
Writes string into stream.
@param outString string
@param outStream stream
@throws IOException {@link IOException}
"""
for (int i = 0; i < outString.length(); i++)
{
int charCode = outString.charAt(i);
outStream.write(charCode & 0xFF);
outStream.write((charCode >> 8) & 0xFF);
}
} | java | private void simpleWriteString(String outString, OutputStream outStream) throws IOException
{
for (int i = 0; i < outString.length(); i++)
{
int charCode = outString.charAt(i);
outStream.write(charCode & 0xFF);
outStream.write((charCode >> 8) & 0xFF);
}
} | [
"private",
"void",
"simpleWriteString",
"(",
"String",
"outString",
",",
"OutputStream",
"outStream",
")",
"throws",
"IOException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"outString",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"int",
"charCode",
"=",
"outString",
".",
"charAt",
"(",
"i",
")",
";",
"outStream",
".",
"write",
"(",
"charCode",
"&",
"0xFF",
")",
";",
"outStream",
".",
"write",
"(",
"(",
"charCode",
">>",
"8",
")",
"&",
"0xFF",
")",
";",
"}",
"}"
] | Writes string into stream.
@param outString string
@param outStream stream
@throws IOException {@link IOException} | [
"Writes",
"string",
"into",
"stream",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/lnkproducer/LinkGenerator.java#L333-L341 |
Talend/tesb-rt-se | sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProtocolHeaderCodec.java | FlowIdProtocolHeaderCodec.writeFlowId | public static void writeFlowId(Message message, String flowId) {
"""
Write flow id.
@param message the message
@param flowId the flow id
"""
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
headers.put(FLOWID_HTTP_HEADER_NAME, Collections.singletonList(flowId));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' set to: " + flowId);
}
} | java | public static void writeFlowId(Message message, String flowId) {
Map<String, List<String>> headers = getOrCreateProtocolHeader(message);
headers.put(FLOWID_HTTP_HEADER_NAME, Collections.singletonList(flowId));
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("HTTP header '" + FLOWID_HTTP_HEADER_NAME + "' set to: " + flowId);
}
} | [
"public",
"static",
"void",
"writeFlowId",
"(",
"Message",
"message",
",",
"String",
"flowId",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
"=",
"getOrCreateProtocolHeader",
"(",
"message",
")",
";",
"headers",
".",
"put",
"(",
"FLOWID_HTTP_HEADER_NAME",
",",
"Collections",
".",
"singletonList",
"(",
"flowId",
")",
")",
";",
"if",
"(",
"LOG",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"HTTP header '\"",
"+",
"FLOWID_HTTP_HEADER_NAME",
"+",
"\"' set to: \"",
"+",
"flowId",
")",
";",
"}",
"}"
] | Write flow id.
@param message the message
@param flowId the flow id | [
"Write",
"flow",
"id",
"."
] | train | https://github.com/Talend/tesb-rt-se/blob/0a151a6d91ffff65ac4b5ee0c5b2c882ac28d886/sam/sam-agent/src/main/java/org/talend/esb/sam/agent/flowidprocessor/FlowIdProtocolHeaderCodec.java#L77-L83 |
mikepenz/Android-Iconics | library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java | IconicsDrawable.backgroundContourColorListRes | @NonNull
public IconicsDrawable backgroundContourColorListRes(@ColorRes int colorResId) {
"""
Set background contour colors from color res.
@return The current IconicsDrawable for chaining.
"""
return backgroundContourColor(ContextCompat.getColorStateList(mContext, colorResId));
} | java | @NonNull
public IconicsDrawable backgroundContourColorListRes(@ColorRes int colorResId) {
return backgroundContourColor(ContextCompat.getColorStateList(mContext, colorResId));
} | [
"@",
"NonNull",
"public",
"IconicsDrawable",
"backgroundContourColorListRes",
"(",
"@",
"ColorRes",
"int",
"colorResId",
")",
"{",
"return",
"backgroundContourColor",
"(",
"ContextCompat",
".",
"getColorStateList",
"(",
"mContext",
",",
"colorResId",
")",
")",
";",
"}"
] | Set background contour colors from color res.
@return The current IconicsDrawable for chaining. | [
"Set",
"background",
"contour",
"colors",
"from",
"color",
"res",
"."
] | train | https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L764-L767 |
Wadpam/guja | guja-gae/src/main/java/com/wadpam/guja/servlet/GAEBlobServlet.java | GAEBlobServlet.getUploadUrl | private void getUploadUrl(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
"""
Get an upload URL
@param req
@param resp
@throws ServletException
@throws IOException
"""
LOGGER.debug("Get blobstore upload url");
String callback = req.getParameter(CALLBACK_PARAM);
if (null == callback) {
callback = req.getRequestURI();
}
String keepQueryParam = req.getParameter(KEEP_QUERY_PARAM);
// Forward any existing query parameters, e.g. access_token
if (null != keepQueryParam) {
final String queryString = req.getQueryString();
callback = String.format("%s?%s", callback, null != queryString ? queryString : "");
}
Map<String, String> response = ImmutableMap.of("uploadUrl", blobstoreService.createUploadUrl(callback));
PrintWriter out = resp.getWriter();
resp.setContentType(JsonCharacterEncodingResponseFilter.APPLICATION_JSON_UTF8);
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(out, response);
out.close();
} | java | private void getUploadUrl(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
LOGGER.debug("Get blobstore upload url");
String callback = req.getParameter(CALLBACK_PARAM);
if (null == callback) {
callback = req.getRequestURI();
}
String keepQueryParam = req.getParameter(KEEP_QUERY_PARAM);
// Forward any existing query parameters, e.g. access_token
if (null != keepQueryParam) {
final String queryString = req.getQueryString();
callback = String.format("%s?%s", callback, null != queryString ? queryString : "");
}
Map<String, String> response = ImmutableMap.of("uploadUrl", blobstoreService.createUploadUrl(callback));
PrintWriter out = resp.getWriter();
resp.setContentType(JsonCharacterEncodingResponseFilter.APPLICATION_JSON_UTF8);
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(out, response);
out.close();
} | [
"private",
"void",
"getUploadUrl",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"resp",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Get blobstore upload url\"",
")",
";",
"String",
"callback",
"=",
"req",
".",
"getParameter",
"(",
"CALLBACK_PARAM",
")",
";",
"if",
"(",
"null",
"==",
"callback",
")",
"{",
"callback",
"=",
"req",
".",
"getRequestURI",
"(",
")",
";",
"}",
"String",
"keepQueryParam",
"=",
"req",
".",
"getParameter",
"(",
"KEEP_QUERY_PARAM",
")",
";",
"// Forward any existing query parameters, e.g. access_token",
"if",
"(",
"null",
"!=",
"keepQueryParam",
")",
"{",
"final",
"String",
"queryString",
"=",
"req",
".",
"getQueryString",
"(",
")",
";",
"callback",
"=",
"String",
".",
"format",
"(",
"\"%s?%s\"",
",",
"callback",
",",
"null",
"!=",
"queryString",
"?",
"queryString",
":",
"\"\"",
")",
";",
"}",
"Map",
"<",
"String",
",",
"String",
">",
"response",
"=",
"ImmutableMap",
".",
"of",
"(",
"\"uploadUrl\"",
",",
"blobstoreService",
".",
"createUploadUrl",
"(",
"callback",
")",
")",
";",
"PrintWriter",
"out",
"=",
"resp",
".",
"getWriter",
"(",
")",
";",
"resp",
".",
"setContentType",
"(",
"JsonCharacterEncodingResponseFilter",
".",
"APPLICATION_JSON_UTF8",
")",
";",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"mapper",
".",
"writeValue",
"(",
"out",
",",
"response",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"}"
] | Get an upload URL
@param req
@param resp
@throws ServletException
@throws IOException | [
"Get",
"an",
"upload",
"URL"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-gae/src/main/java/com/wadpam/guja/servlet/GAEBlobServlet.java#L104-L128 |
alkacon/opencms-core | src/org/opencms/search/CmsSearchManager.java | CmsSearchManager.removeSearchFieldMapping | public boolean removeSearchFieldMapping(CmsLuceneField field, CmsSearchFieldMapping mapping)
throws CmsIllegalStateException {
"""
Removes a search field mapping from the given field.<p>
@param field the field
@param mapping mapping to remove from the field
@return true if remove was successful, false if preconditions for removal are ok but the given
mapping was unknown.
@throws CmsIllegalStateException if the given mapping is the last mapping inside the given field.
"""
if (field.getMappings().size() < 2) {
throw new CmsIllegalStateException(
Messages.get().container(
Messages.ERR_FIELD_MAPPING_DELETE_2,
mapping.getType().toString(),
field.getName()));
} else {
if (LOG.isInfoEnabled()) {
LOG.info(
Messages.get().getBundle().key(
Messages.LOG_REMOVE_FIELD_MAPPING_INDEX_2,
mapping.toString(),
field.getName()));
}
return field.getMappings().remove(mapping);
}
} | java | public boolean removeSearchFieldMapping(CmsLuceneField field, CmsSearchFieldMapping mapping)
throws CmsIllegalStateException {
if (field.getMappings().size() < 2) {
throw new CmsIllegalStateException(
Messages.get().container(
Messages.ERR_FIELD_MAPPING_DELETE_2,
mapping.getType().toString(),
field.getName()));
} else {
if (LOG.isInfoEnabled()) {
LOG.info(
Messages.get().getBundle().key(
Messages.LOG_REMOVE_FIELD_MAPPING_INDEX_2,
mapping.toString(),
field.getName()));
}
return field.getMappings().remove(mapping);
}
} | [
"public",
"boolean",
"removeSearchFieldMapping",
"(",
"CmsLuceneField",
"field",
",",
"CmsSearchFieldMapping",
"mapping",
")",
"throws",
"CmsIllegalStateException",
"{",
"if",
"(",
"field",
".",
"getMappings",
"(",
")",
".",
"size",
"(",
")",
"<",
"2",
")",
"{",
"throw",
"new",
"CmsIllegalStateException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_FIELD_MAPPING_DELETE_2",
",",
"mapping",
".",
"getType",
"(",
")",
".",
"toString",
"(",
")",
",",
"field",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"LOG",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"LOG_REMOVE_FIELD_MAPPING_INDEX_2",
",",
"mapping",
".",
"toString",
"(",
")",
",",
"field",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"return",
"field",
".",
"getMappings",
"(",
")",
".",
"remove",
"(",
"mapping",
")",
";",
"}",
"}"
] | Removes a search field mapping from the given field.<p>
@param field the field
@param mapping mapping to remove from the field
@return true if remove was successful, false if preconditions for removal are ok but the given
mapping was unknown.
@throws CmsIllegalStateException if the given mapping is the last mapping inside the given field. | [
"Removes",
"a",
"search",
"field",
"mapping",
"from",
"the",
"given",
"field",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/CmsSearchManager.java#L1931-L1951 |
xdcrafts/flower | flower-tools/src/main/java/com/github/xdcrafts/flower/tools/map/MapApi.java | MapApi.getNullableOptional | public static <T> Optional<T> getNullableOptional(final Map map, final Class<T> clazz, final Object... path) {
"""
Get optional value by path.
@param <T> optional value type
@param clazz type of value
@param map subject
@param path nodes to walk in map
@return value
"""
return getNullable(map, Optional.class, path);
} | java | public static <T> Optional<T> getNullableOptional(final Map map, final Class<T> clazz, final Object... path) {
return getNullable(map, Optional.class, path);
} | [
"public",
"static",
"<",
"T",
">",
"Optional",
"<",
"T",
">",
"getNullableOptional",
"(",
"final",
"Map",
"map",
",",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"Object",
"...",
"path",
")",
"{",
"return",
"getNullable",
"(",
"map",
",",
"Optional",
".",
"class",
",",
"path",
")",
";",
"}"
] | Get optional value by path.
@param <T> optional value type
@param clazz type of value
@param map subject
@param path nodes to walk in map
@return value | [
"Get",
"optional",
"value",
"by",
"path",
"."
] | train | https://github.com/xdcrafts/flower/blob/96a8e49102fea434bd383a3c7852f0ee9545f999/flower-tools/src/main/java/com/github/xdcrafts/flower/tools/map/MapApi.java#L283-L285 |
apache/incubator-gobblin | gobblin-compaction/src/main/java/org/apache/gobblin/compaction/dataset/TimeBasedSubDirDatasetsFinder.java | TimeBasedSubDirDatasetsFinder.folderWithinAllowedPeriod | protected boolean folderWithinAllowedPeriod(Path inputFolder, DateTime folderTime) {
"""
Return true iff input folder time is between compaction.timebased.min.time.ago and
compaction.timebased.max.time.ago.
"""
DateTime currentTime = new DateTime(this.timeZone);
PeriodFormatter periodFormatter = getPeriodFormatter();
DateTime earliestAllowedFolderTime = getEarliestAllowedFolderTime(currentTime, periodFormatter);
DateTime latestAllowedFolderTime = getLatestAllowedFolderTime(currentTime, periodFormatter);
if (folderTime.isBefore(earliestAllowedFolderTime)) {
log.info(String.format("Folder time for %s is %s, earlier than the earliest allowed folder time, %s. Skipping",
inputFolder, folderTime, earliestAllowedFolderTime));
return false;
} else if (folderTime.isAfter(latestAllowedFolderTime)) {
log.info(String.format("Folder time for %s is %s, later than the latest allowed folder time, %s. Skipping",
inputFolder, folderTime, latestAllowedFolderTime));
return false;
} else {
return true;
}
} | java | protected boolean folderWithinAllowedPeriod(Path inputFolder, DateTime folderTime) {
DateTime currentTime = new DateTime(this.timeZone);
PeriodFormatter periodFormatter = getPeriodFormatter();
DateTime earliestAllowedFolderTime = getEarliestAllowedFolderTime(currentTime, periodFormatter);
DateTime latestAllowedFolderTime = getLatestAllowedFolderTime(currentTime, periodFormatter);
if (folderTime.isBefore(earliestAllowedFolderTime)) {
log.info(String.format("Folder time for %s is %s, earlier than the earliest allowed folder time, %s. Skipping",
inputFolder, folderTime, earliestAllowedFolderTime));
return false;
} else if (folderTime.isAfter(latestAllowedFolderTime)) {
log.info(String.format("Folder time for %s is %s, later than the latest allowed folder time, %s. Skipping",
inputFolder, folderTime, latestAllowedFolderTime));
return false;
} else {
return true;
}
} | [
"protected",
"boolean",
"folderWithinAllowedPeriod",
"(",
"Path",
"inputFolder",
",",
"DateTime",
"folderTime",
")",
"{",
"DateTime",
"currentTime",
"=",
"new",
"DateTime",
"(",
"this",
".",
"timeZone",
")",
";",
"PeriodFormatter",
"periodFormatter",
"=",
"getPeriodFormatter",
"(",
")",
";",
"DateTime",
"earliestAllowedFolderTime",
"=",
"getEarliestAllowedFolderTime",
"(",
"currentTime",
",",
"periodFormatter",
")",
";",
"DateTime",
"latestAllowedFolderTime",
"=",
"getLatestAllowedFolderTime",
"(",
"currentTime",
",",
"periodFormatter",
")",
";",
"if",
"(",
"folderTime",
".",
"isBefore",
"(",
"earliestAllowedFolderTime",
")",
")",
"{",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Folder time for %s is %s, earlier than the earliest allowed folder time, %s. Skipping\"",
",",
"inputFolder",
",",
"folderTime",
",",
"earliestAllowedFolderTime",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"folderTime",
".",
"isAfter",
"(",
"latestAllowedFolderTime",
")",
")",
"{",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Folder time for %s is %s, later than the latest allowed folder time, %s. Skipping\"",
",",
"inputFolder",
",",
"folderTime",
",",
"latestAllowedFolderTime",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | Return true iff input folder time is between compaction.timebased.min.time.ago and
compaction.timebased.max.time.ago. | [
"Return",
"true",
"iff",
"input",
"folder",
"time",
"is",
"between",
"compaction",
".",
"timebased",
".",
"min",
".",
"time",
".",
"ago",
"and",
"compaction",
".",
"timebased",
".",
"max",
".",
"time",
".",
"ago",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/dataset/TimeBasedSubDirDatasetsFinder.java#L220-L237 |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/Stripe.java | Stripe.createAccountTokenSynchronous | @Nullable
public Token createAccountTokenSynchronous(@NonNull final AccountParams accountParams)
throws AuthenticationException,
InvalidRequestException,
APIConnectionException,
APIException {
"""
Blocking method to create a {@link Token} for a Connect Account. Do not call this on the UI
thread or your app will crash. The method uses the currently set
{@link #mDefaultPublishableKey}.
@param accountParams params to use for this token.
@return a {@link Token} that can be used for this account.
@throws AuthenticationException failure to properly authenticate yourself (check your key)
@throws InvalidRequestException your request has invalid parameters
@throws APIConnectionException failure to connect to Stripe's API
@throws APIException any other type of problem (for instance, a temporary issue with
Stripe's servers)
"""
return createAccountTokenSynchronous(accountParams, mDefaultPublishableKey);
} | java | @Nullable
public Token createAccountTokenSynchronous(@NonNull final AccountParams accountParams)
throws AuthenticationException,
InvalidRequestException,
APIConnectionException,
APIException {
return createAccountTokenSynchronous(accountParams, mDefaultPublishableKey);
} | [
"@",
"Nullable",
"public",
"Token",
"createAccountTokenSynchronous",
"(",
"@",
"NonNull",
"final",
"AccountParams",
"accountParams",
")",
"throws",
"AuthenticationException",
",",
"InvalidRequestException",
",",
"APIConnectionException",
",",
"APIException",
"{",
"return",
"createAccountTokenSynchronous",
"(",
"accountParams",
",",
"mDefaultPublishableKey",
")",
";",
"}"
] | Blocking method to create a {@link Token} for a Connect Account. Do not call this on the UI
thread or your app will crash. The method uses the currently set
{@link #mDefaultPublishableKey}.
@param accountParams params to use for this token.
@return a {@link Token} that can be used for this account.
@throws AuthenticationException failure to properly authenticate yourself (check your key)
@throws InvalidRequestException your request has invalid parameters
@throws APIConnectionException failure to connect to Stripe's API
@throws APIException any other type of problem (for instance, a temporary issue with
Stripe's servers) | [
"Blocking",
"method",
"to",
"create",
"a",
"{",
"@link",
"Token",
"}",
"for",
"a",
"Connect",
"Account",
".",
"Do",
"not",
"call",
"this",
"on",
"the",
"UI",
"thread",
"or",
"your",
"app",
"will",
"crash",
".",
"The",
"method",
"uses",
"the",
"currently",
"set",
"{",
"@link",
"#mDefaultPublishableKey",
"}",
"."
] | train | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/Stripe.java#L689-L696 |
gitblit/fathom | fathom-mailer/src/main/java/fathom/mailer/Mailer.java | Mailer.newTextMailRequest | public MailRequest newTextMailRequest(String requestId, String subject, String body) {
"""
Creates a plan text MailRequest with the specified subject and body.
The request id is supplied.
@param requestId
@param subject
@param body
@return a text mail request
"""
return createMailRequest(requestId, false, subject, body);
} | java | public MailRequest newTextMailRequest(String requestId, String subject, String body) {
return createMailRequest(requestId, false, subject, body);
} | [
"public",
"MailRequest",
"newTextMailRequest",
"(",
"String",
"requestId",
",",
"String",
"subject",
",",
"String",
"body",
")",
"{",
"return",
"createMailRequest",
"(",
"requestId",
",",
"false",
",",
"subject",
",",
"body",
")",
";",
"}"
] | Creates a plan text MailRequest with the specified subject and body.
The request id is supplied.
@param requestId
@param subject
@param body
@return a text mail request | [
"Creates",
"a",
"plan",
"text",
"MailRequest",
"with",
"the",
"specified",
"subject",
"and",
"body",
".",
"The",
"request",
"id",
"is",
"supplied",
"."
] | train | https://github.com/gitblit/fathom/blob/f2f820eb16e9fea1e36ad4eda4ed51b35f056538/fathom-mailer/src/main/java/fathom/mailer/Mailer.java#L110-L112 |
cdk/cdk | display/renderbasic/src/main/java/org/openscience/cdk/renderer/AbstractRenderer.java | AbstractRenderer.shiftDrawCenter | public void shiftDrawCenter(double shiftX, double shiftY) {
"""
Move the draw center by dx and dy.
@param shiftX the x shift
@param shiftY the y shift
"""
drawCenter.set(drawCenter.x + shiftX, drawCenter.y + shiftY);
setup();
} | java | public void shiftDrawCenter(double shiftX, double shiftY) {
drawCenter.set(drawCenter.x + shiftX, drawCenter.y + shiftY);
setup();
} | [
"public",
"void",
"shiftDrawCenter",
"(",
"double",
"shiftX",
",",
"double",
"shiftY",
")",
"{",
"drawCenter",
".",
"set",
"(",
"drawCenter",
".",
"x",
"+",
"shiftX",
",",
"drawCenter",
".",
"y",
"+",
"shiftY",
")",
";",
"setup",
"(",
")",
";",
"}"
] | Move the draw center by dx and dy.
@param shiftX the x shift
@param shiftY the y shift | [
"Move",
"the",
"draw",
"center",
"by",
"dx",
"and",
"dy",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/display/renderbasic/src/main/java/org/openscience/cdk/renderer/AbstractRenderer.java#L260-L263 |
google/closure-templates | java/src/com/google/template/soy/pysrc/internal/TranslateToPyExprVisitor.java | TranslateToPyExprVisitor.genCodeForKeyAccess | private static String genCodeForKeyAccess(
String containerExpr,
PyExpr key,
NotFoundBehavior notFoundBehavior,
CoerceKeyToString coerceKeyToString) {
"""
Generates the code for key access given the name of a variable to be used as a key, e.g. {@code
.get(key)}.
@param key an expression to be used as a key
@param notFoundBehavior What should happen if the key is not in the structure.
@param coerceKeyToString Whether or not the key should be coerced to a string.
"""
if (coerceKeyToString == CoerceKeyToString.YES) {
key = new PyFunctionExprBuilder("runtime.maybe_coerce_key_to_string").addArg(key).asPyExpr();
}
switch (notFoundBehavior.getType()) {
case RETURN_NONE:
return new PyFunctionExprBuilder("runtime.key_safe_data_access")
.addArg(new PyExpr(containerExpr, Integer.MAX_VALUE))
.addArg(key)
.build();
case THROW:
return new PyFunctionExprBuilder(containerExpr + ".get").addArg(key).build();
case DEFAULT_VALUE:
return new PyFunctionExprBuilder(containerExpr + ".get")
.addArg(key)
.addArg(notFoundBehavior.getDefaultValue())
.build();
}
throw new AssertionError(notFoundBehavior.getType());
} | java | private static String genCodeForKeyAccess(
String containerExpr,
PyExpr key,
NotFoundBehavior notFoundBehavior,
CoerceKeyToString coerceKeyToString) {
if (coerceKeyToString == CoerceKeyToString.YES) {
key = new PyFunctionExprBuilder("runtime.maybe_coerce_key_to_string").addArg(key).asPyExpr();
}
switch (notFoundBehavior.getType()) {
case RETURN_NONE:
return new PyFunctionExprBuilder("runtime.key_safe_data_access")
.addArg(new PyExpr(containerExpr, Integer.MAX_VALUE))
.addArg(key)
.build();
case THROW:
return new PyFunctionExprBuilder(containerExpr + ".get").addArg(key).build();
case DEFAULT_VALUE:
return new PyFunctionExprBuilder(containerExpr + ".get")
.addArg(key)
.addArg(notFoundBehavior.getDefaultValue())
.build();
}
throw new AssertionError(notFoundBehavior.getType());
} | [
"private",
"static",
"String",
"genCodeForKeyAccess",
"(",
"String",
"containerExpr",
",",
"PyExpr",
"key",
",",
"NotFoundBehavior",
"notFoundBehavior",
",",
"CoerceKeyToString",
"coerceKeyToString",
")",
"{",
"if",
"(",
"coerceKeyToString",
"==",
"CoerceKeyToString",
".",
"YES",
")",
"{",
"key",
"=",
"new",
"PyFunctionExprBuilder",
"(",
"\"runtime.maybe_coerce_key_to_string\"",
")",
".",
"addArg",
"(",
"key",
")",
".",
"asPyExpr",
"(",
")",
";",
"}",
"switch",
"(",
"notFoundBehavior",
".",
"getType",
"(",
")",
")",
"{",
"case",
"RETURN_NONE",
":",
"return",
"new",
"PyFunctionExprBuilder",
"(",
"\"runtime.key_safe_data_access\"",
")",
".",
"addArg",
"(",
"new",
"PyExpr",
"(",
"containerExpr",
",",
"Integer",
".",
"MAX_VALUE",
")",
")",
".",
"addArg",
"(",
"key",
")",
".",
"build",
"(",
")",
";",
"case",
"THROW",
":",
"return",
"new",
"PyFunctionExprBuilder",
"(",
"containerExpr",
"+",
"\".get\"",
")",
".",
"addArg",
"(",
"key",
")",
".",
"build",
"(",
")",
";",
"case",
"DEFAULT_VALUE",
":",
"return",
"new",
"PyFunctionExprBuilder",
"(",
"containerExpr",
"+",
"\".get\"",
")",
".",
"addArg",
"(",
"key",
")",
".",
"addArg",
"(",
"notFoundBehavior",
".",
"getDefaultValue",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"}",
"throw",
"new",
"AssertionError",
"(",
"notFoundBehavior",
".",
"getType",
"(",
")",
")",
";",
"}"
] | Generates the code for key access given the name of a variable to be used as a key, e.g. {@code
.get(key)}.
@param key an expression to be used as a key
@param notFoundBehavior What should happen if the key is not in the structure.
@param coerceKeyToString Whether or not the key should be coerced to a string. | [
"Generates",
"the",
"code",
"for",
"key",
"access",
"given",
"the",
"name",
"of",
"a",
"variable",
"to",
"be",
"used",
"as",
"a",
"key",
"e",
".",
"g",
".",
"{",
"@code",
".",
"get",
"(",
"key",
")",
"}",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/TranslateToPyExprVisitor.java#L591-L614 |
haifengl/smile | demo/src/main/java/smile/demo/util/ParameterParser.java | ParameterParser.addParameter | public void addParameter(String name, ParameterType type) {
"""
Add a (optional) parameter.
@param name the name of parameter.
@param type the type of parameter.
"""
parameters.put(name, new Parameter(name, type));
} | java | public void addParameter(String name, ParameterType type) {
parameters.put(name, new Parameter(name, type));
} | [
"public",
"void",
"addParameter",
"(",
"String",
"name",
",",
"ParameterType",
"type",
")",
"{",
"parameters",
".",
"put",
"(",
"name",
",",
"new",
"Parameter",
"(",
"name",
",",
"type",
")",
")",
";",
"}"
] | Add a (optional) parameter.
@param name the name of parameter.
@param type the type of parameter. | [
"Add",
"a",
"(",
"optional",
")",
"parameter",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/demo/src/main/java/smile/demo/util/ParameterParser.java#L93-L95 |
VoltDB/voltdb | src/frontend/org/voltdb/jdbc/JDBC4DatabaseMetaData.java | JDBC4DatabaseMetaData.getTablePrivileges | @Override
public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
"""
Retrieves a description of the access rights for each table available in a catalog.
"""
checkClosed();
VoltTable vtable = new VoltTable(
new ColumnInfo("TABLE_CAT", VoltType.STRING),
new ColumnInfo("TABLE_SCHEM", VoltType.STRING),
new ColumnInfo("TABLE_NAME", VoltType.STRING),
new ColumnInfo("GRANTOR", VoltType.STRING),
new ColumnInfo("GRANTEE", VoltType.STRING),
new ColumnInfo("PRIVILEGE", VoltType.STRING),
new ColumnInfo("IS_GRANTABLE", VoltType.STRING)
);
//NB: @SystemCatalog(?) will need additional support if we want to
// populate the table.
JDBC4ResultSet res = new JDBC4ResultSet(this.sysCatalog, vtable);
return res;
} | java | @Override
public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException
{
checkClosed();
VoltTable vtable = new VoltTable(
new ColumnInfo("TABLE_CAT", VoltType.STRING),
new ColumnInfo("TABLE_SCHEM", VoltType.STRING),
new ColumnInfo("TABLE_NAME", VoltType.STRING),
new ColumnInfo("GRANTOR", VoltType.STRING),
new ColumnInfo("GRANTEE", VoltType.STRING),
new ColumnInfo("PRIVILEGE", VoltType.STRING),
new ColumnInfo("IS_GRANTABLE", VoltType.STRING)
);
//NB: @SystemCatalog(?) will need additional support if we want to
// populate the table.
JDBC4ResultSet res = new JDBC4ResultSet(this.sysCatalog, vtable);
return res;
} | [
"@",
"Override",
"public",
"ResultSet",
"getTablePrivileges",
"(",
"String",
"catalog",
",",
"String",
"schemaPattern",
",",
"String",
"tableNamePattern",
")",
"throws",
"SQLException",
"{",
"checkClosed",
"(",
")",
";",
"VoltTable",
"vtable",
"=",
"new",
"VoltTable",
"(",
"new",
"ColumnInfo",
"(",
"\"TABLE_CAT\"",
",",
"VoltType",
".",
"STRING",
")",
",",
"new",
"ColumnInfo",
"(",
"\"TABLE_SCHEM\"",
",",
"VoltType",
".",
"STRING",
")",
",",
"new",
"ColumnInfo",
"(",
"\"TABLE_NAME\"",
",",
"VoltType",
".",
"STRING",
")",
",",
"new",
"ColumnInfo",
"(",
"\"GRANTOR\"",
",",
"VoltType",
".",
"STRING",
")",
",",
"new",
"ColumnInfo",
"(",
"\"GRANTEE\"",
",",
"VoltType",
".",
"STRING",
")",
",",
"new",
"ColumnInfo",
"(",
"\"PRIVILEGE\"",
",",
"VoltType",
".",
"STRING",
")",
",",
"new",
"ColumnInfo",
"(",
"\"IS_GRANTABLE\"",
",",
"VoltType",
".",
"STRING",
")",
")",
";",
"//NB: @SystemCatalog(?) will need additional support if we want to",
"// populate the table.",
"JDBC4ResultSet",
"res",
"=",
"new",
"JDBC4ResultSet",
"(",
"this",
".",
"sysCatalog",
",",
"vtable",
")",
";",
"return",
"res",
";",
"}"
] | Retrieves a description of the access rights for each table available in a catalog. | [
"Retrieves",
"a",
"description",
"of",
"the",
"access",
"rights",
"for",
"each",
"table",
"available",
"in",
"a",
"catalog",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4DatabaseMetaData.java#L788-L805 |
line/armeria | core/src/main/java/com/linecorp/armeria/server/throttling/ThrottlingService.java | ThrottlingService.onSuccess | protected O onSuccess(ServiceRequestContext ctx, I req) throws Exception {
"""
Invoked when {@code req} is not throttled. By default, this method delegates the specified {@code req} to
the {@link #delegate()} of this service.
"""
return delegate().serve(ctx, req);
} | java | protected O onSuccess(ServiceRequestContext ctx, I req) throws Exception {
return delegate().serve(ctx, req);
} | [
"protected",
"O",
"onSuccess",
"(",
"ServiceRequestContext",
"ctx",
",",
"I",
"req",
")",
"throws",
"Exception",
"{",
"return",
"delegate",
"(",
")",
".",
"serve",
"(",
"ctx",
",",
"req",
")",
";",
"}"
] | Invoked when {@code req} is not throttled. By default, this method delegates the specified {@code req} to
the {@link #delegate()} of this service. | [
"Invoked",
"when",
"{"
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/throttling/ThrottlingService.java#L56-L58 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/impl/LogRepositoryBaseImpl.java | LogRepositoryBaseImpl.getLogDirectoryName | public String getLogDirectoryName(long timestamp, String pid, String label) {
"""
returns sub-directory name to be used for instances and sub-processes
@param timestamp time of the instance start. It should be negative for sub-processes
@param pid process Id of the instance or sub-process. It cannot be null or empty.
@param label additional identification to use on the sub-directory.
@return string representing requested sub-directory.
"""
if (pid == null || pid.isEmpty()) {
throw new IllegalArgumentException("pid cannot be empty");
}
StringBuilder sb = new StringBuilder();
if (timestamp > 0) {
sb.append(timestamp).append(TIMESEPARATOR);
}
sb.append(pid);
if (label != null && !label.trim().isEmpty()) {
sb.append(LABELSEPARATOR).append(label);
}
return sb.toString();
} | java | public String getLogDirectoryName(long timestamp, String pid, String label) {
if (pid == null || pid.isEmpty()) {
throw new IllegalArgumentException("pid cannot be empty");
}
StringBuilder sb = new StringBuilder();
if (timestamp > 0) {
sb.append(timestamp).append(TIMESEPARATOR);
}
sb.append(pid);
if (label != null && !label.trim().isEmpty()) {
sb.append(LABELSEPARATOR).append(label);
}
return sb.toString();
} | [
"public",
"String",
"getLogDirectoryName",
"(",
"long",
"timestamp",
",",
"String",
"pid",
",",
"String",
"label",
")",
"{",
"if",
"(",
"pid",
"==",
"null",
"||",
"pid",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"pid cannot be empty\"",
")",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"timestamp",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"timestamp",
")",
".",
"append",
"(",
"TIMESEPARATOR",
")",
";",
"}",
"sb",
".",
"append",
"(",
"pid",
")",
";",
"if",
"(",
"label",
"!=",
"null",
"&&",
"!",
"label",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"LABELSEPARATOR",
")",
".",
"append",
"(",
"label",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | returns sub-directory name to be used for instances and sub-processes
@param timestamp time of the instance start. It should be negative for sub-processes
@param pid process Id of the instance or sub-process. It cannot be null or empty.
@param label additional identification to use on the sub-directory.
@return string representing requested sub-directory. | [
"returns",
"sub",
"-",
"directory",
"name",
"to",
"be",
"used",
"for",
"instances",
"and",
"sub",
"-",
"processes"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/impl/LogRepositoryBaseImpl.java#L317-L334 |
exoplatform/jcr | exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/JCROrganizationServiceImpl.java | JCROrganizationServiceImpl.getStorageSession | Session getStorageSession() throws RepositoryException {
"""
Return system Session to org-service storage workspace. For internal use
only.
@return system session
@throws RepositoryException if any Exception is occurred
"""
try
{
ManageableRepository repository = getWorkingRepository();
String workspaceName = storageWorkspace;
if (workspaceName == null)
{
workspaceName = repository.getConfiguration().getDefaultWorkspaceName();
}
return repository.getSystemSession(workspaceName);
}
catch (RepositoryConfigurationException e)
{
throw new RepositoryException("Can not get system session", e);
}
} | java | Session getStorageSession() throws RepositoryException
{
try
{
ManageableRepository repository = getWorkingRepository();
String workspaceName = storageWorkspace;
if (workspaceName == null)
{
workspaceName = repository.getConfiguration().getDefaultWorkspaceName();
}
return repository.getSystemSession(workspaceName);
}
catch (RepositoryConfigurationException e)
{
throw new RepositoryException("Can not get system session", e);
}
} | [
"Session",
"getStorageSession",
"(",
")",
"throws",
"RepositoryException",
"{",
"try",
"{",
"ManageableRepository",
"repository",
"=",
"getWorkingRepository",
"(",
")",
";",
"String",
"workspaceName",
"=",
"storageWorkspace",
";",
"if",
"(",
"workspaceName",
"==",
"null",
")",
"{",
"workspaceName",
"=",
"repository",
".",
"getConfiguration",
"(",
")",
".",
"getDefaultWorkspaceName",
"(",
")",
";",
"}",
"return",
"repository",
".",
"getSystemSession",
"(",
"workspaceName",
")",
";",
"}",
"catch",
"(",
"RepositoryConfigurationException",
"e",
")",
"{",
"throw",
"new",
"RepositoryException",
"(",
"\"Can not get system session\"",
",",
"e",
")",
";",
"}",
"}"
] | Return system Session to org-service storage workspace. For internal use
only.
@return system session
@throws RepositoryException if any Exception is occurred | [
"Return",
"system",
"Session",
"to",
"org",
"-",
"service",
"storage",
"workspace",
".",
"For",
"internal",
"use",
"only",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/JCROrganizationServiceImpl.java#L331-L349 |
jenkinsci/artifactory-plugin | src/main/java/org/jfrog/hudson/pipeline/common/docker/DockerImage.java | DockerImage.checkAndSetManifestAndImagePathCandidates | private boolean checkAndSetManifestAndImagePathCandidates(String manifestPath, String candidateImagePath, ArtifactoryDependenciesClient dependenciesClient, TaskListener listener) throws IOException {
"""
Check if the provided manifestPath is correct.
Set the manifest and imagePath in case of the correct manifest.
@param manifestPath
@param candidateImagePath
@param dependenciesClient
@param listener
@return true if found the correct manifest
@throws IOException
"""
String candidateManifest = getManifestFromArtifactory(dependenciesClient, manifestPath);
if (candidateManifest == null) {
return false;
}
String imageDigest = DockerUtils.getConfigDigest(candidateManifest);
if (imageDigest.equals(imageId)) {
manifest = candidateManifest;
imagePath = candidateImagePath;
return true;
}
listener.getLogger().println(String.format("Found incorrect manifest.json file in Artifactory in the following path: %s\nExpecting: %s got: %s", manifestPath, imageId, imageDigest));
return false;
} | java | private boolean checkAndSetManifestAndImagePathCandidates(String manifestPath, String candidateImagePath, ArtifactoryDependenciesClient dependenciesClient, TaskListener listener) throws IOException {
String candidateManifest = getManifestFromArtifactory(dependenciesClient, manifestPath);
if (candidateManifest == null) {
return false;
}
String imageDigest = DockerUtils.getConfigDigest(candidateManifest);
if (imageDigest.equals(imageId)) {
manifest = candidateManifest;
imagePath = candidateImagePath;
return true;
}
listener.getLogger().println(String.format("Found incorrect manifest.json file in Artifactory in the following path: %s\nExpecting: %s got: %s", manifestPath, imageId, imageDigest));
return false;
} | [
"private",
"boolean",
"checkAndSetManifestAndImagePathCandidates",
"(",
"String",
"manifestPath",
",",
"String",
"candidateImagePath",
",",
"ArtifactoryDependenciesClient",
"dependenciesClient",
",",
"TaskListener",
"listener",
")",
"throws",
"IOException",
"{",
"String",
"candidateManifest",
"=",
"getManifestFromArtifactory",
"(",
"dependenciesClient",
",",
"manifestPath",
")",
";",
"if",
"(",
"candidateManifest",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"String",
"imageDigest",
"=",
"DockerUtils",
".",
"getConfigDigest",
"(",
"candidateManifest",
")",
";",
"if",
"(",
"imageDigest",
".",
"equals",
"(",
"imageId",
")",
")",
"{",
"manifest",
"=",
"candidateManifest",
";",
"imagePath",
"=",
"candidateImagePath",
";",
"return",
"true",
";",
"}",
"listener",
".",
"getLogger",
"(",
")",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"Found incorrect manifest.json file in Artifactory in the following path: %s\\nExpecting: %s got: %s\"",
",",
"manifestPath",
",",
"imageId",
",",
"imageDigest",
")",
")",
";",
"return",
"false",
";",
"}"
] | Check if the provided manifestPath is correct.
Set the manifest and imagePath in case of the correct manifest.
@param manifestPath
@param candidateImagePath
@param dependenciesClient
@param listener
@return true if found the correct manifest
@throws IOException | [
"Check",
"if",
"the",
"provided",
"manifestPath",
"is",
"correct",
".",
"Set",
"the",
"manifest",
"and",
"imagePath",
"in",
"case",
"of",
"the",
"correct",
"manifest",
"."
] | train | https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/DockerImage.java#L212-L227 |
apache/flink | flink-core/src/main/java/org/apache/flink/util/Preconditions.java | Preconditions.checkState | public static void checkState(boolean condition,
@Nullable String errorMessageTemplate,
@Nullable Object... errorMessageArgs) {
"""
Checks the given boolean condition, and throws an {@code IllegalStateException} if
the condition is not met (evaluates to {@code false}).
@param condition The condition to check
@param errorMessageTemplate The message template for the {@code IllegalStateException}
that is thrown if the check fails. The template substitutes its
{@code %s} placeholders with the error message arguments.
@param errorMessageArgs The arguments for the error message, to be inserted into the
message template for the {@code %s} placeholders.
@throws IllegalStateException Thrown, if the condition is violated.
"""
if (!condition) {
throw new IllegalStateException(format(errorMessageTemplate, errorMessageArgs));
}
} | java | public static void checkState(boolean condition,
@Nullable String errorMessageTemplate,
@Nullable Object... errorMessageArgs) {
if (!condition) {
throw new IllegalStateException(format(errorMessageTemplate, errorMessageArgs));
}
} | [
"public",
"static",
"void",
"checkState",
"(",
"boolean",
"condition",
",",
"@",
"Nullable",
"String",
"errorMessageTemplate",
",",
"@",
"Nullable",
"Object",
"...",
"errorMessageArgs",
")",
"{",
"if",
"(",
"!",
"condition",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"format",
"(",
"errorMessageTemplate",
",",
"errorMessageArgs",
")",
")",
";",
"}",
"}"
] | Checks the given boolean condition, and throws an {@code IllegalStateException} if
the condition is not met (evaluates to {@code false}).
@param condition The condition to check
@param errorMessageTemplate The message template for the {@code IllegalStateException}
that is thrown if the check fails. The template substitutes its
{@code %s} placeholders with the error message arguments.
@param errorMessageArgs The arguments for the error message, to be inserted into the
message template for the {@code %s} placeholders.
@throws IllegalStateException Thrown, if the condition is violated. | [
"Checks",
"the",
"given",
"boolean",
"condition",
"and",
"throws",
"an",
"{",
"@code",
"IllegalStateException",
"}",
"if",
"the",
"condition",
"is",
"not",
"met",
"(",
"evaluates",
"to",
"{",
"@code",
"false",
"}",
")",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/util/Preconditions.java#L212-L219 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/LookupTableHelper.java | LookupTableHelper.getContext | public static UIContext getContext(final String key, final Request request) {
"""
Retrieves the UIContext for the given data list.
@param key the list key.
@param request the current request being responded to.
@return the UIContext for the given key.
"""
return (UIContext) request.getSessionAttribute(DATA_LIST_UIC_SESSION_KEY);
} | java | public static UIContext getContext(final String key, final Request request) {
return (UIContext) request.getSessionAttribute(DATA_LIST_UIC_SESSION_KEY);
} | [
"public",
"static",
"UIContext",
"getContext",
"(",
"final",
"String",
"key",
",",
"final",
"Request",
"request",
")",
"{",
"return",
"(",
"UIContext",
")",
"request",
".",
"getSessionAttribute",
"(",
"DATA_LIST_UIC_SESSION_KEY",
")",
";",
"}"
] | Retrieves the UIContext for the given data list.
@param key the list key.
@param request the current request being responded to.
@return the UIContext for the given key. | [
"Retrieves",
"the",
"UIContext",
"for",
"the",
"given",
"data",
"list",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/LookupTableHelper.java#L47-L49 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/StatisticalMoments.java | StatisticalMoments.put | @Override
public void put(double val, double weight) {
"""
Add data with a given weight.
@param val data
@param weight weight
"""
if(weight <= 0) {
return;
}
if(this.n == 0) {
n = weight;
min = max = val;
sum = val * weight;
m2 = m3 = m4 = 0;
return;
}
final double nn = weight + this.n;
final double deltan = val * this.n - this.sum;
final double inc = deltan * weight;
// Some factors used below:
final double delta_nn = deltan / (this.n * nn);
final double delta_nnw = delta_nn * weight;
final double delta_nn2 = delta_nn * delta_nn;
final double delta_nn3 = delta_nn2 * delta_nn;
final double nb2 = weight * weight;
final double tmp1 = this.n - weight;
final double tmp2 = this.n * tmp1 + nb2;
this.m4 += inc * delta_nn3 * tmp2 + 6. * nb2 * this.m2 * delta_nn2 - 4. * this.m3 * delta_nnw;
this.m3 += inc * delta_nn2 * tmp1 - 3. * this.m2 * delta_nnw;
this.m2 += inc * delta_nn;
this.sum += weight * val;
this.n = nn;
min = val < min ? val : min;
max = val > max ? val : max;
} | java | @Override
public void put(double val, double weight) {
if(weight <= 0) {
return;
}
if(this.n == 0) {
n = weight;
min = max = val;
sum = val * weight;
m2 = m3 = m4 = 0;
return;
}
final double nn = weight + this.n;
final double deltan = val * this.n - this.sum;
final double inc = deltan * weight;
// Some factors used below:
final double delta_nn = deltan / (this.n * nn);
final double delta_nnw = delta_nn * weight;
final double delta_nn2 = delta_nn * delta_nn;
final double delta_nn3 = delta_nn2 * delta_nn;
final double nb2 = weight * weight;
final double tmp1 = this.n - weight;
final double tmp2 = this.n * tmp1 + nb2;
this.m4 += inc * delta_nn3 * tmp2 + 6. * nb2 * this.m2 * delta_nn2 - 4. * this.m3 * delta_nnw;
this.m3 += inc * delta_nn2 * tmp1 - 3. * this.m2 * delta_nnw;
this.m2 += inc * delta_nn;
this.sum += weight * val;
this.n = nn;
min = val < min ? val : min;
max = val > max ? val : max;
} | [
"@",
"Override",
"public",
"void",
"put",
"(",
"double",
"val",
",",
"double",
"weight",
")",
"{",
"if",
"(",
"weight",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"n",
"==",
"0",
")",
"{",
"n",
"=",
"weight",
";",
"min",
"=",
"max",
"=",
"val",
";",
"sum",
"=",
"val",
"*",
"weight",
";",
"m2",
"=",
"m3",
"=",
"m4",
"=",
"0",
";",
"return",
";",
"}",
"final",
"double",
"nn",
"=",
"weight",
"+",
"this",
".",
"n",
";",
"final",
"double",
"deltan",
"=",
"val",
"*",
"this",
".",
"n",
"-",
"this",
".",
"sum",
";",
"final",
"double",
"inc",
"=",
"deltan",
"*",
"weight",
";",
"// Some factors used below:",
"final",
"double",
"delta_nn",
"=",
"deltan",
"/",
"(",
"this",
".",
"n",
"*",
"nn",
")",
";",
"final",
"double",
"delta_nnw",
"=",
"delta_nn",
"*",
"weight",
";",
"final",
"double",
"delta_nn2",
"=",
"delta_nn",
"*",
"delta_nn",
";",
"final",
"double",
"delta_nn3",
"=",
"delta_nn2",
"*",
"delta_nn",
";",
"final",
"double",
"nb2",
"=",
"weight",
"*",
"weight",
";",
"final",
"double",
"tmp1",
"=",
"this",
".",
"n",
"-",
"weight",
";",
"final",
"double",
"tmp2",
"=",
"this",
".",
"n",
"*",
"tmp1",
"+",
"nb2",
";",
"this",
".",
"m4",
"+=",
"inc",
"*",
"delta_nn3",
"*",
"tmp2",
"+",
"6.",
"*",
"nb2",
"*",
"this",
".",
"m2",
"*",
"delta_nn2",
"-",
"4.",
"*",
"this",
".",
"m3",
"*",
"delta_nnw",
";",
"this",
".",
"m3",
"+=",
"inc",
"*",
"delta_nn2",
"*",
"tmp1",
"-",
"3.",
"*",
"this",
".",
"m2",
"*",
"delta_nnw",
";",
"this",
".",
"m2",
"+=",
"inc",
"*",
"delta_nn",
";",
"this",
".",
"sum",
"+=",
"weight",
"*",
"val",
";",
"this",
".",
"n",
"=",
"nn",
";",
"min",
"=",
"val",
"<",
"min",
"?",
"val",
":",
"min",
";",
"max",
"=",
"val",
">",
"max",
"?",
"val",
":",
"max",
";",
"}"
] | Add data with a given weight.
@param val data
@param weight weight | [
"Add",
"data",
"with",
"a",
"given",
"weight",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/StatisticalMoments.java#L149-L182 |
xwiki/xwiki-rendering | xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java | TocTreeBuilder.addItemBlock | private Block addItemBlock(Block currentBlock, HeaderBlock headerBlock, String documentReference) {
"""
Add a {@link ListItemBlock} in the current toc tree block and return the new {@link ListItemBlock}.
@param currentBlock the current block in the toc tree.
@param headerBlock the {@link HeaderBlock} to use to generate toc anchor label.
@return the new {@link ListItemBlock}.
"""
ListItemBlock itemBlock =
headerBlock == null ? createEmptyTocEntry() : createTocEntry(headerBlock, documentReference);
currentBlock.addChild(itemBlock);
return itemBlock;
} | java | private Block addItemBlock(Block currentBlock, HeaderBlock headerBlock, String documentReference)
{
ListItemBlock itemBlock =
headerBlock == null ? createEmptyTocEntry() : createTocEntry(headerBlock, documentReference);
currentBlock.addChild(itemBlock);
return itemBlock;
} | [
"private",
"Block",
"addItemBlock",
"(",
"Block",
"currentBlock",
",",
"HeaderBlock",
"headerBlock",
",",
"String",
"documentReference",
")",
"{",
"ListItemBlock",
"itemBlock",
"=",
"headerBlock",
"==",
"null",
"?",
"createEmptyTocEntry",
"(",
")",
":",
"createTocEntry",
"(",
"headerBlock",
",",
"documentReference",
")",
";",
"currentBlock",
".",
"addChild",
"(",
"itemBlock",
")",
";",
"return",
"itemBlock",
";",
"}"
] | Add a {@link ListItemBlock} in the current toc tree block and return the new {@link ListItemBlock}.
@param currentBlock the current block in the toc tree.
@param headerBlock the {@link HeaderBlock} to use to generate toc anchor label.
@return the new {@link ListItemBlock}. | [
"Add",
"a",
"{",
"@link",
"ListItemBlock",
"}",
"in",
"the",
"current",
"toc",
"tree",
"block",
"and",
"return",
"the",
"new",
"{",
"@link",
"ListItemBlock",
"}",
"."
] | train | https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java#L163-L171 |
apache/incubator-shardingsphere | sharding-transaction/sharding-transaction-2pc/sharding-transaction-xa/sharding-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionFactory.java | XAConnectionFactory.createXAConnection | public static XAConnection createXAConnection(final DatabaseType databaseType, final XADataSource xaDataSource, final Connection connection) {
"""
Create XA connection from normal connection.
@param databaseType database type
@param connection normal connection
@param xaDataSource XA data source
@return XA connection
"""
switch (databaseType) {
case MySQL:
return new MySQLXAConnectionWrapper().wrap(xaDataSource, connection);
case PostgreSQL:
return new PostgreSQLXAConnectionWrapper().wrap(xaDataSource, connection);
case H2:
return new H2XAConnectionWrapper().wrap(xaDataSource, connection);
default:
throw new UnsupportedOperationException(String.format("Cannot support database type: `%s`", databaseType));
}
} | java | public static XAConnection createXAConnection(final DatabaseType databaseType, final XADataSource xaDataSource, final Connection connection) {
switch (databaseType) {
case MySQL:
return new MySQLXAConnectionWrapper().wrap(xaDataSource, connection);
case PostgreSQL:
return new PostgreSQLXAConnectionWrapper().wrap(xaDataSource, connection);
case H2:
return new H2XAConnectionWrapper().wrap(xaDataSource, connection);
default:
throw new UnsupportedOperationException(String.format("Cannot support database type: `%s`", databaseType));
}
} | [
"public",
"static",
"XAConnection",
"createXAConnection",
"(",
"final",
"DatabaseType",
"databaseType",
",",
"final",
"XADataSource",
"xaDataSource",
",",
"final",
"Connection",
"connection",
")",
"{",
"switch",
"(",
"databaseType",
")",
"{",
"case",
"MySQL",
":",
"return",
"new",
"MySQLXAConnectionWrapper",
"(",
")",
".",
"wrap",
"(",
"xaDataSource",
",",
"connection",
")",
";",
"case",
"PostgreSQL",
":",
"return",
"new",
"PostgreSQLXAConnectionWrapper",
"(",
")",
".",
"wrap",
"(",
"xaDataSource",
",",
"connection",
")",
";",
"case",
"H2",
":",
"return",
"new",
"H2XAConnectionWrapper",
"(",
")",
".",
"wrap",
"(",
"xaDataSource",
",",
"connection",
")",
";",
"default",
":",
"throw",
"new",
"UnsupportedOperationException",
"(",
"String",
".",
"format",
"(",
"\"Cannot support database type: `%s`\"",
",",
"databaseType",
")",
")",
";",
"}",
"}"
] | Create XA connection from normal connection.
@param databaseType database type
@param connection normal connection
@param xaDataSource XA data source
@return XA connection | [
"Create",
"XA",
"connection",
"from",
"normal",
"connection",
"."
] | train | https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-transaction/sharding-transaction-2pc/sharding-transaction-xa/sharding-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionFactory.java#L47-L58 |
icode/ameba | src/main/java/ameba/core/Requests.java | Requests.readEntity | public static <T> T readEntity(Class<T> rawType, Type type) {
"""
<p>readEntity.</p>
@param rawType a {@link java.lang.Class} object.
@param type a {@link java.lang.reflect.Type} object.
@param <T> a T object.
@return a T object.
"""
return getRequest().readEntity(rawType, type);
} | java | public static <T> T readEntity(Class<T> rawType, Type type) {
return getRequest().readEntity(rawType, type);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"readEntity",
"(",
"Class",
"<",
"T",
">",
"rawType",
",",
"Type",
"type",
")",
"{",
"return",
"getRequest",
"(",
")",
".",
"readEntity",
"(",
"rawType",
",",
"type",
")",
";",
"}"
] | <p>readEntity.</p>
@param rawType a {@link java.lang.Class} object.
@param type a {@link java.lang.reflect.Type} object.
@param <T> a T object.
@return a T object. | [
"<p",
">",
"readEntity",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/core/Requests.java#L239-L241 |
xdcrafts/flower | flower-tools/src/main/java/com/github/xdcrafts/flower/tools/map/MapDsl.java | MapDsl.with | public static MapOperator with(final Map map, final Class<? extends Map> nodeClass) {
"""
Entry point for mutable map dsl.
@param map subject
@param nodeClass map class
@return operator
"""
return new MapOperator(map, nodeClass);
} | java | public static MapOperator with(final Map map, final Class<? extends Map> nodeClass) {
return new MapOperator(map, nodeClass);
} | [
"public",
"static",
"MapOperator",
"with",
"(",
"final",
"Map",
"map",
",",
"final",
"Class",
"<",
"?",
"extends",
"Map",
">",
"nodeClass",
")",
"{",
"return",
"new",
"MapOperator",
"(",
"map",
",",
"nodeClass",
")",
";",
"}"
] | Entry point for mutable map dsl.
@param map subject
@param nodeClass map class
@return operator | [
"Entry",
"point",
"for",
"mutable",
"map",
"dsl",
"."
] | train | https://github.com/xdcrafts/flower/blob/96a8e49102fea434bd383a3c7852f0ee9545f999/flower-tools/src/main/java/com/github/xdcrafts/flower/tools/map/MapDsl.java#L36-L38 |
eclipse/xtext-extras | org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/conformance/TypeConformanceComputer.java | TypeConformanceComputer.getCommonParameterSuperType | @Deprecated
public final LightweightTypeReference getCommonParameterSuperType(List<LightweightTypeReference> types, List<LightweightTypeReference> initiallyRequested, ITypeReferenceOwner owner) {
"""
Logic was moved to inner class CommonSuperTypeFinder in the context of bug 495314.
This method is scheduled for deletion in Xtext 2.15
@deprecated see {@link CommonSuperTypeFinder#getCommonParameterSuperType(List)}
"""
CommonSuperTypeFinder typeFinder = newCommonSuperTypeFinder(owner);
typeFinder.requestsInProgress = Lists.newArrayList();
typeFinder.requestsInProgress.add(initiallyRequested);
return typeFinder.getCommonParameterSuperType(types);
} | java | @Deprecated
public final LightweightTypeReference getCommonParameterSuperType(List<LightweightTypeReference> types, List<LightweightTypeReference> initiallyRequested, ITypeReferenceOwner owner) {
CommonSuperTypeFinder typeFinder = newCommonSuperTypeFinder(owner);
typeFinder.requestsInProgress = Lists.newArrayList();
typeFinder.requestsInProgress.add(initiallyRequested);
return typeFinder.getCommonParameterSuperType(types);
} | [
"@",
"Deprecated",
"public",
"final",
"LightweightTypeReference",
"getCommonParameterSuperType",
"(",
"List",
"<",
"LightweightTypeReference",
">",
"types",
",",
"List",
"<",
"LightweightTypeReference",
">",
"initiallyRequested",
",",
"ITypeReferenceOwner",
"owner",
")",
"{",
"CommonSuperTypeFinder",
"typeFinder",
"=",
"newCommonSuperTypeFinder",
"(",
"owner",
")",
";",
"typeFinder",
".",
"requestsInProgress",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"typeFinder",
".",
"requestsInProgress",
".",
"add",
"(",
"initiallyRequested",
")",
";",
"return",
"typeFinder",
".",
"getCommonParameterSuperType",
"(",
"types",
")",
";",
"}"
] | Logic was moved to inner class CommonSuperTypeFinder in the context of bug 495314.
This method is scheduled for deletion in Xtext 2.15
@deprecated see {@link CommonSuperTypeFinder#getCommonParameterSuperType(List)} | [
"Logic",
"was",
"moved",
"to",
"inner",
"class",
"CommonSuperTypeFinder",
"in",
"the",
"context",
"of",
"bug",
"495314",
"."
] | train | https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/conformance/TypeConformanceComputer.java#L814-L820 |
aws/aws-sdk-java | aws-java-sdk-stepfunctions/src/main/java/com/amazonaws/services/stepfunctions/builder/internal/validation/ValidationContext.java | ValidationContext.assertNotEmpty | public void assertNotEmpty(Collection<?> collection, String propertyName) {
"""
Asserts the collection is not null and not empty, reporting to {@link ProblemReporter} with this context if it is.
@param collection Collection to assert on.
@param propertyName Name of property.
"""
if (CollectionUtils.isNullOrEmpty(collection)) {
problemReporter.report(new Problem(this, String.format("%s requires one or more items", propertyName)));
}
} | java | public void assertNotEmpty(Collection<?> collection, String propertyName) {
if (CollectionUtils.isNullOrEmpty(collection)) {
problemReporter.report(new Problem(this, String.format("%s requires one or more items", propertyName)));
}
} | [
"public",
"void",
"assertNotEmpty",
"(",
"Collection",
"<",
"?",
">",
"collection",
",",
"String",
"propertyName",
")",
"{",
"if",
"(",
"CollectionUtils",
".",
"isNullOrEmpty",
"(",
"collection",
")",
")",
"{",
"problemReporter",
".",
"report",
"(",
"new",
"Problem",
"(",
"this",
",",
"String",
".",
"format",
"(",
"\"%s requires one or more items\"",
",",
"propertyName",
")",
")",
")",
";",
"}",
"}"
] | Asserts the collection is not null and not empty, reporting to {@link ProblemReporter} with this context if it is.
@param collection Collection to assert on.
@param propertyName Name of property. | [
"Asserts",
"the",
"collection",
"is",
"not",
"null",
"and",
"not",
"empty",
"reporting",
"to",
"{",
"@link",
"ProblemReporter",
"}",
"with",
"this",
"context",
"if",
"it",
"is",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-stepfunctions/src/main/java/com/amazonaws/services/stepfunctions/builder/internal/validation/ValidationContext.java#L90-L94 |
liferay/com-liferay-commerce | commerce-tax-engine-fixed-service/src/main/java/com/liferay/commerce/tax/engine/fixed/service/persistence/impl/CommerceTaxFixedRatePersistenceImpl.java | CommerceTaxFixedRatePersistenceImpl.findAll | @Override
public List<CommerceTaxFixedRate> findAll() {
"""
Returns all the commerce tax fixed rates.
@return the commerce tax fixed rates
"""
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | java | @Override
public List<CommerceTaxFixedRate> findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceTaxFixedRate",
">",
"findAll",
"(",
")",
"{",
"return",
"findAll",
"(",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
";",
"}"
] | Returns all the commerce tax fixed rates.
@return the commerce tax fixed rates | [
"Returns",
"all",
"the",
"commerce",
"tax",
"fixed",
"rates",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-tax-engine-fixed-service/src/main/java/com/liferay/commerce/tax/engine/fixed/service/persistence/impl/CommerceTaxFixedRatePersistenceImpl.java#L1953-L1956 |
lessthanoptimal/BoofCV | main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java | SimulatePlanarWorld.computePixel | public void computePixel(int which, double x, double y, Point2D_F64 output) {
"""
Project a point which lies on the 2D planar polygon's surface onto the rendered image
"""
SurfaceRect r = scene.get(which);
Point3D_F64 p3 = new Point3D_F64(-x,-y,0);
SePointOps_F64.transform(r.rectToCamera, p3, p3);
// unit sphere
p3.scale(1.0/p3.norm());
sphereToPixel.compute(p3.x,p3.y,p3.z,output);
} | java | public void computePixel(int which, double x, double y, Point2D_F64 output) {
SurfaceRect r = scene.get(which);
Point3D_F64 p3 = new Point3D_F64(-x,-y,0);
SePointOps_F64.transform(r.rectToCamera, p3, p3);
// unit sphere
p3.scale(1.0/p3.norm());
sphereToPixel.compute(p3.x,p3.y,p3.z,output);
} | [
"public",
"void",
"computePixel",
"(",
"int",
"which",
",",
"double",
"x",
",",
"double",
"y",
",",
"Point2D_F64",
"output",
")",
"{",
"SurfaceRect",
"r",
"=",
"scene",
".",
"get",
"(",
"which",
")",
";",
"Point3D_F64",
"p3",
"=",
"new",
"Point3D_F64",
"(",
"-",
"x",
",",
"-",
"y",
",",
"0",
")",
";",
"SePointOps_F64",
".",
"transform",
"(",
"r",
".",
"rectToCamera",
",",
"p3",
",",
"p3",
")",
";",
"// unit sphere",
"p3",
".",
"scale",
"(",
"1.0",
"/",
"p3",
".",
"norm",
"(",
")",
")",
";",
"sphereToPixel",
".",
"compute",
"(",
"p3",
".",
"x",
",",
"p3",
".",
"y",
",",
"p3",
".",
"z",
",",
"output",
")",
";",
"}"
] | Project a point which lies on the 2D planar polygon's surface onto the rendered image | [
"Project",
"a",
"point",
"which",
"lies",
"on",
"the",
"2D",
"planar",
"polygon",
"s",
"surface",
"onto",
"the",
"rendered",
"image"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java#L307-L317 |
RestComm/sip-servlets | sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java | FacebookRestClient.users_getInfo | public T users_getInfo(Collection<Integer> userIds, EnumSet<ProfileField> fields)
throws FacebookException, IOException {
"""
Retrieves the requested info fields for the requested set of users.
@param userIds a collection of user IDs for which to fetch info
@param fields a set of ProfileFields
@return a T consisting of a list of users, with each user element
containing the requested fields.
"""
// assertions test for invalid params
assert (userIds != null);
assert (fields != null);
assert (!fields.isEmpty());
return this.callMethod(FacebookMethod.USERS_GET_INFO,
new Pair<String, CharSequence>("uids", delimit(userIds)),
new Pair<String, CharSequence>("fields", delimit(fields)));
} | java | public T users_getInfo(Collection<Integer> userIds, EnumSet<ProfileField> fields)
throws FacebookException, IOException {
// assertions test for invalid params
assert (userIds != null);
assert (fields != null);
assert (!fields.isEmpty());
return this.callMethod(FacebookMethod.USERS_GET_INFO,
new Pair<String, CharSequence>("uids", delimit(userIds)),
new Pair<String, CharSequence>("fields", delimit(fields)));
} | [
"public",
"T",
"users_getInfo",
"(",
"Collection",
"<",
"Integer",
">",
"userIds",
",",
"EnumSet",
"<",
"ProfileField",
">",
"fields",
")",
"throws",
"FacebookException",
",",
"IOException",
"{",
"// assertions test for invalid params",
"assert",
"(",
"userIds",
"!=",
"null",
")",
";",
"assert",
"(",
"fields",
"!=",
"null",
")",
";",
"assert",
"(",
"!",
"fields",
".",
"isEmpty",
"(",
")",
")",
";",
"return",
"this",
".",
"callMethod",
"(",
"FacebookMethod",
".",
"USERS_GET_INFO",
",",
"new",
"Pair",
"<",
"String",
",",
"CharSequence",
">",
"(",
"\"uids\"",
",",
"delimit",
"(",
"userIds",
")",
")",
",",
"new",
"Pair",
"<",
"String",
",",
"CharSequence",
">",
"(",
"\"fields\"",
",",
"delimit",
"(",
"fields",
")",
")",
")",
";",
"}"
] | Retrieves the requested info fields for the requested set of users.
@param userIds a collection of user IDs for which to fetch info
@param fields a set of ProfileFields
@return a T consisting of a list of users, with each user element
containing the requested fields. | [
"Retrieves",
"the",
"requested",
"info",
"fields",
"for",
"the",
"requested",
"set",
"of",
"users",
"."
] | train | https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java#L923-L933 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java | EscapedFunctions2.sqltruncate | public static void sqltruncate(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
"""
truncate to trunc translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens
"""
twoArgumentsFunctionCall(buf, "trunc(", "truncate", parsedArgs);
} | java | public static void sqltruncate(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
twoArgumentsFunctionCall(buf, "trunc(", "truncate", parsedArgs);
} | [
"public",
"static",
"void",
"sqltruncate",
"(",
"StringBuilder",
"buf",
",",
"List",
"<",
"?",
"extends",
"CharSequence",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"twoArgumentsFunctionCall",
"(",
"buf",
",",
"\"trunc(\"",
",",
"\"truncate\"",
",",
"parsedArgs",
")",
";",
"}"
] | truncate to trunc translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens | [
"truncate",
"to",
"trunc",
"translation"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java#L131-L133 |
cdk/cdk | base/standard/src/main/java/org/openscience/cdk/geometry/GeometryUtil.java | GeometryUtil.getScaleFactor | public static double getScaleFactor(IAtomContainer container, double bondLength) {
"""
Determines the scale factor for displaying a structure loaded from disk in a frame. An
average of all bond length values is produced and a scale factor is determined which would
scale the given molecule such that its See comment for center(IAtomContainer atomCon,
Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
@param container The AtomContainer for which the ScaleFactor is to be calculated
@param bondLength The target bond length
@return The ScaleFactor with which the AtomContainer must be scaled to have the target bond
length
"""
double currentAverageBondLength = getBondLengthMedian(container);
if (currentAverageBondLength == 0 || Double.isNaN(currentAverageBondLength)) return 1;
return bondLength / currentAverageBondLength;
} | java | public static double getScaleFactor(IAtomContainer container, double bondLength) {
double currentAverageBondLength = getBondLengthMedian(container);
if (currentAverageBondLength == 0 || Double.isNaN(currentAverageBondLength)) return 1;
return bondLength / currentAverageBondLength;
} | [
"public",
"static",
"double",
"getScaleFactor",
"(",
"IAtomContainer",
"container",
",",
"double",
"bondLength",
")",
"{",
"double",
"currentAverageBondLength",
"=",
"getBondLengthMedian",
"(",
"container",
")",
";",
"if",
"(",
"currentAverageBondLength",
"==",
"0",
"||",
"Double",
".",
"isNaN",
"(",
"currentAverageBondLength",
")",
")",
"return",
"1",
";",
"return",
"bondLength",
"/",
"currentAverageBondLength",
";",
"}"
] | Determines the scale factor for displaying a structure loaded from disk in a frame. An
average of all bond length values is produced and a scale factor is determined which would
scale the given molecule such that its See comment for center(IAtomContainer atomCon,
Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
@param container The AtomContainer for which the ScaleFactor is to be calculated
@param bondLength The target bond length
@return The ScaleFactor with which the AtomContainer must be scaled to have the target bond
length | [
"Determines",
"the",
"scale",
"factor",
"for",
"displaying",
"a",
"structure",
"loaded",
"from",
"disk",
"in",
"a",
"frame",
".",
"An",
"average",
"of",
"all",
"bond",
"length",
"values",
"is",
"produced",
"and",
"a",
"scale",
"factor",
"is",
"determined",
"which",
"would",
"scale",
"the",
"given",
"molecule",
"such",
"that",
"its",
"See",
"comment",
"for",
"center",
"(",
"IAtomContainer",
"atomCon",
"Dimension",
"areaDim",
"HashMap",
"renderingCoordinates",
")",
"for",
"details",
"on",
"coordinate",
"sets"
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/standard/src/main/java/org/openscience/cdk/geometry/GeometryUtil.java#L898-L902 |
umano/AndroidSlidingUpPanel | library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java | ViewDragHelper.checkTouchSlop | private boolean checkTouchSlop(View child, float dx, float dy) {
"""
Check if we've crossed a reasonable touch slop for the given child view.
If the child cannot be dragged along the horizontal or vertical axis, motion
along that axis will not count toward the slop check.
@param child Child to check
@param dx Motion since initial position along X axis
@param dy Motion since initial position along Y axis
@return true if the touch slop has been crossed
"""
if (child == null) {
return false;
}
final boolean checkHorizontal = mCallback.getViewHorizontalDragRange(child) > 0;
final boolean checkVertical = mCallback.getViewVerticalDragRange(child) > 0;
if (checkHorizontal && checkVertical) {
return dx * dx + dy * dy > mTouchSlop * mTouchSlop;
} else if (checkHorizontal) {
return Math.abs(dx) > mTouchSlop;
} else if (checkVertical) {
return Math.abs(dy) > mTouchSlop;
}
return false;
} | java | private boolean checkTouchSlop(View child, float dx, float dy) {
if (child == null) {
return false;
}
final boolean checkHorizontal = mCallback.getViewHorizontalDragRange(child) > 0;
final boolean checkVertical = mCallback.getViewVerticalDragRange(child) > 0;
if (checkHorizontal && checkVertical) {
return dx * dx + dy * dy > mTouchSlop * mTouchSlop;
} else if (checkHorizontal) {
return Math.abs(dx) > mTouchSlop;
} else if (checkVertical) {
return Math.abs(dy) > mTouchSlop;
}
return false;
} | [
"private",
"boolean",
"checkTouchSlop",
"(",
"View",
"child",
",",
"float",
"dx",
",",
"float",
"dy",
")",
"{",
"if",
"(",
"child",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"final",
"boolean",
"checkHorizontal",
"=",
"mCallback",
".",
"getViewHorizontalDragRange",
"(",
"child",
")",
">",
"0",
";",
"final",
"boolean",
"checkVertical",
"=",
"mCallback",
".",
"getViewVerticalDragRange",
"(",
"child",
")",
">",
"0",
";",
"if",
"(",
"checkHorizontal",
"&&",
"checkVertical",
")",
"{",
"return",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
">",
"mTouchSlop",
"*",
"mTouchSlop",
";",
"}",
"else",
"if",
"(",
"checkHorizontal",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"dx",
")",
">",
"mTouchSlop",
";",
"}",
"else",
"if",
"(",
"checkVertical",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"dy",
")",
">",
"mTouchSlop",
";",
"}",
"return",
"false",
";",
"}"
] | Check if we've crossed a reasonable touch slop for the given child view.
If the child cannot be dragged along the horizontal or vertical axis, motion
along that axis will not count toward the slop check.
@param child Child to check
@param dx Motion since initial position along X axis
@param dy Motion since initial position along Y axis
@return true if the touch slop has been crossed | [
"Check",
"if",
"we",
"ve",
"crossed",
"a",
"reasonable",
"touch",
"slop",
"for",
"the",
"given",
"child",
"view",
".",
"If",
"the",
"child",
"cannot",
"be",
"dragged",
"along",
"the",
"horizontal",
"or",
"vertical",
"axis",
"motion",
"along",
"that",
"axis",
"will",
"not",
"count",
"toward",
"the",
"slop",
"check",
"."
] | train | https://github.com/umano/AndroidSlidingUpPanel/blob/45a460435b07e764138a700328836cafc1ed5c42/library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java#L1293-L1308 |
thorntail/thorntail | plugins/gradle/gradle-plugin/src/main/java/org/wildfly/swarm/plugin/gradle/GradleDependencyResolutionHelper.java | GradleDependencyResolutionHelper.asDescriptor | private static DependencyDescriptor asDescriptor(String scope, ResolvedDependency dependency) {
"""
Translate the given {@link ResolvedDependency resolved dependency} in to a {@link DependencyDescriptor} reference.
@param scope the scope to assign to the descriptor.
@param dependency the resolved dependency reference.
@return an instance of {@link DependencyDescriptor}.
"""
Set<ResolvedArtifact> artifacts = dependency.getModuleArtifacts();
// Let us use the first artifact's type for determining the type.
// I am not sure under what circumstances, would we need to check for multiple artifacts.
String type = "jar";
String classifier = null;
File file = null;
if (!artifacts.isEmpty()) {
ResolvedArtifact ra = artifacts.iterator().next();
type = ra.getType();
classifier = ra.getClassifier();
file = ra.getFile();
}
return new DefaultDependencyDescriptor(scope, dependency.getModuleGroup(), dependency.getModuleName(),
dependency.getModuleVersion(), type, classifier, file);
} | java | private static DependencyDescriptor asDescriptor(String scope, ResolvedDependency dependency) {
Set<ResolvedArtifact> artifacts = dependency.getModuleArtifacts();
// Let us use the first artifact's type for determining the type.
// I am not sure under what circumstances, would we need to check for multiple artifacts.
String type = "jar";
String classifier = null;
File file = null;
if (!artifacts.isEmpty()) {
ResolvedArtifact ra = artifacts.iterator().next();
type = ra.getType();
classifier = ra.getClassifier();
file = ra.getFile();
}
return new DefaultDependencyDescriptor(scope, dependency.getModuleGroup(), dependency.getModuleName(),
dependency.getModuleVersion(), type, classifier, file);
} | [
"private",
"static",
"DependencyDescriptor",
"asDescriptor",
"(",
"String",
"scope",
",",
"ResolvedDependency",
"dependency",
")",
"{",
"Set",
"<",
"ResolvedArtifact",
">",
"artifacts",
"=",
"dependency",
".",
"getModuleArtifacts",
"(",
")",
";",
"// Let us use the first artifact's type for determining the type.",
"// I am not sure under what circumstances, would we need to check for multiple artifacts.",
"String",
"type",
"=",
"\"jar\"",
";",
"String",
"classifier",
"=",
"null",
";",
"File",
"file",
"=",
"null",
";",
"if",
"(",
"!",
"artifacts",
".",
"isEmpty",
"(",
")",
")",
"{",
"ResolvedArtifact",
"ra",
"=",
"artifacts",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"type",
"=",
"ra",
".",
"getType",
"(",
")",
";",
"classifier",
"=",
"ra",
".",
"getClassifier",
"(",
")",
";",
"file",
"=",
"ra",
".",
"getFile",
"(",
")",
";",
"}",
"return",
"new",
"DefaultDependencyDescriptor",
"(",
"scope",
",",
"dependency",
".",
"getModuleGroup",
"(",
")",
",",
"dependency",
".",
"getModuleName",
"(",
")",
",",
"dependency",
".",
"getModuleVersion",
"(",
")",
",",
"type",
",",
"classifier",
",",
"file",
")",
";",
"}"
] | Translate the given {@link ResolvedDependency resolved dependency} in to a {@link DependencyDescriptor} reference.
@param scope the scope to assign to the descriptor.
@param dependency the resolved dependency reference.
@return an instance of {@link DependencyDescriptor}. | [
"Translate",
"the",
"given",
"{",
"@link",
"ResolvedDependency",
"resolved",
"dependency",
"}",
"in",
"to",
"a",
"{",
"@link",
"DependencyDescriptor",
"}",
"reference",
"."
] | train | https://github.com/thorntail/thorntail/blob/4a391b68ffae98c6e66d30a3bfb99dadc9509f14/plugins/gradle/gradle-plugin/src/main/java/org/wildfly/swarm/plugin/gradle/GradleDependencyResolutionHelper.java#L264-L282 |
Gagravarr/VorbisJava | core/src/main/java/org/gagravarr/ogg/OggPacketReader.java | OggPacketReader.skipToGranulePosition | public void skipToGranulePosition(int sid, long granulePosition) throws IOException {
"""
Skips forward until the first packet with a Granule Position
of equal or greater than that specified. Call {@link #getNextPacket()}
to retrieve this packet.
This method advances across all streams, but only searches the
specified one.
@param sid The ID of the stream who's packets we will search
@param granulePosition The granule position we're looking for
"""
OggPacket p = null;
while( (p = getNextPacket()) != null ) {
if(p.getSid() == sid && p.getGranulePosition() >= granulePosition) {
nextPacket = p;
break;
}
}
} | java | public void skipToGranulePosition(int sid, long granulePosition) throws IOException {
OggPacket p = null;
while( (p = getNextPacket()) != null ) {
if(p.getSid() == sid && p.getGranulePosition() >= granulePosition) {
nextPacket = p;
break;
}
}
} | [
"public",
"void",
"skipToGranulePosition",
"(",
"int",
"sid",
",",
"long",
"granulePosition",
")",
"throws",
"IOException",
"{",
"OggPacket",
"p",
"=",
"null",
";",
"while",
"(",
"(",
"p",
"=",
"getNextPacket",
"(",
")",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"p",
".",
"getSid",
"(",
")",
"==",
"sid",
"&&",
"p",
".",
"getGranulePosition",
"(",
")",
">=",
"granulePosition",
")",
"{",
"nextPacket",
"=",
"p",
";",
"break",
";",
"}",
"}",
"}"
] | Skips forward until the first packet with a Granule Position
of equal or greater than that specified. Call {@link #getNextPacket()}
to retrieve this packet.
This method advances across all streams, but only searches the
specified one.
@param sid The ID of the stream who's packets we will search
@param granulePosition The granule position we're looking for | [
"Skips",
"forward",
"until",
"the",
"first",
"packet",
"with",
"a",
"Granule",
"Position",
"of",
"equal",
"or",
"greater",
"than",
"that",
"specified",
".",
"Call",
"{"
] | train | https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPacketReader.java#L190-L198 |
apache/flink | flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java | MemorySegment.putCharBigEndian | public final void putCharBigEndian(int index, char value) {
"""
Writes the given character (16 bit, 2 bytes) to the given position in big-endian
byte order. This method's speed depends on the system's native byte order, and it
is possibly slower than {@link #putChar(int, char)}. For most cases (such as
transient storage in memory or serialization for I/O and network),
it suffices to know that the byte order in which the value is written is the same as the
one in which it is read, and {@link #putChar(int, char)} is the preferable choice.
@param index The position at which the value will be written.
@param value The char value to be written.
@throws IndexOutOfBoundsException Thrown, if the index is negative, or larger than the segment size minus 2.
"""
if (LITTLE_ENDIAN) {
putChar(index, Character.reverseBytes(value));
} else {
putChar(index, value);
}
} | java | public final void putCharBigEndian(int index, char value) {
if (LITTLE_ENDIAN) {
putChar(index, Character.reverseBytes(value));
} else {
putChar(index, value);
}
} | [
"public",
"final",
"void",
"putCharBigEndian",
"(",
"int",
"index",
",",
"char",
"value",
")",
"{",
"if",
"(",
"LITTLE_ENDIAN",
")",
"{",
"putChar",
"(",
"index",
",",
"Character",
".",
"reverseBytes",
"(",
"value",
")",
")",
";",
"}",
"else",
"{",
"putChar",
"(",
"index",
",",
"value",
")",
";",
"}",
"}"
] | Writes the given character (16 bit, 2 bytes) to the given position in big-endian
byte order. This method's speed depends on the system's native byte order, and it
is possibly slower than {@link #putChar(int, char)}. For most cases (such as
transient storage in memory or serialization for I/O and network),
it suffices to know that the byte order in which the value is written is the same as the
one in which it is read, and {@link #putChar(int, char)} is the preferable choice.
@param index The position at which the value will be written.
@param value The char value to be written.
@throws IndexOutOfBoundsException Thrown, if the index is negative, or larger than the segment size minus 2. | [
"Writes",
"the",
"given",
"character",
"(",
"16",
"bit",
"2",
"bytes",
")",
"to",
"the",
"given",
"position",
"in",
"big",
"-",
"endian",
"byte",
"order",
".",
"This",
"method",
"s",
"speed",
"depends",
"on",
"the",
"system",
"s",
"native",
"byte",
"order",
"and",
"it",
"is",
"possibly",
"slower",
"than",
"{",
"@link",
"#putChar",
"(",
"int",
"char",
")",
"}",
".",
"For",
"most",
"cases",
"(",
"such",
"as",
"transient",
"storage",
"in",
"memory",
"or",
"serialization",
"for",
"I",
"/",
"O",
"and",
"network",
")",
"it",
"suffices",
"to",
"know",
"that",
"the",
"byte",
"order",
"in",
"which",
"the",
"value",
"is",
"written",
"is",
"the",
"same",
"as",
"the",
"one",
"in",
"which",
"it",
"is",
"read",
"and",
"{",
"@link",
"#putChar",
"(",
"int",
"char",
")",
"}",
"is",
"the",
"preferable",
"choice",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java#L536-L542 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java | AbstractProxyFactory.retrieveCollectionProxyConstructor | private static Constructor retrieveCollectionProxyConstructor(Class proxyClass, Class baseType, String typeDesc) {
"""
Retrieves the constructor that is used by OJB to create instances of the given collection proxy
class.
@param proxyClass The proxy class
@param baseType The required base type of the proxy class
@param typeDesc The type of collection proxy
@return The constructor
"""
if(proxyClass == null)
{
throw new MetadataException("No " + typeDesc + " specified.");
}
if(proxyClass.isInterface() || Modifier.isAbstract(proxyClass.getModifiers()) || !baseType.isAssignableFrom(proxyClass))
{
throw new MetadataException("Illegal class "
+ proxyClass.getName()
+ " specified for "
+ typeDesc
+ ". Must be a concrete subclass of "
+ baseType.getName());
}
Class[] paramType = {PBKey.class, Class.class, Query.class};
try
{
return proxyClass.getConstructor(paramType);
}
catch(NoSuchMethodException ex)
{
throw new MetadataException("The class "
+ proxyClass.getName()
+ " specified for "
+ typeDesc
+ " is required to have a public constructor with signature ("
+ PBKey.class.getName()
+ ", "
+ Class.class.getName()
+ ", "
+ Query.class.getName()
+ ").");
}
} | java | private static Constructor retrieveCollectionProxyConstructor(Class proxyClass, Class baseType, String typeDesc)
{
if(proxyClass == null)
{
throw new MetadataException("No " + typeDesc + " specified.");
}
if(proxyClass.isInterface() || Modifier.isAbstract(proxyClass.getModifiers()) || !baseType.isAssignableFrom(proxyClass))
{
throw new MetadataException("Illegal class "
+ proxyClass.getName()
+ " specified for "
+ typeDesc
+ ". Must be a concrete subclass of "
+ baseType.getName());
}
Class[] paramType = {PBKey.class, Class.class, Query.class};
try
{
return proxyClass.getConstructor(paramType);
}
catch(NoSuchMethodException ex)
{
throw new MetadataException("The class "
+ proxyClass.getName()
+ " specified for "
+ typeDesc
+ " is required to have a public constructor with signature ("
+ PBKey.class.getName()
+ ", "
+ Class.class.getName()
+ ", "
+ Query.class.getName()
+ ").");
}
} | [
"private",
"static",
"Constructor",
"retrieveCollectionProxyConstructor",
"(",
"Class",
"proxyClass",
",",
"Class",
"baseType",
",",
"String",
"typeDesc",
")",
"{",
"if",
"(",
"proxyClass",
"==",
"null",
")",
"{",
"throw",
"new",
"MetadataException",
"(",
"\"No \"",
"+",
"typeDesc",
"+",
"\" specified.\"",
")",
";",
"}",
"if",
"(",
"proxyClass",
".",
"isInterface",
"(",
")",
"||",
"Modifier",
".",
"isAbstract",
"(",
"proxyClass",
".",
"getModifiers",
"(",
")",
")",
"||",
"!",
"baseType",
".",
"isAssignableFrom",
"(",
"proxyClass",
")",
")",
"{",
"throw",
"new",
"MetadataException",
"(",
"\"Illegal class \"",
"+",
"proxyClass",
".",
"getName",
"(",
")",
"+",
"\" specified for \"",
"+",
"typeDesc",
"+",
"\". Must be a concrete subclass of \"",
"+",
"baseType",
".",
"getName",
"(",
")",
")",
";",
"}",
"Class",
"[",
"]",
"paramType",
"=",
"{",
"PBKey",
".",
"class",
",",
"Class",
".",
"class",
",",
"Query",
".",
"class",
"}",
";",
"try",
"{",
"return",
"proxyClass",
".",
"getConstructor",
"(",
"paramType",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"ex",
")",
"{",
"throw",
"new",
"MetadataException",
"(",
"\"The class \"",
"+",
"proxyClass",
".",
"getName",
"(",
")",
"+",
"\" specified for \"",
"+",
"typeDesc",
"+",
"\" is required to have a public constructor with signature (\"",
"+",
"PBKey",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\", \"",
"+",
"Class",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\", \"",
"+",
"Query",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\").\"",
")",
";",
"}",
"}"
] | Retrieves the constructor that is used by OJB to create instances of the given collection proxy
class.
@param proxyClass The proxy class
@param baseType The required base type of the proxy class
@param typeDesc The type of collection proxy
@return The constructor | [
"Retrieves",
"the",
"constructor",
"that",
"is",
"used",
"by",
"OJB",
"to",
"create",
"instances",
"of",
"the",
"given",
"collection",
"proxy",
"class",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/core/proxy/AbstractProxyFactory.java#L180-L216 |
smartsheet-platform/smartsheet-java-sdk | src/main/java/com/smartsheet/api/internal/SheetResourcesImpl.java | SheetResourcesImpl.importCsv | public Sheet importCsv(String file, String sheetName, Integer headerRowIndex, Integer primaryRowIndex) throws SmartsheetException {
"""
Imports a sheet.
It mirrors to the following Smartsheet REST API method: POST /sheets/import
@param file path to the CSV file
@param sheetName destination sheet name
@param headerRowIndex index (0 based) of row to be used for column names
@param primaryRowIndex index (0 based) of primary column
@return the created sheet
@throws IllegalArgumentException if any argument is null or empty string
@throws InvalidRequestException if there is any problem with the REST API request
@throws AuthorizationException if there is any problem with the REST API authorization (access token)
@throws ResourceNotFoundException if the resource cannot be found
@throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
@throws SmartsheetException if there is any other error during the operation
"""
return importFile("sheets/import", file,"text/csv", sheetName, headerRowIndex, primaryRowIndex);
} | java | public Sheet importCsv(String file, String sheetName, Integer headerRowIndex, Integer primaryRowIndex) throws SmartsheetException {
return importFile("sheets/import", file,"text/csv", sheetName, headerRowIndex, primaryRowIndex);
} | [
"public",
"Sheet",
"importCsv",
"(",
"String",
"file",
",",
"String",
"sheetName",
",",
"Integer",
"headerRowIndex",
",",
"Integer",
"primaryRowIndex",
")",
"throws",
"SmartsheetException",
"{",
"return",
"importFile",
"(",
"\"sheets/import\"",
",",
"file",
",",
"\"text/csv\"",
",",
"sheetName",
",",
"headerRowIndex",
",",
"primaryRowIndex",
")",
";",
"}"
] | Imports a sheet.
It mirrors to the following Smartsheet REST API method: POST /sheets/import
@param file path to the CSV file
@param sheetName destination sheet name
@param headerRowIndex index (0 based) of row to be used for column names
@param primaryRowIndex index (0 based) of primary column
@return the created sheet
@throws IllegalArgumentException if any argument is null or empty string
@throws InvalidRequestException if there is any problem with the REST API request
@throws AuthorizationException if there is any problem with the REST API authorization (access token)
@throws ResourceNotFoundException if the resource cannot be found
@throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
@throws SmartsheetException if there is any other error during the operation | [
"Imports",
"a",
"sheet",
"."
] | train | https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/f60e264412076271f83b65889ef9b891fad83df8/src/main/java/com/smartsheet/api/internal/SheetResourcesImpl.java#L435-L437 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/bcc/BccClient.java | BccClient.rebootInstance | public void rebootInstance(String instanceId, boolean forceStop) {
"""
Rebooting the instance owned by the user.
You can reboot the instance only when the instance is Running,
otherwise,it's will get <code>409</code> errorCode.
This is an asynchronous interface,
you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)}
@param instanceId The id of the instance.
@param forceStop The option param to stop the instance forcibly.If <code>true</code>,
it will stop the instance just like power off immediately
and it may result int losing important data which have not written to disk.
"""
this.rebootInstance(new RebootInstanceRequest().withInstanceId(instanceId).withForceStop(forceStop));
} | java | public void rebootInstance(String instanceId, boolean forceStop) {
this.rebootInstance(new RebootInstanceRequest().withInstanceId(instanceId).withForceStop(forceStop));
} | [
"public",
"void",
"rebootInstance",
"(",
"String",
"instanceId",
",",
"boolean",
"forceStop",
")",
"{",
"this",
".",
"rebootInstance",
"(",
"new",
"RebootInstanceRequest",
"(",
")",
".",
"withInstanceId",
"(",
"instanceId",
")",
".",
"withForceStop",
"(",
"forceStop",
")",
")",
";",
"}"
] | Rebooting the instance owned by the user.
You can reboot the instance only when the instance is Running,
otherwise,it's will get <code>409</code> errorCode.
This is an asynchronous interface,
you can get the latest status by invoke {@link #getInstance(GetInstanceRequest)}
@param instanceId The id of the instance.
@param forceStop The option param to stop the instance forcibly.If <code>true</code>,
it will stop the instance just like power off immediately
and it may result int losing important data which have not written to disk. | [
"Rebooting",
"the",
"instance",
"owned",
"by",
"the",
"user",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bcc/BccClient.java#L480-L482 |
Stratio/bdt | src/main/java/com/stratio/qa/specs/DcosSpec.java | DcosSpec.sendAppendRequest | @Then("^I add a new DCOS label with key '(.+?)' and value '(.+?)' to the service '(.+?)'?$")
public void sendAppendRequest(String key, String value, String service) throws Exception {
"""
A PUT request over the body value.
@param key
@param value
@param service
@throws Exception
"""
commonspec.runCommandAndGetResult("touch " + service + ".json && dcos marathon app show " + service + " > /dcos/" + service + ".json");
commonspec.runCommandAndGetResult("cat /dcos/" + service + ".json");
String configFile = commonspec.getRemoteSSHConnection().getResult();
String myValue = commonspec.getJSONPathString(configFile, ".labels", "0");
String myJson = commonspec.updateMarathonJson(commonspec.removeJSONPathElement(configFile, "$.labels"));
String newValue = myValue.replaceFirst("\\{", "{\"" + key + "\": \"" + value + "\", ");
newValue = "\"labels\":" + newValue;
String myFinalJson = myJson.replaceFirst("\\{", "{" + newValue.replace("\\n", "\\\\n") + ",");
if (myFinalJson.contains("uris")) {
String test = myFinalJson.replaceAll("\"uris\"", "\"none\"");
commonspec.runCommandAndGetResult("echo '" + test + "' > /dcos/final" + service + ".json");
} else {
commonspec.runCommandAndGetResult("echo '" + myFinalJson + "' > /dcos/final" + service + ".json");
}
commonspec.runCommandAndGetResult("dcos marathon app update " + service + " < /dcos/final" + service + ".json");
commonspec.setCommandExitStatus(commonspec.getRemoteSSHConnection().getExitStatus());
} | java | @Then("^I add a new DCOS label with key '(.+?)' and value '(.+?)' to the service '(.+?)'?$")
public void sendAppendRequest(String key, String value, String service) throws Exception {
commonspec.runCommandAndGetResult("touch " + service + ".json && dcos marathon app show " + service + " > /dcos/" + service + ".json");
commonspec.runCommandAndGetResult("cat /dcos/" + service + ".json");
String configFile = commonspec.getRemoteSSHConnection().getResult();
String myValue = commonspec.getJSONPathString(configFile, ".labels", "0");
String myJson = commonspec.updateMarathonJson(commonspec.removeJSONPathElement(configFile, "$.labels"));
String newValue = myValue.replaceFirst("\\{", "{\"" + key + "\": \"" + value + "\", ");
newValue = "\"labels\":" + newValue;
String myFinalJson = myJson.replaceFirst("\\{", "{" + newValue.replace("\\n", "\\\\n") + ",");
if (myFinalJson.contains("uris")) {
String test = myFinalJson.replaceAll("\"uris\"", "\"none\"");
commonspec.runCommandAndGetResult("echo '" + test + "' > /dcos/final" + service + ".json");
} else {
commonspec.runCommandAndGetResult("echo '" + myFinalJson + "' > /dcos/final" + service + ".json");
}
commonspec.runCommandAndGetResult("dcos marathon app update " + service + " < /dcos/final" + service + ".json");
commonspec.setCommandExitStatus(commonspec.getRemoteSSHConnection().getExitStatus());
} | [
"@",
"Then",
"(",
"\"^I add a new DCOS label with key '(.+?)' and value '(.+?)' to the service '(.+?)'?$\"",
")",
"public",
"void",
"sendAppendRequest",
"(",
"String",
"key",
",",
"String",
"value",
",",
"String",
"service",
")",
"throws",
"Exception",
"{",
"commonspec",
".",
"runCommandAndGetResult",
"(",
"\"touch \"",
"+",
"service",
"+",
"\".json && dcos marathon app show \"",
"+",
"service",
"+",
"\" > /dcos/\"",
"+",
"service",
"+",
"\".json\"",
")",
";",
"commonspec",
".",
"runCommandAndGetResult",
"(",
"\"cat /dcos/\"",
"+",
"service",
"+",
"\".json\"",
")",
";",
"String",
"configFile",
"=",
"commonspec",
".",
"getRemoteSSHConnection",
"(",
")",
".",
"getResult",
"(",
")",
";",
"String",
"myValue",
"=",
"commonspec",
".",
"getJSONPathString",
"(",
"configFile",
",",
"\".labels\"",
",",
"\"0\"",
")",
";",
"String",
"myJson",
"=",
"commonspec",
".",
"updateMarathonJson",
"(",
"commonspec",
".",
"removeJSONPathElement",
"(",
"configFile",
",",
"\"$.labels\"",
")",
")",
";",
"String",
"newValue",
"=",
"myValue",
".",
"replaceFirst",
"(",
"\"\\\\{\"",
",",
"\"{\\\"\"",
"+",
"key",
"+",
"\"\\\": \\\"\"",
"+",
"value",
"+",
"\"\\\", \"",
")",
";",
"newValue",
"=",
"\"\\\"labels\\\":\"",
"+",
"newValue",
";",
"String",
"myFinalJson",
"=",
"myJson",
".",
"replaceFirst",
"(",
"\"\\\\{\"",
",",
"\"{\"",
"+",
"newValue",
".",
"replace",
"(",
"\"\\\\n\"",
",",
"\"\\\\\\\\n\"",
")",
"+",
"\",\"",
")",
";",
"if",
"(",
"myFinalJson",
".",
"contains",
"(",
"\"uris\"",
")",
")",
"{",
"String",
"test",
"=",
"myFinalJson",
".",
"replaceAll",
"(",
"\"\\\"uris\\\"\"",
",",
"\"\\\"none\\\"\"",
")",
";",
"commonspec",
".",
"runCommandAndGetResult",
"(",
"\"echo '\"",
"+",
"test",
"+",
"\"' > /dcos/final\"",
"+",
"service",
"+",
"\".json\"",
")",
";",
"}",
"else",
"{",
"commonspec",
".",
"runCommandAndGetResult",
"(",
"\"echo '\"",
"+",
"myFinalJson",
"+",
"\"' > /dcos/final\"",
"+",
"service",
"+",
"\".json\"",
")",
";",
"}",
"commonspec",
".",
"runCommandAndGetResult",
"(",
"\"dcos marathon app update \"",
"+",
"service",
"+",
"\" < /dcos/final\"",
"+",
"service",
"+",
"\".json\"",
")",
";",
"commonspec",
".",
"setCommandExitStatus",
"(",
"commonspec",
".",
"getRemoteSSHConnection",
"(",
")",
".",
"getExitStatus",
"(",
")",
")",
";",
"}"
] | A PUT request over the body value.
@param key
@param value
@param service
@throws Exception | [
"A",
"PUT",
"request",
"over",
"the",
"body",
"value",
"."
] | train | https://github.com/Stratio/bdt/blob/55324d19e7497764ad3dd7139923e13eb9841d75/src/main/java/com/stratio/qa/specs/DcosSpec.java#L405-L426 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java | GlobalUsersInner.beginStartEnvironmentAsync | public Observable<Void> beginStartEnvironmentAsync(String userName, String environmentId) {
"""
Starts an environment by starting all resources inside the environment. This operation can take a while to complete.
@param userName The name of the user.
@param environmentId The resourceId of the environment
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return beginStartEnvironmentWithServiceResponseAsync(userName, environmentId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginStartEnvironmentAsync(String userName, String environmentId) {
return beginStartEnvironmentWithServiceResponseAsync(userName, environmentId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginStartEnvironmentAsync",
"(",
"String",
"userName",
",",
"String",
"environmentId",
")",
"{",
"return",
"beginStartEnvironmentWithServiceResponseAsync",
"(",
"userName",
",",
"environmentId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Starts an environment by starting all resources inside the environment. This operation can take a while to complete.
@param userName The name of the user.
@param environmentId The resourceId of the environment
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Starts",
"an",
"environment",
"by",
"starting",
"all",
"resources",
"inside",
"the",
"environment",
".",
"This",
"operation",
"can",
"take",
"a",
"while",
"to",
"complete",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GlobalUsersInner.java#L1174-L1181 |
ixa-ehu/ixa-pipe-pos | src/main/java/eus/ixa/ixa/pipe/pos/StatisticalTagger.java | StatisticalTagger.loadModel | private POSModel loadModel(final String lang, final String modelName, final Boolean useModelCache) {
"""
Loads statically the probabilistic model. Every instance of this finder
will share the same model.
@param lang
the language
@param modelName
the model to be loaded
@param useModelCache
whether to cache the model in memory
@return the model as a {@link POSModel} object
"""
final long lStartTime = new Date().getTime();
POSModel model = null;
try {
if (useModelCache) {
synchronized (posModels) {
if (!posModels.containsKey(lang)) {
model = new POSModel(new FileInputStream(modelName));
posModels.put(lang, model);
}
}
} else {
model = new POSModel(new FileInputStream(modelName));
}
} catch (final IOException e) {
e.printStackTrace();
}
final long lEndTime = new Date().getTime();
final long difference = lEndTime - lStartTime;
System.err.println("ixa-pipe-pos model loaded in: " + difference
+ " miliseconds ... [DONE]");
return model;
} | java | private POSModel loadModel(final String lang, final String modelName, final Boolean useModelCache) {
final long lStartTime = new Date().getTime();
POSModel model = null;
try {
if (useModelCache) {
synchronized (posModels) {
if (!posModels.containsKey(lang)) {
model = new POSModel(new FileInputStream(modelName));
posModels.put(lang, model);
}
}
} else {
model = new POSModel(new FileInputStream(modelName));
}
} catch (final IOException e) {
e.printStackTrace();
}
final long lEndTime = new Date().getTime();
final long difference = lEndTime - lStartTime;
System.err.println("ixa-pipe-pos model loaded in: " + difference
+ " miliseconds ... [DONE]");
return model;
} | [
"private",
"POSModel",
"loadModel",
"(",
"final",
"String",
"lang",
",",
"final",
"String",
"modelName",
",",
"final",
"Boolean",
"useModelCache",
")",
"{",
"final",
"long",
"lStartTime",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"POSModel",
"model",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"useModelCache",
")",
"{",
"synchronized",
"(",
"posModels",
")",
"{",
"if",
"(",
"!",
"posModels",
".",
"containsKey",
"(",
"lang",
")",
")",
"{",
"model",
"=",
"new",
"POSModel",
"(",
"new",
"FileInputStream",
"(",
"modelName",
")",
")",
";",
"posModels",
".",
"put",
"(",
"lang",
",",
"model",
")",
";",
"}",
"}",
"}",
"else",
"{",
"model",
"=",
"new",
"POSModel",
"(",
"new",
"FileInputStream",
"(",
"modelName",
")",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"final",
"long",
"lEndTime",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"final",
"long",
"difference",
"=",
"lEndTime",
"-",
"lStartTime",
";",
"System",
".",
"err",
".",
"println",
"(",
"\"ixa-pipe-pos model loaded in: \"",
"+",
"difference",
"+",
"\" miliseconds ... [DONE]\"",
")",
";",
"return",
"model",
";",
"}"
] | Loads statically the probabilistic model. Every instance of this finder
will share the same model.
@param lang
the language
@param modelName
the model to be loaded
@param useModelCache
whether to cache the model in memory
@return the model as a {@link POSModel} object | [
"Loads",
"statically",
"the",
"probabilistic",
"model",
".",
"Every",
"instance",
"of",
"this",
"finder",
"will",
"share",
"the",
"same",
"model",
"."
] | train | https://github.com/ixa-ehu/ixa-pipe-pos/blob/083c986103f95ae8063b8ddc89a2caa8047d29b9/src/main/java/eus/ixa/ixa/pipe/pos/StatisticalTagger.java#L152-L174 |
ReactiveX/RxJavaAsyncUtil | src/main/java/rx/util/async/Async.java | Async.toAsyncThrowing | public static <T1, T2, T3, R> Func3<T1, T2, T3, Observable<R>> toAsyncThrowing(ThrowingFunc3<? super T1, ? super T2, ? super T3, ? extends R> func) {
"""
Convert a synchronous function call into an asynchronous function call through an Observable.
<p>
<img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toAsync.png" alt="">
@param <T1> the first parameter type
@param <T2> the second parameter type
@param <T3> the third parameter type
@param <R> the result type
@param func the function to convert
@return a function that returns an Observable that executes the {@code func} and emits its returned value
@see <a href="https://github.com/ReactiveX/RxJava/wiki/Async-Operators#wiki-toasync-or-asyncaction-or-asyncfunc">RxJava Wiki: toAsync()</a>
@see <a href="http://msdn.microsoft.com/en-us/library/hh229450.aspx">MSDN: Observable.ToAsync</a>
"""
return toAsyncThrowing(func, Schedulers.computation());
} | java | public static <T1, T2, T3, R> Func3<T1, T2, T3, Observable<R>> toAsyncThrowing(ThrowingFunc3<? super T1, ? super T2, ? super T3, ? extends R> func) {
return toAsyncThrowing(func, Schedulers.computation());
} | [
"public",
"static",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"R",
">",
"Func3",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"Observable",
"<",
"R",
">",
">",
"toAsyncThrowing",
"(",
"ThrowingFunc3",
"<",
"?",
"super",
"T1",
",",
"?",
"super",
"T2",
",",
"?",
"super",
"T3",
",",
"?",
"extends",
"R",
">",
"func",
")",
"{",
"return",
"toAsyncThrowing",
"(",
"func",
",",
"Schedulers",
".",
"computation",
"(",
")",
")",
";",
"}"
] | Convert a synchronous function call into an asynchronous function call through an Observable.
<p>
<img width="640" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toAsync.png" alt="">
@param <T1> the first parameter type
@param <T2> the second parameter type
@param <T3> the third parameter type
@param <R> the result type
@param func the function to convert
@return a function that returns an Observable that executes the {@code func} and emits its returned value
@see <a href="https://github.com/ReactiveX/RxJava/wiki/Async-Operators#wiki-toasync-or-asyncaction-or-asyncfunc">RxJava Wiki: toAsync()</a>
@see <a href="http://msdn.microsoft.com/en-us/library/hh229450.aspx">MSDN: Observable.ToAsync</a> | [
"Convert",
"a",
"synchronous",
"function",
"call",
"into",
"an",
"asynchronous",
"function",
"call",
"through",
"an",
"Observable",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"src",
"=",
"https",
":",
"//",
"raw",
".",
"github",
".",
"com",
"/",
"wiki",
"/",
"ReactiveX",
"/",
"RxJava",
"/",
"images",
"/",
"rx",
"-",
"operators",
"/",
"toAsync",
".",
"png",
"alt",
"=",
">"
] | train | https://github.com/ReactiveX/RxJavaAsyncUtil/blob/6294e1da30e639df79f76399906229314c14e74d/src/main/java/rx/util/async/Async.java#L326-L328 |
jingwei/krati | krati-main/src/main/java/krati/util/SourceWaterMarks.java | SourceWaterMarks.setWaterMarks | public void setWaterMarks(String source, long lwmScn, long hwmScn) {
"""
Sets the water marks of a source.
@param source - the source
@param lwmScn - the low water mark SCN
@param hwmScn - the high water mark SCN
"""
WaterMarkEntry e = sourceWaterMarkMap.get(source);
if (e == null) {
e = new WaterMarkEntry(source);
sourceWaterMarkMap.put(source, e);
}
e.setLWMScn(lwmScn);
e.setHWMScn(hwmScn);
} | java | public void setWaterMarks(String source, long lwmScn, long hwmScn) {
WaterMarkEntry e = sourceWaterMarkMap.get(source);
if (e == null) {
e = new WaterMarkEntry(source);
sourceWaterMarkMap.put(source, e);
}
e.setLWMScn(lwmScn);
e.setHWMScn(hwmScn);
} | [
"public",
"void",
"setWaterMarks",
"(",
"String",
"source",
",",
"long",
"lwmScn",
",",
"long",
"hwmScn",
")",
"{",
"WaterMarkEntry",
"e",
"=",
"sourceWaterMarkMap",
".",
"get",
"(",
"source",
")",
";",
"if",
"(",
"e",
"==",
"null",
")",
"{",
"e",
"=",
"new",
"WaterMarkEntry",
"(",
"source",
")",
";",
"sourceWaterMarkMap",
".",
"put",
"(",
"source",
",",
"e",
")",
";",
"}",
"e",
".",
"setLWMScn",
"(",
"lwmScn",
")",
";",
"e",
".",
"setHWMScn",
"(",
"hwmScn",
")",
";",
"}"
] | Sets the water marks of a source.
@param source - the source
@param lwmScn - the low water mark SCN
@param hwmScn - the high water mark SCN | [
"Sets",
"the",
"water",
"marks",
"of",
"a",
"source",
"."
] | train | https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/main/java/krati/util/SourceWaterMarks.java#L248-L256 |
pdef/pdef-java | pdef/src/main/java/io/pdef/json/JsonFormat.java | JsonFormat.read | public <T> T read(final InputStream stream, final DataTypeDescriptor<T> descriptor) {
"""
Parses an object from an input stream, does not close the input stream.
"""
try {
return jsonFormat.read(stream, descriptor);
} catch (Exception e) {
throw propagate(e);
}
} | java | public <T> T read(final InputStream stream, final DataTypeDescriptor<T> descriptor) {
try {
return jsonFormat.read(stream, descriptor);
} catch (Exception e) {
throw propagate(e);
}
} | [
"public",
"<",
"T",
">",
"T",
"read",
"(",
"final",
"InputStream",
"stream",
",",
"final",
"DataTypeDescriptor",
"<",
"T",
">",
"descriptor",
")",
"{",
"try",
"{",
"return",
"jsonFormat",
".",
"read",
"(",
"stream",
",",
"descriptor",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"propagate",
"(",
"e",
")",
";",
"}",
"}"
] | Parses an object from an input stream, does not close the input stream. | [
"Parses",
"an",
"object",
"from",
"an",
"input",
"stream",
"does",
"not",
"close",
"the",
"input",
"stream",
"."
] | train | https://github.com/pdef/pdef-java/blob/7776c44d1aab0f3dbf7267b0c32b8f9282fe6167/pdef/src/main/java/io/pdef/json/JsonFormat.java#L86-L92 |
Azure/azure-sdk-for-java | applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/WorkbooksInner.java | WorkbooksInner.listByResourceGroup | public List<WorkbookInner> listByResourceGroup(String resourceGroupName, CategoryType category) {
"""
Get all Workbooks defined within a specified resource group and category.
@param resourceGroupName The name of the resource group.
@param category Category of workbook to return. Possible values include: 'workbook', 'TSG', 'performance', 'retention'
@throws IllegalArgumentException thrown if parameters fail the validation
@throws WorkbookErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<WorkbookInner> object if successful.
"""
return listByResourceGroupWithServiceResponseAsync(resourceGroupName, category).toBlocking().single().body();
} | java | public List<WorkbookInner> listByResourceGroup(String resourceGroupName, CategoryType category) {
return listByResourceGroupWithServiceResponseAsync(resourceGroupName, category).toBlocking().single().body();
} | [
"public",
"List",
"<",
"WorkbookInner",
">",
"listByResourceGroup",
"(",
"String",
"resourceGroupName",
",",
"CategoryType",
"category",
")",
"{",
"return",
"listByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"category",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Get all Workbooks defined within a specified resource group and category.
@param resourceGroupName The name of the resource group.
@param category Category of workbook to return. Possible values include: 'workbook', 'TSG', 'performance', 'retention'
@throws IllegalArgumentException thrown if parameters fail the validation
@throws WorkbookErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<WorkbookInner> object if successful. | [
"Get",
"all",
"Workbooks",
"defined",
"within",
"a",
"specified",
"resource",
"group",
"and",
"category",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/WorkbooksInner.java#L95-L97 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringHelper.java | StringHelper.removeMultiple | @Nonnull
public static String removeMultiple (@Nullable final String sInputString, @Nonnull final char [] aRemoveChars) {
"""
Optimized remove method that removes a set of characters from an input
string!
@param sInputString
The input string.
@param aRemoveChars
The characters to remove. May not be <code>null</code>.
@return The version of the string without the passed characters or an empty
String if the input string was <code>null</code>.
"""
ValueEnforcer.notNull (aRemoveChars, "RemoveChars");
// Any input text?
if (hasNoText (sInputString))
return "";
// Anything to remove?
if (aRemoveChars.length == 0)
return sInputString;
final StringBuilder aSB = new StringBuilder (sInputString.length ());
iterateChars (sInputString, cInput -> {
if (!ArrayHelper.contains (aRemoveChars, cInput))
aSB.append (cInput);
});
return aSB.toString ();
} | java | @Nonnull
public static String removeMultiple (@Nullable final String sInputString, @Nonnull final char [] aRemoveChars)
{
ValueEnforcer.notNull (aRemoveChars, "RemoveChars");
// Any input text?
if (hasNoText (sInputString))
return "";
// Anything to remove?
if (aRemoveChars.length == 0)
return sInputString;
final StringBuilder aSB = new StringBuilder (sInputString.length ());
iterateChars (sInputString, cInput -> {
if (!ArrayHelper.contains (aRemoveChars, cInput))
aSB.append (cInput);
});
return aSB.toString ();
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"removeMultiple",
"(",
"@",
"Nullable",
"final",
"String",
"sInputString",
",",
"@",
"Nonnull",
"final",
"char",
"[",
"]",
"aRemoveChars",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aRemoveChars",
",",
"\"RemoveChars\"",
")",
";",
"// Any input text?",
"if",
"(",
"hasNoText",
"(",
"sInputString",
")",
")",
"return",
"\"\"",
";",
"// Anything to remove?",
"if",
"(",
"aRemoveChars",
".",
"length",
"==",
"0",
")",
"return",
"sInputString",
";",
"final",
"StringBuilder",
"aSB",
"=",
"new",
"StringBuilder",
"(",
"sInputString",
".",
"length",
"(",
")",
")",
";",
"iterateChars",
"(",
"sInputString",
",",
"cInput",
"->",
"{",
"if",
"(",
"!",
"ArrayHelper",
".",
"contains",
"(",
"aRemoveChars",
",",
"cInput",
")",
")",
"aSB",
".",
"append",
"(",
"cInput",
")",
";",
"}",
")",
";",
"return",
"aSB",
".",
"toString",
"(",
")",
";",
"}"
] | Optimized remove method that removes a set of characters from an input
string!
@param sInputString
The input string.
@param aRemoveChars
The characters to remove. May not be <code>null</code>.
@return The version of the string without the passed characters or an empty
String if the input string was <code>null</code>. | [
"Optimized",
"remove",
"method",
"that",
"removes",
"a",
"set",
"of",
"characters",
"from",
"an",
"input",
"string!"
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L5196-L5215 |
alkacon/opencms-core | src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java | CmsMessageBundleEditorModel.handleKeyChange | public KeyChangeResult handleKeyChange(EntryChangeEvent event, boolean allLanguages) {
"""
Handles a key change.
@param event the key change event.
@param allLanguages <code>true</code> for changing the key for all languages, <code>false</code> if the key should be changed only for the current language.
@return result, indicating if the key change was successful.
"""
if (m_keyset.getKeySet().contains(event.getNewValue())) {
m_container.getItem(event.getItemId()).getItemProperty(TableProperty.KEY).setValue(event.getOldValue());
return KeyChangeResult.FAILED_DUPLICATED_KEY;
}
if (allLanguages && !renameKeyForAllLanguages(event.getOldValue(), event.getNewValue())) {
m_container.getItem(event.getItemId()).getItemProperty(TableProperty.KEY).setValue(event.getOldValue());
return KeyChangeResult.FAILED_FOR_OTHER_LANGUAGE;
}
return KeyChangeResult.SUCCESS;
} | java | public KeyChangeResult handleKeyChange(EntryChangeEvent event, boolean allLanguages) {
if (m_keyset.getKeySet().contains(event.getNewValue())) {
m_container.getItem(event.getItemId()).getItemProperty(TableProperty.KEY).setValue(event.getOldValue());
return KeyChangeResult.FAILED_DUPLICATED_KEY;
}
if (allLanguages && !renameKeyForAllLanguages(event.getOldValue(), event.getNewValue())) {
m_container.getItem(event.getItemId()).getItemProperty(TableProperty.KEY).setValue(event.getOldValue());
return KeyChangeResult.FAILED_FOR_OTHER_LANGUAGE;
}
return KeyChangeResult.SUCCESS;
} | [
"public",
"KeyChangeResult",
"handleKeyChange",
"(",
"EntryChangeEvent",
"event",
",",
"boolean",
"allLanguages",
")",
"{",
"if",
"(",
"m_keyset",
".",
"getKeySet",
"(",
")",
".",
"contains",
"(",
"event",
".",
"getNewValue",
"(",
")",
")",
")",
"{",
"m_container",
".",
"getItem",
"(",
"event",
".",
"getItemId",
"(",
")",
")",
".",
"getItemProperty",
"(",
"TableProperty",
".",
"KEY",
")",
".",
"setValue",
"(",
"event",
".",
"getOldValue",
"(",
")",
")",
";",
"return",
"KeyChangeResult",
".",
"FAILED_DUPLICATED_KEY",
";",
"}",
"if",
"(",
"allLanguages",
"&&",
"!",
"renameKeyForAllLanguages",
"(",
"event",
".",
"getOldValue",
"(",
")",
",",
"event",
".",
"getNewValue",
"(",
")",
")",
")",
"{",
"m_container",
".",
"getItem",
"(",
"event",
".",
"getItemId",
"(",
")",
")",
".",
"getItemProperty",
"(",
"TableProperty",
".",
"KEY",
")",
".",
"setValue",
"(",
"event",
".",
"getOldValue",
"(",
")",
")",
";",
"return",
"KeyChangeResult",
".",
"FAILED_FOR_OTHER_LANGUAGE",
";",
"}",
"return",
"KeyChangeResult",
".",
"SUCCESS",
";",
"}"
] | Handles a key change.
@param event the key change event.
@param allLanguages <code>true</code> for changing the key for all languages, <code>false</code> if the key should be changed only for the current language.
@return result, indicating if the key change was successful. | [
"Handles",
"a",
"key",
"change",
"."
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorModel.java#L815-L826 |
alkacon/opencms-core | src/org/opencms/xml/CmsXmlContentDefinition.java | CmsXmlContentDefinition.getCachedContentDefinition | private static CmsXmlContentDefinition getCachedContentDefinition(String schemaLocation, EntityResolver resolver) {
"""
Looks up the given XML content definition system id in the internal content definition cache.<p>
@param schemaLocation the system id of the XML content definition to look up
@param resolver the XML entity resolver to use (contains the cache)
@return the XML content definition found, or null if no definition is cached for the given system id
"""
if (resolver instanceof CmsXmlEntityResolver) {
// check for a cached version of this content definition
CmsXmlEntityResolver cmsResolver = (CmsXmlEntityResolver)resolver;
return cmsResolver.getCachedContentDefinition(schemaLocation);
}
return null;
} | java | private static CmsXmlContentDefinition getCachedContentDefinition(String schemaLocation, EntityResolver resolver) {
if (resolver instanceof CmsXmlEntityResolver) {
// check for a cached version of this content definition
CmsXmlEntityResolver cmsResolver = (CmsXmlEntityResolver)resolver;
return cmsResolver.getCachedContentDefinition(schemaLocation);
}
return null;
} | [
"private",
"static",
"CmsXmlContentDefinition",
"getCachedContentDefinition",
"(",
"String",
"schemaLocation",
",",
"EntityResolver",
"resolver",
")",
"{",
"if",
"(",
"resolver",
"instanceof",
"CmsXmlEntityResolver",
")",
"{",
"// check for a cached version of this content definition",
"CmsXmlEntityResolver",
"cmsResolver",
"=",
"(",
"CmsXmlEntityResolver",
")",
"resolver",
";",
"return",
"cmsResolver",
".",
"getCachedContentDefinition",
"(",
"schemaLocation",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Looks up the given XML content definition system id in the internal content definition cache.<p>
@param schemaLocation the system id of the XML content definition to look up
@param resolver the XML entity resolver to use (contains the cache)
@return the XML content definition found, or null if no definition is cached for the given system id | [
"Looks",
"up",
"the",
"given",
"XML",
"content",
"definition",
"system",
"id",
"in",
"the",
"internal",
"content",
"definition",
"cache",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/CmsXmlContentDefinition.java#L861-L869 |
baratine/baratine | core/src/main/java/com/caucho/v5/amp/manager/ServiceManagerAmpWrapper.java | ServiceManagerAmpWrapper.bind | @Override
public ServiceRefAmp bind(ServiceRefAmp service, String address) {
"""
/*
@Override
public <T> T createPinProxy(ServiceRefAmp actorRef,
Class<T> api,
Class<?>... apis)
{
return getDelegate().createPinProxy(actorRef, api, apis);
}
"""
return delegate().bind(service, address);
} | java | @Override
public ServiceRefAmp bind(ServiceRefAmp service, String address)
{
return delegate().bind(service, address);
} | [
"@",
"Override",
"public",
"ServiceRefAmp",
"bind",
"(",
"ServiceRefAmp",
"service",
",",
"String",
"address",
")",
"{",
"return",
"delegate",
"(",
")",
".",
"bind",
"(",
"service",
",",
"address",
")",
";",
"}"
] | /*
@Override
public <T> T createPinProxy(ServiceRefAmp actorRef,
Class<T> api,
Class<?>... apis)
{
return getDelegate().createPinProxy(actorRef, api, apis);
} | [
"/",
"*"
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/manager/ServiceManagerAmpWrapper.java#L158-L162 |
citrusframework/citrus | modules/citrus-core/src/main/java/com/consol/citrus/actions/ExecutePLSQLAction.java | ExecutePLSQLAction.createStatementsFromScript | private List<String> createStatementsFromScript(TestContext context) {
"""
Create SQL statements from inline script.
@param context the current test context.
@return list of SQL statements.
"""
List<String> stmts = new ArrayList<>();
script = context.replaceDynamicContentInString(script);
if (log.isDebugEnabled()) {
log.debug("Found inline PLSQL script " + script);
}
StringTokenizer tok = new StringTokenizer(script, PLSQL_STMT_ENDING);
while (tok.hasMoreTokens()) {
String next = tok.nextToken().trim();
if (StringUtils.hasText(next)) {
stmts.add(next);
}
}
return stmts;
} | java | private List<String> createStatementsFromScript(TestContext context) {
List<String> stmts = new ArrayList<>();
script = context.replaceDynamicContentInString(script);
if (log.isDebugEnabled()) {
log.debug("Found inline PLSQL script " + script);
}
StringTokenizer tok = new StringTokenizer(script, PLSQL_STMT_ENDING);
while (tok.hasMoreTokens()) {
String next = tok.nextToken().trim();
if (StringUtils.hasText(next)) {
stmts.add(next);
}
}
return stmts;
} | [
"private",
"List",
"<",
"String",
">",
"createStatementsFromScript",
"(",
"TestContext",
"context",
")",
"{",
"List",
"<",
"String",
">",
"stmts",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"script",
"=",
"context",
".",
"replaceDynamicContentInString",
"(",
"script",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"Found inline PLSQL script \"",
"+",
"script",
")",
";",
"}",
"StringTokenizer",
"tok",
"=",
"new",
"StringTokenizer",
"(",
"script",
",",
"PLSQL_STMT_ENDING",
")",
";",
"while",
"(",
"tok",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"next",
"=",
"tok",
".",
"nextToken",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"hasText",
"(",
"next",
")",
")",
"{",
"stmts",
".",
"add",
"(",
"next",
")",
";",
"}",
"}",
"return",
"stmts",
";",
"}"
] | Create SQL statements from inline script.
@param context the current test context.
@return list of SQL statements. | [
"Create",
"SQL",
"statements",
"from",
"inline",
"script",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-core/src/main/java/com/consol/citrus/actions/ExecutePLSQLAction.java#L119-L136 |
raphw/byte-buddy | byte-buddy-dep/src/main/java/net/bytebuddy/utility/JavaConstant.java | MethodHandle.ofLoaded | public static MethodHandle ofLoaded(Object methodHandle, Object lookup) {
"""
Creates a method handles representation of a loaded method handle which is analyzed using the given lookup context.
A method handle can only be analyzed on virtual machines that support the corresponding API (Java 7+). For virtual machines before Java 8+,
a method handle instance can only be analyzed by taking advantage of private APIs what might require a access context.
@param methodHandle The loaded method handle to represent.
@param lookup The lookup object to use for analyzing the method handle.
@return A representation of the loaded method handle
"""
if (!JavaType.METHOD_HANDLE.isInstance(methodHandle)) {
throw new IllegalArgumentException("Expected method handle object: " + methodHandle);
} else if (!JavaType.METHOD_HANDLES_LOOKUP.isInstance(lookup)) {
throw new IllegalArgumentException("Expected method handle lookup object: " + lookup);
}
Dispatcher dispatcher = DISPATCHER.initialize();
Object methodHandleInfo = dispatcher.reveal(lookup, methodHandle);
Object methodType = dispatcher.getMethodType(methodHandleInfo);
return new MethodHandle(HandleType.of(dispatcher.getReferenceKind(methodHandleInfo)),
TypeDescription.ForLoadedType.of(dispatcher.getDeclaringClass(methodHandleInfo)),
dispatcher.getName(methodHandleInfo),
TypeDescription.ForLoadedType.of(dispatcher.returnType(methodType)),
new TypeList.ForLoadedTypes(dispatcher.parameterArray(methodType)));
} | java | public static MethodHandle ofLoaded(Object methodHandle, Object lookup) {
if (!JavaType.METHOD_HANDLE.isInstance(methodHandle)) {
throw new IllegalArgumentException("Expected method handle object: " + methodHandle);
} else if (!JavaType.METHOD_HANDLES_LOOKUP.isInstance(lookup)) {
throw new IllegalArgumentException("Expected method handle lookup object: " + lookup);
}
Dispatcher dispatcher = DISPATCHER.initialize();
Object methodHandleInfo = dispatcher.reveal(lookup, methodHandle);
Object methodType = dispatcher.getMethodType(methodHandleInfo);
return new MethodHandle(HandleType.of(dispatcher.getReferenceKind(methodHandleInfo)),
TypeDescription.ForLoadedType.of(dispatcher.getDeclaringClass(methodHandleInfo)),
dispatcher.getName(methodHandleInfo),
TypeDescription.ForLoadedType.of(dispatcher.returnType(methodType)),
new TypeList.ForLoadedTypes(dispatcher.parameterArray(methodType)));
} | [
"public",
"static",
"MethodHandle",
"ofLoaded",
"(",
"Object",
"methodHandle",
",",
"Object",
"lookup",
")",
"{",
"if",
"(",
"!",
"JavaType",
".",
"METHOD_HANDLE",
".",
"isInstance",
"(",
"methodHandle",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected method handle object: \"",
"+",
"methodHandle",
")",
";",
"}",
"else",
"if",
"(",
"!",
"JavaType",
".",
"METHOD_HANDLES_LOOKUP",
".",
"isInstance",
"(",
"lookup",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected method handle lookup object: \"",
"+",
"lookup",
")",
";",
"}",
"Dispatcher",
"dispatcher",
"=",
"DISPATCHER",
".",
"initialize",
"(",
")",
";",
"Object",
"methodHandleInfo",
"=",
"dispatcher",
".",
"reveal",
"(",
"lookup",
",",
"methodHandle",
")",
";",
"Object",
"methodType",
"=",
"dispatcher",
".",
"getMethodType",
"(",
"methodHandleInfo",
")",
";",
"return",
"new",
"MethodHandle",
"(",
"HandleType",
".",
"of",
"(",
"dispatcher",
".",
"getReferenceKind",
"(",
"methodHandleInfo",
")",
")",
",",
"TypeDescription",
".",
"ForLoadedType",
".",
"of",
"(",
"dispatcher",
".",
"getDeclaringClass",
"(",
"methodHandleInfo",
")",
")",
",",
"dispatcher",
".",
"getName",
"(",
"methodHandleInfo",
")",
",",
"TypeDescription",
".",
"ForLoadedType",
".",
"of",
"(",
"dispatcher",
".",
"returnType",
"(",
"methodType",
")",
")",
",",
"new",
"TypeList",
".",
"ForLoadedTypes",
"(",
"dispatcher",
".",
"parameterArray",
"(",
"methodType",
")",
")",
")",
";",
"}"
] | Creates a method handles representation of a loaded method handle which is analyzed using the given lookup context.
A method handle can only be analyzed on virtual machines that support the corresponding API (Java 7+). For virtual machines before Java 8+,
a method handle instance can only be analyzed by taking advantage of private APIs what might require a access context.
@param methodHandle The loaded method handle to represent.
@param lookup The lookup object to use for analyzing the method handle.
@return A representation of the loaded method handle | [
"Creates",
"a",
"method",
"handles",
"representation",
"of",
"a",
"loaded",
"method",
"handle",
"which",
"is",
"analyzed",
"using",
"the",
"given",
"lookup",
"context",
".",
"A",
"method",
"handle",
"can",
"only",
"be",
"analyzed",
"on",
"virtual",
"machines",
"that",
"support",
"the",
"corresponding",
"API",
"(",
"Java",
"7",
"+",
")",
".",
"For",
"virtual",
"machines",
"before",
"Java",
"8",
"+",
"a",
"method",
"handle",
"instance",
"can",
"only",
"be",
"analyzed",
"by",
"taking",
"advantage",
"of",
"private",
"APIs",
"what",
"might",
"require",
"a",
"access",
"context",
"."
] | train | https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/utility/JavaConstant.java#L503-L517 |
Azure/azure-sdk-for-java | compute/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java | DisksInner.createOrUpdate | public DiskInner createOrUpdate(String resourceGroupName, String diskName, DiskInner disk) {
"""
Creates or updates a disk.
@param resourceGroupName The name of the resource group.
@param diskName The name of the managed disk that is being created. The name can't be changed after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters.
@param disk Disk object supplied in the body of the Put disk operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DiskInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, diskName, disk).toBlocking().last().body();
} | java | public DiskInner createOrUpdate(String resourceGroupName, String diskName, DiskInner disk) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, diskName, disk).toBlocking().last().body();
} | [
"public",
"DiskInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"diskName",
",",
"DiskInner",
"disk",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"diskName",
",",
"disk",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates or updates a disk.
@param resourceGroupName The name of the resource group.
@param diskName The name of the managed disk that is being created. The name can't be changed after the disk is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80 characters.
@param disk Disk object supplied in the body of the Put disk operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DiskInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"disk",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java#L144-L146 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.document_id_GET | public OvhDocument document_id_GET(String id) throws IOException {
"""
Get this object properties
REST: GET /me/document/{id}
@param id [required] Document id
"""
String qPath = "/me/document/{id}";
StringBuilder sb = path(qPath, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDocument.class);
} | java | public OvhDocument document_id_GET(String id) throws IOException {
String qPath = "/me/document/{id}";
StringBuilder sb = path(qPath, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDocument.class);
} | [
"public",
"OvhDocument",
"document_id_GET",
"(",
"String",
"id",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/document/{id}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"id",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDocument",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /me/document/{id}
@param id [required] Document id | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L2545-L2550 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ManagedInstancesInner.java | ManagedInstancesInner.updateAsync | public Observable<ManagedInstanceInner> updateAsync(String resourceGroupName, String managedInstanceName, ManagedInstanceUpdate parameters) {
"""
Updates a managed instance.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param managedInstanceName The name of the managed instance.
@param parameters The requested managed instance resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return updateWithServiceResponseAsync(resourceGroupName, managedInstanceName, parameters).map(new Func1<ServiceResponse<ManagedInstanceInner>, ManagedInstanceInner>() {
@Override
public ManagedInstanceInner call(ServiceResponse<ManagedInstanceInner> response) {
return response.body();
}
});
} | java | public Observable<ManagedInstanceInner> updateAsync(String resourceGroupName, String managedInstanceName, ManagedInstanceUpdate parameters) {
return updateWithServiceResponseAsync(resourceGroupName, managedInstanceName, parameters).map(new Func1<ServiceResponse<ManagedInstanceInner>, ManagedInstanceInner>() {
@Override
public ManagedInstanceInner call(ServiceResponse<ManagedInstanceInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ManagedInstanceInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"managedInstanceName",
",",
"ManagedInstanceUpdate",
"parameters",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"managedInstanceName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ManagedInstanceInner",
">",
",",
"ManagedInstanceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ManagedInstanceInner",
"call",
"(",
"ServiceResponse",
"<",
"ManagedInstanceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates a managed instance.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param managedInstanceName The name of the managed instance.
@param parameters The requested managed instance resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Updates",
"a",
"managed",
"instance",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ManagedInstancesInner.java#L789-L796 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java | PgResultSet.getBytes | @Override
public byte[] getBytes(int columnIndex) throws SQLException {
"""
{@inheritDoc}
<p>In normal use, the bytes represent the raw values returned by the backend. However, if the
column is an OID, then it is assumed to refer to a Large Object, and that object is returned as
a byte array.</p>
<p><b>Be warned</b> If the large object is huge, then you may run out of memory.</p>
"""
connection.getLogger().log(Level.FINEST, " getBytes columnIndex: {0}", columnIndex);
checkResultSet(columnIndex);
if (wasNullFlag) {
return null;
}
if (isBinary(columnIndex)) {
// If the data is already binary then just return it
return thisRow[columnIndex - 1];
}
if (fields[columnIndex - 1].getOID() == Oid.BYTEA) {
return trimBytes(columnIndex, PGbytea.toBytes(thisRow[columnIndex - 1]));
} else {
return trimBytes(columnIndex, thisRow[columnIndex - 1]);
}
} | java | @Override
public byte[] getBytes(int columnIndex) throws SQLException {
connection.getLogger().log(Level.FINEST, " getBytes columnIndex: {0}", columnIndex);
checkResultSet(columnIndex);
if (wasNullFlag) {
return null;
}
if (isBinary(columnIndex)) {
// If the data is already binary then just return it
return thisRow[columnIndex - 1];
}
if (fields[columnIndex - 1].getOID() == Oid.BYTEA) {
return trimBytes(columnIndex, PGbytea.toBytes(thisRow[columnIndex - 1]));
} else {
return trimBytes(columnIndex, thisRow[columnIndex - 1]);
}
} | [
"@",
"Override",
"public",
"byte",
"[",
"]",
"getBytes",
"(",
"int",
"columnIndex",
")",
"throws",
"SQLException",
"{",
"connection",
".",
"getLogger",
"(",
")",
".",
"log",
"(",
"Level",
".",
"FINEST",
",",
"\" getBytes columnIndex: {0}\"",
",",
"columnIndex",
")",
";",
"checkResultSet",
"(",
"columnIndex",
")",
";",
"if",
"(",
"wasNullFlag",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"isBinary",
"(",
"columnIndex",
")",
")",
"{",
"// If the data is already binary then just return it",
"return",
"thisRow",
"[",
"columnIndex",
"-",
"1",
"]",
";",
"}",
"if",
"(",
"fields",
"[",
"columnIndex",
"-",
"1",
"]",
".",
"getOID",
"(",
")",
"==",
"Oid",
".",
"BYTEA",
")",
"{",
"return",
"trimBytes",
"(",
"columnIndex",
",",
"PGbytea",
".",
"toBytes",
"(",
"thisRow",
"[",
"columnIndex",
"-",
"1",
"]",
")",
")",
";",
"}",
"else",
"{",
"return",
"trimBytes",
"(",
"columnIndex",
",",
"thisRow",
"[",
"columnIndex",
"-",
"1",
"]",
")",
";",
"}",
"}"
] | {@inheritDoc}
<p>In normal use, the bytes represent the raw values returned by the backend. However, if the
column is an OID, then it is assumed to refer to a Large Object, and that object is returned as
a byte array.</p>
<p><b>Be warned</b> If the large object is huge, then you may run out of memory.</p> | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java#L2324-L2341 |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/cookie/CookieHelper.java | CookieHelper.removeCookie | public static void removeCookie (@Nonnull final HttpServletResponse aHttpResponse, @Nonnull final Cookie aCookie) {
"""
Remove a cookie by setting the max age to 0.
@param aHttpResponse
The HTTP response. May not be <code>null</code>.
@param aCookie
The cookie to be removed. May not be <code>null</code>.
"""
ValueEnforcer.notNull (aHttpResponse, "HttpResponse");
ValueEnforcer.notNull (aCookie, "aCookie");
// expire the cookie!
aCookie.setMaxAge (0);
aHttpResponse.addCookie (aCookie);
} | java | public static void removeCookie (@Nonnull final HttpServletResponse aHttpResponse, @Nonnull final Cookie aCookie)
{
ValueEnforcer.notNull (aHttpResponse, "HttpResponse");
ValueEnforcer.notNull (aCookie, "aCookie");
// expire the cookie!
aCookie.setMaxAge (0);
aHttpResponse.addCookie (aCookie);
} | [
"public",
"static",
"void",
"removeCookie",
"(",
"@",
"Nonnull",
"final",
"HttpServletResponse",
"aHttpResponse",
",",
"@",
"Nonnull",
"final",
"Cookie",
"aCookie",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aHttpResponse",
",",
"\"HttpResponse\"",
")",
";",
"ValueEnforcer",
".",
"notNull",
"(",
"aCookie",
",",
"\"aCookie\"",
")",
";",
"// expire the cookie!",
"aCookie",
".",
"setMaxAge",
"(",
"0",
")",
";",
"aHttpResponse",
".",
"addCookie",
"(",
"aCookie",
")",
";",
"}"
] | Remove a cookie by setting the max age to 0.
@param aHttpResponse
The HTTP response. May not be <code>null</code>.
@param aCookie
The cookie to be removed. May not be <code>null</code>. | [
"Remove",
"a",
"cookie",
"by",
"setting",
"the",
"max",
"age",
"to",
"0",
"."
] | train | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/cookie/CookieHelper.java#L135-L143 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.intdiv | public static Number intdiv(Number left, Number right) {
"""
Integer Divide two Numbers.
@param left a Number
@param right another Number
@return a Number (an Integer) resulting from the integer division operation
@since 1.0
"""
return NumberMath.intdiv(left, right);
} | java | public static Number intdiv(Number left, Number right) {
return NumberMath.intdiv(left, right);
} | [
"public",
"static",
"Number",
"intdiv",
"(",
"Number",
"left",
",",
"Number",
"right",
")",
"{",
"return",
"NumberMath",
".",
"intdiv",
"(",
"left",
",",
"right",
")",
";",
"}"
] | Integer Divide two Numbers.
@param left a Number
@param right another Number
@return a Number (an Integer) resulting from the integer division operation
@since 1.0 | [
"Integer",
"Divide",
"two",
"Numbers",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L15434-L15436 |
keyboardsurfer/Crouton | library/src/main/java/de/keyboardsurfer/android/widget/crouton/Manager.java | Manager.removeCrouton | protected void removeCrouton(Crouton crouton) {
"""
Removes the {@link Crouton}'s view after it's display
durationInMilliseconds.
@param crouton
The {@link Crouton} added to a {@link ViewGroup} and should be
removed.
"""
// If the crouton hasn't been displayed yet a `Crouton.hide()` will fail to hide
// it since the DISPLAY message might still be in the queue. Remove all messages
// for this crouton.
removeAllMessagesForCrouton(crouton);
View croutonView = crouton.getView();
ViewGroup croutonParentView = (ViewGroup) croutonView.getParent();
if (null != croutonParentView) {
croutonView.startAnimation(crouton.getOutAnimation());
// Remove the Crouton from the queue.
Crouton removed = croutonQueue.poll();
// Remove the crouton from the view's parent.
croutonParentView.removeView(croutonView);
if (null != removed) {
removed.detachActivity();
removed.detachViewGroup();
if (null != removed.getLifecycleCallback()) {
removed.getLifecycleCallback().onRemoved();
}
removed.detachLifecycleCallback();
}
// Send a message to display the next crouton but delay it by the out
// animation duration to make sure it finishes
sendMessageDelayed(crouton, Messages.DISPLAY_CROUTON, crouton.getOutAnimation().getDuration());
}
} | java | protected void removeCrouton(Crouton crouton) {
// If the crouton hasn't been displayed yet a `Crouton.hide()` will fail to hide
// it since the DISPLAY message might still be in the queue. Remove all messages
// for this crouton.
removeAllMessagesForCrouton(crouton);
View croutonView = crouton.getView();
ViewGroup croutonParentView = (ViewGroup) croutonView.getParent();
if (null != croutonParentView) {
croutonView.startAnimation(crouton.getOutAnimation());
// Remove the Crouton from the queue.
Crouton removed = croutonQueue.poll();
// Remove the crouton from the view's parent.
croutonParentView.removeView(croutonView);
if (null != removed) {
removed.detachActivity();
removed.detachViewGroup();
if (null != removed.getLifecycleCallback()) {
removed.getLifecycleCallback().onRemoved();
}
removed.detachLifecycleCallback();
}
// Send a message to display the next crouton but delay it by the out
// animation duration to make sure it finishes
sendMessageDelayed(crouton, Messages.DISPLAY_CROUTON, crouton.getOutAnimation().getDuration());
}
} | [
"protected",
"void",
"removeCrouton",
"(",
"Crouton",
"crouton",
")",
"{",
"// If the crouton hasn't been displayed yet a `Crouton.hide()` will fail to hide",
"// it since the DISPLAY message might still be in the queue. Remove all messages",
"// for this crouton.",
"removeAllMessagesForCrouton",
"(",
"crouton",
")",
";",
"View",
"croutonView",
"=",
"crouton",
".",
"getView",
"(",
")",
";",
"ViewGroup",
"croutonParentView",
"=",
"(",
"ViewGroup",
")",
"croutonView",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"croutonParentView",
")",
"{",
"croutonView",
".",
"startAnimation",
"(",
"crouton",
".",
"getOutAnimation",
"(",
")",
")",
";",
"// Remove the Crouton from the queue.",
"Crouton",
"removed",
"=",
"croutonQueue",
".",
"poll",
"(",
")",
";",
"// Remove the crouton from the view's parent.",
"croutonParentView",
".",
"removeView",
"(",
"croutonView",
")",
";",
"if",
"(",
"null",
"!=",
"removed",
")",
"{",
"removed",
".",
"detachActivity",
"(",
")",
";",
"removed",
".",
"detachViewGroup",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"removed",
".",
"getLifecycleCallback",
"(",
")",
")",
"{",
"removed",
".",
"getLifecycleCallback",
"(",
")",
".",
"onRemoved",
"(",
")",
";",
"}",
"removed",
".",
"detachLifecycleCallback",
"(",
")",
";",
"}",
"// Send a message to display the next crouton but delay it by the out",
"// animation duration to make sure it finishes",
"sendMessageDelayed",
"(",
"crouton",
",",
"Messages",
".",
"DISPLAY_CROUTON",
",",
"crouton",
".",
"getOutAnimation",
"(",
")",
".",
"getDuration",
"(",
")",
")",
";",
"}",
"}"
] | Removes the {@link Crouton}'s view after it's display
durationInMilliseconds.
@param crouton
The {@link Crouton} added to a {@link ViewGroup} and should be
removed. | [
"Removes",
"the",
"{",
"@link",
"Crouton",
"}",
"s",
"view",
"after",
"it",
"s",
"display",
"durationInMilliseconds",
"."
] | train | https://github.com/keyboardsurfer/Crouton/blob/7806b15e4d52793e1f5aeaa4a55b1e220289e619/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Manager.java#L295-L325 |
actframework/actframework | src/main/java/act/cli/ascii_table/impl/SimpleASCIITableImpl.java | SimpleASCIITableImpl.getRowLineBuf | private String getRowLineBuf(int colCount, List<Integer> colMaxLenList, String[][] data) {
"""
Each string item rendering requires the border and a space on both sides.
12 3 12 3 12 34
+----- +-------- +------+
abc venkat last
@param colCount
@param colMaxLenList
@param data
@return
"""
S.Buffer rowBuilder = S.buffer();
int colWidth;
for (int i = 0 ; i < colCount ; i ++) {
colWidth = colMaxLenList.get(i) + 3;
for (int j = 0; j < colWidth ; j ++) {
if (j==0) {
rowBuilder.append("+");
} else if ((i+1 == colCount && j+1 == colWidth)) {//for last column close the border
rowBuilder.append("-+");
} else {
rowBuilder.append("-");
}
}
}
return rowBuilder.append("\n").toString();
} | java | private String getRowLineBuf(int colCount, List<Integer> colMaxLenList, String[][] data) {
S.Buffer rowBuilder = S.buffer();
int colWidth;
for (int i = 0 ; i < colCount ; i ++) {
colWidth = colMaxLenList.get(i) + 3;
for (int j = 0; j < colWidth ; j ++) {
if (j==0) {
rowBuilder.append("+");
} else if ((i+1 == colCount && j+1 == colWidth)) {//for last column close the border
rowBuilder.append("-+");
} else {
rowBuilder.append("-");
}
}
}
return rowBuilder.append("\n").toString();
} | [
"private",
"String",
"getRowLineBuf",
"(",
"int",
"colCount",
",",
"List",
"<",
"Integer",
">",
"colMaxLenList",
",",
"String",
"[",
"]",
"[",
"]",
"data",
")",
"{",
"S",
".",
"Buffer",
"rowBuilder",
"=",
"S",
".",
"buffer",
"(",
")",
";",
"int",
"colWidth",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"colCount",
";",
"i",
"++",
")",
"{",
"colWidth",
"=",
"colMaxLenList",
".",
"get",
"(",
"i",
")",
"+",
"3",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"colWidth",
";",
"j",
"++",
")",
"{",
"if",
"(",
"j",
"==",
"0",
")",
"{",
"rowBuilder",
".",
"append",
"(",
"\"+\"",
")",
";",
"}",
"else",
"if",
"(",
"(",
"i",
"+",
"1",
"==",
"colCount",
"&&",
"j",
"+",
"1",
"==",
"colWidth",
")",
")",
"{",
"//for last column close the border",
"rowBuilder",
".",
"append",
"(",
"\"-+\"",
")",
";",
"}",
"else",
"{",
"rowBuilder",
".",
"append",
"(",
"\"-\"",
")",
";",
"}",
"}",
"}",
"return",
"rowBuilder",
".",
"append",
"(",
"\"\\n\"",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Each string item rendering requires the border and a space on both sides.
12 3 12 3 12 34
+----- +-------- +------+
abc venkat last
@param colCount
@param colMaxLenList
@param data
@return | [
"Each",
"string",
"item",
"rendering",
"requires",
"the",
"border",
"and",
"a",
"space",
"on",
"both",
"sides",
"."
] | train | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/cli/ascii_table/impl/SimpleASCIITableImpl.java#L338-L359 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/UtilFile.java | UtilFile.isType | public static boolean isType(File file, String extension) {
"""
Check if the following type is the expected type.
@param file The file to check (can be <code>null</code>).
@param extension The expected extension (must not be <code>null</code>).
@return <code>true</code> if correct, <code>false</code> else.
@throws LionEngineException If invalid argument.
"""
Check.notNull(extension);
if (file != null && file.isFile())
{
final String current = getExtension(file);
return current.equals(extension.replace(Constant.DOT, Constant.EMPTY_STRING));
}
return false;
} | java | public static boolean isType(File file, String extension)
{
Check.notNull(extension);
if (file != null && file.isFile())
{
final String current = getExtension(file);
return current.equals(extension.replace(Constant.DOT, Constant.EMPTY_STRING));
}
return false;
} | [
"public",
"static",
"boolean",
"isType",
"(",
"File",
"file",
",",
"String",
"extension",
")",
"{",
"Check",
".",
"notNull",
"(",
"extension",
")",
";",
"if",
"(",
"file",
"!=",
"null",
"&&",
"file",
".",
"isFile",
"(",
")",
")",
"{",
"final",
"String",
"current",
"=",
"getExtension",
"(",
"file",
")",
";",
"return",
"current",
".",
"equals",
"(",
"extension",
".",
"replace",
"(",
"Constant",
".",
"DOT",
",",
"Constant",
".",
"EMPTY_STRING",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Check if the following type is the expected type.
@param file The file to check (can be <code>null</code>).
@param extension The expected extension (must not be <code>null</code>).
@return <code>true</code> if correct, <code>false</code> else.
@throws LionEngineException If invalid argument. | [
"Check",
"if",
"the",
"following",
"type",
"is",
"the",
"expected",
"type",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/UtilFile.java#L233-L243 |
Alexey1Gavrilov/ExpectIt | expectit-core/src/main/java/net/sf/expectit/ExpectBuilder.java | ExpectBuilder.withTimeout | public final ExpectBuilder withTimeout(long duration, TimeUnit unit) {
"""
Sets the default timeout in the given unit for expect operations. Optional,
the default value is 30 seconds.
@param duration the timeout value
@param unit the time unit
@return this
@throws java.lang.IllegalArgumentException if the timeout {@code <= 0}
"""
validateDuration(duration);
this.timeout = unit.toMillis(duration);
return this;
} | java | public final ExpectBuilder withTimeout(long duration, TimeUnit unit) {
validateDuration(duration);
this.timeout = unit.toMillis(duration);
return this;
} | [
"public",
"final",
"ExpectBuilder",
"withTimeout",
"(",
"long",
"duration",
",",
"TimeUnit",
"unit",
")",
"{",
"validateDuration",
"(",
"duration",
")",
";",
"this",
".",
"timeout",
"=",
"unit",
".",
"toMillis",
"(",
"duration",
")",
";",
"return",
"this",
";",
"}"
] | Sets the default timeout in the given unit for expect operations. Optional,
the default value is 30 seconds.
@param duration the timeout value
@param unit the time unit
@return this
@throws java.lang.IllegalArgumentException if the timeout {@code <= 0} | [
"Sets",
"the",
"default",
"timeout",
"in",
"the",
"given",
"unit",
"for",
"expect",
"operations",
".",
"Optional",
"the",
"default",
"value",
"is",
"30",
"seconds",
"."
] | train | https://github.com/Alexey1Gavrilov/ExpectIt/blob/5acbe1f8f895fe1dbd63e29bf3ab8e5bbf0873c3/expectit-core/src/main/java/net/sf/expectit/ExpectBuilder.java#L104-L108 |
alipay/sofa-hessian | src/main/java/com/caucho/hessian/io/Hessian2Output.java | Hessian2Output.writeListBegin | public boolean writeListBegin(int length, String type)
throws IOException {
"""
Writes the list header to the stream. List writers will call
<code>writeListBegin</code> followed by the list contents and then
call <code>writeListEnd</code>.
<code><pre>
list ::= V type value* Z
::= v type int value*
</pre></code>
@return true for variable lists, false for fixed lists
"""
flushIfFull();
if (length < 0) {
if (type != null) {
_buffer[_offset++] = (byte) BC_LIST_VARIABLE;
writeType(type);
}
else
_buffer[_offset++] = (byte) BC_LIST_VARIABLE_UNTYPED;
return true;
}
else if (length <= LIST_DIRECT_MAX) {
if (type != null) {
_buffer[_offset++] = (byte) (BC_LIST_DIRECT + length);
writeType(type);
}
else {
_buffer[_offset++] = (byte) (BC_LIST_DIRECT_UNTYPED + length);
}
return false;
}
else {
if (type != null) {
_buffer[_offset++] = (byte) BC_LIST_FIXED;
writeType(type);
}
else {
_buffer[_offset++] = (byte) BC_LIST_FIXED_UNTYPED;
}
writeInt(length);
return false;
}
} | java | public boolean writeListBegin(int length, String type)
throws IOException
{
flushIfFull();
if (length < 0) {
if (type != null) {
_buffer[_offset++] = (byte) BC_LIST_VARIABLE;
writeType(type);
}
else
_buffer[_offset++] = (byte) BC_LIST_VARIABLE_UNTYPED;
return true;
}
else if (length <= LIST_DIRECT_MAX) {
if (type != null) {
_buffer[_offset++] = (byte) (BC_LIST_DIRECT + length);
writeType(type);
}
else {
_buffer[_offset++] = (byte) (BC_LIST_DIRECT_UNTYPED + length);
}
return false;
}
else {
if (type != null) {
_buffer[_offset++] = (byte) BC_LIST_FIXED;
writeType(type);
}
else {
_buffer[_offset++] = (byte) BC_LIST_FIXED_UNTYPED;
}
writeInt(length);
return false;
}
} | [
"public",
"boolean",
"writeListBegin",
"(",
"int",
"length",
",",
"String",
"type",
")",
"throws",
"IOException",
"{",
"flushIfFull",
"(",
")",
";",
"if",
"(",
"length",
"<",
"0",
")",
"{",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"BC_LIST_VARIABLE",
";",
"writeType",
"(",
"type",
")",
";",
"}",
"else",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"BC_LIST_VARIABLE_UNTYPED",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"length",
"<=",
"LIST_DIRECT_MAX",
")",
"{",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"BC_LIST_DIRECT",
"+",
"length",
")",
";",
"writeType",
"(",
"type",
")",
";",
"}",
"else",
"{",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"BC_LIST_DIRECT_UNTYPED",
"+",
"length",
")",
";",
"}",
"return",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"BC_LIST_FIXED",
";",
"writeType",
"(",
"type",
")",
";",
"}",
"else",
"{",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"BC_LIST_FIXED_UNTYPED",
";",
"}",
"writeInt",
"(",
"length",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Writes the list header to the stream. List writers will call
<code>writeListBegin</code> followed by the list contents and then
call <code>writeListEnd</code>.
<code><pre>
list ::= V type value* Z
::= v type int value*
</pre></code>
@return true for variable lists, false for fixed lists | [
"Writes",
"the",
"list",
"header",
"to",
"the",
"stream",
".",
"List",
"writers",
"will",
"call",
"<code",
">",
"writeListBegin<",
"/",
"code",
">",
"followed",
"by",
"the",
"list",
"contents",
"and",
"then",
"call",
"<code",
">",
"writeListEnd<",
"/",
"code",
">",
"."
] | train | https://github.com/alipay/sofa-hessian/blob/89e4f5af28602101dab7b498995018871616357b/src/main/java/com/caucho/hessian/io/Hessian2Output.java#L477-L516 |
rundeck/rundeck | core/src/main/java/com/dtolabs/utils/PropertiesUtil.java | PropertiesUtil.listPropertiesWithPrefix | public static Collection listPropertiesWithPrefix(Properties props, String prefix) {
"""
Returns a Collection of all property values that have keys with a certain prefix.
@param props the Properties to reaqd
@param prefix the prefix
@return Collection of all property values with keys with a certain prefix
"""
final HashSet set = new HashSet();
for (Iterator i = props.keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
if (key.startsWith(prefix)) {
set.add(props.getProperty(key));
}
}
return set;
} | java | public static Collection listPropertiesWithPrefix(Properties props, String prefix) {
final HashSet set = new HashSet();
for (Iterator i = props.keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
if (key.startsWith(prefix)) {
set.add(props.getProperty(key));
}
}
return set;
} | [
"public",
"static",
"Collection",
"listPropertiesWithPrefix",
"(",
"Properties",
"props",
",",
"String",
"prefix",
")",
"{",
"final",
"HashSet",
"set",
"=",
"new",
"HashSet",
"(",
")",
";",
"for",
"(",
"Iterator",
"i",
"=",
"props",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"key",
"=",
"(",
"String",
")",
"i",
".",
"next",
"(",
")",
";",
"if",
"(",
"key",
".",
"startsWith",
"(",
"prefix",
")",
")",
"{",
"set",
".",
"add",
"(",
"props",
".",
"getProperty",
"(",
"key",
")",
")",
";",
"}",
"}",
"return",
"set",
";",
"}"
] | Returns a Collection of all property values that have keys with a certain prefix.
@param props the Properties to reaqd
@param prefix the prefix
@return Collection of all property values with keys with a certain prefix | [
"Returns",
"a",
"Collection",
"of",
"all",
"property",
"values",
"that",
"have",
"keys",
"with",
"a",
"certain",
"prefix",
"."
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/PropertiesUtil.java#L125-L134 |
jboss/jboss-jstl-api_spec | src/main/java/org/apache/taglibs/standard/functions/Functions.java | Functions.containsIgnoreCase | public static boolean containsIgnoreCase(String input, String substring) {
"""
Tests if a string contains the specified substring in a case insensitive way.
Equivalent to <code>fn:contains(fn:toUpperCase(string), fn:toUpperCase(substring))</code>.
@param input the input string on which the function is applied
@param substring the substring tested for
@return true if the character sequence represented by the substring
exists in the string
"""
return contains(input.toUpperCase(), substring.toUpperCase());
} | java | public static boolean containsIgnoreCase(String input, String substring) {
return contains(input.toUpperCase(), substring.toUpperCase());
} | [
"public",
"static",
"boolean",
"containsIgnoreCase",
"(",
"String",
"input",
",",
"String",
"substring",
")",
"{",
"return",
"contains",
"(",
"input",
".",
"toUpperCase",
"(",
")",
",",
"substring",
".",
"toUpperCase",
"(",
")",
")",
";",
"}"
] | Tests if a string contains the specified substring in a case insensitive way.
Equivalent to <code>fn:contains(fn:toUpperCase(string), fn:toUpperCase(substring))</code>.
@param input the input string on which the function is applied
@param substring the substring tested for
@return true if the character sequence represented by the substring
exists in the string | [
"Tests",
"if",
"a",
"string",
"contains",
"the",
"specified",
"substring",
"in",
"a",
"case",
"insensitive",
"way",
".",
"Equivalent",
"to",
"<code",
">",
"fn",
":",
"contains",
"(",
"fn",
":",
"toUpperCase",
"(",
"string",
")",
"fn",
":",
"toUpperCase",
"(",
"substring",
"))",
"<",
"/",
"code",
">",
"."
] | train | https://github.com/jboss/jboss-jstl-api_spec/blob/4ad412ae5be1ae606b8d33c188cb3d98bfcbe84c/src/main/java/org/apache/taglibs/standard/functions/Functions.java#L107-L109 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/GVRMesh.java | GVRMesh.createQuad | public static GVRMesh createQuad(GVRContext ctx, String vertexDesc, float width, float height) {
"""
Creates a mesh whose vertices describe a quad consisting of two triangles,
with the specified width and height. If the vertex descriptor allows for
normals and/or texture coordinates, they are added.
@param ctx GVRContext to use for creating mesh.
@param vertexDesc String describing vertex format of {@link GVRVertexBuffer}
@param width the quad's width
@param height the quad's height
@return A 2D, rectangular mesh with four vertices and two triangles
"""
GVRMesh mesh = new GVRMesh(ctx, vertexDesc);
mesh.createQuad(width, height);
return mesh;
} | java | public static GVRMesh createQuad(GVRContext ctx, String vertexDesc, float width, float height)
{
GVRMesh mesh = new GVRMesh(ctx, vertexDesc);
mesh.createQuad(width, height);
return mesh;
} | [
"public",
"static",
"GVRMesh",
"createQuad",
"(",
"GVRContext",
"ctx",
",",
"String",
"vertexDesc",
",",
"float",
"width",
",",
"float",
"height",
")",
"{",
"GVRMesh",
"mesh",
"=",
"new",
"GVRMesh",
"(",
"ctx",
",",
"vertexDesc",
")",
";",
"mesh",
".",
"createQuad",
"(",
"width",
",",
"height",
")",
";",
"return",
"mesh",
";",
"}"
] | Creates a mesh whose vertices describe a quad consisting of two triangles,
with the specified width and height. If the vertex descriptor allows for
normals and/or texture coordinates, they are added.
@param ctx GVRContext to use for creating mesh.
@param vertexDesc String describing vertex format of {@link GVRVertexBuffer}
@param width the quad's width
@param height the quad's height
@return A 2D, rectangular mesh with four vertices and two triangles | [
"Creates",
"a",
"mesh",
"whose",
"vertices",
"describe",
"a",
"quad",
"consisting",
"of",
"two",
"triangles",
"with",
"the",
"specified",
"width",
"and",
"height",
".",
"If",
"the",
"vertex",
"descriptor",
"allows",
"for",
"normals",
"and",
"/",
"or",
"texture",
"coordinates",
"they",
"are",
"added",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRMesh.java#L733-L738 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.