ptolemy.kernel
Class DecoratedAttributesImplementation

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

public class DecoratedAttributesImplementation
extends DecoratedAttributes

A class that represents a number of decorated attributed. The functionality is divided in two classes (DecoratedAttributes and this class) to solve dependency issues. See DecoratedAttributes for more information.

Since:
Ptolemy II 8.0
Version:
$Id: DecoratedAttributesImplementation.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
private  Decorator _decorator
          The decorater.
private  StringAttribute _decoratorPath
          The decorater path.
 
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
DecoratedAttributesImplementation(NamedObj container, Decorator decorator)
          Construct a DecoratedAttribute from the container and the decorator.
DecoratedAttributesImplementation(NamedObj containerOfDecorator, java.lang.String name)
          Deprecated.  
 
Method Summary
protected  void _addAttribute(Attribute p)
          Add an attribute.
protected  StringAttribute _decoratorPath()
          Return the decorator path.
private static NamedObj _getRealContainer(NamedObj containerOfCodeGenerator, java.lang.String name)
          Find the real container of this object.
 void attributeChanged(Attribute attribute)
          React to a change in an attribute.
 java.lang.Object clone(Workspace workspace)
          Clone the object into the specified workspace.
static java.util.List<Decorator> findDecorators(NamedObj object)
          Return all the decorators for a given object.
 Decorator getDecorator()
          Return the decorator.
 
Methods inherited from class ptolemy.kernel.util.DecoratedAttributes
_register, exportToMoML
 
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
_adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, 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

_decorator

private Decorator _decorator
The decorater.


_decoratorPath

private StringAttribute _decoratorPath
The decorater path. This variable is used for persistence to recreate the code generator after having parsed the model.

Constructor Detail

DecoratedAttributesImplementation

public DecoratedAttributesImplementation(NamedObj container,
                                         Decorator decorator)
                                  throws IllegalActionException,
                                         NameDuplicationException
Construct a DecoratedAttribute from the container and the decorator.

Parameters:
container - The container this object.
decorator - The decorator.
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.

DecoratedAttributesImplementation

public DecoratedAttributesImplementation(NamedObj containerOfDecorator,
                                         java.lang.String name)
                                  throws IllegalActionException,
                                         NameDuplicationException
Deprecated. 

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. WARNING: don't use this constructor director. This should only be used by the MoMLParser.

Parameters:
containerOfDecorator - The container of the decorator.
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

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
React to a change in an attribute. This method is called by a contained attribute when its value changes. In this base class, the method does nothing. In derived classes, this method may throw an exception, indicating that the new attribute value is invalid. It is up to the caller to restore the attribute to a valid value if an exception is thrown.

Overrides:
attributeChanged in class NamedObj
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the change is not acceptable to this container (not thrown in this base class).

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 a DecoratedAttributes object 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)

findDecorators

public static java.util.List<Decorator> findDecorators(NamedObj object)
Return all the decorators for a given object.

Parameters:
object - The object.
Returns:
The decorators for the given object.

getDecorator

public Decorator getDecorator()
Return the decorator.

Specified by:
getDecorator in class DecoratedAttributes
Returns:
The decorator.

_addAttribute

protected void _addAttribute(Attribute p)
                      throws NameDuplicationException,
                             IllegalActionException
Add an attribute. This method should not be used directly. Instead, call setContainer() on the attribute. Derived classes may further constrain the class of the attribute. To do this, they should override this method to throw an exception when the argument is not an instance of the expected class. This method is write-synchronized on the workspace and increments its version number.

Overrides:
_addAttribute in class NamedObj
Parameters:
p - The attribute to be added.
Throws:
NameDuplicationException - If this object already has an attribute with the same name.
IllegalActionException - If the attribute is not an an instance of the expect class (in derived classes).

_decoratorPath

protected 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.

Specified by:
_decoratorPath in class DecoratedAttributes
Returns:
The full path of the decorator in the model.

_getRealContainer

private static NamedObj _getRealContainer(NamedObj containerOfCodeGenerator,
                                          java.lang.String name)
Find the real container of this object.

Parameters:
containerOfCodeGenerator - The container of the decorator.
name - The name of this attribute.
Returns:
The container of this object.