Class SoftMapCache
java.lang.Object
org.apache.xmlgraphics.image.loader.util.SoftMapCache
Provides a simple cache using soft references and storing the values in a Map. The keys into
the Map are hard references, the values are referenced through soft references. The collected
values are cleaned up through a ReferenceQueue.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the cache.void
Triggers some house-keeping, i.e.Returns the value associated with the given key.void
Put a new value in the cache overwriting any existing value with the same key.Removed the value associated with the given key.
-
Constructor Details
-
SoftMapCache
public SoftMapCache(boolean synched) Creates a new soft cache.- Parameters:
synched
- true if the Map containing the values should by synchronized
-
-
Method Details
-
get
Returns the value associated with the given key. If the value is not found or the value has been collected, null is returned.- Parameters:
key
- the key- Returns:
- the requested value or null
-
remove
Removed the value associated with the given key. The value that is removed is returned as the methods result. If the value is not found or the value has been collected, null is returned.- Parameters:
key
- the key- Returns:
- the requested value or null
-
put
Put a new value in the cache overwriting any existing value with the same key.- Parameters:
key
- The keyvalue
- the value
-
clear
public void clear()Clears the cache. -
doHouseKeeping
public void doHouseKeeping()Triggers some house-keeping, i.e. processes any pending objects in the reference queue.
-