Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » What is the best way to find an interface for Java classes
What is the best way to find an interface for Java classes [message #506476] Thu, 07 January 2010 06:28 Go to next message
Eclipse UserFriend
Hi All,

I have a workspace which contains a lot of Java classes, for those Java classes, I need to find out those that implements/extends a particular interface. since my code is performance sensitive, I need to find out the fastest way for doing this search. I've tried some APIs:
1. IType.getSuperInterfaceNames(),
this one only returns the direct interfaces (not working for me)
2. ITypeHierarchy hierarchy = classType.newSupertypeHierarchy(null);
IType[] interfaces = hierarchy.getAllInterfaces();
This one works for me, but my question is will "newSupertypeHierarchy" be expensive when doing the search for each class?

Does any one know any other better ways? Thanks for your help and appreciate it.
Re: What is the best way to find an interface for Java classes [message #506485 is a reply to message #506476] Thu, 07 January 2010 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Benson Ning wrote:
> Hi All,
>
> I have a workspace which contains a lot of Java classes, for those
> Java classes, I need to find out those that implements/extends a
> particular interface. since my code is performance sensitive, I need
> to find out the fastest way for doing this search. I've tried some
> APIs: 1. IType.getSuperInterfaceNames(), this one only returns the
> direct interfaces (not working for me)
> 2. ITypeHierarchy hierarchy = classType.newSupertypeHierarchy(null);
> IType[] interfaces = hierarchy.getAllInterfaces();
> This one works for me, but my question is will "newSupertypeHierarchy"
> be expensive when doing the search for each class?
>
> Does any one know any other better ways?
Use the org.eclipse.jdt.core.search.SearchEngine.

Dani
> Thanks for your help and appreciate it.
Re: What is the best way to find an interface for Java classes [message #506490 is a reply to message #506476] Thu, 07 January 2010 12:11 Go to previous messageGo to next message
Eclipse UserFriend
thanks for the reply, may be one more thing I need to clarify, I am looking for the way for the IType level. Can the SearchEngine do the search only for one IType? Thanks for your time.
Re: What is the best way to find an interface for Java classes [message #506494 is a reply to message #506490] Thu, 07 January 2010 12:41 Go to previous message
Eclipse UserFriend
Benson Ning wrote:
> thanks for the reply, may be one more thing I need to clarify, I am
> looking for the way for the IType level. Can the SearchEngine do the
> search only for one IType?
Sure.

Dani
> Thanks for your time.
Previous Topic:Eclipse need binary?
Next Topic:bindings are null
Goto Forum:
  


Current Time: Tue Apr 29 08:33:39 EDT 2025

Powered by FUDForum. Page generated in 0.04748 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top