org.oddjob.schedules.schedules
Class BrokenSchedule

java.lang.Object
  extended by org.oddjob.schedules.schedules.BrokenSchedule
All Implemented Interfaces:
Serializable, Schedule

public class BrokenSchedule
extends Object
implements Serializable, Schedule

Description

This schedule allows a normal schedule to be broken by the results of another schedule. This might be a list of bank holidays, or time of day, or any other schedule.

This schedule works by moving the schedule forward if the start time of the next interval falls within the next interval defined by the break. In the example below for a time of Midday on 24th of December the logic is as follows:

The optional alternative property defines a schedule to be used during the breaks, instead of simply moving the interval forward.

Example

A schedule that breaks for Christmas.
<schedules:broken xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <schedule>
        <schedules:daily at="10:00"/>
    </schedule>
    <breaks>
        <schedules:yearly fromDate="12-25" toDate="12-26"/>
    </breaks>
</schedules:broken>
The logic is explained above.

Example

A schedule with an alternative. The schedule breaks at weekends and for Christmas. During the break the schedule will be due once at 11am the first day of the break, instead of the usual 10am.
<schedules:broken xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <schedule>
         <schedules:daily from="10:00"/>
    </schedule>
    <breaks>
        <schedules:list>
            <schedules>
                <schedules:weekly from="Saturday" to="Sunday"/>
                <schedules:date on="2011-12-26"/>
                <schedules:date on="2011-12-27"/>
            </schedules>
        </schedules:list>        
    </breaks>
    <alternative>
        <schedules:time from="11:00"/>
    </alternative>
</schedules:broken>

Example

Examples elsewhere.
See Also:
Serialized Form
Author:
Rob Gordon

Constructor Summary
BrokenSchedule()
           
 
Method Summary
 Schedule getAlternative()
           
 Schedule getBreaks()
          Get the breaks which will break up the schedule.
 Schedule getSchedule()
          Get the schedule to break up.
 ScheduleResult nextDue(ScheduleContext context)
          Implement the schedule.
 void setAlternative(Schedule alternative)
           
 void setBreaks(Schedule breaks)
          Set the breaks which will break up the schedule.
 void setSchedule(Schedule schedule)
          Set the schedule to break up.
 String toString()
          Provide a simple string description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BrokenSchedule

public BrokenSchedule()
Method Detail

setSchedule

public void setSchedule(Schedule schedule)
Set the schedule to break up.

Parameters:
schedule - The schedule to break up.

getSchedule

public Schedule getSchedule()
Get the schedule to break up.

Returns:
The schedule to break up.

setBreaks

public void setBreaks(Schedule breaks)
Set the breaks which will break up the schedule.

Parameters:
breaks - The breaks schedule.

getBreaks

public Schedule getBreaks()
Get the breaks which will break up the schedule.

Returns:
The break Schedule.

getAlternative

public Schedule getAlternative()

setAlternative

public void setAlternative(Schedule alternative)

nextDue

public ScheduleResult nextDue(ScheduleContext context)
Implement the schedule.

Specified by:
nextDue in interface Schedule
Returns:
The next due interval for the schedule.

toString

public String toString()
Provide a simple string description.

Overrides:
toString in class Object