|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.batik.util.SoftReferenceCache
public class SoftReferenceCache
This class manages a cache of soft references to objects that may take some time to load or create, such as images loaded from the network.
Adding an object is two fold:
If someone requests a key after it has been added but before it has been put they will be blocked until the put.
Field Summary | |
---|---|
protected Map |
map
The map of cached objects. |
Constructor Summary | |
---|---|
protected |
SoftReferenceCache()
Let people create their own caches. |
protected |
SoftReferenceCache(boolean synchronous)
Constructs a soft reference cache. |
Method Summary | |
---|---|
protected void |
clearImpl(Object key)
Clear the entry for key. |
void |
flush()
Let people flush the cache (remove any cached data). |
protected boolean |
isDoneImpl(Object key)
Check if request(key) will return immediately with the
Object. |
protected boolean |
isPresentImpl(Object key)
Check if request(key) will return with an Object
(not putting you on the hook for it). |
protected void |
putImpl(Object key,
Object object)
Associate object with key. |
protected Object |
requestImpl(Object key)
If this returns null then you are now 'on the hook'. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Map map
Constructor Detail |
---|
protected SoftReferenceCache()
protected SoftReferenceCache(boolean synchronous)
synchronous
- true to enable synchronous mode, false to enable waiting on requestImpl()
until another thread adds the missing objectMethod Detail |
---|
public void flush()
protected final boolean isPresentImpl(Object key)
request(key)
will return with an Object
(not putting you on the hook for it). Note that it is possible
that this will return true but between this call and the call
to request the soft-reference will be cleared. So it
is still possible for request to return NULL, just much less
likely (you can always call 'clear' in that case).
protected final boolean isDoneImpl(Object key)
request(key)
will return immediately with the
Object. Note that it is possible that this will return
true but between this call and the call to request the
soft-reference will be cleared.
protected final Object requestImpl(Object key)
protected final void clearImpl(Object key)
protected final void putImpl(Object key, Object object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |