KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > xml > ElementDefinitionException


1 /* ========================================================================
2  * JCommon : a free general purpose class library for the Java(tm) platform
3  * ========================================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jcommon/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * ------------------------------
28  * ElementDefinitionException.java
29  * ------------------------------
30  * (C)opyright 2002-2004, by Object Refinery Limited.
31  *
32  * $Id: ElementDefinitionException.java,v 1.3 2005/10/18 13:25:44 mungady Exp $
33  *
34  * Changes
35  * -------
36  * 24-Apr-2002 : Initial version
37  * 31-Aug-2002 : Documentation; changed PrintStackTrace for better tracing
38  * 29-Apr-2003 : Distilled from the JFreeReport project and moved into JCommon
39  */

40 package org.jfree.xml;
41
42 import java.io.PrintStream JavaDoc;
43 import java.io.PrintWriter JavaDoc;
44
45 import org.xml.sax.Locator JavaDoc;
46
47 /**
48  * A reportdefinition exception is thrown when the parsing of the report definition
49  * failed because invalid or missing attributes are encountered.
50  *
51  * @author Thomas Morgner
52  */

53 public class ElementDefinitionException extends ParseException {
54
55     /** The parent exception. */
56     private Exception JavaDoc parent;
57
58     /**
59      * Creates a new ElementDefinitionException without an parent exception and with the given
60      * message as explanation.
61      *
62      * @param message a detail message explaining the reasons for this exception.
63      */

64     public ElementDefinitionException(final String JavaDoc message) {
65         super(message);
66     }
67
68     /**
69      * Creates a new ElementDefinitionException with an parent exception and with the parents
70      * message as explaination.
71      *
72      * @param e the parentException that caused this exception
73      */

74     public ElementDefinitionException(final Exception JavaDoc e) {
75         this(e, e.getMessage());
76     }
77
78     /**
79      * Creates a new ElementDefinitionException with an parent exception and with the given
80      * message as explaination.
81      *
82      * @param e the parentException that caused this exception
83      * @param message a detail message explaining the reasons for this exception
84      */

85     public ElementDefinitionException(final Exception JavaDoc e, final String JavaDoc message) {
86         this(message);
87         this.parent = e;
88     }
89
90     /**
91      * Creates a new ParseException with the given root exception
92      * and the locator.
93      *
94      * @param e the exception
95      * @param locator the locator of the parser
96      */

97     public ElementDefinitionException(final Exception JavaDoc e, final Locator JavaDoc locator) {
98         super(e, locator);
99         this.parent = e;
100     }
101
102     /**
103      * Creates a new ParseException with the given message and the locator.
104      *
105      * @param message the message
106      * @param locator the locator of the parser
107      */

108     public ElementDefinitionException(final String JavaDoc message, final Locator JavaDoc locator) {
109         super(message, locator);
110     }
111
112     /**
113      * Creates a new ParseException with the given message, root exception
114      * and the locator.
115      *
116      * @param s the message
117      * @param e the exception
118      * @param locator the locator of the parser
119      */

120     public ElementDefinitionException(final String JavaDoc s, final Exception JavaDoc e, final Locator JavaDoc locator) {
121         super(s, e, locator);
122         this.parent = e;
123     }
124
125     /**
126      * Returns the parent exception.
127      *
128      * @return the parent exception.
129      */

130     public Exception JavaDoc getParentException() {
131         return this.parent;
132     }
133
134     /**
135      * Prints the stack trace. If an inner exception exists, use
136      * its stack trace.
137      *
138      * @param s the stream for writing to.
139      */

140     public void printStackTrace(final PrintStream JavaDoc s) {
141         super.printStackTrace(s);
142         if (this.parent != null) {
143             s.print("ParentException:");
144             this.parent.printStackTrace(s);
145         }
146         else {
147             s.println("ParentException: <null>");
148         }
149     }
150
151     /**
152      * Prints the stack trace. If an inner exception exists, use
153      * its stack trace.
154      *
155      * @param s the stream for writing to.
156      */

157     public void printStackTrace(final PrintWriter JavaDoc s) {
158         super.printStackTrace(s);
159         if (this.parent != null) {
160             s.print("ParentException:");
161             this.parent.printStackTrace(s);
162         }
163         else {
164             s.println("ParentException: <null>");
165         }
166     }
167
168 }
169
Popular Tags