1 15 package org.apache.tapestry.enhance; 16 17 import java.lang.reflect.Method ; 18 import java.lang.reflect.Modifier ; 19 import java.util.HashSet ; 20 import java.util.Set ; 21 22 import org.apache.hivemind.ErrorLog; 23 import org.apache.hivemind.service.MethodSignature; 24 import org.apache.tapestry.spec.IComponentSpecification; 25 26 33 public class EnhancedClassValidatorImpl implements EnhancedClassValidator 34 { 35 private ErrorLog _errorLog; 36 37 public void validate(Class baseClass, Class enhancedClass, IComponentSpecification specification) 38 { 39 Set implementedMethods = new HashSet (); 40 41 Class current = enhancedClass; 42 43 while (true) 44 { 45 Method [] methods = current.getDeclaredMethods(); 46 47 for (int i = 0; i < methods.length; i++) 48 { 49 Method m = methods[i]; 50 51 boolean isAbstract = Modifier.isAbstract(m.getModifiers()); 52 53 MethodSignature s = new MethodSignature(m); 54 55 if (isAbstract) 56 { 57 if (implementedMethods.contains(s)) 58 continue; 59 60 _errorLog.error(EnhanceMessages.noImplForAbstractMethod(m, current, baseClass 61 .getName(), enhancedClass), specification.getLocation(), null); 62 } 63 64 implementedMethods.add(s); 65 } 66 67 72 74 current = current.getSuperclass(); 75 76 81 if (current == null || !Modifier.isAbstract(current.getModifiers())) 82 break; 83 } 84 85 } 86 87 public void setErrorLog(ErrorLog errorLog) 88 { 89 _errorLog = errorLog; 90 } 91 } | Popular Tags |