Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.0-RC2
-
Fix Version/s: None
-
Component/s: core
-
Labels:None
-
Environment:jdk 1.5
-
Number of attachments :
Description
Binding compiler should check for class assignability instead of exact type name matching between structure type and mapping class. In the mapping:
<structure field="..." type="ParentType"/>
<mapping name="child1" type="Child1" ...>...</mapping>
<mapping name="child2" type="Child2" ...>...</mapping>
.
.
.
the compiler generates error. I workaround this by using custom un/marshaller for structure:
public class ConfigHandler implements IMarshaller, IUnmarshaller{
protected String uri="http://www.datalan.sk/search/robot-config/1.1";
public boolean isExtension(int index)
public void marshal(Object obj, IMarshallingContext ictx) throws JiBXException
{ if(!(ictx instanceof MarshallingContext)) throw new JiBXException("Invalid object type for marshaller"); ((IMarshallable)obj).marshal(ictx); }public boolean isPresent(IUnmarshallingContext ctx) throws JiBXException
{ return ctx.isAt(uri, "processing-option")||ctx.isAt(uri, "processing-chain")||ctx.isAt(uri, "processor"); }public Object unmarshal(Object obj, IUnmarshallingContext ctx) throws JiBXException
{ return ctx.unmarshalElement(); }} // end of type
Even though the un/marshaller is that trivial, (or perhaps because of it) the behaviour should be implemented directly by JiBX.
Please provide a complete sample for your problem report, including both the relevant portions of the binding definition and the corresponding Java code. Also give the error description provided by the binding compiler.