KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > support > ejb > ejbqlc > EJBQLException


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25
26 /*
27  * EJBQLException.java
28  *
29  * Created on November 12, 2001
30  */

31
32 package com.sun.jdo.spi.persistence.support.ejb.ejbqlc;
33
34 /**
35  * This class represents errors reported by the EJBQL compiler.
36  *
37  * @author Michael Bouschen
38  */

39 public class EJBQLException
40     extends RuntimeException JavaDoc
41 {
42     /** The Throwable that caused this EJBQLException. */
43     Throwable JavaDoc cause;
44
45     /**
46      * Creates a new <code>EJBQLException</code> without detail message.
47      */

48     public EJBQLException()
49     {
50     }
51
52     /**
53      * Constructs a new <code>EJBQLException</code> with the specified
54      * detail message.
55      * @param msg the detail message.
56      */

57     public EJBQLException(String JavaDoc msg)
58     {
59         super(msg);
60     }
61     
62     /**
63       * Constructs a new <code>EJBQLException</code> with the specified
64       * detail message and cause.
65       * @param msg the detail message.
66       * @param cause the cause <code>Throwable</code>.
67       */

68     public EJBQLException(String JavaDoc msg, Throwable JavaDoc cause)
69     {
70         super(msg);
71         this.cause = cause;
72     }
73     
74     /**
75      * Returns the cause of this <code>EJBQLException</code> or
76      * <code>null</code> if the cause is nonexistent or unknown.
77      * @return the cause of this or <code>null</code> if the
78      * cause is nonexistent or unknown.
79      */

80     public Throwable JavaDoc getCause()
81     {
82         return cause;
83     }
84
85     /**
86      * The <code>String</code> representation includes the name of the class,
87      * the descriptive comment (if any),
88      * and the <code>String</code> representation of the cause
89      * <code>Throwable</code> (if any).
90      * @return the <code>String</code>.
91      */

92     public String JavaDoc toString() {
93         // calculate approximate size of the String to return
94
StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
95         sb.append (super.toString());
96         // include cause Throwable information
97
if (cause != null) {
98             sb.append("\n"); //NOI18N
99
sb.append("Nested exception"); //NOI18N
100
sb.append("\n"); //NOI18N
101
sb.append(cause.toString());
102         }
103         return sb.toString();
104     }
105 }
106
Popular Tags