com.massimo.utils
Class CaseInsensitiveHashMap<V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,V>
          extended by com.massimo.utils.CaseInsensitiveHashMap<V>
Type Parameters:
V -
All Implemented Interfaces:
Serializable, Cloneable, Map<String,V>

public class CaseInsensitiveHashMap<V>
extends HashMap<String,V>

A HashMap that always does key.toString().toLowercase()

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
CaseInsensitiveHashMap()
          Constructs an empty CaseInsensitiveHashMap with the default initial capacity (16) and the default load factor (0.75).
CaseInsensitiveHashMap(int initialCapacity)
          Constructs an empty CaseInsensitiveHashMap with the specified initial capacity and the default load factor (0.75).
CaseInsensitiveHashMap(int initialCapacity, float loadFactor)
          Constructs an empty CaseInsensitiveHashMap with the specified initial capacity and load factor.
CaseInsensitiveHashMap(Map<? extends String,? extends V> m)
          Constructs a new CaseInsensitiveHashMap with the same mappings as the specified Map.
 
Method Summary
 boolean containsKey(Object key)
          Override HashMap
 V get(Object key)
          Override HashMap
 V put(String key, V value)
          Override HashMap
 V remove(Object key)
          Override HashMap
 
Methods inherited from class java.util.HashMap
clear, clone, containsValue, entrySet, isEmpty, keySet, putAll, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

CaseInsensitiveHashMap

public CaseInsensitiveHashMap()
Constructs an empty CaseInsensitiveHashMap with the default initial capacity (16) and the default load factor (0.75).


CaseInsensitiveHashMap

public CaseInsensitiveHashMap(int initialCapacity)
Constructs an empty CaseInsensitiveHashMap with the specified initial capacity and the default load factor (0.75).

Parameters:
initialCapacity - the initial capacity.
Throws:
IllegalArgumentException - if the initial capacity is negative.

CaseInsensitiveHashMap

public CaseInsensitiveHashMap(int initialCapacity,
                              float loadFactor)
Constructs an empty CaseInsensitiveHashMap with the specified initial capacity and load factor.

Parameters:
initialCapacity - The initial capacity.
loadFactor - The load factor.
Throws:
IllegalArgumentException - if the initial capacity is negative or the load factor is nonpositive.

CaseInsensitiveHashMap

public CaseInsensitiveHashMap(Map<? extends String,? extends V> m)
Constructs a new CaseInsensitiveHashMap with the same mappings as the specified Map. The CaseInsensitiveHashMap is created with default load factor (0.75) and an initial capacity sufficient to hold the mappings in the specified Map. This relies on the HashMap.putAll() implementation calling put().

Parameters:
m - the map whose mappings are to be placed in this map.
Throws:
NullPointerException - if the specified map is null.
Method Detail

containsKey

public boolean containsKey(Object key)
Override HashMap

Specified by:
containsKey in interface Map<String,V>
Overrides:
containsKey in class HashMap<String,V>
Parameters:
key - key whose presence in this map is to be tested.
Returns:
boolean

get

public V get(Object key)
Override HashMap

Specified by:
get in interface Map<String,V>
Overrides:
get in class HashMap<String,V>
Parameters:
key - key whose associated value is to be returned.
Returns:
Object

put

public V put(String key,
             V value)
Override HashMap

Specified by:
put in interface Map<String,V>
Overrides:
put in class HashMap<String,V>
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key

remove

public V remove(Object key)
Override HashMap

Specified by:
remove in interface Map<String,V>
Overrides:
remove in class HashMap<String,V>
Parameters:
key - key whose associated value is to be returned.
Returns:
previous value associated with specified key