biz.hammurapi.convert
Class ConvertingService

java.lang.Object
  extended by biz.hammurapi.convert.ConvertingService

public class ConvertingService
extends java.lang.Object


Field Summary
static Converter CONVERTER
          Converter which delegates to convert() method.
 
Constructor Summary
ConvertingService()
           
 
Method Summary
static java.lang.Object convert(java.lang.Object source, java.lang.Class targetType)
          Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources.
static java.lang.Object convert(java.lang.Object source, java.lang.Class targetType, java.lang.ClassLoader classLoader)
          Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources.
static java.lang.Object convert(java.lang.Object source, java.lang.Class targetType, Context context)
          Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources.
static java.lang.Object convert(java.lang.Object source, java.lang.Class targetType, Context context, java.lang.ClassLoader classLoader)
          Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources.
static ConverterClosure getConverter(java.lang.Class sourceType, java.lang.Class targetType)
          Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources.
static ConverterClosure getConverter(java.lang.Class sourceType, java.lang.Class targetType, java.lang.ClassLoader classLoader)
          Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources.
static ConverterClosure getConverter(java.lang.Class sourceType, java.lang.Class targetType, Context context)
          Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources.
static ConverterClosure getConverter(java.lang.Class sourceType, java.lang.Class targetType, Context context, java.lang.ClassLoader classLoader)
          Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERTER

public static final Converter CONVERTER
Converter which delegates to convert() method.

Constructor Detail

ConvertingService

public ConvertingService()
Method Detail

convert

public static java.lang.Object convert(java.lang.Object source,
                                       java.lang.Class targetType)
                                throws ConversionException
Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources. If no converter is found, this method performs converter discovery through constructors if target type is a class and through duck conversion if target type is an interface. Invocation of this method is equivalent to invocation of convert(source, targetType, false)

Parameters:
source - Source object.
targetType - Target type.
Returns:
Source object converted to target type or null if no converter is available for source/targetType combination
Throws:
ConversionException

convert

public static java.lang.Object convert(java.lang.Object source,
                                       java.lang.Class targetType,
                                       Context context)
                                throws ConversionException
Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources. If no converter is found, this method performs converter discovery through constructors if target type is a class and through duck conversion if target type is an interface. Invocation of this method is equivalent to invocation of convert(source, targetType, false)

Parameters:
source - Source object.
targetType - Target type.
context - Conversion context.
Returns:
Source object converted to target type or null if no converter is available for source/targetType combination
Throws:
ConversionException

convert

public static java.lang.Object convert(java.lang.Object source,
                                       java.lang.Class targetType,
                                       java.lang.ClassLoader classLoader)
                                throws ConversionException
Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources. If no converter is found, this method performs converter discovery through constructors if target type is a class and through duck conversion if target type is an interface. Invocation of this method is equivalent to invocation of convert(source, targetType, false)

Parameters:
source - Source object.
targetType - Target type.
classLoader - Class loader, source of converters.
Returns:
Source object converted to target type or null if no converter is available for source/targetType combination
Throws:
ConversionException

convert

public static java.lang.Object convert(java.lang.Object source,
                                       java.lang.Class targetType,
                                       Context context,
                                       java.lang.ClassLoader classLoader)
                                throws ConversionException
Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources. If no converter is found, this method performs converter discovery through constructors if target type is a class and through duck conversion if target type is an interface.

Parameters:
source - Source object.
targetType - Target type.
context - Conversion context.
classLoader - Class loader.
Returns:
Source object converted to target type or null if no converter is available for source/targetType combination
Throws:
ConversionException

getConverter

public static ConverterClosure getConverter(java.lang.Class sourceType,
                                            java.lang.Class targetType)
Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources. If no converter is found, this method performs converter discovery through constructors if target type is a class and through duck conversion if target type is an interface.

Parameters:
sourceType - Source type.
targetType - Target type.
Returns:
Converter from source type to target type, or null if such converter is not available.
Throws:
ConversionException

getConverter

public static ConverterClosure getConverter(java.lang.Class sourceType,
                                            java.lang.Class targetType,
                                            java.lang.ClassLoader classLoader)
Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources. If no converter is found, this method performs converter discovery through constructors if target type is a class and through duck conversion if target type is an interface.

Parameters:
sourceType - Source type.
targetType - Target type.
classLoader - Class loader to retrieve converters from.
Returns:
Converter from source type to target type, or null if such converter is not available.
Throws:
ConversionException

getConverter

public static ConverterClosure getConverter(java.lang.Class sourceType,
                                            java.lang.Class targetType,
                                            Context context)
Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources. If no converter is found, this method performs converter discovery through constructors if target type is a class and through duck conversion if target type is an interface.

Parameters:
sourceType - Source type.
targetType - Target type.
context - Conversion context.
Returns:
Converter from source type to target type, or null if such converter is not available.
Throws:
ConversionException

getConverter

public static ConverterClosure getConverter(java.lang.Class sourceType,
                                            java.lang.Class targetType,
                                            Context context,
                                            java.lang.ClassLoader classLoader)
Converts source to target type using converters loaded from META-INF/config/biz.hammurapi.convert.Converter resources. If no converter is found, this method performs converter discovery through constructors if target type is a class and through duck conversion if target type is an interface.

Parameters:
sourceType - Source type.
targetType - Target type.
context - Conversion context.
classLoader - Class loader to retrieve converters from.
Returns:
Converter from source type to target type, or null if such converter is not available.
Throws:
ConversionException


Copyright © 2003 Hammurapi Group. All Rights Reserved.