E
- the type of the archive entries.@Immutable public abstract class FsArchiveDriver<E extends FsArchiveEntry> extends FsDriver
Subclasses must be thread-safe and should be immutable!
Constructor and Description |
---|
FsArchiveDriver() |
Modifier and Type | Method and Description |
---|---|
protected void |
assertEncodable(String name)
Ensures that the given entry name can get encoded by this driver's
character set.
|
InputSocket<?> |
getInputSocket(FsController<?> controller,
FsEntryName name,
BitField<FsInputOption> options)
Called to prepare reading an archive file artifact of this driver from
name in controller using options . |
OutputSocket<?> |
getOutputSocket(FsController<?> controller,
FsEntryName name,
BitField<FsOutputOption> options,
Entry template)
Called to prepare writing an archive file artifact of this driver to
the entry
name in controller using options and
the nullable template . |
protected abstract IOPool<?> |
getPool()
Returns the I/O buffer pool to use for allocating temporary I/O buffers.
|
boolean |
getRedundantContentSupport()
Returns
true if and only if the archive files produced by this
archive driver may contain redundant archive entry contents. |
boolean |
getRedundantMetaDataSupport()
Returns
true if and only if the archive files produced by this
archive driver may contain redundant archive entry meta data. |
boolean |
isFederated()
Returns
true iff this file system driver implements a federated
file system type, i.e. |
FsController<? extends FsModel> |
newController(FsManager manager,
FsModel model,
FsController<? extends FsModel> parent)
Returns a new thread-safe file system controller for the mount point of
the given file system model and nullable parent file system controller.
|
FsController<?> |
newController(FsModel model,
FsController<?> parent)
Returns a new thread-safe file system controller for the mount point of
the given file system model and parent file system controller.
|
E |
newEntry(String name,
Entry.Type type,
Entry template)
Equivalent to
newEntry(name, type, template, FsOutputOptions.NONE) . |
abstract E |
newEntry(String name,
Entry.Type type,
Entry template,
BitField<FsOutputOption> options)
Returns a new entry for the given name.
|
abstract InputShop<E> |
newInputShop(FsModel model,
InputSocket<?> input)
Creates a new input shop for reading the archive entries for the
given
model from the given input socket's target. |
abstract OutputShop<E> |
newOutputShop(FsModel model,
OutputSocket<?> output,
InputShop<E> source)
Creates a new output shop for writing archive entries for the
given
model to the given output socket's target. |
getPriority, toString
protected void assertEncodable(String name) throws CharConversionException
The implementation in the class FsArchiveDriver
is just a stub
and does nothing.
name
- an entry name.CharConversionException
- If the entry name contains characters
which cannot get encoded.public InputSocket<?> getInputSocket(FsController<?> controller, FsEntryName name, BitField<FsInputOption> options)
name
in controller
using options
.
This method may get overridden in order to modify the given options
before forwarding the call to the given controller.
The implementation in the class FsArchiveDriver
simply forwards
the call to the given controller with the given options unaltered.
controller
- the controller to use for reading an artifact of this
driver.name
- the entry name.options
- the options to use.public OutputSocket<?> getOutputSocket(FsController<?> controller, FsEntryName name, BitField<FsOutputOption> options, @CheckForNull Entry template)
name
in controller
using options
and
the nullable template
.
This method may get overridden in order to modify the given options
before forwarding the call to the given controller.
The implementation in the class FsArchiveDriver
simply forwards
the call to the given controller with the given options unaltered.
controller
- the controller to use for writing an artifact of this
driver.name
- the entry name.options
- the options to use.template
- the template to use.protected abstract IOPool<?> getPool()
Multiple invocations should return the same I/O buffer pool. However, callers should cache the return value for subsequent use in case it isn't always the same.
public boolean getRedundantContentSupport()
true
if and only if the archive files produced by this
archive driver may contain redundant archive entry contents.
If the return value is true
, then an archive file may contain
redundant archive entry contents, but only the last contents written
should get used when reading the archive file.FsArchiveDriver
returns
false
for backwards compatibility.public boolean getRedundantMetaDataSupport()
true
if and only if the archive files produced by this
archive driver may contain redundant archive entry meta data.
If the return value is true
, then an archive file may contain
redundant archive entry meta data, but only the last meta data written
should get used when reading the archive file.
This usually implies the existence of a central directory in the
resulting archive file.FsArchiveDriver
returns
false
for backwards compatibility.public final boolean isFederated()
true
iff this file system driver implements a federated
file system type, i.e. if the type of file system must be a member of a
parent file system.
The implementation in the class FsDriver
returns false
.
The implementation in the class FsArchiveDriver
always returns
true
.
isFederated
in class FsDriver
true
iff the type of the file system implemented by this
file system driver is federated, i.e. must be a member of a
parent file system.public final FsController<? extends FsModel> newController(FsManager manager, FsModel model, @CheckForNull FsController<? extends FsModel> parent)
When called, you may assert the following precondition:
assert null == parent
? null == model.getParent()
: parent.getModel().equals(model.getParent())
The implementation in the class FsDriver
simply forwards the
call to FsDriver.newController(FsModel, FsController)
.
The implementation in the class FsArchiveDriver
simply forwards
the call to the given file system manager after asserting that
model.getParent().equals(parent.getModel())
is true
.
newController
in class FsDriver
manager
- the file system manager for the new controller.model
- the file system model.parent
- the nullable parent file system controller.FsCompositeDriver.newController(de.schlichtherle.truezip.fs.FsManager, de.schlichtherle.truezip.fs.FsModel, de.schlichtherle.truezip.fs.FsController<? extends de.schlichtherle.truezip.fs.FsModel>)
public FsController<?> newController(FsModel model, @Nonnull FsController<?> parent)
When called, you may assert the following precondition:
model.getParent().equals(parent.getModel())
Note that the parent file system controller of an archive file system is
never null
.
newController
in class FsDriver
model
- the file system model.parent
- the non-null parent file system controller.FsCompositeDriver.newController(de.schlichtherle.truezip.fs.FsManager, de.schlichtherle.truezip.fs.FsModel, de.schlichtherle.truezip.fs.FsController<? extends de.schlichtherle.truezip.fs.FsModel>)
public final E newEntry(String name, Entry.Type type, @CheckForNull Entry template) throws CharConversionException
newEntry(name, type, template, FsOutputOptions.NONE)
.name
- an entry name.type
- an entry type.template
- if not null
, then the new entry shall inherit
as much properties from this entry as possible - with the
exception of its name and type.CharConversionException
- if name
contains characters
which are invalid.public abstract E newEntry(String name, Entry.Type type, @CheckForNull Entry template, BitField<FsOutputOption> options) throws CharConversionException
entry name
for their
particular requirements.
If template
is not null
, then the returned entry shall
inherit as much properties from this template as possible - with the
exception of its name and type.
Furthermore, if name
and type
are equal to the name and
type of this template, then the returned entry shall be a (deep) clone
of the template which shares no mutable state with the template.
name
- an entry name.type
- an entry type.template
- if not null
, then the new entry shall inherit
as much properties from this entry as possible - with the
exception of its name and type.options
- when called from FsController.mknod(de.schlichtherle.truezip.fs.FsEntryName, de.schlichtherle.truezip.entry.Entry.Type, de.schlichtherle.truezip.util.BitField<de.schlichtherle.truezip.fs.FsOutputOption>, de.schlichtherle.truezip.entry.Entry)
, this is its
options
parameter, otherwise it's typically an empty set.CharConversionException
- TODO: This has been deprecated and
should get removed.@CreatesObligation public abstract InputShop<E> newInputShop(FsModel model, InputSocket<?> input) throws IOException
model
from the given input
socket's target.
Note that the returned input shop does not need to be thread-safe.
model
- the file system model.input
- the input socket for reading the contents of the
archive file from its target.
This is guaranteed to be the product of this driver's
getInputSocket(de.schlichtherle.truezip.fs.FsController<?>, de.schlichtherle.truezip.fs.FsEntryName, de.schlichtherle.truezip.util.BitField<de.schlichtherle.truezip.fs.FsInputOption>)
method.IOException
- on any I/O error.
If the file system entry for the given model exists in the
parent file system and is not a Entry.Type.SPECIAL
type, then this exception is deemed to indicate a
persistent false positive archive file and gets cached
until the file system controller for the given model is
synced
again.
Otherwise, this exception is deemed to indicate a
transient false positive archive file and does not
get cached.@CreatesObligation public abstract OutputShop<E> newOutputShop(FsModel model, OutputSocket<?> output, @CheckForNull @WillNotClose InputShop<E> source) throws IOException
model
to the given output
socket's target.
Note that the returned output shop does not need to be thread-safe.
model
- the file system model.output
- the output socket for writing the contents of the
archive file to its target.
This is guaranteed to be the product of this driver's
getOutputSocket(de.schlichtherle.truezip.fs.FsController<?>, de.schlichtherle.truezip.fs.FsEntryName, de.schlichtherle.truezip.util.BitField<de.schlichtherle.truezip.fs.FsOutputOption>, de.schlichtherle.truezip.entry.Entry)
method.source
- the InputShop
if archive
is going to get
updated.
If not null
, this is guaranteed to be the product
of this driver's newInputShop(de.schlichtherle.truezip.fs.FsModel, de.schlichtherle.truezip.socket.InputSocket<?>)
factory method.
This feature could get used to copy some meta data which is
specific to the type of archive this driver supports,
e.g. the comment of a ZIP file.IOException
- on any I/O error.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.