Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.0-alpha-20
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Windows XP. Maven 2.0 build
-
Complexity:Intermediate
-
Patch Submitted:Yes
-
Number of attachments :
Description
I have created a .mdo with a required attribute named "count" with a type of "int", and I built with Maven using the goals "java" and "xpp3-writer".
Here is the snippet from my .mdo file for the attribute.
<field xml.attribute="true">
<version>1.0.0</version>
<name>count</name>
<required>true</required>
<type>int</type>
</field>
The java objects are all created correctly; however, if I put a zero into the count field, it is not outputted in the XML. It does output if I use a non-zero value. I can see in the generated source file OutputXpp3Writer.java is checking for zero before it writes the attribute. I assume this is done to determine if the user code has written into that field.
if ( tag.getCount() != 0 )
{ ... output attribute ... }In my code I wish to set the count value to zero. I realize there needs to be a check in the XPP code to determine if the value has been written; however, checking against the default value of zero seems flawed. This method works well for String since "null" isn't a valid string; however, I think for the basic types need some type of isSet flag to determine if the value has been written or not.
I didn't test with the other basic types, but I assume all the integer based types have the same issue of checking against the zero default.