org.apache.camel.impl.converter
Class DefaultTypeConverter

java.lang.Object
  extended by org.apache.camel.impl.converter.DefaultTypeConverter
All Implemented Interfaces:
TypeConverterRegistry, TypeConverter

public class DefaultTypeConverter
extends Object
implements TypeConverter, TypeConverterRegistry

Version:
$Revision: 546882 $

Nested Class Summary
protected static class DefaultTypeConverter.TypeMapping
          Represents a mapping from one type (which can be null) to another
 
Constructor Summary
DefaultTypeConverter()
           
DefaultTypeConverter(Injector injector)
           
 
Method Summary
 void addTypeConverter(Class toType, Class fromType, TypeConverter typeConverter)
          Allows a new type converter to be bregistered
protected  void checkLoaded()
          Checks if the registry is loaded and if not lazily load it
<T> T
convertTo(Class<T> toType, Object value)
          Converts the value to the specified type
protected  TypeConverter findTypeConverter(Class toType, Class fromType, Object value)
          Tries to auto-discover any available type converters
 Injector getInjector()
           
protected
<T> TypeConverter
getOrFindTypeConverter(Class toType, Object value)
           
 TypeConverter getTypeConverter(Class toType, Class fromType)
           
 void setInjector(Injector injector)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTypeConverter

public DefaultTypeConverter()

DefaultTypeConverter

public DefaultTypeConverter(Injector injector)
Method Detail

convertTo

public <T> T convertTo(Class<T> toType,
                       Object value)
Description copied from interface: TypeConverter
Converts the value to the specified type

Specified by:
convertTo in interface TypeConverter
Parameters:
toType - the requested type
value - the value to be converted
Returns:
the converted value or null if it can not be converted

addTypeConverter

public void addTypeConverter(Class toType,
                             Class fromType,
                             TypeConverter typeConverter)
Description copied from interface: TypeConverterRegistry
Allows a new type converter to be bregistered

Specified by:
addTypeConverter in interface TypeConverterRegistry
Parameters:
toType - the type to convert to
fromType - the type to convert from
typeConverter - the type converter to use

getTypeConverter

public TypeConverter getTypeConverter(Class toType,
                                      Class fromType)

getInjector

public Injector getInjector()
Specified by:
getInjector in interface TypeConverterRegistry

setInjector

public void setInjector(Injector injector)

getOrFindTypeConverter

protected <T> TypeConverter getOrFindTypeConverter(Class toType,
                                                   Object value)

findTypeConverter

protected TypeConverter findTypeConverter(Class toType,
                                          Class fromType,
                                          Object value)
Tries to auto-discover any available type converters


checkLoaded

protected void checkLoaded()
Checks if the registry is loaded and if not lazily load it



Copyright © 2007 Apache Software Foundation. All Rights Reserved.