|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.columbia.cpl.Recurrence
Recurrence
represents a recurring interval of time. It
corresponds to a CPL time-switch or an iCalendar RRULE.
A recurring interval of time is represented by a start time, a duration (equivalently, an ending time), a frequency, an interval, a termination ("until") date or recurrence count, and a set of by* rules. For more information on this, see below, and the relevant specifications.
Change history:
Field Summary | |
protected DayAndPosition[] |
byDay
Internal byDay variable. |
protected int[] |
byHour
Internal byHour variable. |
protected int[] |
byMinute
Internal byMinute variable. |
protected int[] |
byMonth
Internal byMonth variable. |
protected int[] |
byMonthDay
Internal byMonthDay variable. |
protected int[] |
bySecond
Internal bySecond variable. |
protected int[] |
byWeekNo
Internal byWeekNo variable. |
protected int[] |
byYearDay
Internal byYearDay variable. |
protected int |
count
Internal count variable. |
static int |
DAILY
The value of frequency indicating a daily recurrence. |
protected Calendar |
dtStart
Internal dtStart variable. |
protected Duration |
duration
Internal duration variable. |
protected int |
frequency
Internal frequency variable. |
static int |
HOURLY
The value of frequency indicating an hourly recurrence. |
protected int |
interval
Internal interval variable. |
static long |
max_count_loops
The maximum number of candidate start times we're willing to consider for count to resolve it to until . |
static long |
max_count_time
The last time we're willing to search for count to resolve
it to until . |
static int |
MINUTELY
The value of frequency indicating a minutely recurrence. |
static int |
MONTHLY
The value of frequency indicating a monthly recurrence. |
static int |
NO_RECURRENCE
The value of frequency indicating no recurrence. |
static int |
SECONDLY
The value of frequency indicating a secondly recurrence. |
static boolean |
strict_count_bounds
Whether to throw an exception if a conversion from count
to until exceeds its defined bounaries, or simply to
assume the count is effectively infinite. |
protected Calendar |
until
Internal until variable. |
static int |
WEEKLY
The value of frequency indicating a weekly recurrence. |
static int |
YEARLY
The value of frequency indicating a yearly recurrence. |
Constructor Summary | |
Recurrence()
Allocate a new Recurrence, with no recurrence frequency, starting at time = 0, duration 0. |
|
Recurrence(Calendar start,
Duration dur)
Allocate a new Recurrence, with no recurrence frequency. |
|
Recurrence(Calendar start,
Duration dur,
int freq)
Allocate a new Recurrence, with the specified frequency. |
Method Summary | |
protected static void |
adjust_constant_length_field(int field,
Calendar start,
Calendar candidate,
boolean is_forward)
Adjust the time specified by candidate so that the field
field equals that of start . |
protected static void |
adjust_day_of_month(Calendar start,
Calendar candidate,
boolean is_forward)
Adjust the time specified by candidate until its day of
the month equals that of start . |
protected static void |
adjust_day_of_year(Calendar start,
Calendar candidate,
boolean is_forward)
Adjust the time specified by candidate until its day of
the year equals that of start . |
protected boolean |
candidateIsInRecurrence(Calendar candidate,
boolean debug)
Check whether a particular candidate start time falls within a reptition of the recurrence. |
Object |
clone()
Overrides Cloneable |
void |
computeUntilFromCount()
If count is set and until is not, calculate
until from count . |
void |
computeUntilFromCount(boolean debug)
Debugging interface to computeUntilFromCount() . |
String |
generateDateTimeString(Calendar cal)
Generate a standard Date-Time string for the given calendar. |
String |
generateDaySetString(DayAndPosition[] set)
Generate a comma-separated DayAndPosition set string (as used in BYDAY arguments). |
protected String |
generateIntSetString(int[] set)
Generate a comma-separated int-set string (as used in BY* arguments). |
DayAndPosition[] |
getByDay()
Get the array of day-of-the-week and position constraints for this recurrence. |
String |
getByDayString()
Get a string representing the day-of-the-week and position constraints for this recurrence. |
int[] |
getByHour()
Get the array of hours-of-the-day constraints for this recurrence. |
String |
getByHourString()
Get a string representing the hours-of-the-day constraints for this recurrence. |
int[] |
getByMinute()
Get the array of minutes-of-the-hour constraints for this recurrence. |
String |
getByMinuteString()
Get a string representing the minutes-of-the-hour constraints for this recurrence. |
int[] |
getByMonth()
Get the array of month constraints for this recurrence. |
int[] |
getByMonthDay()
Get the array of day-of-the-month constraints for this recurrence. |
String |
getByMonthDayString()
Get a string representing the day-of-the-month constraints for this recurrence. |
String |
getByMonthString()
Get a string representing the month constraints for this recurrence. |
int[] |
getBySecond()
Get the array of seconds-of-the-minute constraints for this recurrence. |
String |
getBySecondString()
Get a string representing the seconds-of-the-minute constraints for this recurrence. |
int[] |
getByWeekNo()
Get the array of week-number constraints for this recurrence. |
String |
getByWeekNoString()
Get a string representing the week-number constraints for this recurrence. |
int[] |
getByYearDay()
Get the array of day-of-the-year constraints for this recurrence. |
String |
getByYearDayString()
Get a string representing the day-of-the-year constraints for this recurrence. |
Calendar |
getCandidateStartTime(Calendar current,
boolean is_forward,
boolean debug)
Get the candidate start time for this recurrence, for a given date. |
int |
getCount()
Get the repeat count of the recurrence. |
String |
getCountString()
Get the repeat count of the recurrence, as a string. |
Calendar |
getDtEnd()
Get the end time of the recurrence. |
String |
getDtEndString()
Get a string representing the end time of the recurrence. |
Calendar |
getDtStart()
Get the start time of the recurrence. |
String |
getDtStartString()
Get a string representation of the start time of the recurrence. |
Duration |
getDuration()
Get the duration of the recurrence. |
String |
getDurationString()
Get the duration of the recurrence, represented as a string. |
protected static long |
getFieldNumber(Calendar cal,
int field)
Get the field number corresponding to the date of this calendar (field intervals — seconds, minutes, hours, or days — since the Epoch). |
protected static int |
getFixedSizeInt(String str,
int pos,
int ext,
String fieldname)
Support function for parseDateTime. |
int |
getFrequency()
Get the frequency of the recurrence. |
String |
getFrequencyString()
Get the frequency of the recurrence, as a string. |
int |
getInterval()
Get the interval of the recurrence. |
String |
getIntervalString()
Get the interval of the recurrence, as a string. |
protected int |
getMinimumInterval()
Get the minimum interval for this recurrence, based on the by* parameters and the frequency. |
protected static long |
getMonthNumber(Calendar cal)
Get the month number corresponding to the date of this calendar (months since the Epoch). |
protected long |
getRecurrenceCount(Calendar candidate)
Get the number of instances of the current recurrence frequency that have occured between this recurrence's dtStart, and the time specified by candidate . |
Calendar |
getUntil()
Get the upper bound of the recurrence. |
String |
getUntilString()
Get a string representing the upper bound of the recurrence, or the empty string if unbounded. |
protected static long |
getWeekNumber(Calendar cal)
Get the week number corresponding to the date of this calendar (weeks since the Epoch). |
int |
getWeekStart()
Get the first day of the week for this recurrence. |
String |
getWeekStartString()
Get the first day of the week for this recurrence, as a string. |
protected Calendar |
internalGetCandidateStartTime(Calendar current,
boolean is_forward,
boolean debug)
Internal version of getCandidateStartTime. |
boolean |
isInRecurrence(Calendar current)
Test if the specified time falls within a repetition of this recurrence. |
boolean |
isInRecurrence(Calendar current,
boolean debug)
Debugging interface to isInRecurrence(java.util.Calendar) . |
protected boolean |
matchesByDay(Calendar candidate)
Determine if candidate matches the recurrence's
byDay rules. |
protected static boolean |
matchesByField(int[] array,
int field,
Calendar candidate,
boolean allowNegative)
Determine if field field of candidate matches
an entry in array |
protected boolean |
matchesByHour(Calendar candidate)
Determine if candidate matches the recurrence's
byHour rules. |
protected boolean |
matchesByMinute(Calendar candidate)
Determine if candidate matches the recurrence's
byMinute rules. |
protected boolean |
matchesByMonth(Calendar candidate)
Determine if candidate matches the recurrence's
byMonth rules. |
protected boolean |
matchesByMonthDay(Calendar candidate)
Determine if candidate matches the recurrence's
byMonthDay rules. |
protected boolean |
matchesBySecond(Calendar candidate)
Determine if candidate matches the recurrence's
bySecond rules. |
protected boolean |
matchesByWeekNo(Calendar candidate)
Determine if candidate matches the recurrence's
byWeekNo rules. |
protected boolean |
matchesByYearDay(Calendar candidate)
Determine if candidate matches the recurrence's
byYearDay rules. |
protected boolean |
matchesIndividualByDay(Calendar candidate,
DayAndPosition pos)
Determine if candidate matches one individual
DayAndPosition . |
static Calendar |
parseDateTime(String str)
Parse the given Date-Time string into a Calendar object. |
protected DayAndPosition[] |
parseDaySet(String str)
Parse the given comma-separated list of integers into a DayAndPosition[]. |
protected static int[] |
parseIntSet(String str,
String name,
int min,
int max,
boolean neg_ok)
Parse the given comma-separated list of integers into a int[]. |
void |
setByDay(DayAndPosition[] b)
Set the array of day-of-the-week and position constraints for this recurrence. |
void |
setByDay(String b)
Set the list of day-of-the-week and position constraints for this recurrence. |
void |
setByHour(int[] b)
Set the array of hours-of-the-day constraints for this recurrence. |
void |
setByHour(String b)
Set the list of hours-of-the-day constraints for this recurrence. |
void |
setByMinute(int[] b)
Set the array of minutes-of-the-hour constraints for this recurrence. |
void |
setByMinute(String b)
Set the list of minutes-of-the-hour constraints for this recurrence. |
void |
setByMonth(int[] b)
Set the array of month constraints for this recurrence. |
void |
setByMonth(String b)
Set the list of month constraints for this recurrence. |
void |
setByMonthDay(int[] b)
Set the array of day-of-the-month constraints for this recurrence. |
void |
setByMonthDay(String b)
Set the list of day-of-the-month constraints for this recurrence. |
void |
setBySecond(int[] b)
Set the array of seconds-of-the-minute constraints for this recurrence. |
void |
setBySecond(String b)
Set the list of seconds-of-the-minute constraints for this recurrence. |
void |
setByWeekNo(int[] b)
Set the array of week-number constraints for this recurrence. |
void |
setByWeekNo(String b)
Set the list of week-number constraints for this recurrence. |
void |
setByYearDay(int[] b)
Set the array of day-of-the-year constraints for this recurrence. |
void |
setByYearDay(String b)
Set the list of day-of-the-year constraints for this recurrence. |
protected static void |
setCalendarWeekStart(Calendar cal,
int start)
Set the given calendar's week start value to start , and
set its minimal days in first week to 4. |
void |
setCount(int c)
Set the repeat count of the recurrence. |
void |
setCount(String c)
|
void |
setDtEnd(Calendar end)
Set the end time of the recurrence. |
void |
setDtEnd(String end)
Set the end time of the recurrence. |
void |
setDtStart(Calendar start)
Set the start time of the recurrence. |
void |
setDtStart(String start)
Set the start time of the recurrence. |
void |
setDuration(Duration d)
Set the duration of the recurrence. |
void |
setDuration(String str)
Set the duration of the recurrence. |
void |
setFrequency(int freq)
Set the frequency of the recurrence. |
void |
setFrequency(String freq)
Set the frequency of the recurrence. |
void |
setInterval(int intr)
Set the interval of the recurrence. |
void |
setInterval(String intr)
Set the interval of the recurrence, from a string. |
void |
setUntil(Calendar u)
Set the upper bound of the recurrence. |
void |
setUntil(String u)
Set the upper bound of a recurrence, based on a string. |
void |
setWeekStart(int weekstart)
Set the first day of the week for this recurrence. |
void |
setWeekStart(String weekstart)
Set the first day of the week for this recurrence. |
String |
stringizeIntArray(int[] a)
|
String |
toString()
Return a string representation of this recurrence. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int SECONDLY
setFrequency(int)
,
Constant Field Valuespublic static final int MINUTELY
setFrequency(int)
,
Constant Field Valuespublic static final int HOURLY
setFrequency(int)
,
Constant Field Valuespublic static final int DAILY
setFrequency(int)
,
Constant Field Valuespublic static final int WEEKLY
setFrequency(int)
,
Constant Field Valuespublic static final int MONTHLY
setFrequency(int)
,
Constant Field Valuespublic static final int YEARLY
setFrequency(int)
,
Constant Field Valuespublic static final int NO_RECURRENCE
setFrequency(int)
,
Constant Field Valuesprotected Calendar dtStart
getDtStart()
,
setDtStart(java.util.Calendar)
protected Duration duration
getDuration()
,
setDuration(edu.columbia.cpl.Duration)
protected int frequency
getFrequency()
,
setFrequency(int)
protected int interval
getInterval()
,
setInterval(int)
protected Calendar until
getUntil()
,
setUntil(java.util.Calendar)
protected int count
getCount()
,
setCount(int)
protected int[] bySecond
getBySecond()
,
setBySecond(int[])
protected int[] byMinute
getByMinute()
,
setByMinute(int[])
protected int[] byHour
getByHour()
,
setByHour(int[])
protected DayAndPosition[] byDay
getByDay()
,
setByDay(edu.columbia.cpl.DayAndPosition[])
protected int[] byMonthDay
getByMonthDay()
,
setByMonthDay(int[])
protected int[] byYearDay
getByYearDay()
,
setByYearDay(int[])
protected int[] byWeekNo
getByWeekNo()
,
setByWeekNo(int[])
protected int[] byMonth
getByMonth()
,
setByMonth(int[])
public static long max_count_time
count
to resolve
it to until
. If a recurrence exceeds this instant before
it's filled its counts, consider it infinite, or throw an exception,
depending on the value of strict_count_bounds.
The default value of this parameter is 2000000000000L, or Wednesday, May 18, 2033 03:33:20.000 UTC. This is comfortably less than time_t (2^31 - 1), so we don't have to worry about rounding on systems which implement java.util.Calendar's support functions on a 32-bit time_t.
computeUntilFromCount()
,
strict_count_bounds
public static long max_count_loops
count
to resolve it to until
. If a
recurrence exceeds this instant before it's filled its counts, consider
it infinite, or throw an exception, depending on the value of
strict_count_bounds.
The default value of this parameter is 10000.
computeUntilFromCount()
,
strict_count_bounds
public static boolean strict_count_bounds
count
to until
exceeds its defined bounaries, or simply to
assume the count is effectively infinite.
The default value of this parameter is false.
computeUntilFromCount()
,
max_count_time
,
max_count_loops
Constructor Detail |
public Recurrence()
public Recurrence(Calendar start, Duration dur)
start
- The start time, as a broken-down time. (Only the calendar
fields are used. Use setWeekStart(int)
rather
than Calendar.setFirstDayOfWeek(int)
to set the
first day of the week.)dur
- The duration.setWeekStart(int)
public Recurrence(Calendar start, Duration dur, int freq)
start
- The start time, as a broken-down time. (Only the calendar
fields are used. Use setWeekStart(int)
rather
than Calendar.setFirstDayOfWeek(int)
to set the
first day of the week.)dur
- The duration.freq
- The recurrence frequency (one of
DAILY
, WEEKLY
,
MONTHLY
, YEARLY
,
or NO_RECURRENCE
).setWeekStart(int)
Method Detail |
public Calendar getDtStart()
public String getDtStartString()
public void setDtStart(Calendar start)
start
- The start time, as a broken-down time. (Only the calendar
fields are used. Use setWeekStart(int)
rather
than Calendar.setFirstDayOfWeek(int)
to set the
first day of the week.)setWeekStart(int)
public void setDtStart(String start)
start
- The start time, as a string.
IllegalArgumentException
- If the given string does not describe
a valid Date-Time.public Duration getDuration()
public String getDurationString()
public void setDuration(Duration d)
d
- The duration.public void setDuration(String str)
str
- A string representing the duration.
IllegalArgumentException
- If the given string does not describe
a valid Duration.public Calendar getDtEnd()
public String getDtEndString()
public void setDtEnd(Calendar end)
end
- The end time.public void setDtEnd(String end)
end
- The end time, as a string.
IllegalArgumentException
- If the given string does not describe
a valid Date-Time.public int getFrequency()
SECONDLY
, MINUTELY
,
HOURLY
,
DAILY
, WEEKLY
,
MONTHLY
, YEARLY
,
or NO_RECURRENCE
).public String getFrequencyString()
null
representing no recurrence).public void setFrequency(int freq)
freq
- The recurrence frequency (one of
SECONDLY
, MINUTELY
,
HOURLY
,
DAILY
, WEEKLY
,
MONTHLY
, YEARLY
,
or NO_RECURRENCE
).
IllegalArgumentException
- if the frequency isn't one of
the above values.public void setFrequency(String freq)
freq
- A string representing the recurrence frequency (one of
"SECONDLY", "MINUTELY", "HOURLY", "DAILY", "WEEKLY", "MONTHLY",
"YEARLY", or "" or null
representing no
recurrence).
IllegalArgumentException
- if the frequency isn't one of
the above values.public int getInterval()
public String getIntervalString()
null
if no interval is defined.public void setInterval(int intr)
intr
- The recurrence interval.public void setInterval(String intr)
intr
- The recurrence interval, as a string, or null
.
IllegalArgumentException
- if the argument isn't a valid interval.public Calendar getUntil()
count
has been set, this computes
until
from count
.
null
if unbounded.computeUntilFromCount()
public String getUntilString()
count
has been set, this computes until
from
count
.
null
if unbounded.public void setUntil(Calendar u)
u
- The upper bound, or null
if unbounded.
IllegalArgumentException
- if non-null and count
is set.public void setUntil(String u)
u
- A string representation of the upper bound, or "" or
null
if unbounded.
IllegalArgumentException
- if non-""/non-null
and
count
is set.
IllegalArgumentException
- If the given string does not describe
a valid Date-Time.public int getCount()
public String getCountString()
null
if it is unset or unknown (because 'until' is set).public void setCount(int c)
c
- The repeat count, or 0
if unbounded.
IllegalArgumentException
- If a non-computed until
has been set.computeUntilFromCount()
public void setCount(String c)
public int getWeekStart()
Calendar.SUNDAY
,
Calendar.MONDAY
, Calendar.TUESDAY
,
Calendar.WEDNESDAY
, Calendar.THURSDAY
,
Calendar.FRIDAY
, or Calendar.SATURDAY
).public String getWeekStartString()
public void setWeekStart(int weekstart)
weekstart
- The day of the week (one of Calendar.SUNDAY
,
Calendar.MONDAY
, Calendar.TUESDAY
,
Calendar.WEDNESDAY
, Calendar.THURSDAY
,
Calendar.FRIDAY
, or Calendar.SATURDAY
).public void setWeekStart(String weekstart)
weekstart
- The day of the week, as a string (one of "SU", "MO", "TU"
"WE", "TH", "FR", "SA").
IllegalArgumentException
- If the string is not a valid weekday.public int[] getBySecond()
null
if this recurrence has no such constraints.public String getBySecondString()
null
if this recurrence has no such constraints.public void setBySecond(int[] b)
b
- The array of seconds of the minute.
null
if this recurrence has no such constraints.public void setBySecond(String b)
b
- The seconds-of-the-minute constraints, as a comma-separated
string.
null
if this recurrence has no such constraints.
IllegalArgumentException
- If the string is malformed, or if a
second is outside the range 0 - 60.public int[] getByMinute()
null
if this recurrence has no such constraints.public String getByMinuteString()
null
if this recurrence has no such constraints.public void setByMinute(int[] b)
b
- The array of minutes of the hour.
null
if this recurrence has no such constraints.public void setByMinute(String b)
b
- The minutes-of-the-hour constraints, as a comma-separated string.
null
if this recurrence has no such constraints.
IllegalArgumentException
- If the string is malformed, or if a
minute is outside the range 0 - 59.public int[] getByHour()
null
if this recurrence has no such constraints.public String getByHourString()
null
if this recurrence has no such constraints.public void setByHour(int[] b)
b
- The array of hours of the day.
null
if this recurrence has no such constraints.public void setByHour(String b)
b
- The hours-of-the-day constraints, as a comma-separated string.
null
if this recurrence has no such constraints.
IllegalArgumentException
- If the string is malformed, or if an hour
is outside the range 0 - 23.public DayAndPosition[] getByDay()
null
if this recurrence has no such constraints.public String getByDayString()
null
if this recurrence has
no such constraints.public void setByDay(DayAndPosition[] b)
b
- The array of days of the week and positions.
null
if this recurrence has no such constraints.public void setByDay(String b)
b
- The hours-of-the-day constraints, as a comma-separated string.
null
if this recurrence has no such constraints.
IllegalArgumentException
- If the string is malformed, or if a
day or position is outside its valid range.public int[] getByMonthDay()
null
if this recurrence has no such constraints.public String getByMonthDayString()
null
if this recurrence has no such constraints.public void setByMonthDay(int[] b)
b
- The array of days of the month.
null
if this recurrence has no such constraints.public void setByMonthDay(String b)
b
- The day-of-the-month constraints, as a comma-separated string.
null
if this recurrence has no such constraints.
IllegalArgumentException
- If the string is malformed, or if a day
is outside the range 1 - 31 or -31 to -1.public int[] getByYearDay()
null
if this recurrence has no such constraints.public String getByYearDayString()
null
if this recurrence has no such constraints.public void setByYearDay(int[] b)
b
- The array of days of the year.
null
if this recurrence has no such constraints.public void setByYearDay(String b)
b
- The day-of-the-year constraints, as a comma-separated string.
null
if this recurrence has no such constraints.
IllegalArgumentException
- If the string is malformed, or if a day
is outside the range 1 - 366 or -366 to -1.public int[] getByWeekNo()
null
if this recurrence has no such constraints.public String getByWeekNoString()
null
if this recurrence has no such constraints.public void setByWeekNo(int[] b)
b
- The array of week numbers.
null
if this recurrence has no such constraints.public void setByWeekNo(String b)
b
- The week-number constraints, as a comma-separated string.
null
if this recurrence has no such constraints.
IllegalArgumentException
- If the string is malformed, or if a
week number is outside the range 1 - 53 or -53 to -1.public int[] getByMonth()
Calendar
(Calendar.JANUARY
, etc.).
null
if this recurrence has no such constraints.Calendar.JANUARY
,
Calendar.FEBRUARY
,
Calendar.MARCH
,
Calendar.APRIL
,
Calendar.MAY
,
Calendar.JUNE
,
Calendar.JULY
,
Calendar.AUGUST
,
Calendar.SEPTEMBER
,
Calendar.OCTOBER
,
Calendar.NOVEMBER
,
Calendar.DECEMBER
public String getByMonthString()
null
if this recurrence has no such constraints.public void setByMonth(int[] b)
Calendar
(Calendar.JANUARY
, etc.).
b
- The array of months.
null
if this recurrence has no such constraints.Calendar.JANUARY
,
Calendar.FEBRUARY
,
Calendar.MARCH
,
Calendar.APRIL
,
Calendar.MAY
,
Calendar.JUNE
,
Calendar.JULY
,
Calendar.AUGUST
,
Calendar.SEPTEMBER
,
Calendar.OCTOBER
,
Calendar.NOVEMBER
,
Calendar.DECEMBER
public void setByMonth(String b)
b
- The month constraints, as a comma-separated string.
null
if this recurrence has no such constraints.
IllegalArgumentException
- If the string is malformed, or if a month
is outside the range 1 - 12.public boolean isInRecurrence(Calendar current)
current
- The "current" time, i.e. the time which is being
considered.
public boolean isInRecurrence(Calendar current, boolean debug)
isInRecurrence(java.util.Calendar)
.
current
- The "current" time, i.e. the time which is being
considered.debug
- Whether to print debugging information.
isInRecurrence(java.util.Calendar)
protected boolean candidateIsInRecurrence(Calendar candidate, boolean debug)
isInRecurrence(java.util.Calendar)
.
candidate
- The candidate start time to be checked.debug
- Whether to print debugging information.
protected int getMinimumInterval()
SECONDLY
, MINUTELY
, HOURLY
,
DAILY
, WEEKLY
, MONTHLY
,
YEARLY
, or NO_RECURRENCE
(infinite).public Calendar getCandidateStartTime(Calendar current, boolean is_forward, boolean debug)
current
- The "current" time, i.e. the time which is being
considered.is_forward
- Whether to find the next (true) or previous (false)
candidate start time.debug
- Whether to print debugging information.
protected Calendar internalGetCandidateStartTime(Calendar current, boolean is_forward, boolean debug)
current
- The "current" time, i.e. the time which is being
considered.is_forward
- Whether to find the next (true) or previous (false)
candidate start time.debug
- Whether to print debugging information.
getCandidateStartTime(Calendar, boolean, boolean)
protected static void adjust_constant_length_field(int field, Calendar start, Calendar candidate, boolean is_forward)
candidate
so that the field
field
equals that of start
. If
is_forward
, increase the time, otherwise reduce it.
Adjust other fields appropriately. Only works for constant-length fields
(e.g., Calendar.SECOND
, Calendar.MINUTE
,
Calendar.HOUR_OF_DAY
, or Calendar.DAY_OF_WEEK
).
field
- The calendar field to reduce.start
- The calendar to get the field fromcandidate
- The calendar to adjustis_forward
- Whether to adjust the time forward.
IllegalArgumentException
- field
is not a
constant-length fieldprotected static void adjust_day_of_month(Calendar start, Calendar candidate, boolean is_forward)
candidate
until its day of
the month equals that of start
. If is_forward
,
increase the time, otherwise reduce it. Adjust other fields
appropriately.
Months can vary in length. The iCal spec says: "If BYxxx rule part values are found which are beyond the available scope (ie, BYMONTHDAY=30 in February), they are simply ignored." Assume this applies to times derived from DTStart as well, and roll back/forward through previous months until we find a match.
Example of how this works: consider the current date October 3, and the start date January 31. Assume !is_forward. start - candidate yields 28, which is more than 0, so we subtract the number of days in the previous month (September), which is 30. The resulting value, 1, of the month day, is not equal to the start month day (31), so we subtract the number of days in the second-previous month (31). This gives us August 31; this agrees, so we stop.
When we roll forward, by contrast, we adjust by the number of days in the current month, not the next month. (What matters is the number of days in the month whose end is being crossed.)
Because there are never two consecutive months with fewer than 31 days, this algorithm will try at most two months (in the Gregorian calendar).
start
- The calendar with the target day of the monthcandidate
- The calendar to adjustis_forward
- Whether to adjust the time forward.protected static void adjust_day_of_year(Calendar start, Calendar candidate, boolean is_forward)
candidate
until its day of
the year equals that of start
. If is_forward
,
increase the time, otherwise reduce it. Adjust other fields
appropriately.
The day of year is calculated based on (month, day) pairs, not the numeric day of the year (which is different after February in leap years).
For start dates of February 29, this algorithm will loop through at most seven years before it finds a matching year (in the Gregorian calendar). For candidates between 1901 and 2099, it will loop through at most three years. Start dates which do not fall on a leap day will not loop at all.
start
- The calendar with the target day of the monthcandidate
- The calendar to adjustpublic void computeUntilFromCount()
count
is set and until
is not, calculate
until
from count
. until
will be
set to one second after the count
'th start time of the
interval.
If we do not reach count
recurrences before we reach
max_count_time
, or before we have tried
max_count_loops
candidate start times, set
until
to max_count_time
, or throw an
exception, depending on the state of strict_count_bounds
.
IllegalArgumentException
- If we run off the end, and
strict_count_bounds
is in effect.max_count_time
,
max_count_loops
,
strict_count_bounds
public void computeUntilFromCount(boolean debug)
computeUntilFromCount()
.
IllegalArgumentException
- If we run off the end, and
strict_count_bounds
is in effect.computeUntilFromCount()
protected long getRecurrenceCount(Calendar candidate)
candidate
.
candidate
- The end time of the period
protected static long getFieldNumber(Calendar cal, int field)
cal
- The calendar to calculate.field
- The field to calculate - one of SECONDLY
,
MINUTELY
, HOURLY
, or DAILY
.
protected static long getWeekNumber(Calendar cal)
getWeekStart()
setting.
cal
- The calendar to calculate.
setWeekStart(int)
,
Calendar.setFirstDayOfWeek(int)
protected static long getMonthNumber(Calendar cal)
cal
- The calendar to calculate.
protected boolean matchesByDay(Calendar candidate)
candidate
matches the recurrence's
byDay
rules.
candidate
- The candidate date to check.
protected boolean matchesIndividualByDay(Calendar candidate, DayAndPosition pos)
candidate
matches one individual
DayAndPosition
.
candidate
- the candidate date to checkpos
- the candidate position
protected static boolean matchesByField(int[] array, int field, Calendar candidate, boolean allowNegative)
field
of candidate
matches
an entry in array
array
- The by* array to checkfield
- The Calendar field to checkcandidate
- The Candidate date to checkallowNegative
- Whether negative numbers should count as
N-from-the-end
protected boolean matchesBySecond(Calendar candidate)
candidate
matches the recurrence's
bySecond
rules.
candidate
- the Candidate date to check
protected boolean matchesByMinute(Calendar candidate)
candidate
matches the recurrence's
byMinute
rules.
candidate
- the Candidate date to check
protected boolean matchesByHour(Calendar candidate)
candidate
matches the recurrence's
byHour
rules.
candidate
- the Candidate date to check
protected boolean matchesByMonthDay(Calendar candidate)
candidate
matches the recurrence's
byMonthDay
rules.
candidate
- the Candidate date to check
protected boolean matchesByYearDay(Calendar candidate)
candidate
matches the recurrence's
byYearDay
rules.
candidate
- the Candidate date to check
protected boolean matchesByWeekNo(Calendar candidate)
candidate
matches the recurrence's
byWeekNo
rules.
candidate
- the Candidate date to check
protected boolean matchesByMonth(Calendar candidate)
candidate
matches the recurrence's
byMonth
rules.
candidate
- the Candidate date to check
protected static void setCalendarWeekStart(Calendar cal, int start)
start
, and
set its minimal days in first week to 4.
Clear its WEEK_OF_MONTH
and WEEK_OF_YEAR
fields — setting the values doesn't do this, so old values can
persist.
Note: this works for calendars set by the usual iCalendar/CPL syntax,
e.g. those created by parseDateTime(java.lang.String)
,
but can fail if someone actually specified the current time with
WEEK_OF_MONTH
or WEEK_OF_YEAR
.
cal
- The calendar to resetstart
- The start day of the weeparseDateTime(java.lang.String)
public static Calendar parseDateTime(String str)
The syntax of a Date-Time is given in RFC 2445 as follows:
date-time = date "T" time ;As specified in the date and time ;value definitions date = date-value date-value = date-fullyear date-month date-mday date-fullyear = 4DIGIT date-month = 2DIGIT ;01-12 date-mday = 2DIGIT ;01-28, 01-29, 01-30, 01-31 ;based on month/year time = time-hour time-minute time-second [time-utc] time-hour = 2DIGIT ;00-23 time-minute = 2DIGIT ;00-59 time-second = 2DIGIT ;00-60 ;The "60" value is used to account for "leap" seconds. time-utc = "Z"
str
- The string representation of the date-time.
IllegalArgumentException
- If the given string does not describe a
valid Date-Timeprotected static int getFixedSizeInt(String str, int pos, int ext, String fieldname)
str
- The string from which to extract the integerpos
- The position of the integerext
- The extent of the integerprotected static int[] parseIntSet(String str, String name, int min, int max, boolean neg_ok)
setByXXX(String)
, other
than setByDay(String)
.
str
- The string representation of the integer list.name
- The name of the integer field (for exceptions)min
- The minimum integer value allowedmax
- The maximum integer value allowedneg_ok
- Whether negative values are allowed
IllegalArgumentException
- If the given string does not describe
a valid list of integers complying with the above requirementsprotected DayAndPosition[] parseDaySet(String str)
setByDay(String)
.
str
- The string representation of the day list.
IllegalArgumentException
- If the given string does not describe
a valid list of day-and-positionspublic String generateDateTimeString(Calendar cal)
cal
- The calendar to generate.
protected String generateIntSetString(int[] set)
set
- A vector of ints
public String generateDaySetString(DayAndPosition[] set)
set
- A vector of DayAndPositions
public Object clone()
public String toString()
null
.
public String stringizeIntArray(int[] a)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |