java.lang.Object
net.fortuna.ical4j.model.Calendar
- All Implemented Interfaces:
Serializable,CalendarPropertyAccessor,ComponentContainer<CalendarComponent>,ComponentListAccessor<CalendarComponent>,FluentCalendar,PropertyContainer,PropertyListAccessor,Prototype<Calendar>
public class Calendar
extends Object
implements Prototype<Calendar>, Serializable, PropertyContainer, ComponentContainer<CalendarComponent>, FluentCalendar, CalendarPropertyAccessor
$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..
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringBegin token.static final StringEnd token.static final BiFunction<Calendar,List<CalendarComponent>, Calendar> static final BiFunction<Calendar,List<Property>, Calendar> Smart merging of properties that identifies whether to add or replace existing properties.static final StringCalendar token.Fields inherited from interface net.fortuna.ical4j.model.PropertyContainer
ADD_IF_NOT_PRESENT -
Constructor Summary
ConstructorsConstructorDescriptionCalendar()Default constructor.Creates a shallow copy of the specified calendar.Calendar(ComponentList<? extends CalendarComponent> components) Constructs a new calendar with no properties and the specified components.Calendar(PropertyList properties, ComponentList<? extends CalendarComponent> components) Initialise a Calendar object using the default configured validator.Calendar(PropertyList p, ComponentList<? extends CalendarComponent> c, Validator<Calendar> validator) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal Calendarcopy()Creates a deep copy of the calendar.final booleanfinal ComponentList<CalendarComponent><C extends CalendarComponent>
List<C>getContentType(Charset charset) Returns an appropriate MIME Content-Type for the calendar object instance.Explicitly override due to conflict with groovy implicit method..final PropertyListgetUid()Returns a unique identifier as specified by components in the calendar instance.final inthashCode()Merge all properties and components from the specified calendar with this instance.voidsetComponentList(ComponentList<CalendarComponent> components) voidsetPropertyList(PropertyList properties) Calendar[]split()Splits a calendar object into distinct calendar objects for unique identifiers (UID).final StringtoString()validate()Perform validation on the calendar, its properties and its components in its current state.validate(boolean recurse) Perform validation on the calendar in its current state.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.fortuna.ical4j.model.CalendarPropertyAccessor
getCalendarScale, getMethod, getProductId, getVersionMethods 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.FluentCalendar
withComponent, withDefaults, withProdId, withPropertyMethods inherited from interface net.fortuna.ical4j.model.PropertyContainer
add, addAll, remove, removeAll, removeIf, replace, withMethods inherited from interface net.fortuna.ical4j.model.PropertyListAccessor
getProperties, getProperty, getProperty, getRequiredProperty, getRequiredProperty
-
Field Details
-
MERGE_PROPERTIES
Smart merging of properties that identifies whether to add or replace existing properties. -
MERGE_COMPONENTS
-
BEGIN
Begin token.- See Also:
-
VCALENDAR
Calendar token.- See Also:
-
END
End token.- See Also:
-
-
Constructor Details
-
Calendar
public Calendar()Default constructor. -
Calendar
Constructs a new calendar with no properties and the specified components.- Parameters:
components- a list of components to add to the calendar
-
Calendar
Initialise a Calendar object using the default configured validator.- Parameters:
properties- a list of initial calendar propertiescomponents- a list of initial calendar components
-
Calendar
public Calendar(PropertyList p, ComponentList<? extends CalendarComponent> c, Validator<Calendar> validator) Constructor.- Parameters:
p- a list of propertiesc- a list of componentsvalidator- used to ensure the validity of the calendar instance
-
Calendar
Creates a shallow copy of the specified calendar.- Parameters:
c- the calendar to copy
-
-
Method Details
-
toString
-
getFluentTarget
- Specified by:
getFluentTargetin interfaceFluentCalendar
-
getComponents
-
getComponentList
- Specified by:
getComponentListin interfaceComponentListAccessor<CalendarComponent>- Returns:
- Returns the underlying component list.
-
setComponentList
- Specified by:
setComponentListin interfaceComponentContainer<CalendarComponent>
-
getProperties
Explicitly override due to conflict with groovy implicit method..- Type Parameters:
T-- Returns:
-
getPropertyList
- Specified by:
getPropertyListin interfacePropertyListAccessor- Returns:
- Returns the underlying property list.
-
setPropertyList
- Specified by:
setPropertyListin interfacePropertyContainer
-
validate
Perform validation on the calendar, its properties and its components in its current state.- Throws:
ValidationException- where the calendar is not in a valid state
-
validate
Perform validation on the calendar in its current state.- Parameters:
recurse- indicates whether to validate the calendar's properties and components- Throws:
ValidationException- where the calendar is not in a valid state
-
copy
Creates a deep copy of the calendar. -
merge
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- the second calendar to merge- Returns:
- a Calendar instance containing all properties and components from both of the specified calendars
-
split
Splits a calendar object into distinct calendar objects for unique identifiers (UID).- Returns:
- an array of calendar objects
-
getUid
Returns a unique identifier as specified by components in the calendar instance.- Returns:
- the UID property
- Throws:
ConstraintViolationException- if zero or more than one unique identifier(s) is found in the specified calendar
-
getContentType
Returns an appropriate MIME Content-Type for the calendar object instance.- Parameters:
charset- an optional encoding- Returns:
- a content type string
-
equals
-
hashCode
public final int hashCode()
-