Procházet zdrojové kódy

Encapsulate fields of the submission class by using accessors methods and update all depending classes.

Timur Sağlam před 5 roky
rodič
revize
fbfad7cce8

+ 4 - 4
jplag/src/main/java/jplag/GreedyStringTiling.java

@@ -94,7 +94,7 @@ public class GreedyStringTiling implements TokenConstants {
 
     private final JPlagComparison swapAndCompare(Submission firstSubmission, Submission secondSubmission, boolean withBaseCode) {
         Submission smallerSubmission, largerSubmission;
-        if (firstSubmission.tokenList.size() > secondSubmission.tokenList.size()) {
+        if (firstSubmission.getTokenList().size() > secondSubmission.getTokenList().size()) {
             smallerSubmission = secondSubmission;
             largerSubmission = firstSubmission;
         } else {
@@ -102,7 +102,7 @@ public class GreedyStringTiling implements TokenConstants {
             largerSubmission = secondSubmission;
         }
         // if hashtable exists in first but not in second structure: flip around!
-        if (largerSubmission.tokenList.tokenHashes == null && smallerSubmission.tokenList.tokenHashes != null) {
+        if (largerSubmission.getTokenList().tokenHashes == null && smallerSubmission.getTokenList().tokenHashes != null) {
             Submission swap = smallerSubmission;
             smallerSubmission = largerSubmission;
             largerSubmission = swap;
@@ -119,8 +119,8 @@ public class GreedyStringTiling implements TokenConstants {
      */
     private final JPlagComparison compare(Submission firstSubmission, Submission secondSubmission, boolean withBaseCode) {
         // first and second refer to the list of tokens of the first and second submission:
-        TokenList first = firstSubmission.tokenList;
-        TokenList second = secondSubmission.tokenList;
+        TokenList first = firstSubmission.getTokenList();
+        TokenList second = secondSubmission.getTokenList();
 
         // Initialize:
         JPlagComparison comparison = new JPlagComparison(firstSubmission, secondSubmission);

+ 8 - 8
jplag/src/main/java/jplag/JPlag.java

@@ -180,7 +180,7 @@ public class JPlag implements ProgramI {
     }
 
     private Vector<Submission> filterValidSubmissions(Vector<Submission> submissions) {
-        return submissions.stream().filter(submission -> !submission.hasErrors).collect(Collectors.toCollection(Vector::new));
+        return submissions.stream().filter(submission -> !submission.hasErrors()).collect(Collectors.toCollection(Vector::new));
     }
 
     /**
@@ -313,7 +313,7 @@ public class JPlag implements ProgramI {
         }
 
         long msec = System.currentTimeMillis();
-        print("----- Parsing basecode submission: " + subm.name + "\n", null);
+        print("----- Parsing basecode submission: " + subm.getName() + "\n", null);
 
         // lets go:
 
@@ -322,12 +322,12 @@ public class JPlag implements ProgramI {
             throw new ExitException("Bad basecode submission");
         }
 
-        if (subm.tokenList != null && subm.getNumberOfTokens() < options.getMinTokenMatch()) {
+        if (subm.getTokenList() != null && subm.getNumberOfTokens() < options.getMinTokenMatch()) {
             throw new ExitException("Basecode submission contains fewer tokens " + "than minimum match length allows!\n");
         }
 
         if (options.hasBaseCode()) {
-            gSTiling.createHashes(subm.tokenList, options.getMinTokenMatch(), true);
+            gSTiling.createHashes(subm.getTokenList(), options.getMinTokenMatch(), true);
         }
 
         print("\nBasecode submission parsed!\n", null);
@@ -358,8 +358,8 @@ public class JPlag implements ProgramI {
             boolean removed = false;
             Submission subm = iter.next();
 
-            print(null, "------ Parsing submission: " + subm.name + "\n");
-            currentSubmissionName = subm.name;
+            print(null, "------ Parsing submission: " + subm.getName() + "\n");
+            currentSubmissionName = subm.getName();
 
             if (!(ok = subm.parse())) {
                 errors++;
@@ -367,9 +367,9 @@ public class JPlag implements ProgramI {
 
             count++;
 
-            if (subm.tokenList != null && subm.getNumberOfTokens() < options.getMinTokenMatch()) {
+            if (subm.getTokenList() != null && subm.getNumberOfTokens() < options.getMinTokenMatch()) {
                 print(null, "Submission contains fewer tokens than minimum match " + "length allows!\n");
-                subm.tokenList = null;
+                subm.setTokenList(null);
                 invalid++;
                 removed = true;
             }

+ 12 - 12
jplag/src/main/java/jplag/JPlagComparison.java

@@ -71,7 +71,7 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
             return new String[] {};
         }
 
-        TokenList tokenList = (j == 0 ? firstSubmission : secondSubmission).tokenList;
+        TokenList tokenList = (j == 0 ? firstSubmission : secondSubmission).getTokenList();
         int i, h, starti, starth, count = 1;
 
         o1: for (i = 1; i < matches.size(); i++) {
@@ -176,11 +176,11 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
     public final float similarity() {
         float sa, sb;
         if (secondBaseCodeMatches != null && firstBaseCodeMatches != null) {
-            sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size() - firstBaseCodeMatches.getNumberOfMatchedTokens();
-            sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size() - secondBaseCodeMatches.getNumberOfMatchedTokens();
+            sa = firstSubmission.getNumberOfTokens() - firstSubmission.getFiles().size() - firstBaseCodeMatches.getNumberOfMatchedTokens();
+            sb = secondSubmission.getNumberOfTokens() - secondSubmission.getFiles().size() - secondBaseCodeMatches.getNumberOfMatchedTokens();
         } else {
-            sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
-            sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
+            sa = firstSubmission.getNumberOfTokens() - firstSubmission.getFiles().size();
+            sb = secondSubmission.getNumberOfTokens() - secondSubmission.getFiles().size();
         }
         return (200 * getNumberOfMatchedTokens()) / (sa + sb);
     }
@@ -192,9 +192,9 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
     public final float similarityOfFirst() {
         int divisor;
         if (firstBaseCodeMatches != null) {
-            divisor = firstSubmission.getNumberOfTokens() - firstSubmission.files.size() - firstBaseCodeMatches.getNumberOfMatchedTokens();
+            divisor = firstSubmission.getNumberOfTokens() - firstSubmission.getFiles().size() - firstBaseCodeMatches.getNumberOfMatchedTokens();
         } else {
-            divisor = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
+            divisor = firstSubmission.getNumberOfTokens() - firstSubmission.getFiles().size();
         }
         return (divisor == 0 ? 0f : (getNumberOfMatchedTokens() * 100 / (float) divisor));
     }
@@ -206,9 +206,9 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
     public final float similarityOfSecond() {
         int divisor;
         if (secondBaseCodeMatches != null) {
-            divisor = secondSubmission.getNumberOfTokens() - secondSubmission.files.size() - secondBaseCodeMatches.getNumberOfMatchedTokens();
+            divisor = secondSubmission.getNumberOfTokens() - secondSubmission.getFiles().size() - secondBaseCodeMatches.getNumberOfMatchedTokens();
         } else {
-            divisor = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
+            divisor = secondSubmission.getNumberOfTokens() - secondSubmission.getFiles().size();
         }
         return (divisor == 0 ? 0f : (getNumberOfMatchedTokens() * 100 / (float) divisor));
     }
@@ -288,16 +288,16 @@ public class JPlagComparison implements Comparator<JPlagComparison> {
 
     @Override
     public String toString() {
-        return firstSubmission.name + " <-> " + secondSubmission.name;
+        return firstSubmission.getName() + " <-> " + secondSubmission.getName();
     }
 
     private final float firstBasecodeSimilarity() {
-        float sa = firstSubmission.getNumberOfTokens() - firstSubmission.files.size();
+        float sa = firstSubmission.getNumberOfTokens() - firstSubmission.getFiles().size();
         return firstBaseCodeMatches.getNumberOfMatchedTokens() * 100 / sa;
     }
 
     private final float secondBasecodeSimilarity() {
-        float sb = secondSubmission.getNumberOfTokens() - secondSubmission.files.size();
+        float sb = secondSubmission.getNumberOfTokens() - secondSubmission.getFiles().size();
         return secondBaseCodeMatches.getNumberOfMatchedTokens() * 100 / sb;
     }
 

+ 114 - 87
jplag/src/main/java/jplag/Submission.java

@@ -13,8 +13,8 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
-import java.util.List;
 import java.util.Vector;
 
 /**
@@ -22,30 +22,20 @@ import java.util.Vector;
  */
 public class Submission implements Comparable<Submission> {
 
-    /**
-     * Name that uniquely identifies this submission. Will most commonly be the directory or file name.
-     */
-    public String name;
+    private static final String ERROR_FOLDER = "errors";
 
-    private File submissionFile;
+    private final String name; // uniquely identifies this submission (e.g. directory or file name)
 
-    /**
-     * List of files this submission consists of.
-     */
-    public List<File> files;
+    private final File submissionFile;
 
-    /**
-     * List of tokens that have been parsed from the files this submission consists of.
-     */
-    public TokenList tokenList;
-
-    /**
-     * True, if at least one error occurred while parsing this submission; false otherwise.
-     */
-    public boolean hasErrors = false;
+    private final Collection<File> files; // files of which the submission consists.
 
     private final JPlag program;
 
+    private boolean hasErrors; // indicates that at least one error occurred while parsing this submission
+
+    private TokenList tokenList; // parsed tokens from the files
+
     public Submission(String name, File submissionFile, JPlag program) {
         this.name = name;
         this.submissionFile = submissionFile;
@@ -54,36 +44,20 @@ public class Submission implements Comparable<Submission> {
     }
 
     /**
-     * Recursively scan the given directory for nested files. Excluded files and files with an invalid suffix are ignored.
-     * <p>
-     * If the given file is not a directory, the input will be returned as a singleton list.
-     * @param file - File to start the scan from.
-     * @return a list of nested files.
+     * @return a list of files this submission consists of.
      */
-    private List<File> parseFilesRecursively(File file) {
-        if (program.isFileExcluded(file)) {
-            return Collections.emptyList();
-        }
-
-        if (file.isFile() && program.hasValidSuffix(file)) {
-            return Collections.singletonList(file);
-        }
-
-        String[] nestedFileNames = file.list();
-
-        if (nestedFileNames == null) {
-            return Collections.emptyList();
-        }
-
-        List<File> files = new ArrayList<>();
-
-        for (String fileName : nestedFileNames) {
-            files.addAll(parseFilesRecursively(new File(file, fileName)));
-        }
-
+    public Collection<File> getFiles() {
         return files;
     }
 
+    /**
+     * @return return the name that uniquely identifies this submission. Will most commonly be the directory or file
+     * name.return the name that uniquely identifies this submission. Will most commonly be the directory or file name.
+     */
+    public String getName() {
+        return name;
+    }
+
     public int getNumberOfTokens() {
         if (tokenList == null) {
             return 0;
@@ -92,31 +66,18 @@ public class Submission implements Comparable<Submission> {
         return tokenList.size();
     }
 
-    @Override
-    public int compareTo(Submission other) {
-        return name.compareTo(other.name);
-    }
-
-    @Override
-    public String toString() {
-        return name;
+    /**
+     * @return list of tokens that have been parsed from the files this submission consists of.
+     */
+    public TokenList getTokenList() {
+        return tokenList;
     }
 
     /**
-     * Map all files of this submission to their path relative to the submission directory.
-     * <p>
-     * This method is required to stay compatible with `program.language.parse(...)` as it requires the given file paths to
-     * be relative to the submission directory.
-     * <p>
-     * In a future update, `program.language.parse(...)` should probably just take a list of files.
-     * @param baseFile - File to base all relative file paths on.
-     * @param files - List of files to map.
-     * @return an array of file paths relative to the submission directory.
+     * @return true if at least one error occurred while parsing this submission; false otherwise.
      */
-    private String[] getRelativeFilePaths(File baseFile, List<File> files) {
-        Path baseFilePath = baseFile.toPath();
-
-        return files.stream().map(File::toPath).map(baseFilePath::relativize).map(Path::toString).toArray(String[]::new);
+    public boolean hasErrors() {
+        return hasErrors;
     }
 
     /* parse all the files... */
@@ -159,7 +120,6 @@ public class Submission implements Comparable<Submission> {
             text.removeAllElements();
 
             try {
-                /* file encoding = "UTF-8" */
                 FileInputStream fileInputStream = new FileInputStream(new File(submissionFile, files[i]));
                 InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
                 BufferedReader in = new BufferedReader(inputStreamReader);
@@ -233,6 +193,44 @@ public class Submission implements Comparable<Submission> {
         }
     }
 
+    /**
+     * Sets the tokens that have been parsed from the files this submission consists of.
+     * @param tokenList is the list of these tokens.
+     */
+    public void setTokenList(TokenList tokenList) {
+        this.tokenList = tokenList;
+    }
+
+    @Override
+    public int compareTo(Submission other) {
+        return name.compareTo(other.name);
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    /** Physical copy. :-) */
+    private void copyFile(File in, File out) {
+        byte[] buffer = new byte[10000];
+        try {
+            FileInputStream input = new FileInputStream(in);
+            FileOutputStream output = new FileOutputStream(out);
+            int count;
+            do {
+                count = input.read(buffer);
+                if (count != -1) {
+                    output.write(buffer, 0, count);
+                }
+            } while (count != -1);
+            input.close();
+            output.close();
+        } catch (IOException e) {
+            program.print("Error copying file: " + e.toString() + "\n", null);
+        }
+    }
+
     /*
      * This method is used to copy files that can not be parsed to a special folder: jplag/errors/java old_java scheme cpp
      * /001/(...files...) /002/(...files...)
@@ -242,7 +240,7 @@ public class Submission implements Comparable<Submission> {
         DecimalFormat format = new DecimalFormat("0000");
 
         try {
-            URL url = Submission.class.getResource("errors");
+            URL url = Submission.class.getResource(ERROR_FOLDER);
             errorDir = new File(url.getFile());
         } catch (NullPointerException e) {
             return;
@@ -263,28 +261,57 @@ public class Submission implements Comparable<Submission> {
 
         destDir.mkdir();
 
-        for (i = 0; i < files.size(); i++) {
-            copyFile(new File(files.get(i).getAbsolutePath()), new File(destDir, files.get(i).getName()));
+        for (File file : files) {
+            copyFile(new File(file.getAbsolutePath()), new File(destDir, file.getName()));
         }
     }
 
-    /* Physical copy. :-) */
-    private void copyFile(File in, File out) {
-        byte[] buffer = new byte[10000];
-        try {
-            FileInputStream dis = new FileInputStream(in);
-            FileOutputStream dos = new FileOutputStream(out);
-            int count;
-            do {
-                count = dis.read(buffer);
-                if (count != -1) {
-                    dos.write(buffer, 0, count);
-                }
-            } while (count != -1);
-            dis.close();
-            dos.close();
-        } catch (IOException e) {
-            program.print("Error copying file: " + e.toString() + "\n", null);
+    /**
+     * Map all files of this submission to their path relative to the submission directory.
+     * <p>
+     * This method is required to stay compatible with `program.language.parse(...)` as it requires the given file paths to
+     * be relative to the submission directory.
+     * <p>
+     * In a future update, `program.language.parse(...)` should probably just take a list of files.
+     * @param baseFile - File to base all relative file paths on.
+     * @param files - List of files to map.
+     * @return an array of file paths relative to the submission directory.
+     */
+    private String[] getRelativeFilePaths(File baseFile, Collection<File> files) {
+        Path baseFilePath = baseFile.toPath();
+
+        return files.stream().map(File::toPath).map(baseFilePath::relativize).map(Path::toString).toArray(String[]::new);
+    }
+
+    /**
+     * Recursively scan the given directory for nested files. Excluded files and files with an invalid suffix are ignored.
+     * <p>
+     * If the given file is not a directory, the input will be returned as a singleton list.
+     * @param file - File to start the scan from.
+     * @return a list of nested files.
+     */
+    private Collection<File> parseFilesRecursively(File file) {
+        if (program.isFileExcluded(file)) {
+            return Collections.emptyList();
         }
+
+        if (file.isFile() && program.hasValidSuffix(file)) {
+            return Collections.singletonList(file);
+        }
+
+        String[] nestedFileNames = file.list();
+
+        if (nestedFileNames == null) {
+            return Collections.emptyList();
+        }
+
+        Collection<File> files = new ArrayList<>();
+
+        for (String fileName : nestedFileNames) {
+            files.addAll(parseFilesRecursively(new File(file, fileName)));
+        }
+
+        return files;
     }
+
 }

+ 16 - 16
jplag/src/main/java/jplag/reporting/Report.java

@@ -134,13 +134,13 @@ public class Report { // Mostly legacy code with some minor improvements.
      */
     private void reportComparison(HTMLFile htmlFile, JPlagComparison comparison, int index) {
         Match match;
-        TokenList tokensA = comparison.getFirstSubmission().tokenList;
-        TokenList tokensB = comparison.getSecondSubmission().tokenList;
+        TokenList tokensA = comparison.getFirstSubmission().getTokenList();
+        TokenList tokensB = comparison.getSecondSubmission().getTokenList();
         // sort();
 
         htmlFile.println("<TABLE BORDER=\"1\" CELLSPACING=\"0\" BGCOLOR=\"#d0d0d0\">");
-        htmlFile.println("<TR><TH><TH>" + comparison.getFirstSubmission().name + " (" + comparison.similarityOfFirst() + "%)<TH>"
-                + comparison.getSecondSubmission().name + " (" + comparison.similarityOfSecond() + "%)<TH>" + msg.getString("AllMatches.Tokens"));
+        htmlFile.println("<TR><TH><TH>" + comparison.getFirstSubmission().getName() + " (" + comparison.similarityOfFirst() + "%)<TH>"
+                + comparison.getSecondSubmission().getName() + " (" + comparison.similarityOfSecond() + "%)<TH>" + msg.getString("AllMatches.Tokens"));
 
         for (int i = 0; i < comparison.getMatches().size(); i++) {
             match = comparison.getMatches().get(i);
@@ -264,7 +264,7 @@ public class Report { // Mostly legacy code with some minor improvements.
         Submission sub = (j == 0 ? comparison.getFirstSubmission() : comparison.getSecondSubmission());
         String[] files = comparison.files(j);
         String[][] text = sub.readFiles(files);
-        TokenList tokens = (j == 0 ? comparison.getFirstSubmission() : comparison.getSecondSubmission()).tokenList;
+        TokenList tokens = (j == 0 ? comparison.getFirstSubmission() : comparison.getSecondSubmission()).getTokenList();
 
         // Markup list:
         Comparator<MarkupText> comp = (mo1, mo2) -> {
@@ -377,7 +377,7 @@ public class Report { // Mostly legacy code with some minor improvements.
         for (int x = 0; x < text.length; x++) {
             f.println("<h3>");
             f.println("<center>");
-            f.println("<span>" + sub.name + "</span>");
+            f.println("<span>" + sub.getName() + "</span>");
             f.println("<span> - </span>");
             f.println("<span>" + files[x] + "</span>");
             f.println("</center>");
@@ -478,7 +478,7 @@ public class Report { // Mostly legacy code with some minor improvements.
         Submission sub = (j == 0 ? comparison.getFirstSubmission() : comparison.getSecondSubmission());
         String[] files = comparison.files(j);
         char[][] text = sub.readFilesChar(files);
-        TokenList tokens = (j == 0 ? comparison.getFirstSubmission() : comparison.getSecondSubmission()).tokenList;
+        TokenList tokens = (j == 0 ? comparison.getFirstSubmission() : comparison.getSecondSubmission()).getTokenList();
 
         // get index array with matches sorted in ascending order.
         int[] perm = comparison.sort_permutation(j);
@@ -493,7 +493,7 @@ public class Report { // Mostly legacy code with some minor improvements.
         for (int fileIndex = 0; fileIndex < files.length; fileIndex++) {
             f.println("<h3>");
             f.println("<center>");
-            f.println("<span>" + sub.name + "</span>");
+            f.println("<span>" + sub.getName() + "</span>");
             f.println("<span> - </span>");
             f.println("<span>" + files[fileIndex] + "</span>");
             f.println("</center>");
@@ -560,8 +560,8 @@ public class Report { // Mostly legacy code with some minor improvements.
         htmlFile.println("<TABLE CELLPADDING=3 CELLSPACING=2>");
 
         for (JPlagComparison comparison : comparisons) {
-            String submissionNameA = comparison.getFirstSubmission().name;
-            String submissionNameB = comparison.getSecondSubmission().name;
+            String submissionNameA = comparison.getFirstSubmission().getName();
+            String submissionNameB = comparison.getSecondSubmission().getName();
 
             htmlFile.print("<TR><TD BGCOLOR=" + color(comparison.similarityOfFirst(), 128, 192, 128, 192, 255, 255) + ">" + submissionNameA
                     + "</TD><TD><nobr>-&gt;</nobr>");
@@ -582,7 +582,7 @@ public class Report { // Mostly legacy code with some minor improvements.
         HTMLFile htmlFile = createHTMLFile("match" + i + ".html");
 
         writeHTMLHeader(htmlFile, TagParser.parse(msg.getString("Report.Matches_for_X1_AND_X2"),
-                new String[] {comparison.getFirstSubmission().name, comparison.getSecondSubmission().name}));
+                new String[] {comparison.getFirstSubmission().getName(), comparison.getSecondSubmission().getName()}));
 
         htmlFile.println("<body>");
         htmlFile.println("  <div style=\"align-items: center; display: flex; justify-content: space-around;\">");
@@ -590,7 +590,7 @@ public class Report { // Mostly legacy code with some minor improvements.
         htmlFile.println("    <div>");
         htmlFile.println("      <h3 align=\"center\">");
         htmlFile.println(TagParser.parse(msg.getString("Report.Matches_for_X1_AND_X2"),
-                new String[] {comparison.getFirstSubmission().name, comparison.getSecondSubmission().name}));
+                new String[] {comparison.getFirstSubmission().getName(), comparison.getSecondSubmission().getName()}));
         htmlFile.println("      </h3>");
         htmlFile.println("      <h1 align=\"center\">");
         htmlFile.println("        " + comparison.roundedSimilarity() + "%");
@@ -655,8 +655,8 @@ public class Report { // Mostly legacy code with some minor improvements.
             writer = new FileWriter(csvFile, StandardCharsets.UTF_8);
 
             for (JPlagComparison comparison : comparisons) {
-                String submissionNameA = comparison.getFirstSubmission().name;
-                String submissionNameB = comparison.getSecondSubmission().name;
+                String submissionNameA = comparison.getFirstSubmission().getName();
+                String submissionNameB = comparison.getSecondSubmission().getName();
 
                 writer.write(getComparisonIndex(comparison) + ";");
                 writer.write(submissionNameA + ";");
@@ -685,7 +685,7 @@ public class Report { // Mostly legacy code with some minor improvements.
 
         String[][] text = sub.readFiles(files);
 
-        TokenList tokens = (j == 0 ? comparison.getFirstSubmission() : comparison.getSecondSubmission()).tokenList;
+        TokenList tokens = (j == 0 ? comparison.getFirstSubmission() : comparison.getSecondSubmission()).getTokenList();
         Match currentMatch;
         String hilf;
         int h;
@@ -756,7 +756,7 @@ public class Report { // Mostly legacy code with some minor improvements.
         for (int x = 0; x < text.length; x++) {
             f.println("<h3>");
             f.println("<center>");
-            f.println("<span>" + sub.name + "</span>");
+            f.println("<span>" + sub.getName() + "</span>");
             f.println("<span> - </span>");
             f.println("<span>" + files[x] + "</span>");
             f.println("</center>");

+ 4 - 4
jplag/src/main/java/jplag/strategy/AbstractComparisonStrategy.java

@@ -27,7 +27,7 @@ public abstract class AbstractComparisonStrategy implements ComparisonStrategy {
     protected void compareSubmissionsToBaseCode(Vector<Submission> submissions, Submission baseCodeSubmission) {
         for (Submission currentSubmission : submissions) {
             JPlagComparison baseCodeMatch = greedyStringTiling.compareWithBaseCode(currentSubmission, baseCodeSubmission);
-            baseCodeMatches.put(currentSubmission.name, baseCodeMatch);
+            baseCodeMatches.put(currentSubmission.getName(), baseCodeMatch);
             baseCodeSubmission.resetBaseCode();
         }
     }
@@ -37,10 +37,10 @@ public abstract class AbstractComparisonStrategy implements ComparisonStrategy {
      */
     protected Optional<JPlagComparison> compareSubmissions(Submission first, Submission second, boolean withBaseCode) {
         JPlagComparison comparison = greedyStringTiling.compare(first, second);
-        System.out.println("Comparing " + first.name + "-" + second.name + ": " + comparison.similarity());
+        System.out.println("Comparing " + first.getName() + "-" + second.getName() + ": " + comparison.similarity());
         if (withBaseCode) {
-            comparison.setFirstBaseCodeMatches(baseCodeMatches.get(comparison.getFirstSubmission().name));
-            comparison.setSecondBaseCodeMatches(baseCodeMatches.get(comparison.getSecondSubmission().name));
+            comparison.setFirstBaseCodeMatches(baseCodeMatches.get(comparison.getFirstSubmission().getName()));
+            comparison.setSecondBaseCodeMatches(baseCodeMatches.get(comparison.getSecondSubmission().getName()));
         }
         if (options.getSimilarityMetric().isAboveThreshold(comparison, options.getSimilarityThreshold())) {
             return Optional.of(comparison);

+ 2 - 2
jplag/src/main/java/jplag/strategy/NormalComparisonStrategy.java

@@ -30,12 +30,12 @@ public class NormalComparisonStrategy extends AbstractComparisonStrategy {
 
         for (i = 0; i < (numberOfSubmissions - 1); i++) {
             first = submissions.elementAt(i);
-            if (first.tokenList == null) {
+            if (first.getTokenList() == null) {
                 continue;
             }
             for (j = (i + 1); j < numberOfSubmissions; j++) {
                 second = submissions.elementAt(j);
-                if (second.tokenList == null) {
+                if (second.getTokenList() == null) {
                     continue;
                 }
                 compareSubmissions(first, second, withBaseCode).ifPresent(it -> comparisons.add(it));

+ 4 - 4
jplag/src/main/java/jplag/strategy/ParallelComparisonStrategy.java

@@ -77,10 +77,10 @@ public class ParallelComparisonStrategy extends AbstractComparisonStrategy {
         List<SubmissionTuple> tuples = new ArrayList<>();
         for (int i = 0; i < (submissions.size() - 1); i++) {
             Submission first = submissions.elementAt(i);
-            if (first.tokenList != null) {
+            if (first.getTokenList() != null) {
                 for (int j = (i + 1); j < submissions.size(); j++) {
                     Submission second = submissions.elementAt(j);
-                    if (second.tokenList != null) {
+                    if (second.getTokenList() != null) {
                         tuples.add(new SubmissionTuple(first, second));
                     }
                 }
@@ -99,8 +99,8 @@ public class ParallelComparisonStrategy extends AbstractComparisonStrategy {
         return new Runnable() {
             @Override
             public void run() {
-                Lock leftLock = getOrCreateLock(tuple.getLeft().name);
-                Lock rightLock = getOrCreateLock(tuple.getRight().name);
+                Lock leftLock = getOrCreateLock(tuple.getLeft().getName());
+                Lock rightLock = getOrCreateLock(tuple.getRight().getName());
                 boolean hasLeft = leftLock.tryLock();
                 boolean hasRight = hasLeft && rightLock.tryLock();
                 try {

+ 6 - 6
jplag/src/test/java/jplag/NormalComparisonTest.java

@@ -56,8 +56,8 @@ public class NormalComparisonTest extends TestBase {
         result.getAllComparisons()
                 .stream()
                 .filter(comparison ->
-                        comparison.getSecondSubmission().name.equals("E") ||
-                                comparison.getFirstSubmission().name.equals("E"))
+                        comparison.getSecondSubmission().getName().equals("E") ||
+                                comparison.getFirstSubmission().getName().equals("E"))
                 .forEach(comparison ->
                         assertEquals(0f, comparison.similarity(), 0.1f)
                 );
@@ -88,10 +88,10 @@ public class NormalComparisonTest extends TestBase {
     private Optional<JPlagComparison> getSelectedComparison(JPlagResult result, String nameA, String nameB) {
         return result.getAllComparisons().stream()
                 .filter(comparison ->
-                        comparison.getFirstSubmission().name.equals(nameA) &&
-                                comparison.getSecondSubmission().name.equals(nameB) ||
-                                comparison.getFirstSubmission().name.equals(nameB) &&
-                                        comparison.getSecondSubmission().name.equals(nameA))
+                        comparison.getFirstSubmission().getName().equals(nameA) &&
+                                comparison.getSecondSubmission().getName().equals(nameB) ||
+                                comparison.getFirstSubmission().getName().equals(nameB) &&
+                                        comparison.getSecondSubmission().getName().equals(nameA))
                 .findFirst();
     }
 }

+ 3 - 3
jplag/src/test/java/jplag/ParallelComparisonTest.java

@@ -58,7 +58,7 @@ public class ParallelComparisonTest extends TestBase {
 
         // All comparisons with E shall have no matches
         result.getAllComparisons().stream()
-                .filter(comparison -> comparison.getSecondSubmission().name.equals("E") || comparison.getFirstSubmission().name.equals("E"))
+                .filter(comparison -> comparison.getSecondSubmission().getName().equals("E") || comparison.getFirstSubmission().getName().equals("E"))
                 .forEach(comparison -> assertEquals(0f, comparison.similarity(), 0.1f));
 
         // Hard coded assertions on selected comparisons
@@ -84,8 +84,8 @@ public class ParallelComparisonTest extends TestBase {
 
     private Optional<JPlagComparison> getSelectedComparison(JPlagResult result, String nameA, String nameB) {
         return result.getAllComparisons().stream()
-                .filter(comparison -> comparison.getFirstSubmission().name.equals(nameA) && comparison.getSecondSubmission().name.equals(nameB)
-                        || comparison.getFirstSubmission().name.equals(nameB) && comparison.getSecondSubmission().name.equals(nameA))
+                .filter(comparison -> comparison.getFirstSubmission().getName().equals(nameA) && comparison.getSecondSubmission().getName().equals(nameB)
+                        || comparison.getFirstSubmission().getName().equals(nameB) && comparison.getSecondSubmission().getName().equals(nameA))
                 .findFirst();
     }
 }

+ 1 - 1
jplag/src/test/java/jplag/VolumeTest.java

@@ -51,7 +51,7 @@ public class VolumeTest extends TestBase {
         System.out.println("Volume test size: " + csv.size());
 
         results.getAllComparisons().forEach(result -> {
-            var key = result.getFirstSubmission().name + result.getSecondSubmission().name;
+            var key = result.getFirstSubmission().getName() + result.getSecondSubmission().getName();
 
             assertTrue(csv.containsKey(key));
             assertEquals(csv.getOrDefault(key, -1f), result.similarity(), 0.1f);