| java.lang.Object java.text.Format org.apache.commons.math.fraction.FractionFormat
All known Subclasses: org.apache.commons.math.fraction.ProperFractionFormat,
FractionFormat | public class FractionFormat extends Format implements Serializable(Code) | | Formats a Fraction number in proper format or improper format. The number
format for each of the whole number, numerator and, denominator can be
configured.
since: 1.1 version: $Revision: 348519 $ $Date: 2005-11-23 12:12:18 -0700 (Wed, 23 Nov 2005) $ |
Constructor Summary | |
public | FractionFormat() Create an improper formatting instance with the default number format
for the numerator and denominator. | public | FractionFormat(NumberFormat format) Create an improper formatting instance with a custom number format for
both the numerator and denominator. | public | FractionFormat(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. |
FractionFormat | public FractionFormat()(Code) | | Create an improper formatting instance with the default number format
for the numerator and denominator.
|
FractionFormat | public FractionFormat(NumberFormat format)(Code) | | Create an improper formatting instance with a custom number format for
both the numerator and denominator.
Parameters: format - the custom format for both the numerator and denominator. |
FractionFormat | public FractionFormat(NumberFormat numeratorFormat, NumberFormat denominatorFormat)(Code) | | Create an improper formatting instance with a custom number format for
the numerator and a custom number format for the denominator.
Parameters: numeratorFormat - the custom format for the numerator. Parameters: denominatorFormat - the custom format for the denominator. |
format | public StringBuffer format(Fraction fraction, StringBuffer toAppendTo, FieldPosition pos)(Code) | | Formats a
Fraction object to produce a string. The fraction is
output in improper format.
Parameters: fraction - the object to format. Parameters: toAppendTo - where the text is to be appended Parameters: pos - On input: an alignment field, if desired. On output: theoffsets of the alignment field the value passed in as toAppendTo. |
formatFraction | public static String formatFraction(Fraction f)(Code) | | This static method calls formatFraction() on a default instance of
FractionFormat.
Parameters: f - Fraction object to format A formatted fraction in proper form. |
getAvailableLocales | public static Locale[] getAvailableLocales()(Code) | | Get the set of locales for which complex formats are available. This
is the same set as the
NumberFormat set.
available complex format locales. |
getDenominatorFormat | public NumberFormat getDenominatorFormat()(Code) | | Access the denominator format.
the denominator format. |
getImproperInstance | public static FractionFormat getImproperInstance()(Code) | | Returns the default complex format for the current locale.
the default complex format. |
getImproperInstance | public static FractionFormat getImproperInstance(Locale locale)(Code) | | Returns the default complex format for the given locale.
Parameters: locale - the specific locale used by the format. the complex format specific to the given locale. |
getNumeratorFormat | public NumberFormat getNumeratorFormat()(Code) | | Access the numerator format.
the numerator format. |
getProperInstance | public static FractionFormat getProperInstance()(Code) | | Returns the default complex format for the current locale.
the default complex format. |
getProperInstance | public static FractionFormat getProperInstance(Locale locale)(Code) | | Returns the default complex format for the given locale.
Parameters: locale - the specific locale used by the format. the complex format specific to the given locale. |
parse | public Fraction parse(String source, ParsePosition pos)(Code) | | Parses a string to produce a
Fraction object. This method
expects the string to be formatted as an improper fraction.
Parameters: source - the string to parse Parameters: pos - input/ouput parsing parameter. the parsed Fraction object. |
parseAndIgnoreWhitespace | protected static void parseAndIgnoreWhitespace(String source, ParsePosition pos)(Code) | | Parses source until a non-whitespace character is found.
Parameters: source - the string to parse Parameters: pos - input/ouput parsing parameter. On output, pos holds the index of the next non-whitespace character. |
parseNextCharacter | protected static char parseNextCharacter(String source, ParsePosition pos)(Code) | | Parses source until a non-whitespace character is found.
Parameters: source - the string to parse Parameters: pos - input/ouput parsing parameter. the first non-whitespace character. |
setDenominatorFormat | public void setDenominatorFormat(NumberFormat format)(Code) | | Modify the denominator format.
Parameters: format - the new denominator format value. throws: IllegalArgumentException - if format isnull . |
|
|