Class AbstractDifferenceEngine

  • All Implemented Interfaces:
    DifferenceEngine
    Direct Known Subclasses:
    DOMDifferenceEngine

    public abstract class AbstractDifferenceEngine
    extends java.lang.Object
    implements DifferenceEngine
    Useful base-implementation of some parts of the DifferenceEngine interface.
    • Constructor Detail

      • AbstractDifferenceEngine

        protected AbstractDifferenceEngine()
    • Method Detail

      • getNodeMatcher

        protected NodeMatcher getNodeMatcher()
        Provides access to the configured NodeMatcher.
      • getDifferenceEvaluator

        protected DifferenceEvaluator getDifferenceEvaluator()
        Provides access to the configured DifferenceEvaluator.
      • getComparisonController

        protected ComparisonController getComparisonController()
        Provides access to the configured ComparisonController.
      • setNamespaceContext

        public void setNamespaceContext​(java.util.Map<java.lang.String,​java.lang.String> prefix2uri)
        Description copied from interface: DifferenceEngine
        Establish a namespace context that will be used in Comparison.Detail#getXPath.

        Without a namespace context (or with an empty context) the XPath expressions will only use local names for elements and attributes.

        Specified by:
        setNamespaceContext in interface DifferenceEngine
        Parameters:
        prefix2uri - maps from prefix to namespace URI.
      • getNamespaceContext

        protected java.util.Map<java.lang.String,​java.lang.String> getNamespaceContext()
        Provides access to the configured namespace context.
      • setAttributeFilter

        public void setAttributeFilter​(Predicate<org.w3c.dom.Attr> af)
        Description copied from interface: DifferenceEngine
        Sets the optional strategy that decides which attributes to consider and which to ignore during comparison.

        Only attributes for which the predicate returns true are part of the comparison. By default all attributes are considered.

        The "special" namespace, namespace-location and schema-instance-type attributes can not be ignored this way. If you want to suppress comparison of them you'll need to implement DifferenceEvaluator.

        Specified by:
        setAttributeFilter in interface DifferenceEngine
      • getAttributeFilter

        protected Predicate<org.w3c.dom.Attr> getAttributeFilter()
        Provides access to the configured ComparisonController.
      • setNodeFilter

        public void setNodeFilter​(Predicate<org.w3c.dom.Node> nf)
        Description copied from interface: DifferenceEngine
        Sets the optional strategy that decides which nodes to consider and which to ignore during comparison.

        Only nodes for which the predicate returns true are part of the comparison. By default nodes that are not document types are considered.

        Specified by:
        setNodeFilter in interface DifferenceEngine
      • getNodeFilter

        protected Predicate<org.w3c.dom.Node> getNodeFilter()
        Provides access to the configured ComparisonController.
      • compare

        protected final AbstractDifferenceEngine.ComparisonState compare​(Comparison comp)
        Compares the detail values for object equality, lets the difference evaluator and comparison controller evaluate the result, notifies all listeners and returns the outcome.
        Returns:
        the outcome as pair of result and a flag that says "stop the whole comparison process" when true.
      • getXPath

        protected static java.lang.String getXPath​(XPathContext ctx)
        Returns a string representation of the given XPathContext.
      • getParentXPath

        protected static java.lang.String getParentXPath​(XPathContext ctx)
        Returns a string representation of the given XPathContext's parent context.