File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding Exposed Methods of a Class

 
K Sujit
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
K Sujit
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all!

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

Sujit
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic