Class ModelUtil
java.lang.Object
org.camunda.bpm.model.xml.impl.util.ModelUtil
Some Helpers useful when handling model elements.
- Author:
- Daniel Meyer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<ModelElementType>Calculate a collection of all base types for the given typestatic Collection<ModelElementType>calculateAllExtendingTypes(Model model, Collection<ModelElementType> baseTypes) Calculate a collection of all extending types for the given base typesstatic voidensureInstanceOf(Object instance, Class<?> type) static intgetIndexOfElementType(ModelElementInstance modelElement, List<ModelElementType> childElementTypes) Find the index of the type of a model element in a list of element typesstatic ModelElementInstancegetModelElement(DomElement domElement, ModelInstanceImpl modelInstance) Returns theModelElementfor a DOM element.protected static ModelElementTypeImplgetModelElement(DomElement domElement, ModelInstanceImpl modelInstance, String namespaceUri) static ModelElementInstancegetModelElement(DomElement domElement, ModelInstanceImpl modelInstance, ModelElementTypeImpl modelType) Returns theModelElementfor a DOM element.static <T extends ModelElementInstance>
Collection<T>getModelElementCollection(Collection<DomElement> view, ModelInstanceImpl model) Get a collection of all model element instances in a viewstatic QNamestatic Stringstatic voidsetGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance) Set unique identifier if the type has a String id attributestatic voidsetGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, boolean withReferenceUpdate) Set unique identifier if the type has a String id attributestatic voidsetNewIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, String newId, boolean withReferenceUpdate) Set new identifier if the type has a String id attributestatic booleanvalueAsBoolean(String rawValue) static doublevalueAsDouble(String rawValue) static floatvalueAsFloat(String rawValue) static intvalueAsInteger(String rawValue) static shortvalueAsShort(String rawValue) static StringvalueAsString(boolean booleanValue) static StringvalueAsString(double doubleValue) static StringvalueAsString(float floatValue) static StringvalueAsString(int integerValue) static StringvalueAsString(short shortValue)
-
Constructor Details
-
ModelUtil
public ModelUtil()
-
-
Method Details
-
getModelElement
public static ModelElementInstance getModelElement(DomElement domElement, ModelInstanceImpl modelInstance) Returns theModelElementfor 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 newModelElementfor- Returns:
- the child model element
-
getModelElement
public static ModelElementInstance getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, ModelElementTypeImpl modelType) Returns theModelElementfor 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 newModelElementformodelInstance- theModelInstancefor which the newModelElementis createdmodelType- theModelElementTypeto create a newModelElementfor- Returns:
- the child model element
-
getModelElement
protected static ModelElementTypeImpl getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, String namespaceUri) -
getQName
-
ensureInstanceOf
-
valueAsBoolean
-
valueAsInteger
-
valueAsFloat
-
valueAsDouble
-
valueAsShort
-
valueAsString
-
valueAsString
-
valueAsString
-
valueAsString
-
valueAsString
-
getModelElementCollection
public static <T extends ModelElementInstance> Collection<T> getModelElementCollection(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, 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 Collection<ModelElementType> calculateAllExtendingTypes(Model model, 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
Calculate a collection of all base types for the given type -
setNewIdentifier
public static void setNewIdentifier(ModelElementType type, ModelElementInstance modelElementInstance, 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
-