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(); }
context, globalTimezone, index
Constructor and Description |
---|
JCalWriter(File file) |
JCalWriter(File file,
boolean wrapInArray) |
JCalWriter(JsonGenerator generator) |
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 |
isPrettyPrint()
Gets whether or not the JSON will be pretty-printed.
|
void |
setPrettyPrint(boolean prettyPrint)
Sets whether or not to pretty-print the JSON.
|
getGlobalTimezone, getScribeIndex, getTimezoneComponents, registerScribe, registerScribe, setGlobalTimezone, setScribeIndex, write
public 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 JCalWriter(JsonGenerator generator)
generator
- the generator to write topublic boolean isPrettyPrint()
public void setPrettyPrint(boolean prettyPrint)
prettyPrint
- true to pretty-print it, false not to (defaults to
false)protected void _write(ICalendar ical) throws IOException
StreamWriter
_write
in class StreamWriter
ical
- the iCalendar object to writeIOException
- if there's a problem writing to the data streamprotected ICalVersion getTargetVersion()
StreamWriter
getTargetVersion
in class StreamWriter
public void flush() throws IOException
flush
in interface Flushable
IOException
- if there's a problem flushing the streampublic void close() throws IOException
Writer
object.close
in interface Closeable
close
in interface AutoCloseable
IOException
- if there's a problem closing the streampublic void closeJsonStream() throws IOException
IOException
- if there's a problem writing to the data streamCopyright © 2013-2017 Michael Angstadt. All Rights Reserved.