Package org.codehaus.stax2.io
Class Stax2Source
- java.lang.Object
-
- org.codehaus.stax2.io.Stax2Source
-
- All Implemented Interfaces:
javax.xml.transform.Source
- Direct Known Subclasses:
Stax2BlockSource,Stax2ReferentialSource
public abstract class Stax2Source extends java.lang.Object implements javax.xml.transform.SourceThis is the base class for additional input sources (implementations ofSource) that Stax2XMLInputFactory2implementations 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, anInputStreamis the most natural access method.Other things to note about using result
Readers andInputStreams:- 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.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedStax2Source()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.io.InputStreamconstructInputStream()This method creates anInputStreamvia which underlying input source can be accessed.abstract java.io.ReaderconstructReader()This method creates aReadervia which underlying input source can be accessed.java.lang.StringgetEncoding()java.lang.StringgetPublicId()abstract java.net.URLgetReference()java.lang.StringgetSystemId()voidsetEncoding(java.lang.String enc)voidsetPublicId(java.lang.String id)voidsetSystemId(java.lang.String id)
-
-
-
Method Detail
-
getSystemId
public java.lang.String getSystemId()
- Specified by:
getSystemIdin interfacejavax.xml.transform.Source
-
setSystemId
public void setSystemId(java.lang.String id)
- Specified by:
setSystemIdin interfacejavax.xml.transform.Source
-
getPublicId
public java.lang.String getPublicId()
-
setPublicId
public void setPublicId(java.lang.String id)
-
getEncoding
public java.lang.String getEncoding()
-
setEncoding
public void setEncoding(java.lang.String enc)
-
getReference
public abstract java.net.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 java.io.Reader constructReader() throws java.io.IOExceptionThis 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:
java.io.IOException
-
constructInputStream
public abstract java.io.InputStream constructInputStream() throws java.io.IOExceptionThis 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:
java.io.IOException
-
-