Package org.codehaus.stax2.io
Class Stax2Source
- java.lang.Object
-
- org.codehaus.stax2.io.Stax2Source
-
- All Implemented Interfaces:
Source
- Direct Known Subclasses:
Stax2BlockSource
,Stax2ReferentialSource
public abstract class Stax2Source extends Object implements Source
This is the base class for additional input sources (implementations ofSource
) that Stax2XMLInputFactory2
implementations should support.Note about usage by the parser factory implementations: the expectation is that at least one of methods
constructReader()
andconstructInputStream()
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 viaReader
. For a byte array, on the other hand, anInputStream
is the most natural access method.Other things to note about using result
Reader
s andInputStream
s:- Caller is responsible for closing any
Reader
andInputStream
instances 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.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Stax2Source()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract InputStream
constructInputStream()
This method creates anInputStream
via which underlying input source can be accessed.abstract Reader
constructReader()
This method creates aReader
via which underlying input source can be accessed.String
getEncoding()
String
getPublicId()
abstract URL
getReference()
String
getSystemId()
void
setEncoding(String enc)
void
setPublicId(String id)
void
setSystemId(String id)
-
-
-
Method Detail
-
getSystemId
public String getSystemId()
- Specified by:
getSystemId
in interfaceSource
-
setSystemId
public void setSystemId(String id)
- Specified by:
setSystemId
in interfaceSource
-
getPublicId
public String getPublicId()
-
setPublicId
public void setPublicId(String id)
-
getEncoding
public String getEncoding()
-
setEncoding
public void setEncoding(String enc)
-
getReference
public abstract URL 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
public abstract Reader constructReader() throws IOException
This method creates aReader
via 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
public abstract InputStream constructInputStream() throws IOException
This method creates anInputStream
via which underlying input source can be accessed. Note that caller is responsible for closing that InputSource when it is done reading it- Throws:
IOException
-
-