diff options
Diffstat (limited to 'base/src/main/java/bjc')
| -rw-r--r-- | base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java | 22 | ||||
| -rw-r--r-- | base/src/main/java/bjc/utils/math/DualExpr.java | 18 |
2 files changed, 31 insertions, 9 deletions
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 3814e41..7f02987 100644 --- a/base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java +++ b/base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java @@ -55,6 +55,28 @@ public class SimpleBlockReader implements BlockReader { lineNo = 1; } + /** + * 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. + * + * @param source + * The source to read blocks from. + * NOTE: This does modify the provided scanner. + */ + public SimpleBlockReader(final String blockDelim, final Scanner source) { + blockReader = source; + + final String pattern = String.format("(?:%s)|\\Z", blockDelim); + final Pattern pt = Pattern.compile(pattern, Pattern.MULTILINE); + + blockReader.useDelimiter(pt); + + lineNo = 1; + } + @Override public boolean hasNextBlock() { return blockReader.hasNext(); diff --git a/base/src/main/java/bjc/utils/math/DualExpr.java b/base/src/main/java/bjc/utils/math/DualExpr.java index 9a4ed5e..4d21413 100644 --- a/base/src/main/java/bjc/utils/math/DualExpr.java +++ b/base/src/main/java/bjc/utils/math/DualExpr.java @@ -308,6 +308,14 @@ public class DualExpr { return false; } + if(right == null) { + if(other.right != null) { + return false; + } + } else if(!right.equals(other.right)) { + return false; + } + if(number == null) { if(other.number != null) return false; } else if(!number.equals(other.number)) { @@ -318,14 +326,6 @@ public class DualExpr { return false; } - if(right == null) { - if(other.right != null) { - return false; - } - } else if(!right.equals(other.right)) { - return false; - } - return true; } -}
\ No newline at end of file +} |
