This blog serves as my personal work documentations. Most of the posts are ideas/solutions from work. Some of the code has been simplified or improved. Others are modified to conceal coding work from company's architecture. Some posts are thoughts outside of my job and may be in Chinese.
It is scary to find out that a dependency of your project is no longer supported and you really need a code update. That's what happened to me when I requested the source code of one dependency and I was told no one can find it.
The dependency I need to update is a JAXB client implementation to connect to liveglobalbid (lgb) - a leading developer of online auction software providing a high quality, real time simultaneous video and audio broadcast of a live auction sale. And surprisingly, I was able to get rid of the dependency along with the JAXB dependencies and use JAXB 2.0 API that comes with Java 5 and above. Besides that, by using JAXB 2.0 Annotations, the new client implementation is simple and light.
When it comes to internationalization, resource encoding is a big challenge. Sun's JDK doesn't offer UTF-8 encoding on ResourceBundle. So one way to work around is convert all UTF-8 translations in property files to Hexadecimal Characters first. There are lots of website offering online converters to serve the purpose. But there is still quite a few steps to do.
Recently, I started to work on a resource repository that centralize global resources within the company to reduce duplicate work. Users are suppose to be able to import and export resources in property file format. So it got me thinking, what if I offer real-time conversion of Hexadecimal Characters upon exporting resources to save the trouble.
After explored some of the online converter sites mentioned earlier, I find that the actual conversion is fairly simple. Strangely, all these websites uses JavaScript, but no search result turns out to do it Java way.
To run the test, simple execute with a file path as argument. In unicodeToJava, I choose to ignore any regular characters, which I recommend. But if you want to convert everything instead, skip all the conditions in unicodeToJava and leave only one line -- return "\\u" + getHexCode(ch); -- will do the trick.