Class XmlInterface

  • Direct Known Subclasses:
    XmlInterfaceVersion1

    public abstract class XmlInterface
    extends java.lang.Object
    Represents a version of the Xml format used to store settings. The parser and serializer must understand each other, so they're kept together.
    Since:
    6.1.0
    Author:
    Clément Fournier
    • Constructor Detail

      • XmlInterface

        public XmlInterface​(int rev)
    • Method Detail

      • getRevisionNumber

        public int getRevisionNumber()
      • parseXml

        public final java.util.Optional<SimpleBeanModelNode> parseXml​(org.w3c.dom.Document document)
        Parses a XML document produced by writeModelToXml(File, SimpleBeanModelNode) into a settings node.
        Parameters:
        document - The document to parse
        Returns:
        The root of the model hierarchy, or empty if the revision is not supported
      • canParse

        public boolean canParse​(org.w3c.dom.Document document)
        Returns true if the document can be read by this object.
        Parameters:
        document - Document to test
      • writeModelToXml

        public final void writeModelToXml​(java.io.File output,
                                          SimpleBeanModelNode model)
                                   throws java.io.IOException
        Writes the model to a file.
        Parameters:
        output - The output file
        model - The model to serialize
        Throws:
        java.io.IOException - If saving the settings failed
      • parseSettingsOwnerNode

        protected abstract SimpleBeanModelNode parseSettingsOwnerNode​(org.w3c.dom.Element nodeElement)
        Parses a settings node and its descendants recursively.
        Parameters:
        nodeElement - Element to parse
        Returns:
        The model described by the element
      • getDocumentMakerVisitor

        protected abstract BeanNodeVisitor<org.w3c.dom.Element> getDocumentMakerVisitor()
        Gets a visitor which populates xml elements with corresponding nodes.
        Returns:
        A visitor