difflib
Class Chunk

java.lang.Object
  extended by difflib.Chunk

public class Chunk
extends java.lang.Object

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.

Author:
Constructor Summary
Chunk(int position, int size, java.util.List<?> lines)
          Creates a chunk and saves a copy of affected lines
Chunk(int position, int size, java.lang.Object[] lines)
          Creates a chunk and saves a copy of affected lines
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.util.List<?> getLines()
           
 int getPosition()
           
 int getSize()
           
 int hashCode()
           
 int last()
          Returns the index of the last line of the chunk.
 void setLines(java.util.List<?> lines)
           
 void setPosition(int position)
           
 void setSize(int size)
           
 java.lang.String toString()
           
 void verify(java.util.List<?> target)
          Verifies that this chunk's saved text matches the corresponding text in the given sequence.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Chunk

public Chunk(int position,
             int size,
             java.util.List<?> lines)
Creates a chunk and saves a copy of affected lines

Parameters:
position - the start position
size - the size of a Chunk
lines - the affected lines

Chunk

public Chunk(int position,
             int size,
             java.lang.Object[] lines)
Creates a chunk and saves a copy of affected lines

Parameters:
position - the start position
size - the size of a Chunk
lines - the affected lines
Method Detail

verify

public void verify(java.util.List<?> 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

getPosition

public int getPosition()
Returns:
the start position of chunk in the text

setPosition

public void setPosition(int position)
Parameters:
position - the start position to set

getSize

public int getSize()
Returns:
the size of Chunk (size of affected lines)

setSize

public void setSize(int size)
Parameters:
size - the size of affected lines to set

getLines

public java.util.List<?> getLines()
Returns:
the affected lines

setLines

public void setLines(java.util.List<?> lines)
Parameters:
lines - the affected lines to set

last

public int last()
Returns the index of the last line of the chunk.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object