Class AbstractStaxBuilder
- java.lang.Object
-
- org.hibernate.validator.internal.xml.AbstractStaxBuilder
-
public abstract class AbstractStaxBuilder extends Object
Other Stax xml builders should extend from this one. Provides some common functionality like reading an attribute value or value of a simple tag.- Author:
- Marko Bekhta
-
-
Constructor Summary
Constructors Constructor Description AbstractStaxBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleanaccept(XMLEvent xmlEvent)Checks if the givenXMLEventis aStartElementand if the corresponding xml tag can be processed based on a tag name.protected abstract voidadd(XMLEventReader xmlEventReader, XMLEvent xmlEvent)protected abstract StringgetAcceptableQName()booleanprocess(XMLEventReader xmlEventReader, XMLEvent xmlEvent)protected Optional<String>readAttribute(StartElement startElement, QName qName)Reads a value of an attribute of a given element.protected StringreadSingleElement(XMLEventReader xmlEventReader)Reads a value between a simple tag element.
-
-
-
Method Detail
-
getAcceptableQName
protected abstract String getAcceptableQName()
-
accept
protected boolean accept(XMLEvent xmlEvent)
Checks if the givenXMLEventis aStartElementand if the corresponding xml tag can be processed based on a tag name.- Parameters:
xmlEvent- an event to check- Returns:
trueif corresponding event can be processed by current builder,falseotherwise
-
process
public boolean process(XMLEventReader xmlEventReader, XMLEvent xmlEvent)
-
add
protected abstract void add(XMLEventReader xmlEventReader, XMLEvent xmlEvent) throws XMLStreamException
- Throws:
XMLStreamException
-
readSingleElement
protected String readSingleElement(XMLEventReader xmlEventReader) throws XMLStreamException
Reads a value between a simple tag element. In case of a<someTag>some-value</someTag>will returnsome-valueas a string.- Parameters:
xmlEventReader- a currentXMLEventReader- Returns:
- a value of a current xml tag as a string
- Throws:
XMLStreamException
-
readAttribute
protected Optional<String> readAttribute(StartElement startElement, QName qName)
Reads a value of an attribute of a given element.- Parameters:
startElement- an element to get an attribute fromqName- aQNameof an attribute to read- Returns:
- a value of an attribute if it is present,
Optional.empty()otherwise
-
-