public class ParameterSet extends ScopeExtendingAttribute implements Executable
attributeName = valuewhere
variableName
is the name of the attribute
in a format suitable for NamedObj.setName(String)
(i.e., does not contain periods) and value
is
the expression in the Ptolemy expression language.
Comments are lines that begin with the #
character.
Each line in the file is interpreted as a separate assignment.
The attributes that are created will have the same visibility as parameters of the container of the attribute. They are shadowed, however, by parameters of the container. That is, if the container has a parameter with the same name as one in the parameter set, the one in the container provides the value to any observer.
If the file is modified during execution of a model, by default this will not be noticed until the next run. If you set the checkForFileUpdates parameter to true, then on each prefiring of the enclosing opaque composite actor, this parameter will check for updates of the file. Otherwise, it will only check between runs of the model or when the file name or URL gets changed.
Note that the order the parameters are created is arbitrary, this is because we read the file in using java.util.Properties.load(), which uses a HashMap to store the properties. We use a Properties.load() because it provides a nice parser for the files and can read and write values in both text and XML.
Variable
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
Parameter |
checkForFileUpdates
If this parameter is set to true, then the specified file or
URL will be checked for updates on every prefiring of the
enclosing opaque composite actor.
|
FileParameter |
fileOrURL
A parameter naming the file or URL to be read that contains
attribute names and values.
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
ParameterSet(NamedObj container,
java.lang.String name)
Construct an attribute with the given name contained by the specified
entity.
|
Modifier and Type | Method and Description |
---|---|
void |
addInitializable(Initializable initializable)
Add the specified object to the list of objects whose
preinitialize(), initialize(), and wrapup()
methods should be invoked upon invocation of the corresponding
methods of this object.
|
void |
attributeChanged(Attribute attribute)
If the parameter is fileOrURL, and the specified file
name is not null, then open and read the file.
|
void |
expand()
Expand the scope of the container by creating any required attributes.
|
void |
fire()
Do nothing.
|
void |
initialize()
Do nothing except invoke the initialize methods
of objects that have been added using addInitializable().
|
boolean |
isFireFunctional()
Return true.
|
boolean |
isStrict()
Return false.
|
int |
iterate(int count)
Check to see whether the specified file has changed, and if so,
re-read it.
|
boolean |
postfire()
Do nothing.
|
boolean |
prefire()
Check to see whether the specified file has changed, and if so,
re-read it.
|
void |
preinitialize()
Check to see whether the specified file has changed, and if so,
re-read it, and invoke the preinitialize() methods
of objects that have been added using addInitializable().
|
void |
read()
Read the contents of the file named by this parameter and create
attributes in the current scope.
|
void |
removeInitializable(Initializable initializable)
Remove the specified object from the list of objects whose
preinitialize(), initialize(), and wrapup()
methods should be invoked upon invocation of the corresponding
methods of this object.
|
void |
setContainer(NamedObj container)
Override the base class to register as a piggyback with the nearest opaque
composite actor above in the hierarchy.
|
void |
stop()
Do nothing.
|
void |
stopFire()
Do nothing.
|
void |
terminate()
Do nothing.
|
void |
wrapup()
Check to see whether the specified file has changed, and if so,
re-read it, and invoke the wrapup() methods
of objects that have been added using addInitializable().
|
validate
_checkContainer, _getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, 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
attributeList, getAttribute
public Parameter checkForFileUpdates
public FileParameter fileOrURL
public ParameterSet(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 addInitializable(Initializable initializable)
addInitializable
in interface Initializable
initializable
- The object whose methods should be invoked.removeInitializable(Initializable)
,
CompositeActor.addPiggyback(Executable)
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the superclass throws it, or
if the file cannot be read, or if the file parameters cannot
be evaluated.public void expand() throws IllegalActionException
expand
in interface ScopeExtender
expand
in class ScopeExtendingAttribute
IllegalActionException
- If any required attribute cannot be
created.public void fire() throws IllegalActionException
fire
in interface Executable
IllegalActionException
- If firing is not permitted.public void initialize() throws IllegalActionException
initialize
in interface Initializable
IllegalActionException
- If one of the added objects
throws it.public boolean isFireFunctional()
isFireFunctional
in interface Executable
public boolean isStrict()
isStrict
in interface Executable
public int iterate(int count) throws IllegalActionException
iterate
in interface Executable
count
- The number of iterations to perform, ignored by this
method.IllegalActionException
- If re-reading the file fails.public boolean postfire()
postfire
in interface Executable
public boolean prefire() throws IllegalActionException
prefire
in interface Executable
IllegalActionException
- If re-reading the file fails.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
IllegalActionException
- If one of the added objects
throws it, or if re-reading the file fails.public void read() throws IllegalActionException, NameDuplicationException, java.io.IOException
java.io.IOException
- If there is a problem reading the file.IllegalActionException
- If there is a problem
reading the previous attribute or validating the settablesNameDuplicationException
- If there is a problem removing
a previous attribute or creating a new variable.public void removeInitializable(Initializable initializable)
removeInitializable
in interface Initializable
initializable
- The object whose methods should no longer be invoked.addInitializable(Initializable)
,
CompositeActor.removePiggyback(Executable)
public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException
setContainer
in class ScopeExtendingAttribute
container
- The proposed container.IllegalActionException
- If the action would result in a
recursive containment structure, or if
this entity and container are not in the same workspace.NameDuplicationException
- If the container already has
an entity with the name of this entity.Attribute.getContainer()
public void stop()
stop
in interface Executable
public void stopFire()
stopFire
in interface Executable
public void terminate()
terminate
in interface Executable
public void wrapup() throws IllegalActionException
wrapup
in interface Initializable
IllegalActionException
- If one of the added objects
throws it, or if re-reading the file fails.