vfs
Class VFSDirectory

java.lang.Object
  extended by vfs.VFSDirectory
All Implemented Interfaces:
VFSItem
Direct Known Subclasses:
JarDirectory, NativeDirectory

public class VFSDirectory
extends java.lang.Object
implements VFSItem

A VFSDirectory is a container for VFSItem objects in a virtual file system. In addition to VFSItem methods, it has methods for accessing files and subdirectories.

This is a Composite class in a Composite design pattern whose other classes are VFSItem (Component) and VFSFile (Leaf).


Constructor Summary
VFSDirectory(java.lang.String nm, VFSDirectory par)
          new VFSDirectory(nm, par) returns a virtual directory named nm whose parent is par.
VFSDirectory(java.net.URL url)
          new VFSDirectory(url) returns a virtual file system root directory representing the directory whose URL is url.
 
Method Summary
protected  VFSFile addFile(java.lang.String nm)
          addFile(nm) adds the file named nm to this VFSDirectory.
protected  void addSubdirectory(VFSDirectory dir)
          d.addSubdirectory(nm) adds the subdirectory named nm to d.
 void escort(VFSVisitor v)
          d.escort(v) escorts v through the directories and files descending from d.
 VFSFile getFile(java.lang.String nm)
          d.getFile(nm) returns the file named nm in d or null if there is no such file.
 java.util.Iterator<java.lang.String> getFileNames()
          d.getFileNames() returns an iterator for the names of file in d.
 java.util.Iterator<VFSFile> getFiles()
          d.getFiles() returns an iterator for the files in d.
 java.lang.String getName()
          d.getName() returns the name of d.
 java.util.Iterator<VFSDirectory> getSubdirectories()
          d.getSubdirectories() returns an iterator for the subdirectories of d.
 VFSDirectory getSubdirectory(java.lang.String nm)
          d.getFile(nm) returns the subdirectory named nm in d or null if there is no such subdirectory.
 java.util.Iterator<java.lang.String> getSubdirectoryNames()
          d.getSubdirectoryNames() returns an iterator for the names of subdirectories of d.
 java.net.URL getURL()
          v.getURL() returns the URL for d.
 boolean isRoot()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VFSDirectory

public VFSDirectory(java.net.URL url)
new VFSDirectory(url) returns a virtual file system root directory representing the directory whose URL is url.

Parameters:
url - the URL of the root directory

VFSDirectory

public VFSDirectory(java.lang.String nm,
                    VFSDirectory par)
new VFSDirectory(nm, par) returns a virtual directory named nm whose parent is par.

Parameters:
nm - the name of the directory
par - its virtual file system parent
Method Detail

addSubdirectory

protected void addSubdirectory(VFSDirectory dir)
d.addSubdirectory(nm) adds the subdirectory named nm to d.


addFile

protected VFSFile addFile(java.lang.String nm)
addFile(nm) adds the file named nm to this VFSDirectory.


getName

public java.lang.String getName()
d.getName() returns the name of d.

Specified by:
getName in interface VFSItem
Returns:
the name of the item

getURL

public java.net.URL getURL()
v.getURL() returns the URL for d.

Specified by:
getURL in interface VFSItem
Returns:
the URL for the directory

isRoot

public boolean isRoot()

getFile

public VFSFile getFile(java.lang.String nm)
d.getFile(nm) returns the file named nm in d or null if there is no such file.

Returns:
the named file

getFiles

public java.util.Iterator<VFSFile> getFiles()
d.getFiles() returns an iterator for the files in d.

Returns:
an iterator for the files

getFileNames

public java.util.Iterator<java.lang.String> getFileNames()
d.getFileNames() returns an iterator for the names of file in d.

Returns:
an iterator for the file names

getSubdirectory

public VFSDirectory getSubdirectory(java.lang.String nm)
d.getFile(nm) returns the subdirectory named nm in d or null if there is no such subdirectory.

Returns:
the named directory

getSubdirectories

public java.util.Iterator<VFSDirectory> getSubdirectories()
d.getSubdirectories() returns an iterator for the subdirectories of d.

Returns:
an iterator for the subdirectories

getSubdirectoryNames

public java.util.Iterator<java.lang.String> getSubdirectoryNames()
d.getSubdirectoryNames() returns an iterator for the names of subdirectories of d.

Returns:
an iterator for the subdirectory names

escort

public void escort(VFSVisitor v)
d.escort(v) escorts v through the directories and files descending from d.