Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / external / sax / org / xml / sax / HandlerBase.java
blob6f037883bbcc4199255119724853e67ef652fb1c
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.1 2005/02/02 00:41:51 tromey Exp $
6 package org.xml.sax;
8 /**
9 * Default base class for handlers.
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>
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>
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>
30 * <p>Note that the use of this class is optional.</p>
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
45 public class HandlerBase
46 implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler
50 ////////////////////////////////////////////////////////////////////
51 // Default implementation of the EntityResolver interface.
52 ////////////////////////////////////////////////////////////////////
54 /**
55 * Resolve an external entity.
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>
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
73 public InputSource resolveEntity (String publicId, String systemId)
74 throws SAXException
76 return null;
81 ////////////////////////////////////////////////////////////////////
82 // Default implementation of DTDHandler interface.
83 ////////////////////////////////////////////////////////////////////
86 /**
87 * Receive notification of a notation declaration.
89 * <p>By default, do nothing. Application writers may override this
90 * method in a subclass if they wish to keep track of the notations
91 * declared in a document.</p>
93 * @param name The notation name.
94 * @param publicId The notation public identifier, or null if not
95 * available.
96 * @param systemId The notation system identifier.
97 * @see org.xml.sax.DTDHandler#notationDecl
99 public void notationDecl (String name, String publicId, String systemId)
101 // no op
106 * Receive notification of an unparsed entity declaration.
108 * <p>By default, do nothing. Application writers may override this
109 * method in a subclass to keep track of the unparsed entities
110 * declared in a document.</p>
112 * @param name The entity name.
113 * @param publicId The entity public identifier, or null if not
114 * available.
115 * @param systemId The entity system identifier.
116 * @param notationName The name of the associated notation.
117 * @see org.xml.sax.DTDHandler#unparsedEntityDecl
119 public void unparsedEntityDecl (String name, String publicId,
120 String systemId, String notationName)
122 // no op
127 ////////////////////////////////////////////////////////////////////
128 // Default implementation of DocumentHandler interface.
129 ////////////////////////////////////////////////////////////////////
133 * Receive a Locator object for document events.
135 * <p>By default, do nothing. Application writers may override this
136 * method in a subclass if they wish to store the locator for use
137 * with other document events.</p>
139 * @param locator A locator for all SAX document events.
140 * @see org.xml.sax.DocumentHandler#setDocumentLocator
141 * @see org.xml.sax.Locator
143 public void setDocumentLocator (Locator locator)
145 // no op
150 * Receive notification of the beginning of the document.
152 * <p>By default, do nothing. Application writers may override this
153 * method in a subclass to take specific actions at the beginning
154 * of a document (such as allocating the root node of a tree or
155 * creating an output file).</p>
157 * @exception org.xml.sax.SAXException Any SAX exception, possibly
158 * wrapping another exception.
159 * @see org.xml.sax.DocumentHandler#startDocument
161 public void startDocument ()
162 throws SAXException
164 // no op
169 * Receive notification of the end of the document.
171 * <p>By default, do nothing. Application writers may override this
172 * method in a subclass to take specific actions at the beginning
173 * of a document (such as finalising a tree or closing an output
174 * file).</p>
176 * @exception org.xml.sax.SAXException Any SAX exception, possibly
177 * wrapping another exception.
178 * @see org.xml.sax.DocumentHandler#endDocument
180 public void endDocument ()
181 throws SAXException
183 // no op
188 * Receive notification of the start of an element.
190 * <p>By default, do nothing. Application writers may override this
191 * method in a subclass to take specific actions at the start of
192 * each element (such as allocating a new tree node or writing
193 * output to a file).</p>
195 * @param name The element type name.
196 * @param attributes The specified or defaulted attributes.
197 * @exception org.xml.sax.SAXException Any SAX exception, possibly
198 * wrapping another exception.
199 * @see org.xml.sax.DocumentHandler#startElement
201 public void startElement (String name, AttributeList attributes)
202 throws SAXException
204 // no op
209 * Receive notification of the end of an element.
211 * <p>By default, do nothing. Application writers may override this
212 * method in a subclass to take specific actions at the end of
213 * each element (such as finalising a tree node or writing
214 * output to a file).</p>
216 * @param name the element name
217 * @exception org.xml.sax.SAXException Any SAX exception, possibly
218 * wrapping another exception.
219 * @see org.xml.sax.DocumentHandler#endElement
221 public void endElement (String name)
222 throws SAXException
224 // no op
229 * Receive notification of character data inside an element.
231 * <p>By default, do nothing. Application writers may override this
232 * method to take specific actions for each chunk of character data
233 * (such as adding the data to a node or buffer, or printing it to
234 * a file).</p>
236 * @param ch The characters.
237 * @param start The start position in the character array.
238 * @param length The number of characters to use from the
239 * character array.
240 * @exception org.xml.sax.SAXException Any SAX exception, possibly
241 * wrapping another exception.
242 * @see org.xml.sax.DocumentHandler#characters
244 public void characters (char ch[], int start, int length)
245 throws SAXException
247 // no op
252 * Receive notification of ignorable whitespace in element content.
254 * <p>By default, do nothing. Application writers may override this
255 * method to take specific actions for each chunk of ignorable
256 * whitespace (such as adding data to a node or buffer, or printing
257 * it to a file).</p>
259 * @param ch The whitespace characters.
260 * @param start The start position in the character array.
261 * @param length The number of characters to use from the
262 * character array.
263 * @exception org.xml.sax.SAXException Any SAX exception, possibly
264 * wrapping another exception.
265 * @see org.xml.sax.DocumentHandler#ignorableWhitespace
267 public void ignorableWhitespace (char ch[], int start, int length)
268 throws SAXException
270 // no op
275 * Receive notification of a processing instruction.
277 * <p>By default, do nothing. Application writers may override this
278 * method in a subclass to take specific actions for each
279 * processing instruction, such as setting status variables or
280 * invoking other methods.</p>
282 * @param target The processing instruction target.
283 * @param data The processing instruction data, or null if
284 * none is supplied.
285 * @exception org.xml.sax.SAXException Any SAX exception, possibly
286 * wrapping another exception.
287 * @see org.xml.sax.DocumentHandler#processingInstruction
289 public void processingInstruction (String target, String data)
290 throws SAXException
292 // no op
297 ////////////////////////////////////////////////////////////////////
298 // Default implementation of the ErrorHandler interface.
299 ////////////////////////////////////////////////////////////////////
303 * Receive notification of a parser warning.
305 * <p>The default implementation does nothing. Application writers
306 * may override this method in a subclass to take specific actions
307 * for each warning, such as inserting the message in a log file or
308 * printing it to the console.</p>
310 * @param e The warning information encoded as an exception.
311 * @exception org.xml.sax.SAXException Any SAX exception, possibly
312 * wrapping another exception.
313 * @see org.xml.sax.ErrorHandler#warning
314 * @see org.xml.sax.SAXParseException
316 public void warning (SAXParseException e)
317 throws SAXException
319 // no op
324 * Receive notification of a recoverable parser error.
326 * <p>The default implementation does nothing. Application writers
327 * may override this method in a subclass to take specific actions
328 * for each error, such as inserting the message in a log file or
329 * printing it to the console.</p>
331 * @param e The warning information encoded as an exception.
332 * @exception org.xml.sax.SAXException Any SAX exception, possibly
333 * wrapping another exception.
334 * @see org.xml.sax.ErrorHandler#warning
335 * @see org.xml.sax.SAXParseException
337 public void error (SAXParseException e)
338 throws SAXException
340 // no op
345 * Report a fatal XML parsing error.
347 * <p>The default implementation throws a SAXParseException.
348 * Application writers may override this method in a subclass if
349 * they need to take specific actions for each fatal error (such as
350 * collecting all of the errors into a single report): in any case,
351 * the application must stop all regular processing when this
352 * method is invoked, since the document is no longer reliable, and
353 * the parser may no longer report parsing events.</p>
355 * @param e The error information encoded as an exception.
356 * @exception org.xml.sax.SAXException Any SAX exception, possibly
357 * wrapping another exception.
358 * @see org.xml.sax.ErrorHandler#fatalError
359 * @see org.xml.sax.SAXParseException
361 public void fatalError (SAXParseException e)
362 throws SAXException
364 throw e;
369 // end of HandlerBase.java