org.apache.commons.convert1
Class ConvertRegistry

java.lang.Object
  extended by org.apache.commons.convert1.ConvertRegistry

public class ConvertRegistry
extends Object

Stores Converters under a dual-key system of fromClass to toClass.

Since:
0.1
Version:
$Id: ConvertRegistry.java 155441 2005-02-26 13:19:22Z dirkv $
Author:
Henri Yandell

Constructor Summary
ConvertRegistry()
           
 
Method Summary
 void clear()
          Remove all registered Converters.
 Object convert(Object value, Class toClass)
          Convert the specified value to an object of the specified class (if possible).
 void deregister(Class fromClass, Class toClass)
          Remove any registered Converter for the specified destination Class.
 void fromClassDeregister(Class fromClass)
           
 Converter lookup(Class fromClass, Class toClass)
          Look up and return any registered Converter for the specified destination class; if there is no registered Converter, return null.
 void register(Converter converter, Class fromClass, Class toClass)
          Register a custom Converter for the specified destination Class, replacing any previously registered Converter.
 void toClassDeregister(Class toClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConvertRegistry

public ConvertRegistry()
Method Detail

convert

public Object convert(Object value,
                      Class toClass)
Convert the specified value to an object of the specified class (if possible). Otherwise, return a String representation of the value.

Parameters:
value - Value to be converted (may be null)
clazz - Java class to be converted to
Throws:
ConversionException - if thrown by an underlying Converter

clear

public void clear()
Remove all registered Converters.


deregister

public void deregister(Class fromClass,
                       Class toClass)
Remove any registered Converter for the specified destination Class.

Parameters:
clazz - Class for which to remove a registered Converter

fromClassDeregister

public void fromClassDeregister(Class fromClass)

toClassDeregister

public void toClassDeregister(Class toClass)

lookup

public Converter lookup(Class fromClass,
                        Class toClass)
Look up and return any registered Converter for the specified destination class; if there is no registered Converter, return null.

Parameters:
clazz - Class for which to return a registered Converter

register

public void register(Converter converter,
                     Class fromClass,
                     Class toClass)
Register a custom Converter for the specified destination Class, replacing any previously registered Converter.

Parameters:
converter - Converter to be registered
clazz - Destination class for conversions performed by this Converter


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