|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.columbia.cpl.Duration
Duration represents a duration field in an iCalendar recurrence
or a CPL time-switch.
It represents a duration of time, expressed as a number of days, hours, minutes, and seconds, or a number of weeks.
The iCalendar spec forbids a duration from simultaneously specifying
weeks
and other units. The Duration class enforces this
restriction. Trying to specify a week value when there are any non-zero
non-week values, or a non-week value when there is a non-zero week value,
will throw an InvalidStateException exception.
Values may be specified which are larger than permitted for their enclosing fields. They will be normalized appropriately.
Change history:
Recurrence| Constructor Summary | |
Duration()
Construct a Duration object and initializes it to
a zero-length interval. |
|
Duration(int w)
Construct a Duration object with the specified duration. |
|
Duration(int h,
int m,
int s)
Construct a Duration object with the specified duration. |
|
Duration(int d,
int h,
int m,
int s)
Construct a Duration object with the specified duration. |
|
Duration(String s)
Construct a Duration object described by the given string. |
|
| Method Summary | |
protected void |
checkNonWeeksOkay(int f)
Check if it would be okay to set a non-weeks field of this duration. |
protected void |
checkWeeksOkay(int f)
Check if it would be okay to set the weeks field of this duration. |
void |
clear()
Reset the duration to a zero-length interval. |
Object |
clone()
Overrides Cloneable |
int |
getDays()
Get the days field of this duration. |
int |
getHours()
Get the hours field of this duration. |
long |
getInterval()
Get the interval represented by this Duration, in
milliseconds. |
int |
getMinutes()
Get the minutes field of this duration. |
int |
getSeconds()
Get the seconds field of this duration. |
String |
getString()
Get the standardized string representation of the Duration. |
int |
getWeeks()
Get the weeks field of this duration. |
protected void |
normalize()
Normalize the duration, so that every field is within its legal range. |
void |
setDays(int d)
Set the days field of this duration. |
void |
setHours(int h)
Set the hours field of this duration. |
void |
setInterval(long millis)
Set the duration's interval to the specified number of milliseconds. |
void |
setMinutes(int m)
Set the minutes field of this duration. |
void |
setSeconds(int s)
Set the seconds field of this duration. |
void |
setString(String str)
Set the value of the Duration object to the given string. |
void |
setWeeks(int w)
Set the weeks field of this duration. |
String |
toString()
Return a string representation of this duration. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Duration()
Duration object and initializes it to
a zero-length interval.
public Duration(int d,
int h,
int m,
int s)
Duration object with the specified duration.
d - The number of days.h - The number of hours.m - The number of minutes.s - The number of seconds.
public Duration(int h,
int m,
int s)
Duration object with the specified duration.
h - The number of hours.m - The number of minutes.s - The number of seconds.public Duration(int w)
Duration object with the specified duration.
w - The number of weeks.public Duration(String s)
Duration object described by the given string.
A duration string is defined as follows, according to RFC 2445:
dur-value = (["+"] / "-") "P" (dur-date / dur-time / dur-week)
dur-date = dur-day [dur-time]
dur-time = "T" (dur-hour / dur-minute / dur-second)
dur-week = 1*DIGIT "W"
dur-hour = 1*DIGIT "H" [dur-minute]
dur-minute = 1*DIGIT "M" [dur-second]
dur-second = 1*DIGIT "S"
dur-day = 1*DIGIT "D"
s - The string representation of the duration.
IllegalArgumentException - If the given string does not
describe a valid Duration| Method Detail |
public void clear()
public void setString(String str)
Duration object to the given string.
A duration string is defined as follows, according to RFC 2445:
dur-value = (["+"] / "-") "P" (dur-date / dur-time / dur-week)
dur-date = dur-day [dur-time]
dur-time = "T" (dur-hour / dur-minute / dur-second)
dur-week = 1*DIGIT "W"
dur-hour = 1*DIGIT "H" [dur-minute]
dur-minute = 1*DIGIT "M" [dur-second]
dur-second = 1*DIGIT "S"
dur-day = 1*DIGIT "D"
str - The string representation of the duration.
IllegalArgumentException - If the given string does not
describe a valid Durationpublic String getString()
public int getWeeks()
public void setWeeks(int w)
w - The number of weeks.
IllegalArgumentException - If w is negative.
IllegalStateException - If any non-week field is set.public int getDays()
public void setDays(int d)
d - The number of days.
IllegalArgumentException - If d is negative.
IllegalStateException - If the week field is set.public int getHours()
public void setHours(int h)
h - The number of hours.
IllegalArgumentException - If h is negative.
IllegalStateException - If the week field is set.public int getMinutes()
public void setMinutes(int m)
m - The number of minutes.
IllegalArgumentException - If m is negative.
IllegalStateException - If the week field is set.public int getSeconds()
public void setSeconds(int s)
s - The number of days.
IllegalArgumentException - If s is negative.
IllegalStateException - If the week field is set.public long getInterval()
Duration, in
milliseconds. Pure Gregorian time is used; leap-seconds and
daylight-savings time transitions are ignored.
public void setInterval(long millis)
days,
hours, minutes, and seconds
fields; the weeks field will be zero after this method is
called.
millis - The number of milliseconds for this duration.
IllegalArgumentException - If millis is negative.protected void normalize()
protected void checkWeeksOkay(int f)
f - The prospective value for the weeks field
IllegalStateException - If it wouldn't be okay.protected void checkNonWeeksOkay(int f)
f - The prospective value for the non-weeks field
IllegalStateException - If it wouldn't be okay.public Object clone()
public String toString()
null.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||