|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ail.core.Type
com.ail.financial.CurrencyAmount
public class CurrencyAmount
Instances of this class represent amounts of money. todo This currently assumes a BigDecimal scale of 2 for all currencies.
| Field Summary |
|---|
| Fields inherited from class com.ail.core.Type |
|---|
jXPathContext, NOT_PERSISTED |
| Constructor Summary | |
|---|---|
CurrencyAmount()
Default constructor. |
|
CurrencyAmount(java.math.BigDecimal amount,
Currency currency)
Constructor |
|
CurrencyAmount(double amount,
Currency currency)
Constructor |
|
CurrencyAmount(java.lang.String amount,
Currency currency)
Constructor |
|
| Method Summary | |
|---|---|
void |
add(CurrencyAmount that)
Add another currency amount to this one, saving the result in this one. |
void |
apply(Rate rate)
Apply a percentage to this currency amount. |
java.lang.Object |
clone()
Clone this. |
boolean |
equals(java.lang.Object obj)
Equality checker |
java.math.BigDecimal |
getAmount()
Get the amount represented |
java.lang.String |
getAmountAsString()
|
Currency |
getCurrency()
Get the amount's currency |
java.lang.String |
getCurrencyAsString()
Get the currency as a string. |
boolean |
greaterThan(CurrencyAmount that)
Compare the value of 'that' currency amount with this. |
boolean |
greaterThan(double amount,
Currency currency)
Compare the value of amount in currency with the amount represented by
this. |
boolean |
lessThan(CurrencyAmount that)
Compare the value of 'that' currency amount with this. |
boolean |
lessThan(double amount,
Currency currency)
Compare the value of amount in currency with the amount represented by
this. |
void |
setAmount(java.math.BigDecimal amount)
Set the amount property. |
void |
setAmountAsString(java.lang.String amount)
Set the amount property from a string. |
void |
setCurrencyAsString(java.lang.String currency)
Set the currency based on a String representation of a currency. |
void |
subtract(CurrencyAmount that)
Subtract another currency amount from this one, saving the result in this one. |
java.lang.String |
toString()
Get the String representation of this amount. |
| Methods inherited from class com.ail.core.Type |
|---|
addAttribute, deleteLock, deleteSerialVersion, fetchJXPathContext, getAttribute, getAttribute, getAttributeCount, getForeignSystemId, getLock, getSerialVersion, getSystemId, hasLock, hasSerialVersion, hasSystemId, isPersisted, markAsNotPersisted, mergeWithDataFrom, removeAttribute, removeAttribute, setAttribute, setForeignSystemId, setLock, setSerialVersion, setSystemId, xpathGet, xpathGet, xpathIterate, xpathSet |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CurrencyAmount()
public CurrencyAmount(java.math.BigDecimal amount,
Currency currency)
amount - The amountcurrency - The currency
public CurrencyAmount(java.lang.String amount,
Currency currency)
amount - The amountcurrency - The currency
public CurrencyAmount(double amount,
Currency currency)
amount - The amountcurrency - The currency.| Method Detail |
|---|
public java.math.BigDecimal getAmount()
public void setAmount(java.math.BigDecimal amount)
amount -
public void setAmountAsString(java.lang.String amount)
throws java.lang.NumberFormatException
amount -
java.lang.NumberFormatException - If string does not represent a valid decimal amount.public java.lang.String getAmountAsString()
public void subtract(CurrencyAmount that)
throws java.lang.IllegalArgumentException
that - Currency amount to subtract
java.lang.IllegalArgumentException - If the currency types does not match.
public void add(CurrencyAmount that)
throws java.lang.IllegalArgumentException
that - Currenct amount to add
java.lang.IllegalArgumentException - If the curerncies do not match.public boolean lessThan(CurrencyAmount that)
that - Currency amount to compare with.
java.lang.IllegalArgumentException - if the currencies do not match.public boolean greaterThan(CurrencyAmount that)
that - Currency amount to compare with.
java.lang.IllegalArgumentException - if the currencies do not match.
public boolean lessThan(double amount,
Currency currency)
amount in currency with the amount represented by
this. The two currencies must be the same.
amount - Amount to compare against.currency - The currency amount is in.
amount and currency is less than than this.
java.lang.IllegalArgumentException - if the currencies do not match.
public boolean greaterThan(double amount,
Currency currency)
amount in currency with the amount represented by
this. The two currencies must be the same.
amount - Amount to compare against.currency - The currency amount is in.
amount and currency is greater than than this.
java.lang.IllegalArgumentException - if the currencies do not match.
public void setCurrencyAsString(java.lang.String currency)
throws java.lang.IndexOutOfBoundsException
currency -
java.lang.IndexOutOfBoundsExceptionpublic Currency getCurrency()
public java.lang.String getCurrencyAsString()
public java.lang.String toString()
toString in class java.lang.Objectpublic void apply(Rate rate)
rate - Percentage to apply.
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class Typejava.lang.CloneNotSupportedException - If the clone failspublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectthat - Amount to check equality with
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||