biweekly.io.json
Class JCalReader

java.lang.Object
  extended by biweekly.io.json.JCalReader
All Implemented Interfaces:
Closeable

public class JCalReader
extends Object
implements Closeable

Parses ICalendar objects from a jCal data stream (JSON).

Example:

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

Author:
Michael Angstadt
See Also:
jCal draft

Constructor Summary
JCalReader(File file)
          Creates a jCard reader.
JCalReader(InputStream in)
          Creates a jCard reader.
JCalReader(Reader reader)
          Creates a jCard reader.
JCalReader(String json)
          Creates a jCard reader.
 
Method Summary
 void close()
           
 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.
 ICalendar readNext()
          Reads the next iCalendar object from the JSON data stream.
 void registerMarshaller(ICalComponentMarshaller<? extends ICalComponent> marshaller)
           Registers an experimental component marshaller.
 void registerMarshaller(ICalPropertyMarshaller<? extends ICalProperty> marshaller)
           Registers an experimental property marshaller.
 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

JCalReader

public JCalReader(String json)
Creates a jCard reader.

Parameters:
json - the JSON string

JCalReader

public JCalReader(InputStream in)
Creates a jCard reader.

Parameters:
in - the input stream to read the vCards from

JCalReader

public JCalReader(File file)
           throws FileNotFoundException
Creates a jCard reader.

Parameters:
file - the file to read the vCards from
Throws:
FileNotFoundException - if the file doesn't exist

JCalReader

public JCalReader(Reader reader)
Creates a jCard reader.

Parameters:
reader - the reader to read the vCards from
Method Detail

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

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

readNext

public ICalendar readNext()
                   throws IOException
Reads the next iCalendar object from the JSON data stream.

Returns:
the iCalendar object or null if there are no more
Throws:
JCalParseException - if the jCal syntax is incorrect (the JSON syntax may be valid, but it is not in the correct jCal format).
JsonParseException - if the JSON syntax is incorrect
IOException - if there is a problem reading from the data stream

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException


Copyright © 2013 Michael Angstadt. All Rights Reserved.