summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2018-06-02 19:39:38 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2018-06-02 19:39:38 -0300
commit84bbde06c9d24a1f2422478aa04b0122b3c51c2c (patch)
tree6c3759458f02b81e62bb793874304f5b082bc546 /base/src/main/java/bjc/utils
parent62b4f03236f4ac5f75f637fc11ccc301d922ef1f (diff)
Minor updates
Diffstat (limited to 'base/src/main/java/bjc/utils')
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/SimpleBlockReader.java22
-rw-r--r--base/src/main/java/bjc/utils/math/DualExpr.java18
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
+}