0

I am learning opencsv now,the method parseLine(String nextLine, boolean multi) in CSVParser is a little complex. What is the mearning of the field 'inField' in the class CSVParser? What does 'inQuotes' and 'fromQuotedField' denote in method parseLine(String nextLine, boolean multi); Thanks!

about line 112 in CSVParser : private boolean inField = false ;

about 348 line in parseLine(String nextLine, boolean multi):

    boolean inQuotes = false;
    boolean fromQuotedField = false;

1 Answers1

0

The inQuotes tells the parser that the data it is reading is inside a quoted string - so if a delemeter character is met then it is part of the string instead of a signal to start a new field.

inField has basically the same functionality but it is a global variable (and it is not dependent on quotations). The reason openCSV needs to know this is that the CSVReader feeds the one line at a time - so if there is a line feed inside one of the fields then it will take multiple calls to the CSVParser to build one complete record. Hence the parseLineMulti.

The fromQuoteFields is a new addition for feature request #60. This is used with the null field indicator to detect if you have a set of empty quotes should the field be an empty string or null.

Scott Conway
  • 975
  • 7
  • 13