Package org.jboss.as.controller.parsing
Class ParseUtils
java.lang.Object
org.jboss.as.controller.parsing.ParseUtils
- Author:
- David M. Lloyd
-
Method Summary
Modifier and TypeMethodDescriptionstatic XMLStreamExceptionduplicateAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, String name) Get an exception reporting that an attribute of a given name has already been declared in this scope.static XMLStreamExceptionduplicateNamedElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String name) Get an exception reporting that an element of a given type and name has already been declared in this scope.static XMLStreamExceptioninvalidAttributeValue(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index) Get an exception reporting an invalid XML attribute value.static booleanisExpression(String value) static booleanisNoNamespaceAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index) static booleanisXmlNamespaceAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index) static XMLStreamExceptionmaxOccursExceeded(org.jboss.staxmapper.XMLExtendedStreamReader reader, Collection<QName> names, XMLCardinality cardinality) Creates an exception reporting that a given element appeared too many times.static XMLStreamExceptionminOccursNotReached(org.jboss.staxmapper.XMLExtendedStreamReader reader, Collection<QName> names, XMLCardinality cardinality) Creates an exception reporting that a given element(s) did not appear a sufficient number of times.static XMLStreamExceptionmissingOneOf(org.jboss.staxmapper.XMLExtendedStreamReader reader, Set<?> required) Get an exception reporting a missing, required XML child element.static XMLStreamExceptionmissingRequired(org.jboss.staxmapper.XMLExtendedStreamReader reader, String... required) Get an exception reporting a missing, required XML attribute.static XMLStreamExceptionmissingRequired(org.jboss.staxmapper.XMLExtendedStreamReader reader, Set<?> required) Get an exception reporting a missing, required XML attribute.static XMLStreamExceptionmissingRequiredElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, Set<?> required) Get an exception reporting a missing, required XML child element.static ElementnextElement(org.jboss.staxmapper.XMLExtendedStreamReader reader) static ElementnextElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String expectedNamespaceUri) A variation of nextElement that verifies the nextElement is not in a different namespace.static org.jboss.dmr.ModelNodeparseAttributeValue(String value, boolean isExpressionAllowed, org.jboss.dmr.ModelType attributeType) static org.jboss.dmr.ModelNodeparsePossibleExpression(String value) static <T> T[]readArrayAttributeElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String attributeName, Class<T> type) Read an element which contains only a single list attribute of a given type, returning it as an array.static booleanreadBooleanAttributeElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String attributeName) Read an element which contains only a single boolean attribute.static <T> List<T>readListAttributeElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String attributeName, Class<T> type) Read an element which contains only a single list attribute of a given type.static org.jboss.dmr.PropertyreadProperty(org.jboss.staxmapper.XMLExtendedStreamReader reader) static org.jboss.dmr.PropertyreadProperty(org.jboss.staxmapper.XMLExtendedStreamReader reader, boolean supportsExpressions) static StringreadStringAttributeElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String attributeName) Read an element which contains only a single string attribute.static String[]requireAttributes(org.jboss.staxmapper.XMLExtendedStreamReader reader, String... attributeNames) Require all the named attributes, returning their values in order.static voidrequireNamespace(org.jboss.staxmapper.XMLExtendedStreamReader reader, String requiredNs) Require that the namespace of the current element matches the required namespace.static voidrequireNoAttributes(org.jboss.staxmapper.XMLExtendedStreamReader reader) Checks that the current element has no attributes, throwing anXMLStreamExceptionif one is found.static voidrequireNoContent(org.jboss.staxmapper.XMLExtendedStreamReader reader) Consumes the remainder of the current element, throwing anXMLStreamExceptionif it contains any child elements.static voidrequireNoNamespaceAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index) static voidrequireSingleAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, String attributeName) Require that the current element have only a single attribute with the given name.static XMLStreamExceptionunexpectedAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index) Get an exception reporting an unexpected XML attribute.static XMLStreamExceptionunexpectedAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index, Set<?> possibleAttributes) Get an exception reporting an unexpected XML attribute.static XMLStreamExceptionunexpectedElement(org.jboss.staxmapper.XMLExtendedStreamReader reader) Get an exception reporting an unexpected XML element.static XMLStreamExceptionunexpectedElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, Set<?> possible) Get an exception reporting an unexpected XML element.static XMLStreamExceptionunexpectedEndElement(org.jboss.staxmapper.XMLExtendedStreamReader reader) Get an exception reporting an unexpected end tag for an XML element.static XMLStreamExceptionunsupportedElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String supportedElement) Get an exception reporting a missing, required XML attribute.static XMLStreamExceptionunsupportedNamespace(org.jboss.staxmapper.XMLExtendedStreamReader reader) Get an exception reporting an element using an unsupported namespace.
-
Method Details
-
nextElement
public static Element nextElement(org.jboss.staxmapper.XMLExtendedStreamReader reader) throws XMLStreamException - Throws:
XMLStreamException
-
nextElement
public static Element nextElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String expectedNamespaceUri) throws XMLStreamException A variation of nextElement that verifies the nextElement is not in a different namespace.- Parameters:
reader- the XmlExtendedReader to read from.expectedNamespace- the namespace expected.- Returns:
- the element or null if the end is reached
- Throws:
XMLStreamException- if the namespace is wrong or there is a problem accessing the reader
-
unexpectedElement
public static XMLStreamException unexpectedElement(org.jboss.staxmapper.XMLExtendedStreamReader reader) Get an exception reporting an unexpected XML element.- Parameters:
reader- the stream reader- Returns:
- the exception
-
unexpectedElement
public static XMLStreamException unexpectedElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, Set<?> possible) Get an exception reporting an unexpected XML element.- Parameters:
reader- the stream reader- Returns:
- the exception
-
unsupportedNamespace
public static XMLStreamException unsupportedNamespace(org.jboss.staxmapper.XMLExtendedStreamReader reader) Get an exception reporting an element using an unsupported namespace.- Parameters:
reader- the stream reader- Returns:
- the exception
-
unexpectedEndElement
public static XMLStreamException unexpectedEndElement(org.jboss.staxmapper.XMLExtendedStreamReader 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(org.jboss.staxmapper.XMLExtendedStreamReader 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(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index, Set<?> possibleAttributes) Get an exception reporting an unexpected XML attribute.- Parameters:
reader- the stream readerindex- the attribute indexpossibleAttributes- attributes that are expected on this element- Returns:
- the exception
-
invalidAttributeValue
public static XMLStreamException invalidAttributeValue(org.jboss.staxmapper.XMLExtendedStreamReader 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(org.jboss.staxmapper.XMLExtendedStreamReader 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
-
missingRequired
public static XMLStreamException missingRequired(org.jboss.staxmapper.XMLExtendedStreamReader reader, String... 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(org.jboss.staxmapper.XMLExtendedStreamReader 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
-
missingOneOf
public static XMLStreamException missingOneOf(org.jboss.staxmapper.XMLExtendedStreamReader 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(org.jboss.staxmapper.XMLExtendedStreamReader reader) throws XMLStreamException Checks that the current element has no attributes, throwing anXMLStreamExceptionif one is found.- Parameters:
reader- the reader- Throws:
XMLStreamException- if an error occurs
-
requireNoContent
public static void requireNoContent(org.jboss.staxmapper.XMLExtendedStreamReader reader) throws XMLStreamException Consumes the remainder of the current element, throwing anXMLStreamExceptionif it contains any child elements.- Parameters:
reader- the reader- Throws:
XMLStreamException- if an error occurs
-
requireNamespace
public static void requireNamespace(org.jboss.staxmapper.XMLExtendedStreamReader reader, String requiredNs) throws XMLStreamException Require that the namespace of the current element matches the required namespace.- Parameters:
reader- the readerrequiredNs- the namespace required- Throws:
XMLStreamException- if the current namespace does not match the required namespace
-
duplicateAttribute
public static XMLStreamException duplicateAttribute(org.jboss.staxmapper.XMLExtendedStreamReader 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(org.jboss.staxmapper.XMLExtendedStreamReader 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(org.jboss.staxmapper.XMLExtendedStreamReader 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(org.jboss.staxmapper.XMLExtendedStreamReader 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.
-
readListAttributeElement
public static <T> List<T> readListAttributeElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String attributeName, Class<T> type) throws XMLStreamException Read an element which contains only a single list attribute of a given type.- Type Parameters:
T- the value type- Parameters:
reader- the readerattributeName- the attribute name, usually "value"type- the value type class- Returns:
- the value list
- Throws:
XMLStreamException- if an error occurs or if the element does not contain the specified attribute, contains other attributes, or contains child elements.
-
readProperty
public static org.jboss.dmr.Property readProperty(org.jboss.staxmapper.XMLExtendedStreamReader reader) throws XMLStreamException - Throws:
XMLStreamException
-
readProperty
public static org.jboss.dmr.Property readProperty(org.jboss.staxmapper.XMLExtendedStreamReader reader, boolean supportsExpressions) throws XMLStreamException - Throws:
XMLStreamException
-
readArrayAttributeElement
public static <T> T[] readArrayAttributeElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String attributeName, Class<T> type) throws XMLStreamException Read an element which contains only a single list attribute of a given type, returning it as an array.- Type Parameters:
T- the value type- Parameters:
reader- the readerattributeName- the attribute name, usually "value"type- the value type class- Returns:
- the value list as an array
- 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 void requireSingleAttribute(org.jboss.staxmapper.XMLExtendedStreamReader 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(org.jboss.staxmapper.XMLExtendedStreamReader reader, 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
-
isXmlNamespaceAttribute
public static boolean isXmlNamespaceAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index) -
isNoNamespaceAttribute
public static boolean isNoNamespaceAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index) -
requireNoNamespaceAttribute
public static void requireNoNamespaceAttribute(org.jboss.staxmapper.XMLExtendedStreamReader reader, int index) throws XMLStreamException - Throws:
XMLStreamException
-
parseAttributeValue
public static org.jboss.dmr.ModelNode parseAttributeValue(String value, boolean isExpressionAllowed, org.jboss.dmr.ModelType attributeType) -
isExpression
-
parsePossibleExpression
-
unsupportedElement
public static XMLStreamException unsupportedElement(org.jboss.staxmapper.XMLExtendedStreamReader reader, String supportedElement) Get an exception reporting a missing, required XML attribute.- Parameters:
reader- the stream readersupportedElement- the element that is to be used in place of the unsupported one.- Returns:
- the exception
-
minOccursNotReached
public static XMLStreamException minOccursNotReached(org.jboss.staxmapper.XMLExtendedStreamReader reader, Collection<QName> names, XMLCardinality cardinality) Creates an exception reporting that a given element(s) did not appear a sufficient number of times.- Parameters:
reader- the stream readerelementName- the element name- Returns:
- a validation exception
-
maxOccursExceeded
public static XMLStreamException maxOccursExceeded(org.jboss.staxmapper.XMLExtendedStreamReader reader, Collection<QName> names, XMLCardinality cardinality) Creates an exception reporting that a given element appeared too many times.- Parameters:
reader- the stream readerelementName- the element name- Returns:
- a validation exception
-