1 16 17 package org.springframework.validation; 18 19 import java.util.List ; 20 import java.util.Map ; 21 22 import org.springframework.beans.PropertyEditorRegistry; 23 import org.springframework.util.Assert; 24 25 42 public class BindException extends Exception implements BindingResult { 43 44 50 public static final String ERROR_KEY_PREFIX = BindException.class.getName() + "."; 51 52 53 private final BindingResult bindingResult; 54 55 56 60 public BindException(BindingResult bindingResult) { 61 Assert.notNull(bindingResult, "BindingResult must not be null"); 62 this.bindingResult = bindingResult; 63 } 64 65 71 public BindException(Object target, String objectName) { 72 Assert.notNull(target, "Target object must not be null"); 73 this.bindingResult = new BeanPropertyBindingResult(target, objectName); 74 } 75 76 77 82 public final BindingResult getBindingResult() { 83 return this.bindingResult; 84 } 85 86 90 public final PropertyEditorRegistry getPropertyEditorRegistry() { 91 return this.bindingResult.getPropertyEditorRegistry(); 92 } 93 94 95 public String getObjectName() { 96 return this.bindingResult.getObjectName(); 97 } 98 99 public void setNestedPath(String nestedPath) { 100 this.bindingResult.setNestedPath(nestedPath); 101 } 102 103 public String getNestedPath() { 104 return this.bindingResult.getNestedPath(); 105 } 106 107 public void pushNestedPath(String subPath) { 108 this.bindingResult.pushNestedPath(subPath); 109 } 110 111 public void popNestedPath() throws IllegalStateException { 112 this.bindingResult.popNestedPath(); 113 } 114 115 116 public void reject(String errorCode) { 117 this.bindingResult.reject(errorCode); 118 } 119 120 public void reject(String errorCode, String defaultMessage) { 121 this.bindingResult.reject(errorCode, defaultMessage); 122 } 123 124 public void reject(String errorCode, Object [] errorArgs, String defaultMessage) { 125 this.bindingResult.reject(errorCode, errorArgs, defaultMessage); 126 } 127 128 public void rejectValue(String field, String errorCode) { 129 this.bindingResult.rejectValue(field, errorCode); 130 } 131 132 public void rejectValue(String field, String errorCode, String defaultMessage) { 133 this.bindingResult.rejectValue(field, errorCode, defaultMessage); 134 } 135 136 public void rejectValue(String field, String errorCode, Object [] errorArgs, String defaultMessage) { 137 this.bindingResult.rejectValue(field, errorCode, errorArgs, defaultMessage); 138 } 139 140 public void addAllErrors(Errors errors) { 141 this.bindingResult.addAllErrors(errors); 142 } 143 144 145 public boolean hasErrors() { 146 return this.bindingResult.hasErrors(); 147 } 148 149 public int getErrorCount() { 150 return this.bindingResult.getErrorCount(); 151 } 152 153 public List getAllErrors() { 154 return this.bindingResult.getAllErrors(); 155 } 156 157 public boolean hasGlobalErrors() { 158 return this.bindingResult.hasGlobalErrors(); 159 } 160 161 public int getGlobalErrorCount() { 162 return this.bindingResult.getGlobalErrorCount(); 163 } 164 165 public List getGlobalErrors() { 166 return this.bindingResult.getGlobalErrors(); 167 } 168 169 public ObjectError getGlobalError() { 170 return this.bindingResult.getGlobalError(); 171 } 172 173 public boolean hasFieldErrors() { 174 return this.bindingResult.hasFieldErrors(); 175 } 176 177 public int getFieldErrorCount() { 178 return this.bindingResult.getFieldErrorCount(); 179 } 180 181 public List getFieldErrors() { 182 return this.bindingResult.getFieldErrors(); 183 } 184 185 public FieldError getFieldError() { 186 return this.bindingResult.getFieldError(); 187 } 188 189 public boolean hasFieldErrors(String field) { 190 return this.bindingResult.hasFieldErrors(field); 191 } 192 193 public int getFieldErrorCount(String field) { 194 return this.bindingResult.getFieldErrorCount(field); 195 } 196 197 public List getFieldErrors(String field) { 198 return this.bindingResult.getFieldErrors(field); 199 } 200 201 public FieldError getFieldError(String field) { 202 return this.bindingResult.getFieldError(field); 203 } 204 205 public Object getFieldValue(String field) { 206 return this.bindingResult.getFieldValue(field); 207 } 208 209 public Class getFieldType(String field) { 210 return this.bindingResult.getFieldType(field); 211 } 212 213 public Object getTarget() { 214 return this.bindingResult.getTarget(); 215 } 216 217 public Map getModel() { 218 return this.bindingResult.getModel(); 219 } 220 221 public void recordSuppressedField(String fieldName) { 222 this.bindingResult.recordSuppressedField(fieldName); 223 } 224 225 public String [] getSuppressedFields() { 226 return this.bindingResult.getSuppressedFields(); 227 } 228 229 public void addError(ObjectError error) { 230 this.bindingResult.addError(error); 231 } 232 233 public String [] resolveMessageCodes(String errorCode, String field) { 234 return this.bindingResult.resolveMessageCodes(errorCode, field); 235 } 236 237 238 241 public String getMessage() { 242 return this.bindingResult.toString(); 243 } 244 245 public boolean equals(Object other) { 246 return (this == other || this.bindingResult.equals(other)); 247 } 248 249 public int hashCode() { 250 return this.bindingResult.hashCode(); 251 } 252 253 } 254 | Popular Tags |