Class Hunk

  • public class Hunk
    extends Object
    A hunk records a block of diff between the left and the right document. it represents either a insertion, deletion, change or identiy. several hunks are chained in a linked list.
    • Field Detail


        public static final int UNMODIFIED
        type indicates an unmodified block
        See Also:
        Constant Field Values
      • INSERTED

        public static final int INSERTED
        type indicates an inserted block
        See Also:
        Constant Field Values
      • DELETED

        public static final int DELETED
        type indicates a deleted block
        See Also:
        Constant Field Values
      • CHANGED

        public static final int CHANGED
        type indicates a changed block
        See Also:
        Constant Field Values
      • left

        public final Range left
        the range in the left document
      • right

        public final Range right
        the rnage in the right document
      • type

        public final int type
        the hunk type
    • Constructor Detail

      • Hunk

        public Hunk​(Range left,
                    Range right,
                    int type,
                    Hunk prev)
        Creates a new hunk and adds it to the previous hunk
        left - the left range
        right - the right range
        type - the hunk type
        prev - the previous hunk
    • Method Detail

      • prev

        public Hunk prev()
        Returns the previous hunk of this chain
        the previous hunk.
      • next

        public Hunk next()
        Returns the next hunk of this chain
        the next hunk.
      • write

        public Hunk write​(DiffWriter out,
                          int numContextLines)
                   throws IOException
        Writes a unified diff to the given writer and returns the next hunk to continue the output.
        out - the writer
        numContextLines - the number of context lines to include in the diff blocks. do not change during iteration!
        the next hunk or null.
        IOException - if an I/O error occurs.