|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.at4j.archive.ArchiveEntryCollaborator<T,U>
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>>
This is a collaborator object that gives archive entries access to the archive.
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.
Constructor Summary | |
---|---|
protected |
ArchiveEntryCollaborator(RandomlyAccessibleFile archiveFile,
Map<AbsoluteLocation,T> entryMap)
Create a new collaborator. |
Method Summary | |
---|---|
void |
close()
Close the collaborator. |
protected void |
finalize()
|
T |
getEntry(AbsoluteLocation loc)
Get the archive entry stored at the specified absolute location in the archive. |
void |
notifyClosed(RandomAccess ra)
This callback method is called when a stream is closed on a file entry. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ArchiveEntryCollaborator(RandomlyAccessibleFile archiveFile, Map<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.Method Detail |
---|
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 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(AbsoluteLocation loc)
loc
- The entry's position in the archive.
null
if there is no entry at the
specified location.public void notifyClosed(RandomAccess ra)
notifyClosed
in interface RandomAccessCloseObserver
ra
- The closed RandomAccess
.public void close()
protected void finalize() throws Throwable
finalize
in class Object
Throwable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |