|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objectnet.objectlab.kit.datecalc.common.AbstractDateCalculator<E>
E - a representation of a date, typically JDK: Date, Calendar;
Joda:LocalDate, YearMonthDaypublic abstract class AbstractDateCalculator<E>
Abstract implementation in order to encapsulate all the common functionality
between Jdk and Joda implementations. It is parametrized on
but basically Date and LocalDate are the only
viable values for it for now.
| Field Summary | |
|---|---|
protected static int |
DAYS_IN_WEEK
|
| Constructor Summary | |
|---|---|
protected |
AbstractDateCalculator(String name,
HolidayCalendar<E> holidayCalendar,
HolidayHandler<E> holidayHandler)
|
| Method Summary | |
|---|---|
List<E> |
calculateTenorDates(List<Tenor> tenors)
Calculate a series of Tenor codes in one go based on current day, this does NOT change the current business date. |
List<E> |
calculateTenorDates(List<Tenor> tenors,
int spotLag)
Calculate a series of Tenor codes in one go based on SPOT day (calculated with the spot lag), this does NOT change the current business date. |
protected abstract void |
checkBoundary(E date)
This may throw an IndexOutOfBoundsException if the date is not within the
boundaries. |
protected abstract E |
clone(E date)
|
DateCalculator<E> |
combine(DateCalculator<E> calculator)
Allows DateCalculators to be combined into a new one, the startDate and currentBusinessDate will be the ones from the existing calendar (not the parameter one). |
protected abstract E |
compareDate(E date1,
E date2,
boolean returnEarliest)
|
protected abstract DateCalculator<E> |
createNewCalculator(String calcName,
E theStartDate,
HolidayCalendar<E> holidays,
HolidayHandler<E> handler)
|
E |
getCurrentBusinessDate()
Gives the current business date held by the calculator. |
int |
getCurrentIncrement()
return the current increment in the calculator, this is used by the handler. |
HolidayCalendar<E> |
getHolidayCalendar()
Returns an immutable version of the HolidayCalendar. |
HolidayHandler<E> |
getHolidayHandler()
|
String |
getHolidayHandlerType()
Gives the name of the holiday handler algorithm, see HolidayHandlerType for some standard values. |
String |
getName()
This is typically the name of the associated set of holidays. |
E |
getStartDate()
Gives the startDate of this calculator (immutable once set via setStartDate). |
protected abstract E |
getToday()
|
boolean |
isCurrentDateNonWorking()
Is the current business day a non-working day, this is useful if the calculator does not have any algorithm to change the date when it falls on a non-working day. |
boolean |
isNonWorkingDay(E date)
is the given date a non working day? |
DateCalculator<E> |
moveByBusinessDays(int businessDays)
This changes the current business date held in the calculator, it moves the current date by a number of business days, this means that if a date is either a 'weekend' or holiday along the way, it will be skipped acording to the holiday handler and not count towards the number of days to move. |
protected abstract DateCalculator<E> |
moveByMonths(int months)
|
DateCalculator<E> |
moveByTenor(Tenor tenor)
Move the current date by a given tenor, please note that all tenors are relative to the CURRENT day (and NOT from spot). |
DateCalculator<E> |
moveByTenor(Tenor tenor,
int spotLag)
move the current date by a given tenor, this means that if a date is either a 'weekend' or holiday, it will be skipped acording to the holiday handler and not count towards the number of days to move. |
E |
setCurrentBusinessDate(E date)
Gives a current business date, it may be moved acording to the HolidayHandler algorithm if it falls on a non-working day. |
void |
setCurrentIncrement(int currentIncrement)
This would be used by delegate methods to detect if the increment if positive or negative (this will allow us to define a Handler that can act as Forward if positive and Backward if negative). |
void |
setHolidayCalendar(HolidayCalendar<E> calendar)
This is typically used at the construction of a DateCalculator to give a reference to a Holiday Calendar, if not the case, the calculator will make an immutable copy of the HolidayCalendar. |
void |
setHolidayHandler(HolidayHandler<E> holidayHandler)
|
void |
setName(String name)
|
void |
setStartDate(E startDate)
Set both start date and current date |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface net.objectlab.kit.datecalc.common.DateCalculator |
|---|
isWeekend, moveByDays, setWorkingWeek |
| Field Detail |
|---|
protected static final int DAYS_IN_WEEK
| Constructor Detail |
|---|
protected AbstractDateCalculator(String name,
HolidayCalendar<E> holidayCalendar,
HolidayHandler<E> holidayHandler)
| Method Detail |
|---|
public void setHolidayCalendar(HolidayCalendar<E> calendar)
DateCalculator
setHolidayCalendar in interface DateCalculator<E>calendar - the holiday calendar (if null, no holidays taken into account)public String getName()
DateCalculator
getName in interface DateCalculator<E>public void setName(String name)
public E getStartDate()
DateCalculator
getStartDate in interface DateCalculator<E>public void setStartDate(E startDate)
setStartDate in interface DateCalculator<E>startDate - the reference date for this calculator, the current business
date is also updated and may be moved if it falls on a non
working day (holiday/weekend).public E getCurrentBusinessDate()
DateCalculator
getCurrentBusinessDate in interface DateCalculator<E>
public DateCalculator<E> moveByTenor(Tenor tenor,
int spotLag)
moveByTenor in interface DateCalculator<E>tenor - the tenor.spotLag - number of days to "spot" days, this can vary from one market
to the other.
public DateCalculator<E> moveByTenor(Tenor tenor)
moveByTenor in interface DateCalculator<E>tenor - the Tenor to reach.
public List<E> calculateTenorDates(List<Tenor> tenors)
calculateTenorDates in interface DateCalculator<E>
public List<E> calculateTenorDates(List<Tenor> tenors,
int spotLag)
calculateTenorDates in interface DateCalculator<E>protected abstract DateCalculator<E> moveByMonths(int months)
public void setHolidayHandler(HolidayHandler<E> holidayHandler)
public String getHolidayHandlerType()
DateCalculator
getHolidayHandlerType in interface DateCalculator<E>public boolean isNonWorkingDay(E date)
isNonWorkingDay in interface DateCalculator<E>protected abstract void checkBoundary(E date)
IndexOutOfBoundsException if the date is not within the
boundaries.
date - public boolean isCurrentDateNonWorking()
DateCalculator
isCurrentDateNonWorking in interface DateCalculator<E>public E setCurrentBusinessDate(E date)
DateCalculator
setCurrentBusinessDate in interface DateCalculator<E>public HolidayHandler<E> getHolidayHandler()
public DateCalculator<E> moveByBusinessDays(int businessDays)
DateCalculator
moveByBusinessDays in interface DateCalculator<E>businessDays - (can be <0 or >0)
public DateCalculator<E> combine(DateCalculator<E> calculator)
combine in interface DateCalculator<E>calculator - return the same DateCalculator if calender is null or the
original calendar (but why would you want to do that?)
IllegalArgumentException - if both calendars have different types of HolidayHandlers or
WorkingWeek;protected abstract E getToday()
protected abstract E compareDate(E date1,
E date2,
boolean returnEarliest)
protected abstract DateCalculator<E> createNewCalculator(String calcName,
E theStartDate,
HolidayCalendar<E> holidays,
HolidayHandler<E> handler)
public int getCurrentIncrement()
DateCalculator
getCurrentIncrement in interface DateCalculator<E>public void setCurrentIncrement(int currentIncrement)
DateCalculator
setCurrentIncrement in interface DateCalculator<E>currentIncrement - The currentIncrement to set.public HolidayCalendar<E> getHolidayCalendar()
DateCalculator
getHolidayCalendar in interface DateCalculator<E>protected abstract E clone(E date)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||