org.apache.avalon.excalibur.cache
Class ValidatingCache

java.lang.Object
  |
  +--org.apache.avalon.excalibur.cache.ValidatingCache
All Implemented Interfaces:
Cache, org.apache.avalon.framework.component.Component

public final class ValidatingCache
extends java.lang.Object
implements Cache

Validating cache proxy.

Author:
Eung-ju Park, Antti Koivunen"

Constructor Summary
ValidatingCache(Cache cache, CacheValidator validator)
           
 
Method Summary
 void addListener(CacheListener listener)
          Add listener.
 int capacity()
          Return capacity of cache.
 void clear()
          Clear cache.
 boolean containsKey(java.lang.Object key)
           
 java.lang.Object get(java.lang.Object key)
          Get an item from the cache.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Puts a new item in the cache.
 java.lang.Object remove(java.lang.Object key)
          Removes an item from the cache.
 void removeListener(CacheListener listener)
          Remove listener.
 int size()
          Return size of cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatingCache

public ValidatingCache(Cache cache,
                       CacheValidator validator)
Parameters:
cache -  
validator - object validator
Method Detail

addListener

public void addListener(CacheListener listener)
Description copied from interface: Cache
Add listener.
Specified by:
addListener in interface Cache
Following copied from interface: org.apache.avalon.excalibur.cache.Cache
Parameters:
listener - listener instance to add

removeListener

public void removeListener(CacheListener listener)
Description copied from interface: Cache
Remove listener.
Specified by:
removeListener in interface Cache
Following copied from interface: org.apache.avalon.excalibur.cache.Cache
Parameters:
listener - listener instance to remove

capacity

public int capacity()
Description copied from interface: Cache
Return capacity of cache.
Specified by:
capacity in interface Cache
Following copied from interface: org.apache.avalon.excalibur.cache.Cache
Returns:
capacity of cache

size

public int size()
Description copied from interface: Cache
Return size of cache.
Specified by:
size in interface Cache
Following copied from interface: org.apache.avalon.excalibur.cache.Cache
Returns:
the number of key-value mappings in this cache.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Description copied from interface: Cache
Puts a new item in the cache. If the cache is full, remove the selected item.
Specified by:
put in interface Cache
Following copied from interface: org.apache.avalon.excalibur.cache.Cache
Parameters:
key - key for the item
value - item
Returns:
old value. null if old value not exists.

get

public java.lang.Object get(java.lang.Object key)
Description copied from interface: Cache
Get an item from the cache.
Specified by:
get in interface Cache
Following copied from interface: org.apache.avalon.excalibur.cache.Cache
Parameters:
key - key to lookup the item
Returns:
the matching object in the cache. null if item not exists.

remove

public java.lang.Object remove(java.lang.Object key)
Description copied from interface: Cache
Removes an item from the cache.
Specified by:
remove in interface Cache
Following copied from interface: org.apache.avalon.excalibur.cache.Cache
Parameters:
key - key to remove
Returns:
the value removed. null if old value not exists.

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface Cache
Following copied from interface: org.apache.avalon.excalibur.cache.Cache
Parameters:
key -  
Returns:
true if matching item in the cache

clear

public void clear()
Description copied from interface: Cache
Clear cache.
Specified by:
clear in interface Cache


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.