org.springframework.util.xml
Class StaxEventContentHandler

java.lang.Object
  extended by org.springframework.util.xml.AbstractStaxContentHandler
      extended by org.springframework.util.xml.StaxEventContentHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler

 class StaxEventContentHandler
extends AbstractStaxContentHandler

SAX ContentHandler that transforms callback calls to XMLEvents and writes them to a XMLEventConsumer.

Since:
3.0
Author:
Arjen Poutsma
See Also:
XMLEvent, XMLEventConsumer

Field Summary
private  javax.xml.stream.util.XMLEventConsumer eventConsumer
           
private  javax.xml.stream.XMLEventFactory eventFactory
           
 
Constructor Summary
StaxEventContentHandler(javax.xml.stream.util.XMLEventConsumer consumer)
          Constructs a new instance of the StaxEventContentHandler that writes to the given XMLEventConsumer.
StaxEventContentHandler(javax.xml.stream.util.XMLEventConsumer consumer, javax.xml.stream.XMLEventFactory factory)
          Constructs a new instance of the StaxEventContentHandler that uses the given event factory to create events and writes to the given XMLEventConsumer.
 
Method Summary
protected  void charactersInternal(char[] ch, int start, int length)
           
private  void consumeEvent(javax.xml.stream.events.XMLEvent event)
           
private  java.util.List<javax.xml.stream.events.Namespace> createNamespaces(SimpleNamespaceContext namespaceContext)
          Creates and returns a list of NameSpace objects from the NamespaceContext.
protected  void endDocumentInternal()
           
protected  void endElementInternal(javax.xml.namespace.QName name, SimpleNamespaceContext namespaceContext)
           
private  java.util.List<javax.xml.stream.events.Attribute> getAttributes(org.xml.sax.Attributes attributes)
           
protected  void ignorableWhitespaceInternal(char[] ch, int start, int length)
           
protected  void processingInstructionInternal(java.lang.String target, java.lang.String data)
           
 void setDocumentLocator(org.xml.sax.Locator locator)
           
protected  void skippedEntityInternal(java.lang.String name)
           
protected  void startDocumentInternal()
           
protected  void startElementInternal(javax.xml.namespace.QName name, org.xml.sax.Attributes atts, SimpleNamespaceContext namespaceContext)
           
 
Methods inherited from class org.springframework.util.xml.AbstractStaxContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startElement, startPrefixMapping, toQName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventFactory

private final javax.xml.stream.XMLEventFactory eventFactory

eventConsumer

private final javax.xml.stream.util.XMLEventConsumer eventConsumer
Constructor Detail

StaxEventContentHandler

StaxEventContentHandler(javax.xml.stream.util.XMLEventConsumer consumer)
Constructs a new instance of the StaxEventContentHandler that writes to the given XMLEventConsumer. A default XMLEventFactory will be created.

Parameters:
consumer - the consumer to write events to

StaxEventContentHandler

StaxEventContentHandler(javax.xml.stream.util.XMLEventConsumer consumer,
                        javax.xml.stream.XMLEventFactory factory)
Constructs a new instance of the StaxEventContentHandler that uses the given event factory to create events and writes to the given XMLEventConsumer.

Parameters:
consumer - the consumer to write events to
factory - the factory used to create events
Method Detail

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)

startDocumentInternal

protected void startDocumentInternal()
                              throws javax.xml.stream.XMLStreamException
Specified by:
startDocumentInternal in class AbstractStaxContentHandler
Throws:
javax.xml.stream.XMLStreamException

endDocumentInternal

protected void endDocumentInternal()
                            throws javax.xml.stream.XMLStreamException
Specified by:
endDocumentInternal in class AbstractStaxContentHandler
Throws:
javax.xml.stream.XMLStreamException

startElementInternal

protected void startElementInternal(javax.xml.namespace.QName name,
                                    org.xml.sax.Attributes atts,
                                    SimpleNamespaceContext namespaceContext)
                             throws javax.xml.stream.XMLStreamException
Specified by:
startElementInternal in class AbstractStaxContentHandler
Throws:
javax.xml.stream.XMLStreamException

endElementInternal

protected void endElementInternal(javax.xml.namespace.QName name,
                                  SimpleNamespaceContext namespaceContext)
                           throws javax.xml.stream.XMLStreamException
Specified by:
endElementInternal in class AbstractStaxContentHandler
Throws:
javax.xml.stream.XMLStreamException

charactersInternal

protected void charactersInternal(char[] ch,
                                  int start,
                                  int length)
                           throws javax.xml.stream.XMLStreamException
Specified by:
charactersInternal in class AbstractStaxContentHandler
Throws:
javax.xml.stream.XMLStreamException

ignorableWhitespaceInternal

protected void ignorableWhitespaceInternal(char[] ch,
                                           int start,
                                           int length)
                                    throws javax.xml.stream.XMLStreamException
Specified by:
ignorableWhitespaceInternal in class AbstractStaxContentHandler
Throws:
javax.xml.stream.XMLStreamException

processingInstructionInternal

protected void processingInstructionInternal(java.lang.String target,
                                             java.lang.String data)
                                      throws javax.xml.stream.XMLStreamException
Specified by:
processingInstructionInternal in class AbstractStaxContentHandler
Throws:
javax.xml.stream.XMLStreamException

consumeEvent

private void consumeEvent(javax.xml.stream.events.XMLEvent event)
                   throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

createNamespaces

private java.util.List<javax.xml.stream.events.Namespace> createNamespaces(SimpleNamespaceContext namespaceContext)
Creates and returns a list of NameSpace objects from the NamespaceContext.


getAttributes

private java.util.List<javax.xml.stream.events.Attribute> getAttributes(org.xml.sax.Attributes attributes)

skippedEntityInternal

protected void skippedEntityInternal(java.lang.String name)
                              throws javax.xml.stream.XMLStreamException
Specified by:
skippedEntityInternal in class AbstractStaxContentHandler
Throws:
javax.xml.stream.XMLStreamException