T
- Java class that will be result of parsing this elementE
- Type containing all tokens that can be found in subelements of the element parsed by this parser, usually an enumpublic abstract class AbstractStaxParser<T,E> extends Object implements StaxParser
Modifier and Type | Field and Description |
---|---|
protected QName |
expectedStartElement |
protected static PicketLinkLogger |
LOGGER |
Constructor and Description |
---|
AbstractStaxParser(QName expectedStartElement,
E unknownElement) |
Modifier and Type | Method and Description |
---|---|
protected abstract E |
getElementFromName(QName name) |
protected abstract T |
instantiateElement(XMLEventReader xmlEventReader,
StartElement element)
Instantiates the target Java class representing the current element.
Precondition: Current event is the StartElement Postcondition: Current event is the StartElement or the EndElement corresponding to the StartElement |
protected boolean |
isUnknownElement(E token) |
T |
parse(XMLEventReader xmlEventReader)
Parse the event stream
|
protected abstract void |
processSubElement(XMLEventReader xmlEventReader,
T target,
E element,
StartElement elementDetail)
Processes the subelement of the element processed in
instantiateElement(javax.xml.stream.XMLEventReader, javax.xml.stream.events.StartElement) method.Precondition: Current event: Last before the StartElement corresponding to the processed subelement, i.e. |
protected void |
validateStartElement(StartElement startElement)
Validates that the given startElement has the expected properties (namely
QName matches the expected one). |
protected static final PicketLinkLogger LOGGER
protected final QName expectedStartElement
public T parse(XMLEventReader xmlEventReader) throws ParsingException
StaxParser
parse
in interface StaxParser
ParsingException
protected void validateStartElement(StartElement startElement)
QName
matches the expected one).startElement
- protected boolean isUnknownElement(E token)
protected abstract T instantiateElement(XMLEventReader xmlEventReader, StartElement element) throws ParsingException
StartElement
StartElement
or the EndElement
corresponding to the StartElement
xmlEventReader
- element
- The XML event that was just read from the xmlEventReader
ParsingException
protected abstract void processSubElement(XMLEventReader xmlEventReader, T target, E element, StartElement elementDetail) throws ParsingException
instantiateElement(javax.xml.stream.XMLEventReader, javax.xml.stream.events.StartElement)
method.StartElement
corresponding to the processed subelement, i.e.
event obtained by Iterator.next()
is the StartElement
of the subelement being processedIterator.next()
is either
the same StartElement
(i.e. no change in position which causes this subelement to be skipped),
the corresponding EndElement
, or the event after the corresponding EndElement
.
Note that in case of recursive nesting the same element, the corresponding end element MUST be consumed in this method.
xmlEventReader
- target
- Target object (the one created by the instantiateElement(javax.xml.stream.XMLEventReader, javax.xml.stream.events.StartElement)
method.element
- The constant corresponding to the current start element.elementDetail
- The XML event that was just read from the xmlEventReader
ParsingException
Copyright © 2021 JBoss by Red Hat. All rights reserved.