Class Chunk<T>

  • Type Parameters:
    T - The type of the compared elements in the 'lines'.
    All Implemented Interfaces:
    Serializable

    public final class Chunk<T>
    extends Object
    implements Serializable
    Holds the information about the part of text involved in the diff process

    Text is represented as Object[] because the diff engine is capable of handling more than plain ascci. In fact, arrays or lists of any type that implements hashCode() and equals() correctly can be subject to differencing using this library.

    Author:
    See Also:
    Serialized Form
    • Constructor Detail

      • Chunk

        public Chunk​(int position,
                     List<T> lines,
                     List<Integer> changePosition)
        Creates a chunk and saves a copy of affected lines
        Parameters:
        position - the start position
        lines - the affected lines
        changePosition - the positions of changed lines
      • Chunk

        public Chunk​(int position,
                     List<T> lines)
        Creates a chunk and saves a copy of affected lines
        Parameters:
        position - the start position
        lines - the affected lines
      • Chunk

        public Chunk​(int position,
                     T[] lines,
                     List<Integer> changePosition)
        Creates a chunk and saves a copy of affected lines
        Parameters:
        position - the start position
        lines - the affected lines
        changePosition - the positions of changed lines
      • Chunk

        public Chunk​(int position,
                     T[] lines)
        Creates a chunk and saves a copy of affected lines
        Parameters:
        position - the start position
        lines - the affected lines
    • Method Detail

      • getPosition

        public int getPosition()
        Returns:
        the start position of chunk in the text
      • setLines

        public void setLines​(List<T> lines)
      • getLines

        public List<T> getLines()
        Returns:
        the affected lines
      • getChangePosition

        public List<Integer> getChangePosition()
        Returns:
        the positions of changed lines of chunk in the text
      • size

        public int size()
      • last

        public int last()
        Returns the index of the last line of the chunk.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object