public final class TimeSchedule extends AbstractSchedule implements java.io.Serializable
toLast
property is specified, from the first day to the last day of the parent interval. When used as the
topmost definition for a schedule then this schedule specifies a single interval
of time starting on the current day.
To provide a schedule for each day at a certain time see the DailySchedule
schedules.
<schedules:time at="10:00" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>When used with a
Timer
this would run a job just once at 10am, and
never again. If the
timer was started after 10am, then the job would run the following day at 10am.
If it was required that the job would run any time the timer was started
after 10am then the
from
property should be used instead of the at
property.<schedules:time from="22:00" to="03:50" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"> <refinement> <schedules:interval interval="00:15"/> </refinement> </schedules:time>
toLast
property works.
<schedules:weekly from="Monday" to="Friday" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"> <refinement> <schedules:time from="08:00" toLast="18:00"> <refinement> <schedules:interval interval="02:00"/> </refinement> </schedules:time> </refinement> </schedules:weekly>The schedule would be due every two hours all day and all night from 8am Monday morning until 6pm Friday afternoon.
Constructor and Description |
---|
TimeSchedule() |
Modifier and Type | Method and Description |
---|---|
protected java.util.Calendar |
fromCalendar(ScheduleContext context) |
java.lang.String |
getFrom() |
java.lang.String |
getTo() |
java.lang.String |
getToLast() |
protected CalendarUnit |
intervalBetween() |
protected Interval |
lastInterval(ScheduleContext context)
Calculate the last interval.
|
ScheduleResult |
nextDue(ScheduleContext context)
For a given date a schedule will provide the interval this schedule
should next be scheduled in.
|
protected Interval |
nextInterval(ScheduleContext context)
/**
Calculate the next interval, without children.
|
protected java.util.Calendar |
nowCalendar(ScheduleContext context) |
void |
setAt(java.lang.String at) |
void |
setFrom(java.lang.String from) |
void |
setTo(java.lang.String to) |
void |
setToLast(java.lang.String toLast) |
protected java.util.Calendar |
shiftFromCalendar(java.util.Calendar calendar,
int intervals) |
protected java.util.Calendar |
shiftToCalendar(java.util.Calendar calendar,
int intervals) |
protected java.util.Calendar |
toCalendar(ScheduleContext context) |
java.lang.String |
toString()
Override toString.
|
getRefinement, setRefinement
public void setFrom(java.lang.String from)
Property: from
Description: The from time.
Required: No. Defaults to the start of any parent interval or the beginning of time.
from
- The from date.public java.lang.String getFrom()
public void setTo(java.lang.String to)
Property: to
Description: The to time. If specified, this is the time on the first day of the parent interval.
Required: No. Defaults to the end of the last day of the parent interval, or the end of time.
to
- The to date.public java.lang.String getTo()
public void setAt(java.lang.String at)
Property: at
Description: The time at which this schedule is for. This has the same effect as setting from and to to the same thing.
Required: No.
at
- The at time.public java.lang.String getToLast()
public void setToLast(java.lang.String toLast)
Property: toLast
Description: The to time for the end of the parent interval. This differs from the to property in that the to property is for the first day of the parent interval.
Required: No. The to property, or it's default value, will be used instead.
toLast
- The to last time of the interval.protected CalendarUnit intervalBetween()
protected java.util.Calendar fromCalendar(ScheduleContext context)
protected java.util.Calendar toCalendar(ScheduleContext context)
protected java.util.Calendar nowCalendar(ScheduleContext context)
context
- protected final Interval nextInterval(ScheduleContext context)
context
- protected final Interval lastInterval(ScheduleContext context)
context
- protected java.util.Calendar shiftFromCalendar(java.util.Calendar calendar, int intervals)
protected java.util.Calendar shiftToCalendar(java.util.Calendar calendar, int intervals)
public ScheduleResult nextDue(ScheduleContext context)
Schedule
If the schedule is never due again for the given date, null is returned.
public java.lang.String toString()
toString
in class java.lang.Object