|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.text.Format
java.text.NumberFormat
org.apache.commons.math.fraction.AbstractFormat
public abstract class AbstractFormat
Common part shared by both FractionFormat
and BigFractionFormat
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.text.NumberFormat |
---|
NumberFormat.Field |
Field Summary | |
---|---|
protected NumberFormat |
denominatorFormat
The format used for the denominator. |
protected NumberFormat |
numeratorFormat
The format used for the numerator. |
Fields inherited from class java.text.NumberFormat |
---|
FRACTION_FIELD, INTEGER_FIELD |
Constructor Summary | |
---|---|
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 numeratorFormat,
NumberFormat denominatorFormat)
Create an improper formatting instance with a custom number format for the numerator and a custom number format for the denominator. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.text.Format |
---|
format, formatToCharacterIterator, parseObject |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected NumberFormat denominatorFormat
protected NumberFormat numeratorFormat
Constructor Detail |
---|
protected AbstractFormat()
protected AbstractFormat(NumberFormat format)
format
- the custom format for both the numerator and denominator.protected AbstractFormat(NumberFormat numeratorFormat, NumberFormat denominatorFormat)
numeratorFormat
- the custom format for the numerator.denominatorFormat
- the custom format for the denominator.Method Detail |
---|
protected static 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 NumberFormat getDefaultNumberFormat(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 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/ouput 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/ouput 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 field
NumberFormat.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 field
NumberFormat.format(Object, StringBuffer, FieldPosition)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |