Class CompareTool.CompareResult

  • Enclosing class:
    CompareTool

    public static class CompareTool.CompareResult
    extends java.lang.Object
    Class containing results of the comparison of two documents.
    • Constructor Summary

      Constructors 
      Constructor Description
      CompareResult​(int messageLimit)
      Creates new empty instance of CompareResult with given limit of difference messages.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addError​(ObjectPath path, java.lang.String message)
      Adds an error message for the ObjectPath.
      java.util.Map<ObjectPath,​java.lang.String> getDifferences()
      Returns map with ObjectPath as keys and difference descriptions as values.
      int getErrorCount()
      Returns number of differences between two documents detected during comparison.
      java.lang.String getReport()
      Converts this CompareResult into text form.
      protected boolean isMessageLimitReached()
      Checks whether maximum number of difference messages to be handled by this CompareResult is reached.
      boolean isOk()
      Verifies if documents are considered equal after comparison.
      void writeReportToXml​(java.io.OutputStream stream)
      Converts this CompareResult into xml form.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • differences

        protected java.util.Map<ObjectPath,​java.lang.String> differences
      • messageLimit

        protected int messageLimit
    • Constructor Detail

      • 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 Detail

      • 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 java.lang.String getReport()
        Converts this CompareResult into text form.
        Returns:
        text report on the differences between two documents.
      • getDifferences

        public java.util.Map<ObjectPath,​java.lang.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​(java.io.OutputStream stream)
                              throws javax.xml.parsers.ParserConfigurationException,
                                     javax.xml.transform.TransformerException
        Converts this CompareResult into xml form.
        Parameters:
        stream - output stream to which xml report will be written.
        Throws:
        javax.xml.parsers.ParserConfigurationException - if a XML DocumentBuilder cannot be created which satisfies the configuration requested.
        javax.xml.transform.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,
                                java.lang.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