Browse Source

Create JPlagResult class; rename some files

Philipp Bauch 6 years ago
parent
commit
104616c972

+ 0 - 2
jplag/src/main/java/jplag/CLI.java

@@ -1,7 +1,5 @@
 package jplag;
 
-import jplag.options.JPlagOptions;
-
 public class CLI {
 
   public static void main(String[] args) {

+ 11 - 9
jplag/src/main/java/jplag/JPlag.java

@@ -21,8 +21,7 @@ import java.util.Vector;
 import jplag.clustering.Cluster;
 import jplag.clustering.Clusters;
 import jplag.clustering.SimilarityMatrix;
-import jplag.options.JPlagClusterType;
-import jplag.options.JPlagOptions;
+import jplag.options.ClusterType;
 import jplagUtils.PropertiesLoader;
 
 /*
@@ -86,7 +85,7 @@ public class JPlag implements ProgramI {
   /**
    * Main procedure
    */
-  public void run() throws jplag.ExitException {
+  public JPlagResult run() throws jplag.ExitException {
     // This file contains all files names which are excluded
     readExclusionFile();
 
@@ -111,7 +110,7 @@ public class JPlag implements ProgramI {
 
     errorVector = null; // errorVector is not needed anymore
 
-    if (options.getClusterType() != JPlagClusterType.NONE) {
+    if (options.getClusterType() != ClusterType.NONE) {
       clusters = new Clusters(this);
       options.similarity = new SimilarityMatrix(submissions.size());
     }
@@ -145,6 +144,9 @@ public class JPlag implements ProgramI {
     }
 
     closeWriter();
+
+    // TODO: Return an actual result.
+    return new JPlagResult();
   }
 
   public void doParse() throws ExitException {
@@ -349,7 +351,7 @@ public class JPlag implements ProgramI {
 
     Cluster cluster = null;
 
-    if (options.getClusterType() != JPlagClusterType.NONE) {
+    if (options.getClusterType() != ClusterType.NONE) {
       cluster = this.clusters.calculateClustering(submissions);
     }
 
@@ -460,7 +462,7 @@ public class JPlag implements ProgramI {
 
     Cluster cluster = null;
 
-    if (options.getClusterType() != JPlagClusterType.NONE) {
+    if (options.getClusterType() != ClusterType.NONE) {
       cluster = this.clusters.calculateClustering(submissions);
     }
 
@@ -709,7 +711,7 @@ public class JPlag implements ProgramI {
 
     Cluster cluster = null;
 
-    if (options.getClusterType() == JPlagClusterType.NONE) {
+    if (options.getClusterType() == ClusterType.NONE) {
       cluster = this.clusters.calculateClustering(submissions);
     }
 
@@ -772,7 +774,7 @@ public class JPlag implements ProgramI {
           }
         }
 
-        if (options.getClusterType() != JPlagClusterType.NONE) {
+        if (options.getClusterType() != ClusterType.NONE) {
           options.similarity.setSimilarity(i, j, percent);
         }
 
@@ -1312,7 +1314,7 @@ public class JPlag implements ProgramI {
       }
     }
 
-    if (options.getClusterType() != JPlagClusterType.NONE) {
+    if (options.getClusterType() != ClusterType.NONE) {
       options.similarity.setSimilarity(a, b, avgPercent);
     }
   }

+ 11 - 10
jplag/src/main/java/jplag/options/JPlagOptions.java → jplag/src/main/java/jplag/JPlagOptions.java

@@ -1,14 +1,15 @@
-package jplag.options;
+package jplag;
 
-import static jplag.options.JPlagComparisonMode.NORMAL;
+import static jplag.options.ComparisonMode.NORMAL;
 
 import java.io.File;
 import java.lang.reflect.Constructor;
 import java.util.List;
-import jplag.ExitException;
-import jplag.JPlag;
 import jplag.clustering.SimilarityMatrix;
 import jplag.filter.Filter;
+import jplag.options.ClusterType;
+import jplag.options.ComparisonMode;
+import jplag.options.Verbosity;
 
 public class JPlagOptions {
 
@@ -149,7 +150,7 @@ public class JPlagOptions {
   /**
    * Clustering option.
    */
-  private JPlagClusterType clusterType;
+  private ClusterType clusterType;
 
   /**
    * TODO: Don't know what the title is used for.
@@ -159,7 +160,7 @@ public class JPlagOptions {
   /**
    * Determine which mode to use for the comparison of submissions.
    */
-  private JPlagComparisonMode comparisonMode = NORMAL;
+  private ComparisonMode comparisonMode = NORMAL;
 
   /**
    * TODO: Don't know what this is used for. Seems to be experimental only.
@@ -239,7 +240,7 @@ public class JPlagOptions {
    * TODO: Rename (conflicts with jplag.Language) Selected language to process the submissions
    * with.
    */
-  private Language language;
+  private jplag.options.Language language;
 
   /**
    * The actual language instance used by JPlag to process the submissions.
@@ -285,7 +286,7 @@ public class JPlagOptions {
         + " -l <language>   (Language) Supported Languages:\n                 ");
   }
 
-  public Language getLanguage() {
+  public jplag.options.Language getLanguage() {
     return language;
   }
 
@@ -337,7 +338,7 @@ public class JPlagOptions {
     return fileList;
   }
 
-  public JPlagClusterType getClusterType() {
+  public ClusterType getClusterType() {
     return clusterType;
   }
 
@@ -345,7 +346,7 @@ public class JPlagOptions {
     return title;
   }
 
-  public JPlagComparisonMode getComparisonMode() {
+  public ComparisonMode getComparisonMode() {
     return comparisonMode;
   }
 

+ 9 - 0
jplag/src/main/java/jplag/JPlagResult.java

@@ -0,0 +1,9 @@
+package jplag;
+
+public class JPlagResult {
+
+  // TODO: Design the JPlagResult class
+
+  public String test = "Works";
+
+}

+ 3 - 3
jplag/src/main/java/jplag/clustering/Clusters.java

@@ -1,7 +1,7 @@
 package jplag.clustering;
 
 import jplag.*;
-import jplag.options.JPlagClusterType;
+import jplag.options.ClusterType;
 
 import java.util.*;
 
@@ -40,8 +40,8 @@ public class Clusters {
    */
   public Cluster minMaxAvrClustering() {
     int nrOfSubmissions = submissions.size();
-    boolean minClustering = (this.program.getOptions().getClusterType() == JPlagClusterType.MIN);
-    boolean maxClustering = (this.program.getOptions().getClusterType() == JPlagClusterType.MAX);
+    boolean minClustering = (this.program.getOptions().getClusterType() == ClusterType.MIN);
+    boolean maxClustering = (this.program.getOptions().getClusterType() == ClusterType.MAX);
     SimilarityMatrix simMatrix = this.program.getOptions().similarity;
 
     ArrayList<Cluster> clusters = new ArrayList<Cluster>(submissions.size());

+ 1 - 1
jplag/src/main/java/jplag/options/JPlagClusterType.java → jplag/src/main/java/jplag/options/ClusterType.java

@@ -1,6 +1,6 @@
 package jplag.options;
 
-public enum JPlagClusterType {
+public enum ClusterType {
   NONE,
   MIN,
   MAX,

+ 1 - 1
jplag/src/main/java/jplag/options/JPlagComparisonMode.java → jplag/src/main/java/jplag/options/ComparisonMode.java

@@ -1,6 +1,6 @@
 package jplag.options;
 
-public enum JPlagComparisonMode {
+public enum ComparisonMode {
   NORMAL,
   REVISION,
   SPECIAL,