Class Difference

java.lang.Object
org.jjazz.diff.api.Difference

public class Difference extends Object
Represents a difference, as used in Diff. A difference consists of two pairs of starting and ending points, each pair representing either the "from" or the "to" collection passed to Diff. If an ending point is -1, then the difference was either a deletion or an addition. For example, if getDeletedEnd() returns -1, then the difference represents an addition.

JJAZZ Changes: minor usability changes.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Difference(int delStart, int delEnd, int addStart, int addEnd)
    Creates the difference for the given start and end points for the deletion and addition.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compares this object to the other for equality.
    int
    The point at which the addition ends, if any.
    int
    The point at which the addition starts, if any.
    int
    The point at which the deletion ends, if any.
    int
    The point at which the deletion starts, if any.
    int
     
    int
     
     
    int
     
    void
    setAdded(int line)
    Sets the point as added.
    void
    setDeleted(int line)
    Sets the point as deleted.
    Returns a string representation of this difference.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Difference

      public Difference(int delStart, int delEnd, int addStart, int addEnd)
      Creates the difference for the given start and end points for the deletion and addition.
  • Method Details

    • getFromRange

      public int getFromRange()
    • getToRange

      public int getToRange()
    • getType

      public Difference.ResultType getType()
    • getDeletedStart

      public int getDeletedStart()
      The point at which the deletion starts, if any. A value equal to NONE means this is an addition.
    • getDeletedEnd

      public int getDeletedEnd()
      The point at which the deletion ends, if any. A value equal to NONE means this is an addition.
    • getAddedStart

      public int getAddedStart()
      The point at which the addition starts, if any. A value equal to NONE means this must be an addition.
    • getAddedEnd

      public int getAddedEnd()
      The point at which the addition ends, if any. A value equal to NONE means this must be an addition.
    • setDeleted

      public void setDeleted(int line)
      Sets the point as deleted. The start and end points will be modified to include the given line.
    • setAdded

      public void setAdded(int line)
      Sets the point as added. The start and end points will be modified to include the given line.
    • equals

      public boolean equals(Object obj)
      Compares this object to the other for equality. Both objects must be of type Difference, with the same starting and ending points.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns a string representation of this difference.
      Overrides:
      toString in class Object