Package org.daisy.braille.tools
Class FileCompare
- java.lang.Object
-
- org.daisy.braille.tools.FileCompare
-
public class FileCompare extends java.lang.ObjectProvides functionality to check if files are equal. Both binary and a looser XML-file compare are provided.- Author:
- Joel HÃ¥kansson
-
-
Constructor Summary
Constructors Constructor Description FileCompare()Creates a new FileCompare objectFileCompare(boolean keepTempFiles)Creates a new FileCompare object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancompareBinary(java.io.InputStream f1, java.io.InputStream f2)Compares the input streams binary.booleancompareXML(java.io.InputStream f1, java.io.InputStream f2)Compare the input streams as XML.java.io.FilegetFileOne()Gets the intermediary file created from the first argument of the latest call to compareXML (as base for the post normalization binary compare).java.io.FilegetFileTwo()Gets the intermediary file created from the second argument of the latest call to compareXML (as base for the post normalization binary compare).intgetPos()Gets the byte position where the latest call to compareBinary or compareXML failed, or -1 if compare was successful
-
-
-
Method Detail
-
compareXML
public boolean compareXML(java.io.InputStream f1, java.io.InputStream f2) throws java.io.IOException, javax.xml.transform.TransformerExceptionCompare 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:
java.io.IOException- if IO failsjavax.xml.transform.TransformerException- if transformation fails
-
getFileOne
public java.io.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).- Returns:
- returns the first file
- Throws:
java.lang.IllegalStateException- if temporary files are not kept or if compareXML has not been called.
-
getFileTwo
public java.io.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).- Returns:
- returns the second file
- Throws:
java.lang.IllegalStateException- if temporary files are not kept or if compareXML has not been called.
-
getPos
public int getPos()
Gets the byte position where the latest call to compareBinary or compareXML failed, or -1 if compare was successful- Returns:
- returns the byte position
-
compareBinary
public boolean compareBinary(java.io.InputStream f1, java.io.InputStream f2) throws java.io.IOExceptionCompares the input streams binary.- Parameters:
f1- the first input streamf2- the second input stream- Returns:
- returns true if the streams are equal, false otherwise
- Throws:
java.io.IOException- if IO fails
-
-