JAXB, downcast an unmarshalled class

Posted by elgcom on Stack Overflow See other posts from Stack Overflow or by elgcom
Published on 2010-05-02T19:55:28Z Indexed on 2010/05/02 19:57 UTC
Read the original article Hit count: 497

Filed under:
|
|

I define two XML type (base and derived types).

 <xs:complexType name="ParentType">
   ...
 </xs:complexType>

 <xs:complexType name="ChildType">
  <xs:complexContent>
  <xs:extension base="ParentType">
   ...
  </xs:complexContent>
 </xs:complexType> 

Now, I have an XML instance of ChildType. The question, If I once unmarshall the XML into ParentType java object, can I downcast the java object to its subclass of ChildType?

Is that possible to that?

thanks

© Stack Overflow or respective owner

Related posts about jaxb

Related posts about java