Configuration files

Eddie Sheffield eddie.sheffield at enterworks.com
Fri Jun 26 22:51:39 BST 1998


Peter Murray-Rust wrote:
> >Better here, I think, to use the simple keyword=value format
> >defined by java:
> >
> >parser.AElfred=com.microstar.xml.SAXDriver
> >parser.xp=com.jclark.xml.sax.Driver
> >preferred.parser=xp
> 
> If this is already parsed by Java I am happy to use it. But for structured
> things like menus we definitely want XML.

Yes, Java already parses property files in this format. Structured items
are a bit more trouble, and somewhat inflexible. But we use something
like this:

myapplet.menu.file=File
myapplet.menu.file.open=Open
myapplet.menu.file.save=Save
myapplet.menu.file.close=Close

This example is how we handle internationalization. Simple change the
values on the RHS to whatever label you want to appear on the item.

For this application I would tend to favor the idea of using a property
file for the bare-bones bootstrapping, perhaps using an entry to point
to a more thorough config file in XML. This way one can take advantage
of the way the Java class loader can "hunt down" the properties file in
a nice, platform independent way.

Incidentally, the property files can also be placed in packages by
placing the file in the appropriate directory and prepending the package
name when retrieving it. Note that there is no "package" keyword that
must be placed in the file, nor must the filename itself be changed. So
to have a property file com.mycompany.myclasses.myapplet I would create
a file called myapplet.properties and place it in the directory
com/mycompany/myclasses. Then when I requested the ResourceBundle called
com.mycompany.myclasses.myapplet it would automatically be located, just
like one of the class files making up my applet.

Eddie

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list