Class ConverterImpl

java.lang.Object
com.twelvemonkeys.util.convert.Converter
com.twelvemonkeys.util.convert.ConverterImpl
All Implemented Interfaces:
PropertyConverter

class ConverterImpl extends Converter
The converter (singleton). Converts strings to objects and back. This is the entrypoint to the converter framework.
Version:
$Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/util/convert/ConverterImpl.java#1 $
See Also:
  • Constructor Details

    • ConverterImpl

      ConverterImpl()
      Creates a Converter.
  • Method Details

    • getConverterForType

      private PropertyConverter getConverterForType(Class pType)
      Gets the registered converter for the given type.
      Parameters:
      pType - the type to convert to
      Returns:
      an instance of a PropertyConverter or null
    • toObject

      public Object toObject(String pString, Class pType, String pFormat) throws ConversionException
      Converts the string to an object of the given type, parsing after the given format.
      Specified by:
      toObject in interface PropertyConverter
      Specified by:
      toObject in class Converter
      Parameters:
      pString - the string to convert
      pType - the type to convert to
      pFormat - the vonversion format
      Returns:
      the object created from the given string.
      Throws:
      ConversionException - if the string cannot be converted for any reason.
    • toString

      public String toString(Object pBean, String pFormat) throws ConversionException
      Converts the object to a string, using object.toString()
      Specified by:
      toString in interface PropertyConverter
      Specified by:
      toString in class Converter
      Parameters:
      pBean - the object to convert
      pFormat - the conversion format
      Returns:
      the string representation of the object, on the correct format.
      Throws:
      ConversionException - if the object cannot be converted to a string for any reason.