XMLBeans 2.0 - Problem with derived/extended schema elements

Sri Harsha Yenuganti <[email protected]>
Newsgroups gmane.text.xml.xmlbeans.user
Message-ID <[email protected]>
Hi ,

Here is the problem.

I have the following interfaces ( These interfaces are generated by XMLBeans
) :
------------------------------
Interface AddressType {
.......
}

Interface EmployeeAddress extends AddressType {
..........
}



I have the following implementation classes ( These classes are generated by
XMLBeans ):
------------------------------
Class AddressTypeImpl implements AddressType {
........................
}

Class EmployeeAddressImpl extends AddressTypeImpl implements
EmployeeAddress{
..............................
}


Here is some class that uses these( This class is generated by XMLBeans ) :
------------------------------
class MyClass {

public AddressType someFunc(){
.............

return employeeAddress;
}

}


In some other class i have this code ( This is written by me ) :
------------------------------
EmployeeAddress ea;

EmployeeAddress ea = (EmployeeAddress) myClass.someFunc();


someFunc() returns an object of type AddressType. I am trying to cast it to
EmployeeAddress.

This is throwing me a class cast exception.
" Cannot convert from AddressTypeImpl to EmployeeAddress type "

As AddressType is an interface, we are getting an object of AddressTypeImpl,
not AddressType. These interfaces and classes are generated by XMLBeans. So
I cant instantiate "EmployeeAddressImpl" which takes several XMLBeans custom
parameters in its constructor.

-- 
Sri Harsha Yenuganti
[email protected]

"  IF YOU ARE NOT BRAVE ENOUGH TO FACE A FAILURE YOU ARE UNFIT TO
SUCCEED.AIM HIGH BUT BE PREPARED FOR THE WORST. "
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.