public class Diff extends Object implements DifferenceListener, ComparisonController
appendMessage
or toString
methods. NB: When comparing documents, the
comparison is halted as soon as the status (identical / similar / different)
is known with certainty. For a list of all differences between the documents
an instance of the DetailedDiff class
can be used
instead.RETURN_ACCEPT_DIFFERENCE, RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL, RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR, RETURN_UPGRADE_DIFFERENCE_NODES_DIFFERENT
Modifier | Constructor and Description |
---|---|
protected |
Diff(Diff prototype)
Construct a Diff from a prototypical instance.
|
|
Diff(Document controlDoc,
Document testDoc)
Construct a Diff that compares the XML in two Documents
|
|
Diff(Document controlDoc,
Document testDoc,
DifferenceEngineContract comparator)
Construct a Diff that compares the XML in two Documents using a specific
DifferenceEngine
|
|
Diff(Document controlDoc,
Document testDoc,
DifferenceEngineContract comparator,
ElementQualifier elementQualifier)
Construct a Diff that compares the XML in two Documents using a specific
DifferenceEngine and ElementQualifier
|
|
Diff(DOMSource control,
DOMSource test)
Construct a Diff that compares the XML in two JAXP DOMSources
|
|
Diff(InputSource control,
InputSource test)
Construct a Diff that compares the XML read from two JAXP InputSources
|
|
Diff(Reader control,
Reader test)
Construct a Diff that compares the XML read from two Readers
|
|
Diff(String control,
String test)
Construct a Diff that compares the XML in two Strings
|
|
Diff(String control,
Transform testTransform)
Construct a Diff that compares the XML in a control Document against the
result of a transformation
|
Modifier and Type | Method and Description |
---|---|
StringBuffer |
appendMessage(StringBuffer toAppendTo)
Append the message from the result of this Diff instance to a specified
StringBuffer
|
protected void |
compare()
Top of the recursive comparison execution tree
|
int |
differenceFound(Difference difference)
DifferenceListener implementation.
|
int |
evaluate(Difference difference) |
boolean |
haltComparison(Difference afterDifference)
ComparisonController implementation.
|
boolean |
identical()
Return the result of a comparison.
|
void |
overrideDifferenceListener(DifferenceListener delegate)
Override the
DifferenceListener used to determine how
to handle differences that are found. |
void |
overrideElementQualifier(ElementQualifier delegate)
Override the
ElementQualifier used to determine which
control and test nodes are comparable for this difference comparison. |
void |
overrideMatchTracker(MatchTracker delegate)
Override the
MatchTracker used to track
successfully matched nodes. |
boolean |
similar()
Return the result of a comparison.
|
void |
skippedComparison(Node control,
Node test)
DifferenceListener implementation.
|
String |
toString()
Get the result of this Diff instance as a String
Note: This method will perform the comparison and
cache the result if it hasn't been performed already.
|
public Diff(String control, String test) throws SAXException, IOException
SAXException
IOException
public Diff(Reader control, Reader test) throws SAXException, IOException
SAXException
IOException
public Diff(Document controlDoc, Document testDoc)
public Diff(String control, Transform testTransform) throws IOException, TransformerException, SAXException
public Diff(InputSource control, InputSource test) throws SAXException, IOException
SAXException
IOException
public Diff(DOMSource control, DOMSource test)
public Diff(Document controlDoc, Document testDoc, DifferenceEngineContract comparator)
public Diff(Document controlDoc, Document testDoc, DifferenceEngineContract comparator, ElementQualifier elementQualifier)
protected Diff(Diff prototype)
prototype
- a prototypical instanceprotected final void compare()
public boolean similar()
public boolean identical()
public int differenceFound(Difference difference)
overrideDifferenceListener
method has been called then the interpretation of the difference
will be delegated.differenceFound
in interface DifferenceListener
difference
- public int evaluate(Difference difference)
public void skippedComparison(Node control, Node test)
overrideDifferenceListener
method has been called then the call will be delegated
otherwise a message is printed to System.err
.skippedComparison
in interface DifferenceListener
control
- test
- DifferenceEngine
public boolean haltComparison(Difference afterDifference)
haltComparison
in interface ComparisonController
afterDifference
- Difference.isRecoverable()
public StringBuffer appendMessage(StringBuffer toAppendTo)
toAppendTo
- public String toString()
Note: This method will perform the comparison and cache the result if it hasn't been performed already. Any configuration changes made after calling this method will be ignored.
public void overrideDifferenceListener(DifferenceListener delegate)
DifferenceListener
used to determine how
to handle differences that are found.delegate
- the DifferenceListener instance to delegate handling to.public void overrideElementQualifier(ElementQualifier delegate)
ElementQualifier
used to determine which
control and test nodes are comparable for this difference comparison.delegate
- the ElementQualifier instance to delegate to.public void overrideMatchTracker(MatchTracker delegate)
MatchTracker
used to track
successfully matched nodes.delegate
- the MatchTracker instance to delegate handling to.Copyright © 2001–2017 XMLUnit. All rights reserved.