org.exolab.castor.persist.cache
public class CountLimited extends AbstractBaseCache implements Cache
Every object being put in the Map will live until the map is full. If the map is full, a least-recently-used object will be disposed.
Method dispose will be called whenever an old object is diposed. Developer can get notify by overriding the dispose method dispose.
Version: $Revision: 1.7 $ $Date: 2005/08/04 07:31:15 $
Field Summary | |
---|---|
static int | DEFAULT_SIZE |
Constructor Summary | |
---|---|
CountLimited() | |
CountLimited(int capacity) |
Method Summary | |
---|---|
void | clear() |
void | close() |
boolean | contains(Object key)
Indicates whether the cache holds value object mapped to the specified key. |
boolean | containsKey(Object key) |
boolean | containsValue(Object value) |
protected void | dispose(Object o)
This method is called when an object is disposed.
|
Enumeration | elements()
Returns an enumeration of the values in this LRU map.
|
Set | entrySet() |
void | expire(Object key)
Remove the object identified by key from the cache.
|
Object | get(Object key)
Returns the value to which the specified key is mapped in this Map. |
void | initialize() |
boolean | isEmpty() |
Set | keySet() |
Object | put(Object key, Object value)
Maps the specified key to the specified
value in this Map. |
void | putAll(Map aMap) |
Object | remove(Object key)
Removes the key (and its corresponding value) from this
Map. |
void | setCapacity(int capacity)
Sets the cache capacity. |
int | size() |
Collection | values() |
Parameters: key - A key identifying a value object.
Returns: True if the cache holds a value object for the specified key, false otherwise.
See Also: Cache
Parameters: o - the disposed object
Returns: an enumeration of the values in this Map.
See Also: java.util.Enumeration
Parameters: key the key that needs to be removed.
Parameters: key - a key in the Map.
Returns: the value to which the key is mapped in this Map; null if the key is not mapped to any value in this Map.
key
to the specified
value
in this Map. Neither the key nor the
value can be null
.
The value can be retrieved by calling the get
method
with a key that is equal to the original key, before it is diposed
when the Map is full.
Parameters: key the Map key. value the value.
Returns: the previous value of the specified key in this Map,
or null
if it did not have one.
Throws: NullPointerException if the key or value is
null
.
Parameters: key the key that needs to be removed.
Returns: the value to which the key had been mapped in this Map,
or null
if the key did not have a mapping.
Parameters: capacity the cache capacity.
See Also: Cache