diff --git a/src/java/org/apache/commons/lang/ArrayUtils.java b/src/java/org/apache/commons/lang/ArrayUtils.java index ef968ed11..c7305d1ab 100644 --- a/src/java/org/apache/commons/lang/ArrayUtils.java +++ b/src/java/org/apache/commons/lang/ArrayUtils.java @@ -44,7 +44,7 @@ import org.apache.commons.lang.builder.ToStringStyle; * @author Ashwin S * @author Maarten Coene * @since 2.0 - * @version $Id: ArrayUtils.java,v 1.45 2004/07/27 21:10:33 ggregory Exp $ + * @version $Id: ArrayUtils.java,v 1.46 2004/08/15 02:12:51 bayard Exp $ */ public class ArrayUtils { @@ -148,7 +148,7 @@ public class ArrayUtils { * @param array the array to get a toString for, may be null * @return a String representation of the array, '{}' if null array input */ - public static String toString(final Object array) { + public static String toString(Object array) { return toString(array, "{}"); } @@ -164,7 +164,7 @@ public class ArrayUtils { * @param stringIfNull the String to return if the array is null * @return a String representation of the array */ - public static String toString(final Object array, final String stringIfNull) { + public static String toString(Object array, String stringIfNull) { if (array == null) { return stringIfNull; } @@ -179,7 +179,7 @@ public class ArrayUtils { * @param array the array to get a hashCode for, may be null * @return a hashCode for the array, zero if null array input */ - public static int hashCode(final Object array) { + public static int hashCode(Object array) { return new HashCodeBuilder().append(array).toHashCode(); } @@ -193,7 +193,7 @@ public class ArrayUtils { * @param array2 the right hand array to compare, may be null * @return true if the arrays are equal */ - public static boolean isEquals(final Object array1, final Object array2) { + public static boolean isEquals(Object array1, Object array2) { return new EqualsBuilder().append(array1, array2).isEquals(); } @@ -224,7 +224,7 @@ public class ArrayUtils { * @throws IllegalArgumentException if the array contains elements other * than {@link java.util.Map.Entry} and an Array */ - public static Map toMap(final Object[] array) { + public static Map toMap(Object[] array) { if (array == null) { return null; } @@ -265,7 +265,7 @@ public class ArrayUtils { * @param array the array to shallow clone, may be null * @return the cloned array, null if null input */ - public static Object[] clone(final Object[] array) { + public static Object[] clone(Object[] array) { if (array == null) { return null; } @@ -281,7 +281,7 @@ public class ArrayUtils { * @param array the array to clone, may be null * @return the cloned array, null if null input */ - public static long[] clone(final long[] array) { + public static long[] clone(long[] array) { if (array == null) { return null; } @@ -313,7 +313,7 @@ public class ArrayUtils { * @param array the array to clone, may be null * @return the cloned array, null if null input */ - public static short[] clone(final short[] array) { + public static short[] clone(short[] array) { if (array == null) { return null; } @@ -329,7 +329,7 @@ public class ArrayUtils { * @param array the array to clone, may be null * @return the cloned array, null if null input */ - public static char[] clone(final char[] array) { + public static char[] clone(char[] array) { if (array == null) { return null; } @@ -345,7 +345,7 @@ public class ArrayUtils { * @param array the array to clone, may be null * @return the cloned array, null if null input */ - public static byte[] clone(final byte[] array) { + public static byte[] clone(byte[] array) { if (array == null) { return null; } @@ -361,7 +361,7 @@ public class ArrayUtils { * @param array the array to clone, may be null * @return the cloned array, null if null input */ - public static double[] clone(final double[] array) { + public static double[] clone(double[] array) { if (array == null) { return null; } @@ -377,7 +377,7 @@ public class ArrayUtils { * @param array the array to clone, may be null * @return the cloned array, null if null input */ - public static float[] clone(final float[] array) { + public static float[] clone(float[] array) { if (array == null) { return null; } @@ -393,7 +393,7 @@ public class ArrayUtils { * @param array the array to clone, may be null * @return the cloned array, null if null input */ - public static boolean[] clone(final boolean[] array) { + public static boolean[] clone(boolean[] array) { if (array == null) { return null; } @@ -765,7 +765,7 @@ public class ArrayUtils { * @return true if length of arrays matches, treating * null as an empty array */ - public static boolean isSameLength(final Object[] array1, final Object[] array2) { + public static boolean isSameLength(Object[] array1, Object[] array2) { if ((array1 == null && array2 != null && array2.length > 0) || (array2 == null && array1 != null && array1.length > 0) || (array1 != null && array2 != null && array1.length != array2.length)) { @@ -783,7 +783,7 @@ public class ArrayUtils { * @return true if length of arrays matches, treating * null as an empty array */ - public static boolean isSameLength(final long[] array1, final long[] array2) { + public static boolean isSameLength(long[] array1, long[] array2) { if ((array1 == null && array2 != null && array2.length > 0) || (array2 == null && array1 != null && array1.length > 0) || (array1 != null && array2 != null && array1.length != array2.length)) { @@ -801,7 +801,7 @@ public class ArrayUtils { * @return true if length of arrays matches, treating * null as an empty array */ - public static boolean isSameLength(final int[] array1, final int[] array2) { + public static boolean isSameLength(int[] array1, int[] array2) { if ((array1 == null && array2 != null && array2.length > 0) || (array2 == null && array1 != null && array1.length > 0) || (array1 != null && array2 != null && array1.length != array2.length)) { @@ -819,7 +819,7 @@ public class ArrayUtils { * @return true if length of arrays matches, treating * null as an empty array */ - public static boolean isSameLength(final short[] array1, final short[] array2) { + public static boolean isSameLength(short[] array1, short[] array2) { if ((array1 == null && array2 != null && array2.length > 0) || (array2 == null && array1 != null && array1.length > 0) || (array1 != null && array2 != null && array1.length != array2.length)) { @@ -837,7 +837,7 @@ public class ArrayUtils { * @return true if length of arrays matches, treating * null as an empty array */ - public static boolean isSameLength(final char[] array1, final char[] array2) { + public static boolean isSameLength(char[] array1, char[] array2) { if ((array1 == null && array2 != null && array2.length > 0) || (array2 == null && array1 != null && array1.length > 0) || (array1 != null && array2 != null && array1.length != array2.length)) { @@ -855,7 +855,7 @@ public class ArrayUtils { * @return true if length of arrays matches, treating * null as an empty array */ - public static boolean isSameLength(final byte[] array1, final byte[] array2) { + public static boolean isSameLength(byte[] array1, byte[] array2) { if ((array1 == null && array2 != null && array2.length > 0) || (array2 == null && array1 != null && array1.length > 0) || (array1 != null && array2 != null && array1.length != array2.length)) { @@ -873,7 +873,7 @@ public class ArrayUtils { * @return true if length of arrays matches, treating * null as an empty array */ - public static boolean isSameLength(final double[] array1, final double[] array2) { + public static boolean isSameLength(double[] array1, double[] array2) { if ((array1 == null && array2 != null && array2.length > 0) || (array2 == null && array1 != null && array1.length > 0) || (array1 != null && array2 != null && array1.length != array2.length)) { @@ -891,7 +891,7 @@ public class ArrayUtils { * @return true if length of arrays matches, treating * null as an empty array */ - public static boolean isSameLength(final float[] array1, final float[] array2) { + public static boolean isSameLength(float[] array1, float[] array2) { if ((array1 == null && array2 != null && array2.length > 0) || (array2 == null && array1 != null && array1.length > 0) || (array1 != null && array2 != null && array1.length != array2.length)) { @@ -909,7 +909,7 @@ public class ArrayUtils { * @return true if length of arrays matches, treating * null as an empty array */ - public static boolean isSameLength(final boolean[] array1, final boolean[] array2) { + public static boolean isSameLength(boolean[] array1, boolean[] array2) { if ((array1 == null && array2 != null && array2.length > 0) || (array2 == null && array1 != null && array1.length > 0) || (array1 != null && array2 != null && array1.length != array2.length)) { @@ -938,7 +938,7 @@ public class ArrayUtils { * @return The length of the array, or 0 if the array is null * @throws IllegalArgumentException if the object arguement is not an array. */ - public static int getLength(final Object array) { + public static int getLength(Object array) { if (array == null) { return 0; } else { @@ -964,7 +964,7 @@ public class ArrayUtils { * @return the last index, -1 if empty or null * @throws IllegalArgumentException if the object arguement is not an array. */ - public static int lastIndex(final Object array) { + public static int lastIndex(Object array) { return ArrayUtils.getLength(array) - 1; } @@ -977,7 +977,7 @@ public class ArrayUtils { * @return true if type of arrays matches * @throws IllegalArgumentException if either array is null */ - public static boolean isSameType(final Object array1, final Object array2) { + public static boolean isSameType(Object array1, Object array2) { if (array1 == null || array2 == null) { throw new IllegalArgumentException("The Array must not be null"); } @@ -995,7 +995,7 @@ public class ArrayUtils { * * @param array the array to reverse, may be null */ - public static void reverse(final Object[] array) { + public static void reverse(Object[] array) { if (array == null) { return; } @@ -1018,7 +1018,7 @@ public class ArrayUtils { * * @param array the array to reverse, may be null */ - public static void reverse(final long[] array) { + public static void reverse(long[] array) { if (array == null) { return; } @@ -1041,7 +1041,7 @@ public class ArrayUtils { * * @param array the array to reverse, may be null */ - public static void reverse(final int[] array) { + public static void reverse(int[] array) { if (array == null) { return; } @@ -1064,7 +1064,7 @@ public class ArrayUtils { * * @param array the array to reverse, may be null */ - public static void reverse(final short[] array) { + public static void reverse(short[] array) { if (array == null) { return; } @@ -1087,7 +1087,7 @@ public class ArrayUtils { * * @param array the array to reverse, may be null */ - public static void reverse(final char[] array) { + public static void reverse(char[] array) { if (array == null) { return; } @@ -1110,7 +1110,7 @@ public class ArrayUtils { * * @param array the array to reverse, may be null */ - public static void reverse(final byte[] array) { + public static void reverse(byte[] array) { if (array == null) { return; } @@ -1133,7 +1133,7 @@ public class ArrayUtils { * * @param array the array to reverse, may be null */ - public static void reverse(final double[] array) { + public static void reverse(double[] array) { if (array == null) { return; } @@ -1156,7 +1156,7 @@ public class ArrayUtils { * * @param array the array to reverse, may be null */ - public static void reverse(final float[] array) { + public static void reverse(float[] array) { if (array == null) { return; } @@ -1179,7 +1179,7 @@ public class ArrayUtils { * * @param array the array to reverse, may be null */ - public static void reverse(final boolean[] array) { + public static void reverse(boolean[] array) { if (array == null) { return; } @@ -1210,7 +1210,7 @@ public class ArrayUtils { * @return the index of the object within the array, * -1 if not found or null array input */ - public static int indexOf(final Object[] array, final Object objectToFind) { + public static int indexOf(Object[] array, Object objectToFind) { return indexOf(array, objectToFind, 0); } @@ -1228,7 +1228,7 @@ public class ArrayUtils { * @return the index of the object within the array starting at the index, * -1 if not found or null array input */ - public static int indexOf(final Object[] array, final Object objectToFind, int startIndex) { + public static int indexOf(Object[] array, Object objectToFind, int startIndex) { if (array == null) { return -1; } @@ -1261,7 +1261,7 @@ public class ArrayUtils { * @return the last index of the object within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final Object[] array, final Object objectToFind) { + public static int lastIndexOf(Object[] array, Object objectToFind) { return lastIndexOf(array, objectToFind, Integer.MAX_VALUE); } @@ -1279,7 +1279,7 @@ public class ArrayUtils { * @return the last index of the object within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final Object[] array, final Object objectToFind, int startIndex) { + public static int lastIndexOf(Object[] array, Object objectToFind, int startIndex) { if (array == null) { return -1; } @@ -1313,7 +1313,7 @@ public class ArrayUtils { * @param objectToFind the object to find * @return true if the array contains the object */ - public static boolean contains(final Object[] array, final Object objectToFind) { + public static boolean contains(Object[] array, Object objectToFind) { return (indexOf(array, objectToFind) != -1); } @@ -1329,7 +1329,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final long[] array, final long valueToFind) { + public static int indexOf(long[] array, long valueToFind) { return indexOf(array, valueToFind, 0); } @@ -1347,7 +1347,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final long[] array, final long valueToFind, int startIndex) { + public static int indexOf(long[] array, long valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1372,7 +1372,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final long[] array, final long valueToFind) { + public static int lastIndexOf(long[] array, long valueToFind) { return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); } @@ -1390,7 +1390,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final long[] array, final long valueToFind, int startIndex) { + public static int lastIndexOf(long[] array, long valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1416,7 +1416,7 @@ public class ArrayUtils { * @param valueToFind the value to find * @return true if the array contains the object */ - public static boolean contains(final long[] array, final long valueToFind) { + public static boolean contains(long[] array, long valueToFind) { return (indexOf(array, valueToFind) != -1); } @@ -1432,7 +1432,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final int[] array, final int valueToFind) { + public static int indexOf(int[] array, int valueToFind) { return indexOf(array, valueToFind, 0); } @@ -1450,7 +1450,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final int[] array, final int valueToFind, int startIndex) { + public static int indexOf(int[] array, int valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1475,7 +1475,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final int[] array, final int valueToFind) { + public static int lastIndexOf(int[] array, int valueToFind) { return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); } @@ -1493,7 +1493,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final int[] array, final int valueToFind, int startIndex) { + public static int lastIndexOf(int[] array, int valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1519,7 +1519,7 @@ public class ArrayUtils { * @param valueToFind the value to find * @return true if the array contains the object */ - public static boolean contains(final int[] array, final int valueToFind) { + public static boolean contains(int[] array, int valueToFind) { return (indexOf(array, valueToFind) != -1); } @@ -1535,7 +1535,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final short[] array, final short valueToFind) { + public static int indexOf(short[] array, short valueToFind) { return indexOf(array, valueToFind, 0); } @@ -1553,7 +1553,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final short[] array, final short valueToFind, int startIndex) { + public static int indexOf(short[] array, short valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1578,7 +1578,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final short[] array, final short valueToFind) { + public static int lastIndexOf(short[] array, short valueToFind) { return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); } @@ -1596,7 +1596,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final short[] array, final short valueToFind, int startIndex) { + public static int lastIndexOf(short[] array, short valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1622,7 +1622,7 @@ public class ArrayUtils { * @param valueToFind the value to find * @return true if the array contains the object */ - public static boolean contains(final short[] array, final short valueToFind) { + public static boolean contains(short[] array, short valueToFind) { return (indexOf(array, valueToFind) != -1); } @@ -1638,7 +1638,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final char[] array, final char valueToFind) { + public static int indexOf(char[] array, char valueToFind) { return indexOf(array, valueToFind, 0); } @@ -1656,7 +1656,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final char[] array, final char valueToFind, int startIndex) { + public static int indexOf(char[] array, char valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1681,7 +1681,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final char[] array, final char valueToFind) { + public static int lastIndexOf(char[] array, char valueToFind) { return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); } @@ -1699,7 +1699,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final char[] array, final char valueToFind, int startIndex) { + public static int lastIndexOf(char[] array, char valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1725,7 +1725,7 @@ public class ArrayUtils { * @param valueToFind the value to find * @return true if the array contains the object */ - public static boolean contains(final char[] array, final char valueToFind) { + public static boolean contains(char[] array, char valueToFind) { return (indexOf(array, valueToFind) != -1); } @@ -1741,7 +1741,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final byte[] array, final byte valueToFind) { + public static int indexOf(byte[] array, byte valueToFind) { return indexOf(array, valueToFind, 0); } @@ -1759,7 +1759,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final byte[] array, final byte valueToFind, int startIndex) { + public static int indexOf(byte[] array, byte valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1784,7 +1784,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final byte[] array, final byte valueToFind) { + public static int lastIndexOf(byte[] array, byte valueToFind) { return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); } @@ -1802,7 +1802,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final byte[] array, final byte valueToFind, int startIndex) { + public static int lastIndexOf(byte[] array, byte valueToFind, int startIndex) { if (array == null) { return -1; } @@ -1828,7 +1828,7 @@ public class ArrayUtils { * @param valueToFind the value to find * @return true if the array contains the object */ - public static boolean contains(final byte[] array, final byte valueToFind) { + public static boolean contains(byte[] array, byte valueToFind) { return (indexOf(array, valueToFind) != -1); } @@ -1844,7 +1844,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final double[] array, final double valueToFind) { + public static int indexOf(double[] array, double valueToFind) { return indexOf(array, valueToFind, 0); } @@ -1861,7 +1861,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final double[] array, final double valueToFind, final double tolerance) { + public static int indexOf(double[] array, double valueToFind, double tolerance) { return indexOf(array, valueToFind, 0, tolerance); } @@ -1879,7 +1879,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final double[] array, final double valueToFind, int startIndex) { + public static int indexOf(double[] array, double valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return -1; } @@ -1911,7 +1911,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final double[] array, final double valueToFind, int startIndex, double tolerance) { + public static int indexOf(double[] array, double valueToFind, int startIndex, double tolerance) { if (ArrayUtils.isEmpty(array)) { return -1; } @@ -1938,7 +1938,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final double[] array, final double valueToFind) { + public static int lastIndexOf(double[] array, double valueToFind) { return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); } @@ -1955,7 +1955,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final double[] array, final double valueToFind, final double tolerance) { + public static int lastIndexOf(double[] array, double valueToFind, double tolerance) { return lastIndexOf(array, valueToFind, Integer.MAX_VALUE, tolerance); } @@ -1973,7 +1973,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final double[] array, final double valueToFind, int startIndex) { + public static int lastIndexOf(double[] array, double valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return -1; } @@ -2007,7 +2007,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final double[] array, final double valueToFind, int startIndex, double tolerance) { + public static int lastIndexOf(double[] array, double valueToFind, int startIndex, double tolerance) { if (ArrayUtils.isEmpty(array)) { return -1; } @@ -2035,7 +2035,7 @@ public class ArrayUtils { * @param valueToFind the value to find * @return true if the array contains the object */ - public static boolean contains(final double[] array, final double valueToFind) { + public static boolean contains(double[] array, double valueToFind) { return (indexOf(array, valueToFind) != -1); } @@ -2052,7 +2052,7 @@ public class ArrayUtils { * @param tolerance the array contains the tolerance of the search * @return true if value falling within tolerance is in array */ - public static boolean contains(final double[] array, final double valueToFind, final double tolerance) { + public static boolean contains(double[] array, double valueToFind, double tolerance) { return (indexOf(array, valueToFind, 0, tolerance) != -1); } @@ -2068,7 +2068,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final float[] array, final float valueToFind) { + public static int indexOf(float[] array, float valueToFind) { return indexOf(array, valueToFind, 0); } @@ -2086,7 +2086,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final float[] array, final float valueToFind, int startIndex) { + public static int indexOf(float[] array, float valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return -1; } @@ -2111,7 +2111,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final float[] array, final float valueToFind) { + public static int lastIndexOf(float[] array, float valueToFind) { return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); } @@ -2129,7 +2129,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final float[] array, final float valueToFind, int startIndex) { + public static int lastIndexOf(float[] array, float valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return -1; } @@ -2155,7 +2155,7 @@ public class ArrayUtils { * @param valueToFind the value to find * @return true if the array contains the object */ - public static boolean contains(final float[] array, final float valueToFind) { + public static boolean contains(float[] array, float valueToFind) { return (indexOf(array, valueToFind) != -1); } @@ -2171,7 +2171,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final boolean[] array, final boolean valueToFind) { + public static int indexOf(boolean[] array, boolean valueToFind) { return indexOf(array, valueToFind, 0); } @@ -2189,7 +2189,7 @@ public class ArrayUtils { * @return the index of the value within the array, * -1 if not found or null array input */ - public static int indexOf(final boolean[] array, final boolean valueToFind, int startIndex) { + public static int indexOf(boolean[] array, boolean valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return -1; } @@ -2214,7 +2214,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final boolean[] array, final boolean valueToFind) { + public static int lastIndexOf(boolean[] array, boolean valueToFind) { return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); } @@ -2232,7 +2232,7 @@ public class ArrayUtils { * @return the last index of the value within the array, * -1 if not found or null array input */ - public static int lastIndexOf(final boolean[] array, final boolean valueToFind, int startIndex) { + public static int lastIndexOf(boolean[] array, boolean valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return -1; } @@ -2258,7 +2258,7 @@ public class ArrayUtils { * @param valueToFind the value to find * @return true if the array contains the object */ - public static boolean contains(final boolean[] array, final boolean valueToFind) { + public static boolean contains(boolean[] array, boolean valueToFind) { return (indexOf(array, valueToFind) != -1); } @@ -2276,7 +2276,7 @@ public class ArrayUtils { * @return a long array, null if null array input * @throws NullPointerException if array content is null */ - public static long[] toPrimitive(final Long[] array) { + public static long[] toPrimitive(Long[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2298,7 +2298,7 @@ public class ArrayUtils { * @param valueForNull the value to insert if null found * @return a long array, null if null array input */ - public static long[] toPrimitive(final Long[] array, final long valueForNull) { + public static long[] toPrimitive(Long[] array, long valueForNull) { if (array == null) { return null; } else if (array.length == 0) { @@ -2320,7 +2320,7 @@ public class ArrayUtils { * @param array a long array * @return a Long array, null if null array input */ - public static Long[] toObject(final long[] array) { + public static Long[] toObject(long[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2344,7 +2344,7 @@ public class ArrayUtils { * @return an int array, null if null array input * @throws NullPointerException if array content is null */ - public static int[] toPrimitive(final Integer[] array) { + public static int[] toPrimitive(Integer[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2366,7 +2366,7 @@ public class ArrayUtils { * @param valueForNull the value to insert if null found * @return an int array, null if null array input */ - public static int[] toPrimitive(final Integer[] array, final int valueForNull) { + public static int[] toPrimitive(Integer[] array, int valueForNull) { if (array == null) { return null; } else if (array.length == 0) { @@ -2388,7 +2388,7 @@ public class ArrayUtils { * @param array an int array * @return an Integer array, null if null array input */ - public static Integer[] toObject(final int[] array) { + public static Integer[] toObject(int[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2412,7 +2412,7 @@ public class ArrayUtils { * @return a byte array, null if null array input * @throws NullPointerException if array content is null */ - public static short[] toPrimitive(final Short[] array) { + public static short[] toPrimitive(Short[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2434,7 +2434,7 @@ public class ArrayUtils { * @param valueForNull the value to insert if null found * @return a byte array, null if null array input */ - public static short[] toPrimitive(final Short[] array, final short valueForNull) { + public static short[] toPrimitive(Short[] array, short valueForNull) { if (array == null) { return null; } else if (array.length == 0) { @@ -2456,7 +2456,7 @@ public class ArrayUtils { * @param array a short array * @return a Short array, null if null array input */ - public static Short[] toObject(final short[] array) { + public static Short[] toObject(short[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2480,7 +2480,7 @@ public class ArrayUtils { * @return a byte array, null if null array input * @throws NullPointerException if array content is null */ - public static byte[] toPrimitive(final Byte[] array) { + public static byte[] toPrimitive(Byte[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2502,7 +2502,7 @@ public class ArrayUtils { * @param valueForNull the value to insert if null found * @return a byte array, null if null array input */ - public static byte[] toPrimitive(final Byte[] array, final byte valueForNull) { + public static byte[] toPrimitive(Byte[] array, byte valueForNull) { if (array == null) { return null; } else if (array.length == 0) { @@ -2524,7 +2524,7 @@ public class ArrayUtils { * @param array a byte array * @return a Byte array, null if null array input */ - public static Byte[] toObject(final byte[] array) { + public static Byte[] toObject(byte[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2548,7 +2548,7 @@ public class ArrayUtils { * @return a double array, null if null array input * @throws NullPointerException if array content is null */ - public static double[] toPrimitive(final Double[] array) { + public static double[] toPrimitive(Double[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2570,7 +2570,7 @@ public class ArrayUtils { * @param valueForNull the value to insert if null found * @return a double array, null if null array input */ - public static double[] toPrimitive(final Double[] array, final double valueForNull) { + public static double[] toPrimitive(Double[] array, double valueForNull) { if (array == null) { return null; } else if (array.length == 0) { @@ -2592,7 +2592,7 @@ public class ArrayUtils { * @param array a double array * @return a Double array, null if null array input */ - public static Double[] toObject(final double[] array) { + public static Double[] toObject(double[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2616,7 +2616,7 @@ public class ArrayUtils { * @return a float array, null if null array input * @throws NullPointerException if array content is null */ - public static float[] toPrimitive(final Float[] array) { + public static float[] toPrimitive(Float[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2638,7 +2638,7 @@ public class ArrayUtils { * @param valueForNull the value to insert if null found * @return a float array, null if null array input */ - public static float[] toPrimitive(final Float[] array, final float valueForNull) { + public static float[] toPrimitive(Float[] array, float valueForNull) { if (array == null) { return null; } else if (array.length == 0) { @@ -2660,7 +2660,7 @@ public class ArrayUtils { * @param array a float array * @return a Float array, null if null array input */ - public static Float[] toObject(final float[] array) { + public static Float[] toObject(float[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2684,7 +2684,7 @@ public class ArrayUtils { * @return a boolean array, null if null array input * @throws NullPointerException if array content is null */ - public static boolean[] toPrimitive(final Boolean[] array) { + public static boolean[] toPrimitive(Boolean[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2706,7 +2706,7 @@ public class ArrayUtils { * @param valueForNull the value to insert if null found * @return a boolean array, null if null array input */ - public static boolean[] toPrimitive(final Boolean[] array, final boolean valueForNull) { + public static boolean[] toPrimitive(Boolean[] array, boolean valueForNull) { if (array == null) { return null; } else if (array.length == 0) { @@ -2728,7 +2728,7 @@ public class ArrayUtils { * @param array a boolean array * @return a Boolean array, null if null array input */ - public static Boolean[] toObject(final boolean[] array) { + public static Boolean[] toObject(boolean[] array) { if (array == null) { return null; } else if (array.length == 0) { @@ -2749,7 +2749,7 @@ public class ArrayUtils { * @return true if the array is empty or null * @since 2.1 */ - public static boolean isEmpty(final Object[] array) { + public static boolean isEmpty(Object[] array) { if (array == null || array.length == 0) { return true; } @@ -2763,7 +2763,7 @@ public class ArrayUtils { * @return true if the array is empty or null * @since 2.1 */ - public static boolean isEmpty(final long[] array) { + public static boolean isEmpty(long[] array) { if (array == null || array.length == 0) { return true; } @@ -2777,7 +2777,7 @@ public class ArrayUtils { * @return true if the array is empty or null * @since 2.1 */ - public static boolean isEmpty(final int[] array) { + public static boolean isEmpty(int[] array) { if (array == null || array.length == 0) { return true; } @@ -2791,7 +2791,7 @@ public class ArrayUtils { * @return true if the array is empty or null * @since 2.1 */ - public static boolean isEmpty(final short[] array) { + public static boolean isEmpty(short[] array) { if (array == null || array.length == 0) { return true; } @@ -2805,7 +2805,7 @@ public class ArrayUtils { * @return true if the array is empty or null * @since 2.1 */ - public static boolean isEmpty(final char[] array) { + public static boolean isEmpty(char[] array) { if (array == null || array.length == 0) { return true; } @@ -2819,7 +2819,7 @@ public class ArrayUtils { * @return true if the array is empty or null * @since 2.1 */ - public static boolean isEmpty(final byte[] array) { + public static boolean isEmpty(byte[] array) { if (array == null || array.length == 0) { return true; } @@ -2833,7 +2833,7 @@ public class ArrayUtils { * @return true if the array is empty or null * @since 2.1 */ - public static boolean isEmpty(final double[] array) { + public static boolean isEmpty(double[] array) { if (array == null || array.length == 0) { return true; } @@ -2847,7 +2847,7 @@ public class ArrayUtils { * @return true if the array is empty or null * @since 2.1 */ - public static boolean isEmpty(final float[] array) { + public static boolean isEmpty(float[] array) { if (array == null || array.length == 0) { return true; } @@ -2861,7 +2861,7 @@ public class ArrayUtils { * @return true if the array is empty or null * @since 2.1 */ - public static boolean isEmpty(final boolean[] array) { + public static boolean isEmpty(boolean[] array) { if (array == null || array.length == 0) { return true; } @@ -2926,7 +2926,7 @@ public class ArrayUtils { * @return A new array containing the existing elements plus the new element * @since 2.1 */ - public static Object[] add(final Object[] array, final Object element) { + public static Object[] add(Object[] array, Object element) { Object newArray = copyArrayGrow1(array, element != null ? element.getClass() : Object.class); Array.set(newArray, lastIndex(newArray), element); return (Object[]) newArray; @@ -2953,7 +2953,7 @@ public class ArrayUtils { * @return A new array containing the existing elements plus the new element * @since 2.1 */ - public static boolean[] add(final boolean[] array, final boolean element) { + public static boolean[] add(boolean[] array, boolean element) { boolean[] newArray = (boolean[])copyArrayGrow1(array, Boolean.TYPE); newArray[lastIndex(newArray)] = element; return newArray; @@ -2980,7 +2980,7 @@ public class ArrayUtils { * @return A new array containing the existing elements plus the new element * @since 2.1 */ - public static byte[] add(final byte[] array, final byte element) { + public static byte[] add(byte[] array, byte element) { byte[] newArray = (byte[])copyArrayGrow1(array, Byte.TYPE); newArray[lastIndex(newArray)] = element; return newArray; @@ -3007,7 +3007,7 @@ public class ArrayUtils { * @return A new array containing the existing elements plus the new element * @since 2.1 */ - public static char[] add(final char[] array, final char element) { + public static char[] add(char[] array, char element) { char[] newArray = (char[])copyArrayGrow1(array, Character.TYPE); newArray[lastIndex(newArray)] = element; return newArray; @@ -3034,7 +3034,7 @@ public class ArrayUtils { * @return A new array containing the existing elements plus the new element * @since 2.1 */ - public static double[] add(final double[] array, final double element) { + public static double[] add(double[] array, double element) { double[] newArray = (double[])copyArrayGrow1(array, Double.TYPE); newArray[lastIndex(newArray)] = element; return newArray; @@ -3061,7 +3061,7 @@ public class ArrayUtils { * @return A new array containing the existing elements plus the new element * @since 2.1 */ - public static float[] add(final float[] array, final float element) { + public static float[] add(float[] array, float element) { float[] newArray = (float[])copyArrayGrow1(array, Float.TYPE); newArray[lastIndex(newArray)] = element; return newArray; @@ -3088,7 +3088,7 @@ public class ArrayUtils { * @return A new array containing the existing elements plus the new element * @since 2.1 */ - public static int[] add(final int[] array, final int element) { + public static int[] add(int[] array, int element) { int[] newArray = (int[])copyArrayGrow1(array, Integer.TYPE); newArray[lastIndex(newArray)] = element; return newArray; @@ -3115,7 +3115,7 @@ public class ArrayUtils { * @return A new array containing the existing elements plus the new element * @since 2.1 */ - public static long[] add(final long[] array, final long element) { + public static long[] add(long[] array, long element) { long[] newArray = (long[])copyArrayGrow1(array, Long.TYPE); newArray[lastIndex(newArray)] = element; return newArray; @@ -3142,7 +3142,7 @@ public class ArrayUtils { * @return A new array containing the existing elements plus the new element * @since 2.1 */ - public static short[] add(final short[] array, final short element) { + public static short[] add(short[] array, short element) { short[] newArray = (short[])copyArrayGrow1(array, Short.TYPE); newArray[lastIndex(newArray)] = element; return newArray; @@ -3157,7 +3157,7 @@ public class ArrayUtils { * size 1 array of this type. * @return A new copy of the array of size 1 greater than the input. */ - private static Object copyArrayGrow1(final Object array, Class newArrayComponentType) { + private static Object copyArrayGrow1(Object array, Class newArrayComponentType) { if (array != null) { int arrayLength = Array.getLength(array); Object newArray = Array.newInstance(array.getClass().getComponentType(), arrayLength + 1); @@ -3196,7 +3196,7 @@ public class ArrayUtils { * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index > array.length). */ - public static Object[] add(final Object[] array, final int index, final Object element) { + public static Object[] add(Object[] array, int index, Object element) { if (array == null) { if (index != 0) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: 0"); @@ -3246,7 +3246,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - public static Object[] remove(final Object[] array, final int index) { + public static Object[] remove(Object[] array, int index) { return (Object[]) remove((Object) array, index); } @@ -3275,7 +3275,7 @@ public class ArrayUtils { * occurrence of the specified element. * @since 2.1 */ - public static Object[] removeElement(final Object[] array, final Object element) { + public static Object[] removeElement(Object[] array, Object element) { int index = indexOf(array, element); if (index == -1) { return clone(array); @@ -3311,7 +3311,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - public static boolean[] remove(final boolean[] array, final int index) { + public static boolean[] remove(boolean[] array, int index) { return (boolean[]) remove((Object) array, index); } @@ -3340,7 +3340,7 @@ public class ArrayUtils { * occurrence of the specified element. * @since 2.1 */ - public static boolean[] removeElement(final boolean[] array, final boolean element) { + public static boolean[] removeElement(boolean[] array, boolean element) { int index = indexOf(array, element); if (index == -1) { return clone(array); @@ -3376,7 +3376,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - public static byte[] remove(final byte[] array, final int index) { + public static byte[] remove(byte[] array, int index) { return (byte[]) remove((Object) array, index); } @@ -3405,7 +3405,7 @@ public class ArrayUtils { * occurrence of the specified element. * @since 2.1 */ - public static byte[] removeElement(final byte[] array, final byte element) { + public static byte[] removeElement(byte[] array, byte element) { int index = indexOf(array, element); if (index == -1) { return clone(array); @@ -3441,7 +3441,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - public static char[] remove(final char[] array, final int index) { + public static char[] remove(char[] array, int index) { return (char[]) remove((Object) array, index); } @@ -3470,7 +3470,7 @@ public class ArrayUtils { * occurrence of the specified element. * @since 2.1 */ - public static char[] removeElement(final char[] array, final char element) { + public static char[] removeElement(char[] array, char element) { int index = indexOf(array, element); if (index == -1) { return clone(array); @@ -3506,7 +3506,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - public static double[] remove(final double[] array, final int index) { + public static double[] remove(double[] array, int index) { return (double[]) remove((Object) array, index); } @@ -3535,7 +3535,7 @@ public class ArrayUtils { * occurrence of the specified element. * @since 2.1 */ - public static double[] removeElement(final double[] array, final double element) { + public static double[] removeElement(double[] array, double element) { int index = indexOf(array, element); if (index == -1) { return clone(array); @@ -3571,7 +3571,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - public static float[] remove(final float[] array, final int index) { + public static float[] remove(float[] array, int index) { return (float[]) remove((Object) array, index); } @@ -3600,7 +3600,7 @@ public class ArrayUtils { * occurrence of the specified element. * @since 2.1 */ - public static float[] removeElement(final float[] array, final float element) { + public static float[] removeElement(float[] array, float element) { int index = indexOf(array, element); if (index == -1) { return clone(array); @@ -3636,7 +3636,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - public static int[] remove(final int[] array, final int index) { + public static int[] remove(int[] array, int index) { return (int[]) remove((Object) array, index); } @@ -3665,7 +3665,7 @@ public class ArrayUtils { * occurrence of the specified element. * @since 2.1 */ - public static int[] removeElement(final int[] array, final int element) { + public static int[] removeElement(int[] array, int element) { int index = indexOf(array, element); if (index == -1) { return clone(array); @@ -3701,7 +3701,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - public static long[] remove(final long[] array, final int index) { + public static long[] remove(long[] array, int index) { return (long[]) remove((Object) array, index); } @@ -3730,7 +3730,7 @@ public class ArrayUtils { * occurrence of the specified element. * @since 2.1 */ - public static long[] removeElement(final long[] array, final long element) { + public static long[] removeElement(long[] array, long element) { int index = indexOf(array, element); if (index == -1) { return clone(array); @@ -3766,7 +3766,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - public static short[] remove(final short[] array, final int index) { + public static short[] remove(short[] array, int index) { return (short[]) remove((Object) array, index); } @@ -3795,7 +3795,7 @@ public class ArrayUtils { * occurrence of the specified element. * @since 2.1 */ - public static short[] removeElement(final short[] array, final short element) { + public static short[] removeElement(short[] array, short element) { int index = indexOf(array, element); if (index == -1) { return clone(array); @@ -3824,7 +3824,7 @@ public class ArrayUtils { * (index < 0 || index >= array.length), or if the array is null. * @since 2.1 */ - private static Object remove(final Object array, final int index) { + private static Object remove(Object array, int index) { int length = getLength(array); if (index < 0 || index >= length) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length); diff --git a/src/java/org/apache/commons/lang/BitField.java b/src/java/org/apache/commons/lang/BitField.java index 667a1a532..4f5a52600 100644 --- a/src/java/org/apache/commons/lang/BitField.java +++ b/src/java/org/apache/commons/lang/BitField.java @@ -26,7 +26,7 @@ package org.apache.commons.lang; * @author Pete Gieser * @author Gary Gregory * @since 2.0 - * @version $Id: BitField.java,v 1.5 2004/02/18 22:59:50 ggregory Exp $ + * @version $Id: BitField.java,v 1.6 2004/08/15 02:12:51 bayard Exp $ */ public class BitField { @@ -40,7 +40,7 @@ public class BitField { * BitField. Bits that are set in this mask are the bits * that this BitField operates on */ - public BitField(final int mask) { + public BitField(int mask) { _mask = mask; int count = 0; int bit_pattern = mask; @@ -68,7 +68,7 @@ public class BitField { * in * @return the selected bits, shifted right appropriately */ - public int getValue(final int holder) { + public int getValue(int holder) { return getRawValue(holder) >> _shift_count; } @@ -86,7 +86,7 @@ public class BitField { * interested in * @return the selected bits, shifted right appropriately */ - public short getShortValue(final short holder) { + public short getShortValue(short holder) { return (short) getValue(holder); } @@ -97,7 +97,7 @@ public class BitField { * interested in * @return the selected bits */ - public int getRawValue(final int holder) { + public int getRawValue(int holder) { return (holder & _mask); } @@ -108,7 +108,7 @@ public class BitField { * interested in * @return the selected bits */ - public short getShortRawValue(final short holder) { + public short getShortRawValue(short holder) { return (short) getRawValue(holder); } @@ -125,7 +125,7 @@ public class BitField { * @return true if any of the bits are set, * else false */ - public boolean isSet(final int holder) { + public boolean isSet(int holder) { return (holder & _mask) != 0; } @@ -141,7 +141,7 @@ public class BitField { * @return true if all of the bits are set, * else false */ - public boolean isAllSet(final int holder) { + public boolean isAllSet(int holder) { return (holder & _mask) == _mask; } @@ -155,7 +155,7 @@ public class BitField { * @return the value of holder with the bits from the value * parameter replacing the old bits */ - public int setValue(final int holder, final int value) { + public int setValue(int holder, int value) { return (holder & ~_mask) | ((value << _shift_count) & _mask); } @@ -169,7 +169,7 @@ public class BitField { * @return the value of holder with the bits from the value * parameter replacing the old bits */ - public short setShortValue(final short holder, final short value) { + public short setShortValue(short holder, short value) { return (short) setValue(holder, value); } @@ -181,7 +181,7 @@ public class BitField { * @return the value of holder with the specified bits cleared * (set to 0) */ - public int clear(final int holder) { + public int clear(int holder) { return holder & ~_mask; } @@ -193,7 +193,7 @@ public class BitField { * @return the value of holder with the specified bits cleared * (set to 0) */ - public short clearShort(final short holder) { + public short clearShort(short holder) { return (short) clear(holder); } @@ -206,7 +206,7 @@ public class BitField { * @return the value of holder with the specified bits cleared * (set to 0) */ - public byte clearByte(final byte holder) { + public byte clearByte(byte holder) { return (byte) clear(holder); } @@ -218,7 +218,7 @@ public class BitField { * @return the value of holder with the specified bits set * to 1 */ - public int set(final int holder) { + public int set(int holder) { return holder | _mask; } @@ -230,7 +230,7 @@ public class BitField { * @return the value of holder with the specified bits set * to 1 */ - public short setShort(final short holder) { + public short setShort(short holder) { return (short) set(holder); } @@ -243,7 +243,7 @@ public class BitField { * @return the value of holder with the specified bits set * to 1 */ - public byte setByte(final byte holder) { + public byte setByte(byte holder) { return (byte) set(holder); } @@ -256,7 +256,7 @@ public class BitField { * @return the value of holder with the specified bits set or * cleared */ - public int setBoolean(final int holder, final boolean flag) { + public int setBoolean(int holder, boolean flag) { return flag ? set(holder) : clear(holder); } @@ -269,7 +269,7 @@ public class BitField { * @return the value of holder with the specified bits set or * cleared */ - public short setShortBoolean(final short holder, final boolean flag) { + public short setShortBoolean(short holder, boolean flag) { return flag ? setShort(holder) : clearShort(holder); } @@ -282,7 +282,7 @@ public class BitField { * @return the value of holder with the specified bits set or * cleared */ - public byte setByteBoolean(final byte holder, final boolean flag) { + public byte setByteBoolean(byte holder, boolean flag) { return flag ? setByte(holder) : clearByte(holder); }