Class Hunk3

java.lang.Object
com.day.util.diff.Hunk3

public class Hunk3 extends 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 Details

    • MARKER_L

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

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

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

      public static final String[] MARKER_M
      the separation marker pattern
  • Constructor Details

    • 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 Details

    • 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 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:
      IOException - if a I/O error occurs.
    • toString

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

      public static String getMarker(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