public class DocumentComparator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.io.PrintStream |
m_differencePrint
Print stream for reporting differences.
|
protected XmlPullParser |
m_parserA
Parser for first document.
|
protected XmlPullParser |
m_parserB
Parser for second document.
|
protected boolean |
m_schemaCompare
Compare using schema data value adjustments flag.
|
Constructor and Description |
---|
DocumentComparator(java.io.PrintStream print)
Constructor.
|
DocumentComparator(java.io.PrintStream print,
boolean schema)
Constructor with schema adjustments flag specified.
|
Modifier and Type | Method and Description |
---|---|
protected static java.lang.String |
buildName(java.lang.String ns,
java.lang.String name)
Build name string.
|
protected static java.lang.String |
buildPositionString(XmlPullParser parser)
Build parse input position description.
|
boolean |
compare(java.io.Reader rdra,
java.io.Reader rdrb)
Compares a pair of documents by reading them in parallel from a pair of
parsers.
|
protected boolean |
equalValues(java.lang.String texta,
java.lang.String textb)
Check for equal values.
|
private static boolean |
isSchemaLocation(java.lang.String name,
java.lang.String ns)
Check if a name/namespace pair matches a schema namespace location
attribute.
|
protected boolean |
matchAttributes()
Verifies that the attributes on the current start tags match.
|
protected boolean |
matchNames()
Verifies that the current start or end tag names match.
|
protected boolean |
matchText(java.lang.String texta,
java.lang.String textb,
java.lang.String lead)
Check if two text strings match, ignoring leading and trailing spaces.
|
private static java.lang.String |
normalizeDecimal(java.lang.String text)
Normalize a decimal value for comparison.
|
protected void |
printError(java.lang.String msg)
Prints error description text.
|
protected XmlPullParser m_parserA
protected XmlPullParser m_parserB
protected java.io.PrintStream m_differencePrint
protected boolean m_schemaCompare
public DocumentComparator(java.io.PrintStream print, boolean schema) throws XmlPullParserException
print
- print stream for reporting differencesschema
- use schema adjustments in comparisons flagXmlPullParserException
- on error creating parserspublic DocumentComparator(java.io.PrintStream print) throws XmlPullParserException
print
- print stream for reporting differencesXmlPullParserException
- on error creating parsersprotected static java.lang.String buildPositionString(XmlPullParser parser)
parser
- for which to build descriptionprotected static java.lang.String buildName(java.lang.String ns, java.lang.String name)
ns
- namespace URIname
- local nameprotected void printError(java.lang.String msg)
msg
- error message textprivate static boolean isSchemaLocation(java.lang.String name, java.lang.String ns)
name
- ns
- true
if a schema namespace location,
false
if notprivate static java.lang.String normalizeDecimal(java.lang.String text)
text
- protected boolean equalValues(java.lang.String texta, java.lang.String textb)
texta
- textb
- true
if values match, false
if notprotected boolean matchAttributes()
true
if the attributes match, false
if
notprotected boolean matchText(java.lang.String texta, java.lang.String textb, java.lang.String lead)
texta
- textb
- lead
- error text leadtrue
if the texts match, false
if
notprotected boolean matchNames()
true
if the names match, false
if notpublic boolean compare(java.io.Reader rdra, java.io.Reader rdrb)
rdra
- reader for first document to be comparedrdrb
- reader for second document to be comparedtrue
if the documents are the same,
false
if they're different