org.codehaus.stax2.io
Class Stax2Source

java.lang.Object
  extended by 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 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:


Field Summary
protected  String mEncoding
           
protected  String mPublicId
           
protected  String mSystemId
           
 
Constructor Summary
protected Stax2Source()
           
 
Method Summary
abstract  InputStream constructInputStream()
          This method creates an InputStream via which underlying input source can be accessed.
abstract  Reader constructReader()
          This method creates a Reader 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mSystemId

protected String mSystemId

mPublicId

protected String mPublicId

mEncoding

protected String mEncoding
Constructor Detail

Stax2Source

protected Stax2Source()
Method Detail

getSystemId

public String getSystemId()
Specified by:
getSystemId in interface Source

setSystemId

public void setSystemId(String id)
Specified by:
setSystemId in interface Source

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 a Reader 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 an InputStream 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