From: Jeff W. <jww...@ya...> - 2004-09-01 02:10:24
|
I think I may have found something that might at least partially explain the problems I'm experiencing with Converters and I'd love to hear an opinion or two. In the constructor for the SysexGetDialog class is the following code: // First Populate the Device/Driver List with all Device/Driver // combinations except converters // skip 0 (Generic Device) for (int i=1; i < AppConfig.deviceCount(); i++) { Device device=AppConfig.getDevice(i); for (int j=0; j < device.driverCount(); j++) { IDriver driver = device.getDriver(j); if (driver instanceof IPatchDriver) { // Skipping a converter deviceComboBox.addItem(device); break; } } } I was able to step through this code with a debugger and what I found was that the condition in the if statement: if (driver instanceof IPatchDriver) { // Skipping a converter is returning a true condition even when driver is a Converter. (Note this condition is being used in a few other places, too). I decided to check the class and interface hierarchies using a class browser. Stripping away all the stuff that didn't seem relative, this is what I found: Interface Hierarchy-- IDriver IConverter extends IDriver IPatchDriver extends IDriver IBankDriver extends IPatchDriver ISingleDriver extends IPatchDriver Class Hierarchy-- Driver implements ISingleDriver BankDriver extends Driver implements IBankDriver Converter extends Driver implements IConverter Even though Converter does not directly implement IPatchDriver, notice that it extends Driver, which implements ISingleDriver, which extends IPatchDriver. I'm certainly no expert with interfaces and maybe I'm missing something here but doesn't that mean that Converter implements IPatchDriver indirectly? Is that the reason why the condition (driver instanceof IPatchDriver) returns true for a Converter? __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |