Package org.eclipse.osgi.framework.util
Class CaseInsensitiveDictionaryMap<K,V>
java.lang.Object
java.util.Dictionary<K,V>
org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap<K,V>
- All Implemented Interfaces:
Map<K,
V>
CaseInsensitiveDictionaryMap classes. This class implements Dictionary and
Map with the following behavior:
- String keys are case-preserved, but the lookup operations are case-insensitive.
- Keys and values must not be null.
- Since:
- 3.13
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionCreate an empty CaseInsensitiveDictionaryMap.CaseInsensitiveDictionaryMap
(int initialCapacity) Create an empty CaseInsensitiveDictionaryMap.CaseInsensitiveDictionaryMap
(Dictionary<? extends K, ? extends V> dictionary) Create a CaseInsensitiveDictionaryMap dictionary from a Dictionary.CaseInsensitiveDictionaryMap
(Map<? extends K, ? extends V> map) Create a CaseInsensitiveDictionaryMap dictionary from a Map. -
Method Summary
Modifier and TypeMethodDescriptionDictionary<K,
V> Return an unmodifiable dictionary wrapping this CaseInsensitiveDictionaryMap.Return an unmodifiable map wrapping this CaseInsensitiveDictionaryMap.void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) elements()
entrySet()
boolean
static org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap.CaseInsensitiveKey
findCommonKeyIndex
(String key) int
hashCode()
protected static int
initialCapacity
(int size) Compute the initial capacity of a map for the specified number of entries based upon the load factor of 0.75f.boolean
isEmpty()
keys()
keySet()
void
int
size()
toString()
static <K,
V> Dictionary<K, V> unmodifiableDictionary
(Dictionary<? extends K, ? extends V> d) Return an unmodifiable dictionary wrapping the specified dictionary.values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
CaseInsensitiveDictionaryMap
public CaseInsensitiveDictionaryMap()Create an empty CaseInsensitiveDictionaryMap. -
CaseInsensitiveDictionaryMap
public CaseInsensitiveDictionaryMap(int initialCapacity) Create an empty CaseInsensitiveDictionaryMap.- Parameters:
initialCapacity
- The initial capacity.
-
CaseInsensitiveDictionaryMap
Create a CaseInsensitiveDictionaryMap dictionary from a Dictionary.- Parameters:
dictionary
- The initial dictionary for this CaseInsensitiveDictionaryMap object.- Throws:
IllegalArgumentException
- If a case-variants of a key are in the dictionary parameter.
-
CaseInsensitiveDictionaryMap
Create a CaseInsensitiveDictionaryMap dictionary from a Map.- Parameters:
map
- The initial map for this CaseInsensitiveDictionaryMap object.- Throws:
IllegalArgumentException
- If a case-variants of a key are in the map parameter.
-
-
Method Details
-
findCommonKeyIndex
public static org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap.CaseInsensitiveKey findCommonKeyIndex(String key) -
initialCapacity
protected static int initialCapacity(int size) Compute the initial capacity of a map for the specified number of entries based upon the load factor of 0.75f.- Parameters:
size
- The desired number of entries.- Returns:
- The initial capacity of a map.
-
keys
- Specified by:
keys
in classDictionary<K,
V>
-
elements
- Specified by:
elements
in classDictionary<K,
V>
-
get
If the key is a String, the key is located in a case-insensitive manner.
-
size
public int size() -
isEmpty
public boolean isEmpty() -
put
The key and value must be non-null.
If the key is a String, any case-variant will be replaced.
-
remove
If the key is a String, the key is removed in a case-insensitive manner.
-
toString
-
clear
public void clear() -
containsKey
If the key is a String, the key is located in a case-insensitive manner.
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
entrySet
-
keySet
-
values
-
putAll
If the specified map has case-variants of a String key, only the last case-variant found while iterating over the entrySet will be present in this object.
-
hashCode
public int hashCode() -
equals
-
asUnmodifiableMap
Return an unmodifiable map wrapping this CaseInsensitiveDictionaryMap.- Returns:
- An unmodifiable map wrapping this CaseInsensitiveDictionaryMap.
-
asUnmodifiableDictionary
Return an unmodifiable dictionary wrapping this CaseInsensitiveDictionaryMap.- Returns:
- An unmodifiable dictionary wrapping this CaseInsensitiveDictionaryMap.
-
unmodifiableDictionary
Return an unmodifiable dictionary wrapping the specified dictionary.- Returns:
- An unmodifiable dictionary wrapping the specified dictionary.
-