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.

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

Author:
Michael Angstadt

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.
 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 a marshaller for an experimental component.
 void registerMarshaller(ICalPropertyMarshaller<? extends ICalProperty> marshaller)
          Registers a marshaller for an experimental property.
 void setCaretDecodingEnabled(boolean enable)
          Sets whether the reader will decode parameter values that use circumflex accent encoding (enabled by default).
 
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 a marshaller for an experimental property.

Parameters:
marshaller - the marshaller to register

registerMarshaller

public void registerMarshaller(ICalComponentMarshaller<? extends ICalComponent> marshaller)
Registers a marshaller for an experimental component.

Parameters:
marshaller - the marshaller to register

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.