public class ZipStorage extends Storage
Note: This storage is read-only. Unpack the ZIP file and use a DirStorage for read-write access.
Modifier and Type | Field and Description |
---|---|
protected java.util.HashMap |
entries
The ZIP entries and index map.
|
static java.lang.String |
KEY_FILE
The dictionary key for the ZIP file location.
|
protected java.util.zip.ZipFile |
zip
The ZIP file used for locating resources.
|
KEY_MOUNT_OVERLAY_PATH, KEY_MOUNT_OVERLAY_PRIO, KEY_MOUNT_PATH, KEY_MOUNT_TIME, KEY_READWRITE, PATH_STORAGE, PATH_STORAGE_CACHE, PATH_STORAGEINFO
dict, KEY_CLASSNAME, KEY_ID, KEY_TYPE
Constructor and Description |
---|
ZipStorage(java.io.File zipFile)
Creates a new read-only ZIP file storage.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroys this object.
|
java.io.File |
file()
Returns the ZIP file being read by this storage.
|
void |
init()
Initializes this object.
|
java.lang.Object |
load(Path path)
Loads an object from the specified location.
|
Metadata |
lookup(Path path)
Searches for an object at the specified location and returns
metadata about the object if found.
|
void |
remove(Path path)
Removes an object or an index at the specified location.
|
void |
store(Path path,
java.lang.Object data)
Stores an object at the specified location.
|
compareTo, isReadWrite, loadAll, localPath, lookupAll, mountOverlayPath, mountOverlayPrio, mountTime, path, setMountInfo
activate, id, isActive, isModified, passivate, serialize, toString, type
public static final java.lang.String KEY_FILE
protected java.util.zip.ZipFile zip
protected java.util.HashMap entries
public ZipStorage(java.io.File zipFile) throws java.io.IOException
zipFile
- the ZIP file to usejava.io.IOException
- if the ZIP couldn't be opened properlypublic void init()
init
in class StorableObject
public void destroy() throws StorageException
destroy
in class StorableObject
StorageException
- if the destruction failedpublic java.io.File file()
public Metadata lookup(Path path)
public java.lang.Object load(Path path)
public void store(Path path, java.lang.Object data) throws StorageException
store
in class Storage
path
- the storage locationdata
- the data to storeStorageException
- if the data couldn't be writtenpublic void remove(Path path) throws StorageException
remove
in class Storage
path
- the storage locationStorageException
- if the data couldn't be removed