public class DirectoryListing extends SequenceSource implements java.io.FilenameFilter
The file names include the complete path, unless relative is set to true, in which case, the names are relative to the directory. The pattern is a regular expression. For a reference on regular expression syntax see: http://download.oracle.com/javase/tutorial/essential/regex/
If directoryOrURL is a local directory (not a URL), then you can optionally list only contained files or directories. If listOnlyDirectories is true, then only directories will be listed on the output. If listOnlyFiles is true, then only files will be listed on the output. If both are true, then an exception is thrown.
If directoryOrURL is a URL, then this actor assumes that the server will list the contents of the referenced directory in an HTML file where each file listed will have the following form:
<a href="filename">filename</a>
If the filename is longer than 20 characters, then only the first 20 characters of the two appearances of the filename are compared, since some servers truncate the file names.
If allowEmptyDirectory controls whether reading an empty directory will throw an exception.
Note that DirectoryListing returns the contents of the directory in a different order depending on whether one is using the Sun JVM or the IBM JVM. Thus, you may want to connect the output to an ArraySort actor.
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
Parameter |
allowEmptyDirectory
If true, and directoryOrURL refers to a local directory
(not a URL), that is empty, then the output will be empty
string array and no exception is reported.
|
FilePortParameter |
directoryOrURL
The directory name or URL from which to read.
|
Parameter |
listOnlyDirectories
If true, and directoryOrURL refers to a local directory (not a URL),
then only directories will be listed on the output.
|
Parameter |
listOnlyFiles
If true, and directoryOrURL refers to a local directory (not a URL),
then only files will be listed on the output.
|
StringParameter |
pattern
If non-empty, then only output file and directory names that
match the specified (regular expression) pattern.
|
Parameter |
recursive
Whether files in the subdirectories should be searched as well.
|
Parameter |
relative
If true, then produce an array with file names relative to the
specified directory.
|
_firingCountLimit, _iterationCount, firingCountLimit
_triggered, output, trigger
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_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 |
---|
DirectoryListing(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name.
|
Modifier and Type | Method and Description |
---|---|
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 an array containing file and/or directory names.
|
initialize, postfire
_customTypeConstraints, prefire
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, 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, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public FilePortParameter directoryOrURL
FilePortParameter
.
By default, this is empty. An empty string is equivalent to specifying
"$CWD", the current working directory.public Parameter listOnlyDirectories
public Parameter listOnlyFiles
public Parameter allowEmptyDirectory
public StringParameter pattern
public Parameter recursive
public Parameter relative
public DirectoryListing(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.public boolean accept(java.io.File directory, java.lang.String name)
accept
in interface java.io.FilenameFilter
directory
- The directory in which the file was found
(ignored, but required by the FilenameFilter interface).name
- The name of the file or directory.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class LimitedFiringSource
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 or
if the directory or URL is invalid.