com.partnersoft.io.vfs
Class AbstractVfs

java.lang.Object
  extended by com.partnersoft.io.vfs.AbstractVfs
All Implemented Interfaces:
Vfs
Direct Known Subclasses:
HaversackVfs, ZipVfs

public abstract class AbstractVfs
extends java.lang.Object
implements Vfs

A basic (and fairly simpleminded) implementation of a Vfs. It provides an indexing setup so that VfsDirectories and VfsFile objects are stored and tracked as objects rather than on disk. So, it may be appropriate to relatively small and static file systems (e.g. a archive file format) but not for large or dynamic ones.

Copyright 2009 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Constructor Summary
AbstractVfs()
           
 
Method Summary
protected  VfsDirectory addDirectoryEntry(Path path)
          Adds a directory entry to the index, and automatically adds all parent directories as well.
protected  void addFileEntry(VfsFile file)
          Adds a file entry to the index, and automatically adds all parent directories as well.
abstract  void close()
           
 VfsDirectory directoryFor(Path path)
          Returns a VfsDirectory for the given path.
 VfsDirectory directoryFor(java.lang.String pathString)
          Returns a VfsDirectory for the given path.
 VfsFile fileFor(Path path)
          Returns a VfsFile for the given path.
 VfsFile fileFor(java.lang.String pathString)
          Returns a VfsFile for the given path string.
 boolean isWritable()
          True if this module supports writing.
abstract  void open()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.partnersoft.io.vfs.Vfs
getAbsolutePath
 

Constructor Detail

AbstractVfs

public AbstractVfs()
            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

open

public abstract void open()
                   throws java.io.IOException
Throws:
java.io.IOException

close

public abstract void close()
                    throws java.io.IOException
Throws:
java.io.IOException

directoryFor

public VfsDirectory directoryFor(Path path)
Description copied from interface: Vfs
Returns a VfsDirectory for the given path. Note that this does not imply that the underlying file actually exists. You may use the methods provided by the VfsDirectory to list and modify the directory's contents.

Specified by:
directoryFor in interface Vfs
Parameters:
path - to directory
Returns:
directory for given path

directoryFor

public VfsDirectory directoryFor(java.lang.String pathString)
Description copied from interface: Vfs
Returns a VfsDirectory for the given path. This is the same as directoryFor(new Path(pathString).

Specified by:
directoryFor in interface Vfs
Parameters:
pathString - string-encoded path to directory
Returns:
directory for given path

fileFor

public VfsFile fileFor(Path path)
Description copied from interface: Vfs
Returns a VfsFile for the given path. Note that this does not imply that the underlying file actually exists. You may use the methods provided by the VfsFile to read and write the file's contents.

Specified by:
fileFor in interface Vfs
Parameters:
path - to file
Returns:
file for given path

fileFor

public VfsFile fileFor(java.lang.String pathString)
Description copied from interface: Vfs
Returns a VfsFile for the given path string. This is the same as fileFor(new Path(pathString).

Specified by:
fileFor in interface Vfs
Parameters:
pathString - string-encoded path to file
Returns:
file for given path

isWritable

public boolean isWritable()
Description copied from interface: Vfs
True if this module supports writing.

Specified by:
isWritable in interface Vfs
Returns:
true if module is writable

addFileEntry

protected void addFileEntry(VfsFile file)
Adds a file entry to the index, and automatically adds all parent directories as well. Subclass implementations should use this to build the file tree index.


addDirectoryEntry

protected VfsDirectory addDirectoryEntry(Path path)
Adds a directory entry to the index, and automatically adds all parent directories as well. Thus, you only need to call addFileEntry(file) and not this, unless you want a blank directory entry. Subclass implementations should use this to build the file tree index.