001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * ReportEventException.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report;
030:
031: import java.io.PrintStream;
032: import java.io.PrintWriter;
033: import java.util.List;
034:
035: /**
036: * The ReportEventException is thrown, if there were unrecoverable exceptions during the
037: * report processing.
038: *
039: * @author Thomas Morgner
040: */
041: public class ReportEventException extends ReportProcessingException {
042: /**
043: * the collected child exceptions.
044: */
045: private List childExceptions;
046:
047: /**
048: * Creates an ReportEventException to handle exceptions, that occured during the event
049: * dispatching.
050: *
051: * @param message the exception message.
052: * @param childExceptions the collected exceptions.
053: */
054: public ReportEventException(final String message,
055: final List childExceptions) {
056: super (message);
057: if (childExceptions == null) {
058: throw new NullPointerException();
059: }
060: this .childExceptions = childExceptions;
061: }
062:
063: /**
064: * Gets the collected child exceptions, that occured during the event dispatching.
065: *
066: * @return the collected child exceptions.
067: */
068: public List getChildExceptions() {
069: return childExceptions;
070: }
071:
072: /**
073: * Returns the errort message string of this throwable object.
074: *
075: * @return the error message string of this <code>Throwable</code> object if it was
076: * created with an error message string; or <code>null</code> if it was created
077: * with no error message.
078: */
079: public String getMessage() {
080: return super .getMessage() + ": " + childExceptions.size()
081: + " exceptions occured.";
082: }
083:
084: /**
085: * Prints the stack trace to the specified writer.
086: *
087: * @param writer the writer.
088: */
089: public void printStackTrace(final PrintWriter writer) {
090: super .printStackTrace(writer);
091: for (int i = 0; i < childExceptions.size(); i++) {
092: writer.print("Exception #");
093: writer.println(i);
094: final Exception ex = (Exception) childExceptions.get(i);
095: if (ex != null) {
096: ex.printStackTrace(writer);
097: } else {
098: writer.println("<not defined>");
099: }
100: }
101: }
102:
103: /**
104: * Prints the stack trace to the specified stream.
105: *
106: * @param stream the output stream.
107: */
108: public void printStackTrace(final PrintStream stream) {
109: super .printStackTrace(stream);
110: for (int i = 0; i < childExceptions.size(); i++) {
111: stream.print("Exception #");
112: stream.println(i);
113: final Exception ex = (Exception) childExceptions.get(i);
114: if (ex != null) {
115: ex.printStackTrace(stream);
116: } else {
117: stream.println("<not defined>");
118: }
119: }
120: }
121: }
|