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>`

public class CaseInsensitiveDictionaryMap<K,V> extends Dictionary<K,V> implements 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

## Nested classes/interfaces inherited from interface java.util.Map

`Map.Entry<K extends Object,V extends Object>`

## Constructor Summary

Constructors
Constructor
Description
`CaseInsensitiveDictionaryMap()`
Create 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 Type
Method
Description
`Dictionary<K,V>`
`asUnmodifiableDictionary()`
Return an unmodifiable dictionary wrapping this CaseInsensitiveDictionaryMap.
`Map<K,V>`
`asUnmodifiableMap()`
Return an unmodifiable map wrapping this CaseInsensitiveDictionaryMap.
`void`
`clear()`
`boolean`
`containsKey(Object key)`
`boolean`
`containsValue(Object value)`
`Enumeration<V>`
`elements()`
`Set<Map.Entry<K,V>>`
`entrySet()`
`boolean`
`equals(Object obj)`
`static org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap.CaseInsensitiveKey`
`findCommonKeyIndex(String key)`
`V`
`get(Object 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()`
`Enumeration<K>`
`keys()`
`Set<K>`
`keySet()`
`V`
`put(K key, V value)`
`void`
`putAll(Map<? extends K,? extends V> m)`
`V`
`remove(Object key)`
`int`
`size()`
`String`
`toString()`
`static <K, V> Dictionary<K,V>`
`unmodifiableDictionary(Dictionary<? extends K,? extends V> d)`
Return an unmodifiable dictionary wrapping the specified dictionary.
`Collection<V>`
`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

public CaseInsensitiveDictionaryMap(Dictionary<? extends K,? extends V> dictionary)
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

public CaseInsensitiveDictionaryMap(Map<? extends K,? extends V> map)
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

public Enumeration<K> keys()

Specified by:
  `keys` in class `Dictionary<K,V>`

### elements

public Enumeration<V> elements()

Specified by:
  `elements` in class `Dictionary<K,V>`

### get

public V get(Object key)

If the key is a String, the key is located in a case-insensitive manner.

Specified by:
  `get` in interface `Map<K,V>`
Specified by:
  `get` in class `Dictionary<K,V>`

### size

public int size()

Specified by:
  `size` in interface `Map<K,V>`
Specified by:
  `size` in class `Dictionary<K,V>`

### isEmpty

public boolean isEmpty()

Specified by:
  `isEmpty` in interface `Map<K,V>`
Specified by:
  `isEmpty` in class `Dictionary<K,V>`

### put

public V put(K key, V value)

The key and value must be non-null.

If the key is a String, any case-variant will be replaced.

Specified by:
  `put` in interface `Map<K,V>`
Specified by:
  `put` in class `Dictionary<K,V>`

### remove

public V remove(Object key)

If the key is a String, the key is removed in a case-insensitive manner.

Specified by:
  `remove` in interface `Map<K,V>`
Specified by:
  `remove` in class `Dictionary<K,V>`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### clear

public void clear()

Specified by:
  `clear` in interface `Map<K,V>`

### containsKey

public boolean containsKey(Object key)

If the key is a String, the key is located in a case-insensitive manner.

Specified by:
  `containsKey` in interface `Map<K,V>`

### containsValue

public boolean containsValue(Object value)

Specified by:
  `containsValue` in interface `Map<K,V>`

### entrySet

public Set<Map.Entry<K,V>> entrySet()

Specified by:
  `entrySet` in interface `Map<K,V>`

### keySet

public Set<K> keySet()

Specified by:
  `keySet` in interface `Map<K,V>`

### values

public Collection<V> values()

Specified by:
  `values` in interface `Map<K,V>`

### putAll

public void putAll(Map<? extends K,? extends V> m)

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.

Specified by:
  `putAll` in interface `Map<K,V>`

### hashCode

public int hashCode()

Specified by:
  `hashCode` in interface `Map<K,V>`
Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object obj)

Specified by:
  `equals` in interface `Map<K,V>`
Overrides:
  `equals` in class `Object`

### asUnmodifiableMap

public Map<K,V> asUnmodifiableMap()
Return an unmodifiable map wrapping this CaseInsensitiveDictionaryMap.

Returns:
  An unmodifiable map wrapping this CaseInsensitiveDictionaryMap.

### asUnmodifiableDictionary

public Dictionary<K,V> asUnmodifiableDictionary()
Return an unmodifiable dictionary wrapping this CaseInsensitiveDictionaryMap.

Returns:
  An unmodifiable dictionary wrapping this CaseInsensitiveDictionaryMap.

### unmodifiableDictionary

public static <K, V> Dictionary<K,V> unmodifiableDictionary(Dictionary<? extends K,? extends V> d)
Return an unmodifiable dictionary wrapping the specified dictionary.

Returns:
  An unmodifiable dictionary wrapping the specified dictionary.