1. // SAX error handler.
  2. // No warranty; no copyright -- use this as you will.
  3. // $Id: ErrorHandler.java,v 1.2 2001/08/01 06:43:17 tcng Exp $
  4. package org.xml.sax;
  5. /**
  6. * Basic interface for SAX error handlers.
  7. *
  8. * <blockquote>
  9. * <em>This module, both source code and documentation, is in the
  10. * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  11. * </blockquote>
  12. *
  13. * <p>If a SAX application needs to implement customized error
  14. * handling, it must implement this interface and then register an
  15. * instance with the XML reader using the
  16. * {@link org.xml.sax.XMLReader#setErrorHandler setErrorHandler}
  17. * method. The parser will then report all errors and warnings
  18. * through this interface.</p>
  19. *
  20. * <p><strong>WARNING:</strong> If an application does <em>not</em>
  21. * register an ErrorHandler, XML parsing errors will go unreported
  22. * and bizarre behaviour may result.</p>
  23. *
  24. * <p>For XML processing errors, a SAX driver must use this interface
  25. * instead of throwing an exception: it is up to the application
  26. * to decide whether to throw an exception for different types of
  27. * errors and warnings. Note, however, that there is no requirement that
  28. * the parser continue to provide useful information after a call to
  29. * {@link #fatalError fatalError} (in other words, a SAX driver class
  30. * could catch an exception and report a fatalError).</p>
  31. *
  32. * @since SAX 1.0
  33. * @author David Megginson,
  34. * <a href="mailto:sax@megginson.com">sax@megginson.com</a>
  35. * @version 2.0
  36. * @see org.xml.sax.Parser#setErrorHandler
  37. * @see org.xml.sax.SAXParseException
  38. */
  39. public interface ErrorHandler {
  40. /**
  41. * Receive notification of a warning.
  42. *
  43. * <p>SAX parsers will use this method to report conditions that
  44. * are not errors or fatal errors as defined by the XML 1.0
  45. * recommendation. The default behaviour is to take no action.</p>
  46. *
  47. * <p>The SAX parser must continue to provide normal parsing events
  48. * after invoking this method: it should still be possible for the
  49. * application to process the document through to the end.</p>
  50. *
  51. * <p>Filters may use this method to report other, non-XML warnings
  52. * as well.</p>
  53. *
  54. * @param exception The warning information encapsulated in a
  55. * SAX parse exception.
  56. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  57. * wrapping another exception.
  58. * @see org.xml.sax.SAXParseException
  59. */
  60. public abstract void warning (SAXParseException exception)
  61. throws SAXException;
  62. /**
  63. * Receive notification of a recoverable error.
  64. *
  65. * <p>This corresponds to the definition of "error" in section 1.2
  66. * of the W3C XML 1.0 Recommendation. For example, a validating
  67. * parser would use this callback to report the violation of a
  68. * validity constraint. The default behaviour is to take no
  69. * action.</p>
  70. *
  71. * <p>The SAX parser must continue to provide normal parsing events
  72. * after invoking this method: it should still be possible for the
  73. * application to process the document through to the end. If the
  74. * application cannot do so, then the parser should report a fatal
  75. * error even if the XML 1.0 recommendation does not require it to
  76. * do so.</p>
  77. *
  78. * <p>Filters may use this method to report other, non-XML errors
  79. * as well.</p>
  80. *
  81. * @param exception The error information encapsulated in a
  82. * SAX parse exception.
  83. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  84. * wrapping another exception.
  85. * @see org.xml.sax.SAXParseException
  86. */
  87. public abstract void error (SAXParseException exception)
  88. throws SAXException;
  89. /**
  90. * Receive notification of a non-recoverable error.
  91. *
  92. * <p>This corresponds to the definition of "fatal error" in
  93. * section 1.2 of the W3C XML 1.0 Recommendation. For example, a
  94. * parser would use this callback to report the violation of a
  95. * well-formedness constraint.</p>
  96. *
  97. * <p>The application must assume that the document is unusable
  98. * after the parser has invoked this method, and should continue
  99. * (if at all) only for the sake of collecting addition error
  100. * messages: in fact, SAX parsers are free to stop reporting any
  101. * other events once this method has been invoked.</p>
  102. *
  103. * @param exception The error information encapsulated in a
  104. * SAX parse exception.
  105. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  106. * wrapping another exception.
  107. * @see org.xml.sax.SAXParseException
  108. */
  109. public abstract void fatalError (SAXParseException exception)
  110. throws SAXException;
  111. }
  112. // end of ErrorHandler.java