Package org.daisy.braille.utils.pef
Class XMLFileCompare
- java.lang.Object
-
- org.daisy.braille.utils.pef.FileCompare
-
- org.daisy.braille.utils.pef.XMLFileCompare
-
public class XMLFileCompare extends FileCompare
Provides functionality to check if files are equal. Both binary and a looser XML-file compare are provided.
-
-
Constructor Summary
Constructors Constructor Description XMLFileCompare(TransformerFactory factory)
Creates a new FileCompare object.XMLFileCompare(TransformerFactory factory, boolean keepTempFiles)
Creates a new FileCompare object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
compareXML(InputStream f1, InputStream f2)
Compare the input streams as XML.File
getFileOne()
Gets the intermediary file created from the first argument of the latest call to compareXML (as base for the post normalization binary compare).File
getFileTwo()
Gets the intermediary file created from the second argument of the latest call to compareXML (as base for the post normalization binary compare).-
Methods inherited from class org.daisy.braille.utils.pef.FileCompare
compareBinary, getPos
-
-
-
-
Constructor Detail
-
XMLFileCompare
public XMLFileCompare(TransformerFactory factory)
Creates a new FileCompare object.- Parameters:
factory
- the transformer factory
-
XMLFileCompare
public XMLFileCompare(TransformerFactory factory, boolean keepTempFiles)
Creates a new FileCompare object.- Parameters:
factory
- the transformer factorykeepTempFiles
- true if temporary files should be kept, false otherwise
-
-
Method Detail
-
getFileOne
public File getFileOne()
Gets the intermediary file created from the first argument of the latest call to compareXML (as base for the post normalization binary compare).- Overrides:
getFileOne
in classFileCompare
- Returns:
- returns the first file
- Throws:
IllegalStateException
- if temporary files are not kept or if compareXML has not been called.
-
getFileTwo
public File getFileTwo()
Gets the intermediary file created from the second argument of the latest call to compareXML (as base for the post normalization binary compare).- Overrides:
getFileTwo
in classFileCompare
- Returns:
- returns the second file
- Throws:
IllegalStateException
- if temporary files are not kept or if compareXML has not been called.
-
compareXML
public boolean compareXML(InputStream f1, InputStream f2) throws IOException, TransformerException
Compare the input streams as XML. THe files are considered equal if they are binary equal once transformed through the same transparent XSLT (whitespace is normalized on text nodes) using the same transformer implementation.- Parameters:
f1
- the first input streamf2
- the second input stream- Returns:
- returns true if the streams are equal, false otherwise
- Throws:
IOException
- if IO failsTransformerException
- if transformation fails
-
-