org.exolab.castor.persist.cache

Class TimeLimited

public class TimeLimited extends AbstractBaseCache implements Cache

TimeLimited is a time limted least-recently-used Map.

Every object being put in the Map will live until the timeout expired.

Method dispose will be called whenever an old object is diposed. Developer can get notify by overriding the dispose method dispose.

Version: $Revision: 1.9 $ $Date: 2005/08/04 07:31:15 $

Author: Thomas Yip Werner Guttmann Stein M. Hugubakken

Constructor Summary
TimeLimited()
Creates an instance of TimeLimited.
Method Summary
voidclear()
voidclose()
booleancontains(Object key)
Indicates whether the cache holds a value object for the specified key.
booleancontainsKey(Object key)
booleancontainsValue(Object value)
protected voiddispose(Object o)
This method is called when an object is disposed.
Enumerationelements()
Returns an enumeration of the values in this LRU map.
SetentrySet()
voidexpire(Object key)
Remove the object identified by key from the cache.
Objectget(Object key)
Returns the value to which the specified key is mapped in this Map.
voidinitialize()
booleanisEmpty()
SetkeySet()
Objectput(Object key, Object value)
Maps the specified key to the specified value in this Map.
voidputAll(Map aMap)
Objectremove(Object key)
Removes the key (and its corresponding value) from this Map.
voidsetCapacity(int capacity)
intsize()
Collectionvalues()

Constructor Detail

TimeLimited

public TimeLimited()
Creates an instance of TimeLimited.

Method Detail

clear

public void clear()

close

public void close()

See Also: close

contains

public boolean contains(Object key)
Indicates whether the cache holds a value object for the specified key.

See Also: Cache

containsKey

public boolean containsKey(Object key)

containsValue

public boolean containsValue(Object value)

dispose

protected void dispose(Object o)
This method is called when an object is disposed. Override this method if you interested in the disposed object.

Parameters: o - the disposed object

elements

public Enumeration elements()
Returns an enumeration of the values in this LRU map. Use the Enumeration methods on the returned object to fetch the elements sequentially.

Returns: an enumeration of the values in this Map.

See Also: java.util.Enumeration

entrySet

public Set entrySet()

expire

public void expire(Object key)
Remove the object identified by key from the cache.

Parameters: key the key that needs to be removed.

get

public Object get(Object key)
Returns the value to which the specified key is mapped in this Map.

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.

initialize

public void initialize()

See Also: initialize

isEmpty

public boolean isEmpty()

keySet

public Set keySet()

put

public Object put(Object key, Object value)
Maps the specified 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 timeout of the entry is expired.

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.

putAll

public void putAll(Map aMap)

remove

public Object remove(Object key)
Removes the key (and its corresponding value) from this Map. This method does nothing if the key is not in the Map.

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.

setCapacity

public void setCapacity(int capacity)

See Also: getCapacity

size

public int size()

values

public Collection values()
Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com