org.infinispan.configuration.parsing
Class ParseUtils

java.lang.Object
  extended by org.infinispan.configuration.parsing.ParseUtils

public final class ParseUtils
extends Object

Author:
David M. Lloyd

Method Summary
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 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, String... attributeNames)
          Require all the named attributes, returning their values in order.
static void requireNoAttributes(XMLStreamReader reader)
          Checks that the current element has no attributes, throwing an XMLStreamException if one is found.
static void requireNoContent(XMLStreamReader reader)
          Consumes the remainder of the current element, throwing an XMLStreamException if it contains any child elements.
static void requireNoNamespaceAttribute(XMLStreamReader reader, int index)
           
static void 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 reader
index - the attribute index
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

requireNoAttributes

public static void requireNoAttributes(XMLStreamReader 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(XMLStreamReader 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

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 void 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,
                                         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)

requireNoNamespaceAttribute

public static void requireNoNamespaceAttribute(XMLStreamReader reader,
                                               int index)
                                        throws XMLStreamException
Throws:
XMLStreamException

getWarningMessage

public static String getWarningMessage(String msg,
                                       Location location)

-->

Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.