public class StaxParserUtil extends Object
Constructor and Description |
---|
StaxParserUtil() |
Modifier and Type | Method and Description |
---|---|
static XMLEvent |
advance(XMLEventReader xmlEventReader)
Consume the next event
|
static XMLEvent |
bypassElementBlock(XMLEventReader xmlEventReader)
Bypass an entire XML element block.
|
static void |
bypassElementBlock(XMLEventReader xmlEventReader,
QName tag)
Bypass an entire XML element block from startElement to endElement.
|
static void |
bypassElementBlock(XMLEventReader xmlEventReader,
String tag)
Bypass an entire XML element block from startElement to endElement.
|
static String |
getAttributeValue(Attribute attribute)
Given an
Attribute , get its trimmed value |
static String |
getAttributeValue(StartElement startElement,
HasQName attrName)
Get the Attribute value
|
static String |
getAttributeValue(StartElement startElement,
QName attrQName)
Get the Attribute value
|
static String |
getAttributeValue(StartElement startElement,
String tag)
Deprecated.
|
static String |
getAttributeValueRP(Attribute attribute)
Given an
Attribute , get its trimmed value, replacing every occurrence of ${..} by corresponding system property value |
static String |
getAttributeValueRP(StartElement startElement,
HasQName attrName)
Get the Attribute value, replacing every occurrence of ${..} by corresponding system property value
|
static Boolean |
getBooleanAttributeValue(StartElement startElement,
HasQName attrName)
Get the Attribute value
|
static boolean |
getBooleanAttributeValue(StartElement startElement,
String tag)
Deprecated.
|
static boolean |
getBooleanAttributeValue(StartElement startElement,
String tag,
boolean defaultValue)
Deprecated.
|
static Boolean |
getBooleanAttributeValueRP(StartElement startElement,
HasQName attrName)
Get the Attribute value, replacing every occurrence of ${..} by corresponding system property value
|
static Element |
getDOMElement(XMLEventReader xmlEventReader)
Given that the
XMLEventReader is in XMLStreamConstants.START_ELEMENT mode, we parse into a DOM
Element |
static String |
getElementName(EndElement endElement)
Return the name of the end element
|
static String |
getElementName(StartElement startElement)
Return the name of the start element
|
static String |
getElementText(XMLEventReader xmlEventReader)
Get the element text.
|
static String |
getElementTextRP(XMLEventReader xmlEventReader)
Get the element text, replacing every occurrence of ${..} by corresponding system property value
|
static Integer |
getIntegerAttributeValue(StartElement startElement,
HasQName attrName)
Get the Attribute value
|
static Integer |
getIntegerAttributeValueRP(StartElement startElement,
HasQName attrName)
Get the Attribute value, replacing every occurrence of ${..} by corresponding system property value
|
static String |
getLineColumnNumber(Location location)
Given a
Location , return a formatted string [lineNum,colNum] |
static EndElement |
getNextEndElement(XMLEventReader xmlEventReader)
Get the next
EndElement |
static XMLEvent |
getNextEvent(XMLEventReader xmlEventReader)
Get the next xml event
|
static StartElement |
getNextStartElement(XMLEventReader xmlEventReader)
Get the next
StartElement |
static String |
getRequiredAttributeValue(StartElement startElement,
HasQName attrName) |
static String |
getRequiredAttributeValueRP(StartElement startElement,
HasQName attrName) |
static List<String> |
getRequiredStringListAttributeValue(StartElement startElement,
HasQName attrName)
Parse a space delimited list of strings
|
static URI |
getUriAttributeValue(StartElement startElement,
HasQName attrName)
Get the Attribute value
|
static Duration |
getXmlDurationAttributeValue(StartElement startElement,
HasQName attrName)
Get the Attribute value
|
static XMLEventReader |
getXMLEventReader(InputStream is)
Get the XML event reader
|
static XMLEventReader |
getXMLEventReader(Source source)
Get the XML event reader
|
static XMLGregorianCalendar |
getXmlTimeAttributeValue(StartElement startElement,
HasQName attrName)
Get the Attribute value
|
static String |
getXSITypeValue(StartElement startElement)
Given a start element, obtain the xsi:type defined
|
static boolean |
hasTextAhead(XMLEventReader xmlEventReader)
Return whether the next event is going to be text
|
static boolean |
matches(EndElement endElement,
String tag)
Match that the end element with the expected tag
|
static boolean |
matches(StartElement startElement,
String tag)
Match that the start element with the expected tag
|
static XMLEvent |
peek(XMLEventReader xmlEventReader)
Peek at the next event
|
static EndElement |
peekNextEndElement(XMLEventReader xmlEventReader)
Peek the next
EndElement |
static StartElement |
peekNextStartElement(XMLEventReader xmlEventReader)
Peek the next
StartElement |
static XMLEvent |
peekNextTag(XMLEventReader xmlEventReader)
Peek the next
StartElement or EndElement . |
static String |
trim(String str)
Given a string, trim it
|
static void |
validate(EndElement endElement,
String tag)
Validate that the end element has the expected tag
|
static void |
validate(InputStream doc,
InputStream sch) |
static void |
validate(StartElement startElement,
QName tag)
Validate that the start element has the expected tag
|
static void |
validate(StartElement startElement,
String tag)
Deprecated.
|
static boolean |
wasWhitespacePeeked(XMLEventReader xmlEventReader,
XMLEvent xmlEvent)
Advances reader if character whitespace encountered
|
public static void validate(InputStream doc, InputStream sch) throws ParsingException
ParsingException
public static void bypassElementBlock(XMLEventReader xmlEventReader, String tag) throws ParsingException
xmlEventReader
is positioned at (has not yet read)
the start element of the block it should bypass.xmlEventReader
- tag
- Tag of the XML element that we need to bypassParsingException
public static void bypassElementBlock(XMLEventReader xmlEventReader, QName tag) throws ParsingException
xmlEventReader
is positioned at (has not yet read)
the start element of the block it should bypass.xmlEventReader
- tag
- Tag of the XML element that we need to bypassParsingException
public static XMLEvent bypassElementBlock(XMLEventReader xmlEventReader) throws ParsingException
xmlEventReader
is positioned at (has not yet read)
the start element of the block it should bypass.xmlEventReader
- ParsingException
public static boolean wasWhitespacePeeked(XMLEventReader xmlEventReader, XMLEvent xmlEvent)
xmlEventReader
- xmlEvent
- public static String getAttributeValue(Attribute attribute)
Attribute
, get its trimmed valueattribute
- public static String getAttributeValueRP(Attribute attribute)
Attribute
, get its trimmed value, replacing every occurrence of ${..} by corresponding system property valueattribute
- @Deprecated public static String getAttributeValue(StartElement startElement, String tag)
startElement
- tag
- localpart of the qname of the attributepublic static String getAttributeValue(StartElement startElement, HasQName attrName)
startElement
- tag
- localpart of the qname of the attributepublic static String getAttributeValueRP(StartElement startElement, HasQName attrName)
startElement
- tag
- localpart of the qname of the attributeStringPropertyReplacer.replaceProperties(java.lang.String)
public static String getAttributeValue(StartElement startElement, QName attrQName)
startElement
- tag
- localpart of the qname of the attributepublic static URI getUriAttributeValue(StartElement startElement, HasQName attrName)
startElement
- tag
- localpart of the qname of the attributepublic static XMLGregorianCalendar getXmlTimeAttributeValue(StartElement startElement, HasQName attrName) throws ParsingException
startElement
- tag
- localpart of the qname of the attributeParsingException
public static Duration getXmlDurationAttributeValue(StartElement startElement, HasQName attrName) throws ParsingException
startElement
- tag
- localpart of the qname of the attributeParsingException
public static Integer getIntegerAttributeValue(StartElement startElement, HasQName attrName)
startElement
- tag
- localpart of the qname of the attributepublic static Integer getIntegerAttributeValueRP(StartElement startElement, HasQName attrName)
startElement
- tag
- localpart of the qname of the attributepublic static Boolean getBooleanAttributeValue(StartElement startElement, HasQName attrName)
startElement
- tag
- localpart of the qname of the attributepublic static Boolean getBooleanAttributeValueRP(StartElement startElement, HasQName attrName)
startElement
- tag
- localpart of the qname of the attribute@Deprecated public static boolean getBooleanAttributeValue(StartElement startElement, String tag)
startElement
- tag
- localpart of the qname of the attribute@Deprecated public static boolean getBooleanAttributeValue(StartElement startElement, String tag, boolean defaultValue)
startElement
- tag
- localpart of the qname of the attributepublic static String getRequiredAttributeValue(StartElement startElement, HasQName attrName) throws ParsingException
ParsingException
public static String getRequiredAttributeValueRP(StartElement startElement, HasQName attrName) throws ParsingException
ParsingException
public static List<String> getRequiredStringListAttributeValue(StartElement startElement, HasQName attrName) throws ParsingException
startElement
- attrName
- ParsingException
public static Element getDOMElement(XMLEventReader xmlEventReader) throws ParsingException
XMLEventReader
is in XMLStreamConstants.START_ELEMENT
mode, we parse into a DOM
ElementxmlEventReader
- ParsingException
public static String getElementText(XMLEventReader xmlEventReader) throws ParsingException
XMLEventReader.getElementText()
:
Precondition: the current event is START_ELEMENT.
Postcondition: The current event is the corresponding END_ELEMENT.xmlEventReader
- ParsingException
public static String getElementTextRP(XMLEventReader xmlEventReader) throws ParsingException
xmlEventReader
- ParsingException
public static XMLEventReader getXMLEventReader(InputStream is)
is
- public static XMLEventReader getXMLEventReader(Source source)
source
- public static String getLineColumnNumber(Location location)
Location
, return a formatted string [lineNum,colNum]location
- public static XMLEvent getNextEvent(XMLEventReader xmlEventReader) throws ParsingException
xmlEventReader
- ParsingException
public static StartElement getNextStartElement(XMLEventReader xmlEventReader) throws ParsingException
StartElement
xmlEventReader
- ParsingException
public static EndElement getNextEndElement(XMLEventReader xmlEventReader) throws ParsingException
EndElement
xmlEventReader
- ParsingException
public static String getElementName(StartElement startElement)
startElement
- public static String getElementName(EndElement endElement)
endElement
- public static String getXSITypeValue(StartElement startElement)
startElement
- RuntimeException
- if xsi:type is missingpublic static boolean hasTextAhead(XMLEventReader xmlEventReader) throws ParsingException
xmlEventReader
- ParsingException
public static boolean matches(StartElement startElement, String tag)
startElement
- tag
- public static boolean matches(EndElement endElement, String tag)
endElement
- tag
- public static XMLEvent peek(XMLEventReader xmlEventReader) throws ParsingException
xmlEventReader
- ParsingException
public static XMLEvent advance(XMLEventReader xmlEventReader) throws ParsingException
xmlEventReader
- ParsingException
public static StartElement peekNextStartElement(XMLEventReader xmlEventReader) throws ParsingException
StartElement
xmlEventReader
- ParsingException
public static XMLEvent peekNextTag(XMLEventReader xmlEventReader) throws ParsingException
StartElement
or EndElement
.xmlEventReader
- ParsingException
public static EndElement peekNextEndElement(XMLEventReader xmlEventReader) throws ParsingException
EndElement
xmlEventReader
- ParsingException
public static final String trim(String str)
str
- {@code
- IllegalArgumentException} if the passed str is null@Deprecated public static void validate(StartElement startElement, String tag)
startElement
- tag
- RuntimeException
- mismatchpublic static void validate(StartElement startElement, QName tag)
startElement
- tag
- RuntimeException
- mismatchpublic static void validate(EndElement endElement, String tag)
endElement
- tag
- RuntimeException
- mismatchCopyright © 2021 JBoss by Red Hat. All rights reserved.