12005
|
1 |
/*
|
|
2 |
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package javax.xml.transform;
|
|
27 |
|
|
28 |
/**
|
|
29 |
* <p>To provide customized error handling, implement this interface and
|
|
30 |
* use the <code>setErrorListener</code> method to register an instance of the
|
24887
|
31 |
* implementation with the {@link javax.xml.transform.Transformer}. The
|
12005
|
32 |
* <code>Transformer</code> then reports all errors and warnings through this
|
|
33 |
* interface.</p>
|
|
34 |
*
|
|
35 |
* <p>If an application does <em>not</em> register its own custom
|
|
36 |
* <code>ErrorListener</code>, the default <code>ErrorListener</code>
|
|
37 |
* is used which reports all warnings and errors to <code>System.err</code>
|
|
38 |
* and does not throw any <code>Exception</code>s.
|
|
39 |
* Applications are <em>strongly</em> encouraged to register and use
|
|
40 |
* <code>ErrorListener</code>s that insure proper behavior for warnings and
|
|
41 |
* errors.</p>
|
|
42 |
*
|
|
43 |
* <p>For transformation errors, a <code>Transformer</code> must use this
|
|
44 |
* interface instead of throwing an <code>Exception</code>: it is up to the
|
|
45 |
* application to decide whether to throw an <code>Exception</code> for
|
|
46 |
* different types of errors and warnings. Note however that the
|
|
47 |
* <code>Transformer</code> is not required to continue with the transformation
|
|
48 |
* after a call to {@link #fatalError(TransformerException exception)}.</p>
|
|
49 |
*
|
|
50 |
* <p><code>Transformer</code>s may use this mechanism to report XML parsing
|
|
51 |
* errors as well as transformation errors.</p>
|
25262
|
52 |
*
|
|
53 |
* @since 1.4
|
12005
|
54 |
*/
|
|
55 |
public interface ErrorListener {
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Receive notification of a warning.
|
|
59 |
*
|
|
60 |
* <p>{@link javax.xml.transform.Transformer} can use this method to report
|
|
61 |
* conditions that are not errors or fatal errors. The default behaviour
|
|
62 |
* is to take no action.</p>
|
|
63 |
*
|
|
64 |
* <p>After invoking this method, the Transformer must continue with
|
|
65 |
* the transformation. It should still be possible for the
|
|
66 |
* application to process the document through to the end.</p>
|
|
67 |
*
|
|
68 |
* @param exception The warning information encapsulated in a
|
|
69 |
* transformer exception.
|
|
70 |
*
|
|
71 |
* @throws javax.xml.transform.TransformerException if the application
|
|
72 |
* chooses to discontinue the transformation.
|
|
73 |
*
|
|
74 |
* @see javax.xml.transform.TransformerException
|
|
75 |
*/
|
|
76 |
public abstract void warning(TransformerException exception)
|
|
77 |
throws TransformerException;
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Receive notification of a recoverable error.
|
|
81 |
*
|
|
82 |
* <p>The transformer must continue to try and provide normal transformation
|
|
83 |
* after invoking this method. It should still be possible for the
|
|
84 |
* application to process the document through to the end if no other errors
|
|
85 |
* are encountered.</p>
|
|
86 |
*
|
|
87 |
* @param exception The error information encapsulated in a
|
|
88 |
* transformer exception.
|
|
89 |
*
|
|
90 |
* @throws javax.xml.transform.TransformerException if the application
|
|
91 |
* chooses to discontinue the transformation.
|
|
92 |
*
|
|
93 |
* @see javax.xml.transform.TransformerException
|
|
94 |
*/
|
|
95 |
public abstract void error(TransformerException exception)
|
|
96 |
throws TransformerException;
|
|
97 |
|
|
98 |
/**
|
|
99 |
* <p>Receive notification of a non-recoverable error.</p>
|
|
100 |
*
|
|
101 |
* <p>The processor may choose to continue, but will not normally
|
|
102 |
* proceed to a successful completion.</p>
|
|
103 |
*
|
|
104 |
* <p>The method should throw an exception if it is unable to
|
|
105 |
* process the error, or if it wishes execution to terminate
|
|
106 |
* immediately. The processor will not necessarily honor this
|
|
107 |
* request.</p>
|
|
108 |
*
|
|
109 |
* @param exception The error information encapsulated in a
|
|
110 |
* <code>TransformerException</code>.
|
|
111 |
*
|
|
112 |
* @throws javax.xml.transform.TransformerException if the application
|
|
113 |
* chooses to discontinue the transformation.
|
|
114 |
*
|
|
115 |
* @see javax.xml.transform.TransformerException
|
|
116 |
*/
|
|
117 |
public abstract void fatalError(TransformerException exception)
|
|
118 |
throws TransformerException;
|
|
119 |
}
|