public abstract class AbstractFormat extends NumberFormat implements Serializable
FractionFormat
and BigFractionFormat
.NumberFormat.Field
FRACTION_FIELD, INTEGER_FIELD
Modifier | Constructor and Description |
---|---|
protected |
AbstractFormat()
Create an improper formatting instance with the default number format
for the numerator and denominator.
|
protected |
AbstractFormat(NumberFormat format)
Create an improper formatting instance with a custom number format for
both the numerator and denominator.
|
protected |
AbstractFormat(NumberFormat numeratorFormatIn,
NumberFormat denominatorFormatIn)
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 |
---|---|
StringBuffer |
format(double value,
StringBuffer buffer,
FieldPosition position)
Formats a double value as a fraction and appends the result to a StringBuffer.
|
StringBuffer |
format(long value,
StringBuffer buffer,
FieldPosition position)
Formats a long value as a fraction and appends the result to a StringBuffer.
|
protected static NumberFormat |
getDefaultNumberFormat()
Create a default number format.
|
protected static NumberFormat |
getDefaultNumberFormat(Locale locale)
Create a default number format.
|
NumberFormat |
getDenominatorFormat()
Access the denominator format.
|
NumberFormat |
getNumeratorFormat()
Access the numerator format.
|
protected static void |
parseAndIgnoreWhitespace(String source,
ParsePosition pos)
Parses
source until a non-whitespace character is found. |
protected static char |
parseNextCharacter(String source,
ParsePosition pos)
Parses
source until a non-whitespace character is found. |
void |
setDenominatorFormat(NumberFormat format)
Modify the denominator format.
|
void |
setNumeratorFormat(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
format, formatToCharacterIterator, parseObject
protected AbstractFormat()
protected AbstractFormat(NumberFormat format)
format
- the custom format for both the numerator and denominator.protected AbstractFormat(NumberFormat numeratorFormatIn, NumberFormat denominatorFormatIn)
numeratorFormatIn
- the custom format for the numerator.denominatorFormatIn
- the custom format for the denominator.protected static NumberFormat getDefaultNumberFormat()
NumberFormat.getNumberInstance(java.util.Locale)
. The only
customization is the maximum number of BigFraction digits, which is set to 0.protected static NumberFormat getDefaultNumberFormat(Locale locale)
NumberFormat.getNumberInstance(java.util.Locale)
. The only
customization is the maximum number of BigFraction digits, which is set to 0.locale
- the specific locale used by the format.public NumberFormat getDenominatorFormat()
public NumberFormat getNumeratorFormat()
public void setDenominatorFormat(NumberFormat format)
format
- the new denominator format value.NullArgumentException
- if format
is null
.public void setNumeratorFormat(NumberFormat format)
format
- the new numerator format value.NullArgumentException
- if format
is null
.protected static void parseAndIgnoreWhitespace(String source, ParsePosition pos)
source
until a non-whitespace character is found.source
- the string to parsepos
- input/output parsing parameter. On output, pos
holds the index of the next non-whitespace
character.protected static char parseNextCharacter(String source, ParsePosition pos)
source
until a non-whitespace character is found.source
- the string to parsepos
- input/output parsing parameter.public StringBuffer format(double value, StringBuffer buffer, FieldPosition position)
format
in class 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 StringBuffer format(long value, StringBuffer buffer, FieldPosition position)
format
in class 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 © 2019 CNES. All rights reserved.