This commit is contained in:
Keith Donald 2009-11-12 21:18:17 +00:00
parent 61a8fa0ebd
commit 3361de3875
1 changed files with 29 additions and 19 deletions

View File

@ -20,7 +20,6 @@ import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
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
@ -58,7 +57,21 @@ public class CompositeStringExpression implements Expression {
public String getValue() throws EvaluationException {
StringBuilder sb = new StringBuilder();
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();
}
@ -66,19 +79,24 @@ public class CompositeStringExpression implements Expression {
public String getValue(EvaluationContext context) throws EvaluationException {
StringBuilder sb = new StringBuilder();
for (Expression expression : this.expressions) {
sb.append(ObjectUtils.getDisplayString(expression.getValue(context)));
}
return sb.toString();
}
public String getValue(Object rootObject) throws EvaluationException {
StringBuilder sb = new StringBuilder();
for (Expression expression : this.expressions) {
sb.append(ObjectUtils.getDisplayString(expression.getValue(rootObject)));
String value = expression.getValue(context, String.class);
if (value != null) {
sb.append(value);
}
}
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) {
return String.class;
@ -124,14 +142,6 @@ public class CompositeStringExpression implements Expression {
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)
throws EvaluationException {
Object value = getValue(context,rootObject);