Class Element

    • Constructor Detail

      • Element

        public Element​(java.lang.String localName)
      • Element

        public Element​(java.lang.String namespacePrefix,
                       java.lang.String localName)
    • Method Detail

      • getNamespacePrefix

        public java.lang.String getNamespacePrefix()
        Returns the element's namespace prefix.
        Returns:
        The element's namespace prefix, or null if the element belongs to the default namespace.
      • getLocalName

        public java.lang.String getLocalName()
        Returns:
        The element's local name.
      • getName

        public java.lang.String getName()
        Returns the fully-qualified name of the element.
        Returns:
        The local name if no namespace is defined, or the fully-qualified name if there is a namespace.
      • getDefaultNamespaceURI

        public java.lang.String getDefaultNamespaceURI()
        Returns the element's default namespace URI.
        Returns:
        The default namespace URI declared by this element, or null if this element does not declare a default namespace.
      • setDefaultNamespaceURI

        public void setDefaultNamespaceURI​(java.lang.String defaultNamespaceURI)
        Sets the element's default namespace URI.
        Parameters:
        defaultNamespaceURI - The default namespace URI declared by this element, or null if this element does not declare a default namespace.
      • getNamespaceURI

        public java.lang.String getNamespaceURI​(java.lang.String prefix)
        Determines the namespace URI corresponding to the given prefix by traversing the element's ancestry.
        Parameters:
        prefix - The namespace prefix to look up, or null to determine the default namespace for this element.
        Returns:
        The namespace URI corresponding to the given prefix, or null if a URI could not be found.
      • add

        public int add​(Node node)
        Adds a node to this element.
        Specified by:
        add in interface List<Node>
        Specified by:
        add in interface Sequence<Node>
        Parameters:
        node - The node to be added.
        Returns:
        The index at which the node was added.
        Throws:
        java.lang.IllegalArgumentException - if the node already has a parent.
        See Also:
        ListListener.itemInserted(List, int)
      • insert

        public void insert​(Node node,
                           int index)
        Inserts a node at a specific location within this element.
        Specified by:
        insert in interface List<Node>
        Specified by:
        insert in interface Sequence<Node>
        Parameters:
        node - The node to insert.
        index - The index within this element where to insert the node.
        See Also:
        ListListener.itemInserted(List, int)
      • update

        @UnsupportedOperation
        public Node update​(int index,
                           Node node)
        Description copied from interface: List
        Updates the item at the given index.
        Specified by:
        update in interface List<Node>
        Specified by:
        update in interface Sequence<Node>
        Parameters:
        index - The index of the item to update.
        node - The item that will replace any existing value at the given index.
        Returns:
        The item that was previously stored at the given index.
        Throws:
        java.lang.UnsupportedOperationException - This method is not supported.
        See Also:
        ListListener.itemUpdated(List, int, Object)
      • remove

        public int remove​(Node node)
        Removes a node from this element.
        Specified by:
        remove in interface Sequence<Node>
        Parameters:
        node - The node to remove.
        Returns:
        The index of the node before it was removed, or -1 if the node was not found.
        See Also:
        Sequence.remove(int, int)
      • get

        public Node get​(int index)
        Returns the node at the given index.
        Specified by:
        get in interface Sequence<Node>
        Parameters:
        index - The desired index.
        Returns:
        The node at that index, or null if there is no node at that location.
      • indexOf

        public int indexOf​(Node node)
        Determines the index of the given node within this element.
        Specified by:
        indexOf in interface Sequence<Node>
        Parameters:
        node - The item to locate.
        Returns:
        The index of the node, or -1 if the node does not exist in this element.
      • getLength

        public int getLength()
        Returns the number of nodes contained by this element.
        Specified by:
        getLength in interface List<Node>
        Specified by:
        getLength in interface Sequence<Node>
        Returns:
        The number of items in the list, or -1 if the list's length is not known. In this case, the iterator must be used to retrieve the contents of the list.
      • setComparator

        @UnsupportedOperation
        public void setComparator​(java.util.Comparator<Node> comparator)
        Description copied from interface: Collection
        Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.

        Calling this method more than once with the same comparator will re-sort the collection.

        Specified by:
        setComparator in interface Collection<Node>
        Specified by:
        setComparator in interface List<Node>
        Parameters:
        comparator - The comparator used to order elements in the collection, or null if the collection is unsorted.
        Throws:
        java.lang.UnsupportedOperationException - Elements cannot be sorted.
        See Also:
        ListListener.comparatorChanged(List, Comparator)
      • iterator

        public java.util.Iterator<Node> iterator()
        Returns an iterator over this elements child nodes.
        Specified by:
        iterator in interface java.lang.Iterable<Node>
      • isEmpty

        public boolean isEmpty()
        Determines if this element defines any attributes.
        Specified by:
        isEmpty in interface Collection<Node>
        Returns:
        true if this element does not define any attributes; false otherwise.
      • getElements

        public List<Element> getElements​(java.lang.String name)
        Returns the sub-elements of of this element whose tag names match the given name.
        Parameters:
        name - The tag name to match.
        Returns:
        A list containing the matching elements. The list will be empty if no elements matched the given tag name.
      • getText

        public java.lang.String getText()
        Returns the text content of this element. An element is defined to contain text when it contains a single child that is an instance of TextNode.
        Returns:
        The text content of the element, or null if this element does not contain text.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object