Compoze Software, Inc.

com.compoze.ebusiness
Class DateRecurrence


java.lang.Object

  |

  +--com.compoze.ebusiness.DateRecurrence

All Implemented Interfaces:
IPersistable, java.io.Serializable

public class DateRecurrence
extends java.lang.Object
implements java.io.Serializable, IPersistable

This class describes the way that an exact instant in time recurs, and provides a method to enumerate the recurring dates. The recurrence rules are based largely on the iCalendar specification (RFC #2445), and in fact all iCalendar recurrence rules may be completely specified with this class. Some additional functionality is present, namely the byYear rule.

See Also:
Serialized Form

Inner Class Summary
 class DateRecurrence.DateIterator
          This class is an iterator that returns the dates in a DateRecurrence.
 class DateRecurrence.DateRangeIterator
          This class is an iterator that returns the dates in a DateRecurrence as a date range (each date plus a duration).
 
Field Summary
static int ALL_DAYS
          The value that represents all days of the week.
static int ALL_MONTHS
          The value that represents all months of the year.
static int APRIL
          The value that represents the month April.
static int AUGUST
          The value that represents the month August.
static int BYDAY_FIFTH
          The value that represents the fifth weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int BYDAY_FIFTH_TO_LAST
          The value that represents the fifth to the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int BYDAY_FIRST
          The value that represents the first weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int BYDAY_FOURTH
          The value that represents the fourth weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int BYDAY_FOURTH_TO_LAST
          The value that represents the fourth to the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int BYDAY_LAST
          The value that represents the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int BYDAY_SECOND
          The value that represents the second weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int BYDAY_SECOND_TO_LAST
          The value that represents the second to the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int BYDAY_THIRD
          The value that represents the third weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int BYDAY_THIRD_TO_LAST
          The value that represents the third to the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)
static int DECEMBER
          The value that represents the month December.
static int FEBRUARY
          The value that represents the month February.
static int FRIDAY
          The value that represents the day Friday.
static int JANUARY
          The value that represents the month January.
static int JULY
          The value that represents the month July.
static int JUNE
          The value that represents the month June.
static int MARCH
          The value that represents the month March.
static int MAY
          The value that represents the month May.
static int MONDAY
          The value that represents the day Monday.
static int NOVEMBER
          The value that represents the month November.
static int OCTOBER
          The value that represents the month October.
static int RECUR_DAILY
          The value that represents a daily recurrence.
static int RECUR_HOURLY
          The value that represents an hourly recurrence.
static int RECUR_MINUTELY
          The value that represents a minutely recurrence.
static int RECUR_MONTHLY
          The value that represents a monthly recurrence.
static int RECUR_SECONDLY
          The value that represents a secondly recurrence.
static int RECUR_WEEKLY
          The value that represents a weekly recurrence.
static int RECUR_YEARLY
          The value that represents a yearly recurrence.
static int RULE_ALL_FUTURE
          This value indicates 'this and all future instances' rule.
static int RULE_ALL_INSTANCES
          This value indicates 'all instances' rule.
static int RULE_ALL_PREVIOUS
          This value indicates 'this and all previous instances' rule.
static int RULE_THIS_INSTANCE
          This value indicates 'this instance' rule.
static int SATURDAY
          The value that represents the day Saturday.
static int SEPTEMBER
          The value that represents the month September.
static int SUNDAY
          The value that represents the day Sunday.
static int THURSDAY
          The value that represents the day Thursday.
static int TUESDAY
          The value that represents the day Tuesday.
static int WEDNESDAY
          The value that represents the day Wednesday.
static int WEEKDAYS
          The value that represents the weekdays (Monday-Friday).
static int WEEKEND_DAYS
          The value that represents the weekend days (Saturday and Sunday).
 
Constructor Summary
DateRecurrence()
          Constructor.
DateRecurrence(java.util.Date startDate, int iFrequency, int iInterval, java.util.BitSet bySecond, java.util.BitSet byMinute, int iByHour, int[] byDay, java.util.BitSet byMonthDay, java.util.BitSet byYearDay, java.util.BitSet byWeekNo, int iByMonth, int[] byYear, java.util.BitSet bySetPos, int iWeekStart, int iCount, java.util.Date untilDate)
          Constructor.
 
Method Summary
 java.util.SortedSet applyRule(java.util.Calendar calendar, java.util.Date startDate, java.util.Date endDate)
          Applies the rule by returning the resulting dates within the given date range.
 java.util.SortedSet applyRule(java.util.Date startDate, java.util.Date endDate)
          Applies the rule by returning the resulting dates within the given date range using the default calendar.
 java.util.SortedSet applyRule(DateRange dateRange)
          Applies the rule by returning the resulting dates within the given date range using the default calendar.
 java.util.SortedSet applyRule(DateRange dateRange, long lDuration)
          Applies the rule by returning a set of date ranges occurring totally or partially within the given date range window.
static DateRecurrence createAnnual(java.util.Date time, int iDayOfYear, java.util.Date endDate)
          Creates a date recurrence once per year on a given day of the year.
static DateRecurrence createAnnual(java.util.Date time, int iDayOfYear, int iCount)
          Creates a date recurrence once per year on a given day of the year.
static DateRecurrence createAnnual(java.util.Date time, int iMonth, int iDay, java.util.Date endDate)
          Creates a date recurrence once per year on a given month and day.
static DateRecurrence createAnnual(java.util.Date time, int iMonth, int iDay, java.util.Date endDate, java.util.Calendar calendar)
          Creates a date recurrence once per year on a given month and day.
static DateRecurrence createAnnual(java.util.Date time, int iMonth, int iDay, int iCount)
          Creates a date recurrence once per year on a given month and day.
static DateRecurrence createAnnual(java.util.Date time, int iMonth, int iDay, int iCount, java.util.Calendar calendar)
          Creates a date recurrence once per year on a given month and day.
static DateRecurrence createDaily(java.util.Date time, int iDaysOfWeek, java.util.Date endDate)
          Creates a date recurrence that occurs on the given days of the week.
static DateRecurrence createDaily(java.util.Date time, int iDaysOfWeek, int iCount)
          Creates a date recurrence that occurs on the given days of the week.
static DateRecurrence createEveryNDays(java.util.Date startDate, int iNDays, java.util.Date endDate)
          Creates a date recurrence that occurs every n days.
static DateRecurrence createEveryNDays(java.util.Date startDate, int iNDays, int iCount)
          Creates a date recurrence that occurs every n days.
static DateRecurrence createEveryNMonths(java.util.Date startDate, int iNMonths, java.util.Date endDate)
          Creates a date recurrence that occurs every n months.
static DateRecurrence createEveryNWeeks(java.util.Calendar cal, java.util.Date startDate, int iNWeeks, java.util.Date endDate)
          Creates a date recurrence that occurs every n weeks.
static DateRecurrence createEveryNWeeks(java.util.Date startDate, int iNWeeks, java.util.Date endDate)
          Creates a date recurrence that occurs every n weeks.
static DateRecurrence createEveryNYears(java.util.Date startDate, int iNYears, java.util.Date endDate)
          Creates a date recurrence that occurs every n years.
static DateRecurrence createMonthly(java.util.Date time, int iDayOfMonth, java.util.Date endDate)
          Creates a date recurrence once per month on the nth day of the month.
static DateRecurrence createMonthly(java.util.Date time, int iDayOfMonth, java.util.Date endDate, java.util.Calendar calendar)
          Creates a date recurrence once per month on the nth day of the month.
static DateRecurrence createMonthly(java.util.Date time, int iDayOfMonth, int iCount)
          Creates a date recurrence once per month on the nth day of the month.
static DateRecurrence createMonthly(java.util.Date time, int iDayOfMonth, int iCount, java.util.Calendar calendar)
          Creates a date recurrence once per month on the nth day of the month.
static DateRecurrence createMonthlyOnWeekdayOfMonth(java.util.Date time, int iDaysOfWeekMask, java.util.Date endDate)
          Creates a date recurrence once per month on the nth weekday of every month.
static DateRecurrence createMonthlyOnWeekdayOfMonth(java.util.Date time, int iDaysOfWeekMask, int iInterval, int iCount)
          Creates a date recurrence once per month on the nth weekday of every month.
static DateRecurrence createWeekday(java.util.Date startDate, java.util.Date endDate)
          Creates a date recurrence that occurs every weekday (Monday-Friday).
static DateRecurrence createWeekday(java.util.Date startDate, int iCount)
          Creates a date recurrence that occurs every weekday (Monday-Friday).
static DateRecurrence createWeekend(java.util.Date startDate, java.util.Date endDate)
          Creates a date recurrence that occurs every weekend day (Saturday and Sunday).
static DateRecurrence createWeekend(java.util.Date startDate, int iCount)
          Creates a date recurrence that occurs every weekend day (Saturday and Sunday).
static DateRecurrence createWeekly(java.util.Calendar cal, java.util.Date startDate, java.util.Date endDate)
          Creates a date recurrence that occurs weekly.
static DateRecurrence createWeekly(java.util.Calendar cal, java.util.Date startDate, int iCount)
          Creates a date recurrence that occurs weekly.
static DateRecurrence createWeekly(java.util.Date startDate, java.util.Date endDate)
          Creates a date recurrence that occurs weekly.
static DateRecurrence createWeekly(java.util.Date startDate, int iCount)
          Creates a date recurrence that occurs weekly.
 boolean filterByRules(java.util.Calendar calendar)
          Applies the by rules on the given calendar to determine if it should be accepted in the recurrence set.
static int getBitSetIndexMonthDay(int iBitSetIndex)
          Gets the day of the month that corresponds to the given bit set index in a by month day rule.
static int getBitSetIndexYearDay(int iBitSetIndex)
          Gets the day of the year that corresponds to the given bit set index in a by year rule.
 int[] getByDay()
          Gets the by day rule.
 int getByHour()
          Gets the by hour rule.
 java.util.BitSet getByMinute()
          Gets the by minute rule.
 int getByMonth()
          Gets the by month rule.
 java.util.BitSet getByMonthDay()
          Gets the by month day rule.
 java.util.BitSet getBySecond()
          Gets the interval.
 java.util.BitSet getBySetPos()
          Gets the by setpos rule.
 java.util.BitSet getByWeekNumber()
          Gets the by week number rule.
 int[] getByYear()
          Gets the by year rule.
 java.util.BitSet getByYearDay()
          Gets the by year day rule.
 int getCount()
          Gets the event count.
static int getDayOfWeekInMonthFromMask(int iDayOfWeekInMonthMask)
          Gets the Calendar version of the day of week in month from the day of week in month mask.
static int getDaysFromEndOfMonth(java.util.Calendar calendar, int iDayOfMonth)
          Gets the number of days from the end of the month of the given day for the given calendar.
static int getDaysFromEndOfYear(java.util.Calendar calendar, int iDayOfYear)
          Gets the number of days from the end of the year of the given day for the given calendar.
 java.util.List getDeleteDates()
          Gets the delete dates.
 java.util.Date getEffectiveUntilDate()
          Gets the effective until date.
 int getFrequency()
          Gets the frequency.
 int getInterval()
          Gets the interval.
 java.util.Iterator getIterator()
          Gets an iterator that iterates over all of the recurring dates using the default calendar.
 java.util.Iterator getIterator(java.util.Calendar cal)
          Gets an iterator that iterates over all of the recurring dates using the specified calendar.
 java.util.Iterator getIterator(java.util.Calendar calendar, java.util.Date startDate, java.util.Date endDate)
          Gets an iterator that iterates over the recurring dates.
 java.util.Iterator getIterator(java.util.Date startDate, java.util.Date endDate)
          Gets an iterator that iterates over the recurring dates using the default calendar.
 java.util.Iterator getIterator(DateRange dateRange)
          Gets an iterator that iterates over the recurring dates using the default calendar.
 java.util.Iterator getIterator(DateRange dateRange, long lDuration)
          Gets an iterator that iterates over the recurring dates using the default calendar.
static int getMaskFromDayOfWeek(int iDayOfWeek)
          Gets the day of week mask suitable for the by day rule from the Calendar version of the day of week.
static int getMaskFromDayOfWeekInMonth(int iDayOfWeekInMonth)
          Gets the day of week mask suitable for the by day rule from the Calendar version of the day of week in month.
static int getMonthDayBitSetIndex(int iDayOfMonth)
          Gets the bit that should be set in a bit set to represent the specified day of the month.
 java.util.Date getStartDate()
          Gets the start date.
 java.util.Date getUntilDate()
          Gets the until date.
 int getWeekStart()
          Gets the week start.
static int getYearDayBitSetIndex(int iDayOfYear)
          Gets the bit that should be set in a bit set to represent the specified day of the year.
 boolean isDeleteDate(java.util.Date givenDate)
          Checks if the specified date is a delete date.
static void main(java.lang.String[] args)
          Exerciser.
 void setByDay(int[] byDay)
          Sets the by day rule.
 void setByHour(int iByHour)
          Sets the by hour rule.
 void setByMinute(java.util.BitSet byMinute)
          Sets the by minute rule.
 void setByMonth(int iByMonth)
          Sets the by month rule.
 void setByMonthDay(java.util.BitSet byMonthDay)
          Sets the by month day rule.
 void setBySecond(java.util.BitSet bySecond)
          Sets the by second rule.
 void setBySetPos(java.util.BitSet bySetPos)
          Sets the by setpos rule.
 void setByWeekNumber(java.util.BitSet byWeekNo)
          Sets the by week number rule.
 void setByYear(int[] byYear)
          Sets the by year rule.
 void setByYearDay(java.util.BitSet byYearDay)
          Sets the by year day rule.
 void setCount(int iCount)
          Sets the event count.
 void setFrequency(int iFrequency)
          Sets the frequency.
 void setInterval(int iInterval)
          Sets the interval.
 void setStartDate(java.util.Date startDate)
          Sets the start date.
 void setUntilDate(java.util.Date untilDate)
          Sets the until date.
 void setWeekStart(int iWeekStart)
          Sets the week start.
 java.lang.String toRecurrenceString()
          Creates a string representation of the date recurrence.
 java.lang.String toVcalendarString()
          Creates a string that contains the vCalendar 2.0 compliant recurrence rule, for example
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RULE_THIS_INSTANCE


public static final int RULE_THIS_INSTANCE
This value indicates 'this instance' rule.

RULE_ALL_INSTANCES


public static final int RULE_ALL_INSTANCES
This value indicates 'all instances' rule.

RULE_ALL_PREVIOUS


public static final int RULE_ALL_PREVIOUS
This value indicates 'this and all previous instances' rule.

RULE_ALL_FUTURE


public static final int RULE_ALL_FUTURE
This value indicates 'this and all future instances' rule.

SUNDAY


public static final int SUNDAY
The value that represents the day Sunday.

MONDAY


public static final int MONDAY
The value that represents the day Monday.

TUESDAY


public static final int TUESDAY
The value that represents the day Tuesday.

WEDNESDAY


public static final int WEDNESDAY
The value that represents the day Wednesday.

THURSDAY


public static final int THURSDAY
The value that represents the day Thursday.

FRIDAY


public static final int FRIDAY
The value that represents the day Friday.

SATURDAY


public static final int SATURDAY
The value that represents the day Saturday.

BYDAY_FIRST


public static final int BYDAY_FIRST
The value that represents the first weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

BYDAY_SECOND


public static final int BYDAY_SECOND
The value that represents the second weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

BYDAY_THIRD


public static final int BYDAY_THIRD
The value that represents the third weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

BYDAY_FOURTH


public static final int BYDAY_FOURTH
The value that represents the fourth weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

BYDAY_FIFTH


public static final int BYDAY_FIFTH
The value that represents the fifth weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

BYDAY_LAST


public static final int BYDAY_LAST
The value that represents the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

BYDAY_SECOND_TO_LAST


public static final int BYDAY_SECOND_TO_LAST
The value that represents the second to the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

BYDAY_THIRD_TO_LAST


public static final int BYDAY_THIRD_TO_LAST
The value that represents the third to the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

BYDAY_FOURTH_TO_LAST


public static final int BYDAY_FOURTH_TO_LAST
The value that represents the fourth to the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

BYDAY_FIFTH_TO_LAST


public static final int BYDAY_FIFTH_TO_LAST
The value that represents the fifth to the last weekday of the month (or'd with SUNDAY-SATURDAY constants for the by day rule)

ALL_DAYS


public static final int ALL_DAYS
The value that represents all days of the week.

WEEKDAYS


public static final int WEEKDAYS
The value that represents the weekdays (Monday-Friday).

WEEKEND_DAYS


public static final int WEEKEND_DAYS
The value that represents the weekend days (Saturday and Sunday).

JANUARY


public static final int JANUARY
The value that represents the month January.

FEBRUARY


public static final int FEBRUARY
The value that represents the month February.

MARCH


public static final int MARCH
The value that represents the month March.

APRIL


public static final int APRIL
The value that represents the month April.

MAY


public static final int MAY
The value that represents the month May.

JUNE


public static final int JUNE
The value that represents the month June.

JULY


public static final int JULY
The value that represents the month July.

AUGUST


public static final int AUGUST
The value that represents the month August.

SEPTEMBER


public static final int SEPTEMBER
The value that represents the month September.

OCTOBER


public static final int OCTOBER
The value that represents the month October.

NOVEMBER


public static final int NOVEMBER
The value that represents the month November.

DECEMBER


public static final int DECEMBER
The value that represents the month December.

ALL_MONTHS


public static final int ALL_MONTHS
The value that represents all months of the year.

RECUR_YEARLY


public static final int RECUR_YEARLY
The value that represents a yearly recurrence.

RECUR_MONTHLY


public static final int RECUR_MONTHLY
The value that represents a monthly recurrence.

RECUR_WEEKLY


public static final int RECUR_WEEKLY
The value that represents a weekly recurrence.

RECUR_DAILY


public static final int RECUR_DAILY
The value that represents a daily recurrence.

RECUR_HOURLY


public static final int RECUR_HOURLY
The value that represents an hourly recurrence.

RECUR_MINUTELY


public static final int RECUR_MINUTELY
The value that represents a minutely recurrence.

RECUR_SECONDLY


public static final int RECUR_SECONDLY
The value that represents a secondly recurrence.
Constructor Detail

DateRecurrence


public DateRecurrence()
Constructor. NOTE: This default constructor technically leaves the date recurrence in an invalid state. The recurrence parameters should be set before the object is used.

DateRecurrence


public DateRecurrence(java.util.Date startDate,
                      int iFrequency,
                      int iInterval,
                      java.util.BitSet bySecond,
                      java.util.BitSet byMinute,
                      int iByHour,
                      int[] byDay,
                      java.util.BitSet byMonthDay,
                      java.util.BitSet byYearDay,
                      java.util.BitSet byWeekNo,
                      int iByMonth,
                      int[] byYear,
                      java.util.BitSet bySetPos,
                      int iWeekStart,
                      int iCount,
                      java.util.Date untilDate)
               throws InvalidRuleException
Constructor. Once the rule is constructed it may be applied as often as desired.
Parameters:
startDate - start date (must not be null)
iFrequency - frequency of recurrence (see RECUR_ constants, no dates are considered below this frequency)
iInterval - the recurrence interval (<=0 will default to 1)
bySecond - bysecond rule, match these seconds (set bits 0-59, null to skip)
byMinute - byminute rule, match these minutes (set bits 0-59, null to skip)
iByHour - byhour rule, match these hours (set bits 0-23 in int, 0 to skip)
byDay - byday rule, match these days (array of int masks of SUNDAY-SATURDAY constants possibly or'd with one of the BYDAY_ constants, 0 to skip)
byMonthDay - bymonthday rule, match these days of the month (-1 to -31 or 1 to 31, null to skip, 31 is subtracted from bit index to obtain day of month)
byYearDay - byyearday rule, match these days of the year (-1 to -366 or 1 to 366, null to skip, 366 is subtracted from bit index to obtain day of year)
byWeekNo - byweekno rule, match this week number (null to skip, bit 1 is first week of year)
iByMonth - bymonth rule, match these months (0 to skip, see JANUARY-DECEMBER constants)
byYear - byyear rule, match these years (array of ints, null to skip)
bySetPos - bysetpos rule, select returned positions within result (-366 to -1, 1 to 366, 366 is subtracted from bit index to obtain set position, requires another by rule, null to skip)
iWeekStart - set the start day of the week (see SUNDAY-SATURDAY constants, 0 defaults to Sunday)
iCount - the number of recurrences to match (0 for all)
untilDate - the date to recur until (null for indefinite)
Throws:
InvalidRuleException - if the specified rule is invalid
See Also:
getYearDayBitSetIndex(int), getMonthDayBitSetIndex(int)
Method Detail

setStartDate


public void setStartDate(java.util.Date startDate)
Sets the start date.
Parameters:
startDate - the start date

getStartDate


public java.util.Date getStartDate()
Gets the start date.
Returns:
the start date

getDeleteDates


public java.util.List getDeleteDates()
Gets the delete dates.
Returns:
the delete date

isDeleteDate


public boolean isDeleteDate(java.util.Date givenDate)
Checks if the specified date is a delete date.
Parameters:
givenDate - the date to check
Returns:
true if the date is deleted; false otherwise

setFrequency


public void setFrequency(int iFrequency)
Sets the frequency.
Parameters:
iFrequency - the frequency

getFrequency


public int getFrequency()
Gets the frequency.
Returns:
the frequency

setInterval


public void setInterval(int iInterval)
Sets the interval.
Parameters:
iInterval - the interval

getInterval


public int getInterval()
Gets the interval.
Returns:
the interval

getEffectiveUntilDate


public java.util.Date getEffectiveUntilDate()
Gets the effective until date. This takes into account if the until date was specified or a count was used.
Returns:
the effective until date

setBySecond


public void setBySecond(java.util.BitSet bySecond)
Sets the by second rule.
Parameters:
bySecond - the by second rule

getBySecond


public java.util.BitSet getBySecond()
Gets the interval.
Returns:
the by second rule

setByMinute


public void setByMinute(java.util.BitSet byMinute)
Sets the by minute rule.
Parameters:
byMinute - the by minute rule

getByMinute


public java.util.BitSet getByMinute()
Gets the by minute rule.
Returns:
the by minute rule

setByHour


public void setByHour(int iByHour)
Sets the by hour rule.
Parameters:
iByHour - the by hour rule

getByHour


public int getByHour()
Gets the by hour rule.
Returns:
the by hour rule

setByDay


public void setByDay(int[] byDay)
Sets the by day rule.
Parameters:
byDay - the by day rule

getByDay


public int[] getByDay()
Gets the by day rule.
Returns:
the by day rule

setByMonthDay


public void setByMonthDay(java.util.BitSet byMonthDay)
Sets the by month day rule.
Parameters:
byMonthDay - the by month day rule

getByMonthDay


public java.util.BitSet getByMonthDay()
Gets the by month day rule.
Returns:
the by month day rule

setByYearDay


public void setByYearDay(java.util.BitSet byYearDay)
Sets the by year day rule.
Parameters:
byYearDay - the by year day rule

getByYearDay


public java.util.BitSet getByYearDay()
Gets the by year day rule.
Returns:
the by year day rule

setByWeekNumber


public void setByWeekNumber(java.util.BitSet byWeekNo)
Sets the by week number rule.
Parameters:
byWeekNo - the by week number rule

getByWeekNumber


public java.util.BitSet getByWeekNumber()
Gets the by week number rule.
Returns:
the by week number rule

setByMonth


public void setByMonth(int iByMonth)
Sets the by month rule.
Parameters:
byMonth - the by month rule

getByMonth


public int getByMonth()
Gets the by month rule.
Returns:
the by month rule

setByYear


public void setByYear(int[] byYear)
Sets the by year rule.
Parameters:
byYear - the by year rule

getByYear


public int[] getByYear()
Gets the by year rule.
Returns:
the by year rule

setBySetPos


public void setBySetPos(java.util.BitSet bySetPos)
Sets the by setpos rule.
Parameters:
bySetPos - the by setpos rule

getBySetPos


public java.util.BitSet getBySetPos()
Gets the by setpos rule.
Returns:
the by setpos rule

setWeekStart


public void setWeekStart(int iWeekStart)
Sets the week start.
Parameters:
iWeekStart - the week start

getWeekStart


public int getWeekStart()
Gets the week start.
Returns:
the week start

setCount


public void setCount(int iCount)
Sets the event count.
Parameters:
iCount - the event count

getCount


public int getCount()
Gets the event count.
Returns:
the event count

setUntilDate


public void setUntilDate(java.util.Date untilDate)
Sets the until date.
Parameters:
untilDate - the until date

getUntilDate


public java.util.Date getUntilDate()
Gets the until date.
Returns:
the until date

applyRule


public java.util.SortedSet applyRule(java.util.Date startDate,
                                     java.util.Date endDate)
                              throws java.lang.ArithmeticException
Applies the rule by returning the resulting dates within the given date range using the default calendar.
Parameters:
startDate - start date, or null for start date of rule
endDate - end date, or null to use until date of rule
Returns:
the set of recurring dates
Throws:
java.lang.ArithmeticException - if the resulting enumeration would be of infinite length
See Also:
Calendar.getInstance(), applyRule(Calendar,Date,Date)

applyRule


public java.util.SortedSet applyRule(DateRange dateRange)
Applies the rule by returning the resulting dates within the given date range using the default calendar.
Parameters:
dateRange - the date range
Returns:
the set of recurring dates
Throws:
java.lang.ArithmeticException - if the resulting enumeration would be of infinite length
See Also:
Calendar.getInstance(), applyRule(Date,Date)

applyRule


public java.util.SortedSet applyRule(DateRange dateRange,
                                     long lDuration)
Applies the rule by returning a set of date ranges occurring totally or partially within the given date range window. The duration is added to the starting date of each recurrence to come up with each individual date range.
Parameters:
dateRange - the date range window (neither start or end may be null)
lDuration - the duration of each date range
Returns:
the sorted set of recurring DateRange objects

applyRule


public java.util.SortedSet applyRule(java.util.Calendar calendar,
                                     java.util.Date startDate,
                                     java.util.Date endDate)
                              throws java.lang.ArithmeticException
Applies the rule by returning the resulting dates within the given date range. The rules are applied in the following order:
  1. apply frequency and interval rules
  2. apply by rules
  3. apply bysetpos rule on remaining result set
  4. apply count or until to limit result range
Parameters:
calendar - the calendar to use to apply the rules (should be constructed with appropriate time zone and locale)
startDate - start date, or null for start date of rule
endDate - end date, or null to use until date of rule, which if it is null, yields the possibility that this method will loop indefinitely
Returns:
the set of recurring dates
Throws:
java.lang.ArithmeticException - if it can be determined that the resulting enumeration would be of infinite length (if the set is of infinite length an iterator should be used)
See Also:
getIterator(Calendar,Date,Date)

getIterator


public java.util.Iterator getIterator()
                               throws java.lang.ArithmeticException
Gets an iterator that iterates over all of the recurring dates using the default calendar.
Returns:
an iterator that iterates over the recurring dates
See Also:
Calendar.getInstance(), getIterator(Calendar,Date,Date)

getIterator


public java.util.Iterator getIterator(java.util.Calendar cal)
                               throws java.lang.ArithmeticException
Gets an iterator that iterates over all of the recurring dates using the specified calendar.
Parameters:
cal - the calendar
Returns:
an iterator that iterates over the recurring dates
See Also:
Calendar.getInstance(), getIterator(Calendar,Date,Date)

getIterator


public java.util.Iterator getIterator(DateRange dateRange)
                               throws java.lang.ArithmeticException
Gets an iterator that iterates over the recurring dates using the default calendar.
Parameters:
dateRange - the date range
Returns:
an iterator that iterates over the recurring dates
See Also:
Calendar.getInstance(), getIterator(Date,Date)

getIterator


public java.util.Iterator getIterator(java.util.Date startDate,
                                      java.util.Date endDate)
                               throws java.lang.ArithmeticException
Gets an iterator that iterates over the recurring dates using the default calendar.
Parameters:
startDate - start date, or null for start date of rule
endDate - end date, or null to use until date of rule
Returns:
an iterator that iterates over the recurring dates
See Also:
Calendar.getInstance(), getIterator(Calendar,Date,Date)

getIterator


public java.util.Iterator getIterator(DateRange dateRange,
                                      long lDuration)
                               throws java.lang.ArithmeticException
Gets an iterator that iterates over the recurring dates using the default calendar. The duration is added to the starting date of each recurrence to come up with each individual date range.
Parameters:
dateRange - the date range
lDuration - the duration of each date range
Returns:
an iterator that iterates over the recurring dates
See Also:
Calendar.getInstance(), getIterator(Calendar,Date,Date)

getIterator


public java.util.Iterator getIterator(java.util.Calendar calendar,
                                      java.util.Date startDate,
                                      java.util.Date endDate)
Gets an iterator that iterates over the recurring dates.
Parameters:
calendar - the calendar to use to apply the rules (should be constructed with appropriate time zone and locale)
startDate - start date, or null for start date of rule
endDate - end date, or null to use until date of rule, which if it is null, yields the possibility that this method will loop indefinitely
Returns:
an iterator that iterates over the recurring dates

getMonthDayBitSetIndex


public static int getMonthDayBitSetIndex(int iDayOfMonth)
Gets the bit that should be set in a bit set to represent the specified day of the month. Valid values range from 1 to 31, and -1 to -31 (for the number of days from the end of the month).
Parameters:
iDayOfMonth - the day of the month
Returns:
the index on the bit set to set

getBitSetIndexMonthDay


public static int getBitSetIndexMonthDay(int iBitSetIndex)
Gets the day of the month that corresponds to the given bit set index in a by month day rule.
Parameters:
iBitSetIndex - the bit set index
Returns:
the day of the year

getYearDayBitSetIndex


public static int getYearDayBitSetIndex(int iDayOfYear)
Gets the bit that should be set in a bit set to represent the specified day of the year. Valid values range from 1 to 366, and -1 to -366 (for the number of days from the end of the year).
Parameters:
iDayOfYear - the day of the year
Returns:
the index on the bit set to set

getBitSetIndexYearDay


public static int getBitSetIndexYearDay(int iBitSetIndex)
Gets the day of the year that corresponds to the given bit set index in a by year rule.
Parameters:
iBitSetIndex - the bit set index
Returns:
the day of the year

getDaysFromEndOfYear


public static int getDaysFromEndOfYear(java.util.Calendar calendar,
                                       int iDayOfYear)
Gets the number of days from the end of the year of the given day for the given calendar.
Parameters:
calendar - the calendar
iDayOfYear - the day of the year
Returns:
the number of days from the end of the year

getDaysFromEndOfMonth


public static int getDaysFromEndOfMonth(java.util.Calendar calendar,
                                        int iDayOfMonth)
Gets the number of days from the end of the month of the given day for the given calendar.
Parameters:
calendar - the calendar
iDayOfMonth - the day of the month
Returns:
the number of days from the end of the month

filterByRules


public boolean filterByRules(java.util.Calendar calendar)
Applies the by rules on the given calendar to determine if it should be accepted in the recurrence set. The calendar must be set to the correct date.
Parameters:
calendar - the calendar to test
Returns:
true if the calendar's date is accepted

getMaskFromDayOfWeek


public static int getMaskFromDayOfWeek(int iDayOfWeek)
Gets the day of week mask suitable for the by day rule from the Calendar version of the day of week.
Parameters:
iDayOfWeek - calendar day of week
Returns:
day of week mask

getMaskFromDayOfWeekInMonth


public static int getMaskFromDayOfWeekInMonth(int iDayOfWeekInMonth)
Gets the day of week mask suitable for the by day rule from the Calendar version of the day of week in month.
Parameters:
iDayOfWeekInMonth - the calendar day of week in month
Returns:
day of week in month mask

getDayOfWeekInMonthFromMask


public static int getDayOfWeekInMonthFromMask(int iDayOfWeekInMonthMask)
Gets the Calendar version of the day of week in month from the day of week in month mask.
Parameters:
iDayOfWeekInMonthMask - the day of week in month mask
Returns:
day of week in month mask

createAnnual


public static DateRecurrence createAnnual(java.util.Date time,
                                          int iDayOfYear,
                                          int iCount)
                                   throws InvalidRuleException
Creates a date recurrence once per year on a given day of the year.
Parameters:
time - the time of day (date parameters ignored)
iDayOfYear - the day of the year to occur (1-366, negative to count from the end of the year)
iCount - number of times to occur
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createAnnual


public static DateRecurrence createAnnual(java.util.Date time,
                                          int iDayOfYear,
                                          java.util.Date endDate)
                                   throws InvalidRuleException
Creates a date recurrence once per year on a given day of the year.
Parameters:
time - the time of day (date parameters ignored)
iDayOfYear - the day of the year to occur (1-366, negative to count from the end of the year)
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createAnnual


public static DateRecurrence createAnnual(java.util.Date time,
                                          int iMonth,
                                          int iDay,
                                          int iCount)
                                   throws InvalidRuleException
Creates a date recurrence once per year on a given month and day.
Parameters:
time - the time of day (date parameters ignored)
iMonth - the month of the year to occur (see month constants in java.util.Calendar)
iDay - the day of the month to occur (1-31)
iCount - number of times to occur
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid
See Also:
Calendar

createAnnual


public static DateRecurrence createAnnual(java.util.Date time,
                                          int iMonth,
                                          int iDay,
                                          int iCount,
                                          java.util.Calendar calendar)
                                   throws InvalidRuleException
Creates a date recurrence once per year on a given month and day.
Parameters:
time - the time of day (date parameters ignored)
iMonth - the month of the year to occur (see month constants in java.util.Calendar)
iDay - the day of the month to occur (1-31)
iCount - number of times to occur
calendar - the calendar
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid
See Also:
Calendar

createEveryNYears


public static DateRecurrence createEveryNYears(java.util.Date startDate,
                                               int iNYears,
                                               java.util.Date endDate)
                                        throws InvalidRuleException
Creates a date recurrence that occurs every n years.
Parameters:
startDate - the starting date and time
iNYears - number of years between occurrences of event
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createAnnual


public static DateRecurrence createAnnual(java.util.Date time,
                                          int iMonth,
                                          int iDay,
                                          java.util.Date endDate)
                                   throws InvalidRuleException
Creates a date recurrence once per year on a given month and day.
Parameters:
time - the time of day (date parameters ignored)
iMonth - the month of the year to occur (see month constants in java.util.Calendar)
iDay - the day of the month to occur (1-31)
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid
See Also:
Calendar

createAnnual


public static DateRecurrence createAnnual(java.util.Date time,
                                          int iMonth,
                                          int iDay,
                                          java.util.Date endDate,
                                          java.util.Calendar calendar)
                                   throws InvalidRuleException
Creates a date recurrence once per year on a given month and day.
Parameters:
time - the time of day (date parameters ignored)
iMonth - the month of the year to occur (see month constants in java.util.Calendar)
iDay - the day of the month to occur (1-31)
endDate - end by this date
calendar - the calendar
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid
See Also:
Calendar

createMonthly


public static DateRecurrence createMonthly(java.util.Date time,
                                           int iDayOfMonth,
                                           int iCount)
                                    throws InvalidRuleException
Creates a date recurrence once per month on the nth day of the month.
Parameters:
time - the time of day (date parameters ignored)
iDayOfMonth - the day of the month that the event occurs
iCount - number of times to occur
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createMonthly


public static DateRecurrence createMonthly(java.util.Date time,
                                           int iDayOfMonth,
                                           int iCount,
                                           java.util.Calendar calendar)
                                    throws InvalidRuleException
Creates a date recurrence once per month on the nth day of the month.
Parameters:
time - the time of day (date parameters ignored)
iDayOfMonth - the day of the month that the event occurs
iCount - number of times to occur
calendar - the calendar
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createMonthly


public static DateRecurrence createMonthly(java.util.Date time,
                                           int iDayOfMonth,
                                           java.util.Date endDate)
                                    throws InvalidRuleException
Creates a date recurrence once per month on the nth day of the month.
Parameters:
time - the time of day (date parameters ignored)
iDayOfMonth - the day of the month that the event occurs
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createMonthly


public static DateRecurrence createMonthly(java.util.Date time,
                                           int iDayOfMonth,
                                           java.util.Date endDate,
                                           java.util.Calendar calendar)
                                    throws InvalidRuleException
Creates a date recurrence once per month on the nth day of the month.
Parameters:
time - the time of day (date parameters ignored)
iDayOfMonth - the day of the month that the event occurs
endDate - end by this date
calendar - the calendar
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createEveryNMonths


public static DateRecurrence createEveryNMonths(java.util.Date startDate,
                                                int iNMonths,
                                                java.util.Date endDate)
                                         throws InvalidRuleException
Creates a date recurrence that occurs every n months.
Parameters:
startDate - the starting date and time
iNMonths - number of months between occurrences of event
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createMonthlyOnWeekdayOfMonth


public static DateRecurrence createMonthlyOnWeekdayOfMonth(java.util.Date time,
                                                           int iDaysOfWeekMask,
                                                           int iInterval,
                                                           int iCount)
                                                    throws InvalidRuleException
Creates a date recurrence once per month on the nth weekday of every month.
Parameters:
time - the time of day (date parameters ignored)
iDaysOfWeekMask - the day of the week mask (see day of week constants and BYDAY_ constants in this class)
iInterval - recur every this number of months
iCount - number of times to occur
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createMonthlyOnWeekdayOfMonth


public static DateRecurrence createMonthlyOnWeekdayOfMonth(java.util.Date time,
                                                           int iDaysOfWeekMask,
                                                           java.util.Date endDate)
                                                    throws InvalidRuleException
Creates a date recurrence once per month on the nth weekday of every month.
Parameters:
time - the time of day (date parameters ignored)
iDaysOfWeekMask - the day of the week mask (see day of week constants and BYDAY_ constants in this class)
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createDaily


public static DateRecurrence createDaily(java.util.Date time,
                                         int iDaysOfWeek,
                                         int iCount)
                                  throws InvalidRuleException
Creates a date recurrence that occurs on the given days of the week.
Parameters:
time - the time of day (date parameters ignored)
iDaysOfWeek - the days of the week that the event occurs (see day of week constants in this class)
iCount - number of times to occur
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createDaily


public static DateRecurrence createDaily(java.util.Date time,
                                         int iDaysOfWeek,
                                         java.util.Date endDate)
                                  throws InvalidRuleException
Creates a date recurrence that occurs on the given days of the week.
Parameters:
time - the time of day (date parameters ignored)
iDaysOfWeek - the days of the week that the event occurs (see day of week constants in this class)
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createEveryNDays


public static DateRecurrence createEveryNDays(java.util.Date startDate,
                                              int iNDays,
                                              int iCount)
                                       throws InvalidRuleException
Creates a date recurrence that occurs every n days.
Parameters:
startDate - the starting date and time
iNDays - number of days between occurrences of event
iCount - the number of occurrences
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createEveryNDays


public static DateRecurrence createEveryNDays(java.util.Date startDate,
                                              int iNDays,
                                              java.util.Date endDate)
                                       throws InvalidRuleException
Creates a date recurrence that occurs every n days.
Parameters:
startDate - the starting date and time
iNDays - number of days between occurrences of event
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createWeekly


public static DateRecurrence createWeekly(java.util.Date startDate,
                                          int iCount)
                                   throws InvalidRuleException
Creates a date recurrence that occurs weekly.
Parameters:
startDate - the starting date and time
iCount - the number of occurrences
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createWeekly


public static DateRecurrence createWeekly(java.util.Calendar cal,
                                          java.util.Date startDate,
                                          int iCount)
                                   throws InvalidRuleException
Creates a date recurrence that occurs weekly.
Parameters:
cal - the calendar to use
startDate - the starting date and time
iCount - the number of occurrences
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createWeekly


public static DateRecurrence createWeekly(java.util.Date startDate,
                                          java.util.Date endDate)
                                   throws InvalidRuleException
Creates a date recurrence that occurs weekly.
Parameters:
startDate - the starting date and time
iCount - the number of occurrences
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createWeekly


public static DateRecurrence createWeekly(java.util.Calendar cal,
                                          java.util.Date startDate,
                                          java.util.Date endDate)
                                   throws InvalidRuleException
Creates a date recurrence that occurs weekly.
Parameters:
cal - the calendar to use
startDate - the starting date and time
iCount - the number of occurrences
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createEveryNWeeks


public static DateRecurrence createEveryNWeeks(java.util.Date startDate,
                                               int iNWeeks,
                                               java.util.Date endDate)
                                        throws InvalidRuleException
Creates a date recurrence that occurs every n weeks.
Parameters:
startDate - the starting date and time
iNWeeks - number of weeks between occurrences of event
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createEveryNWeeks


public static DateRecurrence createEveryNWeeks(java.util.Calendar cal,
                                               java.util.Date startDate,
                                               int iNWeeks,
                                               java.util.Date endDate)
                                        throws InvalidRuleException
Creates a date recurrence that occurs every n weeks.
Parameters:
cal - the calendar to use
startDate - the starting date and time
iNWeeks - number of weeks between occurrences of event
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createWeekday


public static DateRecurrence createWeekday(java.util.Date startDate,
                                           int iCount)
                                    throws InvalidRuleException
Creates a date recurrence that occurs every weekday (Monday-Friday).
Parameters:
startDate - the starting date and time
iCount - the number of occurrences
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createWeekday


public static DateRecurrence createWeekday(java.util.Date startDate,
                                           java.util.Date endDate)
                                    throws InvalidRuleException
Creates a date recurrence that occurs every weekday (Monday-Friday).
Parameters:
startDate - the starting date and time
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createWeekend


public static DateRecurrence createWeekend(java.util.Date startDate,
                                           int iCount)
                                    throws InvalidRuleException
Creates a date recurrence that occurs every weekend day (Saturday and Sunday).
Parameters:
startDate - the starting date and time
iCount - the number of occurrences
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

createWeekend


public static DateRecurrence createWeekend(java.util.Date startDate,
                                           java.util.Date endDate)
                                    throws InvalidRuleException
Creates a date recurrence that occurs every weekend day (Saturday and Sunday).
Parameters:
startDate - the starting date and time
endDate - end by this date
Returns:
the date recurrence object
Throws:
InvalidRuleException - if the specified rule is invalid

toRecurrenceString


public java.lang.String toRecurrenceString()
Creates a string representation of the date recurrence. This method requires that the recurrence parameters are properly set, which is why it is not a toString() method.
Returns:
the string representation (up to 100 occurrences)

toVcalendarString


public java.lang.String toVcalendarString()
Creates a string that contains the vCalendar 2.0 compliant recurrence rule, for example
RRULE:FREQ=WEEKLY
.

main


public static void main(java.lang.String[] args)
Exerciser.
Parameters:
args -  

Compoze Software, Inc.

Copyright ©1999-2001 Compoze Software, Inc. All rights reserved.