Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Question: resource bundle/properties file referencing key from value



I have say message.properties as follows

label.productName = MyProduct
label.companyName = MyCompany
label.header = MyCompany-MyProduct
label.title = MyCompany-MyProduct
label.footer = MyCompany 2005-2008 All rights reserved

As you can see I have same words repeated in most of the labels.
Is there any way to avoid it by using keys "label.productName" and "label.companyName" with other values like..

label.productName = MyProduct
label.companyName = MyCompany
label.header = {label.productName}-{label.companyName}
label.title = {label.productName}-{label.companyName}
label.footer = {label.companyName} 2005-2008 All rights reserved

Can resource bundle recognize it if my values contain/references other keys defined in same properties file.

I need it for rebranding of the product. I do not want to keep multiple copies of same properties file with different productName/ companyName.I also want to avoid find/replace for each occurrence of productName/ companyName if I want to change the value for productName/ companyName.