org.apache.commons.collections.map
Class TransformedMap

java.lang.Object
  |
  +--org.apache.commons.collections.map.AbstractMapDecorator
        |
        +--org.apache.commons.collections.map.AbstractInputCheckedMapDecorator
              |
              +--org.apache.commons.collections.map.TransformedMap
All Implemented Interfaces:
java.util.Map, java.io.Serializable
Direct Known Subclasses:
TransformedSortedMap

public class TransformedMap
extends org.apache.commons.collections.map.AbstractInputCheckedMapDecorator
implements java.io.Serializable

Decorates another Map 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.

This class is Serializable from Commons Collections 3.1.

Since:
Commons Collections 3.0
Version:
$Revision: 1.11 $ $Date: 2004/06/07 22:14:42 $
Author:
Stephen Colebourne
See Also:
Serialized Form

Method Summary
static java.util.Map decorate(java.util.Map map, Transformer keyTransformer, Transformer valueTransformer)
          Factory method to create a transforming map.
 java.util.Set entrySet()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map mapToCopy)
           
 
Methods inherited from class org.apache.commons.collections.map.AbstractMapDecorator
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, remove, size, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

decorate

public static java.util.Map decorate(java.util.Map map,
                                     Transformer keyTransformer,
                                     Transformer valueTransformer)
Factory method to create a transforming map.

If there are any elements already in the map being decorated, they are NOT transformed.

Parameters:
map - the map to decorate, must not be null
keyTransformer - the transformer to use for key conversion, null means no conversion
valueTransformer - the transformer to use for value conversion, null means no conversion
Throws:
java.lang.IllegalArgumentException - if map is null

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map
Overrides:
put in class AbstractMapDecorator

putAll

public void putAll(java.util.Map mapToCopy)
Specified by:
putAll in interface java.util.Map
Overrides:
putAll in class AbstractMapDecorator

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map
Overrides:
entrySet in class AbstractMapDecorator


Copyright © 2001-2004 The Apache Software Foundation. All Rights Reserved.