diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2018-02-12 22:45:04 -0500 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2018-02-12 22:45:04 -0500 |
| commit | df94066e3af02ff02d5ab4d033a3d603f743234c (patch) | |
| tree | 168a1edaf58d386c175ffb601e9d4da8e13d31e2 /base/src/main/java/bjc/utils/ioutils | |
| parent | ae51c587c53f7ca311e556e3cbd0c5566d6c2843 (diff) | |
Formatting pass
Diffstat (limited to 'base/src/main/java/bjc/utils/ioutils')
21 files changed, 171 insertions, 166 deletions
diff --git a/base/src/main/java/bjc/utils/ioutils/Prompter.java b/base/src/main/java/bjc/utils/ioutils/Prompter.java index a6ec4c0..b318222 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 71f6782..e11d4b4 100644 --- a/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java +++ b/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java @@ -25,13 +25,13 @@ public class RegexStringEditor { * 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. */ @@ -44,13 +44,13 @@ public class RegexStringEditor { * 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. @@ -64,16 +64,16 @@ 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. */ @@ -102,16 +102,16 @@ 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. */ @@ -133,10 +133,10 @@ 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. @@ -153,7 +153,7 @@ public class RegexStringEditor { /* * For every match. */ - while (matcher.find()) { + while(matcher.find()) { final String match = matcher.group(); /* @@ -183,20 +183,20 @@ 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) { final Matcher matcher = patt.matcher(input); - if (matcher.matches()) { + if(matcher.matches()) { return action.apply(input); } else { return input; @@ -207,13 +207,13 @@ 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 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. @@ -221,7 +221,7 @@ public class RegexStringEditor { 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; } else { return action.apply(input); diff --git a/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java b/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java index 7c5205b..9e4bbb6 100644 --- a/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java +++ b/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java @@ -22,30 +22,30 @@ import bjc.utils.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> { - /* Function to execute when starting a rule. - * Takes the tokenizer, and a pair of the read token and application state + /* + * Function to execute when starting a rule. Takes the tokenizer, and a + * pair of the read token and application state */ private BiConsumer<FunctionalStringTokenizer, IPair<String, E>> start; /* - * Function to use when continuing a rule - * Takes a tokenizer and application state + * Function to use when continuing a rule Takes a tokenizer and + * application state */ private BiConsumer<FunctionalStringTokenizer, E> continueRule; /* - * Function to use when ending a rule - * Takes an application state + * Function to use when ending a rule Takes an application state */ private Consumer<E> end; /* - * Map of pragma names to pragma actions - * Pragma actions are functions taking a tokenizer and application state + * Map of pragma names to pragma actions Pragma actions are functions + * taking a tokenizer and application state */ private final IMap<String, BiConsumer<FunctionalStringTokenizer, E>> pragmas; @@ -53,11 +53,11 @@ 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) { @@ -72,22 +72,23 @@ 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) throw new NullPointerException("Pragma name must not be null"); - else if (action == null) throw new NullPointerException("Pragma action must not be null"); + if(name == null) + throw new NullPointerException("Pragma name must not be 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) { // 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) + else if(continueRule == null) throw new InputMismatchException("Rule continuation not supported for current grammar"); /* @@ -100,7 +101,7 @@ public class RuleBasedConfigReader<E> { /* * Ignore blank line without an open rule */ - if (isRuleOpen == false) + if(isRuleOpen == false) /* * Do nothing */ @@ -109,7 +110,7 @@ public class RuleBasedConfigReader<E> { /* * Nothing happens on rule end */ - if (end != null) { + if(end != null) { /* * Process the rule ending */ @@ -127,13 +128,13 @@ 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 @@ -143,7 +144,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 @@ -157,17 +158,17 @@ public class RuleBasedConfigReader<E> { /* * 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")) { /* * Continue the rule */ @@ -191,7 +192,7 @@ 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) { this.continueRule = continueRule; @@ -201,7 +202,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; @@ -211,10 +212,10 @@ 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"); + if(start == null) throw new NullPointerException("Action on rule start must be non-null"); this.start = start; } @@ -233,7 +234,7 @@ public class RuleBasedConfigReader<E> { /* * Handle pragmas */ - if (nextToken.equals("pragma")) { + if(nextToken.equals("pragma")) { /* * Get the pragma name */ @@ -249,7 +250,7 @@ public class RuleBasedConfigReader<E> { /* * Make sure input is correct */ - if (isRuleOpen == true) + if(isRuleOpen == true) throw new InputMismatchException("Nested rules are currently not supported"); /* diff --git a/base/src/main/java/bjc/utils/ioutils/RuleBasedReaderPragmas.java b/base/src/main/java/bjc/utils/ioutils/RuleBasedReaderPragmas.java index e26a7ee..5d19337 100644 --- a/base/src/main/java/bjc/utils/ioutils/RuleBasedReaderPragmas.java +++ b/base/src/main/java/bjc/utils/ioutils/RuleBasedReaderPragmas.java @@ -18,11 +18,11 @@ 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, @@ -31,7 +31,7 @@ public class RuleBasedReaderPragmas { /* * 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,13 +47,14 @@ 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."; - final PragmaFormatException pfex = new PragmaFormatException(String.format(fmt, token, name)); + final PragmaFormatException pfex = new PragmaFormatException( + String.format(fmt, token, name)); pfex.initCause(nfex); @@ -67,11 +68,11 @@ public class RuleBasedReaderPragmas { * 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( @@ -80,7 +81,7 @@ public class RuleBasedReaderPragmas { /* * 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 e6279c4..7043ed2 100644 --- a/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java +++ b/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java @@ -32,23 +32,23 @@ public class SimpleProperties implements Map<String, String> { * All leading/trailing spaces from the name & body are removed. * * @param is - * The stream to read from. + * 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) { - try (Scanner scn = new Scanner(is)) { - while (scn.hasNextLine()) { + try(Scanner scn = new Scanner(is)) { + while(scn.hasNextLine()) { final String ln = scn.nextLine().trim(); /* * Skip blank lines/comments */ - if (ln.equals("")) { + if(ln.equals("")) { continue; } - if (ln.startsWith("#")) { + if(ln.startsWith("#")) { continue; } @@ -57,7 +57,7 @@ public class SimpleProperties implements Map<String, String> { /* * Complain about improperly formatted lines. */ - if (sepIdx == -1) { + if(sepIdx == -1) { final String fmt = "Properties must be a name, a space, then the body.\n\tOffending line is '%s'"; final String msg = String.format(fmt, ln); @@ -70,7 +70,7 @@ public class SimpleProperties implements Map<String, String> { /* * Complain about duplicates, if that is wanted. */ - if (!allowDuplicates && containsKey(name)) { + if(!allowDuplicates && containsKey(name)) { final String msg = String.format("Duplicate key '%s'", name); throw new IllegalStateException(msg); @@ -87,7 +87,7 @@ public class SimpleProperties implements Map<String, String> { public void outputProperties() { System.out.println("Read properties:"); - for (final Entry<String, String> entry : entrySet()) { + for(final Entry<String, String> entry : entrySet()) { System.out.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 15f3510..1bf6b46 100644 --- a/base/src/main/java/bjc/utils/ioutils/blocks/Block.java +++ b/base/src/main/java/bjc/utils/ioutils/blocks/Block.java @@ -31,13 +31,13 @@ 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) { this.contents = contents; @@ -61,20 +61,20 @@ public class Block { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof Block)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof Block)) return false; final Block other = (Block) obj; - if (blockNo != other.blockNo) return false; + if(blockNo != other.blockNo) return false; - if (contents == null) { - if (other.contents != null) return false; - } else if (!contents.equals(other.contents)) return false; + if(contents == null) { + if(other.contents != null) return false; + } else if(!contents.equals(other.contents)) return false; - if (endLine != other.endLine) return false; - if (startLine != other.startLine) return false; + if(endLine != other.endLine) return false; + if(startLine != other.startLine) return false; return true; } 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 3c695c6..bf402f5 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> { * 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 8bbb89c..f1dfc3c 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,10 +55,10 @@ 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. */ @@ -70,8 +70,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/LayeredBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/LayeredBlockReader.java index 967a1f2..af138e7 100644 --- a/base/src/main/java/bjc/utils/ioutils/blocks/LayeredBlockReader.java +++ b/base/src/main/java/bjc/utils/ioutils/blocks/LayeredBlockReader.java @@ -17,8 +17,8 @@ public class LayeredBlockReader implements BlockReader { /* * The readers to drain from. */ - private final BlockReader first; - private final BlockReader second; + private final BlockReader first; + private final BlockReader second; /* * The current block number. @@ -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; @@ -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/SerialBlockReader.java b/base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java index c229da1..62db3a8 100644 --- a/base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java +++ b/base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java @@ -18,18 +18,17 @@ 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) { - 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. @@ -40,10 +39,10 @@ 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) { + } catch(final IOException ioex) { throw new IllegalStateException("Exception thrown by discarded reader", ioex); } @@ -56,22 +55,23 @@ public class SerialBlockReader implements BlockReader { @Override public Block getBlock() { - if (readerQueue.isEmpty()) + if(readerQueue.isEmpty()) return null; - else return readerQueue.peek().getBlock(); + else + return readerQueue.peek().getBlock(); } @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) { + } catch(final IOException ioex) { throw new IllegalStateException("Exception thrown by discarded reader", ioex); } @@ -79,7 +79,7 @@ public class SerialBlockReader implements BlockReader { cont = gotBlock || readerQueue.isEmpty(); } - if (cont) { + if(cont) { blockNo += 1; } @@ -93,7 +93,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 7985de2..6536d0c 100644 --- a/base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java +++ b/base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java @@ -7,6 +7,7 @@ import java.util.Scanner; import java.util.regex.Pattern; import bjc.utils.funcutils.StringUtils; + /** * Simple implementation of {@link BlockReader} * @@ -30,18 +31,18 @@ public class SimpleBlockReader implements BlockReader { /* * Info about the current block. */ - private int blockNo; - private int lineNo; + private int blockNo; + private int lineNo; /** * 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); @@ -80,7 +81,7 @@ public class SimpleBlockReader implements BlockReader { currBlock = new Block(blockNo, blockContents, blockStartLine, blockEndLine); return true; - } catch (final NoSuchElementException nseex) { + } catch(final NoSuchElementException nseex) { currBlock = null; return false; @@ -101,7 +102,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); 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 8f39b8f..cac0416 100644 --- a/base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java +++ b/base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java @@ -5,8 +5,8 @@ import java.io.IOException; import bjc.utils.data.BooleanToggle; public class ToggledBlockReader implements BlockReader { - private BlockReader leftSource; - private BlockReader rightSource; + private BlockReader leftSource; + private BlockReader rightSource; /* * We choose the left source when this is true. @@ -16,7 +16,7 @@ public class ToggledBlockReader implements BlockReader { private int blockNo; public ToggledBlockReader(BlockReader left, BlockReader right) { - leftSource = left; + leftSource = left; rightSource = right; blockNo = 0; @@ -26,14 +26,18 @@ public class ToggledBlockReader implements BlockReader { @Override public boolean hasNextBlock() { - if(leftToggle.peek()) return leftSource.hasNextBlock(); - else return rightSource.hasNextBlock(); + if(leftToggle.peek()) + return leftSource.hasNextBlock(); + else + return rightSource.hasNextBlock(); } @Override public Block getBlock() { - if(leftToggle.peek()) return leftSource.getBlock(); - else return rightSource.getBlock(); + if(leftToggle.peek()) + return leftSource.getBlock(); + else + return rightSource.getBlock(); } @Override @@ -54,7 +58,7 @@ public class ToggledBlockReader implements BlockReader { public int getBlockCount() { return blockNo; } - + @Override public void close() throws IOException { leftSource.close(); 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 3a1e393..a066f9c 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/format/AestheticDirective.java b/base/src/main/java/bjc/utils/ioutils/format/AestheticDirective.java index 9cc10d2..16d9d12 100644 --- a/base/src/main/java/bjc/utils/ioutils/format/AestheticDirective.java +++ b/base/src/main/java/bjc/utils/ioutils/format/AestheticDirective.java @@ -10,15 +10,15 @@ class AestheticDirective implements Directive { public void format(StringBuffer sb, Object item, CLModifiers mods, CLParameters params, Tape<Object> tParams, Matcher dirMatcher, CLFormatter fmt) { CLFormatter.checkItem(item, 'A'); - + int mincol = 0, colinc = 1, minpad = 0; char padchar = ' '; - if (params.length() > 1) { + if(params.length() > 1) { mincol = params.getIntDefault(0, "minimum column count", 'A', 0); } - if (params.length() < 4) { + if(params.length() < 4) { throw new IllegalArgumentException( "Must provide either zero, one or four arguments to A directive"); } @@ -29,13 +29,13 @@ class AestheticDirective implements Directive { StringBuilder work = new StringBuilder(); - if (mods.atMod) { - for (int i = 0; i < minpad; i++) { + if(mods.atMod) { + for(int i = 0; i < minpad; i++) { work.append(padchar); } - for (int i = work.length(); i < mincol; i++) { - for (int k = 0; k < colinc; k++) { + for(int i = work.length(); i < mincol; i++) { + for(int k = 0; k < colinc; k++) { work.append(padchar); } } @@ -43,18 +43,18 @@ class AestheticDirective implements Directive { work.append(item.toString()); - if (!mods.atMod) { - for (int i = 0; i < minpad; i++) { + if(!mods.atMod) { + for(int i = 0; i < minpad; i++) { work.append(padchar); } - for (int i = work.length(); i < mincol; i++) { - for (int k = 0; k < colinc; k++) { + for(int i = work.length(); i < mincol; i++) { + for(int k = 0; k < colinc; k++) { work.append(padchar); } } } - + tParams.right(); } diff --git a/base/src/main/java/bjc/utils/ioutils/format/CLParameters.java b/base/src/main/java/bjc/utils/ioutils/format/CLParameters.java index 5bdcbbf..2588446 100644 --- a/base/src/main/java/bjc/utils/ioutils/format/CLParameters.java +++ b/base/src/main/java/bjc/utils/ioutils/format/CLParameters.java @@ -126,7 +126,7 @@ public class CLParameters { return param.charAt(1); } - + /** * Get an optional integer parameter with a default value. * @@ -148,7 +148,7 @@ public class CLParameters { return def; } - + /** * Get a mandatory integer parameter. * diff --git a/base/src/main/java/bjc/utils/ioutils/format/CharacterDirective.java b/base/src/main/java/bjc/utils/ioutils/format/CharacterDirective.java index 7ff74bb..91ddabe 100644 --- a/base/src/main/java/bjc/utils/ioutils/format/CharacterDirective.java +++ b/base/src/main/java/bjc/utils/ioutils/format/CharacterDirective.java @@ -11,7 +11,7 @@ class CharacterDirective implements Directive { public void format(StringBuffer buff, Object parm, CLModifiers mods, CLParameters arrParams, Tape<Object> tParams, Matcher dirMatcher, CLFormatter fmt) { CLFormatter.checkItem(parm, 'C'); - + if(!(parm instanceof Character)) { throw new IllegalFormatConversionException('C', parm.getClass()); } @@ -27,7 +27,7 @@ class CharacterDirective implements Directive { } else { buff.append(ch); } - + tParams.right(); } diff --git a/base/src/main/java/bjc/utils/ioutils/format/EscapeDirective.java b/base/src/main/java/bjc/utils/ioutils/format/EscapeDirective.java index 4f44479..8db3a86 100644 --- a/base/src/main/java/bjc/utils/ioutils/format/EscapeDirective.java +++ b/base/src/main/java/bjc/utils/ioutils/format/EscapeDirective.java @@ -7,8 +7,8 @@ import java.util.regex.Matcher; class EscapeDirective implements Directive { @Override - public void format(StringBuffer sb, Object item, CLModifiers mods, CLParameters params, Tape<Object> formatParams, - Matcher dirMatcher, CLFormatter fmt) { + public void format(StringBuffer sb, Object item, CLModifiers mods, CLParameters params, + Tape<Object> formatParams, Matcher dirMatcher, CLFormatter fmt) { boolean shouldExit; switch(params.length()) { diff --git a/base/src/main/java/bjc/utils/ioutils/format/GotoDirective.java b/base/src/main/java/bjc/utils/ioutils/format/GotoDirective.java index b09053e..767a77e 100644 --- a/base/src/main/java/bjc/utils/ioutils/format/GotoDirective.java +++ b/base/src/main/java/bjc/utils/ioutils/format/GotoDirective.java @@ -7,8 +7,8 @@ import java.util.regex.Matcher; class GotoDirective implements Directive { @Override - public void format(StringBuffer sb, Object item, CLModifiers mods, CLParameters params, Tape<Object> formatParams, - Matcher dirMatcher, CLFormatter fmt) { + public void format(StringBuffer sb, Object item, CLModifiers mods, CLParameters params, + Tape<Object> formatParams, Matcher dirMatcher, CLFormatter fmt) { if(mods.colonMod) { int num = 1; if(params.length() > 1) { diff --git a/base/src/main/java/bjc/utils/ioutils/format/IterationDirective.java b/base/src/main/java/bjc/utils/ioutils/format/IterationDirective.java index e13cb1c..81ce611 100644 --- a/base/src/main/java/bjc/utils/ioutils/format/IterationDirective.java +++ b/base/src/main/java/bjc/utils/ioutils/format/IterationDirective.java @@ -51,11 +51,11 @@ class IterationDirective implements Directive { } int maxItr = Integer.MAX_VALUE; - + if(arrParams.length() > 0) { maxItr = arrParams.getInt(0, "maximum iterations", '{'); } - + if(mods.atMod && mods.colonMod) { } else if(mods.atMod) { diff --git a/base/src/main/java/bjc/utils/ioutils/format/LiteralDirective.java b/base/src/main/java/bjc/utils/ioutils/format/LiteralDirective.java index 77d26cc..5110a9b 100644 --- a/base/src/main/java/bjc/utils/ioutils/format/LiteralDirective.java +++ b/base/src/main/java/bjc/utils/ioutils/format/LiteralDirective.java @@ -6,15 +6,14 @@ import java.util.regex.Matcher; class LiteralDirective implements Directive { - private char directive; - private String lit; + private char directive; + private String lit; public LiteralDirective(String lit, char directive) { this.directive = directive; this.lit = lit; } - @Override public void format(StringBuffer buff, Object item, CLModifiers mods, CLParameters params, Tape<Object> tParams, Matcher dirMatcher, CLFormatter fmt) { diff --git a/base/src/main/java/bjc/utils/ioutils/format/RadixDirective.java b/base/src/main/java/bjc/utils/ioutils/format/RadixDirective.java index 3742582..668a0bd 100644 --- a/base/src/main/java/bjc/utils/ioutils/format/RadixDirective.java +++ b/base/src/main/java/bjc/utils/ioutils/format/RadixDirective.java @@ -12,7 +12,7 @@ class RadixDirective extends GeneralNumberDirective { public void format(StringBuffer buff, Object arg, CLModifiers mods, CLParameters params, Tape<Object> tParams, Matcher dirMatcher, CLFormatter fmt) { CLFormatter.checkItem(arg, 'R'); - + if(!(arg instanceof Number)) { throw new IllegalFormatConversionException('R', arg.getClass()); } @@ -38,7 +38,7 @@ class RadixDirective extends GeneralNumberDirective { handleNumberDirective(buff, mods, params, 0, val, radix); } - + tParams.right(); } } |
