File tree Expand file tree Collapse file tree
main/java/org/apache/commons/csv
test/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ Token nextToken(Token tkn) throws IOException {
9292 if (isCommentStart (c )) { // TODO should only match at start of line
9393 // ignore everything till end of line and continue (incr linecount)
9494 in .readLine ();
95- tkn = nextToken ( tkn . reset ()) ;
95+ tkn . type = COMMENT ;
9696 } else if (isDelimiter (c )) {
9797 // empty token return TOKEN("")
9898 tkn .type = TOKEN ;
Original file line number Diff line number Diff line change @@ -154,6 +154,8 @@ CSVRecord getRecord() throws IOException {
154154 break ;
155155 case INVALID :
156156 throw new IOException ("(line " + getLineNumber () + ") invalid parse sequence" );
157+ case COMMENT : // Ignored currently
158+ break ;
157159 }
158160 } while (reusableToken .type == TOKEN );
159161
Original file line number Diff line number Diff line change @@ -41,7 +41,10 @@ enum Type {
4141 EOF ,
4242
4343 /** Token with content when end of a line is reached. */
44- EORECORD
44+ EORECORD ,
45+
46+ /** Token is a comment line */
47+ COMMENT
4548 }
4649
4750 /** Token type */
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ public void testNextToken2() throws IOException {
7676 assertTokenEquals (TOKEN , "a" , parser .nextToken (new Token ()));
7777 assertTokenEquals (TOKEN , "b x" , parser .nextToken (new Token ()));
7878 assertTokenEquals (EORECORD , "c" , parser .nextToken (new Token ()));
79+ assertTokenEquals (COMMENT , "" , parser .nextToken (new Token ()));
7980 assertTokenEquals (EORECORD , "" , parser .nextToken (new Token ()));
8081 assertTokenEquals (TOKEN , "d" , parser .nextToken (new Token ()));
8182 assertTokenEquals (TOKEN , "e" , parser .nextToken (new Token ()));
You can’t perform that action at this time.
0 commit comments