Class Parameter
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,HasTypeConstraints
,Typeable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,Settable
,ValueListener
- Direct Known Subclasses:
AbstractInitializableParameter
,BaseUnit
,ColorAttribute
,ConstraintMonitor
,ContainerIgnoringAttribute
,DoubleRangeParameter
,Event.EventParameter
,ExpertParameter
,GTParameter
,HierarchyFlatteningAttribute
,IntRangeParameter
,IterativeParameter
,LocationAttribute
,LocationParameter
,ModelParameter
,Priority
,PtalonParameter
,RelationCollapsingAttribute
,RelationHidingAttribute
,SequenceAttribute
,SharedParameter
,SingletonParameter
,SizeAttribute
,StringParameter
,SynchronizeToRealtime
,TableauParameter
,TypeAttribute
,UnitConversionInfo
,WindowPropertiesAttribute
public class Parameter extends Variable
Parameter extends Variable with additional support for string-valued variables that makes these friendlier at the user interface level. In particular, this class supports an annotation that specifies choices for values. A user interface can use this to present a choice dialog that offers the specified values. This is typically used when a particular set of choices make sense. The values can be any expression, or if used in conjunction with string mode, any string.
By default, an instance of Parameter, unlike Variable, is persistent.
By convention, an instance of NamedObj has a set of attributes, some of which are visible to users and some of which are not. When a user interface presents these attributes for editing, it presents only those that are visible. By default, an instance of Parameter is visible, as indicated by the fact that it returns FULL in its getVisibility() method. This can be overridden by calling setVisibility().
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.data.expr.Variable
Variable.CircularDependencyError, Variable.VariableScope
-
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.data.expr.Variable
_currentExpression, _needsEvaluation, _parserScope, _parseTreeValid, _suppressVariableSubstitution, _valueListeners
-
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 Parameter()
Construct a parameter in the default workspace with an empty string as its name.Parameter(NamedObj container, java.lang.String name)
Construct a parameter with the given name contained by the specified entity.Parameter(NamedObj container, java.lang.String name, Token token)
Construct a Parameter with the given container, name, and Token.Parameter(Workspace workspace)
Construct a parameter in the specified workspace with an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChoice(java.lang.String choice)
Add a choice.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 this object is not persistent.java.lang.String[]
getChoices()
Get choices.void
removeAllChoices()
Remove all the choices.void
removeChoice(java.lang.String choice)
Remove a choice.-
Methods inherited from class ptolemy.data.expr.Variable
_description, _evaluate, _getCurrentExpression, _notifyValueListeners, _parseIfNecessary, _propagate, _propagateToValueListeners, _propagateValue, _setToken, _setTokenAndNotify, addValueListener, attributeChanged, getDeclaredType, getExpression, getFreeIdentifiers, getParserScope, getScope, getScope, getToken, getType, getTypeTerm, getValueAsString, getVariable, getVisibility, invalidate, isKnown, isLazy, isStringMode, isSuppressVariableSubstitution, isTypeAcceptable, removeValueListener, reset, setContainer, setExpression, setLazy, setName, setParseTreeEvaluator, setStringMode, setSuppressVariableSubstitution, setToken, setToken, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, setUnknown, setValueListenerAsWeakDependency, setVisibility, stringRepresentation, toString, typeConstraintList, typeConstraints, validate, valueChanged
-
Methods inherited from class ptolemy.kernel.util.AbstractSettableAttribute
getDefaultExpression
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, 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, 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
-
Methods inherited from interface ptolemy.kernel.util.Settable
getDisplayName
-
-
-
-
Constructor Detail
-
Parameter
public Parameter()
Construct a parameter in the default workspace with an empty string as its name. The parameter is added to the list of objects in the workspace. Increment the version number of the workspace.
-
Parameter
public Parameter(Workspace workspace)
Construct a parameter 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 list of objects in the workspace. Increment the version number of the workspace.- Parameters:
workspace
- The workspace that will list the parameter.
-
Parameter
public Parameter(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a parameter with the given name contained by the specified entity. The container argument must not be null, or a NullPointerException will be thrown. This parameter 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 not added to the list of objects in the workspace unless the container is null. Increment the version of the workspace.- Parameters:
container
- The container.name
- The name of the parameter.- Throws:
IllegalActionException
- If the parameter is not of an acceptable class for the container.NameDuplicationException
- If the name coincides with a parameter already in the container.
-
Parameter
public Parameter(NamedObj container, java.lang.String name, Token token) throws IllegalActionException, NameDuplicationException
Construct a Parameter with the given container, name, and Token. The container argument must not be null, or a NullPointerException will be thrown. This parameter 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 not added to the list of objects in the workspace unless the container is null. Increment the version of the workspace. If the name argument is null, then the name is set to the empty string.- Parameters:
container
- The container.name
- The name.token
- The Token contained by this Parameter.- Throws:
IllegalActionException
- If the parameter is not of an acceptable class for the container.NameDuplicationException
- If the name coincides with an parameter already in the container.
-
-
Method Detail
-
addChoice
public void addChoice(java.lang.String choice)
Add a choice.- Parameters:
choice
- A choice to offer to the user.- See Also:
removeChoice(String)
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace.
-
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 this object is not persistent. MoML is an XML modeling markup language. In this class, the object is identified by the "property" element, with "name" and "class" (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()
-
getChoices
public java.lang.String[] getChoices()
Get choices.- Returns:
- An array of choices, or null if there are none.
- See Also:
addChoice(String)
-
removeAllChoices
public void removeAllChoices()
Remove all the choices.- See Also:
removeChoice(String)
-
removeChoice
public void removeChoice(java.lang.String choice)
Remove a choice.- Parameters:
choice
- A choice to remove from the list offered to the user.- See Also:
addChoice(String)
,removeAllChoices()
-
-