1 21 22 package org.apache.commons.validator; 23 24 import java.io.Serializable ; 25 import java.util.Collections ; 26 import java.util.HashMap ; 27 import java.util.Map ; 28 29 33 public class ValidatorResult implements Serializable { 34 35 39 protected Map hAction = new HashMap (); 40 41 45 protected Field field = null; 46 47 51 public ValidatorResult(Field field) { 52 this.field = field; 53 } 54 55 58 public void add(String validatorName, boolean result) { 59 this.add(validatorName, result, null); 60 } 61 62 65 public void add(String validatorName, boolean result, Object value) { 66 hAction.put(validatorName, new ResultStatus(result, value)); 67 } 68 69 public boolean containsAction(String validatorName) { 70 return hAction.containsKey(validatorName); 71 } 72 73 public boolean isValid(String validatorName) { 74 ResultStatus status = (ResultStatus) hAction.get(validatorName); 75 return (status == null) ? false : status.isValid(); 76 } 77 78 public Map getActionMap() { 79 return Collections.unmodifiableMap(hAction); 80 } 81 82 85 public Field getField() { 86 return this.field; 87 } 88 89 92 protected class ResultStatus implements Serializable { 93 private boolean valid = false; 94 private Object result = null; 95 96 public ResultStatus(boolean valid, Object result) { 97 this.valid = valid; 98 this.result = result; 99 } 100 101 104 public boolean isValid() { 105 return valid; 106 } 107 108 111 public void setValid(boolean valid) { 112 this.valid = valid; 113 } 114 115 120 public Object getResult() { 121 return result; 122 } 123 124 129 public void setResult(Object result) { 130 this.result = result; 131 } 132 133 } 134 135 } | Popular Tags |