if (args[1] instanceof Literal) {
// Constant string expression: optimize by
// compiling format string.
String formatString = (String) ((Literal) args[1]).getValue();
final Format format = new Format(formatString, locale);
return new AbstractStringCalc(call, new Calc[] {calc}) {
public String evaluateString(Evaluator evaluator) {
final Object o = calc.evaluate(evaluator);
return format.format(o);
}
};
} else {
// Variable string expression
final StringCalc stringCalc =
compiler.compileString(call.getArg(1));
return new AbstractStringCalc(call, new Calc[] {calc, stringCalc}) {
public String evaluateString(Evaluator evaluator) {
final Object o = calc.evaluate(evaluator);
final String formatString =
stringCalc.evaluateString(evaluator);
final Format format =