public abstract class

AbstractOrderedMapDecorator

extends AbstractMapDecorator
implements OrderedMap
java.lang.Object
   ↳ org.apache.commons.collections.map.AbstractMapDecorator
     ↳ org.apache.commons.collections.map.AbstractOrderedMapDecorator
Known Direct Subclasses

Class Overview

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.

Summary

[Expand]
Inherited Fields
From class org.apache.commons.collections.map.AbstractMapDecorator
Public Constructors
AbstractOrderedMapDecorator(OrderedMap map)
Constructor that wraps (not copies).
Protected Constructors
AbstractOrderedMapDecorator()
Constructor only used in deserialization, do not use otherwise.
Public Methods
Object firstKey()
Gets the first key currently in this map.
Object lastKey()
Gets the last key currently in this map.
MapIterator mapIterator()
Obtains a MapIterator over the map.
Object nextKey(Object key)
Gets the next key after the one specified.
OrderedMapIterator orderedMapIterator()
Obtains an OrderedMapIterator over the map.
Object previousKey(Object key)
Gets the previous key before the one specified.
Protected Methods
OrderedMap getOrderedMap()
Gets the map being decorated.
[Expand]
Inherited Methods
From class org.apache.commons.collections.map.AbstractMapDecorator
From class java.lang.Object
From interface java.util.Map
From interface org.apache.commons.collections.IterableMap
From interface org.apache.commons.collections.OrderedMap

Public Constructors

public AbstractOrderedMapDecorator (OrderedMap map)

Constructor that wraps (not copies).

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

Protected Constructors

protected AbstractOrderedMapDecorator ()

Constructor only used in deserialization, do not use otherwise.

Public Methods

public Object firstKey ()

Gets the first key currently in this map.

Returns
  • the first key currently in this map

public Object lastKey ()

Gets the last key currently in this map.

Returns
  • the last key currently in this map

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");
 }
 

Returns
  • a map iterator

public Object nextKey (Object key)

Gets the next key after the one specified.

Parameters
key the key to search for next from
Returns
  • the next key, null if no match or at end

public OrderedMapIterator orderedMapIterator ()

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();
 }
 

Returns
  • a map iterator

public Object previousKey (Object key)

Gets the previous key before the one specified.

Parameters
key the key to search for previous from
Returns
  • the previous key, null if no match or at start

Protected Methods

protected OrderedMap getOrderedMap ()

Gets the map being decorated.

Returns
  • the decorated map