Created an attachment (id=15933)
New implementation of VariableFormatter
This patch contains some modifications of VariableFormatter with the purpose to
make the code easier to understand and more integrated into the rest of the
The main idea of this patch is to separate the logic for detecting variables
from the processing of variables. There is now a new nested class
VariableParser, which scans the input data for text and variable tokens. This
class is used in the main interpolation method and called in a loop to obtain
all tokens and process them according to their type.
This approach IMO makes customization of this class easier. ATM the involved
helper classes and methods are protected allowing a sub class to override some
of them. This way e.g. completely different mechanisms for detecting variables
or escaping could be implemented. If you think that the API becomes too
complex, the involved classes and methods could be made private.
There are the following further modifications and improvements:
- The main interpolation method now operates on a char and can therefor
easier be used from other classes in this package.
- StrTokenizer.Matcher is used for detecting variable tokens. This is a
"natural" way of dealing with char.
- The escaping mechanism can now be implemented much easier. No need for
escape() and unescape() methods or for escaping variable end tokens.
- StrBuilder is used internally for constructing result strings instead of