olg.csv.bean.loader.parser
Class AbstractParserLoader

Package class diagram package AbstractParserLoader
java.lang.Object
  extended by olg.csv.bean.loader.parser.AbstractParserLoader
Direct Known Subclasses:
CustomParserLoader, DateParserLoader

public abstract class AbstractParserLoader
extends Object

Class dedicated to load a parser from an XML element conformed to XML schema ParserType specification. Each concret class shall have the responsibility to load a concrete AbstractLoader class.

Class based on Chain of responsability pattern used to chain concret Filter Loaders.

See Also:
AbstractParser

Field Summary
private static AbstractParserLoader instance
          Singleton responsible of parsers loading.
protected  AbstractParserLoader successor
          ParserLoader successor as describe in Chain of responsability pattern.
protected  String xPathExpression
          This Xpath expression allows to identify xml node which describe the corresponding concret parser under parser Type node.
 
Constructor Summary
protected AbstractParserLoader(String xPathExpression, AbstractParserLoader successor)
           
 
Method Summary
protected abstract
<T> AbstractParser<T>
getConcreteParser(Class<T> clazz, Element node)
          Returns a concret parser this concret loader has the responsablity to create.
static AbstractParserLoader getInstance()
          Returns Singleton responsible of parsers loading.
<T> AbstractParser<T>
getParser(Class<T> clazz, Element element)
          Returns a concret parser identified from the given XML Element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static AbstractParserLoader instance
Singleton responsible of parsers loading.


xPathExpression

protected String xPathExpression
This Xpath expression allows to identify xml node which describe the corresponding concret parser under parser Type node.


successor

protected AbstractParserLoader successor
ParserLoader successor as describe in Chain of responsability pattern. Each parserLoader has the responsability of only one parser type.

Constructor Detail

AbstractParserLoader

protected AbstractParserLoader(String xPathExpression,
                               AbstractParserLoader successor)
Parameters:
xPathExpression - the XPath expression that allows to identify the concret parser under the XML FilterType node
successor - following concret loader in the chain of responsability
Method Detail

getInstance

public static AbstractParserLoader getInstance()
Returns Singleton responsible of parsers loading. This is this instance you have to be used to load every type of parser from XML element conformed to XML Schema ParserType specification.

Returns:
the parser loader instance.

getParser

public final <T> AbstractParser<T> getParser(Class<T> clazz,
                                             Element element)
                                  throws XPathExpressionException,
                                         LoadException
Returns a concret parser identified from the given XML Element.

Type Parameters:
T - the type the parser treats.
Parameters:
clazz - the class that the parser should return
element - XML node corresponding to correspondant to XML ParserType as described in our XML schema
Returns:
a concret parser or null if the given element doesn't match concret parser this loader has responsability and doesn't match any successor
Throws:
XPathExpressionException - on invalid XPathExpression
LoadException - on Error occurs during loading

getConcreteParser

protected abstract <T> AbstractParser<T> getConcreteParser(Class<T> clazz,
                                                           Element node)
                                                throws XPathExpressionException,
                                                       LoadException
Returns a concret parser this concret loader has the responsablity to create.

Type Parameters:
T - the type the parser treats.
Parameters:
clazz - the class that the parser should return
node - XML Element corresponding to the XPath expression from which load corresponding parser
Returns:
the concret parser. null if the given node doesn't match the type this loader should return
Throws:
XPathExpressionException - on invalid XPathExpression
LoadException - if Error occurs during loading
See Also:
xPathExpression


Copyright © 2014. All Rights Reserved.