Modifier and Type | Field and Description |
---|---|
static Object[] |
OBJECT_EMPTY |
Constructor and Description |
---|
ArrayUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
arrayContainsIgnoreEmpty(Array arr,
String value,
boolean ignoreCase) |
static double |
avg(Array array)
average of all values of the array, only work when all values are numeric
|
static Object[] |
clone(Object[] src,
Object[] trg) |
static int |
find(Array array,
Object object)
find a object in array
|
static Object |
get(Object o,
int index)
gets a value of a array at defined index
|
static Object |
get(Object o,
int index,
Object defaultValue)
gets a value of a array at defined index
|
static int |
indexOf(String[] arr,
String value)
return index of given value in Array or -1
|
static int |
indexOfIgnoreCase(String[] arr,
String value)
return index of given value in Array or -1
|
static boolean |
isEmpty(boolean[] array) |
static boolean |
isEmpty(byte[] array) |
static boolean |
isEmpty(char[] array) |
static boolean |
isEmpty(double[] array) |
static boolean |
isEmpty(float[] array) |
static boolean |
isEmpty(int[] array) |
static boolean |
isEmpty(List list) |
static boolean |
isEmpty(long[] array) |
static boolean |
isEmpty(Object[] array) |
static Object[] |
keys(Map map) |
static double |
max(Array array)
the greatest value, of all values inside the array, only work when all values are numeric
|
static double |
median(Array array)
median value of all items in the arrays, only works when all values are numeric
|
static <E> List<E> |
merge(E[] a1,
E[] a2) |
static Object[] |
mergeNativeArrays(Object[] dst,
Object[] src,
int dstPosition,
boolean doPowerOf2)
this method efficiently copy the contents of one native array into another by using System.arraycopy()
|
static double |
min(Array array)
the smallest value, of all values inside the array, only work when all values are numeric
|
static Object[] |
resizeIfNeeded(Object[] arr,
int minSize,
boolean doPowerOf2)
this method returns the original array if its length is equal or greater than the minSize, or create a new array
and copies the data from the original array into the new one.
|
static Object |
set(Object o,
int index,
Object value)
sets a value to a array at defined index
|
static Object |
setEL(Object o,
int index,
Object value)
sets a value to a array at defined index
|
static int |
size(boolean[] array) |
static int |
size(byte[] array) |
static int |
size(char[] array) |
static int |
size(double[] array) |
static int |
size(float[] array) |
static int |
size(int[] array) |
static int |
size(long[] array) |
static int |
size(Object[] array) |
static long |
sizeOf(Array array) |
static long |
sizeOf(List list) |
static double |
sum(Array array)
sum of all values of a array, only work when all values are numeric
|
static void |
swap(Array array,
int left,
int right)
swap to values of the array
|
static Object[] |
toArray(List<?> list)
creates a native array out of the input list, if all values are from the same type, this type is used for the array, otherwise object
|
static boolean[] |
toBooleanArray(Object obj) |
static byte[] |
toByteArray(Object obj) |
static char[] |
toCharArray(Object obj) |
static Comparator |
toComparator(PageContext pc,
String strSortType,
String sortOrder,
boolean localeSensitive) |
static double[] |
toDoubleArray(Object obj) |
static float[] |
toFloatArray(Object obj) |
static int[] |
toIntArray(Object obj) |
static long[] |
toLongArray(Object obj) |
static Object[] |
toNullArray(Object obj) |
static Boolean[] |
toReferenceType(boolean[] primArr)
convert a primitive array (value type) to Object Array (reference type).
|
static Byte[] |
toReferenceType(byte[] primArr)
convert a primitive array (value type) to Object Array (reference type).
|
static Character[] |
toReferenceType(char[] primArr)
convert a primitive array (value type) to Object Array (reference type).
|
static Double[] |
toReferenceType(double[] primArr)
convert a primitive array (value type) to Object Array (reference type).
|
static Float[] |
toReferenceType(float[] primArr)
convert a primitive array (value type) to Object Array (reference type).
|
static Integer[] |
toReferenceType(int[] primArr)
convert a primitive array (value type) to Object Array (reference type).
|
static Long[] |
toReferenceType(long[] primArr)
convert a primitive array (value type) to Object Array (reference type).
|
static Object[] |
toReferenceType(Object obj) |
static Object[] |
toReferenceType(Object obj,
Object[] defaultValue) |
static Short[] |
toReferenceType(short[] primArr)
convert a primitive array (value type) to Object Array (reference type).
|
static short[] |
toShortArray(Object obj) |
static SortRegister[] |
toSortRegisterArray(ArrayList list) |
static SortRegister[] |
toSortRegisterArray(QueryColumn column) |
static String[] |
trim(String[] arr)
trims all value of a String Array
|
static Object[] |
values(Map map) |
public static final Object[] OBJECT_EMPTY
public ArrayUtil()
public static String[] trim(String[] arr)
arr
- public static SortRegister[] toSortRegisterArray(ArrayList list)
list
- public static SortRegister[] toSortRegisterArray(QueryColumn column)
column
- public static void swap(Array array, int left, int right) throws ExpressionException
array
- left
- left value to swapright
- right value to swapExpressionException
public static int find(Array array, Object object)
array
- object
- object to findpublic static double avg(Array array) throws ExpressionException
array
- ExpressionException
public static double sum(Array array) throws ExpressionException
array
- ArrayExpressionException
public static double median(Array array) throws ExpressionException
array
- ExpressionException
public static double min(Array array) throws PageException
array
- PageException
public static double max(Array array) throws PageException
array
- PageException
public static int indexOf(String[] arr, String value)
arr
- value
- public static int indexOfIgnoreCase(String[] arr, String value)
arr
- value
- public static Boolean[] toReferenceType(boolean[] primArr)
primArr
- value type Arraypublic static Byte[] toReferenceType(byte[] primArr)
primArr
- value type Arraypublic static Character[] toReferenceType(char[] primArr)
primArr
- value type Arraypublic static Short[] toReferenceType(short[] primArr)
primArr
- value type Arraypublic static Integer[] toReferenceType(int[] primArr)
primArr
- value type Arraypublic static Long[] toReferenceType(long[] primArr)
primArr
- value type Arraypublic static Float[] toReferenceType(float[] primArr)
primArr
- value type Arraypublic static Double[] toReferenceType(double[] primArr)
primArr
- value type Arraypublic static Object get(Object o, int index) throws ArrayUtilException
o
- index
- ArrayUtilException
public static Object get(Object o, int index, Object defaultValue)
o
- index
- public static Object set(Object o, int index, Object value) throws ArrayUtilException
o
- index
- value
- ArrayUtilException
public static Object setEL(Object o, int index, Object value)
o
- index
- value
- public static boolean isEmpty(boolean[] array)
public static boolean isEmpty(char[] array)
public static boolean isEmpty(double[] array)
public static boolean isEmpty(long[] array)
public static boolean isEmpty(int[] array)
public static boolean isEmpty(float[] array)
public static boolean isEmpty(byte[] array)
public static int size(boolean[] array)
public static int size(char[] array)
public static int size(double[] array)
public static int size(long[] array)
public static int size(int[] array)
public static int size(float[] array)
public static int size(byte[] array)
public static boolean[] toBooleanArray(Object obj) throws PageException
PageException
public static byte[] toByteArray(Object obj) throws PageException
PageException
public static short[] toShortArray(Object obj) throws PageException
PageException
public static int[] toIntArray(Object obj) throws PageException
PageException
public static Object[] toNullArray(Object obj) throws PageException
PageException
public static long[] toLongArray(Object obj) throws PageException
PageException
public static float[] toFloatArray(Object obj) throws PageException
PageException
public static double[] toDoubleArray(Object obj) throws PageException
PageException
public static char[] toCharArray(Object obj) throws PageException
PageException
public static int arrayContainsIgnoreEmpty(Array arr, String value, boolean ignoreCase)
public static Object[] toReferenceType(Object obj) throws CasterException
CasterException
public static Object[] toReferenceType(Object obj, Object[] defaultValue)
public static Object[] toArray(List<?> list)
list
- public static Comparator toComparator(PageContext pc, String strSortType, String sortOrder, boolean localeSensitive) throws PageException
PageException
public static Object[] mergeNativeArrays(Object[] dst, Object[] src, int dstPosition, boolean doPowerOf2)
dst
- - the array that will be modifiedsrc
- - the data to be copieddstPosition
- - pass -1 to append to the end of the dst array, or a valid position to add it elsewheredoPowerOf2
- - if true, and the array needs to be resized, it will be resized to the next power of 2 sizepublic static Object[] resizeIfNeeded(Object[] arr, int minSize, boolean doPowerOf2)
arr
- - the array to checkminSize
- - the required minimum sizedoPowerOf2
- - if true, and a resize is required, the new size will be a power of 2Copyright © 2015 Lucee