1 23 package org.hammurapi.inspectors; 24 25 import org.hammurapi.InspectorBase; 26 27 import com.pavelvlasov.config.ConfigurationException; 28 import com.pavelvlasov.config.Parameterizable; 29 import com.pavelvlasov.jsel.Operation; 30 31 37 public class TooManyThrowsRule extends InspectorBase implements Parameterizable { 38 42 private Integer maxThrows; 43 44 50 public void visit(Operation element) { 51 if (element.getThrows().size()>maxThrows.intValue()) { 52 context.reportViolation(element); 53 } 54 } 55 56 64 public boolean setParameter(String name, Object parameter) throws ConfigurationException { 65 if ("max-throws".equals(name)) { 66 maxThrows = (Integer ) parameter; 67 return true; 68 } 69 70 throw new ConfigurationException("Parameter '"+name+"' is not supported by "+getClass().getName()); 71 } 72 73 76 public String getConfigInfo() { 77 StringBuffer ret=new StringBuffer ("Allowed maximum item in the throws clause:\n"); 79 ret.append("max-throws: " + maxThrows + "\n"); 81 return ret.toString(); 82 } 83 } 84 | Popular Tags |