Pārlūkot izejas kodu

Clean up exit exception and the JPlag program interface.

Timur Sağlam 5 gadi atpakaļ
vecāks
revīzija
05c450b997

+ 14 - 7
jplag.frontend-utils/src/main/java/jplag/ProgramI.java

@@ -1,11 +1,18 @@
 package jplag;
 
 public interface ProgramI {
-	public void addError(String errorMsg) ;
-	/**
-	 * 
-	 * @param normalMsg
-	 * @param longMsg Message for verbose mode
-	 */
-	public void print(String normalMsg, String longMsg);
+    
+    /**
+     * Print and store an error.
+     * @param errorMessage is the error message.
+     */
+    public void addError(String errorMessage);
+
+    /**
+     * Prints a message depending on the verbosity.
+     * @param message is the message for the normal mode.
+     * @param longMessage is the message for verbose mode.
+     * @see JPlagOptions.getVerbosity()
+     */
+    public void print(String message, String longMessage);
 }

+ 17 - 18
jplag/src/main/java/jplag/ExitException.java

@@ -1,13 +1,10 @@
 package jplag;
-/*
- * Created on 05.03.2005 Author Moritz Kroll, Emeric Kwemou
- */
 
 /**
  * Exception to be reached through to the main caller of JPlag to replace the "exit" method
+ * @apiNote Created on 05.03.2005 Author Moritz Kroll, Emeric Kwemou.
  */
 public class ExitException extends Exception {
-    // public static final int PACKAGING_RESULTS = 201;
     public static final int COMPARE_SOURCE_DONE = 300;
     public static final int UNKNOWN_ERROR_OCCURRED = 400;
     public static final int BAD_LANGUAGE_ERROR = 401;
@@ -17,30 +14,32 @@ public class ExitException extends Exception {
     public static final int SUBMISSION_ABORTED = 405;
 
     private static final long serialVersionUID = 1L;
-    private int state = 0;
-    private String report = "";
+    private final int errorCode;
+    private final String message;
 
-    public ExitException(String msg) {
-        super(msg);
-        this.state = UNKNOWN_ERROR_OCCURRED;
-        this.report = msg;
+    public ExitException(String message) {
+        super(message);
+        errorCode = UNKNOWN_ERROR_OCCURRED;
+        this.message = message;
     }
 
-    public ExitException(String msg, int errorcode) {
-        super(msg);
-        this.state = errorcode;
-        this.report = msg;
+    public ExitException(String message, int errorCode) {
+        super(message);
+        this.errorCode = errorCode;
+        this.message = message;
     }
 
-    public ExitException(String msg, Throwable cause) {
-        super(msg, cause);
+    public ExitException(String message, Throwable cause) {
+        super(message, cause);
+        errorCode = UNKNOWN_ERROR_OCCURRED;
+        this.message = message;
     }
 
     public int getState() {
-        return this.state;
+        return errorCode;
     }
 
     public String getReport() {
-        return this.report;
+        return message;
     }
 }