Top Description Fields Constructors Methods
org.springframework.util.xml

pack-priv Class StaxResult

extends SAXResult
Class Inheritance
Imports
javax.xml.stream.XMLEventWriter, .XMLStreamWriter, javax.xml.transform.sax.SAXResult, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.springframework.lang.Nullable

Implementation of the Result tagging interface for StAX writers. Can be constructed with an XMLEventConsumer or an 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 backwards 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 getHandler() to parse an input source using an XMLReader. Calling setHandler(org.xml.sax.ContentHandler) or setLexicalHandler(org.xml.sax.ext.LexicalHandler) will result in UnsupportedOperationExceptions.

Author
Arjen Poutsma
Since
3.0
See Also
XMLEventWriter, XMLStreamWriter, javax.xml.transform.Transformer

Field Summary

Modifier and TypeField and Description
private XMLEventWriter
private XMLStreamWriter
Inherited from javax.xml.transform.sax.SAXResult:
FEATURE

Constructor Summary

AccessConstructor and Description
public
StaxResult(XMLEventWriter
the XMLEventWriter to write to
eventWriter
)

Construct a new instance of the StaxResult with the specified XMLEventWriter.

public
StaxResult(XMLStreamWriter
the XMLStreamWriter to write to
streamWriter
)

Construct a new instance of the StaxResult with the specified XMLStreamWriter.

Method Summary

Modifier and TypeMethod and Description
public XMLEventWriter

Returns:

the StAX event writer used by this result
getXMLEventWriter
()

Return the XMLEventWriter used by this StaxResult.

public XMLStreamWriter

Returns:

the StAX stream writer used by this result
getXMLStreamWriter
()

Return the XMLStreamWriter used by this StaxResult.

public void
setHandler(ContentHandler
Must be a non-null ContentHandler reference.
handler
)

Overrides javax.xml.transform.sax.SAXResult.setHandler.

Throws an UnsupportedOperationException.

public void
setLexicalHandler(LexicalHandler
A non-null LexicalHandler for handling lexical parse events.
handler
)

Overrides javax.xml.transform.sax.SAXResult.setLexicalHandler.

Throws an UnsupportedOperationException.

Inherited from javax.xml.transform.sax.SAXResult:
getHandlergetLexicalHandlergetSystemIdsetSystemId

Field Detail

eventWriterback to summary
private XMLEventWriter eventWriter
Annotations
@Nullable
streamWriterback to summary
private XMLStreamWriter streamWriter
Annotations
@Nullable

Constructor Detail

StaxResultback to summary
public StaxResult(XMLEventWriter eventWriter)

Construct a new instance of the StaxResult with the specified XMLEventWriter.

Parameters
eventWriter:XMLEventWriter

the XMLEventWriter to write to

StaxResultback to summary
public StaxResult(XMLStreamWriter streamWriter)

Construct a new instance of the StaxResult with the specified XMLStreamWriter.

Parameters
streamWriter:XMLStreamWriter

the XMLStreamWriter to write to

Method Detail

getXMLEventWriterback to summary
public XMLEventWriter getXMLEventWriter()

Return the XMLEventWriter used by this StaxResult.

If this StaxResult was created with an XMLStreamWriter, the result will be null.

Returns:XMLEventWriter

the StAX event writer used by this result

Annotations
@Nullable
See Also
StaxResult(javax.xml.stream.XMLEventWriter)
getXMLStreamWriterback to summary
public XMLStreamWriter getXMLStreamWriter()

Return the XMLStreamWriter used by this StaxResult.

If this StaxResult was created with an XMLEventConsumer, the result will be null.

Returns:XMLStreamWriter

the StAX stream writer used by this result

Annotations
@Nullable
See Also
StaxResult(javax.xml.stream.XMLStreamWriter)
setHandlerback to summary
public void setHandler(ContentHandler handler)

Overrides javax.xml.transform.sax.SAXResult.setHandler.

Throws an UnsupportedOperationException.

Parameters
handler:ContentHandler

Doc from javax.xml.transform.sax.SAXResult.setHandler.

Must be a non-null ContentHandler reference.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always
setLexicalHandlerback to summary
public void setLexicalHandler(LexicalHandler handler)

Overrides javax.xml.transform.sax.SAXResult.setLexicalHandler.

Throws an UnsupportedOperationException.

Parameters
handler:LexicalHandler

Doc from javax.xml.transform.sax.SAXResult.setLexicalHandler.

A non-null LexicalHandler for handling lexical parse events.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always