SortedMap to transform objects that are added.
The Map put methods and Map.Entry setValue method are affected by this class. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.
Note that TransformedSortedMap is not synchronized and is not thread-safe.
If you wish to use this map from multiple threads concurrently, you must use
appropriate synchronization. The simplest approach is to wrap this map
using java.. This class may throw
exceptions when accessed by concurrent threads without synchronization.
This class is Serializable from Commons Collections 3.1.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| protected | TransformedSortedMap(final SortedMap<K, V>
the map to decorate, must not be null map, final Transformer<? super K, ? extends K> the predicate to validate the keys, null means no transformation keyTransformer, final Transformer<? super V, ? extends V> the predicate to validate to values, null means no transformation valueTransformer)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| public Comparator | comparator()
Implements java. null if this map uses the natural ordering of its keys.
|
| public K | firstKey()
Implements java. |
| protected SortedMap | |
| public SortedMap | headMap(final K
high endpoint (exclusive) of the keys in the returned map toKey)Implements java. toKey.
|
| public K | lastKey()
Implements java. |
| public SortedMap | 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. fromKey, inclusive, to toKey, exclusive.
|
| public SortedMap | tailMap(final K
low endpoint (inclusive) of the keys in the returned map fromKey)Implements java. fromKey.
|
| public static < the key type K, the value type V> TransformedSortedMap | Returns: a new transformed sorted mapthe map to decorate, must not be null map, final Transformer<? super K, ? extends K> the transformer to use for key conversion, null means no transformation keyTransformer, final Transformer<? super V, ? extends V> the transformer to use for value conversion, null means no transformation valueTransformer)Factory method to create a transforming sorted map that will transform existing contents of the specified map. |
| public static < the key type K, the value type V> TransformedSortedMap | Returns: a new transformed sorted mapthe map to decorate, must not be null map, final Transformer<? super K, ? extends K> the predicate to validate the keys, null means no transformation keyTransformer, final Transformer<? super V, ? extends V> the predicate to validate to values, null means no transformation valueTransformer)Factory method to create a transforming sorted map. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| TransformedSortedMap | back to summary |
|---|---|
| protected TransformedSortedMap(final SortedMap<K, V> map, final Transformer<? super K, ? extends K> keyTransformer, final Transformer<? super V, ? extends V> valueTransformer) Constructor that wraps (not copies). If there are any elements already in the collection being decorated, they are NOT transformed.
| |
| comparator | back to summary |
|---|---|
| public Comparator Implements java. Doc from java. Returns the comparator used to order the keys in this map, or
| |
| firstKey | back to summary |
|---|---|
| public K firstKey() Implements java. Doc from java. Returns the first (lowest) key currently in this map.
| |
| getSortedMap | back to summary |
|---|---|
| protected SortedMap Gets the map being decorated.
| |
| headMap | back to summary |
|---|---|
| public SortedMap Implements java. Doc from java. Returns a view of the portion of this map whose keys are
strictly less than The returned map will throw an | |
| lastKey | back to summary |
|---|---|
| public K lastKey() Implements java. Doc from java. Returns the last (highest) key currently in this map.
| |
| subMap | back to summary |
|---|---|
| public SortedMap Implements java. Doc from java. Returns a view of the portion of this map whose keys range from
The returned map will throw an | |
| tailMap | back to summary |
|---|---|
| public SortedMap Implements java. Doc from java. Returns a view of the portion of this map whose keys are
greater than or equal to The returned map will throw an | |
| transformedSortedMap | back to summary |
|---|---|
| public static <K, V> TransformedSortedMap Factory method to create a transforming sorted map that will transform existing contents of the specified map.
If there are any elements already in the map being decorated, they
will be transformed by this method.
Contrast this with
| |
| transformingSortedMap | back to summary |
|---|---|
| public static <K, V> TransformedSortedMap Factory method to create a transforming sorted map.
If there are any elements already in the map being decorated, they are NOT transformed.
Contrast this with
| |