org.jutil.java.collections
Class Arrays

java.lang.Object
  |
  +--org.jutil.java.collections.Arrays

public abstract class Arrays
extends java.lang.Object

A class with static methods for arrays


Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
Arrays()
           
 
Method Summary
static int[] getArrayDimensions(java.lang.Object[] array)
          Return the dimensions of the given array
static java.lang.Class getArrayType(java.lang.Object array)
          Return the type of an array
static boolean isObjectArray(java.lang.Class clazz)
          Check whether the given class is an array of objects
static boolean isObjectArray(java.lang.Object object)
          Check whether the given object is an array of objects
static java.lang.Object[] newArray(java.lang.Object[] array)
          Return a new array of the same type and dimension as the given array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Constructor Detail

Arrays

public Arrays()
Method Detail

newArray

public static java.lang.Object[] newArray(java.lang.Object[] array)
                                   throws ZeroDimensionException
Return a new array of the same type and dimension as the given array.

Parameters:
array - an array that will be "cloned"

Specifications:
requires array != null;
ensures \result != null;
ensures getArrayType(\result ) == getArrayType(array);
ensures ( \forall int i; i >= 0&&i < getArrayDimensions(array).length; getArrayDimensions(\result )[i] == getArrayDimensions(array)[i]);

getArrayDimensions

public static int[] getArrayDimensions(java.lang.Object[] array)
                                throws ZeroDimensionException
Return the dimensions of the given array

Parameters:
array - The array of which the dimensions are requested
Returns:
The dimensions of the given array. The size of the i-th dimension will be at the (i-1)-th position in the returned array.

Specifications:
requires array != null;

getArrayType

public static java.lang.Class getArrayType(java.lang.Object array)
Return the type of an array

Parameters:
array - The array of which the type must be determined
Returns:
The type of the given array. In case of a primitive type, the wrapper class will be returned

Specifications:
requires array != null;
requires array.getClass().isArray();

isObjectArray

public static boolean isObjectArray(java.lang.Class clazz)
Check whether the given class is an array of objects

Returns:
clazz The Class to be checked.

Specifications:
ensures (clazz == null) ==> (\result == false);
ensures \result == clazz.isArray()&&(clazz.getName().indexOf("[L") != -1);

isObjectArray

public static boolean isObjectArray(java.lang.Object object)
Check whether the given object is an array of objects

Parameters:
clazz - The object to be checked Result True if the given object is an array of objects.

Specifications:
ensures (object == null) ==> (\result == false);
ensures isObjectArray(object.getClass());