public class XCalWriter extends StreamWriter
Writes xCards (XML-encoded iCalendar objects) in a streaming fashion.
Example:
ICalendar ical1 = ...
ICalendar ical2 = ...
File file = new File("icals.xml");
XCalWriter writer = null;
try {
writer = new XCalWriter(file);
writer.write(ical1);
writer.write(ical2);
} finally {
if (writer != null) writer.close();
}
Changing the timezone settings:
XCalWriter writer = new XCalWriter(...); //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 |
|---|
XCalWriter(File file) |
XCalWriter(Node parent) |
XCalWriter(OutputStream out) |
XCalWriter(Writer writer) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_write(ICalendar ical)
Writes an iCalendar object to the data stream.
|
void |
close()
Terminates the XML document and closes the output stream.
|
protected ICalVersion |
getTargetVersion()
Gets the version that the next iCalendar object will be written as.
|
void |
registerParameterDataType(String parameterName,
ICalDataType dataType)
Registers the data type of an experimental parameter.
|
void |
setIndent(String indent)
Set the indentation string to use for pretty-printing the output.
|
getScribeIndex, getTimezoneInfo, registerScribe, registerScribe, setScribeIndex, setTimezoneInfo, writepublic XCalWriter(OutputStream out)
out - the output stream to write to (UTF-8 encoding will be used)public XCalWriter(File file) throws IOException
file - the file to write to (UTF-8 encoding will be used).IOException - if there's a problem opening the filepublic XCalWriter(Writer writer)
writer - the writer to write topublic XCalWriter(Node parent)
parent - the DOM node to add child elements topublic void setIndent(String indent)
indent - the indentation string (e.g. 2 spaces) or null to disable
pretty-printing (defaults to null)public void registerParameterDataType(String parameterName, ICalDataType dataType)
parameterName - the parameter name (e.g. "x-foo")dataType - the data type or null to removeprotected 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 close() throws IOException
IOExceptionCopyright © 2013-2015 Michael Angstadt. All Rights Reserved.