upidiff.diff
Class Change

java.lang.Object
  |
  +--upidiff.diff.Change
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BlockChange, CharChange, LineChange

public abstract class Change
extends Object
implements Serializable

This is the base class for all possible kinds of changes. A change can either be a BlockChange, a LineChange or a CharChange. Each change represents one place where some text - either lines of text or characters - are deleted and some are inserted.

Author:
bmeurer
See Also:
Diff.Change, Serialized Form

Field Summary
protected  int deleted
          The number of lines or characters of the old text changed here.
protected  int deletedOffset
          Offset of the first deleted item in the old text.
protected  int inserted
          The number of lines or characters of the new text changed here.
protected  int insertedOffset
          Offset of the first inserted item in the new text.
static int NEWFILE
          A constant defined to name the new file version
protected  Change next
          Pointer to the next Change in the list or null.
static int NOTMERGED
          Indicates that the Change was not yet merged.
static int OLDFILE
          A constant defined to name the old file version
protected  Change parent
          Pointer to the parent Change.
protected  Change prev
          Pointer to the previous Change in the list or null.
protected  int whichVersion
          Which Version was was merged.
 
Constructor Summary
(package private) Change(Diff.Change change, Change parent)
          Creates a new Change object using the result of the diff calculation.
(package private) Change(int deletedOffset, int insertedOffset, int deleted, int inserted, Change parent)
          Creates a new Change object using the given attributes.
 
Method Summary
 int getDeleted()
          Returns the amount of the old text changed here.
 int getDeletedOffset()
          Returns the offset of the first deleted item in the old text.
 int getInserted()
          Returns the amount of the new text changed here.
 int getInsertedOffset()
          Returns the offset of the first inserted item in the new text.
 int getMergedVersion()
          Returns the the Version that was merged or -1 if this Change wasn't merged allready.
 Change getNext()
          Returns a pointer to the next Change in the list.
 Change getParent()
          Returns a pointer to the parent Change.
 Change getPrev()
          Returns a pointer to the previous Change in the list.
 boolean isMerged()
          Whether or not this Change was already merged.
 void setDeleted(int deleted)
          Sets the amount of the old text changed here.
 void setDeletedOffset(int offset)
          Sets the offset of the first deleted item in the old text.
 void setInserted(int inserted)
          Sets the amount of the new text changed here.
 void setInsertedOffset(int offset)
          Sets the offset of the first inserted item in the new text.
 void setMerged(int whichVersion)
          Marks this Change as merged.
 void setNext(Change change)
          Sets the pointer to the next Change in the list.
 void setParent(Change parent)
          Reparents the Change with the given paren Change.
 void setPrev(Change change)
          Sets the pointer to the previous Change in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOTMERGED

public static final int NOTMERGED
Indicates that the Change was not yet merged.

See Also:
Constant Field Values

OLDFILE

public static final int OLDFILE
A constant defined to name the old file version

See Also:
Constant Field Values

NEWFILE

public static final int NEWFILE
A constant defined to name the new file version

See Also:
Constant Field Values

next

protected Change next
Pointer to the next Change in the list or null.


prev

protected Change prev
Pointer to the previous Change in the list or null.


parent

protected Change parent
Pointer to the parent Change. For a CharChange this points to the LineChange that covers the CharChange and for a LineChange the parent is the BlockChange that contains the specific line. For a BlockChange this is always null.


deleted

protected int deleted
The number of lines or characters of the old text changed here.

See Also:
getDeleted(), setDeleted(int)

inserted

protected int inserted
The number of lines or characters of the new text changed here.

See Also:
getInserted(), setInserted(int)

deletedOffset

protected int deletedOffset
Offset of the first deleted item in the old text.

See Also:
getDeletedOffset(), setDeletedOffset(int), Diff.Change.line0

insertedOffset

protected int insertedOffset
Offset of the first inserted item in the new text.

See Also:
getInsertedOffset(), setInsertedOffset(int), Diff.Change.line1

whichVersion

protected int whichVersion
Which Version was was merged. Use OLDFILE or NEWFILE

Constructor Detail

Change

Change(int deletedOffset,
       int insertedOffset,
       int deleted,
       int inserted,
       Change parent)
Creates a new Change object using the given attributes.

Parameters:
deletedOffset - First offset in the old file.
insertedOffset - First offset in the new file.
deleted - Amount of data in the old file.
inserted - Amount of data in the new file.
parent - Parent change object.

Change

Change(Diff.Change change,
       Change parent)
Creates a new Change object using the result of the diff calculation.

Parameters:
change - Result of the diff calculation.
parent - Parent change object.
See Also:
Diff.Change
Method Detail

getNext

public final Change getNext()
Returns a pointer to the next Change in the list.

Returns:
Pointer to the next Change.

setNext

public final void setNext(Change change)
Sets the pointer to the next Change in the list.

Parameters:
change - New next Change.

getPrev

public final Change getPrev()
Returns a pointer to the previous Change in the list.

Returns:
Pointer to the previous Change.

setPrev

public final void setPrev(Change change)
Sets the pointer to the previous Change in the list.

Parameters:
change - New previous Change.

getParent

public final Change getParent()
Returns a pointer to the parent Change.

Returns:
Pointer to the parent Change.

setParent

public final void setParent(Change parent)
Reparents the Change with the given paren Change.

Parameters:
parent - New parent Change.

getDeleted

public final int getDeleted()
Returns the amount of the old text changed here. The amount can either be a number lines for block and line changes or a number of characters in a line for a character changes.

Returns:
The number of lines or characters of the old text changed here.

setDeleted

public final void setDeleted(int deleted)
Sets the amount of the old text changed here. The amount can either be a number lines for block and line changes or a number of characters in a line for a character changes.

Parameters:
deleted - The new number of lines or characters of the old text changed here.

getInserted

public final int getInserted()
Returns the amount of the new text changed here. The amount can either be a number lines for block and line changes or a number of characters in a line for a character changes.

Returns:
The number of lines or characters of the new text changed here.

setInserted

public final void setInserted(int inserted)
Sets the amount of the new text changed here. The amount can either be a number lines for block and line changes or a number of characters in a line for a character changes.

Parameters:
inserted - The new number of lines or characters of the new text changed here.

getDeletedOffset

public final int getDeletedOffset()
Returns the offset of the first deleted item in the old text. The offset is a line number for block and line changes and a character offset in the line for character changes. The origin for the offset is 0, so an offset of 0 for a character change means the first character in that line and an offset of 0 for a line or block change means the first line in that text.

Returns:
The offset of the first deleted line or character in the old text.

setDeletedOffset

public final void setDeletedOffset(int offset)
Sets the offset of the first deleted item in the old text. The offset is a line number for block and line changes and a character offset in the line for character changes. The origin for the offset is 0, so an offset of 0 for a character change means the first character in that line and an offset of 0 for a line or block change means the first line in that text.

Parameters:
offset - The new offset of the first deleted item in the old text.

getInsertedOffset

public final int getInsertedOffset()
Returns the offset of the first inserted item in the new text. The offset is a line number for block and line changes and a character offset in the line for character changes. The origin for the offset is 0, so an offset of 0 for a character change means the first character in that line and an offset of 0 for a line or block change means the first line in that text.

Returns:
The offset of the first inserted line or character in the new text.

setInsertedOffset

public final void setInsertedOffset(int offset)
Sets the offset of the first inserted item in the new text. The offset is a line number for block and line changes and a character offset in the line for character changes. The origin for the offset is 0, so an offset of 0 for a character change means the first character in that line and an offset of 0 for a line or block change means the first line in that text.

Parameters:
offset - The new offset of the first inserted item in the new text.

isMerged

public final boolean isMerged()
Whether or not this Change was already merged.

Returns:
true if this Change was already merged, else false.
See Also:
setMerged(int)

setMerged

public final void setMerged(int whichVersion)
Marks this Change as merged.

Parameters:
whichVersion - the merged version. Use OLDFILE or NEWFILE only
See Also:
isMerged()

getMergedVersion

public final int getMergedVersion()
Returns the the Version that was merged or -1 if this Change wasn't merged allready.

Returns:
The version that was merged: OLDFILE or NEWFILE