Package org.codehaus.gmavenplus.util
Class JDK5Utils
- java.lang.Object
-
- org.codehaus.gmavenplus.util.JDK5Utils
-
public class JDK5Utils extends Object
Utility methods ported from later JDK versions for use with JDK 5.- Since:
- 1.2
- Author:
- Keegan Witt
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T[]
Arrays_copyOf(T[] original, int newLength)
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.static <T,U>
T[]Arrays_copyOf(U[] original, int newLength, Class<? extends T[]> newType)
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.
-
-
-
Method Detail
-
Arrays_copyOf
public static <T> T[] Arrays_copyOf(T[] original, int newLength)
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain null. Such indices will exist if and only if the specified length is greater than that of the original array. The resulting array is of exactly the same class as the original array.- Parameters:
original
- the array to be copiednewLength
- the length of the copy to be returned- Returns:
- a copy of the original array, truncated or padded with nulls to obtain the specified length
- Throws:
NegativeArraySizeException
- if newLength is negativeNullPointerException
- if original is null
-
Arrays_copyOf
public static <T,U> T[] Arrays_copyOf(U[] original, int newLength, Class<? extends T[]> newType)
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain null. Such indices will exist if and only if the specified length is greater than that of the original array. The resulting array is of the class newType.- Parameters:
original
- the array to be copiednewLength
- the length of the copy to be returnednewType
- the class of the copy to be returned- Returns:
- a copy of the original array, truncated or padded with nulls to obtain the specified length
- Throws:
NegativeArraySizeException
- if newLength is negativeNullPointerException
- if original is nullArrayStoreException
- if an element copied from original is not of a runtime type that can be stored in an array of class newType
-
-