upidiff.diff
Class LineChange

java.lang.Object
  |
  +--upidiff.diff.Change
        |
        +--upidiff.diff.LineChange
All Implemented Interfaces:
Serializable

public final class LineChange
extends Change

This class represents a line change. A line change can either be a line inserted or deleted in the new file, or a line in the old file replaced with another line in the new file.

Author:
bmeurer
See Also:
Serialized Form

Field Summary
private  boolean charChangesVisible
          Whether or not char changes are displayed for this line change.
private  LineChange nextLineChange
          Points to the next line change within this block change or null.
private  LineChange prevLineChange
          Points to the previous line change within this change or null.
 
Fields inherited from class upidiff.diff.Change
deleted, deletedOffset, inserted, insertedOffset, NEWFILE, next, NOTMERGED, OLDFILE, parent, prev, whichVersion
 
Constructor Summary
(package private) LineChange(int deletedOffset, int insertedOffset, int deleted, int inserted, boolean charChangesVisible, BlockChange parent)
          Creates a new line change using the given attributes.
 
Method Summary
(package private)  void calculateCharChanges(String oldLine, String newLine)
          Calculates the char changes for this line change.
 boolean charChangesPossible()
          Tells whether or not this line change can contain character changes.
private  Character[] convertToArray(String line)
          Converts a String to a Character array.
 LineChange getNextLineChange()
          Returns a pointer to the next line change within this block change.
 LineChange getPrevLineChange()
          Returns a pointer to the previous line change within this block change.
 boolean isCharChangesVisible()
          Returns whether or not to display the char changes within this line change.
 boolean oneCharAlreadyMerged()
          This method queries whether one of the CharChanges in this Line was already merged.
 void setCharChangesVisible(boolean visible)
          Sets whether or not to display the char changes within this line change.
 void setNextLineChange(LineChange next)
          Sets the pointer to the next line change within this block change.
 void setPrevLineChange(LineChange prev)
          Sets the pointer to the previous line change within this block change.
 
Methods inherited from class upidiff.diff.Change
getDeleted, getDeletedOffset, getInserted, getInsertedOffset, getMergedVersion, getNext, getParent, getPrev, isMerged, setDeleted, setDeletedOffset, setInserted, setInsertedOffset, setMerged, setNext, setParent, setPrev
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

charChangesVisible

private boolean charChangesVisible
Whether or not char changes are displayed for this line change.


nextLineChange

private LineChange nextLineChange
Points to the next line change within this block change or null. A value of null indicates that there a no more line changes in the block change after this line change.


prevLineChange

private LineChange prevLineChange
Points to the previous line change within this change or null. A value of null indicates that there a no more line changes in the block change before this line change.

Constructor Detail

LineChange

LineChange(int deletedOffset,
           int insertedOffset,
           int deleted,
           int inserted,
           boolean charChangesVisible,
           BlockChange parent)
Creates a new line change using the given attributes.

Parameters:
deletedOffset - Line offset in old file.
insertedOffset - Line offset in new file.
deleted - Number of lines deleted.
inserted - Number of lines inserted.
charChangesVisible - Should char changes be displayed for this line change.
parent - BlockChange this LineChange belongs to.
See Also:
BlockChange, Change.Change(int,int,int,int,Change)
Method Detail

isCharChangesVisible

public final boolean isCharChangesVisible()
Returns whether or not to display the char changes within this line change.

Returns:
Whether to display char changes for this line change.

setCharChangesVisible

public final void setCharChangesVisible(boolean visible)
Sets whether or not to display the char changes within this line change.

Parameters:
visible - Whether to display char changes for this line change.

getNextLineChange

public final LineChange getNextLineChange()
Returns a pointer to the next line change within this block change.

Returns:
Pointer to the next line change or null.

oneCharAlreadyMerged

public final boolean oneCharAlreadyMerged()
This method queries whether one of the CharChanges in this Line was already merged.

Returns:
Returns true if on of its CharChanges was already merged

setNextLineChange

public final void setNextLineChange(LineChange next)
Sets the pointer to the next line change within this block change.

Parameters:
next - New next line change.

getPrevLineChange

public final LineChange getPrevLineChange()
Returns a pointer to the previous line change within this block change.

Returns:
Pointer to the previous line change or null.

setPrevLineChange

public final void setPrevLineChange(LineChange prev)
Sets the pointer to the previous line change within this block change.

Parameters:
prev - New previous line change.

charChangesPossible

public final boolean charChangesPossible()
Tells whether or not this line change can contain character changes. A line change can have character changes associated with it only if the number of lines deleted match the number of lines inserted, that is both the deleted and the inserted attribute is 1.

Returns:
true, if the line change can contain character changes, else false is returned.

convertToArray

private final Character[] convertToArray(String line)
Converts a String to a Character array.

Parameters:
line - String to convert.
Returns:
The Character array.

calculateCharChanges

final void calculateCharChanges(String oldLine,
                                String newLine)
Calculates the char changes for this line change.

Parameters:
oldLine - Line in the old text.
newLine - Line in the new text.