turner      2002/09/19 10:25:27

  Modified:    validator/src/share/org/apache/commons/validator
                        GenericValidator.java
  Log:
  Bug 11541
  
  Added double, short and float range checking.
  
  Revision  Changes    Path
  1.6       +41 -4     
jakarta-commons/validator/src/share/org/apache/commons/validator/GenericValidator.java
  
  Index: GenericValidator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/GenericValidator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GenericValidator.java     2 Apr 2002 01:59:11 -0000       1.5
  +++ GenericValidator.java     19 Sep 2002 17:25:27 -0000      1.6
  @@ -75,6 +75,7 @@
    * performing validations.</p>
    *
    * @author David Winterfeldt
  + * @author James Turner
    * @version $Revision$ $Date$
   */
   public class GenericValidator implements Serializable {
  @@ -248,6 +249,42 @@
        * @param        max             The maximum value of the range.
       */
       public static boolean isInRange(int value, int min, int max) {
  +       return ((value >= min) && (value <= max));
  +    }
  +
  +    /**
  +     * <p>Checks if a value is within a range (min &amp; max specified 
  +     * in the vars attribute).</p>
  +     *
  +     * @param        value           The value validation is being performed on.
  +     * @param        min             The minimum value of the range.
  +     * @param        max             The maximum value of the range.
  +    */
  +    public static boolean isInRange(float value, float min, float max) {
  +       return ((value >= min) && (value <= max));
  +    }
  +
  +    /**
  +     * <p>Checks if a value is within a range (min &amp; max specified 
  +     * in the vars attribute).</p>
  +     *
  +     * @param        value           The value validation is being performed on.
  +     * @param        min             The minimum value of the range.
  +     * @param        max             The maximum value of the range.
  +    */
  +    public static boolean isInRange(short value, short min, short max) {
  +       return ((value >= min) && (value <= max));
  +    }
  +
  +    /**
  +     * <p>Checks if a value is within a range (min &amp; max specified 
  +     * in the vars attribute).</p>
  +     *
  +     * @param        value           The value validation is being performed on.
  +     * @param        min             The minimum value of the range.
  +     * @param        max             The maximum value of the range.
  +    */
  +    public static boolean isInRange(double value, double min, double max) {
          return ((value >= min) && (value <= max));
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to