org.ujac.util
Class DefaultTypeConverter

java.lang.Object
  extended by org.ujac.util.DefaultTypeConverter
All Implemented Interfaces:
TypeConverter

public class DefaultTypeConverter
extends Object
implements TypeConverter

Name: DefaultTypeConverter
Description: The default type converter implementation.

Author:
lauerc

Constructor Summary
DefaultTypeConverter()
          Constructs a DefaultTypeConverter instance with no specific attributes.
DefaultTypeConverter(FormatHelper formatHelper)
          Constructs a DefaultTypeConverter instance with specific attributes.
 
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.
protected  void registerDataTypes()
          Registers the data types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTypeConverter

public DefaultTypeConverter()
Constructs a DefaultTypeConverter instance with no specific attributes.


DefaultTypeConverter

public DefaultTypeConverter(FormatHelper formatHelper)
Constructs a DefaultTypeConverter instance with specific attributes.

Parameters:
formatHelper - The format helper to use.
Method Detail

registerDataTypes

protected void registerDataTypes()
Registers the data types.


registerDataType

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

Specified by:
registerDataType in interface TypeConverter
Parameters:
clazz - The type to handle.
typeHandler - The type handler.

getDataType

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

Specified by:
getDataType in interface TypeConverter
Parameters:
clazz - The type to get the handler for.
Returns:
The registered type handler.

getDataType

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

Specified by:
getDataType in interface TypeConverter
Parameters:
typeId - The ID of the type to get the handler for.
Returns:
The registered type handler.

convertObject

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

Specified by:
convertObject in interface TypeConverter
Parameters:
clazz - The type class.
value - The value to convert.
Returns:
The according instance.
Throws:
TypeConverterException - In case the conversion failed.

convertObject

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

Specified by:
convertObject in interface TypeConverter
Parameters:
typeId - The type ID.
value - The value to convert.
Returns:
The according instance.
Throws:
TypeConverterException - In case the conversion failed.

formatValue

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

Specified by:
formatValue in interface TypeConverter
Parameters:
clazz - The type class.
value - The value to convert.
Returns:
The formatted value.
Throws:
TypeConverterException - In case the conversion failed.

formatValue

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

Specified by:
formatValue in interface TypeConverter
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.