1 20 package org.enhydra.barracuda.core.forms.validators; 21 22 import java.util.*; 23 24 import org.enhydra.barracuda.core.forms.*; 25 import org.enhydra.barracuda.plankton.*; 26 27 31 public class EqualsValidator extends DefaultFormValidator { 32 33 protected Object obj = null; 34 35 38 public EqualsValidator() { 39 this(null, null); 40 } 41 42 47 public EqualsValidator(Object iobj) { 48 this(iobj, null); 49 } 50 51 57 public EqualsValidator(Object iobj, String ierrmsg) { 58 super(ierrmsg); 59 obj = iobj; 60 } 61 62 66 public Object getObject() { 67 return obj; 68 } 69 70 82 public void validateFormElement(Object val, FormElement element, boolean deferExceptions) throws ValidationException { 83 if (localLogger.isInfoEnabled()) localLogger.info("validating to see if val {"+val+"} .equals() {"+obj+"}"); 84 if (isNull(val, element)) 87 return; 88 89 if (val==obj) return; 90 91 if (element.getParseException()==null) { 92 if (element.getVal().equals(obj)) 93 return; 94 else 95 throw this.generateException(element, deferExceptions, "Value {"+val+"} is not equal to {"+obj+"}"); 96 } 97 else 98 throw this.generateException(element, deferExceptions, "Unable to parse: " + element.getParseException().getMessage()); 99 101 102 108 } 110 111 } 112 | Popular Tags |