olg.csv.bean.loader
Class BeanProcessorLoader<T>

Package class diagram package BeanProcessorLoader
java.lang.Object
  extended by olg.csv.bean.loader.BeanProcessorLoader<T>
Type Parameters:
T - the entity
Direct Known Subclasses:
BeanProcessorLoader.RowBeanTransformerLoader

public class BeanProcessorLoader<T>
extends Object

Class dedicated to load BeanProcessor instances from an XML file. XML Root element must be one of the followings :


Nested Class Summary
protected static class BeanProcessorLoader.RowBeanTransformerLoader<T>
          TransformerLoader adaptation in order to manage with beanRowType elements.
 
Constructor Summary
BeanProcessorLoader()
           
 
Method Summary
protected
<I> IPropertyProcessor<I>
getPropertyParser(Element node, Class<I> beanClass)
          Returns new propertyProcessor which have responsability to set a property to the given bean.
protected  BeanProcessor<T> getTransformer(Element element, Class<T> classBean)
          Returns new instance of BeanProcessor from XML node.
protected
<B> Class<?>
identifyFieldClass(String name, String className, Class<B> beanClass)
          Return thes concrete class with which the given field must be setted.
 BeanProcessor<T> load(File file)
          Returns the transformer described in the given XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanProcessorLoader

public BeanProcessorLoader()
Method Detail

load

public BeanProcessor<T> load(File file)
                      throws LoadException
Returns the transformer described in the given XML file.

Parameters:
file - XML file conform to bean-reader xsd declaration. Must be not null.
Returns:
a new transformer
Throws:
LoadException - if an error occurs during loading

identifyFieldClass

protected <B> Class<?> identifyFieldClass(String name,
                                          String className,
                                          Class<B> beanClass)
                               throws LoadException
Return thes concrete class with which the given field must be setted.

Type Parameters:
B - the bean type that has the field
Parameters:
name - the field name
className - a candidate class, if null identify the concrete class from its setter
beanClass - the bean class that has the field
Returns:
the concrete class with which set the field
Throws:
LoadException - if the class is not concrete

getTransformer

protected final BeanProcessor<T> getTransformer(Element element,
                                                Class<T> classBean)
                                         throws LoadException
Returns new instance of BeanProcessor from XML node.

Parameters:
element - XML node conform to beanReaderType declaration or beanRowType declaration
classBean - the bean class the transformer has responsability to return. if null try to load class from class argument of the given XML element
Returns:
the bean processor loaded from the XML node.
Throws:
LoadException - if an error occurs during loading

getPropertyParser

protected <I> IPropertyProcessor<I> getPropertyParser(Element node,
                                                      Class<I> beanClass)
                                           throws XPathExpressionException,
                                                  LoadException
Returns new propertyProcessor which have responsability to set a property to the given bean.

Type Parameters:
I - parent bean type
Parameters:
node - XML node conform to MappingType declaration
beanClass - parent bean class of the property this propertyTransformer set
Returns:
the property processor loaded from the XML node.
Throws:
XPathExpressionException - If an XPath expression cannot be evaluated
LoadException - if an error occurs during loading


Copyright © 2014. All Rights Reserved.