public class StaxParserUtil extends Object implements XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
Constructor and Description |
---|
StaxParserUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
getAttributeValue(Attribute attribute)
Given an
Attribute , get its trimmed value |
static String |
getStartElementName(StartElement startElement)
Return the name of the start element
|
static XMLStreamException |
missingRequired(XMLStreamReader reader,
Set<?> required)
Get an exception reporting a missing, required XML attribute.
|
static void |
requireNoContent(XMLStreamReader reader)
Consumes the remainder of the current element, throwing an
XMLStreamException
if it contains any child elements. |
static String |
trim(String inputStr)
Given a string, trim it
|
static XMLStreamException |
unexpectedAttribute(XMLStreamReader reader,
int index)
Get an exception reporting an unexpected XML attribute.
|
static XMLStreamException |
unexpectedElement(String elementName,
XMLEvent event)
Get an exception reporting an unexpected XML element.
|
static XMLStreamException |
unexpectedElement(XMLStreamReader reader)
Get an exception reporting an unexpected XML element.
|
static XMLStreamException |
unexpectedNS(String namespaceURI,
XMLEvent event)
Get an exceptioon reporting an unexpected nasmespace URI.
|
public static String getAttributeValue(Attribute attribute)
Attribute
, get its trimmed valueattribute
- public static String getStartElementName(StartElement startElement)
startElement
- public static final String trim(String inputStr)
inputStr
- {@code
- IllegalArgumentException} if the passed str is nullpublic static XMLStreamException missingRequired(XMLStreamReader reader, Set<?> required)
reader
- the stream readerrequired
- a set of enums whose toString method returns the attribute namepublic static XMLStreamException unexpectedElement(XMLStreamReader reader)
reader
- the stream readerpublic static XMLStreamException unexpectedElement(String elementName, XMLEvent event)
elementName
- the unexpected element nameevent
- the XML eventpublic static XMLStreamException unexpectedNS(String namespaceURI, XMLEvent event)
namespaceURI
- the unexpected namespace URI.public static XMLStreamException unexpectedAttribute(XMLStreamReader reader, int index)
reader
- the stream readerindex
- the attribute indexpublic static void requireNoContent(XMLStreamReader reader) throws XMLStreamException
XMLStreamException
if it contains any child elements.reader
- the readerXMLStreamException
- if an error occursCopyright © 2018 JBoss by Red Hat. All rights reserved.