net.sf.jec
Class ObjectConverter

java.lang.Object
  extended bynet.sf.jec.ObjectConverter

public class ObjectConverter
extends java.lang.Object

ObjectsConverter instances provide methods for common object to object conversions and object to basic type conversions. It handles special conversions as currencies, dates, and percents.

Author:
mballesteros

Constructor Summary
ObjectConverter()
           
 
Method Summary
static java.lang.Object convert(java.lang.Object value, java.lang.Class targetClass)
           
static java.lang.Object normalize(java.lang.Object number)
          Normalizes a Number: its minimum values equal 'null' objects.
static boolean toBoolean(java.lang.Object obj)
          Converts an object into a boolean basic type.
static double toDouble(java.lang.Number obj)
          Converts a number into a double basic type
static double toDouble(java.lang.Object obj)
          Converts an Object into a double basic type
static int toInt(java.lang.Number obj)
          Converts a number into an int basic type
static int toInt(java.lang.Object obj)
          Converts an Object into an int basic type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectConverter

public ObjectConverter()
Method Detail

convert

public static java.lang.Object convert(java.lang.Object value,
                                       java.lang.Class targetClass)
                                throws ConversionException
Throws:
ConversionException

toInt

public static int toInt(java.lang.Number obj)
                 throws ConversionException
Converts a number into an int basic type

Parameters:
obj - The Number to convert
Throws:
ConversionException

toInt

public static int toInt(java.lang.Object obj)
                 throws ConversionException
Converts an Object into an int basic type

Parameters:
obj - The Object to convert
Throws:
ConversionException

toDouble

public static double toDouble(java.lang.Number obj)
                       throws ConversionException
Converts a number into a double basic type

Parameters:
obj - The Number to convert
Throws:
ConversionException

toDouble

public static double toDouble(java.lang.Object obj)
                       throws ConversionException
Converts an Object into a double basic type

Parameters:
obj - The Object to convert
Throws:
ConversionException

normalize

public static java.lang.Object normalize(java.lang.Object number)
Normalizes a Number: its minimum values equal 'null' objects. If the given object is not a Number it will be left

Parameters:
number - The Number to normalize
Returns:
The normalized value

toBoolean

public static boolean toBoolean(java.lang.Object obj)
                         throws ConversionException
Converts an object into a boolean basic type. java.lang.Boolean are converted into its values. Objects which toString() method equals (ignoring case) "true" or "false" are also succesfully converted. Other objects are rejected and a ConversionException is thrown.

Returns:
boolean The converted value, when possible.
Throws:
ConversionException


Copyright © 2003 SourceForge. All Rights Reserved.