|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.entityfs.util.AbstractIteratorUtil org.entityfs.util.zip.AbstractZipCreator<T>
public abstract class AbstractZipCreator<T extends AbstractZipCreator<?>>
Abstract base class for creating Zip files.
Constructor Summary | |
---|---|
protected |
AbstractZipCreator(Iterator<? extends ZipEntryInfo> itr,
DirectoryView targetDirectory,
String targetFileName,
ErrorHandlingStrategy ehs)
Create an AbstractZipCreator that uses the supplied
ErrorHandlingStrategy . |
Method Summary | |
---|---|
EFile |
create()
Create the Zip file. |
EFile |
create(EntityLock wl)
Create the Zip file. |
protected ZipOutputStream |
createOutputStream(WritableFile f)
Create the output stream to write contents to. |
protected EFile |
createTargetFile(DirectoryView dv,
String name)
Create the target Zip file (empty). |
protected DirectoryView |
getTargetDirectory()
|
protected String |
getTargetFileName()
|
protected T |
getThis()
Get this cast to its actual type. |
T |
setComment(String comment)
Set the Zip file comment. |
T |
setLevel(int level)
Set the entry compression level (see ZipOutputStream.setLevel(int) ). |
T |
setMethod(int method)
Set the entry compression method (see ZipOutputStream.setMethod(int) ). |
Methods inherited from class org.entityfs.util.AbstractIteratorUtil |
---|
letErrorStrategyHandle, letErrorStrategyHandle, letErrorStrategyHandle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AbstractZipCreator(Iterator<? extends ZipEntryInfo> itr, DirectoryView targetDirectory, String targetFileName, ErrorHandlingStrategy ehs)
AbstractZipCreator
that uses the supplied
ErrorHandlingStrategy
.
itr
- The iterator to get ZipEntryInfo
objects from.targetDirectory
- The directory where the Zip file will be created.targetFileName
- The name of the Zip file.ehs
- The error handling strategy. Set to null
to use the
default ErrorHandlingStrategy
.Method Detail |
---|
protected final T getThis()
this
cast to its actual type. This is useful for returning
the right type of this
when implementing setter methods that
return the called object.
this
cast to its actual type.protected DirectoryView getTargetDirectory()
protected String getTargetFileName()
public T setComment(String comment)
comment
- The Zip file comment.
this
.public T setMethod(int method)
ZipOutputStream.setMethod(int)
). Default is
ZipOutputStream.DEFLATED
.
method
- The compression method.
this
.public T setLevel(int level)
ZipOutputStream.setLevel(int)
). Default is to use the Zlib
library's default compression level. It is currently set to
6
, but that may change in the future.
level
- The compression level.
this
.protected EFile createTargetFile(DirectoryView dv, String name)
dv
- The parent directory. This is locked for writing when this
method is called. The method should not release that lock.name
- The name of the file
protected ZipOutputStream createOutputStream(WritableFile f) throws IOException
The target file is locked for writing when this method is called.
IOException
public EFile create(EntityLock wl) throws UncheckedInterruptedException, EntityFoundException
wl
- A locked write lock for the target directory. The lock will be
released as soon as the Zip file is created and locked. This method is
responsible for unlocking this lock, regardless of its result, even if it
throws an exception.
null
if the supplied iterator did
not return any entities. (In which case the file is not created.)
UncheckedInterruptedException
- If the thread is interrupted.
EntityFoundException
- If an entity with the same name as the Zip
file already exists.public EFile create() throws UncheckedInterruptedException, EntityFoundException
null
if the supplied iterator did
not return any entities. (In which case the file is not created.)
UncheckedInterruptedException
- If the thread is interrupted.
EntityFoundException
- If an entity with the same name as the Zip
file already exists.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |