E - the type of the ZIP driver entries.@Immutable
public abstract class AbstractZipDriver<E extends AbstractZipDriverEntry>
extends net.java.truevfs.kernel.spec.FsArchiveDriver<E>
implements net.java.truevfs.comp.zip.ZipOutputStreamParameters, net.java.truevfs.comp.zip.ZipFileParameters<E>
Sub-classes must be thread-safe and should be immutable!
| Constructor and Description |
|---|
AbstractZipDriver() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
check(E local,
ZipInputService<E> input)
Whether or not the content of the given entry shall get
checked/authenticated when reading it.
|
net.java.truevfs.kernel.spec.FsController |
decorate(net.java.truevfs.kernel.spec.FsController controller) |
java.net.URI |
fileSystemUri(net.java.truevfs.kernel.spec.FsModel model,
java.lang.String name)
A template method for resolving the resource URI which is required to
look up the
KeyProvider for the entry with the given name in the
file system with the given model. |
net.java.truecommons.key.spec.KeyManagerMap |
getKeyManagerMap()
Returns the map of key managers for accessing protected resources
(encryption).
|
int |
getLevel() |
int |
getMethod() |
int |
getOverheadSize() |
net.java.truecommons.cio.IoBufferPool |
getPool() |
boolean |
getPostambled() |
boolean |
getPreambled() |
boolean |
getRedundantContentSupport() |
boolean |
getRedundantMetaDataSupport() |
java.net.URI |
mountPointUri(net.java.truevfs.kernel.spec.FsModel model)
A template method for resolving the resource URI which is required to
look up the
KeyProvider for the mount point of the file system
with the given model. |
E |
newEntry(net.java.truecommons.shed.BitField<net.java.truevfs.kernel.spec.FsAccessOption> options,
java.lang.String name,
net.java.truecommons.cio.Entry.Type type,
net.java.truecommons.cio.Entry template) |
abstract E |
newEntry(java.lang.String name)
Returns a new ZIP driver entry with the given
name. |
abstract E |
newEntry(java.lang.String name,
net.java.truevfs.comp.zip.ZipEntry template)
Returns a new ZIP driver entry with the given
name and all
other properties copied from the given template. |
protected ZipInputService<E> |
newInput(net.java.truevfs.kernel.spec.FsModel model,
net.java.truevfs.kernel.spec.FsInputSocketSource source) |
protected net.java.truecommons.cio.OutputService<E> |
newOutput(net.java.truevfs.kernel.spec.FsModel model,
net.java.truevfs.kernel.spec.FsOutputSocketSink sink,
net.java.truecommons.cio.InputService<E> input) |
protected ZipInputService<E> |
newZipInput(net.java.truevfs.kernel.spec.FsModel model,
net.java.truevfs.kernel.spec.FsInputSocketSource source) |
protected boolean |
rdc(AbstractZipDriverEntry input,
AbstractZipDriverEntry output)
Returns
true if and only if the content of the given input
target entry is eligible for Raw Data Copying (RDC). |
protected net.java.truevfs.kernel.spec.FsOutputSocketSink |
sink(net.java.truecommons.shed.BitField<net.java.truevfs.kernel.spec.FsAccessOption> options,
net.java.truevfs.kernel.spec.FsController controller,
net.java.truevfs.kernel.spec.FsNodeName name)
This implementation transforms
options in the following way before
it forwards the call to controller:
FsAccessOption.STORE is set. |
protected net.java.truevfs.comp.zip.ZipCryptoParameters |
zipCryptoParameters(net.java.truevfs.kernel.spec.FsModel model,
java.nio.charset.Charset charset)
Returns the ZIP crypto parameters for the given file system model
and character set or
null if not available. |
checkEncodable, getCharset, isArchiveDriver, newController, newEntry, newInput, newOutput, normalize, source, toStringpublic net.java.truecommons.cio.IoBufferPool getPool()
The implementation in the class AbstractZipDriver returns
IoBufferPoolLocator.SINGLETON.get().
getPool in class net.java.truevfs.kernel.spec.FsArchiveDriver<E extends AbstractZipDriverEntry>public net.java.truecommons.key.spec.KeyManagerMap getKeyManagerMap()
This is an immutable property - multiple calls must return the same object.
KeyManagerMapLocator.SINGLETON, as by the implementation
in the class ZipDriver.@CheckForNull
protected net.java.truevfs.comp.zip.ZipCryptoParameters zipCryptoParameters(net.java.truevfs.kernel.spec.FsModel model,
java.nio.charset.Charset charset)
null if not available.
To enable the use of this method when writing an archive entry with the
client APIs, you must use FsAccessOption.ENCRYPT.
The implementation in the class ZipDriver returns
new KeyManagerZipCryptoParameters(this, model, charset).
model - the file system model.charset - charset the character set used for encoding entry names
and the file comment in the ZIP file.null if not available.public java.net.URI mountPointUri(net.java.truevfs.kernel.spec.FsModel model)
KeyProvider for the mount point of the file system
with the given model.
The implementation in the class ZipDriver returns the
expression model.getMountPoint().toHierarchicalUri()
in order to improve the readability of the URI in comparison to the
expression model.getMountPoint().getUri().
model - the file system model.public java.net.URI fileSystemUri(net.java.truevfs.kernel.spec.FsModel model,
java.lang.String name)
KeyProvider for the entry with the given name in the
file system with the given model.
The implementation in the class ZipDriver ignores the given
entry name and just returns the expression mountPointUri(model)
in order to lookup the same key provider for all entries in a ZIP file.
An alternative implementation in a sub-class could return the expression
mountPointUri(model).resolve("/" + name) instead.
model - the file system model.name - the entry name.KeyProvider.public boolean getRedundantContentSupport()
getRedundantContentSupport in class net.java.truevfs.kernel.spec.FsArchiveDriver<E extends AbstractZipDriverEntry>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 net.java.truevfs.kernel.spec.FsArchiveDriver<E extends AbstractZipDriverEntry>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 check(E local, @WillNotClose ZipInputService<E> input)
true and the check fails, then an
IOException gets thrown.local - the entry to test.input - the origin of the entry.entry.isEncrypted().protected boolean rdc(AbstractZipDriverEntry input, AbstractZipDriverEntry output)
true if and only if the content of the given input
target entry is eligible for Raw Data Copying (RDC).
This method gets called twice (once on each side of a copy operation)
and should return false unless both target entries can mutually
agree on transferring raw (unprocessed) content.
Note that it is an error to compare the properties of the target entries
because this method may get called before the output target
entry gets mutated to compare equal with the input target entry!
The implementation in the class ZipDriver returns
!local.isEncrypted() && !remote.isEncrypted() in order to cover
the typical case that the cipher keys of both targets are not the same.
Note that there is no safe way to explicitly test for this.
input - the input target entry for copying the contents.output - the output target entry for copying the contents.public boolean getPreambled()
The implementation in the class ZipDriver
returns false.
getPreambled in interface net.java.truevfs.comp.zip.ZipFileParameters<E extends AbstractZipDriverEntry>falsepublic boolean getPostambled()
The implementation in the class ZipDriver
returns false.
getPostambled in interface net.java.truevfs.comp.zip.ZipFileParameters<E extends AbstractZipDriverEntry>falsepublic int getOverheadSize()
The implementation in the class ZipDriver
returns Maps#OVERHEAD_SIZE.
getOverheadSize in interface net.java.truevfs.comp.zip.ZipOutputStreamParametersMaps#OVERHEAD_SIZEpublic int getMethod()
The implementation in the class ZipDriver
returns ZipEntry#DEFLATED.
getMethod in interface net.java.truevfs.comp.zip.ZipOutputStreamParametersZipEntry#DEFLATEDpublic int getLevel()
The implementation in the class ZipDriver
returns Deflater#BEST_COMPRESSION.
getLevel in interface net.java.truevfs.comp.zip.ZipOutputStreamParametersDeflater#BEST_COMPRESSIONpublic net.java.truevfs.kernel.spec.FsController decorate(net.java.truevfs.kernel.spec.FsController controller)
The implementation in the class ZipDriver decorates the given controller with a package private
controller which keeps track of the AES PBE parameters, e.g. the encryption passwords.
This method should be overridden in order to return just controller if and only if you are overriding
zipCryptoParameters(FsModel, Charset), too, and do not want to use a locatable key manager to resolve
passwords for WinZip AES encryption.
decorate in class net.java.truevfs.kernel.spec.FsArchiveDriver<E extends AbstractZipDriverEntry>protected final ZipInputService<E> newInput(net.java.truevfs.kernel.spec.FsModel model, net.java.truevfs.kernel.spec.FsInputSocketSource source) throws java.io.IOException
newInput in class net.java.truevfs.kernel.spec.FsArchiveDriver<E extends AbstractZipDriverEntry>java.io.IOException@CreatesObligation protected ZipInputService<E> newZipInput(net.java.truevfs.kernel.spec.FsModel model, net.java.truevfs.kernel.spec.FsInputSocketSource source) throws java.io.IOException
java.io.IOException@CreatesObligation protected net.java.truecommons.cio.OutputService<E> newOutput(net.java.truevfs.kernel.spec.FsModel model, net.java.truevfs.kernel.spec.FsOutputSocketSink sink, @CheckForNull @WillNotClose net.java.truecommons.cio.InputService<E> input) throws java.io.IOException
newOutput in class net.java.truevfs.kernel.spec.FsArchiveDriver<E extends AbstractZipDriverEntry>java.io.IOExceptionprotected net.java.truevfs.kernel.spec.FsOutputSocketSink sink(net.java.truecommons.shed.BitField<net.java.truevfs.kernel.spec.FsAccessOption> options,
net.java.truevfs.kernel.spec.FsController controller,
net.java.truevfs.kernel.spec.FsNodeName name)
options in the following way before
it forwards the call to controller:
FsAccessOption.STORE is set.
FsAccessOption.GROW is set, then
FsAccessOption.APPEND gets set, too, and
FsAccessOption.CACHE gets cleared.
The resulting output socket is then wrapped in a private nested class
for an upcast in newOutput(net.java.truevfs.kernel.spec.FsModel, net.java.truevfs.kernel.spec.FsOutputSocketSink, net.java.truecommons.cio.InputService<E>).
Thus, when overriding this method, newOutput(net.java.truevfs.kernel.spec.FsModel, net.java.truevfs.kernel.spec.FsOutputSocketSink, net.java.truecommons.cio.InputService<E>) should get
overridden, too.
Otherwise, a class cast exception will be thrown in newOutput(net.java.truevfs.kernel.spec.FsModel, net.java.truevfs.kernel.spec.FsOutputSocketSink, net.java.truecommons.cio.InputService<E>).
sink in class net.java.truevfs.kernel.spec.FsArchiveDriver<E extends AbstractZipDriverEntry>public E newEntry(net.java.truecommons.shed.BitField<net.java.truevfs.kernel.spec.FsAccessOption> options, java.lang.String name, net.java.truecommons.cio.Entry.Type type, @CheckForNull net.java.truecommons.cio.Entry template)
newEntry in class net.java.truevfs.kernel.spec.FsArchiveDriver<E extends AbstractZipDriverEntry>public abstract E newEntry(java.lang.String name)
name.newEntry in interface net.java.truevfs.comp.zip.ZipEntryFactory<E extends AbstractZipDriverEntry>name - the entry name.public abstract E newEntry(java.lang.String name, net.java.truevfs.comp.zip.ZipEntry template)
name and all
other properties copied from the given template.name - the entry name.template - the template entry.