/** * Create the {@link SpringELExpression}. * <p><strong>Note:</strong> as of 2.4.8, this method is not invoked when a * {@link SimpleParserContext} is passed in, which is mainly the case when using * SpEL for data binding. In those scenarios, the configuration options are * limited to the use of property accessors and a ConversionService. */ protected SpringELExpression createSpringELExpression(Map<String, Expression> expressionVars, org.springframework.expression.Expression spelExpression, Class<?> expectedResultType, org.springframework.core.convert.ConversionService conversionService) { return new SpringELExpression(spelExpression, expressionVars, expectedResultType, conversionService, propertyAccessors); }
public String toString() { return getExpressionString(); }
@SuppressWarnings("deprecation") public Class<?> getValueType(Object rootObject) throws EvaluationException { try { EvaluationContext context = contextFactory.createContext(rootObject); if (context instanceof StandardEvaluationContext) { extendEvaluationContext((StandardEvaluationContext) context); } return expression.getValueType(context); } catch (SpelEvaluationException e) { if (e.getMessageCode().equals(SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE)) { throw new PropertyNotFoundException(rootObject.getClass(), getExpressionString(), e); } throw new EvaluationException(rootObject.getClass(), getExpressionString(), "An ELException occurred getting the value type for expression '" + getExpressionString() + "' on context [" + rootObject.getClass() + "]", e); } }
@SuppressWarnings("deprecation") public Class<?> getValueType(Object rootObject) throws EvaluationException { try { EvaluationContext context = contextFactory.createContext(rootObject); if (context instanceof StandardEvaluationContext) { extendEvaluationContext((StandardEvaluationContext) context); } return expression.getValueType(context); } catch (SpelEvaluationException e) { if (e.getMessageCode().equals(SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE)) { throw new PropertyNotFoundException(rootObject.getClass(), getExpressionString(), e); } throw new EvaluationException(rootObject.getClass(), getExpressionString(), "An ELException occurred getting the value type for expression '" + getExpressionString() + "' on context [" + rootObject.getClass() + "]", e); } }
@SuppressWarnings("deprecation") public void setValue(Object rootObject, Object value) throws EvaluationException { try { EvaluationContext context = contextFactory.createContext(rootObject); if (context instanceof StandardEvaluationContext) { extendEvaluationContext((StandardEvaluationContext) context); } expression.setValue(context, value); } catch (SpelEvaluationException e) { if (e.getMessageCode().equals(SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE)) { throw new PropertyNotFoundException(rootObject.getClass(), getExpressionString(), e); } if (e.getMessageCode().equals(SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE)) { throw new ValueCoercionException(rootObject.getClass(), getExpressionString(), value, expectedType, e); } throw new EvaluationException(rootObject.getClass(), getExpressionString(), "An ELException occurred setting the value of expression '" + getExpressionString() + "' on context [" + rootObject.getClass() + "] to [" + value + "]", e); } }
/** * Create the {@link SpringELExpression}. * <p><strong>Note:</strong> as of 2.4.8, this method is not invoked when a * {@link SimpleParserContext} is passed in, which is mainly the case when using * SpEL for data binding. In those scenarios, the configuration options are * limited to the use of property accessors and a ConversionService. */ protected SpringELExpression createSpringELExpression(Map<String, Expression> expressionVars, org.springframework.expression.Expression spelExpression, Class<?> expectedResultType, org.springframework.core.convert.ConversionService conversionService) { return new SpringELExpression(spelExpression, expressionVars, expectedResultType, conversionService, propertyAccessors); }
public String toString() { return getExpressionString(); }
@SuppressWarnings("deprecation") public void setValue(Object rootObject, Object value) throws EvaluationException { try { EvaluationContext context = contextFactory.createContext(rootObject); if (context instanceof StandardEvaluationContext) { extendEvaluationContext((StandardEvaluationContext) context); } expression.setValue(context, value); } catch (SpelEvaluationException e) { if (e.getMessageCode().equals(SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE)) { throw new PropertyNotFoundException(rootObject.getClass(), getExpressionString(), e); } if (e.getMessageCode().equals(SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE)) { throw new ValueCoercionException(rootObject.getClass(), getExpressionString(), value, expectedType, e); } throw new EvaluationException(rootObject.getClass(), getExpressionString(), "An ELException occurred setting the value of expression '" + getExpressionString() + "' on context [" + rootObject.getClass() + "] to [" + value + "]", e); } }
public Expression parseExpression(String expression, ParserContext context) throws ParserException { Assert.hasText(expression, "The expression string to parse is required and must not be empty"); context = (context == null) ? NullParserContext.INSTANCE : context; Map<String, Expression> expressionVars = parseSpelExpressionVariables(context.getExpressionVariables()); org.springframework.expression.Expression spelExpression = parseSpelExpression(expression, context); Class<?> expectedResultType = context.getExpectedEvaluationResultType(); org.springframework.core.convert.ConversionService cs = conversionService.getDelegateConversionService(); return context instanceof SimpleParserContext ? new SpringELExpression(spelExpression, expectedResultType, simpleContextFactory) : createSpringELExpression(expressionVars, spelExpression, expectedResultType, cs); }
@SuppressWarnings("deprecation") public Object getValue(Object rootObject) throws EvaluationException { try { EvaluationContext context = contextFactory.createContext(rootObject); if (context instanceof StandardEvaluationContext) { extendEvaluationContext((StandardEvaluationContext) context); } return expression.getValue(context, expectedType); } catch (SpelEvaluationException e) { if (e.getMessageCode().equals(SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE)) { throw new PropertyNotFoundException(rootObject.getClass(), getExpressionString(), e); } if (e.getMessageCode().equals(SpelMessage.TYPE_CONVERSION_ERROR)) { throw new ValueCoercionException(rootObject.getClass(), getExpressionString(), null, expectedType, e); } throw new EvaluationException(rootObject.getClass(), expression.getExpressionString(), "An ELException occurred getting the value for expression '" + getExpressionString() + "' on context [" + rootObject.getClass() + "]", e); } }
public Expression parseExpression(String expression, ParserContext context) throws ParserException { Assert.hasText(expression, "The expression string to parse is required and must not be empty"); context = (context == null) ? NullParserContext.INSTANCE : context; Map<String, Expression> expressionVars = parseSpelExpressionVariables(context.getExpressionVariables()); org.springframework.expression.Expression spelExpression = parseSpelExpression(expression, context); Class<?> expectedResultType = context.getExpectedEvaluationResultType(); org.springframework.core.convert.ConversionService cs = conversionService.getDelegateConversionService(); return context instanceof SimpleParserContext ? new SpringELExpression(spelExpression, expectedResultType, simpleContextFactory) : createSpringELExpression(expressionVars, spelExpression, expectedResultType, cs); }
@SuppressWarnings("deprecation") public Object getValue(Object rootObject) throws EvaluationException { try { EvaluationContext context = contextFactory.createContext(rootObject); if (context instanceof StandardEvaluationContext) { extendEvaluationContext((StandardEvaluationContext) context); } return expression.getValue(context, expectedType); } catch (SpelEvaluationException e) { if (e.getMessageCode().equals(SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE)) { throw new PropertyNotFoundException(rootObject.getClass(), getExpressionString(), e); } if (e.getMessageCode().equals(SpelMessage.TYPE_CONVERSION_ERROR)) { throw new ValueCoercionException(rootObject.getClass(), getExpressionString(), null, expectedType, e); } throw new EvaluationException(rootObject.getClass(), expression.getExpressionString(), "An ELException occurred getting the value for expression '" + getExpressionString() + "' on context [" + rootObject.getClass() + "]", e); } }