ptolemy.domains.ptera.kernel
Class ParametersAttribute
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.kernel.util.AbstractSettableAttribute
ptolemy.data.expr.Variable
ptolemy.data.expr.Parameter
ptolemy.data.expr.StringParameter
ptolemy.domains.ptera.kernel.ParametersAttribute
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, HasTypeConstraints, Typeable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable, ValueListener
public class ParametersAttribute
- extends StringParameter
This attribute keeps the parameters for an Ptera event. These parameters are
syntactically defined as pairs of names and types separated by colons. An
example of this syntax is as follows:
(a:int, b:{boolean, string}, c:{x=double, y=object("ptolemy.actor.Actor")})
- Since:
- Ptolemy II 8.0
- Version:
- $Id: ParametersAttribute.java 57044 2010-01-27 22:41:05Z cxh $
- Author:
- Thomas Huining Feng
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary |
ParametersAttribute(NamedObj container,
java.lang.String name)
Construct a attribute for a list of typed parameters with the given name
contained by the specified container. |
Method Summary |
protected void |
_evaluate()
Evaluate the current expression to a token. |
private void |
_parse()
Parse the expression of this attribute to generate a parse tree to be
recorded locally. |
java.lang.Object |
clone(Workspace workspace)
Clone the attribute into the specified workspace. |
java.util.List<java.lang.String> |
getParameterNames()
Return a list of names (in the String type) of the parameters defined in
this attribute. |
Type[] |
getParameterTypes()
Return an array of parameter types. |
Methods inherited from class ptolemy.data.expr.Variable |
_description, _notifyValueListeners, _parseIfNecessary, _propagate, _propagateToValueListeners, _propagateValue, _setToken, _setTokenAndNotify, addValueListener, 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.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 |
_parseTree
private ASTPtFunctionDefinitionNode _parseTree
- The parse tree of the expression with "function" added to the head and
" 1" appended to the end.
_parseTreeVersion
private long _parseTreeVersion
- Version of _parseTree.
ParametersAttribute
public ParametersAttribute(NamedObj container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
- Construct a attribute for a list of typed parameters 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.
- 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.
clone
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
- Clone the attribute into the specified workspace. The new attribute 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:
clone
in class Variable
- Parameters:
workspace
- The workspace for the cloned object.
- Returns:
- The new Attribute.
- Throws:
java.lang.CloneNotSupportedException
- Not thrown in this base class- See Also:
Object.clone()
getParameterNames
public java.util.List<java.lang.String> getParameterNames()
throws IllegalActionException
- Return a list of names (in the String type) of the parameters defined in
this attribute.
- Returns:
- A list of names.
- Throws:
IllegalActionException
- If the list of parameters cannot be
parsed.- See Also:
getParameterTypes()
getParameterTypes
public Type[] getParameterTypes()
throws IllegalActionException
- Return an array of parameter types.
- Returns:
- An array of parameter types.
- Throws:
IllegalActionException
- If the list of parameters cannot be
parsed.- See Also:
getParameterNames()
_evaluate
protected void _evaluate()
throws IllegalActionException
- Evaluate the current expression to a token. The expression of this
parameter must be a parentheses enclosed string with comma-separated
pairs of parameter names and types. Each name and type must be separated
by a colon. Examples of an acceptable expressions are:
(a)
and
(a:int, b:double)
- Overrides:
_evaluate
in class Variable
- Throws:
IllegalActionException
- If the expression cannot
be parsed or cannot be evaluated, or if a dependency loop is found.
_parse
private void _parse()
throws IllegalActionException
- Parse the expression of this attribute to generate a parse tree to be
recorded locally.
To parse the expression, "function" is first added to the head and " 1"
is appended to the end so that the new string becomes a function
definition, and the parameters to be defined are the parameters of that
function.
- Throws:
IllegalActionException
- If the format of the expression is
invalid, or some parameter names are invalid, or some of the types
cannot be evaluated.