Hi all,
I am writing a custom unmarshaller and marshaller for the root element
of a XML / root of an object structure.
I think the jibx binding compiler does not like it when I have two
different classes for the marshaller and unmarshaller. Looks like the
generated class file corresponding to the Unmarshaller replaces the
generated class file relating to the Marshaller.
But If I have the same class to do both marshalling and unmarshalling,
then everything looks fine.
For example:
Case 1 :
Say I have the following mapping definition:
<mapping class="someclass" name="someElement"
marshaller="MyMarshallerClass"
unmarshaller="MyUnmarshallerClass" />
this generates only a class file called
JiBX_dma_bindingMyUnmarshallerClass_0.class, in addition to the other
class files corresponding to stuff defined in the bindings.xml. I had a
look in to the decompiled source and see something like this.
package test;
import org.jibx.runtime.IMarshaller;
import org.jibx.runtime.IUnmarshaller;
import com.MyUnmarshallerClass;
public class JiBX_dma_bindingMyUnmarshallerClass _0 extends
MyUnmarshallerClass
implements IUnmarshaller, IMarshaller
{
public JiBX_dma_bindingOrderUnmarshaller_0()
{
super(null, 0, "RootElementName");
}
}
Case 2 :
When I have the mapping as following:
<mapping class="someclass" name="someElement"
marshaller="MyMarshallerClass"
unmarshaller="MyMarshallerClass" />
Note: here I am using the same class , which acts as both a marshaller
and an unmarshaller, implementing both IUnmarshaller and IMarshaller
interfaces.
In this case, the binding compiler generates only a class file called
JiBX_dma_bindingMyMarshallerClass _0.class. The source of this is:
package test;
import org.jibx.runtime.IMarshaller;
import org.jibx.runtime.IUnmarshaller;
import com.MyMarshallerClass;
public class JiBX_dma_bindingMyMarshallerClass _0 extends
MyMarshallerClass
implements IUnmarshaller, IMarshaller
{
public JiBX_dma_bindingMyMarshallerClass _0()
{
super(null, 0, "RootElementName");
}
}
In case 1, when I try to marshall, I get
Exception in thread "main" java.lang.AbstractMethodError:
com.JiBX_dma_bindingMyUnmarshallerClass
_0.marshal(Ljava/lang/Object;Lorg/jibx/runtime/IMarshallingContext;)V
,, obviously because my unmarshaller class does not define the marshall
method, ,,, . But I did this purposely, since I wanted the marshaller
and unmarshaller code to be in different classes.
Ok. Now the question is : Is it mandatory for both marshaller and
unmarshaller to be the same class, for jibx to work properly.
Thanks in advance for any replies.
The information contained in this email is strictly confidential and for the
use of the addressee only, unless otherwise indicated. If you are not the
intended recipient, please do not read, copy, use or disclose to others this
message or any attachment. Please also notify the sender by replying to this
email or by telephone (+44 (0)20 7896 0011) and then delete the email and any
copies of it. Opinions, conclusions (etc.) that do not relate to the official
business of this company shall be understood as neither given nor endorsed by
it. IG Index plc is a company registered in England and Wales under number
01190902. VAT registration number 761 2978 07. Registered Office: Friars House,
157-168 Blackfriars Road, London SE1 8EZ. Authorised and regulated by the
Financial Services Authority. FSA Register number 114059.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users