java.lang.Object
net.fortuna.ical4j.model.Content
net.fortuna.ical4j.model.Component
net.fortuna.ical4j.model.component.CalendarComponent
net.fortuna.ical4j.model.component.VEvent
- All Implemented Interfaces:
Serializable,Comparable<Component>,AlarmsAccessor,ChangeManagementPropertyAccessor,ComponentContainer<Component>,ComponentListAccessor<Component>,DateTimePropertyAccessor,DescriptivePropertyAccessor,FluentComponent,LocationsAccessor,ParticipantsAccessor,PropertyContainer,PropertyListAccessor,Prototype<Component>,RecurrenceSupport<VEvent>,RelationshipPropertyAccessor,ResourcesAccessor
public class VEvent
extends CalendarComponent
implements ComponentContainer<Component>, RecurrenceSupport<VEvent>, DescriptivePropertyAccessor, ChangeManagementPropertyAccessor, DateTimePropertyAccessor, RelationshipPropertyAccessor, AlarmsAccessor, ParticipantsAccessor, LocationsAccessor, ResourcesAccessor
$Id$ [Apr 5, 2004]
Defines an iCalendar VEVENT component.
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());
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class net.fortuna.ical4j.model.component.CalendarComponent
EMPTY_VALIDATORFields inherited from class net.fortuna.ical4j.model.Component
AVAILABLE, BEGIN, components, END, EXPERIMENTAL_PREFIX, PARTICIPANT, properties, VALARM, VAVAILABILITY, VEVENT, VFREEBUSY, VJOURNAL, VLOCATION, VRESOURCE, VTIMEZONE, VTODO, VVENUEFields inherited from interface net.fortuna.ical4j.model.PropertyContainer
ADD_IF_NOT_PRESENT -
Constructor Summary
ConstructorsConstructorDescriptionVEvent()Default constructor.VEvent(boolean initialise) 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.Constructs a new VEVENT instance starting and ending at the specified times with the specified summary.VEvent(PropertyList properties) Constructor.VEvent(PropertyList properties, ComponentList<VAlarm> alarms) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Create a (deep) copy of this component.booleangetConsumedTime(Period<T> range) Returns a normalised list of periods representing the consumed time for this event.getConsumedTime(Period<T> range, boolean normalise) Returns a list of periods representing the consumed time for this event in the specified range.Deprecated.Returns the end date of this event.getEndDate(boolean deriveFromDuration) Convenience method to pull the DTEND out of the property list.getOccurrence(T date) Deprecated.Deprecated.Deprecated.inthashCode()protected ComponentFactory<VEvent>Returns a new component factory used to create deep copies.voidsetComponentList(ComponentList<Component> components) validate(boolean recurse) Perform validation on a component.Performs method-specific ITIP validation.Methods inherited from class net.fortuna.ical4j.model.component.CalendarComponent
validateAdd, validateCancel, validateCounter, validateDeclineCounter, validatePublish, validateRefresh, validateReply, validateRequestMethods inherited from class net.fortuna.ical4j.model.Component
calculateRecurrenceSet, compareTo, getFluentTarget, getName, getProperties, getPropertyList, getUid, getValue, setPropertyList, toString, validate, validatePropertiesMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.fortuna.ical4j.model.AlarmsAccessor
getAlarmsMethods inherited from interface net.fortuna.ical4j.model.ChangeManagementPropertyAccessor
getCreated, getDateTimeStamp, getLastModified, getSequenceMethods inherited from interface net.fortuna.ical4j.model.ComponentContainer
add, remove, replace, withMethods inherited from interface net.fortuna.ical4j.model.ComponentListAccessor
getComponent, getComponentsMethods inherited from interface net.fortuna.ical4j.model.DateTimePropertyAccessor
getDateTimeCompleted, getDateTimeDue, getDateTimeEnd, getDateTimeStart, getDuration, getFreeBusyTime, getTimeTransparencyMethods inherited from interface net.fortuna.ical4j.model.DescriptivePropertyAccessor
getAttachments, getCategories, getClassification, getComments, getDescription, getGeographicPos, getLocation, getPercentComplete, getPriority, getStatus, getSummaryMethods inherited from interface net.fortuna.ical4j.model.FluentComponent
withPropertyMethods inherited from interface net.fortuna.ical4j.model.LocationsAccessor
getLocationsMethods inherited from interface net.fortuna.ical4j.model.ParticipantsAccessor
getParticipantsMethods inherited from interface net.fortuna.ical4j.model.PropertyContainer
add, addAll, remove, removeAll, removeIf, replace, setPropertyList, withMethods inherited from interface net.fortuna.ical4j.model.PropertyListAccessor
getProperties, getProperty, getProperty, getPropertyList, getRequiredProperty, getRequiredPropertyMethods inherited from interface net.fortuna.ical4j.model.RecurrenceSupport
calculateRecurrenceSet, getOccurrencesMethods inherited from interface net.fortuna.ical4j.model.RelationshipPropertyAccessor
getAttendees, getContact, getOrganizer, getRecurrenceId, getRelatedTo, getUrlMethods inherited from interface net.fortuna.ical4j.model.ResourcesAccessor
getResources
-
Constructor Details
-
VEvent
public VEvent()Default constructor. -
VEvent
public VEvent(boolean initialise) -
VEvent
Constructor.- Parameters:
properties- a list of properties
-
VEvent
Constructor.- Parameters:
properties- a list of propertiesalarms- a list of alarms
-
VEvent
Constructs a new VEVENT instance starting at the specified time with the specified summary.- Parameters:
start- the start date of the new eventsummary- the event summary
-
VEvent
Constructs a new VEVENT instance starting and ending at the specified times with the specified summary.- Parameters:
start- the start date of the new eventend- the end date of the new eventsummary- the event summary
-
VEvent
Constructs a new VEVENT instance starting at the specified times, for the specified duration, with the specified summary.- Parameters:
start- the start date of the new eventduration- the duration of the new eventsummary- the event summary
-
-
Method Details
-
getComponentList
- Specified by:
getComponentListin interfaceComponentListAccessor<Component>
-
setComponentList
- Specified by:
setComponentListin interfaceComponentContainer<Component>
-
validate
Perform validation on a component.- Specified by:
validatein classComponent- Parameters:
recurse- indicates whether to validate the component's properties- Throws:
ValidationException- where the component is not in a valid state
-
validate
Performs method-specific ITIP validation.- Overrides:
validatein classCalendarComponent- Parameters:
method- the applicable method- Throws:
ValidationException- where the component does not comply with RFC2446
-
getConsumedTime
Returns a normalised list of periods representing the consumed time for this event.- Parameters:
range- the range to check for consumed time- Returns:
- a normalised list of periods representing consumed time for this event
-
getConsumedTime
public final <T extends Temporal> List<Period<T>> getConsumedTime(Period<T> range, boolean normalise) Returns a list of periods representing the consumed time for this event in the specified range. Note that the returned list may contain a single period for non-recurring components or multiple periods for recurring components. If no time is consumed by this event an empty list is returned.- Parameters:
range- the range to check for consumed timenormalise- indicate whether the returned list of periods should be normalised- Returns:
- a list of periods representing consumed time for this event
-
getOccurrence
Deprecated.Returns a single occurrence of a recurring event.- Parameters:
date- a date on which the occurence should occur- Returns:
- a single non-recurring event instance for the specified date, or null if the event doesn't occur on the specified date
-
getStartDate
Deprecated.Convenience method to pull the DTSTART out of the property list.- Returns:
- The DtStart object representation of the start Date
-
getDateStamp
Deprecated.- Returns:
- the optional date-stamp property
-
getTransparency
Deprecated.- Returns:
- the optional time transparency property for an event
-
getEndDate
Returns the end date of this event. Where an end date is not available it will be derived from the event duration.- Returns:
- a DtEnd instance, or null if one cannot be derived
-
getEndDate
Convenience method to pull the DTEND out of the property list. If DTEND was not specified, use the DTSTART + DURATION to calculate it.- Parameters:
deriveFromDuration- specifies whether to derive an end date from the event duration where an end date is not found- Returns:
- The end for this VEVENT.
-
equals
-
hashCode
public int hashCode() -
newFactory
Description copied from class:ComponentReturns a new component factory used to create deep copies.- Specified by:
newFactoryin classComponent- Returns:
- a component factory instance
-
copy
Description copied from class:ComponentCreate a (deep) copy of this component.
-
ChangeManagementPropertyAccessor.getDateTimeStamp()