Class StringAttribute
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.kernel.util.AbstractSettableAttribute
-
- ptolemy.kernel.util.StringAttribute
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,Settable
- Direct Known Subclasses:
Action
,ChicAttribute
,Documentation
,FileAttribute
,GraphTransformer.ReplacementObjectAttribute
,GTIngredientsAttribute
,InvalidStringAttribute
,OntologyAnnotationAttribute
,PatternObjectAttribute
,VersionAttribute
,WebAttribute
,WebElement
public class StringAttribute extends AbstractSettableAttribute
An attribute that has a string value. Use setExpression() to define the value, as in for exampleattribute.setExpression("xxx");
The default value of the string contained by this attribute is the empty string.
By default, an instance of this class is fully visible in a user interface. The visibility is indicated to the user interface when the user interface calls the getVisibility() method of this class and the value Settable.FULL is returned to the userInterface.
Note that the string value within StringAttribute cannot reference other StringAttributes or Parameters, so if an actor has a public StringAttribute, then one cannot make the value of that attribute dependent on a value higher in the hierarchy. Usually, actors have public ptolemy.data.expr.Parameters instead of public StringAttributes so that the value can reference other parameters. The primary reason to use StringAttribute is if you want a string that will not be parsed and you do not want to type a leading a trailing double quote.
- Since:
- Ptolemy II 1.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- See Also:
Settable.FULL
- Pt.AcceptedRating:
- Green (cxh)
- Pt.ProposedRating:
- Green (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
Nested classes/interfaces inherited from interface ptolemy.kernel.util.Settable
Settable.Visibility
-
-
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
-
Fields inherited from interface ptolemy.kernel.util.Settable
EXPERT, FULL, NONE, NOT_EDITABLE
-
-
Constructor Summary
Constructors Constructor Description StringAttribute()
Construct an attribute in the default workspace with an empty string as its name.StringAttribute(NamedObj container, java.lang.String name)
Construct an attribute with the given name contained by the specified container.StringAttribute(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
_propagateValue(NamedObj destination)
Propagate the value of this object to the specified object.void
addValueListener(ValueListener listener)
Add a listener to be notified when the value of this attribute changes.java.lang.Object
clone(Workspace workspace)
Clone the object into the specified workspace.void
exportMoML(java.io.Writer output, int depth, java.lang.String name)
Write a MoML description of this object, unless it is non-persistent.java.lang.String
getExpression()
Get the value that has been set by setExpression(), or null if there is none.Settable.Visibility
getVisibility()
Get the visibility of this attribute, as set by setVisibility().void
removeValueListener(ValueListener listener)
Remove a listener from the list of listeners that is notified when the value of this attribute changes.void
setExpression(java.lang.String expression)
Set the value of the string attribute and notify the container of the value of this attribute by calling attributeChanged().void
setVisibility(Settable.Visibility visibility)
Set the visibility of this attribute.java.util.Collection
validate()
Do nothing.-
Methods inherited from class ptolemy.kernel.util.AbstractSettableAttribute
getDefaultExpression, getValueAsString
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
-
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, _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, 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
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getFullName, getName, getName, setName
-
Methods inherited from interface ptolemy.kernel.util.Settable
getDisplayName
-
-
-
-
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)
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace.- Overrides:
clone
in classAttribute
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new NamedObj.
- Throws:
java.lang.CloneNotSupportedException
- If any of the attributes cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
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 interfaceMoMLExportable
- Overrides:
exportMoML
in classNamedObj
- 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)
-
getVisibility
public Settable.Visibility getVisibility()
Get the visibility of this attribute, as set by setVisibility(). The visibility is set by default to FULL.- Returns:
- The visibility of this attribute.
- See Also:
setVisibility(Settable.Visibility)
-
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)
-
setExpression
public void setExpression(java.lang.String expression) throws IllegalActionException
Set the value of the string attribute and notify the container of the value of this attribute by calling attributeChanged(). Notify any value listeners of this attribute.- Specified by:
setExpression
in interfaceSettable
- Overrides:
setExpression
in classAbstractSettableAttribute
- Parameters:
expression
- The value of the string attribute.- Throws:
IllegalActionException
- If the change is not acceptable to the container.- See Also:
getExpression()
-
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 classNamedObj
- Parameters:
destination
- Object to which to propagate the value.- Throws:
IllegalActionException
- If the value cannot be propagated.
-
-