Class ExpressionUtils
java.lang.Object
org.springframework.integration.expression.ExpressionUtils
public final class ExpressionUtils
extends java.lang.Object
Utility class with static methods for helping with evaluation of SpEL expressions.
- Since:
- 2.2
-
Method Summary
Modifier and Type Method Description static org.springframework.expression.spel.support.SimpleEvaluationContextcreateSimpleEvaluationContext()Used to create a context with no BeanFactory, usually in tests.static org.springframework.expression.spel.support.SimpleEvaluationContextcreateSimpleEvaluationContext(org.springframework.beans.factory.BeanFactory beanFactory)Obtains the context from the beanFactory if not null; emits a warning if the beanFactory is null.static org.springframework.expression.spel.support.StandardEvaluationContextcreateStandardEvaluationContext()Used to create a context with no BeanFactory, usually in tests.static org.springframework.expression.spel.support.StandardEvaluationContextcreateStandardEvaluationContext(org.springframework.beans.factory.BeanFactory beanFactory)Obtains the context from the beanFactory if not null; emits a warning if the beanFactory is null.static java.io.FileexpressionToFile(org.springframework.expression.Expression expression, org.springframework.expression.EvaluationContext evaluationContext, org.springframework.messaging.Message<?> message, java.lang.String propertyName)Evaluate an expression and return aFileobject; the expression can evaluate to aStringorFile.static org.springframework.expression.ExpressionintExpression(java.lang.String expression)Return aValueExpressionfor a simple literal, otherwise aSpelExpression.static org.springframework.expression.ExpressionlongExpression(java.lang.String expression)Return aValueExpressionfor a simple literal, otherwise aSpelExpression.
-
Method Details
-
createStandardEvaluationContext
public static org.springframework.expression.spel.support.StandardEvaluationContext createStandardEvaluationContext()Used to create a context with no BeanFactory, usually in tests.- Returns:
- The evaluation context.
-
createSimpleEvaluationContext
public static org.springframework.expression.spel.support.SimpleEvaluationContext createSimpleEvaluationContext()Used to create a context with no BeanFactory, usually in tests.- Returns:
- The evaluation context.
- Since:
- 4.3.15
-
createStandardEvaluationContext
public static org.springframework.expression.spel.support.StandardEvaluationContext createStandardEvaluationContext(@Nullable org.springframework.beans.factory.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 org.springframework.expression.spel.support.SimpleEvaluationContext createSimpleEvaluationContext(@Nullable org.springframework.beans.factory.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 java.io.File expressionToFile(org.springframework.expression.Expression expression, org.springframework.expression.EvaluationContext evaluationContext, @Nullable org.springframework.messaging.Message<?> message, java.lang.String propertyName)Evaluate an expression and return aFileobject; the expression can evaluate to aStringorFile.- 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 org.springframework.expression.Expression intExpression(java.lang.String expression)Return aValueExpressionfor a simple literal, otherwise aSpelExpression.- Parameters:
expression- the expression string.- Returns:
- the expression.
- Since:
- 5.0
-
longExpression
public static org.springframework.expression.Expression longExpression(java.lang.String expression)Return aValueExpressionfor a simple literal, otherwise aSpelExpression.- Parameters:
expression- the expression string.- Returns:
- the expression.
- Since:
- 5.0
-