This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Finding Exposed Methods of a Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Finding Exposed Methods of a Class" Watch "Finding Exposed Methods of a Class" New topic
Author

Finding Exposed Methods of a Class

K Sujit
Ranch Hand

Joined: Mar 23, 2005
Posts: 33
Hi All,

I have many classes with only set and get methods. The number of set and get methods differ from class to class. Obviously it depends upon the number of instance variables that particular class has.

Now suppose I got a class C, I want to find what all methods it is exposing. How can I do that.

Thanks in advance!


I wish java run in my veins.
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Options include (in roughly preferential order, and not limited to) reading the API docs for the class, relying on an IDE, looking at the source, or using reflection.

Hope this helps.
Rick Stabile
Greenhorn

Joined: Sep 22, 2005
Posts: 6
I did something similar recently. Only I exposed a class's fields rather than its methods using the Class.getFields() method. I talk about it here: Reflection made my life easier today..

Rather than use the getFields() method, you would probably want to use the getMethods() method. Look at the javadoc for the Class class - Javadoc for Class. There's a lot of interesting stuff there.


- Rick S.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

"ESK"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
K Sujit
Ranch Hand

Joined: Mar 23, 2005
Posts: 33
Thanks all!

I found what I wanted at
http://java.sun.com/docs/books/tutorial/reflect/class/getMethods.html

Sujit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Finding Exposed Methods of a Class
 
Similar Threads
Methods not shown in VAJ EE 4.0.
Generics Confusion in Overriding a method
I need design advice
Obtaining recNo from JTable - wrapping recNo in Room Object(UrlyBird)
Coding Java Bean Using Constants Instead of Variables