Class Diff

  • Direct Known Subclasses:
    RegularDiff

    public abstract class Diff
    extends Object
    The Class Diff, the central object if it comes to the comparison of XML documents. All methods might return null if not available in a certain case.
    Author:
    Martin Scharm
    • Field Detail

      • ALLOW_DIFFERENT_IDS

        public static final boolean ALLOW_DIFFERENT_IDS
        Are mappings of nodes with different ids allowed? At the first glimpse that might sound stupid, but ids are generally arbitrary and say nothing valuable about the entities. they just need to be unique.. Look at the following two species:
         <species id="s1" name="glucose" initial_concentration="0.1" compartment="cell" initialAmount="1" hasOnlySubstanceUnits="true" boundaryCondition="true" />
         <species id="species1" name="glucose" initial_concentration="0.1" compartment="cell" initialAmount="1" hasOnlySubstanceUnits="true" boundaryCondition="true" />
         
        The id attribute might just be assigned by two different tools, everything else is the same. Should we map these entities? By default this is true.
        See Also:
        DocumentNode.getAttributeDistance(DocumentNode, boolean, boolean, boolean), Constant Field Values
      • CARE_ABOUT_NAMES

        public static final boolean CARE_ABOUT_NAMES
        Do we care about names? Should we treat names differently? They often provide more information than other attributes.
        See Also:
        DocumentNode.getAttributeDistance(DocumentNode, boolean, boolean, boolean), Constant Field Values
      • STRICTER_NAMES

        public static final boolean STRICTER_NAMES
        Should we handle names very strictly? Go for this option if you're sure that you're names are very similar.
        See Also:
        DocumentNode.getAttributeDistance(DocumentNode, boolean, boolean, boolean), Constant Field Values
      • treeA

        protected de.unirostock.sems.xmlutils.ds.TreeDocument treeA
        The tree corresponding to the former version.
      • treeB

        protected de.unirostock.sems.xmlutils.ds.TreeDocument treeB
        The tree corresponding to the later version.
    • Constructor Detail

      • Diff

        public Diff​(File fileA,
                    File fileB)
             throws de.unirostock.sems.xmlutils.exception.XmlDocumentParseException,
                    IOException,
                    org.jdom2.JDOMException
        Instantiates a new diff object in order to compare two documents stored in files fileA and fileB.
        Parameters:
        fileA - the file containing the former version
        fileB - the file containing the later version
        Throws:
        de.unirostock.sems.xmlutils.exception.XmlDocumentParseException - the xml document parse exception
        IOException - Signals that an I/O exception has occurred.
        org.jdom2.JDOMException - the jDOM exception
      • Diff

        public Diff​(String docA,
                    String docB)
             throws de.unirostock.sems.xmlutils.exception.XmlDocumentParseException,
                    IOException,
                    org.jdom2.JDOMException
        Instantiates a new diff object in order to compare two documents stored in strings docA and docB.
        Parameters:
        docA - the former version
        docB - the later version
        Throws:
        de.unirostock.sems.xmlutils.exception.XmlDocumentParseException - the xml document parse exception
        IOException - Signals that an I/O exception has occurred.
        org.jdom2.JDOMException - the jDOM exception
      • Diff

        public Diff​(de.unirostock.sems.xmlutils.ds.TreeDocument treeA,
                    de.unirostock.sems.xmlutils.ds.TreeDocument treeB)
        Instantiates a new diff object in order to compare two tree documents.
        Parameters:
        treeA - the former version of the tree
        treeB - the later version of the tree
      • Diff

        public Diff​(File fileA,
                    File fileB,
                    DiffAnnotator diffAnnotator)
             throws de.unirostock.sems.xmlutils.exception.XmlDocumentParseException,
                    IOException,
                    org.jdom2.JDOMException
        Instantiates a new diff object in order to compare two documents stored in files fileA and fileB.
        Parameters:
        fileA - the file containing the former version
        fileB - the file containing the later version
        diffAnnotator - the annotator for identified changes
        Throws:
        de.unirostock.sems.xmlutils.exception.XmlDocumentParseException - the xml document parse exception
        IOException - Signals that an I/O exception has occurred.
        org.jdom2.JDOMException - the jDOM exception
      • Diff

        public Diff​(String docA,
                    String docB,
                    DiffAnnotator diffAnnotator)
             throws de.unirostock.sems.xmlutils.exception.XmlDocumentParseException,
                    IOException,
                    org.jdom2.JDOMException
        Instantiates a new diff object in order to compare two documents stored in strings docA and docB.
        Parameters:
        docA - the former version
        docB - the later version
        diffAnnotator - the annotator for identified changes
        Throws:
        de.unirostock.sems.xmlutils.exception.XmlDocumentParseException - the xml document parse exception
        IOException - Signals that an I/O exception has occurred.
        org.jdom2.JDOMException - the jDOM exception
      • Diff

        public Diff​(de.unirostock.sems.xmlutils.ds.TreeDocument treeA,
                    de.unirostock.sems.xmlutils.ds.TreeDocument treeB,
                    DiffAnnotator diffAnnotator)
        Instantiates a new diff object in order to compare two tree documents.
        Parameters:
        treeA - the former version of the tree
        treeB - the later version of the tree
        diffAnnotator - the annotator for identified changes
    • Method Detail

      • getDiff

        public String getDiff()
        Gets the diff as a string, encoded in XML.
        Returns:
        the diff
      • getDiff

        public String getDiff​(boolean inclAnnotations)
        Gets the differences encoded in an XML string
        Parameters:
        inclAnnotations - include annotations in the XML patch
        Returns:
        the diff
      • getPatch

        public Patch getPatch()
        Gets the patch object.
        Returns:
        the patch
      • mapTrees

        public abstract boolean mapTrees​(boolean allowDifferentIds,
                                         boolean careAboutNames,
                                         boolean stricterNames)
                                  throws Exception
        Map both trees. This method let's you decide whether
        • mapped entities may have different ids,
        • we specially treat name attributes,
        • we handle names very strictly.
        For default values see ALLOW_DIFFERENT_IDS, CARE_ABOUT_NAMES, and STRICTER_NAMES.
        Parameters:
        allowDifferentIds - are mapped entities allowed to have different ids?
        careAboutNames - should we care about names?
        stricterNames - should we handle names very strictly?
        Returns:
        true, if successful mapped
        Throws:
        Exception - the exception
      • mapTrees

        public boolean mapTrees()
                         throws Exception
        Map both trees. This method by default allows different ids, better cares about names (that means, different names are worse than different concentrations) but doesn't handle the names too strict. Compare DocumentNode.getAttributeDistance(DocumentNode, boolean, boolean, boolean).
        Returns:
        true, if successful
        Throws:
        Exception - the exception
      • getReactionsGraph

        public abstract Object getReactionsGraph​(GraphTranslator gt)
                                          throws Exception
        Returns the graph of the reaction network providing an own graph translator. Might return null if not available.
        Parameters:
        gt - the graph translator
        Returns:
        the reaction network or null if not available
        Throws:
        Exception - the exception
      • getHierarchyGraph

        public abstract Object getHierarchyGraph​(GraphTranslator gt)
                                          throws Exception
        Returns the component's hierarchy graph providing an own graph translator. Might return null if not available.
        Parameters:
        gt - the graph translator
        Returns:
        the hierarchy graph or null if not available
        Throws:
        Exception - the exception
      • getCRNGraphML

        @Deprecated
        public String getCRNGraphML()
                             throws Exception
        Deprecated.
        As of 1.3.3 replaced by getReactionsGraphML()
        Returns the graph of the chemical reaction network encoded in GraphML. Might return null if not available.
        Returns:
        the chemical reaction network or null if not available
        Throws:
        Exception - the exception
      • getReactionsGraphML

        public abstract String getReactionsGraphML()
                                            throws Exception
        Returns the graph of the reaction network encoded in GraphML. Might return null if not available.
        Returns:
        the reaction network or null if not available
        Throws:
        Exception - the exception
      • getHierarchyGraphML

        public abstract String getHierarchyGraphML()
                                            throws Exception
        Returns the component's hierarchy graph encoded in GraphML. Might return null if not available.
        Returns:
        the hierarchy graph or null if not available
        Throws:
        Exception - the exception
      • getCRNDotGraph

        @Deprecated
        public String getCRNDotGraph()
                              throws Exception
        Deprecated.
        As of 1.3.3 replaced by getReactionsDotGraph()
        Returns the graph of the chemical reaction network encoded in DOT language. Might return null if not available.
        Returns:
        the chemical reaction network or null if not available
        Throws:
        Exception - the exception
      • getReactionsDotGraph

        public abstract String getReactionsDotGraph()
                                             throws Exception
        Returns the graph of the reaction network encoded in DOT language. Might return null if not available.
        Returns:
        the reaction network or null if not available
        Throws:
        Exception - the exception
      • getHierarchyDotGraph

        public abstract String getHierarchyDotGraph()
                                             throws Exception
        Returns the component's hierarchy graph encoded in DOT language. Might return null if not available.
        Returns:
        the hierarchy graph or null if not available
        Throws:
        Exception - the exception
      • getCRNJsonGraph

        @Deprecated
        public String getCRNJsonGraph()
                               throws Exception
        Deprecated.
        As of 1.3.3 replaced by getReactionsJsonGraph()
        Returns the graph of the chemical reaction network encoded in JSON. Might return null if not available.
        Returns:
        the chemical reaction network or null if not available
        Throws:
        Exception - the exception
      • getReactionsJsonGraph

        public abstract String getReactionsJsonGraph()
                                              throws Exception
        Returns the graph of the reaction network encoded in JSON. Might return null if not available.
        Returns:
        the reaction network or null if not available
        Throws:
        Exception - the exception
      • getHierarchyJsonGraph

        public abstract String getHierarchyJsonGraph()
                                              throws Exception
        Returns the component's hierarchy graph encoded in JSON. Might return null if not available.
        Returns:
        the hierarchy graph or null if not available
        Throws:
        Exception - the exception
      • getReactionsSbgnJsonGraph

        public abstract String getReactionsSbgnJsonGraph()
                                                  throws Exception
        Returns the graph of the reaction network encoded in an SBGN-JSON format. Might return null if not available.
        Returns:
        the reaction network or null if not available
        Throws:
        Exception - the exception
      • getReport

        public abstract String getReport​(Typesetting ts)
                                  throws Exception
        Returns the report providing an on markup processor. Might return null if not available.
        Parameters:
        ts - the ts
        Returns:
        the report or null if not available
        Throws:
        Exception - the exception
      • getHTMLReport

        public abstract String getHTMLReport()
                                      throws Exception
        Returns the report encoded in HTML. Might return null if not available.
        Returns:
        the hTML report or null if not available
        Throws:
        Exception - the exception
      • getMarkDownReport

        public abstract String getMarkDownReport()
                                          throws Exception
        Returns the report encoded MarkDown. Might return null if not available.
        Returns:
        the mark down report or null if not available
        Throws:
        Exception - the exception
      • getReStructuredTextReport

        public abstract String getReStructuredTextReport()
                                                  throws Exception
        Returns the report encoded in ReStructured text. Might return null if not available.
        Returns:
        the ReStructured text report or null if not available
        Throws:
        Exception - the exception