Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit 4702e05

Browse files
committed
Add CsvParser.nextTextValue() impl as well
1 parent 8db3dc0 commit 4702e05

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/main/java/com/fasterxml/jackson/dataformat/csv/CsvParser.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ public String nextFieldName() throws IOException
501501
{
502502
// Optimize for expected case of getting FIELD_NAME:
503503
if (_state == STATE_NEXT_ENTRY) {
504+
_binaryValue = null;
504505
JsonToken t = _handleNextEntry();
505506
_currToken = t;
506507
if (t == JsonToken.FIELD_NAME) {
@@ -511,7 +512,28 @@ public String nextFieldName() throws IOException
511512
// unlikely, but verify just in case
512513
return (nextToken() == JsonToken.FIELD_NAME) ? getCurrentName() : null;
513514
}
514-
515+
516+
@Override
517+
public String nextTextValue() throws IOException
518+
{
519+
_binaryValue = null;
520+
JsonToken t;
521+
if (_state == STATE_NAMED_VALUE) {
522+
_currToken = t = _handleNamedValue();
523+
if (t == JsonToken.VALUE_STRING) {
524+
return _currentValue;
525+
}
526+
} else if (_state == STATE_UNNAMED_VALUE) {
527+
_currToken = t = _handleUnnamedValue();
528+
if (t == JsonToken.VALUE_STRING) {
529+
return _currentValue;
530+
}
531+
} else {
532+
t = nextToken();
533+
}
534+
return (t == JsonToken.VALUE_STRING) ? getText() : null;
535+
}
536+
515537
/*
516538
/**********************************************************
517539
/* Parsing, helper methods

0 commit comments

Comments
 (0)