Class DomElementImpl

  • All Implemented Interfaces:
    DomElement

    public class DomElementImpl
    extends java.lang.Object
    implements DomElement
    Author:
    Sebastian Menski
    • Constructor Summary

      Constructors 
      Constructor Description
      DomElementImpl​(org.w3c.dom.Element element)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCDataSection​(java.lang.String data)
      Adds a CDATA section to this element.
      void appendChild​(DomElement childDomElement)
      Appends the element to the child elements of this element.
      boolean equals​(java.lang.Object o)  
      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 namespaceUri, 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.
      protected org.w3c.dom.Element getElement()  
      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.
      int hashCode()  
      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 childDomElement)
      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.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DomElementImpl

        public DomElementImpl​(org.w3c.dom.Element element)
    • Method Detail

      • getElement

        protected org.w3c.dom.Element getElement()
      • getNamespaceURI

        public java.lang.String getNamespaceURI()
        Description copied from interface: DomElement
        Returns the namespace URI for this element.
        Specified by:
        getNamespaceURI in interface DomElement
        Returns:
        the namespace URI
      • getLocalName

        public java.lang.String getLocalName()
        Description copied from interface: DomElement
        Returns the local name of this element.
        Specified by:
        getLocalName in interface DomElement
        Returns:
        the local name
      • getPrefix

        public java.lang.String getPrefix()
        Description copied from interface: DomElement
        Returns the prefix of this element.
        Specified by:
        getPrefix in interface DomElement
        Returns:
        the prefix
      • getDocument

        public DomDocument getDocument()
        Description copied from interface: DomElement
        Returns the DOM document which contains this element.
        Specified by:
        getDocument in interface DomElement
        Returns:
        the DOM document or null if the element itself is a document
      • getRootElement

        public DomElement getRootElement()
        Description copied from interface: DomElement
        Returns the root element of the document which contains this element.
        Specified by:
        getRootElement in interface DomElement
        Returns:
        the root element of the document or null if non exists
      • getParentElement

        public DomElement getParentElement()
        Description copied from interface: DomElement
        Returns the parent element of this element.
        Specified by:
        getParentElement in interface DomElement
        Returns:
        the parent element or null if not part of a tree
      • getChildElements

        public java.util.List<DomElement> getChildElements()
        Description copied from interface: DomElement
        Returns all child elements of this element.
        Specified by:
        getChildElements in interface DomElement
        Returns:
        the list of child elements
      • getChildElementsByNameNs

        public java.util.List<DomElement> getChildElementsByNameNs​(java.lang.String namespaceUri,
                                                                   java.lang.String elementName)
        Description copied from interface: DomElement
        Returns all child elements of this element with a specific namespace + name
        Specified by:
        getChildElementsByNameNs in interface DomElement
        Returns:
        the list of child elements
      • getChildElementsByNameNs

        public java.util.List<DomElement> getChildElementsByNameNs​(java.util.Set<java.lang.String> namespaceUris,
                                                                   java.lang.String elementName)
        Description copied from interface: DomElement
        Returns all child elements of this element with specific namespaces + name.
        Specified by:
        getChildElementsByNameNs in interface DomElement
        Returns:
        the list of child elements
      • replaceChild

        public void replaceChild​(DomElement newChildDomElement,
                                 DomElement existingChildDomElement)
        Description copied from interface: DomElement
        Replaces a child element with a new element.
        Specified by:
        replaceChild in interface DomElement
        Parameters:
        newChildDomElement - the new child element
        existingChildDomElement - the existing child element
      • removeChild

        public boolean removeChild​(DomElement childDomElement)
        Description copied from interface: DomElement
        Removes a child element of this element.
        Specified by:
        removeChild in interface DomElement
        Parameters:
        childDomElement - the child element to remove
        Returns:
        true if the child element was removed otherwise false
      • appendChild

        public void appendChild​(DomElement childDomElement)
        Description copied from interface: DomElement
        Appends the element to the child elements of this element.
        Specified by:
        appendChild in interface DomElement
        Parameters:
        childDomElement - the element to append
      • insertChildElementAfter

        public void insertChildElementAfter​(DomElement elementToInsert,
                                            DomElement insertAfter)
        Description copied from interface: DomElement
        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.
        Specified by:
        insertChildElementAfter in interface DomElement
        Parameters:
        elementToInsert - the new element to insert
        insertAfter - the existing child element to insert after or null
      • hasAttribute

        public boolean hasAttribute​(java.lang.String localName)
        Description copied from interface: DomElement
        Checks if this element has a attribute under the namespace of this element.
        Specified by:
        hasAttribute in interface DomElement
        Parameters:
        localName - the name of the attribute
        Returns:
        true if the attribute exists otherwise false
      • hasAttribute

        public boolean hasAttribute​(java.lang.String namespaceUri,
                                    java.lang.String localName)
        Description copied from interface: DomElement
        Checks if this element has a attribute with the given namespace.
        Specified by:
        hasAttribute in interface DomElement
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
        Returns:
        true if the attribute exists otherwise false
      • getAttribute

        public java.lang.String getAttribute​(java.lang.String attributeName)
        Description copied from interface: DomElement
        Returns the attribute value for the namespace of this element.
        Specified by:
        getAttribute in interface DomElement
        Parameters:
        attributeName - the name of the attribute
        Returns:
        the value of the attribute or the empty string
      • getAttribute

        public java.lang.String getAttribute​(java.lang.String namespaceUri,
                                             java.lang.String localName)
        Description copied from interface: DomElement
        Returns the attribute value for the given namespace.
        Specified by:
        getAttribute in interface DomElement
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
        Returns:
        the value of the attribute or the empty string
      • setAttribute

        public void setAttribute​(java.lang.String localName,
                                 java.lang.String value)
        Description copied from interface: DomElement
        Sets the attribute value for the namespace of this element.
        Specified by:
        setAttribute in interface DomElement
        Parameters:
        localName - the name of the attribute
        value - the value to set
      • setAttribute

        public void setAttribute​(java.lang.String namespaceUri,
                                 java.lang.String localName,
                                 java.lang.String value)
        Description copied from interface: DomElement
        Sets the attribute value for the given namespace.
        Specified by:
        setAttribute in interface DomElement
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
        value - the value to set
      • setIdAttribute

        public void setIdAttribute​(java.lang.String localName,
                                   java.lang.String value)
        Description copied from interface: DomElement
        Sets the value of a id attribute for the namespace of this element.
        Specified by:
        setIdAttribute in interface DomElement
        Parameters:
        localName - the name of the attribute
        value - the value to set
      • setIdAttribute

        public void setIdAttribute​(java.lang.String namespaceUri,
                                   java.lang.String localName,
                                   java.lang.String value)
        Description copied from interface: DomElement
        Sets the value of a id attribute for the given namespace.
        Specified by:
        setIdAttribute in interface DomElement
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
        value - the value to set
      • removeAttribute

        public void removeAttribute​(java.lang.String localName)
        Description copied from interface: DomElement
        Removes the attribute for the namespace of this element.
        Specified by:
        removeAttribute in interface DomElement
        Parameters:
        localName - the name of the attribute
      • removeAttribute

        public void removeAttribute​(java.lang.String namespaceUri,
                                    java.lang.String localName)
        Description copied from interface: DomElement
        Removes the attribute for the given namespace.
        Specified by:
        removeAttribute in interface DomElement
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        localName - the name of the attribute
      • getTextContent

        public java.lang.String getTextContent()
        Description copied from interface: DomElement
        Gets the text content of this element all its descendants.
        Specified by:
        getTextContent in interface DomElement
        Returns:
        the text content
      • setTextContent

        public void setTextContent​(java.lang.String textContent)
        Description copied from interface: DomElement
        Sets the text content of this element.
        Specified by:
        setTextContent in interface DomElement
        Parameters:
        textContent - the text content to set
      • addCDataSection

        public void addCDataSection​(java.lang.String data)
        Description copied from interface: DomElement
        Adds a CDATA section to this element.
        Specified by:
        addCDataSection in interface DomElement
      • registerNamespace

        public java.lang.String registerNamespace​(java.lang.String namespaceUri)
        Description copied from interface: DomElement
        Adds a new namespace with a generated prefix to this element.
        Specified by:
        registerNamespace in interface DomElement
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        Returns:
        the generated prefix for the new namespace
      • registerNamespace

        public void registerNamespace​(java.lang.String prefix,
                                      java.lang.String namespaceUri)
        Description copied from interface: DomElement
        Adds a new namespace with prefix to this element.
        Specified by:
        registerNamespace in interface DomElement
        Parameters:
        prefix - the prefix of the namespace
        namespaceUri - the namespaceUri of the namespace
      • lookupPrefix

        public java.lang.String lookupPrefix​(java.lang.String namespaceUri)
        Description copied from interface: DomElement
        Returns the prefix of the namespace starting from this node upwards. The default namespace has the prefix null.
        Specified by:
        lookupPrefix in interface DomElement
        Parameters:
        namespaceUri - the namespaceUri of the namespace
        Returns:
        the prefix or null if non is defined
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object