org.at4j.archive
Interface Archive<T extends ArchiveEntry<T,U>,U extends ArchiveDirectoryEntry<T,U>>

Type Parameters:
T - The type of entries in this archive.
U - The type of directory entries in this archive.
All Superinterfaces:
Map<AbsoluteLocation,T>
All Known Implementing Classes:
TarFile, ZipFile

public interface Archive<T extends ArchiveEntry<T,U>,U extends ArchiveDirectoryEntry<T,U>>
extends Map<AbsoluteLocation,T>

This interface defines an archive file. The archive file is represented as a read only Map<AbsoluteLocation, ArchiveEntry>, i.e. a map containing the archive's ArchiveEntry:s keyed under their absolute locations in the archive.

An archive is opened by creating a new archive object on an archive file. While the archive is opened, it keeps a read lock on the file (if the file is ReadLockable), and it opens and closes new streams and RandomAccess objects on it as needed. When close() is called on an archive object, the read lock is released and all open streams on the archive are closed. After the archive has been closed, all of its methods throw IllegalStateException.

Archive objects are not safe to use concurrently from several threads without external synchronization. If the archive file is in a locking FileSystem, all threads other than the thread creating the archive object, manually have to acquire an EntityLock for reading the archive file before using any archive methods. (This requires that the file system locking strategy permits several read locks on the same entity.) See the EntityFS documentation for details on file locking.

The ArchiveExtractor can be used to extract all entries from an archive.

Since:
1.0
Author:
Karl Gustafsson
See Also:
ArchiveEntry, ArchiveBuilder

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 void close()
          Close this archive and release all of its resources.
 U getRootEntry()
          Get the archive's root directory.
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Method Detail

getRootEntry

U getRootEntry()
                                                  throws IllegalStateException
Get the archive's root directory.

Returns:
The archive's root directory.
Throws:
IllegalStateException - If the archive has been closed.

close

void close()
Close this archive and release all of its resources. After calling this method, all of the archive's method will throw an IllegalStateException.

It is safe to call this method more than once on an archive.