1 46 package groovy.lang; 47 48 import java.lang.reflect.Field ; 49 import java.lang.reflect.Modifier ; 50 51 58 public class IllegalPropertyAccessException extends MissingPropertyException { 59 60 private static String makeMessage(String propertyName, Class clazz, int modifiers, boolean isField) { 61 String access = "private"; 62 if (Modifier.isProtected(modifiers)) access = "protected"; 63 if (Modifier.isPublic(modifiers)) access = "public"; 64 String propertyType = "property"; 65 if (isField) propertyType = "field"; 66 return "Can not access the "+access+" "+propertyType+" "+propertyName+" in class "+clazz.getName(); 67 } 68 69 public IllegalPropertyAccessException(String propertyName, Class clazz, int modifiers) { 70 super(makeMessage(propertyName,clazz,modifiers,false),propertyName,clazz); 71 } 72 73 public IllegalPropertyAccessException(Field field, Class clazz) { 74 super(makeMessage(field.getName(),clazz,field.getModifiers(),true),field.getName(),clazz); 75 } 76 77 } 78 | Popular Tags |