org.tbee.swing.text
Class CurrencyFormat

java.lang.Object
  extended by java.text.Format
      extended by java.text.NumberFormat
          extended by org.tbee.swing.text.CurrencyFormat
All Implemented Interfaces:
Serializable, Cloneable

public class CurrencyFormat
extends NumberFormat

Render or parse a currency. Behaviour is slightly different from the formatter provided by Java. There is no need to actually type the currency before the number

Author:
user
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.NumberFormat
NumberFormat.Field
 
Field Summary
static String CURRENCY_PROPERTY_ID
           
static String SHOWCURRENCY_PROPERTY_ID
           
 
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
 
Constructor Summary
CurrencyFormat()
           
CurrencyFormat(Currency currency)
           
CurrencyFormat(Locale locale)
           
CurrencyFormat(NumberFormat currencyFormat, NumberFormat numberFormat)
           
CurrencyFormat(String currencyCode)
           
 
Method Summary
 StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos)
           
 StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos)
           
 Currency getCurrency()
          Currency:
 boolean getShowCurrency()
          ShowCurrency:
 Number parse(String source, ParsePosition parsePosition)
          first try the currency formatter, if it fails try the number formatter
 void setCurrency(Currency value)
           
 void setShowCurrency(boolean value)
           
 CurrencyFormat withCurrency(Currency value)
           
 CurrencyFormat withShowCurrency(boolean value)
           
 
Methods inherited from class java.text.NumberFormat
clone, equals, format, format, format, getAvailableLocales, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, getRoundingMode, hashCode, isGroupingUsed, isParseIntegerOnly, parse, parseObject, 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

CURRENCY_PROPERTY_ID

public static final String CURRENCY_PROPERTY_ID
See Also:
Constant Field Values

SHOWCURRENCY_PROPERTY_ID

public static final String SHOWCURRENCY_PROPERTY_ID
See Also:
Constant Field Values
Constructor Detail

CurrencyFormat

public CurrencyFormat()

CurrencyFormat

public CurrencyFormat(Locale locale)
Parameters:
locale -

CurrencyFormat

public CurrencyFormat(Currency currency)
Parameters:
locale -

CurrencyFormat

public CurrencyFormat(String currencyCode)
Parameters:
locale -

CurrencyFormat

public CurrencyFormat(NumberFormat currencyFormat,
                      NumberFormat numberFormat)
Parameters:
currencyFormat -
numberFormat -
Method Detail

getCurrency

public Currency getCurrency()
Currency:

Overrides:
getCurrency in class NumberFormat

setCurrency

public void setCurrency(Currency value)
Overrides:
setCurrency in class NumberFormat

withCurrency

public CurrencyFormat withCurrency(Currency value)

getShowCurrency

public boolean getShowCurrency()
ShowCurrency:


setShowCurrency

public void setShowCurrency(boolean value)

withShowCurrency

public CurrencyFormat withShowCurrency(boolean value)

format

public StringBuffer format(double number,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Specified by:
format in class NumberFormat

format

public StringBuffer format(long number,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Specified by:
format in class NumberFormat

parse

public Number parse(String source,
                    ParsePosition parsePosition)
first try the currency formatter, if it fails try the number formatter

Specified by:
parse in class NumberFormat


Copyright © 2011 KnowledgePlaza. All Rights Reserved.