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
|
---|---|---|---|---|---|---|---|---|---|---|
ModeShape/modeshape
|
index-providers/modeshape-lucene-index-provider/src/main/java/org/modeshape/jcr/index/lucene/query/LuceneQueryFactory.java
|
LuceneQueryFactory.forMultiColumnIndex
|
public static LuceneQueryFactory forMultiColumnIndex( ValueFactories factories,
Map<String, Object> variables,
Map<String, PropertyType> propertyTypesByName ) {
"""
Creates a new query factory which can be used to produce Lucene queries for {@link org.modeshape.jcr.index.lucene.MultiColumnIndex}
indexes.
@param factories a {@link ValueFactories} instance; may not be null
@param variables a {@link Map} instance which contains the query variables for a particular query; may be {@code null}
@param propertyTypesByName a {@link Map} representing the columns and their types for the index definition
for which the query should be created; may not be null.
@return a {@link LuceneQueryFactory} instance, never {@code null}
"""
return new LuceneQueryFactory(factories, variables, propertyTypesByName);
}
|
java
|
public static LuceneQueryFactory forMultiColumnIndex( ValueFactories factories,
Map<String, Object> variables,
Map<String, PropertyType> propertyTypesByName ) {
return new LuceneQueryFactory(factories, variables, propertyTypesByName);
}
|
[
"public",
"static",
"LuceneQueryFactory",
"forMultiColumnIndex",
"(",
"ValueFactories",
"factories",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"variables",
",",
"Map",
"<",
"String",
",",
"PropertyType",
">",
"propertyTypesByName",
")",
"{",
"return",
"new",
"LuceneQueryFactory",
"(",
"factories",
",",
"variables",
",",
"propertyTypesByName",
")",
";",
"}"
] |
Creates a new query factory which can be used to produce Lucene queries for {@link org.modeshape.jcr.index.lucene.MultiColumnIndex}
indexes.
@param factories a {@link ValueFactories} instance; may not be null
@param variables a {@link Map} instance which contains the query variables for a particular query; may be {@code null}
@param propertyTypesByName a {@link Map} representing the columns and their types for the index definition
for which the query should be created; may not be null.
@return a {@link LuceneQueryFactory} instance, never {@code null}
|
[
"Creates",
"a",
"new",
"query",
"factory",
"which",
"can",
"be",
"used",
"to",
"produce",
"Lucene",
"queries",
"for",
"{",
"@link",
"org",
".",
"modeshape",
".",
"jcr",
".",
"index",
".",
"lucene",
".",
"MultiColumnIndex",
"}",
"indexes",
"."
] |
train
|
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/index-providers/modeshape-lucene-index-provider/src/main/java/org/modeshape/jcr/index/lucene/query/LuceneQueryFactory.java#L126-L130
|
apache/incubator-heron
|
heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java
|
SchedulerStateManagerAdaptor.updateTopology
|
public Boolean updateTopology(TopologyAPI.Topology topology, String topologyName) {
"""
Update the topology definition for the given topology. If the topology doesn't exist,
create it. If it does, update it.
@param topologyName the name of the topology
@return Boolean - Success or Failure
"""
if (getTopology(topologyName) != null) {
deleteTopology(topologyName);
}
return setTopology(topology, topologyName);
}
|
java
|
public Boolean updateTopology(TopologyAPI.Topology topology, String topologyName) {
if (getTopology(topologyName) != null) {
deleteTopology(topologyName);
}
return setTopology(topology, topologyName);
}
|
[
"public",
"Boolean",
"updateTopology",
"(",
"TopologyAPI",
".",
"Topology",
"topology",
",",
"String",
"topologyName",
")",
"{",
"if",
"(",
"getTopology",
"(",
"topologyName",
")",
"!=",
"null",
")",
"{",
"deleteTopology",
"(",
"topologyName",
")",
";",
"}",
"return",
"setTopology",
"(",
"topology",
",",
"topologyName",
")",
";",
"}"
] |
Update the topology definition for the given topology. If the topology doesn't exist,
create it. If it does, update it.
@param topologyName the name of the topology
@return Boolean - Success or Failure
|
[
"Update",
"the",
"topology",
"definition",
"for",
"the",
"given",
"topology",
".",
"If",
"the",
"topology",
"doesn",
"t",
"exist",
"create",
"it",
".",
"If",
"it",
"does",
"update",
"it",
"."
] |
train
|
https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L129-L134
|
alkacon/opencms-core
|
src/org/opencms/workplace/CmsWorkplace.java
|
CmsWorkplace.checkLock
|
public void checkLock(String resource, CmsLockType type) throws CmsException {
"""
Checks the lock state of the resource and locks it if the autolock feature is enabled.<p>
@param resource the resource name which is checked
@param type indicates the mode {@link CmsLockType#EXCLUSIVE} or {@link CmsLockType#TEMPORARY}
@throws CmsException if reading or locking the resource fails
"""
CmsResource res = getCms().readResource(resource, CmsResourceFilter.ALL);
CmsLock lock = getCms().getLock(res);
boolean lockable = lock.isLockableBy(getCms().getRequestContext().getCurrentUser());
if (OpenCms.getWorkplaceManager().autoLockResources()) {
// autolock is enabled, check the lock state of the resource
if (lockable) {
// resource is lockable, so lock it automatically
if (type == CmsLockType.TEMPORARY) {
getCms().lockResourceTemporary(resource);
} else {
getCms().lockResource(resource);
}
} else {
throw new CmsException(Messages.get().container(Messages.ERR_WORKPLACE_LOCK_RESOURCE_1, resource));
}
} else {
if (!lockable) {
throw new CmsException(Messages.get().container(Messages.ERR_WORKPLACE_LOCK_RESOURCE_1, resource));
}
}
}
|
java
|
public void checkLock(String resource, CmsLockType type) throws CmsException {
CmsResource res = getCms().readResource(resource, CmsResourceFilter.ALL);
CmsLock lock = getCms().getLock(res);
boolean lockable = lock.isLockableBy(getCms().getRequestContext().getCurrentUser());
if (OpenCms.getWorkplaceManager().autoLockResources()) {
// autolock is enabled, check the lock state of the resource
if (lockable) {
// resource is lockable, so lock it automatically
if (type == CmsLockType.TEMPORARY) {
getCms().lockResourceTemporary(resource);
} else {
getCms().lockResource(resource);
}
} else {
throw new CmsException(Messages.get().container(Messages.ERR_WORKPLACE_LOCK_RESOURCE_1, resource));
}
} else {
if (!lockable) {
throw new CmsException(Messages.get().container(Messages.ERR_WORKPLACE_LOCK_RESOURCE_1, resource));
}
}
}
|
[
"public",
"void",
"checkLock",
"(",
"String",
"resource",
",",
"CmsLockType",
"type",
")",
"throws",
"CmsException",
"{",
"CmsResource",
"res",
"=",
"getCms",
"(",
")",
".",
"readResource",
"(",
"resource",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"CmsLock",
"lock",
"=",
"getCms",
"(",
")",
".",
"getLock",
"(",
"res",
")",
";",
"boolean",
"lockable",
"=",
"lock",
".",
"isLockableBy",
"(",
"getCms",
"(",
")",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
")",
";",
"if",
"(",
"OpenCms",
".",
"getWorkplaceManager",
"(",
")",
".",
"autoLockResources",
"(",
")",
")",
"{",
"// autolock is enabled, check the lock state of the resource",
"if",
"(",
"lockable",
")",
"{",
"// resource is lockable, so lock it automatically",
"if",
"(",
"type",
"==",
"CmsLockType",
".",
"TEMPORARY",
")",
"{",
"getCms",
"(",
")",
".",
"lockResourceTemporary",
"(",
"resource",
")",
";",
"}",
"else",
"{",
"getCms",
"(",
")",
".",
"lockResource",
"(",
"resource",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"CmsException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_WORKPLACE_LOCK_RESOURCE_1",
",",
"resource",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"lockable",
")",
"{",
"throw",
"new",
"CmsException",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_WORKPLACE_LOCK_RESOURCE_1",
",",
"resource",
")",
")",
";",
"}",
"}",
"}"
] |
Checks the lock state of the resource and locks it if the autolock feature is enabled.<p>
@param resource the resource name which is checked
@param type indicates the mode {@link CmsLockType#EXCLUSIVE} or {@link CmsLockType#TEMPORARY}
@throws CmsException if reading or locking the resource fails
|
[
"Checks",
"the",
"lock",
"state",
"of",
"the",
"resource",
"and",
"locks",
"it",
"if",
"the",
"autolock",
"feature",
"is",
"enabled",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/CmsWorkplace.java#L1446-L1469
|
landawn/AbacusUtil
|
src/com/landawn/abacus/util/Primitives.java
|
Primitives.unbox
|
public static long[] unbox(final Long[] a, final long valueForNull) {
"""
<p>
Converts an array of object Long to primitives handling {@code null}.
</p>
<p>
This method returns {@code null} for a {@code null} input array.
</p>
@param a
a {@code Long} array, may be {@code null}
@param valueForNull
the value to insert if {@code null} found
@return a {@code long} array, {@code null} if null array input
"""
if (a == null) {
return null;
}
return unbox(a, 0, a.length, valueForNull);
}
|
java
|
public static long[] unbox(final Long[] a, final long valueForNull) {
if (a == null) {
return null;
}
return unbox(a, 0, a.length, valueForNull);
}
|
[
"public",
"static",
"long",
"[",
"]",
"unbox",
"(",
"final",
"Long",
"[",
"]",
"a",
",",
"final",
"long",
"valueForNull",
")",
"{",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"unbox",
"(",
"a",
",",
"0",
",",
"a",
".",
"length",
",",
"valueForNull",
")",
";",
"}"
] |
<p>
Converts an array of object Long to primitives handling {@code null}.
</p>
<p>
This method returns {@code null} for a {@code null} input array.
</p>
@param a
a {@code Long} array, may be {@code null}
@param valueForNull
the value to insert if {@code null} found
@return a {@code long} array, {@code null} if null array input
|
[
"<p",
">",
"Converts",
"an",
"array",
"of",
"object",
"Long",
"to",
"primitives",
"handling",
"{",
"@code",
"null",
"}",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/Primitives.java#L1078-L1084
|
alkacon/opencms-core
|
src/org/opencms/security/CmsOrgUnitManager.java
|
CmsOrgUnitManager.removeResourceFromOrgUnit
|
public void removeResourceFromOrgUnit(CmsObject cms, String ouFqn, String resourceName) throws CmsException {
"""
Removes a resource from the given organizational unit.<p>
@param cms the opencms context
@param ouFqn the fully qualified name of the organizational unit to remove the resource from
@param resourceName the name of the resource that is to be removed from the organizational unit
@throws CmsException if something goes wrong
"""
CmsOrganizationalUnit orgUnit = readOrganizationalUnit(cms, ouFqn);
CmsResource resource = cms.readResource(resourceName, CmsResourceFilter.ALL);
m_securityManager.removeResourceFromOrgUnit(cms.getRequestContext(), orgUnit, resource);
}
|
java
|
public void removeResourceFromOrgUnit(CmsObject cms, String ouFqn, String resourceName) throws CmsException {
CmsOrganizationalUnit orgUnit = readOrganizationalUnit(cms, ouFqn);
CmsResource resource = cms.readResource(resourceName, CmsResourceFilter.ALL);
m_securityManager.removeResourceFromOrgUnit(cms.getRequestContext(), orgUnit, resource);
}
|
[
"public",
"void",
"removeResourceFromOrgUnit",
"(",
"CmsObject",
"cms",
",",
"String",
"ouFqn",
",",
"String",
"resourceName",
")",
"throws",
"CmsException",
"{",
"CmsOrganizationalUnit",
"orgUnit",
"=",
"readOrganizationalUnit",
"(",
"cms",
",",
"ouFqn",
")",
";",
"CmsResource",
"resource",
"=",
"cms",
".",
"readResource",
"(",
"resourceName",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"m_securityManager",
".",
"removeResourceFromOrgUnit",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
",",
"orgUnit",
",",
"resource",
")",
";",
"}"
] |
Removes a resource from the given organizational unit.<p>
@param cms the opencms context
@param ouFqn the fully qualified name of the organizational unit to remove the resource from
@param resourceName the name of the resource that is to be removed from the organizational unit
@throws CmsException if something goes wrong
|
[
"Removes",
"a",
"resource",
"from",
"the",
"given",
"organizational",
"unit",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/security/CmsOrgUnitManager.java#L324-L330
|
Red5/red5-server-common
|
src/main/java/org/red5/server/stream/ClientBroadcastStream.java
|
ClientBroadcastStream.getRecordFile
|
protected File getRecordFile(IScope scope, String name) {
"""
Get the file we'd be recording to based on scope and given name.
@param scope
scope
@param name
record name
@return file
"""
return RecordingListener.getRecordFile(scope, name);
}
|
java
|
protected File getRecordFile(IScope scope, String name) {
return RecordingListener.getRecordFile(scope, name);
}
|
[
"protected",
"File",
"getRecordFile",
"(",
"IScope",
"scope",
",",
"String",
"name",
")",
"{",
"return",
"RecordingListener",
".",
"getRecordFile",
"(",
"scope",
",",
"name",
")",
";",
"}"
] |
Get the file we'd be recording to based on scope and given name.
@param scope
scope
@param name
record name
@return file
|
[
"Get",
"the",
"file",
"we",
"d",
"be",
"recording",
"to",
"based",
"on",
"scope",
"and",
"given",
"name",
"."
] |
train
|
https://github.com/Red5/red5-server-common/blob/39ae73710c25bda86d70b13ef37ae707962217b9/src/main/java/org/red5/server/stream/ClientBroadcastStream.java#L956-L958
|
lettuce-io/lettuce-core
|
src/main/java/io/lettuce/core/AbstractRedisClient.java
|
AbstractRedisClient.initializeChannelAsync
|
@SuppressWarnings("unchecked")
protected <K, V, T extends RedisChannelHandler<K, V>> ConnectionFuture<T> initializeChannelAsync(
ConnectionBuilder connectionBuilder) {
"""
Connect and initialize a channel from {@link ConnectionBuilder}.
@param connectionBuilder must not be {@literal null}.
@return the {@link ConnectionFuture} to synchronize the connection process.
@since 4.4
"""
Mono<SocketAddress> socketAddressSupplier = connectionBuilder.socketAddress();
if (clientResources.eventExecutorGroup().isShuttingDown()) {
throw new IllegalStateException("Cannot connect, Event executor group is terminated.");
}
CompletableFuture<SocketAddress> socketAddressFuture = new CompletableFuture<>();
CompletableFuture<Channel> channelReadyFuture = new CompletableFuture<>();
socketAddressSupplier.doOnError(socketAddressFuture::completeExceptionally).doOnNext(socketAddressFuture::complete)
.subscribe(redisAddress -> {
if (channelReadyFuture.isCancelled()) {
return;
}
initializeChannelAsync0(connectionBuilder, channelReadyFuture, redisAddress);
}, channelReadyFuture::completeExceptionally);
return new DefaultConnectionFuture<>(socketAddressFuture, channelReadyFuture.thenApply(channel -> (T) connectionBuilder
.connection()));
}
|
java
|
@SuppressWarnings("unchecked")
protected <K, V, T extends RedisChannelHandler<K, V>> ConnectionFuture<T> initializeChannelAsync(
ConnectionBuilder connectionBuilder) {
Mono<SocketAddress> socketAddressSupplier = connectionBuilder.socketAddress();
if (clientResources.eventExecutorGroup().isShuttingDown()) {
throw new IllegalStateException("Cannot connect, Event executor group is terminated.");
}
CompletableFuture<SocketAddress> socketAddressFuture = new CompletableFuture<>();
CompletableFuture<Channel> channelReadyFuture = new CompletableFuture<>();
socketAddressSupplier.doOnError(socketAddressFuture::completeExceptionally).doOnNext(socketAddressFuture::complete)
.subscribe(redisAddress -> {
if (channelReadyFuture.isCancelled()) {
return;
}
initializeChannelAsync0(connectionBuilder, channelReadyFuture, redisAddress);
}, channelReadyFuture::completeExceptionally);
return new DefaultConnectionFuture<>(socketAddressFuture, channelReadyFuture.thenApply(channel -> (T) connectionBuilder
.connection()));
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"<",
"K",
",",
"V",
",",
"T",
"extends",
"RedisChannelHandler",
"<",
"K",
",",
"V",
">",
">",
"ConnectionFuture",
"<",
"T",
">",
"initializeChannelAsync",
"(",
"ConnectionBuilder",
"connectionBuilder",
")",
"{",
"Mono",
"<",
"SocketAddress",
">",
"socketAddressSupplier",
"=",
"connectionBuilder",
".",
"socketAddress",
"(",
")",
";",
"if",
"(",
"clientResources",
".",
"eventExecutorGroup",
"(",
")",
".",
"isShuttingDown",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot connect, Event executor group is terminated.\"",
")",
";",
"}",
"CompletableFuture",
"<",
"SocketAddress",
">",
"socketAddressFuture",
"=",
"new",
"CompletableFuture",
"<>",
"(",
")",
";",
"CompletableFuture",
"<",
"Channel",
">",
"channelReadyFuture",
"=",
"new",
"CompletableFuture",
"<>",
"(",
")",
";",
"socketAddressSupplier",
".",
"doOnError",
"(",
"socketAddressFuture",
"::",
"completeExceptionally",
")",
".",
"doOnNext",
"(",
"socketAddressFuture",
"::",
"complete",
")",
".",
"subscribe",
"(",
"redisAddress",
"->",
"{",
"if",
"(",
"channelReadyFuture",
".",
"isCancelled",
"(",
")",
")",
"{",
"return",
";",
"}",
"initializeChannelAsync0",
"(",
"connectionBuilder",
",",
"channelReadyFuture",
",",
"redisAddress",
")",
";",
"}",
",",
"channelReadyFuture",
"::",
"completeExceptionally",
")",
";",
"return",
"new",
"DefaultConnectionFuture",
"<>",
"(",
"socketAddressFuture",
",",
"channelReadyFuture",
".",
"thenApply",
"(",
"channel",
"->",
"(",
"T",
")",
"connectionBuilder",
".",
"connection",
"(",
")",
")",
")",
";",
"}"
] |
Connect and initialize a channel from {@link ConnectionBuilder}.
@param connectionBuilder must not be {@literal null}.
@return the {@link ConnectionFuture} to synchronize the connection process.
@since 4.4
|
[
"Connect",
"and",
"initialize",
"a",
"channel",
"from",
"{",
"@link",
"ConnectionBuilder",
"}",
"."
] |
train
|
https://github.com/lettuce-io/lettuce-core/blob/b6de74e384dea112e3656684ca3f50cdfd6c8e0d/src/main/java/io/lettuce/core/AbstractRedisClient.java#L275-L299
|
inkstand-io/scribble
|
scribble-ldap/src/main/java/io/inkstand/scribble/rules/ldap/builder/DirectoryBuilder.java
|
DirectoryBuilder.withPartition
|
public DirectoryBuilder withPartition(final String partitionId, final String suffix) {
"""
Adds a new partition to the {@link Directory} on initialization.
@param partitionId
the id of the partition
@param suffix
the suffix of the parition so that it can be addressed using a DN
@return this builder
"""
this.partitions.put(partitionId, suffix);
return this;
}
|
java
|
public DirectoryBuilder withPartition(final String partitionId, final String suffix) {
this.partitions.put(partitionId, suffix);
return this;
}
|
[
"public",
"DirectoryBuilder",
"withPartition",
"(",
"final",
"String",
"partitionId",
",",
"final",
"String",
"suffix",
")",
"{",
"this",
".",
"partitions",
".",
"put",
"(",
"partitionId",
",",
"suffix",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a new partition to the {@link Directory} on initialization.
@param partitionId
the id of the partition
@param suffix
the suffix of the parition so that it can be addressed using a DN
@return this builder
|
[
"Adds",
"a",
"new",
"partition",
"to",
"the",
"{",
"@link",
"Directory",
"}",
"on",
"initialization",
"."
] |
train
|
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-ldap/src/main/java/io/inkstand/scribble/rules/ldap/builder/DirectoryBuilder.java#L109-L113
|
stripe/stripe-android
|
stripe/src/main/java/com/stripe/android/Stripe.java
|
Stripe.createSourceSynchronous
|
@Nullable
public Source createSourceSynchronous(@NonNull SourceParams params)
throws AuthenticationException,
InvalidRequestException,
APIConnectionException,
APIException {
"""
Blocking method to create a {@link Source} object using this object's
{@link Stripe#mDefaultPublishableKey key}.
Do not call this on the UI thread or your app will crash.
@param params a set of {@link SourceParams} with which to create the source
@return a {@link Source}, or {@code null} if a problem occurred
@throws AuthenticationException failure to properly authenticate yourself (check your key)
@throws InvalidRequestException your request has invalid parameters
@throws APIConnectionException failure to connect to Stripe's API
@throws APIException any other type of problem (for instance, a temporary issue with
Stripe's servers
"""
return createSourceSynchronous(params, null);
}
|
java
|
@Nullable
public Source createSourceSynchronous(@NonNull SourceParams params)
throws AuthenticationException,
InvalidRequestException,
APIConnectionException,
APIException {
return createSourceSynchronous(params, null);
}
|
[
"@",
"Nullable",
"public",
"Source",
"createSourceSynchronous",
"(",
"@",
"NonNull",
"SourceParams",
"params",
")",
"throws",
"AuthenticationException",
",",
"InvalidRequestException",
",",
"APIConnectionException",
",",
"APIException",
"{",
"return",
"createSourceSynchronous",
"(",
"params",
",",
"null",
")",
";",
"}"
] |
Blocking method to create a {@link Source} object using this object's
{@link Stripe#mDefaultPublishableKey key}.
Do not call this on the UI thread or your app will crash.
@param params a set of {@link SourceParams} with which to create the source
@return a {@link Source}, or {@code null} if a problem occurred
@throws AuthenticationException failure to properly authenticate yourself (check your key)
@throws InvalidRequestException your request has invalid parameters
@throws APIConnectionException failure to connect to Stripe's API
@throws APIException any other type of problem (for instance, a temporary issue with
Stripe's servers
|
[
"Blocking",
"method",
"to",
"create",
"a",
"{",
"@link",
"Source",
"}",
"object",
"using",
"this",
"object",
"s",
"{",
"@link",
"Stripe#mDefaultPublishableKey",
"key",
"}",
"."
] |
train
|
https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/Stripe.java#L395-L402
|
Sciss/abc4j
|
abc/src/main/java/abc/util/PropertyManager.java
|
PropertyManager.setProperty
|
public void setProperty(String key, String val) {
"""
Sets Application/User String properties; default property values cannot be set.
"""
ArrayList list = null;
Object oldValue = null;
oldValue = getProperty(key);
appProps.setProperty(key, val);
if (listeners.containsKey(key)) {
list = (ArrayList)listeners.get(key);
int len = list.size();
if (len > 0) {
PropertyChangeEvent evt = new PropertyChangeEvent(this, key, oldValue, val);
for (Object aList : list) {
if (aList instanceof PropertyChangeListener)
((PropertyChangeListener) aList).propertyChange(evt);
}
}
}
}
|
java
|
public void setProperty(String key, String val) {
ArrayList list = null;
Object oldValue = null;
oldValue = getProperty(key);
appProps.setProperty(key, val);
if (listeners.containsKey(key)) {
list = (ArrayList)listeners.get(key);
int len = list.size();
if (len > 0) {
PropertyChangeEvent evt = new PropertyChangeEvent(this, key, oldValue, val);
for (Object aList : list) {
if (aList instanceof PropertyChangeListener)
((PropertyChangeListener) aList).propertyChange(evt);
}
}
}
}
|
[
"public",
"void",
"setProperty",
"(",
"String",
"key",
",",
"String",
"val",
")",
"{",
"ArrayList",
"list",
"=",
"null",
";",
"Object",
"oldValue",
"=",
"null",
";",
"oldValue",
"=",
"getProperty",
"(",
"key",
")",
";",
"appProps",
".",
"setProperty",
"(",
"key",
",",
"val",
")",
";",
"if",
"(",
"listeners",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"list",
"=",
"(",
"ArrayList",
")",
"listeners",
".",
"get",
"(",
"key",
")",
";",
"int",
"len",
"=",
"list",
".",
"size",
"(",
")",
";",
"if",
"(",
"len",
">",
"0",
")",
"{",
"PropertyChangeEvent",
"evt",
"=",
"new",
"PropertyChangeEvent",
"(",
"this",
",",
"key",
",",
"oldValue",
",",
"val",
")",
";",
"for",
"(",
"Object",
"aList",
":",
"list",
")",
"{",
"if",
"(",
"aList",
"instanceof",
"PropertyChangeListener",
")",
"(",
"(",
"PropertyChangeListener",
")",
"aList",
")",
".",
"propertyChange",
"(",
"evt",
")",
";",
"}",
"}",
"}",
"}"
] |
Sets Application/User String properties; default property values cannot be set.
|
[
"Sets",
"Application",
"/",
"User",
"String",
"properties",
";",
"default",
"property",
"values",
"cannot",
"be",
"set",
"."
] |
train
|
https://github.com/Sciss/abc4j/blob/117b405642c84a7bfca4e3e13668838258b90ca7/abc/src/main/java/abc/util/PropertyManager.java#L92-L112
|
alkacon/opencms-core
|
src/org/opencms/ade/configuration/CmsConfigurationCache.java
|
CmsConfigurationCache.isDetailPage
|
public boolean isDetailPage(CmsObject cms, CmsResource resource) {
"""
Checks if the given resource is a detail page.<p>
Delegates the actual work to the cache state, but also caches the result.<p>
@param cms the current CMS context
@param resource the resource to check
@return true if the given resource is a detail page
"""
try {
boolean result = m_detailPageIdCache.get(resource).booleanValue();
if (!result) {
// We want new detail pages to be available fast, so we don't cache negative results
m_detailPageIdCache.invalidate(resource);
}
return result;
} catch (ExecutionException e) {
LOG.error(e.getLocalizedMessage(), e);
return true;
}
}
|
java
|
public boolean isDetailPage(CmsObject cms, CmsResource resource) {
try {
boolean result = m_detailPageIdCache.get(resource).booleanValue();
if (!result) {
// We want new detail pages to be available fast, so we don't cache negative results
m_detailPageIdCache.invalidate(resource);
}
return result;
} catch (ExecutionException e) {
LOG.error(e.getLocalizedMessage(), e);
return true;
}
}
|
[
"public",
"boolean",
"isDetailPage",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
")",
"{",
"try",
"{",
"boolean",
"result",
"=",
"m_detailPageIdCache",
".",
"get",
"(",
"resource",
")",
".",
"booleanValue",
"(",
")",
";",
"if",
"(",
"!",
"result",
")",
"{",
"// We want new detail pages to be available fast, so we don't cache negative results\r",
"m_detailPageIdCache",
".",
"invalidate",
"(",
"resource",
")",
";",
"}",
"return",
"result",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"true",
";",
"}",
"}"
] |
Checks if the given resource is a detail page.<p>
Delegates the actual work to the cache state, but also caches the result.<p>
@param cms the current CMS context
@param resource the resource to check
@return true if the given resource is a detail page
|
[
"Checks",
"if",
"the",
"given",
"resource",
"is",
"a",
"detail",
"page",
".",
"<p",
">",
"Delegates",
"the",
"actual",
"work",
"to",
"the",
"cache",
"state",
"but",
"also",
"caches",
"the",
"result",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/CmsConfigurationCache.java#L266-L279
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java
|
LabelInfo.checkForValidEscapedCharacter
|
private static void checkForValidEscapedCharacter(int index, String labelDescriptor) {
"""
Confirms that the character at the specified index within the given label descriptor is
a valid 'escapable' character. i.e. either an ampersand or backslash.
@param index The position within the label descriptor of the character to be checked.
@param labelDescriptor The label descriptor.
@throws NullPointerException if {@code labelDescriptor} is null.
@throws IllegalArgumentException if the given {@code index} position is beyond the length
of the string or if the character at that position is not an ampersand or backslash.
"""
if (index >= labelDescriptor.length()) {
throw new IllegalArgumentException(
"The label descriptor contains an invalid escape sequence. Backslash "
+ "characters (\\) must be followed by either an ampersand (&) or another "
+ "backslash.");
}
char escapedChar = labelDescriptor.charAt(index);
if (escapedChar != '&' && escapedChar != '\\') {
throw new IllegalArgumentException(
"The label descriptor ["
+ labelDescriptor
+ "] contains an invalid escape sequence. Backslash "
+ "characters (\\) must be followed by either an ampersand (&) or another "
+ "backslash.");
}
}
|
java
|
private static void checkForValidEscapedCharacter(int index, String labelDescriptor) {
if (index >= labelDescriptor.length()) {
throw new IllegalArgumentException(
"The label descriptor contains an invalid escape sequence. Backslash "
+ "characters (\\) must be followed by either an ampersand (&) or another "
+ "backslash.");
}
char escapedChar = labelDescriptor.charAt(index);
if (escapedChar != '&' && escapedChar != '\\') {
throw new IllegalArgumentException(
"The label descriptor ["
+ labelDescriptor
+ "] contains an invalid escape sequence. Backslash "
+ "characters (\\) must be followed by either an ampersand (&) or another "
+ "backslash.");
}
}
|
[
"private",
"static",
"void",
"checkForValidEscapedCharacter",
"(",
"int",
"index",
",",
"String",
"labelDescriptor",
")",
"{",
"if",
"(",
"index",
">=",
"labelDescriptor",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The label descriptor contains an invalid escape sequence. Backslash \"",
"+",
"\"characters (\\\\) must be followed by either an ampersand (&) or another \"",
"+",
"\"backslash.\"",
")",
";",
"}",
"char",
"escapedChar",
"=",
"labelDescriptor",
".",
"charAt",
"(",
"index",
")",
";",
"if",
"(",
"escapedChar",
"!=",
"'",
"'",
"&&",
"escapedChar",
"!=",
"'",
"'",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The label descriptor [\"",
"+",
"labelDescriptor",
"+",
"\"] contains an invalid escape sequence. Backslash \"",
"+",
"\"characters (\\\\) must be followed by either an ampersand (&) or another \"",
"+",
"\"backslash.\"",
")",
";",
"}",
"}"
] |
Confirms that the character at the specified index within the given label descriptor is
a valid 'escapable' character. i.e. either an ampersand or backslash.
@param index The position within the label descriptor of the character to be checked.
@param labelDescriptor The label descriptor.
@throws NullPointerException if {@code labelDescriptor} is null.
@throws IllegalArgumentException if the given {@code index} position is beyond the length
of the string or if the character at that position is not an ampersand or backslash.
|
[
"Confirms",
"that",
"the",
"character",
"at",
"the",
"specified",
"index",
"within",
"the",
"given",
"label",
"descriptor",
"is",
"a",
"valid",
"escapable",
"character",
".",
"i",
".",
"e",
".",
"either",
"an",
"ampersand",
"or",
"backslash",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/core/support/LabelInfo.java#L190-L210
|
QSFT/Doradus
|
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java
|
CassandraDefs.slicePredicateStartEndCol
|
static SlicePredicate slicePredicateStartEndCol(byte[] startColName, byte[] endColName, boolean reversed) {
"""
Create a SlicePredicate that starts at the given column name, selecting up to
{@link #MAX_COLS_BATCH_SIZE} columns.
@param startColName Starting column name as a byte[].
@param endColName Ending column name as a byte[]
@return SlicePredicate that starts at the given starting column name,
ends at the given ending column name, selecting up to
{@link #MAX_COLS_BATCH_SIZE} columns.
"""
if(startColName == null) startColName = EMPTY_BYTES;
if(endColName == null) endColName = EMPTY_BYTES;
SliceRange sliceRange =
new SliceRange(
ByteBuffer.wrap(startColName), ByteBuffer.wrap(endColName),
reversed, CassandraDefs.MAX_COLS_BATCH_SIZE);
SlicePredicate slicePred = new SlicePredicate();
slicePred.setSlice_range(sliceRange);
return slicePred;
}
|
java
|
static SlicePredicate slicePredicateStartEndCol(byte[] startColName, byte[] endColName, boolean reversed) {
if(startColName == null) startColName = EMPTY_BYTES;
if(endColName == null) endColName = EMPTY_BYTES;
SliceRange sliceRange =
new SliceRange(
ByteBuffer.wrap(startColName), ByteBuffer.wrap(endColName),
reversed, CassandraDefs.MAX_COLS_BATCH_SIZE);
SlicePredicate slicePred = new SlicePredicate();
slicePred.setSlice_range(sliceRange);
return slicePred;
}
|
[
"static",
"SlicePredicate",
"slicePredicateStartEndCol",
"(",
"byte",
"[",
"]",
"startColName",
",",
"byte",
"[",
"]",
"endColName",
",",
"boolean",
"reversed",
")",
"{",
"if",
"(",
"startColName",
"==",
"null",
")",
"startColName",
"=",
"EMPTY_BYTES",
";",
"if",
"(",
"endColName",
"==",
"null",
")",
"endColName",
"=",
"EMPTY_BYTES",
";",
"SliceRange",
"sliceRange",
"=",
"new",
"SliceRange",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"startColName",
")",
",",
"ByteBuffer",
".",
"wrap",
"(",
"endColName",
")",
",",
"reversed",
",",
"CassandraDefs",
".",
"MAX_COLS_BATCH_SIZE",
")",
";",
"SlicePredicate",
"slicePred",
"=",
"new",
"SlicePredicate",
"(",
")",
";",
"slicePred",
".",
"setSlice_range",
"(",
"sliceRange",
")",
";",
"return",
"slicePred",
";",
"}"
] |
Create a SlicePredicate that starts at the given column name, selecting up to
{@link #MAX_COLS_BATCH_SIZE} columns.
@param startColName Starting column name as a byte[].
@param endColName Ending column name as a byte[]
@return SlicePredicate that starts at the given starting column name,
ends at the given ending column name, selecting up to
{@link #MAX_COLS_BATCH_SIZE} columns.
|
[
"Create",
"a",
"SlicePredicate",
"that",
"starts",
"at",
"the",
"given",
"column",
"name",
"selecting",
"up",
"to",
"{",
"@link",
"#MAX_COLS_BATCH_SIZE",
"}",
"columns",
"."
] |
train
|
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java#L193-L203
|
square/javapoet
|
src/main/java/com/squareup/javapoet/TypeVariableName.java
|
TypeVariableName.get
|
public static TypeVariableName get(String name, TypeName... bounds) {
"""
Returns type variable named {@code name} with {@code bounds}.
"""
return TypeVariableName.of(name, Arrays.asList(bounds));
}
|
java
|
public static TypeVariableName get(String name, TypeName... bounds) {
return TypeVariableName.of(name, Arrays.asList(bounds));
}
|
[
"public",
"static",
"TypeVariableName",
"get",
"(",
"String",
"name",
",",
"TypeName",
"...",
"bounds",
")",
"{",
"return",
"TypeVariableName",
".",
"of",
"(",
"name",
",",
"Arrays",
".",
"asList",
"(",
"bounds",
")",
")",
";",
"}"
] |
Returns type variable named {@code name} with {@code bounds}.
|
[
"Returns",
"type",
"variable",
"named",
"{"
] |
train
|
https://github.com/square/javapoet/blob/0f93da9a3d9a1da8d29fc993409fcf83d40452bc/src/main/java/com/squareup/javapoet/TypeVariableName.java#L93-L95
|
eyp/serfj
|
src/main/java/net/sf/serfj/ServletHelper.java
|
ServletHelper.isRequestMethodServed
|
private boolean isRequestMethodServed(Method method, HttpMethod httpMethod) {
"""
Checks if a resource's method attends HTTP requests using a concrete
HTTP_METHOD (GET, POST, PUT, DELETE). A method accept a particular
HTTP_METHOD if it's annotated with the correct annotation (@GET, @POST,
@PUT, @DELETE).
@param method
A class's method.
@param httpMethod
HTTP_METHOD that comes in the request.
@return <code>true</code> if the method accepts that HTTP_METHOD,
<code>false</code> otherwise.
@throws IllegalArgumentException
if HttpMethod is not supported.
"""
boolean accepts = false;
switch (httpMethod) {
case GET:
accepts = method.getAnnotation(GET.class) != null;
break;
case POST:
accepts = method.getAnnotation(POST.class) != null;
break;
case PUT:
accepts = method.getAnnotation(PUT.class) != null;
break;
case DELETE:
accepts = method.getAnnotation(DELETE.class) != null;
break;
default:
throw new IllegalArgumentException("HTTP method not supported: " + httpMethod);
}
return accepts;
}
|
java
|
private boolean isRequestMethodServed(Method method, HttpMethod httpMethod) {
boolean accepts = false;
switch (httpMethod) {
case GET:
accepts = method.getAnnotation(GET.class) != null;
break;
case POST:
accepts = method.getAnnotation(POST.class) != null;
break;
case PUT:
accepts = method.getAnnotation(PUT.class) != null;
break;
case DELETE:
accepts = method.getAnnotation(DELETE.class) != null;
break;
default:
throw new IllegalArgumentException("HTTP method not supported: " + httpMethod);
}
return accepts;
}
|
[
"private",
"boolean",
"isRequestMethodServed",
"(",
"Method",
"method",
",",
"HttpMethod",
"httpMethod",
")",
"{",
"boolean",
"accepts",
"=",
"false",
";",
"switch",
"(",
"httpMethod",
")",
"{",
"case",
"GET",
":",
"accepts",
"=",
"method",
".",
"getAnnotation",
"(",
"GET",
".",
"class",
")",
"!=",
"null",
";",
"break",
";",
"case",
"POST",
":",
"accepts",
"=",
"method",
".",
"getAnnotation",
"(",
"POST",
".",
"class",
")",
"!=",
"null",
";",
"break",
";",
"case",
"PUT",
":",
"accepts",
"=",
"method",
".",
"getAnnotation",
"(",
"PUT",
".",
"class",
")",
"!=",
"null",
";",
"break",
";",
"case",
"DELETE",
":",
"accepts",
"=",
"method",
".",
"getAnnotation",
"(",
"DELETE",
".",
"class",
")",
"!=",
"null",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"HTTP method not supported: \"",
"+",
"httpMethod",
")",
";",
"}",
"return",
"accepts",
";",
"}"
] |
Checks if a resource's method attends HTTP requests using a concrete
HTTP_METHOD (GET, POST, PUT, DELETE). A method accept a particular
HTTP_METHOD if it's annotated with the correct annotation (@GET, @POST,
@PUT, @DELETE).
@param method
A class's method.
@param httpMethod
HTTP_METHOD that comes in the request.
@return <code>true</code> if the method accepts that HTTP_METHOD,
<code>false</code> otherwise.
@throws IllegalArgumentException
if HttpMethod is not supported.
|
[
"Checks",
"if",
"a",
"resource",
"s",
"method",
"attends",
"HTTP",
"requests",
"using",
"a",
"concrete",
"HTTP_METHOD",
"(",
"GET",
"POST",
"PUT",
"DELETE",
")",
".",
"A",
"method",
"accept",
"a",
"particular",
"HTTP_METHOD",
"if",
"it",
"s",
"annotated",
"with",
"the",
"correct",
"annotation",
"(",
"@GET",
"@POST",
"@PUT",
"@DELETE",
")",
"."
] |
train
|
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/ServletHelper.java#L288-L307
|
RestComm/sip-servlets
|
sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java
|
FacebookRestClient.marketplace_createListing
|
public Long marketplace_createListing(Boolean showOnProfile, MarketplaceListing attrs)
throws FacebookException, IOException {
"""
Create a marketplace listing
@param showOnProfile whether the listing can be shown on the user's profile
@param attrs the properties of the listing
@return the id of the created listing
@see MarketplaceListing
@see <a href="http://wiki.developers.facebook.com/index.php/Marketplace.createListing">
Developers Wiki: marketplace.createListing</a>
"""
T result =
this.callMethod(FacebookMethod.MARKETPLACE_CREATE_LISTING,
new Pair<String, CharSequence>("show_on_profile", showOnProfile ? "1" : "0"),
new Pair<String, CharSequence>("listing_id", "0"),
new Pair<String, CharSequence>("listing_attrs", attrs.jsonify().toString()));
return this.extractLong(result);
}
|
java
|
public Long marketplace_createListing(Boolean showOnProfile, MarketplaceListing attrs)
throws FacebookException, IOException {
T result =
this.callMethod(FacebookMethod.MARKETPLACE_CREATE_LISTING,
new Pair<String, CharSequence>("show_on_profile", showOnProfile ? "1" : "0"),
new Pair<String, CharSequence>("listing_id", "0"),
new Pair<String, CharSequence>("listing_attrs", attrs.jsonify().toString()));
return this.extractLong(result);
}
|
[
"public",
"Long",
"marketplace_createListing",
"(",
"Boolean",
"showOnProfile",
",",
"MarketplaceListing",
"attrs",
")",
"throws",
"FacebookException",
",",
"IOException",
"{",
"T",
"result",
"=",
"this",
".",
"callMethod",
"(",
"FacebookMethod",
".",
"MARKETPLACE_CREATE_LISTING",
",",
"new",
"Pair",
"<",
"String",
",",
"CharSequence",
">",
"(",
"\"show_on_profile\"",
",",
"showOnProfile",
"?",
"\"1\"",
":",
"\"0\"",
")",
",",
"new",
"Pair",
"<",
"String",
",",
"CharSequence",
">",
"(",
"\"listing_id\"",
",",
"\"0\"",
")",
",",
"new",
"Pair",
"<",
"String",
",",
"CharSequence",
">",
"(",
"\"listing_attrs\"",
",",
"attrs",
".",
"jsonify",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"return",
"this",
".",
"extractLong",
"(",
"result",
")",
";",
"}"
] |
Create a marketplace listing
@param showOnProfile whether the listing can be shown on the user's profile
@param attrs the properties of the listing
@return the id of the created listing
@see MarketplaceListing
@see <a href="http://wiki.developers.facebook.com/index.php/Marketplace.createListing">
Developers Wiki: marketplace.createListing</a>
|
[
"Create",
"a",
"marketplace",
"listing"
] |
train
|
https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java#L1929-L1937
|
BorderTech/wcomponents
|
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java
|
TreeUtil.findWComponent
|
public static ComponentWithContext findWComponent(final WComponent component,
final String[] path) {
"""
Retrieves the first WComponent by its path in the WComponent tree. See
{@link #findWComponents(WComponent, String[])} for a description of paths.
<p>
Searches only visible components.
</p>
@param component the component to search from.
@param path the path to the WComponent.
@return the first component matching the given path, or null if not found.
"""
return findWComponent(component, path, true);
}
|
java
|
public static ComponentWithContext findWComponent(final WComponent component,
final String[] path) {
return findWComponent(component, path, true);
}
|
[
"public",
"static",
"ComponentWithContext",
"findWComponent",
"(",
"final",
"WComponent",
"component",
",",
"final",
"String",
"[",
"]",
"path",
")",
"{",
"return",
"findWComponent",
"(",
"component",
",",
"path",
",",
"true",
")",
";",
"}"
] |
Retrieves the first WComponent by its path in the WComponent tree. See
{@link #findWComponents(WComponent, String[])} for a description of paths.
<p>
Searches only visible components.
</p>
@param component the component to search from.
@param path the path to the WComponent.
@return the first component matching the given path, or null if not found.
|
[
"Retrieves",
"the",
"first",
"WComponent",
"by",
"its",
"path",
"in",
"the",
"WComponent",
"tree",
".",
"See",
"{",
"@link",
"#findWComponents",
"(",
"WComponent",
"String",
"[]",
")",
"}",
"for",
"a",
"description",
"of",
"paths",
".",
"<p",
">",
"Searches",
"only",
"visible",
"components",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/TreeUtil.java#L483-L486
|
alexvasilkov/AndroidCommons
|
library/src/main/java/com/alexvasilkov/android/commons/prefs/PreferencesHelper.java
|
PreferencesHelper.getSerializable
|
@Nullable
public static Serializable getSerializable(@NonNull SharedPreferences prefs,
@NonNull String key) {
"""
Retrieves serializable object stored as BASE_64 encoded string.
"""
return deserialize(prefs.getString(key, null));
}
|
java
|
@Nullable
public static Serializable getSerializable(@NonNull SharedPreferences prefs,
@NonNull String key) {
return deserialize(prefs.getString(key, null));
}
|
[
"@",
"Nullable",
"public",
"static",
"Serializable",
"getSerializable",
"(",
"@",
"NonNull",
"SharedPreferences",
"prefs",
",",
"@",
"NonNull",
"String",
"key",
")",
"{",
"return",
"deserialize",
"(",
"prefs",
".",
"getString",
"(",
"key",
",",
"null",
")",
")",
";",
"}"
] |
Retrieves serializable object stored as BASE_64 encoded string.
|
[
"Retrieves",
"serializable",
"object",
"stored",
"as",
"BASE_64",
"encoded",
"string",
"."
] |
train
|
https://github.com/alexvasilkov/AndroidCommons/blob/aca9f6d5acfc6bd3694984b7f89956e1a0146ddb/library/src/main/java/com/alexvasilkov/android/commons/prefs/PreferencesHelper.java#L119-L123
|
venmo/cursor-utils
|
cursor-utils/src/main/java/com/venmo/cursor/IterableCursorWrapper.java
|
IterableCursorWrapper.getFloat
|
public float getFloat(String columnName, float defaultValue) {
"""
Convenience alias to {@code getFloat\(getColumnIndex(columnName))}. If the column does not
exist for the cursor, return {@code defaultValue}.
"""
int index = getColumnIndex(columnName);
if (isValidIndex(index)) {
return getFloat(index);
} else {
return defaultValue;
}
}
|
java
|
public float getFloat(String columnName, float defaultValue) {
int index = getColumnIndex(columnName);
if (isValidIndex(index)) {
return getFloat(index);
} else {
return defaultValue;
}
}
|
[
"public",
"float",
"getFloat",
"(",
"String",
"columnName",
",",
"float",
"defaultValue",
")",
"{",
"int",
"index",
"=",
"getColumnIndex",
"(",
"columnName",
")",
";",
"if",
"(",
"isValidIndex",
"(",
"index",
")",
")",
"{",
"return",
"getFloat",
"(",
"index",
")",
";",
"}",
"else",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] |
Convenience alias to {@code getFloat\(getColumnIndex(columnName))}. If the column does not
exist for the cursor, return {@code defaultValue}.
|
[
"Convenience",
"alias",
"to",
"{"
] |
train
|
https://github.com/venmo/cursor-utils/blob/52cf91c4253346632fe70b8d7b7eab8bbcc9b248/cursor-utils/src/main/java/com/venmo/cursor/IterableCursorWrapper.java#L170-L177
|
basho/riak-java-client
|
src/main/java/com/basho/riak/client/api/convert/reflection/AnnotationUtil.java
|
AnnotationUtil.populateIndexes
|
public static <T> T populateIndexes(RiakIndexes indexes, T domainObject) {
"""
Attempts to populate a domain object with the contents of the supplied
RiakIndexes by looking for a {@literal @RiakIndex} annotated member
@param <T> the type of the domain object
@param indexes a populated RiakIndexes object.
@param domainObject the domain object
@return the domain object.
"""
return AnnotationHelper.getInstance().setIndexes(indexes, domainObject);
}
|
java
|
public static <T> T populateIndexes(RiakIndexes indexes, T domainObject)
{
return AnnotationHelper.getInstance().setIndexes(indexes, domainObject);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"populateIndexes",
"(",
"RiakIndexes",
"indexes",
",",
"T",
"domainObject",
")",
"{",
"return",
"AnnotationHelper",
".",
"getInstance",
"(",
")",
".",
"setIndexes",
"(",
"indexes",
",",
"domainObject",
")",
";",
"}"
] |
Attempts to populate a domain object with the contents of the supplied
RiakIndexes by looking for a {@literal @RiakIndex} annotated member
@param <T> the type of the domain object
@param indexes a populated RiakIndexes object.
@param domainObject the domain object
@return the domain object.
|
[
"Attempts",
"to",
"populate",
"a",
"domain",
"object",
"with",
"the",
"contents",
"of",
"the",
"supplied",
"RiakIndexes",
"by",
"looking",
"for",
"a",
"{",
"@literal",
"@RiakIndex",
"}",
"annotated",
"member"
] |
train
|
https://github.com/basho/riak-java-client/blob/bed6cd60f360bacf1b873ab92dd74f2526651e71/src/main/java/com/basho/riak/client/api/convert/reflection/AnnotationUtil.java#L223-L226
|
alkacon/opencms-core
|
src/org/opencms/jsp/util/CmsJspImageBean.java
|
CmsJspImageBean.addSrcSetWidthVariants
|
public void addSrcSetWidthVariants(int minWidth, int maxWidth) {
"""
Adds a number of size variations to the source set.<p>
In case the screen size is not really known, it may be a good idea to add
some variations for large images to make sure there are some common options in case the basic
image is very large.<p>
@param minWidth the minimum image width to add size variations for
@param maxWidth the maximum width size variation to create
"""
int imageWidth = getWidth();
if (imageWidth > minWidth) {
// only add variants in case the image is larger then the given minimum
int srcSetMaxWidth = getSrcSetMaxWidth();
for (double factor : m_sizeVariants) {
long width = Math.round(imageWidth * factor);
if (width > srcSetMaxWidth) {
if (width <= maxWidth) {
setSrcSets(createWidthVariation(String.valueOf(width)));
}
} else {
break;
}
}
}
}
|
java
|
public void addSrcSetWidthVariants(int minWidth, int maxWidth) {
int imageWidth = getWidth();
if (imageWidth > minWidth) {
// only add variants in case the image is larger then the given minimum
int srcSetMaxWidth = getSrcSetMaxWidth();
for (double factor : m_sizeVariants) {
long width = Math.round(imageWidth * factor);
if (width > srcSetMaxWidth) {
if (width <= maxWidth) {
setSrcSets(createWidthVariation(String.valueOf(width)));
}
} else {
break;
}
}
}
}
|
[
"public",
"void",
"addSrcSetWidthVariants",
"(",
"int",
"minWidth",
",",
"int",
"maxWidth",
")",
"{",
"int",
"imageWidth",
"=",
"getWidth",
"(",
")",
";",
"if",
"(",
"imageWidth",
">",
"minWidth",
")",
"{",
"// only add variants in case the image is larger then the given minimum",
"int",
"srcSetMaxWidth",
"=",
"getSrcSetMaxWidth",
"(",
")",
";",
"for",
"(",
"double",
"factor",
":",
"m_sizeVariants",
")",
"{",
"long",
"width",
"=",
"Math",
".",
"round",
"(",
"imageWidth",
"*",
"factor",
")",
";",
"if",
"(",
"width",
">",
"srcSetMaxWidth",
")",
"{",
"if",
"(",
"width",
"<=",
"maxWidth",
")",
"{",
"setSrcSets",
"(",
"createWidthVariation",
"(",
"String",
".",
"valueOf",
"(",
"width",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"}",
"}"
] |
Adds a number of size variations to the source set.<p>
In case the screen size is not really known, it may be a good idea to add
some variations for large images to make sure there are some common options in case the basic
image is very large.<p>
@param minWidth the minimum image width to add size variations for
@param maxWidth the maximum width size variation to create
|
[
"Adds",
"a",
"number",
"of",
"size",
"variations",
"to",
"the",
"source",
"set",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspImageBean.java#L380-L397
|
beihaifeiwu/dolphin
|
dolphin-common/src/main/java/com/freetmp/common/annotation/AnnotationUtils.java
|
AnnotationUtils.findAnnotationDeclaringClassForTypes
|
public static Class<?> findAnnotationDeclaringClassForTypes(List<Class<? extends Annotation>> annotationTypes, Class<?> clazz) {
"""
Find the first {@link Class} in the inheritance hierarchy of the specified
{@code clazz} (including the specified {@code clazz} itself) which declares
at least one of the specified {@code annotationTypes}, or {@code null} if
none of the specified annotation types could be found.
<p>If the supplied {@code clazz} is {@code null}, {@code null} will be
returned.
<p>If the supplied {@code clazz} is an interface, only the interface itself
will be checked; the inheritance hierarchy for interfaces will not be traversed.
<p>The standard {@link Class} API does not provide a mechanism for determining
which class in an inheritance hierarchy actually declares one of several
candidate {@linkplain Annotation annotations}, so we need to handle this
explicitly.
@param annotationTypes the list of Class objects corresponding to the
annotation types
@param clazz the Class object corresponding to the class on which to check
for the annotations, or {@code null}
@return the first {@link Class} in the inheritance hierarchy of the specified
{@code clazz} which declares an annotation of at least one of the specified
{@code annotationTypes}, or {@code null} if not found
@since 3.2.2
@see Class#isAnnotationPresent(Class)
@see Class#getDeclaredAnnotations()
@see #findAnnotationDeclaringClass(Class, Class)
@see #isAnnotationDeclaredLocally(Class, Class)
"""
Assert.notEmpty(annotationTypes, "The list of annotation types must not be empty");
if (clazz == null || clazz.equals(Object.class)) {
return null;
}
for (Class<? extends Annotation> annotationType : annotationTypes) {
if (isAnnotationDeclaredLocally(annotationType, clazz)) {
return clazz;
}
}
return findAnnotationDeclaringClassForTypes(annotationTypes, clazz.getSuperclass());
}
|
java
|
public static Class<?> findAnnotationDeclaringClassForTypes(List<Class<? extends Annotation>> annotationTypes, Class<?> clazz) {
Assert.notEmpty(annotationTypes, "The list of annotation types must not be empty");
if (clazz == null || clazz.equals(Object.class)) {
return null;
}
for (Class<? extends Annotation> annotationType : annotationTypes) {
if (isAnnotationDeclaredLocally(annotationType, clazz)) {
return clazz;
}
}
return findAnnotationDeclaringClassForTypes(annotationTypes, clazz.getSuperclass());
}
|
[
"public",
"static",
"Class",
"<",
"?",
">",
"findAnnotationDeclaringClassForTypes",
"(",
"List",
"<",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
">",
"annotationTypes",
",",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"Assert",
".",
"notEmpty",
"(",
"annotationTypes",
",",
"\"The list of annotation types must not be empty\"",
")",
";",
"if",
"(",
"clazz",
"==",
"null",
"||",
"clazz",
".",
"equals",
"(",
"Object",
".",
"class",
")",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationType",
":",
"annotationTypes",
")",
"{",
"if",
"(",
"isAnnotationDeclaredLocally",
"(",
"annotationType",
",",
"clazz",
")",
")",
"{",
"return",
"clazz",
";",
"}",
"}",
"return",
"findAnnotationDeclaringClassForTypes",
"(",
"annotationTypes",
",",
"clazz",
".",
"getSuperclass",
"(",
")",
")",
";",
"}"
] |
Find the first {@link Class} in the inheritance hierarchy of the specified
{@code clazz} (including the specified {@code clazz} itself) which declares
at least one of the specified {@code annotationTypes}, or {@code null} if
none of the specified annotation types could be found.
<p>If the supplied {@code clazz} is {@code null}, {@code null} will be
returned.
<p>If the supplied {@code clazz} is an interface, only the interface itself
will be checked; the inheritance hierarchy for interfaces will not be traversed.
<p>The standard {@link Class} API does not provide a mechanism for determining
which class in an inheritance hierarchy actually declares one of several
candidate {@linkplain Annotation annotations}, so we need to handle this
explicitly.
@param annotationTypes the list of Class objects corresponding to the
annotation types
@param clazz the Class object corresponding to the class on which to check
for the annotations, or {@code null}
@return the first {@link Class} in the inheritance hierarchy of the specified
{@code clazz} which declares an annotation of at least one of the specified
{@code annotationTypes}, or {@code null} if not found
@since 3.2.2
@see Class#isAnnotationPresent(Class)
@see Class#getDeclaredAnnotations()
@see #findAnnotationDeclaringClass(Class, Class)
@see #isAnnotationDeclaredLocally(Class, Class)
|
[
"Find",
"the",
"first",
"{"
] |
train
|
https://github.com/beihaifeiwu/dolphin/blob/b100579cc6986dce5eba5593ebb5fbae7bad9d1a/dolphin-common/src/main/java/com/freetmp/common/annotation/AnnotationUtils.java#L443-L454
|
threerings/nenya
|
core/src/main/java/com/threerings/media/image/ColorPository.java
|
ColorPository.getColorRecord
|
public ColorRecord getColorRecord (String className, String colorName) {
"""
Looks up the requested color record by class and color names.
"""
ClassRecord record = getClassRecord(className);
if (record == null) {
log.warning("Requested unknown color class",
"className", className, "colorName", colorName, new Exception());
return null;
}
int colorId = 0;
try {
colorId = record.getColorId(colorName);
} catch (ParseException pe) {
log.info("Error getting color record by name", "error", pe);
return null;
}
return record.colors.get(colorId);
}
|
java
|
public ColorRecord getColorRecord (String className, String colorName)
{
ClassRecord record = getClassRecord(className);
if (record == null) {
log.warning("Requested unknown color class",
"className", className, "colorName", colorName, new Exception());
return null;
}
int colorId = 0;
try {
colorId = record.getColorId(colorName);
} catch (ParseException pe) {
log.info("Error getting color record by name", "error", pe);
return null;
}
return record.colors.get(colorId);
}
|
[
"public",
"ColorRecord",
"getColorRecord",
"(",
"String",
"className",
",",
"String",
"colorName",
")",
"{",
"ClassRecord",
"record",
"=",
"getClassRecord",
"(",
"className",
")",
";",
"if",
"(",
"record",
"==",
"null",
")",
"{",
"log",
".",
"warning",
"(",
"\"Requested unknown color class\"",
",",
"\"className\"",
",",
"className",
",",
"\"colorName\"",
",",
"colorName",
",",
"new",
"Exception",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"int",
"colorId",
"=",
"0",
";",
"try",
"{",
"colorId",
"=",
"record",
".",
"getColorId",
"(",
"colorName",
")",
";",
"}",
"catch",
"(",
"ParseException",
"pe",
")",
"{",
"log",
".",
"info",
"(",
"\"Error getting color record by name\"",
",",
"\"error\"",
",",
"pe",
")",
";",
"return",
"null",
";",
"}",
"return",
"record",
".",
"colors",
".",
"get",
"(",
"colorId",
")",
";",
"}"
] |
Looks up the requested color record by class and color names.
|
[
"Looks",
"up",
"the",
"requested",
"color",
"record",
"by",
"class",
"and",
"color",
"names",
"."
] |
train
|
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ColorPository.java#L453-L471
|
aws/aws-sdk-java
|
aws-java-sdk-iot/src/main/java/com/amazonaws/services/iot/model/RegisterThingResult.java
|
RegisterThingResult.withResourceArns
|
public RegisterThingResult withResourceArns(java.util.Map<String, String> resourceArns) {
"""
<p>
ARNs for the generated resources.
</p>
@param resourceArns
ARNs for the generated resources.
@return Returns a reference to this object so that method calls can be chained together.
"""
setResourceArns(resourceArns);
return this;
}
|
java
|
public RegisterThingResult withResourceArns(java.util.Map<String, String> resourceArns) {
setResourceArns(resourceArns);
return this;
}
|
[
"public",
"RegisterThingResult",
"withResourceArns",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"resourceArns",
")",
"{",
"setResourceArns",
"(",
"resourceArns",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
ARNs for the generated resources.
</p>
@param resourceArns
ARNs for the generated resources.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"ARNs",
"for",
"the",
"generated",
"resources",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-iot/src/main/java/com/amazonaws/services/iot/model/RegisterThingResult.java#L109-L112
|
spring-projects/spring-shell
|
spring-shell-core/src/main/java/org/springframework/shell/jline/ExtendedDefaultParser.java
|
ExtendedDefaultParser.isEscapeChar
|
public boolean isEscapeChar(final CharSequence buffer, final int pos) {
"""
Check if this character is a valid escape char (i.e. one that has not been escaped)
"""
if (pos < 0) {
return false;
}
for (int i = 0; (escapeChars != null) && (i < escapeChars.length); i++) {
if (buffer.charAt(pos) == escapeChars[i]) {
return !isEscaped(buffer, pos); // escape escape
}
}
return false;
}
|
java
|
public boolean isEscapeChar(final CharSequence buffer, final int pos) {
if (pos < 0) {
return false;
}
for (int i = 0; (escapeChars != null) && (i < escapeChars.length); i++) {
if (buffer.charAt(pos) == escapeChars[i]) {
return !isEscaped(buffer, pos); // escape escape
}
}
return false;
}
|
[
"public",
"boolean",
"isEscapeChar",
"(",
"final",
"CharSequence",
"buffer",
",",
"final",
"int",
"pos",
")",
"{",
"if",
"(",
"pos",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"(",
"escapeChars",
"!=",
"null",
")",
"&&",
"(",
"i",
"<",
"escapeChars",
".",
"length",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"buffer",
".",
"charAt",
"(",
"pos",
")",
"==",
"escapeChars",
"[",
"i",
"]",
")",
"{",
"return",
"!",
"isEscaped",
"(",
"buffer",
",",
"pos",
")",
";",
"// escape escape",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if this character is a valid escape char (i.e. one that has not been escaped)
|
[
"Check",
"if",
"this",
"character",
"is",
"a",
"valid",
"escape",
"char",
"(",
"i",
".",
"e",
".",
"one",
"that",
"has",
"not",
"been",
"escaped",
")"
] |
train
|
https://github.com/spring-projects/spring-shell/blob/23d99f45eb8f487e31a1f080c837061313bbfafa/spring-shell-core/src/main/java/org/springframework/shell/jline/ExtendedDefaultParser.java#L183-L195
|
classgraph/classgraph
|
src/main/java/nonapi/io/github/classgraph/json/JSONSerializer.java
|
JSONSerializer.serializeObject
|
public static String serializeObject(final Object obj, final int indentWidth,
final boolean onlySerializePublicFields) {
"""
Recursively serialize an Object (or array, list, map or set of objects) to JSON, skipping transient and final
fields.
@param obj
The root object of the object graph to serialize.
@param indentWidth
If indentWidth == 0, no prettyprinting indentation is performed, otherwise this specifies the
number of spaces to indent each level of JSON.
@param onlySerializePublicFields
If true, only serialize public fields.
@return The object graph in JSON form.
@throws IllegalArgumentException
If anything goes wrong during serialization.
"""
return serializeObject(obj, indentWidth, onlySerializePublicFields,
new ClassFieldCache(/* resolveTypes = */ false, /* onlySerializePublicFields = */ false));
}
|
java
|
public static String serializeObject(final Object obj, final int indentWidth,
final boolean onlySerializePublicFields) {
return serializeObject(obj, indentWidth, onlySerializePublicFields,
new ClassFieldCache(/* resolveTypes = */ false, /* onlySerializePublicFields = */ false));
}
|
[
"public",
"static",
"String",
"serializeObject",
"(",
"final",
"Object",
"obj",
",",
"final",
"int",
"indentWidth",
",",
"final",
"boolean",
"onlySerializePublicFields",
")",
"{",
"return",
"serializeObject",
"(",
"obj",
",",
"indentWidth",
",",
"onlySerializePublicFields",
",",
"new",
"ClassFieldCache",
"(",
"/* resolveTypes = */",
"false",
",",
"/* onlySerializePublicFields = */",
"false",
")",
")",
";",
"}"
] |
Recursively serialize an Object (or array, list, map or set of objects) to JSON, skipping transient and final
fields.
@param obj
The root object of the object graph to serialize.
@param indentWidth
If indentWidth == 0, no prettyprinting indentation is performed, otherwise this specifies the
number of spaces to indent each level of JSON.
@param onlySerializePublicFields
If true, only serialize public fields.
@return The object graph in JSON form.
@throws IllegalArgumentException
If anything goes wrong during serialization.
|
[
"Recursively",
"serialize",
"an",
"Object",
"(",
"or",
"array",
"list",
"map",
"or",
"set",
"of",
"objects",
")",
"to",
"JSON",
"skipping",
"transient",
"and",
"final",
"fields",
"."
] |
train
|
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONSerializer.java#L508-L512
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/formatting/PatternMatchingSupport.java
|
PatternMatchingSupport.valueMatchesRegularExpression
|
public static boolean valueMatchesRegularExpression(String val, String regexp) {
"""
Returns true only if the value matches the regular expression
only once and exactly.
@param val string value that may match the expression
@param regexp regular expression
@return true if val matches regular expression regexp
"""
Pattern p = cache.get(regexp);
if(p == null) {
p = Pattern.compile(regexp);
cache.put(regexp, p);
}
return valueMatchesRegularExpression(val, p);
}
|
java
|
public static boolean valueMatchesRegularExpression(String val, String regexp) {
Pattern p = cache.get(regexp);
if(p == null) {
p = Pattern.compile(regexp);
cache.put(regexp, p);
}
return valueMatchesRegularExpression(val, p);
}
|
[
"public",
"static",
"boolean",
"valueMatchesRegularExpression",
"(",
"String",
"val",
",",
"String",
"regexp",
")",
"{",
"Pattern",
"p",
"=",
"cache",
".",
"get",
"(",
"regexp",
")",
";",
"if",
"(",
"p",
"==",
"null",
")",
"{",
"p",
"=",
"Pattern",
".",
"compile",
"(",
"regexp",
")",
";",
"cache",
".",
"put",
"(",
"regexp",
",",
"p",
")",
";",
"}",
"return",
"valueMatchesRegularExpression",
"(",
"val",
",",
"p",
")",
";",
"}"
] |
Returns true only if the value matches the regular expression
only once and exactly.
@param val string value that may match the expression
@param regexp regular expression
@return true if val matches regular expression regexp
|
[
"Returns",
"true",
"only",
"if",
"the",
"value",
"matches",
"the",
"regular",
"expression",
"only",
"once",
"and",
"exactly",
"."
] |
train
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/formatting/PatternMatchingSupport.java#L46-L53
|
xsonorg/xson
|
src/main/java/org/xson/core/asm/MethodWriter.java
|
MethodWriter.readInt
|
static int readInt(final byte[] b, final int index) {
"""
Reads a signed int value in the given byte array.
@param b a byte array.
@param index the start index of the value to be read.
@return the read value.
"""
return ((b[index] & 0xFF) << 24) | ((b[index + 1] & 0xFF) << 16)
| ((b[index + 2] & 0xFF) << 8) | (b[index + 3] & 0xFF);
}
|
java
|
static int readInt(final byte[] b, final int index) {
return ((b[index] & 0xFF) << 24) | ((b[index + 1] & 0xFF) << 16)
| ((b[index + 2] & 0xFF) << 8) | (b[index + 3] & 0xFF);
}
|
[
"static",
"int",
"readInt",
"(",
"final",
"byte",
"[",
"]",
"b",
",",
"final",
"int",
"index",
")",
"{",
"return",
"(",
"(",
"b",
"[",
"index",
"]",
"&",
"0xFF",
")",
"<<",
"24",
")",
"|",
"(",
"(",
"b",
"[",
"index",
"+",
"1",
"]",
"&",
"0xFF",
")",
"<<",
"16",
")",
"|",
"(",
"(",
"b",
"[",
"index",
"+",
"2",
"]",
"&",
"0xFF",
")",
"<<",
"8",
")",
"|",
"(",
"b",
"[",
"index",
"+",
"3",
"]",
"&",
"0xFF",
")",
";",
"}"
] |
Reads a signed int value in the given byte array.
@param b a byte array.
@param index the start index of the value to be read.
@return the read value.
|
[
"Reads",
"a",
"signed",
"int",
"value",
"in",
"the",
"given",
"byte",
"array",
"."
] |
train
|
https://github.com/xsonorg/xson/blob/ce1e197ec4ef9be448ed6ca96513e886151f83a9/src/main/java/org/xson/core/asm/MethodWriter.java#L2518-L2521
|
ManfredTremmel/gwt-commons-lang3
|
src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
|
DurationFormatUtils.formatPeriodISO
|
public static String formatPeriodISO(final long startMillis, final long endMillis) {
"""
<p>Formats the time gap as a string.</p>
<p>The format used is the ISO 8601 period format.</p>
@param startMillis the start of the duration to format
@param endMillis the end of the duration to format
@return the formatted duration, not null
@throws java.lang.IllegalArgumentException if startMillis is greater than endMillis
"""
return formatPeriod(startMillis, endMillis, ISO_EXTENDED_FORMAT_PATTERN, false, TimeZone.getDefault());
}
|
java
|
public static String formatPeriodISO(final long startMillis, final long endMillis) {
return formatPeriod(startMillis, endMillis, ISO_EXTENDED_FORMAT_PATTERN, false, TimeZone.getDefault());
}
|
[
"public",
"static",
"String",
"formatPeriodISO",
"(",
"final",
"long",
"startMillis",
",",
"final",
"long",
"endMillis",
")",
"{",
"return",
"formatPeriod",
"(",
"startMillis",
",",
"endMillis",
",",
"ISO_EXTENDED_FORMAT_PATTERN",
",",
"false",
",",
"TimeZone",
".",
"getDefault",
"(",
")",
")",
";",
"}"
] |
<p>Formats the time gap as a string.</p>
<p>The format used is the ISO 8601 period format.</p>
@param startMillis the start of the duration to format
@param endMillis the end of the duration to format
@return the formatted duration, not null
@throws java.lang.IllegalArgumentException if startMillis is greater than endMillis
|
[
"<p",
">",
"Formats",
"the",
"time",
"gap",
"as",
"a",
"string",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java#L239-L241
|
raphw/byte-buddy
|
byte-buddy-dep/src/main/java/net/bytebuddy/utility/visitor/MetadataAwareClassVisitor.java
|
MetadataAwareClassVisitor.onVisitOuterClass
|
protected void onVisitOuterClass(String owner, String name, String descriptor) {
"""
An order-sensitive invocation of {@link ClassVisitor#visitOuterClass(String, String, String)}.
@param owner The outer class's internal name.
@param name The outer method's name or {@code null} if it does not exist.
@param descriptor The outer method's descriptor or {@code null} if it does not exist.
"""
super.visitOuterClass(owner, name, descriptor);
}
|
java
|
protected void onVisitOuterClass(String owner, String name, String descriptor) {
super.visitOuterClass(owner, name, descriptor);
}
|
[
"protected",
"void",
"onVisitOuterClass",
"(",
"String",
"owner",
",",
"String",
"name",
",",
"String",
"descriptor",
")",
"{",
"super",
".",
"visitOuterClass",
"(",
"owner",
",",
"name",
",",
"descriptor",
")",
";",
"}"
] |
An order-sensitive invocation of {@link ClassVisitor#visitOuterClass(String, String, String)}.
@param owner The outer class's internal name.
@param name The outer method's name or {@code null} if it does not exist.
@param descriptor The outer method's descriptor or {@code null} if it does not exist.
|
[
"An",
"order",
"-",
"sensitive",
"invocation",
"of",
"{",
"@link",
"ClassVisitor#visitOuterClass",
"(",
"String",
"String",
"String",
")",
"}",
"."
] |
train
|
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/utility/visitor/MetadataAwareClassVisitor.java#L127-L129
|
lessthanoptimal/BoofCV
|
main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/BaseAssociateLocation2DFilter.java
|
BaseAssociateLocation2DFilter.backwardsValidation
|
private boolean backwardsValidation(int indexSrc, int bestIndex) {
"""
Finds the best match for an index in destination and sees if it matches the source index
@param indexSrc The index in source being examined
@param bestIndex Index in dst with the best fit to source
@return true if a match was found and false if not
"""
double bestScoreV = maxError;
int bestIndexV = -1;
D d_forward = descDst.get(bestIndex);
setActiveSource(locationDst.get(bestIndex));
for( int j = 0; j < locationSrc.size(); j++ ) {
// compute distance between the two features
double distance = computeDistanceToSource(locationSrc.get(j));
if( distance > maxDistance )
continue;
D d_v = descSrc.get(j);
double score = scoreAssociation.score(d_forward,d_v);
if( score < bestScoreV ) {
bestScoreV = score;
bestIndexV = j;
}
}
return bestIndexV == indexSrc;
}
|
java
|
private boolean backwardsValidation(int indexSrc, int bestIndex) {
double bestScoreV = maxError;
int bestIndexV = -1;
D d_forward = descDst.get(bestIndex);
setActiveSource(locationDst.get(bestIndex));
for( int j = 0; j < locationSrc.size(); j++ ) {
// compute distance between the two features
double distance = computeDistanceToSource(locationSrc.get(j));
if( distance > maxDistance )
continue;
D d_v = descSrc.get(j);
double score = scoreAssociation.score(d_forward,d_v);
if( score < bestScoreV ) {
bestScoreV = score;
bestIndexV = j;
}
}
return bestIndexV == indexSrc;
}
|
[
"private",
"boolean",
"backwardsValidation",
"(",
"int",
"indexSrc",
",",
"int",
"bestIndex",
")",
"{",
"double",
"bestScoreV",
"=",
"maxError",
";",
"int",
"bestIndexV",
"=",
"-",
"1",
";",
"D",
"d_forward",
"=",
"descDst",
".",
"get",
"(",
"bestIndex",
")",
";",
"setActiveSource",
"(",
"locationDst",
".",
"get",
"(",
"bestIndex",
")",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"locationSrc",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"// compute distance between the two features",
"double",
"distance",
"=",
"computeDistanceToSource",
"(",
"locationSrc",
".",
"get",
"(",
"j",
")",
")",
";",
"if",
"(",
"distance",
">",
"maxDistance",
")",
"continue",
";",
"D",
"d_v",
"=",
"descSrc",
".",
"get",
"(",
"j",
")",
";",
"double",
"score",
"=",
"scoreAssociation",
".",
"score",
"(",
"d_forward",
",",
"d_v",
")",
";",
"if",
"(",
"score",
"<",
"bestScoreV",
")",
"{",
"bestScoreV",
"=",
"score",
";",
"bestIndexV",
"=",
"j",
";",
"}",
"}",
"return",
"bestIndexV",
"==",
"indexSrc",
";",
"}"
] |
Finds the best match for an index in destination and sees if it matches the source index
@param indexSrc The index in source being examined
@param bestIndex Index in dst with the best fit to source
@return true if a match was found and false if not
|
[
"Finds",
"the",
"best",
"match",
"for",
"an",
"index",
"in",
"destination",
"and",
"sees",
"if",
"it",
"matches",
"the",
"source",
"index"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/BaseAssociateLocation2DFilter.java#L167-L191
|
the-fascinator/plugin-authentication-internal
|
src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java
|
InternalAuthentication.createUser
|
@Override
public User createUser(String username, String password)
throws AuthenticationException {
"""
Create a user.
@param username The username of the new user.
@param password The password of the new user.
@return A user object for the newly created in user.
@throws AuthenticationException if there was an error creating the user.
"""
String user = file_store.getProperty(username);
if (user != null) {
throw new AuthenticationException("User '" + username
+ "' already exists.");
}
// Encrypt the new password
String ePwd = encryptPassword(password);
file_store.put(username, ePwd);
try {
saveUsers();
} catch (IOException e) {
throw new AuthenticationException("Error changing password: ", e);
}
return getUser(username);
}
|
java
|
@Override
public User createUser(String username, String password)
throws AuthenticationException {
String user = file_store.getProperty(username);
if (user != null) {
throw new AuthenticationException("User '" + username
+ "' already exists.");
}
// Encrypt the new password
String ePwd = encryptPassword(password);
file_store.put(username, ePwd);
try {
saveUsers();
} catch (IOException e) {
throw new AuthenticationException("Error changing password: ", e);
}
return getUser(username);
}
|
[
"@",
"Override",
"public",
"User",
"createUser",
"(",
"String",
"username",
",",
"String",
"password",
")",
"throws",
"AuthenticationException",
"{",
"String",
"user",
"=",
"file_store",
".",
"getProperty",
"(",
"username",
")",
";",
"if",
"(",
"user",
"!=",
"null",
")",
"{",
"throw",
"new",
"AuthenticationException",
"(",
"\"User '\"",
"+",
"username",
"+",
"\"' already exists.\"",
")",
";",
"}",
"// Encrypt the new password",
"String",
"ePwd",
"=",
"encryptPassword",
"(",
"password",
")",
";",
"file_store",
".",
"put",
"(",
"username",
",",
"ePwd",
")",
";",
"try",
"{",
"saveUsers",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"AuthenticationException",
"(",
"\"Error changing password: \"",
",",
"e",
")",
";",
"}",
"return",
"getUser",
"(",
"username",
")",
";",
"}"
] |
Create a user.
@param username The username of the new user.
@param password The password of the new user.
@return A user object for the newly created in user.
@throws AuthenticationException if there was an error creating the user.
|
[
"Create",
"a",
"user",
"."
] |
train
|
https://github.com/the-fascinator/plugin-authentication-internal/blob/a2b9a0eda9b43bf20583036a406c83c938be3042/src/main/java/com/googlecode/fascinator/authentication/internal/InternalAuthentication.java#L319-L337
|
haifengl/smile
|
core/src/main/java/smile/clustering/BBDTree.java
|
BBDTree.prune
|
private boolean prune(double[] center, double[] radius, double[][] centroids, int bestIndex, int testIndex) {
"""
Determines whether every point in the box is closer to centroids[bestIndex] than to
centroids[testIndex].
If x is a point, c_0 = centroids[bestIndex], c = centroids[testIndex], then:
(x-c).(x-c) < (x-c_0).(x-c_0)
<=> (c-c_0).(c-c_0) < 2(x-c_0).(c-c_0)
The right-hand side is maximized for a vertex of the box where for each
dimension, we choose the low or high value based on the sign of x-c_0 in
that dimension.
"""
if (bestIndex == testIndex) {
return false;
}
int d = centroids[0].length;
double[] best = centroids[bestIndex];
double[] test = centroids[testIndex];
double lhs = 0.0, rhs = 0.0;
for (int i = 0; i < d; i++) {
double diff = test[i] - best[i];
lhs += diff * diff;
if (diff > 0) {
rhs += (center[i] + radius[i] - best[i]) * diff;
} else {
rhs += (center[i] - radius[i] - best[i]) * diff;
}
}
return (lhs >= 2 * rhs);
}
|
java
|
private boolean prune(double[] center, double[] radius, double[][] centroids, int bestIndex, int testIndex) {
if (bestIndex == testIndex) {
return false;
}
int d = centroids[0].length;
double[] best = centroids[bestIndex];
double[] test = centroids[testIndex];
double lhs = 0.0, rhs = 0.0;
for (int i = 0; i < d; i++) {
double diff = test[i] - best[i];
lhs += diff * diff;
if (diff > 0) {
rhs += (center[i] + radius[i] - best[i]) * diff;
} else {
rhs += (center[i] - radius[i] - best[i]) * diff;
}
}
return (lhs >= 2 * rhs);
}
|
[
"private",
"boolean",
"prune",
"(",
"double",
"[",
"]",
"center",
",",
"double",
"[",
"]",
"radius",
",",
"double",
"[",
"]",
"[",
"]",
"centroids",
",",
"int",
"bestIndex",
",",
"int",
"testIndex",
")",
"{",
"if",
"(",
"bestIndex",
"==",
"testIndex",
")",
"{",
"return",
"false",
";",
"}",
"int",
"d",
"=",
"centroids",
"[",
"0",
"]",
".",
"length",
";",
"double",
"[",
"]",
"best",
"=",
"centroids",
"[",
"bestIndex",
"]",
";",
"double",
"[",
"]",
"test",
"=",
"centroids",
"[",
"testIndex",
"]",
";",
"double",
"lhs",
"=",
"0.0",
",",
"rhs",
"=",
"0.0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"d",
";",
"i",
"++",
")",
"{",
"double",
"diff",
"=",
"test",
"[",
"i",
"]",
"-",
"best",
"[",
"i",
"]",
";",
"lhs",
"+=",
"diff",
"*",
"diff",
";",
"if",
"(",
"diff",
">",
"0",
")",
"{",
"rhs",
"+=",
"(",
"center",
"[",
"i",
"]",
"+",
"radius",
"[",
"i",
"]",
"-",
"best",
"[",
"i",
"]",
")",
"*",
"diff",
";",
"}",
"else",
"{",
"rhs",
"+=",
"(",
"center",
"[",
"i",
"]",
"-",
"radius",
"[",
"i",
"]",
"-",
"best",
"[",
"i",
"]",
")",
"*",
"diff",
";",
"}",
"}",
"return",
"(",
"lhs",
">=",
"2",
"*",
"rhs",
")",
";",
"}"
] |
Determines whether every point in the box is closer to centroids[bestIndex] than to
centroids[testIndex].
If x is a point, c_0 = centroids[bestIndex], c = centroids[testIndex], then:
(x-c).(x-c) < (x-c_0).(x-c_0)
<=> (c-c_0).(c-c_0) < 2(x-c_0).(c-c_0)
The right-hand side is maximized for a vertex of the box where for each
dimension, we choose the low or high value based on the sign of x-c_0 in
that dimension.
|
[
"Determines",
"whether",
"every",
"point",
"in",
"the",
"box",
"is",
"closer",
"to",
"centroids",
"[",
"bestIndex",
"]",
"than",
"to",
"centroids",
"[",
"testIndex",
"]",
"."
] |
train
|
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/clustering/BBDTree.java#L341-L362
|
Impetus/Kundera
|
src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/PersistenceValidator.java
|
PersistenceValidator.isValidEntityObject
|
public boolean isValidEntityObject(Object entity, EntityMetadata metadata) {
"""
Validates an entity object for CRUD operations
@param entity
Instance of entity object
@return True if entity object is valid, false otherwise
"""
if (entity == null)
{
log.error("Entity to be persisted must not be null, operation failed");
return false;
}
Object id = PropertyAccessorHelper.getId(entity, metadata);
if (id == null)
{
log.error("Entity to be persisted can't have Primary key set to null.");
throw new IllegalArgumentException("Entity to be persisted can't have Primary key set to null.");
// return false;
}
return true;
}
|
java
|
public boolean isValidEntityObject(Object entity, EntityMetadata metadata)
{
if (entity == null)
{
log.error("Entity to be persisted must not be null, operation failed");
return false;
}
Object id = PropertyAccessorHelper.getId(entity, metadata);
if (id == null)
{
log.error("Entity to be persisted can't have Primary key set to null.");
throw new IllegalArgumentException("Entity to be persisted can't have Primary key set to null.");
// return false;
}
return true;
}
|
[
"public",
"boolean",
"isValidEntityObject",
"(",
"Object",
"entity",
",",
"EntityMetadata",
"metadata",
")",
"{",
"if",
"(",
"entity",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Entity to be persisted must not be null, operation failed\"",
")",
";",
"return",
"false",
";",
"}",
"Object",
"id",
"=",
"PropertyAccessorHelper",
".",
"getId",
"(",
"entity",
",",
"metadata",
")",
";",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Entity to be persisted can't have Primary key set to null.\"",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Entity to be persisted can't have Primary key set to null.\"",
")",
";",
"// return false;",
"}",
"return",
"true",
";",
"}"
] |
Validates an entity object for CRUD operations
@param entity
Instance of entity object
@return True if entity object is valid, false otherwise
|
[
"Validates",
"an",
"entity",
"object",
"for",
"CRUD",
"operations"
] |
train
|
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/persistence/PersistenceValidator.java#L69-L85
|
nulab/backlog4j
|
src/main/java/com/nulabinc/backlog4j/api/option/CreateIssueParams.java
|
CreateIssueParams.milestoneIds
|
public CreateIssueParams milestoneIds(List milestoneIds) {
"""
Sets the issue milestones.
@param milestoneIds the milestone identifiers
@return CreateIssueParams instance
"""
for (Object milestoneId : milestoneIds) {
parameters.add(new NameValuePair("milestoneId[]", milestoneId.toString()));
}
return this;
}
|
java
|
public CreateIssueParams milestoneIds(List milestoneIds) {
for (Object milestoneId : milestoneIds) {
parameters.add(new NameValuePair("milestoneId[]", milestoneId.toString()));
}
return this;
}
|
[
"public",
"CreateIssueParams",
"milestoneIds",
"(",
"List",
"milestoneIds",
")",
"{",
"for",
"(",
"Object",
"milestoneId",
":",
"milestoneIds",
")",
"{",
"parameters",
".",
"add",
"(",
"new",
"NameValuePair",
"(",
"\"milestoneId[]\"",
",",
"milestoneId",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Sets the issue milestones.
@param milestoneIds the milestone identifiers
@return CreateIssueParams instance
|
[
"Sets",
"the",
"issue",
"milestones",
"."
] |
train
|
https://github.com/nulab/backlog4j/blob/862ae0586ad808b2ec413f665b8dfc0c9a107b4e/src/main/java/com/nulabinc/backlog4j/api/option/CreateIssueParams.java#L162-L167
|
liferay/com-liferay-commerce
|
commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountPersistenceImpl.java
|
CommerceDiscountPersistenceImpl.removeByUUID_G
|
@Override
public CommerceDiscount removeByUUID_G(String uuid, long groupId)
throws NoSuchDiscountException {
"""
Removes the commerce discount where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the commerce discount that was removed
"""
CommerceDiscount commerceDiscount = findByUUID_G(uuid, groupId);
return remove(commerceDiscount);
}
|
java
|
@Override
public CommerceDiscount removeByUUID_G(String uuid, long groupId)
throws NoSuchDiscountException {
CommerceDiscount commerceDiscount = findByUUID_G(uuid, groupId);
return remove(commerceDiscount);
}
|
[
"@",
"Override",
"public",
"CommerceDiscount",
"removeByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"NoSuchDiscountException",
"{",
"CommerceDiscount",
"commerceDiscount",
"=",
"findByUUID_G",
"(",
"uuid",
",",
"groupId",
")",
";",
"return",
"remove",
"(",
"commerceDiscount",
")",
";",
"}"
] |
Removes the commerce discount where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the commerce discount that was removed
|
[
"Removes",
"the",
"commerce",
"discount",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountPersistenceImpl.java#L816-L822
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java
|
UnicodeSet._appendToPat
|
private static <T extends Appendable> T _appendToPat(T buf, int c, boolean escapeUnprintable) {
"""
Append the <code>toPattern()</code> representation of a
character to the given <code>Appendable</code>.
"""
try {
if (escapeUnprintable && Utility.isUnprintable(c)) {
// Use hex escape notation (<backslash>uxxxx or <backslash>Uxxxxxxxx) for anything
// unprintable
if (Utility.escapeUnprintable(buf, c)) {
return buf;
}
}
// Okay to let ':' pass through
switch (c) {
case '[': // SET_OPEN:
case ']': // SET_CLOSE:
case '-': // HYPHEN:
case '^': // COMPLEMENT:
case '&': // INTERSECTION:
case '\\': //BACKSLASH:
case '{':
case '}':
case '$':
case ':':
buf.append('\\');
break;
default:
// Escape whitespace
if (PatternProps.isWhiteSpace(c)) {
buf.append('\\');
}
break;
}
appendCodePoint(buf, c);
return buf;
} catch (IOException e) {
throw new ICUUncheckedIOException(e);
}
}
|
java
|
private static <T extends Appendable> T _appendToPat(T buf, int c, boolean escapeUnprintable) {
try {
if (escapeUnprintable && Utility.isUnprintable(c)) {
// Use hex escape notation (<backslash>uxxxx or <backslash>Uxxxxxxxx) for anything
// unprintable
if (Utility.escapeUnprintable(buf, c)) {
return buf;
}
}
// Okay to let ':' pass through
switch (c) {
case '[': // SET_OPEN:
case ']': // SET_CLOSE:
case '-': // HYPHEN:
case '^': // COMPLEMENT:
case '&': // INTERSECTION:
case '\\': //BACKSLASH:
case '{':
case '}':
case '$':
case ':':
buf.append('\\');
break;
default:
// Escape whitespace
if (PatternProps.isWhiteSpace(c)) {
buf.append('\\');
}
break;
}
appendCodePoint(buf, c);
return buf;
} catch (IOException e) {
throw new ICUUncheckedIOException(e);
}
}
|
[
"private",
"static",
"<",
"T",
"extends",
"Appendable",
">",
"T",
"_appendToPat",
"(",
"T",
"buf",
",",
"int",
"c",
",",
"boolean",
"escapeUnprintable",
")",
"{",
"try",
"{",
"if",
"(",
"escapeUnprintable",
"&&",
"Utility",
".",
"isUnprintable",
"(",
"c",
")",
")",
"{",
"// Use hex escape notation (<backslash>uxxxx or <backslash>Uxxxxxxxx) for anything",
"// unprintable",
"if",
"(",
"Utility",
".",
"escapeUnprintable",
"(",
"buf",
",",
"c",
")",
")",
"{",
"return",
"buf",
";",
"}",
"}",
"// Okay to let ':' pass through",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"// SET_OPEN:",
"case",
"'",
"'",
":",
"// SET_CLOSE:",
"case",
"'",
"'",
":",
"// HYPHEN:",
"case",
"'",
"'",
":",
"// COMPLEMENT:",
"case",
"'",
"'",
":",
"// INTERSECTION:",
"case",
"'",
"'",
":",
"//BACKSLASH:",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"break",
";",
"default",
":",
"// Escape whitespace",
"if",
"(",
"PatternProps",
".",
"isWhiteSpace",
"(",
"c",
")",
")",
"{",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"break",
";",
"}",
"appendCodePoint",
"(",
"buf",
",",
"c",
")",
";",
"return",
"buf",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ICUUncheckedIOException",
"(",
"e",
")",
";",
"}",
"}"
] |
Append the <code>toPattern()</code> representation of a
character to the given <code>Appendable</code>.
|
[
"Append",
"the",
"<code",
">",
"toPattern",
"()",
"<",
"/",
"code",
">",
"representation",
"of",
"a",
"character",
"to",
"the",
"given",
"<code",
">",
"Appendable<",
"/",
"code",
">",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UnicodeSet.java#L636-L671
|
seedstack/w20-bridge-addon
|
rest/src/main/java/org/seedstack/w20/internal/MasterPageBuilder.java
|
MasterPageBuilder.replaceTokens
|
private String replaceTokens(String text, Map<String, Object> replacements) {
"""
Replace ${...} placeholders in a string looking up in a replacement map.
@param text the text to replace.
@param replacements the map of replacements.
@return the replaced text.
"""
Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}");
Matcher matcher = pattern.matcher(text);
StringBuffer buffer = new StringBuffer();
while (matcher.find()) {
Object replacement = replacements.get(matcher.group(1));
matcher.appendReplacement(buffer, "");
if (replacement != null) {
buffer.append(replacement.toString());
}
}
matcher.appendTail(buffer);
return buffer.toString();
}
|
java
|
private String replaceTokens(String text, Map<String, Object> replacements) {
Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}");
Matcher matcher = pattern.matcher(text);
StringBuffer buffer = new StringBuffer();
while (matcher.find()) {
Object replacement = replacements.get(matcher.group(1));
matcher.appendReplacement(buffer, "");
if (replacement != null) {
buffer.append(replacement.toString());
}
}
matcher.appendTail(buffer);
return buffer.toString();
}
|
[
"private",
"String",
"replaceTokens",
"(",
"String",
"text",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"replacements",
")",
"{",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"\\\\$\\\\{(.+?)\\\\}\"",
")",
";",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"text",
")",
";",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"while",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"Object",
"replacement",
"=",
"replacements",
".",
"get",
"(",
"matcher",
".",
"group",
"(",
"1",
")",
")",
";",
"matcher",
".",
"appendReplacement",
"(",
"buffer",
",",
"\"\"",
")",
";",
"if",
"(",
"replacement",
"!=",
"null",
")",
"{",
"buffer",
".",
"append",
"(",
"replacement",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"matcher",
".",
"appendTail",
"(",
"buffer",
")",
";",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] |
Replace ${...} placeholders in a string looking up in a replacement map.
@param text the text to replace.
@param replacements the map of replacements.
@return the replaced text.
|
[
"Replace",
"$",
"{",
"...",
"}",
"placeholders",
"in",
"a",
"string",
"looking",
"up",
"in",
"a",
"replacement",
"map",
"."
] |
train
|
https://github.com/seedstack/w20-bridge-addon/blob/94c997a9392f10a1bf1655e7f25bf2f6f328ce20/rest/src/main/java/org/seedstack/w20/internal/MasterPageBuilder.java#L103-L117
|
lmdbjava/lmdbjava
|
src/main/java/org/lmdbjava/DirectBufferProxy.java
|
DirectBufferProxy.compareBuff
|
@SuppressWarnings("checkstyle:ReturnCount")
public static int compareBuff(final DirectBuffer o1, final DirectBuffer o2) {
"""
Lexicographically compare two buffers.
@param o1 left operand (required)
@param o2 right operand (required)
@return as specified by {@link Comparable} interface
"""
requireNonNull(o1);
requireNonNull(o2);
if (o1.equals(o2)) {
return 0;
}
final int minLength = Math.min(o1.capacity(), o2.capacity());
final int minWords = minLength / Long.BYTES;
for (int i = 0; i < minWords * Long.BYTES; i += Long.BYTES) {
final long lw = o1.getLong(i, BIG_ENDIAN);
final long rw = o2.getLong(i, BIG_ENDIAN);
final int diff = Long.compareUnsigned(lw, rw);
if (diff != 0) {
return diff;
}
}
for (int i = minWords * Long.BYTES; i < minLength; i++) {
final int lw = Byte.toUnsignedInt(o1.getByte(i));
final int rw = Byte.toUnsignedInt(o2.getByte(i));
final int result = Integer.compareUnsigned(lw, rw);
if (result != 0) {
return result;
}
}
return o1.capacity() - o2.capacity();
}
|
java
|
@SuppressWarnings("checkstyle:ReturnCount")
public static int compareBuff(final DirectBuffer o1, final DirectBuffer o2) {
requireNonNull(o1);
requireNonNull(o2);
if (o1.equals(o2)) {
return 0;
}
final int minLength = Math.min(o1.capacity(), o2.capacity());
final int minWords = minLength / Long.BYTES;
for (int i = 0; i < minWords * Long.BYTES; i += Long.BYTES) {
final long lw = o1.getLong(i, BIG_ENDIAN);
final long rw = o2.getLong(i, BIG_ENDIAN);
final int diff = Long.compareUnsigned(lw, rw);
if (diff != 0) {
return diff;
}
}
for (int i = minWords * Long.BYTES; i < minLength; i++) {
final int lw = Byte.toUnsignedInt(o1.getByte(i));
final int rw = Byte.toUnsignedInt(o2.getByte(i));
final int result = Integer.compareUnsigned(lw, rw);
if (result != 0) {
return result;
}
}
return o1.capacity() - o2.capacity();
}
|
[
"@",
"SuppressWarnings",
"(",
"\"checkstyle:ReturnCount\"",
")",
"public",
"static",
"int",
"compareBuff",
"(",
"final",
"DirectBuffer",
"o1",
",",
"final",
"DirectBuffer",
"o2",
")",
"{",
"requireNonNull",
"(",
"o1",
")",
";",
"requireNonNull",
"(",
"o2",
")",
";",
"if",
"(",
"o1",
".",
"equals",
"(",
"o2",
")",
")",
"{",
"return",
"0",
";",
"}",
"final",
"int",
"minLength",
"=",
"Math",
".",
"min",
"(",
"o1",
".",
"capacity",
"(",
")",
",",
"o2",
".",
"capacity",
"(",
")",
")",
";",
"final",
"int",
"minWords",
"=",
"minLength",
"/",
"Long",
".",
"BYTES",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"minWords",
"*",
"Long",
".",
"BYTES",
";",
"i",
"+=",
"Long",
".",
"BYTES",
")",
"{",
"final",
"long",
"lw",
"=",
"o1",
".",
"getLong",
"(",
"i",
",",
"BIG_ENDIAN",
")",
";",
"final",
"long",
"rw",
"=",
"o2",
".",
"getLong",
"(",
"i",
",",
"BIG_ENDIAN",
")",
";",
"final",
"int",
"diff",
"=",
"Long",
".",
"compareUnsigned",
"(",
"lw",
",",
"rw",
")",
";",
"if",
"(",
"diff",
"!=",
"0",
")",
"{",
"return",
"diff",
";",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"minWords",
"*",
"Long",
".",
"BYTES",
";",
"i",
"<",
"minLength",
";",
"i",
"++",
")",
"{",
"final",
"int",
"lw",
"=",
"Byte",
".",
"toUnsignedInt",
"(",
"o1",
".",
"getByte",
"(",
"i",
")",
")",
";",
"final",
"int",
"rw",
"=",
"Byte",
".",
"toUnsignedInt",
"(",
"o2",
".",
"getByte",
"(",
"i",
")",
")",
";",
"final",
"int",
"result",
"=",
"Integer",
".",
"compareUnsigned",
"(",
"lw",
",",
"rw",
")",
";",
"if",
"(",
"result",
"!=",
"0",
")",
"{",
"return",
"result",
";",
"}",
"}",
"return",
"o1",
".",
"capacity",
"(",
")",
"-",
"o2",
".",
"capacity",
"(",
")",
";",
"}"
] |
Lexicographically compare two buffers.
@param o1 left operand (required)
@param o2 right operand (required)
@return as specified by {@link Comparable} interface
|
[
"Lexicographically",
"compare",
"two",
"buffers",
"."
] |
train
|
https://github.com/lmdbjava/lmdbjava/blob/5912beb1037722c71f3ddc05e70fcbe739dfa272/src/main/java/org/lmdbjava/DirectBufferProxy.java#L66-L95
|
beihaifeiwu/dolphin
|
dolphin-common/src/main/java/com/freetmp/common/type/ResolvableType.java
|
ResolvableType.forType
|
static ResolvableType forType(Type type, TypeProvider typeProvider, VariableResolver variableResolver) {
"""
Return a {@link ResolvableType} for the specified {@link Type} backed by a given
{@link VariableResolver}.
@param type the source type or {@code null}
@param typeProvider the type provider or {@code null}
@param variableResolver the variable resolver or {@code null}
@return a {@link ResolvableType} for the specified {@link Type} and {@link VariableResolver}
"""
if (type == null && typeProvider != null) {
type = SerializableTypeWrapper.forTypeProvider(typeProvider);
}
if (type == null) {
return NONE;
}
// Purge empty entries on access since we don't have a clean-up thread or the like.
cache.purgeUnreferencedEntries();
// For simple Class references, build the wrapper right away -
// no expensive resolution necessary, so not worth caching...
if (type instanceof Class) {
return new ResolvableType(type, typeProvider, variableResolver, null);
}
// Check the cache - we may have a ResolvableType which has been resolved before...
ResolvableType key = new ResolvableType(type, typeProvider, variableResolver);
ResolvableType resolvableType = cache.get(key);
if (resolvableType == null) {
resolvableType = new ResolvableType(type, typeProvider, variableResolver, null);
cache.put(resolvableType, resolvableType);
}
return resolvableType;
}
|
java
|
static ResolvableType forType(Type type, TypeProvider typeProvider, VariableResolver variableResolver) {
if (type == null && typeProvider != null) {
type = SerializableTypeWrapper.forTypeProvider(typeProvider);
}
if (type == null) {
return NONE;
}
// Purge empty entries on access since we don't have a clean-up thread or the like.
cache.purgeUnreferencedEntries();
// For simple Class references, build the wrapper right away -
// no expensive resolution necessary, so not worth caching...
if (type instanceof Class) {
return new ResolvableType(type, typeProvider, variableResolver, null);
}
// Check the cache - we may have a ResolvableType which has been resolved before...
ResolvableType key = new ResolvableType(type, typeProvider, variableResolver);
ResolvableType resolvableType = cache.get(key);
if (resolvableType == null) {
resolvableType = new ResolvableType(type, typeProvider, variableResolver, null);
cache.put(resolvableType, resolvableType);
}
return resolvableType;
}
|
[
"static",
"ResolvableType",
"forType",
"(",
"Type",
"type",
",",
"TypeProvider",
"typeProvider",
",",
"VariableResolver",
"variableResolver",
")",
"{",
"if",
"(",
"type",
"==",
"null",
"&&",
"typeProvider",
"!=",
"null",
")",
"{",
"type",
"=",
"SerializableTypeWrapper",
".",
"forTypeProvider",
"(",
"typeProvider",
")",
";",
"}",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"return",
"NONE",
";",
"}",
"// Purge empty entries on access since we don't have a clean-up thread or the like.",
"cache",
".",
"purgeUnreferencedEntries",
"(",
")",
";",
"// For simple Class references, build the wrapper right away -",
"// no expensive resolution necessary, so not worth caching...",
"if",
"(",
"type",
"instanceof",
"Class",
")",
"{",
"return",
"new",
"ResolvableType",
"(",
"type",
",",
"typeProvider",
",",
"variableResolver",
",",
"null",
")",
";",
"}",
"// Check the cache - we may have a ResolvableType which has been resolved before...",
"ResolvableType",
"key",
"=",
"new",
"ResolvableType",
"(",
"type",
",",
"typeProvider",
",",
"variableResolver",
")",
";",
"ResolvableType",
"resolvableType",
"=",
"cache",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"resolvableType",
"==",
"null",
")",
"{",
"resolvableType",
"=",
"new",
"ResolvableType",
"(",
"type",
",",
"typeProvider",
",",
"variableResolver",
",",
"null",
")",
";",
"cache",
".",
"put",
"(",
"resolvableType",
",",
"resolvableType",
")",
";",
"}",
"return",
"resolvableType",
";",
"}"
] |
Return a {@link ResolvableType} for the specified {@link Type} backed by a given
{@link VariableResolver}.
@param type the source type or {@code null}
@param typeProvider the type provider or {@code null}
@param variableResolver the variable resolver or {@code null}
@return a {@link ResolvableType} for the specified {@link Type} and {@link VariableResolver}
|
[
"Return",
"a",
"{"
] |
train
|
https://github.com/beihaifeiwu/dolphin/blob/b100579cc6986dce5eba5593ebb5fbae7bad9d1a/dolphin-common/src/main/java/com/freetmp/common/type/ResolvableType.java#L1189-L1214
|
facebookarchive/hadoop-20
|
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
|
FSEditLog.logOpenFile
|
public void logOpenFile(String path, INodeFileUnderConstruction newNode)
throws IOException {
"""
Add open lease record to edit log.
Records the block locations of the last block.
"""
AddOp op = AddOp.getInstance();
op.set(newNode.getId(),
path,
newNode.getReplication(),
newNode.getModificationTime(),
newNode.getAccessTime(),
newNode.getPreferredBlockSize(),
newNode.getBlocks(),
newNode.getPermissionStatus(),
newNode.getClientName(),
newNode.getClientMachine());
logEdit(op);
}
|
java
|
public void logOpenFile(String path, INodeFileUnderConstruction newNode)
throws IOException {
AddOp op = AddOp.getInstance();
op.set(newNode.getId(),
path,
newNode.getReplication(),
newNode.getModificationTime(),
newNode.getAccessTime(),
newNode.getPreferredBlockSize(),
newNode.getBlocks(),
newNode.getPermissionStatus(),
newNode.getClientName(),
newNode.getClientMachine());
logEdit(op);
}
|
[
"public",
"void",
"logOpenFile",
"(",
"String",
"path",
",",
"INodeFileUnderConstruction",
"newNode",
")",
"throws",
"IOException",
"{",
"AddOp",
"op",
"=",
"AddOp",
".",
"getInstance",
"(",
")",
";",
"op",
".",
"set",
"(",
"newNode",
".",
"getId",
"(",
")",
",",
"path",
",",
"newNode",
".",
"getReplication",
"(",
")",
",",
"newNode",
".",
"getModificationTime",
"(",
")",
",",
"newNode",
".",
"getAccessTime",
"(",
")",
",",
"newNode",
".",
"getPreferredBlockSize",
"(",
")",
",",
"newNode",
".",
"getBlocks",
"(",
")",
",",
"newNode",
".",
"getPermissionStatus",
"(",
")",
",",
"newNode",
".",
"getClientName",
"(",
")",
",",
"newNode",
".",
"getClientMachine",
"(",
")",
")",
";",
"logEdit",
"(",
"op",
")",
";",
"}"
] |
Add open lease record to edit log.
Records the block locations of the last block.
|
[
"Add",
"open",
"lease",
"record",
"to",
"edit",
"log",
".",
"Records",
"the",
"block",
"locations",
"of",
"the",
"last",
"block",
"."
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java#L729-L743
|
hankcs/HanLP
|
src/main/java/com/hankcs/hanlp/dictionary/CustomDictionary.java
|
CustomDictionary.updateAttributeIfExist
|
private static boolean updateAttributeIfExist(String key, CoreDictionary.Attribute attribute, TreeMap<String, CoreDictionary.Attribute> map, TreeMap<Integer, CoreDictionary.Attribute> rewriteTable) {
"""
如果已经存在该词条,直接更新该词条的属性
@param key 词语
@param attribute 词语的属性
@param map 加载期间的map
@param rewriteTable
@return 是否更新了
"""
int wordID = CoreDictionary.getWordID(key);
CoreDictionary.Attribute attributeExisted;
if (wordID != -1)
{
attributeExisted = CoreDictionary.get(wordID);
attributeExisted.nature = attribute.nature;
attributeExisted.frequency = attribute.frequency;
attributeExisted.totalFrequency = attribute.totalFrequency;
// 收集该覆写
rewriteTable.put(wordID, attribute);
return true;
}
attributeExisted = map.get(key);
if (attributeExisted != null)
{
attributeExisted.nature = attribute.nature;
attributeExisted.frequency = attribute.frequency;
attributeExisted.totalFrequency = attribute.totalFrequency;
return true;
}
return false;
}
|
java
|
private static boolean updateAttributeIfExist(String key, CoreDictionary.Attribute attribute, TreeMap<String, CoreDictionary.Attribute> map, TreeMap<Integer, CoreDictionary.Attribute> rewriteTable)
{
int wordID = CoreDictionary.getWordID(key);
CoreDictionary.Attribute attributeExisted;
if (wordID != -1)
{
attributeExisted = CoreDictionary.get(wordID);
attributeExisted.nature = attribute.nature;
attributeExisted.frequency = attribute.frequency;
attributeExisted.totalFrequency = attribute.totalFrequency;
// 收集该覆写
rewriteTable.put(wordID, attribute);
return true;
}
attributeExisted = map.get(key);
if (attributeExisted != null)
{
attributeExisted.nature = attribute.nature;
attributeExisted.frequency = attribute.frequency;
attributeExisted.totalFrequency = attribute.totalFrequency;
return true;
}
return false;
}
|
[
"private",
"static",
"boolean",
"updateAttributeIfExist",
"(",
"String",
"key",
",",
"CoreDictionary",
".",
"Attribute",
"attribute",
",",
"TreeMap",
"<",
"String",
",",
"CoreDictionary",
".",
"Attribute",
">",
"map",
",",
"TreeMap",
"<",
"Integer",
",",
"CoreDictionary",
".",
"Attribute",
">",
"rewriteTable",
")",
"{",
"int",
"wordID",
"=",
"CoreDictionary",
".",
"getWordID",
"(",
"key",
")",
";",
"CoreDictionary",
".",
"Attribute",
"attributeExisted",
";",
"if",
"(",
"wordID",
"!=",
"-",
"1",
")",
"{",
"attributeExisted",
"=",
"CoreDictionary",
".",
"get",
"(",
"wordID",
")",
";",
"attributeExisted",
".",
"nature",
"=",
"attribute",
".",
"nature",
";",
"attributeExisted",
".",
"frequency",
"=",
"attribute",
".",
"frequency",
";",
"attributeExisted",
".",
"totalFrequency",
"=",
"attribute",
".",
"totalFrequency",
";",
"// 收集该覆写",
"rewriteTable",
".",
"put",
"(",
"wordID",
",",
"attribute",
")",
";",
"return",
"true",
";",
"}",
"attributeExisted",
"=",
"map",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"attributeExisted",
"!=",
"null",
")",
"{",
"attributeExisted",
".",
"nature",
"=",
"attribute",
".",
"nature",
";",
"attributeExisted",
".",
"frequency",
"=",
"attribute",
".",
"frequency",
";",
"attributeExisted",
".",
"totalFrequency",
"=",
"attribute",
".",
"totalFrequency",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
如果已经存在该词条,直接更新该词条的属性
@param key 词语
@param attribute 词语的属性
@param map 加载期间的map
@param rewriteTable
@return 是否更新了
|
[
"如果已经存在该词条",
"直接更新该词条的属性"
] |
train
|
https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dictionary/CustomDictionary.java#L230-L255
|
dbracewell/mango
|
src/main/java/com/davidbracewell/config/Config.java
|
Config.closestKey
|
public static String closestKey(String propertyPrefix, Language language, String... propertyComponents) {
"""
Finds the closest key to the given components
@param propertyPrefix the property prefix
@param language the language
@param propertyComponents the property components
@return the string
"""
return findKey(propertyPrefix, language, propertyComponents);
}
|
java
|
public static String closestKey(String propertyPrefix, Language language, String... propertyComponents) {
return findKey(propertyPrefix, language, propertyComponents);
}
|
[
"public",
"static",
"String",
"closestKey",
"(",
"String",
"propertyPrefix",
",",
"Language",
"language",
",",
"String",
"...",
"propertyComponents",
")",
"{",
"return",
"findKey",
"(",
"propertyPrefix",
",",
"language",
",",
"propertyComponents",
")",
";",
"}"
] |
Finds the closest key to the given components
@param propertyPrefix the property prefix
@param language the language
@param propertyComponents the property components
@return the string
|
[
"Finds",
"the",
"closest",
"key",
"to",
"the",
"given",
"components"
] |
train
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/config/Config.java#L239-L241
|
raydac/java-binary-block-parser
|
jbbp/src/main/java/com/igormaznitsa/jbbp/compiler/JBBPCompiler.java
|
JBBPCompiler.registerNamedField
|
private static void registerNamedField(final String normalizedName, final int structureBorder, final int offset, final List<JBBPNamedFieldInfo> namedFields, final JBBPToken token) {
"""
Register a name field info item in a named field list.
@param normalizedName normalized name of the named field
@param offset the named field offset
@param namedFields the named field info list for registration
@param token the token for the field
@throws JBBPCompilationException if there is already a registered field for
the path
"""
for (int i = namedFields.size() - 1; i >= structureBorder; i--) {
final JBBPNamedFieldInfo info = namedFields.get(i);
if (info.getFieldPath().equals(normalizedName)) {
throw new JBBPCompilationException("Duplicated named field detected [" + normalizedName + ']', token);
}
}
namedFields.add(new JBBPNamedFieldInfo(normalizedName, normalizedName, offset));
}
|
java
|
private static void registerNamedField(final String normalizedName, final int structureBorder, final int offset, final List<JBBPNamedFieldInfo> namedFields, final JBBPToken token) {
for (int i = namedFields.size() - 1; i >= structureBorder; i--) {
final JBBPNamedFieldInfo info = namedFields.get(i);
if (info.getFieldPath().equals(normalizedName)) {
throw new JBBPCompilationException("Duplicated named field detected [" + normalizedName + ']', token);
}
}
namedFields.add(new JBBPNamedFieldInfo(normalizedName, normalizedName, offset));
}
|
[
"private",
"static",
"void",
"registerNamedField",
"(",
"final",
"String",
"normalizedName",
",",
"final",
"int",
"structureBorder",
",",
"final",
"int",
"offset",
",",
"final",
"List",
"<",
"JBBPNamedFieldInfo",
">",
"namedFields",
",",
"final",
"JBBPToken",
"token",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"namedFields",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
">=",
"structureBorder",
";",
"i",
"--",
")",
"{",
"final",
"JBBPNamedFieldInfo",
"info",
"=",
"namedFields",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"info",
".",
"getFieldPath",
"(",
")",
".",
"equals",
"(",
"normalizedName",
")",
")",
"{",
"throw",
"new",
"JBBPCompilationException",
"(",
"\"Duplicated named field detected [\"",
"+",
"normalizedName",
"+",
"'",
"'",
",",
"token",
")",
";",
"}",
"}",
"namedFields",
".",
"add",
"(",
"new",
"JBBPNamedFieldInfo",
"(",
"normalizedName",
",",
"normalizedName",
",",
"offset",
")",
")",
";",
"}"
] |
Register a name field info item in a named field list.
@param normalizedName normalized name of the named field
@param offset the named field offset
@param namedFields the named field info list for registration
@param token the token for the field
@throws JBBPCompilationException if there is already a registered field for
the path
|
[
"Register",
"a",
"name",
"field",
"info",
"item",
"in",
"a",
"named",
"field",
"list",
"."
] |
train
|
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/compiler/JBBPCompiler.java#L511-L519
|
inversoft/restify
|
src/main/java/com/inversoft/net/ssl/SSLTools.java
|
SSLTools.getSSLServerContext
|
public static SSLContext getSSLServerContext(String certificateString, String keyString) throws CertificateException, KeyStoreException, IOException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyManagementException, InvalidKeySpecException {
"""
This creates an in-memory keystore containing the certificate and private key and initializes the SSLContext with
the key material it contains.
<p>
For using with an HttpsServer: {@code SSLContext sslContext = getSSLServerContext(...); HttpsServer server =
HttpsServer.create(); server.setHttpsConfigurator (new HttpsConfigurator(sslContext));}
@param certificateString a PEM formatted Certificate
@param keyString a PKCS8 PEM formatted Private Key
@return a SSLContext configured with the Certificate and Private Key
"""
byte[] certBytes = parseDERFromPEM(certificateString, CERT_START, CERT_END);
byte[] keyBytes = parseDERFromPEM(keyString, P8_KEY_START, P8_KEY_END);
X509Certificate cert = generateCertificateFromDER(certBytes);
PrivateKey key = generatePrivateKeyFromPKCS8DER(keyBytes);
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(null);
keystore.setCertificateEntry("cert-alias", cert);
keystore.setKeyEntry("key-alias", key, "changeit".toCharArray(), new Certificate[]{cert});
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(keystore, "changeit".toCharArray());
KeyManager[] km = kmf.getKeyManagers();
SSLContext context = SSLContext.getInstance("TLS");
context.init(km, null, null);
return context;
}
|
java
|
public static SSLContext getSSLServerContext(String certificateString, String keyString) throws CertificateException, KeyStoreException, IOException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyManagementException, InvalidKeySpecException {
byte[] certBytes = parseDERFromPEM(certificateString, CERT_START, CERT_END);
byte[] keyBytes = parseDERFromPEM(keyString, P8_KEY_START, P8_KEY_END);
X509Certificate cert = generateCertificateFromDER(certBytes);
PrivateKey key = generatePrivateKeyFromPKCS8DER(keyBytes);
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(null);
keystore.setCertificateEntry("cert-alias", cert);
keystore.setKeyEntry("key-alias", key, "changeit".toCharArray(), new Certificate[]{cert});
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(keystore, "changeit".toCharArray());
KeyManager[] km = kmf.getKeyManagers();
SSLContext context = SSLContext.getInstance("TLS");
context.init(km, null, null);
return context;
}
|
[
"public",
"static",
"SSLContext",
"getSSLServerContext",
"(",
"String",
"certificateString",
",",
"String",
"keyString",
")",
"throws",
"CertificateException",
",",
"KeyStoreException",
",",
"IOException",
",",
"NoSuchAlgorithmException",
",",
"UnrecoverableKeyException",
",",
"KeyManagementException",
",",
"InvalidKeySpecException",
"{",
"byte",
"[",
"]",
"certBytes",
"=",
"parseDERFromPEM",
"(",
"certificateString",
",",
"CERT_START",
",",
"CERT_END",
")",
";",
"byte",
"[",
"]",
"keyBytes",
"=",
"parseDERFromPEM",
"(",
"keyString",
",",
"P8_KEY_START",
",",
"P8_KEY_END",
")",
";",
"X509Certificate",
"cert",
"=",
"generateCertificateFromDER",
"(",
"certBytes",
")",
";",
"PrivateKey",
"key",
"=",
"generatePrivateKeyFromPKCS8DER",
"(",
"keyBytes",
")",
";",
"KeyStore",
"keystore",
"=",
"KeyStore",
".",
"getInstance",
"(",
"\"JKS\"",
")",
";",
"keystore",
".",
"load",
"(",
"null",
")",
";",
"keystore",
".",
"setCertificateEntry",
"(",
"\"cert-alias\"",
",",
"cert",
")",
";",
"keystore",
".",
"setKeyEntry",
"(",
"\"key-alias\"",
",",
"key",
",",
"\"changeit\"",
".",
"toCharArray",
"(",
")",
",",
"new",
"Certificate",
"[",
"]",
"{",
"cert",
"}",
")",
";",
"KeyManagerFactory",
"kmf",
"=",
"KeyManagerFactory",
".",
"getInstance",
"(",
"\"SunX509\"",
")",
";",
"kmf",
".",
"init",
"(",
"keystore",
",",
"\"changeit\"",
".",
"toCharArray",
"(",
")",
")",
";",
"KeyManager",
"[",
"]",
"km",
"=",
"kmf",
".",
"getKeyManagers",
"(",
")",
";",
"SSLContext",
"context",
"=",
"SSLContext",
".",
"getInstance",
"(",
"\"TLS\"",
")",
";",
"context",
".",
"init",
"(",
"km",
",",
"null",
",",
"null",
")",
";",
"return",
"context",
";",
"}"
] |
This creates an in-memory keystore containing the certificate and private key and initializes the SSLContext with
the key material it contains.
<p>
For using with an HttpsServer: {@code SSLContext sslContext = getSSLServerContext(...); HttpsServer server =
HttpsServer.create(); server.setHttpsConfigurator (new HttpsConfigurator(sslContext));}
@param certificateString a PEM formatted Certificate
@param keyString a PKCS8 PEM formatted Private Key
@return a SSLContext configured with the Certificate and Private Key
|
[
"This",
"creates",
"an",
"in",
"-",
"memory",
"keystore",
"containing",
"the",
"certificate",
"and",
"private",
"key",
"and",
"initializes",
"the",
"SSLContext",
"with",
"the",
"key",
"material",
"it",
"contains",
".",
"<p",
">",
"For",
"using",
"with",
"an",
"HttpsServer",
":",
"{",
"@code",
"SSLContext",
"sslContext",
"=",
"getSSLServerContext",
"(",
"...",
")",
";",
"HttpsServer",
"server",
"=",
"HttpsServer",
".",
"create",
"()",
";",
"server",
".",
"setHttpsConfigurator",
"(",
"new",
"HttpsConfigurator",
"(",
"sslContext",
"))",
";",
"}"
] |
train
|
https://github.com/inversoft/restify/blob/f2426d9082e00a9d958af28f78ccda61802c6700/src/main/java/com/inversoft/net/ssl/SSLTools.java#L122-L142
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java
|
ApiOvhXdsl.eligibility_search_streetNumbers_POST
|
public OvhAsyncTaskArray<String> eligibility_search_streetNumbers_POST(String streetCode) throws IOException {
"""
Get the available street numbers for a given street code (unique identifier of a street you can get with the method POST /xdsl/eligibility/search/streets)
REST: POST /xdsl/eligibility/search/streetNumbers
@param streetCode [required] Street code
@deprecated
"""
String qPath = "/xdsl/eligibility/search/streetNumbers";
StringBuilder sb = path(qPath);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "streetCode", streetCode);
String resp = execN(qPath, "POST", sb.toString(), o);
return convertTo(resp, t8);
}
|
java
|
public OvhAsyncTaskArray<String> eligibility_search_streetNumbers_POST(String streetCode) throws IOException {
String qPath = "/xdsl/eligibility/search/streetNumbers";
StringBuilder sb = path(qPath);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "streetCode", streetCode);
String resp = execN(qPath, "POST", sb.toString(), o);
return convertTo(resp, t8);
}
|
[
"public",
"OvhAsyncTaskArray",
"<",
"String",
">",
"eligibility_search_streetNumbers_POST",
"(",
"String",
"streetCode",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/xdsl/eligibility/search/streetNumbers\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"streetCode\"",
",",
"streetCode",
")",
";",
"String",
"resp",
"=",
"execN",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t8",
")",
";",
"}"
] |
Get the available street numbers for a given street code (unique identifier of a street you can get with the method POST /xdsl/eligibility/search/streets)
REST: POST /xdsl/eligibility/search/streetNumbers
@param streetCode [required] Street code
@deprecated
|
[
"Get",
"the",
"available",
"street",
"numbers",
"for",
"a",
"given",
"street",
"code",
"(",
"unique",
"identifier",
"of",
"a",
"street",
"you",
"can",
"get",
"with",
"the",
"method",
"POST",
"/",
"xdsl",
"/",
"eligibility",
"/",
"search",
"/",
"streets",
")"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java#L339-L346
|
borball/weixin-sdk
|
weixin-mp/src/main/java/com/riversoft/weixin/mp/media/Materials.java
|
Materials.addVideo
|
public Material addVideo(InputStream inputStream, String fileName, String title, String description) {
"""
上传视频
@param inputStream 视频流
@param fileName 文件名
@param title title
@param description 描述
@return 上传结果
"""
String url = WxEndpoint.get("url.material.binary.upload");
String desc = "{\"title\":\"%s\",\"introduction\":\"%s\"}";
Map<String, String> form = new HashMap<>();
form.put("description", String.format(desc, title, description));
String response = wxClient.post(String.format(url, MediaType.video.name()), inputStream, fileName, form);
Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response);
if (result.containsKey("media_id")) {
return JsonMapper.defaultMapper().fromJson(response, Material.class);
} else {
logger.warn("image upload failed: {}", response);
throw new WxRuntimeException(999, response);
}
}
|
java
|
public Material addVideo(InputStream inputStream, String fileName, String title, String description) {
String url = WxEndpoint.get("url.material.binary.upload");
String desc = "{\"title\":\"%s\",\"introduction\":\"%s\"}";
Map<String, String> form = new HashMap<>();
form.put("description", String.format(desc, title, description));
String response = wxClient.post(String.format(url, MediaType.video.name()), inputStream, fileName, form);
Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response);
if (result.containsKey("media_id")) {
return JsonMapper.defaultMapper().fromJson(response, Material.class);
} else {
logger.warn("image upload failed: {}", response);
throw new WxRuntimeException(999, response);
}
}
|
[
"public",
"Material",
"addVideo",
"(",
"InputStream",
"inputStream",
",",
"String",
"fileName",
",",
"String",
"title",
",",
"String",
"description",
")",
"{",
"String",
"url",
"=",
"WxEndpoint",
".",
"get",
"(",
"\"url.material.binary.upload\"",
")",
";",
"String",
"desc",
"=",
"\"{\\\"title\\\":\\\"%s\\\",\\\"introduction\\\":\\\"%s\\\"}\"",
";",
"Map",
"<",
"String",
",",
"String",
">",
"form",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"form",
".",
"put",
"(",
"\"description\"",
",",
"String",
".",
"format",
"(",
"desc",
",",
"title",
",",
"description",
")",
")",
";",
"String",
"response",
"=",
"wxClient",
".",
"post",
"(",
"String",
".",
"format",
"(",
"url",
",",
"MediaType",
".",
"video",
".",
"name",
"(",
")",
")",
",",
"inputStream",
",",
"fileName",
",",
"form",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
"=",
"JsonMapper",
".",
"defaultMapper",
"(",
")",
".",
"json2Map",
"(",
"response",
")",
";",
"if",
"(",
"result",
".",
"containsKey",
"(",
"\"media_id\"",
")",
")",
"{",
"return",
"JsonMapper",
".",
"defaultMapper",
"(",
")",
".",
"fromJson",
"(",
"response",
",",
"Material",
".",
"class",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"\"image upload failed: {}\"",
",",
"response",
")",
";",
"throw",
"new",
"WxRuntimeException",
"(",
"999",
",",
"response",
")",
";",
"}",
"}"
] |
上传视频
@param inputStream 视频流
@param fileName 文件名
@param title title
@param description 描述
@return 上传结果
|
[
"上传视频"
] |
train
|
https://github.com/borball/weixin-sdk/blob/32bf5e45cdd8d0d28074e83954e1ec62dcf25cb7/weixin-mp/src/main/java/com/riversoft/weixin/mp/media/Materials.java#L198-L212
|
alkacon/opencms-core
|
src/org/opencms/search/CmsVfsIndexer.java
|
CmsVfsIndexer.updateResource
|
protected void updateResource(I_CmsIndexWriter indexWriter, String rootPath, I_CmsSearchDocument doc) {
"""
Updates a resource with the given index writer and the new document provided.<p>
@param indexWriter the index writer to update the resource with
@param rootPath the root path of the resource to update
@param doc the new document for the resource
"""
try {
indexWriter.updateDocument(rootPath, doc);
} catch (Exception e) {
if (LOG.isWarnEnabled()) {
LOG.warn(
Messages.get().getBundle().key(
Messages.LOG_IO_INDEX_DOCUMENT_UPDATE_2,
rootPath,
m_index.getName()),
e);
}
}
}
|
java
|
protected void updateResource(I_CmsIndexWriter indexWriter, String rootPath, I_CmsSearchDocument doc) {
try {
indexWriter.updateDocument(rootPath, doc);
} catch (Exception e) {
if (LOG.isWarnEnabled()) {
LOG.warn(
Messages.get().getBundle().key(
Messages.LOG_IO_INDEX_DOCUMENT_UPDATE_2,
rootPath,
m_index.getName()),
e);
}
}
}
|
[
"protected",
"void",
"updateResource",
"(",
"I_CmsIndexWriter",
"indexWriter",
",",
"String",
"rootPath",
",",
"I_CmsSearchDocument",
"doc",
")",
"{",
"try",
"{",
"indexWriter",
".",
"updateDocument",
"(",
"rootPath",
",",
"doc",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"LOG",
".",
"isWarnEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"LOG_IO_INDEX_DOCUMENT_UPDATE_2",
",",
"rootPath",
",",
"m_index",
".",
"getName",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Updates a resource with the given index writer and the new document provided.<p>
@param indexWriter the index writer to update the resource with
@param rootPath the root path of the resource to update
@param doc the new document for the resource
|
[
"Updates",
"a",
"resource",
"with",
"the",
"given",
"index",
"writer",
"and",
"the",
"new",
"document",
"provided",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/CmsVfsIndexer.java#L386-L400
|
tvesalainen/bcc
|
src/main/java/org/vesalainen/bcc/Assembler.java
|
Assembler.if_tcmpgt
|
public void if_tcmpgt(TypeMirror type, String target) throws IOException {
"""
gt succeeds if and only if value1 > value2
<p>Stack: ..., value1, value2 => ...
@param type
@param target
@throws IOException
"""
pushType(type);
if_tcmpgt(target);
popType();
}
|
java
|
public void if_tcmpgt(TypeMirror type, String target) throws IOException
{
pushType(type);
if_tcmpgt(target);
popType();
}
|
[
"public",
"void",
"if_tcmpgt",
"(",
"TypeMirror",
"type",
",",
"String",
"target",
")",
"throws",
"IOException",
"{",
"pushType",
"(",
"type",
")",
";",
"if_tcmpgt",
"(",
"target",
")",
";",
"popType",
"(",
")",
";",
"}"
] |
gt succeeds if and only if value1 > value2
<p>Stack: ..., value1, value2 => ...
@param type
@param target
@throws IOException
|
[
"gt",
"succeeds",
"if",
"and",
"only",
"if",
"value1",
">",
";",
"value2",
"<p",
">",
"Stack",
":",
"...",
"value1",
"value2",
"=",
">",
";",
"..."
] |
train
|
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/Assembler.java#L635-L640
|
ozimov/cirneco
|
hamcrest/hamcrest-matchers/src/main/java/it/ozimov/cirneco/hamcrest/HamcrestMatchers.java
|
HamcrestMatchers.containsInRelativeOrder
|
public static <T> Matcher<Iterable<? extends T>> containsInRelativeOrder(final Iterable<T> items) {
"""
Creates a matcher for {@linkplain Iterable}s that matches when a single pass over the examined
{@linkplain Iterable} yields a series of items, that contains items logically equal to the corresponding item in
the specified items, in the same relative order For example:<br />
<p>
<p>For example:
<p>
<pre>
//Arrange
Iterable<String> actual = Arrays.asList("a", "b", "c", "d");
Iterable<String> expected = Arrays.asList("a", "c");
//Assert
assertThat(actual, containsInRelativeOrder(expected));
</pre>
@param items the items that must be contained within items provided by an examined {@linkplain Iterable} in the
same relative order
"""
return IsIterableContainingInRelativeOrder.containsInRelativeOrder(items);
}
|
java
|
public static <T> Matcher<Iterable<? extends T>> containsInRelativeOrder(final Iterable<T> items) {
return IsIterableContainingInRelativeOrder.containsInRelativeOrder(items);
}
|
[
"public",
"static",
"<",
"T",
">",
"Matcher",
"<",
"Iterable",
"<",
"?",
"extends",
"T",
">",
">",
"containsInRelativeOrder",
"(",
"final",
"Iterable",
"<",
"T",
">",
"items",
")",
"{",
"return",
"IsIterableContainingInRelativeOrder",
".",
"containsInRelativeOrder",
"(",
"items",
")",
";",
"}"
] |
Creates a matcher for {@linkplain Iterable}s that matches when a single pass over the examined
{@linkplain Iterable} yields a series of items, that contains items logically equal to the corresponding item in
the specified items, in the same relative order For example:<br />
<p>
<p>For example:
<p>
<pre>
//Arrange
Iterable<String> actual = Arrays.asList("a", "b", "c", "d");
Iterable<String> expected = Arrays.asList("a", "c");
//Assert
assertThat(actual, containsInRelativeOrder(expected));
</pre>
@param items the items that must be contained within items provided by an examined {@linkplain Iterable} in the
same relative order
|
[
"Creates",
"a",
"matcher",
"for",
"{",
"@linkplain",
"Iterable",
"}",
"s",
"that",
"matches",
"when",
"a",
"single",
"pass",
"over",
"the",
"examined",
"{",
"@linkplain",
"Iterable",
"}",
"yields",
"a",
"series",
"of",
"items",
"that",
"contains",
"items",
"logically",
"equal",
"to",
"the",
"corresponding",
"item",
"in",
"the",
"specified",
"items",
"in",
"the",
"same",
"relative",
"order",
"For",
"example",
":",
"<br",
"/",
">",
"<p",
">",
"<p",
">",
"For",
"example",
":",
"<p",
">",
"<pre",
">",
"//",
"Arrange",
"Iterable<String",
">",
"actual",
"=",
"Arrays",
".",
"asList",
"(",
"a",
"b",
"c",
"d",
")",
";",
"Iterable<String",
">",
"expected",
"=",
"Arrays",
".",
"asList",
"(",
"a",
"c",
")",
";"
] |
train
|
https://github.com/ozimov/cirneco/blob/78ad782da0a2256634cfbebb2f97ed78c993b999/hamcrest/hamcrest-matchers/src/main/java/it/ozimov/cirneco/hamcrest/HamcrestMatchers.java#L560-L562
|
mguymon/model-citizen
|
core/src/main/java/com/tobedevoured/modelcitizen/ModelFactory.java
|
ModelFactory.setRegisterBlueprints
|
public void setRegisterBlueprints(Collection blueprints) throws RegisterBlueprintException {
"""
Register a List of Blueprint, Class, or String
class names of Blueprint
@param blueprints List
@throws RegisterBlueprintException failed to register blueprint
"""
for (Object blueprint : blueprints) {
if (blueprint instanceof Class) {
registerBlueprint((Class) blueprint);
} else if (blueprint instanceof String) {
registerBlueprint((String) blueprint);
} else if (blueprint instanceof String) {
registerBlueprint(blueprint);
} else {
throw new RegisterBlueprintException("Only supports List comprised of Class<Blueprint>, Blueprint, or String className");
}
}
}
|
java
|
public void setRegisterBlueprints(Collection blueprints) throws RegisterBlueprintException {
for (Object blueprint : blueprints) {
if (blueprint instanceof Class) {
registerBlueprint((Class) blueprint);
} else if (blueprint instanceof String) {
registerBlueprint((String) blueprint);
} else if (blueprint instanceof String) {
registerBlueprint(blueprint);
} else {
throw new RegisterBlueprintException("Only supports List comprised of Class<Blueprint>, Blueprint, or String className");
}
}
}
|
[
"public",
"void",
"setRegisterBlueprints",
"(",
"Collection",
"blueprints",
")",
"throws",
"RegisterBlueprintException",
"{",
"for",
"(",
"Object",
"blueprint",
":",
"blueprints",
")",
"{",
"if",
"(",
"blueprint",
"instanceof",
"Class",
")",
"{",
"registerBlueprint",
"(",
"(",
"Class",
")",
"blueprint",
")",
";",
"}",
"else",
"if",
"(",
"blueprint",
"instanceof",
"String",
")",
"{",
"registerBlueprint",
"(",
"(",
"String",
")",
"blueprint",
")",
";",
"}",
"else",
"if",
"(",
"blueprint",
"instanceof",
"String",
")",
"{",
"registerBlueprint",
"(",
"blueprint",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RegisterBlueprintException",
"(",
"\"Only supports List comprised of Class<Blueprint>, Blueprint, or String className\"",
")",
";",
"}",
"}",
"}"
] |
Register a List of Blueprint, Class, or String
class names of Blueprint
@param blueprints List
@throws RegisterBlueprintException failed to register blueprint
|
[
"Register",
"a",
"List",
"of",
"Blueprint",
"Class",
"or",
"String",
"class",
"names",
"of",
"Blueprint"
] |
train
|
https://github.com/mguymon/model-citizen/blob/9078ab4121897a21e598dd4f0efa6996b46e4dea/core/src/main/java/com/tobedevoured/modelcitizen/ModelFactory.java#L150-L162
|
khuxtable/seaglass
|
src/main/java/com/seaglasslookandfeel/painter/TitlePaneCloseButtonPainter.java
|
TitlePaneCloseButtonPainter.paintCloseHover
|
private void paintCloseHover(Graphics2D g, JComponent c, int width, int height) {
"""
Paint the background mouse-over state.
@param g the Graphics2D context to paint with.
@param c the component.
@param width the width of the component.
@param height the height of the component.
"""
paintClose(g, c, width, height, hover);
}
|
java
|
private void paintCloseHover(Graphics2D g, JComponent c, int width, int height) {
paintClose(g, c, width, height, hover);
}
|
[
"private",
"void",
"paintCloseHover",
"(",
"Graphics2D",
"g",
",",
"JComponent",
"c",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"paintClose",
"(",
"g",
",",
"c",
",",
"width",
",",
"height",
",",
"hover",
")",
";",
"}"
] |
Paint the background mouse-over state.
@param g the Graphics2D context to paint with.
@param c the component.
@param width the width of the component.
@param height the height of the component.
|
[
"Paint",
"the",
"background",
"mouse",
"-",
"over",
"state",
"."
] |
train
|
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/TitlePaneCloseButtonPainter.java#L127-L129
|
apereo/cas
|
core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/DefaultRegisteredServiceAccessStrategy.java
|
DefaultRegisteredServiceAccessStrategy.doRequiredAttributesAllowPrincipalAccess
|
protected boolean doRequiredAttributesAllowPrincipalAccess(final Map<String, Object> principalAttributes, final Map<String, Set<String>> requiredAttributes) {
"""
Do required attributes allow principal access boolean.
@param principalAttributes the principal attributes
@param requiredAttributes the required attributes
@return the boolean
"""
LOGGER.debug("These required attributes [{}] are examined against [{}] before service can proceed.", requiredAttributes, principalAttributes);
if (requiredAttributes.isEmpty()) {
return true;
}
return requiredAttributesFoundInMap(principalAttributes, requiredAttributes);
}
|
java
|
protected boolean doRequiredAttributesAllowPrincipalAccess(final Map<String, Object> principalAttributes, final Map<String, Set<String>> requiredAttributes) {
LOGGER.debug("These required attributes [{}] are examined against [{}] before service can proceed.", requiredAttributes, principalAttributes);
if (requiredAttributes.isEmpty()) {
return true;
}
return requiredAttributesFoundInMap(principalAttributes, requiredAttributes);
}
|
[
"protected",
"boolean",
"doRequiredAttributesAllowPrincipalAccess",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"principalAttributes",
",",
"final",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"requiredAttributes",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"These required attributes [{}] are examined against [{}] before service can proceed.\"",
",",
"requiredAttributes",
",",
"principalAttributes",
")",
";",
"if",
"(",
"requiredAttributes",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"requiredAttributesFoundInMap",
"(",
"principalAttributes",
",",
"requiredAttributes",
")",
";",
"}"
] |
Do required attributes allow principal access boolean.
@param principalAttributes the principal attributes
@param requiredAttributes the required attributes
@return the boolean
|
[
"Do",
"required",
"attributes",
"allow",
"principal",
"access",
"boolean",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/DefaultRegisteredServiceAccessStrategy.java#L192-L198
|
aws/aws-sdk-java
|
aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/UpdateGatewayResponseResult.java
|
UpdateGatewayResponseResult.withResponseParameters
|
public UpdateGatewayResponseResult withResponseParameters(java.util.Map<String, String> responseParameters) {
"""
<p>
Response parameters (paths, query strings and headers) of the <a>GatewayResponse</a> as a string-to-string map of
key-value pairs.
</p>
@param responseParameters
Response parameters (paths, query strings and headers) of the <a>GatewayResponse</a> as a string-to-string
map of key-value pairs.
@return Returns a reference to this object so that method calls can be chained together.
"""
setResponseParameters(responseParameters);
return this;
}
|
java
|
public UpdateGatewayResponseResult withResponseParameters(java.util.Map<String, String> responseParameters) {
setResponseParameters(responseParameters);
return this;
}
|
[
"public",
"UpdateGatewayResponseResult",
"withResponseParameters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"responseParameters",
")",
"{",
"setResponseParameters",
"(",
"responseParameters",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
Response parameters (paths, query strings and headers) of the <a>GatewayResponse</a> as a string-to-string map of
key-value pairs.
</p>
@param responseParameters
Response parameters (paths, query strings and headers) of the <a>GatewayResponse</a> as a string-to-string
map of key-value pairs.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"Response",
"parameters",
"(",
"paths",
"query",
"strings",
"and",
"headers",
")",
"of",
"the",
"<a",
">",
"GatewayResponse<",
"/",
"a",
">",
"as",
"a",
"string",
"-",
"to",
"-",
"string",
"map",
"of",
"key",
"-",
"value",
"pairs",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-api-gateway/src/main/java/com/amazonaws/services/apigateway/model/UpdateGatewayResponseResult.java#L483-L486
|
Azure/azure-sdk-for-java
|
logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountBatchConfigurationsInner.java
|
IntegrationAccountBatchConfigurationsInner.getAsync
|
public Observable<BatchConfigurationInner> getAsync(String resourceGroupName, String integrationAccountName, String batchConfigurationName) {
"""
Get a batch configuration for an integration account.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@param batchConfigurationName The batch configuration name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the BatchConfigurationInner object
"""
return getWithServiceResponseAsync(resourceGroupName, integrationAccountName, batchConfigurationName).map(new Func1<ServiceResponse<BatchConfigurationInner>, BatchConfigurationInner>() {
@Override
public BatchConfigurationInner call(ServiceResponse<BatchConfigurationInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<BatchConfigurationInner> getAsync(String resourceGroupName, String integrationAccountName, String batchConfigurationName) {
return getWithServiceResponseAsync(resourceGroupName, integrationAccountName, batchConfigurationName).map(new Func1<ServiceResponse<BatchConfigurationInner>, BatchConfigurationInner>() {
@Override
public BatchConfigurationInner call(ServiceResponse<BatchConfigurationInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"BatchConfigurationInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"integrationAccountName",
",",
"String",
"batchConfigurationName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"integrationAccountName",
",",
"batchConfigurationName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"BatchConfigurationInner",
">",
",",
"BatchConfigurationInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"BatchConfigurationInner",
"call",
"(",
"ServiceResponse",
"<",
"BatchConfigurationInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Get a batch configuration for an integration account.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@param batchConfigurationName The batch configuration name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the BatchConfigurationInner object
|
[
"Get",
"a",
"batch",
"configuration",
"for",
"an",
"integration",
"account",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountBatchConfigurationsInner.java#L206-L213
|
Azure/azure-sdk-for-java
|
iothub/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/iothub/v2018_04_01/implementation/IotHubResourcesInner.java
|
IotHubResourcesInner.getKeysForKeyNameAsync
|
public ServiceFuture<SharedAccessSignatureAuthorizationRuleInner> getKeysForKeyNameAsync(String resourceGroupName, String resourceName, String keyName, final ServiceCallback<SharedAccessSignatureAuthorizationRuleInner> serviceCallback) {
"""
Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security.
Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security.
@param resourceGroupName The name of the resource group that contains the IoT hub.
@param resourceName The name of the IoT hub.
@param keyName The name of the shared access policy.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return ServiceFuture.fromResponse(getKeysForKeyNameWithServiceResponseAsync(resourceGroupName, resourceName, keyName), serviceCallback);
}
|
java
|
public ServiceFuture<SharedAccessSignatureAuthorizationRuleInner> getKeysForKeyNameAsync(String resourceGroupName, String resourceName, String keyName, final ServiceCallback<SharedAccessSignatureAuthorizationRuleInner> serviceCallback) {
return ServiceFuture.fromResponse(getKeysForKeyNameWithServiceResponseAsync(resourceGroupName, resourceName, keyName), serviceCallback);
}
|
[
"public",
"ServiceFuture",
"<",
"SharedAccessSignatureAuthorizationRuleInner",
">",
"getKeysForKeyNameAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"String",
"keyName",
",",
"final",
"ServiceCallback",
"<",
"SharedAccessSignatureAuthorizationRuleInner",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"getKeysForKeyNameWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"keyName",
")",
",",
"serviceCallback",
")",
";",
"}"
] |
Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security.
Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security.
@param resourceGroupName The name of the resource group that contains the IoT hub.
@param resourceName The name of the IoT hub.
@param keyName The name of the shared access policy.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
|
[
"Get",
"a",
"shared",
"access",
"policy",
"by",
"name",
"from",
"an",
"IoT",
"hub",
".",
"For",
"more",
"information",
"see",
":",
"https",
":",
"//",
"docs",
".",
"microsoft",
".",
"com",
"/",
"azure",
"/",
"iot",
"-",
"hub",
"/",
"iot",
"-",
"hub",
"-",
"devguide",
"-",
"security",
".",
"Get",
"a",
"shared",
"access",
"policy",
"by",
"name",
"from",
"an",
"IoT",
"hub",
".",
"For",
"more",
"information",
"see",
":",
"https",
":",
"//",
"docs",
".",
"microsoft",
".",
"com",
"/",
"azure",
"/",
"iot",
"-",
"hub",
"/",
"iot",
"-",
"hub",
"-",
"devguide",
"-",
"security",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/iothub/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/iothub/v2018_04_01/implementation/IotHubResourcesInner.java#L2985-L2987
|
threerings/narya
|
core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java
|
ChatProvider.deliverTell
|
public void deliverTell (BodyObject target, UserMessage message) {
"""
Delivers a tell notification to the specified target player. It is assumed that the message
is coming from some server entity and need not be permissions checked or notified of the
result.
"""
SpeakUtil.sendMessage(target, message);
// note that the teller "heard" what they said
SpeakUtil.noteMessage(target, message.speaker, message);
}
|
java
|
public void deliverTell (BodyObject target, UserMessage message)
{
SpeakUtil.sendMessage(target, message);
// note that the teller "heard" what they said
SpeakUtil.noteMessage(target, message.speaker, message);
}
|
[
"public",
"void",
"deliverTell",
"(",
"BodyObject",
"target",
",",
"UserMessage",
"message",
")",
"{",
"SpeakUtil",
".",
"sendMessage",
"(",
"target",
",",
"message",
")",
";",
"// note that the teller \"heard\" what they said",
"SpeakUtil",
".",
"noteMessage",
"(",
"target",
",",
"message",
".",
"speaker",
",",
"message",
")",
";",
"}"
] |
Delivers a tell notification to the specified target player. It is assumed that the message
is coming from some server entity and need not be permissions checked or notified of the
result.
|
[
"Delivers",
"a",
"tell",
"notification",
"to",
"the",
"specified",
"target",
"player",
".",
"It",
"is",
"assumed",
"that",
"the",
"message",
"is",
"coming",
"from",
"some",
"server",
"entity",
"and",
"need",
"not",
"be",
"permissions",
"checked",
"or",
"notified",
"of",
"the",
"result",
"."
] |
train
|
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/chat/server/ChatProvider.java#L261-L267
|
TheCoder4eu/BootsFaces-OSP
|
src/main/java/net/bootsfaces/render/CoreRenderer.java
|
CoreRenderer.getFormGroupWithFeedback
|
@Deprecated
protected String getFormGroupWithFeedback(String additionalClass, String clientId) {
"""
Get the main field container
@deprecated Use
{@link CoreInputRenderer#getWithFeedback(net.bootsfaces.render.CoreInputRenderer.InputMode, javax.faces.component.UIComponent)}
instead
@param additionalClass
@param clientId
@return
"""
if (BsfUtils.isLegacyFeedbackClassesEnabled()) {
return additionalClass;
}
return additionalClass + " " + FacesMessages.getErrorSeverityClass(clientId);
}
|
java
|
@Deprecated
protected String getFormGroupWithFeedback(String additionalClass, String clientId) {
if (BsfUtils.isLegacyFeedbackClassesEnabled()) {
return additionalClass;
}
return additionalClass + " " + FacesMessages.getErrorSeverityClass(clientId);
}
|
[
"@",
"Deprecated",
"protected",
"String",
"getFormGroupWithFeedback",
"(",
"String",
"additionalClass",
",",
"String",
"clientId",
")",
"{",
"if",
"(",
"BsfUtils",
".",
"isLegacyFeedbackClassesEnabled",
"(",
")",
")",
"{",
"return",
"additionalClass",
";",
"}",
"return",
"additionalClass",
"+",
"\" \"",
"+",
"FacesMessages",
".",
"getErrorSeverityClass",
"(",
"clientId",
")",
";",
"}"
] |
Get the main field container
@deprecated Use
{@link CoreInputRenderer#getWithFeedback(net.bootsfaces.render.CoreInputRenderer.InputMode, javax.faces.component.UIComponent)}
instead
@param additionalClass
@param clientId
@return
|
[
"Get",
"the",
"main",
"field",
"container"
] |
train
|
https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/render/CoreRenderer.java#L641-L647
|
apereo/cas
|
core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java
|
AbstractCasWebflowConfigurer.createActionState
|
public ActionState createActionState(final Flow flow, final String name, final Action action) {
"""
Create action state action state.
@param flow the flow
@param name the name
@param action the action
@return the action state
"""
return createActionState(flow, name, new Action[]{action});
}
|
java
|
public ActionState createActionState(final Flow flow, final String name, final Action action) {
return createActionState(flow, name, new Action[]{action});
}
|
[
"public",
"ActionState",
"createActionState",
"(",
"final",
"Flow",
"flow",
",",
"final",
"String",
"name",
",",
"final",
"Action",
"action",
")",
"{",
"return",
"createActionState",
"(",
"flow",
",",
"name",
",",
"new",
"Action",
"[",
"]",
"{",
"action",
"}",
")",
";",
"}"
] |
Create action state action state.
@param flow the flow
@param name the name
@param action the action
@return the action state
|
[
"Create",
"action",
"state",
"action",
"state",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java#L200-L202
|
jferard/fastods
|
fastods/src/main/java/com/github/jferard/fastods/odselement/Settings.java
|
Settings.setViewSetting
|
public void setViewSetting(final String viewId, final String item, final String value) {
"""
Set a view setting
@param viewId the view to which add the setting
@param item the item name
@param value the item value
"""
final ConfigItemMapEntrySet view = this.viewById.get(viewId);
if (view == null)
return;
view.set(item, value);
}
|
java
|
public void setViewSetting(final String viewId, final String item, final String value) {
final ConfigItemMapEntrySet view = this.viewById.get(viewId);
if (view == null)
return;
view.set(item, value);
}
|
[
"public",
"void",
"setViewSetting",
"(",
"final",
"String",
"viewId",
",",
"final",
"String",
"item",
",",
"final",
"String",
"value",
")",
"{",
"final",
"ConfigItemMapEntrySet",
"view",
"=",
"this",
".",
"viewById",
".",
"get",
"(",
"viewId",
")",
";",
"if",
"(",
"view",
"==",
"null",
")",
"return",
";",
"view",
".",
"set",
"(",
"item",
",",
"value",
")",
";",
"}"
] |
Set a view setting
@param viewId the view to which add the setting
@param item the item name
@param value the item value
|
[
"Set",
"a",
"view",
"setting"
] |
train
|
https://github.com/jferard/fastods/blob/a034d173083ffa602dc525699b97f753082eaef9/fastods/src/main/java/com/github/jferard/fastods/odselement/Settings.java#L227-L233
|
alkacon/opencms-core
|
src-gwt/org/opencms/gwt/client/CmsCoreProvider.java
|
CmsCoreProvider.getResourceState
|
public void getResourceState(final CmsUUID structureId, final AsyncCallback<CmsResourceState> callback) {
"""
Fetches the state of a resource from the server.<p>
@param structureId the structure id of the resource
@param callback the callback which should receive the result
"""
CmsRpcAction<CmsResourceState> action = new CmsRpcAction<CmsResourceState>() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(0, false);
getService().getResourceState(structureId, this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
protected void onResponse(CmsResourceState result) {
stop(false);
callback.onSuccess(result);
}
};
action.execute();
}
|
java
|
public void getResourceState(final CmsUUID structureId, final AsyncCallback<CmsResourceState> callback) {
CmsRpcAction<CmsResourceState> action = new CmsRpcAction<CmsResourceState>() {
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
*/
@Override
public void execute() {
start(0, false);
getService().getResourceState(structureId, this);
}
/**
* @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
*/
@Override
protected void onResponse(CmsResourceState result) {
stop(false);
callback.onSuccess(result);
}
};
action.execute();
}
|
[
"public",
"void",
"getResourceState",
"(",
"final",
"CmsUUID",
"structureId",
",",
"final",
"AsyncCallback",
"<",
"CmsResourceState",
">",
"callback",
")",
"{",
"CmsRpcAction",
"<",
"CmsResourceState",
">",
"action",
"=",
"new",
"CmsRpcAction",
"<",
"CmsResourceState",
">",
"(",
")",
"{",
"/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()\n */",
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"{",
"start",
"(",
"0",
",",
"false",
")",
";",
"getService",
"(",
")",
".",
"getResourceState",
"(",
"structureId",
",",
"this",
")",
";",
"}",
"/**\n * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)\n */",
"@",
"Override",
"protected",
"void",
"onResponse",
"(",
"CmsResourceState",
"result",
")",
"{",
"stop",
"(",
"false",
")",
";",
"callback",
".",
"onSuccess",
"(",
"result",
")",
";",
"}",
"}",
";",
"action",
".",
"execute",
"(",
")",
";",
"}"
] |
Fetches the state of a resource from the server.<p>
@param structureId the structure id of the resource
@param callback the callback which should receive the result
|
[
"Fetches",
"the",
"state",
"of",
"a",
"resource",
"from",
"the",
"server",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/CmsCoreProvider.java#L312-L337
|
CenturyLinkCloud/mdw
|
mdw-services/src/com/centurylink/mdw/service/data/process/EngineDataAccessDB.java
|
EngineDataAccessDB.getVariableNameForTaskInstance
|
public String getVariableNameForTaskInstance(Long taskInstId, String name) throws SQLException {
"""
Get the variable name for a task instance with 'Referred as' name
@param taskInstId
@param name
@return
@throws SQLException
"""
String query = "select v.VARIABLE_NAME " +
"from VARIABLE v, VARIABLE_MAPPING vm, TASK t, TASK_INSTANCE ti " +
"where ti.TASK_INSTANCE_ID = ?" +
" and ti.TASK_ID = t.TASK_ID" +
" and vm.MAPPING_OWNER = 'TASK'" +
" and vm.MAPPING_OWNER_ID = t.TASK_ID" +
" and v.VARIABLE_ID = vm.VARIABLE_ID" +
" and (v.VARIABLE_NAME = ? or vm.VAR_REFERRED_AS = ?)";
Object[] args = new Object[3];
args[0] = taskInstId;
args[1] = name;
args[2] = name;
ResultSet rs = db.runSelect(query, args);
if (rs.next()) {
/*if (rs.isLast())*/ return rs.getString(1);
//else throw new SQLException("getVariableNameForTaskInstance returns non-unique result");
} else throw new SQLException("getVariableNameForTaskInstance returns no result");
}
|
java
|
public String getVariableNameForTaskInstance(Long taskInstId, String name) throws SQLException {
String query = "select v.VARIABLE_NAME " +
"from VARIABLE v, VARIABLE_MAPPING vm, TASK t, TASK_INSTANCE ti " +
"where ti.TASK_INSTANCE_ID = ?" +
" and ti.TASK_ID = t.TASK_ID" +
" and vm.MAPPING_OWNER = 'TASK'" +
" and vm.MAPPING_OWNER_ID = t.TASK_ID" +
" and v.VARIABLE_ID = vm.VARIABLE_ID" +
" and (v.VARIABLE_NAME = ? or vm.VAR_REFERRED_AS = ?)";
Object[] args = new Object[3];
args[0] = taskInstId;
args[1] = name;
args[2] = name;
ResultSet rs = db.runSelect(query, args);
if (rs.next()) {
/*if (rs.isLast())*/ return rs.getString(1);
//else throw new SQLException("getVariableNameForTaskInstance returns non-unique result");
} else throw new SQLException("getVariableNameForTaskInstance returns no result");
}
|
[
"public",
"String",
"getVariableNameForTaskInstance",
"(",
"Long",
"taskInstId",
",",
"String",
"name",
")",
"throws",
"SQLException",
"{",
"String",
"query",
"=",
"\"select v.VARIABLE_NAME \"",
"+",
"\"from VARIABLE v, VARIABLE_MAPPING vm, TASK t, TASK_INSTANCE ti \"",
"+",
"\"where ti.TASK_INSTANCE_ID = ?\"",
"+",
"\" and ti.TASK_ID = t.TASK_ID\"",
"+",
"\" and vm.MAPPING_OWNER = 'TASK'\"",
"+",
"\" and vm.MAPPING_OWNER_ID = t.TASK_ID\"",
"+",
"\" and v.VARIABLE_ID = vm.VARIABLE_ID\"",
"+",
"\" and (v.VARIABLE_NAME = ? or vm.VAR_REFERRED_AS = ?)\"",
";",
"Object",
"[",
"]",
"args",
"=",
"new",
"Object",
"[",
"3",
"]",
";",
"args",
"[",
"0",
"]",
"=",
"taskInstId",
";",
"args",
"[",
"1",
"]",
"=",
"name",
";",
"args",
"[",
"2",
"]",
"=",
"name",
";",
"ResultSet",
"rs",
"=",
"db",
".",
"runSelect",
"(",
"query",
",",
"args",
")",
";",
"if",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"/*if (rs.isLast())*/",
"return",
"rs",
".",
"getString",
"(",
"1",
")",
";",
"//else throw new SQLException(\"getVariableNameForTaskInstance returns non-unique result\");",
"}",
"else",
"throw",
"new",
"SQLException",
"(",
"\"getVariableNameForTaskInstance returns no result\"",
")",
";",
"}"
] |
Get the variable name for a task instance with 'Referred as' name
@param taskInstId
@param name
@return
@throws SQLException
|
[
"Get",
"the",
"variable",
"name",
"for",
"a",
"task",
"instance",
"with",
"Referred",
"as",
"name"
] |
train
|
https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/service/data/process/EngineDataAccessDB.java#L1169-L1187
|
mangstadt/biweekly
|
src/main/java/biweekly/util/Recurrence.java
|
Recurrence.getDateIterator
|
public DateIterator getDateIterator(Date startDate, TimeZone timezone) {
"""
Creates an iterator that computes the dates defined by this recurrence.
@param startDate the date that the recurrence starts (typically, the
value of the {@link DateStart} property)
@param timezone the timezone to iterate in (typically, the timezone
associated with the {@link DateStart} property). This is needed in order
to adjust for when the iterator passes over a daylight savings boundary.
@return the iterator
@see <a
href="https://code.google.com/p/google-rfc-2445/">google-rfc-2445</a>
"""
return getDateIterator(new ICalDate(startDate), timezone);
}
|
java
|
public DateIterator getDateIterator(Date startDate, TimeZone timezone) {
return getDateIterator(new ICalDate(startDate), timezone);
}
|
[
"public",
"DateIterator",
"getDateIterator",
"(",
"Date",
"startDate",
",",
"TimeZone",
"timezone",
")",
"{",
"return",
"getDateIterator",
"(",
"new",
"ICalDate",
"(",
"startDate",
")",
",",
"timezone",
")",
";",
"}"
] |
Creates an iterator that computes the dates defined by this recurrence.
@param startDate the date that the recurrence starts (typically, the
value of the {@link DateStart} property)
@param timezone the timezone to iterate in (typically, the timezone
associated with the {@link DateStart} property). This is needed in order
to adjust for when the iterator passes over a daylight savings boundary.
@return the iterator
@see <a
href="https://code.google.com/p/google-rfc-2445/">google-rfc-2445</a>
|
[
"Creates",
"an",
"iterator",
"that",
"computes",
"the",
"dates",
"defined",
"by",
"this",
"recurrence",
"."
] |
train
|
https://github.com/mangstadt/biweekly/blob/2e21350f85c13dfff52fdef98fdbebe2976fcf61/src/main/java/biweekly/util/Recurrence.java#L230-L232
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/java/awt/font/NumericShaper.java
|
NumericShaper.getContextualShaper
|
public static NumericShaper getContextualShaper(int ranges, int defaultContext) {
"""
Returns a contextual shaper for the provided unicode range(s).
Latin-1 (EUROPEAN) digits will be converted to the decimal digits
corresponding to the range of the preceding text, if the
range is one of the provided ranges. Multiple ranges are
represented by or-ing the values together, for example,
<code>NumericShaper.ARABIC | NumericShaper.THAI</code>. The
shaper uses defaultContext as the starting context.
@param ranges the specified Unicode ranges
@param defaultContext the starting context, such as
<code>NumericShaper.EUROPEAN</code>
@return a shaper for the specified Unicode ranges.
@throws IllegalArgumentException if the specified
<code>defaultContext</code> is not a single valid range.
"""
int key = getKeyFromMask(defaultContext);
ranges |= CONTEXTUAL_MASK;
return new NumericShaper(key, ranges);
}
|
java
|
public static NumericShaper getContextualShaper(int ranges, int defaultContext) {
int key = getKeyFromMask(defaultContext);
ranges |= CONTEXTUAL_MASK;
return new NumericShaper(key, ranges);
}
|
[
"public",
"static",
"NumericShaper",
"getContextualShaper",
"(",
"int",
"ranges",
",",
"int",
"defaultContext",
")",
"{",
"int",
"key",
"=",
"getKeyFromMask",
"(",
"defaultContext",
")",
";",
"ranges",
"|=",
"CONTEXTUAL_MASK",
";",
"return",
"new",
"NumericShaper",
"(",
"key",
",",
"ranges",
")",
";",
"}"
] |
Returns a contextual shaper for the provided unicode range(s).
Latin-1 (EUROPEAN) digits will be converted to the decimal digits
corresponding to the range of the preceding text, if the
range is one of the provided ranges. Multiple ranges are
represented by or-ing the values together, for example,
<code>NumericShaper.ARABIC | NumericShaper.THAI</code>. The
shaper uses defaultContext as the starting context.
@param ranges the specified Unicode ranges
@param defaultContext the starting context, such as
<code>NumericShaper.EUROPEAN</code>
@return a shaper for the specified Unicode ranges.
@throws IllegalArgumentException if the specified
<code>defaultContext</code> is not a single valid range.
|
[
"Returns",
"a",
"contextual",
"shaper",
"for",
"the",
"provided",
"unicode",
"range",
"(",
"s",
")",
".",
"Latin",
"-",
"1",
"(",
"EUROPEAN",
")",
"digits",
"will",
"be",
"converted",
"to",
"the",
"decimal",
"digits",
"corresponding",
"to",
"the",
"range",
"of",
"the",
"preceding",
"text",
"if",
"the",
"range",
"is",
"one",
"of",
"the",
"provided",
"ranges",
".",
"Multiple",
"ranges",
"are",
"represented",
"by",
"or",
"-",
"ing",
"the",
"values",
"together",
"for",
"example",
"<code",
">",
"NumericShaper",
".",
"ARABIC",
"|",
"NumericShaper",
".",
"THAI<",
"/",
"code",
">",
".",
"The",
"shaper",
"uses",
"defaultContext",
"as",
"the",
"starting",
"context",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/awt/font/NumericShaper.java#L1019-L1023
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-hostingprivateDatabase/src/main/java/net/minidev/ovh/api/ApiOvhHostingprivateDatabase.java
|
ApiOvhHostingprivateDatabase.serviceName_dump_dumpId_DELETE
|
public OvhTask serviceName_dump_dumpId_DELETE(String serviceName, Long dumpId) throws IOException {
"""
Delete dump before expiration date
REST: DELETE /hosting/privateDatabase/{serviceName}/dump/{dumpId}
@param serviceName [required] The internal name of your private database
@param dumpId [required] Dump id
"""
String qPath = "/hosting/privateDatabase/{serviceName}/dump/{dumpId}";
StringBuilder sb = path(qPath, serviceName, dumpId);
String resp = exec(qPath, "DELETE", sb.toString(), null);
return convertTo(resp, OvhTask.class);
}
|
java
|
public OvhTask serviceName_dump_dumpId_DELETE(String serviceName, Long dumpId) throws IOException {
String qPath = "/hosting/privateDatabase/{serviceName}/dump/{dumpId}";
StringBuilder sb = path(qPath, serviceName, dumpId);
String resp = exec(qPath, "DELETE", sb.toString(), null);
return convertTo(resp, OvhTask.class);
}
|
[
"public",
"OvhTask",
"serviceName_dump_dumpId_DELETE",
"(",
"String",
"serviceName",
",",
"Long",
"dumpId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/hosting/privateDatabase/{serviceName}/dump/{dumpId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"dumpId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhTask",
".",
"class",
")",
";",
"}"
] |
Delete dump before expiration date
REST: DELETE /hosting/privateDatabase/{serviceName}/dump/{dumpId}
@param serviceName [required] The internal name of your private database
@param dumpId [required] Dump id
|
[
"Delete",
"dump",
"before",
"expiration",
"date"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-hostingprivateDatabase/src/main/java/net/minidev/ovh/api/ApiOvhHostingprivateDatabase.java#L685-L690
|
groovy/gmaven
|
groovy-maven-plugin/src/main/java/org/codehaus/gmaven/plugin/util/GroovyVersionHelper.java
|
GroovyVersionHelper.getVersion
|
private String getVersion(final ClassLoader classLoader, final String className, final String methodName) {
"""
Get version from Groovy version helper utilities via reflection.
"""
log.trace("Getting version; class-loader: {}, class-name: {}, method-name: {}",
classLoader, className, methodName);
try {
Class<?> type = classLoader.loadClass(className);
Method method = type.getMethod(methodName);
Object result = method.invoke(null);
if (result != null) {
return result.toString();
}
}
catch (Throwable e) {
log.trace("Unable determine version from: {}", className);
}
return null;
}
|
java
|
private String getVersion(final ClassLoader classLoader, final String className, final String methodName) {
log.trace("Getting version; class-loader: {}, class-name: {}, method-name: {}",
classLoader, className, methodName);
try {
Class<?> type = classLoader.loadClass(className);
Method method = type.getMethod(methodName);
Object result = method.invoke(null);
if (result != null) {
return result.toString();
}
}
catch (Throwable e) {
log.trace("Unable determine version from: {}", className);
}
return null;
}
|
[
"private",
"String",
"getVersion",
"(",
"final",
"ClassLoader",
"classLoader",
",",
"final",
"String",
"className",
",",
"final",
"String",
"methodName",
")",
"{",
"log",
".",
"trace",
"(",
"\"Getting version; class-loader: {}, class-name: {}, method-name: {}\"",
",",
"classLoader",
",",
"className",
",",
"methodName",
")",
";",
"try",
"{",
"Class",
"<",
"?",
">",
"type",
"=",
"classLoader",
".",
"loadClass",
"(",
"className",
")",
";",
"Method",
"method",
"=",
"type",
".",
"getMethod",
"(",
"methodName",
")",
";",
"Object",
"result",
"=",
"method",
".",
"invoke",
"(",
"null",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"log",
".",
"trace",
"(",
"\"Unable determine version from: {}\"",
",",
"className",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get version from Groovy version helper utilities via reflection.
|
[
"Get",
"version",
"from",
"Groovy",
"version",
"helper",
"utilities",
"via",
"reflection",
"."
] |
train
|
https://github.com/groovy/gmaven/blob/6978316bbc29d9cc6793494e0d1a0a057e47de6c/groovy-maven-plugin/src/main/java/org/codehaus/gmaven/plugin/util/GroovyVersionHelper.java#L77-L94
|
dita-ot/dita-ot
|
src/main/java/org/dita/dost/util/XMLUtils.java
|
XMLUtils.getElementNode
|
public static Element getElementNode(final Element element, final DitaClass classValue) {
"""
Get specific element node from child nodes.
@param element parent node
@param classValue DITA class to search for
@return element node, {@code null} if not found
"""
final NodeList list = element.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
final Node node = list.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
final Element child = (Element) node;
if (classValue.matches(child)) {
return child;
}
}
}
return null;
}
|
java
|
public static Element getElementNode(final Element element, final DitaClass classValue) {
final NodeList list = element.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
final Node node = list.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
final Element child = (Element) node;
if (classValue.matches(child)) {
return child;
}
}
}
return null;
}
|
[
"public",
"static",
"Element",
"getElementNode",
"(",
"final",
"Element",
"element",
",",
"final",
"DitaClass",
"classValue",
")",
"{",
"final",
"NodeList",
"list",
"=",
"element",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"Node",
"node",
"=",
"list",
".",
"item",
"(",
"i",
")",
";",
"if",
"(",
"node",
".",
"getNodeType",
"(",
")",
"==",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"final",
"Element",
"child",
"=",
"(",
"Element",
")",
"node",
";",
"if",
"(",
"classValue",
".",
"matches",
"(",
"child",
")",
")",
"{",
"return",
"child",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get specific element node from child nodes.
@param element parent node
@param classValue DITA class to search for
@return element node, {@code null} if not found
|
[
"Get",
"specific",
"element",
"node",
"from",
"child",
"nodes",
"."
] |
train
|
https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/XMLUtils.java#L241-L253
|
future-architect/uroborosql
|
src/main/java/jp/co/future/uroborosql/client/SqlParamUtils.java
|
SqlParamUtils.setParam
|
private static void setParam(final SqlContext ctx, final String key, final String val) {
"""
1つのパラメータの設定
パラメータ値は以下の表記が可能
<dl>
<dh>[NULL]</dh>
<dd><code>null</code>を設定する</dd>
<dh>[EMPTY]</dh>
<dd>""(空文字)を設定する</dd>
<dh>'値'</dh>
<dd>文字列として設定する. 空白を含めることもできる</dd>
<dh>[値1,値2,...]</dh>
<dd>配列として設定する</dd>
<dh>その他</dh>
<dd>文字列として設定する</dd>
</dl>
@param ctx SqlContext
@param key パラメータキー
@param val パラメータ値
"""
if (val.startsWith("[") && val.endsWith("]") && !(val.equals("[NULL]") || val.equals("[EMPTY]"))) {
// [] で囲まれた値は配列に変換する。ex) [1, 2] => {"1", "2"}
String[] parts = val.substring(1, val.length() - 1).split("\\s*,\\s*");
Object[] vals = new Object[parts.length];
for (int i = 0; i < parts.length; i++) {
vals[i] = convertSingleValue(parts[i]);
}
ctx.paramList(key, vals);
} else {
ctx.param(key, convertSingleValue(val));
}
}
|
java
|
private static void setParam(final SqlContext ctx, final String key, final String val) {
if (val.startsWith("[") && val.endsWith("]") && !(val.equals("[NULL]") || val.equals("[EMPTY]"))) {
// [] で囲まれた値は配列に変換する。ex) [1, 2] => {"1", "2"}
String[] parts = val.substring(1, val.length() - 1).split("\\s*,\\s*");
Object[] vals = new Object[parts.length];
for (int i = 0; i < parts.length; i++) {
vals[i] = convertSingleValue(parts[i]);
}
ctx.paramList(key, vals);
} else {
ctx.param(key, convertSingleValue(val));
}
}
|
[
"private",
"static",
"void",
"setParam",
"(",
"final",
"SqlContext",
"ctx",
",",
"final",
"String",
"key",
",",
"final",
"String",
"val",
")",
"{",
"if",
"(",
"val",
".",
"startsWith",
"(",
"\"[\"",
")",
"&&",
"val",
".",
"endsWith",
"(",
"\"]\"",
")",
"&&",
"!",
"(",
"val",
".",
"equals",
"(",
"\"[NULL]\"",
")",
"||",
"val",
".",
"equals",
"(",
"\"[EMPTY]\"",
")",
")",
")",
"{",
"// [] で囲まれた値は配列に変換する。ex) [1, 2] => {\"1\", \"2\"}",
"String",
"[",
"]",
"parts",
"=",
"val",
".",
"substring",
"(",
"1",
",",
"val",
".",
"length",
"(",
")",
"-",
"1",
")",
".",
"split",
"(",
"\"\\\\s*,\\\\s*\"",
")",
";",
"Object",
"[",
"]",
"vals",
"=",
"new",
"Object",
"[",
"parts",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parts",
".",
"length",
";",
"i",
"++",
")",
"{",
"vals",
"[",
"i",
"]",
"=",
"convertSingleValue",
"(",
"parts",
"[",
"i",
"]",
")",
";",
"}",
"ctx",
".",
"paramList",
"(",
"key",
",",
"vals",
")",
";",
"}",
"else",
"{",
"ctx",
".",
"param",
"(",
"key",
",",
"convertSingleValue",
"(",
"val",
")",
")",
";",
"}",
"}"
] |
1つのパラメータの設定
パラメータ値は以下の表記が可能
<dl>
<dh>[NULL]</dh>
<dd><code>null</code>を設定する</dd>
<dh>[EMPTY]</dh>
<dd>""(空文字)を設定する</dd>
<dh>'値'</dh>
<dd>文字列として設定する. 空白を含めることもできる</dd>
<dh>[値1,値2,...]</dh>
<dd>配列として設定する</dd>
<dh>その他</dh>
<dd>文字列として設定する</dd>
</dl>
@param ctx SqlContext
@param key パラメータキー
@param val パラメータ値
|
[
"1つのパラメータの設定"
] |
train
|
https://github.com/future-architect/uroborosql/blob/4c26db51defdac3c6ed16866e33ab45e190e2e0c/src/main/java/jp/co/future/uroborosql/client/SqlParamUtils.java#L99-L111
|
RoaringBitmap/RoaringBitmap
|
roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java
|
BufferUtil.unsignedBinarySearch
|
public static int unsignedBinarySearch(final ShortBuffer array, final int begin, final int end,
final short k) {
"""
Look for value k in buffer in the range [begin,end). If the value is found, return its index.
If not, return -(i+1) where i is the index where the value would be inserted. The buffer is
assumed to contain sorted values where shorts are interpreted as unsigned integers.
@param array buffer where we search
@param begin first index (inclusive)
@param end last index (exclusive)
@param k value we search for
@return count
"""
return branchyUnsignedBinarySearch(array, begin, end, k);
}
|
java
|
public static int unsignedBinarySearch(final ShortBuffer array, final int begin, final int end,
final short k) {
return branchyUnsignedBinarySearch(array, begin, end, k);
}
|
[
"public",
"static",
"int",
"unsignedBinarySearch",
"(",
"final",
"ShortBuffer",
"array",
",",
"final",
"int",
"begin",
",",
"final",
"int",
"end",
",",
"final",
"short",
"k",
")",
"{",
"return",
"branchyUnsignedBinarySearch",
"(",
"array",
",",
"begin",
",",
"end",
",",
"k",
")",
";",
"}"
] |
Look for value k in buffer in the range [begin,end). If the value is found, return its index.
If not, return -(i+1) where i is the index where the value would be inserted. The buffer is
assumed to contain sorted values where shorts are interpreted as unsigned integers.
@param array buffer where we search
@param begin first index (inclusive)
@param end last index (exclusive)
@param k value we search for
@return count
|
[
"Look",
"for",
"value",
"k",
"in",
"buffer",
"in",
"the",
"range",
"[",
"begin",
"end",
")",
".",
"If",
"the",
"value",
"is",
"found",
"return",
"its",
"index",
".",
"If",
"not",
"return",
"-",
"(",
"i",
"+",
"1",
")",
"where",
"i",
"is",
"the",
"index",
"where",
"the",
"value",
"would",
"be",
"inserted",
".",
"The",
"buffer",
"is",
"assumed",
"to",
"contain",
"sorted",
"values",
"where",
"shorts",
"are",
"interpreted",
"as",
"unsigned",
"integers",
"."
] |
train
|
https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java#L619-L622
|
orbisgis/h2gis
|
h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParserTrk.java
|
AbstractGpxParserTrk.startElement
|
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
"""
Fires whenever an XML start markup is encountered. It creates a new
trackSegment when a <trkseg> markup is encountered. It creates a new
trackPoint when a <trkpt> markup is encountered. It saves informations
about <link> in currentPoint or currentLine.
@param uri URI of the local element
@param localName Name of the local element (without prefix)
@param qName qName of the local element (with prefix)
@param attributes Attributes of the local element (contained in the
markup)
@throws SAXException Any SAX exception, possibly wrapping another
exception
"""
if (localName.equalsIgnoreCase(GPXTags.TRKSEG)) {
segment = true;
GPXLine trkSegment = new GPXLine(GpxMetadata.TRKSEGFIELDCOUNT);
trkSegment.setValue(GpxMetadata.LINEID, trksegID++);
trkSegment.setValue(GpxMetadata.TRKSEG_TRKID, getCurrentLine().getValues()[GpxMetadata.LINEID]);
setCurrentSegment(trkSegment);
trksegList.clear();
} else if (localName.equalsIgnoreCase(GPXTags.TRKPT)) {
point = true;
GPXPoint trackPoint = new GPXPoint(GpxMetadata.TRKPTFIELDCOUNT);
Coordinate coordinate = GPXCoordinate.createCoordinate(attributes);
Point geom = getGeometryFactory().createPoint(coordinate);
geom.setSRID(4326);
trackPoint.setValue(GpxMetadata.THE_GEOM, geom);
trackPoint.setValue(GpxMetadata.PTLAT, coordinate.y);
trackPoint.setValue(GpxMetadata.PTLON, coordinate.x);
trackPoint.setValue(GpxMetadata.PTELE, coordinate.z);
trackPoint.setValue(GpxMetadata.PTID, trkptID++);
trackPoint.setValue(GpxMetadata.TRKPT_TRKSEGID, trksegID);
trksegList.add(coordinate);
setCurrentPoint(trackPoint);
}
// Clear content buffer
getContentBuffer().delete(0, getContentBuffer().length());
// Store name of current element in stack
getElementNames().push(qName);
}
|
java
|
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (localName.equalsIgnoreCase(GPXTags.TRKSEG)) {
segment = true;
GPXLine trkSegment = new GPXLine(GpxMetadata.TRKSEGFIELDCOUNT);
trkSegment.setValue(GpxMetadata.LINEID, trksegID++);
trkSegment.setValue(GpxMetadata.TRKSEG_TRKID, getCurrentLine().getValues()[GpxMetadata.LINEID]);
setCurrentSegment(trkSegment);
trksegList.clear();
} else if (localName.equalsIgnoreCase(GPXTags.TRKPT)) {
point = true;
GPXPoint trackPoint = new GPXPoint(GpxMetadata.TRKPTFIELDCOUNT);
Coordinate coordinate = GPXCoordinate.createCoordinate(attributes);
Point geom = getGeometryFactory().createPoint(coordinate);
geom.setSRID(4326);
trackPoint.setValue(GpxMetadata.THE_GEOM, geom);
trackPoint.setValue(GpxMetadata.PTLAT, coordinate.y);
trackPoint.setValue(GpxMetadata.PTLON, coordinate.x);
trackPoint.setValue(GpxMetadata.PTELE, coordinate.z);
trackPoint.setValue(GpxMetadata.PTID, trkptID++);
trackPoint.setValue(GpxMetadata.TRKPT_TRKSEGID, trksegID);
trksegList.add(coordinate);
setCurrentPoint(trackPoint);
}
// Clear content buffer
getContentBuffer().delete(0, getContentBuffer().length());
// Store name of current element in stack
getElementNames().push(qName);
}
|
[
"@",
"Override",
"public",
"void",
"startElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"qName",
",",
"Attributes",
"attributes",
")",
"throws",
"SAXException",
"{",
"if",
"(",
"localName",
".",
"equalsIgnoreCase",
"(",
"GPXTags",
".",
"TRKSEG",
")",
")",
"{",
"segment",
"=",
"true",
";",
"GPXLine",
"trkSegment",
"=",
"new",
"GPXLine",
"(",
"GpxMetadata",
".",
"TRKSEGFIELDCOUNT",
")",
";",
"trkSegment",
".",
"setValue",
"(",
"GpxMetadata",
".",
"LINEID",
",",
"trksegID",
"++",
")",
";",
"trkSegment",
".",
"setValue",
"(",
"GpxMetadata",
".",
"TRKSEG_TRKID",
",",
"getCurrentLine",
"(",
")",
".",
"getValues",
"(",
")",
"[",
"GpxMetadata",
".",
"LINEID",
"]",
")",
";",
"setCurrentSegment",
"(",
"trkSegment",
")",
";",
"trksegList",
".",
"clear",
"(",
")",
";",
"}",
"else",
"if",
"(",
"localName",
".",
"equalsIgnoreCase",
"(",
"GPXTags",
".",
"TRKPT",
")",
")",
"{",
"point",
"=",
"true",
";",
"GPXPoint",
"trackPoint",
"=",
"new",
"GPXPoint",
"(",
"GpxMetadata",
".",
"TRKPTFIELDCOUNT",
")",
";",
"Coordinate",
"coordinate",
"=",
"GPXCoordinate",
".",
"createCoordinate",
"(",
"attributes",
")",
";",
"Point",
"geom",
"=",
"getGeometryFactory",
"(",
")",
".",
"createPoint",
"(",
"coordinate",
")",
";",
"geom",
".",
"setSRID",
"(",
"4326",
")",
";",
"trackPoint",
".",
"setValue",
"(",
"GpxMetadata",
".",
"THE_GEOM",
",",
"geom",
")",
";",
"trackPoint",
".",
"setValue",
"(",
"GpxMetadata",
".",
"PTLAT",
",",
"coordinate",
".",
"y",
")",
";",
"trackPoint",
".",
"setValue",
"(",
"GpxMetadata",
".",
"PTLON",
",",
"coordinate",
".",
"x",
")",
";",
"trackPoint",
".",
"setValue",
"(",
"GpxMetadata",
".",
"PTELE",
",",
"coordinate",
".",
"z",
")",
";",
"trackPoint",
".",
"setValue",
"(",
"GpxMetadata",
".",
"PTID",
",",
"trkptID",
"++",
")",
";",
"trackPoint",
".",
"setValue",
"(",
"GpxMetadata",
".",
"TRKPT_TRKSEGID",
",",
"trksegID",
")",
";",
"trksegList",
".",
"add",
"(",
"coordinate",
")",
";",
"setCurrentPoint",
"(",
"trackPoint",
")",
";",
"}",
"// Clear content buffer",
"getContentBuffer",
"(",
")",
".",
"delete",
"(",
"0",
",",
"getContentBuffer",
"(",
")",
".",
"length",
"(",
")",
")",
";",
"// Store name of current element in stack",
"getElementNames",
"(",
")",
".",
"push",
"(",
"qName",
")",
";",
"}"
] |
Fires whenever an XML start markup is encountered. It creates a new
trackSegment when a <trkseg> markup is encountered. It creates a new
trackPoint when a <trkpt> markup is encountered. It saves informations
about <link> in currentPoint or currentLine.
@param uri URI of the local element
@param localName Name of the local element (without prefix)
@param qName qName of the local element (with prefix)
@param attributes Attributes of the local element (contained in the
markup)
@throws SAXException Any SAX exception, possibly wrapping another
exception
|
[
"Fires",
"whenever",
"an",
"XML",
"start",
"markup",
"is",
"encountered",
".",
"It",
"creates",
"a",
"new",
"trackSegment",
"when",
"a",
"<trkseg",
">",
"markup",
"is",
"encountered",
".",
"It",
"creates",
"a",
"new",
"trackPoint",
"when",
"a",
"<trkpt",
">",
"markup",
"is",
"encountered",
".",
"It",
"saves",
"informations",
"about",
"<link",
">",
"in",
"currentPoint",
"or",
"currentLine",
"."
] |
train
|
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParserTrk.java#L93-L121
|
lesaint/damapping
|
core-parent/util/src/main/java/fr/javatronic/damapping/util/Preconditions.java
|
Preconditions.checkArgument
|
public static void checkArgument(boolean test, @Nullable String message) {
"""
Throws a {@link IllegalArgumentException} with the specified message if the specified boolean
value is false.
<p>
A default message will be used if the specified message is {@code null} or empty.
</p>
@param test a boolean value
@param message a {@link String} or {@code null}
"""
if (!test) {
throw new IllegalArgumentException(message == null || message.isEmpty() ? IAE_DEFAULT_MSG : message);
}
}
|
java
|
public static void checkArgument(boolean test, @Nullable String message) {
if (!test) {
throw new IllegalArgumentException(message == null || message.isEmpty() ? IAE_DEFAULT_MSG : message);
}
}
|
[
"public",
"static",
"void",
"checkArgument",
"(",
"boolean",
"test",
",",
"@",
"Nullable",
"String",
"message",
")",
"{",
"if",
"(",
"!",
"test",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
"==",
"null",
"||",
"message",
".",
"isEmpty",
"(",
")",
"?",
"IAE_DEFAULT_MSG",
":",
"message",
")",
";",
"}",
"}"
] |
Throws a {@link IllegalArgumentException} with the specified message if the specified boolean
value is false.
<p>
A default message will be used if the specified message is {@code null} or empty.
</p>
@param test a boolean value
@param message a {@link String} or {@code null}
|
[
"Throws",
"a",
"{",
"@link",
"IllegalArgumentException",
"}",
"with",
"the",
"specified",
"message",
"if",
"the",
"specified",
"boolean",
"value",
"is",
"false",
".",
"<p",
">",
"A",
"default",
"message",
"will",
"be",
"used",
"if",
"the",
"specified",
"message",
"is",
"{",
"@code",
"null",
"}",
"or",
"empty",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/lesaint/damapping/blob/357afa5866939fd2a18c09213975ffef4836f328/core-parent/util/src/main/java/fr/javatronic/damapping/util/Preconditions.java#L91-L95
|
TheHortonMachine/hortonmachine
|
gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureUtilities.java
|
FeatureUtilities.getAttributeCaseChecked
|
public static Object getAttributeCaseChecked( SimpleFeature feature, String field ) {
"""
Getter for attributes of a feature.
<p>If the attribute is not found, checks are done in non
case sensitive mode.
@param feature the feature from which to get the attribute.
@param field the name of the field.
@return the attribute or null if none found.
"""
Object attribute = feature.getAttribute(field);
if (attribute == null) {
attribute = feature.getAttribute(field.toLowerCase());
if (attribute != null)
return attribute;
attribute = feature.getAttribute(field.toUpperCase());
if (attribute != null)
return attribute;
// alright, last try, search for it
SimpleFeatureType featureType = feature.getFeatureType();
field = findAttributeName(featureType, field);
if (field != null) {
return feature.getAttribute(field);
}
}
return attribute;
}
|
java
|
public static Object getAttributeCaseChecked( SimpleFeature feature, String field ) {
Object attribute = feature.getAttribute(field);
if (attribute == null) {
attribute = feature.getAttribute(field.toLowerCase());
if (attribute != null)
return attribute;
attribute = feature.getAttribute(field.toUpperCase());
if (attribute != null)
return attribute;
// alright, last try, search for it
SimpleFeatureType featureType = feature.getFeatureType();
field = findAttributeName(featureType, field);
if (field != null) {
return feature.getAttribute(field);
}
}
return attribute;
}
|
[
"public",
"static",
"Object",
"getAttributeCaseChecked",
"(",
"SimpleFeature",
"feature",
",",
"String",
"field",
")",
"{",
"Object",
"attribute",
"=",
"feature",
".",
"getAttribute",
"(",
"field",
")",
";",
"if",
"(",
"attribute",
"==",
"null",
")",
"{",
"attribute",
"=",
"feature",
".",
"getAttribute",
"(",
"field",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"attribute",
"!=",
"null",
")",
"return",
"attribute",
";",
"attribute",
"=",
"feature",
".",
"getAttribute",
"(",
"field",
".",
"toUpperCase",
"(",
")",
")",
";",
"if",
"(",
"attribute",
"!=",
"null",
")",
"return",
"attribute",
";",
"// alright, last try, search for it",
"SimpleFeatureType",
"featureType",
"=",
"feature",
".",
"getFeatureType",
"(",
")",
";",
"field",
"=",
"findAttributeName",
"(",
"featureType",
",",
"field",
")",
";",
"if",
"(",
"field",
"!=",
"null",
")",
"{",
"return",
"feature",
".",
"getAttribute",
"(",
"field",
")",
";",
"}",
"}",
"return",
"attribute",
";",
"}"
] |
Getter for attributes of a feature.
<p>If the attribute is not found, checks are done in non
case sensitive mode.
@param feature the feature from which to get the attribute.
@param field the name of the field.
@return the attribute or null if none found.
|
[
"Getter",
"for",
"attributes",
"of",
"a",
"feature",
"."
] |
train
|
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/features/FeatureUtilities.java#L590-L608
|
alibaba/jstorm
|
jstorm-core/src/main/java/backtype/storm/security/auth/AuthUtils.java
|
AuthUtils.populateSubject
|
public static Subject populateSubject(Subject subject, Collection<IAutoCredentials> autos, Map<String, String> credentials) {
"""
Populate a subject from credentials using the IAutoCredentials.
@param subject the subject to populate or null if a new Subject should be created.
@param autos the IAutoCredentials to call to populate the subject.
@param credentials the credentials to pull from
@return the populated subject.
"""
try {
if (subject == null) {
subject = new Subject();
}
for (IAutoCredentials autoCred : autos) {
autoCred.populateSubject(subject, credentials);
}
return subject;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
java
|
public static Subject populateSubject(Subject subject, Collection<IAutoCredentials> autos, Map<String, String> credentials) {
try {
if (subject == null) {
subject = new Subject();
}
for (IAutoCredentials autoCred : autos) {
autoCred.populateSubject(subject, credentials);
}
return subject;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"static",
"Subject",
"populateSubject",
"(",
"Subject",
"subject",
",",
"Collection",
"<",
"IAutoCredentials",
">",
"autos",
",",
"Map",
"<",
"String",
",",
"String",
">",
"credentials",
")",
"{",
"try",
"{",
"if",
"(",
"subject",
"==",
"null",
")",
"{",
"subject",
"=",
"new",
"Subject",
"(",
")",
";",
"}",
"for",
"(",
"IAutoCredentials",
"autoCred",
":",
"autos",
")",
"{",
"autoCred",
".",
"populateSubject",
"(",
"subject",
",",
"credentials",
")",
";",
"}",
"return",
"subject",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Populate a subject from credentials using the IAutoCredentials.
@param subject the subject to populate or null if a new Subject should be created.
@param autos the IAutoCredentials to call to populate the subject.
@param credentials the credentials to pull from
@return the populated subject.
|
[
"Populate",
"a",
"subject",
"from",
"credentials",
"using",
"the",
"IAutoCredentials",
"."
] |
train
|
https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/security/auth/AuthUtils.java#L189-L201
|
ZuInnoTe/hadoopcryptoledger
|
inputformat/src/main/java/org/zuinnote/hadoop/ethereum/format/common/EthereumUtil.java
|
EthereumUtil.decodeRLPElement
|
private static RLPElement decodeRLPElement(ByteBuffer bb) {
"""
/*
Decodes an RLPElement from the given ByteBuffer
@param bb Bytebuffer containing an RLPElement
@return RLPElement in case the byte stream represents a valid RLPElement, null if not
"""
RLPElement result=null;
byte firstByte = bb.get();
int firstByteUnsigned = firstByte & 0xFF;
if (firstByteUnsigned <= 0x7F) {
result=new RLPElement(new byte[] {firstByte},new byte[] {firstByte});
} else if ((firstByteUnsigned>=0x80) && (firstByteUnsigned<=0xb7)) {
// read indicator
byte[] indicator=new byte[]{firstByte};
int noOfBytes = firstByteUnsigned - 0x80;
// read raw data
byte[] rawData = new byte[noOfBytes];
if (noOfBytes > 0) {
bb.get(rawData);
}
result=new RLPElement(indicator,rawData);
} else if ((firstByteUnsigned>=0xb8) && (firstByteUnsigned<=0xbf)) {
// read size of indicator (size of the size)
int NoOfBytesSize = firstByteUnsigned-0xb7;
byte[] indicator = new byte[NoOfBytesSize+1];
indicator[0]=firstByte;
bb.get(indicator, 1, NoOfBytesSize);
long noOfBytes = convertIndicatorToRLPSize(indicator);
// read the data
byte[] rawData=new byte[(int) noOfBytes];
bb.get(rawData);
result= new RLPElement(indicator,rawData);
} else {
result=null;
}
return result;
}
|
java
|
private static RLPElement decodeRLPElement(ByteBuffer bb) {
RLPElement result=null;
byte firstByte = bb.get();
int firstByteUnsigned = firstByte & 0xFF;
if (firstByteUnsigned <= 0x7F) {
result=new RLPElement(new byte[] {firstByte},new byte[] {firstByte});
} else if ((firstByteUnsigned>=0x80) && (firstByteUnsigned<=0xb7)) {
// read indicator
byte[] indicator=new byte[]{firstByte};
int noOfBytes = firstByteUnsigned - 0x80;
// read raw data
byte[] rawData = new byte[noOfBytes];
if (noOfBytes > 0) {
bb.get(rawData);
}
result=new RLPElement(indicator,rawData);
} else if ((firstByteUnsigned>=0xb8) && (firstByteUnsigned<=0xbf)) {
// read size of indicator (size of the size)
int NoOfBytesSize = firstByteUnsigned-0xb7;
byte[] indicator = new byte[NoOfBytesSize+1];
indicator[0]=firstByte;
bb.get(indicator, 1, NoOfBytesSize);
long noOfBytes = convertIndicatorToRLPSize(indicator);
// read the data
byte[] rawData=new byte[(int) noOfBytes];
bb.get(rawData);
result= new RLPElement(indicator,rawData);
} else {
result=null;
}
return result;
}
|
[
"private",
"static",
"RLPElement",
"decodeRLPElement",
"(",
"ByteBuffer",
"bb",
")",
"{",
"RLPElement",
"result",
"=",
"null",
";",
"byte",
"firstByte",
"=",
"bb",
".",
"get",
"(",
")",
";",
"int",
"firstByteUnsigned",
"=",
"firstByte",
"&",
"0xFF",
";",
"if",
"(",
"firstByteUnsigned",
"<=",
"0x7F",
")",
"{",
"result",
"=",
"new",
"RLPElement",
"(",
"new",
"byte",
"[",
"]",
"{",
"firstByte",
"}",
",",
"new",
"byte",
"[",
"]",
"{",
"firstByte",
"}",
")",
";",
"}",
"else",
"if",
"(",
"(",
"firstByteUnsigned",
">=",
"0x80",
")",
"&&",
"(",
"firstByteUnsigned",
"<=",
"0xb7",
")",
")",
"{",
"// read indicator",
"byte",
"[",
"]",
"indicator",
"=",
"new",
"byte",
"[",
"]",
"{",
"firstByte",
"}",
";",
"int",
"noOfBytes",
"=",
"firstByteUnsigned",
"-",
"0x80",
";",
"// read raw data",
"byte",
"[",
"]",
"rawData",
"=",
"new",
"byte",
"[",
"noOfBytes",
"]",
";",
"if",
"(",
"noOfBytes",
">",
"0",
")",
"{",
"bb",
".",
"get",
"(",
"rawData",
")",
";",
"}",
"result",
"=",
"new",
"RLPElement",
"(",
"indicator",
",",
"rawData",
")",
";",
"}",
"else",
"if",
"(",
"(",
"firstByteUnsigned",
">=",
"0xb8",
")",
"&&",
"(",
"firstByteUnsigned",
"<=",
"0xbf",
")",
")",
"{",
"// read size of indicator (size of the size)",
"int",
"NoOfBytesSize",
"=",
"firstByteUnsigned",
"-",
"0xb7",
";",
"byte",
"[",
"]",
"indicator",
"=",
"new",
"byte",
"[",
"NoOfBytesSize",
"+",
"1",
"]",
";",
"indicator",
"[",
"0",
"]",
"=",
"firstByte",
";",
"bb",
".",
"get",
"(",
"indicator",
",",
"1",
",",
"NoOfBytesSize",
")",
";",
"long",
"noOfBytes",
"=",
"convertIndicatorToRLPSize",
"(",
"indicator",
")",
";",
"// read the data",
"byte",
"[",
"]",
"rawData",
"=",
"new",
"byte",
"[",
"(",
"int",
")",
"noOfBytes",
"]",
";",
"bb",
".",
"get",
"(",
"rawData",
")",
";",
"result",
"=",
"new",
"RLPElement",
"(",
"indicator",
",",
"rawData",
")",
";",
"}",
"else",
"{",
"result",
"=",
"null",
";",
"}",
"return",
"result",
";",
"}"
] |
/*
Decodes an RLPElement from the given ByteBuffer
@param bb Bytebuffer containing an RLPElement
@return RLPElement in case the byte stream represents a valid RLPElement, null if not
|
[
"/",
"*",
"Decodes",
"an",
"RLPElement",
"from",
"the",
"given",
"ByteBuffer"
] |
train
|
https://github.com/ZuInnoTe/hadoopcryptoledger/blob/5c9bfb61dd1a82374cd0de8413a7c66391ee4414/inputformat/src/main/java/org/zuinnote/hadoop/ethereum/format/common/EthereumUtil.java#L146-L179
|
statefulj/statefulj
|
statefulj-framework/statefulj-framework-binders/statefulj-framework-binders-common/src/main/java/org/statefulj/framework/binders/common/utils/JavassistUtils.java
|
JavassistUtils.cloneAnnotation
|
public static Annotation cloneAnnotation(ConstPool constPool, java.lang.annotation.Annotation annotation) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
"""
Clone an annotation and all of it's methods
@param constPool
@param annotation
@return
@throws IllegalArgumentException
@throws IllegalAccessException
@throws InvocationTargetException
"""
Class<?> clazz = annotation.annotationType();
Annotation annot = new Annotation(clazz.getName(), constPool);
for(Method method : clazz.getDeclaredMethods()) {
MemberValue memberVal = null;
if (method.getReturnType().isArray()) {
List<MemberValue> memberVals = new LinkedList<MemberValue>();
for(Object val : (Object[])method.invoke(annotation)) {
memberVals.add(createMemberValue(constPool, val));
}
memberVal = new ArrayMemberValue(constPool);
((ArrayMemberValue)memberVal).setValue(memberVals.toArray(new MemberValue[]{}));
} else {
memberVal = createMemberValue(constPool, method.invoke(annotation));
}
annot.addMemberValue(method.getName(), memberVal);
}
return annot;
}
|
java
|
public static Annotation cloneAnnotation(ConstPool constPool, java.lang.annotation.Annotation annotation) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Class<?> clazz = annotation.annotationType();
Annotation annot = new Annotation(clazz.getName(), constPool);
for(Method method : clazz.getDeclaredMethods()) {
MemberValue memberVal = null;
if (method.getReturnType().isArray()) {
List<MemberValue> memberVals = new LinkedList<MemberValue>();
for(Object val : (Object[])method.invoke(annotation)) {
memberVals.add(createMemberValue(constPool, val));
}
memberVal = new ArrayMemberValue(constPool);
((ArrayMemberValue)memberVal).setValue(memberVals.toArray(new MemberValue[]{}));
} else {
memberVal = createMemberValue(constPool, method.invoke(annotation));
}
annot.addMemberValue(method.getName(), memberVal);
}
return annot;
}
|
[
"public",
"static",
"Annotation",
"cloneAnnotation",
"(",
"ConstPool",
"constPool",
",",
"java",
".",
"lang",
".",
"annotation",
".",
"Annotation",
"annotation",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"annotation",
".",
"annotationType",
"(",
")",
";",
"Annotation",
"annot",
"=",
"new",
"Annotation",
"(",
"clazz",
".",
"getName",
"(",
")",
",",
"constPool",
")",
";",
"for",
"(",
"Method",
"method",
":",
"clazz",
".",
"getDeclaredMethods",
"(",
")",
")",
"{",
"MemberValue",
"memberVal",
"=",
"null",
";",
"if",
"(",
"method",
".",
"getReturnType",
"(",
")",
".",
"isArray",
"(",
")",
")",
"{",
"List",
"<",
"MemberValue",
">",
"memberVals",
"=",
"new",
"LinkedList",
"<",
"MemberValue",
">",
"(",
")",
";",
"for",
"(",
"Object",
"val",
":",
"(",
"Object",
"[",
"]",
")",
"method",
".",
"invoke",
"(",
"annotation",
")",
")",
"{",
"memberVals",
".",
"add",
"(",
"createMemberValue",
"(",
"constPool",
",",
"val",
")",
")",
";",
"}",
"memberVal",
"=",
"new",
"ArrayMemberValue",
"(",
"constPool",
")",
";",
"(",
"(",
"ArrayMemberValue",
")",
"memberVal",
")",
".",
"setValue",
"(",
"memberVals",
".",
"toArray",
"(",
"new",
"MemberValue",
"[",
"]",
"{",
"}",
")",
")",
";",
"}",
"else",
"{",
"memberVal",
"=",
"createMemberValue",
"(",
"constPool",
",",
"method",
".",
"invoke",
"(",
"annotation",
")",
")",
";",
"}",
"annot",
".",
"addMemberValue",
"(",
"method",
".",
"getName",
"(",
")",
",",
"memberVal",
")",
";",
"}",
"return",
"annot",
";",
"}"
] |
Clone an annotation and all of it's methods
@param constPool
@param annotation
@return
@throws IllegalArgumentException
@throws IllegalAccessException
@throws InvocationTargetException
|
[
"Clone",
"an",
"annotation",
"and",
"all",
"of",
"it",
"s",
"methods"
] |
train
|
https://github.com/statefulj/statefulj/blob/d3459b3cb12bd508643027743401484a231e5fa1/statefulj-framework/statefulj-framework-binders/statefulj-framework-binders-common/src/main/java/org/statefulj/framework/binders/common/utils/JavassistUtils.java#L94-L114
|
hypercube1024/firefly
|
firefly/src/main/java/com/firefly/codec/http2/model/HttpFields.java
|
HttpFields.put
|
public void put(HttpHeader header, String value) {
"""
Set a field.
@param header the header name of the field
@param value the value of the field. If null the field is cleared.
"""
if (value == null)
remove(header);
else
put(new HttpField(header, value));
}
|
java
|
public void put(HttpHeader header, String value) {
if (value == null)
remove(header);
else
put(new HttpField(header, value));
}
|
[
"public",
"void",
"put",
"(",
"HttpHeader",
"header",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"remove",
"(",
"header",
")",
";",
"else",
"put",
"(",
"new",
"HttpField",
"(",
"header",
",",
"value",
")",
")",
";",
"}"
] |
Set a field.
@param header the header name of the field
@param value the value of the field. If null the field is cleared.
|
[
"Set",
"a",
"field",
"."
] |
train
|
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/HttpFields.java#L519-L524
|
jferard/fastods
|
fastods/src/main/java/com/github/jferard/fastods/datastyle/NumberStyleHelper.java
|
NumberStyleHelper.appendStyleMap
|
private void appendStyleMap(final XMLUtil util, final Appendable appendable) throws IOException {
"""
Appends 16.3 style:map tag.
@param util XML util for escaping
@param appendable where to write
@throws IOException If an I/O error occurs
"""
appendable.append("<style:map");
util.appendEAttribute(appendable, "style:condition", "value()>=0");
util.appendEAttribute(appendable, "style:apply-style-name", this.dataStyle.getName());
appendable.append("/>");
}
|
java
|
private void appendStyleMap(final XMLUtil util, final Appendable appendable) throws IOException {
appendable.append("<style:map");
util.appendEAttribute(appendable, "style:condition", "value()>=0");
util.appendEAttribute(appendable, "style:apply-style-name", this.dataStyle.getName());
appendable.append("/>");
}
|
[
"private",
"void",
"appendStyleMap",
"(",
"final",
"XMLUtil",
"util",
",",
"final",
"Appendable",
"appendable",
")",
"throws",
"IOException",
"{",
"appendable",
".",
"append",
"(",
"\"<style:map\"",
")",
";",
"util",
".",
"appendEAttribute",
"(",
"appendable",
",",
"\"style:condition\"",
",",
"\"value()>=0\"",
")",
";",
"util",
".",
"appendEAttribute",
"(",
"appendable",
",",
"\"style:apply-style-name\"",
",",
"this",
".",
"dataStyle",
".",
"getName",
"(",
")",
")",
";",
"appendable",
".",
"append",
"(",
"\"/>\"",
")",
";",
"}"
] |
Appends 16.3 style:map tag.
@param util XML util for escaping
@param appendable where to write
@throws IOException If an I/O error occurs
|
[
"Appends",
"16",
".",
"3",
"style",
":",
"map",
"tag",
"."
] |
train
|
https://github.com/jferard/fastods/blob/a034d173083ffa602dc525699b97f753082eaef9/fastods/src/main/java/com/github/jferard/fastods/datastyle/NumberStyleHelper.java#L144-L149
|
camunda/camunda-bpm-platform
|
engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/parser/BpmnParse.java
|
BpmnParse.setErrorMessageVariableOnErrorEventDefinition
|
protected void setErrorMessageVariableOnErrorEventDefinition(Element errorEventDefinition, ErrorEventDefinition definition) {
"""
Sets the value for "camunda:errorMessageVariable" on the passed definition if
it's present.
@param errorEventDefinition
the XML errorEventDefinition tag
@param definition
the errorEventDefintion that can get the errorMessageVariable value
"""
String errorMessageVariable = errorEventDefinition.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "errorMessageVariable");
if (errorMessageVariable != null) {
definition.setErrorMessageVariable(errorMessageVariable);
}
}
|
java
|
protected void setErrorMessageVariableOnErrorEventDefinition(Element errorEventDefinition, ErrorEventDefinition definition) {
String errorMessageVariable = errorEventDefinition.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "errorMessageVariable");
if (errorMessageVariable != null) {
definition.setErrorMessageVariable(errorMessageVariable);
}
}
|
[
"protected",
"void",
"setErrorMessageVariableOnErrorEventDefinition",
"(",
"Element",
"errorEventDefinition",
",",
"ErrorEventDefinition",
"definition",
")",
"{",
"String",
"errorMessageVariable",
"=",
"errorEventDefinition",
".",
"attributeNS",
"(",
"CAMUNDA_BPMN_EXTENSIONS_NS",
",",
"\"errorMessageVariable\"",
")",
";",
"if",
"(",
"errorMessageVariable",
"!=",
"null",
")",
"{",
"definition",
".",
"setErrorMessageVariable",
"(",
"errorMessageVariable",
")",
";",
"}",
"}"
] |
Sets the value for "camunda:errorMessageVariable" on the passed definition if
it's present.
@param errorEventDefinition
the XML errorEventDefinition tag
@param definition
the errorEventDefintion that can get the errorMessageVariable value
|
[
"Sets",
"the",
"value",
"for",
"camunda",
":",
"errorMessageVariable",
"on",
"the",
"passed",
"definition",
"if",
"it",
"s",
"present",
"."
] |
train
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/parser/BpmnParse.java#L1138-L1143
|
facebookarchive/hadoop-20
|
src/examples/org/apache/hadoop/examples/dancing/DancingLinks.java
|
DancingLinks.solve
|
public int solve(int[] prefix, SolutionAcceptor<ColumnName> output) {
"""
Given a prefix, find solutions under it.
@param prefix a list of row choices that control which part of the search
tree to explore
@param output the output for each solution
@return the number of solutions
"""
List<Node<ColumnName>> choices = new ArrayList<Node<ColumnName>>();
for(int i=0; i < prefix.length; ++i) {
choices.add(advance(prefix[i]));
}
int result = search(choices, output);
for(int i=prefix.length-1; i >=0; --i) {
rollback(choices.get(i));
}
return result;
}
|
java
|
public int solve(int[] prefix, SolutionAcceptor<ColumnName> output) {
List<Node<ColumnName>> choices = new ArrayList<Node<ColumnName>>();
for(int i=0; i < prefix.length; ++i) {
choices.add(advance(prefix[i]));
}
int result = search(choices, output);
for(int i=prefix.length-1; i >=0; --i) {
rollback(choices.get(i));
}
return result;
}
|
[
"public",
"int",
"solve",
"(",
"int",
"[",
"]",
"prefix",
",",
"SolutionAcceptor",
"<",
"ColumnName",
">",
"output",
")",
"{",
"List",
"<",
"Node",
"<",
"ColumnName",
">>",
"choices",
"=",
"new",
"ArrayList",
"<",
"Node",
"<",
"ColumnName",
">",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"prefix",
".",
"length",
";",
"++",
"i",
")",
"{",
"choices",
".",
"add",
"(",
"advance",
"(",
"prefix",
"[",
"i",
"]",
")",
")",
";",
"}",
"int",
"result",
"=",
"search",
"(",
"choices",
",",
"output",
")",
";",
"for",
"(",
"int",
"i",
"=",
"prefix",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"--",
"i",
")",
"{",
"rollback",
"(",
"choices",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Given a prefix, find solutions under it.
@param prefix a list of row choices that control which part of the search
tree to explore
@param output the output for each solution
@return the number of solutions
|
[
"Given",
"a",
"prefix",
"find",
"solutions",
"under",
"it",
"."
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/examples/org/apache/hadoop/examples/dancing/DancingLinks.java#L417-L427
|
gallandarakhneorg/afc
|
core/vmutils/src/main/java/org/arakhne/afc/vmutil/Android.java
|
Android.initialize
|
public static void initialize(Object androidContext) throws AndroidException {
"""
Extract informations from the current {@code Context} of the android task.
@param androidContext is the Android {@code Context}.
@throws AndroidException when the information cannot be extracted.
"""
assert androidContext != null;
try {
final Class<?> contextType = androidContext.getClass();
final Class<?> contextClass = getContextClass();
if (!contextClass.isAssignableFrom(contextType)) {
throw new AndroidException(Locale.getString("E1", androidContext)); //$NON-NLS-1$
}
synchronized (Android.class) {
contextResolver = null;
context = new SoftReference<>(androidContext);
}
} catch (AssertionError e) {
throw e;
} catch (Throwable e) {
throw new AndroidException(e);
}
ClassLoaderFinder.setPreferredClassLoader(getContextClassLoader());
}
|
java
|
public static void initialize(Object androidContext) throws AndroidException {
assert androidContext != null;
try {
final Class<?> contextType = androidContext.getClass();
final Class<?> contextClass = getContextClass();
if (!contextClass.isAssignableFrom(contextType)) {
throw new AndroidException(Locale.getString("E1", androidContext)); //$NON-NLS-1$
}
synchronized (Android.class) {
contextResolver = null;
context = new SoftReference<>(androidContext);
}
} catch (AssertionError e) {
throw e;
} catch (Throwable e) {
throw new AndroidException(e);
}
ClassLoaderFinder.setPreferredClassLoader(getContextClassLoader());
}
|
[
"public",
"static",
"void",
"initialize",
"(",
"Object",
"androidContext",
")",
"throws",
"AndroidException",
"{",
"assert",
"androidContext",
"!=",
"null",
";",
"try",
"{",
"final",
"Class",
"<",
"?",
">",
"contextType",
"=",
"androidContext",
".",
"getClass",
"(",
")",
";",
"final",
"Class",
"<",
"?",
">",
"contextClass",
"=",
"getContextClass",
"(",
")",
";",
"if",
"(",
"!",
"contextClass",
".",
"isAssignableFrom",
"(",
"contextType",
")",
")",
"{",
"throw",
"new",
"AndroidException",
"(",
"Locale",
".",
"getString",
"(",
"\"E1\"",
",",
"androidContext",
")",
")",
";",
"//$NON-NLS-1$",
"}",
"synchronized",
"(",
"Android",
".",
"class",
")",
"{",
"contextResolver",
"=",
"null",
";",
"context",
"=",
"new",
"SoftReference",
"<>",
"(",
"androidContext",
")",
";",
"}",
"}",
"catch",
"(",
"AssertionError",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"throw",
"new",
"AndroidException",
"(",
"e",
")",
";",
"}",
"ClassLoaderFinder",
".",
"setPreferredClassLoader",
"(",
"getContextClassLoader",
"(",
")",
")",
";",
"}"
] |
Extract informations from the current {@code Context} of the android task.
@param androidContext is the Android {@code Context}.
@throws AndroidException when the information cannot be extracted.
|
[
"Extract",
"informations",
"from",
"the",
"current",
"{",
"@code",
"Context",
"}",
"of",
"the",
"android",
"task",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/Android.java#L167-L185
|
lessthanoptimal/ejml
|
main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java
|
CommonOps_DDRM.changeSign
|
public static void changeSign(DMatrixD1 input , DMatrixD1 output) {
"""
<p>
Changes the sign of every element in the matrix.<br>
<br>
output<sub>ij</sub> = -input<sub>ij</sub>
</p>
@param input A matrix. Modified.
"""
output.reshape(input.numRows,input.numCols);
final int size = input.getNumElements();
for( int i = 0; i < size; i++ ) {
output.data[i] = -input.data[i];
}
}
|
java
|
public static void changeSign(DMatrixD1 input , DMatrixD1 output)
{
output.reshape(input.numRows,input.numCols);
final int size = input.getNumElements();
for( int i = 0; i < size; i++ ) {
output.data[i] = -input.data[i];
}
}
|
[
"public",
"static",
"void",
"changeSign",
"(",
"DMatrixD1",
"input",
",",
"DMatrixD1",
"output",
")",
"{",
"output",
".",
"reshape",
"(",
"input",
".",
"numRows",
",",
"input",
".",
"numCols",
")",
";",
"final",
"int",
"size",
"=",
"input",
".",
"getNumElements",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"output",
".",
"data",
"[",
"i",
"]",
"=",
"-",
"input",
".",
"data",
"[",
"i",
"]",
";",
"}",
"}"
] |
<p>
Changes the sign of every element in the matrix.<br>
<br>
output<sub>ij</sub> = -input<sub>ij</sub>
</p>
@param input A matrix. Modified.
|
[
"<p",
">",
"Changes",
"the",
"sign",
"of",
"every",
"element",
"in",
"the",
"matrix",
".",
"<br",
">",
"<br",
">",
"output<sub",
">",
"ij<",
"/",
"sub",
">",
"=",
"-",
"input<sub",
">",
"ij<",
"/",
"sub",
">",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java#L2528-L2537
|
tzaeschke/zoodb
|
src/org/zoodb/internal/client/SchemaManager.java
|
SchemaManager.locateClassDefinition
|
private ZooClassDef locateClassDefinition(Class<?> cls, Node node) {
"""
Checks class and disk for class definition.
@param cls
@param node
@return Class definition, may return null if no definition is found.
"""
ZooClassDef def = cache.getSchema(cls, node);
if (def == null || def.jdoZooIsDeleted()) {
return null;
}
return def;
}
|
java
|
private ZooClassDef locateClassDefinition(Class<?> cls, Node node) {
ZooClassDef def = cache.getSchema(cls, node);
if (def == null || def.jdoZooIsDeleted()) {
return null;
}
return def;
}
|
[
"private",
"ZooClassDef",
"locateClassDefinition",
"(",
"Class",
"<",
"?",
">",
"cls",
",",
"Node",
"node",
")",
"{",
"ZooClassDef",
"def",
"=",
"cache",
".",
"getSchema",
"(",
"cls",
",",
"node",
")",
";",
"if",
"(",
"def",
"==",
"null",
"||",
"def",
".",
"jdoZooIsDeleted",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"def",
";",
"}"
] |
Checks class and disk for class definition.
@param cls
@param node
@return Class definition, may return null if no definition is found.
|
[
"Checks",
"class",
"and",
"disk",
"for",
"class",
"definition",
"."
] |
train
|
https://github.com/tzaeschke/zoodb/blob/058d0ff161a8ee9d53244c433aca97ee9c654410/src/org/zoodb/internal/client/SchemaManager.java#L82-L88
|
alkacon/opencms-core
|
src-gwt/org/opencms/acacia/client/CmsAttributeHandler.java
|
CmsAttributeHandler.removeAttributeValueAndReturnPrevParent
|
public Panel removeAttributeValueAndReturnPrevParent(int valueIndex, boolean force) {
"""
Removes the attribute value (and corresponding widget) with the given index, and returns
the parent widget.<p>
@param valueIndex the value index
@param force <code>true</code> if the widget should be removed even if it is the last one
@return the parent widget
"""
if (m_attributeValueViews.size() > valueIndex) {
CmsAttributeValueView view = m_attributeValueViews.get(valueIndex);
Panel result = (Panel)view.getParent();
removeAttributeValue(view, force);
return result;
}
return null;
}
|
java
|
public Panel removeAttributeValueAndReturnPrevParent(int valueIndex, boolean force) {
if (m_attributeValueViews.size() > valueIndex) {
CmsAttributeValueView view = m_attributeValueViews.get(valueIndex);
Panel result = (Panel)view.getParent();
removeAttributeValue(view, force);
return result;
}
return null;
}
|
[
"public",
"Panel",
"removeAttributeValueAndReturnPrevParent",
"(",
"int",
"valueIndex",
",",
"boolean",
"force",
")",
"{",
"if",
"(",
"m_attributeValueViews",
".",
"size",
"(",
")",
">",
"valueIndex",
")",
"{",
"CmsAttributeValueView",
"view",
"=",
"m_attributeValueViews",
".",
"get",
"(",
"valueIndex",
")",
";",
"Panel",
"result",
"=",
"(",
"Panel",
")",
"view",
".",
"getParent",
"(",
")",
";",
"removeAttributeValue",
"(",
"view",
",",
"force",
")",
";",
"return",
"result",
";",
"}",
"return",
"null",
";",
"}"
] |
Removes the attribute value (and corresponding widget) with the given index, and returns
the parent widget.<p>
@param valueIndex the value index
@param force <code>true</code> if the widget should be removed even if it is the last one
@return the parent widget
|
[
"Removes",
"the",
"attribute",
"value",
"(",
"and",
"corresponding",
"widget",
")",
"with",
"the",
"given",
"index",
"and",
"returns",
"the",
"parent",
"widget",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/CmsAttributeHandler.java#L921-L931
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/builder/EqualsBuilder.java
|
EqualsBuilder.reflectionEquals
|
public static boolean reflectionEquals(final Object lhs, final Object rhs, final Collection<String> excludeFields) {
"""
<p>This method uses reflection to determine if the two <code>Object</code>s
are equal.</p>
<p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private
fields. This means that it will throw a security exception if run under
a security manager, if the permissions are not set up correctly. It is also
not as efficient as testing explicitly. Non-primitive fields are compared using
<code>equals()</code>.</p>
<p>Transient members will be not be tested, as they are likely derived
fields, and not part of the value of the Object.</p>
<p>Static fields will not be tested. Superclass fields will be included.</p>
@param lhs <code>this</code> object
@param rhs the other object
@param excludeFields Collection of String field names to exclude from testing
@return <code>true</code> if the two Objects have tested equals.
"""
return reflectionEquals(lhs, rhs, ArrayUtil.toArray(excludeFields, String.class));
}
|
java
|
public static boolean reflectionEquals(final Object lhs, final Object rhs, final Collection<String> excludeFields) {
return reflectionEquals(lhs, rhs, ArrayUtil.toArray(excludeFields, String.class));
}
|
[
"public",
"static",
"boolean",
"reflectionEquals",
"(",
"final",
"Object",
"lhs",
",",
"final",
"Object",
"rhs",
",",
"final",
"Collection",
"<",
"String",
">",
"excludeFields",
")",
"{",
"return",
"reflectionEquals",
"(",
"lhs",
",",
"rhs",
",",
"ArrayUtil",
".",
"toArray",
"(",
"excludeFields",
",",
"String",
".",
"class",
")",
")",
";",
"}"
] |
<p>This method uses reflection to determine if the two <code>Object</code>s
are equal.</p>
<p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private
fields. This means that it will throw a security exception if run under
a security manager, if the permissions are not set up correctly. It is also
not as efficient as testing explicitly. Non-primitive fields are compared using
<code>equals()</code>.</p>
<p>Transient members will be not be tested, as they are likely derived
fields, and not part of the value of the Object.</p>
<p>Static fields will not be tested. Superclass fields will be included.</p>
@param lhs <code>this</code> object
@param rhs the other object
@param excludeFields Collection of String field names to exclude from testing
@return <code>true</code> if the two Objects have tested equals.
|
[
"<p",
">",
"This",
"method",
"uses",
"reflection",
"to",
"determine",
"if",
"the",
"two",
"<code",
">",
"Object<",
"/",
"code",
">",
"s",
"are",
"equal",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/builder/EqualsBuilder.java#L233-L235
|
googleapis/google-cloud-java
|
google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/InsertAllRequest.java
|
InsertAllRequest.newBuilder
|
public static Builder newBuilder(TableId table, Iterable<RowToInsert> rows) {
"""
Returns a builder for an {@code InsertAllRequest} object given the destination table and the
rows to insert.
"""
return newBuilder(table).setRows(rows);
}
|
java
|
public static Builder newBuilder(TableId table, Iterable<RowToInsert> rows) {
return newBuilder(table).setRows(rows);
}
|
[
"public",
"static",
"Builder",
"newBuilder",
"(",
"TableId",
"table",
",",
"Iterable",
"<",
"RowToInsert",
">",
"rows",
")",
"{",
"return",
"newBuilder",
"(",
"table",
")",
".",
"setRows",
"(",
"rows",
")",
";",
"}"
] |
Returns a builder for an {@code InsertAllRequest} object given the destination table and the
rows to insert.
|
[
"Returns",
"a",
"builder",
"for",
"an",
"{"
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/InsertAllRequest.java#L343-L345
|
marklogic/marklogic-sesame
|
marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java
|
MarkLogicRepositoryConnection.removeWithoutCommit
|
@Override
protected void removeWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts) throws RepositoryException {
"""
remove without commit
supplied to honor interface
@param subject
@param predicate
@param object
@param contexts
@throws RepositoryException
"""
remove(subject, predicate, object, contexts);
}
|
java
|
@Override
protected void removeWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts) throws RepositoryException {
remove(subject, predicate, object, contexts);
}
|
[
"@",
"Override",
"protected",
"void",
"removeWithoutCommit",
"(",
"Resource",
"subject",
",",
"URI",
"predicate",
",",
"Value",
"object",
",",
"Resource",
"...",
"contexts",
")",
"throws",
"RepositoryException",
"{",
"remove",
"(",
"subject",
",",
"predicate",
",",
"object",
",",
"contexts",
")",
";",
"}"
] |
remove without commit
supplied to honor interface
@param subject
@param predicate
@param object
@param contexts
@throws RepositoryException
|
[
"remove",
"without",
"commit"
] |
train
|
https://github.com/marklogic/marklogic-sesame/blob/d5b668ed2b3d5e90c9f1d5096012813c272062a2/marklogic-sesame/src/main/java/com/marklogic/semantics/sesame/MarkLogicRepositoryConnection.java#L1220-L1223
|
jingwei/krati
|
krati-main/src/retention/java/krati/retention/SimplePosition.java
|
SimplePosition.parsePosition
|
public static SimplePosition parsePosition(String s) {
"""
Parses a string representation of <tt>SimplePosition</tt> in the form of <tt>Id:Offset:Index:Clock</tt>.
<p>
For example, <tt>1:128956235:59272:12789234:12789257:12789305</tt> defines a position with <tt>Id=1</tt>,
<tt>Offset=128956235</tt>, <tt>Index=59272</tt> and <tt>Clock=12789234:12789257:12789305</tt>.
@param s - the string representation of a position.
@throws <tt>NullPointerException</tt> if the string <tt>s</tt> is null.
@throws <tt>NumberFormatException</tt> if the string <tt>s</tt> contains non-parsable <tt>int</tt> or <tt>long</tt>.
"""
String[] parts = s.split(":");
int id = Integer.parseInt(parts[0]);
long offset = Long.parseLong(parts[1]);
int index = Integer.parseInt(parts[2]);
if(parts.length == 3) {
return new SimplePosition(id, offset, index, Clock.ZERO);
}
long[] values = new long[parts.length - 3];
for(int i = 0; i < values.length; i++) {
values[i] = Long.parseLong(parts[3+i]);
}
return new SimplePosition(id, offset, index, new Clock(values));
}
|
java
|
public static SimplePosition parsePosition(String s) {
String[] parts = s.split(":");
int id = Integer.parseInt(parts[0]);
long offset = Long.parseLong(parts[1]);
int index = Integer.parseInt(parts[2]);
if(parts.length == 3) {
return new SimplePosition(id, offset, index, Clock.ZERO);
}
long[] values = new long[parts.length - 3];
for(int i = 0; i < values.length; i++) {
values[i] = Long.parseLong(parts[3+i]);
}
return new SimplePosition(id, offset, index, new Clock(values));
}
|
[
"public",
"static",
"SimplePosition",
"parsePosition",
"(",
"String",
"s",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"s",
".",
"split",
"(",
"\":\"",
")",
";",
"int",
"id",
"=",
"Integer",
".",
"parseInt",
"(",
"parts",
"[",
"0",
"]",
")",
";",
"long",
"offset",
"=",
"Long",
".",
"parseLong",
"(",
"parts",
"[",
"1",
"]",
")",
";",
"int",
"index",
"=",
"Integer",
".",
"parseInt",
"(",
"parts",
"[",
"2",
"]",
")",
";",
"if",
"(",
"parts",
".",
"length",
"==",
"3",
")",
"{",
"return",
"new",
"SimplePosition",
"(",
"id",
",",
"offset",
",",
"index",
",",
"Clock",
".",
"ZERO",
")",
";",
"}",
"long",
"[",
"]",
"values",
"=",
"new",
"long",
"[",
"parts",
".",
"length",
"-",
"3",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"values",
"[",
"i",
"]",
"=",
"Long",
".",
"parseLong",
"(",
"parts",
"[",
"3",
"+",
"i",
"]",
")",
";",
"}",
"return",
"new",
"SimplePosition",
"(",
"id",
",",
"offset",
",",
"index",
",",
"new",
"Clock",
"(",
"values",
")",
")",
";",
"}"
] |
Parses a string representation of <tt>SimplePosition</tt> in the form of <tt>Id:Offset:Index:Clock</tt>.
<p>
For example, <tt>1:128956235:59272:12789234:12789257:12789305</tt> defines a position with <tt>Id=1</tt>,
<tt>Offset=128956235</tt>, <tt>Index=59272</tt> and <tt>Clock=12789234:12789257:12789305</tt>.
@param s - the string representation of a position.
@throws <tt>NullPointerException</tt> if the string <tt>s</tt> is null.
@throws <tt>NumberFormatException</tt> if the string <tt>s</tt> contains non-parsable <tt>int</tt> or <tt>long</tt>.
|
[
"Parses",
"a",
"string",
"representation",
"of",
"<tt",
">",
"SimplePosition<",
"/",
"tt",
">",
"in",
"the",
"form",
"of",
"<tt",
">",
"Id",
":",
"Offset",
":",
"Index",
":",
"Clock<",
"/",
"tt",
">",
"."
] |
train
|
https://github.com/jingwei/krati/blob/1ca0f994a7b0c8215b827eac9aaf95789ec08d21/krati-main/src/retention/java/krati/retention/SimplePosition.java#L130-L146
|
kuali/ojb-1.0.4
|
src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
|
SqlQueryStatement.createTableAlias
|
private TableAlias createTableAlias(String table, String path) {
"""
Create new TableAlias for path
@param table the table name
@param path the path from the target table of the query to this TableAlias.
"""
TableAlias alias;
if (table == null)
{
getLogger().warn("Creating TableAlias without table for path: " + path);
}
String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++; // + m_pathToAlias.size();
alias = new TableAlias(table, aliasName);
setTableAliasForPath(path, null, alias);
m_logger.debug("createTableAlias2: path: " + path + " tableAlias: " + alias);
return alias;
}
|
java
|
private TableAlias createTableAlias(String table, String path)
{
TableAlias alias;
if (table == null)
{
getLogger().warn("Creating TableAlias without table for path: " + path);
}
String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++; // + m_pathToAlias.size();
alias = new TableAlias(table, aliasName);
setTableAliasForPath(path, null, alias);
m_logger.debug("createTableAlias2: path: " + path + " tableAlias: " + alias);
return alias;
}
|
[
"private",
"TableAlias",
"createTableAlias",
"(",
"String",
"table",
",",
"String",
"path",
")",
"{",
"TableAlias",
"alias",
";",
"if",
"(",
"table",
"==",
"null",
")",
"{",
"getLogger",
"(",
")",
".",
"warn",
"(",
"\"Creating TableAlias without table for path: \"",
"+",
"path",
")",
";",
"}",
"String",
"aliasName",
"=",
"String",
".",
"valueOf",
"(",
"getAliasChar",
"(",
")",
")",
"+",
"m_aliasCount",
"++",
";",
"// + m_pathToAlias.size();\r",
"alias",
"=",
"new",
"TableAlias",
"(",
"table",
",",
"aliasName",
")",
";",
"setTableAliasForPath",
"(",
"path",
",",
"null",
",",
"alias",
")",
";",
"m_logger",
".",
"debug",
"(",
"\"createTableAlias2: path: \"",
"+",
"path",
"+",
"\" tableAlias: \"",
"+",
"alias",
")",
";",
"return",
"alias",
";",
"}"
] |
Create new TableAlias for path
@param table the table name
@param path the path from the target table of the query to this TableAlias.
|
[
"Create",
"new",
"TableAlias",
"for",
"path"
] |
train
|
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L1336-L1351
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/bean/BeanUtil.java
|
BeanUtil.fillBean
|
public static <T> T fillBean(T bean, ValueProvider<String> valueProvider, CopyOptions copyOptions) {
"""
填充Bean的核心方法
@param <T> Bean类型
@param bean Bean
@param valueProvider 值提供者
@param copyOptions 拷贝选项,见 {@link CopyOptions}
@return Bean
"""
if (null == valueProvider) {
return bean;
}
return BeanCopier.create(valueProvider, bean, copyOptions).copy();
}
|
java
|
public static <T> T fillBean(T bean, ValueProvider<String> valueProvider, CopyOptions copyOptions) {
if (null == valueProvider) {
return bean;
}
return BeanCopier.create(valueProvider, bean, copyOptions).copy();
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"fillBean",
"(",
"T",
"bean",
",",
"ValueProvider",
"<",
"String",
">",
"valueProvider",
",",
"CopyOptions",
"copyOptions",
")",
"{",
"if",
"(",
"null",
"==",
"valueProvider",
")",
"{",
"return",
"bean",
";",
"}",
"return",
"BeanCopier",
".",
"create",
"(",
"valueProvider",
",",
"bean",
",",
"copyOptions",
")",
".",
"copy",
"(",
")",
";",
"}"
] |
填充Bean的核心方法
@param <T> Bean类型
@param bean Bean
@param valueProvider 值提供者
@param copyOptions 拷贝选项,见 {@link CopyOptions}
@return Bean
|
[
"填充Bean的核心方法"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/bean/BeanUtil.java#L470-L476
|
alkacon/opencms-core
|
src-gwt/org/opencms/ade/containerpage/client/ui/groupeditor/CmsGroupContainerEditor.java
|
CmsGroupContainerEditor.breakUpContainer
|
protected void breakUpContainer() {
"""
Breaks up the group container inserting it's elements into the parent container instead.<p>
"""
final List<CmsContainerElement> elements = getElements();
if (elements.isEmpty()) {
closeDialog(true);
getController().setPageChanged();
return;
}
Set<String> elementIds = new HashSet<String>();
for (CmsContainerElement element : elements) {
elementIds.add(element.getClientId());
}
I_CmsSimpleCallback<Map<String, CmsContainerElementData>> callback = new I_CmsSimpleCallback<Map<String, CmsContainerElementData>>() {
public void execute(Map<String, CmsContainerElementData> elementsData) {
breakUpContainer(elements, elementsData);
}
};
getController().getElements(elementIds, callback);
}
|
java
|
protected void breakUpContainer() {
final List<CmsContainerElement> elements = getElements();
if (elements.isEmpty()) {
closeDialog(true);
getController().setPageChanged();
return;
}
Set<String> elementIds = new HashSet<String>();
for (CmsContainerElement element : elements) {
elementIds.add(element.getClientId());
}
I_CmsSimpleCallback<Map<String, CmsContainerElementData>> callback = new I_CmsSimpleCallback<Map<String, CmsContainerElementData>>() {
public void execute(Map<String, CmsContainerElementData> elementsData) {
breakUpContainer(elements, elementsData);
}
};
getController().getElements(elementIds, callback);
}
|
[
"protected",
"void",
"breakUpContainer",
"(",
")",
"{",
"final",
"List",
"<",
"CmsContainerElement",
">",
"elements",
"=",
"getElements",
"(",
")",
";",
"if",
"(",
"elements",
".",
"isEmpty",
"(",
")",
")",
"{",
"closeDialog",
"(",
"true",
")",
";",
"getController",
"(",
")",
".",
"setPageChanged",
"(",
")",
";",
"return",
";",
"}",
"Set",
"<",
"String",
">",
"elementIds",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"CmsContainerElement",
"element",
":",
"elements",
")",
"{",
"elementIds",
".",
"add",
"(",
"element",
".",
"getClientId",
"(",
")",
")",
";",
"}",
"I_CmsSimpleCallback",
"<",
"Map",
"<",
"String",
",",
"CmsContainerElementData",
">",
">",
"callback",
"=",
"new",
"I_CmsSimpleCallback",
"<",
"Map",
"<",
"String",
",",
"CmsContainerElementData",
">",
">",
"(",
")",
"{",
"public",
"void",
"execute",
"(",
"Map",
"<",
"String",
",",
"CmsContainerElementData",
">",
"elementsData",
")",
"{",
"breakUpContainer",
"(",
"elements",
",",
"elementsData",
")",
";",
"}",
"}",
";",
"getController",
"(",
")",
".",
"getElements",
"(",
"elementIds",
",",
"callback",
")",
";",
"}"
] |
Breaks up the group container inserting it's elements into the parent container instead.<p>
|
[
"Breaks",
"up",
"the",
"group",
"container",
"inserting",
"it",
"s",
"elements",
"into",
"the",
"parent",
"container",
"instead",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/containerpage/client/ui/groupeditor/CmsGroupContainerEditor.java#L219-L239
|
i-net-software/jlessc
|
src/com/inet/lib/less/CustomFunctions.java
|
CustomFunctions.colorizeImage
|
static void colorizeImage( CssFormatter formatter, List<Expression> parameters ) throws IOException {
"""
Colorize an image and inline it as base64.
@param formatter current formatter
@param parameters the parameters (relativeURL, url, main_color, contrast_color)
@throws IOException if any I/O error occur
@throws LessException if parameter list is wrong
"""
if( parameters.size() < 4 ) {
throw new LessException( "error evaluating function colorize-image expects url, main_color, contrast_color " );
}
String relativeURL = parameters.get( 0 ).stringValue( formatter );
String urlString = parameters.get( 1 ).stringValue( formatter );
URL url = new URL( formatter.getBaseURL(), relativeURL );
String urlStr = UrlUtils.removeQuote( urlString );
url = new URL( url, urlStr );
int mainColor = ColorUtils.argb( UrlUtils.getColor( parameters.get( 2 ), formatter ) );
int contrastColor = ColorUtils.argb( UrlUtils.getColor( parameters.get( 3 ), formatter ) );
BufferedImage loadedImage = ImageIO.read( url.openStream() );
// convert the image in a standard color model
int width = loadedImage.getWidth( null );
int height = loadedImage.getHeight( null );
BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB );
Graphics2D bGr = image.createGraphics();
bGr.drawImage( loadedImage, 0, 0, null );
bGr.dispose();
final float[] mainColorHsb = Color.RGBtoHSB( (mainColor >> 16) & 0xFF, (mainColor >> 8) & 0xFF, mainColor & 0xFF, null );
final float[] contrastColorHsb = Color.RGBtoHSB( (contrastColor >> 16) & 0xFF, (contrastColor >> 8) & 0xFF, contrastColor & 0xFF, null );
// get the pixel data
WritableRaster raster = image.getRaster();
DataBufferInt buffer = (DataBufferInt)raster.getDataBuffer();
int[] data = buffer.getData();
float[] hsb = new float[3];
int hsbColor = 0;
int lastRgb = data[0] + 1;
for( int i = 0; i < data.length; i++ ) {
int rgb = data[i];
if( rgb == lastRgb ) {
data[i] = hsbColor;
continue;
}
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
int b = rgb & 0xFF;
Color.RGBtoHSB( r, g, b, hsb );
float[] hsbColorize;
if( hsb[1] == 1.0f ) {
hsbColorize = hsb;
hsb[0] = hsb[0] * 3f / 4f + mainColorHsb[0] / 4f;
hsb[1] = hsb[1] * 3f / 4f + mainColorHsb[1] / 4f;
hsb[2] = hsb[2] * 3f / 4f + mainColorHsb[2] / 4f;
} else {
if( hsb[2] == 1.0f ) {
hsbColorize = contrastColorHsb;
} else {
hsbColorize = mainColorHsb;
}
}
lastRgb = rgb;
hsbColor = Color.HSBtoRGB( hsbColorize[0], hsbColorize[1], hsbColorize[2] );
hsbColor = (rgb & 0xFF000000) | (hsbColor & 0xFFFFFF);
data[i] = hsbColor;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write( image, "PNG", out );
UrlUtils.dataUri( formatter, out.toByteArray(), urlString, "image/png;base64" );
}
|
java
|
static void colorizeImage( CssFormatter formatter, List<Expression> parameters ) throws IOException {
if( parameters.size() < 4 ) {
throw new LessException( "error evaluating function colorize-image expects url, main_color, contrast_color " );
}
String relativeURL = parameters.get( 0 ).stringValue( formatter );
String urlString = parameters.get( 1 ).stringValue( formatter );
URL url = new URL( formatter.getBaseURL(), relativeURL );
String urlStr = UrlUtils.removeQuote( urlString );
url = new URL( url, urlStr );
int mainColor = ColorUtils.argb( UrlUtils.getColor( parameters.get( 2 ), formatter ) );
int contrastColor = ColorUtils.argb( UrlUtils.getColor( parameters.get( 3 ), formatter ) );
BufferedImage loadedImage = ImageIO.read( url.openStream() );
// convert the image in a standard color model
int width = loadedImage.getWidth( null );
int height = loadedImage.getHeight( null );
BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB );
Graphics2D bGr = image.createGraphics();
bGr.drawImage( loadedImage, 0, 0, null );
bGr.dispose();
final float[] mainColorHsb = Color.RGBtoHSB( (mainColor >> 16) & 0xFF, (mainColor >> 8) & 0xFF, mainColor & 0xFF, null );
final float[] contrastColorHsb = Color.RGBtoHSB( (contrastColor >> 16) & 0xFF, (contrastColor >> 8) & 0xFF, contrastColor & 0xFF, null );
// get the pixel data
WritableRaster raster = image.getRaster();
DataBufferInt buffer = (DataBufferInt)raster.getDataBuffer();
int[] data = buffer.getData();
float[] hsb = new float[3];
int hsbColor = 0;
int lastRgb = data[0] + 1;
for( int i = 0; i < data.length; i++ ) {
int rgb = data[i];
if( rgb == lastRgb ) {
data[i] = hsbColor;
continue;
}
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
int b = rgb & 0xFF;
Color.RGBtoHSB( r, g, b, hsb );
float[] hsbColorize;
if( hsb[1] == 1.0f ) {
hsbColorize = hsb;
hsb[0] = hsb[0] * 3f / 4f + mainColorHsb[0] / 4f;
hsb[1] = hsb[1] * 3f / 4f + mainColorHsb[1] / 4f;
hsb[2] = hsb[2] * 3f / 4f + mainColorHsb[2] / 4f;
} else {
if( hsb[2] == 1.0f ) {
hsbColorize = contrastColorHsb;
} else {
hsbColorize = mainColorHsb;
}
}
lastRgb = rgb;
hsbColor = Color.HSBtoRGB( hsbColorize[0], hsbColorize[1], hsbColorize[2] );
hsbColor = (rgb & 0xFF000000) | (hsbColor & 0xFFFFFF);
data[i] = hsbColor;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write( image, "PNG", out );
UrlUtils.dataUri( formatter, out.toByteArray(), urlString, "image/png;base64" );
}
|
[
"static",
"void",
"colorizeImage",
"(",
"CssFormatter",
"formatter",
",",
"List",
"<",
"Expression",
">",
"parameters",
")",
"throws",
"IOException",
"{",
"if",
"(",
"parameters",
".",
"size",
"(",
")",
"<",
"4",
")",
"{",
"throw",
"new",
"LessException",
"(",
"\"error evaluating function colorize-image expects url, main_color, contrast_color \"",
")",
";",
"}",
"String",
"relativeURL",
"=",
"parameters",
".",
"get",
"(",
"0",
")",
".",
"stringValue",
"(",
"formatter",
")",
";",
"String",
"urlString",
"=",
"parameters",
".",
"get",
"(",
"1",
")",
".",
"stringValue",
"(",
"formatter",
")",
";",
"URL",
"url",
"=",
"new",
"URL",
"(",
"formatter",
".",
"getBaseURL",
"(",
")",
",",
"relativeURL",
")",
";",
"String",
"urlStr",
"=",
"UrlUtils",
".",
"removeQuote",
"(",
"urlString",
")",
";",
"url",
"=",
"new",
"URL",
"(",
"url",
",",
"urlStr",
")",
";",
"int",
"mainColor",
"=",
"ColorUtils",
".",
"argb",
"(",
"UrlUtils",
".",
"getColor",
"(",
"parameters",
".",
"get",
"(",
"2",
")",
",",
"formatter",
")",
")",
";",
"int",
"contrastColor",
"=",
"ColorUtils",
".",
"argb",
"(",
"UrlUtils",
".",
"getColor",
"(",
"parameters",
".",
"get",
"(",
"3",
")",
",",
"formatter",
")",
")",
";",
"BufferedImage",
"loadedImage",
"=",
"ImageIO",
".",
"read",
"(",
"url",
".",
"openStream",
"(",
")",
")",
";",
"// convert the image in a standard color model",
"int",
"width",
"=",
"loadedImage",
".",
"getWidth",
"(",
"null",
")",
";",
"int",
"height",
"=",
"loadedImage",
".",
"getHeight",
"(",
"null",
")",
";",
"BufferedImage",
"image",
"=",
"new",
"BufferedImage",
"(",
"width",
",",
"height",
",",
"BufferedImage",
".",
"TYPE_INT_ARGB",
")",
";",
"Graphics2D",
"bGr",
"=",
"image",
".",
"createGraphics",
"(",
")",
";",
"bGr",
".",
"drawImage",
"(",
"loadedImage",
",",
"0",
",",
"0",
",",
"null",
")",
";",
"bGr",
".",
"dispose",
"(",
")",
";",
"final",
"float",
"[",
"]",
"mainColorHsb",
"=",
"Color",
".",
"RGBtoHSB",
"(",
"(",
"mainColor",
">>",
"16",
")",
"&",
"0xFF",
",",
"(",
"mainColor",
">>",
"8",
")",
"&",
"0xFF",
",",
"mainColor",
"&",
"0xFF",
",",
"null",
")",
";",
"final",
"float",
"[",
"]",
"contrastColorHsb",
"=",
"Color",
".",
"RGBtoHSB",
"(",
"(",
"contrastColor",
">>",
"16",
")",
"&",
"0xFF",
",",
"(",
"contrastColor",
">>",
"8",
")",
"&",
"0xFF",
",",
"contrastColor",
"&",
"0xFF",
",",
"null",
")",
";",
"// get the pixel data",
"WritableRaster",
"raster",
"=",
"image",
".",
"getRaster",
"(",
")",
";",
"DataBufferInt",
"buffer",
"=",
"(",
"DataBufferInt",
")",
"raster",
".",
"getDataBuffer",
"(",
")",
";",
"int",
"[",
"]",
"data",
"=",
"buffer",
".",
"getData",
"(",
")",
";",
"float",
"[",
"]",
"hsb",
"=",
"new",
"float",
"[",
"3",
"]",
";",
"int",
"hsbColor",
"=",
"0",
";",
"int",
"lastRgb",
"=",
"data",
"[",
"0",
"]",
"+",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"rgb",
"=",
"data",
"[",
"i",
"]",
";",
"if",
"(",
"rgb",
"==",
"lastRgb",
")",
"{",
"data",
"[",
"i",
"]",
"=",
"hsbColor",
";",
"continue",
";",
"}",
"int",
"r",
"=",
"(",
"rgb",
">>",
"16",
")",
"&",
"0xFF",
";",
"int",
"g",
"=",
"(",
"rgb",
">>",
"8",
")",
"&",
"0xFF",
";",
"int",
"b",
"=",
"rgb",
"&",
"0xFF",
";",
"Color",
".",
"RGBtoHSB",
"(",
"r",
",",
"g",
",",
"b",
",",
"hsb",
")",
";",
"float",
"[",
"]",
"hsbColorize",
";",
"if",
"(",
"hsb",
"[",
"1",
"]",
"==",
"1.0f",
")",
"{",
"hsbColorize",
"=",
"hsb",
";",
"hsb",
"[",
"0",
"]",
"=",
"hsb",
"[",
"0",
"]",
"*",
"3f",
"/",
"4f",
"+",
"mainColorHsb",
"[",
"0",
"]",
"/",
"4f",
";",
"hsb",
"[",
"1",
"]",
"=",
"hsb",
"[",
"1",
"]",
"*",
"3f",
"/",
"4f",
"+",
"mainColorHsb",
"[",
"1",
"]",
"/",
"4f",
";",
"hsb",
"[",
"2",
"]",
"=",
"hsb",
"[",
"2",
"]",
"*",
"3f",
"/",
"4f",
"+",
"mainColorHsb",
"[",
"2",
"]",
"/",
"4f",
";",
"}",
"else",
"{",
"if",
"(",
"hsb",
"[",
"2",
"]",
"==",
"1.0f",
")",
"{",
"hsbColorize",
"=",
"contrastColorHsb",
";",
"}",
"else",
"{",
"hsbColorize",
"=",
"mainColorHsb",
";",
"}",
"}",
"lastRgb",
"=",
"rgb",
";",
"hsbColor",
"=",
"Color",
".",
"HSBtoRGB",
"(",
"hsbColorize",
"[",
"0",
"]",
",",
"hsbColorize",
"[",
"1",
"]",
",",
"hsbColorize",
"[",
"2",
"]",
")",
";",
"hsbColor",
"=",
"(",
"rgb",
"&",
"0xFF000000",
")",
"|",
"(",
"hsbColor",
"&",
"0xFFFFFF",
")",
";",
"data",
"[",
"i",
"]",
"=",
"hsbColor",
";",
"}",
"ByteArrayOutputStream",
"out",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ImageIO",
".",
"write",
"(",
"image",
",",
"\"PNG\"",
",",
"out",
")",
";",
"UrlUtils",
".",
"dataUri",
"(",
"formatter",
",",
"out",
".",
"toByteArray",
"(",
")",
",",
"urlString",
",",
"\"image/png;base64\"",
")",
";",
"}"
] |
Colorize an image and inline it as base64.
@param formatter current formatter
@param parameters the parameters (relativeURL, url, main_color, contrast_color)
@throws IOException if any I/O error occur
@throws LessException if parameter list is wrong
|
[
"Colorize",
"an",
"image",
"and",
"inline",
"it",
"as",
"base64",
"."
] |
train
|
https://github.com/i-net-software/jlessc/blob/15b13e1637f6cc2e4d72df021e23ee0ca8d5e629/src/com/inet/lib/less/CustomFunctions.java#L53-L121
|
e-biz/spring-dbunit
|
spring-dbunit-core/src/main/java/com/excilys/ebi/spring/dbunit/dataset/xml/flyweight/FlyWeightFlatXmlProducer.java
|
FlyWeightFlatXmlProducer.buildException
|
protected final static DataSetException buildException(SAXException cause) {
"""
Wraps a {@link SAXException} into a {@link DataSetException}
@param cause The cause to be wrapped into a {@link DataSetException}
@return A {@link DataSetException} that wraps the given {@link SAXException}
"""
int lineNumber = -1;
if (cause instanceof SAXParseException) {
lineNumber = ((SAXParseException) cause).getLineNumber();
}
Exception exception = cause.getException() == null ? cause : cause.getException();
String message;
if (lineNumber >= 0) {
message = "Line " + lineNumber + ": " + exception.getMessage();
} else {
message = exception.getMessage();
}
if (exception instanceof DataSetException) {
return (DataSetException) exception;
} else {
return new DataSetException(message, exception);
}
}
|
java
|
protected final static DataSetException buildException(SAXException cause) {
int lineNumber = -1;
if (cause instanceof SAXParseException) {
lineNumber = ((SAXParseException) cause).getLineNumber();
}
Exception exception = cause.getException() == null ? cause : cause.getException();
String message;
if (lineNumber >= 0) {
message = "Line " + lineNumber + ": " + exception.getMessage();
} else {
message = exception.getMessage();
}
if (exception instanceof DataSetException) {
return (DataSetException) exception;
} else {
return new DataSetException(message, exception);
}
}
|
[
"protected",
"final",
"static",
"DataSetException",
"buildException",
"(",
"SAXException",
"cause",
")",
"{",
"int",
"lineNumber",
"=",
"-",
"1",
";",
"if",
"(",
"cause",
"instanceof",
"SAXParseException",
")",
"{",
"lineNumber",
"=",
"(",
"(",
"SAXParseException",
")",
"cause",
")",
".",
"getLineNumber",
"(",
")",
";",
"}",
"Exception",
"exception",
"=",
"cause",
".",
"getException",
"(",
")",
"==",
"null",
"?",
"cause",
":",
"cause",
".",
"getException",
"(",
")",
";",
"String",
"message",
";",
"if",
"(",
"lineNumber",
">=",
"0",
")",
"{",
"message",
"=",
"\"Line \"",
"+",
"lineNumber",
"+",
"\": \"",
"+",
"exception",
".",
"getMessage",
"(",
")",
";",
"}",
"else",
"{",
"message",
"=",
"exception",
".",
"getMessage",
"(",
")",
";",
"}",
"if",
"(",
"exception",
"instanceof",
"DataSetException",
")",
"{",
"return",
"(",
"DataSetException",
")",
"exception",
";",
"}",
"else",
"{",
"return",
"new",
"DataSetException",
"(",
"message",
",",
"exception",
")",
";",
"}",
"}"
] |
Wraps a {@link SAXException} into a {@link DataSetException}
@param cause The cause to be wrapped into a {@link DataSetException}
@return A {@link DataSetException} that wraps the given {@link SAXException}
|
[
"Wraps",
"a",
"{",
"@link",
"SAXException",
"}",
"into",
"a",
"{",
"@link",
"DataSetException",
"}"
] |
train
|
https://github.com/e-biz/spring-dbunit/blob/1ec51222ecdd5dbd6daa4bd6879c6eabe76dfb6b/spring-dbunit-core/src/main/java/com/excilys/ebi/spring/dbunit/dataset/xml/flyweight/FlyWeightFlatXmlProducer.java#L533-L552
|
googleads/googleads-java-lib
|
examples/adwords_axis/src/main/java/adwords/axis/v201809/shoppingcampaigns/GetProductCategoryTaxonomy.java
|
GetProductCategoryTaxonomy.runExample
|
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session)
throws RemoteException {
"""
Runs the example.
@param adWordsServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.
"""
// Get the constant data service.
ConstantDataServiceInterface constantDataService =
adWordsServices.get(session, ConstantDataServiceInterface.class);
Selector selector = new SelectorBuilder()
.equals(ConstantDataField.Country, "US")
.build();
ProductBiddingCategoryData[] results =
constantDataService.getProductBiddingCategoryData(selector);
// List of top level category nodes.
List<CategoryNode> rootCategories = new ArrayList<>();
// Map of category ID to category node for all categories found in the results.
Map<Long, CategoryNode> biddingCategories = Maps.newHashMap();
for (ProductBiddingCategoryData productBiddingCategoryData : results) {
Long id = productBiddingCategoryData.getDimensionValue().getValue();
String name = productBiddingCategoryData.getDisplayValue(0).getValue();
CategoryNode node = biddingCategories.get(id);
if (node == null) {
node = new CategoryNode(id, name);
biddingCategories.put(id, node);
} else if (node.name == null) {
// Ensure that the name attribute for the node is set. Name will be null for nodes added
// to biddingCategories as a result of being a parentNode below.
node.name = name;
}
if (productBiddingCategoryData.getParentDimensionValue() != null
&& productBiddingCategoryData.getParentDimensionValue().getValue() != null) {
Long parentId = productBiddingCategoryData.getParentDimensionValue().getValue();
CategoryNode parentNode = biddingCategories.get(parentId);
if (parentNode == null) {
parentNode = new CategoryNode(parentId);
biddingCategories.put(parentId, parentNode);
}
parentNode.children.add(node);
} else {
rootCategories.add(node);
}
}
displayCategories(rootCategories, "");
}
|
java
|
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session)
throws RemoteException {
// Get the constant data service.
ConstantDataServiceInterface constantDataService =
adWordsServices.get(session, ConstantDataServiceInterface.class);
Selector selector = new SelectorBuilder()
.equals(ConstantDataField.Country, "US")
.build();
ProductBiddingCategoryData[] results =
constantDataService.getProductBiddingCategoryData(selector);
// List of top level category nodes.
List<CategoryNode> rootCategories = new ArrayList<>();
// Map of category ID to category node for all categories found in the results.
Map<Long, CategoryNode> biddingCategories = Maps.newHashMap();
for (ProductBiddingCategoryData productBiddingCategoryData : results) {
Long id = productBiddingCategoryData.getDimensionValue().getValue();
String name = productBiddingCategoryData.getDisplayValue(0).getValue();
CategoryNode node = biddingCategories.get(id);
if (node == null) {
node = new CategoryNode(id, name);
biddingCategories.put(id, node);
} else if (node.name == null) {
// Ensure that the name attribute for the node is set. Name will be null for nodes added
// to biddingCategories as a result of being a parentNode below.
node.name = name;
}
if (productBiddingCategoryData.getParentDimensionValue() != null
&& productBiddingCategoryData.getParentDimensionValue().getValue() != null) {
Long parentId = productBiddingCategoryData.getParentDimensionValue().getValue();
CategoryNode parentNode = biddingCategories.get(parentId);
if (parentNode == null) {
parentNode = new CategoryNode(parentId);
biddingCategories.put(parentId, parentNode);
}
parentNode.children.add(node);
} else {
rootCategories.add(node);
}
}
displayCategories(rootCategories, "");
}
|
[
"public",
"static",
"void",
"runExample",
"(",
"AdWordsServicesInterface",
"adWordsServices",
",",
"AdWordsSession",
"session",
")",
"throws",
"RemoteException",
"{",
"// Get the constant data service.",
"ConstantDataServiceInterface",
"constantDataService",
"=",
"adWordsServices",
".",
"get",
"(",
"session",
",",
"ConstantDataServiceInterface",
".",
"class",
")",
";",
"Selector",
"selector",
"=",
"new",
"SelectorBuilder",
"(",
")",
".",
"equals",
"(",
"ConstantDataField",
".",
"Country",
",",
"\"US\"",
")",
".",
"build",
"(",
")",
";",
"ProductBiddingCategoryData",
"[",
"]",
"results",
"=",
"constantDataService",
".",
"getProductBiddingCategoryData",
"(",
"selector",
")",
";",
"// List of top level category nodes.",
"List",
"<",
"CategoryNode",
">",
"rootCategories",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// Map of category ID to category node for all categories found in the results.",
"Map",
"<",
"Long",
",",
"CategoryNode",
">",
"biddingCategories",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"ProductBiddingCategoryData",
"productBiddingCategoryData",
":",
"results",
")",
"{",
"Long",
"id",
"=",
"productBiddingCategoryData",
".",
"getDimensionValue",
"(",
")",
".",
"getValue",
"(",
")",
";",
"String",
"name",
"=",
"productBiddingCategoryData",
".",
"getDisplayValue",
"(",
"0",
")",
".",
"getValue",
"(",
")",
";",
"CategoryNode",
"node",
"=",
"biddingCategories",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"node",
"=",
"new",
"CategoryNode",
"(",
"id",
",",
"name",
")",
";",
"biddingCategories",
".",
"put",
"(",
"id",
",",
"node",
")",
";",
"}",
"else",
"if",
"(",
"node",
".",
"name",
"==",
"null",
")",
"{",
"// Ensure that the name attribute for the node is set. Name will be null for nodes added",
"// to biddingCategories as a result of being a parentNode below.",
"node",
".",
"name",
"=",
"name",
";",
"}",
"if",
"(",
"productBiddingCategoryData",
".",
"getParentDimensionValue",
"(",
")",
"!=",
"null",
"&&",
"productBiddingCategoryData",
".",
"getParentDimensionValue",
"(",
")",
".",
"getValue",
"(",
")",
"!=",
"null",
")",
"{",
"Long",
"parentId",
"=",
"productBiddingCategoryData",
".",
"getParentDimensionValue",
"(",
")",
".",
"getValue",
"(",
")",
";",
"CategoryNode",
"parentNode",
"=",
"biddingCategories",
".",
"get",
"(",
"parentId",
")",
";",
"if",
"(",
"parentNode",
"==",
"null",
")",
"{",
"parentNode",
"=",
"new",
"CategoryNode",
"(",
"parentId",
")",
";",
"biddingCategories",
".",
"put",
"(",
"parentId",
",",
"parentNode",
")",
";",
"}",
"parentNode",
".",
"children",
".",
"add",
"(",
"node",
")",
";",
"}",
"else",
"{",
"rootCategories",
".",
"add",
"(",
"node",
")",
";",
"}",
"}",
"displayCategories",
"(",
"rootCategories",
",",
"\"\"",
")",
";",
"}"
] |
Runs the example.
@param adWordsServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.
|
[
"Runs",
"the",
"example",
"."
] |
train
|
https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/examples/adwords_axis/src/main/java/adwords/axis/v201809/shoppingcampaigns/GetProductCategoryTaxonomy.java#L115-L160
|
b3dgs/lionengine
|
lionengine-network/src/main/java/com/b3dgs/lionengine/network/ServerImpl.java
|
ServerImpl.receiveDisconnected
|
private void receiveDisconnected(ClientSocket client, byte from, StateConnection expected) throws IOException {
"""
Update the receive disconnected state.
@param client The current client.
@param from The id from.
@param expected The expected client state.
@throws IOException If error.
"""
if (ServerImpl.checkValidity(client, from, expected))
{
// Notify other clients
client.setState(StateConnection.DISCONNECTED);
for (final ClientListener listener : listeners)
{
listener.notifyClientDisconnected(Byte.valueOf(client.getId()), client.getName());
}
for (final ClientSocket other : clients.values())
{
if (other.getId() == from || other.getState() != StateConnection.CONNECTED)
{
continue;
}
other.getOut().writeByte(NetworkMessageSystemId.OTHER_CLIENT_DISCONNECTED);
ServerImpl.writeIdAndName(other, client.getId(), client.getName());
// Send
other.getOut().flush();
}
removeClient(Byte.valueOf(from));
}
}
|
java
|
private void receiveDisconnected(ClientSocket client, byte from, StateConnection expected) throws IOException
{
if (ServerImpl.checkValidity(client, from, expected))
{
// Notify other clients
client.setState(StateConnection.DISCONNECTED);
for (final ClientListener listener : listeners)
{
listener.notifyClientDisconnected(Byte.valueOf(client.getId()), client.getName());
}
for (final ClientSocket other : clients.values())
{
if (other.getId() == from || other.getState() != StateConnection.CONNECTED)
{
continue;
}
other.getOut().writeByte(NetworkMessageSystemId.OTHER_CLIENT_DISCONNECTED);
ServerImpl.writeIdAndName(other, client.getId(), client.getName());
// Send
other.getOut().flush();
}
removeClient(Byte.valueOf(from));
}
}
|
[
"private",
"void",
"receiveDisconnected",
"(",
"ClientSocket",
"client",
",",
"byte",
"from",
",",
"StateConnection",
"expected",
")",
"throws",
"IOException",
"{",
"if",
"(",
"ServerImpl",
".",
"checkValidity",
"(",
"client",
",",
"from",
",",
"expected",
")",
")",
"{",
"// Notify other clients",
"client",
".",
"setState",
"(",
"StateConnection",
".",
"DISCONNECTED",
")",
";",
"for",
"(",
"final",
"ClientListener",
"listener",
":",
"listeners",
")",
"{",
"listener",
".",
"notifyClientDisconnected",
"(",
"Byte",
".",
"valueOf",
"(",
"client",
".",
"getId",
"(",
")",
")",
",",
"client",
".",
"getName",
"(",
")",
")",
";",
"}",
"for",
"(",
"final",
"ClientSocket",
"other",
":",
"clients",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"other",
".",
"getId",
"(",
")",
"==",
"from",
"||",
"other",
".",
"getState",
"(",
")",
"!=",
"StateConnection",
".",
"CONNECTED",
")",
"{",
"continue",
";",
"}",
"other",
".",
"getOut",
"(",
")",
".",
"writeByte",
"(",
"NetworkMessageSystemId",
".",
"OTHER_CLIENT_DISCONNECTED",
")",
";",
"ServerImpl",
".",
"writeIdAndName",
"(",
"other",
",",
"client",
".",
"getId",
"(",
")",
",",
"client",
".",
"getName",
"(",
")",
")",
";",
"// Send",
"other",
".",
"getOut",
"(",
")",
".",
"flush",
"(",
")",
";",
"}",
"removeClient",
"(",
"Byte",
".",
"valueOf",
"(",
"from",
")",
")",
";",
"}",
"}"
] |
Update the receive disconnected state.
@param client The current client.
@param from The id from.
@param expected The expected client state.
@throws IOException If error.
|
[
"Update",
"the",
"receive",
"disconnected",
"state",
"."
] |
train
|
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-network/src/main/java/com/b3dgs/lionengine/network/ServerImpl.java#L287-L310
|
VoltDB/voltdb
|
src/hsqldb19b3/org/hsqldb_voltpatches/lib/StringUtil.java
|
StringUtil.skipSpaces
|
public static int skipSpaces(String s, int start) {
"""
Skips any spaces at or after start and returns the index of first
non-space character;
@param s the string
@param start index to start
@return index of first non-space
"""
int limit = s.length();
int i = start;
for (; i < limit; i++) {
if (s.charAt(i) != ' ') {
break;
}
}
return i;
}
|
java
|
public static int skipSpaces(String s, int start) {
int limit = s.length();
int i = start;
for (; i < limit; i++) {
if (s.charAt(i) != ' ') {
break;
}
}
return i;
}
|
[
"public",
"static",
"int",
"skipSpaces",
"(",
"String",
"s",
",",
"int",
"start",
")",
"{",
"int",
"limit",
"=",
"s",
".",
"length",
"(",
")",
";",
"int",
"i",
"=",
"start",
";",
"for",
"(",
";",
"i",
"<",
"limit",
";",
"i",
"++",
")",
"{",
"if",
"(",
"s",
".",
"charAt",
"(",
"i",
")",
"!=",
"'",
"'",
")",
"{",
"break",
";",
"}",
"}",
"return",
"i",
";",
"}"
] |
Skips any spaces at or after start and returns the index of first
non-space character;
@param s the string
@param start index to start
@return index of first non-space
|
[
"Skips",
"any",
"spaces",
"at",
"or",
"after",
"start",
"and",
"returns",
"the",
"index",
"of",
"first",
"non",
"-",
"space",
"character",
";"
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/StringUtil.java#L334-L346
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDLoss.java
|
SDLoss.l2Loss
|
public SDVariable l2Loss(String name, @NonNull SDVariable var) {
"""
L2 loss: 1/2 * sum(x^2)
@param name Name of the output variable
@param var Variable to calculate L2 loss of
@return L2 loss
"""
validateNumerical("l2 loss", var);
SDVariable result = f().lossL2(var);
result = updateVariableNameAndReference(result, name);
result.markAsLoss();
return result;
}
|
java
|
public SDVariable l2Loss(String name, @NonNull SDVariable var) {
validateNumerical("l2 loss", var);
SDVariable result = f().lossL2(var);
result = updateVariableNameAndReference(result, name);
result.markAsLoss();
return result;
}
|
[
"public",
"SDVariable",
"l2Loss",
"(",
"String",
"name",
",",
"@",
"NonNull",
"SDVariable",
"var",
")",
"{",
"validateNumerical",
"(",
"\"l2 loss\"",
",",
"var",
")",
";",
"SDVariable",
"result",
"=",
"f",
"(",
")",
".",
"lossL2",
"(",
"var",
")",
";",
"result",
"=",
"updateVariableNameAndReference",
"(",
"result",
",",
"name",
")",
";",
"result",
".",
"markAsLoss",
"(",
")",
";",
"return",
"result",
";",
"}"
] |
L2 loss: 1/2 * sum(x^2)
@param name Name of the output variable
@param var Variable to calculate L2 loss of
@return L2 loss
|
[
"L2",
"loss",
":",
"1",
"/",
"2",
"*",
"sum",
"(",
"x^2",
")"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDLoss.java#L202-L208
|
orbisgis/h2gis
|
h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/ST_Svf.java
|
ST_Svf.computeSvf
|
public static double computeSvf(Point pt, Geometry geoms, double distance, int rayCount) {
"""
The method to compute the Sky View Factor
@param pt
@param distance
@param rayCount number of rays
@param geoms
@return
"""
return computeSvf(pt, geoms, distance, rayCount, RAY_STEP_LENGTH);
}
|
java
|
public static double computeSvf(Point pt, Geometry geoms, double distance, int rayCount) {
return computeSvf(pt, geoms, distance, rayCount, RAY_STEP_LENGTH);
}
|
[
"public",
"static",
"double",
"computeSvf",
"(",
"Point",
"pt",
",",
"Geometry",
"geoms",
",",
"double",
"distance",
",",
"int",
"rayCount",
")",
"{",
"return",
"computeSvf",
"(",
"pt",
",",
"geoms",
",",
"distance",
",",
"rayCount",
",",
"RAY_STEP_LENGTH",
")",
";",
"}"
] |
The method to compute the Sky View Factor
@param pt
@param distance
@param rayCount number of rays
@param geoms
@return
|
[
"The",
"method",
"to",
"compute",
"the",
"Sky",
"View",
"Factor"
] |
train
|
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/earth/ST_Svf.java#L66-L68
|
ACRA/acra
|
acra-http/src/main/java/org/acra/sender/HttpSender.java
|
HttpSender.setBasicAuth
|
@SuppressWarnings("unused")
public void setBasicAuth(@Nullable String username, @Nullable String password) {
"""
<p>
Set credentials for this HttpSender that override (if present) the ones set globally.
</p>
@param username The username to set for HTTP Basic Auth.
@param password The password to set for HTTP Basic Auth.
"""
mUsername = username;
mPassword = password;
}
|
java
|
@SuppressWarnings("unused")
public void setBasicAuth(@Nullable String username, @Nullable String password) {
mUsername = username;
mPassword = password;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"void",
"setBasicAuth",
"(",
"@",
"Nullable",
"String",
"username",
",",
"@",
"Nullable",
"String",
"password",
")",
"{",
"mUsername",
"=",
"username",
";",
"mPassword",
"=",
"password",
";",
"}"
] |
<p>
Set credentials for this HttpSender that override (if present) the ones set globally.
</p>
@param username The username to set for HTTP Basic Auth.
@param password The password to set for HTTP Basic Auth.
|
[
"<p",
">",
"Set",
"credentials",
"for",
"this",
"HttpSender",
"that",
"override",
"(",
"if",
"present",
")",
"the",
"ones",
"set",
"globally",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/ACRA/acra/blob/bfa3235ab110328c5ab2f792ddf8ee87be4a32d1/acra-http/src/main/java/org/acra/sender/HttpSender.java#L108-L112
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
|
DefaultGroovyMethods.getAt
|
@SuppressWarnings("unchecked")
public static List<Byte> getAt(byte[] array, ObjectRange range) {
"""
Support the subscript operator with an ObjectRange for a byte array
@param array a byte array
@param range an ObjectRange indicating the indices for the items to retrieve
@return list of the retrieved bytes
@since 1.0
"""
return primitiveArrayGet(array, range);
}
|
java
|
@SuppressWarnings("unchecked")
public static List<Byte> getAt(byte[] array, ObjectRange range) {
return primitiveArrayGet(array, range);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"List",
"<",
"Byte",
">",
"getAt",
"(",
"byte",
"[",
"]",
"array",
",",
"ObjectRange",
"range",
")",
"{",
"return",
"primitiveArrayGet",
"(",
"array",
",",
"range",
")",
";",
"}"
] |
Support the subscript operator with an ObjectRange for a byte array
@param array a byte array
@param range an ObjectRange indicating the indices for the items to retrieve
@return list of the retrieved bytes
@since 1.0
|
[
"Support",
"the",
"subscript",
"operator",
"with",
"an",
"ObjectRange",
"for",
"a",
"byte",
"array"
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L13834-L13837
|
xwiki/xwiki-commons
|
xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/internal/XWikiDocument.java
|
XWikiDocument.readElement
|
public static String readElement(Element rootElement, String elementName) throws DocumentException {
"""
Read an element from the XML.
@param rootElement the root XML element under which to find the element
@param elementName the name of the element to read
@return null or the element value as a String
@throws DocumentException if it is not a valid XML wiki page
@since 10.8RC1
"""
String result = null;
Element element = rootElement.element(elementName);
if (element != null) {
// Make sure the element does not have any child element
if (!element.isTextOnly()) {
throw new DocumentException("Unexpected non-text content found in element [" + elementName + "]");
}
result = element.getText();
}
return result;
}
|
java
|
public static String readElement(Element rootElement, String elementName) throws DocumentException
{
String result = null;
Element element = rootElement.element(elementName);
if (element != null) {
// Make sure the element does not have any child element
if (!element.isTextOnly()) {
throw new DocumentException("Unexpected non-text content found in element [" + elementName + "]");
}
result = element.getText();
}
return result;
}
|
[
"public",
"static",
"String",
"readElement",
"(",
"Element",
"rootElement",
",",
"String",
"elementName",
")",
"throws",
"DocumentException",
"{",
"String",
"result",
"=",
"null",
";",
"Element",
"element",
"=",
"rootElement",
".",
"element",
"(",
"elementName",
")",
";",
"if",
"(",
"element",
"!=",
"null",
")",
"{",
"// Make sure the element does not have any child element",
"if",
"(",
"!",
"element",
".",
"isTextOnly",
"(",
")",
")",
"{",
"throw",
"new",
"DocumentException",
"(",
"\"Unexpected non-text content found in element [\"",
"+",
"elementName",
"+",
"\"]\"",
")",
";",
"}",
"result",
"=",
"element",
".",
"getText",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Read an element from the XML.
@param rootElement the root XML element under which to find the element
@param elementName the name of the element to read
@return null or the element value as a String
@throws DocumentException if it is not a valid XML wiki page
@since 10.8RC1
|
[
"Read",
"an",
"element",
"from",
"the",
"XML",
"."
] |
train
|
https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/internal/XWikiDocument.java#L285-L298
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.