summaryrefslogtreecommitdiff
path: root/clformat/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'clformat/src/main/java')
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java292
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/CLModifiers.java15
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/CLParameters.java5
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/CLPattern.java18
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/CLString.java57
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/CLTokenizer.java9
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/CLValue.java56
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/CaseDirective.java65
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/CompileContext.java15
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/ConditionalDirective.java160
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/Directive.java2
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/EscapeDirective.java2
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatContext.java1
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatParameters.java73
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/GeneralNumberDirective.java17
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/GotoDirective.java2
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/IndentDirective.java5
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/InflectDirective.java6
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/IterationDirective.java2
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/LiteralDirective.java3
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/NumberDirective.java4
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/RadixDirective.java1
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/RecursiveDirective.java8
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/directives/TabulateDirective.java6
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/exceptions/MismatchedFormatArgType.java2
-rw-r--r--clformat/src/main/java/bjc/utils/ioutils/format/exceptions/UnexpectedColonEscape.java5
26 files changed, 524 insertions, 307 deletions
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java
index df01238..d2dd82a 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java
@@ -2,11 +2,8 @@ package bjc.utils.ioutils.format;
import java.io.*;
import java.util.*;
-import java.util.regex.*;
-import bjc.utils.data.*;
import bjc.utils.esodata.*;
-import bjc.utils.funcutils.*;
import bjc.utils.ioutils.*;
import bjc.utils.ioutils.format.directives.*;
@@ -43,8 +40,8 @@ public class CLFormatter {
builtinDirectives.put("C", new CharacterDirective());
- builtinDirectives.put("B", new NumberDirective(-1, 2, 'B'));
- builtinDirectives.put("O", new NumberDirective(-1, 8, 'O'));
+ builtinDirectives.put("B", new NumberDirective(-1, 2, 'B'));
+ builtinDirectives.put("O", new NumberDirective(-1, 8, 'O'));
builtinDirectives.put("D", new NumberDirective(-1, 10, 'D'));
builtinDirectives.put("X", new NumberDirective(-1, 16, 'X'));
@@ -54,7 +51,7 @@ public class CLFormatter {
builtinDirectives.put("%", new LiteralDirective("\n", '%'));
builtinDirectives.put("|", new LiteralDirective("\f", '|'));
- builtinDirectives.put("~", new LiteralDirective("~", '~'));
+ builtinDirectives.put("~", new LiteralDirective("~", '~'));
builtinDirectives.put("?", new RecursiveDirective());
builtinDirectives.put("*", new GotoDirective());
@@ -78,8 +75,8 @@ public class CLFormatter {
}
/*
- * @TODO Ben Culkin 9/24/2019 :checkItem
- * Convert this to return a boolean, not throw an exception.
+ * @TODO Ben Culkin 9/24/2019 :checkItem Convert this to return a
+ * boolean, not throw an exception.
*
* In general, I want to cut down on exceptions, except for where it
* would be very inconvenient to do so (namely, the EscapeException we
@@ -89,16 +86,17 @@ public class CLFormatter {
* Check that an item is valid for a directive.
*
* @param itm
- * The item to check.
+ * The item to check.
*
* @param directive
- * The directive to check for.
+ * The directive to check for.
*
- * @throws IlegalArgumentException if itm is null.
+ * @throws IllegalArgumentException
+ * if itm is null.
*/
public static void checkItem(Object itm, char directive) {
- if(itm == null) {
- String msg = String.format("No argument provided for %c directive", directive);
+ if (itm == null) {
+ String msg = String.format("No argument provided for %c directive", directive);
throw new IllegalArgumentException(msg);
}
@@ -108,33 +106,33 @@ public class CLFormatter {
* Format a string in the style of CL's FORMAT.
*
* @param format
- * The format string to use.
+ * The format string to use.
*
* @param params
- * The parameters for the string.
+ * The parameters for the string.
*
* @return The formatted string.
*
- * @throws IOException if something goes wrong during formatting the
- * string.
+ * @throws IOException
+ * if something goes wrong during formatting the string.
*/
public String formatString(String format, Object... params) throws IOException {
return formatString(format, I(AI(params)));
}
-
+
/**
* Format a string in the style of CL's FORMAT.
*
* @param format
- * The format string to use.
+ * The format string to use.
*
* @param params
- * The parameters for the string.
+ * The parameters for the string.
*
* @return The formatted string.
*
- * @throws IOException if something goes wrong during formatting the
- * string.
+ * @throws IOException
+ * if something goes wrong during formatting the string.
*/
public String formatString(String format, Iterable<Object> params) throws IOException {
ReportWriter rw = new ReportWriter(new StringWriter());
@@ -151,33 +149,42 @@ public class CLFormatter {
* Format a string in the style of CL's FORMAT.
*
* @param target
- * The writer to send output to.
+ * The writer to send output to.
*
* @param format
- * The format string to use.
+ * The format string to use.
*
* @param params
- * The parameters for the string.
+ * The parameters for the string.
+ *
+ * @throws IOException
+ * If something I/O related goes wrong.
*/
public void formatString(Writer target, String format, Object... params) throws IOException {
- ReportWriter rw = new ReportWriter(target);
- /* Put the parameters where we can easily handle them. */
- Tape<Object> tParams = new SingleTape<>(params);
+ try (ReportWriter rw = new ReportWriter(target)) {
+ /*
+ * Put the parameters where we can easily handle them.
+ */
+ Tape<Object> tParams = new SingleTape<>(params);
- doFormatString(format, rw, tParams, true);
+ doFormatString(format, rw, tParams, true);
+ }
}
-
+
/**
* Format a string in the style of CL's FORMAT.
*
* @param target
- * The writer with configured format options to use.
+ * The writer with configured format options to use.
*
* @param format
- * The format string to use.
+ * The format string to use.
*
* @param params
- * The parameters for the string.
+ * The parameters for the string.
+ *
+ * @throws IOException
+ * If something I/O related goes wrong.
*/
public void formatString(ReportWriter target, String format, Object... params) throws IOException {
/* Put the parameters where we can easily handle them. */
@@ -190,13 +197,15 @@ public class CLFormatter {
* Format a string in the style of CL's FORMAT.
*
* @param target
- * The writer to send output to.
+ * The writer to send output to.
*
* @param format
- * The format string to use.
+ * The format string to use.
*
* @param params
- * The parameters for the string.
+ * The parameters for the string.
+ *
+ * @throws IOException If something I/O related goes wrong.
*/
public void formatString(Writer target, String format, Iterable<Object> params) throws IOException {
ReportWriter rw = new ReportWriter(target);
@@ -214,20 +223,22 @@ public class CLFormatter {
* different string.
*
* @param format
- * The format to use.
+ * The format to use.
*
* @param rw
- * The buffer to file output into.
+ * The buffer to file output into.
*
* @param tParams
- * The parameters to use.
+ * The parameters to use.
*
- * @param isToplevel
- * Whether or not this is a top-level format
+ * @param isToplevel
+ * Whether or not this is a top-level format
*
- * @throws IOException If something goes wrong
+ * @throws IOException
+ * If something goes wrong
*/
- public void doFormatString(String format, ReportWriter rw, Tape<Object> tParams, boolean isToplevel) throws IOException {
+ public void doFormatString(String format, ReportWriter rw, Tape<Object> tParams, boolean isToplevel)
+ throws IOException {
CLTokenizer cltok = new CLTokenizer(format);
doFormatString(cltok, rw, tParams, isToplevel);
@@ -240,22 +251,22 @@ public class CLFormatter {
* different string.
*
* @param cltok
- * The place to get tokens from.
+ * The place to get tokens from.
*
* @param rw
- * The buffer to file output into.
+ * The buffer to file output into.
*
* @param tParams
- * The parameters to use.
+ * The parameters to use.
*
- * @param isToplevel
- * Whether or not this is a top-level format
+ * @param isToplevel
+ * Whether or not this is a top-level format
*
- * @throws IOException If something goes wrong
+ * @throws IOException
+ * If something goes wrong
*/
- public void doFormatString(CLTokenizer cltok, ReportWriter rw, Tape<Object> tParams, boolean isToplevel) throws IOException {
- boolean doTail = true;
-
+ public void doFormatString(CLTokenizer cltok, ReportWriter rw, Tape<Object> tParams, boolean isToplevel)
+ throws IOException {
try {
while (cltok.hasNext()) {
Decree decr = cltok.next();
@@ -267,86 +278,98 @@ public class CLFormatter {
Object item = tParams.item();
- if(decr.isUserCall) {
+ if (decr.isUserCall) {
/*
- * @TODO implement user-called functions.
+ * @TODO implement user-called
+ * functions.
*/
continue;
}
- if(extraDirectives.containsKey(decr.name)) {
- FormatParameters params = new FormatParameters(rw, item, decr, tParams, cltok, this);
+ if (extraDirectives.containsKey(decr.name)) {
+ FormatParameters params = new FormatParameters(rw, item, decr, tParams, cltok,
+ this);
extraDirectives.get(decr.name).format(params);
continue;
}
- if(builtinDirectives.containsKey(decr.name)) {
- FormatParameters params = new FormatParameters(rw, item, decr, tParams, cltok, this);
+ if (builtinDirectives.containsKey(decr.name)) {
+ FormatParameters params = new FormatParameters(rw, item, decr, tParams, cltok,
+ this);
- builtinDirectives.get(decr.name).format(params);
+ builtinDirectives.get(decr.name).format(params);
continue;
}
- if(decr.name == null) decr.name = "<null>";
-
- switch(decr.name) {
- case "]":
- throw new IllegalArgumentException("Found conditional-end outside of conditional.");
- case ";":
- throw new IllegalArgumentException(
- "Found seperator outside of block.");
- case "}":
- throw new IllegalArgumentException("Found iteration-end outside of iteration");
- case ")":
- throw new IllegalArgumentException("Case-conversion end outside of case conversion");
- case "`]":
- throw new IllegalArgumentException("Inflection-end outside of inflection");
- case "<":
- case ">":
- throw new IllegalArgumentException("Inflection marker outside of inflection");
- case "`<":
- case "`>":
- throw new IllegalArgumentException("Layout-control directives aren't implemented yet.");
- case "F":
- case "E":
- case "G":
- case "$":
- /* @TODO
- *
- * implement floating point directives.
- */
- throw new IllegalArgumentException("Floating-point directives aren't implemented yet.");
- case "W":
- /*
- * @TODO
- *
- * figure out if we want to
- * implement someting for these
- * directives instead of
- * punting.
- */
- throw new IllegalArgumentException("S and W aren't implemented. Use A instead");
- case "P":
- throw new IllegalArgumentException("These directives aren't implemented yet");
- case "\n":
- /*
- * Ignored newline.
- */
- break;
- default:
- String msg = String.format("Unknown format directive '%s'", decr.name);
- throw new IllegalArgumentException(msg);
+ if (decr.name == null) decr.name = "<null>";
+
+ switch (decr.name) {
+ case "]":
+ throw new IllegalArgumentException(
+ "Found conditional-end outside of conditional.");
+ case ";":
+ throw new IllegalArgumentException("Found seperator outside of block.");
+ case "}":
+ throw new IllegalArgumentException("Found iteration-end outside of iteration");
+ case ")":
+ throw new IllegalArgumentException(
+ "Case-conversion end outside of case conversion");
+ case "`]":
+ throw new IllegalArgumentException("Inflection-end outside of inflection");
+ case "<":
+ case ">":
+ throw new IllegalArgumentException("Inflection marker outside of inflection");
+ case "`<":
+ case "`>":
+ throw new IllegalArgumentException(
+ "Layout-control directives aren't implemented yet.");
+ case "F":
+ case "E":
+ case "G":
+ case "$":
+ /*
+ * @TODO
+ *
+ * implement floating point directives.
+ */
+ throw new IllegalArgumentException(
+ "Floating-point directives aren't implemented yet.");
+ case "W":
+ /*
+ * @TODO
+ *
+ * figure out if we want to implement
+ * someting for these directives instead
+ * of punting.
+ */
+ throw new IllegalArgumentException("S and W aren't implemented. Use A instead");
+ case "P":
+ throw new IllegalArgumentException("These directives aren't implemented yet");
+ case "\n":
+ /*
+ * Ignored newline.
+ */
+ break;
+ default:
+ String msg = String.format("Unknown format directive '%s'", decr.name);
+ throw new IllegalArgumentException(msg);
}
}
} catch (EscapeException eex) {
if (!isToplevel) throw eex;
-
- doTail = false;
}
}
+ /**
+ * Compile a CLString from a string.
+ *
+ * @param inp
+ * The string to compile.
+ *
+ * @return The compiled string.
+ */
public CLString compile(String inp) {
CLTokenizer tokenzer = new CLTokenizer(inp);
@@ -355,14 +378,30 @@ public class CLFormatter {
return new CLString(edts);
}
- public List<Edict> compile(Iterable<Decree> cltok) {
+ /**
+ * Compile a set of decrees into a set of edicts.
+ *
+ * @param decrees
+ * The decrees to compile.
+ *
+ * @return The edicts compiled from the decrees.
+ */
+ public List<Edict> compile(Iterable<Decree> decrees) {
// Not 100% sure this is correct, but the tests are passing
- if (cltok == null) return new ArrayList<>();
+ if (decrees == null) return new ArrayList<>();
- CLTokenizer it = CLTokenizer.fromTokens(cltok);
+ CLTokenizer it = CLTokenizer.fromTokens(decrees);
return compile(it);
}
+ /**
+ * Compile a set of edicts from a tokenizer.
+ *
+ * @param cltok
+ * The tokenizer to get decrees from.
+ *
+ * @return The set of edicts compiled from the tokenizer.
+ */
public List<Edict> compile(CLTokenizer cltok) {
List<Edict> result = new ArrayList<>();
@@ -378,21 +417,22 @@ public class CLFormatter {
continue;
}
- if(decr.isUserCall) {
+ if (decr.isUserCall) {
/*
* @TODO implement user-called functions.
*/
- throw new IllegalArgumentException("User-called functions have not yet been implemented");
+ throw new IllegalArgumentException(
+ "User-called functions have not yet been implemented");
}
- if(extraDirectives.containsKey(nam)) {
+ if (extraDirectives.containsKey(nam)) {
Edict edt = extraDirectives.get(nam).compile(compCTX);
result.add(edt);
continue;
- } else if(builtinDirectives.containsKey(nam)) {
- Edict edt = builtinDirectives.get(nam).compile(compCTX);
+ } else if (builtinDirectives.containsKey(nam)) {
+ Edict edt = builtinDirectives.get(nam).compile(compCTX);
result.add(edt);
@@ -401,12 +441,11 @@ public class CLFormatter {
if (nam == null) nam = "<null>";
- switch(nam) {
+ switch (nam) {
case "]":
throw new IllegalArgumentException("Found conditional-end outside of conditional.");
case ";":
- throw new IllegalArgumentException(
- "Found seperator outside of block.");
+ throw new IllegalArgumentException("Found seperator outside of block.");
case "}":
throw new IllegalArgumentException("Found iteration-end outside of iteration");
case ")":
@@ -423,19 +462,18 @@ public class CLFormatter {
case "E":
case "G":
case "$":
- /* @TODO
+ /*
+ * @TODO
*
* implement floating point directives.
*/
throw new IllegalArgumentException("Floating-point directives aren't implemented yet.");
case "W":
/*
- * @TODO
+ * @TODO
*
- * figure out if we want to
- * implement someting for these
- * directives instead of
- * punting.
+ * figure out if we want to implement someting
+ * for these directives instead of punting.
*/
throw new IllegalArgumentException("S and W aren't implemented. Use A instead");
case "P":
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLModifiers.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLModifiers.java
index 68127b6..db62539 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/CLModifiers.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLModifiers.java
@@ -11,14 +11,17 @@ public class CLModifiers {
* Whether the at mod is on.
*/
public final boolean atMod;
+
/**
* Whether the colon mod is on.
*/
public final boolean colonMod;
+
/**
* Whether the dollar mod is on.
*/
public final boolean dollarMod;
+
/**
* Whether the star mod is on.
*/
@@ -63,4 +66,16 @@ public class CLModifiers {
return new CLModifiers(atMod, colonMod, dollarMod, starMod);
}
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ if (atMod) sb.append('@');
+ if (colonMod) sb.append(':');
+ if (dollarMod) sb.append('$');
+ if (starMod) sb.append('*');
+
+ return sb.toString();
+ }
}
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLParameters.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLParameters.java
index f3a2409..8711a2b 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/CLParameters.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLParameters.java
@@ -168,10 +168,7 @@ public class CLParameters {
* other special parameter features.
*
* @param unsplit
- * The string to parse parameters from
- *
- * @param dirParams
- * The parameters of the format string.
+ * The string to parse parameters from.
*
* @return A set of CL parameters.
*/
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLPattern.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLPattern.java
index aed9aea..9e697f9 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/CLPattern.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLPattern.java
@@ -7,6 +7,12 @@ import java.util.regex.Pattern;
import bjc.utils.ioutils.SimpleProperties;
+/**
+ * Utility class for reading in the pattern for parsing format directives.
+ *
+ * @author bjculkin
+ *
+ */
public class CLPattern {
private static String prefixParam;
private static String formatMod;
@@ -26,14 +32,14 @@ public class CLPattern {
// WELP, we failed. Bail
throw new RuntimeException("Couldn't load formats for formatter");
}
-
- String seqPrefixParam = props.get("clFormatPrefixParam");
- prefixParam = String.format(props.get("clFormatPrefix"), seqPrefixParam);
- formatMod = props.get("clFormatModifier");
+ String seqPrefixParam = props.get("clFormatPrefixParam");
+
+ prefixParam = String.format(props.get("clFormatPrefix"), seqPrefixParam);
+ formatMod = props.get("clFormatModifier");
directiveName = props.get("clFormatName");
- prefixList = String.format(props.get("delimSeparatedList"), prefixParam, ",");
+ prefixList = String.format(props.get("delimSeparatedList"), prefixParam, ",");
formatDirective = String.format(props.get("clFormatDirective"), prefixList, formatMod, directiveName);
pFormatDirective = Pattern.compile(formatDirective);
@@ -43,7 +49,7 @@ public class CLPattern {
* Get a matcher for FORMAT directives.
*
* @param inp
- * The string to parse directives from.
+ * The string to parse directives from.
*/
public static Matcher getDirectiveMatcher(String inp) {
return pFormatDirective.matcher(inp);
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLString.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLString.java
index 84f06fa..d704df7 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/CLString.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLString.java
@@ -25,19 +25,55 @@ public class CLString {
edicts = edts;
}
+ /**
+ * Execute this string with the given parameters.
+ *
+ * @param parms
+ * The format parameters for the string.
+ *
+ * @return The result from executing the format string.
+ *
+ * @throws IOException If something I/O related has gone wrong.
+ */
public String format(Object... parms) throws IOException {
StringWriter sw = new StringWriter();
- ReportWriter rw = new ReportWriter(sw);
-
- return format(rw, parms);
+ try (ReportWriter rw = new ReportWriter(sw)) {
+ return format(rw, parms);
+ }
}
+ /**
+ * Execute this string with the given parameters.
+ *
+ * @param rw
+ * The writer to write the string to.
+ *
+ * @param itms
+ * The format parameters to use.
+ *
+ * @return The result of executing the string.
+ *
+ * @throws IOException If something I/O related goes wrong.
+ */
public String format(ReportWriter rw, Tape<Object> itms) throws IOException {
FormatContext formCTX = new FormatContext(rw, itms);
return format(formCTX);
}
+ /**
+ * Execute this string with the given parameters.
+ *
+ * @param rw
+ * The writer to write the string to.
+ *
+ * @param parms
+ * The format parameters to use.
+ *
+ * @return The result of executing the string.
+ *
+ * @throws IOException If something I/O related goes wrong.
+ */
public String format(ReportWriter rw, Object... parms) throws IOException {
Tape<Object> itms = new SingleTape<>(parms);
@@ -46,6 +82,16 @@ public class CLString {
return format(formCTX);
}
+ /**
+ * Execute a format string in a given context.
+ *
+ * @param formCTX
+ * The context to use for formatting.
+ *
+ * @return The result of executing the format string.
+ *
+ * @throws IOException If something I/O related goes wrong.
+ */
public String format(FormatContext formCTX) throws IOException {
try {
for (Edict edt : edicts) {
@@ -58,6 +104,11 @@ public class CLString {
return formCTX.writer.toString();
}
+ /**
+ * Is this format string empty? (does it have 0 edicts?)
+ *
+ * @return If this format string is empty.
+ */
public boolean isEmpty() {
if (edicts.size() == 0) return true;
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLTokenizer.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLTokenizer.java
index 47deefc..6caead5 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/CLTokenizer.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLTokenizer.java
@@ -3,9 +3,12 @@ package bjc.utils.ioutils.format;
import java.util.*;
import java.util.regex.*;
-import bjc.utils.ioutils.*;
-import bjc.utils.ioutils.format.directives.*;
-
+/**
+ * Tokenizer for creating @{link Decree}s from strings.
+ *
+ * @author bjculkin
+ *
+ */
public class CLTokenizer implements Iterator<Decree> {
/*
* Internal class for a tokenizer that returns a specific set of tokens.
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLValue.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLValue.java
index a068048..1fa440c 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/CLValue.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLValue.java
@@ -14,14 +14,16 @@ public interface CLValue {
*
* @param val
* The string to create the value from.
+ *
+ * @return The CLValue represented by the string.
*/
public static CLValue parse(String val) {
+ if (val == null) return new NullValue();
+
if (val.equalsIgnoreCase("V")) {
return new VValue();
}
- if (val == null) return new NullValue();
-
switch (val) {
case "V":
case "v":
@@ -40,11 +42,33 @@ public interface CLValue {
*
* @param params
* The parameters passed to the directive.
+ *
+ * @return The string value of the parameter.
*/
public String getValue(Tape<Object> params);
- static String MSG_FMT = "Invalid %s \"%s\" to %s directive";
+ /**
+ * The format string to use for an invalid usage of a directive.
+ */
+ public static final String MSG_FMT = "Invalid %s \"%s\" to %s directive";
+ /**
+ * Get the value as an integer.
+ *
+ * @param params
+ * The format parameters to use.
+ *
+ * @param paramName
+ * The user-intelligble name for the value.
+ *
+ * @param directive
+ * The directive this value is for.
+ *
+ * @param def
+ * The default value for this value.
+ *
+ * @return The value as an integer, or the default value if the value has no value.
+ */
public default int asInt(Tape<Object> params, String paramName, String directive, int def) {
String param = getValue(params);
@@ -64,10 +88,32 @@ public interface CLValue {
return def;
}
+ /**
+ * Get a CLValue that represent 'nothing'.
+ *
+ * @return A CLValue that represents nothing.
+ */
public static CLValue nil() {
return new NullValue();
}
+ /**
+ * Get the value as a character.
+ *
+ * @param params
+ * The format parameters to use.
+ *
+ * @param paramName
+ * The user-intelligble name for the value.
+ *
+ * @param directive
+ * The directive the value is for.
+ *
+ * @param def
+ * The default value for the value.
+ *
+ * @return The value as an character, or the default value if the value has no value.
+ */
public default char asChar(Tape<Object> params, String paramName, String directive, char def) {
String param = getValue(params);
@@ -94,24 +140,28 @@ public interface CLValue {
class NullValue implements CLValue {
public static CLValue nullVal = new NullValue();
+ @Override
public String getValue(Tape<Object> params) {
return null;
}
}
class PercValue implements CLValue {
+ @Override
public String getValue(Tape<Object> params) {
return Integer.toString(params.position());
}
}
class HashValue implements CLValue {
+ @Override
public String getValue(Tape<Object> params) {
return (Integer.toString(params.size() - params.position()));
}
}
class VValue implements CLValue {
+ @Override
public String getValue(Tape<Object> params) {
// Read parameter from items
Object par = params.item();
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/CaseDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/CaseDirective.java
index 9861864..3b21074 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/CaseDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/CaseDirective.java
@@ -1,7 +1,6 @@
package bjc.utils.ioutils.format.directives;
import java.io.*;
-import java.util.*;
import java.util.regex.*;
import bjc.utils.ioutils.*;
@@ -15,8 +14,12 @@ import bjc.utils.ioutils.format.*;
* @author Ben Culkin
*/
public class CaseDirective implements Directive {
- private static final Pattern wordPattern = Pattern.compile("(\\w+)(\\b*)");
-
+ /**
+ * Compile a case directive.
+ *
+ * @param compCTX
+ * The context to use for compilation.
+ */
public Edict compile(CompileContext compCTX) {
CLModifiers mods = compCTX.decr.modifiers;
@@ -40,10 +43,7 @@ public class CaseDirective implements Directive {
class CaseEdict implements Edict {
public static enum Mode {
- UPPERCASE,
- WORD_UPPERCASE,
- FIRST_UPPERCASE,
- LOWERCASE
+ UPPERCASE, WORD_UPPERCASE, FIRST_UPPERCASE, LOWERCASE
}
private static final Pattern wordPattern = Pattern.compile("(\\w+)(\\b*)");
@@ -52,34 +52,26 @@ class CaseEdict implements Edict {
private Mode caseMode;
- private CLFormatter formatter;
-
public CaseEdict(GroupDecree body, Mode caseMode, CLFormatter fmt) {
this.body = new CLString(fmt.compile(body.unwrap()));
-
- this.caseMode = caseMode;
- this.formatter = fmt;
+ this.caseMode = caseMode;
}
@Override
public void format(FormatContext formCTX) throws IOException {
- ReportWriter nrw = formCTX.getScratchWriter();
-
- //formatter.doFormatString(body, nrw, formCTX.items, false);
-
- String strang = body.format(nrw, formCTX.items);
-
- switch (caseMode) {
- case UPPERCASE:
- strang = strang.toUpperCase();
- break;
- case WORD_UPPERCASE:
- {
+ try (ReportWriter nrw = formCTX.getScratchWriter()) {
+ String strang = body.format(nrw, formCTX.items);
+
+ switch (caseMode) {
+ case UPPERCASE:
+ strang = strang.toUpperCase();
+ break;
+ case WORD_UPPERCASE: {
Matcher mat = wordPattern.matcher(strang);
StringBuffer sb = new StringBuffer();
- while(mat.find()) {
+ while (mat.find()) {
mat.appendReplacement(sb, "");
String word = mat.group(1);
@@ -93,14 +85,13 @@ class CaseEdict implements Edict {
strang = sb.toString();
}
- break;
- case FIRST_UPPERCASE:
- {
+ break;
+ case FIRST_UPPERCASE: {
Matcher mat = wordPattern.matcher(strang);
StringBuffer sb = new StringBuffer();
boolean doCap = true;
- while(mat.find()) {
+ while (mat.find()) {
mat.appendReplacement(sb, "");
String word = mat.group(1);
@@ -119,12 +110,16 @@ class CaseEdict implements Edict {
strang = sb.toString();
}
- break;
- case LOWERCASE:
- strang = strang.toLowerCase();
- break;
- }
+ break;
+ case LOWERCASE:
+ strang = strang.toLowerCase();
+ break;
+ default:
+ throw new IllegalArgumentException("INTERNAL ERROR: CaseEdict mode " + caseMode
+ + " is not supported. This is a bug.");
+ }
- formCTX.writer.write(strang);
+ formCTX.writer.write(strang);
+ }
}
}
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/CompileContext.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/CompileContext.java
index 4fa2fcd..4bbae6b 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/CompileContext.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/CompileContext.java
@@ -1,8 +1,5 @@
package bjc.utils.ioutils.format.directives;
-import java.util.*;
-
-import bjc.utils.esodata.*;
import bjc.utils.ioutils.format.*;
/**
@@ -26,6 +23,18 @@ public class CompileContext {
*/
public Decree decr;
+ /**
+ * Create a new compilation context.
+ *
+ * @param dirs
+ * The directives to compile from.
+ *
+ * @param fmt
+ * The formatter being used to compile.
+ *
+ * @param dcr
+ * The decree currently being compiled.
+ */
public CompileContext(CLTokenizer dirs, CLFormatter fmt, Decree dcr) {
directives = dirs;
formatter = fmt;
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/ConditionalDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/ConditionalDirective.java
index 5a5422b..a1ed7a8 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/ConditionalDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/ConditionalDirective.java
@@ -2,16 +2,15 @@ package bjc.utils.ioutils.format.directives;
import java.io.*;
import java.util.*;
-import java.util.regex.*;
-
import bjc.utils.esodata.*;
import bjc.utils.ioutils.format.*;
/**
* Implements the [ directive.
*
- * This does varying sorts of conditional dispatches on which string to use for formatting, allowing
- * it to be based off of general conditions in varying ways.
+ * This does varying sorts of conditional dispatches on which string to use for
+ * formatting, allowing it to be based off of general conditions in varying
+ * ways.
*
* @author Ben Culkin
*/
@@ -24,7 +23,7 @@ public class ConditionalDirective implements Directive {
List<Decree> condBody = new ArrayList<>();
List<List<Decree>> clauses = new ArrayList<>();
- List<Decree> defClause = null;
+ List<Decree> defClause = null;
boolean isDefault = false;
int nestLevel = 1;
@@ -55,8 +54,6 @@ public class ConditionalDirective implements Directive {
/* End the conditional. */
List<Decree> clause = condBody;
- condBody = new ArrayList<>();
-
if (isDefault) {
defClause = clause;
}
@@ -84,7 +81,8 @@ public class ConditionalDirective implements Directive {
clauses.add(clause);
/*
- * Mark the next clause as the default.
+ * Mark the next clause as the
+ * default.
*/
if (decr.modifiers.colonMod) {
isDefault = true;
@@ -99,7 +97,7 @@ public class ConditionalDirective implements Directive {
}
}
}
-
+
if (mods.starMod && clauses.size() > 0) defClause = clauses.get(0);
CLValue index = null;
@@ -120,16 +118,13 @@ public class ConditionalDirective implements Directive {
mode = ConditionalEdict.Mode.INDEX_CLAUSE;
}
- return new ConditionalEdict(mode, mods.dollarMod, index, clauses,
- defClause, compCTX.formatter);
+ return new ConditionalEdict(mode, mods.dollarMod, index, clauses, defClause, compCTX.formatter);
}
}
class ConditionalEdict implements Edict {
public static enum Mode {
- FIRST_SECOND,
- OUTPUT_TRUE,
- INDEX_CLAUSE
+ FIRST_SECOND, OUTPUT_TRUE, INDEX_CLAUSE
}
private Mode condMode;
@@ -140,11 +135,8 @@ class ConditionalEdict implements Edict {
private List<CLString> clauses;
private CLString defClause;
- private CLFormatter formatter;
-
- public ConditionalEdict(Mode condMode, boolean decrementIndex,
- CLValue index, List<List<Decree>> clauses, List<Decree> defClause,
- CLFormatter fmt) {
+ public ConditionalEdict(Mode condMode, boolean decrementIndex, CLValue index, List<List<Decree>> clauses,
+ List<Decree> defClause, CLFormatter fmt) {
this.condMode = condMode;
this.decrementIndex = decrementIndex;
@@ -155,8 +147,6 @@ class ConditionalEdict implements Edict {
this.clauses.add(new CLString(fmt.compile(clause)));
}
this.defClause = new CLString(fmt.compile(defClause));
-
- this.formatter = fmt;
}
@Override
@@ -165,87 +155,87 @@ class ConditionalEdict implements Edict {
try {
switch (condMode) {
- case FIRST_SECOND:
- {
- Object o = items.item();
- items.right();
+ case FIRST_SECOND: {
+ Object o = items.item();
+ items.right();
+
+ boolean res = false;
+ if (o == null) {
+ //throw new IllegalArgumentException("No parameter provided for [ directive.");
+ } else if (!(o instanceof Boolean)) {
+ throw new IllegalFormatConversionException('[', o.getClass());
+ } else {
+ res = (Boolean) o;
+ }
- boolean res = false;
- if (o == null) {
- //throw new IllegalArgumentException("No parameter provided for [ directive.");
- } else if (!(o instanceof Boolean)) {
- throw new IllegalFormatConversionException('[', o.getClass());
- } else {
- res = (Boolean) o;
- }
+ CLString frmt;
+ if (res) {
+ frmt = clauses.get(1);
+ } else {
+ frmt = clauses.get(0);
+ }
- CLString frmt;
- if (res) {
- frmt = clauses.get(1);
- } else {
- frmt = clauses.get(0);
+ frmt.format(formCTX);
+ }
+ break;
+ case OUTPUT_TRUE: {
+ boolean res = false;
+ Object o = items.item();
+
+ if (o == null) {
+ // throw new IllegalArgumentException("No parameter provided for [ directive.");
+ } else if (o instanceof Integer) {
+ if ((Integer) o != 0) {
+ res = true;
}
+ } else if (o instanceof Boolean) {
+ res = (Boolean) o;
+ } else {
+ throw new IllegalFormatConversionException('[', o.getClass());
+ }
- frmt.format(formCTX);
+ if (res) {
+ clauses.get(0).format(formCTX);
+ } else {
+ items.right();
}
+ }
break;
- case OUTPUT_TRUE:
- {
- boolean res = false;
+ case INDEX_CLAUSE: {
+ int res;
+
+ if (index != null) {
+ res = index.asInt(items, "conditional choice", "[", 0);
+ } else {
Object o = items.item();
if (o == null) {
- // throw new IllegalArgumentException("No parameter provided for [ directive.");
- } else if (o instanceof Integer) {
- if ((Integer)o != 0) {
- res = true;
- }
- } else if (o instanceof Boolean) {
- res = (Boolean) o;
- } else {
- throw new IllegalFormatConversionException('[', o.getClass());
- }
-
- if (res) {
- clauses.get(0).format(formCTX);
- } else {
- items.right();
- }
- }
- break;
- case INDEX_CLAUSE:
- {
- int res;
+ throw new IllegalArgumentException(
+ "No parameter provided for [ directive.");
+ } else if (!(o instanceof Number)) { throw new IllegalFormatConversionException(
+ '[', o.getClass()); }
- if (index != null) {
- res = index.asInt(items, "conditional choice", "[", 0);
- } else {
- Object o = items.item();
+ res = ((Number) o).intValue();
- if (o == null) {
- throw new IllegalArgumentException("No parameter provided for [ directive.");
- } else if (!(o instanceof Number)) {
- throw new IllegalFormatConversionException('[', o.getClass());
- }
+ items.right();
+ }
- res = ((Number) o).intValue();
+ if (decrementIndex) res -= 1;
- items.right();
+ if (clauses.size() == 0 || res < 0 || res >= clauses.size()) {
+ if (defClause != null) {
+ defClause.format(formCTX.writer, items);
}
+ } else {
+ CLString frmt = clauses.get(res);
- if (decrementIndex) res -= 1;
-
- if (clauses.size() == 0 || res < 0 || res >= clauses.size()) {
- if (defClause != null) {
- defClause.format(formCTX.writer, items);
- }
- } else {
- CLString frmt = clauses.get(res);
-
- frmt.format(formCTX.writer, items);
- }
+ frmt.format(formCTX.writer, items);
}
+ }
break;
+ default:
+ throw new IllegalArgumentException("INTERNAL ERROR: ConditionalEdict mode " + condMode
+ + " is not supported. This is a bug.");
}
} catch (EscapeException eex) {
// Conditionals are transparent to iteration-escapes
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/Directive.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/Directive.java
index b6e2df1..d6617de 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/Directive.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/Directive.java
@@ -19,7 +19,7 @@ public interface Directive {
Edict edt = compile(dirParams.toCompileCTX());
edt.format(dirParams.toFormatCTX());
- };
+ }
/**
* Compile this directive.
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/EscapeDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/EscapeDirective.java
index 377102f..e8e4eb8 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/EscapeDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/EscapeDirective.java
@@ -1,7 +1,5 @@
package bjc.utils.ioutils.format.directives;
-import java.io.*;
-
import bjc.utils.esodata.*;
import bjc.utils.ioutils.format.*;
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatContext.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatContext.java
index 1c4e57f..f1147fb 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatContext.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatContext.java
@@ -4,7 +4,6 @@ import java.io.*;
import bjc.utils.esodata.*;
import bjc.utils.ioutils.*;
-import bjc.utils.ioutils.format.*;
/**
* Encapsulates all of the state that is provided to edicts when they are
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatParameters.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatParameters.java
index 82fafbc..e55fdd8 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatParameters.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/FormatParameters.java
@@ -1,24 +1,71 @@
package bjc.utils.ioutils.format.directives;
-import java.util.*;
-
import bjc.utils.esodata.*;
import bjc.utils.ioutils.*;
import bjc.utils.ioutils.format.*;
+/**
+ * The set of parameters used during formatting.
+ *
+ * Since the refactor to use compilation (e.g {@link CLString} and it's ilk),
+ * this is now mostly used as a way of creating the {@link FormatContext} and
+ * {@link CompileContext} objects.
+ *
+ * @author bjculkin
+ *
+ */
public class FormatParameters {
+ /**
+ * The {@link ReportWriter} used for output.
+ */
public ReportWriter rw;
+ /**
+ * The current format parameter.
+ */
public Object item;
+ /**
+ * The current decree.
+ */
public Decree decr;
+ /**
+ * The current format parameters.
+ */
public Tape<Object> tParams;
+ /**
+ * The set of directives we are using.
+ */
public CLTokenizer dirIter;
+ /**
+ * The formatter we are going from.
+ */
public CLFormatter fmt;
+ /**
+ * Create a new set of format parameters.
+ *
+ * @param rw
+ * The writer we are sending output to.
+ *
+ * @param item
+ * The current format parameter.
+ *
+ * @param decr
+ * The decree being formatted.
+ *
+ * @param tParams
+ * The list of all the format parameters.
+ *
+ * @param dirIter
+ * The set of format decrees.
+ *
+ * @param fmt
+ * The formatter we are using
+ */
public FormatParameters(ReportWriter rw, Object item, Decree decr, Tape<Object> tParams,
CLTokenizer dirIter, CLFormatter fmt) {
this.rw = rw;
@@ -34,18 +81,38 @@ public class FormatParameters {
this.fmt = fmt;
}
+ /**
+ * Get the parameters for the current decree.
+ *
+ * @return The parameters to the current decree.
+ */
public CLParameters getParams() {
return decr.parameters;
}
+ /**
+ * Get the modifiers for the current decree.
+ *
+ * @return The modifiers for the current decree.
+ */
public CLModifiers getMods() {
return decr.modifiers;
}
+ /**
+ * Convert this set of parameters into a compilation context.
+ *
+ * @return The compilation context from these parameters.
+ */
public CompileContext toCompileCTX() {
return new CompileContext(dirIter, fmt, decr);
}
-
+
+ /**
+ * Convert this set of parameters into a format context.
+ *
+ * @return The format context from these parameters.
+ */
public FormatContext toFormatCTX() {
return new FormatContext(rw, tParams);
}
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/GeneralNumberDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/GeneralNumberDirective.java
index a6df0d7..fdb78cc 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/GeneralNumberDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/GeneralNumberDirective.java
@@ -1,11 +1,6 @@
package bjc.utils.ioutils.format.directives;
-import java.io.*;
-
-import bjc.utils.esodata.*;
-import bjc.utils.ioutils.*;
import bjc.utils.ioutils.format.*;
-import bjc.utils.math.*;
/**
* Implementation skeleton for number directives.
@@ -14,11 +9,17 @@ import bjc.utils.math.*;
*
*/
public abstract class GeneralNumberDirective implements Directive {
+ /**
+ * Parameters for doing number formatting.
+ *
+ * @author bjculkin
+ *
+ */
public static class NumberParams {
/**
* Minimum # of printed columns
*/
- public CLValue mincol = CLValue.nil();
+ public CLValue mincol = CLValue.nil();
/**
* Character to use for padding if needed.
*/
@@ -41,12 +42,12 @@ public abstract class GeneralNumberDirective implements Directive {
/**
* Character to use as a comma.
*/
- public CLValue commaChar = CLValue.nil();
+ public CLValue commaChar = CLValue.nil();
}
protected NumberParams getParams(CompileContext compCTX, int argidx) {
CLParameters params = compCTX.decr.parameters;
- CLModifiers mods = compCTX.decr.modifiers;
+ CLModifiers mods = compCTX.decr.modifiers;
NumberParams np = new NumberParams();
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/GotoDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/GotoDirective.java
index 9e5ef1f..84d2506 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/GotoDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/GotoDirective.java
@@ -1,7 +1,5 @@
package bjc.utils.ioutils.format.directives;
-import java.io.*;
-
import bjc.utils.esodata.*;
import bjc.utils.ioutils.format.*;
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/IndentDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/IndentDirective.java
index 6191832..b7dce36 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/IndentDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/IndentDirective.java
@@ -1,8 +1,5 @@
package bjc.utils.ioutils.format.directives;
-import java.io.*;
-
-import bjc.utils.esodata.*;
import bjc.utils.ioutils.format.*;
/**
@@ -72,6 +69,6 @@ class IndentEdict implements Edict {
class IndentConfigureEdict implements Edict {
@Override
public void format(FormatContext formCTX) {
-
+ // @TODO implement me - Ben Culkin, 1/5/20
}
}
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/InflectDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/InflectDirective.java
index b2e26d8..ead1c06 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/InflectDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/InflectDirective.java
@@ -2,8 +2,6 @@ package bjc.utils.ioutils.format.directives;
import java.io.*;
import java.util.*;
-import java.util.regex.*;
-
import bjc.inflexion.*;
import bjc.utils.ioutils.*;
@@ -64,12 +62,8 @@ public class InflectDirective implements Directive {
class InflectEdict implements Edict {
private CLString body;
- private CLFormatter fmt;
-
public InflectEdict(List<Decree> body, CLFormatter fmt) {
this.body = new CLString(fmt.compile(body));
-
- this.fmt = fmt;
}
@Override
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/IterationDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/IterationDirective.java
index ac20baa..995acc8 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/IterationDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/IterationDirective.java
@@ -2,8 +2,6 @@ package bjc.utils.ioutils.format.directives;
import java.io.*;
import java.util.*;
-import java.util.regex.*;
-
import bjc.utils.esodata.*;
import bjc.utils.ioutils.format.*;
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/LiteralDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/LiteralDirective.java
index 98312d6..d783e97 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/LiteralDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/LiteralDirective.java
@@ -11,7 +11,6 @@ import bjc.utils.ioutils.format.*;
*
*/
public class LiteralDirective implements Directive {
- private String directive;
private String lit;
/**
@@ -23,7 +22,7 @@ public class LiteralDirective implements Directive {
* The character for the directive.
*/
public LiteralDirective(String lit, char directive) {
- this.directive = Character.toString(directive);
+ Character.toString(directive);
this.lit = lit;
}
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/NumberDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/NumberDirective.java
index 8591dc9..c0e8c72 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/NumberDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/NumberDirective.java
@@ -45,16 +45,12 @@ public class NumberDirective extends GeneralNumberDirective {
class NumberEdict implements Edict {
private int radix;
- private int argidx;
-
private String directive;
private NumberParams np;
public NumberEdict(int radix, char directive, int argidx, NumberParams np) {
this.radix = radix;
- this.argidx = argidx;
-
this.directive = Character.toString(directive);
this.np = np;
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/RadixDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/RadixDirective.java
index 418519a..4a3f1e8 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/RadixDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/RadixDirective.java
@@ -3,7 +3,6 @@ package bjc.utils.ioutils.format.directives;
import java.io.*;
import java.util.*;
-import bjc.utils.esodata.*;
import bjc.utils.ioutils.format.*;
import bjc.utils.math.*;
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/RecursiveDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/RecursiveDirective.java
index 8040333..a52a3ba 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/RecursiveDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/RecursiveDirective.java
@@ -1,12 +1,16 @@
package bjc.utils.ioutils.format.directives;
import java.io.*;
-import java.util.*;
-
import bjc.utils.esodata.*;
import bjc.utils.ioutils.format.*;
import bjc.utils.ioutils.format.exceptions.*;
+/**
+ * Implementation of the ? directive, which does recursive execution of a format string.
+ *
+ * @author bjculkin
+ *
+ */
public class RecursiveDirective implements Directive {
@Override
public Edict compile(CompileContext compCTX) {
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/TabulateDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/TabulateDirective.java
index 04d0140..2aaef19 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/TabulateDirective.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/TabulateDirective.java
@@ -6,6 +6,12 @@ import bjc.utils.esodata.*;
import bjc.utils.ioutils.*;
import bjc.utils.ioutils.format.*;
+/**
+ * Implementation of the T directive, which is used for some formatting based controls.
+ *
+ * @author bjculkin
+ *
+ */
public class TabulateDirective implements Directive {
@Override
public Edict compile(CompileContext compCTX) {
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/exceptions/MismatchedFormatArgType.java b/clformat/src/main/java/bjc/utils/ioutils/format/exceptions/MismatchedFormatArgType.java
index 7ac9e9d..32a62d8 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/exceptions/MismatchedFormatArgType.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/exceptions/MismatchedFormatArgType.java
@@ -6,6 +6,8 @@ package bjc.utils.ioutils.format.exceptions;
* @author Ben Culkin
*/
public class MismatchedFormatArgType extends RuntimeException {
+ private static final long serialVersionUID = 7013519754361279429L;
+
/**
* Create a new format arg mismatch with a given message.
*
diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/exceptions/UnexpectedColonEscape.java b/clformat/src/main/java/bjc/utils/ioutils/format/exceptions/UnexpectedColonEscape.java
index 260e503..5594f17 100644
--- a/clformat/src/main/java/bjc/utils/ioutils/format/exceptions/UnexpectedColonEscape.java
+++ b/clformat/src/main/java/bjc/utils/ioutils/format/exceptions/UnexpectedColonEscape.java
@@ -7,6 +7,11 @@ package bjc.utils.ioutils.format.exceptions;
* @author Ben Culkin
*/
public class UnexpectedColonEscape extends RuntimeException {
+ private static final long serialVersionUID = -3807365015422854036L;
+
+ /**
+ * Create a new exception of this type.
+ */
public UnexpectedColonEscape() {
super("Colon mod not allowed on escape marker in this context");
}