JBoss Metadata Common 7.0.4.Final-redhat-1

org.jboss.metadata.parser.util
Class MetaDataElementParser

java.lang.Object
  extended by org.jboss.metadata.parser.util.MetaDataElementParser
All Implemented Interfaces:
XMLStreamConstants
Direct Known Subclasses:
AddressingParser, DataSourceMetaDataParser, DescriptionGroupMetaDataParser, DescriptionMetaDataParser, DisplayNameMetaDataParser, EJBLocalReferenceMetaDataParser, EJBReferenceMetaDataParser, EnvironmentEntryMetaDataParser, IconMetaDataParser, LifecycleCallbackMetaDataParser, 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

Nested Class Summary
static class MetaDataElementParser.DTDInfo
           
 
Field Summary
 
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
 
Constructor Summary
MetaDataElementParser()
           
 
Method Summary
protected static boolean attributeHasNamespace(XMLStreamReader reader, int i)
           
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.
 boolean equals(Object obj)
          Determine if this object is the same as the given object.
protected static String getElementText(XMLStreamReader reader)
          Read the element text, with trimming.
protected static String getElementText(XMLStreamReader reader, boolean trim)
          Read and return the element text.
protected static String getElementText(XMLStreamReader reader, boolean trim, PropertyReplacer propertyReplacer)
          Read the element text, with trimming and replace in properties.
protected static String getElementText(XMLStreamReader reader, PropertyReplacer propertyReplacer)
          Read the element text, with trimming and replace in properties.
 int hashCode()
          Get the identity hash code of this object.
protected static XMLStreamException missingRequired(XMLStreamReader reader, Set<?> required)
          Get an exception reporting a missing, required XML attribute.
protected static XMLStreamException missingRequiredElement(XMLStreamReader reader, Set<?> required)
          Get an exception reporting a missing, required XML child element.
protected static QName parseQName(XMLStreamReader reader, String qname)
           
protected static boolean readBooleanAttributeElement(XMLStreamReader reader, String attributeName)
          Read an element which contains only a single boolean attribute.
protected static String readDTDLocation(XMLStreamReader reader)
           
protected static String readSchemaLocation(XMLStreamReader reader)
           
protected static String readStringAttributeElement(XMLStreamReader reader, String attributeName)
          Read an element which contains only a single string attribute.
protected static void requireNoAttributes(XMLStreamReader reader)
          Checks that the current element has no attributes, throwing an XMLStreamException if one is found.
protected static void requireNoContent(XMLStreamReader reader)
          Consumes the remainder of the current element, throwing an XMLStreamException if it contains any child elements.
protected static
<K,V> NavigableMap<K,V>
safeCopyMap(NavigableMap<K,V> toCopy)
          Returns a new TreeMap by passing the provided map to its constructor.
static XMLStreamException unexpectedAttribute(XMLStreamReader reader, int index)
          Get an exception reporting an unexpected XML attribute.
protected static XMLStreamException unexpectedElement(XMLStreamReader reader)
          Get an exception reporting an unexpected XML element.
protected static XMLStreamException unexpectedValue(XMLStreamReader reader, Throwable t)
          Get an exception reporting an unexpected XML element or attribute value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaDataElementParser

public MetaDataElementParser()
Method Detail

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

missingRequired

protected 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

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
propertyReplacer - propertyReplacer
trim - True if the text has to be trimmed before returning. False otherwise
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

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

JBoss Metadata Common 7.0.4.Final-redhat-1

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.