scolebourne    2003/07/12 03:09:40

  Modified:    lang/src/java/org/apache/commons/lang ArrayUtils.java
               lang/src/test/org/apache/commons/lang ArrayUtilsTest.java
  Log:
  Add indexOf for primitive arrays
  
  Revision  Changes    Path
  1.17      +760 -50   
jakarta-commons/lang/src/java/org/apache/commons/lang/ArrayUtils.java
  
  Index: ArrayUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/ArrayUtils.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ArrayUtils.java   28 Jun 2003 18:01:18 -0000      1.16
  +++ ArrayUtils.java   12 Jul 2003 10:09:40 -0000      1.17
  @@ -201,7 +201,7 @@
        *     {"BLUE", "#0000FF"}});
        * </pre>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        *
        * @param array  an array whose elements are either a [EMAIL PROTECTED] 
java.util.Map.Entry} or 
        *  an Array containing at least two elements, may be <code>null</code>
  @@ -238,6 +238,7 @@
           return map;
       }
   
  +    // Clone
       //-----------------------------------------------------------------------
       /**
        * <p>Shallow clones an array returning a typecast result and handling
  @@ -246,7 +247,7 @@
        * <p>The objecs in the array are not cloned, thus there is no special
        * handling for multi-dimensional arrays.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to shallow clone, may be <code>null</code>
        * @return the cloned array, or <code>null</code> if <code>null</code>
  @@ -263,7 +264,7 @@
        * <p>Clones an array returning a typecast result and handling
        * <code>null</code>.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to clone, may be <code>null</code>
        * @return the cloned array, or <code>null</code> if <code>null</code>
  @@ -280,7 +281,7 @@
        * <p>Clones an array returning a typecast result and handling
        * <code>null</code>.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to clone, may be <code>null</code>
        * @return the cloned array, or <code>null</code> if <code>null</code>
  @@ -297,7 +298,7 @@
        * <p>Clones an array returning a typecast result and handling
        * <code>null</code>.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to clone, may be <code>null</code>
        * @return the cloned array, or <code>null</code> if <code>null</code>
  @@ -314,7 +315,7 @@
        * <p>Clones an array returning a typecast result and handling
        * <code>null</code>.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to clone, may be <code>null</code>
        * @return the cloned array, or <code>null</code> if <code>null</code>
  @@ -331,7 +332,7 @@
        * <p>Clones an array returning a typecast result and handling
        * <code>null</code>.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to clone, may be <code>null</code>
        * @return the cloned array, or <code>null</code> if <code>null</code>
  @@ -348,7 +349,7 @@
        * <p>Clones an array returning a typecast result and handling
        * <code>null</code>.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to clone, may be <code>null</code>
        * @return the cloned array, or <code>null</code> if <code>null</code>
  @@ -365,7 +366,7 @@
        * <p>Clones an array returning a typecast result and handling
        * <code>null</code>.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to clone, may be <code>null</code>
        * @return the cloned array, or <code>null</code> if <code>null</code>
  @@ -382,7 +383,7 @@
        * <p>Clones an array returning a typecast result and handling
        * <code>null</code>.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to clone, may be <code>null</code>
        * @return the cloned array, or <code>null</code> if <code>null</code>
  @@ -395,6 +396,7 @@
           return (boolean[]) array.clone();
       }
   
  +    // Is same length
       //-----------------------------------------------------------------------
       /**
        * <p>Checks whether two arrays are the same length, treating
  @@ -576,13 +578,14 @@
           return array1.getClass().getName().equals(array2.getClass().getName());
       }
   
  +    // Reverse
       //-----------------------------------------------------------------------
       /** 
        * <p>Reverses the order of the given array.</p>
        *
        * <p>There is no special handling for multi-dimensional arrays.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to reverse, may be <code>null</code>
        */
  @@ -605,7 +608,7 @@
       /**
        * <p>Reverses the order of the given array.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to reverse, may be <code>null</code>
        */
  @@ -628,7 +631,7 @@
       /**
        * <p>Reverses the order of the given array.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to reverse, may be <code>null</code>
        */
  @@ -651,7 +654,7 @@
       /**
        * <p>Reverses the order of the given array.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to reverse, may be <code>null</code>
        */
  @@ -674,7 +677,7 @@
       /**
        * <p>Reverses the order of the given array.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to reverse, may be <code>null</code>
        */
  @@ -697,7 +700,7 @@
       /**
        * <p>Reverses the order of the given array.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to reverse, may be <code>null</code>
        */
  @@ -720,7 +723,7 @@
       /**
        * <p>Reverses the order of the given array.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to reverse, may be <code>null</code>
        */
  @@ -743,7 +746,7 @@
       /**
        * <p>Reverses the order of the given array.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to reverse, may be <code>null</code>
        */
  @@ -766,7 +769,7 @@
       /**
        * <p>Reverses the order of the given array.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  the array to reverse, may be <code>null</code>
        */
  @@ -786,12 +789,15 @@
           }
       }
   
  -    // IndexOf
  +    // IndexOf search
  +    // ----------------------------------------------------------------------
  +    
  +    // Object IndexOf
       //-----------------------------------------------------------------------
       /**
        * <p>Find the index of the given object in the array.</p>
        *
  -     * <p>This method returns <code>-1</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
        * 
        * @param array  the array to search through for the object, may be 
<code>null</code>
        * @param objectToFind  the object to find, may be <code>null</code>
  @@ -804,7 +810,7 @@
       /**
        * <p>Find the index of the given object in the array starting at the given 
index.</p>
        *
  -     * <p>This method returns <code>-1</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
        *
        * <p>A negative startIndex is treated as zero. A startIndex larger than the 
array
        * length will return -1.</p>
  @@ -841,23 +847,20 @@
       /**
        * <p>Find the last index of the given object within the array.</p>
        *
  -     * <p>This method returns <code>-1</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
        * 
        * @param array  the array to travers backwords looking for the object, may be 
<code>null</code>
        * @param objectToFind  the object to find, may be <code>null</code>
        * @return the last index of the object to find, or -1 if not found
        */
       public static int lastIndexOf(final Object[] array, final Object objectToFind) {
  -        if (array == null) {
  -            return -1;
  -        }
  -        return lastIndexOf(array, objectToFind, array.length - 1);
  +        return lastIndexOf(array, objectToFind, Integer.MAX_VALUE);
       }
   
       /**
        * <p>Find the last index of the given object in the array starting at the 
given index.</p>
        *
  -     * <p>This method returns <code>-1</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
        *
        * <p>A negative startIndex will return -1. A startIndex larger than the array
        * length will search from the end of the array.</p>
  @@ -906,6 +909,713 @@
           return (indexOf(array, objectToFind) != -1);
       }
   
  +    // long IndexOf
  +    //-----------------------------------------------------------------------
  +    /**
  +     * <p>Find the index of the given value in the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @return the index of the value within the array, or -1 if not found
  +     */
  +    public static int indexOf(final long[] array, final long valueToFind) {
  +        return indexOf(array, valueToFind, 0);
  +    }
  +
  +    /**
  +     * <p>Find the index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex is treated as zero. A startIndex larger than the 
array
  +     * length will return -1.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the index to start searching at
  +     * @return the index of the value within the array starting at the
  +     *  given index, or -1 if not found
  +     */
  +    public static int indexOf(final long[] array, final long valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            startIndex = 0;
  +        }
  +        for (int i = startIndex; i < array.length; i++) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value within the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to travers backwords looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the object to find
  +     * @return the last index of the value to find, or -1 if not found
  +     */
  +    public static int lastIndexOf(final long[] array, final long valueToFind) {
  +        return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex will return -1. A startIndex larger than the array
  +     * length will search from the end of the array.</p>
  +     * 
  +     * @param array  the array to traverse for looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the start index to travers backwards from
  +     * @return the last index of the value within the array starting at the given 
index,
  +     *  or -1 if not found
  +     */
  +    public static int lastIndexOf(final long[] array, final long valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            return -1;
  +        } else if (startIndex >= array.length) {
  +            startIndex = array.length - 1;
  +        }
  +        for (int i = startIndex; i >= 0; i--) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Checks if the value is in the given array.</p>
  +     *
  +     * <p>The method returns <code>false</code> if a <code>null</code> array is 
passed in.</p>
  +     * 
  +     * @param array  the array to search through
  +     * @param valueToFind  the value to find
  +     * @return <code>true</code> if the array contains the object
  +     */
  +    public static boolean contains(final long[] array, final long valueToFind) {
  +        return (indexOf(array, valueToFind) != -1);
  +    }
  +
  +    // int IndexOf
  +    //-----------------------------------------------------------------------
  +    /**
  +     * <p>Find the index of the given value in the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @return the index of the value within the array, or -1 if not found
  +     */
  +    public static int indexOf(final int[] array, final int valueToFind) {
  +        return indexOf(array, valueToFind, 0);
  +    }
  +
  +    /**
  +     * <p>Find the index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex is treated as zero. A startIndex larger than the 
array
  +     * length will return -1.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the index to start searching at
  +     * @return the index of the value within the array starting at the
  +     *  given index, or -1 if not found
  +     */
  +    public static int indexOf(final int[] array, final int valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            startIndex = 0;
  +        }
  +        for (int i = startIndex; i < array.length; i++) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value within the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to travers backwords looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the object to find
  +     * @return the last index of the value to find, or -1 if not found
  +     */
  +    public static int lastIndexOf(final int[] array, final int valueToFind) {
  +        return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex will return -1. A startIndex larger than the array
  +     * length will search from the end of the array.</p>
  +     * 
  +     * @param array  the array to traverse for looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the start index to travers backwards from
  +     * @return the last index of the value within the array starting at the given 
index,
  +     *  or -1 if not found
  +     */
  +    public static int lastIndexOf(final int[] array, final int valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            return -1;
  +        } else if (startIndex >= array.length) {
  +            startIndex = array.length - 1;
  +        }
  +        for (int i = startIndex; i >= 0; i--) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Checks if the value is in the given array.</p>
  +     *
  +     * <p>The method returns <code>false</code> if a <code>null</code> array is 
passed in.</p>
  +     * 
  +     * @param array  the array to search through
  +     * @param valueToFind  the value to find
  +     * @return <code>true</code> if the array contains the object
  +     */
  +    public static boolean contains(final int[] array, final int valueToFind) {
  +        return (indexOf(array, valueToFind) != -1);
  +    }
  +
  +    // short IndexOf
  +    //-----------------------------------------------------------------------
  +    /**
  +     * <p>Find the index of the given value in the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @return the index of the value within the array, or -1 if not found
  +     */
  +    public static int indexOf(final short[] array, final short valueToFind) {
  +        return indexOf(array, valueToFind, 0);
  +    }
  +
  +    /**
  +     * <p>Find the index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex is treated as zero. A startIndex larger than the 
array
  +     * length will return -1.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the index to start searching at
  +     * @return the index of the value within the array starting at the
  +     *  given index, or -1 if not found
  +     */
  +    public static int indexOf(final short[] array, final short valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            startIndex = 0;
  +        }
  +        for (int i = startIndex; i < array.length; i++) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value within the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to travers backwords looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the object to find
  +     * @return the last index of the value to find, or -1 if not found
  +     */
  +    public static int lastIndexOf(final short[] array, final short valueToFind) {
  +        return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex will return -1. A startIndex larger than the array
  +     * length will search from the end of the array.</p>
  +     * 
  +     * @param array  the array to traverse for looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the start index to travers backwards from
  +     * @return the last index of the value within the array starting at the given 
index,
  +     *  or -1 if not found
  +     */
  +    public static int lastIndexOf(final short[] array, final short valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            return -1;
  +        } else if (startIndex >= array.length) {
  +            startIndex = array.length - 1;
  +        }
  +        for (int i = startIndex; i >= 0; i--) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Checks if the value is in the given array.</p>
  +     *
  +     * <p>The method returns <code>false</code> if a <code>null</code> array is 
passed in.</p>
  +     * 
  +     * @param array  the array to search through
  +     * @param valueToFind  the value to find
  +     * @return <code>true</code> if the array contains the object
  +     */
  +    public static boolean contains(final short[] array, final short valueToFind) {
  +        return (indexOf(array, valueToFind) != -1);
  +    }
  +
  +    // byte IndexOf
  +    //-----------------------------------------------------------------------
  +    /**
  +     * <p>Find the index of the given value in the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @return the index of the value within the array, or -1 if not found
  +     */
  +    public static int indexOf(final byte[] array, final byte valueToFind) {
  +        return indexOf(array, valueToFind, 0);
  +    }
  +
  +    /**
  +     * <p>Find the index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex is treated as zero. A startIndex larger than the 
array
  +     * length will return -1.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the index to start searching at
  +     * @return the index of the value within the array starting at the
  +     *  given index, or -1 if not found
  +     */
  +    public static int indexOf(final byte[] array, final byte valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            startIndex = 0;
  +        }
  +        for (int i = startIndex; i < array.length; i++) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value within the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to travers backwords looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the object to find
  +     * @return the last index of the value to find, or -1 if not found
  +     */
  +    public static int lastIndexOf(final byte[] array, final byte valueToFind) {
  +        return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex will return -1. A startIndex larger than the array
  +     * length will search from the end of the array.</p>
  +     * 
  +     * @param array  the array to traverse for looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the start index to travers backwards from
  +     * @return the last index of the value within the array starting at the given 
index,
  +     *  or -1 if not found
  +     */
  +    public static int lastIndexOf(final byte[] array, final byte valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            return -1;
  +        } else if (startIndex >= array.length) {
  +            startIndex = array.length - 1;
  +        }
  +        for (int i = startIndex; i >= 0; i--) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Checks if the value is in the given array.</p>
  +     *
  +     * <p>The method returns <code>false</code> if a <code>null</code> array is 
passed in.</p>
  +     * 
  +     * @param array  the array to search through
  +     * @param valueToFind  the value to find
  +     * @return <code>true</code> if the array contains the object
  +     */
  +    public static boolean contains(final byte[] array, final byte valueToFind) {
  +        return (indexOf(array, valueToFind) != -1);
  +    }
  +
  +    // double IndexOf
  +    //-----------------------------------------------------------------------
  +    /**
  +     * <p>Find the index of the given value in the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @return the index of the value within the array, or -1 if not found
  +     */
  +    public static int indexOf(final double[] array, final double valueToFind) {
  +        return indexOf(array, valueToFind, 0);
  +    }
  +
  +    /**
  +     * <p>Find the index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex is treated as zero. A startIndex larger than the 
array
  +     * length will return -1.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the index to start searching at
  +     * @return the index of the value within the array starting at the
  +     *  given index, or -1 if not found
  +     */
  +    public static int indexOf(final double[] array, final double valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            startIndex = 0;
  +        }
  +        for (int i = startIndex; i < array.length; i++) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value within the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to travers backwords looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the object to find
  +     * @return the last index of the value to find, or -1 if not found
  +     */
  +    public static int lastIndexOf(final double[] array, final double valueToFind) {
  +        return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex will return -1. A startIndex larger than the array
  +     * length will search from the end of the array.</p>
  +     * 
  +     * @param array  the array to traverse for looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the start index to travers backwards from
  +     * @return the last index of the value within the array starting at the given 
index,
  +     *  or -1 if not found
  +     */
  +    public static int lastIndexOf(final double[] array, final double valueToFind, 
int startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            return -1;
  +        } else if (startIndex >= array.length) {
  +            startIndex = array.length - 1;
  +        }
  +        for (int i = startIndex; i >= 0; i--) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Checks if the value is in the given array.</p>
  +     *
  +     * <p>The method returns <code>false</code> if a <code>null</code> array is 
passed in.</p>
  +     * 
  +     * @param array  the array to search through
  +     * @param valueToFind  the value to find
  +     * @return <code>true</code> if the array contains the object
  +     */
  +    public static boolean contains(final double[] array, final double valueToFind) {
  +        return (indexOf(array, valueToFind) != -1);
  +    }
  +
  +    // float IndexOf
  +    //-----------------------------------------------------------------------
  +    /**
  +     * <p>Find the index of the given value in the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @return the index of the value within the array, or -1 if not found
  +     */
  +    public static int indexOf(final float[] array, final float valueToFind) {
  +        return indexOf(array, valueToFind, 0);
  +    }
  +
  +    /**
  +     * <p>Find the index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex is treated as zero. A startIndex larger than the 
array
  +     * length will return -1.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the index to start searching at
  +     * @return the index of the value within the array starting at the
  +     *  given index, or -1 if not found
  +     */
  +    public static int indexOf(final float[] array, final float valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            startIndex = 0;
  +        }
  +        for (int i = startIndex; i < array.length; i++) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value within the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to travers backwords looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the object to find
  +     * @return the last index of the value to find, or -1 if not found
  +     */
  +    public static int lastIndexOf(final float[] array, final float valueToFind) {
  +        return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex will return -1. A startIndex larger than the array
  +     * length will search from the end of the array.</p>
  +     * 
  +     * @param array  the array to traverse for looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the start index to travers backwards from
  +     * @return the last index of the value within the array starting at the given 
index,
  +     *  or -1 if not found
  +     */
  +    public static int lastIndexOf(final float[] array, final float valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            return -1;
  +        } else if (startIndex >= array.length) {
  +            startIndex = array.length - 1;
  +        }
  +        for (int i = startIndex; i >= 0; i--) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Checks if the value is in the given array.</p>
  +     *
  +     * <p>The method returns <code>false</code> if a <code>null</code> array is 
passed in.</p>
  +     * 
  +     * @param array  the array to search through
  +     * @param valueToFind  the value to find
  +     * @return <code>true</code> if the array contains the object
  +     */
  +    public static boolean contains(final float[] array, final float valueToFind) {
  +        return (indexOf(array, valueToFind) != -1);
  +    }
  +
  +    // boolean IndexOf
  +    //-----------------------------------------------------------------------
  +    /**
  +     * <p>Find the index of the given value in the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @return the index of the value within the array, or -1 if not found
  +     */
  +    public static int indexOf(final boolean[] array, final boolean valueToFind) {
  +        return indexOf(array, valueToFind, 0);
  +    }
  +
  +    /**
  +     * <p>Find the index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex is treated as zero. A startIndex larger than the 
array
  +     * length will return -1.</p>
  +     * 
  +     * @param array  the array to search through for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the index to start searching at
  +     * @return the index of the value within the array starting at the
  +     *  given index, or -1 if not found
  +     */
  +    public static int indexOf(final boolean[] array, final boolean valueToFind, int 
startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            startIndex = 0;
  +        }
  +        for (int i = startIndex; i < array.length; i++) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value within the array.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     * 
  +     * @param array  the array to travers backwords looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the object to find
  +     * @return the last index of the value to find, or -1 if not found
  +     */
  +    public static int lastIndexOf(final boolean[] array, final boolean valueToFind) 
{
  +        return lastIndexOf(array, valueToFind, Integer.MAX_VALUE);
  +    }
  +
  +    /**
  +     * <p>Find the last index of the given value in the array starting at the given 
index.</p>
  +     *
  +     * <p>This method returns <code>-1</code> if <code>null</code> array input.</p>
  +     *
  +     * <p>A negative startIndex will return -1. A startIndex larger than the array
  +     * length will search from the end of the array.</p>
  +     * 
  +     * @param array  the array to traverse for looking for the object, may be 
<code>null</code>
  +     * @param valueToFind  the value to find
  +     * @param startIndex  the start index to travers backwards from
  +     * @return the last index of the value within the array starting at the given 
index,
  +     *  or -1 if not found
  +     */
  +    public static int lastIndexOf(final boolean[] array, final boolean valueToFind, 
int startIndex) {
  +        if (array == null) {
  +            return -1;
  +        }
  +        if (startIndex < 0) {
  +            return -1;
  +        } else if (startIndex >= array.length) {
  +            startIndex = array.length - 1;
  +        }
  +        for (int i = startIndex; i >= 0; i--) {
  +            if (valueToFind == array[i]) {
  +                return i;
  +            }
  +        }
  +        return -1;
  +    }
  +
  +    /**
  +     * <p>Checks if the value is in the given array.</p>
  +     *
  +     * <p>The method returns <code>false</code> if a <code>null</code> array is 
passed in.</p>
  +     * 
  +     * @param array  the array to search through
  +     * @param valueToFind  the value to find
  +     * @return <code>true</code> if the array contains the object
  +     */
  +    public static boolean contains(final boolean[] array, final boolean 
valueToFind) {
  +        return (indexOf(array, valueToFind) != -1);
  +    }
  +
       // Primitive/Object array converters
       // ----------------------------------------------------------------------
       
  @@ -914,7 +1624,7 @@
       /**
        * <p>Converts an array of object Booleans to primitives.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Boolean</code> array, may be <code>null</code>
        * @return a <code>boolean</code> array
  @@ -936,7 +1646,7 @@
       /**
        * <p>Converts an array of object Booleans to primitives handling null.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Boolean</code> array, may be <code>null</code>
        * @param valueForNull  the value to insert if <code>null</code> found
  @@ -959,7 +1669,7 @@
       /**
        * <p>Converts an array of primitive booleans to objects.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>boolean</code> array
        * @return a <code>Boolean</code> array
  @@ -982,7 +1692,7 @@
       /**
        * <p>Converts an array of object Bytes to primitives.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Byte</code> array, may be <code>null</code>
        * @return a <code>byte</code> array
  @@ -1004,7 +1714,7 @@
       /**
        * <p>Converts an array of object Bytes to primitives handling null.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Byte</code> array, may be <code>null</code>
        * @param valueForNull  the value to insert if <code>null</code> found
  @@ -1027,7 +1737,7 @@
       /**
        * <p>Converts an array of primitive bytes to objects.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>byte</code> array
        * @return a <code>Byte</code> array
  @@ -1050,7 +1760,7 @@
       /**
        * <p>Converts an array of object Shorts to primitives.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Short</code> array, may be <code>null</code>
        * @return a <code>byte</code> array
  @@ -1072,7 +1782,7 @@
       /**
        * <p>Converts an array of object Short to primitives handling null.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Short</code> array, may be <code>null</code>
        * @param valueForNull  the value to insert if <code>null</code> found
  @@ -1095,7 +1805,7 @@
       /**
        * <p>Converts an array of primitive shorts to objects.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>short</code> array
        * @return a <code>Short</code> array
  @@ -1118,7 +1828,7 @@
       /**
        * <p>Converts an array of object Integers to primitives.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Integer</code> array, may be <code>null</code>
        * @return an <code>int</code> array
  @@ -1140,7 +1850,7 @@
       /**
        * <p>Converts an array of object Integer to primitives handling null.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Integer</code> array, may be <code>null</code>
        * @param valueForNull  the value to insert if <code>null</code> found
  @@ -1163,7 +1873,7 @@
       /**
        * <p>Converts an array of primitive ints to objects.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  an <code>int</code> array
        * @return an <code>Integer</code> array
  @@ -1186,7 +1896,7 @@
       /**
        * <p>Converts an array of object Longs to primitives.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Long</code> array, may be <code>null</code>
        * @return a <code>long</code> array
  @@ -1208,7 +1918,7 @@
       /**
        * <p>Converts an array of object Long to primitives handling null.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Long</code> array, may be <code>null</code>
        * @param valueForNull  the value to insert if <code>null</code> found
  @@ -1231,7 +1941,7 @@
       /**
        * <p>Converts an array of primitive longs to objects.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array a <code>long</code> array
        * @return a <code>Long</code> array
  @@ -1254,7 +1964,7 @@
       /**
        * <p>Converts an array of object Floats to primitives.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Float</code> array, may be <code>null</code>
        * @return a <code>float</code> array
  @@ -1276,7 +1986,7 @@
       /**
        * <p>Converts an array of object Floats to primitives handling null.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Float</code> array, may be <code>null</code>
        * @param valueForNull  the value to insert if <code>null</code> found
  @@ -1299,7 +2009,7 @@
       /**
        * <p>Converts an array of primitive floats to objects.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array a <code>float</code> array
        * @return a <code>Float</code> array
  @@ -1322,7 +2032,7 @@
       /**
        * <p>Converts an array of object Doubles to primitives.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Double</code> array, may be <code>null</code>
        * @return a <code>double</code> array
  @@ -1344,7 +2054,7 @@
       /**
        * <p>Converts an array of object Doubles to primitives handling null.</p>
        * 
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array  a <code>Double</code> array, may be <code>null</code>
        * @param valueForNull  the value to insert if <code>null</code> found
  @@ -1367,7 +2077,7 @@
       /**
        * <p>Converts an array of primitive doubles to objects.</p>
        *
  -     * <p>This method returns <code>null</code> if <code>null</code> input.</p>
  +     * <p>This method returns <code>null</code> if <code>null</code> array 
input.</p>
        * 
        * @param array a <code>double</code> array
        * @return a <code>Double</code> array
  
  
  
  1.9       +404 -3    
jakarta-commons/lang/src/test/org/apache/commons/lang/ArrayUtilsTest.java
  
  Index: ArrayUtilsTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/ArrayUtilsTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ArrayUtilsTest.java       28 Jun 2003 18:01:19 -0000      1.8
  +++ ArrayUtilsTest.java       12 Jul 2003 10:09:40 -0000      1.9
  @@ -659,7 +659,7 @@
           assertEquals(2, ArrayUtils.indexOf(array, "2", 2));
           assertEquals(3, ArrayUtils.indexOf(array, "3", 2));
           assertEquals(4, ArrayUtils.indexOf(array, null, 2));
  -        assertEquals(-1, ArrayUtils.indexOf(array, "notInArray"));
  +        assertEquals(-1, ArrayUtils.indexOf(array, "notInArray", 2));
           
           assertEquals(4, ArrayUtils.indexOf(array, null, -1));
           assertEquals(-1, ArrayUtils.indexOf(array, "0", 6));
  @@ -687,7 +687,7 @@
           assertEquals(-1, ArrayUtils.lastIndexOf(array, "3", 2));
           assertEquals(4, ArrayUtils.lastIndexOf(array, null, 5));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, null, 2));
  -        assertEquals(-1, ArrayUtils.lastIndexOf(array, "notInArray"));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, "notInArray", 5));
           
           assertEquals(-1, ArrayUtils.lastIndexOf(array, null, -1));
           assertEquals(5, ArrayUtils.lastIndexOf(array, "0", 88));
  @@ -703,6 +703,407 @@
           assertEquals(true, ArrayUtils.contains(array, "3"));
           assertEquals(true, ArrayUtils.contains(array, null));
           assertEquals(false, ArrayUtils.contains(array, "notInArray"));
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    public void testIndexOfLong() {
  +        long[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, 0));
  +        array = new long[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.indexOf(array, 0));
  +        assertEquals(1, ArrayUtils.indexOf(array, 1));
  +        assertEquals(2, ArrayUtils.indexOf(array, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, 3));
  +        assertEquals(-1, ArrayUtils.indexOf(array, 99));
  +    }
  +
  +    public void testIndexOfLongWithStartIndex() {
  +        long[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, 0, 2));
  +        array = new long[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.indexOf(array, 0, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, 1, 2));
  +        assertEquals(2, ArrayUtils.indexOf(array, 2, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, 3, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, 99, 0));
  +        assertEquals(-1, ArrayUtils.indexOf(array, 0, 6));
  +    }
  +
  +    public void testLastIndexOfLong() {
  +        long[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 0));
  +        array = new long[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, 0));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, 1));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, 2));
  +        assertEquals(3, ArrayUtils.lastIndexOf(array, 3));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
  +    }
  +
  +    public void testLastIndexOfLongWithStartIndex() {
  +        long[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 0, 2));
  +        array = new long[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.lastIndexOf(array, 0, 2));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, 1, 2));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, 2, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, 0, 88));
  +    }
  +
  +    public void testContainsLong() {
  +        long[] array = null;
  +        assertEquals(false, ArrayUtils.contains(array, 1));
  +        array = new long[] { 0, 1, 2, 3, 0 };
  +        assertEquals(true, ArrayUtils.contains(array, 0));
  +        assertEquals(true, ArrayUtils.contains(array, 1));
  +        assertEquals(true, ArrayUtils.contains(array, 2));
  +        assertEquals(true, ArrayUtils.contains(array, 3));
  +        assertEquals(false, ArrayUtils.contains(array, 99));
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    public void testIndexOfInt() {
  +        int[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, 0));
  +        array = new int[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.indexOf(array, 0));
  +        assertEquals(1, ArrayUtils.indexOf(array, 1));
  +        assertEquals(2, ArrayUtils.indexOf(array, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, 3));
  +        assertEquals(-1, ArrayUtils.indexOf(array, 99));
  +    }
  +
  +    public void testIndexOfIntWithStartIndex() {
  +        int[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, 0, 2));
  +        array = new int[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.indexOf(array, 0, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, 1, 2));
  +        assertEquals(2, ArrayUtils.indexOf(array, 2, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, 3, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, 99, 0));
  +        assertEquals(-1, ArrayUtils.indexOf(array, 0, 6));
  +    }
  +
  +    public void testLastIndexOfInt() {
  +        int[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 0));
  +        array = new int[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, 0));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, 1));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, 2));
  +        assertEquals(3, ArrayUtils.lastIndexOf(array, 3));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
  +    }
  +
  +    public void testLastIndexOfIntWithStartIndex() {
  +        int[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 0, 2));
  +        array = new int[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.lastIndexOf(array, 0, 2));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, 1, 2));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, 2, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, 0, 88));
  +    }
  +
  +    public void testContainsInt() {
  +        int[] array = null;
  +        assertEquals(false, ArrayUtils.contains(array, 1));
  +        array = new int[] { 0, 1, 2, 3, 0 };
  +        assertEquals(true, ArrayUtils.contains(array, 0));
  +        assertEquals(true, ArrayUtils.contains(array, 1));
  +        assertEquals(true, ArrayUtils.contains(array, 2));
  +        assertEquals(true, ArrayUtils.contains(array, 3));
  +        assertEquals(false, ArrayUtils.contains(array, 99));
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    public void testIndexOfShort() {
  +        short[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, (short) 0));
  +        array = new short[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.indexOf(array, (short) 0));
  +        assertEquals(1, ArrayUtils.indexOf(array, (short) 1));
  +        assertEquals(2, ArrayUtils.indexOf(array, (short) 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (short) 3));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (short) 99));
  +    }
  +
  +    public void testIndexOfShortWithStartIndex() {
  +        short[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, (short) 0, 2));
  +        array = new short[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.indexOf(array, (short) 0, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (short) 1, 2));
  +        assertEquals(2, ArrayUtils.indexOf(array, (short) 2, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (short) 3, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (short) 99, 0));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (short) 0, 6));
  +    }
  +
  +    public void testLastIndexOfShort() {
  +        short[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (short) 0));
  +        array = new short[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, (short) 0));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, (short) 1));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, (short) 2));
  +        assertEquals(3, ArrayUtils.lastIndexOf(array, (short) 3));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (short) 99));
  +    }
  +
  +    public void testLastIndexOfShortWithStartIndex() {
  +        short[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (short) 0, 2));
  +        array = new short[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.lastIndexOf(array, (short) 0, 2));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, (short) 1, 2));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, (short) 2, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (short) 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (short) 99));
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, (short) 0, 88));
  +    }
  +
  +    public void testContainsShort() {
  +        short[] array = null;
  +        assertEquals(false, ArrayUtils.contains(array, (short) 1));
  +        array = new short[] { 0, 1, 2, 3, 0 };
  +        assertEquals(true, ArrayUtils.contains(array, (short) 0));
  +        assertEquals(true, ArrayUtils.contains(array, (short) 1));
  +        assertEquals(true, ArrayUtils.contains(array, (short) 2));
  +        assertEquals(true, ArrayUtils.contains(array, (short) 3));
  +        assertEquals(false, ArrayUtils.contains(array, (short) 99));
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    public void testIndexOfByte() {
  +        byte[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, (byte) 0));
  +        array = new byte[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.indexOf(array, (byte) 0));
  +        assertEquals(1, ArrayUtils.indexOf(array, (byte) 1));
  +        assertEquals(2, ArrayUtils.indexOf(array, (byte) 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (byte) 3));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (byte) 99));
  +    }
  +
  +    public void testIndexOfByteWithStartIndex() {
  +        byte[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, (byte) 0, 2));
  +        array = new byte[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.indexOf(array, (byte) 0, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (byte) 1, 2));
  +        assertEquals(2, ArrayUtils.indexOf(array, (byte) 2, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (byte) 3, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (byte) 99, 0));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (byte) 0, 6));
  +    }
  +
  +    public void testLastIndexOfByte() {
  +        byte[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (byte) 0));
  +        array = new byte[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, (byte) 0));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, (byte) 1));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, (byte) 2));
  +        assertEquals(3, ArrayUtils.lastIndexOf(array, (byte) 3));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (byte) 99));
  +    }
  +
  +    public void testLastIndexOfByteWithStartIndex() {
  +        byte[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (byte) 0, 2));
  +        array = new byte[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.lastIndexOf(array, (byte) 0, 2));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, (byte) 1, 2));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, (byte) 2, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (byte) 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (byte) 99));
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, (byte) 0, 88));
  +    }
  +
  +    public void testContainsByte() {
  +        byte[] array = null;
  +        assertEquals(false, ArrayUtils.contains(array, (byte) 1));
  +        array = new byte[] { 0, 1, 2, 3, 0 };
  +        assertEquals(true, ArrayUtils.contains(array, (byte) 0));
  +        assertEquals(true, ArrayUtils.contains(array, (byte) 1));
  +        assertEquals(true, ArrayUtils.contains(array, (byte) 2));
  +        assertEquals(true, ArrayUtils.contains(array, (byte) 3));
  +        assertEquals(false, ArrayUtils.contains(array, (byte) 99));
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    public void testIndexOfDouble() {
  +        double[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, (double) 0));
  +        array = new double[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.indexOf(array, (double) 0));
  +        assertEquals(1, ArrayUtils.indexOf(array, (double) 1));
  +        assertEquals(2, ArrayUtils.indexOf(array, (double) 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (double) 3));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (double) 99));
  +    }
  +
  +    public void testIndexOfDoubleWithStartIndex() {
  +        double[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 2));
  +        array = new double[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.indexOf(array, (double) 0, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (double) 1, 2));
  +        assertEquals(2, ArrayUtils.indexOf(array, (double) 2, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (double) 3, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (double) 99, 0));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 6));
  +    }
  +
  +    public void testLastIndexOfDouble() {
  +        double[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 0));
  +        array = new double[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, (double) 0));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, (double) 1));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, (double) 2));
  +        assertEquals(3, ArrayUtils.lastIndexOf(array, (double) 3));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 99));
  +    }
  +
  +    public void testLastIndexOfDoubleWithStartIndex() {
  +        double[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 0, 2));
  +        array = new double[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.lastIndexOf(array, (double) 0, 2));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, (double) 1, 2));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, (double) 2, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 99));
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, (double) 0, 88));
  +    }
  +
  +    public void testContainsDouble() {
  +        double[] array = null;
  +        assertEquals(false, ArrayUtils.contains(array, (double) 1));
  +        array = new double[] { 0, 1, 2, 3, 0 };
  +        assertEquals(true, ArrayUtils.contains(array, (double) 0));
  +        assertEquals(true, ArrayUtils.contains(array, (double) 1));
  +        assertEquals(true, ArrayUtils.contains(array, (double) 2));
  +        assertEquals(true, ArrayUtils.contains(array, (double) 3));
  +        assertEquals(false, ArrayUtils.contains(array, (double) 99));
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    public void testIndexOfFloat() {
  +        float[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, (float) 0));
  +        array = new float[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.indexOf(array, (float) 0));
  +        assertEquals(1, ArrayUtils.indexOf(array, (float) 1));
  +        assertEquals(2, ArrayUtils.indexOf(array, (float) 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (float) 3));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (float) 99));
  +    }
  +
  +    public void testIndexOfFloatWithStartIndex() {
  +        float[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, (float) 0, 2));
  +        array = new float[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.indexOf(array, (float) 0, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (float) 1, 2));
  +        assertEquals(2, ArrayUtils.indexOf(array, (float) 2, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (float) 3, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (float) 99, 0));
  +        assertEquals(-1, ArrayUtils.indexOf(array, (float) 0, 6));
  +    }
  +
  +    public void testLastIndexOfFloat() {
  +        float[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 0));
  +        array = new float[] { 0, 1, 2, 3, 0 };
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, (float) 0));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, (float) 1));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, (float) 2));
  +        assertEquals(3, ArrayUtils.lastIndexOf(array, (float) 3));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 99));
  +    }
  +
  +    public void testLastIndexOfFloatWithStartIndex() {
  +        float[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 0, 2));
  +        array = new float[] { 0, 1, 2, 3, 0 };
  +        assertEquals(0, ArrayUtils.lastIndexOf(array, (float) 0, 2));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, (float) 1, 2));
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, (float) 2, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 99));
  +        assertEquals(4, ArrayUtils.lastIndexOf(array, (float) 0, 88));
  +    }
  +
  +    public void testContainsFloat() {
  +        float[] array = null;
  +        assertEquals(false, ArrayUtils.contains(array, (float) 1));
  +        array = new float[] { 0, 1, 2, 3, 0 };
  +        assertEquals(true, ArrayUtils.contains(array, (float) 0));
  +        assertEquals(true, ArrayUtils.contains(array, (float) 1));
  +        assertEquals(true, ArrayUtils.contains(array, (float) 2));
  +        assertEquals(true, ArrayUtils.contains(array, (float) 3));
  +        assertEquals(false, ArrayUtils.contains(array, (float) 99));
  +    }
  +    
  +    //-----------------------------------------------------------------------
  +    public void testIndexOfBoolean() {
  +        boolean[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, true));
  +        array = new boolean[] { true, false, true };
  +        assertEquals(0, ArrayUtils.indexOf(array, true));
  +        assertEquals(1, ArrayUtils.indexOf(array, false));
  +        array = new boolean[] { true, true };
  +        assertEquals(-1, ArrayUtils.indexOf(array, false));
  +    }
  +
  +    public void testIndexOfBooleanWithStartIndex() {
  +        boolean[] array = null;
  +        assertEquals(-1, ArrayUtils.indexOf(array, true, 2));
  +        array = new boolean[] { true, false, true };
  +        assertEquals(2, ArrayUtils.indexOf(array, true, 1));
  +        assertEquals(-1, ArrayUtils.indexOf(array, false, 2));
  +        array = new boolean[] { true, true };
  +        assertEquals(-1, ArrayUtils.indexOf(array, false, 0));
  +    }
  +
  +    public void testLastIndexOfBoolean() {
  +        boolean[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, true));
  +        array = new boolean[] { true, false, true };
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, true));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, false));
  +        array = new boolean[] { true, true };
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, false));
  +    }
  +
  +    public void testLastIndexOfBooleanWithStartIndex() {
  +        boolean[] array = null;
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, true, 2));
  +        array = new boolean[] { true, false, true };
  +        assertEquals(2, ArrayUtils.lastIndexOf(array, true, 2));
  +        assertEquals(0, ArrayUtils.lastIndexOf(array, true, 1));
  +        assertEquals(1, ArrayUtils.lastIndexOf(array, false, 2));
  +        array = new boolean[] { true, true };
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, false, 2));
  +    }
  +
  +    public void testContainsBoolean() {
  +        boolean[] array = null;
  +        assertEquals(false, ArrayUtils.contains(array, true));
  +        array = new boolean[] { true, false, true };
  +        assertEquals(true, ArrayUtils.contains(array, true));
  +        assertEquals(true, ArrayUtils.contains(array, false));
  +        array = new boolean[] { true, true };
  +        assertEquals(true, ArrayUtils.contains(array, true));
  +        assertEquals(false, ArrayUtils.contains(array, false));
       }
       
       // testToPrimitive/Object for boolean
  
  
  

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

Reply via email to