KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_lib > deployment > api > DeploymentDescException


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer(s): ____________________________________.
22  * Contributor(s): Lutris Technologies Inc http://www.lutris.com
23  *
24  * --------------------------------------------------------------------------
25  * $Id: DeploymentDescException.java,v 1.2 2004/05/11 08:07:50 sauthieg Exp $
26  * --------------------------------------------------------------------------
27 */

28
29
30 package org.objectweb.jonas_lib.deployment.api;
31
32 import java.io.PrintStream JavaDoc;
33 import java.io.PrintWriter JavaDoc;
34
35 /**
36  * The DeploymentDesc exception uses the pattern defined by the Enhydra
37  * com.lutris.util.ChainedException
38  * The source has been temporary duplicated to prevent Jonas using
39  * from external dependencies.
40  * @author Christophe Ney
41  */

42 public class DeploymentDescException extends Exception JavaDoc {
43
44     /**
45      * Cause of the exception
46      */

47     private Throwable JavaDoc cause;
48
49    /**
50      * Construct an exception without anything
51      */

52     public DeploymentDescException() {
53         super();
54         cause = null;
55     }
56
57
58     /**
59      * Construct an exception without a specified cause.
60      *
61      * @param msg The message associated with the exception.
62      */

63     public DeploymentDescException(String JavaDoc msg) {
64         super(msg);
65         cause = null;
66     }
67
68     /**
69      * Construct an exception with an associated causing exception.
70      *
71      * @param msg The message associated with the exception.
72      * @param cause The error or exception that cause this
73      * exception.
74      */

75     public DeploymentDescException(String JavaDoc msg,
76                             Throwable JavaDoc cause) {
77         super(msg);
78         this.cause = cause;
79     }
80
81     /**
82      * Construct an exception from a causing exception.
83      *
84      * @param cause The error or exception that cause this
85      * exception. The message will be take be this object's
86      * messasge.
87      */

88     public DeploymentDescException(Throwable JavaDoc cause) {
89         super(cause.getMessage());
90         this.cause = cause;
91     }
92
93     /**
94      * @return the message associated with this exception. If causes
95      * are included, they will be appended to the message.
96      */

97     public String JavaDoc getMessage() {
98         String JavaDoc msg = super.getMessage();
99         if (cause == null) {
100             return msg;
101         } else {
102             return msg + ": " + cause.getMessage();
103         }
104     }
105
106     /**
107      * Gets the causing exception associated with this exception.
108      * @return The causing exception or null if no cause is specified.
109      */

110     public Throwable JavaDoc getCause() {
111         return cause;
112     }
113
114     /**
115      * Prints this DeploymentDescException and its backtrace, and the causes
116      * and their stack traces to the standard error stream.
117      */

118     public void printStackTrace() {
119         super.printStackTrace();
120         if (cause != null) {
121             System.err.println();
122             System.err.println("*** Caused by:");
123             cause.printStackTrace();
124         }
125     }
126
127     /**
128      * Prints this DeploymentDescException and its backtrace, and the causes
129      * and their stack traces to the e specified print stream.
130      * @param s print the trace on a specific print stream
131      */

132     public void printStackTrace(PrintStream JavaDoc s) {
133         super.printStackTrace(s);
134         if (cause != null) {
135             s.println();
136             s.println ("*** Caused by:");
137             cause.printStackTrace(s);
138         }
139     }
140
141     /**
142      * Prints this DeploymentDescException and its backtrace, and the causes
143      * and their stack traces to the e specified print writer.
144      * @param s print the trace on a specific print stream
145      */

146     public void printStackTrace(PrintWriter JavaDoc s) {
147         super.printStackTrace(s);
148         if (cause != null) {
149             s.println();
150             s.println("*** Caused by:");
151             cause.printStackTrace(s);
152         }
153     }
154 }
155
Popular Tags