Package com.day.util.diff
Class Hunk3
- java.lang.Object
-
- com.day.util.diff.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 whichgetLeftRange()
is notnull
), or a change on the right side (for whichgetRightRange()
is notnull
. if the left and the right ranges arenull
this hunk represents an unmodified block of the base document. if both ranges are NOTnull
it represents a conflicting block.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]
MARKER_B
the base document marker patternstatic java.lang.String[]
MARKER_L
the left document marker patternstatic java.lang.String[]
MARKER_M
the separation marker patternstatic java.lang.String[]
MARKER_R
the right document marker pattern
-
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 documentRange
getRightRange()
Returns the range of the right document this hunk spans.Hunk3
next()
Returns the next hunk in this chain ornull
of this hunk is the last one.java.lang.String
toString()
generate a debug stringvoid
write(DiffWriter out, boolean showBase)
Writes this hunk to a writer.
-
-
-
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
-
-
Method Detail
-
next
public Hunk3 next()
Returns the next hunk in this chain ornull
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 benull
.- Returns:
- the left range.
-
getRightRange
public Range getRightRange()
Returns the range of the right document this hunk spans. can benull
.- 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 writershowBase
- 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 classjava.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 formatdoc
- the document ornull
.- Returns:
- the marker string
-
-