upidiff.diff
Class FileChange

java.lang.Object
  |
  +--upidiff.diff.FileChange

public final class FileChange
extends Object

This class represents the changes determined for two input texts.

Author:
bmeurer

Field Summary
private  Change head
          Pointer to the first change in the list.
private  InputBuffer newText
          Input text of the new file.
private  InputBuffer oldText
          Input text of the old file.
private  Change tail
          Pointer to the last change in the list.
 
Constructor Summary
FileChange(InputBuffer oldText, InputBuffer newText)
          Creates a new FileChange object.
 
Method Summary
 boolean allChangesMerged()
          Checks if there a still not-merged changes in the list.
 int blockChangeCount()
           
 void calculate(boolean displayLineChanges, boolean displayCharChanges)
          Calculates the differences between the two given file contents.
 Change getHead()
          Returns the head of the changes list.
 InputBuffer getNewText()
          Returns the content of the new file.
 Change getNextNotMerged(Change current)
          Returns the next change that is not merged or null.
 InputBuffer getOldText()
          Returns the content of the old file.
 Change getPrevNotMerged(Change current)
          Returns the previous change that is not merged or null.
 Change getTail()
          Returns the tail of the changes list.
 void recalculate(int oldTextLine, int newTextLine)
          Recalculates the differences using a fixed line association.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

head

private Change head
Pointer to the first change in the list. A value of null indicates that the two files are equal.

See Also:
getHead()

tail

private Change tail
Pointer to the last change in the list. A value of null indicates that the two files are equal.

See Also:
getTail()

oldText

private InputBuffer oldText
Input text of the old file.

See Also:
getOldText()

newText

private InputBuffer newText
Input text of the new file.

See Also:
getNewText()
Constructor Detail

FileChange

public FileChange(InputBuffer oldText,
                  InputBuffer newText)
Creates a new FileChange object.

Parameters:
oldText - Input buffer with the content of the old file.
newText - Input buffer with the content of the new file.
Method Detail

getHead

public final Change getHead()
Returns the head of the changes list.

Returns:
The first element on the changes list or null.

getTail

public final Change getTail()
Returns the tail of the changes list.

Returns:
The last element on the changes list or null.

blockChangeCount

public final int blockChangeCount()

getOldText

public final InputBuffer getOldText()
Returns the content of the old file.

Returns:
The old file buffer.

getNewText

public final InputBuffer getNewText()
Returns the content of the new file.

Returns:
The new file buffer.

calculate

public final void calculate(boolean displayLineChanges,
                            boolean displayCharChanges)
Calculates the differences between the two given file contents.

Parameters:
displayLineChanges - Whether or not to display line changes by default.
displayCharChanges - Whether or not to display char changes by default. This has no effect if displayLineChanges is false.

recalculate

public final void recalculate(int oldTextLine,
                              int newTextLine)
Recalculates the differences using a fixed line association.

Parameters:
oldTextLine - Line offset of the old text.
newTextLine - Line offset of the new text.

allChangesMerged

public final boolean allChangesMerged()
Checks if there a still not-merged changes in the list.

Returns:
true if all changes have been merge, else false.

getNextNotMerged

public final Change getNextNotMerged(Change current)
Returns the next change that is not merged or null.

Parameters:
current - Current change.
Returns:
The next change that is not yet merged or null.

getPrevNotMerged

public final Change getPrevNotMerged(Change current)
Returns the previous change that is not merged or null.

Parameters:
current - Current change.
Returns:
The previous change that is not yet merged or null.