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:
java.io.Serializable, java.lang.Cloneable

public class CurrencyFormat
extends java.text.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
java.text.NumberFormat.Field
 
Field Summary
static java.lang.String CURRENCY_PROPERTY_ID
           
static java.lang.String SHOWCURRENCY_PROPERTY_ID
           
 
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
 
Constructor Summary
CurrencyFormat()
           
CurrencyFormat(java.util.Currency currency)
           
CurrencyFormat(java.util.Locale locale)
           
CurrencyFormat(java.text.NumberFormat currencyFormat, java.text.NumberFormat numberFormat)
           
CurrencyFormat(java.lang.String currencyCode)
           
 
Method Summary
 java.lang.StringBuffer format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
           
 java.lang.StringBuffer format(long number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
           
 java.util.Currency getCurrency()
          Currency:
 boolean getShowCurrency()
          ShowCurrency:
 java.lang.Number parse(java.lang.String source, java.text.ParsePosition parsePosition)
          first try the currency formatter, if it fails try the number formatter
 void setCurrency(java.util.Currency value)
           
 void setShowCurrency(boolean value)
           
 CurrencyFormat withCurrency(java.util.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 java.lang.String CURRENCY_PROPERTY_ID
See Also:
Constant Field Values

SHOWCURRENCY_PROPERTY_ID

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

CurrencyFormat

public CurrencyFormat()

CurrencyFormat

public CurrencyFormat(java.util.Locale locale)
Parameters:
locale -

CurrencyFormat

public CurrencyFormat(java.util.Currency currency)
Parameters:
locale -

CurrencyFormat

public CurrencyFormat(java.lang.String currencyCode)
Parameters:
locale -

CurrencyFormat

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

getCurrency

public java.util.Currency getCurrency()
Currency:

Overrides:
getCurrency in class java.text.NumberFormat

setCurrency

public void setCurrency(java.util.Currency value)
Overrides:
setCurrency in class java.text.NumberFormat

withCurrency

public CurrencyFormat withCurrency(java.util.Currency value)

getShowCurrency

public boolean getShowCurrency()
ShowCurrency:


setShowCurrency

public void setShowCurrency(boolean value)

withShowCurrency

public CurrencyFormat withShowCurrency(boolean value)

format

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

format

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

parse

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

Specified by:
parse in class java.text.NumberFormat


Copyright © 2010. All Rights Reserved.