summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-10-31 11:14:07 -0400
committerBen Culkin <scorpress@gmail.com>2020-10-31 11:14:07 -0400
commite8b01037e47884c10d9f910192ac59cef14d28bf (patch)
treea48b8b4748679e87f250164788f5c38c78edd2f6
parentd43c2e002313cf649aab00ade69f777a94dd5633 (diff)
Do some restructuring
-rw-r--r--pom.xml10
-rw-r--r--src/main/java/bjc/everge/Everge.java2
-rw-r--r--src/main/java/bjc/everge/IntHolder.java72
-rw-r--r--src/main/java/bjc/everge/LogStream.java341
-rw-r--r--src/main/java/bjc/everge/MirrorOutputStream.java63
-rw-r--r--src/main/java/bjc/everge/ReplError.java2
-rw-r--r--src/main/java/bjc/everge/ReplPair.java1
-rw-r--r--src/test/java/bjc/everge/EvergeTest.java2
8 files changed, 17 insertions, 476 deletions
diff --git a/pom.xml b/pom.xml
index b36b2d6..8f23d4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,6 +46,16 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>bjc</groupId>
+ <artifactId>BJC-Utils2</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.github.bculkin2442</groupId>
+ <artifactId>esodata</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/src/main/java/bjc/everge/Everge.java b/src/main/java/bjc/everge/Everge.java
index c2e361f..d5090db 100644
--- a/src/main/java/bjc/everge/Everge.java
+++ b/src/main/java/bjc/everge/Everge.java
@@ -7,6 +7,8 @@ import java.util.*;
import java.util.concurrent.locks.*;
import java.util.regex.*;
+import bjc.utils.ioutils.*;
+
/**
* Everge front-end application.
*
diff --git a/src/main/java/bjc/everge/IntHolder.java b/src/main/java/bjc/everge/IntHolder.java
deleted file mode 100644
index 31c2578..0000000
--- a/src/main/java/bjc/everge/IntHolder.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package bjc.everge;
-
-/**
- * Utility class for ints by ref.
- *
- * @author Ben Culkin
- */
-public class IntHolder {
- /**
- * The int value.
- */
- public int val;
-
- /**
- * Create a new int-holder set to 0.
- */
- public IntHolder() {
- val = 0;
- }
-
- /**
- * Create a new int-holder set to a value.
- *
- * @param i
- * The value to set the int to.
- */
- public IntHolder(int i) {
- val = i;
- }
-
- /**
- * Increment the value by one, and return it.
- *
- * @return The value of the holder.
- */
- public int incr() {
- return incr(1);
- }
-
- /**
- * Increment the value by an amount and return it.
- *
- * @param i
- * The amount to increment by.
- *
- * @return The value of the holder.
- */
- public int incr(int i) {
- val += 1;
-
- return val;
- }
-
- /**
- * Get the value.
- *
- * @return The value.
- */
- public int get() {
- return val;
- }
-
- /**
- * Set the value.
- *
- * @param i
- * The value to set it to.
- */
- public void set(int i) {
- val = i;
- }
-}
diff --git a/src/main/java/bjc/everge/LogStream.java b/src/main/java/bjc/everge/LogStream.java
deleted file mode 100644
index fe37d21..0000000
--- a/src/main/java/bjc/everge/LogStream.java
+++ /dev/null
@@ -1,341 +0,0 @@
-package bjc.everge;
-
-import java.io.*;
-
-/**
- * Simple class used for logging with various levels.
- *
- * @author Ben Culkin
- */
-public class LogStream {
- /**
- * Log level for printing nothing.
- */
- public static final int NOTHING = -1;
-
- /**
- * Log level for printing only fatal errors.
- */
- public static final int FATAL = 0;
-
- /**
- * Log level for printing all errors.
- */
- public static final int ERROR = 1;
-
- /**
- * Log level for printing warnings.
- */
- public static final int WARN = 2;
-
- /**
- * Log level for printing info messages.
- */
- public static final int INFO = 3;
-
- /**
- * Log level for printing debug messages.
- */
- public static final int DEBUG = 4;
-
- /**
- * Log level for printing trace messages.
- */
- public static final int TRACE = 5;
-
- private int verbosity;
-
- private PrintStream output;
-
- /**
- * Create a new log stream.
- *
- * Defaults to printing only fatal errors.
- *
- * @param out
- * The output stream to place things into.
- */
- public LogStream(PrintStream out) {
- output = out;
- verbosity = FATAL;
- }
-
- /**
- * Create a new log stream.
- *
- * @param out
- * The output stream to place things into.
- * @param level
- * The verbosity level. Use the constants in this class for the
- * values.
- */
- public LogStream(PrintStream out, int level) {
- output = out;
- verbosity = level;
- }
-
- /**
- * Create a new log stream.
- *
- * Defaults to printing only fatal errors.
- *
- * @param out
- * The output stream to place things into.
- */
- public LogStream(OutputStream out) {
- output = new PrintStream(out);
- verbosity = FATAL;
- }
-
- /**
- * Create a new log stream.
- *
- * @param out
- * The output stream to place things into.
- * @param level
- * The verbosity level. Use the constants in this class for the
- * values.
- */
- public LogStream(OutputStream out, int level) {
- output = new PrintStream(out);
- verbosity = level;
- }
-
- /**
- * Get the verbosity of the stream.
- *
- * @return The verbosity of the stream.
- */
- public int verbosity() {
- return verbosity;
- }
-
- /**
- * Set the verbosity of the stream.
- *
- * @param verb
- * The verbosity of the stream.
- */
- public void verbosity(int verb) {
- verbosity = verb;
- }
-
- /**
- * Increment the verbosity of the stream.
- */
- public void louder() {
- louder(1);
- }
-
- /**
- * Increase the verbosity of the stream by an amount.
- *
- * @param amt
- * The amount to increase the verbosity by.
- */
- public void louder(int amt) {
- verbosity += amt;
- }
-
- /**
- * Decrement the verbosity of the stream.
- */
- public void quieter() {
- quieter(1);
- }
-
- /**
- * Decrease the verbosity of the stream by an amount.
- *
- * @param amt
- * The amount to decrease the verbosity by.
- */
- public void quieter(int amt) {
- verbosity -= amt;
- }
-
- /**
- * Print a message that will always be visible.
- *
- * @param msg
- * The message to print.
- */
- public void print(String msg) {
- output.print(msg);
- }
-
- /**
- * Print a formatted message that will always be visible.
- *
- * @param msg
- * The format string for the message to print.
- *
- * @param args
- * The arguments to the format string.
- */
- public void printf(String msg, Object... args) {
- output.printf(msg, args);
- }
-
- /**
- * Print a message at a given verbosity level.
- *
- * @param lvl
- * The verbosity level.
- * @param msg
- * The message to print.
- */
- public void message(int lvl, String msg) {
- if (verbosity >= lvl) {
- output.print(msg);
- }
- }
-
- /**
- * Print a formatted message at a given verbosity level.
- *
- * @param lvl
- * The verbosity level.
- * @param msg
- * The message to print.
- * @param args
- * The arguments to the message.
- */
- public void messagef(int lvl, String msg, Object... args) {
- if (verbosity >= lvl) {
- output.printf(msg, args);
- }
- }
-
- /**
- * Emit a fatal error message.
- *
- * @param msg
- * The message to emit.
- */
- public void fatal(String msg) {
- message(FATAL, msg);
- }
-
- /**
- * Emit a formatted fatal error message.
- *
- * @param msg
- * The message to emit.
- * @param args
- * The arguments to the message.
- */
- public void fatalf(String msg, Object... args) {
- messagef(FATAL, msg, args);
- }
-
- /**
- * Emit a normal error message.
- *
- * @param msg
- * The message to emit.
- */
- public void error(String msg) {
- message(ERROR, msg);
- }
-
- /**
- * Emit a formatted normal error message.
- *
- * @param msg
- * The message to emit.
- * @param args
- * The arguments to the message.
- */
- public void errorf(String msg, Object... args) {
- messagef(ERROR, msg, args);
- }
-
- /**
- * Emit a warning message.
- *
- * @param msg
- * The message to emit.
- */
- public void warn(String msg) {
- message(WARN, msg);
- }
-
- /**
- * Emit a formatted warning message.
- *
- * @param msg
- * The message to emit.
- * @param args
- * The arguments to the message.
- */
- public void warnf(String msg, Object... args) {
- messagef(WARN, msg, args);
- }
-
- /**
- * Emit an info message.
- *
- * @param msg
- * The message to emit.
- */
- public void info(String msg) {
- message(INFO, msg);
- }
-
- /**
- * Emit a formatted info message.
- *
- * @param msg
- * The message to emit.
- * @param args
- * The arguments to the message.
- */
- public void infof(String msg, Object... args) {
- messagef(INFO, msg, args);
- }
-
- /**
- * Emit a debug message.
- *
- * @param msg
- * The message to emit.
- */
- public void debug(String msg) {
- message(DEBUG, msg);
- }
-
- /**
- * Emit a formatted debug message.
- *
- * @param msg
- * The message to emit.
- * @param args
- * The arguments to the message.
- */
- public void debugf(String msg, Object... args) {
- messagef(DEBUG, msg, args);
- }
-
- /**
- * Emit a tracing message.
- *
- * @param msg
- * The message to emit.
- */
- public void trace(String msg) {
- message(TRACE, msg);
- }
-
- /**
- * Emit a formatted tracing message.
- *
- * @param msg
- * The message to emit.
- * @param args
- * The arguments to the message.
- */
- public void tracef(String msg, Object... args) {
- messagef(TRACE, msg, args);
- }
-}
diff --git a/src/main/java/bjc/everge/MirrorOutputStream.java b/src/main/java/bjc/everge/MirrorOutputStream.java
deleted file mode 100644
index bce4f0f..0000000
--- a/src/main/java/bjc/everge/MirrorOutputStream.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package bjc.everge;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * An output stream that mirrors its contents to other streams.
- *
- * @author Ben Culkin
- *
- */
-public class MirrorOutputStream extends OutputStream {
- private List<OutputStream> streams;
-
- /**
- * Create a new mirroring output stream.
- *
- * @param strams
- * The output streams to mirror to.
- */
- public MirrorOutputStream(OutputStream... strams) {
- streams = new ArrayList<>();
-
- for (OutputStream stram : strams) {
- streams.add(stram);
- }
- }
-
- @Override
- public void close() throws IOException {
- for (OutputStream stream : streams) {
- stream.close();
- }
- }
-
- @Override
- public void flush() throws IOException {
- for (OutputStream stream : streams) {
- stream.flush();
- }
- }
-
- @Override
- public void write(byte[] ba) throws IOException {
- for (OutputStream stream : streams) {
- stream.write(ba);
- }
- }
-
- @Override
- public void write(byte[] ba, int off, int len) throws IOException {
- for (OutputStream stream : streams) {
- stream.write(ba, off, len);
- }
- }
-
- @Override
- public void write(int b) throws IOException {
- for (OutputStream stream : streams) {
- stream.write(b);
- }
- }
-}
diff --git a/src/main/java/bjc/everge/ReplError.java b/src/main/java/bjc/everge/ReplError.java
index 27324ca..f9a30a9 100644
--- a/src/main/java/bjc/everge/ReplError.java
+++ b/src/main/java/bjc/everge/ReplError.java
@@ -1,5 +1,7 @@
package bjc.everge;
+import bjc.data.IntHolder;
+
/**
* Represents an error encountered parsing ReplPairs
*
diff --git a/src/main/java/bjc/everge/ReplPair.java b/src/main/java/bjc/everge/ReplPair.java
index 74addc7..153efb3 100644
--- a/src/main/java/bjc/everge/ReplPair.java
+++ b/src/main/java/bjc/everge/ReplPair.java
@@ -4,6 +4,7 @@ import java.util.*;
import java.util.function.*;
import java.util.regex.*;
+import bjc.data.IntHolder;
import bjc.everge.ControlledString.*;
/**
diff --git a/src/test/java/bjc/everge/EvergeTest.java b/src/test/java/bjc/everge/EvergeTest.java
index c99b15e..b70fd26 100644
--- a/src/test/java/bjc/everge/EvergeTest.java
+++ b/src/test/java/bjc/everge/EvergeTest.java
@@ -9,6 +9,8 @@ import static bjc.everge.TestUtils.*;
import org.junit.Test;
+import bjc.utils.ioutils.*;
+
/**
* Unit tests for Everge front-end.
*