public class UMLKindTransform extends UMLTransform
After an instance of this transform is created, the user registers its transformation elements (rules, extractors and transforms) along with the corresponding element kind (eClass) that the transformation element is designed to process. When the first transformation element is registered for a particular element kind, a new subtransform is created and the transformation element is added to that transform. Subsequent transformation elements registered for the same element kind are simply appended to that subtransform. Therefore, multiple transformation elements registered for the same element kind are executed in the order in which they were registered. After all transform elements of a given element kind are executed, the contents of the source is extracted and depending on the element kinds of the extracted element, the associated subtransform will execute on them next. For example, after all the "class" rules are executed for a given "class", the methods of that "class" will be extracted and the "method" rules will be executed on these methods.
The transformation elements are executed based upon an exact match of the element kind for the source UML2 object. For example, a rule that is registered to process "classifiers" will not be called for if the source UML2 element is a "class", even though "class" is derieved from "classifiers". In essence, this UMLKindTransform will only process leaf element kinds defined in the UML2 metamodel.
The UMLKindTransform is designed to process a UML model in a flat manner. The order in which elements of the model are processed is non-deterministic but is based upon the containment hierarchy (owned elements) of the UML model. As such, it is safe to assume that by the time a given element is to be processed, all of its parent elements have been previously processed. The order in which sibling elements are processed may vary from one execution run to the next.
Since the traversal order of the UML containment hierarchy is effectively flat, the execution context passed to all of the registered UML-kind rules will be the same. However, if a transform is registered for a UML element kind, it will be executed with its own context where the parent context is the shared context that registered rules receive.
With UMLKindTransform, rules (or subtransforms) should be only added using the addByKind() method and not the generic Transform add() method. Using the add() method is not recommended and doing so may have undesired results and performance issues because rules added in this manner will be executed for every element in the model.
Note: This type of transform cannot be defined in the transformation extension mechanism because there is currently no way to add a rule to this transform with the associated UML2 kind (eClass).
Constructor and Description |
---|
UMLKindTransform()
The default constructor should only be used internally by the
transformation service.
|
UMLKindTransform(ITransformationDescriptor descriptor)
Constructor for creating root transforms.
|
Modifier and Type | Method and Description |
---|---|
Transform |
addByKind(org.eclipse.emf.ecore.EClass elementKind,
AbstractTransformElement transformElement)
Add a transformation element for the given element kind.
|
ITransformContext |
createContext(ITransformContext parentContext) |
void |
execute(ITransformContext context) |
Transform |
findTransformByKind(org.eclipse.emf.ecore.EClass elementKind)
Retrieve the subtransform created for a specific element kind.
|
protected java.util.Collection |
getElements(ITransformContext context)
Dynamically build a list of transform elements based on source object.
|
protected void |
handle(java.lang.Exception exception,
ITransformContext context) |
public UMLKindTransform()
public UMLKindTransform(ITransformationDescriptor descriptor)
descriptor
- the corresponding transformation descriptorpublic ITransformContext createContext(ITransformContext parentContext)
public void execute(ITransformContext context) throws java.lang.Exception
java.lang.Exception
protected void handle(java.lang.Exception exception, ITransformContext context)
public Transform addByKind(org.eclipse.emf.ecore.EClass elementKind, AbstractTransformElement transformElement)
elementKind
- - An eClass meta object from UML2Package.transformElement
- - A transform element that will receive an elementpublic Transform findTransformByKind(org.eclipse.emf.ecore.EClass elementKind)
elementKind
- - An eClass meta object from UML2Package.protected java.util.Collection getElements(ITransformContext context)
com.ibm.xtools.transform.core.Transform#getElements(com.ibm.xtools.transform.core.ITransformContext)