KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > YanException


1 /*****************************************************************************
2  * Copyright (C) Codehaus.org. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8 /*
9  * Created on Feb 28, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

14 package jfun.yan;
15
16 import java.io.PrintStream JavaDoc;
17 import java.io.PrintWriter JavaDoc;
18 import java.util.Stack JavaDoc;
19
20 /**
21  * The root exception representing any container or component related exception.
22  * <p>
23  * Codehaus.org.
24  *
25  * @author Ben Yu
26  *
27  */

28 public class YanException extends RuntimeException JavaDoc {
29   private final Stack JavaDoc trace = new Stack JavaDoc();
30   public YanException(String JavaDoc arg0) {
31     super(arg0);
32   }
33   public YanException(){}
34   
35   public YanException(String JavaDoc message, Throwable JavaDoc cause) {
36     super(message, cause);
37
38   }
39   public YanException(Throwable JavaDoc cause) {
40     super(cause);
41   }
42   /**
43    * Pushes a resolution frame to the exception.
44    * @param obj the frame.
45    */

46   public void push(Object JavaDoc obj){
47     trace.push(obj);
48   }
49   /**
50    * Get the resolution trace.
51    * @return the resolution trace.
52    */

53   public Stack JavaDoc getResolutionTrace(){
54     return trace;
55   }
56   
57   /**
58    * Print the resolution trace.
59    * @param out the output stream.
60    */

61   public void printResolutionTrace(PrintStream JavaDoc out){
62     printResolutionTrace(new java.io.PrintWriter JavaDoc(out, true));
63   }
64   /**
65    * Print the resultion trace.
66    * @param out the output writer.
67    */

68   public void printResolutionTrace(java.io.PrintWriter JavaDoc out){
69     final int size = trace.size();
70     for(int i=0; i<size; i++){
71       out.println(trace.get(i));
72     }
73   }
74   /**
75    * Prints the resolution trace to the standard error output.
76    */

77   public void printResolutionTrace(){
78     printResolutionTrace(System.err);
79   }
80   public void printStackTrace(PrintStream JavaDoc s) {
81     printResolutionTrace(s);
82     super.printStackTrace(s);
83   }
84   public void printStackTrace(PrintWriter JavaDoc s) {
85     printResolutionTrace(s);
86     super.printStackTrace(s);
87   }
88   /**
89    * Clear the resolution trace.
90    */

91   public void clearResolutionTrace(){
92     trace.clear();
93   }
94   
95 }
96
Popular Tags