org.exolab.castor.persist.cache

Interface Cache

public interface Cache

Interface specification for performance caches as used in Castor. Please implement this interface if you wish to provide your own cache implementation.

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

Author: Werner Guttmann

Method Summary
voidclear()
Removes all mappings from this map.
voidclose()
Life-cycle method to allow custom resource cleanup for a cache implementation
booleancontains(Object key)
Indicates whether the cache holds value object mapped to the specified key.
booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
Enumerationelements()
Returns an enumeration of the values in this LRU map.
SetentrySet()
Returns a set view of the keys contained in this map.
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 hashtable.
StringgetCacheType()
Indicates the type of this cache.
intgetCapacity()
Indicates the cache capacity.
StringgetClassName()
Indicates the class name of objects stored in this cache.
voidinitialize()
Lyfe-cycle method to allow custom initialization of cache implementations
booleanisEmpty()
Returns true if this map contains no key-value mappings.
SetkeySet()
Returns a collection view of the values contained in this map.
Objectput(Object key, Object value)
Maps the specified key to the specified value in this hashtable.
voidputAll(Map aMap)
Copies all of the mappings from the specified map to this map (optional operation).
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.
intsize()
Returns the number of key-value mappings in this map.
Collectionvalues()

Method Detail

clear

public void clear()
Removes all mappings from this map.

Throws: MethodNotImplementedException

close

public void close()
Life-cycle method to allow custom resource cleanup for a cache implementation

contains

public 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.

containsKey

public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key

Parameters: key A key object.

Returns: true if this map contains a mapping for the specified key

Throws: MethodNotImplementedException

containsValue

public boolean containsValue(Object value)
Returns true if this map maps one or more keys to the specified value. This operation will probably require time linear to the cache size for most implementations of the Cache interface.

Parameters: value The object value.

Returns: true if this map maps one or more keys to the specified value

Throws: MethodNotImplementedException

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 hashtable.

See Also: java.util.Enumeration

entrySet

public Set entrySet()
Returns a set view of the keys contained in this map.

Returns: A set view of all the keys.

Throws: MethodNotImplementedException

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 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.

initialize

public void initialize()
Lyfe-cycle method to allow custom initialization of cache implementations

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.

Returns: True if this map contains no key-value mappings

Throws: MethodNotImplementedException

keySet

public Set keySet()
Returns a collection view of the values contained in this map.

Returns: A set view of all the value objects.

Throws: MethodNotImplementedException

put

public 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.

putAll

public void putAll(Map aMap)
Copies all of the mappings from the specified map to this map (optional operation).

Parameters: aMap The map to be copied.

remove

public 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.

size

public int size()
Returns the number of key-value mappings in this map.

Throws: MethodNotImplementedException

values

public Collection values()

Returns:

Throws: MethodNotImplementedException

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