|
|||||||||
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.math3.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 |
---|
java.text.NumberFormat.Field |
Field Summary | |
---|---|
private java.text.NumberFormat |
denominatorFormat
The format used for the denominator. |
private java.text.NumberFormat |
numeratorFormat
The format used for the numerator. |
private static long |
serialVersionUID
Serializable version identifier. |
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(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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.text.NumberFormat |
---|
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 |
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 |
---|
private static final long serialVersionUID
private java.text.NumberFormat denominatorFormat
private java.text.NumberFormat numeratorFormat
Constructor Detail |
---|
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.Method Detail |
---|
protected static java.text.NumberFormat getDefaultNumberFormat()
NumberFormat.getNumberInstance(java.util.Locale)
. The only
customization 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)
. The only
customization 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/output 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/output 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 field
NumberFormat.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 field
NumberFormat.format(Object, StringBuffer, FieldPosition)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |