1 13 14 15 package org.aspectj.runtime.reflect; 16 17 import java.lang.reflect.Field ; 18 19 import org.aspectj.lang.reflect.FieldSignature; 20 21 public class FieldSignatureImpl extends MemberSignatureImpl implements FieldSignature { 22 Class fieldType; 23 private Field field; 24 25 FieldSignatureImpl(int modifiers, String name, Class declaringType, 26 Class fieldType) 27 { 28 super(modifiers, name, declaringType); 29 this.fieldType = fieldType; 30 } 31 32 FieldSignatureImpl(String stringRep) { 33 super(stringRep); 34 } 35 36 public Class getFieldType() { 37 if (fieldType == null) fieldType = extractType(3); 38 return fieldType; 39 } 40 41 protected String createToString(StringMaker sm) { 42 StringBuffer buf = new StringBuffer (); 43 buf.append(sm.makeModifiersString(getModifiers())); 44 if (sm.includeArgs) buf.append(sm.makeTypeName(getFieldType())); 45 if (sm.includeArgs) buf.append(" "); 46 buf.append(sm.makePrimaryTypeName(getDeclaringType(),getDeclaringTypeName())); 47 buf.append("."); 48 buf.append(getName()); 49 return buf.toString(); 50 } 51 52 55 public Field getField() { 56 if (field == null) { 57 try { 58 field = getDeclaringType().getDeclaredField(getName()); 59 } catch (Exception ex) { 60 ; } 62 } 63 return field; 64 } 65 } 66 | Popular Tags |