ezvcard.io.scribe
Class ScribeIndex

java.lang.Object
  extended by ezvcard.io.scribe.ScribeIndex

public class ScribeIndex
extends Object

Manages a listing of property scribes (marshallers). This is useful for injecting the scribes of any extended properties you have defined into a reader or writer object. The same object instance can be reused and injected into multiple reader/writer classes.

Example:

 //init the index
 ScribeIndex index = new ScribeIndex();
 index.register(new CustomPropertyScribe());
 index.register(new AnotherCustomPropertyScribe());
 
 //inject into a reader class
 VCardReader vcardReader = new VCardReader(...);
 vcardReader.setScribeIndex(index);
 List<VCard> vcards = new ArrayList<VCard>();
 VCard vcards;
 while ((vcards = vcardReader.readNext()) != null){
   vcards.add(vcard);
 }
 
 //inject the same instance in another reader/writer class
 JCardWriter jcardWriter = new JCardWriter(...);
 jcardWriter.setScribeIndex(index);
 for (VCard vcard : vcards){
   jcardWriter.write(vcard);
 }
 jcardWriter.close();
 

Author:
Michael Angstadt

Constructor Summary
ScribeIndex()
           
 
Method Summary
 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.
 void register(VCardPropertyScribe<? extends VCardProperty> scribe)
          Registers a property scribe.
 void unregister(VCardPropertyScribe<? extends VCardProperty> scribe)
          Unregisters a property scribe.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScribeIndex

public ScribeIndex()
Method Detail

getPropertyScribe

public VCardPropertyScribe<? extends VCardProperty> getPropertyScribe(String propertyName)
Gets a property scribe by name.

Parameters:
propertyName - the property name (case-insensitive, e.g. "FN")
Returns:
the property scribe or null if not found

getPropertyScribe

public VCardPropertyScribe<? extends VCardProperty> getPropertyScribe(Class<? extends VCardProperty> clazz)
Gets a property scribe by class.

Parameters:
clazz - the property class
Returns:
the property scribe or null if not found

getPropertyScribe

public VCardPropertyScribe<? extends VCardProperty> getPropertyScribe(VCardProperty property)
Gets the appropriate property scribe for a given property instance.

Parameters:
property - the property instance
Returns:
the property scribe or null if not found

getPropertyScribe

public VCardPropertyScribe<? extends VCardProperty> getPropertyScribe(QName qname)
Gets a property scribe by XML local name and namespace.

Parameters:
qname - the XML local name and namespace
Returns:
the property scribe or a XmlScribe if not found

register

public void register(VCardPropertyScribe<? extends VCardProperty> scribe)
Registers a property scribe.

Parameters:
scribe - the scribe to register

unregister

public void unregister(VCardPropertyScribe<? extends VCardProperty> scribe)
Unregisters a property scribe.

Parameters:
scribe - the scribe to unregister


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.