Class ModelUtil
- java.lang.Object
-
- org.camunda.bpm.model.xml.impl.util.ModelUtil
-
public final class ModelUtil extends java.lang.Object
Some Helpers useful when handling model elements.- Author:
- Daniel Meyer
-
-
Constructor Summary
Constructors Constructor Description ModelUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Collection<ModelElementType>
calculateAllBaseTypes(ModelElementType type)
Calculate a collection of all base types for the given typestatic java.util.Collection<ModelElementType>
calculateAllExtendingTypes(Model model, java.util.Collection<ModelElementType> baseTypes)
Calculate a collection of all extending types for the given base typesstatic void
ensureInstanceOf(java.lang.Object instance, java.lang.Class<?> type)
static int
getIndexOfElementType(ModelElementInstance modelElement, java.util.List<ModelElementType> childElementTypes)
Find the index of the type of a model element in a list of element typesstatic ModelElementInstance
getModelElement(DomElement domElement, ModelInstanceImpl modelInstance)
Returns theModelElement
for a DOM element.protected static ModelElementTypeImpl
getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, java.lang.String namespaceUri)
static ModelElementInstance
getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, ModelElementTypeImpl modelType)
Returns theModelElement
for a DOM element.static <T extends ModelElementInstance>
java.util.Collection<T>getModelElementCollection(java.util.Collection<DomElement> view, ModelInstanceImpl model)
Get a collection of all model element instances in a viewstatic QName
getQName(java.lang.String namespaceUri, java.lang.String localName)
static java.lang.String
getUniqueIdentifier(ModelElementType type)
static void
setGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance)
Set unique identifier if the type has a String id attributestatic void
setGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, boolean withReferenceUpdate)
Set unique identifier if the type has a String id attributestatic void
setNewIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, java.lang.String newId, boolean withReferenceUpdate)
Set new identifier if the type has a String id attributestatic boolean
valueAsBoolean(java.lang.String rawValue)
static double
valueAsDouble(java.lang.String rawValue)
static float
valueAsFloat(java.lang.String rawValue)
static int
valueAsInteger(java.lang.String rawValue)
static short
valueAsShort(java.lang.String rawValue)
static java.lang.String
valueAsString(boolean booleanValue)
static java.lang.String
valueAsString(double doubleValue)
static java.lang.String
valueAsString(float floatValue)
static java.lang.String
valueAsString(int integerValue)
static java.lang.String
valueAsString(short shortValue)
-
-
-
Method Detail
-
getModelElement
public static ModelElementInstance getModelElement(DomElement domElement, ModelInstanceImpl modelInstance)
Returns theModelElement
for a DOM element. If the model element does not yet exist, it is created and linked to the DOM.- Parameters:
domElement
- the child element to create a newModelElement
for- Returns:
- the child model element
-
getModelElement
public static ModelElementInstance getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, ModelElementTypeImpl modelType)
Returns theModelElement
for a DOM element. If the model element does not yet exist, it is created and linked to the DOM.- Parameters:
domElement
- the child element to create a newModelElement
formodelInstance
- theModelInstance
for which the newModelElement
is createdmodelType
- theModelElementType
to create a newModelElement
for- Returns:
- the child model element
-
getModelElement
protected static ModelElementTypeImpl getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, java.lang.String namespaceUri)
-
getQName
public static QName getQName(java.lang.String namespaceUri, java.lang.String localName)
-
ensureInstanceOf
public static void ensureInstanceOf(java.lang.Object instance, java.lang.Class<?> type)
-
valueAsBoolean
public static boolean valueAsBoolean(java.lang.String rawValue)
-
valueAsInteger
public static int valueAsInteger(java.lang.String rawValue)
-
valueAsFloat
public static float valueAsFloat(java.lang.String rawValue)
-
valueAsDouble
public static double valueAsDouble(java.lang.String rawValue)
-
valueAsShort
public static short valueAsShort(java.lang.String rawValue)
-
valueAsString
public static java.lang.String valueAsString(boolean booleanValue)
-
valueAsString
public static java.lang.String valueAsString(int integerValue)
-
valueAsString
public static java.lang.String valueAsString(float floatValue)
-
valueAsString
public static java.lang.String valueAsString(double doubleValue)
-
valueAsString
public static java.lang.String valueAsString(short shortValue)
-
getModelElementCollection
public static <T extends ModelElementInstance> java.util.Collection<T> getModelElementCollection(java.util.Collection<DomElement> view, ModelInstanceImpl model)
Get a collection of all model element instances in a view- Parameters:
view
- the collection of DOM elements to find the model element instances formodel
- the model of the elements- Returns:
- the collection of model element instances of the view
-
getIndexOfElementType
public static int getIndexOfElementType(ModelElementInstance modelElement, java.util.List<ModelElementType> childElementTypes)
Find the index of the type of a model element in a list of element types- Parameters:
modelElement
- the model element which type is searched forchildElementTypes
- the list to search the type- Returns:
- the index of the model element type in the list or -1 if it is not found
-
calculateAllExtendingTypes
public static java.util.Collection<ModelElementType> calculateAllExtendingTypes(Model model, java.util.Collection<ModelElementType> baseTypes)
Calculate a collection of all extending types for the given base types- Parameters:
baseTypes
- the collection of types to calculate the union of all extending types
-
calculateAllBaseTypes
public static java.util.Collection<ModelElementType> calculateAllBaseTypes(ModelElementType type)
Calculate a collection of all base types for the given type
-
setNewIdentifier
public static void setNewIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, java.lang.String newId, boolean withReferenceUpdate)
Set new identifier if the type has a String id attribute- Parameters:
type
- the type of the model elementmodelElementInstance
- the model element instance to set the idnewId
- new identifierwithReferenceUpdate
- true to update id references in other elements, false otherwise
-
setGeneratedUniqueIdentifier
public static void setGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance)
Set unique identifier if the type has a String id attribute- Parameters:
type
- the type of the model elementmodelElementInstance
- the model element instance to set the id
-
setGeneratedUniqueIdentifier
public static void setGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, boolean withReferenceUpdate)
Set unique identifier if the type has a String id attribute- Parameters:
type
- the type of the model elementmodelElementInstance
- the model element instance to set the idwithReferenceUpdate
- true to update id references in other elements, false otherwise
-
getUniqueIdentifier
public static java.lang.String getUniqueIdentifier(ModelElementType type)
-
-