Top Description Inners Fields Constructors Methods
org.apache.commons.collections4.map

public abstract Class AbstractSortedMapDecorator<K, V>

extends AbstractMapDecorator<K, V>
implements IterableSortedMap<K, V>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.IterableSortedMap, org.apache.commons.collections4.OrderedMap, org.apache.commons.collections4.IterableMap, org.apache.commons.collections4.IterableGet, org.apache.commons.collections4.Get, org.apache.commons.collections4.Put, java.util.Map, java.util.SortedMap, java.util.SequencedMap
Known Direct Subclasses
org.apache.commons.collections4.map.FixedSizeSortedMap, org.apache.commons.collections4.map.UnmodifiableSortedMap, org.apache.commons.collections4.bidimap.DualTreeBidiMap.ViewMap
Type Parameters
<K>
the type of the keys in the map
<V>
the type of the values in the map
Imports
java.util.Comparator, .Iterator, .ListIterator, .Map, .Set, .SortedMap, org.apache.commons.collections4.IterableSortedMap, .OrderedMapIterator, org.apache.commons.collections4.iterators.ListIteratorWrapper

Provides a base decorator that enables additional functionality to be added to a Map 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.

Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
AbstractSortedMapDecorator.SortedMapIterator<
the key type
K
,
the value type
V
>

OrderedMapIterator implementation.

Field Summary

Inherited from org.apache.commons.collections4.map.AbstractMapDecorator:
map

Constructor Summary

AccessConstructor and Description
protected
AbstractSortedMapDecorator()

Constructor only used in deserialization, do not use otherwise.

public
AbstractSortedMapDecorator(final SortedMap<K, V>
the map to decorate, must not be null
map
)

Constructor that wraps (not copies).

Method Summary

Modifier and TypeMethod and Description
public Comparator<? super K>
comparator()

Implements java.util.SortedMap.comparator.

Returns the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys.
protected SortedMap<K, V>

Returns:

the decorated map
decorated
()

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.decorated.

Gets the map being decorated.
public K
firstKey()

Implements java.util.SortedMap.firstKey, org.apache.commons.collections4.OrderedMap.firstKey.

Returns the first (lowest) key currently in this map.
public SortedMap<K, V>
headMap(final K
high endpoint (exclusive) of the keys in the returned map
toKey
)

Implements java.util.SortedMap.headMap.

Returns a view of the portion of this map whose keys are strictly less than toKey.
public K
lastKey()

Implements java.util.SortedMap.lastKey, org.apache.commons.collections4.OrderedMap.lastKey.

Returns the last (highest) key currently in this map.
public OrderedMapIterator<K, V>
public K
nextKey(final K
the key to search for next from
key
)

Implements org.apache.commons.collections4.OrderedMap.nextKey.

Gets the next key after the one specified.
public K
previousKey(final K
the key to search for previous from
key
)

Implements org.apache.commons.collections4.OrderedMap.previousKey.

Gets the previous key before the one specified.
public SortedMap<K, V>
subMap(final K
low endpoint (inclusive) of the keys in the returned map
fromKey
,
final K
high endpoint (exclusive) of the keys in the returned map
toKey
)

Implements java.util.SortedMap.subMap.

Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
public SortedMap<K, V>
tailMap(final K
low endpoint (inclusive) of the keys in the returned map
fromKey
)

Implements java.util.SortedMap.tailMap.

Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
Inherited from org.apache.commons.collections4.map.AbstractMapDecorator:
clearcontainsKeycontainsValueentrySetequalsgethashCodeisEmptykeySetputputAllremovesizetoStringvalues

Constructor Detail

AbstractSortedMapDecoratorback to summary
protected AbstractSortedMapDecorator()

Constructor only used in deserialization, do not use otherwise.

Since
3.1
AbstractSortedMapDecoratorback to summary
public AbstractSortedMapDecorator(final SortedMap<K, V> map)

Constructor that wraps (not copies).

Parameters
map:SortedMap<K, V>

the map to decorate, must not be null

Exceptions
NullPointerException:
if the map is null

Method Detail

comparatorback to summary
public Comparator<? super K> comparator()

Implements java.util.SortedMap.comparator.

Doc from java.util.SortedMap.comparator.

Returns the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys.

Returns:Comparator<? super K>

the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys

Annotations
@Override
decoratedback to summary
protected SortedMap<K, V> decorated()

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.decorated.

Gets the map being decorated.

Returns:SortedMap<K, V>

the decorated map

Annotations
@Override
firstKeyback to summary
public K firstKey()

Implements java.util.SortedMap.firstKey, org.apache.commons.collections4.OrderedMap.firstKey.

Doc from java.util.SortedMap.firstKey.

Returns the first (lowest) key currently in this map.

Returns:K

the first (lowest) key currently in this map

Annotations
@Override
headMapback to summary
public SortedMap<K, V> headMap(final K toKey)

Implements java.util.SortedMap.headMap.

Doc from java.util.SortedMap.headMap.

Returns a view of the portion of this map whose keys are strictly less than toKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.

Parameters
toKey:K

high endpoint (exclusive) of the keys in the returned map

Returns:SortedMap<K, V>

a view of the portion of this map whose keys are strictly less than toKey

Annotations
@Override
lastKeyback to summary
public K lastKey()

Implements java.util.SortedMap.lastKey, org.apache.commons.collections4.OrderedMap.lastKey.

Doc from java.util.SortedMap.lastKey.

Returns the last (highest) key currently in this map.

Returns:K

the last (highest) key currently in this map

Annotations
@Override
mapIteratorback to summary
public OrderedMapIterator<K, V> mapIterator()

Overrides org.apache.commons.collections4.map.AbstractIterableMap.mapIterator.

Implements org.apache.commons.collections4.OrderedMap.mapIterator, org.apache.commons.collections4.IterableGet.mapIterator.

Doc from org.apache.commons.collections4.OrderedMap.mapIterator.

Obtains an OrderedMapIterator over the map.

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

Returns:OrderedMapIterator<K, V>

a map iterator

Annotations
@Override
nextKeyback to summary
public K nextKey(final K key)

Implements org.apache.commons.collections4.OrderedMap.nextKey.

Doc from org.apache.commons.collections4.OrderedMap.nextKey.

Gets the next key after the one specified.

Parameters
key:K

the key to search for next from

Returns:K

the next key, null if no match or at end

Annotations
@Override
previousKeyback to summary
public K previousKey(final K key)

Implements org.apache.commons.collections4.OrderedMap.previousKey.

Doc from org.apache.commons.collections4.OrderedMap.previousKey.

Gets the previous key before the one specified.

Parameters
key:K

the key to search for previous from

Returns:K

the previous key, null if no match or at start

Annotations
@Override
subMapback to summary
public SortedMap<K, V> subMap(final K fromKey, final K toKey)

Implements java.util.SortedMap.subMap.

Doc from java.util.SortedMap.subMap.

Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive. (If fromKey and toKey are equal, the returned map is empty.) The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.

Parameters
fromKey:K

low endpoint (inclusive) of the keys in the returned map

toKey:K

high endpoint (exclusive) of the keys in the returned map

Returns:SortedMap<K, V>

a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive

Annotations
@Override
tailMapback to summary
public SortedMap<K, V> tailMap(final K fromKey)

Implements java.util.SortedMap.tailMap.

Doc from java.util.SortedMap.tailMap.

Returns a view of the portion of this map whose keys are greater than or equal to fromKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.

Parameters
fromKey:K

low endpoint (inclusive) of the keys in the returned map

Returns:SortedMap<K, V>

a view of the portion of this map whose keys are greater than or equal to fromKey

Annotations
@Override
org.apache.commons.collections4.map back to summary

protected Class AbstractSortedMapDecorator.SortedMapIterator<K, V>

extends EntrySetToMapIteratorAdapter<K, V>
implements OrderedMapIterator<K, V>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.OrderedMapIterator, org.apache.commons.collections4.OrderedIterator, java.util.Iterator, org.apache.commons.collections4.MapIterator
Type Parameters
<K>
the key type
<V>
the value type

OrderedMapIterator implementation.

Field Summary

Inherited from org.apache.commons.collections4.map.EntrySetToMapIteratorAdapter:
entryentrySetiterator

Constructor Summary

AccessConstructor and Description
protected
SortedMapIterator(final Set<Map.Entry<K, V>>
the entrySet to iterate
entrySet
)

Create a new AbstractSortedMapDecorator.SortedMapIterator.

Method Summary

Modifier and TypeMethod and Description
public boolean
hasPrevious()

Implements org.apache.commons.collections4.OrderedMapIterator.hasPrevious.

Checks to see if there is a previous entry that can be iterated to.
public K
previous()

Implements org.apache.commons.collections4.OrderedMapIterator.previous.

Gets the previous key from the Map.
public synchronized void
reset()

Overrides org.apache.commons.collections4.map.EntrySetToMapIteratorAdapter.reset.

Implements org.apache.commons.collections4.ResettableIterator.reset.

Resets the iterator back to the position at which the iterator was created.
Inherited from org.apache.commons.collections4.map.EntrySetToMapIteratorAdapter:
currentgetKeygetValuehasNextnextremovesetValue

Constructor Detail

SortedMapIteratorback to summary
protected SortedMapIterator(final Set<Map.Entry<K, V>> entrySet)

Create a new AbstractSortedMapDecorator.SortedMapIterator.

Parameters
entrySet:Set<Map.Entry<K, V>>

the entrySet to iterate

Method Detail

hasPreviousback to summary
public boolean hasPrevious()

Implements org.apache.commons.collections4.OrderedMapIterator.hasPrevious.

Doc from org.apache.commons.collections4.OrderedMapIterator.hasPrevious.

Checks to see if there is a previous entry that can be iterated to.

Returns:boolean

true if the iterator has a previous element

Annotations
@Override
previousback to summary
public K previous()

Implements org.apache.commons.collections4.OrderedMapIterator.previous.

Doc from org.apache.commons.collections4.OrderedMapIterator.previous.

Gets the previous key from the Map.

Returns:K

the previous key in the iteration

Annotations
@Override
resetback to summary
public synchronized void reset()

Overrides org.apache.commons.collections4.map.EntrySetToMapIteratorAdapter.reset.

Implements org.apache.commons.collections4.ResettableIterator.reset.

Doc from org.apache.commons.collections4.map.EntrySetToMapIteratorAdapter.reset.

Resets the iterator back to the position at which the iterator was created.

Annotations
@Override