public class Expression extends Object
| Constructor and Description |
|---|
Expression(String expression)
Constructor for Expression
|
| Modifier and Type | Method and Description |
|---|---|
void |
assign(Binding binding)
Assign the binding to the environment preparing for evaluation
|
void |
assign(String varname,
String expression)
Assign the expression (variable or function declaration) to the variable name
supplied
|
com.fasterxml.jackson.databind.JsonNode |
evaluate(com.fasterxml.jackson.databind.JsonNode rootContext)
Generate a result form the Expression's parsed expression and variable
assignments or registered functions
|
com.fasterxml.jackson.databind.JsonNode |
evaluate(com.fasterxml.jackson.databind.JsonNode rootContext,
com.fasterxml.jackson.databind.JsonNode bindingObj)
Generate a result form the Expression's parsed expression and variable
assignments or registered functions specified in the bindings object
|
com.fasterxml.jackson.databind.JsonNode |
evaluate(com.fasterxml.jackson.databind.JsonNode rootContext,
List<Binding> bindings)
Generate a result form the Expression's parsed expression and variable
assignments or registered functions specified in the list of bindings
|
static Expression |
jsonata(String expression)
Genearte a new Expression based on evaluating the supplied expression
|
static void |
main(String[] args)
Testing the various methods based on
https://docs.jsonata.org/embedding-extending#expressionregisterfunctionname-implementation-signature
|
void |
registerFunction(String fctName,
String implementation)
Registers a function implementation (declaration) by name
|
public Expression(String expression) throws ParseException
expression - the logic to be parsed for later execution via evaluate
methodsParseExceptionpublic static Expression jsonata(String expression) throws ParseException
expression - the logic to be parsed for later execution via the evaluate
methodsParseExceptionpublic static void main(String[] args)
args - not usedpublic void assign(Binding binding)
binding - public void assign(String varname, String expression) throws ParseException
varname - name of the variable to map to a variable expression or
function declaration expressionexpression - logic to be assigned to the variable nameParseExceptionpublic com.fasterxml.jackson.databind.JsonNode evaluate(com.fasterxml.jackson.databind.JsonNode rootContext)
throws EvaluateException,
ParseException
rootContext - JSON object specifying the content used to evaluate the
expressionEvaluateExceptionParseExceptionpublic com.fasterxml.jackson.databind.JsonNode evaluate(com.fasterxml.jackson.databind.JsonNode rootContext,
List<Binding> bindings)
throws EvaluateException,
ParseException
rootContext - JSON object specifying the content used to evaluate the
expressionbindings - assignments of variable names to variable expressions or
function declarationsEvaluateExceptionParseExceptionpublic com.fasterxml.jackson.databind.JsonNode evaluate(com.fasterxml.jackson.databind.JsonNode rootContext,
com.fasterxml.jackson.databind.JsonNode bindingObj)
throws EvaluateException,
ParseException
rootContext - JSON object specifying the content used to evaluate the
expressionbindingObj - a JSON object containing the assignments of variable names
to variable expressions or function declarationsEvaluateExceptionParseExceptionpublic void registerFunction(String fctName, String implementation) throws ParseException
fctName - the name of the functionimplementation - the function declarationParseExceptionCopyright © 2019. All rights reserved.