Class ParseUtils
- java.lang.Object
-
- org.infinispan.configuration.parsing.ParseUtils
-
public final class ParseUtils extends java.lang.Object- Author:
- David M. Lloyd
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.xml.stream.XMLStreamExceptionduplicateAttribute(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.XMLStreamExceptionduplicateNamedElement(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 java.lang.String[]getListAttributeValue(java.lang.String value)static Namespace[]getNamespaceAnnotations(java.lang.Class<?> cls)static java.lang.StringgetWarningMessage(java.lang.String msg, javax.xml.stream.Location location)static javax.xml.stream.XMLStreamExceptioninvalidAttributeValue(javax.xml.stream.XMLStreamReader reader, int index)Get an exception reporting an invalid XML attribute value.static booleanisNoNamespaceAttribute(javax.xml.stream.XMLStreamReader reader, int index)static javax.xml.stream.XMLStreamExceptionmissingRequired(javax.xml.stream.XMLStreamReader reader, java.util.Set<?> required)Get an exception reporting a missing, required XML attribute.static javax.xml.stream.XMLStreamExceptionmissingRequiredElement(javax.xml.stream.XMLStreamReader reader, java.util.Set<?> required)Get an exception reporting a missing, required XML child element.static ElementnextElement(javax.xml.stream.XMLStreamReader reader)static booleanreadBooleanAttributeElement(javax.xml.stream.XMLStreamReader reader, java.lang.String attributeName)Read an element which contains only a single boolean attribute.static java.lang.StringreadStringAttributeElement(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, boolean replace, java.lang.String... attributeNames)Require all the named attributes, returning their values in order.static java.lang.String[]requireAttributes(javax.xml.stream.XMLStreamReader reader, java.lang.String... attributeNames)static voidrequireNoAttributes(javax.xml.stream.XMLStreamReader reader)Checks that the current element has no attributes, throwing anXMLStreamExceptionif one is found.static voidrequireNoContent(javax.xml.stream.XMLStreamReader reader)Consumes the remainder of the current element, throwing anXMLStreamExceptionif it contains any child elements.static voidrequireNoNamespaceAttribute(javax.xml.stream.XMLStreamReader reader, int index)static java.lang.StringrequireSingleAttribute(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.XMLStreamExceptionunexpectedAttribute(javax.xml.stream.XMLStreamReader reader, int index)Get an exception reporting an unexpected XML attribute.static javax.xml.stream.XMLStreamExceptionunexpectedAttribute(javax.xml.stream.XMLStreamReader reader, java.lang.String name)Get an exception reporting an unexpected XML attribute.static javax.xml.stream.XMLStreamExceptionunexpectedElement(javax.xml.stream.XMLStreamReader reader)Get an exception reporting an unexpected XML element.static javax.xml.stream.XMLStreamExceptionunexpectedEndElement(javax.xml.stream.XMLStreamReader reader)Get an exception reporting an unexpected end tag for an XML element.
-
-
-
Method Detail
-
nextElement
public static Element nextElement(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
unexpectedElement
public static javax.xml.stream.XMLStreamException unexpectedElement(javax.xml.stream.XMLStreamReader reader)
Get an exception reporting an unexpected XML element.- Parameters:
reader- the stream reader- Returns:
- the exception
-
unexpectedEndElement
public static javax.xml.stream.XMLStreamException unexpectedEndElement(javax.xml.stream.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 javax.xml.stream.XMLStreamException unexpectedAttribute(javax.xml.stream.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 javax.xml.stream.XMLStreamException unexpectedAttribute(javax.xml.stream.XMLStreamReader reader, java.lang.String name)Get an exception reporting an unexpected XML attribute.- Parameters:
reader- the stream readername- the attribute name- Returns:
- the exception
-
invalidAttributeValue
public static javax.xml.stream.XMLStreamException invalidAttributeValue(javax.xml.stream.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 javax.xml.stream.XMLStreamException missingRequired(javax.xml.stream.XMLStreamReader reader, java.util.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 javax.xml.stream.XMLStreamException missingRequiredElement(javax.xml.stream.XMLStreamReader reader, java.util.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(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamExceptionChecks that the current element has no attributes, throwing anXMLStreamExceptionif one is found.- Parameters:
reader- the reader- Throws:
javax.xml.stream.XMLStreamException- if an error occurs
-
requireNoContent
public static void requireNoContent(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamExceptionConsumes the remainder of the current element, throwing anXMLStreamExceptionif it contains any child elements.- Parameters:
reader- the reader- Throws:
javax.xml.stream.XMLStreamException- if an error occurs
-
duplicateAttribute
public 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.- Parameters:
reader- the stream readername- the name that was redeclared- Returns:
- the exception
-
duplicateNamedElement
public 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.- Parameters:
reader- the stream readername- the name that was redeclared- Returns:
- the exception
-
readBooleanAttributeElement
public static boolean readBooleanAttributeElement(javax.xml.stream.XMLStreamReader reader, java.lang.String attributeName) throws javax.xml.stream.XMLStreamExceptionRead an element which contains only a single boolean attribute.- Parameters:
reader- the readerattributeName- the attribute name, usually "value"- Returns:
- the boolean value
- Throws:
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.
-
readStringAttributeElement
public static java.lang.String readStringAttributeElement(javax.xml.stream.XMLStreamReader reader, java.lang.String attributeName) throws javax.xml.stream.XMLStreamExceptionRead 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:
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.
-
requireSingleAttribute
public static java.lang.String requireSingleAttribute(javax.xml.stream.XMLStreamReader reader, java.lang.String attributeName) throws javax.xml.stream.XMLStreamExceptionRequire that the current element have only a single attribute with the given name.- Parameters:
reader- the readerattributeName- the attribute name- Throws:
javax.xml.stream.XMLStreamException- if an error occurs
-
requireAttributes
public static java.lang.String[] requireAttributes(javax.xml.stream.XMLStreamReader reader, boolean replace, java.lang.String... attributeNames) throws javax.xml.stream.XMLStreamExceptionRequire all the named attributes, returning their values in order.- Parameters:
reader- the readerattributeNames- the attribute names- Returns:
- the attribute values in order
- Throws:
javax.xml.stream.XMLStreamException- if an error occurs
-
requireAttributes
public static java.lang.String[] requireAttributes(javax.xml.stream.XMLStreamReader reader, java.lang.String... attributeNames) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
isNoNamespaceAttribute
public static boolean isNoNamespaceAttribute(javax.xml.stream.XMLStreamReader reader, int index)
-
requireNoNamespaceAttribute
public static void requireNoNamespaceAttribute(javax.xml.stream.XMLStreamReader reader, int index) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
getWarningMessage
public static java.lang.String getWarningMessage(java.lang.String msg, javax.xml.stream.Location location)
-
getNamespaceAnnotations
public static Namespace[] getNamespaceAnnotations(java.lang.Class<?> cls)
-
getListAttributeValue
public static java.lang.String[] getListAttributeValue(java.lang.String value)
-
-