org.openpipeline.pipeline.connector.filesystem
Class ZipFileSystem

java.lang.Object
  extended by org.openpipeline.pipeline.connector.filesystem.ZipFileSystem
All Implemented Interfaces:
FileSystem

public class ZipFileSystem
extends Object
implements FileSystem

A wrapper around a zip file that makes it look like a file system.


Constructor Summary
ZipFileSystem(File file)
           
 
Method Summary
 FileSystem fetch(String fullname)
          Returns the file or directory that has the specified name.
 String getFullName()
          Get the full name, including an absolute path, of the file.
 InputStream getInputStream()
          Get an InputStream that contains the data in the file.
 boolean getItem(Item item)
          Populates an Item with the data contained in this file.
 FileIterator getIterator()
          If this file is a directory, this iterator iterates over all files and subdirectories in it.
 long getLastUpdate()
          Returns a timestamp, in millis, of the time the file was last updated.
 long getSignature()
          Returns a long value that can help identify if a document has changed.
 long getSize()
          Return the length, in bytes, of the file.
 boolean isDirectory()
          Returns true if this entry is a directory, and it's possible to call getFileIterator() to iterate over files and subdirectories in it.
 boolean isFile()
          Returns true if this entry is a file and there is an InputStream available for it.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZipFileSystem

public ZipFileSystem(File file)
Method Detail

getFullName

public String getFullName()
Description copied from interface: FileSystem
Get the full name, including an absolute path, of the file. The format of the name will be dependent on the particular implementation.

Specified by:
getFullName in interface FileSystem
Returns:
a name

getInputStream

public InputStream getInputStream()
Description copied from interface: FileSystem
Get an InputStream that contains the data in the file. Only returns an InputStream if isFile() is true. For some implementations, may return null, even for files; these implementations may return an Item from getItem() instead.

Specified by:
getInputStream in interface FileSystem
Returns:
an InputStream or null

getItem

public boolean getItem(Item item)
Description copied from interface: FileSystem
Populates an Item with the data contained in this file. Will only populate the Item if 1) isFile() is true, 2) there is actually data available in this file, and 3) this particular implementation returns items. The implementation may return data via getInputStream() instead.

Specified by:
getItem in interface FileSystem
Returns:
true if the item was populated, else false.

getIterator

public FileIterator getIterator()
                         throws FileNotFoundException
Description copied from interface: FileSystem
If this file is a directory, this iterator iterates over all files and subdirectories in it. Performs a similar function to java.io.File.listFiles(), except that the iterator allows the implementation to fetch sub-files in a lazy way.

Specified by:
getIterator in interface FileSystem
Returns:
an iterator. If there are no files in the directory, the iterator will be empty. Implementations will generally throw an exception (possibly unchecked) if this file is not a directory, so always check isDirectory() first.
Throws:
FileNotFoundException

getLastUpdate

public long getLastUpdate()
Description copied from interface: FileSystem
Returns a timestamp, in millis, of the time the file was last updated.

Specified by:
getLastUpdate in interface FileSystem
Returns:
a timestamp, or -1 if the timestamp is not available

getSignature

public long getSignature()
Description copied from interface: FileSystem
Returns a long value that can help identify if a document has changed. The exact value is implementation dependent. It can be a timestamp, or a checksum, or a version number, or any other value that will change when the document changes. This value should only be used to detect changed documents.

Specified by:
getSignature in interface FileSystem
Returns:
a long value

isDirectory

public boolean isDirectory()
Description copied from interface: FileSystem
Returns true if this entry is a directory, and it's possible to call getFileIterator() to iterate over files and subdirectories in it.

Specified by:
isDirectory in interface FileSystem
Returns:
true if this file is a directory

isFile

public boolean isFile()
Description copied from interface: FileSystem
Returns true if this entry is a file and there is an InputStream available for it.

Specified by:
isFile in interface FileSystem

getSize

public long getSize()
Description copied from interface: FileSystem
Return the length, in bytes, of the file. Undefined for directories.

Specified by:
getSize in interface FileSystem
Returns:
a length

fetch

public FileSystem fetch(String fullname)
Description copied from interface: FileSystem
Returns the file or directory that has the specified name. The format of the name is implementation-dependent, but it should be the same as is returned by getFullName(), and should include full path information.

Specified by:
fetch in interface FileSystem
Parameters:
fullname - the name of the file
Returns:
a FileSystem object, or null if the name was not found

toString

public String toString()
Overrides:
toString in class Object