Class TreeValueExpression

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dump​(java.io.PrintWriter writer)
      Print the parse tree.
      boolean equals​(java.lang.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.
      java.lang.Class<?> getExpectedType()
      Returns the type the result of the expression will be coerced to after evaluation.
      java.lang.String getExpressionString()
      Returns the original String used to create this Expression, unmodified.
      java.lang.Class<?> getType​(ELContext context)
      Evaluates the expression as an lvalue and answers the result type.
      java.lang.Object getValue​(ELContext context)
      Evaluates the expression as an rvalue and answers the result.
      ValueReference getValueReference​(ELContext context)
      Returns a ValueReference for this expression instance.
      int hashCode()
      Returns the hash code for this Expression.
      boolean isDeferred()
      Answer true if this is a deferred expression (containing sub-expressions starting with #{)
      boolean isLeftValue()
      Answer true if this could be used as an lvalue.
      boolean isLiteralText()
      Returns whether this expression was created from only literal text.
      boolean isReadOnly​(ELContext context)
      Evaluates the expression as an lvalue and determines if setValue(ELContext, Object) will always fail.
      void setValue​(ELContext context, java.lang.Object value)
      Evaluates the expression as an lvalue and assigns the given value.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TreeValueExpression

        public TreeValueExpression​(TreeStore store,
                                   FunctionMapper functions,
                                   VariableMapper variables,
                                   TypeConverter converter,
                                   java.lang.String expr,
                                   java.lang.Class<?> type)
        Create a new value expression.
        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
        type - the expected type (may be null)
    • Method Detail

      • getExpectedType

        public java.lang.Class<?> getExpectedType()
        Description copied from class: ValueExpression
        Returns the type the result of the expression will be coerced to after evaluation.
        Specified by:
        getExpectedType in class ValueExpression
        Returns:
        the expectedType passed to the ExpressionFactory.createValueExpression method that created this ValueExpression.
      • getExpressionString

        public java.lang.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.
      • getType

        public java.lang.Class<?> getType​(ELContext context)
                                   throws ELException
        Evaluates the expression as an lvalue and answers the result type.
        Specified by:
        getType in class ValueExpression
        Parameters:
        context - used to resolve properties (base.property and base[property]) and to determine the result from the last base/property pair
        Returns:
        lvalue evaluation type or null for rvalue expressions
        Throws:
        ELException - if evaluation fails (e.g. property not found, type conversion failed, ...)
      • getValue

        public java.lang.Object getValue​(ELContext context)
                                  throws ELException
        Evaluates the expression as an rvalue and answers the result.
        Specified by:
        getValue in class ValueExpression
        Parameters:
        context - used to resolve properties (base.property and base[property]) and to determine the result from the last base/property pair
        Returns:
        rvalue evaluation result
        Throws:
        ELException - if evaluation fails (e.g. property not found, type conversion failed, ...)
      • setValue

        public void setValue​(ELContext context,
                             java.lang.Object value)
                      throws ELException
        Evaluates the expression as an lvalue and assigns the given value.
        Specified by:
        setValue in class ValueExpression
        Parameters:
        context - used to resolve properties (base.property and base[property]) and to perform the assignment to the last base/property pair
        value - The new value to be set.
        Throws:
        ELException - if evaluation fails (e.g. property not found, type conversion failed, assignment failed...)
      • 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
      • getValueReference

        public ValueReference getValueReference​(ELContext context)
        Description copied from class: ValueExpression
        Returns a ValueReference for this expression instance.
        Overrides:
        getValueReference in class ValueExpression
        Parameters:
        context - the context of this evaluation
        Returns:
        the ValueReference for this ValueExpression, or null if this ValueExpression is not a reference to a base (null or non-null) and a property. If the base is null, and the property is a EL variable, return the ValueReference for the ValueExpression associated with this EL variable.
      • isLeftValue

        public boolean isLeftValue()
        Answer true if this could be used as an lvalue. This is the case for eval expressions consisting of a simple identifier or a nonliteral prefix, followed by a sequence of property operators (. or [])
      • isDeferred

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

        public boolean equals​(java.lang.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 value expressions are equal if
        1. their structural id's are equal
        2. their bindings are equal
        3. their expected 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()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • dump

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