planetj.formatters
Class CurrencyFormatter

java.lang.Object
  |
  +--java.text.Format
        |
        +--java.text.NumberFormat
              |
              +--planetj.formatters.CurrencyFormatter
All Implemented Interfaces:
Cloneable, IFormatter, Serializable
Direct Known Subclasses:
FourDecimalCurrencyFormatter, NegativeCurrencyFormatter

public class CurrencyFormatter
extends NumberFormat
implements IFormatter

Insert the type's description here. Creation date: (11/28/2001 10:04:12 AM)

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
 
Constructor Summary
CurrencyFormatter()
           
 
Method Summary
 StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos)
          Specialization of format.
 StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos)
          Specialization of format.
 Object formatValue(Object value)
          This method formats a number (or a String representation of the number that has no commas) to be a string that represents the currency format of the current locale.
 NumberFormat getFormatterInstance()
           
 Number parse(String text, ParsePosition parsePosition)
          Returns a Long if possible (e.g., within the range [Long.MIN_VALUE, Long.MAX_VALUE] and with no decimals), otherwise a Double.
 
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, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly
 
Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CurrencyFormatter

public CurrencyFormatter()
Method Detail

format

public StringBuffer format(double number,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Specialization of format.

Specified by:
format in class NumberFormat
See Also:
Format.format(java.lang.Object)

format

public StringBuffer format(long number,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Specialization of format.

Specified by:
format in class NumberFormat
See Also:
Format.format(java.lang.Object)

formatValue

public Object formatValue(Object value)
This method formats a number (or a String representation of the number that has no commas) to be a string that represents the currency format of the current locale. For example, 23434.45 would return $23434.45. If a value is passed in that is not in the right format to be formatted, that value is simply returned

Specified by:
formatValue in interface IFormatter
Parameters:
value - java.lang.Object
Returns:
java.lang.Object

parse

public Number parse(String text,
                    ParsePosition parsePosition)
Returns a Long if possible (e.g., within the range [Long.MIN_VALUE, Long.MAX_VALUE] and with no decimals), otherwise a Double. If IntegerOnly is set, will stop at a decimal point (or equivalent; e.g., for rational numbers "1 2/3", will stop after the 1). Does not throw an exception; if no object can be parsed, index is unchanged!

Specified by:
parse in class NumberFormat
See Also:
NumberFormat.isParseIntegerOnly(), Format.parseObject(java.lang.String, java.text.ParsePosition)

getFormatterInstance

public NumberFormat getFormatterInstance()