update of javajs package; adds org.apache.harmony, org.xml.sax.helpers
[jalview.git] / src / org / xml / sax / HandlerBase.java
1 // SAX default handler base class.
2 // http://www.saxproject.org
3 // No warranty; no copyright -- use this as you will.
4 // $Id: HandlerBase.java,v 1.7 2004/04/26 17:34:34 dmegginson Exp $
5
6 package org.xml.sax;
7
8 /**
9  * Default base class for handlers.
10  *
11  * <blockquote>
12  * <em>This module, both source code and documentation, is in the
13  * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
14  * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
15  * for further information.
16  * </blockquote>
17  *
18  * <p>This class implements the default behaviour for four SAX1
19  * interfaces: EntityResolver, DTDHandler, DocumentHandler,
20  * and ErrorHandler.  It is now obsolete, but is included in SAX2 to
21  * support legacy SAX1 applications.  SAX2 applications should use
22  * the {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
23  * class instead.</p>
24  *
25  * <p>Application writers can extend this class when they need to
26  * implement only part of an interface; parser writers can
27  * instantiate this class to provide default handlers when the
28  * application has not supplied its own.</p>
29  *
30  * <p>Note that the use of this class is optional.</p>
31  *
32  * @deprecated This class works with the deprecated
33  *             {@link org.xml.sax.DocumentHandler DocumentHandler}
34  *             interface.  It has been replaced by the SAX2
35  *             {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
36  *             class.
37  * @since SAX 1.0
38  * @author David Megginson
39  * @version 2.0.1 (sax2r2)
40  * @see org.xml.sax.EntityResolver
41  * @see org.xml.sax.DTDHandler
42  * @see org.xml.sax.DocumentHandler
43  * @see org.xml.sax.ErrorHandler
44  */
45 public class HandlerBase
46     implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler
47 {
48     
49 \f
50     ////////////////////////////////////////////////////////////////////
51     // Default implementation of the EntityResolver interface.
52     ////////////////////////////////////////////////////////////////////
53     
54     /**
55      * Resolve an external entity.
56      *
57      * <p>Always return null, so that the parser will use the system
58      * identifier provided in the XML document.  This method implements
59      * the SAX default behaviour: application writers can override it
60      * in a subclass to do special translations such as catalog lookups
61      * or URI redirection.</p>
62      *
63      * @param publicId The public identifer, or null if none is
64      *                 available.
65      * @param systemId The system identifier provided in the XML 
66      *                 document.
67      * @return The new input source, or null to require the
68      *         default behaviour.
69      * @exception org.xml.sax.SAXException Any SAX exception, possibly
70      *            wrapping another exception.
71      * @see org.xml.sax.EntityResolver#resolveEntity
72      */
73     @Override
74                 public InputSource resolveEntity (String publicId, String systemId)
75         throws SAXException
76     {
77         return null;
78     }
79     
80     
81 \f
82     ////////////////////////////////////////////////////////////////////
83     // Default implementation of DTDHandler interface.
84     ////////////////////////////////////////////////////////////////////
85     
86     
87     /**
88      * Receive notification of a notation declaration.
89      *
90      * <p>By default, do nothing.  Application writers may override this
91      * method in a subclass if they wish to keep track of the notations
92      * declared in a document.</p>
93      *
94      * @param name The notation name.
95      * @param publicId The notation public identifier, or null if not
96      *                 available.
97      * @param systemId The notation system identifier.
98      * @see org.xml.sax.DTDHandler#notationDecl
99      */
100     @Override
101                 public void notationDecl (String name, String publicId, String systemId)
102     {
103         // no op
104     }
105     
106     
107     /**
108      * Receive notification of an unparsed entity declaration.
109      *
110      * <p>By default, do nothing.  Application writers may override this
111      * method in a subclass to keep track of the unparsed entities
112      * declared in a document.</p>
113      *
114      * @param name The entity name.
115      * @param publicId The entity public identifier, or null if not
116      *                 available.
117      * @param systemId The entity system identifier.
118      * @param notationName The name of the associated notation.
119      * @see org.xml.sax.DTDHandler#unparsedEntityDecl
120      */
121     @Override
122                 public void unparsedEntityDecl (String name, String publicId,
123                                     String systemId, String notationName)
124     {
125         // no op
126     }
127     
128     
129 \f
130     ////////////////////////////////////////////////////////////////////
131     // Default implementation of DocumentHandler interface.
132     ////////////////////////////////////////////////////////////////////
133     
134     
135     /**
136      * Receive a Locator object for document events.
137      *
138      * <p>By default, do nothing.  Application writers may override this
139      * method in a subclass if they wish to store the locator for use
140      * with other document events.</p>
141      *
142      * @param locator A locator for all SAX document events.
143      * @see org.xml.sax.DocumentHandler#setDocumentLocator
144      * @see org.xml.sax.Locator
145      */
146     @Override
147                 public void setDocumentLocator (Locator locator)
148     {
149         // no op
150     }
151     
152     
153     /**
154      * Receive notification of the beginning of the document.
155      *
156      * <p>By default, do nothing.  Application writers may override this
157      * method in a subclass to take specific actions at the beginning
158      * of a document (such as allocating the root node of a tree or
159      * creating an output file).</p>
160      *
161      * @exception org.xml.sax.SAXException Any SAX exception, possibly
162      *            wrapping another exception.
163      * @see org.xml.sax.DocumentHandler#startDocument
164      */
165     @Override
166                 public void startDocument ()
167         throws SAXException
168     {
169         // no op
170     }
171     
172     
173     /**
174      * Receive notification of the end of the document.
175      *
176      * <p>By default, do nothing.  Application writers may override this
177      * method in a subclass to take specific actions at the beginning
178      * of a document (such as finalising a tree or closing an output
179      * file).</p>
180      *
181      * @exception org.xml.sax.SAXException Any SAX exception, possibly
182      *            wrapping another exception.
183      * @see org.xml.sax.DocumentHandler#endDocument
184      */
185     @Override
186                 public void endDocument ()
187         throws SAXException
188     {
189         // no op
190     }
191     
192     
193     /**
194      * Receive notification of the start of an element.
195      *
196      * <p>By default, do nothing.  Application writers may override this
197      * method in a subclass to take specific actions at the start of
198      * each element (such as allocating a new tree node or writing
199      * output to a file).</p>
200      *
201      * @param name The element type name.
202      * @param attributes The specified or defaulted attributes.
203      * @exception org.xml.sax.SAXException Any SAX exception, possibly
204      *            wrapping another exception.
205      * @see org.xml.sax.DocumentHandler#startElement
206      */
207     @Override
208                 public void startElement (String name, AttributeList attributes)
209         throws SAXException
210     {
211         // no op
212     }
213     
214     
215     /**
216      * Receive notification of the end of an element.
217      *
218      * <p>By default, do nothing.  Application writers may override this
219      * method in a subclass to take specific actions at the end of
220      * each element (such as finalising a tree node or writing
221      * output to a file).</p>
222      *
223      * @param name the element name
224      * @exception org.xml.sax.SAXException Any SAX exception, possibly
225      *            wrapping another exception.
226      * @see org.xml.sax.DocumentHandler#endElement
227      */
228     @Override
229                 public void endElement (String name)
230         throws SAXException
231     {
232         // no op
233     }
234     
235     
236     /**
237      * Receive notification of character data inside an element.
238      *
239      * <p>By default, do nothing.  Application writers may override this
240      * method to take specific actions for each chunk of character data
241      * (such as adding the data to a node or buffer, or printing it to
242      * a file).</p>
243      *
244      * @param ch The characters.
245      * @param start The start position in the character array.
246      * @param length The number of characters to use from the
247      *               character array.
248      * @exception org.xml.sax.SAXException Any SAX exception, possibly
249      *            wrapping another exception.
250      * @see org.xml.sax.DocumentHandler#characters
251      */
252     @Override
253                 public void characters (char ch[], int start, int length)
254         throws SAXException
255     {
256         // no op
257     }
258     
259     
260     /**
261      * Receive notification of ignorable whitespace in element content.
262      *
263      * <p>By default, do nothing.  Application writers may override this
264      * method to take specific actions for each chunk of ignorable
265      * whitespace (such as adding data to a node or buffer, or printing
266      * it to a file).</p>
267      *
268      * @param ch The whitespace characters.
269      * @param start The start position in the character array.
270      * @param length The number of characters to use from the
271      *               character array.
272      * @exception org.xml.sax.SAXException Any SAX exception, possibly
273      *            wrapping another exception.
274      * @see org.xml.sax.DocumentHandler#ignorableWhitespace
275      */
276     @Override
277                 public void ignorableWhitespace (char ch[], int start, int length)
278         throws SAXException
279     {
280         // no op
281     }
282     
283     
284     /**
285      * Receive notification of a processing instruction.
286      *
287      * <p>By default, do nothing.  Application writers may override this
288      * method in a subclass to take specific actions for each
289      * processing instruction, such as setting status variables or
290      * invoking other methods.</p>
291      *
292      * @param target The processing instruction target.
293      * @param data The processing instruction data, or null if
294      *             none is supplied.
295      * @exception org.xml.sax.SAXException Any SAX exception, possibly
296      *            wrapping another exception.
297      * @see org.xml.sax.DocumentHandler#processingInstruction
298      */
299     @Override
300                 public void processingInstruction (String target, String data)
301         throws SAXException
302     {
303         // no op
304     }
305     
306     
307 \f
308     ////////////////////////////////////////////////////////////////////
309     // Default implementation of the ErrorHandler interface.
310     ////////////////////////////////////////////////////////////////////
311     
312     
313     /**
314      * Receive notification of a parser warning.
315      *
316      * <p>The default implementation does nothing.  Application writers
317      * may override this method in a subclass to take specific actions
318      * for each warning, such as inserting the message in a log file or
319      * printing it to the console.</p>
320      *
321      * @param e The warning information encoded as an exception.
322      * @exception org.xml.sax.SAXException Any SAX exception, possibly
323      *            wrapping another exception.
324      * @see org.xml.sax.ErrorHandler#warning
325      * @see org.xml.sax.SAXParseException
326      */
327     @Override
328                 public void warning (SAXParseException e)
329         throws SAXException
330     {
331         // no op
332     }
333     
334     
335     /**
336      * Receive notification of a recoverable parser error.
337      *
338      * <p>The default implementation does nothing.  Application writers
339      * may override this method in a subclass to take specific actions
340      * for each error, such as inserting the message in a log file or
341      * printing it to the console.</p>
342      *
343      * @param e The warning information encoded as an exception.
344      * @exception org.xml.sax.SAXException Any SAX exception, possibly
345      *            wrapping another exception.
346      * @see org.xml.sax.ErrorHandler#warning
347      * @see org.xml.sax.SAXParseException
348      */
349     @Override
350                 public void error (SAXParseException e)
351         throws SAXException
352     {
353         // no op
354     }
355     
356     
357     /**
358      * Report a fatal XML parsing error.
359      *
360      * <p>The default implementation throws a SAXParseException.
361      * Application writers may override this method in a subclass if
362      * they need to take specific actions for each fatal error (such as
363      * collecting all of the errors into a single report): in any case,
364      * the application must stop all regular processing when this
365      * method is invoked, since the document is no longer reliable, and
366      * the parser may no longer report parsing events.</p>
367      *
368      * @param e The error information encoded as an exception.
369      * @exception org.xml.sax.SAXException Any SAX exception, possibly
370      *            wrapping another exception.
371      * @see org.xml.sax.ErrorHandler#fatalError
372      * @see org.xml.sax.SAXParseException
373      */
374     @Override
375                 public void fatalError (SAXParseException e)
376         throws SAXException
377     {
378         throw e;
379     }
380     
381 }
382
383 // end of HandlerBase.java