Serializable
public class Calendar extends Object implements Serializable
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 CRLFExample 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..
Modifier and Type | Field | Description |
---|---|---|
static String |
BEGIN |
Begin token.
|
static String |
END |
End token.
|
static String |
VCALENDAR |
Calendar token.
|
Constructor | Description |
---|---|
Calendar() |
Default constructor.
|
Calendar(Calendar c) |
Creates a shallow copy of the specified calendar.
|
Calendar(ComponentList<CalendarComponent> components) |
Constructs a new calendar with no properties and the specified components.
|
Calendar(PropertyList properties,
ComponentList<CalendarComponent> components) |
Initialise a Calendar object using the default configured validator.
|
Calendar(PropertyList p,
ComponentList<CalendarComponent> c,
Validator<Calendar> validator) |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
Calendar |
add(CalendarComponent component) |
Add a component to the calendar's component list.
|
Calendar |
add(Property property) |
Add a property to the calendar's property list.
|
Calendar |
copy() |
Creates a deep copy of the calendar.
|
boolean |
equals(Object arg0) |
|
Optional<CalScale> |
getCalendarScale() |
Deprecated.
|
<T extends CalendarComponent> |
getComponent(String name) |
Deprecated.
|
ComponentList<CalendarComponent> |
getComponents() |
|
<C extends CalendarComponent> |
getComponents(String name) |
Deprecated.
|
Optional<Method> |
getMethod() |
Deprecated.
|
Optional<ProdId> |
getProductId() |
Deprecated.
|
PropertyList |
getProperties() |
|
List<Property> |
getProperties(String name) |
Deprecated.
|
<T extends Property> |
getProperty(String name) |
Deprecated.
|
Optional<Version> |
getVersion() |
Deprecated.
|
int |
hashCode() |
|
Calendar |
remove(CalendarComponent component) |
Remove a component from the calendar's component list.
|
Calendar |
remove(Property property) |
Remove a property from the calendar's property list.
|
Calendar |
replace(CalendarComponent component) |
Add a component to the calendar's component list whilst removing all other components with the same component name.
|
Calendar |
replace(Property property) |
Add a property to the calendar's property list whilst removing all other properties with the same property name.
|
protected void |
setComponents(ComponentList<CalendarComponent> components) |
|
protected void |
setProperties(PropertyList properties) |
|
String |
toString() |
|
void |
validate() |
Perform validation on the calendar, its properties and its components in its current state.
|
void |
validate(boolean recurse) |
Perform validation on the calendar in its current state.
|
public static final String BEGIN
public static final String VCALENDAR
public static final String END
public Calendar()
public Calendar(ComponentList<CalendarComponent> components)
components
- a list of components to add to the calendarpublic Calendar(PropertyList properties, ComponentList<CalendarComponent> components)
properties
- a list of initial calendar propertiescomponents
- a list of initial calendar componentspublic Calendar(PropertyList p, ComponentList<CalendarComponent> c, Validator<Calendar> validator)
p
- a list of propertiesc
- a list of componentsvalidator
- used to ensure the validity of the calendar instancepublic Calendar(Calendar c)
c
- the calendar to copypublic final ComponentList<CalendarComponent> getComponents()
protected void setComponents(ComponentList<CalendarComponent> components)
public Calendar add(CalendarComponent component)
component
- the component to addpublic Calendar remove(CalendarComponent component)
component
- the component to removepublic Calendar replace(CalendarComponent component)
component
- the component to add@Deprecated public final <C extends CalendarComponent> List<C> getComponents(String name)
ContentContainer.get(String)
name
- name of components to retrieve@Deprecated public final <T extends CalendarComponent> Optional<T> getComponent(String name)
ContentContainer.getFirst(String)
name
- name of the component to retrievepublic final PropertyList getProperties()
protected void setProperties(PropertyList properties)
public Calendar add(Property property)
property
- the property to addpublic Calendar remove(Property property)
property
- the property to removepublic Calendar replace(Property property)
property
- the property to add@Deprecated public final List<Property> getProperties(String name)
ContentContainer.get(String)
name
- name of properties to retrieve@Deprecated public final <T extends Property> Optional<T> getProperty(String name)
ContentContainer.getFirst(String)
name
- name of the property to retrievepublic final void validate() throws ValidationException
ValidationException
- where the calendar is not in a valid statepublic void validate(boolean recurse) throws ValidationException
recurse
- indicates whether to validate the calendar's properties and componentsValidationException
- where the calendar is not in a valid statepublic final Calendar copy()
@Deprecated public final Optional<ProdId> getProductId()
getProperty(String)
@Deprecated public final Optional<Version> getVersion()
getProperty(String)
@Deprecated public final Optional<CalScale> getCalendarScale()
getProperty(String)
@Deprecated public final Optional<Method> getMethod()
getProperty(String)