Skip to content

Commit 83e4a90

Browse files
committed
CSV-71 - Add convenience Methods to CSVLexer
Use convenience methods from Lexer parent class git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1303904 13f79535-47bb-0310-9956-ffa450edef68
1 parent ff41f78 commit 83e4a90

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/main/java/org/apache/commons/csv/CSVLexer.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ Token nextToken(Token tkn) throws IOException {
9191
}
9292

9393
// ok, start of token reached: comment, encapsulated, or token
94-
if (c == format.getCommentStart()) {
94+
if (isCommentStart(c)) {
9595
// ignore everything till end of line and continue (incr linecount)
9696
in.readLine();
9797
tkn = nextToken(tkn.reset());
98-
} else if (c == format.getDelimiter()) {
98+
} else if (isDelimiter(c)) {
9999
// empty token return TOKEN("")
100100
tkn.type = TOKEN;
101101
tkn.isReady = true;
@@ -104,7 +104,7 @@ Token nextToken(Token tkn) throws IOException {
104104
//noop: tkn.content.append("");
105105
tkn.type = EORECORD;
106106
tkn.isReady = true;
107-
} else if (c == format.getEncapsulator()) {
107+
} else if (isEncapsulator(c)) {
108108
// consume encapsulated token
109109
encapsulatedTokenLexer(tkn, c);
110110
} else if (isEndOfFile(c)) {
@@ -153,12 +153,12 @@ private Token simpleTokenLexer(Token tkn, int c) throws IOException {
153153
tkn.type = EOF;
154154
tkn.isReady = true;
155155
break;
156-
} else if (c == format.getDelimiter()) {
156+
} else if (isDelimiter(c)) {
157157
// end of token
158158
tkn.type = TOKEN;
159159
tkn.isReady = true;
160160
break;
161-
} else if (c == format.getEscape()) {
161+
} else if (isEscape(c)) {
162162
tkn.content.append((char) readEscape(c));
163163
} else {
164164
tkn.content.append((char) c);
@@ -195,18 +195,18 @@ private Token encapsulatedTokenLexer(Token tkn, int c) throws IOException {
195195
while (true) {
196196
c = in.read();
197197

198-
if (c == format.getEscape()) {
198+
if (isEscape(c)) {
199199
tkn.content.append((char) readEscape(c));
200-
} else if (c == format.getEncapsulator()) {
201-
if (in.lookAhead() == format.getEncapsulator()) {
200+
} else if (isEncapsulator(c)) {
201+
if (isEncapsulator(in.lookAhead())) {
202202
// double or escaped encapsulator -> add single encapsulator to token
203203
c = in.read();
204204
tkn.content.append((char) c);
205205
} else {
206206
// token finish mark (encapsulator) reached: ignore whitespace till delimiter
207207
while (true) {
208208
c = in.read();
209-
if (c == format.getDelimiter()) {
209+
if (isDelimiter(c)) {
210210
tkn.type = TOKEN;
211211
tkn.isReady = true;
212212
return tkn;

0 commit comments

Comments
 (0)