|
|||||||||
| Home >> All >> org >> eclipse >> compare >> [ structuremergeviewer overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.compare.structuremergeviewer
Class Differencer

java.lang.Objectorg.eclipse.compare.structuremergeviewer.Differencer
- public class Differencer
- extends java.lang.Object
A generic two-way or three-way differencing engine.
The engine is used by calling one of the findDifferences methods and passing
in the objects to compare.
The engine calls the following methods on the input objects to perform the compare:
getChildren: for enumerating the children of an object (if any),contentsEqual: for comparing the content of leaf objects, that is, objects without children,visit: for every pair of compared object the compare result is passed in.
getChildren: tries to apply theIStructureComparatorinterface to enumerate the children,contentsEqual: tries to apply theIStreamContentAccessorinterface to perform a byte-wise content comparison,visit: creates aDiffNodefor any detected difference between the compared objects and links it under a parent node effectively creating a tree of differences.
| Nested Class Summary | |
(package private) static class |
Differencer.Node
|
| Field Summary | |
static int |
ADDITION
Difference constant (value 1) indicating one side was added. |
static int |
CHANGE
Difference constant (value 3) indicating side changed. |
static int |
CHANGE_TYPE_MASK
Bit mask (value 3) for extracting the kind of difference. |
static int |
CONFLICTING
Three-way change constant (value 12) indicating a change on left and right sides. |
static int |
DELETION
Difference constant (value 2) indicating one side was removed. |
static int |
DIRECTION_MASK
Bit mask (value 12) for extracting the direction of a three-way change. |
static int |
LEFT
Three-way change constant (value 4) indicating a change on left side. |
static int |
NO_CHANGE
Difference constant (value 0) indicating no difference. |
static int |
PSEUDO_CONFLICT
Constant (value 16) indicating a change on left and right side (with respect to ancestor) but left and right are identical. |
static int |
RIGHT
Three-way change constant (value 8) indicating a change on right side. |
| Constructor Summary | |
Differencer()
Creates a new differencing engine. |
|
| Method Summary | |
private int |
compare(boolean threeway,
java.lang.Object ancestor,
java.lang.Object left,
java.lang.Object right)
Performs a 2-way or 3-way compare of the given leaf elements and returns an integer describing the kind of difference. |
protected boolean |
contentsEqual(java.lang.Object input1,
java.lang.Object input2)
Performs a content compare on the two given inputs. |
java.lang.Object |
findDifferences(boolean threeWay,
org.eclipse.core.runtime.IProgressMonitor pm,
java.lang.Object data,
java.lang.Object ancestor,
java.lang.Object left,
java.lang.Object right)
Starts the differencing engine on the three input objects. |
protected java.lang.Object[] |
getChildren(java.lang.Object input)
Returns the children of the given input or null if there are no children. |
private java.io.InputStream |
getStream(java.lang.Object o)
Tries to return an InputStream for the given object. |
private int |
traverse(boolean threeWay,
Differencer.Node parent,
org.eclipse.core.runtime.IProgressMonitor pm,
java.lang.Object ancestor,
java.lang.Object left,
java.lang.Object right)
Traverse tree in postorder. |
protected void |
updateProgress(org.eclipse.core.runtime.IProgressMonitor progressMonitor,
java.lang.Object node)
Called for every leaf or node compare to update progress information. |
protected java.lang.Object |
visit(java.lang.Object data,
int result,
java.lang.Object ancestor,
java.lang.Object left,
java.lang.Object right)
Called for every node or leaf comparison. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
NO_CHANGE
public static final int NO_CHANGE
- Difference constant (value 0) indicating no difference.
- See Also:
- Constant Field Values
ADDITION
public static final int ADDITION
- Difference constant (value 1) indicating one side was added.
- See Also:
- Constant Field Values
DELETION
public static final int DELETION
- Difference constant (value 2) indicating one side was removed.
- See Also:
- Constant Field Values
CHANGE
public static final int CHANGE
- Difference constant (value 3) indicating side changed.
- See Also:
- Constant Field Values
CHANGE_TYPE_MASK
public static final int CHANGE_TYPE_MASK
- Bit mask (value 3) for extracting the kind of difference.
- See Also:
- Constant Field Values
LEFT
public static final int LEFT
- Three-way change constant (value 4) indicating a change on left side.
- See Also:
- Constant Field Values
RIGHT
public static final int RIGHT
- Three-way change constant (value 8) indicating a change on right side.
- See Also:
- Constant Field Values
CONFLICTING
public static final int CONFLICTING
- Three-way change constant (value 12) indicating a change on left and
right sides.
- See Also:
- Constant Field Values
DIRECTION_MASK
public static final int DIRECTION_MASK
- Bit mask (value 12) for extracting the direction of a three-way change.
- See Also:
- Constant Field Values
PSEUDO_CONFLICT
public static final int PSEUDO_CONFLICT
- Constant (value 16) indicating a change on left and
right side (with respect to ancestor) but left and right are identical.
- See Also:
- Constant Field Values
| Constructor Detail |
Differencer
public Differencer()
- Creates a new differencing engine.
| Method Detail |
findDifferences
public java.lang.Object findDifferences(boolean threeWay, org.eclipse.core.runtime.IProgressMonitor pm, java.lang.Object data, java.lang.Object ancestor, java.lang.Object left, java.lang.Object right)
- Starts the differencing engine on the three input objects. If threeWay is
truea three-way comparison is performed, otherwise a two-way compare (in the latter case the ancestor argument is ignored). The progress monitor is passed to the methodupdateProgresswhich is called for every node or leaf compare. The method returns the object that was returned from the top-most call to methodvisit. At most two of the ancestor, left, and right parameters are allowed to benull.
traverse
private int traverse(boolean threeWay,
Differencer.Node parent,
org.eclipse.core.runtime.IProgressMonitor pm,
java.lang.Object ancestor,
java.lang.Object left,
java.lang.Object right)
- Traverse tree in postorder.
visit
protected java.lang.Object visit(java.lang.Object data, int result, java.lang.Object ancestor, java.lang.Object left, java.lang.Object right)
- Called for every node or leaf comparison.
The differencing engine passes in the input objects of the compare and the result of the compare.
The data object is the value returned from a call to the
visitmethod on the parent input. It can be considered the "parent" reference and is useful when building a tree.The
Differencerimplementation returns a newDiffNodewhich is initialized with the corresponding values. Subclasses may override.
compare
private int compare(boolean threeway,
java.lang.Object ancestor,
java.lang.Object left,
java.lang.Object right)
- Performs a 2-way or 3-way compare of the given leaf elements and returns an integer
describing the kind of difference.
contentsEqual
protected boolean contentsEqual(java.lang.Object input1, java.lang.Object input2)
- Performs a content compare on the two given inputs.
The
Differencerimplementation returnstrueif both inputs implementIStreamContentAccessorand their byte contents is identical. Subclasses may override to implement a different content compare on the given inputs.
getStream
private java.io.InputStream getStream(java.lang.Object o)
- Tries to return an InputStream for the given object.
Returns
nullif the object not an IStreamContentAccessor or an error occured.
getChildren
protected java.lang.Object[] getChildren(java.lang.Object input)
- Returns the children of the given input or
nullif there are no children.The
Differencerimplementation checks whether the input implements theIStructureComparatorinterface. If yes it is used to return an array containing all children. Otherwisenullis returned. Subclasses may override to implement a different strategy to enumerate children.
updateProgress
protected void updateProgress(org.eclipse.core.runtime.IProgressMonitor progressMonitor, java.lang.Object node)
- Called for every leaf or node compare to update progress information.
The
Differencerimplementation shows the name of the input object as a subtask. Subclasses may override.
|
|||||||||
| Home >> All >> org >> eclipse >> compare >> [ structuremergeviewer overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.eclipse.compare.structuremergeviewer.Differencer