I was looking out for a utility/library which can be used to generate Java Source code. Initially I thought of using source code templates and generate Java Files from it. But fortunately I came across an interesting library CodeModel.
This library is used by most of the popular code generators including JAXB. The library provides set of API classes which can be used to generate Java Source code (supports Java 5 generics, annotations etc.). The only downside of this library is that, it is not well documented. Worst part is, there are no tutorials available. So If you want to find out more details about how this library works, you better fold your sleeves and start writing some code which uses API. Good Luck.