[jira] [Commented] (CSV-82) CSVRecord inconsistent behaviour when header mapping is not found
[ https://issues.apache.org/jira/browse/CSV-82?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13692006#comment-13692006 ] Emmanuel Bourg commented on CSV-82: --- Sounds good. We probably want to better document isMapped/isSet though, the difference is not obvious when reading the javadoc. > CSVRecord inconsistent behaviour when header mapping is not found > - > > Key: CSV-82 > URL: https://issues.apache.org/jira/browse/CSV-82 > Project: Commons CSV > Issue Type: Bug >Reporter: Sebb > > The CSVRecord#get(String) method has inconsistent behaviour. > If no header mapping was provided, then it throws IllegalStateException. > If the header name is not found, null is returned. > Apart from being inconsistent, it might be useful in the future to be able to > return null as a column value (as distinct from the empty string). > It should throw IllegalArgumentException for a missing header name, instead > of returning null. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CSV-82) CSVRecord inconsistent behaviour when header mapping is not found
[ https://issues.apache.org/jira/browse/CSV-82?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13691688#comment-13691688 ] Gary Gregory commented on CSV-82: - Can we close this issue? > CSVRecord inconsistent behaviour when header mapping is not found > - > > Key: CSV-82 > URL: https://issues.apache.org/jira/browse/CSV-82 > Project: Commons CSV > Issue Type: Bug >Reporter: Sebb > > The CSVRecord#get(String) method has inconsistent behaviour. > If no header mapping was provided, then it throws IllegalStateException. > If the header name is not found, null is returned. > Apart from being inconsistent, it might be useful in the future to be able to > return null as a column value (as distinct from the empty string). > It should throw IllegalArgumentException for a missing header name, instead > of returning null. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CSV-82) CSVRecord inconsistent behaviour when header mapping is not found
[ https://issues.apache.org/jira/browse/CSV-82?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13608126#comment-13608126 ] Benedikt Ritter commented on CSV-82: Returning null is the same behavior as defined by {{java.util.Map.get(Object)}}. When a Map returns null on {{get(Object)}}, you don't know if this is, because null was associated with the key (given you are using a Map implementation that allows null values) or because no mapping for the given key is available. Map provides {{contains(Object)}} to distinguish between the two cases. {{CSVRecord}} OTOH provides {{isMapped(String)}} and {{isSet(String)}} for this. > CSVRecord inconsistent behaviour when header mapping is not found > - > > Key: CSV-82 > URL: https://issues.apache.org/jira/browse/CSV-82 > Project: Commons CSV > Issue Type: Bug >Reporter: Sebb > > The CSVRecord#get(String) method has inconsistent behaviour. > If no header mapping was provided, then it throws IllegalStateException. > If the header name is not found, null is returned. > Apart from being inconsistent, it might be useful in the future to be able to > return null as a column value (as distinct from the empty string). > It should throw IllegalArgumentException for a missing header name, instead > of returning null. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CSV-82) CSVRecord inconsistent behaviour when header mapping is not found
[ https://issues.apache.org/jira/browse/CSV-82?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13238440#comment-13238440 ] Emmanuel Bourg commented on CSV-82: --- The header line should indeed identify all the columns of the file, but the parsing code might be ready to handle more columns than actually present. I have a case where a file contains a date and a time column. The file is generated by a servlet, and depending on a query parameter the time column might be omitted. There is a unique parsing code for both cases, this code considers the time information as optional. It fetches the time column by name and simply ignores a null value. > CSVRecord inconsistent behaviour when header mapping is not found > - > > Key: CSV-82 > URL: https://issues.apache.org/jira/browse/CSV-82 > Project: Commons CSV > Issue Type: Bug >Reporter: Sebb > > The CSVRecord#get(String) method has inconsistent behaviour. > If no header mapping was provided, then it throws IllegalStateException. > If the header name is not found, null is returned. > Apart from being inconsistent, it might be useful in the future to be able to > return null as a column value (as distinct from the empty string). > It should throw IllegalArgumentException for a missing header name, instead > of returning null. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CSV-82) CSVRecord inconsistent behaviour when header mapping is not found
[ https://issues.apache.org/jira/browse/CSV-82?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13238362#comment-13238362 ] Sebb commented on CSV-82: - bq. In case 2 a null value is returned, because some column may be optional. I don't understand this concept of optional columns. Surely any CSV header line needs to provide names for all the columns? Otherwise, what's the point of the header line? > CSVRecord inconsistent behaviour when header mapping is not found > - > > Key: CSV-82 > URL: https://issues.apache.org/jira/browse/CSV-82 > Project: Commons CSV > Issue Type: Bug >Reporter: Sebb > > The CSVRecord#get(String) method has inconsistent behaviour. > If no header mapping was provided, then it throws IllegalStateException. > If the header name is not found, null is returned. > Apart from being inconsistent, it might be useful in the future to be able to > return null as a column value (as distinct from the empty string). > It should throw IllegalArgumentException for a missing header name, instead > of returning null. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CSV-82) CSVRecord inconsistent behaviour when header mapping is not found
[ https://issues.apache.org/jira/browse/CSV-82?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13238343#comment-13238343 ] Emmanuel Bourg commented on CSV-82: --- I don't find this inconsistent. There are two cases to handle: # The header is missing and a field is accessed by name # The header is present but the column name requested doesn't exist In case 1 an IllegalStateException is thrown, because the expectation of the user is severely broken. He attempts to access the fields by name which is completely impossible. In case 2 a null value is returned, because some column may be optional. It's not reasonable to throw an exception in this case, otherwise reading optional columns in a try catch block will become very cumbersome. If you want to differentiate between missing columns and null values this can be done with a CSVRecord#has(String) method. But is it actually useful? > CSVRecord inconsistent behaviour when header mapping is not found > - > > Key: CSV-82 > URL: https://issues.apache.org/jira/browse/CSV-82 > Project: Commons CSV > Issue Type: Bug >Reporter: Sebb > > The CSVRecord#get(String) method has inconsistent behaviour. > If no header mapping was provided, then it throws IllegalStateException. > If the header name is not found, null is returned. > Apart from being inconsistent, it might be useful in the future to be able to > return null as a column value (as distinct from the empty string). > It should throw IllegalArgumentException for a missing header name, instead > of returning null. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira