StAXSource (Java SE 9 & JDK 9 ) (original) (raw)
- javax.xml.transform.stax.StAXSource
All Implemented Interfaces:
[Source](../../../../javax/xml/transform/Source.html "interface in javax.xml.transform")
public class StAXSource
extends Object
implements 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. Transformer,Validator which acceptSource
as input.StAXSource
s are consumed during processing and are not reusable.
Since:
1.6
See Also:
JSR 173: Streaming API for XML, XMLStreamReader, XMLEventReader
Field Summary
Fields
Modifier and Type Field Description static String FEATURE If TransformerFactory.getFeature(String name) returns true when passed this value as an argument, the Transformer supports Source input of this type. Constructor Summary
Constructors
Constructor Description StAXSource(XMLEventReader xmlEventReader) Creates a new instance of a StAXSource by supplying an XMLEventReader. StAXSource(XMLStreamReader xmlStreamReader) Creates a new instance of a StAXSource by supplying an XMLStreamReader. Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type Method Description String getSystemId() Get the system identifier used by thisStAXSource. XMLEventReader getXMLEventReader() Get the XMLEventReader used by thisStAXSource. XMLStreamReader getXMLStreamReader() Get the XMLStreamReader used by thisStAXSource. boolean isEmpty() Indicates whether the StAXSource object is empty. void setSystemId(String systemId) In the context of a StAXSource, it is not appropriate to explicitly set the system identifier. * ### Methods inherited from class java.lang.[Object](../../../../java/lang/Object.html "class in java.lang") `[clone](../../../../java/lang/Object.html#clone--), [equals](../../../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../../../java/lang/Object.html#finalize--), [getClass](../../../../java/lang/Object.html#getClass--), [hashCode](../../../../java/lang/Object.html#hashCode--), [notify](../../../../java/lang/Object.html#notify--), [notifyAll](../../../../java/lang/Object.html#notifyAll--), [toString](../../../../java/lang/Object.html#toString--), [wait](../../../../java/lang/Object.html#wait--), [wait](../../../../java/lang/Object.html#wait-long-), [wait](../../../../java/lang/Object.html#wait-long-int-)`
Field Detail
* #### FEATURE public static final [String](../../../../java/lang/String.html "class in java.lang") FEATURE See Also: [Constant Field Values](../../../../constant-values.html#javax.xml.transform.stax.StAXSource.FEATURE)
Constructor Detail
* #### StAXSource public StAXSource([XMLEventReader](../../../../javax/xml/stream/XMLEventReader.html "interface in javax.xml.stream") xmlEventReader) throws [XMLStreamException](../../../../javax/xml/stream/XMLStreamException.html "class in javax.xml.stream") Parameters: `xmlEventReader` \- `XMLEventReader` used to create this `StAXSource`. Throws: `[XMLStreamException](../../../../javax/xml/stream/XMLStreamException.html "class in javax.xml.stream")` \- If `xmlEventReader` access throws an `Exception`. `[IllegalArgumentException](../../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- If `xmlEventReader` \==`null`. `[IllegalStateException](../../../../java/lang/IllegalStateException.html "class in java.lang")` \- If `xmlEventReader` is not in `XMLStreamConstants.START_DOCUMENT` or`XMLStreamConstants.START_ELEMENT` state. * #### StAXSource public StAXSource([XMLStreamReader](../../../../javax/xml/stream/XMLStreamReader.html "interface in javax.xml.stream") xmlStreamReader) Parameters: `xmlStreamReader` \- `XMLStreamReader` used to create this `StAXSource`. Throws: `[IllegalArgumentException](../../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- If `xmlStreamReader` \==`null`. `[IllegalStateException](../../../../java/lang/IllegalStateException.html "class in java.lang")` \- If `xmlStreamReader` is not in `XMLStreamConstants.START_DOCUMENT` or`XMLStreamConstants.START_ELEMENT` state.
Method Detail
* #### getXMLEventReader public [XMLEventReader](../../../../javax/xml/stream/XMLEventReader.html "interface in javax.xml.stream") getXMLEventReader() Get the `XMLEventReader` used by this`StAXSource`. `XMLEventReader` will be `null`. if this `StAXSource` was created with a`XMLStreamReader`. Returns: `XMLEventReader` used by this`StAXSource`. * #### getXMLStreamReader public [XMLStreamReader](../../../../javax/xml/stream/XMLStreamReader.html "interface in javax.xml.stream") getXMLStreamReader() Get the `XMLStreamReader` used by this`StAXSource`. `XMLStreamReader` will be `null` if this `StAXSource` was created with a`XMLEventReader`. Returns: `XMLStreamReader` used by this`StAXSource`. * #### setSystemId public void setSystemId([String](../../../../java/lang/String.html "class in java.lang") systemId) 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](../../../../java/lang/UnsupportedOperationException.html "class in java.lang") is **always** thrown by this method. Specified by: `[setSystemId](../../../../javax/xml/transform/Source.html#setSystemId-java.lang.String-)` in interface `[Source](../../../../javax/xml/transform/Source.html "interface in javax.xml.transform")` Parameters: `systemId` \- Ignored. Throws: `[UnsupportedOperationException](../../../../java/lang/UnsupportedOperationException.html "class in java.lang")` \- Is **always** thrown by this method. * #### getSystemId public [String](../../../../java/lang/String.html "class in java.lang") 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`. Specified by: `[getSystemId](../../../../javax/xml/transform/Source.html#getSystemId--)` in interface `[Source](../../../../javax/xml/transform/Source.html "interface in javax.xml.transform")` Returns: System identifier used by this `StAXSource`. * #### isEmpty public boolean isEmpty() Indicates whether the `StAXSource` object is empty. Since a`StAXSource` object can never be empty, this method always returns false. Specified by: `[isEmpty](../../../../javax/xml/transform/Source.html#isEmpty--)` in interface `[Source](../../../../javax/xml/transform/Source.html "interface in javax.xml.transform")` Returns: unconditionally false
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.