Class DefaultElement

    • Constructor Detail

      • DefaultElement

        public DefaultElement​(String name)
      • DefaultElement

        public DefaultElement​(QName qname)
      • DefaultElement

        public DefaultElement​(QName qname,
                              int attributeCount)
      • DefaultElement

        public DefaultElement​(String name,
                              Namespace namespace)
    • Method Detail

      • getParent

        public Element getParent()
        Description copied from interface: Node

        getParent returns the parent Element if this node supports the parent relationship or null if it is the root element or does not support the parent relationship.

        This method is an optional feature and may not be supported for all Node implementations.

        Specified by:
        getParent in interface Node
        Overrides:
        getParent in class AbstractNode
        Returns:
        the parent of this node or null if it is the root of the tree or the parent relationship is not supported.
      • setParent

        public void setParent​(Element parent)
        Description copied from interface: Node

        setParent sets the parent relationship of this node if the parent relationship is supported or does nothing if the parent relationship is not supported.

        This method should only be called from inside an Element implementation method and is not intended for general use.

        Specified by:
        setParent in interface Node
        Overrides:
        setParent in class AbstractNode
        Parameters:
        parent - is the new parent of this node.
      • getDocument

        public Document getDocument()
        Description copied from interface: Node

        getDocument returns the Document that this Node is part of if this node supports the parent relationship.

        This method is an optional feature and may not be supported for all Node implementations.

        Specified by:
        getDocument in interface Node
        Overrides:
        getDocument in class AbstractNode
        Returns:
        the document of this node or null if this feature is not supported or the node is not associated with a Document
      • setDocument

        public void setDocument​(Document document)
        Description copied from interface: Node

        setDocument sets the document of this node if the parent relationship is supported or does nothing if the parent relationship is not supported.

        This method should only be called from inside a Document implementation method and is not intended for general use.

        Specified by:
        setDocument in interface Node
        Overrides:
        setDocument in class AbstractNode
        Parameters:
        document - is the new document of this node.
      • supportsParent

        public boolean supportsParent()
        Description copied from interface: Node

        supportsParent returns true if this node supports the parent relationship.

        Some XML tree implementations are singly linked and only support downward navigation through children relationships. The default case is that both parent and children relationships are supported though for memory and performance reasons the parent relationship may not be supported.

        Specified by:
        supportsParent in interface Node
        Overrides:
        supportsParent in class AbstractNode
        Returns:
        true if this node supports the parent relationship or false it is not supported
      • getQName

        public QName getQName()
        Description copied from interface: Element
        Returns the QName of this element which represents the local name, the qualified name and the Namespace.
        Returns:
        the QName associated with this element
      • setQName

        public void setQName​(QName name)
        Description copied from interface: Element
        Sets the QName of this element which represents the local name, the qualified name and the Namespace.
        Parameters:
        name - is the QName to be associated with this element
      • clone

        public Object clone()
        Description copied from interface: Node

        clone will return a deep clone or if this node is read-only then clone will return the same instance.

        Specified by:
        clone in interface Node
        Overrides:
        clone in class AbstractNode
        Returns:
        a deep clone of myself or myself if I am read only.
      • getNamespaceForURI

        public Namespace getNamespaceForURI​(String uri)
        Description copied from interface: Element
        Returns the Namespace which is mapped to the given URI or null if it could not be found. If there is more than one Namespace mapped to the URI, which of them will be returned is undetermined.
        Specified by:
        getNamespaceForURI in interface Element
        Overrides:
        getNamespaceForURI in class AbstractElement
        Parameters:
        uri - DOCUMENT ME!
        Returns:
        the Namespace associated with the given URI
      • declaredNamespaces

        public List<Namespace> declaredNamespaces()
        Description copied from interface: Element
        Returns all the namespaces declared by this element. If no namespaces are declared for this element then an empty list will be returned. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
        Specified by:
        declaredNamespaces in interface Element
        Overrides:
        declaredNamespaces in class AbstractElement
        Returns:
        a list of namespaces declared for this element.
      • additionalNamespaces

        public List<Namespace> additionalNamespaces()
        Description copied from interface: Element
        Returns any additional namespaces declarations for this element other than namespace returned via the Element.getNamespace()method. If no additional namespace declarations are present for this element then an empty list will be returned. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
        Specified by:
        additionalNamespaces in interface Element
        Overrides:
        additionalNamespaces in class AbstractElement
        Returns:
        a list of any additional namespace declarations.
      • processingInstructions

        public List<ProcessingInstruction> processingInstructions()
        Description copied from interface: Branch
        Returns a list of all the processing instructions in this branch. The list is backed by this branch so that changes to the list will be reflected in the branch but the reverse is not the case.
        Specified by:
        processingInstructions in interface Branch
        Overrides:
        processingInstructions in class AbstractElement
        Returns:
        a backed list of the processing instructions
      • processingInstructions

        public List<ProcessingInstruction> processingInstructions​(String target)
        Description copied from interface: Branch
        Returns a list of the processing instructions for the given target. The list is backed by this branch so that changes to the list will be reflected in the branch but the reverse is not the case.
        Specified by:
        processingInstructions in interface Branch
        Overrides:
        processingInstructions in class AbstractElement
        Parameters:
        target - DOCUMENT ME!
        Returns:
        a backed list of the processing instructions
      • element

        public Element element​(String name)
        Description copied from interface: Element
        Returns the first element for the given local name and any namespace.
        Specified by:
        element in interface Element
        Overrides:
        element in class AbstractElement
        Parameters:
        name - DOCUMENT ME!
        Returns:
        the first element with the given local name
      • element

        public Element element​(QName qName)
        Description copied from interface: Element
        Returns the first element for the given fully qualified name.
        Specified by:
        element in interface Element
        Overrides:
        element in class AbstractElement
        Parameters:
        qName - is the fully qualified name to search for
        Returns:
        the first element with the given fully qualified name
      • setContent

        public void setContent​(List<Node> content)
        Description copied from interface: Branch
        Sets the contents of this branch as a List of Node instances.
        Parameters:
        content - is the list of nodes to use as the content for this branch.
      • clearContent

        public void clearContent()
        Description copied from interface: Branch
        Clears the content for this branch, removing any Node instances this branch may contain.
      • 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
        Overrides:
        node in class AbstractElement
        Parameters:
        index - the index of the node to return.
        Returns:
        the Node at the specified position.
      • 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
        Overrides:
        indexOf in class AbstractElement
        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
      • 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
        Overrides:
        nodeCount in class AbstractElement
        Returns:
        the number of nodes this branch contains
      • nodeIterator

        public Iterator<Node> nodeIterator()
        Description copied from interface: Branch
        Returns an iterator through the content nodes of this branch
        Specified by:
        nodeIterator in interface Branch
        Overrides:
        nodeIterator in class AbstractElement
        Returns:
        an iterator through the content nodes of this branch
      • attributes

        public List<Attribute> attributes()
        Description copied from interface: Element
        Returns the Attributeinstances this element contains as a backed Listso that the attributes may be modified directly using the Listinterface. The List is backed by the Element so that changes to the list are reflected in the element and vice versa.
        Specified by:
        attributes in interface Element
        Overrides:
        attributes in class AbstractElement
        Returns:
        the attributes that this element contains as a List
      • setAttributes

        public void setAttributes​(List<Attribute> attributes)
        Description copied from interface: Element
        Sets the attributes that this element contains
        Parameters:
        attributes - DOCUMENT ME!
      • attribute

        public Attribute attribute​(int index)
        Description copied from interface: Element
        Returns the attribute at the specified indexGets the
        Specified by:
        attribute in interface Element
        Overrides:
        attribute in class AbstractElement
        Parameters:
        index - DOCUMENT ME!
        Returns:
        the attribute at the specified index where index >= 0 and index < number of attributes or throws an IndexOutOfBoundsException if the index is not within the allowable range
      • attribute

        public Attribute attribute​(String name)
        Description copied from interface: Element
        Returns the attribute with the given name
        Specified by:
        attribute in interface Element
        Overrides:
        attribute in class AbstractElement
        Parameters:
        name - DOCUMENT ME!
        Returns:
        the attribute for the given local name in any namespace. If there are more than one attributes with the given local name in different namespaces then the first one is returned.
      • attribute

        public Attribute attribute​(QName qName)
        Description copied from interface: Element
        DOCUMENT ME!
        Specified by:
        attribute in interface Element
        Overrides:
        attribute in class AbstractElement
        Parameters:
        qName - is the fully qualified name
        Returns:
        the attribute for the given fully qualified name or null if it could not be found.
      • add

        public void add​(Attribute attribute)
        Description copied from interface: Element
        Adds the given Attribute to this element. If the given node already has a parent defined then an IllegalAddException will be thrown. Attributes with null values are silently ignored. If the value of the attribute is null then this method call will remove any attributes with the QName of this attribute.
        Specified by:
        add in interface Element
        Overrides:
        add in class AbstractElement
        Parameters:
        attribute - is the attribute to be added
      • remove

        public boolean remove​(Attribute attribute)
        Description copied from interface: Element
        Removes the given Attribute from this element.
        Specified by:
        remove in interface Element
        Overrides:
        remove in class AbstractElement
        Parameters:
        attribute - is the attribute to be removed
        Returns:
        true if the attribute was removed
      • addNewNode

        protected void addNewNode​(Node node)
        Description copied from class: AbstractElement
        Like addNode() but does not require a parent check
        Overrides:
        addNewNode in class AbstractElement
        Parameters:
        node - DOCUMENT ME!
      • attributeList

        protected List<Attribute> attributeList​(int size)
        Description copied from class: AbstractElement
        DOCUMENT ME!
        Specified by:
        attributeList in class AbstractElement
        Parameters:
        size - DOCUMENT ME!
        Returns:
        the internal List used to store attributes or creates one with the specified size if one is not available
      • setAttributeList

        protected void setAttributeList​(List<Attribute> attributeList)