org.apache.camel
Interface TypeConverter

All Known Implementing Classes:
ArrayTypeConverter, AsyncProcessorTypeConverter, BaseTypeConverterRegistry, DefaultTypeConverter, EnumTypeConverter, FutureTypeConverter, InstanceMethodFallbackTypeConverter, InstanceMethodTypeConverter, LazyLoadingTypeConverter, PropertyEditorTypeConverter, StaticMethodFallbackTypeConverter, StaticMethodTypeConverter, ToStringTypeConverter, TypeConverterSupport

public interface TypeConverter

A pluggable strategy to be able to convert objects to different types such as to and from String, InputStream/OutputStream, Reader/Writer, Document, byte[], ByteBuffer etc

Version:

Method Summary
<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
<T> T
mandatoryConvertTo(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
mandatoryConvertTo(Class<T> type, Object value)
          Converts the value to the specified type
<T> T
tryConvertTo(Class<T> type, Exchange exchange, Object value)
          Tries to convert the value to the specified type in the context of an exchange, returning null if not possible to convert.
<T> T
tryConvertTo(Class<T> type, Object value)
          Tries to convert the value to the specified type, returning null if not possible to convert.
 

Method Detail

convertTo

<T> T convertTo(Class<T> type,
                Object value)
            throws TypeConversionException
Converts the value to the specified type

Parameters:
type - the requested type
value - the value to be converted
Returns:
the converted value, or null if not possible to convert
Throws:
TypeConversionException - is thrown if error during type conversion

convertTo

<T> T convertTo(Class<T> type,
                Exchange exchange,
                Object value)
            throws TypeConversionException
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).

Parameters:
type - the requested type
exchange - the current exchange
value - the value to be converted
Returns:
the converted value, or null if not possible to convert
Throws:
TypeConversionException - is thrown if error during type conversion

mandatoryConvertTo

<T> T mandatoryConvertTo(Class<T> type,
                         Object value)
                     throws TypeConversionException,
                            NoTypeConversionAvailableException
Converts the value to the specified type

Parameters:
type - the requested type
value - the value to be converted
Returns:
the converted value, is never null
Throws:
TypeConversionException - is thrown if error during type conversion
NoTypeConversionAvailableException} - if no type converters exists to convert to the given type
NoTypeConversionAvailableException

mandatoryConvertTo

<T> T mandatoryConvertTo(Class<T> type,
                         Exchange exchange,
                         Object value)
                     throws TypeConversionException,
                            NoTypeConversionAvailableException
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).

Parameters:
type - the requested type
exchange - the current exchange
value - the value to be converted
Returns:
the converted value, is never null
Throws:
TypeConversionException - is thrown if error during type conversion
NoTypeConversionAvailableException} - if no type converters exists to convert to the given type
NoTypeConversionAvailableException

tryConvertTo

<T> T tryConvertTo(Class<T> type,
                   Object value)
Tries to convert the value to the specified type, returning null if not possible to convert.

This method will not throw an exception if an exception occurred during conversion.

Parameters:
type - the requested type
value - the value to be converted
Returns:
the converted value, or null if not possible to convert

tryConvertTo

<T> T tryConvertTo(Class<T> type,
                   Exchange exchange,
                   Object value)
Tries to convert the value to the specified type in the context of an exchange, returning null if not possible to convert.

This method will not throw an exception if an exception occurred during conversion. 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).

Parameters:
type - the requested type
exchange - the current exchange
value - the value to be converted
Returns:
the converted value, or null if not possible to convert


Apache CAMEL