org.jbpm.util
Class ArrayUtil

java.lang.Object
  extended by org.jbpm.util.ArrayUtil

public class ArrayUtil
extends java.lang.Object

Various methods for manipulating arrays.


Method Summary
static boolean contains(java.lang.Object[] a, java.lang.Object o)
          Tells whether the given array contains the specified element.
static int hashCode(byte[] a)
          Returns a hash code based on the contents of the specified array.
static int indexOf(java.lang.Object[] a, java.lang.Object o)
          Returns the index in the given array of the first occurrence of the specified element, or -1 if the array does not contain this element.
static java.lang.String toString(long[] a)
          Returns a string representation of the contents of the specified array.
static java.lang.String toString(java.lang.Object[] a)
          Returns a string representation of the contents of the specified array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hashCode

public static int hashCode(byte[] a)
Returns a hash code based on the contents of the specified array. For any two byte arrays a and b such that Arrays.equals(a, b), it is also the case that Arrays.hashCode(a) == Arrays.hashCode(b).

The value returned by this method is the same value that would be obtained by invoking the hashCode method on a List containing a sequence of Byte instances representing the elements of a in the same order. If a is null, this method returns 0.

Parameters:
a - the array whose hash value to compute
Returns:
a content-based hash code for a

toString

public static java.lang.String toString(java.lang.Object[] a)
Returns a string representation of the contents of the specified array. If the array contains other arrays as elements, they are converted to strings by the Object.toString() method inherited from Object, which describes their identities rather than their contents.

The value returned by this method is equal to the value that would be returned by Arrays.asList(a).toString(), unless the array is null, in which case "null" is returned.

Parameters:
a - the array whose string representation to return
Returns:
a string representation of a
See Also:
java.util.Arrays.toString(Object[])

toString

public static java.lang.String toString(long[] a)
Returns a string representation of the contents of the specified array. The string representation consists of a list of the array's elements, enclosed in square brackets ( "[]"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Elements are converted to strings by String.valueOf(long). Returns "null" if the array is null.

Parameters:
a - the array whose string representation to return
Returns:
a string representation of a
See Also:
java.util.Arrays.toString(long[])

indexOf

public static int indexOf(java.lang.Object[] a,
                          java.lang.Object o)
Returns the index in the given array of the first occurrence of the specified element, or -1 if the array does not contain this element.

Parameters:
o - element to search for.
Returns:
the index of the first occurrence of the specified element, or -1 if the array does not contain this element.

contains

public static boolean contains(java.lang.Object[] a,
                               java.lang.Object o)
Tells whether the given array contains the specified element.

Parameters:
o - element whose presence in the array is to be tested.
Returns:
true if the array contains the specified element.


Copyright © 2010 JBoss Community. All Rights Reserved.