|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.collections.map.AbstractMapDecorator | +--org.apache.commons.collections.bidimap.AbstractBidiMapDecorator | +--org.apache.commons.collections.bidimap.UnmodifiableBidiMap
Decorates another BidiMap
to ensure it can't be altered.
Inner classes inherited from class java.util.Map |
Map.Entry |
Fields inherited from class org.apache.commons.collections.map.AbstractMapDecorator |
map |
Method Summary | |
void |
clear()
|
static BidiMap |
decorate(BidiMap map)
Factory method to create an unmodifiable map. |
Set |
entrySet()
|
BidiMap |
inverseBidiMap()
Gets a view of this map where the keys and values are reversed. |
Set |
keySet()
|
MapIterator |
mapIterator()
Obtains a MapIterator over the map. |
Object |
put(Object key,
Object value)
Puts the key-value pair into the map, replacing any previous pair. |
void |
putAll(Map mapToCopy)
|
Object |
remove(Object key)
|
Object |
removeValue(Object value)
Removes the key-value pair that is currently mapped to the specified value (optional operation). |
Collection |
values()
|
Methods inherited from class org.apache.commons.collections.bidimap.AbstractBidiMapDecorator |
getBidiMap, getKey |
Methods inherited from class org.apache.commons.collections.map.AbstractMapDecorator |
containsKey, containsValue, equals, get, getMap, hashCode, isEmpty, size, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
containsKey, containsValue, equals, get, hashCode, isEmpty, size |
Method Detail |
public static BidiMap decorate(BidiMap map)
map
- the map to decorate, must not be nullIllegalArgumentException
- if map is nullpublic void clear()
clear
in class AbstractMapDecorator
public Object put(Object key, Object value)
BidiMap
When adding a key-value pair, the value may already exist in the map against a different key. That mapping is removed, to ensure that the value only occurs once in the inverse map.
BidiMap map1 = new DualHashBidiMap(); map.put("A","B"); // contains A mapped to B, as per Map map.put("A","C"); // contains A mapped to C, as per Map BidiMap map2 = new DualHashBidiMap(); map.put("A","B"); // contains A mapped to B, as per Map map.put("C","B"); // contains C mapped to B, key A is removed
put
in class AbstractMapDecorator
org.apache.commons.collections.BidiMap
key
- the key to storevalue
- the value to storeUnsupportedOperationException
- if the put
method is not supportedClassCastException
- (optional) if the map limits the type of the
value and the specified value is inappropriateIllegalArgumentException
- (optional) if the map limits the values
in some way and the value was invalidNullPointerException
- (optional) if the map limits the values to
non-null and null was specifiedpublic void putAll(Map mapToCopy)
putAll
in class AbstractMapDecorator
public Object remove(Object key)
remove
in class AbstractMapDecorator
public Set entrySet()
entrySet
in class AbstractMapDecorator
public Set keySet()
keySet
in class AbstractMapDecorator
public Collection values()
values
in class AbstractMapDecorator
public Object removeValue(Object value)
BidiMap
If the value is not contained in the map, null
is returned.
Implementations should seek to make this method perform equally as well
as remove(Object)
.
removeValue
in class AbstractBidiMapDecorator
org.apache.commons.collections.BidiMap
value
- the value to find the key-value pair fornull
if nothing removedClassCastException
- (optional) if the map limits the type of the
value and the specified value is inappropriateNullPointerException
- (optional) if the map limits the values to
non-null and null was specifiedUnsupportedOperationException
- if this method is not supported
by the implementationpublic MapIterator mapIterator()
BidiMap
MapIterator
over the map.
A map iterator is an efficient way of iterating over maps. It does not require that the map is stored using Map Entry objects which can increase performance.
BidiMap map = new DualHashBidiMap(); MapIterator it = map.mapIterator(); while (it.hasNext()) { Object key = it.next(); Object value = it.getValue(); it.setValue("newValue"); }
mapIterator
in class AbstractBidiMapDecorator
org.apache.commons.collections.BidiMap
public BidiMap inverseBidiMap()
BidiMap
Changes to one map will be visible in the other and vice versa.
This enables both directions of the map to be accessed as a Map
.
Implementations should seek to avoid creating a new object every time this
method is called. See AbstractMap.values()
etc. Calling this
method on the inverse map should return the original.
inverseBidiMap
in class AbstractBidiMapDecorator
org.apache.commons.collections.BidiMap
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |