public class Diff extends java.lang.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(org.w3c.dom.Document controlDoc,
org.w3c.dom.Document testDoc)
Construct a Diff that compares the XML in two Documents
|
|
Diff(org.w3c.dom.Document controlDoc,
org.w3c.dom.Document testDoc,
DifferenceEngine comparator)
Construct a Diff that compares the XML in two Documents using a specific
DifferenceEngine
|
|
Diff(org.w3c.dom.Document controlDoc,
org.w3c.dom.Document testDoc,
DifferenceEngine comparator,
ElementQualifier elementQualifier)
Construct a Diff that compares the XML in two Documents using a specific
DifferenceEngine and ElementQualifier
|
|
Diff(javax.xml.transform.dom.DOMSource control,
javax.xml.transform.dom.DOMSource test)
Construct a Diff that compares the XML in two JAXP DOMSources
|
|
Diff(org.xml.sax.InputSource control,
org.xml.sax.InputSource test)
Construct a Diff that compares the XML read from two JAXP InputSources
|
|
Diff(java.io.Reader control,
java.io.Reader test)
Construct a Diff that compares the XML read from two Readers
|
|
Diff(java.lang.String control,
java.lang.String test)
Construct a Diff that compares the XML in two Strings
|
|
Diff(java.lang.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 |
|---|---|
java.lang.StringBuffer |
appendMessage(java.lang.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.
|
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(org.w3c.dom.Node control,
org.w3c.dom.Node test)
DifferenceListener implementation.
|
java.lang.String |
toString()
Get the result of this Diff instance as a String
|
public Diff(java.lang.String control,
java.lang.String test)
throws org.xml.sax.SAXException,
java.io.IOException
org.xml.sax.SAXExceptionjava.io.IOExceptionpublic Diff(java.io.Reader control,
java.io.Reader test)
throws org.xml.sax.SAXException,
java.io.IOException
org.xml.sax.SAXExceptionjava.io.IOExceptionpublic Diff(org.w3c.dom.Document controlDoc,
org.w3c.dom.Document testDoc)
public Diff(java.lang.String control,
Transform testTransform)
throws java.io.IOException,
javax.xml.transform.TransformerException,
org.xml.sax.SAXException
java.io.IOExceptionjavax.xml.transform.TransformerExceptionorg.xml.sax.SAXExceptionpublic Diff(org.xml.sax.InputSource control,
org.xml.sax.InputSource test)
throws org.xml.sax.SAXException,
java.io.IOException
org.xml.sax.SAXExceptionjava.io.IOExceptionpublic Diff(javax.xml.transform.dom.DOMSource control,
javax.xml.transform.dom.DOMSource test)
public Diff(org.w3c.dom.Document controlDoc,
org.w3c.dom.Document testDoc,
DifferenceEngine comparator)
public Diff(org.w3c.dom.Document controlDoc,
org.w3c.dom.Document testDoc,
DifferenceEngine 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 DifferenceListenerdifference - public void skippedComparison(org.w3c.dom.Node control,
org.w3c.dom.Node test)
overrideDifferenceListener
method has been called then the call will be delegated
otherwise a message is printed to System.err.skippedComparison in interface DifferenceListenercontrol - test - DifferenceEnginepublic boolean haltComparison(Difference afterDifference)
haltComparison in interface ComparisonControllerafterDifference - Difference.isRecoverable()public java.lang.StringBuffer appendMessage(java.lang.StringBuffer toAppendTo)
toAppendTo - public java.lang.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.toString in class java.lang.Objectpublic 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.