KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > config > ConfigurationException


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.config;
10
11 import java.io.PrintStream JavaDoc;
12 import java.io.PrintWriter JavaDoc;
13
14 /**
15  * @version $Revision: 1.3 $
16  */

17 public class ConfigurationException extends Exception JavaDoc
18 {
19    private Throwable JavaDoc cause;
20
21    public ConfigurationException()
22    {
23       this(null, null);
24    }
25
26    public ConfigurationException(String JavaDoc message)
27    {
28       this(message, null);
29    }
30
31    public ConfigurationException(Throwable JavaDoc cause)
32    {
33       this(null, cause);
34    }
35
36    public ConfigurationException(String JavaDoc message, Throwable JavaDoc cause)
37    {
38       super(message);
39       this.cause = cause;
40    }
41
42    public Throwable JavaDoc getCause()
43    {
44       return cause;
45    }
46
47    public void printStackTrace()
48    {
49       if (cause == null)
50       {
51          super.printStackTrace();
52       }
53       else
54       {
55          synchronized (System.err)
56          {
57             System.err.println(this);
58             cause.printStackTrace();
59          }
60       }
61    }
62
63    public void printStackTrace(PrintStream JavaDoc stream)
64    {
65       if (cause == null)
66       {
67          super.printStackTrace(stream);
68       }
69       else
70       {
71          synchronized (stream)
72          {
73             stream.println(this);
74             cause.printStackTrace(stream);
75          }
76       }
77    }
78
79    public void printStackTrace(PrintWriter JavaDoc writer)
80    {
81       if (cause == null)
82       {
83          super.printStackTrace(writer);
84       }
85       else
86       {
87          synchronized (writer)
88          {
89             writer.println(this);
90             cause.printStackTrace(writer);
91          }
92       }
93    }
94 }
95
Popular Tags