Package com.bc.ceres.binding.dom
Class DefaultDomConverter
- java.lang.Object
-
- com.bc.ceres.binding.dom.DefaultDomConverter
-
- All Implemented Interfaces:
DomConverter
public class DefaultDomConverter extends Object implements DomConverter
-
-
Constructor Summary
Constructors Constructor Description DefaultDomConverter(Class<?> valueType)DefaultDomConverter(Class<?> valueType, PropertyDescriptorFactory propertyDescriptorFactory)DefaultDomConverter(Class<?> valueType, PropertyDescriptorFactory propertyDescriptorFactory, PropertySetDescriptor propertySetDescriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectconvertDomToValue(DomElement parentElement, Object value)Converts a DOM to a (complex) value of the type returned byDomConverter.getValueType().voidconvertValueToDom(Object value, DomElement parentElement)Converts a (complex) value of the type returned byDomConverter.getValueType()to its DOM representation which may be further converted to XML.protected DomConvertercreateChildDomConverter(Class<?> valueType, PropertyDescriptorFactory propertyDescriptorFactory, PropertySetDescriptor propertySetDescriptor)Called to create a new DOM converter for a (child) property.protected ObjectcreateValueInstance(Class<?> type)protected DomConverterfindChildDomConverter(PropertyDescriptor descriptor)Called to find a "local" DOM converter for a (child) property.PropertyDescriptorFactorygetPropertyDescriptorFactory()protected PropertySetgetPropertySet(Object value)PropertySetDescriptorgetPropertySetDescriptor()Class<?>getValueType()Gets the value type, which may be abstract.
-
-
-
Constructor Detail
-
DefaultDomConverter
public DefaultDomConverter(Class<?> valueType)
-
DefaultDomConverter
public DefaultDomConverter(Class<?> valueType, PropertyDescriptorFactory propertyDescriptorFactory)
-
DefaultDomConverter
public DefaultDomConverter(Class<?> valueType, PropertyDescriptorFactory propertyDescriptorFactory, PropertySetDescriptor propertySetDescriptor)
-
-
Method Detail
-
getValueType
public Class<?> getValueType()
Gets the value type, which may be abstract.- Specified by:
getValueTypein interfaceDomConverter- Returns:
- The value type.
-
getPropertyDescriptorFactory
public PropertyDescriptorFactory getPropertyDescriptorFactory()
-
getPropertySetDescriptor
public PropertySetDescriptor getPropertySetDescriptor()
-
convertValueToDom
public void convertValueToDom(Object value, DomElement parentElement) throws ConversionException
Converts a (complex) value of the type returned byDomConverter.getValueType()to its DOM representation which may be further converted to XML. The givenvaluecan be safely cast to the type returned byDomConverter.getValueType().- Specified by:
convertValueToDomin interfaceDomConverter- Parameters:
value- The value to be converted to the DOM. Nevernull.parentElement- The parent DOM element, which receives the DOM representation of the value.- Throws:
ConversionException- If the conversion fails (e.g. not implemented).
-
convertDomToValue
public Object convertDomToValue(DomElement parentElement, Object value) throws ConversionException, ValidationException
Converts a DOM to a (complex) value of the type returned byDomConverter.getValueType().- Specified by:
convertDomToValuein interfaceDomConverter- Parameters:
parentElement- The parent DOM element.value- The value which receives the DOM representation of the value ornull. Ifvalueisnull, the method is responsible for the creation of a new instance and its configuration using the DOM.- Returns:
- The converted value, never
null. - Throws:
ConversionException- If the conversion fails.ValidationException- If the converted value is invalid.
-
getPropertySet
protected PropertySet getPropertySet(Object value)
-
createChildDomConverter
protected DomConverter createChildDomConverter(Class<?> valueType, PropertyDescriptorFactory propertyDescriptorFactory, PropertySetDescriptor propertySetDescriptor)
Called to create a new DOM converter for a (child) property. May be overridden by subclasses. The default implementation returns an instance of this class.- Parameters:
valueType- The value typepropertyDescriptorFactory- The property descriptor factory.propertySetDescriptor- The property set descriptor.- Returns:
- a "local" DOM converter or
null.
-
findChildDomConverter
protected DomConverter findChildDomConverter(PropertyDescriptor descriptor)
Called to find a "local" DOM converter for a (child) property. May be overridden by subclasses. The default implementation returnsnull.- Parameters:
descriptor- The property descriptor- Returns:
- a "local" DOM converter or
null.
-
-