KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.lang.reflect.Method JavaDoc;
7 import java.io.Serializable JavaDoc;
8
9 /**
10  * Contains a pair of the original method and the wrapper method if such a method exists.
11  *
12  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
13  */

14 public class MethodTuple implements Serializable JavaDoc {
15   private final Method JavaDoc m_wrapperMethod;
16
17   private final Method JavaDoc m_originalMethod;
18
19   private final Class JavaDoc m_declaringClass;
20
21   /**
22    * @param wrapperMethod
23    * @param originalMethod
24    */

25   public MethodTuple(Method JavaDoc wrapperMethod, Method JavaDoc originalMethod) {
26     if (originalMethod == null) {
27       originalMethod = wrapperMethod;
28     }
29     if (wrapperMethod.getDeclaringClass() != originalMethod.getDeclaringClass()) {
30       throw new RuntimeException JavaDoc(
31               wrapperMethod.getName()
32                       + " and "
33                       + originalMethod.getName()
34                       + " does not have the same declaring class"
35       );
36     }
37     m_declaringClass = wrapperMethod.getDeclaringClass();
38     m_wrapperMethod = wrapperMethod;
39     m_wrapperMethod.setAccessible(true);
40     m_originalMethod = originalMethod;
41     m_originalMethod.setAccessible(true);
42   }
43
44   public boolean isWrapped() {
45     return m_originalMethod != null;
46   }
47
48   public Class JavaDoc getDeclaringClass() {
49     return m_declaringClass;
50   }
51
52   public Method JavaDoc getWrapperMethod() {
53     return m_wrapperMethod;
54   }
55
56   public Method JavaDoc getOriginalMethod() {
57     return m_originalMethod;
58   }
59
60   public String JavaDoc getName() {
61     return m_wrapperMethod.getName();
62   }
63 }
Popular Tags