Re: Re[4]: anybody has a tool to extract variable and class names out of Java Business and Java-Struts-ActionForm classes into xml, i.e. a free-marker usable data format?
Chris Nokleberg <[email protected]> Sat, 27 Sep 2003 15:05:50 -0700
| Newsgroups | gmane.comp.text.fmpp |
|---|---|
| Message-ID | <[email protected]> |
Daniel Dekany wrote:
> Friday, September 26, 2003, 9:53:10 PM, Ralf Hauser wrote:
>> I don't want to extract from jsp files, but from *.java files: class
>> names and private variable names.
>>
>> Do you have any experience with that?
>
> .java file parsing? No. But one possibility is that you compile them to
> classes with Sun's compiler ("javac" if you invoke it from command
> line), and then use CGLIB to examine the resulting .class files. If the
> compilation step is inconvenient, then maybe it is not that hard to
> write a java program that extract these infos from a Java file... I
> mean, it need not be a full-blown Java parser for that, so it is maybe
> not that hard. A third possibility is to find a Java parser. I guess
> there is Java language parser available for parser-generators as ANTLR
> or JavaCC.
If by "private variable names" you mean field names, it is very simple to
extract that info from a .class file using ASM (http://asm.objectweb.org/).
For parsing a Java source file you may want to look at the following
projects, they all some sort of parser you could use as a starting point:
http://qdox.codehaus.org/
http://www.beanshell.org/
http://www.antlr.org/
Chris
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf