public class XCalWriter extends StreamWriter
Writes xCards (XML-encoded vCards) in a streaming fashion.
Example:
VCard vcard1 = ... VCard vcard2 = ... File file = new File("vcards.xml"); XCardWriter xcardWriter = new XCardWriter(file); xcardWriter.write(vcard1); xcardWriter.write(vcard2); xcardWriter.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)
Creates an xCard writer (UTF-8 encoding will be used).
|
XCalWriter(File file,
String indent)
Creates an xCard writer (UTF-8 encoding will be used).
|
XCalWriter(Node parent)
Creates an xCard writer.
|
XCalWriter(OutputStream out)
Creates an xCard writer (UTF-8 encoding will be used).
|
XCalWriter(OutputStream out,
String indent)
Creates an xCard writer (UTF-8 encoding will be used).
|
XCalWriter(Writer writer)
Creates an xCard writer.
|
XCalWriter(Writer writer,
String indent)
Creates an xCard 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.
|
getScribeIndex, getTimezoneInfo, registerScribe, registerScribe, setScribeIndex, setTimezoneInfo, write
public XCalWriter(OutputStream out)
out
- the output stream to write the xCards topublic XCalWriter(OutputStream out, String indent)
out
- the output stream to write the xCards toindent
- the indentation string to use for pretty printing (e.g.
"\t") or null not to pretty printpublic XCalWriter(File file) throws IOException
file
- the file to write the xCards toIOException
- if there's a problem opening the filepublic XCalWriter(File file, String indent) throws IOException
file
- the file to write the xCards toindent
- the indentation string to use for pretty printing (e.g.
"\t") or null not to pretty printIOException
- if there's a problem opening the filepublic XCalWriter(Writer writer)
writer
- the writer to write topublic XCalWriter(Writer writer, String indent)
writer
- the writer to write toindent
- the indentation string to use for pretty printing (e.g.
"\t") or null not to pretty printpublic XCalWriter(Node parent)
parent
- the DOM node to add child elements topublic 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 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 close() throws IOException
IOException
Copyright © 2013-2015 Michael Angstadt. All Rights Reserved.