|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ftlabs.fisa.DefaultCPIFactory
public class DefaultCPIFactory
This is the default implementation of CPIFactory. For maximum efficiency, this implementation caches all provided values so that the getCPI() methods returns as quickly as possible.
| Constructor Summary | |
|---|---|
DefaultCPIFactory()
Creates a new instance of DefaultCPIFactory without any cpi values. |
|
DefaultCPIFactory(java.io.InputStream inputStream)
Creates a new instance of DefaultCPIFactory populated with dates and cpi values provided by an InputStream. |
|
DefaultCPIFactory(java.io.InputStream inputStream,
java.text.Format format,
int earliestYear)
Creates a new instance of DefaultCPIFactory populated with dates and cpi values provided by an InputStream. |
|
DefaultCPIFactory(int earliestYear)
Creates a new instance of DefaultCPIFactory without any cpi values. |
|
DefaultCPIFactory(java.lang.String filePath)
Creates a new instance of DefaultCPIFactory populated with data contained in the provided file setting 1900 to be the earliestYear. |
|
DefaultCPIFactory(java.lang.String filePath,
int earliestYear)
Creates a new instance of DefaultCPIFactory populated with data contained in the provided file setting earliestYear as provided. |
|
| Method Summary | |
|---|---|
void |
addCPIValue(java.util.Date date,
double cpiValue)
Add a CPI value for the provided date. |
void |
clear()
Clear all CPI values. |
double |
getCPI(java.util.Date date)
This method returns the CPI for the given Date. |
double |
getCPI(java.util.Date date,
int monthOffset)
This method returns the CPI for the given month offset from the given date. |
double |
getCPI(int year,
int month)
This method returns the CPI for the given year and month. |
double |
getCPI(int year,
int month,
int monthOffset)
This method returns the CPI for the given month offset from year and month. |
double |
getIndexRatio(java.util.Date datedDate,
java.util.Date settlementDate)
Returns the index ratio for a given datedDate and settlementDate. |
void |
loadCPIValues(java.io.InputStream inputStream)
Adds CPI data provided by an InputStream to this DefaultCPIFactory. |
void |
loadCPIValues(java.io.InputStream inputStream,
java.text.Format format)
Adds CPI data provided by an InputStream to this DefaultCPIFactory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultCPIFactory()
public DefaultCPIFactory(int earliestYear)
earliestYear - The earliest year available from this CPIFactory.
public DefaultCPIFactory(java.lang.String filePath)
throws java.io.IOException,
java.text.ParseException
filePath - The path to a file that contains the holiday dates.
java.io.IOException - Thrown when an IOException occurs.
java.text.ParseException - Thrown when the date is not parsable using a
SimpleDateFormat object with a mask of "M/yyyy".loadCPIValues( InputStream inputStream, Format format )
public DefaultCPIFactory(java.lang.String filePath,
int earliestYear)
throws java.io.IOException,
java.text.ParseException
filePath - The path to a file that contains the holiday dates.earliestYear - The earliest year available from this CPIFactory.
java.io.IOException - Thrown when an IOException occurs.
java.text.ParseException - Thrown when the date is not parsable using a
SimpleDateFormat object with a mask of "M/yyyy".loadCPIValues( InputStream inputStream, Format format )
public DefaultCPIFactory(java.io.InputStream inputStream)
throws java.io.IOException,
java.text.ParseException
inputStream - An InputStream that contains the holiday dates.
java.io.IOException - Thrown when an IOException occurs.
java.text.ParseException - Thrown when the date is not parsable using a
SimpleDateFormat object with a mask of "M/yyyy".loadCPIValues( InputStream inputStream, Format format )
public DefaultCPIFactory(java.io.InputStream inputStream,
java.text.Format format,
int earliestYear)
throws java.io.IOException,
java.text.ParseException
inputStream - An InputStream that contains the CPI data.format - A Format object used to parse the cpi dates contained
within the provided InputStream.earliestYear - The earliest year available from this CPIFactory.
java.io.IOException - Thrown when an IOException occurs.
java.text.ParseException - Thrown when the date is not parsable
using the given Format object.loadCPIValues( InputStream inputStream, Format format )| Method Detail |
|---|
public void clear()
public void loadCPIValues(java.io.InputStream inputStream)
throws java.io.IOException,
java.text.ParseException
inputStream - An InputStream that contains the holiday dates.
java.io.IOException - Thrown when an IOException occurs.
java.text.ParseException - Thrown when the date is not parsable
using a SimpleDateFormat object with a mask of "M/yyyy".
java.lang.NumberFormatException - Thrown if a CPI value is not
parsable as a double.loadCPIValues( InputStream inputStream, Format format )
public void loadCPIValues(java.io.InputStream inputStream,
java.text.Format format)
throws java.io.IOException,
java.text.ParseException
The dates in the stream must be parsable using the provided Format object. The CPI values must be parsable as a double. Each date and value should be separated with either a tab or an equal sign with the date being the key. Each date/value pair should be delimited with a carriage return and/or a linefeed. The order of the date/value pairs doesn't matter, however if there is a duplicate date, the CPI value of the last occurrance will be the value returned for that date.
Example :
03/2005 = 120.5 04/2005 = 121.0 05/2005 = 121.5
inputStream - An InputStream that contains the CPI data.format - A Format object used to parse the CPI dates contained
within the provided InputStream.
java.io.IOException - Thrown when an IOException occurs.
java.text.ParseException - Thrown when the date is not parsable using the given Format object.
java.lang.NumberFormatException - Thrown if a CPI value is not parsable as a double.
public void addCPIValue(java.util.Date date,
double cpiValue)
date - The CPI date.cpiValue - The CPI value.public double getCPI(java.util.Date date)
getCPI in interface CPIFactorydate - A Date
public double getCPI(java.util.Date date,
int monthOffset)
getCPI in interface CPIFactorydate - A datemonthOffset - number of months from the given month.
public double getCPI(int year,
int month)
getCPI in interface CPIFactoryyear - The yearmonth - The month
public double getCPI(int year,
int month,
int monthOffset)
getCPI in interface CPIFactoryyear - The yearmonth - The monthmonthOffset - Months from the given month.
public double getIndexRatio(java.util.Date datedDate,
java.util.Date settlementDate)
getIndexRatio in interface CPIFactorydatedDate - The datedDate of the Security.settlementDate - The settlementDate for a given transaction.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||