ptolemy.moml
Class ParserAttribute

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.util.Attribute
          extended byptolemy.kernel.util.SingletonAttribute
              extended byptolemy.moml.ParserAttribute
All Implemented Interfaces:
Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, Singleton

public class ParserAttribute
extends SingletonAttribute

This attribute represents a MoML parser. If it is present in an entity that is the context for a MoMLChangeRequest, then that change request will use it to parse the changes. It is not a persistent attribute (exportMoML() writes nothing). It is a singleton, meaning that if it is inserted into a container that already contains a singleton attribute with the same name, then it will replace the previous attribute.

By default, this attribute is not persistent, so it will not be present in a MoML representation of its container.

Since:
Ptolemy II 1.0
Version:
$Id: ParserAttribute.java,v 1.16 2004/04/13 03:46:54 cxh Exp $
Author:
Edward A. Lee
See Also:
MoMLChangeRequest, Serialized Form
Accepted Rating:
Red (reviewmoderator)
Proposed Rating:
Red (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
ParserAttribute(NamedObj container, java.lang.String name)
          Construct an attribute with the specified container and name.
 
Method Summary
 MoMLParser getParser()
          Get the parser.
static MoMLParser getParser(NamedObj object)
          Get a parser for the specified object.
 void setParser(MoMLParser parser)
          Set the parser.
 
Methods inherited from class ptolemy.kernel.util.SingletonAttribute
setContainer
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, clone, getContainer, setName
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParserAttribute

public ParserAttribute(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

getParser

public MoMLParser getParser()
Get the parser. If none has been set, then return a new one.

Returns:
A MoML parser.

getParser

public static MoMLParser getParser(NamedObj object)
Get a parser for the specified object. This searches up the hierarchy until it finds a container of the specified object that contains an instance of ParserAttribute. If none is found, then a new ParserAttribute is created at the top level.

Parameters:
object - The object for which to find an associated parser.
Throws:
java.lang.NullPointerException - If the argument is null.

setParser

public void setParser(MoMLParser parser)
Set the parser.

Parameters:
parser - The parser.