org.apache.commons.collections.map
Class UnmodifiableOrderedMap<K,V>

java.lang.Object
  extended by org.apache.commons.collections.map.AbstractMapDecorator<K,V>
      extended by org.apache.commons.collections.map.AbstractOrderedMapDecorator<K,V>
          extended by org.apache.commons.collections.map.UnmodifiableOrderedMap<K,V>
All Implemented Interfaces:
Serializable, Map<K,V>, IterableMap<K,V>, OrderedMap<K,V>, Unmodifiable

public final class UnmodifiableOrderedMap<K,V>
extends AbstractOrderedMapDecorator<K,V>
implements Unmodifiable, Serializable

Decorates another OrderedMap to ensure it can't be altered.

This class is Serializable from Commons Collections 3.1.

Since:
Commons Collections 3.0
Version:
$Revision: 1.1.1.1 $ $Date: 2005/05/23 04:36:16 $
Author:
Matt Hall, John Watkinson, Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.apache.commons.collections.map.AbstractMapDecorator
map
 
Method Summary
 void clear()
           
static
<K,V> OrderedMap<K,V>
decorate(OrderedMap<K,V> map)
          Factory method to create an unmodifiable sorted map.
 Set<Map.Entry<K,V>> entrySet()
           
 Set<K> keySet()
           
 MapIterator<K,V> mapIterator()
          Obtains a MapIterator over the map.
 OrderedMapIterator<K,V> orderedMapIterator()
          Obtains an OrderedMapIterator over the map.
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> mapToCopy)
           
 V remove(Object key)
           
 Collection<V> values()
           
 
Methods inherited from class org.apache.commons.collections.map.AbstractOrderedMapDecorator
firstKey, getOrderedMap, lastKey, nextKey, previousKey
 
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

decorate

public static <K,V> OrderedMap<K,V> decorate(OrderedMap<K,V> map)
Factory method to create an unmodifiable sorted map.

Parameters:
map - the map to decorate, must not be null
Throws:
IllegalArgumentException - if map is null

mapIterator

public MapIterator<K,V> mapIterator()
Description copied from interface: IterableMap
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 IterableMap<K,V>
Overrides:
mapIterator in class AbstractOrderedMapDecorator<K,V>
Returns:
a map iterator

orderedMapIterator

public OrderedMapIterator<K,V> orderedMapIterator()
Description copied from interface: OrderedMap
Obtains an OrderedMapIterator over the map.

A ordered map iterator is an efficient way of iterating over maps in both directions.

 BidiMap map = new TreeBidiMap();
 MapIterator it = map.mapIterator();
 while (it.hasNext()) {
   Object key = it.next();
   Object value = it.getValue();
   it.setValue("newValue");
   Object previousKey = it.previous();
 }
 

Specified by:
orderedMapIterator in interface OrderedMap<K,V>
Overrides:
orderedMapIterator in class AbstractOrderedMapDecorator<K,V>
Returns:
a map iterator

clear

public void clear()
Specified by:
clear in interface Map<K,V>
Overrides:
clear in class AbstractMapDecorator<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMapDecorator<K,V>

putAll

public void putAll(Map<? extends K,? extends V> mapToCopy)
Specified by:
putAll in interface Map<K,V>
Overrides:
putAll in class AbstractMapDecorator<K,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class AbstractMapDecorator<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>
Overrides:
entrySet in class AbstractMapDecorator<K,V>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class AbstractMapDecorator<K,V>

values

public Collection<V> values()
Specified by:
values in interface Map<K,V>
Overrides:
values in class AbstractMapDecorator<K,V>


Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.