public abstract class AbstractDifferenceEngine extends Object implements DifferenceEngine
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractDifferenceEngine.ComparisonState
Encapsulates the current result and a flag that
indicates whether comparison should be stopped.
|
protected static interface |
AbstractDifferenceEngine.DeferredComparison
Encapsulates a comparison that may or may not be performed.
|
protected class |
AbstractDifferenceEngine.FinishedComparisonState |
protected class |
AbstractDifferenceEngine.OngoingComparisonState |
Modifier | Constructor and Description |
---|---|
protected |
AbstractDifferenceEngine() |
Modifier and Type | Method and Description |
---|---|
void |
addComparisonListener(ComparisonListener l)
Registers a listener that is notified of each comparison.
|
void |
addDifferenceListener(ComparisonListener l)
Registers a listener that is notified of each comparison with
outcome other than
ComparisonResult.EQUAL . |
void |
addMatchListener(ComparisonListener l)
Registers a listener that is notified of each comparison with
outcome
ComparisonResult.EQUAL . |
protected 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.
|
protected Predicate<Attr> |
getAttributeFilter()
Provides access to the configured ComparisonController.
|
protected ComparisonController |
getComparisonController()
Provides access to the configured ComparisonController.
|
protected DifferenceEvaluator |
getDifferenceEvaluator()
Provides access to the configured DifferenceEvaluator.
|
protected Map<String,String> |
getNamespaceContext()
Provides access to the configured namespace context.
|
protected Predicate<Node> |
getNodeFilter()
Provides access to the configured ComparisonController.
|
protected NodeMatcher |
getNodeMatcher()
Provides access to the configured NodeMatcher.
|
protected static String |
getParentXPath(XPathContext ctx)
Returns a string representation of the given XPathContext's parent context.
|
protected static String |
getXPath(XPathContext ctx)
Returns a string representation of the given XPathContext.
|
void |
setAttributeFilter(Predicate<Attr> af)
Sets the optional strategy that decides which attributes to
consider and which to ignore during comparison.
|
void |
setComparisonController(ComparisonController c)
Determines whether the comparison should stop after given
difference has been found.
|
void |
setDifferenceEvaluator(DifferenceEvaluator e)
Evaluates the severity of a difference.
|
void |
setNamespaceContext(Map<String,String> prefix2uri)
Establish a namespace context that will be used in
Comparison.Detail#getXPath . |
void |
setNodeFilter(Predicate<Node> nf)
Sets the optional strategy that decides which nodes to
consider and which to ignore during comparison.
|
void |
setNodeMatcher(NodeMatcher n)
Sets the strategy for selecting nodes to compare.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compare
public void addComparisonListener(ComparisonListener l)
DifferenceEngine
addComparisonListener
in interface DifferenceEngine
public void addMatchListener(ComparisonListener l)
DifferenceEngine
ComparisonResult.EQUAL
.addMatchListener
in interface DifferenceEngine
public void addDifferenceListener(ComparisonListener l)
DifferenceEngine
ComparisonResult.EQUAL
.addDifferenceListener
in interface DifferenceEngine
public void setNodeMatcher(NodeMatcher n)
DifferenceEngine
setNodeMatcher
in interface DifferenceEngine
protected NodeMatcher getNodeMatcher()
public void setDifferenceEvaluator(DifferenceEvaluator e)
DifferenceEngine
setDifferenceEvaluator
in interface DifferenceEngine
protected DifferenceEvaluator getDifferenceEvaluator()
public void setComparisonController(ComparisonController c)
DifferenceEngine
setComparisonController
in interface DifferenceEngine
protected ComparisonController getComparisonController()
public void setNamespaceContext(Map<String,String> prefix2uri)
DifferenceEngine
Comparison.Detail#getXPath
.
Without a namespace context (or with an empty context) the XPath expressions will only use local names for elements and attributes.
setNamespaceContext
in interface DifferenceEngine
protected Map<String,String> getNamespaceContext()
public void setAttributeFilter(Predicate<Attr> af)
DifferenceEngine
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
.
setAttributeFilter
in interface DifferenceEngine
protected Predicate<Attr> getAttributeFilter()
public void setNodeFilter(Predicate<Node> nf)
DifferenceEngine
Only nodes for which the predicate returns true are part of the comparison. By default nodes that are not document types are considered.
setNodeFilter
in interface DifferenceEngine
protected Predicate<Node> getNodeFilter()
protected final AbstractDifferenceEngine.ComparisonState compare(Comparison comp)
protected static String getXPath(XPathContext ctx)
protected static String getParentXPath(XPathContext ctx)
Copyright © 2001–2017 XMLUnit. All rights reserved.