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 |
getLineColumnNumber(Location location)
Given a
Location , return a formatted string
[lineNum,colNum] |
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 str)
Given a string, trim it
|
static XMLStreamException |
unexpectedAttribute(XMLStreamReader reader,
int index)
Get an exception reporting an unexpected XML attribute.
|
static XMLStreamException |
unexpectedElement(XMLStreamReader reader)
Get an exception reporting an unexpected XML element.
|
public static String getAttributeValue(Attribute attribute)
Attribute
, get its trimmed valueattribute
- public static String getLineColumnNumber(Location location)
Location
, return a formatted string
[lineNum,colNum]location
- public static String getStartElementName(StartElement startElement)
startElement
- public static final String trim(String str)
str
- {@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 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 © 2013 JBoss Inc.. All Rights Reserved.