public abstract class AbstractTransform extends AbstractTransformElement
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.
There are two types of transforms within the transformation element hierarchy: a root transform and internal transforms. For any given transformation, there is one root transform for every instance of that transformation. A new instance of a root transform should be returned by the transformation provider when requested. (@see AbstractTransformationProvider.createTransformation(ITransformationDescriptor descriptor))
Internal transforms are used within the transformation implementation to contain rules, content extractors and other transforms. If a transformation author does not want to use the default transformation engine, he only needs to create a root transform.
Root transforms always have an associated transformation descriptor, which enables the rules and extractors at execution time to have access to the formal properties defined by the transformation author (in the descriptor).
Typcially internal transforms do not have an associated descriptor, unless one transformation contains another transformation (i.e. a composite transformation).
Modifier and Type | Field and Description |
---|---|
static int |
CODE_OTHER
Something in the environment is invalid.
|
static int |
CODE_PROPERTY
Some other property is invalid.
|
static int |
CODE_SOURCE
Source property is invalid.
|
static int |
CODE_TARGET
Target property is invalid.
|
static int |
CODE_TARGET_CONTAINER
Target Container property is invalid.
|
static java.lang.String |
PROGRESS_MONITOR_WORK_UNITS
The id of the property transformations must declare if they want to
update the progress monitor.
|
Constructor and Description |
---|
AbstractTransform()
The default constructor should only be used internally by the
transformation service.
|
AbstractTransform(ITransformationDescriptor descriptor)
The constructor to be used when creating a root transform.
|
AbstractTransform(java.lang.String id)
This constructor should be used when creating a transform that is
internal within a transformation hierarchy.
|
Modifier and Type | Method and Description |
---|---|
ITransformContext |
createContext(ITransformContext parentContext)
Create an execution context associated with this transform.
|
abstract void |
execute(ITransformContext context)
Execute the transform with the given context.
|
protected int |
getProgressMonitorWorkUnits(ITransformContext context)
Returns the number of work units the transformation wants to use in the
progress monitor.
|
ITransformationDescriptor |
getTransformationDescriptor()
Retrieve the associated transformation descriptor.
|
protected java.lang.String |
getWorkUnitsPropertyId()
Returns the property id that stores the progress monitor work units in
the transform context.
|
org.eclipse.core.runtime.IStatus |
validateContext(ITransformContext context)
Validate the context for the transformation.
|
canAccept, getAcceptCondition, getDescription, getId, getName, getProgressMonitor, setAcceptCondition, setDescription, setId, setName
public static final int CODE_SOURCE
public static final int CODE_TARGET_CONTAINER
public static final int CODE_TARGET
public static final int CODE_PROPERTY
public static final int CODE_OTHER
public static final java.lang.String PROGRESS_MONITOR_WORK_UNITS
public AbstractTransform()
public AbstractTransform(java.lang.String id)
id
- the unique identifier of this transformpublic AbstractTransform(ITransformationDescriptor descriptor)
descriptor
- the associated transformation descriptorpublic ITransformContext createContext(ITransformContext parentContext)
parentContext
- the current context of the transformation executionpublic abstract void execute(ITransformContext context) throws java.lang.Exception
context
- the current context of the transformation executionjava.lang.Exception
public final ITransformationDescriptor getTransformationDescriptor()
public org.eclipse.core.runtime.IStatus validateContext(ITransformContext context)
This method can return either a single status object or multiple status objects depending upon the validation performed. If multiple warnings/errors are to be returned use a MultiStatus object. If one of its child status objects has a severity of ERROR, the multi-status is assumed to be an error.
A valid context should return a single status object with a severity of OK. A "null" return value indicates a major error (e.g., the service could not locate or load the provider).
context
- the context to be validatedMultiStatus
,
Status
protected int getProgressMonitorWorkUnits(ITransformContext context)
context
- The context that contains the property that specifies the
number of work units.IProgressMonitor.UNKNOWN
if nothing is specified.protected java.lang.String getWorkUnitsPropertyId()