Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enhanced java.util.Properties Implementation

 
Jon Chase
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic