jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.dbutil
Class Currency

java.lang.Object
  extended byuk.co.weft.dbutil.Currency

public class Currency
extends java.lang.Object

An amount of money. Most world currencies are now 'decimal' with a larger denomination unit which is on hundred times the value of the smaller denomination unit: e.g. dollars and cents, pounds and pennies, etc. It makes sense to store these in the database as an integer number of the smaller denomination unit. This class represents part of the support for that.


Field Summary
static int defaultCurrency
          the currency which is the default on this system
static int EURO
          symbolic values for some well known currencies - generally, the international dialling code for the country in which the central bank for that currency is located.
static int STERLING
          symbolic values for some well known currencies - generally, the international dialling code for the country in which the central bank for that currency is located.
static int USDOLLAR
          symbolic values for some well known currencies - generally, the international dialling code for the country in which the central bank for that currency is located.
static int YEN
          symbolic values for some well known currencies - generally, the international dialling code for the country in which the central bank for that currency is located.
 
Constructor Summary
Currency()
          create an 'empty' (zero) sum of money
Currency(double pounds)
          Creates a new Currency object.
Currency(double pounds, int currency)
          TODO well unsafe! Fix this!
Currency(int pennies)
          create a new amount of money, currency whatever is the default for this system
Currency(int pennies, int currency)
          create a new amount of this currency
 
Method Summary
 java.lang.Double coerceToDouble()
          Deprecated. this isn't really safe because of possible rounding errors
 java.lang.Integer coerceToInteger()
           
 java.lang.String getSymbolAsEntity()
           
 java.lang.String toString()
           
 java.lang.String toString(boolean withSymbol)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STERLING

public static final int STERLING
symbolic values for some well known currencies - generally, the international dialling code for the country in which the central bank for that currency is located. This one is sterling...

See Also:
Constant Field Values

USDOLLAR

public static final int USDOLLAR
symbolic values for some well known currencies - generally, the international dialling code for the country in which the central bank for that currency is located. This one is the not-so-mighty buck...

See Also:
Constant Field Values

EURO

public static final int EURO
symbolic values for some well known currencies - generally, the international dialling code for the country in which the central bank for that currency is located. This one is the euro...

See Also:
Constant Field Values

YEN

public static final int YEN
symbolic values for some well known currencies - generally, the international dialling code for the country in which the central bank for that currency is located. This one is the yen...

See Also:
Constant Field Values

defaultCurrency

public static int defaultCurrency
the currency which is the default on this system

Constructor Detail

Currency

public Currency()
create an 'empty' (zero) sum of money


Currency

public Currency(int pennies)
         throws DataFormatException
create a new amount of money, currency whatever is the default for this system


Currency

public Currency(int pennies,
                int currency)
         throws DataFormatException
create a new amount of this currency


Currency

public Currency(double pounds)
         throws DataFormatException
Creates a new Currency object.

Parameters:
pounds - DOCUMENT ME!
Throws:
DataFormatException - DOCUMENT ME!

Currency

public Currency(double pounds,
                int currency)
         throws DataFormatException
TODO well unsafe! Fix this!

Method Detail

getSymbolAsEntity

public java.lang.String getSymbolAsEntity()
Returns:
the symbol for this currency as an HTML entity, or an empty string if no symbol is known for this currency.

coerceToInteger

public java.lang.Integer coerceToInteger()
Returns:
my value as an integer number of my smaller denomination

coerceToDouble

public java.lang.Double coerceToDouble()
Deprecated. this isn't really safe because of possible rounding errors

Returns:
my value as a real number of my larger denomination

toString

public java.lang.String toString()
Returns:
a string representation of my value without the currency symbol

toString

public java.lang.String toString(boolean withSymbol)
Parameters:
withSymbol - if true prefix my value with my symbol as an HTML entity
Returns:
a string representation of my value

jacquard 1.12.0 by The Web Engineering Factory and Toolworks