KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > guiframework > view > event > ErrorEvent


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 package com.sun.enterprise.tools.guiframework.view.event;
25
26 import com.iplanet.jato.view.View;
27 import com.iplanet.jato.view.ViewBean;
28
29 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor;
30
31 import java.util.EventObject JavaDoc;
32
33
34 /**
35  * This event object will be created and used when an error is caught by the
36  * framework and there is an error handler defined to take care of the
37  * exception.
38  */

39 public class ErrorEvent extends EventObject JavaDoc {
40
41     /**
42      * This is the constructor for a ErrorEvent. You must specify the
43      * ViewDescriptor (the ViewDescriptor containing the error handler).
44      *
45      * @param src The View described by ViewDescriptor
46      * @param desc The ViewDescriptor containing the error handler
47      * @param vb The ViewBean
48      * @param ex The Exception / Error
49      * @param causeView The View responsible for the Exception / Error
50      * @param causeDesc The responsible ViewDescrptor
51      * @param exMsg Short exception message
52      * @param exClass The Exception type (class name)
53      * @param causeMsg The root cause short exception message
54      * @param causeClass The root cause exception type (class name)
55      * @param fullTrace The full stackTrace to the root cause
56      * @param regTrace The regular stackTrace
57      */

58     public ErrorEvent(View src, ViewDescriptor desc, ViewBean vb, Throwable JavaDoc ex,
59               View causeView, ViewDescriptor causeDesc, String JavaDoc exMsg,
60               String JavaDoc exClass, String JavaDoc causeMsg, String JavaDoc causeClass,
61               String JavaDoc fullTrace, String JavaDoc regTrace) {
62     super((src == null) ? (Object JavaDoc)((desc == null) ? (Object JavaDoc)"" : (Object JavaDoc)desc) : (Object JavaDoc)src);
63     setView(src);
64     setViewDescriptor(desc);
65     setViewBean(vb);
66     setException(ex);
67     setCauseView(causeView);
68     setCauseViewDescriptor(causeDesc);
69     setExceptionMessage(exMsg);
70     setExceptionClassName(exClass);
71     setCauseMessage(causeMsg);
72     setCauseClassName(causeClass);
73     setFullTrace(fullTrace);
74     setRegularTrace(regTrace);
75     }
76
77
78     /**
79      *
80      */

81     protected void setView(View view) {
82     _view = view;
83     }
84
85
86     /**
87      * This method returns the View corresponding to the ViewDescriptor that
88      * is handling this error event. This is not necessarily the same View
89      * where the event occurred. Also, this View may be null if for some
90      * reason the View could not be instantiated (in this case, this would
91      * likely be the reason of the error).
92      *
93      * @return The View associated with the handling ViewDescriptor
94      */

95     public View getView() {
96     return _view;
97     }
98
99
100     /**
101      * This method sets the ViewDescriptor for the object that is about to be
102      * created.
103      *
104      * @param viewDesc The ViewDescriptor of the View to be created.
105      */

106     protected void setViewDescriptor(ViewDescriptor viewDesc) {
107     _viewDesc = viewDesc;
108     }
109
110
111     /**
112      * This method retrieves the ViewDescriptor of the View containing the
113      * error handler. This ViewDescriptor is not necessarily the
114      * ViewDescriptor where the error occurred. This can be null if no error
115      * handler was specified in the chain of ViewDescriptors (in this case the
116      * Servlet's default error handling will be using this ErrorEvent).
117      *
118      * @return The ViewDescriptor describing this ErrorEvent
119      */

120     public ViewDescriptor getViewDescriptor() {
121     return _viewDesc;
122     }
123
124
125     /**
126      *
127      */

128     protected void setViewBean(ViewBean vb) {
129     _viewBean = vb;
130     }
131
132
133     /**
134      * This method returns the ViewBean.
135      *
136      * @return The ViewBean
137      */

138     public ViewBean getViewBean() {
139     return _viewBean;
140     }
141
142
143     /**
144      *
145      */

146     protected void setException(Throwable JavaDoc ex) {
147     _exception = ex;
148     }
149
150
151     /**
152      * This returns the Exception / Error that was caught. This is not the
153      * root cause.
154      */

155     public Throwable JavaDoc getException() {
156     return _exception;
157     }
158
159
160     /**
161      *
162      */

163     protected void setCauseView(View causeView) {
164     _causeView = causeView;
165     }
166
167
168     /**
169      * This method returns the View that was indicated as being responsible
170      * for the error. The View may be null or a parent of the View that
171      * actually had the problem.
172      *
173      * @return The responsible View.
174      */

175     public View getCauseView() {
176     return _causeView;
177     }
178
179
180     /**
181      *
182      */

183     protected void setCauseViewDescriptor(ViewDescriptor causeDesc) {
184     _causeDesc = causeDesc;
185     }
186
187
188     /**
189      * This method returns the ViewDescriptor of the View that had a problem.
190      * This is not likely to be null, but it is possible. The ViewDescriptor
191      * returned may not correspond directly to the View that had the problem.
192      * If the View that had a problem does not have a corresponding
193      * ViewDescriptor, the closest ViewDescriptor to that View will be used.
194      *
195      * @return ViewDescriptor corresponding to View which caused the error
196      */

197     public ViewDescriptor getCauseViewDescriptor() {
198     return _causeDesc;
199     }
200
201
202     /**
203      *
204      */

205     protected void setExceptionMessage(String JavaDoc exMsg) {
206     _exceptionMessage = exMsg;
207     }
208
209
210     /**
211      * This method returns the Message associated with the Exception (not the
212      * root cause exception).
213      *
214      * @return ex.getMessage();
215      */

216     public String JavaDoc getExceptionMessage() {
217     return _exceptionMessage;
218     }
219
220
221     /**
222      *
223      */

224     protected void setExceptionClassName(String JavaDoc exClass) {
225     _exceptionClass = exClass;
226     }
227
228
229     /**
230      * This method returns the name of the Exception Class (e.g.
231      * "java.lang.RuntimeException")
232      *
233      * @return The Class name of the Exception / Error
234      */

235     public String JavaDoc getExceptionClassName() {
236     return _exceptionClass;
237     }
238
239
240     /**
241      *
242      */

243     protected void setCauseMessage(String JavaDoc causeMsg) {
244     _causeMessage = causeMsg;
245     }
246
247
248     /**
249      * This method returns the message of the root cause exception.
250      *
251      * @return The cause exception message.
252      */

253     public String JavaDoc getCauseMessage() {
254     return _causeMessage;
255     }
256
257
258     /**
259      *
260      */

261     protected void setCauseClassName(String JavaDoc causeClass) {
262     _causeClass = causeClass;
263     }
264
265
266     /**
267      * This method returns the Class Name of the root cause exception.
268      *
269      * @return The Class name of the root cause exception.
270      */

271     public String JavaDoc getCauseClassName() {
272     return _causeClass;
273     }
274
275
276     /**
277      *
278      */

279     protected void setFullTrace(String JavaDoc fullTrace) {
280     _fullTrace = fullTrace;
281     }
282
283
284     /**
285      * This method returns a full stack trace to the root cause. If the root
286      * cause is caught 1 or more times, this will not be shown in this stack
287      * trace. This stack trace only has the instructions that were invoked to
288      * reach the root cause.
289      *
290      * @return The full stack trace to the root cause.
291      */

292     public String JavaDoc getFullTrace() {
293     return _fullTrace;
294     }
295
296
297     /**
298      *
299      */

300     protected void setRegularTrace(String JavaDoc regTrace) {
301     _regularTrace = regTrace;
302     }
303
304
305     /**
306      * This method returns the traditional stack trace. This stack trace will
307      * show each catch clause that caught the root cause. It may also omit
308      * some of the details.
309      *
310      * @return Stack trace
311      */

312     public String JavaDoc getRegularTrace() {
313     return _regularTrace;
314     }
315
316
317     private View _view = null;
318     private ViewDescriptor _viewDesc = null;
319     private ViewBean _viewBean = null;
320     private Throwable JavaDoc _exception = null;
321     private View _causeView = null;
322     private ViewDescriptor _causeDesc = null;
323     private String JavaDoc _exceptionMessage = null;
324     private String JavaDoc _exceptionClass = null;
325     private String JavaDoc _causeMessage = null;
326     private String JavaDoc _causeClass = null;
327     private String JavaDoc _fullTrace = null;
328     private String JavaDoc _regularTrace = null;
329 }
330
Popular Tags