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

Default implementation of a type converter registry used for type converters in Camel.

Version:
$Revision: 47150 $

Nested Class Summary
protected static class DefaultTypeConverter.TypeMapping
          Represents a mapping from one type (which can be null) to another
 
Constructor Summary
DefaultTypeConverter(Injector injector)
           
 
Method Summary
 void addFallbackConverter(TypeConverter converter)
           
 void addTypeConverter(Class toType, Class fromType, TypeConverter typeConverter)
          Allows a new type converter to be registered
protected  void checkLoaded()
          Checks if the registry is loaded and if not lazily load it
<T> T
convertTo(Class<T> type, Exchange exchange, Object value)
          Converts the value to the specified type in the context of an exchange

Used when conversion requires extra information from the current exchange (such as encoding).

<T> T
convertTo(Class<T> type, 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)
           
protected  void loadFallbackTypeConverters()
           
 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(Injector injector)
Method Detail

convertTo

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

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

convertTo

public <T> T convertTo(Class<T> type,
                       Exchange exchange,
                       Object value)
Description copied from interface: TypeConverter
Converts the value to the specified type in the context of an exchange

Used when conversion requires extra information from the current exchange (such as encoding).

Specified by:
convertTo in interface TypeConverter
Parameters:
type - the requested type
exchange - the current exchange
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 registered

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

addFallbackConverter

public void addFallbackConverter(TypeConverter converter)

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


loadFallbackTypeConverters

protected void loadFallbackTypeConverters()
                                   throws IOException,
                                          ClassNotFoundException
Throws:
IOException
ClassNotFoundException


Copyright © 2008 IONA Open Source Community. All Rights Reserved.