Package com.day.util.diff
Class Hunk
- java.lang.Object
-
- com.day.util.diff.Hunk
-
public class Hunk extends java.lang.Object
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
Fields Modifier and Type Field Description static int
CHANGED
type indicates a changed blockstatic int
DELETED
type indicates a deleted blockstatic int
INSERTED
type indicates an inserted blockRange
left
the range in the left documentRange
right
the rnage in the right documentint
type
the hunk typestatic int
UNMODIFIED
type indicates an unmodified block
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Hunk
next()
Returns the next hunk of this chainHunk
prev()
Returns the previous hunk of this chainHunk
write(DiffWriter out, int numContextLines)
Writes a unified diff to the given writer and returns the next hunk to continue the output.
-
-
-
Field Detail
-
UNMODIFIED
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
-
-
Method Detail
-
prev
public Hunk prev()
Returns the previous hunk of this chain- Returns:
- the previous hunk.
-
next
public Hunk next()
Returns the next hunk of this chain- Returns:
- the next hunk.
-
write
public Hunk write(DiffWriter out, int numContextLines) throws java.io.IOException
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:
java.io.IOException
- if an I/O error occurs.
-
-