Class ParseUtils
- java.lang.Object
-
- org.infinispan.configuration.parsing.ParseUtils
-
public final class ParseUtils extends Object
- Author:
- David M. Lloyd
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static XMLStreamException
duplicateAttribute(XMLStreamReader reader, String name)
Get an exception reporting that an attribute of a given name has already been declared in this scope.static XMLStreamException
duplicateNamedElement(XMLStreamReader reader, String name)
Get an exception reporting that an element of a given type and name has already been declared in this scope.static String[]
getListAttributeValue(String value)
static Namespace[]
getNamespaceAnnotations(Class<?> cls)
static String
getWarningMessage(String msg, Location location)
static XMLStreamException
invalidAttributeValue(XMLStreamReader reader, int index)
Get an exception reporting an invalid XML attribute value.static boolean
isNoNamespaceAttribute(XMLStreamReader reader, int index)
static XMLStreamException
missingRequired(XMLStreamReader reader, Set<?> required)
Get an exception reporting a missing, required XML attribute.static XMLStreamException
missingRequiredElement(XMLStreamReader reader, Set<?> required)
Get an exception reporting a missing, required XML child element.static Element
nextElement(XMLStreamReader reader)
static boolean
readBooleanAttributeElement(XMLStreamReader reader, String attributeName)
Read an element which contains only a single boolean attribute.static String
readStringAttributeElement(XMLStreamReader reader, String attributeName)
Read an element which contains only a single string attribute.static String[]
requireAttributes(XMLStreamReader reader, boolean replace, String... attributeNames)
Require all the named attributes, returning their values in order.static String[]
requireAttributes(XMLStreamReader reader, String... attributeNames)
static void
requireNoAttributes(XMLStreamReader reader)
Checks that the current element has no attributes, throwing anXMLStreamException
if one is found.static void
requireNoContent(XMLStreamReader reader)
Consumes the remainder of the current element, throwing anXMLStreamException
if it contains any child elements.static void
requireNoNamespaceAttribute(XMLStreamReader reader, int index)
static String
requireSingleAttribute(XMLStreamReader reader, String attributeName)
Require that the current element have only a single attribute with the given name.static XMLStreamException
unexpectedAttribute(XMLStreamReader reader, int index)
Get an exception reporting an unexpected XML attribute.static XMLStreamException
unexpectedAttribute(XMLStreamReader reader, String name)
Get an exception reporting an unexpected XML attribute.static XMLStreamException
unexpectedElement(XMLStreamReader reader)
Get an exception reporting an unexpected XML element.static XMLStreamException
unexpectedEndElement(XMLStreamReader reader)
Get an exception reporting an unexpected end tag for an XML element.
-
-
-
Method Detail
-
nextElement
public static Element nextElement(XMLStreamReader reader) throws XMLStreamException
- Throws:
XMLStreamException
-
unexpectedElement
public static XMLStreamException unexpectedElement(XMLStreamReader reader)
Get an exception reporting an unexpected XML element.- Parameters:
reader
- the stream reader- Returns:
- the exception
-
unexpectedEndElement
public static XMLStreamException unexpectedEndElement(XMLStreamReader reader)
Get an exception reporting an unexpected end tag for an XML element.- Parameters:
reader
- the stream reader- Returns:
- the 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
-
unexpectedAttribute
public static XMLStreamException unexpectedAttribute(XMLStreamReader reader, String name)
Get an exception reporting an unexpected XML attribute.- Parameters:
reader
- the stream readername
- the attribute name- Returns:
- the exception
-
invalidAttributeValue
public static XMLStreamException invalidAttributeValue(XMLStreamReader reader, int index)
Get an exception reporting an invalid XML attribute value.- Parameters:
reader
- the stream readerindex
- the attribute index- Returns:
- the exception
-
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
-
missingRequiredElement
public static XMLStreamException missingRequiredElement(XMLStreamReader reader, Set<?> required)
Get an exception reporting a missing, required XML child element.- Parameters:
reader
- the stream readerrequired
- a set of enums whose toString method returns the attribute name- Returns:
- the exception
-
requireNoAttributes
public static void requireNoAttributes(XMLStreamReader reader) throws XMLStreamException
Checks that the current element has no attributes, throwing anXMLStreamException
if one is found.- Parameters:
reader
- the reader- Throws:
XMLStreamException
- if an error occurs
-
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
-
duplicateAttribute
public static XMLStreamException duplicateAttribute(XMLStreamReader reader, String name)
Get an exception reporting that an attribute of a given name has already been declared in this scope.- Parameters:
reader
- the stream readername
- the name that was redeclared- Returns:
- the exception
-
duplicateNamedElement
public static XMLStreamException duplicateNamedElement(XMLStreamReader reader, String name)
Get an exception reporting that an element of a given type and name has already been declared in this scope.- Parameters:
reader
- the stream readername
- the name that was redeclared- Returns:
- the exception
-
readBooleanAttributeElement
public static boolean readBooleanAttributeElement(XMLStreamReader reader, String attributeName) throws XMLStreamException
Read an element which contains only a single boolean attribute.- Parameters:
reader
- the readerattributeName
- the attribute name, usually "value"- Returns:
- the boolean value
- Throws:
XMLStreamException
- if an error occurs or if the element does not contain the specified attribute, contains other attributes, or contains child elements.
-
readStringAttributeElement
public static String readStringAttributeElement(XMLStreamReader reader, String attributeName) throws XMLStreamException
Read an element which contains only a single string attribute.- Parameters:
reader
- the readerattributeName
- the attribute name, usually "value" or "name"- Returns:
- the string value
- Throws:
XMLStreamException
- if an error occurs or if the element does not contain the specified attribute, contains other attributes, or contains child elements.
-
requireSingleAttribute
public static String requireSingleAttribute(XMLStreamReader reader, String attributeName) throws XMLStreamException
Require that the current element have only a single attribute with the given name.- Parameters:
reader
- the readerattributeName
- the attribute name- Throws:
XMLStreamException
- if an error occurs
-
requireAttributes
public static String[] requireAttributes(XMLStreamReader reader, boolean replace, String... attributeNames) throws XMLStreamException
Require all the named attributes, returning their values in order.- Parameters:
reader
- the readerattributeNames
- the attribute names- Returns:
- the attribute values in order
- Throws:
XMLStreamException
- if an error occurs
-
requireAttributes
public static String[] requireAttributes(XMLStreamReader reader, String... attributeNames) throws XMLStreamException
- Throws:
XMLStreamException
-
isNoNamespaceAttribute
public static boolean isNoNamespaceAttribute(XMLStreamReader reader, int index)
-
requireNoNamespaceAttribute
public static void requireNoNamespaceAttribute(XMLStreamReader reader, int index) throws XMLStreamException
- Throws:
XMLStreamException
-
-