public final class ParseUtils
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
ParseUtils() |
Modifier and Type | Method and Description |
---|---|
static javax.xml.stream.XMLStreamException |
duplicateAttribute(javax.xml.stream.XMLStreamReader reader,
java.lang.String name)
Get an exception reporting that an attribute of a given name has already
been declared in this scope.
|
static javax.xml.stream.XMLStreamException |
duplicateNamedElement(javax.xml.stream.XMLStreamReader reader,
java.lang.String name)
Get an exception reporting that an element of a given type and name has
already been declared in this scope.
|
static Namespace[] |
getNamespaceAnnotations(java.lang.Class<? extends ConfigurationParser> cls) |
static java.lang.String |
getWarningMessage(java.lang.String msg,
javax.xml.stream.Location location) |
static javax.xml.stream.XMLStreamException |
invalidAttributeValue(javax.xml.stream.XMLStreamReader reader,
int index)
Get an exception reporting an invalid XML attribute value.
|
static boolean |
isNoNamespaceAttribute(javax.xml.stream.XMLStreamReader reader,
int index) |
static javax.xml.stream.XMLStreamException |
missingRequired(javax.xml.stream.XMLStreamReader reader,
java.util.Set<?> required)
Get an exception reporting a missing, required XML attribute.
|
static javax.xml.stream.XMLStreamException |
missingRequiredElement(javax.xml.stream.XMLStreamReader reader,
java.util.Set<?> required)
Get an exception reporting a missing, required XML child element.
|
static Element |
nextElement(javax.xml.stream.XMLStreamReader reader) |
static boolean |
readBooleanAttributeElement(javax.xml.stream.XMLStreamReader reader,
java.lang.String attributeName)
Read an element which contains only a single boolean attribute.
|
static java.lang.String |
readStringAttributeElement(javax.xml.stream.XMLStreamReader reader,
java.lang.String attributeName)
Read an element which contains only a single string attribute.
|
static java.lang.String[] |
requireAttributes(javax.xml.stream.XMLStreamReader reader,
java.lang.String... attributeNames)
Require all the named attributes, returning their values in order.
|
static void |
requireNoAttributes(javax.xml.stream.XMLStreamReader reader)
Checks that the current element has no attributes, throwing an
XMLStreamException if one is found. |
static void |
requireNoContent(javax.xml.stream.XMLStreamReader reader)
Consumes the remainder of the current element, throwing an
XMLStreamException if it contains any child
elements. |
static void |
requireNoNamespaceAttribute(javax.xml.stream.XMLStreamReader reader,
int index) |
static java.lang.String |
requireSingleAttribute(javax.xml.stream.XMLStreamReader reader,
java.lang.String attributeName)
Require that the current element have only a single attribute with the
given name.
|
static javax.xml.stream.XMLStreamException |
unexpectedAttribute(javax.xml.stream.XMLStreamReader reader,
int index)
Get an exception reporting an unexpected XML attribute.
|
static javax.xml.stream.XMLStreamException |
unexpectedElement(javax.xml.stream.XMLStreamReader reader)
Get an exception reporting an unexpected XML element.
|
static javax.xml.stream.XMLStreamException |
unexpectedEndElement(javax.xml.stream.XMLStreamReader reader)
Get an exception reporting an unexpected end tag for an XML element.
|
public static Element nextElement(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public static javax.xml.stream.XMLStreamException unexpectedElement(javax.xml.stream.XMLStreamReader reader)
reader
- the stream readerpublic static javax.xml.stream.XMLStreamException unexpectedEndElement(javax.xml.stream.XMLStreamReader reader)
reader
- the stream readerpublic static javax.xml.stream.XMLStreamException unexpectedAttribute(javax.xml.stream.XMLStreamReader reader, int index)
reader
- the stream readerindex
- the attribute indexpublic static javax.xml.stream.XMLStreamException invalidAttributeValue(javax.xml.stream.XMLStreamReader reader, int index)
reader
- the stream readerindex
- the attribute indexpublic static javax.xml.stream.XMLStreamException missingRequired(javax.xml.stream.XMLStreamReader reader, java.util.Set<?> required)
reader
- the stream readerrequired
- a set of enums whose toString method returns the
attribute namepublic static javax.xml.stream.XMLStreamException missingRequiredElement(javax.xml.stream.XMLStreamReader reader, java.util.Set<?> required)
reader
- the stream readerrequired
- a set of enums whose toString method returns the
attribute namepublic static void requireNoAttributes(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
XMLStreamException
if one is found.reader
- the readerjavax.xml.stream.XMLStreamException
- if an error occurspublic static void requireNoContent(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
XMLStreamException
if it contains any child
elements.reader
- the readerjavax.xml.stream.XMLStreamException
- if an error occurspublic static javax.xml.stream.XMLStreamException duplicateAttribute(javax.xml.stream.XMLStreamReader reader, java.lang.String name)
reader
- the stream readername
- the name that was redeclaredpublic static javax.xml.stream.XMLStreamException duplicateNamedElement(javax.xml.stream.XMLStreamReader reader, java.lang.String name)
reader
- the stream readername
- the name that was redeclaredpublic static boolean readBooleanAttributeElement(javax.xml.stream.XMLStreamReader reader, java.lang.String attributeName) throws javax.xml.stream.XMLStreamException
reader
- the readerattributeName
- the attribute name, usually "value"javax.xml.stream.XMLStreamException
- if an error occurs or if the
element does not contain the specified attribute, contains other
attributes, or contains child elements.public static java.lang.String readStringAttributeElement(javax.xml.stream.XMLStreamReader reader, java.lang.String attributeName) throws javax.xml.stream.XMLStreamException
reader
- the readerattributeName
- the attribute name, usually "value" or "name"javax.xml.stream.XMLStreamException
- if an error occurs or if the
element does not contain the specified attribute, contains other
attributes, or contains child elements.public static java.lang.String requireSingleAttribute(javax.xml.stream.XMLStreamReader reader, java.lang.String attributeName) throws javax.xml.stream.XMLStreamException
reader
- the readerattributeName
- the attribute namejavax.xml.stream.XMLStreamException
- if an error occurspublic static java.lang.String[] requireAttributes(javax.xml.stream.XMLStreamReader reader, java.lang.String... attributeNames) throws javax.xml.stream.XMLStreamException
reader
- the readerattributeNames
- the attribute namesjavax.xml.stream.XMLStreamException
- if an error occurspublic static boolean isNoNamespaceAttribute(javax.xml.stream.XMLStreamReader reader, int index)
public static void requireNoNamespaceAttribute(javax.xml.stream.XMLStreamReader reader, int index) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public static java.lang.String getWarningMessage(java.lang.String msg, javax.xml.stream.Location location)
public static Namespace[] getNamespaceAnnotations(java.lang.Class<? extends ConfigurationParser> cls)