public final class ArrayTools
extends java.lang.Object
Constructor and Description |
---|
ArrayTools() |
Modifier and Type | Method and Description |
---|---|
static int |
lastIndexOf(byte[] what,
byte[] within)
Finds the last occurrence of the specified byte array within the given byte array,
searching backward from the end.
|
static int |
lastIndexOf(byte[] what,
byte[] within,
int fromIndex)
Finds the last occurrence of the specified byte array within the given byte array,
searching backward from the specified index.
|
static java.lang.Object[] |
mergeArrays(java.lang.Object[] a1,
java.lang.Object[] a2)
Null-safe method to merge the two given arrays of
Object s into a new array. |
static java.lang.Object |
mergeTypedArrays(java.lang.Class<?> componentType,
java.lang.Object a1,
java.lang.Object a2)
Null-safe method to merge the two given arrays of
Object s into a new array. |
static java.lang.Object[] |
removeArrayMemberAtIndex(java.lang.Object[] a,
int i)
Returns a new
Object array without the element at the specified position,
by copying the given Object array into a new Object array without
the element at the specified position. |
static java.lang.Object |
removeTypedArrayMemberAtIndex(java.lang.Object a,
int i)
Similar to
removeArrayMemberAtIndex(java.lang.Object[], int) , but with Object parameter and
return type to be casted to the correct array type. |
public static final java.lang.Object[] mergeArrays(java.lang.Object[] a1, java.lang.Object[] a2)
Object
s into a new array.
Returns an empty array if both arrays are null or empty.a1
- First Object
array to merge.a2
- Second Object
array to merge.Object
array.public static final java.lang.Object mergeTypedArrays(java.lang.Class<?> componentType, java.lang.Object a1, java.lang.Object a2)
Object
s into a new array.
Returns an empty array if both arrays are null or empty.
Please note that this returns a <component type> array which needs to be casted
before further use.componentType
- The component type of the resulting array.a1
- First Object
array to merge.a2
- Second Object
array to merge.array
.public static final int lastIndexOf(byte[] what, byte[] within)
what
- The byte array to search for.within
- The byte array to search within.public static final int lastIndexOf(byte[] what, byte[] within, int fromIndex)
what
- The byte array to search for.within
- The byte array to search within.fromIndex
- The index to start the backward search from.public static final java.lang.Object[] removeArrayMemberAtIndex(java.lang.Object[] a, int i)
Object
array without the element at the specified position,
by copying the given Object
array into a new Object
array without
the element at the specified position. The new Object
array will have a length
of a.length - 1
, and the original array will be left untouched.a
- The Object
array to remove the element from.i
- The element position to remove.Object
array without the element at the specified position.java.lang.IllegalArgumentException
- If the given array is null.java.lang.ArrayIndexOutOfBoundsException
- If the given element position is out of bounds.public static final java.lang.Object removeTypedArrayMemberAtIndex(java.lang.Object a, int i)
removeArrayMemberAtIndex(java.lang.Object[], int)
, but with Object
parameter and
return type to be casted to the correct array type.a
- The Object
array to remove the element from.i
- The element position to remove.Object
array without the element at the specified position.java.lang.IllegalArgumentException
- If the given array is null.java.lang.ArrayIndexOutOfBoundsException
- If the given element position is out of bounds.Copyright © 2000-2024 OAshi S.à r.l. All Rights Reserved.