Class AbstractStaxParser<T>
java.lang.Object
com.adaptris.adapter.edistream.parser.AbstractParser
com.adaptris.adapter.edistream.parser.xml.AbstractStaxParser<T>
- Type Parameters:
T
- - Type of component parser to use - grammar or edi xml based
- Direct Known Subclasses:
GrammarParser
,XMLEDIParser
Top level abstract Stax (streaming api for xml) parser. Common parent for both Grammar XML and Edi XML parsing. This class implements a
Stax pattern recommendation of delegating the parsing of given tags to a dedicated parser. Note: To get console debugging output for the
stax parsing, set the system flag: edi.parser.stax.debug
-
Field Summary
Modifier and TypeFieldDescriptionprotected XMLInputFactory
protected IXMLTagnames
protected boolean
Fields inherited from class com.adaptris.adapter.edistream.parser.AbstractParser
eventListeners
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Ensures that the parser has been correctly initialized to ensure that the parsing process is successful.protected XMLStreamReader
Creates Stax reader instance from the given input streamprotected XMLStreamReader
Creates a stax reader instance from the given readerparse
(InputStream in) Main parse method.Overloaded method that takes in a Reader that is configured with a given charsetabstract EdiElement
parse
(XMLStreamReader staxXmlReader) Main method to parse the input xml document from the given stax readervoid
registerParser
(String xmlTagname, T componentParser) Register a parser for the processing of a given xml element.void
setFactory
(XMLInputFactory factory) Sets the XML factory from which the stax parser can be createdvoid
setTagnames
(IXMLTagnames tagnames) Sets the XML tagnames that are to be parsed in the document.void
setUseDebugStax
(boolean useDebugStax) Creates an instance of XMLStreamReader that gives stdout log statements to aid debuggingMethods inherited from class com.adaptris.adapter.edistream.parser.AbstractParser
addParsedEventListener, fireElementEndParseEvent, fireElementStartParseEvent, removeParsedEventListener
-
Field Details
-
parserDelegates
-
tagnames
-
factory
-
useDebugStax
protected boolean useDebugStax
-
-
Constructor Details
-
AbstractStaxParser
public AbstractStaxParser()
-
-
Method Details
-
setUseDebugStax
public void setUseDebugStax(boolean useDebugStax) Creates an instance of XMLStreamReader that gives stdout log statements to aid debugging- Parameters:
useDebugStax
-
-
setTagnames
Sets the XML tagnames that are to be parsed in the document.- Parameters:
tagnames
-
-
setFactory
Sets the XML factory from which the stax parser can be created- Parameters:
factory
-
-
checkParserHasBeenInitialized
protected void checkParserHasBeenInitialized()Ensures that the parser has been correctly initialized to ensure that the parsing process is successful. -
registerParser
Register a parser for the processing of a given xml element.- Parameters:
xmlTagname
- - XML tag name to processcomponentParser
- - the specific parsing routine to handle the element
-
parse
public EdiElement parse(InputStream in) throws XMLStreamException, EdiValidationException, EdiMandatoryElementMissingException, EdiFailedToParseSegmentException Main parse method. This parses the gxml file that is to be read in via the supplied InputStream, and returns an object graph representation of it.- Parameters:
in
- - InputStream to read the gxml file.- Returns:
- a new instance of a object graph of EdiElements.
- Throws:
XMLStreamException
- if there is a problem with the xml file.EdiValidationException
- - Inherited exception that must be handled but is not thrown for grammar parsing.InvalidStateException
- if the class has not been initialised properly, hint: use the EdiParserFactory.EdiMandatoryElementMissingException
EdiFailedToParseSegmentException
-
parse
public EdiElement parse(Reader in) throws XMLStreamException, EdiValidationException, EdiMandatoryElementMissingException, EdiFailedToParseSegmentException Overloaded method that takes in a Reader that is configured with a given charset- Parameters:
in
-- Throws:
XMLStreamException
EdiValidationException
EdiMandatoryElementMissingException
EdiFailedToParseSegmentException
-
createXMLStreamReader
Creates Stax reader instance from the given input stream- Parameters:
in
-- Throws:
XMLStreamException
-
createXMLStreamReader
Creates a stax reader instance from the given reader- Parameters:
in
- - Reader configured with appropriate charset- Throws:
XMLStreamException
-
parse
public abstract EdiElement parse(XMLStreamReader staxXmlReader) throws XMLStreamException, EdiValidationException, EdiMandatoryElementMissingException, EdiFailedToParseSegmentException Main method to parse the input xml document from the given stax reader- Parameters:
staxXmlReader
-- Throws:
XMLStreamException
EdiValidationException
EdiMandatoryElementMissingException
EdiFailedToParseSegmentException
-