Skip to content

Commit

Permalink
Merge branch '2.18'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 4, 2024
2 parents d77556c + e72230f commit a129497
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions csv/src/main/java/tools/jackson/dataformat/csv/CsvParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -905,12 +905,7 @@ protected JsonToken _handleNamedValue() throws JacksonException
}
}
_state = STATE_NEXT_ENTRY;
if (_nullValue != null) {
if (_nullValue.equals(_currentValue)) {
return JsonToken.VALUE_NULL;
}
}
if (_cfgEmptyStringAsNull && "".equals(_currentValue)) {
if (_isNullValue(_currentValue)) {
return JsonToken.VALUE_NULL;
}
return JsonToken.VALUE_STRING;
Expand All @@ -932,12 +927,7 @@ protected JsonToken _handleUnnamedValue() throws JacksonException
// state remains the same
_currentValue = next;
++_columnIndex;
if (_nullValue != null) {
if (_nullValue.equals(next)) {
return JsonToken.VALUE_NULL;
}
}
if (_cfgEmptyStringAsNull && "".equals(_currentValue)) {
if (_isNullValue(next)) {
return JsonToken.VALUE_NULL;
}
return JsonToken.VALUE_STRING;
Expand Down Expand Up @@ -977,12 +967,7 @@ protected JsonToken _handleArrayValue() throws JacksonException
if (isEnabled(Feature.TRIM_SPACES)) {
_currentValue = _currentValue.trim();
}
if (_nullValue != null) {
if (_nullValue.equals(_currentValue)) {
return JsonToken.VALUE_NULL;
}
}
if (_cfgEmptyStringAsNull && "".equals(_currentValue)) {
if (_isNullValue(_currentValue)) {
return JsonToken.VALUE_NULL;
}
return JsonToken.VALUE_STRING;
Expand Down Expand Up @@ -1346,4 +1331,23 @@ protected void _startArray(CsvSchema.Column column)
}
_arraySeparator = sep;
}


/**
* Helper method called to check whether specified String value should be considered
* "null" value, if so configured.
*
* @since 2.17.1
*/
protected boolean _isNullValue(String value) {
if (_nullValue != null) {
if (_nullValue.equals(value)) {
return true;
}
}
if (_cfgEmptyStringAsNull && _currentValue.isEmpty()) {
return true;
}
return false;
}
}

0 comments on commit a129497

Please sign in to comment.