public class XmlUtils
extends java.lang.Object
diffToDoc(...)
methods perform a diff of two inputs and return the result as Document
, containing a series of diff operations.
diff(...)
methods perform a diff of two inputs and return the result as a list of DiffOp
objects, each representing a diff operation. This list is returned via a user provided object that implements the DiffOpReceiver
interface.
hash(...)
methods calculate a hash value for the input. These methods return a hash value that, with a high probability, uniquely represents the input. However, hash function collisions are possible, so it is possible for different inputs to have the same hash value.
We also provide equal(...)
methods to verify that two inputs are truly identical by walking the two inputs in lockstep.
Options
has various options that control how the input is processed by XmlUtils
.
Constructor and Description |
---|
XmlUtils()
Constructs a new
XmlUtils object. |
Modifier and Type | Method and Description |
---|---|
void |
diff(java.io.File file1, java.io.File file2, DiffOpReceiver diffOpReceiver, Options opt)
Diffs two input XMLs, stored in the input files.
|
void |
diff(InputSource inSrc1, InputSource inSrc2, DiffOpReceiver diffOpReceiver, Options opt)
Diffs two input XMLs, stored in the
InputSource parameters. |
void |
diff(Node dom1, Node dom2, DiffOpReceiver diffOpReceiver, Options opt)
Diffs two input XMLs, represented by DOM nodes.
|
Document |
diffToDoc(java.io.File file1, java.io.File file2, Options opt)
Diffs two input XMLs, stored in the input files.
|
Document |
diffToDoc(InputSource inSrc1, InputSource inSrc2, Options opt)
Diffs two input XMLs, stored in the
InputSource parameters. |
Document |
diffToDoc(Node dom1, Node dom2, Options opt)
Diffs two input XMLs, represented by DOM nodes.
|
boolean |
equal(java.io.File file1, java.io.File file2, Options opt)
Perform a lockstep comparison of two XML inputs and return a boolean indicating whether the two inputs are equal or not.
|
boolean |
equal(InputSource inSrc1, InputSource inSrc2, Options opt)
Perform a lockstep comparison of two XML inputs and return a boolean indicating whether the two inputs are equal or not.
|
boolean |
equal(Node dom1, Node dom2, Options opt)
Perform a lockstep comparison of two XML inputs and return a boolean indicating whether the two inputs are equal or not.
|
byte[] |
hash(java.io.File file, Options opt)
Compute a hash value that, with a high probability, uniquely identifies the input XML, stored in the input
File . |
byte[] |
hash(InputSource inSrc, Options opt)
Compute a hash value that, with a high probability, uniquely identifies the input XML, given as an
InputSource . |
byte[] |
hash(Node node, Options opt)
Compute a hash value that, with a high probability, uniquely identifies the input XML, represented as a
Node . |
static java.lang.String |
nodeToString(Node node, boolean withDecl)
Helper method for printing out the DOM
Node . |
public Document diffToDoc(Node dom1, Node dom2, Options opt) throws java.lang.Exception
dom1
- first input nodedom2
- second input nodeopt
- options used during the comparison. Default option settings will be used if this parameter is null
Document
containing the diffjava.lang.Exception
- if there is an error during the comparison of the two inputspublic Document diffToDoc(java.io.File file1, java.io.File file2, Options opt) throws java.lang.Exception
file1
- first input XML filefile2
- second input XML fileopt
- options used during the comparison. Default option settings will be used if this parameter is null
Document
containing the diffjava.lang.Exception
- if there is an error during the comparison of the two inputs, or during the parsing of the input filespublic Document diffToDoc(InputSource inSrc1, InputSource inSrc2, Options opt) throws java.lang.Exception
InputSource
parameters.inSrc1
- first input XML as InputSource
inSrc2
- second input XML as InputSource
opt
- options used during the comparison. Default option settings will be used if this parameter is null
Document
containing the diffjava.lang.Exception
- if there is an error during the comparison of the two inputs, or during the parsing of the input sourcespublic void diff(Node dom1, Node dom2, DiffOpReceiver diffOpReceiver, Options opt) throws java.lang.Exception
DiffOp
objects, to the DiffOpReceiver
object that is passed as a parameter to this method.dom1
- first input nodedom2
- second input nodediffOpReceiver
- an object implementing the DiffOpReceiver
interfaceopt
- options used during the comparison. Default option settings will be used if this parameter is null
this parameter is null.java.lang.Exception
- if there is an error during the comparison of the two inputspublic void diff(java.io.File file1, java.io.File file2, DiffOpReceiver diffOpReceiver, Options opt) throws java.lang.Exception
DiffOp
objects, to the DiffOpReceiver
object that is passed as a parameter to this method.file1
- first input XML filefile2
- second input XML filediffOpReceiver
- an object implementing the DiffOpReceiver
interfaceopt
- options used during the comparison. Default option settings will be used if this parameter is null
java.lang.Exception
- if there is an error during the comparison of the two inputs, or during the parsing of the input filespublic void diff(InputSource inSrc1, InputSource inSrc2, DiffOpReceiver diffOpReceiver, Options opt) throws java.lang.Exception
InputSource
parameters. The result is returned programmatically as a list of DiffOp
objects, to the DiffOpReceiver
object that is passed as a parameter to this method.inSrc1
- first input XML as InputSource
inSrc2
- second input XML as InputSource
diffOpReceiver
- an object implementing the DiffOpReceiver
interfaceopt
- options used during the comparison. Default option settings will be used if this parameter is null
java.lang.Exception
- if there is an error during the comparison of the two inputs, or during the parsing of the input sourcespublic boolean equal(Node dom1, Node dom2, Options opt) throws java.lang.Exception
dom1
- first input nodedom2
- second input nodeopt
- options used during the comparison. Default option settings will be used if this parameter is null
Document
containing the diffjava.lang.Exception
- if there is an error during the comparison of the two inputspublic boolean equal(java.io.File file1, java.io.File file2, Options opt) throws java.lang.Exception
file1
- first input XML filefile2
- second input XML fileopt
- options used during the comparison. Default option settings will be used if this parameter is null
Document
containing the diffjava.lang.Exception
- if there is an error during the comparison of the two inputs, or during the parsing of the input filespublic boolean equal(InputSource inSrc1, InputSource inSrc2, Options opt) throws java.lang.Exception
inSrc1
- first input XML as InputSource
inSrc2
- second input XML as InputSource
opt
- options used during the comparison. Default option settings will be used if this parameter is null
Document
containing the diffjava.lang.Exception
- if there is an error during the comparison of the two inputs, or during the parsing of the input sourcespublic byte[] hash(java.io.File file, Options opt) throws java.lang.Exception
File
.file
- File
containing the input XMLopt
- options used during the comparison. Default option settings will be used if this parameter is null
byte[]
java.lang.Exception
- if there is an error during the hash calculation, or parsing of the inputpublic byte[] hash(InputSource inSrc, Options opt) throws java.lang.Exception
InputSource
.inSrc
- InputSource
representing the input XMLopt
- options used during the comparison. Default option settings will be used if this parameter is null
byte[]
java.lang.Exception
- if there is an error during the hash calculation, or parsing of the inputpublic byte[] hash(Node node, Options opt) throws java.lang.Exception
Node
.node
- input nodeopt
- options used during the comparison. Default option settings will be used if this parameter is null
byte[]
java.lang.Exception
- if there is an error during the hash calculationpublic static java.lang.String nodeToString(Node node, boolean withDecl) throws java.lang.Exception
Node
.node
- node to print outString
containg the node representationjava.lang.Exception
- if there's an error outputting the Node
to String