Package org.codehaus.stax2.io
Class Stax2Source
java.lang.Object
org.codehaus.stax2.io.Stax2Source
- All Implemented Interfaces:
Source
- Direct Known Subclasses:
Stax2BlockSource,Stax2ReferentialSource
This is the base class for additional input sources (implementations
of
Source) that Stax2
XMLInputFactory2 implementations should support.
Note about usage by the parser factory implementations: the expectation
is that at least one of methods constructReader() and
constructInputStream() will succeed, but not necessarily both.
This generally depends on type of resource being represented: for example,
if the source is a String or character array, it is most naturally
represent via Reader. For a byte array, on the other hand,
an InputStream is the most natural access method.
Other things to note about using result Readers and
InputStreams:
- Caller is responsible for closing any
ReaderandInputStreaminstances requested. That is, caller owns these accessor objects. - Source objects are only required to return a non-null object once: after this, if new non-null instances are returned, they must not be the same objects as returned earlier. Implementations can choose to construct new instances to the same backing data structure or resource; if so, they should document this behavior.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract InputStreamThis method creates anInputStreamvia which underlying input source can be accessed.abstract ReaderThis method creates aReadervia which underlying input source can be accessed.abstract URLvoidsetEncoding(String enc) voidsetPublicId(String id) voidsetSystemId(String id)
-
Field Details
-
mSystemId
-
mPublicId
-
mEncoding
-
-
Constructor Details
-
Stax2Source
protected Stax2Source()
-
-
Method Details
-
getSystemId
- Specified by:
getSystemIdin interfaceSource
-
setSystemId
- Specified by:
setSystemIdin interfaceSource
-
getPublicId
-
setPublicId
-
getEncoding
-
setEncoding
-
getReference
- Returns:
- URL that can be used to resolve references originating from the content read via this source; may be null if not known (which is the case for most non-referential sources)
-
constructReader
This method creates aReadervia which underlying input source can be accessed. Note that caller is responsible for closing that Reader when it is done reading it.- Throws:
IOException
-
constructInputStream
This method creates anInputStreamvia which underlying input source can be accessed. Note that caller is responsible for closing that InputSource when it is done reading it- Throws:
IOException
-