001: /**************************************************************************************
002: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
003: * http://aspectwerkz.codehaus.org *
004: * ---------------------------------------------------------------------------------- *
005: * The software in this package is published under the terms of the LGPL license *
006: * a copy of which has been included with this distribution in the license.txt file. *
007: **************************************************************************************/package org.codehaus.aspectwerkz.joinpoint.impl;
008:
009: import org.codehaus.aspectwerkz.annotation.Annotation;
010: import org.codehaus.aspectwerkz.annotation.Annotations;
011: import org.codehaus.aspectwerkz.joinpoint.ConstructorSignature;
012:
013: import java.lang.reflect.Constructor;
014: import java.util.List;
015:
016: /**
017: * Implementation for the constructor signature.
018: *
019: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
020: */
021: public class ConstructorSignatureImpl implements ConstructorSignature {
022: private final Class m_declaringType;
023:
024: private final Constructor m_constructor;
025:
026: /**
027: * @param declaringType
028: * @param constructor
029: */
030: public ConstructorSignatureImpl(final Class declaringType,
031: final Constructor constructor) {
032: m_declaringType = declaringType;
033: m_constructor = constructor;
034: }
035:
036: /**
037: * Returns the constructor.
038: *
039: * @return the constructor
040: */
041: public Constructor getConstructor() {
042: return m_constructor;
043: }
044:
045: /**
046: * Returns the declaring class.
047: *
048: * @return the declaring class
049: */
050: public Class getDeclaringType() {
051: return m_declaringType;
052: }
053:
054: /**
055: * Returns the modifiers for the signature. <p/>Could be used like this:
056: * <p/>
057: * <pre>
058: * boolean isPublic = java.lang.reflect.Modifier.isPublic(signature.getModifiers());
059: * </pre>
060: *
061: * @return the mofifiers
062: */
063: public int getModifiers() {
064: return m_constructor.getModifiers();
065: }
066:
067: /**
068: * Returns the name (f.e. name of method of field).
069: *
070: * @return
071: */
072: public String getName() {
073: //return m_constructorTuple.getName();
074: return m_constructor.getName();
075: }
076:
077: /**
078: * Returns the exception types declared by the code block.
079: *
080: * @return the exception types
081: */
082: public Class[] getExceptionTypes() {
083: return m_constructor.getExceptionTypes();
084: }
085:
086: /**
087: * Returns the parameter types.
088: *
089: * @return the parameter types
090: */
091: public Class[] getParameterTypes() {
092: return m_constructor.getParameterTypes();
093: }
094:
095: /**
096: * Return the annotation with a specific name.
097: *
098: * @param annotationName the annotation name
099: * @return the annotation or null
100: */
101: public Annotation getAnnotation(final String annotationName) {
102: return Annotations.getAnnotation(annotationName, m_constructor);
103: }
104:
105: /**
106: * Return a list with the annotations with a specific name.
107: *
108: * @param annotationName the annotation name
109: * @return the annotations in a list (can be empty)
110: */
111: public List getAnnotations(final String annotationName) {
112: return Annotations
113: .getAnnotations(annotationName, m_constructor);
114: }
115:
116: /**
117: * Return all the annotations <p/>Each annotation is wrapped in
118: * {@link org.codehaus.aspectwerkz.annotation.AnnotationInfo}instance.
119: *
120: * @return a list with the annotations
121: */
122: public List getAnnotationInfos() {
123: return Annotations.getAnnotationInfos(m_constructor);
124: }
125:
126: /**
127: * Returns a string representation of the signature.
128: *
129: * @return a string representation
130: */
131: public String toString() {
132: return m_constructor.toString();
133: }
134: }
|