Hi,
The escaping of commas with a backslash "\," does not work in the
Configuration.java. The reason is the recursive call to setProperties:
if (token instanceof String && ((String)token).indexOf(",") > 0)
{
PropertiesTokenizer tokenizer =
new PropertiesTokenizer((String)token);
while (tokenizer.hasMoreTokens())
{
String value = tokenizer.nextToken();
setProperty(key,value);
}
}
If a string has escaped commas (for example "one\,two\,three") is parsed by
PropertiesTokenizer it returns a string with "\"-escapes. (example
"one,two,three"). setProperties() is now recursively called with this
string and the next time it reaches this code it is inserted as a Vector!
My solution is to create a new method and not to use recursion. Something
like this:
public void setStringProperty(String key, String token)
{
Object o = this.get(key);
if (o instanceof String)
{
Vector v = new Vector(2);
v.addElement(o);
v.addElement(token);
put(key, v);
}
else if (o instanceof Vector)
{
((Vector) o).addElement(token);
}
else
{
put(key,toke);
}
}
It will still be able to handle examples like "one\,two,three\,four" but it
will successfully create one string for "one\,two\,three".
Any thoughts on this?
~ Leon