Rename pname from 'tkn' to 'token'.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1383583 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
93fc1f9363
commit
8608520aa1
|
@ -33,14 +33,14 @@ class CSVLexer extends Lexer {
|
||||||
* <p/>
|
* <p/>
|
||||||
* A token corresponds to a term, a record change or an end-of-file indicator.
|
* A token corresponds to a term, a record change or an end-of-file indicator.
|
||||||
*
|
*
|
||||||
* @param tkn
|
* @param token
|
||||||
* an existing Token object to reuse. The caller is responsible to initialize the Token.
|
* an existing Token object to reuse. The caller is responsible to initialize the Token.
|
||||||
* @return the next token found
|
* @return the next token found
|
||||||
* @throws java.io.IOException
|
* @throws java.io.IOException
|
||||||
* on stream access error
|
* on stream access error
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
Token nextToken(Token tkn) throws IOException {
|
Token nextToken(Token token) throws IOException {
|
||||||
|
|
||||||
// get the last read char (required for empty line detection)
|
// get the last read char (required for empty line detection)
|
||||||
int lastChar = in.readAgain();
|
int lastChar = in.readAgain();
|
||||||
|
@ -62,29 +62,29 @@ class CSVLexer extends Lexer {
|
||||||
eol = isEndOfLine(c);
|
eol = isEndOfLine(c);
|
||||||
// reached end of file without any content (empty line at the end)
|
// reached end of file without any content (empty line at the end)
|
||||||
if (isEndOfFile(c)) {
|
if (isEndOfFile(c)) {
|
||||||
tkn.type = EOF;
|
token.type = EOF;
|
||||||
// don't set tkn.isReady here because no content
|
// don't set tkn.isReady here because no content
|
||||||
return tkn;
|
return token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// did we reach eof during the last iteration already ? EOF
|
// did we reach eof during the last iteration already ? EOF
|
||||||
if (isEndOfFile(lastChar) || (!isDelimiter(lastChar) && isEndOfFile(c))) {
|
if (isEndOfFile(lastChar) || (!isDelimiter(lastChar) && isEndOfFile(c))) {
|
||||||
tkn.type = EOF;
|
token.type = EOF;
|
||||||
// don't set tkn.isReady here because no content
|
// don't set tkn.isReady here because no content
|
||||||
return tkn;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isStartOfLine(lastChar) && isCommentStart(c)) {
|
if (isStartOfLine(lastChar) && isCommentStart(c)) {
|
||||||
String comment = in.readLine().trim();
|
String comment = in.readLine().trim();
|
||||||
tkn.content.append(comment);
|
token.content.append(comment);
|
||||||
tkn.type = COMMENT;
|
token.type = COMMENT;
|
||||||
return tkn;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
// important: make sure a new char gets consumed in each iteration
|
// important: make sure a new char gets consumed in each iteration
|
||||||
while (tkn.type == INVALID) {
|
while (token.type == INVALID) {
|
||||||
// ignore whitespaces at beginning of a token
|
// ignore whitespaces at beginning of a token
|
||||||
if (surroundingSpacesIgnored) {
|
if (surroundingSpacesIgnored) {
|
||||||
while (isWhitespace(c) && !eol) {
|
while (isWhitespace(c) && !eol) {
|
||||||
|
@ -96,26 +96,26 @@ class CSVLexer extends Lexer {
|
||||||
// ok, start of token reached: encapsulated, or token
|
// ok, start of token reached: encapsulated, or token
|
||||||
if (isDelimiter(c)) {
|
if (isDelimiter(c)) {
|
||||||
// empty token return TOKEN("")
|
// empty token return TOKEN("")
|
||||||
tkn.type = TOKEN;
|
token.type = TOKEN;
|
||||||
} else if (eol) {
|
} else if (eol) {
|
||||||
// empty token return EORECORD("")
|
// empty token return EORECORD("")
|
||||||
// noop: tkn.content.append("");
|
// noop: tkn.content.append("");
|
||||||
tkn.type = EORECORD;
|
token.type = EORECORD;
|
||||||
} else if (isEncapsulator(c)) {
|
} else if (isEncapsulator(c)) {
|
||||||
// consume encapsulated token
|
// consume encapsulated token
|
||||||
encapsulatedTokenLexer(tkn);
|
encapsulatedTokenLexer(token);
|
||||||
} else if (isEndOfFile(c)) {
|
} else if (isEndOfFile(c)) {
|
||||||
// end of file return EOF()
|
// end of file return EOF()
|
||||||
// noop: tkn.content.append("");
|
// noop: tkn.content.append("");
|
||||||
tkn.type = EOF;
|
token.type = EOF;
|
||||||
tkn.isReady = true; // there is data at EOF
|
token.isReady = true; // there is data at EOF
|
||||||
} else {
|
} else {
|
||||||
// next token must be a simple token
|
// next token must be a simple token
|
||||||
// add removed blanks when not ignoring whitespace chars...
|
// add removed blanks when not ignoring whitespace chars...
|
||||||
simpleTokenLexer(tkn, c);
|
simpleTokenLexer(token, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tkn;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue