private Class<?> getExpectedType(ParserContext context) { Class<?> expectedType = context.getExpectedEvaluationResultType(); return expectedType != null ? expectedType : Object.class; }
private org.springframework.expression.ParserContext getSpelParserContext(ParserContext context) { return context.isTemplate() ? org.springframework.expression.ParserContext.TEMPLATE_EXPRESSION : null; }
protected Expression doParseExpression(String expressionString, ParserContext context) throws ParserException { try { return new OgnlExpression(Ognl.parseExpression(expressionString), parseVariableExpressions(context .getExpressionVariables()), context.getExpectedEvaluationResultType(), expressionString, conversionService); } catch (OgnlException e) { throw new ParserException(expressionString, e); } } }
private ValueExpression parseValueExpression(String expressionString, ParserContext context) throws ELException { ParserELContext elContext = new ParserELContext(); elContext.mapVariables(context.getExpressionVariables(), expressionFactory); ValueExpression expression = expressionFactory.createValueExpression(elContext, expressionString, Object.class); return new BindingValueExpression(expression, getExpectedType(context), conversionService, context.isTemplate()); }
private Expression parseExpressionInternal(String expressionString, ParserContext context, boolean template) throws ParserException { Assert.notNull(expressionString, "The expression string to parse is required"); try { ValueExpression expression = parseValueExpression(expressionString, context); ELContextFactory contextFactory = getContextFactory(context.getEvaluationContextType(), expressionString); return new ELExpression(contextFactory, expression); } catch (ELException e) { throw new ParserException(expressionString, 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); }
private ValueExpression parseValueExpression(String expressionString, ParserContext context) throws ELException { ParserELContext elContext = new ParserELContext(); elContext.mapVariables(context.getExpressionVariables(), expressionFactory); ValueExpression expression = expressionFactory.createValueExpression(elContext, expressionString, Object.class); return new BindingValueExpression(expression, getExpectedType(context), conversionService, context.isTemplate()); }
private Expression parseExpressionInternal(String expressionString, ParserContext context, boolean template) throws ParserException { Assert.notNull(expressionString, "The expression string to parse is required"); try { ValueExpression expression = parseValueExpression(expressionString, context); ELContextFactory contextFactory = getContextFactory(context.getEvaluationContextType(), expressionString); return new ELExpression(contextFactory, expression); } catch (ELException e) { throw new ParserException(expressionString, 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); }
private ValueExpression parseValueExpression(String expressionString, ParserContext context) throws ELException { ParserELContext elContext = new ParserELContext(); elContext.mapVariables(context.getExpressionVariables(), expressionFactory); ValueExpression expression = expressionFactory.createValueExpression(elContext, expressionString, Object.class); return new BindingValueExpression(expression, getExpectedType(context), conversionService, context.isTemplate()); }
private org.springframework.expression.ParserContext getSpelParserContext(ParserContext context) { return context.isTemplate() ? org.springframework.expression.ParserContext.TEMPLATE_EXPRESSION : null; }
private Expression parseExpressionInternal(String expressionString, ParserContext context, boolean template) throws ParserException { Assert.notNull(expressionString, "The expression string to parse is required"); try { ValueExpression expression = parseValueExpression(expressionString, context); ELContextFactory contextFactory = getContextFactory(context.getEvaluationContextType(), expressionString); return new ELExpression(contextFactory, expression); } catch (ELException e) { throw new ParserException(expressionString, e); } }
private Class getExpectedType(ParserContext context) { Class expectedType = context.getExpectedEvaluationResultType(); return expectedType != null ? expectedType : Object.class; }
public Expression parseExpression(String expressionString, ParserContext context) throws ParserException { Assert.notNull(expressionString, "The expression string to parse is required"); if (context == null) { context = NullParserContext.INSTANCE; } if (context.isTemplate()) { return parseExpressionInternal(expressionString, context, true); } else { assertNotDelimited(expressionString); assertHasText(expressionString); return parseExpressionInternal("#{" + expressionString + "}", context, false); } }
private Class<?> getExpectedType(ParserContext context) { Class<?> expectedType = context.getExpectedEvaluationResultType(); return expectedType != null ? expectedType : Object.class; }
public Expression parseExpression(String expressionString, ParserContext context) throws ParserException { Assert.notNull(expressionString, "The expression string to parse is required"); if (context == null) { context = NullParserContext.INSTANCE; } if (context.isTemplate()) { return parseExpressionInternal(expressionString, context, true); } else { assertNotDelimited(expressionString); assertHasText(expressionString); return parseExpressionInternal("#{" + expressionString + "}", context, false); } }
public Expression parseExpression(String expressionString, ParserContext context) throws ParserException { Assert.notNull(expressionString, "The expression string to parse is required"); if (context == null) { context = NullParserContext.INSTANCE; } if (context.isTemplate()) { return parseExpressionInternal(expressionString, context, true); } else { assertNotDelimited(expressionString); assertHasText(expressionString); return parseExpressionInternal("#{" + expressionString + "}", context, false); } }
public Expression parseExpression(String expressionString, ParserContext context) throws ParserException { Assert.notNull(expressionString, "The expression string to parse is required"); if (context == null) { context = NullParserContext.INSTANCE; } if (context.isTemplate()) { return parseTemplate(expressionString, context); } else { if (expressionString.startsWith(getExpressionPrefix()) && expressionString.endsWith(getExpressionSuffix())) { if (!allowDelimitedEvalExpressions) { throw new ParserException( expressionString, "The expression '" + expressionString + "' being parsed is expected be an expression. " + "Do not enclose such expression strings in ${} delimiters as it's redundant. " + "If you need to parse a template that mixes literal text with evaluatable blocks, " + "set the 'template' parser context attribute to true.", null); } else { int lastIndex = expressionString.length() - getExpressionSuffix().length(); String expression = expressionString.substring(getExpressionPrefix().length(), lastIndex); return doParseExpression(expression, context); } } else { return doParseExpression(expressionString, context); } } }
public Expression parseExpression(String expressionString, ParserContext context) throws ParserException { Assert.notNull(expressionString, "The expression string to parse is required"); if (context == null) { context = NullParserContext.INSTANCE; } if (context.isTemplate()) { return parseTemplate(expressionString, context); } else { if (expressionString.startsWith(getExpressionPrefix()) && expressionString.endsWith(getExpressionSuffix())) { if (!allowDelimitedEvalExpressions) { throw new ParserException( expressionString, "The expression '" + expressionString + "' being parsed is expected be a standard OGNL expression. Do not attempt to enclose such expression strings in ${} delimiters--this is redundant. If you need to parse a template that mixes literal text with evaluatable blocks, set the 'template' parser context attribute to true.", null); } else { int lastIndex = expressionString.length() - getExpressionSuffix().length(); String ognlExpression = expressionString.substring(getExpressionPrefix().length(), lastIndex); return doParseExpression(ognlExpression, context); } } else { return doParseExpression(expressionString, context); } } }
public Expression parseExpression(String expressionString, ParserContext context) throws ParserException { Assert.notNull(expressionString, "The expression string to parse is required"); if (context == null) { context = NullParserContext.INSTANCE; } if (context.isTemplate()) { return parseTemplate(expressionString, context); } else { if (expressionString.startsWith(getExpressionPrefix()) && expressionString.endsWith(getExpressionSuffix())) { if (!allowDelimitedEvalExpressions) { throw new ParserException( expressionString, "The expression '" + expressionString + "' being parsed is expected be an expression. " + "Do not enclose such expression strings in ${} delimiters as it's redundant. " + "If you need to parse a template that mixes literal text with evaluatable blocks, " + "set the 'template' parser context attribute to true.", null); } else { int lastIndex = expressionString.length() - getExpressionSuffix().length(); String expression = expressionString.substring(getExpressionPrefix().length(), lastIndex); return doParseExpression(expression, context); } } else { return doParseExpression(expressionString, context); } } }