File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Enhanced java.util.Properties Implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Enhanced java.util.Properties Implementation" Watch "Enhanced java.util.Properties Implementation" New topic
Author

Enhanced java.util.Properties Implementation

Jon Chase
Greenhorn

Joined: Feb 14, 2004
Posts: 7
Hey! I'd like to allow users of our web application to edit its configuration files through the web interface, and I've got the following idea of how to do it (and by the way, I am NOT considering using XML for configuration).

Say you've got a standard .properties file, like:

prop1.displayName=Property 1
prop1.possibleValues=1,2,3,a,b,c
prop1.value=2

prop2.displayName=Property 2
prop2.possibleValues=foo,bar,baz
prop2.value=baz


I'd like to get some type of objects back from reading this properties file which would give me something like the following:

Class: EnhancedProperties // represents the entire file
- Members:
- List properties // one entry for each main property, in our case, we'd have 2 entries (prop1 and prop2)

Class: EnhancedProperty // represents one entry from the EnhancedProperties class
- Members
- String name // in our case, "prop1"
- String displayName // in our case, "Property 1"
- String [] possibleValues // in our case, {"1","2","3","a","b","c"}
- String value // in our case, 2


Using this class, we'd automatically get all main properties, a list of their possible values (for dropdowns), a display name, and a current value, all stored in one place.

Does anyone know of anything out there similar to this? Or for that matter, something that will make config file editing for users of a UI as easy to add as this?
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
I agree with you solution BUT

I think , it not good solution for edit/change data in properties file at RUNTIME. because you MUST create Management Class to manage properties file, it so hard...

You should be use XML file with JAXP : DOM, SAX or Dom4j/JDOM, it suite.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enhanced java.util.Properties Implementation