org.springframework.expression.common.CompositeStringExpression Java Examples

The following examples show how to use org.springframework.expression.common.CompositeStringExpression. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityExpressionSupport.java    From springlets with Apache License 2.0 6 votes vote down vote up
private void registerConversionServiceInSpelExpressions(Expression parsedExpression) {
  if (conversionService == null) {
    return;
  }
  StandardTypeConverter converter = new StandardTypeConverter(conversionService);
  StandardEvaluationContext context = new StandardEvaluationContext();
  context.setTypeConverter(converter);
  setContextIfSpelExpression(parsedExpression, context);

  if (parsedExpression instanceof CompositeStringExpression) {
    CompositeStringExpression composite = (CompositeStringExpression) parsedExpression;
    for (Expression childExpresion : composite.getExpressions()) {
      setContextIfSpelExpression(childExpresion, context);
    }
  }
}
 
Example #2
Source File: SqlSpannerQuery.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
private Expression[] detectExpressions(String sql) {
	Expression expression = this.expressionParser.parseExpression(sql,
			ParserContext.TEMPLATE_EXPRESSION);
	if (expression instanceof LiteralExpression) {
		return new Expression[] { expression };
	}
	else if (expression instanceof CompositeStringExpression) {
		return ((CompositeStringExpression) expression).getExpressions();
	}
	else {
		throw new SpannerDataException("Unexpected expression type. "
				+ "Query can either contain no SpEL expressions or have SpEL expressions in the SQL.");
	}
}
 
Example #3
Source File: ExpressionTransform.java    From kork with Apache License 2.0 5 votes vote down vote up
/** Helper to escape an expression: stripping ${ } */
private String escapeExpression(Expression expression) {
  if (expression instanceof CompositeStringExpression) {
    StringBuilder sb = new StringBuilder();
    for (Expression e : ((CompositeStringExpression) expression).getExpressions()) {
      sb.append(e.getExpressionString());
    }

    return sb.toString();
  }

  return expression.getExpressionString();
}