Replace all direct uses of MessageFormat your method. In your method, find curly braces and replace them based on context before passing it to MessageFormat . Something as stupid as
s.replace("{", "'{'").replace("}", "'}'").replaceAll("'\\{'(\\d+)'\\}'", "{$1}")
could do, depending on what arguments you use.
Do not use this (especially String.replaceAll ) if you are interested in efficiency. My solution is useful if you need to save the power of MessageFormat . An effective solution will analyze the input string once and recognize which curly braces should be specified. See the source code for Pattern.replaceAll how to do this.
source share