|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectLocalMap<K,V>
public final class LocalMap<K,V>
This class represents a map which can be temporarily modified without
impacting other threads (scoped changes).
Operation on instances of this class are thread-safe.
For example:
public class XMLFormat {
static LocalMap
Note: Because key-value mappings are inherited, the semantic of
remove(java.lang.Object) and clear() is slightly modified (association with
null values instead of removing the entries).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
LocalMap()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all mappings from this map (sets the local values to null). |
boolean |
containsKey(Object key)
Indicates if this map contains a mapping for the specified key. |
boolean |
containsValue(Object value)
Indicates if this map associates one or more keys to the specified value. |
Set<Map.Entry<K,V>> |
entrySet()
Returns a FastCollection view of the mappings contained in this
map. |
V |
get(Object key)
Returns the value to which this map associates the specified key. |
V |
getDefault(K key)
Returns the default value for the specified key. |
boolean |
isEmpty()
Indicates if this map contains no key-value mappings. |
Set<K> |
keySet()
Returns a FastCollection view of the keys contained in this map. |
V |
put(K key,
V value)
Associates the specified value with the specified key in this map. |
void |
putAll(Map<? extends K,? extends V> map)
Copies all of the mappings from the specified map to this map. |
V |
putDefault(K key,
V defaultValue)
Sets the default value for the specified key (typically done at initialization). |
V |
remove(Object key)
Removes the mapping for this key from this map if present (sets the local value to null). |
LocalMap<K,V> |
setKeyComparator(FastComparator<? super K> keyComparator)
Sets the key comparator for this local map. |
LocalMap<K,V> |
setValueComparator(FastComparator<? super V> valueComparator)
Sets the value comparator for this local map. |
int |
size()
Returns the number of key-value mappings in this map. |
Collection<V> |
values()
Returns a FastCollection view of the values contained in this
map. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public LocalMap()
| Method Detail |
|---|
public LocalMap<K,V> setKeyComparator(FastComparator<? super K> keyComparator)
keyComparator - the key comparator.
thispublic LocalMap<K,V> setValueComparator(FastComparator<? super V> valueComparator)
valueComparator - the value comparator.
this
public V putDefault(K key,
V defaultValue)
key - the key with which the specified value is to be associated.defaultValue - the default value to be associated with the
specified key.
null if there was no mapping for key. A
null return can also indicate that the map
previously associated null with the specified key.
NullPointerException - if the key is null.public V getDefault(K key)
key - the key with which the default value is associated.
null if there was no mapping for the key.
NullPointerException - if the key is null.public int size()
size in interface Map<K,V>public boolean isEmpty()
isEmpty in interface Map<K,V>true if this map contains no key-value mappings;
false otherwise.public boolean containsKey(Object key)
containsKey in interface Map<K,V>key - the key whose presence in this map is to be tested.
true if this map contains a mapping for the
specified key; false otherwise.
NullPointerException - if the key is null.public boolean containsValue(Object value)
containsValue in interface Map<K,V>value - the value whose presence in this map is to be tested.
true if this map maps one or more keys to the
specified value.
NullPointerException - if the key is null.public V get(Object key)
get in interface Map<K,V>key - the key whose associated value is to be returned.
null if there is no mapping for the key.
NullPointerException - if key is null.
public V put(K key,
V value)
put in interface Map<K,V>key - the key with which the specified value is to be associated.value - the value to be associated with the specified key.
null if there was no mapping for key. A
null return can also indicate that the map
previously associated null with the specified key.
NullPointerException - if the key is null.public void putAll(Map<? extends K,? extends V> map)
putAll in interface Map<K,V>map - the mappings to be stored in this map.
NullPointerException - the specified map is null,
or the specified map contains null keys.public V remove(Object key)
null).
remove in interface Map<K,V>key - the key whose value is set to null
put(key, null)
NullPointerException - if the key is null.public void clear()
null).
clear in interface Map<K,V>public Set<K> keySet()
FastCollection view of the keys contained in this map.
keySet in interface Map<K,V>FastCollection).public Collection<V> values()
FastCollection view of the values contained in this
map.
values in interface Map<K,V>FastCollection).public Set<Map.Entry<K,V>> entrySet()
FastCollection view of the mappings contained in this
map.
entrySet in interface Map<K,V>FastCollection).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||