public class ModelElementInstanceImpl extends Object implements ModelElementInstance
Modifier and Type | Field and Description |
---|---|
protected ModelInstanceImpl |
modelInstance
the containing model instance
|
Constructor and Description |
---|
ModelElementInstanceImpl(ModelTypeInstanceContext instanceContext) |
Modifier and Type | Method and Description |
---|---|
void |
addChildElement(ModelElementInstance newChild)
Adds a new child element to the children of this element.
|
protected <T> Set<T> |
asSet(T... elements) |
boolean |
equals(Object obj) |
String |
getAttributeValue(String attributeName)
Returns the attribute value for the attribute name.
|
String |
getAttributeValueNs(String namespaceUri,
String attributeName)
Returns the attribute value for the given attribute name and namespace URI.
|
<T extends ModelElementInstance> |
getChildElementsByType(Class<T> childElementClass)
Return all child elements of a given type
|
Collection<ModelElementInstance> |
getChildElementsByType(ModelElementType childElementType)
Return all child elements of a given type
|
DomElement |
getDomElement()
Returns the represented DOM
DomElement . |
ModelElementType |
getElementType()
Returns the element type of this.
|
ModelInstanceImpl |
getModelInstance()
Returns the model instance which contains this type instance.
|
ModelElementInstance |
getParentElement()
Returns the parent element of this.
|
String |
getRawTextContent()
Returns the raw text content of the DOM element including all whitespaces.
|
String |
getTextContent()
Returns the text content of the DOM element without leading and trailing spaces.
|
ModelElementInstance |
getUniqueChildElementByNameNs(String namespaceUri,
String elementName)
Returns a child element with the given name or 'null' if no such element exists
|
ModelElementInstance |
getUniqueChildElementByType(Class<? extends ModelElementInstance> elementType)
Returns a child element with the given type
|
int |
hashCode() |
void |
insertElementAfter(ModelElementInstance elementToInsert,
ModelElementInstance insertAfterElement)
Inserts the new element after the given element or at the beginning if the given element is null.
|
static void |
registerType(ModelBuilder modelBuilder) |
void |
removeAttribute(String attributeName)
Removes attribute by name.
|
void |
removeAttributeNs(String namespaceUri,
String attributeName)
Removes the attribute by name and namespace.
|
boolean |
removeChildElement(ModelElementInstance child)
Removes the child element from this.
|
void |
replaceChildElement(ModelElementInstance existingChild,
ModelElementInstance newChild)
Replace an existing child element with a new child element.
|
void |
replaceWithElement(ModelElementInstance newElement)
Replaces this element with a new element and updates references.
|
void |
setAttributeValue(String attributeName,
String xmlValue)
Sets the value by name of a non-ID attribute.
|
void |
setAttributeValue(String attributeName,
String xmlValue,
boolean isIdAttribute)
Sets attribute value by name.
|
void |
setAttributeValueNs(String namespaceUri,
String attributeName,
String xmlValue)
Sets the value by name and namespace of a non-ID attribute.
|
void |
setAttributeValueNs(String namespaceUri,
String attributeName,
String xmlValue,
boolean isIdAttribute)
Sets the attribute value by name and namespace.
|
void |
setTextContent(String textContent)
Sets the text content of the DOM element
|
void |
setUniqueChildElementByNameNs(ModelElementInstance newChild)
Adds or replaces a child element by name.
|
void |
updateAfterReplacement()
Execute updates after the element was inserted as a replacement of another element.
|
protected final ModelInstanceImpl modelInstance
public ModelElementInstanceImpl(ModelTypeInstanceContext instanceContext)
public static void registerType(ModelBuilder modelBuilder)
public DomElement getDomElement()
ModelElementInstance
DomElement
.getDomElement
in interface ModelElementInstance
public ModelInstanceImpl getModelInstance()
ModelElementInstance
getModelInstance
in interface ModelElementInstance
public ModelElementInstance getParentElement()
ModelElementInstance
getParentElement
in interface ModelElementInstance
public ModelElementType getElementType()
ModelElementInstance
getElementType
in interface ModelElementInstance
public String getAttributeValue(String attributeName)
ModelElementInstance
getAttributeValue
in interface ModelElementInstance
attributeName
- the name of the attributepublic String getAttributeValueNs(String namespaceUri, String attributeName)
ModelElementInstance
getAttributeValueNs
in interface ModelElementInstance
namespaceUri
- the namespace URI of the attributeattributeName
- the attribute name of the attributepublic void setAttributeValue(String attributeName, String xmlValue)
ModelElementInstance
setAttributeValue
in interface ModelElementInstance
attributeName
- the name of the attributexmlValue
- the value to setpublic void setAttributeValue(String attributeName, String xmlValue, boolean isIdAttribute)
ModelElementInstance
setAttributeValue
in interface ModelElementInstance
attributeName
- the name of the attributexmlValue
- the value to setisIdAttribute
- true if the attribute is an ID attribute, false otherwisepublic void setAttributeValueNs(String namespaceUri, String attributeName, String xmlValue)
ModelElementInstance
setAttributeValueNs
in interface ModelElementInstance
namespaceUri
- the namespace URI of the attributeattributeName
- the name of the attributexmlValue
- the XML value to setpublic void setAttributeValueNs(String namespaceUri, String attributeName, String xmlValue, boolean isIdAttribute)
ModelElementInstance
setAttributeValueNs
in interface ModelElementInstance
namespaceUri
- the namespace URI of the attributeattributeName
- the name of the attributexmlValue
- the XML value to setisIdAttribute
- true if the attribute is an ID attribute, false otherwisepublic void removeAttribute(String attributeName)
ModelElementInstance
removeAttribute
in interface ModelElementInstance
attributeName
- the name of the attributepublic void removeAttributeNs(String namespaceUri, String attributeName)
ModelElementInstance
removeAttributeNs
in interface ModelElementInstance
namespaceUri
- the namespace URI of the attributeattributeName
- the name of the attributepublic String getTextContent()
ModelElementInstance
getRawTextContent()
.getTextContent
in interface ModelElementInstance
public void setTextContent(String textContent)
ModelElementInstance
setTextContent
in interface ModelElementInstance
textContent
- the new text contentpublic String getRawTextContent()
ModelElementInstance
getRawTextContent
in interface ModelElementInstance
public ModelElementInstance getUniqueChildElementByNameNs(String namespaceUri, String elementName)
ModelElementInstance
getUniqueChildElementByNameNs
in interface ModelElementInstance
namespaceUri
- the local name of the elementelementName
- the namespace of the elementpublic ModelElementInstance getUniqueChildElementByType(Class<? extends ModelElementInstance> elementType)
ModelElementInstance
getUniqueChildElementByType
in interface ModelElementInstance
elementType
- the type of the elementpublic void setUniqueChildElementByNameNs(ModelElementInstance newChild)
ModelElementInstance
setUniqueChildElementByNameNs
in interface ModelElementInstance
newChild
- the child to addpublic void replaceChildElement(ModelElementInstance existingChild, ModelElementInstance newChild)
ModelElementInstance
replaceChildElement
in interface ModelElementInstance
existingChild
- the child element to replacenewChild
- the new child elementpublic void replaceWithElement(ModelElementInstance newElement)
ModelElementInstance
replaceWithElement
in interface ModelElementInstance
newElement
- the new element to replace withpublic void addChildElement(ModelElementInstance newChild)
ModelElementInstance
addChildElement
in interface ModelElementInstance
newChild
- the new child elementpublic boolean removeChildElement(ModelElementInstance child)
ModelElementInstance
removeChildElement
in interface ModelElementInstance
child
- the child element to removepublic Collection<ModelElementInstance> getChildElementsByType(ModelElementType childElementType)
ModelElementInstance
getChildElementsByType
in interface ModelElementInstance
childElementType
- the child element type to search forpublic <T extends ModelElementInstance> Collection<T> getChildElementsByType(Class<T> childElementClass)
ModelElementInstance
getChildElementsByType
in interface ModelElementInstance
childElementClass
- the class of the child element type to search forpublic void insertElementAfter(ModelElementInstance elementToInsert, ModelElementInstance insertAfterElement)
ModelElementInstance
insertElementAfter
in interface ModelElementInstance
elementToInsert
- the new element to insertinsertAfterElement
- the element to insert after or null to insert at first positionpublic void updateAfterReplacement()
ModelElementInstance
updateAfterReplacement
in interface ModelElementInstance
protected <T> Set<T> asSet(T... elements)
Copyright © 2018. All rights reserved.