Nitido Inc.

com.nitido.nimx.nuggets.wcap
Class RecurRule

java.lang.Object
  extended by com.nitido.nimx.nuggets.wcap.RecurRule

public class RecurRule
extends java.lang.Object

The data object for recurrence/exclusion rule used by WcapNugget.

The design of this object is based on the iCalendar proposed standard (RFC 2445 of Internet Engineering Task Force) with consideration of the features and limitation of iPlanet Calendar Server v5.0 or later.

Each recurrence rule must have a valid recurrence frequency that defines the base unit of how the recurrence occur. The supported values of recurrence frequency are defined as constants of RecurFreq class.

According to RFC 2445, you may set up a rule with valid value for count, until or none of these two fields. However, you should never have both fields set in the same rule. Setting count field in this object with a valid value will automatically invalidate the until field, and vice versa.

Other than count and until fields, the sequence of setting other fields would not affect the result at all.

If multiple rule fields are specified, the calendar server should process the fields in the following order:

  1. freq
  2. interval
  3. weekStart
  4. byMonth
  5. byWeekNo
  6. byYearDay
  7. byMonthDay
  8. byDay
  9. byHour
  10. byMinute
  11. bySecond
  12. bySetPos
  13. count
  14. until

If your application only needs to generate recurrence rule that based on a fixed recurrence frequency, you should use the default constructor that takes the RecurFreq as a parameter instead of this constructor. (e.g. your event/todo will happen every month, then your recurrence rule should be constructed with "new RecurRule( RecurFreq.MONTHLY );"

To use this object, you should first create an instance with the constructor and then set the corresponding fields correctly. For example, if I want to create a recurrence rule for repeating at 8:00 in the morning of everyday for 20 times, I would have the following code:

 // ---
 // Create a daily rule
 RecurRule myRule = new RecurRule( RecurFreq.DAILY );

 // ---
 // Set up the recurrence hour
 int[] myByHour = new int[] {8};
 myRule.setByHour( myByHour );

 // ---
 // Set up the recurrence count
 myRule.setCount( 20 );
 

Advance Recurrence Rule Examples

Every two days, for 10 times... (current event/todo also counts)

 RecurRule myRule = new RecurRule( RecurFreq.DAILY );
 myRule.setInterval( 2 );
 myRule.setCount( 10 );
 

Every other week (2 weeks) on Monday and Friday, repeats up to the limit of the calendar server

 RecurRule myRule = new RecurRule( RecurFreq.WEEKLY );
 myRule.setInterval( 2 );
 myRule.setWeekStart( WeekDay.SUNDAY );
 String[] byDay = new String[] { "MO", "FR" };
 myRule.setByDay( byDay );
 

Every 5th, 15th and 25th day of the month, until Dec 25, 2005

 RecurRule myRule = new RecurRule( RecurFreq.MONTHLY );
 int[] byMonthDay = new int[] { 5, 15, 25 }
 myRule.setByMonthDay( byMonthDay );
 // assume untilDate has been declared and initialized correctly before...
 myRule.setUntil( untilDate ); 
 

Every third day from the end of the month, repeats up to the limit of the calendar server

 RecurRule myRule = new RecurRule( RecurFreq.MONTHLY );
 int[] byMonthDay = new int[] { -3 }
 myRule.setByMonthDay( byMonthDay );
 

Every second Friday of the month, repeats up to the limit of the calendar server

 RecurRule myRule = new RecurRule( RecurFreq.MONTHLY );
 String[] byDay = new String[] { "2FR" };
 myRule.setByDay( byDay );
 

Every year on the current date, repeats up to the limit of the calendar server

 RecurRule myRule = new RecurRule( RecurFreq.YEARLY );
 


Field Summary
static RecurRule NO_RECURRENCE
          A convenience constant for indicating a removed recurrence rule.
 
Constructor Summary
RecurRule(RecurFreq freq)
          Default constructor.
RecurRule(RecurFreq freq, int count, java.util.Date until, int interval, WeekDay weekStart, int[] bySecond, int[] byMinute, int[] byHour, java.lang.String[] byDay, int[] byMonthDay, int[] byYearDay, int[] byWeekNo, int[] byMonth, int[] bySetPos)
          Constructor for the advance recurrence rule.
 
Method Summary
static RecurRule convertFromString(java.lang.String ruleStr, java.text.DateFormat dfFull)
          Generate a RecurRule object from a string that follows the standard RFC 2445 recurrence rule format.
 boolean equals(java.lang.Object inObj)
          Override the default java.lang.Object's equal command.
 java.lang.String[] getByDay()
          Retrieves the byDay field (list of values of day of week that the recurrence would happen).
 int[] getByHour()
          Retrieves the byHour field (list of values of hour that the recurrence would happen).
 int[] getByMinute()
          Retrieves the byMinute field (list of values of minute that the recurrence would happen).
 int[] getByMonth()
          Retrieves the byMonth field (list of values of month that the recurrence would happen).
 int[] getByMonthDay()
          Retrieves the byMonthDay field (list of values of day of month that the recurrence would happen).
 int[] getBySecond()
          Retrieves the bySecond field (list of values of second that the recurrence would happen).
 int[] getBySetPos()
          Retrieves the bySetPos field (list of values of occurrence within the set of recurrence instances specified by other fields of this rule).
 int[] getByWeekNo()
          Retrieves the byWeekNo field (list of values of week of a year that the recurrence would happen).
 int[] getByYearDay()
          Retrieves the byYearDay field (list of values of day of year that the recurrence would happen).
 int getCount()
          Retrieves the count field (the number of recurrence instance).
 RecurFreq getFreq()
          Retrieves the freq field.
 int getInterval()
          Retrieves the interval field (how often the recurrence repeats).
 java.util.Date getUntil()
          Retrieves the until field (the time that the recurrence would end).
 WeekDay getWeekStart()
          Retrieves the weekStart field (which day is regarded as the start of the work week).
 void setByDay(java.lang.String[] byDay)
          Sets the list of values of day (within a week) that the recurrence would happen.
 void setByHour(int[] byHour)
          Sets the list of values of hour (within a day) that the recurrence would happen.
 void setByMinute(int[] byMinute)
          Sets the list of values of minute (within an hour) that the recurrence would happen.
 void setByMonth(int[] byMonth)
          Sets the list of values of month that the recurrence would happen.
 void setByMonthDay(int[] byMonthDay)
          Sets the list of values of day within a month that the recurrence would happen.
 void setBySecond(int[] bySecond)
          Sets the list of values of second (within a minute) that the recurrence would happen.
 void setBySetPos(int[] bySetPos)
          Sets the list of values of occurrence within the set of recurrence instances specified by other fields of this rule.
 void setByWeekNo(int[] byWeekNo)
          Sets the list of values of week within a year that the recurrence would happen.
 void setByYearDay(int[] byYearDay)
          Sets the list of values of day within a year that the recurrence would happen.
 void setCount(int count)
          Sets the number of recurrence instances this rule will created.
 void setFreq(RecurFreq freq)
          Sets the freq field.
 void setInterval(int interval)
          Sets how often the recurrence repeats.
 void setUntil(java.util.Date until)
          Sets the time that the recurrence would end.
 void setWeekStart(WeekDay weekStart)
          Sets which day is regarded as the start of the work week.
 java.lang.String toString()
           
 java.lang.String toWcapQuery(WcapNugget nugget, java.text.DateFormat dfFull)
          Convert the component into a string that is used for constructing a WCAP query.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_RECURRENCE

public static final RecurRule NO_RECURRENCE
A convenience constant for indicating a removed recurrence rule. It is a weekly recurrence on sunday WITH COUNT=1.

Constructor Detail

RecurRule

public RecurRule(RecurFreq freq)
          throws InvalidParameterException
Default constructor.

The freq parameter specifies the frequency field of the recurrence rule. This field must be valid and present in every recurrence rule. The meaning of each field follows the RFC 2445 and WCAP commands documentation of Calendar Server's Programmer's Guide.

Programmers should use these constants instead of creating their own string. For example, you should have code like:

 RecurRule myRule = new RecurRule( RecurFreq.YEARLY );
 

After create an instance of RecurRule, you can set the sub rules by invoking the corresponding set*() methods. The order of the invocation of these methods will not affect the execution result.

Parameters:
freq - The RecurFreq object that indicates the frequency scope of the recurrence. The JavaDoc of RecurFreq class has more details.
Throws:
InvalidParameterException

RecurRule

public RecurRule(RecurFreq freq,
                 int count,
                 java.util.Date until,
                 int interval,
                 WeekDay weekStart,
                 int[] bySecond,
                 int[] byMinute,
                 int[] byHour,
                 java.lang.String[] byDay,
                 int[] byMonthDay,
                 int[] byYearDay,
                 int[] byWeekNo,
                 int[] byMonth,
                 int[] bySetPos)
          throws InvalidParameterException
Constructor for the advance recurrence rule. If your event/todo happens on regular intervals (e.g. monthly, yearly), you should use the default constructor instead.

The detail format and definition of the recurrence rule is defined in the RFC 2445.

Parameters:
freq - This field identifies the type of recurrence rule. This rule part MUST be specified in the recurrence rule. All of the valid values are defined as static constants of the class RecurFreq.

Valid values include SECONDLY, to specify repeating events/todos based on an interval of a second or more; MINUTELY, to specify repeating events/todos based on an interval of a minute or more; HOURLY, to specify repeating events/todos based on an interval of an hour or more; DAILY, to specify repeating events/todos based on an interval of a day or more; WEEKLY, to specify repeating events/todos based on an interval of a week or more; MONTHLY, to specify repeating events/todos based on an interval of a month or more; and YEARLY, to specify repeating events/todos based on an interval of a year or more.

count - Ths field defines the number of occurrences at which to range-bound the recurrence. If you specified a positive integer for this field, the method will ignore the field "until" by setting it to null. This parameter is optional. (It is because the RFC 2445 allows either count or until, but not both.) This parameter is regarded as unspecified if the value is a negative number or zero.

If you didn't specify this parameter and the parameter "until" at the same time, the server will treat this recurrence rule with the calendar server's default maximum count. This setting can be set with the "calstring.recurrence.bound" entry of in the ics.conf for iPlanet Calendar Server 5. For SunONE Calendar Server 6.0, this configuration is "calstore.recurrence.bound". For both versions of calendar server, the default configuration of this bound for recurrence count is 60.

Please note that this ICS behaviour is different from the RFC 2445 specification. In RFC 2445, a recurrence lasts forever if both count and until fields are not specified.

until - This parameter defines a date-time value which bounds the recurrence rule in an inclusive manner. This parameter is optional and can be set to null. If the value specified is synchronized with the specified recurrence, this date or date-time becomes the last instance of the recurrence. If specified as a date-time value, then it MUST be specified in an UTC time format.

If you didn't specify this parameter and the parameter "count" at the same time, the server will treat this recurrence rule with the calendar server's default maximum count. This setting can be set with the "calstring.recurrence.bound" entry of in the ics.conf for iPlanet Calendar Server 5. For SunONE Calendar Server 6.0, this configuration is "calstore.recurrence.bound". For both versions of calendar server, the default configuration of this bound for recurrence count is 60.

Please note that this ICS behaviour is different from the RFC 2445 specification. In RFC 2445, a recurrence lasts forever if both count and until fields are not specified.

interval - Sets how often the recurrence repeats. A valid interval is an integer value greater than 0. The unit of the interval depends on the freq field. For example, a interval value "2" for a rule with freq = RecurFreq.MONTHLY means the recurrence would repeat every two months.

If this field is set to an invalid value, this object will treat as if the interval is not set. The calendar server would use the default value "1" instead. (i.e. assuming it repeat every time based on the unit. For a RecurFreq.DAILY rule, this means the recurrence repeats every day.)

weekStart - A valid weekStart is a WeekDay object.

If this field is set to null, the server will not get any setting with respect to this field. The server will assume the default, which is Monday.

This field is significant when a WEEKLY rule has an interval greater than 1 and a ByDay setting. This is also significant when a YEARLY rule has a ByWeekNo setting.

bySecond - Sets the list of values of second (within a minute) that the recurrence would happen.

A valid bySecond field should be an array of integer. Each integer represents a value in second that the event should occur. The integer should have a value between 0 and 59, inclusive.

If this field is set to null, the server will not get any setting with respect to this field.

byMinute - Sets the list of values of minute (within an hour) that the recurrence would happen.

A valid byMinute field should be an array of integer. Each integer represents a value in minute that the event should occur. The integer should have a value between 0 and 59, inclusive.

If this field is set to null, the server will not get any setting with respect to this field.

byHour - Sets the list of values of hour (within a day) that the recurrence would happen.

A valid byHour field should be an array of integer. Each integer represents a value in hour that the event should occur. The integer should have a value between 0 and 23, inclusive.

If this field is set to null, the server will not get any setting with respect to this field.

byDay - Sets the list of values of day (within a week) that the recurrence would happen.

A valid byDay field should be an array of String. Each String represents a value of day that the vent should occur. The possible values are "MO", "TU", "WE", "TH", "FR", "SA" and "SU" (indicating Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday respectively). In addition, each value may be preceded by a possible +n or -n integer, which indicates the nth occurrence of the specific day within the month or year (depending on the freq setting).

For example, the following code will create an recurrence rule that will happened every month, on the Mondays and the last Sunday of the month.:

 String byDay[]   = new String[2];
 byDay[0] = "MO";   // every Monday of the month
 byDay[1] = "-1SU"; // every last Sunday happened in the month
 
 RecurRule myRule = new RecurRule( RecurFreq.MONTHLY );
 myRule.setByDay( byDay );
 

If this field is set to null, the server will not get any setting with respect to this field.

byMonthDay - Sets the list of values of day within a month that the recurrence would happen.

A valid byMonthDay field should be an array of integer. Each integer represents a value in day of month that the event should occur. The integer should have a value of 1 to 31, or, -31 to -1. The positive value indicates the normal way of day counting while the negative value indicates the last n-th day of the month. For example, -5 means the fifth last day of the month.

If this field is set to null, the server will not get any setting with respect to this field.

byYearDay - Sets the list of values of day within a year that the recurrence would happen.

A valid byYearDay field should be an array of integer. Each integer represents a value in day of year that the event should occur. The integer should have a value of 1 to 366, or, -366 to -1. The positive value indicates the normal way of day counting while the negative value indicates the last n-th day of the year. For example, -300 means the 300th to the last day of the year.

If this field is set to null, the server will not get any setting with respect to this field.

byWeekNo - Sets the list of values of week within a year that the recurrence would happen.

A valid byWeekNo field should be an array of integer. Each integer represents a value in week of year that the event should occur. The integer should have a value of 1 to 53 or, -53 to -1. The positive value indicates the normal way of week counting while the negative value indicates the last n-th week of the year. For example, -7 means the last seventh week of the year. while 11 means the 11th week from the beginning of the year. The week numbering is defined by ISO 8601. Week number one of the calendar year is the first week which contains at least four days of that calendar year.

If this field is set to null, the server will not get any setting with respect to this field.

byMonth - Sets the list of values of month that the recurrence would happen.

A valid byMonth field should be an array of integer. Each integer represents a value in month that the event should occur. The integer should have a value between 1 and 12, inclusive.

If this field is set to null, the server will not get any setting with respect to this field.

bySetPos - Sets the list of values of occurrence within the set of recurrence instances specified by other fields of this rule.

A valid bySetPos field should be an array of integer. Each integer represents a value of the position of the set of instances. The integer should have a value of 1 to 366 or -366 to -1.

If this field is set to null, the server will not get any setting with respect to this field. Moreover, if none of the other by*** fields are set, this field will also be ignored.

To better understand the meaning of bySetPos field, let's think about setting a recurrence for the first and last weekday of the year.

 // ---
 // Create the recurrence rule
 RecurRule myRule = new RecurRule( RecurFreq.YEARLY );

 // ---
 // Set up the weekday list
 String[] myByDay = new String[5];
 myByDay[0] = "MO";
 myByDay[1] = "TU";
 myByDay[2] = "WE";
 myByDay[3] = "TH";
 myByDay[4] = "FR";

 myRule.setByDay( myByDay );

 // So... at this point, we have a set of recurrence instances for
 // every weekday in the year.

 // ---
 // Set up the last weekday with position
 int[] myBySetPos = new int[2];
 mySetPos[0] = 1;
 mySetPos[1] = -1;
 
 myRule.setBySetPos( mySetPos );
 
 // Now... we have the first and last weekday of the year only.
 
Throws:
InvalidParameterException
Method Detail

setFreq

public void setFreq(RecurFreq freq)
             throws InvalidParameterException
Sets the freq field. This field must be a valid RecurFreq. This field MUST be specified in the recurrence rule. All of the valid values are defined as static constants of the class RecurFreq.

Valid values include SECONDLY, to specify repeating events/todos based on an interval of a second or more; MINUTELY, to specify repeating events/todos based on an interval of a minute or more; HOURLY, to specify repeating events/todos based on an interval of an hour or more; DAILY, to specify repeating events/todos based on an interval of a day or more; WEEKLY, to specify repeating events/todos based on an interval of a week or more; MONTHLY, to specify repeating events/todos based on an interval of a month or more; and YEARLY, to specify repeating events/todos based on an interval of a year or more.

Throws:
InvalidParameterException

getFreq

public RecurFreq getFreq()
Retrieves the freq field.


setCount

public void setCount(int count)
Sets the number of recurrence instances this rule will created. A valid count must have an integer value of greater than 0.

If a valid count is set, this method will invalidate the until field by setting it to null. (The RFC 2445 allows either count or until, but not both.)

If you have specified an invalid count, this object will not pass any recurrence count to the backend calendar server.

If you didn't both "count" and "until" fields are invalid at the same time, the server will treat this recurrence rule with the calendar server's default maximum count. This setting can be set with the "calstring.recurrence.bound" entry of in the ics.conf for iPlanet Calendar Server 5. For SunONE Calendar Server 6.0, this configuration is "calstore.recurrence.bound". For both versions of calendar server, the default configuration of this bound for recurrence count is 60.

Please note that this ICS behaviour is different from the RFC 2445 specification. In RFC 2445, a recurrence lasts forever if both count and until fields are not specified.


getCount

public int getCount()
Retrieves the count field (the number of recurrence instance).


setUntil

public void setUntil(java.util.Date until)
Sets the time that the recurrence would end. The until date is a time assumed to be in GMT (i.e. UTC). If the until date happens to be on the exact time of a recurrence, that recurrence would be the last instance created by this recurrence rule. (i.e. the time limit is inclusive.)

If a valid until date is set, this method will invalidate the count field by setting it to a negative number. (The RFC 2445 allows either count or until, but not both.)

If you have specified a null value, this object will treat the rule as if there is no until date.

If you didn't both "count" and "until" fields are invalid at the same time, the server will treat this recurrence rule with the calendar server's default maximum count. This setting can be set with the "calstring.recurrence.bound" entry of in the ics.conf for iPlanet Calendar Server 5. For SunONE Calendar Server 6.0, this configuration is "calstore.recurrence.bound". For both versions of calendar server, the default configuration of this bound for recurrence count is 60.

Please note that this ICS behaviour is different from the RFC 2445 specification. In RFC 2445, a recurrence lasts forever if both count and until fields are not specified.


getUntil

public java.util.Date getUntil()
Retrieves the until field (the time that the recurrence would end).


setInterval

public void setInterval(int interval)
Sets how often the recurrence repeats. A valid interval is an integer value greater than 0. The unit of the interval depends on the freq field. For example, a interval value "2" for a rule with freq = RecurFreq.MONTHLY means the recurrence would repeat every two months.

If this field is set to an invalid value, this object will treat as if the interval is not set. The calendar server would use the default value "1" instead. (i.e. assuming it repeat every time based on the unit. For a RecurFreq.DAILY rule, this means the recurrence repeats every day.)


getInterval

public int getInterval()
Retrieves the interval field (how often the recurrence repeats).


setWeekStart

public void setWeekStart(WeekDay weekStart)
Sets which day is regarded as the start of the work week. A valid weekStart is a WeekDay object.

If this field is set to null, the server will not get any setting with respect to this field. The server will assume the default, which is Monday.

This field is significant when a WEEKLY rule has an interval greater than 1 and a ByDay setting. This is also significant when a YEARLY rule has a ByWeekNo setting.


getWeekStart

public WeekDay getWeekStart()
Retrieves the weekStart field (which day is regarded as the start of the work week).


setBySecond

public void setBySecond(int[] bySecond)
Sets the list of values of second (within a minute) that the recurrence would happen.

A valid bySecond field should be an array of integer. Each integer represents a value in second that the event should occur. The integer should have a value between 0 and 59, inclusive.

If this field is set to null, the server will not get any setting with respect to this field.


getBySecond

public int[] getBySecond()
Retrieves the bySecond field (list of values of second that the recurrence would happen).


setByMinute

public void setByMinute(int[] byMinute)
Sets the list of values of minute (within an hour) that the recurrence would happen.

A valid byMinute field should be an array of integer. Each integer represents a value in minute that the event should occur. The integer should have a value between 0 and 59, inclusive.

If this field is set to null, the server will not get any setting with respect to this field.


getByMinute

public int[] getByMinute()
Retrieves the byMinute field (list of values of minute that the recurrence would happen).


setByHour

public void setByHour(int[] byHour)
Sets the list of values of hour (within a day) that the recurrence would happen.

A valid byHour field should be an array of integer. Each integer represents a value in hour that the event should occur. The integer should have a value between 0 and 23, inclusive.

If this field is set to null, the server will not get any setting with respect to this field.


getByHour

public int[] getByHour()
Retrieves the byHour field (list of values of hour that the recurrence would happen).


setByDay

public void setByDay(java.lang.String[] byDay)
Sets the list of values of day (within a week) that the recurrence would happen.

A valid byDay field should be an array of String. Each String represents a value of day that the vent should occur. The possible values are "MO", "TU", "WE", "TH", "FR", "SA" and "SU" (indicating Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday respectively). In addition, each value may be preceded by a possible +n or -n integer, which indicates the nth occurrence of the specific day within the month or year (depending on the freq setting).

For example, the following code will create an recurrence rule that will happened every month, on the Mondays and the last Sunday of the month.:

 String byDay[]   = new String[2];
 byDay[0] = "MO";   // every Monday of the month
 byDay[1] = "-1SU"; // every last Sunday happened in the month
 
 RecurRule myRule = new RecurRule( RecurFreq.MONTHLY );
 myRule.setByDay( byDay );
 

If this field is set to null, the server will not get any setting with respect to this field.


getByDay

public java.lang.String[] getByDay()
Retrieves the byDay field (list of values of day of week that the recurrence would happen).


setByMonthDay

public void setByMonthDay(int[] byMonthDay)
Sets the list of values of day within a month that the recurrence would happen.

A valid byMonthDay field should be an array of integer. Each integer represents a value in day of month that the event should occur. The integer should have a value of 1 to 31, or, -31 to -1. The positive value indicates the normal way of day counting while the negative value indicates the last n-th day of the month. For example, -5 means the fifth last day of the month.

If this field is set to null, the server will not get any setting with respect to this field.


getByMonthDay

public int[] getByMonthDay()
Retrieves the byMonthDay field (list of values of day of month that the recurrence would happen).


setByYearDay

public void setByYearDay(int[] byYearDay)
Sets the list of values of day within a year that the recurrence would happen.

A valid byYearDay field should be an array of integer. Each integer represents a value in day of year that the event should occur. The integer should have a value of 1 to 366, or, -366 to -1. The positive value indicates the normal way of day counting while the negative value indicates the last n-th day of the year. For example, -300 means the 300th to the last day of the year.

If this field is set to null, the server will not get any setting with respect to this field.


getByYearDay

public int[] getByYearDay()
Retrieves the byYearDay field (list of values of day of year that the recurrence would happen).


setByWeekNo

public void setByWeekNo(int[] byWeekNo)
Sets the list of values of week within a year that the recurrence would happen.

A valid byWeekNo field should be an array of integer. Each integer represents a value in week of year that the event should occur. The integer should have a value of 1 to 53 or, -53 to -1. The positive value indicates the normal way of week counting while the negative value indicates the last n-th week of the year. For example, -7 means the last seventh week of the year. while 11 means the 11th week from the beginning of the year. The week numbering is defined by ISO 8601. Week number one of the calendar year is the first week which contains at least four days of that calendar year.

If this field is set to null, the server will not get any setting with respect to this field.


getByWeekNo

public int[] getByWeekNo()
Retrieves the byWeekNo field (list of values of week of a year that the recurrence would happen).


setByMonth

public void setByMonth(int[] byMonth)
Sets the list of values of month that the recurrence would happen.

A valid byMonth field should be an array of integer. Each integer represents a value in month that the event should occur. The integer should have a value between 1 and 12, inclusive.

If this field is set to null, the server will not get any setting with respect to this field.


getByMonth

public int[] getByMonth()
Retrieves the byMonth field (list of values of month that the recurrence would happen).


setBySetPos

public void setBySetPos(int[] bySetPos)
Sets the list of values of occurrence within the set of recurrence instances specified by other fields of this rule.

A valid bySetPos field should be an array of integer. Each integer represents a value of the position of the set of instances. The integer should have a value of 1 to 366 or -366 to -1.

If this field is set to null, the server will not get any setting with respect to this field. Moreover, if none of the other by*** fields are set, this field will also be ignored.

To better understand the meaning of bySetPos field, let's think about setting a recurrence for the first and last weekday of the year.

 // ---
 // Create the recurrence rule
 RecurRule myRule = new RecurRule( RecurFreq.YEARLY );

 // ---
 // Set up the weekday list
 String[] myByDay = new String[5];
 myByDay[0] = "MO";
 myByDay[1] = "TU";
 myByDay[2] = "WE";
 myByDay[3] = "TH";
 myByDay[4] = "FR";

 myRule.setByDay( myByDay );

 // So... at this point, we have a set of recurrence instances for
 // every weekday in the year.

 // ---
 // Set up the last weekday with position
 int[] myBySetPos = new int[2];
 mySetPos[0] = 1;
 mySetPos[1] = -1;
 
 myRule.setBySetPos( mySetPos );
 
 // Now... we have the first and last weekday of the year only.
 


getBySetPos

public int[] getBySetPos()
Retrieves the bySetPos field (list of values of occurrence within the set of recurrence instances specified by other fields of this rule).


toWcapQuery

public java.lang.String toWcapQuery(WcapNugget nugget,
                                    java.text.DateFormat dfFull)
                             throws WcapException
Convert the component into a string that is used for constructing a WCAP query. This method is designed for internal use by the WcapNugget only. It will return a String that is ready to be incorporated into a WCAP query. The result string is an URLEncoded string of the recurrence/exclusion rule.

Sample output:

  1. "freq%3DWEEKLY"
    (freq=WEEKLY)
    - repeat everyweek
  2. "count%3D10%3Bfreq=DAILY%3BBYHOUR=10"
    (count=20;freq=DAILY;byHour=8)
    - repeat daily at 8 for 20 times

Parameters:
dfFull - A DateFormat object that can format a Date object into ISO 8601 Z string. i.e. yyyyMMddThhmmssZ (yyyy=year, MM=month, dd=day, hh=hour, mm=minute, ss=second, T and Z are the actual text to appear in the string).
Throws:
WcapException

equals

public boolean equals(java.lang.Object inObj)
Override the default java.lang.Object's equal command. This will compares the content of the fields. In case of a vector or array field, it will compare the content of the field.

Overrides:
equals in class java.lang.Object

convertFromString

public static RecurRule convertFromString(java.lang.String ruleStr,
                                          java.text.DateFormat dfFull)
                                   throws InvalidParameterException
Generate a RecurRule object from a string that follows the standard RFC 2445 recurrence rule format. e.g. "FREQ=WEEKLY;INTERVAL=1;BYDAY=SU;WKST=MO;COUNT=5" is a rule to repeat the component every week on SUNDAY for five times (including the instance it is associated to) and treat Monday as the start day of a week.

Parameters:
ruleStr - The rule string.
dfFull - If your rule string contains a until element, this method will require a dfFull format string that follows the standard ISO 8601 zulu representation. (i.e. a instance of DatFormat("yyyyMMdd'T'hhmmss'Z'") )
Throws:
InvalidParameterException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Nitido NiM 2.5 Java API

These JavaDoc pages are generated for release/nim_2_5-2.5.44

Copyright © 1999-2009 Nitido Inc.    Proprietary and Confidential.    All Rights Reserved.