Interface DomElement

  • All Known Implementing Classes:
    DomElementImpl

    public interface DomElement
    Encapsulates Element. Implementations of this interface must be thread-safe.
    Author:
    Sebastian Menski
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addCDataSection​(java.lang.String data)
      Adds a CDATA section to this element.
      void appendChild​(DomElement childElement)
      Appends the element to the child elements of this element.
      java.lang.String getAttribute​(java.lang.String attributeName)
      Returns the attribute value for the namespace of this element.
      java.lang.String getAttribute​(java.lang.String namespaceUri, java.lang.String localName)
      Returns the attribute value for the given namespace.
      java.util.List<DomElement> getChildElements()
      Returns all child elements of this element.
      java.util.List<DomElement> getChildElementsByNameNs​(java.lang.String namespaceUris, java.lang.String elementName)
      Returns all child elements of this element with a specific namespace + name
      java.util.List<DomElement> getChildElementsByNameNs​(java.util.Set<java.lang.String> namespaceUris, java.lang.String elementName)
      Returns all child elements of this element with specific namespaces + name.
      java.util.List<DomElement> getChildElementsByType​(ModelInstanceImpl modelInstance, java.lang.Class<? extends ModelElementInstance> elementType)
      Returns all child elements of this element with a specific type.
      DomDocument getDocument()
      Returns the DOM document which contains this element.
      java.lang.String getLocalName()
      Returns the local name of this element.
      ModelElementInstance getModelElementInstance()
      Returns the ModelElementInstance which is associated with this element.
      java.lang.String getNamespaceURI()
      Returns the namespace URI for this element.
      DomElement getParentElement()
      Returns the parent element of this element.
      java.lang.String getPrefix()
      Returns the prefix of this element.
      DomElement getRootElement()
      Returns the root element of the document which contains this element.
      java.lang.String getTextContent()
      Gets the text content of this element all its descendants.
      boolean hasAttribute​(java.lang.String localName)
      Checks if this element has a attribute under the namespace of this element.
      boolean hasAttribute​(java.lang.String namespaceUri, java.lang.String localName)
      Checks if this element has a attribute with the given namespace.
      void insertChildElementAfter​(DomElement elementToInsert, DomElement insertAfter)
      Inserts the new child element after another child element.
      java.lang.String lookupPrefix​(java.lang.String namespaceUri)
      Returns the prefix of the namespace starting from this node upwards.
      java.lang.String registerNamespace​(java.lang.String namespaceUri)
      Adds a new namespace with a generated prefix to this element.
      void registerNamespace​(java.lang.String prefix, java.lang.String namespaceUri)
      Adds a new namespace with prefix to this element.
      void removeAttribute​(java.lang.String localName)
      Removes the attribute for the namespace of this element.
      void removeAttribute​(java.lang.String namespaceUri, java.lang.String localName)
      Removes the attribute for the given namespace.
      boolean removeChild​(DomElement domElement)
      Removes a child element of this element.
      void replaceChild​(DomElement newChildDomElement, DomElement existingChildDomElement)
      Replaces a child element with a new element.
      void setAttribute​(java.lang.String localName, java.lang.String value)
      Sets the attribute value for the namespace of this element.
      void setAttribute​(java.lang.String namespaceUri, java.lang.String localName, java.lang.String value)
      Sets the attribute value for the given namespace.
      void setIdAttribute​(java.lang.String localName, java.lang.String value)
      Sets the value of a id attribute for the namespace of this element.
      void setIdAttribute​(java.lang.String namespaceUri, java.lang.String localName, java.lang.String value)
      Sets the value of a id attribute for the given namespace.
      void setModelElementInstance​(ModelElementInstance modelElementInstance)
      Sets the ModelElementInstance which should be associated with this element.
      void setTextContent​(java.lang.String textContent)
      Sets the text content of this element.
    • Method Detail

      • getNamespaceURI

        java.lang.String getNamespaceURI()
        Returns the namespace URI for this element.
        Returns:
        the namespace URI
      • getLocalName

        java.lang.String getLocalName()
        Returns the local name of this element.
        Returns:
        the local name
      • getPrefix

        java.lang.String getPrefix()
        Returns the prefix of this element.
        Returns:
        the prefix
      • getDocument

        DomDocument getDocument()
        Returns the DOM document which contains this element.
        Returns:
        the DOM document or null if the element itself is a document
      • getRootElement

        DomElement getRootElement()
        Returns the root element of the document which contains this element.
        Returns:
        the root element of the document or null if non exists
      • getParentElement

        DomElement getParentElement()
        Returns the parent element of this element.
        Returns:
        the parent element or null if not part of a tree
      • getChildElements

        java.util.List<DomElement> getChildElements()
        Returns all child elements of this element.
        Returns:
        the list of child elements
      • getChildElementsByNameNs

        java.util.List<DomElement> getChildElementsByNameNs​(java.lang.String namespaceUris,
                                                            java.lang.String elementName)
        Returns all child elements of this element with a specific namespace + name
        Returns:
        the list of child elements
      • getChildElementsByNameNs

        java.util.List<DomElement> getChildElementsByNameNs​(java.util.Set<java.lang.String> namespaceUris,
                                                            java.lang.String elementName)
        Returns all child elements of this element with specific namespaces + name.
        Returns:
        the list of child elements
      • getChildElementsByType

        java.util.List<DomElement> getChildElementsByType​(ModelInstanceImpl modelInstance,
                                                          java.lang.Class<? extends ModelElementInstance> elementType)
        Returns all child elements of this element with a specific type.
        Returns:
        the list of child elements matching the type
      • replaceChild

        void replaceChild​(DomElement newChildDomElement,
                          DomElement existingChildDomElement)
        Replaces a child element with a new element.
        Parameters:
        newChildDomElement - the new child element
        existingChildDomElement - the existing child element
        Throws:
        ModelException - if the child cannot be replaced
      • removeChild

        boolean removeChild​(DomElement domElement)
        Removes a child element of this element.
        Parameters:
        domElement - the child element to remove
        Returns:
        true if the child element was removed otherwise false
      • appendChild

        void appendChild​(DomElement childElement)
        Appends the element to the child elements of this element.
        Parameters:
        childElement - the element to append
      • insertChildElementAfter

        void insertChildElementAfter​(DomElement elementToInsert,
                                     DomElement insertAfter)
        Inserts the new child element after another child element. If the child element to insert after is null the new child element will be inserted at the beginning.
        Parameters:
        elementToInsert - the new element to insert
        insertAfter - the existing child element to insert after or null
      • hasAttribute

        boolean hasAttribute​(java.lang.String localName)
        Checks if this element has a attribute under the namespace of this element.
        Parameters:
        localName - the name of the attribute
        Returns:
        true if the attribute exists otherwise false
      • hasAttribute

        boolean hasAttribute​(java.lang.String namespaceUri,
                             java.lang.String localName)
        Checks if this element has a attribute with the given namespace.
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
        Returns:
        true if the attribute exists otherwise false
      • getAttribute

        java.lang.String getAttribute​(java.lang.String attributeName)
        Returns the attribute value for the namespace of this element.
        Parameters:
        attributeName - the name of the attribute
        Returns:
        the value of the attribute or the empty string
      • getAttribute

        java.lang.String getAttribute​(java.lang.String namespaceUri,
                                      java.lang.String localName)
        Returns the attribute value for the given namespace.
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
        Returns:
        the value of the attribute or the empty string
      • setAttribute

        void setAttribute​(java.lang.String localName,
                          java.lang.String value)
        Sets the attribute value for the namespace of this element.
        Parameters:
        localName - the name of the attribute
        value - the value to set
      • setAttribute

        void setAttribute​(java.lang.String namespaceUri,
                          java.lang.String localName,
                          java.lang.String value)
        Sets the attribute value for the given namespace.
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
        value - the value to set
      • setIdAttribute

        void setIdAttribute​(java.lang.String localName,
                            java.lang.String value)
        Sets the value of a id attribute for the namespace of this element.
        Parameters:
        localName - the name of the attribute
        value - the value to set
      • setIdAttribute

        void setIdAttribute​(java.lang.String namespaceUri,
                            java.lang.String localName,
                            java.lang.String value)
        Sets the value of a id attribute for the given namespace.
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
        value - the value to set
      • removeAttribute

        void removeAttribute​(java.lang.String localName)
        Removes the attribute for the namespace of this element.
        Parameters:
        localName - the name of the attribute
      • removeAttribute

        void removeAttribute​(java.lang.String namespaceUri,
                             java.lang.String localName)
        Removes the attribute for the given namespace.
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
      • getTextContent

        java.lang.String getTextContent()
        Gets the text content of this element all its descendants.
        Returns:
        the text content
      • setTextContent

        void setTextContent​(java.lang.String textContent)
        Sets the text content of this element.
        Parameters:
        textContent - the text content to set
      • addCDataSection

        void addCDataSection​(java.lang.String data)
        Adds a CDATA section to this element.
        Parameters:
        textContent - the CDATA content to set
      • registerNamespace

        java.lang.String registerNamespace​(java.lang.String namespaceUri)
        Adds a new namespace with a generated prefix to this element.
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        Returns:
        the generated prefix for the new namespace
      • registerNamespace

        void registerNamespace​(java.lang.String prefix,
                               java.lang.String namespaceUri)
        Adds a new namespace with prefix to this element.
        Parameters:
        prefix - the prefix of the namespace
        namespaceUri - the namespaceUri of the namespace
      • lookupPrefix

        java.lang.String lookupPrefix​(java.lang.String namespaceUri)
        Returns the prefix of the namespace starting from this node upwards. The default namespace has the prefix null.
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        Returns:
        the prefix or null if non is defined