Commons JEXL
  1. Commons JEXL
  2. JEXL-21

operator overloading / hooks on operator processing

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Labels:
      None

      Description

      I'd like to use JEXL for a website framework. In order to make the scripting code easy readable it would be nice to let the users add hooks in the expression processing.
      such a hook would allow me to add Date operators for example: Date and Durations addition/substraction.

      that would've been very easy for me to implement if I had access to the processing done in let's say ASTAddNode class.

      An easy way to do it is to add a method in the parser like
      registerHook(Class astNodeClass, SimpleNode hook)

      in ExpressionImpl.evaluate we call node.implValue instead of value. This method can check if hooks where registered for the class and call for each hook.value before calling the value of the node itself.
      For perfomance reasons the list of these hooks can be stored by the each SimpleNode in the constructor SimpleNode(Parser p, int i)

      that's it, thanks

        Activity

        Hide
        Henri Biestro added a comment -

        In 2.0, the Arithmetic instance does handle all arithmetic & logical operation; since Arithmetic is an interface and the JexlEngine ctor can use such an instance, it is therefore possible to implement the desired behavior.

        Show
        Henri Biestro added a comment - In 2.0, the Arithmetic instance does handle all arithmetic & logical operation; since Arithmetic is an interface and the JexlEngine ctor can use such an instance, it is therefore possible to implement the desired behavior.
        Hide
        Rahul Akolkar added a comment -

        This is a conceptual solution in the rearchitected 2.0 branch in SVN. Please try it out (by building the branch) and if further work is needed, reopen this issue (with a complete JUnit test that fails, if possible).

        Show
        Rahul Akolkar added a comment - This is a conceptual solution in the rearchitected 2.0 branch in SVN. Please try it out (by building the branch) and if further work is needed, reopen this issue (with a complete JUnit test that fails, if possible).
        Hide
        Henri Biestro added a comment -

        Bulk change issues closed by JEXL 2.0.

        Show
        Henri Biestro added a comment - Bulk change issues closed by JEXL 2.0.

          People

          • Assignee:
            Unassigned
            Reporter:
            AC
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development