handle basic argument substitution in MessageFormat.format

Thanks to Remi for an initial version of this patch.
This commit is contained in:
Joel Dice
2012-08-11 08:56:21 -06:00
parent e2416ddb85
commit e2ff771baa
2 changed files with 15 additions and 2 deletions

View File

@ -28,8 +28,14 @@ public class MessageFormat extends Format {
public StringBuffer format(Object[] args, StringBuffer target,
FieldPosition p)
{
// todo
return target.append(pattern);
// todo: handle other format substitutions and escapes, and make
// this more efficient:
String result = pattern;
int length = args.length;
for (int i = 0; i < length; i++) {
result = result.replace("{" + i + "}", String.valueOf(args[i]));
}
return target.append(result);
}
public StringBuffer format(Object args, StringBuffer target, FieldPosition p)