Class ParseUtils

    • Method Detail

      • 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 reader
        index - 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 reader
        name - 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 reader
        index - 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 reader
        required - 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 reader
        required - a set of enums whose toString method returns the attribute name
        Returns:
        the exception
      • 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 reader
        name - 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 reader
        name - 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 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​(XMLStreamReader 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.
      • 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 reader
        attributeName - 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 reader
        attributeNames - the attribute names
        Returns:
        the attribute values in order
        Throws:
        XMLStreamException - if an error occurs
      • isNoNamespaceAttribute

        public static boolean isNoNamespaceAttribute​(XMLStreamReader reader,
                                                     int index)
      • getNamespaceAnnotations

        public static Namespace[] getNamespaceAnnotations​(Class<?> cls)
      • getListAttributeValue

        public static String[] getListAttributeValue​(String value)