org.entityfs.zip
Class ZipFileSystemBuilder

java.lang.Object
  extended by org.entityfs.impl.AbstractFileSystemBuilder<T>
      extended by org.entityfs.impl.impl.AbstractFileSystemBuilderImpl<ZipFileSystemBuilder>
          extended by org.entityfs.zip.ZipFileSystemBuilder
All Implemented Interfaces:
FileSystemBuilder<ZipFileSystemBuilder>

public class ZipFileSystemBuilder
extends AbstractFileSystemBuilderImpl<ZipFileSystemBuilder>

This is a builder class for building read only Zip file-backed file systems.

A limitation of the Zip file system is that it must be built upon a Zip file in a file-backed file system. This is because Java's ZipFile class only can be built from a File object.

The Zip file system must be closed when it is not needed anymore. If a file entity is used for the zip file, it is locked for reading by the Zip file system. The lock is released when the file system is closed.

Since:
1.0
Author:
Karl Gustafsson
See Also:
org.entiyfs.at4jzip.At4jZipFileSystemBuilder
In_jar:
entityfs-zip

Field Summary
 
Fields inherited from interface org.entityfs.FileSystemBuilder
DEFAULT_BUFFER_SIZE
 
Constructor Summary
ZipFileSystemBuilder()
          Create a builder with default settings: LogAdapter: DefaultLogAdapter.DEFAULT_ADAPTER EntityValidityControlStrategy: null (no one else should have write access to the backend)
ZipFileSystemBuilder(LogAdapter logAdapter)
          Create a builder with a custom log adapter.
 
Method Summary
protected  AdapterFactory createAdapterFactory()
          Subclasses implement this to create the right AdapterFactory implementation.
protected  FileSystemImplementation createFileSystem(SupportObjects fso, FileSystemDelegate fsd)
          Subclasses implement this to return a new file system instance.
protected  FileSystemDelegate createFileSystemDelegate(FileSystemAdapter fsa)
          This method is implemented by a subclass to create the file system delegate to use.
 boolean isLockingSupported()
          Does the file system being built support locking?
protected  boolean isReadOnly()
          Subclasses implement this method to tell if the file system they are about to create is read only.
 ZipFileSystemBuilder setZipFile(EFile f)
          Set the Zip file.
 ZipFileSystemBuilder setZipFile(File f)
          Set the Zip file.
 ZipFileSystemBuilder setZipFile(ZipFile f)
          Set the Zip file.
protected  Collection<String> validate()
          Validate that we can create a file system with the current properties.
 
Methods inherited from class org.entityfs.impl.impl.AbstractFileSystemBuilderImpl
create, createDefaultChildEntityManagerFactory, enableEvents, getChildEntityManagerFactory, getEventManager, isFileSystemSupportedByAllCapabilities, setChildEntityManagerFactory, setEventManager
 
Methods inherited from class org.entityfs.impl.AbstractFileSystemBuilder
addCapabilityProvider, addCapabilityProviders, disableAccessControls, disableEntityValidityControls, enableLocking, getAccessController, getBufferSize, getCapabilityProviders, getCapabilityProvidersInternal, getEntityValidityControlStrategy, getLockAcquiringStrategy, getLockAdapterFactory, getLockCommandExecutor, getLogAdapter, getName, getThis, setAccessController, setBufferSize, setEntityValidityControlStrategy, setLockAcquiringStrategy, setLockAdapterFactory, setLockCommandExecutor, setLogAdapter, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipFileSystemBuilder

public ZipFileSystemBuilder()
Create a builder with default settings:


ZipFileSystemBuilder

public ZipFileSystemBuilder(LogAdapter logAdapter)
Create a builder with a custom log adapter.

Parameters:
logAdapter - The adapter to use for logging from the file system.
Method Detail

setZipFile

public ZipFileSystemBuilder setZipFile(File f)
Set the Zip file.

Parameters:
f - The Zip file.
Returns:
this.

setZipFile

public ZipFileSystemBuilder setZipFile(EFile f)
                                throws IllegalArgumentException
Set the Zip file.

Parameters:
f - The Zip file.
Returns:
this.
Throws:
IllegalArgumentException - If the file is not in a file-backed file system.

setZipFile

public ZipFileSystemBuilder setZipFile(ZipFile f)
Set the Zip file.

Parameters:
f - The Zip file.
Returns:
this.

isLockingSupported

public boolean isLockingSupported()
Description copied from interface: FileSystemBuilder
Does the file system being built support locking?

Returns:
false.
See Also:
FileSystemBuilder.enableLocking()

validate

protected Collection<String> validate()
Description copied from class: AbstractFileSystemBuilder
Validate that we can create a file system with the current properties. Subclasses can override to add more validation checks (but be sure to call super.validate()).

Overrides:
validate in class AbstractFileSystemBuilder<ZipFileSystemBuilder>
Returns:
A Collection of error messages. Can be empty but never null.

isReadOnly

protected boolean isReadOnly()
Description copied from class: AbstractFileSystemBuilderImpl
Subclasses implement this method to tell if the file system they are about to create is read only.

This method is called from AbstractFileSystemBuilderImpl.create().

Specified by:
isReadOnly in class AbstractFileSystemBuilderImpl<ZipFileSystemBuilder>
Returns:
true, always.

createAdapterFactory

protected AdapterFactory createAdapterFactory()
Description copied from class: AbstractFileSystemBuilderImpl
Subclasses implement this to create the right AdapterFactory implementation.

This method is called from AbstractFileSystemBuilderImpl.create().

Specified by:
createAdapterFactory in class AbstractFileSystemBuilderImpl<ZipFileSystemBuilder>
Returns:
An AdapterFactory implementation.

createFileSystemDelegate

protected FileSystemDelegate createFileSystemDelegate(FileSystemAdapter fsa)
Description copied from class: AbstractFileSystemBuilderImpl
This method is implemented by a subclass to create the file system delegate to use.

This method is called from AbstractFileSystemBuilderImpl.create().

Specified by:
createFileSystemDelegate in class AbstractFileSystemBuilderImpl<ZipFileSystemBuilder>
Parameters:
fsa - The file system adapter.
Returns:
A file system delegate.

createFileSystem

protected FileSystemImplementation createFileSystem(SupportObjects fso,
                                                    FileSystemDelegate fsd)
Description copied from class: AbstractFileSystemBuilderImpl
Subclasses implement this to return a new file system instance. The returned instance does not have any root directory set (yet).

This method is called from AbstractFileSystemBuilderImpl.create().

Specified by:
createFileSystem in class AbstractFileSystemBuilderImpl<ZipFileSystemBuilder>
Parameters:
fso - A collection of support objects.
fsd - The file system delegate.
Returns:
A file system implementation.