Escape sintax in variables substituion
JFig is a simple, powerful tool to manage application configuration
Status: Beta
Brought to you by:
bxconrad
Consider this fragmet of my configuration file:
<section name="config">
<entry key="version" value="$Id: vladhp.config.xml
225 2006-06-15 13:43:14Z vlads $" />
</section>
I want to print config file version in debug log of
my application during startup.
log.info("config.version " + JFig.getInstance
().getValue("config", "version"));
The value is automaticay updated when I change my
file in SVN/CVS
Now the value would be empty all the file sine it
will try to evaluate it as variable.
It would be nice to have an escape syntax to avoid
this:
Sugestion is double dollar signe $$
Logged In: NO
As a quick (and dirty) work-around, one can change the code so that the following is used for replacements:
[[section]]{{key}}
This should be enough for regexp.
Class: JFigParser
Methode: getRegexSubstitution
protected static Pattern getRegexSubstitution() throws JFigException {
if (regexSubstitution == null) {
// ? sets to non-greedy. \\) says look for literal ")"
regexSubstitution = Pattern.compile("(.*)(\\" + JFigConstants.SECTION_START_DELIMITER + "\\"+JFigConstants.SECTION_START_DELIMITER+")(.*?)(\\" +
JFigConstants.SECTION_END_DELIMITER+"\\"+JFigConstants.SECTION_END_DELIMITER+"?\\" + // 0 or 1 end section delimiter
JFigConstants.KEY_START_DELIMITER+"\\"+JFigConstants.KEY_START_DELIMITER + ")(.*?)(\\" + JFigConstants.KEY_END_DELIMITER +"\\" + JFigConstants.KEY_END_DELIMITER +
")(.*?)$", Pattern.MULTILINE);
}
}
Stefaan