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 Summary
Modifier and Type Method Description static SimpleEvaluationContextcreateSimpleEvaluationContext()Used to create a context with no BeanFactory, usually in tests.static SimpleEvaluationContextcreateSimpleEvaluationContext(BeanFactory beanFactory)Obtains the context from the beanFactory if not null; emits a warning if the beanFactory is null.static StandardEvaluationContextcreateStandardEvaluationContext()Used to create a context with no BeanFactory, usually in tests.static StandardEvaluationContextcreateStandardEvaluationContext(BeanFactory beanFactory)Obtains the context from the beanFactory if not null; emits a warning if the beanFactory is null.static FileexpressionToFile(Expression expression, EvaluationContext evaluationContext, Message<?> message, String propertyName)static ExpressionintExpression(String expression)Return aValueExpressionfor a simple literal, otherwise aSpelExpression.static ExpressionlongExpression(String expression)Return aValueExpressionfor a simple literal, otherwise aSpelExpression.
-
Method Details
-
createStandardEvaluationContext
Used to create a context with no BeanFactory, usually in tests.- Returns:
- The evaluation context.
-
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)- 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
Return aValueExpressionfor a simple literal, otherwise aSpelExpression.- Parameters:
expression- the expression string.- Returns:
- the expression.
- Since:
- 5.0
-
longExpression
Return aValueExpressionfor a simple literal, otherwise aSpelExpression.- Parameters:
expression- the expression string.- Returns:
- the expression.
- Since:
- 5.0
-