Package uk.ac.starlink.ttools.jel
Class JELArrayFunction<I,O>
java.lang.Object
uk.ac.starlink.ttools.jel.JELArrayFunction<I,O>
Provides an array->array function in which input elements are
mapped to output elements by use of a given JEL expression.
Instances of this class are not threadsafe.
- Since:
- 23 Mar 2021
- Author:
- Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This public class is an implementation detail, not intended for external use. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
JELArrayFunction
public JELArrayFunction(String ivarName, String xvarName, String fexpr, Class<I> inClazz, Class<O> outClazz) throws gnu.jel.CompilationException Constructor.- Parameters:
ivarName
- name of the array index variable (0-based)xvarName
- name of the array element variable (for instance "x")fexpr
- text of expression giving the function value, in terms ofxvarname
(for instance "x+1")inClazz
- type of input array; must be an array type of primitive or object elementsoutClazz
- type of output array; if not known, Object.class may be given, and the output type will be determined from the expression- Throws:
gnu.jel.CompilationException
-
-
Method Details
-
evaluate
Evaluates this expression. Elements for which the evaluation failed are given some type-dependent default value, such as NaN, null, or zero.- Parameters:
inArray
- input array- Returns:
- outArray output array, same length as input
-
evaluate
public static <I> Object evaluate(String ivarName, String xvarName, String fexpr, I inArray) throws gnu.jel.CompilationException Utility method to create and use an array function in one go.- Parameters:
ivarName
- name of the array index variable (for instance "i")xvarName
- name of the array element variable (for instance "x")fexpr
- text of expression giving the function value, in terms ofxvarname
(for instance "x+1")inArray
- input array- Returns:
- output array, same length as input
- Throws:
gnu.jel.CompilationException
-