repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
ingwarsw/arquillian-suite-extension
|
src/main/java/org/eu/ingwar/tools/arquillian/extension/deployment/EarDescriptorBuilder.java
|
EarDescriptorBuilder.addWeb
|
public EarDescriptorBuilder addWeb(String filename, String context) {
"""
Adds WEB module to descriptor.
@param filename name of WAR to add
@param context web context to set for WEB module
@return this object
"""
Map.Entry<String, String> entry = new AbstractMap.SimpleEntry<String, String>(filename, context);
this.webs.add(entry);
return this;
}
|
java
|
public EarDescriptorBuilder addWeb(String filename, String context) {
Map.Entry<String, String> entry = new AbstractMap.SimpleEntry<String, String>(filename, context);
this.webs.add(entry);
return this;
}
|
[
"public",
"EarDescriptorBuilder",
"addWeb",
"(",
"String",
"filename",
",",
"String",
"context",
")",
"{",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
"=",
"new",
"AbstractMap",
".",
"SimpleEntry",
"<",
"String",
",",
"String",
">",
"(",
"filename",
",",
"context",
")",
";",
"this",
".",
"webs",
".",
"add",
"(",
"entry",
")",
";",
"return",
"this",
";",
"}"
] |
Adds WEB module to descriptor.
@param filename name of WAR to add
@param context web context to set for WEB module
@return this object
|
[
"Adds",
"WEB",
"module",
"to",
"descriptor",
"."
] |
train
|
https://github.com/ingwarsw/arquillian-suite-extension/blob/93c9e542ead1d52f45e87b0632bb02ac11f693c8/src/main/java/org/eu/ingwar/tools/arquillian/extension/deployment/EarDescriptorBuilder.java#L81-L85
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/mapreduce/aggregation/Aggregations.java
|
Aggregations.comparableMax
|
public static <Key, Value> Aggregation<Key, Comparable, Comparable> comparableMax() {
"""
Returns an aggregation to find the maximum value of all supplied
{@link java.lang.Comparable} implementing values.<br/>
This aggregation is similar to: <pre>SELECT MAX(value) FROM x</pre>
@param <Key> the input key type
@param <Value> the supplied value type
@return the maximum value over all supplied values
"""
return new AggregationAdapter(new ComparableMaxAggregation<Key, Value>());
}
|
java
|
public static <Key, Value> Aggregation<Key, Comparable, Comparable> comparableMax() {
return new AggregationAdapter(new ComparableMaxAggregation<Key, Value>());
}
|
[
"public",
"static",
"<",
"Key",
",",
"Value",
">",
"Aggregation",
"<",
"Key",
",",
"Comparable",
",",
"Comparable",
">",
"comparableMax",
"(",
")",
"{",
"return",
"new",
"AggregationAdapter",
"(",
"new",
"ComparableMaxAggregation",
"<",
"Key",
",",
"Value",
">",
"(",
")",
")",
";",
"}"
] |
Returns an aggregation to find the maximum value of all supplied
{@link java.lang.Comparable} implementing values.<br/>
This aggregation is similar to: <pre>SELECT MAX(value) FROM x</pre>
@param <Key> the input key type
@param <Value> the supplied value type
@return the maximum value over all supplied values
|
[
"Returns",
"an",
"aggregation",
"to",
"find",
"the",
"maximum",
"value",
"of",
"all",
"supplied",
"{",
"@link",
"java",
".",
"lang",
".",
"Comparable",
"}",
"implementing",
"values",
".",
"<br",
"/",
">",
"This",
"aggregation",
"is",
"similar",
"to",
":",
"<pre",
">",
"SELECT",
"MAX",
"(",
"value",
")",
"FROM",
"x<",
"/",
"pre",
">"
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/mapreduce/aggregation/Aggregations.java#L364-L366
|
podio/podio-java
|
src/main/java/com/podio/item/ItemAPI.java
|
ItemAPI.updateItem
|
public void updateItem(int itemId, ItemUpdate update, boolean silent, boolean hook) {
"""
Updates the entire item. Only fields which have values specified will be
updated. To delete the contents of a field, pass an empty array for the
value.
@param itemId
The id of the item to update
@param update
The data for the update
@param silent
True if the update should be silent, false otherwise
@param hook
True if hooks should be executed for the change, false otherwise
"""
getResourceFactory().getApiResource("/item/" + itemId)
.queryParam("silent", silent ? "1" : "0")
.queryParam("hook", hook ? "1" : "0")
.entity(update, MediaType.APPLICATION_JSON_TYPE).put();
}
|
java
|
public void updateItem(int itemId, ItemUpdate update, boolean silent, boolean hook) {
getResourceFactory().getApiResource("/item/" + itemId)
.queryParam("silent", silent ? "1" : "0")
.queryParam("hook", hook ? "1" : "0")
.entity(update, MediaType.APPLICATION_JSON_TYPE).put();
}
|
[
"public",
"void",
"updateItem",
"(",
"int",
"itemId",
",",
"ItemUpdate",
"update",
",",
"boolean",
"silent",
",",
"boolean",
"hook",
")",
"{",
"getResourceFactory",
"(",
")",
".",
"getApiResource",
"(",
"\"/item/\"",
"+",
"itemId",
")",
".",
"queryParam",
"(",
"\"silent\"",
",",
"silent",
"?",
"\"1\"",
":",
"\"0\"",
")",
".",
"queryParam",
"(",
"\"hook\"",
",",
"hook",
"?",
"\"1\"",
":",
"\"0\"",
")",
".",
"entity",
"(",
"update",
",",
"MediaType",
".",
"APPLICATION_JSON_TYPE",
")",
".",
"put",
"(",
")",
";",
"}"
] |
Updates the entire item. Only fields which have values specified will be
updated. To delete the contents of a field, pass an empty array for the
value.
@param itemId
The id of the item to update
@param update
The data for the update
@param silent
True if the update should be silent, false otherwise
@param hook
True if hooks should be executed for the change, false otherwise
|
[
"Updates",
"the",
"entire",
"item",
".",
"Only",
"fields",
"which",
"have",
"values",
"specified",
"will",
"be",
"updated",
".",
"To",
"delete",
"the",
"contents",
"of",
"a",
"field",
"pass",
"an",
"empty",
"array",
"for",
"the",
"value",
"."
] |
train
|
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/item/ItemAPI.java#L78-L83
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/sun/nio/ch/NativeObject.java
|
NativeObject.putObject
|
void putObject(int offset, NativeObject ob) {
"""
Writes the base address of the given native object at the given offset
of this native object.
@param offset
The offset at which the address is to be written. Note that the
size of an address is implementation-dependent.
@param ob
The native object whose address is to be written
"""
switch (addressSize()) {
case 8:
putLong(offset, ob.address);
break;
case 4:
putInt(offset, (int)(ob.address & 0x00000000FFFFFFFF));
break;
default:
throw new InternalError("Address size not supported");
}
}
|
java
|
void putObject(int offset, NativeObject ob) {
switch (addressSize()) {
case 8:
putLong(offset, ob.address);
break;
case 4:
putInt(offset, (int)(ob.address & 0x00000000FFFFFFFF));
break;
default:
throw new InternalError("Address size not supported");
}
}
|
[
"void",
"putObject",
"(",
"int",
"offset",
",",
"NativeObject",
"ob",
")",
"{",
"switch",
"(",
"addressSize",
"(",
")",
")",
"{",
"case",
"8",
":",
"putLong",
"(",
"offset",
",",
"ob",
".",
"address",
")",
";",
"break",
";",
"case",
"4",
":",
"putInt",
"(",
"offset",
",",
"(",
"int",
")",
"(",
"ob",
".",
"address",
"&",
"0x00000000FFFFFFFF",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"InternalError",
"(",
"\"Address size not supported\"",
")",
";",
"}",
"}"
] |
Writes the base address of the given native object at the given offset
of this native object.
@param offset
The offset at which the address is to be written. Note that the
size of an address is implementation-dependent.
@param ob
The native object whose address is to be written
|
[
"Writes",
"the",
"base",
"address",
"of",
"the",
"given",
"native",
"object",
"at",
"the",
"given",
"offset",
"of",
"this",
"native",
"object",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/nio/ch/NativeObject.java#L150-L161
|
pravega/pravega
|
common/src/main/java/io/pravega/common/util/ToStringUtils.java
|
ToStringUtils.decompressFromBase64
|
@SneakyThrows(IOException.class)
public static String decompressFromBase64(final String base64CompressedString) {
"""
Get the original string from its compressed base64 representation.
@param base64CompressedString Compressed Base64 representation of the string.
@return The original string.
@throws NullPointerException If base64CompressedString is null.
@throws IllegalArgumentException If base64CompressedString is not null, but has a length of zero or if the input is invalid.
"""
Exceptions.checkNotNullOrEmpty(base64CompressedString, "base64CompressedString");
try {
@Cleanup
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(base64CompressedString.getBytes(UTF_8));
@Cleanup
final InputStream base64InputStream = Base64.getDecoder().wrap(byteArrayInputStream);
@Cleanup
final GZIPInputStream gzipInputStream = new GZIPInputStream(base64InputStream);
return IOUtils.toString(gzipInputStream, UTF_8);
} catch (ZipException | EOFException e) { // exceptions thrown for invalid encoding and partial data.
throw new IllegalArgumentException("Invalid base64 input.", e);
}
}
|
java
|
@SneakyThrows(IOException.class)
public static String decompressFromBase64(final String base64CompressedString) {
Exceptions.checkNotNullOrEmpty(base64CompressedString, "base64CompressedString");
try {
@Cleanup
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(base64CompressedString.getBytes(UTF_8));
@Cleanup
final InputStream base64InputStream = Base64.getDecoder().wrap(byteArrayInputStream);
@Cleanup
final GZIPInputStream gzipInputStream = new GZIPInputStream(base64InputStream);
return IOUtils.toString(gzipInputStream, UTF_8);
} catch (ZipException | EOFException e) { // exceptions thrown for invalid encoding and partial data.
throw new IllegalArgumentException("Invalid base64 input.", e);
}
}
|
[
"@",
"SneakyThrows",
"(",
"IOException",
".",
"class",
")",
"public",
"static",
"String",
"decompressFromBase64",
"(",
"final",
"String",
"base64CompressedString",
")",
"{",
"Exceptions",
".",
"checkNotNullOrEmpty",
"(",
"base64CompressedString",
",",
"\"base64CompressedString\"",
")",
";",
"try",
"{",
"@",
"Cleanup",
"final",
"ByteArrayInputStream",
"byteArrayInputStream",
"=",
"new",
"ByteArrayInputStream",
"(",
"base64CompressedString",
".",
"getBytes",
"(",
"UTF_8",
")",
")",
";",
"@",
"Cleanup",
"final",
"InputStream",
"base64InputStream",
"=",
"Base64",
".",
"getDecoder",
"(",
")",
".",
"wrap",
"(",
"byteArrayInputStream",
")",
";",
"@",
"Cleanup",
"final",
"GZIPInputStream",
"gzipInputStream",
"=",
"new",
"GZIPInputStream",
"(",
"base64InputStream",
")",
";",
"return",
"IOUtils",
".",
"toString",
"(",
"gzipInputStream",
",",
"UTF_8",
")",
";",
"}",
"catch",
"(",
"ZipException",
"|",
"EOFException",
"e",
")",
"{",
"// exceptions thrown for invalid encoding and partial data.",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid base64 input.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Get the original string from its compressed base64 representation.
@param base64CompressedString Compressed Base64 representation of the string.
@return The original string.
@throws NullPointerException If base64CompressedString is null.
@throws IllegalArgumentException If base64CompressedString is not null, but has a length of zero or if the input is invalid.
|
[
"Get",
"the",
"original",
"string",
"from",
"its",
"compressed",
"base64",
"representation",
"."
] |
train
|
https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/common/src/main/java/io/pravega/common/util/ToStringUtils.java#L146-L160
|
thorntail/thorntail
|
tools/src/main/java/org/wildfly/swarm/tools/DeclaredDependencies.java
|
DeclaredDependencies.createSpec
|
public static ArtifactSpec createSpec(String gav, String scope) {
"""
Create an instance of {@link ArtifactSpec} from the given GAV coordinates.
@param gav the GAV coordinates for the artifact.
@param scope the scope to be set on the returned instance.
@return an instance of {@link ArtifactSpec} from the given GAV coordinates.
"""
try {
MavenArtifactDescriptor maven = ArtifactSpec.fromMavenGav(gav);
return new ArtifactSpec(
scope,
maven.groupId(),
maven.artifactId(),
maven.version(),
maven.type(),
maven.classifier(),
null
);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
public static ArtifactSpec createSpec(String gav, String scope) {
try {
MavenArtifactDescriptor maven = ArtifactSpec.fromMavenGav(gav);
return new ArtifactSpec(
scope,
maven.groupId(),
maven.artifactId(),
maven.version(),
maven.type(),
maven.classifier(),
null
);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"static",
"ArtifactSpec",
"createSpec",
"(",
"String",
"gav",
",",
"String",
"scope",
")",
"{",
"try",
"{",
"MavenArtifactDescriptor",
"maven",
"=",
"ArtifactSpec",
".",
"fromMavenGav",
"(",
"gav",
")",
";",
"return",
"new",
"ArtifactSpec",
"(",
"scope",
",",
"maven",
".",
"groupId",
"(",
")",
",",
"maven",
".",
"artifactId",
"(",
")",
",",
"maven",
".",
"version",
"(",
")",
",",
"maven",
".",
"type",
"(",
")",
",",
"maven",
".",
"classifier",
"(",
")",
",",
"null",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Create an instance of {@link ArtifactSpec} from the given GAV coordinates.
@param gav the GAV coordinates for the artifact.
@param scope the scope to be set on the returned instance.
@return an instance of {@link ArtifactSpec} from the given GAV coordinates.
|
[
"Create",
"an",
"instance",
"of",
"{",
"@link",
"ArtifactSpec",
"}",
"from",
"the",
"given",
"GAV",
"coordinates",
"."
] |
train
|
https://github.com/thorntail/thorntail/blob/4a391b68ffae98c6e66d30a3bfb99dadc9509f14/tools/src/main/java/org/wildfly/swarm/tools/DeclaredDependencies.java#L211-L228
|
Jasig/uPortal
|
uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/groups/RDBMEntityGroupStore.java
|
RDBMEntityGroupStore.findParentGroups
|
public java.util.Iterator findParentGroups(IEntity ent) throws GroupsException {
"""
Find the groups that this entity belongs to.
@param ent the entity in question
@return java.util.Iterator
"""
String memberKey = ent.getKey();
Integer type = EntityTypesLocator.getEntityTypes().getEntityIDFromType(ent.getLeafType());
return findParentGroupsForEntity(memberKey, type.intValue());
}
|
java
|
public java.util.Iterator findParentGroups(IEntity ent) throws GroupsException {
String memberKey = ent.getKey();
Integer type = EntityTypesLocator.getEntityTypes().getEntityIDFromType(ent.getLeafType());
return findParentGroupsForEntity(memberKey, type.intValue());
}
|
[
"public",
"java",
".",
"util",
".",
"Iterator",
"findParentGroups",
"(",
"IEntity",
"ent",
")",
"throws",
"GroupsException",
"{",
"String",
"memberKey",
"=",
"ent",
".",
"getKey",
"(",
")",
";",
"Integer",
"type",
"=",
"EntityTypesLocator",
".",
"getEntityTypes",
"(",
")",
".",
"getEntityIDFromType",
"(",
"ent",
".",
"getLeafType",
"(",
")",
")",
";",
"return",
"findParentGroupsForEntity",
"(",
"memberKey",
",",
"type",
".",
"intValue",
"(",
")",
")",
";",
"}"
] |
Find the groups that this entity belongs to.
@param ent the entity in question
@return java.util.Iterator
|
[
"Find",
"the",
"groups",
"that",
"this",
"entity",
"belongs",
"to",
"."
] |
train
|
https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-groups/uPortal-groups-core/src/main/java/org/apereo/portal/groups/RDBMEntityGroupStore.java#L298-L302
|
killbilling/recurly-java-library
|
src/main/java/com/ning/billing/recurly/RecurlyClient.java
|
RecurlyClient.getAccountAcquisition
|
public AccountAcquisition getAccountAcquisition(final String accountCode) {
"""
Gets the acquisition details for an account
<p>
https://dev.recurly.com/docs/create-account-acquisition
@param accountCode The account's account code
@return The created AccountAcquisition object
"""
final String path = Account.ACCOUNT_RESOURCE + "/" + accountCode + AccountAcquisition.ACCOUNT_ACQUISITION_RESOURCE;
return doGET(path, AccountAcquisition.class);
}
|
java
|
public AccountAcquisition getAccountAcquisition(final String accountCode) {
final String path = Account.ACCOUNT_RESOURCE + "/" + accountCode + AccountAcquisition.ACCOUNT_ACQUISITION_RESOURCE;
return doGET(path, AccountAcquisition.class);
}
|
[
"public",
"AccountAcquisition",
"getAccountAcquisition",
"(",
"final",
"String",
"accountCode",
")",
"{",
"final",
"String",
"path",
"=",
"Account",
".",
"ACCOUNT_RESOURCE",
"+",
"\"/\"",
"+",
"accountCode",
"+",
"AccountAcquisition",
".",
"ACCOUNT_ACQUISITION_RESOURCE",
";",
"return",
"doGET",
"(",
"path",
",",
"AccountAcquisition",
".",
"class",
")",
";",
"}"
] |
Gets the acquisition details for an account
<p>
https://dev.recurly.com/docs/create-account-acquisition
@param accountCode The account's account code
@return The created AccountAcquisition object
|
[
"Gets",
"the",
"acquisition",
"details",
"for",
"an",
"account",
"<p",
">",
"https",
":",
"//",
"dev",
".",
"recurly",
".",
"com",
"/",
"docs",
"/",
"create",
"-",
"account",
"-",
"acquisition"
] |
train
|
https://github.com/killbilling/recurly-java-library/blob/5e05eedd91885a51e1aa8293bd41139d082cf7f4/src/main/java/com/ning/billing/recurly/RecurlyClient.java#L1974-L1977
|
khuxtable/seaglass
|
src/main/java/com/seaglasslookandfeel/SeaGlassLookAndFeel.java
|
SeaGlassLookAndFeel.defineRootPanes
|
private void defineRootPanes(UIDefaults d) {
"""
Initialize the root pane settings.
@param d the UI defaults map.
"""
String c = PAINTER_PREFIX + "FrameAndRootPainter";
String p = "RootPane";
d.put(p + ".States", "Enabled,WindowFocused,NoFrame");
d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
d.put(p + ".opaque", Boolean.FALSE);
d.put(p + ".NoFrame", new RootPaneNoFrameState());
d.put(p + ".WindowFocused", new RootPaneWindowFocusedState());
d.put(p + "[Enabled+NoFrame].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED_NOFRAME));
d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED));
d.put(p + "[Enabled+WindowFocused].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED_WINDOWFOCUSED));
}
|
java
|
private void defineRootPanes(UIDefaults d) {
String c = PAINTER_PREFIX + "FrameAndRootPainter";
String p = "RootPane";
d.put(p + ".States", "Enabled,WindowFocused,NoFrame");
d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
d.put(p + ".opaque", Boolean.FALSE);
d.put(p + ".NoFrame", new RootPaneNoFrameState());
d.put(p + ".WindowFocused", new RootPaneWindowFocusedState());
d.put(p + "[Enabled+NoFrame].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED_NOFRAME));
d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED));
d.put(p + "[Enabled+WindowFocused].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED_WINDOWFOCUSED));
}
|
[
"private",
"void",
"defineRootPanes",
"(",
"UIDefaults",
"d",
")",
"{",
"String",
"c",
"=",
"PAINTER_PREFIX",
"+",
"\"FrameAndRootPainter\"",
";",
"String",
"p",
"=",
"\"RootPane\"",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".States\"",
",",
"\"Enabled,WindowFocused,NoFrame\"",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".contentMargins\"",
",",
"new",
"InsetsUIResource",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".opaque\"",
",",
"Boolean",
".",
"FALSE",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".NoFrame\"",
",",
"new",
"RootPaneNoFrameState",
"(",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".WindowFocused\"",
",",
"new",
"RootPaneWindowFocusedState",
"(",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Enabled+NoFrame].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"FrameAndRootPainter",
".",
"Which",
".",
"BACKGROUND_ENABLED_NOFRAME",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Enabled].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"FrameAndRootPainter",
".",
"Which",
".",
"BACKGROUND_ENABLED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Enabled+WindowFocused].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"FrameAndRootPainter",
".",
"Which",
".",
"BACKGROUND_ENABLED_WINDOWFOCUSED",
")",
")",
";",
"}"
] |
Initialize the root pane settings.
@param d the UI defaults map.
|
[
"Initialize",
"the",
"root",
"pane",
"settings",
"."
] |
train
|
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/SeaGlassLookAndFeel.java#L1651-L1664
|
httl/httl
|
httl/src/main/java/httl/Engine.java
|
Engine.initProperties
|
@SuppressWarnings( {
"""
/*
Mode and System Configuration
@author Li Ding (oldratlee AT gmail DOT com)
""""unchecked", "rawtypes"})
private static Properties initProperties(String configPath, Properties configProperties) {
Map<String, String> systemProperties = ConfigUtils.filterWithPrefix(HTTL_KEY_PREFIX, (Map) System.getProperties(), false);
Map<String, String> systemEnv = ConfigUtils.filterWithPrefix(HTTL_KEY_PREFIX, System.getenv(), true);
Properties properties = ConfigUtils.mergeProperties(HTTL_DEFAULT_PROPERTIES, configPath, configProperties, systemProperties, systemEnv);
String[] modes = StringUtils.splitByComma(properties.getProperty(MODES_KEY));
if (CollectionUtils.isNotEmpty(modes)) {
Object[] configs = new Object[modes.length + 5];
configs[0] = HTTL_DEFAULT_PROPERTIES;
for (int i = 0; i < modes.length; i++) {
configs[i + 1] = HTTL_PREFIX + modes[i] + PROPERTIES_SUFFIX;
}
configs[modes.length + 1] = configPath;
configs[modes.length + 2] = configProperties;
configs[modes.length + 3] = systemProperties;
configs[modes.length + 4] = systemEnv;
properties = ConfigUtils.mergeProperties(configs);
}
properties.setProperty(ENGINE_NAME, configPath);
return properties;
}
|
java
|
@SuppressWarnings({"unchecked", "rawtypes"})
private static Properties initProperties(String configPath, Properties configProperties) {
Map<String, String> systemProperties = ConfigUtils.filterWithPrefix(HTTL_KEY_PREFIX, (Map) System.getProperties(), false);
Map<String, String> systemEnv = ConfigUtils.filterWithPrefix(HTTL_KEY_PREFIX, System.getenv(), true);
Properties properties = ConfigUtils.mergeProperties(HTTL_DEFAULT_PROPERTIES, configPath, configProperties, systemProperties, systemEnv);
String[] modes = StringUtils.splitByComma(properties.getProperty(MODES_KEY));
if (CollectionUtils.isNotEmpty(modes)) {
Object[] configs = new Object[modes.length + 5];
configs[0] = HTTL_DEFAULT_PROPERTIES;
for (int i = 0; i < modes.length; i++) {
configs[i + 1] = HTTL_PREFIX + modes[i] + PROPERTIES_SUFFIX;
}
configs[modes.length + 1] = configPath;
configs[modes.length + 2] = configProperties;
configs[modes.length + 3] = systemProperties;
configs[modes.length + 4] = systemEnv;
properties = ConfigUtils.mergeProperties(configs);
}
properties.setProperty(ENGINE_NAME, configPath);
return properties;
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"private",
"static",
"Properties",
"initProperties",
"(",
"String",
"configPath",
",",
"Properties",
"configProperties",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"systemProperties",
"=",
"ConfigUtils",
".",
"filterWithPrefix",
"(",
"HTTL_KEY_PREFIX",
",",
"(",
"Map",
")",
"System",
".",
"getProperties",
"(",
")",
",",
"false",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"systemEnv",
"=",
"ConfigUtils",
".",
"filterWithPrefix",
"(",
"HTTL_KEY_PREFIX",
",",
"System",
".",
"getenv",
"(",
")",
",",
"true",
")",
";",
"Properties",
"properties",
"=",
"ConfigUtils",
".",
"mergeProperties",
"(",
"HTTL_DEFAULT_PROPERTIES",
",",
"configPath",
",",
"configProperties",
",",
"systemProperties",
",",
"systemEnv",
")",
";",
"String",
"[",
"]",
"modes",
"=",
"StringUtils",
".",
"splitByComma",
"(",
"properties",
".",
"getProperty",
"(",
"MODES_KEY",
")",
")",
";",
"if",
"(",
"CollectionUtils",
".",
"isNotEmpty",
"(",
"modes",
")",
")",
"{",
"Object",
"[",
"]",
"configs",
"=",
"new",
"Object",
"[",
"modes",
".",
"length",
"+",
"5",
"]",
";",
"configs",
"[",
"0",
"]",
"=",
"HTTL_DEFAULT_PROPERTIES",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"modes",
".",
"length",
";",
"i",
"++",
")",
"{",
"configs",
"[",
"i",
"+",
"1",
"]",
"=",
"HTTL_PREFIX",
"+",
"modes",
"[",
"i",
"]",
"+",
"PROPERTIES_SUFFIX",
";",
"}",
"configs",
"[",
"modes",
".",
"length",
"+",
"1",
"]",
"=",
"configPath",
";",
"configs",
"[",
"modes",
".",
"length",
"+",
"2",
"]",
"=",
"configProperties",
";",
"configs",
"[",
"modes",
".",
"length",
"+",
"3",
"]",
"=",
"systemProperties",
";",
"configs",
"[",
"modes",
".",
"length",
"+",
"4",
"]",
"=",
"systemEnv",
";",
"properties",
"=",
"ConfigUtils",
".",
"mergeProperties",
"(",
"configs",
")",
";",
"}",
"properties",
".",
"setProperty",
"(",
"ENGINE_NAME",
",",
"configPath",
")",
";",
"return",
"properties",
";",
"}"
] |
/*
Mode and System Configuration
@author Li Ding (oldratlee AT gmail DOT com)
|
[
"/",
"*",
"Mode",
"and",
"System",
"Configuration"
] |
train
|
https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Engine.java#L137-L157
|
netscaler/nitro
|
src/main/java/com/citrix/netscaler/nitro/resource/config/appfw/appfwpolicylabel.java
|
appfwpolicylabel.get
|
public static appfwpolicylabel get(nitro_service service, String labelname) throws Exception {
"""
Use this API to fetch appfwpolicylabel resource of given name .
"""
appfwpolicylabel obj = new appfwpolicylabel();
obj.set_labelname(labelname);
appfwpolicylabel response = (appfwpolicylabel) obj.get_resource(service);
return response;
}
|
java
|
public static appfwpolicylabel get(nitro_service service, String labelname) throws Exception{
appfwpolicylabel obj = new appfwpolicylabel();
obj.set_labelname(labelname);
appfwpolicylabel response = (appfwpolicylabel) obj.get_resource(service);
return response;
}
|
[
"public",
"static",
"appfwpolicylabel",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"labelname",
")",
"throws",
"Exception",
"{",
"appfwpolicylabel",
"obj",
"=",
"new",
"appfwpolicylabel",
"(",
")",
";",
"obj",
".",
"set_labelname",
"(",
"labelname",
")",
";",
"appfwpolicylabel",
"response",
"=",
"(",
"appfwpolicylabel",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] |
Use this API to fetch appfwpolicylabel resource of given name .
|
[
"Use",
"this",
"API",
"to",
"fetch",
"appfwpolicylabel",
"resource",
"of",
"given",
"name",
"."
] |
train
|
https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/appfw/appfwpolicylabel.java#L333-L338
|
cternes/openkeepass
|
src/main/java/de/slackspace/openkeepass/KeePassDatabase.java
|
KeePassDatabase.openDatabase
|
public KeePassFile openDatabase(String password, File keyFile) {
"""
Opens a KeePass database with the given password and keyfile and returns
the KeePassFile for further processing.
<p>
If the database cannot be decrypted with the provided password and
keyfile an exception will be thrown.
@param password
the password to open the database
@param keyFile
the password to open the database
@return a KeePassFile
@see KeePassFile
"""
if (password == null) {
throw new IllegalArgumentException(MSG_EMPTY_MASTER_KEY);
}
if (keyFile == null) {
throw new IllegalArgumentException("You must provide a valid KeePass keyfile.");
}
InputStream inputStream = null;
try {
inputStream = new FileInputStream(keyFile);
return openDatabase(password, inputStream);
} catch (FileNotFoundException e) {
throw new IllegalArgumentException("The KeePass keyfile could not be found. You must provide a valid KeePass keyfile.", e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// Ignore
}
}
}
}
|
java
|
public KeePassFile openDatabase(String password, File keyFile) {
if (password == null) {
throw new IllegalArgumentException(MSG_EMPTY_MASTER_KEY);
}
if (keyFile == null) {
throw new IllegalArgumentException("You must provide a valid KeePass keyfile.");
}
InputStream inputStream = null;
try {
inputStream = new FileInputStream(keyFile);
return openDatabase(password, inputStream);
} catch (FileNotFoundException e) {
throw new IllegalArgumentException("The KeePass keyfile could not be found. You must provide a valid KeePass keyfile.", e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// Ignore
}
}
}
}
|
[
"public",
"KeePassFile",
"openDatabase",
"(",
"String",
"password",
",",
"File",
"keyFile",
")",
"{",
"if",
"(",
"password",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"MSG_EMPTY_MASTER_KEY",
")",
";",
"}",
"if",
"(",
"keyFile",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"You must provide a valid KeePass keyfile.\"",
")",
";",
"}",
"InputStream",
"inputStream",
"=",
"null",
";",
"try",
"{",
"inputStream",
"=",
"new",
"FileInputStream",
"(",
"keyFile",
")",
";",
"return",
"openDatabase",
"(",
"password",
",",
"inputStream",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The KeePass keyfile could not be found. You must provide a valid KeePass keyfile.\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"inputStream",
"!=",
"null",
")",
"{",
"try",
"{",
"inputStream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// Ignore\r",
"}",
"}",
"}",
"}"
] |
Opens a KeePass database with the given password and keyfile and returns
the KeePassFile for further processing.
<p>
If the database cannot be decrypted with the provided password and
keyfile an exception will be thrown.
@param password
the password to open the database
@param keyFile
the password to open the database
@return a KeePassFile
@see KeePassFile
|
[
"Opens",
"a",
"KeePass",
"database",
"with",
"the",
"given",
"password",
"and",
"keyfile",
"and",
"returns",
"the",
"KeePassFile",
"for",
"further",
"processing",
".",
"<p",
">",
"If",
"the",
"database",
"cannot",
"be",
"decrypted",
"with",
"the",
"provided",
"password",
"and",
"keyfile",
"an",
"exception",
"will",
"be",
"thrown",
"."
] |
train
|
https://github.com/cternes/openkeepass/blob/4a354aecaea38af3c0dce5eb81b533f297e8d94f/src/main/java/de/slackspace/openkeepass/KeePassDatabase.java#L185-L209
|
qiniu/java-sdk
|
src/main/java/com/qiniu/storage/BucketManager.java
|
BucketManager.createFileListIterator
|
public FileListIterator createFileListIterator(String bucket, String prefix, int limit, String delimiter) {
"""
根据前缀获取文件列表的迭代器
@param bucket 空间名
@param prefix 文件名前缀
@param limit 每次迭代的长度限制,最大1000,推荐值 100
@param delimiter 指定目录分隔符,列出所有公共前缀(模拟列出目录效果)。缺省值为空字符串
@return FileInfo迭代器
"""
return new FileListIterator(bucket, prefix, limit, delimiter);
}
|
java
|
public FileListIterator createFileListIterator(String bucket, String prefix, int limit, String delimiter) {
return new FileListIterator(bucket, prefix, limit, delimiter);
}
|
[
"public",
"FileListIterator",
"createFileListIterator",
"(",
"String",
"bucket",
",",
"String",
"prefix",
",",
"int",
"limit",
",",
"String",
"delimiter",
")",
"{",
"return",
"new",
"FileListIterator",
"(",
"bucket",
",",
"prefix",
",",
"limit",
",",
"delimiter",
")",
";",
"}"
] |
根据前缀获取文件列表的迭代器
@param bucket 空间名
@param prefix 文件名前缀
@param limit 每次迭代的长度限制,最大1000,推荐值 100
@param delimiter 指定目录分隔符,列出所有公共前缀(模拟列出目录效果)。缺省值为空字符串
@return FileInfo迭代器
|
[
"根据前缀获取文件列表的迭代器"
] |
train
|
https://github.com/qiniu/java-sdk/blob/6c05f3fb718403a496c725b048e9241f80171499/src/main/java/com/qiniu/storage/BucketManager.java#L149-L151
|
javagl/ND
|
nd-tuples/src/main/java/de/javagl/nd/tuples/j/LongTuples.java
|
LongTuples.of
|
public static MutableLongTuple of(long x, long y, long z, long w) {
"""
Creates a new {@link MutableLongTuple} with the given values.
@param x The x coordinate
@param y The y coordinate
@param z The z coordinate
@param w The w coordinate
@return The new tuple
"""
return new DefaultLongTuple(new long[]{ x, y, z, w });
}
|
java
|
public static MutableLongTuple of(long x, long y, long z, long w)
{
return new DefaultLongTuple(new long[]{ x, y, z, w });
}
|
[
"public",
"static",
"MutableLongTuple",
"of",
"(",
"long",
"x",
",",
"long",
"y",
",",
"long",
"z",
",",
"long",
"w",
")",
"{",
"return",
"new",
"DefaultLongTuple",
"(",
"new",
"long",
"[",
"]",
"{",
"x",
",",
"y",
",",
"z",
",",
"w",
"}",
")",
";",
"}"
] |
Creates a new {@link MutableLongTuple} with the given values.
@param x The x coordinate
@param y The y coordinate
@param z The z coordinate
@param w The w coordinate
@return The new tuple
|
[
"Creates",
"a",
"new",
"{",
"@link",
"MutableLongTuple",
"}",
"with",
"the",
"given",
"values",
"."
] |
train
|
https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-tuples/src/main/java/de/javagl/nd/tuples/j/LongTuples.java#L1510-L1513
|
shrinkwrap/resolver
|
maven/api-maven/src/main/java/org/jboss/shrinkwrap/resolver/api/maven/repository/MavenRemoteRepositories.java
|
MavenRemoteRepositories.createRemoteRepository
|
public static MavenRemoteRepository createRemoteRepository(final String id, final String url, final String layout)
throws IllegalArgumentException {
"""
Overload of {@link #createRemoteRepository(String, URL, String)} that thrown an exception if URL is wrong.
@param id The unique ID of the repository to create (arbitrary name)
@param url The base URL of the Maven repository
@param layout he repository layout. Should always be "default"
@return A new <code>MavenRemoteRepository</code> with the given ID and URL.
@throws IllegalArgumentException for null or empty id or if the URL is technically wrong or null
"""
try {
return createRemoteRepository(id, new URL(url), layout);
}
catch (MalformedURLException e) {
throw new IllegalArgumentException("invalid URL", e);
}
}
|
java
|
public static MavenRemoteRepository createRemoteRepository(final String id, final String url, final String layout)
throws IllegalArgumentException {
try {
return createRemoteRepository(id, new URL(url), layout);
}
catch (MalformedURLException e) {
throw new IllegalArgumentException("invalid URL", e);
}
}
|
[
"public",
"static",
"MavenRemoteRepository",
"createRemoteRepository",
"(",
"final",
"String",
"id",
",",
"final",
"String",
"url",
",",
"final",
"String",
"layout",
")",
"throws",
"IllegalArgumentException",
"{",
"try",
"{",
"return",
"createRemoteRepository",
"(",
"id",
",",
"new",
"URL",
"(",
"url",
")",
",",
"layout",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid URL\"",
",",
"e",
")",
";",
"}",
"}"
] |
Overload of {@link #createRemoteRepository(String, URL, String)} that thrown an exception if URL is wrong.
@param id The unique ID of the repository to create (arbitrary name)
@param url The base URL of the Maven repository
@param layout he repository layout. Should always be "default"
@return A new <code>MavenRemoteRepository</code> with the given ID and URL.
@throws IllegalArgumentException for null or empty id or if the URL is technically wrong or null
|
[
"Overload",
"of",
"{",
"@link",
"#createRemoteRepository",
"(",
"String",
"URL",
"String",
")",
"}",
"that",
"thrown",
"an",
"exception",
"if",
"URL",
"is",
"wrong",
"."
] |
train
|
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/api-maven/src/main/java/org/jboss/shrinkwrap/resolver/api/maven/repository/MavenRemoteRepositories.java#L39-L47
|
ops4j/org.ops4j.base
|
ops4j-base-util-xml/src/main/java/org/ops4j/util/xml/ElementHelper.java
|
ElementHelper.getRootElement
|
public static Element getRootElement( InputStream input )
throws ParserConfigurationException, IOException, SAXException {
"""
Return the root element of the supplied input stream.
@param input the input stream containing a XML definition
@return the root element
@throws IOException If an underlying I/O problem occurred.
@throws ParserConfigurationException if there is a severe problem in the XML parsing subsystem.
@throws SAXException If the XML is malformed in some way.
"""
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating( false );
factory.setNamespaceAware( false );
try
{
factory.setFeature( "http://xml.org/sax/features/namespaces", false );
factory.setFeature( "http://xml.org/sax/features/validation", false );
factory.setFeature( "http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false );
factory.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false );
}
catch( Throwable ignore )
{
// ignore. we did our best.
}
DocumentBuilder builder = factory.newDocumentBuilder();
try
{
// return an empty entity resolver if parser will ask for it, such disabling any validation
builder.setEntityResolver(
new EntityResolver()
{
public InputSource resolveEntity( java.lang.String publicId, java.lang.String systemId )
throws SAXException, java.io.IOException
{
return new InputSource(
new ByteArrayInputStream( "<?xml version='1.0' encoding='UTF-8'?>".getBytes() )
);
}
}
);
}
catch( Throwable ignore )
{
// ignore. we did our best.
}
Document document = builder.parse( input );
return document.getDocumentElement();
}
|
java
|
public static Element getRootElement( InputStream input )
throws ParserConfigurationException, IOException, SAXException
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating( false );
factory.setNamespaceAware( false );
try
{
factory.setFeature( "http://xml.org/sax/features/namespaces", false );
factory.setFeature( "http://xml.org/sax/features/validation", false );
factory.setFeature( "http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false );
factory.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false );
}
catch( Throwable ignore )
{
// ignore. we did our best.
}
DocumentBuilder builder = factory.newDocumentBuilder();
try
{
// return an empty entity resolver if parser will ask for it, such disabling any validation
builder.setEntityResolver(
new EntityResolver()
{
public InputSource resolveEntity( java.lang.String publicId, java.lang.String systemId )
throws SAXException, java.io.IOException
{
return new InputSource(
new ByteArrayInputStream( "<?xml version='1.0' encoding='UTF-8'?>".getBytes() )
);
}
}
);
}
catch( Throwable ignore )
{
// ignore. we did our best.
}
Document document = builder.parse( input );
return document.getDocumentElement();
}
|
[
"public",
"static",
"Element",
"getRootElement",
"(",
"InputStream",
"input",
")",
"throws",
"ParserConfigurationException",
",",
"IOException",
",",
"SAXException",
"{",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"factory",
".",
"setValidating",
"(",
"false",
")",
";",
"factory",
".",
"setNamespaceAware",
"(",
"false",
")",
";",
"try",
"{",
"factory",
".",
"setFeature",
"(",
"\"http://xml.org/sax/features/namespaces\"",
",",
"false",
")",
";",
"factory",
".",
"setFeature",
"(",
"\"http://xml.org/sax/features/validation\"",
",",
"false",
")",
";",
"factory",
".",
"setFeature",
"(",
"\"http://apache.org/xml/features/nonvalidating/load-dtd-grammar\"",
",",
"false",
")",
";",
"factory",
".",
"setFeature",
"(",
"\"http://apache.org/xml/features/nonvalidating/load-external-dtd\"",
",",
"false",
")",
";",
"}",
"catch",
"(",
"Throwable",
"ignore",
")",
"{",
"// ignore. we did our best.",
"}",
"DocumentBuilder",
"builder",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
";",
"try",
"{",
"// return an empty entity resolver if parser will ask for it, such disabling any validation ",
"builder",
".",
"setEntityResolver",
"(",
"new",
"EntityResolver",
"(",
")",
"{",
"public",
"InputSource",
"resolveEntity",
"(",
"java",
".",
"lang",
".",
"String",
"publicId",
",",
"java",
".",
"lang",
".",
"String",
"systemId",
")",
"throws",
"SAXException",
",",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"new",
"InputSource",
"(",
"new",
"ByteArrayInputStream",
"(",
"\"<?xml version='1.0' encoding='UTF-8'?>\"",
".",
"getBytes",
"(",
")",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Throwable",
"ignore",
")",
"{",
"// ignore. we did our best.",
"}",
"Document",
"document",
"=",
"builder",
".",
"parse",
"(",
"input",
")",
";",
"return",
"document",
".",
"getDocumentElement",
"(",
")",
";",
"}"
] |
Return the root element of the supplied input stream.
@param input the input stream containing a XML definition
@return the root element
@throws IOException If an underlying I/O problem occurred.
@throws ParserConfigurationException if there is a severe problem in the XML parsing subsystem.
@throws SAXException If the XML is malformed in some way.
|
[
"Return",
"the",
"root",
"element",
"of",
"the",
"supplied",
"input",
"stream",
"."
] |
train
|
https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-util-xml/src/main/java/org/ops4j/util/xml/ElementHelper.java#L65-L105
|
Azure/azure-sdk-for-java
|
kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/EventHubConnectionsInner.java
|
EventHubConnectionsInner.eventhubConnectionValidation
|
public EventHubConnectionValidationListResultInner eventhubConnectionValidation(String resourceGroupName, String clusterName, String databaseName, EventHubConnectionValidation parameters) {
"""
Checks that the Event Hub data connection parameters are valid.
@param resourceGroupName The name of the resource group containing the Kusto cluster.
@param clusterName The name of the Kusto cluster.
@param databaseName The name of the database in the Kusto cluster.
@param parameters The Event Hub connection parameters supplied to the CreateOrUpdate 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 EventHubConnectionValidationListResultInner object if successful.
"""
return eventhubConnectionValidationWithServiceResponseAsync(resourceGroupName, clusterName, databaseName, parameters).toBlocking().single().body();
}
|
java
|
public EventHubConnectionValidationListResultInner eventhubConnectionValidation(String resourceGroupName, String clusterName, String databaseName, EventHubConnectionValidation parameters) {
return eventhubConnectionValidationWithServiceResponseAsync(resourceGroupName, clusterName, databaseName, parameters).toBlocking().single().body();
}
|
[
"public",
"EventHubConnectionValidationListResultInner",
"eventhubConnectionValidation",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
",",
"String",
"databaseName",
",",
"EventHubConnectionValidation",
"parameters",
")",
"{",
"return",
"eventhubConnectionValidationWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
",",
"databaseName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Checks that the Event Hub data connection parameters are valid.
@param resourceGroupName The name of the resource group containing the Kusto cluster.
@param clusterName The name of the Kusto cluster.
@param databaseName The name of the database in the Kusto cluster.
@param parameters The Event Hub connection parameters supplied to the CreateOrUpdate 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 EventHubConnectionValidationListResultInner object if successful.
|
[
"Checks",
"that",
"the",
"Event",
"Hub",
"data",
"connection",
"parameters",
"are",
"valid",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/kusto/resource-manager/v2018_09_07_preview/src/main/java/com/microsoft/azure/management/kusto/v2018_09_07_preview/implementation/EventHubConnectionsInner.java#L211-L213
|
op4j/op4j
|
src/main/java/org/op4j/functions/Call.java
|
Call.listOfString
|
public static Function<Object,List<String>> listOfString(final String methodName, final Object... optionalParameters) {
"""
<p>
Abbreviation for {{@link #methodForListOfString(String, Object...)}.
</p>
@since 1.1
@param methodName the name of the method
@param optionalParameters the (optional) parameters of the method.
@return the result of the method execution
"""
return methodForListOfString(methodName, optionalParameters);
}
|
java
|
public static Function<Object,List<String>> listOfString(final String methodName, final Object... optionalParameters) {
return methodForListOfString(methodName, optionalParameters);
}
|
[
"public",
"static",
"Function",
"<",
"Object",
",",
"List",
"<",
"String",
">",
">",
"listOfString",
"(",
"final",
"String",
"methodName",
",",
"final",
"Object",
"...",
"optionalParameters",
")",
"{",
"return",
"methodForListOfString",
"(",
"methodName",
",",
"optionalParameters",
")",
";",
"}"
] |
<p>
Abbreviation for {{@link #methodForListOfString(String, Object...)}.
</p>
@since 1.1
@param methodName the name of the method
@param optionalParameters the (optional) parameters of the method.
@return the result of the method execution
|
[
"<p",
">",
"Abbreviation",
"for",
"{{",
"@link",
"#methodForListOfString",
"(",
"String",
"Object",
"...",
")",
"}",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/op4j/op4j/blob/b577596dfe462089d3dd169666defc6de7ad289a/src/main/java/org/op4j/functions/Call.java#L550-L552
|
Azure/azure-sdk-for-java
|
batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/WorkspacesInner.java
|
WorkspacesInner.createAsync
|
public Observable<WorkspaceInner> createAsync(String resourceGroupName, String workspaceName, WorkspaceCreateParameters parameters) {
"""
Creates a Workspace.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param parameters Workspace creation parameters.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createWithServiceResponseAsync(resourceGroupName, workspaceName, parameters).map(new Func1<ServiceResponse<WorkspaceInner>, WorkspaceInner>() {
@Override
public WorkspaceInner call(ServiceResponse<WorkspaceInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<WorkspaceInner> createAsync(String resourceGroupName, String workspaceName, WorkspaceCreateParameters parameters) {
return createWithServiceResponseAsync(resourceGroupName, workspaceName, parameters).map(new Func1<ServiceResponse<WorkspaceInner>, WorkspaceInner>() {
@Override
public WorkspaceInner call(ServiceResponse<WorkspaceInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"WorkspaceInner",
">",
"createAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"workspaceName",
",",
"WorkspaceCreateParameters",
"parameters",
")",
"{",
"return",
"createWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"workspaceName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"WorkspaceInner",
">",
",",
"WorkspaceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"WorkspaceInner",
"call",
"(",
"ServiceResponse",
"<",
"WorkspaceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates a Workspace.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param parameters Workspace creation parameters.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
|
[
"Creates",
"a",
"Workspace",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/WorkspacesInner.java#L600-L607
|
Mangopay/mangopay2-java-sdk
|
src/main/java/com/mangopay/core/APIs/ApiBase.java
|
ApiBase.updateObject
|
protected <T extends Dto> T updateObject(Class<T> classOfT, String methodKey, T entity) throws Exception {
"""
Saves the Dto instance.
@param <T> Type on behalf of which the request is being called.
@param classOfT Type on behalf of which the request is being called.
@param methodKey Relevant method key.
@param entity Dto instance that is going to be sent.
@return The Dto instance returned from API.
@throws Exception
"""
return updateObject(classOfT, methodKey, entity, "", "");
}
|
java
|
protected <T extends Dto> T updateObject(Class<T> classOfT, String methodKey, T entity) throws Exception {
return updateObject(classOfT, methodKey, entity, "", "");
}
|
[
"protected",
"<",
"T",
"extends",
"Dto",
">",
"T",
"updateObject",
"(",
"Class",
"<",
"T",
">",
"classOfT",
",",
"String",
"methodKey",
",",
"T",
"entity",
")",
"throws",
"Exception",
"{",
"return",
"updateObject",
"(",
"classOfT",
",",
"methodKey",
",",
"entity",
",",
"\"\"",
",",
"\"\"",
")",
";",
"}"
] |
Saves the Dto instance.
@param <T> Type on behalf of which the request is being called.
@param classOfT Type on behalf of which the request is being called.
@param methodKey Relevant method key.
@param entity Dto instance that is going to be sent.
@return The Dto instance returned from API.
@throws Exception
|
[
"Saves",
"the",
"Dto",
"instance",
"."
] |
train
|
https://github.com/Mangopay/mangopay2-java-sdk/blob/037cecb44ea62def63b507817fd9961649151157/src/main/java/com/mangopay/core/APIs/ApiBase.java#L422-L424
|
morimekta/providence
|
providence-core/src/main/java/net/morimekta/providence/util/BaseTypeRegistry.java
|
BaseTypeRegistry.qualifiedNameFromIdAndContext
|
protected static String qualifiedNameFromIdAndContext(String name, String context) {
"""
Make a qualified type name from a name identifier string and the program context.
@param name The type name.
@param context The program context.
@return The qualified name containing program name and type name.
"""
if (!name.contains(".")) {
return context + "." + name;
}
return name;
}
|
java
|
protected static String qualifiedNameFromIdAndContext(String name, String context) {
if (!name.contains(".")) {
return context + "." + name;
}
return name;
}
|
[
"protected",
"static",
"String",
"qualifiedNameFromIdAndContext",
"(",
"String",
"name",
",",
"String",
"context",
")",
"{",
"if",
"(",
"!",
"name",
".",
"contains",
"(",
"\".\"",
")",
")",
"{",
"return",
"context",
"+",
"\".\"",
"+",
"name",
";",
"}",
"return",
"name",
";",
"}"
] |
Make a qualified type name from a name identifier string and the program context.
@param name The type name.
@param context The program context.
@return The qualified name containing program name and type name.
|
[
"Make",
"a",
"qualified",
"type",
"name",
"from",
"a",
"name",
"identifier",
"string",
"and",
"the",
"program",
"context",
"."
] |
train
|
https://github.com/morimekta/providence/blob/7c17dc1c96b1a1d4b9ff942c2cfeb725278bd3aa/providence-core/src/main/java/net/morimekta/providence/util/BaseTypeRegistry.java#L183-L188
|
indeedeng/proctor
|
proctor-consumer/src/main/java/com/indeed/proctor/consumer/AbstractGroupsManager.java
|
AbstractGroupsManager.determineBucketsInternal
|
@VisibleForTesting
protected ProctorResult determineBucketsInternal(final Identifiers identifiers, final Map<String, Object> context, final Map<String, Integer> forcedGroups) {
"""
I don't see any value in using this in an application; you probably should use
{@link #determineBucketsInternal(HttpServletRequest, HttpServletResponse, Identifiers, Map, boolean)}
@param identifiers a {@link Map} of unique-ish {@link String}s describing the request in the context of different {@link TestType}s.For example,
{@link TestType#USER} has a CTK associated, {@link TestType#EMAIL} is an email address, {@link TestType#PAGE} might be a url-encoded String
containing the normalized relevant page parameters
@param context a {@link Map} containing variables describing the context in which the request is executing. These will be supplied to any rules that
execute to determine test eligibility.
@param forcedGroups a {@link Map} from a String test name to an Integer bucket value. For the specified test allocate the specified bucket (if valid) regardless
of the standard logic
@return a {@link ProctorResult} to describe buckets allocations of all tests.
"""
final Proctor proctor = proctorSource.get();
if (proctor == null) {
final Map<String, TestBucket> buckets = getDefaultBucketValues();
final Map<String, Integer> versions = Maps.newHashMap();
for (final String testName : buckets.keySet()) {
versions.put(testName, Integer.valueOf(-1));
}
return new ProctorResult(Audit.EMPTY_VERSION,
buckets,
Collections.<String, Allocation>emptyMap(),
Collections.<String, ConsumableTestDefinition>emptyMap()
);
}
final ProctorResult result = proctor.determineTestGroups(identifiers, context, forcedGroups);
return result;
}
|
java
|
@VisibleForTesting
protected ProctorResult determineBucketsInternal(final Identifiers identifiers, final Map<String, Object> context, final Map<String, Integer> forcedGroups) {
final Proctor proctor = proctorSource.get();
if (proctor == null) {
final Map<String, TestBucket> buckets = getDefaultBucketValues();
final Map<String, Integer> versions = Maps.newHashMap();
for (final String testName : buckets.keySet()) {
versions.put(testName, Integer.valueOf(-1));
}
return new ProctorResult(Audit.EMPTY_VERSION,
buckets,
Collections.<String, Allocation>emptyMap(),
Collections.<String, ConsumableTestDefinition>emptyMap()
);
}
final ProctorResult result = proctor.determineTestGroups(identifiers, context, forcedGroups);
return result;
}
|
[
"@",
"VisibleForTesting",
"protected",
"ProctorResult",
"determineBucketsInternal",
"(",
"final",
"Identifiers",
"identifiers",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"context",
",",
"final",
"Map",
"<",
"String",
",",
"Integer",
">",
"forcedGroups",
")",
"{",
"final",
"Proctor",
"proctor",
"=",
"proctorSource",
".",
"get",
"(",
")",
";",
"if",
"(",
"proctor",
"==",
"null",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"TestBucket",
">",
"buckets",
"=",
"getDefaultBucketValues",
"(",
")",
";",
"final",
"Map",
"<",
"String",
",",
"Integer",
">",
"versions",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"final",
"String",
"testName",
":",
"buckets",
".",
"keySet",
"(",
")",
")",
"{",
"versions",
".",
"put",
"(",
"testName",
",",
"Integer",
".",
"valueOf",
"(",
"-",
"1",
")",
")",
";",
"}",
"return",
"new",
"ProctorResult",
"(",
"Audit",
".",
"EMPTY_VERSION",
",",
"buckets",
",",
"Collections",
".",
"<",
"String",
",",
"Allocation",
">",
"emptyMap",
"(",
")",
",",
"Collections",
".",
"<",
"String",
",",
"ConsumableTestDefinition",
">",
"emptyMap",
"(",
")",
")",
";",
"}",
"final",
"ProctorResult",
"result",
"=",
"proctor",
".",
"determineTestGroups",
"(",
"identifiers",
",",
"context",
",",
"forcedGroups",
")",
";",
"return",
"result",
";",
"}"
] |
I don't see any value in using this in an application; you probably should use
{@link #determineBucketsInternal(HttpServletRequest, HttpServletResponse, Identifiers, Map, boolean)}
@param identifiers a {@link Map} of unique-ish {@link String}s describing the request in the context of different {@link TestType}s.For example,
{@link TestType#USER} has a CTK associated, {@link TestType#EMAIL} is an email address, {@link TestType#PAGE} might be a url-encoded String
containing the normalized relevant page parameters
@param context a {@link Map} containing variables describing the context in which the request is executing. These will be supplied to any rules that
execute to determine test eligibility.
@param forcedGroups a {@link Map} from a String test name to an Integer bucket value. For the specified test allocate the specified bucket (if valid) regardless
of the standard logic
@return a {@link ProctorResult} to describe buckets allocations of all tests.
|
[
"I",
"don",
"t",
"see",
"any",
"value",
"in",
"using",
"this",
"in",
"an",
"application",
";",
"you",
"probably",
"should",
"use",
"{",
"@link",
"#determineBucketsInternal",
"(",
"HttpServletRequest",
"HttpServletResponse",
"Identifiers",
"Map",
"boolean",
")",
"}"
] |
train
|
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-consumer/src/main/java/com/indeed/proctor/consumer/AbstractGroupsManager.java#L65-L82
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.logging.hpel/src/com/ibm/websphere/logging/hpel/reader/RepositoryReaderImpl.java
|
RepositoryReaderImpl.getLogListForServerInstance
|
public ServerInstanceLogRecordList getLogListForServerInstance(RepositoryPointer after, final LogRecordHeaderFilter filter) {
"""
returns log records from the binary repository that are beyond a given repository location and satisfies the filter criteria as specified
by the parameters. Callers would have to invoke {@link RepositoryLogRecord#getRepositoryPointer()} to obtain the RepositoryPointer
of the last record read. The returned logs will be from the same server instance.
@param after RepositoryPointer of the last read log record.
@param filter an instance implementing {@link LogRecordHeaderFilter} interface to verify one record at a time.
@return the iterable list of log records
"""
if (after instanceof RepositoryPointerImpl) {
ServerInstanceByPointer instance = new ServerInstanceByPointer((RepositoryPointerImpl) after);
if (instance.logs == null && instance.traces == null) {
return EMPTY_LIST;
}
if (instance.record != null) {
return new ServerInstanceLogRecordListHeaderPointerImpl(instance.logs, instance.traces, instance.switched, (RepositoryPointerImpl) after, instance.record, filter, -1);
}
// Neither trace nor log contain the location which means that file containing
// it was purged already and that we can just return all the records we can find.
return new ServerInstanceLogRecordListImpl(instance.logs, instance.traces, instance.switched) {
@Override
public OnePidRecordListImpl queryResult(
LogRepositoryBrowser browser) {
return new LogRecordBrowser(browser).recordsInProcess(-1, -1, filter);
}
};
} else if (after != null) {
throw new IllegalArgumentException("This method accept only RepositoryPointer instances retrieved from previously read records");
}
return getLogListForServerInstance((Date) null, filter);
}
|
java
|
public ServerInstanceLogRecordList getLogListForServerInstance(RepositoryPointer after, final LogRecordHeaderFilter filter) {
if (after instanceof RepositoryPointerImpl) {
ServerInstanceByPointer instance = new ServerInstanceByPointer((RepositoryPointerImpl) after);
if (instance.logs == null && instance.traces == null) {
return EMPTY_LIST;
}
if (instance.record != null) {
return new ServerInstanceLogRecordListHeaderPointerImpl(instance.logs, instance.traces, instance.switched, (RepositoryPointerImpl) after, instance.record, filter, -1);
}
// Neither trace nor log contain the location which means that file containing
// it was purged already and that we can just return all the records we can find.
return new ServerInstanceLogRecordListImpl(instance.logs, instance.traces, instance.switched) {
@Override
public OnePidRecordListImpl queryResult(
LogRepositoryBrowser browser) {
return new LogRecordBrowser(browser).recordsInProcess(-1, -1, filter);
}
};
} else if (after != null) {
throw new IllegalArgumentException("This method accept only RepositoryPointer instances retrieved from previously read records");
}
return getLogListForServerInstance((Date) null, filter);
}
|
[
"public",
"ServerInstanceLogRecordList",
"getLogListForServerInstance",
"(",
"RepositoryPointer",
"after",
",",
"final",
"LogRecordHeaderFilter",
"filter",
")",
"{",
"if",
"(",
"after",
"instanceof",
"RepositoryPointerImpl",
")",
"{",
"ServerInstanceByPointer",
"instance",
"=",
"new",
"ServerInstanceByPointer",
"(",
"(",
"RepositoryPointerImpl",
")",
"after",
")",
";",
"if",
"(",
"instance",
".",
"logs",
"==",
"null",
"&&",
"instance",
".",
"traces",
"==",
"null",
")",
"{",
"return",
"EMPTY_LIST",
";",
"}",
"if",
"(",
"instance",
".",
"record",
"!=",
"null",
")",
"{",
"return",
"new",
"ServerInstanceLogRecordListHeaderPointerImpl",
"(",
"instance",
".",
"logs",
",",
"instance",
".",
"traces",
",",
"instance",
".",
"switched",
",",
"(",
"RepositoryPointerImpl",
")",
"after",
",",
"instance",
".",
"record",
",",
"filter",
",",
"-",
"1",
")",
";",
"}",
"// Neither trace nor log contain the location which means that file containing",
"// it was purged already and that we can just return all the records we can find.",
"return",
"new",
"ServerInstanceLogRecordListImpl",
"(",
"instance",
".",
"logs",
",",
"instance",
".",
"traces",
",",
"instance",
".",
"switched",
")",
"{",
"@",
"Override",
"public",
"OnePidRecordListImpl",
"queryResult",
"(",
"LogRepositoryBrowser",
"browser",
")",
"{",
"return",
"new",
"LogRecordBrowser",
"(",
"browser",
")",
".",
"recordsInProcess",
"(",
"-",
"1",
",",
"-",
"1",
",",
"filter",
")",
";",
"}",
"}",
";",
"}",
"else",
"if",
"(",
"after",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"This method accept only RepositoryPointer instances retrieved from previously read records\"",
")",
";",
"}",
"return",
"getLogListForServerInstance",
"(",
"(",
"Date",
")",
"null",
",",
"filter",
")",
";",
"}"
] |
returns log records from the binary repository that are beyond a given repository location and satisfies the filter criteria as specified
by the parameters. Callers would have to invoke {@link RepositoryLogRecord#getRepositoryPointer()} to obtain the RepositoryPointer
of the last record read. The returned logs will be from the same server instance.
@param after RepositoryPointer of the last read log record.
@param filter an instance implementing {@link LogRecordHeaderFilter} interface to verify one record at a time.
@return the iterable list of log records
|
[
"returns",
"log",
"records",
"from",
"the",
"binary",
"repository",
"that",
"are",
"beyond",
"a",
"given",
"repository",
"location",
"and",
"satisfies",
"the",
"filter",
"criteria",
"as",
"specified",
"by",
"the",
"parameters",
".",
"Callers",
"would",
"have",
"to",
"invoke",
"{",
"@link",
"RepositoryLogRecord#getRepositoryPointer",
"()",
"}",
"to",
"obtain",
"the",
"RepositoryPointer",
"of",
"the",
"last",
"record",
"read",
".",
"The",
"returned",
"logs",
"will",
"be",
"from",
"the",
"same",
"server",
"instance",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/websphere/logging/hpel/reader/RepositoryReaderImpl.java#L846-L872
|
seedstack/business
|
core/src/main/java/org/seedstack/business/spi/BaseDtoInfoResolver.java
|
BaseDtoInfoResolver.createFromFactory
|
protected <A extends AggregateRoot<?>> A createFromFactory(Class<A> aggregateClass, Object... parameters) {
"""
Implements the logic to create an aggregate.
@param aggregateClass the aggregate class.
@param parameters the parameters to pass to the factory if any.
@param <A> the type of the aggregate root.
@return the aggregate root.
"""
checkNotNull(aggregateClass);
checkNotNull(parameters);
Factory<A> factory = domainRegistry.getFactory(aggregateClass);
// Find the method in the factory which match the signature determined with the previously
// extracted parameters
Method factoryMethod;
boolean useDefaultFactory = false;
try {
factoryMethod = MethodMatcher.findMatchingMethod(factory.getClass(), aggregateClass, parameters);
if (factoryMethod == null) {
useDefaultFactory = true;
}
} catch (Exception e) {
throw BusinessException.wrap(e, BusinessErrorCode.UNABLE_TO_FIND_FACTORY_METHOD)
.put("aggregateClass", aggregateClass.getName())
.put("parameters", Arrays.toString(parameters));
}
// Invoke the factory to create the aggregate root
try {
if (useDefaultFactory) {
return factory.create(parameters);
} else {
if (parameters.length == 0) {
return ReflectUtils.invoke(factoryMethod, factory);
} else {
return ReflectUtils.invoke(factoryMethod, factory, parameters);
}
}
} catch (Exception e) {
throw BusinessException.wrap(e, BusinessErrorCode.UNABLE_TO_INVOKE_FACTORY_METHOD)
.put("aggregateClass", aggregateClass.getName())
.put("factoryClass", factory.getClass()
.getName())
.put("factoryMethod", Optional.ofNullable(factoryMethod)
.map(Method::getName)
.orElse("create"))
.put("parameters", Arrays.toString(parameters));
}
}
|
java
|
protected <A extends AggregateRoot<?>> A createFromFactory(Class<A> aggregateClass, Object... parameters) {
checkNotNull(aggregateClass);
checkNotNull(parameters);
Factory<A> factory = domainRegistry.getFactory(aggregateClass);
// Find the method in the factory which match the signature determined with the previously
// extracted parameters
Method factoryMethod;
boolean useDefaultFactory = false;
try {
factoryMethod = MethodMatcher.findMatchingMethod(factory.getClass(), aggregateClass, parameters);
if (factoryMethod == null) {
useDefaultFactory = true;
}
} catch (Exception e) {
throw BusinessException.wrap(e, BusinessErrorCode.UNABLE_TO_FIND_FACTORY_METHOD)
.put("aggregateClass", aggregateClass.getName())
.put("parameters", Arrays.toString(parameters));
}
// Invoke the factory to create the aggregate root
try {
if (useDefaultFactory) {
return factory.create(parameters);
} else {
if (parameters.length == 0) {
return ReflectUtils.invoke(factoryMethod, factory);
} else {
return ReflectUtils.invoke(factoryMethod, factory, parameters);
}
}
} catch (Exception e) {
throw BusinessException.wrap(e, BusinessErrorCode.UNABLE_TO_INVOKE_FACTORY_METHOD)
.put("aggregateClass", aggregateClass.getName())
.put("factoryClass", factory.getClass()
.getName())
.put("factoryMethod", Optional.ofNullable(factoryMethod)
.map(Method::getName)
.orElse("create"))
.put("parameters", Arrays.toString(parameters));
}
}
|
[
"protected",
"<",
"A",
"extends",
"AggregateRoot",
"<",
"?",
">",
">",
"A",
"createFromFactory",
"(",
"Class",
"<",
"A",
">",
"aggregateClass",
",",
"Object",
"...",
"parameters",
")",
"{",
"checkNotNull",
"(",
"aggregateClass",
")",
";",
"checkNotNull",
"(",
"parameters",
")",
";",
"Factory",
"<",
"A",
">",
"factory",
"=",
"domainRegistry",
".",
"getFactory",
"(",
"aggregateClass",
")",
";",
"// Find the method in the factory which match the signature determined with the previously",
"// extracted parameters",
"Method",
"factoryMethod",
";",
"boolean",
"useDefaultFactory",
"=",
"false",
";",
"try",
"{",
"factoryMethod",
"=",
"MethodMatcher",
".",
"findMatchingMethod",
"(",
"factory",
".",
"getClass",
"(",
")",
",",
"aggregateClass",
",",
"parameters",
")",
";",
"if",
"(",
"factoryMethod",
"==",
"null",
")",
"{",
"useDefaultFactory",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"BusinessException",
".",
"wrap",
"(",
"e",
",",
"BusinessErrorCode",
".",
"UNABLE_TO_FIND_FACTORY_METHOD",
")",
".",
"put",
"(",
"\"aggregateClass\"",
",",
"aggregateClass",
".",
"getName",
"(",
")",
")",
".",
"put",
"(",
"\"parameters\"",
",",
"Arrays",
".",
"toString",
"(",
"parameters",
")",
")",
";",
"}",
"// Invoke the factory to create the aggregate root",
"try",
"{",
"if",
"(",
"useDefaultFactory",
")",
"{",
"return",
"factory",
".",
"create",
"(",
"parameters",
")",
";",
"}",
"else",
"{",
"if",
"(",
"parameters",
".",
"length",
"==",
"0",
")",
"{",
"return",
"ReflectUtils",
".",
"invoke",
"(",
"factoryMethod",
",",
"factory",
")",
";",
"}",
"else",
"{",
"return",
"ReflectUtils",
".",
"invoke",
"(",
"factoryMethod",
",",
"factory",
",",
"parameters",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"BusinessException",
".",
"wrap",
"(",
"e",
",",
"BusinessErrorCode",
".",
"UNABLE_TO_INVOKE_FACTORY_METHOD",
")",
".",
"put",
"(",
"\"aggregateClass\"",
",",
"aggregateClass",
".",
"getName",
"(",
")",
")",
".",
"put",
"(",
"\"factoryClass\"",
",",
"factory",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
".",
"put",
"(",
"\"factoryMethod\"",
",",
"Optional",
".",
"ofNullable",
"(",
"factoryMethod",
")",
".",
"map",
"(",
"Method",
"::",
"getName",
")",
".",
"orElse",
"(",
"\"create\"",
")",
")",
".",
"put",
"(",
"\"parameters\"",
",",
"Arrays",
".",
"toString",
"(",
"parameters",
")",
")",
";",
"}",
"}"
] |
Implements the logic to create an aggregate.
@param aggregateClass the aggregate class.
@param parameters the parameters to pass to the factory if any.
@param <A> the type of the aggregate root.
@return the aggregate root.
|
[
"Implements",
"the",
"logic",
"to",
"create",
"an",
"aggregate",
"."
] |
train
|
https://github.com/seedstack/business/blob/55b3e861fe152e9b125ebc69daa91a682deeae8a/core/src/main/java/org/seedstack/business/spi/BaseDtoInfoResolver.java#L75-L117
|
SimplicityApks/ReminderDatePicker
|
lib/src/main/java/com/simplicityapks/reminderdatepicker/lib/DateSpinner.java
|
DateSpinner.setShowPastItems
|
public void setShowPastItems(boolean enable) {
"""
Toggles showing the past items. Past mode shows the yesterday and last weekday item.
@param enable True to enable, false to disable past mode.
"""
if(enable && !showPastItems) {
// first reset the minimum date if necessary:
if(getMinDate() != null && compareCalendarDates(getMinDate(), Calendar.getInstance()) == 0)
setMinDate(null);
// create the yesterday and last Monday item:
final Resources res = getResources();
final Calendar date = Calendar.getInstance();
// yesterday:
date.add(Calendar.DAY_OF_YEAR, -1);
insertAdapterItem(new DateItem(res.getString(R.string.date_yesterday), date, R.id.date_yesterday), 0);
// last weekday item:
date.add(Calendar.DAY_OF_YEAR, -6);
int weekday = date.get(Calendar.DAY_OF_WEEK);
insertAdapterItem(new DateItem(getWeekDay(weekday, R.string.date_last_weekday),
date, R.id.date_last_week), 0);
}
else if(!enable && showPastItems) {
// delete the yesterday and last weekday items:
removeAdapterItemById(R.id.date_last_week);
removeAdapterItemById(R.id.date_yesterday);
// we set the minimum date to today as we don't allow past items
setMinDate(Calendar.getInstance());
}
showPastItems = enable;
}
|
java
|
public void setShowPastItems(boolean enable) {
if(enable && !showPastItems) {
// first reset the minimum date if necessary:
if(getMinDate() != null && compareCalendarDates(getMinDate(), Calendar.getInstance()) == 0)
setMinDate(null);
// create the yesterday and last Monday item:
final Resources res = getResources();
final Calendar date = Calendar.getInstance();
// yesterday:
date.add(Calendar.DAY_OF_YEAR, -1);
insertAdapterItem(new DateItem(res.getString(R.string.date_yesterday), date, R.id.date_yesterday), 0);
// last weekday item:
date.add(Calendar.DAY_OF_YEAR, -6);
int weekday = date.get(Calendar.DAY_OF_WEEK);
insertAdapterItem(new DateItem(getWeekDay(weekday, R.string.date_last_weekday),
date, R.id.date_last_week), 0);
}
else if(!enable && showPastItems) {
// delete the yesterday and last weekday items:
removeAdapterItemById(R.id.date_last_week);
removeAdapterItemById(R.id.date_yesterday);
// we set the minimum date to today as we don't allow past items
setMinDate(Calendar.getInstance());
}
showPastItems = enable;
}
|
[
"public",
"void",
"setShowPastItems",
"(",
"boolean",
"enable",
")",
"{",
"if",
"(",
"enable",
"&&",
"!",
"showPastItems",
")",
"{",
"// first reset the minimum date if necessary:",
"if",
"(",
"getMinDate",
"(",
")",
"!=",
"null",
"&&",
"compareCalendarDates",
"(",
"getMinDate",
"(",
")",
",",
"Calendar",
".",
"getInstance",
"(",
")",
")",
"==",
"0",
")",
"setMinDate",
"(",
"null",
")",
";",
"// create the yesterday and last Monday item:",
"final",
"Resources",
"res",
"=",
"getResources",
"(",
")",
";",
"final",
"Calendar",
"date",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"// yesterday:",
"date",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"-",
"1",
")",
";",
"insertAdapterItem",
"(",
"new",
"DateItem",
"(",
"res",
".",
"getString",
"(",
"R",
".",
"string",
".",
"date_yesterday",
")",
",",
"date",
",",
"R",
".",
"id",
".",
"date_yesterday",
")",
",",
"0",
")",
";",
"// last weekday item:",
"date",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"-",
"6",
")",
";",
"int",
"weekday",
"=",
"date",
".",
"get",
"(",
"Calendar",
".",
"DAY_OF_WEEK",
")",
";",
"insertAdapterItem",
"(",
"new",
"DateItem",
"(",
"getWeekDay",
"(",
"weekday",
",",
"R",
".",
"string",
".",
"date_last_weekday",
")",
",",
"date",
",",
"R",
".",
"id",
".",
"date_last_week",
")",
",",
"0",
")",
";",
"}",
"else",
"if",
"(",
"!",
"enable",
"&&",
"showPastItems",
")",
"{",
"// delete the yesterday and last weekday items:",
"removeAdapterItemById",
"(",
"R",
".",
"id",
".",
"date_last_week",
")",
";",
"removeAdapterItemById",
"(",
"R",
".",
"id",
".",
"date_yesterday",
")",
";",
"// we set the minimum date to today as we don't allow past items",
"setMinDate",
"(",
"Calendar",
".",
"getInstance",
"(",
")",
")",
";",
"}",
"showPastItems",
"=",
"enable",
";",
"}"
] |
Toggles showing the past items. Past mode shows the yesterday and last weekday item.
@param enable True to enable, false to disable past mode.
|
[
"Toggles",
"showing",
"the",
"past",
"items",
".",
"Past",
"mode",
"shows",
"the",
"yesterday",
"and",
"last",
"weekday",
"item",
"."
] |
train
|
https://github.com/SimplicityApks/ReminderDatePicker/blob/7596fbac77a5d26f687fec11758935a2b7db156f/lib/src/main/java/com/simplicityapks/reminderdatepicker/lib/DateSpinner.java#L488-L515
|
phax/ph-web
|
ph-web/src/main/java/com/helger/web/multipart/MultipartStream.java
|
MultipartStream.readHeaders
|
public String readHeaders () throws MultipartMalformedStreamException {
"""
<p>
Reads the <code>header-part</code> of the current
<code>encapsulation</code>.
<p>
Headers are returned verbatim to the input stream, including the trailing
<code>CRLF</code> marker. Parsing is left to the application.
@return The <code>header-part</code> of the current encapsulation.
@throws MultipartMalformedStreamException
if the stream ends unexpectedly.
"""
// to support multi-byte characters
try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ())
{
int nHeaderSepIndex = 0;
int nSize = 0;
while (nHeaderSepIndex < HEADER_SEPARATOR.length)
{
byte b;
try
{
b = readByte ();
}
catch (final IOException e)
{
throw new MultipartMalformedStreamException ("Stream ended unexpectedly after " + nSize + " bytes", e);
}
if (++nSize > HEADER_PART_SIZE_MAX)
{
throw new MultipartMalformedStreamException ("Header section has more than " +
HEADER_PART_SIZE_MAX +
" bytes (maybe it is not properly terminated)");
}
if (b == HEADER_SEPARATOR[nHeaderSepIndex])
nHeaderSepIndex++;
else
nHeaderSepIndex = 0;
aBAOS.write (b);
}
final Charset aCharsetToUse = CharsetHelper.getCharsetFromNameOrDefault (m_sHeaderEncoding,
SystemHelper.getSystemCharset ());
return aBAOS.getAsString (aCharsetToUse);
}
}
|
java
|
public String readHeaders () throws MultipartMalformedStreamException
{
// to support multi-byte characters
try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ())
{
int nHeaderSepIndex = 0;
int nSize = 0;
while (nHeaderSepIndex < HEADER_SEPARATOR.length)
{
byte b;
try
{
b = readByte ();
}
catch (final IOException e)
{
throw new MultipartMalformedStreamException ("Stream ended unexpectedly after " + nSize + " bytes", e);
}
if (++nSize > HEADER_PART_SIZE_MAX)
{
throw new MultipartMalformedStreamException ("Header section has more than " +
HEADER_PART_SIZE_MAX +
" bytes (maybe it is not properly terminated)");
}
if (b == HEADER_SEPARATOR[nHeaderSepIndex])
nHeaderSepIndex++;
else
nHeaderSepIndex = 0;
aBAOS.write (b);
}
final Charset aCharsetToUse = CharsetHelper.getCharsetFromNameOrDefault (m_sHeaderEncoding,
SystemHelper.getSystemCharset ());
return aBAOS.getAsString (aCharsetToUse);
}
}
|
[
"public",
"String",
"readHeaders",
"(",
")",
"throws",
"MultipartMalformedStreamException",
"{",
"// to support multi-byte characters",
"try",
"(",
"final",
"NonBlockingByteArrayOutputStream",
"aBAOS",
"=",
"new",
"NonBlockingByteArrayOutputStream",
"(",
")",
")",
"{",
"int",
"nHeaderSepIndex",
"=",
"0",
";",
"int",
"nSize",
"=",
"0",
";",
"while",
"(",
"nHeaderSepIndex",
"<",
"HEADER_SEPARATOR",
".",
"length",
")",
"{",
"byte",
"b",
";",
"try",
"{",
"b",
"=",
"readByte",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"throw",
"new",
"MultipartMalformedStreamException",
"(",
"\"Stream ended unexpectedly after \"",
"+",
"nSize",
"+",
"\" bytes\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"++",
"nSize",
">",
"HEADER_PART_SIZE_MAX",
")",
"{",
"throw",
"new",
"MultipartMalformedStreamException",
"(",
"\"Header section has more than \"",
"+",
"HEADER_PART_SIZE_MAX",
"+",
"\" bytes (maybe it is not properly terminated)\"",
")",
";",
"}",
"if",
"(",
"b",
"==",
"HEADER_SEPARATOR",
"[",
"nHeaderSepIndex",
"]",
")",
"nHeaderSepIndex",
"++",
";",
"else",
"nHeaderSepIndex",
"=",
"0",
";",
"aBAOS",
".",
"write",
"(",
"b",
")",
";",
"}",
"final",
"Charset",
"aCharsetToUse",
"=",
"CharsetHelper",
".",
"getCharsetFromNameOrDefault",
"(",
"m_sHeaderEncoding",
",",
"SystemHelper",
".",
"getSystemCharset",
"(",
")",
")",
";",
"return",
"aBAOS",
".",
"getAsString",
"(",
"aCharsetToUse",
")",
";",
"}",
"}"
] |
<p>
Reads the <code>header-part</code> of the current
<code>encapsulation</code>.
<p>
Headers are returned verbatim to the input stream, including the trailing
<code>CRLF</code> marker. Parsing is left to the application.
@return The <code>header-part</code> of the current encapsulation.
@throws MultipartMalformedStreamException
if the stream ends unexpectedly.
|
[
"<p",
">",
"Reads",
"the",
"<code",
">",
"header",
"-",
"part<",
"/",
"code",
">",
"of",
"the",
"current",
"<code",
">",
"encapsulation<",
"/",
"code",
">",
".",
"<p",
">",
"Headers",
"are",
"returned",
"verbatim",
"to",
"the",
"input",
"stream",
"including",
"the",
"trailing",
"<code",
">",
"CRLF<",
"/",
"code",
">",
"marker",
".",
"Parsing",
"is",
"left",
"to",
"the",
"application",
"."
] |
train
|
https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/multipart/MultipartStream.java#L401-L436
|
aehrc/snorocket
|
snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/Context.java
|
Context.processExternalEdge
|
public void processExternalEdge(final int role, final int src) {
"""
Triggers the processing of an edge based on events that happened in another {@link Context}.
@param role
@param src
"""
externalQueue.add(new IRoleQueueEntry() {
/**
* Serialisation version.
*/
private static final long serialVersionUID = 1L;
@Override
public int getR() {
return role;
}
@Override
public int getB() {
return src;
}
});
}
|
java
|
public void processExternalEdge(final int role, final int src) {
externalQueue.add(new IRoleQueueEntry() {
/**
* Serialisation version.
*/
private static final long serialVersionUID = 1L;
@Override
public int getR() {
return role;
}
@Override
public int getB() {
return src;
}
});
}
|
[
"public",
"void",
"processExternalEdge",
"(",
"final",
"int",
"role",
",",
"final",
"int",
"src",
")",
"{",
"externalQueue",
".",
"add",
"(",
"new",
"IRoleQueueEntry",
"(",
")",
"{",
"/**\r\n * Serialisation version.\r\n */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"@",
"Override",
"public",
"int",
"getR",
"(",
")",
"{",
"return",
"role",
";",
"}",
"@",
"Override",
"public",
"int",
"getB",
"(",
")",
"{",
"return",
"src",
";",
"}",
"}",
")",
";",
"}"
] |
Triggers the processing of an edge based on events that happened in another {@link Context}.
@param role
@param src
|
[
"Triggers",
"the",
"processing",
"of",
"an",
"edge",
"based",
"on",
"events",
"that",
"happened",
"in",
"another",
"{",
"@link",
"Context",
"}",
"."
] |
train
|
https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/concurrent/Context.java#L370-L387
|
j-easy/easy-random
|
easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java
|
ReflectionUtils.setProperty
|
public static void setProperty(final Object object, final Field field, final Object value) throws IllegalAccessException {
"""
Set a value (accessible or not accessible) in a field of a target object.
@param object instance to set the property on
@param field field to set the property on
@param value value to set
@throws IllegalAccessException if the property cannot be set
"""
boolean access = field.isAccessible();
field.setAccessible(true);
field.set(object, value);
field.setAccessible(access);
}
|
java
|
public static void setProperty(final Object object, final Field field, final Object value) throws IllegalAccessException {
boolean access = field.isAccessible();
field.setAccessible(true);
field.set(object, value);
field.setAccessible(access);
}
|
[
"public",
"static",
"void",
"setProperty",
"(",
"final",
"Object",
"object",
",",
"final",
"Field",
"field",
",",
"final",
"Object",
"value",
")",
"throws",
"IllegalAccessException",
"{",
"boolean",
"access",
"=",
"field",
".",
"isAccessible",
"(",
")",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"object",
",",
"value",
")",
";",
"field",
".",
"setAccessible",
"(",
"access",
")",
";",
"}"
] |
Set a value (accessible or not accessible) in a field of a target object.
@param object instance to set the property on
@param field field to set the property on
@param value value to set
@throws IllegalAccessException if the property cannot be set
|
[
"Set",
"a",
"value",
"(",
"accessible",
"or",
"not",
"accessible",
")",
"in",
"a",
"field",
"of",
"a",
"target",
"object",
"."
] |
train
|
https://github.com/j-easy/easy-random/blob/816b0d6a74c7288af111e70ae1b0b57d7fe3b59d/easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java#L130-L135
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java
|
ApiOvhMe.installationTemplate_templateName_GET
|
public OvhTemplates installationTemplate_templateName_GET(String templateName) throws IOException {
"""
Get this object properties
REST: GET /me/installationTemplate/{templateName}
@param templateName [required] This template name
"""
String qPath = "/me/installationTemplate/{templateName}";
StringBuilder sb = path(qPath, templateName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhTemplates.class);
}
|
java
|
public OvhTemplates installationTemplate_templateName_GET(String templateName) throws IOException {
String qPath = "/me/installationTemplate/{templateName}";
StringBuilder sb = path(qPath, templateName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhTemplates.class);
}
|
[
"public",
"OvhTemplates",
"installationTemplate_templateName_GET",
"(",
"String",
"templateName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/installationTemplate/{templateName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"templateName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTemplates",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /me/installationTemplate/{templateName}
@param templateName [required] This template name
|
[
"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#L3438-L3443
|
aws/aws-sdk-java
|
aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/ConditionCheck.java
|
ConditionCheck.withExpressionAttributeNames
|
public ConditionCheck withExpressionAttributeNames(java.util.Map<String, String> expressionAttributeNames) {
"""
<p>
One or more substitution tokens for attribute names in an expression.
</p>
@param expressionAttributeNames
One or more substitution tokens for attribute names in an expression.
@return Returns a reference to this object so that method calls can be chained together.
"""
setExpressionAttributeNames(expressionAttributeNames);
return this;
}
|
java
|
public ConditionCheck withExpressionAttributeNames(java.util.Map<String, String> expressionAttributeNames) {
setExpressionAttributeNames(expressionAttributeNames);
return this;
}
|
[
"public",
"ConditionCheck",
"withExpressionAttributeNames",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"expressionAttributeNames",
")",
"{",
"setExpressionAttributeNames",
"(",
"expressionAttributeNames",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
One or more substitution tokens for attribute names in an expression.
</p>
@param expressionAttributeNames
One or more substitution tokens for attribute names in an expression.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"One",
"or",
"more",
"substitution",
"tokens",
"for",
"attribute",
"names",
"in",
"an",
"expression",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/ConditionCheck.java#L254-L257
|
snowflakedb/snowflake-jdbc
|
src/main/java/net/snowflake/client/core/SFTrustManager.java
|
SFTrustManager.isValidityRange
|
private static boolean isValidityRange(Date currentTime, Date thisUpdate, Date nextUpdate) {
"""
Checks the validity
@param currentTime the current time
@param thisUpdate the last update timestamp
@param nextUpdate the next update timestamp
@return true if valid or false
"""
long tolerableValidity = calculateTolerableVadility(thisUpdate, nextUpdate);
return thisUpdate.getTime() - MAX_CLOCK_SKEW_IN_MILLISECONDS <= currentTime.getTime() &&
currentTime.getTime() <= nextUpdate.getTime() + tolerableValidity;
}
|
java
|
private static boolean isValidityRange(Date currentTime, Date thisUpdate, Date nextUpdate)
{
long tolerableValidity = calculateTolerableVadility(thisUpdate, nextUpdate);
return thisUpdate.getTime() - MAX_CLOCK_SKEW_IN_MILLISECONDS <= currentTime.getTime() &&
currentTime.getTime() <= nextUpdate.getTime() + tolerableValidity;
}
|
[
"private",
"static",
"boolean",
"isValidityRange",
"(",
"Date",
"currentTime",
",",
"Date",
"thisUpdate",
",",
"Date",
"nextUpdate",
")",
"{",
"long",
"tolerableValidity",
"=",
"calculateTolerableVadility",
"(",
"thisUpdate",
",",
"nextUpdate",
")",
";",
"return",
"thisUpdate",
".",
"getTime",
"(",
")",
"-",
"MAX_CLOCK_SKEW_IN_MILLISECONDS",
"<=",
"currentTime",
".",
"getTime",
"(",
")",
"&&",
"currentTime",
".",
"getTime",
"(",
")",
"<=",
"nextUpdate",
".",
"getTime",
"(",
")",
"+",
"tolerableValidity",
";",
"}"
] |
Checks the validity
@param currentTime the current time
@param thisUpdate the last update timestamp
@param nextUpdate the next update timestamp
@return true if valid or false
|
[
"Checks",
"the",
"validity"
] |
train
|
https://github.com/snowflakedb/snowflake-jdbc/blob/98567b5a57753f29d51446809640b969a099658f/src/main/java/net/snowflake/client/core/SFTrustManager.java#L1592-L1597
|
aNNiMON/Lightweight-Stream-API
|
stream/src/main/java/com/annimon/stream/LongStream.java
|
LongStream.scan
|
@NotNull
public LongStream scan(@NotNull final LongBinaryOperator accumulator) {
"""
Returns a {@code LongStream} produced by iterative application of a accumulation function
to reduction value and next element of the current stream.
Produces a {@code LongStream} consisting of {@code value1}, {@code acc(value1, value2)},
{@code acc(acc(value1, value2), value3)}, etc.
<p>This is an intermediate operation.
<p>Example:
<pre>
accumulator: (a, b) -> a + b
stream: [1, 2, 3, 4, 5]
result: [1, 3, 6, 10, 15]
</pre>
@param accumulator the accumulation function
@return the new stream
@throws NullPointerException if {@code accumulator} is null
@since 1.1.6
"""
Objects.requireNonNull(accumulator);
return new LongStream(params, new LongScan(iterator, accumulator));
}
|
java
|
@NotNull
public LongStream scan(@NotNull final LongBinaryOperator accumulator) {
Objects.requireNonNull(accumulator);
return new LongStream(params, new LongScan(iterator, accumulator));
}
|
[
"@",
"NotNull",
"public",
"LongStream",
"scan",
"(",
"@",
"NotNull",
"final",
"LongBinaryOperator",
"accumulator",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"accumulator",
")",
";",
"return",
"new",
"LongStream",
"(",
"params",
",",
"new",
"LongScan",
"(",
"iterator",
",",
"accumulator",
")",
")",
";",
"}"
] |
Returns a {@code LongStream} produced by iterative application of a accumulation function
to reduction value and next element of the current stream.
Produces a {@code LongStream} consisting of {@code value1}, {@code acc(value1, value2)},
{@code acc(acc(value1, value2), value3)}, etc.
<p>This is an intermediate operation.
<p>Example:
<pre>
accumulator: (a, b) -> a + b
stream: [1, 2, 3, 4, 5]
result: [1, 3, 6, 10, 15]
</pre>
@param accumulator the accumulation function
@return the new stream
@throws NullPointerException if {@code accumulator} is null
@since 1.1.6
|
[
"Returns",
"a",
"{",
"@code",
"LongStream",
"}",
"produced",
"by",
"iterative",
"application",
"of",
"a",
"accumulation",
"function",
"to",
"reduction",
"value",
"and",
"next",
"element",
"of",
"the",
"current",
"stream",
".",
"Produces",
"a",
"{",
"@code",
"LongStream",
"}",
"consisting",
"of",
"{",
"@code",
"value1",
"}",
"{",
"@code",
"acc",
"(",
"value1",
"value2",
")",
"}",
"{",
"@code",
"acc",
"(",
"acc",
"(",
"value1",
"value2",
")",
"value3",
")",
"}",
"etc",
"."
] |
train
|
https://github.com/aNNiMON/Lightweight-Stream-API/blob/f29fd57208c20252a4549b084d55ed082c3e58f0/stream/src/main/java/com/annimon/stream/LongStream.java#L682-L686
|
GoogleCloudPlatform/google-cloud-datastore
|
java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java
|
DatastoreHelper.getServiceAccountCredential
|
public static Credential getServiceAccountCredential(String serviceAccountId,
String privateKeyFile, Collection<String> serviceAccountScopes)
throws GeneralSecurityException, IOException {
"""
Constructs credentials for the given account and key file.
@param serviceAccountId service account ID (typically an e-mail address).
@param privateKeyFile the file name from which to get the private key.
@param serviceAccountScopes Collection of OAuth scopes to use with the the service
account flow or {@code null} if not.
@return valid credentials or {@code null}
"""
return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes)
.setServiceAccountPrivateKeyFromP12File(new File(privateKeyFile))
.build();
}
|
java
|
public static Credential getServiceAccountCredential(String serviceAccountId,
String privateKeyFile, Collection<String> serviceAccountScopes)
throws GeneralSecurityException, IOException {
return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes)
.setServiceAccountPrivateKeyFromP12File(new File(privateKeyFile))
.build();
}
|
[
"public",
"static",
"Credential",
"getServiceAccountCredential",
"(",
"String",
"serviceAccountId",
",",
"String",
"privateKeyFile",
",",
"Collection",
"<",
"String",
">",
"serviceAccountScopes",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"return",
"getCredentialBuilderWithoutPrivateKey",
"(",
"serviceAccountId",
",",
"serviceAccountScopes",
")",
".",
"setServiceAccountPrivateKeyFromP12File",
"(",
"new",
"File",
"(",
"privateKeyFile",
")",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Constructs credentials for the given account and key file.
@param serviceAccountId service account ID (typically an e-mail address).
@param privateKeyFile the file name from which to get the private key.
@param serviceAccountScopes Collection of OAuth scopes to use with the the service
account flow or {@code null} if not.
@return valid credentials or {@code null}
|
[
"Constructs",
"credentials",
"for",
"the",
"given",
"account",
"and",
"key",
"file",
"."
] |
train
|
https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java#L177-L183
|
aoindustries/aoweb-framework
|
src/main/java/com/aoindustries/website/framework/WebPage.java
|
WebPage.doGet
|
protected void doGet(WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException, SQLException {
"""
The layout is automatically applied to the page, then <code>doGet</code> is called. To not have this automatically applied,
override this method. By the time this method is called, security checks, authentication, and redirects have been done.<br />
<br />
The first thing this method does is print the frameset if needed. Second, it uses the output cache to quickly print
the output if possible. And third, it will call doGet(ChainWriter,WebSiteRequest,HttpServletResponse) with a stream
directly out if the first two actions were not taken.
@see #doGet(ChainWriter,WebSiteRequest,HttpServletResponse)
"""
WebPageLayout layout=getWebPageLayout(req);
ChainWriter out=getHTMLChainWriter(req, resp);
try {
layout.startHTML(this, req, resp, out, null);
doGet(out, req, resp);
layout.endHTML(this, req, resp, out);
} finally {
out.flush();
out.close();
}
}
|
java
|
protected void doGet(WebSiteRequest req, HttpServletResponse resp) throws ServletException, IOException, SQLException {
WebPageLayout layout=getWebPageLayout(req);
ChainWriter out=getHTMLChainWriter(req, resp);
try {
layout.startHTML(this, req, resp, out, null);
doGet(out, req, resp);
layout.endHTML(this, req, resp, out);
} finally {
out.flush();
out.close();
}
}
|
[
"protected",
"void",
"doGet",
"(",
"WebSiteRequest",
"req",
",",
"HttpServletResponse",
"resp",
")",
"throws",
"ServletException",
",",
"IOException",
",",
"SQLException",
"{",
"WebPageLayout",
"layout",
"=",
"getWebPageLayout",
"(",
"req",
")",
";",
"ChainWriter",
"out",
"=",
"getHTMLChainWriter",
"(",
"req",
",",
"resp",
")",
";",
"try",
"{",
"layout",
".",
"startHTML",
"(",
"this",
",",
"req",
",",
"resp",
",",
"out",
",",
"null",
")",
";",
"doGet",
"(",
"out",
",",
"req",
",",
"resp",
")",
";",
"layout",
".",
"endHTML",
"(",
"this",
",",
"req",
",",
"resp",
",",
"out",
")",
";",
"}",
"finally",
"{",
"out",
".",
"flush",
"(",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
The layout is automatically applied to the page, then <code>doGet</code> is called. To not have this automatically applied,
override this method. By the time this method is called, security checks, authentication, and redirects have been done.<br />
<br />
The first thing this method does is print the frameset if needed. Second, it uses the output cache to quickly print
the output if possible. And third, it will call doGet(ChainWriter,WebSiteRequest,HttpServletResponse) with a stream
directly out if the first two actions were not taken.
@see #doGet(ChainWriter,WebSiteRequest,HttpServletResponse)
|
[
"The",
"layout",
"is",
"automatically",
"applied",
"to",
"the",
"page",
"then",
"<code",
">",
"doGet<",
"/",
"code",
">",
"is",
"called",
".",
"To",
"not",
"have",
"this",
"automatically",
"applied",
"override",
"this",
"method",
".",
"By",
"the",
"time",
"this",
"method",
"is",
"called",
"security",
"checks",
"authentication",
"and",
"redirects",
"have",
"been",
"done",
".",
"<br",
"/",
">",
"<br",
"/",
">",
"The",
"first",
"thing",
"this",
"method",
"does",
"is",
"print",
"the",
"frameset",
"if",
"needed",
".",
"Second",
"it",
"uses",
"the",
"output",
"cache",
"to",
"quickly",
"print",
"the",
"output",
"if",
"possible",
".",
"And",
"third",
"it",
"will",
"call",
"doGet",
"(",
"ChainWriter",
"WebSiteRequest",
"HttpServletResponse",
")",
"with",
"a",
"stream",
"directly",
"out",
"if",
"the",
"first",
"two",
"actions",
"were",
"not",
"taken",
"."
] |
train
|
https://github.com/aoindustries/aoweb-framework/blob/8e58af4f5dd898cd2fdb855ffa810a1ca6973ae0/src/main/java/com/aoindustries/website/framework/WebPage.java#L348-L360
|
aspectran/aspectran
|
core/src/main/java/com/aspectran/core/util/ClassUtils.java
|
ClassUtils.isLoadable
|
private static boolean isLoadable(Class<?> clazz, ClassLoader classLoader) {
"""
Check whether the given class is loadable in the given ClassLoader.
@param clazz the class to check (typically an interface)
@param classLoader the ClassLoader to check against
@return true if the given class is loadable; otherwise false
@since 6.0.0
"""
try {
return (clazz == classLoader.loadClass(clazz.getName()));
// Else: different class with same name found
} catch (ClassNotFoundException ex) {
// No corresponding class found at all
return false;
}
}
|
java
|
private static boolean isLoadable(Class<?> clazz, ClassLoader classLoader) {
try {
return (clazz == classLoader.loadClass(clazz.getName()));
// Else: different class with same name found
} catch (ClassNotFoundException ex) {
// No corresponding class found at all
return false;
}
}
|
[
"private",
"static",
"boolean",
"isLoadable",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"ClassLoader",
"classLoader",
")",
"{",
"try",
"{",
"return",
"(",
"clazz",
"==",
"classLoader",
".",
"loadClass",
"(",
"clazz",
".",
"getName",
"(",
")",
")",
")",
";",
"// Else: different class with same name found",
"}",
"catch",
"(",
"ClassNotFoundException",
"ex",
")",
"{",
"// No corresponding class found at all",
"return",
"false",
";",
"}",
"}"
] |
Check whether the given class is loadable in the given ClassLoader.
@param clazz the class to check (typically an interface)
@param classLoader the ClassLoader to check against
@return true if the given class is loadable; otherwise false
@since 6.0.0
|
[
"Check",
"whether",
"the",
"given",
"class",
"is",
"loadable",
"in",
"the",
"given",
"ClassLoader",
"."
] |
train
|
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ClassUtils.java#L172-L180
|
BorderTech/wcomponents
|
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WColumnLayout.java
|
WColumnLayout.setLeftColumn
|
public void setLeftColumn(final String heading, final WComponent content) {
"""
Sets the left column content.
@param heading the column heading text.
@param content the content.
"""
setLeftColumn(new WHeading(WHeading.MINOR, heading), content);
}
|
java
|
public void setLeftColumn(final String heading, final WComponent content) {
setLeftColumn(new WHeading(WHeading.MINOR, heading), content);
}
|
[
"public",
"void",
"setLeftColumn",
"(",
"final",
"String",
"heading",
",",
"final",
"WComponent",
"content",
")",
"{",
"setLeftColumn",
"(",
"new",
"WHeading",
"(",
"WHeading",
".",
"MINOR",
",",
"heading",
")",
",",
"content",
")",
";",
"}"
] |
Sets the left column content.
@param heading the column heading text.
@param content the content.
|
[
"Sets",
"the",
"left",
"column",
"content",
"."
] |
train
|
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WColumnLayout.java#L82-L84
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.org.apache.directory.server/src/com/ibm/ws/apacheds/EmbeddedApacheDS.java
|
EmbeddedApacheDS.addPartition
|
public Partition addPartition(String partitionId, String partitionDn) throws Exception {
"""
Add a new partition to the server
@param partitionId The partition ID
@param partitionDn The partition DN
@return The newly added partition
@throws Exception If the partition can't be added
"""
Log.info(c, "addPartition", "entry " + partitionId + " " + partitionDn);
JdbmPartition partition = new JdbmPartition(this.service.getSchemaManager());
partition.setId(partitionId);
partition.setPartitionPath(new File(this.service.getInstanceLayout().getPartitionsDirectory(), partitionId).toURI());
partition.setSuffixDn(new Dn(partitionDn));
service.addPartition(partition);
Log.info(c, "addPartition", "exit");
return partition;
}
|
java
|
public Partition addPartition(String partitionId, String partitionDn) throws Exception {
Log.info(c, "addPartition", "entry " + partitionId + " " + partitionDn);
JdbmPartition partition = new JdbmPartition(this.service.getSchemaManager());
partition.setId(partitionId);
partition.setPartitionPath(new File(this.service.getInstanceLayout().getPartitionsDirectory(), partitionId).toURI());
partition.setSuffixDn(new Dn(partitionDn));
service.addPartition(partition);
Log.info(c, "addPartition", "exit");
return partition;
}
|
[
"public",
"Partition",
"addPartition",
"(",
"String",
"partitionId",
",",
"String",
"partitionDn",
")",
"throws",
"Exception",
"{",
"Log",
".",
"info",
"(",
"c",
",",
"\"addPartition\"",
",",
"\"entry \"",
"+",
"partitionId",
"+",
"\" \"",
"+",
"partitionDn",
")",
";",
"JdbmPartition",
"partition",
"=",
"new",
"JdbmPartition",
"(",
"this",
".",
"service",
".",
"getSchemaManager",
"(",
")",
")",
";",
"partition",
".",
"setId",
"(",
"partitionId",
")",
";",
"partition",
".",
"setPartitionPath",
"(",
"new",
"File",
"(",
"this",
".",
"service",
".",
"getInstanceLayout",
"(",
")",
".",
"getPartitionsDirectory",
"(",
")",
",",
"partitionId",
")",
".",
"toURI",
"(",
")",
")",
";",
"partition",
".",
"setSuffixDn",
"(",
"new",
"Dn",
"(",
"partitionDn",
")",
")",
";",
"service",
".",
"addPartition",
"(",
"partition",
")",
";",
"Log",
".",
"info",
"(",
"c",
",",
"\"addPartition\"",
",",
"\"exit\"",
")",
";",
"return",
"partition",
";",
"}"
] |
Add a new partition to the server
@param partitionId The partition ID
@param partitionDn The partition DN
@return The newly added partition
@throws Exception If the partition can't be added
|
[
"Add",
"a",
"new",
"partition",
"to",
"the",
"server"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.org.apache.directory.server/src/com/ibm/ws/apacheds/EmbeddedApacheDS.java#L172-L182
|
elki-project/elki
|
elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/FPGrowth.java
|
FPGrowth.countItemSupport
|
private int[] countItemSupport(final Relation<BitVector> relation, final int dim) {
"""
Count the support of each 1-item.
@param relation Data
@param dim Maximum dimensionality
@return Item counts
"""
final int[] counts = new int[dim];
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Finding frequent 1-items", relation.size(), LOG) : null;
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
SparseFeatureVector<?> bv = relation.get(iditer);
// TODO: only count those which satisfy minlength?
for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) {
counts[bv.iterDim(it)]++;
}
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
return counts;
}
|
java
|
private int[] countItemSupport(final Relation<BitVector> relation, final int dim) {
final int[] counts = new int[dim];
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Finding frequent 1-items", relation.size(), LOG) : null;
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
SparseFeatureVector<?> bv = relation.get(iditer);
// TODO: only count those which satisfy minlength?
for(int it = bv.iter(); bv.iterValid(it); it = bv.iterAdvance(it)) {
counts[bv.iterDim(it)]++;
}
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
return counts;
}
|
[
"private",
"int",
"[",
"]",
"countItemSupport",
"(",
"final",
"Relation",
"<",
"BitVector",
">",
"relation",
",",
"final",
"int",
"dim",
")",
"{",
"final",
"int",
"[",
"]",
"counts",
"=",
"new",
"int",
"[",
"dim",
"]",
";",
"FiniteProgress",
"prog",
"=",
"LOG",
".",
"isVerbose",
"(",
")",
"?",
"new",
"FiniteProgress",
"(",
"\"Finding frequent 1-items\"",
",",
"relation",
".",
"size",
"(",
")",
",",
"LOG",
")",
":",
"null",
";",
"for",
"(",
"DBIDIter",
"iditer",
"=",
"relation",
".",
"iterDBIDs",
"(",
")",
";",
"iditer",
".",
"valid",
"(",
")",
";",
"iditer",
".",
"advance",
"(",
")",
")",
"{",
"SparseFeatureVector",
"<",
"?",
">",
"bv",
"=",
"relation",
".",
"get",
"(",
"iditer",
")",
";",
"// TODO: only count those which satisfy minlength?",
"for",
"(",
"int",
"it",
"=",
"bv",
".",
"iter",
"(",
")",
";",
"bv",
".",
"iterValid",
"(",
"it",
")",
";",
"it",
"=",
"bv",
".",
"iterAdvance",
"(",
"it",
")",
")",
"{",
"counts",
"[",
"bv",
".",
"iterDim",
"(",
"it",
")",
"]",
"++",
";",
"}",
"LOG",
".",
"incrementProcessed",
"(",
"prog",
")",
";",
"}",
"LOG",
".",
"ensureCompleted",
"(",
"prog",
")",
";",
"return",
"counts",
";",
"}"
] |
Count the support of each 1-item.
@param relation Data
@param dim Maximum dimensionality
@return Item counts
|
[
"Count",
"the",
"support",
"of",
"each",
"1",
"-",
"item",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-itemsets/src/main/java/de/lmu/ifi/dbs/elki/algorithm/itemsetmining/FPGrowth.java#L194-L207
|
samskivert/samskivert
|
src/main/java/com/samskivert/jdbc/JORARepository.java
|
JORARepository.updateField
|
protected <T> int updateField (
final Table<T> table, final T object, String field)
throws PersistenceException {
"""
Updates the specified field in the supplied object (which must
correspond to the supplied table).
@return the number of rows modified by the update.
"""
final FieldMask mask = table.getFieldMask();
mask.setModified(field);
return executeUpdate(new Operation<Integer>() {
public Integer invoke (Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
return table.update(conn, object, mask);
}
});
}
|
java
|
protected <T> int updateField (
final Table<T> table, final T object, String field)
throws PersistenceException
{
final FieldMask mask = table.getFieldMask();
mask.setModified(field);
return executeUpdate(new Operation<Integer>() {
public Integer invoke (Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
return table.update(conn, object, mask);
}
});
}
|
[
"protected",
"<",
"T",
">",
"int",
"updateField",
"(",
"final",
"Table",
"<",
"T",
">",
"table",
",",
"final",
"T",
"object",
",",
"String",
"field",
")",
"throws",
"PersistenceException",
"{",
"final",
"FieldMask",
"mask",
"=",
"table",
".",
"getFieldMask",
"(",
")",
";",
"mask",
".",
"setModified",
"(",
"field",
")",
";",
"return",
"executeUpdate",
"(",
"new",
"Operation",
"<",
"Integer",
">",
"(",
")",
"{",
"public",
"Integer",
"invoke",
"(",
"Connection",
"conn",
",",
"DatabaseLiaison",
"liaison",
")",
"throws",
"SQLException",
",",
"PersistenceException",
"{",
"return",
"table",
".",
"update",
"(",
"conn",
",",
"object",
",",
"mask",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Updates the specified field in the supplied object (which must
correspond to the supplied table).
@return the number of rows modified by the update.
|
[
"Updates",
"the",
"specified",
"field",
"in",
"the",
"supplied",
"object",
"(",
"which",
"must",
"correspond",
"to",
"the",
"supplied",
"table",
")",
"."
] |
train
|
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/JORARepository.java#L266-L279
|
google/j2objc
|
jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java
|
BigDecimal.longLongCompareMagnitude
|
private static boolean longLongCompareMagnitude(long hi0, long lo0, long hi1, long lo1) {
"""
/*
returns true if 128 bit number <hi0,lo0> is less then <hi1,lo1>
hi0 & hi1 should be non-negative
"""
if(hi0!=hi1) {
return hi0<hi1;
}
return (lo0+Long.MIN_VALUE) <(lo1+Long.MIN_VALUE);
}
|
java
|
private static boolean longLongCompareMagnitude(long hi0, long lo0, long hi1, long lo1) {
if(hi0!=hi1) {
return hi0<hi1;
}
return (lo0+Long.MIN_VALUE) <(lo1+Long.MIN_VALUE);
}
|
[
"private",
"static",
"boolean",
"longLongCompareMagnitude",
"(",
"long",
"hi0",
",",
"long",
"lo0",
",",
"long",
"hi1",
",",
"long",
"lo1",
")",
"{",
"if",
"(",
"hi0",
"!=",
"hi1",
")",
"{",
"return",
"hi0",
"<",
"hi1",
";",
"}",
"return",
"(",
"lo0",
"+",
"Long",
".",
"MIN_VALUE",
")",
"<",
"(",
"lo1",
"+",
"Long",
".",
"MIN_VALUE",
")",
";",
"}"
] |
/*
returns true if 128 bit number <hi0,lo0> is less then <hi1,lo1>
hi0 & hi1 should be non-negative
|
[
"/",
"*",
"returns",
"true",
"if",
"128",
"bit",
"number",
"<hi0",
"lo0",
">",
"is",
"less",
"then",
"<hi1",
"lo1",
">",
"hi0",
"&",
"hi1",
"should",
"be",
"non",
"-",
"negative"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java#L5141-L5146
|
Azure/azure-sdk-for-java
|
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java
|
KeyVaultClientBaseImpl.purgeDeletedStorageAccount
|
public void purgeDeletedStorageAccount(String vaultBaseUrl, String storageAccountName) {
"""
Permanently deletes the specified storage account.
The purge deleted storage account operation removes the secret permanently, without the possibility of recovery. This operation can only be performed on a soft-delete enabled vault. This operation requires the storage/purge permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
purgeDeletedStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName).toBlocking().single().body();
}
|
java
|
public void purgeDeletedStorageAccount(String vaultBaseUrl, String storageAccountName) {
purgeDeletedStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName).toBlocking().single().body();
}
|
[
"public",
"void",
"purgeDeletedStorageAccount",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"storageAccountName",
")",
"{",
"purgeDeletedStorageAccountWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"storageAccountName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Permanently deletes the specified storage account.
The purge deleted storage account operation removes the secret permanently, without the possibility of recovery. This operation can only be performed on a soft-delete enabled vault. This operation requires the storage/purge permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws KeyVaultErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
|
[
"Permanently",
"deletes",
"the",
"specified",
"storage",
"account",
".",
"The",
"purge",
"deleted",
"storage",
"account",
"operation",
"removes",
"the",
"secret",
"permanently",
"without",
"the",
"possibility",
"of",
"recovery",
".",
"This",
"operation",
"can",
"only",
"be",
"performed",
"on",
"a",
"soft",
"-",
"delete",
"enabled",
"vault",
".",
"This",
"operation",
"requires",
"the",
"storage",
"/",
"purge",
"permission",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L9344-L9346
|
intellimate/Izou
|
src/main/java/org/intellimate/izou/support/SystemMail.java
|
SystemMail.sendMail
|
public void sendMail(String toAddress, String subject, String content, String attachmentName,
String attachmentPath) {
"""
Sends a mail to the address of {@code toAddress} with a subject of {@code subject} and a content of
{@code content} with an attachment
@param toAddress the address to send the mail to
@param subject the subject of the email to send
@param content the content of the email (without attachment)
@param attachmentName the name of the attachment
@param attachmentPath the file path to the attachment
"""
final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
logger.debug("Sending mail...");
Properties props = System.getProperties();
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
props.setProperty("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.port", "465");
props.setProperty("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.store.protocol", "pop3");
props.put("mail.transport.protocol", "smtp");
final String username = "[email protected]";
final String password = "Karlskrone"; // TODO: hide this when password stuff is done
try{
Session session = Session.getDefaultInstance(props, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(username));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toAddress));
message.setSubject(subject);
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Now set the actual message
messageBodyPart.setText(content);
// Create a multipart message
Multipart multipart = new MimeMultipart();
// Set text message part
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(attachmentPath);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(attachmentName);
multipart.addBodyPart(messageBodyPart);
// Send the complete message parts
message.setContent(multipart);
// Send message
Transport.send(message);
logger.debug("Mail sent successfully.");
} catch (MessagingException e) {
logger.error("Unable to send error report.", e);
}
}
|
java
|
public void sendMail(String toAddress, String subject, String content, String attachmentName,
String attachmentPath) {
final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
logger.debug("Sending mail...");
Properties props = System.getProperties();
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
props.setProperty("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.port", "465");
props.setProperty("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.store.protocol", "pop3");
props.put("mail.transport.protocol", "smtp");
final String username = "[email protected]";
final String password = "Karlskrone"; // TODO: hide this when password stuff is done
try{
Session session = Session.getDefaultInstance(props, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(username));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toAddress));
message.setSubject(subject);
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Now set the actual message
messageBodyPart.setText(content);
// Create a multipart message
Multipart multipart = new MimeMultipart();
// Set text message part
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(attachmentPath);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(attachmentName);
multipart.addBodyPart(messageBodyPart);
// Send the complete message parts
message.setContent(multipart);
// Send message
Transport.send(message);
logger.debug("Mail sent successfully.");
} catch (MessagingException e) {
logger.error("Unable to send error report.", e);
}
}
|
[
"public",
"void",
"sendMail",
"(",
"String",
"toAddress",
",",
"String",
"subject",
",",
"String",
"content",
",",
"String",
"attachmentName",
",",
"String",
"attachmentPath",
")",
"{",
"final",
"String",
"SSL_FACTORY",
"=",
"\"javax.net.ssl.SSLSocketFactory\"",
";",
"logger",
".",
"debug",
"(",
"\"Sending mail...\"",
")",
";",
"Properties",
"props",
"=",
"System",
".",
"getProperties",
"(",
")",
";",
"props",
".",
"setProperty",
"(",
"\"mail.smtp.host\"",
",",
"\"smtp.gmail.com\"",
")",
";",
"props",
".",
"setProperty",
"(",
"\"mail.smtp.socketFactory.class\"",
",",
"SSL_FACTORY",
")",
";",
"props",
".",
"setProperty",
"(",
"\"mail.smtp.socketFactory.fallback\"",
",",
"\"false\"",
")",
";",
"props",
".",
"setProperty",
"(",
"\"mail.smtp.port\"",
",",
"\"465\"",
")",
";",
"props",
".",
"setProperty",
"(",
"\"mail.smtp.socketFactory.port\"",
",",
"\"465\"",
")",
";",
"props",
".",
"put",
"(",
"\"mail.smtp.auth\"",
",",
"\"true\"",
")",
";",
"props",
".",
"put",
"(",
"\"mail.debug\"",
",",
"\"true\"",
")",
";",
"props",
".",
"put",
"(",
"\"mail.store.protocol\"",
",",
"\"pop3\"",
")",
";",
"props",
".",
"put",
"(",
"\"mail.transport.protocol\"",
",",
"\"smtp\"",
")",
";",
"final",
"String",
"username",
"=",
"\"[email protected]\"",
";",
"final",
"String",
"password",
"=",
"\"Karlskrone\"",
";",
"// TODO: hide this when password stuff is done",
"try",
"{",
"Session",
"session",
"=",
"Session",
".",
"getDefaultInstance",
"(",
"props",
",",
"new",
"Authenticator",
"(",
")",
"{",
"protected",
"PasswordAuthentication",
"getPasswordAuthentication",
"(",
")",
"{",
"return",
"new",
"PasswordAuthentication",
"(",
"username",
",",
"password",
")",
";",
"}",
"}",
")",
";",
"MimeMessage",
"message",
"=",
"new",
"MimeMessage",
"(",
"session",
")",
";",
"message",
".",
"setFrom",
"(",
"new",
"InternetAddress",
"(",
"username",
")",
")",
";",
"message",
".",
"addRecipient",
"(",
"Message",
".",
"RecipientType",
".",
"TO",
",",
"new",
"InternetAddress",
"(",
"toAddress",
")",
")",
";",
"message",
".",
"setSubject",
"(",
"subject",
")",
";",
"// Create the message part",
"BodyPart",
"messageBodyPart",
"=",
"new",
"MimeBodyPart",
"(",
")",
";",
"// Now set the actual message",
"messageBodyPart",
".",
"setText",
"(",
"content",
")",
";",
"// Create a multipart message",
"Multipart",
"multipart",
"=",
"new",
"MimeMultipart",
"(",
")",
";",
"// Set text message part",
"multipart",
".",
"addBodyPart",
"(",
"messageBodyPart",
")",
";",
"// Part two is attachment",
"messageBodyPart",
"=",
"new",
"MimeBodyPart",
"(",
")",
";",
"DataSource",
"source",
"=",
"new",
"FileDataSource",
"(",
"attachmentPath",
")",
";",
"messageBodyPart",
".",
"setDataHandler",
"(",
"new",
"DataHandler",
"(",
"source",
")",
")",
";",
"messageBodyPart",
".",
"setFileName",
"(",
"attachmentName",
")",
";",
"multipart",
".",
"addBodyPart",
"(",
"messageBodyPart",
")",
";",
"// Send the complete message parts",
"message",
".",
"setContent",
"(",
"multipart",
")",
";",
"// Send message",
"Transport",
".",
"send",
"(",
"message",
")",
";",
"logger",
".",
"debug",
"(",
"\"Mail sent successfully.\"",
")",
";",
"}",
"catch",
"(",
"MessagingException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Unable to send error report.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Sends a mail to the address of {@code toAddress} with a subject of {@code subject} and a content of
{@code content} with an attachment
@param toAddress the address to send the mail to
@param subject the subject of the email to send
@param content the content of the email (without attachment)
@param attachmentName the name of the attachment
@param attachmentPath the file path to the attachment
|
[
"Sends",
"a",
"mail",
"to",
"the",
"address",
"of",
"{",
"@code",
"toAddress",
"}",
"with",
"a",
"subject",
"of",
"{",
"@code",
"subject",
"}",
"and",
"a",
"content",
"of",
"{",
"@code",
"content",
"}",
"with",
"an",
"attachment"
] |
train
|
https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/support/SystemMail.java#L66-L125
|
apache/incubator-shardingsphere
|
sharding-core/sharding-core-route/src/main/java/org/apache/shardingsphere/core/route/SQLLogger.java
|
SQLLogger.logSQL
|
public static void logSQL(final String logicSQL, final boolean showSimple, final SQLStatement sqlStatement, final Collection<RouteUnit> routeUnits) {
"""
Print SQL log for sharding rule.
@param logicSQL logic SQL
@param showSimple whether show SQL in simple style
@param sqlStatement SQL statement
@param routeUnits route units
"""
log("Rule Type: sharding");
log("Logic SQL: {}", logicSQL);
log("SQLStatement: {}", sqlStatement);
if (showSimple) {
logSimpleMode(routeUnits);
} else {
logNormalMode(routeUnits);
}
}
|
java
|
public static void logSQL(final String logicSQL, final boolean showSimple, final SQLStatement sqlStatement, final Collection<RouteUnit> routeUnits) {
log("Rule Type: sharding");
log("Logic SQL: {}", logicSQL);
log("SQLStatement: {}", sqlStatement);
if (showSimple) {
logSimpleMode(routeUnits);
} else {
logNormalMode(routeUnits);
}
}
|
[
"public",
"static",
"void",
"logSQL",
"(",
"final",
"String",
"logicSQL",
",",
"final",
"boolean",
"showSimple",
",",
"final",
"SQLStatement",
"sqlStatement",
",",
"final",
"Collection",
"<",
"RouteUnit",
">",
"routeUnits",
")",
"{",
"log",
"(",
"\"Rule Type: sharding\"",
")",
";",
"log",
"(",
"\"Logic SQL: {}\"",
",",
"logicSQL",
")",
";",
"log",
"(",
"\"SQLStatement: {}\"",
",",
"sqlStatement",
")",
";",
"if",
"(",
"showSimple",
")",
"{",
"logSimpleMode",
"(",
"routeUnits",
")",
";",
"}",
"else",
"{",
"logNormalMode",
"(",
"routeUnits",
")",
";",
"}",
"}"
] |
Print SQL log for sharding rule.
@param logicSQL logic SQL
@param showSimple whether show SQL in simple style
@param sqlStatement SQL statement
@param routeUnits route units
|
[
"Print",
"SQL",
"log",
"for",
"sharding",
"rule",
"."
] |
train
|
https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-route/src/main/java/org/apache/shardingsphere/core/route/SQLLogger.java#L59-L68
|
nakamura5akihito/six-util
|
src/main/java/jp/go/aist/six/util/search/RelationalBinding.java
|
RelationalBinding.greaterEqualBinding
|
public static RelationalBinding greaterEqualBinding(
final String property,
final Object value
) {
"""
Creates a 'GREATER_EQUAL' binding.
@param property
the property.
@param value
the value to which the property should be related.
@return
a 'GREATER_EQUAL' binding.
"""
return (new RelationalBinding( property, Relation.GREATER_EQUAL, value ));
}
|
java
|
public static RelationalBinding greaterEqualBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.GREATER_EQUAL, value ));
}
|
[
"public",
"static",
"RelationalBinding",
"greaterEqualBinding",
"(",
"final",
"String",
"property",
",",
"final",
"Object",
"value",
")",
"{",
"return",
"(",
"new",
"RelationalBinding",
"(",
"property",
",",
"Relation",
".",
"GREATER_EQUAL",
",",
"value",
")",
")",
";",
"}"
] |
Creates a 'GREATER_EQUAL' binding.
@param property
the property.
@param value
the value to which the property should be related.
@return
a 'GREATER_EQUAL' binding.
|
[
"Creates",
"a",
"GREATER_EQUAL",
"binding",
"."
] |
train
|
https://github.com/nakamura5akihito/six-util/blob/a6db388a345e220cea2b1fa6324d15c80c6278b6/src/main/java/jp/go/aist/six/util/search/RelationalBinding.java#L150-L156
|
twitter/cloudhopper-commons
|
ch-commons-util/src/main/java/com/cloudhopper/commons/util/HexUtil.java
|
HexUtil.appendHexString
|
static public void appendHexString(StringBuilder buffer, byte[] bytes, int offset, int length) {
"""
Appends a byte array to a StringBuilder with each byte in a "Big Endian"
hexidecimal format. For example, a byte 0x34 will be appended as a
String in format "34". A byte array of { 0x34, 035 } would append "3435".
@param buffer The StringBuilder the byte array in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.
@param bytes The byte array that will be converted to a hexidecimal String.
If the byte array is null, this method will append nothing (a noop)
@param offset The offset in the byte array to start from. If the offset
or length combination is invalid, this method will throw an IllegalArgumentException.
@param length The length (from the offset) to conver the bytes. If the offset
or length combination is invalid, this method will throw an IllegalArgumentException.
"""
assertNotNull(buffer);
if (bytes == null) {
return; // do nothing (a noop)
}
assertOffsetLengthValid(offset, length, bytes.length);
int end = offset + length;
for (int i = offset; i < end; i++) {
int nibble1 = (bytes[i] & 0xF0) >>> 4;
int nibble0 = (bytes[i] & 0x0F);
buffer.append(HEX_TABLE[nibble1]);
buffer.append(HEX_TABLE[nibble0]);
}
}
|
java
|
static public void appendHexString(StringBuilder buffer, byte[] bytes, int offset, int length) {
assertNotNull(buffer);
if (bytes == null) {
return; // do nothing (a noop)
}
assertOffsetLengthValid(offset, length, bytes.length);
int end = offset + length;
for (int i = offset; i < end; i++) {
int nibble1 = (bytes[i] & 0xF0) >>> 4;
int nibble0 = (bytes[i] & 0x0F);
buffer.append(HEX_TABLE[nibble1]);
buffer.append(HEX_TABLE[nibble0]);
}
}
|
[
"static",
"public",
"void",
"appendHexString",
"(",
"StringBuilder",
"buffer",
",",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"assertNotNull",
"(",
"buffer",
")",
";",
"if",
"(",
"bytes",
"==",
"null",
")",
"{",
"return",
";",
"// do nothing (a noop)",
"}",
"assertOffsetLengthValid",
"(",
"offset",
",",
"length",
",",
"bytes",
".",
"length",
")",
";",
"int",
"end",
"=",
"offset",
"+",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"offset",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"{",
"int",
"nibble1",
"=",
"(",
"bytes",
"[",
"i",
"]",
"&",
"0xF0",
")",
">>>",
"4",
";",
"int",
"nibble0",
"=",
"(",
"bytes",
"[",
"i",
"]",
"&",
"0x0F",
")",
";",
"buffer",
".",
"append",
"(",
"HEX_TABLE",
"[",
"nibble1",
"]",
")",
";",
"buffer",
".",
"append",
"(",
"HEX_TABLE",
"[",
"nibble0",
"]",
")",
";",
"}",
"}"
] |
Appends a byte array to a StringBuilder with each byte in a "Big Endian"
hexidecimal format. For example, a byte 0x34 will be appended as a
String in format "34". A byte array of { 0x34, 035 } would append "3435".
@param buffer The StringBuilder the byte array in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.
@param bytes The byte array that will be converted to a hexidecimal String.
If the byte array is null, this method will append nothing (a noop)
@param offset The offset in the byte array to start from. If the offset
or length combination is invalid, this method will throw an IllegalArgumentException.
@param length The length (from the offset) to conver the bytes. If the offset
or length combination is invalid, this method will throw an IllegalArgumentException.
|
[
"Appends",
"a",
"byte",
"array",
"to",
"a",
"StringBuilder",
"with",
"each",
"byte",
"in",
"a",
"Big",
"Endian",
"hexidecimal",
"format",
".",
"For",
"example",
"a",
"byte",
"0x34",
"will",
"be",
"appended",
"as",
"a",
"String",
"in",
"format",
"34",
".",
"A",
"byte",
"array",
"of",
"{",
"0x34",
"035",
"}",
"would",
"append",
"3435",
"."
] |
train
|
https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-commons-util/src/main/java/com/cloudhopper/commons/util/HexUtil.java#L108-L121
|
forge/core
|
javaee/scaffold-faces/src/main/java/org/jboss/forge/addon/scaffold/faces/freemarker/FreemarkerTemplateProcessor.java
|
FreemarkerTemplateProcessor.processTemplate
|
public static String processTemplate(Map<Object, Object> map, String templateLocation) {
"""
Processes the provided data model with the specified Freemarker template
@param map the data model to use for template processing.
@param templateLocation The location of the template relative to the classpath
@return The text output after successfully processing the template
"""
Writer output = new StringWriter();
try
{
Template templateFile = getFreemarkerConfig().getTemplate(templateLocation);
templateFile.process(map, output);
output.flush();
}
catch (IOException ioEx)
{
throw new RuntimeException(ioEx);
}
catch (TemplateException templateEx)
{
throw new RuntimeException(templateEx);
}
return output.toString();
}
|
java
|
public static String processTemplate(Map<Object, Object> map, String templateLocation)
{
Writer output = new StringWriter();
try
{
Template templateFile = getFreemarkerConfig().getTemplate(templateLocation);
templateFile.process(map, output);
output.flush();
}
catch (IOException ioEx)
{
throw new RuntimeException(ioEx);
}
catch (TemplateException templateEx)
{
throw new RuntimeException(templateEx);
}
return output.toString();
}
|
[
"public",
"static",
"String",
"processTemplate",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"map",
",",
"String",
"templateLocation",
")",
"{",
"Writer",
"output",
"=",
"new",
"StringWriter",
"(",
")",
";",
"try",
"{",
"Template",
"templateFile",
"=",
"getFreemarkerConfig",
"(",
")",
".",
"getTemplate",
"(",
"templateLocation",
")",
";",
"templateFile",
".",
"process",
"(",
"map",
",",
"output",
")",
";",
"output",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioEx",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ioEx",
")",
";",
"}",
"catch",
"(",
"TemplateException",
"templateEx",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"templateEx",
")",
";",
"}",
"return",
"output",
".",
"toString",
"(",
")",
";",
"}"
] |
Processes the provided data model with the specified Freemarker template
@param map the data model to use for template processing.
@param templateLocation The location of the template relative to the classpath
@return The text output after successfully processing the template
|
[
"Processes",
"the",
"provided",
"data",
"model",
"with",
"the",
"specified",
"Freemarker",
"template"
] |
train
|
https://github.com/forge/core/blob/e140eb03bbe2b3409478ad70c86c3edbef6d9a0c/javaee/scaffold-faces/src/main/java/org/jboss/forge/addon/scaffold/faces/freemarker/FreemarkerTemplateProcessor.java#L53-L71
|
rzwitserloot/lombok
|
src/core/lombok/javac/handlers/JavacHandlerUtil.java
|
JavacHandlerUtil.injectField
|
public static JavacNode injectField(JavacNode typeNode, JCVariableDecl field) {
"""
Adds the given new field declaration to the provided type AST Node.
Also takes care of updating the JavacAST.
"""
return injectField(typeNode, field, false);
}
|
java
|
public static JavacNode injectField(JavacNode typeNode, JCVariableDecl field) {
return injectField(typeNode, field, false);
}
|
[
"public",
"static",
"JavacNode",
"injectField",
"(",
"JavacNode",
"typeNode",
",",
"JCVariableDecl",
"field",
")",
"{",
"return",
"injectField",
"(",
"typeNode",
",",
"field",
",",
"false",
")",
";",
"}"
] |
Adds the given new field declaration to the provided type AST Node.
Also takes care of updating the JavacAST.
|
[
"Adds",
"the",
"given",
"new",
"field",
"declaration",
"to",
"the",
"provided",
"type",
"AST",
"Node",
"."
] |
train
|
https://github.com/rzwitserloot/lombok/blob/75601240760bd81ff95fcde7a1b8185769ce64e8/src/core/lombok/javac/handlers/JavacHandlerUtil.java#L1015-L1017
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/component/ShuttleList.java
|
ShuttleList.setEditIcon
|
public void setEditIcon(Icon editIcon, String text) {
"""
Set the icon to use on the edit button. If no icon is specified, then
just the label will be used otherwise the text will be a tooltip.
@param editIcon Icon to use on edit button
"""
if (editIcon != null) {
editButton.setIcon(editIcon);
if (text != null) {
editButton.setToolTipText(text);
}
editButton.setText("");
} else {
editButton.setIcon(null);
if (text != null) {
editButton.setText(text);
}
}
}
|
java
|
public void setEditIcon(Icon editIcon, String text) {
if (editIcon != null) {
editButton.setIcon(editIcon);
if (text != null) {
editButton.setToolTipText(text);
}
editButton.setText("");
} else {
editButton.setIcon(null);
if (text != null) {
editButton.setText(text);
}
}
}
|
[
"public",
"void",
"setEditIcon",
"(",
"Icon",
"editIcon",
",",
"String",
"text",
")",
"{",
"if",
"(",
"editIcon",
"!=",
"null",
")",
"{",
"editButton",
".",
"setIcon",
"(",
"editIcon",
")",
";",
"if",
"(",
"text",
"!=",
"null",
")",
"{",
"editButton",
".",
"setToolTipText",
"(",
"text",
")",
";",
"}",
"editButton",
".",
"setText",
"(",
"\"\"",
")",
";",
"}",
"else",
"{",
"editButton",
".",
"setIcon",
"(",
"null",
")",
";",
"if",
"(",
"text",
"!=",
"null",
")",
"{",
"editButton",
".",
"setText",
"(",
"text",
")",
";",
"}",
"}",
"}"
] |
Set the icon to use on the edit button. If no icon is specified, then
just the label will be used otherwise the text will be a tooltip.
@param editIcon Icon to use on edit button
|
[
"Set",
"the",
"icon",
"to",
"use",
"on",
"the",
"edit",
"button",
".",
"If",
"no",
"icon",
"is",
"specified",
"then",
"just",
"the",
"label",
"will",
"be",
"used",
"otherwise",
"the",
"text",
"will",
"be",
"a",
"tooltip",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/component/ShuttleList.java#L200-L213
|
twitter/hraven
|
hraven-core/src/main/java/com/twitter/hraven/util/BatchUtil.java
|
BatchUtil.shouldRetain
|
public static boolean shouldRetain(int i, int maxRetention, int length) {
"""
Method that can be used when iterating over an array and you want to retain
only maxRetention items.
@param i
index of element in ordered array of length
@param maxRetention
total number of elements to retain.
@param length
of the ordered array
@return whether this element should be retained or not.
"""
// Files with a zero-based index greater or equal than the retentionCutoff
// should be retained.
int retentionCutoff = length - maxRetention;
boolean retain = (i >= retentionCutoff) ? true : false;
return retain;
}
|
java
|
public static boolean shouldRetain(int i, int maxRetention, int length) {
// Files with a zero-based index greater or equal than the retentionCutoff
// should be retained.
int retentionCutoff = length - maxRetention;
boolean retain = (i >= retentionCutoff) ? true : false;
return retain;
}
|
[
"public",
"static",
"boolean",
"shouldRetain",
"(",
"int",
"i",
",",
"int",
"maxRetention",
",",
"int",
"length",
")",
"{",
"// Files with a zero-based index greater or equal than the retentionCutoff",
"// should be retained.",
"int",
"retentionCutoff",
"=",
"length",
"-",
"maxRetention",
";",
"boolean",
"retain",
"=",
"(",
"i",
">=",
"retentionCutoff",
")",
"?",
"true",
":",
"false",
";",
"return",
"retain",
";",
"}"
] |
Method that can be used when iterating over an array and you want to retain
only maxRetention items.
@param i
index of element in ordered array of length
@param maxRetention
total number of elements to retain.
@param length
of the ordered array
@return whether this element should be retained or not.
|
[
"Method",
"that",
"can",
"be",
"used",
"when",
"iterating",
"over",
"an",
"array",
"and",
"you",
"want",
"to",
"retain",
"only",
"maxRetention",
"items",
"."
] |
train
|
https://github.com/twitter/hraven/blob/e35996b6e2f016bcd18db0bad320be7c93d95208/hraven-core/src/main/java/com/twitter/hraven/util/BatchUtil.java#L41-L47
|
mapfish/mapfish-print
|
core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java
|
GridUtils.createLabel
|
public static String createLabel(final double value, final String unit, final GridLabelFormat format) {
"""
Create the label for a grid line.
@param value the value of the line
@param unit the unit that the value is in
"""
final double zero = 0.000000001;
if (format != null) {
return format.format(value, unit);
} else {
if (Math.abs(value - Math.round(value)) < zero) {
return String.format("%d %s", Math.round(value), unit);
} else if ("m".equals(unit)) {
// meter: no decimals
return String.format("%1.0f %s", value, unit);
} else if (NonSI.DEGREE_ANGLE.toString().equals(unit)) {
// degree: by default 6 decimals
return String.format("%1.6f %s", value, unit);
} else {
return String.format("%f %s", value, unit);
}
}
}
|
java
|
public static String createLabel(final double value, final String unit, final GridLabelFormat format) {
final double zero = 0.000000001;
if (format != null) {
return format.format(value, unit);
} else {
if (Math.abs(value - Math.round(value)) < zero) {
return String.format("%d %s", Math.round(value), unit);
} else if ("m".equals(unit)) {
// meter: no decimals
return String.format("%1.0f %s", value, unit);
} else if (NonSI.DEGREE_ANGLE.toString().equals(unit)) {
// degree: by default 6 decimals
return String.format("%1.6f %s", value, unit);
} else {
return String.format("%f %s", value, unit);
}
}
}
|
[
"public",
"static",
"String",
"createLabel",
"(",
"final",
"double",
"value",
",",
"final",
"String",
"unit",
",",
"final",
"GridLabelFormat",
"format",
")",
"{",
"final",
"double",
"zero",
"=",
"0.000000001",
";",
"if",
"(",
"format",
"!=",
"null",
")",
"{",
"return",
"format",
".",
"format",
"(",
"value",
",",
"unit",
")",
";",
"}",
"else",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"value",
"-",
"Math",
".",
"round",
"(",
"value",
")",
")",
"<",
"zero",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%d %s\"",
",",
"Math",
".",
"round",
"(",
"value",
")",
",",
"unit",
")",
";",
"}",
"else",
"if",
"(",
"\"m\"",
".",
"equals",
"(",
"unit",
")",
")",
"{",
"// meter: no decimals",
"return",
"String",
".",
"format",
"(",
"\"%1.0f %s\"",
",",
"value",
",",
"unit",
")",
";",
"}",
"else",
"if",
"(",
"NonSI",
".",
"DEGREE_ANGLE",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"unit",
")",
")",
"{",
"// degree: by default 6 decimals",
"return",
"String",
".",
"format",
"(",
"\"%1.6f %s\"",
",",
"value",
",",
"unit",
")",
";",
"}",
"else",
"{",
"return",
"String",
".",
"format",
"(",
"\"%f %s\"",
",",
"value",
",",
"unit",
")",
";",
"}",
"}",
"}"
] |
Create the label for a grid line.
@param value the value of the line
@param unit the unit that the value is in
|
[
"Create",
"the",
"label",
"for",
"a",
"grid",
"line",
"."
] |
train
|
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/GridUtils.java#L106-L123
|
GwtMaterialDesign/gwt-material
|
gwt-material/src/main/java/gwt/material/design/client/ui/MaterialListValueBox.java
|
MaterialListValueBox.insertItem
|
public void insertItem(T value, String text, int index) {
"""
Inserts an item into the list box, specifying an initial value for the
item. Has the same effect as
<pre>insertItem(value, null, item, index)</pre>
@param value the item's value, to be submitted if it is part of a
{@link FormPanel}.
@param text the text of the item to be inserted
@param index the index at which to insert it
"""
insertItemInternal(value, text, index, true);
}
|
java
|
public void insertItem(T value, String text, int index) {
insertItemInternal(value, text, index, true);
}
|
[
"public",
"void",
"insertItem",
"(",
"T",
"value",
",",
"String",
"text",
",",
"int",
"index",
")",
"{",
"insertItemInternal",
"(",
"value",
",",
"text",
",",
"index",
",",
"true",
")",
";",
"}"
] |
Inserts an item into the list box, specifying an initial value for the
item. Has the same effect as
<pre>insertItem(value, null, item, index)</pre>
@param value the item's value, to be submitted if it is part of a
{@link FormPanel}.
@param text the text of the item to be inserted
@param index the index at which to insert it
|
[
"Inserts",
"an",
"item",
"into",
"the",
"list",
"box",
"specifying",
"an",
"initial",
"value",
"for",
"the",
"item",
".",
"Has",
"the",
"same",
"effect",
"as",
"<pre",
">",
"insertItem",
"(",
"value",
"null",
"item",
"index",
")",
"<",
"/",
"pre",
">"
] |
train
|
https://github.com/GwtMaterialDesign/gwt-material/blob/86feefb282b007c0a44784c09e651a50f257138e/gwt-material/src/main/java/gwt/material/design/client/ui/MaterialListValueBox.java#L383-L385
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java
|
ExpressionUtils.neConst
|
public static <D> Predicate neConst(Expression<D> left, D constant) {
"""
Create a {@code left != constant} expression
@param <D> type of expression
@param left lhs of expression
@param constant rhs of expression
@return left != constant
"""
return ne(left, ConstantImpl.create(constant));
}
|
java
|
public static <D> Predicate neConst(Expression<D> left, D constant) {
return ne(left, ConstantImpl.create(constant));
}
|
[
"public",
"static",
"<",
"D",
">",
"Predicate",
"neConst",
"(",
"Expression",
"<",
"D",
">",
"left",
",",
"D",
"constant",
")",
"{",
"return",
"ne",
"(",
"left",
",",
"ConstantImpl",
".",
"create",
"(",
"constant",
")",
")",
";",
"}"
] |
Create a {@code left != constant} expression
@param <D> type of expression
@param left lhs of expression
@param constant rhs of expression
@return left != constant
|
[
"Create",
"a",
"{",
"@code",
"left",
"!",
"=",
"constant",
"}",
"expression"
] |
train
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java#L707-L709
|
apache/incubator-druid
|
sql/src/main/java/org/apache/druid/sql/calcite/rel/PartialDruidQuery.java
|
PartialDruidQuery.leafRel
|
public RelNode leafRel() {
"""
Returns the rel at the end of the query. It will match the stage returned from {@link #stage()}.
@return leaf rel
"""
final Stage currentStage = stage();
switch (currentStage) {
case SORT_PROJECT:
return sortProject;
case SORT:
return sort;
case AGGREGATE_PROJECT:
return aggregateProject;
case HAVING_FILTER:
return havingFilter;
case AGGREGATE:
return aggregate;
case SELECT_SORT:
return selectSort;
case SELECT_PROJECT:
return selectProject;
case WHERE_FILTER:
return whereFilter;
case SCAN:
return scan;
default:
throw new ISE("WTF?! Unknown stage: %s", currentStage);
}
}
|
java
|
public RelNode leafRel()
{
final Stage currentStage = stage();
switch (currentStage) {
case SORT_PROJECT:
return sortProject;
case SORT:
return sort;
case AGGREGATE_PROJECT:
return aggregateProject;
case HAVING_FILTER:
return havingFilter;
case AGGREGATE:
return aggregate;
case SELECT_SORT:
return selectSort;
case SELECT_PROJECT:
return selectProject;
case WHERE_FILTER:
return whereFilter;
case SCAN:
return scan;
default:
throw new ISE("WTF?! Unknown stage: %s", currentStage);
}
}
|
[
"public",
"RelNode",
"leafRel",
"(",
")",
"{",
"final",
"Stage",
"currentStage",
"=",
"stage",
"(",
")",
";",
"switch",
"(",
"currentStage",
")",
"{",
"case",
"SORT_PROJECT",
":",
"return",
"sortProject",
";",
"case",
"SORT",
":",
"return",
"sort",
";",
"case",
"AGGREGATE_PROJECT",
":",
"return",
"aggregateProject",
";",
"case",
"HAVING_FILTER",
":",
"return",
"havingFilter",
";",
"case",
"AGGREGATE",
":",
"return",
"aggregate",
";",
"case",
"SELECT_SORT",
":",
"return",
"selectSort",
";",
"case",
"SELECT_PROJECT",
":",
"return",
"selectProject",
";",
"case",
"WHERE_FILTER",
":",
"return",
"whereFilter",
";",
"case",
"SCAN",
":",
"return",
"scan",
";",
"default",
":",
"throw",
"new",
"ISE",
"(",
"\"WTF?! Unknown stage: %s\"",
",",
"currentStage",
")",
";",
"}",
"}"
] |
Returns the rel at the end of the query. It will match the stage returned from {@link #stage()}.
@return leaf rel
|
[
"Returns",
"the",
"rel",
"at",
"the",
"end",
"of",
"the",
"query",
".",
"It",
"will",
"match",
"the",
"stage",
"returned",
"from",
"{",
"@link",
"#stage",
"()",
"}",
"."
] |
train
|
https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/sql/src/main/java/org/apache/druid/sql/calcite/rel/PartialDruidQuery.java#L397-L423
|
banq/jdonframework
|
src/main/java/com/jdon/util/RequestUtil.java
|
RequestUtil.setCookie
|
public static void setCookie(HttpServletResponse response, String name, String value, String path) {
"""
Convenience method to set a cookie
@param response
@param name
@param value
@param path
@return HttpServletResponse
"""
Cookie cookie = new Cookie(name, value);
cookie.setSecure(false);
cookie.setPath(path);
cookie.setMaxAge(3600 * 24 * 30); // 30 days
response.addCookie(cookie);
}
|
java
|
public static void setCookie(HttpServletResponse response, String name, String value, String path) {
Cookie cookie = new Cookie(name, value);
cookie.setSecure(false);
cookie.setPath(path);
cookie.setMaxAge(3600 * 24 * 30); // 30 days
response.addCookie(cookie);
}
|
[
"public",
"static",
"void",
"setCookie",
"(",
"HttpServletResponse",
"response",
",",
"String",
"name",
",",
"String",
"value",
",",
"String",
"path",
")",
"{",
"Cookie",
"cookie",
"=",
"new",
"Cookie",
"(",
"name",
",",
"value",
")",
";",
"cookie",
".",
"setSecure",
"(",
"false",
")",
";",
"cookie",
".",
"setPath",
"(",
"path",
")",
";",
"cookie",
".",
"setMaxAge",
"(",
"3600",
"*",
"24",
"*",
"30",
")",
";",
"// 30 days\r",
"response",
".",
"addCookie",
"(",
"cookie",
")",
";",
"}"
] |
Convenience method to set a cookie
@param response
@param name
@param value
@param path
@return HttpServletResponse
|
[
"Convenience",
"method",
"to",
"set",
"a",
"cookie"
] |
train
|
https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/RequestUtil.java#L182-L190
|
Samsung/GearVRf
|
GVRf/Framework/framework/src/main/java/org/gearvrf/GVRShaderData.java
|
GVRShaderData.setTexture
|
public void setTexture(String key, GVRTexture texture) {
"""
Bind a {@link GVRTexture texture} to the shader uniform {@code key}.
@param key Name of the shader uniform to bind the texture to.
@param texture The {@link GVRTexture texture} to bind.
"""
checkStringNotNullOrEmpty("key", key);
synchronized (textures)
{
textures.put(key, texture);
NativeShaderData.setTexture(getNative(), key, texture != null ? texture.getNative() : 0);
}
}
|
java
|
public void setTexture(String key, GVRTexture texture)
{
checkStringNotNullOrEmpty("key", key);
synchronized (textures)
{
textures.put(key, texture);
NativeShaderData.setTexture(getNative(), key, texture != null ? texture.getNative() : 0);
}
}
|
[
"public",
"void",
"setTexture",
"(",
"String",
"key",
",",
"GVRTexture",
"texture",
")",
"{",
"checkStringNotNullOrEmpty",
"(",
"\"key\"",
",",
"key",
")",
";",
"synchronized",
"(",
"textures",
")",
"{",
"textures",
".",
"put",
"(",
"key",
",",
"texture",
")",
";",
"NativeShaderData",
".",
"setTexture",
"(",
"getNative",
"(",
")",
",",
"key",
",",
"texture",
"!=",
"null",
"?",
"texture",
".",
"getNative",
"(",
")",
":",
"0",
")",
";",
"}",
"}"
] |
Bind a {@link GVRTexture texture} to the shader uniform {@code key}.
@param key Name of the shader uniform to bind the texture to.
@param texture The {@link GVRTexture texture} to bind.
|
[
"Bind",
"a",
"{",
"@link",
"GVRTexture",
"texture",
"}",
"to",
"the",
"shader",
"uniform",
"{",
"@code",
"key",
"}",
"."
] |
train
|
https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRShaderData.java#L218-L226
|
febit/wit
|
wit-core/src/main/java/org/febit/wit/InternalContext.java
|
InternalContext.createSubContext
|
public InternalContext createSubContext(VariantIndexer[] indexers, InternalContext localContext, int varSize) {
"""
Create a sub context.
@param indexers indexers
@param localContext local context
@param varSize var size
@return a new sub context
"""
Object[][] myParentScopes = this.parentScopes;
//cal the new-context's parent-scopes
Object[][] scopes;
if (myParentScopes == null) {
scopes = new Object[][]{this.vars};
} else {
scopes = new Object[myParentScopes.length + 1][];
scopes[0] = this.vars;
System.arraycopy(myParentScopes, 0, scopes, 1, myParentScopes.length);
}
InternalContext newContext = new InternalContext(template, localContext.out, Vars.EMPTY,
indexers, varSize, scopes);
newContext.localContext = localContext;
return newContext;
}
|
java
|
public InternalContext createSubContext(VariantIndexer[] indexers, InternalContext localContext, int varSize) {
Object[][] myParentScopes = this.parentScopes;
//cal the new-context's parent-scopes
Object[][] scopes;
if (myParentScopes == null) {
scopes = new Object[][]{this.vars};
} else {
scopes = new Object[myParentScopes.length + 1][];
scopes[0] = this.vars;
System.arraycopy(myParentScopes, 0, scopes, 1, myParentScopes.length);
}
InternalContext newContext = new InternalContext(template, localContext.out, Vars.EMPTY,
indexers, varSize, scopes);
newContext.localContext = localContext;
return newContext;
}
|
[
"public",
"InternalContext",
"createSubContext",
"(",
"VariantIndexer",
"[",
"]",
"indexers",
",",
"InternalContext",
"localContext",
",",
"int",
"varSize",
")",
"{",
"Object",
"[",
"]",
"[",
"]",
"myParentScopes",
"=",
"this",
".",
"parentScopes",
";",
"//cal the new-context's parent-scopes",
"Object",
"[",
"]",
"[",
"]",
"scopes",
";",
"if",
"(",
"myParentScopes",
"==",
"null",
")",
"{",
"scopes",
"=",
"new",
"Object",
"[",
"]",
"[",
"]",
"{",
"this",
".",
"vars",
"}",
";",
"}",
"else",
"{",
"scopes",
"=",
"new",
"Object",
"[",
"myParentScopes",
".",
"length",
"+",
"1",
"]",
"[",
"",
"]",
";",
"scopes",
"[",
"0",
"]",
"=",
"this",
".",
"vars",
";",
"System",
".",
"arraycopy",
"(",
"myParentScopes",
",",
"0",
",",
"scopes",
",",
"1",
",",
"myParentScopes",
".",
"length",
")",
";",
"}",
"InternalContext",
"newContext",
"=",
"new",
"InternalContext",
"(",
"template",
",",
"localContext",
".",
"out",
",",
"Vars",
".",
"EMPTY",
",",
"indexers",
",",
"varSize",
",",
"scopes",
")",
";",
"newContext",
".",
"localContext",
"=",
"localContext",
";",
"return",
"newContext",
";",
"}"
] |
Create a sub context.
@param indexers indexers
@param localContext local context
@param varSize var size
@return a new sub context
|
[
"Create",
"a",
"sub",
"context",
"."
] |
train
|
https://github.com/febit/wit/blob/89ee29efbc5633b79c30c3c7b953c9f4130575af/wit-core/src/main/java/org/febit/wit/InternalContext.java#L129-L145
|
cdk/cdk
|
base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/VentoFoggia.java
|
VentoFoggia.findSubstructure
|
public static Pattern findSubstructure(IAtomContainer query, AtomMatcher atomMatcher, BondMatcher bondMatcher) {
"""
Create a pattern which can be used to find molecules which contain the
{@code query} structure.
@param query the substructure to find
@param atomMatcher how atoms are matched
@param bondMatcher how bonds are matched
@return a pattern for finding the {@code query}
"""
return new VentoFoggia(query, atomMatcher, bondMatcher, true);
}
|
java
|
public static Pattern findSubstructure(IAtomContainer query, AtomMatcher atomMatcher, BondMatcher bondMatcher) {
return new VentoFoggia(query, atomMatcher, bondMatcher, true);
}
|
[
"public",
"static",
"Pattern",
"findSubstructure",
"(",
"IAtomContainer",
"query",
",",
"AtomMatcher",
"atomMatcher",
",",
"BondMatcher",
"bondMatcher",
")",
"{",
"return",
"new",
"VentoFoggia",
"(",
"query",
",",
"atomMatcher",
",",
"bondMatcher",
",",
"true",
")",
";",
"}"
] |
Create a pattern which can be used to find molecules which contain the
{@code query} structure.
@param query the substructure to find
@param atomMatcher how atoms are matched
@param bondMatcher how bonds are matched
@return a pattern for finding the {@code query}
|
[
"Create",
"a",
"pattern",
"which",
"can",
"be",
"used",
"to",
"find",
"molecules",
"which",
"contain",
"the",
"{",
"@code",
"query",
"}",
"structure",
"."
] |
train
|
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/VentoFoggia.java#L184-L186
|
alkacon/opencms-core
|
src/org/opencms/util/CmsStringUtil.java
|
CmsStringUtil.lastIndexOf
|
public static int lastIndexOf(String source, char[] chars) {
"""
Returns the last index of any of the given chars in the given source.<p>
If no char is found, -1 is returned.<p>
@param source the source to check
@param chars the chars to find
@return the last index of any of the given chars in the given source, or -1
"""
// now try to find an "sentence ending" char in the text in the "findPointArea"
int result = -1;
for (int i = 0; i < chars.length; i++) {
int pos = source.lastIndexOf(chars[i]);
if (pos > result) {
// found new last char
result = pos;
}
}
return result;
}
|
java
|
public static int lastIndexOf(String source, char[] chars) {
// now try to find an "sentence ending" char in the text in the "findPointArea"
int result = -1;
for (int i = 0; i < chars.length; i++) {
int pos = source.lastIndexOf(chars[i]);
if (pos > result) {
// found new last char
result = pos;
}
}
return result;
}
|
[
"public",
"static",
"int",
"lastIndexOf",
"(",
"String",
"source",
",",
"char",
"[",
"]",
"chars",
")",
"{",
"// now try to find an \"sentence ending\" char in the text in the \"findPointArea\"",
"int",
"result",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"chars",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"pos",
"=",
"source",
".",
"lastIndexOf",
"(",
"chars",
"[",
"i",
"]",
")",
";",
"if",
"(",
"pos",
">",
"result",
")",
"{",
"// found new last char",
"result",
"=",
"pos",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Returns the last index of any of the given chars in the given source.<p>
If no char is found, -1 is returned.<p>
@param source the source to check
@param chars the chars to find
@return the last index of any of the given chars in the given source, or -1
|
[
"Returns",
"the",
"last",
"index",
"of",
"any",
"of",
"the",
"given",
"chars",
"in",
"the",
"given",
"source",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsStringUtil.java#L1225-L1237
|
apache/incubator-gobblin
|
gobblin-utility/src/main/java/org/apache/gobblin/util/concurrent/TaskScheduler.java
|
TaskScheduler.getScheduledTasks
|
public final Iterable<T> getScheduledTasks() {
"""
Gets all {@link ScheduledTask}s.
@return the {@link ScheduledTask}s
"""
return Iterables.transform(this.cancellableTaskMap.asMap().values(), new Function<CancellableTask<K, T>, T>() {
@Override
public T apply(CancellableTask<K, T> cancellableTask) {
return cancellableTask.getScheduledTask();
}
});
}
|
java
|
public final Iterable<T> getScheduledTasks() {
return Iterables.transform(this.cancellableTaskMap.asMap().values(), new Function<CancellableTask<K, T>, T>() {
@Override
public T apply(CancellableTask<K, T> cancellableTask) {
return cancellableTask.getScheduledTask();
}
});
}
|
[
"public",
"final",
"Iterable",
"<",
"T",
">",
"getScheduledTasks",
"(",
")",
"{",
"return",
"Iterables",
".",
"transform",
"(",
"this",
".",
"cancellableTaskMap",
".",
"asMap",
"(",
")",
".",
"values",
"(",
")",
",",
"new",
"Function",
"<",
"CancellableTask",
"<",
"K",
",",
"T",
">",
",",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"T",
"apply",
"(",
"CancellableTask",
"<",
"K",
",",
"T",
">",
"cancellableTask",
")",
"{",
"return",
"cancellableTask",
".",
"getScheduledTask",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets all {@link ScheduledTask}s.
@return the {@link ScheduledTask}s
|
[
"Gets",
"all",
"{",
"@link",
"ScheduledTask",
"}",
"s",
"."
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/concurrent/TaskScheduler.java#L110-L117
|
aws/aws-sdk-java
|
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/internal/MultiFileOutputStream.java
|
MultiFileOutputStream.write
|
@Override
public void write(byte[] b, int off, int len) throws IOException {
"""
{@inheritDoc}
This method would block as necessary if running out of disk space.
"""
if (b.length == 0)
return;
fos().write(b, off, len);
currFileBytesWritten += len;
totalBytesWritten += len;
}
|
java
|
@Override
public void write(byte[] b, int off, int len) throws IOException {
if (b.length == 0)
return;
fos().write(b, off, len);
currFileBytesWritten += len;
totalBytesWritten += len;
}
|
[
"@",
"Override",
"public",
"void",
"write",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"if",
"(",
"b",
".",
"length",
"==",
"0",
")",
"return",
";",
"fos",
"(",
")",
".",
"write",
"(",
"b",
",",
"off",
",",
"len",
")",
";",
"currFileBytesWritten",
"+=",
"len",
";",
"totalBytesWritten",
"+=",
"len",
";",
"}"
] |
{@inheritDoc}
This method would block as necessary if running out of disk space.
|
[
"{",
"@inheritDoc",
"}"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/internal/MultiFileOutputStream.java#L149-L156
|
craterdog/java-general-utilities
|
src/main/java/craterdog/utils/ByteUtils.java
|
ByteUtils.bytesToInt
|
static public int bytesToInt(byte[] buffer, int index) {
"""
This function converts the bytes in a byte array at the specified index to its
corresponding integer value.
@param buffer The byte array containing the integer.
@param index The index for the first byte in the byte array.
@return The corresponding integer value.
"""
int length = buffer.length - index;
if (length > 4) length = 4;
int integer = 0;
for (int i = 0; i < length; i++) {
integer |= ((buffer[index + length - i - 1] & 0xFF) << (i * 8));
}
return integer;
}
|
java
|
static public int bytesToInt(byte[] buffer, int index) {
int length = buffer.length - index;
if (length > 4) length = 4;
int integer = 0;
for (int i = 0; i < length; i++) {
integer |= ((buffer[index + length - i - 1] & 0xFF) << (i * 8));
}
return integer;
}
|
[
"static",
"public",
"int",
"bytesToInt",
"(",
"byte",
"[",
"]",
"buffer",
",",
"int",
"index",
")",
"{",
"int",
"length",
"=",
"buffer",
".",
"length",
"-",
"index",
";",
"if",
"(",
"length",
">",
"4",
")",
"length",
"=",
"4",
";",
"int",
"integer",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"integer",
"|=",
"(",
"(",
"buffer",
"[",
"index",
"+",
"length",
"-",
"i",
"-",
"1",
"]",
"&",
"0xFF",
")",
"<<",
"(",
"i",
"*",
"8",
")",
")",
";",
"}",
"return",
"integer",
";",
"}"
] |
This function converts the bytes in a byte array at the specified index to its
corresponding integer value.
@param buffer The byte array containing the integer.
@param index The index for the first byte in the byte array.
@return The corresponding integer value.
|
[
"This",
"function",
"converts",
"the",
"bytes",
"in",
"a",
"byte",
"array",
"at",
"the",
"specified",
"index",
"to",
"its",
"corresponding",
"integer",
"value",
"."
] |
train
|
https://github.com/craterdog/java-general-utilities/blob/a3ff45eaa00c2b8ed5c53efe9fe5166065fc1f57/src/main/java/craterdog/utils/ByteUtils.java#L232-L240
|
CenturyLinkCloud/clc-java-sdk
|
sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/InvoiceService.java
|
InvoiceService.getInvoice
|
public InvoiceData getInvoice(Calendar calendar, String pricingAccountAlias) {
"""
Gets a list of invoicing data for a given account alias for a given month.
@param calendar Date of usage
@param pricingAccountAlias Short code of the account that sends the invoice for the accountAlias
@return the invoice data
"""
return getInvoice(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, pricingAccountAlias);
}
|
java
|
public InvoiceData getInvoice(Calendar calendar, String pricingAccountAlias) {
return getInvoice(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, pricingAccountAlias);
}
|
[
"public",
"InvoiceData",
"getInvoice",
"(",
"Calendar",
"calendar",
",",
"String",
"pricingAccountAlias",
")",
"{",
"return",
"getInvoice",
"(",
"calendar",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
",",
"calendar",
".",
"get",
"(",
"Calendar",
".",
"MONTH",
")",
"+",
"1",
",",
"pricingAccountAlias",
")",
";",
"}"
] |
Gets a list of invoicing data for a given account alias for a given month.
@param calendar Date of usage
@param pricingAccountAlias Short code of the account that sends the invoice for the accountAlias
@return the invoice data
|
[
"Gets",
"a",
"list",
"of",
"invoicing",
"data",
"for",
"a",
"given",
"account",
"alias",
"for",
"a",
"given",
"month",
"."
] |
train
|
https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/InvoiceService.java#L66-L68
|
dropbox/dropbox-sdk-java
|
src/main/java/com/dropbox/core/DbxUploader.java
|
DbxUploader.uploadAndFinish
|
public R uploadAndFinish(InputStream in, IOUtil.ProgressListener progressListener) throws X, DbxException, IOException {
"""
This method is the same as {@link #uploadAndFinish(InputStream, long)} except for it allow
tracking the upload progress.
@param in {@code InputStream} containing data to upload
@param progressListener {@code OUtil.ProgressListener} to track the upload progress.
Only support OKHttpRequester and StandardHttpRequester.
@return Response from server
@throws X if the server sent an error response for the request
@throws DbxException if an error occurs uploading the data or reading the response
@throws IOException if an error occurs reading the input stream.
@throws IllegalStateException if this uploader has already been closed (see {@link #close}) or finished (see {@link #finish})
"""
try {
try {
httpUploader.setProgressListener(progressListener);
httpUploader.upload(in);
} catch (IOUtil.ReadException ex) {
throw ex.getCause();
} catch (IOException ex) {
// write exceptions and everything else is a Network I/O problem
throw new NetworkIOException(ex);
}
return finish();
} finally {
close();
}
}
|
java
|
public R uploadAndFinish(InputStream in, IOUtil.ProgressListener progressListener) throws X, DbxException, IOException {
try {
try {
httpUploader.setProgressListener(progressListener);
httpUploader.upload(in);
} catch (IOUtil.ReadException ex) {
throw ex.getCause();
} catch (IOException ex) {
// write exceptions and everything else is a Network I/O problem
throw new NetworkIOException(ex);
}
return finish();
} finally {
close();
}
}
|
[
"public",
"R",
"uploadAndFinish",
"(",
"InputStream",
"in",
",",
"IOUtil",
".",
"ProgressListener",
"progressListener",
")",
"throws",
"X",
",",
"DbxException",
",",
"IOException",
"{",
"try",
"{",
"try",
"{",
"httpUploader",
".",
"setProgressListener",
"(",
"progressListener",
")",
";",
"httpUploader",
".",
"upload",
"(",
"in",
")",
";",
"}",
"catch",
"(",
"IOUtil",
".",
"ReadException",
"ex",
")",
"{",
"throw",
"ex",
".",
"getCause",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"// write exceptions and everything else is a Network I/O problem",
"throw",
"new",
"NetworkIOException",
"(",
"ex",
")",
";",
"}",
"return",
"finish",
"(",
")",
";",
"}",
"finally",
"{",
"close",
"(",
")",
";",
"}",
"}"
] |
This method is the same as {@link #uploadAndFinish(InputStream, long)} except for it allow
tracking the upload progress.
@param in {@code InputStream} containing data to upload
@param progressListener {@code OUtil.ProgressListener} to track the upload progress.
Only support OKHttpRequester and StandardHttpRequester.
@return Response from server
@throws X if the server sent an error response for the request
@throws DbxException if an error occurs uploading the data or reading the response
@throws IOException if an error occurs reading the input stream.
@throws IllegalStateException if this uploader has already been closed (see {@link #close}) or finished (see {@link #finish})
|
[
"This",
"method",
"is",
"the",
"same",
"as",
"{",
"@link",
"#uploadAndFinish",
"(",
"InputStream",
"long",
")",
"}",
"except",
"for",
"it",
"allow",
"tracking",
"the",
"upload",
"progress",
"."
] |
train
|
https://github.com/dropbox/dropbox-sdk-java/blob/d86157005fad6233c18b4b0f10f00b8d9d56ae92/src/main/java/com/dropbox/core/DbxUploader.java#L114-L130
|
gmessner/gitlab4j-api
|
src/main/java/org/gitlab4j/api/GitLabApiForm.java
|
GitLabApiForm.withParam
|
public GitLabApiForm withParam(String name, Object value) throws IllegalArgumentException {
"""
Fluent method for adding query and form parameters to a get() or post() call.
@param name the name of the field/attribute to add
@param value the value of the field/attribute to add
@return this GitLabAPiForm instance
"""
return (withParam(name, value, false));
}
|
java
|
public GitLabApiForm withParam(String name, Object value) throws IllegalArgumentException {
return (withParam(name, value, false));
}
|
[
"public",
"GitLabApiForm",
"withParam",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"throws",
"IllegalArgumentException",
"{",
"return",
"(",
"withParam",
"(",
"name",
",",
"value",
",",
"false",
")",
")",
";",
"}"
] |
Fluent method for adding query and form parameters to a get() or post() call.
@param name the name of the field/attribute to add
@param value the value of the field/attribute to add
@return this GitLabAPiForm instance
|
[
"Fluent",
"method",
"for",
"adding",
"query",
"and",
"form",
"parameters",
"to",
"a",
"get",
"()",
"or",
"post",
"()",
"call",
"."
] |
train
|
https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/GitLabApiForm.java#L46-L48
|
xhsun/gw2wrapper
|
src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java
|
AsynchronousRequest.getWvWRankInfo
|
public void getWvWRankInfo(int[] ids, Callback<List<WvWRank>> callback) throws GuildWars2Exception, NullPointerException {
"""
For more info on WvW ranks API go <a href="https://wiki.guildwars2.com/wiki/API:2/wvw/ranks">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of WvW rank id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see WvWRank WvW rank info
"""
isParamValid(new ParamChecker(ids));
gw2API.getWvWRankInfo(processIds(ids), GuildWars2.lang.getValue()).enqueue(callback);
}
|
java
|
public void getWvWRankInfo(int[] ids, Callback<List<WvWRank>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getWvWRankInfo(processIds(ids), GuildWars2.lang.getValue()).enqueue(callback);
}
|
[
"public",
"void",
"getWvWRankInfo",
"(",
"int",
"[",
"]",
"ids",
",",
"Callback",
"<",
"List",
"<",
"WvWRank",
">",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ids",
")",
")",
";",
"gw2API",
".",
"getWvWRankInfo",
"(",
"processIds",
"(",
"ids",
")",
",",
"GuildWars2",
".",
"lang",
".",
"getValue",
"(",
")",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] |
For more info on WvW ranks API go <a href="https://wiki.guildwars2.com/wiki/API:2/wvw/ranks">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of WvW rank id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see WvWRank WvW rank info
|
[
"For",
"more",
"info",
"on",
"WvW",
"ranks",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"wvw",
"/",
"ranks",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Give",
"user",
"the",
"access",
"to",
"{",
"@link",
"Callback#onResponse",
"(",
"Call",
"Response",
")",
"}",
"and",
"{",
"@link",
"Callback#onFailure",
"(",
"Call",
"Throwable",
")",
"}",
"methods",
"for",
"custom",
"interactions"
] |
train
|
https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L2766-L2769
|
bazaarvoice/emodb
|
mapreduce/sor-hive/src/main/java/com/bazaarvoice/emodb/hive/EmoSerDe.java
|
EmoSerDe.deserializePrimitive
|
private Object deserializePrimitive(PrimitiveTypeInfo type, Object value)
throws SerDeException {
"""
Deserializes a primitive to its corresponding Java type, doing a best-effort conversion when necessary.
"""
switch (type.getPrimitiveCategory()) {
case VOID:
return null;
case STRING:
return deserializeString(value);
case BOOLEAN:
return deserializeBoolean(value);
case BYTE:
case SHORT:
case INT:
case LONG:
case FLOAT:
case DOUBLE:
return deserializeNumber(value, type);
case DATE:
case TIMESTAMP:
return deserializeDate(value, type);
default:
throw new SerDeException("Unsupported type: " + type.getPrimitiveCategory());
}
}
|
java
|
private Object deserializePrimitive(PrimitiveTypeInfo type, Object value)
throws SerDeException {
switch (type.getPrimitiveCategory()) {
case VOID:
return null;
case STRING:
return deserializeString(value);
case BOOLEAN:
return deserializeBoolean(value);
case BYTE:
case SHORT:
case INT:
case LONG:
case FLOAT:
case DOUBLE:
return deserializeNumber(value, type);
case DATE:
case TIMESTAMP:
return deserializeDate(value, type);
default:
throw new SerDeException("Unsupported type: " + type.getPrimitiveCategory());
}
}
|
[
"private",
"Object",
"deserializePrimitive",
"(",
"PrimitiveTypeInfo",
"type",
",",
"Object",
"value",
")",
"throws",
"SerDeException",
"{",
"switch",
"(",
"type",
".",
"getPrimitiveCategory",
"(",
")",
")",
"{",
"case",
"VOID",
":",
"return",
"null",
";",
"case",
"STRING",
":",
"return",
"deserializeString",
"(",
"value",
")",
";",
"case",
"BOOLEAN",
":",
"return",
"deserializeBoolean",
"(",
"value",
")",
";",
"case",
"BYTE",
":",
"case",
"SHORT",
":",
"case",
"INT",
":",
"case",
"LONG",
":",
"case",
"FLOAT",
":",
"case",
"DOUBLE",
":",
"return",
"deserializeNumber",
"(",
"value",
",",
"type",
")",
";",
"case",
"DATE",
":",
"case",
"TIMESTAMP",
":",
"return",
"deserializeDate",
"(",
"value",
",",
"type",
")",
";",
"default",
":",
"throw",
"new",
"SerDeException",
"(",
"\"Unsupported type: \"",
"+",
"type",
".",
"getPrimitiveCategory",
"(",
")",
")",
";",
"}",
"}"
] |
Deserializes a primitive to its corresponding Java type, doing a best-effort conversion when necessary.
|
[
"Deserializes",
"a",
"primitive",
"to",
"its",
"corresponding",
"Java",
"type",
"doing",
"a",
"best",
"-",
"effort",
"conversion",
"when",
"necessary",
"."
] |
train
|
https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/mapreduce/sor-hive/src/main/java/com/bazaarvoice/emodb/hive/EmoSerDe.java#L343-L365
|
jferard/fastods
|
fastods/src/main/java/com/github/jferard/fastods/PageSection.java
|
PageSection.simpleFooter
|
public static Footer simpleFooter(final String text, final TextStyle ts) {
"""
Create a simple footer, with a styled text
@param text the text
@param ts the style
@return the footer
"""
return new SimplePageSectionBuilder().text(Text.styledContent(text, ts)).buildFooter();
}
|
java
|
public static Footer simpleFooter(final String text, final TextStyle ts) {
return new SimplePageSectionBuilder().text(Text.styledContent(text, ts)).buildFooter();
}
|
[
"public",
"static",
"Footer",
"simpleFooter",
"(",
"final",
"String",
"text",
",",
"final",
"TextStyle",
"ts",
")",
"{",
"return",
"new",
"SimplePageSectionBuilder",
"(",
")",
".",
"text",
"(",
"Text",
".",
"styledContent",
"(",
"text",
",",
"ts",
")",
")",
".",
"buildFooter",
"(",
")",
";",
"}"
] |
Create a simple footer, with a styled text
@param text the text
@param ts the style
@return the footer
|
[
"Create",
"a",
"simple",
"footer",
"with",
"a",
"styled",
"text"
] |
train
|
https://github.com/jferard/fastods/blob/a034d173083ffa602dc525699b97f753082eaef9/fastods/src/main/java/com/github/jferard/fastods/PageSection.java#L105-L107
|
fozziethebeat/S-Space
|
src/main/java/edu/ucla/sspace/matrix/MatrixIO.java
|
MatrixIO.readSparseSVDLIBCbinary
|
private static Matrix readSparseSVDLIBCbinary(File matrix, Type matrixType,
boolean transposeOnRead)
throws IOException {
"""
Creates a {@code Matrix} from the data encoded as {@link
Format#SVDLIBC_SPARSE_BINARY} in provided file.
@param matrix
@param matrixType
@return a matrix whose data was specified by the provided file
"""
DataInputStream dis = new DataInputStream(
new BufferedInputStream(new FileInputStream(matrix)));
int rows = dis.readInt();
int cols = dis.readInt();
int nz = dis.readInt();
MATRIX_IO_LOGGER.fine(
String.format("Creating %s matrix %d rows, %d cols, %d nz%n",
((transposeOnRead) ? "transposed" : ""),
rows, cols, nz));
Matrix m = null;
// Special case for reading transposed data. This avoids the log(n)
// overhead from resorting the row data for the matrix, which can be
// significant in large matrices.
if (transposeOnRead) {
SparseDoubleVector[] rowArr = new SparseDoubleVector[cols];
int entriesSeen = 0;
int col = 0;
int curRow = 0;
for (; entriesSeen < nz; ++col) {
int nzInCol = dis.readInt();
int[] indices = new int[nzInCol];
double[] vals = new double[nzInCol];
for (int i = 0; i < nzInCol; ++i, ++entriesSeen) {
indices[i] = dis.readInt();
vals[i] = dis.readFloat();
}
SparseDoubleVector rowVec =
new CompactSparseVector(indices, vals, rows);
rowArr[curRow] = rowVec;
++curRow;
}
m = Matrices.asSparseMatrix(Arrays.asList(rowArr));
}
else {
m = new SparseHashMatrix(rows, cols);
int entriesSeen = 0;
int col = 0;
for (; entriesSeen < nz; ++col) {
int nzInCol = dis.readInt();
for (int i = 0; i < nzInCol; ++i, ++entriesSeen) {
m.set(dis.readInt(), col, dis.readFloat());
}
}
}
dis.close();
MATRIX_IO_LOGGER.fine("Completed loading matrix");
return m;
}
|
java
|
private static Matrix readSparseSVDLIBCbinary(File matrix, Type matrixType,
boolean transposeOnRead)
throws IOException {
DataInputStream dis = new DataInputStream(
new BufferedInputStream(new FileInputStream(matrix)));
int rows = dis.readInt();
int cols = dis.readInt();
int nz = dis.readInt();
MATRIX_IO_LOGGER.fine(
String.format("Creating %s matrix %d rows, %d cols, %d nz%n",
((transposeOnRead) ? "transposed" : ""),
rows, cols, nz));
Matrix m = null;
// Special case for reading transposed data. This avoids the log(n)
// overhead from resorting the row data for the matrix, which can be
// significant in large matrices.
if (transposeOnRead) {
SparseDoubleVector[] rowArr = new SparseDoubleVector[cols];
int entriesSeen = 0;
int col = 0;
int curRow = 0;
for (; entriesSeen < nz; ++col) {
int nzInCol = dis.readInt();
int[] indices = new int[nzInCol];
double[] vals = new double[nzInCol];
for (int i = 0; i < nzInCol; ++i, ++entriesSeen) {
indices[i] = dis.readInt();
vals[i] = dis.readFloat();
}
SparseDoubleVector rowVec =
new CompactSparseVector(indices, vals, rows);
rowArr[curRow] = rowVec;
++curRow;
}
m = Matrices.asSparseMatrix(Arrays.asList(rowArr));
}
else {
m = new SparseHashMatrix(rows, cols);
int entriesSeen = 0;
int col = 0;
for (; entriesSeen < nz; ++col) {
int nzInCol = dis.readInt();
for (int i = 0; i < nzInCol; ++i, ++entriesSeen) {
m.set(dis.readInt(), col, dis.readFloat());
}
}
}
dis.close();
MATRIX_IO_LOGGER.fine("Completed loading matrix");
return m;
}
|
[
"private",
"static",
"Matrix",
"readSparseSVDLIBCbinary",
"(",
"File",
"matrix",
",",
"Type",
"matrixType",
",",
"boolean",
"transposeOnRead",
")",
"throws",
"IOException",
"{",
"DataInputStream",
"dis",
"=",
"new",
"DataInputStream",
"(",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"matrix",
")",
")",
")",
";",
"int",
"rows",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"int",
"cols",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"int",
"nz",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"MATRIX_IO_LOGGER",
".",
"fine",
"(",
"String",
".",
"format",
"(",
"\"Creating %s matrix %d rows, %d cols, %d nz%n\"",
",",
"(",
"(",
"transposeOnRead",
")",
"?",
"\"transposed\"",
":",
"\"\"",
")",
",",
"rows",
",",
"cols",
",",
"nz",
")",
")",
";",
"Matrix",
"m",
"=",
"null",
";",
"// Special case for reading transposed data. This avoids the log(n)",
"// overhead from resorting the row data for the matrix, which can be",
"// significant in large matrices.",
"if",
"(",
"transposeOnRead",
")",
"{",
"SparseDoubleVector",
"[",
"]",
"rowArr",
"=",
"new",
"SparseDoubleVector",
"[",
"cols",
"]",
";",
"int",
"entriesSeen",
"=",
"0",
";",
"int",
"col",
"=",
"0",
";",
"int",
"curRow",
"=",
"0",
";",
"for",
"(",
";",
"entriesSeen",
"<",
"nz",
";",
"++",
"col",
")",
"{",
"int",
"nzInCol",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"int",
"[",
"]",
"indices",
"=",
"new",
"int",
"[",
"nzInCol",
"]",
";",
"double",
"[",
"]",
"vals",
"=",
"new",
"double",
"[",
"nzInCol",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nzInCol",
";",
"++",
"i",
",",
"++",
"entriesSeen",
")",
"{",
"indices",
"[",
"i",
"]",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"vals",
"[",
"i",
"]",
"=",
"dis",
".",
"readFloat",
"(",
")",
";",
"}",
"SparseDoubleVector",
"rowVec",
"=",
"new",
"CompactSparseVector",
"(",
"indices",
",",
"vals",
",",
"rows",
")",
";",
"rowArr",
"[",
"curRow",
"]",
"=",
"rowVec",
";",
"++",
"curRow",
";",
"}",
"m",
"=",
"Matrices",
".",
"asSparseMatrix",
"(",
"Arrays",
".",
"asList",
"(",
"rowArr",
")",
")",
";",
"}",
"else",
"{",
"m",
"=",
"new",
"SparseHashMatrix",
"(",
"rows",
",",
"cols",
")",
";",
"int",
"entriesSeen",
"=",
"0",
";",
"int",
"col",
"=",
"0",
";",
"for",
"(",
";",
"entriesSeen",
"<",
"nz",
";",
"++",
"col",
")",
"{",
"int",
"nzInCol",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nzInCol",
";",
"++",
"i",
",",
"++",
"entriesSeen",
")",
"{",
"m",
".",
"set",
"(",
"dis",
".",
"readInt",
"(",
")",
",",
"col",
",",
"dis",
".",
"readFloat",
"(",
")",
")",
";",
"}",
"}",
"}",
"dis",
".",
"close",
"(",
")",
";",
"MATRIX_IO_LOGGER",
".",
"fine",
"(",
"\"Completed loading matrix\"",
")",
";",
"return",
"m",
";",
"}"
] |
Creates a {@code Matrix} from the data encoded as {@link
Format#SVDLIBC_SPARSE_BINARY} in provided file.
@param matrix
@param matrixType
@return a matrix whose data was specified by the provided file
|
[
"Creates",
"a",
"{",
"@code",
"Matrix",
"}",
"from",
"the",
"data",
"encoded",
"as",
"{",
"@link",
"Format#SVDLIBC_SPARSE_BINARY",
"}",
"in",
"provided",
"file",
"."
] |
train
|
https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/MatrixIO.java#L1068-L1121
|
sahan/RoboZombie
|
robozombie/src/main/java/com/lonepulse/robozombie/util/Assert.java
|
Assert.assertNotNull
|
public static <T extends Object> T assertNotNull(T arg, Class<T> type) {
"""
<p>Asserts that the given argument is <b>{@code not null}</b>. If the argument is {@code null}
a {@link NullPointerException} will be thrown with the message, <i>"The supplied <type>
was found to be <null>"</i>.</p>
@param arg
the argument to be asserted as being {@code not null}
<br><br>
@param type
the {@link Class} of the argument to be asserted
<br><br>
@return the argument which was asserted to be {@code not null}
<br><br>
@throws NullPointerException
if the supplied argument was found to be {@code null}
<br><br>
@since 1.3.0
"""
if(arg == null) {
throw new NullPointerException(new StringBuilder("The supplied ")
.append(type == null? "argument" : type.getName()).append(" was found to be <null>").toString());
}
return arg;
}
|
java
|
public static <T extends Object> T assertNotNull(T arg, Class<T> type) {
if(arg == null) {
throw new NullPointerException(new StringBuilder("The supplied ")
.append(type == null? "argument" : type.getName()).append(" was found to be <null>").toString());
}
return arg;
}
|
[
"public",
"static",
"<",
"T",
"extends",
"Object",
">",
"T",
"assertNotNull",
"(",
"T",
"arg",
",",
"Class",
"<",
"T",
">",
"type",
")",
"{",
"if",
"(",
"arg",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"new",
"StringBuilder",
"(",
"\"The supplied \"",
")",
".",
"append",
"(",
"type",
"==",
"null",
"?",
"\"argument\"",
":",
"type",
".",
"getName",
"(",
")",
")",
".",
"append",
"(",
"\" was found to be <null>\"",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"arg",
";",
"}"
] |
<p>Asserts that the given argument is <b>{@code not null}</b>. If the argument is {@code null}
a {@link NullPointerException} will be thrown with the message, <i>"The supplied <type>
was found to be <null>"</i>.</p>
@param arg
the argument to be asserted as being {@code not null}
<br><br>
@param type
the {@link Class} of the argument to be asserted
<br><br>
@return the argument which was asserted to be {@code not null}
<br><br>
@throws NullPointerException
if the supplied argument was found to be {@code null}
<br><br>
@since 1.3.0
|
[
"<p",
">",
"Asserts",
"that",
"the",
"given",
"argument",
"is",
"<b",
">",
"{",
"@code",
"not",
"null",
"}",
"<",
"/",
"b",
">",
".",
"If",
"the",
"argument",
"is",
"{",
"@code",
"null",
"}",
"a",
"{",
"@link",
"NullPointerException",
"}",
"will",
"be",
"thrown",
"with",
"the",
"message",
"<i",
">",
"The",
"supplied",
"<",
";",
"type>",
";",
"was",
"found",
"to",
"be",
"<",
";",
"null>",
";",
"<",
"/",
"i",
">",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/sahan/RoboZombie/blob/2e02f0d41647612e9d89360c5c48811ea86b33c8/robozombie/src/main/java/com/lonepulse/robozombie/util/Assert.java#L154-L163
|
lessthanoptimal/BoofCV
|
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/ThresholdLocalOtsu.java
|
ThresholdLocalOtsu.applyToBorder
|
void applyToBorder(GrayU8 input, GrayU8 output, int y0, int y1, int x0, int x1, ApplyHelper h) {
"""
Apply around the image border. Use a region that's the full size but apply to all pixels that the region
would go outside of it was centered on them.
"""
// top-left corner
h.computeHistogram(0,0,input);
h.applyToBlock(0,0,x0+1,y0+1,input,output);
// top-middle
for (int x = x0+1; x < x1; x++) {
h.updateHistogramX(x-x0,0,input);
h.applyToBlock(x,0,x+1,y0,input,output);
}
// top-right
h.updateHistogramX(x1-x0,0,input);
h.applyToBlock(x1,0,input.width,y0+1,input,output);
// middle-right
for (int y = y0+1; y < y1; y++) {
h.updateHistogramY(x1-x0,y-y0,input);
h.applyToBlock(x1,y,input.width,y+1,input,output);
}
// bottom-right
h.updateHistogramY(x1-x0,y1-y0,input);
h.applyToBlock(x1,y1,input.width,input.height,input,output);
//Start over in the top-left. Yes this step could be avoided...
// middle-left
h.computeHistogram(0,0,input);
for (int y = y0+1; y < y1; y++) {
h.updateHistogramY(0,y-y0,input);
h.applyToBlock(0,y,x0,y+1,input,output);
}
// bottom-left
h.updateHistogramY(0,y1-y0,input);
h.applyToBlock(0,y1,x0+1,input.height,input,output);
// bottom-middle
for (int x = x0+1; x < x1; x++) {
h.updateHistogramX(x-x0,y1-y0,input);
h.applyToBlock(x,y1,x+1,input.height,input,output);
}
}
|
java
|
void applyToBorder(GrayU8 input, GrayU8 output, int y0, int y1, int x0, int x1, ApplyHelper h) {
// top-left corner
h.computeHistogram(0,0,input);
h.applyToBlock(0,0,x0+1,y0+1,input,output);
// top-middle
for (int x = x0+1; x < x1; x++) {
h.updateHistogramX(x-x0,0,input);
h.applyToBlock(x,0,x+1,y0,input,output);
}
// top-right
h.updateHistogramX(x1-x0,0,input);
h.applyToBlock(x1,0,input.width,y0+1,input,output);
// middle-right
for (int y = y0+1; y < y1; y++) {
h.updateHistogramY(x1-x0,y-y0,input);
h.applyToBlock(x1,y,input.width,y+1,input,output);
}
// bottom-right
h.updateHistogramY(x1-x0,y1-y0,input);
h.applyToBlock(x1,y1,input.width,input.height,input,output);
//Start over in the top-left. Yes this step could be avoided...
// middle-left
h.computeHistogram(0,0,input);
for (int y = y0+1; y < y1; y++) {
h.updateHistogramY(0,y-y0,input);
h.applyToBlock(0,y,x0,y+1,input,output);
}
// bottom-left
h.updateHistogramY(0,y1-y0,input);
h.applyToBlock(0,y1,x0+1,input.height,input,output);
// bottom-middle
for (int x = x0+1; x < x1; x++) {
h.updateHistogramX(x-x0,y1-y0,input);
h.applyToBlock(x,y1,x+1,input.height,input,output);
}
}
|
[
"void",
"applyToBorder",
"(",
"GrayU8",
"input",
",",
"GrayU8",
"output",
",",
"int",
"y0",
",",
"int",
"y1",
",",
"int",
"x0",
",",
"int",
"x1",
",",
"ApplyHelper",
"h",
")",
"{",
"// top-left corner",
"h",
".",
"computeHistogram",
"(",
"0",
",",
"0",
",",
"input",
")",
";",
"h",
".",
"applyToBlock",
"(",
"0",
",",
"0",
",",
"x0",
"+",
"1",
",",
"y0",
"+",
"1",
",",
"input",
",",
"output",
")",
";",
"// top-middle",
"for",
"(",
"int",
"x",
"=",
"x0",
"+",
"1",
";",
"x",
"<",
"x1",
";",
"x",
"++",
")",
"{",
"h",
".",
"updateHistogramX",
"(",
"x",
"-",
"x0",
",",
"0",
",",
"input",
")",
";",
"h",
".",
"applyToBlock",
"(",
"x",
",",
"0",
",",
"x",
"+",
"1",
",",
"y0",
",",
"input",
",",
"output",
")",
";",
"}",
"// top-right",
"h",
".",
"updateHistogramX",
"(",
"x1",
"-",
"x0",
",",
"0",
",",
"input",
")",
";",
"h",
".",
"applyToBlock",
"(",
"x1",
",",
"0",
",",
"input",
".",
"width",
",",
"y0",
"+",
"1",
",",
"input",
",",
"output",
")",
";",
"// middle-right",
"for",
"(",
"int",
"y",
"=",
"y0",
"+",
"1",
";",
"y",
"<",
"y1",
";",
"y",
"++",
")",
"{",
"h",
".",
"updateHistogramY",
"(",
"x1",
"-",
"x0",
",",
"y",
"-",
"y0",
",",
"input",
")",
";",
"h",
".",
"applyToBlock",
"(",
"x1",
",",
"y",
",",
"input",
".",
"width",
",",
"y",
"+",
"1",
",",
"input",
",",
"output",
")",
";",
"}",
"// bottom-right",
"h",
".",
"updateHistogramY",
"(",
"x1",
"-",
"x0",
",",
"y1",
"-",
"y0",
",",
"input",
")",
";",
"h",
".",
"applyToBlock",
"(",
"x1",
",",
"y1",
",",
"input",
".",
"width",
",",
"input",
".",
"height",
",",
"input",
",",
"output",
")",
";",
"//Start over in the top-left. Yes this step could be avoided...",
"// middle-left",
"h",
".",
"computeHistogram",
"(",
"0",
",",
"0",
",",
"input",
")",
";",
"for",
"(",
"int",
"y",
"=",
"y0",
"+",
"1",
";",
"y",
"<",
"y1",
";",
"y",
"++",
")",
"{",
"h",
".",
"updateHistogramY",
"(",
"0",
",",
"y",
"-",
"y0",
",",
"input",
")",
";",
"h",
".",
"applyToBlock",
"(",
"0",
",",
"y",
",",
"x0",
",",
"y",
"+",
"1",
",",
"input",
",",
"output",
")",
";",
"}",
"// bottom-left",
"h",
".",
"updateHistogramY",
"(",
"0",
",",
"y1",
"-",
"y0",
",",
"input",
")",
";",
"h",
".",
"applyToBlock",
"(",
"0",
",",
"y1",
",",
"x0",
"+",
"1",
",",
"input",
".",
"height",
",",
"input",
",",
"output",
")",
";",
"// bottom-middle",
"for",
"(",
"int",
"x",
"=",
"x0",
"+",
"1",
";",
"x",
"<",
"x1",
";",
"x",
"++",
")",
"{",
"h",
".",
"updateHistogramX",
"(",
"x",
"-",
"x0",
",",
"y1",
"-",
"y0",
",",
"input",
")",
";",
"h",
".",
"applyToBlock",
"(",
"x",
",",
"y1",
",",
"x",
"+",
"1",
",",
"input",
".",
"height",
",",
"input",
",",
"output",
")",
";",
"}",
"}"
] |
Apply around the image border. Use a region that's the full size but apply to all pixels that the region
would go outside of it was centered on them.
|
[
"Apply",
"around",
"the",
"image",
"border",
".",
"Use",
"a",
"region",
"that",
"s",
"the",
"full",
"size",
"but",
"apply",
"to",
"all",
"pixels",
"that",
"the",
"region",
"would",
"go",
"outside",
"of",
"it",
"was",
"centered",
"on",
"them",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/ThresholdLocalOtsu.java#L132-L174
|
b3dgs/lionengine
|
lionengine-game/src/main/java/com/b3dgs/lionengine/game/Cursor.java
|
Cursor.setLocation
|
public void setLocation(int x, int y) {
"""
Set cursor location.
@param x The horizontal location.
@param y The vertical location.
"""
screenX = UtilMath.clamp(x, minX, maxX);
screenY = UtilMath.clamp(y, minY, maxY);
}
|
java
|
public void setLocation(int x, int y)
{
screenX = UtilMath.clamp(x, minX, maxX);
screenY = UtilMath.clamp(y, minY, maxY);
}
|
[
"public",
"void",
"setLocation",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"screenX",
"=",
"UtilMath",
".",
"clamp",
"(",
"x",
",",
"minX",
",",
"maxX",
")",
";",
"screenY",
"=",
"UtilMath",
".",
"clamp",
"(",
"y",
",",
"minY",
",",
"maxY",
")",
";",
"}"
] |
Set cursor location.
@param x The horizontal location.
@param y The vertical location.
|
[
"Set",
"cursor",
"location",
"."
] |
train
|
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/Cursor.java#L178-L182
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/util/NameUtil.java
|
NameUtil.updateFilenameHashCode
|
public static final String updateFilenameHashCode(EnterpriseBean enterpriseBean, String oldName) {
"""
Attempts to find the new file name originated from input oldName using the
the new modified BuzzHash algorithm.
This method detects if the oldName contains a valid trailing hashcode and
try to compute the new one. If the oldName has no valid hashcode in the
input name, null is return.
For ease of invocation regardless of the type of file passes in, this method
only changes the hash value and will not recreate the complete file name from
the EnterpriseBean.
@return the new file name using the oldName but with a new hash code, or null if no
new name can be constructed.
"""
String newName = null;
int len = oldName.length();
int last_ = (len > 9 && (oldName.charAt(len - 9) == '_')) ? len - 9 : -1;
// input file name must have a trailing "_" follows by 8 hex digits
// and check to make sure the last 8 characters are all hex digits
if (last_ != -1 && allHexDigits(oldName, ++last_, len))
{
String hashStr = getHashStr(enterpriseBean);
newName = oldName.substring(0, last_) + BuzzHash.computeHashStringMid32Bit(hashStr, true);
}
return newName;
}
|
java
|
public static final String updateFilenameHashCode(EnterpriseBean enterpriseBean, String oldName)
{
String newName = null;
int len = oldName.length();
int last_ = (len > 9 && (oldName.charAt(len - 9) == '_')) ? len - 9 : -1;
// input file name must have a trailing "_" follows by 8 hex digits
// and check to make sure the last 8 characters are all hex digits
if (last_ != -1 && allHexDigits(oldName, ++last_, len))
{
String hashStr = getHashStr(enterpriseBean);
newName = oldName.substring(0, last_) + BuzzHash.computeHashStringMid32Bit(hashStr, true);
}
return newName;
}
|
[
"public",
"static",
"final",
"String",
"updateFilenameHashCode",
"(",
"EnterpriseBean",
"enterpriseBean",
",",
"String",
"oldName",
")",
"{",
"String",
"newName",
"=",
"null",
";",
"int",
"len",
"=",
"oldName",
".",
"length",
"(",
")",
";",
"int",
"last_",
"=",
"(",
"len",
">",
"9",
"&&",
"(",
"oldName",
".",
"charAt",
"(",
"len",
"-",
"9",
")",
"==",
"'",
"'",
")",
")",
"?",
"len",
"-",
"9",
":",
"-",
"1",
";",
"// input file name must have a trailing \"_\" follows by 8 hex digits",
"// and check to make sure the last 8 characters are all hex digits",
"if",
"(",
"last_",
"!=",
"-",
"1",
"&&",
"allHexDigits",
"(",
"oldName",
",",
"++",
"last_",
",",
"len",
")",
")",
"{",
"String",
"hashStr",
"=",
"getHashStr",
"(",
"enterpriseBean",
")",
";",
"newName",
"=",
"oldName",
".",
"substring",
"(",
"0",
",",
"last_",
")",
"+",
"BuzzHash",
".",
"computeHashStringMid32Bit",
"(",
"hashStr",
",",
"true",
")",
";",
"}",
"return",
"newName",
";",
"}"
] |
Attempts to find the new file name originated from input oldName using the
the new modified BuzzHash algorithm.
This method detects if the oldName contains a valid trailing hashcode and
try to compute the new one. If the oldName has no valid hashcode in the
input name, null is return.
For ease of invocation regardless of the type of file passes in, this method
only changes the hash value and will not recreate the complete file name from
the EnterpriseBean.
@return the new file name using the oldName but with a new hash code, or null if no
new name can be constructed.
|
[
"Attempts",
"to",
"find",
"the",
"new",
"file",
"name",
"originated",
"from",
"input",
"oldName",
"using",
"the",
"the",
"new",
"modified",
"BuzzHash",
"algorithm",
".",
"This",
"method",
"detects",
"if",
"the",
"oldName",
"contains",
"a",
"valid",
"trailing",
"hashcode",
"and",
"try",
"to",
"compute",
"the",
"new",
"one",
".",
"If",
"the",
"oldName",
"has",
"no",
"valid",
"hashcode",
"in",
"the",
"input",
"name",
"null",
"is",
"return",
".",
"For",
"ease",
"of",
"invocation",
"regardless",
"of",
"the",
"type",
"of",
"file",
"passes",
"in",
"this",
"method",
"only",
"changes",
"the",
"hash",
"value",
"and",
"will",
"not",
"recreate",
"the",
"complete",
"file",
"name",
"from",
"the",
"EnterpriseBean",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/util/NameUtil.java#L746-L759
|
Azure/azure-sdk-for-java
|
compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/AvailabilitySetsInner.java
|
AvailabilitySetsInner.createOrUpdate
|
public AvailabilitySetInner createOrUpdate(String resourceGroupName, String availabilitySetName, AvailabilitySetInner parameters) {
"""
Create or update an availability set.
@param resourceGroupName The name of the resource group.
@param availabilitySetName The name of the availability set.
@param parameters Parameters supplied to the Create Availability Set 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 AvailabilitySetInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, availabilitySetName, parameters).toBlocking().single().body();
}
|
java
|
public AvailabilitySetInner createOrUpdate(String resourceGroupName, String availabilitySetName, AvailabilitySetInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, availabilitySetName, parameters).toBlocking().single().body();
}
|
[
"public",
"AvailabilitySetInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"availabilitySetName",
",",
"AvailabilitySetInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"availabilitySetName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Create or update an availability set.
@param resourceGroupName The name of the resource group.
@param availabilitySetName The name of the availability set.
@param parameters Parameters supplied to the Create Availability Set 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 AvailabilitySetInner object if successful.
|
[
"Create",
"or",
"update",
"an",
"availability",
"set",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/AvailabilitySetsInner.java#L96-L98
|
TakahikoKawasaki/nv-cipher
|
src/main/java/com/neovisionaries/security/CodecCipher.java
|
CodecCipher.setInit
|
public CodecCipher setInit(Key key) throws IllegalArgumentException {
"""
Set cipher initialization parameters.
<p>
If this method is used to set initialization parameters,
{@link Cipher#init(int, Key) Cipher.init(mode, (Key)key)}
is called later from within {@code encrypt}/{@code decrypt} methods.
</p>
@param key
@return
{@code this} object.
@throws IllegalArgumentException
{@code key} is {@code null}.
"""
return setInit(key, null, null, null);
}
|
java
|
public CodecCipher setInit(Key key) throws IllegalArgumentException
{
return setInit(key, null, null, null);
}
|
[
"public",
"CodecCipher",
"setInit",
"(",
"Key",
"key",
")",
"throws",
"IllegalArgumentException",
"{",
"return",
"setInit",
"(",
"key",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}"
] |
Set cipher initialization parameters.
<p>
If this method is used to set initialization parameters,
{@link Cipher#init(int, Key) Cipher.init(mode, (Key)key)}
is called later from within {@code encrypt}/{@code decrypt} methods.
</p>
@param key
@return
{@code this} object.
@throws IllegalArgumentException
{@code key} is {@code null}.
|
[
"Set",
"cipher",
"initialization",
"parameters",
"."
] |
train
|
https://github.com/TakahikoKawasaki/nv-cipher/blob/d01aa4f53611e2724ae03633060f55bacf549175/src/main/java/com/neovisionaries/security/CodecCipher.java#L721-L724
|
petrbouda/joyrest
|
joyrest-core/src/main/java/org/joyrest/routing/matcher/RequestMatcher.java
|
RequestMatcher.matchProduces
|
public static boolean matchProduces(InternalRoute route, InternalRequest<?> request) {
"""
Matches route produces configurer and Accept-header in an incoming provider
@param route route configurer
@param request incoming provider object
@return returns {@code true} if the given route has produces Media-Type one of an Accept from an incoming provider
"""
if (nonEmpty(request.getAccept())) {
List<MediaType> matchedAcceptTypes = getAcceptedMediaTypes(route.getProduces(), request.getAccept());
if (nonEmpty(matchedAcceptTypes)) {
request.setMatchedAccept(matchedAcceptTypes.get(0));
return true;
}
}
return false;
}
|
java
|
public static boolean matchProduces(InternalRoute route, InternalRequest<?> request) {
if (nonEmpty(request.getAccept())) {
List<MediaType> matchedAcceptTypes = getAcceptedMediaTypes(route.getProduces(), request.getAccept());
if (nonEmpty(matchedAcceptTypes)) {
request.setMatchedAccept(matchedAcceptTypes.get(0));
return true;
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"matchProduces",
"(",
"InternalRoute",
"route",
",",
"InternalRequest",
"<",
"?",
">",
"request",
")",
"{",
"if",
"(",
"nonEmpty",
"(",
"request",
".",
"getAccept",
"(",
")",
")",
")",
"{",
"List",
"<",
"MediaType",
">",
"matchedAcceptTypes",
"=",
"getAcceptedMediaTypes",
"(",
"route",
".",
"getProduces",
"(",
")",
",",
"request",
".",
"getAccept",
"(",
")",
")",
";",
"if",
"(",
"nonEmpty",
"(",
"matchedAcceptTypes",
")",
")",
"{",
"request",
".",
"setMatchedAccept",
"(",
"matchedAcceptTypes",
".",
"get",
"(",
"0",
")",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Matches route produces configurer and Accept-header in an incoming provider
@param route route configurer
@param request incoming provider object
@return returns {@code true} if the given route has produces Media-Type one of an Accept from an incoming provider
|
[
"Matches",
"route",
"produces",
"configurer",
"and",
"Accept",
"-",
"header",
"in",
"an",
"incoming",
"provider"
] |
train
|
https://github.com/petrbouda/joyrest/blob/58903f06fb7f0b8fdf1ef91318fb48a88bf970e0/joyrest-core/src/main/java/org/joyrest/routing/matcher/RequestMatcher.java#L47-L58
|
facebookarchive/hadoop-20
|
src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
|
SecondaryNameNode.doMerge
|
private void doMerge(CheckpointSignature sig, RemoteEditLogManifest manifest,
boolean loadImage, FSImage dstImage) throws IOException {
"""
Merge downloaded image and edits and write the new image into current
storage directory.
"""
if (loadImage) { // create an empty namespace if new image
namesystem = new FSNamesystem(checkpointImage, conf);
checkpointImage.setFSNamesystem(namesystem);
}
assert namesystem.dir.fsImage == checkpointImage;
checkpointImage.doMerge(sig, manifest, loadImage);
}
|
java
|
private void doMerge(CheckpointSignature sig, RemoteEditLogManifest manifest,
boolean loadImage, FSImage dstImage) throws IOException {
if (loadImage) { // create an empty namespace if new image
namesystem = new FSNamesystem(checkpointImage, conf);
checkpointImage.setFSNamesystem(namesystem);
}
assert namesystem.dir.fsImage == checkpointImage;
checkpointImage.doMerge(sig, manifest, loadImage);
}
|
[
"private",
"void",
"doMerge",
"(",
"CheckpointSignature",
"sig",
",",
"RemoteEditLogManifest",
"manifest",
",",
"boolean",
"loadImage",
",",
"FSImage",
"dstImage",
")",
"throws",
"IOException",
"{",
"if",
"(",
"loadImage",
")",
"{",
"// create an empty namespace if new image",
"namesystem",
"=",
"new",
"FSNamesystem",
"(",
"checkpointImage",
",",
"conf",
")",
";",
"checkpointImage",
".",
"setFSNamesystem",
"(",
"namesystem",
")",
";",
"}",
"assert",
"namesystem",
".",
"dir",
".",
"fsImage",
"==",
"checkpointImage",
";",
"checkpointImage",
".",
"doMerge",
"(",
"sig",
",",
"manifest",
",",
"loadImage",
")",
";",
"}"
] |
Merge downloaded image and edits and write the new image into current
storage directory.
|
[
"Merge",
"downloaded",
"image",
"and",
"edits",
"and",
"write",
"the",
"new",
"image",
"into",
"current",
"storage",
"directory",
"."
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java#L367-L375
|
google/closure-compiler
|
src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java
|
ProcessClosureProvidesAndRequires.handleStubDefinition
|
private void handleStubDefinition(NodeTraversal t, Node n) {
"""
Handles a stub definition for a goog.provided name (e.g. a @typedef or a definition from
externs)
@param n EXPR_RESULT node.
"""
if (!t.inGlobalHoistScope()) {
return;
}
JSDocInfo info = n.getFirstChild().getJSDocInfo();
boolean hasStubDefinition = info != null && (n.isFromExterns() || info.hasTypedefType());
if (hasStubDefinition) {
if (n.getFirstChild().isQualifiedName()) {
String name = n.getFirstChild().getQualifiedName();
ProvidedName pn = providedNames.get(name);
if (pn != null) {
n.putBooleanProp(Node.WAS_PREVIOUSLY_PROVIDED, true);
pn.addDefinition(n, t.getModule());
} else if (n.getBooleanProp(Node.WAS_PREVIOUSLY_PROVIDED)) {
// We didn't find it in the providedNames, but it was previously marked as provided.
// This implies we're in hotswap pass and the current typedef is a provided namespace.
ProvidedName provided = new ProvidedName(name, n, t.getModule(), true, true);
providedNames.put(name, provided);
provided.addDefinition(n, t.getModule());
}
}
}
}
|
java
|
private void handleStubDefinition(NodeTraversal t, Node n) {
if (!t.inGlobalHoistScope()) {
return;
}
JSDocInfo info = n.getFirstChild().getJSDocInfo();
boolean hasStubDefinition = info != null && (n.isFromExterns() || info.hasTypedefType());
if (hasStubDefinition) {
if (n.getFirstChild().isQualifiedName()) {
String name = n.getFirstChild().getQualifiedName();
ProvidedName pn = providedNames.get(name);
if (pn != null) {
n.putBooleanProp(Node.WAS_PREVIOUSLY_PROVIDED, true);
pn.addDefinition(n, t.getModule());
} else if (n.getBooleanProp(Node.WAS_PREVIOUSLY_PROVIDED)) {
// We didn't find it in the providedNames, but it was previously marked as provided.
// This implies we're in hotswap pass and the current typedef is a provided namespace.
ProvidedName provided = new ProvidedName(name, n, t.getModule(), true, true);
providedNames.put(name, provided);
provided.addDefinition(n, t.getModule());
}
}
}
}
|
[
"private",
"void",
"handleStubDefinition",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
")",
"{",
"if",
"(",
"!",
"t",
".",
"inGlobalHoistScope",
"(",
")",
")",
"{",
"return",
";",
"}",
"JSDocInfo",
"info",
"=",
"n",
".",
"getFirstChild",
"(",
")",
".",
"getJSDocInfo",
"(",
")",
";",
"boolean",
"hasStubDefinition",
"=",
"info",
"!=",
"null",
"&&",
"(",
"n",
".",
"isFromExterns",
"(",
")",
"||",
"info",
".",
"hasTypedefType",
"(",
")",
")",
";",
"if",
"(",
"hasStubDefinition",
")",
"{",
"if",
"(",
"n",
".",
"getFirstChild",
"(",
")",
".",
"isQualifiedName",
"(",
")",
")",
"{",
"String",
"name",
"=",
"n",
".",
"getFirstChild",
"(",
")",
".",
"getQualifiedName",
"(",
")",
";",
"ProvidedName",
"pn",
"=",
"providedNames",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"pn",
"!=",
"null",
")",
"{",
"n",
".",
"putBooleanProp",
"(",
"Node",
".",
"WAS_PREVIOUSLY_PROVIDED",
",",
"true",
")",
";",
"pn",
".",
"addDefinition",
"(",
"n",
",",
"t",
".",
"getModule",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"n",
".",
"getBooleanProp",
"(",
"Node",
".",
"WAS_PREVIOUSLY_PROVIDED",
")",
")",
"{",
"// We didn't find it in the providedNames, but it was previously marked as provided.",
"// This implies we're in hotswap pass and the current typedef is a provided namespace.",
"ProvidedName",
"provided",
"=",
"new",
"ProvidedName",
"(",
"name",
",",
"n",
",",
"t",
".",
"getModule",
"(",
")",
",",
"true",
",",
"true",
")",
";",
"providedNames",
".",
"put",
"(",
"name",
",",
"provided",
")",
";",
"provided",
".",
"addDefinition",
"(",
"n",
",",
"t",
".",
"getModule",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Handles a stub definition for a goog.provided name (e.g. a @typedef or a definition from
externs)
@param n EXPR_RESULT node.
|
[
"Handles",
"a",
"stub",
"definition",
"for",
"a",
"goog",
".",
"provided",
"name",
"(",
"e",
".",
"g",
".",
"a",
"@typedef",
"or",
"a",
"definition",
"from",
"externs",
")"
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/ProcessClosureProvidesAndRequires.java#L392-L414
|
igniterealtime/Smack
|
smack-openpgp/src/main/java/org/jivesoftware/smackx/ox_im/OXInstantMessagingManager.java
|
OXInstantMessagingManager.signAndEncrypt
|
public OpenPgpElementAndMetadata signAndEncrypt(Set<OpenPgpContact> contacts, List<ExtensionElement> payload)
throws SmackException.NotLoggedInException, IOException, PGPException {
"""
Wrap some {@code payload} into a {@link SigncryptElement}, sign and encrypt it for {@code contacts} and ourselves.
@param contacts recipients of the message
@param payload payload which will be encrypted and signed
@return encrypted and signed {@link OpenPgpElement}, along with {@link OpenPgpMetadata} about the
encryption + signatures.
@throws SmackException.NotLoggedInException in case we are not logged in
@throws IOException IO is dangerous (we need to read keys)
@throws PGPException in case encryption goes wrong
"""
Set<Jid> jids = new HashSet<>();
for (OpenPgpContact contact : contacts) {
jids.add(contact.getJid());
}
jids.add(openPgpManager.getOpenPgpSelf().getJid());
SigncryptElement signcryptElement = new SigncryptElement(jids, payload);
OpenPgpElementAndMetadata encrypted = openPgpManager.getOpenPgpProvider().signAndEncrypt(signcryptElement,
openPgpManager.getOpenPgpSelf(), contacts);
return encrypted;
}
|
java
|
public OpenPgpElementAndMetadata signAndEncrypt(Set<OpenPgpContact> contacts, List<ExtensionElement> payload)
throws SmackException.NotLoggedInException, IOException, PGPException {
Set<Jid> jids = new HashSet<>();
for (OpenPgpContact contact : contacts) {
jids.add(contact.getJid());
}
jids.add(openPgpManager.getOpenPgpSelf().getJid());
SigncryptElement signcryptElement = new SigncryptElement(jids, payload);
OpenPgpElementAndMetadata encrypted = openPgpManager.getOpenPgpProvider().signAndEncrypt(signcryptElement,
openPgpManager.getOpenPgpSelf(), contacts);
return encrypted;
}
|
[
"public",
"OpenPgpElementAndMetadata",
"signAndEncrypt",
"(",
"Set",
"<",
"OpenPgpContact",
">",
"contacts",
",",
"List",
"<",
"ExtensionElement",
">",
"payload",
")",
"throws",
"SmackException",
".",
"NotLoggedInException",
",",
"IOException",
",",
"PGPException",
"{",
"Set",
"<",
"Jid",
">",
"jids",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"OpenPgpContact",
"contact",
":",
"contacts",
")",
"{",
"jids",
".",
"add",
"(",
"contact",
".",
"getJid",
"(",
")",
")",
";",
"}",
"jids",
".",
"add",
"(",
"openPgpManager",
".",
"getOpenPgpSelf",
"(",
")",
".",
"getJid",
"(",
")",
")",
";",
"SigncryptElement",
"signcryptElement",
"=",
"new",
"SigncryptElement",
"(",
"jids",
",",
"payload",
")",
";",
"OpenPgpElementAndMetadata",
"encrypted",
"=",
"openPgpManager",
".",
"getOpenPgpProvider",
"(",
")",
".",
"signAndEncrypt",
"(",
"signcryptElement",
",",
"openPgpManager",
".",
"getOpenPgpSelf",
"(",
")",
",",
"contacts",
")",
";",
"return",
"encrypted",
";",
"}"
] |
Wrap some {@code payload} into a {@link SigncryptElement}, sign and encrypt it for {@code contacts} and ourselves.
@param contacts recipients of the message
@param payload payload which will be encrypted and signed
@return encrypted and signed {@link OpenPgpElement}, along with {@link OpenPgpMetadata} about the
encryption + signatures.
@throws SmackException.NotLoggedInException in case we are not logged in
@throws IOException IO is dangerous (we need to read keys)
@throws PGPException in case encryption goes wrong
|
[
"Wrap",
"some",
"{",
"@code",
"payload",
"}",
"into",
"a",
"{",
"@link",
"SigncryptElement",
"}",
"sign",
"and",
"encrypt",
"it",
"for",
"{",
"@code",
"contacts",
"}",
"and",
"ourselves",
"."
] |
train
|
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox_im/OXInstantMessagingManager.java#L303-L317
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/label/LabeledLabelPanel.java
|
LabeledLabelPanel.newViewableLabel
|
protected Label newViewableLabel(final String id, final IModel<T> model) {
"""
Factory method for creating the new {@link Label}. This method is invoked in the constructor
from the derived classes and can be overridden so users can provide their own version of a
new {@link Label}.
@param id
the id
@param model
the model
@return the new {@link Label}
"""
final PropertyModel<T> viewableLabelModel = new PropertyModel<>(model.getObject(),
this.getId());
return ComponentFactory.newLabel(id, viewableLabelModel);
}
|
java
|
protected Label newViewableLabel(final String id, final IModel<T> model)
{
final PropertyModel<T> viewableLabelModel = new PropertyModel<>(model.getObject(),
this.getId());
return ComponentFactory.newLabel(id, viewableLabelModel);
}
|
[
"protected",
"Label",
"newViewableLabel",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"model",
")",
"{",
"final",
"PropertyModel",
"<",
"T",
">",
"viewableLabelModel",
"=",
"new",
"PropertyModel",
"<>",
"(",
"model",
".",
"getObject",
"(",
")",
",",
"this",
".",
"getId",
"(",
")",
")",
";",
"return",
"ComponentFactory",
".",
"newLabel",
"(",
"id",
",",
"viewableLabelModel",
")",
";",
"}"
] |
Factory method for creating the new {@link Label}. This method is invoked in the constructor
from the derived classes and can be overridden so users can provide their own version of a
new {@link Label}.
@param id
the id
@param model
the model
@return the new {@link Label}
|
[
"Factory",
"method",
"for",
"creating",
"the",
"new",
"{",
"@link",
"Label",
"}",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"new",
"{",
"@link",
"Label",
"}",
"."
] |
train
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/labeled/label/LabeledLabelPanel.java#L96-L101
|
kmi/iserve
|
iserve-elda/src/main/java/uk/ac/open/kmi/iserve/elda/EldaRouterRestletSupport.java
|
EldaRouterRestletSupport.changeMediaType
|
protected static Renderer changeMediaType(final Renderer r, final MediaType mt) {
"""
Given a renderer r and a media type mt, return a new renderer which
behaves like r except that it announces its media type as mt. r
itself is not changed.
This code should be somewhere more sensible. In fact the whole
renderer-choosing machinery needs a good cleanup.
"""
return new Renderer() {
@Override
public MediaType getMediaType(Bindings unused) {
return mt;
}
@Override
public BytesOut render(Times t, Bindings rc, Map<String, String> termBindings, APIResultSet results) {
return r.render(t, rc, termBindings, results);
}
@Override
public String getPreferredSuffix() {
return r.getPreferredSuffix();
}
@Override
public CompleteContext.Mode getMode() {
return r.getMode();
}
};
}
|
java
|
protected static Renderer changeMediaType(final Renderer r, final MediaType mt) {
return new Renderer() {
@Override
public MediaType getMediaType(Bindings unused) {
return mt;
}
@Override
public BytesOut render(Times t, Bindings rc, Map<String, String> termBindings, APIResultSet results) {
return r.render(t, rc, termBindings, results);
}
@Override
public String getPreferredSuffix() {
return r.getPreferredSuffix();
}
@Override
public CompleteContext.Mode getMode() {
return r.getMode();
}
};
}
|
[
"protected",
"static",
"Renderer",
"changeMediaType",
"(",
"final",
"Renderer",
"r",
",",
"final",
"MediaType",
"mt",
")",
"{",
"return",
"new",
"Renderer",
"(",
")",
"{",
"@",
"Override",
"public",
"MediaType",
"getMediaType",
"(",
"Bindings",
"unused",
")",
"{",
"return",
"mt",
";",
"}",
"@",
"Override",
"public",
"BytesOut",
"render",
"(",
"Times",
"t",
",",
"Bindings",
"rc",
",",
"Map",
"<",
"String",
",",
"String",
">",
"termBindings",
",",
"APIResultSet",
"results",
")",
"{",
"return",
"r",
".",
"render",
"(",
"t",
",",
"rc",
",",
"termBindings",
",",
"results",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getPreferredSuffix",
"(",
")",
"{",
"return",
"r",
".",
"getPreferredSuffix",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"CompleteContext",
".",
"Mode",
"getMode",
"(",
")",
"{",
"return",
"r",
".",
"getMode",
"(",
")",
";",
"}",
"}",
";",
"}"
] |
Given a renderer r and a media type mt, return a new renderer which
behaves like r except that it announces its media type as mt. r
itself is not changed.
This code should be somewhere more sensible. In fact the whole
renderer-choosing machinery needs a good cleanup.
|
[
"Given",
"a",
"renderer",
"r",
"and",
"a",
"media",
"type",
"mt",
"return",
"a",
"new",
"renderer",
"which",
"behaves",
"like",
"r",
"except",
"that",
"it",
"announces",
"its",
"media",
"type",
"as",
"mt",
".",
"r",
"itself",
"is",
"not",
"changed",
"."
] |
train
|
https://github.com/kmi/iserve/blob/13e7016e64c1d5a539b838c6debf1a5cc4aefcb7/iserve-elda/src/main/java/uk/ac/open/kmi/iserve/elda/EldaRouterRestletSupport.java#L188-L211
|
apiman/apiman
|
manager/api/war/tomcat8/src/main/java/io/apiman/manager/api/war/tomcat8/Tomcat8PluginRegistry.java
|
Tomcat8PluginRegistry.getPluginDir
|
private static File getPluginDir() {
"""
Creates the directory to use for the plugin registry. The location of
the plugin registry is in the tomcat data directory.
"""
String dataDirPath = System.getProperty("catalina.home"); //$NON-NLS-1$
File dataDir = new File(dataDirPath, "data"); //$NON-NLS-1$
if (!dataDir.getParentFile().isDirectory()) {
throw new RuntimeException("Failed to find Tomcat home at: " + dataDirPath); //$NON-NLS-1$
}
if (!dataDir.exists()) {
dataDir.mkdir();
}
File pluginsDir = new File(dataDir, "apiman/plugins"); //$NON-NLS-1$
return pluginsDir;
}
|
java
|
private static File getPluginDir() {
String dataDirPath = System.getProperty("catalina.home"); //$NON-NLS-1$
File dataDir = new File(dataDirPath, "data"); //$NON-NLS-1$
if (!dataDir.getParentFile().isDirectory()) {
throw new RuntimeException("Failed to find Tomcat home at: " + dataDirPath); //$NON-NLS-1$
}
if (!dataDir.exists()) {
dataDir.mkdir();
}
File pluginsDir = new File(dataDir, "apiman/plugins"); //$NON-NLS-1$
return pluginsDir;
}
|
[
"private",
"static",
"File",
"getPluginDir",
"(",
")",
"{",
"String",
"dataDirPath",
"=",
"System",
".",
"getProperty",
"(",
"\"catalina.home\"",
")",
";",
"//$NON-NLS-1$",
"File",
"dataDir",
"=",
"new",
"File",
"(",
"dataDirPath",
",",
"\"data\"",
")",
";",
"//$NON-NLS-1$",
"if",
"(",
"!",
"dataDir",
".",
"getParentFile",
"(",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to find Tomcat home at: \"",
"+",
"dataDirPath",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"!",
"dataDir",
".",
"exists",
"(",
")",
")",
"{",
"dataDir",
".",
"mkdir",
"(",
")",
";",
"}",
"File",
"pluginsDir",
"=",
"new",
"File",
"(",
"dataDir",
",",
"\"apiman/plugins\"",
")",
";",
"//$NON-NLS-1$",
"return",
"pluginsDir",
";",
"}"
] |
Creates the directory to use for the plugin registry. The location of
the plugin registry is in the tomcat data directory.
|
[
"Creates",
"the",
"directory",
"to",
"use",
"for",
"the",
"plugin",
"registry",
".",
"The",
"location",
"of",
"the",
"plugin",
"registry",
"is",
"in",
"the",
"tomcat",
"data",
"directory",
"."
] |
train
|
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/war/tomcat8/src/main/java/io/apiman/manager/api/war/tomcat8/Tomcat8PluginRegistry.java#L48-L59
|
teatrove/teatrove
|
teaservlet/src/main/java/org/teatrove/teatools/TeaToolsUtils.java
|
TeaToolsUtils.getBeanInfo
|
public BeanInfo getBeanInfo(Class<?> beanClass, Class<?> stopClass)
throws IntrospectionException {
"""
Introspects a Java bean to learn all about its properties, exposed
methods, below a given "stop" point.
@param beanClass the bean class to be analyzed
@param stopClass the base class at which to stop the analysis.
Any methods/properties/events in the stopClass or in its baseclasses
will be ignored in the analysis
"""
return Introspector.getBeanInfo(beanClass, stopClass);
}
|
java
|
public BeanInfo getBeanInfo(Class<?> beanClass, Class<?> stopClass)
throws IntrospectionException {
return Introspector.getBeanInfo(beanClass, stopClass);
}
|
[
"public",
"BeanInfo",
"getBeanInfo",
"(",
"Class",
"<",
"?",
">",
"beanClass",
",",
"Class",
"<",
"?",
">",
"stopClass",
")",
"throws",
"IntrospectionException",
"{",
"return",
"Introspector",
".",
"getBeanInfo",
"(",
"beanClass",
",",
"stopClass",
")",
";",
"}"
] |
Introspects a Java bean to learn all about its properties, exposed
methods, below a given "stop" point.
@param beanClass the bean class to be analyzed
@param stopClass the base class at which to stop the analysis.
Any methods/properties/events in the stopClass or in its baseclasses
will be ignored in the analysis
|
[
"Introspects",
"a",
"Java",
"bean",
"to",
"learn",
"all",
"about",
"its",
"properties",
"exposed",
"methods",
"below",
"a",
"given",
"stop",
"point",
"."
] |
train
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/TeaToolsUtils.java#L619-L622
|
ArcBees/gwtquery
|
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/UiPlugin.java
|
UiPlugin.contains
|
public static boolean contains(Element parent, Element descendant) {
"""
Return true if the <code>descendant</code> is a child of the parent. Return false elsewhere.
"""
return parent != descendant && parent.isOrHasChild(descendant);
}
|
java
|
public static boolean contains(Element parent, Element descendant) {
return parent != descendant && parent.isOrHasChild(descendant);
}
|
[
"public",
"static",
"boolean",
"contains",
"(",
"Element",
"parent",
",",
"Element",
"descendant",
")",
"{",
"return",
"parent",
"!=",
"descendant",
"&&",
"parent",
".",
"isOrHasChild",
"(",
"descendant",
")",
";",
"}"
] |
Return true if the <code>descendant</code> is a child of the parent. Return false elsewhere.
|
[
"Return",
"true",
"if",
"the",
"<code",
">",
"descendant<",
"/",
"code",
">",
"is",
"a",
"child",
"of",
"the",
"parent",
".",
"Return",
"false",
"elsewhere",
"."
] |
train
|
https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/UiPlugin.java#L139-L141
|
h2oai/h2o-2
|
src/main/java/water/api/Models.java
|
Models.summarizeDeepLearningModel
|
private static void summarizeDeepLearningModel(ModelSummary summary, hex.deeplearning.DeepLearningModel model) {
"""
Summarize fields which are specific to hex.deeplearning.DeepLearningModel.
"""
// add generic fields such as column names
summarizeModelCommonFields(summary, model);
summary.model_algorithm = "DeepLearning";
JsonObject all_params = (model.get_params()).toJSON();
summary.critical_parameters = whitelistJsonObject(all_params, DL_critical_params);
summary.secondary_parameters = whitelistJsonObject(all_params, DL_secondary_params);
summary.expert_parameters = whitelistJsonObject(all_params, DL_expert_params);
}
|
java
|
private static void summarizeDeepLearningModel(ModelSummary summary, hex.deeplearning.DeepLearningModel model) {
// add generic fields such as column names
summarizeModelCommonFields(summary, model);
summary.model_algorithm = "DeepLearning";
JsonObject all_params = (model.get_params()).toJSON();
summary.critical_parameters = whitelistJsonObject(all_params, DL_critical_params);
summary.secondary_parameters = whitelistJsonObject(all_params, DL_secondary_params);
summary.expert_parameters = whitelistJsonObject(all_params, DL_expert_params);
}
|
[
"private",
"static",
"void",
"summarizeDeepLearningModel",
"(",
"ModelSummary",
"summary",
",",
"hex",
".",
"deeplearning",
".",
"DeepLearningModel",
"model",
")",
"{",
"// add generic fields such as column names",
"summarizeModelCommonFields",
"(",
"summary",
",",
"model",
")",
";",
"summary",
".",
"model_algorithm",
"=",
"\"DeepLearning\"",
";",
"JsonObject",
"all_params",
"=",
"(",
"model",
".",
"get_params",
"(",
")",
")",
".",
"toJSON",
"(",
")",
";",
"summary",
".",
"critical_parameters",
"=",
"whitelistJsonObject",
"(",
"all_params",
",",
"DL_critical_params",
")",
";",
"summary",
".",
"secondary_parameters",
"=",
"whitelistJsonObject",
"(",
"all_params",
",",
"DL_secondary_params",
")",
";",
"summary",
".",
"expert_parameters",
"=",
"whitelistJsonObject",
"(",
"all_params",
",",
"DL_expert_params",
")",
";",
"}"
] |
Summarize fields which are specific to hex.deeplearning.DeepLearningModel.
|
[
"Summarize",
"fields",
"which",
"are",
"specific",
"to",
"hex",
".",
"deeplearning",
".",
"DeepLearningModel",
"."
] |
train
|
https://github.com/h2oai/h2o-2/blob/be350f3f2c2fb6f135cc07c41f83fd0e4f521ac1/src/main/java/water/api/Models.java#L311-L321
|
google/error-prone-javac
|
src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java
|
Types.makeSuperWildcard
|
private WildcardType makeSuperWildcard(Type bound, TypeVar formal) {
"""
Create a wildcard with the given lower (super) bound; create an
unbounded wildcard if bound is bottom (type of {@code null}).
@param bound the lower bound
@param formal the formal type parameter that will be
substituted by the wildcard
"""
if (bound.hasTag(BOT)) {
return new WildcardType(syms.objectType,
BoundKind.UNBOUND,
syms.boundClass,
formal);
} else {
return new WildcardType(bound,
BoundKind.SUPER,
syms.boundClass,
formal);
}
}
|
java
|
private WildcardType makeSuperWildcard(Type bound, TypeVar formal) {
if (bound.hasTag(BOT)) {
return new WildcardType(syms.objectType,
BoundKind.UNBOUND,
syms.boundClass,
formal);
} else {
return new WildcardType(bound,
BoundKind.SUPER,
syms.boundClass,
formal);
}
}
|
[
"private",
"WildcardType",
"makeSuperWildcard",
"(",
"Type",
"bound",
",",
"TypeVar",
"formal",
")",
"{",
"if",
"(",
"bound",
".",
"hasTag",
"(",
"BOT",
")",
")",
"{",
"return",
"new",
"WildcardType",
"(",
"syms",
".",
"objectType",
",",
"BoundKind",
".",
"UNBOUND",
",",
"syms",
".",
"boundClass",
",",
"formal",
")",
";",
"}",
"else",
"{",
"return",
"new",
"WildcardType",
"(",
"bound",
",",
"BoundKind",
".",
"SUPER",
",",
"syms",
".",
"boundClass",
",",
"formal",
")",
";",
"}",
"}"
] |
Create a wildcard with the given lower (super) bound; create an
unbounded wildcard if bound is bottom (type of {@code null}).
@param bound the lower bound
@param formal the formal type parameter that will be
substituted by the wildcard
|
[
"Create",
"a",
"wildcard",
"with",
"the",
"given",
"lower",
"(",
"super",
")",
"bound",
";",
"create",
"an",
"unbounded",
"wildcard",
"if",
"bound",
"is",
"bottom",
"(",
"type",
"of",
"{",
"@code",
"null",
"}",
")",
"."
] |
train
|
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java#L4558-L4570
|
w3c/epubcheck
|
src/main/java/com/adobe/epubcheck/messages/LocalizedMessages.java
|
LocalizedMessages.getSuggestion
|
public String getSuggestion(MessageId id, String key) {
"""
Returns the suggestion message for the given message ID and key.
In other words, for a message ID of `XXX_NNN`, and a key `key`,
returns the bundle message named `XXX_NNN_SUG.key`.
If the suggestion key is not found, returns the bundle message
named `XXX_NNN_SUG.default`.
If this latter is not found, returns the bundle message nameed
`XXX_NNN_SUG`.
@param id a message ID
@param key the key of a specific suggestion string
@return the associated suggestion string
"""
String messageKey = id.name() + "_SUG." + key;
String messageDefaultKey = id.name() + "_SUG.default";
return bundle.containsKey(messageKey) ? getStringFromBundle(messageKey)
: (bundle.containsKey(messageDefaultKey) ? getStringFromBundle(messageDefaultKey)
: getSuggestion(id));
}
|
java
|
public String getSuggestion(MessageId id, String key)
{
String messageKey = id.name() + "_SUG." + key;
String messageDefaultKey = id.name() + "_SUG.default";
return bundle.containsKey(messageKey) ? getStringFromBundle(messageKey)
: (bundle.containsKey(messageDefaultKey) ? getStringFromBundle(messageDefaultKey)
: getSuggestion(id));
}
|
[
"public",
"String",
"getSuggestion",
"(",
"MessageId",
"id",
",",
"String",
"key",
")",
"{",
"String",
"messageKey",
"=",
"id",
".",
"name",
"(",
")",
"+",
"\"_SUG.\"",
"+",
"key",
";",
"String",
"messageDefaultKey",
"=",
"id",
".",
"name",
"(",
")",
"+",
"\"_SUG.default\"",
";",
"return",
"bundle",
".",
"containsKey",
"(",
"messageKey",
")",
"?",
"getStringFromBundle",
"(",
"messageKey",
")",
":",
"(",
"bundle",
".",
"containsKey",
"(",
"messageDefaultKey",
")",
"?",
"getStringFromBundle",
"(",
"messageDefaultKey",
")",
":",
"getSuggestion",
"(",
"id",
")",
")",
";",
"}"
] |
Returns the suggestion message for the given message ID and key.
In other words, for a message ID of `XXX_NNN`, and a key `key`,
returns the bundle message named `XXX_NNN_SUG.key`.
If the suggestion key is not found, returns the bundle message
named `XXX_NNN_SUG.default`.
If this latter is not found, returns the bundle message nameed
`XXX_NNN_SUG`.
@param id a message ID
@param key the key of a specific suggestion string
@return the associated suggestion string
|
[
"Returns",
"the",
"suggestion",
"message",
"for",
"the",
"given",
"message",
"ID",
"and",
"key",
".",
"In",
"other",
"words",
"for",
"a",
"message",
"ID",
"of",
"XXX_NNN",
"and",
"a",
"key",
"key",
"returns",
"the",
"bundle",
"message",
"named",
"XXX_NNN_SUG",
".",
"key",
".",
"If",
"the",
"suggestion",
"key",
"is",
"not",
"found",
"returns",
"the",
"bundle",
"message",
"named",
"XXX_NNN_SUG",
".",
"default",
".",
"If",
"this",
"latter",
"is",
"not",
"found",
"returns",
"the",
"bundle",
"message",
"nameed",
"XXX_NNN_SUG",
"."
] |
train
|
https://github.com/w3c/epubcheck/blob/4d5a24d9f2878a2a5497eb11c036cc18fe2c0a78/src/main/java/com/adobe/epubcheck/messages/LocalizedMessages.java#L164-L171
|
goldmansachs/gs-collections
|
collections/src/main/java/com/gs/collections/impl/utility/StringIterate.java
|
StringIterate.collectCodePoint
|
public static String collectCodePoint(String string, CodePointFunction function) {
"""
Transform the int code point elements to a new string using the specified function {@code function}.
@since 7.0
"""
int size = string.length();
StringBuilder builder = new StringBuilder(size);
for (int i = 0; i < size; )
{
int codePoint = string.codePointAt(i);
builder.appendCodePoint(function.valueOf(codePoint));
i += Character.charCount(codePoint);
}
return builder.toString();
}
|
java
|
public static String collectCodePoint(String string, CodePointFunction function)
{
int size = string.length();
StringBuilder builder = new StringBuilder(size);
for (int i = 0; i < size; )
{
int codePoint = string.codePointAt(i);
builder.appendCodePoint(function.valueOf(codePoint));
i += Character.charCount(codePoint);
}
return builder.toString();
}
|
[
"public",
"static",
"String",
"collectCodePoint",
"(",
"String",
"string",
",",
"CodePointFunction",
"function",
")",
"{",
"int",
"size",
"=",
"string",
".",
"length",
"(",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"size",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
")",
"{",
"int",
"codePoint",
"=",
"string",
".",
"codePointAt",
"(",
"i",
")",
";",
"builder",
".",
"appendCodePoint",
"(",
"function",
".",
"valueOf",
"(",
"codePoint",
")",
")",
";",
"i",
"+=",
"Character",
".",
"charCount",
"(",
"codePoint",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
Transform the int code point elements to a new string using the specified function {@code function}.
@since 7.0
|
[
"Transform",
"the",
"int",
"code",
"point",
"elements",
"to",
"a",
"new",
"string",
"using",
"the",
"specified",
"function",
"{",
"@code",
"function",
"}",
"."
] |
train
|
https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/StringIterate.java#L615-L626
|
line/armeria
|
core/src/main/java/com/linecorp/armeria/internal/HttpObjectEncoder.java
|
HttpObjectEncoder.writeReset
|
public final ChannelFuture writeReset(int id, int streamId, Http2Error error) {
"""
Resets the specified stream. If the session protocol does not support multiplexing or the connection
is in unrecoverable state, the connection will be closed. For example, in an HTTP/1 connection, this
will lead the connection to be closed immediately or after the previous requests that are not reset.
"""
if (closed) {
return newClosedSessionFuture();
}
return doWriteReset(id, streamId, error);
}
|
java
|
public final ChannelFuture writeReset(int id, int streamId, Http2Error error) {
if (closed) {
return newClosedSessionFuture();
}
return doWriteReset(id, streamId, error);
}
|
[
"public",
"final",
"ChannelFuture",
"writeReset",
"(",
"int",
"id",
",",
"int",
"streamId",
",",
"Http2Error",
"error",
")",
"{",
"if",
"(",
"closed",
")",
"{",
"return",
"newClosedSessionFuture",
"(",
")",
";",
"}",
"return",
"doWriteReset",
"(",
"id",
",",
"streamId",
",",
"error",
")",
";",
"}"
] |
Resets the specified stream. If the session protocol does not support multiplexing or the connection
is in unrecoverable state, the connection will be closed. For example, in an HTTP/1 connection, this
will lead the connection to be closed immediately or after the previous requests that are not reset.
|
[
"Resets",
"the",
"specified",
"stream",
".",
"If",
"the",
"session",
"protocol",
"does",
"not",
"support",
"multiplexing",
"or",
"the",
"connection",
"is",
"in",
"unrecoverable",
"state",
"the",
"connection",
"will",
"be",
"closed",
".",
"For",
"example",
"in",
"an",
"HTTP",
"/",
"1",
"connection",
"this",
"will",
"lead",
"the",
"connection",
"to",
"be",
"closed",
"immediately",
"or",
"after",
"the",
"previous",
"requests",
"that",
"are",
"not",
"reset",
"."
] |
train
|
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/internal/HttpObjectEncoder.java#L84-L91
|
aws/aws-sdk-java
|
aws-java-sdk-robomaker/src/main/java/com/amazonaws/services/robomaker/model/CreateRobotApplicationRequest.java
|
CreateRobotApplicationRequest.withTags
|
public CreateRobotApplicationRequest withTags(java.util.Map<String, String> tags) {
"""
<p>
A map that contains tag keys and tag values that are attached to the robot application.
</p>
@param tags
A map that contains tag keys and tag values that are attached to the robot application.
@return Returns a reference to this object so that method calls can be chained together.
"""
setTags(tags);
return this;
}
|
java
|
public CreateRobotApplicationRequest withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
[
"public",
"CreateRobotApplicationRequest",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
A map that contains tag keys and tag values that are attached to the robot application.
</p>
@param tags
A map that contains tag keys and tag values that are attached to the robot application.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"A",
"map",
"that",
"contains",
"tag",
"keys",
"and",
"tag",
"values",
"that",
"are",
"attached",
"to",
"the",
"robot",
"application",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-robomaker/src/main/java/com/amazonaws/services/robomaker/model/CreateRobotApplicationRequest.java#L238-L241
|
spring-projects/spring-android
|
spring-android-core/src/main/java/org/springframework/core/CollectionFactory.java
|
CollectionFactory.createApproximateCollection
|
@SuppressWarnings("unchecked")
public static Collection createApproximateCollection(Object collection, int initialCapacity) {
"""
Create the most approximate collection for the given collection.
<p>Creates an ArrayList, TreeSet or linked Set for a List, SortedSet
or Set, respectively.
@param collection the original Collection object
@param initialCapacity the initial capacity
@return the new Collection instance
@see java.util.ArrayList
@see java.util.TreeSet
@see java.util.LinkedHashSet
"""
if (collection instanceof LinkedList) {
return new LinkedList();
}
else if (collection instanceof List) {
return new ArrayList(initialCapacity);
}
else if (collection instanceof SortedSet) {
return new TreeSet(((SortedSet) collection).comparator());
}
else {
return new LinkedHashSet(initialCapacity);
}
}
|
java
|
@SuppressWarnings("unchecked")
public static Collection createApproximateCollection(Object collection, int initialCapacity) {
if (collection instanceof LinkedList) {
return new LinkedList();
}
else if (collection instanceof List) {
return new ArrayList(initialCapacity);
}
else if (collection instanceof SortedSet) {
return new TreeSet(((SortedSet) collection).comparator());
}
else {
return new LinkedHashSet(initialCapacity);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Collection",
"createApproximateCollection",
"(",
"Object",
"collection",
",",
"int",
"initialCapacity",
")",
"{",
"if",
"(",
"collection",
"instanceof",
"LinkedList",
")",
"{",
"return",
"new",
"LinkedList",
"(",
")",
";",
"}",
"else",
"if",
"(",
"collection",
"instanceof",
"List",
")",
"{",
"return",
"new",
"ArrayList",
"(",
"initialCapacity",
")",
";",
"}",
"else",
"if",
"(",
"collection",
"instanceof",
"SortedSet",
")",
"{",
"return",
"new",
"TreeSet",
"(",
"(",
"(",
"SortedSet",
")",
"collection",
")",
".",
"comparator",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"LinkedHashSet",
"(",
"initialCapacity",
")",
";",
"}",
"}"
] |
Create the most approximate collection for the given collection.
<p>Creates an ArrayList, TreeSet or linked Set for a List, SortedSet
or Set, respectively.
@param collection the original Collection object
@param initialCapacity the initial capacity
@return the new Collection instance
@see java.util.ArrayList
@see java.util.TreeSet
@see java.util.LinkedHashSet
|
[
"Create",
"the",
"most",
"approximate",
"collection",
"for",
"the",
"given",
"collection",
".",
"<p",
">",
"Creates",
"an",
"ArrayList",
"TreeSet",
"or",
"linked",
"Set",
"for",
"a",
"List",
"SortedSet",
"or",
"Set",
"respectively",
"."
] |
train
|
https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-core/src/main/java/org/springframework/core/CollectionFactory.java#L203-L217
|
facebookarchive/hadoop-20
|
src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyUgiManager.java
|
ProxyUgiManager.getUgiForUser
|
public static synchronized UnixUserGroupInformation getUgiForUser(
String userName) {
"""
retrieve an ugi for a user. try the cache first, if not found, get it by
running a shell command
"""
long now = System.currentTimeMillis();
long cutoffTime = now - ugiLifetime;
CachedUgi cachedUgi = ugiCache.get(userName);
if (cachedUgi != null && cachedUgi.getInitTime() > cutoffTime)
return cachedUgi.getUgi();
UnixUserGroupInformation ugi = null;
try {
ugi = getUgi(userName);
} catch (IOException e) {
return null;
}
if (ugiCache.size() > CLEANUP_THRESHOLD) { // remove expired ugi's first
for (Iterator<Map.Entry<String, CachedUgi>> it = ugiCache.entrySet()
.iterator(); it.hasNext();) {
Map.Entry<String, CachedUgi> e = it.next();
if (e.getValue().getInitTime() < cutoffTime) {
it.remove();
}
}
}
ugiCache.put(ugi.getUserName(), new CachedUgi(ugi, now));
return ugi;
}
|
java
|
public static synchronized UnixUserGroupInformation getUgiForUser(
String userName) {
long now = System.currentTimeMillis();
long cutoffTime = now - ugiLifetime;
CachedUgi cachedUgi = ugiCache.get(userName);
if (cachedUgi != null && cachedUgi.getInitTime() > cutoffTime)
return cachedUgi.getUgi();
UnixUserGroupInformation ugi = null;
try {
ugi = getUgi(userName);
} catch (IOException e) {
return null;
}
if (ugiCache.size() > CLEANUP_THRESHOLD) { // remove expired ugi's first
for (Iterator<Map.Entry<String, CachedUgi>> it = ugiCache.entrySet()
.iterator(); it.hasNext();) {
Map.Entry<String, CachedUgi> e = it.next();
if (e.getValue().getInitTime() < cutoffTime) {
it.remove();
}
}
}
ugiCache.put(ugi.getUserName(), new CachedUgi(ugi, now));
return ugi;
}
|
[
"public",
"static",
"synchronized",
"UnixUserGroupInformation",
"getUgiForUser",
"(",
"String",
"userName",
")",
"{",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"long",
"cutoffTime",
"=",
"now",
"-",
"ugiLifetime",
";",
"CachedUgi",
"cachedUgi",
"=",
"ugiCache",
".",
"get",
"(",
"userName",
")",
";",
"if",
"(",
"cachedUgi",
"!=",
"null",
"&&",
"cachedUgi",
".",
"getInitTime",
"(",
")",
">",
"cutoffTime",
")",
"return",
"cachedUgi",
".",
"getUgi",
"(",
")",
";",
"UnixUserGroupInformation",
"ugi",
"=",
"null",
";",
"try",
"{",
"ugi",
"=",
"getUgi",
"(",
"userName",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"ugiCache",
".",
"size",
"(",
")",
">",
"CLEANUP_THRESHOLD",
")",
"{",
"// remove expired ugi's first",
"for",
"(",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"CachedUgi",
">",
">",
"it",
"=",
"ugiCache",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Map",
".",
"Entry",
"<",
"String",
",",
"CachedUgi",
">",
"e",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"e",
".",
"getValue",
"(",
")",
".",
"getInitTime",
"(",
")",
"<",
"cutoffTime",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}",
"ugiCache",
".",
"put",
"(",
"ugi",
".",
"getUserName",
"(",
")",
",",
"new",
"CachedUgi",
"(",
"ugi",
",",
"now",
")",
")",
";",
"return",
"ugi",
";",
"}"
] |
retrieve an ugi for a user. try the cache first, if not found, get it by
running a shell command
|
[
"retrieve",
"an",
"ugi",
"for",
"a",
"user",
".",
"try",
"the",
"cache",
"first",
"if",
"not",
"found",
"get",
"it",
"by",
"running",
"a",
"shell",
"command"
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyUgiManager.java#L49-L73
|
mgm-tp/jfunk
|
jfunk-data/src/main/java/com/mgmtp/jfunk/data/source/CsvDataSource.java
|
CsvDataSource.hasMoreData
|
@Override
public boolean hasMoreData(final String dataSetKey) {
"""
{@inheritDoc}
@return {@code false}, as soon as the specified CSV file has no more lines available.
"""
if (getCsvFiles().containsKey(dataSetKey)) {
CsvFile csvFile = getCsvFiles().get(dataSetKey);
if (csvFile.lines == null) {
try {
csvFile.load();
} catch (IOException e) {
throw new IllegalArgumentException("Could not load CSV file " + csvFile.fileName, e);
}
}
return csvFile.hasNextLine();
}
return false;
}
|
java
|
@Override
public boolean hasMoreData(final String dataSetKey) {
if (getCsvFiles().containsKey(dataSetKey)) {
CsvFile csvFile = getCsvFiles().get(dataSetKey);
if (csvFile.lines == null) {
try {
csvFile.load();
} catch (IOException e) {
throw new IllegalArgumentException("Could not load CSV file " + csvFile.fileName, e);
}
}
return csvFile.hasNextLine();
}
return false;
}
|
[
"@",
"Override",
"public",
"boolean",
"hasMoreData",
"(",
"final",
"String",
"dataSetKey",
")",
"{",
"if",
"(",
"getCsvFiles",
"(",
")",
".",
"containsKey",
"(",
"dataSetKey",
")",
")",
"{",
"CsvFile",
"csvFile",
"=",
"getCsvFiles",
"(",
")",
".",
"get",
"(",
"dataSetKey",
")",
";",
"if",
"(",
"csvFile",
".",
"lines",
"==",
"null",
")",
"{",
"try",
"{",
"csvFile",
".",
"load",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Could not load CSV file \"",
"+",
"csvFile",
".",
"fileName",
",",
"e",
")",
";",
"}",
"}",
"return",
"csvFile",
".",
"hasNextLine",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
{@inheritDoc}
@return {@code false}, as soon as the specified CSV file has no more lines available.
|
[
"{",
"@inheritDoc",
"}"
] |
train
|
https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-data/src/main/java/com/mgmtp/jfunk/data/source/CsvDataSource.java#L114-L128
|
jenkinsci/jenkins
|
core/src/main/java/jenkins/util/AntClassLoader.java
|
AntClassLoader.findClassInComponents
|
private Class findClassInComponents(String name)
throws ClassNotFoundException {
"""
Finds a class on the given classpath.
@param name The name of the class to be loaded. Must not be
<code>null</code>.
@return the required Class object
@exception ClassNotFoundException if the requested class does not exist
on this loader's classpath.
"""
// we need to search the components of the path to see if
// we can find the class we want.
String classFilename = getClassFilename(name);
Enumeration e = pathComponents.elements();
while (e.hasMoreElements()) {
File pathComponent = (File) e.nextElement();
try (final InputStream stream = getResourceStream(pathComponent, classFilename)) {
if (stream != null) {
log("Loaded from " + pathComponent + " "
+ classFilename, Project.MSG_DEBUG);
return getClassFromStream(stream, name, pathComponent);
}
} catch (SecurityException se) {
throw se;
} catch (IOException ioe) {
// ioe.printStackTrace();
log("Exception reading component " + pathComponent + " (reason: "
+ ioe.getMessage() + ")", Project.MSG_VERBOSE);
}
}
throw new ClassNotFoundException(name);
}
|
java
|
private Class findClassInComponents(String name)
throws ClassNotFoundException {
// we need to search the components of the path to see if
// we can find the class we want.
String classFilename = getClassFilename(name);
Enumeration e = pathComponents.elements();
while (e.hasMoreElements()) {
File pathComponent = (File) e.nextElement();
try (final InputStream stream = getResourceStream(pathComponent, classFilename)) {
if (stream != null) {
log("Loaded from " + pathComponent + " "
+ classFilename, Project.MSG_DEBUG);
return getClassFromStream(stream, name, pathComponent);
}
} catch (SecurityException se) {
throw se;
} catch (IOException ioe) {
// ioe.printStackTrace();
log("Exception reading component " + pathComponent + " (reason: "
+ ioe.getMessage() + ")", Project.MSG_VERBOSE);
}
}
throw new ClassNotFoundException(name);
}
|
[
"private",
"Class",
"findClassInComponents",
"(",
"String",
"name",
")",
"throws",
"ClassNotFoundException",
"{",
"// we need to search the components of the path to see if",
"// we can find the class we want.",
"String",
"classFilename",
"=",
"getClassFilename",
"(",
"name",
")",
";",
"Enumeration",
"e",
"=",
"pathComponents",
".",
"elements",
"(",
")",
";",
"while",
"(",
"e",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"File",
"pathComponent",
"=",
"(",
"File",
")",
"e",
".",
"nextElement",
"(",
")",
";",
"try",
"(",
"final",
"InputStream",
"stream",
"=",
"getResourceStream",
"(",
"pathComponent",
",",
"classFilename",
")",
")",
"{",
"if",
"(",
"stream",
"!=",
"null",
")",
"{",
"log",
"(",
"\"Loaded from \"",
"+",
"pathComponent",
"+",
"\" \"",
"+",
"classFilename",
",",
"Project",
".",
"MSG_DEBUG",
")",
";",
"return",
"getClassFromStream",
"(",
"stream",
",",
"name",
",",
"pathComponent",
")",
";",
"}",
"}",
"catch",
"(",
"SecurityException",
"se",
")",
"{",
"throw",
"se",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"// ioe.printStackTrace();",
"log",
"(",
"\"Exception reading component \"",
"+",
"pathComponent",
"+",
"\" (reason: \"",
"+",
"ioe",
".",
"getMessage",
"(",
")",
"+",
"\")\"",
",",
"Project",
".",
"MSG_VERBOSE",
")",
";",
"}",
"}",
"throw",
"new",
"ClassNotFoundException",
"(",
"name",
")",
";",
"}"
] |
Finds a class on the given classpath.
@param name The name of the class to be loaded. Must not be
<code>null</code>.
@return the required Class object
@exception ClassNotFoundException if the requested class does not exist
on this loader's classpath.
|
[
"Finds",
"a",
"class",
"on",
"the",
"given",
"classpath",
"."
] |
train
|
https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/util/AntClassLoader.java#L1351-L1374
|
googleads/googleads-java-lib
|
modules/ads_lib/src/main/java/com/google/api/ads/admanager/lib/utils/DateTimesHelper.java
|
DateTimesHelper.toStringForTimeZone
|
public String toStringForTimeZone(T dateTime, String newZoneID) {
"""
Returns string representation of this date time with a different time
zone, preserving the millisecond instant.
<p>This method is useful for finding the local time in another time zone,
especially for filtering.
<p>For example, if this date time holds 12:30 in Europe/London, the result
from this method with Europe/Paris would be 13:30. You may also want to use
this with your network's time zone, i.e.
<pre><code> String timeZoneId = networkService.getCurrentNetwork().getTimeZone();
String statementPart =
"startDateTime > "
+ DateTimes.toString(apiDateTime, timeZoneId);
//...
statementBuilder.where(statementPart);
</code></pre>
This method is in the same style of
{@link DateTime#withZone(org.joda.time.DateTimeZone)}.
@param dateTime the date time to stringify into a new time zone
@param newZoneID the time zone ID of the new zone
@return a string representation of the {@code DateTime} in
{@code yyyy-MM-dd'T'HH:mm:ss}
"""
return toDateTime(dateTime)
.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone(newZoneID)))
.toString(ISODateTimeFormat.dateHourMinuteSecond());
}
|
java
|
public String toStringForTimeZone(T dateTime, String newZoneID) {
return toDateTime(dateTime)
.withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone(newZoneID)))
.toString(ISODateTimeFormat.dateHourMinuteSecond());
}
|
[
"public",
"String",
"toStringForTimeZone",
"(",
"T",
"dateTime",
",",
"String",
"newZoneID",
")",
"{",
"return",
"toDateTime",
"(",
"dateTime",
")",
".",
"withZone",
"(",
"DateTimeZone",
".",
"forTimeZone",
"(",
"TimeZone",
".",
"getTimeZone",
"(",
"newZoneID",
")",
")",
")",
".",
"toString",
"(",
"ISODateTimeFormat",
".",
"dateHourMinuteSecond",
"(",
")",
")",
";",
"}"
] |
Returns string representation of this date time with a different time
zone, preserving the millisecond instant.
<p>This method is useful for finding the local time in another time zone,
especially for filtering.
<p>For example, if this date time holds 12:30 in Europe/London, the result
from this method with Europe/Paris would be 13:30. You may also want to use
this with your network's time zone, i.e.
<pre><code> String timeZoneId = networkService.getCurrentNetwork().getTimeZone();
String statementPart =
"startDateTime > "
+ DateTimes.toString(apiDateTime, timeZoneId);
//...
statementBuilder.where(statementPart);
</code></pre>
This method is in the same style of
{@link DateTime#withZone(org.joda.time.DateTimeZone)}.
@param dateTime the date time to stringify into a new time zone
@param newZoneID the time zone ID of the new zone
@return a string representation of the {@code DateTime} in
{@code yyyy-MM-dd'T'HH:mm:ss}
|
[
"Returns",
"string",
"representation",
"of",
"this",
"date",
"time",
"with",
"a",
"different",
"time",
"zone",
"preserving",
"the",
"millisecond",
"instant",
".",
"<p",
">",
"This",
"method",
"is",
"useful",
"for",
"finding",
"the",
"local",
"time",
"in",
"another",
"time",
"zone",
"especially",
"for",
"filtering",
".",
"<p",
">",
"For",
"example",
"if",
"this",
"date",
"time",
"holds",
"12",
":",
"30",
"in",
"Europe",
"/",
"London",
"the",
"result",
"from",
"this",
"method",
"with",
"Europe",
"/",
"Paris",
"would",
"be",
"13",
":",
"30",
".",
"You",
"may",
"also",
"want",
"to",
"use",
"this",
"with",
"your",
"network",
"s",
"time",
"zone",
"i",
".",
"e",
".",
"<pre",
">",
"<code",
">",
"String",
"timeZoneId",
"=",
"networkService",
".",
"getCurrentNetwork",
"()",
".",
"getTimeZone",
"()",
";",
"String",
"statementPart",
"=",
"startDateTime",
">",
"+",
"DateTimes",
".",
"toString",
"(",
"apiDateTime",
"timeZoneId",
")",
";",
"//",
"...",
"statementBuilder",
".",
"where",
"(",
"statementPart",
")",
";",
"<",
"/",
"code",
">",
"<",
"/",
"pre",
">",
"This",
"method",
"is",
"in",
"the",
"same",
"style",
"of",
"{",
"@link",
"DateTime#withZone",
"(",
"org",
".",
"joda",
".",
"time",
".",
"DateTimeZone",
")",
"}",
"."
] |
train
|
https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib/src/main/java/com/google/api/ads/admanager/lib/utils/DateTimesHelper.java#L240-L244
|
lightblueseas/swing-components
|
src/main/java/de/alpharogroup/swing/panels/output/ConsolePanel.java
|
ConsolePanel.newJXTextArea
|
protected JXTextArea newJXTextArea() {
"""
Factory method that creates a new {@link JXTextArea} that prints the output from system out
and error output stream. For custom
@return the JX text area
"""
JXTextArea textArea = new JXTextArea();
JTextAreaOutputStream taout = new JTextAreaOutputStream(textArea, 60);
PrintStream ps = new PrintStream(taout);
System.setOut(ps);
System.setErr(ps);
return textArea;
}
|
java
|
protected JXTextArea newJXTextArea()
{
JXTextArea textArea = new JXTextArea();
JTextAreaOutputStream taout = new JTextAreaOutputStream(textArea, 60);
PrintStream ps = new PrintStream(taout);
System.setOut(ps);
System.setErr(ps);
return textArea;
}
|
[
"protected",
"JXTextArea",
"newJXTextArea",
"(",
")",
"{",
"JXTextArea",
"textArea",
"=",
"new",
"JXTextArea",
"(",
")",
";",
"JTextAreaOutputStream",
"taout",
"=",
"new",
"JTextAreaOutputStream",
"(",
"textArea",
",",
"60",
")",
";",
"PrintStream",
"ps",
"=",
"new",
"PrintStream",
"(",
"taout",
")",
";",
"System",
".",
"setOut",
"(",
"ps",
")",
";",
"System",
".",
"setErr",
"(",
"ps",
")",
";",
"return",
"textArea",
";",
"}"
] |
Factory method that creates a new {@link JXTextArea} that prints the output from system out
and error output stream. For custom
@return the JX text area
|
[
"Factory",
"method",
"that",
"creates",
"a",
"new",
"{",
"@link",
"JXTextArea",
"}",
"that",
"prints",
"the",
"output",
"from",
"system",
"out",
"and",
"error",
"output",
"stream",
".",
"For",
"custom"
] |
train
|
https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/panels/output/ConsolePanel.java#L60-L68
|
VoltDB/voltdb
|
third_party/java/src/org/apache/commons_voltpatches/cli/CommandLine.java
|
CommandLine.getOptionValue
|
public String getOptionValue(char opt, String defaultValue) {
"""
Retrieve the argument, if any, of an option.
@param opt character name of the option
@param defaultValue is the default value to be returned if the option
is not specified
@return Value of the argument if option is set, and has an argument,
otherwise <code>defaultValue</code>.
"""
return getOptionValue(String.valueOf(opt), defaultValue);
}
|
java
|
public String getOptionValue(char opt, String defaultValue)
{
return getOptionValue(String.valueOf(opt), defaultValue);
}
|
[
"public",
"String",
"getOptionValue",
"(",
"char",
"opt",
",",
"String",
"defaultValue",
")",
"{",
"return",
"getOptionValue",
"(",
"String",
".",
"valueOf",
"(",
"opt",
")",
",",
"defaultValue",
")",
";",
"}"
] |
Retrieve the argument, if any, of an option.
@param opt character name of the option
@param defaultValue is the default value to be returned if the option
is not specified
@return Value of the argument if option is set, and has an argument,
otherwise <code>defaultValue</code>.
|
[
"Retrieve",
"the",
"argument",
"if",
"any",
"of",
"an",
"option",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/commons_voltpatches/cli/CommandLine.java#L245-L248
|
alibaba/vlayout
|
vlayout/src/main/java/com/alibaba/android/vlayout/DelegateAdapter.java
|
DelegateAdapter.addAdapters
|
public void addAdapters(int position, @Nullable List<Adapter> adapters) {
"""
Add adapters in <code>position</code>
@param position the index where adapters added
@param adapters adapters
"""
if (adapters == null || adapters.size() == 0) {
return;
}
if (position < 0) {
position = 0;
}
if (position > mAdapters.size()) {
position = mAdapters.size();
}
List<Adapter> newAdapter = new ArrayList<>();
Iterator<Pair<AdapterDataObserver, Adapter>> itr = mAdapters.iterator();
while (itr.hasNext()) {
Pair<AdapterDataObserver, Adapter> pair = itr.next();
Adapter theOrigin = pair.second;
newAdapter.add(theOrigin);
}
for (Adapter adapter : adapters) {
newAdapter.add(position, adapter);
position++;
}
setAdapters(newAdapter);
}
|
java
|
public void addAdapters(int position, @Nullable List<Adapter> adapters) {
if (adapters == null || adapters.size() == 0) {
return;
}
if (position < 0) {
position = 0;
}
if (position > mAdapters.size()) {
position = mAdapters.size();
}
List<Adapter> newAdapter = new ArrayList<>();
Iterator<Pair<AdapterDataObserver, Adapter>> itr = mAdapters.iterator();
while (itr.hasNext()) {
Pair<AdapterDataObserver, Adapter> pair = itr.next();
Adapter theOrigin = pair.second;
newAdapter.add(theOrigin);
}
for (Adapter adapter : adapters) {
newAdapter.add(position, adapter);
position++;
}
setAdapters(newAdapter);
}
|
[
"public",
"void",
"addAdapters",
"(",
"int",
"position",
",",
"@",
"Nullable",
"List",
"<",
"Adapter",
">",
"adapters",
")",
"{",
"if",
"(",
"adapters",
"==",
"null",
"||",
"adapters",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"position",
"<",
"0",
")",
"{",
"position",
"=",
"0",
";",
"}",
"if",
"(",
"position",
">",
"mAdapters",
".",
"size",
"(",
")",
")",
"{",
"position",
"=",
"mAdapters",
".",
"size",
"(",
")",
";",
"}",
"List",
"<",
"Adapter",
">",
"newAdapter",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Iterator",
"<",
"Pair",
"<",
"AdapterDataObserver",
",",
"Adapter",
">",
">",
"itr",
"=",
"mAdapters",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"itr",
".",
"hasNext",
"(",
")",
")",
"{",
"Pair",
"<",
"AdapterDataObserver",
",",
"Adapter",
">",
"pair",
"=",
"itr",
".",
"next",
"(",
")",
";",
"Adapter",
"theOrigin",
"=",
"pair",
".",
"second",
";",
"newAdapter",
".",
"add",
"(",
"theOrigin",
")",
";",
"}",
"for",
"(",
"Adapter",
"adapter",
":",
"adapters",
")",
"{",
"newAdapter",
".",
"add",
"(",
"position",
",",
"adapter",
")",
";",
"position",
"++",
";",
"}",
"setAdapters",
"(",
"newAdapter",
")",
";",
"}"
] |
Add adapters in <code>position</code>
@param position the index where adapters added
@param adapters adapters
|
[
"Add",
"adapters",
"in",
"<code",
">",
"position<",
"/",
"code",
">"
] |
train
|
https://github.com/alibaba/vlayout/blob/8a5a51d9d2eeb91fed2ee331a4cf3496282452ce/vlayout/src/main/java/com/alibaba/android/vlayout/DelegateAdapter.java#L310-L334
|
jbundle/jbundle
|
base/remote/src/main/java/org/jbundle/base/remote/db/TableSession.java
|
TableSession.get
|
public Object get(int iRowIndex, int iRecordCount) throws DBException, RemoteException {
"""
Receive this relative record in the table.
<p />Note: This is usually used only by thin clients, as thick clients have the code to
fake absolute access.
@param iRowIndex The row to retrieve.
@return The record or an error code as an Integer.
@exception DBException File exception.
"""
try {
Utility.getLogger().info("EJB get: row= " + iRowIndex + " count= " + iRecordCount);
synchronized (this.getTask())
{
Record gridRecord = this.getMainRecord();
gridRecord.setEditMode(DBConstants.EDIT_NONE); // This will keep me from using the current record (Since cache is handled by the client)
if (iRecordCount == 1)
return this.getAtRow(iRowIndex);
else
{
Vector<Object> objVector = new Vector<Object>();
for (int iRow = iRowIndex; iRecordCount > 0; iRow++, iRecordCount--)
{
Object objData = this.getAtRow(iRow);
objVector.add(objData);
if (!(objData instanceof Vector))
break;
}
return objVector; // Vector of multiple rows
}
}
} catch (DBException ex) {
throw ex;
}
}
|
java
|
public Object get(int iRowIndex, int iRecordCount) throws DBException, RemoteException
{
try {
Utility.getLogger().info("EJB get: row= " + iRowIndex + " count= " + iRecordCount);
synchronized (this.getTask())
{
Record gridRecord = this.getMainRecord();
gridRecord.setEditMode(DBConstants.EDIT_NONE); // This will keep me from using the current record (Since cache is handled by the client)
if (iRecordCount == 1)
return this.getAtRow(iRowIndex);
else
{
Vector<Object> objVector = new Vector<Object>();
for (int iRow = iRowIndex; iRecordCount > 0; iRow++, iRecordCount--)
{
Object objData = this.getAtRow(iRow);
objVector.add(objData);
if (!(objData instanceof Vector))
break;
}
return objVector; // Vector of multiple rows
}
}
} catch (DBException ex) {
throw ex;
}
}
|
[
"public",
"Object",
"get",
"(",
"int",
"iRowIndex",
",",
"int",
"iRecordCount",
")",
"throws",
"DBException",
",",
"RemoteException",
"{",
"try",
"{",
"Utility",
".",
"getLogger",
"(",
")",
".",
"info",
"(",
"\"EJB get: row= \"",
"+",
"iRowIndex",
"+",
"\" count= \"",
"+",
"iRecordCount",
")",
";",
"synchronized",
"(",
"this",
".",
"getTask",
"(",
")",
")",
"{",
"Record",
"gridRecord",
"=",
"this",
".",
"getMainRecord",
"(",
")",
";",
"gridRecord",
".",
"setEditMode",
"(",
"DBConstants",
".",
"EDIT_NONE",
")",
";",
"// This will keep me from using the current record (Since cache is handled by the client)",
"if",
"(",
"iRecordCount",
"==",
"1",
")",
"return",
"this",
".",
"getAtRow",
"(",
"iRowIndex",
")",
";",
"else",
"{",
"Vector",
"<",
"Object",
">",
"objVector",
"=",
"new",
"Vector",
"<",
"Object",
">",
"(",
")",
";",
"for",
"(",
"int",
"iRow",
"=",
"iRowIndex",
";",
"iRecordCount",
">",
"0",
";",
"iRow",
"++",
",",
"iRecordCount",
"--",
")",
"{",
"Object",
"objData",
"=",
"this",
".",
"getAtRow",
"(",
"iRow",
")",
";",
"objVector",
".",
"add",
"(",
"objData",
")",
";",
"if",
"(",
"!",
"(",
"objData",
"instanceof",
"Vector",
")",
")",
"break",
";",
"}",
"return",
"objVector",
";",
"// Vector of multiple rows",
"}",
"}",
"}",
"catch",
"(",
"DBException",
"ex",
")",
"{",
"throw",
"ex",
";",
"}",
"}"
] |
Receive this relative record in the table.
<p />Note: This is usually used only by thin clients, as thick clients have the code to
fake absolute access.
@param iRowIndex The row to retrieve.
@return The record or an error code as an Integer.
@exception DBException File exception.
|
[
"Receive",
"this",
"relative",
"record",
"in",
"the",
"table",
".",
"<p",
"/",
">",
"Note",
":",
"This",
"is",
"usually",
"used",
"only",
"by",
"thin",
"clients",
"as",
"thick",
"clients",
"have",
"the",
"code",
"to",
"fake",
"absolute",
"access",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/db/TableSession.java#L660-L688
|
aws/aws-sdk-java
|
aws-java-sdk-core/src/main/java/com/amazonaws/http/conn/ssl/SdkTLSSocketFactory.java
|
SdkTLSSocketFactory.clearSessionCache
|
private void clearSessionCache(final SSLSessionContext sessionContext, final InetSocketAddress remoteAddress) {
"""
Invalidates all SSL/TLS sessions in {@code sessionContext} associated with {@code remoteAddress}.
@param sessionContext collection of SSL/TLS sessions to be (potentially) invalidated
@param remoteAddress associated with sessions to invalidate
"""
final String hostName = remoteAddress.getHostName();
final int port = remoteAddress.getPort();
final Enumeration<byte[]> ids = sessionContext.getIds();
if (ids == null) {
return;
}
while (ids.hasMoreElements()) {
final byte[] id = ids.nextElement();
final SSLSession session = sessionContext.getSession(id);
if (session != null && session.getPeerHost() != null && session.getPeerHost().equalsIgnoreCase(hostName)
&& session.getPeerPort() == port) {
session.invalidate();
if (LOG.isDebugEnabled()) {
LOG.debug("Invalidated session " + session);
}
}
}
}
|
java
|
private void clearSessionCache(final SSLSessionContext sessionContext, final InetSocketAddress remoteAddress) {
final String hostName = remoteAddress.getHostName();
final int port = remoteAddress.getPort();
final Enumeration<byte[]> ids = sessionContext.getIds();
if (ids == null) {
return;
}
while (ids.hasMoreElements()) {
final byte[] id = ids.nextElement();
final SSLSession session = sessionContext.getSession(id);
if (session != null && session.getPeerHost() != null && session.getPeerHost().equalsIgnoreCase(hostName)
&& session.getPeerPort() == port) {
session.invalidate();
if (LOG.isDebugEnabled()) {
LOG.debug("Invalidated session " + session);
}
}
}
}
|
[
"private",
"void",
"clearSessionCache",
"(",
"final",
"SSLSessionContext",
"sessionContext",
",",
"final",
"InetSocketAddress",
"remoteAddress",
")",
"{",
"final",
"String",
"hostName",
"=",
"remoteAddress",
".",
"getHostName",
"(",
")",
";",
"final",
"int",
"port",
"=",
"remoteAddress",
".",
"getPort",
"(",
")",
";",
"final",
"Enumeration",
"<",
"byte",
"[",
"]",
">",
"ids",
"=",
"sessionContext",
".",
"getIds",
"(",
")",
";",
"if",
"(",
"ids",
"==",
"null",
")",
"{",
"return",
";",
"}",
"while",
"(",
"ids",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"final",
"byte",
"[",
"]",
"id",
"=",
"ids",
".",
"nextElement",
"(",
")",
";",
"final",
"SSLSession",
"session",
"=",
"sessionContext",
".",
"getSession",
"(",
"id",
")",
";",
"if",
"(",
"session",
"!=",
"null",
"&&",
"session",
".",
"getPeerHost",
"(",
")",
"!=",
"null",
"&&",
"session",
".",
"getPeerHost",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"hostName",
")",
"&&",
"session",
".",
"getPeerPort",
"(",
")",
"==",
"port",
")",
"{",
"session",
".",
"invalidate",
"(",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Invalidated session \"",
"+",
"session",
")",
";",
"}",
"}",
"}",
"}"
] |
Invalidates all SSL/TLS sessions in {@code sessionContext} associated with {@code remoteAddress}.
@param sessionContext collection of SSL/TLS sessions to be (potentially) invalidated
@param remoteAddress associated with sessions to invalidate
|
[
"Invalidates",
"all",
"SSL",
"/",
"TLS",
"sessions",
"in",
"{",
"@code",
"sessionContext",
"}",
"associated",
"with",
"{",
"@code",
"remoteAddress",
"}",
"."
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-core/src/main/java/com/amazonaws/http/conn/ssl/SdkTLSSocketFactory.java#L171-L191
|
avianey/facebook-api-android-maven
|
facebook/src/main/java/com/facebook/AppEventsLogger.java
|
AppEventsLogger.logPurchase
|
public void logPurchase(BigDecimal purchaseAmount, Currency currency, Bundle parameters) {
"""
Logs a purchase event with Facebook, in the specified amount and with the specified currency. Additional
detail about the purchase can be passed in through the parameters bundle.
@param purchaseAmount Amount of purchase, in the currency specified by the 'currency' parameter. This value
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
@param currency Currency used to specify the amount.
@param parameters Arbitrary additional information for describing this event. Should have no more than
10 entries, and keys should be mostly consistent from one purchase event to the next.
"""
if (purchaseAmount == null) {
notifyDeveloperError("purchaseAmount cannot be null");
return;
} else if (currency == null) {
notifyDeveloperError("currency cannot be null");
return;
}
if (parameters == null) {
parameters = new Bundle();
}
parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, currency.getCurrencyCode());
logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, purchaseAmount.doubleValue(), parameters);
eagerFlush();
}
|
java
|
public void logPurchase(BigDecimal purchaseAmount, Currency currency, Bundle parameters) {
if (purchaseAmount == null) {
notifyDeveloperError("purchaseAmount cannot be null");
return;
} else if (currency == null) {
notifyDeveloperError("currency cannot be null");
return;
}
if (parameters == null) {
parameters = new Bundle();
}
parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, currency.getCurrencyCode());
logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, purchaseAmount.doubleValue(), parameters);
eagerFlush();
}
|
[
"public",
"void",
"logPurchase",
"(",
"BigDecimal",
"purchaseAmount",
",",
"Currency",
"currency",
",",
"Bundle",
"parameters",
")",
"{",
"if",
"(",
"purchaseAmount",
"==",
"null",
")",
"{",
"notifyDeveloperError",
"(",
"\"purchaseAmount cannot be null\"",
")",
";",
"return",
";",
"}",
"else",
"if",
"(",
"currency",
"==",
"null",
")",
"{",
"notifyDeveloperError",
"(",
"\"currency cannot be null\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"parameters",
"==",
"null",
")",
"{",
"parameters",
"=",
"new",
"Bundle",
"(",
")",
";",
"}",
"parameters",
".",
"putString",
"(",
"AppEventsConstants",
".",
"EVENT_PARAM_CURRENCY",
",",
"currency",
".",
"getCurrencyCode",
"(",
")",
")",
";",
"logEvent",
"(",
"AppEventsConstants",
".",
"EVENT_NAME_PURCHASED",
",",
"purchaseAmount",
".",
"doubleValue",
"(",
")",
",",
"parameters",
")",
";",
"eagerFlush",
"(",
")",
";",
"}"
] |
Logs a purchase event with Facebook, in the specified amount and with the specified currency. Additional
detail about the purchase can be passed in through the parameters bundle.
@param purchaseAmount Amount of purchase, in the currency specified by the 'currency' parameter. This value
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
@param currency Currency used to specify the amount.
@param parameters Arbitrary additional information for describing this event. Should have no more than
10 entries, and keys should be mostly consistent from one purchase event to the next.
|
[
"Logs",
"a",
"purchase",
"event",
"with",
"Facebook",
"in",
"the",
"specified",
"amount",
"and",
"with",
"the",
"specified",
"currency",
".",
"Additional",
"detail",
"about",
"the",
"purchase",
"can",
"be",
"passed",
"in",
"through",
"the",
"parameters",
"bundle",
"."
] |
train
|
https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/AppEventsLogger.java#L517-L534
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.