|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ail.core.Type
com.ail.util.Rate
public class Rate
This class represents fractions or rates - with some special handling for common fractions like percentages and permils.
| Field Summary |
|---|
| Fields inherited from class com.ail.core.Type |
|---|
jXPathContext, NOT_PERSISTED |
| Constructor Summary | |
|---|---|
Rate()
Constructor. |
|
Rate(java.lang.String rate)
Constructor. |
|
| Method Summary | |
|---|---|
java.math.BigDecimal |
applyTo(java.math.BigDecimal value,
int scale,
int roundingMode)
Apply this rate to a BigDecimal value. |
double |
applyTo(double value,
int scale,
int roundingMode)
Apply this rate to a double value. |
java.lang.String |
applyTo(java.lang.String value,
int scale,
int roundingMode)
Apply this rate to a String value. |
java.lang.Object |
clone()
Clone this object. |
java.lang.String |
getRate()
Get the rate as a string. |
void |
setRate(java.lang.String rate)
Rates can be expressed in the following formats: "n%" where 0 <= n <= 100. |
| 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 |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Rate()
public Rate(java.lang.String rate)
rate - | Method Detail |
|---|
public void setRate(java.lang.String rate)
throws java.lang.IllegalArgumentException,
java.lang.NumberFormatException
rate - The representation of a rate.
java.lang.IllegalArgumentException - if a value is out of range, e.g. "102%".
java.lang.NumberFormatException - if the rate strings format does not match one of those described above.public java.lang.String getRate()
public java.math.BigDecimal applyTo(java.math.BigDecimal value,
int scale,
int roundingMode)
throws java.lang.IllegalStateException
value - The value to apply the rate toscale - Scale (decimal places) for the calculation.roundingMode - The rounding mode to use
java.lang.IllegalStateException - If this rate has not be initialised.For details of rounding modes.
public java.lang.String applyTo(java.lang.String value,
int scale,
int roundingMode)
throws java.lang.IllegalStateException,
java.lang.NumberFormatException
value - String in BigDecimal formatscale - Scale (decimal places) for the calculation.roundingMode - Rounding to mode to apply
java.lang.IllegalStateException - If this rate has not been initialised.
java.lang.NumberFormatException - If "value" does not represent a valid BigDecimal.For details of rounding modes.
public double applyTo(double value,
int scale,
int roundingMode)
throws java.lang.IllegalStateException
value - Value to apply the rate to.scale - Scale (decimal places) for the calculation.roundingMode - Rounding mode to use.
java.lang.IllegalStateException - If this rate has not beeb initialised.public java.lang.Object clone()
Type
clone in class Type
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||