Class TreeMethodExpression

    • Constructor Detail

      • TreeMethodExpression

        public TreeMethodExpression​(TreeStore store,
                                    FunctionMapper functions,
                                    VariableMapper variables,
                                    TypeConverter converter,
                                    String expr,
                                    Class<?> returnType,
                                    Class<?>[] paramTypes)
        Create a new method expression. The expression must be an lvalue expression or literal text. The expected return type may be null, meaning "don't care". If it is an lvalue expression, the parameter types must not be null. If it is literal text, the expected return type must not be void.
        Parameters:
        store - used to get the parse tree from.
        functions - the function mapper used to bind functions
        variables - the variable mapper used to bind variables
        expr - the expression string
        returnType - the expected return type (may be null)
        paramTypes - the expected parameter types (must not be null for lvalues)
    • Method Detail

      • getMethodInfo

        public MethodInfo getMethodInfo​(ELContext context)
                                 throws ELException
        Evaluates the expression and answers information about the method
        Specified by:
        getMethodInfo in class MethodExpression
        Parameters:
        context - used to resolve properties (base.property and base[property])
        Returns:
        method information or null for literal expressions
        Throws:
        ELException - if evaluation fails (e.g. suitable method not found)
      • getExpressionString

        public String getExpressionString()
        Description copied from class: Expression
        Returns the original String used to create this Expression, unmodified. This is used for debugging purposes but also for the purposes of comparison (e.g. to ensure the expression in a configuration file has not changed). This method does not provide sufficient information to re-create an expression. Two different expressions can have exactly the same expression string but different function mappings. Serialization should be used to save and restore the state of an Expression.
        Specified by:
        getExpressionString in class Expression
        Returns:
        The original expression String.
      • invoke

        public Object invoke​(ELContext context,
                             Object[] paramValues)
                      throws ELException
        Evaluates the expression and invokes the method.
        Specified by:
        invoke in class MethodExpression
        Parameters:
        context - used to resolve properties (base.property and base[property])
        paramValues -
        Returns:
        method result or null if this is a literal text expression
        Throws:
        ELException - if evaluation fails (e.g. suitable method not found)
      • isLiteralText

        public boolean isLiteralText()
        Description copied from class: Expression
        Returns whether this expression was created from only literal text. This method must return true if and only if the expression string this expression was created from contained no unescaped EL delimeters (${...} or #{...}).
        Specified by:
        isLiteralText in class Expression
        Returns:
        true if this is a literal text expression
      • isParmetersProvided

        public boolean isParmetersProvided()
        Description copied from class: MethodExpression
        Return whether this MethodExpression was created with parameters.

        This method must return true if and only if parameters are specified in the EL, using the expr-a.expr-b(...) syntax.

        Overrides:
        isParmetersProvided in class MethodExpression
        Returns:
        true if this is a method invocation expression
      • isDeferred

        public boolean isDeferred()
        Answer true if this is a deferred expression (starting with #{)
      • equals

        public boolean equals​(Object obj)
        Expressions are compared using the concept of a structural id: variable and function names are anonymized such that two expressions with same tree structure will also have the same structural id and vice versa. Two method expressions are equal if
        1. their builders are equal
        2. their structural id's are equal
        3. their bindings are equal
        4. their expected types match
        5. their parameter types are equal
        Specified by:
        equals in class Expression
        Parameters:
        obj - the Object to test for equality.
        Returns:
        true if obj equals this Expression; false otherwise.
      • hashCode

        public int hashCode()
        Description copied from class: Expression
        Returns the hash code for this Expression. See the note in the Expression.equals(Object) method on how two expressions can be equal if their expression Strings are different. Recall that if two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. Implementations must take special note and implement hashCode correctly.
        Specified by:
        hashCode in class Expression
        Returns:
        The hash code for this Expression.
        See Also:
        Expression.equals(Object), Hashtable, Object.hashCode()
      • dump

        public void dump​(PrintWriter writer)
        Print the parse tree.
        Parameters:
        writer -