1 package xdoclet.modules.ojb.constraints; 2 3 17 18 import xdoclet.modules.ojb.LogHelper; 19 import xdoclet.modules.ojb.model.ClassDescriptorDef; 20 import xdoclet.modules.ojb.model.DefBase; 21 import xdoclet.modules.ojb.model.PropertyHelper; 22 23 28 public abstract class ConstraintsBase 29 { 30 31 public static final String CHECKLEVEL_NONE = "none"; 32 public static final String CHECKLEVEL_BASIC = "basic"; 33 public static final String CHECKLEVEL_STRICT = "strict"; 34 35 41 protected void checkProxyPrefetchingLimit(DefBase def, String checkLevel) throws ConstraintException 42 { 43 if (CHECKLEVEL_NONE.equals(checkLevel)) 44 { 45 return; 46 } 47 if (def.hasProperty(PropertyHelper.OJB_PROPERTY_PROXY_PREFETCHING_LIMIT)) 48 { 49 if (!def.hasProperty(PropertyHelper.OJB_PROPERTY_PROXY)) 50 { 51 if (def instanceof ClassDescriptorDef) 52 { 53 LogHelper.warn(true, 54 ConstraintsBase.class, 55 "checkProxyPrefetchingLimit", 56 "The class "+def.getName()+" has a proxy-prefetching-limit property but no proxy property"); 57 } 58 else 59 { 60 LogHelper.warn(true, 61 ConstraintsBase.class, 62 "checkProxyPrefetchingLimit", 63 "The feature "+def.getName()+" in class "+def.getOwner().getName()+" has a proxy-prefetching-limit property but no proxy property"); 64 } 65 } 66 67 String propValue = def.getProperty(PropertyHelper.OJB_PROPERTY_PROXY_PREFETCHING_LIMIT); 68 69 try 70 { 71 int value = Integer.parseInt(propValue); 72 73 if (value < 0) 74 { 75 if (def instanceof ClassDescriptorDef) 76 { 77 throw new ConstraintException("The proxy-prefetching-limit value of class "+def.getName()+" must be a non-negative number"); 78 } 79 else 80 { 81 throw new ConstraintException("The proxy-prefetching-limit value of the feature "+def.getName()+" in class "+def.getOwner().getName()+" must be a non-negative number"); 82 } 83 } 84 } 85 catch (NumberFormatException ex) 86 { 87 if (def instanceof ClassDescriptorDef) 88 { 89 throw new ConstraintException("The proxy-prefetching-limit value of the class "+def.getName()+" is not a number"); 90 } 91 else 92 { 93 throw new ConstraintException("The proxy-prefetching-limit value of the feature "+def.getName()+" in class "+def.getOwner().getName()+" is not a number"); 94 } 95 } 96 } 97 } 98 } 99 | Popular Tags |