biweekly.io
Class ICalMarshallerRegistrar

java.lang.Object
  extended by biweekly.io.ICalMarshallerRegistrar

public class ICalMarshallerRegistrar
extends Object

Manages a listing of component and property marshallers. This is useful for injecting the marshallers of any experimental components or 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 registrar
 ICalMarshallerRegistrar registrar = new ICalMarshallerRegistrar();
 registrar.register(new CustomPropertyMarshaller());
 registrar.register(new AnotherCustomPropertyMarshaller());
 registrar.register(new CustomComponentMarshaller());
 
 //inject into a reader class
 ICalReader textReader = new ICalReader(...);
 textReader.setRegistrar(registrar);
 List<ICalendar> icals = new ArrayList<ICalendar>();
 ICalendar ical;
 while ((ical = textReader.readNext()) != null){
   icals.add(ical);
 }
 
 //inject the same instance in another reader/writer class
 JCalWriter writer = new JCalWriter(...);
 writer.setRegistrar(registrar);
 for (ICalendar ical : icals){
   writer.write(ical);
 }
 

Author:
Michael Angstadt

Constructor Summary
ICalMarshallerRegistrar()
           
 
Method Summary
 ICalComponentMarshaller<? extends ICalComponent> getComponentMarshaller(Class<? extends ICalComponent> clazz)
          Gets a component marshaller by class.
 ICalComponentMarshaller<? extends ICalComponent> getComponentMarshaller(ICalComponent component)
          Gets the appropriate component marshaller for a given component instance.
 ICalComponentMarshaller<? extends ICalComponent> getComponentMarshaller(String componentName)
          Gets a component marshaller by name.
static ICalendarMarshaller getICalendarMarshaller()
          Convenience method for getting the marshaller of the root iCalendar component ("VCALENDAR").
 ICalPropertyMarshaller<? extends ICalProperty> getPropertyMarshaller(Class<? extends ICalProperty> clazz)
          Gets a property marshaller by class.
 ICalPropertyMarshaller<? extends ICalProperty> getPropertyMarshaller(ICalProperty property)
          Gets the appropriate property marshaller for a given property instance.
 ICalPropertyMarshaller<? extends ICalProperty> getPropertyMarshaller(QName qname)
          Gets a property marshaller by XML local name and namespace.
 ICalPropertyMarshaller<? extends ICalProperty> getPropertyMarshaller(String propertyName)
          Gets a property marshaller by name.
 void register(ICalComponentMarshaller<? extends ICalComponent> marshaller)
          Registers a component marshaller.
 void register(ICalPropertyMarshaller<? extends ICalProperty> marshaller)
          Registers a property marshaller.
 void unregister(ICalComponentMarshaller<? extends ICalComponent> marshaller)
          Unregisters a component marshaller.
 void unregister(ICalPropertyMarshaller<? extends ICalProperty> marshaller)
          Unregisters a property marshaller
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ICalMarshallerRegistrar

public ICalMarshallerRegistrar()
Method Detail

getComponentMarshaller

public ICalComponentMarshaller<? extends ICalComponent> getComponentMarshaller(String componentName)
Gets a component marshaller by name.

Parameters:
componentName - the component name (e.g. "VEVENT")
Returns:
the component marshaller or a RawComponentMarshaller if not found

getPropertyMarshaller

public ICalPropertyMarshaller<? extends ICalProperty> getPropertyMarshaller(String propertyName)
Gets a property marshaller by name.

Parameters:
propertyName - the property name (e.g. "VERSION")
Returns:
the property marshaller or a RawPropertyMarshaller if not found

getComponentMarshaller

public ICalComponentMarshaller<? extends ICalComponent> getComponentMarshaller(Class<? extends ICalComponent> clazz)
Gets a component marshaller by class.

Parameters:
clazz - the component class
Returns:
the component marshaller or null if not found

getPropertyMarshaller

public ICalPropertyMarshaller<? extends ICalProperty> getPropertyMarshaller(Class<? extends ICalProperty> clazz)
Gets a property marshaller by class.

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

getComponentMarshaller

public ICalComponentMarshaller<? extends ICalComponent> getComponentMarshaller(ICalComponent component)
Gets the appropriate component marshaller for a given component instance.

Parameters:
component - the component instance
Returns:
the component marshaller or null if not found

getPropertyMarshaller

public ICalPropertyMarshaller<? extends ICalProperty> getPropertyMarshaller(ICalProperty property)
Gets the appropriate property marshaller for a given property instance.

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

getPropertyMarshaller

public ICalPropertyMarshaller<? extends ICalProperty> getPropertyMarshaller(QName qname)
Gets a property marshaller by XML local name and namespace.

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

register

public void register(ICalComponentMarshaller<? extends ICalComponent> marshaller)
Registers a component marshaller.

Parameters:
marshaller - the marshaller to register

register

public void register(ICalPropertyMarshaller<? extends ICalProperty> marshaller)
Registers a property marshaller.

Parameters:
marshaller - the marshaller to register

unregister

public void unregister(ICalComponentMarshaller<? extends ICalComponent> marshaller)
Unregisters a component marshaller.

Parameters:
marshaller - the marshaller to unregister

unregister

public void unregister(ICalPropertyMarshaller<? extends ICalProperty> marshaller)
Unregisters a property marshaller

Parameters:
marshaller - the marshaller to unregister

getICalendarMarshaller

public static ICalendarMarshaller getICalendarMarshaller()
Convenience method for getting the marshaller of the root iCalendar component ("VCALENDAR").

Returns:
the marshaller


Copyright © 2013 Michael Angstadt. All Rights Reserved.