From df94066e3af02ff02d5ab4d033a3d603f743234c Mon Sep 17 00:00:00 2001 From: bjculkin Date: Mon, 12 Feb 2018 22:45:04 -0500 Subject: Formatting pass --- .../main/java/bjc/utils/ioutils/blocks/Block.java | 26 +++++++++++----------- .../java/bjc/utils/ioutils/blocks/BlockReader.java | 4 ++-- .../bjc/utils/ioutils/blocks/BlockReaders.java | 17 +++++++------- .../utils/ioutils/blocks/LayeredBlockReader.java | 10 ++++----- .../utils/ioutils/blocks/SerialBlockReader.java | 26 +++++++++++----------- .../utils/ioutils/blocks/SimpleBlockReader.java | 15 +++++++------ .../utils/ioutils/blocks/ToggledBlockReader.java | 20 ++++++++++------- .../utils/ioutils/blocks/TriggeredBlockReader.java | 4 ++-- 8 files changed, 63 insertions(+), 59 deletions(-) (limited to 'base/src/main/java/bjc/utils/ioutils/blocks') 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 { * 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 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; -- cgit v1.2.3