From 4a36dbf913e1a1bce6e7e5e53531ef084f59babf Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Tue, 2 Jul 2019 17:00:47 -0400 Subject: Update site --- .../bjc.everge/ControlledString$Control.html | 2 +- .../bjc.everge/ControlledString$ParseStrings.html | 1 + docs/jacoco-ut/bjc.everge/ControlledString.html | 2 +- .../bjc.everge/ControlledString.java.html | 294 +++++-- docs/jacoco-ut/bjc.everge/ReplError.html | 2 +- docs/jacoco-ut/bjc.everge/ReplError.java.html | 6 +- docs/jacoco-ut/bjc.everge/ReplOpts.html | 2 +- docs/jacoco-ut/bjc.everge/ReplOpts.java.html | 46 +- docs/jacoco-ut/bjc.everge/ReplPair.html | 2 +- docs/jacoco-ut/bjc.everge/ReplPair.java.html | 865 ++++++++++----------- docs/jacoco-ut/bjc.everge/ReplParseException.html | 2 +- .../bjc.everge/ReplParseException.java.html | 58 +- docs/jacoco-ut/bjc.everge/index.html | 2 +- docs/jacoco-ut/bjc.everge/index.source.html | 2 +- 14 files changed, 732 insertions(+), 554 deletions(-) create mode 100644 docs/jacoco-ut/bjc.everge/ControlledString$ParseStrings.html (limited to 'docs/jacoco-ut/bjc.everge') diff --git a/docs/jacoco-ut/bjc.everge/ControlledString$Control.html b/docs/jacoco-ut/bjc.everge/ControlledString$Control.html index e93afa5..e9f1cbe 100644 --- a/docs/jacoco-ut/bjc.everge/ControlledString$Control.html +++ b/docs/jacoco-ut/bjc.everge/ControlledString$Control.html @@ -1 +1 @@ -ControlledString.Control

ControlledString.Control

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total18 of 180%0 of 0n/a339933
ControlledString.Control(String, String[])90%n/a114411
ControlledString.Control(String)60%n/a113311
ControlledString.Control()30%n/a112211
\ No newline at end of file +ControlledString.Control

ControlledString.Control

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total132 of 23343%22 of 4450%2031214639
toString()480%60%448811
get(int)371224%2250%235801
hashCode()270%20%225511
equals(Object)176479%122062%111711401
ControlledString.Control()30%n/a112211
ControlledString.Control(String, String[])9100%n/a010401
ControlledString.Control(String)6100%n/a010301
C(String, String[])6100%n/a010101
count()4100%n/a010101
\ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ControlledString$ParseStrings.html b/docs/jacoco-ut/bjc.everge/ControlledString$ParseStrings.html new file mode 100644 index 0000000..15d59e9 --- /dev/null +++ b/docs/jacoco-ut/bjc.everge/ControlledString$ParseStrings.html @@ -0,0 +1 @@ +ControlledString.ParseStrings

ControlledString.ParseStrings

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total8 of 2365%0 of 0n/a121712
PS(String, String, String, String)80%n/a111111
ControlledString.ParseStrings(String, String, String, String)15100%n/a010601
\ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ControlledString.html b/docs/jacoco-ut/bjc.everge/ControlledString.html index 70da0b2..8b72ed6 100644 --- a/docs/jacoco-ut/bjc.everge/ControlledString.html +++ b/docs/jacoco-ut/bjc.everge/ControlledString.html @@ -1 +1 @@ -ControlledString

ControlledString

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total159 of 1590%14 of 140%1212353555
parse(String, String, String, String, String)1260%120%77232311
ControlledString(String)100%n/a114411
ControlledString(String, ControlledString.Control[])80%n/a114411
hasControls()80%20%221111
ControlledString()70%n/a113311
\ No newline at end of file +ControlledString

ControlledString

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total74 of 22266%3 of 1883%516174437
toString()410%20%227711
parse(String, ControlledString.ParseStrings)1712688%11392%1832401
ControlledString(String, ControlledString.Control[])90%n/a114411
ControlledString()70%n/a113311
ControlledString(String)10100%n/a010401
hasControls()8100%2100%020101
count()4100%n/a010101
\ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ControlledString.java.html b/docs/jacoco-ut/bjc.everge/ControlledString.java.html index 2f928e8..63c0b44 100644 --- a/docs/jacoco-ut/bjc.everge/ControlledString.java.html +++ b/docs/jacoco-ut/bjc.everge/ControlledString.java.html @@ -1,5 +1,7 @@ ControlledString.java

ControlledString.java

package bjc.everge;
 
+import java.util.Arrays;
+
 /**
  * Represents a string with a set of control flags attached to it.
  *
@@ -25,9 +27,9 @@ public class ControlledString {
 		/**
 		 * Create a new blank control.
 		 */
-		public Control() {
+		public Control() {
 
-		}
+		}
 
 		/**
 		 * Create a new argless control.
@@ -35,9 +37,9 @@ public class ControlledString {
 		 * @param nam
 		 * 	The name of the control.
 		 */
-		public Control(String nam) {
-			name = nam;
-		}
+		public Control(String nam) {
+			name = nam;
+		}
 
 		/**
 		 * Create a new control.
@@ -47,12 +49,165 @@ public class ControlledString {
 		 * @param ars
 		 * 	The arguments of the control.
 		 */
-		public Control(String nam, String... ars) {
-			name = nam;
-			args = ars;
-		}
+		public Control(String nam, String... ars) {
+			name = nam;
+			args = ars;
+		}
+
+		/**
+		 * Get the count of arguments this control has.
+		 *
+		 * @return The number of arguments to this control.
+		 */
+		public int count() {
+			return args.length;
+		}
+
+		public String get(int i) {
+			if (i < 0) {
+				String msg = String.format("Control argument index must be greater than 0 (was %d)", i);
+
+				throw new IllegalArgumentException(msg);
+			}
+
+			if (i > args.length) {
+				String msg = String.format("Control argument index must be less than %d (was %d)",
+						args.length, i);
+
+				throw new IllegalArgumentException(msg);
+			}
+
+			return args[i];
+		}
+
+		@Override
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			sb.append(name);
+
+			if (args != null && args.length > 0) {
+				sb.append("/");
+
+				for (String arg : args) {
+					sb.append(arg);
+					sb.append(";");
+				}
+			}
+
+			return sb.toString();
+		}
+
+		@Override
+		public int hashCode() {
+			final int prime = 31;
+			int result = 1;
+			result = prime * result + Arrays.hashCode(args);
+			result = prime * result + ((name == null) ? 0 : name.hashCode());
+			return result;
+		}
+
+		@Override
+		public boolean equals(Object obj) {
+			if (this == obj) { return true; }
+			if (obj == null) { return false; }
+			if (getClass() != obj.getClass()) { return false; }
+
+			Control other = (Control) obj;
+
+			if (name == null) {
+				if (other.name != null) { return false; }
+			} else if (!name.equals(other.name)) { return false; }
+
+			boolean isArged  = args != null && args.length > 0;
+			boolean oIsArged = other.args != null && other.args.length > 0;
+
+			if (isArged && !oIsArged) { return false; }
+			if (!isArged && oIsArged) { return false; }
+
+			if (isArged && oIsArged) {
+				return Arrays.equals(args, other.args);
+			}
+
+			return true;
+		}
+
+		/**
+		 * Convenient static constructor for static imports.
+		 *
+		 * @param nam
+		 * 	The name of the control.
+		 * @param ars
+		 * 	The arguments to the control.
+		 * @return A control with the right parameters.
+		 */
+		public static Control C(String nam, String... ars) {
+			return new Control(nam, ars);
+		}
 	}
+	
+	/**
+	 * Parameter class for defining how to parse a ControlledString.
+	 *
+	 * @author Ben Culkin
+	 */
+	public static class ParseStrings {
+		/**
+		 * The indicator for separating controls from the regular string.
+		 */
+		public String contInd;
+
+		/**
+		 * The indicator for separating individual controls.
+		 */
+		public String contSep;
+
+		/**
+		 * The indicator for separating arguments to a control.
+		 */
+		public String contArg;
+
+		/**
+		 * The indicator for escaping any of the indicators (including itself)
+		 */
+		public String contEsc;
 
+		/**
+		 * Create a new set of parse strings.
+		 *
+		 * @param contInd
+		 * 	The control indicator.
+		 * @param contSep
+		 * 	The control separator.
+		 * @param contArg
+		 * 	The argument separator.
+		 * @param contEsc
+		 * 	The control escape.
+		 */
+		public ParseStrings(String contInd, String contSep, String contArg, String contEsc) {
+			this.contInd = contInd;
+			this.contSep = contSep;
+			this.contArg = contArg;
+			this.contEsc = contEsc;
+		}
+
+		/**
+		 * Convenient static constructor.
+		 *
+		 * @param contInd
+		 * 	The control indicator.
+		 * @param contSep
+		 * 	The control separator.
+		 * @param contArg
+		 * 	The argument separator.
+		 * @param contEsc
+		 * 	The control escape.
+		 * @return A new set of control strings.
+		 */
+		public static ParseStrings PS(String contInd, String contSep, String contArg, String contEsc) {
+			return new ParseStrings(contInd, contSep, contArg, contEsc);
+		}
+	}
+	
 	/**
 	 * The string the controls apply to.
 	 */
@@ -66,9 +221,9 @@ public class ControlledString {
 	/**
 	 * Create a new blank controlled string.
 	 */
-	public ControlledString() {
-		controls = new Control[0];
-	}
+	public ControlledString() {
+		controls = new Control[0];
+	}
 
 	/**
 	 * Create a new controlled string without any controls.
@@ -76,11 +231,11 @@ public class ControlledString {
 	 * @param strung
 	 * 	The string to use.
 	 */
-	public ControlledString(String strung) {
-		strang = strung;
+	public ControlledString(String strung) {
+		strang = strung;
 
-		controls = new Control[0];
-	}
+		controls = new Control[0];
+	}
 
 	/**
 	 * Create a new controlled string.
@@ -90,11 +245,11 @@ public class ControlledString {
 	 * @param controls
 	 * 	The controls that apply to the string.
 	 */
-	public ControlledString(String strung, Control... controls) {
-		strang = strung;
+	public ControlledString(String strung, Control... controls) {
+		strang = strung;
 
-		controls = controls;
-	}
+		this.controls = controls;
+	}
 
 	/**
 	 * Check if the string has controls.
@@ -102,77 +257,90 @@ public class ControlledString {
 	 * @return Whether or not the string has controls.
 	 */
 	public boolean hasControls() {
-		return controls.length > 0;
+		return controls.length > 0;
 	}
 
 	/**
-	 * Parse a controlled string from a regular string.
+	 * Get the count of controls.
 	 *
-	 * The controls must be parsed from the beginning of the string, and are indicated by occurances
-	 * of contInd that bracket them from the string. The individual controls are delimited by
-	 * instances of contSep, with arguments to them being separated by occurances of contArg.
+	 * @return The number of controls for this string.
+	 */
+	public int count() {
+		return controls.length;
+	}
+
+	/**
+	 * Parse a controlled string from a regular string.
 	 *
-	 * Each of those separators (which must be regular strings, not regexes or anything) may be
-	 * escaped by preceeding them with a copy of contEsc.
+	 * The controls must be parsed from the beginning of the string.
 	 *
 	 * @param lne
-	 * 	The string to parse frmo.
-	 * @param contInd
-	 * 	The indicator for whether or not there are controls.
-	 * @param contSep
-	 * 	The separator of individual controls.
-	 * @param contArg
-	 * 	The separator of control arguments.
-	 * @param contEsc
-	 * 	The escape string for each of the separators/indicators.
-	 *
+	 * 	The string to parse from.
+	 * @param parameterObject TODO
 	 * @return A parsed control string.
 	 */
-	public static ControlledString parse(String lne, String contInd, String contSep,
-			String contArg, String contEsc) {
-		if (!lne.startsWith(contInd)) {
-			return new ControlledString(lne);
+	public static ControlledString parse(String lne, ParseStrings parameterObject) 
+	{
+		if (!lne.startsWith(parameterObject.contInd)) {
+			return new ControlledString(lne);
 		}
 
-		String tmp = lne.substring(2);
+		String tmp = lne.substring(2);
 
-		String[] bits = StringUtils.escapeSplit(contEsc, contInd, lne);
+		String[] bits = StringUtils.escapeSplit(parameterObject.contEsc, parameterObject.contInd, lne);
 
-		if (bits.length < 2) {
-			String msg = "Did not find control terminator (%s) where it should be";
-			msg = String.format(msg, contInd);
+		if (bits.length < 2) {
+			String msg = "Did not find control terminator (%s) where it should be";
+			msg = String.format(msg, parameterObject.contInd);
 
-			throw new IllegalArgumentException(msg);
-		}
+			throw new IllegalArgumentException(msg);
+		} 
 
-		ControlledString cs = new ControlledString(bits[0]);
+		ControlledString cs = new ControlledString(bits[0]);
+		if (bits.length > 2) cs.strang = bits[2];
 
-		bits = StringUtils.escapeSplit(contEsc, contSep, bits[1]);
+		bits = StringUtils.escapeSplit(parameterObject.contEsc, parameterObject.contSep, bits[1]);
 
-		cs.controls = new Control[bits.length];
+		cs.controls = new Control[bits.length];
 
-		for (int i = 0; i < bits.length; i++) {
-			String bit = bits[i];
+		for (int i = 0; i < bits.length; i++) {
+			String bit = bits[i];
 
-			String[] bots = StringUtils.escapeSplit(contEsc, contArg, bit);
+			String[] bots = StringUtils.escapeSplit(parameterObject.contEsc, parameterObject.contArg, bit);
 
-			Control cont = new Control(bots[0]);
+			Control cont = new Control(bots[0]);
 
-			if (cont.name.length() > 1) {
-				cont.name = cont.name.toUpperCase();
+			if (cont.name.length() > 1) {
+				cont.name = cont.name.toUpperCase();
 			}
 
-			if (bots.length > 1) {
-				cont.args = new String[bots.length - 1];
-				for (int j = 1; j < bots.length; j++) {
-					cont.args[j - 1] = bots[j];
+			if (bots.length > 1) {
+				cont.args = new String[bots.length - 1];
+				for (int j = 1; j < bots.length; j++) {
+					cont.args[j - 1] = bots[j];
 				}
 			}
 
-			cs.controls[i] = cont;
+			cs.controls[i] = cont;
 		}
 
-		return cs;
+		return cs;
+	}
+
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+
+		sb.append("//");
+
+		for (Control cont : controls) {
+			sb.append(cont);
+		}
+
+		sb.append("//");
+		sb.append(strang);
+
+		return sb.toString();
 	}
 }
 
\ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ReplError.html b/docs/jacoco-ut/bjc.everge/ReplError.html index 7b798b3..5fe14b6 100644 --- a/docs/jacoco-ut/bjc.everge/ReplError.html +++ b/docs/jacoco-ut/bjc.everge/ReplError.html @@ -1 +1 @@ -ReplError

ReplError

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total72 of 13245%7 of 812%6971825
toString()500%40%334411
toPrintString(String)183666%3125%232501
toPrintString()40%n/a111111
ReplError(int, int, String, String)15100%n/a010601
ReplError(IntHolder, IntHolder, String, String)9100%n/a010201
\ No newline at end of file +ReplError

ReplError

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total57 of 13256%5 of 837%5951825
toString()500%40%334411
toPrintString()40%n/a111111
toPrintString(String)35194%1375%130501
ReplError(int, int, String, String)15100%n/a010601
ReplError(IntHolder, IntHolder, String, String)9100%n/a010201
\ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ReplError.java.html b/docs/jacoco-ut/bjc.everge/ReplError.java.html index e2d44dc..1e0ba81 100644 --- a/docs/jacoco-ut/bjc.everge/ReplError.java.html +++ b/docs/jacoco-ut/bjc.everge/ReplError.java.html @@ -76,9 +76,9 @@ public class ReplError { public String toPrintString(String hdr) { String errString; - if (txt == null) errString = "No associated line"; - else if (txt.equals("")) errString = "Text of line was empty"; - else errString = "Text of line was: " + txt; + if (txt == null) errString = "No associated line"; + else if (txt.equals("")) errString = "Text of line was empty"; + else errString = "Text of line was: " + txt; return String.format("[ERROR] line %d, pair %d: %s\n%s\tContext: %s", line, numPairs, msg, hdr, errString); diff --git a/docs/jacoco-ut/bjc.everge/ReplOpts.html b/docs/jacoco-ut/bjc.everge/ReplOpts.html index ff2c6e2..9d884f8 100644 --- a/docs/jacoco-ut/bjc.everge/ReplOpts.html +++ b/docs/jacoco-ut/bjc.everge/ReplOpts.html @@ -1 +1 @@ -ReplOpts

ReplOpts

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total66 of 9631%18 of 180%1011112112
equals(Object)660%180%1010111111
ReplOpts()30100%n/a0101001
\ No newline at end of file +ReplOpts

ReplOpts

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total147 of 17716%30 of 300%1718223223
hashCode()770%100%66101011
equals(Object)700%200%1111121211
ReplOpts()30100%n/a0101001
\ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ReplOpts.java.html b/docs/jacoco-ut/bjc.everge/ReplOpts.java.html index 1194cd3..8e3e829 100644 --- a/docs/jacoco-ut/bjc.everge/ReplOpts.java.html +++ b/docs/jacoco-ut/bjc.everge/ReplOpts.java.html @@ -45,27 +45,33 @@ import java.io.PrintStream; public PrintStream outStream = System.out; public PrintStream errStream = System.err; - @Override - public boolean equals(Object o) { - if (o == null) return false; - - if (!getClass().equals(o.getClass())) return false; - - ReplOpts ro = (ReplOpts)o; - - if (isPerf != ro.isPerf) return false; - - if (isDebug != ro.isDebug) return false; - if (isTrace != ro.isTrace) return false; - - if (defPrior != ro.defPrior) return false; - if (defStage != ro.defStage) return false; - if (defMulti != ro.defMulti) return false; - - if (defStatus != ro.defStatus) return false; - - return true; + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (defMulti ? 1231 : 1237); + result = prime * result + defPrior; + result = prime * result + defStage; + result = prime * result + ((defStatus == null) ? 0 : defStatus.hashCode()); + result = prime * result + (isDebug ? 1231 : 1237); + result = prime * result + (isPerf ? 1231 : 1237); + result = prime * result + (isTrace ? 1231 : 1237); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + ReplOpts other = (ReplOpts) obj; + if (defMulti != other.defMulti) return false; + if (defPrior != other.defPrior) return false; + if (defStage != other.defStage) return false; + if (defStatus != other.defStatus) return false; + if (isDebug != other.isDebug) return false; + if (isPerf != other.isPerf) return false; + if (isTrace != other.isTrace) return false; + return true; } } \ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ReplPair.html b/docs/jacoco-ut/bjc.everge/ReplPair.html index f4c8951..e7404ea 100644 --- a/docs/jacoco-ut/bjc.everge/ReplPair.html +++ b/docs/jacoco-ut/bjc.everge/ReplPair.html @@ -1 +1 @@ -ReplPair

ReplPair

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total800 of 1,62250%87 of 18653%73123138336217
readList(List, Scanner, List, ReplOpts)28237056%315162%25433612501
readGlobal(String, Scanner, List, ReplOpts, IntHolder, IntHolder)1869132%181240%1724436901
getControls(String, List, ReplOpts, IntHolder, IntHolder, String)1350%120%77252511
readName(String, Scanner, List, ReplPair, ReplOpts, IntHolder, IntHolder)13111045%111354%1017306001
readMultiLine(String, Scanner, ReplOpts, List, String, IntHolder)378469%81260%61122001
equals(Object)123675%6650%670801
toString()103376%1150%120301
ReplPair(String, String, String)70%n/a112211
readList(List, Scanner)20100%2100%020501
ReplPair(String, String, int, String)18100%n/a010701
compareTo(ReplPair)17100%2100%020201
readList(Scanner)8100%n/a010201
readList(List, Scanner, List)8100%n/a010101
ReplPair()7100%n/a010201
ReplPair(String, String, int)7100%n/a010201
apply(String)7100%n/a010101
ReplPair(String, String)6100%n/a010201
\ No newline at end of file +ReplPair

ReplPair

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total940 of 1,77547%99 of 20451%83133161355218
readGlobal(String, Scanner, List, ReplOpts, IntHolder, IntHolder)3028722%241233%2127699001
readList(List, Scanner, List, ReplOpts)25437559%295163%24422611601
readName(String, Scanner, List, ReplPair, ReplOpts, IntHolder, IntHolder)2149630%141450%1219456901
hashCode()590%60%448811
readMultiLine(String, Scanner, ReplOpts, List, String, IntHolder)378469%81260%61122001
equals(Object)315262%171139%141531601
getControls(String, List, ReplOpts, IntHolder, IntHolder, String)261027%n/a016701
toString()103376%1150%120301
ReplPair(String, String, String)70%n/a112211
readList(List, Scanner)20100%2100%020501
ReplPair(String, String, int, String)18100%n/a010701
compareTo(ReplPair)17100%2100%020201
readList(Scanner)8100%n/a010201
readList(List, Scanner, List)8100%n/a010101
ReplPair()7100%n/a010201
ReplPair(String, String, int)7100%n/a010201
apply(String)7100%n/a010101
ReplPair(String, String)6100%n/a010201
\ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ReplPair.java.html b/docs/jacoco-ut/bjc.everge/ReplPair.java.html index 7cfa2b5..9701d27 100644 --- a/docs/jacoco-ut/bjc.everge/ReplPair.java.html +++ b/docs/jacoco-ut/bjc.everge/ReplPair.java.html @@ -7,6 +7,7 @@ import java.util.Scanner; import java.util.function.UnaryOperator; import bjc.everge.ControlledString.Control; +import bjc.everge.ControlledString.ParseStrings; /** * String pairs for replacements. @@ -21,7 +22,7 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St private int stage; // Status of this pair with regards to doing staging stuff - private StageStatus stat = StageStatus.BOTH; + private StageStatus stat = StageStatus.BOTH; /** * The priority for this replacement. @@ -49,8 +50,8 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * Create a new blank replacement pair. */ public ReplPair() { - this("", "", 1, null); - } + this("", "", 1, null); + } /** * Create a new replacement pair with a priority of 1. @@ -61,8 +62,8 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The string to replace. */ public ReplPair(String f, String r) { - this(f, r, 1); - } + this(f, r, 1); + } /** * Create a new named replacement pair with a priority of 1. @@ -75,8 +76,8 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The name of the replacement pair. */ public ReplPair(String f, String r, String n) { - this(f, r, 1, n); - } + this(f, r, 1, n); + } /** * Create a new replacement pair with a set priority. @@ -89,8 +90,8 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The priority for the replacement. */ public ReplPair(String f, String r, int p) { - this(f, r, p, f); - } + this(f, r, p, f); + } /** * Create a new replacement pair with a set priority and name. @@ -104,14 +105,14 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * @param p * The priority for the replacement. */ - public ReplPair(String f, String r, int p, String n) { - find = f; - replace = r; + public ReplPair(String f, String r, int p, String n) { + find = f; + replace = r; - name = n; + name = n; - priority = p; - } + priority = p; + } /** * Read a list of replacement pairs from an input source. @@ -122,9 +123,9 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The list of replacements. */ public static List<ReplPair> readList(Scanner scn) { - List<ReplPair> lst = new ArrayList<>(); + List<ReplPair> lst = new ArrayList<>(); - return readList(lst, scn); + return readList(lst, scn); } /** @@ -139,15 +140,15 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The list of replacements. */ public static List<ReplPair> readList(List<ReplPair> detals, Scanner scn) { - List<ReplError> errList = new ArrayList<>(); + List<ReplError> errList = new ArrayList<>(); - List<ReplPair> rplPar = readList(detals, scn, errList); + List<ReplPair> rplPar = readList(detals, scn, errList); - if (errList.size() != 0) { - throw new ReplParseException("", errList); + if (errList.size() != 0) { + throw new ReplParseException("", errList); } - return rplPar; + return rplPar; } /** @@ -164,7 +165,7 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * The list of replacements. */ public static List<ReplPair> readList(List<ReplPair> detals, Scanner scn, List<ReplError> errs) { - return readList(detals, scn, errs, new ReplOpts()); + return readList(detals, scn, errs, new ReplOpts()); } /** @@ -182,634 +183,632 @@ public class ReplPair implements Comparable<ReplPair>, UnaryOperator<St * @return * The list of replacements. */ - public static List<ReplPair> readList(List<ReplPair> detals, Scanner scn, - List<ReplError> errs, ReplOpts ropts) { - IntHolder lno = new IntHolder(); - IntHolder pno = new IntHolder(); + public static List<ReplPair> readList( + List<ReplPair> detals, Scanner scn, + List<ReplError> errs, ReplOpts ropts) + { + IntHolder lno = new IntHolder(); + IntHolder pno = new IntHolder(); - List<List<ReplPair>> stages = new ArrayList<>(); - stages.add(new ArrayList<ReplPair>()); + List<List<ReplPair>> stages = new ArrayList<>(); + stages.add(new ArrayList<ReplPair>()); // For every line in the source... - while (scn.hasNextLine()) { - String name = scn.nextLine().trim(); - lno.incr(); + while (scn.hasNextLine()) { + String name = scn.nextLine().trim(); + lno.incr(); // If its commented or blank, skip it - if (name.equals("")) continue; - if (name.startsWith("#")) continue; + if (name.equals("")) continue; + if (name.startsWith("#")) continue; // Global control. Process it. - if (name.startsWith("|//")) { - readGlobal(name, scn, errs, ropts, lno, pno); + if (name.startsWith("|//")) { + readGlobal(name, scn, errs, ropts, lno, pno); - continue; + continue; } - ReplPair rp = new ReplPair(); + ReplPair rp = new ReplPair(); - rp.priority = ropts.defPrior; - rp.stat = ropts.defStatus; - rp.lno = lno.get(); - rp.stage = ropts.defStage; + rp.priority = ropts.defPrior; + rp.stat = ropts.defStatus; + rp.lno = lno.get(); + rp.stage = ropts.defStage; - boolean isMulti = ropts.defMulti; + boolean isMulti = ropts.defMulti; { - String tmpName = readName(name, scn, errs, rp, ropts, lno, pno); - if (tmpName == null) continue; - name = tmpName; + String tmpName = readName(name, scn, errs, rp, ropts, lno, pno); + if (tmpName == null) continue; + name = tmpName; } - rp.find = name; - if (rp.name == null) rp.name = name; + rp.find = name; + if (rp.name == null) rp.name = name; // We started to process the pair, mark it as being // started - pno.incr(); - String body = null; + pno.incr(); + String body = null; // Read in the next uncommented line do { - if (!scn.hasNextLine()) break; + if (!scn.hasNextLine()) break; - body = scn.nextLine().trim(); - lno.incr(); - } while (body.startsWith("#")); + body = scn.nextLine().trim(); + lno.incr(); + } while (body.startsWith("#")); - if (body == null) { - String msg = - "Ran out of input looking for replacement body for raw name '" + name + "'"; + if (body == null) { + String msg = String.format( + "Ran out of input looking for replacement body for raw name '%s'", name); - errs.add(new ReplError(lno, pno, msg, null)); - break; + errs.add(new ReplError(lno, pno, msg, null)); + break; } - isMulti = ropts.defMulti; - + isMulti = ropts.defMulti; + + ControlledString cs = getControls(body, errs, ropts, lno, pno, "body"); // Body has attached controls, process them. - if (body.startsWith("//")) { - body = body.substring(2); - - String[] bodyBits = StringUtils.escapeSplit("|", "//", body); - if (bodyBits.length < 2) { - String msg = "Did not find control terminator (//) in body where it should be"; - - errs.add(new ReplError(lno, pno, msg, body)); - continue; - } - - String contBody = bodyBits[0]; - String actBody = bodyBits[1]; - - // Split out each control - String[] bits = StringUtils.escapeSplit("|", ";", actBody); - - for (String bit : bits) { - String bitHead = bit.toUpperCase(); - String bitBody = bit; - - String[] bots = StringUtils.escapeSplit("|", "/", bit); - if (bots.length > 1) { - bitHead = bots[0].toUpperCase(); - bitBody = bots[1]; - } - - switch (bitHead) { + if (cs.hasControls()) { + for (Control cont : cs.controls) { + switch (cont.name) { case "MULTITRUE": case "MULTIT": case "MT": - isMulti = true; - break; + isMulti = true; + break; case "MULTIFALSE": case "MULTIF": case "MF": - isMulti = false; - break; + isMulti = false; + break; case "MULTI": case "M": - isMulti = Boolean.parseBoolean(bitBody); - break; + if (cont.count() != 1) { + String errMsg = String.format("Expected one multi flag (got %d)", cont.count()); + errs.add(new ReplError(lno, pno, errMsg, body)); + } else { + isMulti = Boolean.parseBoolean(cont.get(0)); + } + break; default: - errs.add(new ReplError(lno, pno, String.format("Invalid control name '%s'", bitHead), body)); + { + String errMsg = String.format("Invalid control name '%s'", cont.name); + errs.add(new ReplError(lno, pno, errMsg, body)); + } break; } } - body = actBody; + body = cs.strang; } - if (isMulti) { - String tmp = readMultiLine(body, scn, ropts, errs, "body", lno); - if (tmp == null) continue; - body = tmp; + if (isMulti) { + String tmp = readMultiLine(body, scn, ropts, errs, "body", lno); + if (tmp == null) continue; + body = tmp; } - rp.replace = body; + rp.replace = body; - List<ReplPair> stageList = null; - if (rp.stage == 0 || stages.size() < (rp.stage - 1)) { - stageList = stages.get(rp.stage); + List<ReplPair> stageList = null; + if (rp.stage == 0 || stages.size() < (rp.stage - 1)) { + stageList = stages.get(rp.stage); - if (stageList == null) { - stageList = new ArrayList<>(); + if (stageList == null) { + stageList = new ArrayList<>(); - stages.add(rp.stage, stageList); + stages.add(rp.stage, stageList); } } else { - for (int i = stages.size(); i <= rp.stage; i++) { - stages.add(new ArrayList<>()); + for (int i = stages.size(); i <= rp.stage; i++) { + stages.add(new ArrayList<>()); } - stageList = stages.get(rp.stage); + stageList = stages.get(rp.stage); } - if (ropts.isTrace) { - ropts.errStream.printf("\t[DEBUG] Stage %d: Added %s\n\t\tContents: %s\n", - rp.stage, rp, stageList); + if (ropts.isTrace) { + ropts.errStream.printf("\t[DEBUG] Stage %d: Added %s\n\t\tContents: %s\n", + rp.stage, rp, stageList); } - stageList.add(rp); - } + stageList.add(rp); + } // Special-case one-stage processing. - if (stages.size() == 1) { - if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Executing single-stage bypass\n"); + if (stages.size() == 1) { + if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Executing single-stage bypass\n"); - for (ReplPair rp : stages.iterator().next()) { - if (rp.stat == StageStatus.INTERNAL) { - if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Excluding internal RP %s\n", rp); + for (ReplPair rp : stages.iterator().next()) { + if (rp.stat == StageStatus.INTERNAL) { + if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Excluding internal RP %s\n", rp); continue; } - detals.add(rp); - } + detals.add(rp); + } - detals.sort(null); + detals.sort(null); - return detals; + return detals; } // Handle stages - List<ReplPair> tmpList = new ArrayList<>(); - tmpList.addAll(detals); + List<ReplPair> tmpList = new ArrayList<>(); + tmpList.addAll(detals); - if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Stages: %s\n", stages); + if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Stages: %s\n", stages); - int procStg = 0; - for (List<ReplPair> stageList : stages) { - procStg += 1; - List<ReplPair> curStage = new ArrayList<>(); + int procStg = 0; + for (List<ReplPair> stageList : stages) { + procStg += 1; + List<ReplPair> curStage = new ArrayList<>(); - if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Staging stage %d of %d: %s\n", - procStg, stageList.size(), stageList); + if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Staging stage %d of %d: %s\n", + procStg, stageList.size(), stageList); - for (ReplPair rp : stageList) { + for (ReplPair rp : stageList) { // Process through every pair in the previous // stages - for (ReplPair curPar : tmpList) { - String tmp = rp.replace.replaceAll(curPar.find, curPar.replace); + for (ReplPair curPar : tmpList) { + String tmp = rp.replace.replaceAll(curPar.find, curPar.replace); - if (ropts.isTrace && !rp.replace.equals(tmp)) { - ropts.errStream.printf("\t[DEBUG] Staged '%s' -> '%s'\t%s\n", + if (ropts.isTrace && !rp.replace.equals(tmp)) { + ropts.errStream.printf("\t[DEBUG] Staged '%s' -> '%s'\t%s\n", rp.replace, tmp, curPar); } - rp.replace = tmp; - } + rp.replace = tmp; + } // If we're external; add straight to the output - if (rp.stat == StageStatus.EXTERNAL) { - if (ropts.isTrace) { - ropts.errStream.printf("\t[DEBUG] Skipped external for staging: %s\n", + if (rp.stat == StageStatus.EXTERNAL) { + if (ropts.isTrace) { + ropts.errStream.printf("\t[DEBUG] Skipped external for staging: %s\n", rp); } - detals.add(rp); + detals.add(rp); } else { - if (ropts.isTrace) { - ropts.errStream.printf("\t[DEBUG] Added to stage %d: %s\n\t\tContents: %s\n", - procStg, rp, curStage); + if (ropts.isTrace) { + ropts.errStream.printf("\t[DEBUG] Added to stage %d: %s\n\t\tContents: %s\n", + procStg, rp, curStage); } - curStage.add(rp); + curStage.add(rp); } - } + } - tmpList.addAll(curStage); - tmpList.sort(null); - } + tmpList.addAll(curStage); + tmpList.sort(null); + } // Copy over to output, excluding internals - for (ReplPair rp : tmpList) { - if (rp.stat == StageStatus.INTERNAL) { - if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Excluded internal: %s\n", rp); + for (ReplPair rp : tmpList) { + if (rp.stat == StageStatus.INTERNAL) { + if (ropts.isTrace) ropts.errStream.printf("\t[DEBUG] Excluded internal: %s\n", rp); continue; } - detals.add(rp); - } + detals.add(rp); + } - detals.sort(null); + detals.sort(null); - if (ropts.isTrace) { - ropts.errStream.printf("\t[DEBUG] Final output: %s\n", detals); + if (ropts.isTrace) { + ropts.errStream.printf("\t[DEBUG] Final output: %s\n", detals); } - return detals; + return detals; } private static String readMultiLine(String lead, Scanner src, ReplOpts ropts, List<ReplError> errs, String typ, IntHolder lno) { - String tmp = lead; + String tmp = lead; - if (ropts.isTrace && tmp.endsWith("\\")) - ropts.errStream.printf("\t[TRACE] Starting multi-line parse for %s '%s'\n", typ, tmp); + if (ropts.isTrace && tmp.endsWith("\\")) + ropts.errStream.printf("\t[TRACE] Starting multi-line parse for %s '%s'\n", typ, tmp); - boolean didMulti = tmp.endsWith("\\"); - while (tmp.endsWith("\\")) { - boolean incNL = tmp.endsWith("|\\"); + boolean didMulti = tmp.endsWith("\\"); + while (tmp.endsWith("\\")) { + boolean incNL = tmp.endsWith("|\\"); - if (!src.hasNextLine()) break; + if (!src.hasNextLine()) break; - String nxt = src.nextLine().trim(); - lno.incr(); + String nxt = src.nextLine().trim(); + lno.incr(); - if (nxt.startsWith("#")) continue; + if (nxt.startsWith("#")) continue; - String nlStr = incNL ? "\n" : ""; + String nlStr = incNL ? "\n" : ""; - if (tmp.endsWith("\\")) { - if (incNL) { - tmp = tmp.substring(0, tmp.length() - 2); + if (tmp.endsWith("\\")) { + if (incNL) { + tmp = tmp.substring(0, tmp.length() - 2); } else { - tmp = tmp.substring(0, tmp.length() - 1); + tmp = tmp.substring(0, tmp.length() - 1); } } - tmp = String.format("%s%s%s", tmp, nlStr, nxt); - } + tmp = String.format("%s%s%s", tmp, nlStr, nxt); + } - if (ropts.isTrace && didMulti) - ropts.errStream.printf("\t[TRACE] Finished multi-line parse for %s:\n%s\n.\n", + if (ropts.isTrace && didMulti) + ropts.errStream.printf("\t[TRACE] Finished multi-line parse for %s:\n%s\n.\n", typ, tmp); - return tmp; + return tmp; } @Override public String apply(String inp) { - return inp.replaceAll(find, replace); + return inp.replaceAll(find, replace); } @Override public String toString() { - String nameStr = ""; + String nameStr = ""; - if (!find.equals(name)) nameStr = String.format("(%s)", name); + if (!find.equals(name)) nameStr = String.format("(%s)", name); - return String.format("%ss/%s/%s/p(%d)", nameStr, find, replace, priority); + return String.format("%ss/(%s)/(%s)/p(%d)", nameStr, find, replace, priority); } @Override public int compareTo(ReplPair rp) { - if (this.priority == rp.priority) return this.lno - rp.lno; + if (this.priority == rp.priority) return this.lno - rp.lno; - return rp.priority - this.priority; + return rp.priority - this.priority; } - + @Override - public boolean equals(Object o) { - if (o == null) return false; - - if (!getClass().equals(o.getClass())) return false; - - ReplPair ro = (ReplPair)o; - - if (!find.equals(ro.find)) return false; - // lno is not a field we consider for equality - if (!name.equals(ro.name)) return false; - if (priority != ro.priority) return false; - if (!replace.equals(ro.name)) return false; - // stat is not a field we consider for equality + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((find == null) ? 0 : find.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + priority; + result = prime * result + ((replace == null) ? 0 : replace.hashCode()); + result = prime * result + stage; + return result; + } - return true; + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + ReplPair other = (ReplPair) obj; + if (find == null) { + if (other.find != null) return false; + } else if (!find.equals(other.find)) return false; + if (name == null) { + if (other.name != null) return false; + } else if (!name.equals(other.name)) return false; + if (priority != other.priority) return false; + if (replace == null) { + if (other.replace != null) return false; + } else if (!replace.equals(other.replace)) return false; + if (stage != other.stage) return false; + return true; } private static String readName(String nam, Scanner scn, List<ReplError> errs, ReplPair rp, ReplOpts ropts, IntHolder lno, IntHolder pno) { - String name = nam; + ControlledString cs = getControls(nam, errs, ropts, lno, pno, "name"); - boolean isMulti = ropts.defMulti; + boolean isMulti = ropts.defMulti; - // Name has attached controls, process them. - if (name.startsWith("//")) { - name = name.substring(2); + String name = cs.strang; - String[] nameBits = StringUtils.escapeSplit("|", "//", name); + if (cs.hasControls()) { + for (Control cont : cs.controls) { + switch (cont.name) { + case "NAME": + case "N": + if (cont.count() != 1) { + String errMsg = String.format("One name argument was expected (got %d)", + cont.count()); - if (nameBits.length < 2) { - String msg = "Did not find control terminator (//) in name where it should be"; - - errs.add(new ReplError(lno, pno, msg, name)); - return null; - } - - String contName = nameBits[0]; - String actName = nameBits[1]; - - // Split out each control - String[] bits = StringUtils.escapeSplit("|", ";", contName); - - for (String bit : bits) { - String bitHead = bit.toUpperCase(); - String bitBody = bit; + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + rp.name = cont.get(0); + } + break; + case "PRIORITY": + case "PRIOR": + case "P": + try { + if (cont.count() != 1) { + String errMsg = String.format("One priority argument was expected (got %d", + cont.count()); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + rp.priority = Integer.parseInt(cont.get(0)); + } + } catch (NumberFormatException nfex) { + String errMsg = String.format("'%s' is not a valid priority (must be an integer)", + cont.get(0)); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } + break; + case "STAGE": + case "S": + try { + if (cont.count() != 1) { + String errMsg = String.format("One stage argument was expected (got %d", + cont.count()); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + int tmpStage = Integer.parseInt(cont.get(0)); + if (tmpStage < 0) { + String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)", + cont.get(0)); + errs.add(new ReplError(lno, pno, errMsg, nam)); + + break; + } + rp.stage = tmpStage; + } + } catch (NumberFormatException nfex) { + String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)", + cont.get(0)); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } + break; + case "MULTITRUE": + case "MULTIT": + case "MT": + isMulti = true; + break; + case "MULTIFALSE": + case "MULTIF": + case "MF": + isMulti = false; + break; + case "MULTI": + case "M": + if (cont.count() != 1) { + String errMsg = String.format("One multi-flag argument was expected (got %d", + cont.count()); - String[] bots = StringUtils.escapeSplit("|", "/", bit); + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + isMulti = Boolean.parseBoolean(cont.get(0)); + } + break; + case "INTERNAL": + case "INT": + case "I": + rp.stat = StageStatus.INTERNAL; + break; + case "EXTERNAL": + case "EXT": + case "E": + rp.stat = StageStatus.EXTERNAL; + break; + case "BOTH": + case "B": + rp.stat = StageStatus.BOTH; + break; + default: + { + String errMsg = String.format("Unknown control name '%s' for name '%s'", + cont.name, nam); - if (bots.length > 1) { - bitHead = bots[0].toUpperCase(); - bitBody = bots[1]; - } + ReplError erd = new ReplError(lno, pno, errMsg, nam); - switch (bitHead) { - case "NAME": - case "N": - rp.name = bitBody; - break; - case "PRIORITY": - case "PRIOR": - case "P": - try { - rp.priority = Integer.parseInt(bitBody); - } catch (NumberFormatException nfex) { - String errMsg = String.format("'%s' is not a valid priority (must be an integer)", bitBody); - errs.add(new ReplError(lno, pno, errMsg, name)); - } - break; - case "STAGE": - case "S": - try { - int tmpStage = Integer.parseInt(bitBody); - if (tmpStage < 0) { - String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)", bitBody); - errs.add(new ReplError(lno, pno, errMsg, name)); - - break; + errs.add(erd); } - rp.stage = tmpStage; - } catch (NumberFormatException nfex) { - String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)", bitBody); - errs.add(new ReplError(lno, pno, errMsg, name)); - } - break; - case "MULTITRUE": - case "MULTIT": - case "MT": - isMulti = true; - break; - case "MULTIFALSE": - case "MULTIF": - case "MF": - isMulti = false; - break; - case "MULTI": - case "M": - isMulti = Boolean.parseBoolean(bitBody); - break; - case "INTERNAL": - case "INT": - case "I": - rp.stat = StageStatus.INTERNAL; - break; - case "EXTERNAL": - case "EXT": - case "E": - rp.stat = StageStatus.EXTERNAL; - break; - case "BOTH": - case "B": - rp.stat = StageStatus.BOTH; - break; - default: - { - ReplError erd = new ReplError(lno, pno, - String.format("Unknown control name '%s' for name '%s'", - bitHead, name), name); - - errs.add(erd); - } - break; + break; } - - name = actName; } - // Multi-line name with a trailer - if (isMulti) { - String tmp = readMultiLine(name, scn, ropts, errs, "name", lno); - if (tmp == null) return null; - name = tmp; - } + name = cs.strang; + } + + // Multi-line name with a trailer + if (isMulti) { + String tmp = readMultiLine(name, scn, ropts, errs, "name", lno); + if (tmp == null) return null; + name = tmp; } - return name; + return name; } private static void readGlobal(String nam, Scanner scn, List<ReplError> errs, ReplOpts ropts, IntHolder lno, IntHolder pno) { - String name = nam.substring(3); - - // Split out each control - String[] bits = StringUtils.escapeSplit("|", ";", name); - if (ropts.isTrace) { - ropts.errStream.printf("\t[TRACE] Split control bits are: \n"); - for (String bit : bits) { - ropts.errStream.printf("%s, ", bit); - } - ropts.errStream.println(); - } - for (String bit : bits) { - String bitHead = bit.toUpperCase(); - String bitBody = bit; - - String[] bots = StringUtils.escapeSplit("|", "/", bit); - if (bots.length > 1) { - bitHead = bots[0]; - bitBody = bots[1]; - } + ControlledString cs = getControls(nam.substring(1), errs, ropts, lno, pno, "global"); - switch (bitHead) { + for (Control cont : cs.controls) { + switch (cont.name) { case "PRIORITY": case "PRIOR": case "P": try { - int tmp = Integer.parseInt(bitBody); - ropts.defPrior = tmp; - } catch (NumberFormatException nfex) { - String errMsg = String.format("'%s' is not a valid priority (must be an integer)", - bitBody); - - errs.add(new ReplError(lno, pno, errMsg, name)); - } - break; + if (cont.count() != 1) { + String errMsg = String.format("Must specify 1 priority (%d specified)", + cont.count()); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + int tmp = Integer.parseInt(cont.get(0)); + ropts.defPrior = tmp; + } + } catch (NumberFormatException nfex) { + String errMsg = String.format("'%s' is not a valid priority (must be an integer)", + cont.get(0)); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } + break; case "STAGE": case "S": try { - int tmpStage = Integer.parseInt(bitBody); + if (cont.count() != 1) { + String errMsg = String.format("Must specify 1 stage (%d specified)", + cont.count()); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + int tmpStage = Integer.parseInt(cont.get(0)); + + if (tmpStage < 0) { + String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)", + cont.get(0)); - if (tmpStage < 0) { - String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)", - bitBody); + errs.add(new ReplError(lno, pno, errMsg, nam)); + break; + } - errs.add(new ReplError(lno, pno, errMsg, name)); - break; + ropts.defStage = tmpStage; } - ropts.defStage = tmpStage; - } catch (NumberFormatException nfex) { - String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)", - bitBody); - - errs.add(new ReplError(lno, pno, errMsg, name)); - } - break; + } catch (NumberFormatException nfex) { + String errMsg = String.format("'%s' is not a valid stage (must be a positive integer)", + cont.get(0)); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } + break; case "MULTITRUE": case "MULTIT": case "MT": - ropts.defMulti = true; - break; + ropts.defMulti = true; + break; case "MULTIFALSE": case "MULTIF": case "MF": - ropts.defMulti = false; - break; + ropts.defMulti = false; + break; case "MULTI": case "M": - ropts.defMulti = Boolean.parseBoolean(bitBody); - break; + if (cont.count() != 1) { + String errMsg = String.format("Must specify 1 multi-flag (%d specified)", + cont.count()); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + ropts.defMulti = Boolean.parseBoolean(cont.get(0)); + } + break; case "INTERNAL": case "INT": case "I": - ropts.defStatus = StageStatus.INTERNAL; - break; + ropts.defStatus = StageStatus.INTERNAL; + break; case "EXTERNAL": case "EXT": case "E": - ropts.defStatus = StageStatus.EXTERNAL; - break; + ropts.defStatus = StageStatus.EXTERNAL; + break; case "BOTH": case "B": - ropts.defStatus = StageStatus.BOTH; - break; + ropts.defStatus = StageStatus.BOTH; + break; case "DEBUGTRUE": case "DEBUGT": case "DT": - ropts.isDebug = true; - break; + ropts.isDebug = true; + break; case "DEBUGFALSE": case "DEBUGF": case "DF": - ropts.isDebug = false; - break; + ropts.isDebug = false; + break; case "DEBUG": case "D": - ropts.isDebug = Boolean.parseBoolean(bitBody); - break; + if (cont.count() != 1) { + String errMsg = String.format("Must specify 1 debug flag (%d specified)", + cont.count()); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + ropts.isDebug = Boolean.parseBoolean(cont.get(0)); + } + break; case "TRACETRUE": case "TRACET": case "TT": - ropts.isTrace = true; - break; + ropts.isTrace = true; + break; case "TRACEFALSE": case "TRACEF": case "TF": - ropts.isTrace = false; - break; + ropts.isTrace = false; + break; case "TRACE": case "T": - ropts.isTrace = Boolean.parseBoolean(bitBody); - break; + if (cont.count() != 1) { + String errMsg = String.format("Must specify 1 trace flag (%d specified)", + cont.count()); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + ropts.isTrace = Boolean.parseBoolean(cont.get(0)); + } + break; case "PERFTRUE": case "PERFT": case "PRFT": - ropts.isPerf = true; - break; + ropts.isPerf = true; + break; case "PERFFALSE": case "PERFF": case "PRFF": - ropts.isPerf = false; - break; + ropts.isPerf = false; + break; case "PERF": case "PRF": - ropts.isPerf = Boolean.parseBoolean(bitBody); - break; + if (cont.count() != 1) { + String errMsg = String.format("Must specify 1 perf. flag (%d specified)", + cont.count()); + + errs.add(new ReplError(lno, pno, errMsg, nam)); + } else { + ropts.isPerf = Boolean.parseBoolean(cont.get(0)); + } + break; default: { - String msg = String.format("Invalid global control name '%s'", bitHead); - ReplError err = new ReplError(lno, pno, msg, name); - errs.add(err); + String msg = String.format("Invalid global control name '%s'", cont.name); + ReplError err = new ReplError(lno, pno, msg, nam); + errs.add(err); } break; } - if (ropts.isTrace) - ropts.errStream.printf("\t[TRACE] Processed global control '%s':'%s'\n", - bitHead, bitBody); + if (ropts.isTrace) + ropts.errStream.printf("\t[TRACE] Processed global control '%s'\n", cont); } - return; + return; } private static ControlledString getControls(String lne, List<ReplError> errs, - ReplOpts ropts, IntHolder lno, IntHolder pno, String type) { - if (!lne.startsWith("//")) { - return new ControlledString(lne); + ReplOpts ropts, IntHolder lno, IntHolder pno, String type) + { + try { + return ControlledString.parse(lne, new ParseStrings("//", ";", "/", "|")); + } catch (IllegalArgumentException iaex) { + String msg = "Did not find control terminator (//) in %s where it should be"; + msg = String.format(msg, type); + + ReplError re = new ReplError(lno, pno, msg, lne); + errs.add(re); + + return null; } - - String tmp = lne.substring(2); - - String[] bits = StringUtils.escapeSplit("|", "//", lne); - - if (bits.length < 2) { - String msg = "Did not find control terminator (//) in %s where it should be"; - msg = String.format(msg, type); - - ReplError re = new ReplError(lno, pno, msg, lne); - errs.add(re); - - return null; - } - - ControlledString cs = new ControlledString(bits[0]); - - bits = StringUtils.escapeSplit("|", ";", bits[1]); - - cs.controls = new Control[bits.length]; - - for (int i = 0; i < bits.length; i++) { - String bit = bits[i]; - - String[] bots = StringUtils.escapeSplit("|", "/", bit); - - Control cont = new Control(bots[0]); - - if (cont.name.length() > 1) { - cont.name = cont.name.toUpperCase(); - } - - if (bots.length > 1) { - cont.args = new String[bots.length - 1]; - for (int j = 1; j < bots.length; j++) { - cont.args[j - 1] = bots[j]; - } - } - - cs.controls[i] = cont; - } - - return cs; } } \ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ReplParseException.html b/docs/jacoco-ut/bjc.everge/ReplParseException.html index db90db6..f80f7cb 100644 --- a/docs/jacoco-ut/bjc.everge/ReplParseException.html +++ b/docs/jacoco-ut/bjc.everge/ReplParseException.html @@ -1 +1 @@ -ReplParseException

ReplParseException

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total59 of 12853%6 of 1250%710112724
toString()280%20%224411
toPrintString()246272%4660%4651801
ReplParseException(String)70%n/a112211
ReplParseException(String, List)7100%n/a010301
\ No newline at end of file +ReplParseException

ReplParseException

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total59 of 12853%6 of 1250%710112724
toString()280%20%224411
toPrintString()246272%4660%4651801
ReplParseException(String)70%n/a112211
ReplParseException(String, List)7100%n/a010301
\ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/ReplParseException.java.html b/docs/jacoco-ut/bjc.everge/ReplParseException.java.html index 322ba21..717bf7f 100644 --- a/docs/jacoco-ut/bjc.everge/ReplParseException.java.html +++ b/docs/jacoco-ut/bjc.everge/ReplParseException.java.html @@ -4,56 +4,60 @@ import java.util.ArrayList; import java.util.List; public class ReplParseException extends RuntimeException { + /** + * Serialization ID. + */ + private static final long serialVersionUID = 4752304282380556849L; public List<ReplError> errs; public ReplParseException(String msg) { - this(msg, new ArrayList<>()); - } + this(msg, new ArrayList<>()); + } public ReplParseException(String msg, List<ReplError> errs) { - super(msg); + super(msg); - this.errs = errs; - } + this.errs = errs; + } @Override public String toString() { String errString; - if (errs.size() == 0) errString = "An error"; - else errString = "Errors"; + if (errs.size() == 0) errString = "An error"; + else errString = "Errors"; - return String.format("%s occured parsing replacement pairs: %s\n%s", - errString, getMessage(), errs); + return String.format("%s occured parsing replacement pairs: %s\n%s", + errString, getMessage(), errs); } public String toPrintString() { - StringBuilder errString = new StringBuilder("[ERROR] "); + StringBuilder errString = new StringBuilder("[ERROR] "); - if (errs.size() == 0) { - errString.append("No specific errors"); - } else if (errs.size() == 1) { - errString.append("An error"); + if (errs.size() == 0) { + errString.append("No specific errors"); + } else if (errs.size() == 1) { + errString.append("An error"); } else { - errString.append(errs.size()); - errString.append(" errors"); + errString.append(errs.size()); + errString.append(" errors"); } - errString.append(" occured parsing replacement pairs:"); - if (!getMessage().equals("")) { - errString.append(" "); - errString.append(getMessage()); + errString.append(" occured parsing replacement pairs:"); + if (!getMessage().equals("")) { + errString.append(" "); + errString.append(getMessage()); } - if (errs.size() > 0) { - errString.append("\n\t"); + if (errs.size() > 0) { + errString.append("\n\t"); - for (ReplError err : errs) { - errString.append(err.toPrintString("\t")); - errString.append("\n\t"); - } + for (ReplError err : errs) { + errString.append(err.toPrintString("\t")); + errString.append("\n\t"); + } } - return errString.toString().trim(); + return errString.toString().trim(); } } \ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/index.html b/docs/jacoco-ut/bjc.everge/index.html index c22add6..dbd7838 100644 --- a/docs/jacoco-ut/bjc.everge/index.html +++ b/docs/jacoco-ut/bjc.everge/index.html @@ -1 +1 @@ -bjc.everge

bjc.everge

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total2,013 of 3,67345%209 of 38145%1792703887692661312
ReplPair80082250%879953%7312313833621701
Everge53431937%542934%41551241992801
StringUtils19027058%173768%163024801301
ControlledString1590%140%121235355511
ReplSet1050%60%9924246611
ReplError726045%712%697182501
ReplOpts663031%180%101111211201
ReplParseException596953%6650%71011272401
ControlledString.Control180%n/a33993311
IntHolder2268%n/a265122601
Everge.InputStatus34100%n/a01040101
StageStatus34100%n/a01040101
\ No newline at end of file +bjc.everge

bjc.everge

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total2,256 of 4,20846%242 of 45947%2063214158522673113
ReplPair94083547%9910551%8313316135521801
Everge53431937%542934%41551241992801
StringUtils19027058%173768%163024801301
ReplOpts1473016%300%171822322301
ControlledString.Control13210143%222250%203121463901
ReplSet1050%60%9924246611
ControlledString7414866%31583%51617443701
ReplParseException596953%6650%71011272401
ReplError577556%5337%595182501
IntHolder2268%n/a265122601
ControlledString.ParseStrings1565%n/a12171201
Everge.InputStatus34100%n/a01040101
StageStatus34100%n/a01040101
\ No newline at end of file diff --git a/docs/jacoco-ut/bjc.everge/index.source.html b/docs/jacoco-ut/bjc.everge/index.source.html index 0b57023..97db308 100644 --- a/docs/jacoco-ut/bjc.everge/index.source.html +++ b/docs/jacoco-ut/bjc.everge/index.source.html @@ -1 +1 @@ -bjc.everge

bjc.everge

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total2,013 of 3,67345%209 of 38145%1792703887692661312
ReplPair.java80082250%879953%7312313833621701
Everge.java53435339%542934%41561242032902
StringUtils.java19027058%173768%163024801301
ControlledString.java1770%140%151544448822
ReplSet.java1050%60%9924246611
ReplError.java726045%712%697182501
ReplOpts.java663031%180%101111211201
ReplParseException.java596953%6650%71011272401
IntHolder.java2268%n/a265122601
StageStatus.java34100%n/a01040101
\ No newline at end of file +bjc.everge

bjc.everge

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total2,256 of 4,20846%242 of 45947%2063214158522673113
ReplPair.java94083547%9910551%8313316135521801
Everge.java53435339%542934%41561242032902
ControlledString.java21426455%253759%2649399771803
StringUtils.java19027058%173768%163024801301
ReplOpts.java1473016%300%171822322301
ReplSet.java1050%60%9924246611
ReplParseException.java596953%6650%71011272401
ReplError.java577556%5337%595182501
IntHolder.java2268%n/a265122601
StageStatus.java34100%n/a01040101
\ No newline at end of file -- cgit v1.2.3