summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/ioutils
diff options
context:
space:
mode:
Diffstat (limited to 'base/src/main/java/bjc/utils/ioutils')
-rw-r--r--base/src/main/java/bjc/utils/ioutils/LevelSplitter.java52
-rw-r--r--base/src/main/java/bjc/utils/ioutils/LineReader.java3
-rw-r--r--base/src/main/java/bjc/utils/ioutils/MirrorDB.java10
-rw-r--r--base/src/main/java/bjc/utils/ioutils/Prompter.java6
-rw-r--r--base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java98
-rw-r--r--base/src/main/java/bjc/utils/ioutils/ReportWriter.java137
-rw-r--r--base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java86
-rw-r--r--base/src/main/java/bjc/utils/ioutils/RuleBasedReaderPragmas.java39
-rw-r--r--base/src/main/java/bjc/utils/ioutils/SimpleProperties.java65
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/Block.java28
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java4
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/BlockReaders.java19
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/BoundBlockReader.java21
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/FilteredBlockReader.java35
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/FlatMappedBlockReader.java14
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/LayeredBlockReader.java10
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/MappedBlockReader.java10
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/PushbackBlockReader.java14
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java32
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java26
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java17
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/TriggeredBlockReader.java4
-rw-r--r--base/src/main/java/bjc/utils/ioutils/properties/Property.java4
-rw-r--r--base/src/main/java/bjc/utils/ioutils/properties/PropertyDB.java2
24 files changed, 399 insertions, 337 deletions
diff --git a/base/src/main/java/bjc/utils/ioutils/LevelSplitter.java b/base/src/main/java/bjc/utils/ioutils/LevelSplitter.java
index e66ac75..735dd3a 100644
--- a/base/src/main/java/bjc/utils/ioutils/LevelSplitter.java
+++ b/base/src/main/java/bjc/utils/ioutils/LevelSplitter.java
@@ -7,10 +7,10 @@ import java.util.regex.Pattern;
/**
* Splits a string on a delimiter, respecting grouping delimiters.
- *
+ *
* By default, grouping delimiters are (), [], {}, and <>, as well as single and
* double quoted strings.
- *
+ *
* @author bjculkin
*
*/
@@ -23,13 +23,12 @@ public class LevelSplitter {
/**
* Check if a string contains any one of a specified number of things,
* respecting groups.
- *
+ *
* @param haystack
- * The string to look in.
+ * The string to look in.
* @param needles
- * The strings to look for.
- * @return Whether or not any of the strings were contained outside of
- * groups.
+ * The strings to look for.
+ * @return Whether or not any of the strings were contained outside of groups.
*/
public boolean levelContains(String haystack, String... needles) {
int nestLevel = 0;
@@ -43,7 +42,9 @@ public class LevelSplitter {
while (i < haystack.length()) {
if (inString == false && nestLevel == 0) {
for (String needle : needles) {
- if (haystack.regionMatches(i, needle, 0, needle.length())) { return true; }
+ if (haystack.regionMatches(i, needle, 0, needle.length())) {
+ return true;
+ }
}
}
@@ -86,13 +87,13 @@ public class LevelSplitter {
/**
* Split a string, respecting groups.
- *
+ *
* @param phrase
- * The string to split.
+ * The string to split.
* @param splits
- * The strings to split on.
- * @return A list of split strings. If keepDelims is true, it also
- * includes the delimiters in between the split strings.
+ * The strings to split on.
+ * @return A list of split strings. If keepDelims is true, it also includes the
+ * delimiters in between the split strings.
*/
public List<String> levelSplit(String phrase, String... splits) {
return levelSplit(phrase, false, splits);
@@ -100,16 +101,15 @@ public class LevelSplitter {
/**
* Split a string, respecting groups.
- *
+ *
* @param phrase
- * The string to split.
+ * The string to split.
* @param keepDelims
- * Whether or not to include the delimiters in the
- * results.
+ * Whether or not to include the delimiters in the results.
* @param splits
- * The strings to split on.
- * @return A list of split strings. If keepDelims is true, it also
- * includes the delimiters in between the split strings.
+ * The strings to split on.
+ * @return A list of split strings. If keepDelims is true, it also includes the
+ * delimiters in between the split strings.
*/
public List<String> levelSplit(String phrase, boolean keepDelims, String... splits) {
String work = phrase;
@@ -137,7 +137,8 @@ public class LevelSplitter {
if (work.regionMatches(i, split, 0, split.length())) {
strangs.add(work.substring(0, i));
- if (keepDelims) strangs.add(split);
+ if (keepDelims)
+ strangs.add(split);
work = work.substring(i + split.length());
i = 0;
@@ -157,8 +158,8 @@ public class LevelSplitter {
/*
* @TODO Ben Culkin 9/4/18
*
- * This currently crashes if the string ends
- * with one of the delimiters in question.
+ * This currently crashes if the string ends with one of the delimiters in
+ * question.
*/
switch (work.charAt(i)) {
case '\'':
@@ -226,9 +227,10 @@ public class LevelSplitter {
if (mat.lookingAt()) {
strangs.add(phrase.substring(lastMatch, mat.start()));
- if (keepDelims) strangs.add(mat.group());
+ if (keepDelims)
+ strangs.add(mat.group());
lastMatch = mat.end();
- //work = work.substring(mat.end());
+ // work = work.substring(mat.end());
// i = 0;
// mat = pat.matcher(work);
diff --git a/base/src/main/java/bjc/utils/ioutils/LineReader.java b/base/src/main/java/bjc/utils/ioutils/LineReader.java
index 7449670..9a5167d 100644
--- a/base/src/main/java/bjc/utils/ioutils/LineReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/LineReader.java
@@ -4,6 +4,7 @@ import java.util.Scanner;
/**
* A line reader
+ *
* @author bjculkin
*
*/
@@ -14,6 +15,6 @@ public class LineReader implements AutoCloseable {
public void close() {
scn.close();
}
-
+
// @TODO Implement me - ben, 1/6/20
}
diff --git a/base/src/main/java/bjc/utils/ioutils/MirrorDB.java b/base/src/main/java/bjc/utils/ioutils/MirrorDB.java
index 1010fd6..6518d56 100644
--- a/base/src/main/java/bjc/utils/ioutils/MirrorDB.java
+++ b/base/src/main/java/bjc/utils/ioutils/MirrorDB.java
@@ -13,7 +13,7 @@ import java.util.Scanner;
/**
* A database for describing mirrored characters.
- *
+ *
* @author bjculkin
*
*/
@@ -57,9 +57,9 @@ public class MirrorDB {
/**
* Check if a string can be mirrored.
- *
+ *
* @param mir
- * The string to check for mirroring.
+ * The string to check for mirroring.
* @return Whether or not the given string can be mirrored.
*/
public boolean canMirror(String mir) {
@@ -68,9 +68,9 @@ public class MirrorDB {
/**
* Mirror a string.
- *
+ *
* @param mir
- * The string to mirror.
+ * The string to mirror.
* @return The mirrored version of the string.
*/
public String mirror(String mir) {
diff --git a/base/src/main/java/bjc/utils/ioutils/Prompter.java b/base/src/main/java/bjc/utils/ioutils/Prompter.java
index f39020d..352e55b 100644
--- a/base/src/main/java/bjc/utils/ioutils/Prompter.java
+++ b/base/src/main/java/bjc/utils/ioutils/Prompter.java
@@ -19,10 +19,10 @@ public final class Prompter implements Runnable {
* Create a new prompter using the specified prompt.
*
* @param prompt
- * The prompt to present.
+ * The prompt to present.
*
* @param output
- * The stream to print the prompt on.
+ * The stream to print the prompt on.
*/
public Prompter(final String prompt, final PrintStream output) {
promt = prompt;
@@ -34,7 +34,7 @@ public final class Prompter implements Runnable {
* Set the prompt this prompter uses.
*
* @param prompt
- * The prompt this prompter uses.
+ * The prompt this prompter uses.
*/
public void setPrompt(final String prompt) {
promt = prompt;
diff --git a/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java b/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java
index 83672e6..3dad724 100644
--- a/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java
+++ b/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java
@@ -21,39 +21,40 @@ public class RegexStringEditor {
private static final UnaryOperator<String> SID = ID.id();
/**
- * Replace every occurrence of the pattern with the result of applying
- * the action to the string matched by the pattern.
+ * Replace every occurrence of the pattern with the result of applying the
+ * action to the string matched by the pattern.
*
* @param input
- * The input string to process.
+ * The input string to process.
*
* @param patt
- * The pattern to match the string against.
+ * The pattern to match the string against.
*
* @param action
- * The action to transform matches with.
+ * The action to transform matches with.
*
* @return The string, with matches replaced with the action.
*/
- public static String onOccurances(final String input, final Pattern patt, final UnaryOperator<String> action) {
+ public static String onOccurances(final String input, final Pattern patt,
+ final UnaryOperator<String> action) {
return reduceOccurances(input, patt, SID, action);
}
/**
- * Replace every occurrence between the patterns with the result of
- * applying the action to the strings between the patterns.
+ * Replace every occurrence between the patterns with the result of applying the
+ * action to the strings between the patterns.
*
* @param input
- * The input string to process.
+ * The input string to process.
*
* @param patt
- * The pattern to match the string against.
+ * The pattern to match the string against.
*
* @param action
- * The action to transform matches with.
+ * The action to transform matches with.
*
- * @return The string, with strings between the matches replaced with
- * the action.
+ * @return The string, with strings between the matches replaced with the
+ * action.
*/
public static String betweenOccurances(final String input, final Pattern patt,
final UnaryOperator<String> action) {
@@ -64,21 +65,22 @@ public class RegexStringEditor {
* Execute actions between and on matches of a regular expression.
*
* @param input
- * The input string.
+ * The input string.
*
* @param rPatt
- * The pattern to match against the string.
+ * The pattern to match against the string.
*
* @param betweenAction
- * The function to execute between matches of the string.
+ * The function to execute between matches of the string.
*
* @param onAction
- * The function to execute on matches of the string.
+ * The function to execute on matches of the string.
*
* @return The string, with both actions applied.
*/
public static String reduceOccurances(final String input, final Pattern rPatt,
- final UnaryOperator<String> betweenAction, final UnaryOperator<String> onAction) {
+ final UnaryOperator<String> betweenAction,
+ final UnaryOperator<String> onAction) {
/*
* Get all of the occurances.
*/
@@ -87,36 +89,38 @@ public class RegexStringEditor {
/*
* Execute the correct action on every occurance.
*/
- final Toggle<UnaryOperator<String>> actions = new ValueToggle<>(onAction, betweenAction);
- final BiFunction<String, StringBuilder, StringBuilder> reducer = (strang, state) -> {
- return state.append(actions.get().apply(strang));
- };
+ final Toggle<UnaryOperator<String>> actions
+ = new ValueToggle<>(onAction, betweenAction);
+ final BiFunction<String, StringBuilder, StringBuilder> reducer
+ = (strang, state) -> state.append(actions.get().apply(strang));
/*
* Convert the list back to a string.
*/
- return occurances.reduceAux(new StringBuilder(), reducer, StringBuilder::toString);
+ return occurances.reduceAux(new StringBuilder(), reducer,
+ StringBuilder::toString);
}
/**
* Execute actions between and on matches of a regular expression.
*
* @param input
- * The input string.
+ * The input string.
*
* @param rPatt
- * The pattern to match against the string.
+ * The pattern to match against the string.
*
* @param betweenAction
- * The function to execute between matches of the string.
+ * The function to execute between matches of the string.
*
* @param onAction
- * The function to execute on matches of the string.
+ * The function to execute on matches of the string.
*
* @return The string, with both actions applied.
*/
public static IList<String> mapOccurances(final String input, final Pattern rPatt,
- final UnaryOperator<String> betweenAction, final UnaryOperator<String> onAction) {
+ final UnaryOperator<String> betweenAction,
+ final UnaryOperator<String> onAction) {
/*
* Get all of the occurances.
*/
@@ -125,7 +129,8 @@ public class RegexStringEditor {
/*
* Execute the correct action on every occurance.
*/
- final Toggle<UnaryOperator<String>> actions = new ValueToggle<>(onAction, betweenAction);
+ final Toggle<UnaryOperator<String>> actions
+ = new ValueToggle<>(onAction, betweenAction);
return occurances.map(strang -> actions.get().apply(strang));
}
@@ -133,13 +138,13 @@ public class RegexStringEditor {
* Separate a string into match/non-match segments.
*
* @param input
- * The string to separate.
+ * The string to separate.
*
* @param rPatt
- * The pattern to use for separation.
+ * The pattern to use for separation.
*
- * @return The string, as a list of match/non-match segments,
- * starting/ending with a non-match segment.
+ * @return The string, as a list of match/non-match segments, starting/ending
+ * with a non-match segment.
*/
public static IList<String> listOccurances(final String input, final Pattern rPatt) {
final IList<String> res = new FunctionalList<>();
@@ -153,7 +158,7 @@ public class RegexStringEditor {
/*
* For every match.
*/
- while(matcher.find()) {
+ while (matcher.find()) {
final String match = matcher.group();
/*
@@ -183,20 +188,21 @@ public class RegexStringEditor {
* Apply an operation to a string if it matches a regular expression.
*
* @param input
- * The input string.
+ * The input string.
*
* @param patt
- * The pattern to match against it.
+ * The pattern to match against it.
*
* @param action
- * The action to execute if it matches.
+ * The action to execute if it matches.
*
* @return The string, modified by the action if the pattern matched.
*/
- public static String ifMatches(final String input, final Pattern patt, final UnaryOperator<String> action) {
+ public static String ifMatches(final String input, final Pattern patt,
+ final UnaryOperator<String> action) {
final Matcher matcher = patt.matcher(input);
- if(matcher.matches()) {
+ if (matcher.matches()) {
return action.apply(input);
}
@@ -207,21 +213,21 @@ public class RegexStringEditor {
* Apply an operation to a string if it doesn't match a regular expression.
*
* @param input
- * The input string.
+ * The input string.
*
* @param patt
- * The pattern to match against it.
+ * The pattern to match against it.
*
* @param action
- * The action to execute if it doesn't match.
+ * The action to execute if it doesn't match.
*
- * @return The string, modified by the action if the pattern didn't
- * match.
+ * @return The string, modified by the action if the pattern didn't match.
*/
- public static String ifNotMatches(final String input, final Pattern patt, final UnaryOperator<String> action) {
+ public static String ifNotMatches(final String input, final Pattern patt,
+ final UnaryOperator<String> action) {
final Matcher matcher = patt.matcher(input);
- if(matcher.matches()) {
+ if (matcher.matches()) {
return input;
}
diff --git a/base/src/main/java/bjc/utils/ioutils/ReportWriter.java b/base/src/main/java/bjc/utils/ioutils/ReportWriter.java
index d340ffb..95a7f6d 100644
--- a/base/src/main/java/bjc/utils/ioutils/ReportWriter.java
+++ b/base/src/main/java/bjc/utils/ioutils/ReportWriter.java
@@ -9,7 +9,7 @@ import bjc.esodata.DefaultList;
/**
* A writer with support for some formatting operations, such as autoindentation
* and pagination.
- *
+ *
* @author bjculkin
*
*/
@@ -82,7 +82,7 @@ public class ReportWriter extends Writer {
/**
* Get the current indent level.
- *
+ *
* @return The current indent level.
*/
public int getLevel() {
@@ -91,10 +91,10 @@ public class ReportWriter extends Writer {
/**
* Get the current line-spacing.
- *
- * This is the number of blank lines to print out every time a blank
- * line is encountered in the input, and is set to 1 by default.
- *
+ *
+ * This is the number of blank lines to print out every time a blank line is
+ * encountered in the input, and is set to 1 by default.
+ *
* @return The current line spacing.
*/
public int getLineSpacing() {
@@ -103,7 +103,7 @@ public class ReportWriter extends Writer {
/**
* Get the current line on the page.
- *
+ *
* @return The current line on the page.
*/
public int getPageLine() {
@@ -112,7 +112,7 @@ public class ReportWriter extends Writer {
/**
* Get the current page number.
- *
+ *
* @return The current page number.
*/
public int getPageNum() {
@@ -121,7 +121,7 @@ public class ReportWriter extends Writer {
/**
* Get the number of lines per page.
- *
+ *
* @return The number of lines per page.
*/
public int getLinesPerPage() {
@@ -130,9 +130,9 @@ public class ReportWriter extends Writer {
/**
* Get the current indent position.
- *
+ *
* This is the count of columns the indentation occupies.
- *
+ *
* @return The current indent position.
*/
public int getIndentPos() {
@@ -141,7 +141,7 @@ public class ReportWriter extends Writer {
/**
* Get the string of the default indentation value.
- *
+ *
* @return The string for the default indentation value.
*/
public String getString() {
@@ -150,9 +150,9 @@ public class ReportWriter extends Writer {
/**
* Get the string of a specific indentation value.
- *
+ *
* @param lvl
- * The level to get the value for.
+ * The level to get the value for.
* @return The string for the specified indentation value.
*/
public String getString(int lvl) {
@@ -161,7 +161,7 @@ public class ReportWriter extends Writer {
/**
* Get the number of spaces to a tab.
- *
+ *
* @return The number of spaces to a tab.
*/
public int getTabEqv() {
@@ -170,7 +170,7 @@ public class ReportWriter extends Writer {
/**
* Get the total number of lines written.
- *
+ *
* @return The total number of lines written.
*/
public int getLinesWritter() {
@@ -179,7 +179,7 @@ public class ReportWriter extends Writer {
/**
* Get the current position in the line.
- *
+ *
* @return The current position in the line.
*/
public int getLinePos() {
@@ -188,7 +188,7 @@ public class ReportWriter extends Writer {
/**
* Get the last character printed.
- *
+ *
* @return The last character printed.
*/
public char getLastChar() {
@@ -197,7 +197,7 @@ public class ReportWriter extends Writer {
/**
* Get the contained writer.
- *
+ *
* @return The contained writer.
*/
public Writer getWriter() {
@@ -206,7 +206,7 @@ public class ReportWriter extends Writer {
/**
* Check if the last character was a newline.
- *
+ *
* @return Was the last character a new line?
*/
public boolean isLastCharNL() {
@@ -215,7 +215,7 @@ public class ReportWriter extends Writer {
/**
* Check if tabs are being printed as spaces.
- *
+ *
* @return Are tabs being printed as spaces?
*/
public boolean isPrintingTabsAsSpaces() {
@@ -224,10 +224,9 @@ public class ReportWriter extends Writer {
/**
* Set the line spacing.
- *
+ *
* @param spacing
- * The number of lines to print for every blank line
- * encountered.
+ * The number of lines to print for every blank line encountered.
*/
public void setLineSpacing(int spacing) {
lineSpacing = spacing;
@@ -235,9 +234,9 @@ public class ReportWriter extends Writer {
/**
* Set whether tabs are being printed as spaces.
- *
+ *
* @param tabsAsSpaces
- * Whether to print tabs as spaces.
+ * Whether to print tabs as spaces.
*/
public void setPrintTabsAsSpaces(boolean tabsAsSpaces) {
printTabsAsSpaces = tabsAsSpaces;
@@ -248,9 +247,9 @@ public class ReportWriter extends Writer {
/**
* Set the number of lines per page.
- *
+ *
* @param lines
- * The number of lines per page.
+ * The number of lines per page.
*/
public void setLinesPerPage(int lines) {
linesPerPage = lines;
@@ -273,9 +272,9 @@ public class ReportWriter extends Writer {
/**
* Set the current indentation level.
- *
+ *
* @param level
- * The indentation level.
+ * The indentation level.
*/
public void setLevel(int level) {
indentLevel = level;
@@ -283,9 +282,9 @@ public class ReportWriter extends Writer {
/**
* Set the current amount of spaces per tab.
- *
+ *
* @param eqv
- * The amount of spaces per tab.
+ * The amount of spaces per tab.
*/
public void setTabEqv(int eqv) {
tabEqv = eqv;
@@ -302,12 +301,12 @@ public class ReportWriter extends Writer {
/**
* Set the default indentation string to use.
- *
- * NOTE: Using a string that contains a newline may cause weirdness of
- * various sorts to happen.
- *
+ *
+ * NOTE: Using a string that contains a newline may cause weirdness of various
+ * sorts to happen.
+ *
* @param str
- * The string to use for default indentation.
+ * The string to use for default indentation.
*/
public void setString(String str) {
defIVal.indentStr = str;
@@ -317,11 +316,11 @@ public class ReportWriter extends Writer {
/**
* Set the indentation string for a specific indentation level.
- *
+ *
* @param lvl
- * The level to set the indentation string for.
+ * The level to set the indentation string for.
* @param str
- * The indentation string to use.
+ * The indentation string to use.
*/
public void setString(int lvl, String str) {
iVals.get(lvl).indentStr = str;
@@ -336,11 +335,11 @@ public class ReportWriter extends Writer {
// Pass -2 to refresh the default index
/**
* Refresh the indentation settings.
- *
+ *
* @param lvl
- * The level of indents to refresh. Passing a number >= 0
- * refreshes that level, -1 refreshes every level, and -2
- * refreshes just the default indentation.
+ * The level of indents to refresh. Passing a number >= 0 refreshes
+ * that level, -1 refreshes every level, and -2 refreshes just the
+ * default indentation.
*/
private void refreshIndents(int lvl) {
if (lvl == -2) {
@@ -349,7 +348,7 @@ public class ReportWriter extends Writer {
for (IndentVal ival : iVals) {
refreshIndent(ival);
}
-
+
refreshIndent(defIVal);
} else {
refreshIndent(iVals.get(lvl));
@@ -382,8 +381,11 @@ public class ReportWriter extends Writer {
/**
* Duplicate this writers settings.
- * @param contents The internal writer to use.
- * @return A new writer, sharing this ones settings, but writing to the provided Writer instead.
+ *
+ * @param contents
+ * The internal writer to use.
+ * @return A new writer, sharing this ones settings, but writing to the provided
+ * Writer instead.
*/
public ReportWriter duplicate(Writer contents) {
ReportWriter rw = new ReportWriter(contents);
@@ -417,9 +419,12 @@ public class ReportWriter extends Writer {
public ReportWriter() {
this(new StringWriter());
}
+
/**
* Create a new ReportWriter.
- * @param write The place to write to.
+ *
+ * @param write
+ * The place to write to.
*/
public ReportWriter(Writer write) {
this(write, 0, "\t");
@@ -427,9 +432,13 @@ public class ReportWriter extends Writer {
/**
* Create a new ReportWriter with the specified default indentation values.
- * @param write The place to write to.
- * @param level The current indentation level.
- * @param indentStr The indentation string.
+ *
+ * @param write
+ * The place to write to.
+ * @param level
+ * The current indentation level.
+ * @param indentStr
+ * The indentation string.
*/
public ReportWriter(Writer write, int level, String indentStr) {
super();
@@ -446,7 +455,9 @@ public class ReportWriter extends Writer {
/**
* Indent a specific number of levels.
- * @param lvl The number of levels to indent.
+ *
+ * @param lvl
+ * The number of levels to indent.
*/
public void indent(int lvl) {
indentLevel += lvl;
@@ -461,7 +472,9 @@ public class ReportWriter extends Writer {
/**
* Dedent a specific number of levels.
- * @param lvl The number of levels to dedent.
+ *
+ * @param lvl
+ * The number of levels to dedent.
*/
public void dedent(int lvl) {
// @NOTE 9/5/18
@@ -480,8 +493,11 @@ public class ReportWriter extends Writer {
/**
* Writes a buffer to the output, then clears it.
- * @param sb The buffer to write and clear.
- * @throws IOException If something goes wrong writing the buffer.
+ *
+ * @param sb
+ * The buffer to write and clear.
+ * @throws IOException
+ * If something goes wrong writing the buffer.
*/
public void writeBuffer(StringBuffer sb) throws IOException {
write(sb.toString());
@@ -514,7 +530,8 @@ public class ReportWriter extends Writer {
// If we're printing CRLF pairs, make sure that we don't
// print incomplete pairs.
if (i < lineSpacing - 1) {
- if (c == '\n' && lastChar == '\r') contained.write('\r');
+ if (c == '\n' && lastChar == '\r')
+ contained.write('\r');
}
}
@@ -532,7 +549,8 @@ public class ReportWriter extends Writer {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
// Skip empty writes
- if (len == 0) return;
+ if (len == 0)
+ return;
// Last character was a new line, print the indent string
if (lastCharWasNL) {
@@ -546,7 +564,7 @@ public class ReportWriter extends Writer {
char c = cbuf[idx];
- if ((c == '\n' && lastChar != '\r') || c == '\n' || c == '\r' || c == '\f') {
+ if ((c == '\n' && lastChar != '\r') || c == '\n' || c == '\r' || c == '\f') {
writeNL(c);
} else {
if (lastCharWasNL) {
@@ -577,7 +595,8 @@ public class ReportWriter extends Writer {
if (printTabsAsSpaces)
contained.write(ival.indentStrSpacedTabs);
- else contained.write(ival.indentStr);
+ else
+ contained.write(ival.indentStr);
linePos += ival.indentStrPos;
indentPos += ival.indentStrPos;
diff --git a/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java b/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java
index 2ee25d1..88a3b81 100644
--- a/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java
@@ -22,7 +22,7 @@ import bjc.funcdata.IMap;
* @author ben
*
* @param <E>
- * The type of the state object to use
+ * The type of the state object to use
*
*/
public class RuleBasedConfigReader<E> {
@@ -58,14 +58,16 @@ public class RuleBasedConfigReader<E> {
* Create a new rule-based config reader
*
* @param start
- * The action to fire when starting a rule
+ * The action to fire when starting a rule
* @param continueRule
- * The action to fire when continuing a rule
+ * The action to fire when continuing a rule
* @param end
- * The action to fire when ending a rule
+ * The action to fire when ending a rule
*/
- public RuleBasedConfigReader(final BiConsumer<FunctionalStringTokenizer, IPair<String, E>> start,
- final BiConsumer<FunctionalStringTokenizer, E> continueRule, final Consumer<E> end) {
+ public RuleBasedConfigReader(
+ final BiConsumer<FunctionalStringTokenizer, IPair<String, E>> start,
+ final BiConsumer<FunctionalStringTokenizer, E> continueRule,
+ final Consumer<E> end) {
this.start = start;
this.continueRule = continueRule;
this.end = end;
@@ -77,25 +79,28 @@ public class RuleBasedConfigReader<E> {
* Add a pragma to this reader
*
* @param name
- * The name of the pragma to add
+ * The name of the pragma to add
* @param action
- * The function to execute when this pragma is read
+ * The function to execute when this pragma is read
*/
- public void addPragma(final String name, final BiConsumer<FunctionalStringTokenizer, E> action) {
- if(name == null)
+ public void addPragma(final String name,
+ final BiConsumer<FunctionalStringTokenizer, E> action) {
+ if (name == null)
throw new NullPointerException("Pragma name must not be null");
- else if(action == null)
+ else if (action == null)
throw new NullPointerException("Pragma action must not be null");
pragmas.put(name, action);
}
- private void continueRule(final E state, final boolean isRuleOpen, final String line) {
+ private void continueRule(final E state, final boolean isRuleOpen,
+ final String line) {
// Make sure our input is correct
- if(isRuleOpen == false)
+ if (isRuleOpen == false)
throw new InputMismatchException("Cannot continue rule with no rule open");
- else if(continueRule == null)
- throw new InputMismatchException("Rule continuation not supported for current grammar");
+ else if (continueRule == null)
+ throw new InputMismatchException(
+ "Rule continuation not supported for current grammar");
/*
* Accept the rule
@@ -107,7 +112,7 @@ public class RuleBasedConfigReader<E> {
/*
* Ignore blank line without an open rule
*/
- if(isRuleOpen == false) {
+ if (isRuleOpen == false) {
/*
* Do nothing
*/
@@ -117,7 +122,7 @@ public class RuleBasedConfigReader<E> {
/*
* Nothing happens on rule end
*/
- if(end != null) {
+ if (end != null) {
/*
* Process the rule ending
*/
@@ -134,13 +139,14 @@ public class RuleBasedConfigReader<E> {
* Run a stream through this reader
*
* @param input
- * The stream to get input
+ * The stream to get input
* @param initialState
- * The initial state of the reader
+ * The initial state of the reader
* @return The final state of the reader
*/
public E fromStream(final InputStream input, final E initialState) {
- if(input == null) throw new NullPointerException("Input stream must not be null");
+ if (input == null)
+ throw new NullPointerException("Input stream must not be null");
/*
* Application state: We're giving this back later
@@ -150,7 +156,7 @@ public class RuleBasedConfigReader<E> {
/*
* Prepare our input source
*/
- try(Scanner source = new Scanner(input)) {
+ try (Scanner source = new Scanner(input)) {
source.useDelimiter("\n");
/*
* This is true when a rule's open
@@ -160,27 +166,28 @@ public class RuleBasedConfigReader<E> {
/*
* Do something for every line of the file
*/
- source.forEachRemaining((line) -> {
+ source.forEachRemaining(line -> {
/*
* Skip comment lines
*/
- if(line.startsWith("#") || line.startsWith("//"))
+ if (line.startsWith("#") || line.startsWith("//"))
/*
* It's a comment
*/
return;
- else if(line.equals("")) {
+ else if (line.equals("")) {
/*
* End the rule
*/
isRuleOpen.replace(endRule(state, isRuleOpen.getValue()));
- } else if(line.startsWith("\t")) {
+ } else if (line.startsWith("\t")) {
/*
* Skip comment lines.
*/
- if(line.startsWith("#") || line.startsWith("//"))
+ if (line.startsWith("#") || line.startsWith("//"))
/*
- * It's a comment. */
+ * It's a comment.
+ */
return;
/*
@@ -206,9 +213,10 @@ public class RuleBasedConfigReader<E> {
* Set the action to execute when continuing a rule
*
* @param continueRule
- * The action to execute on continuation of a rule
+ * The action to execute on continuation of a rule
*/
- public void setContinueRule(final BiConsumer<FunctionalStringTokenizer, E> continueRule) {
+ public void
+ setContinueRule(final BiConsumer<FunctionalStringTokenizer, E> continueRule) {
this.continueRule = continueRule;
}
@@ -216,7 +224,7 @@ public class RuleBasedConfigReader<E> {
* Set the action to execute when ending a rule
*
* @param end
- * The action to execute on ending of a rule
+ * The action to execute on ending of a rule
*/
public void setEndRule(final Consumer<E> end) {
this.end = end;
@@ -226,10 +234,12 @@ public class RuleBasedConfigReader<E> {
* Set the action to execute when starting a rule
*
* @param start
- * The action to execute on starting of a rule
+ * The action to execute on starting of a rule
*/
- public void setStartRule(final BiConsumer<FunctionalStringTokenizer, IPair<String, E>> start) {
- if(start == null) throw new NullPointerException("Action on rule start must be non-null");
+ public void setStartRule(
+ final BiConsumer<FunctionalStringTokenizer, IPair<String, E>> start) {
+ if (start == null)
+ throw new NullPointerException("Action on rule start must be non-null");
this.start = start;
}
@@ -238,7 +248,8 @@ public class RuleBasedConfigReader<E> {
/*
* Create the line tokenizer
*/
- final FunctionalStringTokenizer tokenizer = new FunctionalStringTokenizer(line, " ");
+ final FunctionalStringTokenizer tokenizer
+ = new FunctionalStringTokenizer(line, " ");
/*
* Get the initial token
@@ -248,7 +259,7 @@ public class RuleBasedConfigReader<E> {
/*
* Handle pragmas
*/
- if(nextToken.equals("pragma")) {
+ if (nextToken.equals("pragma")) {
/*
* Get the pragma name
*/
@@ -264,8 +275,9 @@ public class RuleBasedConfigReader<E> {
/*
* Make sure input is correct
*/
- if(isRuleOpen == true)
- throw new InputMismatchException("Nested rules are currently not supported");
+ if (isRuleOpen == true)
+ throw new InputMismatchException(
+ "Nested rules are currently not supported");
/*
* Start a rule
diff --git a/base/src/main/java/bjc/utils/ioutils/RuleBasedReaderPragmas.java b/base/src/main/java/bjc/utils/ioutils/RuleBasedReaderPragmas.java
index 7e7550e..42a01a4 100644
--- a/base/src/main/java/bjc/utils/ioutils/RuleBasedReaderPragmas.java
+++ b/base/src/main/java/bjc/utils/ioutils/RuleBasedReaderPragmas.java
@@ -18,20 +18,21 @@ public class RuleBasedReaderPragmas {
* Creates a pragma that takes a single integer argument
*
* @param <StateType>
- * The type of state that goes along with this pragma
+ * The type of state that goes along with this pragma
* @param name
- * The name of this pragma, for error message purpose
+ * The name of this pragma, for error message purpose
* @param consumer
- * The function to invoke with the parsed integer
+ * The function to invoke with the parsed integer
* @return A pragma that functions as described above.
*/
- public static <StateType> BiConsumer<FunctionalStringTokenizer, StateType> buildInteger(final String name,
- final BiConsumer<Integer, StateType> consumer) {
+ public static <StateType> BiConsumer<FunctionalStringTokenizer, StateType>
+ buildInteger(final String name,
+ final BiConsumer<Integer, StateType> consumer) {
return (tokenizer, state) -> {
/*
* Check our input is correct
*/
- if(!tokenizer.hasMoreTokens()) {
+ if (!tokenizer.hasMoreTokens()) {
String fmt = "Pragma %s requires one integer argument";
throw new PragmaFormatException(String.format(fmt, name));
@@ -47,14 +48,15 @@ public class RuleBasedReaderPragmas {
* Run the pragma
*/
consumer.accept(Integer.parseInt(token), state);
- } catch(final NumberFormatException nfex) {
+ } catch (final NumberFormatException nfex) {
/*
* Tell the user their argument isn't correct
*/
- String fmt = "Argument %s to %s pragma isn't a valid integer, and this pragma requires an integer argument.";
+ String fmt
+ = "Argument %s to %s pragma isn't a valid integer, and this pragma requires an integer argument.";
- final PragmaFormatException pfex = new PragmaFormatException(
- String.format(fmt, token, name));
+ final PragmaFormatException pfex
+ = new PragmaFormatException(String.format(fmt, token, name));
pfex.initCause(nfex);
@@ -64,24 +66,25 @@ public class RuleBasedReaderPragmas {
}
/**
- * Creates a pragma that takes any number of arguments and collapses
- * them all into a single string
+ * Creates a pragma that takes any number of arguments and collapses them all
+ * into a single string
*
* @param <StateType>
- * The type of state that goes along with this pragma
+ * The type of state that goes along with this pragma
* @param name
- * The name of this pragma, for error message purpose
+ * The name of this pragma, for error message purpose
* @param consumer
- * The function to invoke with the parsed string
+ * The function to invoke with the parsed string
* @return A pragma that functions as described above.
*/
- public static <StateType> BiConsumer<FunctionalStringTokenizer, StateType> buildStringCollapser(
- final String name, final BiConsumer<String, StateType> consumer) {
+ public static <StateType> BiConsumer<FunctionalStringTokenizer, StateType>
+ buildStringCollapser(final String name,
+ final BiConsumer<String, StateType> consumer) {
return (tokenizer, state) -> {
/*
* Check our input
*/
- if(!tokenizer.hasMoreTokens()) {
+ if (!tokenizer.hasMoreTokens()) {
String fmt = "Pragma %s requires one or more string arguments.";
throw new PragmaFormatException(String.format(fmt, name));
diff --git a/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java b/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java
index 3a07fbc..be8cda7 100644
--- a/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java
+++ b/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java
@@ -19,7 +19,7 @@ import java.util.Set;
public class SimpleProperties implements Map<String, String> {
/**
* Exception thrown when there is a duplicate key, when they are forbidden.
- *
+ *
* @author 15405
*
*/
@@ -28,22 +28,25 @@ public class SimpleProperties implements Map<String, String> {
/**
* Create a new duplicate key exception.
- *
+ *
* @param keyName
- * The name of the key that has been duplicated.
+ * The name of the key that has been duplicated.
*/
public DuplicateKeys(String keyName) {
super(String.format("Duplicate value encountered for key '%s'", keyName));
}
}
-
+
public static class InvalidLineFormat extends RuntimeException {
private static final long serialVersionUID = 5332131472090792841L;
-
+
public InvalidLineFormat(String lne) {
- super(String.format("Line '%s' is improperly formatted.\n\tExpected format is a string key, followed by a single space, followed by the value", ""));
+ super(String.format(
+ "Line '%s' is improperly formatted.\n\tExpected format is a string key, followed by a single space, followed by the value",
+ ""));
}
}
+
private final Map<String, String> props;
/**
@@ -52,22 +55,22 @@ public class SimpleProperties implements Map<String, String> {
public SimpleProperties() {
props = new HashMap<>();
}
-
+
/**
* Load properties from an input stream.
- *
- * Delegates to {@link SimpleProperties#loadFrom(Reader, boolean)} to allow
- * you to pass a input stream instead of a reader.
- *
- * @param is
- * The stream to read from.
+ *
+ * Delegates to {@link SimpleProperties#loadFrom(Reader, boolean)} to allow you
+ * to pass a input stream instead of a reader.
+ *
+ * @param is
+ * The stream to read from.
* @param allowDuplicates
- * Whether or not duplicate keys should be allowed.
+ * Whether or not duplicate keys should be allowed.
*/
public void loadFrom(final InputStream is, final boolean allowDuplicates) {
loadFrom(new InputStreamReader(is), allowDuplicates);
}
-
+
/**
* Load properties from the provided input reader.
*
@@ -76,23 +79,26 @@ public class SimpleProperties implements Map<String, String> {
* All leading/trailing spaces from the name &amp; body are removed.
*
* @param rdr
- * The reader to read from.
+ * The reader to read from.
*
* @param allowDuplicates
- * Whether or not duplicate keys should be allowed. If they are,
- * the end-value of the property will be what the last one was.
- *
- * @throws DuplicateKeys If duplicate keys have been found when they are prohibited.
+ * Whether or not duplicate keys should be allowed. If
+ * they are, the end-value of the property will be what
+ * the last one was.
+ *
+ * @throws DuplicateKeys
+ * If duplicate keys have been found when they are
+ * prohibited.
*/
public void loadFrom(final Reader rdr, final boolean allowDuplicates) {
- try(Scanner scn = new Scanner(rdr)) {
- while(scn.hasNextLine()) {
+ try (Scanner scn = new Scanner(rdr)) {
+ while (scn.hasNextLine()) {
final String ln = scn.nextLine().trim();
/*
* Skip blank lines/comments
*/
- if(ln.equals("") || ln.startsWith("#")) {
+ if (ln.equals("") || ln.startsWith("#")) {
continue;
}
@@ -101,7 +107,7 @@ public class SimpleProperties implements Map<String, String> {
/*
* Complain about improperly formatted lines.
*/
- if(sepIdx == -1) {
+ if (sepIdx == -1) {
throw new InvalidLineFormat(ln);
}
@@ -111,7 +117,7 @@ public class SimpleProperties implements Map<String, String> {
/*
* Complain about duplicates, if that is wanted.
*/
- if(!allowDuplicates && containsKey(name)) {
+ if (!allowDuplicates && containsKey(name)) {
throw new DuplicateKeys(name);
}
@@ -122,7 +128,7 @@ public class SimpleProperties implements Map<String, String> {
/**
* Output the set of read properties.
- *
+ *
* Uses System.out, since one isn't specified.
*/
public void outputProperties() {
@@ -131,13 +137,14 @@ public class SimpleProperties implements Map<String, String> {
/**
* Output the set of read properties.
- *
- * @param strim The stream to output properties to.
+ *
+ * @param strim
+ * The stream to output properties to.
*/
public void outputProperties(PrintStream strim) {
strim.println("Read properties:");
- for(final Entry<String, String> entry : entrySet()) {
+ for (final Entry<String, String> entry : entrySet()) {
strim.printf("\t'%s'\t'%s'\n", entry.getKey(), entry.getValue());
}
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/Block.java b/base/src/main/java/bjc/utils/ioutils/blocks/Block.java
index bf0257e..b8c611b 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/Block.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/Block.java
@@ -29,10 +29,10 @@ public class Block {
/**
* The line offset number for this block.
- *
- * Essentially, this is the absolute number of lines that this block is
- * into whatever source it came from, where as startLine and endLine are
- * relative to the BlockReader this Block is from.
+ *
+ * Essentially, this is the absolute number of lines that this block is into
+ * whatever source it came from, where as startLine and endLine are relative to
+ * the BlockReader this Block is from.
*/
public int lineOffset;
@@ -40,15 +40,16 @@ public class Block {
* Create a new block.
*
* @param blockNo
- * The number of this block.
+ * The number of this block.
* @param contents
- * The contents of this block.
+ * The contents of this block.
* @param startLine
- * The line this block started on.
+ * The line this block started on.
* @param endLine
- * The line this block ended.
+ * The line this block ended.
*/
- public Block(final int blockNo, final String contents, final int startLine, final int endLine) {
+ public Block(final int blockNo, final String contents, final int startLine,
+ final int endLine) {
this.contents = contents;
this.startLine = startLine;
this.endLine = endLine;
@@ -58,12 +59,13 @@ public class Block {
@Override
public String toString() {
if (lineOffset != -1) {
- String fmt = "Block #%d (from lines %d (%d) to %d (%d)), length: %d characters";
+ String fmt
+ = "Block #%d (from lines %d (%d) to %d (%d)), length: %d characters";
- return String.format(fmt, blockNo, startLine + lineOffset, startLine, endLine + lineOffset,
- endLine + lineOffset, contents.length());
+ return String.format(fmt, blockNo, startLine + lineOffset, startLine,
+ endLine + lineOffset, endLine + lineOffset, contents.length());
}
-
+
String fmt = "Block #%d (from lines %d to %d), length: %d characters";
return String.format(fmt, blockNo, startLine, endLine, contents.length());
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java
index c6d709c..f111244 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/BlockReader.java
@@ -51,10 +51,10 @@ public interface BlockReader extends AutoCloseable, Iterator<Block>, Iterable<Bl
* Execute an action for each remaining block.
*
* @param action
- * The action to execute for each block
+ * The action to execute for each block
*/
default void forEachBlock(final Consumer<Block> action) {
- while(hasNext()) {
+ while (hasNext()) {
action.accept(next());
}
}
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/BlockReaders.java b/base/src/main/java/bjc/utils/ioutils/blocks/BlockReaders.java
index f1dfc3c..615af85 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/BlockReaders.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/BlockReaders.java
@@ -13,10 +13,10 @@ public class BlockReaders {
* Create a new simple block reader that works off a regex.
*
* @param blockDelim
- * The regex that separates blocks.
+ * The regex that separates blocks.
*
* @param source
- * The reader to get blocks from.
+ * The reader to get blocks from.
*
* @return A configured simple reader.
*/
@@ -28,7 +28,7 @@ public class BlockReaders {
* Create a new pushback block reader.
*
* @param src
- * The block reader to read blocks from.
+ * The block reader to read blocks from.
*
* @return A configured pushback reader.
*/
@@ -40,10 +40,10 @@ public class BlockReaders {
* Create a new triggered block reader.
*
* @param source
- * The block reader to read blocks from.
+ * The block reader to read blocks from.
*
* @param action
- * The action to execute before reading a block.
+ * The action to execute before reading a block.
*
* @return A configured triggered block reader.
*/
@@ -55,14 +55,15 @@ public class BlockReaders {
* Create a new layered block reader.
*
* @param primary
- * The first source to read blocks from.
+ * The first source to read blocks from.
*
* @param secondary
- * The second source to read blocks from.
+ * The second source to read blocks from.
*
* @return A configured layered block reader.
*/
- public static BlockReader layered(final BlockReader primary, final BlockReader secondary) {
+ public static BlockReader layered(final BlockReader primary,
+ final BlockReader secondary) {
return new LayeredBlockReader(primary, secondary);
}
@@ -70,7 +71,7 @@ public class BlockReaders {
* Create a new serial block reader.
*
* @param readers
- * The readers to pull from, in the order to pull from them.
+ * The readers to pull from, in the order to pull from them.
*
* @return A configured serial block reader.
*/
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/BoundBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/BoundBlockReader.java
index ba2c7ab..0bd0991 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/BoundBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/BoundBlockReader.java
@@ -6,14 +6,14 @@ import java.util.function.Supplier;
/**
* A block reader composed from functions.
- *
+ *
* @author EVE
*
*/
public class BoundBlockReader implements BlockReader {
/**
* A function that serves to close an I/O source.
- *
+ *
* @author EVE
*
*/
@@ -21,9 +21,9 @@ public class BoundBlockReader implements BlockReader {
public interface Closer {
/**
* Close the I/O source this is attached to.
- *
+ *
* @throws IOException
- * If something goes wrong
+ * If something goes wrong
*/
public void close() throws IOException;
}
@@ -38,15 +38,16 @@ public class BoundBlockReader implements BlockReader {
/**
* Create a new bound block reader.
- *
+ *
* @param blockChecker
- * Predicate for checking if a block is available
+ * Predicate for checking if a block is available
* @param blockGetter
- * Function to retrieve a block
+ * Function to retrieve a block
* @param blockCloser
- * Function to close a block source
+ * Function to close a block source
*/
- public BoundBlockReader(BooleanSupplier blockChecker, Supplier<Block> blockGetter, Closer blockCloser) {
+ public BoundBlockReader(BooleanSupplier blockChecker, Supplier<Block> blockGetter,
+ Closer blockCloser) {
checker = blockChecker;
getter = blockGetter;
closer = blockCloser;
@@ -66,7 +67,7 @@ public class BoundBlockReader implements BlockReader {
@Override
public boolean nextBlock() {
- if(checker.getAsBoolean()) {
+ if (checker.getAsBoolean()) {
current = getter.get();
blockNo += 1;
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/FilteredBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/FilteredBlockReader.java
index 7a6eddc..5520f1f 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/FilteredBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/FilteredBlockReader.java
@@ -6,7 +6,7 @@ import java.util.function.Predicate;
/**
* A block reader that only yields blocks that pass a predicate.
- *
+ *
* @author EVE
*
*/
@@ -41,28 +41,29 @@ public class FilteredBlockReader implements BlockReader {
/**
* Create a new filtered block reader with a given filter.
- *
+ *
* @param src
- * The place to read blocks from.
+ * The place to read blocks from.
* @param predic
- * The predicate to use to pass blocks.
+ * The predicate to use to pass blocks.
*/
public FilteredBlockReader(BlockReader src, Predicate<Block> predic) {
this(src, predic, null);
}
/**
- * Create a new filtered block reader with a given filter that executes
- * a specific action when a block fails.
- *
+ * Create a new filtered block reader with a given filter that executes a
+ * specific action when a block fails.
+ *
* @param src
- * The place to read blocks from.
+ * The place to read blocks from.
* @param predic
- * The predicate to use to pass blocks.
+ * The predicate to use to pass blocks.
* @param failAct
- * The action to take when a block fails.
+ * The action to take when a block fails.
*/
- public FilteredBlockReader(BlockReader src, Predicate<Block> predic, Consumer<Block> failAct) {
+ public FilteredBlockReader(BlockReader src, Predicate<Block> predic,
+ Consumer<Block> failAct) {
source = src;
pred = predic;
failAction = failAct;
@@ -72,16 +73,16 @@ public class FilteredBlockReader implements BlockReader {
@Override
public boolean hasNextBlock() {
- if(pending != null) return true;
+ if (pending != null)
+ return true;
- while(source.hasNextBlock()) {
+ while (source.hasNextBlock()) {
/*
- * Only say we have a next block if the next block would
- * pass the predicate.
+ * Only say we have a next block if the next block would pass the predicate.
*/
pending = source.next();
- if(pred.test(pending)) {
+ if (pred.test(pending)) {
blockNo += 1;
return true;
}
@@ -99,7 +100,7 @@ public class FilteredBlockReader implements BlockReader {
@Override
public boolean nextBlock() {
- if(pending != null || hasNextBlock()) {
+ if (pending != null || hasNextBlock()) {
current = pending;
pending = null;
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/FlatMappedBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/FlatMappedBlockReader.java
index 9c1bcd5..e08d360 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/FlatMappedBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/FlatMappedBlockReader.java
@@ -36,11 +36,11 @@ public class FlatMappedBlockReader implements BlockReader {
/**
* Create a new flat-mapping block reader.
- *
+ *
* @param source
- * The source to read blocks from
+ * The source to read blocks from
* @param trans
- * The transform to use.
+ * The transform to use.
*/
public FlatMappedBlockReader(BlockReader source, Function<Block, List<Block>> trans) {
reader = source;
@@ -62,11 +62,11 @@ public class FlatMappedBlockReader implements BlockReader {
@Override
public boolean nextBlock() {
/*
- * Attempt to get a new pending list if the one we have isn't
- * valid.
+ * Attempt to get a new pending list if the one we have isn't valid.
*/
- while(pending == null || !pending.hasNext()) {
- if(!reader.hasNext()) return false;
+ while (pending == null || !pending.hasNext()) {
+ if (!reader.hasNext())
+ return false;
pending = transform.apply(reader.next()).iterator();
}
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/LayeredBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/LayeredBlockReader.java
index 48c4963..847e298 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/LayeredBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/LayeredBlockReader.java
@@ -29,10 +29,10 @@ public class LayeredBlockReader implements BlockReader {
* Create a new layered block reader.
*
* @param primary
- * The first source to read blocks from.
+ * The first source to read blocks from.
*
* @param secondary
- * The second source to read blocks from.
+ * The second source to read blocks from.
*/
public LayeredBlockReader(final BlockReader primary, final BlockReader secondary) {
first = primary;
@@ -49,8 +49,8 @@ public class LayeredBlockReader implements BlockReader {
final Block firstBlock = first.getBlock();
/*
- * Only drain a block from the second reader if none are
- * available in the first reader.
+ * Only drain a block from the second reader if none are available in the first
+ * reader.
*/
return firstBlock == null ? second.getBlock() : firstBlock;
}
@@ -60,7 +60,7 @@ public class LayeredBlockReader implements BlockReader {
final boolean gotFirst = first.nextBlock();
final boolean succ = gotFirst ? gotFirst : second.nextBlock();
- if(succ) {
+ if (succ) {
blockNo += 1;
}
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/MappedBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/MappedBlockReader.java
index 4439da2..8b3e0c5 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/MappedBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/MappedBlockReader.java
@@ -5,7 +5,7 @@ import java.util.function.UnaryOperator;
/**
* A block reader that applies a transform to each block.
- *
+ *
* @author EVE
*
*/
@@ -20,11 +20,11 @@ public class MappedBlockReader implements BlockReader {
/**
* Create a new mapped block reader.
- *
+ *
* @param source
- * The source for blocks
+ * The source for blocks
* @param trans
- * The transform to apply.
+ * The transform to apply.
*/
public MappedBlockReader(BlockReader source, UnaryOperator<Block> trans) {
reader = source;
@@ -45,7 +45,7 @@ public class MappedBlockReader implements BlockReader {
@Override
public boolean nextBlock() {
- if(hasNextBlock()) {
+ if (hasNextBlock()) {
current = transform.apply(reader.next());
blockNo += 1;
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/PushbackBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/PushbackBlockReader.java
index 924df39..cdd6760 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/PushbackBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/PushbackBlockReader.java
@@ -27,7 +27,7 @@ public class PushbackBlockReader implements BlockReader {
* Create a new pushback block reader.
*
* @param src
- * The block reader to use when no blocks are queued.
+ * The block reader to use when no blocks are queued.
*/
public PushbackBlockReader(final BlockReader src) {
source = src;
@@ -50,7 +50,7 @@ public class PushbackBlockReader implements BlockReader {
/*
* Drain pushed-back blocks first.
*/
- if(!waiting.isEmpty()) {
+ if (!waiting.isEmpty()) {
curBlock = waiting.pop();
blockNo += 1;
@@ -61,7 +61,7 @@ public class PushbackBlockReader implements BlockReader {
final boolean succ = source.nextBlock();
curBlock = source.getBlock();
- if(succ) {
+ if (succ) {
blockNo += 1;
}
@@ -82,7 +82,7 @@ public class PushbackBlockReader implements BlockReader {
* Insert a block at the back of the queue of pending blocks.
*
* @param blk
- * The block to put at the back.
+ * The block to put at the back.
*/
public void addBlock(final Block blk) {
waiting.add(blk);
@@ -92,7 +92,7 @@ public class PushbackBlockReader implements BlockReader {
* Insert a block at the front of the queue of pending blocks.
*
* @param blk
- * The block to put at the front.
+ * The block to put at the front.
*/
public void pushBlock(final Block blk) {
waiting.push(blk);
@@ -100,7 +100,7 @@ public class PushbackBlockReader implements BlockReader {
@Override
public String toString() {
- return String.format("PushbackBlockReader [waiting=%s, curBlock=%s, blockNo=%s]", waiting, curBlock,
- blockNo);
+ return String.format("PushbackBlockReader [waiting=%s, curBlock=%s, blockNo=%s]",
+ waiting, curBlock, blockNo);
}
}
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java
index 66ebd66..265a781 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java
@@ -19,19 +19,20 @@ public class SerialBlockReader implements BlockReader {
* Create a new serial block reader.
*
* @param readers
- * The readers to pull from, in the order to pull from them.
+ * The readers to pull from, in the order to pull from them.
*/
public SerialBlockReader(final BlockReader... readers) {
readerQueue = new LinkedList<>();
-
- for(final BlockReader reader : readers) {
+
+ for (final BlockReader reader : readers) {
readerQueue.add(reader);
}
}
@Override
public boolean hasNextBlock() {
- if(readerQueue.isEmpty()) return false;
+ if (readerQueue.isEmpty())
+ return false;
/*
* Attempt to get a block from the first reader.
@@ -42,11 +43,12 @@ public class SerialBlockReader implements BlockReader {
/*
* Close/dispose of readers until we get an open one.
*/
- while(!cont) {
+ while (!cont) {
try {
readerQueue.pop().close();
- } catch(final IOException ioex) {
- throw new IllegalStateException("Exception thrown by discarded reader", ioex);
+ } catch (final IOException ioex) {
+ throw new IllegalStateException("Exception thrown by discarded reader",
+ ioex);
}
hasBlock = readerQueue.peek().hasNextBlock();
@@ -58,7 +60,7 @@ public class SerialBlockReader implements BlockReader {
@Override
public Block getBlock() {
- if(readerQueue.isEmpty()) {
+ if (readerQueue.isEmpty()) {
return null;
}
@@ -67,23 +69,25 @@ public class SerialBlockReader implements BlockReader {
@Override
public boolean nextBlock() {
- if(readerQueue.isEmpty()) return false;
+ if (readerQueue.isEmpty())
+ return false;
boolean gotBlock = readerQueue.peek().nextBlock();
boolean cont = gotBlock || readerQueue.isEmpty();
- while(!cont) {
+ while (!cont) {
try {
readerQueue.pop().close();
- } catch(final IOException ioex) {
- throw new IllegalStateException("Exception thrown by discarded reader", ioex);
+ } catch (final IOException ioex) {
+ throw new IllegalStateException("Exception thrown by discarded reader",
+ ioex);
}
gotBlock = readerQueue.peek().nextBlock();
cont = gotBlock || readerQueue.isEmpty();
}
- if(cont) {
+ if (cont) {
blockNo += 1;
}
@@ -97,7 +101,7 @@ public class SerialBlockReader implements BlockReader {
@Override
public void close() throws IOException {
- while(!readerQueue.isEmpty()) {
+ while (!readerQueue.isEmpty()) {
final BlockReader reader = readerQueue.pop();
reader.close();
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java
index ac77f97..94405c9 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java
@@ -38,11 +38,11 @@ public class SimpleBlockReader implements BlockReader {
* Create a new block reader.
*
* @param blockDelim
- * The pattern that separates blocks. Note that the end of file
- * is always considered to end a block.
+ * The pattern that separates blocks. Note that the end of
+ * file is always considered to end a block.
*
* @param source
- * The source to read blocks from.
+ * The source to read blocks from.
*/
public SimpleBlockReader(final String blockDelim, final Reader source) {
blockReader = new Scanner(source);
@@ -59,12 +59,12 @@ public class SimpleBlockReader implements BlockReader {
* Create a new block reader.
*
* @param blockDelim
- * The pattern that separates blocks. Note that the end of file
- * is always considered to end a block.
+ * The pattern that separates blocks. Note that the end of
+ * file is always considered to end a block.
*
* @param source
- * The source to read blocks from.
- * NOTE: This does modify the provided scanner.
+ * The source to read blocks from. NOTE: This does modify the
+ * provided scanner.
*/
public SimpleBlockReader(final String blockDelim, final Scanner source) {
blockReader = source;
@@ -96,7 +96,8 @@ public class SimpleBlockReader implements BlockReader {
final String blockContents = blockReader.next();
final int blockStartLine = lineNo;
- final int blockEndLine = lineNo + StringUtils.countMatches(blockContents, "\\R");
+ final int blockEndLine
+ = lineNo + StringUtils.countMatches(blockContents, "\\R");
lineNo = blockEndLine;
blockNo += 1;
@@ -104,10 +105,10 @@ public class SimpleBlockReader implements BlockReader {
currBlock = new Block(blockNo, blockContents, blockStartLine, blockEndLine);
return true;
- } catch(final NoSuchElementException nseex) {
+ } catch (final NoSuchElementException nseex) {
// Don't null out the current block, let it be the last
// one
- //currBlock = null;
+ // currBlock = null;
return false;
}
@@ -127,7 +128,7 @@ public class SimpleBlockReader implements BlockReader {
* Set the delimiter used to separate blocks.
*
* @param delim
- * The delimiter used to separate blocks.
+ * The delimiter used to separate blocks.
*/
public void setDelimiter(final String delim) {
blockReader.useDelimiter(delim);
@@ -135,6 +136,7 @@ public class SimpleBlockReader implements BlockReader {
@Override
public String toString() {
- return String.format("SimpleBlockReader [currBlock=%s, blockNo=%s]", currBlock, blockNo);
+ return String.format("SimpleBlockReader [currBlock=%s, blockNo=%s]", currBlock,
+ blockNo);
}
}
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java
index 456a445..12568c8 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java
@@ -6,7 +6,7 @@ import bjc.data.BooleanToggle;
/**
* A block reader that toggles between two sources.
- *
+ *
* @author EVE
*
*/
@@ -21,11 +21,11 @@ public class ToggledBlockReader implements BlockReader {
/**
* Create a new toggling block reader.
- *
+ *
* @param left
- * The first block reader to use.
+ * The first block reader to use.
* @param right
- * The second block reader to use.
+ * The second block reader to use.
*/
public ToggledBlockReader(BlockReader left, BlockReader right) {
leftSource = left;
@@ -38,7 +38,7 @@ public class ToggledBlockReader implements BlockReader {
@Override
public boolean hasNextBlock() {
- if(leftToggle.peek()) {
+ if (leftToggle.peek()) {
return leftSource.hasNextBlock();
}
@@ -47,7 +47,7 @@ public class ToggledBlockReader implements BlockReader {
@Override
public Block getBlock() {
- if(leftToggle.peek()) {
+ if (leftToggle.peek()) {
return leftSource.getBlock();
}
@@ -58,13 +58,14 @@ public class ToggledBlockReader implements BlockReader {
public boolean nextBlock() {
boolean succ;
- if(leftToggle.get()) {
+ if (leftToggle.get()) {
succ = leftSource.nextBlock();
} else {
succ = rightSource.nextBlock();
}
- if(succ) blockNo += 1;
+ if (succ)
+ blockNo += 1;
return succ;
}
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/TriggeredBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/TriggeredBlockReader.java
index a066f9c..b4accec 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/TriggeredBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/TriggeredBlockReader.java
@@ -22,10 +22,10 @@ public class TriggeredBlockReader implements BlockReader {
* Create a new triggered reader with the specified source/action.
*
* @param source
- * The block reader to read blocks from.
+ * The block reader to read blocks from.
*
* @param action
- * The action to execute before reading a block.
+ * The action to execute before reading a block.
*/
public TriggeredBlockReader(final BlockReader source, final Runnable action) {
this.source = source;
diff --git a/base/src/main/java/bjc/utils/ioutils/properties/Property.java b/base/src/main/java/bjc/utils/ioutils/properties/Property.java
index 7cc9369..77d990a 100644
--- a/base/src/main/java/bjc/utils/ioutils/properties/Property.java
+++ b/base/src/main/java/bjc/utils/ioutils/properties/Property.java
@@ -8,8 +8,8 @@ public class Property {
public String value;
public Property(String name, String comment, String value) {
- this.name = name;
+ this.name = name;
this.comment = comment;
- this.value = value;
+ this.value = value;
}
}
diff --git a/base/src/main/java/bjc/utils/ioutils/properties/PropertyDB.java b/base/src/main/java/bjc/utils/ioutils/properties/PropertyDB.java
index 0996b58..4126d80 100644
--- a/base/src/main/java/bjc/utils/ioutils/properties/PropertyDB.java
+++ b/base/src/main/java/bjc/utils/ioutils/properties/PropertyDB.java
@@ -2,7 +2,7 @@ package bjc.utils.ioutils.properties;
/**
* A database of properties.
- *
+ *
* @author bjculkin
*
*/