Menu

#51 ParseBool(String trueValue, String falseValue) Bug

Outstanding
closed
nobody
ParseBool (1)
5
2015-01-04
2014-05-10
No

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")

Related

Bugs: #51

Discussion

  • James Bassett

    James Bassett - 2014-05-10

    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.

     
    • CuriousMindOfMankind

      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:

      Yes, there's a feature requesthttp://sourceforge.net/p/supercsv/feature-requests/40/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.


      Status: open
      Group: Outstanding
      Labels: ParseBool
      Created: Sat May 10, 2014 01:03 AM UTC by CuriousMindOfMankind
      Last Updated: Sat May 10, 2014 01:03 AM UTC
      Owner: nobody

      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")


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/supercsv/bugs/51/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #51

  • James Bassett

    James Bassett - 2015-01-04
    • Status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.