|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.davesag.generica.core.Money
This Money bean represents an amount in a currency. This is a whole number of 'cents' in that currency. Note throughout this documentation I shall refer to cents as being the indivisible component of a currency, even though obviously many currencies don't actually have Cents. Use the valueOf method to get the actual 'dollar' value.
| Field Summary | |
protected BigDecimal |
theAmount
the amount |
protected Currency |
theCurrency
the Currency |
| Constructor Summary | |
Money()
null constructor required by hibernate. |
|
Money(Currency currency,
BigDecimal amount)
Constructor that takes a currency object and number of 'cents' as a big decimal. |
|
Money(Currency currency,
int n)
Constructor that takes a currency object and number of 'cents'. |
|
Money(Currency currency,
Integer n)
Constructor that takes a currency object and number of 'cents'. |
|
Money(Currency currency,
String amount)
Constructor that takes a currency object and number of 'cents' as a string. |
|
Money(String currencycode,
BigDecimal amount)
Constructor that takes a currency code and number of 'cents' as a big decimal. |
|
Money(String currencycode,
int n)
Constructor that takes a iso currency code and number of 'cents'. |
|
Money(String currencycode,
Integer amount)
Constructor that takes a currency code and number of 'cents' as a string. |
|
Money(String currencycode,
String amount)
Constructor that takes a currency code and number of 'cents' as a string. |
|
| Method Summary | |
Money |
add(Money addto)
Adds the supplied money to this money, and converts the currency as needed. |
int |
compareTo(Object o)
Compares this money with the supplied money object, performing currency conversion if needed. |
boolean |
equals(Object o)
compare the two moneys for equality. |
String |
format(Locale loc)
Constructs a correcty formatted string representation of this money, according to a format in org.davesag.generica.resource.application currecy.format. |
String |
format(Locale loc,
String formatpattern)
Constructs a correcty formatted string representation of this money, according to a format pattern supplied. |
BigDecimal |
getAmount()
get the amount in a whole number of 'cents'. |
Currency |
getCurrency()
get the currency |
String |
getCurrencyCode()
get the ISO 4217 currency code. |
Integer |
getIntegerAmount()
get the amount in a whole number of 'cents'. |
int |
hashCode()
require to override hashcode when we override the equals method. |
Money |
multiply(int timesby)
Multiplies the supplied number by this money's amount. |
Money |
multiply(Long timesby)
Multiplies the supplied number by this money's amount. |
void |
setAmount(BigDecimal amnt)
Set the amount in 'cents'. |
void |
setCurrency(Currency curr)
Set the currency |
void |
setCurrencyCode(String curcode)
Set the ISO 4217 currency code. |
void |
setIntegerAmount(Integer amnt)
Set the amount in 'cents'. |
Money |
subtract(Money subfrom)
Subtracts the supplied money from this money, and converts the currency as needed. |
String |
toString()
a simple string version of this money. |
static BigDecimal |
valueOf(Money m)
Money is stored as a whole number of 'cents' The actual value depends on the number of decimal places in the currency, but 'cents' is a useful generic term. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected Currency theCurrency
protected BigDecimal theAmount
| Constructor Detail |
public Money()
public Money(String currencycode,
int n)
currencycode - The currency code to use.n - The amount in cents
public Money(Currency currency,
int n)
currency - The currency to use.n - The amount in cents
public Money(Currency currency,
Integer n)
currency - The currency to use.n - The amount in cents as an Integer
public Money(String currencycode,
String amount)
currencycode - The currency code to use.amount - The amount in cents as a string
public Money(String currencycode,
Integer amount)
currencycode - The currency code to use.amount - The amount in cents as an Integer
public Money(Currency currency,
String amount)
currency - The currency to use.amount - The amount in cents as a string
public Money(String currencycode,
BigDecimal amount)
currencycode - The currency code to use.amount - The amount in cents as a BigDecimal
public Money(Currency currency,
BigDecimal amount)
currency - The currency to use.amount - The amount in cents as a BigDecimal| Method Detail |
public Currency getCurrency()
public void setCurrency(Currency curr)
curr - the first name.public String getCurrencyCode()
public void setCurrencyCode(String curcode)
curcode - the first name.public BigDecimal getAmount()
public Integer getIntegerAmount()
public void setIntegerAmount(Integer amnt)
amnt - The amountpublic void setAmount(BigDecimal amnt)
amnt - The amountpublic Money add(Money addto)
addto - The money to add to this money.
public Money subtract(Money subfrom)
subfrom - The money to subtract from this money.
public Money multiply(int timesby)
timesby - The integer to multiply this money by.
public Money multiply(Long timesby)
timesby - The integer to multiply this money by.
public int compareTo(Object o)
compareTo in interface Comparableo - The object to compare.
NullPointerException - if the object incoming was null.
ClassCastException - if the incoming object was not a Money.public boolean equals(Object o)
o - The other object (should be a money).
public int hashCode()
public static BigDecimal valueOf(Money m)
m - the money.
public String format(Locale loc,
String formatpattern)
loc - The local to display the money in.formatpattern - the fomatting pattern.
public String format(Locale loc)
loc - The local to display the money in.
public String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||