Package ptolemy.moml

Class ParserAttribute

  • All Implemented Interfaces:
    java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, 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$
    Author:
    Edward A. Lee
    See Also:
    MoMLChangeRequest
    Pt.AcceptedRating:
    Red (reviewmoderator)
    Pt.ProposedRating:
    Red (eal)
    • 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

      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Clone the attribute into the specified workspace. The resulting object a null value for the value of the parser.
        Overrides:
        clone in class Attribute
        Parameters:
        workspace - The workspace for the cloned object.
        Returns:
        A new attribute.
        Throws:
        java.lang.CloneNotSupportedException - If a derived class contains an attribute that cannot be cloned.
        See Also:
        NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)
      • getParser

        public MoMLParser getParser()
        Get the parser. If none has been set, then return a new one.
        Returns:
        A MoML parser.
        See Also:
        setParser(MoMLParser)
      • 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.
        Returns:
        The parser for the specified object.
        Throws:
        java.lang.NullPointerException - If the argument is null.
        See Also:
        setParser(MoMLParser)