KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hpsf > HPSFRuntimeException


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    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 package org.apache.poi.hpsf;
19
20 import java.io.PrintStream JavaDoc;
21 import java.io.PrintWriter JavaDoc;
22
23 /**
24  * <p>This exception is the superclass of all other unchecked
25  * exceptions thrown in this package. It supports a nested "reason"
26  * throwable, i.e. an exception that caused this one to be thrown.</p>
27  *
28  * @author Rainer Klute <a
29  * HREF="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
30  * @version $Id: HPSFRuntimeException.java,v 1.9 2004/04/09 13:05:16 glens Exp $
31  * @since 2002-02-09
32  */

33 public class HPSFRuntimeException extends RuntimeException JavaDoc
34 {
35
36     /** <p>The underlying reason for this exception - may be
37      * <code>null</code>.</p> */

38     private Throwable JavaDoc reason;
39
40
41
42     /**
43      * <p>Creates a new {@link HPSFRuntimeException}.</p>
44      */

45     public HPSFRuntimeException()
46     {
47         super();
48     }
49
50
51
52     /**
53      * <p>Creates a new {@link HPSFRuntimeException} with a message
54      * string.</p>
55      *
56      * @param msg The message string.
57      */

58     public HPSFRuntimeException(final String JavaDoc msg)
59     {
60         super(msg);
61     }
62
63
64
65     /**
66      * <p>Creates a new {@link HPSFRuntimeException} with a
67      * reason.</p>
68      *
69      * @param reason The reason, i.e. a throwable that indirectly
70      * caused this exception.
71      */

72     public HPSFRuntimeException(final Throwable JavaDoc reason)
73     {
74         super();
75         this.reason = reason;
76     }
77
78
79
80     /**
81      * <p>Creates a new {@link HPSFRuntimeException} with a message
82      * string and a reason.</p>
83      *
84      * @param msg The message string.
85      * @param reason The reason, i.e. a throwable that indirectly
86      * caused this exception.
87      */

88     public HPSFRuntimeException(final String JavaDoc msg, final Throwable JavaDoc reason)
89     {
90         super(msg);
91         this.reason = reason;
92     }
93
94
95
96     /**
97      * <p>Returns the {@link Throwable} that caused this exception to
98      * be thrown or <code>null</code> if there was no such {@link
99      * Throwable}.</p>
100      *
101      * @return The reason
102      */

103     public Throwable JavaDoc getReason()
104     {
105         return reason;
106     }
107
108
109
110     /**
111      * @see Throwable#printStackTrace()
112      */

113     public void printStackTrace()
114     {
115         printStackTrace(System.err);
116     }
117
118
119
120     /**
121      * @see Throwable#printStackTrace(java.io.PrintStream)
122      */

123     public void printStackTrace(final PrintStream JavaDoc p)
124     {
125         final Throwable JavaDoc reason = getReason();
126         super.printStackTrace(p);
127         if (reason != null)
128         {
129             p.println("Caused by:");
130             reason.printStackTrace(p);
131         }
132     }
133
134
135
136     /**
137      * @see Throwable#printStackTrace(java.io.PrintWriter)
138      */

139     public void printStackTrace(final PrintWriter JavaDoc p)
140     {
141         final Throwable JavaDoc reason = getReason();
142         super.printStackTrace(p);
143         if (reason != null)
144         {
145             p.println("Caused by:");
146             reason.printStackTrace(p);
147         }
148     }
149
150 }
151
Popular Tags