Package ptolemy.actor.gt.controller
Class TransformationAttribute
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.actor.gt.controller.TransformationAttribute
-
- All Implemented Interfaces:
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 theexecuteTransformation()
method.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Thomas Huining Feng
- Pt.AcceptedRating:
- Red (tfeng)
- Pt.ProposedRating:
- Yellow (tfeng)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description 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, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, 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, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
-
-
-
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).
-
-
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 classAttribute
- 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 interfaceConfigurable
- 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 interfaceConfigurable
- 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 interfaceConfigurable
- 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 classNamedObj
- 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)
-
-