public abstract class AbstractFormat
extends java.text.NumberFormat
implements java.io.Serializable
FractionFormat
and BigFractionFormat
.Modifier and Type | Field and Description |
---|---|
protected java.text.NumberFormat |
denominatorFormat
The format used for the denominator.
|
protected java.text.NumberFormat |
numeratorFormat
The format used for the numerator.
|
private static long |
serialVersionUID
Serializable version identifier.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractFormat()
Create an improper formatting instance with the default number format
for the numerator and denominator.
|
protected |
AbstractFormat(java.text.NumberFormat format)
Create an improper formatting instance with a custom number format for
both the numerator and denominator.
|
protected |
AbstractFormat(java.text.NumberFormat numeratorFormat,
java.text.NumberFormat denominatorFormat)
Create an improper formatting instance with a custom number format for
the numerator and a custom number format for the denominator.
|
Modifier and Type | Method and Description |
---|---|
java.lang.StringBuffer |
format(double value,
java.lang.StringBuffer buffer,
java.text.FieldPosition position)
Formats a double value as a fraction and appends the result to a StringBuffer.
|
java.lang.StringBuffer |
format(long value,
java.lang.StringBuffer buffer,
java.text.FieldPosition position)
Formats a long value as a fraction and appends the result to a StringBuffer.
|
protected static java.text.NumberFormat |
getDefaultNumberFormat()
Create a default number format.
|
protected static java.text.NumberFormat |
getDefaultNumberFormat(java.util.Locale locale)
Create a default number format.
|
java.text.NumberFormat |
getDenominatorFormat()
Access the denominator format.
|
java.text.NumberFormat |
getNumeratorFormat()
Access the numerator format.
|
protected static void |
parseAndIgnoreWhitespace(java.lang.String source,
java.text.ParsePosition pos)
Parses
source until a non-whitespace character is found. |
protected static char |
parseNextCharacter(java.lang.String source,
java.text.ParsePosition pos)
Parses
source until a non-whitespace character is found. |
void |
setDenominatorFormat(java.text.NumberFormat format)
Modify the denominator format.
|
void |
setNumeratorFormat(java.text.NumberFormat format)
Modify the numerator format.
|
clone, equals, format, format, format, getAvailableLocales, getCurrency, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, getRoundingMode, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parse, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly, setRoundingMode
private static final long serialVersionUID
protected java.text.NumberFormat denominatorFormat
protected java.text.NumberFormat numeratorFormat
protected AbstractFormat()
protected AbstractFormat(java.text.NumberFormat format)
format
- the custom format for both the numerator and denominator.protected AbstractFormat(java.text.NumberFormat numeratorFormat, java.text.NumberFormat denominatorFormat)
numeratorFormat
- the custom format for the numerator.denominatorFormat
- the custom format for the denominator.protected static java.text.NumberFormat getDefaultNumberFormat()
NumberFormat.getNumberInstance(java.util.Locale)
with the only
customizing is the maximum number of BigFraction digits, which is set to 0.protected static java.text.NumberFormat getDefaultNumberFormat(java.util.Locale locale)
NumberFormat.getNumberInstance(java.util.Locale)
with the only
customizing is the maximum number of BigFraction digits, which is set to 0.locale
- the specific locale used by the format.public java.text.NumberFormat getDenominatorFormat()
public java.text.NumberFormat getNumeratorFormat()
public void setDenominatorFormat(java.text.NumberFormat format)
format
- the new denominator format value.NullArgumentException
- if format
is null
.public void setNumeratorFormat(java.text.NumberFormat format)
format
- the new numerator format value.NullArgumentException
- if format
is null
.protected static void parseAndIgnoreWhitespace(java.lang.String source, java.text.ParsePosition pos)
source
until a non-whitespace character is found.source
- the string to parsepos
- input/ouput parsing parameter. On output, pos
holds the index of the next non-whitespace character.protected static char parseNextCharacter(java.lang.String source, java.text.ParsePosition pos)
source
until a non-whitespace character is found.source
- the string to parsepos
- input/ouput parsing parameter.public java.lang.StringBuffer format(double value, java.lang.StringBuffer buffer, java.text.FieldPosition position)
format
in class java.text.NumberFormat
value
- the double value to formatbuffer
- StringBuffer to append toposition
- On input: an alignment field, if desired. On output: the
offsets of the alignment fieldNumberFormat.format(Object, StringBuffer, FieldPosition)
public java.lang.StringBuffer format(long value, java.lang.StringBuffer buffer, java.text.FieldPosition position)
format
in class java.text.NumberFormat
value
- the long value to formatbuffer
- StringBuffer to append toposition
- On input: an alignment field, if desired. On output: the
offsets of the alignment fieldNumberFormat.format(Object, StringBuffer, FieldPosition)
Copyright (c) 2003-2013 Apache Software Foundation