Class AbstractBranch

    • Field Detail

      • DEFAULT_CONTENT_LIST_SIZE

        protected static final int DEFAULT_CONTENT_LIST_SIZE
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractBranch

        public AbstractBranch()
    • Method Detail

      • isReadOnly

        public boolean isReadOnly()
        Description copied from interface: Node

        isReadOnly returns true if this node is read only and cannot be modified. Any attempt to modify a read-only Node will result in an UnsupportedOperationException being thrown.

        Specified by:
        isReadOnly in interface Node
        Overrides:
        isReadOnly in class AbstractNode
        Returns:
        true if this Node is read only and cannot be modified otherwise false.
      • hasContent

        public boolean hasContent()
        Description copied from interface: Node

        hasContent returns true if this node is a Branch (either an Element or a Document) and it contains at least one content node such as a child Element or Text node.

        Specified by:
        hasContent in interface Node
        Overrides:
        hasContent in class AbstractNode
        Returns:
        true if this Node is a Branch with a nodeCount() of one or more.
      • content

        public java.util.List<Node> content()
        Description copied from interface: Branch
        Returns the content nodes of this branch as a backed Listso that the content of this branch may be modified directly using the Listinterface. The List is backed by the Branch so that changes to the list are reflected in the branch and vice versa.
        Specified by:
        content in interface Branch
        Returns:
        the nodes that this branch contains as a List
      • getText

        public java.lang.String getText()
        Description copied from interface: Node

        Returns the text of this node.

        Specified by:
        getText in interface Node
        Overrides:
        getText in class AbstractNode
        Returns:
        the text for this node.
      • getContentAsText

        protected java.lang.String getContentAsText(java.lang.Object content)
        DOCUMENT ME!
        Parameters:
        content - DOCUMENT ME!
        Returns:
        the text value of the given content object as text which returns the text value of CDATA, Entity or Text nodes
      • getContentAsStringValue

        protected java.lang.String getContentAsStringValue(java.lang.Object content)
        DOCUMENT ME!
        Parameters:
        content - DOCUMENT ME!
        Returns:
        the XPath defined string-value of the given content object
      • getTextTrim

        public java.lang.String getTextTrim()
      • setProcessingInstructions

        public void setProcessingInstructions(java.util.List<ProcessingInstruction> listOfPIs)
        Description copied from interface: Branch
        Sets all the processing instructions for this branch
        Specified by:
        setProcessingInstructions in interface Branch
        Parameters:
        listOfPIs - DOCUMENT ME!
      • addElement

        public Element addElement(java.lang.String name)
        Description copied from interface: Branch
        Adds a new Element node with the given name to this branch and returns a reference to the new node.
        Specified by:
        addElement in interface Branch
        Parameters:
        name - is the name for the Element node.
        Returns:
        the newly added Element node.
      • addElement

        public Element addElement(java.lang.String qualifiedName,
                                  java.lang.String namespaceURI)
        Description copied from interface: Branch
        Adds a new Element node with the given qualified name and namespace URI to this branch and returns a reference to the new node.
        Specified by:
        addElement in interface Branch
        Parameters:
        qualifiedName - is the fully qualified name of the Element
        namespaceURI - is the URI of the namespace to use
        Returns:
        the newly added Element node.
      • addElement

        public Element addElement(QName qname)
        Description copied from interface: Branch
        Adds a new Element node with the given QNameto this branch and returns a reference to the new node.
        Specified by:
        addElement in interface Branch
        Parameters:
        qname - is the qualified name for the Element node.
        Returns:
        the newly added Element node.
      • addElement

        public Element addElement(java.lang.String name,
                                  java.lang.String prefix,
                                  java.lang.String uri)
      • add

        public void add(Node node)
        Description copied from interface: Branch
        Adds the given Node or throws IllegalAddException if the given node is not of a valid type. This is a polymorphic method which will call the typesafe method for the node type such as add(Element) or add(Comment).
        Specified by:
        add in interface Branch
        Parameters:
        node - is the given node to add
      • remove

        public boolean remove(Node node)
        Description copied from interface: Branch
        Removes the given Node if the node is an immediate child of this branch. If the given node is not an immediate child of this branch then the Node.detach()method should be used instead. This is a polymorphic method which will call the typesafe method for the node type such as remove(Element) or remove(Comment).
        Specified by:
        remove in interface Branch
        Parameters:
        node - is the given node to be removed
        Returns:
        true if the node was removed
      • add

        public void add(Comment comment)
        Description copied from interface: Branch
        Adds the given Comment to this branch. If the given node already has a parent defined then an IllegalAddException will be thrown.
        Specified by:
        add in interface Branch
        Parameters:
        comment - is the comment to be added
      • add

        public void add(Element element)
        Description copied from interface: Branch
        Adds the given Element to this branch. If the given node already has a parent defined then an IllegalAddException will be thrown.
        Specified by:
        add in interface Branch
        Parameters:
        element - is the element to be added
      • add

        public void add(ProcessingInstruction pi)
        Description copied from interface: Branch
        Adds the given ProcessingInstruction to this branch. If the given node already has a parent defined then an IllegalAddException will be thrown.
        Specified by:
        add in interface Branch
        Parameters:
        pi - is the processing instruction to be added
      • remove

        public boolean remove(Comment comment)
        Description copied from interface: Branch
        Removes the given Comment if the node is an immediate child of this branch. If the given node is not an immediate child of this branch then the Node.detach()method should be used instead.
        Specified by:
        remove in interface Branch
        Parameters:
        comment - is the comment to be removed
        Returns:
        true if the comment was removed
      • remove

        public boolean remove(Element element)
        Description copied from interface: Branch
        Removes the given Element if the node is an immediate child of this branch. If the given node is not an immediate child of this branch then the Node.detach()method should be used instead.
        Specified by:
        remove in interface Branch
        Parameters:
        element - is the element to be removed
        Returns:
        true if the element was removed
      • remove

        public boolean remove(ProcessingInstruction pi)
        Description copied from interface: Branch
        Removes the given ProcessingInstruction if the node is an immediate child of this branch. If the given node is not an immediate child of this branch then the Node.detach()method should be used instead.
        Specified by:
        remove in interface Branch
        Parameters:
        pi - is the processing instruction to be removed
        Returns:
        true if the processing instruction was removed
      • elementByID

        public Element elementByID(java.lang.String elementID)
        Description copied from interface: Branch
        Returns the element of the given ID attribute value. If this tree is capable of understanding which attribute value should be used for the ID then it should be used, otherwise this method should return null.
        Specified by:
        elementByID in interface Branch
        Parameters:
        elementID - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • appendContent

        public void appendContent(Branch branch)
        Description copied from interface: Branch
        Appends the content of the given branch to this branch instance. This method behaves like the Collection.addAll(java.util.Collection) method.
        Specified by:
        appendContent in interface Branch
        Parameters:
        branch - is the branch whose content will be added to me.
      • node

        public Node node(int index)
        Description copied from interface: Branch
        Returns the Node at the specified index position.
        Specified by:
        node in interface Branch
        Parameters:
        index - the index of the node to return.
        Returns:
        the Node at the specified position.
      • nodeCount

        public int nodeCount()
        Description copied from interface: Branch
        Returns the number of Node instances that this branch contains.
        Specified by:
        nodeCount in interface Branch
        Returns:
        the number of nodes this branch contains
      • indexOf

        public int indexOf(Node node)
        Description copied from interface: Branch
        Returns the index of the given node if it is a child node of this branch or -1 if the given node is not a child node.
        Specified by:
        indexOf in interface Branch
        Parameters:
        node - the content child node to find.
        Returns:
        the index of the given node starting at 0 or -1 if the node is not a child node of this branch
      • nodeIterator

        public java.util.Iterator<Node> nodeIterator()
        Description copied from interface: Branch
        Returns an iterator through the content nodes of this branch
        Specified by:
        nodeIterator in interface Branch
        Returns:
        an iterator through the content nodes of this branch
      • elementID

        protected java.lang.String elementID(Element element)
        DOCUMENT ME!
        Parameters:
        element - DOCUMENT ME!
        Returns:
        the ID of the given Element
      • contentList

        protected abstract java.util.List<Node> contentList()
        DOCUMENT ME!
        Returns:
        the internal List used to manage the content
      • createContentList

        protected java.util.List<Node> createContentList()
        A Factory Method pattern which creates a List implementation used to store content
        Returns:
        DOCUMENT ME!
      • createContentList

        protected java.util.List<Node> createContentList(int size)
        A Factory Method pattern which creates a List implementation used to store content
        Parameters:
        size - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • createResultList

        protected <T extends NodeBackedList<T> createResultList()
        A Factory Method pattern which creates a BackedList implementation used to store results of a filtered content query.
        Type Parameters:
        T - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • createSingleResultList

        protected <T extends Node> java.util.List<T> createSingleResultList(T result)
        A Factory Method pattern which creates a BackedList implementation which contains a single result
        Type Parameters:
        T - DOCUMENT ME!
        Parameters:
        result - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • createEmptyList

        protected <T extends Node> java.util.List<T> createEmptyList()
        A Factory Method pattern which creates an empty a BackedList implementation
        Type Parameters:
        T - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • addNode

        protected abstract void addNode(Node node)
      • addNode

        protected abstract void addNode(int index,
                                        Node node)
      • removeNode

        protected abstract boolean removeNode(Node node)
      • childAdded

        protected abstract void childAdded(Node node)
        Called when a new child node has been added to me to allow any parent relationships to be created or events to be fired.
        Parameters:
        node - DOCUMENT ME!
      • childRemoved

        protected abstract void childRemoved(Node node)
        Called when a child node has been removed to allow any parent relationships to be deleted or events to be fired.
        Parameters:
        node - DOCUMENT ME!
      • contentRemoved

        protected void contentRemoved()
        Called when the given List content has been removed so each node should have its parent and document relationships cleared
      • invalidNodeTypeAddException

        protected void invalidNodeTypeAddException(Node node)
        Called when an invalid node has been added. Throws an IllegalAddException.
        Parameters:
        node - DOCUMENT ME!
        Throws:
        IllegalAddException - DOCUMENT ME!