org.springframework.util.xml
Class StaxResult

java.lang.Object
  extended by javax.xml.transform.sax.SAXResult
      extended by org.springframework.util.xml.StaxResult
All Implemented Interfaces:
javax.xml.transform.Result

 class StaxResult
extends javax.xml.transform.sax.SAXResult

Implementation of the Result tagging interface for StAX writers. Can be constructed with a XMLEventConsumer or a XMLStreamWriter.

This class is necessary because there is no implementation of Source for StaxReaders in JAXP 1.3. There is a StAXResult in JAXP 1.4 (JDK 1.6), but this class is kept around for back-ward compatibility reasons.

Even though StaxResult extends from SAXResult, calling the methods of SAXResult is not supported. In general, the only supported operation on this class is to use the ContentHandler obtained via SAXResult.getHandler() to parse an input source using an XMLReader. Calling setHandler(org.xml.sax.ContentHandler) will result in UnsupportedOperationExceptions.

Since:
3.0
Author:
Arjen Poutsma
See Also:
XMLEventWriter, XMLStreamWriter, Transformer

Field Summary
private  javax.xml.stream.XMLEventWriter eventWriter
           
private  javax.xml.stream.XMLStreamWriter streamWriter
           
 
Fields inherited from class javax.xml.transform.sax.SAXResult
FEATURE
 
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
 
Constructor Summary
StaxResult(javax.xml.stream.XMLEventWriter eventWriter)
          Constructs a new instance of the StaxResult with the specified XMLEventWriter.
StaxResult(javax.xml.stream.XMLEventWriter eventWriter, javax.xml.stream.XMLEventFactory eventFactory)
          Constructs a new instance of the StaxResult with the specified XMLEventWriter and XMLEventFactory.
StaxResult(javax.xml.stream.XMLStreamWriter streamWriter)
          Constructs a new instance of the StaxResult with the specified XMLStreamWriter.
 
Method Summary
(package private)  javax.xml.stream.XMLEventWriter getXMLEventWriter()
          Returns the XMLEventWriter used by this StaxResult.
(package private)  javax.xml.stream.XMLStreamWriter getXMLStreamWriter()
          Returns the XMLStreamWriter used by this StaxResult.
 void setHandler(org.xml.sax.ContentHandler handler)
          Throws a UnsupportedOperationException.
 
Methods inherited from class javax.xml.transform.sax.SAXResult
getHandler, getLexicalHandler, getSystemId, setLexicalHandler, setSystemId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventWriter

private javax.xml.stream.XMLEventWriter eventWriter

streamWriter

private javax.xml.stream.XMLStreamWriter streamWriter
Constructor Detail

StaxResult

StaxResult(javax.xml.stream.XMLStreamWriter streamWriter)
Constructs a new instance of the StaxResult with the specified XMLStreamWriter.

Parameters:
streamWriter - the XMLStreamWriter to write to

StaxResult

StaxResult(javax.xml.stream.XMLEventWriter eventWriter)
Constructs a new instance of the StaxResult with the specified XMLEventWriter.

Parameters:
eventWriter - the XMLEventWriter to write to

StaxResult

StaxResult(javax.xml.stream.XMLEventWriter eventWriter,
           javax.xml.stream.XMLEventFactory eventFactory)
Constructs a new instance of the StaxResult with the specified XMLEventWriter and XMLEventFactory.

Parameters:
eventWriter - the XMLEventWriter to write to
eventFactory - the XMLEventFactory to use for creating events
Method Detail

getXMLEventWriter

javax.xml.stream.XMLEventWriter getXMLEventWriter()
Returns the XMLEventWriter used by this StaxResult. If this StaxResult was created with an XMLStreamWriter, the result will be null.

Returns:
the StAX event writer used by this result
See Also:
StaxResult(javax.xml.stream.XMLEventWriter)

getXMLStreamWriter

javax.xml.stream.XMLStreamWriter getXMLStreamWriter()
Returns the XMLStreamWriter used by this StaxResult. If this StaxResult was created with an XMLEventConsumer, the result will be null.

Returns:
the StAX stream writer used by this result
See Also:
StaxResult(javax.xml.stream.XMLStreamWriter)

setHandler

public void setHandler(org.xml.sax.ContentHandler handler)
Throws a UnsupportedOperationException.

Overrides:
setHandler in class javax.xml.transform.sax.SAXResult
Throws:
java.lang.UnsupportedOperationException - always