|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.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.URLReader
ptolemy.actor.lib.URLDirectoryReader
public class URLDirectoryReader
This actor reads a URL and if the URL names a directory, it outputs the name of each file or subdirectory contained in the directory. If the URL names a file, then it outputs the name of that file.
If the repeat flag is true, then the sequence of file names is repeated indefinitely. If the refresh flag is true, and the repeat flag is true, then the directory is re-read before repeating the sequence of files and subdirectories.
If the endsWith String parameter is non-null and non-empty, then only file names or subdirectories that end with the value of the endsWith parameter are output.
One alternative implementation would be that if the URL named a file,
then the actor would output the names of the files and subdirectories
in the directory that contains the file.
Another alternative implementation would output the names of the
files and subdirectories in an array.
An extension would be to include a filter parameter that could be
a regular expression that would allow us to filter the file names.
Should this actor extend URLReader or SequenceActor?
Red (liuj) |
Red (liuj) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.Entity |
---|
Entity.ContainedObjectsIterator |
Field Summary | |
---|---|
private java.lang.String[] |
_data
Deprecated. |
private java.lang.String |
_endsWithValue
Deprecated. |
private int |
_iterationCount
Deprecated. |
private boolean |
_repeatFlag
Deprecated. |
Parameter |
endsWith
Deprecated. If non-null and non-empty, then only output file names and sub directories that end with this String value. |
Parameter |
repeat
Deprecated. Repeat after outputting all elements of the directory. |
Fields inherited from class ptolemy.actor.lib.URLReader |
---|
_reader, _refreshFlag, _source, _stdIn, refresh, sourceURL |
Fields inherited from class ptolemy.actor.lib.Source |
---|
output, trigger |
Fields inherited from class ptolemy.actor.AtomicActor |
---|
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested |
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.actor.Executable |
---|
COMPLETED, NOT_READY, STOP_ITERATING |
Constructor Summary | |
---|---|
URLDirectoryReader(CompositeEntity container,
java.lang.String name)
Deprecated. Construct an actor with the given container and name. |
Method Summary | |
---|---|
private java.lang.String[] |
_list(java.lang.String source,
java.lang.String endsWith)
Deprecated. If the URL names a directory return an array containing the names of the files and subdirectories contained in the directory. |
private java.lang.String[] |
_listFile(java.lang.String source,
java.lang.String endsWith)
Deprecated. Return files and directories contained in the source url. |
private static java.lang.String[] |
_listFileOrURL(java.lang.String source,
java.lang.String endsWith)
Deprecated. Return files and directories contained in the source url. |
void |
attributeChanged(Attribute attribute)
Deprecated. If the specified attribute is URL, then close the current file (if there is one) and open the new one. |
void |
fire()
Deprecated. Output the data read in the prefire. |
void |
initialize()
Deprecated. Open the file at the URL, and set the width of the output. |
boolean |
postfire()
Deprecated. Update the iteration counter until it exceeds the number of elements in the directory. |
boolean |
prefire()
Deprecated. Read one row from the input and prepare for output them. |
Methods inherited from class ptolemy.actor.lib.URLReader |
---|
_setURLReader, wrapup |
Methods inherited from class ptolemy.actor.TypedAtomicActor |
---|
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints |
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.InstantiableNamedObj |
---|
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.actor.Actor |
---|
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList |
Methods inherited from interface ptolemy.actor.Executable |
---|
isFireFunctional, isStrict, iterate, stop, stopFire, terminate |
Methods inherited from interface ptolemy.actor.Initializable |
---|
addInitializable, preinitialize, removeInitializable |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Methods inherited from interface ptolemy.kernel.util.Derivable |
---|
getDerivedLevel, getDerivedList, propagateValue |
Field Detail |
---|
public Parameter endsWith
public Parameter repeat
private java.lang.String _endsWithValue
private int _iterationCount
private java.lang.String[] _data
private boolean _repeatFlag
Constructor Detail |
---|
public URLDirectoryReader(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this actor.
IllegalActionException
- If the actor cannot be contained
by the proposed container.
NameDuplicationException
- If the container already has an
actor with this name.Method Detail |
---|
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class URLReader
attribute
- The attribute that has changed.
IllegalActionException
- If the specified attribute
is URL and the file cannot be opened.public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class Source
IllegalActionException
- If there's no director.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class URLReader
IllegalActionException
- Not thrown in this base classpublic boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor
IllegalActionException
- If the sourceURL is not valid.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class Source
IllegalActionException
- If the sourceURL is invalid.private java.lang.String[] _list(java.lang.String source, java.lang.String endsWith) throws IllegalActionException
source
- The filename or URL to openendsWith
- If non-null, then only files or subdirectories
that end with this string are reported.
IllegalActionException
- If the source is a malformed
URLprivate java.lang.String[] _listFile(java.lang.String source, java.lang.String endsWith) throws IllegalActionException
source
- The source URL to query for files and subdirectories.
The source url must be a String using the "file:" protocol.endsWith
- If non-null and of length greater than 0,
then only files or subdirectories that end with this string
are reported.
IllegalActionException
- If the source does not have
the file: protocol, or if the source is neither a file
nor a directory, or if there is some other problem.private static java.lang.String[] _listFileOrURL(java.lang.String source, java.lang.String endsWith) throws java.net.MalformedURLException, java.io.IOException
source
- The source URL to query for files and subdirectories.
The source url must be a String using the "file:" protocol.endsWith
- If non-null and of length greater than 0,
then only files or subdirectories that end with this string
are reported.
IllegalActionException
- If the source does not have
the file: protocol, or if the source is neither a file
nor a directory, or if there is some other problem.
java.net.MalformedURLException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |