ariba.util.core
Class ArrayUtil

java.lang.Object
  extended by ariba.util.core.ArrayUtil

public final class ArrayUtil
extends java.lang.Object

Array Utilities. These are helper functions for dealing with arrays.


Method Summary
static java.lang.Object[] append(java.lang.Object[] in, java.lang.Object a)
          Helper function to append an Object to an array and return the new array.
static java.lang.Object[] array()
          Helper function to create a new empty Object array
static java.lang.Object[] array(java.util.List vector)
          Convert a List into an Object array with null check.
static java.lang.Object[] array(java.lang.Object a)
          Helper function to create a new Object array containing one Object.
static java.lang.Object[] array(java.lang.Object a, java.lang.Object b)
          Helper function to create a new Object array containing two Objects.
static java.lang.Object[] array(java.lang.Object a, java.lang.Object b, java.lang.Object c)
          Helper function to create a new Object array containing three Objects.
static java.lang.Object[] array(java.lang.Object a, java.lang.Object b, java.lang.Object c, java.lang.Object d)
          Helper function to create a new Object array containing four Objects.
static java.lang.Object[] array(java.lang.Object a, java.lang.Object b, java.lang.Object c, java.lang.Object d, java.lang.Object e)
          Helper function to create a new Object array containing five Objects.
static java.lang.Object[] array(java.lang.Object a, java.lang.Object b, java.lang.Object c, java.lang.Object d, java.lang.Object e, java.lang.Object f)
          Helper function to create a new Object array containing six Objects.
static java.lang.Object[] array(java.lang.Object a, java.lang.Object b, java.lang.Object c, java.lang.Object d, java.lang.Object e, java.lang.Object f, java.lang.Object g)
          Helper function to create a new Object array containing seven Objects.
static java.lang.Object[] array(java.lang.Object a, java.lang.Object b, java.lang.Object c, java.lang.Object d, java.lang.Object e, java.lang.Object f, java.lang.Object g, java.lang.Object h)
          Helper function to create a new Object array containing eight Objects.
static boolean arrayEquals(java.lang.Object[] a1, java.lang.Object[] a2)
          Determines if the two arrays are equal Two arrays are equal if their size is identical and if for each position in the array, both corresponding elements are equal
static boolean contains(java.lang.Object[] array, java.lang.Object x)
          Check if the array contains an object.
static boolean containsIdentical(java.lang.Object[] array, java.lang.Object x)
          Check if the array contains an object.
static java.lang.String formatArray(java.lang.String header, java.lang.String[] args)
          Returns a String with the array printed as formatted text
static int indexOf(java.lang.Object[] array, java.lang.Object x)
          Find the location of an object in the array Object.equals() is used to compare objects.
static boolean nullOrEmptyArray(java.lang.Object[] array)
          Determine if an Object array is null or empty.
static boolean nullOrEmptyIntArray(int[] array)
          Determine if an int array is null or empty.
static java.lang.Object[] prepend(java.lang.Object a, java.lang.Object[] in)
          Helper function to prepend an Object to an array and return the new array.
static void printArray(java.io.PrintStream out, java.lang.String head, java.lang.String[] args)
          Write an array into a PrintStream.
static void reverse(java.lang.Object[] objects)
          Reverses the order of the objects in this array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

array

public static java.lang.Object[] array(java.util.List vector)
Convert a List into an Object array with null check.

Parameters:
vector - a List to pull the contents from
Returns:
a new Object array containing all elements of vector, or a new empty Object array if vector was null

array

public static java.lang.Object[] array()
Helper function to create a new empty Object array

Returns:
a new empty Object array

array

public static java.lang.Object[] array(java.lang.Object a)
Helper function to create a new Object array containing one Object.

Parameters:
a - the first Object to add to the List
Returns:
a new Object array containing the specified object

array

public static java.lang.Object[] array(java.lang.Object a,
                                       java.lang.Object b)
Helper function to create a new Object array containing two Objects.

Parameters:
a - the first Object to add to the List
b - the second Object to add to the List
Returns:
a new Object array containing the specified objects

array

public static java.lang.Object[] array(java.lang.Object a,
                                       java.lang.Object b,
                                       java.lang.Object c)
Helper function to create a new Object array containing three Objects.

Parameters:
a - the first Object to add to the List
b - the second Object to add to the List
c - the third Object to add to the List
Returns:
a new Object array containing the specified objects

array

public static java.lang.Object[] array(java.lang.Object a,
                                       java.lang.Object b,
                                       java.lang.Object c,
                                       java.lang.Object d)
Helper function to create a new Object array containing four Objects.

Parameters:
a - the first Object to add to the List
b - the second Object to add to the List
c - the third Object to add to the List
d - the fourth Object to add to the List
Returns:
a new Object array containing the specified objects

array

public static java.lang.Object[] array(java.lang.Object a,
                                       java.lang.Object b,
                                       java.lang.Object c,
                                       java.lang.Object d,
                                       java.lang.Object e)
Helper function to create a new Object array containing five Objects.

Parameters:
a - the first Object to add to the List
b - the second Object to add to the List
c - the third Object to add to the List
d - the fourth Object to add to the List
e - the fifth Object to add to the List
Returns:
a new Object array containing the specified objects

array

public static java.lang.Object[] array(java.lang.Object a,
                                       java.lang.Object b,
                                       java.lang.Object c,
                                       java.lang.Object d,
                                       java.lang.Object e,
                                       java.lang.Object f)
Helper function to create a new Object array containing six Objects.

Parameters:
a - the first Object to add to the List
b - the second Object to add to the List
c - the third Object to add to the List
d - the fourth Object to add to the List
e - the fifth Object to add to the List
f - the sixth Object to add to the List
Returns:
a new Object array containing the specified objects

array

public static java.lang.Object[] array(java.lang.Object a,
                                       java.lang.Object b,
                                       java.lang.Object c,
                                       java.lang.Object d,
                                       java.lang.Object e,
                                       java.lang.Object f,
                                       java.lang.Object g)
Helper function to create a new Object array containing seven Objects.

Parameters:
a - the first Object to add to the List
b - the second Object to add to the List
c - the third Object to add to the List
d - the fourth Object to add to the List
e - the fifth Object to add to the List
f - the sixth Object to add to the List
g - the seventh Object to add to the List
Returns:
a new Object array containing the specified objects

array

public static java.lang.Object[] array(java.lang.Object a,
                                       java.lang.Object b,
                                       java.lang.Object c,
                                       java.lang.Object d,
                                       java.lang.Object e,
                                       java.lang.Object f,
                                       java.lang.Object g,
                                       java.lang.Object h)
Helper function to create a new Object array containing eight Objects.

Parameters:
a - the first Object to add to the List
b - the second Object to add to the List
c - the third Object to add to the List
d - the fourth Object to add to the List
e - the fifth Object to add to the List
f - the sixth Object to add to the List
g - the seventh Object to add to the List
h - the eighth Object to add to the List
Returns:
a new Object array containing the specified objects

prepend

public static java.lang.Object[] prepend(java.lang.Object a,
                                         java.lang.Object[] in)
Helper function to prepend an Object to an array and return the new array.

Parameters:
a - the Object to be prepended
in - the array to prepend a onto
Returns:
a new Object array containing a + the elements of in

append

public static java.lang.Object[] append(java.lang.Object[] in,
                                        java.lang.Object a)
Helper function to append an Object to an array and return the new array.

Parameters:
in - the array to prepend a onto
a - the Object to be appended
Returns:
a new Object array containing the elements of in + a

nullOrEmptyArray

public static boolean nullOrEmptyArray(java.lang.Object[] array)
Determine if an Object array is null or empty.

Parameters:
array - the Object array to check
Returns:
true if array is null or empty, false otherwise

nullOrEmptyIntArray

public static boolean nullOrEmptyIntArray(int[] array)
Determine if an int array is null or empty.

Parameters:
array - the int array to check
Returns:
true if array is null or empty, false otherwise

printArray

public static void printArray(java.io.PrintStream out,
                              java.lang.String head,
                              java.lang.String[] args)
Write an array into a PrintStream.

Parameters:
out - a PrintStream to write the output to
head - a header to prefix the list with
args - the array of Strings to print
See Also:
formatArray(String, String[])

formatArray

public static java.lang.String formatArray(java.lang.String header,
                                           java.lang.String[] args)
Returns a String with the array printed as formatted text

Parameters:
header - a header to prefix the list with
args - the array of Strings to print
Returns:
a String with the array printed as formatted text.

containsIdentical

public static boolean containsIdentical(java.lang.Object[] array,
                                        java.lang.Object x)
Check if the array contains an object. The == operator is used to compare objects

Parameters:
array - the array to check
x - the object to check for
Returns:
true if the object is in the array

contains

public static boolean contains(java.lang.Object[] array,
                               java.lang.Object x)
Check if the array contains an object. Object.equals() is used to compare objects.

Parameters:
array - the array to check
x - the object to check for
Returns:
true if the object is in the array

indexOf

public static int indexOf(java.lang.Object[] array,
                          java.lang.Object x)
Find the location of an object in the array Object.equals() is used to compare objects.

Parameters:
array - the array to check
x - The object to look for
Returns:
the index of the object, or -1 if it is not found

arrayEquals

public static boolean arrayEquals(java.lang.Object[] a1,
                                  java.lang.Object[] a2)
Determines if the two arrays are equal Two arrays are equal if their size is identical and if for each position in the array, both corresponding elements are equal

Parameters:
a1 - first array
a2 - second array
Returns:
true if the two arrays are equal

reverse

public static void reverse(java.lang.Object[] objects)
Reverses the order of the objects in this array.

Parameters:
objects - the object array


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.