com.scalagent.scheduler.event.PeriodicEvent Class Reference

Inherits com.scalagent.scheduler.event.DiaryEvent.

Inherited by com.scalagent.scheduler.event.BasedPeriodicEvent.

Inheritance diagram for com.scalagent.scheduler.event.PeriodicEvent:

Inheritance graph
[legend]
Collaboration diagram for com.scalagent.scheduler.event.PeriodicEvent:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PeriodicEvent (String timeZoneId, long refDate, DiaryPeriod period, int[] maskField, int[] maskValue)
 PeriodicEvent (String timeZoneId, long refDate, DiaryPeriod period)
 PeriodicEvent (long refDate, DiaryPeriod period)
 PeriodicEvent ()
void setTimeZoneId (String timeZoneId)
String getTimeZoneId ()
void setRefDate (long refDate)
long getRefDate ()
void setPeriod (DiaryPeriod period)
DiaryPeriod getPeriod ()
void setMaskField (int[] maskField)
int[] getMaskField ()
void setMaskValue (int[] maskValue)
int[] getMaskValue ()
boolean validateMask ()
String toString ()
long getNextDate (long now, boolean inclusive)
long getNextDate (long now)
long getLastDate (long now, boolean inclusive)
long getLastDate (long now)

Static Public Member Functions

static long getDate (long refDate, DiaryPeriod period)
static boolean checkField (Calendar calendar, int field, int value)

Protected Member Functions

void applyMask ()
boolean checkMask ()

Protected Attributes

String timeZoneId = null
long refDate = -1
DiaryPeriod period = null
int[] maskField = null
int[] maskValue = null
Calendar calendar

Detailed Description

A PeriodicEvent object implements a repetitive event defined by a reference date and a time period. The time period is qualified with a time unit, so that user meaningful periods may be defined, even though they are variable in length (such as a day, a month, and so on).

The reference date is used internally to keep track of the last computed event occurrence.

Definition at line 40 of file PeriodicEvent.java.


Constructor & Destructor Documentation

com.scalagent.scheduler.event.PeriodicEvent.PeriodicEvent ( String  timeZoneId,
long  refDate,
DiaryPeriod  period,
int[]  maskField,
int[]  maskValue 
)

Constructor setting all fields. May need a call to validateMask if maskField is not null.

Parameters:
timeZoneId id of the time zone to be used when computing dates
refDate reference date from which event dates are computed
period period definition
maskField mask of fields to match event dates, as Calendar constants
maskValue values of corresponding fields in maskField

Definition at line 177 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.calendar, and com.scalagent.scheduler.event.PeriodicEvent.period.

com.scalagent.scheduler.event.PeriodicEvent.PeriodicEvent ( String  timeZoneId,
long  refDate,
DiaryPeriod  period 
)

Constructor with no mask.

Parameters:
timeZoneId id of the time zone to be used when computing dates
refDate reference date from which event dates are computed
period period definition

Definition at line 206 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.period.

com.scalagent.scheduler.event.PeriodicEvent.PeriodicEvent ( long  refDate,
DiaryPeriod  period 
)

Constructor with default time zone.

Parameters:
refDate reference date from which event dates are computed
period period definition

Definition at line 216 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.period.

com.scalagent.scheduler.event.PeriodicEvent.PeriodicEvent (  ) 

Default constructor. Creates an event with a null date and no repeat period.

Definition at line 224 of file PeriodicEvent.java.

Referenced by com.scalagent.scheduler.event.PeriodicEvent.getDate().


Member Function Documentation

static long com.scalagent.scheduler.event.PeriodicEvent.getDate ( long  refDate,
DiaryPeriod  period 
) [static]

Provides an internal computation facility to others, unrelated to any specific PeriodicEvent object.

Parameters:
refDate reference date from which the result date is computed
period period definition to add to refDate
Returns:
refDate + period

Definition at line 54 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.getNextDate(), com.scalagent.scheduler.event.PeriodicEvent.period, com.scalagent.scheduler.event.PeriodicEvent.PeriodicEvent(), and com.scalagent.scheduler.event.DiaryPeriod.value.

Here is the call graph for this function:

static boolean com.scalagent.scheduler.event.PeriodicEvent.checkField ( Calendar  calendar,
int  field,
int  value 
) [static]

Checks a field value of a calendar against a reference value. Handles some special -1 cases.

Parameters:
calendar reference date to check
field field identifier, as a Calendar constant
value reference value, may be negative
Returns:
true if values match

Definition at line 71 of file PeriodicEvent.java.

Referenced by com.scalagent.scheduler.event.PeriodicEvent.validateMask().

void com.scalagent.scheduler.event.PeriodicEvent.setTimeZoneId ( String  timeZoneId  ) 

Field accessor.

Parameters:
timeZoneId id of the time zone to be used when computing dates

Definition at line 233 of file PeriodicEvent.java.

String com.scalagent.scheduler.event.PeriodicEvent.getTimeZoneId (  ) 

Field accessor.

Returns:
id of the time zone to be used when computing dates

Definition at line 242 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.timeZoneId.

void com.scalagent.scheduler.event.PeriodicEvent.setRefDate ( long  refDate  ) 

Field accessor. May need an additional call to validateMask.

Parameters:
refDate reference date from which event dates are computed

Definition at line 251 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.calendar.

Referenced by com.scalagent.scheduler.event.BasedPeriodicEvent.setBaseDate().

long com.scalagent.scheduler.event.PeriodicEvent.getRefDate (  ) 

Field accessor.

Returns:
reference date from which event dates are computed

Definition at line 262 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.refDate.

void com.scalagent.scheduler.event.PeriodicEvent.setPeriod ( DiaryPeriod  period  ) 

Field accessor.

Parameters:
period period definition

Definition at line 271 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.period.

DiaryPeriod com.scalagent.scheduler.event.PeriodicEvent.getPeriod (  ) 

Field accessor.

Returns:
period definition

Definition at line 280 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.period.

void com.scalagent.scheduler.event.PeriodicEvent.setMaskField ( int[]  maskField  ) 

Field accessor.

Parameters:
maskField mask of fields to match event dates, as Calendar constants

Definition at line 290 of file PeriodicEvent.java.

int [] com.scalagent.scheduler.event.PeriodicEvent.getMaskField (  ) 

Field accessor.

Returns:
mask of fields to match event dates

Definition at line 302 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.maskField.

void com.scalagent.scheduler.event.PeriodicEvent.setMaskValue ( int[]  maskValue  ) 

Field accessor.

Parameters:
maskValue values of corresponding fields in maskField

Definition at line 312 of file PeriodicEvent.java.

int [] com.scalagent.scheduler.event.PeriodicEvent.getMaskValue (  ) 

Field accessor.

Returns:
values of corresponding fields in maskField

Definition at line 324 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.maskValue.

boolean com.scalagent.scheduler.event.PeriodicEvent.validateMask (  ) 

Checks the consistency of the four fields refDate, period, maskField, and maskValue. Updates maskValue when null.

Legal (period/maskField) combinations are (YEAR/DAY_OF_YEAR), (YEAR/WEEK_OF_YEAR(&DAY_OF_WEEK)), (YEAR/MONTH&DAY_OF_MONTH), (YEAR/MONTH&WEEK_OF_MONTH(&DAY_OF_WEEK)), (YEAR/MONTH&DAY_OF_WEEK_IN_MONTH(&DAY_OF_WEEK)), (MONTH/DAY_OF_MONTH), (MONTH/WEEK_OF_MONTH(&DAY_OF_WEEK)), (MONTH/DAY_OF_WEEK_IN_MONTH(&DAY_OF_WEEK)). The optional DAY_OF_WEEK mask value may be retrieved from the reference date.

Returns:
true when all three values are consistent, false otherwise.

Definition at line 349 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.calendar, com.scalagent.scheduler.event.PeriodicEvent.checkField(), com.scalagent.scheduler.event.PeriodicEvent.maskField, com.scalagent.scheduler.event.PeriodicEvent.maskValue, com.scalagent.scheduler.event.PeriodicEvent.period, com.scalagent.scheduler.event.PeriodicEvent.refDate, and com.scalagent.scheduler.event.DiaryPeriod.unit.

Here is the call graph for this function:

String com.scalagent.scheduler.event.PeriodicEvent.toString (  ) 

Provides a string image for this object.

Returns:
string image for this object

Definition at line 663 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.maskField, com.scalagent.scheduler.event.PeriodicEvent.maskValue, com.scalagent.scheduler.event.PeriodicEvent.period, com.scalagent.scheduler.event.PeriodicEvent.refDate, and com.scalagent.scheduler.event.PeriodicEvent.timeZoneId.

void com.scalagent.scheduler.event.PeriodicEvent.applyMask (  )  [protected]

Applies the mask on the calendar.

Definition at line 690 of file PeriodicEvent.java.

References com.scalagent.scheduler.event.PeriodicEvent.calendar, com.scalagent.scheduler.event.PeriodicEvent.maskField, and com.scalagent.scheduler.event.PeriodicEvent.maskValue.

boolean com.scalagent.scheduler.event.PeriodicEvent.checkMask (  )  [protected]

Checks that the calendar conforms to the mask.

Definition at line 719 of file PeriodicEvent.java.

long com.scalagent.scheduler.event.PeriodicEvent.getNextDate ( long  now,
boolean  inclusive 
)

Gets the next event date after the parameter date. Returns -1 if there is no such date.

Parameters:
now starting date for the lookup
inclusive if true checks now as an answer
Returns:
the next event date after now, -1 if there is no such date

Implements com.scalagent.scheduler.event.DiaryEvent.

Definition at line 744 of file PeriodicEvent.java.

Referenced by com.scalagent.scheduler.event.PeriodicEvent.getDate().

long com.scalagent.scheduler.event.PeriodicEvent.getNextDate ( long  now  ) 

Gets the next event date after the parameter date. Returns -1 if there is no such date. Calls getNextDate with the inclusive parameter set to false.

Parameters:
now starting date for the lookup
Returns:
the next event date after now, -1 if there is no such date

Implements com.scalagent.scheduler.event.DiaryEvent.

Definition at line 760 of file PeriodicEvent.java.

long com.scalagent.scheduler.event.PeriodicEvent.getLastDate ( long  now,
boolean  inclusive 
)

Gets the last event date before the parameter date. Returns -1 if there is no such date.

Parameters:
now starting date for the backward lookup
inclusive if true checks now as an answer
Returns:
the last event date before now, -1 if there is no such date

Implements com.scalagent.scheduler.event.DiaryEvent.

Definition at line 776 of file PeriodicEvent.java.

long com.scalagent.scheduler.event.PeriodicEvent.getLastDate ( long  now  ) 

Gets the last event date before the parameter date. Returns -1 if there is no such date. Calls getLastDate with the inclusive parameter set to false.

Parameters:
now starting date for the backward lookup
Returns:
the last event date before now, -1 if there is no such date

Implements com.scalagent.scheduler.event.DiaryEvent.

Definition at line 792 of file PeriodicEvent.java.


Member Data Documentation

String com.scalagent.scheduler.event.PeriodicEvent.timeZoneId = null [protected]

ID of the time zone to be used when computing dates. A null value stands for the local time zone.

Defaults to null.

Definition at line 107 of file PeriodicEvent.java.

Referenced by com.scalagent.scheduler.event.PeriodicEvent.getTimeZoneId(), and com.scalagent.scheduler.event.PeriodicEvent.toString().

long com.scalagent.scheduler.event.PeriodicEvent.refDate = -1 [protected]

Reference date from which event dates are computed by adding a multiple of the period length. A -1 value means that no reference date is set.

Defaults to -1.

Definition at line 116 of file PeriodicEvent.java.

Referenced by com.scalagent.scheduler.event.PeriodicEvent.getRefDate(), com.scalagent.scheduler.event.PeriodicEvent.toString(), and com.scalagent.scheduler.event.PeriodicEvent.validateMask().

DiaryPeriod com.scalagent.scheduler.event.PeriodicEvent.period = null [protected]

Period definition. A null value stands for a no repetitive event.

Defaults to null.

Definition at line 124 of file PeriodicEvent.java.

Referenced by com.scalagent.scheduler.event.BasedPeriodicEvent.BasedPeriodicEvent(), com.scalagent.scheduler.event.PeriodicEvent.getDate(), com.scalagent.scheduler.event.PeriodicEvent.getPeriod(), com.scalagent.scheduler.event.PeriodicEvent.PeriodicEvent(), com.scalagent.scheduler.event.PeriodicEvent.setPeriod(), com.scalagent.scheduler.event.PeriodicEvent.toString(), and com.scalagent.scheduler.event.PeriodicEvent.validateMask().

int [] com.scalagent.scheduler.event.PeriodicEvent.maskField = null [protected]

Mask of fields to match event dates, as Calendar constants.

Some values for the period field accept a logical definition of the event date, in addition to the reference date. There are only a small set of (period/maskField) legal combinations that may be validated using validateMask.

The fields are ordered according to the following: YEAR, MONTH, WEEK_OF_YEAR, WEEK_OF_MONTH, DAY_OF_YEAR, DAY_OF_MONTH, DAY_OF_WEEK_IN_MONTH, DAY_OF_WEEK.

Definition at line 138 of file PeriodicEvent.java.

Referenced by com.scalagent.scheduler.event.PeriodicEvent.applyMask(), com.scalagent.scheduler.event.PeriodicEvent.getMaskField(), com.scalagent.scheduler.event.PeriodicEvent.toString(), and com.scalagent.scheduler.event.PeriodicEvent.validateMask().

int [] com.scalagent.scheduler.event.PeriodicEvent.maskValue = null [protected]

Values of corresponding fields in maskField. May be set from refDate using validateMask.

Positive values require an exact match, while negative values are interpreted either by the Calendar class or directly by this class. Negative values are accepted for the DAY_OF_MONTH and DAY_OF_WEEK_IN_MONTH fields.

Definition at line 149 of file PeriodicEvent.java.

Referenced by com.scalagent.scheduler.event.PeriodicEvent.applyMask(), com.scalagent.scheduler.event.PeriodicEvent.getMaskValue(), com.scalagent.scheduler.event.PeriodicEvent.toString(), and com.scalagent.scheduler.event.PeriodicEvent.validateMask().

Calendar com.scalagent.scheduler.event.PeriodicEvent.calendar [protected]

Object used internally to compute dates. It is created from the timeZoneId field when this object is created, and initialized with the reference date.

A Calendar object holds two descriptions of a date, as a long value, and as a number of fields. Those two descriptions are always synced in calendar.

Definition at line 160 of file PeriodicEvent.java.

Referenced by com.scalagent.scheduler.event.PeriodicEvent.applyMask(), com.scalagent.scheduler.event.PeriodicEvent.PeriodicEvent(), com.scalagent.scheduler.event.PeriodicEvent.setRefDate(), and com.scalagent.scheduler.event.PeriodicEvent.validateMask().


The documentation for this class was generated from the following file:
Generated on Tue Sep 16 16:15:50 2008 for joram by  doxygen 1.5.0