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
A comparison state that indicates the comparison should be stopped.
|
protected class |
AbstractDifferenceEngine.OngoingComparisonState
A comparison state that indicates the comparison should perform further steps.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDifferenceEngine()
Protected default constructor.
|
| 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 attribute filter.
|
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 nod filter.
|
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, waitcompareprotected AbstractDifferenceEngine()
public void addComparisonListener(ComparisonListener l)
DifferenceEngineaddComparisonListener in interface DifferenceEnginel - the listener to addpublic void addMatchListener(ComparisonListener l)
DifferenceEngineComparisonResult.EQUAL.addMatchListener in interface DifferenceEnginel - the listener to addpublic void addDifferenceListener(ComparisonListener l)
DifferenceEngineComparisonResult.EQUAL.addDifferenceListener in interface DifferenceEnginel - the listener to addpublic void setNodeMatcher(NodeMatcher n)
DifferenceEnginesetNodeMatcher in interface DifferenceEnginen - the strategy to useprotected NodeMatcher getNodeMatcher()
public void setDifferenceEvaluator(DifferenceEvaluator e)
DifferenceEnginesetDifferenceEvaluator in interface DifferenceEnginee - the evaluator to useprotected DifferenceEvaluator getDifferenceEvaluator()
public void setComparisonController(ComparisonController c)
DifferenceEnginesetComparisonController in interface DifferenceEnginec - the controller to useprotected ComparisonController getComparisonController()
public void setNamespaceContext(Map<String,String> prefix2uri)
DifferenceEngineComparison.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 DifferenceEngineprefix2uri - maps from prefix to namespace URI.protected Map<String,String> getNamespaceContext()
public void setAttributeFilter(Predicate<Attr> af)
DifferenceEngineOnly 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 DifferenceEngineaf - the strategy to useprotected Predicate<Attr> getAttributeFilter()
public void setNodeFilter(Predicate<Node> nf)
DifferenceEngineOnly 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 DifferenceEnginenf - the strategy to useprotected Predicate<Node> getNodeFilter()
protected final AbstractDifferenceEngine.ComparisonState compare(Comparison comp)
comp - the comparison to performprotected static String getXPath(XPathContext ctx)
ctx - the XPathContextprotected static String getParentXPath(XPathContext ctx)
ctx - the XPathContextCopyright © 2001–2024 XMLUnit. All rights reserved.