Class ExpressionUtils

java.lang.Object
org.springframework.integration.expression.ExpressionUtils

public final class ExpressionUtils extends Object
Utility class with static methods for helping with evaluation of SpEL expressions.
Since:
2.2
Author:
Gary Russell, Oleg Zhurakousky, Artem Bilan
  • Method Details

    • createStandardEvaluationContext

      public static StandardEvaluationContext createStandardEvaluationContext()
      Used to create a context with no BeanFactory, usually in tests.
      Returns:
      The evaluation context.
    • createSimpleEvaluationContext

      public static SimpleEvaluationContext createSimpleEvaluationContext()
      Used to create a context with no BeanFactory, usually in tests.
      Returns:
      The evaluation context.
      Since:
      4.3.15
    • createStandardEvaluationContext

      public static StandardEvaluationContext createStandardEvaluationContext(@Nullable BeanFactory beanFactory)
      Obtains the context from the beanFactory if not null; emits a warning if the beanFactory is null.
      Parameters:
      beanFactory - The bean factory.
      Returns:
      The evaluation context.
    • createSimpleEvaluationContext

      public static SimpleEvaluationContext createSimpleEvaluationContext(@Nullable BeanFactory beanFactory)
      Obtains the context from the beanFactory if not null; emits a warning if the beanFactory is null.
      Parameters:
      beanFactory - The bean factory.
      Returns:
      The evaluation context.
      Since:
      4.3.15
    • expressionToFile

      public static File expressionToFile(Expression expression, EvaluationContext evaluationContext, @Nullable Message<?> message, String propertyName)
      Evaluate an expression and return a File object; the expression can evaluate to a String or File.
      Parameters:
      expression - the expression.
      evaluationContext - the evaluation context.
      message - the message (if available).
      propertyName - the property name the expression is evaluated for.
      Returns:
      the File.
      Since:
      5.0
    • intExpression

      public static Expression intExpression(String expression)
      Return a ValueExpression for a simple literal, otherwise a SpelExpression.
      Parameters:
      expression - the expression string.
      Returns:
      the expression.
      Since:
      5.0
    • longExpression

      public static Expression longExpression(String expression)
      Return a ValueExpression for a simple literal, otherwise a SpelExpression.
      Parameters:
      expression - the expression string.
      Returns:
      the expression.
      Since:
      5.0