|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jomic.tools.ArchiveCache
public class ArchiveCache
Cache for extracted archives. The cache maps the file path a a comic book archive to a directory where the extracted images are restored. While there is a size limit, it can temporarily be exeeded, for example because a single comic is bigger than the limit, or no comics can be removed because all of them are locked by a client right now.
ArchiveCacheEntry
Constructor Summary | |
---|---|
ArchiveCache(java.io.File newBaseDir,
long newMaxSize)
Create ArchiveCache storing extracted files and index in the directory newBaseDir
. |
Method Summary | |
---|---|
void |
attemptToReadEntries()
Attempt to read entries from cacheMap.xml. |
void |
clear()
Clear entries and remove all files in the base directory. |
ArchiveCacheEntry |
createCacheEntry(java.io.File newArchiveFile)
Create a new cache entry for newArchiveFile using the next free index. |
ArchiveCacheEntry |
get(java.io.File archiveFile)
|
java.io.File |
getBaseDir()
|
java.io.File |
getCacheEntryDir(ArchiveCacheEntry cacheEntry)
Get directory where cached files extracted from the archive are stored. |
int |
getEntryCount()
Number of cache entries. |
long |
getMaxSize()
Number of bytes the cache should use at the maximum. |
long |
getUsedSize()
Number of bytes currently in use by cache. |
void |
put(ArchiveCacheEntry entry)
|
void |
readEntries(java.io.Reader reader)
|
void |
remove(java.io.File archiveFile)
|
void |
setCacheEntrySize(ArchiveCacheEntry entry)
Set the number of bytes used by entry by computing the number of bytes used by
all files stored in its archive cache directory. |
void |
setMaxSize(long newMaxSize)
Set the maximum number of bytes the cache should use. |
void |
writeEntries()
|
void |
writeEntries(java.io.Writer writer)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ArchiveCache(java.io.File newBaseDir, long newMaxSize) throws java.io.FileNotFoundException
newBaseDir
. This directory must not contain any other data because clearing the cache means deleting
this directory.
newBaseDir
- the directory where extracted files will be storednewMaxSize
- intended maximum size in bytes extracted archives should use
before older files are removed from the cache
java.io.FileNotFoundException
- if newBaseDir
cannot be createdMethod Detail |
---|
public void setCacheEntrySize(ArchiveCacheEntry entry)
entry
by computing the number of bytes used by
all files stored in its archive cache directory.
public void setMaxSize(long newMaxSize)
public ArchiveCacheEntry get(java.io.File archiveFile)
public java.io.File getBaseDir()
public java.io.File getCacheEntryDir(ArchiveCacheEntry cacheEntry)
public int getEntryCount()
CacheInfo
getEntryCount
in interface CacheInfo
public long getMaxSize()
CacheInfo
getMaxSize
in interface CacheInfo
public long getUsedSize()
CacheInfo
getMaxSize()
in case there is only one entry in the cache bigger than this, or (in case entry size can
not be estimated before adding them) temporarely when adding an entry before removing an old
one.
getUsedSize
in interface CacheInfo
public void attemptToReadEntries()
public void clear()
public ArchiveCacheEntry createCacheEntry(java.io.File newArchiveFile)
newArchiveFile
using the next free index.
public void put(ArchiveCacheEntry entry)
public void readEntries(java.io.Reader reader) throws java.io.IOException, org.xml.sax.SAXException
java.io.IOException
org.xml.sax.SAXException
public void remove(java.io.File archiveFile)
public void writeEntries() throws java.io.IOException
java.io.IOException
public void writeEntries(java.io.Writer writer) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |