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.ConstructorTuple;
11 import org.codehaus.aspectwerkz.annotation.Annotation;
12 import org.codehaus.aspectwerkz.annotation.Annotations;
13 import org.codehaus.aspectwerkz.joinpoint.ConstructorSignature;
14
15 import java.lang.reflect.Constructor;
16 import java.util.List;
17
18 /***
19 * Implementation for the constructor signature used in the inlining model
20 *
21 * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
22 */
23 public class ConstructorSignatureImplInlined implements ConstructorSignature {
24
25 private final Class m_declaringType;
26
27 private final Constructor m_constructor;
28
29 /***
30 * @param declaringType
31 * @param constructor
32 */
33 public ConstructorSignatureImplInlined(final Class declaringType, final Constructor constructor) {
34 m_declaringType = declaringType;
35 m_constructor = constructor;
36 }
37
38 /***
39 * Returns the constructor.
40 *
41 * @return the constructor
42 */
43 public Constructor getConstructor() {
44 return m_constructor;
45 }
46
47 /***
48 * Returns the declaring class.
49 *
50 * @return the declaring class
51 */
52 public Class getDeclaringType() {
53 return m_declaringType;
54 }
55
56 /***
57 * Returns the modifiers for the signature. <p/>Could be used like this:
58 *
59 * <pre>
60 * boolean isPublic = java.lang.reflect.Modifier.isPublic(signature.getModifiers());
61 * </pre>
62 *
63 * @return the mofifiers
64 */
65 public int getModifiers() {
66 return m_constructor.getModifiers();
67 }
68
69 /***
70 * Returns the name (f.e. name of method of field).
71 *
72 * @return
73 */
74 public String getName() {
75
76 return m_constructor.getName();
77 }
78
79 /***
80 * Returns the exception types declared by the code block.
81 *
82 * @return the exception types
83 */
84 public Class[] getExceptionTypes() {
85 return m_constructor.getExceptionTypes();
86 }
87
88 /***
89 * Returns the parameter types.
90 *
91 * @return the parameter types
92 */
93 public Class[] getParameterTypes() {
94 return m_constructor.getParameterTypes();
95 }
96
97 /***
98 * Return the annotation with a specific name.
99 *
100 * @param annotationName the annotation name
101 * @return the annotation or null
102 */
103 public Annotation getAnnotation(final String annotationName) {
104 return Annotations.getAnnotation(annotationName, m_constructor);
105 }
106
107 /***
108 * Return a list with the annotations with a specific name.
109 *
110 * @param annotationName the annotation name
111 * @return the annotations in a list (can be empty)
112 */
113 public List getAnnotations(final String annotationName) {
114 return Annotations.getAnnotations(annotationName, m_constructor);
115 }
116
117 /***
118 * Return all the annotations <p/>Each annotation is wrapped in
119 * {@link org.codehaus.aspectwerkz.annotation.AnnotationInfo}instance.
120 *
121 * @return a list with the annotations
122 */
123 public List getAnnotationInfos() {
124 return Annotations.getAnnotationInfos(m_constructor);
125 }
126
127 /***
128 * Returns a string representation of the signature.
129 *
130 * @return a string representation
131 * @TODO: implement toString to something meaningful
132 */
133 public String toString() {
134 return m_constructor.toString();
135 }
136 }