railo.runtime.type.util
Class ArrayUtil

java.lang.Object
  extended by railo.runtime.type.util.ArrayUtil

public final class ArrayUtil
extends Object

Util for diffrent methods to manipulate arrays


Field Summary
static Object[] OBJECT_EMPTY
           
 
Constructor Summary
ArrayUtil()
           
 
Method Summary
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 min(Array array)
          the smallest value, of all values inside the array, only work when all values are numeric
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 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)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OBJECT_EMPTY

public static final Object[] OBJECT_EMPTY
Constructor Detail

ArrayUtil

public ArrayUtil()
Method Detail

trim

public static String[] trim(String[] arr)
trims all value of a String Array

Parameters:
arr -
Returns:
trimmed array

toSortRegisterArray

public static SortRegister[] toSortRegisterArray(ArrayList list)
Parameters:
list -
Returns:
array

toSortRegisterArray

public static SortRegister[] toSortRegisterArray(QueryColumn column)
Parameters:
column -
Returns:
array

swap

public static void swap(Array array,
                        int left,
                        int right)
                 throws ExpressionException
swap to values of the array

Parameters:
array -
left - left value to swap
right - right value to swap
Throws:
ExpressionException

find

public static int find(Array array,
                       Object object)
find a object in array

Parameters:
array -
object - object to find
Returns:
position in array or 0

avg

public static double avg(Array array)
                  throws ExpressionException
average of all values of the array, only work when all values are numeric

Parameters:
array -
Returns:
average of all values
Throws:
ExpressionException

sum

public static double sum(Array array)
                  throws ExpressionException
sum of all values of a array, only work when all values are numeric

Parameters:
array - Array
Returns:
sum of all values
Throws:
ExpressionException

min

public static double min(Array array)
                  throws PageException
the smallest value, of all values inside the array, only work when all values are numeric

Parameters:
array -
Returns:
the smallest value
Throws:
PageException

max

public static double max(Array array)
                  throws PageException
the greatest value, of all values inside the array, only work when all values are numeric

Parameters:
array -
Returns:
the greatest value
Throws:
PageException

indexOf

public static int indexOf(String[] arr,
                          String value)
return index of given value in Array or -1

Parameters:
arr -
value -
Returns:
index of position in array

indexOfIgnoreCase

public static int indexOfIgnoreCase(String[] arr,
                                    String value)
return index of given value in Array or -1

Parameters:
arr -
value -
Returns:
index of position in array

toReferenceType

public static Boolean[] toReferenceType(boolean[] primArr)
convert a primitive array (value type) to Object Array (reference type).

Parameters:
primArr - value type Array
Returns:
reference type Array

toReferenceType

public static Byte[] toReferenceType(byte[] primArr)
convert a primitive array (value type) to Object Array (reference type).

Parameters:
primArr - value type Array
Returns:
reference type Array

toReferenceType

public static Character[] toReferenceType(char[] primArr)
convert a primitive array (value type) to Object Array (reference type).

Parameters:
primArr - value type Array
Returns:
reference type Array

toReferenceType

public static Short[] toReferenceType(short[] primArr)
convert a primitive array (value type) to Object Array (reference type).

Parameters:
primArr - value type Array
Returns:
reference type Array

toReferenceType

public static Integer[] toReferenceType(int[] primArr)
convert a primitive array (value type) to Object Array (reference type).

Parameters:
primArr - value type Array
Returns:
reference type Array

toReferenceType

public static Long[] toReferenceType(long[] primArr)
convert a primitive array (value type) to Object Array (reference type).

Parameters:
primArr - value type Array
Returns:
reference type Array

toReferenceType

public static Float[] toReferenceType(float[] primArr)
convert a primitive array (value type) to Object Array (reference type).

Parameters:
primArr - value type Array
Returns:
reference type Array

toReferenceType

public static Double[] toReferenceType(double[] primArr)
convert a primitive array (value type) to Object Array (reference type).

Parameters:
primArr - value type Array
Returns:
reference type Array

get

public static Object get(Object o,
                         int index)
                  throws ArrayUtilException
gets a value of a array at defined index

Parameters:
o -
index -
Returns:
value at index position
Throws:
ArrayUtilException

get

public static Object get(Object o,
                         int index,
                         Object defaultValue)
gets a value of a array at defined index

Parameters:
o -
index -
Returns:
value of the variable

set

public static Object set(Object o,
                         int index,
                         Object value)
                  throws ArrayUtilException
sets a value to a array at defined index

Parameters:
o -
index -
value -
Returns:
value setted
Throws:
ArrayUtilException

setEL

public static Object setEL(Object o,
                           int index,
                           Object value)
sets a value to a array at defined index

Parameters:
o -
index -
value -
Returns:
value setted

isEmpty

public static boolean isEmpty(List list)

isEmpty

public static boolean isEmpty(Object[] array)

isEmpty

public static boolean isEmpty(boolean[] array)

isEmpty

public static boolean isEmpty(char[] array)

isEmpty

public static boolean isEmpty(double[] array)

isEmpty

public static boolean isEmpty(long[] array)

isEmpty

public static boolean isEmpty(int[] array)

isEmpty

public static boolean isEmpty(float[] array)

isEmpty

public static boolean isEmpty(byte[] array)

size

public static int size(Object[] array)

size

public static int size(boolean[] array)

size

public static int size(char[] array)

size

public static int size(double[] array)

size

public static int size(long[] array)

size

public static int size(int[] array)

size

public static int size(float[] array)

size

public static int size(byte[] array)

toBooleanArray

public static boolean[] toBooleanArray(Object obj)
                                throws PageException
Throws:
PageException

toByteArray

public static byte[] toByteArray(Object obj)
                          throws PageException
Throws:
PageException

toShortArray

public static short[] toShortArray(Object obj)
                            throws PageException
Throws:
PageException

toIntArray

public static int[] toIntArray(Object obj)
                        throws PageException
Throws:
PageException

toNullArray

public static Object[] toNullArray(Object obj)
                            throws PageException
Throws:
PageException

toLongArray

public static long[] toLongArray(Object obj)
                          throws PageException
Throws:
PageException

toFloatArray

public static float[] toFloatArray(Object obj)
                            throws PageException
Throws:
PageException

toDoubleArray

public static double[] toDoubleArray(Object obj)
                              throws PageException
Throws:
PageException

toCharArray

public static char[] toCharArray(Object obj)
                          throws PageException
Throws:
PageException

arrayContainsIgnoreEmpty

public static int arrayContainsIgnoreEmpty(Array arr,
                                           String value,
                                           boolean ignoreCase)

toReferenceType

public static Object[] toReferenceType(Object obj)
                                throws CasterException
Throws:
CasterException

toReferenceType

public static Object[] toReferenceType(Object obj,
                                       Object[] defaultValue)

clone

public static Object[] clone(Object[] src,
                             Object[] trg)

keys

public static Object[] keys(Map map)

values

public static Object[] values(Map map)

sizeOf

public static long sizeOf(List list)

sizeOf

public static long sizeOf(Array array)

toArray

public 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

Parameters:
list -


Copyright © 2012 Railo