Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to retrieve the Interface name from Java file?
How to retrieve the Interface name from Java file? [message #643726] Tue, 07 December 2010 21:58 Go to next message
Wesley is currently offline Wesley
Messages: 13
Registered: July 2010
Junior Member
As the title says, I'm trying to retrieve the full interface name from a java class file, example:

import test.IUserService;

public class UserService implements IUserservice{}

I created a listener that gave me acess to the compilationunit of UserService, but now I want to retrive the full qualified name of the interface that UserService is implementing, which is, in this case "test.IUserService"
Can anyone tell me how?
Re: How to retrieve the Interface name from Java file? [message #643730 is a reply to message #643726] Tue, 07 December 2010 22:02 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak Azad
Messages: 545
Registered: July 2009
Senior Member
On 12/8/2010 8:28 AM, Wesley wrote:
> As the title says, I'm trying to retrieve the full interface name from a
> java class file, example:
>
> import test.IUserService;
>
> public class UserService implements IUserservice{}
>
> I created a listener that gave me acess to the compilationunit of
> UserService, but now I want to retrive the full qualified name of the
> interface that UserService is implementing, which is, in this case
> "test.IUserService"
> Can anyone tell me how?
Try
org.eclipse.jdt.core.ICompilationUnit.getTypes()
and then
org.eclipse.jdt.core.IType.getSuperInterfaceNames()
Re: How to retrieve the Interface name from Java file? [message #643845 is a reply to message #643730] Wed, 08 December 2010 08:34 Go to previous messageGo to next message
Wesley is currently offline Wesley
Messages: 13
Registered: July 2010
Junior Member
Quote:
Try
org.eclipse.jdt.core.ICompilationUnit.getTypes()
and then
org.eclipse.jdt.core.IType.getSuperInterfaceNames()


Thanks for the answer!
I've already tried this, but the name returned is the unresolved one, in this example i would have "QIUserService", but i need the resolved one: "test.IUserService".
Is there any way to convert?
Re: How to retrieve the Interface name from Java file? [message #643875 is a reply to message #643845] Wed, 08 December 2010 09:06 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak Azad
Messages: 545
Registered: July 2009
Senior Member
On 12/8/2010 7:04 PM, Wesley wrote:
> Quote:
>> Try
>> org.eclipse.jdt.core.ICompilationUnit.getTypes()
>> and then
>> org.eclipse.jdt.core.IType.getSuperInterfaceNames()
>
>
> Thanks for the answer!
> I've already tried this, but the name returned is the unresolved one, in
> this example i would have "QIUserService", but i need the resolved one:
> "test.IUserService". Is there any way to convert?
Did you try org.eclipse.jdt.core.IType.resolveType(String) ?
Re: How to retrieve the Interface name from Java file? [message #643956 is a reply to message #643875] Wed, 08 December 2010 14:52 Go to previous message
Wesley is currently offline Wesley
Messages: 13
Registered: July 2010
Junior Member
Quote:
Did you try org.eclipse.jdt.core.IType.resolveType(String) ?


That worked! Thanks... Razz
Previous Topic:How to print "Project Explorer" pane (only) ?
Next Topic:Verify Launch Attributes...
Goto Forum:
  


Current Time: Wed Jul 30 09:23:52 EDT 2014

Powered by FUDForum. Page generated in 0.02877 seconds