java.lang.Object | +--com.cedarspring.tvm.TVMu
GetObjects.TVM is a non-visual java bean that closely emulates the Time Value of Money functions of the Texas Instruments BAII Plus and Hewlett Packard 10B financial calculators.
The bean is offered as a educational tool to help illustrate the basic concepts of reusable software components and Time Value of Money. It should not be used for financial decisions or in any situation that might result in a financial loss without additional testing and modification to insure that it is accurate and suitable for your application.
You can:
Benefits:
Requirements:
message property.oldValue property in the
PropertChangeEvent is always set to null.
If an error occurs, it will fire an ErrorEvent
and will also set the message property.oldValue in the
PropertyChangeEvent is always set to null.message property. The state (except for
message) is not changed when an error occurs.
The two read-only properties (effectiveRate and AmortizationSchedule) can also fire error events since they compute the values only when requested. When an error occurs, an event is fired. The getEffectiveRate method will return 0. The getAmortizationSchedule method will return an empty schedule.
Firing an error event rather than throwing an exception makes the bean easier to wire in visual development tools, and allows additional info to be reported in the event.
| Field Summary | |
private java.beans.PropertyChangeSupport |
change
Reference to the PropertChangeSupport object. |
static java.lang.String |
COMPOUNDING_PER_YEAR
Property name "compoundingPerYear" |
static java.lang.String |
ENTER_RATE_AS_PERCENT
Property name "enterRateAsPercent" |
private ErrorSupport |
error
Reference to the ErrorSupport object. |
static java.lang.String |
FUTURE_VALUE
Property name "futureValue" |
private FutureValue |
fv
Reference to the FutureValue object. |
static java.lang.String |
INTEREST_RATE
Property name "interestRate" |
private InterestRate |
iy
Reference to the InterestRate object. |
static java.lang.String |
MESSAGE
Property name "message" |
private NumberOfPeriods |
n
Reference to the NumberOfPeriods object. |
static java.lang.String |
NUMBER_OF_PERIODS
Property name "numberOfPeriods" |
private Options |
opt
Reference to the Options object. |
static java.lang.String |
PAY_AT_END
Property name "payAtEnd" |
static java.lang.String |
PAYMENT
Property name "payment" |
static java.lang.String |
PAYMENTS_PER_YEAR
Property name "paymentsPerYear" |
private Payment |
pmt
Reference to the Payment object. |
static java.lang.String |
PRESENT_VALUE
Property name "presentValue" |
private PresentValue |
pv
Reference to the PresentValue object |
static java.lang.String |
RATE_ESTIMATE
Property name "rateEstimate" |
static java.lang.String |
ROUNDUP
Property name "roundUp" |
static java.lang.String |
SCALE
Property name "scale" |
(package private) static long |
serialVersionUID
|
| Constructor Summary | |
TVMu()
Create a new TVM object with default state. |
|
| Method Summary | |
void |
addErrorListener(ErrorListener listener)
Adds an ErrorListener to the listener list. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void |
clear()
Clears the TVM fields and error message. |
void |
clearMessage()
Clears the last message (error, warning, or information) that was delivered by any ErrorEvent. |
void |
computeFutureValue()
Computes the future value and sets the futureValue property. |
void |
computeInterestRate()
Computes an approximation of the annual interest rate and sets the interestRate property. |
void |
computeNumberOfPeriods()
Computes number of periods and sets the numberOfPeriods property. |
void |
computePayment()
Computes the annuity payment per period and sets the payment property. |
void |
computePresentValue()
Computes the present value and sets the presentValue property. |
AmortizationSchedule |
getAmortizationSchedule()
Gets an Amortization Schedule that divides each payment into interest and principal, and shows the ending balance for the period. |
int |
getCompoundingPerYear()
Gets compounding periods per year. |
java.math.BigDecimal |
getEffectiveRate()
Gets an annual effective interest rate that is equivalent to the annual nominal rate. |
boolean |
getEnterRateAsPercent()
Gets interest rate representation (decimal or percent) |
java.math.BigDecimal |
getFutureValue()
Gets future value. |
java.math.BigDecimal |
getInterestRate()
Gets annual nominal interest rate. |
java.util.Locale |
getLocale()
Gets the locale. |
java.lang.String |
getMessage()
Gets the last message (error, warning, or information) that was delivered by any ErrorEvent. |
java.math.BigDecimal |
getNumberOfPeriods()
Gets number of periods. |
java.math.BigDecimal |
getPayment()
Gets annuity payment. |
int |
getPaymentsPerYear()
Gets payments per year. |
java.math.BigDecimal |
getPresentValue()
Gets Present Value. |
java.math.BigDecimal |
getRateEstimate()
Gets interest rate estimate. |
boolean |
getRoundUp()
Gets rounding mode. |
int |
getScale()
Gets scale. |
java.math.BigDecimal |
getYears()
Gets the virtual property years. |
boolean |
isPayAtEnd()
Gets payAtEnd which indicates if payments are made at the beginning or end of each period. |
void |
removeErrorListener(ErrorListener listener)
Removes an ErrorListener from the listener list. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
private void |
reportError(java.lang.String errorNumber)
|
void |
reset()
Resets the Calculator to defaults. |
void |
setCompoundingPerYear(int compoundingPerYear)
Sets compounding periods per year. |
void |
setEnterRateAsPercent(boolean enterRateAsPercent)
Sets interest rate representation (decimal or percent). |
void |
setFutureValue(java.math.BigDecimal futureValue)
Sets future value. |
void |
setInterestRate(java.math.BigDecimal interestRate)
Sets annual nominal interest rate. |
void |
setLocale(java.util.Locale locale)
Sets the Locale. |
void |
setNumberOfPeriods(java.math.BigDecimal numberOfPeriods)
Sets number of periods. |
void |
setPayAtEnd(boolean payAtEnd)
Sets payment at beginning or end of period mode. |
void |
setPayment(java.math.BigDecimal payment)
Sets annuity payment. |
void |
setPaymentsPerYear(int paymentsPerYear)
Sets payments per year. |
void |
setPresentValue(java.math.BigDecimal presentValue)
Sets present value. |
void |
setRateEstimate(java.math.BigDecimal rateEstimate)
Sets interest rate estimate. |
void |
setRoundUp(boolean roundUp)
Sets Rounding mode. |
void |
setScale(int scale)
Sets scale. |
void |
setYears(java.math.BigDecimal years)
Sets the virtual property years. |
java.lang.String |
toString()
Gets a string containing values of TVM properties. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String PRESENT_VALUE
public static final java.lang.String FUTURE_VALUE
public static final java.lang.String PAYMENT
public static final java.lang.String INTEREST_RATE
public static final java.lang.String NUMBER_OF_PERIODS
public static final java.lang.String SCALE
public static final java.lang.String ROUNDUP
public static final java.lang.String PAYMENTS_PER_YEAR
public static final java.lang.String PAY_AT_END
public static final java.lang.String COMPOUNDING_PER_YEAR
public static final java.lang.String RATE_ESTIMATE
public static final java.lang.String ENTER_RATE_AS_PERCENT
public static final java.lang.String MESSAGE
private PresentValue pv
private FutureValue fv
private Payment pmt
private InterestRate iy
private NumberOfPeriods n
private Options opt
private ErrorSupport error
private java.beans.PropertyChangeSupport change
static final long serialVersionUID
| Constructor Detail |
public TVMu()
reset()| Method Detail |
public void setPresentValue(java.math.BigDecimal presentValue)
Events:
presentValue - Money that you have now, or
the value of a promised future amount of money or series
of payments that have been discounted to an equivalent value
today. Money paid out is negative.public java.math.BigDecimal getPresentValue()
public void computePresentValue()
Events:
setFutureValue(java.math.BigDecimal),
setPayment(java.math.BigDecimal),
setInterestRate(java.math.BigDecimal),
setNumberOfPeriods(java.math.BigDecimal)public void setFutureValue(java.math.BigDecimal futureValue)
Events:
futureValue - The amount of money that an investment
will grow to at some future date, or the balance of a loan remaining after
the last payment. Money paid out is negative.public java.math.BigDecimal getFutureValue()
public void computeFutureValue()
Events:
setPresentValue(java.math.BigDecimal),
setPayment(java.math.BigDecimal),
setInterestRate(java.math.BigDecimal),
setNumberOfPeriods(java.math.BigDecimal)public void setPayment(java.math.BigDecimal payment)
Events:
payment - Payments (or dividends) must be all inflows or all outflows,
occur at evenly spaced intervals, and represent the payment during one
compounding (or discount) period.
Money paid out is negative.public java.math.BigDecimal getPayment()
public void computePayment()
Events:
setPresentValue(java.math.BigDecimal),
setFutureValue(java.math.BigDecimal),
setInterestRate(java.math.BigDecimal),
setNumberOfPeriods(java.math.BigDecimal)public void setInterestRate(java.math.BigDecimal interestRate)
Events:
interestRate - annual interest rate. Range is 0-999%setEnterRateAsPercent(boolean),
setCompoundingPerYear(int),
setPaymentsPerYear(int)public java.math.BigDecimal getInterestRate()
setEnterRateAsPercent(boolean)public void computeInterestRate()
Events:
setPresentValue(java.math.BigDecimal),
setFutureValue(java.math.BigDecimal),
setPayment(java.math.BigDecimal),
setNumberOfPeriods(java.math.BigDecimal),
setRateEstimate(java.math.BigDecimal)public void setEnterRateAsPercent(boolean enterRateAsPercent)
Events:
enterRateAsPercent - public boolean getEnterRateAsPercent()
public void setRateEstimate(java.math.BigDecimal rateEstimate)
Events:
rateEstimate - Your best estimate of the annual nominal
interest rate. If the computeInterestRate method cannot converge on
rate, try changing this property. The default value of 10% is reasonable
for rates between 0 and 100%. The property can be set to any value, but
it should be close to the range of interestRate (0-999%).computeInterestRate()public java.math.BigDecimal getRateEstimate()
public void setPaymentsPerYear(int paymentsPerYear)
Events:
paymentsPerYear - The number of equally-spaced payments made
per year. Used with compoundingPerYear to compute the interest
rate per period.setCompoundingPerYear(int)public int getPaymentsPerYear()
public void setCompoundingPerYear(int compoundingPerYear)
Events:
compoundingPerYear - The number of compounding periods
per year. Used with paymentsPerYear to compute the interest
rate per period.setPaymentsPerYear(int)public int getCompoundingPerYear()
public java.math.BigDecimal getEffectiveRate()
Events:
setEnterRateAsPercent(boolean),
setInterestRate(java.math.BigDecimal),
setCompoundingPerYear(int)public void setNumberOfPeriods(java.math.BigDecimal numberOfPeriods)
Events:
numberOfPeriods - Number of Periods.public java.math.BigDecimal getNumberOfPeriods()
public void setYears(java.math.BigDecimal years)
Events:
years - years.setNumberOfPeriods(java.math.BigDecimal),
setPaymentsPerYear(int),
setRoundUp(boolean)public java.math.BigDecimal getYears()
setNumberOfPeriods(java.math.BigDecimal),
setPaymentsPerYear(int),
setRoundUp(boolean),
setScale(int)public void computeNumberOfPeriods()
Events:
setPresentValue(java.math.BigDecimal),
setFutureValue(java.math.BigDecimal),
setPayment(java.math.BigDecimal),
setInterestRate(java.math.BigDecimal)public void setPayAtEnd(boolean payAtEnd)
Events:
payAtEnd - public boolean isPayAtEnd()
public void setScale(int scale)
Events:
scale - number of digits to the right of the decimal place.public int getScale()
public void setRoundUp(boolean roundUp)
Events:
roundUp - Rounding applied to subsequent computations.
public boolean getRoundUp()
public AmortizationSchedule getAmortizationSchedule()
The amortization schedule is based on the current values of:
Events:
setPresentValue(java.math.BigDecimal),
setPayment(java.math.BigDecimal),
computePayment(),
setInterestRate(java.math.BigDecimal),
setCompoundingPerYear(int),
setNumberOfPeriods(java.math.BigDecimal),
setPayAtEnd(boolean)public void clear()
Events:
public void reset()
Events:
clear()public java.lang.String getMessage()
public void clearMessage()
public void setLocale(java.util.Locale locale)
public java.util.Locale getLocale()
public java.lang.String toString()
toString in class java.lang.Objectpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - The PropertyChangeListener to be addedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - The PropertyChangeListener to be removedpublic void addErrorListener(ErrorListener listener)
listener - The ErrorListener to be addedpublic void removeErrorListener(ErrorListener listener)
listener - The ErrorListener to be removedprivate void reportError(java.lang.String errorNumber)