public abstract class

AbstractOrderedBidiMapDecorator

extends AbstractBidiMapDecorator
implements OrderedBidiMap
java.lang.Object
   ↳ org.apache.commons.collections.map.AbstractMapDecorator
     ↳ org.apache.commons.collections.bidimap.AbstractBidiMapDecorator
       ↳ org.apache.commons.collections.bidimap.AbstractOrderedBidiMapDecorator
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Provides a base decorator that enables additional functionality to be added to an OrderedBidiMap 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 inverse 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
Protected Constructors
AbstractOrderedBidiMapDecorator(OrderedBidiMap map)
Constructor that wraps (not copies).
Public Methods
Object firstKey()
Gets the first key currently in this map.
OrderedBidiMap inverseOrderedBidiMap()
Gets a view of this map where the keys and values are reversed.
Object lastKey()
Gets the last key currently in this 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
OrderedBidiMap getOrderedBidiMap()
Gets the map being decorated.
[Expand]
Inherited Methods
From class org.apache.commons.collections.bidimap.AbstractBidiMapDecorator
From class org.apache.commons.collections.map.AbstractMapDecorator
From class java.lang.Object
From interface java.util.Map
From interface org.apache.commons.collections.BidiMap
From interface org.apache.commons.collections.IterableMap
From interface org.apache.commons.collections.OrderedBidiMap
From interface org.apache.commons.collections.OrderedMap

Protected Constructors

protected AbstractOrderedBidiMapDecorator (OrderedBidiMap map)

Constructor that wraps (not copies).

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

Public Methods

public Object firstKey ()

Gets the first key currently in this map.

Returns
  • the first key currently in this map

public OrderedBidiMap inverseOrderedBidiMap ()

Gets a view of this map where the keys and values are reversed.

Changes to one map will be visible in the other and vice versa. This enables both directions of the map to be accessed equally.

Implementations should seek to avoid creating a new object every time this method is called. See AbstractMap.values() etc. Calling this method on the inverse map should return the original.

Returns
  • an inverted bidirectional map

public Object lastKey ()

Gets the last key currently in this map.

Returns
  • the last key currently in this map

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 OrderedBidiMap getOrderedBidiMap ()

Gets the map being decorated.

Returns
  • the decorated map