|
PIM Optional Package 1.0 Final Release |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.pim.RepeatRule
Represents a description for a repeating pattern for an Event item. The fields are a subset of the capabilities of the RRULE field in VEVENT defined by the vCalendar 1.0 specification from the Internet Mail Consortium (http://www.imc.org). It is use to determine how often an associated Event occurs.
The fields of a Repeat Rule can conceptually be grouped into two categories:
FREQUENCY
, while all
other repeat rule fields are classified in the second category. This
classification of the fields aids in understanding of the relationship of the
fields and allows for a method to query for supported fields (see
EventList.getSupportedRepeatRuleFields(int)
).
A repeat rule typically needs to have its frequency set first and foremost. The following table shows the valid values for the frequency fields that can be set in RepeatRule:
Fields | Set Method | Valid Values |
---|---|---|
FREQUENCY |
setInt |
DAILY, WEEKLY, MONTHLY, YEARLY |
The following table shows the valid values for the fields that modify or refine the frequency of a RepeatRule:
Fields | Set Method | Valid Values |
---|---|---|
COUNT |
setInt |
any positive int |
INTERVAL |
setInt |
any positive int |
END |
setDate |
any valid Date |
MONTH_IN_YEAR |
setInt |
JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER,
NOVEMBER, DECEMBER (Note: that these are constants defined in the
RepeatRule class and are not the same as those in the Calendar class) |
DAY_IN_WEEK |
setInt |
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY (Note:
that these are constants defined in the RepeatRule class and are not the same
as those in the Calendar class) |
WEEK_IN_MONTH |
setInt |
FIRST, SECOND, THIRD, FOURTH, FIFTH, LAST, SECONDLAST, THIRDLAST, FOURTHLAST,
FIFTHLAST |
DAY_IN_MONTH |
setInt |
1-31 |
DAY_IN_YEAR |
setInt |
1-366 |
The following examples demonstrate some possible repeat values.
To specify the associated event occurs every day:
setInt(RepeatRule.FREQUENCY, RepeatRule.DAILY);
To specify the associated event occurs every day for the next five days:
setInt(RepeatRule.FREQUENCY, RepeatRule.DAILY);
setInt(RepeatRule.COUNT, 5);
To specify this event occurs every week on Monday and Tuesday:
setInt(RepeatRule.FREQUENCY, RepeatRule.WEEKLY);
setInt(RepeatRule.DAY_IN_WEEK, RepeatRule.MONDAY | RepeatRule.TUESDAY);
To specify the associated event occurs every third week on Friday:
setInt(RepeatRule.FREQUENCY, RepeatRule.WEEKLY);
setInt(RepeatRule.INTERVAL, 3);
setInt(RepeatRule.DAY_IN_WEEK, RepeatRule.FRIDAY);
To specify the associated event occurs every month on the Wednesday of the
second week until the end of the current year:
setInt(RepeatRule.FREQUENCY, RepeatRule.MONTHLY);
setInt(RepeatRule.WEEK_IN_MONTH, RepeatRule.SECOND);
setInt(RepeatRule.DAY_IN_WEEK, RepeatRule.WEDNESDAY);
java.util.Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, Calendar.DECEMBER);
cal.set(Calendar.DAY_OF_MONTH, 31);
cal.set(Calendar.AM_PM, Calendar.PM);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
setDate(RepeatRule.END, cal.getTime().getTime());
To specify the associated event occurs every year on the Sunday of the second
week in May:
setInt(RepeatRule.FREQUENCY, RepeatRule.YEARLY);
setInt(RepeatRule.MONTH_IN_YEAR, RepeatRule.MAY);
setInt(RepeatRule.WEEK_IN_MONTH, RepeatRule.SECOND);
setInt(RepeatRule.DAY_IN_WEEK, RepeatRule.SUNDAY);
To specify the associated event occurs every year on the 4th of July:
setInt(RepeatRule.FREQUENCY, RepeatRule.YEARLY);
setInt(RepeatRule.MONTH_IN_YEAR, RepeatRule.JULY);
setInt(RepeatRule.DAY_IN_MONTH, 4);
To specify the associated event occurs every year on the first day:
setInt(RepeatRule.FREQUENCY, RepeatRule.YEARLY);
setInt(RepeatRule.DAY_IN_YEAR, 1);
To check if a particular Repeat Rule frquency value is supported for events for
a certain event list:
// Check if RepeatRule.DAILY is supported in the default event list
EventList el = PIM.openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
int[] supported_fields = el.getSupportedRepeatRuleFields(RepeatRule.DAILY);
if (supported_fields.length > 0) {
System.out.println("RepeatRule.DAILY is supported in default event list");
}
To check if a particular Repeat Rule field is supported for events for a
certain event list:
// Check if RepeatRule.INTERVAL is supported for DAILY frequency events
EventList el = PIM.openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
int[] supported_fields = el.getSupportedRepeatRuleFields(RepeatRule.DAILY);
int i = 0;
while (i < supported_fields.length)
if (supported_fields[i] & RepeatRule.INTERVAL != 0) {
System.out.println("INTERVAL supported in default event list");
break;
}
Field Summary | |
static int |
APRIL
Constant for the month of April used with MONTH_IN_YEAR field. |
static int |
AUGUST
Constant for the month of August used with MONTH_IN_YEAR field. |
static int |
COUNT
Field specifying the number of times this event repeats including the first time, starting from the first time the event starts (derived from Event.START ) and
continuing to the last date of the repeat (defined by RepeatRule.END ). |
static int |
DAILY
Used for frequency when the Event happens every day. |
static int |
DAY_IN_MONTH
Field specifying the day of the month an Event occurs; for example, 15. |
static int |
DAY_IN_WEEK
Field specifying the days of the week an Event occurs. |
static int |
DAY_IN_YEAR
Field specifying the day of the year an Event occurs; for example, 134. |
static int |
DECEMBER
Constant for the month of December used with MONTH_IN_YEAR field. |
static int |
END
Field specifying the ending date of the repeating event. |
static int |
FEBRUARY
Constant for the month of February used with MONTH_IN_YEAR field. |
static int |
FIFTH
Constant for the fifth week of the month used with WEEK_OF_MONTH field. |
static int |
FIFTHLAST
Constant for the fifth to last week of the month used with WEEK_OF_MONTH field. |
static int |
FIRST
Constant for the first week of the month used with WEEK_OF_MONTH field. |
static int |
FOURTH
Constant for the fourth week of the month used with WEEK_OF_MONTH field. |
static int |
FOURTHLAST
Constant for the fourth to last week of the month used with WEEK_OF_MONTH field. |
static int |
FREQUENCY
Field specifying the frequency of the Repeat. |
static int |
FRIDAY
Constant for the day of week Friday used with DAY_IN_WEEK field. |
static int |
INTERVAL
Field specifying the number of iterations of the frequency between occurring dates, or how often the frequency repeats. |
static int |
JANUARY
Constant for the month of January used with MONTH_IN_YEAR field. |
static int |
JULY
Constant for the month of July used with MONTH_IN_YEAR field. |
static int |
JUNE
Constant for the month of June used with MONTH_IN_YEAR field. |
static int |
LAST
Constant for the last week of the month used with WEEK_OF_MONTH field. |
static int |
MARCH
Constant for the month of March used with MONTH_IN_YEAR field. |
static int |
MAY
Constant for the month of May used with MONTH_IN_YEAR field. |
static int |
MONDAY
Constant for the day of week Monday used with DAY_IN_WEEK field. |
static int |
MONTH_IN_YEAR
Field specifying the month in which an event occurs. |
static int |
MONTHLY
Used for frequency when the Event happens every month. |
static int |
NOVEMBER
Constant for the month of November used with MONTH_IN_YEAR field. |
static int |
OCTOBER
Constant for the month of October used with MONTH_IN_YEAR field. |
static int |
SATURDAY
Constant for the day of week Saturday used with DAY_IN_WEEK field. |
static int |
SECOND
Constant for the second week of the month used with WEEK_OF_MONTH field. |
static int |
SECONDLAST
Constant for the second to last week of the month used with WEEK_OF_MONTH field. |
static int |
SEPTEMBER
Constant for the month of September used with MONTH_IN_YEAR field. |
static int |
SUNDAY
Constant for the day of week Sunday used with DAY_IN_WEEK field. |
static int |
THIRD
Constant for the third week of the month used with WEEK_OF_MONTH field. |
static int |
THIRDLAST
Constant for the third to last week of the month used with WEEK_OF_MONTH field. |
static int |
THURSDAY
Constant for the day of week Thursday used with DAY_IN_WEEK field. |
static int |
TUESDAY
Constant for the day of week Tuesday used with DAY_IN_WEEK field. |
static int |
WEDNESDAY
Constant for the day of week Wednesday used with DAY_IN_WEEK field. |
static int |
WEEK_IN_MONTH
Field specifying which week in a month a particular event occurs. |
static int |
WEEKLY
Used for frequency when the Event happens every week. |
static int |
YEARLY
Used for frequency when the Event happens every year. |
Constructor Summary | |
RepeatRule()
Default constructor. |
Method Summary | |
void |
addExceptDate(long date)
Add a Date for which this RepeatRule should not occur. |
java.util.Enumeration |
dates(long startDate,
long subsetBeginning, long subsetEnding)
Returns an Enumeration of dates on which an Event would occur. |
boolean |
equals(java.lang.Object obj)
Compares this RepeatRule with a given RepeatRule for content equality. |
long |
getDate(int field)
Retrieves a Date field. |
java.util.Enumeration |
getExceptDates()
Returns the Dates for which this RepeatRule should not occur. |
int[] |
getFields()
Returns a list of fields that currently have values assigned to it. |
int |
getInt(int field)
Retrieves an integer field. |
void |
removeExceptDate(long date)
Remove a Date for which this RepeatRule should not occur. |
void |
setDate(int field,
long value)
Sets a Date field. |
void |
setInt(int field,
int value)
Sets an integer field. |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int FREQUENCY
DAILY
, WEEKLY
, MONTHLY
or YEARLY
.
The default data value associated with this field in RepeatRule is DAILY
.
This field can be checked for support by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int DAY_IN_MONTH
EventList.getSupportedRepeatRuleFields(int)
.
public static final int DAY_IN_WEEK
MONDAY | THURSDAY
). Retrieval of data
for this field can contain multiple days OR'd together in the same manner as
setting the value. This field can be checked for support in the bit array
values returned by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int DAY_IN_YEAR
EventList.getSupportedRepeatRuleFields(int)
.
public static final int MONTH_IN_YEAR
RepeatRule.JANUARY | RepeatRule.FEBRUARY
). Retrieval of data for this field can contain multiple months OR'd together
in the same manner as setting the value. This field can be checked for support
in the bit array values returned by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int WEEK_IN_MONTH
FIRST | LAST | SECOND |
SECONDLAST
). Retrieval of data for this field can contain multiple
weeks OR'd together in the same manner as setting the value. This field can be
checked for support in the bit array values returned by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int COUNT
Event.START
)
and continuing to the last date of the repeat (defined by RepeatRule.END
).
COUNT
controls the number of times the event occurs during the
period and is used with RepeatRule interval and the frequency to calculate when
the event occurs. RepeatRule.END
overrides this data if the end is
reached prior to the count finishing. If COUNT
is 0 and END
is null
, the event repeats forever. This field can be checked for
support in the bit array values returned by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int END
EventList.getSupportedRepeatRuleFields(int)
.
public static final int INTERVAL
FREQUENCY
is DAILY
and INTERVAL
is 2. The
default value for data associated with this field is 1. This field can be
checked for support in the bit array values returned by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int DAILY
public static final int WEEKLY
public static final int MONTHLY
public static final int YEARLY
public static final int FIRST
WEEK_OF_MONTH
field.
public static final int SECOND
WEEK_OF_MONTH
field.
public static final int THIRD
WEEK_OF_MONTH
field.
public static final int FOURTH
WEEK_OF_MONTH
field.
public static final int FIFTH
WEEK_OF_MONTH
field.
public static final int LAST
WEEK_OF_MONTH
field.
public static final int SECONDLAST
WEEK_OF_MONTH
field.
public static final int THIRDLAST
WEEK_OF_MONTH
field.
public static final int FOURTHLAST
WEEK_OF_MONTH
field.
public static final int FIFTHLAST
WEEK_OF_MONTH
field.
public static final int SATURDAY
DAY_IN_WEEK
field.
public static final int FRIDAY
DAY_IN_WEEK
field.
public static final int THURSDAY
DAY_IN_WEEK
field.
public static final int WEDNESDAY
DAY_IN_WEEK
field.
public static final int TUESDAY
DAY_IN_WEEK
field.
public static final int MONDAY
DAY_IN_WEEK
field.
public static final int SUNDAY
DAY_IN_WEEK
field.
public static final int JANUARY
MONTH_IN_YEAR
field.
public static final int FEBRUARY
MONTH_IN_YEAR
field.
public static final int MARCH
MONTH_IN_YEAR
field.
public static final int APRIL
MONTH_IN_YEAR
field.
public static final int MAY
MONTH_IN_YEAR
field.
public static final int JUNE
MONTH_IN_YEAR
field.
public static final int JULY
MONTH_IN_YEAR
field.
public static final int AUGUST
MONTH_IN_YEAR
field.
public static final int SEPTEMBER
MONTH_IN_YEAR
field.
public static final int OCTOBER
MONTH_IN_YEAR
field.
public static final int NOVEMBER
MONTH_IN_YEAR
field.
public static final int DECEMBER
MONTH_IN_YEAR
field.
Constructor Detail |
public RepeatRule()
Method Detail |
public java.util.Enumeration dates(long startDate, long subsetBeginning, long subsetEnding)
startDate
- the start date for the sequence,
from which the repeat rule is applied to generate possible occurrence dates.
This value must be expressed in the same long value format as java.util.Date,
which is milliseconds since the epoch (00:00:00 GMT, January 1, 1970).subsetBeginning
- the beginning date of the period for which events should be returned. This
value must be expressed in the same long value format as java.util.Date, which
is milliseconds since the epoch (00:00:00 GMT, January 1, 1970).subsetEnding
- the end date of the period for which events should be returned. This value
must be expressed in the same long value format as java.util.Date, which is
milliseconds since the epoch (00:00:00 GMT, January 1, 1970).
java.util.Date
instances. java.lang.IllegalArgumentException
- if beginning
is
greater than ending
.public void addExceptDate(long date)
date
- the date to add to the list of except
dates, expressed in the same long value format as java.util.Date, which is
milliseconds since the epoch (00:00:00 GMT, January 1, 1970).public void removeExceptDate(long date)
date
- the date to remove from the list of
except dates expressed in the same long value format as java.util.Date, which
is milliseconds since the epoch (00:00:00 GMT, January 1, 1970).public java.util.Enumeration getExceptDates()
java.util.Date
instances.public int getInt(int field)
COUNT,
DAY_IN_MONTH, FREQUENCY, INTERVAL, MONTH_IN_YEAR, WEEK_IN_MONTH, DAY_IN_WEEK,
DAY_IN_YEAR
.
getFields()
should be checked prior to invoking the method
to ensure the field has a value associated with it.
field
- The field to get, for example COUNT
.
java.lang.IllegalArgumentException
- if field is not one of the
the valid RepeatRule fields for this method.
FieldEmptyException
- if the field does is a valid integer field but does not have any data values
assigned to it.public void setInt(int field, int value)
COUNT, DAYNUMBER,
FREQUENCY, INTERVAL, MONTH_IN_YEAR, WEEK_IN_MONTH, DAY_IN_WEEK, DAY_IN_YEAR
.
field
- The field to set, for example COUNT
.value
- The value to set the field to. java.lang.IllegalArgumentException
- if field is not one of the
the valid RepeatRule fields for this method, or the value provided is not a
valid value for the given field.public long getDate(int field)
END
.
getFields()
should be checked prior to invoking the method to ensure the field has a value
associated with it.
field
- The field to get. java.lang.IllegalArgumentException
- if field is not one of the
the valid RepeatRule fields for this method.
FieldEmptyException
- if the field does is a valid date field but does not have any data values
assigned to it.public void setDate(int field, long value)
END
.
This field may be rounded off to the date only from a date time stamp if the
underlying platform implementation only supports date fields with dates only
and not date time stamps.
field
- The field to set.value
-
The value to set the field to, expressed in the same long value format as
java.util.Date, which is milliseconds since the epoch (00:00:00 GMT, January 1,
1970). java.lang.IllegalArgumentException
- if field is not one of the
the valid RepeatRule fields for this method.public int[] getFields()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- another RepeatRule object to compare
against
|
Final Release Rev. 1.00 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |