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 a
ProductId property will be added to each vCard
that marks it as having been 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 to add a
ProductId property to each vCard that marks
it as having been generated by this library. |
void |
setScribeIndex(ScribeIndex index)
Sets the scribe index.
|
void |
setVersionStrict(boolean versionStrict)
Sets whether to exclude properties that do not support the target version
from the written vCard.
|
void |
write(VCard vcard)
Writes a vCard to the stream.
|
protected ScribeIndex index
protected boolean addProdId
protected boolean versionStrict
public StreamWriter()
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()
ProductId
property will be added to each vCard
that marks it as having been generated by this library. For 2.1 vCards,
the extended property "X-PRODID" will be added, since ProductId
is not supported by that version.public void setAddProdId(boolean addProdId)
ProductId
property to each vCard that marks
it as having been generated by this library. For 2.1 vCards, the extended
property "X-PRODID" will be added, since ProductId
is not
supported by that version.addProdId
- true to add the property, false not to (defaults to
true)public boolean isVersionStrict()
public void setVersionStrict(boolean versionStrict)
versionStrict
- true to exclude such properties, false not to
(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 indexCopyright © 2012–2023 Michael Angstadt. All rights reserved.