|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.mockrunner.util.common.ArrayUtil
Util class for arrays
| Constructor Summary | |
ArrayUtil()
|
|
| Method Summary | |
static void |
addBytesToList(byte[] data,
int offset,
int len,
java.util.List list,
int index)
Copies the bytes from the specified array to the specified List as Byte objects starting
at the specified index. |
static void |
addBytesToList(byte[] data,
java.util.List list,
int index)
Copies the bytes from the specified array to the specified List as Byte objects starting
at the specified index. |
static java.lang.Object |
convertToArray(java.lang.Object object)
Creates an array with a single object as component. |
static java.lang.Object[] |
convertToObjectArray(java.lang.Object sourceArray)
Returns an object array by wrapping primitive types. |
static java.lang.Object |
copyArray(java.lang.Object array)
Returns a copy of the specified array. |
static void |
ensureUnique(java.lang.String[] values)
Ensures that each entry in the specified string array is unique by adding a number to duplicate entries. |
static byte[] |
getByteArrayFromList(java.util.List data)
Returns a byte array containing the bytes from the List. |
static byte[] |
getByteArrayFromList(java.util.List data,
int index)
Returns a byte array containing the bytes from the List. |
static byte[] |
getByteArrayFromList(java.util.List data,
int index,
int len)
Returns a byte array containing the bytes from the List. |
static java.util.List |
getListFromByteArray(byte[] data)
Returns a List containing the bytes from the
specified array as Byte objects. |
static java.util.List |
getListFromObjectArray(java.lang.Object[] data)
Returns a List containing the objects from the
specified array. |
static int |
indexOf(byte[] source,
byte[] bytes)
Returns the index of the first occurence of the array bytes in the array source. |
static int |
indexOf(byte[] source,
byte[] bytes,
int index)
Returns the index of the first occurence of the array bytes in the array source. |
static java.lang.Object |
truncateArray(java.lang.Object sourceArray,
int len)
Returns a truncated copy of sourceArray. |
static java.lang.Object |
truncateArray(java.lang.Object sourceArray,
int index,
int len)
Returns a truncated copy of sourceArray. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ArrayUtil()
| Method Detail |
public static java.util.List getListFromByteArray(byte[] data)
List containing the bytes from the
specified array as Byte objects.
data - the byte data
List with the Byte objectspublic static java.util.List getListFromObjectArray(java.lang.Object[] data)
List containing the objects from the
specified array.
data - the data
List with the objectspublic static byte[] getByteArrayFromList(java.util.List data)
List.
The List must contain Byte objects.
null entries in the List are
allowed, the resulting byte will be 0.
data - the List
public static byte[] getByteArrayFromList(java.util.List data,
int index)
List.
The List must contain Byte objects.
null entries in the List are
allowed, the resulting byte will be 0.
data - the Listindex - the index at which to start
public static byte[] getByteArrayFromList(java.util.List data,
int index,
int len)
List.
The List must contain Byte objects.
null entries in the List are
allowed, the resulting byte will be 0.
data - the Listindex - the index at which to startlen - the number of bytes
public static void addBytesToList(byte[] data,
java.util.List list,
int index)
List as Byte objects starting
at the specified index. Grows the list if necessary.
index must be a valid index in the list.
data - the byte datalist - the Listindex - the index at which to start copying
public static void addBytesToList(byte[] data,
int offset,
int len,
java.util.List list,
int index)
List as Byte objects starting
at the specified index. Grows the list if necessary.
index must be a valid index in the list.
data - the byte dataoffset - the offset into the byte array at which to startlen - the number of bytes to copylist - the Listindex - the index at which to start copying
public static java.lang.Object truncateArray(java.lang.Object sourceArray,
int len)
sourceArray - the source arraylen - the truncate length
java.lang.IllegalArgumentException - if the specified object
is not an array (either of reference or primitive
component type)
public static java.lang.Object truncateArray(java.lang.Object sourceArray,
int index,
int len)
sourceArray - the source arrayindex - the start indexlen - the truncate length
java.lang.IllegalArgumentException - if the specified object
is not an array (either of reference or primitive
component type)public static java.lang.Object copyArray(java.lang.Object array)
array - the array
public static java.lang.Object[] convertToObjectArray(java.lang.Object sourceArray)
Object[]
with the corresponding wrapper component type is returned.
If the specified array is already an object array, the instance is
returned unchanged.
sourceArray - the array
java.lang.IllegalArgumentException - if the specified object
is not an array (either of reference or primitive
component type)public static java.lang.Object convertToArray(java.lang.Object object)
object - the object
public static int indexOf(byte[] source,
byte[] bytes)
source - the array in which to searchbytes - the array to search
public static int indexOf(byte[] source,
byte[] bytes,
int index)
source - the array in which to searchbytes - the array to searchindex - the index where to begin the search
public static void ensureUnique(java.lang.String[] values)
"entry" occurs three
times, the three entries will be renamed to "entry1",
"entry2" and "entry3".
values - the array of strings
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||