edu.mayo.bsi.ngsportal.shared
Class CaseInsensitiveMap<V>

java.lang.Object
  extended by edu.mayo.bsi.ngsportal.shared.CaseInsensitiveMap<V>
Type Parameters:
V - The class of the Map's values
All Implemented Interfaces:
Map<String,V>

public class CaseInsensitiveMap<V>
extends Object
implements Map<String,V>

A map class for Mapping SQL Strings (as keys) to values, since SQL Strings are case insensitive, and normal Maps are not

@author Gregory Dougherty


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
CaseInsensitiveMap(Map<String,V> parentMap)
          Create a Case-insensitive Map, that uses the sorting, etc.
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<String,V>> entrySet()
          Returns the keys that were passed in, rather than the case insensitive keys actually used.
 V get(Object key)
           
 Map<V,String> invertMap()
          Returns a map that goes from the value to the key.
 boolean isEmpty()
           
 Set<String> keySet()
          Returns the keys that were passed in, rather than the case insensitive keys actually used.
 V put(String key, V value)
           
 void putAll(Map<? extends String,? extends V> m)
           
 V remove(Object key)
           
 int size()
           
 Collection<V> values()
           
 
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

CaseInsensitiveMap

public CaseInsensitiveMap(Map<String,V> parentMap)
Create a Case-insensitive Map, that uses the sorting, etc. of the passed in Map. This constructor violates the Map Contract, because this constructor takes ownership of the passed in Map, rather than just copying it, which is what it's supposed to do. If parentMap is a HashMap, it will be cloned, if it is a TreeMap it will be copied as a TreeMap, in which case the contract will be fulfilled.

Parameters:
parentMap - Map that becomes the basis of this Map, including for things like sorting
Method Detail

size

public int size()
Specified by:
size in interface Map<String,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<String,V>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<String,V>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<String,V>

get

public V get(Object key)
Specified by:
get in interface Map<String,V>

put

public V put(String key,
             V value)
Specified by:
put in interface Map<String,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<String,V>

putAll

public void putAll(Map<? extends String,? extends V> m)
Specified by:
putAll in interface Map<String,V>

clear

public void clear()
Specified by:
clear in interface Map<String,V>

keySet

public Set<String> keySet()
Returns the keys that were passed in, rather than the case insensitive keys actually used. As such, this is not the Map's real key set, and modifications of it will not be propagated back to the map. IOW, this routine violates the Map contract

Specified by:
keySet in interface Map<String,V>

values

public Collection<V> values()
Specified by:
values in interface Map<String,V>

entrySet

public Set<Map.Entry<String,V>> entrySet()
Returns the keys that were passed in, rather than the case insensitive keys actually used. As such, this is not the Map's real entrySet, and modifications of it will not be propagated back to the map. IOW, this routine violates the Map contract

Specified by:
entrySet in interface Map<String,V>

invertMap

public Map<V,String> invertMap()
Returns a map that goes from the value to the key. Only works if user hasn't placed any degenerate values (values mapped to by more than one key

Returns:
A HashMap from V to String, going to the case sensitive versions of the String