biweekly
Class Biweekly

java.lang.Object
  extended by biweekly.Biweekly

public class Biweekly
extends Object

Contains static chaining factory methods for reading/writing iCalendar objects.

Writing an iCalendar object

 ICalendar ical = new ICalendar();
 
 //string
 String icalString = Biweekly.write(ical).go();
 
 //file
 File file = new File("meeting.ics");
 Biweekly.write(ical).go(file);
 
 //writer
 Writer writer = ...
 Biweekly.write(ical).go(writer);
 writer.close();
 

Writing multiple iCalendar objects

 ICalendar ical1 = new ICalendar();
 ICalendar ical2 = new ICalendar();
 
 String icalString = Biweekly.write(ical1, ical2).go();
 

Writing an XML-encoded iCalendar object (xCal)

 //Call writeXml() instead of write()
 ICalendar ical = new ICalendar();
 String xml = Biweekly.writeXml(ical).indent(2).go();
 

Reading an iCalendar object

 ICalendar ical;
 
 //string
 String icalStr = ...
 ical = Biweekly.parse(icalStr).first();
 
 //file
 File file = new File("meeting.ics");
 ical = Biweekly.parse(file).first();
 
 //reader
 Reader reader = ...
 ical = Biweekly.parse(reader).first();
 reader.close();
 

Reading multiple iCalendar objects

 String icalStr = ...
 List<ICalendar> icals = Biweekly.parse(icalStr).all();
 

Reading an XML-encoded iCalendar object (xCal)

 //Call parseXml() instead of parse()
 String xml = ...
 ICalendar ical = Biweekly.parseXml(xml).first();
 

Retrieving parser warnings

 String icalStr = ...
 List<List<String>> warnings = new ArrayList<List<String>>();
 List<ICalendar> icals = Biweekly.parse(icalStr).warnings(warnings).all();
 int i = 0;
 for (List<String> icalWarnings : warnings){
   System.out.println("iCal #" + (i++) + " warnings:");
   for (String warning : icalWarnings){
     System.out.println(warning);
   }
 }
 

The methods in this class make use of the following classes. These classes can be used if greater control over the read/write operation is required:

Classes Supports
streaming?
Text ICalReader / ICalWriter yes
XML XCalDocument no

Author:
Michael Angstadt

Nested Class Summary
static class Biweekly.ParserChainTextReader
          Chainer class for parsing plain text iCalendar data streams.
static class Biweekly.ParserChainTextString
          Chainer class for parsing plain text iCalendar strings.
static class Biweekly.ParserChainXmlDocument
          Chainer class for parsing XML-encoded iCalendar objects (xCal).
static class Biweekly.ParserChainXmlReader
          Chainer class for parsing XML-encoded iCalendar objects (xCal).
static class Biweekly.ParserChainXmlString
          Chainer class for parsing XML-encoded iCalendar objects (xCal).
static class Biweekly.WriterChainTextMulti
          Chainer class for writing to plain text iCalendar data streams.
static class Biweekly.WriterChainTextSingle
          Chainer class for writing to plain text iCalendar data streams.
static class Biweekly.WriterChainXml
          Chainer class for writing xCal documents (XML-encoded iCalendar objects).
 
Field Summary
static String URL
          The project webpage.
static String VERSION
          The version of the library.
 
Method Summary
static Biweekly.ParserChainTextReader parse(File file)
          Parses an iCalendar file.
static Biweekly.ParserChainTextReader parse(InputStream in)
          Parses an iCalendar data stream.
static Biweekly.ParserChainTextReader parse(Reader reader)
          Parses an iCalendar data stream.
static Biweekly.ParserChainTextString parse(String ical)
          Parses an iCalendar object string.
static Biweekly.ParserChainXmlDocument parseXml(Document document)
          Parses an xCal document (XML-encoded iCalendar objects).
static Biweekly.ParserChainXmlReader parseXml(File file)
          Parses an xCal document (XML-encoded iCalendar objects).
static Biweekly.ParserChainXmlReader parseXml(InputStream in)
          Parses an xCal document (XML-encoded iCalendar objects).
static Biweekly.ParserChainXmlReader parseXml(Reader reader)
          Parses an xCal document (XML-encoded iCalendar objects).
static Biweekly.ParserChainXmlString parseXml(String xml)
          Parses an xCal document (XML-encoded iCalendar objects).
static Biweekly.WriterChainTextMulti write(Collection<ICalendar> icals)
          Writes multiple iCalendar objects to a data stream.
static Biweekly.WriterChainTextMulti write(ICalendar... icals)
          Writes multiple iCalendar objects to a data stream.
static Biweekly.WriterChainTextSingle write(ICalendar ical)
          Writes an iCalendar object to a data stream.
static Biweekly.WriterChainXml writeXml(Collection<ICalendar> icals)
          Writes an xCal document (XML-encoded iCalendar objects).
static Biweekly.WriterChainXml writeXml(ICalendar... icals)
          Writes an xCal document (XML-encoded iCalendar objects).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
The version of the library.


URL

public static final String URL
The project webpage.

Method Detail

parse

public static Biweekly.ParserChainTextString parse(String ical)
Parses an iCalendar object string.

Parameters:
ical - the iCalendar data
Returns:
chainer object for completing the parse operation

parse

public static Biweekly.ParserChainTextReader parse(File file)
                                            throws FileNotFoundException
Parses an iCalendar file.

Returns:
chainer object for completing the parse operation
Throws:
FileNotFoundException - if the file does not exist or cannot be accessed

parse

public static Biweekly.ParserChainTextReader parse(InputStream in)
Parses an iCalendar data stream.

Parameters:
in - the input stream
Returns:
chainer object for completing the parse operation

parse

public static Biweekly.ParserChainTextReader parse(Reader reader)
Parses an iCalendar data stream.

Parameters:
reader - the reader
Returns:
chainer object for completing the parse operation

write

public static Biweekly.WriterChainTextSingle write(ICalendar ical)
Writes an iCalendar object to a data stream.

Parameters:
ical - the iCalendar object to write
Returns:
chainer object for completing the write operation

write

public static Biweekly.WriterChainTextMulti write(ICalendar... icals)
Writes multiple iCalendar objects to a data stream.

Parameters:
icals - the iCalendar objects to write
Returns:
chainer object for completing the write operation

write

public static Biweekly.WriterChainTextMulti write(Collection<ICalendar> icals)
Writes multiple iCalendar objects to a data stream.

Parameters:
icals - the iCalendar objects to write
Returns:
chainer object for completing the write operation

parseXml

public static Biweekly.ParserChainXmlString parseXml(String xml)
Parses an xCal document (XML-encoded iCalendar objects).

Parameters:
xml - the XML string
Returns:
chainer object for completing the parse operation

parseXml

public static Biweekly.ParserChainXmlReader parseXml(File file)
                                              throws FileNotFoundException
Parses an xCal document (XML-encoded iCalendar objects).

Parameters:
file - the XML file
Returns:
chainer object for completing the parse operation
Throws:
FileNotFoundException - if the file does not exist or cannot be accessed

parseXml

public static Biweekly.ParserChainXmlReader parseXml(InputStream in)
Parses an xCal document (XML-encoded iCalendar objects).

Parameters:
in - the input stream
Returns:
chainer object for completing the parse operation

parseXml

public static Biweekly.ParserChainXmlReader parseXml(Reader reader)
Parses an xCal document (XML-encoded iCalendar objects).

Parameters:
reader - the reader
Returns:
chainer object for completing the parse operation

parseXml

public static Biweekly.ParserChainXmlDocument parseXml(Document document)
Parses an xCal document (XML-encoded iCalendar objects).

Parameters:
document - the XML document
Returns:
chainer object for completing the parse operation

writeXml

public static Biweekly.WriterChainXml writeXml(ICalendar... icals)
Writes an xCal document (XML-encoded iCalendar objects).

Parameters:
icals - the iCalendar object(s) to write
Returns:
chainer object for completing the write operation

writeXml

public static Biweekly.WriterChainXml writeXml(Collection<ICalendar> icals)
Writes an xCal document (XML-encoded iCalendar objects).

Parameters:
icals - the iCalendar objects to write
Returns:
chainer object for completing the write operation


Copyright © 2013 Michael Angstadt. All Rights Reserved.