@Override
  public final List<String> readNextRow(final Map<String, Object> pReqVars,
    final Reader pReader, final CsvMethod pCsvMethod) throws Exception {
    List<String> result = null;
    StringBuffer sb = new StringBuffer();
    char colSep = pCsvMethod.getColumnSep().charAt(0);
    CsvColumn colMeth = null;
    Character textDel = null;
    Character textDelWas = null;
    for (CsvColumn cc : pCsvMethod.getColumns()) {
      if (cc.getSourceIndex() == 1) {
        colMeth = cc;
        if (colMeth.getTextDelimiter() != null) {
          textDel = colMeth.getTextDelimiter().charAt(0);
        }
        break;
      }
    }
    int colIdx = 1;
    int textDelOccr = 0;
    int chi;
    int charCount = 0;
    char cr  = (char) 0x0D;
    char lf  = (char) 0x0A;
    while ((chi = pReader.read()) != -1) {
      char ch = (char) chi;
      charCount++;
      if (ch == lf || ch == cr || textDel != null && ch == textDel
        || textDelOccr != 1 && ch == colSep) {
        if (charCount == 1 && (ch == lf || ch == cr)) { //CRLF - > LF
          continue;
        }
        if (textDelWas != null && ch != textDelWas && textDelOccr == 2) {
          //second delimiter after text delimiter
          textDelOccr = 0;
          continue;
        }
        if (textDel != null && ch == textDel) {
          textDelOccr++;
        }
        if (textDelOccr != 1) {
          if (colMeth != null) {
            if (result == null) {
              result = new ArrayList<String>();
            }
            if (sb.length() > 0) {
              result.add(sb.toString());
            } else {
              result.add(null);
            }
          }
          if (ch == lf || ch == cr) {
            //the end of line
            break;
          }
          if (sb.length() > 0) {
            sb.delete(0, sb.length());
          }
          colIdx++;
          colMeth = null;
          textDelWas = textDel;
          textDel = null;
          for (CsvColumn cc : pCsvMethod.getColumns()) {
            if (cc.getSourceIndex() == colIdx) {
              colMeth = cc;
              if (colMeth.getTextDelimiter() != null) {
                textDel = colMeth.getTextDelimiter().charAt(0);
              }
              break;
            }
          }
        }
      } else {
        sb.append(ch);
      }
    }
    return result;
  }
@ Override public final List < String > readNextRow ( final Map < String , Object > pReqVars , final Reader pReader , final CsvMethod pCsvMethod ) throws Exception { List < String > result = null ; StringBuffer sb = new StringBuffer ( ) ; char colSep = pCsvMethod . getColumnSep ( ) . charAt ( 0 ) ; CsvColumn colMeth = null ; Character textDel = null ; Character textDelWas = null ; for ( CsvColumn cc : pCsvMethod . getColumns ( ) ) { if ( cc . getSourceIndex ( ) == 1 ) { colMeth = cc ; if ( colMeth . getTextDelimiter ( ) != null ) { textDel = colMeth . getTextDelimiter ( ) . charAt ( 0 ) ; } break ; } } int colIdx = 1 ; int textDelOccr = 0 ; int chi ; int charCount = 0 ; char cr = ( char ) 0x0D ; char lf = ( char ) 0x0A ; while ( ( chi = pReader . read ( ) ) != - 1 ) { char ch = ( char ) chi ; charCount ++ ; if ( ch == lf || ch == cr || textDel != null && ch == textDel || textDelOccr != 1 && ch == colSep ) { if ( charCount == 1 && ( ch == lf || ch == cr ) ) { continue ; } if ( textDelWas != null && ch != textDelWas && textDelOccr == 2 ) { textDelOccr = 0 ; continue ; } if ( textDel != null && ch == textDel ) { textDelOccr ++ ; } if ( textDelOccr != 1 ) { if ( colMeth != null ) { if ( result == null ) { result = new ArrayList < String > ( ) ; } if ( sb . length ( ) > 0 ) { result . add ( sb . toString ( ) ) ; } else { result . add ( null ) ; } } if ( ch == lf || ch == cr ) { break ; } if ( sb . length ( ) > 0 ) { sb . delete ( 0 , sb . length ( ) ) ; } colIdx ++ ; colMeth = null ; textDelWas = textDel ; textDel = null ; for ( CsvColumn cc : pCsvMethod . getColumns ( ) ) { if ( cc . getSourceIndex ( ) == colIdx ) { colMeth = cc ; if ( colMeth . getTextDelimiter ( ) != null ) { textDel = colMeth . getTextDelimiter ( ) . charAt ( 0 ) ; } break ; } } } } else { sb . append ( ch ) ; } } return result ; }
<p>Reads next line from CSV file as list of Strings,
returns null if no more rows left.
Any delimiter can be only single char.</p>
@param pReqVars additional param
@param pReader Reader
@param pCsvMethod Csv Method
@return List<String> list of columns values or null if no more rows left
@throws Exception an Exception