Class StringAttribute

    • Constructor Detail

      • StringAttribute

        public StringAttribute()
        Construct an attribute in the default workspace with an empty string as its name. The object is added to the directory of the workspace. Increment the version number of the workspace.
      • StringAttribute

        public StringAttribute​(Workspace workspace)
        Construct an attribute in the specified workspace with an empty string as a name. 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.
      • StringAttribute

        public StringAttribute​(NamedObj container,
                               java.lang.String name)
                        throws IllegalActionException,
                               NameDuplicationException
        Construct an attribute with the given name contained by the specified container. 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. The object is added to the directory of the workspace if the container is null. Increment the version of the workspace.
        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

      • addValueListener

        public void addValueListener​(ValueListener listener)
        Add a listener to be notified when the value of this attribute changes. If the listener is already on the list of listeners, then do nothing.
        Parameters:
        listener - The listener to add.
        See Also:
        removeValueListener(ValueListener)
      • 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, unless it is non-persistent. MoML is an XML modeling markup language. In this class, the object is identified by the "property" element, with "name", "class", and "value" (XML) attributes. The body of the element, between the "<property>" and "</property>", is written using the _exportMoMLContents() protected method, so that derived classes can override that method alone to alter only how the contents of this object are described. The text that is written is indented according to the specified depth, with each line (including the last one) terminated with a newline.
        Specified by:
        exportMoML in interface MoMLExportable
        Overrides:
        exportMoML in class NamedObj
        Parameters:
        output - The output stream to write to.
        depth - The depth in the hierarchy, to determine indenting.
        name - The name to use instead of the current name.
        Throws:
        java.io.IOException - If an I/O error occurs.
        See Also:
        NamedObj.isPersistent()
      • getExpression

        public java.lang.String getExpression()
        Get the value that has been set by setExpression(), or null if there is none.
        Returns:
        The string value.
        See Also:
        setExpression(String)
      • removeValueListener

        public void removeValueListener​(ValueListener listener)
        Remove a listener from the list of listeners that is notified when the value of this attribute changes. If no such listener exists, do nothing.
        Parameters:
        listener - The listener to remove.
        See Also:
        addValueListener(ValueListener)
      • setVisibility

        public void setVisibility​(Settable.Visibility visibility)
        Set the visibility of this attribute. The argument should be one of the public static instances in Settable.
        Parameters:
        visibility - The visibility of this attribute.
        See Also:
        getVisibility()
      • validate

        public java.util.Collection validate()
                                      throws IllegalActionException
        Do nothing. There is no need to notify the container or listeners of this attribute because they have presumably already been notified in setExpression().
        Returns:
        Null, indicating that no other instances of Settable are validated.
        Throws:
        IllegalActionException - If the change is not acceptable to the container.
      • _propagateValue

        protected void _propagateValue​(NamedObj destination)
                                throws IllegalActionException
        Propagate the value of this object to the specified object. The specified object is required to be an instance of the same class as this one, or a ClassCastException will be thrown.
        Overrides:
        _propagateValue in class NamedObj
        Parameters:
        destination - Object to which to propagate the value.
        Throws:
        IllegalActionException - If the value cannot be propagated.