Package org.keycloak.saml.common.parsers
Class AbstractStaxParser<T,E>
java.lang.Object
org.keycloak.saml.common.parsers.AbstractStaxParser<T,E>
- Type Parameters:
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 enum
- All Implemented Interfaces:
StaxParser
- Direct Known Subclasses:
AbstractStaxSamlAssertionParser
,AbstractStaxSamlMetadataParser
,AbstractStaxSamlProtocolParser
,AbstractStaxXmlDSigParser
,AnyDomParser
Simple support for STaX type of parsing. Parses single element and allows processing its direct children.
- Author:
- hmlnarik
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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 theStartElement
Postcondition: Current event is theStartElement
or theEndElement
corresponding to theStartElement
protected boolean
isUnknownElement
(E token) parse
(XMLEventReader xmlEventReader) Parse the event streamprotected abstract void
processSubElement
(XMLEventReader xmlEventReader, T target, E element, StartElement elementDetail) Processes the subelement of the element processed ininstantiateElement(javax.xml.stream.XMLEventReader, javax.xml.stream.events.StartElement)
method.
Precondition: Current event: Last before theStartElement
corresponding to the processed subelement, i.e.protected void
validateStartElement
(StartElement startElement) Validates that the given startElement has the expected properties (namelyQName
matches the expected one).
-
Field Details
-
LOGGER
-
expectedStartElement
-
-
Constructor Details
-
AbstractStaxParser
-
-
Method Details
-
parse
Description copied from interface:StaxParser
Parse the event stream- Specified by:
parse
in interfaceStaxParser
- Returns:
- Throws:
ParsingException
-
validateStartElement
Validates that the given startElement has the expected properties (namelyQName
matches the expected one).- Parameters:
startElement
-
-
isUnknownElement
-
getElementFromName
-
instantiateElement
protected abstract T instantiateElement(XMLEventReader xmlEventReader, StartElement element) throws ParsingException Instantiates the target Java class representing the current element.
Precondition: Current event is theStartElement
Postcondition: Current event is theStartElement
or theEndElement
corresponding to theStartElement
- Parameters:
xmlEventReader
-element
- The XML event that was just read from thexmlEventReader
- Returns:
- Throws:
ParsingException
-
processSubElement
protected abstract void processSubElement(XMLEventReader xmlEventReader, T target, E element, StartElement elementDetail) throws ParsingException Processes the subelement of the element processed ininstantiateElement(javax.xml.stream.XMLEventReader, javax.xml.stream.events.StartElement)
method.
Precondition: Current event: Last before theStartElement
corresponding to the processed subelement, i.e. event obtained byIterator.next()
is theStartElement
of the subelement being processed
Postcondition: Event obtained byIterator.next()
is either the sameStartElement
(i.e. no change in position which causes this subelement to be skipped), the correspondingEndElement
, or the event after the correspondingEndElement
.Note that in case of recursive nesting the same element, the corresponding end element MUST be consumed in this method.
- Parameters:
xmlEventReader
-target
- Target object (the one created by theinstantiateElement(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 thexmlEventReader
- Throws:
ParsingException
-