View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 2001, 2002,2004 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *      http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package com.sun.org.apache.xerces.internal.xni;
22  
23  /**
24   * This exception is the base exception of all XNI exceptions. It
25   * can be constructed with an error message or used to wrap another
26   * exception object.
27   * <p>
28   * <strong>Note:</strong> By extending the Java
29   * <code>RuntimeException</code>, XNI handlers and components are
30   * not required to catch XNI exceptions but may explicitly catch
31   * them, if so desired.
32   *
33   * @author Andy Clark, IBM
34   *
35   * @version $Id: XNIException.java,v 1.6 2010-11-01 04:40:19 joehw Exp $
36   */
37  public class XNIException
38      extends RuntimeException {
39  
40      /** Serialization version. */
41      static final long serialVersionUID = 9019819772686063775L;
42  
43      //
44      // Data
45      //
46  
47      /** The wrapped exception. */
48      private Exception fException;
49  
50      //
51      // Constructors
52      //
53  
54      /**
55       * Constructs an XNI exception with a message.
56       *
57       * @param message The exception message.
58       */
59      public XNIException(String message) {
60          super(message);
61      } // <init>(String)
62  
63      /**
64       * Constructs an XNI exception with a wrapped exception.
65       *
66       * @param exception The wrapped exception.
67       */
68      public XNIException(Exception exception) {
69          super(exception.getMessage());
70          fException = exception;
71      } // <init>(Exception)
72  
73      /**
74       * Constructs an XNI exception with a message and wrapped exception.
75       *
76       * @param message The exception message.
77       * @param exception The wrapped exception.
78       */
79      public XNIException(String message, Exception exception) {
80          super(message);
81          fException = exception;
82      } // <init>(Exception,String)
83  
84      //
85      // Public methods
86      //
87  
88      /** Returns the wrapped exception. */
89      public Exception getException() {
90          return fException;
91      } // getException():Exception
92  
93      public Throwable getCause() {
94         return fException;
95      }
96  } // class QName