public abstract class StreamWriter extends Object implements Closeable
Modifier and Type | Field and Description |
---|---|
protected boolean |
addProdId |
protected ScribeIndex |
index |
protected boolean |
versionStrict |
Constructor and Description |
---|
StreamWriter() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
_write(VCard vcard,
List<VCardProperty> properties)
Writes a vCard to the stream.
|
ScribeIndex |
getScribeIndex()
Gets the scribe index.
|
protected abstract VCardVersion |
getTargetVersion()
Gets the version that the next vCard will be written as.
|
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 |
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 |
setScribeIndex(ScribeIndex index)
Sets the scribe index.
|
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.
|
protected ScribeIndex index
protected boolean addProdId
protected boolean versionStrict
public void write(VCard vcard) throws IOException
vcard
- the vCard that is being writtenIOException
- if there's a problem writing to the output streamIllegalArgumentException
- if a scribe hasn't been registered for a
custom property class (see: registerScribe
)protected abstract void _write(VCard vcard, List<VCardProperty> properties) throws IOException
vcard
- the vCard that is being writtenproperties
- the properties to writeIOException
- if there's a problem writing to the output streamprotected abstract VCardVersion getTargetVersion()
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 the
target version, false to include them anyway (defaults to true)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 indexThis software is published under the BSD license. Copyright © 2003-${build.year}, CRIXP AG, Switzerland, All rights reserved. Use is subject to license terms.