KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > aspect > management > NoAspectBoundException


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.aspectwerkz.aspect.management;
5
6 import java.io.PrintStream JavaDoc;
7 import java.io.PrintWriter JavaDoc;
8
9 /**
10  * @author <a HREF="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
11  */

12 public class NoAspectBoundException extends RuntimeException JavaDoc {
13
14   private String JavaDoc m_message;
15   private Throwable JavaDoc m_throwable;
16
17   public NoAspectBoundException(String JavaDoc message, String JavaDoc aspectName) {
18     m_message = message + " - " + aspectName;
19   }
20
21   public NoAspectBoundException(Throwable JavaDoc t, String JavaDoc aspectName) {
22     m_throwable = t;
23     m_message = t.getMessage();
24   }
25
26   public String JavaDoc getMessage() {
27     StringBuffer JavaDoc sb = new StringBuffer JavaDoc("NoAspectBound: ");
28     sb.append(m_message);
29     return sb.toString();
30   }
31
32   /**
33    * Returns the original exception.
34    *
35    * @return the cause
36    */

37   public Throwable JavaDoc getCause() {
38     if (m_throwable != null) {
39       return m_throwable;
40     } else {
41       return super.getCause();
42     }
43   }
44
45   /**
46    * Prints the wrapped exception A its backtrace to the standard error stream.
47    */

48   public void printStackTrace() {
49     if (m_throwable != null) {
50       m_throwable.printStackTrace();
51     } else {
52       super.printStackTrace();
53     }
54   }
55
56   /**
57    * Prints the wrapped excpetion A its backtrace to the specified print stream.
58    *
59    * @param s the print stream
60    */

61   public void printStackTrace(final PrintStream JavaDoc s) {
62     if (m_throwable != null) {
63       m_throwable.printStackTrace(s);
64     } else {
65       super.printStackTrace(s);
66     }
67   }
68
69   /**
70    * Prints the wrapped exception A its backtrace to the specified print writer.
71    *
72    * @param s the print writer
73    */

74   public void printStackTrace(final PrintWriter JavaDoc s) {
75     if (m_throwable != null) {
76       m_throwable.printStackTrace(s);
77     } else {
78       super.printStackTrace(s);
79     }
80   }
81
82 }
83
Popular Tags