org.jacorb.notification.util

Class CachingWildcardMap


public class CachingWildcardMap
extends WildcardMap

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

Version:
$Id: CachingWildcardMap.java,v 1.4 2004/05/06 12:40:00 nicolas Exp $

Author:
Alphonse Bendt

Constructor Summary

CachingWildcardMap(int cacheSize)

Method Summary

Object[]
getWithExpansion(Object key)
Returns the value to which this map maps the specified key.
Object
put(Object key, Object value)
The operation put associates the specified value with the specified key in this map.
Object
remove(Object key)
remove the specified key from this Map.

Methods inherited from class org.jacorb.notification.util.WildcardMap

clear, getNoExpansion, getWithExpansion, put, remove, toString

Constructor Details

CachingWildcardMap

public CachingWildcardMap(int cacheSize)

Method Details

getWithExpansion

public Object[] getWithExpansion(Object key)
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.
Overrides:
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.


put

public Object put(Object key,
                  Object value)
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.
Overrides:
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.


remove

public Object remove(Object key)
remove the specified key from this Map.
Overrides:
remove in interface WildcardMap