private void parseLine ( State state , String line ) { // XXX The regex does not work if the first token is blank, and I // don't understand why. Workaround: if it's blank, add a space, // and remember I added a space. boolean firstEmpty = false ; if ( line . startsWith ( state . currentSeparator ) ) { line = " " + line ; firstEmpty = true ; } // Match using the parser state . mLineTokens . reset ( line ) ; int nColumn = 0 ; while ( state . mLineTokens . find ( ) ) { // Does this line have more columns than expected? if ( nColumn == state . nColumns ) { state . columnMismatch = true ; return ; } String token ; if ( state . mLineTokens . start ( 2 ) >= 0 ) { // The token was unquoted. Check if it could be a number. token = state . mLineTokens . group ( 2 ) ; if ( firstEmpty ) { token = "" ; firstEmpty = false ; } if ( ! isTokenNumberParsable ( state , token ) ) { state . columnNumberParsable . set ( nColumn , false ) ; } } else { // If quoted, always use string token = state . mQuote . reset ( state . mLineTokens . group ( 1 ) ) . replaceAll ( "\"" ) ; state . columnNumberParsable . set ( nColumn , false ) ; } state . columnTokens . get ( nColumn ) . add ( token ) ; nColumn ++ ; } // Does this line have fewer columns than expected? if ( nColumn != state . nColumns ) { state . columnMismatch = true ; } }
Parses a line saving the tokens and determines the type match .