Extract String and StringBuffer



Hi all

I need to extract all of the SQL select statements from a codebase ideally during build time.
The SQL queries are embedded in the source code in either String or StringBuffer form, none of them are annotated with a unique annotation.

I've been looking into AspectJ and maybe applying an aspect to the class Connection for instance which could output the sql to whereever at some point during execution, this does mean however that I'd need some way of executing each and every method which executes a select statement in a unit test for instance.

I've also briefly looked into AST as a possibility.

If the queries were annotated I could have used an annotation processor but alas they aren't.

Has anyone done this kind of thing before or can reccommend a suitable method?

Thanks
.