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

public Class Calendar

extends Object
implements Prototype<Calendar>, Serializable, PropertyContainer, ComponentContainer<CalendarComponent>, FluentCalendar, CalendarPropertyAccessor
Class Inheritance
All Implemented Interfaces
net.fortuna.ical4j.model.CalendarPropertyAccessor, net.fortuna.ical4j.model.PropertyContainer, net.fortuna.ical4j.model.PropertyListAccessor, net.fortuna.ical4j.model.FluentCalendar, net.fortuna.ical4j.model.ComponentContainer, net.fortuna.ical4j.model.ComponentListAccessor, java.io.Serializable, net.fortuna.ical4j.model.Prototype
Imports
net.fortuna.ical4j.model.component.CalendarComponent, .VTimeZone, net.fortuna.ical4j.model.parameter.TzId, net.fortuna.ical4j.model.property.Method, .Uid, net.fortuna.ical4j.util.Strings, net.fortuna.ical4j.validate.AbstractCalendarValidatorFactory, .ValidationException, .ValidationResult, .Validator, org.apache.commons.lang3.builder.EqualsBuilder, .HashCodeBuilder, java.io.Serializable, java.nio.charset.Charset, java.util.HashMap, .List, .Map, .Optional, java.util.function.BiFunction, java.util.stream.Collectors

$Id$ [Apr 5, 2004] Defines an iCalendar calendar.
   4.6 Calendar Components

      The body of the iCalendar object consists of a sequence of calendar
      properties and one or more calendar components. The calendar
      properties are attributes that apply to the calendar as a whole. The
      calendar components are collections of properties that express a
      particular calendar semantic. For example, the calendar component can
      specify an event, a to-do, a journal entry, time zone information, or
      free/busy time information, or an alarm.

      The body of the iCalendar object is defined by the following
      notation:

        icalbody   = calprops component

        calprops   = 2*(

                   ; 'prodid' and 'version' are both REQUIRED,
                   ; but MUST NOT occur more than once

                   prodid /version /

                   ; 'calscale' and 'method' are optional,
                   ; but MUST NOT occur more than once

                   calscale        /
                   method          /

                   x-prop

                   )

        component  = 1*(eventc / todoc / journalc / freebusyc /
                   / timezonec / iana-comp / x-comp)

        iana-comp  = "BEGIN" ":" iana-token CRLF

                     1*contentline

                     "END" ":" iana-token CRLF

        x-comp     = "BEGIN" ":" x-name CRLF

                     1*contentline

                     "END" ":" x-name CRLF
Example 1 - Creating a new calendar:

Calendar calendar = new Calendar();
calendar.add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
calendar.add(Version.VERSION_2_0);
calendar.add(CalScale.GREGORIAN);

// Add events, etc..
Author
Ben Fortuna

Field Summary

Modifier and TypeField and Description
public static final String
BEGIN

Begin token.

private ComponentList<CalendarComponent>
public static final String
END

End token.

public static final BiFunction<Calendar, List<CalendarComponent>, Calendar>
public static final BiFunction<Calendar, List<Property>, Calendar>
MERGE_PROPERTIES

Smart merging of properties that identifies whether to add or replace existing properties.

private PropertyList
private static final long
private final Validator<Calendar>
public static final String
VCALENDAR

Calendar token.

Constructor Summary

AccessConstructor and Description
public
Calendar()

Default constructor.

public
Calendar(final ComponentList<? extends CalendarComponent>
a list of components to add to the calendar
components
)

Constructs a new calendar with no properties and the specified components.

public
Calendar(PropertyList
a list of initial calendar properties
properties
,
ComponentList<? extends CalendarComponent>
a list of initial calendar components
components
)

Initialise a Calendar object using the default configured validator.

public
Calendar(PropertyList
a list of properties
p
,
ComponentList<? extends CalendarComponent>
a list of components
c
,
Validator<Calendar>
used to ensure the validity of the calendar instance
validator
)

Constructor.

public
Calendar(Calendar
the calendar to copy
c
)

Creates a shallow copy of the specified calendar.

Method Summary

Modifier and TypeMethod and Description
public final Calendar

Returns:

a new calendar instance that protects against mutation of the source calendar
copy
()

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

Creates a deep copy of the calendar.

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

Overrides java.lang.Object.equals.

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

public final ComponentList<CalendarComponent>

Returns:

Returns the underlying component list.
getComponentList
()

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

public <C extends CalendarComponent> List<C>
public String

Returns:

a content type string
getContentType
(Charset
an optional encoding
charset
)

Returns an appropriate MIME Content-Type for the calendar object instance.

public Calendar
public <T extends Property> List<T>
getProperties()

Explicitly override due to conflict with groovy implicit method..

public final PropertyList

Returns:

Returns the underlying property list.
getPropertyList
()

Implements net.fortuna.ical4j.model.PropertyListAccessor.getPropertyList.

public Uid

Returns:

the UID property
getUid
()

Returns a unique identifier as specified by components in the calendar instance.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public Calendar

Returns:

a Calendar instance containing all properties and components from both of the specified calendars
merge
(final Calendar
the second calendar to merge
c2
)

Merge all properties and components from the specified calendar with this instance.

public void
public void
public Calendar[]

Returns:

an array of calendar objects
split
()

Splits a calendar object into distinct calendar objects for unique identifiers (UID).

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public ValidationResult
validate()

Perform validation on the calendar, its properties and its components in its current state.

public ValidationResult
validate(final boolean
indicates whether to validate the calendar's properties and components
recurse
)

Perform validation on the calendar in its current state.

private ValidationResult
validateComponents()

Invoke validation on the calendar components in its current state.

private ValidationResult
validateProperties()

Invoke validation on the calendar properties in its current state.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

BEGINback to summary
public static final String BEGIN

Begin token.

componentsback to summary
private ComponentList<CalendarComponent> components
ENDback to summary
public static final String END

End token.

MERGE_COMPONENTSback to summary
public static final BiFunction<Calendar, List<CalendarComponent>, Calendar> MERGE_COMPONENTS
MERGE_PROPERTIESback to summary
public static final BiFunction<Calendar, List<Property>, Calendar> MERGE_PROPERTIES

Smart merging of properties that identifies whether to add or replace existing properties.

propertiesback to summary
private PropertyList properties
serialVersionUIDback to summary
private static final long serialVersionUID
validatorback to summary
private final Validator<Calendar> validator
VCALENDARback to summary
public static final String VCALENDAR

Calendar token.

Constructor Detail

Calendarback to summary
public Calendar()

Default constructor.

Calendarback to summary
public Calendar(final ComponentList<? extends CalendarComponent> components)

Constructs a new calendar with no properties and the specified components.

Parameters
components:ComponentList<? extends CalendarComponent>

a list of components to add to the calendar

Calendarback to summary
public Calendar(PropertyList properties, ComponentList<? extends CalendarComponent> components)

Initialise a Calendar object using the default configured validator.

Parameters
properties:PropertyList

a list of initial calendar properties

components:ComponentList<? extends CalendarComponent>

a list of initial calendar components

Calendarback to summary
public Calendar(PropertyList p, ComponentList<? extends CalendarComponent> c, Validator<Calendar> validator)

Constructor.

Parameters
p:PropertyList

a list of properties

c:ComponentList<? extends CalendarComponent>

a list of components

validator:Validator<Calendar>

used to ensure the validity of the calendar instance

Calendarback to summary
public Calendar(Calendar c)

Creates a shallow copy of the specified calendar.

Parameters
c:Calendar

the calendar to copy

Method Detail

copyback to summary
public final Calendar copy()

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

Creates a deep copy of the calendar.

Returns:Calendar

a new calendar instance that protects against mutation of the source calendar

equalsback to summary
public final boolean equals(final Object arg0)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.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

the reference object with which to compare.

Returns:boolean

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

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

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

Returns:ComponentList<CalendarComponent>

Returns the underlying component list.

Annotations
@Override
getComponentsback to summary
public <C extends CalendarComponent> List<C> getComponents()
getContentTypeback to summary
public String getContentType(Charset charset)

Returns an appropriate MIME Content-Type for the calendar object instance.

Parameters
charset:Charset

an optional encoding

Returns:String

a content type string

getFluentTargetback to summary
public Calendar getFluentTarget()

Implements net.fortuna.ical4j.model.FluentCalendar.getFluentTarget.

Annotations
@Override
getPropertiesback to summary
public <T extends Property> List<T> getProperties()

Explicitly override due to conflict with groovy implicit method..

getPropertyListback to summary
public final PropertyList getPropertyList()

Implements net.fortuna.ical4j.model.PropertyListAccessor.getPropertyList.

Returns:PropertyList

Returns the underlying property list.

Annotations
@Override
getUidback to summary
public Uid getUid() throws ConstraintViolationException

Returns a unique identifier as specified by components in the calendar instance.

Returns:Uid

the UID property

Exceptions
ConstraintViolationException:
if zero or more than one unique identifier(s) is found in the specified calendar
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.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

a hash code value for this object

Annotations
@Override
mergeback to summary
public Calendar merge(final Calendar c2)

Merge all properties and components from the specified calendar with this instance. Note that the merge process is not very sophisticated, and may result in invalid calendar data (e.g. multiple properties of a type that should only be specified once).

Parameters
c2:Calendar

the second calendar to merge

Returns:Calendar

a Calendar instance containing all properties and components from both of the specified calendars

setComponentListback to summary
public void setComponentList(ComponentList<CalendarComponent> components)

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

Annotations
@Override
setPropertyListback to summary
public void setPropertyList(PropertyList properties)

Implements net.fortuna.ical4j.model.PropertyContainer.setPropertyList.

Annotations
@Override
splitback to summary
public Calendar[] split()

Splits a calendar object into distinct calendar objects for unique identifiers (UID).

Returns:Calendar[]

an array of calendar objects

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

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

Perform validation on the calendar, its properties and its components in its current state.

Exceptions
ValidationException:
where the calendar is not in a valid state
validateback to summary
public ValidationResult validate(final boolean recurse) throws ValidationException

Perform validation on the calendar in its current state.

Parameters
recurse:boolean

indicates whether to validate the calendar's properties and components

Exceptions
ValidationException:
where the calendar is not in a valid state
validateComponentsback to summary
private ValidationResult validateComponents() throws ValidationException

Invoke validation on the calendar components in its current state.

Exceptions
ValidationException:
where any of the calendar components is not in a valid state
validatePropertiesback to summary
private ValidationResult validateProperties() throws ValidationException

Invoke validation on the calendar properties in its current state.

Exceptions
ValidationException:
where any of the calendar properties is not in a valid state