KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portalImpl > xml > XmlException


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17
18  */

19
20 package org.apache.pluto.portalImpl.xml;
21
22 /**
23  ** The <CODE>XMLException</CODE> class defines a general exception
24  ** that may occur during portlet.xml or web.xml handling
25  **
26
27  **/

28
29 public class XmlException extends java.lang.Exception JavaDoc
30 {
31
32     private Throwable JavaDoc throwable = null;
33
34     /**
35      ** Constructs a new xml exception.
36      **/

37
38     public XmlException ()
39     {
40         super();
41     }
42
43     /**
44      ** Constructs a new xml exception with the given text.
45      **
46      ** @param text
47      ** the exception text
48      **/

49
50     public XmlException (String JavaDoc text)
51     {
52         super(text);
53     }
54
55     /**
56      ** Constructs a new xml exception to throw an
57      ** exception and include a message about the "root case" that interfered
58      ** with its normal operation, including a description message.
59      **
60      ** @param text
61      ** the exception text
62      ** @param cause
63      ** the root cause
64      **/

65
66     public XmlException (String JavaDoc text, Throwable JavaDoc cause)
67     {
68         super (text);
69         throwable = cause;
70     }
71
72     /**
73      ** Constructs a new xml exception to throw an
74      ** exception. The exception's message is based on the localized message
75      ** of the underlying exception.
76      **
77      ** @param cause
78      ** the root cause
79      **/

80
81     public XmlException (Throwable JavaDoc cause)
82     {
83     super(cause.getLocalizedMessage());
84         throwable = cause;
85     }
86
87     /**
88      * Returns the exception that caused this xml exception.
89      *
90      *
91      * @return the <code>Throwable</code>
92      * that caused this xml exception
93      *
94      */

95     
96     public Throwable JavaDoc getRootCause()
97     {
98     return throwable;
99     }
100
101     /**
102      * Prints the stack trace of this exception to the standard error stream.
103      */

104     public void printStackTrace()
105     {
106         this.printStackTrace(System.err);
107     }
108
109     /**
110      * Prints the stack trace of this exception to the specified print stream.
111      *
112      * @param out the <code>PrintStream</code> to use for output
113      */

114     public void printStackTrace(java.io.PrintStream JavaDoc out)
115     {
116         this.printStackTrace(new java.io.PrintWriter JavaDoc(out, true));
117     }
118
119     /**
120      * Prints the stack trace of this exception to the specified print writer.
121      *
122      * @param out the <code>PrintWriter</code> to use for output.
123      */

124     public void printStackTrace(java.io.PrintWriter JavaDoc out)
125     {
126         super.printStackTrace(out);
127
128         if( getRootCause () != null )
129         {
130             out.println();
131             out.print("Nested Exception is ");
132             getRootCause ().printStackTrace(out);
133         }
134     }
135
136 }
137
Popular Tags