I believe there is a bug in the implementation of:
ParseBool(String trueValue, String falseValue)
And the same should be true for:
ParseBool(final String[] trueValues, final String[] falseValues[])
When adding to the list of ParseBool.trueValues or ParseBool.falseValues (lines 124, 125) you simply add in whatever string is passed to the constructor.
trueValues.add(trueValue);
falseValues.add(falseValue);
But when comparing you convert the stringValue to lowercase.
final String stringValue = ((String) value).toLowerCase();
final Boolean result;
if( trueValues.contains(stringValue) ) {
result = Boolean.TRUE;
} else if( falseValues.contains(stringValue) ) {
result = Boolean.FALSE;
} else {
throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a Boolean", value),
context, this);
}
Therefore I received an error that 'Yes' could not be converted even though my rule was setup as:
new ParseBool("Yes", "No")
Yes, there's a feature request regarding this issue. As stated there, it's actually the documented behaviour. Even so, it should probably be changed as that's more in line with what you'd think if you don't read the doco. The only issue is backwards compatibility, but I think it could be sacrificed in this case.
Thanks for the reply James! Don't know how I missed that in the Javadoc.
It's spelled out quite plainly! Sorry for the hassle.
Jay
On Fri, May 9, 2014 at 9:32 PM, James Bassett jamesbassett@users.sf.netwrote:
Related
Bugs:
#51