KickJava   Java API By Example, From Geeks To Geeks.

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


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.ConstructorSignature;
10
11 import java.lang.reflect.Constructor JavaDoc;
12
13 /**
14  * Implementation for the constructor signature.
15  *
16  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
17  */

18 public class ConstructorSignatureImpl implements ConstructorSignature {
19   private final Class JavaDoc m_declaringType;
20
21   private final Constructor JavaDoc m_constructor;
22
23   /**
24    * @param declaringType
25    * @param constructor
26    */

27   public ConstructorSignatureImpl(final Class JavaDoc declaringType, final Constructor JavaDoc constructor) {
28     m_declaringType = declaringType;
29     m_constructor = constructor;
30   }
31
32   /**
33    * Returns the constructor.
34    *
35    * @return the constructor
36    */

37   public Constructor JavaDoc getConstructor() {
38     return m_constructor;
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_constructor.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_constructorTuple.getName();
70
return m_constructor.getName();
71   }
72
73   /**
74    * Returns the exception types declared by the code block.
75    *
76    * @return the exception types
77    */

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

87   public Class JavaDoc[] getParameterTypes() {
88     return m_constructor.getParameterTypes();
89   }
90
91   /**
92    * Return the given annotation if any.
93    *
94    * @param annotationClass the annotation class
95    * @return the annotation or null
96    */

97   public Annotation getAnnotation(final Class JavaDoc annotationClass) {
98     return Annotations.getAnnotation(annotationClass, m_constructor);
99   }
100
101   /**
102    * Return all the annotations.
103    *
104    * @return annotations
105    */

106   public Annotation[] getAnnotations() {
107     return Annotations.getAnnotations(m_constructor);
108   }
109
110   /**
111    * Returns a string representation of the signature.
112    *
113    * @return a string representation
114    */

115   public String JavaDoc toString() {
116     return m_constructor.toString();
117   }
118 }
Popular Tags