org.camunda.bpm.model.xml.impl.instance
Class ModelElementInstanceImpl

java.lang.Object
  extended by org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl
All Implemented Interfaces:
ModelElementInstance

public class ModelElementInstanceImpl
extends Object
implements ModelElementInstance

Base class for implementing Model Elements.

Author:
Daniel Meyer

Field Summary
protected  ModelInstanceImpl modelInstance
          the containing model instance
 
Constructor Summary
ModelElementInstanceImpl(ModelTypeInstanceContext instanceContext)
           
 
Method Summary
 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>
Collection<T>
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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

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 DOM DomElement.

Specified by:
getDomElement in interface ModelElementInstance
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 interface ModelElementInstance
Returns:
the model instance

getParentElement

public ModelElementInstance getParentElement()
Description copied from interface: ModelElementInstance
Returns the parent element of this.

Specified by:
getParentElement in interface ModelElementInstance
Returns:
the parent element

getElementType

public ModelElementType getElementType()
Description copied from interface: ModelElementInstance
Returns the element type of this.

Specified by:
getElementType in interface ModelElementInstance
Returns:
the element type

getAttributeValue

public String getAttributeValue(String attributeName)
Description copied from interface: ModelElementInstance
Returns the attribute value for the attribute name.

Specified by:
getAttributeValue in interface ModelElementInstance
Parameters:
attributeName - the name of the attribute
Returns:
the value of the attribute

getAttributeValueNs

public String getAttributeValueNs(String namespaceUri,
                                  String attributeName)
Description copied from interface: ModelElementInstance
Returns the attribute value for the given attribute name and namespace URI.

Specified by:
getAttributeValueNs in interface ModelElementInstance
Parameters:
namespaceUri - the namespace URI of the attribute
attributeName - the attribute name of the attribute
Returns:
the value of the attribute

setAttributeValue

public void setAttributeValue(String attributeName,
                              String xmlValue)
Description copied from interface: ModelElementInstance
Sets the value by name of a non-ID attribute.

Specified by:
setAttributeValue in interface ModelElementInstance
Parameters:
attributeName - the name of the attribute
xmlValue - the value to set

setAttributeValue

public void setAttributeValue(String attributeName,
                              String xmlValue,
                              boolean isIdAttribute)
Description copied from interface: ModelElementInstance
Sets attribute value by name.

Specified by:
setAttributeValue in interface ModelElementInstance
Parameters:
attributeName - the name of the attribute
xmlValue - the value to set
isIdAttribute - true if the attribute is an ID attribute, false otherwise

setAttributeValueNs

public void setAttributeValueNs(String namespaceUri,
                                String attributeName,
                                String xmlValue)
Description copied from interface: ModelElementInstance
Sets the value by name and namespace of a non-ID attribute.

Specified by:
setAttributeValueNs in interface ModelElementInstance
Parameters:
namespaceUri - the namespace URI of the attribute
attributeName - the name of the attribute
xmlValue - the XML value to set

setAttributeValueNs

public void setAttributeValueNs(String namespaceUri,
                                String attributeName,
                                String xmlValue,
                                boolean isIdAttribute)
Description copied from interface: ModelElementInstance
Sets the attribute value by name and namespace.

Specified by:
setAttributeValueNs in interface ModelElementInstance
Parameters:
namespaceUri - the namespace URI of the attribute
attributeName - the name of the attribute
xmlValue - the XML value to set
isIdAttribute - true if the attribute is an ID attribute, false otherwise

removeAttribute

public void removeAttribute(String attributeName)
Description copied from interface: ModelElementInstance
Removes attribute by name.

Specified by:
removeAttribute in interface ModelElementInstance
Parameters:
attributeName - the name of the attribute

removeAttributeNs

public void removeAttributeNs(String namespaceUri,
                              String attributeName)
Description copied from interface: ModelElementInstance
Removes the attribute by name and namespace.

Specified by:
removeAttributeNs in interface ModelElementInstance
Parameters:
namespaceUri - the namespace URI of the attribute
attributeName - the name of the attribute

getTextContent

public String getTextContent()
Description copied from interface: ModelElementInstance
Returns the text content of the DOM element without leading and trailing spaces. For raw text content see getRawTextContent().

Specified by:
getTextContent in interface ModelElementInstance
Returns:
text content of underlying DOM element with leading and trailing whitespace trimmed

setTextContent

public void setTextContent(String textContent)
Description copied from interface: ModelElementInstance
Sets the text content of the DOM element

Specified by:
setTextContent in interface ModelElementInstance
Parameters:
textContent - the new text content

getRawTextContent

public String getRawTextContent()
Description copied from interface: ModelElementInstance
Returns the raw text content of the DOM element including all whitespaces.

Specified by:
getRawTextContent in interface ModelElementInstance
Returns:
raw text content of underlying DOM element

getUniqueChildElementByNameNs

public ModelElementInstance getUniqueChildElementByNameNs(String namespaceUri,
                                                          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 interface ModelElementInstance
Parameters:
namespaceUri - the local name of the element
elementName - the namespace of the element
Returns:
the child element or null.

getUniqueChildElementByType

public ModelElementInstance getUniqueChildElementByType(Class<? extends ModelElementInstance> elementType)
Description copied from interface: ModelElementInstance
Returns a child element with the given type

Specified by:
getUniqueChildElementByType in interface ModelElementInstance
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 interface ModelElementInstance
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 interface ModelElementInstance
Parameters:
existingChild - the child element to replace
newChild - 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 interface ModelElementInstance
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 interface ModelElementInstance
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 interface ModelElementInstance
Parameters:
child - the child element to remove
Returns:
true if the child element could be removed

getChildElementsByType

public Collection<ModelElementInstance> getChildElementsByType(ModelElementType childElementType)
Description copied from interface: ModelElementInstance
Return all child elements of a given type

Specified by:
getChildElementsByType in interface ModelElementInstance
Parameters:
childElementType - the child element type to search for
Returns:
a collection of elements of the given type

getChildElementsByType

public <T extends ModelElementInstance> Collection<T> getChildElementsByType(Class<T> childElementClass)
Description copied from interface: ModelElementInstance
Return all child elements of a given type

Specified by:
getChildElementsByType in interface ModelElementInstance
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 interface ModelElementInstance
Parameters:
elementToInsert - the new element to insert
insertAfterElement - 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 interface ModelElementInstance

asSet

protected <T> Set<T> asSet(T... elements)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2015 camunda services GmbH. All rights reserved.