psteitz     2004/04/11 22:22:11

  Modified:    math/src/java/org/apache/commons/math/stat/univariate
                        AbstractUnivariateStatistic.java
  Log:
  Reordered checks in test() method to avoid NPE.
  
  Revision  Changes    Path
  1.15      +10 -6     
jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/AbstractUnivariateStatistic.java
  
  Index: AbstractUnivariateStatistic.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/AbstractUnivariateStatistic.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AbstractUnivariateStatistic.java  11 Apr 2004 19:39:10 -0000      1.14
  +++ AbstractUnivariateStatistic.java  12 Apr 2004 05:22:11 -0000      1.15
  @@ -48,7 +48,7 @@
        * @param values Is a double[] containing the values
        * @param begin processing at this point in the array
        * @param length the number of elements to include
  -     * @return true if the array has postive length
  +     * @return true if the parameters are valid and designate a subarray of 
positive length
        * @throws IllegalArgumentException if the indices are invalid or the array is 
null
        */
       protected boolean test(
  @@ -59,14 +59,18 @@
           if (begin < 0) {
               throw new IllegalArgumentException("start position cannot be negative");
           }
  +        
  +        if (length < 0) {
  +            throw new IllegalArgumentException("length cannot be negative");
  +        }
  +        
  +        if (values == null) {
  +            throw new IllegalArgumentException("input value array is null");
  +        }
   
           if (begin + length > values.length) {
               throw new IllegalArgumentException(
                   "begin + length > values.length");
  -        }
  -
  -        if (values == null) {
  -            throw new IllegalArgumentException("input value array is null");
           }
   
           if (length == 0) {
  
  
  

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

Reply via email to