Class CompareTool.CompareResult

java.lang.Object
com.itextpdf.kernel.utils.CompareTool.CompareResult
Enclosing class:
CompareTool

public static class CompareTool.CompareResult extends Object
Class containing results of the comparison of two documents.
  • Field Details

    • differences

      protected Map<ObjectPath,String> 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

      public String getReport()
      Converts this CompareResult into text form.
      Returns:
      text report on the differences between two documents.
    • getDifferences

      public Map<ObjectPath,String> getDifferences()
      Returns map with ObjectPath as 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

      protected void addError (ObjectPath path, String message)
      Adds an error message for the ObjectPath.
      Parameters:
      path - ObjectPath for the two corresponding objects in the compared documents
      message - an error message