Package com.day.util.diff
Class Hunk
java.lang.Object
com.day.util.diff.Hunk
A hunk records a block of diff between the left and the right document.
it represents either a insertion, deletion, change or identity. several
hunks are chained in a linked list.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
type indicates a changed blockstatic final int
type indicates a deleted blockstatic final int
type indicates an inserted blockfinal Range
the range in the left documentfinal Range
the rnage in the right documentfinal int
the hunk typestatic final int
type indicates an unmodified block -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
UNMODIFIED
public static final int UNMODIFIEDtype indicates an unmodified block- See Also:
-
INSERTED
public static final int INSERTEDtype indicates an inserted block- See Also:
-
DELETED
public static final int DELETEDtype indicates a deleted block- See Also:
-
CHANGED
public static final int CHANGEDtype indicates a changed block- See Also:
-
left
the range in the left document -
right
the rnage in the right document -
type
public final int typethe hunk type
-
-
Constructor Details
-
Hunk
Creates a new hunk and adds it to the previous hunk- Parameters:
left
- the left rangeright
- the right rangetype
- the hunk typeprev
- the previous hunk
-
-
Method Details
-
prev
Returns the previous hunk of this chain- Returns:
- the previous hunk.
-
next
Returns the next hunk of this chain- Returns:
- the next hunk.
-
write
Writes a unified diff to the given writer and returns the next hunk to continue the output.- Parameters:
out
- the writernumContextLines
- the number of context lines to include in the diff blocks. do not change during iteration!- Returns:
- the next hunk or
null
. - Throws:
IOException
- if an I/O error occurs.
-