Interface DomElement
-
- All Known Implementing Classes:
DomElementImpl
public interface DomElementEncapsulatesElement. Implementations of this interface must be thread-safe.- Author:
- Sebastian Menski
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddCDataSection(java.lang.String data)Adds a CDATA section to this element.voidappendChild(DomElement childElement)Appends the element to the child elements of this element.java.lang.StringgetAttribute(java.lang.String attributeName)Returns the attribute value for the namespace of this element.java.lang.StringgetAttribute(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 + namejava.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.DomDocumentgetDocument()Returns the DOM document which contains this element.java.lang.StringgetLocalName()Returns the local name of this element.ModelElementInstancegetModelElementInstance()Returns theModelElementInstancewhich is associated with this element.java.lang.StringgetNamespaceURI()Returns the namespace URI for this element.DomElementgetParentElement()Returns the parent element of this element.java.lang.StringgetPrefix()Returns the prefix of this element.DomElementgetRootElement()Returns the root element of the document which contains this element.java.lang.StringgetTextContent()Gets the text content of this element all its descendants.booleanhasAttribute(java.lang.String localName)Checks if this element has a attribute under the namespace of this element.booleanhasAttribute(java.lang.String namespaceUri, java.lang.String localName)Checks if this element has a attribute with the given namespace.voidinsertChildElementAfter(DomElement elementToInsert, DomElement insertAfter)Inserts the new child element after another child element.java.lang.StringlookupPrefix(java.lang.String namespaceUri)Returns the prefix of the namespace starting from this node upwards.java.lang.StringregisterNamespace(java.lang.String namespaceUri)Adds a new namespace with a generated prefix to this element.voidregisterNamespace(java.lang.String prefix, java.lang.String namespaceUri)Adds a new namespace with prefix to this element.voidremoveAttribute(java.lang.String localName)Removes the attribute for the namespace of this element.voidremoveAttribute(java.lang.String namespaceUri, java.lang.String localName)Removes the attribute for the given namespace.booleanremoveChild(DomElement domElement)Removes a child element of this element.voidreplaceChild(DomElement newChildDomElement, DomElement existingChildDomElement)Replaces a child element with a new element.voidsetAttribute(java.lang.String localName, java.lang.String value)Sets the attribute value for the namespace of this element.voidsetAttribute(java.lang.String namespaceUri, java.lang.String localName, java.lang.String value)Sets the attribute value for the given namespace.voidsetIdAttribute(java.lang.String localName, java.lang.String value)Sets the value of a id attribute for the namespace of this element.voidsetIdAttribute(java.lang.String namespaceUri, java.lang.String localName, java.lang.String value)Sets the value of a id attribute for the given namespace.voidsetModelElementInstance(ModelElementInstance modelElementInstance)Sets theModelElementInstancewhich should be associated with this element.voidsetTextContent(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 elementexistingChildDomElement- 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 insertinsertAfter- 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 namespacelocalName- 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 namespacelocalName- 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 attributevalue- 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 namespacelocalName- the name of the attributevalue- 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 attributevalue- 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 namespacelocalName- the name of the attributevalue- 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 namespacelocalName- 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
-
getModelElementInstance
ModelElementInstance getModelElementInstance()
Returns theModelElementInstancewhich is associated with this element.- Returns:
- the
ModelElementInstanceor null if non is associated
-
setModelElementInstance
void setModelElementInstance(ModelElementInstance modelElementInstance)
Sets theModelElementInstancewhich should be associated with this element.- Parameters:
modelElementInstance- theModelElementInstanceto associate
-
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 namespacenamespaceUri- 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 prefixnull.- Parameters:
namespaceUri- the namespaceUri of the namespace- Returns:
- the prefix or null if non is defined
-
-