Class JexlArrayBuilder
java.lang.Object
net.simplace.core.jexl.builder.JexlArrayBuilder
Array functions for JEXL rules (namespace
array:), used like
array:Double(size, default) array:Integer(size, default) array:Char(size, default) array:Double(size) array:Integer(size) array:Char(size) array:clone(sourceArray) array:zip(keyArray, valueArray) array:unzipKeys(sourceArray) array:unzipValues(sourceArray) array:calc(sourceArray, algorithm[+-*\/^] secondPartner) array:sum(sourceArray) array:avg(sourceArray) array:min(sourceArray) array:max(sourceArray) array:sum(sourceArray, startIndex[1...n], endIndex[1...n]) array:avg(sourceArray, startIndex[1...n], endIndex[1...n]) array:min(sourceArray, startIndex[1...n], endIndex[1...n]) array:max(sourceArray, startIndex[1...n], endIndex[1...n]) array:progressivesum(sourceArray)Numeric functions support Double[] and Integer[] arrays.
- Author:
- Andreas Enders
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectUsed in JEXL likearray:avg(sourceArray).static ObjectUsed in JEXL likearray:avg(sourceArray, startIndex, endIndex): the mean of a range; the range is limited to the array, the sum is divided by the number of elements actually used (Integer[]: truncated).static ObjectUsed in JEXL likearray:calc(firstArray, '*', secondPartner): applies an operator element-wise.static String[]Char(int aSize) Used in JEXL likearray:Char(size).static String[]Used in JEXL likearray:Char(size, default).static ObjectUsed in JEXL likearray:clone(sourceArray).static Double[]Double(int aSize) Used in JEXL likearray:Double(size).static Double[]Used in JEXL likearray:Double(size, default).static Integer[]Integer(int aSize) Used in JEXL likearray:Integer(size).static Integer[]Used in JEXL likearray:Integer(size, default).static ObjectUsed in JEXL likearray:max(sourceArray).static ObjectUsed in JEXL likearray:max(sourceArray, startIndex, endIndex): the maximum of a range; the range is limited to the array.static ObjectUsed in JEXL likearray:min(sourceArray).static ObjectUsed in JEXL likearray:min(sourceArray, startIndex, endIndex): the minimum of a range; the range is limited to the array.static Objectprogressivesum(Object anArray) Used in JEXL likearray:progressivesum(sourceArray): cumulative sum.static ObjectUsed in JEXL likearray:sum(sourceArray).static ObjectUsed in JEXL likearray:sum(sourceArray, startIndex, endIndex): the sum of a range; the range is limited to the array.static ObjectUsed in JEXL likearray:unzipKeys(sourceArray); the inverse ofzip(Object[], Object[]).static ObjectunzipValues(Object aSourceArray) Used in JEXL likearray:unzipValues(sourceArray); the inverse ofzip(Object[], Object[]).static ObjectUsed in JEXL likearray:zip(keyArray, valueArray): merges two arrays of the same type alternately.
-
Constructor Details
-
JexlArrayBuilder
public JexlArrayBuilder()
-
-
Method Details
-
clone
-
Double
Used in JEXL likearray:Double(size).- Parameters:
aSize- length of the array- Returns:
- a new Double[] filled with
null
-
Integer
Used in JEXL likearray:Integer(size).- Parameters:
aSize- length of the array- Returns:
- a new Integer[] filled with
null
-
Char
Used in JEXL likearray:Char(size).- Parameters:
aSize- length of the array- Returns:
- a new String[] filled with
null
-
Double
-
Integer
-
Char
-
unzipKeys
Used in JEXL likearray:unzipKeys(sourceArray); the inverse ofzip(Object[], Object[]).- Parameters:
aSourceArray- a zipped Double[], Integer[] or String[] array{key1, value1, key2, value2, ...}- Returns:
- the keys (elements with even index), or
nullfor other types (a warning is logged)
-
unzipValues
Used in JEXL likearray:unzipValues(sourceArray); the inverse ofzip(Object[], Object[]).- Parameters:
aSourceArray- a zipped Double[], Integer[] or String[] array{key1, value1, key2, value2, ...}- Returns:
- the values (elements with odd index), or
nullfor other types (a warning is logged)
-
zip
Used in JEXL likearray:zip(keyArray, valueArray): merges two arrays of the same type alternately.- Parameters:
aKeysSourceArray- the keys (Double[], Integer[] or String[])aValuesSourceArray- the values, same type and at least as long as the keys- Returns:
{key1, value1, key2, value2, ...}, ornullfor other or mixed types (a warning is logged)
-
calc
Used in JEXL likearray:calc(firstArray, '*', secondPartner): applies an operator element-wise. Errors (also an unknown operator) are logged; elements not yet calculated then keep their original value.- Parameters:
aFirstArray- a Double[] or Integer[] array (not changed)aRule- the operator:*,+,-,/or^(for Integer[] the power is truncated to int)aSecondPartner- an array of the same type (element-wise) or a single number of the same type- Returns:
- a new array (same type and size) with the results, or
nullfor other types
-
sum
-
progressivesum
-
min
-
max
-
avg
-
sum
Used in JEXL likearray:sum(sourceArray, startIndex, endIndex): the sum of a range; the range is limited to the array.- Parameters:
anArray- a Double[] or Integer[] arrayaStartIndex- first element (1-based, inclusive)aEndIndex- last element (1-based, inclusive)- Returns:
- the sum of the range, or
nullfor other types
-
min
Used in JEXL likearray:min(sourceArray, startIndex, endIndex): the minimum of a range; the range is limited to the array.- Parameters:
anArray- a Double[] or Integer[] arrayaStartIndex- first element (1-based, inclusive)aEndIndex- last element (1-based, inclusive)- Returns:
- the minimum of the range, or
nullfor other types
-
max
Used in JEXL likearray:max(sourceArray, startIndex, endIndex): the maximum of a range; the range is limited to the array.- Parameters:
anArray- a Double[] or Integer[] arrayaStartIndex- first element (1-based, inclusive)aEndIndex- last element (1-based, inclusive)- Returns:
- the maximum of the range, or
nullfor other types
-
avg
Used in JEXL likearray:avg(sourceArray, startIndex, endIndex): the mean of a range; the range is limited to the array, the sum is divided by the number of elements actually used (Integer[]: truncated).- Parameters:
anArray- a Double[] or Integer[] arrayaStartIndex- first element (1-based, inclusive)aEndIndex- last element (1-based, inclusive)- Returns:
- the mean of the range, or
nullfor other types
-