org.exolab.castor.persist.cache

Class AbstractBaseCache

public abstract class AbstractBaseCache extends Object implements Cache

Base implementation of all LRU cache types.

Author: Werner Guttmann

Method Summary
abstract voidclose()
abstract booleancontains(Object key)
Indicates whether the cache holds value object mapped to the specified key.
protected voiddispose(Object obj)
This method is called when an object is disposed.
abstract Enumerationelements()
Returns an enumeration of the values in this LRU map.
voidexpire(Object key)
Remove the object identified by key from the cache.
abstract Objectget(Object key)
Returns the value to which the specified key is mapped in this hashtable.
StringgetCacheType()
Indicates the type of this cache.
intgetCapacity()
Indicates the cache capacity.
StringgetClassName()
Indicates the class name of objects stored in this cache.
protected ObjectinvokeMethod(Object target, String name, Class[] argumentTypes, Object[] arguments)
protected booleaninvokeMethodReturnBoolean(Object target, String name, Class[] argumentTypes, Object[] arguments)
protected intinvokeMethodReturnInt(Object target, String name, Class[] argumentTypes, Object[] arguments)
protected ObjectinvokeMethodWithExceptions(Object target, String name, Class[] argumentTypes, Object[] arguments)
protected ObjectinvokeStaticMethodWithExceptions(Class target, String name, Class[] argumentTypes, Object[] arguments)
abstract Objectput(Object key, Object value)
Maps the specified key to the specified value in this hashtable.
abstract Objectremove(Object key)
Removes the key (and its corresponding value) from this hashtable.
voidsetCacheType(String cacheType)
Sets the type of this cache instance.
voidsetCapacity(int capacity)
Sets the cache capacity.
voidsetClassName(String className)
Sets the class name of objects cached here.

Method Detail

close

public abstract void close()

See Also: close

contains

public abstract boolean contains(Object key)
Indicates whether the cache holds value object mapped to the specified key.

Parameters: key - A key identifying a value object.

Returns: True if the cache holds a value object for the specified key, false otherwise.

dispose

protected void dispose(Object obj)
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 abstract 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 hashtable.

See Also: java.util.Enumeration

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 abstract Object get(Object key)
Returns the value to which the specified key is mapped in this hashtable.

Parameters: key - a key in the hashtable.

Returns: the value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.

getCacheType

public String getCacheType()
Indicates the type of this cache.

Returns: the cache type.

getCapacity

public int getCapacity()
Indicates the cache capacity.

Returns: the cache capacity.

getClassName

public String getClassName()
Indicates the class name of objects stored in this cache.

Returns: The class name.

See Also: getClassName

invokeMethod

protected Object invokeMethod(Object target, String name, Class[] argumentTypes, Object[] arguments)

invokeMethodReturnBoolean

protected boolean invokeMethodReturnBoolean(Object target, String name, Class[] argumentTypes, Object[] arguments)

invokeMethodReturnInt

protected int invokeMethodReturnInt(Object target, String name, Class[] argumentTypes, Object[] arguments)

invokeMethodWithExceptions

protected Object invokeMethodWithExceptions(Object target, String name, Class[] argumentTypes, Object[] arguments)

invokeStaticMethodWithExceptions

protected Object invokeStaticMethodWithExceptions(Class target, String name, Class[] argumentTypes, Object[] arguments)

put

public abstract Object put(Object key, Object value)
Maps the specified key to the specified value in this hashtable. 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 by the least-recently-used map.

Parameters: key the hashtable key. value the value.

Returns: the previous value of the specified key in this hashtable, or null if it did not have one.

Throws: NullPointerException if the key or value is null.

remove

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

Parameters: key the key that needs to be removed.

Returns: the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

setCacheType

public void setCacheType(String cacheType)
Sets the type of this cache instance.

Parameters: cacheType the type of this cache.

setCapacity

public void setCapacity(int capacity)
Sets the cache capacity.

Parameters: capacity the cache capacity.

setClassName

public void setClassName(String className)
Sets the class name of objects cached here.

Parameters: className The class name.

See Also: setClassName

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