package innovimax.mixthem.operation;

import java.util.EnumSet;

/**
* <p>Describes the result of an line operation on two files.</p>
* @author Innovimax
* @version 1.0
*/
public class LineResult {
    
    private final EnumSet<ResultType> types;
    private String result;
    private String line1;
    private String line2;    
    
    /**
    * Creates a line result.    
    */
    public LineResult() {
        this.types = EnumSet.noneOf(ResultType.class);
        this.result = null;
        this.line1 = null;
        this.line2 = null;        
    }

    /**
    * Reset the result.
    */
    void reset() {        
        this.types.clear();
        this.result = null;
    }
    
    /**
    * Set the result (maybe null).
    */
    void setResult(String result) {
        this.result = result;
        if (result != null) {
            this.types.add(ResultType.HAS_RESULT);
        }
    }

    /**
    * Returns the result (maybe null).
    */
    String getResult() {
        return this.result;
    }

    /**
    * Has a result ?
    */
    boolean hasResult() {
        return this.types.contains(ResultType.HAS_RESULT);     
    }
    
    /**
    * Get the first line.
    */
    String getFirstLine() {
        return this.line1;
    }
    
    /**
    * Set the first line.
    */
    void setFirstLine(String line) {
        this.line1 = line;
    }
    
    /**
    * Get the second line.
    */
    String getSecondLine() {
        return this.line2;
    }
    
    /**
    * Set the second line.
    */
    void setSecondLine(String line) {
        this.line2 = line;
    }
    
    
    /**
    * Preserves first file from reading
    */
    void preserveFirstLine() {        
        this.types.add(ResultType.PRESERVE_FIRST_LINE);
    }

    /**
    * Has to read first file ?
    */
    boolean readingFirstFile() {
        return !this.types.contains(ResultType.PRESERVE_FIRST_LINE);
    }

    /**
    * Preserves second file from reading
    */
    void preserveSecondLine() {
        this.types.add(ResultType.PRESERVE_SECOND_LINE);        
    }

    /**
    * Has to read second file ?
    */
    boolean readingSecondFile() {
        return !this.types.contains(ResultType.PRESERVE_SECOND_LINE);
    }

}

@@ -1252,32 +1252,140 @@
 ne1;%0A    %7D%0A    %0A
+    /**%0A    * Has first line?%0A    */%0A    boolean hasFirstLine() %7B%0A        return this.line1 != null;%0A    %7D%0A%0A
     /**%0A    * Se
@@ -1394,32 +1394,32 @@
 the first line.%0A
-
     */%0A    void 
@@ -1583,24 +1583,134 @@
 line2;%0A    %7D
+%0A%0A    /**%0A    * Has second line?%0A    */%0A    boolean hasSecondLine() %7B%0A        return this.line2 != null;%0A    %7D
 %0A    %0A    /*
@@ -1802,32 +1802,32 @@
 s.line2 = line;%0A
+
     %7D%0A    %0A    %0A
@@ -1817,29 +1817,24 @@
 %0A    %7D%0A    %0A
-    %0A
     /**%0A    

Update LineResult.java