org.springframework.util.xml
Class AbstractStaxContentHandler

java.lang.Object
  extended by org.springframework.util.xml.AbstractStaxContentHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler
Direct Known Subclasses:
StaxEventContentHandler, StaxStreamContentHandler

abstract class AbstractStaxContentHandler
extends java.lang.Object
implements org.xml.sax.ContentHandler

Abstract base class for SAX ContentHandler implementations that use StAX as a basis. All methods delegate to internal template methods, capable of throwing a XMLStreamException. Additionally, an namespace context is used to keep track of declared namespaces.

Since:
3.0
Author:
Arjen Poutsma

Field Summary
private  SimpleNamespaceContext namespaceContext
           
private  boolean namespaceContextChanged
           
 
Constructor Summary
AbstractStaxContentHandler()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
protected abstract  void charactersInternal(char[] ch, int start, int length)
           
 void endDocument()
           
protected abstract  void endDocumentInternal()
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
protected abstract  void endElementInternal(javax.xml.namespace.QName name, SimpleNamespaceContext namespaceContext)
           
 void endPrefixMapping(java.lang.String prefix)
          Removes the binding for the given prefix.
 void ignorableWhitespace(char[] ch, int start, int length)
           
protected abstract  void ignorableWhitespaceInternal(char[] ch, int start, int length)
           
 void processingInstruction(java.lang.String target, java.lang.String data)
           
protected abstract  void processingInstructionInternal(java.lang.String target, java.lang.String data)
           
 void skippedEntity(java.lang.String name)
           
protected abstract  void skippedEntityInternal(java.lang.String name)
           
 void startDocument()
           
protected abstract  void startDocumentInternal()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
           
protected abstract  void startElementInternal(javax.xml.namespace.QName name, org.xml.sax.Attributes atts, SimpleNamespaceContext namespaceContext)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Binds the given prefix to the given namespaces.
protected  javax.xml.namespace.QName toQName(java.lang.String namespaceUri, java.lang.String qualifiedName)
          Convert a namespace URI and DOM or SAX qualified name to a QName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
setDocumentLocator
 

Field Detail

namespaceContext

private SimpleNamespaceContext namespaceContext

namespaceContextChanged

private boolean namespaceContextChanged
Constructor Detail

AbstractStaxContentHandler

AbstractStaxContentHandler()
Method Detail

startDocument

public final void startDocument()
                         throws org.xml.sax.SAXException
Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startDocumentInternal

protected abstract void startDocumentInternal()
                                       throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

endDocument

public final void endDocument()
                       throws org.xml.sax.SAXException
Specified by:
endDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endDocumentInternal

protected abstract void endDocumentInternal()
                                     throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

startPrefixMapping

public final void startPrefixMapping(java.lang.String prefix,
                                     java.lang.String uri)
Binds the given prefix to the given namespaces.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
See Also:
SimpleNamespaceContext.bindNamespaceUri(String,String)

endPrefixMapping

public final void endPrefixMapping(java.lang.String prefix)
Removes the binding for the given prefix.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
See Also:
SimpleNamespaceContext.removeBinding(String)

startElement

public final void startElement(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.String qName,
                               org.xml.sax.Attributes atts)
                        throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startElementInternal

protected abstract void startElementInternal(javax.xml.namespace.QName name,
                                             org.xml.sax.Attributes atts,
                                             SimpleNamespaceContext namespaceContext)
                                      throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

endElement

public final void endElement(java.lang.String uri,
                             java.lang.String localName,
                             java.lang.String qName)
                      throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endElementInternal

protected abstract void endElementInternal(javax.xml.namespace.QName name,
                                           SimpleNamespaceContext namespaceContext)
                                    throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

characters

public final void characters(char[] ch,
                             int start,
                             int length)
                      throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

charactersInternal

protected abstract void charactersInternal(char[] ch,
                                           int start,
                                           int length)
                                    throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

ignorableWhitespace

public final void ignorableWhitespace(char[] ch,
                                      int start,
                                      int length)
                               throws org.xml.sax.SAXException
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

ignorableWhitespaceInternal

protected abstract void ignorableWhitespaceInternal(char[] ch,
                                                    int start,
                                                    int length)
                                             throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

processingInstruction

public final void processingInstruction(java.lang.String target,
                                        java.lang.String data)
                                 throws org.xml.sax.SAXException
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

processingInstructionInternal

protected abstract void processingInstructionInternal(java.lang.String target,
                                                      java.lang.String data)
                                               throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

skippedEntity

public final void skippedEntity(java.lang.String name)
                         throws org.xml.sax.SAXException
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

toQName

protected javax.xml.namespace.QName toQName(java.lang.String namespaceUri,
                                            java.lang.String qualifiedName)
Convert a namespace URI and DOM or SAX qualified name to a QName. The qualified name can have the form prefix:localname or localName.

Parameters:
namespaceUri - the namespace URI
qualifiedName - the qualified name
Returns:
a QName

skippedEntityInternal

protected abstract void skippedEntityInternal(java.lang.String name)
                                       throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException