ptolemy.actor.lib.io
Class DirectoryListing
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.DirectoryListing
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, java.io.FilenameFilter, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TypedActor
- public class DirectoryListing
- extends Source
- implements java.io.FilenameFilter
Given a URL or directory name, this actor produces an array of file names
in that directory that match an (optional) pattern. The file names that
are returned are absolute. The pattern is
a regular expression. For a reference on regular expression syntax see:
http://java.sun.com/docs/books/tutorial/extra/regex/index.html.
FIXME: Useful options would be to output only files or only directories.
- Since:
- Ptolemy II 4.0
- Version:
- $Id: DirectoryListing.java,v 1.11.2.1 2004/07/16 15:19:57 cxh Exp $
- Author:
- Christopher Hylands, Edward A. Lee
- See Also:
- 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 |
boolean |
accept(java.io.File directory,
java.lang.String name)
Return true if the specified name matches the specified pattern,
or if no pattern has been specified. |
void |
attributeChanged(Attribute attribute)
Override the base class to locally cache parameter values. |
void |
fire()
Output the data read in the prefire. |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, initialize, inputPortList, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup |
| 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 |
directoryOrURL
public FileParameter directoryOrURL
- The directory name or URL from which to read. This is a string with
any form accepted by FileParameter.
- See Also:
FileParameter
directoryOrURLPort
public TypedIOPort directoryOrURLPort
- An input port for optionally providing a directory name. This has
type string.
pattern
public StringParameter pattern
- If non-empty, then only output file and directory names that
match the specified (regular expression) pattern.
The default value of this parameter is the empty String "",
which indicates that everything matches.
DirectoryListing
public DirectoryListing(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.
accept
public boolean accept(java.io.File directory,
java.lang.String name)
- Return true if the specified name matches the specified pattern,
or if no pattern has been specified.
- Specified by:
accept in interface java.io.FilenameFilter
- Parameters:
directory - The directory in which the file was found.name - The name of the file or directory.
attributeChanged
public void attributeChanged(Attribute attribute)
throws IllegalActionException
- Override the base class to locally cache parameter values.
- Overrides:
attributeChanged in class NamedObj
- Parameters:
attribute - The attribute that has changed.
- Throws:
IllegalActionException - If the specified attribute
is URL and the file cannot be opened.
fire
public void fire()
throws IllegalActionException
- Output the data read in the prefire.
- Specified by:
fire in interface Executable- Overrides:
fire in class Source
- Throws:
IllegalActionException - If there's no director or
if the directory or URL is invalid.