public class LocalImageCache extends java.lang.Thread implements ImageRetriever
Constructor and Description |
---|
LocalImageCache(java.lang.String name,
int interval,
int maxAge,
ImageRetriever under)
Creates a local image cache that pools its cache directory at interval rates and deletes files older than maxAge.
|
Modifier and Type | Method and Description |
---|---|
java.io.InputStream |
get(java.net.URI uri,
int frameNumber,
boolean thumbnail)
Obtain an image by URI.
|
int |
getInterval() |
int |
getMaxAge() |
boolean |
isRunning() |
void |
run() |
void |
setInterval(int interval) |
void |
setMaxAge(int maxAge) |
void |
start() |
void |
terminate()
Stop this cache from checking for old files.
|
protected static java.lang.String |
toFileName(java.lang.String imageUri,
int frameNumber,
boolean thumbnail) |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
public LocalImageCache(java.lang.String name, int interval, int maxAge, ImageRetriever under)
name
- the name of the cache directory.interval
- the number of seconds to wait between pool cache directory pooling.maxAge
- the number of seconds that a file can stay in the cache without being used/read.under
- the underlying image retrieverpublic void start()
start
in class java.lang.Thread
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void terminate()
public int getInterval()
public void setInterval(int interval)
interval
- the interval to setpublic int getMaxAge()
public void setMaxAge(int maxAge)
maxAge
- the maxAge to setprotected static java.lang.String toFileName(java.lang.String imageUri, int frameNumber, boolean thumbnail)
public java.io.InputStream get(java.net.URI uri, int frameNumber, boolean thumbnail) throws java.io.IOException
ImageRetriever
get
in interface ImageRetriever
uri
- the URI to the imageframeNumber
- the frame numberthumbnail
- whether to retrieve a thumbnail (true) or the image in its original size (false)java.io.IOException
public boolean isRunning()