You'd need to define your own custom deserializer for Integer to make
this work properly - just return null if passed an empty String,
otherwise create and return the appropriate Integer. This is deliberate,
since it's not clear what someone would want for an empty string (the
value 0? a null?). Setting usage="optional" on a text value is really
only going to effect marshalling, since there's always going to be a
string present when unmarshalling.
- Dennis
Paras Jain wrote:
Hi,
I am getting the NumberFormat exception while unmarshalling. Root of
the problem seems to be empty element
Here are the details
public class MyexampleClass {
Integer INTEGER_FIELD;
Date DATE_FIELD;
...getter and setter methods
}
Binding file is
<mapping name="EXAMPLE_CLASS" class="examples.MyexampleClass ">
<structure name="INTEGER_FIELD">
<value usage="optional" style="text" field="INTEGER_FIELD"></value>
</structure>
<structure name="DATE_FIELD">
<value usage="optional" style="text" field="DATE_FIELD"
serializer="examples.CustomDateMarshallerUnmarshaller.serialize"
deserializer="examples.CustomDateMarshallerUnmarshaller.deserialize">
</value>
</structure>
</mapping>
My data file is
<EXAMPLE_CLASS>
<INTEGER_FIELD/>
<DATE_FIELD/>
</EXAMPLE_CLASS>
When I both the fields are empty I get NumberFormatException for input
string "" for integer.
But if INTEGER_FIELD is set to some integer it works fine because for
Date I have custom marshaller unmarshaller.
Why don't empty tags in case of Integer works even if I have
specified usage="optional" in my binding file
Please suggest me? Help me
Regards,
Paras
--
Paras Jain
Software Engineer
Cell - +91-9329427774
-------------------------------------------------------
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-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users