org.camunda.bpm.model.xml.impl.util
Class ModelUtil

java.lang.Object
  extended by org.camunda.bpm.model.xml.impl.util.ModelUtil

public final class ModelUtil
extends Object

Some Helpers useful when handling model elements.

Author:
Daniel Meyer

Constructor Summary
ModelUtil()
           
 
Method Summary
static Collection<ModelElementType> calculateAllBaseTypes(ModelElementType type)
          Calculate a collection of all base types for the given type
static Collection<ModelElementType> calculateAllExtendingTypes(Model model, Collection<ModelElementType> baseTypes)
          Calculate a collection of all extending types for the given base types
static void ensureInstanceOf(Object instance, Class<?> type)
           
static int getIndexOfElementType(ModelElementInstance modelElement, List<ModelElementType> childElementTypes)
          Find the index of the type of a model element in a list of element types
static ModelElementInstance getModelElement(DomElement domElement, ModelInstanceImpl modelInstance)
          Returns the ModelElement for a DOM element.
protected static ModelElementTypeImpl getModelElement(DomElement domElement, ModelInstanceImpl modelInstance, String namespaceUri)
           
static
<T extends ModelElementInstance>
Collection<T>
getModelElementCollection(Collection<DomElement> view, ModelInstanceImpl model)
          Get a collection of all model element instances in a view
static QName getQName(String namespaceUri, String localName)
           
static String getUniqueIdentifier(ModelElementType type)
           
static void setGeneratedUniqueIdentifier(ModelElementType type, ModelElementInstance modelElementInstance)
          Set unique identifier if the type has a String id attribute
static boolean valueAsBoolean(String rawValue)
           
static double valueAsDouble(String rawValue)
           
static float valueAsFloat(String rawValue)
           
static int valueAsInteger(String rawValue)
           
static short valueAsShort(String rawValue)
           
static String valueAsString(boolean booleanValue)
           
static String valueAsString(double doubleValue)
           
static String valueAsString(float floatValue)
           
static String valueAsString(int integerValue)
           
static String valueAsString(short shortValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelUtil

public ModelUtil()
Method Detail

getModelElement

public static ModelElementInstance getModelElement(DomElement domElement,
                                                   ModelInstanceImpl modelInstance)
Returns the ModelElement 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 new ModelElement for
Returns:
the child model element

getModelElement

protected static ModelElementTypeImpl getModelElement(DomElement domElement,
                                                      ModelInstanceImpl modelInstance,
                                                      String namespaceUri)

getQName

public static QName getQName(String namespaceUri,
                             String localName)

ensureInstanceOf

public static void ensureInstanceOf(Object instance,
                                    Class<?> type)

valueAsBoolean

public static boolean valueAsBoolean(String rawValue)

valueAsInteger

public static int valueAsInteger(String rawValue)

valueAsFloat

public static float valueAsFloat(String rawValue)

valueAsDouble

public static double valueAsDouble(String rawValue)

valueAsShort

public static short valueAsShort(String rawValue)

valueAsString

public static String valueAsString(boolean booleanValue)

valueAsString

public static String valueAsString(int integerValue)

valueAsString

public static String valueAsString(float floatValue)

valueAsString

public static String valueAsString(double doubleValue)

valueAsString

public static String valueAsString(short shortValue)

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 for
model - 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 for
childElementTypes - 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

public static Collection<ModelElementType> calculateAllBaseTypes(ModelElementType type)
Calculate a collection of all base types for the given type


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 element
modelElementInstance - the model element instance to set the id

getUniqueIdentifier

public static String getUniqueIdentifier(ModelElementType type)


Copyright © 2016 camunda services GmbH. All rights reserved.