Top Description Inners Fields Constructors Methods
net.fortuna.ical4j.model.component

public Class VEvent

extends CalendarComponent
implements Prototype<VEvent>, ComponentContainer<Component>, RecurrenceSupport<VEvent>, DescriptivePropertyAccessor, ChangeManagementPropertyAccessor, DateTimePropertyAccessor, RelationshipPropertyAccessor, AlarmsAccessor, ParticipantsAccessor, LocationsAccessor, ResourcesAccessor
Class Inheritance
All Implemented Interfaces
net.fortuna.ical4j.model.ResourcesAccessor, net.fortuna.ical4j.model.ComponentContainer, net.fortuna.ical4j.model.ComponentListAccessor, net.fortuna.ical4j.model.LocationsAccessor, net.fortuna.ical4j.model.ParticipantsAccessor, net.fortuna.ical4j.model.AlarmsAccessor, net.fortuna.ical4j.model.RelationshipPropertyAccessor, net.fortuna.ical4j.model.PropertyContainer, net.fortuna.ical4j.model.PropertyListAccessor, net.fortuna.ical4j.model.DateTimePropertyAccessor, net.fortuna.ical4j.model.ChangeManagementPropertyAccessor, net.fortuna.ical4j.model.DescriptivePropertyAccessor, net.fortuna.ical4j.model.RecurrenceSupport, net.fortuna.ical4j.model.Prototype
Imports
net.fortuna.ical4j.model.*, net.fortuna.ical4j.model.parameter.TzId, .Value, net.fortuna.ical4j.model.property.*, net.fortuna.ical4j.util.CompatibilityHints, net.fortuna.ical4j.validate.*, net.fortuna.ical4j.validate.component.VEventValidator, org.apache.commons.lang3.builder.HashCodeBuilder, java.time.temporal.Temporal, .TemporalAmount, java.util.*, java.util.stream.Collectors

$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());
Author
Ben Fortuna

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private static final Map<Method, Validator<VEvent>>
private static final long
Inherited from net.fortuna.ical4j.model.component.CalendarComponent:
EMPTY_VALIDATOR

Constructor Summary

AccessConstructor and Description
public
VEvent()

Default constructor.

public
VEvent(boolean initialise)

public
VEvent(final PropertyList
a list of properties
properties
)

Constructor.

public
VEvent(final PropertyList
a list of properties
properties
,
final ComponentList<VAlarm>
a list of alarms
alarms
)

Constructor.

public
VEvent(final Temporal
the start date of the new event
start
,
final String
the event summary
summary
)

Constructs a new VEVENT instance starting at the specified time with the specified summary.

public
VEvent(final Temporal
the start date of the new event
start
,
final Temporal
the end date of the new event
end
,
final String
the event summary
summary
)

Constructs a new VEVENT instance starting and ending at the specified times with the specified summary.

public
VEvent(final Temporal
the start date of the new event
start
,
final TemporalAmount
the duration of the new event
duration
,
final String
the event summary
summary
)

Constructs a new VEVENT instance starting at the specified times, for the specified duration, with the specified summary.

Method Summary

Modifier and TypeMethod and Description
public VEvent
copy()

Overrides net.fortuna.ical4j.model.Component.copy.

Implements net.fortuna.ical4j.model.Prototype.copy.

Create a (deep) copy of this component.

public boolean
equals(final Object
the reference object with which to compare.
arg0
)

Overrides net.fortuna.ical4j.model.Component.equals.

Indicates whether some other object is "equal to" this one.

public ComponentList<Component>
public final <T extends Temporal> List<Period<T>>

Returns:

a normalised list of periods representing consumed time for this event
getConsumedTime
(final Period<T>
the range to check for consumed time
range
)

Returns a normalised list of periods representing the consumed time for this event.

public final <T extends Temporal> List<Period<T>>

Returns:

a list of periods representing consumed time for this event
getConsumedTime
(final Period<T>
the range to check for consumed time
range
,
final boolean
indicate whether the returned list of periods should be normalised
normalise
)

Returns a list of periods representing the consumed time for this event in the specified range.

public final Optional<DtStamp>

Returns:

the optional date-stamp property
getDateStamp
()

public final <T extends Temporal> Optional<DtEnd<T>>

Returns:

a DtEnd instance, or null if one cannot be derived
getEndDate
()

Returns the end date of this event.

public final <T extends Temporal> Optional<DtEnd<T>>

Returns:

The end for this VEVENT.
getEndDate
(final boolean
specifies whether to derive an end date from the event duration where an end date is not found
deriveFromDuration
)

Convenience method to pull the DTEND out of the property list.

public final <T extends Temporal> VEvent

Returns:

a single non-recurring event instance for the specified date, or null if the event doesn't occur on the specified date
getOccurrence
(final T
a date on which the occurence should occur
date
)

Returns a single occurrence of a recurring event.

public final <T extends Temporal> Optional<DtStart<T>>

Returns:

The DtStart object representation of the start Date
getStartDate
()

Convenience method to pull the DTSTART out of the property list.

public final Optional<Transp>

Returns:

the optional time transparency property for an event
getTransparency
()

public int
hashCode()

Overrides net.fortuna.ical4j.model.Component.hashCode.

Returns a hash code value for this object.

protected ComponentFactory<VEvent>
newFactory()

Implements abstract net.fortuna.ical4j.model.Component.newFactory.

Returns a new component factory used to create deep copies.

public void
public ValidationResult
validate(final boolean
indicates whether to validate the component's properties
recurse
)

Implements abstract net.fortuna.ical4j.model.Component.validate.

Perform validation on a component.

public ValidationResult
validate(Method
the applicable method
method
)

Overrides net.fortuna.ical4j.model.component.CalendarComponent.validate.

Performs method-specific ITIP validation.

Inherited from net.fortuna.ical4j.model.component.CalendarComponent:
validateAddvalidateCancelvalidateCountervalidateDeclineCountervalidatePublishvalidateRefreshvalidateReplyvalidateRequest

Field Detail

methodValidatorsback to summary
private static final Map<Method, Validator<VEvent>> methodValidators
serialVersionUIDback to summary
private static final long serialVersionUID

Hides net.fortuna.ical4j.model.component.CalendarComponent.serialVersionUID.

Constructor Detail

VEventback to summary
public VEvent()

Default constructor.

VEventback to summary
public VEvent(boolean initialise)
VEventback to summary
public VEvent(final PropertyList properties)

Constructor.

Parameters
properties:PropertyList

a list of properties

VEventback to summary
public VEvent(final PropertyList properties, final ComponentList<VAlarm> alarms)

Constructor.

Parameters
properties:PropertyList

a list of properties

alarms:ComponentList<VAlarm>

a list of alarms

VEventback to summary
public VEvent(final Temporal start, final String summary)

Constructs a new VEVENT instance starting at the specified time with the specified summary.

Parameters
start:Temporal

the start date of the new event

summary:String

the event summary

VEventback to summary
public VEvent(final Temporal start, final Temporal end, final String summary)

Constructs a new VEVENT instance starting and ending at the specified times with the specified summary.

Parameters
start:Temporal

the start date of the new event

end:Temporal

the end date of the new event

summary:String

the event summary

VEventback to summary
public VEvent(final Temporal start, final TemporalAmount duration, final String summary)

Constructs a new VEVENT instance starting at the specified times, for the specified duration, with the specified summary.

Parameters
start:Temporal

the start date of the new event

duration:TemporalAmount

the duration of the new event

summary:String

the event summary

Method Detail

copyback to summary
public VEvent copy()

Overrides net.fortuna.ical4j.model.Component.copy.

Implements net.fortuna.ical4j.model.Prototype.copy.

Doc from net.fortuna.ical4j.model.Component.copy.

Create a (deep) copy of this component.

Returns:VEvent

the component copy

Annotations
@Override
equalsback to summary
public boolean equals(final Object arg0)

Overrides net.fortuna.ical4j.model.Component.equals.

Doc from net.fortuna.ical4j.model.Component.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
arg0:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getComponentListback to summary
public ComponentList<Component> getComponentList()

Implements net.fortuna.ical4j.model.ComponentListAccessor.getComponentList.

Annotations
@Override
getConsumedTimeback to summary
public final <T extends Temporal> List<Period<T>> getConsumedTime(final Period<T> range)

Returns a normalised list of periods representing the consumed time for this event.

Parameters
range:Period<T>

the range to check for consumed time

Returns:List<Period<T>>

a normalised list of periods representing consumed time for this event

getConsumedTimeback to summary
public final <T extends Temporal> List<Period<T>> getConsumedTime(final Period<T> range, final 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:Period<T>

the range to check for consumed time

normalise:boolean

indicate whether the returned list of periods should be normalised

Returns:List<Period<T>>

a list of periods representing consumed time for this event

getDateStampback to summary
public final Optional<DtStamp> getDateStamp()
Returns:Optional<DtStamp>

the optional date-stamp property

Annotations
@Deprecated
getEndDateback to summary
public final <T extends Temporal> Optional<DtEnd<T>> getEndDate()

Returns the end date of this event. Where an end date is not available it will be derived from the event duration.

Returns:Optional<DtEnd<T>>

a DtEnd instance, or null if one cannot be derived

getEndDateback to summary
public final <T extends Temporal> Optional<DtEnd<T>> getEndDate(final boolean deriveFromDuration)

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:boolean

specifies whether to derive an end date from the event duration where an end date is not found

Returns:Optional<DtEnd<T>>

The end for this VEVENT.

getOccurrenceback to summary
public final <T extends Temporal> VEvent getOccurrence(final T date)

Returns a single occurrence of a recurring event.

Parameters
date:T

a date on which the occurence should occur

Returns:VEvent

a single non-recurring event instance for the specified date, or null if the event doesn't occur on the specified date

Annotations
@Deprecated
getStartDateback to summary
public final <T extends Temporal> Optional<DtStart<T>> getStartDate()

Convenience method to pull the DTSTART out of the property list.

Returns:Optional<DtStart<T>>

The DtStart object representation of the start Date

Annotations
@Deprecated
getTransparencyback to summary
public final Optional<Transp> getTransparency()
Returns:Optional<Transp>

the optional time transparency property for an event

Annotations
@Deprecated
hashCodeback to summary
public int hashCode()

Overrides net.fortuna.ical4j.model.Component.hashCode.

Doc from net.fortuna.ical4j.model.Component.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
newFactoryback to summary
protected ComponentFactory<VEvent> newFactory()

Implements abstract net.fortuna.ical4j.model.Component.newFactory.

Doc from net.fortuna.ical4j.model.Component.newFactory.

Returns a new component factory used to create deep copies.

Returns:ComponentFactory<VEvent>

a component factory instance

Annotations
@Override
setComponentListback to summary
public void setComponentList(ComponentList<Component> components)

Implements net.fortuna.ical4j.model.ComponentContainer.setComponentList.

Annotations
@Override
validateback to summary
public ValidationResult validate(final boolean recurse) throws ValidationException

Implements abstract net.fortuna.ical4j.model.Component.validate.

Doc from net.fortuna.ical4j.model.Component.validate.

Perform validation on a component.

Parameters
recurse:boolean

indicates whether to validate the component's properties

Annotations
@Override
Exceptions
ValidationException:
where the component is not in a valid state
validateback to summary
public ValidationResult validate(Method method) throws ValidationException

Overrides net.fortuna.ical4j.model.component.CalendarComponent.validate.

Performs method-specific ITIP validation.

Parameters
method:Method

the applicable method

Exceptions
ValidationException:
where the component does not comply with RFC2446
net.fortuna.ical4j.model.component back to summary

public Class VEvent.Factory

extends Factory
implements ComponentFactory<VEvent>
Class Inheritance
All Implemented Interfaces
net.fortuna.ical4j.model.ComponentFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public VEvent
public VEvent
public VEvent
Inherited from net.fortuna.ical4j.model.Content.Factory:
supports

Constructor Detail

Factoryback to summary
public Factory()

Method Detail

createComponentback to summary
public VEvent createComponent()

Implements net.fortuna.ical4j.model.ComponentFactory.createComponent.

Annotations
@Override
createComponentback to summary
public VEvent createComponent(PropertyList properties)

Implements net.fortuna.ical4j.model.ComponentFactory.createComponent.

Annotations
@Override
createComponentback to summary
public VEvent createComponent(PropertyList properties, ComponentList<?> subComponents)

Overrides default net.fortuna.ical4j.model.ComponentFactory.createComponent.

Annotations
@Override
@SuppressWarnings:unchecked