Class InterpretedHelper

  • All Implemented Interfaces:
    HelperAdapter

    public class InterpretedHelper
    extends Helper
    implements HelperAdapter
    Implementation of RuleHelper which extends the functionality of the standard helper class, Helper, by adding the methods required to implement interface RuleHelper. It provides an implementation which executes rules by interpreting the rule tree. Any rule which employs the standard helper type checks built in method calls against class Helper. However, the interpreter assumes that the helper object implements InterpretedHelper. When a rule is compiled class Helper is extended with a generated class CompiledHelper<NNN> which also implements interface RuleHelper. The implementation of the execute method is generated by translating the parse tree to bytecode. Builtin calls are translated to calls of methods defined by class Helper. A rule can also specify its own helper class in order to provide its own set of builtin operations. The helper class does not implement interface RuleHelper. Instead the compilation process will generate a subclass of the user-defined helper class which provides an appropriate implementation for the RuleHelper methods, including an implementation of the execute method dreived from the rule parse tree. As in the default case, builtin calls are translated to calls of methods defined by the helper class.
    • Field Detail

      • bindingMap

        protected java.util.HashMap<java.lang.String,​java.lang.Object> bindingMap
    • Constructor Detail

      • InterpretedHelper

        public InterpretedHelper​(Rule rule)
    • Method Detail

      • execute

        public void execute​(java.lang.Object recipient,
                            java.lang.Object[] args)
                     throws ExecuteException
        install values into the bindings map and then call the execute0 method to actually execute the rule
        Specified by:
        execute in interface HelperAdapter
        Parameters:
        recipient - target of trigger method or null if it is static
        args - array to pass current values and return new values for data local to the trigger method
        Throws:
        ExecuteException
      • execute0

        protected void execute0()
                         throws ExecuteException
        basic implementation of rule execution
        Throws:
        ExecuteException - if an exception occurs during execution of the rule
      • setBinding

        public void setBinding​(java.lang.String name,
                               java.lang.Object value)
        Specified by:
        setBinding in interface HelperAdapter
      • getBinding

        public java.lang.Object getBinding​(java.lang.String name)
        Specified by:
        getBinding in interface HelperAdapter
      • getAccessibleField

        public java.lang.Object getAccessibleField​(java.lang.Object owner,
                                                   int fieldIndex)
        Specified by:
        getAccessibleField in interface HelperAdapter
      • setAccessibleField

        public void setAccessibleField​(java.lang.Object owner,
                                       java.lang.Object value,
                                       int fieldIndex)
        Specified by:
        setAccessibleField in interface HelperAdapter
      • invokeAccessibleMethod

        public java.lang.Object invokeAccessibleMethod​(java.lang.Object target,
                                                       java.lang.Object[] args,
                                                       int methodIndex)
        Specified by:
        invokeAccessibleMethod in interface HelperAdapter