Class XMLConfiguration.XMLBuilderVisitor

    • Field Detail

      • document

        private final org.w3c.dom.Document document
        Stores the document to be constructed.
      • elementMapping

        private final java.util.Map<org.w3c.dom.Node,​org.w3c.dom.Node> elementMapping
        The element mapping.
      • newElements

        private final java.util.Map<ImmutableNode,​org.w3c.dom.Element> newElements
        A mapping for the references for new nodes.
      • listDelimiterHandler

        private final ListDelimiterHandler listDelimiterHandler
        Stores the list delimiter handler .
    • Constructor Detail

      • XMLBuilderVisitor

        public XMLBuilderVisitor​(XMLDocumentHelper docHelper,
                                 ListDelimiterHandler handler)
        Creates a new instance of XMLBuilderVisitor.
        Parameters:
        docHelper - the document helper
        handler - the delimiter handler for properties with multiple values
    • Method Detail

      • clearAttributes

        private static void clearAttributes​(org.w3c.dom.Element elem)
        Removes all attributes of the given element.
        Parameters:
        elem - the element
      • findTextNodeForUpdate

        private static org.w3c.dom.Text findTextNodeForUpdate​(org.w3c.dom.Element elem)
        Returns the only text node of an element for update. This method is called when the element's text changes. Then all text nodes except for the first are removed. A reference to the first is returned or null if there is no text node at all.
        Parameters:
        elem - the element
        Returns:
        the first and only text node
      • updateAttributes

        private static void updateAttributes​(ImmutableNode node,
                                             org.w3c.dom.Element elem)
        Helper method for updating the values of all attributes of the specified node.
        Parameters:
        node - the affected node
        elem - the element that is associated with this node
      • getElement

        private org.w3c.dom.Element getElement​(ImmutableNode node,
                                               ReferenceNodeHandler refHandler)
        Helper method for accessing the element of the specified node.
        Parameters:
        node - the node
        refHandler - the ReferenceNodeHandler
        Returns:
        the element of this node
      • handleRemovedNodes

        public void handleRemovedNodes​(ReferenceNodeHandler refHandler)
        Updates the current XML document regarding removed nodes. The elements associated with removed nodes are removed from the document.
        Parameters:
        refHandler - the ReferenceNodeHandler
      • insert

        protected void insert​(ImmutableNode newNode,
                              ImmutableNode parent,
                              ImmutableNode sibling1,
                              ImmutableNode sibling2,
                              ReferenceNodeHandler refHandler)
        Inserts a new node into the structure constructed by this builder. This method is called for each node that has been added to the configuration tree after the configuration has been loaded from its source. These new nodes have to be inserted into the original structure. The passed in nodes define the position of the node to be inserted: its parent and the siblings between to insert. This implementation ensures that the correct XML element is created and inserted between the given siblings.
        Specified by:
        insert in class BaseHierarchicalConfiguration.BuilderVisitor
        Parameters:
        newNode - the node to be inserted
        parent - the parent node
        sibling1 - the sibling after which the node is to be inserted; can be null if the new node is going to be the first child node
        sibling2 - the sibling before which the node is to be inserted; can be null if the new node is going to be the last child node
        refHandler - the ReferenceNodeHandler
      • processDocument

        public void processDocument​(ReferenceNodeHandler refHandler)
        Processes the specified document, updates element values, and adds new nodes to the hierarchy.
        Parameters:
        refHandler - the ReferenceNodeHandler
      • removeReference

        private void removeReference​(org.w3c.dom.Node element)
        Updates the associated XML elements when a node is removed.
        Parameters:
        element - the element to be removed
      • update

        protected void update​(ImmutableNode node,
                              java.lang.Object reference,
                              ReferenceNodeHandler refHandler)
        Updates a node that already existed in the original hierarchy. This method is called for each node that has an assigned reference object. A concrete implementation should update the reference according to the node's current value. This implementation determines the XML element associated with the given node. Then this element's value and attributes are set accordingly.
        Specified by:
        update in class BaseHierarchicalConfiguration.BuilderVisitor
        Parameters:
        node - the current node to be processed
        reference - the reference object for this node
        refHandler - the ReferenceNodeHandler
      • updateElement

        private void updateElement​(org.w3c.dom.Element element,
                                   java.lang.Object value)
        Updates the node's value if it represents an element node.
        Parameters:
        element - the element
        value - the new value