ptolemy.actor.lib.io
Class ExpressionReader
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Source
ptolemy.actor.lib.io.LineReader
ptolemy.actor.lib.io.ExpressionReader
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TypedActor
- public class ExpressionReader
- extends LineReader
This actor reads a file or URL, one line at a time, evaluates each
line as an expression, and outputs the token resulting from the
evaluation. The first line in the file determines the data type
of the output. All other lines must contain expressions that
evaluate to the same type or a subtype, or a run-time type error will occur.
The file or URL is specified using any form acceptable
to FileParameter. If an end of file is reached, then prefire() and
postfire() will both return false.
- Since:
- Ptolemy II 2.2
- Version:
- $Id: ExpressionReader.java,v 1.17 2004/04/13 03:07:04 cxh Exp $
- Author:
- Edward A. Lee
- See Also:
ExpressionWriter,
FileParameter,
Serialized Form
- Accepted Rating:
- Proposed Rating:
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
Method Summary |
void |
fire()
Output the data read in the preinitialize() or postfire() if
there is any. |
void |
preinitialize()
Open the file or URL and read the first line, and use the
first line to set the type of the output. |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate |
| Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ExpressionReader
public ExpressionReader(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
- Construct an actor with the given container and name.
- Parameters:
container - The container.name - The name of this actor.
- Throws:
IllegalActionException - If the actor cannot be contained
by the proposed container.
NameDuplicationException - If the container already has an
actor with this name.
fire
public void fire()
throws IllegalActionException
- Output the data read in the preinitialize() or postfire() if
there is any.
- Specified by:
fire in interface Executable- Overrides:
fire in class LineReader
- Throws:
IllegalActionException - If there's no director, or
if the expression read from the file cannot be parsed.
preinitialize
public void preinitialize()
throws IllegalActionException
- Open the file or URL and read the first line, and use the
first line to set the type of the output.
- Specified by:
preinitialize in interface Executable- Overrides:
preinitialize in class LineReader
- Throws:
IllegalActionException - If the file or URL cannot be
opened, or if the first line cannot be read.