KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > browser > core > naming > ExceptionWrapper


1 /*===========================================================================
2
3 ObjectWeb Util API
4 Copyright (C) 2002 USTL - LIFL - GOAL
5 Contact: architecture@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ===========================================================================*/

26
27 package org.objectweb.util.browser.core.naming;
28
29 /** To use the ExceptionHolder interface */
30
31 import org.objectweb.util.browser.core.api.ExceptionHolder;
32
33 /**
34  * RuntimeException subclass to wrap a Java exception.
35  *
36  * As ExceptionWrapper is a subclass of RuntimeException,
37  * a method is not required to declare it in its throws clause
38  * that might be thrown during the execution of the method but not caught.
39  *
40  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
41  * @version 0.1
42  */

43 public class ExceptionWrapper extends java.lang.RuntimeException JavaDoc implements ExceptionHolder {
44
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

51     /** The wrapped Java exception. */
52     private Exception JavaDoc exception_ = null;
53
54     // ==================================================================
55
//
56
// Constructors.
57
//
58
// ==================================================================
59

60     /**
61      * Constructs an ExceptionWrapper with no detail message and
62      * no wrapped Java exception.
63      *
64      * This constructor sets the detail message and
65      * the wrapped Java exception to the null value.
66      *
67      * @postcondition
68      * getMessage() == null
69      * and getOWException() == null;
70      */

71     public ExceptionWrapper() {
72         this(null, null);
73     }
74
75     /**
76      * Constructs an ExceptionWrapper with a detail message and
77      * no wrapped Java exception.
78      *
79      * This constructor sets the detail message to the given message
80      * and the wrapped Java exception to the null value.
81      *
82      * @param message The detail message.
83      *
84      * @postcondition
85      * getMessage() == message
86      * and getOWException() == null;
87      */

88     public ExceptionWrapper(String JavaDoc message) {
89         this(message, null);
90     }
91
92     /**
93      * Constructs an ExceptionWrapper with no detail message and
94      * a wrapped Java exception.
95      *
96      * This constructor sets the detail message to the null value
97      * and the wrapped Java exception to the given exception.
98      *
99      * @param exception The Java exception to wrap.
100      *
101      * @postcondition
102      * getMessage() == null
103      * and getOWException() == exception;
104      */

105     public ExceptionWrapper(Exception JavaDoc exception) {
106         this(null, exception);
107     }
108
109     /**
110      * Constructs an ExceptionWrapper with a detail message and
111      * a wrapped Java exception.
112      *
113      * This constructor sets the detail message to the given message
114      * and the wrapped Java exception to the given exception.
115      *
116      * @param message The detail message.
117      * @param exception The Java exception to wrap.
118      *
119      * @postcondition
120      * getMessage() == message
121      * and getOWException() == exception;
122      */

123     public ExceptionWrapper(String JavaDoc message, Exception JavaDoc exception) {
124         // Calls the RuntimeException constructor.
125
super(message);
126         // Inits the internal state.
127
setOWException(exception);
128     }
129
130     // ==================================================================
131
//
132
// Internal methods.
133
//
134
// ==================================================================
135

136     // ==================================================================
137
//
138
// Public methods for interface ExceptionHolder.
139
//
140
// ==================================================================
141

142     /**
143      * Returns the wrapped Java exception.
144      *
145      * This method does not update the wrapped Java exception.
146      *
147      * @return The wrapped Java exception.
148      *
149      * @postcondition return == getOWException();
150      */

151     public java.lang.Exception JavaDoc getOWException() {
152         return exception_;
153     }
154
155     /**
156      * Sets the wrapped Java exception.
157      *
158      * This method sets the wrapped Java exception with the given exception.
159      *
160      * @param exception The Java exception to wrap.
161      *
162      * @postcondition getOWException() == exception;
163      */

164     public void setOWException(java.lang.Exception JavaDoc exception) {
165         exception_ = exception;
166     }
167
168 }
169
Popular Tags