T
- The type of entries in the archive.U
- The type of directory entries in the archive.public abstract class ArchiveEntryCollaborator<T extends ArchiveEntry<T,U>,U extends ArchiveDirectoryEntry<T,U>> extends Object implements org.entityfs.RandomAccessCloseObserver
This object should be safe to use concurrently from several threads. If the
archive file is in a locking FileSystem
, clients should
obtain read locks on the archive file manually for other threads than the one
creating the Archive
object.
Note: This object is part of the archive implementation. Clients don't have to bother with this.
Modifier | Constructor and Description |
---|---|
protected |
ArchiveEntryCollaborator(org.entityfs.RandomlyAccessibleFile archiveFile,
Map<org.entityfs.el.AbsoluteLocation,T> entryMap)
Create a new collaborator.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the collaborator.
|
protected void |
finalize() |
T |
getEntry(org.entityfs.el.AbsoluteLocation loc)
Get the archive entry stored at the specified absolute location in the
archive.
|
void |
notifyClosed(org.entityfs.RandomAccess ra)
This callback method is called when a stream is closed on a file entry.
|
org.entityfs.RandomAccess |
openRandomAccess(long pos,
long upperBound)
Open a read only
RandomAccess object that reads data for a file
entry. |
InputStream |
openStream(long pos,
long upperBound)
Open an
InputStream for reading the data for a file entry. |
protected ArchiveEntryCollaborator(org.entityfs.RandomlyAccessibleFile archiveFile, Map<org.entityfs.el.AbsoluteLocation,T> entryMap)
archiveFile
- The archive file. This file has to be locked by
reading while this object is alive. If several threads access the archive
file, all threads must own a read lock on the archive file (if it is in a
locking file system).entryMap
- A map containing all of the entries in the archive. This
object will use the Map
instance that is supplied in the argument
(i.e. not make a defensive copy of it). The map does not have to contain
all archive entries when this object is created, but it must do so before
any client starts to use the archive object.public InputStream openStream(long pos, long upperBound)
InputStream
for reading the data for a file entry.pos
- The file's data's start position in the archive.upperBound
- The file's data's last position in the archive.InputStream
for reading data between the boundaries.public org.entityfs.RandomAccess openRandomAccess(long pos, long upperBound)
RandomAccess
object that reads data for a file
entry.pos
- The start position of the file data.upperBound
- The last position of the file data in the archive.RandomAccess
for reading data between the boundaries.public T getEntry(org.entityfs.el.AbsoluteLocation loc)
loc
- The entry's position in the archive.null
if there is no entry at the
specified location.public void notifyClosed(org.entityfs.RandomAccess ra)
notifyClosed
in interface org.entityfs.RandomAccessCloseObserver
public void close()