Interface IInfixExpressionHandler<TConstant extends IConstant,​TOperator extends IOperator>

  • Type Parameters:
    TConstant - Type of the implementation for constant symbols.
    TOperator - Type of the implementation for operator symbols.

    public interface IInfixExpressionHandler<TConstant extends IConstant,​TOperator extends IOperator>
    Handler that can tokenize, parse, and evaluate character sequences representing infix expressions.
    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • evaluate

        <TData> TData evaluate​(IEvalContext<TData,​TConstant,​TOperator> ctx,
                               Iterable<IParsedElement<TConstant,​TOperator>> rpn,
                               Locale locale)
                        throws InfixExpressionException
        Evaluates the given reverse polish notation with the given context.
        Type Parameters:
        TData - Type of the data on which the context operates.
        Parameters:
        ctx - Context for performing the evaluation.
        rpn - Reverse polish expression to evaluate.
        locale - Locale used for localizing error messages.
        Returns:
        The result of the evaluation. null when the expression contains no items, or the evaluation context returned null.
        Throws:
        InfixExpressionException - When the expression could not be evaluated, such as when the context threw an exception.
      • tokenize

        Iterable<IToken<TConstant,​TOperator>> tokenize​(CharSequence expression,
                                                             Locale locale)
                                                      throws InfixExpressionException
        Inspects the given expressions and extracts the semantic tokens it consists of.
        Parameters:
        expression - An infix expression to tokenize.
        locale - Locale used for localizing error messages.
        Returns:
        The list of tokens making up the given expression.
        Throws:
        InfixExpressionException - When the input expression cannot be split into tokens, such as when it contains an invalid identifier.
      • validate

        IValidationResult validate​(CharSequence expression,
                                   IValidationOptions options)
        Validates the given infix expression. Checks whether it is well-formed, and that each variable name passes the given existence check.
        Parameters:
        expression - Infix expression to validate.
        options - Options to configure what is to be validated.
        Returns:
        The result of the validation.