public class JEPContextFactory extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
addCustomFunctions(org.nfunk.jep.JEP jep,
NamedPackage... namedPackages)
Registers custom functions and operators into a given JEP object.
|
static void |
addVariables(org.nfunk.jep.JEP jep,
Map<String,Object> contextMap)
Adds all entries from the
contextMap as variables to the JEP context. |
static org.nfunk.jep.JEP |
newContext(Map<String,Object> contextMap,
boolean traverse,
boolean allowUndeclared,
boolean implicitMultiplication,
org.nfunk.jep.type.NumberFactory numberFactory,
NamedPackage... namedPackages)
Creates a new
JEP object with custom functions and operators available, a
collection of initial variables, and custom parameters. |
static org.nfunk.jep.JEP |
newContext(Map<String,Object> contextMap,
NamedPackage... namedPackages)
Creates a new
JEP object with custom functions and operators available, and a
collection of initial variables. |
static org.nfunk.jep.JEP |
newContext(NamedPackage... namedPackages)
Creates a new
JEP object with custom functions and operators available. |
public static org.nfunk.jep.JEP newContext(NamedPackage... namedPackages)
JEP object with custom functions and operators available.
For all functions available, simply pass no argument:
JEP jep = JEPContextFactory.newContext();
For the standard JEP functions only, specify the core package as parameter:
JEP jep = JEPContextFactory.newContext(NamedPackage.CORE);
For specific custom packages (in addition to the standard JEP functions), specify one or more custom package(s) as parameter:
JEP jep = JEPContextFactory.newContext(NamedPackage.STRING, NamedPackage.WEB);
namedPackages - one or more packages which functions shall be added to the JEP
context; if not specified, then all functions will be availableJEP objectpublic static org.nfunk.jep.JEP newContext(Map<String,Object> contextMap, NamedPackage... namedPackages)
JEP object with custom functions and operators available, and a
collection of initial variables.contextMap - a map of variables to be used by the evaluation context; can be
nullnamedPackages - one or more packages which functions shall be added to the JEP
context; if not specified, then all functions will be availableJEP object with a collection of initial variables availablenewContext(NamedPackage...)public static org.nfunk.jep.JEP newContext(Map<String,Object> contextMap, boolean traverse, boolean allowUndeclared, boolean implicitMultiplication, org.nfunk.jep.type.NumberFactory numberFactory, NamedPackage... namedPackages)
JEP object with custom functions and operators available, a
collection of initial variables, and custom parameters.contextMap - a map of variables to be used by the evaluation context;
can be nulltraverse - an optional to print expression trees (useful for debug)allowUndeclared - the "allow undeclared variables" optionimplicitMultiplication - the "implicit multiplication" optionnumberFactory - the number factory to be usednamedPackages - one or more packages which functions shall be added to
the JEP context; if not specified, then all functions
will be availableJEP object with custom functions and operators registerednewContext(NamedPackage...)public static void addCustomFunctions(org.nfunk.jep.JEP jep,
NamedPackage... namedPackages)
For all custom functions available, simply pass no package as argument:
JEPContextFactory.addCustomFunctions(jep);
For specific custom packages, specify one or more custom package(s) as parameter:
JEPContextFactory.addCustomFunctions(jep, NamedPackage.STRING, NamedPackage.WEB);
Although it is assumed that standard JEP functions are already available in the
specified JEP object, this method performs no action or validation on these
features.
Note: This method updates JEP comparative operators regardless of the
specified package. In other words, the comparative operators will always be enhanced
with Date object capabilities after this method call.
jep - the JEP object to which custom functions and operations will be
registerednamedPackages - one or more packages which functions shall be added to the JEP
context; if not specified, then all functions will be availablepublic static void addVariables(org.nfunk.jep.JEP jep,
Map<String,Object> contextMap)
contextMap as variables to the JEP context.jep - the JEP object to be filled with variables, not nullcontextMap - a map of variables to be used by the evaluation contextIllegalArgumentException - if the specified JEP object is nullCopyright © 2021. All rights reserved.