Class MetaDataElementParser

java.lang.Object
org.jboss.metadata.parser.util.MetaDataElementParser
All Implemented Interfaces:
XMLStreamConstants
Direct Known Subclasses:
AddressingParser, AdministeredObjectMetaDataParser, ConnectionFactoryMetaDataParser, ContextServiceMetaDataParser, DataSourceMetaDataParser, DescriptionGroupMetaDataParser, DescriptionMetaDataParser, DisplayNameMetaDataParser, EJBLocalReferenceMetaDataParser, EJBReferenceMetaDataParser, EnvironmentEntryMetaDataParser, IconMetaDataParser, IdMetaDataParser, JMSConnectionFactoryMetaDataParser, JMSDestinationMetaDataParser, LanguageMetaDataParser, LifecycleCallbackMetaDataParser, MailSessionMetaDataParser, ManagedExecutorMetaDataParser, ManagedScheduledExecutorMetaDataParser, ManagedThreadFactoryMetaDataParser, MessageDestinationMetaDataParser, MessageDestinationReferenceMetaDataParser, ParamValueMetaDataParser, PersistenceContextReferenceMetaDataParser, PersistenceUnitReferenceMetaDataParser, PortComponentRefParser, PropertyMetaDataParser, ResourceEnvironmentReferenceMetaDataParser, ResourceInjectionMetaDataParser, ResourceInjectionTargetMetaDataParser, ResourceReferenceMetaDataParser, RespectBindingParser, RunAsMetaDataParser, SecurityRoleMetaDataParser, SecurityRoleRefMetaDataParser, ServiceReferenceHandlerChainMetaDataParser, ServiceReferenceHandlerChainsMetaDataParser, ServiceReferenceHandlerMetaDataParser, ServiceReferenceMetaDataParser, StubPropertyParser

public class MetaDataElementParser extends Object implements XMLStreamConstants
Author:
Emanuel Muckenhuber
  • Constructor Details

    • MetaDataElementParser

      public MetaDataElementParser()
  • Method Details

    • unexpectedValue

      protected static XMLStreamException unexpectedValue(XMLStreamReader reader, Throwable t)
      Get an exception reporting an unexpected XML element or attribute value.
      Parameters:
      reader - the stream reader
      Returns:
      the exception
    • unexpectedElement

      protected static XMLStreamException unexpectedElement(XMLStreamReader reader)
      Get an exception reporting an unexpected 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 element index
      Returns:
      the exception
    • missingRequiredAttributes

      protected static XMLStreamException missingRequiredAttributes(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

      protected 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

      protected 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
    • getElementText

      protected static String getElementText(XMLStreamReader reader) throws XMLStreamException
      Read the element text, with trimming.
      Parameters:
      reader - the reader
      Throws:
      XMLStreamException - if an error occurs
    • getElementText

      protected static String getElementText(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException
      Read the element text, with trimming and replace in properties.
      Parameters:
      reader - the reader
      propertyReplacer - propertyReplacer
      Throws:
      XMLStreamException - if an error occurs
    • getElementText

      protected static String getElementText(XMLStreamReader reader, boolean trim, PropertyReplacer propertyReplacer) throws XMLStreamException
      Read the element text, with trimming and replace in properties.
      Parameters:
      reader - the reader
      trim - True if the text has to be trimmed before returning. False otherwise
      propertyReplacer - propertyReplacer
      Throws:
      XMLStreamException - if an error occurs
    • getElementText

      protected static String getElementText(XMLStreamReader reader, boolean trim) throws XMLStreamException
      Read and return the element text. If the passed trim value is true, then the text is trimmed before returning.
      Parameters:
      reader -
      trim - True if the text has to be trimmed before returning. False otherwise
      Returns:
      Throws:
      XMLStreamException
    • requireNoContent

      protected 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
    • duplicateNamedElement

      protected 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

      protected 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

      protected 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.
    • readSchemaLocation

      protected static String readSchemaLocation(XMLStreamReader reader) throws XMLStreamException
      Throws:
      XMLStreamException
    • readDTDLocation

      protected static String readDTDLocation(XMLStreamReader reader) throws XMLStreamException
      Throws:
      XMLStreamException
    • parseQName

      protected static QName parseQName(XMLStreamReader reader, String qname)
    • attributeHasNamespace

      protected static boolean attributeHasNamespace(XMLStreamReader reader, int i)
    • safeCopyMap

      protected static <K,V> NavigableMap<K,V> safeCopyMap(NavigableMap<K,V> toCopy)
      Returns a new TreeMap by passing the provided map to its constructor. Thread safety note: toCopy's monitor is held while the TreeMap is being constructed.
      Type Parameters:
      K - the type of toCopy's keys
      V - the type of toCopy's values
      Parameters:
      toCopy - the map to copy. Cannot be null
      Returns:
      the copy
    • consumeElementContent

      protected static void consumeElementContent(XMLStreamReader reader) throws XMLStreamException
      Consume the element content of an XML stream reader (e.g. in the event of a non-fatal parse error).
      Parameters:
      reader - the XML stream reader
      Throws:
      XMLStreamException
    • equals

      public final boolean equals(Object obj)
      Determine if this object is the same as the given object. This is an identity comparison.
      Overrides:
      equals in class Object
      Parameters:
      obj - the other object
      Returns:
      true if the objects are the same
    • hashCode

      public final int hashCode()
      Get the identity hash code of this object.
      Overrides:
      hashCode in class Object
      Returns:
      the identity hash code