|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.columbia.cpl.DayAndPosition
DayAndPosition
is a utility class for representing byday
parameters in iCalendar recurrences and CPL time-switches.
It simply holds two pieces of information: a day of the week, and a day position.
The day of the week is represented by the day-of-week parameters of the
class Calendar
: one of Calendar.SUNDAY
, Calendar.MONDAY
, Calendar.TUESDAY
, Calendar.WEDNESDAY
,
Calendar.THURSDAY
, Calendar.FRIDAY
, or Calendar.SATURDAY
. It may also have the value
NO_WEEKDAY
if it has not been initialized.
The day position is an integer with a value between -53 and 53, representing the nth occurence of the day in the enclosing period (a month or a year). Positive values count from the beginning of the period; negative values count from the end. A zero value means that no position is implied, and that every day of the week with the given day value is intended.
If the position is intended to represent a position within a month, only
the positions -5 to 5 are meaningful. However,
DayAndPosition
has no knowledge of what period its position
represents.
Change history:
Recurrence
,
Recurrence.setByDay(edu.columbia.cpl.DayAndPosition[])
,
Calendar
Field Summary | |
static int |
NO_WEEKDAY
The value of dayOfWeek if it has not been initalized. |
Constructor Summary | |
DayAndPosition()
Construct a DayAndPosition with no weekday and zero recurrence. |
|
DayAndPosition(int d,
int p)
Construct a DayAndPosition with the given weekday and recurrence. |
|
DayAndPosition(String s)
Construct a DayAndPosition from the given string |
Method Summary | |
Object |
clone()
Overrides Cloneable |
boolean |
equals(Object obj)
Compare this day-and-position to the specified object. |
static String |
generateDayOfWeek(int day)
Return a string corresponding to the given day-of-the-week. |
int |
getDayOfWeek()
Get the day of the week stored in this object. |
int |
getDayPosition()
Get the day position stored in this object. |
String |
getString()
Get the standardized string representation of the DayAndPosition |
static boolean |
isValidDayOfWeek(int d)
Test if an integer is a valid day of the week. |
static boolean |
isValidDayPosition(int p)
Test if an integer is a valid day position. |
static int |
parseDayOfWeek(String daystr)
Parse a two-char RFC 2445 day-of-week string. |
void |
setDayOfWeek(int d)
Set the day of the week stored in this object. |
void |
setDayPosition(int p)
Set the day position stored in this object. |
void |
setString(String s)
Set the DayAndPosition to the given string |
String |
toString()
Return a string representation of this day-and-position. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int NO_WEEKDAY
dayOfWeek
if it has not been initalized.
Not equal to any of the day-of-week values from the class
Calendar
, which run from 1 (Sunday) to 7
(Saturday).
setDayOfWeek(int)
,
Calendar.SUNDAY
,
Calendar.MONDAY
,
Calendar.TUESDAY
,
Calendar.WEDNESDAY
,
Calendar.THURSDAY
,
Calendar.FRIDAY
,
Calendar.SATURDAY
,
Constant Field ValuesConstructor Detail |
public DayAndPosition()
public DayAndPosition(int d, int p)
d
- The dayp
- The period
IllegalArgumentException
- If either argument is out
of range.public DayAndPosition(String s)
s
- String
IllegalArgumentException
- If the given string does
not describe a valid DayAndPositionMethod Detail |
public String getString()
public void setString(String s)
s
- String
IllegalArgumentException
- If the given string does
not describe a valid DayAndPositionpublic int getDayOfWeek()
Calendar
or
NO_WEEKDAY
.
NO_WEEKDAY
.Calendar.SUNDAY
,
Calendar.MONDAY
,
Calendar.TUESDAY
,
Calendar.WEDNESDAY
,
Calendar.THURSDAY
,
Calendar.FRIDAY
,
Calendar.SATURDAY
,
NO_WEEKDAY
public void setDayOfWeek(int d)
Calendar
or
NO_WEEKDAY
.
d
- The day of the week, or NO_WEEKDAY
.
IllegalArgumentException
- If an invalid weekday is
given.Calendar.SUNDAY
,
Calendar.MONDAY
,
Calendar.TUESDAY
,
Calendar.WEDNESDAY
,
Calendar.THURSDAY
,
Calendar.FRIDAY
,
Calendar.SATURDAY
,
NO_WEEKDAY
public int getDayPosition()
Thus, if dayOfWeek
were Calendar.THURSDAY
, a value
of 1 would mean means the first Thursday, 2 would mean the seocnd
Thursday, -1 would mean the last Thursday, and so forth, while 0 would
mean every Thursday.
public void setDayPosition(int p)
p
- The day position.
IllegalArgumentException
- If an invalid position is
given.public boolean equals(Object obj)
true
if and only if the argument is
not null
and is a DayAndPosition
object that
represents the same day and position as this object.
obj
- the object to compare with.
true
if the objects are the same;
false
otherwise.public static boolean isValidDayOfWeek(int d)
true
if and only if the argument
is a valid weekday constant from Calendar
, or
NO_WEEKDAY
.
d
- The value to be tested.
Calendar.SUNDAY
,
Calendar.MONDAY
,
Calendar.TUESDAY
,
Calendar.WEDNESDAY
,
Calendar.THURSDAY
,
Calendar.FRIDAY
,
Calendar.SATURDAY
,
NO_WEEKDAY
public static boolean isValidDayPosition(int p)
true
if and only if the argument
is in the range -53 to 53.
p
- The value to be tested.
public static int parseDayOfWeek(String daystr)
daystr
- The string to parse.
public static String generateDayOfWeek(int day)
day
- The day of the week
public Object clone()
public String toString()
null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |