Class FEELImpl

  • All Implemented Interfaces:
    FEEL

    public class FEELImpl
    extends java.lang.Object
    implements FEEL
    Language runtime entry point
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addListener​(org.kie.dmn.api.feel.runtime.events.FEELEventListener listener)
      Registers a new event listener into this FEEL instance.
      CompiledExpression compile​(java.lang.String expression, CompilerContext ctx)
      Compiles the string expression using the given compiler context.
      ProcessedExpression compileExpression​(java.lang.String expression, CompilerContext ctx)  
      ProcessedUnaryTest compileUnaryTests​(java.lang.String expressions, CompilerContext ctx)
      Compiles the string expression using the given compiler context.
      java.lang.Object evaluate​(java.lang.String expression)
      Evaluates the given FEEL expression and returns the result
      java.lang.Object evaluate​(java.lang.String expression, java.util.Map<java.lang.String,​java.lang.Object> inputVariables)
      Evaluates the given FEEL expression using the given input variables, and returns the result
      java.lang.Object evaluate​(java.lang.String expression, EvaluationContext ctx)
      Evaluates the given FEEL expression using the given EvaluationContext, and returns the result
      java.lang.Object evaluate​(CompiledExpression expr, java.util.Map<java.lang.String,​java.lang.Object> inputVariables)
      Evaluates the given compiled FEEL expression using the given input variables, and returns the result
      java.lang.Object evaluate​(CompiledExpression expr, EvaluationContext ctx)
      Evaluates the given compiled FEEL expression using the given EvaluationContext, and returns the result
      java.util.List<UnaryTest> evaluateUnaryTests​(java.lang.String expression)
      Evaluates the given expression as a list of of unary tests.
      java.util.List<UnaryTest> evaluateUnaryTests​(java.lang.String expression, java.util.Map<java.lang.String,​Type> variableTypes)
      Evaluates the given expression as a list of of unary tests.
      java.util.Collection<FEELFunction> getCustomFunctions()  
      FEELEventListenersManager getEventsManager​(java.util.Collection<org.kie.dmn.api.feel.runtime.events.FEELEventListener> contextListeners)  
      java.util.Set<org.kie.dmn.api.feel.runtime.events.FEELEventListener> getListeners()
      Retrieves the set of registered event listeners
      CompilerContext newCompilerContext()
      Factory method to create a new compiler context
      CompilerContext newCompilerContext​(java.util.Collection<org.kie.dmn.api.feel.runtime.events.FEELEventListener> contextListeners)  
      EvaluationContextImpl newEvaluationContext​(java.lang.ClassLoader cl, java.util.Collection<org.kie.dmn.api.feel.runtime.events.FEELEventListener> listeners, java.util.Map<java.lang.String,​java.lang.Object> inputVariables)
      Creates a new EvaluationContext with the supplied classloader, and the supplied parameters listeners and inputVariables
      EvaluationContextImpl newEvaluationContext​(java.util.Collection<org.kie.dmn.api.feel.runtime.events.FEELEventListener> listeners, java.util.Map<java.lang.String,​java.lang.Object> inputVariables)
      Creates a new EvaluationContext using this FEEL instance classloader, and the supplied parameters listeners and inputVariables
      void removeListener​(org.kie.dmn.api.feel.runtime.events.FEELEventListener listener)
      Removes a listener from the list of event listeners.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FEELImpl

        public FEELImpl()
      • FEELImpl

        public FEELImpl​(java.lang.ClassLoader cl)
      • FEELImpl

        public FEELImpl​(java.util.List<FEELProfile> profiles)
      • FEELImpl

        public FEELImpl​(java.lang.ClassLoader cl,
                        java.util.List<FEELProfile> profiles)
    • Method Detail

      • newCompilerContext

        public CompilerContext newCompilerContext()
        Description copied from interface: FEEL
        Factory method to create a new compiler context
        Specified by:
        newCompilerContext in interface FEEL
        Returns:
        compiler context with default options set
      • newCompilerContext

        public CompilerContext newCompilerContext​(java.util.Collection<org.kie.dmn.api.feel.runtime.events.FEELEventListener> contextListeners)
      • getCustomFunctions

        public java.util.Collection<FEELFunction> getCustomFunctions()
      • compile

        public CompiledExpression compile​(java.lang.String expression,
                                          CompilerContext ctx)
        Description copied from interface: FEEL
        Compiles the string expression using the given compiler context.
        Specified by:
        compile in interface FEEL
        Parameters:
        expression - a FEEL expression
        ctx - a compiler context
        Returns:
        the compiled expression
      • compileUnaryTests

        public ProcessedUnaryTest compileUnaryTests​(java.lang.String expressions,
                                                    CompilerContext ctx)
        Description copied from interface: FEEL
        Compiles the string expression using the given compiler context.
        Specified by:
        compileUnaryTests in interface FEEL
        Parameters:
        expressions - a FEEL expression for unary tests
        ctx - a compiler context
        Returns:
        the compiled unary tests
      • evaluate

        public java.lang.Object evaluate​(java.lang.String expression)
        Description copied from interface: FEEL
        Evaluates the given FEEL expression and returns the result
        Specified by:
        evaluate in interface FEEL
        Parameters:
        expression - a FEEL expression
        Returns:
        the result of the evaluation of the expression
      • evaluate

        public java.lang.Object evaluate​(java.lang.String expression,
                                         EvaluationContext ctx)
        Description copied from interface: FEEL
        Evaluates the given FEEL expression using the given EvaluationContext, and returns the result
        Specified by:
        evaluate in interface FEEL
        Parameters:
        expression - a FEEL expression
        ctx - the EvaluationContext to be used for defining input variables and additional feel event listeners contextual to this method call
        Returns:
        the result of the evaluation of the expression.
      • evaluate

        public java.lang.Object evaluate​(java.lang.String expression,
                                         java.util.Map<java.lang.String,​java.lang.Object> inputVariables)
        Description copied from interface: FEEL
        Evaluates the given FEEL expression using the given input variables, and returns the result
        Specified by:
        evaluate in interface FEEL
        Parameters:
        expression - a FEEL expression
        inputVariables - a map of input Variables. The keys on the map are the variable names, that need to follow the naming rules for the FEEL language. The values on the map are the corresponding values for the variables. It is completely fine to use a previously returned FEEL context as inputVariables.
        Returns:
        the result of the evaluation of the expression.
      • evaluate

        public java.lang.Object evaluate​(CompiledExpression expr,
                                         java.util.Map<java.lang.String,​java.lang.Object> inputVariables)
        Description copied from interface: FEEL
        Evaluates the given compiled FEEL expression using the given input variables, and returns the result
        Specified by:
        evaluate in interface FEEL
        Parameters:
        expr - a FEEL expression
        inputVariables - a map of input Variables. The keys on the map are the variable names, that need to follow the naming rules for the FEEL language. The values on the map are the corresponding values for the variables. It is completely fine to use a previously returned FEEL context as inputVariables.
        Returns:
        the result of the evaluation of the expression.
      • evaluate

        public java.lang.Object evaluate​(CompiledExpression expr,
                                         EvaluationContext ctx)
        Description copied from interface: FEEL
        Evaluates the given compiled FEEL expression using the given EvaluationContext, and returns the result
        Specified by:
        evaluate in interface FEEL
        ctx - the EvaluationContext to be used for defining input variables and additional feel event listeners contextual to this method call
        Returns:
        the result of the evaluation of the expression.
      • newEvaluationContext

        public EvaluationContextImpl newEvaluationContext​(java.util.Collection<org.kie.dmn.api.feel.runtime.events.FEELEventListener> listeners,
                                                          java.util.Map<java.lang.String,​java.lang.Object> inputVariables)
        Creates a new EvaluationContext using this FEEL instance classloader, and the supplied parameters listeners and inputVariables
      • newEvaluationContext

        public EvaluationContextImpl newEvaluationContext​(java.lang.ClassLoader cl,
                                                          java.util.Collection<org.kie.dmn.api.feel.runtime.events.FEELEventListener> listeners,
                                                          java.util.Map<java.lang.String,​java.lang.Object> inputVariables)
        Creates a new EvaluationContext with the supplied classloader, and the supplied parameters listeners and inputVariables
      • evaluateUnaryTests

        public java.util.List<UnaryTest> evaluateUnaryTests​(java.lang.String expression)
        Description copied from interface: FEEL
        Evaluates the given expression as a list of of unary tests. The syntax for this is defined in the FEEL grammar rule #17, i.e., a list of unary tests separated by commas.
        Specified by:
        evaluateUnaryTests in interface FEEL
        Parameters:
        expression - a unary test list expression
        Returns:
        a List of compiled UnaryTests
      • evaluateUnaryTests

        public java.util.List<UnaryTest> evaluateUnaryTests​(java.lang.String expression,
                                                            java.util.Map<java.lang.String,​Type> variableTypes)
        Description copied from interface: FEEL
        Evaluates the given expression as a list of of unary tests. The syntax for this is defined in the FEEL grammar rule #17, i.e., a list of unary tests separated by commas.
        Specified by:
        evaluateUnaryTests in interface FEEL
        Parameters:
        expression - a unary test list expression
        variableTypes - map of variable names and corresponding types, necessary to compile the unary tests
        Returns:
        a List of compiled UnaryTests
      • addListener

        public void addListener​(org.kie.dmn.api.feel.runtime.events.FEELEventListener listener)
        Description copied from interface: FEEL
        Registers a new event listener into this FEEL instance. The event listeners are notified about signitificative events during compilation or evaluation of expressions.
        Specified by:
        addListener in interface FEEL
        Parameters:
        listener - the listener to register
      • removeListener

        public void removeListener​(org.kie.dmn.api.feel.runtime.events.FEELEventListener listener)
        Description copied from interface: FEEL
        Removes a listener from the list of event listeners.
        Specified by:
        removeListener in interface FEEL
        Parameters:
        listener - the listener to remove
      • getListeners

        public java.util.Set<org.kie.dmn.api.feel.runtime.events.FEELEventListener> getListeners()
        Description copied from interface: FEEL
        Retrieves the set of registered event listeners
        Specified by:
        getListeners in interface FEEL
        Returns:
        the set of listeners
      • getEventsManager

        public FEELEventListenersManager getEventsManager​(java.util.Collection<org.kie.dmn.api.feel.runtime.events.FEELEventListener> contextListeners)