[
https://issues.apache.org/jira/browse/CSV-152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14588598#comment-14588598
]
Michael Newcomb commented on CSV-152:
-------------------------------------
Well, I was mistaken. I didn't realize in my test that I had set nullString to
"" (empty string) and I was getting nulls from get(). So, without the
CSVFormat, there is no way for the CSVRecord to tell if the value is set or not.
If the CSVRecord had a reference to the CSVFormat, it could:
{code}
public boolean isSet(final String name)
{
return isMapped(name) &&
mapping.get(name) < values.length &&
csvFormat.isNullStringSet() ? values[mapping.get(name)] != null :
!values[mapping.get(name)].isEmpty();
}
{code}
> CSVRecord.isSet() does not check if value is not null
> -----------------------------------------------------
>
> Key: CSV-152
> URL: https://issues.apache.org/jira/browse/CSV-152
> Project: Commons CSV
> Issue Type: Bug
> Reporter: Michael Newcomb
>
> Consider:
> public boolean isSet(final String name)
> {
> return isMapped(name) && mapping.get(name).intValue() < values.length;
> }
> The docs say 'and has a value', however, it does not check if
> values[mapping.get(name)] is null.
> Propose:
> public boolean isSet(final String name)
> {
> return isMapped(name) && mapping.get(name) < values.length &&
> values[mapping.get(name)] != null;
> }
> Perhaps a new method 'hasValue' if the above is not desirable?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)