APIdia Launch Partner
Top Description Fields Constructors Methods
javax.xml.transform.stax

public Class StAXSource

extends Object
implements Source
Class Inheritance
All Implemented Interfaces
javax.xml.transform.Source
Imports
javax.xml.stream.XMLEventReader, .XMLStreamConstants, .XMLStreamException, .XMLStreamReader, javax.xml.stream.events.XMLEvent, javax.xml.transform.Source

Acts as a holder for an XML Source in the form of a StAX reader,i.e. XMLStreamReader or XMLEventReader. StAXSource can be used in all cases that accept a Source, e.g. javax.xml.transform.Transformer, javax.xml.validation.Validator which accept Source as input.

StAXSources are consumed during processing and are not reusable.

Authors
Neeraj Bajaj, Jeff Suttor
Since
1.6
See Also
JSR 173: Streaming API for XML, XMLStreamReader, XMLEventReader

Field Summary

Modifier and TypeField and Description
public static final String
FEATURE

If javax.xml.transform.TransformerFactory#getFeature(String name) returns true when passed this value as an argument, the Transformer supports Source input of this type.

private String
systemId

System identifier of source input.

private XMLEventReader
xmlEventReader

XMLEventReader to be used for source input.

private XMLStreamReader
xmlStreamReader

XMLStreamReader to be used for source input.

Constructor Summary

AccessConstructor and Description
public
StAXSource(final XMLEventReader
XMLEventReader used to create this StAXSource.
xmlEventReader
)

Creates a new instance of a StAXSource by supplying an XMLEventReader.

public
StAXSource(final XMLStreamReader
XMLStreamReader used to create this StAXSource.
xmlStreamReader
)

Creates a new instance of a StAXSource by supplying an XMLStreamReader.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

System identifier used by this StAXSource.
getSystemId
()

Implements javax.xml.transform.Source.getSystemId.

Get the system identifier used by this StAXSource.

public XMLEventReader

Returns:

XMLEventReader used by this StAXSource.
getXMLEventReader
()

Get the XMLEventReader used by this StAXSource.

public XMLStreamReader

Returns:

XMLStreamReader used by this StAXSource.
getXMLStreamReader
()

Get the XMLStreamReader used by this StAXSource.

public boolean

Returns:

unconditionally false
isEmpty
()

Overrides default javax.xml.transform.Source.isEmpty.

Indicates whether the StAXSource object is empty.

public void
setSystemId(final String
Ignored.
systemId
)

Implements javax.xml.transform.Source.setSystemId.

In the context of a StAXSource, it is not appropriate to explicitly set the system identifier.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FEATUREback to summary
public static final String FEATURE

If javax.xml.transform.TransformerFactory#getFeature(String name) returns true when passed this value as an argument, the Transformer supports Source input of this type.

systemIdback to summary
private String systemId

System identifier of source input.

xmlEventReaderback to summary
private XMLEventReader xmlEventReader

XMLEventReader to be used for source input.

xmlStreamReaderback to summary
private XMLStreamReader xmlStreamReader

XMLStreamReader to be used for source input.

Constructor Detail

StAXSourceback to summary
public StAXSource(final XMLEventReader xmlEventReader) throws XMLStreamException

Creates a new instance of a StAXSource by supplying an XMLEventReader.

XMLEventReader must be a non-null reference.

XMLEventReader must be in XMLStreamConstants#START_DOCUMENT or XMLStreamConstants#START_ELEMENT state.

Parameters
xmlEventReader:XMLEventReader

XMLEventReader used to create this StAXSource.

Exceptions
XMLStreamException:
If xmlEventReader access throws an Exception.
IllegalArgumentException:
If xmlEventReader == null.
IllegalStateException:
If xmlEventReader is not in XMLStreamConstants.START_DOCUMENT or XMLStreamConstants.START_ELEMENT state.
StAXSourceback to summary
public StAXSource(final XMLStreamReader xmlStreamReader)

Creates a new instance of a StAXSource by supplying an XMLStreamReader.

XMLStreamReader must be a non-null reference.

XMLStreamReader must be in XMLStreamConstants#START_DOCUMENT or XMLStreamConstants#START_ELEMENT state.

Parameters
xmlStreamReader:XMLStreamReader

XMLStreamReader used to create this StAXSource.

Exceptions
IllegalArgumentException:
If xmlStreamReader == null.
IllegalStateException:
If xmlStreamReader is not in XMLStreamConstants.START_DOCUMENT or XMLStreamConstants.START_ELEMENT state.

Method Detail

getSystemIdback to summary
public String getSystemId()

Implements javax.xml.transform.Source.getSystemId.

Get the system identifier used by this StAXSource.

The XMLStreamReader or XMLEventReader used to construct this StAXSource is queried to determine the system identifier of the XML source.

The system identifier may be null or an empty "" String.

Returns:String

System identifier used by this StAXSource.

Annotations
@Override
getXMLEventReaderback to summary
public XMLEventReader getXMLEventReader()

Get the XMLEventReader used by this StAXSource.

XMLEventReader will be null. if this StAXSource was created with a XMLStreamReader.

Returns:XMLEventReader

XMLEventReader used by this StAXSource.

getXMLStreamReaderback to summary
public XMLStreamReader getXMLStreamReader()

Get the XMLStreamReader used by this StAXSource.

XMLStreamReader will be null if this StAXSource was created with a XMLEventReader.

Returns:XMLStreamReader

XMLStreamReader used by this StAXSource.

isEmptyback to summary
public boolean isEmpty()

Overrides default javax.xml.transform.Source.isEmpty.

Indicates whether the StAXSource object is empty. Since a StAXSource object can never be empty, this method always returns false.

Returns:boolean

unconditionally false

Annotations
@Override
setSystemIdback to summary
public void setSystemId(final String systemId)

Implements javax.xml.transform.Source.setSystemId.

In the context of a StAXSource, it is not appropriate to explicitly set the system identifier. The XMLStreamReader or XMLEventReader used to construct this StAXSource determines the system identifier of the XML source.

An UnsupportedOperationException is always thrown by this method.

Parameters
systemId:String

Ignored.

Annotations
@Override
Exceptions
UnsupportedOperationException:
Is always thrown by this method.