ptolemy.actor.lib
Class Writer
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.Sink
ptolemy.actor.lib.Writer
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
- Direct Known Subclasses:
- FileWriter
public class Writer
- extends Sink
This actor reads tokens from any number of input channels and writes
their string values to the specified writer. A newline character
is written between firings. If the width of the input port is greater
than one, then values read from the distinct channels are separated
by tab characters. If no writer is specified using setWriter(), then
this actor writes to the standard output.
- Since:
- Ptolemy II 0.4
- Version:
- $Id: Writer.java 59167 2010-09-21 17:08:02Z cxh $
- Author:
- Yuhong Xiong, Edward A. Lee
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Field Summary |
private static java.io.Writer |
_stdOut
|
private java.io.Writer |
_writer
|
Fields inherited from class ptolemy.actor.lib.Sink |
input |
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 |
Writer(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name. |
Method Summary |
boolean |
postfire()
Read at most one token from each input channel and write its
string value. |
void |
setWriter(java.io.Writer writer)
Set the writer. |
void |
wrapup()
Flush the writer, if there is one. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate |
Methods inherited from class ptolemy.kernel.ComponentEntity |
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
_writer
private java.io.Writer _writer
_stdOut
private static java.io.Writer _stdOut
Writer
public Writer(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.
postfire
public boolean postfire()
throws IllegalActionException
- Read at most one token from each input channel and write its
string value. These values are separated by tab characters.
If an input channel has no data, then two consecutive tab
characters are written.
- Specified by:
postfire
in interface Executable
- Overrides:
postfire
in class AtomicActor
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException
- If an IO error occurs.
setWriter
public void setWriter(java.io.Writer writer)
throws IllegalActionException
- Set the writer. If there was a previous writer, close it.
To set standard output, call this method with argument null.
- Parameters:
writer
- The writer to write to.
- Throws:
IllegalActionException
- If an IO error occurs.
wrapup
public void wrapup()
throws IllegalActionException
- Flush the writer, if there is one.
- Specified by:
wrapup
in interface Initializable
- Overrides:
wrapup
in class AtomicActor
- Throws:
IllegalActionException
- If an IO error occurs.