Class Differencer

java.lang.Object
com.polarion.qcentre.factbase.delta.Differencer

public class Differencer extends 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.
Clients may use as is, or subclass to provide a custom implementation for the three hooks. However the default implementation already deals with the typical case:
  • getChildren: tries to apply the IStructureComparator interface to enumerate the children,
  • contentsEqual: tries to apply the IStreamContentAccessor interface to perform a byte-wise content comparison,
  • visit: creates a DiffNode for any detected difference between the compared objects and links it under a parent node effectively creating a tree of differences.
The different kind of changes detected by the engine are decoded as follows: In the two-way case only NO_CHANGE, ADDITION, DELETION, and CHANGE are used. In the three-way case these constants are bitwise ORed with one of directional constants LEFT, RIGHT, and CONFLICTING.