ptolemy.moml
Class MoMLAttribute

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

public class MoMLAttribute
extends Attribute

This attribute has an arbitrary MoML description that is exported when the exportMoML() methods of the container are called. Thus, it serves as a convenient way to attach persistent information that will not otherwise be exported to MoML. To specify its MoML description, call setMoMLDescription().

Since:
Ptolemy II 1.0
Version:
$Id: MoMLAttribute.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (reviewmoderator)
Proposed Rating:
Red (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
private  java.util.List _momlDescription
           
 
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
MoMLAttribute(NamedObj container, java.lang.String name)
          Construct an attribute with the specified container and name.
MoMLAttribute(Workspace workspace)
          Construct an attribute in the specified workspace with an empty string as a name.
 
Method Summary
 void appendMoMLDescription(java.lang.String moml)
          Append to the MoML description of this object.
 void exportMoML(java.io.Writer output, int depth, java.lang.String name)
          Write a MoML description of this object, which in this case is whatever has been specified by the setMoMLDescription() method.
 void writeMoMLDescription(java.io.Writer output, int depth)
          Write the MoML description of this object, which consists of whatever has been specified using the appendMoMLDescription() method.
 
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, 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

_momlDescription

private java.util.List _momlDescription
Constructor Detail

MoMLAttribute

public MoMLAttribute(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.

MoMLAttribute

public MoMLAttribute(NamedObj container,
                     java.lang.String name)
              throws IllegalActionException,
                     NameDuplicationException
Construct an attribute with the specified container and name.

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.
Method Detail

appendMoMLDescription

public void appendMoMLDescription(java.lang.String moml)
Append to the MoML description of this object.

Parameters:
moml - The MoML description of this object.

writeMoMLDescription

public void writeMoMLDescription(java.io.Writer output,
                                 int depth)
                          throws java.io.IOException
Write the MoML description of this object, which consists of whatever has been specified using the appendMoMLDescription() method. If that method has not been called, then nothing is written. The written MoML is indented to the specified depth and terminated with a newline.

Parameters:
output - The output stream to write to.
depth - The depth in the hierarchy, to determine indenting.
Throws:
java.io.IOException - If there is a problem writing the MoML.

exportMoML

public void exportMoML(java.io.Writer output,
                       int depth,
                       java.lang.String name)
                throws java.io.IOException
Write a MoML description of this object, which in this case is whatever has been specified by the setMoMLDescription() method. If that method has not been called, then nothing is written. The written MoML is indented to the specified depth and terminated with a newline. If this object is not persistent, then nothing is written.

Specified by:
exportMoML in interface MoMLExportable
Overrides:
exportMoML in class NamedObj
Parameters:
name - The name to use instead of the name of this object. This argument is ignored.
output - The output stream to write to.
depth - The depth in the hierarchy, to determine indenting.
Throws:
java.io.IOException - If there is a problem writing the MoML.
See Also:
NamedObj.isPersistent()