public class ScribeIndex extends Object
Manages a listing of component and property scribes. This is useful for injecting the scribes of any experimental components or properties you have defined into a reader or writer object. The same ScribeIndex 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()); index.register(new CustomComponentScribe()); //inject into a reader class ICalReader reader = new ICalReader(...); reader.setScribeIndex(index); List<ICalendar> icals = new ArrayList<ICalendar>(); ICalendar ical; while ((ical = reader.readNext()) != null) { icals.add(ical); } //inject the same instance in another reader/writer class JCalWriter writer = new JCalWriter(...); writer.setScribeIndex(index); for (ICalendar ical : icals) { writer.write(ical); }
Constructor and Description |
---|
ScribeIndex() |
Modifier and Type | Method and Description |
---|---|
ICalComponentScribe<? extends ICalComponent> |
getComponentScribe(Class<? extends ICalComponent> clazz)
Gets a component scribe by class.
|
ICalComponentScribe<? extends ICalComponent> |
getComponentScribe(ICalComponent component)
Gets the appropriate component scribe for a given component instance.
|
ICalComponentScribe<? extends ICalComponent> |
getComponentScribe(String componentName,
ICalVersion version)
Gets a component scribe by name.
|
static ICalendarScribe |
getICalendarScribe()
Convenience method for getting the scribe of the root iCalendar component
("VCALENDAR").
|
ICalPropertyScribe<? extends ICalProperty> |
getPropertyScribe(Class<? extends ICalProperty> clazz)
Gets a property scribe by class.
|
ICalPropertyScribe<? extends ICalProperty> |
getPropertyScribe(ICalProperty property)
Gets the appropriate property scribe for a given property instance.
|
ICalPropertyScribe<? extends ICalProperty> |
getPropertyScribe(QName qname)
Gets a property scribe by XML local name and namespace.
|
ICalPropertyScribe<? extends ICalProperty> |
getPropertyScribe(String propertyName,
ICalVersion version)
Gets a property scribe by name.
|
void |
register(ICalComponentScribe<? extends ICalComponent> scribe)
Registers a component scribe.
|
void |
register(ICalPropertyScribe<? extends ICalProperty> scribe)
Registers a property scribe.
|
void |
unregister(ICalComponentScribe<? extends ICalComponent> scribe)
Unregisters a component scribe.
|
void |
unregister(ICalPropertyScribe<? extends ICalProperty> scribe)
Unregisters a property scribe
|
public ScribeIndex()
public ICalComponentScribe<? extends ICalComponent> getComponentScribe(String componentName, ICalVersion version)
componentName
- the component name (e.g. "VEVENT")version
- the version of the iCalendar object being parsedRawComponentScribe
if not foundpublic ICalPropertyScribe<? extends ICalProperty> getPropertyScribe(String propertyName, ICalVersion version)
propertyName
- the property name (e.g. "UID")version
- the version of the iCalendar object being parsedRawPropertyScribe
if not foundpublic ICalComponentScribe<? extends ICalComponent> getComponentScribe(Class<? extends ICalComponent> clazz)
clazz
- the component classpublic ICalPropertyScribe<? extends ICalProperty> getPropertyScribe(Class<? extends ICalProperty> clazz)
clazz
- the property classpublic ICalComponentScribe<? extends ICalComponent> getComponentScribe(ICalComponent component)
component
- the component instancepublic ICalPropertyScribe<? extends ICalProperty> getPropertyScribe(ICalProperty property)
property
- the property instancepublic ICalPropertyScribe<? extends ICalProperty> getPropertyScribe(QName qname)
qname
- the XML local name and namespaceXmlScribe
if not foundpublic void register(ICalComponentScribe<? extends ICalComponent> scribe)
scribe
- the scribe to registerpublic void register(ICalPropertyScribe<? extends ICalProperty> scribe)
scribe
- the scribe to registerpublic void unregister(ICalComponentScribe<? extends ICalComponent> scribe)
scribe
- the scribe to unregisterpublic void unregister(ICalPropertyScribe<? extends ICalProperty> scribe)
scribe
- the scribe to unregisterpublic static ICalendarScribe getICalendarScribe()
Copyright © 2013–2024 Michael Angstadt. All rights reserved.