Hi,
I have an issue with binding and class inheritance. Take the classes
public class A
{
private int a;
}
public class B extends A
{
int b;
}
and the binding file
<binding>
<mapping name="data" class="A">
<value name="a" field="a"/>
</mapping>
<mapping name="data" class="B" extends="A">
<structure map-as="A"/>
</mapping>
</binding>
- The mapping for A isn't abstract because I need to create concrete
instances of both A and B.
- Class B adds data when extending A but this data does not play any
part in marshalling/unmarshalling.
- The top level element for both A and B is 'data'.
Now I unmarshal the XML
<?xml version=\"1.0\" encoding=\"UTF-8\"?><data><a>24</a></data>
when I pass A.class to the getFactory method in preparation for
unmarshalling, all works as expected. When I pass B.class to the
getFactory method in preparation for unmarshalling, the unmarshalling
method returns an object of class A (not class B).
This does not seem correct. I'm not sure if giving two mappings the same
name is allowed. In the real situation I derived this example from I
need to use the same top level element. Anyone have any idea what is
going on, or what I am doing wrong?
The above was my attempt to get round a limitation with inheritance.
Namely, if class B extends class A, and I have a defined binding for
class A, then I want to be able to marshal/unmarshal objects of class B
implicitly. That is, when I marshal B the run-time would look at class
B, see it doesn't have any binding information, but notice superclass A
does so just use A. I am not familiar with the inner workings of JiBX so
that may be a big ask. Is it a feasible extension?
Thanks,
Paul
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users