[Simple-support] ElementList of custom class type with null values
Brought to you by:
niallg
|
From: Farley L. <poy...@ui...> - 2014-09-15 20:13:59
|
Hi,
I'm serializing a list of custom class (non-string) which requires null
values to maintain the element positions.
However, I haven't found the correct annotation to set it and am not even
sure whether it is supported.
I searched the mailing list and there is a case to use null string values
in the list.
{@Textprivate String value;}
But I didn't find the relevant documentation to deal with null element
values in a list of a custom class.
Here is the use case where two lists "names" and "inits" maintain
corresponding element positions and one of them (inits) has a null element
value in the head of the list. The generated xml follows.
<names class="java.util.ArrayList">
<string>num</string>
<string>i</string>
</names>
<inits class="java.util.ArrayList">
<expression class="streamit.frontend.nodes.ExprConstFloat" val="2.0">
<context
fileName="StreamIt/src/test/streamit/FIRcoarse/FIRcoarse.str"
lineNumber="8" columnNumber="18"/>
</expression>
</inits>
Apparently, the null element value is eliminated so as to cause the 2nd
element to be misplaced in the deserialized list.
The expected generated xml should be something like the following.
<names class="java.util.ArrayList">
<string>num</string>
<string>i</string>
</names>
<inits class="java.util.ArrayList">
<expression class="streamit.frontend.nodes.ExprConstFloat" val="2.0"/>
<expression class="streamit.frontend.nodes.ExprConstFloat" val="2.0">
<context
fileName="StreamIt/src/test/streamit/FIRcoarse/FIRcoarse.str"
lineNumber="8" columnNumber="18"/>
</expression>
</inits>
When deserialized, the first element should be set to null instead of
calling the no-argument constructor.
If supported, what is the correct to annotate the element list?
Thanks.
Farley
|