Package com.twelvemonkeys.util.convert
Class ConverterImpl
java.lang.Object
com.twelvemonkeys.util.convert.Converter
com.twelvemonkeys.util.convert.ConverterImpl
- All Implemented Interfaces:
PropertyConverter
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:
-
Field Summary
Fields inherited from class com.twelvemonkeys.util.convert.Converter
converters, sInstance
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate PropertyConverter
getConverterForType
(Class pType) Gets the registered converter for the given type.Converts the string to an object of the given type, parsing after the given format.Converts the object to a string, usingobject.toString()
Methods inherited from class com.twelvemonkeys.util.convert.Converter
getInstance, registerConverter, toObject, toString, unregisterConverter
-
Constructor Details
-
ConverterImpl
ConverterImpl()Creates a Converter.
-
-
Method Details
-
getConverterForType
Gets the registered converter for the given type.- Parameters:
pType
- the type to convert to- Returns:
- an instance of a
PropertyConverter
ornull
-
toObject
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
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.
-