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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
145,200
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.expiresAfterWrite
|
public <T extends CacheSpec<K, V>> T expiresAfterWrite(String duration) {
this.expiresAfterWrite = convertStringToTime(duration);
return Cast.as(this);
}
|
java
|
public <T extends CacheSpec<K, V>> T expiresAfterWrite(String duration) {
this.expiresAfterWrite = convertStringToTime(duration);
return Cast.as(this);
}
|
[
"public",
"<",
"T",
"extends",
"CacheSpec",
"<",
"K",
",",
"V",
">",
">",
"T",
"expiresAfterWrite",
"(",
"String",
"duration",
")",
"{",
"this",
".",
"expiresAfterWrite",
"=",
"convertStringToTime",
"(",
"duration",
")",
";",
"return",
"Cast",
".",
"as",
"(",
"this",
")",
";",
"}"
] |
The time in milliseconds after write that an item is removed
@param <T> the type parameter
@param duration duration is a string in the form d+[dhms] where d is days, h is hours, m is minutes, and s is
seconds
@return This cache spec
|
[
"The",
"time",
"in",
"milliseconds",
"after",
"write",
"that",
"an",
"item",
"is",
"removed"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L301-L304
|
145,201
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.name
|
public <T extends CacheSpec<K, V>> T name(String name) {
this.name = name;
return Cast.as(this);
}
|
java
|
public <T extends CacheSpec<K, V>> T name(String name) {
this.name = name;
return Cast.as(this);
}
|
[
"public",
"<",
"T",
"extends",
"CacheSpec",
"<",
"K",
",",
"V",
">",
">",
"T",
"name",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"return",
"Cast",
".",
"as",
"(",
"this",
")",
";",
"}"
] |
Sets the name
@param <T> the type parameter
@param name The name
@return This cache spec
|
[
"Sets",
"the",
"name"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L326-L329
|
145,202
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.removalListener
|
public <T extends CacheSpec<K, V>> T removalListener(RemovalListener<K, V> listener) {
this.removalListener = listener;
return Cast.as(this);
}
|
java
|
public <T extends CacheSpec<K, V>> T removalListener(RemovalListener<K, V> listener) {
this.removalListener = listener;
return Cast.as(this);
}
|
[
"public",
"<",
"T",
"extends",
"CacheSpec",
"<",
"K",
",",
"V",
">",
">",
"T",
"removalListener",
"(",
"RemovalListener",
"<",
"K",
",",
"V",
">",
"listener",
")",
"{",
"this",
".",
"removalListener",
"=",
"listener",
";",
"return",
"Cast",
".",
"as",
"(",
"this",
")",
";",
"}"
] |
Sets the removal listener
@param <T> the type parameter
@param listener The removal listener
@return This cache spec
|
[
"Sets",
"the",
"removal",
"listener"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L338-L341
|
145,203
|
devcon5io/common
|
classutils/src/main/java/io/devcon5/classutils/CallStack.java
|
CallStack.loadClass
|
private static Class<?> loadClass(final String className) throws ClassNotFoundException {
ClassLoader ctxCL = Thread.currentThread().getContextClassLoader();
if (ctxCL == null) {
return Class.forName(className);
}
return ctxCL.loadClass(className);
}
|
java
|
private static Class<?> loadClass(final String className) throws ClassNotFoundException {
ClassLoader ctxCL = Thread.currentThread().getContextClassLoader();
if (ctxCL == null) {
return Class.forName(className);
}
return ctxCL.loadClass(className);
}
|
[
"private",
"static",
"Class",
"<",
"?",
">",
"loadClass",
"(",
"final",
"String",
"className",
")",
"throws",
"ClassNotFoundException",
"{",
"ClassLoader",
"ctxCL",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"if",
"(",
"ctxCL",
"==",
"null",
")",
"{",
"return",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"}",
"return",
"ctxCL",
".",
"loadClass",
"(",
"className",
")",
";",
"}"
] |
Loads the class specified by name using the Thread's context class loader - if defined - otherwise the default
classloader.
@param className
the name of the class to load
@return the loaded class
@throws ClassNotFoundException
if the the class could not be loaded
|
[
"Loads",
"the",
"class",
"specified",
"by",
"name",
"using",
"the",
"Thread",
"s",
"context",
"class",
"loader",
"-",
"if",
"defined",
"-",
"otherwise",
"the",
"default",
"classloader",
"."
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/classutils/src/main/java/io/devcon5/classutils/CallStack.java#L129-L136
|
145,204
|
josueeduardo/snappy
|
plugin-parent/snappy-loader/src/main/java/io/joshworks/snappy/loader/jar/JarFile.java
|
JarFile.getFilteredJarFile
|
public synchronized JarFile getFilteredJarFile(JarEntryFilter... filters)
throws IOException {
return new JarFile(this.rootFile, this.pathFromRoot, this.data, this.entries,
filters);
}
|
java
|
public synchronized JarFile getFilteredJarFile(JarEntryFilter... filters)
throws IOException {
return new JarFile(this.rootFile, this.pathFromRoot, this.data, this.entries,
filters);
}
|
[
"public",
"synchronized",
"JarFile",
"getFilteredJarFile",
"(",
"JarEntryFilter",
"...",
"filters",
")",
"throws",
"IOException",
"{",
"return",
"new",
"JarFile",
"(",
"this",
".",
"rootFile",
",",
"this",
".",
"pathFromRoot",
",",
"this",
".",
"data",
",",
"this",
".",
"entries",
",",
"filters",
")",
";",
"}"
] |
Return a new jar based on the filtered contents of this file.
@param filters the set of jar entry filters to be applied
@return a filtered {@link JarFile}
@throws IOException if the jar file cannot be read
|
[
"Return",
"a",
"new",
"jar",
"based",
"on",
"the",
"filtered",
"contents",
"of",
"this",
"file",
"."
] |
d95a9e811eda3c24a5e53086369208819884fa49
|
https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/plugin-parent/snappy-loader/src/main/java/io/joshworks/snappy/loader/jar/JarFile.java#L421-L425
|
145,205
|
momokan/LWJGFont
|
src/main/java/net/chocolapod/lwjgfont/cli/Main.java
|
Main.main
|
public static void main(String[] args) throws IOException, FontFormatException, URISyntaxException {
CliArgumentParser parser = new CliArgumentParser(args);
LwjgFontFactory lwjgFont = new LwjgFontFactory(parser.get(_p));
if (parser.hasArgument(_x)) {
// γγ£γ©γ―γΏγΌγγ‘γ€γ«γε±ιγγ
lwjgFont.extractCharacterFiles();
} else if (parser.hasArgument(_v)) {
// γγΌγΈγ§γ³γ葨瀺γγ
lwjgFont.printVersion();
} else if (parser.hasArgument(_l)) {
// γ·γΉγγ γθͺθγγ¦γγγγ©γ³γεγδΈθ¦§θ‘¨η€Ίγγ
SystemFont.listLogicalFont();
} else if (parser.hasFontSettings()) {
// γγ©γ³γγγγγδ½ζγγ
for (FontSetting fontSetting: parser.listFontSettings()) {
lwjgFont.create(fontSetting);
}
lwjgFont.makePackage();
lwjgFont.writeProcessLog();
}
}
|
java
|
public static void main(String[] args) throws IOException, FontFormatException, URISyntaxException {
CliArgumentParser parser = new CliArgumentParser(args);
LwjgFontFactory lwjgFont = new LwjgFontFactory(parser.get(_p));
if (parser.hasArgument(_x)) {
// γγ£γ©γ―γΏγΌγγ‘γ€γ«γε±ιγγ
lwjgFont.extractCharacterFiles();
} else if (parser.hasArgument(_v)) {
// γγΌγΈγ§γ³γ葨瀺γγ
lwjgFont.printVersion();
} else if (parser.hasArgument(_l)) {
// γ·γΉγγ γθͺθγγ¦γγγγ©γ³γεγδΈθ¦§θ‘¨η€Ίγγ
SystemFont.listLogicalFont();
} else if (parser.hasFontSettings()) {
// γγ©γ³γγγγγδ½ζγγ
for (FontSetting fontSetting: parser.listFontSettings()) {
lwjgFont.create(fontSetting);
}
lwjgFont.makePackage();
lwjgFont.writeProcessLog();
}
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"IOException",
",",
"FontFormatException",
",",
"URISyntaxException",
"{",
"CliArgumentParser",
"parser",
"=",
"new",
"CliArgumentParser",
"(",
"args",
")",
";",
"LwjgFontFactory",
"lwjgFont",
"=",
"new",
"LwjgFontFactory",
"(",
"parser",
".",
"get",
"(",
"_p",
")",
")",
";",
"if",
"(",
"parser",
".",
"hasArgument",
"(",
"_x",
")",
")",
"{",
"//\tγγ£γ©γ―γΏγΌγγ‘γ€γ«γε±ιγγ",
"lwjgFont",
".",
"extractCharacterFiles",
"(",
")",
";",
"}",
"else",
"if",
"(",
"parser",
".",
"hasArgument",
"(",
"_v",
")",
")",
"{",
"//\tγγΌγΈγ§γ³γ葨瀺γγ",
"lwjgFont",
".",
"printVersion",
"(",
")",
";",
"}",
"else",
"if",
"(",
"parser",
".",
"hasArgument",
"(",
"_l",
")",
")",
"{",
"//\tγ·γΉγγ γθͺθγγ¦γγγγ©γ³γεγδΈθ¦§θ‘¨η€Ίγγ",
"SystemFont",
".",
"listLogicalFont",
"(",
")",
";",
"}",
"else",
"if",
"(",
"parser",
".",
"hasFontSettings",
"(",
")",
")",
"{",
"//\tγγ©γ³γγγγγδ½ζγγ",
"for",
"(",
"FontSetting",
"fontSetting",
":",
"parser",
".",
"listFontSettings",
"(",
")",
")",
"{",
"lwjgFont",
".",
"create",
"(",
"fontSetting",
")",
";",
"}",
"lwjgFont",
".",
"makePackage",
"(",
")",
";",
"lwjgFont",
".",
"writeProcessLog",
"(",
")",
";",
"}",
"}"
] |
Main method of LWJGFont in command line mode.
|
[
"Main",
"method",
"of",
"LWJGFont",
"in",
"command",
"line",
"mode",
"."
] |
f2d6138b73d84a7e2c1271bae25b4c76488d9ec2
|
https://github.com/momokan/LWJGFont/blob/f2d6138b73d84a7e2c1271bae25b4c76488d9ec2/src/main/java/net/chocolapod/lwjgfont/cli/Main.java#L49-L70
|
145,206
|
triceo/splitlog
|
splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/ExceptionParser.java
|
ExceptionParser.removePrefix
|
private static Queue<String> removePrefix(final List<String> input) {
if (input.size() < 2) {
return new LinkedList<>(input);
}
String resultingPrefix = "";
final String previousGreatestCommonPrefix = input.get(0).trim();
String greatestCommonPrefix = "";
for (int i = 1; i < input.size(); i++) {
final String previousLine = input.get(i - 1).trim();
final String currentLine = input.get(i).trim();
greatestCommonPrefix = ExceptionParser.greatestCommonPrefix(previousLine, currentLine);
resultingPrefix = ExceptionParser.greatestCommonPrefix(previousGreatestCommonPrefix, greatestCommonPrefix);
if (resultingPrefix.length() == 0) {
break;
}
}
final int prefixLength = resultingPrefix.length();
final boolean hasPrefix = prefixLength > 0;
final Queue<String> result = new LinkedList<>();
for (final String line : input) {
final String line2 = line.trim();
if (hasPrefix) {
result.add(line2.substring(prefixLength));
} else {
result.add(line2);
}
}
return result;
}
|
java
|
private static Queue<String> removePrefix(final List<String> input) {
if (input.size() < 2) {
return new LinkedList<>(input);
}
String resultingPrefix = "";
final String previousGreatestCommonPrefix = input.get(0).trim();
String greatestCommonPrefix = "";
for (int i = 1; i < input.size(); i++) {
final String previousLine = input.get(i - 1).trim();
final String currentLine = input.get(i).trim();
greatestCommonPrefix = ExceptionParser.greatestCommonPrefix(previousLine, currentLine);
resultingPrefix = ExceptionParser.greatestCommonPrefix(previousGreatestCommonPrefix, greatestCommonPrefix);
if (resultingPrefix.length() == 0) {
break;
}
}
final int prefixLength = resultingPrefix.length();
final boolean hasPrefix = prefixLength > 0;
final Queue<String> result = new LinkedList<>();
for (final String line : input) {
final String line2 = line.trim();
if (hasPrefix) {
result.add(line2.substring(prefixLength));
} else {
result.add(line2);
}
}
return result;
}
|
[
"private",
"static",
"Queue",
"<",
"String",
">",
"removePrefix",
"(",
"final",
"List",
"<",
"String",
">",
"input",
")",
"{",
"if",
"(",
"input",
".",
"size",
"(",
")",
"<",
"2",
")",
"{",
"return",
"new",
"LinkedList",
"<>",
"(",
"input",
")",
";",
"}",
"String",
"resultingPrefix",
"=",
"\"\"",
";",
"final",
"String",
"previousGreatestCommonPrefix",
"=",
"input",
".",
"get",
"(",
"0",
")",
".",
"trim",
"(",
")",
";",
"String",
"greatestCommonPrefix",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"input",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"String",
"previousLine",
"=",
"input",
".",
"get",
"(",
"i",
"-",
"1",
")",
".",
"trim",
"(",
")",
";",
"final",
"String",
"currentLine",
"=",
"input",
".",
"get",
"(",
"i",
")",
".",
"trim",
"(",
")",
";",
"greatestCommonPrefix",
"=",
"ExceptionParser",
".",
"greatestCommonPrefix",
"(",
"previousLine",
",",
"currentLine",
")",
";",
"resultingPrefix",
"=",
"ExceptionParser",
".",
"greatestCommonPrefix",
"(",
"previousGreatestCommonPrefix",
",",
"greatestCommonPrefix",
")",
";",
"if",
"(",
"resultingPrefix",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"break",
";",
"}",
"}",
"final",
"int",
"prefixLength",
"=",
"resultingPrefix",
".",
"length",
"(",
")",
";",
"final",
"boolean",
"hasPrefix",
"=",
"prefixLength",
">",
"0",
";",
"final",
"Queue",
"<",
"String",
">",
"result",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"String",
"line",
":",
"input",
")",
"{",
"final",
"String",
"line2",
"=",
"line",
".",
"trim",
"(",
")",
";",
"if",
"(",
"hasPrefix",
")",
"{",
"result",
".",
"add",
"(",
"line2",
".",
"substring",
"(",
"prefixLength",
")",
")",
";",
"}",
"else",
"{",
"result",
".",
"add",
"(",
"line2",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Identifies and removes the common prefix - the longest beginning
substring that all the lines share.
@param input
Lines to be evaluated.
@return The same lines, without the prefix. And stripped of white space
at the ends.
|
[
"Identifies",
"and",
"removes",
"the",
"common",
"prefix",
"-",
"the",
"longest",
"beginning",
"substring",
"that",
"all",
"the",
"lines",
"share",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/ExceptionParser.java#L39-L67
|
145,207
|
triceo/splitlog
|
splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/ExceptionParser.java
|
ExceptionParser.parse
|
public synchronized Collection<ExceptionLine> parse(final Collection<String> input) throws ExceptionParseException {
this.parsedLines.clear();
final Queue<String> linesFromInput = ExceptionParser.removePrefix(new LinkedList<>(input));
LineType previousLineType = LineType.PRE_START;
String currentLine = null;
boolean isFirstLine = true;
while (!linesFromInput.isEmpty()) {
currentLine = linesFromInput.poll();
previousLineType = this.parseLine(previousLineType, currentLine);
if (isFirstLine) {
if (!previousLineType.isAcceptableAsFirstLine()) {
throw new ExceptionParseException(currentLine, "Invalid line type detected at the beginning: "
+ previousLineType);
}
isFirstLine = false;
}
}
if (!previousLineType.isAcceptableAsLastLine()) {
throw new ExceptionParseException(currentLine, "Invalid line type detected at the end: " + previousLineType);
}
return Collections.unmodifiableCollection(new LinkedList<>(this.parsedLines));
}
|
java
|
public synchronized Collection<ExceptionLine> parse(final Collection<String> input) throws ExceptionParseException {
this.parsedLines.clear();
final Queue<String> linesFromInput = ExceptionParser.removePrefix(new LinkedList<>(input));
LineType previousLineType = LineType.PRE_START;
String currentLine = null;
boolean isFirstLine = true;
while (!linesFromInput.isEmpty()) {
currentLine = linesFromInput.poll();
previousLineType = this.parseLine(previousLineType, currentLine);
if (isFirstLine) {
if (!previousLineType.isAcceptableAsFirstLine()) {
throw new ExceptionParseException(currentLine, "Invalid line type detected at the beginning: "
+ previousLineType);
}
isFirstLine = false;
}
}
if (!previousLineType.isAcceptableAsLastLine()) {
throw new ExceptionParseException(currentLine, "Invalid line type detected at the end: " + previousLineType);
}
return Collections.unmodifiableCollection(new LinkedList<>(this.parsedLines));
}
|
[
"public",
"synchronized",
"Collection",
"<",
"ExceptionLine",
">",
"parse",
"(",
"final",
"Collection",
"<",
"String",
">",
"input",
")",
"throws",
"ExceptionParseException",
"{",
"this",
".",
"parsedLines",
".",
"clear",
"(",
")",
";",
"final",
"Queue",
"<",
"String",
">",
"linesFromInput",
"=",
"ExceptionParser",
".",
"removePrefix",
"(",
"new",
"LinkedList",
"<>",
"(",
"input",
")",
")",
";",
"LineType",
"previousLineType",
"=",
"LineType",
".",
"PRE_START",
";",
"String",
"currentLine",
"=",
"null",
";",
"boolean",
"isFirstLine",
"=",
"true",
";",
"while",
"(",
"!",
"linesFromInput",
".",
"isEmpty",
"(",
")",
")",
"{",
"currentLine",
"=",
"linesFromInput",
".",
"poll",
"(",
")",
";",
"previousLineType",
"=",
"this",
".",
"parseLine",
"(",
"previousLineType",
",",
"currentLine",
")",
";",
"if",
"(",
"isFirstLine",
")",
"{",
"if",
"(",
"!",
"previousLineType",
".",
"isAcceptableAsFirstLine",
"(",
")",
")",
"{",
"throw",
"new",
"ExceptionParseException",
"(",
"currentLine",
",",
"\"Invalid line type detected at the beginning: \"",
"+",
"previousLineType",
")",
";",
"}",
"isFirstLine",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"previousLineType",
".",
"isAcceptableAsLastLine",
"(",
")",
")",
"{",
"throw",
"new",
"ExceptionParseException",
"(",
"currentLine",
",",
"\"Invalid line type detected at the end: \"",
"+",
"previousLineType",
")",
";",
"}",
"return",
"Collections",
".",
"unmodifiableCollection",
"(",
"new",
"LinkedList",
"<>",
"(",
"this",
".",
"parsedLines",
")",
")",
";",
"}"
] |
Browsers through a random log and returns first exception stack trace it
could find.
@param input Lines of the log. May begin and end with any garbage, may or
may not contain exception.
@return Raw exception data.
@throws ExceptionParseException If parsing of the log file failed.
|
[
"Browsers",
"through",
"a",
"random",
"log",
"and",
"returns",
"first",
"exception",
"stack",
"trace",
"it",
"could",
"find",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/ExceptionParser.java#L78-L99
|
145,208
|
triceo/splitlog
|
splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/ExceptionParser.java
|
ExceptionParser.parseLine
|
private LineType parseLine(final LineType previousLineType, final String line) throws ExceptionParseException {
switch (previousLineType) {
case PRE_START:
return this.parseLine(line, LineType.CAUSE, LineType.PRE_START);
case CAUSE:
case SUB_CAUSE:
case PRE_STACK_TRACE:
return this.parseLine(line, LineType.STACK_TRACE, LineType.PRE_STACK_TRACE);
case STACK_TRACE:
return this.parseLine(line, LineType.STACK_TRACE, LineType.STACK_TRACE_END, LineType.SUB_CAUSE);
case STACK_TRACE_END:
return this.parseLine(line, LineType.SUB_CAUSE, LineType.POST_END);
case POST_END:
return this.parseLine(line, LineType.POST_END);
default:
throw new IllegalArgumentException("Unsupported line type: " + previousLineType);
}
}
|
java
|
private LineType parseLine(final LineType previousLineType, final String line) throws ExceptionParseException {
switch (previousLineType) {
case PRE_START:
return this.parseLine(line, LineType.CAUSE, LineType.PRE_START);
case CAUSE:
case SUB_CAUSE:
case PRE_STACK_TRACE:
return this.parseLine(line, LineType.STACK_TRACE, LineType.PRE_STACK_TRACE);
case STACK_TRACE:
return this.parseLine(line, LineType.STACK_TRACE, LineType.STACK_TRACE_END, LineType.SUB_CAUSE);
case STACK_TRACE_END:
return this.parseLine(line, LineType.SUB_CAUSE, LineType.POST_END);
case POST_END:
return this.parseLine(line, LineType.POST_END);
default:
throw new IllegalArgumentException("Unsupported line type: " + previousLineType);
}
}
|
[
"private",
"LineType",
"parseLine",
"(",
"final",
"LineType",
"previousLineType",
",",
"final",
"String",
"line",
")",
"throws",
"ExceptionParseException",
"{",
"switch",
"(",
"previousLineType",
")",
"{",
"case",
"PRE_START",
":",
"return",
"this",
".",
"parseLine",
"(",
"line",
",",
"LineType",
".",
"CAUSE",
",",
"LineType",
".",
"PRE_START",
")",
";",
"case",
"CAUSE",
":",
"case",
"SUB_CAUSE",
":",
"case",
"PRE_STACK_TRACE",
":",
"return",
"this",
".",
"parseLine",
"(",
"line",
",",
"LineType",
".",
"STACK_TRACE",
",",
"LineType",
".",
"PRE_STACK_TRACE",
")",
";",
"case",
"STACK_TRACE",
":",
"return",
"this",
".",
"parseLine",
"(",
"line",
",",
"LineType",
".",
"STACK_TRACE",
",",
"LineType",
".",
"STACK_TRACE_END",
",",
"LineType",
".",
"SUB_CAUSE",
")",
";",
"case",
"STACK_TRACE_END",
":",
"return",
"this",
".",
"parseLine",
"(",
"line",
",",
"LineType",
".",
"SUB_CAUSE",
",",
"LineType",
".",
"POST_END",
")",
";",
"case",
"POST_END",
":",
"return",
"this",
".",
"parseLine",
"(",
"line",
",",
"LineType",
".",
"POST_END",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported line type: \"",
"+",
"previousLineType",
")",
";",
"}",
"}"
] |
Parse one line in the log.
@param previousLineType
Type of the previous line in the log. (The state the automaton
is currently in.)
@param line
Line in question.
@return Identified type of this line.
@throws ExceptionParseException
If parsing of the log file failed.
|
[
"Parse",
"one",
"line",
"in",
"the",
"log",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/ExceptionParser.java#L113-L130
|
145,209
|
triceo/splitlog
|
splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/ExceptionParser.java
|
ExceptionParser.parseLine
|
private LineType parseLine(final String line, final LineType... allowedLineTypes) throws ExceptionParseException {
for (final LineType possibleType : allowedLineTypes) {
if ((possibleType == LineType.POST_END) || (possibleType == LineType.PRE_START)) {
// this is garbage, all is accepted without parsing
return possibleType;
}
final ExceptionLine parsedLine = possibleType.parse(line);
if (parsedLine != null) {
if (possibleType == LineType.PRE_STACK_TRACE) {
// in case the cause is multi-line, update the cause
final ExceptionLine currentTop = this.parsedLines.remove(this.parsedLines.size() - 1);
if (!((currentTop instanceof CauseLine) && (parsedLine instanceof PlainTextLine))) {
throw new IllegalStateException("Garbage in the exception message.");
}
this.parsedLines.add(new CauseLine((CauseLine) currentTop, (PlainTextLine) parsedLine));
} else {
this.parsedLines.add(parsedLine);
}
return possibleType;
}
}
throw new ExceptionParseException(line, "Line not any of the expected types: "
+ Arrays.toString(allowedLineTypes));
}
|
java
|
private LineType parseLine(final String line, final LineType... allowedLineTypes) throws ExceptionParseException {
for (final LineType possibleType : allowedLineTypes) {
if ((possibleType == LineType.POST_END) || (possibleType == LineType.PRE_START)) {
// this is garbage, all is accepted without parsing
return possibleType;
}
final ExceptionLine parsedLine = possibleType.parse(line);
if (parsedLine != null) {
if (possibleType == LineType.PRE_STACK_TRACE) {
// in case the cause is multi-line, update the cause
final ExceptionLine currentTop = this.parsedLines.remove(this.parsedLines.size() - 1);
if (!((currentTop instanceof CauseLine) && (parsedLine instanceof PlainTextLine))) {
throw new IllegalStateException("Garbage in the exception message.");
}
this.parsedLines.add(new CauseLine((CauseLine) currentTop, (PlainTextLine) parsedLine));
} else {
this.parsedLines.add(parsedLine);
}
return possibleType;
}
}
throw new ExceptionParseException(line, "Line not any of the expected types: "
+ Arrays.toString(allowedLineTypes));
}
|
[
"private",
"LineType",
"parseLine",
"(",
"final",
"String",
"line",
",",
"final",
"LineType",
"...",
"allowedLineTypes",
")",
"throws",
"ExceptionParseException",
"{",
"for",
"(",
"final",
"LineType",
"possibleType",
":",
"allowedLineTypes",
")",
"{",
"if",
"(",
"(",
"possibleType",
"==",
"LineType",
".",
"POST_END",
")",
"||",
"(",
"possibleType",
"==",
"LineType",
".",
"PRE_START",
")",
")",
"{",
"// this is garbage, all is accepted without parsing",
"return",
"possibleType",
";",
"}",
"final",
"ExceptionLine",
"parsedLine",
"=",
"possibleType",
".",
"parse",
"(",
"line",
")",
";",
"if",
"(",
"parsedLine",
"!=",
"null",
")",
"{",
"if",
"(",
"possibleType",
"==",
"LineType",
".",
"PRE_STACK_TRACE",
")",
"{",
"// in case the cause is multi-line, update the cause",
"final",
"ExceptionLine",
"currentTop",
"=",
"this",
".",
"parsedLines",
".",
"remove",
"(",
"this",
".",
"parsedLines",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"if",
"(",
"!",
"(",
"(",
"currentTop",
"instanceof",
"CauseLine",
")",
"&&",
"(",
"parsedLine",
"instanceof",
"PlainTextLine",
")",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Garbage in the exception message.\"",
")",
";",
"}",
"this",
".",
"parsedLines",
".",
"add",
"(",
"new",
"CauseLine",
"(",
"(",
"CauseLine",
")",
"currentTop",
",",
"(",
"PlainTextLine",
")",
"parsedLine",
")",
")",
";",
"}",
"else",
"{",
"this",
".",
"parsedLines",
".",
"add",
"(",
"parsedLine",
")",
";",
"}",
"return",
"possibleType",
";",
"}",
"}",
"throw",
"new",
"ExceptionParseException",
"(",
"line",
",",
"\"Line not any of the expected types: \"",
"+",
"Arrays",
".",
"toString",
"(",
"allowedLineTypes",
")",
")",
";",
"}"
] |
Parse one line in the log, when knowing the types of lines acceptable at
this point in the log.
@param line
Line to parse.
@param allowedLineTypes
Possible line types, in the order of evaluation. (Possible
transitions.) If evaluation matches for a type, transition
will be made and any subsequent types will be ignored.
@return Identified type of this line.
@throws ExceptionParseException
If no allowed types match.
|
[
"Parse",
"one",
"line",
"in",
"the",
"log",
"when",
"knowing",
"the",
"types",
"of",
"lines",
"acceptable",
"at",
"this",
"point",
"in",
"the",
"log",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/splitters/exceptions/ExceptionParser.java#L146-L169
|
145,210
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVectorTable.java
|
ConcatVectorTable.valueEquals
|
public boolean valueEquals(ConcatVectorTable other, double tolerance) {
if (!Arrays.equals(other.getDimensions(), getDimensions())) return false;
for (int[] assignment : this) {
if (!getAssignmentValue(assignment).get().valueEquals(other.getAssignmentValue(assignment).get(), tolerance)) {
return false;
}
}
return true;
}
|
java
|
public boolean valueEquals(ConcatVectorTable other, double tolerance) {
if (!Arrays.equals(other.getDimensions(), getDimensions())) return false;
for (int[] assignment : this) {
if (!getAssignmentValue(assignment).get().valueEquals(other.getAssignmentValue(assignment).get(), tolerance)) {
return false;
}
}
return true;
}
|
[
"public",
"boolean",
"valueEquals",
"(",
"ConcatVectorTable",
"other",
",",
"double",
"tolerance",
")",
"{",
"if",
"(",
"!",
"Arrays",
".",
"equals",
"(",
"other",
".",
"getDimensions",
"(",
")",
",",
"getDimensions",
"(",
")",
")",
")",
"return",
"false",
";",
"for",
"(",
"int",
"[",
"]",
"assignment",
":",
"this",
")",
"{",
"if",
"(",
"!",
"getAssignmentValue",
"(",
"assignment",
")",
".",
"get",
"(",
")",
".",
"valueEquals",
"(",
"other",
".",
"getAssignmentValue",
"(",
"assignment",
")",
".",
"get",
"(",
")",
",",
"tolerance",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Deep comparison for equality of value, plus tolerance, for every concatvector in the table, plus dimensional
arrangement. This is mostly useful for testing.
@param other the vector table to compare against
@param tolerance the tolerance to use in value comparisons
@return whether the two tables are equivalent by value
|
[
"Deep",
"comparison",
"for",
"equality",
"of",
"value",
"plus",
"tolerance",
"for",
"every",
"concatvector",
"in",
"the",
"table",
"plus",
"dimensional",
"arrangement",
".",
"This",
"is",
"mostly",
"useful",
"for",
"testing",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVectorTable.java#L95-L103
|
145,211
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Val.java
|
Val.of
|
public static Val of(Object o) {
if (o != null && o instanceof Val) {
return Cast.as(o);
}
return new Val(o);
}
|
java
|
public static Val of(Object o) {
if (o != null && o instanceof Val) {
return Cast.as(o);
}
return new Val(o);
}
|
[
"public",
"static",
"Val",
"of",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"!=",
"null",
"&&",
"o",
"instanceof",
"Val",
")",
"{",
"return",
"Cast",
".",
"as",
"(",
"o",
")",
";",
"}",
"return",
"new",
"Val",
"(",
"o",
")",
";",
"}"
] |
Convenience method for creating a Convertible Object
@param o The object to convert
@return The ConvertibleObject wrapping the given object
|
[
"Convenience",
"method",
"for",
"creating",
"a",
"Convertible",
"Object"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Val.java#L72-L77
|
145,212
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Val.java
|
Val.asClass
|
@SuppressWarnings("unchecked")
public <T> Class<T> asClass(Class<T> defaultValue) {
return as(Class.class, defaultValue);
}
|
java
|
@SuppressWarnings("unchecked")
public <T> Class<T> asClass(Class<T> defaultValue) {
return as(Class.class, defaultValue);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"Class",
"<",
"T",
">",
"asClass",
"(",
"Class",
"<",
"T",
">",
"defaultValue",
")",
"{",
"return",
"as",
"(",
"Class",
".",
"class",
",",
"defaultValue",
")",
";",
"}"
] |
As class.
@param <T> the type parameter
@param defaultValue the default value
@return The object as a class
|
[
"As",
"class",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Val.java#L382-L385
|
145,213
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Val.java
|
Val.asList
|
@SuppressWarnings("unchecked")
public <T> List<T> asList(Class<T> itemType) {
return asCollection(List.class, itemType);
}
|
java
|
@SuppressWarnings("unchecked")
public <T> List<T> asList(Class<T> itemType) {
return asCollection(List.class, itemType);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"asList",
"(",
"Class",
"<",
"T",
">",
"itemType",
")",
"{",
"return",
"asCollection",
"(",
"List",
".",
"class",
",",
"itemType",
")",
";",
"}"
] |
Converts the object to a List
@param <T> the type parameter
@param itemType The class of the item in the List
@return The object as a List
|
[
"Converts",
"the",
"object",
"to",
"a",
"List"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Val.java#L730-L733
|
145,214
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Val.java
|
Val.asSet
|
public <T> Set<T> asSet(Class<T> itemType) {
return asCollection(Set.class, itemType);
}
|
java
|
public <T> Set<T> asSet(Class<T> itemType) {
return asCollection(Set.class, itemType);
}
|
[
"public",
"<",
"T",
">",
"Set",
"<",
"T",
">",
"asSet",
"(",
"Class",
"<",
"T",
">",
"itemType",
")",
"{",
"return",
"asCollection",
"(",
"Set",
".",
"class",
",",
"itemType",
")",
";",
"}"
] |
Converts the object to a Set
@param <T> the type parameter
@param itemType The class of the item in the Set
@return The object as a Set
|
[
"Converts",
"the",
"object",
"to",
"a",
"Set"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Val.java#L762-L764
|
145,215
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Val.java
|
Val.asArray
|
public <T> T[] asArray(Class<T> clazz) {
return Cast.as(convert(toConvert, Array.newInstance(clazz, 0).getClass()));
}
|
java
|
public <T> T[] asArray(Class<T> clazz) {
return Cast.as(convert(toConvert, Array.newInstance(clazz, 0).getClass()));
}
|
[
"public",
"<",
"T",
">",
"T",
"[",
"]",
"asArray",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"return",
"Cast",
".",
"as",
"(",
"convert",
"(",
"toConvert",
",",
"Array",
".",
"newInstance",
"(",
"clazz",
",",
"0",
")",
".",
"getClass",
"(",
")",
")",
")",
";",
"}"
] |
Converts an object into an array of objects
@param <T> the type parameter
@param clazz The type of the object to create.
@return An array of the object
|
[
"Converts",
"an",
"object",
"into",
"an",
"array",
"of",
"objects"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Val.java#L792-L794
|
145,216
|
dbracewell/mango
|
src/main/java/com/davidbracewell/parsing/Grammar.java
|
Grammar.precedence
|
public int precedence(ParserToken token) {
if (isInfix(token)) {
return infixHandlers.get(token.type).precedence();
}
return 0;
}
|
java
|
public int precedence(ParserToken token) {
if (isInfix(token)) {
return infixHandlers.get(token.type).precedence();
}
return 0;
}
|
[
"public",
"int",
"precedence",
"(",
"ParserToken",
"token",
")",
"{",
"if",
"(",
"isInfix",
"(",
"token",
")",
")",
"{",
"return",
"infixHandlers",
".",
"get",
"(",
"token",
".",
"type",
")",
".",
"precedence",
"(",
")",
";",
"}",
"return",
"0",
";",
"}"
] |
Gets the precedence of the associated infix handler.
@param token The token whose handler we want precedence for
@return the precedence of the associated infix handler or 0 if there is none.
|
[
"Gets",
"the",
"precedence",
"of",
"the",
"associated",
"infix",
"handler",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/parsing/Grammar.java#L164-L169
|
145,217
|
dbracewell/mango
|
src/main/java/com/davidbracewell/parsing/Grammar.java
|
Grammar.skip
|
public boolean skip(ParserToken token) {
if (token == null) {
return false;
}
if (isPrefix(token)) {
if (prefixHandlers.containsKey(token.getType())) {
return prefixHandlers.get(token.getType()) instanceof PrefixSkipHandler;
} else {
return prefixSkipHandler != null;
}
}
return false;
}
|
java
|
public boolean skip(ParserToken token) {
if (token == null) {
return false;
}
if (isPrefix(token)) {
if (prefixHandlers.containsKey(token.getType())) {
return prefixHandlers.get(token.getType()) instanceof PrefixSkipHandler;
} else {
return prefixSkipHandler != null;
}
}
return false;
}
|
[
"public",
"boolean",
"skip",
"(",
"ParserToken",
"token",
")",
"{",
"if",
"(",
"token",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"isPrefix",
"(",
"token",
")",
")",
"{",
"if",
"(",
"prefixHandlers",
".",
"containsKey",
"(",
"token",
".",
"getType",
"(",
")",
")",
")",
"{",
"return",
"prefixHandlers",
".",
"get",
"(",
"token",
".",
"getType",
"(",
")",
")",
"instanceof",
"PrefixSkipHandler",
";",
"}",
"else",
"{",
"return",
"prefixSkipHandler",
"!=",
"null",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Determines if the given the token should be skipped or not
@param token the token to check
@return True if the token should be skipped, false if it should be parsed.
|
[
"Determines",
"if",
"the",
"given",
"the",
"token",
"should",
"be",
"skipped",
"or",
"not"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/parsing/Grammar.java#L177-L189
|
145,218
|
flex-oss/flex-fruit
|
fruit-core/src/main/java/org/cdlflex/fruit/Filter.java
|
Filter.add
|
public Filter add(String attribute, Operator op, Object value) {
return add(new Predicate(attribute, op, value));
}
|
java
|
public Filter add(String attribute, Operator op, Object value) {
return add(new Predicate(attribute, op, value));
}
|
[
"public",
"Filter",
"add",
"(",
"String",
"attribute",
",",
"Operator",
"op",
",",
"Object",
"value",
")",
"{",
"return",
"add",
"(",
"new",
"Predicate",
"(",
"attribute",
",",
"op",
",",
"value",
")",
")",
";",
"}"
] |
Adds the given Predicate to the list of predicates.
@param attribute the attribute
@param op the operator
@param value the value
@return this for chaining.
@see Predicate(String, Operator, Object)
|
[
"Adds",
"the",
"given",
"Predicate",
"to",
"the",
"list",
"of",
"predicates",
"."
] |
30d7eca5ee796b829f96c9932a95b259ca9738d9
|
https://github.com/flex-oss/flex-fruit/blob/30d7eca5ee796b829f96c9932a95b259ca9738d9/fruit-core/src/main/java/org/cdlflex/fruit/Filter.java#L61-L63
|
145,219
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/HTTPUtilities.java
|
HTTPUtilities.writeOutContent
|
private static void writeOutContent(final byte[] data, final String filename, final String mime, final boolean asAttachment) {
try {
final HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.setContentType(mime);
if (asAttachment) response.addHeader("Content-Disposition", "attachment;filename=" + filename);
response.setContentLength(data.length);
final OutputStream writer = response.getOutputStream();
writer.write(data);
writer.flush();
writer.close();
FacesContext.getCurrentInstance().responseComplete();
} catch (final Exception ex) {
LOG.error("Unable to write content to HTTP Output Stream", ex);
}
}
|
java
|
private static void writeOutContent(final byte[] data, final String filename, final String mime, final boolean asAttachment) {
try {
final HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.setContentType(mime);
if (asAttachment) response.addHeader("Content-Disposition", "attachment;filename=" + filename);
response.setContentLength(data.length);
final OutputStream writer = response.getOutputStream();
writer.write(data);
writer.flush();
writer.close();
FacesContext.getCurrentInstance().responseComplete();
} catch (final Exception ex) {
LOG.error("Unable to write content to HTTP Output Stream", ex);
}
}
|
[
"private",
"static",
"void",
"writeOutContent",
"(",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"String",
"filename",
",",
"final",
"String",
"mime",
",",
"final",
"boolean",
"asAttachment",
")",
"{",
"try",
"{",
"final",
"HttpServletResponse",
"response",
"=",
"(",
"HttpServletResponse",
")",
"FacesContext",
".",
"getCurrentInstance",
"(",
")",
".",
"getExternalContext",
"(",
")",
".",
"getResponse",
"(",
")",
";",
"response",
".",
"setContentType",
"(",
"mime",
")",
";",
"if",
"(",
"asAttachment",
")",
"response",
".",
"addHeader",
"(",
"\"Content-Disposition\"",
",",
"\"attachment;filename=\"",
"+",
"filename",
")",
";",
"response",
".",
"setContentLength",
"(",
"data",
".",
"length",
")",
";",
"final",
"OutputStream",
"writer",
"=",
"response",
".",
"getOutputStream",
"(",
")",
";",
"writer",
".",
"write",
"(",
"data",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"writer",
".",
"close",
"(",
")",
";",
"FacesContext",
".",
"getCurrentInstance",
"(",
")",
".",
"responseComplete",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"ex",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unable to write content to HTTP Output Stream\"",
",",
"ex",
")",
";",
"}",
"}"
] |
Used to send arbitrary to the user.
@param data The contents of the file to send
@param filename The name of the file. This is only useful if asAttachment
is true
@param mime The MIME type of the content
@param asAttachment If true, the file will be downloaded. If false, it is
up to the browser to decide whether to display or download the
file
|
[
"Used",
"to",
"send",
"arbitrary",
"to",
"the",
"user",
"."
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/HTTPUtilities.java#L76-L97
|
145,220
|
jbundle/webapp
|
upload/src/main/java/org/jbundle/util/webapp/upload/UploadServlet.java
|
UploadServlet.doGet
|
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
this.doProcess(req, res);
}
|
java
|
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
this.doProcess(req, res);
}
|
[
"public",
"void",
"doGet",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"res",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"this",
".",
"doProcess",
"(",
"req",
",",
"res",
")",
";",
"}"
] |
Process an HTML get.
@exception ServletException From inherited class.
@exception IOException From inherited class.
|
[
"Process",
"an",
"HTML",
"get",
"."
] |
af2cf32bd92254073052f1f9b4bcd47c2f76ba7d
|
https://github.com/jbundle/webapp/blob/af2cf32bd92254073052f1f9b4bcd47c2f76ba7d/upload/src/main/java/org/jbundle/util/webapp/upload/UploadServlet.java#L85-L89
|
145,221
|
wcm-io-caravan/caravan-hal
|
resource/src/main/java/io/wcm/caravan/hal/resource/Link.java
|
Link.remove
|
public void remove() {
if (context == null) {
throw new IllegalStateException("link with href=" + getHref() + " can not be removed, because it's not part of a HAL resource tree");
}
// iterate over all links grouped by relation (because for removal we need to know the relation)
ListMultimap<String, Link> allLinks = context.getLinks();
for (String relation : allLinks.keySet()) {
List<Link> links = allLinks.get(relation);
// use an indexed for-loop, because we need to know the index to properly remove the link
for (int i = 0; i < links.size(); i++) {
if (links.get(i).getModel() == model) {
context.removeLink(relation, i);
context = null;
return;
}
}
}
throw new IllegalStateException("the last known context resource of link with href=" + getHref() + " no longer contains this link");
}
|
java
|
public void remove() {
if (context == null) {
throw new IllegalStateException("link with href=" + getHref() + " can not be removed, because it's not part of a HAL resource tree");
}
// iterate over all links grouped by relation (because for removal we need to know the relation)
ListMultimap<String, Link> allLinks = context.getLinks();
for (String relation : allLinks.keySet()) {
List<Link> links = allLinks.get(relation);
// use an indexed for-loop, because we need to know the index to properly remove the link
for (int i = 0; i < links.size(); i++) {
if (links.get(i).getModel() == model) {
context.removeLink(relation, i);
context = null;
return;
}
}
}
throw new IllegalStateException("the last known context resource of link with href=" + getHref() + " no longer contains this link");
}
|
[
"public",
"void",
"remove",
"(",
")",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"link with href=\"",
"+",
"getHref",
"(",
")",
"+",
"\" can not be removed, because it's not part of a HAL resource tree\"",
")",
";",
"}",
"// iterate over all links grouped by relation (because for removal we need to know the relation)",
"ListMultimap",
"<",
"String",
",",
"Link",
">",
"allLinks",
"=",
"context",
".",
"getLinks",
"(",
")",
";",
"for",
"(",
"String",
"relation",
":",
"allLinks",
".",
"keySet",
"(",
")",
")",
"{",
"List",
"<",
"Link",
">",
"links",
"=",
"allLinks",
".",
"get",
"(",
"relation",
")",
";",
"// use an indexed for-loop, because we need to know the index to properly remove the link",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"links",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"links",
".",
"get",
"(",
"i",
")",
".",
"getModel",
"(",
")",
"==",
"model",
")",
"{",
"context",
".",
"removeLink",
"(",
"relation",
",",
"i",
")",
";",
"context",
"=",
"null",
";",
"return",
";",
"}",
"}",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"\"the last known context resource of link with href=\"",
"+",
"getHref",
"(",
")",
"+",
"\" no longer contains this link\"",
")",
";",
"}"
] |
Removes this link from its context resource's JSON representation
@throws IllegalStateException if this link was never added to a resource, or has already been removed
|
[
"Removes",
"this",
"link",
"from",
"its",
"context",
"resource",
"s",
"JSON",
"representation"
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/Link.java#L217-L239
|
145,222
|
fuinorg/srcgen4j-commons
|
src/main/java/org/fuin/srcgen4j/commons/Classpath.java
|
Classpath.addBin
|
public final void addBin(@NotNull final BinClasspathEntry entry) {
Contract.requireArgNotNull("entry", entry);
if (binList == null) {
binList = new ArrayList<>();
}
binList.add(entry);
}
|
java
|
public final void addBin(@NotNull final BinClasspathEntry entry) {
Contract.requireArgNotNull("entry", entry);
if (binList == null) {
binList = new ArrayList<>();
}
binList.add(entry);
}
|
[
"public",
"final",
"void",
"addBin",
"(",
"@",
"NotNull",
"final",
"BinClasspathEntry",
"entry",
")",
"{",
"Contract",
".",
"requireArgNotNull",
"(",
"\"entry\"",
",",
"entry",
")",
";",
"if",
"(",
"binList",
"==",
"null",
")",
"{",
"binList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"binList",
".",
"add",
"(",
"entry",
")",
";",
"}"
] |
Adds a classes directory to the list. If the list does not exist it's created.
@param entry
Binaries directory to add.
|
[
"Adds",
"a",
"classes",
"directory",
"to",
"the",
"list",
".",
"If",
"the",
"list",
"does",
"not",
"exist",
"it",
"s",
"created",
"."
] |
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
|
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/Classpath.java#L123-L129
|
145,223
|
poolik/classfinder
|
src/main/java/com/poolik/classfinder/ClassFinder.java
|
ClassFinder.addClasspath
|
public ClassFinder addClasspath() {
try {
String path = System.getProperty("java.class.path");
StringTokenizer tok = new StringTokenizer(path, File.pathSeparator);
while (tok.hasMoreTokens())
add(new File(tok.nextToken()));
} catch (Exception ex) {
log.error("Unable to get class path", ex);
}
return this;
}
|
java
|
public ClassFinder addClasspath() {
try {
String path = System.getProperty("java.class.path");
StringTokenizer tok = new StringTokenizer(path, File.pathSeparator);
while (tok.hasMoreTokens())
add(new File(tok.nextToken()));
} catch (Exception ex) {
log.error("Unable to get class path", ex);
}
return this;
}
|
[
"public",
"ClassFinder",
"addClasspath",
"(",
")",
"{",
"try",
"{",
"String",
"path",
"=",
"System",
".",
"getProperty",
"(",
"\"java.class.path\"",
")",
";",
"StringTokenizer",
"tok",
"=",
"new",
"StringTokenizer",
"(",
"path",
",",
"File",
".",
"pathSeparator",
")",
";",
"while",
"(",
"tok",
".",
"hasMoreTokens",
"(",
")",
")",
"add",
"(",
"new",
"File",
"(",
"tok",
".",
"nextToken",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"log",
".",
"error",
"(",
"\"Unable to get class path\"",
",",
"ex",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Add the contents of the system classpath for classes.
|
[
"Add",
"the",
"contents",
"of",
"the",
"system",
"classpath",
"for",
"classes",
"."
] |
0544f1c702f4fe6cb4a33db2a85c48b1d93f168f
|
https://github.com/poolik/classfinder/blob/0544f1c702f4fe6cb4a33db2a85c48b1d93f168f/src/main/java/com/poolik/classfinder/ClassFinder.java#L136-L146
|
145,224
|
poolik/classfinder
|
src/main/java/com/poolik/classfinder/ClassFinder.java
|
ClassFinder.add
|
public ClassFinder add(File file) {
log.info("Adding file to look into: " + file.getAbsolutePath());
if (fileCanContainClasses(file)) {
String absPath = file.getAbsolutePath();
if (placesToSearch.get(absPath) == null) {
placesToSearch.put(absPath, file);
for (AdditionalResourceLoader resourceLoader : resourceLoaders) {
if (resourceLoader.canLoadAdditional(file)) resourceLoader.loadAdditional(file, this);
}
}
} else {
log.info("The given path '" + file.getAbsolutePath() + "' cannot contain classes!");
}
return this;
}
|
java
|
public ClassFinder add(File file) {
log.info("Adding file to look into: " + file.getAbsolutePath());
if (fileCanContainClasses(file)) {
String absPath = file.getAbsolutePath();
if (placesToSearch.get(absPath) == null) {
placesToSearch.put(absPath, file);
for (AdditionalResourceLoader resourceLoader : resourceLoaders) {
if (resourceLoader.canLoadAdditional(file)) resourceLoader.loadAdditional(file, this);
}
}
} else {
log.info("The given path '" + file.getAbsolutePath() + "' cannot contain classes!");
}
return this;
}
|
[
"public",
"ClassFinder",
"add",
"(",
"File",
"file",
")",
"{",
"log",
".",
"info",
"(",
"\"Adding file to look into: \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"if",
"(",
"fileCanContainClasses",
"(",
"file",
")",
")",
"{",
"String",
"absPath",
"=",
"file",
".",
"getAbsolutePath",
"(",
")",
";",
"if",
"(",
"placesToSearch",
".",
"get",
"(",
"absPath",
")",
"==",
"null",
")",
"{",
"placesToSearch",
".",
"put",
"(",
"absPath",
",",
"file",
")",
";",
"for",
"(",
"AdditionalResourceLoader",
"resourceLoader",
":",
"resourceLoaders",
")",
"{",
"if",
"(",
"resourceLoader",
".",
"canLoadAdditional",
"(",
"file",
")",
")",
"resourceLoader",
".",
"loadAdditional",
"(",
"file",
",",
"this",
")",
";",
"}",
"}",
"}",
"else",
"{",
"log",
".",
"info",
"(",
"\"The given path '\"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"' cannot contain classes!\"",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Add a jar file, zip file or directory to the list of places to search
for classes.
@param file the jar file, zip file or directory
@return this
|
[
"Add",
"a",
"jar",
"file",
"zip",
"file",
"or",
"directory",
"to",
"the",
"list",
"of",
"places",
"to",
"search",
"for",
"classes",
"."
] |
0544f1c702f4fe6cb4a33db2a85c48b1d93f168f
|
https://github.com/poolik/classfinder/blob/0544f1c702f4fe6cb4a33db2a85c48b1d93f168f/src/main/java/com/poolik/classfinder/ClassFinder.java#L155-L171
|
145,225
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/ThreadMap.java
|
ThreadMap.getCurrentStackSize
|
@Override
public int getCurrentStackSize() {
int stackSize = -1;
if (this.tracingContextMap.containsKey(Thread.currentThread()))
stackSize = this.tracingContextMap.get(Thread.currentThread()).getMethodStack().size();
return stackSize;
}
|
java
|
@Override
public int getCurrentStackSize() {
int stackSize = -1;
if (this.tracingContextMap.containsKey(Thread.currentThread()))
stackSize = this.tracingContextMap.get(Thread.currentThread()).getMethodStack().size();
return stackSize;
}
|
[
"@",
"Override",
"public",
"int",
"getCurrentStackSize",
"(",
")",
"{",
"int",
"stackSize",
"=",
"-",
"1",
";",
"if",
"(",
"this",
".",
"tracingContextMap",
".",
"containsKey",
"(",
"Thread",
".",
"currentThread",
"(",
")",
")",
")",
"stackSize",
"=",
"this",
".",
"tracingContextMap",
".",
"get",
"(",
"Thread",
".",
"currentThread",
"(",
")",
")",
".",
"getMethodStack",
"(",
")",
".",
"size",
"(",
")",
";",
"return",
"stackSize",
";",
"}"
] |
Returns the stack size of the current thread. The value -1 indicates that the current thread isn't registered.
@return the current stack size
|
[
"Returns",
"the",
"stack",
"size",
"of",
"the",
"current",
"thread",
".",
"The",
"value",
"-",
"1",
"indicates",
"that",
"the",
"current",
"thread",
"isn",
"t",
"registered",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/ThreadMap.java#L46-L53
|
145,226
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.addNotification
|
public static void addNotification(Notification n) {
NotificationManager.notifications.add(n);
logger.fine("New notification added to notifications list. There is currently: " +
notifications.size()+" notifications\n Notification added: "
+NotificationManager.notifications.get(NotificationManager.notifications.size()-1));
}
|
java
|
public static void addNotification(Notification n) {
NotificationManager.notifications.add(n);
logger.fine("New notification added to notifications list. There is currently: " +
notifications.size()+" notifications\n Notification added: "
+NotificationManager.notifications.get(NotificationManager.notifications.size()-1));
}
|
[
"public",
"static",
"void",
"addNotification",
"(",
"Notification",
"n",
")",
"{",
"NotificationManager",
".",
"notifications",
".",
"add",
"(",
"n",
")",
";",
"logger",
".",
"fine",
"(",
"\"New notification added to notifications list. There is currently: \"",
"+",
"notifications",
".",
"size",
"(",
")",
"+",
"\" notifications\\n Notification added: \"",
"+",
"NotificationManager",
".",
"notifications",
".",
"get",
"(",
"NotificationManager",
".",
"notifications",
".",
"size",
"(",
")",
"-",
"1",
")",
")",
";",
"}"
] |
The user can use this method to add notifications manually.
@param n
the notification to add.
|
[
"The",
"user",
"can",
"use",
"this",
"method",
"to",
"add",
"notifications",
"manually",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L113-L118
|
145,227
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.addNotification
|
@SuppressWarnings("unchecked")
public static void addNotification(Event e, String interaction) {
NotificationManager.notifications.add(new InteractionNotification(getNotificationID(),
NotificationManager.sim.getSchedule().getSteps(), e.getLauncher(),
interaction, (List<Object>) e.getAffected()));
logger.fine("New notification added to notifications list. There is currently: " +
notifications.size()+" notifications\n Notification added: "
+NotificationManager.notifications.get(NotificationManager.notifications.size()-1));
}
|
java
|
@SuppressWarnings("unchecked")
public static void addNotification(Event e, String interaction) {
NotificationManager.notifications.add(new InteractionNotification(getNotificationID(),
NotificationManager.sim.getSchedule().getSteps(), e.getLauncher(),
interaction, (List<Object>) e.getAffected()));
logger.fine("New notification added to notifications list. There is currently: " +
notifications.size()+" notifications\n Notification added: "
+NotificationManager.notifications.get(NotificationManager.notifications.size()-1));
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"void",
"addNotification",
"(",
"Event",
"e",
",",
"String",
"interaction",
")",
"{",
"NotificationManager",
".",
"notifications",
".",
"add",
"(",
"new",
"InteractionNotification",
"(",
"getNotificationID",
"(",
")",
",",
"NotificationManager",
".",
"sim",
".",
"getSchedule",
"(",
")",
".",
"getSteps",
"(",
")",
",",
"e",
".",
"getLauncher",
"(",
")",
",",
"interaction",
",",
"(",
"List",
"<",
"Object",
">",
")",
"e",
".",
"getAffected",
"(",
")",
")",
")",
";",
"logger",
".",
"fine",
"(",
"\"New notification added to notifications list. There is currently: \"",
"+",
"notifications",
".",
"size",
"(",
")",
"+",
"\" notifications\\n Notification added: \"",
"+",
"NotificationManager",
".",
"notifications",
".",
"get",
"(",
"NotificationManager",
".",
"notifications",
".",
"size",
"(",
")",
"-",
"1",
")",
")",
";",
"}"
] |
Whenever a new event triggers it will use this method to add the corresponding notification
to the notification lists.
@param e
the event that for the notification.
@param interaction
|
[
"Whenever",
"a",
"new",
"event",
"triggers",
"it",
"will",
"use",
"this",
"method",
"to",
"add",
"the",
"corresponding",
"notification",
"to",
"the",
"notification",
"lists",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L128-L136
|
145,228
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.getNotificationID
|
private static String getNotificationID() {
NotificationManager.ID_COUNTER = NotificationManager.ID_COUNTER+1;
logger.fine("Notifications identifier counter: "+ID_COUNTER);
return "Notification#" + (NotificationManager.ID_COUNTER);
}
|
java
|
private static String getNotificationID() {
NotificationManager.ID_COUNTER = NotificationManager.ID_COUNTER+1;
logger.fine("Notifications identifier counter: "+ID_COUNTER);
return "Notification#" + (NotificationManager.ID_COUNTER);
}
|
[
"private",
"static",
"String",
"getNotificationID",
"(",
")",
"{",
"NotificationManager",
".",
"ID_COUNTER",
"=",
"NotificationManager",
".",
"ID_COUNTER",
"+",
"1",
";",
"logger",
".",
"fine",
"(",
"\"Notifications identifier counter: \"",
"+",
"ID_COUNTER",
")",
";",
"return",
"\"Notification#\"",
"+",
"(",
"NotificationManager",
".",
"ID_COUNTER",
")",
";",
"}"
] |
Each new notification needs a notification-ID. NotificationManager monitors the number of
notifications and generates a unique identifier for each of them, using this method to obtain it.
@return
a notification ID corresponding with the number of notifications saved on this simulation.
|
[
"Each",
"new",
"notification",
"needs",
"a",
"notification",
"-",
"ID",
".",
"NotificationManager",
"monitors",
"the",
"number",
"of",
"notifications",
"and",
"generates",
"a",
"unique",
"identifier",
"for",
"each",
"of",
"them",
"using",
"this",
"method",
"to",
"obtain",
"it",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L154-L158
|
145,229
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.getByID
|
public Notification getByID(String id) {
//TODO maybe SORT_By_ID then make a better array searching algorithm
for (Notification n: NotificationManager.notifications){
if(n.getId().equals(id)){
logger.fine("...found a match for getByID query. With id: "+id);
return n;
}
}
logger.fine("There is no notification that match the given ID: "+id);
return null;
}
|
java
|
public Notification getByID(String id) {
//TODO maybe SORT_By_ID then make a better array searching algorithm
for (Notification n: NotificationManager.notifications){
if(n.getId().equals(id)){
logger.fine("...found a match for getByID query. With id: "+id);
return n;
}
}
logger.fine("There is no notification that match the given ID: "+id);
return null;
}
|
[
"public",
"Notification",
"getByID",
"(",
"String",
"id",
")",
"{",
"//TODO maybe SORT_By_ID then make a better array searching algorithm",
"for",
"(",
"Notification",
"n",
":",
"NotificationManager",
".",
"notifications",
")",
"{",
"if",
"(",
"n",
".",
"getId",
"(",
")",
".",
"equals",
"(",
"id",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"...found a match for getByID query. With id: \"",
"+",
"id",
")",
";",
"return",
"n",
";",
"}",
"}",
"logger",
".",
"fine",
"(",
"\"There is no notification that match the given ID: \"",
"+",
"id",
")",
";",
"return",
"null",
";",
"}"
] |
Search for a notification with the given id.
@param id
the identifier of the wanted notification.
@return
the notification founded or null if no one can be found.
|
[
"Search",
"for",
"a",
"notification",
"with",
"the",
"given",
"id",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L168-L178
|
145,230
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.getByStep
|
public List<Notification> getByStep(int step) {
List<Notification> found = new ArrayList<Notification>();
for (Notification n: NotificationManager.notifications)
if (n.getWhen() == step){
logger.fine("...found a match for getByStep query. With step: "+step);
found.add(n);
}
if(found.size()>0)
return found;
return null;
}
|
java
|
public List<Notification> getByStep(int step) {
List<Notification> found = new ArrayList<Notification>();
for (Notification n: NotificationManager.notifications)
if (n.getWhen() == step){
logger.fine("...found a match for getByStep query. With step: "+step);
found.add(n);
}
if(found.size()>0)
return found;
return null;
}
|
[
"public",
"List",
"<",
"Notification",
">",
"getByStep",
"(",
"int",
"step",
")",
"{",
"List",
"<",
"Notification",
">",
"found",
"=",
"new",
"ArrayList",
"<",
"Notification",
">",
"(",
")",
";",
"for",
"(",
"Notification",
"n",
":",
"NotificationManager",
".",
"notifications",
")",
"if",
"(",
"n",
".",
"getWhen",
"(",
")",
"==",
"step",
")",
"{",
"logger",
".",
"fine",
"(",
"\"...found a match for getByStep query. With step: \"",
"+",
"step",
")",
";",
"found",
".",
"add",
"(",
"n",
")",
";",
"}",
"if",
"(",
"found",
".",
"size",
"(",
")",
">",
"0",
")",
"return",
"found",
";",
"return",
"null",
";",
"}"
] |
Search for notifications saved on the given step.
@param step
the simulation step number from which the notifications are asked
@return
a List with the notifications that match the given step or null if no one can be found.
|
[
"Search",
"for",
"notifications",
"saved",
"on",
"the",
"given",
"step",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L188-L198
|
145,231
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.getBySource
|
public List<Notification> getBySource(Object source) {
List<Notification> found = new ArrayList<Notification>();
for (Notification n: NotificationManager.notifications)
if (n.getSource().equals(source)) {
logger.fine("...found a match for getBySource query. With source: "+source);
found.add(n);
}
if(found.size()>0)
return found;
return null;
}
|
java
|
public List<Notification> getBySource(Object source) {
List<Notification> found = new ArrayList<Notification>();
for (Notification n: NotificationManager.notifications)
if (n.getSource().equals(source)) {
logger.fine("...found a match for getBySource query. With source: "+source);
found.add(n);
}
if(found.size()>0)
return found;
return null;
}
|
[
"public",
"List",
"<",
"Notification",
">",
"getBySource",
"(",
"Object",
"source",
")",
"{",
"List",
"<",
"Notification",
">",
"found",
"=",
"new",
"ArrayList",
"<",
"Notification",
">",
"(",
")",
";",
"for",
"(",
"Notification",
"n",
":",
"NotificationManager",
".",
"notifications",
")",
"if",
"(",
"n",
".",
"getSource",
"(",
")",
".",
"equals",
"(",
"source",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"...found a match for getBySource query. With source: \"",
"+",
"source",
")",
";",
"found",
".",
"add",
"(",
"n",
")",
";",
"}",
"if",
"(",
"found",
".",
"size",
"(",
")",
">",
"0",
")",
"return",
"found",
";",
"return",
"null",
";",
"}"
] |
Search for notifications originated from the given source object.
@param source
the object of the simulation that generates the notifications
@return
|
[
"Search",
"for",
"notifications",
"originated",
"from",
"the",
"given",
"source",
"object",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L207-L217
|
145,232
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.getByInteraction
|
public List<Notification> getByInteraction(String interaction) {
List<Notification> found = new ArrayList<Notification>();
for (Notification n: NotificationManager.notifications)
if (((InteractionNotification)n).getInteraction().equals(interaction)){
logger.fine("...found a match for getByInteraction query. With interaction: " +
interaction);
found.add(n);
}
if(found.size()>0)
return found;
return null;
}
|
java
|
public List<Notification> getByInteraction(String interaction) {
List<Notification> found = new ArrayList<Notification>();
for (Notification n: NotificationManager.notifications)
if (((InteractionNotification)n).getInteraction().equals(interaction)){
logger.fine("...found a match for getByInteraction query. With interaction: " +
interaction);
found.add(n);
}
if(found.size()>0)
return found;
return null;
}
|
[
"public",
"List",
"<",
"Notification",
">",
"getByInteraction",
"(",
"String",
"interaction",
")",
"{",
"List",
"<",
"Notification",
">",
"found",
"=",
"new",
"ArrayList",
"<",
"Notification",
">",
"(",
")",
";",
"for",
"(",
"Notification",
"n",
":",
"NotificationManager",
".",
"notifications",
")",
"if",
"(",
"(",
"(",
"InteractionNotification",
")",
"n",
")",
".",
"getInteraction",
"(",
")",
".",
"equals",
"(",
"interaction",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"...found a match for getByInteraction query. With interaction: \"",
"+",
"interaction",
")",
";",
"found",
".",
"add",
"(",
"n",
")",
";",
"}",
"if",
"(",
"found",
".",
"size",
"(",
")",
">",
"0",
")",
"return",
"found",
";",
"return",
"null",
";",
"}"
] |
Search for notifications of interaction type that match the given class name.
@param interaction
the class that defines the interaction type of desired notifications.
@return
a List with the notifications founded that match the given class name.
|
[
"Search",
"for",
"notifications",
"of",
"interaction",
"type",
"that",
"match",
"the",
"given",
"class",
"name",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L227-L238
|
145,233
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.getByTarget
|
public List<Notification> getByTarget(Object target) {
List<Notification> found = new ArrayList<Notification>();
for (Notification n: NotificationManager.notifications) {
for (Object t : ((InteractionNotification)n).getTarget()) {
if (t.equals(target)){
logger.fine("...found a match for getByTarget query. With target: "+target);
found.add(n);
}
}
}
if(found.size()>0)
return found;
return null;
}
|
java
|
public List<Notification> getByTarget(Object target) {
List<Notification> found = new ArrayList<Notification>();
for (Notification n: NotificationManager.notifications) {
for (Object t : ((InteractionNotification)n).getTarget()) {
if (t.equals(target)){
logger.fine("...found a match for getByTarget query. With target: "+target);
found.add(n);
}
}
}
if(found.size()>0)
return found;
return null;
}
|
[
"public",
"List",
"<",
"Notification",
">",
"getByTarget",
"(",
"Object",
"target",
")",
"{",
"List",
"<",
"Notification",
">",
"found",
"=",
"new",
"ArrayList",
"<",
"Notification",
">",
"(",
")",
";",
"for",
"(",
"Notification",
"n",
":",
"NotificationManager",
".",
"notifications",
")",
"{",
"for",
"(",
"Object",
"t",
":",
"(",
"(",
"InteractionNotification",
")",
"n",
")",
".",
"getTarget",
"(",
")",
")",
"{",
"if",
"(",
"t",
".",
"equals",
"(",
"target",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"...found a match for getByTarget query. With target: \"",
"+",
"target",
")",
";",
"found",
".",
"add",
"(",
"n",
")",
";",
"}",
"}",
"}",
"if",
"(",
"found",
".",
"size",
"(",
")",
">",
"0",
")",
"return",
"found",
";",
"return",
"null",
";",
"}"
] |
Search for notifications of interaction type that match the given target object
.
@param target
the target object from which notifications are asked.
@return
a List with notifications founded that match the given target object.
|
[
"Search",
"for",
"notifications",
"of",
"interaction",
"type",
"that",
"match",
"the",
"given",
"target",
"object",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L249-L262
|
145,234
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.getByElementID
|
public List<ValueNotification> getByElementID(String elementID) {
if(elementID == null)
return null;
List<ValueNotification> found = new ArrayList<ValueNotification>();
for (Notification n: NotificationManager.notifications){
try{
if (((ValueNotification)n).getElementID().equals(elementID)) {
logger.fine("...found a match for getByElementID query. With elementID: "+elementID);
found.add((ValueNotification) n);
}
} catch (ClassCastException e) {
// Nothing to do. Its normal when comparts value an interaction notifications.
}
}
if(found.size()>0)
return found;
return null;
}
|
java
|
public List<ValueNotification> getByElementID(String elementID) {
if(elementID == null)
return null;
List<ValueNotification> found = new ArrayList<ValueNotification>();
for (Notification n: NotificationManager.notifications){
try{
if (((ValueNotification)n).getElementID().equals(elementID)) {
logger.fine("...found a match for getByElementID query. With elementID: "+elementID);
found.add((ValueNotification) n);
}
} catch (ClassCastException e) {
// Nothing to do. Its normal when comparts value an interaction notifications.
}
}
if(found.size()>0)
return found;
return null;
}
|
[
"public",
"List",
"<",
"ValueNotification",
">",
"getByElementID",
"(",
"String",
"elementID",
")",
"{",
"if",
"(",
"elementID",
"==",
"null",
")",
"return",
"null",
";",
"List",
"<",
"ValueNotification",
">",
"found",
"=",
"new",
"ArrayList",
"<",
"ValueNotification",
">",
"(",
")",
";",
"for",
"(",
"Notification",
"n",
":",
"NotificationManager",
".",
"notifications",
")",
"{",
"try",
"{",
"if",
"(",
"(",
"(",
"ValueNotification",
")",
"n",
")",
".",
"getElementID",
"(",
")",
".",
"equals",
"(",
"elementID",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"...found a match for getByElementID query. With elementID: \"",
"+",
"elementID",
")",
";",
"found",
".",
"add",
"(",
"(",
"ValueNotification",
")",
"n",
")",
";",
"}",
"}",
"catch",
"(",
"ClassCastException",
"e",
")",
"{",
"// Nothing to do. Its normal when comparts value an interaction notifications. ",
"}",
"}",
"if",
"(",
"found",
".",
"size",
"(",
")",
">",
"0",
")",
"return",
"found",
";",
"return",
"null",
";",
"}"
] |
Search for notifications of ElementValue type that match the given element identifier.
@param elementID
the identifier of the element that was notified.
@return
A list with the notifications saved for the given element identifier.
|
[
"Search",
"for",
"notifications",
"of",
"ElementValue",
"type",
"that",
"match",
"the",
"given",
"element",
"identifier",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L271-L288
|
145,235
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.getByType
|
@SuppressWarnings("unchecked")
public ArrayList<Notification> getByType(Class<?> type) {
List<?> byType = this.getByType();
if (type.isAssignableFrom(InteractionNotification.class))
return (ArrayList<Notification>) byType.get(0);
if (type.isAssignableFrom(ValueNotification.class))
return (ArrayList<Notification>) byType.get(1);
return null;
}
|
java
|
@SuppressWarnings("unchecked")
public ArrayList<Notification> getByType(Class<?> type) {
List<?> byType = this.getByType();
if (type.isAssignableFrom(InteractionNotification.class))
return (ArrayList<Notification>) byType.get(0);
if (type.isAssignableFrom(ValueNotification.class))
return (ArrayList<Notification>) byType.get(1);
return null;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"ArrayList",
"<",
"Notification",
">",
"getByType",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"List",
"<",
"?",
">",
"byType",
"=",
"this",
".",
"getByType",
"(",
")",
";",
"if",
"(",
"type",
".",
"isAssignableFrom",
"(",
"InteractionNotification",
".",
"class",
")",
")",
"return",
"(",
"ArrayList",
"<",
"Notification",
">",
")",
"byType",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"type",
".",
"isAssignableFrom",
"(",
"ValueNotification",
".",
"class",
")",
")",
"return",
"(",
"ArrayList",
"<",
"Notification",
">",
")",
"byType",
".",
"get",
"(",
"1",
")",
";",
"return",
"null",
";",
"}"
] |
Search for notifications that match the corresponding notifications realization.
@param type
can be InteractionNotification.class or ElementValueNotification.class
@return
a List with all notifications from the selected type.
|
[
"Search",
"for",
"notifications",
"that",
"match",
"the",
"corresponding",
"notifications",
"realization",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L298-L306
|
145,236
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.step
|
@Override
public void step(SimState arg0) {
logger.finest("Notifying each element of the notifable element list...");
for(Notifable n: NotificationManager.notifables){
NotificationManager.addNotification(n);
}
}
|
java
|
@Override
public void step(SimState arg0) {
logger.finest("Notifying each element of the notifable element list...");
for(Notifable n: NotificationManager.notifables){
NotificationManager.addNotification(n);
}
}
|
[
"@",
"Override",
"public",
"void",
"step",
"(",
"SimState",
"arg0",
")",
"{",
"logger",
".",
"finest",
"(",
"\"Notifying each element of the notifable element list...\"",
")",
";",
"for",
"(",
"Notifable",
"n",
":",
"NotificationManager",
".",
"notifables",
")",
"{",
"NotificationManager",
".",
"addNotification",
"(",
"n",
")",
";",
"}",
"}"
] |
When the setp of NotificationManager its called generates a notification for each notifable
that has been added to it.
|
[
"When",
"the",
"setp",
"of",
"NotificationManager",
"its",
"called",
"generates",
"a",
"notification",
"for",
"each",
"notifable",
"that",
"has",
"been",
"added",
"to",
"it",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L331-L337
|
145,237
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java
|
NotificationManager.addNotification
|
private static void addNotification(Notifable n) {
NotificationManager.notifications.add(new ValueNotification(
getNotificationID(),
NotificationManager.sim.getSchedule().getSteps(),
n.getSource(),
n.getID(),
n.getElementValue()));
logger.fine("Notification added. Element: "+ n.getID()+". Value ="+n.getElementValue());
}
|
java
|
private static void addNotification(Notifable n) {
NotificationManager.notifications.add(new ValueNotification(
getNotificationID(),
NotificationManager.sim.getSchedule().getSteps(),
n.getSource(),
n.getID(),
n.getElementValue()));
logger.fine("Notification added. Element: "+ n.getID()+". Value ="+n.getElementValue());
}
|
[
"private",
"static",
"void",
"addNotification",
"(",
"Notifable",
"n",
")",
"{",
"NotificationManager",
".",
"notifications",
".",
"add",
"(",
"new",
"ValueNotification",
"(",
"getNotificationID",
"(",
")",
",",
"NotificationManager",
".",
"sim",
".",
"getSchedule",
"(",
")",
".",
"getSteps",
"(",
")",
",",
"n",
".",
"getSource",
"(",
")",
",",
"n",
".",
"getID",
"(",
")",
",",
"n",
".",
"getElementValue",
"(",
")",
")",
")",
";",
"logger",
".",
"fine",
"(",
"\"Notification added. Element: \"",
"+",
"n",
".",
"getID",
"(",
")",
"+",
"\". Value =\"",
"+",
"n",
".",
"getElementValue",
"(",
")",
")",
";",
"}"
] |
Add a new notification of the ElementValueNotification type. The ones that are defined
by the user.
@param n
the notifable element to be recorded as a notification.
|
[
"Add",
"a",
"new",
"notification",
"of",
"the",
"ElementValueNotification",
"type",
".",
"The",
"ones",
"that",
"are",
"defined",
"by",
"the",
"user",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/notification/NotificationManager.java#L346-L354
|
145,238
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/ExceptionUtilities.java
|
ExceptionUtilities.getStackTrace
|
public static String getStackTrace(final Throwable ex) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
ex.printStackTrace(pw);
pw.flush();
sw.flush();
return sw.toString();
}
|
java
|
public static String getStackTrace(final Throwable ex) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
ex.printStackTrace(pw);
pw.flush();
sw.flush();
return sw.toString();
}
|
[
"public",
"static",
"String",
"getStackTrace",
"(",
"final",
"Throwable",
"ex",
")",
"{",
"final",
"StringWriter",
"sw",
"=",
"new",
"StringWriter",
"(",
")",
";",
"final",
"PrintWriter",
"pw",
"=",
"new",
"PrintWriter",
"(",
"sw",
",",
"true",
")",
";",
"ex",
".",
"printStackTrace",
"(",
"pw",
")",
";",
"pw",
".",
"flush",
"(",
")",
";",
"sw",
".",
"flush",
"(",
")",
";",
"return",
"sw",
".",
"toString",
"(",
")",
";",
"}"
] |
A standard function to get the stack trace from a
thrown Exception
@param ex The thrown exception
@return The stack trace from the exception
|
[
"A",
"standard",
"function",
"to",
"get",
"the",
"stack",
"trace",
"from",
"a",
"thrown",
"Exception"
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/ExceptionUtilities.java#L33-L40
|
145,239
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/smile/ShanksAgentBayesianReasoningCapability.java
|
ShanksAgentBayesianReasoningCapability.loadNetwork
|
public static void loadNetwork(BayesianReasonerShanksAgent agent)
throws ShanksException {
Network bn = ShanksAgentBayesianReasoningCapability.loadNetwork(agent
.getBayesianNetworkFilePath());
agent.setBayesianNetwork(bn);
}
|
java
|
public static void loadNetwork(BayesianReasonerShanksAgent agent)
throws ShanksException {
Network bn = ShanksAgentBayesianReasoningCapability.loadNetwork(agent
.getBayesianNetworkFilePath());
agent.setBayesianNetwork(bn);
}
|
[
"public",
"static",
"void",
"loadNetwork",
"(",
"BayesianReasonerShanksAgent",
"agent",
")",
"throws",
"ShanksException",
"{",
"Network",
"bn",
"=",
"ShanksAgentBayesianReasoningCapability",
".",
"loadNetwork",
"(",
"agent",
".",
"getBayesianNetworkFilePath",
"(",
")",
")",
";",
"agent",
".",
"setBayesianNetwork",
"(",
"bn",
")",
";",
"}"
] |
Load the Bayesian network of the agent
@param agent
@throws ShanksException
|
[
"Load",
"the",
"Bayesian",
"network",
"of",
"the",
"agent"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/smile/ShanksAgentBayesianReasoningCapability.java#L70-L75
|
145,240
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/smile/ShanksAgentBayesianReasoningCapability.java
|
ShanksAgentBayesianReasoningCapability.addSoftEvidences
|
public static void addSoftEvidences(Network bn,
HashMap<String, HashMap<String, Double>> softEvidences)
throws ShanksException {
for (Entry<String, HashMap<String, Double>> softEvidence : softEvidences
.entrySet()) {
ShanksAgentBayesianReasoningCapability.addSoftEvidence(bn,
softEvidence.getKey(), softEvidence.getValue());
}
}
|
java
|
public static void addSoftEvidences(Network bn,
HashMap<String, HashMap<String, Double>> softEvidences)
throws ShanksException {
for (Entry<String, HashMap<String, Double>> softEvidence : softEvidences
.entrySet()) {
ShanksAgentBayesianReasoningCapability.addSoftEvidence(bn,
softEvidence.getKey(), softEvidence.getValue());
}
}
|
[
"public",
"static",
"void",
"addSoftEvidences",
"(",
"Network",
"bn",
",",
"HashMap",
"<",
"String",
",",
"HashMap",
"<",
"String",
",",
"Double",
">",
">",
"softEvidences",
")",
"throws",
"ShanksException",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"HashMap",
"<",
"String",
",",
"Double",
">",
">",
"softEvidence",
":",
"softEvidences",
".",
"entrySet",
"(",
")",
")",
"{",
"ShanksAgentBayesianReasoningCapability",
".",
"addSoftEvidence",
"(",
"bn",
",",
"softEvidence",
".",
"getKey",
"(",
")",
",",
"softEvidence",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Add a set of soft-evidences to the Bayesian network to reason with it. It
creates automatically the auxiliary nodes.
@param bn
@param softEvidences
hashmap in format [nodeName, hashmap] to set evidences in the
bayesian network. The second hashmap in format [nodeStatus,
confidence]
@throws ShanksException
|
[
"Add",
"a",
"set",
"of",
"soft",
"-",
"evidences",
"to",
"the",
"Bayesian",
"network",
"to",
"reason",
"with",
"it",
".",
"It",
"creates",
"automatically",
"the",
"auxiliary",
"nodes",
"."
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/agent/capability/reasoning/bayes/smile/ShanksAgentBayesianReasoningCapability.java#L421-L429
|
145,241
|
NessComputing/service-discovery
|
client/src/main/java/com/nesscomputing/service/discovery/client/internal/ServiceDiscoveryRunnable.java
|
ServiceDiscoveryRunnable.determineCurrentGeneration
|
@Override
public long determineCurrentGeneration(final AtomicLong generation, final long tick)
{
// If the scan interval was reached, trigger the
// run.
if (tick - lastScan >= scanTicks) {
lastScan = tick;
return generation.incrementAndGet();
}
// Otherwise, give the service discovery serviceDiscoveryVisitors a chance
// to increment the generation.
for (ServiceDiscoveryTask visitor : visitors) {
visitor.determineGeneration(generation, tick);
}
return generation.get();
}
|
java
|
@Override
public long determineCurrentGeneration(final AtomicLong generation, final long tick)
{
// If the scan interval was reached, trigger the
// run.
if (tick - lastScan >= scanTicks) {
lastScan = tick;
return generation.incrementAndGet();
}
// Otherwise, give the service discovery serviceDiscoveryVisitors a chance
// to increment the generation.
for (ServiceDiscoveryTask visitor : visitors) {
visitor.determineGeneration(generation, tick);
}
return generation.get();
}
|
[
"@",
"Override",
"public",
"long",
"determineCurrentGeneration",
"(",
"final",
"AtomicLong",
"generation",
",",
"final",
"long",
"tick",
")",
"{",
"// If the scan interval was reached, trigger the",
"// run.",
"if",
"(",
"tick",
"-",
"lastScan",
">=",
"scanTicks",
")",
"{",
"lastScan",
"=",
"tick",
";",
"return",
"generation",
".",
"incrementAndGet",
"(",
")",
";",
"}",
"// Otherwise, give the service discovery serviceDiscoveryVisitors a chance",
"// to increment the generation.",
"for",
"(",
"ServiceDiscoveryTask",
"visitor",
":",
"visitors",
")",
"{",
"visitor",
".",
"determineGeneration",
"(",
"generation",
",",
"tick",
")",
";",
"}",
"return",
"generation",
".",
"get",
"(",
")",
";",
"}"
] |
Trigger the loop every time enough ticks have been accumulated, or whenever any of the
visitors requests it.
|
[
"Trigger",
"the",
"loop",
"every",
"time",
"enough",
"ticks",
"have",
"been",
"accumulated",
"or",
"whenever",
"any",
"of",
"the",
"visitors",
"requests",
"it",
"."
] |
5091ffdb1de6b12d216d1c238f72858037c7b765
|
https://github.com/NessComputing/service-discovery/blob/5091ffdb1de6b12d216d1c238f72858037c7b765/client/src/main/java/com/nesscomputing/service/discovery/client/internal/ServiceDiscoveryRunnable.java#L68-L85
|
145,242
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Convert.java
|
Convert.register
|
public static void register(Class<?> clazz, Function<Object, ?> converter) {
if (clazz == null || converter == null) {
log.warn("Trying to register either a null class ({0}) or a null converter ({1}). Ignoring!",
clazz,
converter);
return;
}
converters.put(clazz, converter);
}
|
java
|
public static void register(Class<?> clazz, Function<Object, ?> converter) {
if (clazz == null || converter == null) {
log.warn("Trying to register either a null class ({0}) or a null converter ({1}). Ignoring!",
clazz,
converter);
return;
}
converters.put(clazz, converter);
}
|
[
"public",
"static",
"void",
"register",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"Function",
"<",
"Object",
",",
"?",
">",
"converter",
")",
"{",
"if",
"(",
"clazz",
"==",
"null",
"||",
"converter",
"==",
"null",
")",
"{",
"log",
".",
"warn",
"(",
"\"Trying to register either a null class ({0}) or a null converter ({1}). Ignoring!\"",
",",
"clazz",
",",
"converter",
")",
";",
"return",
";",
"}",
"converters",
".",
"put",
"(",
"clazz",
",",
"converter",
")",
";",
"}"
] |
Register void.
@param clazz the clazz
@param converter the converter
|
[
"Register",
"void",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Convert.java#L129-L137
|
145,243
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Convert.java
|
Convert.hasConverter
|
public static <T> boolean hasConverter(Class<T> clazz) {
if (clazz == null) {
return false;
} else if (converters.containsKey(clazz)) {
return true;
}
return clazz.isArray() && converters.containsKey(clazz.getComponentType());
}
|
java
|
public static <T> boolean hasConverter(Class<T> clazz) {
if (clazz == null) {
return false;
} else if (converters.containsKey(clazz)) {
return true;
}
return clazz.isArray() && converters.containsKey(clazz.getComponentType());
}
|
[
"public",
"static",
"<",
"T",
">",
"boolean",
"hasConverter",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"converters",
".",
"containsKey",
"(",
"clazz",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"clazz",
".",
"isArray",
"(",
")",
"&&",
"converters",
".",
"containsKey",
"(",
"clazz",
".",
"getComponentType",
"(",
")",
")",
";",
"}"
] |
Has converter.
@param <T> the type parameter
@param clazz the clazz
@return the boolean
|
[
"Has",
"converter",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Convert.java#L146-L153
|
145,244
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Convert.java
|
Convert.getConverter
|
public static <T> Function<Object, T> getConverter(final Class<T> clazz) {
return object -> Convert.convert(object, clazz);
}
|
java
|
public static <T> Function<Object, T> getConverter(final Class<T> clazz) {
return object -> Convert.convert(object, clazz);
}
|
[
"public",
"static",
"<",
"T",
">",
"Function",
"<",
"Object",
",",
"T",
">",
"getConverter",
"(",
"final",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"return",
"object",
"->",
"Convert",
".",
"convert",
"(",
"object",
",",
"clazz",
")",
";",
"}"
] |
Gets a converter for a given class
@param <T> the type parameter
@param clazz The class to convert to
@return A converter
|
[
"Gets",
"a",
"converter",
"for",
"a",
"given",
"class"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Convert.java#L162-L164
|
145,245
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Convert.java
|
Convert.convert
|
@SuppressWarnings("unchecked")
public static <KEY, VALUE, MAP extends Map<KEY, VALUE>> MAP convert(Object object, Class<?> mapClass, Class<KEY> keyClass, Class<VALUE> valueClass) {
return Cast.as(new MapConverter<KEY, VALUE, MAP>(getConverter(keyClass),
getConverter(valueClass),
Cast.as(mapClass)
).apply(object));
}
|
java
|
@SuppressWarnings("unchecked")
public static <KEY, VALUE, MAP extends Map<KEY, VALUE>> MAP convert(Object object, Class<?> mapClass, Class<KEY> keyClass, Class<VALUE> valueClass) {
return Cast.as(new MapConverter<KEY, VALUE, MAP>(getConverter(keyClass),
getConverter(valueClass),
Cast.as(mapClass)
).apply(object));
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"KEY",
",",
"VALUE",
",",
"MAP",
"extends",
"Map",
"<",
"KEY",
",",
"VALUE",
">",
">",
"MAP",
"convert",
"(",
"Object",
"object",
",",
"Class",
"<",
"?",
">",
"mapClass",
",",
"Class",
"<",
"KEY",
">",
"keyClass",
",",
"Class",
"<",
"VALUE",
">",
"valueClass",
")",
"{",
"return",
"Cast",
".",
"as",
"(",
"new",
"MapConverter",
"<",
"KEY",
",",
"VALUE",
",",
"MAP",
">",
"(",
"getConverter",
"(",
"keyClass",
")",
",",
"getConverter",
"(",
"valueClass",
")",
",",
"Cast",
".",
"as",
"(",
"mapClass",
")",
")",
".",
"apply",
"(",
"object",
")",
")",
";",
"}"
] |
Convert mAP.
@param <KEY> the type parameter
@param <VALUE> the type parameter
@param <MAP> the type parameter
@param object the object
@param mapClass the map class
@param keyClass the key class
@param valueClass the value class
@return the mAP
|
[
"Convert",
"mAP",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Convert.java#L239-L245
|
145,246
|
dbracewell/mango
|
src/main/java/com/davidbracewell/conversion/Convert.java
|
Convert.convert
|
@SuppressWarnings("unchecked")
public static <T, C extends Collection<T>> C convert(Object object, Class<?> collectionClass, Class<T> componentClass) {
if (collectionClass == null || !Collection.class.isAssignableFrom(collectionClass)) {
log.fine("{0} does not extend collection.", collectionClass);
return null;
}
return Cast.as(CollectionConverter.COLLECTION(Cast.<Class<C>>as(collectionClass), componentClass).apply(object));
}
|
java
|
@SuppressWarnings("unchecked")
public static <T, C extends Collection<T>> C convert(Object object, Class<?> collectionClass, Class<T> componentClass) {
if (collectionClass == null || !Collection.class.isAssignableFrom(collectionClass)) {
log.fine("{0} does not extend collection.", collectionClass);
return null;
}
return Cast.as(CollectionConverter.COLLECTION(Cast.<Class<C>>as(collectionClass), componentClass).apply(object));
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
",",
"C",
"extends",
"Collection",
"<",
"T",
">",
">",
"C",
"convert",
"(",
"Object",
"object",
",",
"Class",
"<",
"?",
">",
"collectionClass",
",",
"Class",
"<",
"T",
">",
"componentClass",
")",
"{",
"if",
"(",
"collectionClass",
"==",
"null",
"||",
"!",
"Collection",
".",
"class",
".",
"isAssignableFrom",
"(",
"collectionClass",
")",
")",
"{",
"log",
".",
"fine",
"(",
"\"{0} does not extend collection.\"",
",",
"collectionClass",
")",
";",
"return",
"null",
";",
"}",
"return",
"Cast",
".",
"as",
"(",
"CollectionConverter",
".",
"COLLECTION",
"(",
"Cast",
".",
"<",
"Class",
"<",
"C",
">",
">",
"as",
"(",
"collectionClass",
")",
",",
"componentClass",
")",
".",
"apply",
"(",
"object",
")",
")",
";",
"}"
] |
Convert c.
@param <T> the type parameter
@param <C> the type parameter
@param object the object
@param collectionClass the collection class
@param componentClass the component class
@return the c
|
[
"Convert",
"c",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/conversion/Convert.java#L258-L265
|
145,247
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.getColumRange
|
public static RealMatrix getColumRange (RealMatrix matrix, int start, int end) {
return matrix.getSubMatrix(0, matrix.getRowDimension() - 1, start, end);
}
|
java
|
public static RealMatrix getColumRange (RealMatrix matrix, int start, int end) {
return matrix.getSubMatrix(0, matrix.getRowDimension() - 1, start, end);
}
|
[
"public",
"static",
"RealMatrix",
"getColumRange",
"(",
"RealMatrix",
"matrix",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"matrix",
".",
"getSubMatrix",
"(",
"0",
",",
"matrix",
".",
"getRowDimension",
"(",
")",
"-",
"1",
",",
"start",
",",
"end",
")",
";",
"}"
] |
Returns the column range from the matrix as a new matrix.
@param matrix The input matrix
@param start The index of the column to start with (inclusive)
@param end The index of the column to end with (inclusive)
@return A new matrix with columns specified
|
[
"Returns",
"the",
"column",
"range",
"from",
"the",
"matrix",
"as",
"a",
"new",
"matrix",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L42-L44
|
145,248
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.getRowRange
|
public static RealMatrix getRowRange (RealMatrix matrix, int start, int end) {
return matrix.getSubMatrix(start, end, 0, matrix.getColumnDimension() - 1);
}
|
java
|
public static RealMatrix getRowRange (RealMatrix matrix, int start, int end) {
return matrix.getSubMatrix(start, end, 0, matrix.getColumnDimension() - 1);
}
|
[
"public",
"static",
"RealMatrix",
"getRowRange",
"(",
"RealMatrix",
"matrix",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"matrix",
".",
"getSubMatrix",
"(",
"start",
",",
"end",
",",
"0",
",",
"matrix",
".",
"getColumnDimension",
"(",
")",
"-",
"1",
")",
";",
"}"
] |
Returns the row range from the matrix as a new matrix.
@param matrix The input matrix
@param start The index of the row to start with (inclusive)
@param end The index of the row to end with (inclusive)
@return A new matrix with rows specified
|
[
"Returns",
"the",
"row",
"range",
"from",
"the",
"matrix",
"as",
"a",
"new",
"matrix",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L54-L56
|
145,249
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.colSums
|
public static double[] colSums (RealMatrix matrix) {
// Declare and initialize the return value:
double[] retval = new double[matrix.getColumnDimension()];
// Iterate over columns and compute totals:
for (int col = 0; col < matrix.getColumnDimension(); col++) {
for (int row = 0; row < matrix.getRowDimension(); row++) {
retval[col] += matrix.getEntry(row, col);
}
}
// Done, return col sums:
return retval;
}
|
java
|
public static double[] colSums (RealMatrix matrix) {
// Declare and initialize the return value:
double[] retval = new double[matrix.getColumnDimension()];
// Iterate over columns and compute totals:
for (int col = 0; col < matrix.getColumnDimension(); col++) {
for (int row = 0; row < matrix.getRowDimension(); row++) {
retval[col] += matrix.getEntry(row, col);
}
}
// Done, return col sums:
return retval;
}
|
[
"public",
"static",
"double",
"[",
"]",
"colSums",
"(",
"RealMatrix",
"matrix",
")",
"{",
"// Declare and initialize the return value:",
"double",
"[",
"]",
"retval",
"=",
"new",
"double",
"[",
"matrix",
".",
"getColumnDimension",
"(",
")",
"]",
";",
"// Iterate over columns and compute totals:",
"for",
"(",
"int",
"col",
"=",
"0",
";",
"col",
"<",
"matrix",
".",
"getColumnDimension",
"(",
")",
";",
"col",
"++",
")",
"{",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"matrix",
".",
"getRowDimension",
"(",
")",
";",
"row",
"++",
")",
"{",
"retval",
"[",
"col",
"]",
"+=",
"matrix",
".",
"getEntry",
"(",
"row",
",",
"col",
")",
";",
"}",
"}",
"// Done, return col sums:",
"return",
"retval",
";",
"}"
] |
Returns the sums of columns.
@param matrix The matrix of which the sums of columns to be computed
@return A double array of column sums
|
[
"Returns",
"the",
"sums",
"of",
"columns",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L64-L77
|
145,250
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.colMeans
|
public static double[] colMeans (RealMatrix matrix) {
// Get the col sums:
double[] retval = EMatrixUtils.colSums(matrix);
// Iterate over return value and divide by the length:
for (int i = 0; i < retval.length; i++) {
retval[i] = retval[i] / matrix.getRowDimension();
}
// Done, return col means:
return retval;
}
|
java
|
public static double[] colMeans (RealMatrix matrix) {
// Get the col sums:
double[] retval = EMatrixUtils.colSums(matrix);
// Iterate over return value and divide by the length:
for (int i = 0; i < retval.length; i++) {
retval[i] = retval[i] / matrix.getRowDimension();
}
// Done, return col means:
return retval;
}
|
[
"public",
"static",
"double",
"[",
"]",
"colMeans",
"(",
"RealMatrix",
"matrix",
")",
"{",
"// Get the col sums:",
"double",
"[",
"]",
"retval",
"=",
"EMatrixUtils",
".",
"colSums",
"(",
"matrix",
")",
";",
"// Iterate over return value and divide by the length:",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"retval",
".",
"length",
";",
"i",
"++",
")",
"{",
"retval",
"[",
"i",
"]",
"=",
"retval",
"[",
"i",
"]",
"/",
"matrix",
".",
"getRowDimension",
"(",
")",
";",
"}",
"// Done, return col means:",
"return",
"retval",
";",
"}"
] |
Returns the means of columns.
@param matrix The matrix of which the means of columns to be computed
@return A double array of column means
|
[
"Returns",
"the",
"means",
"of",
"columns",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L106-L117
|
145,251
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.rowMeans
|
public static double[] rowMeans (RealMatrix matrix) {
// Get the col sums:
double[] retval = EMatrixUtils.rowSums(matrix);
// Iterate over return value and divide by the length:
for (int i = 0; i < retval.length; i++) {
retval[i] = retval[i] / matrix.getColumnDimension();
}
// Done, return row means:
return retval;
}
|
java
|
public static double[] rowMeans (RealMatrix matrix) {
// Get the col sums:
double[] retval = EMatrixUtils.rowSums(matrix);
// Iterate over return value and divide by the length:
for (int i = 0; i < retval.length; i++) {
retval[i] = retval[i] / matrix.getColumnDimension();
}
// Done, return row means:
return retval;
}
|
[
"public",
"static",
"double",
"[",
"]",
"rowMeans",
"(",
"RealMatrix",
"matrix",
")",
"{",
"// Get the col sums:",
"double",
"[",
"]",
"retval",
"=",
"EMatrixUtils",
".",
"rowSums",
"(",
"matrix",
")",
";",
"// Iterate over return value and divide by the length:",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"retval",
".",
"length",
";",
"i",
"++",
")",
"{",
"retval",
"[",
"i",
"]",
"=",
"retval",
"[",
"i",
"]",
"/",
"matrix",
".",
"getColumnDimension",
"(",
")",
";",
"}",
"// Done, return row means:",
"return",
"retval",
";",
"}"
] |
Returns the means of rows.
@param matrix The matrix of which the means of rows to be computed
@return A double array of row means
|
[
"Returns",
"the",
"means",
"of",
"rows",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L125-L136
|
145,252
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.colSubtract
|
public static RealMatrix colSubtract (RealMatrix matrix, double[] vector) {
// Declare and initialize the new matrix:
double[][] retval = new double[matrix.getRowDimension()][matrix.getColumnDimension()];
// Iterate over rows:
for (int col = 0; col < retval.length; col++) {
// Iterate over columns:
for (int row = 0; row < retval[0].length; row++) {
retval[row][col] = matrix.getEntry(row, col) - vector[row];
}
}
// Done, return a new matrix:
return MatrixUtils.createRealMatrix(retval);
}
|
java
|
public static RealMatrix colSubtract (RealMatrix matrix, double[] vector) {
// Declare and initialize the new matrix:
double[][] retval = new double[matrix.getRowDimension()][matrix.getColumnDimension()];
// Iterate over rows:
for (int col = 0; col < retval.length; col++) {
// Iterate over columns:
for (int row = 0; row < retval[0].length; row++) {
retval[row][col] = matrix.getEntry(row, col) - vector[row];
}
}
// Done, return a new matrix:
return MatrixUtils.createRealMatrix(retval);
}
|
[
"public",
"static",
"RealMatrix",
"colSubtract",
"(",
"RealMatrix",
"matrix",
",",
"double",
"[",
"]",
"vector",
")",
"{",
"// Declare and initialize the new matrix:",
"double",
"[",
"]",
"[",
"]",
"retval",
"=",
"new",
"double",
"[",
"matrix",
".",
"getRowDimension",
"(",
")",
"]",
"[",
"matrix",
".",
"getColumnDimension",
"(",
")",
"]",
";",
"// Iterate over rows:",
"for",
"(",
"int",
"col",
"=",
"0",
";",
"col",
"<",
"retval",
".",
"length",
";",
"col",
"++",
")",
"{",
"// Iterate over columns:",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"retval",
"[",
"0",
"]",
".",
"length",
";",
"row",
"++",
")",
"{",
"retval",
"[",
"row",
"]",
"[",
"col",
"]",
"=",
"matrix",
".",
"getEntry",
"(",
"row",
",",
"col",
")",
"-",
"vector",
"[",
"row",
"]",
";",
"}",
"}",
"// Done, return a new matrix:",
"return",
"MatrixUtils",
".",
"createRealMatrix",
"(",
"retval",
")",
";",
"}"
] |
Returns a new matrix by subtracting elements column by column.
@param matrix The input matrix
@param vector The vector to be subtracted from columns
@return A new matrix of which the vector is subtracted column by column
|
[
"Returns",
"a",
"new",
"matrix",
"by",
"subtracting",
"elements",
"column",
"by",
"column",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L145-L159
|
145,253
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.columnStdDevs
|
public static double[] columnStdDevs(RealMatrix matrix) {
double[] retval = new double[matrix.getColumnDimension()];
for (int i = 0; i < retval.length; i++) {
retval[i] = new DescriptiveStatistics(matrix.getColumn(i)).getStandardDeviation();
}
return retval;
}
|
java
|
public static double[] columnStdDevs(RealMatrix matrix) {
double[] retval = new double[matrix.getColumnDimension()];
for (int i = 0; i < retval.length; i++) {
retval[i] = new DescriptiveStatistics(matrix.getColumn(i)).getStandardDeviation();
}
return retval;
}
|
[
"public",
"static",
"double",
"[",
"]",
"columnStdDevs",
"(",
"RealMatrix",
"matrix",
")",
"{",
"double",
"[",
"]",
"retval",
"=",
"new",
"double",
"[",
"matrix",
".",
"getColumnDimension",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"retval",
".",
"length",
";",
"i",
"++",
")",
"{",
"retval",
"[",
"i",
"]",
"=",
"new",
"DescriptiveStatistics",
"(",
"matrix",
".",
"getColumn",
"(",
"i",
")",
")",
".",
"getStandardDeviation",
"(",
")",
";",
"}",
"return",
"retval",
";",
"}"
] |
Returns the standard deviations of columns.
@param matrix The matrix of which the standard deviations of columns to be computed
@return A double array of column standard deviations.
|
[
"Returns",
"the",
"standard",
"deviations",
"of",
"columns",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L236-L242
|
145,254
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.rowStdDevs
|
public static double[] rowStdDevs(RealMatrix matrix) {
double[] retval = new double[matrix.getRowDimension()];
for (int i = 0; i < retval.length; i++) {
retval[i] = new DescriptiveStatistics(matrix.getRow(i)).getStandardDeviation();
}
return retval;
}
|
java
|
public static double[] rowStdDevs(RealMatrix matrix) {
double[] retval = new double[matrix.getRowDimension()];
for (int i = 0; i < retval.length; i++) {
retval[i] = new DescriptiveStatistics(matrix.getRow(i)).getStandardDeviation();
}
return retval;
}
|
[
"public",
"static",
"double",
"[",
"]",
"rowStdDevs",
"(",
"RealMatrix",
"matrix",
")",
"{",
"double",
"[",
"]",
"retval",
"=",
"new",
"double",
"[",
"matrix",
".",
"getRowDimension",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"retval",
".",
"length",
";",
"i",
"++",
")",
"{",
"retval",
"[",
"i",
"]",
"=",
"new",
"DescriptiveStatistics",
"(",
"matrix",
".",
"getRow",
"(",
"i",
")",
")",
".",
"getStandardDeviation",
"(",
")",
";",
"}",
"return",
"retval",
";",
"}"
] |
Returns the standard deviations of rows.
@param matrix The matrix of which the standard deviations of rows to be computed
@return A double array of row standard deviations.
|
[
"Returns",
"the",
"standard",
"deviations",
"of",
"rows",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L250-L256
|
145,255
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.rbrMultiply
|
public static RealMatrix rbrMultiply(RealMatrix matrix, RealVector vector) {
// Define the return value:
RealMatrix retval = MatrixUtils.createRealMatrix(matrix.getRowDimension(), matrix.getColumnDimension());
// Iterate over rows:
for (int i = 0; i < retval.getRowDimension(); i++) {
retval.setRowVector(i, matrix.getRowVector(i).ebeMultiply(vector));
}
// Done, return:
return retval;
}
|
java
|
public static RealMatrix rbrMultiply(RealMatrix matrix, RealVector vector) {
// Define the return value:
RealMatrix retval = MatrixUtils.createRealMatrix(matrix.getRowDimension(), matrix.getColumnDimension());
// Iterate over rows:
for (int i = 0; i < retval.getRowDimension(); i++) {
retval.setRowVector(i, matrix.getRowVector(i).ebeMultiply(vector));
}
// Done, return:
return retval;
}
|
[
"public",
"static",
"RealMatrix",
"rbrMultiply",
"(",
"RealMatrix",
"matrix",
",",
"RealVector",
"vector",
")",
"{",
"// Define the return value:",
"RealMatrix",
"retval",
"=",
"MatrixUtils",
".",
"createRealMatrix",
"(",
"matrix",
".",
"getRowDimension",
"(",
")",
",",
"matrix",
".",
"getColumnDimension",
"(",
")",
")",
";",
"// Iterate over rows:",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"retval",
".",
"getRowDimension",
"(",
")",
";",
"i",
"++",
")",
"{",
"retval",
".",
"setRowVector",
"(",
"i",
",",
"matrix",
".",
"getRowVector",
"(",
"i",
")",
".",
"ebeMultiply",
"(",
"vector",
")",
")",
";",
"}",
"// Done, return:",
"return",
"retval",
";",
"}"
] |
Multiplies the matrix' rows using the vector element-by-element.
@param matrix The input matrix.
@param vector The vector which will be used to multiply rows of the matrix element-by-element.
@return The new matrix of which rows are multiplied with the vector element-by-element.
|
[
"Multiplies",
"the",
"matrix",
"rows",
"using",
"the",
"vector",
"element",
"-",
"by",
"-",
"element",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L265-L276
|
145,256
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.rbind
|
public static RealMatrix rbind (RealMatrix m1, RealMatrix m2) {
return MatrixUtils.createRealMatrix(ArrayUtils.addAll(m1.getData(), m2.getData()));
}
|
java
|
public static RealMatrix rbind (RealMatrix m1, RealMatrix m2) {
return MatrixUtils.createRealMatrix(ArrayUtils.addAll(m1.getData(), m2.getData()));
}
|
[
"public",
"static",
"RealMatrix",
"rbind",
"(",
"RealMatrix",
"m1",
",",
"RealMatrix",
"m2",
")",
"{",
"return",
"MatrixUtils",
".",
"createRealMatrix",
"(",
"ArrayUtils",
".",
"addAll",
"(",
"m1",
".",
"getData",
"(",
")",
",",
"m2",
".",
"getData",
"(",
")",
")",
")",
";",
"}"
] |
Appends to matrices by rows.
@param m1 The first matrix
@param m2 The second matrix.
@return Returns the new row-bound matrix.
|
[
"Appends",
"to",
"matrices",
"by",
"rows",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L285-L287
|
145,257
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java
|
EMatrixUtils.shuffleRows
|
public static RealMatrix shuffleRows (RealMatrix matrix, RandomGenerator randomGenerator) {
// Create an index vector to be shuffled:
int[] index = MathArrays.sequence(matrix.getRowDimension(), 0, 1);
MathArrays.shuffle(index, randomGenerator);
// Create a new matrix:
RealMatrix retval = MatrixUtils.createRealMatrix(matrix.getRowDimension(), matrix.getColumnDimension());
// Populate:
for (int row = 0; row < index.length; row++) {
retval.setRowVector(row, matrix.getRowVector(index[row]));
}
// Done, return:
return retval;
}
|
java
|
public static RealMatrix shuffleRows (RealMatrix matrix, RandomGenerator randomGenerator) {
// Create an index vector to be shuffled:
int[] index = MathArrays.sequence(matrix.getRowDimension(), 0, 1);
MathArrays.shuffle(index, randomGenerator);
// Create a new matrix:
RealMatrix retval = MatrixUtils.createRealMatrix(matrix.getRowDimension(), matrix.getColumnDimension());
// Populate:
for (int row = 0; row < index.length; row++) {
retval.setRowVector(row, matrix.getRowVector(index[row]));
}
// Done, return:
return retval;
}
|
[
"public",
"static",
"RealMatrix",
"shuffleRows",
"(",
"RealMatrix",
"matrix",
",",
"RandomGenerator",
"randomGenerator",
")",
"{",
"// Create an index vector to be shuffled:",
"int",
"[",
"]",
"index",
"=",
"MathArrays",
".",
"sequence",
"(",
"matrix",
".",
"getRowDimension",
"(",
")",
",",
"0",
",",
"1",
")",
";",
"MathArrays",
".",
"shuffle",
"(",
"index",
",",
"randomGenerator",
")",
";",
"// Create a new matrix:",
"RealMatrix",
"retval",
"=",
"MatrixUtils",
".",
"createRealMatrix",
"(",
"matrix",
".",
"getRowDimension",
"(",
")",
",",
"matrix",
".",
"getColumnDimension",
"(",
")",
")",
";",
"// Populate:",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"index",
".",
"length",
";",
"row",
"++",
")",
"{",
"retval",
".",
"setRowVector",
"(",
"row",
",",
"matrix",
".",
"getRowVector",
"(",
"index",
"[",
"row",
"]",
")",
")",
";",
"}",
"// Done, return:",
"return",
"retval",
";",
"}"
] |
Shuffles rows of a matrix using the provided random number generator.
@param matrix The matrix of which the rows will be shuffled.
@param randomGenerator The random number generator to be used.
@return The new shuffled matrix.
|
[
"Shuffles",
"rows",
"of",
"a",
"matrix",
"using",
"the",
"provided",
"random",
"number",
"generator",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/EMatrixUtils.java#L306-L321
|
145,258
|
duraspace/fcrepo-cloudsync
|
fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/dao/UserDao.java
|
UserDao.getCurrentUserName
|
private static String getCurrentUserName() {
Authentication a = SecurityContextHolder.getContext().getAuthentication();
if (a == null) return null;
org.springframework.security.core.userdetails.User u =
(org.springframework.security.core.userdetails.User)
a.getPrincipal();
if (u == null) return null;
return u.getUsername();
}
|
java
|
private static String getCurrentUserName() {
Authentication a = SecurityContextHolder.getContext().getAuthentication();
if (a == null) return null;
org.springframework.security.core.userdetails.User u =
(org.springframework.security.core.userdetails.User)
a.getPrincipal();
if (u == null) return null;
return u.getUsername();
}
|
[
"private",
"static",
"String",
"getCurrentUserName",
"(",
")",
"{",
"Authentication",
"a",
"=",
"SecurityContextHolder",
".",
"getContext",
"(",
")",
".",
"getAuthentication",
"(",
")",
";",
"if",
"(",
"a",
"==",
"null",
")",
"return",
"null",
";",
"org",
".",
"springframework",
".",
"security",
".",
"core",
".",
"userdetails",
".",
"User",
"u",
"=",
"(",
"org",
".",
"springframework",
".",
"security",
".",
"core",
".",
"userdetails",
".",
"User",
")",
"a",
".",
"getPrincipal",
"(",
")",
";",
"if",
"(",
"u",
"==",
"null",
")",
"return",
"null",
";",
"return",
"u",
".",
"getUsername",
"(",
")",
";",
"}"
] |
or null if nobody's logged in
|
[
"or",
"null",
"if",
"nobody",
"s",
"logged",
"in"
] |
2d90e2c9c84a827f2605607ff40e116c67eff9b9
|
https://github.com/duraspace/fcrepo-cloudsync/blob/2d90e2c9c84a827f2605607ff40e116c67eff9b9/fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/dao/UserDao.java#L237-L245
|
145,259
|
misha/iroh
|
src/main/java/com/github/msoliter/iroh/container/sources/base/Source.java
|
Source.getInstance
|
public Object getInstance() {
try {
if (prototype) {
return doGetInstance();
} else {
synchronized (cache) {
if (!cache.containsKey(type)) {
cache.put(type, doGetInstance());
}
return cache.get(type);
}
}
} catch (IrohException e) {
throw e;
} catch (Exception e) {
throw new FailedConstructionException(e);
}
}
|
java
|
public Object getInstance() {
try {
if (prototype) {
return doGetInstance();
} else {
synchronized (cache) {
if (!cache.containsKey(type)) {
cache.put(type, doGetInstance());
}
return cache.get(type);
}
}
} catch (IrohException e) {
throw e;
} catch (Exception e) {
throw new FailedConstructionException(e);
}
}
|
[
"public",
"Object",
"getInstance",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"prototype",
")",
"{",
"return",
"doGetInstance",
"(",
")",
";",
"}",
"else",
"{",
"synchronized",
"(",
"cache",
")",
"{",
"if",
"(",
"!",
"cache",
".",
"containsKey",
"(",
"type",
")",
")",
"{",
"cache",
".",
"put",
"(",
"type",
",",
"doGetInstance",
"(",
")",
")",
";",
"}",
"return",
"cache",
".",
"get",
"(",
"type",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IrohException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"FailedConstructionException",
"(",
"e",
")",
";",
"}",
"}"
] |
Retrieves an instance of this source's type, respecting scoping rules.
@return An instance of this source's type.
|
[
"Retrieves",
"an",
"instance",
"of",
"this",
"source",
"s",
"type",
"respecting",
"scoping",
"rules",
"."
] |
5dc92a01d3b2f3ba63e8ad1bf9b5fe342d0b679a
|
https://github.com/misha/iroh/blob/5dc92a01d3b2f3ba63e8ad1bf9b5fe342d0b679a/src/main/java/com/github/msoliter/iroh/container/sources/base/Source.java#L74-L95
|
145,260
|
josueeduardo/snappy
|
snappy/src/main/java/io/joshworks/snappy/http/HttpExchange.java
|
HttpExchange.setNegotiatedContentType
|
private void setNegotiatedContentType() {
ConnegHandler.NegotiatedMediaType negotiatedMediaType = exchange.getAttachment(ConnegHandler.NEGOTIATED_MEDIA_TYPE);
MediaType negotiated = negotiatedMediaType == null ? responseContentType : negotiatedMediaType.produces;
setResponseMediaType(negotiated);
}
|
java
|
private void setNegotiatedContentType() {
ConnegHandler.NegotiatedMediaType negotiatedMediaType = exchange.getAttachment(ConnegHandler.NEGOTIATED_MEDIA_TYPE);
MediaType negotiated = negotiatedMediaType == null ? responseContentType : negotiatedMediaType.produces;
setResponseMediaType(negotiated);
}
|
[
"private",
"void",
"setNegotiatedContentType",
"(",
")",
"{",
"ConnegHandler",
".",
"NegotiatedMediaType",
"negotiatedMediaType",
"=",
"exchange",
".",
"getAttachment",
"(",
"ConnegHandler",
".",
"NEGOTIATED_MEDIA_TYPE",
")",
";",
"MediaType",
"negotiated",
"=",
"negotiatedMediaType",
"==",
"null",
"?",
"responseContentType",
":",
"negotiatedMediaType",
".",
"produces",
";",
"setResponseMediaType",
"(",
"negotiated",
")",
";",
"}"
] |
If client accepts anything, json will be used
|
[
"If",
"client",
"accepts",
"anything",
"json",
"will",
"be",
"used"
] |
d95a9e811eda3c24a5e53086369208819884fa49
|
https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/snappy/src/main/java/io/joshworks/snappy/http/HttpExchange.java#L36-L40
|
145,261
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVector.java
|
ConcatVector.newEmptyClone
|
public ConcatVector newEmptyClone() {
ConcatVector clone = new ConcatVector(getNumberOfComponents());
for (int i = 0; i < pointers.length; i++) {
if (pointers[i] != null && !sparse[i]) {
clone.pointers[i] = new double[pointers[i].length];
clone.sparse[i] = false;
}
}
return clone;
}
|
java
|
public ConcatVector newEmptyClone() {
ConcatVector clone = new ConcatVector(getNumberOfComponents());
for (int i = 0; i < pointers.length; i++) {
if (pointers[i] != null && !sparse[i]) {
clone.pointers[i] = new double[pointers[i].length];
clone.sparse[i] = false;
}
}
return clone;
}
|
[
"public",
"ConcatVector",
"newEmptyClone",
"(",
")",
"{",
"ConcatVector",
"clone",
"=",
"new",
"ConcatVector",
"(",
"getNumberOfComponents",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pointers",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pointers",
"[",
"i",
"]",
"!=",
"null",
"&&",
"!",
"sparse",
"[",
"i",
"]",
")",
"{",
"clone",
".",
"pointers",
"[",
"i",
"]",
"=",
"new",
"double",
"[",
"pointers",
"[",
"i",
"]",
".",
"length",
"]",
";",
"clone",
".",
"sparse",
"[",
"i",
"]",
"=",
"false",
";",
"}",
"}",
"return",
"clone",
";",
"}"
] |
Creates a ConcatVector whose dimensions are the same as this one for all dense components, but is otherwise
completely empty. This is useful to prevent resizing during optimizations where we're adding lots of sparse
vectors.
@return an empty vector suitable for use as a gradient
|
[
"Creates",
"a",
"ConcatVector",
"whose",
"dimensions",
"are",
"the",
"same",
"as",
"this",
"one",
"for",
"all",
"dense",
"components",
"but",
"is",
"otherwise",
"completely",
"empty",
".",
"This",
"is",
"useful",
"to",
"prevent",
"resizing",
"during",
"optimizations",
"where",
"we",
"re",
"adding",
"lots",
"of",
"sparse",
"vectors",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVector.java#L69-L78
|
145,262
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVector.java
|
ConcatVector.setDenseComponent
|
public void setDenseComponent(int component, double[] values) {
if (component >= pointers.length) {
increaseSizeTo(component + 1);
}
pointers[component] = values;
sparse[component] = false;
copyOnWrite[component] = true;
}
|
java
|
public void setDenseComponent(int component, double[] values) {
if (component >= pointers.length) {
increaseSizeTo(component + 1);
}
pointers[component] = values;
sparse[component] = false;
copyOnWrite[component] = true;
}
|
[
"public",
"void",
"setDenseComponent",
"(",
"int",
"component",
",",
"double",
"[",
"]",
"values",
")",
"{",
"if",
"(",
"component",
">=",
"pointers",
".",
"length",
")",
"{",
"increaseSizeTo",
"(",
"component",
"+",
"1",
")",
";",
"}",
"pointers",
"[",
"component",
"]",
"=",
"values",
";",
"sparse",
"[",
"component",
"]",
"=",
"false",
";",
"copyOnWrite",
"[",
"component",
"]",
"=",
"true",
";",
"}"
] |
Sets a single component of the concat vector value as a dense vector. This will make a copy of you values array,
so you're free to continue mutating it.
@param component the index of the component to set
@param values the array of dense values to put into the component
|
[
"Sets",
"a",
"single",
"component",
"of",
"the",
"concat",
"vector",
"value",
"as",
"a",
"dense",
"vector",
".",
"This",
"will",
"make",
"a",
"copy",
"of",
"you",
"values",
"array",
"so",
"you",
"re",
"free",
"to",
"continue",
"mutating",
"it",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVector.java#L87-L94
|
145,263
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVector.java
|
ConcatVector.setSparseComponent
|
public void setSparseComponent(int component, int index, double value) {
if (component >= pointers.length) {
increaseSizeTo(component + 1);
}
double[] sparseInfo = new double[2];
sparseInfo[0] = index;
sparseInfo[1] = value;
pointers[component] = sparseInfo;
sparse[component] = true;
copyOnWrite[component] = false;
}
|
java
|
public void setSparseComponent(int component, int index, double value) {
if (component >= pointers.length) {
increaseSizeTo(component + 1);
}
double[] sparseInfo = new double[2];
sparseInfo[0] = index;
sparseInfo[1] = value;
pointers[component] = sparseInfo;
sparse[component] = true;
copyOnWrite[component] = false;
}
|
[
"public",
"void",
"setSparseComponent",
"(",
"int",
"component",
",",
"int",
"index",
",",
"double",
"value",
")",
"{",
"if",
"(",
"component",
">=",
"pointers",
".",
"length",
")",
"{",
"increaseSizeTo",
"(",
"component",
"+",
"1",
")",
";",
"}",
"double",
"[",
"]",
"sparseInfo",
"=",
"new",
"double",
"[",
"2",
"]",
";",
"sparseInfo",
"[",
"0",
"]",
"=",
"index",
";",
"sparseInfo",
"[",
"1",
"]",
"=",
"value",
";",
"pointers",
"[",
"component",
"]",
"=",
"sparseInfo",
";",
"sparse",
"[",
"component",
"]",
"=",
"true",
";",
"copyOnWrite",
"[",
"component",
"]",
"=",
"false",
";",
"}"
] |
Sets a single component of the concat vector value as a sparse, one hot value.
@param component the index of the component to set
@param index the index of the vector to one-hot
@param value the value of that index
|
[
"Sets",
"a",
"single",
"component",
"of",
"the",
"concat",
"vector",
"value",
"as",
"a",
"sparse",
"one",
"hot",
"value",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVector.java#L103-L113
|
145,264
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVector.java
|
ConcatVector.setSparseComponent
|
public void setSparseComponent(int component, int[] indices, double[] values) {
if (component >= pointers.length) {
increaseSizeTo(component + 1);
}
assert (indices.length == values.length);
if (indices.length == 0) {
pointers[component] = new double[2];
sparse[component] = true;
copyOnWrite[component] = false;
} else {
double[] sparseInfo = new double[indices.length * 2];
for (int i = 0; i < indices.length; i++) {
sparseInfo[i * 2] = indices[i];
sparseInfo[(i * 2) + 1] = values[i];
}
pointers[component] = sparseInfo;
sparse[component] = true;
copyOnWrite[component] = false;
}
}
|
java
|
public void setSparseComponent(int component, int[] indices, double[] values) {
if (component >= pointers.length) {
increaseSizeTo(component + 1);
}
assert (indices.length == values.length);
if (indices.length == 0) {
pointers[component] = new double[2];
sparse[component] = true;
copyOnWrite[component] = false;
} else {
double[] sparseInfo = new double[indices.length * 2];
for (int i = 0; i < indices.length; i++) {
sparseInfo[i * 2] = indices[i];
sparseInfo[(i * 2) + 1] = values[i];
}
pointers[component] = sparseInfo;
sparse[component] = true;
copyOnWrite[component] = false;
}
}
|
[
"public",
"void",
"setSparseComponent",
"(",
"int",
"component",
",",
"int",
"[",
"]",
"indices",
",",
"double",
"[",
"]",
"values",
")",
"{",
"if",
"(",
"component",
">=",
"pointers",
".",
"length",
")",
"{",
"increaseSizeTo",
"(",
"component",
"+",
"1",
")",
";",
"}",
"assert",
"(",
"indices",
".",
"length",
"==",
"values",
".",
"length",
")",
";",
"if",
"(",
"indices",
".",
"length",
"==",
"0",
")",
"{",
"pointers",
"[",
"component",
"]",
"=",
"new",
"double",
"[",
"2",
"]",
";",
"sparse",
"[",
"component",
"]",
"=",
"true",
";",
"copyOnWrite",
"[",
"component",
"]",
"=",
"false",
";",
"}",
"else",
"{",
"double",
"[",
"]",
"sparseInfo",
"=",
"new",
"double",
"[",
"indices",
".",
"length",
"*",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"indices",
".",
"length",
";",
"i",
"++",
")",
"{",
"sparseInfo",
"[",
"i",
"*",
"2",
"]",
"=",
"indices",
"[",
"i",
"]",
";",
"sparseInfo",
"[",
"(",
"i",
"*",
"2",
")",
"+",
"1",
"]",
"=",
"values",
"[",
"i",
"]",
";",
"}",
"pointers",
"[",
"component",
"]",
"=",
"sparseInfo",
";",
"sparse",
"[",
"component",
"]",
"=",
"true",
";",
"copyOnWrite",
"[",
"component",
"]",
"=",
"false",
";",
"}",
"}"
] |
Sets a component to a set of sparse indices, each with a value.
@param component the index of the component to set
@param indices the indices of the vector to give values to
@param values their values
|
[
"Sets",
"a",
"component",
"to",
"a",
"set",
"of",
"sparse",
"indices",
"each",
"with",
"a",
"value",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVector.java#L122-L143
|
145,265
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVector.java
|
ConcatVector.dotProduct
|
public double dotProduct(ConcatVector other) {
if (loadedNative) {
return dotProductNative(other);
} else {
double sum = 0.0f;
for (int i = 0; i < Math.min(pointers.length, other.pointers.length); i++) {
if (pointers[i] == null || other.pointers[i] == null) continue;
if (sparse[i] && other.sparse[i]) {
outer:
for (int j = 0; j < pointers[i].length / 2; j++) {
int sparseIndex = (int) pointers[i][j * 2];
for (int k = 0; k < other.pointers[i].length / 2; k++) {
int otherSparseIndex = (int) other.pointers[i][k * 2];
if (sparseIndex == otherSparseIndex) {
sum += pointers[i][(j * 2) + 1] * other.pointers[i][(k * 2) + 1];
continue outer;
}
}
}
} else if (sparse[i] && !other.sparse[i]) {
for (int j = 0; j < pointers[i].length / 2; j++) {
int sparseIndex = (int) pointers[i][j * 2];
if (sparseIndex >= 0 && sparseIndex < other.pointers[i].length) {
sum += other.pointers[i][sparseIndex] * pointers[i][(j * 2) + 1];
}
}
} else if (!sparse[i] && other.sparse[i]) {
for (int j = 0; j < other.pointers[i].length / 2; j++) {
int sparseIndex = (int) other.pointers[i][j * 2];
if (sparseIndex >= 0 && sparseIndex < pointers[i].length) {
sum += pointers[i][sparseIndex] * other.pointers[i][(j * 2) + 1];
}
}
} else {
for (int j = 0; j < Math.min(pointers[i].length, other.pointers[i].length); j++) {
sum += pointers[i][j] * other.pointers[i][j];
}
}
}
return sum;
}
}
|
java
|
public double dotProduct(ConcatVector other) {
if (loadedNative) {
return dotProductNative(other);
} else {
double sum = 0.0f;
for (int i = 0; i < Math.min(pointers.length, other.pointers.length); i++) {
if (pointers[i] == null || other.pointers[i] == null) continue;
if (sparse[i] && other.sparse[i]) {
outer:
for (int j = 0; j < pointers[i].length / 2; j++) {
int sparseIndex = (int) pointers[i][j * 2];
for (int k = 0; k < other.pointers[i].length / 2; k++) {
int otherSparseIndex = (int) other.pointers[i][k * 2];
if (sparseIndex == otherSparseIndex) {
sum += pointers[i][(j * 2) + 1] * other.pointers[i][(k * 2) + 1];
continue outer;
}
}
}
} else if (sparse[i] && !other.sparse[i]) {
for (int j = 0; j < pointers[i].length / 2; j++) {
int sparseIndex = (int) pointers[i][j * 2];
if (sparseIndex >= 0 && sparseIndex < other.pointers[i].length) {
sum += other.pointers[i][sparseIndex] * pointers[i][(j * 2) + 1];
}
}
} else if (!sparse[i] && other.sparse[i]) {
for (int j = 0; j < other.pointers[i].length / 2; j++) {
int sparseIndex = (int) other.pointers[i][j * 2];
if (sparseIndex >= 0 && sparseIndex < pointers[i].length) {
sum += pointers[i][sparseIndex] * other.pointers[i][(j * 2) + 1];
}
}
} else {
for (int j = 0; j < Math.min(pointers[i].length, other.pointers[i].length); j++) {
sum += pointers[i][j] * other.pointers[i][j];
}
}
}
return sum;
}
}
|
[
"public",
"double",
"dotProduct",
"(",
"ConcatVector",
"other",
")",
"{",
"if",
"(",
"loadedNative",
")",
"{",
"return",
"dotProductNative",
"(",
"other",
")",
";",
"}",
"else",
"{",
"double",
"sum",
"=",
"0.0f",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"Math",
".",
"min",
"(",
"pointers",
".",
"length",
",",
"other",
".",
"pointers",
".",
"length",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pointers",
"[",
"i",
"]",
"==",
"null",
"||",
"other",
".",
"pointers",
"[",
"i",
"]",
"==",
"null",
")",
"continue",
";",
"if",
"(",
"sparse",
"[",
"i",
"]",
"&&",
"other",
".",
"sparse",
"[",
"i",
"]",
")",
"{",
"outer",
":",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"pointers",
"[",
"i",
"]",
".",
"length",
"/",
"2",
";",
"j",
"++",
")",
"{",
"int",
"sparseIndex",
"=",
"(",
"int",
")",
"pointers",
"[",
"i",
"]",
"[",
"j",
"*",
"2",
"]",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"other",
".",
"pointers",
"[",
"i",
"]",
".",
"length",
"/",
"2",
";",
"k",
"++",
")",
"{",
"int",
"otherSparseIndex",
"=",
"(",
"int",
")",
"other",
".",
"pointers",
"[",
"i",
"]",
"[",
"k",
"*",
"2",
"]",
";",
"if",
"(",
"sparseIndex",
"==",
"otherSparseIndex",
")",
"{",
"sum",
"+=",
"pointers",
"[",
"i",
"]",
"[",
"(",
"j",
"*",
"2",
")",
"+",
"1",
"]",
"*",
"other",
".",
"pointers",
"[",
"i",
"]",
"[",
"(",
"k",
"*",
"2",
")",
"+",
"1",
"]",
";",
"continue",
"outer",
";",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"sparse",
"[",
"i",
"]",
"&&",
"!",
"other",
".",
"sparse",
"[",
"i",
"]",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"pointers",
"[",
"i",
"]",
".",
"length",
"/",
"2",
";",
"j",
"++",
")",
"{",
"int",
"sparseIndex",
"=",
"(",
"int",
")",
"pointers",
"[",
"i",
"]",
"[",
"j",
"*",
"2",
"]",
";",
"if",
"(",
"sparseIndex",
">=",
"0",
"&&",
"sparseIndex",
"<",
"other",
".",
"pointers",
"[",
"i",
"]",
".",
"length",
")",
"{",
"sum",
"+=",
"other",
".",
"pointers",
"[",
"i",
"]",
"[",
"sparseIndex",
"]",
"*",
"pointers",
"[",
"i",
"]",
"[",
"(",
"j",
"*",
"2",
")",
"+",
"1",
"]",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"!",
"sparse",
"[",
"i",
"]",
"&&",
"other",
".",
"sparse",
"[",
"i",
"]",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"other",
".",
"pointers",
"[",
"i",
"]",
".",
"length",
"/",
"2",
";",
"j",
"++",
")",
"{",
"int",
"sparseIndex",
"=",
"(",
"int",
")",
"other",
".",
"pointers",
"[",
"i",
"]",
"[",
"j",
"*",
"2",
"]",
";",
"if",
"(",
"sparseIndex",
">=",
"0",
"&&",
"sparseIndex",
"<",
"pointers",
"[",
"i",
"]",
".",
"length",
")",
"{",
"sum",
"+=",
"pointers",
"[",
"i",
"]",
"[",
"sparseIndex",
"]",
"*",
"other",
".",
"pointers",
"[",
"i",
"]",
"[",
"(",
"j",
"*",
"2",
")",
"+",
"1",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"Math",
".",
"min",
"(",
"pointers",
"[",
"i",
"]",
".",
"length",
",",
"other",
".",
"pointers",
"[",
"i",
"]",
".",
"length",
")",
";",
"j",
"++",
")",
"{",
"sum",
"+=",
"pointers",
"[",
"i",
"]",
"[",
"j",
"]",
"*",
"other",
".",
"pointers",
"[",
"i",
"]",
"[",
"j",
"]",
";",
"}",
"}",
"}",
"return",
"sum",
";",
"}",
"}"
] |
This function assumes both vectors are infinitely padded with 0s, so it won't complain if there's a dim mismatch.
There are no side effects.
@param other the MV to dot product with
@return the dot product of this and other
|
[
"This",
"function",
"assumes",
"both",
"vectors",
"are",
"infinitely",
"padded",
"with",
"0s",
"so",
"it",
"won",
"t",
"complain",
"if",
"there",
"s",
"a",
"dim",
"mismatch",
".",
"There",
"are",
"no",
"side",
"effects",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVector.java#L152-L193
|
145,266
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVector.java
|
ConcatVector.mapInPlace
|
public void mapInPlace(Function<Double, Double> fn) {
for (int i = 0; i < pointers.length; i++) {
if (pointers[i] == null) continue;
if (copyOnWrite[i]) {
copyOnWrite[i] = false;
pointers[i] = pointers[i].clone();
}
if (sparse[i]) {
for (int j = 0; j < pointers[i].length / 2; j++) {
pointers[i][(j * 2) + 1] = fn.apply(pointers[i][(j * 2) + 1]);
}
} else {
for (int j = 0; j < pointers[i].length; j++) {
pointers[i][j] = fn.apply(pointers[i][j]);
}
}
}
}
|
java
|
public void mapInPlace(Function<Double, Double> fn) {
for (int i = 0; i < pointers.length; i++) {
if (pointers[i] == null) continue;
if (copyOnWrite[i]) {
copyOnWrite[i] = false;
pointers[i] = pointers[i].clone();
}
if (sparse[i]) {
for (int j = 0; j < pointers[i].length / 2; j++) {
pointers[i][(j * 2) + 1] = fn.apply(pointers[i][(j * 2) + 1]);
}
} else {
for (int j = 0; j < pointers[i].length; j++) {
pointers[i][j] = fn.apply(pointers[i][j]);
}
}
}
}
|
[
"public",
"void",
"mapInPlace",
"(",
"Function",
"<",
"Double",
",",
"Double",
">",
"fn",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pointers",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pointers",
"[",
"i",
"]",
"==",
"null",
")",
"continue",
";",
"if",
"(",
"copyOnWrite",
"[",
"i",
"]",
")",
"{",
"copyOnWrite",
"[",
"i",
"]",
"=",
"false",
";",
"pointers",
"[",
"i",
"]",
"=",
"pointers",
"[",
"i",
"]",
".",
"clone",
"(",
")",
";",
"}",
"if",
"(",
"sparse",
"[",
"i",
"]",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"pointers",
"[",
"i",
"]",
".",
"length",
"/",
"2",
";",
"j",
"++",
")",
"{",
"pointers",
"[",
"i",
"]",
"[",
"(",
"j",
"*",
"2",
")",
"+",
"1",
"]",
"=",
"fn",
".",
"apply",
"(",
"pointers",
"[",
"i",
"]",
"[",
"(",
"j",
"*",
"2",
")",
"+",
"1",
"]",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"pointers",
"[",
"i",
"]",
".",
"length",
";",
"j",
"++",
")",
"{",
"pointers",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"fn",
".",
"apply",
"(",
"pointers",
"[",
"i",
"]",
"[",
"j",
"]",
")",
";",
"}",
"}",
"}",
"}"
] |
Apply a function to every element of every component of this vector, and replace with the result.
@param fn the function to apply to every element of every component.
|
[
"Apply",
"a",
"function",
"to",
"every",
"element",
"of",
"every",
"component",
"of",
"this",
"vector",
"and",
"replace",
"with",
"the",
"result",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVector.java#L468-L487
|
145,267
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVector.java
|
ConcatVector.getSparseIndices
|
public int[] getSparseIndices(int component) {
assert (sparse[component]);
int[] indices = new int[pointers[component].length / 2];
for (int i = 0; i < pointers[component].length / 2; i++) {
indices[i] = (int) pointers[component][i * 2];
}
return indices;
}
|
java
|
public int[] getSparseIndices(int component) {
assert (sparse[component]);
int[] indices = new int[pointers[component].length / 2];
for (int i = 0; i < pointers[component].length / 2; i++) {
indices[i] = (int) pointers[component][i * 2];
}
return indices;
}
|
[
"public",
"int",
"[",
"]",
"getSparseIndices",
"(",
"int",
"component",
")",
"{",
"assert",
"(",
"sparse",
"[",
"component",
"]",
")",
";",
"int",
"[",
"]",
"indices",
"=",
"new",
"int",
"[",
"pointers",
"[",
"component",
"]",
".",
"length",
"/",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pointers",
"[",
"component",
"]",
".",
"length",
"/",
"2",
";",
"i",
"++",
")",
"{",
"indices",
"[",
"i",
"]",
"=",
"(",
"int",
")",
"pointers",
"[",
"component",
"]",
"[",
"i",
"*",
"2",
"]",
";",
"}",
"return",
"indices",
";",
"}"
] |
Gets you the indices of multi hot in a component, assuming it is sparse. Throws an assert if it isn't.
@param component the index of the sparse component.
@return the index of the one-hot value within that sparse component.
|
[
"Gets",
"you",
"the",
"indices",
"of",
"multi",
"hot",
"in",
"a",
"component",
"assuming",
"it",
"is",
"sparse",
".",
"Throws",
"an",
"assert",
"if",
"it",
"isn",
"t",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVector.java#L559-L566
|
145,268
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVector.java
|
ConcatVector.valueEquals
|
public boolean valueEquals(ConcatVector other, double tolerance) {
for (int i = 0; i < Math.max(pointers.length, other.pointers.length); i++) {
int size = 0;
// Find the maximum non-zero element in this component
if (i < pointers.length && i < other.pointers.length && pointers[i] == null && other.pointers[i] == null) {
size = 0;
} else if (i >= pointers.length || (i < pointers.length && pointers[i] == null)) {
if (i >= other.pointers.length) {
size = 0;
} else if (other.sparse[i]) {
size = other.getSparseIndex(i) + 1;
} else {
size = other.pointers[i].length;
}
} else if (i >= other.pointers.length || (i < other.pointers.length && other.pointers[i] == null)) {
if (i >= pointers.length) {
size = 0;
} else if (sparse[i]) {
size = getSparseIndex(i) + 1;
} else {
size = pointers[i].length;
}
} else {
if (sparse[i] && getSparseIndex(i) >= size) size = getSparseIndex(i) + 1;
else if (!sparse[i] && pointers[i].length > size) size = pointers[i].length;
if (other.sparse[i] && other.getSparseIndex(i) >= size) size = other.getSparseIndex(i) + 1;
else if (!other.sparse[i] && other.pointers[i].length > size) size = other.pointers[i].length;
}
for (int j = 0; j < size; j++) {
if (Math.abs(getValueAt(i, j) - other.getValueAt(i, j)) > tolerance) return false;
}
}
return true;
}
|
java
|
public boolean valueEquals(ConcatVector other, double tolerance) {
for (int i = 0; i < Math.max(pointers.length, other.pointers.length); i++) {
int size = 0;
// Find the maximum non-zero element in this component
if (i < pointers.length && i < other.pointers.length && pointers[i] == null && other.pointers[i] == null) {
size = 0;
} else if (i >= pointers.length || (i < pointers.length && pointers[i] == null)) {
if (i >= other.pointers.length) {
size = 0;
} else if (other.sparse[i]) {
size = other.getSparseIndex(i) + 1;
} else {
size = other.pointers[i].length;
}
} else if (i >= other.pointers.length || (i < other.pointers.length && other.pointers[i] == null)) {
if (i >= pointers.length) {
size = 0;
} else if (sparse[i]) {
size = getSparseIndex(i) + 1;
} else {
size = pointers[i].length;
}
} else {
if (sparse[i] && getSparseIndex(i) >= size) size = getSparseIndex(i) + 1;
else if (!sparse[i] && pointers[i].length > size) size = pointers[i].length;
if (other.sparse[i] && other.getSparseIndex(i) >= size) size = other.getSparseIndex(i) + 1;
else if (!other.sparse[i] && other.pointers[i].length > size) size = other.pointers[i].length;
}
for (int j = 0; j < size; j++) {
if (Math.abs(getValueAt(i, j) - other.getValueAt(i, j)) > tolerance) return false;
}
}
return true;
}
|
[
"public",
"boolean",
"valueEquals",
"(",
"ConcatVector",
"other",
",",
"double",
"tolerance",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"Math",
".",
"max",
"(",
"pointers",
".",
"length",
",",
"other",
".",
"pointers",
".",
"length",
")",
";",
"i",
"++",
")",
"{",
"int",
"size",
"=",
"0",
";",
"// Find the maximum non-zero element in this component",
"if",
"(",
"i",
"<",
"pointers",
".",
"length",
"&&",
"i",
"<",
"other",
".",
"pointers",
".",
"length",
"&&",
"pointers",
"[",
"i",
"]",
"==",
"null",
"&&",
"other",
".",
"pointers",
"[",
"i",
"]",
"==",
"null",
")",
"{",
"size",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"i",
">=",
"pointers",
".",
"length",
"||",
"(",
"i",
"<",
"pointers",
".",
"length",
"&&",
"pointers",
"[",
"i",
"]",
"==",
"null",
")",
")",
"{",
"if",
"(",
"i",
">=",
"other",
".",
"pointers",
".",
"length",
")",
"{",
"size",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"other",
".",
"sparse",
"[",
"i",
"]",
")",
"{",
"size",
"=",
"other",
".",
"getSparseIndex",
"(",
"i",
")",
"+",
"1",
";",
"}",
"else",
"{",
"size",
"=",
"other",
".",
"pointers",
"[",
"i",
"]",
".",
"length",
";",
"}",
"}",
"else",
"if",
"(",
"i",
">=",
"other",
".",
"pointers",
".",
"length",
"||",
"(",
"i",
"<",
"other",
".",
"pointers",
".",
"length",
"&&",
"other",
".",
"pointers",
"[",
"i",
"]",
"==",
"null",
")",
")",
"{",
"if",
"(",
"i",
">=",
"pointers",
".",
"length",
")",
"{",
"size",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"sparse",
"[",
"i",
"]",
")",
"{",
"size",
"=",
"getSparseIndex",
"(",
"i",
")",
"+",
"1",
";",
"}",
"else",
"{",
"size",
"=",
"pointers",
"[",
"i",
"]",
".",
"length",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"sparse",
"[",
"i",
"]",
"&&",
"getSparseIndex",
"(",
"i",
")",
">=",
"size",
")",
"size",
"=",
"getSparseIndex",
"(",
"i",
")",
"+",
"1",
";",
"else",
"if",
"(",
"!",
"sparse",
"[",
"i",
"]",
"&&",
"pointers",
"[",
"i",
"]",
".",
"length",
">",
"size",
")",
"size",
"=",
"pointers",
"[",
"i",
"]",
".",
"length",
";",
"if",
"(",
"other",
".",
"sparse",
"[",
"i",
"]",
"&&",
"other",
".",
"getSparseIndex",
"(",
"i",
")",
">=",
"size",
")",
"size",
"=",
"other",
".",
"getSparseIndex",
"(",
"i",
")",
"+",
"1",
";",
"else",
"if",
"(",
"!",
"other",
".",
"sparse",
"[",
"i",
"]",
"&&",
"other",
".",
"pointers",
"[",
"i",
"]",
".",
"length",
">",
"size",
")",
"size",
"=",
"other",
".",
"pointers",
"[",
"i",
"]",
".",
"length",
";",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"size",
";",
"j",
"++",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"getValueAt",
"(",
"i",
",",
"j",
")",
"-",
"other",
".",
"getValueAt",
"(",
"i",
",",
"j",
")",
")",
">",
"tolerance",
")",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Compares two concat vectors by value. This means that we're 0 padding, so a dense and sparse component might
both be considered the same, if the dense array reflects the same value as the sparse array. This is pretty much
only useful for testing. Since it's primarily for testing, we went with the slower, more obviously correct design.
@param other the vector we're comparing to
@param tolerance the amount any pair of values can differ before we say the two vectors are different.
@return whether the two vectors are the same
|
[
"Compares",
"two",
"concat",
"vectors",
"by",
"value",
".",
"This",
"means",
"that",
"we",
"re",
"0",
"padding",
"so",
"a",
"dense",
"and",
"sparse",
"component",
"might",
"both",
"be",
"considered",
"the",
"same",
"if",
"the",
"dense",
"array",
"reflects",
"the",
"same",
"value",
"as",
"the",
"sparse",
"array",
".",
"This",
"is",
"pretty",
"much",
"only",
"useful",
"for",
"testing",
".",
"Since",
"it",
"s",
"primarily",
"for",
"testing",
"we",
"went",
"with",
"the",
"slower",
"more",
"obviously",
"correct",
"design",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVector.java#L643-L677
|
145,269
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/model/ConcatVector.java
|
ConcatVector.increaseSizeTo
|
private void increaseSizeTo(int newSize) {
assert (newSize > pointers.length);
double[][] pointersBuf = new double[newSize][];
boolean[] sparseBuf = new boolean[newSize];
boolean[] copyOnWriteBuf = new boolean[newSize];
System.arraycopy(pointers, 0, pointersBuf, 0, pointers.length);
System.arraycopy(sparse, 0, sparseBuf, 0, pointers.length);
System.arraycopy(copyOnWrite, 0, copyOnWriteBuf, 0, pointers.length);
pointers = pointersBuf;
sparse = sparseBuf;
copyOnWrite = copyOnWriteBuf;
}
|
java
|
private void increaseSizeTo(int newSize) {
assert (newSize > pointers.length);
double[][] pointersBuf = new double[newSize][];
boolean[] sparseBuf = new boolean[newSize];
boolean[] copyOnWriteBuf = new boolean[newSize];
System.arraycopy(pointers, 0, pointersBuf, 0, pointers.length);
System.arraycopy(sparse, 0, sparseBuf, 0, pointers.length);
System.arraycopy(copyOnWrite, 0, copyOnWriteBuf, 0, pointers.length);
pointers = pointersBuf;
sparse = sparseBuf;
copyOnWrite = copyOnWriteBuf;
}
|
[
"private",
"void",
"increaseSizeTo",
"(",
"int",
"newSize",
")",
"{",
"assert",
"(",
"newSize",
">",
"pointers",
".",
"length",
")",
";",
"double",
"[",
"]",
"[",
"]",
"pointersBuf",
"=",
"new",
"double",
"[",
"newSize",
"]",
"[",
"",
"]",
";",
"boolean",
"[",
"]",
"sparseBuf",
"=",
"new",
"boolean",
"[",
"newSize",
"]",
";",
"boolean",
"[",
"]",
"copyOnWriteBuf",
"=",
"new",
"boolean",
"[",
"newSize",
"]",
";",
"System",
".",
"arraycopy",
"(",
"pointers",
",",
"0",
",",
"pointersBuf",
",",
"0",
",",
"pointers",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"sparse",
",",
"0",
",",
"sparseBuf",
",",
"0",
",",
"pointers",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"copyOnWrite",
",",
"0",
",",
"copyOnWriteBuf",
",",
"0",
",",
"pointers",
".",
"length",
")",
";",
"pointers",
"=",
"pointersBuf",
";",
"sparse",
"=",
"sparseBuf",
";",
"copyOnWrite",
"=",
"copyOnWriteBuf",
";",
"}"
] |
This increases the length of the vector, while preserving its contents
@param newSize the new size to increase to. Must be larger than the current size
|
[
"This",
"increases",
"the",
"length",
"of",
"the",
"vector",
"while",
"preserving",
"its",
"contents"
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/model/ConcatVector.java#L712-L723
|
145,270
|
fuinorg/srcgen4j-commons
|
src/main/java/org/fuin/srcgen4j/commons/Target.java
|
Target.matches
|
public final boolean matches(@NotNull final String targetPath) {
Contract.requireArgNotNull("targetPath", targetPath);
if (regExpr == null) {
return true;
}
return regExpr.matcher(targetPath).find();
}
|
java
|
public final boolean matches(@NotNull final String targetPath) {
Contract.requireArgNotNull("targetPath", targetPath);
if (regExpr == null) {
return true;
}
return regExpr.matcher(targetPath).find();
}
|
[
"public",
"final",
"boolean",
"matches",
"(",
"@",
"NotNull",
"final",
"String",
"targetPath",
")",
"{",
"Contract",
".",
"requireArgNotNull",
"(",
"\"targetPath\"",
",",
"targetPath",
")",
";",
"if",
"(",
"regExpr",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"regExpr",
".",
"matcher",
"(",
"targetPath",
")",
".",
"find",
"(",
")",
";",
"}"
] |
Returns if the pattern matches the given path.
@param targetPath
Path to test.
@return If the target matches TRUE, else FALSE.
|
[
"Returns",
"if",
"the",
"pattern",
"matches",
"the",
"given",
"path",
"."
] |
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
|
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/Target.java#L152-L158
|
145,271
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/link/Link.java
|
Link.connectDevice
|
public void connectDevice(Device device) throws ShanksException {
if (this.linkedDevices.size() < deviceCapacity) {
if (!this.linkedDevices.contains(device)) {
this.linkedDevices.add(device);
device.connectToLink(this);
logger.finer("Link " + this.getID() + " has Device "
+ device.getID() + " in its linked device list.");
} else {
logger.finer("Link " + this.getID() + " already has Device "
+ device.getID() + " in its linked device list.");
}
} else {
if (!this.linkedDevices.contains(device)) {
logger.warning("Link " + this.getID()
+ " is full of its capacity. Device " + device.getID()
+ " was not included in its linked device list.");
throw new TooManyConnectionException(this);
} else {
logger.finer("Link " + this.getID() + " already has Device "
+ device.getID() + " in its linked device list.");
}
}
}
|
java
|
public void connectDevice(Device device) throws ShanksException {
if (this.linkedDevices.size() < deviceCapacity) {
if (!this.linkedDevices.contains(device)) {
this.linkedDevices.add(device);
device.connectToLink(this);
logger.finer("Link " + this.getID() + " has Device "
+ device.getID() + " in its linked device list.");
} else {
logger.finer("Link " + this.getID() + " already has Device "
+ device.getID() + " in its linked device list.");
}
} else {
if (!this.linkedDevices.contains(device)) {
logger.warning("Link " + this.getID()
+ " is full of its capacity. Device " + device.getID()
+ " was not included in its linked device list.");
throw new TooManyConnectionException(this);
} else {
logger.finer("Link " + this.getID() + " already has Device "
+ device.getID() + " in its linked device list.");
}
}
}
|
[
"public",
"void",
"connectDevice",
"(",
"Device",
"device",
")",
"throws",
"ShanksException",
"{",
"if",
"(",
"this",
".",
"linkedDevices",
".",
"size",
"(",
")",
"<",
"deviceCapacity",
")",
"{",
"if",
"(",
"!",
"this",
".",
"linkedDevices",
".",
"contains",
"(",
"device",
")",
")",
"{",
"this",
".",
"linkedDevices",
".",
"add",
"(",
"device",
")",
";",
"device",
".",
"connectToLink",
"(",
"this",
")",
";",
"logger",
".",
"finer",
"(",
"\"Link \"",
"+",
"this",
".",
"getID",
"(",
")",
"+",
"\" has Device \"",
"+",
"device",
".",
"getID",
"(",
")",
"+",
"\" in its linked device list.\"",
")",
";",
"}",
"else",
"{",
"logger",
".",
"finer",
"(",
"\"Link \"",
"+",
"this",
".",
"getID",
"(",
")",
"+",
"\" already has Device \"",
"+",
"device",
".",
"getID",
"(",
")",
"+",
"\" in its linked device list.\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"this",
".",
"linkedDevices",
".",
"contains",
"(",
"device",
")",
")",
"{",
"logger",
".",
"warning",
"(",
"\"Link \"",
"+",
"this",
".",
"getID",
"(",
")",
"+",
"\" is full of its capacity. Device \"",
"+",
"device",
".",
"getID",
"(",
")",
"+",
"\" was not included in its linked device list.\"",
")",
";",
"throw",
"new",
"TooManyConnectionException",
"(",
"this",
")",
";",
"}",
"else",
"{",
"logger",
".",
"finer",
"(",
"\"Link \"",
"+",
"this",
".",
"getID",
"(",
")",
"+",
"\" already has Device \"",
"+",
"device",
".",
"getID",
"(",
")",
"+",
"\" in its linked device list.\"",
")",
";",
"}",
"}",
"}"
] |
Connect a device to the link
@param device
@throws TooManyConnectionException
|
[
"Connect",
"a",
"device",
"to",
"the",
"link"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/link/Link.java#L84-L106
|
145,272
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/link/Link.java
|
Link.connectDevices
|
public void connectDevices(Device device1, Device device2)
throws ShanksException {
this.connectDevice(device1);
try {
this.connectDevice(device2);
} catch (ShanksException e) {
this.disconnectDevice(device1);
throw e;
}
}
|
java
|
public void connectDevices(Device device1, Device device2)
throws ShanksException {
this.connectDevice(device1);
try {
this.connectDevice(device2);
} catch (ShanksException e) {
this.disconnectDevice(device1);
throw e;
}
}
|
[
"public",
"void",
"connectDevices",
"(",
"Device",
"device1",
",",
"Device",
"device2",
")",
"throws",
"ShanksException",
"{",
"this",
".",
"connectDevice",
"(",
"device1",
")",
";",
"try",
"{",
"this",
".",
"connectDevice",
"(",
"device2",
")",
";",
"}",
"catch",
"(",
"ShanksException",
"e",
")",
"{",
"this",
".",
"disconnectDevice",
"(",
"device1",
")",
";",
"throw",
"e",
";",
"}",
"}"
] |
Connect both devices to the link
@param device1
@param device2
@throws TooManyConnectionException
|
[
"Connect",
"both",
"devices",
"to",
"the",
"link"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/link/Link.java#L123-L132
|
145,273
|
josueeduardo/snappy
|
plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/MainClassFinder.java
|
MainClassFinder.findMainClass
|
public static String findMainClass(File rootFolder) throws IOException {
return doWithMainClasses(rootFolder, new ClassNameCallback<String>() {
@Override
public String doWith(String className) {
return className;
}
});
}
|
java
|
public static String findMainClass(File rootFolder) throws IOException {
return doWithMainClasses(rootFolder, new ClassNameCallback<String>() {
@Override
public String doWith(String className) {
return className;
}
});
}
|
[
"public",
"static",
"String",
"findMainClass",
"(",
"File",
"rootFolder",
")",
"throws",
"IOException",
"{",
"return",
"doWithMainClasses",
"(",
"rootFolder",
",",
"new",
"ClassNameCallback",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"doWith",
"(",
"String",
"className",
")",
"{",
"return",
"className",
";",
"}",
"}",
")",
";",
"}"
] |
Find the main class from a given folder.
@param rootFolder the root folder to search
@return the main class or {@code null}
@throws IOException if the folder cannot be read
|
[
"Find",
"the",
"main",
"class",
"from",
"a",
"given",
"folder",
"."
] |
d95a9e811eda3c24a5e53086369208819884fa49
|
https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/MainClassFinder.java#L82-L89
|
145,274
|
josueeduardo/snappy
|
plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/MainClassFinder.java
|
MainClassFinder.findSingleMainClass
|
public static String findSingleMainClass(File rootFolder) throws IOException {
MainClassesCallback callback = new MainClassesCallback();
MainClassFinder.doWithMainClasses(rootFolder, callback);
return callback.getMainClass();
}
|
java
|
public static String findSingleMainClass(File rootFolder) throws IOException {
MainClassesCallback callback = new MainClassesCallback();
MainClassFinder.doWithMainClasses(rootFolder, callback);
return callback.getMainClass();
}
|
[
"public",
"static",
"String",
"findSingleMainClass",
"(",
"File",
"rootFolder",
")",
"throws",
"IOException",
"{",
"MainClassesCallback",
"callback",
"=",
"new",
"MainClassesCallback",
"(",
")",
";",
"MainClassFinder",
".",
"doWithMainClasses",
"(",
"rootFolder",
",",
"callback",
")",
";",
"return",
"callback",
".",
"getMainClass",
"(",
")",
";",
"}"
] |
Find a single main class from a given folder.
@param rootFolder the root folder to search
@return the main class or {@code null}
@throws IOException if the folder cannot be read
|
[
"Find",
"a",
"single",
"main",
"class",
"from",
"a",
"given",
"folder",
"."
] |
d95a9e811eda3c24a5e53086369208819884fa49
|
https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/plugin-parent/snappy-maven-plugin/src/main/java/io/joshworks/snappy/maven/tools/MainClassFinder.java#L98-L102
|
145,275
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/net/NetTracer.java
|
NetTracer.sendUserCredentials
|
protected void sendUserCredentials() throws UnknownHostException {
this.getTracePrintStream().printf("user = %s, host = %s, name = %s%n", System.getProperty("user.name"), InetAddress.getLocalHost().getHostName(), super.getName());
}
|
java
|
protected void sendUserCredentials() throws UnknownHostException {
this.getTracePrintStream().printf("user = %s, host = %s, name = %s%n", System.getProperty("user.name"), InetAddress.getLocalHost().getHostName(), super.getName());
}
|
[
"protected",
"void",
"sendUserCredentials",
"(",
")",
"throws",
"UnknownHostException",
"{",
"this",
".",
"getTracePrintStream",
"(",
")",
".",
"printf",
"(",
"\"user = %s, host = %s, name = %s%n\"",
",",
"System",
".",
"getProperty",
"(",
"\"user.name\"",
")",
",",
"InetAddress",
".",
"getLocalHost",
"(",
")",
".",
"getHostName",
"(",
")",
",",
"super",
".",
"getName",
"(",
")",
")",
";",
"}"
] |
Collects some user credentials and sends them over the network.
@throws java.net.UnknownHostException if the local host name could not be resolved into an address
|
[
"Collects",
"some",
"user",
"credentials",
"and",
"sends",
"them",
"over",
"the",
"network",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/net/NetTracer.java#L155-L157
|
145,276
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java
|
AbstractTracer.readConfiguration
|
protected void readConfiguration(XPath xpath, Node node) throws XPathExpressionException, AbstractTracer.Exception {
this.autoflush = "true".equals((String) xpath.evaluate("./dns:AutoFlush/text()", node, XPathConstants.STRING));
this.bufferSize = Integer.parseInt((String) xpath.evaluate("./dns:BufSize/text()", node, XPathConstants.STRING));
System.out.println("this.autoflush = " + this.autoflush);
System.out.println("this.bufferSize = " + this.bufferSize);
NodeList threadNodes = (NodeList) xpath.evaluate("./dns:Context/dns:Thread", node, XPathConstants.NODESET);
for (int i = 0; i < threadNodes.getLength(); i++) {
String threadName = threadNodes.item(i).getAttributes().getNamedItem("name").getNodeValue();
boolean online = "true".equals((String) xpath.evaluate("./dns:Online/text()", threadNodes.item(i), XPathConstants.STRING));
int debugLevel = Integer.parseInt((String) xpath.evaluate("./dns:DebugLevel/text()", threadNodes.item(i), XPathConstants.STRING));
System.out.println("(*-*)");
System.out.println("threadName = " + threadName);
System.out.println("online = " + online);
System.out.println("debugLevel = " + debugLevel);
this.debugConfigMap.put(threadName, new DebugConfig(online, debugLevel));
}
}
|
java
|
protected void readConfiguration(XPath xpath, Node node) throws XPathExpressionException, AbstractTracer.Exception {
this.autoflush = "true".equals((String) xpath.evaluate("./dns:AutoFlush/text()", node, XPathConstants.STRING));
this.bufferSize = Integer.parseInt((String) xpath.evaluate("./dns:BufSize/text()", node, XPathConstants.STRING));
System.out.println("this.autoflush = " + this.autoflush);
System.out.println("this.bufferSize = " + this.bufferSize);
NodeList threadNodes = (NodeList) xpath.evaluate("./dns:Context/dns:Thread", node, XPathConstants.NODESET);
for (int i = 0; i < threadNodes.getLength(); i++) {
String threadName = threadNodes.item(i).getAttributes().getNamedItem("name").getNodeValue();
boolean online = "true".equals((String) xpath.evaluate("./dns:Online/text()", threadNodes.item(i), XPathConstants.STRING));
int debugLevel = Integer.parseInt((String) xpath.evaluate("./dns:DebugLevel/text()", threadNodes.item(i), XPathConstants.STRING));
System.out.println("(*-*)");
System.out.println("threadName = " + threadName);
System.out.println("online = " + online);
System.out.println("debugLevel = " + debugLevel);
this.debugConfigMap.put(threadName, new DebugConfig(online, debugLevel));
}
}
|
[
"protected",
"void",
"readConfiguration",
"(",
"XPath",
"xpath",
",",
"Node",
"node",
")",
"throws",
"XPathExpressionException",
",",
"AbstractTracer",
".",
"Exception",
"{",
"this",
".",
"autoflush",
"=",
"\"true\"",
".",
"equals",
"(",
"(",
"String",
")",
"xpath",
".",
"evaluate",
"(",
"\"./dns:AutoFlush/text()\"",
",",
"node",
",",
"XPathConstants",
".",
"STRING",
")",
")",
";",
"this",
".",
"bufferSize",
"=",
"Integer",
".",
"parseInt",
"(",
"(",
"String",
")",
"xpath",
".",
"evaluate",
"(",
"\"./dns:BufSize/text()\"",
",",
"node",
",",
"XPathConstants",
".",
"STRING",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"this.autoflush = \"",
"+",
"this",
".",
"autoflush",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"this.bufferSize = \"",
"+",
"this",
".",
"bufferSize",
")",
";",
"NodeList",
"threadNodes",
"=",
"(",
"NodeList",
")",
"xpath",
".",
"evaluate",
"(",
"\"./dns:Context/dns:Thread\"",
",",
"node",
",",
"XPathConstants",
".",
"NODESET",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"threadNodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"threadName",
"=",
"threadNodes",
".",
"item",
"(",
"i",
")",
".",
"getAttributes",
"(",
")",
".",
"getNamedItem",
"(",
"\"name\"",
")",
".",
"getNodeValue",
"(",
")",
";",
"boolean",
"online",
"=",
"\"true\"",
".",
"equals",
"(",
"(",
"String",
")",
"xpath",
".",
"evaluate",
"(",
"\"./dns:Online/text()\"",
",",
"threadNodes",
".",
"item",
"(",
"i",
")",
",",
"XPathConstants",
".",
"STRING",
")",
")",
";",
"int",
"debugLevel",
"=",
"Integer",
".",
"parseInt",
"(",
"(",
"String",
")",
"xpath",
".",
"evaluate",
"(",
"\"./dns:DebugLevel/text()\"",
",",
"threadNodes",
".",
"item",
"(",
"i",
")",
",",
"XPathConstants",
".",
"STRING",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"(*-*)\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"threadName = \"",
"+",
"threadName",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"online = \"",
"+",
"online",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"debugLevel = \"",
"+",
"debugLevel",
")",
";",
"this",
".",
"debugConfigMap",
".",
"put",
"(",
"threadName",
",",
"new",
"DebugConfig",
"(",
"online",
",",
"debugLevel",
")",
")",
";",
"}",
"}"
] |
Reads the configuration for this particular tracer instance by evaluating the given node with the given xpath engine.
@param xpath the xpath engine
@param node the config node
@throws javax.xml.xpath.XPathExpressionException indicates xpath problems
@throws de.christofreichardt.diagnosis.AbstractTracer.Exception indicates problems when configuring certain tracer instances
|
[
"Reads",
"the",
"configuration",
"for",
"this",
"particular",
"tracer",
"instance",
"by",
"evaluating",
"the",
"given",
"node",
"with",
"the",
"given",
"xpath",
"engine",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java#L310-L331
|
145,277
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java
|
AbstractTracer.entry
|
@Deprecated
public TraceMethod entry(String methodSignature) {
synchronized (this.syncObject) {
out().printIndentln("ENTRY--" + methodSignature + "--" + Thread.currentThread().getName() + "[" + Thread.currentThread().getId() + "]");
}
TraceMethod traceMethod = null;
try {
traceMethod = new TraceMethod(methodSignature);
if (!this.threadMap.push(traceMethod))
traceMethod = null;
}
catch (AbstractThreadMap.RuntimeException ex) {
logMessage(LogLevel.SEVERE, "Stacksize is exceeded. Tracing is off.", this.getClass(), "entry()");
}
return traceMethod;
}
|
java
|
@Deprecated
public TraceMethod entry(String methodSignature) {
synchronized (this.syncObject) {
out().printIndentln("ENTRY--" + methodSignature + "--" + Thread.currentThread().getName() + "[" + Thread.currentThread().getId() + "]");
}
TraceMethod traceMethod = null;
try {
traceMethod = new TraceMethod(methodSignature);
if (!this.threadMap.push(traceMethod))
traceMethod = null;
}
catch (AbstractThreadMap.RuntimeException ex) {
logMessage(LogLevel.SEVERE, "Stacksize is exceeded. Tracing is off.", this.getClass(), "entry()");
}
return traceMethod;
}
|
[
"@",
"Deprecated",
"public",
"TraceMethod",
"entry",
"(",
"String",
"methodSignature",
")",
"{",
"synchronized",
"(",
"this",
".",
"syncObject",
")",
"{",
"out",
"(",
")",
".",
"printIndentln",
"(",
"\"ENTRY--\"",
"+",
"methodSignature",
"+",
"\"--\"",
"+",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"[\"",
"+",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getId",
"(",
")",
"+",
"\"]\"",
")",
";",
"}",
"TraceMethod",
"traceMethod",
"=",
"null",
";",
"try",
"{",
"traceMethod",
"=",
"new",
"TraceMethod",
"(",
"methodSignature",
")",
";",
"if",
"(",
"!",
"this",
".",
"threadMap",
".",
"push",
"(",
"traceMethod",
")",
")",
"traceMethod",
"=",
"null",
";",
"}",
"catch",
"(",
"AbstractThreadMap",
".",
"RuntimeException",
"ex",
")",
"{",
"logMessage",
"(",
"LogLevel",
".",
"SEVERE",
",",
"\"Stacksize is exceeded. Tracing is off.\"",
",",
"this",
".",
"getClass",
"(",
")",
",",
"\"entry()\"",
")",
";",
"}",
"return",
"traceMethod",
";",
"}"
] |
Indicates an entering of a method.
@deprecated use {@link #entry(String returnType, Class clazz, String methodSignature)} or
{@link #entry(String returnType, Object object, String methodSignature)}
@param methodSignature the signature of the method as string representation
@return the TraceMethod which has been put onto the stack - a mere data object for internal use primarily. May be null.
|
[
"Indicates",
"an",
"entering",
"of",
"a",
"method",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java#L390-L407
|
145,278
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java
|
AbstractTracer.wayout
|
public TraceMethod wayout() {
TraceMethod traceMethod = null;
try {
traceMethod = this.threadMap.pop();
if (traceMethod != null) {
synchronized (this.syncObject) {
out().printIndentln("RETURN-" + traceMethod.getSignature() + "--(+" + traceMethod.getElapsedTime() + "ms)--" + "(+" + traceMethod.getElapsedCpuTime() + "ms)--" + Thread.currentThread().getName() + "[" + Thread.currentThread().getId() + "]");
if (this.autoflush == true) {
out().flush();
}
}
}
}
catch (AbstractThreadMap.RuntimeException ex) {
logMessage(LogLevel.SEVERE, "Stack is corrupted. Tracing is off.", this.getClass(), "wayout()");
}
return traceMethod;
}
|
java
|
public TraceMethod wayout() {
TraceMethod traceMethod = null;
try {
traceMethod = this.threadMap.pop();
if (traceMethod != null) {
synchronized (this.syncObject) {
out().printIndentln("RETURN-" + traceMethod.getSignature() + "--(+" + traceMethod.getElapsedTime() + "ms)--" + "(+" + traceMethod.getElapsedCpuTime() + "ms)--" + Thread.currentThread().getName() + "[" + Thread.currentThread().getId() + "]");
if (this.autoflush == true) {
out().flush();
}
}
}
}
catch (AbstractThreadMap.RuntimeException ex) {
logMessage(LogLevel.SEVERE, "Stack is corrupted. Tracing is off.", this.getClass(), "wayout()");
}
return traceMethod;
}
|
[
"public",
"TraceMethod",
"wayout",
"(",
")",
"{",
"TraceMethod",
"traceMethod",
"=",
"null",
";",
"try",
"{",
"traceMethod",
"=",
"this",
".",
"threadMap",
".",
"pop",
"(",
")",
";",
"if",
"(",
"traceMethod",
"!=",
"null",
")",
"{",
"synchronized",
"(",
"this",
".",
"syncObject",
")",
"{",
"out",
"(",
")",
".",
"printIndentln",
"(",
"\"RETURN-\"",
"+",
"traceMethod",
".",
"getSignature",
"(",
")",
"+",
"\"--(+\"",
"+",
"traceMethod",
".",
"getElapsedTime",
"(",
")",
"+",
"\"ms)--\"",
"+",
"\"(+\"",
"+",
"traceMethod",
".",
"getElapsedCpuTime",
"(",
")",
"+",
"\"ms)--\"",
"+",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"[\"",
"+",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getId",
"(",
")",
"+",
"\"]\"",
")",
";",
"if",
"(",
"this",
".",
"autoflush",
"==",
"true",
")",
"{",
"out",
"(",
")",
".",
"flush",
"(",
")",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"AbstractThreadMap",
".",
"RuntimeException",
"ex",
")",
"{",
"logMessage",
"(",
"LogLevel",
".",
"SEVERE",
",",
"\"Stack is corrupted. Tracing is off.\"",
",",
"this",
".",
"getClass",
"(",
")",
",",
"\"wayout()\"",
")",
";",
"}",
"return",
"traceMethod",
";",
"}"
] |
Indicates the exiting of a method.
@return the TraceMethod which has been popped from the stack - a mere data object for internal use primarily. May be null.
|
[
"Indicates",
"the",
"exiting",
"of",
"a",
"method",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java#L492-L511
|
145,279
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java
|
AbstractTracer.logMessage
|
public void logMessage(LogLevel logLevel, String message, Class clazz, String methodName) {
Date timeStamp = new Date();
char border[] = new char[logLevel.toString().length() + 4];
Arrays.fill(border, '*');
synchronized (this.syncObject) {
this.tracePrintStream.println(border);
this.tracePrintStream.printf("* %s * [%tc] [%d,%s] [%s] [%s] \"%s\"%n", logLevel.toString(), timeStamp, Thread.currentThread().getId(),
Thread.currentThread().getName(), clazz.getName(), methodName, message);
this.tracePrintStream.println(border);
}
}
|
java
|
public void logMessage(LogLevel logLevel, String message, Class clazz, String methodName) {
Date timeStamp = new Date();
char border[] = new char[logLevel.toString().length() + 4];
Arrays.fill(border, '*');
synchronized (this.syncObject) {
this.tracePrintStream.println(border);
this.tracePrintStream.printf("* %s * [%tc] [%d,%s] [%s] [%s] \"%s\"%n", logLevel.toString(), timeStamp, Thread.currentThread().getId(),
Thread.currentThread().getName(), clazz.getName(), methodName, message);
this.tracePrintStream.println(border);
}
}
|
[
"public",
"void",
"logMessage",
"(",
"LogLevel",
"logLevel",
",",
"String",
"message",
",",
"Class",
"clazz",
",",
"String",
"methodName",
")",
"{",
"Date",
"timeStamp",
"=",
"new",
"Date",
"(",
")",
";",
"char",
"border",
"[",
"]",
"=",
"new",
"char",
"[",
"logLevel",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
"+",
"4",
"]",
";",
"Arrays",
".",
"fill",
"(",
"border",
",",
"'",
"'",
")",
";",
"synchronized",
"(",
"this",
".",
"syncObject",
")",
"{",
"this",
".",
"tracePrintStream",
".",
"println",
"(",
"border",
")",
";",
"this",
".",
"tracePrintStream",
".",
"printf",
"(",
"\"* %s * [%tc] [%d,%s] [%s] [%s] \\\"%s\\\"%n\"",
",",
"logLevel",
".",
"toString",
"(",
")",
",",
"timeStamp",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getId",
"(",
")",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
",",
"clazz",
".",
"getName",
"(",
")",
",",
"methodName",
",",
"message",
")",
";",
"this",
".",
"tracePrintStream",
".",
"println",
"(",
"border",
")",
";",
"}",
"}"
] |
Logs a message with the given logLevel and the originating class.
@param logLevel one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVERE
@param message the to be logged message
@param clazz the originating class
@param methodName the originating method
|
[
"Logs",
"a",
"message",
"with",
"the",
"given",
"logLevel",
"and",
"the",
"originating",
"class",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java#L521-L532
|
145,280
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java
|
AbstractTracer.logException
|
public void logException(LogLevel logLevel, Throwable throwable, Class clazz, String methodName) {
Date timeStamp = new Date();
char border[] = new char[logLevel.toString().length() + 4];
Arrays.fill(border, '*');
String message;
if (throwable.getMessage() != null) {
message = throwable.getMessage().trim();
message = message.replace(System.getProperty("line.separator"), " => ");
}
else {
message = "No message.";
}
synchronized (this.syncObject) {
this.tracePrintStream.println(border);
this.tracePrintStream.printf("* %s * [%tc] [%d,%s] [%s] [%s] \"%s\"%n", logLevel.toString(), timeStamp, Thread.currentThread().getId(),
Thread.currentThread().getName(), clazz.getName(), methodName, message);
this.tracePrintStream.println(border);
throwable.printStackTrace(this.tracePrintStream);
}
}
|
java
|
public void logException(LogLevel logLevel, Throwable throwable, Class clazz, String methodName) {
Date timeStamp = new Date();
char border[] = new char[logLevel.toString().length() + 4];
Arrays.fill(border, '*');
String message;
if (throwable.getMessage() != null) {
message = throwable.getMessage().trim();
message = message.replace(System.getProperty("line.separator"), " => ");
}
else {
message = "No message.";
}
synchronized (this.syncObject) {
this.tracePrintStream.println(border);
this.tracePrintStream.printf("* %s * [%tc] [%d,%s] [%s] [%s] \"%s\"%n", logLevel.toString(), timeStamp, Thread.currentThread().getId(),
Thread.currentThread().getName(), clazz.getName(), methodName, message);
this.tracePrintStream.println(border);
throwable.printStackTrace(this.tracePrintStream);
}
}
|
[
"public",
"void",
"logException",
"(",
"LogLevel",
"logLevel",
",",
"Throwable",
"throwable",
",",
"Class",
"clazz",
",",
"String",
"methodName",
")",
"{",
"Date",
"timeStamp",
"=",
"new",
"Date",
"(",
")",
";",
"char",
"border",
"[",
"]",
"=",
"new",
"char",
"[",
"logLevel",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
"+",
"4",
"]",
";",
"Arrays",
".",
"fill",
"(",
"border",
",",
"'",
"'",
")",
";",
"String",
"message",
";",
"if",
"(",
"throwable",
".",
"getMessage",
"(",
")",
"!=",
"null",
")",
"{",
"message",
"=",
"throwable",
".",
"getMessage",
"(",
")",
".",
"trim",
"(",
")",
";",
"message",
"=",
"message",
".",
"replace",
"(",
"System",
".",
"getProperty",
"(",
"\"line.separator\"",
")",
",",
"\" => \"",
")",
";",
"}",
"else",
"{",
"message",
"=",
"\"No message.\"",
";",
"}",
"synchronized",
"(",
"this",
".",
"syncObject",
")",
"{",
"this",
".",
"tracePrintStream",
".",
"println",
"(",
"border",
")",
";",
"this",
".",
"tracePrintStream",
".",
"printf",
"(",
"\"* %s * [%tc] [%d,%s] [%s] [%s] \\\"%s\\\"%n\"",
",",
"logLevel",
".",
"toString",
"(",
")",
",",
"timeStamp",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getId",
"(",
")",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
",",
"clazz",
".",
"getName",
"(",
")",
",",
"methodName",
",",
"message",
")",
";",
"this",
".",
"tracePrintStream",
".",
"println",
"(",
"border",
")",
";",
"throwable",
".",
"printStackTrace",
"(",
"this",
".",
"tracePrintStream",
")",
";",
"}",
"}"
] |
Logs an exception with the given logLevel and the originating class.
@param logLevel one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVERE
@param throwable the to be logged throwable
@param clazz the originating class
@param methodName the name of the relevant method
|
[
"Logs",
"an",
"exception",
"with",
"the",
"given",
"logLevel",
"and",
"the",
"originating",
"class",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java#L542-L563
|
145,281
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java
|
AbstractTracer.initCurrentTracingContext
|
public void initCurrentTracingContext(int debugLevel, boolean online) {
// todo: prevent manually creation of tracing contexts by configuration?!
TracingContext tracingContext = this.threadMap.getCurrentTracingContext();
if (tracingContext == null) {
System.out.println(formatContextInfo(debugLevel, online));
tracingContext = new TracingContext(debugLevel, online);
this.threadMap.setCurrentTracingContext(tracingContext);
}
else {
tracingContext.setDebugLevel(debugLevel);
tracingContext.setOnline(online);
}
}
|
java
|
public void initCurrentTracingContext(int debugLevel, boolean online) {
// todo: prevent manually creation of tracing contexts by configuration?!
TracingContext tracingContext = this.threadMap.getCurrentTracingContext();
if (tracingContext == null) {
System.out.println(formatContextInfo(debugLevel, online));
tracingContext = new TracingContext(debugLevel, online);
this.threadMap.setCurrentTracingContext(tracingContext);
}
else {
tracingContext.setDebugLevel(debugLevel);
tracingContext.setOnline(online);
}
}
|
[
"public",
"void",
"initCurrentTracingContext",
"(",
"int",
"debugLevel",
",",
"boolean",
"online",
")",
"{",
"// todo: prevent manually creation of tracing contexts by configuration?!\r",
"TracingContext",
"tracingContext",
"=",
"this",
".",
"threadMap",
".",
"getCurrentTracingContext",
"(",
")",
";",
"if",
"(",
"tracingContext",
"==",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"formatContextInfo",
"(",
"debugLevel",
",",
"online",
")",
")",
";",
"tracingContext",
"=",
"new",
"TracingContext",
"(",
"debugLevel",
",",
"online",
")",
";",
"this",
".",
"threadMap",
".",
"setCurrentTracingContext",
"(",
"tracingContext",
")",
";",
"}",
"else",
"{",
"tracingContext",
".",
"setDebugLevel",
"(",
"debugLevel",
")",
";",
"tracingContext",
".",
"setOnline",
"(",
"online",
")",
";",
"}",
"}"
] |
Initialises the current tracing context with the given debugLevel and online state.
@param debugLevel controls the extent of the output
@param online a value of false delivers no output of the current thread at all whereas a value of true delivers output controlled by debugLevel
|
[
"Initialises",
"the",
"current",
"tracing",
"context",
"with",
"the",
"given",
"debugLevel",
"and",
"online",
"state",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java#L571-L585
|
145,282
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java
|
AbstractTracer.initCurrentTracingContext
|
public void initCurrentTracingContext() {
// if (this.debugConfigMap.containsKey(Thread.currentThread().getName())) {
// DebugConfig debugConfig = this.debugConfigMap.get(Thread.currentThread().getName());
// this.debugConfigMap.remove(Thread.currentThread().getName());
//
// System.out.println(formatContextInfo(debugConfig.getLevel(), debugConfig.isOnline()));
//
// TracingContext tracingContext = new TracingContext(debugConfig);
// this.threadMap.setCurrentTracingContext(tracingContext);
// }
TracingContext tracingContext = this.threadMap.getCurrentTracingContext();
if (tracingContext == null) {
if (this.debugConfigMap.containsKey(Thread.currentThread().getName())) {
DebugConfig debugConfig = this.debugConfigMap.get(Thread.currentThread().getName());
System.out.println(formatContextInfo(debugConfig.getLevel(), debugConfig.isOnline()));
tracingContext = new TracingContext(debugConfig);
this.threadMap.setCurrentTracingContext(tracingContext);
}
}
}
|
java
|
public void initCurrentTracingContext() {
// if (this.debugConfigMap.containsKey(Thread.currentThread().getName())) {
// DebugConfig debugConfig = this.debugConfigMap.get(Thread.currentThread().getName());
// this.debugConfigMap.remove(Thread.currentThread().getName());
//
// System.out.println(formatContextInfo(debugConfig.getLevel(), debugConfig.isOnline()));
//
// TracingContext tracingContext = new TracingContext(debugConfig);
// this.threadMap.setCurrentTracingContext(tracingContext);
// }
TracingContext tracingContext = this.threadMap.getCurrentTracingContext();
if (tracingContext == null) {
if (this.debugConfigMap.containsKey(Thread.currentThread().getName())) {
DebugConfig debugConfig = this.debugConfigMap.get(Thread.currentThread().getName());
System.out.println(formatContextInfo(debugConfig.getLevel(), debugConfig.isOnline()));
tracingContext = new TracingContext(debugConfig);
this.threadMap.setCurrentTracingContext(tracingContext);
}
}
}
|
[
"public",
"void",
"initCurrentTracingContext",
"(",
")",
"{",
"// if (this.debugConfigMap.containsKey(Thread.currentThread().getName())) {\r",
"// DebugConfig debugConfig = this.debugConfigMap.get(Thread.currentThread().getName());\r",
"// this.debugConfigMap.remove(Thread.currentThread().getName());\r",
"//\r",
"// System.out.println(formatContextInfo(debugConfig.getLevel(), debugConfig.isOnline()));\r",
"//\r",
"// TracingContext tracingContext = new TracingContext(debugConfig);\r",
"// this.threadMap.setCurrentTracingContext(tracingContext);\r",
"// }\r",
"TracingContext",
"tracingContext",
"=",
"this",
".",
"threadMap",
".",
"getCurrentTracingContext",
"(",
")",
";",
"if",
"(",
"tracingContext",
"==",
"null",
")",
"{",
"if",
"(",
"this",
".",
"debugConfigMap",
".",
"containsKey",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"{",
"DebugConfig",
"debugConfig",
"=",
"this",
".",
"debugConfigMap",
".",
"get",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"formatContextInfo",
"(",
"debugConfig",
".",
"getLevel",
"(",
")",
",",
"debugConfig",
".",
"isOnline",
"(",
")",
")",
")",
";",
"tracingContext",
"=",
"new",
"TracingContext",
"(",
"debugConfig",
")",
";",
"this",
".",
"threadMap",
".",
"setCurrentTracingContext",
"(",
"tracingContext",
")",
";",
"}",
"}",
"}"
] |
Initialises the current tracing context by taking the values for debugLevel and online from the configured
debug map.
|
[
"Initialises",
"the",
"current",
"tracing",
"context",
"by",
"taking",
"the",
"values",
"for",
"debugLevel",
"and",
"online",
"from",
"the",
"configured",
"debug",
"map",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java#L591-L611
|
145,283
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java
|
AbstractTracer.formatVersionInfo
|
protected String formatVersionInfo() {
Formatter formatter = new Formatter();
formatter.format("TraceLogger[%s]: Version = %s.", this.name, VERSION);
return formatter.toString();
}
|
java
|
protected String formatVersionInfo() {
Formatter formatter = new Formatter();
formatter.format("TraceLogger[%s]: Version = %s.", this.name, VERSION);
return formatter.toString();
}
|
[
"protected",
"String",
"formatVersionInfo",
"(",
")",
"{",
"Formatter",
"formatter",
"=",
"new",
"Formatter",
"(",
")",
";",
"formatter",
".",
"format",
"(",
"\"TraceLogger[%s]: Version = %s.\"",
",",
"this",
".",
"name",
",",
"VERSION",
")",
";",
"return",
"formatter",
".",
"toString",
"(",
")",
";",
"}"
] |
Gives a string representation about the version of this library.
@return a formatted status line
|
[
"Gives",
"a",
"string",
"representation",
"about",
"the",
"version",
"of",
"this",
"library",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/AbstractTracer.java#L691-L696
|
145,284
|
lightszentip/logmanagement-plugin
|
src/main/java/com/lightszentip/module/logmanagement/plugin/LogManagementPluginFactory.java
|
LogManagementPluginFactory.getLogManagementPlugin
|
public static LogManagementPlugin getLogManagementPlugin() {
final String loggerImpl = org.slf4j.impl.StaticLoggerBinder
.getSingleton().getLoggerFactoryClassStr();
if ("Log4jLoggerFactoryο»Ώ".equals(loggerImpl.substring(loggerImpl
.lastIndexOf(".") + 1))) {
return new LogManagementPluginLog4jImpl();
} else if (loggerImpl.indexOf("logback.") > 1
&& "ContextSelectorStaticBinder".equals(loggerImpl
.substring(loggerImpl.lastIndexOf(".") + 1))) {
return new LogManagementPluginLogbackImpl();
}
throw new UnsupportedOperationException();
}
|
java
|
public static LogManagementPlugin getLogManagementPlugin() {
final String loggerImpl = org.slf4j.impl.StaticLoggerBinder
.getSingleton().getLoggerFactoryClassStr();
if ("Log4jLoggerFactoryο»Ώ".equals(loggerImpl.substring(loggerImpl
.lastIndexOf(".") + 1))) {
return new LogManagementPluginLog4jImpl();
} else if (loggerImpl.indexOf("logback.") > 1
&& "ContextSelectorStaticBinder".equals(loggerImpl
.substring(loggerImpl.lastIndexOf(".") + 1))) {
return new LogManagementPluginLogbackImpl();
}
throw new UnsupportedOperationException();
}
|
[
"public",
"static",
"LogManagementPlugin",
"getLogManagementPlugin",
"(",
")",
"{",
"final",
"String",
"loggerImpl",
"=",
"org",
".",
"slf4j",
".",
"impl",
".",
"StaticLoggerBinder",
".",
"getSingleton",
"(",
")",
".",
"getLoggerFactoryClassStr",
"(",
")",
";",
"if",
"(",
"\"Log4jLoggerFactoryο»Ώ\".e",
"q",
"uals(l",
"o",
"ggerImpl.s",
"u",
"bstring(l",
"o",
"ggerImpl",
".",
"lastIndexOf",
"(",
"\".\"",
")",
"+",
"1",
")",
")",
")",
"{",
"return",
"new",
"LogManagementPluginLog4jImpl",
"(",
")",
";",
"}",
"else",
"if",
"(",
"loggerImpl",
".",
"indexOf",
"(",
"\"logback.\"",
")",
">",
"1",
"&&",
"\"ContextSelectorStaticBinder\"",
".",
"equals",
"(",
"loggerImpl",
".",
"substring",
"(",
"loggerImpl",
".",
"lastIndexOf",
"(",
"\".\"",
")",
"+",
"1",
")",
")",
")",
"{",
"return",
"new",
"LogManagementPluginLogbackImpl",
"(",
")",
";",
"}",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}"
] |
Get implementation for log management plugin.
@return The implementation of log management plugin.
|
[
"Get",
"implementation",
"for",
"log",
"management",
"plugin",
"."
] |
acd648a88c2d261848088a29787f09fc0818d369
|
https://github.com/lightszentip/logmanagement-plugin/blob/acd648a88c2d261848088a29787f09fc0818d369/src/main/java/com/lightszentip/module/logmanagement/plugin/LogManagementPluginFactory.java#L40-L52
|
145,285
|
flex-oss/flex-fruit
|
fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/CriteriaMapper.java
|
CriteriaMapper.create
|
public Predicate create(Filter filter) {
List<Predicate> predicates = new ArrayList<>(filter.getPredicates().size());
for (org.cdlflex.fruit.Predicate fp : filter.getPredicates()) {
predicates.add(create(fp));
}
return connect(predicates, filter.getConnective());
}
|
java
|
public Predicate create(Filter filter) {
List<Predicate> predicates = new ArrayList<>(filter.getPredicates().size());
for (org.cdlflex.fruit.Predicate fp : filter.getPredicates()) {
predicates.add(create(fp));
}
return connect(predicates, filter.getConnective());
}
|
[
"public",
"Predicate",
"create",
"(",
"Filter",
"filter",
")",
"{",
"List",
"<",
"Predicate",
">",
"predicates",
"=",
"new",
"ArrayList",
"<>",
"(",
"filter",
".",
"getPredicates",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"org",
".",
"cdlflex",
".",
"fruit",
".",
"Predicate",
"fp",
":",
"filter",
".",
"getPredicates",
"(",
")",
")",
"{",
"predicates",
".",
"add",
"(",
"create",
"(",
"fp",
")",
")",
";",
"}",
"return",
"connect",
"(",
"predicates",
",",
"filter",
".",
"getConnective",
"(",
")",
")",
";",
"}"
] |
Creates a joined predicate from the given Filter.
@param filter the filter
@return a new JPA criteria Predicate
|
[
"Creates",
"a",
"joined",
"predicate",
"from",
"the",
"given",
"Filter",
"."
] |
30d7eca5ee796b829f96c9932a95b259ca9738d9
|
https://github.com/flex-oss/flex-fruit/blob/30d7eca5ee796b829f96c9932a95b259ca9738d9/fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/CriteriaMapper.java#L59-L67
|
145,286
|
flex-oss/flex-fruit
|
fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/CriteriaMapper.java
|
CriteriaMapper.create
|
public Predicate create(org.cdlflex.fruit.Predicate predicate) {
Path<?> attribute = resolvePath(predicate.getKey());
Object value = predicate.getValue();
Predicate jpaPredicate = create(predicate.getOp(), attribute, value);
return (predicate.isNot()) ? jpaPredicate.not() : jpaPredicate;
}
|
java
|
public Predicate create(org.cdlflex.fruit.Predicate predicate) {
Path<?> attribute = resolvePath(predicate.getKey());
Object value = predicate.getValue();
Predicate jpaPredicate = create(predicate.getOp(), attribute, value);
return (predicate.isNot()) ? jpaPredicate.not() : jpaPredicate;
}
|
[
"public",
"Predicate",
"create",
"(",
"org",
".",
"cdlflex",
".",
"fruit",
".",
"Predicate",
"predicate",
")",
"{",
"Path",
"<",
"?",
">",
"attribute",
"=",
"resolvePath",
"(",
"predicate",
".",
"getKey",
"(",
")",
")",
";",
"Object",
"value",
"=",
"predicate",
".",
"getValue",
"(",
")",
";",
"Predicate",
"jpaPredicate",
"=",
"create",
"(",
"predicate",
".",
"getOp",
"(",
")",
",",
"attribute",
",",
"value",
")",
";",
"return",
"(",
"predicate",
".",
"isNot",
"(",
")",
")",
"?",
"jpaPredicate",
".",
"not",
"(",
")",
":",
"jpaPredicate",
";",
"}"
] |
Maps the given API Predicate object to a JPA criteria Predicate.
@param predicate the Predicate object
@return a JPA criteria Predicate
|
[
"Maps",
"the",
"given",
"API",
"Predicate",
"object",
"to",
"a",
"JPA",
"criteria",
"Predicate",
"."
] |
30d7eca5ee796b829f96c9932a95b259ca9738d9
|
https://github.com/flex-oss/flex-fruit/blob/30d7eca5ee796b829f96c9932a95b259ca9738d9/fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/CriteriaMapper.java#L75-L82
|
145,287
|
flex-oss/flex-fruit
|
fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/CriteriaMapper.java
|
CriteriaMapper.connect
|
public Predicate connect(List<Predicate> predicates, Connective connective) {
Predicate[] predicateArray = predicates.toArray(new Predicate[predicates.size()]);
switch (connective) {
case AND:
return cb.and(predicateArray);
case OR:
return cb.or(predicateArray);
default:
throw new UnsupportedOperationException("Unknown connective " + connective);
}
}
|
java
|
public Predicate connect(List<Predicate> predicates, Connective connective) {
Predicate[] predicateArray = predicates.toArray(new Predicate[predicates.size()]);
switch (connective) {
case AND:
return cb.and(predicateArray);
case OR:
return cb.or(predicateArray);
default:
throw new UnsupportedOperationException("Unknown connective " + connective);
}
}
|
[
"public",
"Predicate",
"connect",
"(",
"List",
"<",
"Predicate",
">",
"predicates",
",",
"Connective",
"connective",
")",
"{",
"Predicate",
"[",
"]",
"predicateArray",
"=",
"predicates",
".",
"toArray",
"(",
"new",
"Predicate",
"[",
"predicates",
".",
"size",
"(",
")",
"]",
")",
";",
"switch",
"(",
"connective",
")",
"{",
"case",
"AND",
":",
"return",
"cb",
".",
"and",
"(",
"predicateArray",
")",
";",
"case",
"OR",
":",
"return",
"cb",
".",
"or",
"(",
"predicateArray",
")",
";",
"default",
":",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Unknown connective \"",
"+",
"connective",
")",
";",
"}",
"}"
] |
Joins the given predicates using the criteria builder with the given connective.
@param predicates the predicates to join
@param connective the logical connective
@return a new predicate that connects all given predicate
|
[
"Joins",
"the",
"given",
"predicates",
"using",
"the",
"criteria",
"builder",
"with",
"the",
"given",
"connective",
"."
] |
30d7eca5ee796b829f96c9932a95b259ca9738d9
|
https://github.com/flex-oss/flex-fruit/blob/30d7eca5ee796b829f96c9932a95b259ca9738d9/fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/CriteriaMapper.java#L107-L118
|
145,288
|
flex-oss/flex-fruit
|
fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/CriteriaMapper.java
|
CriteriaMapper.create
|
public List<Order> create(OrderBy order) {
List<Order> list = new ArrayList<>();
for (SortSpecification sort : order.getSort()) {
if (sort.getSortOrder() == SortOrder.DESC) {
list.add(cb.desc(root.get(sort.getKey())));
} else if (sort.getSortOrder() == SortOrder.ASC) {
list.add(cb.asc(root.get(sort.getKey())));
}
}
return list;
}
|
java
|
public List<Order> create(OrderBy order) {
List<Order> list = new ArrayList<>();
for (SortSpecification sort : order.getSort()) {
if (sort.getSortOrder() == SortOrder.DESC) {
list.add(cb.desc(root.get(sort.getKey())));
} else if (sort.getSortOrder() == SortOrder.ASC) {
list.add(cb.asc(root.get(sort.getKey())));
}
}
return list;
}
|
[
"public",
"List",
"<",
"Order",
">",
"create",
"(",
"OrderBy",
"order",
")",
"{",
"List",
"<",
"Order",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"SortSpecification",
"sort",
":",
"order",
".",
"getSort",
"(",
")",
")",
"{",
"if",
"(",
"sort",
".",
"getSortOrder",
"(",
")",
"==",
"SortOrder",
".",
"DESC",
")",
"{",
"list",
".",
"add",
"(",
"cb",
".",
"desc",
"(",
"root",
".",
"get",
"(",
"sort",
".",
"getKey",
"(",
")",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"sort",
".",
"getSortOrder",
"(",
")",
"==",
"SortOrder",
".",
"ASC",
")",
"{",
"list",
".",
"add",
"(",
"cb",
".",
"asc",
"(",
"root",
".",
"get",
"(",
"sort",
".",
"getKey",
"(",
")",
")",
")",
")",
";",
"}",
"}",
"return",
"list",
";",
"}"
] |
Converts an OrderBy clause to a list of javax.persistence Order instances given a Root and a CriteriaBuilder.
@param order the order by clause
@return a list of Order instances
|
[
"Converts",
"an",
"OrderBy",
"clause",
"to",
"a",
"list",
"of",
"javax",
".",
"persistence",
"Order",
"instances",
"given",
"a",
"Root",
"and",
"a",
"CriteriaBuilder",
"."
] |
30d7eca5ee796b829f96c9932a95b259ca9738d9
|
https://github.com/flex-oss/flex-fruit/blob/30d7eca5ee796b829f96c9932a95b259ca9738d9/fruit-jpa/src/main/java/org/cdlflex/fruit/jpa/CriteriaMapper.java#L126-L138
|
145,289
|
LevelFourAB/commons
|
commons-types/src/main/java/se/l4/commons/types/matching/AbstractClassMatchingMap.java
|
AbstractClassMatchingMap.findMatching
|
protected void findMatching(Class<? extends T> type, BiPredicate<Class<? extends T>, D> predicate)
{
traverseType(type, predicate, new HashSet<>());
}
|
java
|
protected void findMatching(Class<? extends T> type, BiPredicate<Class<? extends T>, D> predicate)
{
traverseType(type, predicate, new HashSet<>());
}
|
[
"protected",
"void",
"findMatching",
"(",
"Class",
"<",
"?",
"extends",
"T",
">",
"type",
",",
"BiPredicate",
"<",
"Class",
"<",
"?",
"extends",
"T",
">",
",",
"D",
">",
"predicate",
")",
"{",
"traverseType",
"(",
"type",
",",
"predicate",
",",
"new",
"HashSet",
"<>",
"(",
")",
")",
";",
"}"
] |
Perform matching against the given type. This will go through the
hierarchy and interfaces of the type trying to find if this map has
an entry for them.
|
[
"Perform",
"matching",
"against",
"the",
"given",
"type",
".",
"This",
"will",
"go",
"through",
"the",
"hierarchy",
"and",
"interfaces",
"of",
"the",
"type",
"trying",
"to",
"find",
"if",
"this",
"map",
"has",
"an",
"entry",
"for",
"them",
"."
] |
aa121b3a5504b43d0c10450a1b984694fcd2b8ee
|
https://github.com/LevelFourAB/commons/blob/aa121b3a5504b43d0c10450a1b984694fcd2b8ee/commons-types/src/main/java/se/l4/commons/types/matching/AbstractClassMatchingMap.java#L82-L85
|
145,290
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/ResourceUtilities.java
|
ResourceUtilities.resourceFileToXMLDocument
|
public static Document resourceFileToXMLDocument(final String location, final String fileName) {
if (location == null || fileName == null) return null;
final InputStream in = ResourceUtilities.class.getResourceAsStream(location + fileName);
if (in == null) return null;
final DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder dBuilder;
Document doc = null;
try {
dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(in);
} catch (Exception e) {
LOG.error("Failed to parse the resource as XML.", e);
} finally {
try {
in.close();
} catch (IOException e) {
LOG.error("Failed to close the InputStream", e);
}
}
return doc;
}
|
java
|
public static Document resourceFileToXMLDocument(final String location, final String fileName) {
if (location == null || fileName == null) return null;
final InputStream in = ResourceUtilities.class.getResourceAsStream(location + fileName);
if (in == null) return null;
final DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder dBuilder;
Document doc = null;
try {
dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(in);
} catch (Exception e) {
LOG.error("Failed to parse the resource as XML.", e);
} finally {
try {
in.close();
} catch (IOException e) {
LOG.error("Failed to close the InputStream", e);
}
}
return doc;
}
|
[
"public",
"static",
"Document",
"resourceFileToXMLDocument",
"(",
"final",
"String",
"location",
",",
"final",
"String",
"fileName",
")",
"{",
"if",
"(",
"location",
"==",
"null",
"||",
"fileName",
"==",
"null",
")",
"return",
"null",
";",
"final",
"InputStream",
"in",
"=",
"ResourceUtilities",
".",
"class",
".",
"getResourceAsStream",
"(",
"location",
"+",
"fileName",
")",
";",
"if",
"(",
"in",
"==",
"null",
")",
"return",
"null",
";",
"final",
"DocumentBuilderFactory",
"dbFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"final",
"DocumentBuilder",
"dBuilder",
";",
"Document",
"doc",
"=",
"null",
";",
"try",
"{",
"dBuilder",
"=",
"dbFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"doc",
"=",
"dBuilder",
".",
"parse",
"(",
"in",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to parse the resource as XML.\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to close the InputStream\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"doc",
";",
"}"
] |
Reads a resource file and converts it into a XML based Document object.
@param location The location of the resource file.
@param fileName The name of the file.
@return The Document that represents the contents of the file or null if an error occurred.
|
[
"Reads",
"a",
"resource",
"file",
"and",
"converts",
"it",
"into",
"a",
"XML",
"based",
"Document",
"object",
"."
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/ResourceUtilities.java#L84-L106
|
145,291
|
Mthwate/DatLib
|
src/main/java/com/mthwate/datlib/math/MathUtils.java
|
MathUtils.gcd
|
public static BigInteger gcd(BigInteger a, BigInteger b) {
return gcd(a, b, Calculator.BIG_INTEGER_CALCULATOR);
}
|
java
|
public static BigInteger gcd(BigInteger a, BigInteger b) {
return gcd(a, b, Calculator.BIG_INTEGER_CALCULATOR);
}
|
[
"public",
"static",
"BigInteger",
"gcd",
"(",
"BigInteger",
"a",
",",
"BigInteger",
"b",
")",
"{",
"return",
"gcd",
"(",
"a",
",",
"b",
",",
"Calculator",
".",
"BIG_INTEGER_CALCULATOR",
")",
";",
"}"
] |
Gets the greatest common divisor of 2 numbers.
@since 1.3
@param a the first BigInteger
@param b the second BigInteger
@return the greatest common divisor as a BigInteger
|
[
"Gets",
"the",
"greatest",
"common",
"divisor",
"of",
"2",
"numbers",
"."
] |
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
|
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/math/MathUtils.java#L47-L49
|
145,292
|
Mthwate/DatLib
|
src/main/java/com/mthwate/datlib/math/MathUtils.java
|
MathUtils.lcm
|
public static BigInteger lcm(BigInteger a, BigInteger b) {
return lcm(a, b, Calculator.BIG_INTEGER_CALCULATOR);
}
|
java
|
public static BigInteger lcm(BigInteger a, BigInteger b) {
return lcm(a, b, Calculator.BIG_INTEGER_CALCULATOR);
}
|
[
"public",
"static",
"BigInteger",
"lcm",
"(",
"BigInteger",
"a",
",",
"BigInteger",
"b",
")",
"{",
"return",
"lcm",
"(",
"a",
",",
"b",
",",
"Calculator",
".",
"BIG_INTEGER_CALCULATOR",
")",
";",
"}"
] |
Gets the least common multiple of 2 numbers.
@since 1.3
@param a the first BigInteger
@param b the second BigInteger
@return the least common multiple as a BigInteger
|
[
"Gets",
"the",
"least",
"common",
"multiple",
"of",
"2",
"numbers",
"."
] |
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
|
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/math/MathUtils.java#L96-L98
|
145,293
|
Mthwate/DatLib
|
src/main/java/com/mthwate/datlib/math/MathUtils.java
|
MathUtils.round
|
public static double round(double value, int decimals, RoundingMode roundingMode) {
if (decimals < 0) {
throw new IllegalArgumentException("Invalid number of decimal places");
}
BigDecimal bd = new BigDecimal(value);
return bd.setScale(decimals, roundingMode).doubleValue();
}
|
java
|
public static double round(double value, int decimals, RoundingMode roundingMode) {
if (decimals < 0) {
throw new IllegalArgumentException("Invalid number of decimal places");
}
BigDecimal bd = new BigDecimal(value);
return bd.setScale(decimals, roundingMode).doubleValue();
}
|
[
"public",
"static",
"double",
"round",
"(",
"double",
"value",
",",
"int",
"decimals",
",",
"RoundingMode",
"roundingMode",
")",
"{",
"if",
"(",
"decimals",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid number of decimal places\"",
")",
";",
"}",
"BigDecimal",
"bd",
"=",
"new",
"BigDecimal",
"(",
"value",
")",
";",
"return",
"bd",
".",
"setScale",
"(",
"decimals",
",",
"roundingMode",
")",
".",
"doubleValue",
"(",
")",
";",
"}"
] |
Rounds a number to the specified number of decomal places.
@since 1.1
@param value the number to round
@param decimals the number of decimal places
@param roundingMode the method to use for rounding
@return the rounded number
|
[
"Rounds",
"a",
"number",
"to",
"the",
"specified",
"number",
"of",
"decomal",
"places",
"."
] |
f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077
|
https://github.com/Mthwate/DatLib/blob/f0b3a9f9cf6fdc773d4f86234ebd95986c9b6077/src/main/java/com/mthwate/datlib/math/MathUtils.java#L125-L132
|
145,294
|
wcm-io-caravan/caravan-hal
|
docs/src/main/java/io/wcm/caravan/hal/docs/impl/reader/ServiceJson.java
|
ServiceJson.write
|
public void write(Service model, OutputStream os) throws IOException {
objectMapper.writerWithDefaultPrettyPrinter().writeValue(os, model);
}
|
java
|
public void write(Service model, OutputStream os) throws IOException {
objectMapper.writerWithDefaultPrettyPrinter().writeValue(os, model);
}
|
[
"public",
"void",
"write",
"(",
"Service",
"model",
",",
"OutputStream",
"os",
")",
"throws",
"IOException",
"{",
"objectMapper",
".",
"writerWithDefaultPrettyPrinter",
"(",
")",
".",
"writeValue",
"(",
"os",
",",
"model",
")",
";",
"}"
] |
Write model to stream.
@param model Model
@param os Stream
@throws IOException
|
[
"Write",
"model",
"to",
"stream",
"."
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs/src/main/java/io/wcm/caravan/hal/docs/impl/reader/ServiceJson.java#L58-L60
|
145,295
|
dbracewell/mango
|
src/main/java/com/davidbracewell/collection/IntervalTree.java
|
IntervalTree.overlapping
|
public List<T> overlapping(Span span) {
if (span == null || root.isNull()) {
return Collections.emptyList();
}
return overlapping(root, span, new ArrayList<>());
}
|
java
|
public List<T> overlapping(Span span) {
if (span == null || root.isNull()) {
return Collections.emptyList();
}
return overlapping(root, span, new ArrayList<>());
}
|
[
"public",
"List",
"<",
"T",
">",
"overlapping",
"(",
"Span",
"span",
")",
"{",
"if",
"(",
"span",
"==",
"null",
"||",
"root",
".",
"isNull",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"return",
"overlapping",
"(",
"root",
",",
"span",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"}"
] |
Gets all Ts that overlap the given span
@param span the span
@return the list of overlapping T
|
[
"Gets",
"all",
"Ts",
"that",
"overlap",
"the",
"given",
"span"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/collection/IntervalTree.java#L193-L198
|
145,296
|
dbracewell/mango
|
src/main/java/com/davidbracewell/collection/IntervalTree.java
|
IntervalTree.floor
|
public T floor(T T) {
if (T == null) {
return null;
}
NodeIterator<T> iterator = new NodeIterator<>(root, -1, T.start(), false);
if (iterator.hasNext()) {
return iterator.next();
}
return null;
}
|
java
|
public T floor(T T) {
if (T == null) {
return null;
}
NodeIterator<T> iterator = new NodeIterator<>(root, -1, T.start(), false);
if (iterator.hasNext()) {
return iterator.next();
}
return null;
}
|
[
"public",
"T",
"floor",
"(",
"T",
"T",
")",
"{",
"if",
"(",
"T",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"NodeIterator",
"<",
"T",
">",
"iterator",
"=",
"new",
"NodeIterator",
"<>",
"(",
"root",
",",
"-",
"1",
",",
"T",
".",
"start",
"(",
")",
",",
"false",
")",
";",
"if",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
"iterator",
".",
"next",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Floor T.
@param T the T
@return the T
|
[
"Floor",
"T",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/collection/IntervalTree.java#L582-L591
|
145,297
|
dbracewell/mango
|
src/main/java/com/davidbracewell/collection/IntervalTree.java
|
IntervalTree.ceiling
|
public T ceiling(T T) {
if (T == null) {
return null;
}
NodeIterator<T> iterator = new NodeIterator<>(root, T.end(), Integer.MAX_VALUE, true);
if (iterator.hasNext()) {
return iterator.next();
}
return null;
}
|
java
|
public T ceiling(T T) {
if (T == null) {
return null;
}
NodeIterator<T> iterator = new NodeIterator<>(root, T.end(), Integer.MAX_VALUE, true);
if (iterator.hasNext()) {
return iterator.next();
}
return null;
}
|
[
"public",
"T",
"ceiling",
"(",
"T",
"T",
")",
"{",
"if",
"(",
"T",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"NodeIterator",
"<",
"T",
">",
"iterator",
"=",
"new",
"NodeIterator",
"<>",
"(",
"root",
",",
"T",
".",
"end",
"(",
")",
",",
"Integer",
".",
"MAX_VALUE",
",",
"true",
")",
";",
"if",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
"iterator",
".",
"next",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Ceiling T.
@param T the T
@return the T
|
[
"Ceiling",
"T",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/collection/IntervalTree.java#L600-L609
|
145,298
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/storage/ModelBatch.java
|
ModelBatch.readFrom
|
private void readFrom(InputStream inputStream, Consumer<GraphicalModel> featurizer) throws IOException {
GraphicalModel read;
while ((read = GraphicalModel.readFromStream(inputStream)) != null) {
featurizer.accept(read);
add(read);
}
}
|
java
|
private void readFrom(InputStream inputStream, Consumer<GraphicalModel> featurizer) throws IOException {
GraphicalModel read;
while ((read = GraphicalModel.readFromStream(inputStream)) != null) {
featurizer.accept(read);
add(read);
}
}
|
[
"private",
"void",
"readFrom",
"(",
"InputStream",
"inputStream",
",",
"Consumer",
"<",
"GraphicalModel",
">",
"featurizer",
")",
"throws",
"IOException",
"{",
"GraphicalModel",
"read",
";",
"while",
"(",
"(",
"read",
"=",
"GraphicalModel",
".",
"readFromStream",
"(",
"inputStream",
")",
")",
"!=",
"null",
")",
"{",
"featurizer",
".",
"accept",
"(",
"read",
")",
";",
"add",
"(",
"read",
")",
";",
"}",
"}"
] |
Load a batch of models from disk, while running the function "featurizer" on each of the models before adding it
to the batch. This gives the loader a chance to experiment with new featurization techniques.
@param inputStream the input stream to load from
@param featurizer a function that gets run on every GraphicalModel, and has a chance to edit them (eg by adding
or changing features)
|
[
"Load",
"a",
"batch",
"of",
"models",
"from",
"disk",
"while",
"running",
"the",
"function",
"featurizer",
"on",
"each",
"of",
"the",
"models",
"before",
"adding",
"it",
"to",
"the",
"batch",
".",
"This",
"gives",
"the",
"loader",
"a",
"chance",
"to",
"experiment",
"with",
"new",
"featurization",
"techniques",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/storage/ModelBatch.java#L84-L90
|
145,299
|
keenon/loglinear
|
src/main/java/com/github/keenon/loglinear/storage/ModelBatch.java
|
ModelBatch.writeToFile
|
public void writeToFile(String filename) throws IOException {
FileOutputStream fos = new FileOutputStream(filename);
writeToStream(fos);
fos.close();
}
|
java
|
public void writeToFile(String filename) throws IOException {
FileOutputStream fos = new FileOutputStream(filename);
writeToStream(fos);
fos.close();
}
|
[
"public",
"void",
"writeToFile",
"(",
"String",
"filename",
")",
"throws",
"IOException",
"{",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"filename",
")",
";",
"writeToStream",
"(",
"fos",
")",
";",
"fos",
".",
"close",
"(",
")",
";",
"}"
] |
Convenience function to write the current state of the modelBatch out to a file, including all factors.
WARNING: These files can get quite large, if you're using large embeddings as features.
@param filename the file to write the batch to
@throws IOException
|
[
"Convenience",
"function",
"to",
"write",
"the",
"current",
"state",
"of",
"the",
"modelBatch",
"out",
"to",
"a",
"file",
"including",
"all",
"factors",
"."
] |
fa0c370ab6782015412f676ef2ab11c97be58e29
|
https://github.com/keenon/loglinear/blob/fa0c370ab6782015412f676ef2ab11c97be58e29/src/main/java/com/github/keenon/loglinear/storage/ModelBatch.java#L100-L104
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.