Class Engine
- java.lang.Object
-
- org.apache.commons.jexl3.JexlEngine
-
- org.apache.commons.jexl3.internal.Engine
-
- All Implemented Interfaces:
JexlUberspect.ConstantResolverFactory
- Direct Known Subclasses:
Engine32
public class Engine extends JexlEngine implements JexlUberspect.ConstantResolverFactory
A JexlEngine implementation.- Since:
- 2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classEngine.UberspectHolderGets the default instance of Uberspect.protected static classEngine.VarCollectorUtility class to collect variables.-
Nested classes/interfaces inherited from class org.apache.commons.jexl3.JexlEngine
JexlEngine.EmptyContext, JexlEngine.EmptyNamespaceResolver, JexlEngine.Options
-
-
Field Summary
Fields Modifier and Type Field Description protected JexlArithmeticarithmeticTheJexlArithmeticinstance.protected JexlCache<Source,java.lang.Object>cacheThe expression cache.protected intcacheThresholdThe expression max length to hit the cache.protected booleancancellableWhether expressions evaluated by this engine will throw JexlException.Cancel (true) or return null (false) when interrupted.protected java.nio.charset.CharsetcharsetThe default charset.protected FqcnResolverclassNameSolverThe default class name resolver.protected intcollectModeCollect all or only dot references.protected booleandebugWhether error messages will carry debugging information.protected JexlFeaturesexpressionFeaturesThe set of default expression parsing features.protected java.util.Map<java.lang.String,java.lang.Object>functionsThe map of 'prefix:function' to object implementing the namespaces.protected org.apache.commons.logging.LogloggerThe Log to which all JexlEngine messages will be logged.protected MetaCachemetaCacheThe set of caches created by this engine.protected JexlOptionsoptionsA cached version of the options.protected JexlScriptParserparserTheParser; when parsing expressions, this engine uses the parser if it is not already in use otherwise it will create a new temporary one.protected java.util.function.Supplier<JexlScriptParser>parserFactoryThe Jexl script parser factory.protected java.util.concurrent.atomic.AtomicBooleanparsingThe atomic parsing flag; true whilst parsing.protected static JexlFeaturesPROPERTY_FEATURESThe features allowed for property set/get methods.protected booleansafeWhether this engine considers null in navigation expression as errors.protected JexlFeaturesscriptFeaturesThe set of default script parsing features.protected booleansilentWhether expressions evaluated by this engine will throw exceptions (false) or return null (true) on errors.protected intstackOverflowThe maximum stack height.protected booleanstrictWhether this engine considers unknown variables, methods and constructors as errors.protected JexlUberspectuberspectThe JexlUberspect instance.-
Fields inherited from class org.apache.commons.jexl3.JexlEngine
CONTEXT, DEFAULT_FEATURES, EMPTY_CONTEXT, EMPTY_NS, ENGINE, TRY_FAILED
-
-
Constructor Summary
Constructors Constructor Description Engine()Creates an engine with default arguments.Engine(JexlBuilder conf)Creates a JEXL engine using the providedJexlBuilder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclearCache()Clears the expression cache.protected JexlCache<Source,java.lang.Object>createCache(int capacity)Creates a new cache instance.JexlUberspect.ClassConstantResolvercreateConstantResolver(java.util.Collection<java.lang.String> imports)Creates a constant resolver.ScriptcreateExpression(JexlInfo info, java.lang.String expression)Creates an JexlExpression from a String containing valid JEXL syntax.protected InterpretercreateInterpreter(JexlContext context, Frame frame, JexlOptions opts)Creates an interpreter.TemplateEnginecreateJxltEngine(boolean noScript, int cacheSize, char immediate, char deferred)Creates a new instance ofJxltEngineusing this engine.ScriptcreateScript(JexlFeatures features, JexlInfo info, java.lang.String scriptText, java.lang.String... names)Creates a JexlScript from a String containing valid JEXL syntax.protected InterpretercreateTemplateInterpreter(TemplateInterpreter.Arguments args)Creates a template interpreter.protected java.lang.ObjectdoCreateInstance(java.lang.Object clazz, java.lang.Object... args)Creates a new instance of an object using the most appropriate constructor based on the arguments.protected JexlOptionsevalOptions(JexlContext context)Extracts the engine evaluation options from context if available, the engine options otherwise.private JexlOptionsevalOptions(JexlEngine.Options opts)Obsolete version of options evaluation.protected JexlOptionsevalOptions(ASTJexlScript script, JexlContext context)Compute a script options for evaluation.JexlArithmeticgetArithmetic()Gets this engine underlyingJexlArithmetic.(package private) JexlCache<Source,java.lang.Object>getCache()java.nio.charset.CharsetgetCharset()Gets the charset used for parsing.protected java.lang.String[]getLocalVariables(JexlScript script)Deprecated.3.6.1(package private) java.lang.ObjectgetNamespace(java.lang.String name)Solves a namespace using this engine map of functions.protected java.lang.String[]getParameters(JexlScript script)Deprecated.3.6.1java.lang.ObjectgetProperty(java.lang.Object bean, java.lang.String expr)Accesses properties of a bean using an expression.java.lang.ObjectgetProperty(JexlContext context, java.lang.Object bean, java.lang.String expr)Accesses properties of a bean using an expression.JexlUberspectgetUberspect()Gets this engine underlyingJexlUberspect.static UberspectgetUberspect(org.apache.commons.logging.Log logger, JexlUberspect.ResolverStrategy strategy)Deprecated.3.3static UberspectgetUberspect(org.apache.commons.logging.Log logger, JexlUberspect.ResolverStrategy strategy, JexlPermissions permissions)Gets the default instance of Uberspect.protected java.util.Set<java.util.List<java.lang.String>>getVariables(ASTJexlScript script)Gets the list of variables accessed by a script.protected voidgetVariables(ASTJexlScript script, JexlNode node, Engine.VarCollector collector)Fills up the list of variables accessed by a node.java.lang.ObjectinvokeMethod(java.lang.Object obj, java.lang.String meth, java.lang.Object... args)Invokes an object's method by name and arguments.booleanisCancellable()Checks whether this engine will throw JexlException.Cancel (true) or return null (false) when interrupted during an execution.booleanisDebug()Checks whether this engine is in debug mode.booleanisSilent()Checks whether this engine throws JexlException during evaluation.booleanisStrict()Checks whether this engine considers unknown variables, methods, functions and constructors as errors.protected ASTJexlScriptjxltParse(JexlInfo info, boolean expr, java.lang.String src, Scope scope)Parses a Jexl expression or script.<T> TnewInstance(java.lang.Class<? extends T> clazz, java.lang.Object... args)Creates a new instance of an object using the most appropriate constructor based on the arguments.java.lang.ObjectnewInstance(java.lang.String clazz, java.lang.Object... args)Creates a new instance of an object using the most appropriate constructor based on the arguments.private static <T> Toption(T conf, T def)Solves an optional option.JexlOptionsoptionsSet(JexlOptions opts)Sets options from this engine options.protected ASTJexlScriptparse(JexlInfo info, JexlFeatures parsingf, java.lang.String src, Scope scope)Parses an expression.private voidprocessPragmaModule(java.util.Map<java.lang.String,java.lang.Object> ns, java.lang.String key, java.lang.Object value, JexlInfo info, JexlContext context)Processes jexl.module.ns pragma.private voidprocessPragmaNamespace(java.util.Map<java.lang.String,java.lang.Object> ns, java.lang.String key, java.lang.Object value)Processes jexl.namespace.ns pragma.protected voidprocessPragmas(ASTJexlScript script, JexlContext context, JexlOptions opts)Processes a script pragmas.protected JexlEngineputThreadEngine(JexlEngine jexl)Swaps the current thread local engine.protected JexlContext.ThreadLocalputThreadLocal(JexlContext.ThreadLocal tls)Swaps the current thread local context.voidsetClassLoader(java.lang.ClassLoader classLoader)Sets the class loader used to discover classes in 'new' expressions.voidsetProperty(java.lang.Object bean, java.lang.String expr, java.lang.Object value)Assign properties of a bean using an expression.voidsetProperty(JexlContext context, java.lang.Object bean, java.lang.String expr, java.lang.Object value)Assign properties of a bean using an expression.protected java.lang.StringtrimSource(java.lang.CharSequence str)Trims the source from front and ending spaces.protected Engine.VarCollectorvarCollector()Creates a collector instance.private voidwithValueSet(java.lang.Object value, java.util.function.Consumer<java.lang.Object> consumer)Utility to deal with single value or set of values.-
Methods inherited from class org.apache.commons.jexl3.JexlEngine
createExpression, createInfo, createInfo, createJxltEngine, createJxltEngine, createScript, createScript, createScript, createScript, createScript, createScript, createScript, createScript, createScript, getThreadContext, getThreadEngine, readSource, readSource, setThreadContext, toString
-
-
-
-
Field Detail
-
PROPERTY_FEATURES
protected static final JexlFeatures PROPERTY_FEATURES
The features allowed for property set/get methods.
-
logger
protected final org.apache.commons.logging.Log logger
The Log to which all JexlEngine messages will be logged.
-
uberspect
protected final JexlUberspect uberspect
The JexlUberspect instance.
-
arithmetic
protected final JexlArithmetic arithmetic
TheJexlArithmeticinstance.
-
functions
protected final java.util.Map<java.lang.String,java.lang.Object> functions
The map of 'prefix:function' to object implementing the namespaces.
-
classNameSolver
protected final FqcnResolver classNameSolver
The default class name resolver.
-
stackOverflow
protected final int stackOverflow
The maximum stack height.
-
strict
protected final boolean strict
Whether this engine considers unknown variables, methods and constructors as errors.
-
safe
protected final boolean safe
Whether this engine considers null in navigation expression as errors.
-
silent
protected final boolean silent
Whether expressions evaluated by this engine will throw exceptions (false) or return null (true) on errors. Default is false.
-
cancellable
protected final boolean cancellable
Whether expressions evaluated by this engine will throw JexlException.Cancel (true) or return null (false) when interrupted. Default is true when not silent and strict.
-
debug
protected final boolean debug
Whether error messages will carry debugging information.
-
scriptFeatures
protected final JexlFeatures scriptFeatures
The set of default script parsing features.
-
expressionFeatures
protected final JexlFeatures expressionFeatures
The set of default expression parsing features.
-
charset
protected final java.nio.charset.Charset charset
The default charset.
-
parserFactory
protected final java.util.function.Supplier<JexlScriptParser> parserFactory
The Jexl script parser factory.
-
parsing
protected final java.util.concurrent.atomic.AtomicBoolean parsing
The atomic parsing flag; true whilst parsing.
-
parser
protected final JexlScriptParser parser
TheParser; when parsing expressions, this engine uses the parser if it is not already in use otherwise it will create a new temporary one.
-
cacheThreshold
protected final int cacheThreshold
The expression max length to hit the cache.
-
collectMode
protected final int collectMode
Collect all or only dot references.
-
options
protected final JexlOptions options
A cached version of the options.
-
metaCache
protected final MetaCache metaCache
The set of caches created by this engine.Caches are soft-referenced by the engine so they can be cleaned on class loader change.
-
-
Constructor Detail
-
Engine
public Engine()
Creates an engine with default arguments.
-
Engine
public Engine(JexlBuilder conf)
Creates a JEXL engine using the providedJexlBuilder.- Parameters:
conf- the builder
-
-
Method Detail
-
getUberspect
@Deprecated public static Uberspect getUberspect(org.apache.commons.logging.Log logger, JexlUberspect.ResolverStrategy strategy)
Deprecated.3.3- Parameters:
logger- the loggerstrategy- the strategy- Returns:
- an Uberspect instance
-
getUberspect
public static Uberspect getUberspect(org.apache.commons.logging.Log logger, JexlUberspect.ResolverStrategy strategy, JexlPermissions permissions)
Gets the default instance of Uberspect.This is lazily initialized to avoid building a default instance if there is no use for it.
The main reason for not using the default Uberspect instance are: - Using a (low level) introspector created with a given logger instead of the default one
- Using a (restricted) set of permissions
- Parameters:
logger- the logger to use for the underlying Uberspectstrategy- the property resolver strategypermissions- the introspection permissions- Returns:
- Uberspect the default uberspector instance.
- Since:
- 3.3
-
option
private static <T> T option(T conf, T def)Solves an optional option.- Type Parameters:
T- the option type- Parameters:
conf- the option as configured, may be nulldef- the default value if null, shall not be null- Returns:
- conf or def
-
clearCache
public void clearCache()
Description copied from class:JexlEngineClears the expression cache.- Specified by:
clearCachein classJexlEngine
-
createExpression
public Script createExpression(JexlInfo info, java.lang.String expression)
Description copied from class:JexlEngineCreates an JexlExpression from a String containing valid JEXL syntax. This method parses the expression which must contain either a reference or an expression.- Specified by:
createExpressionin classJexlEngine- Parameters:
info- An info structure to carry debugging information if neededexpression- A String containing valid JEXL syntax- Returns:
- An
JexlExpressionwhich can be evaluated using aJexlContext
-
createInterpreter
protected Interpreter createInterpreter(JexlContext context, Frame frame, JexlOptions opts)
Creates an interpreter.- Parameters:
context- a JexlContext; if null, the empty context is used instead.frame- the interpreter frameopts- the evaluation options- Returns:
- an Interpreter
-
createJxltEngine
public TemplateEngine createJxltEngine(boolean noScript, int cacheSize, char immediate, char deferred)
Description copied from class:JexlEngineCreates a new instance ofJxltEngineusing this engine.- Specified by:
createJxltEnginein classJexlEngine- Parameters:
noScript- whether the JxltEngine only allows JEXL expressions or scriptscacheSize- the number of expressions in this cache, default is 256immediate- the immediate template expression character, default is '$'deferred- the deferred template expression character, default is '#'- Returns:
- a JEXL Template engine
-
createScript
public Script createScript(JexlFeatures features, JexlInfo info, java.lang.String scriptText, java.lang.String... names)
Description copied from class:JexlEngineCreates a JexlScript from a String containing valid JEXL syntax. This method parses the script and validates the syntax.- Specified by:
createScriptin classJexlEngine- Parameters:
features- A set of features that will be enforced during parsinginfo- An info structure to carry debugging information if neededscriptText- A string containing valid JEXL syntaxnames- The script parameter names used during parsing; a corresponding array of arguments containing values should be used during evaluation- Returns:
- A
JexlScriptwhich can be executed using aJexlContext
-
createTemplateInterpreter
protected Interpreter createTemplateInterpreter(TemplateInterpreter.Arguments args)
Creates a template interpreter.- Parameters:
args- the template interpreter arguments
-
doCreateInstance
protected java.lang.Object doCreateInstance(java.lang.Object clazz, java.lang.Object... args)Creates a new instance of an object using the most appropriate constructor based on the arguments.- Parameters:
clazz- the class to instantiateargs- the constructor arguments- Returns:
- the created object instance or null on failure when silent
-
evalOptions
protected JexlOptions evalOptions(ASTJexlScript script, JexlContext context)
Compute a script options for evaluation.This calls processPragma(...).
- Parameters:
script- the scriptcontext- the context- Returns:
- the options
-
evalOptions
protected JexlOptions evalOptions(JexlContext context)
Extracts the engine evaluation options from context if available, the engine options otherwise.If the context is an options handle and the handled options shared instance flag is false, this method creates a copy of the options making them immutable during execution.
- Parameters:
context- the context- Returns:
- the options if any
-
evalOptions
private JexlOptions evalOptions(JexlEngine.Options opts)
Obsolete version of options evaluation.- Parameters:
opts- the obsolete instance of options- Returns:
- the newer class of options
-
getArithmetic
public JexlArithmetic getArithmetic()
Description copied from class:JexlEngineGets this engine underlyingJexlArithmetic.- Specified by:
getArithmeticin classJexlEngine- Returns:
- the arithmetic
-
getCharset
public java.nio.charset.Charset getCharset()
Description copied from class:JexlEngineGets the charset used for parsing.- Specified by:
getCharsetin classJexlEngine- Returns:
- the charset
-
getLocalVariables
@Deprecated protected java.lang.String[] getLocalVariables(JexlScript script)
Deprecated.3.6.1Gets the array of local variable from a script.- Parameters:
script- the script- Returns:
- the local variables array which may be empty (but not null) if no local variables were defined
- Since:
- 3.0
-
getNamespace
final java.lang.Object getNamespace(java.lang.String name)
Solves a namespace using this engine map of functions.- Parameters:
name- the namespoce name- Returns:
- the object associated
-
getParameters
@Deprecated protected java.lang.String[] getParameters(JexlScript script)
Deprecated.3.6.1Gets the array of parameters from a script.- Parameters:
script- the script- Returns:
- the parameters which may be empty (but not null) if no parameters were defined
- Since:
- 3.0
-
getProperty
public java.lang.Object getProperty(JexlContext context, java.lang.Object bean, java.lang.String expr)
Description copied from class:JexlEngineAccesses properties of a bean using an expression.If the JEXL engine is silent, errors will be logged through its logger as warning.
- Specified by:
getPropertyin classJexlEngine- Parameters:
context- the evaluation contextbean- the bean to get properties fromexpr- the property expression- Returns:
- the value of the property
-
getProperty
public java.lang.Object getProperty(java.lang.Object bean, java.lang.String expr)Description copied from class:JexlEngineAccesses properties of a bean using an expression.jexl.get(myobject, "foo.bar"); should equate to myobject.getFoo().getBar(); (or myobject.getFoo().get("bar"))
If the JEXL engine is silent, errors will be logged through its logger as warning.
- Specified by:
getPropertyin classJexlEngine- Parameters:
bean- the bean to get properties fromexpr- the property expression- Returns:
- the value of the property
-
getUberspect
public JexlUberspect getUberspect()
Description copied from class:JexlEngineGets this engine underlyingJexlUberspect.- Specified by:
getUberspectin classJexlEngine- Returns:
- the uberspect
-
getVariables
protected java.util.Set<java.util.List<java.lang.String>> getVariables(ASTJexlScript script)
Gets the list of variables accessed by a script.This method will visit all nodes of a script and extract all variables whether they are written in 'dot' or 'bracketed' notation. (a.b is equivalent to a['b']).
- Parameters:
script- the script- Returns:
- the set of variables, each as a list of strings (ant-ish variables use more than 1 string) or the empty set if no variables are used
-
getVariables
protected void getVariables(ASTJexlScript script, JexlNode node, Engine.VarCollector collector)
Fills up the list of variables accessed by a node.- Parameters:
script- the owning scriptnode- the nodecollector- the variable collector
-
invokeMethod
public java.lang.Object invokeMethod(java.lang.Object obj, java.lang.String meth, java.lang.Object... args)Description copied from class:JexlEngineInvokes an object's method by name and arguments.- Specified by:
invokeMethodin classJexlEngine- Parameters:
obj- the method's invoker objectmeth- the method's nameargs- the method's arguments- Returns:
- the method returned value or null if it failed and engine is silent
-
isCancellable
public boolean isCancellable()
Description copied from class:JexlEngineChecks whether this engine will throw JexlException.Cancel (true) or return null (false) when interrupted during an execution.- Specified by:
isCancellablein classJexlEngine- Returns:
- true if cancellable, false otherwise
-
isDebug
public boolean isDebug()
Description copied from class:JexlEngineChecks whether this engine is in debug mode.If set to true which is the default, when calling
JexlEngine.newInstance(java.lang.Class<? extends T>, java.lang.Object...),JexlEngine.invokeMethod(java.lang.Object, java.lang.String, java.lang.Object...),JexlEngine.setProperty(org.apache.commons.jexl3.JexlContext, java.lang.Object, java.lang.String, java.lang.Object),JexlEngine.getProperty(org.apache.commons.jexl3.JexlContext, java.lang.Object, java.lang.String)or if noJexlInfoinstance is provided when creating a script and an error occurs during execution, the error message will contain the stack-trace (class/method/line) location of the caller for the methods, of the creator for the script; this may not be desirable in rare environments where vulnerability assessments are strict.- Specified by:
isDebugin classJexlEngine- Returns:
- true if debug is on, false otherwise
- See Also:
JexlBuilder.debug(boolean)
-
isSilent
public boolean isSilent()
Description copied from class:JexlEngineChecks whether this engine throws JexlException during evaluation.- Specified by:
isSilentin classJexlEngine- Returns:
- true if silent, false (default) otherwise
-
isStrict
public boolean isStrict()
Description copied from class:JexlEngineChecks whether this engine considers unknown variables, methods, functions and constructors as errors.- Specified by:
isStrictin classJexlEngine- Returns:
- true if strict, false otherwise
-
newInstance
public <T> T newInstance(java.lang.Class<? extends T> clazz, java.lang.Object... args)Description copied from class:JexlEngineCreates a new instance of an object using the most appropriate constructor based on the arguments.- Specified by:
newInstancein classJexlEngine- Type Parameters:
T- the type of object- Parameters:
clazz- the class to instantiateargs- the constructor arguments- Returns:
- the created object instance or null on failure when silent
-
newInstance
public java.lang.Object newInstance(java.lang.String clazz, java.lang.Object... args)Description copied from class:JexlEngineCreates a new instance of an object using the most appropriate constructor based on the arguments.- Specified by:
newInstancein classJexlEngine- Parameters:
clazz- the name of the class to instantiate resolved through this engine's class loaderargs- the constructor arguments- Returns:
- the created object instance or null on failure when silent
-
createConstantResolver
public JexlUberspect.ClassConstantResolver createConstantResolver(java.util.Collection<java.lang.String> imports)
Description copied from interface:JexlUberspect.ConstantResolverFactoryCreates a constant resolver.- Specified by:
createConstantResolverin interfaceJexlUberspect.ConstantResolverFactory- Parameters:
imports- the collection of imports (packages and classes) to use- Returns:
- a constant resolver
-
optionsSet
public JexlOptions optionsSet(JexlOptions opts)
Sets options from this engine options.- Parameters:
opts- the options to set- Returns:
- the options
-
parse
protected ASTJexlScript parse(JexlInfo info, JexlFeatures parsingf, java.lang.String src, Scope scope)
Parses an expression.- Parameters:
info- information structureparsingf- the set of parsing featuressrc- the expression to parsescope- the script frame- Returns:
- the parsed tree
- Throws:
JexlException- if any error occurred during parsing
-
jxltParse
protected ASTJexlScript jxltParse(JexlInfo info, boolean expr, java.lang.String src, Scope scope)
Parses a Jexl expression or script.- Parameters:
info- the JexlInfoexpr- whether to parse an expression or a scriptsrc- the source to parsescope- the scope, maybe null- Returns:
- the parsed tree
-
processPragmaModule
private void processPragmaModule(java.util.Map<java.lang.String,java.lang.Object> ns, java.lang.String key, java.lang.Object value, JexlInfo info, JexlContext context)Processes jexl.module.ns pragma.If the value is empty, the namespace will be cleared which may be useful to debug and force unload the object bound to the namespace.
- Parameters:
ns- the namespace mapkey- the key the namespacevalue- the value, ie the expression to evaluate and its result bound to the namespaceinfo- the expression infocontext- the value-as-expression evaluation context
-
processPragmaNamespace
private void processPragmaNamespace(java.util.Map<java.lang.String,java.lang.Object> ns, java.lang.String key, java.lang.Object value)Processes jexl.namespace.ns pragma.- Parameters:
ns- the namespace mapkey- the keyvalue- the value, ie the class
-
processPragmas
protected void processPragmas(ASTJexlScript script, JexlContext context, JexlOptions opts)
Processes a script pragmas.Only called from options(...)
- Parameters:
script- the scriptcontext- the contextopts- the options
-
putThreadEngine
protected JexlEngine putThreadEngine(JexlEngine jexl)
Swaps the current thread local engine.- Parameters:
jexl- the engine or null- Returns:
- the previous thread local engine
-
putThreadLocal
protected JexlContext.ThreadLocal putThreadLocal(JexlContext.ThreadLocal tls)
Swaps the current thread local context.- Parameters:
tls- the context or null- Returns:
- the previous thread local context
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader classLoader)
Description copied from class:JexlEngineSets the class loader used to discover classes in 'new' expressions.This method is not thread safe; it may be called after JexlEngine initialization and allow scripts to use new classes definitions.
- Specified by:
setClassLoaderin classJexlEngine- Parameters:
classLoader- the class loader to use
-
setProperty
public void setProperty(JexlContext context, java.lang.Object bean, java.lang.String expr, java.lang.Object value)
Description copied from class:JexlEngineAssign properties of a bean using an expression.If the JEXL engine is silent, errors will be logged through its logger as warning.
- Specified by:
setPropertyin classJexlEngine- Parameters:
context- the evaluation contextbean- the bean to set properties inexpr- the property expressionvalue- the value of the property
-
setProperty
public void setProperty(java.lang.Object bean, java.lang.String expr, java.lang.Object value)Description copied from class:JexlEngineAssign properties of a bean using an expression.jexl.set(myobject, "foo.bar", 10); should equate to myobject.getFoo().setBar(10); (or myobject.getFoo().put("bar", 10) )
If the JEXL engine is silent, errors will be logged through its logger as warning.
- Specified by:
setPropertyin classJexlEngine- Parameters:
bean- the bean to set properties inexpr- the property expressionvalue- the value of the property
-
trimSource
protected java.lang.String trimSource(java.lang.CharSequence str)
Trims the source from front and ending spaces.- Parameters:
str- expression to clean- Returns:
- trimmed expression ending in a semicolon
-
varCollector
protected Engine.VarCollector varCollector()
Creates a collector instance.- Returns:
- a collector instance
-
withValueSet
private void withValueSet(java.lang.Object value, java.util.function.Consumer<java.lang.Object> consumer)Utility to deal with single value or set of values.- Parameters:
value- the value or the setconsumer- the consumer of values
-
-