public class XCalWriter extends Object implements Closeable
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();
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 |
---|---|
void |
close()
Terminates the XML document and closes the output stream.
|
ScribeIndex |
getScribeIndex()
Gets the object that manages the component/property scribes.
|
void |
registerParameterDataType(String parameterName,
ICalDataType dataType)
Registers the data type of an experimental parameter.
|
void |
registerScribe(ICalComponentScribe<? extends ICalComponent> scribe)
Registers an experimental component scribe.
|
void |
registerScribe(ICalPropertyScribe<? extends ICalProperty> scribe)
Registers an experimental property scribe.
|
void |
setScribeIndex(ScribeIndex scribe)
Sets the object that manages the component/property scribes.
|
void |
write(ICalendar ical)
Writes an iCalendar object.
|
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 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 scribe)
scribe
- the scribe indexpublic void write(ICalendar ical) throws SAXException
ical
- the iCalendar object to writeSAXException
- if there's a problem writing the iCalendar objectIllegalArgumentException
- if the scribe index is missing scribes
for one or more properties/components.public void registerParameterDataType(String parameterName, ICalDataType dataType)
parameterName
- the parameter name (e.g. "x-foo")dataType
- the data type or null to removepublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2013-2014 Michael Angstadt. All Rights Reserved.