T - the data type of this converter.public abstract class AbstractNumberConverter<T extends java.lang.Number> extends DefaultObjectConverter<T>
ObjectConverter abstract implementation for Number. The fromString method is not implemented.| Modifier and Type | Field and Description |
|---|---|
static ConverterContext |
CONTEXT_FIXED_1_DIGIT_FRACTION
A converter context to tell the NumberConverter to use fixed 2 digit fraction.
|
static ConverterContext |
CONTEXT_FIXED_2_DIGIT_FRACTION
A converter context to tell the NumberConverter to use fixed 2 digit fraction.
|
static ConverterContext |
CONTEXT_FIXED_4_DIGIT_FRACTION
A converter context to tell the NumberConverter to use fixed 2 digit fraction.
|
static java.lang.String |
PROPERTY_NUMBER_FORMAT
A property for the converter context.
|
| Constructor and Description |
|---|
AbstractNumberConverter() |
AbstractNumberConverter(java.util.Locale locale) |
AbstractNumberConverter(java.util.Locale locale,
java.lang.String pattern) |
AbstractNumberConverter(java.text.NumberFormat numberFormat) |
AbstractNumberConverter(java.lang.String pattern) |
| Modifier and Type | Method and Description |
|---|---|
protected java.text.NumberFormat |
getNumberFormat()
Returns a
NumberFormat instance to use for formatting and parsing in this AbstractNumberConverter. |
java.lang.Number |
numberFromString(java.lang.String string,
ConverterContext context)
Converts the String to a Number.
|
java.lang.String |
toString(T number,
ConverterContext context)
Converts the value to String.
|
fromString, fromString, getObjectConverterManager, toString, toStringConverterpublic static final ConverterContext CONTEXT_FIXED_1_DIGIT_FRACTION
public static final ConverterContext CONTEXT_FIXED_2_DIGIT_FRACTION
public static final ConverterContext CONTEXT_FIXED_4_DIGIT_FRACTION
public static final java.lang.String PROPERTY_NUMBER_FORMAT
public AbstractNumberConverter()
public AbstractNumberConverter(java.util.Locale locale)
public AbstractNumberConverter(java.lang.String pattern)
public AbstractNumberConverter(java.util.Locale locale,
java.lang.String pattern)
public AbstractNumberConverter(java.text.NumberFormat numberFormat)
protected java.text.NumberFormat getNumberFormat()
NumberFormat instance to use for formatting and parsing in this AbstractNumberConverter.public java.lang.Number numberFromString(java.lang.String string,
ConverterContext context)
PROPERTY_NUMBER_FORMAT if any.
If not there, it will use getNumberFormat() to get the NumberFormat to do the conversion.string - the string to be converted.context - the contextpublic java.lang.String toString(T number, ConverterContext context)
DefaultObjectConvertertoString in interface ObjectConverter<T extends java.lang.Number>toString in class DefaultObjectConverter<T extends java.lang.Number>number - the value to be concerted.context - converter context to be used