summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/ioutils
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2021-07-12 15:58:34 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2021-07-12 15:58:34 -0300
commita732ae9404c0b7ba446d40bffb246ec43aad603c (patch)
tree931a49908e951471e751e352c8baa3142019bb6b /base/src/main/java/bjc/utils/ioutils
parenta24c1042499f76ff2d442ae133ef165011a7af4c (diff)
parentaba8e262d0e89ebef4229ad807b67660fc9bef35 (diff)
Merge & Update
Diffstat (limited to 'base/src/main/java/bjc/utils/ioutils')
-rw-r--r--base/src/main/java/bjc/utils/ioutils/LevelSplitter.java49
-rw-r--r--base/src/main/java/bjc/utils/ioutils/LineReader.java18
-rw-r--r--base/src/main/java/bjc/utils/ioutils/SimpleProperties.java12
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/package-info.java22
4 files changed, 49 insertions, 52 deletions
diff --git a/base/src/main/java/bjc/utils/ioutils/LevelSplitter.java b/base/src/main/java/bjc/utils/ioutils/LevelSplitter.java
index 22cf2c5..e808bec 100644
--- a/base/src/main/java/bjc/utils/ioutils/LevelSplitter.java
+++ b/base/src/main/java/bjc/utils/ioutils/LevelSplitter.java
@@ -5,29 +5,24 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-/**
- * Splits a string on a delimiter, respecting grouping delimiters.
+/** Splits a string on a delimiter, respecting grouping delimiters.
*
* By default, grouping delimiters are (), [], {}, and &lt;&gt;, as well as single and
* double quoted strings.
*
- * @author bjculkin
- *
- */
+ * @author bjculkin */
public class LevelSplitter {
- /**
- * Defaultly configured level splitter.
- */
+ /** Default configured level splitter. */
public final static LevelSplitter def = new LevelSplitter();
- /**
- * Check if a string contains any one of a specified number of things,
+ /** Should empty strings be ignored? */
+ public boolean ignoreEmpty = false;
+
+ /** Check if a string contains any one of a specified number of things,
* respecting groups.
*
- * @param haystack
- * The string to look in.
- * @param needles
- * The strings to look for.
+ * @param haystack The string to look in.
+ * @param needles The strings to look for.
* @return Whether or not any of the strings were contained outside of groups.
*/
public boolean levelContains(String haystack, String... needles) {
@@ -88,13 +83,11 @@ public class LevelSplitter {
return false;
}
- /**
- * Split a string, respecting groups.
+ /** Split a string, respecting groups.
*
- * @param phrase
- * The string to split.
- * @param splits
- * The strings to split on.
+ * @param phrase The string to split.
+ * @param splits The strings to split on.
+ *
* @return A list of split strings. If keepDelims is true, it also includes the
* delimiters in between the split strings.
*/
@@ -102,15 +95,12 @@ public class LevelSplitter {
return levelSplit(phrase, false, splits);
}
- /**
- * Split a string, respecting groups.
+ /** Split a string, respecting groups.
*
- * @param phrase
- * The string to split.
- * @param keepDelims
- * Whether or not to include the delimiters in the results.
- * @param splits
- * The strings to split on.
+ * @param phrase The string to split.
+ * @param keepDelims Whether or not to include the delimiters in the results.
+ * @param splits The strings to split on.
+ *
* @return A list of split strings. If keepDelims is true, it also includes the
* delimiters in between the split strings.
*/
@@ -140,8 +130,7 @@ public class LevelSplitter {
if (work.regionMatches(i, split, 0, split.length())) {
strangs.add(work.substring(0, i));
- if (keepDelims)
- strangs.add(split);
+ if (keepDelims) strangs.add(split);
work = work.substring(i + split.length());
i = 0;
diff --git a/base/src/main/java/bjc/utils/ioutils/LineReader.java b/base/src/main/java/bjc/utils/ioutils/LineReader.java
deleted file mode 100644
index 2ac2797..0000000
--- a/base/src/main/java/bjc/utils/ioutils/LineReader.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package bjc.utils.ioutils;
-
-/**
- * A line reader
- *
- * @author bjculkin
- *
- */
-public class LineReader implements AutoCloseable {
- //private Scanner scn;
-
- @Override
- public void close() {
- //scn.close();
- }
-
- // @TODO Implement me - ben, 1/6/20
-}
diff --git a/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java b/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java
index 754ed45..d380866 100644
--- a/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java
+++ b/base/src/main/java/bjc/utils/ioutils/SimpleProperties.java
@@ -170,17 +170,20 @@ public class SimpleProperties implements Map<String, String> {
return props.isEmpty();
}
- @Override
+ @SuppressWarnings("unlikely-arg-type")
+ @Override
public boolean containsKey(final Object key) {
return props.containsKey(key);
}
- @Override
+ @SuppressWarnings("unlikely-arg-type")
+ @Override
public boolean containsValue(final Object value) {
return props.containsValue(value);
}
- @Override
+ @SuppressWarnings("unlikely-arg-type")
+ @Override
public String get(final Object key) {
return props.get(key);
}
@@ -190,7 +193,8 @@ public class SimpleProperties implements Map<String, String> {
return props.put(key, value);
}
- @Override
+ @SuppressWarnings("unlikely-arg-type")
+ @Override
public String remove(final Object key) {
return props.remove(key);
}
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/package-info.java b/base/src/main/java/bjc/utils/ioutils/blocks/package-info.java
new file mode 100644
index 0000000..3d05ed4
--- /dev/null
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/package-info.java
@@ -0,0 +1,22 @@
+/** This package contains a number of classes useful for processing input that
+ * is structured as a series of 'blocks' or records.
+ * <p>
+ *
+ * The most fundamental unit here is that of {@link Block}. Each {@link
+ * BlockReader} will yield a sequence of these, which contain a piece of text
+ * as its contents, as well as the beginning/ending line for that block.
+ *
+ * There are a number of different types of {@link BlockReader}, which are
+ * summarized here.
+ * </p>
+ *
+ * <dl>
+ * <dt>{@link SimpleBlockReader}</dt>
+ * <dd>
+ * The most basic form of BlockReader. This uses a regular expression to
+ * delimit input reader from a {@link Reader} into a series of blocks.
+ * Listed first, because this is
+ * </dd>
+ * </dl>
+ * @author Ben Culkin */
+package bjc.utils.ioutils.blocks;