|
IBM Rational Software Modeler Release 6.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.xtools.transform.core.AbstractTransformElement
com.ibm.xtools.transform.core.AbstractRule
The Abstract Rule class is the base class for all target model processing that occurs within the default transformation engine.
In the default transformation engine, transforms are containers that traverse the transformation element hierarchy, executing extractors, rules and nested transforms. Extractors effectively walk the source model and rules create or update the target model.
A rule is responsible for converting an object from the source model into an object in the target model. Before a rule is executed, it must accept the execution context which contains properties that define the source object, the target container (within target model). The context also contains transformation specific properties. When the rule is executed, it has the option of determining if the target object already exists and if so, simply perfom an update of that object. Alternately, the rule must create the target object if it does not exist.
There are several methods in this base class that enable this functionality,
which is effectively persisting and looking up a "derived" relationship
between the target object and the source object. The mapTarget()
method enables the rule to save the derived relationship and the
findTarget()
method can use the saved relationships to
locate the existing target object so that it can be updated (not recreated).
Constructor Summary | |
AbstractRule()
The default constructor should only be used internally by the transformation service. |
|
AbstractRule(String id,
String name)
Constructor to create a rule. |
Method Summary | |
protected abstract Object |
createTarget(ITransformContext context)
Create a new target object based on the source in the context. |
Object |
execute(ITransformContext context)
When a rule is executed, it will: determine whether a target object already exists. |
protected Object |
findTarget(ITransformContext context)
Return a target object if it already exists. |
boolean |
isSourceConsumed(ITransformContext context)
Determine if the source object is to be consumed by this rule. |
protected void |
mapTarget(ITransformContext context,
Object target)
Create a mapping from the source object to the target object so that it can be found when findTarget() is called. |
String |
toString()
|
protected void |
updateTarget(ITransformContext context,
Object target)
When an existing target object is found, this update method is called to refresh any stale information in the target based on the new context. |
Methods inherited from class com.ibm.xtools.transform.core.AbstractTransformElement |
canAccept, getAcceptCondition, getDescription, getId, getName, getProgressMonitor, setAcceptCondition, setDescription, setId, setName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public AbstractRule()
public AbstractRule(String id, String name)
id
- A unique identifier for the rule.name
- The name of the rule.Method Detail |
protected abstract Object createTarget(ITransformContext context) throws Exception
context
- the current context of the transformation execution
Exception
public Object execute(ITransformContext context) throws Exception
context
- the current context of the transformation execution
Exception
public boolean isSourceConsumed(ITransformContext context)
When a source object is consumed, all sibling rules, extractors and transforms in the same parent transform are skipped (not executed) for the source object. By default, a rule does not consume the source. To change this behaviour, the concrete rule class must override this method.
context
- the current context of the transformation execution
protected Object findTarget(ITransformContext context)
context
- the current context of the transformation execution
protected void mapTarget(ITransformContext context, Object target)
context
- the current context of the transformation executiontarget
- the target object created by the rule.public String toString()
Object.toString()
protected void updateTarget(ITransformContext context, Object target) throws Exception
Subclasses can override this method to modify any attributes of an existing target object.
context
- the current context of the transformation executiontarget
- the previously created object (returned by findTarget())
Exception
|
IBM Rational Software Modeler Release 6.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2004. All rights reserved.