mondrian.util
Class Schedule

java.lang.Object
  extended by mondrian.util.Schedule

public class Schedule
extends Object

A Schedule generates a series of time events.

Create a schedule using one of the factory methods:

Then use the nextOccurrence(java.util.Date, boolean) method to find the next occurrence after a particular point in time.

The begin and end parameters represent the points in time between which the schedule is active. Both are optional. However, if a schedule type supports a period parameter, and you supply a value greater than 1, begin is used to determine the start of the cycle. If begin is not specified, the cycle starts at the epoch (January 1st, 1970).

The Date parameters in this API -- begin and end, the time parameter to createOnce(java.util.Date, java.util.TimeZone), and the earliestDate parameter and value returned from nextOccurrence(java.util.Date, boolean) -- always represent a point in time (GMT), not a local time. If a schedule is to start at 12 noon Tokyo time, April 1st, 2002, it is the application's reponsibility to convert this into a UTC Date value.

Since:
May 7, 2002
Author:
jhyde
 

Field Summary
(package private) static int allDaysOfMonthBitmap
           
(package private) static int allDaysOfWeekBitmap
           
(package private) static int allWeeksOfMonthBitmap
           
static int LAST_DAY_OF_MONTH
          Indicates that a schedule should fire on the last day of the month.
static int LAST_WEEK_OF_MONTH
          Indicates that a schedule should fire on the last week of the month.
(package private) static TimeZone utcTimeZone
           
 
Method Summary
static Schedule createDaily(Date begin, Date end, TimeZone tz, Time timeOfDay, int period)
          Creates a calendar which fires every day.
static Schedule createMonthlyByDay(Date begin, Date end, TimeZone tz, Time timeOfDay, int period, int daysOfMonthBitmap)
          Creates a calendar which fires on particular days of each month.
static Schedule createMonthlyByWeek(Date begin, Date end, TimeZone tz, Time timeOfDay, int period, int daysOfWeekBitmap, int weeksOfMonthBitmap)
          Creates a calendar which fires on particular days of particular weeks of a month.
static Schedule createOnce(Date date, TimeZone tz)
          Creates a calendar which fires only once.
static Schedule createWeekly(Date begin, Date end, TimeZone tz, Time timeOfDay, int period, int daysOfWeekBitmap)
          Creates a calendar which fires on particular days each week.
 Date nextOccurrence(Date after, boolean strict)
          Returns the next occurrence of this schedule after a given date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAST_DAY_OF_MONTH

public static final int LAST_DAY_OF_MONTH
Indicates that a schedule should fire on the last day of the month.

See Also:
createMonthlyByDay(java.util.Date, java.util.Date, java.util.TimeZone, java.sql.Time, int, int), Constant Field Values

LAST_WEEK_OF_MONTH

public static final int LAST_WEEK_OF_MONTH
Indicates that a schedule should fire on the last week of the month.

See Also:
createMonthlyByWeek(java.util.Date, java.util.Date, java.util.TimeZone, java.sql.Time, int, int, int), Constant Field Values

utcTimeZone

static final TimeZone utcTimeZone

allDaysOfWeekBitmap

static final int allDaysOfWeekBitmap
See Also:
Constant Field Values

allDaysOfMonthBitmap

static final int allDaysOfMonthBitmap
See Also:
Constant Field Values

allWeeksOfMonthBitmap

static final int allWeeksOfMonthBitmap
See Also:
Constant Field Values
Method Detail

createOnce

public static Schedule createOnce(Date date,
                                  TimeZone tz)
Creates a calendar which fires only once.

Pre-condition:
tz != null, date != null
Post-condition:
return != null
Parameters:
date - date and time to fire, must be UTC
tz - timezone

createDaily

public static Schedule createDaily(Date begin,
                                   Date end,
                                   TimeZone tz,
                                   Time timeOfDay,
                                   int period)
Creates a calendar which fires every day.

Pre-condition:
tz != null, period > 0
Post-condition:
return != null
Parameters:
begin - open lower bound, may be null, must be UTC
end - closed upper bound, may be null, must be UTC
tz - timezone
timeOfDay - time at which to fire
period - causes the schedule to fire every period days. If period is greater than 1, the cycle starts at the begin point of the schedule, or at the epoch (1 January, 1970) if begin is not specified.

createWeekly

public static Schedule createWeekly(Date begin,
                                    Date end,
                                    TimeZone tz,
                                    Time timeOfDay,
                                    int period,
                                    int daysOfWeekBitmap)
Creates a calendar which fires on particular days each week.

Pre-condition:
tz != null, period > 0
Post-condition:
return != null
Parameters:
tz - timezone
daysOfWeekBitmap - a bitmap of day values, for example (1 << Calendar.TUESDAY) | (1 << Calendar.THURSDAY) to fire on Tuesdays and Thursdays
timeOfDay - time at which to fire
begin - open lower bound, may be null
end - closed upper bound, may be null
period - causes the schedule to be active every period weeks. If period is greater than 1, the cycle starts at the begin point of the schedule, or at the epoch (1 January, 1970) if begin is not specified.

createMonthlyByDay

public static Schedule createMonthlyByDay(Date begin,
                                          Date end,
                                          TimeZone tz,
                                          Time timeOfDay,
                                          int period,
                                          int daysOfMonthBitmap)
Creates a calendar which fires on particular days of each month. For example,
createMonthlyByDay(
     null, null, TimeZone.getTimeZone("PST"), 1,
     (1 << 12) | (1 << 14) | (1 << LAST_DAY_OF_MONTH))
creates a schedule which fires on the 12th, 14th and last day of the month.

Pre-condition:
tz != null, period > 0
Post-condition:
return != null
Parameters:
begin - open lower bound, may be null
end - closed upper bound, may be null
tz - timezone
daysOfMonthBitmap - a bitmap of day values, may include LAST_DAY_OF_MONTH
timeOfDay - time at which to fire
period - causes the schedule to be active every period months. If period is greater than 1, the cycle starts at the begin point of the schedule, or at the epoch (1 January, 1970) if begin is not specified.

createMonthlyByWeek

public static Schedule createMonthlyByWeek(Date begin,
                                           Date end,
                                           TimeZone tz,
                                           Time timeOfDay,
                                           int period,
                                           int daysOfWeekBitmap,
                                           int weeksOfMonthBitmap)
Creates a calendar which fires on particular days of particular weeks of a month. For example,
createMonthlyByWeek(
     null, null, TimeZone.getTimeZone("PST"),
     (1 << Calendar.TUESDAY) | (1 << Calendar.THURSDAY),
     (1 << 2) | (1 << LAST_WEEK_OF_MONTH)
creates a schedule which fires on the 2nd and last Tuesday and Thursday of the month.

Pre-condition:
tz != null, period > 0
Post-condition:
return != null
Parameters:
begin - open lower bound, may be null
end - closed upper bound, may be null
tz - timezone
daysOfWeekBitmap - a bitmap of day values, for example (1 << Calendar.TUESDAY) | (1 << Calendar.THURSDAY)
weeksOfMonthBitmap - a bitmap of week values (may include LAST_WEEK_OF_MONTH
timeOfDay - time at which to fire
period - causes the schedule be active every period months. If period is greater than 1, the cycle starts at the begin point of the schedule, or at the epoch (1 January, 1970) if begin is not specified.

nextOccurrence

public Date nextOccurrence(Date after,
                           boolean strict)
Returns the next occurrence of this schedule after a given date. If after is null, returns the first occurrence. If there are no further occurrences, returns null.

Parameters:
after - if not null, returns the first occurrence after this point in time; if null, returns the first occurrence ever.
strict - If after is an occurrence, strict determines whether this method returns it, or the next occurrence. If strict is true, the value returned is strictly greater than after.

SourceForge.net_Logo