Hi Dave,
Dave Westerman wrote:
I am using the commons-configuration for my property files. However,
unfortunately, I have a need to have a value in some of my properties
that look exactly like the variables that commons-config uses.
myproperty=${myNonCommonsConfigVariable}
I've tried to escape it thus:
myproperty=\${myNonCommonsConfigVariable}
myproperty=\\${myNonCommonsConfigVariable}
myproperty=$${myNonCommonsConfigVariable}
but all to no avail.
Is there any way for me to get around this conflict? Can I change the
delimiter that commons-config uses (I've looked at all the classes,
there doesn't seem to be a way)?
The error I'm getting is this:
java.lang.IllegalStateException: infinite loop in property interpolation
of
${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar,${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar,${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar:
DB2UNIVERSAL_JDBC_DRIVER_PATH->DB2UNIVERSAL_JDBC_DRIVER_PATH
which version of Commons Configuration do you use? Since the 1.3 release
substituation of variables is handled by the StrSubstitutor class of
Commons Lang [1]. Here the '$' sign is used for escaping variables, so
your 3rd example
myproperty=$${myNonCommonsConfigVariable}
should work. There is also a unit test that checks this behavior:
public void testInterpolationEscaped()
{
config.addProperty("var", "x");
config.addProperty("escVar", "Use the variable $${${var}}.");
assertEquals("Wrong escaped variable", "Use the variable
${x}.", config
.getString("escVar"));
}
IIRC in earlier versions of Configuration escaping variables was not
supported.
Oliver
[1]
http://jakarta.apache.org/commons/lang/api-release/org/apache/commons/lang/text/StrSubstitutor.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]