public class JCalWriter extends Object implements Closeable, Flushable
Writes ICalendar objects to a JSON data stream (jCal).
Example:
List<ICalendar> icals = ...
OutputStream out = ...
JCalWriter jcalWriter = new JCalWriter(out);
for (ICalendar ical : icals){
jcalWriter.write(ical);
}
jcalWriter.close();
| Constructor and Description |
|---|
JCalWriter(File file)
Creates a jCal writer that writes to a file.
|
JCalWriter(File file,
boolean wrapInArray)
Creates a jCal writer that writes to a file.
|
JCalWriter(OutputStream outputStream)
Creates a jCal writer that writes to an output stream.
|
JCalWriter(OutputStream outputStream,
boolean wrapInArray)
Creates a jCal writer that writes to an output stream.
|
JCalWriter(Writer writer)
Creates a jCal writer that writes to a writer.
|
JCalWriter(Writer writer,
boolean wrapInArray)
Creates a jCal writer that writes to a writer.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
ScribeIndex |
getScribeIndex()
Gets the object that manages the component/property scribes.
|
boolean |
isIndent()
Gets whether or not the JSON will be pretty-printed.
|
void |
registerScribe(ICalComponentScribe<? extends ICalComponent> scribe)
Registers an experimental component scribe.
|
void |
registerScribe(ICalPropertyScribe<? extends ICalProperty> scribe)
Registers an experimental property scribe.
|
void |
setIndent(boolean indent)
Sets whether or not to pretty-print the JSON.
|
void |
setScribeIndex(ScribeIndex index)
Sets the object that manages the component/property scribes.
|
void |
write(ICalendar ical)
Writes an iCalendar object to the data stream.
|
public JCalWriter(OutputStream outputStream)
outputStream - the output stream to write topublic JCalWriter(OutputStream outputStream, boolean wrapInArray)
outputStream - the output stream 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(File file) throws IOException
file - the file to write toIOException - if the file cannot be written topublic JCalWriter(File file, boolean wrapInArray) throws IOException
file - the file to write towrapInArray - 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 the data streampublic JCalWriter(Writer writer, boolean wrapInArray)
writer - the writer to the data streamwrapInArray - true to wrap all iCalendar objects in a parent array,
false not to (useful when writing more than one iCalendar object)public void registerScribe(ICalPropertyScribe<? extends ICalProperty> scribe)
Registers an experimental property scribe. Can also be used to override the scribe of a standard property (such as DTSTART). Calling this method is the same as calling:
getScribeIndex().register(scribe).
scribe - the scribe to registerpublic void registerScribe(ICalComponentScribe<? extends ICalComponent> scribe)
Registers an experimental component scribe. Can also be used to override the scribe of a standard component (such as VEVENT). Calling this method is the same as calling:
getScribeIndex().register(scribe).
scribe - the scribe to registerpublic ScribeIndex getScribeIndex()
public void setScribeIndex(ScribeIndex index)
index - the scribe indexpublic boolean isIndent()
public void setIndent(boolean indent)
indent - true to pretty-print it, false not to (defaults to false)public void write(ICalendar ical) throws IOException
ical - the iCalendar object to writeIllegalArgumentException - if the scribe class for a component or
property object cannot be found (only happens when an experimental
property/component scribe is not registered with the
registerScribe method.)IOException - if there's a problem writing to the data streampublic 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-2014 Michael Angstadt. All Rights Reserved.