org.apache.commons.collections.bidimap

Class AbstractBidiMapDecorator

Implemented Interfaces:
BidiMap, IterableMap, Map
Known Direct Subclasses:
AbstractOrderedBidiMapDecorator, UnmodifiableBidiMap

public abstract class AbstractBidiMapDecorator
extends AbstractMapDecorator
implements BidiMap

Provides a base decorator that enables additional functionality to be added to a BidiMap via decoration.

Methods are forwarded directly to the decorated map.

This implementation does not perform any special processing with the map views. Instead it simply returns the set/collection from the wrapped map. This may be undesirable, for example if you are trying to write a validating implementation it would provide a loophole around the validation. But, you might want that loophole, so this class is kept simple.

Version:
$Revision: 1.5 $ $Date: 2004/02/18 00:57:39 $
Author:
Stephen Colebourne
Since:
Commons Collections 3.0

Field Summary

Fields inherited from class org.apache.commons.collections.map.AbstractMapDecorator

map

Constructor Summary

AbstractBidiMapDecorator(BidiMap map)
Constructor that wraps (not copies).

Method Summary

protected BidiMap
getBidiMap()
Gets the map being decorated.
Object
getKey(Object value)
BidiMap
inverseBidiMap()
MapIterator
mapIterator()
Obtains a MapIterator over the map.
Object
removeValue(Object value)

Methods inherited from class org.apache.commons.collections.map.AbstractMapDecorator

clear, containsKey, containsValue, entrySet, equals, get, getMap, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values

Constructor Details

AbstractBidiMapDecorator

protected AbstractBidiMapDecorator(BidiMap map)
Constructor that wraps (not copies).
Parameters:
map - the map to decorate, must not be null

Method Details

getBidiMap

protected BidiMap getBidiMap()
Gets the map being decorated.
Returns:
the decorated map

getKey

public Object getKey(Object value)
Specified by:
getKey in interface BidiMap

inverseBidiMap

public BidiMap inverseBidiMap()
Specified by:
inverseBidiMap in interface BidiMap

mapIterator

public MapIterator mapIterator()
Obtains a MapIterator over the map.

A map iterator is an efficient way of iterating over maps. There is no need to access the entry set or cast to Map Entry objects.

 IterableMap map = new HashedMap();
 MapIterator it = map.mapIterator();
 while (it.hasNext()) {
   Object key = it.next();
   Object value = it.getValue();
   it.setValue("newValue");
 }
 
Specified by:
mapIterator in interface BidiMap
mapIterator in interface IterableMap
Returns:
a map iterator

removeValue

public Object removeValue(Object value)
Specified by:
removeValue in interface BidiMap

Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.