1 12 package org.aspectj.internal.lang.reflect; 13 14 import java.lang.reflect.Type ; 15 16 import org.aspectj.lang.reflect.AjType; 17 import org.aspectj.lang.reflect.DeclareParents; 18 import org.aspectj.lang.reflect.TypePattern; 19 20 24 public class DeclareParentsImpl implements DeclareParents { 25 26 private AjType<?> declaringType; 27 private TypePattern targetTypesPattern; 28 private Type [] parents; 29 private String parentsString; 30 private String firstMissingTypeName; 31 private boolean isExtends; 32 private boolean parentsError = false; 33 34 38 public DeclareParentsImpl(String targets, String parentsAsString, boolean isExtends, AjType<?> declaring) 39 { 40 this.targetTypesPattern = new TypePatternImpl(targets); 41 this.isExtends = isExtends; 42 this.declaringType = declaring; 43 this.parentsString = parentsAsString; 44 try { 45 this.parents = StringToType.commaSeparatedListToTypeArray(parentsAsString, declaring.getJavaClass()); 46 } catch (ClassNotFoundException cnfEx) { 47 this.parentsError = true; 48 this.firstMissingTypeName = cnfEx.getMessage(); 49 } 50 } 51 52 55 public AjType getDeclaringType() { 56 return this.declaringType; 57 } 58 59 62 public TypePattern getTargetTypesPattern() { 63 return this.targetTypesPattern; 64 } 65 66 69 public boolean isExtends() { 70 return this.isExtends; 71 } 72 73 76 public boolean isImplements() { 77 return !this.isExtends; 78 } 79 80 83 public Type [] getParentTypes() throws ClassNotFoundException { 84 if (parentsError) { 85 throw new ClassNotFoundException (this.firstMissingTypeName); 86 } 87 return this.parents; 88 } 89 90 public String toString() { 91 StringBuffer sb = new StringBuffer (); 92 sb.append("declare parents : "); 93 sb.append(getTargetTypesPattern().asString()); 94 sb.append(isExtends() ? " extends " : " implements "); 95 sb.append(this.parentsString); 96 return sb.toString(); 97 } 98 } 99 | Popular Tags |