summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2018-02-12 22:57:29 -0500
committerbjculkin <bjculkin@mix.wvu.edu>2018-02-12 22:57:29 -0500
commit040870eced4dc3e273313b9ec2ce7bb88d9cc6a0 (patch)
tree4712f4fc1dd1c6bccac7a1de98921f78ec6d326a /base/src/main/java/bjc/utils
parentdf94066e3af02ff02d5ab4d033a3d603f743234c (diff)
Commenting
Diffstat (limited to 'base/src/main/java/bjc/utils')
-rw-r--r--base/src/main/java/bjc/utils/data/TopDownTransformIterator.java1
-rw-r--r--base/src/main/java/bjc/utils/data/Tree.java16
-rw-r--r--base/src/main/java/bjc/utils/data/ValueToggle.java8
-rw-r--r--base/src/main/java/bjc/utils/data/internals/WrappedLazy.java5
-rw-r--r--base/src/main/java/bjc/utils/data/internals/WrappedOption.java4
-rw-r--r--base/src/main/java/bjc/utils/esodata/PushdownMap.java14
-rw-r--r--base/src/main/java/bjc/utils/esodata/SingleTape.java3
-rw-r--r--base/src/main/java/bjc/utils/funcdata/IMap.java2
-rw-r--r--base/src/main/java/bjc/utils/funcutils/StringUtils.java5
-rw-r--r--base/src/main/java/bjc/utils/funcutils/TreeUtils.java8
-rw-r--r--base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java8
-rw-r--r--base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java26
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java7
-rw-r--r--base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java28
-rw-r--r--base/src/main/java/bjc/utils/parserutils/StringDescaper.java28
-rw-r--r--base/src/main/java/bjc/utils/parserutils/defines/SimpleDefine.java14
-rw-r--r--base/src/main/java/bjc/utils/parserutils/splitter/SimpleTokenSplitter.java7
17 files changed, 131 insertions, 53 deletions
diff --git a/base/src/main/java/bjc/utils/data/TopDownTransformIterator.java b/base/src/main/java/bjc/utils/data/TopDownTransformIterator.java
index 8f3e40c..d4a676c 100644
--- a/base/src/main/java/bjc/utils/data/TopDownTransformIterator.java
+++ b/base/src/main/java/bjc/utils/data/TopDownTransformIterator.java
@@ -12,6 +12,7 @@ import java.util.function.Function;
/*
* @TODO 10/11/17 Ben Culkin :TopDownStep
+ *
* Figure out what is broken with this, and fix it so that step-wise
* iteration works correctly.
*/
diff --git a/base/src/main/java/bjc/utils/data/Tree.java b/base/src/main/java/bjc/utils/data/Tree.java
index 6b7e03a..f7ff90a 100644
--- a/base/src/main/java/bjc/utils/data/Tree.java
+++ b/base/src/main/java/bjc/utils/data/Tree.java
@@ -140,13 +140,13 @@ public class Tree<ContainedType> implements ITree<ContainedType> {
public int revFind(final Predicate<ITree<ContainedType>> childPred) {
if(childCount == 0) {
return -1;
- } else {
- for(int i = childCount - 1; i >= 0; i--) {
- if(childPred.test(getChild(i))) return i;
- }
+ }
- return -1;
+ for(int i = childCount - 1; i >= 0; i--) {
+ if(childPred.test(getChild(i))) return i;
}
+
+ return -1;
}
@Override
@@ -234,8 +234,10 @@ public class Tree<ContainedType> implements ITree<ContainedType> {
}
protected void internalToString(final StringBuilder builder, final int indentLevel, final boolean initial) {
- for(int i = 0; i < indentLevel; i++) {
- builder.append(">\t");
+ if(!initial) {
+ for(int i = 0; i < indentLevel; i++) {
+ builder.append(">\t");
+ }
}
builder.append("Node #");
diff --git a/base/src/main/java/bjc/utils/data/ValueToggle.java b/base/src/main/java/bjc/utils/data/ValueToggle.java
index 09f314c..0fddddf 100644
--- a/base/src/main/java/bjc/utils/data/ValueToggle.java
+++ b/base/src/main/java/bjc/utils/data/ValueToggle.java
@@ -39,18 +39,18 @@ public class ValueToggle<E> implements Toggle<E> {
public E get() {
if(alignment.get()) {
return lft;
- } else {
- return rght;
}
+
+ return rght;
}
@Override
public E peek() {
if(alignment.peek()) {
return lft;
- } else {
- return rght;
}
+
+ return rght;
}
@Override
diff --git a/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java b/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java
index 57f9302..c08e502 100644
--- a/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java
+++ b/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java
@@ -10,6 +10,8 @@ import bjc.utils.data.Lazy;
* A wrapped lazy value.
*
* @author Ben Culkin
+ * @param <ContainedType>
+ * The type of the wrapped value.
*/
public class WrappedLazy<ContainedType> implements IHolder<ContainedType> {
/* Held value. */
@@ -33,7 +35,8 @@ public class WrappedLazy<ContainedType> implements IHolder<ContainedType> {
* the compiler could know which one we meant without the dummy
* parameter.
*/
- private WrappedLazy(final IHolder<IHolder<ContainedType>> wrappedHolder, final boolean dummy) {
+ private WrappedLazy(final IHolder<IHolder<ContainedType>> wrappedHolder,
+ @SuppressWarnings("unused") final boolean dummy) {
held = wrappedHolder;
}
diff --git a/base/src/main/java/bjc/utils/data/internals/WrappedOption.java b/base/src/main/java/bjc/utils/data/internals/WrappedOption.java
index 6260ce4..b2fe71f 100644
--- a/base/src/main/java/bjc/utils/data/internals/WrappedOption.java
+++ b/base/src/main/java/bjc/utils/data/internals/WrappedOption.java
@@ -10,6 +10,7 @@ import bjc.utils.data.Option;
* A wrapped optional value.
*
* @author Ben Culkin.
+ * @param <ContainedType> The wrapped type.
*/
public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
/* The held value. */
@@ -30,7 +31,8 @@ public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
* method, because without this method erases to the same type as the
* public one.
*/
- private WrappedOption(final IHolder<IHolder<ContainedType>> toHold, final boolean dummy) {
+ private WrappedOption(final IHolder<IHolder<ContainedType>> toHold,
+ @SuppressWarnings("unused") final boolean dummy) {
held = toHold;
}
diff --git a/base/src/main/java/bjc/utils/esodata/PushdownMap.java b/base/src/main/java/bjc/utils/esodata/PushdownMap.java
index e010fee..35dcf2d 100644
--- a/base/src/main/java/bjc/utils/esodata/PushdownMap.java
+++ b/base/src/main/java/bjc/utils/esodata/PushdownMap.java
@@ -101,13 +101,13 @@ public class PushdownMap<KeyType, ValueType> implements IMap<KeyType, ValueType>
stk.push(val);
return vl;
- } else {
- final Stack<ValueType> stk = new SimpleStack<>();
+ }
- stk.push(val);
+ final Stack<ValueType> stk = new SimpleStack<>();
- return null;
- }
+ stk.push(val);
+
+ return null;
}
@Override
@@ -116,9 +116,9 @@ public class PushdownMap<KeyType, ValueType> implements IMap<KeyType, ValueType>
if(stk.size() > 1) {
return stk.pop();
- } else {
- return backing.remove(key).top();
}
+
+ return backing.remove(key).top();
}
@Override
diff --git a/base/src/main/java/bjc/utils/esodata/SingleTape.java b/base/src/main/java/bjc/utils/esodata/SingleTape.java
index 57ee99a..5218269 100644
--- a/base/src/main/java/bjc/utils/esodata/SingleTape.java
+++ b/base/src/main/java/bjc/utils/esodata/SingleTape.java
@@ -35,6 +35,9 @@ public class SingleTape<T> implements Tape<T> {
/**
* Create a new tape with the specified contents that doesn't
* autoextend.
+ *
+ * @param vals
+ * The values to put on the tape.
*/
@SafeVarargs
public SingleTape(T... vals) {
diff --git a/base/src/main/java/bjc/utils/funcdata/IMap.java b/base/src/main/java/bjc/utils/funcdata/IMap.java
index 9449898..848ec1c 100644
--- a/base/src/main/java/bjc/utils/funcdata/IMap.java
+++ b/base/src/main/java/bjc/utils/funcdata/IMap.java
@@ -80,7 +80,7 @@ public interface IMap<KeyType, ValueType> {
default ValueType getOrDefault(final KeyType key, final ValueType defaultValue) {
try {
return get(key);
- } catch(@SuppressWarnings("unused") final IllegalArgumentException iaex) {
+ } catch(final IllegalArgumentException iaex) {
/*
* We don't care about this, because it indicates a key
* is missing.
diff --git a/base/src/main/java/bjc/utils/funcutils/StringUtils.java b/base/src/main/java/bjc/utils/funcutils/StringUtils.java
index fa7e59e..e753abd 100644
--- a/base/src/main/java/bjc/utils/funcutils/StringUtils.java
+++ b/base/src/main/java/bjc/utils/funcutils/StringUtils.java
@@ -161,9 +161,9 @@ public class StringUtils {
public static String toEnglishList(final Object[] objects, final boolean and) {
if(and) {
return toEnglishList(objects, "and");
- } else {
- return toEnglishList(objects, "or");
}
+
+ return toEnglishList(objects, "or");
}
/**
@@ -194,6 +194,7 @@ public class StringUtils {
*
* @param pattern
* The pattern to count occurances of.
+ * @return The number of times the pattern matches.
*/
public static int countMatches(final String value, final String pattern) {
Matcher mat = Pattern.compile(pattern).matcher(value);
diff --git a/base/src/main/java/bjc/utils/funcutils/TreeUtils.java b/base/src/main/java/bjc/utils/funcutils/TreeUtils.java
index 1bdd7b3..ac8bb69 100644
--- a/base/src/main/java/bjc/utils/funcutils/TreeUtils.java
+++ b/base/src/main/java/bjc/utils/funcutils/TreeUtils.java
@@ -13,9 +13,15 @@ import bjc.utils.funcdata.IList;
* @author Benjamin Culkin
*/
public class TreeUtils {
- /*
+ /**
* Convert a tree into a list of outline nodes that match a certain
* path.
+ *
+ * @param tre
+ * The tree to outline.
+ * @param leafMarker
+ * The path to mark nodes with.
+ * @return The list of marked paths.
*/
public static <T> IList<IList<T>> outlineTree(ITree<T> tre, Predicate<T> leafMarker) {
IList<IList<T>> paths = new FunctionalList<>();
diff --git a/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java b/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java
index e11d4b4..9f81001 100644
--- a/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java
+++ b/base/src/main/java/bjc/utils/ioutils/RegexStringEditor.java
@@ -198,9 +198,9 @@ public class RegexStringEditor {
if(matcher.matches()) {
return action.apply(input);
- } else {
- return input;
}
+
+ return input;
}
/**
@@ -223,8 +223,8 @@ public class RegexStringEditor {
if(matcher.matches()) {
return input;
- } else {
- return action.apply(input);
}
+
+ return action.apply(input);
}
}
diff --git a/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java b/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java
index 9e4bbb6..9b46c06 100644
--- a/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/RuleBasedConfigReader.java
@@ -101,27 +101,27 @@ public class RuleBasedConfigReader<E> {
/*
* Ignore blank line without an open rule
*/
- if(isRuleOpen == false)
+ if(isRuleOpen == false) {
/*
* Do nothing
*/
return false;
- else {
- /*
- * Nothing happens on rule end
- */
- if(end != null) {
- /*
- * Process the rule ending
- */
- end.accept(state);
- }
+ }
+ /*
+ * Nothing happens on rule end
+ */
+ if(end != null) {
/*
- * Return a closed rule
+ * Process the rule ending
*/
- return false;
+ end.accept(state);
}
+
+ /*
+ * Return a closed rule
+ */
+ return false;
}
/**
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 62db3a8..02483c1 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/SerialBlockReader.java
@@ -55,10 +55,11 @@ public class SerialBlockReader implements BlockReader {
@Override
public Block getBlock() {
- if(readerQueue.isEmpty())
+ if(readerQueue.isEmpty()) {
return null;
- else
- return readerQueue.peek().getBlock();
+ }
+
+ return readerQueue.peek().getBlock();
}
@Override
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 cac0416..0b756c5 100644
--- a/base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java
+++ b/base/src/main/java/bjc/utils/ioutils/blocks/ToggledBlockReader.java
@@ -4,6 +4,12 @@ import java.io.IOException;
import bjc.utils.data.BooleanToggle;
+/**
+ * A block reader that toggles between two sources.
+ *
+ * @author EVE
+ *
+ */
public class ToggledBlockReader implements BlockReader {
private BlockReader leftSource;
private BlockReader rightSource;
@@ -15,6 +21,14 @@ public class ToggledBlockReader implements BlockReader {
private int blockNo;
+ /**
+ * Create a new toggling block reader.
+ *
+ * @param left
+ * The first block reader to use.
+ * @param right
+ * The second block reader to use.
+ */
public ToggledBlockReader(BlockReader left, BlockReader right) {
leftSource = left;
rightSource = right;
@@ -26,18 +40,20 @@ public class ToggledBlockReader implements BlockReader {
@Override
public boolean hasNextBlock() {
- if(leftToggle.peek())
+ if(leftToggle.peek()) {
return leftSource.hasNextBlock();
- else
- return rightSource.hasNextBlock();
+ }
+
+ return rightSource.hasNextBlock();
}
@Override
public Block getBlock() {
- if(leftToggle.peek())
+ if(leftToggle.peek()) {
return leftSource.getBlock();
- else
- return rightSource.getBlock();
+ }
+
+ return rightSource.getBlock();
}
@Override
diff --git a/base/src/main/java/bjc/utils/parserutils/StringDescaper.java b/base/src/main/java/bjc/utils/parserutils/StringDescaper.java
index 59f4760..0beb7c8 100644
--- a/base/src/main/java/bjc/utils/parserutils/StringDescaper.java
+++ b/base/src/main/java/bjc/utils/parserutils/StringDescaper.java
@@ -12,6 +12,12 @@ import static java.util.Map.Entry;
import static bjc.utils.PropertyDB.getRegex;
+/**
+ * Customizable string descaping.
+ *
+ * @author EVE
+ *
+ */
public class StringDescaper {
private Logger LOGGER = Logger.getLogger(StringDescaper.class.getName());
@@ -37,6 +43,9 @@ public class StringDescaper {
private Map<String, String> literalEscapes;
private Map<Pattern, UnaryOperator<String>> specialEscapes;
+ /**
+ * Create a new string descaper.
+ */
public StringDescaper() {
literalEscapes = new HashMap<>();
specialEscapes = new HashMap<>();
@@ -45,6 +54,14 @@ public class StringDescaper {
escapePatt = Pattern.compile(rEscapeString);
}
+ /**
+ * Add a new literal string escape.
+ *
+ * @param escape
+ * The escape to add.
+ * @param val
+ * The value for the escape.
+ */
public void addLiteralEscape(String escape, String val) {
if(literalEscapes.containsKey(escape)) {
LOGGER.warning(String.format("Shadowing literal escape '%s'\n", escape));
@@ -53,6 +70,14 @@ public class StringDescaper {
literalEscapes.put(escape, val);
}
+ /**
+ * Create a new custom escape.
+ *
+ * @param escape
+ * The escape to add.
+ * @param val
+ * The implementation of the escape.
+ */
public void addSpecialEscape(String escape, UnaryOperator<String> val) {
/*
* Make sure this special escape is a valid regex.
@@ -77,6 +102,9 @@ public class StringDescaper {
specialEscapes.put(patt, val);
}
+ /**
+ * Compile the escapes.
+ */
public void compileEscapes() {
StringBuilder work = new StringBuilder();
diff --git a/base/src/main/java/bjc/utils/parserutils/defines/SimpleDefine.java b/base/src/main/java/bjc/utils/parserutils/defines/SimpleDefine.java
index 5d206bd..d42f7d8 100644
--- a/base/src/main/java/bjc/utils/parserutils/defines/SimpleDefine.java
+++ b/base/src/main/java/bjc/utils/parserutils/defines/SimpleDefine.java
@@ -4,10 +4,24 @@ import java.util.function.UnaryOperator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * A simple match-and-replace operation on strings.
+ *
+ * @author EVE
+ *
+ */
public class SimpleDefine implements UnaryOperator<String> {
private Pattern patt;
private String repl;
+ /**
+ * Create a new simple define.
+ *
+ * @param pattern
+ * The pattern to look for.
+ * @param replace
+ * The thing to replace it with.
+ */
public SimpleDefine(Pattern pattern, String replace) {
patt = pattern;
diff --git a/base/src/main/java/bjc/utils/parserutils/splitter/SimpleTokenSplitter.java b/base/src/main/java/bjc/utils/parserutils/splitter/SimpleTokenSplitter.java
index c96f72a..4e97008 100644
--- a/base/src/main/java/bjc/utils/parserutils/splitter/SimpleTokenSplitter.java
+++ b/base/src/main/java/bjc/utils/parserutils/splitter/SimpleTokenSplitter.java
@@ -34,10 +34,11 @@ public class SimpleTokenSplitter implements TokenSplitter {
@Override
public IList<String> split(final String input) {
- if(keepDelim)
+ if(keepDelim) {
return RegexStringEditor.mapOccurances(input, spliter, ID.id(), ID.id());
- else
- return RegexStringEditor.mapOccurances(input, spliter, ID.id(), strang -> "");
+ }
+
+ return RegexStringEditor.mapOccurances(input, spliter, ID.id(), strang -> "");
}
@Override