KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > exceptions > CJDBCException


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2005 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Mathieu Peltier.
22  * Contributor(s): _______________________.
23  */

24
25 package org.objectweb.cjdbc.common.exceptions;
26
27 import java.io.PrintStream JavaDoc;
28 import java.io.PrintWriter JavaDoc;
29 import java.io.Serializable JavaDoc;
30
31 /**
32  * C-JDBC base exception.
33  *
34  * @author <a HREF="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
35  * @version 1.0
36  */

37 public class CJDBCException extends Exception JavaDoc implements Serializable JavaDoc
38 {
39   private static final long serialVersionUID = -1899348090329064503L;
40
41   /** Optional exception cause */
42   protected Throwable JavaDoc cause;
43
44   /**
45    * Creates a new <code>CJDBCException</code> instance.
46    */

47   public CJDBCException()
48   {
49   }
50
51   /**
52    * Creates a new <code>CJDBCException</code> instance.
53    *
54    * @param message the error message
55    */

56   public CJDBCException(String JavaDoc message)
57   {
58     super(message);
59   }
60
61   /**
62    * Creates a new <code>CJDBCException</code> instance.
63    *
64    * @param cause the root cause
65    */

66   public CJDBCException(Throwable JavaDoc cause)
67   {
68     this.cause = cause;
69   }
70
71   /**
72    * Creates a new <code>CJDBCException</code> instance.
73    *
74    * @param message the error message
75    * @param cause the root cause
76    */

77   public CJDBCException(String JavaDoc message, Throwable JavaDoc cause)
78   {
79     super(message);
80     this.cause = cause;
81   }
82
83   /**
84    * Gets the root cause of this exception.
85    *
86    * @return a <code>Throwable</code> object
87    */

88   public Throwable JavaDoc getCause()
89   {
90     return cause;
91   }
92
93   /**
94    * @see java.lang.Throwable#fillInStackTrace()
95    */

96   public synchronized Throwable JavaDoc fillInStackTrace()
97   {
98     if (cause != null)
99     {
100       return cause.fillInStackTrace();
101     }
102     else
103     {
104       return super.fillInStackTrace();
105     }
106   }
107
108   /**
109    * @see java.lang.Throwable#getStackTrace()
110    */

111   public StackTraceElement JavaDoc[] getStackTrace()
112   {
113     if (cause != null)
114     {
115       return cause.getStackTrace();
116     }
117     else
118     {
119       return super.getStackTrace();
120     }
121   }
122
123   /**
124    * @see java.lang.Throwable#getMessage()
125    */

126   public String JavaDoc getMessage()
127   {
128     if (cause != null)
129     {
130       return cause.getMessage();
131     }
132     else
133     {
134       return super.getMessage();
135     }
136   }
137
138   /**
139    * @see java.lang.Throwable#printStackTrace()
140    */

141   public void printStackTrace()
142   {
143     if (cause != null)
144     {
145       cause.printStackTrace();
146     }
147     else
148     {
149       super.printStackTrace();
150     }
151   }
152
153   /**
154    * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
155    */

156   public void printStackTrace(PrintStream JavaDoc arg0)
157   {
158     if (cause != null)
159     {
160       cause.printStackTrace(arg0);
161     }
162     else
163     {
164       super.printStackTrace(arg0);
165     }
166   }
167
168   /**
169    * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
170    */

171   public void printStackTrace(PrintWriter JavaDoc arg0)
172   {
173     if (cause != null)
174     {
175       cause.printStackTrace(arg0);
176     }
177     else
178     {
179       super.printStackTrace(arg0);
180     }
181   }
182
183   /**
184    * @see java.lang.Throwable#setStackTrace(java.lang.StackTraceElement[])
185    */

186   public void setStackTrace(StackTraceElement JavaDoc[] arg0)
187   {
188     if (cause != null)
189     {
190       cause.setStackTrace(arg0);
191     }
192     else
193     {
194       super.setStackTrace(arg0);
195     }
196   }
197
198 }
199
Popular Tags