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 = EnumSet.noneOf(ResultType.class);
    private String line1 = null;
    private String line2 = null;
    private String result = null;

    /**
    * Reset the result types.
    */
    void resetTypes() {        
        this.types.clear(); 
    }
    
    /**
    * Reset the read lines.
    */
    void resetLines() {        
        this.line1 = null;
        this.line2 = null;
    }

    /**
    * Set the first line.
    */
    void setFirstLine(String line) {
        this.line1 = line;        
    }
    
    /**
    * Get the first line.
    */
    String getFirstLine() {
        return this.line1;
    }
    
    /**
    * Has first line?
    */
    boolean hasFirstLine() {
        return this.line1 != null;
    }
    
    /**
    * Set the last line.
    */
    void setLastLine(String line) {
        this.line2 = line;        
    }
    
    /**
    * Get the last line.
    */
    String getLastLine() {
        return this.line2;
    }
    
    /**
    * Has last line?
    */
    boolean hasLastLine() {
        return this.line2 != null;
    }
    
    /**
    * Set the result of the operation (maybe null).
    */
    void setResult(String result) {
        this.result = result;        
        this.types.add(result == null ? ResultType._IGNORE_RESULT : ResultType._GET_RESULT);        
    }

    /**
    * Ignores the result of the operation (set to null).
    */
    void ignoreResult() {
        this.types.add(ResultType._IGNORE_RESULT);
    }

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

    /**
    * Returns the result of the operation (maybe null).
    */
    boolean hasResult() {
        eturn this.types.contains(ResultType._GET_RESULT);     
    }
    
    /**
    * Preserves first file from reading
    */
    void preserveFirst() {
        this.types.add(ResultType._READ_LAST);        
    }

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

    /**
    * Preserves last file from reading
    */
    void preserveLast() {
        this.types.add(ResultType._READ_FIRST);        
    }

    /**
    * Has to read last file ?
    */
    boolean readLast() {
        return this.types.contains(ResultType._READ_LAST);        
    }

    /**
    * Explores both files for next reading
    */
    void exploreBoth() {
        this.types.add(ResultType._READ_BOTH);        
    }   

    /**
    * Has to read both files ?
    */
    boolean readBoth() {
        return this.types.contains(ResultType._READ_BOTH);        
    } 

}

@@ -991,28 +991,30 @@
   * Set the 
-last
+second
  line.%0A    *
@@ -1027,20 +1027,22 @@
 void set
-Last
+Second
 Line(Str
@@ -1121,20 +1121,22 @@
 Get the 
-last
+second
  line.%0A 
@@ -1155,20 +1155,22 @@
 ring get
-Last
+Second
 Line() %7B
@@ -1226,20 +1226,22 @@
   * Has 
-last
+second
  line?%0A 
@@ -1261,20 +1261,22 @@
 lean has
-Last
+Second
 Line() %7B
@@ -2103,24 +2103,28 @@
 reserveFirst
+Line
 () %7B%0A       
@@ -2148,36 +2148,43 @@
 esultType._READ_
-LAST
+SECOND_FILE
 );        %0A    %7D
@@ -2247,17 +2247,24 @@
 ean 
-readFirst
+firstFileReading
 () %7B
@@ -2313,32 +2313,89 @@
 Type._READ_FIRST
+_FILE) %7C%7C this.types.contains(ResultType._READ_BOTH_FILES
 );        %0A    %7D
@@ -2420,20 +2420,22 @@
 eserves 
-last
+second
  file fr
@@ -2469,20 +2469,26 @@
 preserve
-Last
+SecondLine
 () %7B%0A   
@@ -2529,16 +2529,21 @@
 AD_FIRST
+_FILE
 );      
@@ -2582,12 +2582,14 @@
 ead 
-last
+second
  fil
@@ -2615,16 +2615,25 @@
 ean 
-readLast
+secondFileReading
 () %7B
@@ -2689,12 +2689,71 @@
 EAD_
-LAST
+SECOND_FILE) %7C%7C this.types.contains(ResultType._READ_BOTH_FILES
 );  
@@ -2840,24 +2840,29 @@
  exploreBoth
+Files
 () %7B%0A       
@@ -2890,32 +2890,38 @@
 tType._READ_BOTH
+_FILES
 );        %0A    %7D
@@ -2987,16 +2987,24 @@
 ean 
-readBoth
+bothFilesReading
 () %7B
@@ -3060,16 +3060,22 @@
 EAD_BOTH
+_FILES
 );      

Update LineResult.java