org.oddjob.schedules.schedules
Class YearlySchedule

java.lang.Object
  extended by org.oddjob.schedules.AbstractSchedule
      extended by org.oddjob.schedules.ConstrainedSchedule
          extended by org.oddjob.schedules.schedules.YearlySchedule
All Implemented Interfaces:
Serializable, RefineableSchedule, Schedule

public final class YearlySchedule
extends ConstrainedSchedule
implements Serializable

Description

A schedule for the periods of the year. The periods may be specified either as the dates of days of the year or as months.

The format for dates is MM-dd, i.e. 03-02 is The second of March.

The format for months is either the month number, 1 to 12 or one of JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER (case insensitive).

Description

A schedule for a range of months, or a month. The month is specified as an integer between 1 and 12 where 1 is January and 12 is December.

Example

A schedule for two different month ranges. From April to September the job will run daily at 10 am, and from October to March the job will run daily at 11 am.
<schedules:list xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <schedules>
        <schedules:yearly fromMonth="4" toMonth="9">
            <refinement>
                <schedules:daily at="10:00"/>
            </refinement>
        </schedules:yearly>
        <schedules:yearly fromMonth="10" toMonth="3">
            <refinement>
                <schedules:daily at="11:00"/>
            </refinement>
        </schedules:yearly>
    </schedules>
</schedules:list>
Instead of month numbers, English month names can be used. This is equivalent to the above.
<schedules:list xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <schedules>
        <schedules:yearly fromMonth="April" toMonth="September">
            <refinement>
                <schedules:daily at="10:00"/>
            </refinement>
        </schedules:yearly>
        <schedules:yearly fromMonth="October" toMonth="March">
            <refinement>
                <schedules:daily at="11:00"/>
            </refinement>
        </schedules:yearly>
    </schedules>
</schedules:list>

Example

A from day of year to day of year example.
<schedules:yearly fromDate="12-25" toDate="12-26" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>

Example

An on day of year example.
<schedules:yearly onDate="01-01" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>
See Also:
Serialized Form
Author:
Rob Gordon

Field Summary
static Pattern DAY_FORMAT
           
 
Constructor Summary
YearlySchedule()
           
 
Method Summary
protected  Calendar fromCalendar(Date referenceDate, TimeZone timeZone)
          Provide a Calendar for the start of the constraint.
 String getFromDate()
           
 Month getFromMonth()
           
 String getToDate()
           
 Month getToMonth()
           
protected  CalendarUnit intervalBetween()
          Sub classes must provide a unit which is what must be added to move the schedule on.
 void setFromDate(String from)
           
 void setFromMonth(Month from)
           
 void setInMonth(Month in)
           
 void setOnDate(String on)
           
 void setToDate(String to)
           
 void setToMonth(Month to)
           
protected  Calendar toCalendar(Date referenceDate, TimeZone timeZone)
          Provide a Calendar for the end of the constraint.
 String toString()
          Override toString.
 
Methods inherited from class org.oddjob.schedules.ConstrainedSchedule
lastInterval, nextDue, nextInterval, shiftFromCalendar, shiftToCalendar
 
Methods inherited from class org.oddjob.schedules.AbstractSchedule
getRefinement, setRefinement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DAY_FORMAT

public static final Pattern DAY_FORMAT
Constructor Detail

YearlySchedule

public YearlySchedule()
Method Detail

setFromMonth

public void setFromMonth(Month from)

getFromMonth

public Month getFromMonth()

setToMonth

public void setToMonth(Month to)

getToMonth

public Month getToMonth()

setInMonth

public void setInMonth(Month in)

Property: inMonth

Description: The month in which this schedule is for. This has the same effect as setting fromMonth and toMonth to the same thing.

Required: No.

Parameters:
in - The in month.

setFromDate

public void setFromDate(String from)

getFromDate

public String getFromDate()

setToDate

public void setToDate(String to)

getToDate

public String getToDate()

setOnDate

public void setOnDate(String on)

Property: onDate

Description: The day on which this schedule is for. This has the same effect as setting fromDate and toDate to the same thing.

Required: No.

Parameters:
on - The day on which this schedule is for.

intervalBetween

protected CalendarUnit intervalBetween()
Description copied from class: ConstrainedSchedule
Sub classes must provide a unit which is what must be added to move the schedule on. I.e. the equivalent of a day, week, month etc.

Specified by:
intervalBetween in class ConstrainedSchedule
Returns:

fromCalendar

protected Calendar fromCalendar(Date referenceDate,
                                TimeZone timeZone)
Description copied from class: ConstrainedSchedule
Provide a Calendar for the start of the constraint.

Specified by:
fromCalendar in class ConstrainedSchedule
Parameters:
referenceDate - The date/time now.
timeZone - The time zone.
Returns:
A calendar for the from time.

toCalendar

protected Calendar toCalendar(Date referenceDate,
                              TimeZone timeZone)
Description copied from class: ConstrainedSchedule
Provide a Calendar for the end of the constraint.

Specified by:
toCalendar in class ConstrainedSchedule
Parameters:
referenceDate - The date/time now.
timeZone - The time zone.
Returns:
A calendar for the end time.

toString

public String toString()
Override toString.

Specified by:
toString in class ConstrainedSchedule
Returns:
A description of the schedule.