Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems comparing java classes

Status
Not open for further replies.

rdoor

Technical User
May 4, 2002
43
0
0
US
I have a project for an elementary classroom and I'm trying to use Eclipse to access a MySQL database. I have a class called Student and I want to show a properties view for the students.

I'm new to Eclipse and I'm having a hard time figuring out the IAdaptable interface. I've made Student implement IAdaptable and included a getAdapter() method.

public Object getAdapter(Class adapter) {
return Platform.getAdapterManager().getAdapter(this,adapter);
}

I have also an AdapterFactory: The StudentPropertySource(Student) has the methods to return the necessary information to the properties view.

public Object getAdapter(Object adaptableObject, Class adapterType) {
System.out.println(">adaptableObject= "+adaptableObject.getClass()+". adapterType= "+adapterType.getName());
System.out.println(">adapterType==IPropertySource = "+(adapterType == IPropertySource.class));

if (adapterType == IPropertySource.class) {
return new StudentPropertySource((Student) adaptableObject);
}

return null;
}


But, when I run this, I get the following:

>adaptableObject= class madmin.Student. adapterType= org.eclipse.ui.views.properties.IPropertySource
>adapterType == IPropertySource = false

I'm showing that the adapterType is IPropertySource, but the == operator returns false. using equals() does the same. What gives?

Roy
 
Try instanceof operator.

And please don't post in red, it's hard to read, use code tag instead.

Cheers,
Dian
 
Dear Dian:

Thanks! I had tried the instanceof operator and it didn't work either. I figured out that I had a duplicate view.jar file in the classpath of my plugin and eliminating one of them took care of the problem.

Roy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top