Class Hunk3


  • public class Hunk3
    extends java.lang.Object
    A hunk3 represents a block of a change from the 3-way diff. it can either be a modification on the left side (for which getLeftRange() is not null), or a change on the right side (for which getRightRange() is not null. if the left and the right ranges are null this hunk represents an unmodified block of the base document. if both ranges are NOT null it represents a conflicting block.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String[] MARKER_B
      the base document marker pattern
      static java.lang.String[] MARKER_L
      the left document marker pattern
      static java.lang.String[] MARKER_M
      the separation marker pattern
      static java.lang.String[] MARKER_R
      the right document marker pattern
    • Constructor Summary

      Constructors 
      Constructor Description
      Hunk3​(Range base, Range left, Range right, Hunk3 prev)
      Constructs a new hunk and appends it to the previous one.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Range getBaseRange()
      Returns the range of the base document this hunk spans.
      Range getLeftRange()
      Returns the range of the left document this hunk spans.
      static java.lang.String getMarker​(java.lang.String[] fmt, Document doc)
      Returns the marker string for the given format and document
      Range getRightRange()
      Returns the range of the right document this hunk spans.
      Hunk3 next()
      Returns the next hunk in this chain or null of this hunk is the last one.
      java.lang.String toString()
      generate a debug string
      void write​(DiffWriter out, boolean showBase)
      Writes this hunk to a writer.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • MARKER_L

        public static final java.lang.String[] MARKER_L
        the left document marker pattern
      • MARKER_R

        public static final java.lang.String[] MARKER_R
        the right document marker pattern
      • MARKER_B

        public static final java.lang.String[] MARKER_B
        the base document marker pattern
      • MARKER_M

        public static final java.lang.String[] MARKER_M
        the separation marker pattern
    • Constructor Detail

      • Hunk3

        public Hunk3​(Range base,
                     Range left,
                     Range right,
                     Hunk3 prev)
        Constructs a new hunk and appends it to the previous one.
        Parameters:
        base - the base document
        left - the left document
        right - the right document
        prev - the previous hunk
    • Method Detail

      • next

        public Hunk3 next()
        Returns the next hunk in this chain or null of this hunk is the last one.
        Returns:
        the next hunk.
      • getBaseRange

        public Range getBaseRange()
        Returns the range of the base document this hunk spans.
        Returns:
        the base range.
      • getLeftRange

        public Range getLeftRange()
        Returns the range of the left document this hunk spans. can be null.
        Returns:
        the left range.
      • getRightRange

        public Range getRightRange()
        Returns the range of the right document this hunk spans. can be null.
        Returns:
        the right range.
      • write

        public void write​(DiffWriter out,
                          boolean showBase)
                   throws java.io.IOException
        Writes this hunk to a writer. if this hunk represents a conflict it is included in a merge-like manner using the separators defined above.
        Parameters:
        out - the writer
        showBase - include the block of the base document in case of a conflict as well.
        Throws:
        java.io.IOException - if a I/O error occurs.
      • toString

        public java.lang.String toString()
        generate a debug string
        Overrides:
        toString in class java.lang.Object
        Returns:
        a debug string
      • getMarker

        public static java.lang.String getMarker​(java.lang.String[] fmt,
                                                 Document doc)
        Returns the marker string for the given format and document
        Parameters:
        fmt - the marker format
        doc - the document or null.
        Returns:
        the marker string