Translate

Thursday, November 09, 2006

Searching inherited methods

A neat feature of Class Viewer which deserves its own post is the way to search through inherited methods as to do that you have to type a search string into the "Search String" box, and hit Enter.

So why did I separate out searchers from inherited methods in that way, as the other ways to search methods like double-clicking on text in the left hand window will NOT pull up inherited methods?

Well back when I was developing the program I just thought at times way too many methods would get pulled in from superclasses, and figured, hey, I should stop that!

So I did. But I knew you needed at times to look for inherited ones so I connected that to the search string box, but I ended up with a bonus.

For instance typing in "Panel" in the Class Name area, I pull up java.awt.Panel, and notice that its superclass is java.awt.Container.

It turns out the superclass has a method called remove(Component). And I'm copying from the program so of course that means the method takes a Component as an argument.

Well, if you do a search on "remove" in the "Search String" box, you get nothing but methods from the superclass since Panel doesn't have any, and here's an example:

void Container.remove(Component)


And you can see that it has "Container" on the front of it, so you see what its inherited from which I thought was just this annoying little thing which was a problem with how I was pulling off package names, but here's another method from that list:

synchronized void Component.remove(MenuComponent)

And, of course, the superclass of Container is Component and you have a method inherited down the line from it, and because of that extra that I first thought was annoying, you know where it came from!

So I decided not to figure out a way to clear it out.

And then the neat trick of searching on inherited methods is that because of the way I clear out package names, you get left-over telling you where that method is coming from, as in which superclass, and now I like it, so it stays!


James Harris
Post a Comment