How to set a property reference to an empty collection instead of null
during unmarshalling when the associated element is missing from the
input xml.

 

 

This  binding causes the property to be null when the corresponding
element (list) is missing from the xml: 

 

<binding>

    <mapping name="A" class="a">

            <collection 

name="list" 

get-method="getList" 

set-method="setList"

factory="package.Factory.listFactory"  <!-this method creates and
returns an ArrayList -->

item-type="item"

usage="optional"

test-method="testListIsNullOrEmpty" />

    </mapping>

 

    <mapping ---- for item --/>

 

</binding>

 

I changed the above to the following, it did not help. 

 

<binding>

    <mapping name="A" class="a">

        <structure

            name="list"                   

            usage="optional"

            test-method=" testListIsNullOrEmpty">

            

            <collection

get-method="getList" 

set-method="setList"

factory="package.Factory.listFactory"  <!-this method creates and
returns an ArrayList -->

item-type="item"

 

            </structure>

    </mapping>

 

    <mapping ---- for item --/>

</binding>

 

 

What is the binding missing? Would using post-set method for this
purpose cause any issues/unwanted side effects?

 

Thanks.

 

Regards,

Sunil

 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to