|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectezvcard.io.json.JCardWriter
public class JCardWriter
Writes VCard
objects to a JSON data stream (jCard format).
Example:
VCard vcard1 = ... VCard vcard2 = ... File file = new File("vcard.json"); JCardWriter jcardWriter = new JCardWriter(file); jcardWriter.write(vcard1); jcardWriter.write(vcard2); jcardWriter.close(); //"close()" must be called in order to terminate the JSON object
Constructor Summary | |
---|---|
JCardWriter(File file)
Creates a writer that writes jCards to a file (UTF-8 encoding will be used). |
|
JCardWriter(File file,
boolean wrapInArray)
Creates a writer that writes jCards to a file (UTF-8 encoding will be used). |
|
JCardWriter(OutputStream out)
Creates a writer that writes jCards to an output stream (UTF-8 encoding will be used). |
|
JCardWriter(OutputStream out,
boolean wrapInArray)
Creates a writer that writes jCards to an output stream (UTF-8 encoding will be used). |
|
JCardWriter(Writer writer)
Creates a writer that writes jCards to a writer. |
|
JCardWriter(Writer writer,
boolean wrapInArray)
Creates a writer that writes jCards to a writer. |
Method Summary | |
---|---|
void |
close()
Ends the jCard data stream and closes the underlying writer. |
void |
closeJsonStream()
Ends the jCard data stream, but does not close the underlying writer. |
void |
flush()
Flushes the jCard data stream. |
ScribeIndex |
getScribeIndex()
Gets the scribe index. |
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 |
isIndent()
Gets whether or not the JSON will be pretty-printed. |
boolean |
isVersionStrict()
Gets whether properties that do not support jCard (vCard version 4.0) 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 |
setIndent(boolean indent)
Sets whether or not to pretty-print the JSON. |
void |
setScribeIndex(ScribeIndex index)
Sets the scribe index. |
void |
setVersionStrict(boolean versionStrict)
Sets whether properties that do not support jCard (vCard version 4.0) 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 JCardWriter(OutputStream out)
out
- the output stream to write the vCard topublic JCardWriter(OutputStream out, boolean wrapInArray)
out
- the output stream to write the vCard towrapInArray
- true to enclose all written vCards in a JSON array,
false not topublic JCardWriter(File file) throws IOException
file
- the file to write the vCard to
IOException
- if there's a problem opening the filepublic JCardWriter(File file, boolean wrapInArray) throws IOException
file
- the file to write the vCard towrapInArray
- true to enclose all written vCards in a JSON array,
false not to
IOException
- if there's a problem opening the filepublic JCardWriter(Writer writer)
writer
- the writer to write the vCard topublic JCardWriter(Writer writer, boolean wrapInArray)
writer
- the writer to write the vCard towrapInArray
- true to enclose all written vCards in a JSON array,
false not toMethod Detail |
---|
public 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 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
jCard, false to include them anyway (defaults to true)public boolean isIndent()
public void setIndent(boolean indent)
indent
- true to pretty-print it, false not to (defaults to false)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 flush() throws IOException
flush
in interface Flushable
IOException
- if there's a problem flushing the streampublic void closeJsonStream() throws IOException
IOException
- if there's a problem closing the streampublic void close() throws IOException
close
in interface Closeable
IOException
- if there's a problem closing the stream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |