Class JexlRuleScript
java.lang.Object
net.simplace.core.jexl.JexlRuleScript
- All Implemented Interfaces:
org.apache.commons.jexl3.JexlExpression
A rule of a solution (e.g. of a variable or a transformer), compiled once as JEXL expression or script and
evaluated against a context. Parameters
${component.var} in the rule are replaced by the JEXL names
component__var before compiling. Rules without parameters are plain values.- Author:
- lap
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic JexlRuleScript.COMPLEXITYanalyseComplexity(String aRule) Analyses the complexity of a rule: rules containing a parameter${...}or the namespacearray:(and neither!ZIPnor!UNZIP) are SCRIPT if they contain;,{or a line break, otherwise EXPRESSION; all other rules are VALUE.callable(org.apache.commons.jexl3.JexlContext aArg0) debugValues(FWSimVarMap aVarMap) Lists the current values of all parameters of the rule, for error messages.evaluate(org.apache.commons.jexl3.JexlContext aContext) Evaluates the rule.getRule()toString()
-
Method Details
-
analyseComplexity
Analyses the complexity of a rule: rules containing a parameter${...}or the namespacearray:(and neither!ZIPnor!UNZIP) are SCRIPT if they contain;,{or a line break, otherwise EXPRESSION; all other rules are VALUE.- Parameters:
aRule- the rule text- Returns:
- the complexity
-
evaluate
Evaluates the rule.- Specified by:
evaluatein interfaceorg.apache.commons.jexl3.JexlExpression- Parameters:
aContext- the context providing the variable values- Returns:
- the result of the expression or script, or the rule text for VALUE
- Throws:
IllegalStateException- if the rule could not be compiled (the parse error was logged on creation; was aNullPointerException)
-
debugValues
Lists the current values of all parameters of the rule, for error messages.- Parameters:
aVarMap- the variable map providing the values- Returns:
- one line
name: valueper parameter
-
getComplexity
- Returns:
- the
JexlRuleScript.COMPLEXITYof this rule
-
getRule
- Returns:
- the rule text (with the original
${...}parameters)
-
toString
- Overrides:
toStringin classObject- Returns:
- the source text, see
getSourceText()
-
getSourceText
- Specified by:
getSourceTextin interfaceorg.apache.commons.jexl3.JexlExpression- Returns:
- the compiled source text prefixed with
Expression:orScript:, or the rule text for VALUE or if the rule could not be compiled
-
getParsedText
- Specified by:
getParsedTextin interfaceorg.apache.commons.jexl3.JexlExpression- Returns:
- the parsed text prefixed with
Expression:orScript:, ornullfor VALUE or if the rule could not be compiled
-
callable
- Specified by:
callablein interfaceorg.apache.commons.jexl3.JexlExpression- Parameters:
aArg0- the context providing the variable values- Returns:
- a callable evaluating the rule with
evaluate(JexlContext)
-