KickJava   Java API By Example, From Geeks To Geeks.

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


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.backport175.Annotation;
7 import com.tc.backport175.Annotations;
8
9 import com.tc.aspectwerkz.joinpoint.MethodSignature;
10
11 import java.lang.reflect.Method JavaDoc;
12
13 /**
14  * Implementation for the method signature.
15  *
16  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
17  */

18 public class MethodSignatureImpl implements MethodSignature {
19   private final Class JavaDoc m_declaringType;
20
21   private final Method JavaDoc m_method;
22
23   /**
24    * @param declaringType
25    * @param method
26    */

27   public MethodSignatureImpl(final Class JavaDoc declaringType, final Method JavaDoc method) {
28     m_declaringType = declaringType;
29     m_method = method;
30   }
31
32   /**
33    * Returns the method.
34    *
35    * @return the method
36    */

37   public Method JavaDoc getMethod() {
38     return m_method;
39   }
40
41   /**
42    * Returns the declaring class.
43    *
44    * @return the declaring class
45    */

46   public Class JavaDoc getDeclaringType() {
47     return m_declaringType;
48   }
49
50   /**
51    * Returns the modifiers for the signature. <p/>Could be used like this:
52    * <p/>
53    * <pre>
54    * boolean isPublic = java.lang.reflect.Modifier.isPublic(signature.getModifiers());
55    * </pre>
56    *
57    * @return the mofifiers
58    */

59   public int getModifiers() {
60     return m_method.getModifiers();
61   }
62
63   /**
64    * Returns the name (f.e. name of method of field).
65    *
66    * @return
67    */

68   public String JavaDoc getName() {
69     return m_method.getName();
70   }
71
72   /**
73    * Returns the exception types declared by the code block.
74    *
75    * @return the exception types
76    */

77   public Class JavaDoc[] getExceptionTypes() {
78     return m_method.getExceptionTypes();
79   }
80
81   /**
82    * Returns the parameter types.
83    *
84    * @return the parameter types
85    */

86   public Class JavaDoc[] getParameterTypes() {
87     return m_method.getParameterTypes();
88   }
89
90   /**
91    * Returns the return type.
92    *
93    * @return the return type
94    */

95   public Class JavaDoc getReturnType() {
96     return m_method.getReturnType();
97   }
98
99   /**
100    * Return the annotation with a specific class.
101    *
102    * @param annotationClass the annotation class
103    * @return the annotation or null
104    */

105   public Annotation getAnnotation(final Class JavaDoc annotationClass) {
106     return Annotations.getAnnotation(annotationClass, m_method);
107   }
108
109   /**
110    * Return all the annotations.
111    *
112    * @return annotations
113    */

114   public Annotation[] getAnnotations() {
115     return Annotations.getAnnotations(m_method);
116   }
117
118   /**
119    * Returns a string representation of the signature.
120    *
121    * @return a string representation
122    */

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