Home | History | Annotate | Download | only in transform
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one or more
      3  * contributor license agreements.  See the NOTICE file distributed with
      4  * this work for additional information regarding copyright ownership.
      5  * The ASF licenses this file to You under the Apache License, Version 2.0
      6  * (the "License"); you may not use this file except in compliance with
      7  * the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 // $Id: TransformerFactoryConfigurationError.java 569994 2007-08-27 04:28:57Z mrglavas $
     19 
     20 package javax.xml.transform;
     21 
     22 /**
     23  * Thrown when a problem with configuration with the Transformer Factories
     24  * exists. This error will typically be thrown when the class of a
     25  * transformation factory specified in the system properties cannot be found
     26  * or instantiated.
     27  */
     28 public class TransformerFactoryConfigurationError extends Error {
     29 
     30     /**
     31      * <code>Exception</code> for the
     32      *  <code>TransformerFactoryConfigurationError</code>.
     33      */
     34     private Exception exception;
     35 
     36     /**
     37      * Create a new <code>TransformerFactoryConfigurationError</code> with no
     38      * detail message.
     39      */
     40     public TransformerFactoryConfigurationError() {
     41         this.exception = null;
     42     }
     43 
     44     /**
     45      * Create a new <code>TransformerFactoryConfigurationError</code> with
     46      * the <code>String</code> specified as an error message.
     47      *
     48      * @param msg The error message for the exception.
     49      */
     50     public TransformerFactoryConfigurationError(String msg) {
     51 
     52         super(msg);
     53 
     54         this.exception = null;
     55     }
     56 
     57     /**
     58      * Create a new <code>TransformerFactoryConfigurationError</code> with a
     59      * given <code>Exception</code> base cause of the error.
     60      *
     61      * @param e The exception to be encapsulated in a
     62      * TransformerFactoryConfigurationError.
     63      */
     64     public TransformerFactoryConfigurationError(Exception e) {
     65 
     66         super(e.toString());
     67 
     68         this.exception = e;
     69     }
     70 
     71     /**
     72      * Create a new <code>TransformerFactoryConfigurationError</code> with the
     73      * given <code>Exception</code> base cause and detail message.
     74      *
     75      * @param e The exception to be encapsulated in a
     76      * TransformerFactoryConfigurationError
     77      * @param msg The detail message.
     78      */
     79     public TransformerFactoryConfigurationError(Exception e, String msg) {
     80 
     81         super(msg);
     82 
     83         this.exception = e;
     84     }
     85 
     86     /**
     87      * Return the message (if any) for this error . If there is no
     88      * message for the exception and there is an encapsulated
     89      * exception then the message of that exception will be returned.
     90      *
     91      * @return The error message.
     92      */
     93     public String getMessage() {
     94 
     95         String message = super.getMessage();
     96 
     97         if ((message == null) && (exception != null)) {
     98             return exception.getMessage();
     99         }
    100 
    101         return message;
    102     }
    103 
    104     /**
    105      * Return the actual exception (if any) that caused this exception to
    106      * be raised.
    107      *
    108      * @return The encapsulated exception, or null if there is none.
    109      */
    110     public Exception getException() {
    111         return exception;
    112     }
    113 }
    114