Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / external / sax / org / xml / sax / helpers / DefaultHandler.java
blob56c84c1b9480d72988ca8be644e6161c997b8fab
1 // DefaultHandler.java - default implementation of the core handlers.
2 // http://www.saxproject.org
3 // Written by David Megginson
4 // NO WARRANTY! This class is in the public domain.
5 // $Id: DefaultHandler.java,v 1.1 2005/02/02 00:41:54 tromey Exp $
7 package org.xml.sax.helpers;
9 import java.io.IOException;
11 import org.xml.sax.InputSource;
12 import org.xml.sax.Locator;
13 import org.xml.sax.Attributes;
14 import org.xml.sax.EntityResolver;
15 import org.xml.sax.DTDHandler;
16 import org.xml.sax.ContentHandler;
17 import org.xml.sax.ErrorHandler;
18 import org.xml.sax.SAXException;
19 import org.xml.sax.SAXParseException;
22 /**
23 * Default base class for SAX2 event handlers.
25 * <blockquote>
26 * <em>This module, both source code and documentation, is in the
27 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
28 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
29 * for further information.
30 * </blockquote>
32 * <p>This class is available as a convenience base class for SAX2
33 * applications: it provides default implementations for all of the
34 * callbacks in the four core SAX2 handler classes:</p>
36 * <ul>
37 * <li>{@link org.xml.sax.EntityResolver EntityResolver}</li>
38 * <li>{@link org.xml.sax.DTDHandler DTDHandler}</li>
39 * <li>{@link org.xml.sax.ContentHandler ContentHandler}</li>
40 * <li>{@link org.xml.sax.ErrorHandler ErrorHandler}</li>
41 * </ul>
43 * <p>Application writers can extend this class when they need to
44 * implement only part of an interface; parser writers can
45 * instantiate this class to provide default handlers when the
46 * application has not supplied its own.</p>
48 * <p>This class replaces the deprecated SAX1
49 * {@link org.xml.sax.HandlerBase HandlerBase} class.</p>
51 * @since SAX 2.0
52 * @author David Megginson,
53 * @version 2.0.1 (sax2r2)
54 * @see org.xml.sax.EntityResolver
55 * @see org.xml.sax.DTDHandler
56 * @see org.xml.sax.ContentHandler
57 * @see org.xml.sax.ErrorHandler
59 public class DefaultHandler
60 implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler
64 ////////////////////////////////////////////////////////////////////
65 // Default implementation of the EntityResolver interface.
66 ////////////////////////////////////////////////////////////////////
68 /**
69 * Resolve an external entity.
71 * <p>Always return null, so that the parser will use the system
72 * identifier provided in the XML document. This method implements
73 * the SAX default behaviour: application writers can override it
74 * in a subclass to do special translations such as catalog lookups
75 * or URI redirection.</p>
77 * @param publicId The public identifer, or null if none is
78 * available.
79 * @param systemId The system identifier provided in the XML
80 * document.
81 * @return The new input source, or null to require the
82 * default behaviour.
83 * @exception java.io.IOException If there is an error setting
84 * up the new input source.
85 * @exception org.xml.sax.SAXException Any SAX exception, possibly
86 * wrapping another exception.
87 * @see org.xml.sax.EntityResolver#resolveEntity
89 public InputSource resolveEntity (String publicId, String systemId)
90 throws IOException, SAXException
92 return null;
97 ////////////////////////////////////////////////////////////////////
98 // Default implementation of DTDHandler interface.
99 ////////////////////////////////////////////////////////////////////
103 * Receive notification of a notation declaration.
105 * <p>By default, do nothing. Application writers may override this
106 * method in a subclass if they wish to keep track of the notations
107 * declared in a document.</p>
109 * @param name The notation name.
110 * @param publicId The notation public identifier, or null if not
111 * available.
112 * @param systemId The notation system identifier.
113 * @exception org.xml.sax.SAXException Any SAX exception, possibly
114 * wrapping another exception.
115 * @see org.xml.sax.DTDHandler#notationDecl
117 public void notationDecl (String name, String publicId, String systemId)
118 throws SAXException
120 // no op
125 * Receive notification of an unparsed entity declaration.
127 * <p>By default, do nothing. Application writers may override this
128 * method in a subclass to keep track of the unparsed entities
129 * declared in a document.</p>
131 * @param name The entity name.
132 * @param publicId The entity public identifier, or null if not
133 * available.
134 * @param systemId The entity system identifier.
135 * @param notationName The name of the associated notation.
136 * @exception org.xml.sax.SAXException Any SAX exception, possibly
137 * wrapping another exception.
138 * @see org.xml.sax.DTDHandler#unparsedEntityDecl
140 public void unparsedEntityDecl (String name, String publicId,
141 String systemId, String notationName)
142 throws SAXException
144 // no op
149 ////////////////////////////////////////////////////////////////////
150 // Default implementation of ContentHandler interface.
151 ////////////////////////////////////////////////////////////////////
155 * Receive a Locator object for document events.
157 * <p>By default, do nothing. Application writers may override this
158 * method in a subclass if they wish to store the locator for use
159 * with other document events.</p>
161 * @param locator A locator for all SAX document events.
162 * @see org.xml.sax.ContentHandler#setDocumentLocator
163 * @see org.xml.sax.Locator
165 public void setDocumentLocator (Locator locator)
167 // no op
172 * Receive notification of the beginning of the document.
174 * <p>By default, do nothing. Application writers may override this
175 * method in a subclass to take specific actions at the beginning
176 * of a document (such as allocating the root node of a tree or
177 * creating an output file).</p>
179 * @exception org.xml.sax.SAXException Any SAX exception, possibly
180 * wrapping another exception.
181 * @see org.xml.sax.ContentHandler#startDocument
183 public void startDocument ()
184 throws SAXException
186 // no op
191 * Receive notification of the end of the document.
193 * <p>By default, do nothing. Application writers may override this
194 * method in a subclass to take specific actions at the end
195 * of a document (such as finalising a tree or closing an output
196 * file).</p>
198 * @exception org.xml.sax.SAXException Any SAX exception, possibly
199 * wrapping another exception.
200 * @see org.xml.sax.ContentHandler#endDocument
202 public void endDocument ()
203 throws SAXException
205 // no op
210 * Receive notification of the start of a Namespace mapping.
212 * <p>By default, do nothing. Application writers may override this
213 * method in a subclass to take specific actions at the start of
214 * each Namespace prefix scope (such as storing the prefix mapping).</p>
216 * @param prefix The Namespace prefix being declared.
217 * @param uri The Namespace URI mapped to the prefix.
218 * @exception org.xml.sax.SAXException Any SAX exception, possibly
219 * wrapping another exception.
220 * @see org.xml.sax.ContentHandler#startPrefixMapping
222 public void startPrefixMapping (String prefix, String uri)
223 throws SAXException
225 // no op
230 * Receive notification of the end of a Namespace mapping.
232 * <p>By default, do nothing. Application writers may override this
233 * method in a subclass to take specific actions at the end of
234 * each prefix mapping.</p>
236 * @param prefix The Namespace prefix being declared.
237 * @exception org.xml.sax.SAXException Any SAX exception, possibly
238 * wrapping another exception.
239 * @see org.xml.sax.ContentHandler#endPrefixMapping
241 public void endPrefixMapping (String prefix)
242 throws SAXException
244 // no op
249 * Receive notification of the start of an element.
251 * <p>By default, do nothing. Application writers may override this
252 * method in a subclass to take specific actions at the start of
253 * each element (such as allocating a new tree node or writing
254 * output to a file).</p>
256 * @param uri The Namespace URI, or the empty string if the
257 * element has no Namespace URI or if Namespace
258 * processing is not being performed.
259 * @param localName The local name (without prefix), or the
260 * empty string if Namespace processing is not being
261 * performed.
262 * @param qName The qualified name (with prefix), or the
263 * empty string if qualified names are not available.
264 * @param attributes The attributes attached to the element. If
265 * there are no attributes, it shall be an empty
266 * Attributes object.
267 * @exception org.xml.sax.SAXException Any SAX exception, possibly
268 * wrapping another exception.
269 * @see org.xml.sax.ContentHandler#startElement
271 public void startElement (String uri, String localName,
272 String qName, Attributes attributes)
273 throws SAXException
275 // no op
280 * Receive notification of the end of an element.
282 * <p>By default, do nothing. Application writers may override this
283 * method in a subclass to take specific actions at the end of
284 * each element (such as finalising a tree node or writing
285 * output to a file).</p>
287 * @param uri The Namespace URI, or the empty string if the
288 * element has no Namespace URI or if Namespace
289 * processing is not being performed.
290 * @param localName The local name (without prefix), or the
291 * empty string if Namespace processing is not being
292 * performed.
293 * @param qName The qualified name (with prefix), or the
294 * empty string if qualified names are not available.
295 * @exception org.xml.sax.SAXException Any SAX exception, possibly
296 * wrapping another exception.
297 * @see org.xml.sax.ContentHandler#endElement
299 public void endElement (String uri, String localName, String qName)
300 throws SAXException
302 // no op
307 * Receive notification of character data inside an element.
309 * <p>By default, do nothing. Application writers may override this
310 * method to take specific actions for each chunk of character data
311 * (such as adding the data to a node or buffer, or printing it to
312 * a file).</p>
314 * @param ch The characters.
315 * @param start The start position in the character array.
316 * @param length The number of characters to use from the
317 * character array.
318 * @exception org.xml.sax.SAXException Any SAX exception, possibly
319 * wrapping another exception.
320 * @see org.xml.sax.ContentHandler#characters
322 public void characters (char ch[], int start, int length)
323 throws SAXException
325 // no op
330 * Receive notification of ignorable whitespace in element content.
332 * <p>By default, do nothing. Application writers may override this
333 * method to take specific actions for each chunk of ignorable
334 * whitespace (such as adding data to a node or buffer, or printing
335 * it to a file).</p>
337 * @param ch The whitespace characters.
338 * @param start The start position in the character array.
339 * @param length The number of characters to use from the
340 * character array.
341 * @exception org.xml.sax.SAXException Any SAX exception, possibly
342 * wrapping another exception.
343 * @see org.xml.sax.ContentHandler#ignorableWhitespace
345 public void ignorableWhitespace (char ch[], int start, int length)
346 throws SAXException
348 // no op
353 * Receive notification of a processing instruction.
355 * <p>By default, do nothing. Application writers may override this
356 * method in a subclass to take specific actions for each
357 * processing instruction, such as setting status variables or
358 * invoking other methods.</p>
360 * @param target The processing instruction target.
361 * @param data The processing instruction data, or null if
362 * none is supplied.
363 * @exception org.xml.sax.SAXException Any SAX exception, possibly
364 * wrapping another exception.
365 * @see org.xml.sax.ContentHandler#processingInstruction
367 public void processingInstruction (String target, String data)
368 throws SAXException
370 // no op
375 * Receive notification of a skipped entity.
377 * <p>By default, do nothing. Application writers may override this
378 * method in a subclass to take specific actions for each
379 * processing instruction, such as setting status variables or
380 * invoking other methods.</p>
382 * @param name The name of the skipped entity.
383 * @exception org.xml.sax.SAXException Any SAX exception, possibly
384 * wrapping another exception.
385 * @see org.xml.sax.ContentHandler#processingInstruction
387 public void skippedEntity (String name)
388 throws SAXException
390 // no op
395 ////////////////////////////////////////////////////////////////////
396 // Default implementation of the ErrorHandler interface.
397 ////////////////////////////////////////////////////////////////////
401 * Receive notification of a parser warning.
403 * <p>The default implementation does nothing. Application writers
404 * may override this method in a subclass to take specific actions
405 * for each warning, such as inserting the message in a log file or
406 * printing it to the console.</p>
408 * @param e The warning information encoded as an exception.
409 * @exception org.xml.sax.SAXException Any SAX exception, possibly
410 * wrapping another exception.
411 * @see org.xml.sax.ErrorHandler#warning
412 * @see org.xml.sax.SAXParseException
414 public void warning (SAXParseException e)
415 throws SAXException
417 // no op
422 * Receive notification of a recoverable parser error.
424 * <p>The default implementation does nothing. Application writers
425 * may override this method in a subclass to take specific actions
426 * for each error, such as inserting the message in a log file or
427 * printing it to the console.</p>
429 * @param e The warning information encoded as an exception.
430 * @exception org.xml.sax.SAXException Any SAX exception, possibly
431 * wrapping another exception.
432 * @see org.xml.sax.ErrorHandler#warning
433 * @see org.xml.sax.SAXParseException
435 public void error (SAXParseException e)
436 throws SAXException
438 // no op
443 * Report a fatal XML parsing error.
445 * <p>The default implementation throws a SAXParseException.
446 * Application writers may override this method in a subclass if
447 * they need to take specific actions for each fatal error (such as
448 * collecting all of the errors into a single report): in any case,
449 * the application must stop all regular processing when this
450 * method is invoked, since the document is no longer reliable, and
451 * the parser may no longer report parsing events.</p>
453 * @param e The error information encoded as an exception.
454 * @exception org.xml.sax.SAXException Any SAX exception, possibly
455 * wrapping another exception.
456 * @see org.xml.sax.ErrorHandler#fatalError
457 * @see org.xml.sax.SAXParseException
459 public void fatalError (SAXParseException e)
460 throws SAXException
462 throw e;
467 // end of DefaultHandler.java