summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/everge/ReplSet.java
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-10-31 12:45:15 -0400
committerBen Culkin <scorpress@gmail.com>2020-10-31 12:45:15 -0400
commitd5eaaa14adc980e9b0588a3caf7ee7d81df1183e (patch)
tree866603edc90f0e1538e869db8a7732ce8c4bf03c /src/main/java/bjc/everge/ReplSet.java
parente8b01037e47884c10d9f910192ac59cef14d28bf (diff)
General cleanup
This does a bunch of structural cleanups to make the code better
Diffstat (limited to 'src/main/java/bjc/everge/ReplSet.java')
-rw-r--r--src/main/java/bjc/everge/ReplSet.java106
1 files changed, 0 insertions, 106 deletions
diff --git a/src/main/java/bjc/everge/ReplSet.java b/src/main/java/bjc/everge/ReplSet.java
deleted file mode 100644
index 0daa725..0000000
--- a/src/main/java/bjc/everge/ReplSet.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package bjc.everge;
-
-import java.io.*;
-
-import java.util.*;
-
-/**
- * A set of ReplPairs, kept together for easy use
- *
- * @author Ben Culkin
- */
-public class ReplSet {
- // The list of pairs
- private List<ReplPair> parList;
-
- /**
- * Create a new blank set of pairs.
- */
- public ReplSet() {
- parList = new ArrayList<>();
- }
-
- /**
- * Create a new set of pairs using an existing list of pairs.
- *
- * Changes to the list of pairs will carry across to the ReplSet, so be careful
- * about that.
- *
- * @param lst
- * The list of pairs to use.
- */
- public ReplSet(List<ReplPair> lst) {
- parList = lst;
- }
-
- /**
- * Load a ReplSet from a file.
- *
- * @param fName
- * The file to load the ReplSet from.
- * @return A ReplSet, loaded from the file.
- * @throws IOException
- * if something goes badly reading it.
- */
- public static ReplSet fromFile(String fName) throws IOException {
- ReplSet rs = new ReplSet();
-
- try (FileInputStream fis = new FileInputStream(fName);
- Scanner scn = new Scanner(fis)) {
- rs.parList = ReplPair.readList(scn);
- }
-
- return rs;
- }
-
- /**
- * Adds more pairs to the ReplSet.
- *
- * @param pars
- * The pairs to add to the ReplSet.
- */
- public void addPairs(List<ReplPair> pars) {
- for (ReplPair par : pars) {
- parList.add(par);
- }
-
- // Resort the pairs into priority order
- parList.sort(null);
- }
-
- /**
- * Adds more pairs to the ReplSet.
- *
- * @param pars
- * The pairs to add to the ReplSet.
- */
- public void addPairs(ReplPair... pars) {
- for (ReplPair par : pars) {
- parList.add(par);
- }
-
- // Resort the pairs into priority order
- parList.sort(null);
- }
-
- /**
- * Apply the ReplSet to a string.
- *
- * @param val
- * The string to apply the ReplSet to.
- *
- * @return The result of applying the ReplSet.
- */
- public String apply(String val) {
- String ret = val;
-
- for (ReplPair par : parList) {
- System.err.printf("Applying pair '%s' to string '%s' (original was '%s')\n", par, ret, val);
- String tmp = par.apply(ret);
-
- ret = tmp;
- }
-
- return ret;
- }
-}