@@ -154,24 +154,24 @@ public boolean hasNext() {
154154 if (CSVParser .this .isClosed ()) {
155155 return false ;
156156 }
157- if (this . current == null ) {
158- this . current = this . getNextRecord ();
157+ if (current == null ) {
158+ current = getNextRecord ();
159159 }
160160
161- return this . current != null ;
161+ return current != null ;
162162 }
163163
164164 @ Override
165165 public CSVRecord next () {
166166 if (CSVParser .this .isClosed ()) {
167167 throw new NoSuchElementException ("CSVParser has been closed" );
168168 }
169- CSVRecord next = this . current ;
170- this . current = null ;
169+ CSVRecord next = current ;
170+ current = null ;
171171
172172 if (next == null ) {
173173 // hasNext() wasn't called before
174- next = this . getNextRecord ();
174+ next = getNextRecord ();
175175 if (next == null ) {
176176 throw new NoSuchElementException ("No more CSV records available" );
177177 }
@@ -427,7 +427,6 @@ public CSVParser(final Reader reader, final CSVFormat format, final long charact
427427 throws IOException {
428428 Objects .requireNonNull (reader , "reader" );
429429 Objects .requireNonNull (format , "format" );
430-
431430 this .format = format .copy ();
432431 this .lexer = new Lexer (format , new ExtendedBufferedReader (reader ));
433432 this .csvRecordIterator = new CSVRecordIterator ();
@@ -437,11 +436,11 @@ public CSVParser(final Reader reader, final CSVFormat format, final long charact
437436 }
438437
439438 private void addRecordValue (final boolean lastRecord ) {
440- final String input = this . format .trim (this . reusableToken .content .toString ());
441- if (lastRecord && input .isEmpty () && this . format .getTrailingDelimiter ()) {
439+ final String input = format .trim (reusableToken .content .toString ());
440+ if (lastRecord && input .isEmpty () && format .getTrailingDelimiter ()) {
442441 return ;
443442 }
444- this . recordList .add (handleNull (input ));
443+ recordList .add (handleNull (input ));
445444 }
446445
447446 /**
@@ -452,13 +451,13 @@ private void addRecordValue(final boolean lastRecord) {
452451 */
453452 @ Override
454453 public void close () throws IOException {
455- if (this . lexer != null ) {
456- this . lexer .close ();
454+ if (lexer != null ) {
455+ lexer .close ();
457456 }
458457 }
459458
460459 private Map <String , Integer > createEmptyHeaderMap () {
461- return this . format .getIgnoreHeaderCase () ?
460+ return format .getIgnoreHeaderCase () ?
462461 new TreeMap <>(String .CASE_INSENSITIVE_ORDER ) :
463462 new LinkedHashMap <>();
464463 }
@@ -472,20 +471,20 @@ private Map<String, Integer> createEmptyHeaderMap() {
472471 private Headers createHeaders () throws IOException {
473472 Map <String , Integer > hdrMap = null ;
474473 List <String > headerNames = null ;
475- final String [] formatHeader = this . format .getHeader ();
474+ final String [] formatHeader = format .getHeader ();
476475 if (formatHeader != null ) {
477476 hdrMap = createEmptyHeaderMap ();
478477 String [] headerRecord = null ;
479478 if (formatHeader .length == 0 ) {
480479 // read the header from the first line of the file
481- final CSVRecord nextRecord = this . nextRecord ();
480+ final CSVRecord nextRecord = nextRecord ();
482481 if (nextRecord != null ) {
483482 headerRecord = nextRecord .values ();
484483 headerComment = nextRecord .getComment ();
485484 }
486485 } else {
487- if (this . format .getSkipHeaderRecord ()) {
488- final CSVRecord nextRecord = this . nextRecord ();
486+ if (format .getSkipHeaderRecord ()) {
487+ final CSVRecord nextRecord = nextRecord ();
489488 if (nextRecord != null ) {
490489 headerComment = nextRecord .getComment ();
491490 }
@@ -500,13 +499,13 @@ private Headers createHeaders() throws IOException {
500499 for (int i = 0 ; i < headerRecord .length ; i ++) {
501500 final String header = headerRecord [i ];
502501 final boolean blankHeader = CSVFormat .isBlank (header );
503- if (blankHeader && !this . format .getAllowMissingColumnNames ()) {
502+ if (blankHeader && !format .getAllowMissingColumnNames ()) {
504503 throw new IllegalArgumentException (
505504 "A header name is missing in " + Arrays .toString (headerRecord ));
506505 }
507506
508507 final boolean containsHeader = blankHeader ? observedMissing : hdrMap .containsKey (header );
509- final DuplicateHeaderMode headerMode = this . format .getDuplicateHeaderMode ();
508+ final DuplicateHeaderMode headerMode = format .getDuplicateHeaderMode ();
510509 final boolean duplicatesAllowed = headerMode == DuplicateHeaderMode .ALLOW_ALL ;
511510 final boolean emptyDuplicatesAllowed = headerMode == DuplicateHeaderMode .ALLOW_EMPTY ;
512511
@@ -546,7 +545,7 @@ private Headers createHeaders() throws IOException {
546545 * @return current line number
547546 */
548547 public long getCurrentLineNumber () {
549- return this . lexer .getCurrentLineNumber ();
548+ return lexer .getCurrentLineNumber ();
550549 }
551550
552551 /**
@@ -583,11 +582,11 @@ public String getHeaderComment() {
583582 * @return a copy of the header map.
584583 */
585584 public Map <String , Integer > getHeaderMap () {
586- if (this . headers .headerMap == null ) {
585+ if (headers .headerMap == null ) {
587586 return null ;
588587 }
589588 final Map <String , Integer > map = createEmptyHeaderMap ();
590- map .putAll (this . headers .headerMap );
589+ map .putAll (headers .headerMap );
591590 return map ;
592591 }
593592
@@ -597,7 +596,7 @@ public Map<String, Integer> getHeaderMap() {
597596 * @return the underlying header map.
598597 */
599598 Map <String , Integer > getHeaderMapRaw () {
600- return this . headers .headerMap ;
599+ return headers .headerMap ;
601600 }
602601
603602 /**
@@ -627,7 +626,7 @@ public List<String> getHeaderNames() {
627626 * @return current record number
628627 */
629628 public long getRecordNumber () {
630- return this . recordNumber ;
629+ return recordNumber ;
631630 }
632631
633632 /**
@@ -665,7 +664,7 @@ public String getTrailerComment() {
665664 * @return null if input is parsed as null, or input itself if the input isn't parsed as null
666665 */
667666 private String handleNull (final String input ) {
668- final boolean isQuoted = this . reusableToken .isQuoted ;
667+ final boolean isQuoted = reusableToken .isQuoted ;
669668 final String nullString = format .getNullString ();
670669 final boolean strictQuoteMode = isStrictQuoteMode ();
671670 if (input .equals (nullString )) {
@@ -711,7 +710,7 @@ public boolean hasTrailerComment() {
711710 * @return whether this parser is closed.
712711 */
713712 public boolean isClosed () {
714- return this . lexer .isClosed ();
713+ return lexer .isClosed ();
715714 }
716715
717716 /**
@@ -721,8 +720,8 @@ public boolean isClosed() {
721720 * {@link QuoteMode#NON_NUMERIC}.
722721 */
723722 private boolean isStrictQuoteMode () {
724- return this . format .getQuoteMode () == QuoteMode .ALL_NON_NULL ||
725- this . format .getQuoteMode () == QuoteMode .NON_NUMERIC ;
723+ return format .getQuoteMode () == QuoteMode .ALL_NON_NULL ||
724+ format .getQuoteMode () == QuoteMode .NON_NUMERIC ;
726725 }
727726
728727 /**
@@ -758,47 +757,47 @@ public Iterator<CSVRecord> iterator() {
758757 */
759758 CSVRecord nextRecord () throws IOException {
760759 CSVRecord result = null ;
761- this . recordList .clear ();
760+ recordList .clear ();
762761 StringBuilder sb = null ;
763- final long startCharPosition = lexer .getCharacterPosition () + this . characterOffset ;
762+ final long startCharPosition = lexer .getCharacterPosition () + characterOffset ;
764763 do {
765- this . reusableToken .reset ();
766- this . lexer .nextToken (this . reusableToken );
767- switch (this . reusableToken .type ) {
764+ reusableToken .reset ();
765+ lexer .nextToken (reusableToken );
766+ switch (reusableToken .type ) {
768767 case TOKEN :
769- this . addRecordValue (false );
768+ addRecordValue (false );
770769 break ;
771770 case EORECORD :
772- this . addRecordValue (true );
771+ addRecordValue (true );
773772 break ;
774773 case EOF :
775- if (this . reusableToken .isReady ) {
776- this . addRecordValue (true );
774+ if (reusableToken .isReady ) {
775+ addRecordValue (true );
777776 } else if (sb != null ) {
778777 trailerComment = sb .toString ();
779778 }
780779 break ;
781780 case INVALID :
782- throw new IOException ("(line " + this . getCurrentLineNumber () + ") invalid parse sequence" );
781+ throw new IOException ("(line " + getCurrentLineNumber () + ") invalid parse sequence" );
783782 case COMMENT : // Ignored currently
784783 if (sb == null ) { // first comment for this record
785784 sb = new StringBuilder ();
786785 } else {
787786 sb .append (Constants .LF );
788787 }
789- sb .append (this . reusableToken .content );
790- this . reusableToken .type = TOKEN ; // Read another token
788+ sb .append (reusableToken .content );
789+ reusableToken .type = TOKEN ; // Read another token
791790 break ;
792791 default :
793- throw new IllegalStateException ("Unexpected Token type: " + this . reusableToken .type );
792+ throw new IllegalStateException ("Unexpected Token type: " + reusableToken .type );
794793 }
795- } while (this . reusableToken .type == TOKEN );
794+ } while (reusableToken .type == TOKEN );
796795
797- if (!this . recordList .isEmpty ()) {
798- this . recordNumber ++;
796+ if (!recordList .isEmpty ()) {
797+ recordNumber ++;
799798 final String comment = sb == null ? null : sb .toString ();
800- result = new CSVRecord (this , this . recordList .toArray (Constants .EMPTY_STRING_ARRAY ), comment ,
801- this . recordNumber , startCharPosition );
799+ result = new CSVRecord (this , recordList .toArray (Constants .EMPTY_STRING_ARRAY ), comment ,
800+ recordNumber , startCharPosition );
802801 }
803802 return result ;
804803 }
0 commit comments