CSV-71 - Add convenience Methods to CSVLexer
Added methods to Lexer parent class (updated CSVLexer to follow) git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1303882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fdfe50842f
commit
1ae3639d2c
|
@ -25,6 +25,16 @@ import java.io.IOException;
|
|||
*/
|
||||
abstract class Lexer {
|
||||
|
||||
private final boolean isEncapsulating;
|
||||
private final boolean isEscaping;
|
||||
private final boolean isCommentEnabled;
|
||||
|
||||
private final char delimiter;
|
||||
private final char escape;
|
||||
private final char encapsulator;
|
||||
private final char commmentStart;
|
||||
|
||||
|
||||
final CSVFormat format;
|
||||
|
||||
/** The input stream */
|
||||
|
@ -33,6 +43,13 @@ abstract class Lexer {
|
|||
Lexer(CSVFormat format, ExtendedBufferedReader in) {
|
||||
this.format = format;
|
||||
this.in = in;
|
||||
this.isEncapsulating = format.isEncapsulating();
|
||||
this.isEscaping = format.isEscaping();
|
||||
this.isCommentEnabled = format.isCommentingEnabled();
|
||||
this.delimiter = format.getDelimiter();
|
||||
this.escape = format.getEscape();
|
||||
this.encapsulator = format.getEncapsulator();
|
||||
this.commmentStart = format.getCommentStart();
|
||||
}
|
||||
|
||||
int getLineNumber() {
|
||||
|
@ -98,4 +115,20 @@ abstract class Lexer {
|
|||
}
|
||||
|
||||
abstract Token nextToken(Token reusableToken) throws IOException;
|
||||
|
||||
boolean isDelimiter(int c) {
|
||||
return c == delimiter;
|
||||
}
|
||||
|
||||
boolean isEscape(int c) {
|
||||
return isEscaping && c == escape;
|
||||
}
|
||||
|
||||
boolean isEncapsulator(int c) {
|
||||
return isEncapsulating && c == encapsulator;
|
||||
}
|
||||
|
||||
boolean isCommentStart(int c) {
|
||||
return isCommentEnabled && c == commmentStart;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue