de.dfki.util.xmlrpc.conversion
Class XmlRpcBeanConverter

java.lang.Object
  extended by de.dfki.util.xmlrpc.conversion.XmlRpcBeanConverter
All Implemented Interfaces:
ParameterConverter<java.lang.Object,java.util.Map<java.lang.String,java.lang.Object>>

public class XmlRpcBeanConverter
extends java.lang.Object
implements ParameterConverter<java.lang.Object,java.util.Map<java.lang.String,java.lang.Object>>

Idea: Use this class to automatically turn your instance into a map representation using the bean getters. Create a bean instance vice versa by using bean setters.

Author:
lauer
See Also:
XmlRpcBean

Constructor Summary
XmlRpcBeanConverter(java.lang.Class<?> targetClass)
           
 
Method Summary
 java.lang.Object createFrom(java.util.Map<java.lang.String,java.lang.Object> xmlRepresentation)
          Creates an instance of parameter type T.
protected  java.util.Collection<java.beans.PropertyDescriptor> filterProperties(java.beans.PropertyDescriptor[] sourceDescriptors)
           
protected  java.lang.reflect.Constructor<?> getBeanConstructor()
           
 java.beans.BeanInfo getBeanInfo()
           
 java.beans.PropertyDescriptor getDescriptorForProperty(java.lang.String propertyName)
           
 java.util.Collection<java.beans.PropertyDescriptor> getPropertyDescriptors()
           
 XmlRpc.Type getXmlRpcRepresentationType()
           
static java.util.logging.Logger log()
           
 java.util.Map<java.lang.String,java.lang.Object> toXmlRpc(java.lang.Object param)
          Transforms a parameter into it's XML-RPC representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlRpcBeanConverter

public XmlRpcBeanConverter(java.lang.Class<?> targetClass)
                    throws TypeConversionException
Parameters:
targetClass - Bean with a getter and a setter for each property. Public zero-arg constructor for instance creation.
Throws:
java.beans.IntrospectionException
TypeConversionException, - if there are no bean properties available in this class.
TypeConversionException
Method Detail

log

public static java.util.logging.Logger log()

getXmlRpcRepresentationType

public XmlRpc.Type getXmlRpcRepresentationType()
Specified by:
getXmlRpcRepresentationType in interface ParameterConverter<java.lang.Object,java.util.Map<java.lang.String,java.lang.Object>>
Returns:
The XML-RPC type the converter uses as XML-RPC representation.

createFrom

public java.lang.Object createFrom(java.util.Map<java.lang.String,java.lang.Object> xmlRepresentation)
                            throws TypeConversionException
Description copied from interface: ParameterConverter
Creates an instance of parameter type T.

Specified by:
createFrom in interface ParameterConverter<java.lang.Object,java.util.Map<java.lang.String,java.lang.Object>>
Parameters:
xmlRepresentation - The structure transfered via XML-RPC.
Returns:
The new instance. May also be null.
Throws:
TypeConversionException

toXmlRpc

public java.util.Map<java.lang.String,java.lang.Object> toXmlRpc(java.lang.Object param)
                                                          throws TypeConversionException
Description copied from interface: ParameterConverter
Transforms a parameter into it's XML-RPC representation.

Specified by:
toXmlRpc in interface ParameterConverter<java.lang.Object,java.util.Map<java.lang.String,java.lang.Object>>
Parameters:
param - The parameter to convert. May be null.
Returns:
A XML-RPC representation (must not be null).
Throws:
TypeConversionException

getBeanConstructor

protected java.lang.reflect.Constructor<?> getBeanConstructor()
                                                       throws TypeConversionException
Returns:
The public zero-argument constructor of the bean class.
Throws:
TypeConversionException - Denotes errors while getting the constructor (e.g., not available, not public, ...)

getPropertyDescriptors

public java.util.Collection<java.beans.PropertyDescriptor> getPropertyDescriptors()

getDescriptorForProperty

public java.beans.PropertyDescriptor getDescriptorForProperty(java.lang.String propertyName)

filterProperties

protected java.util.Collection<java.beans.PropertyDescriptor> filterProperties(java.beans.PropertyDescriptor[] sourceDescriptors)

getBeanInfo

public java.beans.BeanInfo getBeanInfo()
                                throws java.beans.IntrospectionException
Throws:
java.beans.IntrospectionException


Copyright © 2012. All Rights Reserved.