org.oddjob.schedules
Class ScheduleContext

java.lang.Object
  extended by org.oddjob.schedules.ScheduleContext

public class ScheduleContext
extends Object

A schedule context provides a context for the evaluation of a schedules next due interval.


Constructor Summary
ScheduleContext(Date now)
          Constructor for a new context with a date to evaluate from, and using the default time zone.
ScheduleContext(Date use, TimeZone timeZone)
          Constructor for a new context with a date to evaluate from, and a time zone to evaluate the schedule with.
ScheduleContext(Date now, TimeZone timeZone, Map<Object,Object> data)
          Constructor with a data map.
ScheduleContext(Date now, TimeZone timeZone, Map<Object,Object> data, Interval parentInterval)
          Constructor with a data map.
 
Method Summary
 Object getData(Object key)
          Get data back from the context data map.
 Date getDate()
          Get the date to evaluate the schedule with.
 Interval getParentInterval()
          The parent interval will be defined by a schedule and passed to it's child.
 TimeZone getTimeZone()
          Get the time zone to evaluate the schdule in.
 ScheduleContext move(Date date)
          Moves the existing context to one for a new date.
 void putData(Object key, Object value)
          Add data to the context data map.
 ScheduleContext spawn(Date date, Interval parentInterval)
          Create a new context from the existing one for a new parent interval and with an new context date.
 ScheduleContext spawn(Interval parentInterval)
          Create a new context with the existing time zone and data map, but a new parent interval.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScheduleContext

public ScheduleContext(Date now)
Constructor for a new context with a date to evaluate from, and using the default time zone.

Parameters:
now - The date to evaluate from.

ScheduleContext

public ScheduleContext(Date use,
                       TimeZone timeZone)
Constructor for a new context with a date to evaluate from, and a time zone to evaluate the schedule with.

Parameters:
use - The date to evaluate from.
timeZone - The time zone.

ScheduleContext

public ScheduleContext(Date now,
                       TimeZone timeZone,
                       Map<Object,Object> data)
Constructor with a data map.

Parameters:
now - The date to evaluate from. A null date is allowed and means the schedule will never be due.
timeZone - The time zone.
data - The data map.

ScheduleContext

public ScheduleContext(Date now,
                       TimeZone timeZone,
                       Map<Object,Object> data,
                       Interval parentInterval)
Constructor with a data map.

Parameters:
now - The date to evaluate from. A null date is allowed and means the schedule will never be due.
timeZone - The time zone.
data - The data map.
Method Detail

getDate

public Date getDate()
Get the date to evaluate the schedule with.

Returns:
The date to evaluate the schedule with. Never null.

getTimeZone

public TimeZone getTimeZone()
Get the time zone to evaluate the schdule in.

Returns:
The time zone, Never null.

putData

public void putData(Object key,
                    Object value)
Add data to the context data map.

Parameters:
key - The key.
value - The value.

getData

public Object getData(Object key)
Get data back from the context data map.

Parameters:
key - The key.
Returns:
The value.

getParentInterval

public Interval getParentInterval()
The parent interval will be defined by a schedule and passed to it's child. Schedules may use this interval to limit themselves.

Returns:

spawn

public ScheduleContext spawn(Interval parentInterval)
Create a new context with the existing time zone and data map, but a new parent interval. This is used when narrowing a schedule with a refinement.

Parameters:
parentInterval - The new constraining parent interval.
Returns:
A new context. Never null.

spawn

public ScheduleContext spawn(Date date,
                             Interval parentInterval)
Create a new context from the existing one for a new parent interval and with an new context date. Used when a evaluating a next date in a refinement.

Parameters:
date - The next date.
parentInterval - The new constraining parent interval.
Returns:
A new context. Never null.

move

public ScheduleContext move(Date date)
Moves the existing context to one for a new date. The parent interval, time zone and data map remain unchanged.

Parameters:
date - The date to shift the context to.
Returns:
A new context. never null.

toString

public String toString()
Overrides:
toString in class Object