public final class JexlOptions extends Object
This interface replaces the now deprecated JexlEngine.Options.
Constructor and Description |
---|
JexlOptions()
Default ctor.
|
Modifier and Type | Method and Description |
---|---|
JexlOptions |
copy()
Creates a copy of this instance.
|
Collection<String> |
getImports()
Gets the optional set of imported packages.
|
MathContext |
getMathContext()
The MathContext instance used for +,-,/,*,% operations on big decimals.
|
int |
getMathScale()
The BigDecimal scale used for comparison and coercion operations.
|
Map<String,Object> |
getNamespaces()
Gets the optional map of namespaces.
|
boolean |
isAntish()
Checks whether evaluation will attempt resolving antish variable names.
|
boolean |
isCancellable()
Checks whether evaluation will throw JexlException.Cancel (true) or
return null (false) if interrupted.
|
boolean |
isLexical()
Checks whether runtime variable scope is lexical.
|
boolean |
isLexicalShade()
Checks whether local variables shade global ones.
|
boolean |
isSafe()
Checks whether the engine considers null in navigation expression as
errors during evaluation..
|
boolean |
isSharedInstance() |
boolean |
isSilent()
Checks whether the engine will throw a
JexlException when an
error is encountered during evaluation. |
boolean |
isStrict()
Checks whether the engine considers unknown variables, methods and
constructors as errors during evaluation.
|
boolean |
isStrictArithmetic()
Checks whether the arithmetic triggers errors during evaluation when null
is used as an operand.
|
static int |
parseFlags(int initial,
String... flags)
Parses flags by name.
|
JexlOptions |
set(JexlEngine jexl)
Set options from engine.
|
JexlOptions |
set(JexlOptions src)
Set options from options.
|
void |
setAntish(boolean flag)
Sets whether the engine will attempt solving antish variable names from
context.
|
void |
setCancellable(boolean flag)
Sets whether the engine will throw JexlException.Cancel (true) or return
null (false) when interrupted during evaluation.
|
static void |
setDefaultFlags(String... flags)
Sets the default (static, shared) option flags.
|
void |
setFlags(String... opts)
Sets this option flags using the +/- syntax.
|
void |
setImports(Collection<String> imports)
Sets the optional set of imports.
|
void |
setLexical(boolean flag)
Sets whether the engine uses a strict block lexical scope during
evaluation.
|
void |
setLexicalShade(boolean flag)
Sets whether the engine strictly shades global variables.
|
void |
setMathContext(MathContext mcontext)
Sets the arithmetic math context.
|
void |
setMathScale(int mscale)
Sets the arithmetic math scale.
|
void |
setNamespaces(Map<String,Object> ns)
Sets the optional map of namespaces.
|
void |
setSafe(boolean flag)
Sets whether the engine considers null in navigation expression as null or as errors
during evaluation.
|
void |
setSharedInstance(boolean flag)
Whether these options are immutable at runtime.
|
void |
setSilent(boolean flag)
Sets whether the engine will throw a
JexlException when an error
is encountered during evaluation. |
void |
setStrict(boolean flag)
Sets whether the engine considers unknown variables, methods and
constructors as errors during evaluation.
|
void |
setStrictArithmetic(boolean stricta)
Sets the strict arithmetic flag.
|
String |
toString() |
public JexlOptions()
public static void setDefaultFlags(String... flags)
Whenever possible, we recommend using JexlBuilder methods to unambiguously instantiate a JEXL engine; this method should only be used for testing / validation.
A '+flag' or 'flag' will set the option named 'flag' as true, '-flag' set as false. The possible flag names are: cancellable, strict, silent, safe, lexical, antish, lexicalShade
Calling JexlBuilder.setDefaultOptions("+safe") once before JEXL engine creation may ease validating JEXL3.2 in your environment.
flags
- the flags to setpublic static int parseFlags(int initial, String... flags)
A '+flag' or 'flag' will set flag as true, '-flag' set as false. The possible flag names are: cancellable, strict, silent, safe, lexical, antish, lexicalShade
initial
- the initial mask stateflags
- the flags to setpublic void setFlags(String... opts)
opts
- the option flagspublic MathContext getMathContext()
public int getMathScale()
public boolean isAntish()
public boolean isCancellable()
public boolean isLexical()
If true, lexical scope applies to local variables and parameters. Redefining a variable in the same lexical unit will generate errors.
public boolean isLexicalShade()
After a symbol is defined as local, dereferencing it outside its scope will trigger an error instead of seeking a global variable of the same name. To further reduce potential naming ambiguity errors, global variables (ie non-local) must be declared to be assigned (@link JexlContext#has(String) ) when this flag is on; attempting to set an undeclared global variables will raise an error.
public boolean isSafe()
public boolean isSilent()
JexlException
when an
error is encountered during evaluation.public boolean isStrict()
public boolean isStrictArithmetic()
public void setAntish(boolean flag)
flag
- true if antish variables are solved, false otherwisepublic void setCancellable(boolean flag)
flag
- true when cancellable, false otherwisepublic void setLexical(boolean flag)
flag
- true if lexical scope is used, false otherwisepublic void setLexicalShade(boolean flag)
flag
- true if creation is allowed, false otherwisepublic void setMathContext(MathContext mcontext)
mcontext
- the contextpublic void setMathScale(int mscale)
mscale
- the scalepublic void setSafe(boolean flag)
If safe, encountering null during a navigation expression - dereferencing a method or a field through a null object or property - will not be considered an error but evaluated as null. It is recommended to use setSafe(false) as an explicit default.
flag
- true if safe, false otherwisepublic void setSilent(boolean flag)
JexlException
when an error
is encountered during evaluation.flag
- true if silent, false otherwisepublic void setStrict(boolean flag)
flag
- true if strict, false otherwisepublic void setStrictArithmetic(boolean stricta)
stricta
- true or falsepublic void setSharedInstance(boolean flag)
Expert mode; allows instance handled through context to be shared instead of copied.
flag
- true if shared, false if notpublic boolean isSharedInstance()
public JexlOptions set(JexlEngine jexl)
jexl
- the enginepublic JexlOptions set(JexlOptions src)
src
- the optionspublic Map<String,Object> getNamespaces()
public void setNamespaces(Map<String,Object> ns)
ns
- a namespaces mappublic Collection<String> getImports()
public void setImports(Collection<String> imports)
imports
- the imported packagespublic JexlOptions copy()
Copyright © 2001–2022 The Apache Software Foundation. All rights reserved.