id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
141,700 | fuinorg/units4j | src/main/java/org/fuin/units4j/assertionrules/Utils.java | Utils.findOverrideMethods | public static List<MethodInfo> findOverrideMethods(final Index index, final MethodInfo method) {
return findOverrideMethods(index, method.declaringClass(), method, 0);
} | java | public static List<MethodInfo> findOverrideMethods(final Index index, final MethodInfo method) {
return findOverrideMethods(index, method.declaringClass(), method, 0);
} | [
"public",
"static",
"List",
"<",
"MethodInfo",
">",
"findOverrideMethods",
"(",
"final",
"Index",
"index",
",",
"final",
"MethodInfo",
"method",
")",
"{",
"return",
"findOverrideMethods",
"(",
"index",
",",
"method",
".",
"declaringClass",
"(",
")",
",",
"method",
",",
"0",
")",
";",
"}"
] | Returns a list of all methods the given one overrides. Such methods can be found in interfaces and super classes.
@param index
Index with all known classes.
@param method
Method signature to find.
@return List of methods the given one overrides. | [
"Returns",
"a",
"list",
"of",
"all",
"methods",
"the",
"given",
"one",
"overrides",
".",
"Such",
"methods",
"can",
"be",
"found",
"in",
"interfaces",
"and",
"super",
"classes",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/assertionrules/Utils.java#L122-L126 |
141,701 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.setPrivateField | public static void setPrivateField(final Object obj, final String name, final Object value) {
try {
final Field field = obj.getClass().getDeclaredField(name);
field.setAccessible(true);
field.set(obj, value);
} catch (final Exception ex) {
throw new RuntimeException("Couldn't set field '" + name + "' in class '" + obj.getClass() + "'", ex);
}
} | java | public static void setPrivateField(final Object obj, final String name, final Object value) {
try {
final Field field = obj.getClass().getDeclaredField(name);
field.setAccessible(true);
field.set(obj, value);
} catch (final Exception ex) {
throw new RuntimeException("Couldn't set field '" + name + "' in class '" + obj.getClass() + "'", ex);
}
} | [
"public",
"static",
"void",
"setPrivateField",
"(",
"final",
"Object",
"obj",
",",
"final",
"String",
"name",
",",
"final",
"Object",
"value",
")",
"{",
"try",
"{",
"final",
"Field",
"field",
"=",
"obj",
".",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"name",
")",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"field",
".",
"set",
"(",
"obj",
",",
"value",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Couldn't set field '\"",
"+",
"name",
"+",
"\"' in class '\"",
"+",
"obj",
".",
"getClass",
"(",
")",
"+",
"\"'\"",
",",
"ex",
")",
";",
"}",
"}"
] | Sets a private field in an object by using reflection.
@param obj
Object with the attribute to set.
@param name
Name of the attribute to set.
@param value
Value to set for the attribute. | [
"Sets",
"a",
"private",
"field",
"in",
"an",
"object",
"by",
"using",
"reflection",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L255-L263 |
141,702 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.assertCauseMessage | public static void assertCauseMessage(final Throwable ex, final String expectedMessage) {
assertThat(ex.getCause()).isNotNull();
assertThat(ex.getCause().getMessage()).isEqualTo(expectedMessage);
} | java | public static void assertCauseMessage(final Throwable ex, final String expectedMessage) {
assertThat(ex.getCause()).isNotNull();
assertThat(ex.getCause().getMessage()).isEqualTo(expectedMessage);
} | [
"public",
"static",
"void",
"assertCauseMessage",
"(",
"final",
"Throwable",
"ex",
",",
"final",
"String",
"expectedMessage",
")",
"{",
"assertThat",
"(",
"ex",
".",
"getCause",
"(",
")",
")",
".",
"isNotNull",
"(",
")",
";",
"assertThat",
"(",
"ex",
".",
"getCause",
"(",
")",
".",
"getMessage",
"(",
")",
")",
".",
"isEqualTo",
"(",
"expectedMessage",
")",
";",
"}"
] | Verifies that the cause of an exception contains an expected message.
@param ex
Exception with the cause to check,
@param expectedMessage
Message of the cause. | [
"Verifies",
"that",
"the",
"cause",
"of",
"an",
"exception",
"contains",
"an",
"expected",
"message",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L273-L276 |
141,703 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.assertCauseCauseMessage | public static void assertCauseCauseMessage(final Throwable ex, final String expectedMessage) {
assertThat(ex.getCause()).isNotNull();
assertThat(ex.getCause().getCause()).isNotNull();
assertThat(ex.getCause().getCause().getMessage()).isEqualTo(expectedMessage);
} | java | public static void assertCauseCauseMessage(final Throwable ex, final String expectedMessage) {
assertThat(ex.getCause()).isNotNull();
assertThat(ex.getCause().getCause()).isNotNull();
assertThat(ex.getCause().getCause().getMessage()).isEqualTo(expectedMessage);
} | [
"public",
"static",
"void",
"assertCauseCauseMessage",
"(",
"final",
"Throwable",
"ex",
",",
"final",
"String",
"expectedMessage",
")",
"{",
"assertThat",
"(",
"ex",
".",
"getCause",
"(",
")",
")",
".",
"isNotNull",
"(",
")",
";",
"assertThat",
"(",
"ex",
".",
"getCause",
"(",
")",
".",
"getCause",
"(",
")",
")",
".",
"isNotNull",
"(",
")",
";",
"assertThat",
"(",
"ex",
".",
"getCause",
"(",
")",
".",
"getCause",
"(",
")",
".",
"getMessage",
"(",
")",
")",
".",
"isEqualTo",
"(",
"expectedMessage",
")",
";",
"}"
] | Verifies that the cause of a cause of an exception contains an expected message.
@param ex
Exception with the cause/cause to check,
@param expectedMessage
Message of the cause/cause. | [
"Verifies",
"that",
"the",
"cause",
"of",
"a",
"cause",
"of",
"an",
"exception",
"contains",
"an",
"expected",
"message",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L286-L290 |
141,704 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.validate | public static Set<ConstraintViolation<Object>> validate(final Object obj, final Class<?>... scopes) {
if (scopes == null) {
return validator().validate(obj, Default.class);
}
return validator().validate(obj, scopes);
} | java | public static Set<ConstraintViolation<Object>> validate(final Object obj, final Class<?>... scopes) {
if (scopes == null) {
return validator().validate(obj, Default.class);
}
return validator().validate(obj, scopes);
} | [
"public",
"static",
"Set",
"<",
"ConstraintViolation",
"<",
"Object",
">",
">",
"validate",
"(",
"final",
"Object",
"obj",
",",
"final",
"Class",
"<",
"?",
">",
"...",
"scopes",
")",
"{",
"if",
"(",
"scopes",
"==",
"null",
")",
"{",
"return",
"validator",
"(",
")",
".",
"validate",
"(",
"obj",
",",
"Default",
".",
"class",
")",
";",
"}",
"return",
"validator",
"(",
")",
".",
"validate",
"(",
"obj",
",",
"scopes",
")",
";",
"}"
] | Validates the given object by using a newly created validator.
@param obj
Object to validate using the given scopes.
@param scopes
Scopes or <code>null</code> for the default scope.
@return Constraint violations. | [
"Validates",
"the",
"given",
"object",
"by",
"using",
"a",
"newly",
"created",
"validator",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L302-L307 |
141,705 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.findFilesRecursive | public static List<File> findFilesRecursive(final File dir, final String extension) {
final String dotExtension = "." + extension;
final List<File> files = new ArrayList<>();
final FileProcessor fileProcessor = new FileProcessor(new FileHandler() {
@Override
public final FileHandlerResult handleFile(final File file) {
// Directory
if (file.isDirectory()) {
return FileHandlerResult.CONTINUE;
}
// File
final String name = file.getName();
if (name.endsWith(dotExtension)) {
files.add(file);
}
return FileHandlerResult.CONTINUE;
}
});
fileProcessor.process(dir);
return files;
} | java | public static List<File> findFilesRecursive(final File dir, final String extension) {
final String dotExtension = "." + extension;
final List<File> files = new ArrayList<>();
final FileProcessor fileProcessor = new FileProcessor(new FileHandler() {
@Override
public final FileHandlerResult handleFile(final File file) {
// Directory
if (file.isDirectory()) {
return FileHandlerResult.CONTINUE;
}
// File
final String name = file.getName();
if (name.endsWith(dotExtension)) {
files.add(file);
}
return FileHandlerResult.CONTINUE;
}
});
fileProcessor.process(dir);
return files;
} | [
"public",
"static",
"List",
"<",
"File",
">",
"findFilesRecursive",
"(",
"final",
"File",
"dir",
",",
"final",
"String",
"extension",
")",
"{",
"final",
"String",
"dotExtension",
"=",
"\".\"",
"+",
"extension",
";",
"final",
"List",
"<",
"File",
">",
"files",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"final",
"FileProcessor",
"fileProcessor",
"=",
"new",
"FileProcessor",
"(",
"new",
"FileHandler",
"(",
")",
"{",
"@",
"Override",
"public",
"final",
"FileHandlerResult",
"handleFile",
"(",
"final",
"File",
"file",
")",
"{",
"// Directory",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"FileHandlerResult",
".",
"CONTINUE",
";",
"}",
"// File",
"final",
"String",
"name",
"=",
"file",
".",
"getName",
"(",
")",
";",
"if",
"(",
"name",
".",
"endsWith",
"(",
"dotExtension",
")",
")",
"{",
"files",
".",
"add",
"(",
"file",
")",
";",
"}",
"return",
"FileHandlerResult",
".",
"CONTINUE",
";",
"}",
"}",
")",
";",
"fileProcessor",
".",
"process",
"(",
"dir",
")",
";",
"return",
"files",
";",
"}"
] | Returns a list of files with a given extension.
@param dir
Directory and it's subdirectories to inspect.
@param extension
Extension to find (like "txt" or "class") without the ".".
@return List fo files. | [
"Returns",
"a",
"list",
"of",
"files",
"with",
"a",
"given",
"extension",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L329-L350 |
141,706 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.indexAllClasses | public static final Index indexAllClasses(final List<File> classFiles) {
final Indexer indexer = new Indexer();
indexAllClasses(indexer, classFiles);
return indexer.complete();
} | java | public static final Index indexAllClasses(final List<File> classFiles) {
final Indexer indexer = new Indexer();
indexAllClasses(indexer, classFiles);
return indexer.complete();
} | [
"public",
"static",
"final",
"Index",
"indexAllClasses",
"(",
"final",
"List",
"<",
"File",
">",
"classFiles",
")",
"{",
"final",
"Indexer",
"indexer",
"=",
"new",
"Indexer",
"(",
")",
";",
"indexAllClasses",
"(",
"indexer",
",",
"classFiles",
")",
";",
"return",
"indexer",
".",
"complete",
"(",
")",
";",
"}"
] | Creates an index for all class files in the given list.
@param classFiles
List of ".class" files.
@return Index. | [
"Creates",
"an",
"index",
"for",
"all",
"class",
"files",
"in",
"the",
"given",
"list",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L372-L376 |
141,707 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.indexAllClasses | public static final void indexAllClasses(final Indexer indexer, final List<File> classFiles) {
classFiles.forEach(file -> {
try {
final InputStream in = new FileInputStream(file);
try {
indexer.index(in);
} finally {
in.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
});
} | java | public static final void indexAllClasses(final Indexer indexer, final List<File> classFiles) {
classFiles.forEach(file -> {
try {
final InputStream in = new FileInputStream(file);
try {
indexer.index(in);
} finally {
in.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
});
} | [
"public",
"static",
"final",
"void",
"indexAllClasses",
"(",
"final",
"Indexer",
"indexer",
",",
"final",
"List",
"<",
"File",
">",
"classFiles",
")",
"{",
"classFiles",
".",
"forEach",
"(",
"file",
"->",
"{",
"try",
"{",
"final",
"InputStream",
"in",
"=",
"new",
"FileInputStream",
"(",
"file",
")",
";",
"try",
"{",
"indexer",
".",
"index",
"(",
"in",
")",
";",
"}",
"finally",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
")",
";",
"}"
] | Index all class files in the given list.
@param indexer
Indexer to use.
@param classFiles
List of ".class" files. | [
"Index",
"all",
"class",
"files",
"in",
"the",
"given",
"list",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L386-L399 |
141,708 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.classInfo | public static ClassInfo classInfo(final ClassLoader cl, final Class<?> clasz) {
return classInfo(cl, clasz.getName());
} | java | public static ClassInfo classInfo(final ClassLoader cl, final Class<?> clasz) {
return classInfo(cl, clasz.getName());
} | [
"public",
"static",
"ClassInfo",
"classInfo",
"(",
"final",
"ClassLoader",
"cl",
",",
"final",
"Class",
"<",
"?",
">",
"clasz",
")",
"{",
"return",
"classInfo",
"(",
"cl",
",",
"clasz",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Loads a class and creates a Jandex class information for it.
@param cl
Class loader to use.
@param clasz
Class to load.
@return Jandex class information. | [
"Loads",
"a",
"class",
"and",
"creates",
"a",
"Jandex",
"class",
"information",
"for",
"it",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L423-L425 |
141,709 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.classInfo | public static ClassInfo classInfo(final ClassLoader cl, final String className) {
final Index index = index(cl, className);
return index.getClassByName(DotName.createSimple(className));
} | java | public static ClassInfo classInfo(final ClassLoader cl, final String className) {
final Index index = index(cl, className);
return index.getClassByName(DotName.createSimple(className));
} | [
"public",
"static",
"ClassInfo",
"classInfo",
"(",
"final",
"ClassLoader",
"cl",
",",
"final",
"String",
"className",
")",
"{",
"final",
"Index",
"index",
"=",
"index",
"(",
"cl",
",",
"className",
")",
";",
"return",
"index",
".",
"getClassByName",
"(",
"DotName",
".",
"createSimple",
"(",
"className",
")",
")",
";",
"}"
] | Loads a class by it's name and creates a Jandex class information for it.
@param cl
Class loader to use.
@param className
Full qualified name of the class.
@return Jandex class information. | [
"Loads",
"a",
"class",
"by",
"it",
"s",
"name",
"and",
"creates",
"a",
"Jandex",
"class",
"information",
"for",
"it",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L449-L452 |
141,710 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.index | public static Index index(final ClassLoader cl, final String className) {
final Indexer indexer = new Indexer();
index(indexer, cl, className);
return indexer.complete();
} | java | public static Index index(final ClassLoader cl, final String className) {
final Indexer indexer = new Indexer();
index(indexer, cl, className);
return indexer.complete();
} | [
"public",
"static",
"Index",
"index",
"(",
"final",
"ClassLoader",
"cl",
",",
"final",
"String",
"className",
")",
"{",
"final",
"Indexer",
"indexer",
"=",
"new",
"Indexer",
"(",
")",
";",
"index",
"(",
"indexer",
",",
"cl",
",",
"className",
")",
";",
"return",
"indexer",
".",
"complete",
"(",
")",
";",
"}"
] | Returns a Jandex index for a class by it's name.
@param cl
Class loader to use.
@param className
Full qualified name of the class.
@return Jandex index. | [
"Returns",
"a",
"Jandex",
"index",
"for",
"a",
"class",
"by",
"it",
"s",
"name",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L464-L468 |
141,711 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.index | public static void index(final Indexer indexer, final ClassLoader cl, final String className) {
final InputStream stream = cl.getResourceAsStream(className.replace('.', '/') + ".class");
try {
indexer.index(stream);
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
} | java | public static void index(final Indexer indexer, final ClassLoader cl, final String className) {
final InputStream stream = cl.getResourceAsStream(className.replace('.', '/') + ".class");
try {
indexer.index(stream);
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
} | [
"public",
"static",
"void",
"index",
"(",
"final",
"Indexer",
"indexer",
",",
"final",
"ClassLoader",
"cl",
",",
"final",
"String",
"className",
")",
"{",
"final",
"InputStream",
"stream",
"=",
"cl",
".",
"getResourceAsStream",
"(",
"className",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
"+",
"\".class\"",
")",
";",
"try",
"{",
"indexer",
".",
"index",
"(",
"stream",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}"
] | Indexes a class by it's name.
@param indexer
Indexer to use.
@param cl
Class loader to use.
@param className
Full qualified name of the class. | [
"Indexes",
"a",
"class",
"by",
"it",
"s",
"name",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L480-L487 |
141,712 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.replaceXmlAttr | public static String replaceXmlAttr(final String xml, final KV... keyValues) {
final List<String> searchList = new ArrayList<String>();
final List<String> replacementList = new ArrayList<String>();
for (final KV kv : keyValues) {
final String tag = kv.getKey() + "=\"";
int pa = xml.indexOf(tag);
while (pa > -1) {
final int s = pa + tag.length();
final int pe = xml.indexOf("\"", s);
if (pe > -1) {
final String str = xml.substring(pa, pe + 1);
searchList.add(str);
final String repl = xml.substring(pa, pa + tag.length()) + kv.getValue() + "\"";
replacementList.add(repl);
}
pa = xml.indexOf(tag, s);
}
}
final String[] searchArray = searchList.toArray(new String[searchList.size()]);
final String[] replacementArray = replacementList.toArray(new String[replacementList.size()]);
return StringUtils.replaceEachRepeatedly(xml, searchArray, replacementArray);
} | java | public static String replaceXmlAttr(final String xml, final KV... keyValues) {
final List<String> searchList = new ArrayList<String>();
final List<String> replacementList = new ArrayList<String>();
for (final KV kv : keyValues) {
final String tag = kv.getKey() + "=\"";
int pa = xml.indexOf(tag);
while (pa > -1) {
final int s = pa + tag.length();
final int pe = xml.indexOf("\"", s);
if (pe > -1) {
final String str = xml.substring(pa, pe + 1);
searchList.add(str);
final String repl = xml.substring(pa, pa + tag.length()) + kv.getValue() + "\"";
replacementList.add(repl);
}
pa = xml.indexOf(tag, s);
}
}
final String[] searchArray = searchList.toArray(new String[searchList.size()]);
final String[] replacementArray = replacementList.toArray(new String[replacementList.size()]);
return StringUtils.replaceEachRepeatedly(xml, searchArray, replacementArray);
} | [
"public",
"static",
"String",
"replaceXmlAttr",
"(",
"final",
"String",
"xml",
",",
"final",
"KV",
"...",
"keyValues",
")",
"{",
"final",
"List",
"<",
"String",
">",
"searchList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"final",
"List",
"<",
"String",
">",
"replacementList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"final",
"KV",
"kv",
":",
"keyValues",
")",
"{",
"final",
"String",
"tag",
"=",
"kv",
".",
"getKey",
"(",
")",
"+",
"\"=\\\"\"",
";",
"int",
"pa",
"=",
"xml",
".",
"indexOf",
"(",
"tag",
")",
";",
"while",
"(",
"pa",
">",
"-",
"1",
")",
"{",
"final",
"int",
"s",
"=",
"pa",
"+",
"tag",
".",
"length",
"(",
")",
";",
"final",
"int",
"pe",
"=",
"xml",
".",
"indexOf",
"(",
"\"\\\"\"",
",",
"s",
")",
";",
"if",
"(",
"pe",
">",
"-",
"1",
")",
"{",
"final",
"String",
"str",
"=",
"xml",
".",
"substring",
"(",
"pa",
",",
"pe",
"+",
"1",
")",
";",
"searchList",
".",
"add",
"(",
"str",
")",
";",
"final",
"String",
"repl",
"=",
"xml",
".",
"substring",
"(",
"pa",
",",
"pa",
"+",
"tag",
".",
"length",
"(",
")",
")",
"+",
"kv",
".",
"getValue",
"(",
")",
"+",
"\"\\\"\"",
";",
"replacementList",
".",
"add",
"(",
"repl",
")",
";",
"}",
"pa",
"=",
"xml",
".",
"indexOf",
"(",
"tag",
",",
"s",
")",
";",
"}",
"}",
"final",
"String",
"[",
"]",
"searchArray",
"=",
"searchList",
".",
"toArray",
"(",
"new",
"String",
"[",
"searchList",
".",
"size",
"(",
")",
"]",
")",
";",
"final",
"String",
"[",
"]",
"replacementArray",
"=",
"replacementList",
".",
"toArray",
"(",
"new",
"String",
"[",
"replacementList",
".",
"size",
"(",
")",
"]",
")",
";",
"return",
"StringUtils",
".",
"replaceEachRepeatedly",
"(",
"xml",
",",
"searchArray",
",",
"replacementArray",
")",
";",
"}"
] | Replaces the content of one or more XML attributes.
@param xml
Xml with content to replace.
@param keyValues
Attribute name and new value.
@return Replaced content. | [
"Replaces",
"the",
"content",
"of",
"one",
"or",
"more",
"XML",
"attributes",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L499-L523 |
141,713 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.isExpectedType | public static boolean isExpectedType(final Class<?> expectedClass, final Object obj) {
final Class<?> actualClass;
if (obj == null) {
actualClass = null;
} else {
actualClass = obj.getClass();
}
return Objects.equals(expectedClass, actualClass);
} | java | public static boolean isExpectedType(final Class<?> expectedClass, final Object obj) {
final Class<?> actualClass;
if (obj == null) {
actualClass = null;
} else {
actualClass = obj.getClass();
}
return Objects.equals(expectedClass, actualClass);
} | [
"public",
"static",
"boolean",
"isExpectedType",
"(",
"final",
"Class",
"<",
"?",
">",
"expectedClass",
",",
"final",
"Object",
"obj",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"actualClass",
";",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"actualClass",
"=",
"null",
";",
"}",
"else",
"{",
"actualClass",
"=",
"obj",
".",
"getClass",
"(",
")",
";",
"}",
"return",
"Objects",
".",
"equals",
"(",
"expectedClass",
",",
"actualClass",
")",
";",
"}"
] | Determines if an object has an expected type in a null-safe way.
@param expectedClass
Expected type.
@param obj
Object to test.
@return TRUE if the object is exactly of the same class, else FALSE. | [
"Determines",
"if",
"an",
"object",
"has",
"an",
"expected",
"type",
"in",
"a",
"null",
"-",
"safe",
"way",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L535-L543 |
141,714 | fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.isExpectedException | public static boolean isExpectedException(final Class<? extends Exception> expectedClass,
final String expectedMessage, final Exception ex) {
if (!isExpectedType(expectedClass, ex)) {
return false;
}
if ((expectedClass != null) && (expectedMessage != null) && (ex != null)) {
return Objects.equals(expectedMessage, ex.getMessage());
}
return true;
} | java | public static boolean isExpectedException(final Class<? extends Exception> expectedClass,
final String expectedMessage, final Exception ex) {
if (!isExpectedType(expectedClass, ex)) {
return false;
}
if ((expectedClass != null) && (expectedMessage != null) && (ex != null)) {
return Objects.equals(expectedMessage, ex.getMessage());
}
return true;
} | [
"public",
"static",
"boolean",
"isExpectedException",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Exception",
">",
"expectedClass",
",",
"final",
"String",
"expectedMessage",
",",
"final",
"Exception",
"ex",
")",
"{",
"if",
"(",
"!",
"isExpectedType",
"(",
"expectedClass",
",",
"ex",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"expectedClass",
"!=",
"null",
")",
"&&",
"(",
"expectedMessage",
"!=",
"null",
")",
"&&",
"(",
"ex",
"!=",
"null",
")",
")",
"{",
"return",
"Objects",
".",
"equals",
"(",
"expectedMessage",
",",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Determines if an exception has an expected type and message in a null-safe way.
@param expectedClass
Expected exception type.
@param expectedMessage
Expected message.
@param ex
Exception to test.
@return TRUE if the object is exactly of the same class and has the same message, else FALSE. | [
"Determines",
"if",
"an",
"exception",
"has",
"an",
"expected",
"type",
"and",
"message",
"in",
"a",
"null",
"-",
"safe",
"way",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L557-L566 |
141,715 | fuinorg/units4j | src/main/java/org/fuin/units4j/dependency/Dependencies.java | Dependencies.isAlwaysAllowed | public final boolean isAlwaysAllowed(final String packageName) {
if (packageName.equals("java.lang")) {
return true;
}
return Utils.findAllowedByName(getAlwaysAllowed(), packageName) != null;
} | java | public final boolean isAlwaysAllowed(final String packageName) {
if (packageName.equals("java.lang")) {
return true;
}
return Utils.findAllowedByName(getAlwaysAllowed(), packageName) != null;
} | [
"public",
"final",
"boolean",
"isAlwaysAllowed",
"(",
"final",
"String",
"packageName",
")",
"{",
"if",
"(",
"packageName",
".",
"equals",
"(",
"\"java.lang\"",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"Utils",
".",
"findAllowedByName",
"(",
"getAlwaysAllowed",
"(",
")",
",",
"packageName",
")",
"!=",
"null",
";",
"}"
] | Checks if the package is always OK.
@param packageName
Name of the package to check.
@return If the package is always allowed <code>true</code> else <code>false</code>. | [
"Checks",
"if",
"the",
"package",
"is",
"always",
"OK",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/dependency/Dependencies.java#L85-L90 |
141,716 | fuinorg/units4j | src/main/java/org/fuin/units4j/dependency/Dependencies.java | Dependencies.validate | public final void validate() throws InvalidDependenciesDefinitionException {
int errorCount = 0;
final StringBuilder sb = new StringBuilder("Duplicate package entries in 'allowed' and 'forbidden': ");
final List<Package<NotDependsOn>> list = getForbidden();
for (int i = 0; i < list.size(); i++) {
final String name = list.get(i).getName();
final Package<DependsOn> dep = new Package<DependsOn>(name);
if (getAllowed().indexOf(dep) > -1) {
if (errorCount > 0) {
sb.append(", ");
}
sb.append(name);
errorCount++;
}
}
if (errorCount > 0) {
throw new InvalidDependenciesDefinitionException(this, sb.toString());
}
} | java | public final void validate() throws InvalidDependenciesDefinitionException {
int errorCount = 0;
final StringBuilder sb = new StringBuilder("Duplicate package entries in 'allowed' and 'forbidden': ");
final List<Package<NotDependsOn>> list = getForbidden();
for (int i = 0; i < list.size(); i++) {
final String name = list.get(i).getName();
final Package<DependsOn> dep = new Package<DependsOn>(name);
if (getAllowed().indexOf(dep) > -1) {
if (errorCount > 0) {
sb.append(", ");
}
sb.append(name);
errorCount++;
}
}
if (errorCount > 0) {
throw new InvalidDependenciesDefinitionException(this, sb.toString());
}
} | [
"public",
"final",
"void",
"validate",
"(",
")",
"throws",
"InvalidDependenciesDefinitionException",
"{",
"int",
"errorCount",
"=",
"0",
";",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"\"Duplicate package entries in 'allowed' and 'forbidden': \"",
")",
";",
"final",
"List",
"<",
"Package",
"<",
"NotDependsOn",
">",
">",
"list",
"=",
"getForbidden",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"String",
"name",
"=",
"list",
".",
"get",
"(",
"i",
")",
".",
"getName",
"(",
")",
";",
"final",
"Package",
"<",
"DependsOn",
">",
"dep",
"=",
"new",
"Package",
"<",
"DependsOn",
">",
"(",
"name",
")",
";",
"if",
"(",
"getAllowed",
"(",
")",
".",
"indexOf",
"(",
"dep",
")",
">",
"-",
"1",
")",
"{",
"if",
"(",
"errorCount",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"name",
")",
";",
"errorCount",
"++",
";",
"}",
"}",
"if",
"(",
"errorCount",
">",
"0",
")",
"{",
"throw",
"new",
"InvalidDependenciesDefinitionException",
"(",
"this",
",",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Checks if the definition is valid - Especially if no package is in both lists.
@throws InvalidDependenciesDefinitionException
This instance is invalid. | [
"Checks",
"if",
"the",
"definition",
"is",
"valid",
"-",
"Especially",
"if",
"no",
"package",
"is",
"in",
"both",
"lists",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/dependency/Dependencies.java#L136-L155 |
141,717 | fuinorg/units4j | src/main/java/org/fuin/units4j/dependency/Dependencies.java | Dependencies.findAllowedByName | public final Package<DependsOn> findAllowedByName(final String packageName) {
final List<Package<DependsOn>> list = getAllowed();
for (final Package<DependsOn> pkg : list) {
if (pkg.getName().equals(packageName)) {
return pkg;
}
}
return null;
} | java | public final Package<DependsOn> findAllowedByName(final String packageName) {
final List<Package<DependsOn>> list = getAllowed();
for (final Package<DependsOn> pkg : list) {
if (pkg.getName().equals(packageName)) {
return pkg;
}
}
return null;
} | [
"public",
"final",
"Package",
"<",
"DependsOn",
">",
"findAllowedByName",
"(",
"final",
"String",
"packageName",
")",
"{",
"final",
"List",
"<",
"Package",
"<",
"DependsOn",
">",
">",
"list",
"=",
"getAllowed",
"(",
")",
";",
"for",
"(",
"final",
"Package",
"<",
"DependsOn",
">",
"pkg",
":",
"list",
")",
"{",
"if",
"(",
"pkg",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"packageName",
")",
")",
"{",
"return",
"pkg",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Find an entry in the allowed list by package name.
@param packageName
Name to find.
@return Package or <code>null</code> if no entry with the given name was found. | [
"Find",
"an",
"entry",
"in",
"the",
"allowed",
"list",
"by",
"package",
"name",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/dependency/Dependencies.java#L165-L173 |
141,718 | fuinorg/units4j | src/main/java/org/fuin/units4j/dependency/Dependencies.java | Dependencies.findForbiddenByName | public final Package<NotDependsOn> findForbiddenByName(final String packageName) {
final List<Package<NotDependsOn>> list = getForbidden();
for (final Package<NotDependsOn> pkg : list) {
if (pkg.getName().equals(packageName)) {
return pkg;
}
}
return null;
} | java | public final Package<NotDependsOn> findForbiddenByName(final String packageName) {
final List<Package<NotDependsOn>> list = getForbidden();
for (final Package<NotDependsOn> pkg : list) {
if (pkg.getName().equals(packageName)) {
return pkg;
}
}
return null;
} | [
"public",
"final",
"Package",
"<",
"NotDependsOn",
">",
"findForbiddenByName",
"(",
"final",
"String",
"packageName",
")",
"{",
"final",
"List",
"<",
"Package",
"<",
"NotDependsOn",
">",
">",
"list",
"=",
"getForbidden",
"(",
")",
";",
"for",
"(",
"final",
"Package",
"<",
"NotDependsOn",
">",
"pkg",
":",
"list",
")",
"{",
"if",
"(",
"pkg",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"packageName",
")",
")",
"{",
"return",
"pkg",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Find an entry in the forbidden list by package name.
@param packageName
Name to find.
@return Package or <code>null</code> if no entry with the given name was found. | [
"Find",
"an",
"entry",
"in",
"the",
"forbidden",
"list",
"by",
"package",
"name",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/dependency/Dependencies.java#L183-L191 |
141,719 | fuinorg/units4j | src/main/java/org/fuin/units4j/dependency/Utils.java | Utils.createXStream | public static XStream createXStream() {
final Class<?>[] classes = new Class[] { Dependencies.class, Package.class, DependsOn.class, NotDependsOn.class, Dependency.class };
final XStream xstream = new XStream();
XStream.setupDefaultSecurity(xstream);
xstream.allowTypes(classes);
xstream.alias("dependencies", Dependencies.class);
xstream.alias("package", Package.class);
xstream.alias("dependsOn", DependsOn.class);
xstream.alias("notDependsOn", NotDependsOn.class);
xstream.aliasField("package", Dependency.class, "packageName");
xstream.useAttributeFor(Package.class, "name");
xstream.useAttributeFor(Package.class, "comment");
xstream.useAttributeFor(Dependency.class, "packageName");
xstream.useAttributeFor(Dependency.class, "includeSubPackages");
xstream.useAttributeFor(NotDependsOn.class, "comment");
xstream.addImplicitCollection(Package.class, "dependencies");
return xstream;
} | java | public static XStream createXStream() {
final Class<?>[] classes = new Class[] { Dependencies.class, Package.class, DependsOn.class, NotDependsOn.class, Dependency.class };
final XStream xstream = new XStream();
XStream.setupDefaultSecurity(xstream);
xstream.allowTypes(classes);
xstream.alias("dependencies", Dependencies.class);
xstream.alias("package", Package.class);
xstream.alias("dependsOn", DependsOn.class);
xstream.alias("notDependsOn", NotDependsOn.class);
xstream.aliasField("package", Dependency.class, "packageName");
xstream.useAttributeFor(Package.class, "name");
xstream.useAttributeFor(Package.class, "comment");
xstream.useAttributeFor(Dependency.class, "packageName");
xstream.useAttributeFor(Dependency.class, "includeSubPackages");
xstream.useAttributeFor(NotDependsOn.class, "comment");
xstream.addImplicitCollection(Package.class, "dependencies");
return xstream;
} | [
"public",
"static",
"XStream",
"createXStream",
"(",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"[",
"]",
"classes",
"=",
"new",
"Class",
"[",
"]",
"{",
"Dependencies",
".",
"class",
",",
"Package",
".",
"class",
",",
"DependsOn",
".",
"class",
",",
"NotDependsOn",
".",
"class",
",",
"Dependency",
".",
"class",
"}",
";",
"final",
"XStream",
"xstream",
"=",
"new",
"XStream",
"(",
")",
";",
"XStream",
".",
"setupDefaultSecurity",
"(",
"xstream",
")",
";",
"xstream",
".",
"allowTypes",
"(",
"classes",
")",
";",
"xstream",
".",
"alias",
"(",
"\"dependencies\"",
",",
"Dependencies",
".",
"class",
")",
";",
"xstream",
".",
"alias",
"(",
"\"package\"",
",",
"Package",
".",
"class",
")",
";",
"xstream",
".",
"alias",
"(",
"\"dependsOn\"",
",",
"DependsOn",
".",
"class",
")",
";",
"xstream",
".",
"alias",
"(",
"\"notDependsOn\"",
",",
"NotDependsOn",
".",
"class",
")",
";",
"xstream",
".",
"aliasField",
"(",
"\"package\"",
",",
"Dependency",
".",
"class",
",",
"\"packageName\"",
")",
";",
"xstream",
".",
"useAttributeFor",
"(",
"Package",
".",
"class",
",",
"\"name\"",
")",
";",
"xstream",
".",
"useAttributeFor",
"(",
"Package",
".",
"class",
",",
"\"comment\"",
")",
";",
"xstream",
".",
"useAttributeFor",
"(",
"Dependency",
".",
"class",
",",
"\"packageName\"",
")",
";",
"xstream",
".",
"useAttributeFor",
"(",
"Dependency",
".",
"class",
",",
"\"includeSubPackages\"",
")",
";",
"xstream",
".",
"useAttributeFor",
"(",
"NotDependsOn",
".",
"class",
",",
"\"comment\"",
")",
";",
"xstream",
".",
"addImplicitCollection",
"(",
"Package",
".",
"class",
",",
"\"dependencies\"",
")",
";",
"return",
"xstream",
";",
"}"
] | Creates a ready configured XStream instance.
@return New XStream instance. | [
"Creates",
"a",
"ready",
"configured",
"XStream",
"instance",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/dependency/Utils.java#L53-L70 |
141,720 | fuinorg/units4j | src/main/java/org/fuin/units4j/dependency/Utils.java | Utils.load | public static Dependencies load(final File file) {
Utils4J.checkNotNull("file", file);
Utils4J.checkValidFile(file);
try {
final InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
try {
return load(inputStream);
} finally {
inputStream.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
} | java | public static Dependencies load(final File file) {
Utils4J.checkNotNull("file", file);
Utils4J.checkValidFile(file);
try {
final InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
try {
return load(inputStream);
} finally {
inputStream.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
} | [
"public",
"static",
"Dependencies",
"load",
"(",
"final",
"File",
"file",
")",
"{",
"Utils4J",
".",
"checkNotNull",
"(",
"\"file\"",
",",
"file",
")",
";",
"Utils4J",
".",
"checkValidFile",
"(",
"file",
")",
";",
"try",
"{",
"final",
"InputStream",
"inputStream",
"=",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
")",
";",
"try",
"{",
"return",
"load",
"(",
"inputStream",
")",
";",
"}",
"finally",
"{",
"inputStream",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}"
] | Load dependencies from a file.
@param file
XML File to load - Cannot be <code>null</code> and must be a valid file.
@return New dependencies instance. | [
"Load",
"dependencies",
"from",
"a",
"file",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/dependency/Utils.java#L80-L93 |
141,721 | fuinorg/units4j | src/main/java/org/fuin/units4j/dependency/Utils.java | Utils.load | public static Dependencies load(final InputStream inputStream) {
Utils4J.checkNotNull("inputStream", inputStream);
final XStream xstream = createXStream();
final Reader reader = new InputStreamReader(inputStream);
return (Dependencies) xstream.fromXML(reader);
} | java | public static Dependencies load(final InputStream inputStream) {
Utils4J.checkNotNull("inputStream", inputStream);
final XStream xstream = createXStream();
final Reader reader = new InputStreamReader(inputStream);
return (Dependencies) xstream.fromXML(reader);
} | [
"public",
"static",
"Dependencies",
"load",
"(",
"final",
"InputStream",
"inputStream",
")",
"{",
"Utils4J",
".",
"checkNotNull",
"(",
"\"inputStream\"",
",",
"inputStream",
")",
";",
"final",
"XStream",
"xstream",
"=",
"createXStream",
"(",
")",
";",
"final",
"Reader",
"reader",
"=",
"new",
"InputStreamReader",
"(",
"inputStream",
")",
";",
"return",
"(",
"Dependencies",
")",
"xstream",
".",
"fromXML",
"(",
"reader",
")",
";",
"}"
] | Load dependencies from an input stream.
@param inputStream
XML input stream to read - Cannot be <code>null</code>.
@return New dependencies instance. | [
"Load",
"dependencies",
"from",
"an",
"input",
"stream",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/dependency/Utils.java#L103-L108 |
141,722 | fuinorg/units4j | src/main/java/org/fuin/units4j/dependency/Utils.java | Utils.load | public static Dependencies load(final Class<?> clasz, final String resourcePathAndName) {
Utils4J.checkNotNull("clasz", clasz);
Utils4J.checkNotNull("resourcePathAndName", resourcePathAndName);
try {
final URL url = clasz.getResource(resourcePathAndName);
if (url == null) {
throw new RuntimeException("Resource '" + resourcePathAndName + "' not found!");
}
final InputStream in = url.openStream();
try {
return load(in);
} finally {
in.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
} | java | public static Dependencies load(final Class<?> clasz, final String resourcePathAndName) {
Utils4J.checkNotNull("clasz", clasz);
Utils4J.checkNotNull("resourcePathAndName", resourcePathAndName);
try {
final URL url = clasz.getResource(resourcePathAndName);
if (url == null) {
throw new RuntimeException("Resource '" + resourcePathAndName + "' not found!");
}
final InputStream in = url.openStream();
try {
return load(in);
} finally {
in.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
} | [
"public",
"static",
"Dependencies",
"load",
"(",
"final",
"Class",
"<",
"?",
">",
"clasz",
",",
"final",
"String",
"resourcePathAndName",
")",
"{",
"Utils4J",
".",
"checkNotNull",
"(",
"\"clasz\"",
",",
"clasz",
")",
";",
"Utils4J",
".",
"checkNotNull",
"(",
"\"resourcePathAndName\"",
",",
"resourcePathAndName",
")",
";",
"try",
"{",
"final",
"URL",
"url",
"=",
"clasz",
".",
"getResource",
"(",
"resourcePathAndName",
")",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Resource '\"",
"+",
"resourcePathAndName",
"+",
"\"' not found!\"",
")",
";",
"}",
"final",
"InputStream",
"in",
"=",
"url",
".",
"openStream",
"(",
")",
";",
"try",
"{",
"return",
"load",
"(",
"in",
")",
";",
"}",
"finally",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}"
] | Load dependencies from a resource.
@param clasz
Class to use for loading the resource - Cannot be <code>null</code>.
@param resourcePathAndName
Name and path of the XML file (in the class path) - Cannot be <code>null</code>.
@return New dependencies instance. | [
"Load",
"dependencies",
"from",
"a",
"resource",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/dependency/Utils.java#L120-L139 |
141,723 | fuinorg/units4j | src/main/java/org/fuin/units4j/dependency/Utils.java | Utils.save | public static void save(final File file, final Dependencies dependencies) {
Utils4J.checkNotNull("file", file);
Utils4J.checkValidFile(file);
final XStream xstream = createXStream();
try {
final Writer writer = new FileWriter(file);
try {
xstream.toXML(dependencies, writer);
} finally {
writer.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
} | java | public static void save(final File file, final Dependencies dependencies) {
Utils4J.checkNotNull("file", file);
Utils4J.checkValidFile(file);
final XStream xstream = createXStream();
try {
final Writer writer = new FileWriter(file);
try {
xstream.toXML(dependencies, writer);
} finally {
writer.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
} | [
"public",
"static",
"void",
"save",
"(",
"final",
"File",
"file",
",",
"final",
"Dependencies",
"dependencies",
")",
"{",
"Utils4J",
".",
"checkNotNull",
"(",
"\"file\"",
",",
"file",
")",
";",
"Utils4J",
".",
"checkValidFile",
"(",
"file",
")",
";",
"final",
"XStream",
"xstream",
"=",
"createXStream",
"(",
")",
";",
"try",
"{",
"final",
"Writer",
"writer",
"=",
"new",
"FileWriter",
"(",
"file",
")",
";",
"try",
"{",
"xstream",
".",
"toXML",
"(",
"dependencies",
",",
"writer",
")",
";",
"}",
"finally",
"{",
"writer",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}"
] | Write the dependencies to a file.
@param file
XML File - Cannot be <code>null</code> and must be a valid file.
@param dependencies
Dependencies to save. | [
"Write",
"the",
"dependencies",
"to",
"a",
"file",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/dependency/Utils.java#L149-L163 |
141,724 | fuinorg/units4j | src/main/java/org/fuin/units4j/analyzer/MethodCallAnalyzer.java | MethodCallAnalyzer.findCallingMethodsInJar | public final void findCallingMethodsInJar(final File file) throws IOException {
try (final JarFile jarFile = new JarFile(file)) {
final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
if (entry.getName().endsWith(".class")) {
final InputStream in = new BufferedInputStream(jarFile.getInputStream(entry), 1024);
try {
new ClassReader(in).accept(cv, 0);
} finally {
in.close();
}
}
}
}
} | java | public final void findCallingMethodsInJar(final File file) throws IOException {
try (final JarFile jarFile = new JarFile(file)) {
final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
if (entry.getName().endsWith(".class")) {
final InputStream in = new BufferedInputStream(jarFile.getInputStream(entry), 1024);
try {
new ClassReader(in).accept(cv, 0);
} finally {
in.close();
}
}
}
}
} | [
"public",
"final",
"void",
"findCallingMethodsInJar",
"(",
"final",
"File",
"file",
")",
"throws",
"IOException",
"{",
"try",
"(",
"final",
"JarFile",
"jarFile",
"=",
"new",
"JarFile",
"(",
"file",
")",
")",
"{",
"final",
"Enumeration",
"<",
"JarEntry",
">",
"entries",
"=",
"jarFile",
".",
"entries",
"(",
")",
";",
"while",
"(",
"entries",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"final",
"JarEntry",
"entry",
"=",
"entries",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"entry",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".class\"",
")",
")",
"{",
"final",
"InputStream",
"in",
"=",
"new",
"BufferedInputStream",
"(",
"jarFile",
".",
"getInputStream",
"(",
"entry",
")",
",",
"1024",
")",
";",
"try",
"{",
"new",
"ClassReader",
"(",
"in",
")",
".",
"accept",
"(",
"cv",
",",
"0",
")",
";",
"}",
"finally",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Locate method calls in classes of a JAR file.
@param file
File to search.
@throws IOException
Error reading the file. | [
"Locate",
"method",
"calls",
"in",
"classes",
"of",
"a",
"JAR",
"file",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/analyzer/MethodCallAnalyzer.java#L84-L104 |
141,725 | fuinorg/units4j | src/main/java/org/fuin/units4j/analyzer/MethodCallAnalyzer.java | MethodCallAnalyzer.findCallingMethodsInDir | public final void findCallingMethodsInDir(final File dir, final FileFilter filter) {
final FileProcessor fileProcessor = new FileProcessor(new FileHandler() {
@Override
public final FileHandlerResult handleFile(final File file) {
if (file.isDirectory()) {
return FileHandlerResult.CONTINUE;
}
if (file.getName().endsWith(".class") && (filter == null || filter.accept(file))) {
handleClass(file);
}
return FileHandlerResult.CONTINUE;
}
});
fileProcessor.process(dir);
} | java | public final void findCallingMethodsInDir(final File dir, final FileFilter filter) {
final FileProcessor fileProcessor = new FileProcessor(new FileHandler() {
@Override
public final FileHandlerResult handleFile(final File file) {
if (file.isDirectory()) {
return FileHandlerResult.CONTINUE;
}
if (file.getName().endsWith(".class") && (filter == null || filter.accept(file))) {
handleClass(file);
}
return FileHandlerResult.CONTINUE;
}
});
fileProcessor.process(dir);
} | [
"public",
"final",
"void",
"findCallingMethodsInDir",
"(",
"final",
"File",
"dir",
",",
"final",
"FileFilter",
"filter",
")",
"{",
"final",
"FileProcessor",
"fileProcessor",
"=",
"new",
"FileProcessor",
"(",
"new",
"FileHandler",
"(",
")",
"{",
"@",
"Override",
"public",
"final",
"FileHandlerResult",
"handleFile",
"(",
"final",
"File",
"file",
")",
"{",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"FileHandlerResult",
".",
"CONTINUE",
";",
"}",
"if",
"(",
"file",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".class\"",
")",
"&&",
"(",
"filter",
"==",
"null",
"||",
"filter",
".",
"accept",
"(",
"file",
")",
")",
")",
"{",
"handleClass",
"(",
"file",
")",
";",
"}",
"return",
"FileHandlerResult",
".",
"CONTINUE",
";",
"}",
"}",
")",
";",
"fileProcessor",
".",
"process",
"(",
"dir",
")",
";",
"}"
] | Locate method calls in classes of a directory.
@param dir
Directory to search (including sub directories).
@param filter
File filter or NULL (process all '*.class' files). | [
"Locate",
"method",
"calls",
"in",
"classes",
"of",
"a",
"directory",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/analyzer/MethodCallAnalyzer.java#L137-L153 |
141,726 | fuinorg/units4j | src/main/java/org/fuin/units4j/analyzer/MCAClassVisitor.java | MCAClassVisitor.addCall | public final void addCall(final MCAMethod found, final int line) {
calls.add(new MCAMethodCall(found, className, methodName, methodDescr, source, line));
} | java | public final void addCall(final MCAMethod found, final int line) {
calls.add(new MCAMethodCall(found, className, methodName, methodDescr, source, line));
} | [
"public",
"final",
"void",
"addCall",
"(",
"final",
"MCAMethod",
"found",
",",
"final",
"int",
"line",
")",
"{",
"calls",
".",
"add",
"(",
"new",
"MCAMethodCall",
"(",
"found",
",",
"className",
",",
"methodName",
",",
"methodDescr",
",",
"source",
",",
"line",
")",
")",
";",
"}"
] | Adds the current method to the list of callers.
@param found
Called method.
@param line
Line number of the call. | [
"Adds",
"the",
"current",
"method",
"to",
"the",
"list",
"of",
"callers",
"."
] | 29383e30b0f9c246b309e734df9cc63dc5d5499e | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/analyzer/MCAClassVisitor.java#L88-L90 |
141,727 | hortonworks/dstream | dstream-api/src/main/java/io/dstream/DStreamExecutionGraphBuilder.java | DStreamExecutionGraphBuilder.createDefaultExtractOperation | private void createDefaultExtractOperation(){
this.currentStreamOperation = new DStreamOperation(this.operationIdCounter++);
this.currentStreamOperation.addStreamOperationFunction(Ops.extract.name(), s -> s);
} | java | private void createDefaultExtractOperation(){
this.currentStreamOperation = new DStreamOperation(this.operationIdCounter++);
this.currentStreamOperation.addStreamOperationFunction(Ops.extract.name(), s -> s);
} | [
"private",
"void",
"createDefaultExtractOperation",
"(",
")",
"{",
"this",
".",
"currentStreamOperation",
"=",
"new",
"DStreamOperation",
"(",
"this",
".",
"operationIdCounter",
"++",
")",
";",
"this",
".",
"currentStreamOperation",
".",
"addStreamOperationFunction",
"(",
"Ops",
".",
"extract",
".",
"name",
"(",
")",
",",
"s",
"->",
"s",
")",
";",
"}"
] | Will create an operation named 'extract' with a pass-thru function | [
"Will",
"create",
"an",
"operation",
"named",
"extract",
"with",
"a",
"pass",
"-",
"thru",
"function"
] | 3a106c0f14725b028fe7fe2dbc660406d9a5f142 | https://github.com/hortonworks/dstream/blob/3a106c0f14725b028fe7fe2dbc660406d9a5f142/dstream-api/src/main/java/io/dstream/DStreamExecutionGraphBuilder.java#L413-L416 |
141,728 | hortonworks/dstream | dstream-tez/src/main/java/io/dstream/tez/utils/ClassPathUtils.java | ClassPathUtils.toJar | public static File toJar(File sourceDir, String jarName) {
if (!sourceDir.isAbsolute()) {
throw new IllegalArgumentException("Source must be expressed through absolute path");
}
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
File jarFile = new File(jarName);
try {
JarOutputStream target = new JarOutputStream(new FileOutputStream(jarFile), manifest);
add(sourceDir, sourceDir.getAbsolutePath().length(), target);
target.close();
}
catch (Exception e) {
throw new IllegalStateException("Failed to create JAR file '"
+ jarName + "' from " + sourceDir.getAbsolutePath(), e);
}
return jarFile;
} | java | public static File toJar(File sourceDir, String jarName) {
if (!sourceDir.isAbsolute()) {
throw new IllegalArgumentException("Source must be expressed through absolute path");
}
Manifest manifest = new Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
File jarFile = new File(jarName);
try {
JarOutputStream target = new JarOutputStream(new FileOutputStream(jarFile), manifest);
add(sourceDir, sourceDir.getAbsolutePath().length(), target);
target.close();
}
catch (Exception e) {
throw new IllegalStateException("Failed to create JAR file '"
+ jarName + "' from " + sourceDir.getAbsolutePath(), e);
}
return jarFile;
} | [
"public",
"static",
"File",
"toJar",
"(",
"File",
"sourceDir",
",",
"String",
"jarName",
")",
"{",
"if",
"(",
"!",
"sourceDir",
".",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Source must be expressed through absolute path\"",
")",
";",
"}",
"Manifest",
"manifest",
"=",
"new",
"Manifest",
"(",
")",
";",
"manifest",
".",
"getMainAttributes",
"(",
")",
".",
"put",
"(",
"Attributes",
".",
"Name",
".",
"MANIFEST_VERSION",
",",
"\"1.0\"",
")",
";",
"File",
"jarFile",
"=",
"new",
"File",
"(",
"jarName",
")",
";",
"try",
"{",
"JarOutputStream",
"target",
"=",
"new",
"JarOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"jarFile",
")",
",",
"manifest",
")",
";",
"add",
"(",
"sourceDir",
",",
"sourceDir",
".",
"getAbsolutePath",
"(",
")",
".",
"length",
"(",
")",
",",
"target",
")",
";",
"target",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Failed to create JAR file '\"",
"+",
"jarName",
"+",
"\"' from \"",
"+",
"sourceDir",
".",
"getAbsolutePath",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"jarFile",
";",
"}"
] | Will create a JAR file from base dir
@param sourceDir
@param jarName
@return | [
"Will",
"create",
"a",
"JAR",
"file",
"from",
"base",
"dir"
] | 3a106c0f14725b028fe7fe2dbc660406d9a5f142 | https://github.com/hortonworks/dstream/blob/3a106c0f14725b028fe7fe2dbc660406d9a5f142/dstream-tez/src/main/java/io/dstream/tez/utils/ClassPathUtils.java#L76-L93 |
141,729 | hortonworks/dstream | dstream-nifi/src/main/java/io/dstream/nifi/AbstractDStreamProcessor.java | AbstractDStreamProcessor.installConfiguration | private String installConfiguration(String configurationName, InputStream confFileInputStream){
String outputPath;
try {
File confDir = new File(System.getProperty("java.io.tmpdir") + "/dstream_" + UUID.randomUUID());
confDir.mkdirs();
File executionConfig = new File(confDir, configurationName);
executionConfig.deleteOnExit();
FileOutputStream confFileOs = new FileOutputStream(executionConfig);
Properties configurationProperties = new Properties();
configurationProperties.load(confFileInputStream);
configurationProperties.store(confFileOs, configurationName + " configuration");
this.addToClassPath(confDir);
outputPath = configurationProperties.containsKey(DStreamConstants.OUTPUT)
? configurationProperties.getProperty(DStreamConstants.OUTPUT)
: configurationName.split("\\.")[0] + "/out";
}
catch (Exception e) {
throw new IllegalStateException("Failed to generate execution config", e);
}
return outputPath;
} | java | private String installConfiguration(String configurationName, InputStream confFileInputStream){
String outputPath;
try {
File confDir = new File(System.getProperty("java.io.tmpdir") + "/dstream_" + UUID.randomUUID());
confDir.mkdirs();
File executionConfig = new File(confDir, configurationName);
executionConfig.deleteOnExit();
FileOutputStream confFileOs = new FileOutputStream(executionConfig);
Properties configurationProperties = new Properties();
configurationProperties.load(confFileInputStream);
configurationProperties.store(confFileOs, configurationName + " configuration");
this.addToClassPath(confDir);
outputPath = configurationProperties.containsKey(DStreamConstants.OUTPUT)
? configurationProperties.getProperty(DStreamConstants.OUTPUT)
: configurationName.split("\\.")[0] + "/out";
}
catch (Exception e) {
throw new IllegalStateException("Failed to generate execution config", e);
}
return outputPath;
} | [
"private",
"String",
"installConfiguration",
"(",
"String",
"configurationName",
",",
"InputStream",
"confFileInputStream",
")",
"{",
"String",
"outputPath",
";",
"try",
"{",
"File",
"confDir",
"=",
"new",
"File",
"(",
"System",
".",
"getProperty",
"(",
"\"java.io.tmpdir\"",
")",
"+",
"\"/dstream_\"",
"+",
"UUID",
".",
"randomUUID",
"(",
")",
")",
";",
"confDir",
".",
"mkdirs",
"(",
")",
";",
"File",
"executionConfig",
"=",
"new",
"File",
"(",
"confDir",
",",
"configurationName",
")",
";",
"executionConfig",
".",
"deleteOnExit",
"(",
")",
";",
"FileOutputStream",
"confFileOs",
"=",
"new",
"FileOutputStream",
"(",
"executionConfig",
")",
";",
"Properties",
"configurationProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"configurationProperties",
".",
"load",
"(",
"confFileInputStream",
")",
";",
"configurationProperties",
".",
"store",
"(",
"confFileOs",
",",
"configurationName",
"+",
"\" configuration\"",
")",
";",
"this",
".",
"addToClassPath",
"(",
"confDir",
")",
";",
"outputPath",
"=",
"configurationProperties",
".",
"containsKey",
"(",
"DStreamConstants",
".",
"OUTPUT",
")",
"?",
"configurationProperties",
".",
"getProperty",
"(",
"DStreamConstants",
".",
"OUTPUT",
")",
":",
"configurationName",
".",
"split",
"(",
"\"\\\\.\"",
")",
"[",
"0",
"]",
"+",
"\"/out\"",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Failed to generate execution config\"",
",",
"e",
")",
";",
"}",
"return",
"outputPath",
";",
"}"
] | Will generate execution configuration and add it to the classpath
@param context | [
"Will",
"generate",
"execution",
"configuration",
"and",
"add",
"it",
"to",
"the",
"classpath"
] | 3a106c0f14725b028fe7fe2dbc660406d9a5f142 | https://github.com/hortonworks/dstream/blob/3a106c0f14725b028fe7fe2dbc660406d9a5f142/dstream-nifi/src/main/java/io/dstream/nifi/AbstractDStreamProcessor.java#L233-L256 |
141,730 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <T, U, E extends Exception> BiConsumer<T, U> sneaked(
SneakyBiConsumer<T, U, E> biConsumer) {
return (t, u) -> {
@SuppressWarnings("unchecked")
SneakyBiConsumer<T, U, RuntimeException> castedBiConsumer =
(SneakyBiConsumer<T, U, RuntimeException>) biConsumer;
castedBiConsumer.accept(t, u);
};
} | java | public static <T, U, E extends Exception> BiConsumer<T, U> sneaked(
SneakyBiConsumer<T, U, E> biConsumer) {
return (t, u) -> {
@SuppressWarnings("unchecked")
SneakyBiConsumer<T, U, RuntimeException> castedBiConsumer =
(SneakyBiConsumer<T, U, RuntimeException>) biConsumer;
castedBiConsumer.accept(t, u);
};
} | [
"public",
"static",
"<",
"T",
",",
"U",
",",
"E",
"extends",
"Exception",
">",
"BiConsumer",
"<",
"T",
",",
"U",
">",
"sneaked",
"(",
"SneakyBiConsumer",
"<",
"T",
",",
"U",
",",
"E",
">",
"biConsumer",
")",
"{",
"return",
"(",
"t",
",",
"u",
")",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakyBiConsumer",
"<",
"T",
",",
"U",
",",
"RuntimeException",
">",
"castedBiConsumer",
"=",
"(",
"SneakyBiConsumer",
"<",
"T",
",",
"U",
",",
"RuntimeException",
">",
")",
"biConsumer",
";",
"castedBiConsumer",
".",
"accept",
"(",
"t",
",",
"u",
")",
";",
"}",
";",
"}"
] | Sneaky throws a BiConsumer lambda.
@param biConsumer BiConsumer that can throw an exception
@param <T> type of first argument
@param <U> type of the second argument
@return a BiConsumer as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"BiConsumer",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L95-L103 |
141,731 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <T, U, R, E extends Exception> BiFunction<T, U, R> sneaked(
SneakyBiFunction<T, U, R, E> biFunction) {
return (t, u) -> {
@SuppressWarnings("unchecked")
SneakyBiFunction<T, U, R, RuntimeException> castedBiFunction =
(SneakyBiFunction<T, U, R, RuntimeException>) biFunction;
return castedBiFunction.apply(t, u);
};
} | java | public static <T, U, R, E extends Exception> BiFunction<T, U, R> sneaked(
SneakyBiFunction<T, U, R, E> biFunction) {
return (t, u) -> {
@SuppressWarnings("unchecked")
SneakyBiFunction<T, U, R, RuntimeException> castedBiFunction =
(SneakyBiFunction<T, U, R, RuntimeException>) biFunction;
return castedBiFunction.apply(t, u);
};
} | [
"public",
"static",
"<",
"T",
",",
"U",
",",
"R",
",",
"E",
"extends",
"Exception",
">",
"BiFunction",
"<",
"T",
",",
"U",
",",
"R",
">",
"sneaked",
"(",
"SneakyBiFunction",
"<",
"T",
",",
"U",
",",
"R",
",",
"E",
">",
"biFunction",
")",
"{",
"return",
"(",
"t",
",",
"u",
")",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakyBiFunction",
"<",
"T",
",",
"U",
",",
"R",
",",
"RuntimeException",
">",
"castedBiFunction",
"=",
"(",
"SneakyBiFunction",
"<",
"T",
",",
"U",
",",
"R",
",",
"RuntimeException",
">",
")",
"biFunction",
";",
"return",
"castedBiFunction",
".",
"apply",
"(",
"t",
",",
"u",
")",
";",
"}",
";",
"}"
] | Sneaky throws a BiFunction lambda.
@param biFunction BiFunction that can throw an exception
@param <T> type of first argument
@param <U> type of second argument
@param <R> return type of biFunction
@return a BiFunction as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"BiFunction",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L114-L122 |
141,732 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <T, E extends Exception> BinaryOperator<T> sneaked(
SneakyBinaryOperator<T, E> binaryOperator) {
return (t1, t2) -> {
@SuppressWarnings("unchecked")
SneakyBinaryOperator<T, RuntimeException> castedBinaryOperator =
(SneakyBinaryOperator<T, RuntimeException>) binaryOperator;
return castedBinaryOperator.apply(t1, t2);
};
} | java | public static <T, E extends Exception> BinaryOperator<T> sneaked(
SneakyBinaryOperator<T, E> binaryOperator) {
return (t1, t2) -> {
@SuppressWarnings("unchecked")
SneakyBinaryOperator<T, RuntimeException> castedBinaryOperator =
(SneakyBinaryOperator<T, RuntimeException>) binaryOperator;
return castedBinaryOperator.apply(t1, t2);
};
} | [
"public",
"static",
"<",
"T",
",",
"E",
"extends",
"Exception",
">",
"BinaryOperator",
"<",
"T",
">",
"sneaked",
"(",
"SneakyBinaryOperator",
"<",
"T",
",",
"E",
">",
"binaryOperator",
")",
"{",
"return",
"(",
"t1",
",",
"t2",
")",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakyBinaryOperator",
"<",
"T",
",",
"RuntimeException",
">",
"castedBinaryOperator",
"=",
"(",
"SneakyBinaryOperator",
"<",
"T",
",",
"RuntimeException",
">",
")",
"binaryOperator",
";",
"return",
"castedBinaryOperator",
".",
"apply",
"(",
"t1",
",",
"t2",
")",
";",
"}",
";",
"}"
] | Sneaky throws a BinaryOperator lambda.
@param binaryOperator BinaryOperator that can throw an exception
@param <T> type of the two arguments and the return type of the binaryOperator
@return a BinaryOperator as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"BinaryOperator",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L131-L139 |
141,733 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <T, U, E extends Exception> BiPredicate<T, U> sneaked(
SneakyBiPredicate<T, U, E> biPredicate) {
return (t, u) -> {
@SuppressWarnings("unchecked")
SneakyBiPredicate<T, U, RuntimeException> castedBiPredicate =
(SneakyBiPredicate<T, U, RuntimeException>) biPredicate;
return castedBiPredicate.test(t, u);
};
} | java | public static <T, U, E extends Exception> BiPredicate<T, U> sneaked(
SneakyBiPredicate<T, U, E> biPredicate) {
return (t, u) -> {
@SuppressWarnings("unchecked")
SneakyBiPredicate<T, U, RuntimeException> castedBiPredicate =
(SneakyBiPredicate<T, U, RuntimeException>) biPredicate;
return castedBiPredicate.test(t, u);
};
} | [
"public",
"static",
"<",
"T",
",",
"U",
",",
"E",
"extends",
"Exception",
">",
"BiPredicate",
"<",
"T",
",",
"U",
">",
"sneaked",
"(",
"SneakyBiPredicate",
"<",
"T",
",",
"U",
",",
"E",
">",
"biPredicate",
")",
"{",
"return",
"(",
"t",
",",
"u",
")",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakyBiPredicate",
"<",
"T",
",",
"U",
",",
"RuntimeException",
">",
"castedBiPredicate",
"=",
"(",
"SneakyBiPredicate",
"<",
"T",
",",
"U",
",",
"RuntimeException",
">",
")",
"biPredicate",
";",
"return",
"castedBiPredicate",
".",
"test",
"(",
"t",
",",
"u",
")",
";",
"}",
";",
"}"
] | Sneaky throws a BiPredicate lambda.
@param biPredicate BiPredicate that can throw an exception
@param <T> type of first argument
@param <U> type of second argument
@return a BiPredicate as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"BiPredicate",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L149-L157 |
141,734 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <T, E extends Exception> Consumer<T> sneaked(SneakyConsumer<T, E> consumer) {
return t -> {
@SuppressWarnings("unchecked")
SneakyConsumer<T, RuntimeException> casedConsumer =
(SneakyConsumer<T, RuntimeException>) consumer;
casedConsumer.accept(t);
};
} | java | public static <T, E extends Exception> Consumer<T> sneaked(SneakyConsumer<T, E> consumer) {
return t -> {
@SuppressWarnings("unchecked")
SneakyConsumer<T, RuntimeException> casedConsumer =
(SneakyConsumer<T, RuntimeException>) consumer;
casedConsumer.accept(t);
};
} | [
"public",
"static",
"<",
"T",
",",
"E",
"extends",
"Exception",
">",
"Consumer",
"<",
"T",
">",
"sneaked",
"(",
"SneakyConsumer",
"<",
"T",
",",
"E",
">",
"consumer",
")",
"{",
"return",
"t",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakyConsumer",
"<",
"T",
",",
"RuntimeException",
">",
"casedConsumer",
"=",
"(",
"SneakyConsumer",
"<",
"T",
",",
"RuntimeException",
">",
")",
"consumer",
";",
"casedConsumer",
".",
"accept",
"(",
"t",
")",
";",
"}",
";",
"}"
] | Sneaky throws a Consumer lambda.
@param consumer Consumer that can throw an exception
@param <T> type of first argument
@return a Consumer as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"Consumer",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L166-L173 |
141,735 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <T, R, E extends Exception> Function<T, R> sneaked(
SneakyFunction<T, R, E> function) {
return t -> {
@SuppressWarnings("unchecked")
SneakyFunction<T, R, RuntimeException> f1 = (SneakyFunction<T, R, RuntimeException>) function;
return f1.apply(t);
};
} | java | public static <T, R, E extends Exception> Function<T, R> sneaked(
SneakyFunction<T, R, E> function) {
return t -> {
@SuppressWarnings("unchecked")
SneakyFunction<T, R, RuntimeException> f1 = (SneakyFunction<T, R, RuntimeException>) function;
return f1.apply(t);
};
} | [
"public",
"static",
"<",
"T",
",",
"R",
",",
"E",
"extends",
"Exception",
">",
"Function",
"<",
"T",
",",
"R",
">",
"sneaked",
"(",
"SneakyFunction",
"<",
"T",
",",
"R",
",",
"E",
">",
"function",
")",
"{",
"return",
"t",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakyFunction",
"<",
"T",
",",
"R",
",",
"RuntimeException",
">",
"f1",
"=",
"(",
"SneakyFunction",
"<",
"T",
",",
"R",
",",
"RuntimeException",
">",
")",
"function",
";",
"return",
"f1",
".",
"apply",
"(",
"t",
")",
";",
"}",
";",
"}"
] | Sneaky throws a Function lambda.
@param function Function that can throw an exception
@param <T> type of first argument
@param <R> type of the second argument
@return a Function as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"Function",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L183-L190 |
141,736 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <T, E extends Exception> Predicate<T> sneaked(SneakyPredicate<T, E> predicate) {
return t -> {
@SuppressWarnings("unchecked")
SneakyPredicate<T, RuntimeException> castedSneakyPredicate =
(SneakyPredicate<T, RuntimeException>) predicate;
return castedSneakyPredicate.test(t);
};
} | java | public static <T, E extends Exception> Predicate<T> sneaked(SneakyPredicate<T, E> predicate) {
return t -> {
@SuppressWarnings("unchecked")
SneakyPredicate<T, RuntimeException> castedSneakyPredicate =
(SneakyPredicate<T, RuntimeException>) predicate;
return castedSneakyPredicate.test(t);
};
} | [
"public",
"static",
"<",
"T",
",",
"E",
"extends",
"Exception",
">",
"Predicate",
"<",
"T",
">",
"sneaked",
"(",
"SneakyPredicate",
"<",
"T",
",",
"E",
">",
"predicate",
")",
"{",
"return",
"t",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakyPredicate",
"<",
"T",
",",
"RuntimeException",
">",
"castedSneakyPredicate",
"=",
"(",
"SneakyPredicate",
"<",
"T",
",",
"RuntimeException",
">",
")",
"predicate",
";",
"return",
"castedSneakyPredicate",
".",
"test",
"(",
"t",
")",
";",
"}",
";",
"}"
] | Sneaky throws a Predicate lambda.
@param predicate Predicate that can throw an exception
@param <T> type of first argument
@return a Predicate as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"Predicate",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L199-L206 |
141,737 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <E extends Exception> Runnable sneaked(SneakyRunnable<E> runnable) {
return () -> {
@SuppressWarnings("unchecked")
SneakyRunnable<RuntimeException> castedRunnable = (SneakyRunnable<RuntimeException>) runnable;
castedRunnable.run();
};
} | java | public static <E extends Exception> Runnable sneaked(SneakyRunnable<E> runnable) {
return () -> {
@SuppressWarnings("unchecked")
SneakyRunnable<RuntimeException> castedRunnable = (SneakyRunnable<RuntimeException>) runnable;
castedRunnable.run();
};
} | [
"public",
"static",
"<",
"E",
"extends",
"Exception",
">",
"Runnable",
"sneaked",
"(",
"SneakyRunnable",
"<",
"E",
">",
"runnable",
")",
"{",
"return",
"(",
")",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakyRunnable",
"<",
"RuntimeException",
">",
"castedRunnable",
"=",
"(",
"SneakyRunnable",
"<",
"RuntimeException",
">",
")",
"runnable",
";",
"castedRunnable",
".",
"run",
"(",
")",
";",
"}",
";",
"}"
] | Sneaky throws a Runnable lambda.
@param runnable Runnable that can throw an exception
@return a Runnable as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"Runnable",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L214-L220 |
141,738 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <T, E extends Exception> Supplier<T> sneaked(SneakySupplier<T, E> supplier) {
return () -> {
@SuppressWarnings("unchecked")
SneakySupplier<T, RuntimeException> castedSupplier =
(SneakySupplier<T, RuntimeException>) supplier;
return castedSupplier.get();
};
} | java | public static <T, E extends Exception> Supplier<T> sneaked(SneakySupplier<T, E> supplier) {
return () -> {
@SuppressWarnings("unchecked")
SneakySupplier<T, RuntimeException> castedSupplier =
(SneakySupplier<T, RuntimeException>) supplier;
return castedSupplier.get();
};
} | [
"public",
"static",
"<",
"T",
",",
"E",
"extends",
"Exception",
">",
"Supplier",
"<",
"T",
">",
"sneaked",
"(",
"SneakySupplier",
"<",
"T",
",",
"E",
">",
"supplier",
")",
"{",
"return",
"(",
")",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakySupplier",
"<",
"T",
",",
"RuntimeException",
">",
"castedSupplier",
"=",
"(",
"SneakySupplier",
"<",
"T",
",",
"RuntimeException",
">",
")",
"supplier",
";",
"return",
"castedSupplier",
".",
"get",
"(",
")",
";",
"}",
";",
"}"
] | Sneaky throws a Supplier lambda.
@param supplier Supplier that can throw an exception
@param <T> type of supplier's return value
@return a Supplier as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"Supplier",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L229-L236 |
141,739 | rainerhahnekamp/sneakythrow | src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java | Sneaky.sneaked | public static <T, E extends Exception> UnaryOperator<T> sneaked(
SneakyUnaryOperator<T, E> unaryOperator) {
return t -> {
@SuppressWarnings("unchecked")
SneakyUnaryOperator<T, RuntimeException> castedUnaryOperator =
(SneakyUnaryOperator<T, RuntimeException>) unaryOperator;
return castedUnaryOperator.apply(t);
};
} | java | public static <T, E extends Exception> UnaryOperator<T> sneaked(
SneakyUnaryOperator<T, E> unaryOperator) {
return t -> {
@SuppressWarnings("unchecked")
SneakyUnaryOperator<T, RuntimeException> castedUnaryOperator =
(SneakyUnaryOperator<T, RuntimeException>) unaryOperator;
return castedUnaryOperator.apply(t);
};
} | [
"public",
"static",
"<",
"T",
",",
"E",
"extends",
"Exception",
">",
"UnaryOperator",
"<",
"T",
">",
"sneaked",
"(",
"SneakyUnaryOperator",
"<",
"T",
",",
"E",
">",
"unaryOperator",
")",
"{",
"return",
"t",
"->",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"SneakyUnaryOperator",
"<",
"T",
",",
"RuntimeException",
">",
"castedUnaryOperator",
"=",
"(",
"SneakyUnaryOperator",
"<",
"T",
",",
"RuntimeException",
">",
")",
"unaryOperator",
";",
"return",
"castedUnaryOperator",
".",
"apply",
"(",
"t",
")",
";",
"}",
";",
"}"
] | Sneaky throws a UnaryOperator lambda.
@param unaryOperator UnaryOperator that can throw an exception
@param <T> type of unaryOperator's argument and returned value
@return a UnaryOperator as defined in java.util.function | [
"Sneaky",
"throws",
"a",
"UnaryOperator",
"lambda",
"."
] | 789eb3c8df4287742f88548f1569654ff2b38390 | https://github.com/rainerhahnekamp/sneakythrow/blob/789eb3c8df4287742f88548f1569654ff2b38390/src/main/java/com/rainerhahnekamp/sneakythrow/Sneaky.java#L245-L253 |
141,740 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/util/StringUtil.java | StringUtil.split | public static String[] split(String input, char delimiter){
if(input == null) throw new NullPointerException("input cannot be null");
final int len = input.length();
// find the number of strings to split into
int nSplits = 1;
for (int i = 0; i < len; i++) {
if (input.charAt(i) == delimiter) {
nSplits++;
}
}
// do the actual splitting
String[] result = new String[nSplits];
int lastMark = 0;
int lastSplit = 0;
for (int i = 0; i < len; i++) {
if (input.charAt(i) == delimiter) {
result[lastSplit] = input.substring(lastMark, i);
lastSplit++;
lastMark = i + 1;// 1 == delimiter length
}
}
result[lastSplit] = input.substring(lastMark, len);
return result;
} | java | public static String[] split(String input, char delimiter){
if(input == null) throw new NullPointerException("input cannot be null");
final int len = input.length();
// find the number of strings to split into
int nSplits = 1;
for (int i = 0; i < len; i++) {
if (input.charAt(i) == delimiter) {
nSplits++;
}
}
// do the actual splitting
String[] result = new String[nSplits];
int lastMark = 0;
int lastSplit = 0;
for (int i = 0; i < len; i++) {
if (input.charAt(i) == delimiter) {
result[lastSplit] = input.substring(lastMark, i);
lastSplit++;
lastMark = i + 1;// 1 == delimiter length
}
}
result[lastSplit] = input.substring(lastMark, len);
return result;
} | [
"public",
"static",
"String",
"[",
"]",
"split",
"(",
"String",
"input",
",",
"char",
"delimiter",
")",
"{",
"if",
"(",
"input",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"input cannot be null\"",
")",
";",
"final",
"int",
"len",
"=",
"input",
".",
"length",
"(",
")",
";",
"// find the number of strings to split into",
"int",
"nSplits",
"=",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"input",
".",
"charAt",
"(",
"i",
")",
"==",
"delimiter",
")",
"{",
"nSplits",
"++",
";",
"}",
"}",
"// do the actual splitting",
"String",
"[",
"]",
"result",
"=",
"new",
"String",
"[",
"nSplits",
"]",
";",
"int",
"lastMark",
"=",
"0",
";",
"int",
"lastSplit",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"input",
".",
"charAt",
"(",
"i",
")",
"==",
"delimiter",
")",
"{",
"result",
"[",
"lastSplit",
"]",
"=",
"input",
".",
"substring",
"(",
"lastMark",
",",
"i",
")",
";",
"lastSplit",
"++",
";",
"lastMark",
"=",
"i",
"+",
"1",
";",
"// 1 == delimiter length",
"}",
"}",
"result",
"[",
"lastSplit",
"]",
"=",
"input",
".",
"substring",
"(",
"lastMark",
",",
"len",
")",
";",
"return",
"result",
";",
"}"
] | Splits a string into an array using a provided delimiter. The split chunks are also trimmed.
@param input string to split.
@param delimiter delimiter
@return a string into an array using a provided delimiter | [
"Splits",
"a",
"string",
"into",
"an",
"array",
"using",
"a",
"provided",
"delimiter",
".",
"The",
"split",
"chunks",
"are",
"also",
"trimmed",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/util/StringUtil.java#L18-L45 |
141,741 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/util/StringUtil.java | StringUtil.split | public static void split(String input, char delimiter, Consumer<String> callbackPerSubstring) {
if(input == null) throw new NullPointerException("input cannot be null");
final int len = input.length();
int lastMark = 0;
for (int i = 0; i < len; i++) {
if (input.charAt(i) == delimiter) {
callbackPerSubstring.accept(input.substring(lastMark, i));
lastMark = i + 1;// 1 == delimiter length
}
}
callbackPerSubstring.accept(input.substring(lastMark, len));
} | java | public static void split(String input, char delimiter, Consumer<String> callbackPerSubstring) {
if(input == null) throw new NullPointerException("input cannot be null");
final int len = input.length();
int lastMark = 0;
for (int i = 0; i < len; i++) {
if (input.charAt(i) == delimiter) {
callbackPerSubstring.accept(input.substring(lastMark, i));
lastMark = i + 1;// 1 == delimiter length
}
}
callbackPerSubstring.accept(input.substring(lastMark, len));
} | [
"public",
"static",
"void",
"split",
"(",
"String",
"input",
",",
"char",
"delimiter",
",",
"Consumer",
"<",
"String",
">",
"callbackPerSubstring",
")",
"{",
"if",
"(",
"input",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"input cannot be null\"",
")",
";",
"final",
"int",
"len",
"=",
"input",
".",
"length",
"(",
")",
";",
"int",
"lastMark",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"input",
".",
"charAt",
"(",
"i",
")",
"==",
"delimiter",
")",
"{",
"callbackPerSubstring",
".",
"accept",
"(",
"input",
".",
"substring",
"(",
"lastMark",
",",
"i",
")",
")",
";",
"lastMark",
"=",
"i",
"+",
"1",
";",
"// 1 == delimiter length",
"}",
"}",
"callbackPerSubstring",
".",
"accept",
"(",
"input",
".",
"substring",
"(",
"lastMark",
",",
"len",
")",
")",
";",
"}"
] | Splits a string into an array using a provided delimiter.
The callback will be invoked once per each found substring
@param input string to split.
@param delimiter delimiter
@param callbackPerSubstring called for each splitted string | [
"Splits",
"a",
"string",
"into",
"an",
"array",
"using",
"a",
"provided",
"delimiter",
".",
"The",
"callback",
"will",
"be",
"invoked",
"once",
"per",
"each",
"found",
"substring"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/util/StringUtil.java#L55-L68 |
141,742 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/util/StringUtil.java | StringUtil.firstPartOfCamelCase | public static String firstPartOfCamelCase(String camelcased) {
// by starting to count before the isUpperCase-check,
// we do not care if the strings starts with a lower- or uppercase
int end = 0;
while (++end < camelcased.length()) {
if (Character.isUpperCase(camelcased.charAt(end)))
break;
}
return camelcased.substring(0,end);
} | java | public static String firstPartOfCamelCase(String camelcased) {
// by starting to count before the isUpperCase-check,
// we do not care if the strings starts with a lower- or uppercase
int end = 0;
while (++end < camelcased.length()) {
if (Character.isUpperCase(camelcased.charAt(end)))
break;
}
return camelcased.substring(0,end);
} | [
"public",
"static",
"String",
"firstPartOfCamelCase",
"(",
"String",
"camelcased",
")",
"{",
"// by starting to count before the isUpperCase-check,",
"// we do not care if the strings starts with a lower- or uppercase",
"int",
"end",
"=",
"0",
";",
"while",
"(",
"++",
"end",
"<",
"camelcased",
".",
"length",
"(",
")",
")",
"{",
"if",
"(",
"Character",
".",
"isUpperCase",
"(",
"camelcased",
".",
"charAt",
"(",
"end",
")",
")",
")",
"break",
";",
"}",
"return",
"camelcased",
".",
"substring",
"(",
"0",
",",
"end",
")",
";",
"}"
] | Extracts the first part of a camel_cased string.
@param camelcased A camel_cased string that may or may not start with an upper cased letter.
@return "get" from "getVideo" or "post" from "postVideoUpload" or "Get" from "GetVideo" | [
"Extracts",
"the",
"first",
"part",
"of",
"a",
"camel_cased",
"string",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/util/StringUtil.java#L144-L153 |
141,743 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/util/StringUtil.java | StringUtil.decapitalize | public static String decapitalize(String word) {
return Character.toLowerCase(word.charAt(0)) + word.substring(1);
} | java | public static String decapitalize(String word) {
return Character.toLowerCase(word.charAt(0)) + word.substring(1);
} | [
"public",
"static",
"String",
"decapitalize",
"(",
"String",
"word",
")",
"{",
"return",
"Character",
".",
"toLowerCase",
"(",
"word",
".",
"charAt",
"(",
"0",
")",
")",
"+",
"word",
".",
"substring",
"(",
"1",
")",
";",
"}"
] | Decapitalizes a word - only the first character is converted to lower case.
@param word word/phrase to decapitalize.
@return same as input argument, but the first character is in lower case. | [
"Decapitalizes",
"a",
"word",
"-",
"only",
"the",
"first",
"character",
"is",
"converted",
"to",
"lower",
"case",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/util/StringUtil.java#L172-L174 |
141,744 | buschmais/jqa-core-framework | scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java | ScannerImpl.satisfies | private <I, D extends Descriptor> boolean satisfies(ScannerPlugin<I, D> selectedPlugin, D descriptor) {
return !(selectedPlugin.getClass().isAnnotationPresent(Requires.class) && descriptor == null);
} | java | private <I, D extends Descriptor> boolean satisfies(ScannerPlugin<I, D> selectedPlugin, D descriptor) {
return !(selectedPlugin.getClass().isAnnotationPresent(Requires.class) && descriptor == null);
} | [
"private",
"<",
"I",
",",
"D",
"extends",
"Descriptor",
">",
"boolean",
"satisfies",
"(",
"ScannerPlugin",
"<",
"I",
",",
"D",
">",
"selectedPlugin",
",",
"D",
"descriptor",
")",
"{",
"return",
"!",
"(",
"selectedPlugin",
".",
"getClass",
"(",
")",
".",
"isAnnotationPresent",
"(",
"Requires",
".",
"class",
")",
"&&",
"descriptor",
"==",
"null",
")",
";",
"}"
] | Verifies if the selected plugin requires a descriptor.
@param selectedPlugin
The selected plugin.
@param descriptor
The descriptor.
@param <I>
The item type of the plugin.
@param <D>
The descriptor type of the plugin.
@return <code>true</code> if the selected plugin can be used. | [
"Verifies",
"if",
"the",
"selected",
"plugin",
"requires",
"a",
"descriptor",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java#L147-L149 |
141,745 | buschmais/jqa-core-framework | scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java | ScannerImpl.accepts | protected <I> boolean accepts(ScannerPlugin<I, ?> selectedPlugin, I item, String path, Scope scope) {
boolean accepted = false;
try {
accepted = selectedPlugin.accepts(item, path, scope);
} catch (IOException e) {
LOGGER.error("Plugin " + selectedPlugin + " failed to check whether it can accept item " + path, e);
}
return accepted;
} | java | protected <I> boolean accepts(ScannerPlugin<I, ?> selectedPlugin, I item, String path, Scope scope) {
boolean accepted = false;
try {
accepted = selectedPlugin.accepts(item, path, scope);
} catch (IOException e) {
LOGGER.error("Plugin " + selectedPlugin + " failed to check whether it can accept item " + path, e);
}
return accepted;
} | [
"protected",
"<",
"I",
">",
"boolean",
"accepts",
"(",
"ScannerPlugin",
"<",
"I",
",",
"?",
">",
"selectedPlugin",
",",
"I",
"item",
",",
"String",
"path",
",",
"Scope",
"scope",
")",
"{",
"boolean",
"accepted",
"=",
"false",
";",
"try",
"{",
"accepted",
"=",
"selectedPlugin",
".",
"accepts",
"(",
"item",
",",
"path",
",",
"scope",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Plugin \"",
"+",
"selectedPlugin",
"+",
"\" failed to check whether it can accept item \"",
"+",
"path",
",",
"e",
")",
";",
"}",
"return",
"accepted",
";",
"}"
] | Checks whether a plugin accepts an item.
@param selectedPlugin
The plugin.
@param item
The item.
@param path
The path.
@param scope
The scope.
@param <I>
The item type.
@return <code>true</code> if the plugin accepts the item for scanning. | [
"Checks",
"whether",
"a",
"plugin",
"accepts",
"an",
"item",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java#L166-L176 |
141,746 | buschmais/jqa-core-framework | scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java | ScannerImpl.pushDesriptor | private <D extends Descriptor> void pushDesriptor(Class<D> type, D descriptor) {
if (descriptor != null) {
scannerContext.push(type, descriptor);
scannerContext.setCurrentDescriptor(descriptor);
}
} | java | private <D extends Descriptor> void pushDesriptor(Class<D> type, D descriptor) {
if (descriptor != null) {
scannerContext.push(type, descriptor);
scannerContext.setCurrentDescriptor(descriptor);
}
} | [
"private",
"<",
"D",
"extends",
"Descriptor",
">",
"void",
"pushDesriptor",
"(",
"Class",
"<",
"D",
">",
"type",
",",
"D",
"descriptor",
")",
"{",
"if",
"(",
"descriptor",
"!=",
"null",
")",
"{",
"scannerContext",
".",
"push",
"(",
"type",
",",
"descriptor",
")",
";",
"scannerContext",
".",
"setCurrentDescriptor",
"(",
"descriptor",
")",
";",
"}",
"}"
] | Push the given descriptor with all it's types to the context.
@param descriptor
The descriptor.
@param <D>
The descriptor type. | [
"Push",
"the",
"given",
"descriptor",
"with",
"all",
"it",
"s",
"types",
"to",
"the",
"context",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java#L186-L191 |
141,747 | buschmais/jqa-core-framework | scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java | ScannerImpl.popDescriptor | private <D extends Descriptor> void popDescriptor(Class<D> type, D descriptor) {
if (descriptor != null) {
scannerContext.setCurrentDescriptor(null);
scannerContext.pop(type);
}
} | java | private <D extends Descriptor> void popDescriptor(Class<D> type, D descriptor) {
if (descriptor != null) {
scannerContext.setCurrentDescriptor(null);
scannerContext.pop(type);
}
} | [
"private",
"<",
"D",
"extends",
"Descriptor",
">",
"void",
"popDescriptor",
"(",
"Class",
"<",
"D",
">",
"type",
",",
"D",
"descriptor",
")",
"{",
"if",
"(",
"descriptor",
"!=",
"null",
")",
"{",
"scannerContext",
".",
"setCurrentDescriptor",
"(",
"null",
")",
";",
"scannerContext",
".",
"pop",
"(",
"type",
")",
";",
"}",
"}"
] | Pop the given descriptor from the context.
@param descriptor
The descriptor.
@param <D>
The descriptor type. | [
"Pop",
"the",
"given",
"descriptor",
"from",
"the",
"context",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java#L201-L206 |
141,748 | buschmais/jqa-core-framework | scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java | ScannerImpl.getScannerPluginsForType | private List<ScannerPlugin<?, ?>> getScannerPluginsForType(final Class<?> type) {
List<ScannerPlugin<?, ?>> plugins = scannerPluginsPerType.get(type);
if (plugins == null) {
// The list of all scanner plugins which accept the given type
final List<ScannerPlugin<?, ?>> candidates = new LinkedList<>();
// The map of scanner plugins which produce a descriptor type
final Map<Class<? extends Descriptor>, Set<ScannerPlugin<?, ?>>> pluginsByDescriptor = new HashMap<>();
for (ScannerPlugin<?, ?> scannerPlugin : scannerPlugins.values()) {
Class<?> scannerPluginType = scannerPlugin.getType();
if (scannerPluginType.isAssignableFrom(type)) {
Class<? extends Descriptor> descriptorType = scannerPlugin.getDescriptorType();
Set<ScannerPlugin<?, ?>> pluginsForDescriptorType = pluginsByDescriptor.get(descriptorType);
if (pluginsForDescriptorType == null) {
pluginsForDescriptorType = new HashSet<>();
pluginsByDescriptor.put(descriptorType, pluginsForDescriptorType);
}
pluginsForDescriptorType.add(scannerPlugin);
candidates.add(scannerPlugin);
}
}
// Order plugins by the values of their optional @Requires
// annotation
plugins = DependencyResolver.newInstance(candidates, new DependencyProvider<ScannerPlugin<?, ?>>() {
@Override
public Set<ScannerPlugin<?, ?>> getDependencies(ScannerPlugin<?, ?> dependent) {
Set<ScannerPlugin<?, ?>> dependencies = new HashSet<>();
Requires annotation = dependent.getClass().getAnnotation(Requires.class);
if (annotation != null) {
for (Class<? extends Descriptor> descriptorType : annotation.value()) {
Set<ScannerPlugin<?, ?>> pluginsByDescriptorType = pluginsByDescriptor.get(descriptorType);
if (pluginsByDescriptorType != null) {
for (ScannerPlugin<?, ?> scannerPlugin : pluginsByDescriptorType) {
if (!scannerPlugin.equals(dependent)) {
dependencies.add(scannerPlugin);
}
}
}
}
}
return dependencies;
}
}).resolve();
scannerPluginsPerType.put(type, plugins);
}
return plugins;
} | java | private List<ScannerPlugin<?, ?>> getScannerPluginsForType(final Class<?> type) {
List<ScannerPlugin<?, ?>> plugins = scannerPluginsPerType.get(type);
if (plugins == null) {
// The list of all scanner plugins which accept the given type
final List<ScannerPlugin<?, ?>> candidates = new LinkedList<>();
// The map of scanner plugins which produce a descriptor type
final Map<Class<? extends Descriptor>, Set<ScannerPlugin<?, ?>>> pluginsByDescriptor = new HashMap<>();
for (ScannerPlugin<?, ?> scannerPlugin : scannerPlugins.values()) {
Class<?> scannerPluginType = scannerPlugin.getType();
if (scannerPluginType.isAssignableFrom(type)) {
Class<? extends Descriptor> descriptorType = scannerPlugin.getDescriptorType();
Set<ScannerPlugin<?, ?>> pluginsForDescriptorType = pluginsByDescriptor.get(descriptorType);
if (pluginsForDescriptorType == null) {
pluginsForDescriptorType = new HashSet<>();
pluginsByDescriptor.put(descriptorType, pluginsForDescriptorType);
}
pluginsForDescriptorType.add(scannerPlugin);
candidates.add(scannerPlugin);
}
}
// Order plugins by the values of their optional @Requires
// annotation
plugins = DependencyResolver.newInstance(candidates, new DependencyProvider<ScannerPlugin<?, ?>>() {
@Override
public Set<ScannerPlugin<?, ?>> getDependencies(ScannerPlugin<?, ?> dependent) {
Set<ScannerPlugin<?, ?>> dependencies = new HashSet<>();
Requires annotation = dependent.getClass().getAnnotation(Requires.class);
if (annotation != null) {
for (Class<? extends Descriptor> descriptorType : annotation.value()) {
Set<ScannerPlugin<?, ?>> pluginsByDescriptorType = pluginsByDescriptor.get(descriptorType);
if (pluginsByDescriptorType != null) {
for (ScannerPlugin<?, ?> scannerPlugin : pluginsByDescriptorType) {
if (!scannerPlugin.equals(dependent)) {
dependencies.add(scannerPlugin);
}
}
}
}
}
return dependencies;
}
}).resolve();
scannerPluginsPerType.put(type, plugins);
}
return plugins;
} | [
"private",
"List",
"<",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
">",
"getScannerPluginsForType",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"List",
"<",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
">",
"plugins",
"=",
"scannerPluginsPerType",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"plugins",
"==",
"null",
")",
"{",
"// The list of all scanner plugins which accept the given type",
"final",
"List",
"<",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
">",
"candidates",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"// The map of scanner plugins which produce a descriptor type",
"final",
"Map",
"<",
"Class",
"<",
"?",
"extends",
"Descriptor",
">",
",",
"Set",
"<",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
">",
">",
"pluginsByDescriptor",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
"scannerPlugin",
":",
"scannerPlugins",
".",
"values",
"(",
")",
")",
"{",
"Class",
"<",
"?",
">",
"scannerPluginType",
"=",
"scannerPlugin",
".",
"getType",
"(",
")",
";",
"if",
"(",
"scannerPluginType",
".",
"isAssignableFrom",
"(",
"type",
")",
")",
"{",
"Class",
"<",
"?",
"extends",
"Descriptor",
">",
"descriptorType",
"=",
"scannerPlugin",
".",
"getDescriptorType",
"(",
")",
";",
"Set",
"<",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
">",
"pluginsForDescriptorType",
"=",
"pluginsByDescriptor",
".",
"get",
"(",
"descriptorType",
")",
";",
"if",
"(",
"pluginsForDescriptorType",
"==",
"null",
")",
"{",
"pluginsForDescriptorType",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"pluginsByDescriptor",
".",
"put",
"(",
"descriptorType",
",",
"pluginsForDescriptorType",
")",
";",
"}",
"pluginsForDescriptorType",
".",
"add",
"(",
"scannerPlugin",
")",
";",
"candidates",
".",
"add",
"(",
"scannerPlugin",
")",
";",
"}",
"}",
"// Order plugins by the values of their optional @Requires",
"// annotation",
"plugins",
"=",
"DependencyResolver",
".",
"newInstance",
"(",
"candidates",
",",
"new",
"DependencyProvider",
"<",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Set",
"<",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
">",
"getDependencies",
"(",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
"dependent",
")",
"{",
"Set",
"<",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
">",
"dependencies",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"Requires",
"annotation",
"=",
"dependent",
".",
"getClass",
"(",
")",
".",
"getAnnotation",
"(",
"Requires",
".",
"class",
")",
";",
"if",
"(",
"annotation",
"!=",
"null",
")",
"{",
"for",
"(",
"Class",
"<",
"?",
"extends",
"Descriptor",
">",
"descriptorType",
":",
"annotation",
".",
"value",
"(",
")",
")",
"{",
"Set",
"<",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
">",
"pluginsByDescriptorType",
"=",
"pluginsByDescriptor",
".",
"get",
"(",
"descriptorType",
")",
";",
"if",
"(",
"pluginsByDescriptorType",
"!=",
"null",
")",
"{",
"for",
"(",
"ScannerPlugin",
"<",
"?",
",",
"?",
">",
"scannerPlugin",
":",
"pluginsByDescriptorType",
")",
"{",
"if",
"(",
"!",
"scannerPlugin",
".",
"equals",
"(",
"dependent",
")",
")",
"{",
"dependencies",
".",
"add",
"(",
"scannerPlugin",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"dependencies",
";",
"}",
"}",
")",
".",
"resolve",
"(",
")",
";",
"scannerPluginsPerType",
".",
"put",
"(",
"type",
",",
"plugins",
")",
";",
"}",
"return",
"plugins",
";",
"}"
] | Determine the list of scanner plugins that handle the given type.
@param type
The type.
@return The list of plugins. | [
"Determine",
"the",
"list",
"of",
"scanner",
"plugins",
"that",
"handle",
"the",
"given",
"type",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerImpl.java#L234-L279 |
141,749 | jinahya/database-metadata-bind | src/main/java/com/github/jinahya/database/metadata/bind/MetadataContext.java | MetadataContext.bind | private <T> List<? super T> bind(final ResultSet results, final Class<T> klass, final List<? super T> instances)
throws SQLException {
if (results == null) {
throw new NullPointerException("results is null");
}
if (klass == null) {
throw new NullPointerException("klass is null");
}
if (instances == null) {
throw new NullPointerException("instances is null");
}
while (results.next()) {
final T instance;
try {
instance = klass.newInstance();
} catch (final ReflectiveOperationException roe) {
logger.log(SEVERE, format("failed to create new instance of %s", klass), roe);
continue;
}
instances.add(bind(results, klass, instance));
}
return instances;
} | java | private <T> List<? super T> bind(final ResultSet results, final Class<T> klass, final List<? super T> instances)
throws SQLException {
if (results == null) {
throw new NullPointerException("results is null");
}
if (klass == null) {
throw new NullPointerException("klass is null");
}
if (instances == null) {
throw new NullPointerException("instances is null");
}
while (results.next()) {
final T instance;
try {
instance = klass.newInstance();
} catch (final ReflectiveOperationException roe) {
logger.log(SEVERE, format("failed to create new instance of %s", klass), roe);
continue;
}
instances.add(bind(results, klass, instance));
}
return instances;
} | [
"private",
"<",
"T",
">",
"List",
"<",
"?",
"super",
"T",
">",
"bind",
"(",
"final",
"ResultSet",
"results",
",",
"final",
"Class",
"<",
"T",
">",
"klass",
",",
"final",
"List",
"<",
"?",
"super",
"T",
">",
"instances",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"results",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"results is null\"",
")",
";",
"}",
"if",
"(",
"klass",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"klass is null\"",
")",
";",
"}",
"if",
"(",
"instances",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"instances is null\"",
")",
";",
"}",
"while",
"(",
"results",
".",
"next",
"(",
")",
")",
"{",
"final",
"T",
"instance",
";",
"try",
"{",
"instance",
"=",
"klass",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"ReflectiveOperationException",
"roe",
")",
"{",
"logger",
".",
"log",
"(",
"SEVERE",
",",
"format",
"(",
"\"failed to create new instance of %s\"",
",",
"klass",
")",
",",
"roe",
")",
";",
"continue",
";",
"}",
"instances",
".",
"add",
"(",
"bind",
"(",
"results",
",",
"klass",
",",
"instance",
")",
")",
";",
"}",
"return",
"instances",
";",
"}"
] | Binds all records as given type and add them to specified list.
@param <T> binding type parameter
@param results the records to bind
@param klass the type of instances
@param instances a list to which instances are added
@return given list
@throws SQLException if a database error occurs. | [
"Binds",
"all",
"records",
"as",
"given",
"type",
"and",
"add",
"them",
"to",
"specified",
"list",
"."
] | 94fc9f9c85149c30dcfd10434f475d8332eedf76 | https://github.com/jinahya/database-metadata-bind/blob/94fc9f9c85149c30dcfd10434f475d8332eedf76/src/main/java/com/github/jinahya/database/metadata/bind/MetadataContext.java#L293-L315 |
141,750 | jinahya/database-metadata-bind | src/main/java/com/github/jinahya/database/metadata/bind/MetadataContext.java | MetadataContext.addSuppressionPaths | public MetadataContext addSuppressionPaths(@NonNull final String suppressionPath,
@NonNull final String... otherPaths) {
addSuppressionPath(suppressionPath);
for (final String otherPath : otherPaths) {
addSuppressionPath(otherPath);
}
return this;
} | java | public MetadataContext addSuppressionPaths(@NonNull final String suppressionPath,
@NonNull final String... otherPaths) {
addSuppressionPath(suppressionPath);
for (final String otherPath : otherPaths) {
addSuppressionPath(otherPath);
}
return this;
} | [
"public",
"MetadataContext",
"addSuppressionPaths",
"(",
"@",
"NonNull",
"final",
"String",
"suppressionPath",
",",
"@",
"NonNull",
"final",
"String",
"...",
"otherPaths",
")",
"{",
"addSuppressionPath",
"(",
"suppressionPath",
")",
";",
"for",
"(",
"final",
"String",
"otherPath",
":",
"otherPaths",
")",
"{",
"addSuppressionPath",
"(",
"otherPath",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Adds suppression paths and returns this instance.
@param suppressionPath the first suppression suppressionPath
@param otherPaths other suppression paths
@return this instance | [
"Adds",
"suppression",
"paths",
"and",
"returns",
"this",
"instance",
"."
] | 94fc9f9c85149c30dcfd10434f475d8332eedf76 | https://github.com/jinahya/database-metadata-bind/blob/94fc9f9c85149c30dcfd10434f475d8332eedf76/src/main/java/com/github/jinahya/database/metadata/bind/MetadataContext.java#L863-L870 |
141,751 | MTDdk/jawn | jawn-core-new/src/main/java/net/javapla/jawn/core/Jawn.java | Jawn.stop | public void stop() {
CompletableFuture.runAsync(() -> {
try {
bootstrap.getInjector().getInstance(Server.class).stop();
} catch (Exception ignore) {
// Ignore NPE. At this point the server REALLY should be possible to find
}
bootstrap.shutdown();
});
} | java | public void stop() {
CompletableFuture.runAsync(() -> {
try {
bootstrap.getInjector().getInstance(Server.class).stop();
} catch (Exception ignore) {
// Ignore NPE. At this point the server REALLY should be possible to find
}
bootstrap.shutdown();
});
} | [
"public",
"void",
"stop",
"(",
")",
"{",
"CompletableFuture",
".",
"runAsync",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"bootstrap",
".",
"getInjector",
"(",
")",
".",
"getInstance",
"(",
"Server",
".",
"class",
")",
".",
"stop",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ignore",
")",
"{",
"// Ignore NPE. At this point the server REALLY should be possible to find",
"}",
"bootstrap",
".",
"shutdown",
"(",
")",
";",
"}",
")",
";",
"}"
] | Asynchronously shutdowns the server | [
"Asynchronously",
"shutdowns",
"the",
"server"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core-new/src/main/java/net/javapla/jawn/core/Jawn.java#L177-L186 |
141,752 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/Jawn.java | Jawn.onStartup | public Jawn onStartup(Runnable callback) {
Objects.requireNonNull(callback);
bootstrapper.onStartup(callback);
return this;
} | java | public Jawn onStartup(Runnable callback) {
Objects.requireNonNull(callback);
bootstrapper.onStartup(callback);
return this;
} | [
"public",
"Jawn",
"onStartup",
"(",
"Runnable",
"callback",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"callback",
")",
";",
"bootstrapper",
".",
"onStartup",
"(",
"callback",
")",
";",
"return",
"this",
";",
"}"
] | Run the tasks as a part of the start up process.
With the current implementation, the Runnables will be executed
just before starting the server.
@param callback
@return this, for chaining | [
"Run",
"the",
"tasks",
"as",
"a",
"part",
"of",
"the",
"start",
"up",
"process",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/Jawn.java#L76-L80 |
141,753 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/Jawn.java | Jawn.onShutdown | public Jawn onShutdown(Runnable callback) {
Objects.requireNonNull(callback);
bootstrapper.onShutdown(callback);
return this;
} | java | public Jawn onShutdown(Runnable callback) {
Objects.requireNonNull(callback);
bootstrapper.onShutdown(callback);
return this;
} | [
"public",
"Jawn",
"onShutdown",
"(",
"Runnable",
"callback",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"callback",
")",
";",
"bootstrapper",
".",
"onShutdown",
"(",
"callback",
")",
";",
"return",
"this",
";",
"}"
] | Run the tasks as a part of the shut down process.
With the current implementation, the Runnables will be executed
right after stopping the server, but before closing any
connection pool to a {@link DatabaseConnection}.
@param callback
@return this, for chaining | [
"Run",
"the",
"tasks",
"as",
"a",
"part",
"of",
"the",
"shut",
"down",
"process",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/Jawn.java#L92-L96 |
141,754 | MTDdk/jawn | jawn-server/src/main/java/net/javapla/jawn/server/RequestConvertImpl.java | RequestConvertImpl.asText | @Override
public String asText() throws ParsableException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()))) {
return reader.lines().collect(Collectors.joining());
} catch (IOException e) {
throw new ParsableException("Reading the input failed");
}
} | java | @Override
public String asText() throws ParsableException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()))) {
return reader.lines().collect(Collectors.joining());
} catch (IOException e) {
throw new ParsableException("Reading the input failed");
}
} | [
"@",
"Override",
"public",
"String",
"asText",
"(",
")",
"throws",
"ParsableException",
"{",
"try",
"(",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"request",
".",
"getInputStream",
"(",
")",
")",
")",
")",
"{",
"return",
"reader",
".",
"lines",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ParsableException",
"(",
"\"Reading the input failed\"",
")",
";",
"}",
"}"
] | Conveniently converts any input in the request into a string
@return data sent by client as string.
@throws ParsableException If the request could not be correctly read as a stream | [
"Conveniently",
"converts",
"any",
"input",
"in",
"the",
"request",
"into",
"a",
"string"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-server/src/main/java/net/javapla/jawn/server/RequestConvertImpl.java#L75-L82 |
141,755 | MTDdk/jawn | jawn-server/src/main/java/net/javapla/jawn/server/RequestConvertImpl.java | RequestConvertImpl.asBytes | @Override
public byte[] asBytes() throws IOException {
try (ServletInputStream stream = request.getInputStream()) {
ByteArrayOutputStream array = new ByteArrayOutputStream(stream.available());
return array.toByteArray();
}
} | java | @Override
public byte[] asBytes() throws IOException {
try (ServletInputStream stream = request.getInputStream()) {
ByteArrayOutputStream array = new ByteArrayOutputStream(stream.available());
return array.toByteArray();
}
} | [
"@",
"Override",
"public",
"byte",
"[",
"]",
"asBytes",
"(",
")",
"throws",
"IOException",
"{",
"try",
"(",
"ServletInputStream",
"stream",
"=",
"request",
".",
"getInputStream",
"(",
")",
")",
"{",
"ByteArrayOutputStream",
"array",
"=",
"new",
"ByteArrayOutputStream",
"(",
"stream",
".",
"available",
"(",
")",
")",
";",
"return",
"array",
".",
"toByteArray",
"(",
")",
";",
"}",
"}"
] | Reads entire request data as byte array. Do not use for large data sets to avoid
memory issues.
@return data sent by client as string.
@throws IOException | [
"Reads",
"entire",
"request",
"data",
"as",
"byte",
"array",
".",
"Do",
"not",
"use",
"for",
"large",
"data",
"sets",
"to",
"avoid",
"memory",
"issues",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-server/src/main/java/net/javapla/jawn/server/RequestConvertImpl.java#L101-L107 |
141,756 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/api/executor/RuleSetExecutor.java | RuleSetExecutor.executeGroup | private void executeGroup(RuleSet ruleSet, Group group, Severity parentSeverity) throws RuleException {
if (!executedGroups.contains(group)) {
ruleVisitor.beforeGroup(group, getEffectiveSeverity(group, parentSeverity, parentSeverity));
for (Map.Entry<String, Severity> conceptEntry : group.getConcepts().entrySet()) {
applyConcepts(ruleSet, conceptEntry.getKey(), parentSeverity, conceptEntry.getValue());
}
for (Map.Entry<String, Severity> groupEntry : group.getGroups().entrySet()) {
executeGroups(ruleSet, groupEntry.getKey(), parentSeverity, groupEntry.getValue());
}
Map<String, Severity> constraints = group.getConstraints();
for (Map.Entry<String, Severity> constraintEntry : constraints.entrySet()) {
validateConstraints(ruleSet, constraintEntry.getKey(), parentSeverity, constraintEntry.getValue());
}
ruleVisitor.afterGroup(group);
executedGroups.add(group);
}
} | java | private void executeGroup(RuleSet ruleSet, Group group, Severity parentSeverity) throws RuleException {
if (!executedGroups.contains(group)) {
ruleVisitor.beforeGroup(group, getEffectiveSeverity(group, parentSeverity, parentSeverity));
for (Map.Entry<String, Severity> conceptEntry : group.getConcepts().entrySet()) {
applyConcepts(ruleSet, conceptEntry.getKey(), parentSeverity, conceptEntry.getValue());
}
for (Map.Entry<String, Severity> groupEntry : group.getGroups().entrySet()) {
executeGroups(ruleSet, groupEntry.getKey(), parentSeverity, groupEntry.getValue());
}
Map<String, Severity> constraints = group.getConstraints();
for (Map.Entry<String, Severity> constraintEntry : constraints.entrySet()) {
validateConstraints(ruleSet, constraintEntry.getKey(), parentSeverity, constraintEntry.getValue());
}
ruleVisitor.afterGroup(group);
executedGroups.add(group);
}
} | [
"private",
"void",
"executeGroup",
"(",
"RuleSet",
"ruleSet",
",",
"Group",
"group",
",",
"Severity",
"parentSeverity",
")",
"throws",
"RuleException",
"{",
"if",
"(",
"!",
"executedGroups",
".",
"contains",
"(",
"group",
")",
")",
"{",
"ruleVisitor",
".",
"beforeGroup",
"(",
"group",
",",
"getEffectiveSeverity",
"(",
"group",
",",
"parentSeverity",
",",
"parentSeverity",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Severity",
">",
"conceptEntry",
":",
"group",
".",
"getConcepts",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"applyConcepts",
"(",
"ruleSet",
",",
"conceptEntry",
".",
"getKey",
"(",
")",
",",
"parentSeverity",
",",
"conceptEntry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Severity",
">",
"groupEntry",
":",
"group",
".",
"getGroups",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"executeGroups",
"(",
"ruleSet",
",",
"groupEntry",
".",
"getKey",
"(",
")",
",",
"parentSeverity",
",",
"groupEntry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"Map",
"<",
"String",
",",
"Severity",
">",
"constraints",
"=",
"group",
".",
"getConstraints",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Severity",
">",
"constraintEntry",
":",
"constraints",
".",
"entrySet",
"(",
")",
")",
"{",
"validateConstraints",
"(",
"ruleSet",
",",
"constraintEntry",
".",
"getKey",
"(",
")",
",",
"parentSeverity",
",",
"constraintEntry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"ruleVisitor",
".",
"afterGroup",
"(",
"group",
")",
";",
"executedGroups",
".",
"add",
"(",
"group",
")",
";",
"}",
"}"
] | Executes the given group.
@param ruleSet
The rule set.
@param group
The group.
@param parentSeverity
The severity. | [
"Executes",
"the",
"given",
"group",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/api/executor/RuleSetExecutor.java#L70-L86 |
141,757 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/api/executor/RuleSetExecutor.java | RuleSetExecutor.getEffectiveSeverity | private Severity getEffectiveSeverity(SeverityRule rule, Severity parentSeverity, Severity requestedSeverity) {
Severity effectiveSeverity = requestedSeverity != null ? requestedSeverity : parentSeverity;
return effectiveSeverity != null ? effectiveSeverity : rule.getSeverity();
} | java | private Severity getEffectiveSeverity(SeverityRule rule, Severity parentSeverity, Severity requestedSeverity) {
Severity effectiveSeverity = requestedSeverity != null ? requestedSeverity : parentSeverity;
return effectiveSeverity != null ? effectiveSeverity : rule.getSeverity();
} | [
"private",
"Severity",
"getEffectiveSeverity",
"(",
"SeverityRule",
"rule",
",",
"Severity",
"parentSeverity",
",",
"Severity",
"requestedSeverity",
")",
"{",
"Severity",
"effectiveSeverity",
"=",
"requestedSeverity",
"!=",
"null",
"?",
"requestedSeverity",
":",
"parentSeverity",
";",
"return",
"effectiveSeverity",
"!=",
"null",
"?",
"effectiveSeverity",
":",
"rule",
".",
"getSeverity",
"(",
")",
";",
"}"
] | Determines the effective severity for a rule to be executed.
@param rule
The rule.
@param parentSeverity
The severity inherited from the parent group.
@param requestedSeverity
The severity as specified on the rule in the parent group.
@return The effective severity. | [
"Determines",
"the",
"effective",
"severity",
"for",
"a",
"rule",
"to",
"be",
"executed",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/api/executor/RuleSetExecutor.java#L132-L135 |
141,758 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/api/executor/RuleSetExecutor.java | RuleSetExecutor.validateConstraint | private void validateConstraint(RuleSet ruleSet, Constraint constraint, Severity severity) throws RuleException {
if (!executedConstraints.contains(constraint)) {
if (applyRequiredConcepts(ruleSet, constraint)) {
ruleVisitor.visitConstraint(constraint, severity);
} else {
ruleVisitor.skipConstraint(constraint, severity);
}
executedConstraints.add(constraint);
}
} | java | private void validateConstraint(RuleSet ruleSet, Constraint constraint, Severity severity) throws RuleException {
if (!executedConstraints.contains(constraint)) {
if (applyRequiredConcepts(ruleSet, constraint)) {
ruleVisitor.visitConstraint(constraint, severity);
} else {
ruleVisitor.skipConstraint(constraint, severity);
}
executedConstraints.add(constraint);
}
} | [
"private",
"void",
"validateConstraint",
"(",
"RuleSet",
"ruleSet",
",",
"Constraint",
"constraint",
",",
"Severity",
"severity",
")",
"throws",
"RuleException",
"{",
"if",
"(",
"!",
"executedConstraints",
".",
"contains",
"(",
"constraint",
")",
")",
"{",
"if",
"(",
"applyRequiredConcepts",
"(",
"ruleSet",
",",
"constraint",
")",
")",
"{",
"ruleVisitor",
".",
"visitConstraint",
"(",
"constraint",
",",
"severity",
")",
";",
"}",
"else",
"{",
"ruleVisitor",
".",
"skipConstraint",
"(",
"constraint",
",",
"severity",
")",
";",
"}",
"executedConstraints",
".",
"add",
"(",
"constraint",
")",
";",
"}",
"}"
] | Validates the given constraint.
@param constraint
The constraint.
@throws RuleException
If the constraint cannot be validated. | [
"Validates",
"the",
"given",
"constraint",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/api/executor/RuleSetExecutor.java#L145-L154 |
141,759 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/api/executor/RuleSetExecutor.java | RuleSetExecutor.applyConcept | private boolean applyConcept(RuleSet ruleSet, Concept concept, Severity severity) throws RuleException {
Boolean result = executedConcepts.get(concept);
if (result == null) {
if (applyRequiredConcepts(ruleSet, concept)) {
result = ruleVisitor.visitConcept(concept, severity);
} else {
ruleVisitor.skipConcept(concept, severity);
result = false;
}
executedConcepts.put(concept, result);
}
return result;
} | java | private boolean applyConcept(RuleSet ruleSet, Concept concept, Severity severity) throws RuleException {
Boolean result = executedConcepts.get(concept);
if (result == null) {
if (applyRequiredConcepts(ruleSet, concept)) {
result = ruleVisitor.visitConcept(concept, severity);
} else {
ruleVisitor.skipConcept(concept, severity);
result = false;
}
executedConcepts.put(concept, result);
}
return result;
} | [
"private",
"boolean",
"applyConcept",
"(",
"RuleSet",
"ruleSet",
",",
"Concept",
"concept",
",",
"Severity",
"severity",
")",
"throws",
"RuleException",
"{",
"Boolean",
"result",
"=",
"executedConcepts",
".",
"get",
"(",
"concept",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"if",
"(",
"applyRequiredConcepts",
"(",
"ruleSet",
",",
"concept",
")",
")",
"{",
"result",
"=",
"ruleVisitor",
".",
"visitConcept",
"(",
"concept",
",",
"severity",
")",
";",
"}",
"else",
"{",
"ruleVisitor",
".",
"skipConcept",
"(",
"concept",
",",
"severity",
")",
";",
"result",
"=",
"false",
";",
"}",
"executedConcepts",
".",
"put",
"(",
"concept",
",",
"result",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Applies the given concept.
@param concept
The concept.
@throws RuleException
If the concept cannot be applied. | [
"Applies",
"the",
"given",
"concept",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/api/executor/RuleSetExecutor.java#L180-L192 |
141,760 | buschmais/jqa-core-framework | analysis/src/main/java/com/buschmais/jqassistant/core/analysis/impl/AbstractCypherRuleInterpreterPlugin.java | AbstractCypherRuleInterpreterPlugin.isSuppressedRow | private boolean isSuppressedRow(String ruleId, Map<String, Object> row, String primaryColumn) {
Object primaryValue = row.get(primaryColumn);
if (primaryValue != null && Suppress.class.isAssignableFrom(primaryValue.getClass())) {
Suppress suppress = (Suppress) primaryValue;
for (String suppressId : suppress.getSuppressIds()) {
if (ruleId.equals(suppressId)) {
return true;
}
}
}
return false;
} | java | private boolean isSuppressedRow(String ruleId, Map<String, Object> row, String primaryColumn) {
Object primaryValue = row.get(primaryColumn);
if (primaryValue != null && Suppress.class.isAssignableFrom(primaryValue.getClass())) {
Suppress suppress = (Suppress) primaryValue;
for (String suppressId : suppress.getSuppressIds()) {
if (ruleId.equals(suppressId)) {
return true;
}
}
}
return false;
} | [
"private",
"boolean",
"isSuppressedRow",
"(",
"String",
"ruleId",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"row",
",",
"String",
"primaryColumn",
")",
"{",
"Object",
"primaryValue",
"=",
"row",
".",
"get",
"(",
"primaryColumn",
")",
";",
"if",
"(",
"primaryValue",
"!=",
"null",
"&&",
"Suppress",
".",
"class",
".",
"isAssignableFrom",
"(",
"primaryValue",
".",
"getClass",
"(",
")",
")",
")",
"{",
"Suppress",
"suppress",
"=",
"(",
"Suppress",
")",
"primaryValue",
";",
"for",
"(",
"String",
"suppressId",
":",
"suppress",
".",
"getSuppressIds",
"(",
")",
")",
"{",
"if",
"(",
"ruleId",
".",
"equals",
"(",
"suppressId",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Verifies if the given row shall be suppressed.
The primary column is checked if it contains a suppression that matches the
current rule id.
@param ruleId
The rule id.
@param row
The row.
@param primaryColumn
The name of the primary column.
@return <code>true</code> if the row shall be suppressed. | [
"Verifies",
"if",
"the",
"given",
"row",
"shall",
"be",
"suppressed",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/analysis/src/main/java/com/buschmais/jqassistant/core/analysis/impl/AbstractCypherRuleInterpreterPlugin.java#L73-L84 |
141,761 | buschmais/jqa-core-framework | analysis/src/main/java/com/buschmais/jqassistant/core/analysis/impl/AbstractCypherRuleInterpreterPlugin.java | AbstractCypherRuleInterpreterPlugin.getStatus | protected <T extends ExecutableRule<?>> Status getStatus(T executableRule, List<String> columnNames, List<Map<String, Object>> rows,
AnalyzerContext context) throws RuleException {
return context.verify(executableRule, columnNames, rows);
} | java | protected <T extends ExecutableRule<?>> Status getStatus(T executableRule, List<String> columnNames, List<Map<String, Object>> rows,
AnalyzerContext context) throws RuleException {
return context.verify(executableRule, columnNames, rows);
} | [
"protected",
"<",
"T",
"extends",
"ExecutableRule",
"<",
"?",
">",
">",
"Status",
"getStatus",
"(",
"T",
"executableRule",
",",
"List",
"<",
"String",
">",
"columnNames",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"rows",
",",
"AnalyzerContext",
"context",
")",
"throws",
"RuleException",
"{",
"return",
"context",
".",
"verify",
"(",
"executableRule",
",",
"columnNames",
",",
"rows",
")",
";",
"}"
] | Evaluate the status of the result, may be overridden by sub-classes.
@param executableRule
The {@link ExecutableRule}.
@param columnNames
The column names.
@param rows
The rows.
@param context
The {@link AnalyzerContext}.
@param <T>
The rule type.
@return The {@link Status}.
@throws RuleException
If evaluation fails. | [
"Evaluate",
"the",
"status",
"of",
"the",
"result",
"may",
"be",
"overridden",
"by",
"sub",
"-",
"classes",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/analysis/src/main/java/com/buschmais/jqassistant/core/analysis/impl/AbstractCypherRuleInterpreterPlugin.java#L103-L106 |
141,762 | buschmais/jqa-core-framework | report/src/main/java/com/buschmais/jqassistant/core/report/api/LanguageHelper.java | LanguageHelper.getAnnotationValue | private static <T> T getAnnotationValue(Annotation annotation, String value, Class<T> expectedType) {
Class<? extends Annotation> annotationType = annotation.annotationType();
Method valueMethod;
try {
valueMethod = annotationType.getDeclaredMethod(value);
} catch (NoSuchMethodException e) {
throw new IllegalStateException("Cannot resolve required method '" + value + "()' for '" + annotationType + "'.");
}
Object elementValue;
try {
elementValue = valueMethod.invoke(annotation);
} catch (ReflectiveOperationException e) {
throw new IllegalStateException("Cannot invoke method value() for " + annotationType);
}
return elementValue != null ? expectedType.cast(elementValue) : null;
} | java | private static <T> T getAnnotationValue(Annotation annotation, String value, Class<T> expectedType) {
Class<? extends Annotation> annotationType = annotation.annotationType();
Method valueMethod;
try {
valueMethod = annotationType.getDeclaredMethod(value);
} catch (NoSuchMethodException e) {
throw new IllegalStateException("Cannot resolve required method '" + value + "()' for '" + annotationType + "'.");
}
Object elementValue;
try {
elementValue = valueMethod.invoke(annotation);
} catch (ReflectiveOperationException e) {
throw new IllegalStateException("Cannot invoke method value() for " + annotationType);
}
return elementValue != null ? expectedType.cast(elementValue) : null;
} | [
"private",
"static",
"<",
"T",
">",
"T",
"getAnnotationValue",
"(",
"Annotation",
"annotation",
",",
"String",
"value",
",",
"Class",
"<",
"T",
">",
"expectedType",
")",
"{",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationType",
"=",
"annotation",
".",
"annotationType",
"(",
")",
";",
"Method",
"valueMethod",
";",
"try",
"{",
"valueMethod",
"=",
"annotationType",
".",
"getDeclaredMethod",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot resolve required method '\"",
"+",
"value",
"+",
"\"()' for '\"",
"+",
"annotationType",
"+",
"\"'.\"",
")",
";",
"}",
"Object",
"elementValue",
";",
"try",
"{",
"elementValue",
"=",
"valueMethod",
".",
"invoke",
"(",
"annotation",
")",
";",
"}",
"catch",
"(",
"ReflectiveOperationException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot invoke method value() for \"",
"+",
"annotationType",
")",
";",
"}",
"return",
"elementValue",
"!=",
"null",
"?",
"expectedType",
".",
"cast",
"(",
"elementValue",
")",
":",
"null",
";",
"}"
] | Return a value from an annotation.
@param annotation
The annotation.
@param value
The value.
@param expectedType
The expected type.
@param <T>
The expected type.
@return The value. | [
"Return",
"a",
"value",
"from",
"an",
"annotation",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/report/src/main/java/com/buschmais/jqassistant/core/report/api/LanguageHelper.java#L56-L71 |
141,763 | buschmais/jqa-core-framework | report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java | ReportHelper.verifyRuleResults | private int verifyRuleResults(Collection<? extends Result<? extends ExecutableRule>> results, Severity warnOnSeverity, Severity failOnSeverity, String type,
String header, boolean logResult) {
int violations = 0;
for (Result<?> result : results) {
if (Result.Status.FAILURE.equals(result.getStatus())) {
ExecutableRule rule = result.getRule();
String severityInfo = rule.getSeverity().getInfo(result.getSeverity());
List<String> resultRows = getResultRows(result, logResult);
// violation severity level check
boolean warn = warnOnSeverity != null && result.getSeverity().getLevel() <= warnOnSeverity.getLevel();
boolean fail = failOnSeverity != null && result.getSeverity().getLevel() <= failOnSeverity.getLevel();
LoggingStrategy loggingStrategy;
if (fail) {
violations++;
loggingStrategy = errorLogger;
} else if (warn) {
loggingStrategy = warnLogger;
} else {
loggingStrategy = debugLogger;
}
log(loggingStrategy, rule, resultRows, severityInfo, type, header);
}
}
return violations;
} | java | private int verifyRuleResults(Collection<? extends Result<? extends ExecutableRule>> results, Severity warnOnSeverity, Severity failOnSeverity, String type,
String header, boolean logResult) {
int violations = 0;
for (Result<?> result : results) {
if (Result.Status.FAILURE.equals(result.getStatus())) {
ExecutableRule rule = result.getRule();
String severityInfo = rule.getSeverity().getInfo(result.getSeverity());
List<String> resultRows = getResultRows(result, logResult);
// violation severity level check
boolean warn = warnOnSeverity != null && result.getSeverity().getLevel() <= warnOnSeverity.getLevel();
boolean fail = failOnSeverity != null && result.getSeverity().getLevel() <= failOnSeverity.getLevel();
LoggingStrategy loggingStrategy;
if (fail) {
violations++;
loggingStrategy = errorLogger;
} else if (warn) {
loggingStrategy = warnLogger;
} else {
loggingStrategy = debugLogger;
}
log(loggingStrategy, rule, resultRows, severityInfo, type, header);
}
}
return violations;
} | [
"private",
"int",
"verifyRuleResults",
"(",
"Collection",
"<",
"?",
"extends",
"Result",
"<",
"?",
"extends",
"ExecutableRule",
">",
">",
"results",
",",
"Severity",
"warnOnSeverity",
",",
"Severity",
"failOnSeverity",
",",
"String",
"type",
",",
"String",
"header",
",",
"boolean",
"logResult",
")",
"{",
"int",
"violations",
"=",
"0",
";",
"for",
"(",
"Result",
"<",
"?",
">",
"result",
":",
"results",
")",
"{",
"if",
"(",
"Result",
".",
"Status",
".",
"FAILURE",
".",
"equals",
"(",
"result",
".",
"getStatus",
"(",
")",
")",
")",
"{",
"ExecutableRule",
"rule",
"=",
"result",
".",
"getRule",
"(",
")",
";",
"String",
"severityInfo",
"=",
"rule",
".",
"getSeverity",
"(",
")",
".",
"getInfo",
"(",
"result",
".",
"getSeverity",
"(",
")",
")",
";",
"List",
"<",
"String",
">",
"resultRows",
"=",
"getResultRows",
"(",
"result",
",",
"logResult",
")",
";",
"// violation severity level check",
"boolean",
"warn",
"=",
"warnOnSeverity",
"!=",
"null",
"&&",
"result",
".",
"getSeverity",
"(",
")",
".",
"getLevel",
"(",
")",
"<=",
"warnOnSeverity",
".",
"getLevel",
"(",
")",
";",
"boolean",
"fail",
"=",
"failOnSeverity",
"!=",
"null",
"&&",
"result",
".",
"getSeverity",
"(",
")",
".",
"getLevel",
"(",
")",
"<=",
"failOnSeverity",
".",
"getLevel",
"(",
")",
";",
"LoggingStrategy",
"loggingStrategy",
";",
"if",
"(",
"fail",
")",
"{",
"violations",
"++",
";",
"loggingStrategy",
"=",
"errorLogger",
";",
"}",
"else",
"if",
"(",
"warn",
")",
"{",
"loggingStrategy",
"=",
"warnLogger",
";",
"}",
"else",
"{",
"loggingStrategy",
"=",
"debugLogger",
";",
"}",
"log",
"(",
"loggingStrategy",
",",
"rule",
",",
"resultRows",
",",
"severityInfo",
",",
"type",
",",
"header",
")",
";",
"}",
"}",
"return",
"violations",
";",
"}"
] | Verifies the given results and logs messages.
@param results
The collection of results to verify.
@param warnOnSeverity
The severity threshold to warn.
@param failOnSeverity
The severity threshold to fail.
@param type
The type of the rules (as string).
@param header
The header to use.
@param logResult
if `true` log the result of the executable rule.
@return The number of detected violations. | [
"Verifies",
"the",
"given",
"results",
"and",
"logs",
"messages",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java#L101-L125 |
141,764 | buschmais/jqa-core-framework | report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java | ReportHelper.getResultRows | private List<String> getResultRows(Result<?> result, boolean logResult) {
List<String> rows = new ArrayList<>();
if (logResult) {
for (Map<String, Object> columns : result.getRows()) {
StringBuilder row = new StringBuilder();
for (Map.Entry<String, Object> entry : columns.entrySet()) {
if (row.length() > 0) {
row.append(", ");
}
row.append(entry.getKey());
row.append('=');
String stringValue = getLabel(entry.getValue());
row.append(stringValue);
}
rows.add(" " + row.toString());
}
}
return rows;
} | java | private List<String> getResultRows(Result<?> result, boolean logResult) {
List<String> rows = new ArrayList<>();
if (logResult) {
for (Map<String, Object> columns : result.getRows()) {
StringBuilder row = new StringBuilder();
for (Map.Entry<String, Object> entry : columns.entrySet()) {
if (row.length() > 0) {
row.append(", ");
}
row.append(entry.getKey());
row.append('=');
String stringValue = getLabel(entry.getValue());
row.append(stringValue);
}
rows.add(" " + row.toString());
}
}
return rows;
} | [
"private",
"List",
"<",
"String",
">",
"getResultRows",
"(",
"Result",
"<",
"?",
">",
"result",
",",
"boolean",
"logResult",
")",
"{",
"List",
"<",
"String",
">",
"rows",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"logResult",
")",
"{",
"for",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"columns",
":",
"result",
".",
"getRows",
"(",
")",
")",
"{",
"StringBuilder",
"row",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"columns",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"row",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"row",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"row",
".",
"append",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"row",
".",
"append",
"(",
"'",
"'",
")",
";",
"String",
"stringValue",
"=",
"getLabel",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"row",
".",
"append",
"(",
"stringValue",
")",
";",
"}",
"rows",
".",
"add",
"(",
"\" \"",
"+",
"row",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"return",
"rows",
";",
"}"
] | Convert the result rows into a string representation.
@param result
The result.
@param logResult
if `false` suppress logging the result.
@return The string representation as list. | [
"Convert",
"the",
"result",
"rows",
"into",
"a",
"string",
"representation",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java#L150-L168 |
141,765 | buschmais/jqa-core-framework | report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java | ReportHelper.logDescription | private void logDescription(LoggingStrategy loggingStrategy, Rule rule) {
String description = rule.getDescription();
StringTokenizer tokenizer = new StringTokenizer(description, "\n");
while (tokenizer.hasMoreTokens()) {
loggingStrategy.log(tokenizer.nextToken().replaceAll("(\\r|\\n|\\t)", ""));
}
} | java | private void logDescription(LoggingStrategy loggingStrategy, Rule rule) {
String description = rule.getDescription();
StringTokenizer tokenizer = new StringTokenizer(description, "\n");
while (tokenizer.hasMoreTokens()) {
loggingStrategy.log(tokenizer.nextToken().replaceAll("(\\r|\\n|\\t)", ""));
}
} | [
"private",
"void",
"logDescription",
"(",
"LoggingStrategy",
"loggingStrategy",
",",
"Rule",
"rule",
")",
"{",
"String",
"description",
"=",
"rule",
".",
"getDescription",
"(",
")",
";",
"StringTokenizer",
"tokenizer",
"=",
"new",
"StringTokenizer",
"(",
"description",
",",
"\"\\n\"",
")",
";",
"while",
"(",
"tokenizer",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"loggingStrategy",
".",
"log",
"(",
"tokenizer",
".",
"nextToken",
"(",
")",
".",
"replaceAll",
"(",
"\"(\\\\r|\\\\n|\\\\t)\"",
",",
"\"\"",
")",
")",
";",
"}",
"}"
] | Log the description of a rule.
@param rule
The rule. | [
"Log",
"the",
"description",
"of",
"a",
"rule",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java#L176-L182 |
141,766 | buschmais/jqa-core-framework | report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java | ReportHelper.escapeRuleId | public static String escapeRuleId(Rule rule) {
return rule != null ? rule.getId().replaceAll("\\:", "_") : null;
} | java | public static String escapeRuleId(Rule rule) {
return rule != null ? rule.getId().replaceAll("\\:", "_") : null;
} | [
"public",
"static",
"String",
"escapeRuleId",
"(",
"Rule",
"rule",
")",
"{",
"return",
"rule",
"!=",
"null",
"?",
"rule",
".",
"getId",
"(",
")",
".",
"replaceAll",
"(",
"\"\\\\:\"",
",",
"\"_\"",
")",
":",
"null",
";",
"}"
] | Escape the id of the given rule in a way such that it can be used as file
name.
@param rule
The rule.
@return The escaped name. | [
"Escape",
"the",
"id",
"of",
"the",
"given",
"rule",
"in",
"a",
"way",
"such",
"that",
"it",
"can",
"be",
"used",
"as",
"file",
"name",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java#L192-L194 |
141,767 | buschmais/jqa-core-framework | report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java | ReportHelper.getLabel | public static String getLabel(Object value) {
if (value != null) {
if (value instanceof CompositeObject) {
CompositeObject descriptor = (CompositeObject) value;
String label = getLanguageLabel(descriptor);
return label != null ? label : descriptor.toString();
} else if (value.getClass().isArray()) {
Object[] objects = (Object[]) value;
return getLabel(Arrays.asList(objects));
} else if (value instanceof Iterable) {
StringBuilder sb = new StringBuilder();
for (Object o : ((Iterable) value)) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(getLabel(o));
}
return "[" + sb.toString() + "]";
} else if (value instanceof Map) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> entry : ((Map<String, Object>) value).entrySet()) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(entry.getKey());
sb.append(":");
sb.append(getLabel(entry.getValue()));
}
return "{" + sb.toString() + "}";
}
return value.toString();
}
return null;
} | java | public static String getLabel(Object value) {
if (value != null) {
if (value instanceof CompositeObject) {
CompositeObject descriptor = (CompositeObject) value;
String label = getLanguageLabel(descriptor);
return label != null ? label : descriptor.toString();
} else if (value.getClass().isArray()) {
Object[] objects = (Object[]) value;
return getLabel(Arrays.asList(objects));
} else if (value instanceof Iterable) {
StringBuilder sb = new StringBuilder();
for (Object o : ((Iterable) value)) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(getLabel(o));
}
return "[" + sb.toString() + "]";
} else if (value instanceof Map) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> entry : ((Map<String, Object>) value).entrySet()) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(entry.getKey());
sb.append(":");
sb.append(getLabel(entry.getValue()));
}
return "{" + sb.toString() + "}";
}
return value.toString();
}
return null;
} | [
"public",
"static",
"String",
"getLabel",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"if",
"(",
"value",
"instanceof",
"CompositeObject",
")",
"{",
"CompositeObject",
"descriptor",
"=",
"(",
"CompositeObject",
")",
"value",
";",
"String",
"label",
"=",
"getLanguageLabel",
"(",
"descriptor",
")",
";",
"return",
"label",
"!=",
"null",
"?",
"label",
":",
"descriptor",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"value",
".",
"getClass",
"(",
")",
".",
"isArray",
"(",
")",
")",
"{",
"Object",
"[",
"]",
"objects",
"=",
"(",
"Object",
"[",
"]",
")",
"value",
";",
"return",
"getLabel",
"(",
"Arrays",
".",
"asList",
"(",
"objects",
")",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Iterable",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Object",
"o",
":",
"(",
"(",
"Iterable",
")",
"value",
")",
")",
"{",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"getLabel",
"(",
"o",
")",
")",
";",
"}",
"return",
"\"[\"",
"+",
"sb",
".",
"toString",
"(",
")",
"+",
"\"]\"",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Map",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"(",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"value",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\":\"",
")",
";",
"sb",
".",
"append",
"(",
"getLabel",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"return",
"\"{\"",
"+",
"sb",
".",
"toString",
"(",
")",
"+",
"\"}\"",
";",
"}",
"return",
"value",
".",
"toString",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Converts a value to its string representation.
@param value
The value.
@return The string representation | [
"Converts",
"a",
"value",
"to",
"its",
"string",
"representation",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/report/src/main/java/com/buschmais/jqassistant/core/report/api/ReportHelper.java#L203-L236 |
141,768 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/reflection/DynamicClassFactory.java | DynamicClassFactory.getCompiledClass | public final static Class<?> getCompiledClass(String className, boolean useCache) throws CompilationException, ClassLoadException {
try {
if (! useCache) {
/*String compilationResult = compileClass(className);
System.out.println("************ compilationResult " + compilationResult);
if (compilationResult.contains("cannot read")) {
throw new ClassLoadException(compilationResult);
}
if (compilationResult.contains("error")) {
throw new CompilationException(compilationResult);
}*/
DynamicClassLoader dynamicClassLoader = new DynamicClassLoader(DynamicClassFactory.class.getClassLoader());
return dynamicClassLoader.loadClass(className);
} else {
return CACHED_CONTROLLERS.computeIfAbsent(className, WRAP_FORNAME);
}
} catch (CompilationException e) {
throw e; // so the exception doesn't get caught by the more general catch(Exception)
} catch (Exception e) {
throw new ClassLoadException(e);
}
} | java | public final static Class<?> getCompiledClass(String className, boolean useCache) throws CompilationException, ClassLoadException {
try {
if (! useCache) {
/*String compilationResult = compileClass(className);
System.out.println("************ compilationResult " + compilationResult);
if (compilationResult.contains("cannot read")) {
throw new ClassLoadException(compilationResult);
}
if (compilationResult.contains("error")) {
throw new CompilationException(compilationResult);
}*/
DynamicClassLoader dynamicClassLoader = new DynamicClassLoader(DynamicClassFactory.class.getClassLoader());
return dynamicClassLoader.loadClass(className);
} else {
return CACHED_CONTROLLERS.computeIfAbsent(className, WRAP_FORNAME);
}
} catch (CompilationException e) {
throw e; // so the exception doesn't get caught by the more general catch(Exception)
} catch (Exception e) {
throw new ClassLoadException(e);
}
} | [
"public",
"final",
"static",
"Class",
"<",
"?",
">",
"getCompiledClass",
"(",
"String",
"className",
",",
"boolean",
"useCache",
")",
"throws",
"CompilationException",
",",
"ClassLoadException",
"{",
"try",
"{",
"if",
"(",
"!",
"useCache",
")",
"{",
"/*String compilationResult = compileClass(className);\n System.out.println(\"************ compilationResult \" + compilationResult);\n if (compilationResult.contains(\"cannot read\")) {\n throw new ClassLoadException(compilationResult);\n }\n if (compilationResult.contains(\"error\")) {\n throw new CompilationException(compilationResult);\n }*/",
"DynamicClassLoader",
"dynamicClassLoader",
"=",
"new",
"DynamicClassLoader",
"(",
"DynamicClassFactory",
".",
"class",
".",
"getClassLoader",
"(",
")",
")",
";",
"return",
"dynamicClassLoader",
".",
"loadClass",
"(",
"className",
")",
";",
"}",
"else",
"{",
"return",
"CACHED_CONTROLLERS",
".",
"computeIfAbsent",
"(",
"className",
",",
"WRAP_FORNAME",
")",
";",
"}",
"}",
"catch",
"(",
"CompilationException",
"e",
")",
"{",
"throw",
"e",
";",
"// so the exception doesn't get caught by the more general catch(Exception)",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ClassLoadException",
"(",
"e",
")",
";",
"}",
"}"
] | Handles caching of classes if not active_reload
@param className
@param useCache flag to specify whether to cache the controller or not
@return
@throws CompilationException
@throws ClassLoadException | [
"Handles",
"caching",
"of",
"classes",
"if",
"not",
"active_reload"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/reflection/DynamicClassFactory.java#L83-L106 |
141,769 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/ResultBuilder.java | ResultBuilder.json | public final Result json(Object obj) {
final Result response = ok().contentType(MediaType.APPLICATION_JSON).renderable(obj);
holder.setControllerResult(response);
return response;
} | java | public final Result json(Object obj) {
final Result response = ok().contentType(MediaType.APPLICATION_JSON).renderable(obj);
holder.setControllerResult(response);
return response;
} | [
"public",
"final",
"Result",
"json",
"(",
"Object",
"obj",
")",
"{",
"final",
"Result",
"response",
"=",
"ok",
"(",
")",
".",
"contentType",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
".",
"renderable",
"(",
"obj",
")",
";",
"holder",
".",
"setControllerResult",
"(",
"response",
")",
";",
"return",
"response",
";",
"}"
] | This method will send a JSON response to the client.
It will not use any layouts.
Use it to build app.services and to support AJAX.
@param obj
@return {@link Result}, to accept additional information. The response is automatically
has its content type set to "application/json" | [
"This",
"method",
"will",
"send",
"a",
"JSON",
"response",
"to",
"the",
"client",
".",
"It",
"will",
"not",
"use",
"any",
"layouts",
".",
"Use",
"it",
"to",
"build",
"app",
".",
"services",
"and",
"to",
"support",
"AJAX",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/ResultBuilder.java#L105-L109 |
141,770 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/ResultBuilder.java | ResultBuilder.xml | public Result xml(Object obj) {
Result response = ok();
holder.setControllerResult(response);
response.contentType(MediaType.APPLICATION_XML).renderable(obj);
return response;
} | java | public Result xml(Object obj) {
Result response = ok();
holder.setControllerResult(response);
response.contentType(MediaType.APPLICATION_XML).renderable(obj);
return response;
} | [
"public",
"Result",
"xml",
"(",
"Object",
"obj",
")",
"{",
"Result",
"response",
"=",
"ok",
"(",
")",
";",
"holder",
".",
"setControllerResult",
"(",
"response",
")",
";",
"response",
".",
"contentType",
"(",
"MediaType",
".",
"APPLICATION_XML",
")",
".",
"renderable",
"(",
"obj",
")",
";",
"return",
"response",
";",
"}"
] | This method will send a XML response to the client.
It will not use any layouts.
Use it to build app.services.
@param obj
@return {@link Result}, to accept additional information. The response is automatically
has its content type set to "application/xml" | [
"This",
"method",
"will",
"send",
"a",
"XML",
"response",
"to",
"the",
"client",
".",
"It",
"will",
"not",
"use",
"any",
"layouts",
".",
"Use",
"it",
"to",
"build",
"app",
".",
"services",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/ResultBuilder.java#L130-L135 |
141,771 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java | AsciidocRuleParserPlugin.extractRules | private void extractRules(RuleSource ruleSource, Collection<?> blocks, RuleSetBuilder builder) throws RuleException {
for (Object element : blocks) {
if (element instanceof AbstractBlock) {
AbstractBlock block = (AbstractBlock) element;
if (EXECUTABLE_RULE_TYPES.contains(block.getRole())) {
extractExecutableRule(ruleSource, block, builder);
} else if (GROUP.equals(block.getRole())) {
extractGroup(ruleSource, block, builder);
}
extractRules(ruleSource, block.getBlocks(), builder);
} else if (element instanceof Collection<?>) {
extractRules(ruleSource, (Collection<?>) element, builder);
}
}
} | java | private void extractRules(RuleSource ruleSource, Collection<?> blocks, RuleSetBuilder builder) throws RuleException {
for (Object element : blocks) {
if (element instanceof AbstractBlock) {
AbstractBlock block = (AbstractBlock) element;
if (EXECUTABLE_RULE_TYPES.contains(block.getRole())) {
extractExecutableRule(ruleSource, block, builder);
} else if (GROUP.equals(block.getRole())) {
extractGroup(ruleSource, block, builder);
}
extractRules(ruleSource, block.getBlocks(), builder);
} else if (element instanceof Collection<?>) {
extractRules(ruleSource, (Collection<?>) element, builder);
}
}
} | [
"private",
"void",
"extractRules",
"(",
"RuleSource",
"ruleSource",
",",
"Collection",
"<",
"?",
">",
"blocks",
",",
"RuleSetBuilder",
"builder",
")",
"throws",
"RuleException",
"{",
"for",
"(",
"Object",
"element",
":",
"blocks",
")",
"{",
"if",
"(",
"element",
"instanceof",
"AbstractBlock",
")",
"{",
"AbstractBlock",
"block",
"=",
"(",
"AbstractBlock",
")",
"element",
";",
"if",
"(",
"EXECUTABLE_RULE_TYPES",
".",
"contains",
"(",
"block",
".",
"getRole",
"(",
")",
")",
")",
"{",
"extractExecutableRule",
"(",
"ruleSource",
",",
"block",
",",
"builder",
")",
";",
"}",
"else",
"if",
"(",
"GROUP",
".",
"equals",
"(",
"block",
".",
"getRole",
"(",
")",
")",
")",
"{",
"extractGroup",
"(",
"ruleSource",
",",
"block",
",",
"builder",
")",
";",
"}",
"extractRules",
"(",
"ruleSource",
",",
"block",
".",
"getBlocks",
"(",
")",
",",
"builder",
")",
";",
"}",
"else",
"if",
"(",
"element",
"instanceof",
"Collection",
"<",
"?",
">",
")",
"{",
"extractRules",
"(",
"ruleSource",
",",
"(",
"Collection",
"<",
"?",
">",
")",
"element",
",",
"builder",
")",
";",
"}",
"}",
"}"
] | Find all content parts representing source code listings with a role that
represents a rule.
@param ruleSource
The rule source.
@param blocks
The content parts of the document.
@param builder
The {@link RuleSetBuilder}. | [
"Find",
"all",
"content",
"parts",
"representing",
"source",
"code",
"listings",
"with",
"a",
"role",
"that",
"represents",
"a",
"rule",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java#L152-L166 |
141,772 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java | AsciidocRuleParserPlugin.getRequiresConcepts | private Map<String, Boolean> getRequiresConcepts(RuleSource ruleSource, String id, Attributes attributes) throws RuleException {
Map<String, String> requiresDeclarations = getReferences(attributes, REQUIRES_CONCEPTS);
Map<String, Boolean> required = new HashMap<>();
for (Map.Entry<String, String> requiresEntry : requiresDeclarations.entrySet()) {
String conceptId = requiresEntry.getKey();
String dependencyAttribute = requiresEntry.getValue();
Boolean optional = dependencyAttribute != null ? OPTIONAL.equals(dependencyAttribute.toLowerCase()) : null;
required.put(conceptId, optional);
}
return required;
} | java | private Map<String, Boolean> getRequiresConcepts(RuleSource ruleSource, String id, Attributes attributes) throws RuleException {
Map<String, String> requiresDeclarations = getReferences(attributes, REQUIRES_CONCEPTS);
Map<String, Boolean> required = new HashMap<>();
for (Map.Entry<String, String> requiresEntry : requiresDeclarations.entrySet()) {
String conceptId = requiresEntry.getKey();
String dependencyAttribute = requiresEntry.getValue();
Boolean optional = dependencyAttribute != null ? OPTIONAL.equals(dependencyAttribute.toLowerCase()) : null;
required.put(conceptId, optional);
}
return required;
} | [
"private",
"Map",
"<",
"String",
",",
"Boolean",
">",
"getRequiresConcepts",
"(",
"RuleSource",
"ruleSource",
",",
"String",
"id",
",",
"Attributes",
"attributes",
")",
"throws",
"RuleException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"requiresDeclarations",
"=",
"getReferences",
"(",
"attributes",
",",
"REQUIRES_CONCEPTS",
")",
";",
"Map",
"<",
"String",
",",
"Boolean",
">",
"required",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"requiresEntry",
":",
"requiresDeclarations",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"conceptId",
"=",
"requiresEntry",
".",
"getKey",
"(",
")",
";",
"String",
"dependencyAttribute",
"=",
"requiresEntry",
".",
"getValue",
"(",
")",
";",
"Boolean",
"optional",
"=",
"dependencyAttribute",
"!=",
"null",
"?",
"OPTIONAL",
".",
"equals",
"(",
"dependencyAttribute",
".",
"toLowerCase",
"(",
")",
")",
":",
"null",
";",
"required",
".",
"put",
"(",
"conceptId",
",",
"optional",
")",
";",
"}",
"return",
"required",
";",
"}"
] | Evaluates required concepts of a rule.
@param ruleSource
The rule source.
@param attributes
The attributes of an asciidoc rule block
@param id
The id.
@return A map where the keys represent the ids of required concepts and the
values if they are optional.
@throws RuleException
If the dependencies cannot be evaluated. | [
"Evaluates",
"required",
"concepts",
"of",
"a",
"rule",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java#L251-L261 |
141,773 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java | AsciidocRuleParserPlugin.getReferences | private Map<String, String> getReferences(Attributes attributes, String attributeName) {
String attribute = attributes.getString(attributeName);
Set<String> references = new HashSet<>();
if (attribute != null && !attribute.trim().isEmpty()) {
references.addAll(asList(attribute.split("\\s*,\\s*")));
}
Map<String, String> rules = new HashMap<>();
for (String reference : references) {
Matcher matcher = DEPENDENCY_PATTERN.matcher(reference);
if (matcher.matches()) {
String id = matcher.group(1);
String referenceValue = matcher.group(3);
rules.put(id, referenceValue);
}
}
return rules;
} | java | private Map<String, String> getReferences(Attributes attributes, String attributeName) {
String attribute = attributes.getString(attributeName);
Set<String> references = new HashSet<>();
if (attribute != null && !attribute.trim().isEmpty()) {
references.addAll(asList(attribute.split("\\s*,\\s*")));
}
Map<String, String> rules = new HashMap<>();
for (String reference : references) {
Matcher matcher = DEPENDENCY_PATTERN.matcher(reference);
if (matcher.matches()) {
String id = matcher.group(1);
String referenceValue = matcher.group(3);
rules.put(id, referenceValue);
}
}
return rules;
} | [
"private",
"Map",
"<",
"String",
",",
"String",
">",
"getReferences",
"(",
"Attributes",
"attributes",
",",
"String",
"attributeName",
")",
"{",
"String",
"attribute",
"=",
"attributes",
".",
"getString",
"(",
"attributeName",
")",
";",
"Set",
"<",
"String",
">",
"references",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"if",
"(",
"attribute",
"!=",
"null",
"&&",
"!",
"attribute",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"references",
".",
"addAll",
"(",
"asList",
"(",
"attribute",
".",
"split",
"(",
"\"\\\\s*,\\\\s*\"",
")",
")",
")",
";",
"}",
"Map",
"<",
"String",
",",
"String",
">",
"rules",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"reference",
":",
"references",
")",
"{",
"Matcher",
"matcher",
"=",
"DEPENDENCY_PATTERN",
".",
"matcher",
"(",
"reference",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"String",
"id",
"=",
"matcher",
".",
"group",
"(",
"1",
")",
";",
"String",
"referenceValue",
"=",
"matcher",
".",
"group",
"(",
"3",
")",
";",
"rules",
".",
"put",
"(",
"id",
",",
"referenceValue",
")",
";",
"}",
"}",
"return",
"rules",
";",
"}"
] | Get reference declarations for an attribute from a map of attributes.
@param attributes
The map of attributes.
@param attributeName
The name of the attribute.
@return A map containing the ids of the references as keys and their
associated values (optional). | [
"Get",
"reference",
"declarations",
"for",
"an",
"attribute",
"from",
"a",
"map",
"of",
"attributes",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java#L296-L312 |
141,774 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java | AsciidocRuleParserPlugin.getSeverity | private Severity getSeverity(Attributes attributes, Severity defaultSeverity) throws RuleException {
String severity = attributes.getString(SEVERITY);
if (severity == null) {
return defaultSeverity;
}
Severity value = Severity.fromValue(severity.toLowerCase());
return value != null ? value : defaultSeverity;
} | java | private Severity getSeverity(Attributes attributes, Severity defaultSeverity) throws RuleException {
String severity = attributes.getString(SEVERITY);
if (severity == null) {
return defaultSeverity;
}
Severity value = Severity.fromValue(severity.toLowerCase());
return value != null ? value : defaultSeverity;
} | [
"private",
"Severity",
"getSeverity",
"(",
"Attributes",
"attributes",
",",
"Severity",
"defaultSeverity",
")",
"throws",
"RuleException",
"{",
"String",
"severity",
"=",
"attributes",
".",
"getString",
"(",
"SEVERITY",
")",
";",
"if",
"(",
"severity",
"==",
"null",
")",
"{",
"return",
"defaultSeverity",
";",
"}",
"Severity",
"value",
"=",
"Severity",
".",
"fromValue",
"(",
"severity",
".",
"toLowerCase",
"(",
")",
")",
";",
"return",
"value",
"!=",
"null",
"?",
"value",
":",
"defaultSeverity",
";",
"}"
] | Extract the optional severity of a rule.
@param attributes
The attributes of the rule.
@param defaultSeverity
The default severity to use if no severity is specified.
@return The severity. | [
"Extract",
"the",
"optional",
"severity",
"of",
"a",
"rule",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java#L323-L330 |
141,775 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java | AsciidocRuleParserPlugin.unescapeHtml | private String unescapeHtml(Object content) {
return content != null ? content.toString().replace("<", "<").replace(">", ">") : "";
} | java | private String unescapeHtml(Object content) {
return content != null ? content.toString().replace("<", "<").replace(">", ">") : "";
} | [
"private",
"String",
"unescapeHtml",
"(",
"Object",
"content",
")",
"{",
"return",
"content",
"!=",
"null",
"?",
"content",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"\"<\"",
",",
"\"<\"",
")",
".",
"replace",
"(",
"\">\"",
",",
"\">\"",
")",
":",
"\"\"",
";",
"}"
] | Unescapes the content of a rule.
TODO do better, or even better add a partget(Original|Raw)Content() to
asciidoctor
@param content
The content of a rule.
@return The unescaped rule | [
"Unescapes",
"the",
"content",
"of",
"a",
"rule",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java#L342-L344 |
141,776 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java | AsciidocRuleParserPlugin.getReport | private Report getReport(AbstractBlock part) {
Object primaryReportColum = part.getAttributes().get(PRIMARY_REPORT_COLUM);
Object reportType = part.getAttributes().get(REPORT_TYPE);
Properties reportProperties = parseProperties(part, REPORT_PROPERTIES);
Report.ReportBuilder reportBuilder = Report.builder();
if (reportType != null) {
reportBuilder.selectedTypes(Report.selectTypes(reportType.toString()));
}
if (primaryReportColum != null) {
reportBuilder.primaryColumn(primaryReportColum.toString());
}
return reportBuilder.properties(reportProperties).build();
} | java | private Report getReport(AbstractBlock part) {
Object primaryReportColum = part.getAttributes().get(PRIMARY_REPORT_COLUM);
Object reportType = part.getAttributes().get(REPORT_TYPE);
Properties reportProperties = parseProperties(part, REPORT_PROPERTIES);
Report.ReportBuilder reportBuilder = Report.builder();
if (reportType != null) {
reportBuilder.selectedTypes(Report.selectTypes(reportType.toString()));
}
if (primaryReportColum != null) {
reportBuilder.primaryColumn(primaryReportColum.toString());
}
return reportBuilder.properties(reportProperties).build();
} | [
"private",
"Report",
"getReport",
"(",
"AbstractBlock",
"part",
")",
"{",
"Object",
"primaryReportColum",
"=",
"part",
".",
"getAttributes",
"(",
")",
".",
"get",
"(",
"PRIMARY_REPORT_COLUM",
")",
";",
"Object",
"reportType",
"=",
"part",
".",
"getAttributes",
"(",
")",
".",
"get",
"(",
"REPORT_TYPE",
")",
";",
"Properties",
"reportProperties",
"=",
"parseProperties",
"(",
"part",
",",
"REPORT_PROPERTIES",
")",
";",
"Report",
".",
"ReportBuilder",
"reportBuilder",
"=",
"Report",
".",
"builder",
"(",
")",
";",
"if",
"(",
"reportType",
"!=",
"null",
")",
"{",
"reportBuilder",
".",
"selectedTypes",
"(",
"Report",
".",
"selectTypes",
"(",
"reportType",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"primaryReportColum",
"!=",
"null",
")",
"{",
"reportBuilder",
".",
"primaryColumn",
"(",
"primaryReportColum",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"reportBuilder",
".",
"properties",
"(",
"reportProperties",
")",
".",
"build",
"(",
")",
";",
"}"
] | Create the report part of a rule.
@param part
The content part.
@return The report. | [
"Create",
"the",
"report",
"part",
"of",
"a",
"rule",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java#L353-L365 |
141,777 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java | AsciidocRuleParserPlugin.parseProperties | private Properties parseProperties(AbstractBlock part, String attributeName) {
Properties properties = new Properties();
Object attribute = part.getAttributes().get(attributeName);
if (attribute == null) {
return properties;
}
Scanner propertiesScanner = new Scanner(attribute.toString());
propertiesScanner.useDelimiter(";");
while (propertiesScanner.hasNext()) {
String next = propertiesScanner.next().trim();
if (next.length() > 0) {
Scanner propertyScanner = new Scanner(next);
propertyScanner.useDelimiter("=");
String key = propertyScanner.next().trim();
String value = propertyScanner.next().trim();
properties.setProperty(key, value);
}
}
return properties;
} | java | private Properties parseProperties(AbstractBlock part, String attributeName) {
Properties properties = new Properties();
Object attribute = part.getAttributes().get(attributeName);
if (attribute == null) {
return properties;
}
Scanner propertiesScanner = new Scanner(attribute.toString());
propertiesScanner.useDelimiter(";");
while (propertiesScanner.hasNext()) {
String next = propertiesScanner.next().trim();
if (next.length() > 0) {
Scanner propertyScanner = new Scanner(next);
propertyScanner.useDelimiter("=");
String key = propertyScanner.next().trim();
String value = propertyScanner.next().trim();
properties.setProperty(key, value);
}
}
return properties;
} | [
"private",
"Properties",
"parseProperties",
"(",
"AbstractBlock",
"part",
",",
"String",
"attributeName",
")",
"{",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"Object",
"attribute",
"=",
"part",
".",
"getAttributes",
"(",
")",
".",
"get",
"(",
"attributeName",
")",
";",
"if",
"(",
"attribute",
"==",
"null",
")",
"{",
"return",
"properties",
";",
"}",
"Scanner",
"propertiesScanner",
"=",
"new",
"Scanner",
"(",
"attribute",
".",
"toString",
"(",
")",
")",
";",
"propertiesScanner",
".",
"useDelimiter",
"(",
"\";\"",
")",
";",
"while",
"(",
"propertiesScanner",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"next",
"=",
"propertiesScanner",
".",
"next",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"next",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"Scanner",
"propertyScanner",
"=",
"new",
"Scanner",
"(",
"next",
")",
";",
"propertyScanner",
".",
"useDelimiter",
"(",
"\"=\"",
")",
";",
"String",
"key",
"=",
"propertyScanner",
".",
"next",
"(",
")",
".",
"trim",
"(",
")",
";",
"String",
"value",
"=",
"propertyScanner",
".",
"next",
"(",
")",
".",
"trim",
"(",
")",
";",
"properties",
".",
"setProperty",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"return",
"properties",
";",
"}"
] | Parse properties from an attribute.
@param part
The content part containing the attribute.
@param attributeName
The attribute name.
@return The properties. | [
"Parse",
"properties",
"from",
"an",
"attribute",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/AsciidocRuleParserPlugin.java#L376-L395 |
141,778 | MTDdk/jawn | jawn-core-new/src/main/java/net/javapla/jawn/core/internal/reflection/DynamicClassFactory.java | DynamicClassFactory.getCompiledClass | public final static Class<?> getCompiledClass(String fullClassName, boolean useCache) throws Err.Compilation, Err.UnloadableClass {
try {
if (! useCache) {
DynamicClassLoader dynamicClassLoader = new DynamicClassLoader(fullClassName.substring(0, fullClassName.lastIndexOf('.')));
Class<?> cl = dynamicClassLoader.loadClass(fullClassName);
dynamicClassLoader = null;
return cl;
} else {
return CACHED_CONTROLLERS.computeIfAbsent(fullClassName, WRAP_FORNAME);
}
} catch (Exception e) {
throw new Err.UnloadableClass(e);
}
} | java | public final static Class<?> getCompiledClass(String fullClassName, boolean useCache) throws Err.Compilation, Err.UnloadableClass {
try {
if (! useCache) {
DynamicClassLoader dynamicClassLoader = new DynamicClassLoader(fullClassName.substring(0, fullClassName.lastIndexOf('.')));
Class<?> cl = dynamicClassLoader.loadClass(fullClassName);
dynamicClassLoader = null;
return cl;
} else {
return CACHED_CONTROLLERS.computeIfAbsent(fullClassName, WRAP_FORNAME);
}
} catch (Exception e) {
throw new Err.UnloadableClass(e);
}
} | [
"public",
"final",
"static",
"Class",
"<",
"?",
">",
"getCompiledClass",
"(",
"String",
"fullClassName",
",",
"boolean",
"useCache",
")",
"throws",
"Err",
".",
"Compilation",
",",
"Err",
".",
"UnloadableClass",
"{",
"try",
"{",
"if",
"(",
"!",
"useCache",
")",
"{",
"DynamicClassLoader",
"dynamicClassLoader",
"=",
"new",
"DynamicClassLoader",
"(",
"fullClassName",
".",
"substring",
"(",
"0",
",",
"fullClassName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
")",
";",
"Class",
"<",
"?",
">",
"cl",
"=",
"dynamicClassLoader",
".",
"loadClass",
"(",
"fullClassName",
")",
";",
"dynamicClassLoader",
"=",
"null",
";",
"return",
"cl",
";",
"}",
"else",
"{",
"return",
"CACHED_CONTROLLERS",
".",
"computeIfAbsent",
"(",
"fullClassName",
",",
"WRAP_FORNAME",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"Err",
".",
"UnloadableClass",
"(",
"e",
")",
";",
"}",
"}"
] | Handles caching of classes if not useCache
@param fullClassName including package name
@param useCache flag to specify whether to cache the controller or not
@return
@throws CompilationException
@throws ClassLoadException | [
"Handles",
"caching",
"of",
"classes",
"if",
"not",
"useCache"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core-new/src/main/java/net/javapla/jawn/core/internal/reflection/DynamicClassFactory.java#L68-L81 |
141,779 | cvent/pangaea | src/main/java/com/cvent/pangaea/MultiEnvAware.java | MultiEnvAware.getKeyOrDefault | public String getKeyOrDefault(String key) {
if (StringUtils.isBlank(key)) {
if (this.hasDefaultEnvironment()) {
return defaultEnvironment;
} else {
throw new MultiEnvSupportException("[environment] property is mandatory and can't be empty");
}
}
if (map.containsKey(key)) {
return key;
}
if (this.hasTemplateEnvironment()) {
return this.templateEnvironment;
}
LOG.error("Failed to find environment [{}] in {}", key, this.keySet());
throw new MultiEnvSupportException(String.format(
"Failed to find configuration for environment %s", key));
} | java | public String getKeyOrDefault(String key) {
if (StringUtils.isBlank(key)) {
if (this.hasDefaultEnvironment()) {
return defaultEnvironment;
} else {
throw new MultiEnvSupportException("[environment] property is mandatory and can't be empty");
}
}
if (map.containsKey(key)) {
return key;
}
if (this.hasTemplateEnvironment()) {
return this.templateEnvironment;
}
LOG.error("Failed to find environment [{}] in {}", key, this.keySet());
throw new MultiEnvSupportException(String.format(
"Failed to find configuration for environment %s", key));
} | [
"public",
"String",
"getKeyOrDefault",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"key",
")",
")",
"{",
"if",
"(",
"this",
".",
"hasDefaultEnvironment",
"(",
")",
")",
"{",
"return",
"defaultEnvironment",
";",
"}",
"else",
"{",
"throw",
"new",
"MultiEnvSupportException",
"(",
"\"[environment] property is mandatory and can't be empty\"",
")",
";",
"}",
"}",
"if",
"(",
"map",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"return",
"key",
";",
"}",
"if",
"(",
"this",
".",
"hasTemplateEnvironment",
"(",
")",
")",
"{",
"return",
"this",
".",
"templateEnvironment",
";",
"}",
"LOG",
".",
"error",
"(",
"\"Failed to find environment [{}] in {}\"",
",",
"key",
",",
"this",
".",
"keySet",
"(",
")",
")",
";",
"throw",
"new",
"MultiEnvSupportException",
"(",
"String",
".",
"format",
"(",
"\"Failed to find configuration for environment %s\"",
",",
"key",
")",
")",
";",
"}"
] | Returns the key, if that specified key is mapped to something
@param key - environment name
@return String | [
"Returns",
"the",
"key",
"if",
"that",
"specified",
"key",
"is",
"mapped",
"to",
"something"
] | 6cd213c370817905ae04a67db07347a4e29a708c | https://github.com/cvent/pangaea/blob/6cd213c370817905ae04a67db07347a4e29a708c/src/main/java/com/cvent/pangaea/MultiEnvAware.java#L120-L137 |
141,780 | cvent/pangaea | src/main/java/com/cvent/pangaea/MultiEnvAware.java | MultiEnvAware.get | @Override
public T get(Object key) {
String sKey = (String) key;
if (StringUtils.isBlank(sKey) && this.hasDefaultEnvironment()) {
sKey = defaultEnvironment;
} else if (StringUtils.isBlank(sKey)) {
throw new MultiEnvSupportException("[environment] property is mandatory and can't be empty");
}
T value = map.get(sKey);
if (value == null) {
if (creationFunction != null) {
value = creationFunction.apply(sKey);
} else {
value = resolve(sKey, getTemplate());
}
if (value != null) {
map.put(sKey, value);
}
}
return value;
} | java | @Override
public T get(Object key) {
String sKey = (String) key;
if (StringUtils.isBlank(sKey) && this.hasDefaultEnvironment()) {
sKey = defaultEnvironment;
} else if (StringUtils.isBlank(sKey)) {
throw new MultiEnvSupportException("[environment] property is mandatory and can't be empty");
}
T value = map.get(sKey);
if (value == null) {
if (creationFunction != null) {
value = creationFunction.apply(sKey);
} else {
value = resolve(sKey, getTemplate());
}
if (value != null) {
map.put(sKey, value);
}
}
return value;
} | [
"@",
"Override",
"public",
"T",
"get",
"(",
"Object",
"key",
")",
"{",
"String",
"sKey",
"=",
"(",
"String",
")",
"key",
";",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"sKey",
")",
"&&",
"this",
".",
"hasDefaultEnvironment",
"(",
")",
")",
"{",
"sKey",
"=",
"defaultEnvironment",
";",
"}",
"else",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"sKey",
")",
")",
"{",
"throw",
"new",
"MultiEnvSupportException",
"(",
"\"[environment] property is mandatory and can't be empty\"",
")",
";",
"}",
"T",
"value",
"=",
"map",
".",
"get",
"(",
"sKey",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"if",
"(",
"creationFunction",
"!=",
"null",
")",
"{",
"value",
"=",
"creationFunction",
".",
"apply",
"(",
"sKey",
")",
";",
"}",
"else",
"{",
"value",
"=",
"resolve",
"(",
"sKey",
",",
"getTemplate",
"(",
")",
")",
";",
"}",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"map",
".",
"put",
"(",
"sKey",
",",
"value",
")",
";",
"}",
"}",
"return",
"value",
";",
"}"
] | Returns the value to which the specified key is mapped, and adds it to the internal map if it wasn't previously
present.
@param key - environment name | [
"Returns",
"the",
"value",
"to",
"which",
"the",
"specified",
"key",
"is",
"mapped",
"and",
"adds",
"it",
"to",
"the",
"internal",
"map",
"if",
"it",
"wasn",
"t",
"previously",
"present",
"."
] | 6cd213c370817905ae04a67db07347a4e29a708c | https://github.com/cvent/pangaea/blob/6cd213c370817905ae04a67db07347a4e29a708c/src/main/java/com/cvent/pangaea/MultiEnvAware.java#L178-L200 |
141,781 | cvent/pangaea | src/main/java/com/cvent/pangaea/MultiEnvAware.java | MultiEnvAware.resolve | protected T resolve(String sKey, T value) {
LOG.error("Fail to find environment [{}] in {}", sKey, this.keySet());
throw new MultiEnvSupportException(String.format(
"Fail to find configuration for environment %s", sKey));
} | java | protected T resolve(String sKey, T value) {
LOG.error("Fail to find environment [{}] in {}", sKey, this.keySet());
throw new MultiEnvSupportException(String.format(
"Fail to find configuration for environment %s", sKey));
} | [
"protected",
"T",
"resolve",
"(",
"String",
"sKey",
",",
"T",
"value",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Fail to find environment [{}] in {}\"",
",",
"sKey",
",",
"this",
".",
"keySet",
"(",
")",
")",
";",
"throw",
"new",
"MultiEnvSupportException",
"(",
"String",
".",
"format",
"(",
"\"Fail to find configuration for environment %s\"",
",",
"sKey",
")",
")",
";",
"}"
] | By default we don't try to resolve anything, but others can extend this behavior if they'd like to try to resolve
not found values differently.
@param sKey
@param value
@return | [
"By",
"default",
"we",
"don",
"t",
"try",
"to",
"resolve",
"anything",
"but",
"others",
"can",
"extend",
"this",
"behavior",
"if",
"they",
"d",
"like",
"to",
"try",
"to",
"resolve",
"not",
"found",
"values",
"differently",
"."
] | 6cd213c370817905ae04a67db07347a4e29a708c | https://github.com/cvent/pangaea/blob/6cd213c370817905ae04a67db07347a4e29a708c/src/main/java/com/cvent/pangaea/MultiEnvAware.java#L331-L335 |
141,782 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java | ImageHandlerBuilder.resize | public ImageHandlerBuilder resize(int width, int height) {
BufferedImage resize = Scalr.resize(image, Scalr.Mode.FIT_EXACT, width, height);
image.flush();
image = resize;
return this;
} | java | public ImageHandlerBuilder resize(int width, int height) {
BufferedImage resize = Scalr.resize(image, Scalr.Mode.FIT_EXACT, width, height);
image.flush();
image = resize;
return this;
} | [
"public",
"ImageHandlerBuilder",
"resize",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"BufferedImage",
"resize",
"=",
"Scalr",
".",
"resize",
"(",
"image",
",",
"Scalr",
".",
"Mode",
".",
"FIT_EXACT",
",",
"width",
",",
"height",
")",
";",
"image",
".",
"flush",
"(",
")",
";",
"image",
"=",
"resize",
";",
"return",
"this",
";",
"}"
] | Resize the image to the given width and height
@param width
@param height
@return | [
"Resize",
"the",
"image",
"to",
"the",
"given",
"width",
"and",
"height"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L179-L184 |
141,783 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java | ImageHandlerBuilder.resizeToHeight | public ImageHandlerBuilder resizeToHeight(int size) {
if (image.getHeight() < size) return this;
BufferedImage resize = Scalr.resize(image, Scalr.Mode.FIT_TO_HEIGHT, Math.min(size, image.getHeight()));
image.flush();
image = resize;
return this;
} | java | public ImageHandlerBuilder resizeToHeight(int size) {
if (image.getHeight() < size) return this;
BufferedImage resize = Scalr.resize(image, Scalr.Mode.FIT_TO_HEIGHT, Math.min(size, image.getHeight()));
image.flush();
image = resize;
return this;
} | [
"public",
"ImageHandlerBuilder",
"resizeToHeight",
"(",
"int",
"size",
")",
"{",
"if",
"(",
"image",
".",
"getHeight",
"(",
")",
"<",
"size",
")",
"return",
"this",
";",
"BufferedImage",
"resize",
"=",
"Scalr",
".",
"resize",
"(",
"image",
",",
"Scalr",
".",
"Mode",
".",
"FIT_TO_HEIGHT",
",",
"Math",
".",
"min",
"(",
"size",
",",
"image",
".",
"getHeight",
"(",
")",
")",
")",
";",
"image",
".",
"flush",
"(",
")",
";",
"image",
"=",
"resize",
";",
"return",
"this",
";",
"}"
] | Resize the image to a given height, maintaining the original proportions of the image
and setting the width accordingly.
If the height of the image is smaller than the provided size, then the image is not scaled.
@param size
@return | [
"Resize",
"the",
"image",
"to",
"a",
"given",
"height",
"maintaining",
"the",
"original",
"proportions",
"of",
"the",
"image",
"and",
"setting",
"the",
"width",
"accordingly",
".",
"If",
"the",
"height",
"of",
"the",
"image",
"is",
"smaller",
"than",
"the",
"provided",
"size",
"then",
"the",
"image",
"is",
"not",
"scaled",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L192-L198 |
141,784 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java | ImageHandlerBuilder.resizeToWidth | public ImageHandlerBuilder resizeToWidth(int size) {
if (image.getWidth() < size) return this;
BufferedImage resize = Scalr.resize(image, Scalr.Mode.FIT_TO_WIDTH, size);
image.flush();
image = resize;
return this;
} | java | public ImageHandlerBuilder resizeToWidth(int size) {
if (image.getWidth() < size) return this;
BufferedImage resize = Scalr.resize(image, Scalr.Mode.FIT_TO_WIDTH, size);
image.flush();
image = resize;
return this;
} | [
"public",
"ImageHandlerBuilder",
"resizeToWidth",
"(",
"int",
"size",
")",
"{",
"if",
"(",
"image",
".",
"getWidth",
"(",
")",
"<",
"size",
")",
"return",
"this",
";",
"BufferedImage",
"resize",
"=",
"Scalr",
".",
"resize",
"(",
"image",
",",
"Scalr",
".",
"Mode",
".",
"FIT_TO_WIDTH",
",",
"size",
")",
";",
"image",
".",
"flush",
"(",
")",
";",
"image",
"=",
"resize",
";",
"return",
"this",
";",
"}"
] | Resize the image to a given width, maintaining the original proportions of the image
and setting the height accordingly.
If the width of the image is smaller than the provided size, then the image is not scaled.
@param size
@return this | [
"Resize",
"the",
"image",
"to",
"a",
"given",
"width",
"maintaining",
"the",
"original",
"proportions",
"of",
"the",
"image",
"and",
"setting",
"the",
"height",
"accordingly",
".",
"If",
"the",
"width",
"of",
"the",
"image",
"is",
"smaller",
"than",
"the",
"provided",
"size",
"then",
"the",
"image",
"is",
"not",
"scaled",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L206-L212 |
141,785 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java | ImageHandlerBuilder.save | public String save(String uploadFolder) throws ControllerException {
String realPath = info.getRealPath(uploadFolder);
fn.sanitise();
String imagename = uniqueImagename(realPath, fn.fullPath());
try {
ImageIO.write(image, fn.extension(), new File(realPath, imagename));
image.flush();
} catch (IOException e) {
throw new ControllerException(e);
}
return uploadFolder + File.separatorChar + imagename;
} | java | public String save(String uploadFolder) throws ControllerException {
String realPath = info.getRealPath(uploadFolder);
fn.sanitise();
String imagename = uniqueImagename(realPath, fn.fullPath());
try {
ImageIO.write(image, fn.extension(), new File(realPath, imagename));
image.flush();
} catch (IOException e) {
throw new ControllerException(e);
}
return uploadFolder + File.separatorChar + imagename;
} | [
"public",
"String",
"save",
"(",
"String",
"uploadFolder",
")",
"throws",
"ControllerException",
"{",
"String",
"realPath",
"=",
"info",
".",
"getRealPath",
"(",
"uploadFolder",
")",
";",
"fn",
".",
"sanitise",
"(",
")",
";",
"String",
"imagename",
"=",
"uniqueImagename",
"(",
"realPath",
",",
"fn",
".",
"fullPath",
"(",
")",
")",
";",
"try",
"{",
"ImageIO",
".",
"write",
"(",
"image",
",",
"fn",
".",
"extension",
"(",
")",
",",
"new",
"File",
"(",
"realPath",
",",
"imagename",
")",
")",
";",
"image",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ControllerException",
"(",
"e",
")",
";",
"}",
"return",
"uploadFolder",
"+",
"File",
".",
"separatorChar",
"+",
"imagename",
";",
"}"
] | Saves the file on the server in the folder given
@param uploadFolder
@return The server path to the saved file.
@throws ControllerException If anything goes wrong during write to disk. | [
"Saves",
"the",
"file",
"on",
"the",
"server",
"in",
"the",
"folder",
"given"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L277-L290 |
141,786 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java | ImageHandlerBuilder.uniqueImagename | String uniqueImagename(String folder, String filename) {
String buildFileName = filename;//.replace(' ', '_');
while ( (new File(folder , buildFileName)).exists())
buildFileName = fn.increment();
return buildFileName;//output.getPath();
} | java | String uniqueImagename(String folder, String filename) {
String buildFileName = filename;//.replace(' ', '_');
while ( (new File(folder , buildFileName)).exists())
buildFileName = fn.increment();
return buildFileName;//output.getPath();
} | [
"String",
"uniqueImagename",
"(",
"String",
"folder",
",",
"String",
"filename",
")",
"{",
"String",
"buildFileName",
"=",
"filename",
";",
"//.replace(' ', '_');",
"while",
"(",
"(",
"new",
"File",
"(",
"folder",
",",
"buildFileName",
")",
")",
".",
"exists",
"(",
")",
")",
"buildFileName",
"=",
"fn",
".",
"increment",
"(",
")",
";",
"return",
"buildFileName",
";",
"//output.getPath();",
"}"
] | Calculates a unique filename located in the image upload folder.
WARNING: not threadsafe! Another file with the calculated name might very well get written onto disk first after this name is found
@param filename
@return Outputs the relative path of the calculated filename. | [
"Calculates",
"a",
"unique",
"filename",
"located",
"in",
"the",
"image",
"upload",
"folder",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L327-L334 |
141,787 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/XmlRuleParserPlugin.java | XmlRuleParserPlugin.readXmlSource | private List<JqassistantRules> readXmlSource(RuleSource ruleSource) {
List<JqassistantRules> rules = new ArrayList<>();
try (InputStream inputStream = ruleSource.getInputStream()) {
JqassistantRules jqassistantRules = jaxbUnmarshaller.unmarshal(inputStream);
rules.add(jqassistantRules);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot read rules from '" + ruleSource.getId() + "'.", e);
}
return rules;
} | java | private List<JqassistantRules> readXmlSource(RuleSource ruleSource) {
List<JqassistantRules> rules = new ArrayList<>();
try (InputStream inputStream = ruleSource.getInputStream()) {
JqassistantRules jqassistantRules = jaxbUnmarshaller.unmarshal(inputStream);
rules.add(jqassistantRules);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot read rules from '" + ruleSource.getId() + "'.", e);
}
return rules;
} | [
"private",
"List",
"<",
"JqassistantRules",
">",
"readXmlSource",
"(",
"RuleSource",
"ruleSource",
")",
"{",
"List",
"<",
"JqassistantRules",
">",
"rules",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"(",
"InputStream",
"inputStream",
"=",
"ruleSource",
".",
"getInputStream",
"(",
")",
")",
"{",
"JqassistantRules",
"jqassistantRules",
"=",
"jaxbUnmarshaller",
".",
"unmarshal",
"(",
"inputStream",
")",
";",
"rules",
".",
"add",
"(",
"jqassistantRules",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot read rules from '\"",
"+",
"ruleSource",
".",
"getId",
"(",
")",
"+",
"\"'.\"",
",",
"e",
")",
";",
"}",
"return",
"rules",
";",
"}"
] | Read rules from XML documents.
@param ruleSource
The available sources.
@return The list of found rules. | [
"Read",
"rules",
"from",
"XML",
"documents",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/XmlRuleParserPlugin.java#L67-L76 |
141,788 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/XmlRuleParserPlugin.java | XmlRuleParserPlugin.getReport | private Report getReport(ReportType reportType) {
String type = null;
String primaryColumn = null;
Properties properties = new Properties();
if (reportType != null) {
type = reportType.getType();
primaryColumn = reportType.getPrimaryColumn();
for (PropertyType propertyType : reportType.getProperty()) {
properties.setProperty(propertyType.getName(), propertyType.getValue());
}
}
Report.ReportBuilder reportBuilder = Report.builder().primaryColumn(primaryColumn).properties(properties);
if (type != null) {
reportBuilder.selectedTypes(Report.selectTypes(type));
}
return reportBuilder.build();
} | java | private Report getReport(ReportType reportType) {
String type = null;
String primaryColumn = null;
Properties properties = new Properties();
if (reportType != null) {
type = reportType.getType();
primaryColumn = reportType.getPrimaryColumn();
for (PropertyType propertyType : reportType.getProperty()) {
properties.setProperty(propertyType.getName(), propertyType.getValue());
}
}
Report.ReportBuilder reportBuilder = Report.builder().primaryColumn(primaryColumn).properties(properties);
if (type != null) {
reportBuilder.selectedTypes(Report.selectTypes(type));
}
return reportBuilder.build();
} | [
"private",
"Report",
"getReport",
"(",
"ReportType",
"reportType",
")",
"{",
"String",
"type",
"=",
"null",
";",
"String",
"primaryColumn",
"=",
"null",
";",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"if",
"(",
"reportType",
"!=",
"null",
")",
"{",
"type",
"=",
"reportType",
".",
"getType",
"(",
")",
";",
"primaryColumn",
"=",
"reportType",
".",
"getPrimaryColumn",
"(",
")",
";",
"for",
"(",
"PropertyType",
"propertyType",
":",
"reportType",
".",
"getProperty",
"(",
")",
")",
"{",
"properties",
".",
"setProperty",
"(",
"propertyType",
".",
"getName",
"(",
")",
",",
"propertyType",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"Report",
".",
"ReportBuilder",
"reportBuilder",
"=",
"Report",
".",
"builder",
"(",
")",
".",
"primaryColumn",
"(",
"primaryColumn",
")",
".",
"properties",
"(",
"properties",
")",
";",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"reportBuilder",
".",
"selectedTypes",
"(",
"Report",
".",
"selectTypes",
"(",
"type",
")",
")",
";",
"}",
"return",
"reportBuilder",
".",
"build",
"(",
")",
";",
"}"
] | Read the report definition.
@param reportType
The report type.
@return The report definition. | [
"Read",
"the",
"report",
"definition",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/XmlRuleParserPlugin.java#L137-L153 |
141,789 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/XmlRuleParserPlugin.java | XmlRuleParserPlugin.getVerification | private Verification getVerification(VerificationType verificationType) throws RuleException {
if (verificationType != null) {
RowCountVerificationType rowCountVerificationType = verificationType.getRowCount();
AggregationVerificationType aggregationVerificationType = verificationType.getAggregation();
if (aggregationVerificationType != null) {
return AggregationVerification.builder().column(aggregationVerificationType.getColumn()).min(aggregationVerificationType.getMin())
.max(aggregationVerificationType.getMax()).build();
} else if (rowCountVerificationType != null) {
return RowCountVerification.builder().min(rowCountVerificationType.getMin()).max(rowCountVerificationType.getMax()).build();
} else {
throw new RuleException("Unsupported verification " + verificationType);
}
}
return null;
} | java | private Verification getVerification(VerificationType verificationType) throws RuleException {
if (verificationType != null) {
RowCountVerificationType rowCountVerificationType = verificationType.getRowCount();
AggregationVerificationType aggregationVerificationType = verificationType.getAggregation();
if (aggregationVerificationType != null) {
return AggregationVerification.builder().column(aggregationVerificationType.getColumn()).min(aggregationVerificationType.getMin())
.max(aggregationVerificationType.getMax()).build();
} else if (rowCountVerificationType != null) {
return RowCountVerification.builder().min(rowCountVerificationType.getMin()).max(rowCountVerificationType.getMax()).build();
} else {
throw new RuleException("Unsupported verification " + verificationType);
}
}
return null;
} | [
"private",
"Verification",
"getVerification",
"(",
"VerificationType",
"verificationType",
")",
"throws",
"RuleException",
"{",
"if",
"(",
"verificationType",
"!=",
"null",
")",
"{",
"RowCountVerificationType",
"rowCountVerificationType",
"=",
"verificationType",
".",
"getRowCount",
"(",
")",
";",
"AggregationVerificationType",
"aggregationVerificationType",
"=",
"verificationType",
".",
"getAggregation",
"(",
")",
";",
"if",
"(",
"aggregationVerificationType",
"!=",
"null",
")",
"{",
"return",
"AggregationVerification",
".",
"builder",
"(",
")",
".",
"column",
"(",
"aggregationVerificationType",
".",
"getColumn",
"(",
")",
")",
".",
"min",
"(",
"aggregationVerificationType",
".",
"getMin",
"(",
")",
")",
".",
"max",
"(",
"aggregationVerificationType",
".",
"getMax",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"}",
"else",
"if",
"(",
"rowCountVerificationType",
"!=",
"null",
")",
"{",
"return",
"RowCountVerification",
".",
"builder",
"(",
")",
".",
"min",
"(",
"rowCountVerificationType",
".",
"getMin",
"(",
")",
")",
".",
"max",
"(",
"rowCountVerificationType",
".",
"getMax",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuleException",
"(",
"\"Unsupported verification \"",
"+",
"verificationType",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Read the verification definition. | [
"Read",
"the",
"verification",
"definition",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/XmlRuleParserPlugin.java#L190-L204 |
141,790 | buschmais/jqa-core-framework | rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/XmlRuleParserPlugin.java | XmlRuleParserPlugin.getSeverity | private Severity getSeverity(SeverityEnumType severityType, Severity defaultSeverity) throws RuleException {
return severityType == null ? defaultSeverity : Severity.fromValue(severityType.value());
} | java | private Severity getSeverity(SeverityEnumType severityType, Severity defaultSeverity) throws RuleException {
return severityType == null ? defaultSeverity : Severity.fromValue(severityType.value());
} | [
"private",
"Severity",
"getSeverity",
"(",
"SeverityEnumType",
"severityType",
",",
"Severity",
"defaultSeverity",
")",
"throws",
"RuleException",
"{",
"return",
"severityType",
"==",
"null",
"?",
"defaultSeverity",
":",
"Severity",
".",
"fromValue",
"(",
"severityType",
".",
"value",
"(",
")",
")",
";",
"}"
] | Get the severity.
@param severityType
The severity type.
@param defaultSeverity
The default severity.
@return The severity. | [
"Get",
"the",
"severity",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/rule/src/main/java/com/buschmais/jqassistant/core/rule/impl/reader/XmlRuleParserPlugin.java#L274-L276 |
141,791 | buschmais/jqa-core-framework | scanner/src/main/java/com/buschmais/jqassistant/core/scanner/api/ScopeHelper.java | ScopeHelper.printScopes | public void printScopes(Map<String, Scope> scopes) {
logger.info("Scopes [" + scopes.size() + "]");
for (String scopeName : scopes.keySet()) {
logger.info("\t" + scopeName);
}
} | java | public void printScopes(Map<String, Scope> scopes) {
logger.info("Scopes [" + scopes.size() + "]");
for (String scopeName : scopes.keySet()) {
logger.info("\t" + scopeName);
}
} | [
"public",
"void",
"printScopes",
"(",
"Map",
"<",
"String",
",",
"Scope",
">",
"scopes",
")",
"{",
"logger",
".",
"info",
"(",
"\"Scopes [\"",
"+",
"scopes",
".",
"size",
"(",
")",
"+",
"\"]\"",
")",
";",
"for",
"(",
"String",
"scopeName",
":",
"scopes",
".",
"keySet",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"\"\\t\"",
"+",
"scopeName",
")",
";",
"}",
"}"
] | Print a list of available scopes to the console.
@param scopes
The available scopes. | [
"Print",
"a",
"list",
"of",
"available",
"scopes",
"to",
"the",
"console",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/scanner/src/main/java/com/buschmais/jqassistant/core/scanner/api/ScopeHelper.java#L30-L35 |
141,792 | MTDdk/jawn | jawn-core-new/src/main/java/net/javapla/jawn/core/internal/server/netty/NettyServer.java | NettyServer.shutdownGracefully | private void shutdownGracefully(final Iterator<EventExecutorGroup> iterator) {
if (iterator.hasNext()) {
EventExecutorGroup group = iterator.next();
if (!group.isShuttingDown()) {
group.shutdownGracefully().addListener(future -> {
if (!future.isSuccess()) {
//log.debug("shutdown of {} resulted in exception", group, future.cause());
}
shutdownGracefully(iterator);
});
}
}
} | java | private void shutdownGracefully(final Iterator<EventExecutorGroup> iterator) {
if (iterator.hasNext()) {
EventExecutorGroup group = iterator.next();
if (!group.isShuttingDown()) {
group.shutdownGracefully().addListener(future -> {
if (!future.isSuccess()) {
//log.debug("shutdown of {} resulted in exception", group, future.cause());
}
shutdownGracefully(iterator);
});
}
}
} | [
"private",
"void",
"shutdownGracefully",
"(",
"final",
"Iterator",
"<",
"EventExecutorGroup",
">",
"iterator",
")",
"{",
"if",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"EventExecutorGroup",
"group",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"group",
".",
"isShuttingDown",
"(",
")",
")",
"{",
"group",
".",
"shutdownGracefully",
"(",
")",
".",
"addListener",
"(",
"future",
"->",
"{",
"if",
"(",
"!",
"future",
".",
"isSuccess",
"(",
")",
")",
"{",
"//log.debug(\"shutdown of {} resulted in exception\", group, future.cause());",
"}",
"shutdownGracefully",
"(",
"iterator",
")",
";",
"}",
")",
";",
"}",
"}",
"}"
] | Shutdown executor in order.
@param iterator Executors to shutdown. | [
"Shutdown",
"executor",
"in",
"order",
"."
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core-new/src/main/java/net/javapla/jawn/core/internal/server/netty/NettyServer.java#L128-L140 |
141,793 | MTDdk/jawn | jawn-core-new/src/main/java/net/javapla/jawn/core/util/DataCodec.java | DataCodec.decode | public static void decode(final Map<String, String> map, final String data) {
//String[] keyValues = StringUtil.split(data, '&');
StringUtil.split(data, '&', keyValue -> {
final int indexOfSeperator = keyValue.indexOf('=');
if (indexOfSeperator > -1) {
if (indexOfSeperator == keyValue.length() - 1) { // The '=' is at the end of the string - this counts as an unsigned value
map.put(URLCodec.decode(keyValue.substring(0, indexOfSeperator), StandardCharsets.UTF_8), "");
} else {
final String first = keyValue.substring(0, indexOfSeperator),
second = keyValue.substring(indexOfSeperator + 1);
map.put(URLCodec.decode(first, StandardCharsets.UTF_8), URLCodec.decode(second, StandardCharsets.UTF_8));
}
}
});
} | java | public static void decode(final Map<String, String> map, final String data) {
//String[] keyValues = StringUtil.split(data, '&');
StringUtil.split(data, '&', keyValue -> {
final int indexOfSeperator = keyValue.indexOf('=');
if (indexOfSeperator > -1) {
if (indexOfSeperator == keyValue.length() - 1) { // The '=' is at the end of the string - this counts as an unsigned value
map.put(URLCodec.decode(keyValue.substring(0, indexOfSeperator), StandardCharsets.UTF_8), "");
} else {
final String first = keyValue.substring(0, indexOfSeperator),
second = keyValue.substring(indexOfSeperator + 1);
map.put(URLCodec.decode(first, StandardCharsets.UTF_8), URLCodec.decode(second, StandardCharsets.UTF_8));
}
}
});
} | [
"public",
"static",
"void",
"decode",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"map",
",",
"final",
"String",
"data",
")",
"{",
"//String[] keyValues = StringUtil.split(data, '&');",
"StringUtil",
".",
"split",
"(",
"data",
",",
"'",
"'",
",",
"keyValue",
"->",
"{",
"final",
"int",
"indexOfSeperator",
"=",
"keyValue",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"indexOfSeperator",
">",
"-",
"1",
")",
"{",
"if",
"(",
"indexOfSeperator",
"==",
"keyValue",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"// The '=' is at the end of the string - this counts as an unsigned value",
"map",
".",
"put",
"(",
"URLCodec",
".",
"decode",
"(",
"keyValue",
".",
"substring",
"(",
"0",
",",
"indexOfSeperator",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
",",
"\"\"",
")",
";",
"}",
"else",
"{",
"final",
"String",
"first",
"=",
"keyValue",
".",
"substring",
"(",
"0",
",",
"indexOfSeperator",
")",
",",
"second",
"=",
"keyValue",
".",
"substring",
"(",
"indexOfSeperator",
"+",
"1",
")",
";",
"map",
".",
"put",
"(",
"URLCodec",
".",
"decode",
"(",
"first",
",",
"StandardCharsets",
".",
"UTF_8",
")",
",",
"URLCodec",
".",
"decode",
"(",
"second",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | A faster decode than the original from Play Framework,
but still equivalent in output
@param map the map to decode data into.
@param data the data to decode. | [
"A",
"faster",
"decode",
"than",
"the",
"original",
"from",
"Play",
"Framework",
"but",
"still",
"equivalent",
"in",
"output"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core-new/src/main/java/net/javapla/jawn/core/util/DataCodec.java#L40-L56 |
141,794 | buschmais/jqa-core-framework | shared/src/main/java/com/buschmais/jqassistant/core/shared/option/OptionHelper.java | OptionHelper.selectValue | public static <T> T selectValue(T defaultValue, T... overrides) {
for (T override : overrides) {
if (override != null) {
return override;
}
}
return defaultValue;
} | java | public static <T> T selectValue(T defaultValue, T... overrides) {
for (T override : overrides) {
if (override != null) {
return override;
}
}
return defaultValue;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"selectValue",
"(",
"T",
"defaultValue",
",",
"T",
"...",
"overrides",
")",
"{",
"for",
"(",
"T",
"override",
":",
"overrides",
")",
"{",
"if",
"(",
"override",
"!=",
"null",
")",
"{",
"return",
"override",
";",
"}",
"}",
"return",
"defaultValue",
";",
"}"
] | Determine a value from given options.
@param defaultValue
The default (i.e. fallback) value.
@param overrides
The option that override the default value, the first non-null value will be accepted.
@param <T>
The value type.
@return The value. | [
"Determine",
"a",
"value",
"from",
"given",
"options",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/shared/src/main/java/com/buschmais/jqassistant/core/shared/option/OptionHelper.java#L25-L32 |
141,795 | buschmais/jqa-core-framework | shared/src/main/java/com/buschmais/jqassistant/core/shared/option/OptionHelper.java | OptionHelper.verifyDeprecatedOption | public static <T> void verifyDeprecatedOption(String deprecatedOption, T value, String option) {
if (value != null) {
LOGGER.warn("The option '" + deprecatedOption + "' is deprecated, use '" + option + "' instead.");
}
} | java | public static <T> void verifyDeprecatedOption(String deprecatedOption, T value, String option) {
if (value != null) {
LOGGER.warn("The option '" + deprecatedOption + "' is deprecated, use '" + option + "' instead.");
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"verifyDeprecatedOption",
"(",
"String",
"deprecatedOption",
",",
"T",
"value",
",",
"String",
"option",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"The option '\"",
"+",
"deprecatedOption",
"+",
"\"' is deprecated, use '\"",
"+",
"option",
"+",
"\"' instead.\"",
")",
";",
"}",
"}"
] | Verify if a deprecated option has been used and emit a warning.
@param deprecatedOption
The name of the deprecated option.
@param value
The provided value.
@param option
The option to use.
@param <T>
The value type. | [
"Verify",
"if",
"a",
"deprecated",
"option",
"has",
"been",
"used",
"and",
"emit",
"a",
"warning",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/shared/src/main/java/com/buschmais/jqassistant/core/shared/option/OptionHelper.java#L46-L50 |
141,796 | buschmais/jqa-core-framework | scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerContextImpl.java | ScannerContextImpl.getValues | <T> Deque<T> getValues(Class<T> key) {
Deque<T> values = (Deque<T>) contextValuesPerKey.get(key);
if (values == null) {
values = new LinkedList<>();
contextValuesPerKey.put(key, values);
}
return values;
} | java | <T> Deque<T> getValues(Class<T> key) {
Deque<T> values = (Deque<T>) contextValuesPerKey.get(key);
if (values == null) {
values = new LinkedList<>();
contextValuesPerKey.put(key, values);
}
return values;
} | [
"<",
"T",
">",
"Deque",
"<",
"T",
">",
"getValues",
"(",
"Class",
"<",
"T",
">",
"key",
")",
"{",
"Deque",
"<",
"T",
">",
"values",
"=",
"(",
"Deque",
"<",
"T",
">",
")",
"contextValuesPerKey",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"values",
"==",
"null",
")",
"{",
"values",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"contextValuesPerKey",
".",
"put",
"(",
"key",
",",
"values",
")",
";",
"}",
"return",
"values",
";",
"}"
] | Determine the stack for the given key.
@param key
The key.
@param <T>
The key key.
@return The stack. | [
"Determine",
"the",
"stack",
"for",
"the",
"given",
"key",
"."
] | 0e63ff509cfe52f9063539a23d5f9f183b2ea4a5 | https://github.com/buschmais/jqa-core-framework/blob/0e63ff509cfe52f9063539a23d5f9f183b2ea4a5/scanner/src/main/java/com/buschmais/jqassistant/core/scanner/impl/ScannerContextImpl.java#L77-L84 |
141,797 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/FileName.java | FileName.apply | public void apply(UnaryOperator<String> function) {
this.filename = function.apply(this.filename);
if (path != null && !path.isEmpty())
this.path = function.apply(this.path);
} | java | public void apply(UnaryOperator<String> function) {
this.filename = function.apply(this.filename);
if (path != null && !path.isEmpty())
this.path = function.apply(this.path);
} | [
"public",
"void",
"apply",
"(",
"UnaryOperator",
"<",
"String",
">",
"function",
")",
"{",
"this",
".",
"filename",
"=",
"function",
".",
"apply",
"(",
"this",
".",
"filename",
")",
";",
"if",
"(",
"path",
"!=",
"null",
"&&",
"!",
"path",
".",
"isEmpty",
"(",
")",
")",
"this",
".",
"path",
"=",
"function",
".",
"apply",
"(",
"this",
".",
"path",
")",
";",
"}"
] | Apply the function to all string
@param function | [
"Apply",
"the",
"function",
"to",
"all",
"string"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/FileName.java#L129-L133 |
141,798 | MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/FileName.java | FileName.increment | public String increment() {
// filename[count].jpg
int count = 0;
String newFilename,
altered = filename();
if (altered.charAt(altered.length()-1) == RIGHT) { //(last char == 'v') we assume that a suffix already has been applied
int rightBracket = altered.length()-1,
leftBracket = altered.lastIndexOf(LEFT);
// leftBracket = rightBracket-2;// '-2' because at least one char ought to be between LEFT & RIGHT
// crawling backwards
// while (leftBracket > 0 && altered.charAt(leftBracket) != LEFT) leftBracket--;
try {
count = Integer.parseInt(altered.substring(leftBracket+1, rightBracket));
} catch (NumberFormatException | IndexOutOfBoundsException ignore) {
//if it fails, we can assume that it was not a correct suffix, so we add one now
newFilename = altered + LEFT;
}
newFilename = altered.substring(0, leftBracket+1);
} else {
newFilename = altered + LEFT;
}
newFilename += (count+1);
newFilename += RIGHT; // to prevent the char being added as an int
updateName(newFilename);
return newFilename + EXTENSION_SEPERATOR + ext;
} | java | public String increment() {
// filename[count].jpg
int count = 0;
String newFilename,
altered = filename();
if (altered.charAt(altered.length()-1) == RIGHT) { //(last char == 'v') we assume that a suffix already has been applied
int rightBracket = altered.length()-1,
leftBracket = altered.lastIndexOf(LEFT);
// leftBracket = rightBracket-2;// '-2' because at least one char ought to be between LEFT & RIGHT
// crawling backwards
// while (leftBracket > 0 && altered.charAt(leftBracket) != LEFT) leftBracket--;
try {
count = Integer.parseInt(altered.substring(leftBracket+1, rightBracket));
} catch (NumberFormatException | IndexOutOfBoundsException ignore) {
//if it fails, we can assume that it was not a correct suffix, so we add one now
newFilename = altered + LEFT;
}
newFilename = altered.substring(0, leftBracket+1);
} else {
newFilename = altered + LEFT;
}
newFilename += (count+1);
newFilename += RIGHT; // to prevent the char being added as an int
updateName(newFilename);
return newFilename + EXTENSION_SEPERATOR + ext;
} | [
"public",
"String",
"increment",
"(",
")",
"{",
"// filename[count].jpg",
"int",
"count",
"=",
"0",
";",
"String",
"newFilename",
",",
"altered",
"=",
"filename",
"(",
")",
";",
"if",
"(",
"altered",
".",
"charAt",
"(",
"altered",
".",
"length",
"(",
")",
"-",
"1",
")",
"==",
"RIGHT",
")",
"{",
"//(last char == 'v') we assume that a suffix already has been applied",
"int",
"rightBracket",
"=",
"altered",
".",
"length",
"(",
")",
"-",
"1",
",",
"leftBracket",
"=",
"altered",
".",
"lastIndexOf",
"(",
"LEFT",
")",
";",
"// leftBracket = rightBracket-2;// '-2' because at least one char ought to be between LEFT & RIGHT",
"// crawling backwards",
"// while (leftBracket > 0 && altered.charAt(leftBracket) != LEFT) leftBracket--;",
"try",
"{",
"count",
"=",
"Integer",
".",
"parseInt",
"(",
"altered",
".",
"substring",
"(",
"leftBracket",
"+",
"1",
",",
"rightBracket",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"|",
"IndexOutOfBoundsException",
"ignore",
")",
"{",
"//if it fails, we can assume that it was not a correct suffix, so we add one now",
"newFilename",
"=",
"altered",
"+",
"LEFT",
";",
"}",
"newFilename",
"=",
"altered",
".",
"substring",
"(",
"0",
",",
"leftBracket",
"+",
"1",
")",
";",
"}",
"else",
"{",
"newFilename",
"=",
"altered",
"+",
"LEFT",
";",
"}",
"newFilename",
"+=",
"(",
"count",
"+",
"1",
")",
";",
"newFilename",
"+=",
"RIGHT",
";",
"// to prevent the char being added as an int",
"updateName",
"(",
"newFilename",
")",
";",
"return",
"newFilename",
"+",
"EXTENSION_SEPERATOR",
"+",
"ext",
";",
"}"
] | filename.jpg -> filename_1v.jpg -> filename_2v.jpg
I wanted to use filename[1].jpg, but ResourceHandler seems to not understand that format
@return The new filename | [
"filename",
".",
"jpg",
"-",
">",
";",
"filename_1v",
".",
"jpg",
"-",
">",
";",
"filename_2v",
".",
"jpg"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/FileName.java#L155-L184 |
141,799 | MTDdk/jawn | jawn-server-undertow/src/main/java/net/javapla/jawn/server/undertow/UndertowRequest.java | UndertowRequest.memoizeLock | public static <T> Supplier<T> memoizeLock(Supplier<T> delegate) {
AtomicReference<T> value = new AtomicReference<>();
return () -> {
// A 2-field variant of Double Checked Locking.
T val = value.get();
if (val == null) {
synchronized(value) {
val = value.get();
if (val == null) {
val = Objects.requireNonNull(delegate.get());
value.set(val);
}
}
}
return val;
};
} | java | public static <T> Supplier<T> memoizeLock(Supplier<T> delegate) {
AtomicReference<T> value = new AtomicReference<>();
return () -> {
// A 2-field variant of Double Checked Locking.
T val = value.get();
if (val == null) {
synchronized(value) {
val = value.get();
if (val == null) {
val = Objects.requireNonNull(delegate.get());
value.set(val);
}
}
}
return val;
};
} | [
"public",
"static",
"<",
"T",
">",
"Supplier",
"<",
"T",
">",
"memoizeLock",
"(",
"Supplier",
"<",
"T",
">",
"delegate",
")",
"{",
"AtomicReference",
"<",
"T",
">",
"value",
"=",
"new",
"AtomicReference",
"<>",
"(",
")",
";",
"return",
"(",
")",
"->",
"{",
"// A 2-field variant of Double Checked Locking.",
"T",
"val",
"=",
"value",
".",
"get",
"(",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"synchronized",
"(",
"value",
")",
"{",
"val",
"=",
"value",
".",
"get",
"(",
")",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"val",
"=",
"Objects",
".",
"requireNonNull",
"(",
"delegate",
".",
"get",
"(",
")",
")",
";",
"value",
".",
"set",
"(",
"val",
")",
";",
"}",
"}",
"}",
"return",
"val",
";",
"}",
";",
"}"
] | Stolen from Googles Guava Suppliers.java
@param delegate
@return | [
"Stolen",
"from",
"Googles",
"Guava",
"Suppliers",
".",
"java"
] | 4ec2d09b97d413efdead7487e6075e5bfd13b925 | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-server-undertow/src/main/java/net/javapla/jawn/server/undertow/UndertowRequest.java#L256-L272 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.