FYI, I filed a bug: http://jira.codehaus.org/browse/JIBX-433

-Archie

On Tue, Mar 29, 2011 at 3:10 PM, Archie Cobbs <arc...@dellroad.org> wrote:

> Looking more at the docs, I guess this is working as designed.
>
> However, this seems like sub-optimal behavior. I would expect JiBX to apply
> a default value only if an explicit default="..." attribute was provided.
> Otherwise, there's no way to have the same non-zero/null default value apply
> in both the Java and XML worlds without having to declare that default value
> twice (which is error-prone and redundant).
>
> -Archie
>
>
> On Tue, Mar 29, 2011 at 2:55 PM, Archie Cobbs <arc...@dellroad.org> wrote:
>
>> I have a JiBX mapping for a serial port that looks like this:
>>
>>     <mapping abstract="true" class="com.exampleSerialConfig">
>>         <value name="baudRate" get-method="getBaudRate"
>> set-method="setBaudRate" usage="optional"/>
>>         ...
>>      </mapping>
>>
>> The getBaudRate()/setBaudRate() methods take a value of type int.
>>
>> I would expect that if the XML contained no <baudRate> element, then
>> setBaudRate() would not be invoked. The underlying Java class initializes
>> this property to 9600, so I would expect that to be the default value if not
>> specified.
>>
>> However, event when there's no <baudRate> element JiBX is invoking
>> setBaudRate() with a value of zero!
>>
>> Where is this zero coming from??
>>
>> Similarly, in the case of object properties, JiBX is always setting the
>> value to null if there's no corresponding XML element.
>>
>> Is this a bug or am I missing something?
>>
>> Thanks,
>> -Archie
>>
>> --
>> Archie L. Cobbs
>>
>>
>
>
> --
> Archie L. Cobbs
>
>


-- 
Archie L. Cobbs
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to