Recording source file names in output files, allowing output of intermediate results

This commit is contained in:
2021-11-18 15:38:29 -06:00
parent 09aa5961f3
commit 2ab93dd4b7
8 changed files with 73 additions and 29 deletions

View File

@@ -12,18 +12,20 @@ import java.util.List;
public class MatchingFileWriter {
private String filename;
private String sourceFileName;
private List<String> comments;
private List<String> headers;
private List<List<String>> results;
private List<List<String>> allResults;
public MatchingFileWriter(String filename, List<String> comments, List<String> headers, List<List<String>> results){
public MatchingFileWriter(String filename, MatchingResult result){
if(!filename.matches(".*\\.csv")){
filename = filename + ".csv";
}
this.filename = filename;
this.comments = comments;
this.headers = headers;
this.results = results;
this.sourceFileName = result.getSourceFileName();
this.comments = result.getComments();
this.headers = result.getHeaders();
this.allResults = result.getAllResults();
}
public void writeResultsToFile(){
@@ -41,8 +43,8 @@ public class MatchingFileWriter {
for(String comment: comments){
printer.printComment(comment);
}
results.add(0, headers);
printer.printRecords(results);
allResults.add(0, headers);
printer.printRecords(allResults);
} catch(IOException ex){
System.out.println("Could not make new file named "+filename);