Menu

#45 SuperCSV doesn't follow official getter/setter naming conventions

2.2.0
closed
None
1
2014-04-24
2013-06-26
No

Look at chapter 8 of the official javabeans spec.

And at the description (and implementation) of Introspector.decapitalize() (docs.oracle.com)

All uppercase property names (or at least the first two letters in uppercase) will be left alone. The property "file" will result in "getFile()", the property "URL" will result in "getURL()", the property "IDs" will result in "getIDs()".

This process is reversible, so from "getURL()" you get the property name "URL", from "getFile()" the property name "file", from "getIDs() you'll get the name "IDs".

The reversability is realized in Introspector.decapitalize().

One side effect, and this is where SuperCSV (as many other libraries) is wrong, is that property names such as "iPad" (i.e. only the second character is upper case) will result in "getiPad()", even if it looks unusual. SuperCSV looks for "getIPad()" and doesn't find it in a correctly defined java bean.

Compare your favorite IDE's (Eclipse, NetBeans, IntelliJ) "generate getters/setters" method which work that way.

Discussion

  • James Bassett

    James Bassett - 2013-06-29

    Thanks Ulrich, you're totally right. We'll fix this in the next release.

     
  • cf126330

    cf126330 - 2014-01-24

    any update? When can we expect the next release? I'm also seeing the same problem, and would really like to see this fixed asap.

    org.supercsv.exception.SuperCsvReflectionException: unable to find method setnumber(java.lang.String)

     
  • James Bassett

    James Bassett - 2014-04-24
    • status: open --> pending
    • assigned_to: James Bassett
    • Group: Outstanding --> 2.2.0
     
  • James Bassett

    James Bassett - 2014-04-24

    Fixed in [r298].

    CsvBeanReader/Writer now ignore the case of any getter/setter when looking for a match.

     

    Related

    Commit: [r298]

  • James Bassett

    James Bassett - 2014-04-24
    • Status: pending --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB