summaryrefslogtreecommitdiff
path: root/src/main/java/tlIItools/NameFileReader.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/tlIItools/NameFileReader.java')
-rw-r--r--src/main/java/tlIItools/NameFileReader.java136
1 files changed, 38 insertions, 98 deletions
diff --git a/src/main/java/tlIItools/NameFileReader.java b/src/main/java/tlIItools/NameFileReader.java
index 8b1b62d4..a9646942 100644
--- a/src/main/java/tlIItools/NameFileReader.java
+++ b/src/main/java/tlIItools/NameFileReader.java
@@ -1,120 +1,71 @@
package tlIItools;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.Reader;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-
-/**
- * Reads in a list of file names to process.
+import java.io.*;
+
+import java.util.*;
+
+/** Reads in a list of file names to process.
*
- * @author Ben Culkin
- */
+ * @author Ben Culkin */
public class NameFileReader {
- /**
- * Are we attempting to guess group names?
- */
+ /** Are we attempting to guess group names? */
public boolean guessGroups;
-
- /**
- * Regex to use for guessing group names.
- */
+ /** Regex to use for guessing group names. */
public String groupRx;
-
- /**
- * The default group to put files into.
- */
+ /** The default group to put files into. */
public String defGroup;
-
- /**
- * The map of file groups.
- */
+ /** The map of file groups. */
public Map<String, List<String>> fNames;
- /*
- * The current group.
- */
+ /* The current group. */
private String curGroup;
- /*
- * The list of files for the current group.
- */
+ /* The list of files for the current group. */
private List<String> curList;
- /**
- * Counts the files read in.
- */
+ /** Counts the files read in. */
public int fCount;
- /**
- * Stream to write normal output to.
- */
+ /** Stream to write normal output to. */
public PrintStream normOut = System.out;
-
- /**
- * Stream to write error output to.
- */
+ /** Stream to write error output to. */
public PrintStream errOut = System.err;
- /**
- * Create a new name reader using the default settings.
+ /** Create a new name reader using the default settings.
*
- * Guessing groups is disabled by default.
- */
+ * Guessing groups is disabled by default. */
public NameFileReader() {
this(false);
}
- /**
- * Create a new name reader using the default settings.
+ /** Create a new name reader using the default settings.
*
- * @param guessGroups
- * Controls whether or not to try to guess file groups from file
- * names.
- */
+ * @param guessGroups Controls whether or not to try to guess file groups from file names. */
public NameFileReader(boolean guessGroups) {
this(new HashMap<>(), "default", guessGroups);
}
- /**
- * Create a new name reader using the specified settings.
- *
- * @param fNames
- * The set of groups to add files to.
- *
- * @param defGroup
- * The name of the default file group.
+ /** Create a new name reader using the specified settings.
*
- * @param guessGroups
- * Whether or not to attempt to guess group names.
- */
+ * @param fNames The set of groups to add files to.
+ * @param defGroup The name of the default file group.
+ * @param guessGroups Whether or not to attempt to guess group names. */
public NameFileReader(Map<String, List<String>> fNames, String defGroup, boolean guessGroups) {
- if (!fNames.containsKey(defGroup))
- fNames.put(defGroup, new ArrayList<>());
+ if (!fNames.containsKey(defGroup)) fNames.put(defGroup, new ArrayList<>());
this.fNames = fNames;
- this.defGroup = defGroup;
-
+ this.defGroup = defGroup;
this.guessGroups = guessGroups;
+ this.curGroup = defGroup;
- this.curGroup = defGroup;
- this.curList = fNames.get(curGroup);
+ this.curList = fNames.get(curGroup);
this.fCount = 0;
}
- /**
- * Read in file names from a file.
+ /** Read in file names from a file.
*
- * @param from
- * The name of the file to read from.
- */
+ * @param from The name of the file to read from. */
public void readFrom(String from) {
try (FileReader fr = new FileReader(from)) {
readFrom(fr);
@@ -125,13 +76,9 @@ public class NameFileReader {
}
}
- /**
- * Read in file names from an input source.
- *
- * @param r
- * The input source to read from.
+ /** Read in file names from an input source.
*
- */
+ * @param r The input source to read from. */
public void readFrom(Reader r) {
Scanner scn = new Scanner(r);
@@ -160,12 +107,9 @@ public class NameFileReader {
scn.close();
}
- /**
- * Swap to a new file group.
+ /** Swap to a new file group.
*
- * @param groupName
- * The name of the group to swap to.
- */
+ * @param groupName The name of the group to swap to. */
public void swapGroup(String groupName) {
curGroup = groupName;
@@ -178,23 +122,19 @@ public class NameFileReader {
}
}
- /**
- * Add a file to this file reader.
+ /** Add a file to this file reader.
*
- * @param fName The file to add.
- */
+ * @param fName The file to add. */
public void addFile(String fName) {
curList.add(fName);
fCount += 1;
}
- /**
- * Add a file to this file reader.
+ /** Add a file to this file reader.
*
- * @param groupName The group to add the file to. *
- * @param fName The file to add.
- */
+ * @param groupName The group to add the file to.
+ * @param fName The file to add. */
public void addFile(String groupName, String fName) {
fNames.computeIfAbsent(groupName, (key) -> new ArrayList<>()).add(fName);