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 * 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 * @since 1.4 35 */ 36 public class TransformerFactoryConfigurationError extends Error { 37 private static final long serialVersionUID = -6527718720676281516L; 38 39 /** 40 * <code>Exception</code> for the 41 * <code>TransformerFactoryConfigurationError</code>. 42 */ 43 private Exception exception; 44 45 /** 46 * Create a new <code>TransformerFactoryConfigurationError</code> with no 47 * detail message. 48 */ TransformerFactoryConfigurationError()49 public TransformerFactoryConfigurationError() { 50 51 super(); 52 53 this.exception = null; 54 } 55 56 /** 57 * Create a new <code>TransformerFactoryConfigurationError</code> with 58 * the <code>String</code> specified as an error message. 59 * 60 * @param msg The error message for the exception. 61 */ TransformerFactoryConfigurationError(String msg)62 public TransformerFactoryConfigurationError(String msg) { 63 64 super(msg); 65 66 this.exception = null; 67 } 68 69 /** 70 * Create a new <code>TransformerFactoryConfigurationError</code> with a 71 * given <code>Exception</code> base cause of the error. 72 * 73 * @param e The exception to be encapsulated in a 74 * TransformerFactoryConfigurationError. 75 */ TransformerFactoryConfigurationError(Exception e)76 public TransformerFactoryConfigurationError(Exception e) { 77 78 super(e.toString()); 79 80 this.exception = e; 81 } 82 83 /** 84 * Create a new <code>TransformerFactoryConfigurationError</code> with the 85 * given <code>Exception</code> base cause and detail message. 86 * 87 * @param e The exception to be encapsulated in a 88 * TransformerFactoryConfigurationError 89 * @param msg The detail message. 90 */ TransformerFactoryConfigurationError(Exception e, String msg)91 public TransformerFactoryConfigurationError(Exception e, String msg) { 92 93 super(msg); 94 95 this.exception = e; 96 } 97 98 /** 99 * Return the message (if any) for this error . If there is no 100 * message for the exception and there is an encapsulated 101 * exception then the message of that exception will be returned. 102 * 103 * @return The error message. 104 */ getMessage()105 public String getMessage() { 106 107 String message = super.getMessage(); 108 109 if ((message == null) && (exception != null)) { 110 return exception.getMessage(); 111 } 112 113 return message; 114 } 115 116 /** 117 * Return the actual exception (if any) that caused this exception to 118 * be raised. 119 * 120 * @return The encapsulated exception, or null if there is none. 121 */ getException()122 public Exception getException() { 123 return exception; 124 } 125 /** 126 * use the exception chaining mechanism of JDK1.4 127 */ 128 @Override getCause()129 public Throwable getCause() { 130 return exception; 131 } 132 } 133