Package org.jboss.security.config.parser
Class StaxParserUtil
- java.lang.Object
-
- org.jboss.security.config.parser.StaxParserUtil
-
- All Implemented Interfaces:
XMLStreamConstants
public class StaxParserUtil extends Object implements XMLStreamConstants
Utility for the stax based parser- Since:
- Feb 8, 2010
- Author:
- Anil.Saldhana@redhat.com, Marcus Moyses
-
-
Field Summary
-
Fields inherited from interface javax.xml.stream.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 Summary
Constructors Constructor Description StaxParserUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getAttributeValue(Attribute attribute)
Given anAttribute
, get its trimmed valuestatic String
getStartElementName(StartElement startElement)
Return the name of the start elementstatic 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 anXMLStreamException
if it contains any child elements.static String
trim(String inputStr)
Given a string, trim itstatic 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.
-
-
-
Method Detail
-
getAttributeValue
public static String getAttributeValue(Attribute attribute)
Given anAttribute
, get its trimmed value- Parameters:
attribute
-- Returns:
-
getStartElementName
public static String getStartElementName(StartElement startElement)
Return the name of the start element- Parameters:
startElement
-- Returns:
-
trim
public static final String trim(String inputStr)
Given a string, trim it- Parameters:
inputStr
-- Returns:
-
missingRequired
public static XMLStreamException missingRequired(XMLStreamReader reader, Set<?> required)
Get an exception reporting a missing, required XML attribute.- Parameters:
reader
- the stream readerrequired
- a set of enums whose toString method returns the attribute name- Returns:
- the exception
-
unexpectedElement
public static XMLStreamException unexpectedElement(XMLStreamReader reader)
Get an exception reporting an unexpected XML element.- Parameters:
reader
- the stream reader- Returns:
- the exception
-
unexpectedElement
public static XMLStreamException unexpectedElement(String elementName, XMLEvent event)
Get an exception reporting an unexpected XML element.- Parameters:
elementName
- the unexpected element nameevent
- the XML event- Returns:
- the constructed exception
-
unexpectedNS
public static XMLStreamException unexpectedNS(String namespaceURI, XMLEvent event)
Get an exceptioon reporting an unexpected nasmespace URI.- Parameters:
namespaceURI
- the unexpected namespace URI.- Returns:
- the constructed exception.
-
unexpectedAttribute
public static XMLStreamException unexpectedAttribute(XMLStreamReader reader, int index)
Get an exception reporting an unexpected XML attribute.- Parameters:
reader
- the stream readerindex
- the attribute index- Returns:
- the exception
-
requireNoContent
public static void requireNoContent(XMLStreamReader reader) throws XMLStreamException
Consumes the remainder of the current element, throwing anXMLStreamException
if it contains any child elements.- Parameters:
reader
- the reader- Throws:
XMLStreamException
- if an error occurs
-
-