Package org.xmlunit.diff
Class AbstractDifferenceEngine
java.lang.Object
org.xmlunit.diff.AbstractDifferenceEngine
- All Implemented Interfaces:
DifferenceEngine
- Direct Known Subclasses:
DOMDifferenceEngine
Useful base-implementation of some parts of the DifferenceEngine
interface.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classEncapsulates the current result and a flag that indicates whether comparison should be stopped.protected static interfaceEncapsulates a comparison that may or may not be performed.protected final classprotected final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ComparisonControllerprivate DifferenceEvaluatorprivate static final Stringprivate final ComparisonListenerSupportprivate NodeMatcherprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a listener that is notified of each comparison.voidRegisters a listener that is notified of each comparison with outcome other thanComparisonResult.EQUAL.voidRegisters a listener that is notified of each comparison with outcomeComparisonResult.EQUAL.protected final AbstractDifferenceEngine.ComparisonStatecompare(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.Provides access to the configured ComparisonController.protected ComparisonControllerProvides access to the configured ComparisonController.protected DifferenceEvaluatorProvides access to the configured DifferenceEvaluator.Provides access to the configured namespace context.Provides access to the configured ComparisonController.protected NodeMatcherProvides access to the configured NodeMatcher.protected static StringReturns a string representation of the given XPathContext's parent context.protected static StringgetXPath(XPathContext ctx) Returns a string representation of the given XPathContext.voidSets the optional strategy that decides which attributes to consider and which to ignore during comparison.voidDetermines whether the comparison should stop after given difference has been found.voidEvaluates the severity of a difference.voidsetNamespaceContext(Map<String, String> prefix2uri) Establish a namespace context that will be used inComparison.Detail#getXPath.voidsetNodeFilter(Predicate<Node> nf) Sets the optional strategy that decides which nodes to consider and which to ignore during comparison.voidSets the strategy for selecting nodes to compare.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xmlunit.diff.DifferenceEngine
compare
-
Field Details
-
NOT_BE_NULL
- See Also:
-
LISTENER_MUST_NOT_BE_NULL
- See Also:
-
listeners
-
nodeMatcher
-
diffEvaluator
-
comparisonController
-
prefix2uri
-
attributeFilter
-
nodeFilter
-
-
Constructor Details
-
AbstractDifferenceEngine
protected AbstractDifferenceEngine()
-
-
Method Details
-
addComparisonListener
Description copied from interface:DifferenceEngineRegisters a listener that is notified of each comparison.- Specified by:
addComparisonListenerin interfaceDifferenceEngine
-
addMatchListener
Description copied from interface:DifferenceEngineRegisters a listener that is notified of each comparison with outcomeComparisonResult.EQUAL.- Specified by:
addMatchListenerin interfaceDifferenceEngine
-
addDifferenceListener
Description copied from interface:DifferenceEngineRegisters a listener that is notified of each comparison with outcome other thanComparisonResult.EQUAL.- Specified by:
addDifferenceListenerin interfaceDifferenceEngine
-
setNodeMatcher
Description copied from interface:DifferenceEngineSets the strategy for selecting nodes to compare.- Specified by:
setNodeMatcherin interfaceDifferenceEngine
-
getNodeMatcher
Provides access to the configured NodeMatcher. -
setDifferenceEvaluator
Description copied from interface:DifferenceEngineEvaluates the severity of a difference.- Specified by:
setDifferenceEvaluatorin interfaceDifferenceEngine
-
getDifferenceEvaluator
Provides access to the configured DifferenceEvaluator. -
setComparisonController
Description copied from interface:DifferenceEngineDetermines whether the comparison should stop after given difference has been found.- Specified by:
setComparisonControllerin interfaceDifferenceEngine
-
getComparisonController
Provides access to the configured ComparisonController. -
setNamespaceContext
Description copied from interface:DifferenceEngineEstablish a namespace context that will be used inComparison.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:
setNamespaceContextin interfaceDifferenceEngine- Parameters:
prefix2uri- maps from prefix to namespace URI.
-
getNamespaceContext
Provides access to the configured namespace context. -
setAttributeFilter
Description copied from interface:DifferenceEngineSets 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:
setAttributeFilterin interfaceDifferenceEngine
-
getAttributeFilter
Provides access to the configured ComparisonController. -
setNodeFilter
Description copied from interface:DifferenceEngineSets 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:
setNodeFilterin interfaceDifferenceEngine
-
getNodeFilter
Provides access to the configured ComparisonController. -
compare
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
Returns a string representation of the given XPathContext. -
getParentXPath
Returns a string representation of the given XPathContext's parent context.
-