Skip to content

Commit 3ea8118

Browse files
committed
Move Token into separate file for more flexibility
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1303505 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0519364 commit 3ea8118

3 files changed

Lines changed: 3 additions & 46 deletions

File tree

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

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,17 @@
1919

2020
import java.io.IOException;
2121

22-
import static org.apache.commons.csv.CSVLexer.Token.Type.*;
22+
import static org.apache.commons.csv.Token.Type.*;
2323

2424
class CSVLexer {
2525

26-
/** length of the initial token (content-)buffer */
27-
private static final int INITIAL_TOKEN_LENGTH = 50;
28-
2926
private final StringBuilder wsBuf = new StringBuilder();
3027

3128
private final CSVFormat format;
3229

3330
/** The input stream */
3431
private final ExtendedBufferedReader in;
3532

36-
/**
37-
* Token is an internal token representation.
38-
* <p/>
39-
* It is used as contract between the lexer and the parser.
40-
*/
41-
static class Token {
42-
43-
enum Type {
44-
/** Token has no valid content, i.e. is in its initialized state. */
45-
INVALID,
46-
47-
/** Token with content, at beginning or in the middle of a line. */
48-
TOKEN,
49-
50-
/** Token (which can have content) when end of file is reached. */
51-
EOF,
52-
53-
/** Token with content when end of a line is reached. */
54-
EORECORD
55-
}
56-
57-
/** Token type */
58-
Type type = INVALID;
59-
60-
/** The content buffer. */
61-
StringBuilder content = new StringBuilder(INITIAL_TOKEN_LENGTH);
62-
63-
/** Token ready flag: indicates a valid token with content (ready for the parser). */
64-
boolean isReady;
65-
66-
Token reset() {
67-
content.setLength(0);
68-
type = INVALID;
69-
isReady = false;
70-
return this;
71-
}
72-
}
73-
7433
CSVLexer(CSVFormat format, ExtendedBufferedReader in) {
7534
this.format = format;
7635
this.in = in;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@
2727
import java.util.Map;
2828
import java.util.NoSuchElementException;
2929

30-
import org.apache.commons.csv.CSVLexer.Token;
3130

32-
import static org.apache.commons.csv.CSVLexer.Token.Type.*;
31+
import static org.apache.commons.csv.Token.Type.*;
3332

3433
/**
3534
* Parses CSV files according to the specified configuration.

src/test/java/org/apache/commons/csv/CSVLexerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
import java.io.IOException;
2121
import java.io.StringReader;
2222

23-
import org.apache.commons.csv.CSVLexer.Token;
2423
import org.junit.Test;
2524

26-
import static org.apache.commons.csv.CSVLexer.Token.Type.*;
25+
import static org.apache.commons.csv.Token.Type.*;
2726
import static org.junit.Assert.*;
2827

2928
public class CSVLexerTest {

0 commit comments

Comments
 (0)