org.exolab.castor.persist

Class LRU.TimeLimited

Enclosing Class:
LRU

public static class LRU.TimeLimited
extends LRU

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

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

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

Author:
Thomas Yip

Nested Class Summary

Nested classes/interfaces inherited from class org.exolab.castor.persist.LRU

LRU.CountLimited, LRU.NoCache, LRU.TimeLimited, LRU.Unlimited

Field Summary

static int
DEFAULT_PRECISION
The Default precision in millisecond is 1000.

Fields inherited from class org.exolab.castor.persist.LRU

CACHE_COUNT_LIMITED, CACHE_NONE, CACHE_TIME_LIMITED, CACHE_UNLIMITED, DEFAULT_PARAM, DEFAULT_TYPE

Constructor Summary

TimeLimited(int interval)
Constructor

Method Summary

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.
Object
get(Object key)
Returns the value to which the specified key is mapped in this Map.
Object
put(Object key, Object value)
Maps the specified key to the specified value in this Map.
Object
remove(Object key)
Removes the key (and its corresponding value) from this Map.

Methods inherited from class org.exolab.castor.persist.LRU

create, elements, get, mapType, put, remove

Field Details

DEFAULT_PRECISION

public static final int DEFAULT_PRECISION
The Default precision in millisecond is 1000. Percision is the interval between each time which the timer thread will wake up and trigger clean up of least-recently-used Object.
Field Value:
1000

Constructor Details

TimeLimited

public TimeLimited(int interval)
Constructor
Parameters:
interval - the number of ticks an object live before it is disposed.

Method Details

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.
Overrides:
elements in interface LRU
Returns:
an enumeration of the values in this Map.
See Also:
java.util.Enumeration

get

public Object get(Object key)
Returns the value to which the specified key is mapped in this Map.
Overrides:
get in interface LRU
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.

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.

Overrides:
put in interface LRU
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.

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.
Overrides:
remove in interface LRU
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.

Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com