org.springframework.util.xml
Class AbstractStaxXMLReader

java.lang.Object
  extended by org.springframework.util.xml.AbstractXMLReader
      extended by org.springframework.util.xml.AbstractStaxXMLReader
All Implemented Interfaces:
org.xml.sax.XMLReader
Direct Known Subclasses:
StaxEventXMLReader, StaxStreamXMLReader

abstract class AbstractStaxXMLReader
extends AbstractXMLReader

Abstract base class for SAX XMLReader implementations that use StAX as a basis.

Since:
3.0
Author:
Arjen Poutsma
See Also:
AbstractXMLReader.setContentHandler(org.xml.sax.ContentHandler), AbstractXMLReader.setDTDHandler(org.xml.sax.DTDHandler), AbstractXMLReader.setEntityResolver(org.xml.sax.EntityResolver), AbstractXMLReader.setErrorHandler(org.xml.sax.ErrorHandler)

Nested Class Summary
private static class AbstractStaxXMLReader.StaxLocator
          Implementation of the Locator interface that is based on a StAX Location.
 
Field Summary
private static java.lang.String IS_STANDALONE_FEATURE_NAME
           
private  java.lang.Boolean isStandalone
           
private static java.lang.String NAMESPACE_PREFIXES_FEATURE_NAME
           
private  boolean namespacePrefixesFeature
           
private  java.util.Map<java.lang.String,java.lang.String> namespaces
           
private static java.lang.String NAMESPACES_FEATURE_NAME
           
private  boolean namespacesFeature
           
 
Constructor Summary
AbstractStaxXMLReader()
           
 
Method Summary
protected  void endPrefixMapping(java.lang.String prefix)
          Ends the prefix mapping for the given prefix.
 boolean getFeature(java.lang.String name)
          Throws a SAXNotRecognizedException exception.
protected  boolean hasNamespacePrefixesFeature()
          Indicates whether the SAX feature http://xml.org/sax/features/namespaces-prefixes is turned on.
protected  boolean hasNamespacesFeature()
          Indicates whether the SAX feature http://xml.org/sax/features/namespaces is turned on.
private  void parse()
           
 void parse(org.xml.sax.InputSource ignored)
          Parse the StAX XML reader passed at construction-time.
 void parse(java.lang.String ignored)
          Parse the StAX XML reader passed at construction-time.
protected abstract  void parseInternal()
          Template-method that parses the StAX reader passed at construction-time.
 void setFeature(java.lang.String name, boolean value)
          Throws a SAXNotRecognizedException exception.
protected  void setStandalone(boolean standalone)
           
protected  void startPrefixMapping(java.lang.String prefix, java.lang.String namespace)
          Starts the prefix mapping for the given prefix.
protected  java.lang.String toQualifiedName(javax.xml.namespace.QName qName)
          Convert a QName to a qualified name, as used by DOM and SAX.
 
Methods inherited from class org.springframework.util.xml.AbstractXMLReader
getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getLexicalHandler, getProperty, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACES_FEATURE_NAME

private static final java.lang.String NAMESPACES_FEATURE_NAME
See Also:
Constant Field Values

NAMESPACE_PREFIXES_FEATURE_NAME

private static final java.lang.String NAMESPACE_PREFIXES_FEATURE_NAME
See Also:
Constant Field Values

IS_STANDALONE_FEATURE_NAME

private static final java.lang.String IS_STANDALONE_FEATURE_NAME
See Also:
Constant Field Values

namespacesFeature

private boolean namespacesFeature

namespacePrefixesFeature

private boolean namespacePrefixesFeature

isStandalone

private java.lang.Boolean isStandalone

namespaces

private final java.util.Map<java.lang.String,java.lang.String> namespaces
Constructor Detail

AbstractStaxXMLReader

AbstractStaxXMLReader()
Method Detail

getFeature

public boolean getFeature(java.lang.String name)
                   throws org.xml.sax.SAXNotRecognizedException,
                          org.xml.sax.SAXNotSupportedException
Description copied from class: AbstractXMLReader
Throws a SAXNotRecognizedException exception.

Specified by:
getFeature in interface org.xml.sax.XMLReader
Overrides:
getFeature in class AbstractXMLReader
Throws:
org.xml.sax.SAXNotRecognizedException - always
org.xml.sax.SAXNotSupportedException

setFeature

public void setFeature(java.lang.String name,
                       boolean value)
                throws org.xml.sax.SAXNotRecognizedException,
                       org.xml.sax.SAXNotSupportedException
Description copied from class: AbstractXMLReader
Throws a SAXNotRecognizedException exception.

Specified by:
setFeature in interface org.xml.sax.XMLReader
Overrides:
setFeature in class AbstractXMLReader
Throws:
org.xml.sax.SAXNotRecognizedException - always
org.xml.sax.SAXNotSupportedException

setStandalone

protected void setStandalone(boolean standalone)

hasNamespacesFeature

protected boolean hasNamespacesFeature()
Indicates whether the SAX feature http://xml.org/sax/features/namespaces is turned on.


hasNamespacePrefixesFeature

protected boolean hasNamespacePrefixesFeature()
Indicates whether the SAX feature http://xml.org/sax/features/namespaces-prefixes is turned on.


toQualifiedName

protected java.lang.String toQualifiedName(javax.xml.namespace.QName qName)
Convert a QName to a qualified name, as used by DOM and SAX. The returned string has a format of prefix:localName if the prefix is set, or just localName if not.

Parameters:
qName - the QName
Returns:
the qualified name

parse

public final void parse(org.xml.sax.InputSource ignored)
                 throws org.xml.sax.SAXException
Parse the StAX XML reader passed at construction-time.

NOTE:: The given InputSource is not read, but ignored.

Parameters:
ignored - is ignored
Throws:
org.xml.sax.SAXException - a SAX exception, possibly wrapping a XMLStreamException

parse

public final void parse(java.lang.String ignored)
                 throws org.xml.sax.SAXException
Parse the StAX XML reader passed at construction-time.

NOTE:: The given system identifier is not read, but ignored.

Parameters:
ignored - is ignored
Throws:
org.xml.sax.SAXException - A SAX exception, possibly wrapping a XMLStreamException

parse

private void parse()
            throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

parseInternal

protected abstract void parseInternal()
                               throws org.xml.sax.SAXException,
                                      javax.xml.stream.XMLStreamException
Template-method that parses the StAX reader passed at construction-time.

Throws:
org.xml.sax.SAXException
javax.xml.stream.XMLStreamException

startPrefixMapping

protected void startPrefixMapping(java.lang.String prefix,
                                  java.lang.String namespace)
                           throws org.xml.sax.SAXException
Starts the prefix mapping for the given prefix.

Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.startPrefixMapping(String, String)

endPrefixMapping

protected void endPrefixMapping(java.lang.String prefix)
                         throws org.xml.sax.SAXException
Ends the prefix mapping for the given prefix.

Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.endPrefixMapping(String)