org.exolab.castor.persist.cache
Interface Cache

All Known Implementing Classes:
AbstractBaseCache, CountLimited, NoCache, TimeLimited

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.3 $ $Date: 2004/06/08 09:52:00 $
Author:
Werner Guttmann

Method Summary
 boolean contains(java.lang.Object key)
          Indicates whether the cache holds value object mapped to the specified key.
 java.util.Enumeration elements()
          Returns an enumeration of the values in this LRU map.
 void expire(java.lang.Object key)
          Remove the object identified by key from the cache.
 java.lang.Object get(java.lang.Object key)
          Returns the value to which the specified key is mapped in this hashtable.
 java.lang.String getCacheType()
          Indicates the type of this cache.
 int getCapacity()
          Indicates the cache capacity.
 java.lang.String getClassName()
          Indicates the class name of objects stored in this cache.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this hashtable.
 void setCacheType(java.lang.String cacheType)
          Sets the type of this cache instance.
 void setCapacity(int capacity)
          Sets the cache capacity.
 void setClassName(java.lang.String className)
          Sets the class name of objects cached here.
 

Method Detail

get

public java.lang.Object get(java.lang.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.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.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:
java.lang.NullPointerException - if the key or value is null.

remove

public java.lang.Object remove(java.lang.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.

elements

public java.util.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:
Enumeration

expire

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

Parameters:
key - the key that needs to be removed.

contains

public boolean contains(java.lang.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.

getCacheType

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

Returns:
the cache type.

setCacheType

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

Parameters:
cacheType - The type of this cache.

getCapacity

public int getCapacity()
Indicates the cache capacity.

Returns:
the cache capacity.

setCapacity

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

Parameters:
capacity - the cache capacity.

getClassName

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

Returns:
The class name.

setClassName

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

Parameters:
className - The class name.


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