01: /*
02: Mdarad-Toolobox is a collection of tools for Architected RAD
03: (Rapid Application Development) based on an MDA approach.
04: The toolbox contains frameworks and generators for many environments
05: (JAVA, J2EE, Hibernate, .NET, C++, etc.) which allow to generate
06: applications from a design Model
07: Copyright (C) 2004-2005 Elapse Technologies Inc.
08:
09: This library is free software; you can redistribute it and/or
10: modify it under the terms of the GNU General Public
11: License as published by the Free Software Foundation; either
12: version 2.1 of the License, or (at your option) any later version.
13:
14: This library is distributed in the hope that it will be useful,
15: but WITHOUT ANY WARRANTY; without even the implied warranty of
16: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: General Public License for more details.
18:
19: You should have received a copy of the GNU General Public
20: License along with this library; if not, write to the Free Software
21: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: */
23: package org.mdarad.framework.exception;
24:
25: import java.io.PrintStream;
26: import java.io.PrintWriter;
27: import java.util.Iterator;
28: import java.util.Vector;
29:
30: public class ChainedException extends SystemException {
31: Vector exceptions = new Vector();
32:
33: public ChainedException() {
34: super ();
35: }
36:
37: public ChainedException(String message) {
38: super (message);
39: }
40:
41: public ChainedException(Throwable cause) {
42: super (cause);
43: }
44:
45: public ChainedException(String message, Throwable cause) {
46: super (message, cause);
47: }
48:
49: public void chain(Throwable cause) {
50: chain(null, cause);
51: }
52:
53: public void chain(String message, Throwable cause) {
54: if (message == null)
55: exceptions.add(new SystemException(message, cause));
56: }
57:
58: public void printStackTrace() {
59: Iterator iterator = exceptions.iterator();
60:
61: while (iterator.hasNext()) {
62: Throwable throwable = (Throwable) iterator.next();
63: throwable.printStackTrace();
64: }
65: }
66:
67: public void printStackTrace(PrintWriter s) {
68: Iterator iterator = exceptions.iterator();
69:
70: while (iterator.hasNext()) {
71: Throwable throwable = (Throwable) iterator.next();
72: throwable.printStackTrace(s);
73: }
74: }
75:
76: public void printStackTrace(PrintStream s) {
77: Iterator iterator = exceptions.iterator();
78:
79: while (iterator.hasNext()) {
80: Throwable throwable = (Throwable) iterator.next();
81: throwable.printStackTrace(s);
82: }
83: }
84:
85: public Throwable getThrowable(int index) {
86: return (Throwable) exceptions.get(index);
87: }
88: }
|