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); //output stream OutputStream out = ... Biweekly.write(ical).go(out); out.close(); //writer (should be configured to use UTF-8 encoding) 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();
Writing a JSON-encoded iCalendar object (jCal)
//Call writeJson() instead of write() ICalendar ical = new ICalendar(); String json = Biweekly.writeJson(ical).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(); //input stream InputStream in = ... ical = Biweekly.parse(in).first(); in.close(); //reader (should be configured to read UTF-8) 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();
Reading a JSON-encoded iCalendar object (Cal)
//Call parseJson() instead of parse() String json = ... ICalendar ical = Biweekly.parseJson(json).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 |
JSON | JCalReader / JCalWriter |
yes |
Modifier and Type | Class and Description |
---|---|
static class |
Biweekly.ParserChainJsonReader
Chainer class for parsing JSON-encoded iCalendar data streams (jCal).
|
static class |
Biweekly.ParserChainJsonString
Chainer class for parsing JSON-encoded iCalendar strings (jCal).
|
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.WriterChainJson
Chainer class for writing to JSON-encoded iCalendar data streams (jCal).
|
static class |
Biweekly.WriterChainText
Chainer class for writing to plain text iCalendar data streams.
|
static class |
Biweekly.WriterChainXml
Chainer class for writing xCal documents (XML-encoded iCalendar objects).
|
Modifier and Type | Field and Description |
---|---|
static String |
URL
The project webpage.
|
static String |
VERSION
The version of the library.
|
Modifier and Type | Method and Description |
---|---|
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.ParserChainJsonReader |
parseJson(File file)
Parses a jCal data stream (JSON-encoded iCalendar objects).
|
static Biweekly.ParserChainJsonReader |
parseJson(InputStream in)
Parses a jCal data stream (JSON-encoded iCalendar objects).
|
static Biweekly.ParserChainJsonReader |
parseJson(Reader reader)
Parses a jCal data stream (JSON-encoded iCalendar objects).
|
static Biweekly.ParserChainJsonString |
parseJson(String json)
Parses a jCal data stream (JSON-encoded iCalendar objects).
|
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) from a file.
|
static Biweekly.ParserChainXmlReader |
parseXml(InputStream in)
Parses an xCal document (XML-encoded iCalendar objects) from an input
stream.
|
static Biweekly.ParserChainXmlReader |
parseXml(Reader reader)
Parses an xCal document (XML-encoded iCalendar objects) from a reader.
|
static Biweekly.ParserChainXmlString |
parseXml(String xml)
Parses an xCal document (XML-encoded iCalendar objects) from a string.
|
static Biweekly.WriterChainText |
write(Collection<ICalendar> icals)
Writes multiple iCalendar objects to a data stream.
|
static Biweekly.WriterChainText |
write(ICalendar... icals)
Writes multiple iCalendar objects to a data stream.
|
static Biweekly.WriterChainJson |
writeJson(Collection<ICalendar> icals)
Writes an xCal document (XML-encoded iCalendar objects).
|
static Biweekly.WriterChainJson |
writeJson(ICalendar... icals)
Writes an xCal document (XML-encoded iCalendar objects).
|
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).
|
public static Biweekly.ParserChainTextString parse(String ical)
ical
- the iCalendar datapublic static Biweekly.ParserChainTextReader parse(File file)
file
- the iCalendar filepublic static Biweekly.ParserChainTextReader parse(InputStream in)
in
- the input streampublic static Biweekly.ParserChainTextReader parse(Reader reader)
reader
- the readerpublic static Biweekly.WriterChainText write(ICalendar... icals)
icals
- the iCalendar objects to writepublic static Biweekly.WriterChainText write(Collection<ICalendar> icals)
icals
- the iCalendar objects to writepublic static Biweekly.ParserChainXmlString parseXml(String xml)
xml
- the XML stringpublic static Biweekly.ParserChainXmlReader parseXml(File file)
file
- the XML filepublic static Biweekly.ParserChainXmlReader parseXml(InputStream in)
in
- the input streampublic static Biweekly.ParserChainXmlReader parseXml(Reader reader)
Parses an xCal document (XML-encoded iCalendar objects) from a reader.
Note that use of this method is discouraged. It ignores the character
encoding that is defined within the XML document itself, and should only
be used if the encoding is undefined or if the encoding needs to be
ignored for whatever reason. The parseXml(InputStream)
method
should be used instead, since it takes the XML document's character
encoding into account when parsing.
reader
- the readerpublic static Biweekly.ParserChainXmlDocument parseXml(Document document)
document
- the XML documentpublic static Biweekly.WriterChainXml writeXml(ICalendar... icals)
icals
- the iCalendar object(s) to writepublic static Biweekly.WriterChainXml writeXml(Collection<ICalendar> icals)
icals
- the iCalendar objects to writepublic static Biweekly.ParserChainJsonString parseJson(String json)
json
- the JSON datapublic static Biweekly.ParserChainJsonReader parseJson(File file)
file
- the JSON filepublic static Biweekly.ParserChainJsonReader parseJson(InputStream in)
in
- the input streampublic static Biweekly.ParserChainJsonReader parseJson(Reader reader)
reader
- the readerpublic static Biweekly.WriterChainJson writeJson(ICalendar... icals)
icals
- the iCalendar object(s) to writepublic static Biweekly.WriterChainJson writeJson(Collection<ICalendar> icals)
icals
- the iCalendar objects to writeCopyright © 2013-2015 Michael Angstadt. All Rights Reserved.