org.ujac.util
Interface TypeConverter

All Known Implementing Classes:
DefaultTypeConverter

public interface TypeConverter

Name: TypeConverter
Description: An interface for type converters.

Author:
lauerc

Method Summary
 Object convertObject(Class clazz, Object value)
          Converts the given value into an instance of this type.
 Object convertObject(int typeId, Object value)
          Converts the given value into an instance of this type.
 String formatValue(Class clazz, Object value)
          FormatsConverts the given value into an instance of this type.
 String formatValue(int typeId, Object value)
          FormatsConverts the given value into an instance of this type.
 DataType getDataType(Class clazz)
          Gets the data type for the given class.
 DataType getDataType(int typeId)
          Gets the data type for the given type ID.
 void registerDataType(Class clazz, DataType typeHandler)
          Registers the data type.
 

Method Detail

registerDataType

void registerDataType(Class clazz,
                      DataType typeHandler)
Registers the data type.

Parameters:
clazz - The type to handle.
typeHandler - The type handler.

getDataType

DataType getDataType(Class clazz)
Gets the data type for the given class.

Parameters:
clazz - The type to handle.
Returns:
The registered type handler.

getDataType

DataType getDataType(int typeId)
Gets the data type for the given type ID.

Parameters:
typeId - The ID of the type to get the handler for.
Returns:
The registered type handler.

convertObject

Object convertObject(Class clazz,
                     Object value)
                     throws TypeConverterException
Converts the given value into an instance of this type.

Parameters:
clazz - The class value.
value - The value to convert.
Returns:
The according instance.
Throws:
TypeConverterException - In case the conversion failed.

convertObject

Object convertObject(int typeId,
                     Object value)
                     throws TypeConverterException
Converts the given value into an instance of this type.

Parameters:
typeId - The type ID.
value - The value to convert.
Returns:
The according instance.
Throws:
TypeConverterException - In case the conversion failed.

formatValue

String formatValue(Class clazz,
                   Object value)
                   throws TypeConverterException
FormatsConverts the given value into an instance of this type.

Parameters:
clazz - The class value.
value - The value to convert.
Returns:
The formatted value.
Throws:
TypeConverterException - In case the conversion failed.

formatValue

String formatValue(int typeId,
                   Object value)
                   throws TypeConverterException
FormatsConverts the given value into an instance of this type.

Parameters:
typeId - The type ID.
value - The value to convert.
Returns:
The formatted value.
Throws:
TypeConverterException - In case the conversion failed.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.