001 /*
002 * $Id: ConstructorSignatureImpl.java,v 1.4 2011/07/09 21:43:22 oboehm Exp $
003 *
004 * Copyright (c) 2009 by Oliver Boehm
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 *
018 * (c)reated 04.04.2009 by oliver (ob@aosd.de)
019 */
020 package patterntesting.runtime.util.reflect;
021
022 import java.lang.reflect.Constructor;
023
024 import org.aspectj.lang.reflect.ConstructorSignature;
025 import org.slf4j.*;
026
027 import patterntesting.runtime.annotation.UnsupportedOperation;
028 import patterntesting.runtime.util.Converter;
029
030 /**
031 * The Class ConstructorSignatureImpl.
032 *
033 * @author <a href="boehm@javatux.de">oliver</a>
034 * @since 04.04.2009
035 * @version $Revision: 1.4 $
036 */
037 public class ConstructorSignatureImpl implements ConstructorSignature {
038
039 private static final Logger log = LoggerFactory.getLogger(ConstructorSignatureImpl.class);
040 private final Constructor<?> ctor;
041
042 /**
043 * Instantiates a new constructor signature impl.
044 *
045 * @param ctor the ctor
046 */
047 public ConstructorSignatureImpl(final Constructor<?> ctor) {
048 this.ctor = ctor;
049 }
050
051 /**
052 * @see org.aspectj.lang.reflect.ConstructorSignature#getConstructor()
053 */
054 public Constructor<?> getConstructor() {
055 return this.ctor;
056 }
057
058 /**
059 * Gets the exception types.
060 *
061 * @return the exception types
062 *
063 * @see org.aspectj.lang.reflect.CodeSignature#getExceptionTypes()
064 */
065 public Class<?>[] getExceptionTypes() {
066 return this.ctor.getExceptionTypes();
067 }
068
069 /**
070 * Gets the parameter names.
071 *
072 * @return the parameter names
073 *
074 * @see org.aspectj.lang.reflect.CodeSignature#getParameterNames()
075 */
076 @UnsupportedOperation
077 public String[] getParameterNames() {
078 log.debug("this operation is not implemented");
079 return null;
080 }
081
082 /**
083 * Gets the parameter types.
084 *
085 * @return the parameter types
086 *
087 * @see org.aspectj.lang.reflect.CodeSignature#getParameterTypes()
088 */
089 public Class<?>[] getParameterTypes() {
090 return this.ctor.getParameterTypes();
091 }
092
093 /**
094 * Gets the declaring type.
095 *
096 * @return the declaring type
097 *
098 * @see org.aspectj.lang.Signature#getDeclaringType()
099 */
100 public Class<?> getDeclaringType() {
101 return this.ctor.getDeclaringClass();
102 }
103
104 /**
105 * Gets the declaring type name.
106 *
107 * @return the declaring type name
108 *
109 * @see org.aspectj.lang.Signature#getDeclaringTypeName()
110 */
111 public String getDeclaringTypeName() {
112 return this.getDeclaringType().getName();
113 }
114
115 /**
116 * Gets the modifiers.
117 *
118 * @return the modifiers
119 *
120 * @see org.aspectj.lang.Signature#getModifiers()
121 */
122 public int getModifiers() {
123 return this.ctor.getModifiers();
124 }
125
126 /**
127 * Gets the name.
128 *
129 * @return the name
130 *
131 * @see org.aspectj.lang.Signature#getName()
132 */
133 public String getName() {
134 return "<init>";
135 }
136
137 /**
138 * To long string.
139 *
140 * @return the string
141 *
142 * @see org.aspectj.lang.Signature#toLongString()
143 */
144 public String toLongString() {
145 return this.ctor.toGenericString();
146 }
147
148 /**
149 * To short string.
150 *
151 * @return the string
152 *
153 * @see org.aspectj.lang.Signature#toShortString()
154 */
155 public String toShortString() {
156 return this.ctor.toString();
157 }
158
159 /**
160 * To string.
161 *
162 * @return the string
163 *
164 * @see java.lang.Object#toString()
165 */
166 @Override
167 public String toString() {
168 return this.getDeclaringTypeName() + "("
169 + Converter.toShortString(this.getParameterTypes()) + ")";
170 }
171
172 }
173
174 /**
175 * $Log: ConstructorSignatureImpl.java,v $
176 * Revision 1.4 2011/07/09 21:43:22 oboehm
177 * switched from commons-logging to SLF4J
178 *
179 * Revision 1.3 2010/04/22 18:32:01 oboehm
180 * compiler warnings fixed
181 *
182 * Revision 1.2 2010/04/22 18:27:19 oboehm
183 * code cleanup of src/main/java
184 *
185 * Revision 1.1 2010/01/05 13:26:17 oboehm
186 * begin with 1.0
187 *
188 * Revision 1.5 2009/12/28 10:07:23 oboehm
189 * missing Javadocs completed
190 *
191 * Revision 1.4 2009/12/19 22:34:09 oboehm
192 * trailing spaces removed
193 *
194 * Revision 1.3 2009/09/25 14:49:43 oboehm
195 * javadocs completed with the help of JAutodoc
196 *
197 * Revision 1.2 2009/04/09 18:30:47 oboehm
198 * no longer double entries (bug 2745302 fixed)
199 *
200 * Revision 1.1 2009/04/06 07:08:53 oboehm
201 * detection of never called constructors implemented
202 *
203 * $Source: /cvsroot/patterntesting/PatternTesting10/patterntesting-rt/src/main/java/patterntesting/runtime/util/reflect/ConstructorSignatureImpl.java,v $
204 */