Class Differencer
 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 the- IStructureComparatorinterface to enumerate the children,
- contentsEqual: tries to apply the- IStreamContentAccessorinterface to perform a byte-wise content comparison,
- visit: creates a- DiffNodefor any detected difference between the compared objects and links it under a parent node effectively creating a tree of differences.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intDifference constant (value 1) indicating one side was added.static final intDifference constant (value 3) indicating side changed.static final intBit mask (value 3) for extracting the kind of difference.static final intThree-way change constant (value 12) indicating a change on left and right sides.static final intDifference constant (value 2) indicating one side was removed.static final intBit mask (value 12) for extracting the direction of a three-way change.static final intThree-way change constant (value 4) indicating a change on left side.static final intDifference constant (value 0) indicating no difference.static final intConstant (value 16) indicating a change on left and right side (with respect to ancestor) but left and right are identical.static final intThree-way change constant (value 8) indicating a change on right side.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleancontentsEqual(Object input1, char contributor1, Object input2, char contributor2) Performs a content compare on the two given inputs.protected booleancontentsEqual(Object input1, Object input2) Performs a content compare on the two given inputs.findDifferences(boolean threeWay, IProgressMonitor pm, Object data, Object ancestor, Object left, Object right) Starts the differencing engine on the three input objects.protected Object[]getChildren(Object input) Returns the children of the given input ornullif there are no children.protected voidupdateProgress(IProgressMonitor progressMonitor, Object node) Called for every leaf or node compare to update progress information.protected ObjectCalled for every node or leaf comparison.
- 
Field Details- 
NO_CHANGEpublic static final int NO_CHANGEDifference constant (value 0) indicating no difference.- See Also:
 
- 
ADDITIONpublic static final int ADDITIONDifference constant (value 1) indicating one side was added.- See Also:
 
- 
DELETIONpublic static final int DELETIONDifference constant (value 2) indicating one side was removed.- See Also:
 
- 
CHANGEpublic static final int CHANGEDifference constant (value 3) indicating side changed.- See Also:
 
- 
CHANGE_TYPE_MASKpublic static final int CHANGE_TYPE_MASKBit mask (value 3) for extracting the kind of difference.- See Also:
 
- 
LEFTpublic static final int LEFTThree-way change constant (value 4) indicating a change on left side.- See Also:
 
- 
RIGHTpublic static final int RIGHTThree-way change constant (value 8) indicating a change on right side.- See Also:
 
- 
CONFLICTINGpublic static final int CONFLICTINGThree-way change constant (value 12) indicating a change on left and right sides.- See Also:
 
- 
DIRECTION_MASKpublic static final int DIRECTION_MASKBit mask (value 12) for extracting the direction of a three-way change.- See Also:
 
- 
PSEUDO_CONFLICTpublic static final int PSEUDO_CONFLICTConstant (value 16) indicating a change on left and right side (with respect to ancestor) but left and right are identical.- See Also:
 
 
- 
- 
Constructor Details- 
Differencerpublic Differencer()Creates a new differencing engine.
 
- 
- 
Method Details- 
findDifferencespublic Object findDifferences(boolean threeWay, IProgressMonitor pm, Object data, Object ancestor, Object left, Object right) Starts the differencing engine on the three input objects. If threeWay istruea 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.- Parameters:
- threeWay- if- truea three-way comparison is performed, otherwise a two-way compare
- pm- a progress monitor which is passed to method- updateProgress
- data- a client data that is passed to the top-level call to- visit
- ancestor- the ancestor object of the compare (may be- null)
- left- the left object of the compare
- right- the right object of the compare
- Returns:
- the object returned from the top most call to method visit, possiblynull
 
- 
visitCalled 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 thevisitmethod 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.- Parameters:
- data- object returned from parent call to- visit, possibly- null
- result- the result of the compare operation performed on the three inputs
- ancestor- the compare ancestor of the left and right inputs
- left- the left input to the compare
- right- the right input to the compare
- Returns:
- the result, possibly null
 
- 
contentsEqualPerforms a content compare on the two given inputs.The Differencerimplementation returnscontentsEqual(Object input1, Object input2). Subclasses may override to implement a different content compare on the given inputs.- Parameters:
- input1- first input to contents compare
- contributor1- the contributor of input1
- input2- second input to contents compare
- contributor2- the contributor of input2
- Returns:
- trueif content is equal
- Since:
- 3.6
- Restriction:
- This method is not intended to be referenced by clients.
 
- 
contentsEqualPerforms 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.- Parameters:
- input1- first input to contents compare
- input2- second input to contents compare
- Returns:
- trueif content is equal
 
- 
getChildrenReturns the children of the given input ornullif 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.- Parameters:
- input- the object for which to return children
- Returns:
- the children of the given input or nullif there are no children.
 
- 
updateProgressCalled 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.- Parameters:
- progressMonitor- the progress monitor for reporting progress
- node- the currently processed non-- nullnode
 
 
-