Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.math.util
Class TransformerMap

    java.lang.Object
      org.apache.commons.math.util.TransformerMap

All Implemented Interfaces:
  NumberTransformer, Serializable

public class TransformerMap
extends Object
implements NumberTransformer, Serializable

This TansformerMap automates the transformation of of mixed object types. It provides a means to set NumberTransformers that will be selected based on the Class of the object handed to the Maps `double transform(Object o)` method.

Version:
  $Revision: 1.15 $ $Date: 2004/06/23 16:26:15 $
See Also:
  Serialized Form

Field Summary
`(package private) static long` | `serialVersionUID` Serializable version identifier

Constructor Summary
`TransformerMap()`

Method Summary
`Set` | `classes()` Returns the Set of Classes used as keys in the map.
`void` | `clear()` Clears all the Class to Transformer mappings.
`boolean` | `containsClass(Class key)` Tests if a Class is present in the TransformerMap.
`boolean` | `containsTransformer(NumberTransformer value)` Tests if a NumberTransformer is present in the TransformerMap.
`NumberTransformer` | `getTransformer(Class key)` Returns the Transformer that is mapped to a class if mapping is not present, this returns null.
`Object` | `putTransformer(Class key, NumberTransformer transformer)` Sets a Class to Transformer Mapping in the Map.
`Object` | `removeTransformer(Class key)` Removes a Class to Transformer Mapping in the Map.
`double` | `transform(Object o)` Attempts to transform the Object against the map of NumberTransformers.
`Collection` | `transformers()` Returns the Set of NumberTransformers used as values in the map.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### serialVersionUID

    static final long serialVersionUID

  Serializable version identifier

  See Also:
    Constant Field Values

Constructor Detail

### TransformerMap

    public TransformerMap()

Method Detail

### containsClass

    public boolean containsClass(Class key)

  Tests if a Class is present in the TransformerMap.

  Parameters:
    `key` - Class to check
  Returns:
    true|false

### containsTransformer

    public boolean containsTransformer(NumberTransformer value)

  Tests if a NumberTransformer is present in the TransformerMap.

  Parameters:
    `value` - NumberTransformer to check
  Returns:
    true|false

### getTransformer

    public NumberTransformer getTransformer(Class key)

  Returns the Transformer that is mapped to a class if mapping is not present, this returns null.

  Parameters:
    `key` - The Class of the object
  Returns:
    the mapped NumberTransformer or null.

### putTransformer

    public Object putTransformer(Class key,
                                 NumberTransformer transformer)

  Sets a Class to Transformer Mapping in the Map. If the Class is already present, this overwrites that mapping.

  Parameters:
    `key` - The Class
    `transformer` - The NumberTransformer
  Returns:
    the replaced transformer if one is present

### removeTransformer

    public Object removeTransformer(Class key)

  Removes a Class to Transformer Mapping in the Map.

  Parameters:
    `key` - The Class
  Returns:
    the removed transformer if one is present or null if none was present.

### clear

    public void clear()

  Clears all the Class to Transformer mappings.

### classes

    public Set classes()

  Returns the Set of Classes used as keys in the map.

  Returns:
    Set of Classes

### transformers

    public Collection transformers()

  Returns the Set of NumberTransformers used as values in the map.

  Returns:
    Set of NumberTransformers

### transform

    public double transform(Object o)
                     throws MathException

  Attempts to transform the Object against the map of NumberTransformers. Otherwise it returns Double.NaN.

  Specified by:
    `transform` in interface `NumberTransformer`
  Parameters:
    `o` - the Object to be transformed.
  Returns:
    the double value of the Object.
  Throws:
    `MathException` - if the Object can not be transformed into a Double.
  See Also:
    `NumberTransformer.transform(java.lang.Object)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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