@Immutable @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public class ZipDriver extends FsCharsetArchiveDriver<ZipArchiveEntry> implements ZipEntryFactory<ZipArchiveEntry>
JarDriver instead!
This driver does not check the CRC value of any entries in existing
archives
- use CheckedZipDriver instead!
CheckedZipDriver| Modifier and Type | Field and Description |
|---|---|
private IOPoolProvider |
provider |
private static Charset |
ZIP_CHARSET
The default character set for entry names and comments, which is
"IBM437". |
| Modifier | Constructor and Description |
|---|---|
|
ZipDriver(IOPoolProvider provider)
Equivalent to
new ZipDriver(provider, ZIP_CHARSET). |
protected |
ZipDriver(IOPoolProvider provider,
Charset charset)
Constructs a new ZIP driver.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
getLevel()
Returns the value of the property
level. |
protected int |
getMethod()
Returns the value of the property
method. |
OptionOutputSocket |
getOutputSocket(FsController<?> controller,
FsEntryName name,
BitField<FsOutputOption> options,
Entry template)
This implementation modifies
options in the following way before
it forwards the call to controller:
FsOutputOption.STORE is set. |
protected IOPool<?> |
getPool() |
protected boolean |
getPostambled()
Returns the value of the property
postambled. |
protected boolean |
getPreambled()
Returns the value of the property
preambled. |
boolean |
getRedundantContentSupport() |
boolean |
getRedundantMetaDataSupport() |
ZipArchiveEntry |
newEntry(String name)
Returns a new ZIP entry with the given
name. |
ZipArchiveEntry |
newEntry(String name,
Entry.Type type,
Entry template,
BitField<FsOutputOption> mknod) |
protected ZipArchiveEntry |
newEntry(String name,
ZipArchiveEntry template) |
InputShop<ZipArchiveEntry> |
newInputShop(FsModel model,
InputSocket<?> input)
The implementation in the class
ZipDriver acquires a read only
file from the given socket and forwards the call to
newInputShop(de.schlichtherle.truezip.fs.FsModel, de.schlichtherle.truezip.socket.InputSocket<?>). |
protected InputShop<ZipArchiveEntry> |
newInputShop(ReadOnlyFile rof) |
protected OutputShop<ZipArchiveEntry> |
newOutputShop(FsModel model,
OptionOutputSocket output,
ZipInputShop source) |
OutputShop<ZipArchiveEntry> |
newOutputShop(FsModel model,
OutputSocket<?> output,
InputShop<ZipArchiveEntry> source)
This implementation first checks if
FsOutputOption.GROW is set
for the given output socket. |
protected OutputShop<ZipArchiveEntry> |
newOutputShop(OutputStream out,
ZipInputShop source) |
private OutputShop<ZipArchiveEntry> |
newOutputShop0(FsModel model,
OptionOutputSocket output,
ZipInputShop source) |
assertEncodable, getCharset, toString, toZipOrTarEntryNamegetClosedIcon, getInputSocket, getOpenIcon, isFederated, newController, newEntry, newInputStream, newOutputStream, newReadOnlyFilegetPriorityprivate static final Charset ZIP_CHARSET
"IBM437".private final IOPoolProvider provider
public ZipDriver(IOPoolProvider provider)
new ZipDriver(provider, ZIP_CHARSET).protected ZipDriver(IOPoolProvider provider, Charset charset)
provider - the I/O pool service to use for allocating temporary I/O
entries.charset - the character set to use for entry names and comments.public boolean getRedundantContentSupport()
getRedundantContentSupport in class FsArchiveDriver<ZipArchiveEntry>ZipDriver returns
true because when reading a ZIP file sequentially,
each ZIP entry should "override" any previously read
ZIP entry with an equal name.
This holds true even if the central directory is used to access
the ZIP entries in random order.public boolean getRedundantMetaDataSupport()
getRedundantMetaDataSupport in class FsArchiveDriver<ZipArchiveEntry>ZipDriver returns
true because when reading a ZIP file sequentially,
each ZIP entry should "override" any previously read
ZIP entry with an equal name.
This holds true even if the central directory is used to access
the ZIP entries in random order.protected final IOPool<?> getPool()
getPool in class FsArchiveDriver<ZipArchiveEntry>protected boolean getPreambled()
preambled.
If this is true, then a ZIP file is allowed to contain arbitrary
data as its preamble before the actual ZIP file data.
Self Extracting Archives typically use a preamble to store the
application code that is required to extract the ZIP file contents.
Note that searching for a preamble can seriously degrade the performance if the file is not compatible to the ZIP File Format Specification.
The implementation in the class ZipDriver returns false.
preambled.protected boolean getPostambled()
postambled.
If this is true, then a ZIP file is allowed to contain arbitrary
length data as its postamble after the actual ZIP file data.
If this is false, then a ZIP 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.
Note that searching for an arbitrary length postamble can seriously
degrade the performance if the file is not compatible to the ZIP File
Format Specification.
So this should be set to true only if Self Extracting Archives
with very large postambles need to get supported.
The implementation in the class ZipDriver returns false.
postambled.protected int getMethod()
method.
This is the compression method to use when writing an entry to a ZIP
output stream.
The implementation in the class ZipDriver returns
ZipEntry.DEFLATED.
method.protected int getLevel()
level.
This is the compression level to use when deflating an entry to a ZIP
output stream.
The implementation in the class ZipDriver returns
Deflater.BEST_COMPRESSION.
level.public InputShop<ZipArchiveEntry> newInputShop(FsModel model, InputSocket<?> input) throws IOException
The implementation in the class ZipDriver acquires a read only
file from the given socket and forwards the call to
newInputShop(de.schlichtherle.truezip.fs.FsModel, de.schlichtherle.truezip.socket.InputSocket<?>).
newInputShop in class FsArchiveDriver<ZipArchiveEntry>IOExceptionprotected InputShop<ZipArchiveEntry> newInputShop(ReadOnlyFile rof) throws IOException
IOExceptionpublic OptionOutputSocket getOutputSocket(FsController<?> controller, FsEntryName name, BitField<FsOutputOption> options, @CheckForNull Entry template)
options in the following way before
it forwards the call to controller:
FsOutputOption.STORE is set.
FsOutputOption.GROW is set, FsOutputOption.APPEND
gets set too, and FsOutputOption.CACHE gets cleared.
The resulting output socket is then wrapped in a private nested class
for an upcast in newOutputShop(de.schlichtherle.truezip.fs.FsModel, de.schlichtherle.truezip.socket.OutputSocket<?>, de.schlichtherle.truezip.socket.InputShop<de.schlichtherle.truezip.fs.archive.zip.ZipArchiveEntry>).
Thus, when overriding this method, newOutputShop(de.schlichtherle.truezip.fs.FsModel, de.schlichtherle.truezip.socket.OutputSocket<?>, de.schlichtherle.truezip.socket.InputShop<de.schlichtherle.truezip.fs.archive.zip.ZipArchiveEntry>) should get
overridden, too.
Otherwise, a class cast exception will get thrown in
newOutputShop(de.schlichtherle.truezip.fs.FsModel, de.schlichtherle.truezip.socket.OutputSocket<?>, de.schlichtherle.truezip.socket.InputShop<de.schlichtherle.truezip.fs.archive.zip.ZipArchiveEntry>).
getOutputSocket in class FsArchiveDriver<ZipArchiveEntry>public final OutputShop<ZipArchiveEntry> newOutputShop(FsModel model, OutputSocket<?> output, @CheckForNull InputShop<ZipArchiveEntry> source) throws IOException
FsOutputOption.GROW is set
for the given output socket.
If this is the case and the given source is not null,
then it's marked for appending to it.
Then, an output stream is acquired from the given output socket
and the parameters are forwarded to newOutputShop(FsModel, OptionOutputSocket, ZipInputShop)
and the result gets wrapped in a new FsMultiplexedOutputShop
which uses the current getPool().newOutputShop in class FsArchiveDriver<ZipArchiveEntry>IOExceptionprivate OutputShop<ZipArchiveEntry> newOutputShop0(FsModel model, OptionOutputSocket output, @CheckForNull ZipInputShop source) throws IOException
IOExceptionprotected OutputShop<ZipArchiveEntry> newOutputShop(FsModel model, OptionOutputSocket output, @CheckForNull ZipInputShop source) throws IOException
IOExceptionprotected OutputShop<ZipArchiveEntry> newOutputShop(OutputStream out, @CheckForNull ZipInputShop source) throws IOException
IOExceptionpublic ZipArchiveEntry newEntry(String name, Entry.Type type, Entry template, BitField<FsOutputOption> mknod) throws CharConversionException
newEntry in class FsArchiveDriver<ZipArchiveEntry>CharConversionExceptionpublic ZipArchiveEntry newEntry(String name)
ZipEntryFactoryname.newEntry in interface ZipEntryFactory<ZipArchiveEntry>name - the entry name.name.protected ZipArchiveEntry newEntry(String name, ZipArchiveEntry template)
Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.