|
TrueZIP Kernel 7.0-rc1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.truezip.fs.archive.FsArchiveFileSystem<E>
E - The type of the archive entries.@NotThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) class FsArchiveFileSystem<E extends FsArchiveEntry>
A base class for a virtual file system for archive entries.
| Nested Class Summary | |
|---|---|
private class |
FsArchiveFileSystem.Checker
|
private class |
FsArchiveFileSystem.PathLink
TODO: This implementation yields a potential issue: The state of the file system may be altered between the construction of an instance and the call to the FsArchiveFileSystem.PathLink.run() method, which may render the operation
illegal and corrupt the file system. |
private static class |
FsArchiveFileSystem.SegmentLink<E extends FsArchiveEntry>
A data class which represents a segment for use by FsArchiveFileSystem.PathLink. |
private static class |
FsArchiveFileSystem.Splitter
Splits a path name into a parent path name and a base path. |
| Field Summary | |
|---|---|
private EntryFactory<E> |
factory
|
private Map<String,FsArchiveFileSystemEntry<E>> |
master
The map of archive file system entries. |
private FsArchiveFileSystemEntry<E> |
root
The file system entry for the (virtual) root of this file system. |
private boolean |
touched
Whether or not this file system has been modified (touched). |
private LinkedHashSet<FsArchiveFileSystemTouchListener<? super E>> |
touchListeners
|
| Constructor Summary | |
|---|---|
private |
FsArchiveFileSystem(EntryFactory<E> factory)
|
(package private) |
FsArchiveFileSystem(EntryFactory<E> factory,
EntryContainer<E> archive,
Entry rootTemplate)
|
| Method Summary | ||
|---|---|---|
void |
addArchiveFileSystemTouchListener(FsArchiveFileSystemTouchListener<? super E> listener)
Adds the given listener to the set of archive file system listeners. |
|
(package private) E |
copy(E entry)
|
|
(package private) Set<FsArchiveFileSystemTouchListener<? super E>> |
getArchiveFileSystemTouchListeners()
Returns a protective copy of the set of archive file system listeners. |
|
FsArchiveFileSystemEntry<E> |
getEntry(FsEntryName name)
|
|
FsArchiveFileSystemEntry<E> |
getEntry(String path)
Returns the entry for the given name or
null if no entry with this name exists in this container. |
|
int |
getSize()
Returns the number of entries in this container. |
|
boolean |
isReadOnly()
Returns true if and only if this archive file system is
read-only. |
|
boolean |
isTouched()
Returns true if and only if this archive file system has been
modified since its time of creation. |
|
boolean |
isWritable(FsEntryName name)
|
|
Iterator<FsArchiveFileSystemEntry<E>> |
iterator()
Returns a new iterator over all entries in this container. |
|
FsArchiveFileSystemOperation<E> |
mknod(FsEntryName name,
Entry.Type type,
BitField<FsOutputOption> options,
Entry template)
Begins a transaction to create or replace and finally link a chain of one or more archive entries for the given path into
this archive file system. |
|
(package private) static
|
newArchiveFileSystem(EntryFactory<AE> factory)
Returns a new archive file system and ensures its integrity. |
|
(package private) static
|
newArchiveFileSystem(EntryFactory<E> factory,
EntryContainer<E> archive,
Entry rootTemplate,
boolean readOnly)
Returns a new archive file system which populates its entries from the given archive and ensures its integrity. |
|
private FsArchiveFileSystemEntry<E> |
newEntryChecked(String path,
Entry.Type type,
Entry template)
Returns a new file system entry for this (virtual) archive file system. |
|
private FsArchiveFileSystemEntry<E> |
newEntryUnchecked(String path,
Entry.Type type,
Entry template)
Like newEntryChecked(path, type, null),
but wraps any CharConversionException in an
AssertionError. |
|
void |
removeArchiveFileSystemTouchListener(FsArchiveFileSystemTouchListener<? super E> listener)
Removes the given listener from the set of archive file system listeners. |
|
void |
setReadOnly(FsEntryName name)
|
|
boolean |
setTime(FsEntryName name,
BitField<Entry.Access> types,
long value)
|
|
private void |
touch()
Ensures that the controller's data structures required to output entries are properly initialized and marks this (virtual) archive file system as touched. |
|
void |
unlink(FsEntryName name)
If this method returns, the file system entry identified by the given path has been successfully deleted from this archive file
system. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final EntryFactory<E extends FsArchiveEntry> factory
private final Map<String,FsArchiveFileSystemEntry<E extends FsArchiveEntry>> master
Note that the archive entries in this map are shared with the
EntryContainer object provided to the constructor of
this class.
private final FsArchiveFileSystemEntry<E extends FsArchiveEntry> root
private boolean touched
private LinkedHashSet<FsArchiveFileSystemTouchListener<? super E extends FsArchiveEntry>> touchListeners
| Constructor Detail |
|---|
private FsArchiveFileSystem(EntryFactory<E> factory)
FsArchiveFileSystem(EntryFactory<E> factory,
EntryContainer<E> archive,
@CheckForNull
Entry rootTemplate)
| Method Detail |
|---|
static <AE extends FsArchiveEntry> FsArchiveFileSystem<AE> newArchiveFileSystem(EntryFactory<AE> factory)
factory - the archive entry factory to use.
NullPointerException - If factory is null.
static <E extends FsArchiveEntry> FsArchiveFileSystem<E> newArchiveFileSystem(EntryFactory<E> factory,
EntryContainer<E> archive,
@CheckForNull
Entry rootTemplate,
boolean readOnly)
archive and ensures its integrity.
First, the entries from the archive are loaded into the file system.
Second, a root directory with the given last modification time is created and linked into the filesystem (so it's never loaded from the archive).
Finally, the file system integrity is checked and fixed: Any missing parent directories are created using the system's current time as their last modification time - existing directories will never be replaced.
Note that the entries in the file system are shared with the given
archive entry container.
archive - The archive entry container to read the entries for
the population of the archive file system.factory - the archive entry factory to use.rootTemplate - The last modification time of the root of the populated
file system in milliseconds since the epoch.readOnly - If and only if true, any subsequent
modifying operation on the file system will result in a
FsReadOnlyArchiveFileSystemException.
NullPointerException - If container, factory or
rootTemplate are null.
IllegalArgumentException - If rootTemplate is an instance
of FsArchiveFileSystemEntry.public boolean isReadOnly()
true if and only if this archive file system is
read-only.
This method is provided for inheritance - the implementation in this
class always returns false.
public boolean isTouched()
true if and only if this archive file system has been
modified since its time of creation.
private void touch()
throws FsArchiveFileSystemException
ArchiveReadOnlyExceptionn - If this (virtual) archive file system
is read only.
FsArchiveFileSystemException - If the listener vetoed the beforeTouch
operation for any reason.Set<FsArchiveFileSystemTouchListener<? super E>> getArchiveFileSystemTouchListeners()
public final void addArchiveFileSystemTouchListener(FsArchiveFileSystemTouchListener<? super E> listener)
listener - the listener for archive file system events.
public final void removeArchiveFileSystemTouchListener(@Nullable
FsArchiveFileSystemTouchListener<? super E> listener)
listener - the listener for archive file system events.public int getSize()
EntryContainer
getSize in interface EntryContainer<FsArchiveFileSystemEntry<E extends FsArchiveEntry>>public Iterator<FsArchiveFileSystemEntry<E>> iterator()
EntryContainerFirst, the iteration must be consistent: Multiple iterators must iterate the same entries in the same order again unless the set of entries has changed.
Next, the iteration should also reflect the natural order of the entries in this container. For example, if this container represents an archive file, the iteration should reflect the natural order of the entries in the archive file.
iterator in interface EntryContainer<FsArchiveFileSystemEntry<E extends FsArchiveEntry>>iterator in interface Iterable<FsArchiveFileSystemEntry<E extends FsArchiveEntry>>null iterator over all entries in this
container.@Nullable public final FsArchiveFileSystemEntry<E> getEntry(FsEntryName name)
@Nullable public FsArchiveFileSystemEntry<E> getEntry(String path)
EntryContainername or
null if no entry with this name exists in this container.
getEntry in interface EntryContainer<FsArchiveFileSystemEntry<E extends FsArchiveEntry>>path - an entry name.
name or
null if no entry with this name exists in this container.
private FsArchiveFileSystemEntry<E> newEntryUnchecked(String path,
Entry.Type type,
@CheckForNull
Entry template)
newEntryChecked(path, type, null),
but wraps any CharConversionException in an
AssertionError.
AssertionError - if a CharConversionException
occurs. The original exception is wrapped as its cause.
private FsArchiveFileSystemEntry<E> newEntryChecked(String path,
Entry.Type type,
@CheckForNull
Entry template)
throws FsArchiveFileSystemException
path - the path name of the archive file system entry.
FsArchiveFileSystemExceptionmknod(de.schlichtherle.truezip.fs.FsEntryName, de.schlichtherle.truezip.entry.Entry.Type, de.schlichtherle.truezip.util.BitField, de.schlichtherle.truezip.entry.Entry) final E copy(E entry)
public FsArchiveFileSystemOperation<E> mknod(FsEntryName name,
Entry.Type type,
BitField<FsOutputOption> options,
@CheckForNull
Entry template)
throws FsArchiveFileSystemException
path into
this archive file system.
To commit the transaction, you need to call
FsArchiveFileSystemOperation.run() on the returned object, which
will mark this archive file system as touched and
set the last modification time of the created and linked archive file
system entries to the system's current time at the moment of the call
to this method.
name - an entry name.type - an entry type.options - if CREATE_PARENTS is set, any missing parent
directories will be created and linked into this file
system with its last modification time set to the system's
current time.template - if not null, then the archive 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.
FsArchiveFileSystemOperation.run() method.
NullPointerException - if path or type are
null.
ArchiveReadOnlyExceptionn - If this archive file system is read
only.
FsArchiveFileSystemException - If one of the following is true:
name contains characters which are not
supported by the file system.
FILE or DIRECTORY.
FsOutputOption.EXCLUSIVE is set or the entry is a
directory.
createParents is
false.
public void unlink(FsEntryName name)
throws FsArchiveFileSystemException
path has been successfully deleted from this archive file
system.
If the file system entry is a directory, it must be empty for successful
deletion.
ArchiveReadOnlyExceptionn - If this (virtual) archive file system
is read-only.
FsArchiveFileSystemException - If the operation fails for some other
reason.
public boolean setTime(FsEntryName name,
BitField<Entry.Access> types,
long value)
throws FsArchiveFileSystemException
FsArchiveFileSystemExceptionpublic boolean isWritable(FsEntryName name)
public void setReadOnly(FsEntryName name)
throws FsArchiveFileSystemException
FsArchiveFileSystemException
|
TrueZIP Kernel 7.0-rc1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||