com.ftlabs.fisa.calc
Class CouponDateGenerator

java.lang.Object
  extended by com.ftlabs.fisa.calc.CouponDateGenerator
All Implemented Interfaces:
java.io.Serializable

public final class CouponDateGenerator
extends java.lang.Object
implements java.io.Serializable

A class to efficiently calculate the next or previous coupon payment date, or quasi coupon payment date.

See Also:
Serialized Form

Constructor Summary
CouponDateGenerator(int interestFrequency, boolean eomAdjust)
          Create a new CouponDateGenerator using the provided interestFrequency and eomAdjust setting.
 
Method Summary
 FISADate current()
          Returns a new FISADate to represent the current coupon date or quasi coupon date.
 void current(FISADate date)
          Sets the provided date to the current coupon date or quasi coupon date.
 int currentAsInteger()
          Returns the current coupon date or quasi coupon date as an integer, formatted as ( year * 10000 ) + ( month * 100 ) + day.
protected  byte getLDOM()
          Get the last day of the month.
protected static byte getLDOM(int year, int month)
          Get the last day of the month.
static FISADate getNext(FISADate settlementDate, FISADate synchronizeDate, int interestFrequency, boolean eomAdjust)
           
static void getNext(FISADate settlementDate, FISADate synchronizeDate, int interestFrequency, boolean eomAdjust, FISADate nextCouponDate)
           
static FISADate getNext(FISADate currentCouponDate, int interestFrequency, boolean eomAdjust)
           
static void getNext(FISADate currentCouponDate, int interestFrequency, boolean eomAdjust, FISADate nextCouponDate)
           
static FISADate getNext(FISADate currentCouponDate, int periodCount, int interestFrequency, boolean eomAdjust)
           
static void getNext(FISADate currentCouponDate, int periodCount, int interestFrequency, boolean eomAdjust, FISADate nextCouponDate)
           
static FISADate getPrev(FISADate currentCouponDate, int interestFrequency, boolean eomAdjust)
           
static void getPrev(FISADate currentCouponDate, int interestFrequency, boolean eomAdjust, FISADate prevCouponDate)
           
static FISADate getPrev(FISADate currentCouponDate, int periodCount, int interestFrequency, boolean eomAdjust)
           
static void getPrev(FISADate currentCouponDate, int periodCount, int interestFrequency, boolean eomAdjust, FISADate prevCouponDate)
           
 void moveNext()
          Move to the next coupon date or quasi coupon date.
 void moveNext(int periodCount)
          Move forward a number of periods as specified by periodCount.
 void movePrev()
          Move to the previous coupon date or quasi coupon date.
 void movePrev(int periodCount)
          Move backward a number of periods as specified by periodCount.
 FISADate next()
          Moves to the next coupon date or quasi coupon date and returns a new FISADate to represent that date.
 void next(FISADate date)
          Moves to the next coupon date or quasi coupon date and sets the provided date to that date.
 FISADate next(int periodCount)
          Move forward a number of periods as specified by periodCount and return the ending period date.
 void next(int periodCount, FISADate date)
          Move forward a number of periods as specified by periodCount and set the provided date to represent the ending period date.
 FISADate prev()
          Moves to the previous coupon date or quasi coupon date and returns a new FISADate to represent that date.
 void prev(FISADate date)
          Moves to the previous coupon date or quasi coupon date and sets the provided date to that date.
 FISADate prev(int periodCount)
          Move backward a number of periods as specified by periodCount and return the ending period date.
 void prev(int periodCount, FISADate date)
          Move backward a number of periods as specified by periodCount and set the provided date to represent the ending period date.
 void setCurrent(FISADate date)
          Sets the current coupon date or quasi coupon date.
 void setToSettlementPeriod(FISADate settlementDate, FISADate lastInterestDate)
          Sets the current coupon date or quasi coupon date to be the next coupon date after the provided settlement date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CouponDateGenerator

public CouponDateGenerator(int interestFrequency,
                           boolean eomAdjust)
Create a new CouponDateGenerator using the provided interestFrequency and eomAdjust setting.

Parameters:
interestFrequency - The number of interest payments within a year.
eomAdjust - Determines whether to use the End Of Month Adjustment rule or not.
Method Detail

moveNext

public void moveNext(int periodCount)
Move forward a number of periods as specified by periodCount.

Parameters:
periodCount - The number of periods to move forward.

next

public void next(int periodCount,
                 FISADate date)
Move forward a number of periods as specified by periodCount and set the provided date to represent the ending period date.

Parameters:
periodCount - The number of periods to move forward.
date - A date to store the ending coupon period date.

next

public FISADate next(int periodCount)
Move forward a number of periods as specified by periodCount and return the ending period date.

Parameters:
periodCount - The number of periods to move forward.
Returns:
The ending period date.

moveNext

public final void moveNext()
Move to the next coupon date or quasi coupon date. This method doesn't allocate any new objects.


next

public final FISADate next()
Moves to the next coupon date or quasi coupon date and returns a new FISADate to represent that date.

Returns:
The next coupon date or quasi coupon date.

next

public final void next(FISADate date)
Moves to the next coupon date or quasi coupon date and sets the provided date to that date. This method is preferable to FISADate next(), since this method doesn't create any new objects.

Parameters:
date - A FISADate that will be set to the next coupon date or quasi coupon date.

movePrev

public void movePrev(int periodCount)
Move backward a number of periods as specified by periodCount.

Parameters:
periodCount - The number of periods to move backward.

prev

public void prev(int periodCount,
                 FISADate date)
Move backward a number of periods as specified by periodCount and set the provided date to represent the ending period date.

Parameters:
periodCount - The number of periods to move backward.
date - A date to store the ending coupon period date.

prev

public FISADate prev(int periodCount)
Move backward a number of periods as specified by periodCount and return the ending period date.

Parameters:
periodCount - The number of periods to move backward.
Returns:
The ending period date.

movePrev

public final void movePrev()
Move to the previous coupon date or quasi coupon date. This method doesn't allocate any new objects.


prev

public final FISADate prev()
Moves to the previous coupon date or quasi coupon date and returns a new FISADate to represent that date.

Returns:
The previous coupon date or quasi coupon date.

prev

public final void prev(FISADate date)
Moves to the previous coupon date or quasi coupon date and sets the provided date to that date. This method is preferable to FISADate prev(), since this method doesn't create any new objects.

Parameters:
date - A FISADate that will be set to the previous coupon date or quasi coupon date.

current

public final FISADate current()
Returns a new FISADate to represent the current coupon date or quasi coupon date.

Returns:
The current coupon date or quasi coupon date.

current

public final void current(FISADate date)
Sets the provided date to the current coupon date or quasi coupon date. This method is preferable to FISADate current(), since this method doesn't create any new objects.

Parameters:
date - A FISADate that will be set to the current coupon date or quasi coupon date.

currentAsInteger

public final int currentAsInteger()
Returns the current coupon date or quasi coupon date as an integer, formatted as ( year * 10000 ) + ( month * 100 ) + day. This is used to efficiently compare to FISADates without allocating any new objects.


setCurrent

public final void setCurrent(FISADate date)
Sets the current coupon date or quasi coupon date.

Parameters:
date - The current coupon date or quasi coupon date.

setToSettlementPeriod

public final void setToSettlementPeriod(FISADate settlementDate,
                                        FISADate lastInterestDate)
Sets the current coupon date or quasi coupon date to be the next coupon date after the provided settlement date.

Parameters:
settlementDate - The settlement date.
lastInterestDate - The interest date just prior to redemption for odd last periods, or the redemption date for normal length periods.

getLDOM

protected final byte getLDOM()
Get the last day of the month.

Returns:
The last day of the month.

getLDOM

protected static final byte getLDOM(int year,
                                    int month)
Get the last day of the month.

Returns:
The last day of the month.

getNext

public static final FISADate getNext(FISADate currentCouponDate,
                                     int interestFrequency,
                                     boolean eomAdjust)

getNext

public static final void getNext(FISADate currentCouponDate,
                                 int interestFrequency,
                                 boolean eomAdjust,
                                 FISADate nextCouponDate)

getNext

public static final FISADate getNext(FISADate currentCouponDate,
                                     int periodCount,
                                     int interestFrequency,
                                     boolean eomAdjust)

getNext

public static final void getNext(FISADate currentCouponDate,
                                 int periodCount,
                                 int interestFrequency,
                                 boolean eomAdjust,
                                 FISADate nextCouponDate)

getPrev

public static final FISADate getPrev(FISADate currentCouponDate,
                                     int interestFrequency,
                                     boolean eomAdjust)

getPrev

public static final void getPrev(FISADate currentCouponDate,
                                 int interestFrequency,
                                 boolean eomAdjust,
                                 FISADate prevCouponDate)

getPrev

public static final FISADate getPrev(FISADate currentCouponDate,
                                     int periodCount,
                                     int interestFrequency,
                                     boolean eomAdjust)

getPrev

public static final void getPrev(FISADate currentCouponDate,
                                 int periodCount,
                                 int interestFrequency,
                                 boolean eomAdjust,
                                 FISADate prevCouponDate)

getNext

public static final FISADate getNext(FISADate settlementDate,
                                     FISADate synchronizeDate,
                                     int interestFrequency,
                                     boolean eomAdjust)

getNext

public static final void getNext(FISADate settlementDate,
                                 FISADate synchronizeDate,
                                 int interestFrequency,
                                 boolean eomAdjust,
                                 FISADate nextCouponDate)