|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
org.geotools.util.CheckedHashMap<K,V>
K
- The type of keys in the map.V
- The type of values in the map.public class CheckedHashMap<K,V>
A checked and synchronized Map
. Type checks are performed at run-time in addition of
compile-time checks. The synchronization lock can be modified at runtime by overriding the
getLock()
method.
This class is similar to using the wrappers provided in Collections
, minus the cost
of indirection levels and with the addition of overrideable methods.
Collections#checkedMap
,
Collections#synchronizedMap
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Constructor Summary | |
---|---|
CheckedHashMap(java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Constructs a map of the specified type. |
Method Summary | |
---|---|
protected void |
checkWritePermission()
Checks if changes in this collection are allowed. |
void |
clear()
Removes all of the elements from this map. |
CheckedHashMap<K,V> |
clone()
Returns a shallow copy of this map. |
boolean |
containsKey(java.lang.Object key)
Returns true if this map contains the specified key. |
boolean |
containsValue(java.lang.Object value)
Returns true if this map contains the specified value. |
boolean |
equals(java.lang.Object o)
Compares the specified object with this map for equality. |
V |
get(java.lang.Object key)
Returns the value to which the specified key is mapped, or null if none. |
protected java.lang.Object |
getLock()
Returns the synchronization lock. |
int |
hashCode()
Returns the hash code value for this map. |
boolean |
isEmpty()
Returns true if this map contains no elements. |
V |
put(K key,
V value)
Associates the specified value with the specified key in this map. |
void |
putAll(java.util.Map<? extends K,? extends V> m)
Copies all of the mappings from the specified map to this map. |
V |
remove(java.lang.Object key)
Removes the mapping for the specified key from this map if present. |
int |
size()
Returns the number of elements in this map. |
java.lang.String |
toString()
Returns a string representation of this map. |
Methods inherited from class java.util.LinkedHashMap |
---|
removeEldestEntry |
Methods inherited from class java.util.HashMap |
---|
entrySet, keySet, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
entrySet, keySet, values |
Constructor Detail |
---|
public CheckedHashMap(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
keyType
- The key type (should not be null).valueType
- The value type (should not be null).Method Detail |
---|
protected void checkWritePermission() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.protected java.lang.Object getLock()
this
.
Subclasses that override this method should be careful to update the lock reference
when this set is cloned.
public int size()
size
in interface java.util.Map<K,V>
size
in class java.util.HashMap<K,V>
public boolean isEmpty()
true
if this map contains no elements.
isEmpty
in interface java.util.Map<K,V>
isEmpty
in class java.util.HashMap<K,V>
public boolean containsKey(java.lang.Object key)
true
if this map contains the specified key.
containsKey
in interface java.util.Map<K,V>
containsKey
in class java.util.HashMap<K,V>
public boolean containsValue(java.lang.Object value)
true
if this map contains the specified value.
containsValue
in interface java.util.Map<K,V>
containsValue
in class java.util.LinkedHashMap<K,V>
public V get(java.lang.Object key)
null
if none.
get
in interface java.util.Map<K,V>
get
in class java.util.LinkedHashMap<K,V>
public V put(K key, V value) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
put
in interface java.util.Map<K,V>
put
in class java.util.HashMap<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
null
.
java.lang.IllegalArgumentException
- if the key or the value is not of the expected type.
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public void putAll(java.util.Map<? extends K,? extends V> m) throws java.lang.UnsupportedOperationException
putAll
in interface java.util.Map<K,V>
putAll
in class java.util.HashMap<K,V>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public V remove(java.lang.Object key) throws java.lang.UnsupportedOperationException
remove
in interface java.util.Map<K,V>
remove
in class java.util.HashMap<K,V>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public void clear() throws java.lang.UnsupportedOperationException
clear
in interface java.util.Map<K,V>
clear
in class java.util.LinkedHashMap<K,V>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public java.lang.String toString()
toString
in class java.util.AbstractMap<K,V>
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map<K,V>
equals
in class java.util.AbstractMap<K,V>
public int hashCode()
hashCode
in interface java.util.Map<K,V>
hashCode
in class java.util.AbstractMap<K,V>
public CheckedHashMap<K,V> clone()
clone
in class java.util.HashMap<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |