There is something called JAVAML - XML for Java source code. An XML representation is very helpful for extracting the details out of the source code. We're often confronted with the need to massively refactor huge amount of code based on syntactic contexts. Being able to express those as XPath expressions or XSLT templates makes this otherwise complex task much, much easier. I have everything you need to be able to parse java source code into xml and then be able to programmatically parse generated xml and be able to modify, put it into database or whatever. You can google JAVAML and use it's dtd, xsl along with JavaCC to accomplish what you want to do or contact me at
npatel32@gmail.com for more information.