KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > joinpoint > impl > CatchClauseRttiImpl


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.joinpoint.impl;
5
6 import com.tc.aspectwerkz.joinpoint.CatchClauseRtti;
7 import com.tc.aspectwerkz.joinpoint.Rtti;
8
9 import java.lang.ref.WeakReference JavaDoc;
10
11 /**
12  * Implementation for the catch clause RTTI.
13  *
14  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
15  */

16 public class CatchClauseRttiImpl implements CatchClauseRtti {
17   private final CatchClauseSignatureImpl m_signature;
18
19   private WeakReference JavaDoc m_thisRef;
20
21   private WeakReference JavaDoc m_targetRef;
22
23   private Object JavaDoc m_parameterValue;
24
25   /**
26    * Creates a new catch clause RTTI.
27    *
28    * @param signature
29    * @param thisInstance
30    * @param targetInstance
31    */

32   public CatchClauseRttiImpl(final CatchClauseSignatureImpl signature,
33                              final Object JavaDoc thisInstance,
34                              final Object JavaDoc targetInstance) {
35     m_signature = signature;
36     m_thisRef = new WeakReference JavaDoc(thisInstance);
37     m_targetRef = new WeakReference JavaDoc(targetInstance);
38   }
39
40   /**
41    * Clones the RTTI instance.
42    *
43    * @param thisInstance
44    * @param targetInstance
45    * @return
46    */

47   public Rtti cloneFor(final Object JavaDoc thisInstance, final Object JavaDoc targetInstance) {
48     return new CatchClauseRttiImpl(m_signature, thisInstance, targetInstance);
49   }
50
51   /**
52    * Returns the instance currently executing.
53    *
54    * @return the instance currently executing
55    */

56   public Object JavaDoc getThis() {
57     return m_thisRef.get();
58   }
59
60   /**
61    * Returns the target instance.
62    *
63    * @return the target instance
64    */

65   public Object JavaDoc getTarget() {
66     return m_targetRef.get();
67   }
68
69   /**
70    * Returns the declaring class.
71    *
72    * @return the declaring class
73    */

74   public Class JavaDoc getDeclaringType() {
75     return m_signature.getDeclaringType();
76   }
77
78   /**
79    * Returns the modifiers for the signature. <p/>Could be used like this:
80    * <p/>
81    * <pre>
82    * boolean isPublic = java.lang.reflect.Modifier.isPublic(signature.getModifiers());
83    * </pre>
84    *
85    * @return the mofifiers
86    */

87   public int getModifiers() {
88     return m_signature.getModifiers();
89   }
90
91   /**
92    * Returns the name (f.e. name of method of field).
93    *
94    * @return
95    */

96   public String JavaDoc getName() {
97     return m_signature.getName();
98   }
99
100   /**
101    * Returns the parameter type.
102    *
103    * @return the parameter type
104    */

105   public Class JavaDoc getParameterType() {
106     return m_signature.getParameterType();
107   }
108
109   /**
110    * Returns the value of the parameter.
111    *
112    * @return the value of the parameter
113    */

114   public Object JavaDoc getParameterValue() {
115     return getTarget();//m_parameterValue;
116
}
117
118   /**
119    * Returns a string representation of the signature.
120    *
121    * @return a string representation
122    * @TODO: implement toString to something meaningful
123    */

124   public String JavaDoc toString() {
125     return super.toString();
126   }
127 }
Popular Tags