com.cc.framework.ui.model.imp
Class RecurrencePatternImp

java.lang.Object
  extended bycom.cc.framework.ui.model.imp.RecurrencePatternImp
All Implemented Interfaces:
DataModel, RecurrencePattern

public class RecurrencePatternImp
extends java.lang.Object
implements RecurrencePattern

Recurrence pattern for appointments

Version:
$Revision: 1.17 $
Author:
Harald Schulz

Nested Class Summary
protected static class RecurrencePatternImp.AbstractRecurrenceIterator
          Day iterator
static class RecurrencePatternImp.DailyIterator
          Daily iterator
static class RecurrencePatternImp.MonthlyIterator
          Monthly iterator
static class RecurrencePatternImp.MonthlyNthIterator
          Monthly iterator
static class RecurrencePatternImp.WeeklyIterator
          Weekly iterator
static class RecurrencePatternImp.YearlyIterator
          Yearly iterator
static class RecurrencePatternImp.YearlyNthIterator
          Yearly iterator
 
Field Summary
private  Appointment appointment
          The appointment this recurrence pattern is attached to
private  int dayOfMonth
          The Day of the month
private  int dayOfWeekMask
          Bit mask for a day of the week (use the CalendarHelp.DOWM_xxx constants) Sunday = CalendarHelp.DOWM_SUNDAY Monday = CalendarHelp.DOWM_MONDAY Tuesday = CalendarHelp.DOWM_TUESDAY ...
protected static java.lang.String ERR_ATTR
          Exception text
protected static java.lang.String ERR_ATTR_VALUE
          Exception text
protected static java.lang.String ERR_ATTR_ZERO
          Exception text
protected static java.lang.String ERR_MASK
          Exception text
protected static java.lang.String ERR_NOT_IMPLEMENTED
          Exception text
private  int instance
          The Instance property is used when the AppointmentItem is to recur only once during each recurrence unit, such as the second Wednesday of every month or the first Tuesday of every January.
private  int interval
          The Interval property is used when the AppointmentItem is to recur less often than every recurrence unit, such as once every three days, once every two weeks, or once every six months.
private  int monthOfYear
          The MonthOfYear property contains the calendar number of the month in which the AppointmentItem is to recur, for example the value 2 to indicate February.
private  int occurrences
          The Occurrences property is used when the appointment is to recur a specific number of times, such as the next ten Thursdays.
private  java.util.Calendar patternEndDate
          The PatternEndDate property contains the latest possible date of the last occurrence of the appointment.
private  java.util.Calendar patternStartDate
          The PatternStartDate property contains the earliest possible date of the first occurrence of the appointment.
private  RecurrenceType recurType
          Recurrence Type
 
Constructor Summary
RecurrencePatternImp()
          Constructor
 
Method Summary
protected  java.util.Calendar calcPatternEndDate()
          This method calculates the patterns end date from the pattern start date and the number of occurrences
static RecurrencePatternImp createDailyPattern(int interval, int dayOfWeekMask)
          Constructor for a daily recurrence pattern
static RecurrencePatternImp createMonthlyNthPattern(int interval, int instance, int dayOfWeekMask)
          Constructor for a monthly (N-th) recurrence pattern
static RecurrencePatternImp createMonthlyPattern(int interval, int dayOfMonth)
          Constructor for a monthly recurrence pattern
static RecurrencePatternImp createWeeklyPattern(int interval, int dayOfWeekMask)
          Constructor for a weekly recurrence pattern
static RecurrencePatternImp createYearlyNthPattern(int instance, int dayOfWeekMask, int monthOfYear)
          Constructor for a yearly (N-th) recurrence pattern
static RecurrencePatternImp createYearlyPattern(int dayOfMonth, int monthOfYear)
          Constructor for a yearly recurrence pattern
 Appointment getAppointment()
           
 int getDayOfMonth()
          The DayOfMonth property contains the calendar date of each month on which the AppointmentItem is to recur, for example the value 1 to indicate the first day of every month.
 int getDayOfWeekMask()
          The maximum value for the DayOfWeekMask property is 127, which is the logical inclusive OR of all seven days.
 RecurrenceException[] getExceptions()
           
 int getInstance()
          The Instance property is used when the AppointmentItem is to recur only once during each recurrence unit, such as the second Wednesday of every month or the first Tuesday of every January.
 int getInterval()
          The Interval property is used when the AppointmentItem is to recur less often than every recurrence unit, such as once every three days, once every two weeks, or once every six months.
 int getMonthOfYear()
          The MonthOfYear property contains the calendar number of the month in which the AppointmentItem is to recur, for example the value 2 to indicate February.
 int getOccurrences()
          The Occurrences property is used when the appointment is to recur a specific number of times, such as the next ten Thursdays.
 java.util.Calendar getPatternEndDate()
          The PatternEndDate property contains the latest possible date of the last occurrence of the appointment.
 java.util.Calendar getPatternStartDate()
          The PatternStartDate property contains the earliest possible date of the first occurrence of the appointment.
 RecurrenceType getRecurrenceType()
           
 boolean hasNoEndDate()
          The NoEndDate property contains True if the AppointmentItem object is to recur indefinitely and False if the recurrence has a terminal date.
 java.util.Iterator iterator()
          This method creates an iterator that can be used to iterate the single occurrences of this pattern.
 boolean match(java.util.Calendar date)
          This method checks if the recurrence pattern matches the given date
 void setAppointment(Appointment appointment)
          sets the reference to the appointment item
 void setPattern(RecurrenceType recurType, int dayOfMonth, int dayOfWeekMask, int instance, int interval, int monthOfYear)
          Sets the recurrence pattern fields
 RecurrencePatternImp setRange(java.util.Calendar patternStartDate)
          Sets the patterns range
 RecurrencePatternImp setRange(java.util.Calendar patternStartDate, java.util.Calendar patternEndDate)
          Sets the patterns range
 RecurrencePatternImp setRange(java.util.Calendar patternStartDate, int occurrences)
          Sets the patterns range
 void validate()
          This method validates the current recurrence settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERR_NOT_IMPLEMENTED

protected static final java.lang.String ERR_NOT_IMPLEMENTED
Exception text

See Also:
Constant Field Values

ERR_MASK

protected static final java.lang.String ERR_MASK
Exception text

See Also:
Constant Field Values

ERR_ATTR

protected static final java.lang.String ERR_ATTR
Exception text

See Also:
Constant Field Values

ERR_ATTR_ZERO

protected static final java.lang.String ERR_ATTR_ZERO
Exception text

See Also:
Constant Field Values

ERR_ATTR_VALUE

protected static final java.lang.String ERR_ATTR_VALUE
Exception text

See Also:
Constant Field Values

appointment

private Appointment appointment
The appointment this recurrence pattern is attached to


recurType

private RecurrenceType recurType
Recurrence Type


dayOfMonth

private int dayOfMonth
The Day of the month


dayOfWeekMask

private int dayOfWeekMask
Bit mask for a day of the week (use the CalendarHelp.DOWM_xxx constants)

See Also:
CalendarHelp

instance

private int instance
The Instance property is used when the AppointmentItem is to recur only once during each recurrence unit, such as the second Wednesday of every month or the first Tuesday of every January. The DayOfWeekMask property must specify exactly one day of the week, and Instance selects the occurrence of that day within the month on which recurrence is enabled. The last occurrence of the day within the month can be represented by the value 5. Instance is only valid if the value of the RecurrenceType property is MONTHLY_NTH or YEARLY_NTH. When Instance is valid on a newly created RecurrencePattern object, it defaults to the current instance of the current day of the week. For example, if the RecurrencePattern object is created on Wednesday 9 December and RecurrenceType is set to YEARLY_NTH, then DayOfWeekMask defaults to 8 (Wednesday), Instance defaults to 2 (the second Wednesday of the month), and MonthOfYear defaults to 12 (December).


interval

private int interval
The Interval property is used when the AppointmentItem is to recur less often than every recurrence unit, such as once every three days, once every two weeks, or once every six months. Interval contains a value representing the frequency of recurrence in terms of recurrence units.


monthOfYear

private int monthOfYear
The MonthOfYear property contains the calendar number of the month in which the AppointmentItem is to recur, for example the value 2 to indicate February. MonthOfYear is only valid if the value of the RecurrenceType property is YEARLY or YEARLY_NTH. When MonthOfYear is valid on a newly created RecurrencePattern object, it defaults to the current month.


occurrences

private int occurrences
The Occurrences property is used when the appointment is to recur a specific number of times, such as the next ten Thursdays. Occurrences has a minimum value of 1 and represents the total number of occurrences of the AppointmentItem object fitting the recurrence pattern. This qualification is necessary because the days of the original appointment, the PatternStartDate, and the PatternEndDate are not required to be included in the pattern specified by the DayOfMonth, DayOfWeekMask, Instance, Interval, and MonthOfYear properties. The original appointment is counted in Occurrences only if it matches the pattern. Occurrences is always valid on a newly created RecurrencePattern object and defaults to its maximum value of 1,490,000. If the NoEndDate property is subsequently set to False, Occurrences defaults to 10.


patternEndDate

private java.util.Calendar patternEndDate
The PatternEndDate property contains the latest possible date of the last occurrence of the appointment. This qualification is necessary because PatternEndDate is not required to be included in the pattern specified by the DayOfMonth, DayOfWeekMask, Instance, Interval, and MonthOfYear properties. A recurrence is generated on PatternEndDate only if it matches the pattern.


patternStartDate

private java.util.Calendar patternStartDate
The PatternStartDate property contains the earliest possible date of the first occurrence of the appointment. This qualification is necessary because PatternStartDate is not required to be included in the pattern specified by the DayOfMonth, DayOfWeekMask, Instance, Interval, and MonthOfYear properties. A recurrence is generated on PatternStartDate only if it matches the pattern.

Constructor Detail

RecurrencePatternImp

public RecurrencePatternImp()
Constructor

Method Detail

setPattern

public void setPattern(RecurrenceType recurType,
                       int dayOfMonth,
                       int dayOfWeekMask,
                       int instance,
                       int interval,
                       int monthOfYear)
Description copied from interface: RecurrencePattern
Sets the recurrence pattern fields

Specified by:
setPattern in interface RecurrencePattern
Parameters:
recurType - Recurrence Type
dayOfMonth - Day of Month
dayOfWeekMask - Day of Week mask
instance - instance
interval - interval
monthOfYear - month of the year
See Also:
RecurrencePattern.setPattern(com.cc.framework.ui.model.RecurrenceType, int, int, int, int, int)

validate

public void validate()
This method validates the current recurrence settings. It throws IndexOutOfBoundsException or IllegalArgumentException if the recurrence settings are invalid.


createDailyPattern

public static RecurrencePatternImp createDailyPattern(int interval,
                                                      int dayOfWeekMask)
Constructor for a daily recurrence pattern

Parameters:
interval - Every N days
dayOfWeekMask - Every Tuesday, Wednesday, and Thursday (use the CalendarHelp.DOWM_xxxxx constants)
Returns:
Recurrence Pattern

createWeeklyPattern

public static RecurrencePatternImp createWeeklyPattern(int interval,
                                                       int dayOfWeekMask)
Constructor for a weekly recurrence pattern

Parameters:
interval - Every N weeks
dayOfWeekMask - Every Tuesday, Wednesday, and Thursday
Returns:
Recurrence Pattern

createMonthlyPattern

public static RecurrencePatternImp createMonthlyPattern(int interval,
                                                        int dayOfMonth)
Constructor for a monthly recurrence pattern

Parameters:
interval - Every N months
dayOfMonth - The N-th day of the month
Returns:
Recurrence Pattern

createMonthlyNthPattern

public static RecurrencePatternImp createMonthlyNthPattern(int interval,
                                                           int instance,
                                                           int dayOfWeekMask)
Constructor for a monthly (N-th) recurrence pattern

Parameters:
interval - Every N months
instance - The N-th Tuesday
dayOfWeekMask - Every Tuesday and Wednesday
Returns:
Recurrence Pattern

createYearlyPattern

public static RecurrencePatternImp createYearlyPattern(int dayOfMonth,
                                                       int monthOfYear)
Constructor for a yearly recurrence pattern

Parameters:
dayOfMonth - The N-th day of the month
monthOfYear - February
Returns:
Recurrence Pattern

createYearlyNthPattern

public static RecurrencePatternImp createYearlyNthPattern(int instance,
                                                          int dayOfWeekMask,
                                                          int monthOfYear)
Constructor for a yearly (N-th) recurrence pattern

Parameters:
instance - The N-th Tuesday
dayOfWeekMask - Tuesday, Wednesday, Thursday
monthOfYear - February
Returns:
Recurrence Pattern

getDayOfMonth

public int getDayOfMonth()
Description copied from interface: RecurrencePattern
The DayOfMonth property contains the calendar date of each month on which the AppointmentItem is to recur, for example the value 1 to indicate the first day of every month. The last day of every month can be represented by the value 31 in monthly recurrences. For yearly recurrences, DayOfMonth cannot be set past the last possible day in the selected month. If an appointment is viewed and its DayOfMonth property has a value greater than the number of days in the specified month, it does not generate a recurrence for that month. This applies, for example, if DayOfMonth is 29 and MonthOfYear is 2. For such an appointment, it only generates a recurrence in leap years, whereas generate recurrences on February 28 for years other than leap years. DayOfMonth is only valid if the value of the RecurrenceType property is MONTHLY or YEARLY. When DayOfMonth is valid on a newly created RecurrencePattern object, it defaults to the current day of the month.

Specified by:
getDayOfMonth in interface RecurrencePattern
Returns:
Day of month
See Also:
RecurrencePattern.getDayOfMonth()

getDayOfWeekMask

public int getDayOfWeekMask()
Description copied from interface: RecurrencePattern
The maximum value for the DayOfWeekMask property is 127, which is the logical inclusive OR of all seven days. An attempt to set DayOfWeekMask to any value less than 0 or greater than 127 results in an OutOfBounds Exception. DayOfWeekMask is only valid if the value of the RecurrenceType property is WEEKLY, MONTHLY_NTH, or YEARLY_NTH. When DayOfWeekMask is valid on a newly created RecurrencePattern object, it defaults to the current day of the week. Setting DayOfWeekMask to multiple days per week is only valid if the value of the RecurrenceType property is WEEKLY. Recurrences of type MONTHLY_NTH or YEARLY_NTH can only use a single day per week.

Specified by:
getDayOfWeekMask in interface RecurrencePattern
Returns:
Day of Week
See Also:
RecurrencePattern.getDayOfWeekMask()

getInstance

public int getInstance()
Description copied from interface: RecurrencePattern
The Instance property is used when the AppointmentItem is to recur only once during each recurrence unit, such as the second Wednesday of every month or the first Tuesday of every January. The DayOfWeekMask property must specify exactly one day of the week, and Instance selects the occurrence of that day within the month on which recurrence is enabled. The last occurrence of the day within the month can be represented by the value 5. Instance is only valid if the value of the RecurrenceType property is MONTHLY_NTH or YEARLY_NTH. When Instance is valid on a newly created RecurrencePattern object, it defaults to the current instance of the current day of the week. For example, if the RecurrencePattern object is created on Wednesday 9 December and RecurrenceType is set to YEARLY_NTH, then DayOfWeekMask defaults to 8 (Wednesday), Instance defaults to 2 (the second Wednesday of the month), and MonthOfYear defaults to 12 (December).

Specified by:
getInstance in interface RecurrencePattern
Returns:
Instance
See Also:
RecurrencePattern.getInstance()

getInterval

public int getInterval()
Description copied from interface: RecurrencePattern
The Interval property is used when the AppointmentItem is to recur less often than every recurrence unit, such as once every three days, once every two weeks, or once every six months. Interval contains a value representing the frequency of recurrence in terms of recurrence units.

Specified by:
getInterval in interface RecurrencePattern
Returns:
Interval
See Also:
RecurrencePattern.getInterval()

getMonthOfYear

public int getMonthOfYear()
Description copied from interface: RecurrencePattern
The MonthOfYear property contains the calendar number of the month in which the AppointmentItem is to recur, for example the value 2 to indicate February. MonthOfYear is only valid if the value of the RecurrenceType property is YEARLY or YEARLY_NTH. When MonthOfYear is valid on a newly created RecurrencePattern object, it defaults to the current month.

Specified by:
getMonthOfYear in interface RecurrencePattern
Returns:
MonthOfYear
See Also:
RecurrencePattern.getMonthOfYear()

getOccurrences

public int getOccurrences()
Description copied from interface: RecurrencePattern
The Occurrences property is used when the appointment is to recur a specific number of times, such as the next ten Thursdays. Occurrences has a minimum value of 1 and represents the total number of occurrences of the AppointmentItem object fitting the recurrence pattern. This qualification is necessary because the days of the original appointment, the PatternStartDate, and the PatternEndDate are not required to be included in the pattern specified by the DayOfMonth, DayOfWeekMask, Instance, Interval, and MonthOfYear properties. The original appointment is counted in Occurrences only if it matches the pattern. Occurrences is always valid on a newly created RecurrencePattern object and defaults to its maximum value of 1,490,000. If the NoEndDate property is subsequently set to False, Occurrences defaults to 10.

Specified by:
getOccurrences in interface RecurrencePattern
Returns:
Number of occurrences
See Also:
RecurrencePattern.getOccurrences()

getAppointment

public Appointment getAppointment()
Specified by:
getAppointment in interface RecurrencePattern
Returns:
Returns the parent AppointmentItem object
See Also:
RecurrencePattern.getAppointment()

setAppointment

public void setAppointment(Appointment appointment)
Description copied from interface: RecurrencePattern
sets the reference to the appointment item

Specified by:
setAppointment in interface RecurrencePattern
Parameters:
appointment - appointment item
See Also:
RecurrencePattern.setAppointment(com.cc.framework.ui.model.Appointment)

getPatternEndDate

public java.util.Calendar getPatternEndDate()
Description copied from interface: RecurrencePattern
The PatternEndDate property contains the latest possible date of the last occurrence of the appointment. This qualification is necessary because PatternEndDate is not required to be included in the pattern specified by the DayOfMonth, DayOfWeekMask, Instance, Interval, and MonthOfYear properties. A recurrence is generated on PatternEndDate only if it matches the pattern.

Specified by:
getPatternEndDate in interface RecurrencePattern
Returns:
PatternEndDate
See Also:
RecurrencePattern.getPatternEndDate()

getPatternStartDate

public java.util.Calendar getPatternStartDate()
Description copied from interface: RecurrencePattern
The PatternStartDate property contains the earliest possible date of the first occurrence of the appointment. This qualification is necessary because PatternStartDate is not required to be included in the pattern specified by the DayOfMonth, DayOfWeekMask, Instance, Interval, and MonthOfYear properties. A recurrence is generated on PatternStartDate only if it matches the pattern.

Specified by:
getPatternStartDate in interface RecurrencePattern
Returns:
PatternStartDate
See Also:
RecurrencePattern.getPatternStartDate()

getRecurrenceType

public RecurrenceType getRecurrenceType()
Specified by:
getRecurrenceType in interface RecurrencePattern
Returns:
Returns the Recurrence type
See Also:
RecurrencePattern.getRecurrenceType()

hasNoEndDate

public boolean hasNoEndDate()
Description copied from interface: RecurrencePattern
The NoEndDate property contains True if the AppointmentItem object is to recur indefinitely and False if the recurrence has a terminal date. NoEndDate is always valid on a newly created RecurrencePattern object and defaults to True.

Specified by:
hasNoEndDate in interface RecurrencePattern
Returns:
true if the AppointmentItem object is to recur indefinitely
See Also:
RecurrencePattern.hasNoEndDate()

getExceptions

public RecurrenceException[] getExceptions()
Specified by:
getExceptions in interface RecurrencePattern
Returns:
Returns an collection of exceptions for a specified series of recurring appointments
See Also:
RecurrencePattern.getExceptions()

setRange

public RecurrencePatternImp setRange(java.util.Calendar patternStartDate)
Sets the patterns range

Parameters:
patternStartDate - the start date for this pattern
Returns:
the pattern

setRange

public RecurrencePatternImp setRange(java.util.Calendar patternStartDate,
                                     java.util.Calendar patternEndDate)
Sets the patterns range

Parameters:
patternStartDate - the start date for this pattern
patternEndDate - the end date for this pattern or null
Returns:
the pattern

setRange

public RecurrencePatternImp setRange(java.util.Calendar patternStartDate,
                                     int occurrences)
Sets the patterns range

Parameters:
patternStartDate - the start date for this pattern
occurrences - the number of occurrences for this pattern or null
Returns:
the pattern

match

public boolean match(java.util.Calendar date)
Description copied from interface: RecurrencePattern
This method checks if the recurrence pattern matches the given date

Specified by:
match in interface RecurrencePattern
Parameters:
date - The date to check
Returns:
true if the pattern matches the Date
See Also:
RecurrencePattern.match(java.util.Calendar)

calcPatternEndDate

protected java.util.Calendar calcPatternEndDate()
This method calculates the patterns end date from the pattern start date and the number of occurrences

Returns:
calculated pattern end date

iterator

public java.util.Iterator iterator()
This method creates an iterator that can be used to iterate the single occurrences of this pattern.

Specified by:
iterator in interface RecurrencePattern
Returns:
Iterator of Calendar Objects


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.