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.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.String> |
caseInsensitiveKeys |
private java.util.Locale |
locale |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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) |
void |
putAll(java.util.Map<? extends java.lang.String,? extends V> map) |
V |
remove(java.lang.Object key) |
private final java.util.Map<java.lang.String,java.lang.String> caseInsensitiveKeys
private final java.util.Locale locale
public LinkedCaseInsensitiveMap()
String.toLowerCase()
public LinkedCaseInsensitiveMap(java.util.Locale locale)
locale
- the Locale to use for lower-case conversionString.toLowerCase(java.util.Locale)
public LinkedCaseInsensitiveMap(int initialCapacity)
LinkedHashMap
with the given initial capacity and stores lower-case keys according
to the default Locale.initialCapacity
- the initial capacityString.toLowerCase()
public LinkedCaseInsensitiveMap(int initialCapacity, java.util.Locale locale)
LinkedHashMap
with the given initial capacity and stores lower-case keys according
to the given Locale.initialCapacity
- the initial capacitylocale
- the Locale to use for lower-case conversionString.toLowerCase(java.util.Locale)
public void putAll(java.util.Map<? extends java.lang.String,? extends V> map)
public boolean containsKey(java.lang.Object key)
public V get(java.lang.Object key)
public V remove(java.lang.Object key)
public void clear()
protected java.lang.String convertKey(java.lang.String key)
The default implementation converts the key to lower-case according to this Map's Locale.
key
- the user-specified keyString.toLowerCase(java.util.Locale)