Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Associating and using javadoc comments with java elements.

Thread view: 
sude - 15 Feb 2006 00:59 GMT
Hi!,
    I need a way to associate a javadoc comment with the corresponding
Java Element. And access that programmatically in Java.
e.g. For the code below
/**
      * This is my Class
    */
        public class X {
         
        }

I need something like
<sometype> myJavaElement = <something which gives class X>
myJavaElement.getComment();

One way which I was thinking of was using the AntLR and modifying the
lexer code generated by the AntLR. But was wondering that this problem
might (should ) have been faced by other people and if there exists
an open source tool which can be used for this purpose.
I looked at qdox but that I guess will not be able to handle package
level comments which is a basic requirement for me.

Any help is highly appreciated and highly awaited.

Thanks a lot,
Sudhanshu
Roedy Green - 15 Feb 2006 04:29 GMT
>One way which I was thinking of was using the AntLR and modifying the
>lexer code generated by the AntLR. But was wondering that this problem
>might (should =EF=81=8A) have been faced by other people and if there exists
>an open source tool which can be used for this purpose.
>I looked at qdox but that I guess will not be able to handle package
>level comments which is a basic requirement for me.

I don't follow why you are doing this or what precisely you are
tracking. However, there are two techniques in general for tackling
this sort of problem.

1. annotations:

2. custom Javadoc comments you handle with a custom Doclet to generate
the HTML or other summaries.

See http://mindprod.com/jgloss/annotations.html
http://mindprod.com/jgloss/javadoc.html

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Owen Jacobson - 15 Feb 2006 14:45 GMT
> Hi!,
>     I need a way to associate a javadoc comment with the corresponding
> Java Element. And access that programmatically in Java.

Comments (including "javadoc comments") are not retained by the compiler.
End of story. If you need some descriptive information about a class at
runtime, either store it in an annotation with runtime retention or create
a lookup table mapping symbols (class names, packages, class member names,
et cetera) to the information you need and access that.
Richard Wheeldon - 15 Feb 2006 19:59 GMT
> I need a way to associate a javadoc comment with the corresponding
> Java Element. And access that programmatically in Java.

Use a custom doclet, write <method,comment> pairs to some output file.
Read them back as required,

Richard
sude - 25 Feb 2006 20:13 GMT
Well this requires an assumption on my part that the  comments that are
provided in the java code are given through a java doc tag. Right? But
I do not want to impose any such restriction to the user. In my opinion
JDT would need to solve this problem to show the javadoc comment
associated with any element.
Am not sure if they have any lean/minimal component to solve this.
Anybody has any idea?

sudhanshu


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.