Reputation: 2454
My application needs to have queries externalized, so to make use of default resourcebundle, I've decided to go with queries in properties files. So, here's what a properties file looks like now:
SELECT_USER_QUERY = Select username, userid from user where userid=?
INSERT_USER_QUERY = insert into user values (?,?)
The problem here obviously is not a showstopper - this properties file gets picked up and gets processed nicely, but for somebody to edit in the near future, it looks ugly. I would like something like this:
SELECT_USER_QUERY = select username, userid
from user
where userid=?
I want to see that formatting in my properties file. I think one way to go about it would be to introduce a "\" (as per some answers on SO) at the end of each line. Are there any other ways to retain formatting in the properties file and still load it successfully?
Upvotes: 3
Views: 1859
Reputation: 2454
Ok. I think one way to go about it (and most likely I would) is to write all queries in a properties file, but each query value spanning multiple formatted rows. I will be using a custom ResourceBundle to load these properties in a custom way. This way, I can ensure that there is formatting in properties file and also code wise load properties using ResourceBundle.
Upvotes: 0
Reputation: 71
Just add a \ at the end of the line, that must not be interpreted as a linebreak. There is no other way to retain the formatting (line breaks) in a properties file
Upvotes: 3
Reputation: 272337
There's no reason to restrict yourself to properties files. Why not simply store the above in a text file and have (say) a text file per query/statement ? That way someone can edit the text file without having to worry about properties-style formatting.
Upvotes: 2