KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > generator > GeneratorException


1 /*
2   Loader - tool for transfering data from one JDBC source to another and
3   doing transformations during copy.
4     Copyright (C) 2002 Together
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12     Lesser General Public License for more details.
13     You should have received a copy of the GNU Lesser General Public
14     License along with this library; if not, write to the Free Software
15     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  LoaderException.java
17  Date: 22.09.2001.
18  @version 1.0
19  @author:
20  Milosevic Sinisa
21  */

22
23 package org.webdocwf.util.loader.generator;
24
25 import java.io.ByteArrayOutputStream JavaDoc;
26 import java.io.PrintStream JavaDoc;
27 import java.io.PrintWriter JavaDoc;
28
29 /**
30  *
31  * GeneratorException class is used for handling the exceptions in
32  * Enhydra Octopus application.
33  * @author Milosevic Sinisa
34  * @version 1.0
35  */

36 public class GeneratorException extends Exception JavaDoc {
37
38   private Throwable JavaDoc cause;
39
40   /**
41    * This is the public constructor with one parameter
42    * @param msg is constructor argument
43    */

44   public GeneratorException(String JavaDoc msg) {
45     super(msg);
46     cause = null;
47   }
48
49   /**
50    * This is the public constructor with two parameter
51    * @param msg is first constructor parameter
52    * @param cause is secund constructor parameter
53    */

54   public GeneratorException(String JavaDoc msg,
55                          Throwable JavaDoc cause) {
56     super(msg);
57     this.cause = cause;
58   }
59
60   /**
61    * This method read message from exception object
62    * @return message
63    */

64   public String JavaDoc getMessage() {
65     return super.getMessage();
66   }
67
68   /**
69    * Gets the exception associated with this exception.
70    * @return The exception or null if no cause is specified.
71    */

72   public Throwable JavaDoc getCause() {
73     return cause;
74   }
75
76   /**
77    * Prints this ChainedException and its backtrace, and the causes
78    * and their stack traces to the standard error stream.
79    */

80   public void printStackTrace() {
81     super.printStackTrace();
82     Throwable JavaDoc a = new Throwable JavaDoc();
83     a.printStackTrace();
84   }
85
86   /**
87    * Prints this LoaderException and its backtrace, and the causes
88    * and their stack traces to the e specified print stream.
89    * @param s represents PrintWriter stream
90    */

91   public void printStackTrace(PrintStream JavaDoc s) {
92     super.printStackTrace(s);
93     Throwable JavaDoc a = new Throwable JavaDoc();
94     a.printStackTrace(s);
95   }
96
97   /**
98    * Prints this LoaderException and its backtrace, and the causes
99    * and their stack traces to the specified print writer.
100    * @param s represents PrintWriter stream
101    */

102   public void printStackTrace(PrintWriter JavaDoc s) {
103     super.printStackTrace(s);
104     Throwable JavaDoc a = new Throwable JavaDoc();
105     a.printStackTrace(s);
106   }
107   
108   /**
109    * Construct string with stack trace.
110    * @return String representation of stack trace.
111    */

112   public String JavaDoc getStackTraceAsString() {
113     ByteArrayOutputStream JavaDoc out = new ByteArrayOutputStream JavaDoc();
114    this.printStackTrace(new PrintStream JavaDoc(out));
115     return out.toString();
116   }
117 }
118
Popular Tags