com.gridsystems.innergrid.kernel.genericutils
Class ArrayUtil

java.lang.Object
  extended by com.gridsystems.innergrid.kernel.genericutils.ArrayUtil

public final class ArrayUtil
extends java.lang.Object

Array related commonly used methods.

Version:
1.0
Author:
rruiz@gridsystems.com

Method Summary
static boolean[] checkedArray(boolean[] data)
          Returns a zero-length array if data is null, or data itself otherwise.
static java.lang.Object[] checkedArray(java.util.Collection col, java.lang.Class c)
          Copies the contents of the specified collection to an array of the type specified by c.
static float[] checkedArray(float[] data)
          Returns a zero-length array if data is null, or data itself otherwise.
static int[] checkedArray(int[] data)
          Returns a zero-length array if data is null, or data itself otherwise.
static long[] checkedArray(long[] data)
          Returns a zero-length array if data is null, or data itself otherwise.
static java.lang.Object[] checkedArray(java.lang.Object[] items, java.lang.Class c)
          Gets a "checked" version of the specified array.
static java.lang.String[] checkedArray(java.lang.String[] data)
          Returns a zero-length array if data is null, or data itself otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkedArray

public static java.lang.Object[] checkedArray(java.lang.Object[] items,
                                              java.lang.Class c)
Gets a "checked" version of the specified array.

First, if the specified array is null, it returns a zero-length array of the type specified in c. If it is not null, it compares the type of the array with c: if both are the same, it returns the array without changes; if they do not coincide, it performs a copy into a newly created array

Parameters:
items - the array to process
c - the class of the returning array
Returns:
An array of class c with the same elements as items
Throws:
java.lang.ArrayStoreException - if an element of items is not compatible with class c. This should be treated as a fatal error

checkedArray

public static java.lang.Object[] checkedArray(java.util.Collection col,
                                              java.lang.Class c)
Copies the contents of the specified collection to an array of the type specified by c.

Parameters:
col - the collection to process
c - the class of the returning array
Returns:
an array of class c containing the items in col
Throws:
java.lang.ArrayStoreException - if an element of items is not compatible with class c. This should be treated as a fatal error

checkedArray

public static boolean[] checkedArray(boolean[] data)
Returns a zero-length array if data is null, or data itself otherwise.

Parameters:
data - The array to process
Returns:
data, if data is not null; a zero-length array otherwise

checkedArray

public static int[] checkedArray(int[] data)
Returns a zero-length array if data is null, or data itself otherwise.

Parameters:
data - The array to process
Returns:
data, if data is not null; a zero-length array otherwise

checkedArray

public static long[] checkedArray(long[] data)
Returns a zero-length array if data is null, or data itself otherwise.

Parameters:
data - The array to process
Returns:
data, if data is not null; a zero-length array otherwise

checkedArray

public static float[] checkedArray(float[] data)
Returns a zero-length array if data is null, or data itself otherwise.

Parameters:
data - The array to process
Returns:
data, if data is not null; a zero-length array otherwise

checkedArray

public static java.lang.String[] checkedArray(java.lang.String[] data)
Returns a zero-length array if data is null, or data itself otherwise.

Parameters:
data - The array to process
Returns:
data, if data is not null; a zero-length array otherwise


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.