public abstract class NumberTypeHandler extends LocaleSupport implements ConfigurableTypeHandler, Cloneable
DecimalFormatlocaleFORMAT_SETTINGNIL| Constructor and Description |
|---|
NumberTypeHandler() |
| Modifier and Type | Method and Description |
|---|---|
protected DecimalFormat |
createDecimalFormat()
Creates a DecimalFormat for parsing and formatting the number value.
|
protected abstract Number |
createNumber(BigDecimal bg)
Parses a Number from a BigDecimal.
|
protected abstract Number |
createNumber(String text)
Parses a Number from text.
|
String |
format(Object value)
Formats a Number by calling toString().
|
String |
getPattern()
Returns the DecimalFormat pattern to use to parse and format the
number value.
|
TypeHandler |
newInstance(Properties properties)
Creates a customized instance of this type handler.
|
Number |
parse(String text)
Parses a Number from the given text.
|
void |
setPattern(String pattern)
Sets the DeimcalFormat pattern to use to parse and format the number
value.
|
getLocale, setLocaleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetTypepublic final Number parse(String text) throws TypeConversionException
parse in interface TypeHandlertext - the text to parseTypeConversionException - if the text is not a valid numberprotected abstract Number createNumber(String text) throws NumberFormatException
text - the text to convert to a NumberNumberFormatException - if the text is not a valid numberprotected abstract Number createNumber(BigDecimal bg) throws ArithmeticException
bg - the BigDecimal version of the numberArithmeticException - if the BigDecimal cannot be converted
to the Number type supported by this handlerpublic TypeHandler newInstance(Properties properties) throws IllegalArgumentException
ConfigurableTypeHandlernewInstance in interface ConfigurableTypeHandlerproperties - the properties for customizing the instanceIllegalArgumentException - if a property value is invalidprotected DecimalFormat createDecimalFormat()
public String format(Object value)
format in interface TypeHandlervalue - the number to formatpublic String getPattern()
public void setPattern(String pattern)
pattern - the DecimalFormat pattern