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:
java.io.Serializable
public final class Chunk<T> extends java.lang.Object implements java.io.SerializableHolds the information about the part of text involved in the diff processText 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 implementshashCode()andequals()correctly can be subject to differencing using this library.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.Integer>changePositionprivate java.util.List<T>linesprivate intposition
-
Constructor Summary
Constructors Constructor Description Chunk(int position, java.util.List<T> lines)Creates a chunk and saves a copy of affected linesChunk(int position, java.util.List<T> lines, java.util.List<java.lang.Integer> changePosition)Creates a chunk and saves a copy of affected linesChunk(int position, T[] lines)Creates a chunk and saves a copy of affected linesChunk(int position, T[] lines, java.util.List<java.lang.Integer> changePosition)Creates a chunk and saves a copy of affected lines
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.util.List<java.lang.Integer>getChangePosition()java.util.List<T>getLines()intgetPosition()inthashCode()intlast()Returns the index of the last line of the chunk.voidsetLines(java.util.List<T> lines)intsize()java.lang.StringtoString()VerifyChunkverifyChunk(java.util.List<T> target)Verifies that this chunk's saved text matches the corresponding text in the given sequence.VerifyChunkverifyChunk(java.util.List<T> target, int fuzz, int position)Verifies that this chunk's saved text matches the corresponding text in the given sequence.
-
-
-
Field Detail
-
position
private final int position
-
lines
private java.util.List<T> lines
-
changePosition
private final java.util.List<java.lang.Integer> changePosition
-
-
Constructor Detail
-
Chunk
public Chunk(int position, java.util.List<T> lines, java.util.List<java.lang.Integer> changePosition)Creates a chunk and saves a copy of affected lines- Parameters:
position- the start positionlines- the affected lineschangePosition- the positions of changed lines
-
Chunk
public Chunk(int position, java.util.List<T> lines)Creates a chunk and saves a copy of affected lines- Parameters:
position- the start positionlines- the affected lines
-
Chunk
public Chunk(int position, T[] lines, java.util.List<java.lang.Integer> changePosition)Creates a chunk and saves a copy of affected lines- Parameters:
position- the start positionlines- the affected lineschangePosition- the positions of changed lines
-
Chunk
public Chunk(int position, T[] lines)Creates a chunk and saves a copy of affected lines- Parameters:
position- the start positionlines- the affected lines
-
-
Method Detail
-
verifyChunk
public VerifyChunk verifyChunk(java.util.List<T> target) throws PatchFailedException
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
public VerifyChunk verifyChunk(java.util.List<T> target, int fuzz, int position) throws PatchFailedException
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
public void setLines(java.util.List<T> lines)
-
getLines
public java.util.List<T> getLines()
- Returns:
- the affected lines
-
getChangePosition
public java.util.List<java.lang.Integer> 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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-