+++ /dev/null
-// SAX input source.\r
-// No warranty; no copyright -- use this as you will.\r
-// $Id: InputSource.java,v 1.1 2000/10/02 02:43:17 sboag Exp $\r
-\r
-package org.xml.sax;\r
-\r
-import java.io.Reader;\r
-import java.io.InputStream;\r
-\r
-/**\r
- * A single input source for an XML entity.\r
- *\r
- * <blockquote>\r
- * <em>This module, both source code and documentation, is in the\r
- * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>\r
- * </blockquote>\r
- *\r
- * <p>This class allows a SAX application to encapsulate information\r
- * about an input source in a single object, which may include\r
- * a public identifier, a system identifier, a byte stream (possibly\r
- * with a specified encoding), and/or a character stream.</p>\r
- *\r
- * <p>There are two places that the application will deliver this\r
- * input source to the parser: as the argument to the Parser.parse\r
- * method, or as the return value of the EntityResolver.resolveEntity\r
- * method.</p>\r
- *\r
- * <p>The SAX parser will use the InputSource object to determine how\r
- * to read XML input. If there is a character stream available, the\r
- * parser will read that stream directly; if not, the parser will use\r
- * a byte stream, if available; if neither a character stream nor a\r
- * byte stream is available, the parser will attempt to open a URI\r
- * connection to the resource identified by the system\r
- * identifier.</p>\r
- *\r
- * <p>An InputSource object belongs to the application: the SAX parser\r
- * shall never modify it in any way (it may modify a copy if \r
- * necessary).</p>\r
- *\r
- * @since SAX 1.0\r
- * @author David Megginson, \r
- * <a href="mailto:sax@megginson.com">sax@megginson.com</a>\r
- * @version 2.0\r
- * @see org.xml.sax.Parser#parse\r
- * @see org.xml.sax.EntityResolver#resolveEntity\r
- * @see java.io.InputStream\r
- * @see java.io.Reader\r
- */\r
-public class InputSource {\r
- \r
- /**\r
- * Zero-argument default constructor.\r
- *\r
- * @see #setPublicId\r
- * @see #setSystemId\r
- * @see #setByteStream\r
- * @see #setCharacterStream\r
- * @see #setEncoding\r
- */\r
- public InputSource ()\r
- {\r
- }\r
- \r
- \r
- /**\r
- * Create a new input source with a system identifier.\r
- *\r
- * <p>Applications may use setPublicId to include a \r
- * public identifier as well, or setEncoding to specify\r
- * the character encoding, if known.</p>\r
- *\r
- * <p>If the system identifier is a URL, it must be full resolved.</p>\r
- *\r
- * @param systemId The system identifier (URI).\r
- * @see #setPublicId\r
- * @see #setSystemId\r
- * @see #setByteStream\r
- * @see #setEncoding\r
- * @see #setCharacterStream\r
- */\r
- public InputSource (String systemId)\r
- {\r
- setSystemId(systemId);\r
- }\r
- \r
- \r
- /**\r
- * Create a new input source with a byte stream.\r
- *\r
- * <p>Application writers may use setSystemId to provide a base \r
- * for resolving relative URIs, setPublicId to include a \r
- * public identifier, and/or setEncoding to specify the object's\r
- * character encoding.</p>\r
- *\r
- * @param byteStream The raw byte stream containing the document.\r
- * @see #setPublicId\r
- * @see #setSystemId\r
- * @see #setEncoding\r
- * @see #setByteStream\r
- * @see #setCharacterStream\r
- */\r
- public InputSource (InputStream byteStream)\r
- {\r
- setByteStream(byteStream);\r
- }\r
- \r
- \r
- /**\r
- * Create a new input source with a character stream.\r
- *\r
- * <p>Application writers may use setSystemId() to provide a base \r
- * for resolving relative URIs, and setPublicId to include a \r
- * public identifier.</p>\r
- *\r
- * <p>The character stream shall not include a byte order mark.</p>\r
- *\r
- * @see #setPublicId\r
- * @see #setSystemId\r
- * @see #setByteStream\r
- * @see #setCharacterStream\r
- */\r
- public InputSource (Reader characterStream)\r
- {\r
- setCharacterStream(characterStream);\r
- }\r
- \r
- \r
- /**\r
- * Set the public identifier for this input source.\r
- *\r
- * <p>The public identifier is always optional: if the application\r
- * writer includes one, it will be provided as part of the\r
- * location information.</p>\r
- *\r
- * @param publicId The public identifier as a string.\r
- * @see #getPublicId\r
- * @see org.xml.sax.Locator#getPublicId\r
- * @see org.xml.sax.SAXParseException#getPublicId\r
- */\r
- public void setPublicId (String publicId)\r
- {\r
- this.publicId = publicId;\r
- }\r
- \r
- \r
- /**\r
- * Get the public identifier for this input source.\r
- *\r
- * @return The public identifier, or null if none was supplied.\r
- * @see #setPublicId\r
- */\r
- public String getPublicId ()\r
- {\r
- return publicId;\r
- }\r
- \r
- \r
- /**\r
- * Set the system identifier for this input source.\r
- *\r
- * <p>The system identifier is optional if there is a byte stream\r
- * or a character stream, but it is still useful to provide one,\r
- * since the application can use it to resolve relative URIs\r
- * and can include it in error messages and warnings (the parser\r
- * will attempt to open a connection to the URI only if\r
- * there is no byte stream or character stream specified).</p>\r
- *\r
- * <p>If the application knows the character encoding of the\r
- * object pointed to by the system identifier, it can register\r
- * the encoding using the setEncoding method.</p>\r
- *\r
- * <p>If the system ID is a URL, it must be fully resolved.</p>\r
- *\r
- * @param systemId The system identifier as a string.\r
- * @see #setEncoding\r
- * @see #getSystemId\r
- * @see org.xml.sax.Locator#getSystemId\r
- * @see org.xml.sax.SAXParseException#getSystemId\r
- */\r
- public void setSystemId (String systemId)\r
- {\r
- this.systemId = systemId;\r
- }\r
- \r
- \r
- /**\r
- * Get the system identifier for this input source.\r
- *\r
- * <p>The getEncoding method will return the character encoding\r
- * of the object pointed to, or null if unknown.</p>\r
- *\r
- * <p>If the system ID is a URL, it will be fully resolved.</p>\r
- *\r
- * @return The system identifier.\r
- * @see #setSystemId\r
- * @see #getEncoding\r
- */\r
- public String getSystemId ()\r
- {\r
- return systemId;\r
- }\r
- \r
- \r
- /**\r
- * Set the byte stream for this input source.\r
- *\r
- * <p>The SAX parser will ignore this if there is also a character\r
- * stream specified, but it will use a byte stream in preference\r
- * to opening a URI connection itself.</p>\r
- *\r
- * <p>If the application knows the character encoding of the\r
- * byte stream, it should set it with the setEncoding method.</p>\r
- *\r
- * @param byteStream A byte stream containing an XML document or\r
- * other entity.\r
- * @see #setEncoding\r
- * @see #getByteStream\r
- * @see #getEncoding\r
- * @see java.io.InputStream\r
- */\r
- public void setByteStream (InputStream byteStream)\r
- {\r
- this.byteStream = byteStream;\r
- }\r
- \r
- \r
- /**\r
- * Get the byte stream for this input source.\r
- *\r
- * <p>The getEncoding method will return the character\r
- * encoding for this byte stream, or null if unknown.</p>\r
- *\r
- * @return The byte stream, or null if none was supplied.\r
- * @see #getEncoding\r
- * @see #setByteStream\r
- */\r
- public InputStream getByteStream ()\r
- {\r
- return byteStream;\r
- }\r
- \r
- \r
- /** \r
- * Set the character encoding, if known.\r
- *\r
- * <p>The encoding must be a string acceptable for an\r
- * XML encoding declaration (see section 4.3.3 of the XML 1.0\r
- * recommendation).</p>\r
- *\r
- * <p>This method has no effect when the application provides a\r
- * character stream.</p>\r
- *\r
- * @param encoding A string describing the character encoding.\r
- * @see #setSystemId\r
- * @see #setByteStream\r
- * @see #getEncoding\r
- */\r
- public void setEncoding (String encoding)\r
- {\r
- this.encoding = encoding;\r
- }\r
- \r
- \r
- /**\r
- * Get the character encoding for a byte stream or URI.\r
- *\r
- * @return The encoding, or null if none was supplied.\r
- * @see #setByteStream\r
- * @see #getSystemId\r
- * @see #getByteStream\r
- */\r
- public String getEncoding ()\r
- {\r
- return encoding;\r
- }\r
- \r
- \r
- /**\r
- * Set the character stream for this input source.\r
- *\r
- * <p>If there is a character stream specified, the SAX parser\r
- * will ignore any byte stream and will not attempt to open\r
- * a URI connection to the system identifier.</p>\r
- *\r
- * @param characterStream The character stream containing the\r
- * XML document or other entity.\r
- * @see #getCharacterStream\r
- * @see java.io.Reader\r
- */\r
- public void setCharacterStream (Reader characterStream)\r
- {\r
- this.characterStream = characterStream;\r
- }\r
- \r
- \r
- /**\r
- * Get the character stream for this input source.\r
- *\r
- * @return The character stream, or null if none was supplied.\r
- * @see #setCharacterStream\r
- */\r
- public Reader getCharacterStream ()\r
- {\r
- return characterStream;\r
- }\r
- \r
- \r
-\f\r
- ////////////////////////////////////////////////////////////////////\r
- // Internal state.\r
- ////////////////////////////////////////////////////////////////////\r
- \r
- private String publicId;\r
- private String systemId;\r
- private InputStream byteStream;\r
- private String encoding;\r
- private Reader characterStream;\r
- \r
-}\r
-\r
-// end of InputSource.java\r