org.pf.util
Class CaseInsensitiveKeyMap

java.lang.Object
  extended byorg.pf.util.MapWrapper
      extended byorg.pf.util.CaseInsensitiveKeyMap
All Implemented Interfaces:
java.util.Map, java.io.Serializable

public class CaseInsensitiveKeyMap
extends MapWrapper

This class provides a map that treats all keys as case-insensitive strings. That means, the methods get(key) and containsKey(key) will find entries regardless of the keys case. Be aware the this is to some degree NOT an exact implementation of the Map interface. Iterators on the keys and values are NOT backed by the corresponding collection. That means that particularly a Collections.synchronizedMap() doesn't work with an instance of this class!

Version:
1.1
Author:
Manfred Duchrow
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
CaseInsensitiveKeyMap()
          Initialize the new instance with default values.
CaseInsensitiveKeyMap(int initialCapacity)
          Initialize the new instance with an initial capacity.
 
Method Summary
 boolean containsKey(java.lang.Object key)
          This method returns true, if the given key can be found in this map.
 boolean containsValue(java.lang.Object value)
          This method returns true, if the given value is a value of any entry in this map.
 java.util.Set entrySet()
          This method automatically touches every entry, so that its expire period starts anew.
 java.lang.Object get(java.lang.Object key)
          Returns the object that was registered under the specified key.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Puts the given value under the specified key into the map.
 void putAll(java.util.Map map)
          Each entry of the given map will be added.
 java.lang.Object remove(java.lang.Object key)
          Removes the entry with the specified key.
 java.util.Collection values()
          Returns all values of the map.
 
Methods inherited from class org.pf.util.MapWrapper
clear, isEmpty, keySet, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

CaseInsensitiveKeyMap

public CaseInsensitiveKeyMap()
Initialize the new instance with default values.


CaseInsensitiveKeyMap

public CaseInsensitiveKeyMap(int initialCapacity)
Initialize the new instance with an initial capacity.

Parameters:
initialCapacity - Defines how many "slots" for elements are created initially
Method Detail

containsKey

public boolean containsKey(java.lang.Object key)
This method returns true, if the given key can be found in this map.

Specified by:
containsKey in interface java.util.Map
Overrides:
containsKey in class MapWrapper
See Also:
Map.containsKey(Object)

get

public java.lang.Object get(java.lang.Object key)
Returns the object that was registered under the specified key. The given key must be a String. If not null is returned.

Specified by:
get in interface java.util.Map
Overrides:
get in class MapWrapper
See Also:
Map.get(Object)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Puts the given value under the specified key into the map.
If the key is no java.lang.String nothing will be put to the map and the method returns null!

Specified by:
put in interface java.util.Map
Overrides:
put in class MapWrapper
See Also:
Map.put(Object, Object)

putAll

public void putAll(java.util.Map map)
Each entry of the given map will be added. Each added entry gets an associated timestamp.

Specified by:
putAll in interface java.util.Map
Overrides:
putAll in class MapWrapper
See Also:
Map.putAll(Map)

containsValue

public boolean containsValue(java.lang.Object value)
This method returns true, if the given value is a value of any entry in this map.

Specified by:
containsValue in interface java.util.Map
Overrides:
containsValue in class MapWrapper
See Also:
Map.containsValue(Object)

values

public java.util.Collection values()
Returns all values of the map.

Specified by:
values in interface java.util.Map
Overrides:
values in class MapWrapper
See Also:
Map.values()

remove

public java.lang.Object remove(java.lang.Object key)
Removes the entry with the specified key.

Specified by:
remove in interface java.util.Map
Overrides:
remove in class MapWrapper
See Also:
Map.remove(Object)

entrySet

public java.util.Set entrySet()
This method automatically touches every entry, so that its expire period starts anew.

Specified by:
entrySet in interface java.util.Map
Overrides:
entrySet in class MapWrapper
See Also:
Map.entrySet()