KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > schema2beans > Schema2BeansNestedException


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * Schema2BeansNestedException
22  */

23
24 package org.netbeans.modules.schema2beans;
25
26 import java.util.*;
27 import java.io.*;
28
29 public class Schema2BeansNestedException extends Schema2BeansException implements Serializable {
30     protected Throwable JavaDoc childThrowable;
31     protected String JavaDoc message;
32     protected String JavaDoc stackTrace;
33
34     public Schema2BeansNestedException(Throwable JavaDoc e) {
35         super("");
36         if (DDLogFlags.debug) {
37             System.out.println("Created Schema2BeansNestedException1: e="+e);
38             e.printStackTrace();
39         }
40         childThrowable = e;
41         message = childThrowable.getMessage();
42         genStackTrace();
43     }
44     
45     public Schema2BeansNestedException(String JavaDoc mesg, Throwable JavaDoc e) {
46         super(mesg);
47         if (DDLogFlags.debug) {
48             System.out.println("Created Schema2BeansNestedException2: e="+e+" mesg="+mesg);
49             e.printStackTrace();
50         }
51         childThrowable = e;
52         message = mesg+"\n"+childThrowable.getMessage();
53         genStackTrace();
54     }
55
56     public Throwable JavaDoc getCause() {
57         return childThrowable;
58     }
59     
60     public String JavaDoc getMessage() {
61         return message;
62     }
63
64     protected void genStackTrace() {
65         StringWriter strWriter = new StringWriter();
66         PrintWriter s = new PrintWriter(strWriter);
67         if (childThrowable == null) {
68             super.printStackTrace(s);
69         } else {
70             s.println(super.getMessage());
71             childThrowable.printStackTrace(s);
72         }
73         stackTrace = strWriter.toString();
74    }
75
76     public void printStackTrace(PrintStream s) {
77         s.println(stackTrace);
78     }
79
80     public void printStackTrace(PrintWriter s) {
81         s.println(stackTrace);
82     }
83
84     public void printStackTrace() {
85         System.err.println(stackTrace);
86     }
87 }
88
Popular Tags