Binding compiler should check for class assignability instead of exact type.
----------------------------------------------------------------------------

         Key: JIBX-95
         URL: http://jira.codehaus.org/browse/JIBX-95
     Project: JiBX
        Type: Bug

  Components: core  
    Versions: 1.0-RC2    
 Environment: jdk 1.5
    Reporter: Maros Ivanco


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) {
                return false;
        }
        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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
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_id=7637&alloc_id=16865&op=click
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to