Figure 7-3. Expected structure of properties shown in Example 7-1
While this sounds good, Java provides no means of accessing the
name-value pairs in this manner; it does not give the period any
special value, but instead treats it as just another character. So
while you can do this:
String classpathValue = Properties.getProperty("org.enhydra.classpath");
You cannot do this:
List enhydraProperties = Properties.getProperties("org.enhydra");
You would expect (or at least I do!) that the latter would work, and
provide you all the subproperties with the structure
org.enhydra
(org.enhydra.classpath,
org.enhydra.initialargs, etc.). Unfortunately,
that's not part of the Properties class. For
this reason, many developers have had to write their own little
wrapper methods around this object, which of course is nonstandard
and a bit of a pain. Wouldn't it be nice if this information
could be modeled in XML, where operations like the second example are
simple? That's exactly what I want to write code to do, and
I'll use JDOM to demonstrate that API.