lumis.portal.serialization.persistency.zip
Class ZipDirectory

Package class diagram package ZipDirectory
java.lang.Object
  extended by lumis.portal.serialization.persistency.zip.ZipDirectory
All Implemented Interfaces:
Closeable, IDirectory, IFSDirectory

public class ZipDirectory
extends Object
implements IFSDirectory

IDirectory implementation that uses a zip file as the concrete repository. This implementation allows only one open stream at a time. Tries to get some input or output stream when another stream was got and not closed yet will raise an StreamStillOpenException.

Since:
4.0.10

Constructor Summary
ZipDirectory(File zipFile)
           
ZipDirectory(File zipFile, boolean createIfNotExist)
           
ZipDirectory(String zipFilePath)
           
 
Method Summary
 void close()
           In this implementation, this method MUST be called in order to persist new added files.
 void delete()
          Delete the repository.
 boolean exists(String filePath)
          Check the existence of a file.
protected  void finalize()
           
 String getDescription()
          Generate a general description of the directory, used mainly to compose exception messages.
 String getDirectoryPath()
           
 InputStream getInputStream(String filePath)
          Get an InputStream to a repository file. This implementation does not allow more than one stream open at a time.
 OutputStream getOutputStream(String filePath)
          Get an OutputStream to a repository file. Due to an output optimization, this implementation does not persist the new files just after closing the OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipDirectory

public ZipDirectory(String zipFilePath)
             throws FileNotFoundException
Parameters:
zipFilePath - path to the zip file.
Throws:
FileNotFoundException - if the zip file was not found.

ZipDirectory

public ZipDirectory(File zipFile)
             throws FileNotFoundException
Parameters:
zipFile - File that wraps the zip file.
Throws:
FileNotFoundException - if the zip file was not found.

ZipDirectory

public ZipDirectory(File zipFile,
                    boolean createIfNotExist)
             throws FileNotFoundException,
                    IOException
Parameters:
zipFile - File that wraps the zip file.
createIfNotExist - if true, the zip file will be created if it does not exist.
Throws:
FileNotFoundException - if the zip file was not found and createIfNotExist=false.
IOException
Method Detail

exists

public boolean exists(String filePath)
               throws IOException
Check the existence of a file.

Specified by:
exists in interface IDirectory
Parameters:
filePath - path to the file to be checked.
Returns:
true, if the specified file exists.
Throws:
IllegalStateException - if this method is called in an already closed instance.
IOException - if an I/O error occurs.

getDescription

public String getDescription()
Description copied from interface: IDirectory
Generate a general description of the directory, used mainly to compose exception messages.

Specified by:
getDescription in interface IDirectory
Returns:
directory description.

getInputStream

public InputStream getInputStream(String filePath)
                           throws StreamStillOpenException,
                                  FileNotFoundException,
                                  IOException
Get an InputStream to a repository file.

This implementation does not allow more than one stream open at a time.

Specified by:
getInputStream in interface IDirectory
Parameters:
filePath - path to the file.
Returns:
InputStream to file found in specified filePath.
Throws:
StreamStillOpenException - if there is another stream that was gotten and not closed yet.
IllegalStateException - if this method is called in an already closed instance.
FileNotFoundException - if no file was found in specified filePath.
IOException - if an I/O error occurs.

getOutputStream

public OutputStream getOutputStream(String filePath)
                             throws StreamStillOpenException,
                                    IOException
Get an OutputStream to a repository file.

Due to an output optimization, this implementation does not persist the new files just after closing the OutputStream. To commit the persistence, the method close() must be called.

This implementation does not allow more than one stream open at a time.

If the file already exists, an IOException will be thrown.

Specified by:
getOutputStream in interface IDirectory
Parameters:
filePath - path to the file.
Returns:
OutputStream to the new file
Throws:
StreamStillOpenException - if there is another stream that was gotten and not closed yet.
IllegalStateException - if this method is called in an already closed instance.
IOException - if an I/O error occurs.

close

public void close()
           throws IOException

In this implementation, this method MUST be called in order to persist new added files.

Specified by:
close in interface Closeable
Throws:
IOException

delete

public void delete()
            throws IOException
Description copied from interface: IDirectory
Delete the repository.

Specified by:
delete in interface IDirectory
Throws:
IOException - if an I/O error occurs.

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

getDirectoryPath

public String getDirectoryPath()
Specified by:
getDirectoryPath in interface IFSDirectory


Lumisportal  4.1.0.071221 - Copyright © 2001-2007, Lumis. All Rights Reserved.