001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.aspectwerkz.joinpoint.impl;
005:
006: import com.tc.backport175.Annotation;
007: import com.tc.backport175.Annotations;
008:
009: import com.tc.aspectwerkz.joinpoint.ConstructorSignature;
010:
011: import java.lang.reflect.Constructor;
012:
013: /**
014: * Implementation for the constructor signature.
015: *
016: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
017: */
018: public class ConstructorSignatureImpl implements ConstructorSignature {
019: private final Class m_declaringType;
020:
021: private final Constructor m_constructor;
022:
023: /**
024: * @param declaringType
025: * @param constructor
026: */
027: public ConstructorSignatureImpl(final Class declaringType,
028: final Constructor constructor) {
029: m_declaringType = declaringType;
030: m_constructor = constructor;
031: }
032:
033: /**
034: * Returns the constructor.
035: *
036: * @return the constructor
037: */
038: public Constructor getConstructor() {
039: return m_constructor;
040: }
041:
042: /**
043: * Returns the declaring class.
044: *
045: * @return the declaring class
046: */
047: public Class getDeclaringType() {
048: return m_declaringType;
049: }
050:
051: /**
052: * Returns the modifiers for the signature. <p/>Could be used like this:
053: * <p/>
054: * <pre>
055: * boolean isPublic = java.lang.reflect.Modifier.isPublic(signature.getModifiers());
056: * </pre>
057: *
058: * @return the mofifiers
059: */
060: public int getModifiers() {
061: return m_constructor.getModifiers();
062: }
063:
064: /**
065: * Returns the name (f.e. name of method of field).
066: *
067: * @return
068: */
069: public String getName() {
070: //return m_constructorTuple.getName();
071: return m_constructor.getName();
072: }
073:
074: /**
075: * Returns the exception types declared by the code block.
076: *
077: * @return the exception types
078: */
079: public Class[] getExceptionTypes() {
080: return m_constructor.getExceptionTypes();
081: }
082:
083: /**
084: * Returns the parameter types.
085: *
086: * @return the parameter types
087: */
088: public Class[] getParameterTypes() {
089: return m_constructor.getParameterTypes();
090: }
091:
092: /**
093: * Return the given annotation if any.
094: *
095: * @param annotationClass the annotation class
096: * @return the annotation or null
097: */
098: public Annotation getAnnotation(final Class annotationClass) {
099: return Annotations
100: .getAnnotation(annotationClass, m_constructor);
101: }
102:
103: /**
104: * Return all the annotations.
105: *
106: * @return annotations
107: */
108: public Annotation[] getAnnotations() {
109: return Annotations.getAnnotations(m_constructor);
110: }
111:
112: /**
113: * Returns a string representation of the signature.
114: *
115: * @return a string representation
116: */
117: public String toString() {
118: return m_constructor.toString();
119: }
120: }
|