接口 Expression

  • 所有已知实现类:
    CompositeStringExpression, LiteralExpression, SpelExpression

    public interface Expression
    An expression capable of evaluating itself against context objects. Encapsulates the details of a previously parsed expression string. Provides a common abstraction for expression evaluation.
    从以下版本开始:
    3.0
    作者:
    Keith Donald, Andy Clement, Juergen Hoeller
    • 方法详细资料

      • getExpressionString

        String getExpressionString()
        Return the original string used to create this expression (unmodified).
        返回:
        the original expression string
      • getValue

        <T> T getValue​(Class<T> desiredResultType)
                throws EvaluationException
        Evaluate the expression in the default context. If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be returned.
        参数:
        desiredResultType - the class the caller would like the result to be
        返回:
        the evaluation result
        抛出:
        EvaluationException - if there is a problem during evaluation
      • getValue

        Object getValue​(Object rootObject)
                 throws EvaluationException
        Evaluate this expression against the specified root object.
        参数:
        rootObject - the root object against which to evaluate the expression
        返回:
        the evaluation result
        抛出:
        EvaluationException - if there is a problem during evaluation
      • getValue

        <T> T getValue​(Object rootObject,
                       Class<T> desiredResultType)
                throws EvaluationException
        Evaluate the expression in the default context against the specified root object. If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be returned.
        参数:
        rootObject - the root object against which to evaluate the expression
        desiredResultType - the class the caller would like the result to be
        返回:
        the evaluation result
        抛出:
        EvaluationException - if there is a problem during evaluation
      • getValue

        Object getValue​(EvaluationContext context,
                        Object rootObject)
                 throws EvaluationException
        Evaluate this expression in the provided context and return the result of evaluation, but use the supplied root context as an override for any default root object specified in the context.
        参数:
        context - the context in which to evaluate the expression
        rootObject - the root object against which to evaluate the expression
        返回:
        the evaluation result
        抛出:
        EvaluationException - if there is a problem during evaluation
      • getValue

        <T> T getValue​(EvaluationContext context,
                       Class<T> desiredResultType)
                throws EvaluationException
        Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular class and an exception will be thrown if it is not and cannot be converted to that type.
        参数:
        context - the context in which to evaluate the expression
        desiredResultType - the class the caller would like the result to be
        返回:
        the evaluation result
        抛出:
        EvaluationException - if there is a problem during evaluation
      • getValue

        <T> T getValue​(EvaluationContext context,
                       Object rootObject,
                       Class<T> desiredResultType)
                throws EvaluationException
        Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular class and an exception will be thrown if it is not and cannot be converted to that type. The supplied root object overrides any default specified on the supplied context.
        参数:
        context - the context in which to evaluate the expression
        rootObject - the root object against which to evaluate the expression
        desiredResultType - the class the caller would like the result to be
        返回:
        the evaluation result
        抛出:
        EvaluationException - if there is a problem during evaluation
      • isWritable

        boolean isWritable​(Object rootObject)
                    throws EvaluationException
        Determine if an expression can be written to, i.e. setValue() can be called.
        参数:
        rootObject - the root object against which to evaluate the expression
        返回:
        true if the expression is writable; false otherwise
        抛出:
        EvaluationException - if there is a problem determining if it is writable
      • isWritable

        boolean isWritable​(EvaluationContext context)
                    throws EvaluationException
        Determine if an expression can be written to, i.e. setValue() can be called.
        参数:
        context - the context in which the expression should be checked
        返回:
        true if the expression is writable; false otherwise
        抛出:
        EvaluationException - if there is a problem determining if it is writable
      • isWritable

        boolean isWritable​(EvaluationContext context,
                           Object rootObject)
                    throws EvaluationException
        Determine if an expression can be written to, i.e. setValue() can be called. The supplied root object overrides any specified in the context.
        参数:
        context - the context in which the expression should be checked
        rootObject - the root object against which to evaluate the expression
        返回:
        true if the expression is writable; false otherwise
        抛出:
        EvaluationException - if there is a problem determining if it is writable
      • setValue

        void setValue​(Object rootObject,
                      Object value)
               throws EvaluationException
        Set this expression in the provided context to the value provided.
        参数:
        rootObject - the root object against which to evaluate the expression
        value - the new value
        抛出:
        EvaluationException - if there is a problem during evaluation
      • setValue

        void setValue​(EvaluationContext context,
                      Object rootObject,
                      Object value)
               throws EvaluationException
        Set this expression in the provided context to the value provided. The supplied root object overrides any specified in the context.
        参数:
        context - the context in which to set the value of the expression
        rootObject - the root object against which to evaluate the expression
        value - the new value
        抛出:
        EvaluationException - if there is a problem during evaluation