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,100
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheEngines.java
|
CacheEngines.get
|
public static CacheEngine get(String name) {
if (!engines.containsKey(name)) {
throw new IllegalArgumentException(name + " is not a valid cache engine name.");
}
return engines.get(name);
}
|
java
|
public static CacheEngine get(String name) {
if (!engines.containsKey(name)) {
throw new IllegalArgumentException(name + " is not a valid cache engine name.");
}
return engines.get(name);
}
|
[
"public",
"static",
"CacheEngine",
"get",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"!",
"engines",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"name",
"+",
"\" is not a valid cache engine name.\"",
")",
";",
"}",
"return",
"engines",
".",
"get",
"(",
"name",
")",
";",
"}"
] |
Gets the cache engine associated with the given name
@param name the name of the cache engine
@return the cache engine associated with the given name
@throws IllegalArgumentException If the name is not a valid cache engine name
|
[
"Gets",
"the",
"cache",
"engine",
"associated",
"with",
"the",
"given",
"name"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheEngines.java#L60-L65
|
145,101
|
massimozappino/tagmycode-java-plugin-framework
|
src/main/java/com/tagmycode/plugin/gui/TextPrompt.java
|
TextPrompt.changeAlpha
|
public void changeAlpha(int alpha) {
alpha = alpha > 255 ? 255 : alpha < 0 ? 0 : alpha;
Color foreground = getForeground();
int red = foreground.getRed();
int green = foreground.getGreen();
int blue = foreground.getBlue();
Color withAlpha = new Color(red, green, blue, alpha);
super.setForeground(withAlpha);
}
|
java
|
public void changeAlpha(int alpha) {
alpha = alpha > 255 ? 255 : alpha < 0 ? 0 : alpha;
Color foreground = getForeground();
int red = foreground.getRed();
int green = foreground.getGreen();
int blue = foreground.getBlue();
Color withAlpha = new Color(red, green, blue, alpha);
super.setForeground(withAlpha);
}
|
[
"public",
"void",
"changeAlpha",
"(",
"int",
"alpha",
")",
"{",
"alpha",
"=",
"alpha",
">",
"255",
"?",
"255",
":",
"alpha",
"<",
"0",
"?",
"0",
":",
"alpha",
";",
"Color",
"foreground",
"=",
"getForeground",
"(",
")",
";",
"int",
"red",
"=",
"foreground",
".",
"getRed",
"(",
")",
";",
"int",
"green",
"=",
"foreground",
".",
"getGreen",
"(",
")",
";",
"int",
"blue",
"=",
"foreground",
".",
"getBlue",
"(",
")",
";",
"Color",
"withAlpha",
"=",
"new",
"Color",
"(",
"red",
",",
"green",
",",
"blue",
",",
"alpha",
")",
";",
"super",
".",
"setForeground",
"(",
"withAlpha",
")",
";",
"}"
] |
Convenience method to applyChanges the alpha value of the current foreground
Color to the specifice value.
@param alpha value in the range of 0 - 255.
|
[
"Convenience",
"method",
"to",
"applyChanges",
"the",
"alpha",
"value",
"of",
"the",
"current",
"foreground",
"Color",
"to",
"the",
"specifice",
"value",
"."
] |
06637e32bf737e3e0d318859c718815edac9d0f0
|
https://github.com/massimozappino/tagmycode-java-plugin-framework/blob/06637e32bf737e3e0d318859c718815edac9d0f0/src/main/java/com/tagmycode/plugin/gui/TextPrompt.java#L68-L78
|
145,102
|
massimozappino/tagmycode-java-plugin-framework
|
src/main/java/com/tagmycode/plugin/gui/TextPrompt.java
|
TextPrompt.checkForPrompt
|
private void checkForPrompt() {
// Text has been entered, remove the prompt
if (document.getLength() > 0) {
setVisible(false);
return;
}
// Prompt has already been shown once, remove it
if (showPromptOnce && focusLost > 0) {
setVisible(false);
return;
}
// Check the Show property and component focus to determine if the
// prompt should be displayed.
if (component.hasFocus()) {
if (show == Show.ALWAYS
|| show == Show.FOCUS_GAINED)
setVisible(true);
else
setVisible(false);
} else {
if (show == Show.ALWAYS
|| show == Show.FOCUS_LOST)
setVisible(true);
else
setVisible(false);
}
}
|
java
|
private void checkForPrompt() {
// Text has been entered, remove the prompt
if (document.getLength() > 0) {
setVisible(false);
return;
}
// Prompt has already been shown once, remove it
if (showPromptOnce && focusLost > 0) {
setVisible(false);
return;
}
// Check the Show property and component focus to determine if the
// prompt should be displayed.
if (component.hasFocus()) {
if (show == Show.ALWAYS
|| show == Show.FOCUS_GAINED)
setVisible(true);
else
setVisible(false);
} else {
if (show == Show.ALWAYS
|| show == Show.FOCUS_LOST)
setVisible(true);
else
setVisible(false);
}
}
|
[
"private",
"void",
"checkForPrompt",
"(",
")",
"{",
"// Text has been entered, remove the prompt",
"if",
"(",
"document",
".",
"getLength",
"(",
")",
">",
"0",
")",
"{",
"setVisible",
"(",
"false",
")",
";",
"return",
";",
"}",
"// Prompt has already been shown once, remove it",
"if",
"(",
"showPromptOnce",
"&&",
"focusLost",
">",
"0",
")",
"{",
"setVisible",
"(",
"false",
")",
";",
"return",
";",
"}",
"// Check the Show property and component focus to determine if the",
"// prompt should be displayed.",
"if",
"(",
"component",
".",
"hasFocus",
"(",
")",
")",
"{",
"if",
"(",
"show",
"==",
"Show",
".",
"ALWAYS",
"||",
"show",
"==",
"Show",
".",
"FOCUS_GAINED",
")",
"setVisible",
"(",
"true",
")",
";",
"else",
"setVisible",
"(",
"false",
")",
";",
"}",
"else",
"{",
"if",
"(",
"show",
"==",
"Show",
".",
"ALWAYS",
"||",
"show",
"==",
"Show",
".",
"FOCUS_LOST",
")",
"setVisible",
"(",
"true",
")",
";",
"else",
"setVisible",
"(",
"false",
")",
";",
"}",
"}"
] |
Check whether the prompt should be visible or not. The visibility
will applyChanges on updates to the Document and on focus changes.
|
[
"Check",
"whether",
"the",
"prompt",
"should",
"be",
"visible",
"or",
"not",
".",
"The",
"visibility",
"will",
"applyChanges",
"on",
"updates",
"to",
"the",
"Document",
"and",
"on",
"focus",
"changes",
"."
] |
06637e32bf737e3e0d318859c718815edac9d0f0
|
https://github.com/massimozappino/tagmycode-java-plugin-framework/blob/06637e32bf737e3e0d318859c718815edac9d0f0/src/main/java/com/tagmycode/plugin/gui/TextPrompt.java#L140-L171
|
145,103
|
dbracewell/mango
|
src/main/java/com/davidbracewell/collection/Trie.java
|
Trie.trimToSize
|
public Trie<V> trimToSize() {
Queue<TrieNode<V>> queue = new LinkedList<>();
queue.add(root);
while (!queue.isEmpty()) {
TrieNode<V> node = queue.remove();
node.children.trimToSize();
queue.addAll(node.children);
}
return this;
}
|
java
|
public Trie<V> trimToSize() {
Queue<TrieNode<V>> queue = new LinkedList<>();
queue.add(root);
while (!queue.isEmpty()) {
TrieNode<V> node = queue.remove();
node.children.trimToSize();
queue.addAll(node.children);
}
return this;
}
|
[
"public",
"Trie",
"<",
"V",
">",
"trimToSize",
"(",
")",
"{",
"Queue",
"<",
"TrieNode",
"<",
"V",
">>",
"queue",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"queue",
".",
"add",
"(",
"root",
")",
";",
"while",
"(",
"!",
"queue",
".",
"isEmpty",
"(",
")",
")",
"{",
"TrieNode",
"<",
"V",
">",
"node",
"=",
"queue",
".",
"remove",
"(",
")",
";",
"node",
".",
"children",
".",
"trimToSize",
"(",
")",
";",
"queue",
".",
"addAll",
"(",
"node",
".",
"children",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Compresses the memory of the individual trie nodes.
@return this trie
|
[
"Compresses",
"the",
"memory",
"of",
"the",
"individual",
"trie",
"nodes",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/collection/Trie.java#L367-L376
|
145,104
|
wanglinsong/testharness
|
src/main/java/com/tascape/qa/th/libx/DefaultExecutor.java
|
DefaultExecutor.createThread
|
@Override
protected Thread createThread(final Runnable runnable, final String name) {
return new Thread(runnable, Thread.currentThread().getName() + "-exec");
}
|
java
|
@Override
protected Thread createThread(final Runnable runnable, final String name) {
return new Thread(runnable, Thread.currentThread().getName() + "-exec");
}
|
[
"@",
"Override",
"protected",
"Thread",
"createThread",
"(",
"final",
"Runnable",
"runnable",
",",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"Thread",
"(",
"runnable",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"-exec\"",
")",
";",
"}"
] |
Factory method to create a thread waiting for the result of an
asynchronous execution.
@param runnable the runnable passed to the thread
@param name the name of the thread
@return the thread
|
[
"Factory",
"method",
"to",
"create",
"a",
"thread",
"waiting",
"for",
"the",
"result",
"of",
"an",
"asynchronous",
"execution",
"."
] |
76f3e4546648e0720f6f87a58cb91a09cd36dfca
|
https://github.com/wanglinsong/testharness/blob/76f3e4546648e0720f6f87a58cb91a09cd36dfca/src/main/java/com/tascape/qa/th/libx/DefaultExecutor.java#L33-L36
|
145,105
|
dbracewell/mango
|
src/main/java/com/davidbracewell/io/CSVReader.java
|
CSVReader.forEach
|
@Override
public void forEach(Consumer<? super List<String>> consumer) {
try (Stream<List<String>> stream = stream()) {
stream.forEach(consumer);
}
}
|
java
|
@Override
public void forEach(Consumer<? super List<String>> consumer) {
try (Stream<List<String>> stream = stream()) {
stream.forEach(consumer);
}
}
|
[
"@",
"Override",
"public",
"void",
"forEach",
"(",
"Consumer",
"<",
"?",
"super",
"List",
"<",
"String",
">",
">",
"consumer",
")",
"{",
"try",
"(",
"Stream",
"<",
"List",
"<",
"String",
">",
">",
"stream",
"=",
"stream",
"(",
")",
")",
"{",
"stream",
".",
"forEach",
"(",
"consumer",
")",
";",
"}",
"}"
] |
Convenience method for consuming all rows in the CSV file
@param consumer the consumer to use to process the rows
|
[
"Convenience",
"method",
"for",
"consuming",
"all",
"rows",
"in",
"the",
"CSV",
"file"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/io/CSVReader.java#L153-L158
|
145,106
|
dbracewell/mango
|
src/main/java/com/davidbracewell/io/CSVReader.java
|
CSVReader.getHeader
|
public List<String> getHeader() {
if (header == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(header);
}
|
java
|
public List<String> getHeader() {
if (header == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(header);
}
|
[
"public",
"List",
"<",
"String",
">",
"getHeader",
"(",
")",
"{",
"if",
"(",
"header",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"header",
")",
";",
"}"
] |
Gets the header read in from the csv file or specified via the CSV specification.
@return The header of the CSV file
|
[
"Gets",
"the",
"header",
"read",
"in",
"from",
"the",
"csv",
"file",
"or",
"specified",
"via",
"the",
"CSV",
"specification",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/io/CSVReader.java#L165-L170
|
145,107
|
dbracewell/mango
|
src/main/java/com/davidbracewell/io/CSVReader.java
|
CSVReader.nextRow
|
public List<String> nextRow() throws IOException {
row = new ArrayList<>();
STATE = START;
int c;
int readCount = 0;
gobbleWhiteSpace();
while ((c = read()) != -1) {
if (c == '\r') {
if (bufferPeek() == '\n') {
continue;
} else {
c = '\n';
}
}
readCount++;
switch (STATE) {
case START:
STATE = beginOfLine(c);
break;
case IN_QUOTE:
wasQuoted = true;
STATE = inField(c, true);
break;
case IN_FIELD:
STATE = inField(c, false);
break;
case OUT_QUOTE:
STATE = outQuote(c);
break;
default:
throw new IOException("State [" + STATE + "]");
}
if (STATE == END_OF_ROW) {
break;
}
}
if (readCount > 0) {
addCell(wasQuoted);
}
if (row.isEmpty()) {
return null;
}
return new ArrayList<>(row);
}
|
java
|
public List<String> nextRow() throws IOException {
row = new ArrayList<>();
STATE = START;
int c;
int readCount = 0;
gobbleWhiteSpace();
while ((c = read()) != -1) {
if (c == '\r') {
if (bufferPeek() == '\n') {
continue;
} else {
c = '\n';
}
}
readCount++;
switch (STATE) {
case START:
STATE = beginOfLine(c);
break;
case IN_QUOTE:
wasQuoted = true;
STATE = inField(c, true);
break;
case IN_FIELD:
STATE = inField(c, false);
break;
case OUT_QUOTE:
STATE = outQuote(c);
break;
default:
throw new IOException("State [" + STATE + "]");
}
if (STATE == END_OF_ROW) {
break;
}
}
if (readCount > 0) {
addCell(wasQuoted);
}
if (row.isEmpty()) {
return null;
}
return new ArrayList<>(row);
}
|
[
"public",
"List",
"<",
"String",
">",
"nextRow",
"(",
")",
"throws",
"IOException",
"{",
"row",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"STATE",
"=",
"START",
";",
"int",
"c",
";",
"int",
"readCount",
"=",
"0",
";",
"gobbleWhiteSpace",
"(",
")",
";",
"while",
"(",
"(",
"c",
"=",
"read",
"(",
")",
")",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"bufferPeek",
"(",
")",
"==",
"'",
"'",
")",
"{",
"continue",
";",
"}",
"else",
"{",
"c",
"=",
"'",
"'",
";",
"}",
"}",
"readCount",
"++",
";",
"switch",
"(",
"STATE",
")",
"{",
"case",
"START",
":",
"STATE",
"=",
"beginOfLine",
"(",
"c",
")",
";",
"break",
";",
"case",
"IN_QUOTE",
":",
"wasQuoted",
"=",
"true",
";",
"STATE",
"=",
"inField",
"(",
"c",
",",
"true",
")",
";",
"break",
";",
"case",
"IN_FIELD",
":",
"STATE",
"=",
"inField",
"(",
"c",
",",
"false",
")",
";",
"break",
";",
"case",
"OUT_QUOTE",
":",
"STATE",
"=",
"outQuote",
"(",
"c",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IOException",
"(",
"\"State [\"",
"+",
"STATE",
"+",
"\"]\"",
")",
";",
"}",
"if",
"(",
"STATE",
"==",
"END_OF_ROW",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"readCount",
">",
"0",
")",
"{",
"addCell",
"(",
"wasQuoted",
")",
";",
"}",
"if",
"(",
"row",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"ArrayList",
"<>",
"(",
"row",
")",
";",
"}"
] |
Reads the next row from the CSV file retuning null if there are not anymore
@return the row as a list of strings or null if there are not any more rows to read
@throws IOException Something went wrong reading the file
|
[
"Reads",
"the",
"next",
"row",
"from",
"the",
"CSV",
"file",
"retuning",
"null",
"if",
"there",
"are",
"not",
"anymore"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/io/CSVReader.java#L218-L261
|
145,108
|
dbracewell/mango
|
src/main/java/com/davidbracewell/io/CSVReader.java
|
CSVReader.stream
|
public Stream<List<String>> stream() {
return Streams.asStream(new RowIterator()).onClose(Unchecked.runnable(this::close));
}
|
java
|
public Stream<List<String>> stream() {
return Streams.asStream(new RowIterator()).onClose(Unchecked.runnable(this::close));
}
|
[
"public",
"Stream",
"<",
"List",
"<",
"String",
">",
">",
"stream",
"(",
")",
"{",
"return",
"Streams",
".",
"asStream",
"(",
"new",
"RowIterator",
"(",
")",
")",
".",
"onClose",
"(",
"Unchecked",
".",
"runnable",
"(",
"this",
"::",
"close",
")",
")",
";",
"}"
] |
Creates a new stream over the rows in the file that will close underlying reader on stream close.
@return the stream of rows in the file
|
[
"Creates",
"a",
"new",
"stream",
"over",
"the",
"rows",
"in",
"the",
"file",
"that",
"will",
"close",
"underlying",
"reader",
"on",
"stream",
"close",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/io/CSVReader.java#L326-L328
|
145,109
|
vst/commons-math-extensions
|
src/main/java/com/vsthost/rnd/commons/math/ext/linear/IOUtils.java
|
IOUtils.readMatrix
|
public static RealMatrix readMatrix (Reader reader) throws IOException {
// Initialize the return value:
List<double[]> retval = new ArrayList<>();
// Parse and get the iterarable:
Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(reader);
// Iterate over the records and populate return value:
for (CSVRecord record : records) {
double[] row = new double[record.size()];
for (int i = 0; i < record.size(); i++) {
row[i] = Double.parseDouble(record.get(i));
}
retval.add(row);
}
// Convert the list to an array:
double[][] retvalArray = new double[retval.size()][];
retval.toArray(retvalArray);
// Done, return the array:
return MatrixUtils.createRealMatrix(retvalArray);
}
|
java
|
public static RealMatrix readMatrix (Reader reader) throws IOException {
// Initialize the return value:
List<double[]> retval = new ArrayList<>();
// Parse and get the iterarable:
Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(reader);
// Iterate over the records and populate return value:
for (CSVRecord record : records) {
double[] row = new double[record.size()];
for (int i = 0; i < record.size(); i++) {
row[i] = Double.parseDouble(record.get(i));
}
retval.add(row);
}
// Convert the list to an array:
double[][] retvalArray = new double[retval.size()][];
retval.toArray(retvalArray);
// Done, return the array:
return MatrixUtils.createRealMatrix(retvalArray);
}
|
[
"public",
"static",
"RealMatrix",
"readMatrix",
"(",
"Reader",
"reader",
")",
"throws",
"IOException",
"{",
"// Initialize the return value:",
"List",
"<",
"double",
"[",
"]",
">",
"retval",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// Parse and get the iterarable:",
"Iterable",
"<",
"CSVRecord",
">",
"records",
"=",
"CSVFormat",
".",
"EXCEL",
".",
"parse",
"(",
"reader",
")",
";",
"// Iterate over the records and populate return value:",
"for",
"(",
"CSVRecord",
"record",
":",
"records",
")",
"{",
"double",
"[",
"]",
"row",
"=",
"new",
"double",
"[",
"record",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"record",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"row",
"[",
"i",
"]",
"=",
"Double",
".",
"parseDouble",
"(",
"record",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"retval",
".",
"add",
"(",
"row",
")",
";",
"}",
"// Convert the list to an array:",
"double",
"[",
"]",
"[",
"]",
"retvalArray",
"=",
"new",
"double",
"[",
"retval",
".",
"size",
"(",
")",
"]",
"[",
"",
"]",
";",
"retval",
".",
"toArray",
"(",
"retvalArray",
")",
";",
"// Done, return the array:",
"return",
"MatrixUtils",
".",
"createRealMatrix",
"(",
"retvalArray",
")",
";",
"}"
] |
Reads a matrix of double values from the reader provided.
@param reader The reader which the values to be read from.
@return A matrix
@throws IOException As thrown by the CSV parser.
|
[
"Reads",
"a",
"matrix",
"of",
"double",
"values",
"from",
"the",
"reader",
"provided",
"."
] |
a11ee78ffe53ab7c016062be93c5af07aa8e1823
|
https://github.com/vst/commons-math-extensions/blob/a11ee78ffe53ab7c016062be93c5af07aa8e1823/src/main/java/com/vsthost/rnd/commons/math/ext/linear/IOUtils.java#L54-L76
|
145,110
|
rwl/JKLU
|
src/main/java/edu/ufl/cise/klu/tdouble/Dklu_analyze_given.java
|
Dklu_analyze_given.klu_alloc_symbolic
|
protected static KLU_symbolic klu_alloc_symbolic(int n, int[] Ap, int[] Ai, KLU_common Common)
{
KLU_symbolic Symbolic ;
int[] P, Q, R ;
double[] Lnz ;
int nz, i, j, p, pend ;
if (Common == null)
{
return (null) ;
}
Common.status = KLU_OK ;
/* A is n-by-n, with n > 0. Ap [0] = 0 and nz = Ap [n] >= 0 required.
* Ap [j] <= Ap [j+1] must hold for all j = 0 to n-1. Row indices in Ai
* must be in the range 0 to n-1, and no duplicate entries can be present.
* The list of row indices in each column of A need not be sorted.
*/
if (n <= 0 || Ap == null || Ai == null)
{
/* Ap and Ai must be present, and n must be > 0 */
Common.status = KLU_INVALID ;
return (null) ;
}
nz = Ap [n] ;
if (Ap [0] != 0 || nz < 0)
{
/* nz must be >= 0 and Ap [0] must equal zero */
Common.status = KLU_INVALID ;
return (null) ;
}
for (j = 0 ; j < n ; j++)
{
if (Ap [j] > Ap [j+1])
{
/* column pointers must be non-decreasing */
Common.status = KLU_INVALID ;
return (null) ;
}
}
P = klu_malloc_int (n, Common) ;
if (Common.status < KLU_OK)
{
/* out of memory */
Common.status = KLU_OUT_OF_MEMORY ;
return (null) ;
}
for (i = 0 ; i < n ; i++)
{
P [i] = EMPTY ;
}
for (j = 0 ; j < n ; j++)
{
pend = Ap [j+1] ;
for (p = Ap [j] ; p < pend ; p++)
{
i = Ai [p] ;
if (i < 0 || i >= n || P [i] == j)
{
/* row index out of range, or duplicate entry */
//klu_free (P, n, Integer.class, Common) ;
P = null;
Common.status = KLU_INVALID ;
return (null) ;
}
/* flag row i as appearing in column j */
P [i] = j ;
}
}
/* ---------------------------------------------------------------------- */
/* allocate the Symbolic object */
/* ---------------------------------------------------------------------- */
try {
//Symbolic = klu_malloc (KLU_symbolic.class, 1, Common) ;
Symbolic = new KLU_symbolic();
} catch (OutOfMemoryError e) {
/* out of memory */
//klu_free (P, n, sizeof (int), Common) ;
P = null;
Common.status = KLU_OUT_OF_MEMORY ;
return (null) ;
}
Q = klu_malloc_int(n, Common) ;
R = klu_malloc_int (n+1, Common) ;
Lnz = klu_malloc_dbl (n, Common) ;
Symbolic.n = n ;
Symbolic.nz = nz ;
Symbolic.P = P ;
Symbolic.Q = Q ;
Symbolic.R = R ;
Symbolic.Lnz = Lnz ;
if (Common.status < KLU_OK)
{
/* out of memory */
//klu_free_symbolic (Symbolic, Common) ;
Symbolic = null;
Common.status = KLU_OUT_OF_MEMORY ;
return (null) ;
}
return (Symbolic) ;
}
|
java
|
protected static KLU_symbolic klu_alloc_symbolic(int n, int[] Ap, int[] Ai, KLU_common Common)
{
KLU_symbolic Symbolic ;
int[] P, Q, R ;
double[] Lnz ;
int nz, i, j, p, pend ;
if (Common == null)
{
return (null) ;
}
Common.status = KLU_OK ;
/* A is n-by-n, with n > 0. Ap [0] = 0 and nz = Ap [n] >= 0 required.
* Ap [j] <= Ap [j+1] must hold for all j = 0 to n-1. Row indices in Ai
* must be in the range 0 to n-1, and no duplicate entries can be present.
* The list of row indices in each column of A need not be sorted.
*/
if (n <= 0 || Ap == null || Ai == null)
{
/* Ap and Ai must be present, and n must be > 0 */
Common.status = KLU_INVALID ;
return (null) ;
}
nz = Ap [n] ;
if (Ap [0] != 0 || nz < 0)
{
/* nz must be >= 0 and Ap [0] must equal zero */
Common.status = KLU_INVALID ;
return (null) ;
}
for (j = 0 ; j < n ; j++)
{
if (Ap [j] > Ap [j+1])
{
/* column pointers must be non-decreasing */
Common.status = KLU_INVALID ;
return (null) ;
}
}
P = klu_malloc_int (n, Common) ;
if (Common.status < KLU_OK)
{
/* out of memory */
Common.status = KLU_OUT_OF_MEMORY ;
return (null) ;
}
for (i = 0 ; i < n ; i++)
{
P [i] = EMPTY ;
}
for (j = 0 ; j < n ; j++)
{
pend = Ap [j+1] ;
for (p = Ap [j] ; p < pend ; p++)
{
i = Ai [p] ;
if (i < 0 || i >= n || P [i] == j)
{
/* row index out of range, or duplicate entry */
//klu_free (P, n, Integer.class, Common) ;
P = null;
Common.status = KLU_INVALID ;
return (null) ;
}
/* flag row i as appearing in column j */
P [i] = j ;
}
}
/* ---------------------------------------------------------------------- */
/* allocate the Symbolic object */
/* ---------------------------------------------------------------------- */
try {
//Symbolic = klu_malloc (KLU_symbolic.class, 1, Common) ;
Symbolic = new KLU_symbolic();
} catch (OutOfMemoryError e) {
/* out of memory */
//klu_free (P, n, sizeof (int), Common) ;
P = null;
Common.status = KLU_OUT_OF_MEMORY ;
return (null) ;
}
Q = klu_malloc_int(n, Common) ;
R = klu_malloc_int (n+1, Common) ;
Lnz = klu_malloc_dbl (n, Common) ;
Symbolic.n = n ;
Symbolic.nz = nz ;
Symbolic.P = P ;
Symbolic.Q = Q ;
Symbolic.R = R ;
Symbolic.Lnz = Lnz ;
if (Common.status < KLU_OK)
{
/* out of memory */
//klu_free_symbolic (Symbolic, Common) ;
Symbolic = null;
Common.status = KLU_OUT_OF_MEMORY ;
return (null) ;
}
return (Symbolic) ;
}
|
[
"protected",
"static",
"KLU_symbolic",
"klu_alloc_symbolic",
"(",
"int",
"n",
",",
"int",
"[",
"]",
"Ap",
",",
"int",
"[",
"]",
"Ai",
",",
"KLU_common",
"Common",
")",
"{",
"KLU_symbolic",
"Symbolic",
";",
"int",
"[",
"]",
"P",
",",
"Q",
",",
"R",
";",
"double",
"[",
"]",
"Lnz",
";",
"int",
"nz",
",",
"i",
",",
"j",
",",
"p",
",",
"pend",
";",
"if",
"(",
"Common",
"==",
"null",
")",
"{",
"return",
"(",
"null",
")",
";",
"}",
"Common",
".",
"status",
"=",
"KLU_OK",
";",
"/* A is n-by-n, with n > 0. Ap [0] = 0 and nz = Ap [n] >= 0 required.\n\t\t * Ap [j] <= Ap [j+1] must hold for all j = 0 to n-1. Row indices in Ai\n\t\t * must be in the range 0 to n-1, and no duplicate entries can be present.\n\t\t * The list of row indices in each column of A need not be sorted.\n\t\t */",
"if",
"(",
"n",
"<=",
"0",
"||",
"Ap",
"==",
"null",
"||",
"Ai",
"==",
"null",
")",
"{",
"/* Ap and Ai must be present, and n must be > 0 */",
"Common",
".",
"status",
"=",
"KLU_INVALID",
";",
"return",
"(",
"null",
")",
";",
"}",
"nz",
"=",
"Ap",
"[",
"n",
"]",
";",
"if",
"(",
"Ap",
"[",
"0",
"]",
"!=",
"0",
"||",
"nz",
"<",
"0",
")",
"{",
"/* nz must be >= 0 and Ap [0] must equal zero */",
"Common",
".",
"status",
"=",
"KLU_INVALID",
";",
"return",
"(",
"null",
")",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"if",
"(",
"Ap",
"[",
"j",
"]",
">",
"Ap",
"[",
"j",
"+",
"1",
"]",
")",
"{",
"/* column pointers must be non-decreasing */",
"Common",
".",
"status",
"=",
"KLU_INVALID",
";",
"return",
"(",
"null",
")",
";",
"}",
"}",
"P",
"=",
"klu_malloc_int",
"(",
"n",
",",
"Common",
")",
";",
"if",
"(",
"Common",
".",
"status",
"<",
"KLU_OK",
")",
"{",
"/* out of memory */",
"Common",
".",
"status",
"=",
"KLU_OUT_OF_MEMORY",
";",
"return",
"(",
"null",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"P",
"[",
"i",
"]",
"=",
"EMPTY",
";",
"}",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"pend",
"=",
"Ap",
"[",
"j",
"+",
"1",
"]",
";",
"for",
"(",
"p",
"=",
"Ap",
"[",
"j",
"]",
";",
"p",
"<",
"pend",
";",
"p",
"++",
")",
"{",
"i",
"=",
"Ai",
"[",
"p",
"]",
";",
"if",
"(",
"i",
"<",
"0",
"||",
"i",
">=",
"n",
"||",
"P",
"[",
"i",
"]",
"==",
"j",
")",
"{",
"/* row index out of range, or duplicate entry */",
"//klu_free (P, n, Integer.class, Common) ;",
"P",
"=",
"null",
";",
"Common",
".",
"status",
"=",
"KLU_INVALID",
";",
"return",
"(",
"null",
")",
";",
"}",
"/* flag row i as appearing in column j */",
"P",
"[",
"i",
"]",
"=",
"j",
";",
"}",
"}",
"/* ---------------------------------------------------------------------- */",
"/* allocate the Symbolic object */",
"/* ---------------------------------------------------------------------- */",
"try",
"{",
"//Symbolic = klu_malloc (KLU_symbolic.class, 1, Common) ;",
"Symbolic",
"=",
"new",
"KLU_symbolic",
"(",
")",
";",
"}",
"catch",
"(",
"OutOfMemoryError",
"e",
")",
"{",
"/* out of memory */",
"//klu_free (P, n, sizeof (int), Common) ;",
"P",
"=",
"null",
";",
"Common",
".",
"status",
"=",
"KLU_OUT_OF_MEMORY",
";",
"return",
"(",
"null",
")",
";",
"}",
"Q",
"=",
"klu_malloc_int",
"(",
"n",
",",
"Common",
")",
";",
"R",
"=",
"klu_malloc_int",
"(",
"n",
"+",
"1",
",",
"Common",
")",
";",
"Lnz",
"=",
"klu_malloc_dbl",
"(",
"n",
",",
"Common",
")",
";",
"Symbolic",
".",
"n",
"=",
"n",
";",
"Symbolic",
".",
"nz",
"=",
"nz",
";",
"Symbolic",
".",
"P",
"=",
"P",
";",
"Symbolic",
".",
"Q",
"=",
"Q",
";",
"Symbolic",
".",
"R",
"=",
"R",
";",
"Symbolic",
".",
"Lnz",
"=",
"Lnz",
";",
"if",
"(",
"Common",
".",
"status",
"<",
"KLU_OK",
")",
"{",
"/* out of memory */",
"//klu_free_symbolic (Symbolic, Common) ;",
"Symbolic",
"=",
"null",
";",
"Common",
".",
"status",
"=",
"KLU_OUT_OF_MEMORY",
";",
"return",
"(",
"null",
")",
";",
"}",
"return",
"(",
"Symbolic",
")",
";",
"}"
] |
Allocate Symbolic object, and check input matrix. Not user callable.
@param n
@param Ap
@param Ai
@param Common
@return
|
[
"Allocate",
"Symbolic",
"object",
"and",
"check",
"input",
"matrix",
".",
"Not",
"user",
"callable",
"."
] |
4e5fcdfb479040be72b4642ff1682670142b4892
|
https://github.com/rwl/JKLU/blob/4e5fcdfb479040be72b4642ff1682670142b4892/src/main/java/edu/ufl/cise/klu/tdouble/Dklu_analyze_given.java#L54-L163
|
145,111
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/device/Device.java
|
Device.connectToLink
|
public void connectToLink(Link link) throws ShanksException {
if (!this.linksList.contains(link)) {
this.linksList.add(link);
logger.finer("Device " + this.getID()
+ " is now connected to Link " + link.getID());
link.connectDevice(this);
}
}
|
java
|
public void connectToLink(Link link) throws ShanksException {
if (!this.linksList.contains(link)) {
this.linksList.add(link);
logger.finer("Device " + this.getID()
+ " is now connected to Link " + link.getID());
link.connectDevice(this);
}
}
|
[
"public",
"void",
"connectToLink",
"(",
"Link",
"link",
")",
"throws",
"ShanksException",
"{",
"if",
"(",
"!",
"this",
".",
"linksList",
".",
"contains",
"(",
"link",
")",
")",
"{",
"this",
".",
"linksList",
".",
"add",
"(",
"link",
")",
";",
"logger",
".",
"finer",
"(",
"\"Device \"",
"+",
"this",
".",
"getID",
"(",
")",
"+",
"\" is now connected to Link \"",
"+",
"link",
".",
"getID",
"(",
")",
")",
";",
"link",
".",
"connectDevice",
"(",
"this",
")",
";",
"}",
"}"
] |
Connect the device to a link
@param link
@throws TooManyConnectionException
|
[
"Connect",
"the",
"device",
"to",
"a",
"link"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/device/Device.java#L88-L95
|
145,112
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/device/Device.java
|
Device.disconnectFromLink
|
public void disconnectFromLink(Link link) {
boolean disconnected = this.linksList.remove(link);
if (disconnected) {
link.disconnectDevice(this);
logger.fine("Device " + this.getID()
+ " is now disconnected from Link " + link.getID());
} else {
logger.warning("Device " + this.getID()
+ " could not be disconnected from Link " + link.getID()
+ ", because it was not connected.");
}
}
|
java
|
public void disconnectFromLink(Link link) {
boolean disconnected = this.linksList.remove(link);
if (disconnected) {
link.disconnectDevice(this);
logger.fine("Device " + this.getID()
+ " is now disconnected from Link " + link.getID());
} else {
logger.warning("Device " + this.getID()
+ " could not be disconnected from Link " + link.getID()
+ ", because it was not connected.");
}
}
|
[
"public",
"void",
"disconnectFromLink",
"(",
"Link",
"link",
")",
"{",
"boolean",
"disconnected",
"=",
"this",
".",
"linksList",
".",
"remove",
"(",
"link",
")",
";",
"if",
"(",
"disconnected",
")",
"{",
"link",
".",
"disconnectDevice",
"(",
"this",
")",
";",
"logger",
".",
"fine",
"(",
"\"Device \"",
"+",
"this",
".",
"getID",
"(",
")",
"+",
"\" is now disconnected from Link \"",
"+",
"link",
".",
"getID",
"(",
")",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warning",
"(",
"\"Device \"",
"+",
"this",
".",
"getID",
"(",
")",
"+",
"\" could not be disconnected from Link \"",
"+",
"link",
".",
"getID",
"(",
")",
"+",
"\", because it was not connected.\"",
")",
";",
"}",
"}"
] |
Disconnect the device From a link
@param link
|
[
"Disconnect",
"the",
"device",
"From",
"a",
"link"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/device/Device.java#L102-L113
|
145,113
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/device/Device.java
|
Device.connectToDeviceWithLink
|
public void connectToDeviceWithLink(Device device, Link link)
throws ShanksException {
this.connectToLink(link);
try {
device.connectToLink(link);
} catch (ShanksException e) {
this.disconnectFromLink(link);
throw e;
}
}
|
java
|
public void connectToDeviceWithLink(Device device, Link link)
throws ShanksException {
this.connectToLink(link);
try {
device.connectToLink(link);
} catch (ShanksException e) {
this.disconnectFromLink(link);
throw e;
}
}
|
[
"public",
"void",
"connectToDeviceWithLink",
"(",
"Device",
"device",
",",
"Link",
"link",
")",
"throws",
"ShanksException",
"{",
"this",
".",
"connectToLink",
"(",
"link",
")",
";",
"try",
"{",
"device",
".",
"connectToLink",
"(",
"link",
")",
";",
"}",
"catch",
"(",
"ShanksException",
"e",
")",
"{",
"this",
".",
"disconnectFromLink",
"(",
"link",
")",
";",
"throw",
"e",
";",
"}",
"}"
] |
Connect the device to other device with a link
@param device
@param link
@throws TooManyConnectionException
|
[
"Connect",
"the",
"device",
"to",
"other",
"device",
"with",
"a",
"link"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/element/device/Device.java#L122-L131
|
145,114
|
dbracewell/mango
|
src/main/java/com/davidbracewell/io/JarUtils.java
|
JarUtils.getClasspathResources
|
public static List<Resource> getClasspathResources() {
synchronized (classpathResources) {
if (classpathResources.isEmpty()) {
for (String jar : SystemInfo.JAVA_CLASS_PATH.split(SystemInfo.PATH_SEPARATOR)) {
File file = new File(jar);
if (file.isDirectory()) {
classpathResources.addAll(new FileResource(file).getChildren(true));
} else {
classpathResources.addAll(getJarContents(Resources.fromFile(jar), v -> true));
}
}
}
return Collections.unmodifiableList(classpathResources);
}
}
|
java
|
public static List<Resource> getClasspathResources() {
synchronized (classpathResources) {
if (classpathResources.isEmpty()) {
for (String jar : SystemInfo.JAVA_CLASS_PATH.split(SystemInfo.PATH_SEPARATOR)) {
File file = new File(jar);
if (file.isDirectory()) {
classpathResources.addAll(new FileResource(file).getChildren(true));
} else {
classpathResources.addAll(getJarContents(Resources.fromFile(jar), v -> true));
}
}
}
return Collections.unmodifiableList(classpathResources);
}
}
|
[
"public",
"static",
"List",
"<",
"Resource",
">",
"getClasspathResources",
"(",
")",
"{",
"synchronized",
"(",
"classpathResources",
")",
"{",
"if",
"(",
"classpathResources",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"String",
"jar",
":",
"SystemInfo",
".",
"JAVA_CLASS_PATH",
".",
"split",
"(",
"SystemInfo",
".",
"PATH_SEPARATOR",
")",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"jar",
")",
";",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"classpathResources",
".",
"addAll",
"(",
"new",
"FileResource",
"(",
"file",
")",
".",
"getChildren",
"(",
"true",
")",
")",
";",
"}",
"else",
"{",
"classpathResources",
".",
"addAll",
"(",
"getJarContents",
"(",
"Resources",
".",
"fromFile",
"(",
"jar",
")",
",",
"v",
"->",
"true",
")",
")",
";",
"}",
"}",
"}",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"classpathResources",
")",
";",
"}",
"}"
] |
Gets classpath resources.
@return A list of all resources on the classpath
|
[
"Gets",
"classpath",
"resources",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/io/JarUtils.java#L116-L130
|
145,115
|
sangupta/jerry-services
|
src/main/java/com/sangupta/jerry/quartz/BaseQuartzJob.java
|
BaseQuartzJob.initializeApplicationContext
|
private void initializeApplicationContext(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
this.applicationContext = (ApplicationContext) jobExecutionContext.getScheduler().getContext().get("applicationContext");
if (this.applicationContext == null) {
throw new JobExecutionException("No application context available in scheduler context for key \"applicationContext\"");
}
} catch (SchedulerException e) {
getLogger().error("Error extracting Spring application context from SchedulerContext", e);
throw new JobExecutionException("Error fetching application context available in scheduler context for key \"applicationContext\"");
}
}
|
java
|
private void initializeApplicationContext(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
this.applicationContext = (ApplicationContext) jobExecutionContext.getScheduler().getContext().get("applicationContext");
if (this.applicationContext == null) {
throw new JobExecutionException("No application context available in scheduler context for key \"applicationContext\"");
}
} catch (SchedulerException e) {
getLogger().error("Error extracting Spring application context from SchedulerContext", e);
throw new JobExecutionException("Error fetching application context available in scheduler context for key \"applicationContext\"");
}
}
|
[
"private",
"void",
"initializeApplicationContext",
"(",
"JobExecutionContext",
"jobExecutionContext",
")",
"throws",
"JobExecutionException",
"{",
"try",
"{",
"this",
".",
"applicationContext",
"=",
"(",
"ApplicationContext",
")",
"jobExecutionContext",
".",
"getScheduler",
"(",
")",
".",
"getContext",
"(",
")",
".",
"get",
"(",
"\"applicationContext\"",
")",
";",
"if",
"(",
"this",
".",
"applicationContext",
"==",
"null",
")",
"{",
"throw",
"new",
"JobExecutionException",
"(",
"\"No application context available in scheduler context for key \\\"applicationContext\\\"\"",
")",
";",
"}",
"}",
"catch",
"(",
"SchedulerException",
"e",
")",
"{",
"getLogger",
"(",
")",
".",
"error",
"(",
"\"Error extracting Spring application context from SchedulerContext\"",
",",
"e",
")",
";",
"throw",
"new",
"JobExecutionException",
"(",
"\"Error fetching application context available in scheduler context for key \\\"applicationContext\\\"\"",
")",
";",
"}",
"}"
] |
Initialize Spring Application Context from Quartz SchedulerContext.
@param jobExecutionContext
the {@link JobExecutionContext} to use
@throws JobExecutionException
if something fails
|
[
"Initialize",
"Spring",
"Application",
"Context",
"from",
"Quartz",
"SchedulerContext",
"."
] |
25ff6577445850916425c72068d654c08eba9bcc
|
https://github.com/sangupta/jerry-services/blob/25ff6577445850916425c72068d654c08eba9bcc/src/main/java/com/sangupta/jerry/quartz/BaseQuartzJob.java#L91-L101
|
145,116
|
dbracewell/mango
|
src/main/java/com/davidbracewell/tuple/Tuple4.java
|
Tuple4.of
|
public static <A, B, C, D> Tuple4<A, B, C, D> of(A a, B b, C c, D d) {
return new Tuple4<>(a, b, c, d);
}
|
java
|
public static <A, B, C, D> Tuple4<A, B, C, D> of(A a, B b, C c, D d) {
return new Tuple4<>(a, b, c, d);
}
|
[
"public",
"static",
"<",
"A",
",",
"B",
",",
"C",
",",
"D",
">",
"Tuple4",
"<",
"A",
",",
"B",
",",
"C",
",",
"D",
">",
"of",
"(",
"A",
"a",
",",
"B",
"b",
",",
"C",
"c",
",",
"D",
"d",
")",
"{",
"return",
"new",
"Tuple4",
"<>",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
")",
";",
"}"
] |
Of tuple 4.
@param <A> the type parameter
@param <B> the type parameter
@param <C> the type parameter
@param <D> the type parameter
@param a the a
@param b the b
@param c the c
@param d the d
@return the tuple 4
|
[
"Of",
"tuple",
"4",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/tuple/Tuple4.java#L86-L88
|
145,117
|
NessComputing/service-discovery
|
jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java
|
ServiceDiscoveryTransportFactory.registerDiscoveryClient
|
static void registerDiscoveryClient(UUID injectorId, ReadOnlyDiscoveryClient discoveryClient, DiscoveryJmsConfig config) {
DISCO_CLIENTS.put(injectorId, discoveryClient);
CONFIGS.put(injectorId, config);
LOG.info("Registered discovery client %s as %s", injectorId, discoveryClient);
}
|
java
|
static void registerDiscoveryClient(UUID injectorId, ReadOnlyDiscoveryClient discoveryClient, DiscoveryJmsConfig config) {
DISCO_CLIENTS.put(injectorId, discoveryClient);
CONFIGS.put(injectorId, config);
LOG.info("Registered discovery client %s as %s", injectorId, discoveryClient);
}
|
[
"static",
"void",
"registerDiscoveryClient",
"(",
"UUID",
"injectorId",
",",
"ReadOnlyDiscoveryClient",
"discoveryClient",
",",
"DiscoveryJmsConfig",
"config",
")",
"{",
"DISCO_CLIENTS",
".",
"put",
"(",
"injectorId",
",",
"discoveryClient",
")",
";",
"CONFIGS",
".",
"put",
"(",
"injectorId",
",",
"config",
")",
";",
"LOG",
".",
"info",
"(",
"\"Registered discovery client %s as %s\"",
",",
"injectorId",
",",
"discoveryClient",
")",
";",
"}"
] |
Register a discoveryClient under a unique id. This works around the TransportFactory's inherent staticness
so that we may use the correct discovery client even in the presence of multiple injectors in the same JVM.
|
[
"Register",
"a",
"discoveryClient",
"under",
"a",
"unique",
"id",
".",
"This",
"works",
"around",
"the",
"TransportFactory",
"s",
"inherent",
"staticness",
"so",
"that",
"we",
"may",
"use",
"the",
"correct",
"discovery",
"client",
"even",
"in",
"the",
"presence",
"of",
"multiple",
"injectors",
"in",
"the",
"same",
"JVM",
"."
] |
5091ffdb1de6b12d216d1c238f72858037c7b765
|
https://github.com/NessComputing/service-discovery/blob/5091ffdb1de6b12d216d1c238f72858037c7b765/jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java#L70-L74
|
145,118
|
NessComputing/service-discovery
|
jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java
|
ServiceDiscoveryTransportFactory.findParameters
|
@SuppressWarnings("PMD.PreserveStackTrace")
private Map<String, String> findParameters(URI location) throws MalformedURLException {
final Map<String, String> params;
try {
params = URISupport.parseParameters(location);
} catch (final URISyntaxException e) {
throw new MalformedURLException(e.getMessage());
}
return params;
}
|
java
|
@SuppressWarnings("PMD.PreserveStackTrace")
private Map<String, String> findParameters(URI location) throws MalformedURLException {
final Map<String, String> params;
try {
params = URISupport.parseParameters(location);
} catch (final URISyntaxException e) {
throw new MalformedURLException(e.getMessage());
}
return params;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"PMD.PreserveStackTrace\"",
")",
"private",
"Map",
"<",
"String",
",",
"String",
">",
"findParameters",
"(",
"URI",
"location",
")",
"throws",
"MalformedURLException",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"params",
";",
"try",
"{",
"params",
"=",
"URISupport",
".",
"parseParameters",
"(",
"location",
")",
";",
"}",
"catch",
"(",
"final",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"MalformedURLException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"params",
";",
"}"
] |
Extract the query string from a connection URI into a Map
|
[
"Extract",
"the",
"query",
"string",
"from",
"a",
"connection",
"URI",
"into",
"a",
"Map"
] |
5091ffdb1de6b12d216d1c238f72858037c7b765
|
https://github.com/NessComputing/service-discovery/blob/5091ffdb1de6b12d216d1c238f72858037c7b765/jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java#L94-L103
|
145,119
|
NessComputing/service-discovery
|
jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java
|
ServiceDiscoveryTransportFactory.getDiscoveryId
|
private UUID getDiscoveryId(final Map<String, String> params) throws IOException {
final String discoveryId = params.get("discoveryId");
if (discoveryId == null) {
throw new IOException("srvc transport did not get a discoveryId parameter. Refusing to create.");
}
return UUID.fromString(discoveryId);
}
|
java
|
private UUID getDiscoveryId(final Map<String, String> params) throws IOException {
final String discoveryId = params.get("discoveryId");
if (discoveryId == null) {
throw new IOException("srvc transport did not get a discoveryId parameter. Refusing to create.");
}
return UUID.fromString(discoveryId);
}
|
[
"private",
"UUID",
"getDiscoveryId",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"IOException",
"{",
"final",
"String",
"discoveryId",
"=",
"params",
".",
"get",
"(",
"\"discoveryId\"",
")",
";",
"if",
"(",
"discoveryId",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"srvc transport did not get a discoveryId parameter. Refusing to create.\"",
")",
";",
"}",
"return",
"UUID",
".",
"fromString",
"(",
"discoveryId",
")",
";",
"}"
] |
Find and validate the discoveryId given in a connection string
|
[
"Find",
"and",
"validate",
"the",
"discoveryId",
"given",
"in",
"a",
"connection",
"string"
] |
5091ffdb1de6b12d216d1c238f72858037c7b765
|
https://github.com/NessComputing/service-discovery/blob/5091ffdb1de6b12d216d1c238f72858037c7b765/jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java#L108-L115
|
145,120
|
NessComputing/service-discovery
|
jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java
|
ServiceDiscoveryTransportFactory.getDiscoveryClient
|
private ReadOnlyDiscoveryClient getDiscoveryClient(Map<String, String> params) throws IOException {
final UUID discoveryId = getDiscoveryId(params);
final ReadOnlyDiscoveryClient discoveryClient = DISCO_CLIENTS.get(discoveryId);
if (discoveryClient == null) {
throw new IOException("No discovery client registered for id " + discoveryId);
}
return discoveryClient;
}
|
java
|
private ReadOnlyDiscoveryClient getDiscoveryClient(Map<String, String> params) throws IOException {
final UUID discoveryId = getDiscoveryId(params);
final ReadOnlyDiscoveryClient discoveryClient = DISCO_CLIENTS.get(discoveryId);
if (discoveryClient == null) {
throw new IOException("No discovery client registered for id " + discoveryId);
}
return discoveryClient;
}
|
[
"private",
"ReadOnlyDiscoveryClient",
"getDiscoveryClient",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"IOException",
"{",
"final",
"UUID",
"discoveryId",
"=",
"getDiscoveryId",
"(",
"params",
")",
";",
"final",
"ReadOnlyDiscoveryClient",
"discoveryClient",
"=",
"DISCO_CLIENTS",
".",
"get",
"(",
"discoveryId",
")",
";",
"if",
"(",
"discoveryClient",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"No discovery client registered for id \"",
"+",
"discoveryId",
")",
";",
"}",
"return",
"discoveryClient",
";",
"}"
] |
Locate the appropriate DiscoveryClient for a given discoveryId
|
[
"Locate",
"the",
"appropriate",
"DiscoveryClient",
"for",
"a",
"given",
"discoveryId"
] |
5091ffdb1de6b12d216d1c238f72858037c7b765
|
https://github.com/NessComputing/service-discovery/blob/5091ffdb1de6b12d216d1c238f72858037c7b765/jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java#L120-L129
|
145,121
|
NessComputing/service-discovery
|
jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java
|
ServiceDiscoveryTransportFactory.getServiceInformations
|
private List<ServiceInformation> getServiceInformations(URI location, final Map<String, String> params)
throws IOException {
final ReadOnlyDiscoveryClient discoveryClient = getDiscoveryClient(params);
final String serviceType = params.get("serviceType");
final List<ServiceInformation> services;
if (serviceType != null) {
services = discoveryClient.findAllServiceInformation(location.getHost(), serviceType);
} else {
services = discoveryClient.findAllServiceInformation(location.getHost());
}
return services;
}
|
java
|
private List<ServiceInformation> getServiceInformations(URI location, final Map<String, String> params)
throws IOException {
final ReadOnlyDiscoveryClient discoveryClient = getDiscoveryClient(params);
final String serviceType = params.get("serviceType");
final List<ServiceInformation> services;
if (serviceType != null) {
services = discoveryClient.findAllServiceInformation(location.getHost(), serviceType);
} else {
services = discoveryClient.findAllServiceInformation(location.getHost());
}
return services;
}
|
[
"private",
"List",
"<",
"ServiceInformation",
">",
"getServiceInformations",
"(",
"URI",
"location",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"IOException",
"{",
"final",
"ReadOnlyDiscoveryClient",
"discoveryClient",
"=",
"getDiscoveryClient",
"(",
"params",
")",
";",
"final",
"String",
"serviceType",
"=",
"params",
".",
"get",
"(",
"\"serviceType\"",
")",
";",
"final",
"List",
"<",
"ServiceInformation",
">",
"services",
";",
"if",
"(",
"serviceType",
"!=",
"null",
")",
"{",
"services",
"=",
"discoveryClient",
".",
"findAllServiceInformation",
"(",
"location",
".",
"getHost",
"(",
")",
",",
"serviceType",
")",
";",
"}",
"else",
"{",
"services",
"=",
"discoveryClient",
".",
"findAllServiceInformation",
"(",
"location",
".",
"getHost",
"(",
")",
")",
";",
"}",
"return",
"services",
";",
"}"
] |
Find and return applicable services for a given connection
|
[
"Find",
"and",
"return",
"applicable",
"services",
"for",
"a",
"given",
"connection"
] |
5091ffdb1de6b12d216d1c238f72858037c7b765
|
https://github.com/NessComputing/service-discovery/blob/5091ffdb1de6b12d216d1c238f72858037c7b765/jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java#L138-L152
|
145,122
|
NessComputing/service-discovery
|
jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java
|
ServiceDiscoveryTransportFactory.buildTransport
|
private Transport buildTransport(Map<String, String> params, final List<ServiceInformation> services) throws IOException {
final String configPostfix = getConfig(params).getServiceConfigurationPostfix();
final StringBuilder uriBuilder = new StringBuilder();
uriBuilder.append("failover:(");
uriBuilder.append(Joiner.on(',').join(Collections2.transform(services, SERVICE_TO_URI)));
uriBuilder.append(')');
if (!StringUtils.isBlank(configPostfix)) {
uriBuilder.append('?');
uriBuilder.append(configPostfix);
}
try {
final URI uri = URI.create(uriBuilder.toString());
LOG.debug("Service discovery transport discovered %s", uri);
return interceptPropertySetters(TransportFactory.compositeConnect(uri));
} catch (final Exception e) {
Throwables.propagateIfPossible(e, IOException.class);
throw new IOException("Could not create failover transport", e);
}
}
|
java
|
private Transport buildTransport(Map<String, String> params, final List<ServiceInformation> services) throws IOException {
final String configPostfix = getConfig(params).getServiceConfigurationPostfix();
final StringBuilder uriBuilder = new StringBuilder();
uriBuilder.append("failover:(");
uriBuilder.append(Joiner.on(',').join(Collections2.transform(services, SERVICE_TO_URI)));
uriBuilder.append(')');
if (!StringUtils.isBlank(configPostfix)) {
uriBuilder.append('?');
uriBuilder.append(configPostfix);
}
try {
final URI uri = URI.create(uriBuilder.toString());
LOG.debug("Service discovery transport discovered %s", uri);
return interceptPropertySetters(TransportFactory.compositeConnect(uri));
} catch (final Exception e) {
Throwables.propagateIfPossible(e, IOException.class);
throw new IOException("Could not create failover transport", e);
}
}
|
[
"private",
"Transport",
"buildTransport",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"params",
",",
"final",
"List",
"<",
"ServiceInformation",
">",
"services",
")",
"throws",
"IOException",
"{",
"final",
"String",
"configPostfix",
"=",
"getConfig",
"(",
"params",
")",
".",
"getServiceConfigurationPostfix",
"(",
")",
";",
"final",
"StringBuilder",
"uriBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"uriBuilder",
".",
"append",
"(",
"\"failover:(\"",
")",
";",
"uriBuilder",
".",
"append",
"(",
"Joiner",
".",
"on",
"(",
"'",
"'",
")",
".",
"join",
"(",
"Collections2",
".",
"transform",
"(",
"services",
",",
"SERVICE_TO_URI",
")",
")",
")",
";",
"uriBuilder",
".",
"append",
"(",
"'",
"'",
")",
";",
"if",
"(",
"!",
"StringUtils",
".",
"isBlank",
"(",
"configPostfix",
")",
")",
"{",
"uriBuilder",
".",
"append",
"(",
"'",
"'",
")",
";",
"uriBuilder",
".",
"append",
"(",
"configPostfix",
")",
";",
"}",
"try",
"{",
"final",
"URI",
"uri",
"=",
"URI",
".",
"create",
"(",
"uriBuilder",
".",
"toString",
"(",
")",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Service discovery transport discovered %s\"",
",",
"uri",
")",
";",
"return",
"interceptPropertySetters",
"(",
"TransportFactory",
".",
"compositeConnect",
"(",
"uri",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"Throwables",
".",
"propagateIfPossible",
"(",
"e",
",",
"IOException",
".",
"class",
")",
";",
"throw",
"new",
"IOException",
"(",
"\"Could not create failover transport\"",
",",
"e",
")",
";",
"}",
"}"
] |
From a list of ServiceInformation, build a failover transport that balances between the brokers.
|
[
"From",
"a",
"list",
"of",
"ServiceInformation",
"build",
"a",
"failover",
"transport",
"that",
"balances",
"between",
"the",
"brokers",
"."
] |
5091ffdb1de6b12d216d1c238f72858037c7b765
|
https://github.com/NessComputing/service-discovery/blob/5091ffdb1de6b12d216d1c238f72858037c7b765/jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java#L157-L175
|
145,123
|
NessComputing/service-discovery
|
jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java
|
ServiceDiscoveryTransportFactory.interceptPropertySetters
|
private Transport interceptPropertySetters(Transport transport) {
final Enhancer e = new Enhancer();
e.setInterfaces(new Class<?>[] {Transport.class, ServiceTransportBeanSetters.class});
final TransportDelegationFilter filter = new TransportDelegationFilter(transport, ServiceTransportBeanSetters.class);
e.setCallbackFilter(filter);
e.setCallbacks(filter.getCallbacks());
return (Transport) e.create();
}
|
java
|
private Transport interceptPropertySetters(Transport transport) {
final Enhancer e = new Enhancer();
e.setInterfaces(new Class<?>[] {Transport.class, ServiceTransportBeanSetters.class});
final TransportDelegationFilter filter = new TransportDelegationFilter(transport, ServiceTransportBeanSetters.class);
e.setCallbackFilter(filter);
e.setCallbacks(filter.getCallbacks());
return (Transport) e.create();
}
|
[
"private",
"Transport",
"interceptPropertySetters",
"(",
"Transport",
"transport",
")",
"{",
"final",
"Enhancer",
"e",
"=",
"new",
"Enhancer",
"(",
")",
";",
"e",
".",
"setInterfaces",
"(",
"new",
"Class",
"<",
"?",
">",
"[",
"]",
"{",
"Transport",
".",
"class",
",",
"ServiceTransportBeanSetters",
".",
"class",
"}",
")",
";",
"final",
"TransportDelegationFilter",
"filter",
"=",
"new",
"TransportDelegationFilter",
"(",
"transport",
",",
"ServiceTransportBeanSetters",
".",
"class",
")",
";",
"e",
".",
"setCallbackFilter",
"(",
"filter",
")",
";",
"e",
".",
"setCallbacks",
"(",
"filter",
".",
"getCallbacks",
"(",
")",
")",
";",
"return",
"(",
"Transport",
")",
"e",
".",
"create",
"(",
")",
";",
"}"
] |
ActiveMQ expects to reflectively call setX for every property x specified in the connection string.
Since we are actually constructing a failover transport, these properties are obviously not expected
and ActiveMQ complains that we are specifying invalid parameters. So create a CGLIB proxy that
intercepts and ignores appropriate setter calls.
|
[
"ActiveMQ",
"expects",
"to",
"reflectively",
"call",
"setX",
"for",
"every",
"property",
"x",
"specified",
"in",
"the",
"connection",
"string",
".",
"Since",
"we",
"are",
"actually",
"constructing",
"a",
"failover",
"transport",
"these",
"properties",
"are",
"obviously",
"not",
"expected",
"and",
"ActiveMQ",
"complains",
"that",
"we",
"are",
"specifying",
"invalid",
"parameters",
".",
"So",
"create",
"a",
"CGLIB",
"proxy",
"that",
"intercepts",
"and",
"ignores",
"appropriate",
"setter",
"calls",
"."
] |
5091ffdb1de6b12d216d1c238f72858037c7b765
|
https://github.com/NessComputing/service-discovery/blob/5091ffdb1de6b12d216d1c238f72858037c7b765/jms/src/main/java/com/nesscomputing/jms/activemq/ServiceDiscoveryTransportFactory.java#L183-L190
|
145,124
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.beginArray
|
public String beginArray() throws IOException {
String name = null;
if (currentValue.getKey() == NAME) {
name = currentValue.getValue().asString();
consume();
}
if (currentValue.getKey() == BEGIN_ARRAY) {
consume();
} else if (readStack.peek() != BEGIN_ARRAY) {
throw new IOException("Expecting BEGIN_ARRAY, but found " + jsonTokenToStructuredElement(null));
}
return name;
}
|
java
|
public String beginArray() throws IOException {
String name = null;
if (currentValue.getKey() == NAME) {
name = currentValue.getValue().asString();
consume();
}
if (currentValue.getKey() == BEGIN_ARRAY) {
consume();
} else if (readStack.peek() != BEGIN_ARRAY) {
throw new IOException("Expecting BEGIN_ARRAY, but found " + jsonTokenToStructuredElement(null));
}
return name;
}
|
[
"public",
"String",
"beginArray",
"(",
")",
"throws",
"IOException",
"{",
"String",
"name",
"=",
"null",
";",
"if",
"(",
"currentValue",
".",
"getKey",
"(",
")",
"==",
"NAME",
")",
"{",
"name",
"=",
"currentValue",
".",
"getValue",
"(",
")",
".",
"asString",
"(",
")",
";",
"consume",
"(",
")",
";",
"}",
"if",
"(",
"currentValue",
".",
"getKey",
"(",
")",
"==",
"BEGIN_ARRAY",
")",
"{",
"consume",
"(",
")",
";",
"}",
"else",
"if",
"(",
"readStack",
".",
"peek",
"(",
")",
"!=",
"BEGIN_ARRAY",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Expecting BEGIN_ARRAY, but found \"",
"+",
"jsonTokenToStructuredElement",
"(",
"null",
")",
")",
";",
"}",
"return",
"name",
";",
"}"
] |
Begins an Array
@return This array's name
@throws IOException Something went wrong reading
|
[
"Begins",
"an",
"Array"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L89-L101
|
145,125
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.beginArray
|
public JsonReader beginArray(String expectedName) throws IOException {
String name = beginArray();
if (!StringUtils.isNullOrBlank(expectedName) && (name == null || !name.equals(expectedName))) {
throw new IOException("Expected " + expectedName);
}
return this;
}
|
java
|
public JsonReader beginArray(String expectedName) throws IOException {
String name = beginArray();
if (!StringUtils.isNullOrBlank(expectedName) && (name == null || !name.equals(expectedName))) {
throw new IOException("Expected " + expectedName);
}
return this;
}
|
[
"public",
"JsonReader",
"beginArray",
"(",
"String",
"expectedName",
")",
"throws",
"IOException",
"{",
"String",
"name",
"=",
"beginArray",
"(",
")",
";",
"if",
"(",
"!",
"StringUtils",
".",
"isNullOrBlank",
"(",
"expectedName",
")",
"&&",
"(",
"name",
"==",
"null",
"||",
"!",
"name",
".",
"equals",
"(",
"expectedName",
")",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Expected \"",
"+",
"expectedName",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Begins an array with an expected name.
@param expectedName The name that the next array should have
@return the structured reader
@throws IOException Something happened reading or the expected name was not found
|
[
"Begins",
"an",
"array",
"with",
"an",
"expected",
"name",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L110-L116
|
145,126
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.beginObject
|
public JsonReader beginObject(String expectedName) throws IOException {
String name = beginObject();
if (!StringUtils.isNullOrBlank(expectedName) && !name.equals(expectedName)) {
throw new IOException("Expected " + expectedName);
}
return this;
}
|
java
|
public JsonReader beginObject(String expectedName) throws IOException {
String name = beginObject();
if (!StringUtils.isNullOrBlank(expectedName) && !name.equals(expectedName)) {
throw new IOException("Expected " + expectedName);
}
return this;
}
|
[
"public",
"JsonReader",
"beginObject",
"(",
"String",
"expectedName",
")",
"throws",
"IOException",
"{",
"String",
"name",
"=",
"beginObject",
"(",
")",
";",
"if",
"(",
"!",
"StringUtils",
".",
"isNullOrBlank",
"(",
"expectedName",
")",
"&&",
"!",
"name",
".",
"equals",
"(",
"expectedName",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Expected \"",
"+",
"expectedName",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Begins an object with an expected name.
@param expectedName The name that the next object should have
@return the structured reader
@throws IOException Something happened reading or the expected name was not found
|
[
"Begins",
"an",
"object",
"with",
"an",
"expected",
"name",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L161-L167
|
145,127
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.endArray
|
public JsonReader endArray() throws IOException {
if (currentValue.getKey() != END_ARRAY) {
throw new IOException("Expecting END_ARRAY, but found " + jsonTokenToStructuredElement(null));
}
consume();
return this;
}
|
java
|
public JsonReader endArray() throws IOException {
if (currentValue.getKey() != END_ARRAY) {
throw new IOException("Expecting END_ARRAY, but found " + jsonTokenToStructuredElement(null));
}
consume();
return this;
}
|
[
"public",
"JsonReader",
"endArray",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"currentValue",
".",
"getKey",
"(",
")",
"!=",
"END_ARRAY",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Expecting END_ARRAY, but found \"",
"+",
"jsonTokenToStructuredElement",
"(",
"null",
")",
")",
";",
"}",
"consume",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Ends an Array
@return the structured reader
@throws IOException Something went wrong reading
|
[
"Ends",
"an",
"Array"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L246-L252
|
145,128
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.endObject
|
public JsonReader endObject() throws IOException {
if (currentValue.getKey() != END_OBJECT) {
throw new IOException("Expecting END_OBJECT, but found " + jsonTokenToStructuredElement(null));
}
consume();
return this;
}
|
java
|
public JsonReader endObject() throws IOException {
if (currentValue.getKey() != END_OBJECT) {
throw new IOException("Expecting END_OBJECT, but found " + jsonTokenToStructuredElement(null));
}
consume();
return this;
}
|
[
"public",
"JsonReader",
"endObject",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"currentValue",
".",
"getKey",
"(",
")",
"!=",
"END_OBJECT",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Expecting END_OBJECT, but found \"",
"+",
"jsonTokenToStructuredElement",
"(",
"null",
")",
")",
";",
"}",
"consume",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Ends the document
@return the structured reader
@throws IOException Something went wrong reading
|
[
"Ends",
"the",
"document"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L272-L278
|
145,129
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.nextKeyValue
|
public Tuple2<String, Val> nextKeyValue() throws IOException {
if (currentValue.getKey() != NAME) {
throw new IOException("Expecting NAME, but found " + jsonTokenToStructuredElement(null));
}
String name = currentValue.getValue().asString();
consume();
return Tuple2.of(name, nextValue());
}
|
java
|
public Tuple2<String, Val> nextKeyValue() throws IOException {
if (currentValue.getKey() != NAME) {
throw new IOException("Expecting NAME, but found " + jsonTokenToStructuredElement(null));
}
String name = currentValue.getValue().asString();
consume();
return Tuple2.of(name, nextValue());
}
|
[
"public",
"Tuple2",
"<",
"String",
",",
"Val",
">",
"nextKeyValue",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"currentValue",
".",
"getKey",
"(",
")",
"!=",
"NAME",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Expecting NAME, but found \"",
"+",
"jsonTokenToStructuredElement",
"(",
"null",
")",
")",
";",
"}",
"String",
"name",
"=",
"currentValue",
".",
"getValue",
"(",
")",
".",
"asString",
"(",
")",
";",
"consume",
"(",
")",
";",
"return",
"Tuple2",
".",
"of",
"(",
"name",
",",
"nextValue",
"(",
")",
")",
";",
"}"
] |
Reads the next key-value pair
@return The next key value pair
@throws IOException Something went wrong reading
|
[
"Reads",
"the",
"next",
"key",
"-",
"value",
"pair"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L458-L465
|
145,130
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.nextKeyValue
|
public Val nextKeyValue(String expectedKey) throws IOException {
Tuple2<String, Val> Tuple2 = nextKeyValue();
if (expectedKey != null && (Tuple2 == null || !Tuple2.getKey().equals(expectedKey))) {
throw new IOException("Expected a Key-Value Tuple2 with named " + expectedKey);
}
return Tuple2.getV2();
}
|
java
|
public Val nextKeyValue(String expectedKey) throws IOException {
Tuple2<String, Val> Tuple2 = nextKeyValue();
if (expectedKey != null && (Tuple2 == null || !Tuple2.getKey().equals(expectedKey))) {
throw new IOException("Expected a Key-Value Tuple2 with named " + expectedKey);
}
return Tuple2.getV2();
}
|
[
"public",
"Val",
"nextKeyValue",
"(",
"String",
"expectedKey",
")",
"throws",
"IOException",
"{",
"Tuple2",
"<",
"String",
",",
"Val",
">",
"Tuple2",
"=",
"nextKeyValue",
"(",
")",
";",
"if",
"(",
"expectedKey",
"!=",
"null",
"&&",
"(",
"Tuple2",
"==",
"null",
"||",
"!",
"Tuple2",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"expectedKey",
")",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Expected a Key-Value Tuple2 with named \"",
"+",
"expectedKey",
")",
";",
"}",
"return",
"Tuple2",
".",
"getV2",
"(",
")",
";",
"}"
] |
Reads in a key value with an expected key.
@param expectedKey The expected key
@return The next key value Tuple2
@throws IOException Something went wrong reading
|
[
"Reads",
"in",
"a",
"key",
"value",
"with",
"an",
"expected",
"key",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L474-L480
|
145,131
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.nextKeyValue
|
public <T> Tuple2<String, T> nextKeyValue(Class<T> clazz) throws IOException {
if (currentValue.getKey() != NAME) {
throw new IOException("Expecting NAME, but found " + jsonTokenToStructuredElement(null));
}
String name = currentValue.getValue().asString();
consume();
return Tuple2.of(name, nextValue(clazz));
}
|
java
|
public <T> Tuple2<String, T> nextKeyValue(Class<T> clazz) throws IOException {
if (currentValue.getKey() != NAME) {
throw new IOException("Expecting NAME, but found " + jsonTokenToStructuredElement(null));
}
String name = currentValue.getValue().asString();
consume();
return Tuple2.of(name, nextValue(clazz));
}
|
[
"public",
"<",
"T",
">",
"Tuple2",
"<",
"String",
",",
"T",
">",
"nextKeyValue",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"IOException",
"{",
"if",
"(",
"currentValue",
".",
"getKey",
"(",
")",
"!=",
"NAME",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Expecting NAME, but found \"",
"+",
"jsonTokenToStructuredElement",
"(",
"null",
")",
")",
";",
"}",
"String",
"name",
"=",
"currentValue",
".",
"getValue",
"(",
")",
".",
"asString",
"(",
")",
";",
"consume",
"(",
")",
";",
"return",
"Tuple2",
".",
"of",
"(",
"name",
",",
"nextValue",
"(",
"clazz",
")",
")",
";",
"}"
] |
Reads the next key-value pair with the value being of the given type
@param <T> the value type parameter
@param clazz the clazz associated with the value type
@return the next key-value pair
@throws IOException Something went wrong reading
|
[
"Reads",
"the",
"next",
"key",
"-",
"value",
"pair",
"with",
"the",
"value",
"being",
"of",
"the",
"given",
"type"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L490-L497
|
145,132
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.nextMap
|
public Map<String, Val> nextMap(String expectedName) throws IOException {
boolean ignoreObject = peek() != JsonTokenType.BEGIN_OBJECT && StringUtils.isNullOrBlank(expectedName);
if (!ignoreObject) beginObject(expectedName);
Map<String, Val> map = new HashMap<>();
while (peek() != JsonTokenType.END_OBJECT && peek() != JsonTokenType.END_DOCUMENT) {
Tuple2<String, Val> kv = nextKeyValue();
map.put(kv.getKey(), kv.getValue());
}
if (!ignoreObject) endObject();
return map;
}
|
java
|
public Map<String, Val> nextMap(String expectedName) throws IOException {
boolean ignoreObject = peek() != JsonTokenType.BEGIN_OBJECT && StringUtils.isNullOrBlank(expectedName);
if (!ignoreObject) beginObject(expectedName);
Map<String, Val> map = new HashMap<>();
while (peek() != JsonTokenType.END_OBJECT && peek() != JsonTokenType.END_DOCUMENT) {
Tuple2<String, Val> kv = nextKeyValue();
map.put(kv.getKey(), kv.getValue());
}
if (!ignoreObject) endObject();
return map;
}
|
[
"public",
"Map",
"<",
"String",
",",
"Val",
">",
"nextMap",
"(",
"String",
"expectedName",
")",
"throws",
"IOException",
"{",
"boolean",
"ignoreObject",
"=",
"peek",
"(",
")",
"!=",
"JsonTokenType",
".",
"BEGIN_OBJECT",
"&&",
"StringUtils",
".",
"isNullOrBlank",
"(",
"expectedName",
")",
";",
"if",
"(",
"!",
"ignoreObject",
")",
"beginObject",
"(",
"expectedName",
")",
";",
"Map",
"<",
"String",
",",
"Val",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"while",
"(",
"peek",
"(",
")",
"!=",
"JsonTokenType",
".",
"END_OBJECT",
"&&",
"peek",
"(",
")",
"!=",
"JsonTokenType",
".",
"END_DOCUMENT",
")",
"{",
"Tuple2",
"<",
"String",
",",
"Val",
">",
"kv",
"=",
"nextKeyValue",
"(",
")",
";",
"map",
".",
"put",
"(",
"kv",
".",
"getKey",
"(",
")",
",",
"kv",
".",
"getValue",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"ignoreObject",
")",
"endObject",
"(",
")",
";",
"return",
"map",
";",
"}"
] |
Reads in the next object as a map with an expected name
@param expectedName the expected name of the next object
@return the map
@throws IOException Something went wrong reading
|
[
"Reads",
"in",
"the",
"next",
"object",
"as",
"a",
"map",
"with",
"an",
"expected",
"name"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L516-L526
|
145,133
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.nextSimpleValue
|
protected Val nextSimpleValue() throws IOException {
switch (currentValue.getKey()) {
case NULL:
case STRING:
case BOOLEAN:
case NUMBER:
Val object = currentValue.v2;
consume();
return object;
default:
throw new IOException("Expecting VALUE, but found " + jsonTokenToStructuredElement(null));
}
}
|
java
|
protected Val nextSimpleValue() throws IOException {
switch (currentValue.getKey()) {
case NULL:
case STRING:
case BOOLEAN:
case NUMBER:
Val object = currentValue.v2;
consume();
return object;
default:
throw new IOException("Expecting VALUE, but found " + jsonTokenToStructuredElement(null));
}
}
|
[
"protected",
"Val",
"nextSimpleValue",
"(",
")",
"throws",
"IOException",
"{",
"switch",
"(",
"currentValue",
".",
"getKey",
"(",
")",
")",
"{",
"case",
"NULL",
":",
"case",
"STRING",
":",
"case",
"BOOLEAN",
":",
"case",
"NUMBER",
":",
"Val",
"object",
"=",
"currentValue",
".",
"v2",
";",
"consume",
"(",
")",
";",
"return",
"object",
";",
"default",
":",
"throw",
"new",
"IOException",
"(",
"\"Expecting VALUE, but found \"",
"+",
"jsonTokenToStructuredElement",
"(",
"null",
")",
")",
";",
"}",
"}"
] |
Next simple value val.
@return the val
@throws IOException the io exception
|
[
"Next",
"simple",
"value",
"val",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L567-L579
|
145,134
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.nextValue
|
public Val nextValue() throws IOException {
switch (peek()) {
case BEGIN_ARRAY:
return Val.of(nextCollection(ArrayList::new));
case BEGIN_OBJECT:
return Val.of(nextMap());
case NAME:
return nextKeyValue().getV2();
default:
return nextSimpleValue();
}
}
|
java
|
public Val nextValue() throws IOException {
switch (peek()) {
case BEGIN_ARRAY:
return Val.of(nextCollection(ArrayList::new));
case BEGIN_OBJECT:
return Val.of(nextMap());
case NAME:
return nextKeyValue().getV2();
default:
return nextSimpleValue();
}
}
|
[
"public",
"Val",
"nextValue",
"(",
")",
"throws",
"IOException",
"{",
"switch",
"(",
"peek",
"(",
")",
")",
"{",
"case",
"BEGIN_ARRAY",
":",
"return",
"Val",
".",
"of",
"(",
"nextCollection",
"(",
"ArrayList",
"::",
"new",
")",
")",
";",
"case",
"BEGIN_OBJECT",
":",
"return",
"Val",
".",
"of",
"(",
"nextMap",
"(",
")",
")",
";",
"case",
"NAME",
":",
"return",
"nextKeyValue",
"(",
")",
".",
"getV2",
"(",
")",
";",
"default",
":",
"return",
"nextSimpleValue",
"(",
")",
";",
"}",
"}"
] |
Reads the next value
@return The next value
@throws IOException Something went wrong reading
|
[
"Reads",
"the",
"next",
"value"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L587-L598
|
145,135
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.readReadable
|
protected <T> T readReadable(Class<T> clazz) throws IOException {
try {
T object = Reflect.onClass(clazz).allowPrivilegedAccess().create().get();
JsonSerializable readable = Cast.as(object);
boolean isArray = JsonArraySerializable.class.isAssignableFrom(clazz);//(object instanceof ArrayValue);
if (isArray && peek() == JsonTokenType.BEGIN_ARRAY) {
beginArray();
} else if (peek() == JsonTokenType.BEGIN_OBJECT) {
beginObject();
}
readable.fromJson(this);
if (isArray && peek() == JsonTokenType.END_ARRAY) {
endArray();
} else if (peek() == JsonTokenType.END_OBJECT) {
endObject();
}
return object;
} catch (ReflectionException e) {
throw new IOException(e);
}
}
|
java
|
protected <T> T readReadable(Class<T> clazz) throws IOException {
try {
T object = Reflect.onClass(clazz).allowPrivilegedAccess().create().get();
JsonSerializable readable = Cast.as(object);
boolean isArray = JsonArraySerializable.class.isAssignableFrom(clazz);//(object instanceof ArrayValue);
if (isArray && peek() == JsonTokenType.BEGIN_ARRAY) {
beginArray();
} else if (peek() == JsonTokenType.BEGIN_OBJECT) {
beginObject();
}
readable.fromJson(this);
if (isArray && peek() == JsonTokenType.END_ARRAY) {
endArray();
} else if (peek() == JsonTokenType.END_OBJECT) {
endObject();
}
return object;
} catch (ReflectionException e) {
throw new IOException(e);
}
}
|
[
"protected",
"<",
"T",
">",
"T",
"readReadable",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"IOException",
"{",
"try",
"{",
"T",
"object",
"=",
"Reflect",
".",
"onClass",
"(",
"clazz",
")",
".",
"allowPrivilegedAccess",
"(",
")",
".",
"create",
"(",
")",
".",
"get",
"(",
")",
";",
"JsonSerializable",
"readable",
"=",
"Cast",
".",
"as",
"(",
"object",
")",
";",
"boolean",
"isArray",
"=",
"JsonArraySerializable",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
";",
"//(object instanceof ArrayValue);",
"if",
"(",
"isArray",
"&&",
"peek",
"(",
")",
"==",
"JsonTokenType",
".",
"BEGIN_ARRAY",
")",
"{",
"beginArray",
"(",
")",
";",
"}",
"else",
"if",
"(",
"peek",
"(",
")",
"==",
"JsonTokenType",
".",
"BEGIN_OBJECT",
")",
"{",
"beginObject",
"(",
")",
";",
"}",
"readable",
".",
"fromJson",
"(",
"this",
")",
";",
"if",
"(",
"isArray",
"&&",
"peek",
"(",
")",
"==",
"JsonTokenType",
".",
"END_ARRAY",
")",
"{",
"endArray",
"(",
")",
";",
"}",
"else",
"if",
"(",
"peek",
"(",
")",
"==",
"JsonTokenType",
".",
"END_OBJECT",
")",
"{",
"endObject",
"(",
")",
";",
"}",
"return",
"object",
";",
"}",
"catch",
"(",
"ReflectionException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"}"
] |
Reads a class implementing readable
@param <T> the type parameter
@param clazz the clazz
@return the t
@throws IOException the io exception
|
[
"Reads",
"a",
"class",
"implementing",
"readable"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L675-L695
|
145,136
|
dbracewell/mango
|
src/main/java/com/davidbracewell/json/JsonReader.java
|
JsonReader.skip
|
public JsonTokenType skip() throws IOException {
try {
JsonTokenType element = jsonTokenToStructuredElement(reader.peek());
JsonToken token = currentValue.getKey();
if (token == NAME &&
(element == JsonTokenType.BEGIN_OBJECT || element == JsonTokenType.BEGIN_ARRAY)) {
reader.skipValue();
}
consume();
return element;
} catch (IOException e) {
throw new IOException(e);
}
}
|
java
|
public JsonTokenType skip() throws IOException {
try {
JsonTokenType element = jsonTokenToStructuredElement(reader.peek());
JsonToken token = currentValue.getKey();
if (token == NAME &&
(element == JsonTokenType.BEGIN_OBJECT || element == JsonTokenType.BEGIN_ARRAY)) {
reader.skipValue();
}
consume();
return element;
} catch (IOException e) {
throw new IOException(e);
}
}
|
[
"public",
"JsonTokenType",
"skip",
"(",
")",
"throws",
"IOException",
"{",
"try",
"{",
"JsonTokenType",
"element",
"=",
"jsonTokenToStructuredElement",
"(",
"reader",
".",
"peek",
"(",
")",
")",
";",
"JsonToken",
"token",
"=",
"currentValue",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"token",
"==",
"NAME",
"&&",
"(",
"element",
"==",
"JsonTokenType",
".",
"BEGIN_OBJECT",
"||",
"element",
"==",
"JsonTokenType",
".",
"BEGIN_ARRAY",
")",
")",
"{",
"reader",
".",
"skipValue",
"(",
")",
";",
"}",
"consume",
"(",
")",
";",
"return",
"element",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"}"
] |
Skips the next element in the stream
@return The type of the element that was skipped
@throws IOException Something went wrong reading
|
[
"Skips",
"the",
"next",
"element",
"in",
"the",
"stream"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/json/JsonReader.java#L703-L716
|
145,137
|
devcon5io/common
|
classutils/src/main/java/io/devcon5/classutils/JarScanner.java
|
JarScanner.addJar
|
public JarScanner addJar(Collection<URL> jars) {
this.jars.addAll(jars.stream().map(JarScanner::toUri).collect(Collectors.toList()));
return this;
}
|
java
|
public JarScanner addJar(Collection<URL> jars) {
this.jars.addAll(jars.stream().map(JarScanner::toUri).collect(Collectors.toList()));
return this;
}
|
[
"public",
"JarScanner",
"addJar",
"(",
"Collection",
"<",
"URL",
">",
"jars",
")",
"{",
"this",
".",
"jars",
".",
"addAll",
"(",
"jars",
".",
"stream",
"(",
")",
".",
"map",
"(",
"JarScanner",
"::",
"toUri",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a jar file to be scanned
@param jars
jars to be added to the scanner
@return this scanner
|
[
"Adds",
"a",
"jar",
"file",
"to",
"be",
"scanned"
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/classutils/src/main/java/io/devcon5/classutils/JarScanner.java#L111-L114
|
145,138
|
devcon5io/common
|
classutils/src/main/java/io/devcon5/classutils/JarScanner.java
|
JarScanner.toUri
|
private static URI toUri(final URL u) {
try {
return u.toURI();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Could not convert URL "+u+" to uri",e);
}
}
|
java
|
private static URI toUri(final URL u) {
try {
return u.toURI();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Could not convert URL "+u+" to uri",e);
}
}
|
[
"private",
"static",
"URI",
"toUri",
"(",
"final",
"URL",
"u",
")",
"{",
"try",
"{",
"return",
"u",
".",
"toURI",
"(",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Could not convert URL \"",
"+",
"u",
"+",
"\" to uri\"",
",",
"e",
")",
";",
"}",
"}"
] |
Converts a url to uri without throwing a checked exception. In case an URI syntax exception occurs, an
IllegalArgumentException is thrown.
@param u
the url to be converted
@return
the converted uri
|
[
"Converts",
"a",
"url",
"to",
"uri",
"without",
"throwing",
"a",
"checked",
"exception",
".",
"In",
"case",
"an",
"URI",
"syntax",
"exception",
"occurs",
"an",
"IllegalArgumentException",
"is",
"thrown",
"."
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/classutils/src/main/java/io/devcon5/classutils/JarScanner.java#L124-L131
|
145,139
|
devcon5io/common
|
classutils/src/main/java/io/devcon5/classutils/JarScanner.java
|
JarScanner.scanJar
|
private Collection<String> scanJar(Predicate<Path> pathFilter) {
return jars.parallelStream()
.map(JarScanner::createJarUri)
.flatMap(u -> scanJar(u, pathFilter).stream())
.distinct()
.collect(Collectors.toList());
}
|
java
|
private Collection<String> scanJar(Predicate<Path> pathFilter) {
return jars.parallelStream()
.map(JarScanner::createJarUri)
.flatMap(u -> scanJar(u, pathFilter).stream())
.distinct()
.collect(Collectors.toList());
}
|
[
"private",
"Collection",
"<",
"String",
">",
"scanJar",
"(",
"Predicate",
"<",
"Path",
">",
"pathFilter",
")",
"{",
"return",
"jars",
".",
"parallelStream",
"(",
")",
".",
"map",
"(",
"JarScanner",
"::",
"createJarUri",
")",
".",
"flatMap",
"(",
"u",
"->",
"scanJar",
"(",
"u",
",",
"pathFilter",
")",
".",
"stream",
"(",
")",
")",
".",
"distinct",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
Scans the jars of the JarScanner finding all items matching the path filter
@param pathFilter
the filter to find items in the jars
@return
Collections of items of the jars matching the filter
|
[
"Scans",
"the",
"jars",
"of",
"the",
"JarScanner",
"finding",
"all",
"items",
"matching",
"the",
"path",
"filter"
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/classutils/src/main/java/io/devcon5/classutils/JarScanner.java#L160-L166
|
145,140
|
devcon5io/common
|
classutils/src/main/java/io/devcon5/classutils/JarScanner.java
|
JarScanner.scanJar
|
private Collection<String> scanJar(URI u, Predicate<Path> pathPredicate) {
try (FileSystem fs = FileSystems.newFileSystem(u, READY_ONLY_ENV)) {
return Files.walk(fs.getPath("/"))
.filter(pathPredicate)
.map(f -> toFQName(f.toAbsolutePath()))
.distinct()
.collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
private Collection<String> scanJar(URI u, Predicate<Path> pathPredicate) {
try (FileSystem fs = FileSystems.newFileSystem(u, READY_ONLY_ENV)) {
return Files.walk(fs.getPath("/"))
.filter(pathPredicate)
.map(f -> toFQName(f.toAbsolutePath()))
.distinct()
.collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"private",
"Collection",
"<",
"String",
">",
"scanJar",
"(",
"URI",
"u",
",",
"Predicate",
"<",
"Path",
">",
"pathPredicate",
")",
"{",
"try",
"(",
"FileSystem",
"fs",
"=",
"FileSystems",
".",
"newFileSystem",
"(",
"u",
",",
"READY_ONLY_ENV",
")",
")",
"{",
"return",
"Files",
".",
"walk",
"(",
"fs",
".",
"getPath",
"(",
"\"/\"",
")",
")",
".",
"filter",
"(",
"pathPredicate",
")",
".",
"map",
"(",
"f",
"->",
"toFQName",
"(",
"f",
".",
"toAbsolutePath",
"(",
")",
")",
")",
".",
"distinct",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Scans the jar and filters all elements
@param u
the uri of the jar file to be scanned
@param pathPredicate
the matching predicate for collecting the entries
@return a stream of collected strings
|
[
"Scans",
"the",
"jar",
"and",
"filters",
"all",
"elements"
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/classutils/src/main/java/io/devcon5/classutils/JarScanner.java#L178-L188
|
145,141
|
devcon5io/common
|
classutils/src/main/java/io/devcon5/classutils/JarScanner.java
|
JarScanner.isIgnored
|
private boolean isIgnored(Path p) {
final String path = toFQName(p);
return this.ignoredFolders.stream().anyMatch(path::startsWith);
}
|
java
|
private boolean isIgnored(Path p) {
final String path = toFQName(p);
return this.ignoredFolders.stream().anyMatch(path::startsWith);
}
|
[
"private",
"boolean",
"isIgnored",
"(",
"Path",
"p",
")",
"{",
"final",
"String",
"path",
"=",
"toFQName",
"(",
"p",
")",
";",
"return",
"this",
".",
"ignoredFolders",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"path",
"::",
"startsWith",
")",
";",
"}"
] |
Checks if the specified path is on the ignore list
@param p
the path to check
@return true if the path should be ignored
|
[
"Checks",
"if",
"the",
"specified",
"path",
"is",
"on",
"the",
"ignore",
"list"
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/classutils/src/main/java/io/devcon5/classutils/JarScanner.java#L212-L215
|
145,142
|
dbracewell/mango
|
src/main/java/com/davidbracewell/io/resource/BaseResource.java
|
BaseResource.createOutputStream
|
protected OutputStream createOutputStream() throws IOException {
if (asFile().isPresent()) {
return new FileOutputStream(asFile().orElse(null));
}
return null;
}
|
java
|
protected OutputStream createOutputStream() throws IOException {
if (asFile().isPresent()) {
return new FileOutputStream(asFile().orElse(null));
}
return null;
}
|
[
"protected",
"OutputStream",
"createOutputStream",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"asFile",
"(",
")",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
"new",
"FileOutputStream",
"(",
"asFile",
"(",
")",
".",
"orElse",
"(",
"null",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Create output stream output stream.
@return the output stream
@throws IOException the io exception
|
[
"Create",
"output",
"stream",
"output",
"stream",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/io/resource/BaseResource.java#L109-L115
|
145,143
|
dbracewell/mango
|
src/main/java/com/davidbracewell/io/resource/BaseResource.java
|
BaseResource.createInputStream
|
protected InputStream createInputStream() throws IOException {
if (asFile().isPresent()) {
return new FileInputStream(asFile().orElse(null));
}
return null;
}
|
java
|
protected InputStream createInputStream() throws IOException {
if (asFile().isPresent()) {
return new FileInputStream(asFile().orElse(null));
}
return null;
}
|
[
"protected",
"InputStream",
"createInputStream",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"asFile",
"(",
")",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
"new",
"FileInputStream",
"(",
"asFile",
"(",
")",
".",
"orElse",
"(",
"null",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Create input stream input stream.
@return the input stream
@throws IOException the io exception
|
[
"Create",
"input",
"stream",
"input",
"stream",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/io/resource/BaseResource.java#L123-L128
|
145,144
|
fuinorg/srcgen4javassist
|
src/main/java/org/fuin/srcgen4javassist/SgUtils.java
|
SgUtils.uppercaseToUnderscore
|
public static String uppercaseToUnderscore(final String str) {
if (str == null) {
return null;
}
final StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
final char ch = str.charAt(i);
if (Character.isUpperCase(ch)) {
if (i > 0) {
sb.append("_");
}
sb.append(Character.toLowerCase(ch));
} else {
sb.append(ch);
}
}
return sb.toString();
}
|
java
|
public static String uppercaseToUnderscore(final String str) {
if (str == null) {
return null;
}
final StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
final char ch = str.charAt(i);
if (Character.isUpperCase(ch)) {
if (i > 0) {
sb.append("_");
}
sb.append(Character.toLowerCase(ch));
} else {
sb.append(ch);
}
}
return sb.toString();
}
|
[
"public",
"static",
"String",
"uppercaseToUnderscore",
"(",
"final",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"char",
"ch",
"=",
"str",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"Character",
".",
"isUpperCase",
"(",
"ch",
")",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\"_\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"Character",
".",
"toLowerCase",
"(",
"ch",
")",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"ch",
")",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Inserts an underscore before every upper case character and returns an
all lower case string. If the first character is upper case an underscore
will not be inserted.
@param str
String to convert.
@return Lower case + underscored text.
|
[
"Inserts",
"an",
"underscore",
"before",
"every",
"upper",
"case",
"character",
"and",
"returns",
"an",
"all",
"lower",
"case",
"string",
".",
"If",
"the",
"first",
"character",
"is",
"upper",
"case",
"an",
"underscore",
"will",
"not",
"be",
"inserted",
"."
] |
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
|
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgUtils.java#L277-L294
|
145,145
|
fuinorg/srcgen4javassist
|
src/main/java/org/fuin/srcgen4javassist/SgUtils.java
|
SgUtils.concatPackages
|
public static String concatPackages(final String package1, final String package2) {
if ((package1 == null) || (package1.length() == 0)) {
if ((package2 == null) || (package2.length() == 0)) {
return "";
} else {
return package2;
}
} else {
if ((package2 == null) || (package2.length() == 0)) {
return package1;
} else {
return package1 + "." + package2;
}
}
}
|
java
|
public static String concatPackages(final String package1, final String package2) {
if ((package1 == null) || (package1.length() == 0)) {
if ((package2 == null) || (package2.length() == 0)) {
return "";
} else {
return package2;
}
} else {
if ((package2 == null) || (package2.length() == 0)) {
return package1;
} else {
return package1 + "." + package2;
}
}
}
|
[
"public",
"static",
"String",
"concatPackages",
"(",
"final",
"String",
"package1",
",",
"final",
"String",
"package2",
")",
"{",
"if",
"(",
"(",
"package1",
"==",
"null",
")",
"||",
"(",
"package1",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"if",
"(",
"(",
"package2",
"==",
"null",
")",
"||",
"(",
"package2",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"else",
"{",
"return",
"package2",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"(",
"package2",
"==",
"null",
")",
"||",
"(",
"package2",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
"package1",
";",
"}",
"else",
"{",
"return",
"package1",
"+",
"\".\"",
"+",
"package2",
";",
"}",
"}",
"}"
] |
Merge two packages into one. If any package is null or empty no "." will
be added. If both packages are null an empty string will be returned.
@param package1
First package - Can also be null or empty.
@param package2
Second package - Can also be null or empty.
@return Both packages added with ".".
|
[
"Merge",
"two",
"packages",
"into",
"one",
".",
"If",
"any",
"package",
"is",
"null",
"or",
"empty",
"no",
".",
"will",
"be",
"added",
".",
"If",
"both",
"packages",
"are",
"null",
"an",
"empty",
"string",
"will",
"be",
"returned",
"."
] |
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
|
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgUtils.java#L329-L343
|
145,146
|
fuinorg/srcgen4javassist
|
src/main/java/org/fuin/srcgen4javassist/SgUtils.java
|
SgUtils.modifierMatrixToHtml
|
public static String modifierMatrixToHtml() {
final StringBuffer sb = new StringBuffer();
sb.append("<table border=\"1\">\n");
// Header
sb.append("<tr>");
sb.append("<th> </th>");
for (int type = FIELD; type <= INNER_INTERFACE; type++) {
sb.append("<th>");
sb.append(TYPE_NAMES[type]);
sb.append("</th>");
}
sb.append("</tr>\n");
// Content
for (int modifier = ABSTRACT; modifier <= STRICTFP; modifier++) {
sb.append("<tr>");
sb.append("<td>");
sb.append(MODIFIER_NAMES[modifier]);
sb.append("</td>");
for (int type = FIELD; type <= INNER_INTERFACE; type++) {
sb.append("<td>");
sb.append(MODIFIERS_MATRIX[modifier][type]);
sb.append("</td>");
}
sb.append("</tr>\n");
}
sb.append("</table>\n");
return sb.toString();
}
|
java
|
public static String modifierMatrixToHtml() {
final StringBuffer sb = new StringBuffer();
sb.append("<table border=\"1\">\n");
// Header
sb.append("<tr>");
sb.append("<th> </th>");
for (int type = FIELD; type <= INNER_INTERFACE; type++) {
sb.append("<th>");
sb.append(TYPE_NAMES[type]);
sb.append("</th>");
}
sb.append("</tr>\n");
// Content
for (int modifier = ABSTRACT; modifier <= STRICTFP; modifier++) {
sb.append("<tr>");
sb.append("<td>");
sb.append(MODIFIER_NAMES[modifier]);
sb.append("</td>");
for (int type = FIELD; type <= INNER_INTERFACE; type++) {
sb.append("<td>");
sb.append(MODIFIERS_MATRIX[modifier][type]);
sb.append("</td>");
}
sb.append("</tr>\n");
}
sb.append("</table>\n");
return sb.toString();
}
|
[
"public",
"static",
"String",
"modifierMatrixToHtml",
"(",
")",
"{",
"final",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"<table border=\\\"1\\\">\\n\"",
")",
";",
"// Header\r",
"sb",
".",
"append",
"(",
"\"<tr>\"",
")",
";",
"sb",
".",
"append",
"(",
"\"<th> </th>\"",
")",
";",
"for",
"(",
"int",
"type",
"=",
"FIELD",
";",
"type",
"<=",
"INNER_INTERFACE",
";",
"type",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"\"<th>\"",
")",
";",
"sb",
".",
"append",
"(",
"TYPE_NAMES",
"[",
"type",
"]",
")",
";",
"sb",
".",
"append",
"(",
"\"</th>\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"</tr>\\n\"",
")",
";",
"// Content\r",
"for",
"(",
"int",
"modifier",
"=",
"ABSTRACT",
";",
"modifier",
"<=",
"STRICTFP",
";",
"modifier",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"\"<tr>\"",
")",
";",
"sb",
".",
"append",
"(",
"\"<td>\"",
")",
";",
"sb",
".",
"append",
"(",
"MODIFIER_NAMES",
"[",
"modifier",
"]",
")",
";",
"sb",
".",
"append",
"(",
"\"</td>\"",
")",
";",
"for",
"(",
"int",
"type",
"=",
"FIELD",
";",
"type",
"<=",
"INNER_INTERFACE",
";",
"type",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"\"<td>\"",
")",
";",
"sb",
".",
"append",
"(",
"MODIFIERS_MATRIX",
"[",
"modifier",
"]",
"[",
"type",
"]",
")",
";",
"sb",
".",
"append",
"(",
"\"</td>\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"</tr>\\n\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"</table>\\n\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Create a simple HTML table for the modifier matrix. This is helpful to
check if the matrix is valid.
@return Modifier matrix HTML table.
|
[
"Create",
"a",
"simple",
"HTML",
"table",
"for",
"the",
"modifier",
"matrix",
".",
"This",
"is",
"helpful",
"to",
"check",
"if",
"the",
"matrix",
"is",
"valid",
"."
] |
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
|
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgUtils.java#L379-L408
|
145,147
|
fuinorg/srcgen4javassist
|
src/main/java/org/fuin/srcgen4javassist/SgUtils.java
|
SgUtils.toModifiers
|
public static int toModifiers(final String modifiers) {
if (modifiers == null) {
return 0;
}
final String trimmedModifiers = modifiers.trim();
int modifier = 0;
final StringTokenizer tok = new StringTokenizer(trimmedModifiers, " ");
while (tok.hasMoreTokens()) {
final String mod = tok.nextToken();
modifier = modifier | modifierValueForName(mod);
}
return modifier;
}
|
java
|
public static int toModifiers(final String modifiers) {
if (modifiers == null) {
return 0;
}
final String trimmedModifiers = modifiers.trim();
int modifier = 0;
final StringTokenizer tok = new StringTokenizer(trimmedModifiers, " ");
while (tok.hasMoreTokens()) {
final String mod = tok.nextToken();
modifier = modifier | modifierValueForName(mod);
}
return modifier;
}
|
[
"public",
"static",
"int",
"toModifiers",
"(",
"final",
"String",
"modifiers",
")",
"{",
"if",
"(",
"modifiers",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"final",
"String",
"trimmedModifiers",
"=",
"modifiers",
".",
"trim",
"(",
")",
";",
"int",
"modifier",
"=",
"0",
";",
"final",
"StringTokenizer",
"tok",
"=",
"new",
"StringTokenizer",
"(",
"trimmedModifiers",
",",
"\" \"",
")",
";",
"while",
"(",
"tok",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"final",
"String",
"mod",
"=",
"tok",
".",
"nextToken",
"(",
")",
";",
"modifier",
"=",
"modifier",
"|",
"modifierValueForName",
"(",
"mod",
")",
";",
"}",
"return",
"modifier",
";",
"}"
] |
Returns a Java "Modifier" value for a list of modifier names.
@param modifiers
Modifier names separated by spaces.
@return Modifiers.
|
[
"Returns",
"a",
"Java",
"Modifier",
"value",
"for",
"a",
"list",
"of",
"modifier",
"names",
"."
] |
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
|
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgUtils.java#L427-L439
|
145,148
|
fuinorg/srcgen4javassist
|
src/main/java/org/fuin/srcgen4javassist/SgUtils.java
|
SgUtils.createAnnotations
|
public static List<SgAnnotation> createAnnotations(final Annotation[] ann) {
final List<SgAnnotation> list = new ArrayList<SgAnnotation>();
if ((ann != null) && (ann.length > 0)) {
for (int i = 0; i < ann.length; i++) {
final SgAnnotation annotation = new SgAnnotation(ann[i].annotationType()
.getPackage().getName(), ann[i].annotationType().getSimpleName());
// TODO Handle annotation arguments
list.add(annotation);
}
}
return list;
}
|
java
|
public static List<SgAnnotation> createAnnotations(final Annotation[] ann) {
final List<SgAnnotation> list = new ArrayList<SgAnnotation>();
if ((ann != null) && (ann.length > 0)) {
for (int i = 0; i < ann.length; i++) {
final SgAnnotation annotation = new SgAnnotation(ann[i].annotationType()
.getPackage().getName(), ann[i].annotationType().getSimpleName());
// TODO Handle annotation arguments
list.add(annotation);
}
}
return list;
}
|
[
"public",
"static",
"List",
"<",
"SgAnnotation",
">",
"createAnnotations",
"(",
"final",
"Annotation",
"[",
"]",
"ann",
")",
"{",
"final",
"List",
"<",
"SgAnnotation",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"SgAnnotation",
">",
"(",
")",
";",
"if",
"(",
"(",
"ann",
"!=",
"null",
")",
"&&",
"(",
"ann",
".",
"length",
">",
"0",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ann",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"SgAnnotation",
"annotation",
"=",
"new",
"SgAnnotation",
"(",
"ann",
"[",
"i",
"]",
".",
"annotationType",
"(",
")",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
",",
"ann",
"[",
"i",
"]",
".",
"annotationType",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"// TODO Handle annotation arguments\r",
"list",
".",
"add",
"(",
"annotation",
")",
";",
"}",
"}",
"return",
"list",
";",
"}"
] |
Create a list of annotations.
@param ann
Java annotation array.
@return List of annotations.
|
[
"Create",
"a",
"list",
"of",
"annotations",
"."
] |
355828113cfce3cdd3d69ba242c5bdfc7d899f2f
|
https://github.com/fuinorg/srcgen4javassist/blob/355828113cfce3cdd3d69ba242c5bdfc7d899f2f/src/main/java/org/fuin/srcgen4javassist/SgUtils.java#L569-L580
|
145,149
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/file/FileTracer.java
|
FileTracer.open
|
@Override
public void open() {
try {
if (this.isOpened() == false) {
System.out.println(formatVersionInfo() + " Opening ...");
this.traceLogfile = FileSystems.getDefault().getPath(this.logDirPath.toString(), super.getName() + ".log").toFile();
this.fileOutputStream = new FileOutputStream(this.traceLogfile);
this.setBufferedOutputStream(new BufferedOutputStream(this.fileOutputStream, this.getBufferSize()));
this.setTracePrintStream(new TracePrintStream(this.getBufferedOutputStream(), this.getThreadMap()));
this.getTracePrintStream().printf("--> TraceLog opened!%n");
this.getTracePrintStream().printf(" Time : %tc%n", new Date());
this.getTracePrintStream().printf(" Bufsize : %d%n", this.getBufferSize());
this.getTracePrintStream().printf(" Autoflush: %b%n%n", this.isAutoflush());
this.setOpened(true);
}
else {
System.err.println("WARNING: Tracelog is opened already.");
}
}
catch (FileNotFoundException ex) {
ex.printStackTrace(System.err);
}
}
|
java
|
@Override
public void open() {
try {
if (this.isOpened() == false) {
System.out.println(formatVersionInfo() + " Opening ...");
this.traceLogfile = FileSystems.getDefault().getPath(this.logDirPath.toString(), super.getName() + ".log").toFile();
this.fileOutputStream = new FileOutputStream(this.traceLogfile);
this.setBufferedOutputStream(new BufferedOutputStream(this.fileOutputStream, this.getBufferSize()));
this.setTracePrintStream(new TracePrintStream(this.getBufferedOutputStream(), this.getThreadMap()));
this.getTracePrintStream().printf("--> TraceLog opened!%n");
this.getTracePrintStream().printf(" Time : %tc%n", new Date());
this.getTracePrintStream().printf(" Bufsize : %d%n", this.getBufferSize());
this.getTracePrintStream().printf(" Autoflush: %b%n%n", this.isAutoflush());
this.setOpened(true);
}
else {
System.err.println("WARNING: Tracelog is opened already.");
}
}
catch (FileNotFoundException ex) {
ex.printStackTrace(System.err);
}
}
|
[
"@",
"Override",
"public",
"void",
"open",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"this",
".",
"isOpened",
"(",
")",
"==",
"false",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"formatVersionInfo",
"(",
")",
"+",
"\" Opening ...\"",
")",
";",
"this",
".",
"traceLogfile",
"=",
"FileSystems",
".",
"getDefault",
"(",
")",
".",
"getPath",
"(",
"this",
".",
"logDirPath",
".",
"toString",
"(",
")",
",",
"super",
".",
"getName",
"(",
")",
"+",
"\".log\"",
")",
".",
"toFile",
"(",
")",
";",
"this",
".",
"fileOutputStream",
"=",
"new",
"FileOutputStream",
"(",
"this",
".",
"traceLogfile",
")",
";",
"this",
".",
"setBufferedOutputStream",
"(",
"new",
"BufferedOutputStream",
"(",
"this",
".",
"fileOutputStream",
",",
"this",
".",
"getBufferSize",
"(",
")",
")",
")",
";",
"this",
".",
"setTracePrintStream",
"(",
"new",
"TracePrintStream",
"(",
"this",
".",
"getBufferedOutputStream",
"(",
")",
",",
"this",
".",
"getThreadMap",
"(",
")",
")",
")",
";",
"this",
".",
"getTracePrintStream",
"(",
")",
".",
"printf",
"(",
"\"--> TraceLog opened!%n\"",
")",
";",
"this",
".",
"getTracePrintStream",
"(",
")",
".",
"printf",
"(",
"\" Time : %tc%n\"",
",",
"new",
"Date",
"(",
")",
")",
";",
"this",
".",
"getTracePrintStream",
"(",
")",
".",
"printf",
"(",
"\" Bufsize : %d%n\"",
",",
"this",
".",
"getBufferSize",
"(",
")",
")",
";",
"this",
".",
"getTracePrintStream",
"(",
")",
".",
"printf",
"(",
"\" Autoflush: %b%n%n\"",
",",
"this",
".",
"isAutoflush",
"(",
")",
")",
";",
"this",
".",
"setOpened",
"(",
"true",
")",
";",
"}",
"else",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"WARNING: Tracelog is opened already.\"",
")",
";",
"}",
"}",
"catch",
"(",
"FileNotFoundException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
"System",
".",
"err",
")",
";",
"}",
"}"
] |
Creates the underlying trace file and opens the associated trace streams. The file name will be assembled by the path to
log directory and the name of the tracer.
|
[
"Creates",
"the",
"underlying",
"trace",
"file",
"and",
"opens",
"the",
"associated",
"trace",
"streams",
".",
"The",
"file",
"name",
"will",
"be",
"assembled",
"by",
"the",
"path",
"to",
"log",
"directory",
"and",
"the",
"name",
"of",
"the",
"tracer",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/file/FileTracer.java#L95-L119
|
145,150
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/file/FileTracer.java
|
FileTracer.close
|
@Override
public void close() {
try {
if (this.isOpened() == true) {
this.getTracePrintStream().println();
this.getTracePrintStream().printf("--> TraceLog closing!%n");
this.getTracePrintStream().printf(" Time : %tc%n", new Date());
System.out.println(formatStreamErrorState() + " Closing ...");
this.getTracePrintStream().close();
this.getBufferedOutputStream().close();
this.fileOutputStream.close();
this.setOpened(false);
}
else {
System.err.println("WARNING: Tracelog is closed already.");
}
}
catch (IOException ex) {
ex.printStackTrace(System.err);
}
}
|
java
|
@Override
public void close() {
try {
if (this.isOpened() == true) {
this.getTracePrintStream().println();
this.getTracePrintStream().printf("--> TraceLog closing!%n");
this.getTracePrintStream().printf(" Time : %tc%n", new Date());
System.out.println(formatStreamErrorState() + " Closing ...");
this.getTracePrintStream().close();
this.getBufferedOutputStream().close();
this.fileOutputStream.close();
this.setOpened(false);
}
else {
System.err.println("WARNING: Tracelog is closed already.");
}
}
catch (IOException ex) {
ex.printStackTrace(System.err);
}
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"this",
".",
"isOpened",
"(",
")",
"==",
"true",
")",
"{",
"this",
".",
"getTracePrintStream",
"(",
")",
".",
"println",
"(",
")",
";",
"this",
".",
"getTracePrintStream",
"(",
")",
".",
"printf",
"(",
"\"--> TraceLog closing!%n\"",
")",
";",
"this",
".",
"getTracePrintStream",
"(",
")",
".",
"printf",
"(",
"\" Time : %tc%n\"",
",",
"new",
"Date",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"formatStreamErrorState",
"(",
")",
"+",
"\" Closing ...\"",
")",
";",
"this",
".",
"getTracePrintStream",
"(",
")",
".",
"close",
"(",
")",
";",
"this",
".",
"getBufferedOutputStream",
"(",
")",
".",
"close",
"(",
")",
";",
"this",
".",
"fileOutputStream",
".",
"close",
"(",
")",
";",
"this",
".",
"setOpened",
"(",
"false",
")",
";",
"}",
"else",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"WARNING: Tracelog is closed already.\"",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
"System",
".",
"err",
")",
";",
"}",
"}"
] |
Closes the associated trace streams.
|
[
"Closes",
"the",
"associated",
"trace",
"streams",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/file/FileTracer.java#L124-L146
|
145,151
|
chr78rm/tracelogger
|
src/main/java/de/christofreichardt/diagnosis/file/FileTracer.java
|
FileTracer.checkLimit
|
protected void checkLimit() {
synchronized (this.getSyncObject()) {
if (this.byteLimit != -1 && this.traceLogfile != null && this.traceLogfile.length() > this.byteLimit) {
close();
int pos = this.traceLogfile.getAbsolutePath().lastIndexOf('\u002e');
String splitFilename = this.traceLogfile.getAbsolutePath().substring(0, pos) + "." + (++this.counter) + ".log";
File splitFile = new File(splitFilename);
if (splitFile.exists()) {
if (!splitFile.delete())
System.err.printf("WARNING: Couldn't delete old file: %s%n", splitFile.getName());
}
this.traceLogfile.renameTo(splitFile);
open();
}
}
}
|
java
|
protected void checkLimit() {
synchronized (this.getSyncObject()) {
if (this.byteLimit != -1 && this.traceLogfile != null && this.traceLogfile.length() > this.byteLimit) {
close();
int pos = this.traceLogfile.getAbsolutePath().lastIndexOf('\u002e');
String splitFilename = this.traceLogfile.getAbsolutePath().substring(0, pos) + "." + (++this.counter) + ".log";
File splitFile = new File(splitFilename);
if (splitFile.exists()) {
if (!splitFile.delete())
System.err.printf("WARNING: Couldn't delete old file: %s%n", splitFile.getName());
}
this.traceLogfile.renameTo(splitFile);
open();
}
}
}
|
[
"protected",
"void",
"checkLimit",
"(",
")",
"{",
"synchronized",
"(",
"this",
".",
"getSyncObject",
"(",
")",
")",
"{",
"if",
"(",
"this",
".",
"byteLimit",
"!=",
"-",
"1",
"&&",
"this",
".",
"traceLogfile",
"!=",
"null",
"&&",
"this",
".",
"traceLogfile",
".",
"length",
"(",
")",
">",
"this",
".",
"byteLimit",
")",
"{",
"close",
"(",
")",
";",
"int",
"pos",
"=",
"this",
".",
"traceLogfile",
".",
"getAbsolutePath",
"(",
")",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"String",
"splitFilename",
"=",
"this",
".",
"traceLogfile",
".",
"getAbsolutePath",
"(",
")",
".",
"substring",
"(",
"0",
",",
"pos",
")",
"+",
"\".\"",
"+",
"(",
"++",
"this",
".",
"counter",
")",
"+",
"\".log\"",
";",
"File",
"splitFile",
"=",
"new",
"File",
"(",
"splitFilename",
")",
";",
"if",
"(",
"splitFile",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"splitFile",
".",
"delete",
"(",
")",
")",
"System",
".",
"err",
".",
"printf",
"(",
"\"WARNING: Couldn't delete old file: %s%n\"",
",",
"splitFile",
".",
"getName",
"(",
")",
")",
";",
"}",
"this",
".",
"traceLogfile",
".",
"renameTo",
"(",
"splitFile",
")",
";",
"open",
"(",
")",
";",
"}",
"}",
"}"
] |
Checks if the file size limit has been exceeded and splits the trace file if need be.
|
[
"Checks",
"if",
"the",
"file",
"size",
"limit",
"has",
"been",
"exceeded",
"and",
"splits",
"the",
"trace",
"file",
"if",
"need",
"be",
"."
] |
ad22452b20f8111ad4d367302c2b26a100a20200
|
https://github.com/chr78rm/tracelogger/blob/ad22452b20f8111ad4d367302c2b26a100a20200/src/main/java/de/christofreichardt/diagnosis/file/FileTracer.java#L172-L189
|
145,152
|
wcm-io-caravan/caravan-hal
|
resource/src/main/java/io/wcm/caravan/hal/resource/util/HalCuriAugmenter.java
|
HalCuriAugmenter.register
|
public HalCuriAugmenter register(String name, String href) {
Link link = new Link(href).setName(name);
return register(link);
}
|
java
|
public HalCuriAugmenter register(String name, String href) {
Link link = new Link(href).setName(name);
return register(link);
}
|
[
"public",
"HalCuriAugmenter",
"register",
"(",
"String",
"name",
",",
"String",
"href",
")",
"{",
"Link",
"link",
"=",
"new",
"Link",
"(",
"href",
")",
".",
"setName",
"(",
"name",
")",
";",
"return",
"register",
"(",
"link",
")",
";",
"}"
] |
Registers a CURI link by the given name and HREF.
@param name CURI link name
@param href Link URI
@return This augmenter
|
[
"Registers",
"a",
"CURI",
"link",
"by",
"the",
"given",
"name",
"and",
"HREF",
"."
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/util/HalCuriAugmenter.java#L65-L68
|
145,153
|
wcm-io-caravan/caravan-hal
|
resource/src/main/java/io/wcm/caravan/hal/resource/util/HalCuriAugmenter.java
|
HalCuriAugmenter.augment
|
public HalCuriAugmenter augment(HalResource hal) {
Set<String> existingCurieNames = getExistingCurieNames(hal);
Set<Link> curieLinks = getCuriLinks(hal, existingCurieNames);
hal.addLinks(LINK_RELATION_CURIES, curieLinks);
return this;
}
|
java
|
public HalCuriAugmenter augment(HalResource hal) {
Set<String> existingCurieNames = getExistingCurieNames(hal);
Set<Link> curieLinks = getCuriLinks(hal, existingCurieNames);
hal.addLinks(LINK_RELATION_CURIES, curieLinks);
return this;
}
|
[
"public",
"HalCuriAugmenter",
"augment",
"(",
"HalResource",
"hal",
")",
"{",
"Set",
"<",
"String",
">",
"existingCurieNames",
"=",
"getExistingCurieNames",
"(",
"hal",
")",
";",
"Set",
"<",
"Link",
">",
"curieLinks",
"=",
"getCuriLinks",
"(",
"hal",
",",
"existingCurieNames",
")",
";",
"hal",
".",
"addLinks",
"(",
"LINK_RELATION_CURIES",
",",
"curieLinks",
")",
";",
"return",
"this",
";",
"}"
] |
Augments a HAL resource by CURI links. Only adds CURIES being registered and referenced in the HAL resource. Will not override existing CURI links.
@param hal HAL resource to augment
@return This augmenter
|
[
"Augments",
"a",
"HAL",
"resource",
"by",
"CURI",
"links",
".",
"Only",
"adds",
"CURIES",
"being",
"registered",
"and",
"referenced",
"in",
"the",
"HAL",
"resource",
".",
"Will",
"not",
"override",
"existing",
"CURI",
"links",
"."
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/resource/src/main/java/io/wcm/caravan/hal/resource/util/HalCuriAugmenter.java#L112-L119
|
145,154
|
triceo/splitlog
|
splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java
|
LogWatchStorageManager.getAllMessages
|
protected synchronized List<Message> getAllMessages(final Follower follower) {
final int end = this.getEndingMessageId(follower);
/*
* If messages have been discarded, the original starting message ID
* will no longer be valid. Therefore, we check for the actual starting
* ID.
*/
final int start = Math.max(this.messages.getFirstPosition(), this.getStartingMessageId(follower));
if (start > end) {
/*
* in case some messages have been discarded, the actual start may
* get ahead of the expected end. this would have caused an
* exception within the message store, and so we handle it here and
* return an empty list. this is exactly correct, as if the end is
* before the first message in the store, there really is nothing to
* return.
*/
return Collections.unmodifiableList(Collections.emptyList());
} else {
return Collections.unmodifiableList(this.messages.getFromRange(start, end + 1));
}
}
|
java
|
protected synchronized List<Message> getAllMessages(final Follower follower) {
final int end = this.getEndingMessageId(follower);
/*
* If messages have been discarded, the original starting message ID
* will no longer be valid. Therefore, we check for the actual starting
* ID.
*/
final int start = Math.max(this.messages.getFirstPosition(), this.getStartingMessageId(follower));
if (start > end) {
/*
* in case some messages have been discarded, the actual start may
* get ahead of the expected end. this would have caused an
* exception within the message store, and so we handle it here and
* return an empty list. this is exactly correct, as if the end is
* before the first message in the store, there really is nothing to
* return.
*/
return Collections.unmodifiableList(Collections.emptyList());
} else {
return Collections.unmodifiableList(this.messages.getFromRange(start, end + 1));
}
}
|
[
"protected",
"synchronized",
"List",
"<",
"Message",
">",
"getAllMessages",
"(",
"final",
"Follower",
"follower",
")",
"{",
"final",
"int",
"end",
"=",
"this",
".",
"getEndingMessageId",
"(",
"follower",
")",
";",
"/*\n * If messages have been discarded, the original starting message ID\n * will no longer be valid. Therefore, we check for the actual starting\n * ID.\n */",
"final",
"int",
"start",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"messages",
".",
"getFirstPosition",
"(",
")",
",",
"this",
".",
"getStartingMessageId",
"(",
"follower",
")",
")",
";",
"if",
"(",
"start",
">",
"end",
")",
"{",
"/*\n * in case some messages have been discarded, the actual start may\n * get ahead of the expected end. this would have caused an\n * exception within the message store, and so we handle it here and\n * return an empty list. this is exactly correct, as if the end is\n * before the first message in the store, there really is nothing to\n * return.\n */",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"Collections",
".",
"emptyList",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"this",
".",
"messages",
".",
"getFromRange",
"(",
"start",
",",
"end",
"+",
"1",
")",
")",
";",
"}",
"}"
] |
Return all messages that have been sent to the follower, from its start
until either its termination or to this moment, whichever is relevant.
This method is synchronized so that the modification of the underlying
message store in {@link #addLine(String)} and the reading of this store
is mutually excluded. Otherwise, there is a possibility of message ID
mess in the discarding case.
@param follower
The follower in question.
@return Unmodifiable list of all the received messages, in the order
received.
|
[
"Return",
"all",
"messages",
"that",
"have",
"been",
"sent",
"to",
"the",
"follower",
"from",
"its",
"start",
"until",
"either",
"its",
"termination",
"or",
"to",
"this",
"moment",
"whichever",
"is",
"relevant",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java#L89-L110
|
145,155
|
triceo/splitlog
|
splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java
|
LogWatchStorageManager.getEndingMessageId
|
private synchronized int getEndingMessageId(final Follower follower) {
if (this.isFollowerActive(follower)) {
return this.messages.getLatestPosition();
} else if (this.isFollowerTerminated(follower)) {
return this.terminatedFollowerRanges.get(follower)[1];
} else {
throw new IllegalStateException("Follower never before seen.");
}
}
|
java
|
private synchronized int getEndingMessageId(final Follower follower) {
if (this.isFollowerActive(follower)) {
return this.messages.getLatestPosition();
} else if (this.isFollowerTerminated(follower)) {
return this.terminatedFollowerRanges.get(follower)[1];
} else {
throw new IllegalStateException("Follower never before seen.");
}
}
|
[
"private",
"synchronized",
"int",
"getEndingMessageId",
"(",
"final",
"Follower",
"follower",
")",
"{",
"if",
"(",
"this",
".",
"isFollowerActive",
"(",
"follower",
")",
")",
"{",
"return",
"this",
".",
"messages",
".",
"getLatestPosition",
"(",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"isFollowerTerminated",
"(",
"follower",
")",
")",
"{",
"return",
"this",
".",
"terminatedFollowerRanges",
".",
"get",
"(",
"follower",
")",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Follower never before seen.\"",
")",
";",
"}",
"}"
] |
Get index of the last plus one message that the follower has access to.
@param follower
Follower in question.
@return Ending message ID after {@link #followerTerminated(Follower)}.
{@link MessageStore#getLatestPosition()} between
{@link #followerStarted(Follower)} and
{@link #followerTerminated(Follower)}. Will throw an exception
otherwise.
|
[
"Get",
"index",
"of",
"the",
"last",
"plus",
"one",
"message",
"that",
"the",
"follower",
"has",
"access",
"to",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java#L123-L131
|
145,156
|
triceo/splitlog
|
splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java
|
LogWatchStorageManager.getFirstReachableMessageId
|
protected synchronized int getFirstReachableMessageId() {
final boolean followersRunning = !this.runningFollowerStartMarks.isEmpty();
if (!followersRunning && this.terminatedFollowerRanges.isEmpty()) {
// no followers present; no reachable messages
return -1;
}
final IntSortedSet set = new IntAVLTreeSet(this.runningFollowerStartMarks.values());
if (!set.isEmpty()) {
final int first = this.messages.getFirstPosition();
if (set.firstInt() <= first) {
/*
* cannot go below first position; any other calculation
* unnecessary
*/
return first;
}
}
set.addAll(this.terminatedFollowerRanges.values().stream().map(pair -> pair[0]).collect(Collectors.toList()));
return set.firstInt();
}
|
java
|
protected synchronized int getFirstReachableMessageId() {
final boolean followersRunning = !this.runningFollowerStartMarks.isEmpty();
if (!followersRunning && this.terminatedFollowerRanges.isEmpty()) {
// no followers present; no reachable messages
return -1;
}
final IntSortedSet set = new IntAVLTreeSet(this.runningFollowerStartMarks.values());
if (!set.isEmpty()) {
final int first = this.messages.getFirstPosition();
if (set.firstInt() <= first) {
/*
* cannot go below first position; any other calculation
* unnecessary
*/
return first;
}
}
set.addAll(this.terminatedFollowerRanges.values().stream().map(pair -> pair[0]).collect(Collectors.toList()));
return set.firstInt();
}
|
[
"protected",
"synchronized",
"int",
"getFirstReachableMessageId",
"(",
")",
"{",
"final",
"boolean",
"followersRunning",
"=",
"!",
"this",
".",
"runningFollowerStartMarks",
".",
"isEmpty",
"(",
")",
";",
"if",
"(",
"!",
"followersRunning",
"&&",
"this",
".",
"terminatedFollowerRanges",
".",
"isEmpty",
"(",
")",
")",
"{",
"// no followers present; no reachable messages",
"return",
"-",
"1",
";",
"}",
"final",
"IntSortedSet",
"set",
"=",
"new",
"IntAVLTreeSet",
"(",
"this",
".",
"runningFollowerStartMarks",
".",
"values",
"(",
")",
")",
";",
"if",
"(",
"!",
"set",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"int",
"first",
"=",
"this",
".",
"messages",
".",
"getFirstPosition",
"(",
")",
";",
"if",
"(",
"set",
".",
"firstInt",
"(",
")",
"<=",
"first",
")",
"{",
"/*\n * cannot go below first position; any other calculation\n * unnecessary\n */",
"return",
"first",
";",
"}",
"}",
"set",
".",
"addAll",
"(",
"this",
".",
"terminatedFollowerRanges",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"pair",
"->",
"pair",
"[",
"0",
"]",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"return",
"set",
".",
"firstInt",
"(",
")",
";",
"}"
] |
Will crawl the weak hash maps and make sure we always have the latest
information on the availability of messages.
This method is only intended to be used from within
{@link LogWatchStorageSweeper}.
@return ID of the very first message that is reachable by any follower in
this logWatch. -1 when there are no reachable messages.
|
[
"Will",
"crawl",
"the",
"weak",
"hash",
"maps",
"and",
"make",
"sure",
"we",
"always",
"have",
"the",
"latest",
"information",
"on",
"the",
"availability",
"of",
"messages",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java#L143-L162
|
145,157
|
triceo/splitlog
|
splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java
|
LogWatchStorageManager.getStartingMessageId
|
private synchronized int getStartingMessageId(final Follower follower) {
if (this.isFollowerActive(follower)) {
return this.runningFollowerStartMarks.getInt(follower);
} else if (this.isFollowerTerminated(follower)) {
return this.terminatedFollowerRanges.get(follower)[0];
} else {
throw new IllegalStateException("Follower never before seen.");
}
}
|
java
|
private synchronized int getStartingMessageId(final Follower follower) {
if (this.isFollowerActive(follower)) {
return this.runningFollowerStartMarks.getInt(follower);
} else if (this.isFollowerTerminated(follower)) {
return this.terminatedFollowerRanges.get(follower)[0];
} else {
throw new IllegalStateException("Follower never before seen.");
}
}
|
[
"private",
"synchronized",
"int",
"getStartingMessageId",
"(",
"final",
"Follower",
"follower",
")",
"{",
"if",
"(",
"this",
".",
"isFollowerActive",
"(",
"follower",
")",
")",
"{",
"return",
"this",
".",
"runningFollowerStartMarks",
".",
"getInt",
"(",
"follower",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"isFollowerTerminated",
"(",
"follower",
")",
")",
"{",
"return",
"this",
".",
"terminatedFollowerRanges",
".",
"get",
"(",
"follower",
")",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Follower never before seen.\"",
")",
";",
"}",
"}"
] |
For a given follower, return the starting mark.
@param follower
Tailer in question.
@return Starting message ID, if after {@link #followerStarted(Follower)}.
Will throw an exception otherwise.
|
[
"For",
"a",
"given",
"follower",
"return",
"the",
"starting",
"mark",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java#L188-L196
|
145,158
|
triceo/splitlog
|
splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java
|
LogWatchStorageManager.logWatchTerminated
|
public synchronized void logWatchTerminated() {
final Iterable<Follower> followersToTerminate = new ObjectLinkedOpenHashSet<>(this.runningFollowerStartMarks.keySet());
followersToTerminate.forEach(this::followerTerminated);
this.sweeping.stop();
}
|
java
|
public synchronized void logWatchTerminated() {
final Iterable<Follower> followersToTerminate = new ObjectLinkedOpenHashSet<>(this.runningFollowerStartMarks.keySet());
followersToTerminate.forEach(this::followerTerminated);
this.sweeping.stop();
}
|
[
"public",
"synchronized",
"void",
"logWatchTerminated",
"(",
")",
"{",
"final",
"Iterable",
"<",
"Follower",
">",
"followersToTerminate",
"=",
"new",
"ObjectLinkedOpenHashSet",
"<>",
"(",
"this",
".",
"runningFollowerStartMarks",
".",
"keySet",
"(",
")",
")",
";",
"followersToTerminate",
".",
"forEach",
"(",
"this",
"::",
"followerTerminated",
")",
";",
"this",
".",
"sweeping",
".",
"stop",
"(",
")",
";",
"}"
] |
Will mean the end of the storage, including the termination of sweeping.
|
[
"Will",
"mean",
"the",
"end",
"of",
"the",
"storage",
"including",
"the",
"termination",
"of",
"sweeping",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/com/github/triceo/splitlog/LogWatchStorageManager.java#L227-L231
|
145,159
|
syphr42/prom
|
src/main/java/org/syphr/prom/PropertiesManagers.java
|
PropertiesManagers.getProperties
|
public static Properties getProperties(URL url) throws IOException
{
Properties properties = new Properties();
InputStream inputStream = url.openStream();
try
{
properties.load(inputStream);
}
finally
{
inputStream.close();
}
return properties;
}
|
java
|
public static Properties getProperties(URL url) throws IOException
{
Properties properties = new Properties();
InputStream inputStream = url.openStream();
try
{
properties.load(inputStream);
}
finally
{
inputStream.close();
}
return properties;
}
|
[
"public",
"static",
"Properties",
"getProperties",
"(",
"URL",
"url",
")",
"throws",
"IOException",
"{",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"InputStream",
"inputStream",
"=",
"url",
".",
"openStream",
"(",
")",
";",
"try",
"{",
"properties",
".",
"load",
"(",
"inputStream",
")",
";",
"}",
"finally",
"{",
"inputStream",
".",
"close",
"(",
")",
";",
"}",
"return",
"properties",
";",
"}"
] |
Load values from a URL.
@param url
the URL containing default values
@return a new properties instance loaded with values from the given URL
@throws IOException
if there is an error while reading the given URL
|
[
"Load",
"values",
"from",
"a",
"URL",
"."
] |
074d67c4ebb3afb0b163fcb0bc4826ee577ac803
|
https://github.com/syphr42/prom/blob/074d67c4ebb3afb0b163fcb0bc4826ee577ac803/src/main/java/org/syphr/prom/PropertiesManagers.java#L374-L389
|
145,160
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/Scenario3DPortrayal.java
|
Scenario3DPortrayal.drawLink
|
public void drawLink(Link link) {
List<Device> linkedDevices = link.getLinkedDevices();
for (int i = 0; i<linkedDevices.size(); i++) {
Device from = linkedDevices.get(i);
for (int j = i+1 ; j<linkedDevices.size(); j++) {
Device to = linkedDevices.get(j);
Edge e = new Edge(from, to, link);
links.addEdge(e);
}
}
}
|
java
|
public void drawLink(Link link) {
List<Device> linkedDevices = link.getLinkedDevices();
for (int i = 0; i<linkedDevices.size(); i++) {
Device from = linkedDevices.get(i);
for (int j = i+1 ; j<linkedDevices.size(); j++) {
Device to = linkedDevices.get(j);
Edge e = new Edge(from, to, link);
links.addEdge(e);
}
}
}
|
[
"public",
"void",
"drawLink",
"(",
"Link",
"link",
")",
"{",
"List",
"<",
"Device",
">",
"linkedDevices",
"=",
"link",
".",
"getLinkedDevices",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"linkedDevices",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Device",
"from",
"=",
"linkedDevices",
".",
"get",
"(",
"i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"i",
"+",
"1",
";",
"j",
"<",
"linkedDevices",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"Device",
"to",
"=",
"linkedDevices",
".",
"get",
"(",
"j",
")",
";",
"Edge",
"e",
"=",
"new",
"Edge",
"(",
"from",
",",
"to",
",",
"link",
")",
";",
"links",
".",
"addEdge",
"(",
"e",
")",
";",
"}",
"}",
"}"
] |
To draw a link
@param link
|
[
"To",
"draw",
"a",
"link"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/model/scenario/portrayal/Scenario3DPortrayal.java#L190-L200
|
145,161
|
dbracewell/mango
|
src/main/java/com/davidbracewell/string/TableFormatter.java
|
TableFormatter.header
|
public <T> TableFormatter header(Collection<? extends T> collection) {
header.addAll(collection);
longestCell = (int) Math.max(longestCell, collection.stream()
.mapToDouble(o -> o.toString().length() + 2)
.max()
.orElse(0));
return this;
}
|
java
|
public <T> TableFormatter header(Collection<? extends T> collection) {
header.addAll(collection);
longestCell = (int) Math.max(longestCell, collection.stream()
.mapToDouble(o -> o.toString().length() + 2)
.max()
.orElse(0));
return this;
}
|
[
"public",
"<",
"T",
">",
"TableFormatter",
"header",
"(",
"Collection",
"<",
"?",
"extends",
"T",
">",
"collection",
")",
"{",
"header",
".",
"addAll",
"(",
"collection",
")",
";",
"longestCell",
"=",
"(",
"int",
")",
"Math",
".",
"max",
"(",
"longestCell",
",",
"collection",
".",
"stream",
"(",
")",
".",
"mapToDouble",
"(",
"o",
"->",
"o",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
"+",
"2",
")",
".",
"max",
"(",
")",
".",
"orElse",
"(",
"0",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Header table formatter.
@param collection the collection
@return the table formatter
|
[
"Header",
"table",
"formatter",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/string/TableFormatter.java#L77-L84
|
145,162
|
dbracewell/mango
|
src/main/java/com/davidbracewell/string/TableFormatter.java
|
TableFormatter.content
|
public TableFormatter content(Collection<?> collection) {
this.content.add(new ArrayList<>(collection));
longestCell = (int) Math.max(longestCell, collection.stream()
.mapToDouble(o -> {
if (o instanceof Number) {
return Math.max(MIN_CELL_WIDTH, length(Cast.as(o)));
} else {
return Math.max(MIN_CELL_WIDTH,
o.toString().length() + 2);
}
}
).max().orElse(0)
);
longestRow = Math.max(longestRow, collection.size());
return this;
}
|
java
|
public TableFormatter content(Collection<?> collection) {
this.content.add(new ArrayList<>(collection));
longestCell = (int) Math.max(longestCell, collection.stream()
.mapToDouble(o -> {
if (o instanceof Number) {
return Math.max(MIN_CELL_WIDTH, length(Cast.as(o)));
} else {
return Math.max(MIN_CELL_WIDTH,
o.toString().length() + 2);
}
}
).max().orElse(0)
);
longestRow = Math.max(longestRow, collection.size());
return this;
}
|
[
"public",
"TableFormatter",
"content",
"(",
"Collection",
"<",
"?",
">",
"collection",
")",
"{",
"this",
".",
"content",
".",
"add",
"(",
"new",
"ArrayList",
"<>",
"(",
"collection",
")",
")",
";",
"longestCell",
"=",
"(",
"int",
")",
"Math",
".",
"max",
"(",
"longestCell",
",",
"collection",
".",
"stream",
"(",
")",
".",
"mapToDouble",
"(",
"o",
"->",
"{",
"if",
"(",
"o",
"instanceof",
"Number",
")",
"{",
"return",
"Math",
".",
"max",
"(",
"MIN_CELL_WIDTH",
",",
"length",
"(",
"Cast",
".",
"as",
"(",
"o",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"Math",
".",
"max",
"(",
"MIN_CELL_WIDTH",
",",
"o",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
"+",
"2",
")",
";",
"}",
"}",
")",
".",
"max",
"(",
")",
".",
"orElse",
"(",
"0",
")",
")",
";",
"longestRow",
"=",
"Math",
".",
"max",
"(",
"longestRow",
",",
"collection",
".",
"size",
"(",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Content table formatter.
@param collection the collection
@return the table formatter
|
[
"Content",
"table",
"formatter",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/string/TableFormatter.java#L101-L116
|
145,163
|
fuinorg/srcgen4j-commons
|
src/main/java/org/fuin/srcgen4j/commons/SrcGen4J.java
|
SrcGen4J.execute
|
public final void execute() throws ParseException, GenerateException {
LOG.info("Executing full build");
enhanceClasspath();
cleanFolders();
// Parse models & generate
final Parsers parsers = config.getParsers();
if (parsers == null) {
LOG.warn("No parsers element");
} else {
final List<ParserConfig> parserConfigs = parsers.getList();
if (parserConfigs == null) {
LOG.warn("No parsers configured");
} else {
for (final ParserConfig pc : parserConfigs) {
final Parser<Object> parser = pc.getParser();
final Object model = parser.parse();
final List<GeneratorConfig> generatorConfigs = config.findGeneratorsForParser(pc.getName());
for (final GeneratorConfig gc : generatorConfigs) {
final Generator<Object> generator = gc.getGenerator();
generator.generate(model, false);
}
}
}
}
}
|
java
|
public final void execute() throws ParseException, GenerateException {
LOG.info("Executing full build");
enhanceClasspath();
cleanFolders();
// Parse models & generate
final Parsers parsers = config.getParsers();
if (parsers == null) {
LOG.warn("No parsers element");
} else {
final List<ParserConfig> parserConfigs = parsers.getList();
if (parserConfigs == null) {
LOG.warn("No parsers configured");
} else {
for (final ParserConfig pc : parserConfigs) {
final Parser<Object> parser = pc.getParser();
final Object model = parser.parse();
final List<GeneratorConfig> generatorConfigs = config.findGeneratorsForParser(pc.getName());
for (final GeneratorConfig gc : generatorConfigs) {
final Generator<Object> generator = gc.getGenerator();
generator.generate(model, false);
}
}
}
}
}
|
[
"public",
"final",
"void",
"execute",
"(",
")",
"throws",
"ParseException",
",",
"GenerateException",
"{",
"LOG",
".",
"info",
"(",
"\"Executing full build\"",
")",
";",
"enhanceClasspath",
"(",
")",
";",
"cleanFolders",
"(",
")",
";",
"// Parse models & generate\r",
"final",
"Parsers",
"parsers",
"=",
"config",
".",
"getParsers",
"(",
")",
";",
"if",
"(",
"parsers",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"No parsers element\"",
")",
";",
"}",
"else",
"{",
"final",
"List",
"<",
"ParserConfig",
">",
"parserConfigs",
"=",
"parsers",
".",
"getList",
"(",
")",
";",
"if",
"(",
"parserConfigs",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"No parsers configured\"",
")",
";",
"}",
"else",
"{",
"for",
"(",
"final",
"ParserConfig",
"pc",
":",
"parserConfigs",
")",
"{",
"final",
"Parser",
"<",
"Object",
">",
"parser",
"=",
"pc",
".",
"getParser",
"(",
")",
";",
"final",
"Object",
"model",
"=",
"parser",
".",
"parse",
"(",
")",
";",
"final",
"List",
"<",
"GeneratorConfig",
">",
"generatorConfigs",
"=",
"config",
".",
"findGeneratorsForParser",
"(",
"pc",
".",
"getName",
"(",
")",
")",
";",
"for",
"(",
"final",
"GeneratorConfig",
"gc",
":",
"generatorConfigs",
")",
"{",
"final",
"Generator",
"<",
"Object",
">",
"generator",
"=",
"gc",
".",
"getGenerator",
"(",
")",
";",
"generator",
".",
"generate",
"(",
"model",
",",
"false",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Parse and generate.
@throws ParseException
Error during parse process.
@throws GenerateException
Error during generation process.
|
[
"Parse",
"and",
"generate",
"."
] |
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
|
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/SrcGen4J.java#L181-L210
|
145,164
|
fuinorg/srcgen4j-commons
|
src/main/java/org/fuin/srcgen4j/commons/SrcGen4J.java
|
SrcGen4J.getFileFilter
|
@NotNull
public FileFilter getFileFilter() {
if (fileFilter == null) {
final List<IOFileFilter> filters = new ArrayList<>();
final Parsers parsers = config.getParsers();
if (parsers != null) {
final List<ParserConfig> parserConfigs = parsers.getList();
if (parserConfigs != null) {
for (final ParserConfig pc : parserConfigs) {
final Parser<Object> pars = pc.getParser();
if (pars instanceof IncrementalParser) {
final IncrementalParser<?> parser = (IncrementalParser<?>) pars;
filters.add(parser.getFileFilter());
}
}
}
}
fileFilter = new OrFileFilter(filters);
}
return fileFilter;
}
|
java
|
@NotNull
public FileFilter getFileFilter() {
if (fileFilter == null) {
final List<IOFileFilter> filters = new ArrayList<>();
final Parsers parsers = config.getParsers();
if (parsers != null) {
final List<ParserConfig> parserConfigs = parsers.getList();
if (parserConfigs != null) {
for (final ParserConfig pc : parserConfigs) {
final Parser<Object> pars = pc.getParser();
if (pars instanceof IncrementalParser) {
final IncrementalParser<?> parser = (IncrementalParser<?>) pars;
filters.add(parser.getFileFilter());
}
}
}
}
fileFilter = new OrFileFilter(filters);
}
return fileFilter;
}
|
[
"@",
"NotNull",
"public",
"FileFilter",
"getFileFilter",
"(",
")",
"{",
"if",
"(",
"fileFilter",
"==",
"null",
")",
"{",
"final",
"List",
"<",
"IOFileFilter",
">",
"filters",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"final",
"Parsers",
"parsers",
"=",
"config",
".",
"getParsers",
"(",
")",
";",
"if",
"(",
"parsers",
"!=",
"null",
")",
"{",
"final",
"List",
"<",
"ParserConfig",
">",
"parserConfigs",
"=",
"parsers",
".",
"getList",
"(",
")",
";",
"if",
"(",
"parserConfigs",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"ParserConfig",
"pc",
":",
"parserConfigs",
")",
"{",
"final",
"Parser",
"<",
"Object",
">",
"pars",
"=",
"pc",
".",
"getParser",
"(",
")",
";",
"if",
"(",
"pars",
"instanceof",
"IncrementalParser",
")",
"{",
"final",
"IncrementalParser",
"<",
"?",
">",
"parser",
"=",
"(",
"IncrementalParser",
"<",
"?",
">",
")",
"pars",
";",
"filters",
".",
"add",
"(",
"parser",
".",
"getFileFilter",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"fileFilter",
"=",
"new",
"OrFileFilter",
"(",
"filters",
")",
";",
"}",
"return",
"fileFilter",
";",
"}"
] |
Returns a file filter that combines all filters for all incremental parsers. It should be used for selecting the appropriate files.
@return File filter.
|
[
"Returns",
"a",
"file",
"filter",
"that",
"combines",
"all",
"filters",
"for",
"all",
"incremental",
"parsers",
".",
"It",
"should",
"be",
"used",
"for",
"selecting",
"the",
"appropriate",
"files",
"."
] |
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
|
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/SrcGen4J.java#L217-L237
|
145,165
|
fuinorg/srcgen4j-commons
|
src/main/java/org/fuin/srcgen4j/commons/SrcGen4J.java
|
SrcGen4J.execute
|
public final void execute(@NotNull final Set<File> files) throws ParseException, GenerateException {
Contract.requireArgNotNull("files", files);
LOG.info("Executing incremental build ({} files)", files.size());
if (LOG.isDebugEnabled()) {
for (final File file : files) {
LOG.debug(file.toString());
}
}
if (files.size() == 0) {
// Nothing to do...
return;
}
// Parse models & generate
final Parsers parsers = config.getParsers();
if (parsers == null) {
LOG.warn("No parsers element");
} else {
final List<ParserConfig> parserConfigs = parsers.getList();
if (parserConfigs == null) {
LOG.warn("No parsers configured");
} else {
for (final ParserConfig pc : parserConfigs) {
final Parser<Object> pars = pc.getParser();
if (pars instanceof IncrementalParser) {
final IncrementalParser<?> parser = (IncrementalParser<?>) pars;
final Object model = parser.parse(files);
final List<GeneratorConfig> generatorConfigs = config.findGeneratorsForParser(pc.getName());
for (final GeneratorConfig gc : generatorConfigs) {
final Generator<Object> generator = gc.getGenerator();
generator.generate(model, true);
}
} else {
LOG.debug("No incremental parser: {}", pars.getClass().getName());
}
}
}
}
}
|
java
|
public final void execute(@NotNull final Set<File> files) throws ParseException, GenerateException {
Contract.requireArgNotNull("files", files);
LOG.info("Executing incremental build ({} files)", files.size());
if (LOG.isDebugEnabled()) {
for (final File file : files) {
LOG.debug(file.toString());
}
}
if (files.size() == 0) {
// Nothing to do...
return;
}
// Parse models & generate
final Parsers parsers = config.getParsers();
if (parsers == null) {
LOG.warn("No parsers element");
} else {
final List<ParserConfig> parserConfigs = parsers.getList();
if (parserConfigs == null) {
LOG.warn("No parsers configured");
} else {
for (final ParserConfig pc : parserConfigs) {
final Parser<Object> pars = pc.getParser();
if (pars instanceof IncrementalParser) {
final IncrementalParser<?> parser = (IncrementalParser<?>) pars;
final Object model = parser.parse(files);
final List<GeneratorConfig> generatorConfigs = config.findGeneratorsForParser(pc.getName());
for (final GeneratorConfig gc : generatorConfigs) {
final Generator<Object> generator = gc.getGenerator();
generator.generate(model, true);
}
} else {
LOG.debug("No incremental parser: {}", pars.getClass().getName());
}
}
}
}
}
|
[
"public",
"final",
"void",
"execute",
"(",
"@",
"NotNull",
"final",
"Set",
"<",
"File",
">",
"files",
")",
"throws",
"ParseException",
",",
"GenerateException",
"{",
"Contract",
".",
"requireArgNotNull",
"(",
"\"files\"",
",",
"files",
")",
";",
"LOG",
".",
"info",
"(",
"\"Executing incremental build ({} files)\"",
",",
"files",
".",
"size",
"(",
")",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"for",
"(",
"final",
"File",
"file",
":",
"files",
")",
"{",
"LOG",
".",
"debug",
"(",
"file",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"files",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// Nothing to do...\r",
"return",
";",
"}",
"// Parse models & generate\r",
"final",
"Parsers",
"parsers",
"=",
"config",
".",
"getParsers",
"(",
")",
";",
"if",
"(",
"parsers",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"No parsers element\"",
")",
";",
"}",
"else",
"{",
"final",
"List",
"<",
"ParserConfig",
">",
"parserConfigs",
"=",
"parsers",
".",
"getList",
"(",
")",
";",
"if",
"(",
"parserConfigs",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"No parsers configured\"",
")",
";",
"}",
"else",
"{",
"for",
"(",
"final",
"ParserConfig",
"pc",
":",
"parserConfigs",
")",
"{",
"final",
"Parser",
"<",
"Object",
">",
"pars",
"=",
"pc",
".",
"getParser",
"(",
")",
";",
"if",
"(",
"pars",
"instanceof",
"IncrementalParser",
")",
"{",
"final",
"IncrementalParser",
"<",
"?",
">",
"parser",
"=",
"(",
"IncrementalParser",
"<",
"?",
">",
")",
"pars",
";",
"final",
"Object",
"model",
"=",
"parser",
".",
"parse",
"(",
"files",
")",
";",
"final",
"List",
"<",
"GeneratorConfig",
">",
"generatorConfigs",
"=",
"config",
".",
"findGeneratorsForParser",
"(",
"pc",
".",
"getName",
"(",
")",
")",
";",
"for",
"(",
"final",
"GeneratorConfig",
"gc",
":",
"generatorConfigs",
")",
"{",
"final",
"Generator",
"<",
"Object",
">",
"generator",
"=",
"gc",
".",
"getGenerator",
"(",
")",
";",
"generator",
".",
"generate",
"(",
"model",
",",
"true",
")",
";",
"}",
"}",
"else",
"{",
"LOG",
".",
"debug",
"(",
"\"No incremental parser: {}\"",
",",
"pars",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Incremental parse and generate. The class loader of this class will be used.
@param files
Set of files to parse for the model.
@throws ParseException
Error during parse process.
@throws GenerateException
Error during generation process.
|
[
"Incremental",
"parse",
"and",
"generate",
".",
"The",
"class",
"loader",
"of",
"this",
"class",
"will",
"be",
"used",
"."
] |
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
|
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/SrcGen4J.java#L250-L292
|
145,166
|
EsfingeFramework/ClassMock
|
ClassMock/src/main/java/net/sf/esfinge/classmock/parse/ParseASM.java
|
ParseASM.parse
|
public byte[] parse() {
this.addEntity();
this.addClassDefaultConstructor();
this.addClassLevelAnnotations();
this.addFields();
this.addMethods();
this.cw.visitEnd();
return this.cw.toByteArray();
}
|
java
|
public byte[] parse() {
this.addEntity();
this.addClassDefaultConstructor();
this.addClassLevelAnnotations();
this.addFields();
this.addMethods();
this.cw.visitEnd();
return this.cw.toByteArray();
}
|
[
"public",
"byte",
"[",
"]",
"parse",
"(",
")",
"{",
"this",
".",
"addEntity",
"(",
")",
";",
"this",
".",
"addClassDefaultConstructor",
"(",
")",
";",
"this",
".",
"addClassLevelAnnotations",
"(",
")",
";",
"this",
".",
"addFields",
"(",
")",
";",
"this",
".",
"addMethods",
"(",
")",
";",
"this",
".",
"cw",
".",
"visitEnd",
"(",
")",
";",
"return",
"this",
".",
"cw",
".",
"toByteArray",
"(",
")",
";",
"}"
] |
Mount the class and generate it definition in byte array.
@return the data from the entity
|
[
"Mount",
"the",
"class",
"and",
"generate",
"it",
"definition",
"in",
"byte",
"array",
"."
] |
a354c9dc68e8813fc4e995eef13e34796af58892
|
https://github.com/EsfingeFramework/ClassMock/blob/a354c9dc68e8813fc4e995eef13e34796af58892/ClassMock/src/main/java/net/sf/esfinge/classmock/parse/ParseASM.java#L65-L76
|
145,167
|
duraspace/fcrepo-cloudsync
|
fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/rest/URIMapper.java
|
URIMapper.getUri
|
public static URI getUri(UriInfo uriInfo,
HttpServletRequest req,
String path) {
String suffix = "";
if (req.getRequestURI().endsWith(".json")) {
suffix = ".json";
} else if (req.getRequestURI().endsWith(".xml")) {
suffix = ".xml";
}
return URI.create(uriInfo.getBaseUri() + "/" + path + suffix);
}
|
java
|
public static URI getUri(UriInfo uriInfo,
HttpServletRequest req,
String path) {
String suffix = "";
if (req.getRequestURI().endsWith(".json")) {
suffix = ".json";
} else if (req.getRequestURI().endsWith(".xml")) {
suffix = ".xml";
}
return URI.create(uriInfo.getBaseUri() + "/" + path + suffix);
}
|
[
"public",
"static",
"URI",
"getUri",
"(",
"UriInfo",
"uriInfo",
",",
"HttpServletRequest",
"req",
",",
"String",
"path",
")",
"{",
"String",
"suffix",
"=",
"\"\"",
";",
"if",
"(",
"req",
".",
"getRequestURI",
"(",
")",
".",
"endsWith",
"(",
"\".json\"",
")",
")",
"{",
"suffix",
"=",
"\".json\"",
";",
"}",
"else",
"if",
"(",
"req",
".",
"getRequestURI",
"(",
")",
".",
"endsWith",
"(",
"\".xml\"",
")",
")",
"{",
"suffix",
"=",
"\".xml\"",
";",
"}",
"return",
"URI",
".",
"create",
"(",
"uriInfo",
".",
"getBaseUri",
"(",
")",
"+",
"\"/\"",
"+",
"path",
"+",
"suffix",
")",
";",
"}"
] |
Gets a full URI for the given path, based on the request URI.
|
[
"Gets",
"a",
"full",
"URI",
"for",
"the",
"given",
"path",
"based",
"on",
"the",
"request",
"URI",
"."
] |
2d90e2c9c84a827f2605607ff40e116c67eff9b9
|
https://github.com/duraspace/fcrepo-cloudsync/blob/2d90e2c9c84a827f2605607ff40e116c67eff9b9/fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/rest/URIMapper.java#L15-L25
|
145,168
|
duraspace/fcrepo-cloudsync
|
fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/rest/URIMapper.java
|
URIMapper.getId
|
public static String getId(URI uri) {
String s = uri.toString();
return s.substring(s.lastIndexOf("/") + 1);
}
|
java
|
public static String getId(URI uri) {
String s = uri.toString();
return s.substring(s.lastIndexOf("/") + 1);
}
|
[
"public",
"static",
"String",
"getId",
"(",
"URI",
"uri",
")",
"{",
"String",
"s",
"=",
"uri",
".",
"toString",
"(",
")",
";",
"return",
"s",
".",
"substring",
"(",
"s",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
"+",
"1",
")",
";",
"}"
] |
Gets the id for the given task, set, store, user, or taskLog URI.
|
[
"Gets",
"the",
"id",
"for",
"the",
"given",
"task",
"set",
"store",
"user",
"or",
"taskLog",
"URI",
"."
] |
2d90e2c9c84a827f2605607ff40e116c67eff9b9
|
https://github.com/duraspace/fcrepo-cloudsync/blob/2d90e2c9c84a827f2605607ff40e116c67eff9b9/fcrepo-cloudsync-service/src/main/java/org/duraspace/fcrepo/cloudsync/service/rest/URIMapper.java#L30-L33
|
145,169
|
fuinorg/srcgen4j-commons
|
src/main/java/org/fuin/srcgen4j/commons/GeneratorConfig.java
|
GeneratorConfig.addArtifact
|
public final void addArtifact(@NotNull final Artifact artifact) {
Contract.requireArgNotNull("artifact", artifact);
if (artifacts == null) {
artifacts = new ArrayList<>();
}
artifacts.add(artifact);
}
|
java
|
public final void addArtifact(@NotNull final Artifact artifact) {
Contract.requireArgNotNull("artifact", artifact);
if (artifacts == null) {
artifacts = new ArrayList<>();
}
artifacts.add(artifact);
}
|
[
"public",
"final",
"void",
"addArtifact",
"(",
"@",
"NotNull",
"final",
"Artifact",
"artifact",
")",
"{",
"Contract",
".",
"requireArgNotNull",
"(",
"\"artifact\"",
",",
"artifact",
")",
";",
"if",
"(",
"artifacts",
"==",
"null",
")",
"{",
"artifacts",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"artifacts",
".",
"add",
"(",
"artifact",
")",
";",
"}"
] |
Adds a artifact to the list. If the list does not exist it's created.
@param artifact
Artifact to add.
|
[
"Adds",
"a",
"artifact",
"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/GeneratorConfig.java#L169-L175
|
145,170
|
fuinorg/srcgen4j-commons
|
src/main/java/org/fuin/srcgen4j/commons/GeneratorConfig.java
|
GeneratorConfig.getDefProject
|
@Nullable
public final String getDefProject() {
if (getProject() == null) {
if (parent == null) {
return null;
}
return parent.getProject();
}
return getProject();
}
|
java
|
@Nullable
public final String getDefProject() {
if (getProject() == null) {
if (parent == null) {
return null;
}
return parent.getProject();
}
return getProject();
}
|
[
"@",
"Nullable",
"public",
"final",
"String",
"getDefProject",
"(",
")",
"{",
"if",
"(",
"getProject",
"(",
")",
"==",
"null",
")",
"{",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"parent",
".",
"getProject",
"(",
")",
";",
"}",
"return",
"getProject",
"(",
")",
";",
"}"
] |
Returns the defined project from this object or any of it's parents.
@return Project.
|
[
"Returns",
"the",
"defined",
"project",
"from",
"this",
"object",
"or",
"any",
"of",
"it",
"s",
"parents",
"."
] |
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
|
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/GeneratorConfig.java#L222-L231
|
145,171
|
fuinorg/srcgen4j-commons
|
src/main/java/org/fuin/srcgen4j/commons/GeneratorConfig.java
|
GeneratorConfig.getDefFolder
|
@Nullable
public final String getDefFolder() {
if (getFolder() == null) {
if (parent == null) {
return null;
}
return parent.getFolder();
}
return getFolder();
}
|
java
|
@Nullable
public final String getDefFolder() {
if (getFolder() == null) {
if (parent == null) {
return null;
}
return parent.getFolder();
}
return getFolder();
}
|
[
"@",
"Nullable",
"public",
"final",
"String",
"getDefFolder",
"(",
")",
"{",
"if",
"(",
"getFolder",
"(",
")",
"==",
"null",
")",
"{",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"parent",
".",
"getFolder",
"(",
")",
";",
"}",
"return",
"getFolder",
"(",
")",
";",
"}"
] |
Returns the defined folder from this object or any of it's parents.
@return Folder.
|
[
"Returns",
"the",
"defined",
"folder",
"from",
"this",
"object",
"or",
"any",
"of",
"it",
"s",
"parents",
"."
] |
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
|
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/GeneratorConfig.java#L238-L247
|
145,172
|
fuinorg/srcgen4j-commons
|
src/main/java/org/fuin/srcgen4j/commons/GeneratorConfig.java
|
GeneratorConfig.getGenerator
|
@SuppressWarnings("unchecked")
public final Generator<Object> getGenerator() {
if (generator != null) {
return generator;
}
LOG.info("Creating generator: {}", className);
if (className == null) {
throw new IllegalStateException("Class name was not set: " + getName());
}
if (context == null) {
throw new IllegalStateException("Context class loader was not set: " + getName() + " / " + className);
}
final Object obj = Utils4J.createInstance(className, context.getClassLoader());
if (!(obj instanceof Generator<?>)) {
throw new IllegalStateException("Expected class to be of type '" + Generator.class.getName() + "', but was: " + className);
}
generator = (Generator<Object>) obj;
generator.initialize(this);
return generator;
}
|
java
|
@SuppressWarnings("unchecked")
public final Generator<Object> getGenerator() {
if (generator != null) {
return generator;
}
LOG.info("Creating generator: {}", className);
if (className == null) {
throw new IllegalStateException("Class name was not set: " + getName());
}
if (context == null) {
throw new IllegalStateException("Context class loader was not set: " + getName() + " / " + className);
}
final Object obj = Utils4J.createInstance(className, context.getClassLoader());
if (!(obj instanceof Generator<?>)) {
throw new IllegalStateException("Expected class to be of type '" + Generator.class.getName() + "', but was: " + className);
}
generator = (Generator<Object>) obj;
generator.initialize(this);
return generator;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"Generator",
"<",
"Object",
">",
"getGenerator",
"(",
")",
"{",
"if",
"(",
"generator",
"!=",
"null",
")",
"{",
"return",
"generator",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Creating generator: {}\"",
",",
"className",
")",
";",
"if",
"(",
"className",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Class name was not set: \"",
"+",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Context class loader was not set: \"",
"+",
"getName",
"(",
")",
"+",
"\" / \"",
"+",
"className",
")",
";",
"}",
"final",
"Object",
"obj",
"=",
"Utils4J",
".",
"createInstance",
"(",
"className",
",",
"context",
".",
"getClassLoader",
"(",
")",
")",
";",
"if",
"(",
"!",
"(",
"obj",
"instanceof",
"Generator",
"<",
"?",
">",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Expected class to be of type '\"",
"+",
"Generator",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"', but was: \"",
"+",
"className",
")",
";",
"}",
"generator",
"=",
"(",
"Generator",
"<",
"Object",
">",
")",
"obj",
";",
"generator",
".",
"initialize",
"(",
"this",
")",
";",
"return",
"generator",
";",
"}"
] |
Returns an existing generator instance or creates a new one if it's the first call to this method.
@return Generator of type {@link #className}.
|
[
"Returns",
"an",
"existing",
"generator",
"instance",
"or",
"creates",
"a",
"new",
"one",
"if",
"it",
"s",
"the",
"first",
"call",
"to",
"this",
"method",
"."
] |
bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b
|
https://github.com/fuinorg/srcgen4j-commons/blob/bce26fd3167ea91fb2f3ad3fc9a1836d3d9fb14b/src/main/java/org/fuin/srcgen4j/commons/GeneratorConfig.java#L273-L292
|
145,173
|
akberc/ceylon-maven-plugin
|
src/main/java/com/dgwave/car/common/ModuleXmlReader.java
|
ModuleXmlReader.parse
|
protected static Module parse(final File moduleXml) throws Exception {
InputStream is = new FileInputStream(moduleXml);
try {
Document document = parseXml(is);
Element root = document.getDocumentElement();
ModuleIdentifier main = getModuleIdentifier(root);
Module module = new Module(main);
Element dependencies = getChildElement(root, "dependencies");
if (dependencies != null) {
for (Element dependency : getElements(dependencies, "module")) {
module.addDependency(getModuleIdentifier(dependency));
}
}
return module;
} finally {
is.close();
}
}
|
java
|
protected static Module parse(final File moduleXml) throws Exception {
InputStream is = new FileInputStream(moduleXml);
try {
Document document = parseXml(is);
Element root = document.getDocumentElement();
ModuleIdentifier main = getModuleIdentifier(root);
Module module = new Module(main);
Element dependencies = getChildElement(root, "dependencies");
if (dependencies != null) {
for (Element dependency : getElements(dependencies, "module")) {
module.addDependency(getModuleIdentifier(dependency));
}
}
return module;
} finally {
is.close();
}
}
|
[
"protected",
"static",
"Module",
"parse",
"(",
"final",
"File",
"moduleXml",
")",
"throws",
"Exception",
"{",
"InputStream",
"is",
"=",
"new",
"FileInputStream",
"(",
"moduleXml",
")",
";",
"try",
"{",
"Document",
"document",
"=",
"parseXml",
"(",
"is",
")",
";",
"Element",
"root",
"=",
"document",
".",
"getDocumentElement",
"(",
")",
";",
"ModuleIdentifier",
"main",
"=",
"getModuleIdentifier",
"(",
"root",
")",
";",
"Module",
"module",
"=",
"new",
"Module",
"(",
"main",
")",
";",
"Element",
"dependencies",
"=",
"getChildElement",
"(",
"root",
",",
"\"dependencies\"",
")",
";",
"if",
"(",
"dependencies",
"!=",
"null",
")",
"{",
"for",
"(",
"Element",
"dependency",
":",
"getElements",
"(",
"dependencies",
",",
"\"module\"",
")",
")",
"{",
"module",
".",
"addDependency",
"(",
"getModuleIdentifier",
"(",
"dependency",
")",
")",
";",
"}",
"}",
"return",
"module",
";",
"}",
"finally",
"{",
"is",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Parse the module.xml file.
@param moduleXml The file to parse
@return Module representation
@throws Exception In case of parsing error
|
[
"Parse",
"the",
"module",
".",
"xml",
"file",
"."
] |
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
|
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/ModuleXmlReader.java#L38-L55
|
145,174
|
akberc/ceylon-maven-plugin
|
src/main/java/com/dgwave/car/common/ModuleXmlReader.java
|
ModuleXmlReader.getModuleIdentifier
|
protected static ModuleIdentifier getModuleIdentifier(final Element root) {
return new ModuleIdentifier(root.getAttribute("name"), root.getAttribute("slot"),
Boolean.parseBoolean(root.getAttribute("optional")), Boolean.parseBoolean(root.getAttribute("export")));
}
|
java
|
protected static ModuleIdentifier getModuleIdentifier(final Element root) {
return new ModuleIdentifier(root.getAttribute("name"), root.getAttribute("slot"),
Boolean.parseBoolean(root.getAttribute("optional")), Boolean.parseBoolean(root.getAttribute("export")));
}
|
[
"protected",
"static",
"ModuleIdentifier",
"getModuleIdentifier",
"(",
"final",
"Element",
"root",
")",
"{",
"return",
"new",
"ModuleIdentifier",
"(",
"root",
".",
"getAttribute",
"(",
"\"name\"",
")",
",",
"root",
".",
"getAttribute",
"(",
"\"slot\"",
")",
",",
"Boolean",
".",
"parseBoolean",
"(",
"root",
".",
"getAttribute",
"(",
"\"optional\"",
")",
")",
",",
"Boolean",
".",
"parseBoolean",
"(",
"root",
".",
"getAttribute",
"(",
"\"export\"",
")",
")",
")",
";",
"}"
] |
ModuleIdentifier from XML element.
@param root The root element
@return ModuleIdentifier The name/version of the module
|
[
"ModuleIdentifier",
"from",
"XML",
"element",
"."
] |
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
|
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/ModuleXmlReader.java#L62-L65
|
145,175
|
akberc/ceylon-maven-plugin
|
src/main/java/com/dgwave/car/common/ModuleXmlReader.java
|
ModuleXmlReader.parseXml
|
protected static Document parseXml(final InputStream inputStream)
throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputStream);
doc.getDocumentElement().normalize();
return doc;
}
|
java
|
protected static Document parseXml(final InputStream inputStream)
throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputStream);
doc.getDocumentElement().normalize();
return doc;
}
|
[
"protected",
"static",
"Document",
"parseXml",
"(",
"final",
"InputStream",
"inputStream",
")",
"throws",
"ParserConfigurationException",
",",
"SAXException",
",",
"IOException",
"{",
"DocumentBuilderFactory",
"dbFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"DocumentBuilder",
"dBuilder",
"=",
"dbFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"Document",
"doc",
"=",
"dBuilder",
".",
"parse",
"(",
"inputStream",
")",
";",
"doc",
".",
"getDocumentElement",
"(",
")",
".",
"normalize",
"(",
")",
";",
"return",
"doc",
";",
"}"
] |
Parse module.xml from an input stream.
@param inputStream The InputStream to parse
@return Document the parsed DOM
@throws ParserConfigurationException In case of parser mis-configuration
@throws SAXException In case of SAX exception
@throws IOException In case of IO error
|
[
"Parse",
"module",
".",
"xml",
"from",
"an",
"input",
"stream",
"."
] |
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
|
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/ModuleXmlReader.java#L75-L82
|
145,176
|
akberc/ceylon-maven-plugin
|
src/main/java/com/dgwave/car/common/ModuleXmlReader.java
|
ModuleXmlReader.getElements
|
protected static List<Element> getElements(final Element parent, final String tagName) {
List<Element> elements = new ArrayList<Element>();
NodeList nodes = parent.getElementsByTagName(tagName);
for (int i = 0; i < nodes.getLength(); i++) {
org.w3c.dom.Node node = nodes.item(i);
if (node instanceof Element) {
elements.add(Element.class.cast(node));
}
}
return elements;
}
|
java
|
protected static List<Element> getElements(final Element parent, final String tagName) {
List<Element> elements = new ArrayList<Element>();
NodeList nodes = parent.getElementsByTagName(tagName);
for (int i = 0; i < nodes.getLength(); i++) {
org.w3c.dom.Node node = nodes.item(i);
if (node instanceof Element) {
elements.add(Element.class.cast(node));
}
}
return elements;
}
|
[
"protected",
"static",
"List",
"<",
"Element",
">",
"getElements",
"(",
"final",
"Element",
"parent",
",",
"final",
"String",
"tagName",
")",
"{",
"List",
"<",
"Element",
">",
"elements",
"=",
"new",
"ArrayList",
"<",
"Element",
">",
"(",
")",
";",
"NodeList",
"nodes",
"=",
"parent",
".",
"getElementsByTagName",
"(",
"tagName",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"org",
".",
"w3c",
".",
"dom",
".",
"Node",
"node",
"=",
"nodes",
".",
"item",
"(",
"i",
")",
";",
"if",
"(",
"node",
"instanceof",
"Element",
")",
"{",
"elements",
".",
"add",
"(",
"Element",
".",
"class",
".",
"cast",
"(",
"node",
")",
")",
";",
"}",
"}",
"return",
"elements",
";",
"}"
] |
Finds child elements in DOM.
@param parent The Element to find in
@param tagName The element to find
@return List of elements
|
[
"Finds",
"child",
"elements",
"in",
"DOM",
"."
] |
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
|
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/ModuleXmlReader.java#L90-L100
|
145,177
|
akberc/ceylon-maven-plugin
|
src/main/java/com/dgwave/car/common/ModuleXmlReader.java
|
ModuleXmlReader.getChildElement
|
protected static Element getChildElement(final Element parent, final String tagName) {
List<Element> elements = getElements(parent, tagName);
if (elements.size() > 0) {
return elements.get(0);
} else {
return null;
}
}
|
java
|
protected static Element getChildElement(final Element parent, final String tagName) {
List<Element> elements = getElements(parent, tagName);
if (elements.size() > 0) {
return elements.get(0);
} else {
return null;
}
}
|
[
"protected",
"static",
"Element",
"getChildElement",
"(",
"final",
"Element",
"parent",
",",
"final",
"String",
"tagName",
")",
"{",
"List",
"<",
"Element",
">",
"elements",
"=",
"getElements",
"(",
"parent",
",",
"tagName",
")",
";",
"if",
"(",
"elements",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"return",
"elements",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Get a single child element.
@param parent The parent element
@param tagName The child element name
@return Element The first child element by that name
|
[
"Get",
"a",
"single",
"child",
"element",
"."
] |
b7f6c4a2b24f2fa237350c9e715f4193e83415ef
|
https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/ModuleXmlReader.java#L108-L115
|
145,178
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation2DGUI.java
|
ShanksSimulation2DGUI.addTimeChart
|
public void addTimeChart(String chartID, String xAxisLabel,
String yAxisLabel) throws ShanksException {
Scenario2DPortrayal scenarioPortrayal = (Scenario2DPortrayal) this
.getSimulation().getScenarioPortrayal();
scenarioPortrayal.addTimeChart(chartID, xAxisLabel, yAxisLabel);
}
|
java
|
public void addTimeChart(String chartID, String xAxisLabel,
String yAxisLabel) throws ShanksException {
Scenario2DPortrayal scenarioPortrayal = (Scenario2DPortrayal) this
.getSimulation().getScenarioPortrayal();
scenarioPortrayal.addTimeChart(chartID, xAxisLabel, yAxisLabel);
}
|
[
"public",
"void",
"addTimeChart",
"(",
"String",
"chartID",
",",
"String",
"xAxisLabel",
",",
"String",
"yAxisLabel",
")",
"throws",
"ShanksException",
"{",
"Scenario2DPortrayal",
"scenarioPortrayal",
"=",
"(",
"Scenario2DPortrayal",
")",
"this",
".",
"getSimulation",
"(",
")",
".",
"getScenarioPortrayal",
"(",
")",
";",
"scenarioPortrayal",
".",
"addTimeChart",
"(",
"chartID",
",",
"xAxisLabel",
",",
"yAxisLabel",
")",
";",
"}"
] |
Add a time chart to the simulation
@param chartID
@param xAxisLabel
@param yAxisLabel
@throws ShanksException
|
[
"Add",
"a",
"time",
"chart",
"to",
"the",
"simulation"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation2DGUI.java#L356-L361
|
145,179
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation2DGUI.java
|
ShanksSimulation2DGUI.removeTimeChart
|
public void removeTimeChart(String chartID) throws ShanksException {
Scenario2DPortrayal scenarioPortrayal = (Scenario2DPortrayal) this
.getSimulation().getScenarioPortrayal();
scenarioPortrayal.removeTimeChart(chartID);
}
|
java
|
public void removeTimeChart(String chartID) throws ShanksException {
Scenario2DPortrayal scenarioPortrayal = (Scenario2DPortrayal) this
.getSimulation().getScenarioPortrayal();
scenarioPortrayal.removeTimeChart(chartID);
}
|
[
"public",
"void",
"removeTimeChart",
"(",
"String",
"chartID",
")",
"throws",
"ShanksException",
"{",
"Scenario2DPortrayal",
"scenarioPortrayal",
"=",
"(",
"Scenario2DPortrayal",
")",
"this",
".",
"getSimulation",
"(",
")",
".",
"getScenarioPortrayal",
"(",
")",
";",
"scenarioPortrayal",
".",
"removeTimeChart",
"(",
"chartID",
")",
";",
"}"
] |
Remove a time chart to the simulation
@param chartID
@throws ScenarioNotFoundException
@throws DuplicatedPortrayalIDException
|
[
"Remove",
"a",
"time",
"chart",
"to",
"the",
"simulation"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation2DGUI.java#L370-L374
|
145,180
|
gsi-upm/Shanks
|
shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation2DGUI.java
|
ShanksSimulation2DGUI.addHistogram
|
public void addHistogram(String histogramID, String xAxisLabel,
String yAxisLabel) throws ShanksException {
Scenario2DPortrayal scenarioPortrayal = (Scenario2DPortrayal) this
.getSimulation().getScenarioPortrayal();
scenarioPortrayal.addHistogram(histogramID, xAxisLabel, yAxisLabel);
}
|
java
|
public void addHistogram(String histogramID, String xAxisLabel,
String yAxisLabel) throws ShanksException {
Scenario2DPortrayal scenarioPortrayal = (Scenario2DPortrayal) this
.getSimulation().getScenarioPortrayal();
scenarioPortrayal.addHistogram(histogramID, xAxisLabel, yAxisLabel);
}
|
[
"public",
"void",
"addHistogram",
"(",
"String",
"histogramID",
",",
"String",
"xAxisLabel",
",",
"String",
"yAxisLabel",
")",
"throws",
"ShanksException",
"{",
"Scenario2DPortrayal",
"scenarioPortrayal",
"=",
"(",
"Scenario2DPortrayal",
")",
"this",
".",
"getSimulation",
"(",
")",
".",
"getScenarioPortrayal",
"(",
")",
";",
"scenarioPortrayal",
".",
"addHistogram",
"(",
"histogramID",
",",
"xAxisLabel",
",",
"yAxisLabel",
")",
";",
"}"
] |
Add a Histogram to the simulation
@param histogramID
- The name of the Histogram
@param xAxisLabel
- The label for the x axis
@param yAxisLabel
- The label fot the y axis
@throws DuplicatedChartIDException
@throws DuplicatedPortrayalIDException
@throws ScenarioNotFoundException
|
[
"Add",
"a",
"Histogram",
"to",
"the",
"simulation"
] |
35d87a81c22731f4f83bbd0571c9c6d466bd16be
|
https://github.com/gsi-upm/Shanks/blob/35d87a81c22731f4f83bbd0571c9c6d466bd16be/shanks-core/src/main/java/es/upm/dit/gsi/shanks/ShanksSimulation2DGUI.java#L423-L428
|
145,181
|
LevelFourAB/commons
|
commons-serialization/src/main/java/se/l4/commons/serialization/AbstractSerializerCollection.java
|
AbstractSerializerCollection.registerIfNamed
|
protected void registerIfNamed(Class<?> from, Serializer<?> serializer)
{
if(from.isAnnotationPresent(Named.class))
{
Named named = from.getAnnotation(Named.class);
QualifiedName key = new QualifiedName(named.namespace(), named.name());
nameToSerializer.put(key, serializer);
serializerToName.put(serializer, key);
}
}
|
java
|
protected void registerIfNamed(Class<?> from, Serializer<?> serializer)
{
if(from.isAnnotationPresent(Named.class))
{
Named named = from.getAnnotation(Named.class);
QualifiedName key = new QualifiedName(named.namespace(), named.name());
nameToSerializer.put(key, serializer);
serializerToName.put(serializer, key);
}
}
|
[
"protected",
"void",
"registerIfNamed",
"(",
"Class",
"<",
"?",
">",
"from",
",",
"Serializer",
"<",
"?",
">",
"serializer",
")",
"{",
"if",
"(",
"from",
".",
"isAnnotationPresent",
"(",
"Named",
".",
"class",
")",
")",
"{",
"Named",
"named",
"=",
"from",
".",
"getAnnotation",
"(",
"Named",
".",
"class",
")",
";",
"QualifiedName",
"key",
"=",
"new",
"QualifiedName",
"(",
"named",
".",
"namespace",
"(",
")",
",",
"named",
".",
"name",
"(",
")",
")",
";",
"nameToSerializer",
".",
"put",
"(",
"key",
",",
"serializer",
")",
";",
"serializerToName",
".",
"put",
"(",
"serializer",
",",
"key",
")",
";",
"}",
"}"
] |
Register the given serializer if it has a name.
@param from
@param serializer
|
[
"Register",
"the",
"given",
"serializer",
"if",
"it",
"has",
"a",
"name",
"."
] |
aa121b3a5504b43d0c10450a1b984694fcd2b8ee
|
https://github.com/LevelFourAB/commons/blob/aa121b3a5504b43d0c10450a1b984694fcd2b8ee/commons-serialization/src/main/java/se/l4/commons/serialization/AbstractSerializerCollection.java#L248-L257
|
145,182
|
dbracewell/mango
|
src/main/java/com/davidbracewell/parsing/ExpressionIterator.java
|
ExpressionIterator.next
|
public Expression next(int precedence) throws ParseException {
ParserToken token;
Expression result;
do {
token = tokenStream.consume();
if (token == null) {
return null;
}
result = grammar.parse(this, token);
} while (result == null);
//Consume things that will be skipped
while (grammar.skip(tokenStream.lookAhead(0))) {
tokenStream.consume();
}
while (precedence < grammar.precedence(tokenStream.lookAhead(0))) {
token = tokenStream.consume();
result = grammar.parse(this, result, token);
}
return result;
}
|
java
|
public Expression next(int precedence) throws ParseException {
ParserToken token;
Expression result;
do {
token = tokenStream.consume();
if (token == null) {
return null;
}
result = grammar.parse(this, token);
} while (result == null);
//Consume things that will be skipped
while (grammar.skip(tokenStream.lookAhead(0))) {
tokenStream.consume();
}
while (precedence < grammar.precedence(tokenStream.lookAhead(0))) {
token = tokenStream.consume();
result = grammar.parse(this, result, token);
}
return result;
}
|
[
"public",
"Expression",
"next",
"(",
"int",
"precedence",
")",
"throws",
"ParseException",
"{",
"ParserToken",
"token",
";",
"Expression",
"result",
";",
"do",
"{",
"token",
"=",
"tokenStream",
".",
"consume",
"(",
")",
";",
"if",
"(",
"token",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"result",
"=",
"grammar",
".",
"parse",
"(",
"this",
",",
"token",
")",
";",
"}",
"while",
"(",
"result",
"==",
"null",
")",
";",
"//Consume things that will be skipped",
"while",
"(",
"grammar",
".",
"skip",
"(",
"tokenStream",
".",
"lookAhead",
"(",
"0",
")",
")",
")",
"{",
"tokenStream",
".",
"consume",
"(",
")",
";",
"}",
"while",
"(",
"precedence",
"<",
"grammar",
".",
"precedence",
"(",
"tokenStream",
".",
"lookAhead",
"(",
"0",
")",
")",
")",
"{",
"token",
"=",
"tokenStream",
".",
"consume",
"(",
")",
";",
"result",
"=",
"grammar",
".",
"parse",
"(",
"this",
",",
"result",
",",
"token",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Parses the token stream to get the next expression
@param precedence The precedence of the next prefix expression
@return the next expression in the parse
@throws ParseException Something went wrong parsing
|
[
"Parses",
"the",
"token",
"stream",
"to",
"get",
"the",
"next",
"expression"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/parsing/ExpressionIterator.java#L64-L87
|
145,183
|
triceo/splitlog
|
splitlog-core/src/main/java/org/apache/commons/io/input/fork/TailerRun.java
|
TailerRun.readLines
|
private long readLines(final RandomAccessFile reader) throws IOException {
final ByteArrayOutputStream lineBuf = new ByteArrayOutputStream(64);
long pos = reader.getFilePointer();
long rePos = pos; // position to re-read
int num;
boolean seenCR = false;
// FIXME replace -1 with EOF when we're merging back into commons-io
while ((num = reader.read(this.inbuf)) != -1) {
for (int i = 0; i < num; i++) {
final byte ch = this.inbuf[i];
switch (ch) {
case '\n':
seenCR = false; // swallow CR before LF
this.listener.handle(new String(lineBuf.toByteArray(), this.cset));
lineBuf.reset();
rePos = pos + i + 1;
break;
case '\r':
if (seenCR) {
lineBuf.write('\r');
}
seenCR = true;
break;
default:
if (seenCR) {
seenCR = false; // swallow final CR
this.listener.handle(new String(lineBuf.toByteArray(), this.cset));
lineBuf.reset();
rePos = pos + i + 1;
}
lineBuf.write(ch);
}
}
pos = reader.getFilePointer();
}
IOUtils.closeQuietly(lineBuf); // not strictly necessary
reader.seek(rePos); // Ensure we can re-read if necessary
return rePos;
}
|
java
|
private long readLines(final RandomAccessFile reader) throws IOException {
final ByteArrayOutputStream lineBuf = new ByteArrayOutputStream(64);
long pos = reader.getFilePointer();
long rePos = pos; // position to re-read
int num;
boolean seenCR = false;
// FIXME replace -1 with EOF when we're merging back into commons-io
while ((num = reader.read(this.inbuf)) != -1) {
for (int i = 0; i < num; i++) {
final byte ch = this.inbuf[i];
switch (ch) {
case '\n':
seenCR = false; // swallow CR before LF
this.listener.handle(new String(lineBuf.toByteArray(), this.cset));
lineBuf.reset();
rePos = pos + i + 1;
break;
case '\r':
if (seenCR) {
lineBuf.write('\r');
}
seenCR = true;
break;
default:
if (seenCR) {
seenCR = false; // swallow final CR
this.listener.handle(new String(lineBuf.toByteArray(), this.cset));
lineBuf.reset();
rePos = pos + i + 1;
}
lineBuf.write(ch);
}
}
pos = reader.getFilePointer();
}
IOUtils.closeQuietly(lineBuf); // not strictly necessary
reader.seek(rePos); // Ensure we can re-read if necessary
return rePos;
}
|
[
"private",
"long",
"readLines",
"(",
"final",
"RandomAccessFile",
"reader",
")",
"throws",
"IOException",
"{",
"final",
"ByteArrayOutputStream",
"lineBuf",
"=",
"new",
"ByteArrayOutputStream",
"(",
"64",
")",
";",
"long",
"pos",
"=",
"reader",
".",
"getFilePointer",
"(",
")",
";",
"long",
"rePos",
"=",
"pos",
";",
"// position to re-read",
"int",
"num",
";",
"boolean",
"seenCR",
"=",
"false",
";",
"// FIXME replace -1 with EOF when we're merging back into commons-io",
"while",
"(",
"(",
"num",
"=",
"reader",
".",
"read",
"(",
"this",
".",
"inbuf",
")",
")",
"!=",
"-",
"1",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"num",
";",
"i",
"++",
")",
"{",
"final",
"byte",
"ch",
"=",
"this",
".",
"inbuf",
"[",
"i",
"]",
";",
"switch",
"(",
"ch",
")",
"{",
"case",
"'",
"'",
":",
"seenCR",
"=",
"false",
";",
"// swallow CR before LF",
"this",
".",
"listener",
".",
"handle",
"(",
"new",
"String",
"(",
"lineBuf",
".",
"toByteArray",
"(",
")",
",",
"this",
".",
"cset",
")",
")",
";",
"lineBuf",
".",
"reset",
"(",
")",
";",
"rePos",
"=",
"pos",
"+",
"i",
"+",
"1",
";",
"break",
";",
"case",
"'",
"'",
":",
"if",
"(",
"seenCR",
")",
"{",
"lineBuf",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"seenCR",
"=",
"true",
";",
"break",
";",
"default",
":",
"if",
"(",
"seenCR",
")",
"{",
"seenCR",
"=",
"false",
";",
"// swallow final CR",
"this",
".",
"listener",
".",
"handle",
"(",
"new",
"String",
"(",
"lineBuf",
".",
"toByteArray",
"(",
")",
",",
"this",
".",
"cset",
")",
")",
";",
"lineBuf",
".",
"reset",
"(",
")",
";",
"rePos",
"=",
"pos",
"+",
"i",
"+",
"1",
";",
"}",
"lineBuf",
".",
"write",
"(",
"ch",
")",
";",
"}",
"}",
"pos",
"=",
"reader",
".",
"getFilePointer",
"(",
")",
";",
"}",
"IOUtils",
".",
"closeQuietly",
"(",
"lineBuf",
")",
";",
"// not strictly necessary",
"reader",
".",
"seek",
"(",
"rePos",
")",
";",
"// Ensure we can re-read if necessary",
"return",
"rePos",
";",
"}"
] |
Read new lines.
@param reader
The file to read
@return The new position after the lines have been read
@throws java.io.IOException
if an I/O error occurs.
|
[
"Read",
"new",
"lines",
"."
] |
4e1b188e8c814119f5cf7343bbc53917843d68a2
|
https://github.com/triceo/splitlog/blob/4e1b188e8c814119f5cf7343bbc53917843d68a2/splitlog-core/src/main/java/org/apache/commons/io/input/fork/TailerRun.java#L97-L135
|
145,184
|
fnklabs/draenei
|
src/main/java/com/fnklabs/draenei/orm/EntityMetadata.java
|
EntityMetadata.getFieldMetaData
|
List<ColumnMetadata> getFieldMetaData() {
return columnsMetadata.entrySet()
.stream()
.map(entry -> entry.getValue())
.collect(Collectors.toList());
}
|
java
|
List<ColumnMetadata> getFieldMetaData() {
return columnsMetadata.entrySet()
.stream()
.map(entry -> entry.getValue())
.collect(Collectors.toList());
}
|
[
"List",
"<",
"ColumnMetadata",
">",
"getFieldMetaData",
"(",
")",
"{",
"return",
"columnsMetadata",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"entry",
"->",
"entry",
".",
"getValue",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
Get field metadata
@return
|
[
"Get",
"field",
"metadata"
] |
0a8cac54f1f635be3e2950375a23291d38453ae8
|
https://github.com/fnklabs/draenei/blob/0a8cac54f1f635be3e2950375a23291d38453ae8/src/main/java/com/fnklabs/draenei/orm/EntityMetadata.java#L140-L145
|
145,185
|
wcm-io-caravan/caravan-hal
|
docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java
|
GenerateHalDocsJsonMojo.getServiceIdFromMavenBundlePlugin
|
private String getServiceIdFromMavenBundlePlugin() {
Plugin bundlePlugin = project.getBuildPlugins().stream()
.filter(plugin -> StringUtils.equals(plugin.getKey(), MAVEN_BUNDLE_PLUGIN_ID))
.findFirst().orElse(null);
if (bundlePlugin != null) {
Xpp3Dom configuration = (Xpp3Dom)bundlePlugin.getConfiguration();
if (configuration != null) {
Xpp3Dom instructions = configuration.getChild("instructions");
if (instructions != null) {
Xpp3Dom applicationPath = instructions.getChild(ApplicationPath.HEADER_APPLICATON_PATH);
if (applicationPath != null) {
return applicationPath.getValue();
}
}
}
}
return null;
}
|
java
|
private String getServiceIdFromMavenBundlePlugin() {
Plugin bundlePlugin = project.getBuildPlugins().stream()
.filter(plugin -> StringUtils.equals(plugin.getKey(), MAVEN_BUNDLE_PLUGIN_ID))
.findFirst().orElse(null);
if (bundlePlugin != null) {
Xpp3Dom configuration = (Xpp3Dom)bundlePlugin.getConfiguration();
if (configuration != null) {
Xpp3Dom instructions = configuration.getChild("instructions");
if (instructions != null) {
Xpp3Dom applicationPath = instructions.getChild(ApplicationPath.HEADER_APPLICATON_PATH);
if (applicationPath != null) {
return applicationPath.getValue();
}
}
}
}
return null;
}
|
[
"private",
"String",
"getServiceIdFromMavenBundlePlugin",
"(",
")",
"{",
"Plugin",
"bundlePlugin",
"=",
"project",
".",
"getBuildPlugins",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"plugin",
"->",
"StringUtils",
".",
"equals",
"(",
"plugin",
".",
"getKey",
"(",
")",
",",
"MAVEN_BUNDLE_PLUGIN_ID",
")",
")",
".",
"findFirst",
"(",
")",
".",
"orElse",
"(",
"null",
")",
";",
"if",
"(",
"bundlePlugin",
"!=",
"null",
")",
"{",
"Xpp3Dom",
"configuration",
"=",
"(",
"Xpp3Dom",
")",
"bundlePlugin",
".",
"getConfiguration",
"(",
")",
";",
"if",
"(",
"configuration",
"!=",
"null",
")",
"{",
"Xpp3Dom",
"instructions",
"=",
"configuration",
".",
"getChild",
"(",
"\"instructions\"",
")",
";",
"if",
"(",
"instructions",
"!=",
"null",
")",
"{",
"Xpp3Dom",
"applicationPath",
"=",
"instructions",
".",
"getChild",
"(",
"ApplicationPath",
".",
"HEADER_APPLICATON_PATH",
")",
";",
"if",
"(",
"applicationPath",
"!=",
"null",
")",
"{",
"return",
"applicationPath",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Tries to detect the service id automatically from maven bundle plugin definition in same POM.
@return Service id or null
|
[
"Tries",
"to",
"detect",
"the",
"service",
"id",
"automatically",
"from",
"maven",
"bundle",
"plugin",
"definition",
"in",
"same",
"POM",
"."
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java#L135-L152
|
145,186
|
wcm-io-caravan/caravan-hal
|
docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java
|
GenerateHalDocsJsonMojo.getServiceInfos
|
private Service getServiceInfos(ClassLoader compileClassLoader) {
Service service = new Service();
// get some service properties from pom
service.setServiceId(serviceId);
service.setName(project.getName());
// find @ServiceDoc annotated class in source folder
JavaProjectBuilder builder = new JavaProjectBuilder();
builder.addSourceTree(new File(source));
JavaClass serviceInfo = builder.getSources().stream()
.flatMap(javaSource -> javaSource.getClasses().stream())
.filter(javaClass -> hasAnnotation(javaClass, ServiceDoc.class))
.findFirst().orElse(null);
// populate further service information from @ServiceDoc class and @LinkRelationDoc fields
if (serviceInfo != null) {
service.setDescriptionMarkup(serviceInfo.getComment());
serviceInfo.getFields().stream()
.filter(field -> hasAnnotation(field, LinkRelationDoc.class))
.map(field -> toLinkRelation(serviceInfo, field, compileClassLoader))
.forEach(service::addLinkRelation);
}
// resolve link relations
service.resolve();
return service;
}
|
java
|
private Service getServiceInfos(ClassLoader compileClassLoader) {
Service service = new Service();
// get some service properties from pom
service.setServiceId(serviceId);
service.setName(project.getName());
// find @ServiceDoc annotated class in source folder
JavaProjectBuilder builder = new JavaProjectBuilder();
builder.addSourceTree(new File(source));
JavaClass serviceInfo = builder.getSources().stream()
.flatMap(javaSource -> javaSource.getClasses().stream())
.filter(javaClass -> hasAnnotation(javaClass, ServiceDoc.class))
.findFirst().orElse(null);
// populate further service information from @ServiceDoc class and @LinkRelationDoc fields
if (serviceInfo != null) {
service.setDescriptionMarkup(serviceInfo.getComment());
serviceInfo.getFields().stream()
.filter(field -> hasAnnotation(field, LinkRelationDoc.class))
.map(field -> toLinkRelation(serviceInfo, field, compileClassLoader))
.forEach(service::addLinkRelation);
}
// resolve link relations
service.resolve();
return service;
}
|
[
"private",
"Service",
"getServiceInfos",
"(",
"ClassLoader",
"compileClassLoader",
")",
"{",
"Service",
"service",
"=",
"new",
"Service",
"(",
")",
";",
"// get some service properties from pom",
"service",
".",
"setServiceId",
"(",
"serviceId",
")",
";",
"service",
".",
"setName",
"(",
"project",
".",
"getName",
"(",
")",
")",
";",
"// find @ServiceDoc annotated class in source folder",
"JavaProjectBuilder",
"builder",
"=",
"new",
"JavaProjectBuilder",
"(",
")",
";",
"builder",
".",
"addSourceTree",
"(",
"new",
"File",
"(",
"source",
")",
")",
";",
"JavaClass",
"serviceInfo",
"=",
"builder",
".",
"getSources",
"(",
")",
".",
"stream",
"(",
")",
".",
"flatMap",
"(",
"javaSource",
"->",
"javaSource",
".",
"getClasses",
"(",
")",
".",
"stream",
"(",
")",
")",
".",
"filter",
"(",
"javaClass",
"->",
"hasAnnotation",
"(",
"javaClass",
",",
"ServiceDoc",
".",
"class",
")",
")",
".",
"findFirst",
"(",
")",
".",
"orElse",
"(",
"null",
")",
";",
"// populate further service information from @ServiceDoc class and @LinkRelationDoc fields",
"if",
"(",
"serviceInfo",
"!=",
"null",
")",
"{",
"service",
".",
"setDescriptionMarkup",
"(",
"serviceInfo",
".",
"getComment",
"(",
")",
")",
";",
"serviceInfo",
".",
"getFields",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"field",
"->",
"hasAnnotation",
"(",
"field",
",",
"LinkRelationDoc",
".",
"class",
")",
")",
".",
"map",
"(",
"field",
"->",
"toLinkRelation",
"(",
"serviceInfo",
",",
"field",
",",
"compileClassLoader",
")",
")",
".",
"forEach",
"(",
"service",
"::",
"addLinkRelation",
")",
";",
"}",
"// resolve link relations",
"service",
".",
"resolve",
"(",
")",
";",
"return",
"service",
";",
"}"
] |
Get service infos from current maven project.
@return Service
|
[
"Get",
"service",
"infos",
"from",
"current",
"maven",
"project",
"."
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java#L158-L187
|
145,187
|
wcm-io-caravan/caravan-hal
|
docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java
|
GenerateHalDocsJsonMojo.buildJsonSchemaRefForModel
|
private String buildJsonSchemaRefForModel(Class<?> modelClass, File artifactFile) {
try {
ZipFile zipFile = new ZipFile(artifactFile);
String halDocsDomainPath = getHalDocsDomainPath(zipFile);
if (halDocsDomainPath != null && hasJsonSchemaFile(zipFile, modelClass)) {
return JsonSchemaBundleTracker.SCHEMA_URI_PREFIX + halDocsDomainPath
+ "/" + modelClass.getName() + ".json";
}
return null;
}
catch (IOException ex) {
throw new RuntimeException("Unable to read artifact file: " + artifactFile.getAbsolutePath() + "\n" + ex.getMessage(), ex);
}
}
|
java
|
private String buildJsonSchemaRefForModel(Class<?> modelClass, File artifactFile) {
try {
ZipFile zipFile = new ZipFile(artifactFile);
String halDocsDomainPath = getHalDocsDomainPath(zipFile);
if (halDocsDomainPath != null && hasJsonSchemaFile(zipFile, modelClass)) {
return JsonSchemaBundleTracker.SCHEMA_URI_PREFIX + halDocsDomainPath
+ "/" + modelClass.getName() + ".json";
}
return null;
}
catch (IOException ex) {
throw new RuntimeException("Unable to read artifact file: " + artifactFile.getAbsolutePath() + "\n" + ex.getMessage(), ex);
}
}
|
[
"private",
"String",
"buildJsonSchemaRefForModel",
"(",
"Class",
"<",
"?",
">",
"modelClass",
",",
"File",
"artifactFile",
")",
"{",
"try",
"{",
"ZipFile",
"zipFile",
"=",
"new",
"ZipFile",
"(",
"artifactFile",
")",
";",
"String",
"halDocsDomainPath",
"=",
"getHalDocsDomainPath",
"(",
"zipFile",
")",
";",
"if",
"(",
"halDocsDomainPath",
"!=",
"null",
"&&",
"hasJsonSchemaFile",
"(",
"zipFile",
",",
"modelClass",
")",
")",
"{",
"return",
"JsonSchemaBundleTracker",
".",
"SCHEMA_URI_PREFIX",
"+",
"halDocsDomainPath",
"+",
"\"/\"",
"+",
"modelClass",
".",
"getName",
"(",
")",
"+",
"\".json\"",
";",
"}",
"return",
"null",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to read artifact file: \"",
"+",
"artifactFile",
".",
"getAbsolutePath",
"(",
")",
"+",
"\"\\n\"",
"+",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"}"
] |
Check if JAR file has a doc domain path and corresponding schema file and then builds a documenation path for it.
@param modelClass Model calss
@param artifactFile JAR artifact's file
@return JSON schema path or null
|
[
"Check",
"if",
"JAR",
"file",
"has",
"a",
"doc",
"domain",
"path",
"and",
"corresponding",
"schema",
"file",
"and",
"then",
"builds",
"a",
"documenation",
"path",
"for",
"it",
"."
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java#L266-L279
|
145,188
|
wcm-io-caravan/caravan-hal
|
docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java
|
GenerateHalDocsJsonMojo.hasAnnotation
|
private boolean hasAnnotation(JavaAnnotatedElement clazz, Class<? extends Annotation> annotationClazz) {
return clazz.getAnnotations().stream()
.filter(item -> item.getType().isA(annotationClazz.getName()))
.count() > 0;
}
|
java
|
private boolean hasAnnotation(JavaAnnotatedElement clazz, Class<? extends Annotation> annotationClazz) {
return clazz.getAnnotations().stream()
.filter(item -> item.getType().isA(annotationClazz.getName()))
.count() > 0;
}
|
[
"private",
"boolean",
"hasAnnotation",
"(",
"JavaAnnotatedElement",
"clazz",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClazz",
")",
"{",
"return",
"clazz",
".",
"getAnnotations",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"item",
"->",
"item",
".",
"getType",
"(",
")",
".",
"isA",
"(",
"annotationClazz",
".",
"getName",
"(",
")",
")",
")",
".",
"count",
"(",
")",
">",
"0",
";",
"}"
] |
Checks if the given element has an annotation set.
@param clazz QDox class
@param annotationClazz Annotation class
@return true if annotation is present
|
[
"Checks",
"if",
"the",
"given",
"element",
"has",
"an",
"annotation",
"set",
"."
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java#L315-L319
|
145,189
|
wcm-io-caravan/caravan-hal
|
docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java
|
GenerateHalDocsJsonMojo.getStaticFieldValue
|
@SuppressWarnings("unchecked")
private <T> T getStaticFieldValue(JavaClass javaClazz, JavaField javaField, ClassLoader compileClassLoader, Class<T> fieldType) {
try {
Class<?> clazz = compileClassLoader.loadClass(javaClazz.getFullyQualifiedName());
Field field = clazz.getField(javaField.getName());
return (T)field.get(fieldType);
}
catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
throw new RuntimeException("Unable to get contanst value of field '" + javaClazz.getName() + "#" + javaField.getName() + ":\n" + ex.getMessage(), ex);
}
}
|
java
|
@SuppressWarnings("unchecked")
private <T> T getStaticFieldValue(JavaClass javaClazz, JavaField javaField, ClassLoader compileClassLoader, Class<T> fieldType) {
try {
Class<?> clazz = compileClassLoader.loadClass(javaClazz.getFullyQualifiedName());
Field field = clazz.getField(javaField.getName());
return (T)field.get(fieldType);
}
catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
throw new RuntimeException("Unable to get contanst value of field '" + javaClazz.getName() + "#" + javaField.getName() + ":\n" + ex.getMessage(), ex);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
">",
"T",
"getStaticFieldValue",
"(",
"JavaClass",
"javaClazz",
",",
"JavaField",
"javaField",
",",
"ClassLoader",
"compileClassLoader",
",",
"Class",
"<",
"T",
">",
"fieldType",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"compileClassLoader",
".",
"loadClass",
"(",
"javaClazz",
".",
"getFullyQualifiedName",
"(",
")",
")",
";",
"Field",
"field",
"=",
"clazz",
".",
"getField",
"(",
"javaField",
".",
"getName",
"(",
")",
")",
";",
"return",
"(",
"T",
")",
"field",
".",
"get",
"(",
"fieldType",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"|",
"NoSuchFieldException",
"|",
"SecurityException",
"|",
"IllegalArgumentException",
"|",
"IllegalAccessException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to get contanst value of field '\"",
"+",
"javaClazz",
".",
"getName",
"(",
")",
"+",
"\"#\"",
"+",
"javaField",
".",
"getName",
"(",
")",
"+",
"\":\\n\"",
"+",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"}"
] |
Get constant field value.
@param javaClazz QDox class
@param javaField QDox field
@param compileClassLoader Classloader for compile dependencies
@param fieldType Field type
@return Value
|
[
"Get",
"constant",
"field",
"value",
"."
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java#L329-L339
|
145,190
|
wcm-io-caravan/caravan-hal
|
docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java
|
GenerateHalDocsJsonMojo.getAnnotation
|
private <T extends Annotation> T getAnnotation(JavaClass javaClazz, JavaField javaField, ClassLoader compileClassLoader, Class<T> annotationType) {
try {
Class<?> clazz = compileClassLoader.loadClass(javaClazz.getFullyQualifiedName());
Field field = clazz.getField(javaField.getName());
return field.getAnnotation(annotationType);
}
catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException ex) {
throw new RuntimeException("Unable to get contanst value of field '" + javaClazz.getName() + "#" + javaField.getName() + ":\n" + ex.getMessage(), ex);
}
}
|
java
|
private <T extends Annotation> T getAnnotation(JavaClass javaClazz, JavaField javaField, ClassLoader compileClassLoader, Class<T> annotationType) {
try {
Class<?> clazz = compileClassLoader.loadClass(javaClazz.getFullyQualifiedName());
Field field = clazz.getField(javaField.getName());
return field.getAnnotation(annotationType);
}
catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException ex) {
throw new RuntimeException("Unable to get contanst value of field '" + javaClazz.getName() + "#" + javaField.getName() + ":\n" + ex.getMessage(), ex);
}
}
|
[
"private",
"<",
"T",
"extends",
"Annotation",
">",
"T",
"getAnnotation",
"(",
"JavaClass",
"javaClazz",
",",
"JavaField",
"javaField",
",",
"ClassLoader",
"compileClassLoader",
",",
"Class",
"<",
"T",
">",
"annotationType",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"compileClassLoader",
".",
"loadClass",
"(",
"javaClazz",
".",
"getFullyQualifiedName",
"(",
")",
")",
";",
"Field",
"field",
"=",
"clazz",
".",
"getField",
"(",
"javaField",
".",
"getName",
"(",
")",
")",
";",
"return",
"field",
".",
"getAnnotation",
"(",
"annotationType",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"|",
"NoSuchFieldException",
"|",
"SecurityException",
"|",
"IllegalArgumentException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to get contanst value of field '\"",
"+",
"javaClazz",
".",
"getName",
"(",
")",
"+",
"\"#\"",
"+",
"javaField",
".",
"getName",
"(",
")",
"+",
"\":\\n\"",
"+",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"}"
] |
Get annotation for field.
@param javaClazz QDox class
@param javaField QDox field
@param compileClassLoader Classloader for compile dependencies
@param annotationType Annotation type
@return Annotation of null if not present
|
[
"Get",
"annotation",
"for",
"field",
"."
] |
25d58756b58c70c8c48a17fe781e673dd93d5085
|
https://github.com/wcm-io-caravan/caravan-hal/blob/25d58756b58c70c8c48a17fe781e673dd93d5085/docs-maven-plugin/src/main/java/io/wcm/caravan/maven/plugins/haldocs/GenerateHalDocsJsonMojo.java#L349-L358
|
145,191
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheManager.java
|
CacheManager.getGlobalCache
|
@SuppressWarnings("unchecked")
public static <K, V> Cache<K, V> getGlobalCache() {
if (caches.containsKey(GLOBAL_CACHE)) {
return Cast.as(caches.get(GLOBAL_CACHE));
}
return register(getCacheSpec(GLOBAL_CACHE));
}
|
java
|
@SuppressWarnings("unchecked")
public static <K, V> Cache<K, V> getGlobalCache() {
if (caches.containsKey(GLOBAL_CACHE)) {
return Cast.as(caches.get(GLOBAL_CACHE));
}
return register(getCacheSpec(GLOBAL_CACHE));
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"Cache",
"<",
"K",
",",
"V",
">",
"getGlobalCache",
"(",
")",
"{",
"if",
"(",
"caches",
".",
"containsKey",
"(",
"GLOBAL_CACHE",
")",
")",
"{",
"return",
"Cast",
".",
"as",
"(",
"caches",
".",
"get",
"(",
"GLOBAL_CACHE",
")",
")",
";",
"}",
"return",
"register",
"(",
"getCacheSpec",
"(",
"GLOBAL_CACHE",
")",
")",
";",
"}"
] |
Gets global cache.
@return The global cache
|
[
"Gets",
"global",
"cache",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheManager.java#L151-L157
|
145,192
|
CubeEngine/LogScribe
|
core/src/main/java/org/cubeengine/logscribe/Filterable.java
|
Filterable.log
|
public void log(final LogEntry entry)
{
if (entry.getLevel().compareTo(this.level) < 0)
{
return;
}
if (!this.filters.isEmpty())
{
for (LogFilter filter : this.filters)
{
if (!filter.accept(entry))
{
return;
}
}
}
this.publish(entry);
}
|
java
|
public void log(final LogEntry entry)
{
if (entry.getLevel().compareTo(this.level) < 0)
{
return;
}
if (!this.filters.isEmpty())
{
for (LogFilter filter : this.filters)
{
if (!filter.accept(entry))
{
return;
}
}
}
this.publish(entry);
}
|
[
"public",
"void",
"log",
"(",
"final",
"LogEntry",
"entry",
")",
"{",
"if",
"(",
"entry",
".",
"getLevel",
"(",
")",
".",
"compareTo",
"(",
"this",
".",
"level",
")",
"<",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"this",
".",
"filters",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"LogFilter",
"filter",
":",
"this",
".",
"filters",
")",
"{",
"if",
"(",
"!",
"filter",
".",
"accept",
"(",
"entry",
")",
")",
"{",
"return",
";",
"}",
"}",
"}",
"this",
".",
"publish",
"(",
"entry",
")",
";",
"}"
] |
Checks if the LogLevel is higher than the set LogLevel and all registered Filters pass and then publishes the LogEntry
@param entry the logEntry to log
|
[
"Checks",
"if",
"the",
"LogLevel",
"is",
"higher",
"than",
"the",
"set",
"LogLevel",
"and",
"all",
"registered",
"Filters",
"pass",
"and",
"then",
"publishes",
"the",
"LogEntry"
] |
c3a449b82677d1d70c3efe77b68fdaaaf7525295
|
https://github.com/CubeEngine/LogScribe/blob/c3a449b82677d1d70c3efe77b68fdaaaf7525295/core/src/main/java/org/cubeengine/logscribe/Filterable.java#L110-L127
|
145,193
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.from
|
public static <K, V> CacheSpec<K, V> from(String specification) {
return CacheSpec.<K, V>create().fromString(specification);
}
|
java
|
public static <K, V> CacheSpec<K, V> from(String specification) {
return CacheSpec.<K, V>create().fromString(specification);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"CacheSpec",
"<",
"K",
",",
"V",
">",
"from",
"(",
"String",
"specification",
")",
"{",
"return",
"CacheSpec",
".",
"<",
"K",
",",
"V",
">",
"create",
"(",
")",
".",
"fromString",
"(",
"specification",
")",
";",
"}"
] |
From cache spec.
@param <K> the type parameter
@param <V> the type parameter
@param specification the specification
@return the cache spec
|
[
"From",
"cache",
"spec",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L83-L85
|
145,194
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.loadingFunction
|
public CacheSpec<K, V> loadingFunction(Function<K, V> loadingFunction) {
this.cacheFunction = loadingFunction;
return this;
}
|
java
|
public CacheSpec<K, V> loadingFunction(Function<K, V> loadingFunction) {
this.cacheFunction = loadingFunction;
return this;
}
|
[
"public",
"CacheSpec",
"<",
"K",
",",
"V",
">",
"loadingFunction",
"(",
"Function",
"<",
"K",
",",
"V",
">",
"loadingFunction",
")",
"{",
"this",
".",
"cacheFunction",
"=",
"loadingFunction",
";",
"return",
"this",
";",
"}"
] |
Loading function cache spec.
@param loadingFunction the loading function
@return the cache spec
|
[
"Loading",
"function",
"cache",
"spec",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L118-L121
|
145,195
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.getEngine
|
public CacheEngine getEngine() {
if (StringUtils.isNullOrBlank(cacheEngine)) {
return CacheEngines.get("Guava");
}
return CacheEngines.get(cacheEngine);
}
|
java
|
public CacheEngine getEngine() {
if (StringUtils.isNullOrBlank(cacheEngine)) {
return CacheEngines.get("Guava");
}
return CacheEngines.get(cacheEngine);
}
|
[
"public",
"CacheEngine",
"getEngine",
"(",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNullOrBlank",
"(",
"cacheEngine",
")",
")",
"{",
"return",
"CacheEngines",
".",
"get",
"(",
"\"Guava\"",
")",
";",
"}",
"return",
"CacheEngines",
".",
"get",
"(",
"cacheEngine",
")",
";",
"}"
] |
Gets cache type.
@return the cache type
|
[
"Gets",
"cache",
"type",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L128-L133
|
145,196
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.concurrencyLevel
|
public <T extends CacheSpec<K, V>> T concurrencyLevel(int concurrencyLevel) {
checkArgument(concurrencyLevel > 0, "Concurrency Level must be > 0");
this.concurrencyLevel = concurrencyLevel;
return Cast.as(this);
}
|
java
|
public <T extends CacheSpec<K, V>> T concurrencyLevel(int concurrencyLevel) {
checkArgument(concurrencyLevel > 0, "Concurrency Level must be > 0");
this.concurrencyLevel = concurrencyLevel;
return Cast.as(this);
}
|
[
"public",
"<",
"T",
"extends",
"CacheSpec",
"<",
"K",
",",
"V",
">",
">",
"T",
"concurrencyLevel",
"(",
"int",
"concurrencyLevel",
")",
"{",
"checkArgument",
"(",
"concurrencyLevel",
">",
"0",
",",
"\"Concurrency Level must be > 0\"",
")",
";",
"this",
".",
"concurrencyLevel",
"=",
"concurrencyLevel",
";",
"return",
"Cast",
".",
"as",
"(",
"this",
")",
";",
"}"
] |
Concurrency level t.
@param <T> the type parameter
@param concurrencyLevel the concurrency level
@return the t
|
[
"Concurrency",
"level",
"t",
"."
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L235-L239
|
145,197
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.initialCapacity
|
public <T extends CacheSpec<K, V>> T initialCapacity(int initialCapacity) {
checkArgument(initialCapacity > 0, "Capacity must be > 0");
this.initialCapacity = initialCapacity;
return Cast.as(this);
}
|
java
|
public <T extends CacheSpec<K, V>> T initialCapacity(int initialCapacity) {
checkArgument(initialCapacity > 0, "Capacity must be > 0");
this.initialCapacity = initialCapacity;
return Cast.as(this);
}
|
[
"public",
"<",
"T",
"extends",
"CacheSpec",
"<",
"K",
",",
"V",
">",
">",
"T",
"initialCapacity",
"(",
"int",
"initialCapacity",
")",
"{",
"checkArgument",
"(",
"initialCapacity",
">",
"0",
",",
"\"Capacity must be > 0\"",
")",
";",
"this",
".",
"initialCapacity",
"=",
"initialCapacity",
";",
"return",
"Cast",
".",
"as",
"(",
"this",
")",
";",
"}"
] |
Sets the initial capacity
@param <T> the type parameter
@param initialCapacity The initial capacity
@return This Cache spec
|
[
"Sets",
"the",
"initial",
"capacity"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L248-L252
|
145,198
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.weakValues
|
public <T extends CacheSpec<K, V>> T weakValues() {
this.weakValues = true;
return Cast.as(this);
}
|
java
|
public <T extends CacheSpec<K, V>> T weakValues() {
this.weakValues = true;
return Cast.as(this);
}
|
[
"public",
"<",
"T",
"extends",
"CacheSpec",
"<",
"K",
",",
"V",
">",
">",
"T",
"weakValues",
"(",
")",
"{",
"this",
".",
"weakValues",
"=",
"true",
";",
"return",
"Cast",
".",
"as",
"(",
"this",
")",
";",
"}"
] |
Sets to use weak values
@param <T> the type parameter
@return This cache spec
|
[
"Sets",
"to",
"use",
"weak",
"values"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L260-L263
|
145,199
|
dbracewell/mango
|
src/main/java/com/davidbracewell/cache/CacheSpec.java
|
CacheSpec.weakKeys
|
public <T extends CacheSpec<K, V>> T weakKeys() {
this.weakKeys = true;
return Cast.as(this);
}
|
java
|
public <T extends CacheSpec<K, V>> T weakKeys() {
this.weakKeys = true;
return Cast.as(this);
}
|
[
"public",
"<",
"T",
"extends",
"CacheSpec",
"<",
"K",
",",
"V",
">",
">",
"T",
"weakKeys",
"(",
")",
"{",
"this",
".",
"weakKeys",
"=",
"true",
";",
"return",
"Cast",
".",
"as",
"(",
"this",
")",
";",
"}"
] |
Sets to use weak keys
@param <T> the type parameter
@return This cache spec
|
[
"Sets",
"to",
"use",
"weak",
"keys"
] |
2cec08826f1fccd658694dd03abce10fc97618ec
|
https://github.com/dbracewell/mango/blob/2cec08826f1fccd658694dd03abce10fc97618ec/src/main/java/com/davidbracewell/cache/CacheSpec.java#L271-L274
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.