org.apache.commons.collections.map

Class AbstractOrderedMapDecorator

Implemented Interfaces:
IterableMap, Map, OrderedMap
Known Direct Subclasses:
UnmodifiableOrderedMap

public abstract class AbstractOrderedMapDecorator
extends AbstractMapDecorator
implements OrderedMap

Provides a base decorator that enables additional functionality to be added to an OrderedMap 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.7 $ $Date: 2004/04/02 21:17:48 $
Author:
Stephen Colebourne
Since:
Commons Collections 3.0

Field Summary

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

map

Constructor Summary

AbstractOrderedMapDecorator()
Constructor only used in deserialization, do not use otherwise.
AbstractOrderedMapDecorator(OrderedMap map)
Constructor that wraps (not copies).

Method Summary

Object
firstKey()
protected OrderedMap
getOrderedMap()
Gets the map being decorated.
Object
lastKey()
MapIterator
mapIterator()
Obtains a MapIterator over the map.
Object
nextKey(Object key)
OrderedMapIterator
orderedMapIterator()
Object
previousKey(Object key)

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

AbstractOrderedMapDecorator

protected AbstractOrderedMapDecorator()
Constructor only used in deserialization, do not use otherwise.
Since:
Commons Collections 3.1

AbstractOrderedMapDecorator

public AbstractOrderedMapDecorator(OrderedMap map)
Constructor that wraps (not copies).
Parameters:
map - the map to decorate, must not be null

Method Details

firstKey

public Object firstKey()
Specified by:
firstKey in interface OrderedMap

getOrderedMap

protected OrderedMap getOrderedMap()
Gets the map being decorated.
Returns:
the decorated map

lastKey

public Object lastKey()
Specified by:
lastKey in interface OrderedMap

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 IterableMap
Returns:
a map iterator

nextKey

public Object nextKey(Object key)
Specified by:
nextKey in interface OrderedMap

orderedMapIterator

public OrderedMapIterator orderedMapIterator()
Specified by:
orderedMapIterator in interface OrderedMap

previousKey

public Object previousKey(Object key)
Specified by:
previousKey in interface OrderedMap

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