From 84bbde06c9d24a1f2422478aa04b0122b3c51c2c Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Sat, 2 Jun 2018 19:39:38 -0300 Subject: Minor updates --- .../utils/ioutils/blocks/SimpleBlockReader.java | 22 ++++++++++++++++++++++ base/src/main/java/bjc/utils/math/DualExpr.java | 18 +++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) (limited to 'base/src/main') 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 +} -- cgit v1.2.3