|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.text.Format com.pcauto.util.QuantityFormat com.pcauto.util.CurrencyFormat
CurrencyFormat
provides several mechanisms to use
Currency
objects;
Currency
objects
Locale based constructors will use a default scale of 2. The parse and format
methods are used to generate and format Currency
objects
respectively. They can be used in conjunction to convert Currency
objects into different units.
Conversion rates have been hardcoded to Sept. 06, 2002. Use the setCurrencyExchange member function to set new conversion rates.
Nested Class Summary |
Nested classes inherited from class java.text.Format |
java.text.Format.Field |
Field Summary |
Fields inherited from class com.pcauto.util.QuantityFormat |
groupingUsed, scale, units |
Constructor Summary | |
CurrencyFormat()
Creates new CurrencyFormat instance based on default
Locale |
|
CurrencyFormat(CurrencyUnits units,
int scale)
Creates new CurrencyFormat instance with units set to
int units and scale set to int scale. |
|
CurrencyFormat(java.util.Locale loc)
Creates new CurrencyFormat instance based on supplied
Locale |
Method Summary | |
java.lang.StringBuffer |
format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
Returns StringBuffer with supplied Currency
quantity formatted in units |
java.lang.String |
formatCurrency(Currency crn)
Returns String with supplied Currency
quantity formatted in units |
CurrencyUnits |
getUnits()
Gets value for currency units. |
Currency |
parseCurrency(java.lang.String value)
Parses String based on units to return a
Currency object. |
java.lang.Object |
parseObject(java.lang.String source,
java.text.ParsePosition pos)
Parses String based on units to return a
Currency object. |
void |
setCurrencyExchange(CurrencyUnits srcCurrency,
CurrencyUnits destCurrency,
double exchangeRate)
Sets exchange rate between diferent currency units. |
void |
setUnits(CurrencyUnits units)
Sets value for currency units. |
Methods inherited from class com.pcauto.util.QuantityFormat |
getScale, isGroupingUsed, setGroupingUsed, setScale |
Methods inherited from class java.text.Format |
clone, format, formatToCharacterIterator, parseObject |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CurrencyFormat()
CurrencyFormat
instance based on default
Locale
public CurrencyFormat(java.util.Locale loc)
CurrencyFormat
instance based on supplied
Locale
loc
- Locale
to set correct currency unitspublic CurrencyFormat(CurrencyUnits units, int scale)
CurrencyFormat
instance with units set to
int
units and scale set to int
scale.
scale
- int
to set scaleMethod Detail |
public java.lang.String formatCurrency(Currency crn)
String
with supplied Currency
quantity formatted in units
crn
- Currency
object from which to format value
String
currency in current unitspublic java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
StringBuffer
with supplied Currency
quantity formatted in units
toAppendTo
- StringBuffer
to append string topos
- FieldPosition
ignored in this implementation
StringBuffer
currency in current unitspublic Currency parseCurrency(java.lang.String value)
String
based on units to return a
Currency
object. The function will successfully parse input
String
, even if it contains unit character
as first character ($5.33)
public java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition pos)
String
based on units to return a
Currency
object. The function will successfully parse input
String
, even if it contains unit character
as first character ($5.33)
Currency
holding a value specified
in input String
NumberFormatException
- on non-numeric
String
inputpublic void setCurrencyExchange(CurrencyUnits srcCurrency, CurrencyUnits destCurrency, double exchangeRate)
public void setUnits(CurrencyUnits units)
public CurrencyUnits getUnits()
CurrencyUnits
value of current measurement units
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |