Class Attribute

    • Constructor Detail

      • Attribute

        public Attribute()
        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.
      • Attribute

        public Attribute​(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.
      • Attribute

        public Attribute​(NamedObj container,
                         java.lang.String name)
                  throws IllegalActionException,
                         NameDuplicationException
        Construct an attribute with the given name contained by the specified entity. 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. 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.
      • Attribute

        protected Attribute​(NamedObj container,
                            java.lang.String name,
                            boolean incrementWorkspaceVersion)
                     throws IllegalActionException,
                            NameDuplicationException
        Construct an attribute with the given name contained by the specified entity. 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. Increment the version of the workspace.
        Parameters:
        container - The container.
        name - The name of this attribute.
        incrementWorkspaceVersion - False to not add this to the workspace or do anything else that might change the workspace version number.
        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 object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there). The result is an attribute with no container.
        Overrides:
        clone in class NamedObj
        Parameters:
        workspace - The workspace for the cloned object.
        Returns:
        The new Attribute.
        Throws:
        java.lang.CloneNotSupportedException - Not thrown in this base class
        See Also:
        NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)
      • moveDown

        public int moveDown()
                     throws IllegalActionException
        Move this object down by one in the list of attributes of its container. If this object is already last, do nothing. This method gets write access on workspace and increments the version.
        Specified by:
        moveDown in interface Moveable
        Overrides:
        moveDown in class NamedObj
        Returns:
        The index of the specified object prior to moving it, or -1 if it is not moved.
        Throws:
        IllegalActionException - If this object has no container.
      • moveToFirst

        public int moveToFirst()
                        throws IllegalActionException
        Move this object to the first position in the list of attributes of the container. If this object is already first, do nothing. This method gets write access on workspace and increments the version.
        Specified by:
        moveToFirst in interface Moveable
        Overrides:
        moveToFirst in class NamedObj
        Returns:
        The index of the specified object prior to moving it, or -1 if it is not moved.
        Throws:
        IllegalActionException - If this object has no container.
      • moveToIndex

        public int moveToIndex​(int index)
                        throws IllegalActionException
        Move this object to the specified position in the list of attributes of the container. If this object is already at the specified position, do nothing. This method gets write access on workspace and increments the version.
        Specified by:
        moveToIndex in interface Moveable
        Overrides:
        moveToIndex in class NamedObj
        Parameters:
        index - The zero based position to which this object is moved. 0 means the first position, 1 means the second position.
        Returns:
        The index of the specified object prior to moving it, or -1 if it is not moved.
        Throws:
        IllegalActionException - If this object has no container or if the index is out of bounds.
      • moveToLast

        public int moveToLast()
                       throws IllegalActionException
        Move this object to the last position in the list of attributes of the container. If this object is already last, do nothing. This method gets write access on workspace and increments the version.
        Specified by:
        moveToLast in interface Moveable
        Overrides:
        moveToLast in class NamedObj
        Returns:
        The index of the specified object prior to moving it, or -1 if it is not moved.
        Throws:
        IllegalActionException - If this object has no container.
      • moveUp

        public int moveUp()
                   throws IllegalActionException
        Move this object up by one in the list of attributes of the container. If this object is already first, do nothing. This method gets write access on workspace and increments the version.
        Specified by:
        moveUp in interface Moveable
        Overrides:
        moveUp in class NamedObj
        Returns:
        The index of the specified object prior to moving it, or -1 if it is not moved.
        Throws:
        IllegalActionException - If this object has no container.
      • setContainer

        public void setContainer​(NamedObj container)
                          throws IllegalActionException,
                                 NameDuplicationException
        Specify the container NamedObj, adding this attribute to the list of attributes in the container. If the container already contains an attribute with the same name, then throw an exception and do not make any changes. Similarly, if the container is not in the same workspace as this attribute, throw an exception. If this attribute is already contained by the NamedObj, do nothing. If the attribute already has a container, remove this attribute from its attribute list first. Otherwise, remove it from the directory of the workspace, if it is there. If the argument is null, then remove it from its container. It is not added to the workspace directory, so this could result in this object being garbage collected. Note that since an Attribute is a NamedObj, it can itself have attributes. However, recursive containment is not allowed, where an attribute is an attribute of itself, or indirectly of any attribute it contains. This method is write-synchronized on the workspace and increments its version number.

        Subclasses may constrain the type of container by overriding setContainer(NamedObj).

        Parameters:
        container - The container to attach this attribute to..
        Throws:
        IllegalActionException - If this attribute is not of the expected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.
        NameDuplicationException - If the container already has an attribute with the name of this attribute.
        See Also:
        getContainer()
      • updateContent

        public void updateContent()
                           throws InternalErrorException
        Update the content of this attribute. In this base class, nothing is performed. Subclasses need to override this class to update the attribute.
        Throws:
        InternalErrorException - Not thrown in this base class.
      • _checkContainer

        protected void _checkContainer​(NamedObj container)
                                throws IllegalActionException
        Check that the specified container is of a suitable class for this attribute. In this base class, this method returns immediately without doing anything.
        Parameters:
        container - The proposed container.
        Throws:
        IllegalActionException - If the container is not of an acceptable class. Not thrown in this base class.
      • _getContainedObject

        protected NamedObj _getContainedObject​(NamedObj container,
                                               java.lang.String relativeName)
                                        throws IllegalActionException
        Get an attribute with the specified name in the specified container. The type of object sought is an instance of the same class as this object. The returned object is assured of being an instance of the same class as this object.
        Overrides:
        _getContainedObject in class NamedObj
        Parameters:
        relativeName - The name relative to the container.
        container - The container expected to contain the object.
        Returns:
        An object of the same class as this object, or null if there is none.
        Throws:
        IllegalActionException - If the object exists and has the wrong class.
      • _propagateExistence

        protected NamedObj _propagateExistence​(NamedObj container)
                                        throws IllegalActionException
        Propagate existence of this object to the specified object. This overrides the base class to set the container.
        Overrides:
        _propagateExistence in class NamedObj
        Parameters:
        container - Object to contain the new object.
        Returns:
        A new object of the same class and name as this one.
        Throws:
        IllegalActionException - If the object cannot be cloned.