KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > runtime > reflect > InitializerSignatureImpl


1 /* *******************************************************************
2  * Copyright (c) 1999-2001 Xerox Corporation,
3  * 2002 Palo Alto Research Center, Incorporated (PARC).
4  * All rights reserved.
5  * This program and the accompanying materials are made available
6  * under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * Xerox/PARC initial implementation
12  * ******************************************************************/

13
14
15 package org.aspectj.runtime.reflect;
16
17 import org.aspectj.lang.reflect.InitializerSignature;
18
19 import java.lang.reflect.Constructor JavaDoc;
20 import java.lang.reflect.Modifier JavaDoc;
21
22 class InitializerSignatureImpl extends CodeSignatureImpl implements InitializerSignature {
23     private Constructor JavaDoc constructor;
24     
25     InitializerSignatureImpl(int modifiers, Class JavaDoc declaringType) {
26         super(modifiers, Modifier.isStatic(modifiers) ? "<clinit>" : "<init>", declaringType, EMPTY_CLASS_ARRAY,
27               EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY);
28     }
29     
30     InitializerSignatureImpl(String JavaDoc stringRep) {
31         super(stringRep);
32     }
33     
34     public String JavaDoc getName() {
35         return Modifier.isStatic(getModifiers()) ? "<clinit>": "<init>";
36     }
37
38     protected String JavaDoc createToString(StringMaker sm) {
39         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
40         buf.append(sm.makeModifiersString(getModifiers()));
41         buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName()));
42         buf.append(".");
43         buf.append(getName());
44         return buf.toString();
45     }
46     
47     /* (non-Javadoc)
48      * @see org.aspectj.runtime.reflect.MemberSignatureImpl#createAccessibleObject()
49      */

50     public Constructor JavaDoc getInitializer() {
51         if (constructor == null) {
52             try {
53                 constructor = getDeclaringType().getDeclaredConstructor(getParameterTypes());
54             } catch (Exception JavaDoc ex) {
55                 ; // nothing we can do, caller will see null
56
}
57         }
58         return constructor;
59     }
60 }
61
Popular Tags