org.jacorb.notification.util
Class CachingWildcardMap

java.lang.Object
  extended byorg.jacorb.notification.util.CachingWildcardMap
All Implemented Interfaces:
WildcardMap

public class CachingWildcardMap
extends java.lang.Object
implements WildcardMap

Add Caching to WildcardMap. If the Keys inside the Map contain the Wildcard Operator '*' the Operation getWithExpansion is rather timeconsuming. For each Key that contains a '*' a pattern match must be done. This Decorator adds simple Caching. When a key is looked up the retrieved value is stored in an internal cache with fixed size. Subsequent calls to getWithExpansion query the cache first. As soon as a put or remove Operation occurs the Cache is invalidated.

Version:
$Id: CachingWildcardMap.java,v 1.5 2005/02/14 00:13:05 alphonse.bendt Exp $
Author:
Alphonse Bendt

Constructor Summary
CachingWildcardMap()
           
CachingWildcardMap(int cacheSize, WildcardMap delegate)
           
 
Method Summary
 void clear()
          clear this map
 java.lang.Object getNoExpansion(java.lang.Object key)
          Returns the value to which this map maps the specified key.
 java.lang.Object[] getWithExpansion(java.lang.Object key)
          Returns the value to which this map maps the specified key.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          The operation put associates the specified value with the specified key in this map.
 java.lang.Object remove(java.lang.Object key)
          remove the specified key from this Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingWildcardMap

public CachingWildcardMap()

CachingWildcardMap

public CachingWildcardMap(int cacheSize,
                          WildcardMap delegate)
Method Detail

clear

public void clear()
Description copied from interface: WildcardMap
clear this map

Specified by:
clear in interface WildcardMap

remove

public java.lang.Object remove(java.lang.Object key)
Description copied from interface: WildcardMap
remove the specified key from this Map.

Specified by:
remove in interface WildcardMap

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Description copied from interface: WildcardMap
The operation put associates the specified value with the specified key in this map. The String representation of the Key toString() is used. If the map previously contained a mapping for this key, the old value is replaced by the specified value.

Specified by:
put in interface WildcardMap
Parameters:
key - key with which String representation the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key.

getWithExpansion

public java.lang.Object[] getWithExpansion(java.lang.Object key)
Description copied from interface: WildcardMap
Returns the value to which this map maps the specified key. Additionaly return all Values which keys contain a Wildcard and match the requested key. Returns null if the map contains no mapping for this key.

Specified by:
getWithExpansion in interface WildcardMap
Parameters:
key - key whose associated value is to be returned
Returns:
an Array of all Matching entries or null if no matching entry could be found.

getNoExpansion

public java.lang.Object getNoExpansion(java.lang.Object key)
Description copied from interface: WildcardMap
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key.

Specified by:
getNoExpansion in interface WildcardMap
Parameters:
key - key whose associated value is to be returned
Returns:
the value to which this map maps the specified key, or null if the map contains no mapping for this key.