public class JCalWriter extends StreamWriter implements Flushable
Writes ICalendar objects to a JSON data stream (jCal).
Example:
ICalendar ical1 = ...
ICalendar ical2 = ...
File file = new File("icals.json");
JCalWriter writer = null;
try {
writer = new JCalWriter(file);
writer.write(ical1);
writer.write(ical2);
} finally {
if (writer != null) writer.close();
}
Changing the timezone settings:
JCalWriter writer = new JCalWriter(...); //format all date/time values in a specific timezone instead of UTC //note: this makes an HTTP call to the "tzurl.org" website writer.getTimezoneInfo().setDefaultTimeZone(TimeZone.getDefault()); //format the value of a particular date/time property in a specific timezone instead of UTC //note: this makes an HTTP call to the "tzurl.org" website DateStart dtstart = ... writer.getTimezoneInfo().setTimeZone(dtstart, TimeZone.getDefault()); //generate Outlook-friendly VTIMEZONE components: writer.getTimezoneInfo().setGenerator(new TzUrlDotOrgGenerator(true));
context, index, tzinfo| Constructor and Description |
|---|
JCalWriter(File file) |
JCalWriter(File file,
boolean wrapInArray) |
JCalWriter(OutputStream out) |
JCalWriter(OutputStream out,
boolean wrapInArray) |
JCalWriter(Writer writer) |
JCalWriter(Writer writer,
boolean wrapInArray) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_write(ICalendar ical)
Writes an iCalendar object to the data stream.
|
void |
close()
Finishes writing the JSON document and closes the underlying
Writer object. |
void |
closeJsonStream()
Finishes writing the JSON document so that it is syntactically correct.
|
void |
flush()
Flushes the stream.
|
protected ICalVersion |
getTargetVersion()
Gets the version that the next iCalendar object will be written as.
|
boolean |
isIndent()
Gets whether or not the JSON will be pretty-printed.
|
void |
setIndent(boolean indent)
Sets whether or not to pretty-print the JSON.
|
getScribeIndex, getTimezoneInfo, registerScribe, registerScribe, setScribeIndex, setTimezoneInfo, writepublic JCalWriter(OutputStream out)
out - the output stream to write to (UTF-8 encoding will be used)public JCalWriter(OutputStream out, boolean wrapInArray)
out - the output stream to write to (UTF-8 encoding will be used)wrapInArray - true to wrap all iCalendar objects in a parent array,
false not to (useful when writing more than one iCalendar object)public JCalWriter(File file) throws IOException
file - the file to write to (UTF-8 encoding will be used)IOException - if the file cannot be written topublic JCalWriter(File file, boolean wrapInArray) throws IOException
file - the file to write to (UTF-8 encoding will be used)wrapInArray - true to wrap all iCalendar objects in a parent array,
false not to (useful when writing more than one iCalendar object)IOException - if the file cannot be written topublic JCalWriter(Writer writer)
writer - the writer to write topublic JCalWriter(Writer writer, boolean wrapInArray)
writer - the writer to write towrapInArray - true to wrap all iCalendar objects in a parent array,
false not to (useful when writing more than one iCalendar object)public boolean isIndent()
public void setIndent(boolean indent)
indent - true to pretty-print it, false not to (defaults to false)protected void _write(ICalendar ical) throws IOException
StreamWriter_write in class StreamWriterical - the iCalendar object to writeIOException - if there's a problem writing to the data streamprotected ICalVersion getTargetVersion()
StreamWritergetTargetVersion in class StreamWriterpublic void flush() throws IOException
flush in interface FlushableIOException - if there's a problem flushing the streampublic void close() throws IOException
Writer object.close in interface Closeableclose in interface AutoCloseableIOException - if there's a problem closing the streampublic void closeJsonStream() throws IOException
IOException - if there's a problem writing to the data streamCopyright © 2013-2015 Michael Angstadt. All Rights Reserved.