Class ModelElementInstanceImpl
- java.lang.Object
-
- org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl
-
- All Implemented Interfaces:
ModelElementInstance
- Direct Known Subclasses:
BpmnModelElementInstanceImpl
,CmmnModelElementInstanceImpl
,DmnModelElementInstanceImpl
public class ModelElementInstanceImpl extends java.lang.Object implements ModelElementInstance
Base class for implementing Model Elements.- Author:
- Daniel Meyer
-
-
Field Summary
Fields Modifier and Type Field Description protected ModelInstanceImpl
modelInstance
the containing model instance
-
Constructor Summary
Constructors Constructor Description ModelElementInstanceImpl(ModelTypeInstanceContext instanceContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChildElement(ModelElementInstance newChild)
Adds a new child element to the children of this element.protected <T> java.util.Set<T>
asSet(T element, java.util.Set<T> elements)
boolean
equals(java.lang.Object obj)
java.lang.String
getAttributeValue(java.lang.String attributeName)
Returns the attribute value for the attribute name.java.lang.String
getAttributeValueNs(java.lang.String namespaceUri, java.lang.String attributeName)
Returns the attribute value for the given attribute name and namespace URI.<T extends ModelElementInstance>
java.util.Collection<T>getChildElementsByType(java.lang.Class<T> childElementClass)
Return all child elements of a given typejava.util.Collection<ModelElementInstance>
getChildElementsByType(ModelElementType childElementType)
Return all child elements of a given typeDomElement
getDomElement()
Returns the represented DOMDomElement
.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.java.lang.String
getRawTextContent()
Returns the raw text content of the DOM element including all whitespaces.java.lang.String
getTextContent()
Returns the text content of the DOM element without leading and trailing spaces.ModelElementInstance
getUniqueChildElementByNameNs(java.lang.String namespaceUri, java.lang.String elementName)
Returns a child element with the given name or 'null' if no such element existsModelElementInstance
getUniqueChildElementByType(java.lang.Class<? extends ModelElementInstance> elementType)
Returns a child element with the given typeint
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(java.lang.String attributeName)
Removes attribute by name.void
removeAttributeNs(java.lang.String namespaceUri, java.lang.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(java.lang.String attributeName, java.lang.String xmlValue)
Sets the value by name of a non-ID attribute.void
setAttributeValue(java.lang.String attributeName, java.lang.String xmlValue, boolean isIdAttribute)
Sets attribute value by name.void
setAttributeValue(java.lang.String attributeName, java.lang.String xmlValue, boolean isIdAttribute, boolean withReferenceUpdate)
Sets attribute value by name.void
setAttributeValueNs(java.lang.String namespaceUri, java.lang.String attributeName, java.lang.String xmlValue)
Sets the value by name and namespace of a non-ID attribute.void
setAttributeValueNs(java.lang.String namespaceUri, java.lang.String attributeName, java.lang.String xmlValue, boolean isIdAttribute)
Sets the attribute value by name and namespace.void
setAttributeValueNs(java.lang.String namespaceUri, java.lang.String attributeName, java.lang.String xmlValue, boolean isIdAttribute, boolean withReferenceUpdate)
Sets the attribute value by name and namespace.void
setTextContent(java.lang.String textContent)
Sets the text content of the DOM elementvoid
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.
-
-
-
Field Detail
-
modelInstance
protected final ModelInstanceImpl modelInstance
the containing model instance
-
-
Constructor Detail
-
ModelElementInstanceImpl
public ModelElementInstanceImpl(ModelTypeInstanceContext instanceContext)
-
-
Method Detail
-
registerType
public static void registerType(ModelBuilder modelBuilder)
-
getDomElement
public DomElement getDomElement()
Description copied from interface:ModelElementInstance
Returns the represented DOMDomElement
.- Specified by:
getDomElement
in interfaceModelElementInstance
- Returns:
- the DOM element
-
getModelInstance
public ModelInstanceImpl getModelInstance()
Description copied from interface:ModelElementInstance
Returns the model instance which contains this type instance.- Specified by:
getModelInstance
in interfaceModelElementInstance
- Returns:
- the model instance
-
getParentElement
public ModelElementInstance getParentElement()
Description copied from interface:ModelElementInstance
Returns the parent element of this.- Specified by:
getParentElement
in interfaceModelElementInstance
- Returns:
- the parent element
-
getElementType
public ModelElementType getElementType()
Description copied from interface:ModelElementInstance
Returns the element type of this.- Specified by:
getElementType
in interfaceModelElementInstance
- Returns:
- the element type
-
getAttributeValue
public java.lang.String getAttributeValue(java.lang.String attributeName)
Description copied from interface:ModelElementInstance
Returns the attribute value for the attribute name.- Specified by:
getAttributeValue
in interfaceModelElementInstance
- Parameters:
attributeName
- the name of the attribute- Returns:
- the value of the attribute
-
getAttributeValueNs
public java.lang.String getAttributeValueNs(java.lang.String namespaceUri, java.lang.String attributeName)
Description copied from interface:ModelElementInstance
Returns the attribute value for the given attribute name and namespace URI.- Specified by:
getAttributeValueNs
in interfaceModelElementInstance
- Parameters:
namespaceUri
- the namespace URI of the attributeattributeName
- the attribute name of the attribute- Returns:
- the value of the attribute
-
setAttributeValue
public void setAttributeValue(java.lang.String attributeName, java.lang.String xmlValue)
Description copied from interface:ModelElementInstance
Sets the value by name of a non-ID attribute.- Specified by:
setAttributeValue
in interfaceModelElementInstance
- Parameters:
attributeName
- the name of the attributexmlValue
- the value to set
-
setAttributeValue
public void setAttributeValue(java.lang.String attributeName, java.lang.String xmlValue, boolean isIdAttribute)
Description copied from interface:ModelElementInstance
Sets attribute value by name.- Specified by:
setAttributeValue
in interfaceModelElementInstance
- Parameters:
attributeName
- the name of the attributexmlValue
- the value to setisIdAttribute
- true if the attribute is an ID attribute, false otherwise
-
setAttributeValue
public void setAttributeValue(java.lang.String attributeName, java.lang.String xmlValue, boolean isIdAttribute, boolean withReferenceUpdate)
Description copied from interface:ModelElementInstance
Sets attribute value by name.- Specified by:
setAttributeValue
in interfaceModelElementInstance
- Parameters:
attributeName
- the name of the attributexmlValue
- the value to setisIdAttribute
- true if the attribute is an ID attribute, false otherwisewithReferenceUpdate
- true to update incoming references in other elements, false otherwise
-
setAttributeValueNs
public void setAttributeValueNs(java.lang.String namespaceUri, java.lang.String attributeName, java.lang.String xmlValue)
Description copied from interface:ModelElementInstance
Sets the value by name and namespace of a non-ID attribute.- Specified by:
setAttributeValueNs
in interfaceModelElementInstance
- Parameters:
namespaceUri
- the namespace URI of the attributeattributeName
- the name of the attributexmlValue
- the XML value to set
-
setAttributeValueNs
public void setAttributeValueNs(java.lang.String namespaceUri, java.lang.String attributeName, java.lang.String xmlValue, boolean isIdAttribute)
Description copied from interface:ModelElementInstance
Sets the attribute value by name and namespace.- Specified by:
setAttributeValueNs
in interfaceModelElementInstance
- Parameters:
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 otherwise
-
setAttributeValueNs
public void setAttributeValueNs(java.lang.String namespaceUri, java.lang.String attributeName, java.lang.String xmlValue, boolean isIdAttribute, boolean withReferenceUpdate)
Description copied from interface:ModelElementInstance
Sets the attribute value by name and namespace.- Specified by:
setAttributeValueNs
in interfaceModelElementInstance
- Parameters:
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 otherwisewithReferenceUpdate
- true to update incoming references in other elements, false otherwise
-
removeAttribute
public void removeAttribute(java.lang.String attributeName)
Description copied from interface:ModelElementInstance
Removes attribute by name.- Specified by:
removeAttribute
in interfaceModelElementInstance
- Parameters:
attributeName
- the name of the attribute
-
removeAttributeNs
public void removeAttributeNs(java.lang.String namespaceUri, java.lang.String attributeName)
Description copied from interface:ModelElementInstance
Removes the attribute by name and namespace.- Specified by:
removeAttributeNs
in interfaceModelElementInstance
- Parameters:
namespaceUri
- the namespace URI of the attributeattributeName
- the name of the attribute
-
getTextContent
public java.lang.String getTextContent()
Description copied from interface:ModelElementInstance
Returns the text content of the DOM element without leading and trailing spaces. For raw text content seegetRawTextContent()
.- Specified by:
getTextContent
in interfaceModelElementInstance
- Returns:
- text content of underlying DOM element with leading and trailing whitespace trimmed
-
setTextContent
public void setTextContent(java.lang.String textContent)
Description copied from interface:ModelElementInstance
Sets the text content of the DOM element- Specified by:
setTextContent
in interfaceModelElementInstance
- Parameters:
textContent
- the new text content
-
getRawTextContent
public java.lang.String getRawTextContent()
Description copied from interface:ModelElementInstance
Returns the raw text content of the DOM element including all whitespaces.- Specified by:
getRawTextContent
in interfaceModelElementInstance
- Returns:
- raw text content of underlying DOM element
-
getUniqueChildElementByNameNs
public ModelElementInstance getUniqueChildElementByNameNs(java.lang.String namespaceUri, java.lang.String elementName)
Description copied from interface:ModelElementInstance
Returns a child element with the given name or 'null' if no such element exists- Specified by:
getUniqueChildElementByNameNs
in interfaceModelElementInstance
- Parameters:
namespaceUri
- the local name of the elementelementName
- the namespace of the element- Returns:
- the child element or null.
-
getUniqueChildElementByType
public ModelElementInstance getUniqueChildElementByType(java.lang.Class<? extends ModelElementInstance> elementType)
Description copied from interface:ModelElementInstance
Returns a child element with the given type- Specified by:
getUniqueChildElementByType
in interfaceModelElementInstance
- Parameters:
elementType
- the type of the element- Returns:
- the child element or null
-
setUniqueChildElementByNameNs
public void setUniqueChildElementByNameNs(ModelElementInstance newChild)
Description copied from interface:ModelElementInstance
Adds or replaces a child element by name. Replaces an existing Child Element with the same name or adds a new child if no such element exists.- Specified by:
setUniqueChildElementByNameNs
in interfaceModelElementInstance
- Parameters:
newChild
- the child to add
-
replaceChildElement
public void replaceChildElement(ModelElementInstance existingChild, ModelElementInstance newChild)
Description copied from interface:ModelElementInstance
Replace an existing child element with a new child element. Changes the underlying DOM element tree.- Specified by:
replaceChildElement
in interfaceModelElementInstance
- Parameters:
existingChild
- the child element to replacenewChild
- the new child element
-
replaceWithElement
public void replaceWithElement(ModelElementInstance newElement)
Description copied from interface:ModelElementInstance
Replaces this element with a new element and updates references.- Specified by:
replaceWithElement
in interfaceModelElementInstance
- Parameters:
newElement
- the new element to replace with
-
addChildElement
public void addChildElement(ModelElementInstance newChild)
Description copied from interface:ModelElementInstance
Adds a new child element to the children of this element. The child is inserted at the correct position of the allowed child types. Updates the underlying DOM element tree.- Specified by:
addChildElement
in interfaceModelElementInstance
- Parameters:
newChild
- the new child element
-
removeChildElement
public boolean removeChildElement(ModelElementInstance child)
Description copied from interface:ModelElementInstance
Removes the child element from this.- Specified by:
removeChildElement
in interfaceModelElementInstance
- Parameters:
child
- the child element to remove- Returns:
- true if the child element could be removed
-
getChildElementsByType
public java.util.Collection<ModelElementInstance> getChildElementsByType(ModelElementType childElementType)
Description copied from interface:ModelElementInstance
Return all child elements of a given type- Specified by:
getChildElementsByType
in interfaceModelElementInstance
- Parameters:
childElementType
- the child element type to search for- Returns:
- a collection of elements of the given type
-
getChildElementsByType
public <T extends ModelElementInstance> java.util.Collection<T> getChildElementsByType(java.lang.Class<T> childElementClass)
Description copied from interface:ModelElementInstance
Return all child elements of a given type- Specified by:
getChildElementsByType
in interfaceModelElementInstance
- Parameters:
childElementClass
- the class of the child element type to search for- Returns:
- a collection of elements to the given type
-
insertElementAfter
public void insertElementAfter(ModelElementInstance elementToInsert, ModelElementInstance insertAfterElement)
Description copied from interface:ModelElementInstance
Inserts the new element after the given element or at the beginning if the given element is null.- Specified by:
insertElementAfter
in interfaceModelElementInstance
- Parameters:
elementToInsert
- the new element to insertinsertAfterElement
- the element to insert after or null to insert at first position
-
updateAfterReplacement
public void updateAfterReplacement()
Description copied from interface:ModelElementInstance
Execute updates after the element was inserted as a replacement of another element.- Specified by:
updateAfterReplacement
in interfaceModelElementInstance
-
asSet
protected <T> java.util.Set<T> asSet(T element, java.util.Set<T> elements)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-