olg.csv.bean.loader
Class CustomLoader

Package class diagram package CustomLoader
java.lang.Object
  extended by olg.csv.bean.loader.CustomLoader

public final class CustomLoader
extends Object

Class specialized in bean loading from an XML element conformed to XML schema CustomType specification.


Constructor Summary
private CustomLoader()
          private constructor to prevent its instantiation.
 
Method Summary
static Object getBean(Element node)
          Returns an instance of a bean corresponding to XML node parameter.
private static
<B,T> void
setProperty(AbstractParser<T> parser, String propertyName, B bean, String value)
          Set a property on a bean.
private static
<B> void
setProperty(Element node, B bean)
          Sets a property on a bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomLoader

private CustomLoader()
private constructor to prevent its instantiation.

Method Detail

getBean

public static Object getBean(Element node)
                      throws XPathExpressionException,
                             LoadException
Returns an instance of a bean corresponding to XML node parameter.

Parameters:
node - CustomType node as described in XML schema.
Returns:
a new instance
Throws:
XPathExpressionException - on invalid XPathExpression
LoadException - if bean class not found or instanciation not possible. In case of applying properties, a LoadException is thrown when property class is not found or setter is not found
XPathExpressionException - on invalid XPathExpression

setProperty

private static <B> void setProperty(Element node,
                                    B bean)
                         throws XPathExpressionException,
                                LoadException
Sets a property on a bean.

Type Parameters:
B - the type of the bean.
Parameters:
node - PropertyType Node as described in XML Schema that define the property to set.
bean - bean that we want to set the property.
Throws:
XPathExpressionException - on invalid XPathExpression
LoadException - if property class not found or setter not found

setProperty

private static <B,T> void setProperty(AbstractParser<T> parser,
                                      String propertyName,
                                      B bean,
                                      String value)
                         throws LoadException
Set a property on a bean.

Type Parameters:
B - the type of the bean
T - the type of the property
Parameters:
parser - the parser to use to parse the value
propertyName - the name of the property
bean - the bean
value - the value
Throws:
LoadException - if no property setter exists or error occurs on setter invocation.


Copyright © 2014. All Rights Reserved.