This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I am working in a project where I have to load two different property files (for example parent.properties & child.properties ) which are totally have different base name and it should also have inheritance relationship between this two bundle. So that if any keys are not found in child.properties it should get from parent.properties.
When I was analyzing the resource bundle code, I came to know there is method setParent(), this method is used to set which is your parent bundle (something like java super class). For example if we use bundle name called "child_en.properties" the my parent bundle should be "child.properties".
As this method was protected method in ResourceBundle Class, so to use this class I have sub classed my own ResourceBundle class and overridden the setParent Method like below.
So after changing the class I have executed with the below method, excepts that it should pick the key from parent.properties file if the key is not present in child.properties file.
As usual J there is an error thrown saying the key was missing.
So what's wrong?
I tried to debug the code in the resource bundle class and below code surprised me.
As I was setting the value in setParent() of resource bundle to change the parent resource bundle, but when the bundle are created using ResourceBundle.getInstance(), internally it calls getBundleImpl() which set the parent as "NOT_FOUND" direcly.
I was really confused why the code was setting directly rather than using values from the setter method???
As user of this class this implementation really stops customization which users expects.