Package ptolemy.kernel.util
Class Attribute
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- All Implemented Interfaces:
java.lang.Cloneable,Changeable,Debuggable,DebugListener,Derivable,ModelErrorHandler,MoMLExportable,Moveable,Nameable
- Direct Known Subclasses:
AbstractInitializableAttribute,AbstractLayoutConfiguration,AbstractSettableAttribute,ActorConstraintsDefinitionAttribute,AttributeMatcher,ChicInvoker,CollectLatticeOntologySolverDetails,ConceptFunctionDefinitionAttribute,ConfigurableAttribute,Configurer.ContainmentExtender,ContainmentExtender,ContextMenuFactoryCreator,DecorationParameters,DecoratorAttributes,DependencyDeclaration,DesignPatternImporter,Director,DocBuilder,EditorFactory,EditorIcon,EditorPaneFactory,ExceptionAnalyzer,GenericCodeGenerator,GiottoCodeGenerator,GUIAction,GUIProperty,HighlightEntities,ImportAttribute,KeplerDocumentationAttribute,MappingEditor,MatchingAttribute,MathematicalModelConverter,ModelRepaintController,MoMLAttribute,MoMLModelAttribute,OntologyMoMLHandler,ParameterEditorStyle,RefinementExtender,RefinementSuggestion,SchedulePlotter,Scheduler,ScopeExtendingAttribute,SingletonAttribute,TableauFactory,TDLCodeGenerator,TestInstantiableAttribute,TransformationAttribute,UnitCategory,VisibleAttribute,WebExportParameters
public class Attribute extends NamedObj
Attribute is a base class for attributes to be attached to instances of NamedObj. This base class is itself a NamedObj, with the only extension being that it can have a container. The setContainer() method puts this object on the list of attributes of the container.- Since:
- Ptolemy II 0.2
- Version:
- $Id$
- Author:
- Edward A. Lee, Neil Smyth
- Pt.AcceptedRating:
- Green (johnr)
- Pt.ProposedRating:
- Green (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Constructor Summary
Constructors Modifier Constructor Description Attribute()Construct an attribute in the default workspace with an empty string as its name.Attribute(NamedObj container, java.lang.String name)Construct an attribute with the given name contained by the specified entity.protectedAttribute(NamedObj container, java.lang.String name, boolean incrementWorkspaceVersion)Construct an attribute with the given name contained by the specified entity.Attribute(Workspace workspace)Construct an attribute in the specified workspace with an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_checkContainer(NamedObj container)Check that the specified container is of a suitable class for this attribute.protected NamedObj_getContainedObject(NamedObj container, java.lang.String relativeName)Get an attribute with the specified name in the specified container.protected NamedObj_propagateExistence(NamedObj container)Propagate existence of this object to the specified object.java.lang.Objectclone(Workspace workspace)Clone the object into the specified workspace.NamedObjgetContainer()Get the NamedObj that this Attribute is attached to.intmoveDown()Move this object down by one in the list of attributes of its container.intmoveToFirst()Move this object to the first position in the list of attributes of the container.intmoveToIndex(int index)Move this object to the specified position in the list of attributes of the container.intmoveToLast()Move this object to the last position in the list of attributes of the container.intmoveUp()Move this object up by one in the list of attributes of the container.voidsetContainer(NamedObj container)Specify the container NamedObj, adding this attribute to the list of attributes in the container.voidsetName(java.lang.String name)Set the name of the attribute.voidupdateContent()Update the content of this attribute.-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, 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, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
-
-
-
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:
clonein classNamedObj- 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 IllegalActionExceptionMove 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:
moveDownin interfaceMoveable- Overrides:
moveDownin classNamedObj- 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 IllegalActionExceptionMove 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:
moveToFirstin interfaceMoveable- Overrides:
moveToFirstin classNamedObj- 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 IllegalActionExceptionMove 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:
moveToIndexin interfaceMoveable- Overrides:
moveToIndexin classNamedObj- 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 IllegalActionExceptionMove 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:
moveToLastin interfaceMoveable- Overrides:
moveToLastin classNamedObj- 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 IllegalActionExceptionMove 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:
moveUpin interfaceMoveable- Overrides:
moveUpin classNamedObj- 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.
-
getContainer
public NamedObj getContainer()
Get the NamedObj that this Attribute is attached to.- Specified by:
getContainerin interfaceNameable- Overrides:
getContainerin classNamedObj- Returns:
- The container, an instance of NamedObj.
- See Also:
setContainer(NamedObj)
-
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()
-
setName
public void setName(java.lang.String name) throws IllegalActionException, NameDuplicationExceptionSet the name of the attribute. If there is already an attribute of the container with the same name, then throw a NameDuplicationException.- Specified by:
setNamein interfaceNameable- Overrides:
setNamein classNamedObj- Parameters:
name- The new name.- Throws:
IllegalActionException- If the name contains a period.NameDuplicationException- If there is already an attribute with the same name in the container.- See Also:
NamedObj.getName(),NamedObj.getName(NamedObj)
-
updateContent
public void updateContent() throws InternalErrorExceptionUpdate 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:
_getContainedObjectin classNamedObj- 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:
_propagateExistencein classNamedObj- 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.
-
-