public class StringAttribute extends AbstractSettableAttribute
attribute.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.
Settable.FULL
NamedObj.ContainedObjectsIterator
Settable.Visibility
_attributes, _changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
EXPERT, FULL, NONE, NOT_EDITABLE
Constructor and 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.
|
Modifier and Type | Method and 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.
|
getDefaultExpression, getValueAsString
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
_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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDisplayName
description, getContainer, getFullName, getName, getName, setName
public StringAttribute()
public StringAttribute(Workspace workspace)
workspace
- The workspace that will list the attribute.public StringAttribute(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this attribute.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.public void addValueListener(ValueListener listener)
listener
- The listener to add.removeValueListener(ValueListener)
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Attribute
workspace
- The workspace for the new object.java.lang.CloneNotSupportedException
- If any of the attributes
cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void exportMoML(java.io.Writer output, int depth, java.lang.String name) throws java.io.IOException
exportMoML
in interface MoMLExportable
exportMoML
in class NamedObj
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.java.io.IOException
- If an I/O error occurs.NamedObj.isPersistent()
public java.lang.String getExpression()
setExpression(String)
public Settable.Visibility getVisibility()
setVisibility(Settable.Visibility)
public void removeValueListener(ValueListener listener)
listener
- The listener to remove.addValueListener(ValueListener)
public void setExpression(java.lang.String expression) throws IllegalActionException
setExpression
in interface Settable
setExpression
in class AbstractSettableAttribute
expression
- The value of the string attribute.IllegalActionException
- If the change is not acceptable
to the container.getExpression()
public void setVisibility(Settable.Visibility visibility)
visibility
- The visibility of this attribute.getVisibility()
public java.util.Collection validate() throws IllegalActionException
IllegalActionException
- If the change is not acceptable
to the container.protected void _propagateValue(NamedObj destination) throws IllegalActionException
_propagateValue
in class NamedObj
destination
- Object to which to propagate the
value.IllegalActionException
- If the value cannot
be propagated.