|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.schlichtherle.io.archive.spi.AbstractArchiveDriver
de.schlichtherle.io.archive.zip.ZipDriver
public class ZipDriver
An archive driver which builds ZIP files. Note that this driver does not check the CRC value of any entries in existing archives.
Instances of this class are immutable.
CheckedZipDriver
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class de.schlichtherle.io.archive.spi.AbstractArchiveDriver |
---|
AbstractArchiveDriver.InconsistentCharsetSupportError |
Field Summary | |
---|---|
static String |
DEFAULT_CHARSET
The default character set to use for entry names and comments, which is "IBM437". |
static int |
DEFAULT_LEVEL
The default compression level to use when writing a ZIP output stream, which is 9. |
Constructor Summary | |
---|---|
ZipDriver()
Equivalent to this(DEFAULT_CHARSET, null, null, false, false, DEFAULT_LEVEL) . |
|
ZipDriver(int level)
Equivalent to this(DEFAULT_CHARSET, null, null, false, false, level) . |
|
ZipDriver(String charset)
Equivalent to this(charset, null, null, false, false, DEFAULT_LEVEL) . |
|
ZipDriver(String charset,
boolean preambled,
boolean postambled,
Icon openIcon,
Icon closedIcon)
|
|
ZipDriver(String charset,
Icon openIcon,
Icon closedIcon,
boolean preambled,
boolean postambled,
int level)
Constructs a new ZIP driver. |
Method Summary | |
---|---|
ArchiveEntry |
createArchiveEntry(Archive archive,
String entryName,
ArchiveEntry template)
Creates a new archive entry for entryName
for use with an OutputArchive . |
InputArchive |
createInputArchive(Archive archive,
ReadOnlyFile rof)
Creates a new input archive for archive
from the given read only file. |
OutputArchive |
createOutputArchive(Archive archive,
OutputStream out,
InputArchive source)
Creates a new output archive for archive
from the given output stream. |
protected ZipInputArchive |
createZip32InputArchive(Archive archive,
ReadOnlyFile rof)
Deprecated. Use createZipInputArchive(de.schlichtherle.io.archive.Archive, de.schlichtherle.io.rof.ReadOnlyFile) instead. |
protected ZipOutputArchive |
createZip32OutputArchive(Archive archive,
OutputStream out,
ZipInputArchive source)
Deprecated. Use createZipOutputArchive(de.schlichtherle.io.archive.Archive, java.io.OutputStream, de.schlichtherle.io.archive.zip.ZipInputArchive) instead. |
protected ZipEntry |
createZipEntry(String entryName)
|
protected ZipEntry |
createZipEntry(ZipEntry template)
|
protected ZipInputArchive |
createZipInputArchive(Archive archive,
ReadOnlyFile rof)
|
protected ZipOutputArchive |
createZipOutputArchive(Archive archive,
OutputStream out,
ZipInputArchive source)
|
int |
getLevel()
Returns the value of the property level which was
provided to the constructor. |
boolean |
getPostambled()
Returns the value of the property postambled which was
provided to the constructor. |
boolean |
getPreambled()
Returns the value of the property preambled which was
provided to the constructor. |
Methods inherited from class de.schlichtherle.io.archive.spi.AbstractArchiveDriver |
---|
ensureEncodable, getCharset, getClosedIcon, getEncoding, getOpenIcon |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.schlichtherle.io.archive.spi.ArchiveDriver |
---|
equals, hashCode |
Field Detail |
---|
public static final String DEFAULT_CHARSET
public static final int DEFAULT_LEVEL
Constructor Detail |
---|
public ZipDriver()
this(DEFAULT_CHARSET, null, null, false, false, DEFAULT_LEVEL)
.
public ZipDriver(String charset)
this(charset, null, null, false, false, DEFAULT_LEVEL)
.
public ZipDriver(int level)
this(DEFAULT_CHARSET, null, null, false, false, level)
.
public ZipDriver(String charset, boolean preambled, boolean postambled, Icon openIcon, Icon closedIcon)
public ZipDriver(String charset, Icon openIcon, Icon closedIcon, boolean preambled, boolean postambled, int level)
preambled
- true
if and only if a prospective ZIP
compatible file is allowed to contain preamble data before the
actual ZIP file data.
Self Extracting Archives typically use the preamble to store the
application code that is required to extract the ZIP file contents.
Please note that any ZIP compatible file may actually have a
preamble. However, for performance reasons this parameter should
be set to false
, unless required.
postambled
- true
if and only if a prospective ZIP
compatible file is allowed to have a postamble of arbitrary
length.
If set to false
, the ZIP compatible file may still
have a postamble. However, the postamble must not exceed 64KB
size, including the End Of Central Directory record and thus
the ZIP file comment. This causes the initial ZIP file
compatibility test to fail fast if the file is not compatible
to the ZIP File Format Specification.
For performance reasons, this parameter should be set to
false
unless you need to support Self Extracting
Archives with very large postambles.level
- The compression level to use when deflating an entry to
a ZIP output stream.
IllegalArgumentException
- If level
is not in the
range [0, 9]
and is not -1.Method Detail |
---|
public final boolean getPreambled()
preambled
which was
provided to the constructor.
public final boolean getPostambled()
postambled
which was
provided to the constructor.
public final int getLevel()
level
which was
provided to the constructor.
public ArchiveEntry createArchiveEntry(Archive archive, String entryName, ArchiveEntry template) throws CharConversionException
ArchiveDriver
entryName
for use with an OutputArchive
.
archive
- The abstract archive representation which TrueZIP's
internal ArchiveController
is processing
- never null
.entryName
- A valid archive entry name - never null
.template
- If not null
, then the newly created entry
shall inherit as much attributes from this object as possible
(with the exception of the name).
This is typically used for archive copy operations.
Note that there is no guarantee on the runtime type of this
object; it may have been created by other drivers.
It is safe to ignore the metaData
property when
copying entries.
CharConversionException
- If name
contains
illegal characters.protected ZipEntry createZipEntry(ZipEntry template)
protected ZipEntry createZipEntry(String entryName)
public InputArchive createInputArchive(Archive archive, ReadOnlyFile rof) throws IOException
archive
from the given read only file.
Note that if an exception is thrown, the method must be reentrant!
In addition, the exception type determines the behaviour of the classes
File
, FileInputStream
and FileOutputStream
as follows:
Exception type | File.isFile() |
File.isDirectory() |
File.exists() |
File.delete() |
---|---|---|---|---|
FileNotFoundException |
false |
false |
true |
true (unless prohibited by the real file system) |
IOException |
true |
false |
true |
true (unless prohibited by the real file system) |
The implementation in ZipDriver
simply forwards the call to
createZipInputArchive(de.schlichtherle.io.archive.Archive, de.schlichtherle.io.rof.ReadOnlyFile)
.
archive
- The abstract archive representation which TrueZIP's
internal ArchiveController
is processing
- never null
.rof
- The ReadOnlyFile
to read the
actual archive contents from - never null
.
Hint: If you'ld prefer to have an InputStream
,
you could decorate this parameter with a
ReadOnlyFileInputStream
.
TransientIOException
- If calling this method for the same
archive file again may finally succeed.
This exception is associated with another IOException
as its cause which is unwrapped and interpreted as below.
FileNotFoundException
- If the input archive is inaccessible
for any reason and you would like the package
de.schlichtherle.io
to mask the archive as a
special file which cannot get read, written or deleted.
IOException
- On any other I/O or data format related issue
when reading the input archive and you would like the package
de.schlichtherle.io
to treat the archive like a
regular file which may be read, written or deleted.InputArchive
protected ZipInputArchive createZipInputArchive(Archive archive, ReadOnlyFile rof) throws IOException
IOException
protected ZipInputArchive createZip32InputArchive(Archive archive, ReadOnlyFile rof) throws IOException
createZipInputArchive(de.schlichtherle.io.archive.Archive, de.schlichtherle.io.rof.ReadOnlyFile)
instead.
IOException
public OutputArchive createOutputArchive(Archive archive, OutputStream out, InputArchive source) throws IOException
archive
from the given output stream.
The implementation in ZipDriver
simply forwards the call to
createZipOutputArchive(de.schlichtherle.io.archive.Archive, java.io.OutputStream, de.schlichtherle.io.archive.zip.ZipInputArchive)
and wraps the result in a new
MultiplexedOutputArchive
.
archive
- The abstract archive representation which TrueZIP's
internal ArchiveController
is processing
- never null
.out
- The OutputStream
to write the archive entries to
- never null
.source
- The source InputArchive
if
archive
is going to get updated.
If not null
, this is guaranteed to be a product
of this driver's ArchiveDriver.createInputArchive(de.schlichtherle.io.archive.Archive, de.schlichtherle.io.rof.ReadOnlyFile)
method.
This may be used to copy some meta data which is specific to
the type of archive this driver supports.
For example, this could be used to copy the comment of a ZIP
file.
TransientIOException
- If calling this method for the same
archive file again may finally succeed.
This exception is associated with another IOException
as its cause which is unwrapped and interpreted as below.
FileNotFoundException
- If the output archive is inaccessible
for any reason.
IOException
- On any other I/O or data format related issue
when writing the output archive.OutputArchive
protected ZipOutputArchive createZipOutputArchive(Archive archive, OutputStream out, ZipInputArchive source) throws IOException
IOException
protected ZipOutputArchive createZip32OutputArchive(Archive archive, OutputStream out, ZipInputArchive source) throws IOException
createZipOutputArchive(de.schlichtherle.io.archive.Archive, java.io.OutputStream, de.schlichtherle.io.archive.zip.ZipInputArchive)
instead.
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |