Bug 127175 - Convert Properties files into constant class
Summary: Convert Properties files into constant class
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2006-02-09 16:58 EST by David Leal CLA
Modified: 2009-08-30 02:41 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Leal CLA 2006-02-09 16:58:43 EST
I would like to suggest the posibility given a *.properties file to convert it to the equivalent constant class with to options:
1. Convert only the constant properties names.
2. Convert the constant properties names and its value.

Why?, because most application needs a *.properties files in order to configurate some behaviour and a good practice in order to avoid string constante names throught the source code with the risk of misspelling key name could be to get a class representation of such properties file.

For example:
File: app.properties with the following properties:
key1 = value1
group1.Key1 = value2
group2.Key1 = value3

can be converted to:

final class App {
  public static final String KEY1 = "key1"

  public class Group1 {
  
    public static final KEY1 = "group1.key1";
  }
  public class Group2 {
  
    public static final KEY1 = "group2.key1";
  }
}

so, now on the application code, you don't make mistakes when you want to refere the property: group2.key1, using:

App.Group2.KEY1, in order to represent the property name group2.key1.

You only have to sinchronize the App class with app.properties if you add a new property in the file or a new information on the constant class.

The second option, it is less usefull, because when you modify the value of the property you have to generate the class again. With the 1 option you have to your properties key on the properties file mapped to the class constant and you can use in a safe way.

I think that this could improve the Resource Bundle Editor.

Thanks in advance,

David Leal

P.D.: I haven't seen such pluging for eclipse, if you know some one, please let me know, thanks.
Comment 1 Martin Aeschlimann CLA 2006-02-12 13:02:18 EST
I think this would be a nice idea for a plugin for eclipse, but I don't think we should add this to the default tooling; it's rather special.

Comment 2 Eclipse Webmaster CLA 2009-08-30 02:41:14 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.