![]() |
Quadcap Embeddable Database |
00001 /* Copyright 2000 - 2001 Quadcap Software. All rights reserved. 00002 * 00003 * This software is distributed under the Quadcap Free Software License. 00004 * This software may be used or modified for any purpose, personal or 00005 * commercial. Open Source redistributions are permitted. Commercial 00006 * redistribution of larger works derived from, or works which bundle 00007 * this software requires a "Commercial Redistribution License"; see 00008 * http://www.quadcap.com/purchase. 00009 * 00010 * Redistributions qualify as "Open Source" under one of the following terms: 00011 * 00012 * Redistributions are made at no charge beyond the reasonable cost of 00013 * materials and delivery. 00014 * 00015 * Redistributions are accompanied by a copy of the Source Code or by an 00016 * irrevocable offer to provide a copy of the Source Code for up to three 00017 * years at the cost of materials and delivery. Such redistributions 00018 * must allow further use, modification, and redistribution of the Source 00019 * Code under substantially the same terms as this license. 00020 * 00021 * Redistributions of source code must retain the copyright notices as they 00022 * appear in each source code file, these license terms, and the 00023 * disclaimer/limitation of liability set forth as paragraph 6 below. 00024 * 00025 * Redistributions in binary form must reproduce this Copyright Notice, 00026 * these license terms, and the disclaimer/limitation of liability set 00027 * forth as paragraph 6 below, in the documentation and/or other materials 00028 * provided with the distribution. 00029 * 00030 * The Software is provided on an "AS IS" basis. No warranty is 00031 * provided that the Software is free of defects, or fit for a 00032 * particular purpose. 00033 * 00034 * Limitation of Liability. Quadcap Software shall not be liable 00035 * for any damages suffered by the Licensee or any third party resulting 00036 * from use of the Software. 00037 */ 00038 00039 // SAX input source. 00040 // No warranty; no copyright -- use this as you will. 00041 // $Id: InputSource.java,v 1.3 2001/01/06 06:11:02 stan Exp $ 00042 00043 package org.xml.sax; 00044 00045 import java.io.Reader; 00046 import java.io.InputStream; 00047 00048 /** 00049 * A single input source for an XML entity. 00050 * 00051 * <p>This class allows a SAX application to encapsulate information 00052 * about an input source in a single object, which may include 00053 * a public identifier, a system identifier, a byte stream (possibly 00054 * with a specified encoding), and/or a character stream.</p> 00055 * 00056 * <p>There are two places that the application will deliver this 00057 * input source to the parser: as the argument to the Parser.parse 00058 * method, or as the return value of the EntityResolver.resolveEntity 00059 * method.</p> 00060 * 00061 * <p>The SAX parser will use the InputSource object to determine how 00062 * to read XML input. If there is a character stream available, the 00063 * parser will read that stream directly; if not, the parser will use 00064 * a byte stream, if available; if neither a character stream nor a 00065 * byte stream is available, the parser will attempt to open a URI 00066 * connection to the resource identified by the system 00067 * identifier.</p> 00068 * 00069 * <p>An InputSource object belongs to the application: the SAX parser 00070 * shall never modify it in any way (it may modify a copy if 00071 * necessary).</p> 00072 * 00073 * @author David Megginson (ak117@freenet.carleton.ca) 00074 * @version 1.0 00075 * @see org.xml.sax.Parser#parse 00076 * @see org.xml.sax.EntityResolver#resolveEntity 00077 * @see java.io.InputStream 00078 * @see java.io.Reader 00079 */ 00081 00082 /** 00083 * Zero-argument default constructor. 00084 * 00085 * @see #setPublicId 00086 * @see #setSystemId 00087 * @see #setByteStream 00088 * @see #setCharacterStream 00089 * @see #setEncoding 00090 */ 00092 { 00093 } 00094 00095 00096 /** 00097 * Create a new input source with a system identifier. 00098 * 00099 * <p>Applications may use setPublicId to include a 00100 * public identifier as well, or setEncoding to specify 00101 * the character encoding, if known.</p> 00102 * 00103 * <p>If the system identifier is a URL, it must be full resolved.</p> 00104 * 00105 * @param systemId The system identifier (URI). 00106 * @see #setPublicId 00107 * @see #setSystemId 00108 * @see #setByteStream 00109 * @see #setEncoding 00110 * @see #setCharacterStream 00111 */ 00113 { 00115 } 00116 00117 00118 /** 00119 * Create a new input source with a byte stream. 00120 * 00121 * <p>Application writers may use setSystemId to provide a base 00122 * for resolving relative URIs, setPublicId to include a 00123 * public identifier, and/or setEncoding to specify the object's 00124 * character encoding.</p> 00125 * 00126 * @param byteStream The raw byte stream containing the document. 00127 * @see #setPublicId 00128 * @see #setSystemId 00129 * @see #setEncoding 00130 * @see #setByteStream 00131 * @see #setCharacterStream 00132 */ 00134 { 00136 } 00137 00138 00139 /** 00140 * Create a new input source with a character stream. 00141 * 00142 * <p>Application writers may use setSystemId() to provide a base 00143 * for resolving relative URIs, and setPublicId to include a 00144 * public identifier.</p> 00145 * 00146 * <p>The character stream shall not include a byte order mark.</p> 00147 * 00148 * @see #setPublicId 00149 * @see #setSystemId 00150 * @see #setByteStream 00151 * @see #setCharacterStream 00152 */ 00154 { 00156 } 00157 00158 00159 /** 00160 * Set the public identifier for this input source. 00161 * 00162 * <p>The public identifier is always optional: if the application 00163 * writer includes one, it will be provided as part of the 00164 * location information.</p> 00165 * 00166 * @param publicId The public identifier as a string. 00167 * @see #getPublicId 00168 * @see org.xml.sax.Locator#getPublicId 00169 * @see org.xml.sax.SAXParseException#getPublicId 00170 */ 00172 { 00173 this.publicId = publicId; 00174 } 00175 00176 00177 /** 00178 * Get the public identifier for this input source. 00179 * 00180 * @return The public identifier, or null if none was supplied. 00181 * @see #setPublicId 00182 */ 00184 { 00186 } 00187 00188 00189 /** 00190 * Set the system identifier for this input source. 00191 * 00192 * <p>The system identifier is optional if there is a byte stream 00193 * or a character stream, but it is still useful to provide one, 00194 * since the application can use it to resolve relative URIs 00195 * and can include it in error messages and warnings (the parser 00196 * will attempt to open a connection to the URI only if 00197 * there is no byte stream or character stream specified).</p> 00198 * 00199 * <p>If the application knows the character encoding of the 00200 * object pointed to by the system identifier, it can register 00201 * the encoding using the setEncoding method.</p> 00202 * 00203 * <p>If the system ID is a URL, it must be fully resolved.</p> 00204 * 00205 * @param systemId The system identifier as a string. 00206 * @see #setEncoding 00207 * @see #getSystemId 00208 * @see org.xml.sax.Locator#getSystemId 00209 * @see org.xml.sax.SAXParseException#getSystemId 00210 */ 00212 { 00213 this.systemId = systemId; 00214 } 00215 00216 00217 /** 00218 * Get the system identifier for this input source. 00219 * 00220 * <p>The getEncoding method will return the character encoding 00221 * of the object pointed to, or null if unknown.</p> 00222 * 00223 * <p>If the system ID is a URL, it will be fully resolved.</p> 00224 * 00225 * @return The system identifier. 00226 * @see #setSystemId 00227 * @see #getEncoding 00228 */ 00230 { 00232 } 00233 00234 00235 /** 00236 * Set the byte stream for this input source. 00237 * 00238 * <p>The SAX parser will ignore this if there is also a character 00239 * stream specified, but it will use a byte stream in preference 00240 * to opening a URI connection itself.</p> 00241 * 00242 * <p>If the application knows the character encoding of the 00243 * byte stream, it should set it with the setEncoding method.</p> 00244 * 00245 * @param byteStream A byte stream containing an XML document or 00246 * other entity. 00247 * @see #setEncoding 00248 * @see #getByteStream 00249 * @see #getEncoding 00250 * @see java.io.InputStream 00251 */ 00253 { 00254 this.byteStream = byteStream; 00255 } 00256 00257 00258 /** 00259 * Get the byte stream for this input source. 00260 * 00261 * <p>The getEncoding method will return the character 00262 * encoding for this byte stream, or null if unknown.</p> 00263 * 00264 * @return The byte stream, or null if none was supplied. 00265 * @see #getEncoding 00266 * @see #setByteStream 00267 */ 00269 { 00271 } 00272 00273 00274 /** 00275 * Set the character encoding, if known. 00276 * 00277 * <p>The encoding must be a string acceptable for an 00278 * XML encoding declaration (see section 4.3.3 of the XML 1.0 00279 * recommendation).</p> 00280 * 00281 * <p>This method has no effect when the application provides a 00282 * character stream.</p> 00283 * 00284 * @param encoding A string describing the character encoding. 00285 * @see #setSystemId 00286 * @see #setByteStream 00287 * @see #getEncoding 00288 */ 00290 { 00291 this.encoding = encoding; 00292 } 00293 00294 00295 /** 00296 * Get the character encoding for a byte stream or URI. 00297 * 00298 * @return The encoding, or null if none was supplied. 00299 * @see #setByteStream 00300 * @see #getSystemId 00301 * @see #getByteStream 00302 */ 00304 { 00306 } 00307 00308 00309 /** 00310 * Set the character stream for this input source. 00311 * 00312 * <p>If there is a character stream specified, the SAX parser 00313 * will ignore any byte stream and will not attempt to open 00314 * a URI connection to the system identifier.</p> 00315 * 00316 * @param characterStream The character stream containing the 00317 * XML document or other entity. 00318 * @see #getCharacterStream 00319 * @see java.io.Reader 00320 */ 00322 { 00323 this.characterStream = characterStream; 00324 } 00325 00326 00327 /** 00328 * Get the character stream for this input source. 00329 * 00330 * @return The character stream, or null if none was supplied. 00331 * @see #setCharacterStream 00332 */ 00334 { 00336 } 00337 00338 00339 00340 ////////////////////////////////////////////////////////////////////// 00341 // Internal state. 00342 ////////////////////////////////////////////////////////////////////// 00343 00349 00350 }