Package com.twelvemonkeys.util.convert
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:
Converter.registerConverter(Class, PropertyConverter)
-
-
Field Summary
-
Fields inherited from class com.twelvemonkeys.util.convert.Converter
converters, sInstance
-
-
Constructor Summary
Constructors Constructor Description ConverterImpl()
Creates a Converter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private PropertyConverter
getConverterForType(java.lang.Class pType)
Gets the registered converter for the given type.java.lang.Object
toObject(java.lang.String pString, java.lang.Class pType, java.lang.String pFormat)
Converts the string to an object of the given type, parsing after the given format.java.lang.String
toString(java.lang.Object pBean, java.lang.String pFormat)
Converts the object to a string, usingobject.toString()
-
Methods inherited from class com.twelvemonkeys.util.convert.Converter
getInstance, registerConverter, toObject, toString, unregisterConverter
-
-
-
-
Method Detail
-
getConverterForType
private PropertyConverter getConverterForType(java.lang.Class pType)
Gets the registered converter for the given type.- Parameters:
pType
- the type to convert to- Returns:
- an instance of a
PropertyConverter
ornull
-
toObject
public java.lang.Object toObject(java.lang.String pString, java.lang.Class pType, java.lang.String pFormat) throws ConversionException
Converts the string to an object of the given type, parsing after the given format.- Specified by:
toObject
in interfacePropertyConverter
- Specified by:
toObject
in classConverter
- Parameters:
pString
- the string to convertpType
- the type to convert topFormat
- the vonversion format- Returns:
- the object created from the given string.
- Throws:
ConversionException
- if the string cannot be converted for any reason.
-
toString
public java.lang.String toString(java.lang.Object pBean, java.lang.String pFormat) throws ConversionException
Converts the object to a string, usingobject.toString()
- Specified by:
toString
in interfacePropertyConverter
- Specified by:
toString
in classConverter
- Parameters:
pBean
- the object to convertpFormat
- 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.
-
-