comics.core
Class GregorianDayRoller

java.lang.Object
  extended bycomics.core.GregorianDayRoller
All Implemented Interfaces:
DayRoller

public class GregorianDayRoller
extends java.lang.Object
implements DayRoller

This class provides a DayRoller implementation, based on the GregorianCalendar by default. The defaults for the starting date are the current date and for the applicable days to be all days.

Author:
Lennart Martens

Constructor Summary
GregorianDayRoller()
          The default constructor creates a GregorianDayRoller using a GregorianCalendar for the Calendar implementation, the current date as the starting date and sets all days as applicable.
GregorianDayRoller(java.util.Calendar aStartDate, int[] aApplicableDays)
          This constructor allows the caller to set the GregorianDayRoller up in full.
GregorianDayRoller(java.util.Date aStartDate, int[] aApplicableDays)
          This constructor allows the caller to set the GregorianDayRoller up in full.
 
Method Summary
 java.util.Calendar getCurrentDate()
          This method returns the current date, or the first earlier applicable day.
 int getCurrentDayOfMonth()
          This method returns the current day of month (1-31)
 int getCurrentMonth()
          This method returns the current month (1-12)
 int getCurrentYear()
          This method returns the current year (4-digit notation, eg. 2003)
 java.lang.String getFormattedCurrentDate(java.lang.String aFormatter)
          This method returns the formatted current date, or the first earlier applicable day.
 java.util.Calendar getNextDay()
          This method returns the current Calendar instance rolled forward by the necessary amount of days to match the nearest future applicable day.
 java.util.Calendar getPreviousDay()
          This method returns the current Calendar instance rolled back by the necessary amount of days to match the nearest previous applicable day.
 void setApplicableDays(int[] aDays)
          This method allows the caller to specify which days should be reported.
 void setStartDate(java.util.Calendar aStartDate)
          This method allows the setting of a specific starting date via a specified Calendar.
 void setStartDate(java.util.Date aStartDate)
          This method allows the setting of a specific starting date via a specified Date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GregorianDayRoller

public GregorianDayRoller()
The default constructor creates a GregorianDayRoller using a GregorianCalendar for the Calendar implementation, the current date as the starting date and sets all days as applicable.


GregorianDayRoller

public GregorianDayRoller(java.util.Calendar aStartDate,
                          int[] aApplicableDays)
This constructor allows the caller to set the GregorianDayRoller up in full.

Parameters:
aStartDate - Calendar with a Calendar implementation set at the desired start date.
aApplicableDays - int[] with the applicable days; the elements of the array should all be one of the day constants defined on the Calendar interface. This parameter can be 'null' if all days are applicable.

GregorianDayRoller

public GregorianDayRoller(java.util.Date aStartDate,
                          int[] aApplicableDays)
This constructor allows the caller to set the GregorianDayRoller up in full.

Parameters:
aStartDate - Date with the desired start date. The Calendar used here by default will be the GregorianCalendar.
aApplicableDays - int[] with the applicable days; the elements of the array should all be one of the day constants defined on the Calendar interface. This parameter can be 'null' if all days are applicable.
Method Detail

getNextDay

public java.util.Calendar getNextDay()
This method returns the current Calendar instance rolled forward by the necessary amount of days to match the nearest future applicable day.

Specified by:
getNextDay in interface DayRoller
Returns:
Calendar with the nearest future applicable day

getPreviousDay

public java.util.Calendar getPreviousDay()
This method returns the current Calendar instance rolled back by the necessary amount of days to match the nearest previous applicable day.

Specified by:
getPreviousDay in interface DayRoller
Returns:
Calendar with the nearest previous applicable day

setApplicableDays

public void setApplicableDays(int[] aDays)
This method allows the caller to specify which days should be reported.

Specified by:
setApplicableDays in interface DayRoller
Parameters:
aDays - int[] with the integer codes for days as specified by the constants in the Calendar interface. Can be 'null' if all days are applicable.

setStartDate

public void setStartDate(java.util.Calendar aStartDate)
This method allows the setting of a specific starting date via a specified Calendar. Note that this Calendar instance will subsequently be used for rolling through the days.

Specified by:
setStartDate in interface DayRoller
Parameters:
aStartDate - Calendar with the desired start date.

setStartDate

public void setStartDate(java.util.Date aStartDate)
This method allows the setting of a specific starting date via a specified Date. Note that a GregorianCalendar instance will be created for rolling through the days.

Specified by:
setStartDate in interface DayRoller
Parameters:
aStartDate - Calendar with the desired start date.

getCurrentDayOfMonth

public int getCurrentDayOfMonth()
This method returns the current day of month (1-31)

Specified by:
getCurrentDayOfMonth in interface DayRoller
Returns:
int with the current day of the month (1-31)

getCurrentMonth

public int getCurrentMonth()
This method returns the current month (1-12)

Specified by:
getCurrentMonth in interface DayRoller
Returns:
int with the current month (1-12)

getCurrentYear

public int getCurrentYear()
This method returns the current year (4-digit notation, eg. 2003)

Specified by:
getCurrentYear in interface DayRoller
Returns:
int with the current year (4-digit notation, eg. 2003)

getCurrentDate

public java.util.Calendar getCurrentDate()
This method returns the current date, or the first earlier applicable day.

Specified by:
getCurrentDate in interface DayRoller
Returns:
Calendar with the current date, or the first previous applicable day

getFormattedCurrentDate

public java.lang.String getFormattedCurrentDate(java.lang.String aFormatter)
This method returns the formatted current date, or the first earlier applicable day. Formatting will be applied according to the specified String using a SimpleDateFormatter.

Specified by:
getFormattedCurrentDate in interface DayRoller
Returns:
String with the formatted current date, or the first previous applicable day.


Copyright © Lennart Martens. All Rights Reserved.