1. // $Id: ErrorListener.java,v 1.2 2003/09/19 10:10:13 jsuttor Exp $
  2. /*
  3. * @(#)ErrorListener.java 1.12 04/07/26
  4. *
  5. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  6. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  7. */
  8. package javax.xml.transform;
  9. /**
  10. * <p>To provide customized error handling, implement this interface and
  11. * use the <code>setErrorListener</code> method to register an instance of the
  12. * implmentation with the {@link javax.xml.transform.Transformer}. The
  13. * <code>Transformer</code> then reports all errors and warnings through this
  14. * interface.</p>
  15. *
  16. * <p>If an application does <em>not</em> register its own custom
  17. * <code>ErrorListener</code>, the default <code>ErrorListener</code>
  18. * is used which reports all warnings and errors to <code>System.err</code>
  19. * and does not throw any <code>Exception</code>s.
  20. * Applications are <em>strongly</em> encouraged to register and use
  21. * <code>ErrorListener</code>s that insure proper behavior for warnings and
  22. * errors.</p>
  23. *
  24. * <p>For transformation errors, a <code>Transformer</code> must use this
  25. * interface instead of throwing an <code>Exception</code>: it is up to the
  26. * application to decide whether to throw an <code>Exception</code> for
  27. * different types of errors and warnings. Note however that the
  28. * <code>Transformer</code> is not required to continue with the transformation
  29. * after a call to {@link #fatalError(TransformerException exception)}.</p>
  30. *
  31. * <p><code>Transformer</code>s may use this mechanism to report XML parsing
  32. * errors as well as transformation errors.</p>
  33. */
  34. public interface ErrorListener {
  35. /**
  36. * Receive notification of a warning.
  37. *
  38. * <p>{@link javax.xml.transform.Transformer} can use this method to report
  39. * conditions that are not errors or fatal errors. The default behaviour
  40. * is to take no action.</p>
  41. *
  42. * <p>After invoking this method, the Transformer must continue with
  43. * the transformation. It should still be possible for the
  44. * application to process the document through to the end.</p>
  45. *
  46. * @param exception The warning information encapsulated in a
  47. * transformer exception.
  48. *
  49. * @throws javax.xml.transform.TransformerException if the application
  50. * chooses to discontinue the transformation.
  51. *
  52. * @see javax.xml.transform.TransformerException
  53. */
  54. public abstract void warning(TransformerException exception)
  55. throws TransformerException;
  56. /**
  57. * Receive notification of a recoverable error.
  58. *
  59. * <p>The transformer must continue to try and provide normal transformation
  60. * after invoking this method. It should still be possible for the
  61. * application to process the document through to the end if no other errors
  62. * are encountered.</p>
  63. *
  64. * @param exception The error information encapsulated in a
  65. * transformer exception.
  66. *
  67. * @throws javax.xml.transform.TransformerException if the application
  68. * chooses to discontinue the transformation.
  69. *
  70. * @see javax.xml.transform.TransformerException
  71. */
  72. public abstract void error(TransformerException exception)
  73. throws TransformerException;
  74. /**
  75. * <p>Receive notification of a non-recoverable error.</p>
  76. *
  77. * <p>The <code>Transformer</code> must continue to try and provide normal
  78. * transformation after invoking this method. It should still be possible for the
  79. * application to process the document through to the end if no other errors
  80. * are encountered, but there is no guarantee that the output will be
  81. * useable.</p>
  82. *
  83. * @param exception The error information encapsulated in a
  84. * <code>TransformerException</code>.
  85. *
  86. * @throws javax.xml.transform.TransformerException if the application
  87. * chooses to discontinue the transformation.
  88. *
  89. * @see javax.xml.transform.TransformerException
  90. */
  91. public abstract void fatalError(TransformerException exception)
  92. throws TransformerException;
  93. }