org.apache.commons.collections.bidimap

Class UnmodifiableBidiMap

Implemented Interfaces:
BidiMap, IterableMap, Map, Unmodifiable

public final class UnmodifiableBidiMap
extends AbstractBidiMapDecorator
implements Unmodifiable

Decorates another BidiMap to ensure it can't be altered.
Version:
$Revision: 1.5 $ $Date: 2004/05/15 12:13:03 $
Author:
Stephen Colebourne
Since:
Commons Collections 3.0

Field Summary

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()
Set
keySet()
MapIterator
mapIterator()
Obtains a MapIterator over the map.
Object
put(Object key, Object value)
void
putAll(Map mapToCopy)
Object
remove(Object key)
Object
removeValue(Object value)
Collection
values()

Methods inherited from class org.apache.commons.collections.bidimap.AbstractBidiMapDecorator

getBidiMap, getKey, inverseBidiMap, mapIterator, removeValue

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

Method Details

clear

public void clear()
Overrides:
clear in interface AbstractMapDecorator

decorate

public static BidiMap decorate(BidiMap map)
Factory method to create an unmodifiable map.

If the map passed in is already unmodifiable, it is returned.

Parameters:
map - the map to decorate, must not be null
Returns:
an unmodifiable BidiMap

entrySet

public Set entrySet()
Overrides:
entrySet in interface AbstractMapDecorator

inverseBidiMap

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

keySet

public Set keySet()
Overrides:
keySet in interface AbstractMapDecorator

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
Overrides:
mapIterator in interface AbstractBidiMapDecorator
Returns:
a map iterator

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface BidiMap
Overrides:
put in interface AbstractMapDecorator

putAll

public void putAll(Map mapToCopy)
Overrides:
putAll in interface AbstractMapDecorator

remove

public Object remove(Object key)
Overrides:
remove in interface AbstractMapDecorator

removeValue

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

values

public Collection values()
Overrides:
values in interface AbstractMapDecorator

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