ptolemy.moml
Class MoMLModelAttribute

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

public class MoMLModelAttribute
extends Attribute
implements Configurable

An attribute that has a model described in MoML. The MoML is specified by calling configure(URL, String, String), or by including the MoML within <configure> tags in a MoML file. The MoML is returned by the getConfigureText() method. The getContainedModel() method returns the model specified by the MoML.

When an instance of this attribute is exported to MoML, the MoML description above will be included in the exported MoML within <configure> tags.

An instance of this attribute may wish to override the default "Look Inside" behavior by including an instance of ptolemy.vergil.toolbox.MoMLModelAttributeControllerFactory as attribute contained by this instance. Instead of having an explicit compile-time dependency between this class and MoMLModelAttributeControllerFactory, derived classes should use MoML to set up the containment relationship. For example,

 
     
     
     
        ... my MoML text here ...
     
 
 

Since:
Ptolemy II 8.0
Version:
$Id: MoMLModelAttribute.java 59167 2010-09-21 17:08:02Z cxh $
Author:
Dai Bui, Edward Lee, Ben Lickly
See Also:
Serialized Form
Accepted Rating:
Red (tfeng)
Proposed Rating:
Red (tfeng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
protected  NamedObj _model
          The contained model.
 
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
MoMLModelAttribute(NamedObj container, java.lang.String name)
          Create a model attribute with the specified container and name.
 
Method Summary
protected  void _exportMoMLContents(java.io.Writer output, int depth)
          Write a MoML description this object, which includes a MoML description of the contained model within the <configure> tag.
 java.lang.Object clone(Workspace workspace)
          Return a clone of this model attribute.
 void configure(java.net.URL base, java.lang.String source, java.lang.String text)
          Construct and configure the contained model with the specified source and text.
 java.lang.String getConfigureSource()
          Return null.
 java.lang.String getConfigureText()
          Return the MoML description of the model, if there is one, and null otherwise.
 NamedObj getContainedModel()
          Return the contained model.
 
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

_model

protected NamedObj _model
The contained model. This is protected so that derived classes can provide a default model.

Constructor Detail

MoMLModelAttribute

public MoMLModelAttribute(NamedObj container,
                          java.lang.String name)
                   throws NameDuplicationException,
                          IllegalActionException
Create a model attribute with the specified container and name.

Parameters:
container - The specified container.
name - The specified name.
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

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Return a clone of this model attribute. This also creates a clone for the contained model.

Overrides:
clone in class Attribute
Parameters:
workspace - The workspace for the cloned object.
Returns:
A clone.
Throws:
java.lang.CloneNotSupportedException - Thrown if an error occurs while cloning the attribute or the contained model.
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
Construct and configure the contained model with the specified source and text. This parses the specified MoML text.

Specified by:
configure in interface Configurable
Parameters:
base - The base URL for relative references, or null if not known.
source - The URI of a document providing source, which is ignored in this class.
text - The MoML description.
Throws:
java.lang.Exception - If the parsing fails.

getConfigureSource

public java.lang.String getConfigureSource()
Return null. This class ignores the source attribute of a configure tag.

Specified by:
getConfigureSource in interface Configurable
Returns:
The configure source.

getConfigureText

public java.lang.String getConfigureText()
Return the MoML description of the model, if there is one, and null otherwise.

Specified by:
getConfigureText in interface Configurable
Returns:
The text to include in a configure tag.

getContainedModel

public NamedObj getContainedModel()
Return the contained model.

Returns:
The contained model.

_exportMoMLContents

protected void _exportMoMLContents(java.io.Writer output,
                                   int depth)
                            throws java.io.IOException
Write a MoML description this object, which includes a MoML description of the contained model within the <configure> tag.

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)