biweekly
Class ICalendar

java.lang.Object
  extended by biweekly.component.ICalComponent
      extended by biweekly.ICalendar

public class ICalendar
extends ICalComponent

Represents an iCalendar object.

Examples:

 ICalendar ical = new ICalendar();
 
 VEvent event = new VEvent();
 event.setSummary("Team Meeting");
 Date start = ...;
 event.setDateStart(start);
 Date end = ...;
 event.setDateEnd(end);
 ical.addEvent(event);
 

Author:
Michael Angstadt
Specification Reference:
RFC 5545

Field Summary
 
Fields inherited from class biweekly.component.ICalComponent
components, properties
 
Constructor Summary
ICalendar()
           Creates a new iCalendar object.
 
Method Summary
 void addEvent(VEvent event)
          Adds an event.
 void addFreeBusy(VFreeBusy freeBusy)
          Adds a free/busy entry.
 void addJournal(VJournal journal)
          Adds a journal entry.
 void addTimezone(VTimezone timezone)
          Adds a timezone.
 void addTodo(VTodo todo)
          Adds a to-do.
 CalendarScale getCalendarScale()
          Gets the calendar system that this iCalendar object uses.
 List<VEvent> getEvents()
          Gets the events.
 List<VFreeBusy> getFreeBusies()
          Gets the free/busy entries.
 List<VJournal> getJournals()
          Gets the journal entries.
 Method getMethod()
          Gets the value of the Content-Type "method" parameter if the iCalendar object is defined as a MIME message entity.
 ProductId getProductId()
          Gets the name of the application that created the iCalendar object.
 List<VTimezone> getTimezones()
          Gets the timezones.
 List<VTodo> getTodos()
          Gets the to-dos.
 Version getVersion()
          Gets the min/max versions a consumer must support in order to successfully parse the iCalendar object.
 void setCalendarScale(CalendarScale calendarScale)
          Sets the calendar system that this iCalendar object uses.
 void setMethod(Method method)
          Sets the value of the Content-Type "method" parameter if the iCalendar object is defined as a MIME message entity.
 Method setMethod(String method)
          Sets the value of the Content-Type "method" parameter if the iCalendar object is defined as a MIME message entity.
 void setProductId(ProductId prodId)
          Sets the name of the application that created the iCalendar object.
 ProductId setProductId(String prodId)
          Sets the application that created the iCalendar object.
 void setVersion(Version version)
          Sets the min/max versions a consumer must support in order to successfully parse the iCalendar object.
 ValidationWarnings validate()
          Checks this iCalendar object for data consistency problems or deviations from the spec.
protected  void validate(List<ICalComponent> components, List<String> warnings)
          Checks the component for data consistency problems or deviations from the spec.
 String write()
          Marshals this iCalendar object to its plain text representation.
 void write(File file)
          Marshals this iCalendar object to its plain text representation.
 void write(OutputStream out)
          Marshals this iCalendar object to its plain text representation.
 void write(Writer writer)
          Marshals this iCalendar object to its plain text representation.
 String writeJson()
          Marshals this iCalendar object to its JSON representation (jCal).
 void writeJson(File file)
          Marshals this iCalendar object to its JSON representation (jCal).
 void writeJson(OutputStream out)
          Marshals this iCalendar object to its JSON representation (jCal).
 void writeJson(Writer writer)
          Marshals this iCalendar object to its JSON representation (jCal).
 String writeXml()
          Marshals this iCalendar object to its XML representation (xCal).
 void writeXml(File file)
          Marshals this iCalendar object to its XML representation (xCal).
 void writeXml(OutputStream out)
          Marshals this iCalendar object to its XML representation (xCal).
 void writeXml(Writer writer)
          Marshals this iCalendar object to its XML representation (xCal).
 
Methods inherited from class biweekly.component.ICalComponent
addComponent, addExperimentalComponent, addExperimentalProperty, addExperimentalProperty, addProperty, checkOptionalCardinality, checkRequiredCardinality, getComponent, getComponents, getComponents, getExperimentalComponent, getExperimentalComponents, getExperimentalComponents, getExperimentalProperties, getExperimentalProperties, getExperimentalProperty, getProperties, getProperties, getProperty, removeExperimentalComponents, removeExperimentalProperty, removeProperties, setComponent, setComponent, setExperimentalComponents, setExperimentalProperty, setExperimentalProperty, setProperty, setProperty, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ICalendar

public ICalendar()

Creates a new iCalendar object.

The following properties are auto-generated on object creation. These properties must be present in order for the iCalendar object to be valid:

Method Detail

getVersion

public Version getVersion()
Gets the min/max versions a consumer must support in order to successfully parse the iCalendar object. All ICalendar objects are initialized with a version of "2.0" (the default version). It is a required property.

Returns:
the version
Specification Reference:
RFC 5545 p.79-80

setVersion

public void setVersion(Version version)
Sets the min/max versions a consumer must support in order to successfully parse the iCalendar object. All ICalendar objects are initialized with a version of "2.0" (the default version). It is a required property.

Parameters:
version - the version
Specification Reference:
RFC 5545 p.79-80

getProductId

public ProductId getProductId()
Gets the name of the application that created the iCalendar object. All ICalendar objects are initialized with a product ID representing this library. It is a required property.

Returns:
the property instance or null if not set
Specification Reference:
RFC 5545 p.78-9

setProductId

public void setProductId(ProductId prodId)
Sets the name of the application that created the iCalendar object. All ICalendar objects are initialized with a product ID representing this library. It is a required property.

Parameters:
prodId - the property instance or null to remove
Specification Reference:
RFC 5545 p.78-9

setProductId

public ProductId setProductId(String prodId)
Sets the application that created the iCalendar object. All ICalendar objects are initialized with a product ID representing this library.

Parameters:
prodId - a unique string representing the application (e.g. "-//Company//Application//EN") or null to remove
Returns:
the property that was created
Specification Reference:
RFC 5545 p.78-9

getCalendarScale

public CalendarScale getCalendarScale()
Gets the calendar system that this iCalendar object uses. If none is specified, then the calendar is assumed to be in Gregorian format.

Returns:
the calendar system or null if not set
Specification Reference:
RFC 5545 p.76-7

setCalendarScale

public void setCalendarScale(CalendarScale calendarScale)
Sets the calendar system that this iCalendar object uses. If none is specified, then the calendar is assumed to be in Gregorian format.

Parameters:
calendarScale - the calendar system or null to remove
Specification Reference:
RFC 5545 p.76-7

getMethod

public Method getMethod()
Gets the value of the Content-Type "method" parameter if the iCalendar object is defined as a MIME message entity.

Returns:
the property or null if not set
Specification Reference:
RFC 5545 p.77-8

setMethod

public void setMethod(Method method)
Sets the value of the Content-Type "method" parameter if the iCalendar object is defined as a MIME message entity.

Parameters:
method - the property or null to remove
Specification Reference:
RFC 5545 p.77-8

setMethod

public Method setMethod(String method)
Sets the value of the Content-Type "method" parameter if the iCalendar object is defined as a MIME message entity.

Parameters:
method - the method or null to remove
Returns:
the property that was created
Specification Reference:
RFC 5545 p.77-8

getEvents

public List<VEvent> getEvents()
Gets the events.

Returns:
the events

addEvent

public void addEvent(VEvent event)
Adds an event.

Parameters:
event - the event

getTodos

public List<VTodo> getTodos()
Gets the to-dos.

Returns:
the to-dos

addTodo

public void addTodo(VTodo todo)
Adds a to-do.

Parameters:
todo - the to-do

getJournals

public List<VJournal> getJournals()
Gets the journal entries.

Returns:
the journal entries

addJournal

public void addJournal(VJournal journal)
Adds a journal entry.

Parameters:
journal - the journal entry

getFreeBusies

public List<VFreeBusy> getFreeBusies()
Gets the free/busy entries.

Returns:
the free/busy entries

addFreeBusy

public void addFreeBusy(VFreeBusy freeBusy)
Adds a free/busy entry.

Parameters:
freeBusy - the free/busy entry

getTimezones

public List<VTimezone> getTimezones()
Gets the timezones.

Returns:
the timezones

addTimezone

public void addTimezone(VTimezone timezone)
Adds a timezone.

Parameters:
timezone - the timezone

validate

public ValidationWarnings validate()
Checks this iCalendar object for data consistency problems or deviations from the spec. These problems will not prevent the iCalendar object from being written to a data stream, but may prevent it from being parsed correctly by the consuming application. These problems can largely be avoided by reading the Javadocs of the component and property classes, or by being familiar with the iCalendar standard.

Returns:
the validation warnings

validate

protected void validate(List<ICalComponent> components,
                        List<String> warnings)
Description copied from class: ICalComponent
Checks the component for data consistency problems or deviations from the spec. Meant to be overridden by child classes.

Overrides:
validate in class ICalComponent
Parameters:
components - the hierarchy of components that the component belongs to
warnings - the list to add the warnings to

write

public String write()
Marshals this iCalendar object to its plain text representation.

Returns:
the plain text representation

write

public void write(File file)
           throws IOException
Marshals this iCalendar object to its plain text representation.

Parameters:
file - the file to write to
Throws:
IOException - if there's an I/O problem

write

public void write(OutputStream out)
           throws IOException
Marshals this iCalendar object to its plain text representation.

Parameters:
out - the data stream to write to
Throws:
IOException - if there's an I/O problem

write

public void write(Writer writer)
           throws IOException
Marshals this iCalendar object to its plain text representation.

Parameters:
writer - the data stream to write to
Throws:
IOException - if there's an I/O problem

writeXml

public String writeXml()
Marshals this iCalendar object to its XML representation (xCal). If the iCalendar object contains user-defined property or component objects, use the Biweekly class instead, in order to register the marshaller classes.

Returns:
the XML document
Throws:
IllegalArgumentException - if the iCalendar object contains user-defined property or component objects

writeXml

public void writeXml(File file)
              throws TransformerException,
                     IOException
Marshals this iCalendar object to its XML representation (xCal). If the iCalendar object contains user-defined property or component objects, use the Biweekly class instead, in order to register the marshaller classes.

Parameters:
file - the file to write to
Throws:
IllegalArgumentException - if the iCalendar object contains user-defined property or component objects
TransformerException - if there's an I/O problem
IOException - if the file cannot be written to

writeXml

public void writeXml(OutputStream out)
              throws TransformerException
Marshals this iCalendar object to its XML representation (xCal). If the iCalendar object contains user-defined property or component objects, use the Biweekly class instead, in order to register the marshaller classes.

Parameters:
out - the data stream to write to
Throws:
IllegalArgumentException - if the iCalendar object contains user-defined property or component objects
TransformerException - if there's an I/O problem

writeXml

public void writeXml(Writer writer)
              throws TransformerException
Marshals this iCalendar object to its XML representation (xCal). If the iCalendar object contains user-defined property or component objects, use the Biweekly class instead, in order to register the marshaller classes.

Parameters:
writer - the data stream to write to
Throws:
IllegalArgumentException - if the iCalendar object contains user-defined property or component objects
TransformerException - if there's an I/O problem

writeJson

public String writeJson()
Marshals this iCalendar object to its JSON representation (jCal). If the iCalendar object contains user-defined property or component objects, use the Biweekly class instead, in order to register the marshaller classes.

Returns:
the JSON string
Throws:
IllegalArgumentException - if the iCalendar object contains user-defined property or component objects

writeJson

public void writeJson(File file)
               throws IOException
Marshals this iCalendar object to its JSON representation (jCal). If the iCalendar object contains user-defined property or component objects, use the Biweekly class instead, in order to register the marshaller classes.

Parameters:
file - the file to write to
Throws:
IllegalArgumentException - if the iCalendar object contains user-defined property or component objects
IOException - if there's a problem writing to the file

writeJson

public void writeJson(OutputStream out)
               throws IOException
Marshals this iCalendar object to its JSON representation (jCal). If the iCalendar object contains user-defined property or component objects, use the Biweekly class instead, in order to register the marshaller classes.

Parameters:
out - the data stream to write to
Throws:
IllegalArgumentException - if the iCalendar object contains user-defined property or component objects
IOException - if there's a problem writing to the output stream

writeJson

public void writeJson(Writer writer)
               throws IOException
Marshals this iCalendar object to its JSON representation (jCal). If the iCalendar object contains user-defined property or component objects, use the Biweekly class instead, in order to register the marshaller classes.

Parameters:
writer - the data stream to write to
Throws:
IllegalArgumentException - if the iCalendar object contains user-defined property or component objects
IOException - if there's a problem writing to the writer


Copyright © 2013 Michael Angstadt. All Rights Reserved.