|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiweekly.Biweekly
public class Biweekly
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 |
Nested Class Summary | |
---|---|
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). |
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.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). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String VERSION
public static final String URL
Method Detail |
---|
public static Biweekly.ParserChainTextString parse(String ical)
ical
- the iCalendar data
public static Biweekly.ParserChainTextReader parse(File file)
file
- the iCalendar file
public static Biweekly.ParserChainTextReader parse(InputStream in)
in
- the input stream
public static Biweekly.ParserChainTextReader parse(Reader reader)
reader
- the reader
public static Biweekly.WriterChainText write(ICalendar... icals)
icals
- the iCalendar objects to write
public static Biweekly.WriterChainText write(Collection<ICalendar> icals)
icals
- the iCalendar objects to write
public static Biweekly.ParserChainXmlString parseXml(String xml)
xml
- the XML string
public static Biweekly.ParserChainXmlReader parseXml(File file)
file
- the XML file
public static Biweekly.ParserChainXmlReader parseXml(InputStream in)
in
- the input stream
public 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 reader
public static Biweekly.ParserChainXmlDocument parseXml(Document document)
document
- the XML document
public static Biweekly.WriterChainXml writeXml(ICalendar... icals)
icals
- the iCalendar object(s) to write
public static Biweekly.WriterChainXml writeXml(Collection<ICalendar> icals)
icals
- the iCalendar objects to write
public static Biweekly.ParserChainJsonString parseJson(String json)
json
- the JSON data
public static Biweekly.ParserChainJsonReader parseJson(File file)
file
- the JSON file
public static Biweekly.ParserChainJsonReader parseJson(InputStream in)
in
- the input stream
public static Biweekly.ParserChainJsonReader parseJson(Reader reader)
reader
- the reader
public static Biweekly.WriterChainJson writeJson(ICalendar... icals)
icals
- the iCalendar object(s) to write
public static Biweekly.WriterChainJson writeJson(Collection<ICalendar> icals)
icals
- the iCalendar objects to write
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |