SPR-6278
This commit is contained in:
parent
61a8fa0ebd
commit
3361de3875
|
|
@ -20,7 +20,6 @@ import org.springframework.core.convert.TypeDescriptor;
|
||||||
import org.springframework.expression.EvaluationContext;
|
import org.springframework.expression.EvaluationContext;
|
||||||
import org.springframework.expression.EvaluationException;
|
import org.springframework.expression.EvaluationException;
|
||||||
import org.springframework.expression.Expression;
|
import org.springframework.expression.Expression;
|
||||||
import org.springframework.util.ObjectUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a template expression broken into pieces. Each piece will be an Expression but pure text parts to the
|
* Represents a template expression broken into pieces. Each piece will be an Expression but pure text parts to the
|
||||||
|
|
@ -58,7 +57,21 @@ public class CompositeStringExpression implements Expression {
|
||||||
public String getValue() throws EvaluationException {
|
public String getValue() throws EvaluationException {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (Expression expression : this.expressions) {
|
for (Expression expression : this.expressions) {
|
||||||
sb.append(ObjectUtils.getDisplayString(expression.getValue()));
|
String value = expression.getValue(String.class);
|
||||||
|
if (value != null) {
|
||||||
|
sb.append(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(Object rootObject) throws EvaluationException {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Expression expression : this.expressions) {
|
||||||
|
String value = expression.getValue(rootObject, String.class);
|
||||||
|
if (value != null) {
|
||||||
|
sb.append(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
@ -66,19 +79,24 @@ public class CompositeStringExpression implements Expression {
|
||||||
public String getValue(EvaluationContext context) throws EvaluationException {
|
public String getValue(EvaluationContext context) throws EvaluationException {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (Expression expression : this.expressions) {
|
for (Expression expression : this.expressions) {
|
||||||
sb.append(ObjectUtils.getDisplayString(expression.getValue(context)));
|
String value = expression.getValue(context, String.class);
|
||||||
}
|
if (value != null) {
|
||||||
return sb.toString();
|
sb.append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue(Object rootObject) throws EvaluationException {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (Expression expression : this.expressions) {
|
|
||||||
sb.append(ObjectUtils.getDisplayString(expression.getValue(rootObject)));
|
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getValue(EvaluationContext context, Object rootObject) throws EvaluationException {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Expression expression : this.expressions) {
|
||||||
|
String value = expression.getValue(context, rootObject, String.class);
|
||||||
|
if (value != null) {
|
||||||
|
sb.append(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public Class getValueType(EvaluationContext context) {
|
public Class getValueType(EvaluationContext context) {
|
||||||
return String.class;
|
return String.class;
|
||||||
|
|
@ -124,14 +142,6 @@ public class CompositeStringExpression implements Expression {
|
||||||
return ExpressionUtils.convert(null, value, desiredResultType);
|
return ExpressionUtils.convert(null, value, desiredResultType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue(EvaluationContext context, Object rootObject) throws EvaluationException {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (Expression expression : this.expressions) {
|
|
||||||
sb.append(ObjectUtils.getDisplayString(expression.getValue(context,rootObject)));
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType)
|
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType)
|
||||||
throws EvaluationException {
|
throws EvaluationException {
|
||||||
Object value = getValue(context,rootObject);
|
Object value = getValue(context,rootObject);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue