[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    Re: XMLBeans 2.0 - Problem with derived/extended schema elements
From:       Jacob Danner <jacob.danner () gmail ! com>
Date:       2010-03-12 22:34:56
Message-ID: bb04eb0a1003121434p45da9c95n51ebfb54def2b562 () mail ! gmail ! com
[Download RAW message or body]

This sounds like a Java problem more than an XMLBeans problem. From
the sounds of it you are trying to cast up. In other words you
AddressType -> Cannot be cast to -> EmployeeAddress
But you were expecting something like this.
EmployeeAddress -> Can be cast to -> AddressType

Rather than use constructors from EmployeeAddressImpl, why not use the
EmployeeAddress.Factory.parse(...)/newInstance(...)
based on how you are writing/starting your instance.

-jacobd

On Fri, Mar 12, 2010 at 12:18 PM, Sri Harsha Yenuganti
<shyenuganti@gmail.com> wrote:
> 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
> shyenuganti@gmail.com
>
> "  IF YOU ARE NOT BRAVE ENOUGH TO FACE A FAILURE YOU ARE UNFIT TO
> SUCCEED.AIM HIGH BUT BE PREPARED FOR THE WORST. "
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic