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