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 36 public class TooManyParametersRule extends InspectorBase implements Parameterizable { 37 41 private Integer maxParameters; 42 43 48 public void visit(Operation operation) { 49 if (maxParameters!=null && operation.getParameters().size()>maxParameters.intValue()) { 50 context.reportViolation(operation, new Object [] {new Integer (operation.getParameters().size()), maxParameters}); 51 } 52 } 53 54 62 public boolean setParameter(String name, Object value) throws ConfigurationException { 63 if ("max-parameters".equals(name)) { 64 maxParameters=new Integer (Integer.parseInt(value.toString())); 65 return true; 66 } 67 68 throw new ConfigurationException("Parameter '"+name+"' is not supported"); 69 } 70 71 74 public String getConfigInfo() { 75 StringBuffer ret=new StringBuffer ("Allowed nbr of parameters:\n"); 76 ret.append("max parameters: " + maxParameters + "\n"); 77 return ret.toString(); 78 } 79 } 80 | Popular Tags |