Package com.bc.ceres.binding.converters
Class NumberConverter<T extends Number>
- java.lang.Object
-
- com.bc.ceres.binding.converters.NumberConverter<T>
-
- All Implemented Interfaces:
Converter<T>
- Direct Known Subclasses:
ByteConverter
,DoubleConverter
,FloatConverter
,IntegerConverter
,LongConverter
,ShortConverter
public abstract class NumberConverter<T extends Number> extends Object implements Converter<T>
-
-
Constructor Summary
Constructors Constructor Description NumberConverter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
format(T value)
Converts a value of the type returned byConverter.getValueType()
to its plain text representation.abstract Class<? extends T>
getValueType()
Gets the value type.T
parse(String value)
Converts a value from its plain text representation to a Java object instance of the type returned byConverter.getValueType()
.protected abstract T
parseNumber(String value)
-
-
-
Method Detail
-
getValueType
public abstract Class<? extends T> getValueType()
Description copied from interface:Converter
Gets the value type.- Specified by:
getValueType
in interfaceConverter<T extends Number>
- Returns:
- The value type.
-
parse
public T parse(String value) throws ConversionException
Description copied from interface:Converter
Converts a value from its plain text representation to a Java object instance of the type returned byConverter.getValueType()
.- Specified by:
parse
in interfaceConverter<T extends Number>
- Parameters:
value
- The textual representation of the value.- Returns:
- The converted value.
- Throws:
ConversionException
- If the conversion fails.
-
parseNumber
protected abstract T parseNumber(String value) throws NumberFormatException
- Throws:
NumberFormatException
-
format
public String format(T value)
Description copied from interface:Converter
Converts a value of the type returned byConverter.getValueType()
to its plain text representation.
-
-