commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator ValidatorResult.java
Date Sat, 24 May 2003 18:36:20 GMT
dgraham     2003/05/24 11:36:20

  Modified:    validator/src/share/org/apache/commons/validator
                        ValidatorResult.java
  Log:
  Simplified isValid() logic and changed ResultStatus.getValid to isValid.
  
  Revision  Changes    Path
  1.5       +96 -93    jakarta-commons/validator/src/share/org/apache/commons/validator/ValidatorResult.java
  
  Index: ValidatorResult.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/ValidatorResult.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ValidatorResult.java	13 Dec 2002 07:54:10 -0000	1.4
  +++ ValidatorResult.java	24 May 2003 18:36:19 -0000	1.5
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -59,7 +59,6 @@
    *
    */
   
  -
   package org.apache.commons.validator;
   
   import java.io.Serializable;
  @@ -67,109 +66,113 @@
   import java.util.HashMap;
   import java.util.Map;
   
  -
   /**
    * <p>This contains the results of a set of 
    * validation rules processed on JavaBean.</p>
    *
    * @author David Winterfeldt
    * @version $Revision$ $Date$
  -*/
  + */
   public class ValidatorResult implements Serializable {
   
      /**
  -    * Map of results.  The key is the name 
  -    * of the <code>ValidatorAction</code> 
  -    * and the value is whether or not 
  -    * this field passed or not.
  -   */
  -   protected Map hAction = new HashMap();
  +    * Map of results.  The key is the name of the <code>ValidatorAction</code>

  +    * and the value is whether or not this field passed or not.
  +    */
  +    protected Map hAction = new HashMap();
   
      /**
       * <code>Field</code> being validated.
  -   */
  -   protected Field field = null;
  +    */
  +    protected Field field = null;
      
  -   /**
  -    * Constructs a <code>ValidatorResult</code> 
  -    * with the associated field being validated.
  -   */
  -   public ValidatorResult(Field field) {
  -      this.field = field;	
  -   }
  -
  -   /**
  -    * Add the result of a validator action.
  -   */
  -   public void add(String validatorName, boolean result) {
  -      add(validatorName, result, null);
  -   }
  +    /**
  +     * Constructs a <code>ValidatorResult</code> with the associated field
being 
  +     * validated.
  +     */
  +    public ValidatorResult(Field field) {
  +        this.field = field;
  +    }
  +
  +    /**
  +     * Add the result of a validator action.
  +     */
  +    public void add(String validatorName, boolean result) {
  +        add(validatorName, result, null);
  +    }
   
      /**
       * Add the result of a validator action.
  -   */
  -   public void add(String validatorName, boolean result, Object value) {
  -      hAction.put(validatorName, new ResultStatus(result, value));
  -   }
  -
  -   public boolean containsAction(String validatorName) {
  -      return hAction.containsKey(validatorName);	
  -   }
  -
  -   public boolean isValid(String validatorName) {
  -      Object o = hAction.get(validatorName);	
  -      
  -      return ((o != null) ? ((ResultStatus)o).getValid() : false);
  -   }
  -
  -   public Map getActionMap() {
  -      return Collections.unmodifiableMap(hAction);
  -   }
  +    */
  +    public void add(String validatorName, boolean result, Object value) {
  +        hAction.put(validatorName, new ResultStatus(result, value));
  +    }
  +    
  +    public boolean containsAction(String validatorName) {
  +        return hAction.containsKey(validatorName);
  +    }
  +
  +    public boolean isValid(String validatorName) {
  +        ResultStatus status = (ResultStatus) hAction.get(validatorName);
  +        return (status == null) ? false : status.isValid();
  +    }
  +
  +    public Map getActionMap() {
  +        return Collections.unmodifiableMap(hAction);
  +    }
         
  -   /**
  -    * Contains the status of the validation.
  -   */
  -   protected class ResultStatus implements Serializable {
  -      private boolean valid = false;
  -      private Object result = null;
  -      
  -      public ResultStatus(boolean valid, Object result) {
  -         this.valid = valid;
  -         this.result = result;
  -      }
  -      
  -      /**
  -       * Gets whether or not the validation passed.
  -      */
  -      public boolean getValid() {
  -         return valid;
  -      }
  -
  -      /**
  -       * Sets whether or not the validation passed.
  -      */
  -      public void setValid(boolean valid) {
  -         this.valid = valid;
  -      }
  -
  -      /**
  -       * Gets the result returned by a validation method.  
  -       * This can be used to retrieve to the correctly 
  -       * typed value of a date validation for example.
  -      */
  -      public Object getResult() {
  -         return result;
  -      }
  -
  -      /**
  -       * Sets the result returned by a validation method.  
  -       * This can be used to retrieve to the correctly 
  -       * typed value of a date validation for example.
  -      */
  -      public void setResult(Object result) {
  -         this.result = result;
  -      }
  -
  -   }
  +    /**
  +     * Contains the status of the validation.
  +     */
  +    protected class ResultStatus implements Serializable {
  +        private boolean valid = false;
  +        private Object result = null;
  +    
  +        public ResultStatus(boolean valid, Object result) {
  +            this.valid = valid;
  +            this.result = result;
  +        }
  +    
  +        /**
  +         * Gets whether or not the validation passed.
  +         * @deprecated Use isValid() instead.
  +         */
  +        public boolean getValid() {
  +            return valid;
  +        }
  +    
  +        /**
  +         * Tests whether or not the validation passed.
  +         */
  +        public boolean isValid() {
  +            return valid;
  +        }
  +    
  +        /**
  +         * Sets whether or not the validation passed.
  +         */
  +        public void setValid(boolean valid) {
  +            this.valid = valid;
  +        }
  +    
  +        /**
  +         * Gets the result returned by a validation method.  
  +         * This can be used to retrieve to the correctly 
  +         * typed value of a date validation for example.
  +         */
  +        public Object getResult() {
  +            return result;
  +        }
  +    
  +        /**
  +         * Sets the result returned by a validation method.  
  +         * This can be used to retrieve to the correctly 
  +         * typed value of a date validation for example.
  +         */
  +        public void setResult(Object result) {
  +            this.result = result;
  +        }
  +    
  +    }
      
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message