repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
Ordinastie/MalisisCore | src/main/java/net/malisis/core/asm/AsmUtils.java | AsmUtils.changeFieldAccess | public static Field changeFieldAccess(Class<?> clazz, String fieldName, String srgName, boolean silenced) {
"""
Changes the access level for the specified field for a class.
@param clazz the clazz
@param fieldName the field name
@param srgName the srg name
@param silenced the silenced
@return the field
"""
try
{
Field f = clazz.getDeclaredField(MalisisCore.isObfEnv ? srgName : fieldName);
f.setAccessible(true);
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
modifiers.setInt(f, f.getModifiers() & ~Modifier.FINAL);
return f;
}
catch (ReflectiveOperationException e)
{
if (!silenced)
MalisisCore.log.error("Could not change access for field " + clazz.getSimpleName() + "."
+ (MalisisCore.isObfEnv ? srgName : fieldName), e);
return null;
}
} | java | public static Field changeFieldAccess(Class<?> clazz, String fieldName, String srgName, boolean silenced)
{
try
{
Field f = clazz.getDeclaredField(MalisisCore.isObfEnv ? srgName : fieldName);
f.setAccessible(true);
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
modifiers.setInt(f, f.getModifiers() & ~Modifier.FINAL);
return f;
}
catch (ReflectiveOperationException e)
{
if (!silenced)
MalisisCore.log.error("Could not change access for field " + clazz.getSimpleName() + "."
+ (MalisisCore.isObfEnv ? srgName : fieldName), e);
return null;
}
} | [
"public",
"static",
"Field",
"changeFieldAccess",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"fieldName",
",",
"String",
"srgName",
",",
"boolean",
"silenced",
")",
"{",
"try",
"{",
"Field",
"f",
"=",
"clazz",
".",
"getDeclaredField",
"(",
"MalisisCore",
".",
"isObfEnv",
"?",
"srgName",
":",
"fieldName",
")",
";",
"f",
".",
"setAccessible",
"(",
"true",
")",
";",
"Field",
"modifiers",
"=",
"Field",
".",
"class",
".",
"getDeclaredField",
"(",
"\"modifiers\"",
")",
";",
"modifiers",
".",
"setAccessible",
"(",
"true",
")",
";",
"modifiers",
".",
"setInt",
"(",
"f",
",",
"f",
".",
"getModifiers",
"(",
")",
"&",
"~",
"Modifier",
".",
"FINAL",
")",
";",
"return",
"f",
";",
"}",
"catch",
"(",
"ReflectiveOperationException",
"e",
")",
"{",
"if",
"(",
"!",
"silenced",
")",
"MalisisCore",
".",
"log",
".",
"error",
"(",
"\"Could not change access for field \"",
"+",
"clazz",
".",
"getSimpleName",
"(",
")",
"+",
"\".\"",
"+",
"(",
"MalisisCore",
".",
"isObfEnv",
"?",
"srgName",
":",
"fieldName",
")",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Changes the access level for the specified field for a class.
@param clazz the clazz
@param fieldName the field name
@param srgName the srg name
@param silenced the silenced
@return the field | [
"Changes",
"the",
"access",
"level",
"for",
"the",
"specified",
"field",
"for",
"a",
"class",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/asm/AsmUtils.java#L339-L359 |
ngageoint/geopackage-java | src/main/java/mil/nga/geopackage/user/custom/UserCustomTableReader.java | UserCustomTableReader.readTable | public static UserCustomTable readTable(GeoPackageConnection connection,
String tableName) {
"""
Read the table
@param connection
GeoPackage connection
@param tableName
table name
@return table
"""
UserCustomConnection userDb = new UserCustomConnection(connection);
return readTable(userDb, tableName);
} | java | public static UserCustomTable readTable(GeoPackageConnection connection,
String tableName) {
UserCustomConnection userDb = new UserCustomConnection(connection);
return readTable(userDb, tableName);
} | [
"public",
"static",
"UserCustomTable",
"readTable",
"(",
"GeoPackageConnection",
"connection",
",",
"String",
"tableName",
")",
"{",
"UserCustomConnection",
"userDb",
"=",
"new",
"UserCustomConnection",
"(",
"connection",
")",
";",
"return",
"readTable",
"(",
"userDb",
",",
"tableName",
")",
";",
"}"
] | Read the table
@param connection
GeoPackage connection
@param tableName
table name
@return table | [
"Read",
"the",
"table"
] | train | https://github.com/ngageoint/geopackage-java/blob/889bffb5d18330a3f4bd89443acf7959ebe3a376/src/main/java/mil/nga/geopackage/user/custom/UserCustomTableReader.java#L65-L69 |
micronaut-projects/micronaut-core | runtime/src/main/java/io/micronaut/jackson/JacksonConfiguration.java | JacksonConfiguration.constructType | public static <T> JavaType constructType(@Nonnull Argument<T> type, @Nonnull TypeFactory typeFactory) {
"""
Constructors a JavaType for the given argument and type factory.
@param type The type
@param typeFactory The type factory
@param <T> The generic type
@return The JavaType
"""
ArgumentUtils.requireNonNull("type", type);
ArgumentUtils.requireNonNull("typeFactory", typeFactory);
Map<String, Argument<?>> typeVariables = type.getTypeVariables();
JavaType[] objects = toJavaTypeArray(typeFactory, typeVariables);
final Class<T> rawType = type.getType();
if (ArrayUtils.isNotEmpty(objects)) {
final JavaType javaType = typeFactory.constructType(
rawType
);
if (javaType.isCollectionLikeType()) {
return typeFactory.constructCollectionLikeType(
rawType,
objects[0]
);
} else if (javaType.isMapLikeType()) {
return typeFactory.constructMapLikeType(
rawType,
objects[0],
objects[1]
);
} else if (javaType.isReferenceType()) {
return typeFactory.constructReferenceType(rawType, objects[0]);
}
return typeFactory.constructParametricType(rawType, objects);
} else {
return typeFactory.constructType(
rawType
);
}
} | java | public static <T> JavaType constructType(@Nonnull Argument<T> type, @Nonnull TypeFactory typeFactory) {
ArgumentUtils.requireNonNull("type", type);
ArgumentUtils.requireNonNull("typeFactory", typeFactory);
Map<String, Argument<?>> typeVariables = type.getTypeVariables();
JavaType[] objects = toJavaTypeArray(typeFactory, typeVariables);
final Class<T> rawType = type.getType();
if (ArrayUtils.isNotEmpty(objects)) {
final JavaType javaType = typeFactory.constructType(
rawType
);
if (javaType.isCollectionLikeType()) {
return typeFactory.constructCollectionLikeType(
rawType,
objects[0]
);
} else if (javaType.isMapLikeType()) {
return typeFactory.constructMapLikeType(
rawType,
objects[0],
objects[1]
);
} else if (javaType.isReferenceType()) {
return typeFactory.constructReferenceType(rawType, objects[0]);
}
return typeFactory.constructParametricType(rawType, objects);
} else {
return typeFactory.constructType(
rawType
);
}
} | [
"public",
"static",
"<",
"T",
">",
"JavaType",
"constructType",
"(",
"@",
"Nonnull",
"Argument",
"<",
"T",
">",
"type",
",",
"@",
"Nonnull",
"TypeFactory",
"typeFactory",
")",
"{",
"ArgumentUtils",
".",
"requireNonNull",
"(",
"\"type\"",
",",
"type",
")",
";",
"ArgumentUtils",
".",
"requireNonNull",
"(",
"\"typeFactory\"",
",",
"typeFactory",
")",
";",
"Map",
"<",
"String",
",",
"Argument",
"<",
"?",
">",
">",
"typeVariables",
"=",
"type",
".",
"getTypeVariables",
"(",
")",
";",
"JavaType",
"[",
"]",
"objects",
"=",
"toJavaTypeArray",
"(",
"typeFactory",
",",
"typeVariables",
")",
";",
"final",
"Class",
"<",
"T",
">",
"rawType",
"=",
"type",
".",
"getType",
"(",
")",
";",
"if",
"(",
"ArrayUtils",
".",
"isNotEmpty",
"(",
"objects",
")",
")",
"{",
"final",
"JavaType",
"javaType",
"=",
"typeFactory",
".",
"constructType",
"(",
"rawType",
")",
";",
"if",
"(",
"javaType",
".",
"isCollectionLikeType",
"(",
")",
")",
"{",
"return",
"typeFactory",
".",
"constructCollectionLikeType",
"(",
"rawType",
",",
"objects",
"[",
"0",
"]",
")",
";",
"}",
"else",
"if",
"(",
"javaType",
".",
"isMapLikeType",
"(",
")",
")",
"{",
"return",
"typeFactory",
".",
"constructMapLikeType",
"(",
"rawType",
",",
"objects",
"[",
"0",
"]",
",",
"objects",
"[",
"1",
"]",
")",
";",
"}",
"else",
"if",
"(",
"javaType",
".",
"isReferenceType",
"(",
")",
")",
"{",
"return",
"typeFactory",
".",
"constructReferenceType",
"(",
"rawType",
",",
"objects",
"[",
"0",
"]",
")",
";",
"}",
"return",
"typeFactory",
".",
"constructParametricType",
"(",
"rawType",
",",
"objects",
")",
";",
"}",
"else",
"{",
"return",
"typeFactory",
".",
"constructType",
"(",
"rawType",
")",
";",
"}",
"}"
] | Constructors a JavaType for the given argument and type factory.
@param type The type
@param typeFactory The type factory
@param <T> The generic type
@return The JavaType | [
"Constructors",
"a",
"JavaType",
"for",
"the",
"given",
"argument",
"and",
"type",
"factory",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/runtime/src/main/java/io/micronaut/jackson/JacksonConfiguration.java#L317-L347 |
j-a-w-r/jawr-main-repo | jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java | BundleProcessor.initClassLoader | protected ClassLoader initClassLoader(String baseDirPath)
throws MalformedURLException {
"""
Initialize the classloader
@param baseDirPath
the base directory path
@return the class loader
@throws MalformedURLException
"""
File webAppClasses = new File(baseDirPath + WEB_INF_CLASSES_DIR_PATH);
File[] webAppLibs = new File(baseDirPath + WEB_INF_LIB_DIR_PATH)
.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(JAR_FILE_EXTENSION);
}
});
int length = webAppLibs != null ? webAppLibs.length + 1 : 1;
URL[] urls = new URL[length];
urls[0] = webAppClasses.toURI().toURL();
for (int i = 1; i < length; i++) {
urls[i] = webAppLibs[i - 1].toURI().toURL();
}
ClassLoader webAppClassLoader = new JawrBundleProcessorCustomClassLoader(
urls, getClass().getClassLoader());
Thread.currentThread().setContextClassLoader(webAppClassLoader);
return webAppClassLoader;
} | java | protected ClassLoader initClassLoader(String baseDirPath)
throws MalformedURLException {
File webAppClasses = new File(baseDirPath + WEB_INF_CLASSES_DIR_PATH);
File[] webAppLibs = new File(baseDirPath + WEB_INF_LIB_DIR_PATH)
.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(JAR_FILE_EXTENSION);
}
});
int length = webAppLibs != null ? webAppLibs.length + 1 : 1;
URL[] urls = new URL[length];
urls[0] = webAppClasses.toURI().toURL();
for (int i = 1; i < length; i++) {
urls[i] = webAppLibs[i - 1].toURI().toURL();
}
ClassLoader webAppClassLoader = new JawrBundleProcessorCustomClassLoader(
urls, getClass().getClassLoader());
Thread.currentThread().setContextClassLoader(webAppClassLoader);
return webAppClassLoader;
} | [
"protected",
"ClassLoader",
"initClassLoader",
"(",
"String",
"baseDirPath",
")",
"throws",
"MalformedURLException",
"{",
"File",
"webAppClasses",
"=",
"new",
"File",
"(",
"baseDirPath",
"+",
"WEB_INF_CLASSES_DIR_PATH",
")",
";",
"File",
"[",
"]",
"webAppLibs",
"=",
"new",
"File",
"(",
"baseDirPath",
"+",
"WEB_INF_LIB_DIR_PATH",
")",
".",
"listFiles",
"(",
"new",
"FilenameFilter",
"(",
")",
"{",
"public",
"boolean",
"accept",
"(",
"File",
"dir",
",",
"String",
"name",
")",
"{",
"return",
"name",
".",
"endsWith",
"(",
"JAR_FILE_EXTENSION",
")",
";",
"}",
"}",
")",
";",
"int",
"length",
"=",
"webAppLibs",
"!=",
"null",
"?",
"webAppLibs",
".",
"length",
"+",
"1",
":",
"1",
";",
"URL",
"[",
"]",
"urls",
"=",
"new",
"URL",
"[",
"length",
"]",
";",
"urls",
"[",
"0",
"]",
"=",
"webAppClasses",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"urls",
"[",
"i",
"]",
"=",
"webAppLibs",
"[",
"i",
"-",
"1",
"]",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
";",
"}",
"ClassLoader",
"webAppClassLoader",
"=",
"new",
"JawrBundleProcessorCustomClassLoader",
"(",
"urls",
",",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
")",
";",
"Thread",
".",
"currentThread",
"(",
")",
".",
"setContextClassLoader",
"(",
"webAppClassLoader",
")",
";",
"return",
"webAppClassLoader",
";",
"}"
] | Initialize the classloader
@param baseDirPath
the base directory path
@return the class loader
@throws MalformedURLException | [
"Initialize",
"the",
"classloader"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L324-L348 |
apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics/src/main/java/org/apache/gobblin/metrics/GobblinMetricsRegistry.java | GobblinMetricsRegistry.getOrDefault | public GobblinMetrics getOrDefault(String id, Callable<? extends GobblinMetrics> valueLoader) {
"""
Get the {@link GobblinMetrics} instance associated with a given ID. If the ID is not found this method returns the
{@link GobblinMetrics} returned by the given {@link Callable}, and creates a mapping between the specified ID
and the {@link GobblinMetrics} instance returned by the {@link Callable}.
@param id the given {@link GobblinMetrics} ID
@param valueLoader a {@link Callable} that returns a {@link GobblinMetrics}, the {@link Callable} is only invoked
if the given id is not found
@return a {@link GobblinMetrics} instance associated with the id
"""
try {
return this.metricsCache.get(id, valueLoader);
} catch (ExecutionException ee) {
throw Throwables.propagate(ee);
}
} | java | public GobblinMetrics getOrDefault(String id, Callable<? extends GobblinMetrics> valueLoader) {
try {
return this.metricsCache.get(id, valueLoader);
} catch (ExecutionException ee) {
throw Throwables.propagate(ee);
}
} | [
"public",
"GobblinMetrics",
"getOrDefault",
"(",
"String",
"id",
",",
"Callable",
"<",
"?",
"extends",
"GobblinMetrics",
">",
"valueLoader",
")",
"{",
"try",
"{",
"return",
"this",
".",
"metricsCache",
".",
"get",
"(",
"id",
",",
"valueLoader",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"ee",
")",
"{",
"throw",
"Throwables",
".",
"propagate",
"(",
"ee",
")",
";",
"}",
"}"
] | Get the {@link GobblinMetrics} instance associated with a given ID. If the ID is not found this method returns the
{@link GobblinMetrics} returned by the given {@link Callable}, and creates a mapping between the specified ID
and the {@link GobblinMetrics} instance returned by the {@link Callable}.
@param id the given {@link GobblinMetrics} ID
@param valueLoader a {@link Callable} that returns a {@link GobblinMetrics}, the {@link Callable} is only invoked
if the given id is not found
@return a {@link GobblinMetrics} instance associated with the id | [
"Get",
"the",
"{",
"@link",
"GobblinMetrics",
"}",
"instance",
"associated",
"with",
"a",
"given",
"ID",
".",
"If",
"the",
"ID",
"is",
"not",
"found",
"this",
"method",
"returns",
"the",
"{",
"@link",
"GobblinMetrics",
"}",
"returned",
"by",
"the",
"given",
"{",
"@link",
"Callable",
"}",
"and",
"creates",
"a",
"mapping",
"between",
"the",
"specified",
"ID",
"and",
"the",
"{",
"@link",
"GobblinMetrics",
"}",
"instance",
"returned",
"by",
"the",
"{",
"@link",
"Callable",
"}",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics/src/main/java/org/apache/gobblin/metrics/GobblinMetricsRegistry.java#L90-L96 |
buschmais/jqa-maven3-plugin | src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java | MavenModelScannerPlugin.addDevelopers | private void addDevelopers(MavenPomDescriptor pomDescriptor, Model model, Store store) {
"""
Adds information about developers.
@param pomDescriptor
The descriptor for the current POM.
@param model
The Maven Model.
@param store
The database.
"""
List<Developer> developers = model.getDevelopers();
for (Developer developer : developers) {
MavenDeveloperDescriptor developerDescriptor = store.create(MavenDeveloperDescriptor.class);
developerDescriptor.setId(developer.getId());
addCommonParticipantAttributes(developerDescriptor, developer, store);
pomDescriptor.getDevelopers().add(developerDescriptor);
}
} | java | private void addDevelopers(MavenPomDescriptor pomDescriptor, Model model, Store store) {
List<Developer> developers = model.getDevelopers();
for (Developer developer : developers) {
MavenDeveloperDescriptor developerDescriptor = store.create(MavenDeveloperDescriptor.class);
developerDescriptor.setId(developer.getId());
addCommonParticipantAttributes(developerDescriptor, developer, store);
pomDescriptor.getDevelopers().add(developerDescriptor);
}
} | [
"private",
"void",
"addDevelopers",
"(",
"MavenPomDescriptor",
"pomDescriptor",
",",
"Model",
"model",
",",
"Store",
"store",
")",
"{",
"List",
"<",
"Developer",
">",
"developers",
"=",
"model",
".",
"getDevelopers",
"(",
")",
";",
"for",
"(",
"Developer",
"developer",
":",
"developers",
")",
"{",
"MavenDeveloperDescriptor",
"developerDescriptor",
"=",
"store",
".",
"create",
"(",
"MavenDeveloperDescriptor",
".",
"class",
")",
";",
"developerDescriptor",
".",
"setId",
"(",
"developer",
".",
"getId",
"(",
")",
")",
";",
"addCommonParticipantAttributes",
"(",
"developerDescriptor",
",",
"developer",
",",
"store",
")",
";",
"pomDescriptor",
".",
"getDevelopers",
"(",
")",
".",
"add",
"(",
"developerDescriptor",
")",
";",
"}",
"}"
] | Adds information about developers.
@param pomDescriptor
The descriptor for the current POM.
@param model
The Maven Model.
@param store
The database. | [
"Adds",
"information",
"about",
"developers",
"."
] | train | https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L361-L371 |
twitter/scalding | scalding-serialization/src/main/java/com/twitter/scalding/serialization/Undeprecated.java | Undeprecated.getAsciiBytes | @SuppressWarnings("deprecation")
public static void getAsciiBytes(String element, int charStart, int charLen, byte[] bytes, int byteOffset) {
"""
This method is faster for ASCII data, but unsafe otherwise
it is used by our macros AFTER checking that the string is ASCII
following a pattern seen in Kryo, which benchmarking showed helped.
Scala cannot supress warnings like this so we do it here
"""
element.getBytes(charStart, charLen, bytes, byteOffset);
} | java | @SuppressWarnings("deprecation")
public static void getAsciiBytes(String element, int charStart, int charLen, byte[] bytes, int byteOffset) {
element.getBytes(charStart, charLen, bytes, byteOffset);
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"void",
"getAsciiBytes",
"(",
"String",
"element",
",",
"int",
"charStart",
",",
"int",
"charLen",
",",
"byte",
"[",
"]",
"bytes",
",",
"int",
"byteOffset",
")",
"{",
"element",
".",
"getBytes",
"(",
"charStart",
",",
"charLen",
",",
"bytes",
",",
"byteOffset",
")",
";",
"}"
] | This method is faster for ASCII data, but unsafe otherwise
it is used by our macros AFTER checking that the string is ASCII
following a pattern seen in Kryo, which benchmarking showed helped.
Scala cannot supress warnings like this so we do it here | [
"This",
"method",
"is",
"faster",
"for",
"ASCII",
"data",
"but",
"unsafe",
"otherwise",
"it",
"is",
"used",
"by",
"our",
"macros",
"AFTER",
"checking",
"that",
"the",
"string",
"is",
"ASCII",
"following",
"a",
"pattern",
"seen",
"in",
"Kryo",
"which",
"benchmarking",
"showed",
"helped",
".",
"Scala",
"cannot",
"supress",
"warnings",
"like",
"this",
"so",
"we",
"do",
"it",
"here"
] | train | https://github.com/twitter/scalding/blob/428b5507279655676e507d52c669c3cbc7812dc0/scalding-serialization/src/main/java/com/twitter/scalding/serialization/Undeprecated.java#L25-L28 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java | RandomUtil.randomDouble | public static double randomDouble(double min, double max, int scale, RoundingMode roundingMode) {
"""
获得指定范围内的随机数
@param min 最小数(包含)
@param max 最大数(不包含)
@param scale 保留小数位数
@param roundingMode 保留小数的模式 {@link RoundingMode}
@return 随机数
@since 4.0.8
"""
return NumberUtil.round(randomDouble(min, max), scale, roundingMode).doubleValue();
} | java | public static double randomDouble(double min, double max, int scale, RoundingMode roundingMode) {
return NumberUtil.round(randomDouble(min, max), scale, roundingMode).doubleValue();
} | [
"public",
"static",
"double",
"randomDouble",
"(",
"double",
"min",
",",
"double",
"max",
",",
"int",
"scale",
",",
"RoundingMode",
"roundingMode",
")",
"{",
"return",
"NumberUtil",
".",
"round",
"(",
"randomDouble",
"(",
"min",
",",
"max",
")",
",",
"scale",
",",
"roundingMode",
")",
".",
"doubleValue",
"(",
")",
";",
"}"
] | 获得指定范围内的随机数
@param min 最小数(包含)
@param max 最大数(不包含)
@param scale 保留小数位数
@param roundingMode 保留小数的模式 {@link RoundingMode}
@return 随机数
@since 4.0.8 | [
"获得指定范围内的随机数"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/RandomUtil.java#L160-L162 |
LGoodDatePicker/LGoodDatePicker | Project/src/main/java/com/github/lgooddatepicker/components/TimePickerSettings.java | TimePickerSettings.zApplyMinimumSpinnerButtonWidthInPixels | void zApplyMinimumSpinnerButtonWidthInPixels() {
"""
zApplyMinimumSpinnerButtonWidthInPixels, The applies the specified setting to the time
picker.
"""
if (parent == null) {
return;
}
Dimension decreaseButtonPreferredSize = parent.getComponentDecreaseSpinnerButton().getPreferredSize();
Dimension increaseButtonPreferredSize = parent.getComponentIncreaseSpinnerButton().getPreferredSize();
int width = Math.max(decreaseButtonPreferredSize.width, increaseButtonPreferredSize.width);
int height = Math.max(decreaseButtonPreferredSize.height, increaseButtonPreferredSize.height);
int minimumWidth = minimumSpinnerButtonWidthInPixels;
width = (width < minimumWidth) ? minimumWidth : width;
Dimension newSize = new Dimension(width, height);
parent.getComponentDecreaseSpinnerButton().setPreferredSize(newSize);
parent.getComponentIncreaseSpinnerButton().setPreferredSize(newSize);
} | java | void zApplyMinimumSpinnerButtonWidthInPixels() {
if (parent == null) {
return;
}
Dimension decreaseButtonPreferredSize = parent.getComponentDecreaseSpinnerButton().getPreferredSize();
Dimension increaseButtonPreferredSize = parent.getComponentIncreaseSpinnerButton().getPreferredSize();
int width = Math.max(decreaseButtonPreferredSize.width, increaseButtonPreferredSize.width);
int height = Math.max(decreaseButtonPreferredSize.height, increaseButtonPreferredSize.height);
int minimumWidth = minimumSpinnerButtonWidthInPixels;
width = (width < minimumWidth) ? minimumWidth : width;
Dimension newSize = new Dimension(width, height);
parent.getComponentDecreaseSpinnerButton().setPreferredSize(newSize);
parent.getComponentIncreaseSpinnerButton().setPreferredSize(newSize);
} | [
"void",
"zApplyMinimumSpinnerButtonWidthInPixels",
"(",
")",
"{",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Dimension",
"decreaseButtonPreferredSize",
"=",
"parent",
".",
"getComponentDecreaseSpinnerButton",
"(",
")",
".",
"getPreferredSize",
"(",
")",
";",
"Dimension",
"increaseButtonPreferredSize",
"=",
"parent",
".",
"getComponentIncreaseSpinnerButton",
"(",
")",
".",
"getPreferredSize",
"(",
")",
";",
"int",
"width",
"=",
"Math",
".",
"max",
"(",
"decreaseButtonPreferredSize",
".",
"width",
",",
"increaseButtonPreferredSize",
".",
"width",
")",
";",
"int",
"height",
"=",
"Math",
".",
"max",
"(",
"decreaseButtonPreferredSize",
".",
"height",
",",
"increaseButtonPreferredSize",
".",
"height",
")",
";",
"int",
"minimumWidth",
"=",
"minimumSpinnerButtonWidthInPixels",
";",
"width",
"=",
"(",
"width",
"<",
"minimumWidth",
")",
"?",
"minimumWidth",
":",
"width",
";",
"Dimension",
"newSize",
"=",
"new",
"Dimension",
"(",
"width",
",",
"height",
")",
";",
"parent",
".",
"getComponentDecreaseSpinnerButton",
"(",
")",
".",
"setPreferredSize",
"(",
"newSize",
")",
";",
"parent",
".",
"getComponentIncreaseSpinnerButton",
"(",
")",
".",
"setPreferredSize",
"(",
"newSize",
")",
";",
"}"
] | zApplyMinimumSpinnerButtonWidthInPixels, The applies the specified setting to the time
picker. | [
"zApplyMinimumSpinnerButtonWidthInPixels",
"The",
"applies",
"the",
"specified",
"setting",
"to",
"the",
"time",
"picker",
"."
] | train | https://github.com/LGoodDatePicker/LGoodDatePicker/blob/c7df05a5fe382e1e08a6237e9391d8dc5fd48692/Project/src/main/java/com/github/lgooddatepicker/components/TimePickerSettings.java#L961-L974 |
Waikato/moa | moa/src/main/java/moa/classifiers/meta/DACC.java | DACC.updateEvaluationWindow | protected double updateEvaluationWindow(int index,int val) {
"""
Updates the evaluation window of a classifier and returns the
updated weight value.
@param index the index of the classifier in the ensemble
@param val the last evaluation record of the classifier
@return the updated weight value of the classifier
"""
int[] newEnsembleWindows = new int[this.ensembleWindows[index].length];
int wsize = (int)Math.min(this.evaluationSizeOption.getValue(),this.ensembleAges[index]+1);
int sum = 0;
for (int i = 0; i < wsize-1 ; i++){
newEnsembleWindows[i+1] = this.ensembleWindows[index][i];
sum = sum + this.ensembleWindows[index][i];
}
newEnsembleWindows[0] = val;
this.ensembleWindows[index] = newEnsembleWindows;
if (this.ensembleAges[index] >= this.maturityOption.getValue())
return (sum + val) * 1.0/wsize;
else
return 0;
} | java | protected double updateEvaluationWindow(int index,int val){
int[] newEnsembleWindows = new int[this.ensembleWindows[index].length];
int wsize = (int)Math.min(this.evaluationSizeOption.getValue(),this.ensembleAges[index]+1);
int sum = 0;
for (int i = 0; i < wsize-1 ; i++){
newEnsembleWindows[i+1] = this.ensembleWindows[index][i];
sum = sum + this.ensembleWindows[index][i];
}
newEnsembleWindows[0] = val;
this.ensembleWindows[index] = newEnsembleWindows;
if (this.ensembleAges[index] >= this.maturityOption.getValue())
return (sum + val) * 1.0/wsize;
else
return 0;
} | [
"protected",
"double",
"updateEvaluationWindow",
"(",
"int",
"index",
",",
"int",
"val",
")",
"{",
"int",
"[",
"]",
"newEnsembleWindows",
"=",
"new",
"int",
"[",
"this",
".",
"ensembleWindows",
"[",
"index",
"]",
".",
"length",
"]",
";",
"int",
"wsize",
"=",
"(",
"int",
")",
"Math",
".",
"min",
"(",
"this",
".",
"evaluationSizeOption",
".",
"getValue",
"(",
")",
",",
"this",
".",
"ensembleAges",
"[",
"index",
"]",
"+",
"1",
")",
";",
"int",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"wsize",
"-",
"1",
";",
"i",
"++",
")",
"{",
"newEnsembleWindows",
"[",
"i",
"+",
"1",
"]",
"=",
"this",
".",
"ensembleWindows",
"[",
"index",
"]",
"[",
"i",
"]",
";",
"sum",
"=",
"sum",
"+",
"this",
".",
"ensembleWindows",
"[",
"index",
"]",
"[",
"i",
"]",
";",
"}",
"newEnsembleWindows",
"[",
"0",
"]",
"=",
"val",
";",
"this",
".",
"ensembleWindows",
"[",
"index",
"]",
"=",
"newEnsembleWindows",
";",
"if",
"(",
"this",
".",
"ensembleAges",
"[",
"index",
"]",
">=",
"this",
".",
"maturityOption",
".",
"getValue",
"(",
")",
")",
"return",
"(",
"sum",
"+",
"val",
")",
"*",
"1.0",
"/",
"wsize",
";",
"else",
"return",
"0",
";",
"}"
] | Updates the evaluation window of a classifier and returns the
updated weight value.
@param index the index of the classifier in the ensemble
@param val the last evaluation record of the classifier
@return the updated weight value of the classifier | [
"Updates",
"the",
"evaluation",
"window",
"of",
"a",
"classifier",
"and",
"returns",
"the",
"updated",
"weight",
"value",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/classifiers/meta/DACC.java#L245-L265 |
greenmail-mail-test/greenmail | greenmail-core/src/main/java/com/icegreen/greenmail/util/ServerSetup.java | ServerSetup.configureJavaMailSessionProperties | public Properties configureJavaMailSessionProperties(Properties properties, boolean debug) {
"""
Creates default properties for a JavaMail session.
Concrete server implementations can add protocol specific settings.
<p/>
For details see
<ul>
<li>http://docs.oracle.com/javaee/6/api/javax/mail/package-summary.html for some general settings</li>
<li>https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html for valid SMTP properties.</li>
<li>https://javamail.java.net/nonav/docs/api/com/sun/mail/imap/package-summary.html for valid IMAP properties</li>
<li>https://javamail.java.net/nonav/docs/api/com/sun/mail/pop3/package-summary.html for valid POP3 properties.</li>
</ul
@param properties additional and optional properties which overwrite automatically added properties. Can be null.
@param debug sets JavaMail debug properties
@return default properties.
"""
Properties props = new Properties();
if (debug) {
props.setProperty("mail.debug", "true");
// System.setProperty("mail.socket.debug", "true");
}
// Set local host address (makes tests much faster. If this is not set java mail always looks for the address)
props.setProperty(MAIL_DOT + getProtocol() + ".localaddress", String.valueOf(ServerSetup.getLocalHostAddress()));
props.setProperty(MAIL_DOT + getProtocol() + ".port", String.valueOf(getPort()));
props.setProperty(MAIL_DOT + getProtocol() + ".host", String.valueOf(getBindAddress()));
if (isSecure()) {
props.put(MAIL_DOT + getProtocol() + ".starttls.enable", Boolean.TRUE);
props.setProperty(MAIL_DOT + getProtocol() + ".socketFactory.class", DummySSLSocketFactory.class.getName());
props.setProperty(MAIL_DOT + getProtocol() + ".socketFactory.fallback", "false");
}
// Timeouts
props.setProperty(MAIL_DOT + getProtocol() + ".connectiontimeout",
Long.toString(getConnectionTimeout() < 0L ? ServerSetup.CONNECTION_TIMEOUT : getConnectionTimeout()));
props.setProperty(MAIL_DOT + getProtocol() + ".timeout",
Long.toString(getReadTimeout() < 0L ? ServerSetup.READ_TIMEOUT : getReadTimeout()));
// Note: "mail." + setup.getProtocol() + ".writetimeout" breaks TLS/SSL Dummy Socket and makes tests run 6x slower!!!
// Therefore we do not by default configure writetimeout.
if (getWriteTimeout() >= 0L) {
props.setProperty(MAIL_DOT + getProtocol() + ".writetimeout", Long.toString(getWriteTimeout()));
}
// Protocol specific extensions
if (getProtocol().startsWith(PROTOCOL_SMTP)) {
props.setProperty("mail.transport.protocol", getProtocol());
props.setProperty("mail.transport.protocol.rfc822", getProtocol());
}
// Auto configure stores.
props.setProperty("mail.store.protocol", getProtocol());
// Merge with optional additional properties
if (null != properties && !properties.isEmpty()) {
props.putAll(properties);
}
return props;
} | java | public Properties configureJavaMailSessionProperties(Properties properties, boolean debug) {
Properties props = new Properties();
if (debug) {
props.setProperty("mail.debug", "true");
// System.setProperty("mail.socket.debug", "true");
}
// Set local host address (makes tests much faster. If this is not set java mail always looks for the address)
props.setProperty(MAIL_DOT + getProtocol() + ".localaddress", String.valueOf(ServerSetup.getLocalHostAddress()));
props.setProperty(MAIL_DOT + getProtocol() + ".port", String.valueOf(getPort()));
props.setProperty(MAIL_DOT + getProtocol() + ".host", String.valueOf(getBindAddress()));
if (isSecure()) {
props.put(MAIL_DOT + getProtocol() + ".starttls.enable", Boolean.TRUE);
props.setProperty(MAIL_DOT + getProtocol() + ".socketFactory.class", DummySSLSocketFactory.class.getName());
props.setProperty(MAIL_DOT + getProtocol() + ".socketFactory.fallback", "false");
}
// Timeouts
props.setProperty(MAIL_DOT + getProtocol() + ".connectiontimeout",
Long.toString(getConnectionTimeout() < 0L ? ServerSetup.CONNECTION_TIMEOUT : getConnectionTimeout()));
props.setProperty(MAIL_DOT + getProtocol() + ".timeout",
Long.toString(getReadTimeout() < 0L ? ServerSetup.READ_TIMEOUT : getReadTimeout()));
// Note: "mail." + setup.getProtocol() + ".writetimeout" breaks TLS/SSL Dummy Socket and makes tests run 6x slower!!!
// Therefore we do not by default configure writetimeout.
if (getWriteTimeout() >= 0L) {
props.setProperty(MAIL_DOT + getProtocol() + ".writetimeout", Long.toString(getWriteTimeout()));
}
// Protocol specific extensions
if (getProtocol().startsWith(PROTOCOL_SMTP)) {
props.setProperty("mail.transport.protocol", getProtocol());
props.setProperty("mail.transport.protocol.rfc822", getProtocol());
}
// Auto configure stores.
props.setProperty("mail.store.protocol", getProtocol());
// Merge with optional additional properties
if (null != properties && !properties.isEmpty()) {
props.putAll(properties);
}
return props;
} | [
"public",
"Properties",
"configureJavaMailSessionProperties",
"(",
"Properties",
"properties",
",",
"boolean",
"debug",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"if",
"(",
"debug",
")",
"{",
"props",
".",
"setProperty",
"(",
"\"mail.debug\"",
",",
"\"true\"",
")",
";",
"// System.setProperty(\"mail.socket.debug\", \"true\");\r",
"}",
"// Set local host address (makes tests much faster. If this is not set java mail always looks for the address)\r",
"props",
".",
"setProperty",
"(",
"MAIL_DOT",
"+",
"getProtocol",
"(",
")",
"+",
"\".localaddress\"",
",",
"String",
".",
"valueOf",
"(",
"ServerSetup",
".",
"getLocalHostAddress",
"(",
")",
")",
")",
";",
"props",
".",
"setProperty",
"(",
"MAIL_DOT",
"+",
"getProtocol",
"(",
")",
"+",
"\".port\"",
",",
"String",
".",
"valueOf",
"(",
"getPort",
"(",
")",
")",
")",
";",
"props",
".",
"setProperty",
"(",
"MAIL_DOT",
"+",
"getProtocol",
"(",
")",
"+",
"\".host\"",
",",
"String",
".",
"valueOf",
"(",
"getBindAddress",
"(",
")",
")",
")",
";",
"if",
"(",
"isSecure",
"(",
")",
")",
"{",
"props",
".",
"put",
"(",
"MAIL_DOT",
"+",
"getProtocol",
"(",
")",
"+",
"\".starttls.enable\"",
",",
"Boolean",
".",
"TRUE",
")",
";",
"props",
".",
"setProperty",
"(",
"MAIL_DOT",
"+",
"getProtocol",
"(",
")",
"+",
"\".socketFactory.class\"",
",",
"DummySSLSocketFactory",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"props",
".",
"setProperty",
"(",
"MAIL_DOT",
"+",
"getProtocol",
"(",
")",
"+",
"\".socketFactory.fallback\"",
",",
"\"false\"",
")",
";",
"}",
"// Timeouts\r",
"props",
".",
"setProperty",
"(",
"MAIL_DOT",
"+",
"getProtocol",
"(",
")",
"+",
"\".connectiontimeout\"",
",",
"Long",
".",
"toString",
"(",
"getConnectionTimeout",
"(",
")",
"<",
"0L",
"?",
"ServerSetup",
".",
"CONNECTION_TIMEOUT",
":",
"getConnectionTimeout",
"(",
")",
")",
")",
";",
"props",
".",
"setProperty",
"(",
"MAIL_DOT",
"+",
"getProtocol",
"(",
")",
"+",
"\".timeout\"",
",",
"Long",
".",
"toString",
"(",
"getReadTimeout",
"(",
")",
"<",
"0L",
"?",
"ServerSetup",
".",
"READ_TIMEOUT",
":",
"getReadTimeout",
"(",
")",
")",
")",
";",
"// Note: \"mail.\" + setup.getProtocol() + \".writetimeout\" breaks TLS/SSL Dummy Socket and makes tests run 6x slower!!!\r",
"// Therefore we do not by default configure writetimeout.\r",
"if",
"(",
"getWriteTimeout",
"(",
")",
">=",
"0L",
")",
"{",
"props",
".",
"setProperty",
"(",
"MAIL_DOT",
"+",
"getProtocol",
"(",
")",
"+",
"\".writetimeout\"",
",",
"Long",
".",
"toString",
"(",
"getWriteTimeout",
"(",
")",
")",
")",
";",
"}",
"// Protocol specific extensions\r",
"if",
"(",
"getProtocol",
"(",
")",
".",
"startsWith",
"(",
"PROTOCOL_SMTP",
")",
")",
"{",
"props",
".",
"setProperty",
"(",
"\"mail.transport.protocol\"",
",",
"getProtocol",
"(",
")",
")",
";",
"props",
".",
"setProperty",
"(",
"\"mail.transport.protocol.rfc822\"",
",",
"getProtocol",
"(",
")",
")",
";",
"}",
"// Auto configure stores.\r",
"props",
".",
"setProperty",
"(",
"\"mail.store.protocol\"",
",",
"getProtocol",
"(",
")",
")",
";",
"// Merge with optional additional properties\r",
"if",
"(",
"null",
"!=",
"properties",
"&&",
"!",
"properties",
".",
"isEmpty",
"(",
")",
")",
"{",
"props",
".",
"putAll",
"(",
"properties",
")",
";",
"}",
"return",
"props",
";",
"}"
] | Creates default properties for a JavaMail session.
Concrete server implementations can add protocol specific settings.
<p/>
For details see
<ul>
<li>http://docs.oracle.com/javaee/6/api/javax/mail/package-summary.html for some general settings</li>
<li>https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html for valid SMTP properties.</li>
<li>https://javamail.java.net/nonav/docs/api/com/sun/mail/imap/package-summary.html for valid IMAP properties</li>
<li>https://javamail.java.net/nonav/docs/api/com/sun/mail/pop3/package-summary.html for valid POP3 properties.</li>
</ul
@param properties additional and optional properties which overwrite automatically added properties. Can be null.
@param debug sets JavaMail debug properties
@return default properties. | [
"Creates",
"default",
"properties",
"for",
"a",
"JavaMail",
"session",
".",
"Concrete",
"server",
"implementations",
"can",
"add",
"protocol",
"specific",
"settings",
".",
"<p",
"/",
">",
"For",
"details",
"see",
"<ul",
">",
"<li",
">",
"http",
":",
"//",
"docs",
".",
"oracle",
".",
"com",
"/",
"javaee",
"/",
"6",
"/",
"api",
"/",
"javax",
"/",
"mail",
"/",
"package",
"-",
"summary",
".",
"html",
"for",
"some",
"general",
"settings<",
"/",
"li",
">",
"<li",
">",
"https",
":",
"//",
"javamail",
".",
"java",
".",
"net",
"/",
"nonav",
"/",
"docs",
"/",
"api",
"/",
"com",
"/",
"sun",
"/",
"mail",
"/",
"smtp",
"/",
"package",
"-",
"summary",
".",
"html",
"for",
"valid",
"SMTP",
"properties",
".",
"<",
"/",
"li",
">",
"<li",
">",
"https",
":",
"//",
"javamail",
".",
"java",
".",
"net",
"/",
"nonav",
"/",
"docs",
"/",
"api",
"/",
"com",
"/",
"sun",
"/",
"mail",
"/",
"imap",
"/",
"package",
"-",
"summary",
".",
"html",
"for",
"valid",
"IMAP",
"properties<",
"/",
"li",
">",
"<li",
">",
"https",
":",
"//",
"javamail",
".",
"java",
".",
"net",
"/",
"nonav",
"/",
"docs",
"/",
"api",
"/",
"com",
"/",
"sun",
"/",
"mail",
"/",
"pop3",
"/",
"package",
"-",
"summary",
".",
"html",
"for",
"valid",
"POP3",
"properties",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul"
] | train | https://github.com/greenmail-mail-test/greenmail/blob/6d19a62233d1ef6fedbbd1f6fdde2d28e713834a/greenmail-core/src/main/java/com/icegreen/greenmail/util/ServerSetup.java#L195-L240 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/JobOperations.java | JobOperations.getJob | public CloudJob getJob(String jobId, DetailLevel detailLevel, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
"""
Gets the specified {@link CloudJob}.
@param jobId The ID of the job to get.
@param detailLevel A {@link DetailLevel} used for controlling which properties are retrieved from the service.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@return A {@link CloudJob} containing information about the specified Azure Batch job.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
"""
JobGetOptions getJobOptions = new JobGetOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.appendDetailLevelToPerCallBehaviors(detailLevel);
bhMgr.applyRequestBehaviors(getJobOptions);
return this.parentBatchClient.protocolLayer().jobs().get(jobId, getJobOptions);
} | java | public CloudJob getJob(String jobId, DetailLevel detailLevel, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
JobGetOptions getJobOptions = new JobGetOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.appendDetailLevelToPerCallBehaviors(detailLevel);
bhMgr.applyRequestBehaviors(getJobOptions);
return this.parentBatchClient.protocolLayer().jobs().get(jobId, getJobOptions);
} | [
"public",
"CloudJob",
"getJob",
"(",
"String",
"jobId",
",",
"DetailLevel",
"detailLevel",
",",
"Iterable",
"<",
"BatchClientBehavior",
">",
"additionalBehaviors",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"JobGetOptions",
"getJobOptions",
"=",
"new",
"JobGetOptions",
"(",
")",
";",
"BehaviorManager",
"bhMgr",
"=",
"new",
"BehaviorManager",
"(",
"this",
".",
"customBehaviors",
"(",
")",
",",
"additionalBehaviors",
")",
";",
"bhMgr",
".",
"appendDetailLevelToPerCallBehaviors",
"(",
"detailLevel",
")",
";",
"bhMgr",
".",
"applyRequestBehaviors",
"(",
"getJobOptions",
")",
";",
"return",
"this",
".",
"parentBatchClient",
".",
"protocolLayer",
"(",
")",
".",
"jobs",
"(",
")",
".",
"get",
"(",
"jobId",
",",
"getJobOptions",
")",
";",
"}"
] | Gets the specified {@link CloudJob}.
@param jobId The ID of the job to get.
@param detailLevel A {@link DetailLevel} used for controlling which properties are retrieved from the service.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@return A {@link CloudJob} containing information about the specified Azure Batch job.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. | [
"Gets",
"the",
"specified",
"{",
"@link",
"CloudJob",
"}",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/JobOperations.java#L141-L149 |
threerings/gwt-utils | src/main/java/com/threerings/gwt/ui/SmartTable.java | SmartTable.addText | public int addText (Object text, int colSpan, String... styles) {
"""
Adds text to the bottom row of this table in column zero, with the specified column span and
style.
@param text an object whose string value will be displayed.
@return the row to which the text was added.
"""
int row = getRowCount();
setText(row, 0, text, colSpan, styles);
return row;
} | java | public int addText (Object text, int colSpan, String... styles)
{
int row = getRowCount();
setText(row, 0, text, colSpan, styles);
return row;
} | [
"public",
"int",
"addText",
"(",
"Object",
"text",
",",
"int",
"colSpan",
",",
"String",
"...",
"styles",
")",
"{",
"int",
"row",
"=",
"getRowCount",
"(",
")",
";",
"setText",
"(",
"row",
",",
"0",
",",
"text",
",",
"colSpan",
",",
"styles",
")",
";",
"return",
"row",
";",
"}"
] | Adds text to the bottom row of this table in column zero, with the specified column span and
style.
@param text an object whose string value will be displayed.
@return the row to which the text was added. | [
"Adds",
"text",
"to",
"the",
"bottom",
"row",
"of",
"this",
"table",
"in",
"column",
"zero",
"with",
"the",
"specified",
"column",
"span",
"and",
"style",
"."
] | train | https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/SmartTable.java#L311-L316 |
deeplearning4j/deeplearning4j | nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/v2/ModelParameterServer.java | ModelParameterServer.configure | public void configure(@NonNull VoidConfiguration configuration, @NonNull Transport transport, boolean isMasterNode) {
"""
This method stores provided entities for MPS internal use
@param configuration
@param transport
@param isMasterNode
"""
this.transport = transport;
this.masterMode = isMasterNode;
this.configuration = configuration;
} | java | public void configure(@NonNull VoidConfiguration configuration, @NonNull Transport transport, boolean isMasterNode) {
this.transport = transport;
this.masterMode = isMasterNode;
this.configuration = configuration;
} | [
"public",
"void",
"configure",
"(",
"@",
"NonNull",
"VoidConfiguration",
"configuration",
",",
"@",
"NonNull",
"Transport",
"transport",
",",
"boolean",
"isMasterNode",
")",
"{",
"this",
".",
"transport",
"=",
"transport",
";",
"this",
".",
"masterMode",
"=",
"isMasterNode",
";",
"this",
".",
"configuration",
"=",
"configuration",
";",
"}"
] | This method stores provided entities for MPS internal use
@param configuration
@param transport
@param isMasterNode | [
"This",
"method",
"stores",
"provided",
"entities",
"for",
"MPS",
"internal",
"use"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/v2/ModelParameterServer.java#L153-L157 |
Chorus-bdd/Chorus | interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java | HandlerManager.processEndOfScope | public void processEndOfScope(Scope scopeEnding, Iterable<Object> handlerInstances) throws Exception {
"""
Scope is ending, perform the required processing on the supplied handlers.
"""
for (Object handler : handlerInstances) {
Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class);
Scope scope = handlerAnnotation.scope();
runLifecycleMethods(handler, scope, scopeEnding, true);
//dispose handler instances with a scope which matches the scopeEnding
if (scope == scopeEnding) {
disposeSpringResources(handler, scopeEnding);
}
}
} | java | public void processEndOfScope(Scope scopeEnding, Iterable<Object> handlerInstances) throws Exception {
for (Object handler : handlerInstances) {
Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class);
Scope scope = handlerAnnotation.scope();
runLifecycleMethods(handler, scope, scopeEnding, true);
//dispose handler instances with a scope which matches the scopeEnding
if (scope == scopeEnding) {
disposeSpringResources(handler, scopeEnding);
}
}
} | [
"public",
"void",
"processEndOfScope",
"(",
"Scope",
"scopeEnding",
",",
"Iterable",
"<",
"Object",
">",
"handlerInstances",
")",
"throws",
"Exception",
"{",
"for",
"(",
"Object",
"handler",
":",
"handlerInstances",
")",
"{",
"Handler",
"handlerAnnotation",
"=",
"handler",
".",
"getClass",
"(",
")",
".",
"getAnnotation",
"(",
"Handler",
".",
"class",
")",
";",
"Scope",
"scope",
"=",
"handlerAnnotation",
".",
"scope",
"(",
")",
";",
"runLifecycleMethods",
"(",
"handler",
",",
"scope",
",",
"scopeEnding",
",",
"true",
")",
";",
"//dispose handler instances with a scope which matches the scopeEnding",
"if",
"(",
"scope",
"==",
"scopeEnding",
")",
"{",
"disposeSpringResources",
"(",
"handler",
",",
"scopeEnding",
")",
";",
"}",
"}",
"}"
] | Scope is ending, perform the required processing on the supplied handlers. | [
"Scope",
"is",
"ending",
"perform",
"the",
"required",
"processing",
"on",
"the",
"supplied",
"handlers",
"."
] | train | https://github.com/Chorus-bdd/Chorus/blob/1eea7ca858876bce821bb49b43fd5b6ba1737997/interpreter/chorus-interpreter/src/main/java/org/chorusbdd/chorus/interpreter/interpreter/HandlerManager.java#L149-L161 |
Canadensys/canadensys-core | src/main/java/net/canadensys/utils/LangUtils.java | LangUtils.getClassAnnotationValue | public static <T, A extends Annotation> String getClassAnnotationValue(Class<T> classType, Class<A> annotationType, String attributeName) {
"""
Get the value of a Annotation in a class declaration.
@param classType
@param annotationType
@param attributeName
@return the value of the annotation as String or null if something goes wrong
"""
String value = null;
Annotation annotation = classType.getAnnotation(annotationType);
if (annotation != null) {
try {
value = (String) annotation.annotationType().getMethod(attributeName).invoke(annotation);
} catch (Exception ex) {}
}
return value;
} | java | public static <T, A extends Annotation> String getClassAnnotationValue(Class<T> classType, Class<A> annotationType, String attributeName) {
String value = null;
Annotation annotation = classType.getAnnotation(annotationType);
if (annotation != null) {
try {
value = (String) annotation.annotationType().getMethod(attributeName).invoke(annotation);
} catch (Exception ex) {}
}
return value;
} | [
"public",
"static",
"<",
"T",
",",
"A",
"extends",
"Annotation",
">",
"String",
"getClassAnnotationValue",
"(",
"Class",
"<",
"T",
">",
"classType",
",",
"Class",
"<",
"A",
">",
"annotationType",
",",
"String",
"attributeName",
")",
"{",
"String",
"value",
"=",
"null",
";",
"Annotation",
"annotation",
"=",
"classType",
".",
"getAnnotation",
"(",
"annotationType",
")",
";",
"if",
"(",
"annotation",
"!=",
"null",
")",
"{",
"try",
"{",
"value",
"=",
"(",
"String",
")",
"annotation",
".",
"annotationType",
"(",
")",
".",
"getMethod",
"(",
"attributeName",
")",
".",
"invoke",
"(",
"annotation",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"}",
"return",
"value",
";",
"}"
] | Get the value of a Annotation in a class declaration.
@param classType
@param annotationType
@param attributeName
@return the value of the annotation as String or null if something goes wrong | [
"Get",
"the",
"value",
"of",
"a",
"Annotation",
"in",
"a",
"class",
"declaration",
"."
] | train | https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/LangUtils.java#L19-L28 |
ksclarke/vertx-pairtree | src/main/java/info/freelibrary/pairtree/PairtreeFactory.java | PairtreeFactory.getPrefixedPairtree | public Pairtree getPrefixedPairtree(final String aPrefix, final File aDirectory) throws PairtreeException {
"""
Gets a file system based Pairtree using the supplied directory as the Pairtree root and the supplied prefix as
the Pairtree prefix.
@param aPrefix A Pairtree prefix
@param aDirectory A directory to use for the Pairtree root
@return A Pairtree root
@throws PairtreeException If there is trouble creating the Pairtree
"""
return new FsPairtree(aPrefix, myVertx, getDirPath(aDirectory));
} | java | public Pairtree getPrefixedPairtree(final String aPrefix, final File aDirectory) throws PairtreeException {
return new FsPairtree(aPrefix, myVertx, getDirPath(aDirectory));
} | [
"public",
"Pairtree",
"getPrefixedPairtree",
"(",
"final",
"String",
"aPrefix",
",",
"final",
"File",
"aDirectory",
")",
"throws",
"PairtreeException",
"{",
"return",
"new",
"FsPairtree",
"(",
"aPrefix",
",",
"myVertx",
",",
"getDirPath",
"(",
"aDirectory",
")",
")",
";",
"}"
] | Gets a file system based Pairtree using the supplied directory as the Pairtree root and the supplied prefix as
the Pairtree prefix.
@param aPrefix A Pairtree prefix
@param aDirectory A directory to use for the Pairtree root
@return A Pairtree root
@throws PairtreeException If there is trouble creating the Pairtree | [
"Gets",
"a",
"file",
"system",
"based",
"Pairtree",
"using",
"the",
"supplied",
"directory",
"as",
"the",
"Pairtree",
"root",
"and",
"the",
"supplied",
"prefix",
"as",
"the",
"Pairtree",
"prefix",
"."
] | train | https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/PairtreeFactory.java#L83-L85 |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.setStatic | public MethodHandle setStatic(MethodHandles.Lookup lookup, Class<?> target, String name) throws NoSuchFieldException, IllegalAccessException {
"""
Apply the chain of transforms and bind them to an object field assignment specified
using the end signature plus the given class and name. The end signature must take
the target class or a subclass and the field's type as its arguments, and its return
type must be compatible with void.
If the final handle's type does not exactly match the initial type for
this Binder, an additional cast will be attempted.
@param lookup the MethodHandles.Lookup to use to look up the field
@param target the class in which the field is defined
@param name the field's name
@return the full handle chain, bound to the given field assignment
@throws java.lang.NoSuchFieldException if the field does not exist
@throws java.lang.IllegalAccessException if the field is not accessible or cannot be modified
"""
return invoke(lookup.findStaticSetter(target, name, type().parameterType(0)));
} | java | public MethodHandle setStatic(MethodHandles.Lookup lookup, Class<?> target, String name) throws NoSuchFieldException, IllegalAccessException {
return invoke(lookup.findStaticSetter(target, name, type().parameterType(0)));
} | [
"public",
"MethodHandle",
"setStatic",
"(",
"MethodHandles",
".",
"Lookup",
"lookup",
",",
"Class",
"<",
"?",
">",
"target",
",",
"String",
"name",
")",
"throws",
"NoSuchFieldException",
",",
"IllegalAccessException",
"{",
"return",
"invoke",
"(",
"lookup",
".",
"findStaticSetter",
"(",
"target",
",",
"name",
",",
"type",
"(",
")",
".",
"parameterType",
"(",
"0",
")",
")",
")",
";",
"}"
] | Apply the chain of transforms and bind them to an object field assignment specified
using the end signature plus the given class and name. The end signature must take
the target class or a subclass and the field's type as its arguments, and its return
type must be compatible with void.
If the final handle's type does not exactly match the initial type for
this Binder, an additional cast will be attempted.
@param lookup the MethodHandles.Lookup to use to look up the field
@param target the class in which the field is defined
@param name the field's name
@return the full handle chain, bound to the given field assignment
@throws java.lang.NoSuchFieldException if the field does not exist
@throws java.lang.IllegalAccessException if the field is not accessible or cannot be modified | [
"Apply",
"the",
"chain",
"of",
"transforms",
"and",
"bind",
"them",
"to",
"an",
"object",
"field",
"assignment",
"specified",
"using",
"the",
"end",
"signature",
"plus",
"the",
"given",
"class",
"and",
"name",
".",
"The",
"end",
"signature",
"must",
"take",
"the",
"target",
"class",
"or",
"a",
"subclass",
"and",
"the",
"field",
"s",
"type",
"as",
"its",
"arguments",
"and",
"its",
"return",
"type",
"must",
"be",
"compatible",
"with",
"void",
"."
] | train | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L1519-L1521 |
google/gson | gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java | ISO8601Utils.indexOfNonDigit | private static int indexOfNonDigit(String string, int offset) {
"""
Returns the index of the first character in the string that is not a digit, starting at offset.
"""
for (int i = offset; i < string.length(); i++) {
char c = string.charAt(i);
if (c < '0' || c > '9') return i;
}
return string.length();
} | java | private static int indexOfNonDigit(String string, int offset) {
for (int i = offset; i < string.length(); i++) {
char c = string.charAt(i);
if (c < '0' || c > '9') return i;
}
return string.length();
} | [
"private",
"static",
"int",
"indexOfNonDigit",
"(",
"String",
"string",
",",
"int",
"offset",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"offset",
";",
"i",
"<",
"string",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"string",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"<",
"'",
"'",
"||",
"c",
">",
"'",
"'",
")",
"return",
"i",
";",
"}",
"return",
"string",
".",
"length",
"(",
")",
";",
"}"
] | Returns the index of the first character in the string that is not a digit, starting at offset. | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"character",
"in",
"the",
"string",
"that",
"is",
"not",
"a",
"digit",
"starting",
"at",
"offset",
"."
] | train | https://github.com/google/gson/blob/63ee47cb642c8018e5cddd639aa2be143220ad4b/gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java#L344-L350 |
HsiangLeekwok/hlklib | hlklib/src/main/java/com/hlk/hlklib/etc/BitmapUtils.java | BitmapUtils.getBitmapBySize | public static Bitmap getBitmapBySize(String path, int width, int height) {
"""
将指定的图片压缩成需要的尺寸
@param path 图片的路径
@param width 要压缩成的图片的宽度
@param height 要压缩成的图片的高度
"""
BitmapFactory.Options option = new BitmapFactory.Options();
option.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, option);
option.inSampleSize = computeSampleSize(option, -1, width * height);
option.inJustDecodeBounds = false;
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeFile(path, option);
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
} | java | public static Bitmap getBitmapBySize(String path, int width, int height) {
BitmapFactory.Options option = new BitmapFactory.Options();
option.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, option);
option.inSampleSize = computeSampleSize(option, -1, width * height);
option.inJustDecodeBounds = false;
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeFile(path, option);
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
} | [
"public",
"static",
"Bitmap",
"getBitmapBySize",
"(",
"String",
"path",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"BitmapFactory",
".",
"Options",
"option",
"=",
"new",
"BitmapFactory",
".",
"Options",
"(",
")",
";",
"option",
".",
"inJustDecodeBounds",
"=",
"true",
";",
"BitmapFactory",
".",
"decodeFile",
"(",
"path",
",",
"option",
")",
";",
"option",
".",
"inSampleSize",
"=",
"computeSampleSize",
"(",
"option",
",",
"-",
"1",
",",
"width",
"*",
"height",
")",
";",
"option",
".",
"inJustDecodeBounds",
"=",
"false",
";",
"Bitmap",
"bitmap",
"=",
"null",
";",
"try",
"{",
"bitmap",
"=",
"BitmapFactory",
".",
"decodeFile",
"(",
"path",
",",
"option",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"bitmap",
";",
"}"
] | 将指定的图片压缩成需要的尺寸
@param path 图片的路径
@param width 要压缩成的图片的宽度
@param height 要压缩成的图片的高度 | [
"将指定的图片压缩成需要的尺寸"
] | train | https://github.com/HsiangLeekwok/hlklib/blob/b122f6dcab7cec60c8e5455e0c31613d08bec6ad/hlklib/src/main/java/com/hlk/hlklib/etc/BitmapUtils.java#L26-L40 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/utilities/StringUtility.java | StringUtility.prettyPrint | public static String prettyPrint(String in, int lineLength, String delim) {
"""
Method that attempts to break a string up into lines no longer than the
specified line length.
<p>The string is assumed to consist of tokens separated by a delimeter.
The default delimiter is a space. If the last token to be added to a
line exceeds the specified line length, it is written on the next line
so actual line length is approximate given the specified line length
and the length of tokens in the string.
@param in
The input string to be split into lines.
@param lineLength
The maximum length of each line.
@param delim
The character delimiter separating each token in the input string;
if null, defaults to the space character.
@return A string split into multiple lines whose length is less than the
specified length. Actual length is approximate depending on line
length, token size, and how many complete tokens will fit into
the specified line length.
"""
// make a guess about resulting length to minimize copying
StringBuilder sb = new StringBuilder(in.length() + in.length()/lineLength);
if (delim == null) {
delim = " ";
}
StringTokenizer st = new StringTokenizer(in, delim);
int charCount = 0;
while (st.hasMoreTokens()) {
String s = st.nextToken();
charCount = charCount + s.length();
if (charCount < lineLength) {
sb.append(s);
sb.append(' ');
charCount++;
} else {
sb.append('\n');
sb.append(s);
sb.append(' ');
charCount = s.length() + 1;
}
}
return sb.toString();
} | java | public static String prettyPrint(String in, int lineLength, String delim) {
// make a guess about resulting length to minimize copying
StringBuilder sb = new StringBuilder(in.length() + in.length()/lineLength);
if (delim == null) {
delim = " ";
}
StringTokenizer st = new StringTokenizer(in, delim);
int charCount = 0;
while (st.hasMoreTokens()) {
String s = st.nextToken();
charCount = charCount + s.length();
if (charCount < lineLength) {
sb.append(s);
sb.append(' ');
charCount++;
} else {
sb.append('\n');
sb.append(s);
sb.append(' ');
charCount = s.length() + 1;
}
}
return sb.toString();
} | [
"public",
"static",
"String",
"prettyPrint",
"(",
"String",
"in",
",",
"int",
"lineLength",
",",
"String",
"delim",
")",
"{",
"// make a guess about resulting length to minimize copying",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"in",
".",
"length",
"(",
")",
"+",
"in",
".",
"length",
"(",
")",
"/",
"lineLength",
")",
";",
"if",
"(",
"delim",
"==",
"null",
")",
"{",
"delim",
"=",
"\" \"",
";",
"}",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"in",
",",
"delim",
")",
";",
"int",
"charCount",
"=",
"0",
";",
"while",
"(",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"s",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"charCount",
"=",
"charCount",
"+",
"s",
".",
"length",
"(",
")",
";",
"if",
"(",
"charCount",
"<",
"lineLength",
")",
"{",
"sb",
".",
"append",
"(",
"s",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"charCount",
"++",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"s",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"charCount",
"=",
"s",
".",
"length",
"(",
")",
"+",
"1",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Method that attempts to break a string up into lines no longer than the
specified line length.
<p>The string is assumed to consist of tokens separated by a delimeter.
The default delimiter is a space. If the last token to be added to a
line exceeds the specified line length, it is written on the next line
so actual line length is approximate given the specified line length
and the length of tokens in the string.
@param in
The input string to be split into lines.
@param lineLength
The maximum length of each line.
@param delim
The character delimiter separating each token in the input string;
if null, defaults to the space character.
@return A string split into multiple lines whose length is less than the
specified length. Actual length is approximate depending on line
length, token size, and how many complete tokens will fit into
the specified line length. | [
"Method",
"that",
"attempts",
"to",
"break",
"a",
"string",
"up",
"into",
"lines",
"no",
"longer",
"than",
"the",
"specified",
"line",
"length",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/StringUtility.java#L42-L65 |
nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/JavaBean.java | JavaBean.populate | public static void populate(Map<?,?> aValues, Object bean, PropertyConverter<Object, Object> valueConverter) {
"""
Support nested map objects
@param aValues the key/value properties
@param bean the object to write to
@param valueConverter the value converter strategy object
"""
Object key = null;
Object keyValue;
try
{
for(Map.Entry<?, ?> entry : aValues.entrySet())
{
key = entry.getKey();
keyValue = entry.getValue();
PropertyDescriptor desc = getPropertyDescriptor(bean, String.valueOf(key));
if(desc == null)
continue; //skip
if(desc.getWriteMethod() == null)
continue;
if(valueConverter!= null)
{
Class<?> aClass = desc.getPropertyType();
keyValue = valueConverter.convert(keyValue,aClass);
}
Method invoke = desc.getWriteMethod();
invoke.invoke(bean, keyValue);
}
}
catch (Exception e)
{
throw new FormatException(e.getMessage()+" values:"+aValues,e);
}
} | java | public static void populate(Map<?,?> aValues, Object bean, PropertyConverter<Object, Object> valueConverter)
{
Object key = null;
Object keyValue;
try
{
for(Map.Entry<?, ?> entry : aValues.entrySet())
{
key = entry.getKey();
keyValue = entry.getValue();
PropertyDescriptor desc = getPropertyDescriptor(bean, String.valueOf(key));
if(desc == null)
continue; //skip
if(desc.getWriteMethod() == null)
continue;
if(valueConverter!= null)
{
Class<?> aClass = desc.getPropertyType();
keyValue = valueConverter.convert(keyValue,aClass);
}
Method invoke = desc.getWriteMethod();
invoke.invoke(bean, keyValue);
}
}
catch (Exception e)
{
throw new FormatException(e.getMessage()+" values:"+aValues,e);
}
} | [
"public",
"static",
"void",
"populate",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"aValues",
",",
"Object",
"bean",
",",
"PropertyConverter",
"<",
"Object",
",",
"Object",
">",
"valueConverter",
")",
"{",
"Object",
"key",
"=",
"null",
";",
"Object",
"keyValue",
";",
"try",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"?",
",",
"?",
">",
"entry",
":",
"aValues",
".",
"entrySet",
"(",
")",
")",
"{",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"keyValue",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"PropertyDescriptor",
"desc",
"=",
"getPropertyDescriptor",
"(",
"bean",
",",
"String",
".",
"valueOf",
"(",
"key",
")",
")",
";",
"if",
"(",
"desc",
"==",
"null",
")",
"continue",
";",
"//skip\r",
"if",
"(",
"desc",
".",
"getWriteMethod",
"(",
")",
"==",
"null",
")",
"continue",
";",
"if",
"(",
"valueConverter",
"!=",
"null",
")",
"{",
"Class",
"<",
"?",
">",
"aClass",
"=",
"desc",
".",
"getPropertyType",
"(",
")",
";",
"keyValue",
"=",
"valueConverter",
".",
"convert",
"(",
"keyValue",
",",
"aClass",
")",
";",
"}",
"Method",
"invoke",
"=",
"desc",
".",
"getWriteMethod",
"(",
")",
";",
"invoke",
".",
"invoke",
"(",
"bean",
",",
"keyValue",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"FormatException",
"(",
"e",
".",
"getMessage",
"(",
")",
"+",
"\" values:\"",
"+",
"aValues",
",",
"e",
")",
";",
"}",
"}"
] | Support nested map objects
@param aValues the key/value properties
@param bean the object to write to
@param valueConverter the value converter strategy object | [
"Support",
"nested",
"map",
"objects",
"@param",
"aValues",
"the",
"key",
"/",
"value",
"properties",
"@param",
"bean",
"the",
"object",
"to",
"write",
"to",
"@param",
"valueConverter",
"the",
"value",
"converter",
"strategy",
"object"
] | train | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/JavaBean.java#L95-L131 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/Hdf5Archive.java | Hdf5Archive.getDataSets | public List<String> getDataSets(String... groups) {
"""
Get list of data sets from group path.
@param groups Array of zero or more ancestor groups from root to parent.
@return List of HDF5 data set names
"""
synchronized (Hdf5Archive.LOCK_OBJECT) {
if (groups.length == 0)
return getObjects(this.file, H5O_TYPE_DATASET);
Group[] groupArray = openGroups(groups);
List<String> ls = getObjects(groupArray[groupArray.length - 1], H5O_TYPE_DATASET);
closeGroups(groupArray);
return ls;
}
} | java | public List<String> getDataSets(String... groups) {
synchronized (Hdf5Archive.LOCK_OBJECT) {
if (groups.length == 0)
return getObjects(this.file, H5O_TYPE_DATASET);
Group[] groupArray = openGroups(groups);
List<String> ls = getObjects(groupArray[groupArray.length - 1], H5O_TYPE_DATASET);
closeGroups(groupArray);
return ls;
}
} | [
"public",
"List",
"<",
"String",
">",
"getDataSets",
"(",
"String",
"...",
"groups",
")",
"{",
"synchronized",
"(",
"Hdf5Archive",
".",
"LOCK_OBJECT",
")",
"{",
"if",
"(",
"groups",
".",
"length",
"==",
"0",
")",
"return",
"getObjects",
"(",
"this",
".",
"file",
",",
"H5O_TYPE_DATASET",
")",
";",
"Group",
"[",
"]",
"groupArray",
"=",
"openGroups",
"(",
"groups",
")",
";",
"List",
"<",
"String",
">",
"ls",
"=",
"getObjects",
"(",
"groupArray",
"[",
"groupArray",
".",
"length",
"-",
"1",
"]",
",",
"H5O_TYPE_DATASET",
")",
";",
"closeGroups",
"(",
"groupArray",
")",
";",
"return",
"ls",
";",
"}",
"}"
] | Get list of data sets from group path.
@param groups Array of zero or more ancestor groups from root to parent.
@return List of HDF5 data set names | [
"Get",
"list",
"of",
"data",
"sets",
"from",
"group",
"path",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/Hdf5Archive.java#L194-L203 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ManagedInstancesInner.java | ManagedInstancesInner.beginCreateOrUpdate | public ManagedInstanceInner beginCreateOrUpdate(String resourceGroupName, String managedInstanceName, ManagedInstanceInner parameters) {
"""
Creates or updates a managed instance.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param managedInstanceName The name of the managed instance.
@param parameters The requested managed instance resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ManagedInstanceInner object if successful.
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, parameters).toBlocking().single().body();
} | java | public ManagedInstanceInner beginCreateOrUpdate(String resourceGroupName, String managedInstanceName, ManagedInstanceInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, parameters).toBlocking().single().body();
} | [
"public",
"ManagedInstanceInner",
"beginCreateOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"managedInstanceName",
",",
"ManagedInstanceInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"managedInstanceName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates or updates a managed instance.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param managedInstanceName The name of the managed instance.
@param parameters The requested managed instance resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ManagedInstanceInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"managed",
"instance",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ManagedInstancesInner.java#L511-L513 |
SG-O/miIO | src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java | Vacuum.setTimezone | public boolean setTimezone(TimeZone zone) throws CommandExecutionException {
"""
Set the vacuums timezone
@param zone The new timezone to set.
@return True if the command has been received successfully.
@throws CommandExecutionException When there has been a error during the communication or the response was invalid.
"""
if (zone == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray tz = new JSONArray();
tz.put(zone.getID());
return sendOk("set_timezone", tz);
} | java | public boolean setTimezone(TimeZone zone) throws CommandExecutionException {
if (zone == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray tz = new JSONArray();
tz.put(zone.getID());
return sendOk("set_timezone", tz);
} | [
"public",
"boolean",
"setTimezone",
"(",
"TimeZone",
"zone",
")",
"throws",
"CommandExecutionException",
"{",
"if",
"(",
"zone",
"==",
"null",
")",
"throw",
"new",
"CommandExecutionException",
"(",
"CommandExecutionException",
".",
"Error",
".",
"INVALID_PARAMETERS",
")",
";",
"JSONArray",
"tz",
"=",
"new",
"JSONArray",
"(",
")",
";",
"tz",
".",
"put",
"(",
"zone",
".",
"getID",
"(",
")",
")",
";",
"return",
"sendOk",
"(",
"\"set_timezone\"",
",",
"tz",
")",
";",
"}"
] | Set the vacuums timezone
@param zone The new timezone to set.
@return True if the command has been received successfully.
@throws CommandExecutionException When there has been a error during the communication or the response was invalid. | [
"Set",
"the",
"vacuums",
"timezone"
] | train | https://github.com/SG-O/miIO/blob/f352dbd2a699d2cdb1b412ca5e6cbb0c38ca779b/src/main/java/de/sg_o/app/miio/vacuum/Vacuum.java#L74-L79 |
netty/netty | common/src/main/java/io/netty/util/internal/NativeLibraryUtil.java | NativeLibraryUtil.loadLibrary | public static void loadLibrary(String libName, boolean absolute) {
"""
Delegate the calling to {@link System#load(String)} or {@link System#loadLibrary(String)}.
@param libName - The native library path or name
@param absolute - Whether the native library will be loaded by path or by name
"""
if (absolute) {
System.load(libName);
} else {
System.loadLibrary(libName);
}
} | java | public static void loadLibrary(String libName, boolean absolute) {
if (absolute) {
System.load(libName);
} else {
System.loadLibrary(libName);
}
} | [
"public",
"static",
"void",
"loadLibrary",
"(",
"String",
"libName",
",",
"boolean",
"absolute",
")",
"{",
"if",
"(",
"absolute",
")",
"{",
"System",
".",
"load",
"(",
"libName",
")",
";",
"}",
"else",
"{",
"System",
".",
"loadLibrary",
"(",
"libName",
")",
";",
"}",
"}"
] | Delegate the calling to {@link System#load(String)} or {@link System#loadLibrary(String)}.
@param libName - The native library path or name
@param absolute - Whether the native library will be loaded by path or by name | [
"Delegate",
"the",
"calling",
"to",
"{"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/NativeLibraryUtil.java#L34-L40 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/DateTimeFormatter.java | DateTimeFormatter.printTo | public void printTo(Appendable appendable, ReadablePartial partial) throws IOException {
"""
Prints a ReadablePartial.
<p>
Neither the override chronology nor the override zone are used
by this method.
@param appendable the destination to format to, not null
@param partial partial to format
@since 2.0
"""
InternalPrinter printer = requirePrinter();
if (partial == null) {
throw new IllegalArgumentException("The partial must not be null");
}
printer.printTo(appendable, partial, iLocale);
} | java | public void printTo(Appendable appendable, ReadablePartial partial) throws IOException {
InternalPrinter printer = requirePrinter();
if (partial == null) {
throw new IllegalArgumentException("The partial must not be null");
}
printer.printTo(appendable, partial, iLocale);
} | [
"public",
"void",
"printTo",
"(",
"Appendable",
"appendable",
",",
"ReadablePartial",
"partial",
")",
"throws",
"IOException",
"{",
"InternalPrinter",
"printer",
"=",
"requirePrinter",
"(",
")",
";",
"if",
"(",
"partial",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The partial must not be null\"",
")",
";",
"}",
"printer",
".",
"printTo",
"(",
"appendable",
",",
"partial",
",",
"iLocale",
")",
";",
"}"
] | Prints a ReadablePartial.
<p>
Neither the override chronology nor the override zone are used
by this method.
@param appendable the destination to format to, not null
@param partial partial to format
@since 2.0 | [
"Prints",
"a",
"ReadablePartial",
".",
"<p",
">",
"Neither",
"the",
"override",
"chronology",
"nor",
"the",
"override",
"zone",
"are",
"used",
"by",
"this",
"method",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatter.java#L650-L656 |
jMetal/jMetal | jmetal-core/src/main/java/org/uma/jmetal/util/distance/impl/DistanceBetweenSolutionAndKNearestNeighbors.java | DistanceBetweenSolutionAndKNearestNeighbors.getDistance | @Override
public double getDistance(S solution, L solutionList) {
"""
Computes the knn distance. If the solution list size is lower than k, then k = size in the computation
@param solution
@param solutionList
@return
"""
List<Double> listOfDistances = knnDistances(solution, solutionList) ;
listOfDistances.sort(Comparator.naturalOrder());
int limit = Math.min(k, listOfDistances.size()) ;
double result ;
if (limit == 0) {
result = 0.0 ;
} else {
double sum = 0.0;
for (int i = 0; i < limit; i++) {
sum += listOfDistances.get(i);
}
result = sum/limit ;
}
return result;
} | java | @Override
public double getDistance(S solution, L solutionList) {
List<Double> listOfDistances = knnDistances(solution, solutionList) ;
listOfDistances.sort(Comparator.naturalOrder());
int limit = Math.min(k, listOfDistances.size()) ;
double result ;
if (limit == 0) {
result = 0.0 ;
} else {
double sum = 0.0;
for (int i = 0; i < limit; i++) {
sum += listOfDistances.get(i);
}
result = sum/limit ;
}
return result;
} | [
"@",
"Override",
"public",
"double",
"getDistance",
"(",
"S",
"solution",
",",
"L",
"solutionList",
")",
"{",
"List",
"<",
"Double",
">",
"listOfDistances",
"=",
"knnDistances",
"(",
"solution",
",",
"solutionList",
")",
";",
"listOfDistances",
".",
"sort",
"(",
"Comparator",
".",
"naturalOrder",
"(",
")",
")",
";",
"int",
"limit",
"=",
"Math",
".",
"min",
"(",
"k",
",",
"listOfDistances",
".",
"size",
"(",
")",
")",
";",
"double",
"result",
";",
"if",
"(",
"limit",
"==",
"0",
")",
"{",
"result",
"=",
"0.0",
";",
"}",
"else",
"{",
"double",
"sum",
"=",
"0.0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"limit",
";",
"i",
"++",
")",
"{",
"sum",
"+=",
"listOfDistances",
".",
"get",
"(",
"i",
")",
";",
"}",
"result",
"=",
"sum",
"/",
"limit",
";",
"}",
"return",
"result",
";",
"}"
] | Computes the knn distance. If the solution list size is lower than k, then k = size in the computation
@param solution
@param solutionList
@return | [
"Computes",
"the",
"knn",
"distance",
".",
"If",
"the",
"solution",
"list",
"size",
"is",
"lower",
"than",
"k",
"then",
"k",
"=",
"size",
"in",
"the",
"computation"
] | train | https://github.com/jMetal/jMetal/blob/bc981e6aede275d26c5216c9a01227d9675b0cf7/jmetal-core/src/main/java/org/uma/jmetal/util/distance/impl/DistanceBetweenSolutionAndKNearestNeighbors.java#L37-L55 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/PageContentHelper.java | PageContentHelper.addAllHeadlines | public static void addAllHeadlines(final PrintWriter writer, final Headers headers) {
"""
Shortcut method for adding all the headline entries stored in the WHeaders.
@param writer the writer to write to.
@param headers contains all the headline entries.
"""
PageContentHelper.addHeadlines(writer, headers.getHeadLines());
PageContentHelper.addJsHeadlines(writer, headers.getHeadLines(Headers.JAVASCRIPT_HEADLINE));
PageContentHelper.addCssHeadlines(writer, headers.getHeadLines(Headers.CSS_HEADLINE));
} | java | public static void addAllHeadlines(final PrintWriter writer, final Headers headers) {
PageContentHelper.addHeadlines(writer, headers.getHeadLines());
PageContentHelper.addJsHeadlines(writer, headers.getHeadLines(Headers.JAVASCRIPT_HEADLINE));
PageContentHelper.addCssHeadlines(writer, headers.getHeadLines(Headers.CSS_HEADLINE));
} | [
"public",
"static",
"void",
"addAllHeadlines",
"(",
"final",
"PrintWriter",
"writer",
",",
"final",
"Headers",
"headers",
")",
"{",
"PageContentHelper",
".",
"addHeadlines",
"(",
"writer",
",",
"headers",
".",
"getHeadLines",
"(",
")",
")",
";",
"PageContentHelper",
".",
"addJsHeadlines",
"(",
"writer",
",",
"headers",
".",
"getHeadLines",
"(",
"Headers",
".",
"JAVASCRIPT_HEADLINE",
")",
")",
";",
"PageContentHelper",
".",
"addCssHeadlines",
"(",
"writer",
",",
"headers",
".",
"getHeadLines",
"(",
"Headers",
".",
"CSS_HEADLINE",
")",
")",
";",
"}"
] | Shortcut method for adding all the headline entries stored in the WHeaders.
@param writer the writer to write to.
@param headers contains all the headline entries. | [
"Shortcut",
"method",
"for",
"adding",
"all",
"the",
"headline",
"entries",
"stored",
"in",
"the",
"WHeaders",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/PageContentHelper.java#L33-L37 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/StringUtils.java | StringUtils.printToFile | public static void printToFile(String filename, String message) {
"""
Prints to a file. If the file does not exist, rewrites the file;
does not append.
"""
printToFile(new File(filename), message, false);
} | java | public static void printToFile(String filename, String message) {
printToFile(new File(filename), message, false);
} | [
"public",
"static",
"void",
"printToFile",
"(",
"String",
"filename",
",",
"String",
"message",
")",
"{",
"printToFile",
"(",
"new",
"File",
"(",
"filename",
")",
",",
"message",
",",
"false",
")",
";",
"}"
] | Prints to a file. If the file does not exist, rewrites the file;
does not append. | [
"Prints",
"to",
"a",
"file",
".",
"If",
"the",
"file",
"does",
"not",
"exist",
"rewrites",
"the",
"file",
";",
"does",
"not",
"append",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/StringUtils.java#L977-L979 |
kohsuke/com4j | runtime/src/main/java/com4j/COM4J.java | COM4J.getActiveObject | public static <T extends Com4jObject> T getActiveObject(Class<T> primaryInterface, String clsid ) {
"""
Gets an already object from the running object table.
@param <T> the type of the return value and the type parameter of the class object of primaryInterface
@param primaryInterface The returned COM object is returned as this interface.
Must be non-null. Passing in {@link Com4jObject} allows
the caller to create a new instance without knowing
its primary interface.
@param clsid The CLSID of the COM object to be retrieved, in the
"<tt>{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}</tt>" format,
or the ProgID of the object (like "Microsoft.XMLParser.1.0")
@return non-null valid object.
@throws ComException if the retrieval fails.
@see #getActiveObject(Class,GUID)
"""
return getActiveObject(primaryInterface,new GUID(clsid));
} | java | public static <T extends Com4jObject> T getActiveObject(Class<T> primaryInterface, String clsid ) {
return getActiveObject(primaryInterface,new GUID(clsid));
} | [
"public",
"static",
"<",
"T",
"extends",
"Com4jObject",
">",
"T",
"getActiveObject",
"(",
"Class",
"<",
"T",
">",
"primaryInterface",
",",
"String",
"clsid",
")",
"{",
"return",
"getActiveObject",
"(",
"primaryInterface",
",",
"new",
"GUID",
"(",
"clsid",
")",
")",
";",
"}"
] | Gets an already object from the running object table.
@param <T> the type of the return value and the type parameter of the class object of primaryInterface
@param primaryInterface The returned COM object is returned as this interface.
Must be non-null. Passing in {@link Com4jObject} allows
the caller to create a new instance without knowing
its primary interface.
@param clsid The CLSID of the COM object to be retrieved, in the
"<tt>{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}</tt>" format,
or the ProgID of the object (like "Microsoft.XMLParser.1.0")
@return non-null valid object.
@throws ComException if the retrieval fails.
@see #getActiveObject(Class,GUID) | [
"Gets",
"an",
"already",
"object",
"from",
"the",
"running",
"object",
"table",
"."
] | train | https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/COM4J.java#L185-L187 |
molgenis/molgenis | molgenis-one-click-importer/src/main/java/org/molgenis/oneclickimporter/service/impl/CsvServiceImpl.java | CsvServiceImpl.validateCsvFile | private void validateCsvFile(List<String[]> content, String fileName) {
"""
Validates CSV file content.
<p>Checks that the content is not empty. Checks that at least one data row is present. Checks
that data row lengths are consistent with the header row length.
@param content content of CSV-file
@param fileName the name of the file that is validated
@throws MolgenisDataException if the validation fails
"""
if (content.isEmpty()) {
throw new MolgenisDataException(format("CSV-file: [{0}] is empty", fileName));
}
if (content.size() == 1) {
throw new MolgenisDataException(
format("Header was found, but no data is present in file [{0}]", fileName));
}
int headerLength = content.get(0).length;
content.forEach(
row -> {
if (row.length != headerLength) {
throw new MolgenisDataException(
format("Column count in CSV-file: [{0}] is not consistent", fileName));
}
});
} | java | private void validateCsvFile(List<String[]> content, String fileName) {
if (content.isEmpty()) {
throw new MolgenisDataException(format("CSV-file: [{0}] is empty", fileName));
}
if (content.size() == 1) {
throw new MolgenisDataException(
format("Header was found, but no data is present in file [{0}]", fileName));
}
int headerLength = content.get(0).length;
content.forEach(
row -> {
if (row.length != headerLength) {
throw new MolgenisDataException(
format("Column count in CSV-file: [{0}] is not consistent", fileName));
}
});
} | [
"private",
"void",
"validateCsvFile",
"(",
"List",
"<",
"String",
"[",
"]",
">",
"content",
",",
"String",
"fileName",
")",
"{",
"if",
"(",
"content",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"MolgenisDataException",
"(",
"format",
"(",
"\"CSV-file: [{0}] is empty\"",
",",
"fileName",
")",
")",
";",
"}",
"if",
"(",
"content",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"throw",
"new",
"MolgenisDataException",
"(",
"format",
"(",
"\"Header was found, but no data is present in file [{0}]\"",
",",
"fileName",
")",
")",
";",
"}",
"int",
"headerLength",
"=",
"content",
".",
"get",
"(",
"0",
")",
".",
"length",
";",
"content",
".",
"forEach",
"(",
"row",
"->",
"{",
"if",
"(",
"row",
".",
"length",
"!=",
"headerLength",
")",
"{",
"throw",
"new",
"MolgenisDataException",
"(",
"format",
"(",
"\"Column count in CSV-file: [{0}] is not consistent\"",
",",
"fileName",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Validates CSV file content.
<p>Checks that the content is not empty. Checks that at least one data row is present. Checks
that data row lengths are consistent with the header row length.
@param content content of CSV-file
@param fileName the name of the file that is validated
@throws MolgenisDataException if the validation fails | [
"Validates",
"CSV",
"file",
"content",
"."
] | train | https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-one-click-importer/src/main/java/org/molgenis/oneclickimporter/service/impl/CsvServiceImpl.java#L69-L87 |
sarl/sarl | main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/markdown/MarkdownParser.java | MarkdownParser.transformURLAnchor | @SuppressWarnings("static-method")
protected String transformURLAnchor(File file, String anchor, ReferenceContext references) {
"""
Transform the anchor of an URL from Markdown format to HTML format.
@param file the linked file.
@param anchor the anchor to transform.
@param references the set of references from the local document, or {@code null}.
@return the result of the transformation.
@since 0.7
"""
String anc = anchor;
if (references != null) {
anc = references.validateAnchor(anc);
}
return anc;
} | java | @SuppressWarnings("static-method")
protected String transformURLAnchor(File file, String anchor, ReferenceContext references) {
String anc = anchor;
if (references != null) {
anc = references.validateAnchor(anc);
}
return anc;
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"protected",
"String",
"transformURLAnchor",
"(",
"File",
"file",
",",
"String",
"anchor",
",",
"ReferenceContext",
"references",
")",
"{",
"String",
"anc",
"=",
"anchor",
";",
"if",
"(",
"references",
"!=",
"null",
")",
"{",
"anc",
"=",
"references",
".",
"validateAnchor",
"(",
"anc",
")",
";",
"}",
"return",
"anc",
";",
"}"
] | Transform the anchor of an URL from Markdown format to HTML format.
@param file the linked file.
@param anchor the anchor to transform.
@param references the set of references from the local document, or {@code null}.
@return the result of the transformation.
@since 0.7 | [
"Transform",
"the",
"anchor",
"of",
"an",
"URL",
"from",
"Markdown",
"format",
"to",
"HTML",
"format",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/markdown/MarkdownParser.java#L719-L726 |
apache/flink | flink-core/src/main/java/org/apache/flink/types/parser/BigDecParser.java | BigDecParser.parseField | public static final BigDecimal parseField(byte[] bytes, int startPos, int length, char delimiter) {
"""
Static utility to parse a field of type BigDecimal from a byte sequence that represents text
characters
(such as when read from a file stream).
@param bytes The bytes containing the text data that should be parsed.
@param startPos The offset to start the parsing.
@param length The length of the byte sequence (counting from the offset).
@param delimiter The delimiter that terminates the field.
@return The parsed value.
@throws IllegalArgumentException Thrown when the value cannot be parsed because the text
represents not a correct number.
"""
if (length <= 0) {
throw new NumberFormatException("Invalid input: Empty string");
}
int i = 0;
final byte delByte = (byte) delimiter;
while (i < length && bytes[startPos + i] != delByte) {
i++;
}
if (i > 0 &&
(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[startPos + i - 1]))) {
throw new NumberFormatException("There is leading or trailing whitespace in the numeric field.");
}
final char[] chars = new char[i];
for (int j = 0; j < i; j++) {
final byte b = bytes[startPos + j];
if ((b < '0' || b > '9') && b != '-' && b != '+' && b != '.' && b != 'E' && b != 'e') {
throw new NumberFormatException();
}
chars[j] = (char) bytes[startPos + j];
}
return new BigDecimal(chars);
} | java | public static final BigDecimal parseField(byte[] bytes, int startPos, int length, char delimiter) {
if (length <= 0) {
throw new NumberFormatException("Invalid input: Empty string");
}
int i = 0;
final byte delByte = (byte) delimiter;
while (i < length && bytes[startPos + i] != delByte) {
i++;
}
if (i > 0 &&
(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[startPos + i - 1]))) {
throw new NumberFormatException("There is leading or trailing whitespace in the numeric field.");
}
final char[] chars = new char[i];
for (int j = 0; j < i; j++) {
final byte b = bytes[startPos + j];
if ((b < '0' || b > '9') && b != '-' && b != '+' && b != '.' && b != 'E' && b != 'e') {
throw new NumberFormatException();
}
chars[j] = (char) bytes[startPos + j];
}
return new BigDecimal(chars);
} | [
"public",
"static",
"final",
"BigDecimal",
"parseField",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"startPos",
",",
"int",
"length",
",",
"char",
"delimiter",
")",
"{",
"if",
"(",
"length",
"<=",
"0",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"\"Invalid input: Empty string\"",
")",
";",
"}",
"int",
"i",
"=",
"0",
";",
"final",
"byte",
"delByte",
"=",
"(",
"byte",
")",
"delimiter",
";",
"while",
"(",
"i",
"<",
"length",
"&&",
"bytes",
"[",
"startPos",
"+",
"i",
"]",
"!=",
"delByte",
")",
"{",
"i",
"++",
";",
"}",
"if",
"(",
"i",
">",
"0",
"&&",
"(",
"Character",
".",
"isWhitespace",
"(",
"bytes",
"[",
"startPos",
"]",
")",
"||",
"Character",
".",
"isWhitespace",
"(",
"bytes",
"[",
"startPos",
"+",
"i",
"-",
"1",
"]",
")",
")",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
"\"There is leading or trailing whitespace in the numeric field.\"",
")",
";",
"}",
"final",
"char",
"[",
"]",
"chars",
"=",
"new",
"char",
"[",
"i",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"i",
";",
"j",
"++",
")",
"{",
"final",
"byte",
"b",
"=",
"bytes",
"[",
"startPos",
"+",
"j",
"]",
";",
"if",
"(",
"(",
"b",
"<",
"'",
"'",
"||",
"b",
">",
"'",
"'",
")",
"&&",
"b",
"!=",
"'",
"'",
"&&",
"b",
"!=",
"'",
"'",
"&&",
"b",
"!=",
"'",
"'",
"&&",
"b",
"!=",
"'",
"'",
"&&",
"b",
"!=",
"'",
"'",
")",
"{",
"throw",
"new",
"NumberFormatException",
"(",
")",
";",
"}",
"chars",
"[",
"j",
"]",
"=",
"(",
"char",
")",
"bytes",
"[",
"startPos",
"+",
"j",
"]",
";",
"}",
"return",
"new",
"BigDecimal",
"(",
"chars",
")",
";",
"}"
] | Static utility to parse a field of type BigDecimal from a byte sequence that represents text
characters
(such as when read from a file stream).
@param bytes The bytes containing the text data that should be parsed.
@param startPos The offset to start the parsing.
@param length The length of the byte sequence (counting from the offset).
@param delimiter The delimiter that terminates the field.
@return The parsed value.
@throws IllegalArgumentException Thrown when the value cannot be parsed because the text
represents not a correct number. | [
"Static",
"utility",
"to",
"parse",
"a",
"field",
"of",
"type",
"BigDecimal",
"from",
"a",
"byte",
"sequence",
"that",
"represents",
"text",
"characters",
"(",
"such",
"as",
"when",
"read",
"from",
"a",
"file",
"stream",
")",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/types/parser/BigDecParser.java#L104-L129 |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspImageBean.java | CmsJspImageBean.checkCropRegionContainsFocalPoint | private static boolean checkCropRegionContainsFocalPoint(CmsImageScaler scaler, CmsPoint focalPoint) {
"""
Helper method to check whether the focal point in the scaler is contained in the scaler's crop region.<p>
If the scaler has no crop region, true is returned.
@param scaler the scaler
@param focalPoint the focal point to check
@return true if the scaler's crop region contains the focal point
"""
if (!scaler.isCropping()) {
return true;
}
double x = focalPoint.getX();
double y = focalPoint.getY();
return (scaler.getCropX() <= x)
&& (x < (scaler.getCropX() + scaler.getCropWidth()))
&& (scaler.getCropY() <= y)
&& (y < (scaler.getCropY() + scaler.getCropHeight()));
} | java | private static boolean checkCropRegionContainsFocalPoint(CmsImageScaler scaler, CmsPoint focalPoint) {
if (!scaler.isCropping()) {
return true;
}
double x = focalPoint.getX();
double y = focalPoint.getY();
return (scaler.getCropX() <= x)
&& (x < (scaler.getCropX() + scaler.getCropWidth()))
&& (scaler.getCropY() <= y)
&& (y < (scaler.getCropY() + scaler.getCropHeight()));
} | [
"private",
"static",
"boolean",
"checkCropRegionContainsFocalPoint",
"(",
"CmsImageScaler",
"scaler",
",",
"CmsPoint",
"focalPoint",
")",
"{",
"if",
"(",
"!",
"scaler",
".",
"isCropping",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"double",
"x",
"=",
"focalPoint",
".",
"getX",
"(",
")",
";",
"double",
"y",
"=",
"focalPoint",
".",
"getY",
"(",
")",
";",
"return",
"(",
"scaler",
".",
"getCropX",
"(",
")",
"<=",
"x",
")",
"&&",
"(",
"x",
"<",
"(",
"scaler",
".",
"getCropX",
"(",
")",
"+",
"scaler",
".",
"getCropWidth",
"(",
")",
")",
")",
"&&",
"(",
"scaler",
".",
"getCropY",
"(",
")",
"<=",
"y",
")",
"&&",
"(",
"y",
"<",
"(",
"scaler",
".",
"getCropY",
"(",
")",
"+",
"scaler",
".",
"getCropHeight",
"(",
")",
")",
")",
";",
"}"
] | Helper method to check whether the focal point in the scaler is contained in the scaler's crop region.<p>
If the scaler has no crop region, true is returned.
@param scaler the scaler
@param focalPoint the focal point to check
@return true if the scaler's crop region contains the focal point | [
"Helper",
"method",
"to",
"check",
"whether",
"the",
"focal",
"point",
"in",
"the",
"scaler",
"is",
"contained",
"in",
"the",
"scaler",
"s",
"crop",
"region",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspImageBean.java#L344-L355 |
sarl/sarl | main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/extralanguage/preferences/ExtraLanguagePreferenceAccess.java | ExtraLanguagePreferenceAccess.getString | public String getString(String preferenceContainerID, IProject project, String preferenceName) {
"""
Replies the preference value.
<p>This function takes care of the specific options that are associated to the given project.
If the given project is {@code null} or has no specific options, according to
{@link #ifSpecificConfiguration(String, IProject)}, then the global preferences are used.
@param preferenceContainerID the identifier of the generator's preference container.
@param project the context. If {@code null}, the global context is assumed.
@param preferenceName the name of the preference.
@return the value.
@since 0.8
"""
final IProject prj = ifSpecificConfiguration(preferenceContainerID, project);
final IPreferenceStore store = getPreferenceStore(prj);
return getString(store, preferenceContainerID, preferenceName);
} | java | public String getString(String preferenceContainerID, IProject project, String preferenceName) {
final IProject prj = ifSpecificConfiguration(preferenceContainerID, project);
final IPreferenceStore store = getPreferenceStore(prj);
return getString(store, preferenceContainerID, preferenceName);
} | [
"public",
"String",
"getString",
"(",
"String",
"preferenceContainerID",
",",
"IProject",
"project",
",",
"String",
"preferenceName",
")",
"{",
"final",
"IProject",
"prj",
"=",
"ifSpecificConfiguration",
"(",
"preferenceContainerID",
",",
"project",
")",
";",
"final",
"IPreferenceStore",
"store",
"=",
"getPreferenceStore",
"(",
"prj",
")",
";",
"return",
"getString",
"(",
"store",
",",
"preferenceContainerID",
",",
"preferenceName",
")",
";",
"}"
] | Replies the preference value.
<p>This function takes care of the specific options that are associated to the given project.
If the given project is {@code null} or has no specific options, according to
{@link #ifSpecificConfiguration(String, IProject)}, then the global preferences are used.
@param preferenceContainerID the identifier of the generator's preference container.
@param project the context. If {@code null}, the global context is assumed.
@param preferenceName the name of the preference.
@return the value.
@since 0.8 | [
"Replies",
"the",
"preference",
"value",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/extralanguage/preferences/ExtraLanguagePreferenceAccess.java#L138-L142 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/Channel.java | Channel.sendInstantiationProposal | public Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest,
Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
"""
Send instantiate request to the channel. Chaincode is created and initialized.
@param instantiateProposalRequest
@param peers
@return responses from peers.
@throws InvalidArgumentException
@throws ProposalException
@deprecated See new lifecycle chaincode management. {@link LifecycleInstallChaincodeRequest}
"""
checkChannelState();
if (null == instantiateProposalRequest) {
throw new InvalidArgumentException("InstantiateProposalRequest is null");
}
instantiateProposalRequest.setSubmitted();
checkPeers(peers);
try {
TransactionContext transactionContext = getTransactionContext(instantiateProposalRequest.getUserContext());
transactionContext.setProposalWaitTime(instantiateProposalRequest.getProposalWaitTime());
InstantiateProposalBuilder instantiateProposalbuilder = InstantiateProposalBuilder.newBuilder();
instantiateProposalbuilder.context(transactionContext);
instantiateProposalbuilder.argss(instantiateProposalRequest.getArgs());
instantiateProposalbuilder.chaincodeName(instantiateProposalRequest.getChaincodeName());
instantiateProposalbuilder.chaincodeType(instantiateProposalRequest.getChaincodeLanguage());
instantiateProposalbuilder.chaincodePath(instantiateProposalRequest.getChaincodePath());
instantiateProposalbuilder.chaincodeVersion(instantiateProposalRequest.getChaincodeVersion());
instantiateProposalbuilder.chaincodEndorsementPolicy(instantiateProposalRequest.getChaincodeEndorsementPolicy());
instantiateProposalbuilder.chaincodeCollectionConfiguration(instantiateProposalRequest.getChaincodeCollectionConfiguration());
instantiateProposalbuilder.setTransientMap(instantiateProposalRequest.getTransientMap());
FabricProposal.Proposal instantiateProposal = instantiateProposalbuilder.build();
SignedProposal signedProposal = getSignedProposal(transactionContext, instantiateProposal);
return sendProposalToPeers(peers, signedProposal, transactionContext);
} catch (Exception e) {
throw new ProposalException(e);
}
} | java | public Collection<ProposalResponse> sendInstantiationProposal(InstantiateProposalRequest instantiateProposalRequest,
Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
checkChannelState();
if (null == instantiateProposalRequest) {
throw new InvalidArgumentException("InstantiateProposalRequest is null");
}
instantiateProposalRequest.setSubmitted();
checkPeers(peers);
try {
TransactionContext transactionContext = getTransactionContext(instantiateProposalRequest.getUserContext());
transactionContext.setProposalWaitTime(instantiateProposalRequest.getProposalWaitTime());
InstantiateProposalBuilder instantiateProposalbuilder = InstantiateProposalBuilder.newBuilder();
instantiateProposalbuilder.context(transactionContext);
instantiateProposalbuilder.argss(instantiateProposalRequest.getArgs());
instantiateProposalbuilder.chaincodeName(instantiateProposalRequest.getChaincodeName());
instantiateProposalbuilder.chaincodeType(instantiateProposalRequest.getChaincodeLanguage());
instantiateProposalbuilder.chaincodePath(instantiateProposalRequest.getChaincodePath());
instantiateProposalbuilder.chaincodeVersion(instantiateProposalRequest.getChaincodeVersion());
instantiateProposalbuilder.chaincodEndorsementPolicy(instantiateProposalRequest.getChaincodeEndorsementPolicy());
instantiateProposalbuilder.chaincodeCollectionConfiguration(instantiateProposalRequest.getChaincodeCollectionConfiguration());
instantiateProposalbuilder.setTransientMap(instantiateProposalRequest.getTransientMap());
FabricProposal.Proposal instantiateProposal = instantiateProposalbuilder.build();
SignedProposal signedProposal = getSignedProposal(transactionContext, instantiateProposal);
return sendProposalToPeers(peers, signedProposal, transactionContext);
} catch (Exception e) {
throw new ProposalException(e);
}
} | [
"public",
"Collection",
"<",
"ProposalResponse",
">",
"sendInstantiationProposal",
"(",
"InstantiateProposalRequest",
"instantiateProposalRequest",
",",
"Collection",
"<",
"Peer",
">",
"peers",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"checkChannelState",
"(",
")",
";",
"if",
"(",
"null",
"==",
"instantiateProposalRequest",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"InstantiateProposalRequest is null\"",
")",
";",
"}",
"instantiateProposalRequest",
".",
"setSubmitted",
"(",
")",
";",
"checkPeers",
"(",
"peers",
")",
";",
"try",
"{",
"TransactionContext",
"transactionContext",
"=",
"getTransactionContext",
"(",
"instantiateProposalRequest",
".",
"getUserContext",
"(",
")",
")",
";",
"transactionContext",
".",
"setProposalWaitTime",
"(",
"instantiateProposalRequest",
".",
"getProposalWaitTime",
"(",
")",
")",
";",
"InstantiateProposalBuilder",
"instantiateProposalbuilder",
"=",
"InstantiateProposalBuilder",
".",
"newBuilder",
"(",
")",
";",
"instantiateProposalbuilder",
".",
"context",
"(",
"transactionContext",
")",
";",
"instantiateProposalbuilder",
".",
"argss",
"(",
"instantiateProposalRequest",
".",
"getArgs",
"(",
")",
")",
";",
"instantiateProposalbuilder",
".",
"chaincodeName",
"(",
"instantiateProposalRequest",
".",
"getChaincodeName",
"(",
")",
")",
";",
"instantiateProposalbuilder",
".",
"chaincodeType",
"(",
"instantiateProposalRequest",
".",
"getChaincodeLanguage",
"(",
")",
")",
";",
"instantiateProposalbuilder",
".",
"chaincodePath",
"(",
"instantiateProposalRequest",
".",
"getChaincodePath",
"(",
")",
")",
";",
"instantiateProposalbuilder",
".",
"chaincodeVersion",
"(",
"instantiateProposalRequest",
".",
"getChaincodeVersion",
"(",
")",
")",
";",
"instantiateProposalbuilder",
".",
"chaincodEndorsementPolicy",
"(",
"instantiateProposalRequest",
".",
"getChaincodeEndorsementPolicy",
"(",
")",
")",
";",
"instantiateProposalbuilder",
".",
"chaincodeCollectionConfiguration",
"(",
"instantiateProposalRequest",
".",
"getChaincodeCollectionConfiguration",
"(",
")",
")",
";",
"instantiateProposalbuilder",
".",
"setTransientMap",
"(",
"instantiateProposalRequest",
".",
"getTransientMap",
"(",
")",
")",
";",
"FabricProposal",
".",
"Proposal",
"instantiateProposal",
"=",
"instantiateProposalbuilder",
".",
"build",
"(",
")",
";",
"SignedProposal",
"signedProposal",
"=",
"getSignedProposal",
"(",
"transactionContext",
",",
"instantiateProposal",
")",
";",
"return",
"sendProposalToPeers",
"(",
"peers",
",",
"signedProposal",
",",
"transactionContext",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"e",
")",
";",
"}",
"}"
] | Send instantiate request to the channel. Chaincode is created and initialized.
@param instantiateProposalRequest
@param peers
@return responses from peers.
@throws InvalidArgumentException
@throws ProposalException
@deprecated See new lifecycle chaincode management. {@link LifecycleInstallChaincodeRequest} | [
"Send",
"instantiate",
"request",
"to",
"the",
"channel",
".",
"Chaincode",
"is",
"created",
"and",
"initialized",
"."
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2445-L2477 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/JobOperations.java | JobOperations.deleteJob | public void deleteJob(String jobId, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
"""
Deletes the specified job.
@param jobId The ID of the job.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
"""
JobDeleteOptions options = new JobDeleteOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
this.parentBatchClient.protocolLayer().jobs().delete(jobId, options);
} | java | public void deleteJob(String jobId, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
JobDeleteOptions options = new JobDeleteOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
this.parentBatchClient.protocolLayer().jobs().delete(jobId, options);
} | [
"public",
"void",
"deleteJob",
"(",
"String",
"jobId",
",",
"Iterable",
"<",
"BatchClientBehavior",
">",
"additionalBehaviors",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"JobDeleteOptions",
"options",
"=",
"new",
"JobDeleteOptions",
"(",
")",
";",
"BehaviorManager",
"bhMgr",
"=",
"new",
"BehaviorManager",
"(",
"this",
".",
"customBehaviors",
"(",
")",
",",
"additionalBehaviors",
")",
";",
"bhMgr",
".",
"applyRequestBehaviors",
"(",
"options",
")",
";",
"this",
".",
"parentBatchClient",
".",
"protocolLayer",
"(",
")",
".",
"jobs",
"(",
")",
".",
"delete",
"(",
"jobId",
",",
"options",
")",
";",
"}"
] | Deletes the specified job.
@param jobId The ID of the job.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. | [
"Deletes",
"the",
"specified",
"job",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/JobOperations.java#L343-L349 |
awslabs/amazon-sqs-java-messaging-lib | src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java | SQSMessage.setStringProperty | @Override
public void setStringProperty(String name, String value) throws JMSException {
"""
Sets a <code>String</code> property value with the specified name into
the message.
@param name
The name of the property to set.
@param value
The <code>String</code> value of the property to set.
@throws JMSException
On internal error.
@throws IllegalArgumentException
If the name or value is null or empty string.
@throws MessageNotWriteableException
If properties are read-only.
"""
setObjectProperty(name, value);
} | java | @Override
public void setStringProperty(String name, String value) throws JMSException {
setObjectProperty(name, value);
} | [
"@",
"Override",
"public",
"void",
"setStringProperty",
"(",
"String",
"name",
",",
"String",
"value",
")",
"throws",
"JMSException",
"{",
"setObjectProperty",
"(",
"name",
",",
"value",
")",
";",
"}"
] | Sets a <code>String</code> property value with the specified name into
the message.
@param name
The name of the property to set.
@param value
The <code>String</code> value of the property to set.
@throws JMSException
On internal error.
@throws IllegalArgumentException
If the name or value is null or empty string.
@throws MessageNotWriteableException
If properties are read-only. | [
"Sets",
"a",
"<code",
">",
"String<",
"/",
"code",
">",
"property",
"value",
"with",
"the",
"specified",
"name",
"into",
"the",
"message",
"."
] | train | https://github.com/awslabs/amazon-sqs-java-messaging-lib/blob/efa716d34d51ef1c5572790626cdb795419cb342/src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java#L877-L880 |
rterp/GMapsFX | GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptRuntime.java | JavascriptRuntime.getFunction | @Override
public String getFunction(String function, Object... args) {
"""
Gets a function as a String, which then can be passed to the execute()
method.
@param function The function to invoke
@param args Arguments the function requires
@return A string which can be passed to the JavaScript environment to
invoke the function
"""
if (args == null) {
return function + "();";
}
StringBuilder sb = new StringBuilder();
sb.append(function).append("(");
for (Object arg : args) {
sb.append(getArgString(arg)).append(",");
}
sb.replace(sb.length() - 1, sb.length(), ")");
return sb.toString();
} | java | @Override
public String getFunction(String function, Object... args) {
if (args == null) {
return function + "();";
}
StringBuilder sb = new StringBuilder();
sb.append(function).append("(");
for (Object arg : args) {
sb.append(getArgString(arg)).append(",");
}
sb.replace(sb.length() - 1, sb.length(), ")");
return sb.toString();
} | [
"@",
"Override",
"public",
"String",
"getFunction",
"(",
"String",
"function",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"args",
"==",
"null",
")",
"{",
"return",
"function",
"+",
"\"();\"",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"function",
")",
".",
"append",
"(",
"\"(\"",
")",
";",
"for",
"(",
"Object",
"arg",
":",
"args",
")",
"{",
"sb",
".",
"append",
"(",
"getArgString",
"(",
"arg",
")",
")",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"sb",
".",
"replace",
"(",
"sb",
".",
"length",
"(",
")",
"-",
"1",
",",
"sb",
".",
"length",
"(",
")",
",",
"\")\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Gets a function as a String, which then can be passed to the execute()
method.
@param function The function to invoke
@param args Arguments the function requires
@return A string which can be passed to the JavaScript environment to
invoke the function | [
"Gets",
"a",
"function",
"as",
"a",
"String",
"which",
"then",
"can",
"be",
"passed",
"to",
"the",
"execute",
"()",
"method",
"."
] | train | https://github.com/rterp/GMapsFX/blob/4623d3f768e8ad78fc50ee32dd204d236e01059f/GMapsFX/src/main/java/com/lynden/gmapsfx/javascript/JavascriptRuntime.java#L123-L136 |
santhosh-tekuri/jlibs | swing/src/main/java/jlibs/swing/SwingUtil.java | SwingUtil.setInitialFocus | public static void setInitialFocus(Window window, final Component comp) {
"""
sets intial focus in window to the specified component
@param window window on which focus has to be set
@param comp component which need to have initial focus
"""
window.addWindowFocusListener(new WindowAdapter(){
@Override
public void windowGainedFocus(WindowEvent we){
comp.requestFocusInWindow();
we.getWindow().removeWindowFocusListener(this);
}
});
} | java | public static void setInitialFocus(Window window, final Component comp){
window.addWindowFocusListener(new WindowAdapter(){
@Override
public void windowGainedFocus(WindowEvent we){
comp.requestFocusInWindow();
we.getWindow().removeWindowFocusListener(this);
}
});
} | [
"public",
"static",
"void",
"setInitialFocus",
"(",
"Window",
"window",
",",
"final",
"Component",
"comp",
")",
"{",
"window",
".",
"addWindowFocusListener",
"(",
"new",
"WindowAdapter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"windowGainedFocus",
"(",
"WindowEvent",
"we",
")",
"{",
"comp",
".",
"requestFocusInWindow",
"(",
")",
";",
"we",
".",
"getWindow",
"(",
")",
".",
"removeWindowFocusListener",
"(",
"this",
")",
";",
"}",
"}",
")",
";",
"}"
] | sets intial focus in window to the specified component
@param window window on which focus has to be set
@param comp component which need to have initial focus | [
"sets",
"intial",
"focus",
"in",
"window",
"to",
"the",
"specified",
"component"
] | train | https://github.com/santhosh-tekuri/jlibs/blob/59c28719f054123cf778278154e1b92e943ad232/swing/src/main/java/jlibs/swing/SwingUtil.java#L40-L48 |
molgenis/molgenis | molgenis-data/src/main/java/org/molgenis/data/meta/model/Attribute.java | Attribute.getRange | public Range getRange() {
"""
For int and long fields, the value must be between min and max (included) of the range
@return attribute value range
"""
Long rangeMin = getRangeMin();
Long rangeMax = getRangeMax();
return rangeMin != null || rangeMax != null ? new Range(rangeMin, rangeMax) : null;
} | java | public Range getRange() {
Long rangeMin = getRangeMin();
Long rangeMax = getRangeMax();
return rangeMin != null || rangeMax != null ? new Range(rangeMin, rangeMax) : null;
} | [
"public",
"Range",
"getRange",
"(",
")",
"{",
"Long",
"rangeMin",
"=",
"getRangeMin",
"(",
")",
";",
"Long",
"rangeMax",
"=",
"getRangeMax",
"(",
")",
";",
"return",
"rangeMin",
"!=",
"null",
"||",
"rangeMax",
"!=",
"null",
"?",
"new",
"Range",
"(",
"rangeMin",
",",
"rangeMax",
")",
":",
"null",
";",
"}"
] | For int and long fields, the value must be between min and max (included) of the range
@return attribute value range | [
"For",
"int",
"and",
"long",
"fields",
"the",
"value",
"must",
"be",
"between",
"min",
"and",
"max",
"(",
"included",
")",
"of",
"the",
"range"
] | train | https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-data/src/main/java/org/molgenis/data/meta/model/Attribute.java#L609-L613 |
alkacon/opencms-core | src-gwt/org/opencms/acacia/client/widgets/CmsDisplayTypeSelectWidget.java | CmsDisplayTypeSelectWidget.replaceItems | private void replaceItems(Map<String, String> items) {
"""
Replaces the select items with the given items.<p>
@param items the select items
"""
String oldValue = m_selectBox.getFormValueAsString();
//set value and option to the combo box.
m_selectBox.setItems(items);
if (items.containsKey(oldValue)) {
m_selectBox.setFormValueAsString(oldValue);
}
} | java | private void replaceItems(Map<String, String> items) {
String oldValue = m_selectBox.getFormValueAsString();
//set value and option to the combo box.
m_selectBox.setItems(items);
if (items.containsKey(oldValue)) {
m_selectBox.setFormValueAsString(oldValue);
}
} | [
"private",
"void",
"replaceItems",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"items",
")",
"{",
"String",
"oldValue",
"=",
"m_selectBox",
".",
"getFormValueAsString",
"(",
")",
";",
"//set value and option to the combo box.",
"m_selectBox",
".",
"setItems",
"(",
"items",
")",
";",
"if",
"(",
"items",
".",
"containsKey",
"(",
"oldValue",
")",
")",
"{",
"m_selectBox",
".",
"setFormValueAsString",
"(",
"oldValue",
")",
";",
"}",
"}"
] | Replaces the select items with the given items.<p>
@param items the select items | [
"Replaces",
"the",
"select",
"items",
"with",
"the",
"given",
"items",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/widgets/CmsDisplayTypeSelectWidget.java#L307-L315 |
pravega/pravega | controller/src/main/java/io/pravega/controller/task/Stream/StreamTransactionMetadataTasks.java | StreamTransactionMetadataTasks.pingTxnBody | CompletableFuture<PingTxnStatus> pingTxnBody(final String scope,
final String stream,
final UUID txnId,
final long lease,
final OperationContext ctx) {
"""
Ping a txn thereby updating its timeout to current time + lease.
Post-condition:
1. If ping request completes successfully, then
(a) txn timeout is set to lease + current time in timeout service,
(b) txn version in timeout service equals version of txn node in store,
(c) if txn's timeout was not previously tracked in timeout service of current process,
then version of txn node in store is updated, thus fencing out other processes tracking timeout for this txn,
(d) txn is present in the host-txn index of current host,
2. If process fails before responding to the client, then since txn is present in the host-txn index,
some other controller process shall abort the txn after maxLeaseValue
Store read/update operation is not invoked on receiving ping request for a txn that is being tracked in the
timeout service. Otherwise, if the txn is not being tracked in the timeout service, txn node is read from
the store and updated.
@param scope scope name.
@param stream stream name.
@param txnId txn id.
@param lease txn lease.
@param ctx context.
@return ping status.
"""
if (!timeoutService.isRunning()) {
return CompletableFuture.completedFuture(createStatus(Status.DISCONNECTED));
}
log.debug("Txn={}, updating txn node in store and extending lease", txnId);
return fenceTxnUpdateLease(scope, stream, txnId, lease, ctx);
} | java | CompletableFuture<PingTxnStatus> pingTxnBody(final String scope,
final String stream,
final UUID txnId,
final long lease,
final OperationContext ctx) {
if (!timeoutService.isRunning()) {
return CompletableFuture.completedFuture(createStatus(Status.DISCONNECTED));
}
log.debug("Txn={}, updating txn node in store and extending lease", txnId);
return fenceTxnUpdateLease(scope, stream, txnId, lease, ctx);
} | [
"CompletableFuture",
"<",
"PingTxnStatus",
">",
"pingTxnBody",
"(",
"final",
"String",
"scope",
",",
"final",
"String",
"stream",
",",
"final",
"UUID",
"txnId",
",",
"final",
"long",
"lease",
",",
"final",
"OperationContext",
"ctx",
")",
"{",
"if",
"(",
"!",
"timeoutService",
".",
"isRunning",
"(",
")",
")",
"{",
"return",
"CompletableFuture",
".",
"completedFuture",
"(",
"createStatus",
"(",
"Status",
".",
"DISCONNECTED",
")",
")",
";",
"}",
"log",
".",
"debug",
"(",
"\"Txn={}, updating txn node in store and extending lease\"",
",",
"txnId",
")",
";",
"return",
"fenceTxnUpdateLease",
"(",
"scope",
",",
"stream",
",",
"txnId",
",",
"lease",
",",
"ctx",
")",
";",
"}"
] | Ping a txn thereby updating its timeout to current time + lease.
Post-condition:
1. If ping request completes successfully, then
(a) txn timeout is set to lease + current time in timeout service,
(b) txn version in timeout service equals version of txn node in store,
(c) if txn's timeout was not previously tracked in timeout service of current process,
then version of txn node in store is updated, thus fencing out other processes tracking timeout for this txn,
(d) txn is present in the host-txn index of current host,
2. If process fails before responding to the client, then since txn is present in the host-txn index,
some other controller process shall abort the txn after maxLeaseValue
Store read/update operation is not invoked on receiving ping request for a txn that is being tracked in the
timeout service. Otherwise, if the txn is not being tracked in the timeout service, txn node is read from
the store and updated.
@param scope scope name.
@param stream stream name.
@param txnId txn id.
@param lease txn lease.
@param ctx context.
@return ping status. | [
"Ping",
"a",
"txn",
"thereby",
"updating",
"its",
"timeout",
"to",
"current",
"time",
"+",
"lease",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/controller/src/main/java/io/pravega/controller/task/Stream/StreamTransactionMetadataTasks.java#L418-L429 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/cert/X509CertSelector.java | X509CertSelector.setNameConstraints | public void setNameConstraints(byte[] bytes) throws IOException {
"""
Sets the name constraints criterion. The {@code X509Certificate}
must have subject and subject alternative names that
meet the specified name constraints.
<p>
The name constraints are specified as a byte array. This byte array
should contain the DER encoded form of the name constraints, as they
would appear in the NameConstraints structure defined in RFC 3280
and X.509. The ASN.1 definition of this structure appears below.
<pre>{@code
NameConstraints ::= SEQUENCE {
permittedSubtrees [0] GeneralSubtrees OPTIONAL,
excludedSubtrees [1] GeneralSubtrees OPTIONAL }
GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
GeneralSubtree ::= SEQUENCE {
base GeneralName,
minimum [0] BaseDistance DEFAULT 0,
maximum [1] BaseDistance OPTIONAL }
BaseDistance ::= INTEGER (0..MAX)
GeneralName ::= CHOICE {
otherName [0] OtherName,
rfc822Name [1] IA5String,
dNSName [2] IA5String,
x400Address [3] ORAddress,
directoryName [4] Name,
ediPartyName [5] EDIPartyName,
uniformResourceIdentifier [6] IA5String,
iPAddress [7] OCTET STRING,
registeredID [8] OBJECT IDENTIFIER}
}</pre>
<p>
Note that the byte array supplied here is cloned to protect against
subsequent modifications.
@param bytes a byte array containing the ASN.1 DER encoding of
a NameConstraints extension to be used for checking
name constraints. Only the value of the extension is
included, not the OID or criticality flag. Can be
{@code null},
in which case no name constraints check will be performed.
@throws IOException if a parsing error occurs
@see #getNameConstraints
"""
if (bytes == null) {
ncBytes = null;
nc = null;
} else {
ncBytes = bytes.clone();
nc = new NameConstraintsExtension(FALSE, bytes);
}
} | java | public void setNameConstraints(byte[] bytes) throws IOException {
if (bytes == null) {
ncBytes = null;
nc = null;
} else {
ncBytes = bytes.clone();
nc = new NameConstraintsExtension(FALSE, bytes);
}
} | [
"public",
"void",
"setNameConstraints",
"(",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"if",
"(",
"bytes",
"==",
"null",
")",
"{",
"ncBytes",
"=",
"null",
";",
"nc",
"=",
"null",
";",
"}",
"else",
"{",
"ncBytes",
"=",
"bytes",
".",
"clone",
"(",
")",
";",
"nc",
"=",
"new",
"NameConstraintsExtension",
"(",
"FALSE",
",",
"bytes",
")",
";",
"}",
"}"
] | Sets the name constraints criterion. The {@code X509Certificate}
must have subject and subject alternative names that
meet the specified name constraints.
<p>
The name constraints are specified as a byte array. This byte array
should contain the DER encoded form of the name constraints, as they
would appear in the NameConstraints structure defined in RFC 3280
and X.509. The ASN.1 definition of this structure appears below.
<pre>{@code
NameConstraints ::= SEQUENCE {
permittedSubtrees [0] GeneralSubtrees OPTIONAL,
excludedSubtrees [1] GeneralSubtrees OPTIONAL }
GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
GeneralSubtree ::= SEQUENCE {
base GeneralName,
minimum [0] BaseDistance DEFAULT 0,
maximum [1] BaseDistance OPTIONAL }
BaseDistance ::= INTEGER (0..MAX)
GeneralName ::= CHOICE {
otherName [0] OtherName,
rfc822Name [1] IA5String,
dNSName [2] IA5String,
x400Address [3] ORAddress,
directoryName [4] Name,
ediPartyName [5] EDIPartyName,
uniformResourceIdentifier [6] IA5String,
iPAddress [7] OCTET STRING,
registeredID [8] OBJECT IDENTIFIER}
}</pre>
<p>
Note that the byte array supplied here is cloned to protect against
subsequent modifications.
@param bytes a byte array containing the ASN.1 DER encoding of
a NameConstraints extension to be used for checking
name constraints. Only the value of the extension is
included, not the OID or criticality flag. Can be
{@code null},
in which case no name constraints check will be performed.
@throws IOException if a parsing error occurs
@see #getNameConstraints | [
"Sets",
"the",
"name",
"constraints",
"criterion",
".",
"The",
"{",
"@code",
"X509Certificate",
"}",
"must",
"have",
"subject",
"and",
"subject",
"alternative",
"names",
"that",
"meet",
"the",
"specified",
"name",
"constraints",
".",
"<p",
">",
"The",
"name",
"constraints",
"are",
"specified",
"as",
"a",
"byte",
"array",
".",
"This",
"byte",
"array",
"should",
"contain",
"the",
"DER",
"encoded",
"form",
"of",
"the",
"name",
"constraints",
"as",
"they",
"would",
"appear",
"in",
"the",
"NameConstraints",
"structure",
"defined",
"in",
"RFC",
"3280",
"and",
"X",
".",
"509",
".",
"The",
"ASN",
".",
"1",
"definition",
"of",
"this",
"structure",
"appears",
"below",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/security/cert/X509CertSelector.java#L1040-L1048 |
hdecarne/java-default | src/main/java/de/carne/util/Strings.java | Strings.encodeHtml | public static StringBuilder encodeHtml(StringBuilder buffer, CharSequence chars) {
"""
Encodes a {@linkplain CharSequence} to a HTML conform representation by quoting special characters.
@param buffer the {@linkplain StringBuilder} to encode into.
@param chars the {@linkplain CharSequence} to encode.
@return the encoded characters.
"""
chars.chars().forEach(c -> {
switch (c) {
case '<':
buffer.append("<");
break;
case '>':
buffer.append(">");
break;
case '&':
buffer.append("&");
break;
case '"':
buffer.append(""");
break;
case '\'':
buffer.append("'");
break;
default:
if (Character.isAlphabetic(c)) {
buffer.append((char) c);
} else {
buffer.append("&#").append(c).append(';');
}
}
});
return buffer;
} | java | public static StringBuilder encodeHtml(StringBuilder buffer, CharSequence chars) {
chars.chars().forEach(c -> {
switch (c) {
case '<':
buffer.append("<");
break;
case '>':
buffer.append(">");
break;
case '&':
buffer.append("&");
break;
case '"':
buffer.append(""");
break;
case '\'':
buffer.append("'");
break;
default:
if (Character.isAlphabetic(c)) {
buffer.append((char) c);
} else {
buffer.append("&#").append(c).append(';');
}
}
});
return buffer;
} | [
"public",
"static",
"StringBuilder",
"encodeHtml",
"(",
"StringBuilder",
"buffer",
",",
"CharSequence",
"chars",
")",
"{",
"chars",
".",
"chars",
"(",
")",
".",
"forEach",
"(",
"c",
"->",
"{",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"buffer",
".",
"append",
"(",
"\"<\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"buffer",
".",
"append",
"(",
"\">\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"buffer",
".",
"append",
"(",
"\"&\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"buffer",
".",
"append",
"(",
"\""\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"buffer",
".",
"append",
"(",
"\"'\"",
")",
";",
"break",
";",
"default",
":",
"if",
"(",
"Character",
".",
"isAlphabetic",
"(",
"c",
")",
")",
"{",
"buffer",
".",
"append",
"(",
"(",
"char",
")",
"c",
")",
";",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"\"&#\"",
")",
".",
"append",
"(",
"c",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"buffer",
";",
"}"
] | Encodes a {@linkplain CharSequence} to a HTML conform representation by quoting special characters.
@param buffer the {@linkplain StringBuilder} to encode into.
@param chars the {@linkplain CharSequence} to encode.
@return the encoded characters. | [
"Encodes",
"a",
"{",
"@linkplain",
"CharSequence",
"}",
"to",
"a",
"HTML",
"conform",
"representation",
"by",
"quoting",
"special",
"characters",
"."
] | train | https://github.com/hdecarne/java-default/blob/ca16f6fdb0436e90e9e2df3106055e320bb3c9e3/src/main/java/de/carne/util/Strings.java#L424-L451 |
killbill/killbill | profiles/killbill/src/main/java/org/killbill/billing/server/log/obfuscators/Obfuscator.java | Obfuscator.obfuscateConfidentialData | @VisibleForTesting
String obfuscateConfidentialData(final CharSequence confidentialSequence, @Nullable final CharSequence unmasked) {
"""
Get a mask string for masking the given `confidentialSequence`.
@param confidentialSequence the string to be obfuscated
@param unmasked the section of `confidentialSequence` to be left unmasked
@return a mask string
"""
final int maskedLength = unmasked == null ? confidentialSequence.length() : confidentialSequence.length() - unmasked.length();
return new String(new char[maskedLength]).replace('\0', PAD_CHAR);
} | java | @VisibleForTesting
String obfuscateConfidentialData(final CharSequence confidentialSequence, @Nullable final CharSequence unmasked) {
final int maskedLength = unmasked == null ? confidentialSequence.length() : confidentialSequence.length() - unmasked.length();
return new String(new char[maskedLength]).replace('\0', PAD_CHAR);
} | [
"@",
"VisibleForTesting",
"String",
"obfuscateConfidentialData",
"(",
"final",
"CharSequence",
"confidentialSequence",
",",
"@",
"Nullable",
"final",
"CharSequence",
"unmasked",
")",
"{",
"final",
"int",
"maskedLength",
"=",
"unmasked",
"==",
"null",
"?",
"confidentialSequence",
".",
"length",
"(",
")",
":",
"confidentialSequence",
".",
"length",
"(",
")",
"-",
"unmasked",
".",
"length",
"(",
")",
";",
"return",
"new",
"String",
"(",
"new",
"char",
"[",
"maskedLength",
"]",
")",
".",
"replace",
"(",
"'",
"'",
",",
"PAD_CHAR",
")",
";",
"}"
] | Get a mask string for masking the given `confidentialSequence`.
@param confidentialSequence the string to be obfuscated
@param unmasked the section of `confidentialSequence` to be left unmasked
@return a mask string | [
"Get",
"a",
"mask",
"string",
"for",
"masking",
"the",
"given",
"confidentialSequence",
"."
] | train | https://github.com/killbill/killbill/blob/6457b485fb32a182c76197a83f428123331f1380/profiles/killbill/src/main/java/org/killbill/billing/server/log/obfuscators/Obfuscator.java#L101-L105 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java | HttpChannelConfig.minLimit | private int minLimit(int input, int min) {
"""
Return the larger value of either the input int or the minimum
limit.
@param input
@param min
@return int
"""
if (input < min) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Config: " + input + " too small.");
}
return min;
}
return input;
} | java | private int minLimit(int input, int min) {
if (input < min) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Config: " + input + " too small.");
}
return min;
}
return input;
} | [
"private",
"int",
"minLimit",
"(",
"int",
"input",
",",
"int",
"min",
")",
"{",
"if",
"(",
"input",
"<",
"min",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Config: \"",
"+",
"input",
"+",
"\" too small.\"",
")",
";",
"}",
"return",
"min",
";",
"}",
"return",
"input",
";",
"}"
] | Return the larger value of either the input int or the minimum
limit.
@param input
@param min
@return int | [
"Return",
"the",
"larger",
"value",
"of",
"either",
"the",
"input",
"int",
"or",
"the",
"minimum",
"limit",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java#L1510-L1518 |
wisdom-framework/wisdom | extensions/wisdom-raml/wisdom-raml-maven-plugin/src/main/java/org/wisdom/raml/mojo/RamlCompilerMojo.java | RamlCompilerMojo.controllerParsed | @Override
public void controllerParsed(File source, ControllerModel<Raml> model) throws WatchingException {
"""
Generate the raml file from a given controller source file.
@param source The controller source file.
@param model The controller model
@throws WatchingException If there is a problem while creating the raml file.
"""
Raml raml = new Raml(); //Create a new raml file
raml.setBaseUri(baseUri); //set the base uri
raml.setVersion(project().getVersion());
//Visit the controller model to populate the raml model
model.accept(controllerVisitor, raml);
getLog().info("Create raml file for controller " + raml.getTitle());
try {
//create the file
File output = getRamlOutputFile(source);
FileUtils.write(output, ramlEmitter.dump(raml));
getLog().info("Created the RAML description for " + source.getName() + " => " + output.getAbsolutePath());
} catch (IOException ie) {
throw new WatchingException("Cannot create raml file", source, ie);
} catch (IllegalArgumentException e) {
throw new WatchingException("Cannot create Controller Element from", e);
}
} | java | @Override
public void controllerParsed(File source, ControllerModel<Raml> model) throws WatchingException {
Raml raml = new Raml(); //Create a new raml file
raml.setBaseUri(baseUri); //set the base uri
raml.setVersion(project().getVersion());
//Visit the controller model to populate the raml model
model.accept(controllerVisitor, raml);
getLog().info("Create raml file for controller " + raml.getTitle());
try {
//create the file
File output = getRamlOutputFile(source);
FileUtils.write(output, ramlEmitter.dump(raml));
getLog().info("Created the RAML description for " + source.getName() + " => " + output.getAbsolutePath());
} catch (IOException ie) {
throw new WatchingException("Cannot create raml file", source, ie);
} catch (IllegalArgumentException e) {
throw new WatchingException("Cannot create Controller Element from", e);
}
} | [
"@",
"Override",
"public",
"void",
"controllerParsed",
"(",
"File",
"source",
",",
"ControllerModel",
"<",
"Raml",
">",
"model",
")",
"throws",
"WatchingException",
"{",
"Raml",
"raml",
"=",
"new",
"Raml",
"(",
")",
";",
"//Create a new raml file",
"raml",
".",
"setBaseUri",
"(",
"baseUri",
")",
";",
"//set the base uri",
"raml",
".",
"setVersion",
"(",
"project",
"(",
")",
".",
"getVersion",
"(",
")",
")",
";",
"//Visit the controller model to populate the raml model",
"model",
".",
"accept",
"(",
"controllerVisitor",
",",
"raml",
")",
";",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Create raml file for controller \"",
"+",
"raml",
".",
"getTitle",
"(",
")",
")",
";",
"try",
"{",
"//create the file",
"File",
"output",
"=",
"getRamlOutputFile",
"(",
"source",
")",
";",
"FileUtils",
".",
"write",
"(",
"output",
",",
"ramlEmitter",
".",
"dump",
"(",
"raml",
")",
")",
";",
"getLog",
"(",
")",
".",
"info",
"(",
"\"Created the RAML description for \"",
"+",
"source",
".",
"getName",
"(",
")",
"+",
"\" => \"",
"+",
"output",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ie",
")",
"{",
"throw",
"new",
"WatchingException",
"(",
"\"Cannot create raml file\"",
",",
"source",
",",
"ie",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"WatchingException",
"(",
"\"Cannot create Controller Element from\"",
",",
"e",
")",
";",
"}",
"}"
] | Generate the raml file from a given controller source file.
@param source The controller source file.
@param model The controller model
@throws WatchingException If there is a problem while creating the raml file. | [
"Generate",
"the",
"raml",
"file",
"from",
"a",
"given",
"controller",
"source",
"file",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/extensions/wisdom-raml/wisdom-raml-maven-plugin/src/main/java/org/wisdom/raml/mojo/RamlCompilerMojo.java#L85-L106 |
rzwitserloot/lombok | src/core/lombok/javac/handlers/JavacHandlerUtil.java | JavacHandlerUtil.fieldExists | public static MemberExistsResult fieldExists(String fieldName, JavacNode node) {
"""
Checks if there is a field with the provided name.
@param fieldName the field name to check for.
@param node Any node that represents the Type (JCClassDecl) to look in, or any child node thereof.
"""
node = upToTypeNode(node);
if (node != null && node.get() instanceof JCClassDecl) {
for (JCTree def : ((JCClassDecl)node.get()).defs) {
if (def instanceof JCVariableDecl) {
if (((JCVariableDecl)def).name.contentEquals(fieldName)) {
return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
}
}
}
}
return MemberExistsResult.NOT_EXISTS;
} | java | public static MemberExistsResult fieldExists(String fieldName, JavacNode node) {
node = upToTypeNode(node);
if (node != null && node.get() instanceof JCClassDecl) {
for (JCTree def : ((JCClassDecl)node.get()).defs) {
if (def instanceof JCVariableDecl) {
if (((JCVariableDecl)def).name.contentEquals(fieldName)) {
return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
}
}
}
}
return MemberExistsResult.NOT_EXISTS;
} | [
"public",
"static",
"MemberExistsResult",
"fieldExists",
"(",
"String",
"fieldName",
",",
"JavacNode",
"node",
")",
"{",
"node",
"=",
"upToTypeNode",
"(",
"node",
")",
";",
"if",
"(",
"node",
"!=",
"null",
"&&",
"node",
".",
"get",
"(",
")",
"instanceof",
"JCClassDecl",
")",
"{",
"for",
"(",
"JCTree",
"def",
":",
"(",
"(",
"JCClassDecl",
")",
"node",
".",
"get",
"(",
")",
")",
".",
"defs",
")",
"{",
"if",
"(",
"def",
"instanceof",
"JCVariableDecl",
")",
"{",
"if",
"(",
"(",
"(",
"JCVariableDecl",
")",
"def",
")",
".",
"name",
".",
"contentEquals",
"(",
"fieldName",
")",
")",
"{",
"return",
"getGeneratedBy",
"(",
"def",
")",
"==",
"null",
"?",
"MemberExistsResult",
".",
"EXISTS_BY_USER",
":",
"MemberExistsResult",
".",
"EXISTS_BY_LOMBOK",
";",
"}",
"}",
"}",
"}",
"return",
"MemberExistsResult",
".",
"NOT_EXISTS",
";",
"}"
] | Checks if there is a field with the provided name.
@param fieldName the field name to check for.
@param node Any node that represents the Type (JCClassDecl) to look in, or any child node thereof. | [
"Checks",
"if",
"there",
"is",
"a",
"field",
"with",
"the",
"provided",
"name",
"."
] | train | https://github.com/rzwitserloot/lombok/blob/75601240760bd81ff95fcde7a1b8185769ce64e8/src/core/lombok/javac/handlers/JavacHandlerUtil.java#L705-L719 |
jtmelton/appsensor | analysis-engines/appsensor-analysis-rules/src/main/java/org/owasp/appsensor/analysis/AggregateEventAnalysisEngine.java | AggregateEventAnalysisEngine.getQueueInterval | public Interval getQueueInterval(Queue<Event> queue, Event tailEvent) {
"""
Determines the time between the {@link Event} at the head of the queue and the
{@link Event} at the tail of the queue.
@param queue a queue of {@link Event}s
@param tailEvent the {@link Event} at the tail of the queue
@return the duration of the queue as an {@link Interval}
"""
DateTime endTime = DateUtils.fromString(tailEvent.getTimestamp());
DateTime startTime = DateUtils.fromString(queue.peek().getTimestamp());
return new Interval((int)endTime.minus(startTime.getMillis()).getMillis(), "milliseconds");
} | java | public Interval getQueueInterval(Queue<Event> queue, Event tailEvent) {
DateTime endTime = DateUtils.fromString(tailEvent.getTimestamp());
DateTime startTime = DateUtils.fromString(queue.peek().getTimestamp());
return new Interval((int)endTime.minus(startTime.getMillis()).getMillis(), "milliseconds");
} | [
"public",
"Interval",
"getQueueInterval",
"(",
"Queue",
"<",
"Event",
">",
"queue",
",",
"Event",
"tailEvent",
")",
"{",
"DateTime",
"endTime",
"=",
"DateUtils",
".",
"fromString",
"(",
"tailEvent",
".",
"getTimestamp",
"(",
")",
")",
";",
"DateTime",
"startTime",
"=",
"DateUtils",
".",
"fromString",
"(",
"queue",
".",
"peek",
"(",
")",
".",
"getTimestamp",
"(",
")",
")",
";",
"return",
"new",
"Interval",
"(",
"(",
"int",
")",
"endTime",
".",
"minus",
"(",
"startTime",
".",
"getMillis",
"(",
")",
")",
".",
"getMillis",
"(",
")",
",",
"\"milliseconds\"",
")",
";",
"}"
] | Determines the time between the {@link Event} at the head of the queue and the
{@link Event} at the tail of the queue.
@param queue a queue of {@link Event}s
@param tailEvent the {@link Event} at the tail of the queue
@return the duration of the queue as an {@link Interval} | [
"Determines",
"the",
"time",
"between",
"the",
"{",
"@link",
"Event",
"}",
"at",
"the",
"head",
"of",
"the",
"queue",
"and",
"the",
"{",
"@link",
"Event",
"}",
"at",
"the",
"tail",
"of",
"the",
"queue",
"."
] | train | https://github.com/jtmelton/appsensor/blob/c3b4e9ada50fdee974e0d618ec4bdfabc2163798/analysis-engines/appsensor-analysis-rules/src/main/java/org/owasp/appsensor/analysis/AggregateEventAnalysisEngine.java#L241-L246 |
beangle/beangle3 | struts/s2/src/main/java/org/beangle/struts2/view/component/Component.java | Component.findValue | protected Object findValue(String expr, String field, String errorMsg) {
"""
Evaluates the OGNL stack to find an Object value.
<p/>
Function just like <code>findValue(String)</code> except that if the given expression is
<tt>null</tt/> a error is logged and a <code>RuntimeException</code> is thrown constructed with
a messaged based on the given field and errorMsg paramter.
@param expr
OGNL expression.
@param field
field name used when throwing <code>RuntimeException</code>.
@param errorMsg
error message used when throwing <code>RuntimeException</code> .
@return the Object found, is never <tt>null</tt>.
@throws StrutsException
is thrown in case of not found in the OGNL stack, or
expression is <tt>null</tt>.
"""
if (expr == null) {
throw fieldError(field, errorMsg, null);
} else {
Object value = null;
Exception problem = null;
try {
value = findValue(expr);
} catch (Exception e) {
problem = e;
}
if (value == null) { throw fieldError(field, errorMsg, problem); }
return value;
}
} | java | protected Object findValue(String expr, String field, String errorMsg) {
if (expr == null) {
throw fieldError(field, errorMsg, null);
} else {
Object value = null;
Exception problem = null;
try {
value = findValue(expr);
} catch (Exception e) {
problem = e;
}
if (value == null) { throw fieldError(field, errorMsg, problem); }
return value;
}
} | [
"protected",
"Object",
"findValue",
"(",
"String",
"expr",
",",
"String",
"field",
",",
"String",
"errorMsg",
")",
"{",
"if",
"(",
"expr",
"==",
"null",
")",
"{",
"throw",
"fieldError",
"(",
"field",
",",
"errorMsg",
",",
"null",
")",
";",
"}",
"else",
"{",
"Object",
"value",
"=",
"null",
";",
"Exception",
"problem",
"=",
"null",
";",
"try",
"{",
"value",
"=",
"findValue",
"(",
"expr",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"problem",
"=",
"e",
";",
"}",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"fieldError",
"(",
"field",
",",
"errorMsg",
",",
"problem",
")",
";",
"}",
"return",
"value",
";",
"}",
"}"
] | Evaluates the OGNL stack to find an Object value.
<p/>
Function just like <code>findValue(String)</code> except that if the given expression is
<tt>null</tt/> a error is logged and a <code>RuntimeException</code> is thrown constructed with
a messaged based on the given field and errorMsg paramter.
@param expr
OGNL expression.
@param field
field name used when throwing <code>RuntimeException</code>.
@param errorMsg
error message used when throwing <code>RuntimeException</code> .
@return the Object found, is never <tt>null</tt>.
@throws StrutsException
is thrown in case of not found in the OGNL stack, or
expression is <tt>null</tt>. | [
"Evaluates",
"the",
"OGNL",
"stack",
"to",
"find",
"an",
"Object",
"value",
".",
"<p",
"/",
">",
"Function",
"just",
"like",
"<code",
">",
"findValue",
"(",
"String",
")",
"<",
"/",
"code",
">",
"except",
"that",
"if",
"the",
"given",
"expression",
"is",
"<tt",
">",
"null<",
"/",
"tt",
"/",
">",
"a",
"error",
"is",
"logged",
"and",
"a",
"<code",
">",
"RuntimeException<",
"/",
"code",
">",
"is",
"thrown",
"constructed",
"with",
"a",
"messaged",
"based",
"on",
"the",
"given",
"field",
"and",
"errorMsg",
"paramter",
"."
] | train | https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/view/component/Component.java#L328-L344 |
undertow-io/undertow | core/src/main/java/io/undertow/util/ETagUtils.java | ETagUtils.handleIfNoneMatch | public static boolean handleIfNoneMatch(final HttpServerExchange exchange, final ETag etag, boolean allowWeak) {
"""
Handles the if-none-match header. returns true if the request should proceed, false otherwise
@param exchange the exchange
@param etag The etags
@return
"""
return handleIfNoneMatch(exchange, Collections.singletonList(etag), allowWeak);
} | java | public static boolean handleIfNoneMatch(final HttpServerExchange exchange, final ETag etag, boolean allowWeak) {
return handleIfNoneMatch(exchange, Collections.singletonList(etag), allowWeak);
} | [
"public",
"static",
"boolean",
"handleIfNoneMatch",
"(",
"final",
"HttpServerExchange",
"exchange",
",",
"final",
"ETag",
"etag",
",",
"boolean",
"allowWeak",
")",
"{",
"return",
"handleIfNoneMatch",
"(",
"exchange",
",",
"Collections",
".",
"singletonList",
"(",
"etag",
")",
",",
"allowWeak",
")",
";",
"}"
] | Handles the if-none-match header. returns true if the request should proceed, false otherwise
@param exchange the exchange
@param etag The etags
@return | [
"Handles",
"the",
"if",
"-",
"none",
"-",
"match",
"header",
".",
"returns",
"true",
"if",
"the",
"request",
"should",
"proceed",
"false",
"otherwise"
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/util/ETagUtils.java#L111-L113 |
dasein-cloud/dasein-cloud-aws | src/main/java/org/dasein/cloud/aws/platform/RDS.java | RDS.getWindowString | private String getWindowString(TimeWindow window, boolean includeDays) {
"""
Formats a time window as hh24:mi-hh24:mi or ddd:hh24:mi-ddd:hh24:mi
@param window
@param includeDays must be false for PreferredBackupWindow parameter
@return formatted time window text representation
"""
StringBuilder str = new StringBuilder();
if( includeDays ) {
if( window.getStartDayOfWeek() == null ) {
str.append("*");
}
else {
str.append(window.getStartDayOfWeek().getShortString());
}
str.append(":");
}
str.append(String.format("%02d:%02d", window.getStartHour(), window.getStartMinute()));
str.append("-");
if( includeDays ) {
if( window.getEndDayOfWeek() == null ) {
str.append("*");
}
else {
str.append(window.getEndDayOfWeek().getShortString());
}
str.append(":");
}
str.append(String.format("%02d:%02d", window.getEndHour(), window.getEndMinute()));
return str.toString();
} | java | private String getWindowString(TimeWindow window, boolean includeDays) {
StringBuilder str = new StringBuilder();
if( includeDays ) {
if( window.getStartDayOfWeek() == null ) {
str.append("*");
}
else {
str.append(window.getStartDayOfWeek().getShortString());
}
str.append(":");
}
str.append(String.format("%02d:%02d", window.getStartHour(), window.getStartMinute()));
str.append("-");
if( includeDays ) {
if( window.getEndDayOfWeek() == null ) {
str.append("*");
}
else {
str.append(window.getEndDayOfWeek().getShortString());
}
str.append(":");
}
str.append(String.format("%02d:%02d", window.getEndHour(), window.getEndMinute()));
return str.toString();
} | [
"private",
"String",
"getWindowString",
"(",
"TimeWindow",
"window",
",",
"boolean",
"includeDays",
")",
"{",
"StringBuilder",
"str",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"includeDays",
")",
"{",
"if",
"(",
"window",
".",
"getStartDayOfWeek",
"(",
")",
"==",
"null",
")",
"{",
"str",
".",
"append",
"(",
"\"*\"",
")",
";",
"}",
"else",
"{",
"str",
".",
"append",
"(",
"window",
".",
"getStartDayOfWeek",
"(",
")",
".",
"getShortString",
"(",
")",
")",
";",
"}",
"str",
".",
"append",
"(",
"\":\"",
")",
";",
"}",
"str",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"%02d:%02d\"",
",",
"window",
".",
"getStartHour",
"(",
")",
",",
"window",
".",
"getStartMinute",
"(",
")",
")",
")",
";",
"str",
".",
"append",
"(",
"\"-\"",
")",
";",
"if",
"(",
"includeDays",
")",
"{",
"if",
"(",
"window",
".",
"getEndDayOfWeek",
"(",
")",
"==",
"null",
")",
"{",
"str",
".",
"append",
"(",
"\"*\"",
")",
";",
"}",
"else",
"{",
"str",
".",
"append",
"(",
"window",
".",
"getEndDayOfWeek",
"(",
")",
".",
"getShortString",
"(",
")",
")",
";",
"}",
"str",
".",
"append",
"(",
"\":\"",
")",
";",
"}",
"str",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"%02d:%02d\"",
",",
"window",
".",
"getEndHour",
"(",
")",
",",
"window",
".",
"getEndMinute",
"(",
")",
")",
")",
";",
"return",
"str",
".",
"toString",
"(",
")",
";",
"}"
] | Formats a time window as hh24:mi-hh24:mi or ddd:hh24:mi-ddd:hh24:mi
@param window
@param includeDays must be false for PreferredBackupWindow parameter
@return formatted time window text representation | [
"Formats",
"a",
"time",
"window",
"as",
"hh24",
":",
"mi",
"-",
"hh24",
":",
"mi",
"or",
"ddd",
":",
"hh24",
":",
"mi",
"-",
"ddd",
":",
"hh24",
":",
"mi"
] | train | https://github.com/dasein-cloud/dasein-cloud-aws/blob/05098574197a1f573f77447cadc39a76bf00b99d/src/main/java/org/dasein/cloud/aws/platform/RDS.java#L173-L197 |
jeremylong/DependencyCheck | core/src/main/java/org/owasp/dependencycheck/xml/suppression/SuppressionHandler.java | SuppressionHandler.endElement | @Override
public void endElement(String uri, String localName, String qName) throws SAXException {
"""
Handles the end element event.
@param uri the URI of the element
@param localName the local name of the element
@param qName the qName of the element
@throws SAXException thrown if there is an exception processing
"""
if (null != qName) {
switch (qName) {
case SUPPRESS:
if (rule.getUntil() != null && rule.getUntil().before(Calendar.getInstance())) {
LOGGER.info("Suppression is expired for rule: {}", rule);
} else {
suppressionRules.add(rule);
}
rule = null;
break;
case FILE_PATH:
rule.setFilePath(processPropertyType());
break;
case SHA1:
rule.setSha1(currentText.toString());
break;
case GAV:
rule.setGav(processPropertyType());
break;
case CPE:
rule.addCpe(processPropertyType());
break;
case CWE:
rule.addCwe(currentText.toString());
break;
case CVE:
rule.addCve(currentText.toString());
break;
case NOTES:
rule.addNotes(currentText.toString());
break;
case CVSS_BELOW:
final float cvss = Float.parseFloat(currentText.toString());
rule.addCvssBelow(cvss);
break;
default:
break;
}
}
} | java | @Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (null != qName) {
switch (qName) {
case SUPPRESS:
if (rule.getUntil() != null && rule.getUntil().before(Calendar.getInstance())) {
LOGGER.info("Suppression is expired for rule: {}", rule);
} else {
suppressionRules.add(rule);
}
rule = null;
break;
case FILE_PATH:
rule.setFilePath(processPropertyType());
break;
case SHA1:
rule.setSha1(currentText.toString());
break;
case GAV:
rule.setGav(processPropertyType());
break;
case CPE:
rule.addCpe(processPropertyType());
break;
case CWE:
rule.addCwe(currentText.toString());
break;
case CVE:
rule.addCve(currentText.toString());
break;
case NOTES:
rule.addNotes(currentText.toString());
break;
case CVSS_BELOW:
final float cvss = Float.parseFloat(currentText.toString());
rule.addCvssBelow(cvss);
break;
default:
break;
}
}
} | [
"@",
"Override",
"public",
"void",
"endElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"qName",
")",
"throws",
"SAXException",
"{",
"if",
"(",
"null",
"!=",
"qName",
")",
"{",
"switch",
"(",
"qName",
")",
"{",
"case",
"SUPPRESS",
":",
"if",
"(",
"rule",
".",
"getUntil",
"(",
")",
"!=",
"null",
"&&",
"rule",
".",
"getUntil",
"(",
")",
".",
"before",
"(",
"Calendar",
".",
"getInstance",
"(",
")",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Suppression is expired for rule: {}\"",
",",
"rule",
")",
";",
"}",
"else",
"{",
"suppressionRules",
".",
"add",
"(",
"rule",
")",
";",
"}",
"rule",
"=",
"null",
";",
"break",
";",
"case",
"FILE_PATH",
":",
"rule",
".",
"setFilePath",
"(",
"processPropertyType",
"(",
")",
")",
";",
"break",
";",
"case",
"SHA1",
":",
"rule",
".",
"setSha1",
"(",
"currentText",
".",
"toString",
"(",
")",
")",
";",
"break",
";",
"case",
"GAV",
":",
"rule",
".",
"setGav",
"(",
"processPropertyType",
"(",
")",
")",
";",
"break",
";",
"case",
"CPE",
":",
"rule",
".",
"addCpe",
"(",
"processPropertyType",
"(",
")",
")",
";",
"break",
";",
"case",
"CWE",
":",
"rule",
".",
"addCwe",
"(",
"currentText",
".",
"toString",
"(",
")",
")",
";",
"break",
";",
"case",
"CVE",
":",
"rule",
".",
"addCve",
"(",
"currentText",
".",
"toString",
"(",
")",
")",
";",
"break",
";",
"case",
"NOTES",
":",
"rule",
".",
"addNotes",
"(",
"currentText",
".",
"toString",
"(",
")",
")",
";",
"break",
";",
"case",
"CVSS_BELOW",
":",
"final",
"float",
"cvss",
"=",
"Float",
".",
"parseFloat",
"(",
"currentText",
".",
"toString",
"(",
")",
")",
";",
"rule",
".",
"addCvssBelow",
"(",
"cvss",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}",
"}"
] | Handles the end element event.
@param uri the URI of the element
@param localName the local name of the element
@param qName the qName of the element
@throws SAXException thrown if there is an exception processing | [
"Handles",
"the",
"end",
"element",
"event",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/xml/suppression/SuppressionHandler.java#L150-L191 |
jmxtrans/jmxtrans | jmxtrans-core/src/main/java/com/googlecode/jmxtrans/model/Server.java | Server.getEnvironment | @JsonIgnore
public ImmutableMap<String, ?> getEnvironment() {
"""
Generates the proper username/password environment for JMX connections.
"""
if (getProtocolProviderPackages() != null && getProtocolProviderPackages().contains("weblogic")) {
ImmutableMap.Builder<String, String> environment = ImmutableMap.builder();
if ((username != null) && (password != null)) {
environment.put(PROTOCOL_PROVIDER_PACKAGES, getProtocolProviderPackages());
environment.put(SECURITY_PRINCIPAL, username);
environment.put(SECURITY_CREDENTIALS, password);
}
return environment.build();
}
ImmutableMap.Builder<String, Object> environment = ImmutableMap.builder();
if ((username != null) && (password != null)) {
String[] credentials = new String[] {
username,
password
};
environment.put(JMXConnector.CREDENTIALS, credentials);
}
JmxTransRMIClientSocketFactory rmiClientSocketFactory = new JmxTransRMIClientSocketFactory(DEFAULT_SOCKET_SO_TIMEOUT_MILLIS, ssl);
// The following is required when JMX is secured with SSL
// with com.sun.management.jmxremote.ssl=true
// as shown in http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html#gdfvq
environment.put(RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, rmiClientSocketFactory);
// The following is required when JNDI Registry is secured with SSL
// with com.sun.management.jmxremote.registry.ssl=true
// This property is defined in com.sun.jndi.rmi.registry.RegistryContext.SOCKET_FACTORY
environment.put("com.sun.jndi.rmi.factory.socket", rmiClientSocketFactory);
return environment.build();
} | java | @JsonIgnore
public ImmutableMap<String, ?> getEnvironment() {
if (getProtocolProviderPackages() != null && getProtocolProviderPackages().contains("weblogic")) {
ImmutableMap.Builder<String, String> environment = ImmutableMap.builder();
if ((username != null) && (password != null)) {
environment.put(PROTOCOL_PROVIDER_PACKAGES, getProtocolProviderPackages());
environment.put(SECURITY_PRINCIPAL, username);
environment.put(SECURITY_CREDENTIALS, password);
}
return environment.build();
}
ImmutableMap.Builder<String, Object> environment = ImmutableMap.builder();
if ((username != null) && (password != null)) {
String[] credentials = new String[] {
username,
password
};
environment.put(JMXConnector.CREDENTIALS, credentials);
}
JmxTransRMIClientSocketFactory rmiClientSocketFactory = new JmxTransRMIClientSocketFactory(DEFAULT_SOCKET_SO_TIMEOUT_MILLIS, ssl);
// The following is required when JMX is secured with SSL
// with com.sun.management.jmxremote.ssl=true
// as shown in http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html#gdfvq
environment.put(RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, rmiClientSocketFactory);
// The following is required when JNDI Registry is secured with SSL
// with com.sun.management.jmxremote.registry.ssl=true
// This property is defined in com.sun.jndi.rmi.registry.RegistryContext.SOCKET_FACTORY
environment.put("com.sun.jndi.rmi.factory.socket", rmiClientSocketFactory);
return environment.build();
} | [
"@",
"JsonIgnore",
"public",
"ImmutableMap",
"<",
"String",
",",
"?",
">",
"getEnvironment",
"(",
")",
"{",
"if",
"(",
"getProtocolProviderPackages",
"(",
")",
"!=",
"null",
"&&",
"getProtocolProviderPackages",
"(",
")",
".",
"contains",
"(",
"\"weblogic\"",
")",
")",
"{",
"ImmutableMap",
".",
"Builder",
"<",
"String",
",",
"String",
">",
"environment",
"=",
"ImmutableMap",
".",
"builder",
"(",
")",
";",
"if",
"(",
"(",
"username",
"!=",
"null",
")",
"&&",
"(",
"password",
"!=",
"null",
")",
")",
"{",
"environment",
".",
"put",
"(",
"PROTOCOL_PROVIDER_PACKAGES",
",",
"getProtocolProviderPackages",
"(",
")",
")",
";",
"environment",
".",
"put",
"(",
"SECURITY_PRINCIPAL",
",",
"username",
")",
";",
"environment",
".",
"put",
"(",
"SECURITY_CREDENTIALS",
",",
"password",
")",
";",
"}",
"return",
"environment",
".",
"build",
"(",
")",
";",
"}",
"ImmutableMap",
".",
"Builder",
"<",
"String",
",",
"Object",
">",
"environment",
"=",
"ImmutableMap",
".",
"builder",
"(",
")",
";",
"if",
"(",
"(",
"username",
"!=",
"null",
")",
"&&",
"(",
"password",
"!=",
"null",
")",
")",
"{",
"String",
"[",
"]",
"credentials",
"=",
"new",
"String",
"[",
"]",
"{",
"username",
",",
"password",
"}",
";",
"environment",
".",
"put",
"(",
"JMXConnector",
".",
"CREDENTIALS",
",",
"credentials",
")",
";",
"}",
"JmxTransRMIClientSocketFactory",
"rmiClientSocketFactory",
"=",
"new",
"JmxTransRMIClientSocketFactory",
"(",
"DEFAULT_SOCKET_SO_TIMEOUT_MILLIS",
",",
"ssl",
")",
";",
"// The following is required when JMX is secured with SSL",
"// with com.sun.management.jmxremote.ssl=true",
"// as shown in http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html#gdfvq",
"environment",
".",
"put",
"(",
"RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE",
",",
"rmiClientSocketFactory",
")",
";",
"// The following is required when JNDI Registry is secured with SSL",
"// with com.sun.management.jmxremote.registry.ssl=true",
"// This property is defined in com.sun.jndi.rmi.registry.RegistryContext.SOCKET_FACTORY",
"environment",
".",
"put",
"(",
"\"com.sun.jndi.rmi.factory.socket\"",
",",
"rmiClientSocketFactory",
")",
";",
"return",
"environment",
".",
"build",
"(",
")",
";",
"}"
] | Generates the proper username/password environment for JMX connections. | [
"Generates",
"the",
"proper",
"username",
"/",
"password",
"environment",
"for",
"JMX",
"connections",
"."
] | train | https://github.com/jmxtrans/jmxtrans/blob/496f342de3bcf2c2226626374b7a16edf8f4ba2a/jmxtrans-core/src/main/java/com/googlecode/jmxtrans/model/Server.java#L305-L337 |
atomix/atomix | protocols/raft/src/main/java/io/atomix/protocols/raft/roles/PassiveRole.java | PassiveRole.completeAppend | protected boolean completeAppend(boolean succeeded, long lastLogIndex, CompletableFuture<AppendResponse> future) {
"""
Returns a successful append response.
@param succeeded whether the append succeeded
@param lastLogIndex the last log index
@param future the append response future
@return the append response status
"""
future.complete(logResponse(AppendResponse.builder()
.withStatus(RaftResponse.Status.OK)
.withTerm(raft.getTerm())
.withSucceeded(succeeded)
.withLastLogIndex(lastLogIndex)
.build()));
return succeeded;
} | java | protected boolean completeAppend(boolean succeeded, long lastLogIndex, CompletableFuture<AppendResponse> future) {
future.complete(logResponse(AppendResponse.builder()
.withStatus(RaftResponse.Status.OK)
.withTerm(raft.getTerm())
.withSucceeded(succeeded)
.withLastLogIndex(lastLogIndex)
.build()));
return succeeded;
} | [
"protected",
"boolean",
"completeAppend",
"(",
"boolean",
"succeeded",
",",
"long",
"lastLogIndex",
",",
"CompletableFuture",
"<",
"AppendResponse",
">",
"future",
")",
"{",
"future",
".",
"complete",
"(",
"logResponse",
"(",
"AppendResponse",
".",
"builder",
"(",
")",
".",
"withStatus",
"(",
"RaftResponse",
".",
"Status",
".",
"OK",
")",
".",
"withTerm",
"(",
"raft",
".",
"getTerm",
"(",
")",
")",
".",
"withSucceeded",
"(",
"succeeded",
")",
".",
"withLastLogIndex",
"(",
"lastLogIndex",
")",
".",
"build",
"(",
")",
")",
")",
";",
"return",
"succeeded",
";",
"}"
] | Returns a successful append response.
@param succeeded whether the append succeeded
@param lastLogIndex the last log index
@param future the append response future
@return the append response status | [
"Returns",
"a",
"successful",
"append",
"response",
"."
] | train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/protocols/raft/src/main/java/io/atomix/protocols/raft/roles/PassiveRole.java#L362-L370 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/fs/FSInputChecker.java | FSInputChecker.read1 | private int read1(byte b[], int off, int len)
throws IOException {
"""
/*
Read characters into a portion of an array, reading from the underlying
stream at most once if necessary.
"""
int avail = count-pos;
if( avail <= 0 ) {
if(len>=buf.length) {
// read a chunk to user buffer directly; avoid one copy
int nread = readChecksumChunk(b, off, len);
return nread;
} else {
// read a chunk into the local buffer
fill();
if( count <= 0 ) {
return -1;
} else {
avail = count;
}
}
}
// copy content of the local buffer to the user buffer
int cnt = (avail < len) ? avail : len;
System.arraycopy(buf, pos, b, off, cnt);
pos += cnt;
return cnt;
} | java | private int read1(byte b[], int off, int len)
throws IOException {
int avail = count-pos;
if( avail <= 0 ) {
if(len>=buf.length) {
// read a chunk to user buffer directly; avoid one copy
int nread = readChecksumChunk(b, off, len);
return nread;
} else {
// read a chunk into the local buffer
fill();
if( count <= 0 ) {
return -1;
} else {
avail = count;
}
}
}
// copy content of the local buffer to the user buffer
int cnt = (avail < len) ? avail : len;
System.arraycopy(buf, pos, b, off, cnt);
pos += cnt;
return cnt;
} | [
"private",
"int",
"read1",
"(",
"byte",
"b",
"[",
"]",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"int",
"avail",
"=",
"count",
"-",
"pos",
";",
"if",
"(",
"avail",
"<=",
"0",
")",
"{",
"if",
"(",
"len",
">=",
"buf",
".",
"length",
")",
"{",
"// read a chunk to user buffer directly; avoid one copy",
"int",
"nread",
"=",
"readChecksumChunk",
"(",
"b",
",",
"off",
",",
"len",
")",
";",
"return",
"nread",
";",
"}",
"else",
"{",
"// read a chunk into the local buffer",
"fill",
"(",
")",
";",
"if",
"(",
"count",
"<=",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"{",
"avail",
"=",
"count",
";",
"}",
"}",
"}",
"// copy content of the local buffer to the user buffer",
"int",
"cnt",
"=",
"(",
"avail",
"<",
"len",
")",
"?",
"avail",
":",
"len",
";",
"System",
".",
"arraycopy",
"(",
"buf",
",",
"pos",
",",
"b",
",",
"off",
",",
"cnt",
")",
";",
"pos",
"+=",
"cnt",
";",
"return",
"cnt",
";",
"}"
] | /*
Read characters into a portion of an array, reading from the underlying
stream at most once if necessary. | [
"/",
"*",
"Read",
"characters",
"into",
"a",
"portion",
"of",
"an",
"array",
"reading",
"from",
"the",
"underlying",
"stream",
"at",
"most",
"once",
"if",
"necessary",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/fs/FSInputChecker.java#L183-L207 |
Teddy-Zhu/SilentGo | framework/src/main/java/com/silentgo/servlet/oreilly/multipart/FilePart.java | FilePart.writeTo | public long writeTo(File fileOrDirectory) throws IOException {
"""
Write this file part to a file or directory. If the user
supplied a file, we write it to that file, and if they supplied
a directory, we write it to that directory with the filename
that accompanied it. If this part doesn't contain a file this
method does nothing.
@return number of bytes written
@exception IOException if an input or output exception has occurred.
"""
long written = 0;
OutputStream fileOut = null;
try {
// Only do something if this part contains a file
if (fileName != null) {
// Check if user supplied directory
File file;
if (fileOrDirectory.isDirectory()) {
// Write it to that dir the user supplied,
// with the filename it arrived with
file = new File(fileOrDirectory, fileName);
}
else {
// Write it to the file the user supplied,
// ignoring the filename it arrived with
file = fileOrDirectory;
}
if (policy != null) {
file = policy.rename(file);
fileName = file.getName();
}
fileOut = new BufferedOutputStream(new FileOutputStream(file));
written = write(fileOut);
}
}
finally {
if (fileOut != null) fileOut.close();
}
return written;
} | java | public long writeTo(File fileOrDirectory) throws IOException {
long written = 0;
OutputStream fileOut = null;
try {
// Only do something if this part contains a file
if (fileName != null) {
// Check if user supplied directory
File file;
if (fileOrDirectory.isDirectory()) {
// Write it to that dir the user supplied,
// with the filename it arrived with
file = new File(fileOrDirectory, fileName);
}
else {
// Write it to the file the user supplied,
// ignoring the filename it arrived with
file = fileOrDirectory;
}
if (policy != null) {
file = policy.rename(file);
fileName = file.getName();
}
fileOut = new BufferedOutputStream(new FileOutputStream(file));
written = write(fileOut);
}
}
finally {
if (fileOut != null) fileOut.close();
}
return written;
} | [
"public",
"long",
"writeTo",
"(",
"File",
"fileOrDirectory",
")",
"throws",
"IOException",
"{",
"long",
"written",
"=",
"0",
";",
"OutputStream",
"fileOut",
"=",
"null",
";",
"try",
"{",
"// Only do something if this part contains a file",
"if",
"(",
"fileName",
"!=",
"null",
")",
"{",
"// Check if user supplied directory",
"File",
"file",
";",
"if",
"(",
"fileOrDirectory",
".",
"isDirectory",
"(",
")",
")",
"{",
"// Write it to that dir the user supplied, ",
"// with the filename it arrived with",
"file",
"=",
"new",
"File",
"(",
"fileOrDirectory",
",",
"fileName",
")",
";",
"}",
"else",
"{",
"// Write it to the file the user supplied,",
"// ignoring the filename it arrived with",
"file",
"=",
"fileOrDirectory",
";",
"}",
"if",
"(",
"policy",
"!=",
"null",
")",
"{",
"file",
"=",
"policy",
".",
"rename",
"(",
"file",
")",
";",
"fileName",
"=",
"file",
".",
"getName",
"(",
")",
";",
"}",
"fileOut",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
";",
"written",
"=",
"write",
"(",
"fileOut",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"fileOut",
"!=",
"null",
")",
"fileOut",
".",
"close",
"(",
")",
";",
"}",
"return",
"written",
";",
"}"
] | Write this file part to a file or directory. If the user
supplied a file, we write it to that file, and if they supplied
a directory, we write it to that directory with the filename
that accompanied it. If this part doesn't contain a file this
method does nothing.
@return number of bytes written
@exception IOException if an input or output exception has occurred. | [
"Write",
"this",
"file",
"part",
"to",
"a",
"file",
"or",
"directory",
".",
"If",
"the",
"user",
"supplied",
"a",
"file",
"we",
"write",
"it",
"to",
"that",
"file",
"and",
"if",
"they",
"supplied",
"a",
"directory",
"we",
"write",
"it",
"to",
"that",
"directory",
"with",
"the",
"filename",
"that",
"accompanied",
"it",
".",
"If",
"this",
"part",
"doesn",
"t",
"contain",
"a",
"file",
"this",
"method",
"does",
"nothing",
"."
] | train | https://github.com/Teddy-Zhu/SilentGo/blob/27f58b0cafe56b2eb9fc6993efa9ca2b529661e1/framework/src/main/java/com/silentgo/servlet/oreilly/multipart/FilePart.java#L143-L174 |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/types/Timebase.java | Timebase.resample | public long resample(final long samples, final Timebase oldRate, boolean failOnPrecisionLoss) throws ResamplingException {
"""
Convert a sample count from one timebase to another<br />
Note that this may result in data loss due to rounding.
@param samples
@param oldRate
@param failOnPrecisionLoss
if true, precision losing operations will fail by throwing a PrecisionLostException
@return
"""
final double resampled = resample((double) samples, oldRate);
final double rounded = Math.round(resampled);
// Warn about significant loss of precision
if (resampled != rounded && Math.abs(rounded - resampled) > 0.000001)
{
if (failOnPrecisionLoss)
{
throw new ResamplingException("Resample " +
samples +
" from " +
oldRate +
" to " +
this +
" would lose precision by rounding " +
resampled);
}
else
{
if (WARN_ON_PRECISION_LOSS)
log.warn("Resample operation lost precision: " +
samples +
" from " +
oldRate +
" to " +
this +
" produced " +
resampled +
" which will be rounded to " +
rounded);
}
}
return (long) rounded;
} | java | public long resample(final long samples, final Timebase oldRate, boolean failOnPrecisionLoss) throws ResamplingException
{
final double resampled = resample((double) samples, oldRate);
final double rounded = Math.round(resampled);
// Warn about significant loss of precision
if (resampled != rounded && Math.abs(rounded - resampled) > 0.000001)
{
if (failOnPrecisionLoss)
{
throw new ResamplingException("Resample " +
samples +
" from " +
oldRate +
" to " +
this +
" would lose precision by rounding " +
resampled);
}
else
{
if (WARN_ON_PRECISION_LOSS)
log.warn("Resample operation lost precision: " +
samples +
" from " +
oldRate +
" to " +
this +
" produced " +
resampled +
" which will be rounded to " +
rounded);
}
}
return (long) rounded;
} | [
"public",
"long",
"resample",
"(",
"final",
"long",
"samples",
",",
"final",
"Timebase",
"oldRate",
",",
"boolean",
"failOnPrecisionLoss",
")",
"throws",
"ResamplingException",
"{",
"final",
"double",
"resampled",
"=",
"resample",
"(",
"(",
"double",
")",
"samples",
",",
"oldRate",
")",
";",
"final",
"double",
"rounded",
"=",
"Math",
".",
"round",
"(",
"resampled",
")",
";",
"// Warn about significant loss of precision",
"if",
"(",
"resampled",
"!=",
"rounded",
"&&",
"Math",
".",
"abs",
"(",
"rounded",
"-",
"resampled",
")",
">",
"0.000001",
")",
"{",
"if",
"(",
"failOnPrecisionLoss",
")",
"{",
"throw",
"new",
"ResamplingException",
"(",
"\"Resample \"",
"+",
"samples",
"+",
"\" from \"",
"+",
"oldRate",
"+",
"\" to \"",
"+",
"this",
"+",
"\" would lose precision by rounding \"",
"+",
"resampled",
")",
";",
"}",
"else",
"{",
"if",
"(",
"WARN_ON_PRECISION_LOSS",
")",
"log",
".",
"warn",
"(",
"\"Resample operation lost precision: \"",
"+",
"samples",
"+",
"\" from \"",
"+",
"oldRate",
"+",
"\" to \"",
"+",
"this",
"+",
"\" produced \"",
"+",
"resampled",
"+",
"\" which will be rounded to \"",
"+",
"rounded",
")",
";",
"}",
"}",
"return",
"(",
"long",
")",
"rounded",
";",
"}"
] | Convert a sample count from one timebase to another<br />
Note that this may result in data loss due to rounding.
@param samples
@param oldRate
@param failOnPrecisionLoss
if true, precision losing operations will fail by throwing a PrecisionLostException
@return | [
"Convert",
"a",
"sample",
"count",
"from",
"one",
"timebase",
"to",
"another<br",
"/",
">",
"Note",
"that",
"this",
"may",
"result",
"in",
"data",
"loss",
"due",
"to",
"rounding",
"."
] | train | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/types/Timebase.java#L200-L236 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java | ArrayUtil.removeBlank | public static <T extends CharSequence> T[] removeBlank(T[] array) {
"""
去除{@code null}或者""或者空白字符串 元素
@param array 数组
@return 处理后的数组
@since 3.2.2
"""
return filter(array, new Filter<T>() {
@Override
public boolean accept(T t) {
return false == StrUtil.isBlank(t);
}
});
} | java | public static <T extends CharSequence> T[] removeBlank(T[] array) {
return filter(array, new Filter<T>() {
@Override
public boolean accept(T t) {
return false == StrUtil.isBlank(t);
}
});
} | [
"public",
"static",
"<",
"T",
"extends",
"CharSequence",
">",
"T",
"[",
"]",
"removeBlank",
"(",
"T",
"[",
"]",
"array",
")",
"{",
"return",
"filter",
"(",
"array",
",",
"new",
"Filter",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"T",
"t",
")",
"{",
"return",
"false",
"==",
"StrUtil",
".",
"isBlank",
"(",
"t",
")",
";",
"}",
"}",
")",
";",
"}"
] | 去除{@code null}或者""或者空白字符串 元素
@param array 数组
@return 处理后的数组
@since 3.2.2 | [
"去除",
"{",
"@code",
"null",
"}",
"或者",
"或者空白字符串",
"元素"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java#L814-L821 |
couchbase/couchbase-lite-java-core | src/main/java/com/couchbase/lite/store/SQLiteViewStore.java | SQLiteViewStore.groupKey | public static Object groupKey(Object key, int groupLevel) {
"""
Returns the prefix of the key to use in the result row, at this groupLevel
"""
if (groupLevel > 0 && (key instanceof List) && (((List<Object>) key).size() > groupLevel)) {
return ((List<Object>) key).subList(0, groupLevel);
} else {
return key;
}
} | java | public static Object groupKey(Object key, int groupLevel) {
if (groupLevel > 0 && (key instanceof List) && (((List<Object>) key).size() > groupLevel)) {
return ((List<Object>) key).subList(0, groupLevel);
} else {
return key;
}
} | [
"public",
"static",
"Object",
"groupKey",
"(",
"Object",
"key",
",",
"int",
"groupLevel",
")",
"{",
"if",
"(",
"groupLevel",
">",
"0",
"&&",
"(",
"key",
"instanceof",
"List",
")",
"&&",
"(",
"(",
"(",
"List",
"<",
"Object",
">",
")",
"key",
")",
".",
"size",
"(",
")",
">",
"groupLevel",
")",
")",
"{",
"return",
"(",
"(",
"List",
"<",
"Object",
">",
")",
"key",
")",
".",
"subList",
"(",
"0",
",",
"groupLevel",
")",
";",
"}",
"else",
"{",
"return",
"key",
";",
"}",
"}"
] | Returns the prefix of the key to use in the result row, at this groupLevel | [
"Returns",
"the",
"prefix",
"of",
"the",
"key",
"to",
"use",
"in",
"the",
"result",
"row",
"at",
"this",
"groupLevel"
] | train | https://github.com/couchbase/couchbase-lite-java-core/blob/3b275642e2d2f231fd155ad9def9c5e9eff3118e/src/main/java/com/couchbase/lite/store/SQLiteViewStore.java#L1138-L1144 |
QSFT/Doradus | doradus-common/src/main/java/com/dell/doradus/common/Utils.java | Utils.toHexBytes | public static String toHexBytes(byte[] bytes, int offset, int length) {
"""
Converts the given bytes into a hexadecimal representation. bytes[offset] through
bytes[offset + length - 1] are converted, although the given array's length is
never exceeded.
@param offset Index of first byte to convert.
@param length Number of bytes to convert.
@param bytes Source bytes.
@return Hexadecimal string.
"""
StringBuilder builder = new StringBuilder();
for (int index = offset; index < bytes.length && index < (offset + length); index++) {
byte b = bytes[index];
int first = (b >> 4) & 15;
int second = b & 15;
builder.append(hexChars.charAt(first)).append(hexChars.charAt(second));
}
return builder.toString();
} | java | public static String toHexBytes(byte[] bytes, int offset, int length) {
StringBuilder builder = new StringBuilder();
for (int index = offset; index < bytes.length && index < (offset + length); index++) {
byte b = bytes[index];
int first = (b >> 4) & 15;
int second = b & 15;
builder.append(hexChars.charAt(first)).append(hexChars.charAt(second));
}
return builder.toString();
} | [
"public",
"static",
"String",
"toHexBytes",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"index",
"=",
"offset",
";",
"index",
"<",
"bytes",
".",
"length",
"&&",
"index",
"<",
"(",
"offset",
"+",
"length",
")",
";",
"index",
"++",
")",
"{",
"byte",
"b",
"=",
"bytes",
"[",
"index",
"]",
";",
"int",
"first",
"=",
"(",
"b",
">>",
"4",
")",
"&",
"15",
";",
"int",
"second",
"=",
"b",
"&",
"15",
";",
"builder",
".",
"append",
"(",
"hexChars",
".",
"charAt",
"(",
"first",
")",
")",
".",
"append",
"(",
"hexChars",
".",
"charAt",
"(",
"second",
")",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | Converts the given bytes into a hexadecimal representation. bytes[offset] through
bytes[offset + length - 1] are converted, although the given array's length is
never exceeded.
@param offset Index of first byte to convert.
@param length Number of bytes to convert.
@param bytes Source bytes.
@return Hexadecimal string. | [
"Converts",
"the",
"given",
"bytes",
"into",
"a",
"hexadecimal",
"representation",
".",
"bytes",
"[",
"offset",
"]",
"through",
"bytes",
"[",
"offset",
"+",
"length",
"-",
"1",
"]",
"are",
"converted",
"although",
"the",
"given",
"array",
"s",
"length",
"is",
"never",
"exceeded",
"."
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/Utils.java#L673-L682 |
zaproxy/zaproxy | src/org/zaproxy/zap/extension/help/ExtensionHelp.java | ExtensionHelp.enableHelpKey | public static void enableHelpKey (Component component, String id) {
"""
Enables the help for the given component using the given help page ID.
<p>
The help page is shown when the help keyboard shortcut (F1) is pressed, while the component is focused.
@param component the component that will have a help page assigned
@param id the ID of the help page
"""
if (component instanceof JComponent) {
JComponent jComponent = (JComponent) component;
if (componentsWithHelp == null) {
componentsWithHelp = new WeakHashMap<>();
}
componentsWithHelp.put(jComponent, id);
}
if (hb != null) {
hb.enableHelp(component, id, hs);
}
} | java | public static void enableHelpKey (Component component, String id) {
if (component instanceof JComponent) {
JComponent jComponent = (JComponent) component;
if (componentsWithHelp == null) {
componentsWithHelp = new WeakHashMap<>();
}
componentsWithHelp.put(jComponent, id);
}
if (hb != null) {
hb.enableHelp(component, id, hs);
}
} | [
"public",
"static",
"void",
"enableHelpKey",
"(",
"Component",
"component",
",",
"String",
"id",
")",
"{",
"if",
"(",
"component",
"instanceof",
"JComponent",
")",
"{",
"JComponent",
"jComponent",
"=",
"(",
"JComponent",
")",
"component",
";",
"if",
"(",
"componentsWithHelp",
"==",
"null",
")",
"{",
"componentsWithHelp",
"=",
"new",
"WeakHashMap",
"<>",
"(",
")",
";",
"}",
"componentsWithHelp",
".",
"put",
"(",
"jComponent",
",",
"id",
")",
";",
"}",
"if",
"(",
"hb",
"!=",
"null",
")",
"{",
"hb",
".",
"enableHelp",
"(",
"component",
",",
"id",
",",
"hs",
")",
";",
"}",
"}"
] | Enables the help for the given component using the given help page ID.
<p>
The help page is shown when the help keyboard shortcut (F1) is pressed, while the component is focused.
@param component the component that will have a help page assigned
@param id the ID of the help page | [
"Enables",
"the",
"help",
"for",
"the",
"given",
"component",
"using",
"the",
"given",
"help",
"page",
"ID",
".",
"<p",
">",
"The",
"help",
"page",
"is",
"shown",
"when",
"the",
"help",
"keyboard",
"shortcut",
"(",
"F1",
")",
"is",
"pressed",
"while",
"the",
"component",
"is",
"focused",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/help/ExtensionHelp.java#L383-L395 |
xhsun/gw2wrapper | src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java | AsynchronousRequest.getLegendInfo | public void getLegendInfo(String[] ids, Callback<List<Legend>> callback) throws GuildWars2Exception, NullPointerException {
"""
For more info on legends API go <a href="https://wiki.guildwars2.com/wiki/API:2/legends">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of legend id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Legend legend info
"""
isParamValid(new ParamChecker(ids));
gw2API.getLegendInfo(processIds(ids)).enqueue(callback);
} | java | public void getLegendInfo(String[] ids, Callback<List<Legend>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getLegendInfo(processIds(ids)).enqueue(callback);
} | [
"public",
"void",
"getLegendInfo",
"(",
"String",
"[",
"]",
"ids",
",",
"Callback",
"<",
"List",
"<",
"Legend",
">",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ids",
")",
")",
";",
"gw2API",
".",
"getLegendInfo",
"(",
"processIds",
"(",
"ids",
")",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] | For more info on legends API go <a href="https://wiki.guildwars2.com/wiki/API:2/legends">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of legend id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Legend legend info | [
"For",
"more",
"info",
"on",
"legends",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"legends",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Give",
"user",
"the",
"access",
"to",
"{",
"@link",
"Callback#onResponse",
"(",
"Call",
"Response",
")",
"}",
"and",
"{",
"@link",
"Callback#onFailure",
"(",
"Call",
"Throwable",
")",
"}",
"methods",
"for",
"custom",
"interactions"
] | train | https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L1747-L1750 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/UtilColor.java | UtilColor.getWeightedColor | public static ColorRgba getWeightedColor(ImageBuffer surface, int sx, int sy, int width, int height) {
"""
Get the weighted color of an area.
@param surface The surface reference (must not be <code>null</code>).
@param sx The starting horizontal location.
@param sy The starting vertical location.
@param width The area width.
@param height The area height.
@return The weighted color.
"""
Check.notNull(surface);
int r = 0;
int g = 0;
int b = 0;
int count = 0;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
final ColorRgba color = new ColorRgba(surface.getRgb(sx + x, sy + y));
if (color.getAlpha() > 0)
{
r += color.getRed();
g += color.getGreen();
b += color.getBlue();
count++;
}
}
}
if (count == 0)
{
return ColorRgba.TRANSPARENT;
}
return new ColorRgba((int) Math.floor(r / (double) count),
(int) Math.floor(g / (double) count),
(int) Math.floor(b / (double) count));
} | java | public static ColorRgba getWeightedColor(ImageBuffer surface, int sx, int sy, int width, int height)
{
Check.notNull(surface);
int r = 0;
int g = 0;
int b = 0;
int count = 0;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
final ColorRgba color = new ColorRgba(surface.getRgb(sx + x, sy + y));
if (color.getAlpha() > 0)
{
r += color.getRed();
g += color.getGreen();
b += color.getBlue();
count++;
}
}
}
if (count == 0)
{
return ColorRgba.TRANSPARENT;
}
return new ColorRgba((int) Math.floor(r / (double) count),
(int) Math.floor(g / (double) count),
(int) Math.floor(b / (double) count));
} | [
"public",
"static",
"ColorRgba",
"getWeightedColor",
"(",
"ImageBuffer",
"surface",
",",
"int",
"sx",
",",
"int",
"sy",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"Check",
".",
"notNull",
"(",
"surface",
")",
";",
"int",
"r",
"=",
"0",
";",
"int",
"g",
"=",
"0",
";",
"int",
"b",
"=",
"0",
";",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"width",
";",
"x",
"++",
")",
"{",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"height",
";",
"y",
"++",
")",
"{",
"final",
"ColorRgba",
"color",
"=",
"new",
"ColorRgba",
"(",
"surface",
".",
"getRgb",
"(",
"sx",
"+",
"x",
",",
"sy",
"+",
"y",
")",
")",
";",
"if",
"(",
"color",
".",
"getAlpha",
"(",
")",
">",
"0",
")",
"{",
"r",
"+=",
"color",
".",
"getRed",
"(",
")",
";",
"g",
"+=",
"color",
".",
"getGreen",
"(",
")",
";",
"b",
"+=",
"color",
".",
"getBlue",
"(",
")",
";",
"count",
"++",
";",
"}",
"}",
"}",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"return",
"ColorRgba",
".",
"TRANSPARENT",
";",
"}",
"return",
"new",
"ColorRgba",
"(",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"r",
"/",
"(",
"double",
")",
"count",
")",
",",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"g",
"/",
"(",
"double",
")",
"count",
")",
",",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"b",
"/",
"(",
"double",
")",
"count",
")",
")",
";",
"}"
] | Get the weighted color of an area.
@param surface The surface reference (must not be <code>null</code>).
@param sx The starting horizontal location.
@param sy The starting vertical location.
@param width The area width.
@param height The area height.
@return The weighted color. | [
"Get",
"the",
"weighted",
"color",
"of",
"an",
"area",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/UtilColor.java#L119-L148 |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java | AuthenticationAPIClient.passwordlessWithSMS | @SuppressWarnings("WeakerAccess")
public ParameterizableRequest<Void, AuthenticationException> passwordlessWithSMS(@NonNull String phoneNumber, @NonNull PasswordlessType passwordlessType) {
"""
Start a passwordless flow with a <a href="https://auth0.com/docs/api/authentication#get-code-or-link">SMS</a>
By default it will try to authenticate using the "sms" connection.
Requires your Application to have the <b>Resource Owner</b> Legacy Grant Type enabled. See <a href="https://auth0.com/docs/clients/client-grant-types">Client Grant Types</a> to learn how to enable it.
Example usage:
<pre>
{@code
client.passwordlessWithSms("{phone number}", PasswordlessType.CODE)
.start(new BaseCallback<Void>() {
{@literal}Override
public void onSuccess(Void payload) {}
{@literal}Override
public void onFailure(AuthenticationException error) {}
});
}
</pre>
@param phoneNumber where an SMS with a verification code will be sent
@param passwordlessType indicate whether the SMS should contain a code, link or magic link (android {@literal &} iOS)
@return a request to configure and start
"""
return passwordlessWithSMS(phoneNumber, passwordlessType, SMS_CONNECTION);
} | java | @SuppressWarnings("WeakerAccess")
public ParameterizableRequest<Void, AuthenticationException> passwordlessWithSMS(@NonNull String phoneNumber, @NonNull PasswordlessType passwordlessType) {
return passwordlessWithSMS(phoneNumber, passwordlessType, SMS_CONNECTION);
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"ParameterizableRequest",
"<",
"Void",
",",
"AuthenticationException",
">",
"passwordlessWithSMS",
"(",
"@",
"NonNull",
"String",
"phoneNumber",
",",
"@",
"NonNull",
"PasswordlessType",
"passwordlessType",
")",
"{",
"return",
"passwordlessWithSMS",
"(",
"phoneNumber",
",",
"passwordlessType",
",",
"SMS_CONNECTION",
")",
";",
"}"
] | Start a passwordless flow with a <a href="https://auth0.com/docs/api/authentication#get-code-or-link">SMS</a>
By default it will try to authenticate using the "sms" connection.
Requires your Application to have the <b>Resource Owner</b> Legacy Grant Type enabled. See <a href="https://auth0.com/docs/clients/client-grant-types">Client Grant Types</a> to learn how to enable it.
Example usage:
<pre>
{@code
client.passwordlessWithSms("{phone number}", PasswordlessType.CODE)
.start(new BaseCallback<Void>() {
{@literal}Override
public void onSuccess(Void payload) {}
{@literal}Override
public void onFailure(AuthenticationException error) {}
});
}
</pre>
@param phoneNumber where an SMS with a verification code will be sent
@param passwordlessType indicate whether the SMS should contain a code, link or magic link (android {@literal &} iOS)
@return a request to configure and start | [
"Start",
"a",
"passwordless",
"flow",
"with",
"a",
"<a",
"href",
"=",
"https",
":",
"//",
"auth0",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"authentication#get",
"-",
"code",
"-",
"or",
"-",
"link",
">",
"SMS<",
"/",
"a",
">",
"By",
"default",
"it",
"will",
"try",
"to",
"authenticate",
"using",
"the",
"sms",
"connection",
".",
"Requires",
"your",
"Application",
"to",
"have",
"the",
"<b",
">",
"Resource",
"Owner<",
"/",
"b",
">",
"Legacy",
"Grant",
"Type",
"enabled",
".",
"See",
"<a",
"href",
"=",
"https",
":",
"//",
"auth0",
".",
"com",
"/",
"docs",
"/",
"clients",
"/",
"client",
"-",
"grant",
"-",
"types",
">",
"Client",
"Grant",
"Types<",
"/",
"a",
">",
"to",
"learn",
"how",
"to",
"enable",
"it",
".",
"Example",
"usage",
":",
"<pre",
">",
"{",
"@code",
"client",
".",
"passwordlessWithSms",
"(",
"{",
"phone",
"number",
"}",
"PasswordlessType",
".",
"CODE",
")",
".",
"start",
"(",
"new",
"BaseCallback<Void",
">",
"()",
"{",
"{",
"@literal",
"}",
"Override",
"public",
"void",
"onSuccess",
"(",
"Void",
"payload",
")",
"{}"
] | train | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.java#L946-L949 |
rythmengine/rythmengine | src/main/java/org/rythmengine/toString/ToStringStyle.java | ToStringStyle.appendSummarySize | protected void appendSummarySize(StringBuilder buffer, String fieldName, int size) {
"""
<p>Append to the <code>toString</code> a size summary.</p>
<p/>
<p>The size summary is used to summarize the contents of
<code>Collections</code>, <code>Maps</code> and arrays.</p>
<p/>
<p>The output consists of a prefix, the passed in size
and a suffix.</p>
<p/>
<p>The default format is <code>'<size=n>'<code>.</p>
@param buffer the <code>StringBuilder</code> to populate
@param fieldName the field name, typically not used as already appended
@param size the size to append
"""
buffer.append(sizeStartText);
buffer.append(size);
buffer.append(sizeEndText);
} | java | protected void appendSummarySize(StringBuilder buffer, String fieldName, int size) {
buffer.append(sizeStartText);
buffer.append(size);
buffer.append(sizeEndText);
} | [
"protected",
"void",
"appendSummarySize",
"(",
"StringBuilder",
"buffer",
",",
"String",
"fieldName",
",",
"int",
"size",
")",
"{",
"buffer",
".",
"append",
"(",
"sizeStartText",
")",
";",
"buffer",
".",
"append",
"(",
"size",
")",
";",
"buffer",
".",
"append",
"(",
"sizeEndText",
")",
";",
"}"
] | <p>Append to the <code>toString</code> a size summary.</p>
<p/>
<p>The size summary is used to summarize the contents of
<code>Collections</code>, <code>Maps</code> and arrays.</p>
<p/>
<p>The output consists of a prefix, the passed in size
and a suffix.</p>
<p/>
<p>The default format is <code>'<size=n>'<code>.</p>
@param buffer the <code>StringBuilder</code> to populate
@param fieldName the field name, typically not used as already appended
@param size the size to append | [
"<p",
">",
"Append",
"to",
"the",
"<code",
">",
"toString<",
"/",
"code",
">",
"a",
"size",
"summary",
".",
"<",
"/",
"p",
">",
"<p",
"/",
">",
"<p",
">",
"The",
"size",
"summary",
"is",
"used",
"to",
"summarize",
"the",
"contents",
"of",
"<code",
">",
"Collections<",
"/",
"code",
">",
"<code",
">",
"Maps<",
"/",
"code",
">",
"and",
"arrays",
".",
"<",
"/",
"p",
">",
"<p",
"/",
">",
"<p",
">",
"The",
"output",
"consists",
"of",
"a",
"prefix",
"the",
"passed",
"in",
"size",
"and",
"a",
"suffix",
".",
"<",
"/",
"p",
">",
"<p",
"/",
">",
"<p",
">",
"The",
"default",
"format",
"is",
"<code",
">",
"<",
";",
"size",
"=",
"n>",
";",
"<code",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/toString/ToStringStyle.java#L1550-L1554 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/TransformerImpl.java | TransformerImpl.setParameter | public void setParameter(String name, Object value) {
"""
Set a parameter for the transformation.
@param name The name of the parameter,
which may have a namespace URI.
@param value The value object. This can be any valid Java object
-- it's up to the processor to provide the proper
coersion to the object, or simply pass it on for use
in extensions.
"""
if (value == null) {
throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_SET_PARAM_VALUE, new Object[]{name}));
}
StringTokenizer tokenizer = new StringTokenizer(name, "{}", false);
try
{
// The first string might be the namespace, or it might be
// the local name, if the namespace is null.
String s1 = tokenizer.nextToken();
String s2 = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
if (null == m_userParams)
m_userParams = new Vector();
if (null == s2)
{
replaceOrPushUserParam(new QName(s1), XObject.create(value, getXPathContext()));
setParameter(s1, null, value);
}
else
{
replaceOrPushUserParam(new QName(s1, s2), XObject.create(value, getXPathContext()));
setParameter(s2, s1, value);
}
}
catch (java.util.NoSuchElementException nsee)
{
// Should throw some sort of an error.
}
} | java | public void setParameter(String name, Object value)
{
if (value == null) {
throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_SET_PARAM_VALUE, new Object[]{name}));
}
StringTokenizer tokenizer = new StringTokenizer(name, "{}", false);
try
{
// The first string might be the namespace, or it might be
// the local name, if the namespace is null.
String s1 = tokenizer.nextToken();
String s2 = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
if (null == m_userParams)
m_userParams = new Vector();
if (null == s2)
{
replaceOrPushUserParam(new QName(s1), XObject.create(value, getXPathContext()));
setParameter(s1, null, value);
}
else
{
replaceOrPushUserParam(new QName(s1, s2), XObject.create(value, getXPathContext()));
setParameter(s2, s1, value);
}
}
catch (java.util.NoSuchElementException nsee)
{
// Should throw some sort of an error.
}
} | [
"public",
"void",
"setParameter",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"XSLMessages",
".",
"createMessage",
"(",
"XSLTErrorResources",
".",
"ER_INVALID_SET_PARAM_VALUE",
",",
"new",
"Object",
"[",
"]",
"{",
"name",
"}",
")",
")",
";",
"}",
"StringTokenizer",
"tokenizer",
"=",
"new",
"StringTokenizer",
"(",
"name",
",",
"\"{}\"",
",",
"false",
")",
";",
"try",
"{",
"// The first string might be the namespace, or it might be ",
"// the local name, if the namespace is null.",
"String",
"s1",
"=",
"tokenizer",
".",
"nextToken",
"(",
")",
";",
"String",
"s2",
"=",
"tokenizer",
".",
"hasMoreTokens",
"(",
")",
"?",
"tokenizer",
".",
"nextToken",
"(",
")",
":",
"null",
";",
"if",
"(",
"null",
"==",
"m_userParams",
")",
"m_userParams",
"=",
"new",
"Vector",
"(",
")",
";",
"if",
"(",
"null",
"==",
"s2",
")",
"{",
"replaceOrPushUserParam",
"(",
"new",
"QName",
"(",
"s1",
")",
",",
"XObject",
".",
"create",
"(",
"value",
",",
"getXPathContext",
"(",
")",
")",
")",
";",
"setParameter",
"(",
"s1",
",",
"null",
",",
"value",
")",
";",
"}",
"else",
"{",
"replaceOrPushUserParam",
"(",
"new",
"QName",
"(",
"s1",
",",
"s2",
")",
",",
"XObject",
".",
"create",
"(",
"value",
",",
"getXPathContext",
"(",
")",
")",
")",
";",
"setParameter",
"(",
"s2",
",",
"s1",
",",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"java",
".",
"util",
".",
"NoSuchElementException",
"nsee",
")",
"{",
"// Should throw some sort of an error.",
"}",
"}"
] | Set a parameter for the transformation.
@param name The name of the parameter,
which may have a namespace URI.
@param value The value object. This can be any valid Java object
-- it's up to the processor to provide the proper
coersion to the object, or simply pass it on for use
in extensions. | [
"Set",
"a",
"parameter",
"for",
"the",
"transformation",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/transformer/TransformerImpl.java#L1416-L1452 |
ironjacamar/ironjacamar | deployers/src/main/java/org/ironjacamar/deployers/common/AbstractResourceAdapterDeployer.java | AbstractResourceAdapterDeployer.findAdminObject | private String findAdminObject(String className, Connector connector) {
"""
Find the AdminObject class
@param className The initial class name
@param connector The metadata
@return The AdminObject
"""
for (org.ironjacamar.common.api.metadata.spec.AdminObject ao :
connector.getResourceadapter().getAdminObjects())
{
if (className.equals(ao.getAdminobjectClass().getValue()) ||
className.equals(ao.getAdminobjectInterface().getValue()))
return ao.getAdminobjectClass().getValue();
}
return className;
} | java | private String findAdminObject(String className, Connector connector)
{
for (org.ironjacamar.common.api.metadata.spec.AdminObject ao :
connector.getResourceadapter().getAdminObjects())
{
if (className.equals(ao.getAdminobjectClass().getValue()) ||
className.equals(ao.getAdminobjectInterface().getValue()))
return ao.getAdminobjectClass().getValue();
}
return className;
} | [
"private",
"String",
"findAdminObject",
"(",
"String",
"className",
",",
"Connector",
"connector",
")",
"{",
"for",
"(",
"org",
".",
"ironjacamar",
".",
"common",
".",
"api",
".",
"metadata",
".",
"spec",
".",
"AdminObject",
"ao",
":",
"connector",
".",
"getResourceadapter",
"(",
")",
".",
"getAdminObjects",
"(",
")",
")",
"{",
"if",
"(",
"className",
".",
"equals",
"(",
"ao",
".",
"getAdminobjectClass",
"(",
")",
".",
"getValue",
"(",
")",
")",
"||",
"className",
".",
"equals",
"(",
"ao",
".",
"getAdminobjectInterface",
"(",
")",
".",
"getValue",
"(",
")",
")",
")",
"return",
"ao",
".",
"getAdminobjectClass",
"(",
")",
".",
"getValue",
"(",
")",
";",
"}",
"return",
"className",
";",
"}"
] | Find the AdminObject class
@param className The initial class name
@param connector The metadata
@return The AdminObject | [
"Find",
"the",
"AdminObject",
"class"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/deployers/src/main/java/org/ironjacamar/deployers/common/AbstractResourceAdapterDeployer.java#L672-L682 |
xhsun/gw2wrapper | src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java | AsynchronousRequest.getGuildLogInfo | public void getGuildLogInfo(String id, String api, Callback<List<GuildLog>> callback) throws GuildWars2Exception, NullPointerException {
"""
For more info on guild log API go <a href="https://wiki.guildwars2.com/wiki/API:2/guild/:id/log">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions<br/>
@param id guild id
@param api Guild leader's Guild Wars 2 API key
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws NullPointerException if given {@link Callback} is empty
@see GuildLog guild log info
"""
isParamValid(new ParamChecker(ParamType.GUILD, id), new ParamChecker(ParamType.API, api));
gw2API.getGuildLogInfo(id, api).enqueue(callback);
} | java | public void getGuildLogInfo(String id, String api, Callback<List<GuildLog>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ParamType.GUILD, id), new ParamChecker(ParamType.API, api));
gw2API.getGuildLogInfo(id, api).enqueue(callback);
} | [
"public",
"void",
"getGuildLogInfo",
"(",
"String",
"id",
",",
"String",
"api",
",",
"Callback",
"<",
"List",
"<",
"GuildLog",
">",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ParamType",
".",
"GUILD",
",",
"id",
")",
",",
"new",
"ParamChecker",
"(",
"ParamType",
".",
"API",
",",
"api",
")",
")",
";",
"gw2API",
".",
"getGuildLogInfo",
"(",
"id",
",",
"api",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] | For more info on guild log API go <a href="https://wiki.guildwars2.com/wiki/API:2/guild/:id/log">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions<br/>
@param id guild id
@param api Guild leader's Guild Wars 2 API key
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws NullPointerException if given {@link Callback} is empty
@see GuildLog guild log info | [
"For",
"more",
"info",
"on",
"guild",
"log",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"guild",
"/",
":",
"id",
"/",
"log",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Give",
"user",
"the",
"access",
"to",
"{",
"@link",
"Callback#onResponse",
"(",
"Call",
"Response",
")",
"}",
"and",
"{",
"@link",
"Callback#onFailure",
"(",
"Call",
"Throwable",
")",
"}",
"methods",
"for",
"custom",
"interactions<br",
"/",
">"
] | train | https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L1468-L1471 |
Axway/Grapes | server/src/main/java/org/axway/grapes/server/webapp/resources/ArtifactResource.java | ArtifactResource.getVersions | @GET
@Produces( {
"""
Returns the list of available versions of an artifact
This method is call via GET <grapes_url>/artifact/<gavc>/versions
@param gavc String
@return Response a list of versions in JSON or in HTML
"""MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
@Path("/{gavc}" + ServerAPI.GET_VERSIONS)
public Response getVersions(@PathParam("gavc") final String gavc){
if(LOG.isInfoEnabled()) {
LOG.info(String.format("Got a get artifact versions request [%s]", gavc));
}
final ListView view = new ListView("Versions View", "version");
final List<String> versions = getArtifactHandler().getArtifactVersions(gavc);
Collections.sort(versions);
view.addAll(versions);
return Response.ok(view).build();
} | java | @GET
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
@Path("/{gavc}" + ServerAPI.GET_VERSIONS)
public Response getVersions(@PathParam("gavc") final String gavc){
if(LOG.isInfoEnabled()) {
LOG.info(String.format("Got a get artifact versions request [%s]", gavc));
}
final ListView view = new ListView("Versions View", "version");
final List<String> versions = getArtifactHandler().getArtifactVersions(gavc);
Collections.sort(versions);
view.addAll(versions);
return Response.ok(view).build();
} | [
"@",
"GET",
"@",
"Produces",
"(",
"{",
"MediaType",
".",
"TEXT_HTML",
",",
"MediaType",
".",
"APPLICATION_JSON",
"}",
")",
"@",
"Path",
"(",
"\"/{gavc}\"",
"+",
"ServerAPI",
".",
"GET_VERSIONS",
")",
"public",
"Response",
"getVersions",
"(",
"@",
"PathParam",
"(",
"\"gavc\"",
")",
"final",
"String",
"gavc",
")",
"{",
"if",
"(",
"LOG",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Got a get artifact versions request [%s]\"",
",",
"gavc",
")",
")",
";",
"}",
"final",
"ListView",
"view",
"=",
"new",
"ListView",
"(",
"\"Versions View\"",
",",
"\"version\"",
")",
";",
"final",
"List",
"<",
"String",
">",
"versions",
"=",
"getArtifactHandler",
"(",
")",
".",
"getArtifactVersions",
"(",
"gavc",
")",
";",
"Collections",
".",
"sort",
"(",
"versions",
")",
";",
"view",
".",
"addAll",
"(",
"versions",
")",
";",
"return",
"Response",
".",
"ok",
"(",
"view",
")",
".",
"build",
"(",
")",
";",
"}"
] | Returns the list of available versions of an artifact
This method is call via GET <grapes_url>/artifact/<gavc>/versions
@param gavc String
@return Response a list of versions in JSON or in HTML | [
"Returns",
"the",
"list",
"of",
"available",
"versions",
"of",
"an",
"artifact",
"This",
"method",
"is",
"call",
"via",
"GET",
"<grapes_url",
">",
"/",
"artifact",
"/",
"<gavc",
">",
"/",
"versions"
] | train | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/server/src/main/java/org/axway/grapes/server/webapp/resources/ArtifactResource.java#L167-L182 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/FloatField.java | FloatField.doSetData | public int doSetData(Object data, boolean bDisplayOption, int iMoveMode) {
"""
Move this physical binary data to this field.
@param data The physical data to move to this field (must be Float raw data class).
@param bDisplayOption If true, display after setting the data.
@param iMoveMode The type of move.
@return an error code (0 if success).
"""
if ((data != null) && (!(data instanceof Float)))
return DBConstants.ERROR_RETURN;
return super.doSetData(data, bDisplayOption, iMoveMode);
} | java | public int doSetData(Object data, boolean bDisplayOption, int iMoveMode)
{
if ((data != null) && (!(data instanceof Float)))
return DBConstants.ERROR_RETURN;
return super.doSetData(data, bDisplayOption, iMoveMode);
} | [
"public",
"int",
"doSetData",
"(",
"Object",
"data",
",",
"boolean",
"bDisplayOption",
",",
"int",
"iMoveMode",
")",
"{",
"if",
"(",
"(",
"data",
"!=",
"null",
")",
"&&",
"(",
"!",
"(",
"data",
"instanceof",
"Float",
")",
")",
")",
"return",
"DBConstants",
".",
"ERROR_RETURN",
";",
"return",
"super",
".",
"doSetData",
"(",
"data",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"}"
] | Move this physical binary data to this field.
@param data The physical data to move to this field (must be Float raw data class).
@param bDisplayOption If true, display after setting the data.
@param iMoveMode The type of move.
@return an error code (0 if success). | [
"Move",
"this",
"physical",
"binary",
"data",
"to",
"this",
"field",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/FloatField.java#L263-L268 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/core/Parser.java | Parser.parseBlockComment | public static int parseBlockComment(final char[] query, int offset) {
"""
Test if the <tt>/</tt> character at <tt>offset</tt> starts a block comment, and return the
position of the last <tt>/</tt> character.
@param query query
@param offset start offset
@return position of the last <tt>/</tt> character
"""
if (offset + 1 < query.length && query[offset + 1] == '*') {
// /* /* */ */ nest, according to SQL spec
int level = 1;
for (offset += 2; offset < query.length; ++offset) {
switch (query[offset - 1]) {
case '*':
if (query[offset] == '/') {
--level;
++offset; // don't parse / in */* twice
}
break;
case '/':
if (query[offset] == '*') {
++level;
++offset; // don't parse * in /*/ twice
}
break;
default:
break;
}
if (level == 0) {
--offset; // reset position to last '/' char
break;
}
}
}
return offset;
} | java | public static int parseBlockComment(final char[] query, int offset) {
if (offset + 1 < query.length && query[offset + 1] == '*') {
// /* /* */ */ nest, according to SQL spec
int level = 1;
for (offset += 2; offset < query.length; ++offset) {
switch (query[offset - 1]) {
case '*':
if (query[offset] == '/') {
--level;
++offset; // don't parse / in */* twice
}
break;
case '/':
if (query[offset] == '*') {
++level;
++offset; // don't parse * in /*/ twice
}
break;
default:
break;
}
if (level == 0) {
--offset; // reset position to last '/' char
break;
}
}
}
return offset;
} | [
"public",
"static",
"int",
"parseBlockComment",
"(",
"final",
"char",
"[",
"]",
"query",
",",
"int",
"offset",
")",
"{",
"if",
"(",
"offset",
"+",
"1",
"<",
"query",
".",
"length",
"&&",
"query",
"[",
"offset",
"+",
"1",
"]",
"==",
"'",
"'",
")",
"{",
"// /* /* */ */ nest, according to SQL spec",
"int",
"level",
"=",
"1",
";",
"for",
"(",
"offset",
"+=",
"2",
";",
"offset",
"<",
"query",
".",
"length",
";",
"++",
"offset",
")",
"{",
"switch",
"(",
"query",
"[",
"offset",
"-",
"1",
"]",
")",
"{",
"case",
"'",
"'",
":",
"if",
"(",
"query",
"[",
"offset",
"]",
"==",
"'",
"'",
")",
"{",
"--",
"level",
";",
"++",
"offset",
";",
"// don't parse / in */* twice",
"}",
"break",
";",
"case",
"'",
"'",
":",
"if",
"(",
"query",
"[",
"offset",
"]",
"==",
"'",
"'",
")",
"{",
"++",
"level",
";",
"++",
"offset",
";",
"// don't parse * in /*/ twice",
"}",
"break",
";",
"default",
":",
"break",
";",
"}",
"if",
"(",
"level",
"==",
"0",
")",
"{",
"--",
"offset",
";",
"// reset position to last '/' char",
"break",
";",
"}",
"}",
"}",
"return",
"offset",
";",
"}"
] | Test if the <tt>/</tt> character at <tt>offset</tt> starts a block comment, and return the
position of the last <tt>/</tt> character.
@param query query
@param offset start offset
@return position of the last <tt>/</tt> character | [
"Test",
"if",
"the",
"<tt",
">",
"/",
"<",
"/",
"tt",
">",
"character",
"at",
"<tt",
">",
"offset<",
"/",
"tt",
">",
"starts",
"a",
"block",
"comment",
"and",
"return",
"the",
"position",
"of",
"the",
"last",
"<tt",
">",
"/",
"<",
"/",
"tt",
">",
"character",
"."
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/core/Parser.java#L523-L552 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/misc/PixelMath.java | PixelMath.boundImage | public static void boundImage( GrayS16 img , int min , int max ) {
"""
Bounds image pixels to be between these two values
@param img Image
@param min minimum value.
@param max maximum value.
"""
ImplPixelMath.boundImage(img,min,max);
} | java | public static void boundImage( GrayS16 img , int min , int max ) {
ImplPixelMath.boundImage(img,min,max);
} | [
"public",
"static",
"void",
"boundImage",
"(",
"GrayS16",
"img",
",",
"int",
"min",
",",
"int",
"max",
")",
"{",
"ImplPixelMath",
".",
"boundImage",
"(",
"img",
",",
"min",
",",
"max",
")",
";",
"}"
] | Bounds image pixels to be between these two values
@param img Image
@param min minimum value.
@param max maximum value. | [
"Bounds",
"image",
"pixels",
"to",
"be",
"between",
"these",
"two",
"values"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/PixelMath.java#L4391-L4393 |
tomgibara/bits | src/main/java/com/tomgibara/bits/LongBitStore.java | LongBitStore.writeBits | static void writeBits(WriteStream writer, long bits, int count) {
"""
not does not mask off the supplied long - that is responsibility of caller
"""
for (int i = (count - 1) & ~7; i >= 0; i -= 8) {
writer.writeByte((byte) (bits >>> i));
}
} | java | static void writeBits(WriteStream writer, long bits, int count) {
for (int i = (count - 1) & ~7; i >= 0; i -= 8) {
writer.writeByte((byte) (bits >>> i));
}
} | [
"static",
"void",
"writeBits",
"(",
"WriteStream",
"writer",
",",
"long",
"bits",
",",
"int",
"count",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"(",
"count",
"-",
"1",
")",
"&",
"~",
"7",
";",
"i",
">=",
"0",
";",
"i",
"-=",
"8",
")",
"{",
"writer",
".",
"writeByte",
"(",
"(",
"byte",
")",
"(",
"bits",
">>>",
"i",
")",
")",
";",
"}",
"}"
] | not does not mask off the supplied long - that is responsibility of caller | [
"not",
"does",
"not",
"mask",
"off",
"the",
"supplied",
"long",
"-",
"that",
"is",
"responsibility",
"of",
"caller"
] | train | https://github.com/tomgibara/bits/blob/56c32c0a30efd3d7c4e7c6600a0ca39e51eecc97/src/main/java/com/tomgibara/bits/LongBitStore.java#L58-L62 |
jbundle/jbundle | base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XBaseGridScreen.java | XBaseGridScreen.printControlStartForm | public void printControlStartForm(PrintWriter out, int iPrintOptions) {
"""
Display the start form in input format.
@param out The out stream.
@param iPrintOptions The view specific attributes.
"""
super.printControlStartForm(out, iPrintOptions);
BasePanel scrHeading = ((BaseGridScreen)this.getScreenField()).getReportHeading();
if (scrHeading != null)
{
out.println(Utility.startTag(XMLTags.HEADING));
scrHeading.printControl(out, iPrintOptions | HtmlConstants.HEADING_SCREEN);
out.println(Utility.endTag(XMLTags.HEADING));
}
Record record = ((BaseGridScreen)this.getScreenField()).getMainRecord();
if (record == null)
return;
String strRecordName = record.getTableNames(false);
if ((strRecordName == null) || (strRecordName.length() == 0))
strRecordName = "Record";
out.println(Utility.startTag(XMLTags.DETAIL + " name=\"" + strRecordName + "\""));
this.printHeadingFootingControls(out, iPrintOptions | HtmlConstants.HEADING_SCREEN);
} | java | public void printControlStartForm(PrintWriter out, int iPrintOptions)
{
super.printControlStartForm(out, iPrintOptions);
BasePanel scrHeading = ((BaseGridScreen)this.getScreenField()).getReportHeading();
if (scrHeading != null)
{
out.println(Utility.startTag(XMLTags.HEADING));
scrHeading.printControl(out, iPrintOptions | HtmlConstants.HEADING_SCREEN);
out.println(Utility.endTag(XMLTags.HEADING));
}
Record record = ((BaseGridScreen)this.getScreenField()).getMainRecord();
if (record == null)
return;
String strRecordName = record.getTableNames(false);
if ((strRecordName == null) || (strRecordName.length() == 0))
strRecordName = "Record";
out.println(Utility.startTag(XMLTags.DETAIL + " name=\"" + strRecordName + "\""));
this.printHeadingFootingControls(out, iPrintOptions | HtmlConstants.HEADING_SCREEN);
} | [
"public",
"void",
"printControlStartForm",
"(",
"PrintWriter",
"out",
",",
"int",
"iPrintOptions",
")",
"{",
"super",
".",
"printControlStartForm",
"(",
"out",
",",
"iPrintOptions",
")",
";",
"BasePanel",
"scrHeading",
"=",
"(",
"(",
"BaseGridScreen",
")",
"this",
".",
"getScreenField",
"(",
")",
")",
".",
"getReportHeading",
"(",
")",
";",
"if",
"(",
"scrHeading",
"!=",
"null",
")",
"{",
"out",
".",
"println",
"(",
"Utility",
".",
"startTag",
"(",
"XMLTags",
".",
"HEADING",
")",
")",
";",
"scrHeading",
".",
"printControl",
"(",
"out",
",",
"iPrintOptions",
"|",
"HtmlConstants",
".",
"HEADING_SCREEN",
")",
";",
"out",
".",
"println",
"(",
"Utility",
".",
"endTag",
"(",
"XMLTags",
".",
"HEADING",
")",
")",
";",
"}",
"Record",
"record",
"=",
"(",
"(",
"BaseGridScreen",
")",
"this",
".",
"getScreenField",
"(",
")",
")",
".",
"getMainRecord",
"(",
")",
";",
"if",
"(",
"record",
"==",
"null",
")",
"return",
";",
"String",
"strRecordName",
"=",
"record",
".",
"getTableNames",
"(",
"false",
")",
";",
"if",
"(",
"(",
"strRecordName",
"==",
"null",
")",
"||",
"(",
"strRecordName",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"strRecordName",
"=",
"\"Record\"",
";",
"out",
".",
"println",
"(",
"Utility",
".",
"startTag",
"(",
"XMLTags",
".",
"DETAIL",
"+",
"\" name=\\\"\"",
"+",
"strRecordName",
"+",
"\"\\\"\"",
")",
")",
";",
"this",
".",
"printHeadingFootingControls",
"(",
"out",
",",
"iPrintOptions",
"|",
"HtmlConstants",
".",
"HEADING_SCREEN",
")",
";",
"}"
] | Display the start form in input format.
@param out The out stream.
@param iPrintOptions The view specific attributes. | [
"Display",
"the",
"start",
"form",
"in",
"input",
"format",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XBaseGridScreen.java#L91-L111 |
spring-projects/spring-social-facebook | spring-social-facebook/src/main/java/org/springframework/social/facebook/api/FqlResult.java | FqlResult.getTime | public Date getTime(String fieldName) {
"""
Returns the value of the identified field as a Date.
Time fields returned from an FQL query are expressed in terms of seconds since midnight, January 1, 1970 UTC.
@param fieldName the name of the field
@return the value of the field as a Date
@throws FqlException if the field's value cannot be expressed as a long value from which a Date object can be constructed.
"""
try {
if (hasValue(fieldName)) {
return new Date(Long.valueOf(String.valueOf(resultMap.get(fieldName))) * 1000);
} else {
return null;
}
} catch (NumberFormatException e) {
throw new FqlException("Field '" + fieldName +"' is not a time.", e);
}
} | java | public Date getTime(String fieldName) {
try {
if (hasValue(fieldName)) {
return new Date(Long.valueOf(String.valueOf(resultMap.get(fieldName))) * 1000);
} else {
return null;
}
} catch (NumberFormatException e) {
throw new FqlException("Field '" + fieldName +"' is not a time.", e);
}
} | [
"public",
"Date",
"getTime",
"(",
"String",
"fieldName",
")",
"{",
"try",
"{",
"if",
"(",
"hasValue",
"(",
"fieldName",
")",
")",
"{",
"return",
"new",
"Date",
"(",
"Long",
".",
"valueOf",
"(",
"String",
".",
"valueOf",
"(",
"resultMap",
".",
"get",
"(",
"fieldName",
")",
")",
")",
"*",
"1000",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"throw",
"new",
"FqlException",
"(",
"\"Field '\"",
"+",
"fieldName",
"+",
"\"' is not a time.\"",
",",
"e",
")",
";",
"}",
"}"
] | Returns the value of the identified field as a Date.
Time fields returned from an FQL query are expressed in terms of seconds since midnight, January 1, 1970 UTC.
@param fieldName the name of the field
@return the value of the field as a Date
@throws FqlException if the field's value cannot be expressed as a long value from which a Date object can be constructed. | [
"Returns",
"the",
"value",
"of",
"the",
"identified",
"field",
"as",
"a",
"Date",
".",
"Time",
"fields",
"returned",
"from",
"an",
"FQL",
"query",
"are",
"expressed",
"in",
"terms",
"of",
"seconds",
"since",
"midnight",
"January",
"1",
"1970",
"UTC",
"."
] | train | https://github.com/spring-projects/spring-social-facebook/blob/ae2234d94367eaa3adbba251ec7790d5ba7ffa41/spring-social-facebook/src/main/java/org/springframework/social/facebook/api/FqlResult.java#L107-L117 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/BufferedInputStream.java | BufferedInputStream.read1 | private int read1(byte[] b, int off, int len) throws IOException {
"""
Read characters into a portion of an array, reading from the underlying
stream at most once if necessary.
"""
int avail = count - pos;
if (avail <= 0) {
/* If the requested length is at least as large as the buffer, and
if there is no mark/reset activity, do not bother to copy the
bytes into the local buffer. In this way buffered streams will
cascade harmlessly. */
if (len >= getBufIfOpen().length && markpos < 0) {
return getInIfOpen().read(b, off, len);
}
fill();
avail = count - pos;
if (avail <= 0) return -1;
}
int cnt = (avail < len) ? avail : len;
System.arraycopy(getBufIfOpen(), pos, b, off, cnt);
pos += cnt;
return cnt;
} | java | private int read1(byte[] b, int off, int len) throws IOException {
int avail = count - pos;
if (avail <= 0) {
/* If the requested length is at least as large as the buffer, and
if there is no mark/reset activity, do not bother to copy the
bytes into the local buffer. In this way buffered streams will
cascade harmlessly. */
if (len >= getBufIfOpen().length && markpos < 0) {
return getInIfOpen().read(b, off, len);
}
fill();
avail = count - pos;
if (avail <= 0) return -1;
}
int cnt = (avail < len) ? avail : len;
System.arraycopy(getBufIfOpen(), pos, b, off, cnt);
pos += cnt;
return cnt;
} | [
"private",
"int",
"read1",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"int",
"avail",
"=",
"count",
"-",
"pos",
";",
"if",
"(",
"avail",
"<=",
"0",
")",
"{",
"/* If the requested length is at least as large as the buffer, and\n if there is no mark/reset activity, do not bother to copy the\n bytes into the local buffer. In this way buffered streams will\n cascade harmlessly. */",
"if",
"(",
"len",
">=",
"getBufIfOpen",
"(",
")",
".",
"length",
"&&",
"markpos",
"<",
"0",
")",
"{",
"return",
"getInIfOpen",
"(",
")",
".",
"read",
"(",
"b",
",",
"off",
",",
"len",
")",
";",
"}",
"fill",
"(",
")",
";",
"avail",
"=",
"count",
"-",
"pos",
";",
"if",
"(",
"avail",
"<=",
"0",
")",
"return",
"-",
"1",
";",
"}",
"int",
"cnt",
"=",
"(",
"avail",
"<",
"len",
")",
"?",
"avail",
":",
"len",
";",
"System",
".",
"arraycopy",
"(",
"getBufIfOpen",
"(",
")",
",",
"pos",
",",
"b",
",",
"off",
",",
"cnt",
")",
";",
"pos",
"+=",
"cnt",
";",
"return",
"cnt",
";",
"}"
] | Read characters into a portion of an array, reading from the underlying
stream at most once if necessary. | [
"Read",
"characters",
"into",
"a",
"portion",
"of",
"an",
"array",
"reading",
"from",
"the",
"underlying",
"stream",
"at",
"most",
"once",
"if",
"necessary",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/BufferedInputStream.java#L283-L301 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.jaspic/src/com/ibm/ws/security/jaspi/JaspiServletFilter.java | JaspiServletFilter.doFilter | @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
"""
/*
If a JASPI provider returned request/response wrappers in the MessageInfo object then
use those wrappers instead of the original request/response objects for web request.
@see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
"""
HttpServletRequestWrapper reqestWrapper =
(HttpServletRequestWrapper) request.getAttribute("com.ibm.ws.security.jaspi.servlet.request.wrapper");
HttpServletResponseWrapper responseWrapper =
(HttpServletResponseWrapper) request.getAttribute("com.ibm.ws.security.jaspi.servlet.response.wrapper");
ServletRequest req = reqestWrapper != null ? reqestWrapper : request;
ServletResponse res = responseWrapper != null ? responseWrapper : response;
chain.doFilter(req, res);
} | java | @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequestWrapper reqestWrapper =
(HttpServletRequestWrapper) request.getAttribute("com.ibm.ws.security.jaspi.servlet.request.wrapper");
HttpServletResponseWrapper responseWrapper =
(HttpServletResponseWrapper) request.getAttribute("com.ibm.ws.security.jaspi.servlet.response.wrapper");
ServletRequest req = reqestWrapper != null ? reqestWrapper : request;
ServletResponse res = responseWrapper != null ? responseWrapper : response;
chain.doFilter(req, res);
} | [
"@",
"Override",
"public",
"void",
"doFilter",
"(",
"ServletRequest",
"request",
",",
"ServletResponse",
"response",
",",
"FilterChain",
"chain",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"HttpServletRequestWrapper",
"reqestWrapper",
"=",
"(",
"HttpServletRequestWrapper",
")",
"request",
".",
"getAttribute",
"(",
"\"com.ibm.ws.security.jaspi.servlet.request.wrapper\"",
")",
";",
"HttpServletResponseWrapper",
"responseWrapper",
"=",
"(",
"HttpServletResponseWrapper",
")",
"request",
".",
"getAttribute",
"(",
"\"com.ibm.ws.security.jaspi.servlet.response.wrapper\"",
")",
";",
"ServletRequest",
"req",
"=",
"reqestWrapper",
"!=",
"null",
"?",
"reqestWrapper",
":",
"request",
";",
"ServletResponse",
"res",
"=",
"responseWrapper",
"!=",
"null",
"?",
"responseWrapper",
":",
"response",
";",
"chain",
".",
"doFilter",
"(",
"req",
",",
"res",
")",
";",
"}"
] | /*
If a JASPI provider returned request/response wrappers in the MessageInfo object then
use those wrappers instead of the original request/response objects for web request.
@see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) | [
"/",
"*",
"If",
"a",
"JASPI",
"provider",
"returned",
"request",
"/",
"response",
"wrappers",
"in",
"the",
"MessageInfo",
"object",
"then",
"use",
"those",
"wrappers",
"instead",
"of",
"the",
"original",
"request",
"/",
"response",
"objects",
"for",
"web",
"request",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.jaspic/src/com/ibm/ws/security/jaspi/JaspiServletFilter.java#L47-L57 |
alkacon/opencms-core | src/org/opencms/jsp/Messages.java | Messages.getLocalizedMessage | public static String getLocalizedMessage(CmsMessageContainer container, PageContext context) {
"""
Returns the String for the given CmsMessageContainer localized to the current user's locale
if available or to the default locale else.
<p>
This method is needed for localization of non- {@link org.opencms.main.CmsException}
instances that have to be thrown here due to API constraints (javax.servlet.jsp).
<p>
@param container A CmsMessageContainer containing the message to localize.
@param context The page context that is known to any calling
{@link javax.servlet.jsp.tagext.TagSupport} instance (member
<code>pageContext</code>).
@return the String for the given CmsMessageContainer localized to the current user's locale
if available or to the default locale else.
<p>
"""
return Messages.getLocalizedMessage(container, context.getRequest());
} | java | public static String getLocalizedMessage(CmsMessageContainer container, PageContext context) {
return Messages.getLocalizedMessage(container, context.getRequest());
} | [
"public",
"static",
"String",
"getLocalizedMessage",
"(",
"CmsMessageContainer",
"container",
",",
"PageContext",
"context",
")",
"{",
"return",
"Messages",
".",
"getLocalizedMessage",
"(",
"container",
",",
"context",
".",
"getRequest",
"(",
")",
")",
";",
"}"
] | Returns the String for the given CmsMessageContainer localized to the current user's locale
if available or to the default locale else.
<p>
This method is needed for localization of non- {@link org.opencms.main.CmsException}
instances that have to be thrown here due to API constraints (javax.servlet.jsp).
<p>
@param container A CmsMessageContainer containing the message to localize.
@param context The page context that is known to any calling
{@link javax.servlet.jsp.tagext.TagSupport} instance (member
<code>pageContext</code>).
@return the String for the given CmsMessageContainer localized to the current user's locale
if available or to the default locale else.
<p> | [
"Returns",
"the",
"String",
"for",
"the",
"given",
"CmsMessageContainer",
"localized",
"to",
"the",
"current",
"user",
"s",
"locale",
"if",
"available",
"or",
"to",
"the",
"default",
"locale",
"else",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/Messages.java#L315-L318 |
windup/windup | rules-base/api/src/main/java/org/jboss/windup/rules/files/condition/FileContent.java | FileContent.fromInput | private void fromInput(List<FileModel> vertices, GraphRewrite event) {
"""
Generating the input vertices is quite complex. Therefore there are multiple methods that handles the input vertices based on the attribute
specified in specific order. This method handles the {@link FileContent#from(String)} attribute.
"""
if (vertices.isEmpty() && StringUtils.isNotBlank(getInputVariablesName()))
{
for (WindupVertexFrame windupVertexFrame : Variables.instance(event).findVariable(getInputVariablesName()))
{
if (windupVertexFrame instanceof FileModel)
vertices.add((FileModel) windupVertexFrame);
if (windupVertexFrame instanceof FileReferenceModel)
vertices.add(((FileReferenceModel) windupVertexFrame).getFile());
}
}
} | java | private void fromInput(List<FileModel> vertices, GraphRewrite event)
{
if (vertices.isEmpty() && StringUtils.isNotBlank(getInputVariablesName()))
{
for (WindupVertexFrame windupVertexFrame : Variables.instance(event).findVariable(getInputVariablesName()))
{
if (windupVertexFrame instanceof FileModel)
vertices.add((FileModel) windupVertexFrame);
if (windupVertexFrame instanceof FileReferenceModel)
vertices.add(((FileReferenceModel) windupVertexFrame).getFile());
}
}
} | [
"private",
"void",
"fromInput",
"(",
"List",
"<",
"FileModel",
">",
"vertices",
",",
"GraphRewrite",
"event",
")",
"{",
"if",
"(",
"vertices",
".",
"isEmpty",
"(",
")",
"&&",
"StringUtils",
".",
"isNotBlank",
"(",
"getInputVariablesName",
"(",
")",
")",
")",
"{",
"for",
"(",
"WindupVertexFrame",
"windupVertexFrame",
":",
"Variables",
".",
"instance",
"(",
"event",
")",
".",
"findVariable",
"(",
"getInputVariablesName",
"(",
")",
")",
")",
"{",
"if",
"(",
"windupVertexFrame",
"instanceof",
"FileModel",
")",
"vertices",
".",
"add",
"(",
"(",
"FileModel",
")",
"windupVertexFrame",
")",
";",
"if",
"(",
"windupVertexFrame",
"instanceof",
"FileReferenceModel",
")",
"vertices",
".",
"add",
"(",
"(",
"(",
"FileReferenceModel",
")",
"windupVertexFrame",
")",
".",
"getFile",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Generating the input vertices is quite complex. Therefore there are multiple methods that handles the input vertices based on the attribute
specified in specific order. This method handles the {@link FileContent#from(String)} attribute. | [
"Generating",
"the",
"input",
"vertices",
"is",
"quite",
"complex",
".",
"Therefore",
"there",
"are",
"multiple",
"methods",
"that",
"handles",
"the",
"input",
"vertices",
"based",
"on",
"the",
"attribute",
"specified",
"in",
"specific",
"order",
".",
"This",
"method",
"handles",
"the",
"{"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-base/api/src/main/java/org/jboss/windup/rules/files/condition/FileContent.java#L285-L297 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/jar/JarVerifier.java | JarVerifier.mapSignersToCodeSource | private synchronized CodeSource mapSignersToCodeSource(URL url, CodeSigner[] signers) {
"""
/*
Create a unique mapping from codeSigner cache entries to CodeSource.
In theory, multiple URLs origins could map to a single locally cached
and shared JAR file although in practice there will be a single URL in use.
"""
Map map;
if (url == lastURL) {
map = lastURLMap;
} else {
map = (Map) urlToCodeSourceMap.get(url);
if (map == null) {
map = new HashMap();
urlToCodeSourceMap.put(url, map);
}
lastURLMap = map;
lastURL = url;
}
CodeSource cs = (CodeSource) map.get(signers);
if (cs == null) {
cs = new VerifierCodeSource(csdomain, url, signers);
signerToCodeSource.put(signers, cs);
}
return cs;
} | java | private synchronized CodeSource mapSignersToCodeSource(URL url, CodeSigner[] signers) {
Map map;
if (url == lastURL) {
map = lastURLMap;
} else {
map = (Map) urlToCodeSourceMap.get(url);
if (map == null) {
map = new HashMap();
urlToCodeSourceMap.put(url, map);
}
lastURLMap = map;
lastURL = url;
}
CodeSource cs = (CodeSource) map.get(signers);
if (cs == null) {
cs = new VerifierCodeSource(csdomain, url, signers);
signerToCodeSource.put(signers, cs);
}
return cs;
} | [
"private",
"synchronized",
"CodeSource",
"mapSignersToCodeSource",
"(",
"URL",
"url",
",",
"CodeSigner",
"[",
"]",
"signers",
")",
"{",
"Map",
"map",
";",
"if",
"(",
"url",
"==",
"lastURL",
")",
"{",
"map",
"=",
"lastURLMap",
";",
"}",
"else",
"{",
"map",
"=",
"(",
"Map",
")",
"urlToCodeSourceMap",
".",
"get",
"(",
"url",
")",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"map",
"=",
"new",
"HashMap",
"(",
")",
";",
"urlToCodeSourceMap",
".",
"put",
"(",
"url",
",",
"map",
")",
";",
"}",
"lastURLMap",
"=",
"map",
";",
"lastURL",
"=",
"url",
";",
"}",
"CodeSource",
"cs",
"=",
"(",
"CodeSource",
")",
"map",
".",
"get",
"(",
"signers",
")",
";",
"if",
"(",
"cs",
"==",
"null",
")",
"{",
"cs",
"=",
"new",
"VerifierCodeSource",
"(",
"csdomain",
",",
"url",
",",
"signers",
")",
";",
"signerToCodeSource",
".",
"put",
"(",
"signers",
",",
"cs",
")",
";",
"}",
"return",
"cs",
";",
"}"
] | /*
Create a unique mapping from codeSigner cache entries to CodeSource.
In theory, multiple URLs origins could map to a single locally cached
and shared JAR file although in practice there will be a single URL in use. | [
"/",
"*",
"Create",
"a",
"unique",
"mapping",
"from",
"codeSigner",
"cache",
"entries",
"to",
"CodeSource",
".",
"In",
"theory",
"multiple",
"URLs",
"origins",
"could",
"map",
"to",
"a",
"single",
"locally",
"cached",
"and",
"shared",
"JAR",
"file",
"although",
"in",
"practice",
"there",
"will",
"be",
"a",
"single",
"URL",
"in",
"use",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/jar/JarVerifier.java#L528-L547 |
ManfredTremmel/gwt-bean-validators | mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/util/PhoneNumberUtil.java | PhoneNumberUtil.formatMs | public final String formatMs(final String pphoneNumber, final String pcountryCode) {
"""
format phone number in Microsoft canonical address format.
@param pphoneNumber phone number to format
@param pcountryCode iso code of country
@return formated phone number as String
"""
return this.formatMs(this.parsePhoneNumber(pphoneNumber, pcountryCode));
} | java | public final String formatMs(final String pphoneNumber, final String pcountryCode) {
return this.formatMs(this.parsePhoneNumber(pphoneNumber, pcountryCode));
} | [
"public",
"final",
"String",
"formatMs",
"(",
"final",
"String",
"pphoneNumber",
",",
"final",
"String",
"pcountryCode",
")",
"{",
"return",
"this",
".",
"formatMs",
"(",
"this",
".",
"parsePhoneNumber",
"(",
"pphoneNumber",
",",
"pcountryCode",
")",
")",
";",
"}"
] | format phone number in Microsoft canonical address format.
@param pphoneNumber phone number to format
@param pcountryCode iso code of country
@return formated phone number as String | [
"format",
"phone",
"number",
"in",
"Microsoft",
"canonical",
"address",
"format",
"."
] | train | https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/util/PhoneNumberUtil.java#L1171-L1173 |
eurekaclinical/datastore | src/main/java/org/eurekaclinical/datastore/bdb/BdbStoreFactory.java | BdbStoreFactory.createEnvironment | private Environment createEnvironment() {
"""
Creates a Berkeley DB database environment from the provided environment
configuration.
@return an environment instance.
@throws SecurityException if the directory for storing the databases
could not be created.
@throws EnvironmentNotFoundException if the environment does not exist
(does not contain at least one log file) and the EnvironmentConfig
AllowCreate parameter is false.
@throws EnvironmentLockedException when an environment cannot be opened
for write access because another process has the same environment open
for write access. Warning: This exception should be handled when an
environment is opened by more than one process.
@throws VersionMismatchException when the existing log is not compatible
with the version of JE that is running. This occurs when a later version
of JE was used to create the log. Warning: This exception should be
handled when more than one version of JE may be used to access an
environment.
@throws EnvironmentFailureException if an unexpected, internal or
environment-wide failure occurs.
@throws java.lang.UnsupportedOperationException if this environment was
previously opened for replication and is not being opened read-only.
@throws java.lang.IllegalArgumentException if an invalid parameter is
specified, for example, an invalid EnvironmentConfig parameter.
"""
EnvironmentConfig envConf = createEnvConfig();
if (!envFile.exists()) {
envFile.mkdirs();
}
LOGGER.log(Level.INFO,
"Initialized BerkeleyDB cache environment at {0}",
envFile.getAbsolutePath());
return new Environment(this.envFile, envConf);
} | java | private Environment createEnvironment() {
EnvironmentConfig envConf = createEnvConfig();
if (!envFile.exists()) {
envFile.mkdirs();
}
LOGGER.log(Level.INFO,
"Initialized BerkeleyDB cache environment at {0}",
envFile.getAbsolutePath());
return new Environment(this.envFile, envConf);
} | [
"private",
"Environment",
"createEnvironment",
"(",
")",
"{",
"EnvironmentConfig",
"envConf",
"=",
"createEnvConfig",
"(",
")",
";",
"if",
"(",
"!",
"envFile",
".",
"exists",
"(",
")",
")",
"{",
"envFile",
".",
"mkdirs",
"(",
")",
";",
"}",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Initialized BerkeleyDB cache environment at {0}\"",
",",
"envFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"return",
"new",
"Environment",
"(",
"this",
".",
"envFile",
",",
"envConf",
")",
";",
"}"
] | Creates a Berkeley DB database environment from the provided environment
configuration.
@return an environment instance.
@throws SecurityException if the directory for storing the databases
could not be created.
@throws EnvironmentNotFoundException if the environment does not exist
(does not contain at least one log file) and the EnvironmentConfig
AllowCreate parameter is false.
@throws EnvironmentLockedException when an environment cannot be opened
for write access because another process has the same environment open
for write access. Warning: This exception should be handled when an
environment is opened by more than one process.
@throws VersionMismatchException when the existing log is not compatible
with the version of JE that is running. This occurs when a later version
of JE was used to create the log. Warning: This exception should be
handled when more than one version of JE may be used to access an
environment.
@throws EnvironmentFailureException if an unexpected, internal or
environment-wide failure occurs.
@throws java.lang.UnsupportedOperationException if this environment was
previously opened for replication and is not being opened read-only.
@throws java.lang.IllegalArgumentException if an invalid parameter is
specified, for example, an invalid EnvironmentConfig parameter. | [
"Creates",
"a",
"Berkeley",
"DB",
"database",
"environment",
"from",
"the",
"provided",
"environment",
"configuration",
"."
] | train | https://github.com/eurekaclinical/datastore/blob/a03a70819bb562ba45eac66ca49f778035ee45e0/src/main/java/org/eurekaclinical/datastore/bdb/BdbStoreFactory.java#L244-L254 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_easyPabx_serviceName_PUT | public void billingAccount_easyPabx_serviceName_PUT(String billingAccount, String serviceName, OvhEasyPabx body) throws IOException {
"""
Alter this object properties
REST: PUT /telephony/{billingAccount}/easyPabx/{serviceName}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
"""
String qPath = "/telephony/{billingAccount}/easyPabx/{serviceName}";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void billingAccount_easyPabx_serviceName_PUT(String billingAccount, String serviceName, OvhEasyPabx body) throws IOException {
String qPath = "/telephony/{billingAccount}/easyPabx/{serviceName}";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"billingAccount_easyPabx_serviceName_PUT",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"OvhEasyPabx",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/easyPabx/{serviceName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /telephony/{billingAccount}/easyPabx/{serviceName}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L3649-L3653 |
gallandarakhneorg/afc | core/maths/mathgraph/src/main/java/org/arakhne/afc/math/graph/astar/AStar.java | AStar.solve | protected GP solve(AStarNode<ST, PT> startPoint, PT endPoint) {
"""
Run the A* algorithm assuming that the graph is oriented is
an orientation tool was passed to the constructor.
<p>The orientation of the graph may also be overridden by the implementations
of the {@link AStarNode A* nodes}.
@param startPoint is the starting point.
@param endPoint is the point to reach.
@return the found path, or <code>null</code> if none found.
"""
final List<AStarNode<ST, PT>> closeList;
fireAlgorithmStart(startPoint, endPoint);
// Run A*
closeList = findPath(startPoint, endPoint);
if (closeList == null || closeList.isEmpty()) {
return null;
}
fireAlgorithmEnd(closeList);
// Create the path
return createPath(startPoint, endPoint, closeList);
} | java | protected GP solve(AStarNode<ST, PT> startPoint, PT endPoint) {
final List<AStarNode<ST, PT>> closeList;
fireAlgorithmStart(startPoint, endPoint);
// Run A*
closeList = findPath(startPoint, endPoint);
if (closeList == null || closeList.isEmpty()) {
return null;
}
fireAlgorithmEnd(closeList);
// Create the path
return createPath(startPoint, endPoint, closeList);
} | [
"protected",
"GP",
"solve",
"(",
"AStarNode",
"<",
"ST",
",",
"PT",
">",
"startPoint",
",",
"PT",
"endPoint",
")",
"{",
"final",
"List",
"<",
"AStarNode",
"<",
"ST",
",",
"PT",
">",
">",
"closeList",
";",
"fireAlgorithmStart",
"(",
"startPoint",
",",
"endPoint",
")",
";",
"// Run A*",
"closeList",
"=",
"findPath",
"(",
"startPoint",
",",
"endPoint",
")",
";",
"if",
"(",
"closeList",
"==",
"null",
"||",
"closeList",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"fireAlgorithmEnd",
"(",
"closeList",
")",
";",
"// Create the path",
"return",
"createPath",
"(",
"startPoint",
",",
"endPoint",
",",
"closeList",
")",
";",
"}"
] | Run the A* algorithm assuming that the graph is oriented is
an orientation tool was passed to the constructor.
<p>The orientation of the graph may also be overridden by the implementations
of the {@link AStarNode A* nodes}.
@param startPoint is the starting point.
@param endPoint is the point to reach.
@return the found path, or <code>null</code> if none found. | [
"Run",
"the",
"A",
"*",
"algorithm",
"assuming",
"that",
"the",
"graph",
"is",
"oriented",
"is",
"an",
"orientation",
"tool",
"was",
"passed",
"to",
"the",
"constructor",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgraph/src/main/java/org/arakhne/afc/math/graph/astar/AStar.java#L433-L448 |
UrielCh/ovh-java-sdk | ovh-java-sdk-ip/src/main/java/net/minidev/ovh/api/ApiOvhIp.java | ApiOvhIp.ip_mitigation_ipOnMitigation_PUT | public void ip_mitigation_ipOnMitigation_PUT(String ip, String ipOnMitigation, OvhMitigationIp body) throws IOException {
"""
Alter this object properties
REST: PUT /ip/{ip}/mitigation/{ipOnMitigation}
@param body [required] New object properties
@param ip [required]
@param ipOnMitigation [required]
"""
String qPath = "/ip/{ip}/mitigation/{ipOnMitigation}";
StringBuilder sb = path(qPath, ip, ipOnMitigation);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void ip_mitigation_ipOnMitigation_PUT(String ip, String ipOnMitigation, OvhMitigationIp body) throws IOException {
String qPath = "/ip/{ip}/mitigation/{ipOnMitigation}";
StringBuilder sb = path(qPath, ip, ipOnMitigation);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"ip_mitigation_ipOnMitigation_PUT",
"(",
"String",
"ip",
",",
"String",
"ipOnMitigation",
",",
"OvhMitigationIp",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ip/{ip}/mitigation/{ipOnMitigation}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"ip",
",",
"ipOnMitigation",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /ip/{ip}/mitigation/{ipOnMitigation}
@param body [required] New object properties
@param ip [required]
@param ipOnMitigation [required] | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ip/src/main/java/net/minidev/ovh/api/ApiOvhIp.java#L711-L715 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.deleteSubList | public OperationStatus deleteSubList(UUID appId, String versionId, UUID clEntityId, int subListId) {
"""
Deletes a sublist of a specific closed list model.
@param appId The application ID.
@param versionId The version ID.
@param clEntityId The closed list entity extractor ID.
@param subListId The sublist ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful.
"""
return deleteSubListWithServiceResponseAsync(appId, versionId, clEntityId, subListId).toBlocking().single().body();
} | java | public OperationStatus deleteSubList(UUID appId, String versionId, UUID clEntityId, int subListId) {
return deleteSubListWithServiceResponseAsync(appId, versionId, clEntityId, subListId).toBlocking().single().body();
} | [
"public",
"OperationStatus",
"deleteSubList",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"clEntityId",
",",
"int",
"subListId",
")",
"{",
"return",
"deleteSubListWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"clEntityId",
",",
"subListId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Deletes a sublist of a specific closed list model.
@param appId The application ID.
@param versionId The version ID.
@param clEntityId The closed list entity extractor ID.
@param subListId The sublist ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful. | [
"Deletes",
"a",
"sublist",
"of",
"a",
"specific",
"closed",
"list",
"model",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L4872-L4874 |
UrielCh/ovh-java-sdk | ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java | ApiOvhXdsl.serviceName_antiSpams_ip_GET | public OvhAntiSpam serviceName_antiSpams_ip_GET(String serviceName, String ip) throws IOException {
"""
Get this object properties
REST: GET /xdsl/{serviceName}/antiSpams/{ip}
@param serviceName [required] The internal name of your XDSL offer
@param ip [required] IP which spam
"""
String qPath = "/xdsl/{serviceName}/antiSpams/{ip}";
StringBuilder sb = path(qPath, serviceName, ip);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAntiSpam.class);
} | java | public OvhAntiSpam serviceName_antiSpams_ip_GET(String serviceName, String ip) throws IOException {
String qPath = "/xdsl/{serviceName}/antiSpams/{ip}";
StringBuilder sb = path(qPath, serviceName, ip);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAntiSpam.class);
} | [
"public",
"OvhAntiSpam",
"serviceName_antiSpams_ip_GET",
"(",
"String",
"serviceName",
",",
"String",
"ip",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/xdsl/{serviceName}/antiSpams/{ip}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"ip",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhAntiSpam",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /xdsl/{serviceName}/antiSpams/{ip}
@param serviceName [required] The internal name of your XDSL offer
@param ip [required] IP which spam | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java#L1520-L1525 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/PoolOperations.java | PoolOperations.createPool | public void createPool(String poolId, String virtualMachineSize,
CloudServiceConfiguration cloudServiceConfiguration, int targetDedicatedNodes)
throws BatchErrorException, IOException {
"""
Adds a pool to the Batch account.
@param poolId
The ID of the pool.
@param virtualMachineSize
The size of virtual machines in the pool. See <a href=
"https://azure.microsoft.com/documentation/articles/virtual-machines-size-specs/">https://azure.microsoft.com/documentation/articles/virtual-machines-size-specs/</a>
for sizes.
@param cloudServiceConfiguration
The {@link CloudServiceConfiguration} for the pool.
@param targetDedicatedNodes
The desired number of dedicated compute nodes in the pool.
@throws BatchErrorException
Exception thrown when an error response is received from the
Batch service.
@throws IOException
Exception thrown when there is an error in
serialization/deserialization of data sent to/received from the
Batch service.
"""
createPool(poolId, virtualMachineSize, cloudServiceConfiguration, targetDedicatedNodes, 0, null);
} | java | public void createPool(String poolId, String virtualMachineSize,
CloudServiceConfiguration cloudServiceConfiguration, int targetDedicatedNodes)
throws BatchErrorException, IOException {
createPool(poolId, virtualMachineSize, cloudServiceConfiguration, targetDedicatedNodes, 0, null);
} | [
"public",
"void",
"createPool",
"(",
"String",
"poolId",
",",
"String",
"virtualMachineSize",
",",
"CloudServiceConfiguration",
"cloudServiceConfiguration",
",",
"int",
"targetDedicatedNodes",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"createPool",
"(",
"poolId",
",",
"virtualMachineSize",
",",
"cloudServiceConfiguration",
",",
"targetDedicatedNodes",
",",
"0",
",",
"null",
")",
";",
"}"
] | Adds a pool to the Batch account.
@param poolId
The ID of the pool.
@param virtualMachineSize
The size of virtual machines in the pool. See <a href=
"https://azure.microsoft.com/documentation/articles/virtual-machines-size-specs/">https://azure.microsoft.com/documentation/articles/virtual-machines-size-specs/</a>
for sizes.
@param cloudServiceConfiguration
The {@link CloudServiceConfiguration} for the pool.
@param targetDedicatedNodes
The desired number of dedicated compute nodes in the pool.
@throws BatchErrorException
Exception thrown when an error response is received from the
Batch service.
@throws IOException
Exception thrown when there is an error in
serialization/deserialization of data sent to/received from the
Batch service. | [
"Adds",
"a",
"pool",
"to",
"the",
"Batch",
"account",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/PoolOperations.java#L288-L292 |
mgledi/DRUMS | src/main/java/com/unister/semweb/drums/bucket/hashfunction/util/RangeHashSorter.java | RangeHashSorter.insertionSort | private void insertionSort(int left, int right) {
"""
Internal insertion sort routine for subarrays of ranges that is used by quicksort.
@param left
the left-most index of the subarray.
@param right
the right-most index of the subarray.
"""
for (int p = left + 1; p <= right; p++) {
byte[] tmpRange = ranges[p];
String tmpFilename = filenames[p];
int j;
for (j = p; j > left && KeyUtils.compareKey(tmpRange, ranges[j - 1]) < 0; j--) {
ranges[j] = ranges[j - 1];
filenames[j] = filenames[j - 1];
}
ranges[j] = tmpRange;
filenames[j] = tmpFilename;
}
} | java | private void insertionSort(int left, int right) {
for (int p = left + 1; p <= right; p++) {
byte[] tmpRange = ranges[p];
String tmpFilename = filenames[p];
int j;
for (j = p; j > left && KeyUtils.compareKey(tmpRange, ranges[j - 1]) < 0; j--) {
ranges[j] = ranges[j - 1];
filenames[j] = filenames[j - 1];
}
ranges[j] = tmpRange;
filenames[j] = tmpFilename;
}
} | [
"private",
"void",
"insertionSort",
"(",
"int",
"left",
",",
"int",
"right",
")",
"{",
"for",
"(",
"int",
"p",
"=",
"left",
"+",
"1",
";",
"p",
"<=",
"right",
";",
"p",
"++",
")",
"{",
"byte",
"[",
"]",
"tmpRange",
"=",
"ranges",
"[",
"p",
"]",
";",
"String",
"tmpFilename",
"=",
"filenames",
"[",
"p",
"]",
";",
"int",
"j",
";",
"for",
"(",
"j",
"=",
"p",
";",
"j",
">",
"left",
"&&",
"KeyUtils",
".",
"compareKey",
"(",
"tmpRange",
",",
"ranges",
"[",
"j",
"-",
"1",
"]",
")",
"<",
"0",
";",
"j",
"--",
")",
"{",
"ranges",
"[",
"j",
"]",
"=",
"ranges",
"[",
"j",
"-",
"1",
"]",
";",
"filenames",
"[",
"j",
"]",
"=",
"filenames",
"[",
"j",
"-",
"1",
"]",
";",
"}",
"ranges",
"[",
"j",
"]",
"=",
"tmpRange",
";",
"filenames",
"[",
"j",
"]",
"=",
"tmpFilename",
";",
"}",
"}"
] | Internal insertion sort routine for subarrays of ranges that is used by quicksort.
@param left
the left-most index of the subarray.
@param right
the right-most index of the subarray. | [
"Internal",
"insertion",
"sort",
"routine",
"for",
"subarrays",
"of",
"ranges",
"that",
"is",
"used",
"by",
"quicksort",
"."
] | train | https://github.com/mgledi/DRUMS/blob/a670f17a2186c9a15725f26617d77ce8e444e072/src/main/java/com/unister/semweb/drums/bucket/hashfunction/util/RangeHashSorter.java#L118-L131 |
sebastiangraf/jSCSI | bundles/commons/src/main/java/org/jscsi/utils/Utils.java | Utils.printField | public static final void printField (final StringBuilder sb, final String fieldName, final String fieldValue, final int indent) {
"""
This methods creates an easy to use interface to print out a logging message of a specific variable.
@param sb StringBuilder to directly write the logging messages in.
@param fieldName The name of the variable.
@param fieldValue The value of the given variable.
@param indent The level of indention.
"""
indent(sb, indent);
sb.append(fieldName);
sb.append(": ");
sb.append(fieldValue);
sb.append("\n");
} | java | public static final void printField (final StringBuilder sb, final String fieldName, final String fieldValue, final int indent) {
indent(sb, indent);
sb.append(fieldName);
sb.append(": ");
sb.append(fieldValue);
sb.append("\n");
} | [
"public",
"static",
"final",
"void",
"printField",
"(",
"final",
"StringBuilder",
"sb",
",",
"final",
"String",
"fieldName",
",",
"final",
"String",
"fieldValue",
",",
"final",
"int",
"indent",
")",
"{",
"indent",
"(",
"sb",
",",
"indent",
")",
";",
"sb",
".",
"append",
"(",
"fieldName",
")",
";",
"sb",
".",
"append",
"(",
"\": \"",
")",
";",
"sb",
".",
"append",
"(",
"fieldValue",
")",
";",
"sb",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}"
] | This methods creates an easy to use interface to print out a logging message of a specific variable.
@param sb StringBuilder to directly write the logging messages in.
@param fieldName The name of the variable.
@param fieldValue The value of the given variable.
@param indent The level of indention. | [
"This",
"methods",
"creates",
"an",
"easy",
"to",
"use",
"interface",
"to",
"print",
"out",
"a",
"logging",
"message",
"of",
"a",
"specific",
"variable",
"."
] | train | https://github.com/sebastiangraf/jSCSI/blob/6169bfe73f0b15de7d6485453555389e782ae888/bundles/commons/src/main/java/org/jscsi/utils/Utils.java#L111-L118 |
svenkubiak/mangooio | mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java | Validator.validateNull | public void validateNull(Object object, String name, String message) {
"""
Validates a given object to be null
@param object The object to check
@param name The name of the field to display the error message
@param message A custom error message instead of the default one
"""
if (object != null) {
addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.NULL_KEY.name(), name)));
}
} | java | public void validateNull(Object object, String name, String message) {
if (object != null) {
addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.NULL_KEY.name(), name)));
}
} | [
"public",
"void",
"validateNull",
"(",
"Object",
"object",
",",
"String",
"name",
",",
"String",
"message",
")",
"{",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"addError",
"(",
"name",
",",
"Optional",
".",
"ofNullable",
"(",
"message",
")",
".",
"orElse",
"(",
"messages",
".",
"get",
"(",
"Validation",
".",
"NULL_KEY",
".",
"name",
"(",
")",
",",
"name",
")",
")",
")",
";",
"}",
"}"
] | Validates a given object to be null
@param object The object to check
@param name The name of the field to display the error message
@param message A custom error message instead of the default one | [
"Validates",
"a",
"given",
"object",
"to",
"be",
"null"
] | train | https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java#L499-L503 |
ocelotds/ocelot | ocelot-processor/src/main/java/org/ocelotds/processors/visitors/DataServiceVisitorJsBuilder.java | DataServiceVisitorJsBuilder.createReturnOcelotPromiseFactory | void createReturnOcelotPromiseFactory(String classname, String methodName, boolean ws, String args, String keys, Writer writer) throws IOException {
"""
Return body js line that return the OcelotPromise
@param classname
@param methodName
@param args
@param keys
@param writer
@throws IOException
"""
String md5 = keyMaker.getMd5(classname + DOT + methodName);
writer.append(TAB3).append("return promiseFactory.create").append(OPENPARENTHESIS).append("_ds").append(COMMA).append(SPACEOPTIONAL)
.append(QUOTE).append(md5).append(UNDERSCORE).append(QUOTE)
.append(" + JSON.stringify([").append(keys).append("]).md5()").append(COMMA).append(SPACEOPTIONAL)
.append(QUOTE).append(methodName).append(QUOTE).append(COMMA).append(SPACEOPTIONAL).append(""+ws).append(COMMA)
.append(SPACEOPTIONAL).append(OPENBRACKET).append(args).append(CLOSEBRACKET).append(CLOSEPARENTHESIS)
.append(SEMICOLON).append(CR);
} | java | void createReturnOcelotPromiseFactory(String classname, String methodName, boolean ws, String args, String keys, Writer writer) throws IOException {
String md5 = keyMaker.getMd5(classname + DOT + methodName);
writer.append(TAB3).append("return promiseFactory.create").append(OPENPARENTHESIS).append("_ds").append(COMMA).append(SPACEOPTIONAL)
.append(QUOTE).append(md5).append(UNDERSCORE).append(QUOTE)
.append(" + JSON.stringify([").append(keys).append("]).md5()").append(COMMA).append(SPACEOPTIONAL)
.append(QUOTE).append(methodName).append(QUOTE).append(COMMA).append(SPACEOPTIONAL).append(""+ws).append(COMMA)
.append(SPACEOPTIONAL).append(OPENBRACKET).append(args).append(CLOSEBRACKET).append(CLOSEPARENTHESIS)
.append(SEMICOLON).append(CR);
} | [
"void",
"createReturnOcelotPromiseFactory",
"(",
"String",
"classname",
",",
"String",
"methodName",
",",
"boolean",
"ws",
",",
"String",
"args",
",",
"String",
"keys",
",",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"String",
"md5",
"=",
"keyMaker",
".",
"getMd5",
"(",
"classname",
"+",
"DOT",
"+",
"methodName",
")",
";",
"writer",
".",
"append",
"(",
"TAB3",
")",
".",
"append",
"(",
"\"return promiseFactory.create\"",
")",
".",
"append",
"(",
"OPENPARENTHESIS",
")",
".",
"append",
"(",
"\"_ds\"",
")",
".",
"append",
"(",
"COMMA",
")",
".",
"append",
"(",
"SPACEOPTIONAL",
")",
".",
"append",
"(",
"QUOTE",
")",
".",
"append",
"(",
"md5",
")",
".",
"append",
"(",
"UNDERSCORE",
")",
".",
"append",
"(",
"QUOTE",
")",
".",
"append",
"(",
"\" + JSON.stringify([\"",
")",
".",
"append",
"(",
"keys",
")",
".",
"append",
"(",
"\"]).md5()\"",
")",
".",
"append",
"(",
"COMMA",
")",
".",
"append",
"(",
"SPACEOPTIONAL",
")",
".",
"append",
"(",
"QUOTE",
")",
".",
"append",
"(",
"methodName",
")",
".",
"append",
"(",
"QUOTE",
")",
".",
"append",
"(",
"COMMA",
")",
".",
"append",
"(",
"SPACEOPTIONAL",
")",
".",
"append",
"(",
"\"\"",
"+",
"ws",
")",
".",
"append",
"(",
"COMMA",
")",
".",
"append",
"(",
"SPACEOPTIONAL",
")",
".",
"append",
"(",
"OPENBRACKET",
")",
".",
"append",
"(",
"args",
")",
".",
"append",
"(",
"CLOSEBRACKET",
")",
".",
"append",
"(",
"CLOSEPARENTHESIS",
")",
".",
"append",
"(",
"SEMICOLON",
")",
".",
"append",
"(",
"CR",
")",
";",
"}"
] | Return body js line that return the OcelotPromise
@param classname
@param methodName
@param args
@param keys
@param writer
@throws IOException | [
"Return",
"body",
"js",
"line",
"that",
"return",
"the",
"OcelotPromise"
] | train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-processor/src/main/java/org/ocelotds/processors/visitors/DataServiceVisitorJsBuilder.java#L239-L247 |
igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java | JmfMediaManager.setupJMF | public static void setupJMF() {
"""
Runs JMFInit the first time the application is started so that capture
devices are properly detected and initialized by JMF.
"""
// .jmf is the place where we store the jmf.properties file used
// by JMF. if the directory does not exist or it does not contain
// a jmf.properties file. or if the jmf.properties file has 0 length
// then this is the first time we're running and should continue to
// with JMFInit
String homeDir = System.getProperty("user.home");
File jmfDir = new File(homeDir, ".jmf");
String classpath = System.getProperty("java.class.path");
classpath += System.getProperty("path.separator")
+ jmfDir.getAbsolutePath();
System.setProperty("java.class.path", classpath);
if (!jmfDir.exists())
jmfDir.mkdir();
File jmfProperties = new File(jmfDir, "jmf.properties");
if (!jmfProperties.exists()) {
try {
jmfProperties.createNewFile();
}
catch (IOException ex) {
LOGGER.log(Level.FINE, "Failed to create jmf.properties", ex);
}
}
// if we're running on linux checkout that libjmutil.so is where it
// should be and put it there.
runLinuxPreInstall();
// if (jmfProperties.length() == 0) {
new JMFInit(null, false);
// }
} | java | public static void setupJMF() {
// .jmf is the place where we store the jmf.properties file used
// by JMF. if the directory does not exist or it does not contain
// a jmf.properties file. or if the jmf.properties file has 0 length
// then this is the first time we're running and should continue to
// with JMFInit
String homeDir = System.getProperty("user.home");
File jmfDir = new File(homeDir, ".jmf");
String classpath = System.getProperty("java.class.path");
classpath += System.getProperty("path.separator")
+ jmfDir.getAbsolutePath();
System.setProperty("java.class.path", classpath);
if (!jmfDir.exists())
jmfDir.mkdir();
File jmfProperties = new File(jmfDir, "jmf.properties");
if (!jmfProperties.exists()) {
try {
jmfProperties.createNewFile();
}
catch (IOException ex) {
LOGGER.log(Level.FINE, "Failed to create jmf.properties", ex);
}
}
// if we're running on linux checkout that libjmutil.so is where it
// should be and put it there.
runLinuxPreInstall();
// if (jmfProperties.length() == 0) {
new JMFInit(null, false);
// }
} | [
"public",
"static",
"void",
"setupJMF",
"(",
")",
"{",
"// .jmf is the place where we store the jmf.properties file used",
"// by JMF. if the directory does not exist or it does not contain",
"// a jmf.properties file. or if the jmf.properties file has 0 length",
"// then this is the first time we're running and should continue to",
"// with JMFInit",
"String",
"homeDir",
"=",
"System",
".",
"getProperty",
"(",
"\"user.home\"",
")",
";",
"File",
"jmfDir",
"=",
"new",
"File",
"(",
"homeDir",
",",
"\".jmf\"",
")",
";",
"String",
"classpath",
"=",
"System",
".",
"getProperty",
"(",
"\"java.class.path\"",
")",
";",
"classpath",
"+=",
"System",
".",
"getProperty",
"(",
"\"path.separator\"",
")",
"+",
"jmfDir",
".",
"getAbsolutePath",
"(",
")",
";",
"System",
".",
"setProperty",
"(",
"\"java.class.path\"",
",",
"classpath",
")",
";",
"if",
"(",
"!",
"jmfDir",
".",
"exists",
"(",
")",
")",
"jmfDir",
".",
"mkdir",
"(",
")",
";",
"File",
"jmfProperties",
"=",
"new",
"File",
"(",
"jmfDir",
",",
"\"jmf.properties\"",
")",
";",
"if",
"(",
"!",
"jmfProperties",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"jmfProperties",
".",
"createNewFile",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Failed to create jmf.properties\"",
",",
"ex",
")",
";",
"}",
"}",
"// if we're running on linux checkout that libjmutil.so is where it",
"// should be and put it there.",
"runLinuxPreInstall",
"(",
")",
";",
"// if (jmfProperties.length() == 0) {",
"new",
"JMFInit",
"(",
"null",
",",
"false",
")",
";",
"// }",
"}"
] | Runs JMFInit the first time the application is started so that capture
devices are properly detected and initialized by JMF. | [
"Runs",
"JMFInit",
"the",
"first",
"time",
"the",
"application",
"is",
"started",
"so",
"that",
"capture",
"devices",
"are",
"properly",
"detected",
"and",
"initialized",
"by",
"JMF",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java#L124-L159 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-integrations/valkyrie-rcp-jideoss/src/main/java/org/valkyriercp/component/SearchableInterceptor.java | SearchableInterceptor.processComponent | @Override
public void processComponent(String propertyName, JComponent component) {
"""
Installs a <code>Searchable</code> into the given component.
@param propertyName
the property name.
@param component
the target component.
"""
if (component instanceof JComboBox) {
this.installSearchable((JComboBox) component);
} else if (component instanceof JList) {
this.installSearchable((JList) component);
} else if (component instanceof JTable) {
this.installSearchable((JTable) component);
} else if (component instanceof JTextComponent) {
this.installSearchable((JTextComponent) component);
}
} | java | @Override
public void processComponent(String propertyName, JComponent component) {
if (component instanceof JComboBox) {
this.installSearchable((JComboBox) component);
} else if (component instanceof JList) {
this.installSearchable((JList) component);
} else if (component instanceof JTable) {
this.installSearchable((JTable) component);
} else if (component instanceof JTextComponent) {
this.installSearchable((JTextComponent) component);
}
} | [
"@",
"Override",
"public",
"void",
"processComponent",
"(",
"String",
"propertyName",
",",
"JComponent",
"component",
")",
"{",
"if",
"(",
"component",
"instanceof",
"JComboBox",
")",
"{",
"this",
".",
"installSearchable",
"(",
"(",
"JComboBox",
")",
"component",
")",
";",
"}",
"else",
"if",
"(",
"component",
"instanceof",
"JList",
")",
"{",
"this",
".",
"installSearchable",
"(",
"(",
"JList",
")",
"component",
")",
";",
"}",
"else",
"if",
"(",
"component",
"instanceof",
"JTable",
")",
"{",
"this",
".",
"installSearchable",
"(",
"(",
"JTable",
")",
"component",
")",
";",
"}",
"else",
"if",
"(",
"component",
"instanceof",
"JTextComponent",
")",
"{",
"this",
".",
"installSearchable",
"(",
"(",
"JTextComponent",
")",
"component",
")",
";",
"}",
"}"
] | Installs a <code>Searchable</code> into the given component.
@param propertyName
the property name.
@param component
the target component. | [
"Installs",
"a",
"<code",
">",
"Searchable<",
"/",
"code",
">",
"into",
"the",
"given",
"component",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-integrations/valkyrie-rcp-jideoss/src/main/java/org/valkyriercp/component/SearchableInterceptor.java#L116-L128 |
sdaschner/jaxrs-analyzer | src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/bytecode/simulation/MethodSimulator.java | MethodSimulator.mergeElementStore | private void mergeElementStore(final int index, final String type, final Element element) {
"""
Merges a stored element to the local variables.
@param index The index of the variable
@param type The type of the variable or the element (whatever is more specific)
@param element The element to merge
"""
// new element must be created for immutability
final String elementType = type.equals(Types.OBJECT) ? determineLeastSpecificType(element.getTypes().toArray(new String[element.getTypes().size()])) : type;
final Element created = new Element(elementType);
created.merge(element);
localVariables.merge(index, created, Element::merge);
} | java | private void mergeElementStore(final int index, final String type, final Element element) {
// new element must be created for immutability
final String elementType = type.equals(Types.OBJECT) ? determineLeastSpecificType(element.getTypes().toArray(new String[element.getTypes().size()])) : type;
final Element created = new Element(elementType);
created.merge(element);
localVariables.merge(index, created, Element::merge);
} | [
"private",
"void",
"mergeElementStore",
"(",
"final",
"int",
"index",
",",
"final",
"String",
"type",
",",
"final",
"Element",
"element",
")",
"{",
"// new element must be created for immutability",
"final",
"String",
"elementType",
"=",
"type",
".",
"equals",
"(",
"Types",
".",
"OBJECT",
")",
"?",
"determineLeastSpecificType",
"(",
"element",
".",
"getTypes",
"(",
")",
".",
"toArray",
"(",
"new",
"String",
"[",
"element",
".",
"getTypes",
"(",
")",
".",
"size",
"(",
")",
"]",
")",
")",
":",
"type",
";",
"final",
"Element",
"created",
"=",
"new",
"Element",
"(",
"elementType",
")",
";",
"created",
".",
"merge",
"(",
"element",
")",
";",
"localVariables",
".",
"merge",
"(",
"index",
",",
"created",
",",
"Element",
"::",
"merge",
")",
";",
"}"
] | Merges a stored element to the local variables.
@param index The index of the variable
@param type The type of the variable or the element (whatever is more specific)
@param element The element to merge | [
"Merges",
"a",
"stored",
"element",
"to",
"the",
"local",
"variables",
"."
] | train | https://github.com/sdaschner/jaxrs-analyzer/blob/4ac62942202d05632977d6c14d3cd7e2d27e2b9b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/bytecode/simulation/MethodSimulator.java#L222-L228 |
sahan/ZombieLink | zombielink/src/main/java/com/lonepulse/zombielink/executor/BasicRequestExecutor.java | BasicRequestExecutor.fetchResponse | protected HttpResponse fetchResponse(InvocationContext context, HttpRequestBase request) {
"""
<p>Performs the actual request execution with the {@link HttpClient} to be used for the endpoint
(fetched using the {@link HttpClientDirectory}). See {@link HttpClient#execute(HttpUriRequest)}.</p>
<p>If the endpoint is annotated with @{@link Stateful}, the relevant {@link HttpContext} from the
{@link HttpContextDirectory} is used. See {@link HttpClient#execute(HttpUriRequest, HttpContext)}</p>
@param context
the {@link InvocationContext} used to discover information about the proxy invocation
<br><br>
@param request
the {@link HttpRequestBase} to be executed using the endpoint's {@link HttpClient}
<br><br>
@return the {@link HttpResponse} which resulted from the execution
<br><br>
@since 1.3.0
"""
try {
Class<?> endpoint = context.getEndpoint();
HttpClient httpClient = HttpClientDirectory.INSTANCE.lookup(endpoint);
return endpoint.isAnnotationPresent(Stateful.class)?
httpClient.execute(request, HttpContextDirectory.INSTANCE.lookup(endpoint))
:httpClient.execute(request);
}
catch(Exception e) {
throw new RequestExecutionException(context.getRequest(), context.getEndpoint(), e);
}
} | java | protected HttpResponse fetchResponse(InvocationContext context, HttpRequestBase request) {
try {
Class<?> endpoint = context.getEndpoint();
HttpClient httpClient = HttpClientDirectory.INSTANCE.lookup(endpoint);
return endpoint.isAnnotationPresent(Stateful.class)?
httpClient.execute(request, HttpContextDirectory.INSTANCE.lookup(endpoint))
:httpClient.execute(request);
}
catch(Exception e) {
throw new RequestExecutionException(context.getRequest(), context.getEndpoint(), e);
}
} | [
"protected",
"HttpResponse",
"fetchResponse",
"(",
"InvocationContext",
"context",
",",
"HttpRequestBase",
"request",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"endpoint",
"=",
"context",
".",
"getEndpoint",
"(",
")",
";",
"HttpClient",
"httpClient",
"=",
"HttpClientDirectory",
".",
"INSTANCE",
".",
"lookup",
"(",
"endpoint",
")",
";",
"return",
"endpoint",
".",
"isAnnotationPresent",
"(",
"Stateful",
".",
"class",
")",
"?",
"httpClient",
".",
"execute",
"(",
"request",
",",
"HttpContextDirectory",
".",
"INSTANCE",
".",
"lookup",
"(",
"endpoint",
")",
")",
":",
"httpClient",
".",
"execute",
"(",
"request",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RequestExecutionException",
"(",
"context",
".",
"getRequest",
"(",
")",
",",
"context",
".",
"getEndpoint",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | <p>Performs the actual request execution with the {@link HttpClient} to be used for the endpoint
(fetched using the {@link HttpClientDirectory}). See {@link HttpClient#execute(HttpUriRequest)}.</p>
<p>If the endpoint is annotated with @{@link Stateful}, the relevant {@link HttpContext} from the
{@link HttpContextDirectory} is used. See {@link HttpClient#execute(HttpUriRequest, HttpContext)}</p>
@param context
the {@link InvocationContext} used to discover information about the proxy invocation
<br><br>
@param request
the {@link HttpRequestBase} to be executed using the endpoint's {@link HttpClient}
<br><br>
@return the {@link HttpResponse} which resulted from the execution
<br><br>
@since 1.3.0 | [
"<p",
">",
"Performs",
"the",
"actual",
"request",
"execution",
"with",
"the",
"{",
"@link",
"HttpClient",
"}",
"to",
"be",
"used",
"for",
"the",
"endpoint",
"(",
"fetched",
"using",
"the",
"{",
"@link",
"HttpClientDirectory",
"}",
")",
".",
"See",
"{",
"@link",
"HttpClient#execute",
"(",
"HttpUriRequest",
")",
"}",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/sahan/ZombieLink/blob/a9971add56d4f6919a4a5e84c78e9220011d8982/zombielink/src/main/java/com/lonepulse/zombielink/executor/BasicRequestExecutor.java#L82-L98 |
contentful/contentful-management.java | src/main/java/com/contentful/java/cma/ModuleRoles.java | ModuleRoles.fetchOne | public CMARole fetchOne(String spaceId, String roleId) {
"""
Fetches one role by its id from Contentful.
<p>
This method will override the configuration specified through
{@link CMAClient.Builder#setSpaceId(String)} and will ignore
{@link CMAClient.Builder#setEnvironmentId(String)}.
@param spaceId the space this role is hosted by.
@param roleId the id of the role to be found.
@return null if no role was found, otherwise the found role.
@throws IllegalArgumentException if space id is null.
@throws IllegalArgumentException if role id is null.
"""
assertNotNull(spaceId, "spaceId");
assertNotNull(roleId, "roleId");
return service.fetchOne(spaceId, roleId).blockingFirst();
} | java | public CMARole fetchOne(String spaceId, String roleId) {
assertNotNull(spaceId, "spaceId");
assertNotNull(roleId, "roleId");
return service.fetchOne(spaceId, roleId).blockingFirst();
} | [
"public",
"CMARole",
"fetchOne",
"(",
"String",
"spaceId",
",",
"String",
"roleId",
")",
"{",
"assertNotNull",
"(",
"spaceId",
",",
"\"spaceId\"",
")",
";",
"assertNotNull",
"(",
"roleId",
",",
"\"roleId\"",
")",
";",
"return",
"service",
".",
"fetchOne",
"(",
"spaceId",
",",
"roleId",
")",
".",
"blockingFirst",
"(",
")",
";",
"}"
] | Fetches one role by its id from Contentful.
<p>
This method will override the configuration specified through
{@link CMAClient.Builder#setSpaceId(String)} and will ignore
{@link CMAClient.Builder#setEnvironmentId(String)}.
@param spaceId the space this role is hosted by.
@param roleId the id of the role to be found.
@return null if no role was found, otherwise the found role.
@throws IllegalArgumentException if space id is null.
@throws IllegalArgumentException if role id is null. | [
"Fetches",
"one",
"role",
"by",
"its",
"id",
"from",
"Contentful",
".",
"<p",
">",
"This",
"method",
"will",
"override",
"the",
"configuration",
"specified",
"through",
"{",
"@link",
"CMAClient",
".",
"Builder#setSpaceId",
"(",
"String",
")",
"}",
"and",
"will",
"ignore",
"{",
"@link",
"CMAClient",
".",
"Builder#setEnvironmentId",
"(",
"String",
")",
"}",
"."
] | train | https://github.com/contentful/contentful-management.java/blob/ca310fb9ea9577fcff0ca57949ab7c2315fa2534/src/main/java/com/contentful/java/cma/ModuleRoles.java#L157-L162 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.