|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.microedition.pim.RepeatRule
public class 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:
This means that a Repeat Rule's calculation of applicable dates starts with a
repeating frequency (such as weekly, daily, yearly, or monthly) and then
other fields refine or modify the repeat characteristics according to the
field (e.g. the COUNT
field specifies that only X repeat
occurrences happen at the given frequency). The first category contains only
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 frequency 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;
}
Event.setRepeat(RepeatRule)
,
Event.getRepeat()
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_IN_MONTH field. |
|
static int |
FIFTHLAST
Constant for the fifth to last week of the month used with WEEK_IN_MONTH field. |
|
static int |
FIRST
Constant for the first week of the month used with WEEK_IN_MONTH field. |
|
static int |
FOURTH
Constant for the fourth week of the month used with WEEK_IN_MONTH field. |
|
static int |
FOURTHLAST
Constant for the fourth to last week of the month used with WEEK_IN_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_IN_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 |
MONTHLY
Used for frequency when the Event happens every month. |
|
static int |
MONTH_IN_YEAR
Field specifying the month in which an event occurs. |
|
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_IN_MONTH field. |
|
static int |
SECONDLAST
Constant for the second to last week of the month used with WEEK_IN_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_IN_MONTH field. |
|
static int |
THIRDLAST
Constant for the third to last week of the month used with WEEK_IN_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 |
WEEKLY
Used for frequency when the Event happens every week. |
|
static int |
WEEK_IN_MONTH
Field specifying which week in a month a particular event occurs. |
|
static int |
YEARLY
Used for frequency when the Event happens every year. |
Constructor Summary | ||
---|---|---|
RepeatRule()
Creates a new RepeatRule instance. |
Method Summary | ||
---|---|---|
void |
addExceptDate(long date)
Add a Date for which this RepeatRule should not occur. |
|
Enumeration |
dates(long startDate,
long subsetBeginning,
long subsetEnding)
Returns an Enumeration of dates on which an Event would
occur. |
|
boolean |
equals(Object obj)
Compares this RepeatRule with a given
RepeatRule for content equality. |
|
long |
getDate(int field)
Retrieves a date field. |
|
Enumeration |
getExceptDates()
Returns the Dates for which this RepeatRule should not
occur. |
|
int[] |
getFields()
Returns a list of fields that currently have values assigned. |
|
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 the value of a date field. |
|
void |
setInt(int field,
int value)
Sets the value of an integer field. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
(zero) and END
is
null
, the event repeats forever.
This field can be checked for support by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int DAY_IN_MONTH
This field can be checked for support by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int DAY_IN_WEEK
MONDAY|THURSDAY
).
Retrieval of data for this field can contain multiple days bitwise-OR'd
together in the same manner as setting the value.
Valid values for this field are:
RepeatRule.SUNDAY
RepeatRule.MONDAY
RepeatRule.TUESDAY
RepeatRule.WEDNESDAY
RepeatRule.THURSDAY
RepeatRule.FRIDAY
RepeatRule.SATURDAY
This field can be checked for support by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int DAY_IN_YEAR
This field can be checked for support by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int END
Date
, which is milliseconds since the epoch (00:00:00
GMT, January 1, 1970).
This field can be checked for support by
EventList.getSupportedRepeatRuleFields(int)
.
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 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 by
EventList.getSupportedRepeatRuleFields(int)
.
public static final int MONTH_IN_YEAR
JANUARY|FEBRUARY
). Retrieval of data for this field can
contain multiple months bitwise-OR'd together in the same manner as
setting the value.
Valid values for this field are:
RepeatRule.JANUARY
RepeatRule.FEBRUARY
RepeatRule.MARCH
RepeatRule.APRIL
RepeatRule.MAY
RepeatRule.JUNE
RepeatRule.JULY
RepeatRule.AUGUST
RepeatRule.SEPTEMBER
RepeatRule.OCTOBER
RepeatRule.NOVEMBER
RepeatRule.DECEMBER
This field can be checked for support 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 bitwise-OR'd together in the same manner
as setting the value.
Valid values for this field are:
RepeatRule.FIRST
RepeatRule.SECOND
RepeatRule.THIRD
RepeatRule.FOURTH
RepeatRule.FIFTH
RepeatRule.LAST
RepeatRule.SECONDLAST
RepeatRule.THIRDLAST
RepeatRule.FOURTHLAST
RepeatRule.FIFTHLAST
This field can be checked for support 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_IN_MONTH
field.
public static final int SECOND
WEEK_IN_MONTH
field.
public static final int THIRD
WEEK_IN_MONTH
field.
public static final int FOURTH
WEEK_IN_MONTH
field.
public static final int FIFTH
WEEK_IN_MONTH
field.
public static final int LAST
WEEK_IN_MONTH
field.
public static final int SECONDLAST
WEEK_IN_MONTH
field.
public static final int THIRDLAST
WEEK_IN_MONTH
field.
public static final int FOURTHLAST
WEEK_IN_MONTH
field.
public static final int FIFTHLAST
WEEK_IN_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()
RepeatRule
instance.
Method Detail |
---|
public Enumeration dates(long startDate, long subsetBeginning, long subsetEnding)
Enumeration
of dates on which an Event would
occur. A start date is specified from which the repeating rule is applied
to generate dates. Then a beginning date and a start date is also
provided to return only a subset of all possible occurrences of an Event
within the given timeframe. The sequence of the items is by date.
Exceptional dates are not included in the returned
Enumeration
. For example, an Event may happen every
Monday during a year starting on January 1st. However, one wants to know
occurrences of the Event during the month of June only. The
startDate
parameter specifies the anchor point for the
Event from which it begins repeating, and the
subsetBeginning
and subsetEnding
parameters
would limit the Events returned to those only in June in this example.
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 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 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 Date
, which is
milliseconds since the epoch (00:00:00 GMT, January 1,
1970).
Enumeration
of dates for the given parameters,
with the Enumeration
containing
Date
instances.public void addExceptDate(long date)
RepeatRule
should not occur.
This value 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.
date
- the date to add to the list of except dates, expressed in
the same long value format as Date
,
which is milliseconds since the epoch (00:00:00 GMT,
January 1, 1970).RepeatRule.getExceptDates()
,
RepeatRule.removeExceptDate(long)
public void removeExceptDate(long date)
RepeatRule
should not occur.
If the date was in the list of except dates, it is removed; otherwise,
does nothing.
date
- the date to remove from the list of except dates expressed
in the same long value format as Date
,
which is milliseconds since the epoch (00:00:00 GMT,
January 1, 1970).RepeatRule.addExceptDate(long)
,
RepeatRule.getExceptDates()
public Enumeration getExceptDates()
RepeatRule
should not
occur.
Enumeration
of dates for which this
RepeatRule
should not occur, with the
Enumeration
containing Date
instances.RepeatRule.addExceptDate(long)
,
RepeatRule.removeExceptDate(long)
public int getInt(int field)
RepeatRule.getFields()
method should be
checked prior to invoking the method to ensure the field has a value
associated with it.
field
- the field whose value to get; valid values are
RepeatRule.COUNT
, RepeatRule.DAY_IN_MONTH
,
RepeatRule.FREQUENCY
, RepeatRule.INTERVAL
,
RepeatRule.MONTH_IN_YEAR
, RepeatRule.WEEK_IN_MONTH
,
RepeatRule.DAY_IN_WEEK
, and RepeatRule.DAY_IN_YEAR
.
IllegalArgumentException
- if field is not one of the the valid
RepeatRule
fields for this method.
FieldEmptyException
- if the field is a valid integer field but does not have
any data values assigned to it.RepeatRule.setInt(int, int)
,
RepeatRule.getFields()
public void setInt(int field, int value)
field
- the field whose value to set; valid values are
RepeatRule.COUNT
, RepeatRule.DAY_IN_MONTH
,
RepeatRule.FREQUENCY
, RepeatRule.INTERVAL
,
RepeatRule.MONTH_IN_YEAR
, RepeatRule.WEEK_IN_MONTH
,
RepeatRule.DAY_IN_WEEK
, and RepeatRule.DAY_IN_YEAR
.value
- the value to set the field to.
IllegalArgumentException
- if field is not one of the the valid
RepeatRule
fields for this method.RepeatRule.getInt(int)
,
RepeatRule.getFields()
public long getDate(int field)
RepeatRule.getFields()
method should be checked
prior to invoking the method to ensure the field has a value associated
with it.
field
- the field whose value to get; the only valid value is
RepeatRule.END
IllegalArgumentException
- if field is not one of the the valid
RepeatRule
fields for this method.
FieldEmptyException
- if the field is a valid date field but does not have any
data values assigned to it.RepeatRule.setDate(int, long)
,
RepeatRule.getFields()
public void setDate(int field, long value)
field
- the field whose value to set; the only valid value is
RepeatRule.END
value
- the value to set the field to.
IllegalArgumentException
- if field is not one of the the valid
RepeatRule
fields for this method.RepeatRule.getDate(int)
,
RepeatRule.getFields()
public int[] getFields()
public boolean equals(Object obj)
RepeatRule
with a given
RepeatRule
for content equality. For RepeatRules, dates
are considered equal if one or both of the dates compared contains a date
only with no timestamp and the date values are equal regardless of the
time qualifier. This rule accounts for platform dependent rounding off of
dates from date time stamps to dates only. For example, a date value of
3/14/03 with no time stamp is considered equal to a date value of 3/14/03
with a time stamp. If the application requires that dates be exactly
equal, comparisons should be made explicitly outside of this method.
equals
in class Object
obj
- the object to compare to this object
true
if obj
is a non-null instance
of RepeatRule
and its contents are equivalent to
this Repeat Rule's contents; false
otherwise.Boolean.hashCode()
,
Hashtable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal