org.exolab.castor.persist.cache
Interface Cache

All Known Implementing Classes:
AbstractBaseCache, CoherenceCache, CountLimited, FKCache, JCache, JcsCache, NoCache, TimeLimited, Unlimited

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
 void clear()
          Removes all mappings from this map.
 void close()
          Life-cycle method to allow custom resource cleanup for a cache implementation
 boolean contains(java.lang.Object key)
          Indicates whether the cache holds value object mapped to the specified key.
 boolean containsKey(java.lang.Object key)
          Returns true if this map contains a mapping for the specified key
 boolean containsValue(java.lang.Object value)
          Returns true if this map maps one or more keys to the specified value.
 java.util.Enumeration elements()
          Returns an enumeration of the values in this LRU map.
 java.util.Set entrySet()
          Returns a set view of the keys contained in this 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.
 void initialize()
          Lyfe-cycle method to allow custom initialization of cache implementations
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
 java.util.Set keySet()
          Returns a collection view of the values contained in this map.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
 void putAll(java.util.Map aMap)
          Copies all of the mappings from the specified map to this map (optional operation).
 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.
 int size()
          Returns the number of key-value mappings in this map.
 java.util.Collection values()
           
 

Method Detail

initialize

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

Throws:
CacheAcquireException

close

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


get

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

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

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

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

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

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

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

Returns:
the cache type.

setCacheType

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

Parameters:
cacheType - The type of this cache.

getCapacity

int getCapacity()
Indicates the cache capacity.

Returns:
the cache capacity.

setCapacity

void setCapacity(int capacity)
Sets the cache capacity.

Parameters:
capacity - the cache capacity.

getClassName

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

Returns:
The class name.

setClassName

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

Parameters:
className - The class name.

size

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

Throws:
MethodNotImplementedException

clear

void clear()
           throws MethodNotImplementedException
Removes all mappings from this map.

Throws:
MethodNotImplementedException

isEmpty

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

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

containsKey

boolean containsKey(java.lang.Object key)
                    throws MethodNotImplementedException
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

boolean containsValue(java.lang.Object value)
                      throws MethodNotImplementedException
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

values

java.util.Collection values()
                            throws MethodNotImplementedException
Returns:
Throws:
MethodNotImplementedException

putAll

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

Parameters:
aMap - The map to be copied.

entrySet

java.util.Set entrySet()
                       throws MethodNotImplementedException
Returns a set view of the keys contained in this map.

Returns:
A set view of all the keys.
Throws:
MethodNotImplementedException

keySet

java.util.Set keySet()
                     throws MethodNotImplementedException
Returns a collection view of the values contained in this map.

Returns:
A set view of all the value objects.
Throws:
MethodNotImplementedException


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