Package uk.ac.starlink.ttools.jel
Class JELArrayFunction<I,O>
- java.lang.Object
-
- uk.ac.starlink.ttools.jel.JELArrayFunction<I,O>
-
public class JELArrayFunction<I,O> extends java.lang.ObjectProvides 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 Classes Modifier and Type Class Description static classJELArrayFunction.XResolverThis public class is an implementation detail, not intended for external use.
-
Constructor Summary
Constructors Constructor Description JELArrayFunction(java.lang.String ivarName, java.lang.String xvarName, java.lang.String fexpr, java.lang.Class<I> inClazz, java.lang.Class<O> outClazz)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Oevaluate(I inArray)Evaluates this expression.static <I> java.lang.Objectevaluate(java.lang.String ivarName, java.lang.String xvarName, java.lang.String fexpr, I inArray)Utility method to create and use an array function in one go.
-
-
-
Constructor Detail
-
JELArrayFunction
public JELArrayFunction(java.lang.String ivarName, java.lang.String xvarName, java.lang.String fexpr, java.lang.Class<I> inClazz, java.lang.Class<O> outClazz) throws gnu.jel.CompilationExceptionConstructor.- 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 Detail
-
evaluate
public O evaluate(I inArray)
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> java.lang.Object evaluate(java.lang.String ivarName, java.lang.String xvarName, java.lang.String fexpr, I inArray) throws gnu.jel.CompilationExceptionUtility 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
-
-