com.ashridgetech.jamda.transform
Class BasicTransformer

java.lang.Object
  |
  +--com.ashridgetech.jamda.transform.AbstractModelTransformer
        |
        +--com.ashridgetech.jamda.transform.BasicTransformer
All Implemented Interfaces:
ModelTransformer
Direct Known Subclasses:
ClassCreatorTransformer

public class BasicTransformer
extends AbstractModelTransformer

A basics for ModelTransformer implementation that applies a given ElementTransformer to ModelElements with a given Stereotype. May be subclassed for more specialised transformations. Must be configured with the class of the ElementTransformer to apply as well as the configuration required by AbstractModelTransformer.

Author:
Paul Boocock version 1.0
See Also:
BasicTransformerSpec

Nested Class Summary
 
Nested classes inherited from class com.ashridgetech.jamda.transform.AbstractModelTransformer
AbstractModelTransformer.Config
 
Nested classes inherited from class com.ashridgetech.jamda.transform.ModelTransformer
ModelTransformer.TransformException
 
Constructor Summary
BasicTransformer()
           
 
Method Summary
 java.lang.String getDescription()
          Get a short description of this transformer, including details of its configuration.
 java.lang.Class getElementTransformerClass()
          Get the class which will process the selected elements.
 java.lang.Class getElementTransformerSuperclass()
          Get the class which must be the superclass of any class set by setElementTransformerClass(java.lang.Class).
protected  ElementTransformer makeElementTransformer(ModelElement element)
          Create an ElementTransformer which can process the source element.
 void setElementTransformerClass(java.lang.Class elementTransformerClass)
          Set the class which will process the selected elements.
 void setElementTransformerSuperclass(java.lang.Class elementTransformerSuperclass)
          Set the class which must be the superclass of any class set by setElementTransformerClass(java.lang.Class).
 java.util.Collection standardElementDefs()
          Get the definitions of the standard model elements required by the transformer.
 void transform(Model model)
          Process the selected elements in a Model.
 void validateTransformerClass(java.lang.Class elementTransformerClass)
          Validate the elementTransformerClass passed to setElementTransformerClass(java.lang.Class).
 
Methods inherited from class com.ashridgetech.jamda.transform.AbstractModelTransformer
addStereotypeName, getConfig, getStereotypeNames, selectElements, setStereotypeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicTransformer

public BasicTransformer()
Method Detail

getElementTransformerClass

public java.lang.Class getElementTransformerClass()
Get the class which will process the selected elements.

Returns:
the transformer class
See Also:
setElementTransformerClass(java.lang.Class)

setElementTransformerClass

public void setElementTransformerClass(java.lang.Class elementTransformerClass)
                                throws ModelTransformer.TransformException
Set the class which will process the selected elements. Calls validateTransformerClass(java.lang.Class) to check elementTransformerClass.

Parameters:
elementTransformerClass - the transformer class
ModelTransformer.TransformException

getElementTransformerSuperclass

public java.lang.Class getElementTransformerSuperclass()
Get the class which must be the superclass of any class set by setElementTransformerClass(java.lang.Class).

Returns:
the superclass of the transformer class - might be null
See Also:
setElementTransformerClass(java.lang.Class), setElementTransformerSuperclass(java.lang.Class)

setElementTransformerSuperclass

public void setElementTransformerSuperclass(java.lang.Class elementTransformerSuperclass)
Set the class which must be the superclass of any class set by setElementTransformerClass(java.lang.Class). This is used by validateTransformerClass(java.lang.Class) to check the class passed to setElementTransformerClass(java.lang.Class).

Parameters:
elementTransformerSuperclass - the transformer class - may be null. The class must implement ElementTransformer.

validateTransformerClass

public void validateTransformerClass(java.lang.Class elementTransformerClass)
                              throws ModelTransformer.TransformException
Validate the elementTransformerClass passed to setElementTransformerClass(java.lang.Class). This implementation checks that the elementTransformerClass is assignable to the class returned getElementTransformerSuperclass(), if it is not null.

Parameters:
elementTransformerClass - the class to validate
Throws:
TransformException - if the class is not valid for some reason
ModelTransformer.TransformException

transform

public void transform(Model model)
               throws ModelTransformer.TransformException
Process the selected elements in a Model.

Parameters:
model - the Model on which to operate
ModelTransformer.TransformException

getDescription

public java.lang.String getDescription()
Get a short description of this transformer, including details of its configuration.

Specified by:
getDescription in interface ModelTransformer
Overrides:
getDescription in class AbstractModelTransformer
Returns:
the description

standardElementDefs

public java.util.Collection standardElementDefs()
                                         throws ModelTransformer.TransformException
Get the definitions of the standard model elements required by the transformer. The convention used is:
If the class set in setElementTransformerClass(java.lang.Class) has a public static method called standardElementDefs, which returns a Collection, call it and return its return value. Otherwise return an empty Collection.

Specified by:
standardElementDefs in interface ModelTransformer
Overrides:
standardElementDefs in class AbstractModelTransformer
Returns:
${inheritdoc}
ModelTransformer.TransformException

makeElementTransformer

protected ElementTransformer makeElementTransformer(ModelElement element)
                                             throws ModelTransformer.TransformException
Create an ElementTransformer which can process the source element. The default action of this implementation is to attempt to create an instance of the class set in setElementTransformerClass(java.lang.Class), passing element to its constructor.

Parameters:
element - the UML element for which the transformer is needed
Returns:
the transformer
ModelTransformer.TransformException


Copyright © 2003 Ashridge Technologies Ltd. All Rights Reserved.