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

pack-priv Class StaxSource

extends SAXSource
Class Inheritance
Imports
javax.xml.stream.XMLEventReader, .XMLStreamReader, javax.xml.transform.sax.SAXSource, org.xml.sax.InputSource, .XMLReader, org.springframework.lang.Nullable

Implementation of the Source tagging interface for StAX readers. Can be constructed with an XMLEventReader or an XMLStreamReader.

This class is necessary because there is no implementation of Source for StAX Readers in JAXP 1.3. There is a StAXSource in JAXP 1.4 (JDK 1.6), but this class is kept around for backwards compatibility reasons.

Even though StaxSource extends from SAXSource, calling the methods of SAXSource is not supported. In general, the only supported operation on this class is to use the XMLReader obtained via getXMLReader() to parse the input source obtained via getInputSource(). Calling setXMLReader(XMLReader) or setInputSource(InputSource) will result in UnsupportedOperationException #setInputSource(InputSource) will result in UnsupportedOperationExceptions.

Author
Arjen Poutsma
Since
3.0
See Also
XMLEventReader, XMLStreamReader, javax.xml.transform.Transformer

Field Summary

Modifier and TypeField and Description
private XMLEventReader
private XMLStreamReader
Inherited from javax.xml.transform.sax.SAXSource:
FEATURE

Constructor Summary

AccessConstructor and Description
pack-priv
StaxSource(XMLEventReader
the XMLEventReader to read from
eventReader
)

Construct a new instance of the StaxSource with the specified XMLEventReader.

pack-priv
StaxSource(XMLStreamReader
the XMLStreamReader to read from
streamReader
)

Construct a new instance of the StaxSource with the specified XMLStreamReader.

Method Summary

Modifier and TypeMethod and Description
pack-priv XMLEventReader

Returns:

the StAX event reader used by this source
getXMLEventReader
()

Return the XMLEventReader used by this StaxSource.

pack-priv XMLStreamReader

Returns:

the StAX event reader used by this source
getXMLStreamReader
()

Return the XMLStreamReader used by this StaxSource.

public void
setInputSource(InputSource
A valid InputSource reference.
inputSource
)

Overrides javax.xml.transform.sax.SAXSource.setInputSource.

Throws an UnsupportedOperationException.

public void
setXMLReader(XMLReader
A valid XMLReader or XMLFilter reference.
reader
)

Overrides javax.xml.transform.sax.SAXSource.setXMLReader.

Throws an UnsupportedOperationException.

Inherited from javax.xml.transform.sax.SAXSource:
getInputSourcegetSystemIdgetXMLReaderisEmptysetSystemIdsourceToInputSource

Field Detail

eventReaderback to summary
private XMLEventReader eventReader
Annotations
@Nullable
streamReaderback to summary
private XMLStreamReader streamReader
Annotations
@Nullable

Constructor Detail

StaxSourceback to summary
pack-priv StaxSource(XMLEventReader eventReader)

Construct a new instance of the StaxSource with the specified XMLEventReader. The supplied event reader must be in XMLStreamConstants.START_DOCUMENT or XMLStreamConstants.START_ELEMENT state.

Parameters
eventReader:XMLEventReader

the XMLEventReader to read from

Exceptions
IllegalStateException:
if the reader is not at the start of a document or element
StaxSourceback to summary
pack-priv StaxSource(XMLStreamReader streamReader)

Construct a new instance of the StaxSource with the specified XMLStreamReader. The supplied stream reader must be in XMLStreamConstants.START_DOCUMENT or XMLStreamConstants.START_ELEMENT state.

Parameters
streamReader:XMLStreamReader

the XMLStreamReader to read from

Exceptions
IllegalStateException:
if the reader is not at the start of a document or element

Method Detail

getXMLEventReaderback to summary
pack-priv XMLEventReader getXMLEventReader()

Return the XMLEventReader used by this StaxSource.

If this StaxSource was created with an XMLStreamReader, the result will be null.

Returns:XMLEventReader

the StAX event reader used by this source

Annotations
@Nullable
See Also
StaxSource#StaxSource(javax.xml.stream.XMLEventReader)
getXMLStreamReaderback to summary
pack-priv XMLStreamReader getXMLStreamReader()

Return the XMLStreamReader used by this StaxSource.

If this StaxSource was created with an XMLEventReader, the result will be null.

Returns:XMLStreamReader

the StAX event reader used by this source

Annotations
@Nullable
See Also
StaxSource#StaxSource(javax.xml.stream.XMLEventReader)
setInputSourceback to summary
public void setInputSource(InputSource inputSource)

Overrides javax.xml.transform.sax.SAXSource.setInputSource.

Throws an UnsupportedOperationException.

Parameters
inputSource:InputSource

Doc from javax.xml.transform.sax.SAXSource.setInputSource.

A valid InputSource reference.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always
setXMLReaderback to summary
public void setXMLReader(XMLReader reader)

Overrides javax.xml.transform.sax.SAXSource.setXMLReader.

Throws an UnsupportedOperationException.

Parameters
reader:XMLReader

Doc from javax.xml.transform.sax.SAXSource.setXMLReader.

A valid XMLReader or XMLFilter reference.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always