1 /*
2 * Copyright 2000-2005 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package javax.xml.transform;
27
28 /**
29 * Thrown when a problem with configuration with the Transformer Factories
30 * exists. This error will typically be thrown when the class of a
31 * transformation factory specified in the system properties cannot be found
32 * or instantiated.
33 */
34 public class TransformerFactoryConfigurationError extends Error {
35
36 /**
37 * <code>Exception</code> for the
38 * <code>TransformerFactoryConfigurationError</code>.
39 */
40 private Exception exception;
41
42 /**
43 * Create a new <code>TransformerFactoryConfigurationError</code> with no
44 * detail mesage.
45 */
46 public TransformerFactoryConfigurationError() {
47
48 super();
49
50 this.exception = null;
51 }
52
53 /**
54 * Create a new <code>TransformerFactoryConfigurationError</code> with
55 * the <code>String</code> specified as an error message.
56 *
57 * @param msg The error message for the exception.
58 */
59 public TransformerFactoryConfigurationError(String msg) {
60
61 super(msg);
62
63 this.exception = null;
64 }
65
66 /**
67 * Create a new <code>TransformerFactoryConfigurationError</code> with a
68 * given <code>Exception</code> base cause of the error.
69 *
70 * @param e The exception to be encapsulated in a
71 * TransformerFactoryConfigurationError.
72 */
73 public TransformerFactoryConfigurationError(Exception e) {
74
75 super(e.toString());
76
77 this.exception = e;
78 }
79
80 /**
81 * Create a new <code>TransformerFactoryConfigurationError</code> with the
82 * given <code>Exception</code> base cause and detail message.
83 *
84 * @param e The exception to be encapsulated in a
85 * TransformerFactoryConfigurationError
86 * @param msg The detail message.
87 */
88 public TransformerFactoryConfigurationError(Exception e, String msg) {
89
90 super(msg);
91
92 this.exception = e;
93 }
94
95 /**
96 * Return the message (if any) for this error . If there is no
97 * message for the exception and there is an encapsulated
98 * exception then the message of that exception will be returned.
99 *
100 * @return The error message.
101 */
102 public String getMessage() {
103
104 String message = super.getMessage();
105
106 if ((message == null) && (exception != null)) {
107 return exception.getMessage();
108 }
109
110 return message;
111 }
112
113 /**
114 * Return the actual exception (if any) that caused this exception to
115 * be raised.
116 *
117 * @return The encapsulated exception, or null if there is none.
118 */
119 public Exception getException() {
120 return exception;
121 }
122 }