public class ScribeIndex extends Object
Manages a collection of property scribes (marshallers) to use when reading or writing a vCard. The same instance of this object can be re-used across multiple vCard reader/writer objects. This is useful if you have custom scribe classes defined, as it allows you to only define them once instead of each time a vCard reader/writer object is created.
Example:
//init the index
ScribeIndex index = new ScribeIndex();
index.register(new CustomPropertyScribe());
index.register(new AnotherCustomPropertyScribe());
//inject the ScribeIndex into a plain-text vCard reader class and read the vCard data stream
VCardReader vcardReader = new VCardReader(...);
vcardReader.setScribeIndex(index);
List<VCard> vcards = new ArrayList<VCard>();
VCard vcard;
while ((vcards = vcardReader.readNext()) != null){
vcards.add(vcard);
}
vcardReader.close();
//inject the same ScribeIndex instance into a jCard writer and write the vCards
JCardWriter jcardWriter = new JCardWriter(...);
jcardWriter.setScribeIndex(index);
for (VCard vcard : vcards){
jcardWriter.write(vcard);
}
jcardWriter.close();
| Constructor and Description |
|---|
ScribeIndex() |
| Modifier and Type | Method and Description |
|---|---|
VCardPropertyScribe<? extends VCardProperty> |
getPropertyScribe(Class<? extends VCardProperty> clazz)
Gets a property scribe by class.
|
VCardPropertyScribe<? extends VCardProperty> |
getPropertyScribe(QName qname)
Gets a property scribe by XML local name and namespace.
|
VCardPropertyScribe<? extends VCardProperty> |
getPropertyScribe(String propertyName)
Gets a property scribe by name.
|
VCardPropertyScribe<? extends VCardProperty> |
getPropertyScribe(VCardProperty property)
Gets the appropriate property scribe for a given property instance.
|
boolean |
hasPropertyScribe(VCardProperty property)
Determines if a scribe exists for a given property instance.
|
void |
register(VCardPropertyScribe<? extends VCardProperty> scribe)
Registers a property scribe.
|
void |
unregister(VCardPropertyScribe<? extends VCardProperty> scribe)
Unregisters a property scribe.
|
public VCardPropertyScribe<? extends VCardProperty> getPropertyScribe(String propertyName)
propertyName - the property name (case-insensitive, e.g. "FN")public boolean hasPropertyScribe(VCardProperty property)
property - the propertypublic VCardPropertyScribe<? extends VCardProperty> getPropertyScribe(Class<? extends VCardProperty> clazz)
clazz - the property classpublic VCardPropertyScribe<? extends VCardProperty> getPropertyScribe(VCardProperty property)
property - the property instancepublic VCardPropertyScribe<? extends VCardProperty> getPropertyScribe(QName qname)
qname - the XML local name and namespaceXmlScribe if not foundpublic void register(VCardPropertyScribe<? extends VCardProperty> scribe)
scribe - the scribe to registerpublic void unregister(VCardPropertyScribe<? extends VCardProperty> scribe)
scribe - the scribe to unregisterThis software is published under the BSD license. Copyright © 2003-${build.year}, CRIXP AG, Switzerland, All rights reserved. Use is subject to license terms.