Package com.github.difflib.patch
Class Chunk<T>
java.lang.Object
com.github.difflib.patch.Chunk<T>
- Type Parameters:
T
- The type of the compared elements in the 'lines'.
- All Implemented Interfaces:
Serializable
Holds the information about the part of text involved in the diff process
Text is represented as Object[]
because the diff engine is
capable of handling more than plain ascci. In fact, arrays or lists of any
type that implements hashCode()
and
equals()
correctly can be subject to
differencing using this library.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a chunk and saves a copy of affected linesCreates a chunk and saves a copy of affected linesCreates a chunk and saves a copy of affected linesCreates a chunk and saves a copy of affected lines -
Method Summary
Modifier and TypeMethodDescriptionboolean
getLines()
int
int
hashCode()
int
last()
Returns the index of the last line of the chunk.void
int
size()
toString()
verifyChunk
(List<T> target) Verifies that this chunk's saved text matches the corresponding text in the given sequence.verifyChunk
(List<T> target, int fuzz, int position) Verifies that this chunk's saved text matches the corresponding text in the given sequence.
-
Field Details
-
position
private final int position -
lines
-
changePosition
-
-
Constructor Details
-
Chunk
Creates a chunk and saves a copy of affected lines- Parameters:
position
- the start positionlines
- the affected lineschangePosition
- the positions of changed lines
-
Chunk
Creates a chunk and saves a copy of affected lines- Parameters:
position
- the start positionlines
- the affected lines
-
Chunk
Creates a chunk and saves a copy of affected lines- Parameters:
position
- the start positionlines
- the affected lineschangePosition
- the positions of changed lines
-
Chunk
Creates a chunk and saves a copy of affected lines- Parameters:
position
- the start positionlines
- the affected lines
-
-
Method Details
-
verifyChunk
Verifies that this chunk's saved text matches the corresponding text in the given sequence.- Parameters:
target
- the sequence to verify against.- Throws:
PatchFailedException
-
verifyChunk
Verifies that this chunk's saved text matches the corresponding text in the given sequence.- Parameters:
target
- the sequence to verify against.fuzz
- the count of ignored prefix/suffixposition
- the position of target- Throws:
PatchFailedException
-
getPosition
public int getPosition()- Returns:
- the start position of chunk in the text
-
setLines
-
getLines
- Returns:
- the affected lines
-
getChangePosition
- Returns:
- the positions of changed lines of chunk in the text
-
size
public int size() -
last
public int last()Returns the index of the last line of the chunk. -
hashCode
public int hashCode() -
equals
-
toString
-