ptolemy.actor.gt.controller
Class TransformationAttribute

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.gt.controller.TransformationAttribute
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, GTAttribute, Changeable, Configurable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class TransformationAttribute
extends Attribute
implements Configurable, GTAttribute

An attribute encapsulating a model transformation with the Ptera controller. The transformation can be applied to the container of this attribute either manually by the model user, or automatically by invoking the executeTransformation() method.

Since:
Ptolemy II 8.0
Version:
$Id: TransformationAttribute.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Thomas Huining Feng
See Also:
Serialized Form
Accepted Rating:
Red (tfeng)
Proposed Rating:
Yellow (tfeng)

Nested Class Summary
private  class TransformationAttribute.TransformationListener
          An execution listener that sets the model parameter to contain the container of the transformation attribute at the beginning of the transformation.
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
private  Configurer _configurer
          The configurer containing the model updater.
private  java.lang.String _configureSource
          The configure source.
private  java.util.List<ExecutionListener> _executionListeners
          The list of execution listeners.
private  PteraModalModel _modelUpdater
          The model updater.
 Parameter condition
          The condition under which this attribute is applicable.
 TransformationAttributeEditorFactory editorFactory
          The editor factory for the contents in this attribute (the model updater).
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
TransformationAttribute(NamedObj container, java.lang.String name)
          Construct an attribute with the given name contained by the specified entity.
TransformationAttribute(Workspace workspace)
          Construct an attribute in the specified workspace with an empty string as a name.
 
Method Summary
private static void _clearURI(NamedObj object)
          Clear the URI attribute of the given object.
protected  void _exportMoMLContents(java.io.Writer output, int depth)
          Write a MoML description of the contents of this object, which in this base class is the attributes.
private  void _init()
          Create the parameters and private fields of this attribute.
 void addExecutionListener(ExecutionListener listener)
          Add an execution listener to the list of execution listeners, which are invoked at specific points when the transformation is executed.
 java.lang.Object clone(Workspace workspace)
          Clone the object into the specified workspace.
 void configure(java.net.URL base, java.lang.String source, java.lang.String text)
          Configure the object with data from the specified input source (a URL) and/or textual data.
 void executeTransformation()
          Execute the transformation with the container of this attribute as the model to be transformed.
 void executeTransformation(CompositeEntity model)
          Execute the transformation with the given model as the model to be transformed.
 java.lang.String getConfigureSource()
          Return the input source that was specified the last time the configure method was called.
 java.lang.String getConfigureText()
          Return the text string that represents the current configuration of this object.
 PteraModalModel getModelUpdater()
          Get the model updater encapsulated in this attribute.
 void removeExecutionListener(ExecutionListener listener)
          Remove an execution listener from the list of execution listeners, which\ are invoked at specific points when the transformation is executed.
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

condition

public Parameter condition
The condition under which this attribute is applicable. It must evaluate to a BooleanToken. If its value is false, execution of the transformation causes no effect.


editorFactory

public TransformationAttributeEditorFactory editorFactory
The editor factory for the contents in this attribute (the model updater).


_configureSource

private java.lang.String _configureSource
The configure source.


_configurer

private Configurer _configurer
The configurer containing the model updater.


_executionListeners

private java.util.List<ExecutionListener> _executionListeners
The list of execution listeners.


_modelUpdater

private PteraModalModel _modelUpdater
The model updater.

Constructor Detail

TransformationAttribute

public TransformationAttribute(NamedObj container,
                               java.lang.String name)
                        throws NameDuplicationException,
                               IllegalActionException
Construct an attribute with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.

Parameters:
container - The container.
name - The name of this attribute.
Throws:
IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
NameDuplicationException - If the name coincides with an attribute already in the container.

TransformationAttribute

public TransformationAttribute(Workspace workspace)
Construct an attribute in the specified workspace with an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace. The object is added to the directory of the workspace. Increment the version number of the workspace.

Parameters:
workspace - The workspace that will list the attribute.
Method Detail

addExecutionListener

public void addExecutionListener(ExecutionListener listener)
Add an execution listener to the list of execution listeners, which are invoked at specific points when the transformation is executed.

Parameters:
listener - The listener.
See Also:
removeExecutionListener(ExecutionListener)

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there). The result is an attribute with no container.

Overrides:
clone in class Attribute
Parameters:
workspace - The workspace for the cloned object.
Returns:
The new Attribute.
Throws:
java.lang.CloneNotSupportedException - Not thrown in this base class
See Also:
NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)

configure

public void configure(java.net.URL base,
                      java.lang.String source,
                      java.lang.String text)
               throws java.lang.Exception
Configure the object with data from the specified input source (a URL) and/or textual data. The object should interpret the source first, if it is specified, followed by the literal text, if that is specified. The new configuration should usually override any old configuration wherever possible, in order to ensure that the current state can be successfully retrieved.

This method is defined to throw a very general exception to allow classes that implement the interface to use whatever exceptions are appropriate.

Specified by:
configure in interface Configurable
Parameters:
base - The base relative to which references within the input are found, or null if this is not known, or there is none.
source - The input source, which specifies a URL, or null if none.
text - Configuration information given as text, or null if none.
Throws:
java.lang.Exception - If something goes wrong.

executeTransformation

public void executeTransformation()
                           throws java.lang.Exception
Execute the transformation with the container of this attribute as the model to be transformed.

Throws:
java.lang.Exception - If error occurs in the transformation.
See Also:
executeTransformation(CompositeEntity)

executeTransformation

public void executeTransformation(CompositeEntity model)
                           throws java.lang.Exception
Execute the transformation with the given model as the model to be transformed.

Parameters:
model - The model to be transformed.
Throws:
java.lang.Exception - If error occurs in the transformation.

getConfigureSource

public java.lang.String getConfigureSource()
Return the input source that was specified the last time the configure method was called.

Specified by:
getConfigureSource in interface Configurable
Returns:
The string representation of the input URL, or null if the no source has been used to configure this object, or null if no external source need be used to configure this object.

getConfigureText

public java.lang.String getConfigureText()
Return the text string that represents the current configuration of this object. Note that any configuration that was previously specified using the source attribute need not be represented here as well.

Specified by:
getConfigureText in interface Configurable
Returns:
A configuration string, or null if no configuration has been used to configure this object, or null if no configuration string need be used to configure this object.

getModelUpdater

public PteraModalModel getModelUpdater()
Get the model updater encapsulated in this attribute.

Returns:
The model updater.

removeExecutionListener

public void removeExecutionListener(ExecutionListener listener)
Remove an execution listener from the list of execution listeners, which\ are invoked at specific points when the transformation is executed.

Parameters:
listener - The listener to be removed.
See Also:
addExecutionListener(ExecutionListener)

_exportMoMLContents

protected void _exportMoMLContents(java.io.Writer output,
                                   int depth)
                            throws java.io.IOException
Write a MoML description of the contents of this object, which in this base class is the attributes. This method is called by _exportMoML(). If there are attributes, then each attribute description is indented according to the specified depth and terminated with a newline character. Callers of this method should hold read access before calling this method. Note that exportMoML() does this for us.

Overrides:
_exportMoMLContents in class NamedObj
Parameters:
output - The output stream to write to.
depth - The depth in the hierarchy, to determine indenting.
Throws:
java.io.IOException - If an I/O error occurs.
See Also:
NamedObj.exportMoML(Writer, int)

_clearURI

private static void _clearURI(NamedObj object)
                       throws IllegalActionException
Clear the URI attribute of the given object.

Parameters:
object - The object.
Throws:
IllegalActionException - If the URI attribute of the object cannot be removed.

_init

private void _init()
            throws IllegalActionException,
                   NameDuplicationException
Create the parameters and private fields of this attribute.

Throws:
IllegalActionException - If thrown when creating the parameters.
NameDuplicationException - If thrown when creating the parameters.