KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > apache > xerces > framework > XMLDocumentHandler


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.enhydra.apache.xerces.framework;
59
60 import org.enhydra.apache.xerces.utils.QName;
61
62 /**
63  * XMLValidator defines the interface that XMLDocumentScanner and XML
64  * EntityHandler have with an object that serves as a pluggable validator.
65  * This abstraction allows validators for XML grammar languages to be
66  * plugged in and queried for validity checks as the scanner processes
67  * a document.
68  * <p>
69  * The document scanner and entity handler need to ask the validator object
70  * for this information because the validator object is responsible for reading
71  * the grammar specification file (which contains markup declarations and entity
72  * declarations)
73  *
74  * @version $Id: XMLDocumentHandler.java,v 1.1.1.1 2003/03/10 16:34:32 taweili Exp $
75  */

76
77 public interface XMLDocumentHandler {
78
79     /**
80      * Callback for start of document
81      *
82      * If the there is no version info, encoding info, or standalone info,
83      * the corresponding argument will be set to -1.
84      *
85      * @exception java.lang.Exception
86      */

87     public void startDocument() throws Exception JavaDoc;
88
89     /**
90      * callback for the end of document.
91      *
92      * @exception java.lang.Exception
93      */

94     public void endDocument() throws Exception JavaDoc;
95
96     /**
97      * Signal the XML declaration of a document
98      *
99      * @param version the handle in the string pool for the version number
100      * @param encoding the handle in the string pool for the encoding
101      * @param standalong the handle in the string pool for the standalone value
102      * @exception java.lang.Exception
103      */

104     public void xmlDecl(int version, int encoding, int standalone) throws Exception JavaDoc;
105
106     /**
107      * Signal the Text declaration of an external entity.
108      *
109      * @exception java.lang.Exception
110      */

111     public void textDecl(int version, int encoding) throws Exception JavaDoc;
112
113     /**
114      * callback for the start of a namespace declaration scope.
115      *
116      * @param prefix string pool index of the namespace prefix being declared
117      * @param uri string pool index of the namespace uri begin bound
118      * @param java.lang.Exception
119      */

120     public void startNamespaceDeclScope(int prefix, int uri) throws Exception JavaDoc;
121
122     /**
123      * callback for the end a namespace declaration scope.
124      *
125      * @param prefix string pool index of the namespace prefix being declared
126      * @exception java.lang.Exception
127      */

128     public void endNamespaceDeclScope(int prefix) throws Exception JavaDoc;
129
130     /**
131      * callback for the start of element.
132      *
133      * @param elementType element handle for the element being scanned
134      * @param attrList attrList containing the attributes of the element
135      * @param attrListHandle handle into attrList. Allows attributes to be retreived.
136      * @exception java.lang.Exception
137      */

138     public void startElement(QName element,
139                              XMLAttrList attrList, int attrListHandle) throws Exception JavaDoc;
140
141     /**
142      * callback for end of element.
143      *
144      * @param elementType element handle for the element being scanned
145      * @exception java.lang.Exception
146      */

147     public void endElement(QName element) throws Exception JavaDoc;
148
149     /**
150      * callback for start of entity reference.
151      *
152      * @param entityName string pool index of the entity name
153      * @param entityType the XMLEntityHandler.ENTITYTYPE_* type
154      * @see org.enhydra.apache.xerces.readers.XMLEntityHandler
155      * @param entityContext the XMLEntityHandler.ENTITYREF_* type for where
156      * the entity reference appears
157      * @see org.enhydra.apache.xerces.readers.XMLEntityHandler
158      * @exception java.lang.Exception
159      */

160     public void startEntityReference(int entityName, int entityType, int entityContext) throws Exception JavaDoc;
161
162     /**
163      * callback for end of entity reference.
164      *
165      * @param entityName string pool index of the entity anem
166      * @param entityType the XMLEntityHandler.ENTITYTYPE_* type
167      * @see org.enhydra.apache.xerces.readers.XMLEntityHandler
168      * @param entityContext the XMLEntityHandler.ENTITYREF_* type for where
169      * the entity reference appears
170      * @see org.enhydra.apache.xerces.readers.XMLEntityHandler
171      * @exception java.lang.Exception
172      */

173     public void endEntityReference(int entityName, int entityType, int entityContext) throws Exception JavaDoc;
174
175     /**
176      * callback for processing instruction.
177      *
178      * @param target string pool index of the PI target
179      * @param data string pool index of the PI data
180      * @exception java.lang.Exception
181      */

182     public void processingInstruction(int target, int data) throws Exception JavaDoc;
183
184     /**
185      * callback for comment.
186      *
187      * @param comment string pool index of the comment text
188      * @exception java.lang.Exception
189      */

190     public void comment(int comment) throws Exception JavaDoc;
191
192     /**
193      * callback for characters (string pool form).
194      *
195      * @param data string pool index of the characters that were scanned
196      * @exception java.lang.Exception
197      */

198     public void characters(int data) throws Exception JavaDoc;
199
200     /**
201      * callback for characters.
202      *
203      * @param ch character array containing the characters that were scanned
204      * @param start offset in ch where scanned characters begin
205      * @param length length of scanned characters in ch
206      * @exception java.lang.Exception
207      */

208     public void characters(char ch[], int start, int length) throws Exception JavaDoc;
209
210     /**
211      * callback for ignorable whitespace.
212      *
213      * @param data string pool index of ignorable whitespace
214      * @exception java.lang.Exception
215      */

216     public void ignorableWhitespace(int data) throws Exception JavaDoc;
217
218     /**
219      * callback for ignorable whitespace.
220      *
221      * @param ch character array containing the whitespace that was scanned
222      * @param start offset in ch where scanned whitespace begins
223      * @param length length of scanned whitespace in ch
224      * @exception java.lang.Exception
225      */

226     public void ignorableWhitespace(char ch[], int start, int length) throws Exception JavaDoc;
227
228     /**
229      * callback for start of CDATA section.
230      * this callback marks the start of a CDATA section
231      *
232      * @exception java.lang.Exception
233      */

234     public void startCDATA() throws Exception JavaDoc;
235
236     /**
237      * callback for end of CDATA section.
238      * this callback marks the end of a CDATA section
239      *
240      * @exception java.lang.Exception
241      */

242     public void endCDATA() throws Exception JavaDoc;
243
244     //
245
// Additional DTD specific events.
246
//
247
public interface DTDHandler {
248         /**
249          * callback for the start of the DTD
250          * This function will be called when a &lt;!DOCTYPE...&gt; declaration is
251          * encountered.
252          *
253          * @param rootElementType element handle for the root element of the document
254          * @param publicId string pool index of the DTD's public ID
255          * @param systemId string pool index of the DTD's system ID
256          * @exception java.lang.Exception
257          */

258         public void startDTD(QName rootElement, int publicId, int systemId) throws Exception JavaDoc;
259
260         /**
261          * Supports DOM Level 2 internalSubset additions.
262          * Called when the internal subset is completely scanned.
263          */

264         public void internalSubset(int internalSubset) throws Exception JavaDoc;
265
266         /**
267          * Signal the Text declaration of an external entity.
268          *
269          * @exception java.lang.Exception
270          */

271         public void textDecl(int version, int encoding) throws Exception JavaDoc;
272
273         /**
274          * callback for the end of the DTD
275          * This function will be called at the end of the DTD.
276          */

277         public void endDTD() throws Exception JavaDoc;
278
279         /**
280          * callback for an element declaration.
281          *
282          * @param elementType element handle of the element being declared
283          * @param contentSpec contentSpec for the element being declared
284          * @see org.enhydra.apache.xerces.framework.XMLContentSpec
285          * @exception java.lang.Exception
286          */

287         public void elementDecl(QName elementDecl,
288                                 int contentSpecType,
289                                 int contentSpecIndex,
290                                 XMLContentSpec.Provider contentSpecProvider) throws Exception JavaDoc;
291
292         /**
293          * callback for an attribute list declaration.
294          *
295          * @param elementType element handle for the attribute's element
296          * @param attrName string pool index of the attribute name
297          * @param attType type of attribute
298          * @param enumString String representing the values of the enumeration,
299          * if the attribute is of enumerated type, or null if it is not.
300          * @param attDefaultType an integer value denoting the DefaultDecl value
301          * @param attDefaultValue string pool index of this attribute's default value
302          * or -1 if there is no defaultvalue
303          * @exception java.lang.Exception
304          */

305         public void attlistDecl(QName elementDecl, QName attributeDecl,
306                                 int attType, boolean attList,
307                                 String JavaDoc enumString,
308                                 int attDefaultType,
309                                 int attDefaultValue) throws Exception JavaDoc;
310
311         /**
312          * callback for an internal parameter entity declaration.
313          *
314          * @param entityName string pool index of the entity name
315          * @param entityValue string pool index of the entity replacement text
316          * @exception java.lang.Exception
317          */

318         public void internalPEDecl(int entityName, int entityValue) throws Exception JavaDoc;
319
320         /**
321          * callback for an external parameter entity declaration.
322          *
323          * @param entityName string pool index of the entity name
324          * @param publicId string pool index of the entity's public id.
325          * @param systemId string pool index of the entity's system id.
326          * @exception java.lang.Exception
327          */

328         public void externalPEDecl(int entityName, int publicId, int systemId) throws Exception JavaDoc;
329
330         /**
331          * callback for internal general entity declaration.
332          *
333          * @param entityName string pool index of the entity name
334          * @param entityValue string pool index of the entity replacement text
335          * @exception java.lang.Exception
336          */

337         public void internalEntityDecl(int entityName, int entityValue) throws Exception JavaDoc;
338
339         /**
340          * callback for external general entity declaration.
341          *
342          * @param entityName string pool index of the entity name
343          * @param publicId string pool index of the entity's public id.
344          * @param systemId string pool index of the entity's system id.
345          * @exception java.lang.Exception
346          */

347         public void externalEntityDecl(int entityName, int publicId, int systemId) throws Exception JavaDoc;
348
349         /**
350          * callback for an unparsed entity declaration.
351          *
352          * @param entityName string pool index of the entity name
353          * @param publicId string pool index of the entity's public id.
354          * @param systemId string pool index of the entity's system id.
355          * @param notationName string pool index of the notation name.
356          * @exception java.lang.Exception
357          */

358         public void unparsedEntityDecl(int entityName, int publicId, int systemId, int notationName) throws Exception JavaDoc;
359
360         /**
361          * callback for a notation declaration.
362          *
363          * @param notationName string pool index of the notation name
364          * @param publicId string pool index of the notation's public id.
365          * @param systemId string pool index of the notation's system id.
366          * @exception java.lang.Exception
367          */

368         public void notationDecl(int notationName, int publicId, int systemId) throws Exception JavaDoc;
369
370         /**
371          * Callback for processing instruction in DTD.
372          *
373          * @param target the string pool index of the PI's target
374          * @param data the string pool index of the PI's data
375          * @exception java.lang.Exception
376          */

377         public void processingInstruction(int targetIndex, int dataIndex) throws Exception JavaDoc;
378
379         /**
380          * Callback for comment in DTD.
381          *
382          * @param comment the string pool index of the comment text
383          * @exception java.lang.Exception
384          */

385         public void comment(int dataIndex) throws Exception JavaDoc;
386     }
387 }
388
Popular Tags