KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > aspectwerkz > joinpoint > impl > CatchClauseRttiImpl


1 /**************************************************************************************
2  * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package org.codehaus.aspectwerkz.joinpoint.impl;
9
10 import org.codehaus.aspectwerkz.joinpoint.CatchClauseRtti;
11 import org.codehaus.aspectwerkz.joinpoint.Rtti;
12
13 import java.lang.ref.WeakReference JavaDoc;
14
15 /**
16  * Implementation for the catch clause RTTI.
17  *
18  * @author <a HREF="mailto:jboner@codehaus.org">Jonas Bonér </a>
19  */

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

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

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

60     public Object JavaDoc getThis() {
61         return m_thisRef.get();
62     }
63
64     /**
65      * Returns the target instance.
66      *
67      * @return the target instance
68      */

69     public Object JavaDoc getTarget() {
70         return m_targetRef.get();
71     }
72
73     /**
74      * Returns the declaring class.
75      *
76      * @return the declaring class
77      */

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

91     public int getModifiers() {
92         return m_signature.getModifiers();
93     }
94
95     /**
96      * Returns the name (f.e. name of method of field).
97      *
98      * @return
99      */

100     public String JavaDoc getName() {
101         return m_signature.getName();
102     }
103
104     /**
105      * Returns the parameter type.
106      *
107      * @return the parameter type
108      */

109     public Class JavaDoc getParameterType() {
110         return m_signature.getParameterType();
111     }
112
113     /**
114      * Returns the value of the parameter.
115      *
116      * @return the value of the parameter
117      */

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

128     public String JavaDoc toString() {
129         return super.toString();
130     }
131 }
Popular Tags