public abstract class NumberConverter extends java.lang.Object implements ObjectConverter
Modifier and Type | Field and Description |
---|---|
static ConverterContext |
CONTEXT_FRACTION_NUMBER |
Constructor and Description |
---|
NumberConverter()
Creates a number converter with no NumberFormat.
|
NumberConverter(java.text.NumberFormat format)
Creates the number converter with a specified NumberFormat.
|
Modifier and Type | Method and Description |
---|---|
protected java.text.NumberFormat |
getDefaultNumberFormat()
Gets the NumberFormat for Locale.US.
|
protected java.text.NumberFormat |
getNumberFormat()
Gets the NumberFormat.
|
static boolean |
isGroupingUsed()
Gets flag if the grouping is used for the format.
|
protected java.lang.Number |
parseNumber(java.lang.String string)
Parse the string as number.
|
void |
setCurrency(java.util.Currency currency)
Set the currency of this converter.
|
void |
setFractionDigits(int minDigits,
int maxDigits)
Set the fraction digits of this converter.
|
static void |
setGroupingUsed(boolean groupingUsed)
Sets if the grouping will be used for the NumberFormat.
|
void |
setIntegerDigits(int minDigits,
int maxDigits)
Set the integer digits of this converter.
|
void |
setNumberFormat(java.text.NumberFormat numberFormat) |
void |
setRoundingMode(java.math.RoundingMode mode)
Set the rounding mode of this converter.
|
boolean |
supportToString(java.lang.Object object,
ConverterContext context)
If it supports toString method.
|
java.lang.String |
toString(java.lang.Object object,
ConverterContext context)
Converts from object to String based on current locale.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fromString, supportFromString
public static final ConverterContext CONTEXT_FRACTION_NUMBER
public NumberConverter()
public NumberConverter(java.text.NumberFormat format)
format
- the number format.public java.lang.String toString(java.lang.Object object, ConverterContext context)
ObjectConverter
toString
in interface ObjectConverter
object
- object to be convertedcontext
- converter context to be usedpublic boolean supportToString(java.lang.Object object, ConverterContext context)
ObjectConverter
supportToString
in interface ObjectConverter
object
- object to be convertedcontext
- converter context to be usedpublic void setNumberFormat(java.text.NumberFormat numberFormat)
protected java.text.NumberFormat getNumberFormat()
protected java.text.NumberFormat getDefaultNumberFormat()
protected java.lang.Number parseNumber(java.lang.String string)
string
- the stringpublic static boolean isGroupingUsed()
public static void setGroupingUsed(boolean groupingUsed)
groupingUsed
- true or false.public void setFractionDigits(int minDigits, int maxDigits)
minDigits
- minimum fraction digitsmaxDigits
- maximum fraction digitspublic void setCurrency(java.util.Currency currency)
currency
- currencypublic void setIntegerDigits(int minDigits, int maxDigits)
minDigits
- minimum integer digitsmaxDigits
- maximum integer digitspublic void setRoundingMode(java.math.RoundingMode mode)
mode
- rounding mode