support for concatenation with String via operator '+' - for Ramnivas.

This commit is contained in:
Andy Clement
2009-06-30 19:19:07 +00:00
parent a32448da02
commit 7e05c928dd
3 changed files with 16 additions and 4 deletions

View File

@@ -73,6 +73,14 @@ public class OpPlus extends Operator {
}
} else if (operandOne instanceof String && operandTwo instanceof String) {
return new TypedValue(new StringBuilder((String) operandOne).append((String) operandTwo).toString(),STRING_TYPE_DESCRIPTOR);
} else if (operandOne instanceof String) {
StringBuilder result = new StringBuilder((String)operandOne);
result.append((operandTwo==null?"null":operandTwo.toString()));
return new TypedValue(result.toString(),STRING_TYPE_DESCRIPTOR);
} else if (operandTwo instanceof String) {
StringBuilder result = new StringBuilder((operandOne==null?"null":operandOne.toString()));
result.append((String)operandTwo);
return new TypedValue(result.toString(),STRING_TYPE_DESCRIPTOR);
}
return state.operate(Operation.ADD, operandOne, operandTwo);
}