Skip to main content


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] Wed, 08 December 2010 02:58 Go to next message
Wesley is currently offline WesleyFriend
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] Wed, 08 December 2010 03:02 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
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 13:34 Go to previous messageGo to next message
Wesley is currently offline WesleyFriend
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 14:06 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
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 19:52 Go to previous message
Wesley is currently offline WesleyFriend
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: Thu Apr 25 14:19:49 GMT 2024

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

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

Back to the top