org.eclipse.gemini.blueprint.util.internal
Class MapBasedDictionary<K,V>

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by org.eclipse.gemini.blueprint.util.internal.MapBasedDictionary<K,V>
All Implemented Interfaces:
Map<K,V>

public class MapBasedDictionary<K,V>
extends Dictionary<K,V>
implements Map<K,V>

Dictionary implementation backed by a map instance. While the JDK provides a Dictionary implementation through Hashtable, the class itself is always synchronized and does not maintain the internal order.

This simple wrapper, accepts any type of Map as backing storage allowing more options in choosing the appropriate implementation. By default, a LinkedHashMap is used, if no Map is specified.

This implementation will enforce the Dictionary behaviour over the map when it comes to handling null values. As opposed to a Map, the Dictionary always throws NullPointerException if a given argument is null.

Author:
Costin Leau
See Also:
Map, Dictionary

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
MapBasedDictionary()
          Default constructor.
MapBasedDictionary(Dictionary<? extends K,? extends V> dictionary)
          Constructor for dealing with existing Dictionary.
MapBasedDictionary(int initialCapacity)
           
MapBasedDictionary(Map<K,V> map)
           
MapBasedDictionary(Map<K,V> map, Dictionary<? extends K,? extends V> dictionary)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Enumeration<V> elements()
           
 Set<Map.Entry<K,V>> entrySet()
           
 boolean equals(Object obj)
           
 V get(Object key)
           
 int hashCode()
           
 boolean isEmpty()
           
 Enumeration<K> keys()
           
 Set<K> keySet()
           
 V put(K key, V value)
           
<T extends K>
void
putAll(Dictionary<T,? extends V> dictionary)
           
 void putAll(Map<? extends K,? extends V> t)
           
 V remove(Object key)
           
 int size()
           
 String toString()
           
 Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapBasedDictionary

public MapBasedDictionary(Map<K,V> map)

MapBasedDictionary

public MapBasedDictionary()
Default constructor.


MapBasedDictionary

public MapBasedDictionary(int initialCapacity)

MapBasedDictionary

public MapBasedDictionary(Dictionary<? extends K,? extends V> dictionary)
Constructor for dealing with existing Dictionary. Will copy the content into the inner Map.

Parameters:
dictionary -

MapBasedDictionary

public MapBasedDictionary(Map<K,V> map,
                          Dictionary<? extends K,? extends V> dictionary)
Method Detail

clear

public void clear()
Specified by:
clear in interface Map<K,V>

containsKey

public boolean containsKey(Object key)
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>

get

public V get(Object key)
Specified by:
get in interface Map<K,V>
Specified by:
get 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>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>
Specified by:
put in class Dictionary<K,V>

putAll

public void putAll(Map<? extends K,? extends V> t)
Specified by:
putAll in interface Map<K,V>

putAll

public <T extends K> void putAll(Dictionary<T,? extends V> dictionary)

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>
Specified by:
remove 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>

values

public Collection<V> values()
Specified by:
values in interface Map<K,V>

elements

public Enumeration<V> elements()
Specified by:
elements in class Dictionary<K,V>

keys

public Enumeration<K> keys()
Specified by:
keys in class Dictionary<K,V>

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Specified by:
equals in interface Map<K,V>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Map<K,V>
Overrides:
hashCode in class Object


Copyright © 2006-2013. All Rights Reserved.