Class JexlRuleScript

java.lang.Object
net.simplace.core.jexl.JexlRuleScript
All Implemented Interfaces:
org.apache.commons.jexl3.JexlExpression

public class JexlRuleScript extends Object implements 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
  • Method Details

    • analyseComplexity

      public static JexlRuleScript.COMPLEXITY analyseComplexity(String aRule)
      Analyses the complexity of a rule: rules containing a parameter ${...} or the namespace array: (and neither !ZIP nor !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

      public Object evaluate(org.apache.commons.jexl3.JexlContext aContext)
      Evaluates the rule.
      Specified by:
      evaluate in interface org.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 a NullPointerException)
    • debugValues

      public String debugValues(FWSimVarMap aVarMap)
      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: value per parameter
    • getComplexity

      public JexlRuleScript.COMPLEXITY getComplexity()
      Returns:
      the JexlRuleScript.COMPLEXITY of this rule
    • getRule

      public String getRule()
      Returns:
      the rule text (with the original ${...} parameters)
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the source text, see getSourceText()
    • getSourceText

      public String getSourceText()
      Specified by:
      getSourceText in interface org.apache.commons.jexl3.JexlExpression
      Returns:
      the compiled source text prefixed with Expression: or Script: , or the rule text for VALUE or if the rule could not be compiled
    • getParsedText

      public String getParsedText()
      Specified by:
      getParsedText in interface org.apache.commons.jexl3.JexlExpression
      Returns:
      the parsed text prefixed with Expression: or Script: , or null for VALUE or if the rule could not be compiled
    • callable

      public Callable<Object> callable(org.apache.commons.jexl3.JexlContext aArg0)
      Specified by:
      callable in interface org.apache.commons.jexl3.JexlExpression
      Parameters:
      aArg0 - the context providing the variable values
      Returns:
      a callable evaluating the rule with evaluate(JexlContext)