Package com.itextpdf.kernel.utils
Class CompareTool.CompareResult
java.lang.Object
com.itextpdf.kernel.utils.CompareTool.CompareResult
- Enclosing class:
- CompareTool
Class containing results of the comparison of two documents.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCompareResult(int messageLimit) Creates new empty instance of CompareResult with given limit of difference messages. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddError(ObjectPath path, String message) Adds an error message for theObjectPath.Returns map withObjectPathas keys and difference descriptions as values.intReturns number of differences between two documents detected during comparison.Converts this CompareResult into text form.protected booleanChecks whether maximum number of difference messages to be handled by this CompareResult is reached.booleanisOk()Verifies if documents are considered equal after comparison.voidwriteReportToXml(OutputStream stream) Converts this CompareResult into xml form.
-
Field Details
-
differences
-
messageLimit
protected int messageLimit
-
-
Constructor Details
-
CompareResult
public CompareResult(int messageLimit) Creates new empty instance of CompareResult with given limit of difference messages.- Parameters:
-
messageLimit- maximum number of difference messages to be handled by this CompareResult.
-
-
Method Details
-
isOk
public boolean isOk()Verifies if documents are considered equal after comparison.- Returns:
- true if documents are equal, false otherwise.
-
getErrorCount
public int getErrorCount()Returns number of differences between two documents detected during comparison.- Returns:
- number of differences.
-
getReport
Converts this CompareResult into text form.- Returns:
- text report on the differences between two documents.
-
getDifferences
Returns map withObjectPathas keys and difference descriptions as values.- Returns:
- differences map which could be used to find in the document the objects that are different.
-
writeReportToXml
public void writeReportToXml(OutputStream stream) throws ParserConfigurationException, TransformerException Converts this CompareResult into xml form.- Parameters:
-
stream- output stream to which xml report will be written. - Throws:
-
ParserConfigurationException- if a XML DocumentBuilder cannot be created which satisfies the configuration requested. -
TransformerException- if it is not possible to create an XML Transformer instance or an unrecoverable error occurs during the course of the transformation.
-
isMessageLimitReached
protected boolean isMessageLimitReached()Checks whether maximum number of difference messages to be handled by this CompareResult is reached.- Returns:
- true if limit of difference messages is reached, false otherwise.
-
addError
Adds an error message for theObjectPath.- Parameters:
-
path-ObjectPathfor the two corresponding objects in the compared documents -
message- an error message
-