Skip to content

Commit

Permalink
Merge part of #471 ahead of it (to reduce diff) (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored Apr 4, 2024
1 parent b41a64e commit 9039e78
Showing 1 changed file with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1021,12 +1021,7 @@ protected JsonToken _handleNamedValue() throws IOException
}
}
_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 @@ -1048,12 +1043,7 @@ protected JsonToken _handleUnnamedValue() throws IOException
// 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 @@ -1093,12 +1083,7 @@ protected JsonToken _handleArrayValue() throws IOException
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 @@ -1448,4 +1433,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 9039e78

Please sign in to comment.