LibreOffice Module xmerge (master)  1
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
org.openoffice.xmerge.merger.Difference Class Reference

This is the. More...

Public Member Functions

 Difference (int operation, int orgPosition, int modPosition)
 Constructor. More...
 
int getOperation ()
 Get the operation of the. More...
 
int getOrgPosition ()
 Get the original. More...
 
int getModPosition ()
 Get the modified. More...
 
boolean equals (Object obj)
 Two. More...
 
int hashCode ()
 
String debug ()
 Display debug information. More...
 
String toString ()
 Returns position and operation values as a single string. More...
 

Static Public Attributes

static final int ADD = 1
 Add operation. More...
 
static final int DELETE = 2
 Delete operation. More...
 
static final int CHANGE = 3
 Change operation. More...
 
static final int UNCHANGE = 4
 Unchange operation (i.e. More...
 

Private Attributes

final int operation
 The action of the diff - either ADD or DELETE. More...
 
final int orgPosition
 The position of the content that should be operated on (original. More...
 
final int modPosition
 The position of the content that should be operated (modified iterator). More...
 

Detailed Description

This is the.

basic unit.

Used by the

DiffAlgorithm

as a set of difference between two

Iterators

(the original and modified

Iterators

).

Definition at line 27 of file Difference.java.

Constructor & Destructor Documentation

org.openoffice.xmerge.merger.Difference.Difference ( int  operation,
int  orgPosition,
int  modPosition 
)
inline

Constructor.

This is the standard way to create a

object.

Parameters
operationEither ADD or DELETE.
orgPositionThe position in the original (first)
Iterator
.
modPositionThe position in the modified (second)
Iterator
.

Definition at line 120 of file Difference.java.

References org.openoffice.xmerge.merger.Difference.modPosition, org.openoffice.xmerge.merger.Difference.operation, and org.openoffice.xmerge.merger.Difference.orgPosition.

Referenced by org.openoffice.xmerge.merger.Difference.equals().

Member Function Documentation

String org.openoffice.xmerge.merger.Difference.debug ( )
inline
boolean org.openoffice.xmerge.merger.Difference.equals ( Object  obj)
inline
int org.openoffice.xmerge.merger.Difference.getModPosition ( )
inline

Get the modified.

Iterator

position.

Returns
The position in the modified (second)
Iterator
.

Definition at line 151 of file Difference.java.

References org.openoffice.xmerge.merger.Difference.modPosition.

Referenced by org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge.coreMerge().

int org.openoffice.xmerge.merger.Difference.getOperation ( )
inline

Get the operation of the.

.

Returns
the operation of the , either ADD or DELETE.

Definition at line 133 of file Difference.java.

References org.openoffice.xmerge.merger.Difference.operation.

int org.openoffice.xmerge.merger.Difference.getOrgPosition ( )
inline

Get the original.

Iterator

position.

Returns
The position in the original (first)
Iterator
.

Definition at line 142 of file Difference.java.

References org.openoffice.xmerge.merger.Difference.orgPosition.

Referenced by org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge.applyDifference(), and org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge.coreMerge().

int org.openoffice.xmerge.merger.Difference.hashCode ( )
inline

Definition at line 179 of file Difference.java.

String org.openoffice.xmerge.merger.Difference.toString ( )
inline

Returns position and operation values as a single string.

Returns
, and as a single .

Definition at line 219 of file Difference.java.

References org.openoffice.xmerge.merger.Difference.operation, and String.

Member Data Documentation

final int org.openoffice.xmerge.merger.Difference.ADD = 1
static
final int org.openoffice.xmerge.merger.Difference.CHANGE = 3
static
final int org.openoffice.xmerge.merger.Difference.DELETE = 2
static
final int org.openoffice.xmerge.merger.Difference.modPosition
private

The position of the content that should be operated (modified iterator).

For explanation and examples, see orgPosition

.

Definition at line 109 of file Difference.java.

Referenced by org.openoffice.xmerge.merger.Difference.Difference(), org.openoffice.xmerge.merger.Difference.equals(), and org.openoffice.xmerge.merger.Difference.getModPosition().

final int org.openoffice.xmerge.merger.Difference.operation
private
final int org.openoffice.xmerge.merger.Difference.orgPosition
private

The position of the content that should be operated on (original.

iterator

).

For

, the

is the position of the original sequence where the diff will insert (the element count is starting from 0, and always insert before the element). The

is the position of the diff in the modified sequence (also starting from 0).

{ example:
diff -  and 
note:  is original sequence and 
is the modified one.
     and here is the position of those sequence:
      
      0 1   0 1 2 3 4 5
result:
<diff orgpos="0" modpos="0" operation="ADD">  <-- element A
<diff orgpos="1" modpos="2" operation="ADD">  <-- element C
<diff orgpos="2" modpos="4" operation="ADD">  <-- element E
<diff orgpos="2" modpos="5" operation="ADD">  <-- element F}
One can notice the add operation is inserted before the position.
Hence, in order to append an element, we will have a position of original
sequence length + 1 to denote an append.
For

,

is the position that the element will be deleted (starting from 0) and

is the position where the deleted element should be (consider as an

).

The

is less useful and it is difficult to understand how the position is calculated. One can just skip this piece of information. It is useful if one wants to reverse the role of original sequence and modified sequence and find out the diff easily (just change add to delete and delete to add for operation and swap the

and

).

{ example:
diff -  and 
note:  is original sequence and 
is the modified one.
      and here is the position of those sequence:
       
       0 1 2 3 4 5   0 1
result:
<diff orgpos="0" modpos="0" operation="DELETE">  <--  element A
<diff orgpos="2" modpos="1" operation="DELETE">  <--  element C
<diff orgpos="4" modpos="2" operation="DELETE">  <--  element E
<diff orgpos="5" modpos="2" operation="DELETE">  <--  element F}

Definition at line 102 of file Difference.java.

Referenced by org.openoffice.xmerge.merger.Difference.Difference(), org.openoffice.xmerge.merger.Difference.equals(), and org.openoffice.xmerge.merger.Difference.getOrgPosition().

final int org.openoffice.xmerge.merger.Difference.UNCHANGE = 4
static

Unchange operation (i.e.

no change).

Definition at line 39 of file Difference.java.

Referenced by org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge.coreMerge().


The documentation for this class was generated from the following file: