commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimir Stevanovic <vstevano...@emisia.net>
Subject [configuration] inconsistent behaving of AbstractHierarchicalFileConfiguration.containsKey(String) method
Date Thu, 09 Jun 2011 09:27:48 GMT
I'm using the following code:

//part1
XMLConfiguration config= new XMLConfiguration();
config.setDelimiterParsingDisabled(true);
config.setExpressionEngine(new XPathExpressionEngine());
config.setFile(f);
if (f.exists()) {
    config.load(f);
}

//part2
config.addProperty(" a", "");
config.addProperty("a b", "");
config.addProperty("a/b c", "");
config.save();
	
//part3
System.out.println("a is a valid key " + config.containsKey("a"));
System.out.println("a/b is a valid key " + config.containsKey("a/b"));
System.out.println("a/b/c is a valid key " + config.containsKey("a/b/c"));

After executing it for the first time, the code behaves as I expected,
the simple nested xml structure is created and the output is:
a is a valid key true
a/b is a valid key true
a/b/c is a valid key true

Then, I removed the "part2" code, so the program should just read the
previously created configuration, bat the output was:
a is a valid key false
a/b is a valid key false
a/b/c is a valid key true

So, sometimes if key doesn't have any values it is seen as a key, and
sometimes not. Any explanation, solution,... ?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message