ptolemy.data.expr
Class Parameter

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.kernel.util.AbstractSettableAttribute
              extended by ptolemy.data.expr.Variable
                  extended by ptolemy.data.expr.Parameter
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HasTypeConstraints, Typeable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable, ValueListener
Direct Known Subclasses:
BaseUnit, ColorAttribute, Commutator.WidthDependentParameter, Commutator.WidthDependentParameter, ContainerIgnoringAttribute, Distributor.WidthDependentParameter, Distributor.WidthDependentParameter, DoubleRangeParameter, Event.EventParameter, ExpertParameter, GTParameter, HierarchyFlatteningAttribute, IntRangeParameter, IterativeParameter, LocationAttribute, LocationParameter, ModelParameter, PortParameter, Priority, PtalonParameter, RelationCollapsingAttribute, RelationHidingAttribute, SharedParameter, SingletonParameter, SizeAttribute, StringParameter, SynchronizeToRealtime, TableauParameter, TypeAttribute, 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().

Since:
Ptolemy II 0.2
Version:
$Id: Parameter.java 59167 2010-09-21 17:08:02Z cxh $
Author:
Neil Smyth, Edward A. Lee, Xiaojun Liu
See Also:
PtParser, Token, Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.data.expr.Variable
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
private  java.util.List _choices
           
 
Fields inherited from class ptolemy.data.expr.Variable
_currentExpression, _needsEvaluation, _parserScope, _parseTreeValid, _valueListeners
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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
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
 void addChoice(java.lang.String choice)
          Add a choice.
 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, _notifyValueListeners, _parseIfNecessary, _propagate, _propagateToValueListeners, _propagateValue, _setToken, _setTokenAndNotify, addValueListener, clone, getDeclaredType, getExpression, getFreeIdentifiers, getParserScope, getScope, getScope, getToken, getType, getTypeTerm, getValueAsString, getVariable, getVisibility, invalidate, isKnown, isLazy, isStringMode, isTypeAcceptable, removeValueListener, reset, setContainer, setExpression, setLazy, setName, setParseTreeEvaluator, setStringMode, setToken, setToken, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, setUnknown, 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, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, 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.Settable
getDisplayName
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getFullName, getName, getName
 

Field Detail

_choices

private java.util.List _choices
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)

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 interface MoMLExportable
Overrides:
exportMoML in class NamedObj
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()