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

        AC created issue -
        dion gillard made changes -
        Field Original Value New Value
        Fix Version/s 2.0 [ 12312031 ]
        Rahul Akolkar made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Henri Biestro made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development