Skip to content

Commit 3361de3

Browse files
author
Keith Donald
committed
SPR-6278
1 parent 61a8fa0 commit 3361de3

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

org.springframework.expression/src/main/java/org/springframework/expression/common/CompositeStringExpression.java

+25-15
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.springframework.expression.EvaluationContext;
2121
import org.springframework.expression.EvaluationException;
2222
import org.springframework.expression.Expression;
23-
import org.springframework.util.ObjectUtils;
2423

2524
/**
2625
* Represents a template expression broken into pieces. Each piece will be an Expression but pure text parts to the
@@ -58,27 +57,46 @@ public final String getExpressionString() {
5857
public String getValue() throws EvaluationException {
5958
StringBuilder sb = new StringBuilder();
6059
for (Expression expression : this.expressions) {
61-
sb.append(ObjectUtils.getDisplayString(expression.getValue()));
60+
String value = expression.getValue(String.class);
61+
if (value != null) {
62+
sb.append(value);
63+
}
6264
}
6365
return sb.toString();
6466
}
6567

66-
public String getValue(EvaluationContext context) throws EvaluationException {
68+
public String getValue(Object rootObject) throws EvaluationException {
6769
StringBuilder sb = new StringBuilder();
6870
for (Expression expression : this.expressions) {
69-
sb.append(ObjectUtils.getDisplayString(expression.getValue(context)));
71+
String value = expression.getValue(rootObject, String.class);
72+
if (value != null) {
73+
sb.append(value);
74+
}
7075
}
7176
return sb.toString();
7277
}
73-
74-
public String getValue(Object rootObject) throws EvaluationException {
78+
79+
public String getValue(EvaluationContext context) throws EvaluationException {
7580
StringBuilder sb = new StringBuilder();
7681
for (Expression expression : this.expressions) {
77-
sb.append(ObjectUtils.getDisplayString(expression.getValue(rootObject)));
82+
String value = expression.getValue(context, String.class);
83+
if (value != null) {
84+
sb.append(value);
85+
}
7886
}
7987
return sb.toString();
8088
}
8189

90+
public String getValue(EvaluationContext context, Object rootObject) throws EvaluationException {
91+
StringBuilder sb = new StringBuilder();
92+
for (Expression expression : this.expressions) {
93+
String value = expression.getValue(context, rootObject, String.class);
94+
if (value != null) {
95+
sb.append(value);
96+
}
97+
}
98+
return sb.toString();
99+
}
82100

83101
public Class getValueType(EvaluationContext context) {
84102
return String.class;
@@ -124,14 +142,6 @@ public <T> T getValue(Object rootObject, Class<T> desiredResultType) throws Eval
124142
return ExpressionUtils.convert(null, value, desiredResultType);
125143
}
126144

127-
public String getValue(EvaluationContext context, Object rootObject) throws EvaluationException {
128-
StringBuilder sb = new StringBuilder();
129-
for (Expression expression : this.expressions) {
130-
sb.append(ObjectUtils.getDisplayString(expression.getValue(context,rootObject)));
131-
}
132-
return sb.toString();
133-
}
134-
135145
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType)
136146
throws EvaluationException {
137147
Object value = getValue(context,rootObject);

0 commit comments

Comments
 (0)