Conversion options "default-value" and "justify" doesn't work together. With following settings:
<record-element length="4" beanref="competitor.registrationNumber" type="integer">
<conversion-option name="default-value" value="xxxx" />
<conversion-option name="pad-character" value="0"/>
<conversion-option name="justify" value="right" />
</record-element>
the output value is "0000" for null field value instead of "xxxx".
The problem is in following part of ConversionHelper.java:
// JBL - Implement iteration of conversion-options
// Iterate over conversion-options, that way, the xml file
// can drive the order of conversions, instead of having them
// hard-coded like in 'removePadding' (old way)
Set<String> keys = options.keySet();
for (Iterator<String> it = keys.iterator(); it.hasNext();)
{
ConversionOption conv = options.get(it.next());
if (conv.getName().equals("default-value"))
fieldChars = Util.defaultValue(fieldChars, conv.getValue(), options);
if (conv.getName().equals("justify"))
fieldChars = Util.justify(fieldChars, conv.getValue(), options, length);
if (conv.getName().equals("strip-chars"))
fieldChars = Util.strip(fieldChars, conv.getValue(), options);
if (conv.getName().equals("substring"))
fieldChars = Util.substring(fieldChars, conv.getValue(), options);
}
Which is wrong, because XML cannot drive conversion-options order since HashMap doesn't guarantee any precise order.