This simple class describes a source of input
for an XMLReader. An
InputSource object can be passed to the
parse( ) method of XMLReader,
and is also the return value of the
EntityResolver.resolveEntity( ) method.
Create an InputSource( ) with one of the
constructor methods, specifying the system identifier (a URL) of the
file to be parsed, or specifying a byte or character stream that the
parser should read the document from. In addition to calling the
constructor, you may also want to call setSystemId(
) to specify and/or setPublicId( ) to
provide identifiers for the document being parsed. Having a filename
or URL is useful if an error arises, and your
ErrorHandler object needs to print an error
message, for example. If you specify the document to parse as a URL
or as a byte stream, you can also call setEncoding(
) to specify the character encoding of the document. The
parser will use this encoding value if you supply it, but XML
documents are supposed to describe their own encoding in the
<?xml?> declaration, so the parser ought to
be able to determine the encoding of the document even if you do not
call setEncoding( ).
This class allows you to specify more than one input source. The
XMLReader will first call
getCharacterStream( ) and use the returned
Reader if there is one. If that method returns
false, then it calls getByteStream(
) and uses the InputStream it returns.
Finally, if no character or byte stream is found, then the parser
will call getSystemId( ) and will attempt to read
an XML document from the returned URL.
An XMLReader will never use any of the
set( ) methods to modify the state of an
InputSource object.
public class InputSource {
// Public Constructors
public InputSource( );
public InputSource(java.io.Reader characterStream);
public InputSource(java.io.InputStream byteStream);
public InputSource(String systemId);
// Public Instance Methods
public java.io.InputStream getByteStream( ); default:null
public java.io.Reader getCharacterStream( ); default:null
public String getEncoding( ); default:null
public String getPublicId( ); default:null
public String getSystemId( ); default:null
public void setByteStream(java.io.InputStream byteStream);
public void setCharacterStream(java.io.Reader characterStream);
public void setEncoding(String encoding);
public void setPublicId(String publicId);
public void setSystemId(String systemId);
}
Passed To
javax.xml.parsers.DocumentBuilder.parse( ),
javax.xml.parsers.SAXParser.parse( ),
javax.xml.transform.sax.SAXSource.{SAXSource( ),
setInputSource( )},
javax.xml.xpath.XPath.evaluate( ),
javax.xml.xpath.XPathExpression.evaluate( ),
Parser.parse( ), XMLReader.parse(
), org.xml.sax.helpers.ParserAdapter.parse(
), org.xml.sax.helpers.XMLFilterImpl.parse(
), org.xml.sax.helpers.XMLReaderAdapter.parse(
)
Returned By
javax.xml.transform.sax.SAXSource.{getInputSource(
), sourceToInputSource( )},
EntityResolver.resolveEntity( ),
HandlerBase.resolveEntity( ),
org.xml.sax.ext.DefaultHandler2.{getExternalSubset(
), resolveEntity( )},
org.xml.sax.ext.EntityResolver2.{getExternalSubset(
), resolveEntity( )},
org.xml.sax.helpers.DefaultHandler.resolveEntity(
),
org.xml.sax.helpers.XMLFilterImpl.resolveEntity( )
|