|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectezvcard.io.text.VCardWriter
public class VCardWriter
Writes VCard
objects to a plain-text vCard data stream.
Example:
VCard vcard1 = ... VCard vcard2 = ... File file = new File("vcard.vcf"); VCardWriter vcardWriter = new VCardWriter(file); vcardWriter.write(vcard1); vcardWriter.write(vcard2); vcardWriter.close();
Constructor Summary | |
---|---|
VCardWriter(File file)
Creates a writer that writes vCards to a file (writes v3.0 vCards and uses the standard folding scheme and newline sequence). |
|
VCardWriter(File file,
boolean append)
Creates a writer that writes vCards to a file (writes v3.0 vCards and uses the standard folding scheme and newline sequence). |
|
VCardWriter(File file,
boolean append,
VCardVersion targetVersion)
Creates a writer that writes vCards to a file (uses the standard folding scheme and newline sequence). |
|
VCardWriter(File file,
boolean append,
VCardVersion targetVersion,
FoldingScheme foldingScheme,
String newline)
Creates a writer that writes vCards to a file. |
|
VCardWriter(OutputStream out)
Creates a writer that writes vCards to an output stream (writes v3.0 vCards and uses the standard folding scheme and newline sequence). |
|
VCardWriter(OutputStream out,
VCardVersion targetVersion)
Creates a writer that writes vCards to an output stream (uses the standard folding scheme and newline sequence). |
|
VCardWriter(OutputStream out,
VCardVersion targetVersion,
FoldingScheme foldingScheme,
String newline)
Creates a writer that writes vCards to an output stream. |
|
VCardWriter(Writer writer)
Creates a writer that writes vCards to a writer (writes v3.0 vCards and uses the standard folding scheme and newline sequence). |
|
VCardWriter(Writer writer,
VCardVersion targetVersion)
Creates a writer that writes vCards to a writer (uses the standard folding scheme and newline sequence). |
|
VCardWriter(Writer writer,
VCardVersion targetVersion,
FoldingScheme foldingScheme,
String newline)
Creates a writer that writes vCards to a writer. |
Method Summary | |
---|---|
void |
close()
Closes the underlying Writer object. |
void |
flush()
Flushes the underlying Writer object. |
FoldingScheme |
getFoldingScheme()
Gets the rules for how each line is folded. |
String |
getNewline()
Gets the newline sequence that is used to separate lines. |
ScribeIndex |
getScribeIndex()
Gets the scribe index. |
VCardVersion |
getTargetVersion()
Gets the version that the vCards should adhere to. |
boolean |
isAddProdId()
Gets whether or not a "PRODID" property will be added to each vCard, saying that the vCard was generated by this library. |
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). |
boolean |
isVersionStrict()
Gets whether properties that do not support the target version will be excluded from the written vCard. |
void |
registerScribe(VCardPropertyScribe<? extends VCardProperty> scribe)
Registers a property scribe. |
void |
setAddProdId(boolean addProdId)
Sets whether or not to add a "PRODID" property to each vCard, saying that the vCard was generated by this library. |
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 |
setScribeIndex(ScribeIndex index)
Sets the scribe index. |
void |
setTargetVersion(VCardVersion targetVersion)
Sets the version that the vCards should adhere to. |
void |
setVersionStrict(boolean versionStrict)
Sets whether properties that do not support the target version will be excluded from the written vCard. |
void |
write(VCard vcard)
Writes a vCard to the stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VCardWriter(OutputStream out)
out
- the output stream to write the vCard topublic VCardWriter(OutputStream out, VCardVersion targetVersion)
out
- the output stream to write the vCard totargetVersion
- the version that the vCards should conform to (if
set to "4.0", vCards will be written in UTF-8 encoding)public VCardWriter(OutputStream out, VCardVersion targetVersion, FoldingScheme foldingScheme, String newline)
out
- the output stream to write the vCard totargetVersion
- the version that the vCards should conform to (if
set to "4.0", vCards will be written in UTF-8 encoding)foldingScheme
- the folding scheme to use or null not to fold at allnewline
- the newline sequence to usepublic VCardWriter(File file) throws IOException
file
- the file to write the vCard to
IOException
- if there's a problem opening the filepublic VCardWriter(File file, boolean append) throws IOException
file
- the file to write the vCard toappend
- true to append to the end of the file, false to overwrite
it
IOException
- if there's a problem opening the filepublic VCardWriter(File file, boolean append, VCardVersion targetVersion) throws IOException
file
- the file to write the vCard toappend
- true to append to the end of the file, false to overwrite
ittargetVersion
- the version that the vCards should conform to (if
set to "4.0", vCards will be written in UTF-8 encoding)
IOException
- if there's a problem opening the filepublic VCardWriter(File file, boolean append, VCardVersion targetVersion, FoldingScheme foldingScheme, String newline) throws IOException
file
- the file to write the vCard toappend
- true to append to the end of the file, false to overwrite
ittargetVersion
- the version that the vCards should conform to (if
set to "4.0", vCards will be written in UTF-8 encoding)foldingScheme
- the folding scheme to use or null not to fold at allnewline
- the newline sequence to use
IOException
- if there's a problem opening the filepublic VCardWriter(Writer writer)
writer
- the writer to write the vCard topublic VCardWriter(Writer writer, VCardVersion targetVersion)
writer
- the writer to write the vCard totargetVersion
- the version that the vCards should conform topublic VCardWriter(Writer writer, VCardVersion targetVersion, FoldingScheme foldingScheme, String newline)
writer
- the writer to write the vCard totargetVersion
- the version that the vCards should conform tofoldingScheme
- the folding scheme to use or null not to fold at allnewline
- the newline sequence to useMethod Detail |
---|
public VCardVersion getTargetVersion()
public void setTargetVersion(VCardVersion targetVersion)
targetVersion
- the vCard versionpublic boolean isAddProdId()
public void setAddProdId(boolean addProdId)
addProdId
- true to add this property, false not to (defaults to
true)public boolean isVersionStrict()
public void setVersionStrict(boolean versionStrict)
versionStrict
- true to exclude properties that do not support the
target version, false to include them anyway (defaults to true)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.
VCardRawWriter.isCaretEncodingEnabled()
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.
enable
- true to use circumflex accent encoding, false not toVCardRawWriter.setCaretEncodingEnabled(boolean)
public String getNewline()
public FoldingScheme getFoldingScheme()
public void registerScribe(VCardPropertyScribe<? extends VCardProperty> scribe)
Registers a property scribe. This is the same as calling:
getScribeIndex().register(scribe)
scribe
- the scribe to registerpublic ScribeIndex getScribeIndex()
public void setScribeIndex(ScribeIndex index)
index
- the scribe indexpublic void write(VCard vcard) throws IOException
vcard
- the vCard to write
IOException
- if there's a problem writing to the output stream
IllegalArgumentException
- if a scribe hasn't been registered for a
custom property class (see: registerScribe(ezvcard.io.scribe.VCardPropertyScribe extends ezvcard.property.VCardProperty>)
)public void flush() throws IOException
Writer
object.
flush
in interface Flushable
IOException
- if there's a problem flushing the writerpublic void close() throws IOException
Writer
object.
close
in interface Closeable
IOException
- if there's a problem closing the writer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |