|
20 | 20 | import org.springframework.expression.EvaluationContext; |
21 | 21 | import org.springframework.expression.EvaluationException; |
22 | 22 | import org.springframework.expression.Expression; |
23 | | -import org.springframework.util.ObjectUtils; |
24 | 23 |
|
25 | 24 | /** |
26 | 25 | * 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() { |
58 | 57 | public String getValue() throws EvaluationException { |
59 | 58 | StringBuilder sb = new StringBuilder(); |
60 | 59 | 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 | + } |
62 | 64 | } |
63 | 65 | return sb.toString(); |
64 | 66 | } |
65 | 67 |
|
66 | | - public String getValue(EvaluationContext context) throws EvaluationException { |
| 68 | + public String getValue(Object rootObject) throws EvaluationException { |
67 | 69 | StringBuilder sb = new StringBuilder(); |
68 | 70 | 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 | + } |
70 | 75 | } |
71 | 76 | return sb.toString(); |
72 | 77 | } |
73 | | - |
74 | | - public String getValue(Object rootObject) throws EvaluationException { |
| 78 | + |
| 79 | + public String getValue(EvaluationContext context) throws EvaluationException { |
75 | 80 | StringBuilder sb = new StringBuilder(); |
76 | 81 | 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 | + } |
78 | 86 | } |
79 | 87 | return sb.toString(); |
80 | 88 | } |
81 | 89 |
|
| 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 | + } |
82 | 100 |
|
83 | 101 | public Class getValueType(EvaluationContext context) { |
84 | 102 | return String.class; |
@@ -124,14 +142,6 @@ public <T> T getValue(Object rootObject, Class<T> desiredResultType) throws Eval |
124 | 142 | return ExpressionUtils.convert(null, value, desiredResultType); |
125 | 143 | } |
126 | 144 |
|
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 | | - |
135 | 145 | public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType) |
136 | 146 | throws EvaluationException { |
137 | 147 | Object value = getValue(context,rootObject); |
|
0 commit comments