001: /* ========================================================================
002: * JCommon : a free general purpose class library for the Java(tm) platform
003: * ========================================================================
004: *
005: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006: *
007: * Project Info: http://www.jfree.org/jcommon/index.html
008: *
009: * This library is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU Lesser General Public License as published by
011: * the Free Software Foundation; either version 2.1 of the License, or
012: * (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but
015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017: * License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022: * USA.
023: *
024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * ------------------------------
028: * ElementDefinitionException.java
029: * ------------------------------
030: * (C)opyright 2002-2004, by Object Refinery Limited.
031: *
032: * $Id: ElementDefinitionException.java,v 1.3 2005/10/18 13:25:44 mungady Exp $
033: *
034: * Changes
035: * -------
036: * 24-Apr-2002 : Initial version
037: * 31-Aug-2002 : Documentation; changed PrintStackTrace for better tracing
038: * 29-Apr-2003 : Distilled from the JFreeReport project and moved into JCommon
039: */
040: package org.jfree.xml;
041:
042: import java.io.PrintStream;
043: import java.io.PrintWriter;
044:
045: import org.xml.sax.Locator;
046:
047: /**
048: * A reportdefinition exception is thrown when the parsing of the report definition
049: * failed because invalid or missing attributes are encountered.
050: *
051: * @author Thomas Morgner
052: */
053: public class ElementDefinitionException extends ParseException {
054:
055: /** The parent exception. */
056: private Exception parent;
057:
058: /**
059: * Creates a new ElementDefinitionException without an parent exception and with the given
060: * message as explanation.
061: *
062: * @param message a detail message explaining the reasons for this exception.
063: */
064: public ElementDefinitionException(final String message) {
065: super (message);
066: }
067:
068: /**
069: * Creates a new ElementDefinitionException with an parent exception and with the parents
070: * message as explaination.
071: *
072: * @param e the parentException that caused this exception
073: */
074: public ElementDefinitionException(final Exception e) {
075: this (e, e.getMessage());
076: }
077:
078: /**
079: * Creates a new ElementDefinitionException with an parent exception and with the given
080: * message as explaination.
081: *
082: * @param e the parentException that caused this exception
083: * @param message a detail message explaining the reasons for this exception
084: */
085: public ElementDefinitionException(final Exception e,
086: final String message) {
087: this (message);
088: this .parent = e;
089: }
090:
091: /**
092: * Creates a new ParseException with the given root exception
093: * and the locator.
094: *
095: * @param e the exception
096: * @param locator the locator of the parser
097: */
098: public ElementDefinitionException(final Exception e,
099: final Locator locator) {
100: super (e, locator);
101: this .parent = e;
102: }
103:
104: /**
105: * Creates a new ParseException with the given message and the locator.
106: *
107: * @param message the message
108: * @param locator the locator of the parser
109: */
110: public ElementDefinitionException(final String message,
111: final Locator locator) {
112: super (message, locator);
113: }
114:
115: /**
116: * Creates a new ParseException with the given message, root exception
117: * and the locator.
118: *
119: * @param s the message
120: * @param e the exception
121: * @param locator the locator of the parser
122: */
123: public ElementDefinitionException(final String s,
124: final Exception e, final Locator locator) {
125: super (s, e, locator);
126: this .parent = e;
127: }
128:
129: /**
130: * Returns the parent exception.
131: *
132: * @return the parent exception.
133: */
134: public Exception getParentException() {
135: return this .parent;
136: }
137:
138: /**
139: * Prints the stack trace. If an inner exception exists, use
140: * its stack trace.
141: *
142: * @param s the stream for writing to.
143: */
144: public void printStackTrace(final PrintStream s) {
145: super .printStackTrace(s);
146: if (this .parent != null) {
147: s.print("ParentException:");
148: this .parent.printStackTrace(s);
149: } else {
150: s.println("ParentException: <null>");
151: }
152: }
153:
154: /**
155: * Prints the stack trace. If an inner exception exists, use
156: * its stack trace.
157: *
158: * @param s the stream for writing to.
159: */
160: public void printStackTrace(final PrintWriter s) {
161: super .printStackTrace(s);
162: if (this .parent != null) {
163: s.print("ParentException:");
164: this .parent.printStackTrace(s);
165: } else {
166: s.println("ParentException: <null>");
167: }
168: }
169:
170: }
|