repository_name
stringlengths 7
54
| func_path_in_repository
stringlengths 18
196
| func_name
stringlengths 7
107
| whole_func_string
stringlengths 76
3.82k
| language
stringclasses 1
value | func_code_string
stringlengths 76
3.82k
| func_code_tokens
listlengths 22
717
| func_documentation_string
stringlengths 61
1.98k
| func_documentation_tokens
listlengths 1
508
| split_name
stringclasses 1
value | func_code_url
stringlengths 111
310
|
---|---|---|---|---|---|---|---|---|---|---|
apache/flink
|
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/NetworkEnvironmentConfiguration.java
|
NetworkEnvironmentConfiguration.calculateNumberOfNetworkBuffers
|
@SuppressWarnings("deprecation")
private static int calculateNumberOfNetworkBuffers(Configuration configuration, long maxJvmHeapMemory) {
final int numberOfNetworkBuffers;
if (!hasNewNetworkConfig(configuration)) {
// fallback: number of network buffers
numberOfNetworkBuffers = configuration.getInteger(TaskManagerOptions.NETWORK_NUM_BUFFERS);
checkOldNetworkConfig(numberOfNetworkBuffers);
} else {
if (configuration.contains(TaskManagerOptions.NETWORK_NUM_BUFFERS)) {
LOG.info("Ignoring old (but still present) network buffer configuration via {}.",
TaskManagerOptions.NETWORK_NUM_BUFFERS.key());
}
final long networkMemorySize = calculateNewNetworkBufferMemory(configuration, maxJvmHeapMemory);
// tolerate offcuts between intended and allocated memory due to segmentation (will be available to the user-space memory)
long numberOfNetworkBuffersLong = networkMemorySize / getPageSize(configuration);
if (numberOfNetworkBuffersLong > Integer.MAX_VALUE) {
throw new IllegalArgumentException("The given number of memory bytes (" + networkMemorySize
+ ") corresponds to more than MAX_INT pages.");
}
numberOfNetworkBuffers = (int) numberOfNetworkBuffersLong;
}
return numberOfNetworkBuffers;
}
|
java
|
@SuppressWarnings("deprecation")
private static int calculateNumberOfNetworkBuffers(Configuration configuration, long maxJvmHeapMemory) {
final int numberOfNetworkBuffers;
if (!hasNewNetworkConfig(configuration)) {
// fallback: number of network buffers
numberOfNetworkBuffers = configuration.getInteger(TaskManagerOptions.NETWORK_NUM_BUFFERS);
checkOldNetworkConfig(numberOfNetworkBuffers);
} else {
if (configuration.contains(TaskManagerOptions.NETWORK_NUM_BUFFERS)) {
LOG.info("Ignoring old (but still present) network buffer configuration via {}.",
TaskManagerOptions.NETWORK_NUM_BUFFERS.key());
}
final long networkMemorySize = calculateNewNetworkBufferMemory(configuration, maxJvmHeapMemory);
// tolerate offcuts between intended and allocated memory due to segmentation (will be available to the user-space memory)
long numberOfNetworkBuffersLong = networkMemorySize / getPageSize(configuration);
if (numberOfNetworkBuffersLong > Integer.MAX_VALUE) {
throw new IllegalArgumentException("The given number of memory bytes (" + networkMemorySize
+ ") corresponds to more than MAX_INT pages.");
}
numberOfNetworkBuffers = (int) numberOfNetworkBuffersLong;
}
return numberOfNetworkBuffers;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"private",
"static",
"int",
"calculateNumberOfNetworkBuffers",
"(",
"Configuration",
"configuration",
",",
"long",
"maxJvmHeapMemory",
")",
"{",
"final",
"int",
"numberOfNetworkBuffers",
";",
"if",
"(",
"!",
"hasNewNetworkConfig",
"(",
"configuration",
")",
")",
"{",
"// fallback: number of network buffers",
"numberOfNetworkBuffers",
"=",
"configuration",
".",
"getInteger",
"(",
"TaskManagerOptions",
".",
"NETWORK_NUM_BUFFERS",
")",
";",
"checkOldNetworkConfig",
"(",
"numberOfNetworkBuffers",
")",
";",
"}",
"else",
"{",
"if",
"(",
"configuration",
".",
"contains",
"(",
"TaskManagerOptions",
".",
"NETWORK_NUM_BUFFERS",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Ignoring old (but still present) network buffer configuration via {}.\"",
",",
"TaskManagerOptions",
".",
"NETWORK_NUM_BUFFERS",
".",
"key",
"(",
")",
")",
";",
"}",
"final",
"long",
"networkMemorySize",
"=",
"calculateNewNetworkBufferMemory",
"(",
"configuration",
",",
"maxJvmHeapMemory",
")",
";",
"// tolerate offcuts between intended and allocated memory due to segmentation (will be available to the user-space memory)",
"long",
"numberOfNetworkBuffersLong",
"=",
"networkMemorySize",
"/",
"getPageSize",
"(",
"configuration",
")",
";",
"if",
"(",
"numberOfNetworkBuffersLong",
">",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The given number of memory bytes (\"",
"+",
"networkMemorySize",
"+",
"\") corresponds to more than MAX_INT pages.\"",
")",
";",
"}",
"numberOfNetworkBuffers",
"=",
"(",
"int",
")",
"numberOfNetworkBuffersLong",
";",
"}",
"return",
"numberOfNetworkBuffers",
";",
"}"
] |
Calculates the number of network buffers based on configuration and jvm heap size.
@param configuration configuration object
@param maxJvmHeapMemory the maximum JVM heap size (in bytes)
@return the number of network buffers
|
[
"Calculates",
"the",
"number",
"of",
"network",
"buffers",
"based",
"on",
"configuration",
"and",
"jvm",
"heap",
"size",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/NetworkEnvironmentConfiguration.java#L387-L413
|
ngageoint/geopackage-android-map
|
geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java
|
FeatureInfoBuilder.buildResultsInfoMessage
|
public String buildResultsInfoMessage(FeatureIndexResults results, double tolerance, LatLng clickLocation) {
return buildResultsInfoMessage(results, tolerance, clickLocation, null);
}
|
java
|
public String buildResultsInfoMessage(FeatureIndexResults results, double tolerance, LatLng clickLocation) {
return buildResultsInfoMessage(results, tolerance, clickLocation, null);
}
|
[
"public",
"String",
"buildResultsInfoMessage",
"(",
"FeatureIndexResults",
"results",
",",
"double",
"tolerance",
",",
"LatLng",
"clickLocation",
")",
"{",
"return",
"buildResultsInfoMessage",
"(",
"results",
",",
"tolerance",
",",
"clickLocation",
",",
"null",
")",
";",
"}"
] |
Build a feature results information message
@param results feature index results
@param tolerance distance tolerance
@param clickLocation map click location
@return results message or null if no results
|
[
"Build",
"a",
"feature",
"results",
"information",
"message"
] |
train
|
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java#L319-L321
|
Impetus/Kundera
|
src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java
|
MongoDBClient.onFlushBatch
|
private void onFlushBatch(Map<String, BulkWriteOperation> bulkWriteOperationMap)
{
if (!bulkWriteOperationMap.isEmpty())
{
for (BulkWriteOperation builder : bulkWriteOperationMap.values())
{
try
{
builder.execute(getWriteConcern());
}
catch (BulkWriteException bwex)
{
log.error("Batch insertion is not performed due to error in write command. Caused By: ", bwex);
throw new KunderaException(
"Batch insertion is not performed due to error in write command. Caused By: ", bwex);
}
catch (MongoException mex)
{
log.error("Batch insertion is not performed. Caused By: ", mex);
throw new KunderaException("Batch insertion is not performed. Caused By: ", mex);
}
}
}
}
|
java
|
private void onFlushBatch(Map<String, BulkWriteOperation> bulkWriteOperationMap)
{
if (!bulkWriteOperationMap.isEmpty())
{
for (BulkWriteOperation builder : bulkWriteOperationMap.values())
{
try
{
builder.execute(getWriteConcern());
}
catch (BulkWriteException bwex)
{
log.error("Batch insertion is not performed due to error in write command. Caused By: ", bwex);
throw new KunderaException(
"Batch insertion is not performed due to error in write command. Caused By: ", bwex);
}
catch (MongoException mex)
{
log.error("Batch insertion is not performed. Caused By: ", mex);
throw new KunderaException("Batch insertion is not performed. Caused By: ", mex);
}
}
}
}
|
[
"private",
"void",
"onFlushBatch",
"(",
"Map",
"<",
"String",
",",
"BulkWriteOperation",
">",
"bulkWriteOperationMap",
")",
"{",
"if",
"(",
"!",
"bulkWriteOperationMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"BulkWriteOperation",
"builder",
":",
"bulkWriteOperationMap",
".",
"values",
"(",
")",
")",
"{",
"try",
"{",
"builder",
".",
"execute",
"(",
"getWriteConcern",
"(",
")",
")",
";",
"}",
"catch",
"(",
"BulkWriteException",
"bwex",
")",
"{",
"log",
".",
"error",
"(",
"\"Batch insertion is not performed due to error in write command. Caused By: \"",
",",
"bwex",
")",
";",
"throw",
"new",
"KunderaException",
"(",
"\"Batch insertion is not performed due to error in write command. Caused By: \"",
",",
"bwex",
")",
";",
"}",
"catch",
"(",
"MongoException",
"mex",
")",
"{",
"log",
".",
"error",
"(",
"\"Batch insertion is not performed. Caused By: \"",
",",
"mex",
")",
";",
"throw",
"new",
"KunderaException",
"(",
"\"Batch insertion is not performed. Caused By: \"",
",",
"mex",
")",
";",
"}",
"}",
"}",
"}"
] |
On flush batch.
@param bulkWriteOperationMap
the bulk write operation map
|
[
"On",
"flush",
"batch",
"."
] |
train
|
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java#L1329-L1352
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java
|
ApiOvhDedicatedserver.serviceName_serviceMonitoring_monitoringId_alert_email_alertId_GET
|
public OvhEmailAlert serviceName_serviceMonitoring_monitoringId_alert_email_alertId_GET(String serviceName, Long monitoringId, Long alertId) throws IOException {
String qPath = "/dedicated/server/{serviceName}/serviceMonitoring/{monitoringId}/alert/email/{alertId}";
StringBuilder sb = path(qPath, serviceName, monitoringId, alertId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhEmailAlert.class);
}
|
java
|
public OvhEmailAlert serviceName_serviceMonitoring_monitoringId_alert_email_alertId_GET(String serviceName, Long monitoringId, Long alertId) throws IOException {
String qPath = "/dedicated/server/{serviceName}/serviceMonitoring/{monitoringId}/alert/email/{alertId}";
StringBuilder sb = path(qPath, serviceName, monitoringId, alertId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhEmailAlert.class);
}
|
[
"public",
"OvhEmailAlert",
"serviceName_serviceMonitoring_monitoringId_alert_email_alertId_GET",
"(",
"String",
"serviceName",
",",
"Long",
"monitoringId",
",",
"Long",
"alertId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicated/server/{serviceName}/serviceMonitoring/{monitoringId}/alert/email/{alertId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"monitoringId",
",",
"alertId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhEmailAlert",
".",
"class",
")",
";",
"}"
] |
Get this object properties
REST: GET /dedicated/server/{serviceName}/serviceMonitoring/{monitoringId}/alert/email/{alertId}
@param serviceName [required] The internal name of your dedicated server
@param monitoringId [required] This monitoring id
@param alertId [required] This monitoring id
|
[
"Get",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L2192-L2197
|
ocelotds/ocelot
|
ocelot-web/src/main/java/org/ocelotds/topic/TopicManagerImpl.java
|
TopicManagerImpl.isInconsistenceContext
|
boolean isInconsistenceContext(String topic, Session session) {
return null == topic || null == session || topic.isEmpty();
}
|
java
|
boolean isInconsistenceContext(String topic, Session session) {
return null == topic || null == session || topic.isEmpty();
}
|
[
"boolean",
"isInconsistenceContext",
"(",
"String",
"topic",
",",
"Session",
"session",
")",
"{",
"return",
"null",
"==",
"topic",
"||",
"null",
"==",
"session",
"||",
"topic",
".",
"isEmpty",
"(",
")",
";",
"}"
] |
Return if argument is inconsistent for context : topic and session null or empty
@param topic
@param session
@return
|
[
"Return",
"if",
"argument",
"is",
"inconsistent",
"for",
"context",
":",
"topic",
"and",
"session",
"null",
"or",
"empty"
] |
train
|
https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/topic/TopicManagerImpl.java#L119-L121
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
|
BackendCleanup.truncateInternalProperties
|
private static void truncateInternalProperties(String tableName, Statement ddlStatement, Connection connection) throws SQLException {
try (PreparedStatement preparedStatement = connection.prepareStatement("delete from internal_properties where kee not in (?,?)")) {
preparedStatement.setString(1, InternalProperties.DEFAULT_ORGANIZATION);
preparedStatement.setString(2, InternalProperties.SERVER_ID_CHECKSUM);
preparedStatement.execute();
// commit is useless on some databases
connection.commit();
}
}
|
java
|
private static void truncateInternalProperties(String tableName, Statement ddlStatement, Connection connection) throws SQLException {
try (PreparedStatement preparedStatement = connection.prepareStatement("delete from internal_properties where kee not in (?,?)")) {
preparedStatement.setString(1, InternalProperties.DEFAULT_ORGANIZATION);
preparedStatement.setString(2, InternalProperties.SERVER_ID_CHECKSUM);
preparedStatement.execute();
// commit is useless on some databases
connection.commit();
}
}
|
[
"private",
"static",
"void",
"truncateInternalProperties",
"(",
"String",
"tableName",
",",
"Statement",
"ddlStatement",
",",
"Connection",
"connection",
")",
"throws",
"SQLException",
"{",
"try",
"(",
"PreparedStatement",
"preparedStatement",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"delete from internal_properties where kee not in (?,?)\"",
")",
")",
"{",
"preparedStatement",
".",
"setString",
"(",
"1",
",",
"InternalProperties",
".",
"DEFAULT_ORGANIZATION",
")",
";",
"preparedStatement",
".",
"setString",
"(",
"2",
",",
"InternalProperties",
".",
"SERVER_ID_CHECKSUM",
")",
";",
"preparedStatement",
".",
"execute",
"(",
")",
";",
"// commit is useless on some databases",
"connection",
".",
"commit",
"(",
")",
";",
"}",
"}"
] |
Internal property {@link InternalProperties#DEFAULT_ORGANIZATION} must never be deleted.
|
[
"Internal",
"property",
"{"
] |
train
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java#L232-L240
|
walkmod/walkmod-core
|
src/main/java/org/walkmod/util/location/LocationAttributes.java
|
LocationAttributes.addLocationAttributes
|
public static Attributes addLocationAttributes(Locator locator, Attributes attrs) {
if (locator == null || attrs.getIndex(URI, SRC_ATTR) != -1) {
return attrs;
}
AttributesImpl newAttrs = attrs instanceof AttributesImpl ? (AttributesImpl) attrs : new AttributesImpl(attrs);
return newAttrs;
}
|
java
|
public static Attributes addLocationAttributes(Locator locator, Attributes attrs) {
if (locator == null || attrs.getIndex(URI, SRC_ATTR) != -1) {
return attrs;
}
AttributesImpl newAttrs = attrs instanceof AttributesImpl ? (AttributesImpl) attrs : new AttributesImpl(attrs);
return newAttrs;
}
|
[
"public",
"static",
"Attributes",
"addLocationAttributes",
"(",
"Locator",
"locator",
",",
"Attributes",
"attrs",
")",
"{",
"if",
"(",
"locator",
"==",
"null",
"||",
"attrs",
".",
"getIndex",
"(",
"URI",
",",
"SRC_ATTR",
")",
"!=",
"-",
"1",
")",
"{",
"return",
"attrs",
";",
"}",
"AttributesImpl",
"newAttrs",
"=",
"attrs",
"instanceof",
"AttributesImpl",
"?",
"(",
"AttributesImpl",
")",
"attrs",
":",
"new",
"AttributesImpl",
"(",
"attrs",
")",
";",
"return",
"newAttrs",
";",
"}"
] |
Add location attributes to a set of SAX attributes.
@param locator
the <code>Locator</code> (can be null)
@param attrs
the <code>Attributes</code> where locator information should
be added
@return Location enabled Attributes.
|
[
"Add",
"location",
"attributes",
"to",
"a",
"set",
"of",
"SAX",
"attributes",
"."
] |
train
|
https://github.com/walkmod/walkmod-core/blob/fa79b836894fa00ca4b3e2bd26326a44b778f46f/src/main/java/org/walkmod/util/location/LocationAttributes.java#L67-L74
|
assertthat/selenium-shutterbug
|
src/main/java/com/assertthat/selenium_shutterbug/core/Shutterbug.java
|
Shutterbug.shootPage
|
public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll) {
return shootPage(driver, scroll, DEFAULT_SCROLL_TIMEOUT);
}
|
java
|
public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll) {
return shootPage(driver, scroll, DEFAULT_SCROLL_TIMEOUT);
}
|
[
"public",
"static",
"PageSnapshot",
"shootPage",
"(",
"WebDriver",
"driver",
",",
"ScrollStrategy",
"scroll",
")",
"{",
"return",
"shootPage",
"(",
"driver",
",",
"scroll",
",",
"DEFAULT_SCROLL_TIMEOUT",
")",
";",
"}"
] |
To be used when screen shooting the page
and need to scroll while making screen shots, either vertically or
horizontally or both directions (Chrome).
@param driver WebDriver instance
@param scroll ScrollStrategy How you need to scroll
@return PageSnapshot instance
|
[
"To",
"be",
"used",
"when",
"screen",
"shooting",
"the",
"page",
"and",
"need",
"to",
"scroll",
"while",
"making",
"screen",
"shots",
"either",
"vertically",
"or",
"horizontally",
"or",
"both",
"directions",
"(",
"Chrome",
")",
"."
] |
train
|
https://github.com/assertthat/selenium-shutterbug/blob/770d9b92423200d262c9ab70e40405921d81e262/src/main/java/com/assertthat/selenium_shutterbug/core/Shutterbug.java#L57-L59
|
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/type/TrackedTypeFactory.java
|
TrackedTypeFactory.build
|
public static Type build(final Type type, final Type source) {
if (!TypeUtils.isAssignable(type, source)) {
throw new IllegalArgumentException(String.format(
"Can't track type %s generics because it's not assignable to %s",
TypeToStringUtils.toStringType(type),
TypeToStringUtils.toStringTypeIgnoringVariables(source)));
}
Type res = type;
if (ArrayTypeUtils.isArray(type) && ArrayTypeUtils.isArray(source)) {
// for arrays track actual component types
res = ArrayTypeUtils.toArrayType(
build(ArrayTypeUtils.getArrayComponentType(type), ArrayTypeUtils.getArrayComponentType(source)));
} else {
final Class<?> target = GenericsUtils.resolveClass(type);
// it make sense to track from direct parameterized type or parameterized types inside wildcard
if (target.getTypeParameters().length > 0
&& (source instanceof ParameterizedType || source instanceof WildcardType)) {
// select the most specific generics
final Map<String, Type> generics = resolveGenerics(type, target, source);
// empty generics may appear from wildcard without parameterized types (no source)
if (!generics.isEmpty()) {
res = new ParameterizedTypeImpl(target,
generics.values().toArray(new Type[0]),
// intentionally not tracking owner type as redundant complication
TypeUtils.getOuter(type));
}
}
}
return res;
}
|
java
|
public static Type build(final Type type, final Type source) {
if (!TypeUtils.isAssignable(type, source)) {
throw new IllegalArgumentException(String.format(
"Can't track type %s generics because it's not assignable to %s",
TypeToStringUtils.toStringType(type),
TypeToStringUtils.toStringTypeIgnoringVariables(source)));
}
Type res = type;
if (ArrayTypeUtils.isArray(type) && ArrayTypeUtils.isArray(source)) {
// for arrays track actual component types
res = ArrayTypeUtils.toArrayType(
build(ArrayTypeUtils.getArrayComponentType(type), ArrayTypeUtils.getArrayComponentType(source)));
} else {
final Class<?> target = GenericsUtils.resolveClass(type);
// it make sense to track from direct parameterized type or parameterized types inside wildcard
if (target.getTypeParameters().length > 0
&& (source instanceof ParameterizedType || source instanceof WildcardType)) {
// select the most specific generics
final Map<String, Type> generics = resolveGenerics(type, target, source);
// empty generics may appear from wildcard without parameterized types (no source)
if (!generics.isEmpty()) {
res = new ParameterizedTypeImpl(target,
generics.values().toArray(new Type[0]),
// intentionally not tracking owner type as redundant complication
TypeUtils.getOuter(type));
}
}
}
return res;
}
|
[
"public",
"static",
"Type",
"build",
"(",
"final",
"Type",
"type",
",",
"final",
"Type",
"source",
")",
"{",
"if",
"(",
"!",
"TypeUtils",
".",
"isAssignable",
"(",
"type",
",",
"source",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Can't track type %s generics because it's not assignable to %s\"",
",",
"TypeToStringUtils",
".",
"toStringType",
"(",
"type",
")",
",",
"TypeToStringUtils",
".",
"toStringTypeIgnoringVariables",
"(",
"source",
")",
")",
")",
";",
"}",
"Type",
"res",
"=",
"type",
";",
"if",
"(",
"ArrayTypeUtils",
".",
"isArray",
"(",
"type",
")",
"&&",
"ArrayTypeUtils",
".",
"isArray",
"(",
"source",
")",
")",
"{",
"// for arrays track actual component types",
"res",
"=",
"ArrayTypeUtils",
".",
"toArrayType",
"(",
"build",
"(",
"ArrayTypeUtils",
".",
"getArrayComponentType",
"(",
"type",
")",
",",
"ArrayTypeUtils",
".",
"getArrayComponentType",
"(",
"source",
")",
")",
")",
";",
"}",
"else",
"{",
"final",
"Class",
"<",
"?",
">",
"target",
"=",
"GenericsUtils",
".",
"resolveClass",
"(",
"type",
")",
";",
"// it make sense to track from direct parameterized type or parameterized types inside wildcard",
"if",
"(",
"target",
".",
"getTypeParameters",
"(",
")",
".",
"length",
">",
"0",
"&&",
"(",
"source",
"instanceof",
"ParameterizedType",
"||",
"source",
"instanceof",
"WildcardType",
")",
")",
"{",
"// select the most specific generics",
"final",
"Map",
"<",
"String",
",",
"Type",
">",
"generics",
"=",
"resolveGenerics",
"(",
"type",
",",
"target",
",",
"source",
")",
";",
"// empty generics may appear from wildcard without parameterized types (no source)",
"if",
"(",
"!",
"generics",
".",
"isEmpty",
"(",
")",
")",
"{",
"res",
"=",
"new",
"ParameterizedTypeImpl",
"(",
"target",
",",
"generics",
".",
"values",
"(",
")",
".",
"toArray",
"(",
"new",
"Type",
"[",
"0",
"]",
")",
",",
"// intentionally not tracking owner type as redundant complication",
"TypeUtils",
".",
"getOuter",
"(",
"type",
")",
")",
";",
"}",
"}",
"}",
"return",
"res",
";",
"}"
] |
Sub type must be either {@link ParameterizedType} or {@link WildcardType} containing parameterized types,
because otherwise tracking is impossible (no source to track from) and so orignial type is simply returned as is.
<p>
In case of arrays, internal components are directly compared.
@param type type to track generics for
@param source type to track generics from (middle type)
@return improved type or original type itself if nothing to track
@throws IllegalArgumentException if type is not assignable for provided sub type
|
[
"Sub",
"type",
"must",
"be",
"either",
"{",
"@link",
"ParameterizedType",
"}",
"or",
"{",
"@link",
"WildcardType",
"}",
"containing",
"parameterized",
"types",
"because",
"otherwise",
"tracking",
"is",
"impossible",
"(",
"no",
"source",
"to",
"track",
"from",
")",
"and",
"so",
"orignial",
"type",
"is",
"simply",
"returned",
"as",
"is",
".",
"<p",
">",
"In",
"case",
"of",
"arrays",
"internal",
"components",
"are",
"directly",
"compared",
"."
] |
train
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/type/TrackedTypeFactory.java#L39-L72
|
samskivert/pythagoras
|
src/main/java/pythagoras/f/Matrix4.java
|
Matrix4.setToRotation
|
public Matrix4 setToRotation (float angle, IVector3 axis) {
return setToRotation(angle, axis.x(), axis.y(), axis.z());
}
|
java
|
public Matrix4 setToRotation (float angle, IVector3 axis) {
return setToRotation(angle, axis.x(), axis.y(), axis.z());
}
|
[
"public",
"Matrix4",
"setToRotation",
"(",
"float",
"angle",
",",
"IVector3",
"axis",
")",
"{",
"return",
"setToRotation",
"(",
"angle",
",",
"axis",
".",
"x",
"(",
")",
",",
"axis",
".",
"y",
"(",
")",
",",
"axis",
".",
"z",
"(",
")",
")",
";",
"}"
] |
Sets this to a rotation matrix.
@return a reference to this matrix, for chaining.
|
[
"Sets",
"this",
"to",
"a",
"rotation",
"matrix",
"."
] |
train
|
https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/f/Matrix4.java#L202-L204
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java
|
JsonUtil.getFloat
|
public static float getFloat(JsonObject object, String field, float defaultValue) {
final JsonValue value = object.get(field);
if (value == null || value.isNull()) {
return defaultValue;
} else {
return value.asFloat();
}
}
|
java
|
public static float getFloat(JsonObject object, String field, float defaultValue) {
final JsonValue value = object.get(field);
if (value == null || value.isNull()) {
return defaultValue;
} else {
return value.asFloat();
}
}
|
[
"public",
"static",
"float",
"getFloat",
"(",
"JsonObject",
"object",
",",
"String",
"field",
",",
"float",
"defaultValue",
")",
"{",
"final",
"JsonValue",
"value",
"=",
"object",
".",
"get",
"(",
"field",
")",
";",
"if",
"(",
"value",
"==",
"null",
"||",
"value",
".",
"isNull",
"(",
")",
")",
"{",
"return",
"defaultValue",
";",
"}",
"else",
"{",
"return",
"value",
".",
"asFloat",
"(",
")",
";",
"}",
"}"
] |
Returns a field in a Json object as a float.
@param object the Json Object
@param field the field in the Json object to return
@param defaultValue a default value for the field if the field value is null
@return the Json field value as a float
|
[
"Returns",
"a",
"field",
"in",
"a",
"Json",
"object",
"as",
"a",
"float",
"."
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/util/JsonUtil.java#L151-L158
|
alkacon/opencms-core
|
src/org/opencms/ade/upload/CmsUploadService.java
|
CmsUploadService.isDeletedResource
|
private boolean isDeletedResource(String path, boolean rootPath) {
CmsObject cms = getCmsObject();
CmsResource res = null;
try {
if (rootPath) {
String origSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot("");
res = cms.readResource(path, CmsResourceFilter.ALL);
} finally {
cms.getRequestContext().setSiteRoot(origSiteRoot);
}
} else {
res = cms.readResource(path, CmsResourceFilter.ALL);
}
} catch (CmsException e) {
// ignore
}
return (res != null) && res.getState().isDeleted();
}
|
java
|
private boolean isDeletedResource(String path, boolean rootPath) {
CmsObject cms = getCmsObject();
CmsResource res = null;
try {
if (rootPath) {
String origSiteRoot = cms.getRequestContext().getSiteRoot();
try {
cms.getRequestContext().setSiteRoot("");
res = cms.readResource(path, CmsResourceFilter.ALL);
} finally {
cms.getRequestContext().setSiteRoot(origSiteRoot);
}
} else {
res = cms.readResource(path, CmsResourceFilter.ALL);
}
} catch (CmsException e) {
// ignore
}
return (res != null) && res.getState().isDeleted();
}
|
[
"private",
"boolean",
"isDeletedResource",
"(",
"String",
"path",
",",
"boolean",
"rootPath",
")",
"{",
"CmsObject",
"cms",
"=",
"getCmsObject",
"(",
")",
";",
"CmsResource",
"res",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"rootPath",
")",
"{",
"String",
"origSiteRoot",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getSiteRoot",
"(",
")",
";",
"try",
"{",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"\"\"",
")",
";",
"res",
"=",
"cms",
".",
"readResource",
"(",
"path",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"}",
"finally",
"{",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setSiteRoot",
"(",
"origSiteRoot",
")",
";",
"}",
"}",
"else",
"{",
"res",
"=",
"cms",
".",
"readResource",
"(",
"path",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"}",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"// ignore",
"}",
"return",
"(",
"res",
"!=",
"null",
")",
"&&",
"res",
".",
"getState",
"(",
")",
".",
"isDeleted",
"(",
")",
";",
"}"
] |
Checks if a the resource exists but is marked as deleted.<p>
@param path the path
@param rootPath in case the path is a root path
@return true is the resource exists but is marked as deleted
|
[
"Checks",
"if",
"a",
"the",
"resource",
"exists",
"but",
"is",
"marked",
"as",
"deleted",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/upload/CmsUploadService.java#L169-L190
|
vakinge/jeesuite-libs
|
jeesuite-common/src/main/java/com/jeesuite/common/util/DateUtils.java
|
DateUtils.formatDateStr
|
public static String formatDateStr(String dateStr, String... patterns) {
String pattern = TIMESTAMP_PATTERN;
if (patterns != null && patterns.length > 0
&& StringUtils.isNotBlank(patterns[0])) {
pattern = patterns[0];
}
return DateFormatUtils.format(parseDate(dateStr), pattern);
}
|
java
|
public static String formatDateStr(String dateStr, String... patterns) {
String pattern = TIMESTAMP_PATTERN;
if (patterns != null && patterns.length > 0
&& StringUtils.isNotBlank(patterns[0])) {
pattern = patterns[0];
}
return DateFormatUtils.format(parseDate(dateStr), pattern);
}
|
[
"public",
"static",
"String",
"formatDateStr",
"(",
"String",
"dateStr",
",",
"String",
"...",
"patterns",
")",
"{",
"String",
"pattern",
"=",
"TIMESTAMP_PATTERN",
";",
"if",
"(",
"patterns",
"!=",
"null",
"&&",
"patterns",
".",
"length",
">",
"0",
"&&",
"StringUtils",
".",
"isNotBlank",
"(",
"patterns",
"[",
"0",
"]",
")",
")",
"{",
"pattern",
"=",
"patterns",
"[",
"0",
"]",
";",
"}",
"return",
"DateFormatUtils",
".",
"format",
"(",
"parseDate",
"(",
"dateStr",
")",
",",
"pattern",
")",
";",
"}"
] |
格式化日期字符串<br>
generate by: vakin jiang at 2012-3-7
@param dateStr
@param patterns
@return
|
[
"格式化日期字符串<br",
">",
"generate",
"by",
":",
"vakin",
"jiang",
"at",
"2012",
"-",
"3",
"-",
"7"
] |
train
|
https://github.com/vakinge/jeesuite-libs/blob/c48fe2c7fbd294892cf4030dbec96e744dd3e386/jeesuite-common/src/main/java/com/jeesuite/common/util/DateUtils.java#L159-L166
|
fommil/matrix-toolkits-java
|
src/main/java/no/uib/cipr/matrix/io/MatrixVectorWriter.java
|
MatrixVectorWriter.printCoordinate
|
public void printCoordinate(int[] row, int[] column, long[] data, int offset) {
int size = row.length;
if (size != column.length || size != data.length)
throw new IllegalArgumentException(
"All arrays must be of the same size");
for (int i = 0; i < size; ++i)
format(Locale.ENGLISH, "%10d %10d %19d%n", row[i] + offset,
column[i] + offset, data[i]);
}
|
java
|
public void printCoordinate(int[] row, int[] column, long[] data, int offset) {
int size = row.length;
if (size != column.length || size != data.length)
throw new IllegalArgumentException(
"All arrays must be of the same size");
for (int i = 0; i < size; ++i)
format(Locale.ENGLISH, "%10d %10d %19d%n", row[i] + offset,
column[i] + offset, data[i]);
}
|
[
"public",
"void",
"printCoordinate",
"(",
"int",
"[",
"]",
"row",
",",
"int",
"[",
"]",
"column",
",",
"long",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"{",
"int",
"size",
"=",
"row",
".",
"length",
";",
"if",
"(",
"size",
"!=",
"column",
".",
"length",
"||",
"size",
"!=",
"data",
".",
"length",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"All arrays must be of the same size\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"++",
"i",
")",
"format",
"(",
"Locale",
".",
"ENGLISH",
"",
",",
"\"%10d %10d %19d%n\"",
",",
"row",
"[",
"i",
"]",
"+",
"offset",
",",
"column",
"[",
"i",
"]",
"+",
"offset",
",",
"data",
"[",
"i",
"]",
")",
";",
"}"
] |
Prints the coordinate format to the underlying stream. One index pair and
entry on each line. The offset is added to each index, typically, this
can transform from a 0-based indicing to a 1-based.
|
[
"Prints",
"the",
"coordinate",
"format",
"to",
"the",
"underlying",
"stream",
".",
"One",
"index",
"pair",
"and",
"entry",
"on",
"each",
"line",
".",
"The",
"offset",
"is",
"added",
"to",
"each",
"index",
"typically",
"this",
"can",
"transform",
"from",
"a",
"0",
"-",
"based",
"indicing",
"to",
"a",
"1",
"-",
"based",
"."
] |
train
|
https://github.com/fommil/matrix-toolkits-java/blob/6157618bc86bcda3749af2a60bf869d8f3292960/src/main/java/no/uib/cipr/matrix/io/MatrixVectorWriter.java#L370-L378
|
apiman/apiman
|
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
|
AuditUtils.organizationCreated
|
public static AuditEntryBean organizationCreated(OrganizationBean bean, ISecurityContext securityContext) {
AuditEntryBean entry = newEntry(bean.getId(), AuditEntityType.Organization, securityContext);
entry.setEntityId(null);
entry.setEntityVersion(null);
entry.setWhat(AuditEntryType.Create);
return entry;
}
|
java
|
public static AuditEntryBean organizationCreated(OrganizationBean bean, ISecurityContext securityContext) {
AuditEntryBean entry = newEntry(bean.getId(), AuditEntityType.Organization, securityContext);
entry.setEntityId(null);
entry.setEntityVersion(null);
entry.setWhat(AuditEntryType.Create);
return entry;
}
|
[
"public",
"static",
"AuditEntryBean",
"organizationCreated",
"(",
"OrganizationBean",
"bean",
",",
"ISecurityContext",
"securityContext",
")",
"{",
"AuditEntryBean",
"entry",
"=",
"newEntry",
"(",
"bean",
".",
"getId",
"(",
")",
",",
"AuditEntityType",
".",
"Organization",
",",
"securityContext",
")",
";",
"entry",
".",
"setEntityId",
"(",
"null",
")",
";",
"entry",
".",
"setEntityVersion",
"(",
"null",
")",
";",
"entry",
".",
"setWhat",
"(",
"AuditEntryType",
".",
"Create",
")",
";",
"return",
"entry",
";",
"}"
] |
Creates an {@link AuditEntryBean} for the 'organization created' event.
@param bean the bean
@param securityContext the security context
@return the audit entry
|
[
"Creates",
"an",
"{"
] |
train
|
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L188-L194
|
kite-sdk/kite
|
kite-data/kite-data-core/src/main/java/org/kitesdk/data/spi/Compatibility.java
|
Compatibility.checkAndWarn
|
public static void checkAndWarn(String namespace, String datasetName, Schema schema) {
try {
checkDatasetName(namespace, datasetName);
checkSchema(schema);
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage());
} catch (IllegalStateException e) {
LOG.warn(e.getMessage());
}
}
|
java
|
public static void checkAndWarn(String namespace, String datasetName, Schema schema) {
try {
checkDatasetName(namespace, datasetName);
checkSchema(schema);
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage());
} catch (IllegalStateException e) {
LOG.warn(e.getMessage());
}
}
|
[
"public",
"static",
"void",
"checkAndWarn",
"(",
"String",
"namespace",
",",
"String",
"datasetName",
",",
"Schema",
"schema",
")",
"{",
"try",
"{",
"checkDatasetName",
"(",
"namespace",
",",
"datasetName",
")",
";",
"checkSchema",
"(",
"schema",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Checks the name and schema for known compatibility issues and warns.
If the column names are not compatible across components, this will warn
the user.
@param namespace a String namespace
@param datasetName a String dataset name
@param schema a {@link Schema}
|
[
"Checks",
"the",
"name",
"and",
"schema",
"for",
"known",
"compatibility",
"issues",
"and",
"warns",
"."
] |
train
|
https://github.com/kite-sdk/kite/blob/72bfb4b1a881af85808cd7f14bc3e15160a1e811/kite-data/kite-data-core/src/main/java/org/kitesdk/data/spi/Compatibility.java#L82-L91
|
cybazeitalia/emaze-dysfunctional
|
src/main/java/net/emaze/dysfunctional/ranges/Densify.java
|
Densify.canBeMerged
|
private boolean canBeMerged(DenseRange<T> current, DenseRange<T> next) {
return Order.of(comparator, current.end(), Optional.of(next.begin())) == Order.EQ || current.overlaps(next);
}
|
java
|
private boolean canBeMerged(DenseRange<T> current, DenseRange<T> next) {
return Order.of(comparator, current.end(), Optional.of(next.begin())) == Order.EQ || current.overlaps(next);
}
|
[
"private",
"boolean",
"canBeMerged",
"(",
"DenseRange",
"<",
"T",
">",
"current",
",",
"DenseRange",
"<",
"T",
">",
"next",
")",
"{",
"return",
"Order",
".",
"of",
"(",
"comparator",
",",
"current",
".",
"end",
"(",
")",
",",
"Optional",
".",
"of",
"(",
"next",
".",
"begin",
"(",
")",
")",
")",
"==",
"Order",
".",
"EQ",
"||",
"current",
".",
"overlaps",
"(",
"next",
")",
";",
"}"
] |
<code>
|-----------|
|-----|
</code> or
<code>
|-----------|
|------|
</code>
@param current the current range
@param next the next range
@return true if the two ranges can be merged
|
[
"<code",
">",
"|",
"-----------",
"|",
"|",
"-----",
"|",
"<",
"/",
"code",
">",
"or",
"<code",
">",
"|",
"-----------",
"|",
"|",
"------",
"|",
"<",
"/",
"code",
">"
] |
train
|
https://github.com/cybazeitalia/emaze-dysfunctional/blob/98115a436e35335c5e8831f9fdc12f6d93d524be/src/main/java/net/emaze/dysfunctional/ranges/Densify.java#L72-L74
|
NoraUi/NoraUi
|
src/main/java/com/github/noraui/application/steps/Step.java
|
Step.checkElementPresence
|
protected void checkElementPresence(PageElement pageElement, boolean present) throws FailureException {
if (present) {
try {
Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(pageElement)));
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, pageElement.getPage().getCallBack());
}
} else {
try {
Context.waitUntil(ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(Utilities.getLocator(pageElement))));
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.getMessage(Messages.FAIL_MESSAGE_ELEMENT_STILL_VISIBLE), true, pageElement.getPage().getCallBack());
}
}
}
|
java
|
protected void checkElementPresence(PageElement pageElement, boolean present) throws FailureException {
if (present) {
try {
Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(pageElement)));
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, pageElement.getPage().getCallBack());
}
} else {
try {
Context.waitUntil(ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(Utilities.getLocator(pageElement))));
} catch (final Exception e) {
new Result.Failure<>(e.getMessage(), Messages.getMessage(Messages.FAIL_MESSAGE_ELEMENT_STILL_VISIBLE), true, pageElement.getPage().getCallBack());
}
}
}
|
[
"protected",
"void",
"checkElementPresence",
"(",
"PageElement",
"pageElement",
",",
"boolean",
"present",
")",
"throws",
"FailureException",
"{",
"if",
"(",
"present",
")",
"{",
"try",
"{",
"Context",
".",
"waitUntil",
"(",
"ExpectedConditions",
".",
"presenceOfElementLocated",
"(",
"Utilities",
".",
"getLocator",
"(",
"pageElement",
")",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"new",
"Result",
".",
"Failure",
"<>",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"Messages",
".",
"getMessage",
"(",
"Messages",
".",
"FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT",
")",
",",
"true",
",",
"pageElement",
".",
"getPage",
"(",
")",
".",
"getCallBack",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"Context",
".",
"waitUntil",
"(",
"ExpectedConditions",
".",
"not",
"(",
"ExpectedConditions",
".",
"presenceOfAllElementsLocatedBy",
"(",
"Utilities",
".",
"getLocator",
"(",
"pageElement",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"new",
"Result",
".",
"Failure",
"<>",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"Messages",
".",
"getMessage",
"(",
"Messages",
".",
"FAIL_MESSAGE_ELEMENT_STILL_VISIBLE",
")",
",",
"true",
",",
"pageElement",
".",
"getPage",
"(",
")",
".",
"getCallBack",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Checks if an html element (PageElement) is displayed.
@param pageElement
Is target element
@param present
Is target element supposed to be present
@throws FailureException
if the scenario encounters a functional error. Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT} message
(with screenshot, with exception)
|
[
"Checks",
"if",
"an",
"html",
"element",
"(",
"PageElement",
")",
"is",
"displayed",
"."
] |
train
|
https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/application/steps/Step.java#L426-L440
|
lessthanoptimal/ejml
|
main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java
|
NormOps_DDRM.fastElementP
|
public static double fastElementP(DMatrixD1 A , double p ) {
if( p == 2 ) {
return fastNormF(A);
} else {
double total = 0;
int size = A.getNumElements();
for( int i = 0; i < size; i++ ) {
double a = A.get(i);
total += Math.pow(Math.abs(a),p);
}
return Math.pow(total,1.0/p);
}
}
|
java
|
public static double fastElementP(DMatrixD1 A , double p ) {
if( p == 2 ) {
return fastNormF(A);
} else {
double total = 0;
int size = A.getNumElements();
for( int i = 0; i < size; i++ ) {
double a = A.get(i);
total += Math.pow(Math.abs(a),p);
}
return Math.pow(total,1.0/p);
}
}
|
[
"public",
"static",
"double",
"fastElementP",
"(",
"DMatrixD1",
"A",
",",
"double",
"p",
")",
"{",
"if",
"(",
"p",
"==",
"2",
")",
"{",
"return",
"fastNormF",
"(",
"A",
")",
";",
"}",
"else",
"{",
"double",
"total",
"=",
"0",
";",
"int",
"size",
"=",
"A",
".",
"getNumElements",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"double",
"a",
"=",
"A",
".",
"get",
"(",
"i",
")",
";",
"total",
"+=",
"Math",
".",
"pow",
"(",
"Math",
".",
"abs",
"(",
"a",
")",
",",
"p",
")",
";",
"}",
"return",
"Math",
".",
"pow",
"(",
"total",
",",
"1.0",
"/",
"p",
")",
";",
"}",
"}"
] |
Same as {@link #elementP} but runs faster by not mitigating overflow/underflow related problems.
@param A Matrix. Not modified.
@param p p value.
@return The norm's value.
|
[
"Same",
"as",
"{",
"@link",
"#elementP",
"}",
"but",
"runs",
"faster",
"by",
"not",
"mitigating",
"overflow",
"/",
"underflow",
"related",
"problems",
"."
] |
train
|
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/NormOps_DDRM.java#L259-L275
|
bazaarvoice/emodb
|
event/src/main/java/com/bazaarvoice/emodb/event/db/astyanax/AstyanaxEventId.java
|
AstyanaxEventId.computeChecksum
|
private static int computeChecksum(byte[] buf, int offset, int length, String channel) {
Hasher hasher = Hashing.murmur3_32().newHasher();
hasher.putBytes(buf, offset, length);
hasher.putUnencodedChars(channel);
return hasher.hash().asInt() & 0xffff;
}
|
java
|
private static int computeChecksum(byte[] buf, int offset, int length, String channel) {
Hasher hasher = Hashing.murmur3_32().newHasher();
hasher.putBytes(buf, offset, length);
hasher.putUnencodedChars(channel);
return hasher.hash().asInt() & 0xffff;
}
|
[
"private",
"static",
"int",
"computeChecksum",
"(",
"byte",
"[",
"]",
"buf",
",",
"int",
"offset",
",",
"int",
"length",
",",
"String",
"channel",
")",
"{",
"Hasher",
"hasher",
"=",
"Hashing",
".",
"murmur3_32",
"(",
")",
".",
"newHasher",
"(",
")",
";",
"hasher",
".",
"putBytes",
"(",
"buf",
",",
"offset",
",",
"length",
")",
";",
"hasher",
".",
"putUnencodedChars",
"(",
"channel",
")",
";",
"return",
"hasher",
".",
"hash",
"(",
")",
".",
"asInt",
"(",
")",
"&",
"0xffff",
";",
"}"
] |
Computes a 16-bit checksum of the contents of the specific ByteBuffer and channel name.
|
[
"Computes",
"a",
"16",
"-",
"bit",
"checksum",
"of",
"the",
"contents",
"of",
"the",
"specific",
"ByteBuffer",
"and",
"channel",
"name",
"."
] |
train
|
https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/event/src/main/java/com/bazaarvoice/emodb/event/db/astyanax/AstyanaxEventId.java#L75-L80
|
jbundle/jbundle
|
thin/base/screen/util-misc/src/main/java/org/jbundle/thin/base/screen/util/html/JHtmlView.java
|
JHtmlView.linkActivated
|
public void linkActivated(URL url, BaseApplet applet, int iOptions)
{
m_editorPane.linkActivated(url, applet, iOptions);
}
|
java
|
public void linkActivated(URL url, BaseApplet applet, int iOptions)
{
m_editorPane.linkActivated(url, applet, iOptions);
}
|
[
"public",
"void",
"linkActivated",
"(",
"URL",
"url",
",",
"BaseApplet",
"applet",
",",
"int",
"iOptions",
")",
"{",
"m_editorPane",
".",
"linkActivated",
"(",
"url",
",",
"applet",
",",
"iOptions",
")",
";",
"}"
] |
Follows the reference in an
link. The given url is the requested reference.
By default this calls <a href="#setPage">setPage</a>,
and if an exception is thrown the original previous
document is restored and a beep sounded. If an
attempt was made to follow a link, but it represented
a malformed url, this method will be called with a
null argument.
@param url the URL to follow
|
[
"Follows",
"the",
"reference",
"in",
"an",
"link",
".",
"The",
"given",
"url",
"is",
"the",
"requested",
"reference",
".",
"By",
"default",
"this",
"calls",
"<a",
"href",
"=",
"#setPage",
">",
"setPage<",
"/",
"a",
">",
"and",
"if",
"an",
"exception",
"is",
"thrown",
"the",
"original",
"previous",
"document",
"is",
"restored",
"and",
"a",
"beep",
"sounded",
".",
"If",
"an",
"attempt",
"was",
"made",
"to",
"follow",
"a",
"link",
"but",
"it",
"represented",
"a",
"malformed",
"url",
"this",
"method",
"will",
"be",
"called",
"with",
"a",
"null",
"argument",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/util-misc/src/main/java/org/jbundle/thin/base/screen/util/html/JHtmlView.java#L225-L228
|
google/identity-toolkit-java-client
|
src/main/java/com/google/identitytoolkit/GitkitClient.java
|
GitkitClient.getOobResponse
|
public OobResponse getOobResponse(HttpServletRequest req)
throws GitkitServerException {
String gitkitToken = lookupCookie(req, cookieName);
return getOobResponse(req, gitkitToken);
}
|
java
|
public OobResponse getOobResponse(HttpServletRequest req)
throws GitkitServerException {
String gitkitToken = lookupCookie(req, cookieName);
return getOobResponse(req, gitkitToken);
}
|
[
"public",
"OobResponse",
"getOobResponse",
"(",
"HttpServletRequest",
"req",
")",
"throws",
"GitkitServerException",
"{",
"String",
"gitkitToken",
"=",
"lookupCookie",
"(",
"req",
",",
"cookieName",
")",
";",
"return",
"getOobResponse",
"(",
"req",
",",
"gitkitToken",
")",
";",
"}"
] |
Gets out-of-band response. Used by oob endpoint for ResetPassword and ChangeEmail operation.
The web site needs to send user an email containing the oobUrl in the response. The user needs
to click the oobUrl to finish the operation.
@param req http request for the oob endpoint
@return the oob response.
@throws GitkitServerException
|
[
"Gets",
"out",
"-",
"of",
"-",
"band",
"response",
".",
"Used",
"by",
"oob",
"endpoint",
"for",
"ResetPassword",
"and",
"ChangeEmail",
"operation",
".",
"The",
"web",
"site",
"needs",
"to",
"send",
"user",
"an",
"email",
"containing",
"the",
"oobUrl",
"in",
"the",
"response",
".",
"The",
"user",
"needs",
"to",
"click",
"the",
"oobUrl",
"to",
"finish",
"the",
"operation",
"."
] |
train
|
https://github.com/google/identity-toolkit-java-client/blob/61dda1aabbd541ad5e431e840fd266bfca5f8a4a/src/main/java/com/google/identitytoolkit/GitkitClient.java#L444-L448
|
BranchMetrics/android-branch-deep-linking
|
Branch-SDK/src/io/branch/referral/Branch.java
|
Branch.getCreditHistory
|
public void getCreditHistory(final String bucket, final String afterId, final int length,
@NonNull final CreditHistoryOrder order, BranchListResponseListener callback) {
ServerRequest req = new ServerRequestGetRewardHistory(context_, bucket, afterId, length, order, callback);
if (!req.constructError_ && !req.handleErrors(context_)) {
handleNewRequest(req);
}
}
|
java
|
public void getCreditHistory(final String bucket, final String afterId, final int length,
@NonNull final CreditHistoryOrder order, BranchListResponseListener callback) {
ServerRequest req = new ServerRequestGetRewardHistory(context_, bucket, afterId, length, order, callback);
if (!req.constructError_ && !req.handleErrors(context_)) {
handleNewRequest(req);
}
}
|
[
"public",
"void",
"getCreditHistory",
"(",
"final",
"String",
"bucket",
",",
"final",
"String",
"afterId",
",",
"final",
"int",
"length",
",",
"@",
"NonNull",
"final",
"CreditHistoryOrder",
"order",
",",
"BranchListResponseListener",
"callback",
")",
"{",
"ServerRequest",
"req",
"=",
"new",
"ServerRequestGetRewardHistory",
"(",
"context_",
",",
"bucket",
",",
"afterId",
",",
"length",
",",
"order",
",",
"callback",
")",
";",
"if",
"(",
"!",
"req",
".",
"constructError_",
"&&",
"!",
"req",
".",
"handleErrors",
"(",
"context_",
")",
")",
"{",
"handleNewRequest",
"(",
"req",
")",
";",
"}",
"}"
] |
<p>Gets the credit history of the specified bucket and triggers a callback to handle the
response.</p>
@param bucket A {@link String} value containing the name of the referral bucket that the
code will belong to.
@param afterId A {@link String} value containing the ID of the history record to begin after.
This allows for a partial history to be retrieved, rather than the entire
credit history of the bucket.
@param length A {@link Integer} value containing the number of credit history records to
return.
@param order A {@link CreditHistoryOrder} object indicating which order the results should
be returned in.
<p>Valid choices:</p>
<ul>
<li>{@link CreditHistoryOrder#kMostRecentFirst}</li>
<li>{@link CreditHistoryOrder#kLeastRecentFirst}</li>
</ul>
@param callback A {@link BranchListResponseListener} callback instance that will trigger
actions defined therein upon receipt of a response to a create link request.
|
[
"<p",
">",
"Gets",
"the",
"credit",
"history",
"of",
"the",
"specified",
"bucket",
"and",
"triggers",
"a",
"callback",
"to",
"handle",
"the",
"response",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/BranchMetrics/android-branch-deep-linking/blob/e3bee2ccfcbf6d4bf1a5815b5b86666e4ff8f848/Branch-SDK/src/io/branch/referral/Branch.java#L1994-L2000
|
javagl/Common
|
src/main/java/de/javagl/common/xml/XmlUtils.java
|
XmlUtils.getFirstChild
|
public static Node getFirstChild(Node node, String childNodeName)
{
NodeList childNodes = node.getChildNodes();
for (int i=0; i<childNodes.getLength(); i++)
{
Node child = childNodes.item(i);
String childName = child.getNodeName();
if (childName.equalsIgnoreCase(childNodeName))
{
return child;
}
}
return null;
}
|
java
|
public static Node getFirstChild(Node node, String childNodeName)
{
NodeList childNodes = node.getChildNodes();
for (int i=0; i<childNodes.getLength(); i++)
{
Node child = childNodes.item(i);
String childName = child.getNodeName();
if (childName.equalsIgnoreCase(childNodeName))
{
return child;
}
}
return null;
}
|
[
"public",
"static",
"Node",
"getFirstChild",
"(",
"Node",
"node",
",",
"String",
"childNodeName",
")",
"{",
"NodeList",
"childNodes",
"=",
"node",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"childNodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"child",
"=",
"childNodes",
".",
"item",
"(",
"i",
")",
";",
"String",
"childName",
"=",
"child",
".",
"getNodeName",
"(",
")",
";",
"if",
"(",
"childName",
".",
"equalsIgnoreCase",
"(",
"childNodeName",
")",
")",
"{",
"return",
"child",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the first child of the given node with the given name (ignoring
upper/lower case), or <code>null</code> if no such child is found.
@param node The node
@param childNodeName The child node name
@return The child with the given name, or <code>null</code>
|
[
"Returns",
"the",
"first",
"child",
"of",
"the",
"given",
"node",
"with",
"the",
"given",
"name",
"(",
"ignoring",
"upper",
"/",
"lower",
"case",
")",
"or",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"no",
"such",
"child",
"is",
"found",
"."
] |
train
|
https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/xml/XmlUtils.java#L388-L401
|
lessthanoptimal/BoofCV
|
main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java
|
FactoryPointTracker.combined_ST_SURF_KLT
|
public static <I extends ImageGray<I>, D extends ImageGray<D>>
PointTracker<I> combined_ST_SURF_KLT(ConfigGeneralDetector configExtract,
PkltConfig kltConfig,
int reactivateThreshold,
ConfigSurfDescribe.Stability configDescribe,
ConfigSlidingIntegral configOrientation,
Class<I> imageType,
@Nullable Class<D> derivType) {
if( derivType == null )
derivType = GImageDerivativeOps.getDerivativeType(imageType);
GeneralFeatureDetector<I, D> corner = createShiTomasi(configExtract, derivType);
InterestPointDetector<I> detector = FactoryInterestPoint.wrapPoint(corner, 1, imageType, derivType);
DescribeRegionPoint<I,BrightFeature> regionDesc
= FactoryDescribeRegionPoint.surfStable(configDescribe, imageType);
ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.scoreEuclidean(TupleDesc_F64.class, true);
AssociateSurfBasic assoc = new AssociateSurfBasic(FactoryAssociation.greedy(score, 100000, true));
AssociateDescription<BrightFeature> generalAssoc = new WrapAssociateSurfBasic(assoc);
OrientationImage<I> orientation = null;
if( configOrientation != null ) {
Class integralType = GIntegralImageOps.getIntegralType(imageType);
OrientationIntegral orientationII = FactoryOrientationAlgs.sliding_ii(configOrientation, integralType);
orientation = FactoryOrientation.convertImage(orientationII,imageType);
}
return combined(detector,orientation,regionDesc,generalAssoc, kltConfig,reactivateThreshold,
imageType);
}
|
java
|
public static <I extends ImageGray<I>, D extends ImageGray<D>>
PointTracker<I> combined_ST_SURF_KLT(ConfigGeneralDetector configExtract,
PkltConfig kltConfig,
int reactivateThreshold,
ConfigSurfDescribe.Stability configDescribe,
ConfigSlidingIntegral configOrientation,
Class<I> imageType,
@Nullable Class<D> derivType) {
if( derivType == null )
derivType = GImageDerivativeOps.getDerivativeType(imageType);
GeneralFeatureDetector<I, D> corner = createShiTomasi(configExtract, derivType);
InterestPointDetector<I> detector = FactoryInterestPoint.wrapPoint(corner, 1, imageType, derivType);
DescribeRegionPoint<I,BrightFeature> regionDesc
= FactoryDescribeRegionPoint.surfStable(configDescribe, imageType);
ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.scoreEuclidean(TupleDesc_F64.class, true);
AssociateSurfBasic assoc = new AssociateSurfBasic(FactoryAssociation.greedy(score, 100000, true));
AssociateDescription<BrightFeature> generalAssoc = new WrapAssociateSurfBasic(assoc);
OrientationImage<I> orientation = null;
if( configOrientation != null ) {
Class integralType = GIntegralImageOps.getIntegralType(imageType);
OrientationIntegral orientationII = FactoryOrientationAlgs.sliding_ii(configOrientation, integralType);
orientation = FactoryOrientation.convertImage(orientationII,imageType);
}
return combined(detector,orientation,regionDesc,generalAssoc, kltConfig,reactivateThreshold,
imageType);
}
|
[
"public",
"static",
"<",
"I",
"extends",
"ImageGray",
"<",
"I",
">",
",",
"D",
"extends",
"ImageGray",
"<",
"D",
">",
">",
"PointTracker",
"<",
"I",
">",
"combined_ST_SURF_KLT",
"(",
"ConfigGeneralDetector",
"configExtract",
",",
"PkltConfig",
"kltConfig",
",",
"int",
"reactivateThreshold",
",",
"ConfigSurfDescribe",
".",
"Stability",
"configDescribe",
",",
"ConfigSlidingIntegral",
"configOrientation",
",",
"Class",
"<",
"I",
">",
"imageType",
",",
"@",
"Nullable",
"Class",
"<",
"D",
">",
"derivType",
")",
"{",
"if",
"(",
"derivType",
"==",
"null",
")",
"derivType",
"=",
"GImageDerivativeOps",
".",
"getDerivativeType",
"(",
"imageType",
")",
";",
"GeneralFeatureDetector",
"<",
"I",
",",
"D",
">",
"corner",
"=",
"createShiTomasi",
"(",
"configExtract",
",",
"derivType",
")",
";",
"InterestPointDetector",
"<",
"I",
">",
"detector",
"=",
"FactoryInterestPoint",
".",
"wrapPoint",
"(",
"corner",
",",
"1",
",",
"imageType",
",",
"derivType",
")",
";",
"DescribeRegionPoint",
"<",
"I",
",",
"BrightFeature",
">",
"regionDesc",
"=",
"FactoryDescribeRegionPoint",
".",
"surfStable",
"(",
"configDescribe",
",",
"imageType",
")",
";",
"ScoreAssociation",
"<",
"TupleDesc_F64",
">",
"score",
"=",
"FactoryAssociation",
".",
"scoreEuclidean",
"(",
"TupleDesc_F64",
".",
"class",
",",
"true",
")",
";",
"AssociateSurfBasic",
"assoc",
"=",
"new",
"AssociateSurfBasic",
"(",
"FactoryAssociation",
".",
"greedy",
"(",
"score",
",",
"100000",
",",
"true",
")",
")",
";",
"AssociateDescription",
"<",
"BrightFeature",
">",
"generalAssoc",
"=",
"new",
"WrapAssociateSurfBasic",
"(",
"assoc",
")",
";",
"OrientationImage",
"<",
"I",
">",
"orientation",
"=",
"null",
";",
"if",
"(",
"configOrientation",
"!=",
"null",
")",
"{",
"Class",
"integralType",
"=",
"GIntegralImageOps",
".",
"getIntegralType",
"(",
"imageType",
")",
";",
"OrientationIntegral",
"orientationII",
"=",
"FactoryOrientationAlgs",
".",
"sliding_ii",
"(",
"configOrientation",
",",
"integralType",
")",
";",
"orientation",
"=",
"FactoryOrientation",
".",
"convertImage",
"(",
"orientationII",
",",
"imageType",
")",
";",
"}",
"return",
"combined",
"(",
"detector",
",",
"orientation",
",",
"regionDesc",
",",
"generalAssoc",
",",
"kltConfig",
",",
"reactivateThreshold",
",",
"imageType",
")",
";",
"}"
] |
Creates a tracker which detects Shi-Tomasi corner features, describes them with SURF, and
nominally tracks them using KLT.
@see ShiTomasiCornerIntensity
@see DescribePointSurf
@see boofcv.abst.feature.tracker.DdaManagerDetectDescribePoint
@param configExtract Configuration for extracting features
@param kltConfig Configuration for KLT
@param reactivateThreshold Tracks are reactivated after this many have been dropped. Try 10% of maxMatches
@param configDescribe Configuration for SURF descriptor
@param configOrientation Configuration for region orientation. If null then orientation isn't estimated
@param imageType Type of image the input is.
@param derivType Image derivative type. @return SURF based tracker.
|
[
"Creates",
"a",
"tracker",
"which",
"detects",
"Shi",
"-",
"Tomasi",
"corner",
"features",
"describes",
"them",
"with",
"SURF",
"and",
"nominally",
"tracks",
"them",
"using",
"KLT",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java#L422-L455
|
threerings/nenya
|
tools/src/main/java/com/threerings/media/tile/tools/MapFileTileSetIDBroker.java
|
MapFileTileSetIDBroker.writeMapFile
|
public static void writeMapFile (BufferedWriter bout, HashMap<String, Integer> map)
throws IOException
{
String[] lines = new String[map.size()];
Iterator<String> iter = map.keySet().iterator();
for (int ii = 0; iter.hasNext(); ii++) {
String key = iter.next();
Integer value = map.get(key);
lines[ii] = key + SEP_STR + value;
}
QuickSort.sort(lines);
for (String line : lines) {
bout.write(line, 0, line.length());
bout.newLine();
}
bout.flush();
}
|
java
|
public static void writeMapFile (BufferedWriter bout, HashMap<String, Integer> map)
throws IOException
{
String[] lines = new String[map.size()];
Iterator<String> iter = map.keySet().iterator();
for (int ii = 0; iter.hasNext(); ii++) {
String key = iter.next();
Integer value = map.get(key);
lines[ii] = key + SEP_STR + value;
}
QuickSort.sort(lines);
for (String line : lines) {
bout.write(line, 0, line.length());
bout.newLine();
}
bout.flush();
}
|
[
"public",
"static",
"void",
"writeMapFile",
"(",
"BufferedWriter",
"bout",
",",
"HashMap",
"<",
"String",
",",
"Integer",
">",
"map",
")",
"throws",
"IOException",
"{",
"String",
"[",
"]",
"lines",
"=",
"new",
"String",
"[",
"map",
".",
"size",
"(",
")",
"]",
";",
"Iterator",
"<",
"String",
">",
"iter",
"=",
"map",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
"ii",
"++",
")",
"{",
"String",
"key",
"=",
"iter",
".",
"next",
"(",
")",
";",
"Integer",
"value",
"=",
"map",
".",
"get",
"(",
"key",
")",
";",
"lines",
"[",
"ii",
"]",
"=",
"key",
"+",
"SEP_STR",
"+",
"value",
";",
"}",
"QuickSort",
".",
"sort",
"(",
"lines",
")",
";",
"for",
"(",
"String",
"line",
":",
"lines",
")",
"{",
"bout",
".",
"write",
"(",
"line",
",",
"0",
",",
"line",
".",
"length",
"(",
")",
")",
";",
"bout",
".",
"newLine",
"(",
")",
";",
"}",
"bout",
".",
"flush",
"(",
")",
";",
"}"
] |
Writes out a mapping from strings to integers in a manner that can
be read back in via {@link #readMapFile}.
|
[
"Writes",
"out",
"a",
"mapping",
"from",
"strings",
"to",
"integers",
"in",
"a",
"manner",
"that",
"can",
"be",
"read",
"back",
"in",
"via",
"{"
] |
train
|
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/tools/src/main/java/com/threerings/media/tile/tools/MapFileTileSetIDBroker.java#L162-L178
|
stapler/stapler
|
core/src/main/java/org/kohsuke/stapler/Stapler.java
|
Stapler.invoke
|
public void invoke(HttpServletRequest req, HttpServletResponse rsp, Object root, String url) throws IOException, ServletException {
RequestImpl sreq = new RequestImpl(this, req, new ArrayList<AncestorImpl>(), new TokenList(url));
RequestImpl oreq = CURRENT_REQUEST.get();
CURRENT_REQUEST.set(sreq);
ResponseImpl srsp = new ResponseImpl(this, rsp);
ResponseImpl orsp = CURRENT_RESPONSE.get();
CURRENT_RESPONSE.set(srsp);
try {
invoke(sreq,srsp,root);
} finally {
CURRENT_REQUEST.set(oreq);
CURRENT_RESPONSE.set(orsp);
}
}
|
java
|
public void invoke(HttpServletRequest req, HttpServletResponse rsp, Object root, String url) throws IOException, ServletException {
RequestImpl sreq = new RequestImpl(this, req, new ArrayList<AncestorImpl>(), new TokenList(url));
RequestImpl oreq = CURRENT_REQUEST.get();
CURRENT_REQUEST.set(sreq);
ResponseImpl srsp = new ResponseImpl(this, rsp);
ResponseImpl orsp = CURRENT_RESPONSE.get();
CURRENT_RESPONSE.set(srsp);
try {
invoke(sreq,srsp,root);
} finally {
CURRENT_REQUEST.set(oreq);
CURRENT_RESPONSE.set(orsp);
}
}
|
[
"public",
"void",
"invoke",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"rsp",
",",
"Object",
"root",
",",
"String",
"url",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"RequestImpl",
"sreq",
"=",
"new",
"RequestImpl",
"(",
"this",
",",
"req",
",",
"new",
"ArrayList",
"<",
"AncestorImpl",
">",
"(",
")",
",",
"new",
"TokenList",
"(",
"url",
")",
")",
";",
"RequestImpl",
"oreq",
"=",
"CURRENT_REQUEST",
".",
"get",
"(",
")",
";",
"CURRENT_REQUEST",
".",
"set",
"(",
"sreq",
")",
";",
"ResponseImpl",
"srsp",
"=",
"new",
"ResponseImpl",
"(",
"this",
",",
"rsp",
")",
";",
"ResponseImpl",
"orsp",
"=",
"CURRENT_RESPONSE",
".",
"get",
"(",
")",
";",
"CURRENT_RESPONSE",
".",
"set",
"(",
"srsp",
")",
";",
"try",
"{",
"invoke",
"(",
"sreq",
",",
"srsp",
",",
"root",
")",
";",
"}",
"finally",
"{",
"CURRENT_REQUEST",
".",
"set",
"(",
"oreq",
")",
";",
"CURRENT_RESPONSE",
".",
"set",
"(",
"orsp",
")",
";",
"}",
"}"
] |
Performs stapler processing on the given root object and request URL.
|
[
"Performs",
"stapler",
"processing",
"on",
"the",
"given",
"root",
"object",
"and",
"request",
"URL",
"."
] |
train
|
https://github.com/stapler/stapler/blob/11ad5af185e062fb46e01bf9fbed66f3ebf2a8f7/core/src/main/java/org/kohsuke/stapler/Stapler.java#L666-L681
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java
|
ApiOvhOrder.dedicated_server_serviceName_ipMigration_duration_GET
|
public OvhOrder dedicated_server_serviceName_ipMigration_duration_GET(String serviceName, String duration, String ip, String token) throws IOException {
String qPath = "/order/dedicated/server/{serviceName}/ipMigration/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "ip", ip);
query(sb, "token", token);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
}
|
java
|
public OvhOrder dedicated_server_serviceName_ipMigration_duration_GET(String serviceName, String duration, String ip, String token) throws IOException {
String qPath = "/order/dedicated/server/{serviceName}/ipMigration/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "ip", ip);
query(sb, "token", token);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
}
|
[
"public",
"OvhOrder",
"dedicated_server_serviceName_ipMigration_duration_GET",
"(",
"String",
"serviceName",
",",
"String",
"duration",
",",
"String",
"ip",
",",
"String",
"token",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/dedicated/server/{serviceName}/ipMigration/{duration}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"duration",
")",
";",
"query",
"(",
"sb",
",",
"\"ip\"",
",",
"ip",
")",
";",
"query",
"(",
"sb",
",",
"\"token\"",
",",
"token",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] |
Get prices and contracts information
REST: GET /order/dedicated/server/{serviceName}/ipMigration/{duration}
@param ip [required] The IP to move to this server
@param token [required] IP migration token
@param serviceName [required] The internal name of your dedicated server
@param duration [required] Duration
|
[
"Get",
"prices",
"and",
"contracts",
"information"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L2572-L2579
|
kaazing/gateway
|
mina.core/core/src/main/java/org/apache/mina/handler/chain/ChainedIoHandler.java
|
ChainedIoHandler.messageReceived
|
@Override
public void messageReceived(IoSession session, Object message)
throws Exception {
chain.execute(null, session, message);
}
|
java
|
@Override
public void messageReceived(IoSession session, Object message)
throws Exception {
chain.execute(null, session, message);
}
|
[
"@",
"Override",
"public",
"void",
"messageReceived",
"(",
"IoSession",
"session",
",",
"Object",
"message",
")",
"throws",
"Exception",
"{",
"chain",
".",
"execute",
"(",
"null",
",",
"session",
",",
"message",
")",
";",
"}"
] |
Handles the specified <tt>messageReceived</tt> event with the
{@link IoHandlerCommand} or {@link IoHandlerChain} you specified
in the constructor.
|
[
"Handles",
"the",
"specified",
"<tt",
">",
"messageReceived<",
"/",
"tt",
">",
"event",
"with",
"the",
"{"
] |
train
|
https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.core/core/src/main/java/org/apache/mina/handler/chain/ChainedIoHandler.java#L64-L68
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/tools/Tools.java
|
Tools.selectRules
|
public static void selectRules(JLanguageTool lt, List<String> disabledRuleIds, List<String> enabledRuleIds, boolean useEnabledOnly) {
Set<String> disabledRuleIdsSet = new HashSet<>();
disabledRuleIdsSet.addAll(disabledRuleIds);
Set<String> enabledRuleIdsSet = new HashSet<>();
enabledRuleIdsSet.addAll(enabledRuleIds);
selectRules(lt, Collections.emptySet(), Collections.emptySet(), disabledRuleIdsSet, enabledRuleIdsSet, useEnabledOnly);
}
|
java
|
public static void selectRules(JLanguageTool lt, List<String> disabledRuleIds, List<String> enabledRuleIds, boolean useEnabledOnly) {
Set<String> disabledRuleIdsSet = new HashSet<>();
disabledRuleIdsSet.addAll(disabledRuleIds);
Set<String> enabledRuleIdsSet = new HashSet<>();
enabledRuleIdsSet.addAll(enabledRuleIds);
selectRules(lt, Collections.emptySet(), Collections.emptySet(), disabledRuleIdsSet, enabledRuleIdsSet, useEnabledOnly);
}
|
[
"public",
"static",
"void",
"selectRules",
"(",
"JLanguageTool",
"lt",
",",
"List",
"<",
"String",
">",
"disabledRuleIds",
",",
"List",
"<",
"String",
">",
"enabledRuleIds",
",",
"boolean",
"useEnabledOnly",
")",
"{",
"Set",
"<",
"String",
">",
"disabledRuleIdsSet",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"disabledRuleIdsSet",
".",
"addAll",
"(",
"disabledRuleIds",
")",
";",
"Set",
"<",
"String",
">",
"enabledRuleIdsSet",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"enabledRuleIdsSet",
".",
"addAll",
"(",
"enabledRuleIds",
")",
";",
"selectRules",
"(",
"lt",
",",
"Collections",
".",
"emptySet",
"(",
")",
",",
"Collections",
".",
"emptySet",
"(",
")",
",",
"disabledRuleIdsSet",
",",
"enabledRuleIdsSet",
",",
"useEnabledOnly",
")",
";",
"}"
] |
Enable and disable rules of the given LanguageTool instance.
@param lt LanguageTool object
@param disabledRuleIds ids of the rules to be disabled
@param enabledRuleIds ids of the rules to be enabled
@param useEnabledOnly if set to {@code true}, disable all rules except those enabled explicitly
|
[
"Enable",
"and",
"disable",
"rules",
"of",
"the",
"given",
"LanguageTool",
"instance",
"."
] |
train
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/tools/Tools.java#L286-L292
|
Cornutum/tcases
|
tcases-io/src/main/java/org/cornutum/tcases/io/SystemInputJson.java
|
SystemInputJson.asValueDef
|
private static VarValueDef asValueDef( String valueName, JsonObject json)
{
try
{
VarValueDef valueDef = new VarValueDef( ObjectUtils.toObject( valueName));
// Get the type of this value
boolean failure = json.getBoolean( FAILURE_KEY, false);
boolean once = json.getBoolean( ONCE_KEY, false);
valueDef.setType
( failure? VarValueDef.Type.FAILURE :
once? VarValueDef.Type.ONCE :
VarValueDef.Type.VALID);
if( failure && json.containsKey( PROPERTIES_KEY))
{
throw new SystemInputException( "Failure type values can't define properties");
}
// Get annotations for this value
Optional.ofNullable( json.getJsonObject( HAS_KEY))
.ifPresent( has -> has.keySet().stream().forEach( key -> valueDef.setAnnotation( key, has.getString( key))));
// Get the condition for this value
Optional.ofNullable( json.getJsonObject( WHEN_KEY))
.ifPresent( object -> valueDef.setCondition( asValidCondition( object)));
// Get properties for this value
Optional.ofNullable( json.getJsonArray( PROPERTIES_KEY))
.map( properties -> toIdentifiers( properties))
.ifPresent( properties -> valueDef.addProperties( properties));
return valueDef;
}
catch( SystemInputException e)
{
throw new SystemInputException( String.format( "Error defining value=%s", valueName), e);
}
}
|
java
|
private static VarValueDef asValueDef( String valueName, JsonObject json)
{
try
{
VarValueDef valueDef = new VarValueDef( ObjectUtils.toObject( valueName));
// Get the type of this value
boolean failure = json.getBoolean( FAILURE_KEY, false);
boolean once = json.getBoolean( ONCE_KEY, false);
valueDef.setType
( failure? VarValueDef.Type.FAILURE :
once? VarValueDef.Type.ONCE :
VarValueDef.Type.VALID);
if( failure && json.containsKey( PROPERTIES_KEY))
{
throw new SystemInputException( "Failure type values can't define properties");
}
// Get annotations for this value
Optional.ofNullable( json.getJsonObject( HAS_KEY))
.ifPresent( has -> has.keySet().stream().forEach( key -> valueDef.setAnnotation( key, has.getString( key))));
// Get the condition for this value
Optional.ofNullable( json.getJsonObject( WHEN_KEY))
.ifPresent( object -> valueDef.setCondition( asValidCondition( object)));
// Get properties for this value
Optional.ofNullable( json.getJsonArray( PROPERTIES_KEY))
.map( properties -> toIdentifiers( properties))
.ifPresent( properties -> valueDef.addProperties( properties));
return valueDef;
}
catch( SystemInputException e)
{
throw new SystemInputException( String.format( "Error defining value=%s", valueName), e);
}
}
|
[
"private",
"static",
"VarValueDef",
"asValueDef",
"(",
"String",
"valueName",
",",
"JsonObject",
"json",
")",
"{",
"try",
"{",
"VarValueDef",
"valueDef",
"=",
"new",
"VarValueDef",
"(",
"ObjectUtils",
".",
"toObject",
"(",
"valueName",
")",
")",
";",
"// Get the type of this value",
"boolean",
"failure",
"=",
"json",
".",
"getBoolean",
"(",
"FAILURE_KEY",
",",
"false",
")",
";",
"boolean",
"once",
"=",
"json",
".",
"getBoolean",
"(",
"ONCE_KEY",
",",
"false",
")",
";",
"valueDef",
".",
"setType",
"(",
"failure",
"?",
"VarValueDef",
".",
"Type",
".",
"FAILURE",
":",
"once",
"?",
"VarValueDef",
".",
"Type",
".",
"ONCE",
":",
"VarValueDef",
".",
"Type",
".",
"VALID",
")",
";",
"if",
"(",
"failure",
"&&",
"json",
".",
"containsKey",
"(",
"PROPERTIES_KEY",
")",
")",
"{",
"throw",
"new",
"SystemInputException",
"(",
"\"Failure type values can't define properties\"",
")",
";",
"}",
"// Get annotations for this value",
"Optional",
".",
"ofNullable",
"(",
"json",
".",
"getJsonObject",
"(",
"HAS_KEY",
")",
")",
".",
"ifPresent",
"(",
"has",
"->",
"has",
".",
"keySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"key",
"->",
"valueDef",
".",
"setAnnotation",
"(",
"key",
",",
"has",
".",
"getString",
"(",
"key",
")",
")",
")",
")",
";",
"// Get the condition for this value",
"Optional",
".",
"ofNullable",
"(",
"json",
".",
"getJsonObject",
"(",
"WHEN_KEY",
")",
")",
".",
"ifPresent",
"(",
"object",
"->",
"valueDef",
".",
"setCondition",
"(",
"asValidCondition",
"(",
"object",
")",
")",
")",
";",
"// Get properties for this value",
"Optional",
".",
"ofNullable",
"(",
"json",
".",
"getJsonArray",
"(",
"PROPERTIES_KEY",
")",
")",
".",
"map",
"(",
"properties",
"->",
"toIdentifiers",
"(",
"properties",
")",
")",
".",
"ifPresent",
"(",
"properties",
"->",
"valueDef",
".",
"addProperties",
"(",
"properties",
")",
")",
";",
"return",
"valueDef",
";",
"}",
"catch",
"(",
"SystemInputException",
"e",
")",
"{",
"throw",
"new",
"SystemInputException",
"(",
"String",
".",
"format",
"(",
"\"Error defining value=%s\"",
",",
"valueName",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Returns the value definition represented by the given JSON object.
|
[
"Returns",
"the",
"value",
"definition",
"represented",
"by",
"the",
"given",
"JSON",
"object",
"."
] |
train
|
https://github.com/Cornutum/tcases/blob/21e15cf107fa149620c40f4bda1829c1224fcfb1/tcases-io/src/main/java/org/cornutum/tcases/io/SystemInputJson.java#L342-L380
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheProviderWrapper.java
|
CacheProviderWrapper.invalidateAndSet
|
@Override
public Object invalidateAndSet(com.ibm.ws.cache.EntryInfo ei, Object value, boolean coordinate) {
final String methodName = "invalidateAndSet()";
Object oldValue = null;
Object id = null;
if (ei != null && value != null) {
id = ei.getIdObject();
com.ibm.websphere.cache.CacheEntry oldCacheEntry = this.coreCache.put(ei, value);
if (oldCacheEntry != null) {
oldValue = oldCacheEntry.getValue();
}
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, methodName + " cacheName=" + cacheName + " id=" + id + " value=" + value);
}
return oldValue;
}
|
java
|
@Override
public Object invalidateAndSet(com.ibm.ws.cache.EntryInfo ei, Object value, boolean coordinate) {
final String methodName = "invalidateAndSet()";
Object oldValue = null;
Object id = null;
if (ei != null && value != null) {
id = ei.getIdObject();
com.ibm.websphere.cache.CacheEntry oldCacheEntry = this.coreCache.put(ei, value);
if (oldCacheEntry != null) {
oldValue = oldCacheEntry.getValue();
}
}
if (tc.isDebugEnabled()) {
Tr.debug(tc, methodName + " cacheName=" + cacheName + " id=" + id + " value=" + value);
}
return oldValue;
}
|
[
"@",
"Override",
"public",
"Object",
"invalidateAndSet",
"(",
"com",
".",
"ibm",
".",
"ws",
".",
"cache",
".",
"EntryInfo",
"ei",
",",
"Object",
"value",
",",
"boolean",
"coordinate",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"invalidateAndSet()\"",
";",
"Object",
"oldValue",
"=",
"null",
";",
"Object",
"id",
"=",
"null",
";",
"if",
"(",
"ei",
"!=",
"null",
"&&",
"value",
"!=",
"null",
")",
"{",
"id",
"=",
"ei",
".",
"getIdObject",
"(",
")",
";",
"com",
".",
"ibm",
".",
"websphere",
".",
"cache",
".",
"CacheEntry",
"oldCacheEntry",
"=",
"this",
".",
"coreCache",
".",
"put",
"(",
"ei",
",",
"value",
")",
";",
"if",
"(",
"oldCacheEntry",
"!=",
"null",
")",
"{",
"oldValue",
"=",
"oldCacheEntry",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"methodName",
"+",
"\" cacheName=\"",
"+",
"cacheName",
"+",
"\" id=\"",
"+",
"id",
"+",
"\" value=\"",
"+",
"value",
")",
";",
"}",
"return",
"oldValue",
";",
"}"
] |
Puts an entry into the cache. If the entry already exists in the
cache, this method will ALSO update the same.
Called by DistributedMap
@param ei The EntryInfo object
@param value The value of the object
@param coordinate Indicates that the value should be set in other caches caching this value. (No effect on CoreCache)
|
[
"Puts",
"an",
"entry",
"into",
"the",
"cache",
".",
"If",
"the",
"entry",
"already",
"exists",
"in",
"the",
"cache",
"this",
"method",
"will",
"ALSO",
"update",
"the",
"same",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/CacheProviderWrapper.java#L439-L455
|
mikepenz/MaterialDrawer
|
library/src/main/java/com/mikepenz/materialdrawer/Drawer.java
|
Drawer.addItemAtPosition
|
public void addItemAtPosition(@NonNull IDrawerItem drawerItem, int position) {
mDrawerBuilder.getItemAdapter().add(position, drawerItem);
}
|
java
|
public void addItemAtPosition(@NonNull IDrawerItem drawerItem, int position) {
mDrawerBuilder.getItemAdapter().add(position, drawerItem);
}
|
[
"public",
"void",
"addItemAtPosition",
"(",
"@",
"NonNull",
"IDrawerItem",
"drawerItem",
",",
"int",
"position",
")",
"{",
"mDrawerBuilder",
".",
"getItemAdapter",
"(",
")",
".",
"add",
"(",
"position",
",",
"drawerItem",
")",
";",
"}"
] |
Add a drawerItem at a specific position
@param drawerItem
@param position
|
[
"Add",
"a",
"drawerItem",
"at",
"a",
"specific",
"position"
] |
train
|
https://github.com/mikepenz/MaterialDrawer/blob/f4fb31635767edead0a01cee7b7588942b89d8d9/library/src/main/java/com/mikepenz/materialdrawer/Drawer.java#L733-L735
|
radkovo/jStyleParser
|
src/main/java/cz/vutbr/web/domassign/Analyzer.java
|
Analyzer.assingDeclarationsToDOM
|
protected DeclarationMap assingDeclarationsToDOM(Document doc, MediaSpec media, final boolean inherit) {
// classify the rules
classifyAllSheets(media);
// resulting map
DeclarationMap declarations = new DeclarationMap();
// if the holder is empty skip evaluation
if(rules!=null && !rules.isEmpty()) {
Traversal<DeclarationMap> traversal = new Traversal<DeclarationMap>(
doc, (Object) rules, NodeFilter.SHOW_ELEMENT) {
protected void processNode(DeclarationMap result,
Node current, Object source) {
assignDeclarationsToElement(result, walker, (Element) current,
(Holder) source);
}
};
// list traversal will be enough
if (!inherit)
traversal.listTraversal(declarations);
// we will do level traversal to economize blind returning
// in tree
else
traversal.levelTraversal(declarations);
}
return declarations;
}
|
java
|
protected DeclarationMap assingDeclarationsToDOM(Document doc, MediaSpec media, final boolean inherit) {
// classify the rules
classifyAllSheets(media);
// resulting map
DeclarationMap declarations = new DeclarationMap();
// if the holder is empty skip evaluation
if(rules!=null && !rules.isEmpty()) {
Traversal<DeclarationMap> traversal = new Traversal<DeclarationMap>(
doc, (Object) rules, NodeFilter.SHOW_ELEMENT) {
protected void processNode(DeclarationMap result,
Node current, Object source) {
assignDeclarationsToElement(result, walker, (Element) current,
(Holder) source);
}
};
// list traversal will be enough
if (!inherit)
traversal.listTraversal(declarations);
// we will do level traversal to economize blind returning
// in tree
else
traversal.levelTraversal(declarations);
}
return declarations;
}
|
[
"protected",
"DeclarationMap",
"assingDeclarationsToDOM",
"(",
"Document",
"doc",
",",
"MediaSpec",
"media",
",",
"final",
"boolean",
"inherit",
")",
"{",
"// classify the rules",
"classifyAllSheets",
"(",
"media",
")",
";",
"// resulting map",
"DeclarationMap",
"declarations",
"=",
"new",
"DeclarationMap",
"(",
")",
";",
"// if the holder is empty skip evaluation",
"if",
"(",
"rules",
"!=",
"null",
"&&",
"!",
"rules",
".",
"isEmpty",
"(",
")",
")",
"{",
"Traversal",
"<",
"DeclarationMap",
">",
"traversal",
"=",
"new",
"Traversal",
"<",
"DeclarationMap",
">",
"(",
"doc",
",",
"(",
"Object",
")",
"rules",
",",
"NodeFilter",
".",
"SHOW_ELEMENT",
")",
"{",
"protected",
"void",
"processNode",
"(",
"DeclarationMap",
"result",
",",
"Node",
"current",
",",
"Object",
"source",
")",
"{",
"assignDeclarationsToElement",
"(",
"result",
",",
"walker",
",",
"(",
"Element",
")",
"current",
",",
"(",
"Holder",
")",
"source",
")",
";",
"}",
"}",
";",
"// list traversal will be enough",
"if",
"(",
"!",
"inherit",
")",
"traversal",
".",
"listTraversal",
"(",
"declarations",
")",
";",
"// we will do level traversal to economize blind returning",
"// in tree",
"else",
"traversal",
".",
"levelTraversal",
"(",
"declarations",
")",
";",
"}",
"return",
"declarations",
";",
"}"
] |
Creates map of declarations assigned to each element of a DOM tree
@param doc
DOM document
@param media
Media type to be used for declarations
@param inherit
Inheritance (cascade propagation of values)
@return Map of elements as keys and their declarations
|
[
"Creates",
"map",
"of",
"declarations",
"assigned",
"to",
"each",
"element",
"of",
"a",
"DOM",
"tree"
] |
train
|
https://github.com/radkovo/jStyleParser/blob/8ab049ac6866aa52c4d7deee25c9e294e7191957/src/main/java/cz/vutbr/web/domassign/Analyzer.java#L200-L230
|
apache/flink
|
flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/HadoopInputs.java
|
HadoopInputs.readHadoopFile
|
public static <K, V> HadoopInputFormat<K, V> readHadoopFile(org.apache.hadoop.mapred.FileInputFormat<K, V> mapredInputFormat, Class<K> key, Class<V> value, String inputPath, JobConf job) {
// set input path in JobConf
org.apache.hadoop.mapred.FileInputFormat.addInputPath(job, new org.apache.hadoop.fs.Path(inputPath));
// return wrapping InputFormat
return createHadoopInput(mapredInputFormat, key, value, job);
}
|
java
|
public static <K, V> HadoopInputFormat<K, V> readHadoopFile(org.apache.hadoop.mapred.FileInputFormat<K, V> mapredInputFormat, Class<K> key, Class<V> value, String inputPath, JobConf job) {
// set input path in JobConf
org.apache.hadoop.mapred.FileInputFormat.addInputPath(job, new org.apache.hadoop.fs.Path(inputPath));
// return wrapping InputFormat
return createHadoopInput(mapredInputFormat, key, value, job);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"HadoopInputFormat",
"<",
"K",
",",
"V",
">",
"readHadoopFile",
"(",
"org",
".",
"apache",
".",
"hadoop",
".",
"mapred",
".",
"FileInputFormat",
"<",
"K",
",",
"V",
">",
"mapredInputFormat",
",",
"Class",
"<",
"K",
">",
"key",
",",
"Class",
"<",
"V",
">",
"value",
",",
"String",
"inputPath",
",",
"JobConf",
"job",
")",
"{",
"// set input path in JobConf",
"org",
".",
"apache",
".",
"hadoop",
".",
"mapred",
".",
"FileInputFormat",
".",
"addInputPath",
"(",
"job",
",",
"new",
"org",
".",
"apache",
".",
"hadoop",
".",
"fs",
".",
"Path",
"(",
"inputPath",
")",
")",
";",
"// return wrapping InputFormat",
"return",
"createHadoopInput",
"(",
"mapredInputFormat",
",",
"key",
",",
"value",
",",
"job",
")",
";",
"}"
] |
Creates a Flink {@link InputFormat} that wraps the given Hadoop {@link org.apache.hadoop.mapred.FileInputFormat}.
@return A Flink InputFormat that wraps the Hadoop FileInputFormat.
|
[
"Creates",
"a",
"Flink",
"{",
"@link",
"InputFormat",
"}",
"that",
"wraps",
"the",
"given",
"Hadoop",
"{",
"@link",
"org",
".",
"apache",
".",
"hadoop",
".",
"mapred",
".",
"FileInputFormat",
"}",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/HadoopInputs.java#L50-L55
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/pdf/Barcode.java
|
Barcode.createImageWithBarcode
|
public Image createImageWithBarcode(PdfContentByte cb, Color barColor, Color textColor) {
try {
return Image.getInstance(createTemplateWithBarcode(cb, barColor, textColor));
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
|
java
|
public Image createImageWithBarcode(PdfContentByte cb, Color barColor, Color textColor) {
try {
return Image.getInstance(createTemplateWithBarcode(cb, barColor, textColor));
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
|
[
"public",
"Image",
"createImageWithBarcode",
"(",
"PdfContentByte",
"cb",
",",
"Color",
"barColor",
",",
"Color",
"textColor",
")",
"{",
"try",
"{",
"return",
"Image",
".",
"getInstance",
"(",
"createTemplateWithBarcode",
"(",
"cb",
",",
"barColor",
",",
"textColor",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ExceptionConverter",
"(",
"e",
")",
";",
"}",
"}"
] |
Creates an <CODE>Image</CODE> with the barcode.
@param cb the <CODE>PdfContentByte</CODE> to create the <CODE>Image</CODE>. It
serves no other use
@param barColor the color of the bars. It can be <CODE>null</CODE>
@param textColor the color of the text. It can be <CODE>null</CODE>
@return the <CODE>Image</CODE>
@see #placeBarcode(PdfContentByte cb, Color barColor, Color textColor)
|
[
"Creates",
"an",
"<CODE",
">",
"Image<",
"/",
"CODE",
">",
"with",
"the",
"barcode",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/Barcode.java#L422-L429
|
lessthanoptimal/BoofCV
|
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java
|
GaliosFieldTableOps.polyEvalContinue
|
public int polyEvalContinue( int previousOutput, GrowQueue_I8 part , int x ) {
int y = previousOutput;
for (int i = 0; i < part.size; i++) {
y = multiply(y,x) ^ (part.data[i]&0xFF);
}
return y;
}
|
java
|
public int polyEvalContinue( int previousOutput, GrowQueue_I8 part , int x ) {
int y = previousOutput;
for (int i = 0; i < part.size; i++) {
y = multiply(y,x) ^ (part.data[i]&0xFF);
}
return y;
}
|
[
"public",
"int",
"polyEvalContinue",
"(",
"int",
"previousOutput",
",",
"GrowQueue_I8",
"part",
",",
"int",
"x",
")",
"{",
"int",
"y",
"=",
"previousOutput",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"part",
".",
"size",
";",
"i",
"++",
")",
"{",
"y",
"=",
"multiply",
"(",
"y",
",",
"x",
")",
"^",
"(",
"part",
".",
"data",
"[",
"i",
"]",
"&",
"0xFF",
")",
";",
"}",
"return",
"y",
";",
"}"
] |
Continue evaluating a polynomial which has been broken up into multiple arrays.
@param previousOutput Output from the evaluation of the prior part of the polynomial
@param part Additional segment of the polynomial
@param x Point it's being evaluated at
@return results
|
[
"Continue",
"evaluating",
"a",
"polynomial",
"which",
"has",
"been",
"broken",
"up",
"into",
"multiple",
"arrays",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java#L335-L342
|
lessthanoptimal/BoofCV
|
main/boofcv-ip/src/main/java/boofcv/factory/filter/binary/FactoryThresholdBinary.java
|
FactoryThresholdBinary.localSauvola
|
public static <T extends ImageGray<T>>
InputToBinary<T> localSauvola(ConfigLength width, boolean down, float k, Class<T> inputType)
{
if( BOverrideFactoryThresholdBinary.localSauvola != null )
return BOverrideFactoryThresholdBinary.localSauvola.handle(width, k, down, inputType);
InputToBinary<GrayF32> sauvola;
if( BoofConcurrency.USE_CONCURRENT ) {
sauvola = new ThresholdSauvola_MT(width, k, down);
} else {
sauvola = new ThresholdSauvola(width, k, down);
}
return new InputToBinarySwitch<>(sauvola,inputType);
}
|
java
|
public static <T extends ImageGray<T>>
InputToBinary<T> localSauvola(ConfigLength width, boolean down, float k, Class<T> inputType)
{
if( BOverrideFactoryThresholdBinary.localSauvola != null )
return BOverrideFactoryThresholdBinary.localSauvola.handle(width, k, down, inputType);
InputToBinary<GrayF32> sauvola;
if( BoofConcurrency.USE_CONCURRENT ) {
sauvola = new ThresholdSauvola_MT(width, k, down);
} else {
sauvola = new ThresholdSauvola(width, k, down);
}
return new InputToBinarySwitch<>(sauvola,inputType);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"InputToBinary",
"<",
"T",
">",
"localSauvola",
"(",
"ConfigLength",
"width",
",",
"boolean",
"down",
",",
"float",
"k",
",",
"Class",
"<",
"T",
">",
"inputType",
")",
"{",
"if",
"(",
"BOverrideFactoryThresholdBinary",
".",
"localSauvola",
"!=",
"null",
")",
"return",
"BOverrideFactoryThresholdBinary",
".",
"localSauvola",
".",
"handle",
"(",
"width",
",",
"k",
",",
"down",
",",
"inputType",
")",
";",
"InputToBinary",
"<",
"GrayF32",
">",
"sauvola",
";",
"if",
"(",
"BoofConcurrency",
".",
"USE_CONCURRENT",
")",
"{",
"sauvola",
"=",
"new",
"ThresholdSauvola_MT",
"(",
"width",
",",
"k",
",",
"down",
")",
";",
"}",
"else",
"{",
"sauvola",
"=",
"new",
"ThresholdSauvola",
"(",
"width",
",",
"k",
",",
"down",
")",
";",
"}",
"return",
"new",
"InputToBinarySwitch",
"<>",
"(",
"sauvola",
",",
"inputType",
")",
";",
"}"
] |
@see ThresholdSauvola
@param width Width of square region.
@param down Should it threshold up or down.
@param k User specified threshold adjustment factor. Must be positive. Try 0.3
@param inputType Type of input image
@return Filter to binary
|
[
"@see",
"ThresholdSauvola"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/binary/FactoryThresholdBinary.java#L68-L81
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.logging.core/src/com/ibm/ejs/ras/TraceNLS.java
|
TraceNLS.getFormattedMessage
|
public String getFormattedMessage(String key, Object[] args, String defaultString) {
return resolver.getMessage(caller, null, ivBundleName, key, args, defaultString, true, null, false);
}
|
java
|
public String getFormattedMessage(String key, Object[] args, String defaultString) {
return resolver.getMessage(caller, null, ivBundleName, key, args, defaultString, true, null, false);
}
|
[
"public",
"String",
"getFormattedMessage",
"(",
"String",
"key",
",",
"Object",
"[",
"]",
"args",
",",
"String",
"defaultString",
")",
"{",
"return",
"resolver",
".",
"getMessage",
"(",
"caller",
",",
"null",
",",
"ivBundleName",
",",
"key",
",",
"args",
",",
"defaultString",
",",
"true",
",",
"null",
",",
"false",
")",
";",
"}"
] |
Return the message obtained by looking up the localized text indicated by
the key in the ResourceBundle wrapped by this instance, then formatting
the message using the specified arguments as substitution parameters.
<p>
The message is formatted using the java.text.MessageFormat class.
Substitution parameters are handled according to the rules of that class.
Most noteably, that class does special formatting for native java Date and
Number objects.
<p>
If an error occurs in obtaining the localized text corresponding to this
key, then the defaultString is used as the message text. If all else fails,
this class will provide one of the default English messages to indicate
what occurred.
<p>
@param key
the key to use in the ResourceBundle lookup. Null is tolerated
@param args
substitution parameters that are inserted into the message
text. Null is tolerated
@param defaultString
text to use if the localized text cannot be found. Null is
tolerated
<p>
@return a non-null message that is localized and formatted as
appropriate.
|
[
"Return",
"the",
"message",
"obtained",
"by",
"looking",
"up",
"the",
"localized",
"text",
"indicated",
"by",
"the",
"key",
"in",
"the",
"ResourceBundle",
"wrapped",
"by",
"this",
"instance",
"then",
"formatting",
"the",
"message",
"using",
"the",
"specified",
"arguments",
"as",
"substitution",
"parameters",
".",
"<p",
">",
"The",
"message",
"is",
"formatted",
"using",
"the",
"java",
".",
"text",
".",
"MessageFormat",
"class",
".",
"Substitution",
"parameters",
"are",
"handled",
"according",
"to",
"the",
"rules",
"of",
"that",
"class",
".",
"Most",
"noteably",
"that",
"class",
"does",
"special",
"formatting",
"for",
"native",
"java",
"Date",
"and",
"Number",
"objects",
".",
"<p",
">",
"If",
"an",
"error",
"occurs",
"in",
"obtaining",
"the",
"localized",
"text",
"corresponding",
"to",
"this",
"key",
"then",
"the",
"defaultString",
"is",
"used",
"as",
"the",
"message",
"text",
".",
"If",
"all",
"else",
"fails",
"this",
"class",
"will",
"provide",
"one",
"of",
"the",
"default",
"English",
"messages",
"to",
"indicate",
"what",
"occurred",
".",
"<p",
">"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.core/src/com/ibm/ejs/ras/TraceNLS.java#L184-L186
|
xwiki/xwiki-commons
|
xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-default/src/main/java/org/xwiki/component/annotation/ComponentAnnotationLoader.java
|
ComponentAnnotationLoader.initialize
|
public void initialize(ComponentManager manager, ClassLoader classLoader)
{
try {
// Find all declared components by retrieving the list defined in COMPONENT_LIST.
List<ComponentDeclaration> componentDeclarations = getDeclaredComponents(classLoader, COMPONENT_LIST);
// Find all the Component overrides and adds them to the bottom of the list as component declarations with
// the highest priority of 0. This is purely for backward compatibility since the override files is now
// deprecated.
List<ComponentDeclaration> componentOverrideDeclarations =
getDeclaredComponents(classLoader, COMPONENT_OVERRIDE_LIST);
for (ComponentDeclaration componentOverrideDeclaration : componentOverrideDeclarations) {
// Since the old way to declare an override was to define it in both a component.txt and a
// component-overrides.txt file we first need to remove the override component declaration stored in
// componentDeclarations.
componentDeclarations.remove(componentOverrideDeclaration);
// Add it to the end of the list with the highest priority.
componentDeclarations.add(new ComponentDeclaration(componentOverrideDeclaration
.getImplementationClassName(), 0));
}
initialize(manager, classLoader, componentDeclarations);
} catch (Exception e) {
// Make sure we make the calling code fail in order to fail fast and prevent the application to start
// if something is amiss.
throw new RuntimeException("Failed to get the list of components to load", e);
}
}
|
java
|
public void initialize(ComponentManager manager, ClassLoader classLoader)
{
try {
// Find all declared components by retrieving the list defined in COMPONENT_LIST.
List<ComponentDeclaration> componentDeclarations = getDeclaredComponents(classLoader, COMPONENT_LIST);
// Find all the Component overrides and adds them to the bottom of the list as component declarations with
// the highest priority of 0. This is purely for backward compatibility since the override files is now
// deprecated.
List<ComponentDeclaration> componentOverrideDeclarations =
getDeclaredComponents(classLoader, COMPONENT_OVERRIDE_LIST);
for (ComponentDeclaration componentOverrideDeclaration : componentOverrideDeclarations) {
// Since the old way to declare an override was to define it in both a component.txt and a
// component-overrides.txt file we first need to remove the override component declaration stored in
// componentDeclarations.
componentDeclarations.remove(componentOverrideDeclaration);
// Add it to the end of the list with the highest priority.
componentDeclarations.add(new ComponentDeclaration(componentOverrideDeclaration
.getImplementationClassName(), 0));
}
initialize(manager, classLoader, componentDeclarations);
} catch (Exception e) {
// Make sure we make the calling code fail in order to fail fast and prevent the application to start
// if something is amiss.
throw new RuntimeException("Failed to get the list of components to load", e);
}
}
|
[
"public",
"void",
"initialize",
"(",
"ComponentManager",
"manager",
",",
"ClassLoader",
"classLoader",
")",
"{",
"try",
"{",
"// Find all declared components by retrieving the list defined in COMPONENT_LIST.",
"List",
"<",
"ComponentDeclaration",
">",
"componentDeclarations",
"=",
"getDeclaredComponents",
"(",
"classLoader",
",",
"COMPONENT_LIST",
")",
";",
"// Find all the Component overrides and adds them to the bottom of the list as component declarations with",
"// the highest priority of 0. This is purely for backward compatibility since the override files is now",
"// deprecated.",
"List",
"<",
"ComponentDeclaration",
">",
"componentOverrideDeclarations",
"=",
"getDeclaredComponents",
"(",
"classLoader",
",",
"COMPONENT_OVERRIDE_LIST",
")",
";",
"for",
"(",
"ComponentDeclaration",
"componentOverrideDeclaration",
":",
"componentOverrideDeclarations",
")",
"{",
"// Since the old way to declare an override was to define it in both a component.txt and a",
"// component-overrides.txt file we first need to remove the override component declaration stored in",
"// componentDeclarations.",
"componentDeclarations",
".",
"remove",
"(",
"componentOverrideDeclaration",
")",
";",
"// Add it to the end of the list with the highest priority.",
"componentDeclarations",
".",
"add",
"(",
"new",
"ComponentDeclaration",
"(",
"componentOverrideDeclaration",
".",
"getImplementationClassName",
"(",
")",
",",
"0",
")",
")",
";",
"}",
"initialize",
"(",
"manager",
",",
"classLoader",
",",
"componentDeclarations",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Make sure we make the calling code fail in order to fail fast and prevent the application to start",
"// if something is amiss.",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to get the list of components to load\"",
",",
"e",
")",
";",
"}",
"}"
] |
Loads all components defined using annotations.
@param manager the component manager to use to dynamically register components
@param classLoader the classloader to use to look for the Component list declaration file (
{@code META-INF/components.txt})
|
[
"Loads",
"all",
"components",
"defined",
"using",
"annotations",
"."
] |
train
|
https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-default/src/main/java/org/xwiki/component/annotation/ComponentAnnotationLoader.java#L99-L126
|
carewebframework/carewebframework-core
|
org.carewebframework.messaging-parent/org.carewebframework.messaging.amqp-parent/org.carewebframework.messaging.amqp.rabbitmq/src/main/java/org/carewebframework/messaging/amqp/rabbitmq/Broker.java
|
Broker.sendMessage
|
public void sendMessage(String channel, Message message) {
ensureChannel(channel);
admin.getRabbitTemplate().convertAndSend(exchange.getName(), channel, message);
}
|
java
|
public void sendMessage(String channel, Message message) {
ensureChannel(channel);
admin.getRabbitTemplate().convertAndSend(exchange.getName(), channel, message);
}
|
[
"public",
"void",
"sendMessage",
"(",
"String",
"channel",
",",
"Message",
"message",
")",
"{",
"ensureChannel",
"(",
"channel",
")",
";",
"admin",
".",
"getRabbitTemplate",
"(",
")",
".",
"convertAndSend",
"(",
"exchange",
".",
"getName",
"(",
")",
",",
"channel",
",",
"message",
")",
";",
"}"
] |
Sends an event to the default exchange.
@param channel Name of the channel.
@param message Message to send.
|
[
"Sends",
"an",
"event",
"to",
"the",
"default",
"exchange",
"."
] |
train
|
https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.messaging-parent/org.carewebframework.messaging.amqp-parent/org.carewebframework.messaging.amqp.rabbitmq/src/main/java/org/carewebframework/messaging/amqp/rabbitmq/Broker.java#L104-L107
|
h2oai/h2o-3
|
h2o-automl/src/main/java/ai/h2o/automl/AutoML.java
|
AutoML.pollAndUpdateProgress
|
private void pollAndUpdateProgress(Stage stage, String name, WorkAllocations.Work work, Job parentJob, Job subJob) {
pollAndUpdateProgress(stage, name, work, parentJob, subJob, false);
}
|
java
|
private void pollAndUpdateProgress(Stage stage, String name, WorkAllocations.Work work, Job parentJob, Job subJob) {
pollAndUpdateProgress(stage, name, work, parentJob, subJob, false);
}
|
[
"private",
"void",
"pollAndUpdateProgress",
"(",
"Stage",
"stage",
",",
"String",
"name",
",",
"WorkAllocations",
".",
"Work",
"work",
",",
"Job",
"parentJob",
",",
"Job",
"subJob",
")",
"{",
"pollAndUpdateProgress",
"(",
"stage",
",",
"name",
",",
"work",
",",
"parentJob",
",",
"subJob",
",",
"false",
")",
";",
"}"
] |
***************** Jobs Build / Configure / Run / Poll section (model agnostic, kind of...) *****************//
|
[
"*****************",
"Jobs",
"Build",
"/",
"Configure",
"/",
"Run",
"/",
"Poll",
"section",
"(",
"model",
"agnostic",
"kind",
"of",
"...",
")",
"*****************",
"//"
] |
train
|
https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-automl/src/main/java/ai/h2o/automl/AutoML.java#L555-L557
|
undertow-io/undertow
|
core/src/main/java/io/undertow/server/handlers/proxy/mod_cluster/NodePingUtil.java
|
NodePingUtil.pingHttpClient
|
static void pingHttpClient(URI connection, PingCallback callback, HttpServerExchange exchange, UndertowClient client, XnioSsl xnioSsl, OptionMap options) {
final XnioIoThread thread = exchange.getIoThread();
final RequestExchangeListener exchangeListener = new RequestExchangeListener(callback, NodeHealthChecker.NO_CHECK, true);
final Runnable r = new HttpClientPingTask(connection, exchangeListener, thread, client, xnioSsl, exchange.getConnection().getByteBufferPool(), options);
exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : thread, r);
// Schedule timeout task
scheduleCancelTask(exchange.getIoThread(), exchangeListener, 5, TimeUnit.SECONDS);
}
|
java
|
static void pingHttpClient(URI connection, PingCallback callback, HttpServerExchange exchange, UndertowClient client, XnioSsl xnioSsl, OptionMap options) {
final XnioIoThread thread = exchange.getIoThread();
final RequestExchangeListener exchangeListener = new RequestExchangeListener(callback, NodeHealthChecker.NO_CHECK, true);
final Runnable r = new HttpClientPingTask(connection, exchangeListener, thread, client, xnioSsl, exchange.getConnection().getByteBufferPool(), options);
exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : thread, r);
// Schedule timeout task
scheduleCancelTask(exchange.getIoThread(), exchangeListener, 5, TimeUnit.SECONDS);
}
|
[
"static",
"void",
"pingHttpClient",
"(",
"URI",
"connection",
",",
"PingCallback",
"callback",
",",
"HttpServerExchange",
"exchange",
",",
"UndertowClient",
"client",
",",
"XnioSsl",
"xnioSsl",
",",
"OptionMap",
"options",
")",
"{",
"final",
"XnioIoThread",
"thread",
"=",
"exchange",
".",
"getIoThread",
"(",
")",
";",
"final",
"RequestExchangeListener",
"exchangeListener",
"=",
"new",
"RequestExchangeListener",
"(",
"callback",
",",
"NodeHealthChecker",
".",
"NO_CHECK",
",",
"true",
")",
";",
"final",
"Runnable",
"r",
"=",
"new",
"HttpClientPingTask",
"(",
"connection",
",",
"exchangeListener",
",",
"thread",
",",
"client",
",",
"xnioSsl",
",",
"exchange",
".",
"getConnection",
"(",
")",
".",
"getByteBufferPool",
"(",
")",
",",
"options",
")",
";",
"exchange",
".",
"dispatch",
"(",
"exchange",
".",
"isInIoThread",
"(",
")",
"?",
"SameThreadExecutor",
".",
"INSTANCE",
":",
"thread",
",",
"r",
")",
";",
"// Schedule timeout task",
"scheduleCancelTask",
"(",
"exchange",
".",
"getIoThread",
"(",
")",
",",
"exchangeListener",
",",
"5",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}"
] |
Try to ping a server using the undertow client.
@param connection the connection URI
@param callback the ping callback
@param exchange the http servers exchange
@param client the undertow client
@param xnioSsl the ssl setup
@param options the options
|
[
"Try",
"to",
"ping",
"a",
"server",
"using",
"the",
"undertow",
"client",
"."
] |
train
|
https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/server/handlers/proxy/mod_cluster/NodePingUtil.java#L103-L111
|
boncey/Flickr4Java
|
src/main/java/com/flickr4java/flickr/util/UrlUtilities.java
|
UrlUtilities.createBuddyIconUrl
|
@Deprecated
public static String createBuddyIconUrl(int iconFarm, int iconServer, String id) {
return createBuddyIconUrl("http", iconFarm, iconServer, id);
}
|
java
|
@Deprecated
public static String createBuddyIconUrl(int iconFarm, int iconServer, String id) {
return createBuddyIconUrl("http", iconFarm, iconServer, id);
}
|
[
"@",
"Deprecated",
"public",
"static",
"String",
"createBuddyIconUrl",
"(",
"int",
"iconFarm",
",",
"int",
"iconServer",
",",
"String",
"id",
")",
"{",
"return",
"createBuddyIconUrl",
"(",
"\"http\"",
",",
"iconFarm",
",",
"iconServer",
",",
"id",
")",
";",
"}"
] |
Construct the BuddyIconUrl with {@code http} scheme.
<p>
If none available, return the <a href="http://www.flickr.com/images/buddyicon.jpg">default</a>, or an URL assembled from farm, iconserver and nsid.
@see <a href="http://flickr.com/services/api/misc.buddyicons.html">Flickr Documentation</a>
@param iconFarm
@param iconServer
@param id
@return The BuddyIconUrl
@deprecated use {@link #createSecureBuddyIconUrl(int, int, java.lang.String) }
|
[
"Construct",
"the",
"BuddyIconUrl",
"with",
"{",
"@code",
"http",
"}",
"scheme",
".",
"<p",
">",
"If",
"none",
"available",
"return",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"flickr",
".",
"com",
"/",
"images",
"/",
"buddyicon",
".",
"jpg",
">",
"default<",
"/",
"a",
">",
"or",
"an",
"URL",
"assembled",
"from",
"farm",
"iconserver",
"and",
"nsid",
"."
] |
train
|
https://github.com/boncey/Flickr4Java/blob/f66987ba0e360e5fb7730efbbb8c51f3d978fc25/src/main/java/com/flickr4java/flickr/util/UrlUtilities.java#L182-L185
|
apache/groovy
|
src/main/java/org/codehaus/groovy/transform/trait/Traits.java
|
Traits.getAsType
|
@SuppressWarnings("unchecked")
public static <T> T getAsType(Object self, Class<T> clazz) {
if (self instanceof GeneratedGroovyProxy) {
Object proxyTarget = ((GeneratedGroovyProxy)self).getProxyTarget();
if (clazz.isAssignableFrom(proxyTarget.getClass())) {
return (T) proxyTarget;
}
}
return DefaultGroovyMethods.asType(self, clazz);
}
|
java
|
@SuppressWarnings("unchecked")
public static <T> T getAsType(Object self, Class<T> clazz) {
if (self instanceof GeneratedGroovyProxy) {
Object proxyTarget = ((GeneratedGroovyProxy)self).getProxyTarget();
if (clazz.isAssignableFrom(proxyTarget.getClass())) {
return (T) proxyTarget;
}
}
return DefaultGroovyMethods.asType(self, clazz);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"getAsType",
"(",
"Object",
"self",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"if",
"(",
"self",
"instanceof",
"GeneratedGroovyProxy",
")",
"{",
"Object",
"proxyTarget",
"=",
"(",
"(",
"GeneratedGroovyProxy",
")",
"self",
")",
".",
"getProxyTarget",
"(",
")",
";",
"if",
"(",
"clazz",
".",
"isAssignableFrom",
"(",
"proxyTarget",
".",
"getClass",
"(",
")",
")",
")",
"{",
"return",
"(",
"T",
")",
"proxyTarget",
";",
"}",
"}",
"return",
"DefaultGroovyMethods",
".",
"asType",
"(",
"self",
",",
"clazz",
")",
";",
"}"
] |
Converts a class implementing some trait into a target class. If the trait is a dynamic proxy and
that the target class is assignable to the target object of the proxy, then the target object is
returned. Otherwise, falls back to {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#asType(java.lang.Object, Class)}
@param self an object to be coerced to some class
@param clazz the class to be coerced to
@return the object coerced to the target class, or the proxy instance if it is compatible with the target class.
|
[
"Converts",
"a",
"class",
"implementing",
"some",
"trait",
"into",
"a",
"target",
"class",
".",
"If",
"the",
"trait",
"is",
"a",
"dynamic",
"proxy",
"and",
"that",
"the",
"target",
"class",
"is",
"assignable",
"to",
"the",
"target",
"object",
"of",
"the",
"proxy",
"then",
"the",
"target",
"object",
"is",
"returned",
".",
"Otherwise",
"falls",
"back",
"to",
"{"
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/trait/Traits.java#L253-L262
|
apache/incubator-heron
|
heron/packing/src/java/org/apache/heron/packing/binpacking/FirstFitDecreasingPacking.java
|
FirstFitDecreasingPacking.removeInstancesFromContainers
|
private void removeInstancesFromContainers(PackingPlanBuilder packingPlanBuilder,
Map<String, Integer> componentsToScaleDown) {
List<ResourceRequirement> resourceRequirements =
getSortedInstances(componentsToScaleDown.keySet());
InstanceCountScorer instanceCountScorer = new InstanceCountScorer();
ContainerIdScorer containerIdScorer = new ContainerIdScorer(false);
for (ResourceRequirement resourceRequirement : resourceRequirements) {
String componentName = resourceRequirement.getComponentName();
int numInstancesToRemove = -componentsToScaleDown.get(componentName);
List<Scorer<Container>> scorers = new ArrayList<>();
scorers.add(new HomogeneityScorer(componentName, true)); // all-same-component containers
scorers.add(instanceCountScorer); // then fewest instances
scorers.add(new HomogeneityScorer(componentName, false)); // then most homogeneous
scorers.add(containerIdScorer); // then highest container id
for (int j = 0; j < numInstancesToRemove; j++) {
packingPlanBuilder.removeInstance(scorers, componentName);
}
}
}
|
java
|
private void removeInstancesFromContainers(PackingPlanBuilder packingPlanBuilder,
Map<String, Integer> componentsToScaleDown) {
List<ResourceRequirement> resourceRequirements =
getSortedInstances(componentsToScaleDown.keySet());
InstanceCountScorer instanceCountScorer = new InstanceCountScorer();
ContainerIdScorer containerIdScorer = new ContainerIdScorer(false);
for (ResourceRequirement resourceRequirement : resourceRequirements) {
String componentName = resourceRequirement.getComponentName();
int numInstancesToRemove = -componentsToScaleDown.get(componentName);
List<Scorer<Container>> scorers = new ArrayList<>();
scorers.add(new HomogeneityScorer(componentName, true)); // all-same-component containers
scorers.add(instanceCountScorer); // then fewest instances
scorers.add(new HomogeneityScorer(componentName, false)); // then most homogeneous
scorers.add(containerIdScorer); // then highest container id
for (int j = 0; j < numInstancesToRemove; j++) {
packingPlanBuilder.removeInstance(scorers, componentName);
}
}
}
|
[
"private",
"void",
"removeInstancesFromContainers",
"(",
"PackingPlanBuilder",
"packingPlanBuilder",
",",
"Map",
"<",
"String",
",",
"Integer",
">",
"componentsToScaleDown",
")",
"{",
"List",
"<",
"ResourceRequirement",
">",
"resourceRequirements",
"=",
"getSortedInstances",
"(",
"componentsToScaleDown",
".",
"keySet",
"(",
")",
")",
";",
"InstanceCountScorer",
"instanceCountScorer",
"=",
"new",
"InstanceCountScorer",
"(",
")",
";",
"ContainerIdScorer",
"containerIdScorer",
"=",
"new",
"ContainerIdScorer",
"(",
"false",
")",
";",
"for",
"(",
"ResourceRequirement",
"resourceRequirement",
":",
"resourceRequirements",
")",
"{",
"String",
"componentName",
"=",
"resourceRequirement",
".",
"getComponentName",
"(",
")",
";",
"int",
"numInstancesToRemove",
"=",
"-",
"componentsToScaleDown",
".",
"get",
"(",
"componentName",
")",
";",
"List",
"<",
"Scorer",
"<",
"Container",
">",
">",
"scorers",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"scorers",
".",
"add",
"(",
"new",
"HomogeneityScorer",
"(",
"componentName",
",",
"true",
")",
")",
";",
"// all-same-component containers",
"scorers",
".",
"add",
"(",
"instanceCountScorer",
")",
";",
"// then fewest instances",
"scorers",
".",
"add",
"(",
"new",
"HomogeneityScorer",
"(",
"componentName",
",",
"false",
")",
")",
";",
"// then most homogeneous",
"scorers",
".",
"add",
"(",
"containerIdScorer",
")",
";",
"// then highest container id",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"numInstancesToRemove",
";",
"j",
"++",
")",
"{",
"packingPlanBuilder",
".",
"removeInstance",
"(",
"scorers",
",",
"componentName",
")",
";",
"}",
"}",
"}"
] |
Removes instances from containers during scaling down
@param packingPlanBuilder existing packing plan
@param componentsToScaleDown scale down factor for the components.
|
[
"Removes",
"instances",
"from",
"containers",
"during",
"scaling",
"down"
] |
train
|
https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/packing/src/java/org/apache/heron/packing/binpacking/FirstFitDecreasingPacking.java#L257-L280
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java
|
SDBaseOps.scalarSet
|
public SDVariable scalarSet(String name, SDVariable in, Number set) {
SDVariable ret = f().scalarSet(in, set);
return updateVariableNameAndReference(ret, name);
}
|
java
|
public SDVariable scalarSet(String name, SDVariable in, Number set) {
SDVariable ret = f().scalarSet(in, set);
return updateVariableNameAndReference(ret, name);
}
|
[
"public",
"SDVariable",
"scalarSet",
"(",
"String",
"name",
",",
"SDVariable",
"in",
",",
"Number",
"set",
")",
"{",
"SDVariable",
"ret",
"=",
"f",
"(",
")",
".",
"scalarSet",
"(",
"in",
",",
"set",
")",
";",
"return",
"updateVariableNameAndReference",
"(",
"ret",
",",
"name",
")",
";",
"}"
] |
Return a variable with equal shape to the input, but all elements set to value 'set'
@param name Name of the output variable
@param in Input variable
@param set Value to set
@return Output variable
|
[
"Return",
"a",
"variable",
"with",
"equal",
"shape",
"to",
"the",
"input",
"but",
"all",
"elements",
"set",
"to",
"value",
"set"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/ops/SDBaseOps.java#L2005-L2008
|
h2oai/h2o-3
|
h2o-core/src/main/java/water/util/VecUtils.java
|
VecUtils.UUIDToStringVec
|
public static Vec UUIDToStringVec(Vec src) {
if( !src.isUUID() ) throw new H2OIllegalArgumentException("UUIDToStringVec() conversion only works on UUID columns");
Vec res = new MRTask() {
@Override public void map(Chunk chk, NewChunk newChk) {
if (chk instanceof C0DChunk) { // all NAs
for (int i=0; i < chk._len; i++)
newChk.addNA();
} else {
for (int i=0; i < chk._len; i++) {
if (!chk.isNA(i))
newChk.addStr(PrettyPrint.UUID(chk.at16l(i), chk.at16h(i)));
else
newChk.addNA();
}
}
}
}.doAll(Vec.T_STR,src).outputFrame().anyVec();
assert res != null;
return res;
}
|
java
|
public static Vec UUIDToStringVec(Vec src) {
if( !src.isUUID() ) throw new H2OIllegalArgumentException("UUIDToStringVec() conversion only works on UUID columns");
Vec res = new MRTask() {
@Override public void map(Chunk chk, NewChunk newChk) {
if (chk instanceof C0DChunk) { // all NAs
for (int i=0; i < chk._len; i++)
newChk.addNA();
} else {
for (int i=0; i < chk._len; i++) {
if (!chk.isNA(i))
newChk.addStr(PrettyPrint.UUID(chk.at16l(i), chk.at16h(i)));
else
newChk.addNA();
}
}
}
}.doAll(Vec.T_STR,src).outputFrame().anyVec();
assert res != null;
return res;
}
|
[
"public",
"static",
"Vec",
"UUIDToStringVec",
"(",
"Vec",
"src",
")",
"{",
"if",
"(",
"!",
"src",
".",
"isUUID",
"(",
")",
")",
"throw",
"new",
"H2OIllegalArgumentException",
"(",
"\"UUIDToStringVec() conversion only works on UUID columns\"",
")",
";",
"Vec",
"res",
"=",
"new",
"MRTask",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"map",
"(",
"Chunk",
"chk",
",",
"NewChunk",
"newChk",
")",
"{",
"if",
"(",
"chk",
"instanceof",
"C0DChunk",
")",
"{",
"// all NAs",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"chk",
".",
"_len",
";",
"i",
"++",
")",
"newChk",
".",
"addNA",
"(",
")",
";",
"}",
"else",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"chk",
".",
"_len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"chk",
".",
"isNA",
"(",
"i",
")",
")",
"newChk",
".",
"addStr",
"(",
"PrettyPrint",
".",
"UUID",
"(",
"chk",
".",
"at16l",
"(",
"i",
")",
",",
"chk",
".",
"at16h",
"(",
"i",
")",
")",
")",
";",
"else",
"newChk",
".",
"addNA",
"(",
")",
";",
"}",
"}",
"}",
"}",
".",
"doAll",
"(",
"Vec",
".",
"T_STR",
",",
"src",
")",
".",
"outputFrame",
"(",
")",
".",
"anyVec",
"(",
")",
";",
"assert",
"res",
"!=",
"null",
";",
"return",
"res",
";",
"}"
] |
Create a new {@link Vec} of string values from a UUID {@link Vec}.
String {@link Vec} is the standard hexadecimal representations of a UUID.
@param src a UUID {@link Vec}
@return a string {@link Vec}
|
[
"Create",
"a",
"new",
"{",
"@link",
"Vec",
"}",
"of",
"string",
"values",
"from",
"a",
"UUID",
"{",
"@link",
"Vec",
"}",
"."
] |
train
|
https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-core/src/main/java/water/util/VecUtils.java#L367-L386
|
maguro/aunit
|
junit/src/main/java/com/toolazydogs/aunit/Assert.java
|
Assert.assertTree
|
public static void assertTree(String message, String rootText, String preorder, Tree tree)
{
assertNotNull("tree should be non-null", tree);
assertEquals(message + " (asserting type of root)", rootText, tree.getText());
assertPreordered(message, preorder, tree);
}
|
java
|
public static void assertTree(String message, String rootText, String preorder, Tree tree)
{
assertNotNull("tree should be non-null", tree);
assertEquals(message + " (asserting type of root)", rootText, tree.getText());
assertPreordered(message, preorder, tree);
}
|
[
"public",
"static",
"void",
"assertTree",
"(",
"String",
"message",
",",
"String",
"rootText",
",",
"String",
"preorder",
",",
"Tree",
"tree",
")",
"{",
"assertNotNull",
"(",
"\"tree should be non-null\"",
",",
"tree",
")",
";",
"assertEquals",
"(",
"message",
"+",
"\" (asserting type of root)\"",
",",
"rootText",
",",
"tree",
".",
"getText",
"(",
")",
")",
";",
"assertPreordered",
"(",
"message",
",",
"preorder",
",",
"tree",
")",
";",
"}"
] |
Asserts a parse tree.
@param message the message to display on failure.
@param rootText the text of the root of the tree.
@param preorder the preorder traversal of the tree.
@param tree an ANTLR tree to assert on.
|
[
"Asserts",
"a",
"parse",
"tree",
"."
] |
train
|
https://github.com/maguro/aunit/blob/1f972e35b28327e5e2e7881befc928df0546d74c/junit/src/main/java/com/toolazydogs/aunit/Assert.java#L324-L329
|
elki-project/elki
|
elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java
|
TextWriterWriterInterface.writeObject
|
@SuppressWarnings("unchecked")
public final void writeObject(TextWriterStream out, String label, Object object) throws IOException {
write(out, label, (O) object);
}
|
java
|
@SuppressWarnings("unchecked")
public final void writeObject(TextWriterStream out, String label, Object object) throws IOException {
write(out, label, (O) object);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"void",
"writeObject",
"(",
"TextWriterStream",
"out",
",",
"String",
"label",
",",
"Object",
"object",
")",
"throws",
"IOException",
"{",
"write",
"(",
"out",
",",
"label",
",",
"(",
"O",
")",
"object",
")",
";",
"}"
] |
Non-type-checking version.
@param out Output stream
@param label Label to prefix
@param object object to output
@throws IOException on IO errors
|
[
"Non",
"-",
"type",
"-",
"checking",
"version",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java#L52-L55
|
deeplearning4j/deeplearning4j
|
deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/impl/multilayer/SparkDl4jMultiLayer.java
|
SparkDl4jMultiLayer.scoreExamples
|
public JavaDoubleRDD scoreExamples(RDD<DataSet> data, boolean includeRegularizationTerms, int batchSize) {
return scoreExamples(data.toJavaRDD(), includeRegularizationTerms, batchSize);
}
|
java
|
public JavaDoubleRDD scoreExamples(RDD<DataSet> data, boolean includeRegularizationTerms, int batchSize) {
return scoreExamples(data.toJavaRDD(), includeRegularizationTerms, batchSize);
}
|
[
"public",
"JavaDoubleRDD",
"scoreExamples",
"(",
"RDD",
"<",
"DataSet",
">",
"data",
",",
"boolean",
"includeRegularizationTerms",
",",
"int",
"batchSize",
")",
"{",
"return",
"scoreExamples",
"(",
"data",
".",
"toJavaRDD",
"(",
")",
",",
"includeRegularizationTerms",
",",
"batchSize",
")",
";",
"}"
] |
{@code RDD<DataSet>}
overload of {@link #scoreExamples(JavaRDD, boolean, int)}
|
[
"{"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/impl/multilayer/SparkDl4jMultiLayer.java#L418-L420
|
wildfly/wildfly-core
|
controller/src/main/java/org/jboss/as/controller/transform/TransformerRegistry.java
|
TransformerRegistry.resolveServer
|
public OperationTransformerRegistry resolveServer(final ModelVersion mgmtVersion, final ModelNode subsystems) {
return resolveServer(mgmtVersion, resolveVersions(subsystems));
}
|
java
|
public OperationTransformerRegistry resolveServer(final ModelVersion mgmtVersion, final ModelNode subsystems) {
return resolveServer(mgmtVersion, resolveVersions(subsystems));
}
|
[
"public",
"OperationTransformerRegistry",
"resolveServer",
"(",
"final",
"ModelVersion",
"mgmtVersion",
",",
"final",
"ModelNode",
"subsystems",
")",
"{",
"return",
"resolveServer",
"(",
"mgmtVersion",
",",
"resolveVersions",
"(",
"subsystems",
")",
")",
";",
"}"
] |
Resolve the server registry.
@param mgmtVersion the mgmt version
@param subsystems the subsystems
@return the transformer registry
|
[
"Resolve",
"the",
"server",
"registry",
"."
] |
train
|
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/transform/TransformerRegistry.java#L224-L226
|
javamelody/javamelody
|
javamelody-core/src/main/java/net/bull/javamelody/internal/web/html/HtmlCounterReport.java
|
HtmlCounterReport.htmlEncodeRequestName
|
static String htmlEncodeRequestName(String requestId, String requestName) {
if (requestId.startsWith(Counter.SQL_COUNTER_NAME)) {
final String htmlEncoded = htmlEncodeButNotSpace(requestName);
// highlight SQL keywords
return SQL_KEYWORDS_PATTERN.matcher(htmlEncoded)
.replaceAll("<span class='sqlKeyword'>$1</span>");
}
return htmlEncodeButNotSpace(requestName);
}
|
java
|
static String htmlEncodeRequestName(String requestId, String requestName) {
if (requestId.startsWith(Counter.SQL_COUNTER_NAME)) {
final String htmlEncoded = htmlEncodeButNotSpace(requestName);
// highlight SQL keywords
return SQL_KEYWORDS_PATTERN.matcher(htmlEncoded)
.replaceAll("<span class='sqlKeyword'>$1</span>");
}
return htmlEncodeButNotSpace(requestName);
}
|
[
"static",
"String",
"htmlEncodeRequestName",
"(",
"String",
"requestId",
",",
"String",
"requestName",
")",
"{",
"if",
"(",
"requestId",
".",
"startsWith",
"(",
"Counter",
".",
"SQL_COUNTER_NAME",
")",
")",
"{",
"final",
"String",
"htmlEncoded",
"=",
"htmlEncodeButNotSpace",
"(",
"requestName",
")",
";",
"// highlight SQL keywords\r",
"return",
"SQL_KEYWORDS_PATTERN",
".",
"matcher",
"(",
"htmlEncoded",
")",
".",
"replaceAll",
"(",
"\"<span class='sqlKeyword'>$1</span>\"",
")",
";",
"}",
"return",
"htmlEncodeButNotSpace",
"(",
"requestName",
")",
";",
"}"
] |
Encode le nom d'une requête pour affichage en html, sans encoder les espaces en nbsp (insécables),
et highlight les mots clés SQL.
@param requestId Id de la requête
@param requestName Nom de la requête à encoder
@return String
|
[
"Encode",
"le",
"nom",
"d",
"une",
"requête",
"pour",
"affichage",
"en",
"html",
"sans",
"encoder",
"les",
"espaces",
"en",
"nbsp",
"(",
"insécables",
")",
"et",
"highlight",
"les",
"mots",
"clés",
"SQL",
"."
] |
train
|
https://github.com/javamelody/javamelody/blob/18ad583ddeb5dcadd797dfda295409c6983ffd71/javamelody-core/src/main/java/net/bull/javamelody/internal/web/html/HtmlCounterReport.java#L367-L376
|
aws/aws-sdk-java
|
aws-java-sdk-iot1clickdevices/src/main/java/com/amazonaws/services/iot1clickdevices/model/DeviceDescription.java
|
DeviceDescription.withTags
|
public DeviceDescription withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
java
|
public DeviceDescription withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
[
"public",
"DeviceDescription",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
The tags currently associated with the AWS IoT 1-Click device.
</p>
@param tags
The tags currently associated with the AWS IoT 1-Click device.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"The",
"tags",
"currently",
"associated",
"with",
"the",
"AWS",
"IoT",
"1",
"-",
"Click",
"device",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-iot1clickdevices/src/main/java/com/amazonaws/services/iot1clickdevices/model/DeviceDescription.java#L379-L382
|
igniterealtime/Smack
|
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
|
Roster.createItemAndRequestSubscription
|
public void createItemAndRequestSubscription(BareJid jid, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
createItem(jid, name, groups);
sendSubscriptionRequest(jid);
}
|
java
|
public void createItemAndRequestSubscription(BareJid jid, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
createItem(jid, name, groups);
sendSubscriptionRequest(jid);
}
|
[
"public",
"void",
"createItemAndRequestSubscription",
"(",
"BareJid",
"jid",
",",
"String",
"name",
",",
"String",
"[",
"]",
"groups",
")",
"throws",
"NotLoggedInException",
",",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"createItem",
"(",
"jid",
",",
"name",
",",
"groups",
")",
";",
"sendSubscriptionRequest",
"(",
"jid",
")",
";",
"}"
] |
Creates a new roster entry and presence subscription. The server will asynchronously
update the roster with the subscription status.
@param jid the XMPP address of the contact (e.g. johndoe@jabber.org)
@param name the nickname of the user.
@param groups the list of group names the entry will belong to, or <tt>null</tt> if the
the roster entry won't belong to a group.
@throws NoResponseException if there was no response from the server.
@throws XMPPErrorException if an XMPP exception occurs.
@throws NotLoggedInException If not logged in.
@throws NotConnectedException
@throws InterruptedException
@since 4.4.0
|
[
"Creates",
"a",
"new",
"roster",
"entry",
"and",
"presence",
"subscription",
".",
"The",
"server",
"will",
"asynchronously",
"update",
"the",
"roster",
"with",
"the",
"subscription",
"status",
"."
] |
train
|
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L707-L711
|
jeremylong/DependencyCheck
|
core/src/main/java/org/owasp/dependencycheck/analyzer/RubyBundleAuditAnalyzer.java
|
RubyBundleAuditAnalyzer.launchBundleAudit
|
private Process launchBundleAudit(File folder) throws AnalysisException {
if (!folder.isDirectory()) {
throw new AnalysisException(String.format("%s should have been a directory.", folder.getAbsolutePath()));
}
final List<String> args = new ArrayList<>();
final String bundleAuditPath = getSettings().getString(Settings.KEYS.ANALYZER_BUNDLE_AUDIT_PATH);
File bundleAudit = null;
if (bundleAuditPath != null) {
bundleAudit = new File(bundleAuditPath);
if (!bundleAudit.isFile()) {
LOGGER.warn("Supplied `bundleAudit` path is incorrect: {}", bundleAuditPath);
bundleAudit = null;
}
}
args.add(bundleAudit != null && bundleAudit.isFile() ? bundleAudit.getAbsolutePath() : "bundle-audit");
args.add("check");
args.add("--verbose");
final ProcessBuilder builder = new ProcessBuilder(args);
builder.directory(folder);
try {
LOGGER.info("Launching: {} from {}", args, folder);
return builder.start();
} catch (IOException ioe) {
throw new AnalysisException("bundle-audit initialization failure; this error can be ignored if you are not analyzing Ruby. "
+ "Otherwise ensure that bundle-audit is installed and the path to bundle audit is correctly specified", ioe);
}
}
|
java
|
private Process launchBundleAudit(File folder) throws AnalysisException {
if (!folder.isDirectory()) {
throw new AnalysisException(String.format("%s should have been a directory.", folder.getAbsolutePath()));
}
final List<String> args = new ArrayList<>();
final String bundleAuditPath = getSettings().getString(Settings.KEYS.ANALYZER_BUNDLE_AUDIT_PATH);
File bundleAudit = null;
if (bundleAuditPath != null) {
bundleAudit = new File(bundleAuditPath);
if (!bundleAudit.isFile()) {
LOGGER.warn("Supplied `bundleAudit` path is incorrect: {}", bundleAuditPath);
bundleAudit = null;
}
}
args.add(bundleAudit != null && bundleAudit.isFile() ? bundleAudit.getAbsolutePath() : "bundle-audit");
args.add("check");
args.add("--verbose");
final ProcessBuilder builder = new ProcessBuilder(args);
builder.directory(folder);
try {
LOGGER.info("Launching: {} from {}", args, folder);
return builder.start();
} catch (IOException ioe) {
throw new AnalysisException("bundle-audit initialization failure; this error can be ignored if you are not analyzing Ruby. "
+ "Otherwise ensure that bundle-audit is installed and the path to bundle audit is correctly specified", ioe);
}
}
|
[
"private",
"Process",
"launchBundleAudit",
"(",
"File",
"folder",
")",
"throws",
"AnalysisException",
"{",
"if",
"(",
"!",
"folder",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"AnalysisException",
"(",
"String",
".",
"format",
"(",
"\"%s should have been a directory.\"",
",",
"folder",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"final",
"List",
"<",
"String",
">",
"args",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"final",
"String",
"bundleAuditPath",
"=",
"getSettings",
"(",
")",
".",
"getString",
"(",
"Settings",
".",
"KEYS",
".",
"ANALYZER_BUNDLE_AUDIT_PATH",
")",
";",
"File",
"bundleAudit",
"=",
"null",
";",
"if",
"(",
"bundleAuditPath",
"!=",
"null",
")",
"{",
"bundleAudit",
"=",
"new",
"File",
"(",
"bundleAuditPath",
")",
";",
"if",
"(",
"!",
"bundleAudit",
".",
"isFile",
"(",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Supplied `bundleAudit` path is incorrect: {}\"",
",",
"bundleAuditPath",
")",
";",
"bundleAudit",
"=",
"null",
";",
"}",
"}",
"args",
".",
"add",
"(",
"bundleAudit",
"!=",
"null",
"&&",
"bundleAudit",
".",
"isFile",
"(",
")",
"?",
"bundleAudit",
".",
"getAbsolutePath",
"(",
")",
":",
"\"bundle-audit\"",
")",
";",
"args",
".",
"add",
"(",
"\"check\"",
")",
";",
"args",
".",
"add",
"(",
"\"--verbose\"",
")",
";",
"final",
"ProcessBuilder",
"builder",
"=",
"new",
"ProcessBuilder",
"(",
"args",
")",
";",
"builder",
".",
"directory",
"(",
"folder",
")",
";",
"try",
"{",
"LOGGER",
".",
"info",
"(",
"\"Launching: {} from {}\"",
",",
"args",
",",
"folder",
")",
";",
"return",
"builder",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"AnalysisException",
"(",
"\"bundle-audit initialization failure; this error can be ignored if you are not analyzing Ruby. \"",
"+",
"\"Otherwise ensure that bundle-audit is installed and the path to bundle audit is correctly specified\"",
",",
"ioe",
")",
";",
"}",
"}"
] |
Launch bundle-audit.
@param folder directory that contains bundle audit
@return a handle to the process
@throws AnalysisException thrown when there is an issue launching bundle
audit
|
[
"Launch",
"bundle",
"-",
"audit",
"."
] |
train
|
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/RubyBundleAuditAnalyzer.java#L138-L164
|
phax/ph-commons
|
ph-xml/src/main/java/com/helger/xml/xpath/MapBasedXPathFunctionResolver.java
|
MapBasedXPathFunctionResolver.addUniqueFunction
|
@Nonnull
public EChange addUniqueFunction (@Nonnull final String sNamespaceURI,
@Nonnull final String sLocalPart,
@Nonnegative final int nArity,
@Nonnull final XPathFunction aFunction)
{
return addUniqueFunction (new QName (sNamespaceURI, sLocalPart), nArity, aFunction);
}
|
java
|
@Nonnull
public EChange addUniqueFunction (@Nonnull final String sNamespaceURI,
@Nonnull final String sLocalPart,
@Nonnegative final int nArity,
@Nonnull final XPathFunction aFunction)
{
return addUniqueFunction (new QName (sNamespaceURI, sLocalPart), nArity, aFunction);
}
|
[
"@",
"Nonnull",
"public",
"EChange",
"addUniqueFunction",
"(",
"@",
"Nonnull",
"final",
"String",
"sNamespaceURI",
",",
"@",
"Nonnull",
"final",
"String",
"sLocalPart",
",",
"@",
"Nonnegative",
"final",
"int",
"nArity",
",",
"@",
"Nonnull",
"final",
"XPathFunction",
"aFunction",
")",
"{",
"return",
"addUniqueFunction",
"(",
"new",
"QName",
"(",
"sNamespaceURI",
",",
"sLocalPart",
")",
",",
"nArity",
",",
"aFunction",
")",
";",
"}"
] |
Add a new function.
@param sNamespaceURI
The namespace URI of the function
@param sLocalPart
The local part of the function
@param nArity
The number of parameters of the function
@param aFunction
The function to be used. May not be <code>null</code>.
@return {@link EChange}
|
[
"Add",
"a",
"new",
"function",
"."
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/xpath/MapBasedXPathFunctionResolver.java#L84-L91
|
kkopacz/agiso-core
|
bundles/agiso-core-lang/src/main/java/org/agiso/core/lang/util/ThreadUtils.java
|
ThreadUtils.putAttribute
|
public static Object putAttribute(String key, Object attribute, boolean inheritable) {
if(inheritable) {
Object value = inheritableAttributeHolder.get().put(key, attribute);
if(value == null) {
value = localAttributeHolder.get().remove(key);
} else {
localAttributeHolder.get().remove(key);
}
return value;
} else {
Object value = localAttributeHolder.get().put(key, attribute);
if(value == null) {
value = inheritableAttributeHolder.get().remove(key);
} else {
inheritableAttributeHolder.get().remove(key);
}
return value;
}
}
|
java
|
public static Object putAttribute(String key, Object attribute, boolean inheritable) {
if(inheritable) {
Object value = inheritableAttributeHolder.get().put(key, attribute);
if(value == null) {
value = localAttributeHolder.get().remove(key);
} else {
localAttributeHolder.get().remove(key);
}
return value;
} else {
Object value = localAttributeHolder.get().put(key, attribute);
if(value == null) {
value = inheritableAttributeHolder.get().remove(key);
} else {
inheritableAttributeHolder.get().remove(key);
}
return value;
}
}
|
[
"public",
"static",
"Object",
"putAttribute",
"(",
"String",
"key",
",",
"Object",
"attribute",
",",
"boolean",
"inheritable",
")",
"{",
"if",
"(",
"inheritable",
")",
"{",
"Object",
"value",
"=",
"inheritableAttributeHolder",
".",
"get",
"(",
")",
".",
"put",
"(",
"key",
",",
"attribute",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"localAttributeHolder",
".",
"get",
"(",
")",
".",
"remove",
"(",
"key",
")",
";",
"}",
"else",
"{",
"localAttributeHolder",
".",
"get",
"(",
")",
".",
"remove",
"(",
"key",
")",
";",
"}",
"return",
"value",
";",
"}",
"else",
"{",
"Object",
"value",
"=",
"localAttributeHolder",
".",
"get",
"(",
")",
".",
"put",
"(",
"key",
",",
"attribute",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"inheritableAttributeHolder",
".",
"get",
"(",
")",
".",
"remove",
"(",
"key",
")",
";",
"}",
"else",
"{",
"inheritableAttributeHolder",
".",
"get",
"(",
")",
".",
"remove",
"(",
"key",
")",
";",
"}",
"return",
"value",
";",
"}",
"}"
] |
Umieszcza wartość atrybutu pod określonym kluczem w zasięgu wątku określonym
parametrem wywołania <code>inheritable</code>.
@param key Klucz, pod którym atrybut zostanie umieszczony
@param attribute Wartość atrybutu do umieszczenia w zasięgu wątku
@param inheritable Wartość logiczna określająca, czy atrybut ma być
dziedziczony przez wąki dzieci, czy nie, jeśli ma wartość:
<ul>
<li><code>false</code> - jest atrybutem lokalnym dla bieżącego
wątku i nie jest widoczny przez jego dzieci,</li>
<li><code>true</code> - jest atrybutem dziedzicznym bieżącego
wątku i jest widoczny przez jego dzieci.</li>
</ul>
@return
|
[
"Umieszcza",
"wartość",
"atrybutu",
"pod",
"określonym",
"kluczem",
"w",
"zasięgu",
"wątku",
"określonym",
"parametrem",
"wywołania",
"<code",
">",
"inheritable<",
"/",
"code",
">",
"."
] |
train
|
https://github.com/kkopacz/agiso-core/blob/b994ec0146be1fe3f10829d69cd719bdbdebe1c5/bundles/agiso-core-lang/src/main/java/org/agiso/core/lang/util/ThreadUtils.java#L127-L145
|
deeplearning4j/deeplearning4j
|
deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/layers/convolutional/KerasConvolution1D.java
|
KerasConvolution1D.setWeights
|
@Override
public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException {
this.weights = new HashMap<>();
if (weights.containsKey(conf.getKERAS_PARAM_NAME_W())) {
INDArray kerasParamValue = weights.get(conf.getKERAS_PARAM_NAME_W());
INDArray paramValue;
switch (this.getDimOrder()) {
case TENSORFLOW:
paramValue = kerasParamValue.permute(2, 1, 0);
paramValue = paramValue.reshape(
paramValue.size(0), paramValue.size(1),
paramValue.size(2), 1);
break;
case THEANO:
paramValue = kerasParamValue.permute(2, 1, 0);
paramValue = paramValue.reshape(
paramValue.size(0), paramValue.size(1),
paramValue.size(2), 1).dup();
for (int i = 0; i < paramValue.tensorsAlongDimension(2, 3); i++) {
INDArray copyFilter = paramValue.tensorAlongDimension(i, 2, 3).dup();
double[] flattenedFilter = copyFilter.ravel().data().asDouble();
ArrayUtils.reverse(flattenedFilter);
INDArray newFilter = Nd4j.create(flattenedFilter, copyFilter.shape());
INDArray inPlaceFilter = paramValue.tensorAlongDimension(i, 2, 3);
inPlaceFilter.muli(0).addi(newFilter);
}
break;
default:
throw new InvalidKerasConfigurationException("Unknown keras backend " + this.getDimOrder());
}
this.weights.put(ConvolutionParamInitializer.WEIGHT_KEY, paramValue);
} else
throw new InvalidKerasConfigurationException(
"Parameter " + conf.getKERAS_PARAM_NAME_W() + " does not exist in weights");
if (hasBias) {
if (weights.containsKey(conf.getKERAS_PARAM_NAME_B()))
this.weights.put(ConvolutionParamInitializer.BIAS_KEY, weights.get(conf.getKERAS_PARAM_NAME_B()));
else
throw new InvalidKerasConfigurationException(
"Parameter " + conf.getKERAS_PARAM_NAME_B() + " does not exist in weights");
}
removeDefaultWeights(weights, conf);
}
|
java
|
@Override
public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException {
this.weights = new HashMap<>();
if (weights.containsKey(conf.getKERAS_PARAM_NAME_W())) {
INDArray kerasParamValue = weights.get(conf.getKERAS_PARAM_NAME_W());
INDArray paramValue;
switch (this.getDimOrder()) {
case TENSORFLOW:
paramValue = kerasParamValue.permute(2, 1, 0);
paramValue = paramValue.reshape(
paramValue.size(0), paramValue.size(1),
paramValue.size(2), 1);
break;
case THEANO:
paramValue = kerasParamValue.permute(2, 1, 0);
paramValue = paramValue.reshape(
paramValue.size(0), paramValue.size(1),
paramValue.size(2), 1).dup();
for (int i = 0; i < paramValue.tensorsAlongDimension(2, 3); i++) {
INDArray copyFilter = paramValue.tensorAlongDimension(i, 2, 3).dup();
double[] flattenedFilter = copyFilter.ravel().data().asDouble();
ArrayUtils.reverse(flattenedFilter);
INDArray newFilter = Nd4j.create(flattenedFilter, copyFilter.shape());
INDArray inPlaceFilter = paramValue.tensorAlongDimension(i, 2, 3);
inPlaceFilter.muli(0).addi(newFilter);
}
break;
default:
throw new InvalidKerasConfigurationException("Unknown keras backend " + this.getDimOrder());
}
this.weights.put(ConvolutionParamInitializer.WEIGHT_KEY, paramValue);
} else
throw new InvalidKerasConfigurationException(
"Parameter " + conf.getKERAS_PARAM_NAME_W() + " does not exist in weights");
if (hasBias) {
if (weights.containsKey(conf.getKERAS_PARAM_NAME_B()))
this.weights.put(ConvolutionParamInitializer.BIAS_KEY, weights.get(conf.getKERAS_PARAM_NAME_B()));
else
throw new InvalidKerasConfigurationException(
"Parameter " + conf.getKERAS_PARAM_NAME_B() + " does not exist in weights");
}
removeDefaultWeights(weights, conf);
}
|
[
"@",
"Override",
"public",
"void",
"setWeights",
"(",
"Map",
"<",
"String",
",",
"INDArray",
">",
"weights",
")",
"throws",
"InvalidKerasConfigurationException",
"{",
"this",
".",
"weights",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"weights",
".",
"containsKey",
"(",
"conf",
".",
"getKERAS_PARAM_NAME_W",
"(",
")",
")",
")",
"{",
"INDArray",
"kerasParamValue",
"=",
"weights",
".",
"get",
"(",
"conf",
".",
"getKERAS_PARAM_NAME_W",
"(",
")",
")",
";",
"INDArray",
"paramValue",
";",
"switch",
"(",
"this",
".",
"getDimOrder",
"(",
")",
")",
"{",
"case",
"TENSORFLOW",
":",
"paramValue",
"=",
"kerasParamValue",
".",
"permute",
"(",
"2",
",",
"1",
",",
"0",
")",
";",
"paramValue",
"=",
"paramValue",
".",
"reshape",
"(",
"paramValue",
".",
"size",
"(",
"0",
")",
",",
"paramValue",
".",
"size",
"(",
"1",
")",
",",
"paramValue",
".",
"size",
"(",
"2",
")",
",",
"1",
")",
";",
"break",
";",
"case",
"THEANO",
":",
"paramValue",
"=",
"kerasParamValue",
".",
"permute",
"(",
"2",
",",
"1",
",",
"0",
")",
";",
"paramValue",
"=",
"paramValue",
".",
"reshape",
"(",
"paramValue",
".",
"size",
"(",
"0",
")",
",",
"paramValue",
".",
"size",
"(",
"1",
")",
",",
"paramValue",
".",
"size",
"(",
"2",
")",
",",
"1",
")",
".",
"dup",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"paramValue",
".",
"tensorsAlongDimension",
"(",
"2",
",",
"3",
")",
";",
"i",
"++",
")",
"{",
"INDArray",
"copyFilter",
"=",
"paramValue",
".",
"tensorAlongDimension",
"(",
"i",
",",
"2",
",",
"3",
")",
".",
"dup",
"(",
")",
";",
"double",
"[",
"]",
"flattenedFilter",
"=",
"copyFilter",
".",
"ravel",
"(",
")",
".",
"data",
"(",
")",
".",
"asDouble",
"(",
")",
";",
"ArrayUtils",
".",
"reverse",
"(",
"flattenedFilter",
")",
";",
"INDArray",
"newFilter",
"=",
"Nd4j",
".",
"create",
"(",
"flattenedFilter",
",",
"copyFilter",
".",
"shape",
"(",
")",
")",
";",
"INDArray",
"inPlaceFilter",
"=",
"paramValue",
".",
"tensorAlongDimension",
"(",
"i",
",",
"2",
",",
"3",
")",
";",
"inPlaceFilter",
".",
"muli",
"(",
"0",
")",
".",
"addi",
"(",
"newFilter",
")",
";",
"}",
"break",
";",
"default",
":",
"throw",
"new",
"InvalidKerasConfigurationException",
"(",
"\"Unknown keras backend \"",
"+",
"this",
".",
"getDimOrder",
"(",
")",
")",
";",
"}",
"this",
".",
"weights",
".",
"put",
"(",
"ConvolutionParamInitializer",
".",
"WEIGHT_KEY",
",",
"paramValue",
")",
";",
"}",
"else",
"throw",
"new",
"InvalidKerasConfigurationException",
"(",
"\"Parameter \"",
"+",
"conf",
".",
"getKERAS_PARAM_NAME_W",
"(",
")",
"+",
"\" does not exist in weights\"",
")",
";",
"if",
"(",
"hasBias",
")",
"{",
"if",
"(",
"weights",
".",
"containsKey",
"(",
"conf",
".",
"getKERAS_PARAM_NAME_B",
"(",
")",
")",
")",
"this",
".",
"weights",
".",
"put",
"(",
"ConvolutionParamInitializer",
".",
"BIAS_KEY",
",",
"weights",
".",
"get",
"(",
"conf",
".",
"getKERAS_PARAM_NAME_B",
"(",
")",
")",
")",
";",
"else",
"throw",
"new",
"InvalidKerasConfigurationException",
"(",
"\"Parameter \"",
"+",
"conf",
".",
"getKERAS_PARAM_NAME_B",
"(",
")",
"+",
"\" does not exist in weights\"",
")",
";",
"}",
"removeDefaultWeights",
"(",
"weights",
",",
"conf",
")",
";",
"}"
] |
Set weights for layer.
@param weights Map from parameter name to INDArray.
|
[
"Set",
"weights",
"for",
"layer",
"."
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/layers/convolutional/KerasConvolution1D.java#L177-L222
|
jenkinsci/artifactory-plugin
|
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
|
DockerAgentUtils.getImageIdFromAgent
|
public static String getImageIdFromAgent(Launcher launcher, final String imageTag, final String host) throws IOException, InterruptedException {
return launcher.getChannel().call(new MasterToSlaveCallable<String, IOException>() {
public String call() throws IOException {
return DockerUtils.getImageIdFromTag(imageTag, host);
}
});
}
|
java
|
public static String getImageIdFromAgent(Launcher launcher, final String imageTag, final String host) throws IOException, InterruptedException {
return launcher.getChannel().call(new MasterToSlaveCallable<String, IOException>() {
public String call() throws IOException {
return DockerUtils.getImageIdFromTag(imageTag, host);
}
});
}
|
[
"public",
"static",
"String",
"getImageIdFromAgent",
"(",
"Launcher",
"launcher",
",",
"final",
"String",
"imageTag",
",",
"final",
"String",
"host",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"return",
"launcher",
".",
"getChannel",
"(",
")",
".",
"call",
"(",
"new",
"MasterToSlaveCallable",
"<",
"String",
",",
"IOException",
">",
"(",
")",
"{",
"public",
"String",
"call",
"(",
")",
"throws",
"IOException",
"{",
"return",
"DockerUtils",
".",
"getImageIdFromTag",
"(",
"imageTag",
",",
"host",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Get image ID from imageTag on the current agent.
@param imageTag
@return
|
[
"Get",
"image",
"ID",
"from",
"imageTag",
"on",
"the",
"current",
"agent",
"."
] |
train
|
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L278-L284
|
JOML-CI/JOML
|
src/org/joml/Matrix3x2f.java
|
Matrix3x2f.scaleAround
|
public Matrix3x2f scaleAround(float sx, float sy, float ox, float oy) {
return scaleAround(sx, sy, ox, oy, this);
}
|
java
|
public Matrix3x2f scaleAround(float sx, float sy, float ox, float oy) {
return scaleAround(sx, sy, ox, oy, this);
}
|
[
"public",
"Matrix3x2f",
"scaleAround",
"(",
"float",
"sx",
",",
"float",
"sy",
",",
"float",
"ox",
",",
"float",
"oy",
")",
"{",
"return",
"scaleAround",
"(",
"sx",
",",
"sy",
",",
"ox",
",",
"oy",
",",
"this",
")",
";",
"}"
] |
Apply scaling to this matrix by scaling the base axes by the given sx and
sy factors while using <code>(ox, oy)</code> as the scaling origin.
<p>
If <code>M</code> is <code>this</code> matrix and <code>S</code> the scaling matrix,
then the new matrix will be <code>M * S</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * S * v</code>, the
scaling will be applied first!
<p>
This method is equivalent to calling: <code>translate(ox, oy).scale(sx, sy).translate(-ox, -oy)</code>
@param sx
the scaling factor of the x component
@param sy
the scaling factor of the y component
@param ox
the x coordinate of the scaling origin
@param oy
the y coordinate of the scaling origin
@return this
|
[
"Apply",
"scaling",
"to",
"this",
"matrix",
"by",
"scaling",
"the",
"base",
"axes",
"by",
"the",
"given",
"sx",
"and",
"sy",
"factors",
"while",
"using",
"<code",
">",
"(",
"ox",
"oy",
")",
"<",
"/",
"code",
">",
"as",
"the",
"scaling",
"origin",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"S<",
"/",
"code",
">",
"the",
"scaling",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"S<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"S",
"*",
"v<",
"/",
"code",
">",
"the",
"scaling",
"will",
"be",
"applied",
"first!",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
":",
"<code",
">",
"translate",
"(",
"ox",
"oy",
")",
".",
"scale",
"(",
"sx",
"sy",
")",
".",
"translate",
"(",
"-",
"ox",
"-",
"oy",
")",
"<",
"/",
"code",
">"
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix3x2f.java#L1431-L1433
|
jmapper-framework/jmapper-core
|
JMapper Framework/src/main/java/com/googlecode/jmapper/cache/JMapperCache.java
|
JMapperCache.relationalMapperName
|
private static String relationalMapperName(Class<?> configuredClass, String resource){
String className = configuredClass.getName().replaceAll("\\.","");
if(isEmpty(resource))
return className;
if(!isPath(resource))
return write(className, String.valueOf(resource.hashCode()));
String[]dep = resource.split("\\\\");
if(dep.length<=1)dep = resource.split("/");
String xml = dep[dep.length-1];
return write(className, xml.replaceAll("\\.","").replaceAll(" ",""));
}
|
java
|
private static String relationalMapperName(Class<?> configuredClass, String resource){
String className = configuredClass.getName().replaceAll("\\.","");
if(isEmpty(resource))
return className;
if(!isPath(resource))
return write(className, String.valueOf(resource.hashCode()));
String[]dep = resource.split("\\\\");
if(dep.length<=1)dep = resource.split("/");
String xml = dep[dep.length-1];
return write(className, xml.replaceAll("\\.","").replaceAll(" ",""));
}
|
[
"private",
"static",
"String",
"relationalMapperName",
"(",
"Class",
"<",
"?",
">",
"configuredClass",
",",
"String",
"resource",
")",
"{",
"String",
"className",
"=",
"configuredClass",
".",
"getName",
"(",
")",
".",
"replaceAll",
"(",
"\"\\\\.\"",
",",
"\"\"",
")",
";",
"if",
"(",
"isEmpty",
"(",
"resource",
")",
")",
"return",
"className",
";",
"if",
"(",
"!",
"isPath",
"(",
"resource",
")",
")",
"return",
"write",
"(",
"className",
",",
"String",
".",
"valueOf",
"(",
"resource",
".",
"hashCode",
"(",
")",
")",
")",
";",
"String",
"[",
"]",
"dep",
"=",
"resource",
".",
"split",
"(",
"\"\\\\\\\\\"",
")",
";",
"if",
"(",
"dep",
".",
"length",
"<=",
"1",
")",
"dep",
"=",
"resource",
".",
"split",
"(",
"\"/\"",
")",
";",
"String",
"xml",
"=",
"dep",
"[",
"dep",
".",
"length",
"-",
"1",
"]",
";",
"return",
"write",
"(",
"className",
",",
"xml",
".",
"replaceAll",
"(",
"\"\\\\.\"",
",",
"\"\"",
")",
".",
"replaceAll",
"(",
"\" \"",
",",
"\"\"",
")",
")",
";",
"}"
] |
Returns a unique name that identify this relationalMapper.
@param configuredClass configured class
@param resource resource to analyze
@return Returns a string that represents the identifier for this relationalMapper instance
|
[
"Returns",
"a",
"unique",
"name",
"that",
"identify",
"this",
"relationalMapper",
"."
] |
train
|
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/cache/JMapperCache.java#L215-L229
|
buschmais/jqa-javaee6-plugin
|
src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/WebXmlScannerPlugin.java
|
WebXmlScannerPlugin.setAsyncSupported
|
private void setAsyncSupported(AsyncSupportedDescriptor asyncSupportedDescriptor, TrueFalseType asyncSupported) {
if (asyncSupported != null) {
asyncSupportedDescriptor.setAsyncSupported(asyncSupported.isValue());
}
}
|
java
|
private void setAsyncSupported(AsyncSupportedDescriptor asyncSupportedDescriptor, TrueFalseType asyncSupported) {
if (asyncSupported != null) {
asyncSupportedDescriptor.setAsyncSupported(asyncSupported.isValue());
}
}
|
[
"private",
"void",
"setAsyncSupported",
"(",
"AsyncSupportedDescriptor",
"asyncSupportedDescriptor",
",",
"TrueFalseType",
"asyncSupported",
")",
"{",
"if",
"(",
"asyncSupported",
"!=",
"null",
")",
"{",
"asyncSupportedDescriptor",
".",
"setAsyncSupported",
"(",
"asyncSupported",
".",
"isValue",
"(",
")",
")",
";",
"}",
"}"
] |
Set the value for an async supported on the given descriptor.
@param asyncSupportedDescriptor
The async supported descriptor.
@param asyncSupported
The value.
|
[
"Set",
"the",
"value",
"for",
"an",
"async",
"supported",
"on",
"the",
"given",
"descriptor",
"."
] |
train
|
https://github.com/buschmais/jqa-javaee6-plugin/blob/f5776604d9255206807e5aca90b8767bde494e14/src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/WebXmlScannerPlugin.java#L480-L484
|
facebookarchive/hadoop-20
|
src/hdfs/org/apache/hadoop/hdfs/server/datanode/BlockInlineChecksumReader.java
|
BlockInlineChecksumReader.getPosFromBlockOffset
|
public static long getPosFromBlockOffset(long offsetInBlock, int bytesPerChecksum,
int checksumSize) {
// We only support to read full chunks, so offsetInBlock must be the boundary
// of the chunks.
assert offsetInBlock % bytesPerChecksum == 0;
// The position in the file will be the same as the file size for the block
// size.
return getFileLengthFromBlockSize(offsetInBlock, bytesPerChecksum, checksumSize);
}
|
java
|
public static long getPosFromBlockOffset(long offsetInBlock, int bytesPerChecksum,
int checksumSize) {
// We only support to read full chunks, so offsetInBlock must be the boundary
// of the chunks.
assert offsetInBlock % bytesPerChecksum == 0;
// The position in the file will be the same as the file size for the block
// size.
return getFileLengthFromBlockSize(offsetInBlock, bytesPerChecksum, checksumSize);
}
|
[
"public",
"static",
"long",
"getPosFromBlockOffset",
"(",
"long",
"offsetInBlock",
",",
"int",
"bytesPerChecksum",
",",
"int",
"checksumSize",
")",
"{",
"// We only support to read full chunks, so offsetInBlock must be the boundary",
"// of the chunks.",
"assert",
"offsetInBlock",
"%",
"bytesPerChecksum",
"==",
"0",
";",
"// The position in the file will be the same as the file size for the block",
"// size.",
"return",
"getFileLengthFromBlockSize",
"(",
"offsetInBlock",
",",
"bytesPerChecksum",
",",
"checksumSize",
")",
";",
"}"
] |
Translate from block offset to position in file.
@param offsetInBlock
@param bytesPerChecksum
@param checksumSize
@return
|
[
"Translate",
"from",
"block",
"offset",
"to",
"position",
"in",
"file",
"."
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/server/datanode/BlockInlineChecksumReader.java#L164-L172
|
sarl/sarl
|
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/JanusConfig.java
|
JanusConfig.getSystemProperty
|
public static String getSystemProperty(String name, String defaultValue) {
String value;
value = System.getProperty(name, null);
if (value != null) {
return value;
}
value = System.getenv(name);
if (value != null) {
return value;
}
return defaultValue;
}
|
java
|
public static String getSystemProperty(String name, String defaultValue) {
String value;
value = System.getProperty(name, null);
if (value != null) {
return value;
}
value = System.getenv(name);
if (value != null) {
return value;
}
return defaultValue;
}
|
[
"public",
"static",
"String",
"getSystemProperty",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"{",
"String",
"value",
";",
"value",
"=",
"System",
".",
"getProperty",
"(",
"name",
",",
"null",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"return",
"value",
";",
"}",
"value",
"=",
"System",
".",
"getenv",
"(",
"name",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"return",
"value",
";",
"}",
"return",
"defaultValue",
";",
"}"
] |
Replies the value of the system property.
@param name
- name of the property.
@param defaultValue
- value to reply if the these is no property found
@return the value, or defaultValue.
|
[
"Replies",
"the",
"value",
"of",
"the",
"system",
"property",
"."
] |
train
|
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/JanusConfig.java#L320-L331
|
fuinorg/units4j
|
src/main/java/org/fuin/units4j/Units4JUtils.java
|
Units4JUtils.assertCauseCauseMessage
|
public static void assertCauseCauseMessage(final Throwable ex, final String expectedMessage) {
assertThat(ex.getCause()).isNotNull();
assertThat(ex.getCause().getCause()).isNotNull();
assertThat(ex.getCause().getCause().getMessage()).isEqualTo(expectedMessage);
}
|
java
|
public static void assertCauseCauseMessage(final Throwable ex, final String expectedMessage) {
assertThat(ex.getCause()).isNotNull();
assertThat(ex.getCause().getCause()).isNotNull();
assertThat(ex.getCause().getCause().getMessage()).isEqualTo(expectedMessage);
}
|
[
"public",
"static",
"void",
"assertCauseCauseMessage",
"(",
"final",
"Throwable",
"ex",
",",
"final",
"String",
"expectedMessage",
")",
"{",
"assertThat",
"(",
"ex",
".",
"getCause",
"(",
")",
")",
".",
"isNotNull",
"(",
")",
";",
"assertThat",
"(",
"ex",
".",
"getCause",
"(",
")",
".",
"getCause",
"(",
")",
")",
".",
"isNotNull",
"(",
")",
";",
"assertThat",
"(",
"ex",
".",
"getCause",
"(",
")",
".",
"getCause",
"(",
")",
".",
"getMessage",
"(",
")",
")",
".",
"isEqualTo",
"(",
"expectedMessage",
")",
";",
"}"
] |
Verifies that the cause of a cause of an exception contains an expected message.
@param ex
Exception with the cause/cause to check,
@param expectedMessage
Message of the cause/cause.
|
[
"Verifies",
"that",
"the",
"cause",
"of",
"a",
"cause",
"of",
"an",
"exception",
"contains",
"an",
"expected",
"message",
"."
] |
train
|
https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L286-L290
|
javagl/ND
|
nd-distance/src/main/java/de/javagl/nd/distance/tuples/i/IntTupleDistanceFunctions.java
|
IntTupleDistanceFunctions.computeChebyshev
|
static int computeChebyshev(IntTuple t0, IntTuple t1)
{
Utils.checkForEqualSize(t0, t1);
int max = 0;
for (int i=0; i<t0.getSize(); i++)
{
int d = t0.get(i)-t1.get(i);
max = Math.max(max, Math.abs(d));
}
return max;
}
|
java
|
static int computeChebyshev(IntTuple t0, IntTuple t1)
{
Utils.checkForEqualSize(t0, t1);
int max = 0;
for (int i=0; i<t0.getSize(); i++)
{
int d = t0.get(i)-t1.get(i);
max = Math.max(max, Math.abs(d));
}
return max;
}
|
[
"static",
"int",
"computeChebyshev",
"(",
"IntTuple",
"t0",
",",
"IntTuple",
"t1",
")",
"{",
"Utils",
".",
"checkForEqualSize",
"(",
"t0",
",",
"t1",
")",
";",
"int",
"max",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"t0",
".",
"getSize",
"(",
")",
";",
"i",
"++",
")",
"{",
"int",
"d",
"=",
"t0",
".",
"get",
"(",
"i",
")",
"-",
"t1",
".",
"get",
"(",
"i",
")",
";",
"max",
"=",
"Math",
".",
"max",
"(",
"max",
",",
"Math",
".",
"abs",
"(",
"d",
")",
")",
";",
"}",
"return",
"max",
";",
"}"
] |
Computes the Chebyshev distance between the given tuples
@param t0 The first tuple
@param t1 The second tuple
@return The distance
@throws IllegalArgumentException If the given tuples do not
have the same {@link Tuple#getSize() size}
|
[
"Computes",
"the",
"Chebyshev",
"distance",
"between",
"the",
"given",
"tuples"
] |
train
|
https://github.com/javagl/ND/blob/bcb655aaf5fc88af6194f73a27cca079186ff559/nd-distance/src/main/java/de/javagl/nd/distance/tuples/i/IntTupleDistanceFunctions.java#L313-L323
|
lightblueseas/swing-components
|
src/main/java/de/alpharogroup/swing/img/ImageExtensions.java
|
ImageExtensions.randomBufferedImage
|
public static BufferedImage randomBufferedImage(final int width, final int height,
final int imageType)
{
final BufferedImage img = new BufferedImage(width, height, imageType);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
img.setRGB(x, y, RandomExtensions.newRandomPixel());
}
}
return img;
}
|
java
|
public static BufferedImage randomBufferedImage(final int width, final int height,
final int imageType)
{
final BufferedImage img = new BufferedImage(width, height, imageType);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
img.setRGB(x, y, RandomExtensions.newRandomPixel());
}
}
return img;
}
|
[
"public",
"static",
"BufferedImage",
"randomBufferedImage",
"(",
"final",
"int",
"width",
",",
"final",
"int",
"height",
",",
"final",
"int",
"imageType",
")",
"{",
"final",
"BufferedImage",
"img",
"=",
"new",
"BufferedImage",
"(",
"width",
",",
"height",
",",
"imageType",
")",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"height",
";",
"y",
"++",
")",
"{",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"width",
";",
"x",
"++",
")",
"{",
"img",
".",
"setRGB",
"(",
"x",
",",
"y",
",",
"RandomExtensions",
".",
"newRandomPixel",
"(",
")",
")",
";",
"}",
"}",
"return",
"img",
";",
"}"
] |
Generates a random {@link BufferedImage} with the given parameters.
@param width
the width
@param height
the height
@param imageType
the type of the image
@return The generated {@link BufferedImage}.
|
[
"Generates",
"a",
"random",
"{",
"@link",
"BufferedImage",
"}",
"with",
"the",
"given",
"parameters",
"."
] |
train
|
https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/img/ImageExtensions.java#L242-L254
|
KyoriPowered/text
|
api/src/main/java/net/kyori/text/TranslatableComponent.java
|
TranslatableComponent.of
|
public static TranslatableComponent of(final @NonNull String key, final @Nullable TextColor color, final @NonNull List<Component> args) {
return of(key, color, Collections.emptySet(), args);
}
|
java
|
public static TranslatableComponent of(final @NonNull String key, final @Nullable TextColor color, final @NonNull List<Component> args) {
return of(key, color, Collections.emptySet(), args);
}
|
[
"public",
"static",
"TranslatableComponent",
"of",
"(",
"final",
"@",
"NonNull",
"String",
"key",
",",
"final",
"@",
"Nullable",
"TextColor",
"color",
",",
"final",
"@",
"NonNull",
"List",
"<",
"Component",
">",
"args",
")",
"{",
"return",
"of",
"(",
"key",
",",
"color",
",",
"Collections",
".",
"emptySet",
"(",
")",
",",
"args",
")",
";",
"}"
] |
Creates a translatable component with a translation key and arguments.
@param key the translation key
@param color the color
@param args the translation arguments
@return the translatable component
|
[
"Creates",
"a",
"translatable",
"component",
"with",
"a",
"translation",
"key",
"and",
"arguments",
"."
] |
train
|
https://github.com/KyoriPowered/text/blob/4496c593bf89e8fb036dd6efe26f8ac60f7655c9/api/src/main/java/net/kyori/text/TranslatableComponent.java#L169-L171
|
lightblueseas/swing-components
|
src/main/java/de/alpharogroup/swing/components/factories/JComponentFactory.java
|
JComponentFactory.newJSplitPane
|
public static JSplitPane newJSplitPane(Component newLeftComponent, Component newRightComponent)
{
return newJSplitPane(JSplitPane.HORIZONTAL_SPLIT, newLeftComponent, newRightComponent);
}
|
java
|
public static JSplitPane newJSplitPane(Component newLeftComponent, Component newRightComponent)
{
return newJSplitPane(JSplitPane.HORIZONTAL_SPLIT, newLeftComponent, newRightComponent);
}
|
[
"public",
"static",
"JSplitPane",
"newJSplitPane",
"(",
"Component",
"newLeftComponent",
",",
"Component",
"newRightComponent",
")",
"{",
"return",
"newJSplitPane",
"(",
"JSplitPane",
".",
"HORIZONTAL_SPLIT",
",",
"newLeftComponent",
",",
"newRightComponent",
")",
";",
"}"
] |
Factory method for create new {@link JSplitPane} object
@param newLeftComponent
the <code>Component</code> that will appear on the left of a horizontally-split
pane, or at the top of a vertically-split pane
@param newRightComponent
the <code>Component</code> that will appear on the right of a horizontally-split
pane, or at the bottom of a vertically-split pane
@return the new {@link JSplitPane} object
|
[
"Factory",
"method",
"for",
"create",
"new",
"{",
"@link",
"JSplitPane",
"}",
"object"
] |
train
|
https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/components/factories/JComponentFactory.java#L83-L86
|
opsmatters/newrelic-api
|
src/main/java/com/opsmatters/newrelic/api/services/HttpContext.java
|
HttpContext.PATCH
|
public <T> Optional<T> PATCH(String partialUrl, Object payload, GenericType<T> returnType)
{
URI uri = buildUri(partialUrl);
return executePatchRequest(uri, payload, null, null, returnType);
}
|
java
|
public <T> Optional<T> PATCH(String partialUrl, Object payload, GenericType<T> returnType)
{
URI uri = buildUri(partialUrl);
return executePatchRequest(uri, payload, null, null, returnType);
}
|
[
"public",
"<",
"T",
">",
"Optional",
"<",
"T",
">",
"PATCH",
"(",
"String",
"partialUrl",
",",
"Object",
"payload",
",",
"GenericType",
"<",
"T",
">",
"returnType",
")",
"{",
"URI",
"uri",
"=",
"buildUri",
"(",
"partialUrl",
")",
";",
"return",
"executePatchRequest",
"(",
"uri",
",",
"payload",
",",
"null",
",",
"null",
",",
"returnType",
")",
";",
"}"
] |
Execute a PATCH call against the partial URL.
@param <T> The type parameter used for the return object
@param partialUrl The partial URL to build
@param payload The object to use for the PATCH
@param returnType The expected return type
@return The return type
|
[
"Execute",
"a",
"PATCH",
"call",
"against",
"the",
"partial",
"URL",
"."
] |
train
|
https://github.com/opsmatters/newrelic-api/blob/5bc2ea62ec368db891e4fd5fe3dcdf529d086b5e/src/main/java/com/opsmatters/newrelic/api/services/HttpContext.java#L275-L279
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.crypto.ltpakeyutil/src/com/ibm/ws/crypto/ltpakeyutil/LTPAKeyFileUtilityImpl.java
|
LTPAKeyFileUtilityImpl.addLTPAKeysToFile
|
protected void addLTPAKeysToFile(OutputStream os, Properties ltpaProps) throws Exception {
try {
// Write the ltpa key propeperties to
ltpaProps.store(os, null);
} catch (IOException e) {
throw e;
} finally {
if (os != null)
try {
os.close();
} catch (IOException e) {
}
}
return;
}
|
java
|
protected void addLTPAKeysToFile(OutputStream os, Properties ltpaProps) throws Exception {
try {
// Write the ltpa key propeperties to
ltpaProps.store(os, null);
} catch (IOException e) {
throw e;
} finally {
if (os != null)
try {
os.close();
} catch (IOException e) {
}
}
return;
}
|
[
"protected",
"void",
"addLTPAKeysToFile",
"(",
"OutputStream",
"os",
",",
"Properties",
"ltpaProps",
")",
"throws",
"Exception",
"{",
"try",
"{",
"// Write the ltpa key propeperties to",
"ltpaProps",
".",
"store",
"(",
"os",
",",
"null",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"finally",
"{",
"if",
"(",
"os",
"!=",
"null",
")",
"try",
"{",
"os",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"}",
"}",
"return",
";",
"}"
] |
Write the LTPA key properties to the given OutputStream. This method
will close the OutputStream.
@param keyImportFile The import file to be created
@param ltpaProps The properties containing the LTPA keys
@throws TokenException
@throws IOException
|
[
"Write",
"the",
"LTPA",
"key",
"properties",
"to",
"the",
"given",
"OutputStream",
".",
"This",
"method",
"will",
"close",
"the",
"OutputStream",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.crypto.ltpakeyutil/src/com/ibm/ws/crypto/ltpakeyutil/LTPAKeyFileUtilityImpl.java#L109-L124
|
facebookarchive/hadoop-20
|
src/contrib/highavailability/src/java/org/apache/hadoop/hdfs/server/datanode/OfferService.java
|
OfferService.processFailedReceivedDeleted
|
private void processFailedReceivedDeleted(long[] failedMap, Block[] sent) {
synchronized (receivedAndDeletedBlockList) {
// Blocks that do not belong to an Inode are saved for
// retransmisions
for (int i = sent.length - 1 ; i >= 0; i--) {
if(!LightWeightBitSet.get(failedMap, i)){
continue;
}
// Insert into retry list.
LOG.info("Block " + sent[i] + " does not belong to any file "
+ "on namenode " + avatarnodeAddress + " Retry later.");
receivedAndDeletedBlockList.add(0, sent[i]);
if (!DFSUtil.isDeleted(sent[i])) {
pendingReceivedRequests++;
}
}
lastBlockReceivedFailed = AvatarDataNode.now();
}
}
|
java
|
private void processFailedReceivedDeleted(long[] failedMap, Block[] sent) {
synchronized (receivedAndDeletedBlockList) {
// Blocks that do not belong to an Inode are saved for
// retransmisions
for (int i = sent.length - 1 ; i >= 0; i--) {
if(!LightWeightBitSet.get(failedMap, i)){
continue;
}
// Insert into retry list.
LOG.info("Block " + sent[i] + " does not belong to any file "
+ "on namenode " + avatarnodeAddress + " Retry later.");
receivedAndDeletedBlockList.add(0, sent[i]);
if (!DFSUtil.isDeleted(sent[i])) {
pendingReceivedRequests++;
}
}
lastBlockReceivedFailed = AvatarDataNode.now();
}
}
|
[
"private",
"void",
"processFailedReceivedDeleted",
"(",
"long",
"[",
"]",
"failedMap",
",",
"Block",
"[",
"]",
"sent",
")",
"{",
"synchronized",
"(",
"receivedAndDeletedBlockList",
")",
"{",
"// Blocks that do not belong to an Inode are saved for",
"// retransmisions",
"for",
"(",
"int",
"i",
"=",
"sent",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"!",
"LightWeightBitSet",
".",
"get",
"(",
"failedMap",
",",
"i",
")",
")",
"{",
"continue",
";",
"}",
"// Insert into retry list.",
"LOG",
".",
"info",
"(",
"\"Block \"",
"+",
"sent",
"[",
"i",
"]",
"+",
"\" does not belong to any file \"",
"+",
"\"on namenode \"",
"+",
"avatarnodeAddress",
"+",
"\" Retry later.\"",
")",
";",
"receivedAndDeletedBlockList",
".",
"add",
"(",
"0",
",",
"sent",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"DFSUtil",
".",
"isDeleted",
"(",
"sent",
"[",
"i",
"]",
")",
")",
"{",
"pendingReceivedRequests",
"++",
";",
"}",
"}",
"lastBlockReceivedFailed",
"=",
"AvatarDataNode",
".",
"now",
"(",
")",
";",
"}",
"}"
] |
Adds blocks of incremental block report back to the
receivedAndDeletedBlockList when the blocks are to be
retried later (when sending to standby)
@param failed
|
[
"Adds",
"blocks",
"of",
"incremental",
"block",
"report",
"back",
"to",
"the",
"receivedAndDeletedBlockList",
"when",
"the",
"blocks",
"are",
"to",
"be",
"retried",
"later",
"(",
"when",
"sending",
"to",
"standby",
")"
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/highavailability/src/java/org/apache/hadoop/hdfs/server/datanode/OfferService.java#L511-L529
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/JScreen.java
|
JScreen.createScreenComponent
|
public JComponent createScreenComponent(Converter fieldInfo)
{
int iRows = 1;
int iColumns = fieldInfo.getMaxLength();
if (iColumns > 40)
{
iRows = 3;
iColumns = 30;
}
String strDefault = fieldInfo.toString();
if (strDefault == null)
strDefault = Constants.BLANK;
JComponent component = null;
if (iRows <= 1)
{
component = new JTextField(strDefault, iColumns);
if (fieldInfo instanceof FieldInfo)
if (Number.class.isAssignableFrom(((FieldInfo)fieldInfo).getDataClass()))
((JTextField)component).setHorizontalAlignment(JTextField.RIGHT);
}
else
{
component = new JTextArea(strDefault, iRows, iColumns);
component.setBorder(m_borderLine);
}
return component;
}
|
java
|
public JComponent createScreenComponent(Converter fieldInfo)
{
int iRows = 1;
int iColumns = fieldInfo.getMaxLength();
if (iColumns > 40)
{
iRows = 3;
iColumns = 30;
}
String strDefault = fieldInfo.toString();
if (strDefault == null)
strDefault = Constants.BLANK;
JComponent component = null;
if (iRows <= 1)
{
component = new JTextField(strDefault, iColumns);
if (fieldInfo instanceof FieldInfo)
if (Number.class.isAssignableFrom(((FieldInfo)fieldInfo).getDataClass()))
((JTextField)component).setHorizontalAlignment(JTextField.RIGHT);
}
else
{
component = new JTextArea(strDefault, iRows, iColumns);
component.setBorder(m_borderLine);
}
return component;
}
|
[
"public",
"JComponent",
"createScreenComponent",
"(",
"Converter",
"fieldInfo",
")",
"{",
"int",
"iRows",
"=",
"1",
";",
"int",
"iColumns",
"=",
"fieldInfo",
".",
"getMaxLength",
"(",
")",
";",
"if",
"(",
"iColumns",
">",
"40",
")",
"{",
"iRows",
"=",
"3",
";",
"iColumns",
"=",
"30",
";",
"}",
"String",
"strDefault",
"=",
"fieldInfo",
".",
"toString",
"(",
")",
";",
"if",
"(",
"strDefault",
"==",
"null",
")",
"strDefault",
"=",
"Constants",
".",
"BLANK",
";",
"JComponent",
"component",
"=",
"null",
";",
"if",
"(",
"iRows",
"<=",
"1",
")",
"{",
"component",
"=",
"new",
"JTextField",
"(",
"strDefault",
",",
"iColumns",
")",
";",
"if",
"(",
"fieldInfo",
"instanceof",
"FieldInfo",
")",
"if",
"(",
"Number",
".",
"class",
".",
"isAssignableFrom",
"(",
"(",
"(",
"FieldInfo",
")",
"fieldInfo",
")",
".",
"getDataClass",
"(",
")",
")",
")",
"(",
"(",
"JTextField",
")",
"component",
")",
".",
"setHorizontalAlignment",
"(",
"JTextField",
".",
"RIGHT",
")",
";",
"}",
"else",
"{",
"component",
"=",
"new",
"JTextArea",
"(",
"strDefault",
",",
"iRows",
",",
"iColumns",
")",
";",
"component",
".",
"setBorder",
"(",
"m_borderLine",
")",
";",
"}",
"return",
"component",
";",
"}"
] |
Add the screen controls to the second column of the grid.
Create a default component for this fieldInfo.
@param fieldInfo the field to create a control for.
@return The component.
|
[
"Add",
"the",
"screen",
"controls",
"to",
"the",
"second",
"column",
"of",
"the",
"grid",
".",
"Create",
"a",
"default",
"component",
"for",
"this",
"fieldInfo",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/JScreen.java#L298-L325
|
eFaps/eFaps-Kernel
|
src/main/java/org/efaps/db/print/value/ClassificationValueSelect.java
|
ClassificationValueSelect.executeOneCompleteStmt
|
protected boolean executeOneCompleteStmt(final String _complStmt,
final List<Instance> _instances)
throws EFapsException
{
final boolean ret = false;
ConnectionResource con = null;
try {
con = Context.getThreadContext().getConnectionResource();
final Statement stmt = con.createStatement();
final ResultSet rs = stmt.executeQuery(_complStmt.toString());
final Map<Long, List<Long>> link2clazz = new HashMap<>();
while (rs.next()) {
final long linkId = rs.getLong(2);
final long classificationID = rs.getLong(3);
final List<Long> templ;
if (link2clazz.containsKey(linkId)) {
templ = link2clazz.get(linkId);
} else {
templ = new ArrayList<>();
link2clazz.put(linkId, templ);
}
templ.add(classificationID);
}
for (final Instance instance : _instances) {
this.instances2classId.put(instance, link2clazz.get(instance.getId()));
}
rs.close();
stmt.close();
} catch (final SQLException e) {
throw new EFapsException(ClassificationValueSelect.class, "executeOneCompleteStmt", e);
}
return ret;
}
|
java
|
protected boolean executeOneCompleteStmt(final String _complStmt,
final List<Instance> _instances)
throws EFapsException
{
final boolean ret = false;
ConnectionResource con = null;
try {
con = Context.getThreadContext().getConnectionResource();
final Statement stmt = con.createStatement();
final ResultSet rs = stmt.executeQuery(_complStmt.toString());
final Map<Long, List<Long>> link2clazz = new HashMap<>();
while (rs.next()) {
final long linkId = rs.getLong(2);
final long classificationID = rs.getLong(3);
final List<Long> templ;
if (link2clazz.containsKey(linkId)) {
templ = link2clazz.get(linkId);
} else {
templ = new ArrayList<>();
link2clazz.put(linkId, templ);
}
templ.add(classificationID);
}
for (final Instance instance : _instances) {
this.instances2classId.put(instance, link2clazz.get(instance.getId()));
}
rs.close();
stmt.close();
} catch (final SQLException e) {
throw new EFapsException(ClassificationValueSelect.class, "executeOneCompleteStmt", e);
}
return ret;
}
|
[
"protected",
"boolean",
"executeOneCompleteStmt",
"(",
"final",
"String",
"_complStmt",
",",
"final",
"List",
"<",
"Instance",
">",
"_instances",
")",
"throws",
"EFapsException",
"{",
"final",
"boolean",
"ret",
"=",
"false",
";",
"ConnectionResource",
"con",
"=",
"null",
";",
"try",
"{",
"con",
"=",
"Context",
".",
"getThreadContext",
"(",
")",
".",
"getConnectionResource",
"(",
")",
";",
"final",
"Statement",
"stmt",
"=",
"con",
".",
"createStatement",
"(",
")",
";",
"final",
"ResultSet",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
"_complStmt",
".",
"toString",
"(",
")",
")",
";",
"final",
"Map",
"<",
"Long",
",",
"List",
"<",
"Long",
">",
">",
"link2clazz",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"final",
"long",
"linkId",
"=",
"rs",
".",
"getLong",
"(",
"2",
")",
";",
"final",
"long",
"classificationID",
"=",
"rs",
".",
"getLong",
"(",
"3",
")",
";",
"final",
"List",
"<",
"Long",
">",
"templ",
";",
"if",
"(",
"link2clazz",
".",
"containsKey",
"(",
"linkId",
")",
")",
"{",
"templ",
"=",
"link2clazz",
".",
"get",
"(",
"linkId",
")",
";",
"}",
"else",
"{",
"templ",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"link2clazz",
".",
"put",
"(",
"linkId",
",",
"templ",
")",
";",
"}",
"templ",
".",
"add",
"(",
"classificationID",
")",
";",
"}",
"for",
"(",
"final",
"Instance",
"instance",
":",
"_instances",
")",
"{",
"this",
".",
"instances2classId",
".",
"put",
"(",
"instance",
",",
"link2clazz",
".",
"get",
"(",
"instance",
".",
"getId",
"(",
")",
")",
")",
";",
"}",
"rs",
".",
"close",
"(",
")",
";",
"stmt",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"EFapsException",
"(",
"ClassificationValueSelect",
".",
"class",
",",
"\"executeOneCompleteStmt\"",
",",
"e",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Method to execute one statement against the eFaps-DataBase.
@param _complStmt ststement
@param _instances list of instances
@return true it values where found
@throws EFapsException on error
|
[
"Method",
"to",
"execute",
"one",
"statement",
"against",
"the",
"eFaps",
"-",
"DataBase",
"."
] |
train
|
https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/db/print/value/ClassificationValueSelect.java#L259-L293
|
LearnLib/automatalib
|
util/src/main/java/net/automatalib/util/minimizer/Minimizer.java
|
Minimizer.addAllToSplitterQueue
|
private void addAllToSplitterQueue(Collection<Block<S, L>> blocks) {
for (Block<S, L> block : blocks) {
addToSplitterQueue(block);
}
}
|
java
|
private void addAllToSplitterQueue(Collection<Block<S, L>> blocks) {
for (Block<S, L> block : blocks) {
addToSplitterQueue(block);
}
}
|
[
"private",
"void",
"addAllToSplitterQueue",
"(",
"Collection",
"<",
"Block",
"<",
"S",
",",
"L",
">",
">",
"blocks",
")",
"{",
"for",
"(",
"Block",
"<",
"S",
",",
"L",
">",
"block",
":",
"blocks",
")",
"{",
"addToSplitterQueue",
"(",
"block",
")",
";",
"}",
"}"
] |
Adds all but the largest block of a given collection to the splitter queue.
|
[
"Adds",
"all",
"but",
"the",
"largest",
"block",
"of",
"a",
"given",
"collection",
"to",
"the",
"splitter",
"queue",
"."
] |
train
|
https://github.com/LearnLib/automatalib/blob/8a462ec52f6eaab9f8996e344f2163a72cb8aa6e/util/src/main/java/net/automatalib/util/minimizer/Minimizer.java#L454-L458
|
sundrio/sundrio
|
annotations/builder/src/main/java/io/sundr/builder/internal/functions/ToPojo.java
|
ToPojo.readAnnotationProperty
|
private static String readAnnotationProperty(String ref, TypeDef source, Property property) {
return convertReference(ref, source, ((ClassRef)property.getTypeRef()).getDefinition());
}
|
java
|
private static String readAnnotationProperty(String ref, TypeDef source, Property property) {
return convertReference(ref, source, ((ClassRef)property.getTypeRef()).getDefinition());
}
|
[
"private",
"static",
"String",
"readAnnotationProperty",
"(",
"String",
"ref",
",",
"TypeDef",
"source",
",",
"Property",
"property",
")",
"{",
"return",
"convertReference",
"(",
"ref",
",",
"source",
",",
"(",
"(",
"ClassRef",
")",
"property",
".",
"getTypeRef",
"(",
")",
")",
".",
"getDefinition",
"(",
")",
")",
";",
"}"
] |
Returns the string representation of the code that reads a primitive array property.
@param ref The reference.
@param source The type of the reference.
@param property The property to read.
@return The code.
|
[
"Returns",
"the",
"string",
"representation",
"of",
"the",
"code",
"that",
"reads",
"a",
"primitive",
"array",
"property",
"."
] |
train
|
https://github.com/sundrio/sundrio/blob/4e38368f4db0d950f7c41a8c75e15b0baff1f69a/annotations/builder/src/main/java/io/sundr/builder/internal/functions/ToPojo.java#L675-L677
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJSWrapperCommon.java
|
EJSWrapperCommon.getFieldValue
|
private static Object getFieldValue(FieldClassValue fieldClassValue, Object obj) {
try {
return fieldClassValue.get(obj.getClass()).get(obj);
} catch (IllegalAccessException e) {
// FieldClassValueFactory returns ClassValue that make the Field
// accessible, so this should not happen.
throw new IllegalStateException(e);
}
}
|
java
|
private static Object getFieldValue(FieldClassValue fieldClassValue, Object obj) {
try {
return fieldClassValue.get(obj.getClass()).get(obj);
} catch (IllegalAccessException e) {
// FieldClassValueFactory returns ClassValue that make the Field
// accessible, so this should not happen.
throw new IllegalStateException(e);
}
}
|
[
"private",
"static",
"Object",
"getFieldValue",
"(",
"FieldClassValue",
"fieldClassValue",
",",
"Object",
"obj",
")",
"{",
"try",
"{",
"return",
"fieldClassValue",
".",
"get",
"(",
"obj",
".",
"getClass",
"(",
")",
")",
".",
"get",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"// FieldClassValueFactory returns ClassValue that make the Field",
"// accessible, so this should not happen.",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}"
] |
Get the value of a field from an object.
@param fieldClassValue the Field class value
@param obj the object
@return the field value
|
[
"Get",
"the",
"value",
"of",
"a",
"field",
"from",
"an",
"object",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/EJSWrapperCommon.java#L468-L476
|
zxing/zxing
|
core/src/main/java/com/google/zxing/oned/ITFReader.java
|
ITFReader.decodeEnd
|
private int[] decodeEnd(BitArray row) throws NotFoundException {
// For convenience, reverse the row and then
// search from 'the start' for the end block
row.reverse();
try {
int endStart = skipWhiteSpace(row);
int[] endPattern;
try {
endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED[0]);
} catch (NotFoundException nfe) {
endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED[1]);
}
// The start & end patterns must be pre/post fixed by a quiet zone. This
// zone must be at least 10 times the width of a narrow line.
// ref: http://www.barcode-1.net/i25code.html
validateQuietZone(row, endPattern[0]);
// Now recalculate the indices of where the 'endblock' starts & stops to
// accommodate
// the reversed nature of the search
int temp = endPattern[0];
endPattern[0] = row.getSize() - endPattern[1];
endPattern[1] = row.getSize() - temp;
return endPattern;
} finally {
// Put the row back the right way.
row.reverse();
}
}
|
java
|
private int[] decodeEnd(BitArray row) throws NotFoundException {
// For convenience, reverse the row and then
// search from 'the start' for the end block
row.reverse();
try {
int endStart = skipWhiteSpace(row);
int[] endPattern;
try {
endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED[0]);
} catch (NotFoundException nfe) {
endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED[1]);
}
// The start & end patterns must be pre/post fixed by a quiet zone. This
// zone must be at least 10 times the width of a narrow line.
// ref: http://www.barcode-1.net/i25code.html
validateQuietZone(row, endPattern[0]);
// Now recalculate the indices of where the 'endblock' starts & stops to
// accommodate
// the reversed nature of the search
int temp = endPattern[0];
endPattern[0] = row.getSize() - endPattern[1];
endPattern[1] = row.getSize() - temp;
return endPattern;
} finally {
// Put the row back the right way.
row.reverse();
}
}
|
[
"private",
"int",
"[",
"]",
"decodeEnd",
"(",
"BitArray",
"row",
")",
"throws",
"NotFoundException",
"{",
"// For convenience, reverse the row and then",
"// search from 'the start' for the end block",
"row",
".",
"reverse",
"(",
")",
";",
"try",
"{",
"int",
"endStart",
"=",
"skipWhiteSpace",
"(",
"row",
")",
";",
"int",
"[",
"]",
"endPattern",
";",
"try",
"{",
"endPattern",
"=",
"findGuardPattern",
"(",
"row",
",",
"endStart",
",",
"END_PATTERN_REVERSED",
"[",
"0",
"]",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"nfe",
")",
"{",
"endPattern",
"=",
"findGuardPattern",
"(",
"row",
",",
"endStart",
",",
"END_PATTERN_REVERSED",
"[",
"1",
"]",
")",
";",
"}",
"// The start & end patterns must be pre/post fixed by a quiet zone. This",
"// zone must be at least 10 times the width of a narrow line.",
"// ref: http://www.barcode-1.net/i25code.html",
"validateQuietZone",
"(",
"row",
",",
"endPattern",
"[",
"0",
"]",
")",
";",
"// Now recalculate the indices of where the 'endblock' starts & stops to",
"// accommodate",
"// the reversed nature of the search",
"int",
"temp",
"=",
"endPattern",
"[",
"0",
"]",
";",
"endPattern",
"[",
"0",
"]",
"=",
"row",
".",
"getSize",
"(",
")",
"-",
"endPattern",
"[",
"1",
"]",
";",
"endPattern",
"[",
"1",
"]",
"=",
"row",
".",
"getSize",
"(",
")",
"-",
"temp",
";",
"return",
"endPattern",
";",
"}",
"finally",
"{",
"// Put the row back the right way.",
"row",
".",
"reverse",
"(",
")",
";",
"}",
"}"
] |
Identify where the end of the middle / payload section ends.
@param row row of black/white values to search
@return Array, containing index of start of 'end block' and end of 'end
block'
|
[
"Identify",
"where",
"the",
"end",
"of",
"the",
"middle",
"/",
"payload",
"section",
"ends",
"."
] |
train
|
https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/core/src/main/java/com/google/zxing/oned/ITFReader.java#L271-L302
|
QSFT/Doradus
|
doradus-common/src/main/java/com/dell/doradus/common/DBObject.java
|
DBObject.addFieldValue
|
public void addFieldValue(String fieldName, String value) {
Utils.require(!Utils.isEmpty(fieldName), "fieldName");
if (fieldName.charAt(0) == '_') {
setSystemField(fieldName, value);
} else {
List<String> currValues = m_valueMap.get(fieldName);
if (currValues == null) {
currValues = new ArrayList<>();
m_valueMap.put(fieldName, currValues);
}
currValues.add(value);
}
}
|
java
|
public void addFieldValue(String fieldName, String value) {
Utils.require(!Utils.isEmpty(fieldName), "fieldName");
if (fieldName.charAt(0) == '_') {
setSystemField(fieldName, value);
} else {
List<String> currValues = m_valueMap.get(fieldName);
if (currValues == null) {
currValues = new ArrayList<>();
m_valueMap.put(fieldName, currValues);
}
currValues.add(value);
}
}
|
[
"public",
"void",
"addFieldValue",
"(",
"String",
"fieldName",
",",
"String",
"value",
")",
"{",
"Utils",
".",
"require",
"(",
"!",
"Utils",
".",
"isEmpty",
"(",
"fieldName",
")",
",",
"\"fieldName\"",
")",
";",
"if",
"(",
"fieldName",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"{",
"setSystemField",
"(",
"fieldName",
",",
"value",
")",
";",
"}",
"else",
"{",
"List",
"<",
"String",
">",
"currValues",
"=",
"m_valueMap",
".",
"get",
"(",
"fieldName",
")",
";",
"if",
"(",
"currValues",
"==",
"null",
")",
"{",
"currValues",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"m_valueMap",
".",
"put",
"(",
"fieldName",
",",
"currValues",
")",
";",
"}",
"currValues",
".",
"add",
"(",
"value",
")",
";",
"}",
"}"
] |
Add the given value to the field with the given name. For a system field, its
existing value, if any, is replaced. If a null or empty field is added for an
SV scalar, the field is nullified.
@param fieldName Name of a field.
@param value Value to add to field. Ignored if null or empty.
|
[
"Add",
"the",
"given",
"value",
"to",
"the",
"field",
"with",
"the",
"given",
"name",
".",
"For",
"a",
"system",
"field",
"its",
"existing",
"value",
"if",
"any",
"is",
"replaced",
".",
"If",
"a",
"null",
"or",
"empty",
"field",
"is",
"added",
"for",
"an",
"SV",
"scalar",
"the",
"field",
"is",
"nullified",
"."
] |
train
|
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/DBObject.java#L403-L416
|
phax/ph-commons
|
ph-commons/src/main/java/com/helger/commons/string/StringParser.java
|
StringParser.parseDouble
|
public static double parseDouble (@Nullable final String sStr, final double dDefault)
{
// parseDouble throws a NPE if parameter is null
if (sStr != null && sStr.length () > 0)
try
{
// Single point where we replace "," with "." for parsing!
return Double.parseDouble (_getUnifiedDecimal (sStr));
}
catch (final NumberFormatException ex)
{
// Fall through
}
return dDefault;
}
|
java
|
public static double parseDouble (@Nullable final String sStr, final double dDefault)
{
// parseDouble throws a NPE if parameter is null
if (sStr != null && sStr.length () > 0)
try
{
// Single point where we replace "," with "." for parsing!
return Double.parseDouble (_getUnifiedDecimal (sStr));
}
catch (final NumberFormatException ex)
{
// Fall through
}
return dDefault;
}
|
[
"public",
"static",
"double",
"parseDouble",
"(",
"@",
"Nullable",
"final",
"String",
"sStr",
",",
"final",
"double",
"dDefault",
")",
"{",
"// parseDouble throws a NPE if parameter is null",
"if",
"(",
"sStr",
"!=",
"null",
"&&",
"sStr",
".",
"length",
"(",
")",
">",
"0",
")",
"try",
"{",
"// Single point where we replace \",\" with \".\" for parsing!",
"return",
"Double",
".",
"parseDouble",
"(",
"_getUnifiedDecimal",
"(",
"sStr",
")",
")",
";",
"}",
"catch",
"(",
"final",
"NumberFormatException",
"ex",
")",
"{",
"// Fall through",
"}",
"return",
"dDefault",
";",
"}"
] |
Parse the given {@link String} as double.
@param sStr
The string to parse. May be <code>null</code>.
@param dDefault
The default value to be returned if the passed object could not be
converted to a valid value.
@return The default value if the string does not represent a valid value.
|
[
"Parse",
"the",
"given",
"{",
"@link",
"String",
"}",
"as",
"double",
"."
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringParser.java#L484-L498
|
jaxio/javaee-lab
|
javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java
|
GenericRepository.findPropertyCount
|
@Transactional
public int findPropertyCount(E entity, SearchParameters sp, Attribute<?, ?>... attributes) {
return findPropertyCount(entity, sp, newArrayList(attributes));
}
|
java
|
@Transactional
public int findPropertyCount(E entity, SearchParameters sp, Attribute<?, ?>... attributes) {
return findPropertyCount(entity, sp, newArrayList(attributes));
}
|
[
"@",
"Transactional",
"public",
"int",
"findPropertyCount",
"(",
"E",
"entity",
",",
"SearchParameters",
"sp",
",",
"Attribute",
"<",
"?",
",",
"?",
">",
"...",
"attributes",
")",
"{",
"return",
"findPropertyCount",
"(",
"entity",
",",
"sp",
",",
"newArrayList",
"(",
"attributes",
")",
")",
";",
"}"
] |
Count the number of E instances.
@param entity a sample entity whose non-null properties may be used as search hint
@param sp carries additional search information
@param attributes the list of attributes to the property
@return the number of entities matching the search.
|
[
"Count",
"the",
"number",
"of",
"E",
"instances",
"."
] |
train
|
https://github.com/jaxio/javaee-lab/blob/61238b967952446d81cc68424a4e809093a77fcf/javaee7-jpa-query-by-example/src/main/java/com/jaxio/jpa/querybyexample/GenericRepository.java#L392-L395
|
buyi/RecyclerViewPagerIndicator
|
recycler-viewpager-indicator/src/main/java/com/viewpagerindicator/as/library/indicator/RecyclerTitlePageIndicator.java
|
RecyclerTitlePageIndicator.calcBounds
|
private Rect calcBounds(int index, Paint paint) {
//Calculate the text bounds
Rect bounds = new Rect();
CharSequence title = getTitle(index);
bounds.right = (int) paint.measureText(title, 0, title.length());
bounds.bottom = (int) (paint.descent() - paint.ascent());
return bounds;
}
|
java
|
private Rect calcBounds(int index, Paint paint) {
//Calculate the text bounds
Rect bounds = new Rect();
CharSequence title = getTitle(index);
bounds.right = (int) paint.measureText(title, 0, title.length());
bounds.bottom = (int) (paint.descent() - paint.ascent());
return bounds;
}
|
[
"private",
"Rect",
"calcBounds",
"(",
"int",
"index",
",",
"Paint",
"paint",
")",
"{",
"//Calculate the text bounds",
"Rect",
"bounds",
"=",
"new",
"Rect",
"(",
")",
";",
"CharSequence",
"title",
"=",
"getTitle",
"(",
"index",
")",
";",
"bounds",
".",
"right",
"=",
"(",
"int",
")",
"paint",
".",
"measureText",
"(",
"title",
",",
"0",
",",
"title",
".",
"length",
"(",
")",
")",
";",
"bounds",
".",
"bottom",
"=",
"(",
"int",
")",
"(",
"paint",
".",
"descent",
"(",
")",
"-",
"paint",
".",
"ascent",
"(",
")",
")",
";",
"return",
"bounds",
";",
"}"
] |
Calculate the bounds for a view's title
@param index
@param paint
@return
|
[
"Calculate",
"the",
"bounds",
"for",
"a",
"view",
"s",
"title"
] |
train
|
https://github.com/buyi/RecyclerViewPagerIndicator/blob/b3b5283801b60d40f7325c7f590c945262194fad/recycler-viewpager-indicator/src/main/java/com/viewpagerindicator/as/library/indicator/RecyclerTitlePageIndicator.java#L698-L705
|
yasserg/crawler4j
|
crawler4j/src/main/java/edu/uci/ics/crawler4j/crawler/CrawlController.java
|
CrawlController.startNonBlocking
|
public <T extends WebCrawler> void startNonBlocking(Class<T> clazz, int numberOfCrawlers) {
start(new DefaultWebCrawlerFactory<>(clazz), numberOfCrawlers, false);
}
|
java
|
public <T extends WebCrawler> void startNonBlocking(Class<T> clazz, int numberOfCrawlers) {
start(new DefaultWebCrawlerFactory<>(clazz), numberOfCrawlers, false);
}
|
[
"public",
"<",
"T",
"extends",
"WebCrawler",
">",
"void",
"startNonBlocking",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"int",
"numberOfCrawlers",
")",
"{",
"start",
"(",
"new",
"DefaultWebCrawlerFactory",
"<>",
"(",
"clazz",
")",
",",
"numberOfCrawlers",
",",
"false",
")",
";",
"}"
] |
Start the crawling session and return immediately.
This method utilizes default crawler factory that creates new crawler using Java reflection
@param clazz
the class that implements the logic for crawler threads
@param numberOfCrawlers
the number of concurrent threads that will be contributing in
this crawling session.
@param <T> Your class extending WebCrawler
|
[
"Start",
"the",
"crawling",
"session",
"and",
"return",
"immediately",
".",
"This",
"method",
"utilizes",
"default",
"crawler",
"factory",
"that",
"creates",
"new",
"crawler",
"using",
"Java",
"reflection"
] |
train
|
https://github.com/yasserg/crawler4j/blob/4fcddc86414d1831973aff94050af55c7aeff3bc/crawler4j/src/main/java/edu/uci/ics/crawler4j/crawler/CrawlController.java#L265-L267
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java
|
ApiOvhCloud.project_serviceName_instance_POST
|
public OvhInstanceDetail project_serviceName_instance_POST(String serviceName, String flavorId, String groupId, String imageId, Boolean monthlyBilling, String name, OvhNetworkParams[] networks, String region, String sshKeyId, String userData, String volumeId) throws IOException {
String qPath = "/cloud/project/{serviceName}/instance";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "flavorId", flavorId);
addBody(o, "groupId", groupId);
addBody(o, "imageId", imageId);
addBody(o, "monthlyBilling", monthlyBilling);
addBody(o, "name", name);
addBody(o, "networks", networks);
addBody(o, "region", region);
addBody(o, "sshKeyId", sshKeyId);
addBody(o, "userData", userData);
addBody(o, "volumeId", volumeId);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhInstanceDetail.class);
}
|
java
|
public OvhInstanceDetail project_serviceName_instance_POST(String serviceName, String flavorId, String groupId, String imageId, Boolean monthlyBilling, String name, OvhNetworkParams[] networks, String region, String sshKeyId, String userData, String volumeId) throws IOException {
String qPath = "/cloud/project/{serviceName}/instance";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "flavorId", flavorId);
addBody(o, "groupId", groupId);
addBody(o, "imageId", imageId);
addBody(o, "monthlyBilling", monthlyBilling);
addBody(o, "name", name);
addBody(o, "networks", networks);
addBody(o, "region", region);
addBody(o, "sshKeyId", sshKeyId);
addBody(o, "userData", userData);
addBody(o, "volumeId", volumeId);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhInstanceDetail.class);
}
|
[
"public",
"OvhInstanceDetail",
"project_serviceName_instance_POST",
"(",
"String",
"serviceName",
",",
"String",
"flavorId",
",",
"String",
"groupId",
",",
"String",
"imageId",
",",
"Boolean",
"monthlyBilling",
",",
"String",
"name",
",",
"OvhNetworkParams",
"[",
"]",
"networks",
",",
"String",
"region",
",",
"String",
"sshKeyId",
",",
"String",
"userData",
",",
"String",
"volumeId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/project/{serviceName}/instance\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"flavorId\"",
",",
"flavorId",
")",
";",
"addBody",
"(",
"o",
",",
"\"groupId\"",
",",
"groupId",
")",
";",
"addBody",
"(",
"o",
",",
"\"imageId\"",
",",
"imageId",
")",
";",
"addBody",
"(",
"o",
",",
"\"monthlyBilling\"",
",",
"monthlyBilling",
")",
";",
"addBody",
"(",
"o",
",",
"\"name\"",
",",
"name",
")",
";",
"addBody",
"(",
"o",
",",
"\"networks\"",
",",
"networks",
")",
";",
"addBody",
"(",
"o",
",",
"\"region\"",
",",
"region",
")",
";",
"addBody",
"(",
"o",
",",
"\"sshKeyId\"",
",",
"sshKeyId",
")",
";",
"addBody",
"(",
"o",
",",
"\"userData\"",
",",
"userData",
")",
";",
"addBody",
"(",
"o",
",",
"\"volumeId\"",
",",
"volumeId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhInstanceDetail",
".",
"class",
")",
";",
"}"
] |
Create a new instance
REST: POST /cloud/project/{serviceName}/instance
@param flavorId [required] Instance flavor id
@param groupId [required] Start instance in group
@param imageId [required] Instance image id
@param monthlyBilling [required] Active monthly billing
@param name [required] Instance name
@param networks [required] Create network interfaces
@param region [required] Instance region
@param serviceName [required] Project name
@param sshKeyId [required] SSH keypair id
@param userData [required] Configuration information or scripts to use upon launch
@param volumeId [required] Specify a volume id to boot from it
|
[
"Create",
"a",
"new",
"instance"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L1791-L1807
|
mgm-tp/jfunk
|
jfunk-web/src/main/java/com/mgmtp/jfunk/web/util/DumpFileCreator.java
|
DumpFileCreator.createDumpFile
|
public File createDumpFile(final File dir, final String extension, final String urlString, final String additionalInfo) {
URI uri = URI.create(urlString);
String path = uri.getPath();
if (path == null) {
log.warn("Cannot create dump file for URI: " + uri);
return null;
}
String name = PATTERN_FIRST_LAST_SLASH.matcher(path).replaceAll("$1");
name = PATTERN_ILLEGAL_CHARS.matcher(name).replaceAll("_");
Key key = Key.get(dir.getPath(), extension);
MutableInt counter = countersMap.get(key);
if (counter == null) {
counter = new MutableInt();
countersMap.put(key, counter);
}
int counterValue = counter.intValue();
counter.increment();
StringBuilder sb = new StringBuilder();
sb.append(String.format("%04d", counterValue));
sb.append('_');
sb.append(name);
if (StringUtils.isNotBlank(additionalInfo)) {
sb.append("_");
sb.append(additionalInfo);
}
sb.append(".");
sb.append(extension);
return new File(dir, sb.toString());
}
|
java
|
public File createDumpFile(final File dir, final String extension, final String urlString, final String additionalInfo) {
URI uri = URI.create(urlString);
String path = uri.getPath();
if (path == null) {
log.warn("Cannot create dump file for URI: " + uri);
return null;
}
String name = PATTERN_FIRST_LAST_SLASH.matcher(path).replaceAll("$1");
name = PATTERN_ILLEGAL_CHARS.matcher(name).replaceAll("_");
Key key = Key.get(dir.getPath(), extension);
MutableInt counter = countersMap.get(key);
if (counter == null) {
counter = new MutableInt();
countersMap.put(key, counter);
}
int counterValue = counter.intValue();
counter.increment();
StringBuilder sb = new StringBuilder();
sb.append(String.format("%04d", counterValue));
sb.append('_');
sb.append(name);
if (StringUtils.isNotBlank(additionalInfo)) {
sb.append("_");
sb.append(additionalInfo);
}
sb.append(".");
sb.append(extension);
return new File(dir, sb.toString());
}
|
[
"public",
"File",
"createDumpFile",
"(",
"final",
"File",
"dir",
",",
"final",
"String",
"extension",
",",
"final",
"String",
"urlString",
",",
"final",
"String",
"additionalInfo",
")",
"{",
"URI",
"uri",
"=",
"URI",
".",
"create",
"(",
"urlString",
")",
";",
"String",
"path",
"=",
"uri",
".",
"getPath",
"(",
")",
";",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"log",
".",
"warn",
"(",
"\"Cannot create dump file for URI: \"",
"+",
"uri",
")",
";",
"return",
"null",
";",
"}",
"String",
"name",
"=",
"PATTERN_FIRST_LAST_SLASH",
".",
"matcher",
"(",
"path",
")",
".",
"replaceAll",
"(",
"\"$1\"",
")",
";",
"name",
"=",
"PATTERN_ILLEGAL_CHARS",
".",
"matcher",
"(",
"name",
")",
".",
"replaceAll",
"(",
"\"_\"",
")",
";",
"Key",
"key",
"=",
"Key",
".",
"get",
"(",
"dir",
".",
"getPath",
"(",
")",
",",
"extension",
")",
";",
"MutableInt",
"counter",
"=",
"countersMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"counter",
"==",
"null",
")",
"{",
"counter",
"=",
"new",
"MutableInt",
"(",
")",
";",
"countersMap",
".",
"put",
"(",
"key",
",",
"counter",
")",
";",
"}",
"int",
"counterValue",
"=",
"counter",
".",
"intValue",
"(",
")",
";",
"counter",
".",
"increment",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"%04d\"",
",",
"counterValue",
")",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"name",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"additionalInfo",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"_\"",
")",
";",
"sb",
".",
"append",
"(",
"additionalInfo",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\".\"",
")",
";",
"sb",
".",
"append",
"(",
"extension",
")",
";",
"return",
"new",
"File",
"(",
"dir",
",",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Computes the best file to save the response to the current page.
|
[
"Computes",
"the",
"best",
"file",
"to",
"save",
"the",
"response",
"to",
"the",
"current",
"page",
"."
] |
train
|
https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-web/src/main/java/com/mgmtp/jfunk/web/util/DumpFileCreator.java#L52-L85
|
looly/hutool
|
hutool-extra/src/main/java/cn/hutool/extra/template/engine/velocity/VelocityUtil.java
|
VelocityUtil.toWriter
|
public static void toWriter(String templateFileName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) {
final VelocityContext context = new VelocityContext();
parseRequest(context, request);
parseSession(context, request.getSession(false));
Writer writer = null;
try {
writer = response.getWriter();
toWriter(templateFileName, context, writer);
} catch (Exception e) {
throw new UtilException(e, "Write Velocity content template by [{}] to response error!", templateFileName);
} finally {
IoUtil.close(writer);
}
}
|
java
|
public static void toWriter(String templateFileName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) {
final VelocityContext context = new VelocityContext();
parseRequest(context, request);
parseSession(context, request.getSession(false));
Writer writer = null;
try {
writer = response.getWriter();
toWriter(templateFileName, context, writer);
} catch (Exception e) {
throw new UtilException(e, "Write Velocity content template by [{}] to response error!", templateFileName);
} finally {
IoUtil.close(writer);
}
}
|
[
"public",
"static",
"void",
"toWriter",
"(",
"String",
"templateFileName",
",",
"javax",
".",
"servlet",
".",
"http",
".",
"HttpServletRequest",
"request",
",",
"javax",
".",
"servlet",
".",
"http",
".",
"HttpServletResponse",
"response",
")",
"{",
"final",
"VelocityContext",
"context",
"=",
"new",
"VelocityContext",
"(",
")",
";",
"parseRequest",
"(",
"context",
",",
"request",
")",
";",
"parseSession",
"(",
"context",
",",
"request",
".",
"getSession",
"(",
"false",
")",
")",
";",
"Writer",
"writer",
"=",
"null",
";",
"try",
"{",
"writer",
"=",
"response",
".",
"getWriter",
"(",
")",
";",
"toWriter",
"(",
"templateFileName",
",",
"context",
",",
"writer",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"UtilException",
"(",
"e",
",",
"\"Write Velocity content template by [{}] to response error!\"",
",",
"templateFileName",
")",
";",
"}",
"finally",
"{",
"IoUtil",
".",
"close",
"(",
"writer",
")",
";",
"}",
"}"
] |
生成内容写到响应内容中<br>
模板的变量来自于Request的Attribute对象
@param templateFileName 模板文件
@param request 请求对象,用于获取模板中的变量值
@param response 响应对象
|
[
"生成内容写到响应内容中<br",
">",
"模板的变量来自于Request的Attribute对象"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/template/engine/velocity/VelocityUtil.java#L214-L228
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java
|
ImgUtil.cut
|
public static void cut(Image srcImage, ImageOutputStream destImageStream, Rectangle rectangle) throws IORuntimeException {
writeJpg(cut(srcImage, rectangle), destImageStream);
}
|
java
|
public static void cut(Image srcImage, ImageOutputStream destImageStream, Rectangle rectangle) throws IORuntimeException {
writeJpg(cut(srcImage, rectangle), destImageStream);
}
|
[
"public",
"static",
"void",
"cut",
"(",
"Image",
"srcImage",
",",
"ImageOutputStream",
"destImageStream",
",",
"Rectangle",
"rectangle",
")",
"throws",
"IORuntimeException",
"{",
"writeJpg",
"(",
"cut",
"(",
"srcImage",
",",
"rectangle",
")",
",",
"destImageStream",
")",
";",
"}"
] |
图像切割(按指定起点坐标和宽高切割),此方法并不关闭流
@param srcImage 源图像
@param destImageStream 切片后的图像输出流
@param rectangle 矩形对象,表示矩形区域的x,y,width,height
@since 3.1.0
@throws IORuntimeException IO异常
|
[
"图像切割",
"(",
"按指定起点坐标和宽高切割",
")",
",此方法并不关闭流"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java#L319-L321
|
orbisgis/h2gis
|
h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParserWpt.java
|
AbstractGpxParserWpt.endElement
|
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
// currentElement represents the last string encountered in the document
setCurrentElement(getElementNames().pop());
if (getCurrentElement().equalsIgnoreCase(GPXTags.WPT)) {
//if </wpt> markup is found, the currentPoint is added in the table wptdbd and the default contentHandler is setted.
try {
PreparedStatement pStm = getWptPreparedStmt();
int i = 1;
Object[] values = getCurrentPoint().getValues();
for (Object object : values) {
pStm.setObject(i, object);
i++;
}
pStm.execute();
} catch (SQLException ex) {
throw new SAXException("Cannot import the waypoint.", ex);
}
getReader().setContentHandler(parent);
} else {
getCurrentPoint().setAttribute(getCurrentElement(), getContentBuffer());
}
}
|
java
|
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
// currentElement represents the last string encountered in the document
setCurrentElement(getElementNames().pop());
if (getCurrentElement().equalsIgnoreCase(GPXTags.WPT)) {
//if </wpt> markup is found, the currentPoint is added in the table wptdbd and the default contentHandler is setted.
try {
PreparedStatement pStm = getWptPreparedStmt();
int i = 1;
Object[] values = getCurrentPoint().getValues();
for (Object object : values) {
pStm.setObject(i, object);
i++;
}
pStm.execute();
} catch (SQLException ex) {
throw new SAXException("Cannot import the waypoint.", ex);
}
getReader().setContentHandler(parent);
} else {
getCurrentPoint().setAttribute(getCurrentElement(), getContentBuffer());
}
}
|
[
"@",
"Override",
"public",
"void",
"endElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"qName",
")",
"throws",
"SAXException",
"{",
"// currentElement represents the last string encountered in the document",
"setCurrentElement",
"(",
"getElementNames",
"(",
")",
".",
"pop",
"(",
")",
")",
";",
"if",
"(",
"getCurrentElement",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"GPXTags",
".",
"WPT",
")",
")",
"{",
"//if </wpt> markup is found, the currentPoint is added in the table wptdbd and the default contentHandler is setted.",
"try",
"{",
"PreparedStatement",
"pStm",
"=",
"getWptPreparedStmt",
"(",
")",
";",
"int",
"i",
"=",
"1",
";",
"Object",
"[",
"]",
"values",
"=",
"getCurrentPoint",
"(",
")",
".",
"getValues",
"(",
")",
";",
"for",
"(",
"Object",
"object",
":",
"values",
")",
"{",
"pStm",
".",
"setObject",
"(",
"i",
",",
"object",
")",
";",
"i",
"++",
";",
"}",
"pStm",
".",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"ex",
")",
"{",
"throw",
"new",
"SAXException",
"(",
"\"Cannot import the waypoint.\"",
",",
"ex",
")",
";",
"}",
"getReader",
"(",
")",
".",
"setContentHandler",
"(",
"parent",
")",
";",
"}",
"else",
"{",
"getCurrentPoint",
"(",
")",
".",
"setAttribute",
"(",
"getCurrentElement",
"(",
")",
",",
"getContentBuffer",
"(",
")",
")",
";",
"}",
"}"
] |
Fires whenever an XML end markup is encountered. It catches attributes of
the waypoint and saves them in corresponding values[].
@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)
@throws SAXException Any SAX exception, possibly wrapping another
exception
|
[
"Fires",
"whenever",
"an",
"XML",
"end",
"markup",
"is",
"encountered",
".",
"It",
"catches",
"attributes",
"of",
"the",
"waypoint",
"and",
"saves",
"them",
"in",
"corresponding",
"values",
"[]",
"."
] |
train
|
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/gpx/model/AbstractGpxParserWpt.java#L86-L110
|
rollbar/rollbar-java
|
rollbar-android/src/main/java/com/rollbar/android/Rollbar.java
|
Rollbar.log
|
public void log(String message, Map<String, Object> custom, Level level) {
log(null, custom, message, level);
}
|
java
|
public void log(String message, Map<String, Object> custom, Level level) {
log(null, custom, message, level);
}
|
[
"public",
"void",
"log",
"(",
"String",
"message",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"custom",
",",
"Level",
"level",
")",
"{",
"log",
"(",
"null",
",",
"custom",
",",
"message",
",",
"level",
")",
";",
"}"
] |
Record a message with extra information attached at the specified level.
@param message the message.
@param custom the extra information.
@param level the level.
|
[
"Record",
"a",
"message",
"with",
"extra",
"information",
"attached",
"at",
"the",
"specified",
"level",
"."
] |
train
|
https://github.com/rollbar/rollbar-java/blob/5eb4537d1363722b51cfcce55b427cbd8489f17b/rollbar-android/src/main/java/com/rollbar/android/Rollbar.java#L776-L778
|
mozilla/rhino
|
src/org/mozilla/javascript/Parser.java
|
Parser.createDestructuringAssignment
|
Node createDestructuringAssignment(int type, Node left, Node right)
{
String tempName = currentScriptOrFn.getNextTempName();
Node result = destructuringAssignmentHelper(type, left, right,
tempName);
Node comma = result.getLastChild();
comma.addChildToBack(createName(tempName));
return result;
}
|
java
|
Node createDestructuringAssignment(int type, Node left, Node right)
{
String tempName = currentScriptOrFn.getNextTempName();
Node result = destructuringAssignmentHelper(type, left, right,
tempName);
Node comma = result.getLastChild();
comma.addChildToBack(createName(tempName));
return result;
}
|
[
"Node",
"createDestructuringAssignment",
"(",
"int",
"type",
",",
"Node",
"left",
",",
"Node",
"right",
")",
"{",
"String",
"tempName",
"=",
"currentScriptOrFn",
".",
"getNextTempName",
"(",
")",
";",
"Node",
"result",
"=",
"destructuringAssignmentHelper",
"(",
"type",
",",
"left",
",",
"right",
",",
"tempName",
")",
";",
"Node",
"comma",
"=",
"result",
".",
"getLastChild",
"(",
")",
";",
"comma",
".",
"addChildToBack",
"(",
"createName",
"(",
"tempName",
")",
")",
";",
"return",
"result",
";",
"}"
] |
Given a destructuring assignment with a left hand side parsed
as an array or object literal and a right hand side expression,
rewrite as a series of assignments to the variables defined in
left from property accesses to the expression on the right.
@param type declaration type: Token.VAR or Token.LET or -1
@param left array or object literal containing NAME nodes for
variables to assign
@param right expression to assign from
@return expression that performs a series of assignments to
the variables defined in left
|
[
"Given",
"a",
"destructuring",
"assignment",
"with",
"a",
"left",
"hand",
"side",
"parsed",
"as",
"an",
"array",
"or",
"object",
"literal",
"and",
"a",
"right",
"hand",
"side",
"expression",
"rewrite",
"as",
"a",
"series",
"of",
"assignments",
"to",
"the",
"variables",
"defined",
"in",
"left",
"from",
"property",
"accesses",
"to",
"the",
"expression",
"on",
"the",
"right",
"."
] |
train
|
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Parser.java#L3996-L4004
|
Jasig/uPortal
|
uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/ResourceUtils.java
|
ResourceUtils.getResourceUri
|
public static String getResourceUri(Resource resource) {
try {
return resource.getURI().toString();
} catch (FileNotFoundException e) {
return resource.getDescription();
} catch (IOException e) {
throw new RuntimeException("Could not create URI for resource: " + resource, e);
}
}
|
java
|
public static String getResourceUri(Resource resource) {
try {
return resource.getURI().toString();
} catch (FileNotFoundException e) {
return resource.getDescription();
} catch (IOException e) {
throw new RuntimeException("Could not create URI for resource: " + resource, e);
}
}
|
[
"public",
"static",
"String",
"getResourceUri",
"(",
"Resource",
"resource",
")",
"{",
"try",
"{",
"return",
"resource",
".",
"getURI",
"(",
")",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"return",
"resource",
".",
"getDescription",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not create URI for resource: \"",
"+",
"resource",
",",
"e",
")",
";",
"}",
"}"
] |
First tries {@link Resource#getURI()} and if that fails with a FileNotFoundException then
{@link Resource#getDescription()} is returned.
|
[
"First",
"tries",
"{"
] |
train
|
https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/ResourceUtils.java#L29-L37
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/compression/CompressedDataBuffer.java
|
CompressedDataBuffer.readUnknown
|
public static DataBuffer readUnknown(DataInputStream s, AllocationMode allocMode, long length, DataType type) {
// if buffer is uncompressed, it'll be valid buffer, so we'll just return it
if (type != DataType.COMPRESSED) {
DataBuffer buffer = Nd4j.createBuffer(type, length, false);
buffer.read(s, allocMode, length, type);
return buffer;
} else {
try {
// if buffer is compressed one, we''ll restore it here
String compressionAlgorithm = s.readUTF();
long compressedLength = s.readLong();
long originalLength = s.readLong();
long numberOfElements = s.readLong();
DataType originalType = DataType.values()[s.readInt()];
byte[] temp = new byte[(int) compressedLength];
for (int i = 0; i < compressedLength; i++) {
temp[i] = s.readByte();
}
Pointer pointer = new BytePointer(temp);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(compressedLength);
descriptor.setCompressionAlgorithm(compressionAlgorithm);
descriptor.setOriginalLength(originalLength);
descriptor.setNumberOfElements(numberOfElements);
descriptor.setOriginalDataType(originalType);
return new CompressedDataBuffer(pointer, descriptor);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
|
java
|
public static DataBuffer readUnknown(DataInputStream s, AllocationMode allocMode, long length, DataType type) {
// if buffer is uncompressed, it'll be valid buffer, so we'll just return it
if (type != DataType.COMPRESSED) {
DataBuffer buffer = Nd4j.createBuffer(type, length, false);
buffer.read(s, allocMode, length, type);
return buffer;
} else {
try {
// if buffer is compressed one, we''ll restore it here
String compressionAlgorithm = s.readUTF();
long compressedLength = s.readLong();
long originalLength = s.readLong();
long numberOfElements = s.readLong();
DataType originalType = DataType.values()[s.readInt()];
byte[] temp = new byte[(int) compressedLength];
for (int i = 0; i < compressedLength; i++) {
temp[i] = s.readByte();
}
Pointer pointer = new BytePointer(temp);
CompressionDescriptor descriptor = new CompressionDescriptor();
descriptor.setCompressedLength(compressedLength);
descriptor.setCompressionAlgorithm(compressionAlgorithm);
descriptor.setOriginalLength(originalLength);
descriptor.setNumberOfElements(numberOfElements);
descriptor.setOriginalDataType(originalType);
return new CompressedDataBuffer(pointer, descriptor);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
|
[
"public",
"static",
"DataBuffer",
"readUnknown",
"(",
"DataInputStream",
"s",
",",
"AllocationMode",
"allocMode",
",",
"long",
"length",
",",
"DataType",
"type",
")",
"{",
"// if buffer is uncompressed, it'll be valid buffer, so we'll just return it",
"if",
"(",
"type",
"!=",
"DataType",
".",
"COMPRESSED",
")",
"{",
"DataBuffer",
"buffer",
"=",
"Nd4j",
".",
"createBuffer",
"(",
"type",
",",
"length",
",",
"false",
")",
";",
"buffer",
".",
"read",
"(",
"s",
",",
"allocMode",
",",
"length",
",",
"type",
")",
";",
"return",
"buffer",
";",
"}",
"else",
"{",
"try",
"{",
"// if buffer is compressed one, we''ll restore it here",
"String",
"compressionAlgorithm",
"=",
"s",
".",
"readUTF",
"(",
")",
";",
"long",
"compressedLength",
"=",
"s",
".",
"readLong",
"(",
")",
";",
"long",
"originalLength",
"=",
"s",
".",
"readLong",
"(",
")",
";",
"long",
"numberOfElements",
"=",
"s",
".",
"readLong",
"(",
")",
";",
"DataType",
"originalType",
"=",
"DataType",
".",
"values",
"(",
")",
"[",
"s",
".",
"readInt",
"(",
")",
"]",
";",
"byte",
"[",
"]",
"temp",
"=",
"new",
"byte",
"[",
"(",
"int",
")",
"compressedLength",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"compressedLength",
";",
"i",
"++",
")",
"{",
"temp",
"[",
"i",
"]",
"=",
"s",
".",
"readByte",
"(",
")",
";",
"}",
"Pointer",
"pointer",
"=",
"new",
"BytePointer",
"(",
"temp",
")",
";",
"CompressionDescriptor",
"descriptor",
"=",
"new",
"CompressionDescriptor",
"(",
")",
";",
"descriptor",
".",
"setCompressedLength",
"(",
"compressedLength",
")",
";",
"descriptor",
".",
"setCompressionAlgorithm",
"(",
"compressionAlgorithm",
")",
";",
"descriptor",
".",
"setOriginalLength",
"(",
"originalLength",
")",
";",
"descriptor",
".",
"setNumberOfElements",
"(",
"numberOfElements",
")",
";",
"descriptor",
".",
"setOriginalDataType",
"(",
"originalType",
")",
";",
"return",
"new",
"CompressedDataBuffer",
"(",
"pointer",
",",
"descriptor",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] |
Drop-in replacement wrapper for BaseDataBuffer.read() method, aware of CompressedDataBuffer
@param s
@return
|
[
"Drop",
"-",
"in",
"replacement",
"wrapper",
"for",
"BaseDataBuffer",
".",
"read",
"()",
"method",
"aware",
"of",
"CompressedDataBuffer"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/compression/CompressedDataBuffer.java#L97-L129
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java
|
Shape.shapeEquals
|
public static boolean shapeEquals(int[] shape1, int[] shape2) {
if (isColumnVectorShape(shape1) && isColumnVectorShape(shape2)) {
return Arrays.equals(shape1, shape2);
}
if (isRowVectorShape(shape1) && isRowVectorShape(shape2)) {
int[] shape1Comp = squeeze(shape1);
int[] shape2Comp = squeeze(shape2);
return Arrays.equals(shape1Comp, shape2Comp);
}
//scalars
if(shape1.length == 0 || shape2.length == 0) {
if(shape1.length == 0 && shapeIsScalar(shape2)) {
return true;
}
if(shape2.length == 0 && shapeIsScalar(shape1)) {
return true;
}
}
shape1 = squeeze(shape1);
shape2 = squeeze(shape2);
return scalarEquals(shape1, shape2) || Arrays.equals(shape1, shape2);
}
|
java
|
public static boolean shapeEquals(int[] shape1, int[] shape2) {
if (isColumnVectorShape(shape1) && isColumnVectorShape(shape2)) {
return Arrays.equals(shape1, shape2);
}
if (isRowVectorShape(shape1) && isRowVectorShape(shape2)) {
int[] shape1Comp = squeeze(shape1);
int[] shape2Comp = squeeze(shape2);
return Arrays.equals(shape1Comp, shape2Comp);
}
//scalars
if(shape1.length == 0 || shape2.length == 0) {
if(shape1.length == 0 && shapeIsScalar(shape2)) {
return true;
}
if(shape2.length == 0 && shapeIsScalar(shape1)) {
return true;
}
}
shape1 = squeeze(shape1);
shape2 = squeeze(shape2);
return scalarEquals(shape1, shape2) || Arrays.equals(shape1, shape2);
}
|
[
"public",
"static",
"boolean",
"shapeEquals",
"(",
"int",
"[",
"]",
"shape1",
",",
"int",
"[",
"]",
"shape2",
")",
"{",
"if",
"(",
"isColumnVectorShape",
"(",
"shape1",
")",
"&&",
"isColumnVectorShape",
"(",
"shape2",
")",
")",
"{",
"return",
"Arrays",
".",
"equals",
"(",
"shape1",
",",
"shape2",
")",
";",
"}",
"if",
"(",
"isRowVectorShape",
"(",
"shape1",
")",
"&&",
"isRowVectorShape",
"(",
"shape2",
")",
")",
"{",
"int",
"[",
"]",
"shape1Comp",
"=",
"squeeze",
"(",
"shape1",
")",
";",
"int",
"[",
"]",
"shape2Comp",
"=",
"squeeze",
"(",
"shape2",
")",
";",
"return",
"Arrays",
".",
"equals",
"(",
"shape1Comp",
",",
"shape2Comp",
")",
";",
"}",
"//scalars",
"if",
"(",
"shape1",
".",
"length",
"==",
"0",
"||",
"shape2",
".",
"length",
"==",
"0",
")",
"{",
"if",
"(",
"shape1",
".",
"length",
"==",
"0",
"&&",
"shapeIsScalar",
"(",
"shape2",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"shape2",
".",
"length",
"==",
"0",
"&&",
"shapeIsScalar",
"(",
"shape1",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"shape1",
"=",
"squeeze",
"(",
"shape1",
")",
";",
"shape2",
"=",
"squeeze",
"(",
"shape2",
")",
";",
"return",
"scalarEquals",
"(",
"shape1",
",",
"shape2",
")",
"||",
"Arrays",
".",
"equals",
"(",
"shape1",
",",
"shape2",
")",
";",
"}"
] |
Returns whether 2 shapes are equals by checking for dimension semantics
as well as array equality
@param shape1 the first shape for comparison
@param shape2 the second shape for comparison
@return whether the shapes are equivalent
|
[
"Returns",
"whether",
"2",
"shapes",
"are",
"equals",
"by",
"checking",
"for",
"dimension",
"semantics",
"as",
"well",
"as",
"array",
"equality"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java#L1494-L1521
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-router/src/main/java/net/minidev/ovh/api/ApiOvhRouter.java
|
ApiOvhRouter.serviceName_vpn_id_PUT
|
public void serviceName_vpn_id_PUT(String serviceName, Long id, OvhVpn body) throws IOException {
String qPath = "/router/{serviceName}/vpn/{id}";
StringBuilder sb = path(qPath, serviceName, id);
exec(qPath, "PUT", sb.toString(), body);
}
|
java
|
public void serviceName_vpn_id_PUT(String serviceName, Long id, OvhVpn body) throws IOException {
String qPath = "/router/{serviceName}/vpn/{id}";
StringBuilder sb = path(qPath, serviceName, id);
exec(qPath, "PUT", sb.toString(), body);
}
|
[
"public",
"void",
"serviceName_vpn_id_PUT",
"(",
"String",
"serviceName",
",",
"Long",
"id",
",",
"OvhVpn",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/router/{serviceName}/vpn/{id}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"id",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] |
Alter this object properties
REST: PUT /router/{serviceName}/vpn/{id}
@param body [required] New object properties
@param serviceName [required] The internal name of your Router offer
@param id [required]
|
[
"Alter",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-router/src/main/java/net/minidev/ovh/api/ApiOvhRouter.java#L90-L94
|
landawn/AbacusUtil
|
src/com/landawn/abacus/android/util/SQLiteExecutor.java
|
SQLiteExecutor.toList
|
static <T> List<T> toList(Class<T> targetClass, Cursor cursor) {
return toList(targetClass, cursor, 0, Integer.MAX_VALUE);
}
|
java
|
static <T> List<T> toList(Class<T> targetClass, Cursor cursor) {
return toList(targetClass, cursor, 0, Integer.MAX_VALUE);
}
|
[
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"toList",
"(",
"Class",
"<",
"T",
">",
"targetClass",
",",
"Cursor",
"cursor",
")",
"{",
"return",
"toList",
"(",
"targetClass",
",",
"cursor",
",",
"0",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"}"
] |
Returns values from all rows associated with the specified <code>targetClass</code> if the specified <code>targetClass</code> is an entity class, otherwise, only returns values from first column.
@param targetClass entity class or specific column type.
@param cursor
@return
|
[
"Returns",
"values",
"from",
"all",
"rows",
"associated",
"with",
"the",
"specified",
"<code",
">",
"targetClass<",
"/",
"code",
">",
"if",
"the",
"specified",
"<code",
">",
"targetClass<",
"/",
"code",
">",
"is",
"an",
"entity",
"class",
"otherwise",
"only",
"returns",
"values",
"from",
"first",
"column",
"."
] |
train
|
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/android/util/SQLiteExecutor.java#L269-L271
|
indeedeng/util
|
util-core/src/main/java/com/indeed/util/core/sort/Quicksortables.java
|
Quicksortables.heapSort
|
public static void heapSort(Quicksortable q, int size) {
q = reverseQuicksortable(q);
makeHeap(q, size);
sortheap(q, size);
}
|
java
|
public static void heapSort(Quicksortable q, int size) {
q = reverseQuicksortable(q);
makeHeap(q, size);
sortheap(q, size);
}
|
[
"public",
"static",
"void",
"heapSort",
"(",
"Quicksortable",
"q",
",",
"int",
"size",
")",
"{",
"q",
"=",
"reverseQuicksortable",
"(",
"q",
")",
";",
"makeHeap",
"(",
"q",
",",
"size",
")",
";",
"sortheap",
"(",
"q",
",",
"size",
")",
";",
"}"
] |
sorts the elements in q using the heapsort method
@param q The quicksortable to heapsort.
@param size The size of the quicksortable.
|
[
"sorts",
"the",
"elements",
"in",
"q",
"using",
"the",
"heapsort",
"method"
] |
train
|
https://github.com/indeedeng/util/blob/332008426cf14b57e7fc3e817d9423e3f84fb922/util-core/src/main/java/com/indeed/util/core/sort/Quicksortables.java#L241-L245
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.kernel.feature.cmdline/src/com/ibm/ws/kernel/feature/internal/generator/ManifestFileProcessor.java
|
ManifestFileProcessor.getUsrProductFeatureDefinitions
|
private Map<String, ProvisioningFeatureDefinition> getUsrProductFeatureDefinitions() {
Map<String, ProvisioningFeatureDefinition> features = null;
File userDir = Utils.getUserDir();
if (userDir != null && userDir.exists()) {
File userFeatureDir = new File(userDir, USER_FEATURE_DIR);
if (userFeatureDir.exists()) {
features = new TreeMap<String, ProvisioningFeatureDefinition>();
File[] userManifestFiles = userFeatureDir.listFiles(MFFilter);
if (userManifestFiles != null) {
for (File file : userManifestFiles) {
try {
ProvisioningFeatureDefinition fd = new SubsystemFeatureDefinitionImpl(USR_PRODUCT_EXT_NAME, file);
features.put(fd.getSymbolicName(), fd);
} catch (IOException e) {
// TODO: PROPER NLS MESSAGE
throw new FeatureToolException("Unable to read feature manifest from user extension: " + file,
(String) null,
e,
ReturnCode.BAD_FEATURE_DEFINITION);
}
}
}
}
}
return features;
}
|
java
|
private Map<String, ProvisioningFeatureDefinition> getUsrProductFeatureDefinitions() {
Map<String, ProvisioningFeatureDefinition> features = null;
File userDir = Utils.getUserDir();
if (userDir != null && userDir.exists()) {
File userFeatureDir = new File(userDir, USER_FEATURE_DIR);
if (userFeatureDir.exists()) {
features = new TreeMap<String, ProvisioningFeatureDefinition>();
File[] userManifestFiles = userFeatureDir.listFiles(MFFilter);
if (userManifestFiles != null) {
for (File file : userManifestFiles) {
try {
ProvisioningFeatureDefinition fd = new SubsystemFeatureDefinitionImpl(USR_PRODUCT_EXT_NAME, file);
features.put(fd.getSymbolicName(), fd);
} catch (IOException e) {
// TODO: PROPER NLS MESSAGE
throw new FeatureToolException("Unable to read feature manifest from user extension: " + file,
(String) null,
e,
ReturnCode.BAD_FEATURE_DEFINITION);
}
}
}
}
}
return features;
}
|
[
"private",
"Map",
"<",
"String",
",",
"ProvisioningFeatureDefinition",
">",
"getUsrProductFeatureDefinitions",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"ProvisioningFeatureDefinition",
">",
"features",
"=",
"null",
";",
"File",
"userDir",
"=",
"Utils",
".",
"getUserDir",
"(",
")",
";",
"if",
"(",
"userDir",
"!=",
"null",
"&&",
"userDir",
".",
"exists",
"(",
")",
")",
"{",
"File",
"userFeatureDir",
"=",
"new",
"File",
"(",
"userDir",
",",
"USER_FEATURE_DIR",
")",
";",
"if",
"(",
"userFeatureDir",
".",
"exists",
"(",
")",
")",
"{",
"features",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"ProvisioningFeatureDefinition",
">",
"(",
")",
";",
"File",
"[",
"]",
"userManifestFiles",
"=",
"userFeatureDir",
".",
"listFiles",
"(",
"MFFilter",
")",
";",
"if",
"(",
"userManifestFiles",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"file",
":",
"userManifestFiles",
")",
"{",
"try",
"{",
"ProvisioningFeatureDefinition",
"fd",
"=",
"new",
"SubsystemFeatureDefinitionImpl",
"(",
"USR_PRODUCT_EXT_NAME",
",",
"file",
")",
";",
"features",
".",
"put",
"(",
"fd",
".",
"getSymbolicName",
"(",
")",
",",
"fd",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// TODO: PROPER NLS MESSAGE",
"throw",
"new",
"FeatureToolException",
"(",
"\"Unable to read feature manifest from user extension: \"",
"+",
"file",
",",
"(",
"String",
")",
"null",
",",
"e",
",",
"ReturnCode",
".",
"BAD_FEATURE_DEFINITION",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"features",
";",
"}"
] |
Retrieves a Map of feature definitions in default usr product extension location
@return Null if the user directory cannot be found. An empty map if the features manifests cannot
be found. A Map of product extension features if all goes well.
|
[
"Retrieves",
"a",
"Map",
"of",
"feature",
"definitions",
"in",
"default",
"usr",
"product",
"extension",
"location"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.feature.cmdline/src/com/ibm/ws/kernel/feature/internal/generator/ManifestFileProcessor.java#L287-L313
|
alkacon/opencms-core
|
src/org/opencms/db/CmsDriverManager.java
|
CmsDriverManager.updateLastLoginDate
|
public void updateLastLoginDate(CmsDbContext dbc, CmsUser user) throws CmsException {
m_monitor.clearUserCache(user);
// set the last login time to the current time
user.setLastlogin(System.currentTimeMillis());
dbc.setAttribute(ATTRIBUTE_LOGIN, user.getName());
getUserDriver(dbc).writeUser(dbc, user);
// update cache
m_monitor.cacheUser(user);
// invalidate all user dependent caches
m_monitor.flushCache(
CmsMemoryMonitor.CacheType.ACL,
CmsMemoryMonitor.CacheType.GROUP,
CmsMemoryMonitor.CacheType.ORG_UNIT,
CmsMemoryMonitor.CacheType.USERGROUPS,
CmsMemoryMonitor.CacheType.USER_LIST,
CmsMemoryMonitor.CacheType.PERMISSION,
CmsMemoryMonitor.CacheType.RESOURCE_LIST);
// fire user modified event
Map<String, Object> eventData = new HashMap<String, Object>();
eventData.put(I_CmsEventListener.KEY_USER_ID, user.getId().toString());
eventData.put(I_CmsEventListener.KEY_USER_NAME, user.getName());
eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_USER_MODIFIED_ACTION_WRITE_USER);
eventData.put(I_CmsEventListener.KEY_USER_CHANGES, Integer.valueOf(CmsUser.FLAG_LAST_LOGIN));
OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_USER_MODIFIED, eventData));
}
|
java
|
public void updateLastLoginDate(CmsDbContext dbc, CmsUser user) throws CmsException {
m_monitor.clearUserCache(user);
// set the last login time to the current time
user.setLastlogin(System.currentTimeMillis());
dbc.setAttribute(ATTRIBUTE_LOGIN, user.getName());
getUserDriver(dbc).writeUser(dbc, user);
// update cache
m_monitor.cacheUser(user);
// invalidate all user dependent caches
m_monitor.flushCache(
CmsMemoryMonitor.CacheType.ACL,
CmsMemoryMonitor.CacheType.GROUP,
CmsMemoryMonitor.CacheType.ORG_UNIT,
CmsMemoryMonitor.CacheType.USERGROUPS,
CmsMemoryMonitor.CacheType.USER_LIST,
CmsMemoryMonitor.CacheType.PERMISSION,
CmsMemoryMonitor.CacheType.RESOURCE_LIST);
// fire user modified event
Map<String, Object> eventData = new HashMap<String, Object>();
eventData.put(I_CmsEventListener.KEY_USER_ID, user.getId().toString());
eventData.put(I_CmsEventListener.KEY_USER_NAME, user.getName());
eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_USER_MODIFIED_ACTION_WRITE_USER);
eventData.put(I_CmsEventListener.KEY_USER_CHANGES, Integer.valueOf(CmsUser.FLAG_LAST_LOGIN));
OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_USER_MODIFIED, eventData));
}
|
[
"public",
"void",
"updateLastLoginDate",
"(",
"CmsDbContext",
"dbc",
",",
"CmsUser",
"user",
")",
"throws",
"CmsException",
"{",
"m_monitor",
".",
"clearUserCache",
"(",
"user",
")",
";",
"// set the last login time to the current time",
"user",
".",
"setLastlogin",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"dbc",
".",
"setAttribute",
"(",
"ATTRIBUTE_LOGIN",
",",
"user",
".",
"getName",
"(",
")",
")",
";",
"getUserDriver",
"(",
"dbc",
")",
".",
"writeUser",
"(",
"dbc",
",",
"user",
")",
";",
"// update cache",
"m_monitor",
".",
"cacheUser",
"(",
"user",
")",
";",
"// invalidate all user dependent caches",
"m_monitor",
".",
"flushCache",
"(",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"ACL",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"GROUP",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"ORG_UNIT",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"USERGROUPS",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"USER_LIST",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"PERMISSION",
",",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"RESOURCE_LIST",
")",
";",
"// fire user modified event",
"Map",
"<",
"String",
",",
"Object",
">",
"eventData",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"eventData",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_USER_ID",
",",
"user",
".",
"getId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"eventData",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_USER_NAME",
",",
"user",
".",
"getName",
"(",
")",
")",
";",
"eventData",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_USER_ACTION",
",",
"I_CmsEventListener",
".",
"VALUE_USER_MODIFIED_ACTION_WRITE_USER",
")",
";",
"eventData",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_USER_CHANGES",
",",
"Integer",
".",
"valueOf",
"(",
"CmsUser",
".",
"FLAG_LAST_LOGIN",
")",
")",
";",
"OpenCms",
".",
"fireCmsEvent",
"(",
"new",
"CmsEvent",
"(",
"I_CmsEventListener",
".",
"EVENT_USER_MODIFIED",
",",
"eventData",
")",
")",
";",
"}"
] |
Updates the last login date on the given user to the current time.<p>
@param dbc the current database context
@param user the user to be updated
@throws CmsException if operation was not successful
|
[
"Updates",
"the",
"last",
"login",
"date",
"on",
"the",
"given",
"user",
"to",
"the",
"current",
"time",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L9399-L9426
|
alkacon/opencms-core
|
src/org/opencms/jsp/CmsJspNavBuilder.java
|
CmsJspNavBuilder.getDefaultFile
|
@Deprecated
public static String getDefaultFile(CmsObject cms, String folder) {
if (folder.endsWith("/")) {
try {
CmsResource defaultFile = cms.readDefaultFile(folder);
if (defaultFile != null) {
return cms.getSitePath(defaultFile);
}
} catch (CmsException e) {
LOG.debug(e.getLocalizedMessage(), e);
}
return folder;
}
return null;
}
|
java
|
@Deprecated
public static String getDefaultFile(CmsObject cms, String folder) {
if (folder.endsWith("/")) {
try {
CmsResource defaultFile = cms.readDefaultFile(folder);
if (defaultFile != null) {
return cms.getSitePath(defaultFile);
}
} catch (CmsException e) {
LOG.debug(e.getLocalizedMessage(), e);
}
return folder;
}
return null;
}
|
[
"@",
"Deprecated",
"public",
"static",
"String",
"getDefaultFile",
"(",
"CmsObject",
"cms",
",",
"String",
"folder",
")",
"{",
"if",
"(",
"folder",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"try",
"{",
"CmsResource",
"defaultFile",
"=",
"cms",
".",
"readDefaultFile",
"(",
"folder",
")",
";",
"if",
"(",
"defaultFile",
"!=",
"null",
")",
"{",
"return",
"cms",
".",
"getSitePath",
"(",
"defaultFile",
")",
";",
"}",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"LOG",
".",
"debug",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"folder",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the full name (including VFS path) of the default file for this navigation element
or <code>null</code> if the navigation element is not a folder.<p>
The default file of a folder is determined by the value of the property
<code>default-file</code> or the system wide property setting.<p>
@param cms the CMS object
@param folder full name of the folder
@return the name of the default file
@deprecated use {@link CmsObject#readDefaultFile(String)} instead
|
[
"Returns",
"the",
"full",
"name",
"(",
"including",
"VFS",
"path",
")",
"of",
"the",
"default",
"file",
"for",
"this",
"navigation",
"element",
"or",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"the",
"navigation",
"element",
"is",
"not",
"a",
"folder",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/CmsJspNavBuilder.java#L202-L217
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.