electric.util.array
Class ArrayUtil

java.lang.Object
  extended byelectric.util.array.ArrayUtil

public final class ArrayUtil
extends java.lang.Object

ArrayUtil defines a set of static methods for manipulating Java arrays.

Author:
webMethods

Constructor Summary
ArrayUtil()
           
 
Method Summary
static int[] addElement(int[] array, int element)
          Return a new array that is a copy of the array plus a new integer element.
static java.lang.Object addElement(java.lang.Object array, java.lang.Object element)
          Return a new array that is a copy of the array plus a new element.
static java.lang.Object addElements(java.lang.Object array1, java.lang.Object array2)
          Return a new array that is the union of the elements in array1 and array2.
static boolean contains(java.lang.Object value, java.lang.Object[] array)
          Returns true if the value object is contained within the array.
static boolean equals(byte[] array1, byte[] array2)
           
static boolean equals(java.lang.Object[] array1, java.lang.Object[] array2)
           
static boolean equals(java.lang.Object object1, java.lang.Object object2)
           
static void fill(int[] array, int value)
           
static java.lang.Class getBaseClass(java.lang.Class arrayClass)
           
static java.lang.Class getBaseClass(java.lang.Object array)
           
static int getNumberOfDimensions(java.lang.Class arrayClass)
           
static int getNumberOfDimensions(java.lang.Object array)
           
static java.lang.Object grow(java.lang.Object array, int newLength)
           
static int indexOf(int value, int[] array)
           
static int indexOf(java.lang.Object value, java.lang.Object[] array)
           
static int indexOfIdentity(java.lang.Object value, java.lang.Object[] array)
           
static java.lang.Object insertElement(java.lang.Object array, java.lang.Object element)
          Return a new array that is a copy of the array with the new element inserted at the beginning.
static java.lang.Object insertElementAt(java.lang.Object array, java.lang.Object element, int index)
          Return a new array that is a copy of the array with the newly inserted element.
static boolean isPrimitiveArray(java.lang.Class arrayClass)
           
static boolean isPrimitiveArray(java.lang.Object possibleArray)
           
static int nextInt(int max)
           
static java.lang.Object randomizeOrder(java.lang.Object oldArray)
           
static java.lang.Object removeElement(java.lang.Object array, java.lang.Object element)
           
static java.lang.Object removeElementAt(java.lang.Object oldarray, int index)
           
static java.lang.Object removeElementIdentity(java.lang.Object array, java.lang.Object element)
           
static java.lang.Object removeElements(java.lang.Object array1, java.lang.Object array2)
           
static java.lang.Object shrink(java.lang.Object array, int newLength)
           
static byte[] toBytes(java.lang.Object object, java.lang.String encoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayUtil

public ArrayUtil()
Method Detail

addElement

public static java.lang.Object addElement(java.lang.Object array,
                                          java.lang.Object element)
Return a new array that is a copy of the array plus a new element. The component type of the array must be the same as that type of the element.

Parameters:
array - An array
element - The element to append.

addElement

public static int[] addElement(int[] array,
                               int element)
Return a new array that is a copy of the array plus a new integer element. The component type of the array must be the same as that type of the element.

Parameters:
array - An array
element - The element to append.

addElements

public static java.lang.Object addElements(java.lang.Object array1,
                                           java.lang.Object array2)
Return a new array that is the union of the elements in array1 and array2. The component types of both arrays must be the same.

Parameters:
array1 - The first array.
array2 - The second array.

grow

public static java.lang.Object grow(java.lang.Object array,
                                    int newLength)
Parameters:
array -
newLength -

shrink

public static java.lang.Object shrink(java.lang.Object array,
                                      int newLength)
Parameters:
array -
newLength -

insertElement

public static java.lang.Object insertElement(java.lang.Object array,
                                             java.lang.Object element)
Return a new array that is a copy of the array with the new element inserted at the beginning. The component type of the array must be the same as that type of the element.

Parameters:
array - An array
element - The element to insert.

insertElementAt

public static java.lang.Object insertElementAt(java.lang.Object array,
                                               java.lang.Object element,
                                               int index)
Return a new array that is a copy of the array with the newly inserted element. The component type of the array must be the same as that type of the element.

Parameters:
array - An array
element - The element to insert.
index - The index to insert the element before.

removeElement

public static java.lang.Object removeElement(java.lang.Object array,
                                             java.lang.Object element)
Parameters:
array -
element -

removeElements

public static java.lang.Object removeElements(java.lang.Object array1,
                                              java.lang.Object array2)
Parameters:
array1 -
array2 -

removeElementIdentity

public static java.lang.Object removeElementIdentity(java.lang.Object array,
                                                     java.lang.Object element)
Parameters:
array -
element -

removeElementAt

public static java.lang.Object removeElementAt(java.lang.Object oldarray,
                                               int index)
Parameters:
oldarray -
index -

indexOf

public static int indexOf(int value,
                          int[] array)
Parameters:
value -
array -

indexOf

public static int indexOf(java.lang.Object value,
                          java.lang.Object[] array)
Parameters:
value -
array -

indexOfIdentity

public static int indexOfIdentity(java.lang.Object value,
                                  java.lang.Object[] array)
Parameters:
value -
array -

equals

public static boolean equals(java.lang.Object[] array1,
                             java.lang.Object[] array2)
Parameters:
array1 -
array2 -

equals

public static boolean equals(byte[] array1,
                             byte[] array2)
Parameters:
array1 -
array2 -

equals

public static boolean equals(java.lang.Object object1,
                             java.lang.Object object2)
Parameters:
object1 -
object2 -

isPrimitiveArray

public static boolean isPrimitiveArray(java.lang.Object possibleArray)
Parameters:
possibleArray -

isPrimitiveArray

public static boolean isPrimitiveArray(java.lang.Class arrayClass)
Parameters:
arrayClass -

getNumberOfDimensions

public static int getNumberOfDimensions(java.lang.Object array)
Parameters:
array -

getNumberOfDimensions

public static int getNumberOfDimensions(java.lang.Class arrayClass)
Parameters:
arrayClass -

fill

public static void fill(int[] array,
                        int value)

getBaseClass

public static java.lang.Class getBaseClass(java.lang.Object array)
Parameters:
array -

getBaseClass

public static java.lang.Class getBaseClass(java.lang.Class arrayClass)
Parameters:
arrayClass -

contains

public static boolean contains(java.lang.Object value,
                               java.lang.Object[] array)
Returns true if the value object is contained within the array. NOTE that this is not a test for reference equality, but rather value equality.

Parameters:
value -
array -

toBytes

public static byte[] toBytes(java.lang.Object object,
                             java.lang.String encoding)
                      throws java.io.UnsupportedEncodingException
Parameters:
object -
encoding -
Throws:
java.io.UnsupportedEncodingException

randomizeOrder

public static java.lang.Object randomizeOrder(java.lang.Object oldArray)
Parameters:
oldArray -

nextInt

public static int nextInt(int max)
Parameters:
max -


copyright© 2001-2004 by webMethods All Rights Reserved.