org.springframework.util
Class LinkedCaseInsensitiveMap<V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<java.lang.String,V>
org.springframework.util.LinkedCaseInsensitiveMap<V>
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,V>
public class LinkedCaseInsensitiveMap<V>
- extends java.util.LinkedHashMap<java.lang.String,V>
LinkedHashMap
variant that stores String keys in a case-insensitive
manner, for example for key-based access in a results table.
Preserves the original order as well as the original casing of keys,
while allowing for contains, get and remove calls with any case of key.
Does not support null
keys.
- Since:
- 3.0
- Author:
- Juergen Hoeller
- See Also:
- Serialized Form
Nested classes/interfaces inherited from class java.util.AbstractMap |
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Constructor Summary |
LinkedCaseInsensitiveMap()
Create a new LinkedCaseInsensitiveMap for the default Locale. |
LinkedCaseInsensitiveMap(int initialCapacity)
Create a new LinkedCaseInsensitiveMap that wraps a LinkedHashMap
with the given initial capacity and stores lower-case keys according
to the default Locale. |
LinkedCaseInsensitiveMap(int initialCapacity,
java.util.Locale locale)
Create a new LinkedCaseInsensitiveMap that wraps a LinkedHashMap
with the given initial capacity and stores lower-case keys according
to the given Locale. |
LinkedCaseInsensitiveMap(java.util.Locale locale)
Create a new LinkedCaseInsensitiveMap that stores lower-case keys
according to the given Locale. |
Method Summary |
void |
clear()
|
boolean |
containsKey(java.lang.Object key)
|
protected java.lang.String |
convertKey(java.lang.String key)
Convert the given key to a case-insensitive key. |
V |
get(java.lang.Object key)
|
V |
put(java.lang.String key,
V value)
|
V |
remove(java.lang.Object key)
|
Methods inherited from class java.util.LinkedHashMap |
containsValue, removeEldestEntry |
Methods inherited from class java.util.HashMap |
clone, 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 |
entrySet, equals, hashCode, isEmpty, keySet, putAll, size, values |
caseInsensitiveKeys
private final java.util.Map<java.lang.String,java.lang.String> caseInsensitiveKeys
locale
private final java.util.Locale locale
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap()
- Create a new LinkedCaseInsensitiveMap for the default Locale.
- See Also:
String.toLowerCase()
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(java.util.Locale locale)
- Create a new LinkedCaseInsensitiveMap that stores lower-case keys
according to the given Locale.
- Parameters:
locale
- the Locale to use for lower-case conversion- See Also:
String.toLowerCase(java.util.Locale)
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(int initialCapacity)
- Create a new LinkedCaseInsensitiveMap that wraps a
LinkedHashMap
with the given initial capacity and stores lower-case keys according
to the default Locale.
- Parameters:
initialCapacity
- the initial capacity- See Also:
String.toLowerCase()
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(int initialCapacity,
java.util.Locale locale)
- Create a new LinkedCaseInsensitiveMap that wraps a
LinkedHashMap
with the given initial capacity and stores lower-case keys according
to the given Locale.
- Parameters:
initialCapacity
- the initial capacitylocale
- the Locale to use for lower-case conversion- See Also:
String.toLowerCase(java.util.Locale)
put
public V put(java.lang.String key,
V value)
- Specified by:
put
in interface java.util.Map<java.lang.String,V>
- Overrides:
put
in class java.util.HashMap<java.lang.String,V>
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interface java.util.Map<java.lang.String,V>
- Overrides:
containsKey
in class java.util.HashMap<java.lang.String,V>
get
public V get(java.lang.Object key)
- Specified by:
get
in interface java.util.Map<java.lang.String,V>
- Overrides:
get
in class java.util.LinkedHashMap<java.lang.String,V>
remove
public V remove(java.lang.Object key)
- Specified by:
remove
in interface java.util.Map<java.lang.String,V>
- Overrides:
remove
in class java.util.HashMap<java.lang.String,V>
clear
public void clear()
- Specified by:
clear
in interface java.util.Map<java.lang.String,V>
- Overrides:
clear
in class java.util.LinkedHashMap<java.lang.String,V>
convertKey
protected java.lang.String convertKey(java.lang.String key)
- Convert the given key to a case-insensitive key.
The default implementation converts the key
to lower-case according to this Map's Locale.
- Parameters:
key
- the user-specified key
- Returns:
- the key to use for storing
- See Also:
String.toLowerCase(java.util.Locale)