1 | #ifndef DOMInputSource_HEADER_GUARD_
|
---|
2 | #define DOMInputSource_HEADER_GUARD_
|
---|
3 |
|
---|
4 | /*
|
---|
5 | * Copyright 2002,2004 The Apache Software Foundation.
|
---|
6 | *
|
---|
7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
8 | * you may not use this file except in compliance with the License.
|
---|
9 | * You may obtain a copy of the License at
|
---|
10 | *
|
---|
11 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
12 | *
|
---|
13 | * Unless required by applicable law or agreed to in writing, software
|
---|
14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
16 | * See the License for the specific language governing permissions and
|
---|
17 | * limitations under the License.
|
---|
18 | */
|
---|
19 |
|
---|
20 | /*
|
---|
21 | * $Id: DOMInputSource.hpp,v 1.11 2004/09/08 13:55:39 peiyongz Exp $
|
---|
22 | */
|
---|
23 |
|
---|
24 |
|
---|
25 | #include <xercesc/util/XercesDefs.hpp>
|
---|
26 |
|
---|
27 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
28 |
|
---|
29 |
|
---|
30 | class BinInputStream;
|
---|
31 |
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * This interface represents a single input source for an XML entity.
|
---|
35 | *
|
---|
36 | * <p>This interface allows an application to encapsulate information about
|
---|
37 | * an input source in a single object, which may include a public identifier,
|
---|
38 | * a system identifier, a byte stream (possibly with a specified encoding),
|
---|
39 | * and/or a character stream.</p>
|
---|
40 | *
|
---|
41 | * <p>There are two places that the application will deliver this input source
|
---|
42 | * to the parser: as the argument to the parse method, or as the return value
|
---|
43 | * of the DOMEntityResolver.resolveEntity method.</p>
|
---|
44 | *
|
---|
45 | * <p>The DOMBuilder will use the DOMInputSource object to determine how to
|
---|
46 | * read XML input. If there is a character stream available, the parser will
|
---|
47 | * read that stream directly; if not, the parser will use a byte stream, if
|
---|
48 | * available; if neither a character stream nor a byte stream is available,
|
---|
49 | * the parser will attempt to open a URI connection to the resource identified
|
---|
50 | * by the system identifier.</p>
|
---|
51 | *
|
---|
52 | * <p>A DOMInputSource object belongs to the application: the parser shall
|
---|
53 | * never modify it in any way (it may modify a copy if necessary).</p>
|
---|
54 | *
|
---|
55 | * @see DOMBuilder#parse
|
---|
56 | * @see DOMEntityResolver#resolveEntity
|
---|
57 | * @since DOM Level 3
|
---|
58 | */
|
---|
59 | class CDOM_EXPORT DOMInputSource
|
---|
60 | {
|
---|
61 | protected:
|
---|
62 | // -----------------------------------------------------------------------
|
---|
63 | // Hidden constructors
|
---|
64 | // -----------------------------------------------------------------------
|
---|
65 | /** @name Hidden constructors */
|
---|
66 | //@{
|
---|
67 | DOMInputSource() {};
|
---|
68 | //@}
|
---|
69 |
|
---|
70 | private:
|
---|
71 | // -----------------------------------------------------------------------
|
---|
72 | // Unimplemented constructors and operators
|
---|
73 | // -----------------------------------------------------------------------
|
---|
74 | /** @name Unimplemented constructors and operators */
|
---|
75 | //@{
|
---|
76 | DOMInputSource(const DOMInputSource &);
|
---|
77 | DOMInputSource & operator = (const DOMInputSource &);
|
---|
78 | //@}
|
---|
79 |
|
---|
80 | public:
|
---|
81 | // -----------------------------------------------------------------------
|
---|
82 | // All constructors are hidden, just the destructor is available
|
---|
83 | // -----------------------------------------------------------------------
|
---|
84 | /** @name Destructor */
|
---|
85 | //@{
|
---|
86 | /**
|
---|
87 | * Destructor
|
---|
88 | *
|
---|
89 | */
|
---|
90 | virtual ~DOMInputSource() {};
|
---|
91 | //@}
|
---|
92 |
|
---|
93 | // -----------------------------------------------------------------------
|
---|
94 | // Virtual DOMInputSource interface
|
---|
95 | // -----------------------------------------------------------------------
|
---|
96 | /** @name Functions introduced in DOM Level 3 */
|
---|
97 | //@{
|
---|
98 | // -----------------------------------------------------------------------
|
---|
99 | // Getter methods
|
---|
100 | // -----------------------------------------------------------------------
|
---|
101 | /**
|
---|
102 | * An input source can be set to force the parser to assume a particular
|
---|
103 | * encoding for the data that input source reprsents, via the setEncoding()
|
---|
104 | * method. This method returns name of the encoding that is to be forced.
|
---|
105 | * If the encoding has never been forced, it returns a null pointer.
|
---|
106 | *
|
---|
107 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
108 | *
|
---|
109 | * @return The forced encoding, or null if none was supplied.
|
---|
110 | * @see #setEncoding
|
---|
111 | * @since DOM Level 3
|
---|
112 | */
|
---|
113 | virtual const XMLCh* getEncoding() const = 0;
|
---|
114 |
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * Get the public identifier for this input source.
|
---|
118 | *
|
---|
119 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
120 | *
|
---|
121 | * @return The public identifier, or null if none was supplied.
|
---|
122 | * @see #setPublicId
|
---|
123 | * @since DOM Level 3
|
---|
124 | */
|
---|
125 | virtual const XMLCh* getPublicId() const = 0;
|
---|
126 |
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Get the system identifier for this input source.
|
---|
130 | *
|
---|
131 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
132 | *
|
---|
133 | * <p>If the system ID is a URL, it will be fully resolved.</p>
|
---|
134 | *
|
---|
135 | * @return The system identifier.
|
---|
136 | * @see #setSystemId
|
---|
137 | * @since DOM Level 3
|
---|
138 | */
|
---|
139 | virtual const XMLCh* getSystemId() const = 0;
|
---|
140 |
|
---|
141 |
|
---|
142 | /**
|
---|
143 | * Get the base URI to be used for resolving relative URIs to absolute
|
---|
144 | * URIs. If the baseURI is itself a relative URI, the behavior is
|
---|
145 | * implementation dependent.
|
---|
146 | *
|
---|
147 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
148 | *
|
---|
149 | * @return The base URI.
|
---|
150 | * @see #setBaseURI
|
---|
151 | * @since DOM Level 3
|
---|
152 | */
|
---|
153 | virtual const XMLCh* getBaseURI() const = 0;
|
---|
154 |
|
---|
155 | // -----------------------------------------------------------------------
|
---|
156 | // Setter methods
|
---|
157 | // -----------------------------------------------------------------------
|
---|
158 | /**
|
---|
159 | * Set the encoding which will be required for use with the XML text read
|
---|
160 | * via a stream opened by this input source.
|
---|
161 | *
|
---|
162 | * <p>This is usually not set, allowing the encoding to be sensed in the
|
---|
163 | * usual XML way. However, in some cases, the encoding in the file is known
|
---|
164 | * to be incorrect because of intermediate transcoding, for instance
|
---|
165 | * encapsulation within a MIME document.
|
---|
166 | *
|
---|
167 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
168 | *
|
---|
169 | * @param encodingStr The name of the encoding to force.
|
---|
170 | * @since DOM Level 3
|
---|
171 | */
|
---|
172 | virtual void setEncoding(const XMLCh* const encodingStr) = 0;
|
---|
173 |
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * Set the public identifier for this input source.
|
---|
177 | *
|
---|
178 | * <p>The public identifier is always optional: if the application writer
|
---|
179 | * includes one, it will be provided as part of the location information.</p>
|
---|
180 | *
|
---|
181 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
182 | *
|
---|
183 | * @param publicId The public identifier as a string.
|
---|
184 | * @see #getPublicId
|
---|
185 | * @since DOM Level 3
|
---|
186 | */
|
---|
187 | virtual void setPublicId(const XMLCh* const publicId) = 0;
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * Set the system identifier for this input source.
|
---|
191 | *
|
---|
192 | * <p>The system id is always required. The public id may be used to map
|
---|
193 | * to another system id, but the system id must always be present as a fall
|
---|
194 | * back.</p>
|
---|
195 | *
|
---|
196 | * <p>If the system ID is a URL, it must be fully resolved.</p>
|
---|
197 | *
|
---|
198 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
199 | *
|
---|
200 | * @param systemId The system identifier as a string.
|
---|
201 | * @see #getSystemId
|
---|
202 | * @since DOM Level 3
|
---|
203 | */
|
---|
204 | virtual void setSystemId(const XMLCh* const systemId) = 0;
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * Set the base URI to be used for resolving relative URIs to absolute
|
---|
208 | * URIs. If the baseURI is itself a relative URI, the behavior is
|
---|
209 | * implementation dependent.
|
---|
210 | *
|
---|
211 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
212 | *
|
---|
213 | * @param baseURI The base URI.
|
---|
214 | * @see #getBaseURI
|
---|
215 | * @since DOM Level 3
|
---|
216 | */
|
---|
217 | virtual void setBaseURI(const XMLCh* const baseURI) = 0;
|
---|
218 | //@}
|
---|
219 |
|
---|
220 | // -----------------------------------------------------------------------
|
---|
221 | // Non-standard Extension
|
---|
222 | // -----------------------------------------------------------------------
|
---|
223 | /** @name Non-standard Extension */
|
---|
224 | //@{
|
---|
225 |
|
---|
226 | /**
|
---|
227 | * Makes the byte stream for this input source.
|
---|
228 | *
|
---|
229 | * <p>The derived class must create and return a binary input stream of an
|
---|
230 | * appropriate type for its kind of data source. The returned stream must
|
---|
231 | * be dynamically allocated and becomes the parser's property.
|
---|
232 | * </p>
|
---|
233 | *
|
---|
234 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
235 | *
|
---|
236 | * @see BinInputStream
|
---|
237 | */
|
---|
238 | virtual BinInputStream* makeStream() const = 0;
|
---|
239 |
|
---|
240 | /**
|
---|
241 | * Indicates if the parser should issue fatal error if this input source
|
---|
242 | * is not found. If set to false, the parser issue warning message instead.
|
---|
243 | *
|
---|
244 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
245 | *
|
---|
246 | * @param flag True if the parser should issue fatal error if this input source is not found.
|
---|
247 | * If set to false, the parser issue warning message instead. (Default: true)
|
---|
248 | *
|
---|
249 | * @see #getIssueFatalErrorIfNotFound
|
---|
250 | */
|
---|
251 | virtual void setIssueFatalErrorIfNotFound(const bool flag) = 0;
|
---|
252 |
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Get the flag that indicates if the parser should issue fatal error if this input source
|
---|
256 | * is not found.
|
---|
257 | *
|
---|
258 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
259 | *
|
---|
260 | * @return True if the parser should issue fatal error if this input source is not found.
|
---|
261 | * False if the parser issue warning message instead.
|
---|
262 | * @see #setIssueFatalErrorIfNotFound
|
---|
263 | */
|
---|
264 | virtual bool getIssueFatalErrorIfNotFound() const = 0;
|
---|
265 |
|
---|
266 | /**
|
---|
267 | * Called to indicate that this DOMInputSource is no longer in use
|
---|
268 | * and that the implementation may relinquish any resources associated with it.
|
---|
269 | *
|
---|
270 | * Access to a released object will lead to unexpected result.
|
---|
271 | */
|
---|
272 | virtual void release() = 0;
|
---|
273 | //@}
|
---|
274 | };
|
---|
275 |
|
---|
276 |
|
---|
277 | XERCES_CPP_NAMESPACE_END
|
---|
278 |
|
---|
279 | #endif
|
---|