Class ParseUtils

    • Method Detail

      • nextElement

        public static Element nextElement​(org.jboss.staxmapper.XMLExtendedStreamReader reader,
                                          Namespace expectedNamespace)
                                   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<String> possible)
        Get an exception reporting an unexpected XML element.
        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 reader
        index - the attribute index
        Returns:
        the exception
      • unexpectedAttribute

        public static XMLStreamException unexpectedAttribute​(org.jboss.staxmapper.XMLExtendedStreamReader reader,
                                                             int index,
                                                             Set<String> possibleAttributes)
        Get an exception reporting an unexpected XML attribute.
        Parameters:
        reader - the stream reader
        index - the attribute index
        possibleAttributes - 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 reader
        index - 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 reader
        required - 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 reader
        required - 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 reader
        required - 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 reader
        required - 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 an XMLStreamException if 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 an XMLStreamException if 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,
                                            Namespace requiredNs)
                                     throws XMLStreamException
        Require that the namespace of the current element matches the required namespace.
        Parameters:
        reader - the reader
        requiredNs - 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 reader
        name - 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 reader
        name - 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 reader
        attributeName - 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 reader
        attributeName - 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 reader
        attributeName - 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,
                                                          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 reader
        attributeName - 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 reader
        attributeName - 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 reader
        attributeNames - the attribute names
        Returns:
        the attribute values in order
        Throws:
        XMLStreamException - if an error occurs
      • 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

        public static boolean isExpression​(String value)
      • parsePossibleExpression

        public static org.jboss.dmr.ModelNode parsePossibleExpression​(String value)
      • 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 reader
        supportedElement - the element that is to be used in place of the unsupported one.
        Returns:
        the exception