|
@@ -39,19 +39,22 @@ public class StringFormatter {
|
|
|
FmtStateMachine formatMain() {
|
|
FmtStateMachine formatMain() {
|
|
|
int lpos = 0;
|
|
int lpos = 0;
|
|
|
for (int pos = fmt.indexOf('{'); pos != -1; lpos = pos+1, pos = fmt.indexOf('{', lpos)) {
|
|
for (int pos = fmt.indexOf('{'); pos != -1; lpos = pos+1, pos = fmt.indexOf('{', lpos)) {
|
|
|
- str.append(fmt.substring(lpos, pos));
|
|
|
|
|
|
|
+ str.append(fmt.substring(lpos, pos).replaceAll("}}", "}"));
|
|
|
int epos = fmt.indexOf('}', pos);
|
|
int epos = fmt.indexOf('}', pos);
|
|
|
|
|
|
|
|
if (fmt.charAt(pos+1) == '{') {
|
|
if (fmt.charAt(pos+1) == '{') {
|
|
|
- str.append(fmt.substring(++pos, ++epos));
|
|
|
|
|
|
|
+ // Literal '{'
|
|
|
|
|
+ str.append('{');
|
|
|
|
|
+ epos = pos + 1;
|
|
|
} else if (epos == pos+1) {
|
|
} else if (epos == pos+1) {
|
|
|
|
|
+ // Unmarked '{}' -> get the next argument
|
|
|
str.append(args[currentIdx++]);
|
|
str.append(args[currentIdx++]);
|
|
|
} else {
|
|
} else {
|
|
|
formatToken(pos, epos);
|
|
formatToken(pos, epos);
|
|
|
}
|
|
}
|
|
|
pos = epos;
|
|
pos = epos;
|
|
|
}
|
|
}
|
|
|
- str.append(fmt.substring(lpos));
|
|
|
|
|
|
|
+ str.append(fmt.substring(lpos).replaceAll("}}", "}"));
|
|
|
return this;
|
|
return this;
|
|
|
}
|
|
}
|
|
|
|
|
|