org.jbeans.converters
Class NumberTypeConverter

java.lang.Object
  |
  +--org.jbeans.BaseTypeConverter
        |
        +--org.jbeans.converters.NumberTypeConverter
All Implemented Interfaces:
TypeConverter

public class NumberTypeConverter
extends BaseTypeConverter

This class is the main number converter. It is able to convert strings to primitive types or sub-classes of java.lang.Number. Primitive types are handled by conversion to the equivalent wrapper class. In most cases the valueOf method is used on the appropriate wrapper class in order to convert the string value. Since this class sub-classes BaseTypeConverter it is able to convert to and from arrays. See the parent for more information.

Author:
Brian Pontarelli

Constructor Summary
NumberTypeConverter()
          Creates new NumberTypeConverter
 
Method Summary
 Object convertString(String value, Class convertTo)
          Converts the string to the given type.
 
Methods inherited from class org.jbeans.BaseTypeConverter
convert, convertArray, convertArrayToArray, convertStringToArray, convertToArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberTypeConverter

public NumberTypeConverter()
Creates new NumberTypeConverter
Method Detail

convertString

public Object convertString(String value,
                            Class convertTo)
                     throws TypeConversionException
Converts the string to the given type. If the given type is an array type then this method returns the result of calling convertStringToArray. Otherwise, the string is converted to the correct type. If the string passed in is either null, empty or only whitespace, then this method returns null
Overrides:
convertString in class BaseTypeConverter
Parameters:
value - The string value to convert
convertTo - The type to convert the string to. Primitive types and sub-classes of java.lang.Number are handled by this class
Returns:
The converted object
Throws:
TypeConversionException - If there was an error converting such as an NumberFormatException or something similar