org.objectweb.jac.util
Class ExtArrays

java.lang.Object
  extended byorg.objectweb.jac.util.ExtArrays

public class ExtArrays
extends Object

Various often used array functions


Field Summary
static Class[] emptyClassArray
           
static Interceptor[] emptyInterceptorArray
           
static Object[] emptyObjectArray
           
static String[] emptyStringArray
           
 
Constructor Summary
ExtArrays()
           
 
Method Summary
static Object[] add(int position, Object toInsert, Object[] array)
          Insert an object into an array
static Object[] add(int position, Object toInsert, Object[] array, Class type)
          Insert an object into an array
static Object[] add(Object toAppend, Object[] array)
          Append an object at the end of an array
static Object[] add(Object toAppend, Object[] array, Class type)
          Append an object at the end of an array
static List asList(byte[] array)
          Builds a List out of an array of bytes
static boolean contains(Object[] array, Object value)
          Tells wether an array of objects contains a given value
static boolean equals(byte[] a, int offseta, byte[] b, int offsetb, int length)
          Tests equality of some elements of two arrays of bytes.
static int indexOf(Object[] array, Object value)
          Returns the index of a value in an array of Object.
static Object subArray(Object[] array, int start)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

emptyObjectArray

public static final Object[] emptyObjectArray

emptyStringArray

public static final String[] emptyStringArray

emptyClassArray

public static final Class[] emptyClassArray

emptyInterceptorArray

public static final Interceptor[] emptyInterceptorArray
Constructor Detail

ExtArrays

public ExtArrays()
Method Detail

add

public static Object[] add(int position,
                           Object toInsert,
                           Object[] array)
Insert an object into an array

Parameters:
position - of the object to insert (>=0 and <=array.length)
toInsert - the object to insert
array - the array
Returns:
a new array of size array.length+1, where item at position "position" is toInsert. The actual type of the returned array is the same as the parameter array, or the type of toInsert, or Object[].
See Also:
add(int,Object,Object[],Class), add(Object,Object[])

add

public static Object[] add(int position,
                           Object toInsert,
                           Object[] array,
                           Class type)
Insert an object into an array

Parameters:
position - of the object to insert (>=0 and <=array.length)
toInsert - the object to insert
array - the array
type - component type of the array to return
Returns:
a new array of size array.length+1, where item at position "position" is toInsert.
See Also:
add(int,Object,Object[])

add

public static Object[] add(Object toAppend,
                           Object[] array)
Append an object at the end of an array

Parameters:
toAppend - the object to add
array - the array
Returns:
a new array, of length array.length+1 and whose last item is toAppend
See Also:
add(int,Object,Object[],Class), add(Object,Object[],Class)

add

public static Object[] add(Object toAppend,
                           Object[] array,
                           Class type)
Append an object at the end of an array

Parameters:
toAppend - the object to add
array - the array
type - component type of the array to return
Returns:
a new array, of length array.length+1 and whose last item is toAppend
See Also:
add(Object,Object[]), add(int,Object,Object[])

indexOf

public static int indexOf(Object[] array,
                          Object value)
Returns the index of a value in an array of Object.

Parameters:
array - the array
value - the searched value
Returns:
Returns the lowest integer value i such that array[i]==value, or -1.

contains

public static boolean contains(Object[] array,
                               Object value)
Tells wether an array of objects contains a given value

Parameters:
array - the array to search the value in
value - the object to search for
Returns:
true if array contains value

equals

public static boolean equals(byte[] a,
                             int offseta,
                             byte[] b,
                             int offsetb,
                             int length)
Tests equality of some elements of two arrays of bytes.

Parameters:
a - first array of bytes
offseta - start comparison in first array with this offset
b - second array
offsetb - start comparison in second array with this offset
length - number of bytes to compare

asList

public static List asList(byte[] array)
Builds a List out of an array of bytes

Returns:
a List whose elements are Byte objects

subArray

public static Object subArray(Object[] array,
                              int start)