biweekly.io.text
Class ICalReader

java.lang.Object
  extended by biweekly.io.text.ICalReader
All Implemented Interfaces:
Closeable

public class ICalReader
extends Object
implements Closeable

Parses ICalendar objects from an iCalendar data stream.

Example:

 InputStream in = ...
 ICalReader icalReader = new ICalReader(in);
 ICalendar ical;
 while ((ical = icalReader.readNext()) != null){
   ...
 }
 icalReader.close();
 

Author:
Michael Angstadt
Specification Reference:
RFC 5545

Constructor Summary
ICalReader(File file)
          Creates a reader that parses iCalendar objects from a file.
ICalReader(InputStream in)
          Creates a reader that parses iCalendar objects from an input stream.
ICalReader(Reader reader)
          Creates a reader that parses iCalendar objects from a reader.
ICalReader(String string)
          Creates a reader that parses iCalendar objects from a string.
 
Method Summary
 void close()
          Closes the underlying Reader object.
 ICalMarshallerRegistrar getRegistrar()
          Gets the object that manages the component/property marshaller objects.
 List<String> getWarnings()
          Gets the warnings from the last iCalendar object that was unmarshalled.
 boolean isCaretDecodingEnabled()
          Gets whether the reader will decode parameter values that use circumflex accent encoding (enabled by default).
 ICalendar readNext()
          Reads the next iCalendar object.
 void registerMarshaller(ICalComponentMarshaller<? extends ICalComponent> marshaller)
           Registers an experimental component marshaller.
 void registerMarshaller(ICalPropertyMarshaller<? extends ICalProperty> marshaller)
           Registers an experimental property marshaller.
 void setCaretDecodingEnabled(boolean enable)
          Sets whether the reader will decode parameter values that use circumflex accent encoding (enabled by default).
 void setRegistrar(ICalMarshallerRegistrar registrar)
          Sets the object that manages the component/property marshaller objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ICalReader

public ICalReader(String string)
Creates a reader that parses iCalendar objects from a string.

Parameters:
string - the string

ICalReader

public ICalReader(InputStream in)
Creates a reader that parses iCalendar objects from an input stream.

Parameters:
in - the input stream

ICalReader

public ICalReader(File file)
           throws FileNotFoundException
Creates a reader that parses iCalendar objects from a file.

Parameters:
file - the file
Throws:
FileNotFoundException - if the file doesn't exist

ICalReader

public ICalReader(Reader reader)
Creates a reader that parses iCalendar objects from a reader.

Parameters:
reader - the reader
Method Detail

isCaretDecodingEnabled

public boolean isCaretDecodingEnabled()
Gets whether the reader will decode parameter values that use circumflex accent encoding (enabled by default). This escaping mechanism allows newlines and double quotes to be included in parameter values.

Returns:
true if circumflex accent decoding is enabled, false if not
See Also:
ICalRawReader.isCaretDecodingEnabled()

setCaretDecodingEnabled

public void setCaretDecodingEnabled(boolean enable)
Sets whether the reader will decode parameter values that use circumflex accent encoding (enabled by default). This escaping mechanism allows newlines and double quotes to be included in parameter values.

Parameters:
enable - true to use circumflex accent decoding, false not to
See Also:
ICalRawReader.setCaretDecodingEnabled(boolean)

registerMarshaller

public void registerMarshaller(ICalPropertyMarshaller<? extends ICalProperty> marshaller)

Registers an experimental property marshaller. Can also be used to override the marshaller of a standard property (such as DTSTART). Calling this method is the same as calling:

getRegistrar().register(marshaller).

Parameters:
marshaller - the marshaller to register

registerMarshaller

public void registerMarshaller(ICalComponentMarshaller<? extends ICalComponent> marshaller)

Registers an experimental component marshaller. Can also be used to override the marshaller of a standard component (such as VEVENT). Calling this method is the same as calling:

getRegistrar().register(marshaller).

Parameters:
marshaller - the marshaller to register

getRegistrar

public ICalMarshallerRegistrar getRegistrar()
Gets the object that manages the component/property marshaller objects.

Returns:
the marshaller registrar

setRegistrar

public void setRegistrar(ICalMarshallerRegistrar registrar)
Sets the object that manages the component/property marshaller objects.

Parameters:
registrar - the marshaller registrar

getWarnings

public List<String> getWarnings()
Gets the warnings from the last iCalendar object that was unmarshalled. This list is reset every time a new iCalendar object is read.

Returns:
the warnings or empty list if there were no warnings

readNext

public ICalendar readNext()
                   throws IOException
Reads the next iCalendar object.

Returns:
the next iCalendar object or null if there are no more
Throws:
IOException - if there's a problem reading from the stream

close

public void close()
           throws IOException
Closes the underlying Reader object.

Specified by:
close in interface Closeable
Throws:
IOException


Copyright © 2013 Michael Angstadt. All Rights Reserved.