IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.transform.core
Interface ITransformContext


public interface ITransformContext

The Transform Context is the interface for setting and getting property values during the execution of a transformation.

The hierarchical nature of source models and the recursive nature of the transformation hierarchy require that the context in which the transforms, extractors and rules are executed must be kept in a stack-like fashion. ITransformContext is responsible for maintaining this execution contextual information, which includes the current source, target and target container objects. It also includes a local property table that enables rules to define data that can be accessed by sibling rules or by rules in nested transforms.

A new execution context object is created each time a transform is executed. All rules and extractors associated with the transform use the same context instance so if one rule defines a property, a sibling rule can access or modify that property. When a nested transform is executed, a new execution context created that is linked to its parent context. Therefore, rules within the nested transforms have access to the properties defined in the parent context(s), in addition to the properties defined in their own context. However, the properties in the parent context(s) are read-only.

An execute context has its own local property table and its associated transform may have a transformation descriptor with properties. Setting a value for a property defined in the descriptor results in an entry in the local property table, if the descriptor property is read-write. The default property values in the actual descriptor cannot be changed via the execute context. Properties may also be defined in a parent context but again, setting a new value will not change the value in the parent context. The property is simply added to the local table which temporarily overrides the value in the parent context.


Field Summary
static String CURRENT_ELEMENT
          The current transform element being executed.
static String PROGRESS_MONITOR
          The progress monitor to be used for this transformation execution.
static String SOURCE
          The source object property id.
static String TARGET
          The target object corresponding to the source object property id.
static String TARGET_CONTAINER
          The target container object property id.
 
Method Summary
 ITransformContext getParentContext()
          Get the parent execution context.
 String[] getPropertyIds()
          Retrieve a list of property identifiers in this context.
 Object getPropertyValue(String propertyId)
          Get the value of a property that is defined within the context of the transformation being executed.
 Object getSource()
          Get the source object that the transformation element is to process
 Object getTarget()
          Get the target object that the transformation element is to use
 Object getTargetContainer()
          Get the target container object that the transformation element is to use
 AbstractTransform getTransform()
          Get the transform associated with this context.
 boolean setPropertyValue(String propertyId, Object data)
          Set a property value in the transformation execution context.
 

Field Detail

SOURCE

public static final String SOURCE
The source object property id.

See Also:
Constant Field Values

TARGET_CONTAINER

public static final String TARGET_CONTAINER
The target container object property id.

See Also:
Constant Field Values

TARGET

public static final String TARGET
The target object corresponding to the source object property id.

See Also:
Constant Field Values

PROGRESS_MONITOR

public static final String PROGRESS_MONITOR
The progress monitor to be used for this transformation execution.

See Also:
Constant Field Values

CURRENT_ELEMENT

public static final String CURRENT_ELEMENT
The current transform element being executed.

See Also:
Constant Field Values
Method Detail

getParentContext

public ITransformContext getParentContext()
Get the parent execution context.

If the parent context is null, context is the root of the transformation.

Returns:
ITransformContext - the context of the parent transform

getPropertyIds

public String[] getPropertyIds()
Retrieve a list of property identifiers in this context.

Returns:
A list of property IDs.

getPropertyValue

public Object getPropertyValue(String propertyId)
Get the value of a property that is defined within the context of the transformation being executed.

This method checks the property table in the current execution context and if the property does not exist, the property table in the parent context is checked recursively. If the context for the root transform does not contain the property, the transformation descriptors associated with the transforms are then checked.

Parameters:
propertyId - the ID of the property
Returns:
Object - the property value or null if property not defined

getSource

public Object getSource()
Get the source object that the transformation element is to process

Returns:
Object - the source object the rule is to process

getTarget

public Object getTarget()
Get the target object that the transformation element is to use

Returns:
Object - the target object the rule is to process

getTargetContainer

public Object getTargetContainer()
Get the target container object that the transformation element is to use

Returns:
Object - the source object the rule is to process

getTransform

public AbstractTransform getTransform()
Get the transform associated with this context.

A transformation may have several nested transforms. When each transform is executed, a new execution context is created and is linked into the existing context execution stack.

Returns:
AbstractTransform - the transform being executed

setPropertyValue

public boolean setPropertyValue(String propertyId,
                                Object data)
Set a property value in the transformation execution context. If the property has been defined by the transformation descriptor and is read-only, the property value cannot be set.

Parameters:
propertyId - the ID of the property being set
data - the data object for the property value
Returns:
boolean - true if property was set, false if property is read-only

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.