1 7 package com.inversoft.verge.mvc.config; 8 9 10 import java.util.ArrayList ; 11 import java.util.List ; 12 13 import com.inversoft.util.ReflectionException; 14 import com.inversoft.util.ReflectionTools; 15 import com.inversoft.verge.mvc.validator.Validator; 16 17 18 28 public class BaseValidatorConfig extends BaseConfig { 29 30 private Class validator; 31 private String failure; 32 private List properties; 33 34 35 42 public BaseValidatorConfig(Class validator, String failure) { 43 this.validator = validator; 44 this.failure = failure; 45 this.properties = new ArrayList (); 46 47 if (validator != null) { 48 setName(validator.getName()); 49 } 50 } 51 52 59 public BaseValidatorConfig(BaseValidatorConfig base) { 60 this.validator = base.validator; 61 this.failure = base.failure; 62 this.properties = new ArrayList (base.properties); 63 64 if (validator != null) { 65 setName(validator.getName()); 66 } 67 } 68 69 70 77 public String getFailureDefinition() { 78 return failure; 79 } 80 81 86 public void setFailureDefinition(String failure) { 87 this.failure = failure; 88 } 89 90 95 protected Class getValidator() { 96 return validator; 97 } 98 99 104 void setValidator(Class validator) { 105 this.validator = validator; 106 } 107 108 113 public boolean isValidating() { 114 return (validator != null); 115 } 116 117 120 public Validator newValidator() throws ReflectionException { 121 return (Validator) ReflectionTools.instantiate(validator); 122 } 123 124 129 public void addProperty(PropertyConfig property) { 130 properties.add(property); 131 } 132 133 140 public List getProperties() { 141 return new ArrayList (properties); 142 } 143 144 147 public boolean hasProperties() { 148 return (properties.size() > 0); 149 } 150 151 156 void removeProperty(PropertyConfig propConfig) { 157 properties.remove(propConfig); 158 } 159 } | Popular Tags |