ptolemy.kernel.util
Class DecoratedAttributes

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.kernel.util.DecoratedAttributes
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
DecoratedAttributesImplementation

public abstract class DecoratedAttributes
extends Attribute

An abstract class that represents a number of decorated attributes.

A NamedObj can contain DecoratedAttributes. These are attributes that are added by another NamedObj, called a decorator to this NamedObj. An example is a code generator that has specific attributes such as parameters that control the code code generator. These attributes are added by the Decorator (the code generator), to the director (the "this" object). These attributes are stored separately and can be retrieved by using NamedObj.getDecoratorAttributes(Decorator) or NamedObj.getDecoratorAttributes(Decorator).

A DecoratedAttributes instance has a decorator and decoratored attributes. The container of this class is the object that is being decorated.

The implementation class is DecoratedAttributesImplementation, the functionality is divided in two classes to solve dependency issues.

Since:
Ptolemy II 8.0
Version:
$Id: DecoratedAttributes.java 59167 2010-09-21 17:08:02Z cxh $
Author:
Bert Rodiers
See Also:
Serialized Form
Accepted Rating:
Red (rodiers)
Proposed Rating:
Red (rodiers)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_attributes, _changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
DecoratedAttributes(NamedObj container, java.lang.String name)
          Construct a DecoratedAttributes instance with the given name and the container of the decorator.
 
Method Summary
protected abstract  StringAttribute _decoratorPath()
          Return the decorator path.
protected  void _register()
          Register this attribute again to the container.
 void exportToMoML(NamedObj container, java.io.Writer output, int depth)
          Export the Decorated attributes.
abstract  Decorator getDecorator()
          Return the decorator.
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, clone, 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, _exportMoMLContents, _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
 

Constructor Detail

DecoratedAttributes

public DecoratedAttributes(NamedObj container,
                           java.lang.String name)
                    throws IllegalActionException,
                           NameDuplicationException
Construct a DecoratedAttributes instance with the given name and the container of the decorator. 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 of this object.
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.
Method Detail

exportToMoML

public void exportToMoML(NamedObj container,
                         java.io.Writer output,
                         int depth)
                  throws InvalidStateException,
                         java.io.IOException
Export the Decorated attributes. This is a special method where we don't store the Decorated Attributes directly in the container, but we do it is another container (typically the container of the decorator) to make sure that when the model is parsed again, both the container of this object and the decorator are already parsed and hence all links can be corrected.

Parameters:
container - The container in which we store the the attribute. This typically is the container of the decorator.
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.
InvalidStateException - If a recursive structure is encountered, where this object directly or indirectly contains itself. Note that this is a runtime exception so it need not be declared explicitly.

getDecorator

public abstract Decorator getDecorator()
Return the decorator.

Returns:
The decorator.

_decoratorPath

protected abstract StringAttribute _decoratorPath()
Return the decorator path. It is the full path of the decorator in the model. This variable is used for persistence to recreate the code generator after having parsed the model.

Returns:
The full path of the decorator in the model.

_register

protected final void _register()
                        throws NameDuplicationException,
                               IllegalActionException
Register this attribute again to the container. This is necessary, since when opening the model, the decorator is not directly know, the container doesn't have the mapping between attribute and decorator.

Throws:
NameDuplicationException - If the container already has an attribute with the same name.
IllegalActionException - If the attribute is not an an instance of the expect class (in derived classes).