public class VCardRawWriter
extends java.lang.Object
implements java.io.Closeable, java.io.Flushable
Modifier and Type | Class and Description |
---|---|
static interface |
VCardRawWriter.ProblemsListener
A listener whose methods are invoked when non-critical issues occur
during the writing process.
|
Constructor and Description |
---|
VCardRawWriter(java.io.Writer writer,
VCardVersion version)
Creates a vCard raw writer.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying
Writer object. |
void |
flush()
Flushes the underlying
Writer object. |
FoldedLineWriter |
getFoldedLineWriter()
Gets the writer object that this object wraps.
|
VCardRawWriter.ProblemsListener |
getProblemsListener()
Gets the problems listener.
|
VCardVersion |
getVersion()
Gets the vCard version that the writer is adhering to.
|
boolean |
isCaretEncodingEnabled()
Gets whether the writer will apply circumflex accent encoding on
parameter values (disabled by default, only applies to 3.0 and 4.0
vCards).
|
void |
setCaretEncodingEnabled(boolean enable)
Sets whether the writer will apply circumflex accent encoding on
parameter values (disabled by default, only applies to 3.0 and 4.0
vCards).
|
void |
setProblemsListener(VCardRawWriter.ProblemsListener problemsListener)
Sets the problems listener.
|
void |
setVersion(VCardVersion version)
Sets the vCard version that the writer should adhere to.
|
void |
writeBeginComponent(java.lang.String componentName)
Writes a property marking the beginning of a component (in other words,
writes a "BEGIN:NAME" property).
|
void |
writeEndComponent(java.lang.String componentName)
Writes a property marking the end of a component (in other words, writes
a "END:NAME" property).
|
void |
writeProperty(java.lang.String propertyName,
java.lang.String value)
Writes a property to the vCard data stream.
|
void |
writeProperty(java.lang.String group,
java.lang.String propertyName,
VCardParameters parameters,
java.lang.String value)
Writes a property to the vCard data stream.
|
void |
writeVersion()
Writes a "VERSION" property, based on the vCard version that the writer
is adhering to.
|
public VCardRawWriter(java.io.Writer writer, VCardVersion version)
writer
- the writer to the data streamversion
- the vCard version to adhere topublic FoldedLineWriter getFoldedLineWriter()
public boolean isCaretEncodingEnabled()
Gets whether the writer will apply circumflex accent encoding on parameter values (disabled by default, only applies to 3.0 and 4.0 vCards). This escaping mechanism allows for newlines and double quotes to be included in parameter values.
When disabled, the writer will replace newlines with spaces and double quotes with single quotes.
Character | Replacement (when disabled) |
Replacement (when enabled) |
---|---|---|
" |
' |
^' |
newline | space |
^n |
^ |
^ |
^^ |
Example:
GEO;X-ADDRESS="Pittsburgh Pirates^n115 Federal St^nPitt sburgh, PA 15212":40.446816;80.00566
public void setCaretEncodingEnabled(boolean enable)
Sets whether the writer will apply circumflex accent encoding on parameter values (disabled by default, only applies to 3.0 and 4.0 vCards). This escaping mechanism allows for newlines and double quotes to be included in parameter values.
When disabled, the writer will replace newlines with spaces and double quotes with single quotes.
Character | Replacement (when disabled) |
Replacement (when enabled) |
---|---|---|
" |
' |
^' |
newline | space |
^n |
^ |
^ |
^^ |
Example:
GEO;X-ADDRESS="Pittsburgh Pirates^n115 Federal St^nPitt sburgh, PA 15212":40.446816;80.00566
enable
- true to use circumflex accent encoding, false not topublic VCardVersion getVersion()
public void setVersion(VCardVersion version)
version
- the versionpublic VCardRawWriter.ProblemsListener getProblemsListener()
public void setProblemsListener(VCardRawWriter.ProblemsListener problemsListener)
problemsListener
- the listener or null to removepublic void writeBeginComponent(java.lang.String componentName) throws java.io.IOException
componentName
- the component name (e.g. "VCARD")java.io.IOException
- if there's an I/O problempublic void writeEndComponent(java.lang.String componentName) throws java.io.IOException
componentName
- the component name (e.g. "VCARD")java.io.IOException
- if there's an I/O problempublic void writeVersion() throws java.io.IOException
java.io.IOException
- if there's an I/O problempublic void writeProperty(java.lang.String propertyName, java.lang.String value) throws java.io.IOException
propertyName
- the property name (e.g. "FN")value
- the property valuejava.lang.IllegalArgumentException
- if the property name contains invalid
charactersjava.io.IOException
- if there's an I/O problempublic void writeProperty(java.lang.String group, java.lang.String propertyName, VCardParameters parameters, java.lang.String value) throws java.io.IOException
group
- the group or null if there is no grouppropertyName
- the property name (e.g. "FN")parameters
- the property parametersvalue
- the property value (will be converted to "quoted-printable"
encoding if the Encoding.QUOTED_PRINTABLE
parameter is set)java.lang.IllegalArgumentException
- if the group or property name contains
invalid charactersjava.io.IOException
- if there's an I/O problempublic void flush() throws java.io.IOException
Writer
object.flush
in interface java.io.Flushable
java.io.IOException
- if there's a problem flushing the writerpublic void close() throws java.io.IOException
Writer
object.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
- if there's a problem closing the writerThis software is published under the BSD license. Copyright © 2003-${build.year}, CRIXP AG, Switzerland, All rights reserved. Use is subject to license terms.