E - The type of the archive entries.@NotThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) abstract class FsArchiveController<E extends FsArchiveEntry> extends FsConcurrentModelController
Each instance of this class manages an archive file - the target file - in order to allow random access to it as if it were a regular directory in its parent file system.
Note that in general all of the methods in this class are reentrant on exceptions. This is important because client applications may repeatedly call them. Of course, depending on the calling context, some or all of the archive file's data may be lost in this case.
| Modifier and Type | Class and Description |
|---|---|
private class |
FsArchiveController.Input |
private class |
FsArchiveController.Output |
private static class |
FsArchiveController.ProxyEntry |
| Modifier and Type | Field and Description |
|---|---|
private ThreadLocal<FsOperationContext> |
context |
private static Logger |
logger |
| Constructor and Description |
|---|
FsArchiveController(FsConcurrentModel model)
Constructs a new basic archive controller.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) FsArchiveFileSystem<E> |
autoMount()
Equivalent to
autoMount(false). |
(package private) abstract FsArchiveFileSystem<E> |
autoMount(boolean autoCreate)
Returns the (virtual) archive file system mounted from the target
archive file.
|
(package private) abstract void |
checkAccess(FsEntryName name,
Entry.Access intention)
Checks if the intended access to the named archive entry in the virtual
file system is possible without performing a
sync operation in
advance. |
(package private) FsOperationContext |
getContext()
Returns a JavaBean which represents the original values of selected
parameters for the
FsContextController operation in progress. |
FsEntry |
getEntry(FsEntryName name)
Returns a file system entry or
null if no file system entry
exists for the given name. |
InputSocket<?> |
getInputSocket(FsEntryName name,
BitField<FsInputOption> options)
Returns an input socket for reading the contents of the file system
entry addressed by the given name from the file system.
|
(package private) abstract InputSocket<?> |
getInputSocket(String name) |
(package private) abstract OutputSocket<?> |
getOutputSocket(E entry) |
OutputSocket<?> |
getOutputSocket(FsEntryName name,
BitField<FsOutputOption> options,
Entry template)
Returns an output socket for writing the contents of the entry addressed
by the given name to the file system.
|
boolean |
isReadable(FsEntryName name)
Returns
false if the named file system entry is not readable. |
boolean |
isReadOnly()
Returns
true if and only if the file system is read-only. |
boolean |
isWritable(FsEntryName name)
Returns
false if the named file system entry is not writable. |
void |
mknod(FsEntryName name,
Entry.Type type,
BitField<FsOutputOption> options,
Entry template)
Creates or replaces and finally links a chain of one or more entries
for the given entry
name into the file system. |
(package private) void |
setContext(FsOperationContext context)
Sets the JavaBean which represents the original values of selected
parameters for the
FsContextController operation in progress. |
void |
setReadOnly(FsEntryName name) |
boolean |
setTime(FsEntryName name,
BitField<Entry.Access> types,
long value,
BitField<FsOutputOption> options)
Makes an attempt to set the last access time of all types in the given
bit field for the file system entry with the given name.
|
boolean |
setTime(FsEntryName name,
Map<Entry.Access,Long> times,
BitField<FsOutputOption> options)
Makes an attempt to set the last access time of all types in the given
map for the file system entry with the given name.
|
void |
unlink(FsEntryName name,
BitField<FsOutputOption> options)
Removes the named file system entry from the file system.
|
assertNotReadLockedByCurrentThread, assertWriteLockedByCurrentThread, isWriteLockedByCurrentThread, readLock, writeLockgetModel, getMountPoint, isTouched, setTouchedequals, getClosedIcon, getOpenIcon, getParent, hashCode, isExecutable, sync, sync, toStringprivate final ThreadLocal<FsOperationContext> context
private static final Logger logger
FsArchiveController(FsConcurrentModel model)
model - the non-null archive model.final FsArchiveFileSystem<E> autoMount() throws IOException
autoMount(false).IOExceptionabstract FsArchiveFileSystem<E> autoMount(boolean autoCreate) throws IOException
Warning: Either the read or the write lock of this controller must be acquired while this method is called! If only a read lock is acquired, but a write lock is required, this method will temporarily release all locks, so any preconditions must be checked again upon return to protect against concurrent modifications!
autoCreate - If the archive file does not exist and this is
true, a new archvie file system with only a (virtual)
root directory is created with its last modification time set
to the system's current time.IOExceptionabstract void checkAccess(FsEntryName name, @CheckForNull Entry.Access intention) throws FsNotSyncedException
sync operation in
advance.name - the file system entry name.intention - the intended I/O operation on the archive entry.
If null, then only an update to the archive entry meta
data (i.e. a pure virtual file system operation with no I/O)
is intended.FsNotSyncedException - If a sync operation is required.final FsOperationContext getContext()
FsContextController operation in progress.
Note that this is a thread-local property!
FsContextController operation in
progress.public final FsEntry getEntry(FsEntryName name) throws IOException
FsControllernull if no file system entry
exists for the given name.
Modifying the returned object is either not supported (i.e. throws an
UnsupportedOperationException) or does not show any effect on
the file system.getEntry in class FsController<FsConcurrentModel>name - the name of the file system entry.null if no file system entry
exists for the given name.IOException - on any I/O error.public final InputSocket<?> getInputSocket(FsEntryName name, BitField<FsInputOption> options)
FsControllergetInputSocket in class FsController<FsConcurrentModel>name - the file system entry name.options - the input options.InputSocket.abstract InputSocket<?> getInputSocket(String name)
abstract OutputSocket<?> getOutputSocket(E entry)
public final OutputSocket<?> getOutputSocket(FsEntryName name, BitField<FsOutputOption> options, Entry template)
FsControllertemplate is not null, then the output entry shall
have as many of its properties copied as reasonable, e.g. the last
modification time.getOutputSocket in class FsController<FsConcurrentModel>name - a file system entry name.options - a bit field of output options.template - a nullable template for the properties of the output
entry.OutputSocket.public final boolean isReadable(FsEntryName name) throws IOException
FsControllerfalse if the named file system entry is not readable.isReadable in class FsController<FsConcurrentModel>name - the name of the file system entry.false if the named file system entry is not readable.IOException - On any I/O error.public final boolean isReadOnly()
throws IOException
FsControllertrue if and only if the file system is read-only.isReadOnly in class FsController<FsConcurrentModel>true if and only if the file system is read-only.IOException - on any I/O error.public final boolean isWritable(FsEntryName name) throws IOException
FsControllerfalse if the named file system entry is not writable.isWritable in class FsController<FsConcurrentModel>name - the name of the file system entry.false if the named file system entry is not writable.IOException - On any I/O error.public final void mknod(FsEntryName name, Entry.Type type, BitField<FsOutputOption> options, Entry template) throws IOException
FsControllername into the file system.mknod in class FsController<FsConcurrentModel>name - the file system entry name.type - the file system entry type.options - the file system output options.
If FsOutputOption.CREATE_PARENTS is set, any missing
parent directories will be created and linked into the file
system with its last modification time set to the system's
current time.template - if not null, then the file system entry
at the end of the chain shall inherit as much properties from
this entry as possible - with the exception of its name and type.IOException - on any I/O error, including but not limited to these
reasons:
name contains characters which are not
supported by the file system.
FsOutputOption.EXCLUSIVE is set or the entry is a
directory.
createParents is
false.
final void setContext(@CheckForNull FsOperationContext context)
FsContextController operation in progress.
This method should only get called by the class
FsContextController.
Note that this is a thread-local property!
context - the JavaBean which represents the original values of
selected parameters for the FsContextController
operation in progress.getContext()public final void setReadOnly(FsEntryName name) throws IOException
setReadOnly in class FsController<FsConcurrentModel>IOExceptionpublic final boolean setTime(FsEntryName name, BitField<Entry.Access> types, long value, BitField<FsOutputOption> options) throws IOException
FsControllerfalse is returned or an IOException is thrown, then
still some of the last access times may have been set.
Whether or not this is an atomic operation is specific to the
implementation.setTime in class FsController<FsConcurrentModel>name - the file system entry name.types - the access types.value - the last access time.true if and only if setting the access time for all
types in types succeeded.IOException - on any I/O error.public final boolean setTime(FsEntryName name, Map<Entry.Access,Long> times, BitField<FsOutputOption> options) throws IOException
FsControllerfalse is returned or an IOException is thrown, then
still some of the last access times may have been set.
Whether or not this is an atomic operation is specific to the
implementation.setTime in class FsController<FsConcurrentModel>name - the file system entry name.times - the access times.true if and only if setting the access time for all
types in times succeeded.IOException - on any I/O error.public void unlink(FsEntryName name, BitField<FsOutputOption> options) throws IOException
FsControllerunlink in class FsController<FsConcurrentModel>name - the file system entry name.options - output options for this operation.IOException - On any I/O error.Copyright © 2004-2011 Schlichtherle IT Services. All Rights Reserved.