Map.
Before keys are added to the map or compared to other existing keys, they are converted to all lowercase in a locale-independent fashion by using information from the Unicode data file.
Null keys are supported.
The keySet() method returns all lowercase keys, or nulls.
Example:
Map<String, String> map = new CaseInsensitiveMap<String, String>();
map.put("One", "One");
map.put("Two", "Two");
map.put(null, "Three");
map.put("one", "Four");
The example above creates a CaseInsensitiveMap with three entries.
map.get(null) returns "Three" and map.get("ONE")
returns "Four". The Set returned by keySet()
equals {"one", "two", null}.
This map will violate the detail of various Map and map view contracts.
As a general rule, don't compare this map to other maps. In particular, you can't
use decorators like ListOrderedMap on it, which silently assume that these
contracts are fulfilled.
Note that CaseInsensitiveMap is not synchronized and is not thread-safe.
If you wish to use this map from multiple threads concurrently, you must use
appropriate synchronization. The simplest approach is to wrap this map
using java.. This class may throw
exceptions when accessed by concurrent threads without synchronization.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Serialisation version |
| Access | Constructor and Description |
|---|---|
| public | |
| public | CaseInsensitiveMap(final int
the initial capacity initialCapacity)Constructs a new, empty map with the specified initial capacity. |
| public | CaseInsensitiveMap(final int
the initial capacity initialCapacity, final float the load factor loadFactor)Constructs a new, empty map with the specified initial capacity and load factor. |
| public | CaseInsensitiveMap(final Map<? extends K, ? extends V>
the map to copy map)Constructor copying elements from another map. |
| Modifier and Type | Method and Description |
|---|---|
| public CaseInsensitiveMap | Returns: a shallow cloneOverrides org. |
| protected Object | Returns: the converted keythe key convert key)Overrides org. AbstractHashedMap to convert keys to
lower case.
|
| private void | |
| private void |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialisation version | |
| CaseInsensitiveMap | back to summary |
|---|---|
| public CaseInsensitiveMap() Constructs a new empty map with default size and load factor. | |
| CaseInsensitiveMap | back to summary |
|---|---|
| public CaseInsensitiveMap(final int initialCapacity) Constructs a new, empty map with the specified initial capacity.
| |
| CaseInsensitiveMap | back to summary |
|---|---|
| public CaseInsensitiveMap(final int initialCapacity, final float loadFactor) Constructs a new, empty map with the specified initial capacity and load factor.
| |
| CaseInsensitiveMap | back to summary |
|---|---|
| public CaseInsensitiveMap(final Map<? extends K, ? extends V> map) Constructor copying elements from another map. Keys will be converted to lower case strings, which may cause some entries to be removed (if string representation of keys differ only by character case).
| |
| clone | back to summary |
|---|---|
| public CaseInsensitiveMap Overrides org. Clones the map without cloning the keys or values.
| |
| convertKey | back to summary |
|---|---|
| protected Object convertKey(final Object key) Overrides org. Overrides convertKey() from
Returns | |
| readObject | back to summary |
|---|---|
| private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException Read the map in using a custom routine.
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(final ObjectOutputStream out) throws IOException Write the map out using a custom routine.
| |