public class VEvent extends CalendarComponent
4.6.1 Event Component Component Name: "VEVENT" Purpose: Provide a grouping of component properties that describe an event. Format Definition: A "VEVENT" calendar component is defined by the following notation: eventc = "BEGIN" ":" "VEVENT" CRLF eventprop *alarmc "END" ":" "VEVENT" CRLF eventprop = *( ; the following are optional, ; but MUST NOT occur more than once class / created / description / dtstart / geo / last-mod / location / organizer / priority / dtstamp / seq / status / summary / transp / uid / url / recurid / ; either 'dtend' or 'duration' may appear in ; a 'eventprop', but 'dtend' and 'duration' ; MUST NOT occur in the same 'eventprop' dtend / duration / ; the following are optional, ; and MAY occur more than once attach / attendee / categories / comment / contact / exdate / exrule / rstatus / related / resources / rdate / rrule / x-prop )Example 1 - Creating a new all-day event:
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.set(java.util.Calendar.MONTH, java.util.Calendar.DECEMBER);
cal.set(java.util.Calendar.DAY_OF_MONTH, 25);
VEvent christmas = new VEvent(cal.getTime(), "Christmas Day");
// initialise as an all-day event..
christmas.getProperties().getProperty(Property.DTSTART).getParameters().add(
Value.DATE);
// add timezone information..
VTimeZone tz = VTimeZone.getDefault();
TzId tzParam = new TzId(tz.getProperties().getProperty(Property.TZID)
.getValue());
christmas.getProperties().getProperty(Property.DTSTART).getParameters().add(
tzParam);
Example 2 - Creating an event of one (1) hour duration:
java.util.Calendar cal = java.util.Calendar.getInstance();
// tomorrow..
cal.add(java.util.Calendar.DAY_OF_MONTH, 1);
cal.set(java.util.Calendar.HOUR_OF_DAY, 9);
cal.set(java.util.Calendar.MINUTE, 30);
VEvent meeting = new VEvent(cal.getTime(), 1000 * 60 * 60, "Progress Meeting");
// add timezone information..
VTimeZone tz = VTimeZone.getDefault();
TzId tzParam = new TzId(tz.getProperties().getProperty(Property.TZID)
.getValue());
meeting.getProperties().getProperty(Property.DTSTART).getParameters().add(
tzParam);
Example 3 - Retrieve a list of periods representing a recurring event in a specified range:
Calendar weekday9AM = Calendar.getInstance();
weekday9AM.set(2005, Calendar.MARCH, 7, 9, 0, 0);
weekday9AM.set(Calendar.MILLISECOND, 0);
Calendar weekday5PM = Calendar.getInstance();
weekday5PM.set(2005, Calendar.MARCH, 7, 17, 0, 0);
weekday5PM.set(Calendar.MILLISECOND, 0);
// Do the recurrence until December 31st.
Calendar untilCal = Calendar.getInstance();
untilCal.set(2005, Calendar.DECEMBER, 31);
untilCal.set(Calendar.MILLISECOND, 0);
// 9:00AM to 5:00PM Rule
Recur recur = new Recur(Recur.WEEKLY, untilCal.getTime());
recur.getDayList().add(WeekDay.MO);
recur.getDayList().add(WeekDay.TU);
recur.getDayList().add(WeekDay.WE);
recur.getDayList().add(WeekDay.TH);
recur.getDayList().add(WeekDay.FR);
recur.setInterval(3);
recur.setWeekStartDay(WeekDay.MO.getDay());
RRule rrule = new RRule(recur);
Summary summary = new Summary("TEST EVENTS THAT HAPPEN 9-5 MON-FRI");
weekdayNineToFiveEvents = new VEvent();
weekdayNineToFiveEvents.add(rrule);
weekdayNineToFiveEvents.add(summary);
weekdayNineToFiveEvents.add(new DtStart(weekday9AM.getTime()));
weekdayNineToFiveEvents.add(new DtEnd(weekday5PM.getTime()));
// Test Start 04/01/2005, End One month later.
// Query Calendar Start and End Dates.
Calendar queryStartDate = Calendar.getInstance();
queryStartDate.set(2005, Calendar.APRIL, 1, 14, 47, 0);
queryStartDate.set(Calendar.MILLISECOND, 0);
Calendar queryEndDate = Calendar.getInstance();
queryEndDate.set(2005, Calendar.MAY, 1, 11, 15, 0);
queryEndDate.set(Calendar.MILLISECOND, 0);
// This range is monday to friday every three weeks, starting from
// March 7th 2005, which means for our query dates we need
// April 18th through to the 22nd.
PeriodList periods = weekdayNineToFiveEvents.getPeriods(queryStartDate
.getTime(), queryEndDate.getTime());
Modifier and Type | Class and Description |
---|---|
static class |
VEvent.Factory |
EMPTY_VALIDATOR
AVAILABLE, BEGIN, END, EXPERIMENTAL_PREFIX, properties, VALARM, VAVAILABILITY, VEVENT, VFREEBUSY, VJOURNAL, VTIMEZONE, VTODO, VVENUE
Constructor and Description |
---|
VEvent()
Default constructor.
|
VEvent(boolean initialise) |
VEvent(PropertyList properties)
Constructor.
|
VEvent(PropertyList properties,
ComponentList<VAlarm> alarms)
Constructor.
|
VEvent(Temporal start,
String summary)
Constructs a new VEVENT instance starting at the specified time with the specified summary.
|
VEvent(Temporal start,
TemporalAmount duration,
String summary)
Constructs a new VEVENT instance starting at the specified times, for the specified duration, with the specified
summary.
|
VEvent(Temporal start,
Temporal end,
String summary)
Constructs a new VEVENT instance starting and ending at the specified times with the specified summary.
|
Modifier and Type | Method and Description |
---|---|
void |
add(VAlarm alarm)
Add a new alarm to the event.
|
VEvent |
copy()
Overrides default copy method to add support for copying alarm sub-components.
|
boolean |
equals(Object arg0) |
ComponentList<VAlarm> |
getAlarms()
Returns the list of alarms for this event.
|
Optional<Clazz> |
getClassification()
Deprecated.
|
<T extends Temporal> |
getConsumedTime(Period<T> range)
Returns a normalised list of periods representing the consumed time for this event.
|
<T extends Temporal> |
getConsumedTime(Period<T> range,
boolean normalise)
Returns a list of periods representing the consumed time for this event in the specified range.
|
Optional<Created> |
getCreated()
Deprecated.
|
Optional<DtStamp> |
getDateStamp()
Deprecated.
|
Optional<Description> |
getDescription()
Deprecated.
|
Optional<Duration> |
getDuration()
Deprecated.
|
Optional<DtEnd<?>> |
getEndDate()
Returns the end date of this event.
|
Optional<DtEnd<?>> |
getEndDate(boolean deriveFromDuration)
Convenience method to pull the DTEND out of the property list.
|
Optional<Geo> |
getGeographicPos()
Deprecated.
|
Optional<LastModified> |
getLastModified()
Deprecated.
|
Optional<Location> |
getLocation()
Deprecated.
|
<T extends Temporal> |
getOccurrence(T date)
Returns a single occurrence of a recurring event.
|
Optional<Organizer> |
getOrganizer()
Deprecated.
|
Optional<Priority> |
getPriority()
Deprecated.
|
Optional<RecurrenceId<?>> |
getRecurrenceId()
Deprecated.
|
Optional<Sequence> |
getSequence()
Deprecated.
|
Optional<DtStart<?>> |
getStartDate()
Deprecated.
|
Optional<Status> |
getStatus()
Deprecated.
|
Optional<Summary> |
getSummary()
Deprecated.
|
Optional<Transp> |
getTransparency()
Deprecated.
|
Optional<Uid> |
getUid()
Deprecated.
|
Optional<Url> |
getUrl()
Deprecated.
|
int |
hashCode() |
protected ComponentFactory<VEvent> |
newFactory()
Returns a new component factory used to create deep copies.
|
String |
toString() |
void |
validate(boolean recurse)
Perform validation on a component.
|
void |
validate(Method method)
Performs method-specific ITIP validation.
|
validateAdd, validateCancel, validateCounter, validateDeclineCounter, validatePublish, validateRefresh, validateReply, validateRequest
add, calculateRecurrenceSet, getName, getProperties, getProperties, getProperty, getRequiredProperty, getValue, remove, removeAll, replace, setProperties, validate, validateProperties
public VEvent()
public VEvent(boolean initialise)
public VEvent(PropertyList properties)
properties
- a list of propertiespublic VEvent(PropertyList properties, ComponentList<VAlarm> alarms)
properties
- a list of propertiesalarms
- a list of alarmspublic VEvent(Temporal start, String summary)
start
- the start date of the new eventsummary
- the event summarypublic VEvent(Temporal start, Temporal end, String summary)
start
- the start date of the new eventend
- the end date of the new eventsummary
- the event summarypublic VEvent(Temporal start, TemporalAmount duration, String summary)
start
- the start date of the new eventduration
- the duration of the new eventsummary
- the event summarypublic final ComponentList<VAlarm> getAlarms()
public void add(VAlarm alarm)
alarm
- the alarm to addpublic final void validate(boolean recurse) throws ValidationException
validate
in class Component
recurse
- indicates whether to validate the component's propertiesValidationException
- where the component is not in a valid statepublic void validate(Method method) throws ValidationException
validate
in class CalendarComponent
method
- the applicable methodValidationException
- where the component does not comply with RFC2446public final <T extends Temporal> List<Period<T>> getConsumedTime(Period<T> range)
range
- the range to check for consumed timepublic final <T extends Temporal> List<Period<T>> getConsumedTime(Period<T> range, boolean normalise)
range
- the range to check for consumed timenormalise
- indicate whether the returned list of periods should be normalisedpublic final <T extends Temporal> VEvent getOccurrence(T date)
date
- a date on which the occurence should occur@Deprecated public final Optional<Clazz> getClassification()
Component.getProperty(String)
@Deprecated public final Optional<Created> getCreated()
Component.getProperty(String)
@Deprecated public final Optional<Description> getDescription()
Component.getProperty(String)
@Deprecated public final Optional<DtStart<?>> getStartDate()
Component.getProperty(String)
@Deprecated public final Optional<Geo> getGeographicPos()
Component.getProperty(String)
@Deprecated public final Optional<LastModified> getLastModified()
Component.getProperty(String)
@Deprecated public final Optional<Location> getLocation()
Component.getProperty(String)
@Deprecated public final Optional<Organizer> getOrganizer()
Component.getProperty(String)
@Deprecated public final Optional<Priority> getPriority()
Component.getProperty(String)
@Deprecated public final Optional<DtStamp> getDateStamp()
Component.getProperty(String)
@Deprecated public final Optional<Sequence> getSequence()
Component.getProperty(String)
@Deprecated public final Optional<Status> getStatus()
Component.getProperty(String)
@Deprecated public final Optional<Summary> getSummary()
Component.getProperty(String)
@Deprecated public final Optional<Transp> getTransparency()
Component.getProperty(String)
@Deprecated public final Optional<Url> getUrl()
Component.getProperty(String)
@Deprecated public final Optional<RecurrenceId<?>> getRecurrenceId()
Component.getProperty(String)
public final Optional<DtEnd<?>> getEndDate()
public final Optional<DtEnd<?>> getEndDate(boolean deriveFromDuration)
deriveFromDuration
- specifies whether to derive an end date from the event duration where an end date is
not found@Deprecated public final Optional<Duration> getDuration()
Component.getProperty(String)
@Deprecated public final Optional<Uid> getUid()
Component.getProperty(String)
public VEvent copy()
copy
in class Component
Component.copy()
protected ComponentFactory<VEvent> newFactory()
Component
newFactory
in class Component