/** * Closes resources. * * @throws IOException * If an I/O error occurs */ @Override public void close() throws IOException { if (this.lexer != null) { this.lexer.close(); } }
this.recordList.clear(); StringBuilder sb = null; final long startCharPosition = lexer.getCharacterPosition() + this.characterOffset; do { this.reusableToken.reset(); this.lexer.nextToken(this.reusableToken); switch (this.reusableToken.type) { case TOKEN:
final long startLineNumber = getCurrentLineNumber(); int c; while (true) { c = reader.read(); if (isEscape(c)) { final int unescaped = readEscape(); if (unescaped == END_OF_STREAM) { // unexpected char after escape token.content.append((char) c).append((char) reader.getLastChar()); } else if (isQuoteChar(c)) { if (isQuoteChar(reader.lookAhead())) { if (isDelimiter(c)) { token.type = TOKEN; return token; } else if (isEndOfFile(c)) { token.type = EOF; token.isReady = true; // There is data at EOF return token; } else if (readEndOfLine(c)) { token.type = EORECORD; return token; } else if (!isWhitespace(c)) { throw new IOException("(line " + getCurrentLineNumber() + ") invalid char between encapsulated token and delimiter"); } else if (isEndOfFile(c)) {
boolean eol = readEndOfLine(c); while (eol && isStartOfLine(lastChar)) { eol = readEndOfLine(c); if (isEndOfFile(c)) { token.type = EOF; if (isEndOfFile(lastChar) || !isDelimiter(lastChar) && isEndOfFile(c)) { token.type = EOF; if (isStartOfLine(lastChar) && isCommentStart(c)) { final String line = reader.readLine(); if (line == null) { while (isWhitespace(c) && !eol) { c = reader.read(); eol = readEndOfLine(c); if (isDelimiter(c)) { } else if (isQuoteChar(c)) { parseEncapsulatedToken(token); } else if (isEndOfFile(c)) { parseSimpleToken(token, c);
if (readEndOfLine(ch)) { token.type = EORECORD; break; } else if (isEndOfFile(ch)) { token.type = EOF; token.isReady = true; // There is data at EOF break; } else if (isDelimiter(ch)) { token.type = TOKEN; break; } else if (isEscape(ch)) { final int unescaped = readEscape(); if (unescaped == END_OF_STREAM) { // unexpected char after escape token.content.append((char) ch).append((char) reader.getLastChar()); trimTrailingSpaces(token.content);
/** * @return true if the given char is a whitespace character */ boolean isWhitespace(final int ch) { return !isDelimiter(ch) && Character.isWhitespace((char) ch); }
/** * Gets whether this parser is closed. * * @return whether this parser is closed. */ public boolean isClosed() { return this.lexer.isClosed(); }
/** * Returns the current line number in the input stream. * * <p> * <strong>ATTENTION:</strong> If your CSV input has multi-line values, the returned number does not correspond to * the record number. * </p> * * @return current line number */ public long getCurrentLineNumber() { return this.lexer.getCurrentLineNumber(); }
this.lexer = new Lexer(format, new ExtendedBufferedReader(reader)); this.csvRecordIterator = new CSVRecordIterator(); this.headerMap = this.initializeHeader();
default: if (isMetaChar(ch)) { return ch;
boolean eol = readEndOfLine(c); while (eol && isStartOfLine(lastChar)) { eol = readEndOfLine(c); if (isEndOfFile(c)) { token.type = EOF; if (isEndOfFile(lastChar) || !isDelimiter(lastChar) && isEndOfFile(c)) { token.type = EOF; if (isStartOfLine(lastChar) && isCommentStart(c)) { final String line = reader.readLine(); if (line == null) { while (isWhitespace(c) && !eol) { c = reader.read(); eol = readEndOfLine(c); if (isDelimiter(c)) { } else if (isQuoteChar(c)) { parseEncapsulatedToken(token); } else if (isEndOfFile(c)) { parseSimpleToken(token, c);
if (readEndOfLine(ch)) { token.type = EORECORD; break; } else if (isEndOfFile(ch)) { token.type = EOF; token.isReady = true; // There is data at EOF break; } else if (isDelimiter(ch)) { token.type = TOKEN; break; } else if (isEscape(ch)) { final int unescaped = readEscape(); if (unescaped == END_OF_STREAM) { // unexpected char after escape token.content.append((char) ch).append((char) reader.getLastChar()); trimTrailingSpaces(token.content);
/** * @return true if the given char is a whitespace character */ boolean isWhitespace(final int ch) { return !isDelimiter(ch) && Character.isWhitespace((char) ch); }
/** * Gets whether this parser is closed. * * @return whether this parser is closed. */ public boolean isClosed() { return this.lexer.isClosed(); }
/** * Returns the current line number in the input stream. * * <p> * <strong>ATTENTION:</strong> If your CSV input has multi-line values, the returned number does not correspond to * the record number. * </p> * * @return current line number */ public long getCurrentLineNumber() { return this.lexer.getCurrentLineNumber(); }
this.lexer = new Lexer(format, new ExtendedBufferedReader(reader)); this.headerMap = this.initializeHeader(); this.characterOffset = characterOffset;
default: if (isMetaChar(ch)) { return ch;
boolean eol = readEndOfLine(c); while (eol && isStartOfLine(lastChar)) { eol = readEndOfLine(c); if (isEndOfFile(c)) { token.type = EOF; if (isEndOfFile(lastChar) || (!isDelimiter(lastChar) && isEndOfFile(c))) { token.type = EOF; if (isStartOfLine(lastChar) && isCommentStart(c)) { final String line = reader.readLine(); if (line == null) { while (isWhitespace(c) && !eol) { c = reader.read(); eol = readEndOfLine(c); if (isDelimiter(c)) { } else if (isQuoteChar(c)) { parseEncapsulatedToken(token); } else if (isEndOfFile(c)) { parseSimpleToken(token, c);
final long startLineNumber = getCurrentLineNumber(); int c; while (true) { c = reader.read(); if (isEscape(c)) { final int unescaped = readEscape(); if (unescaped == END_OF_STREAM) { // unexpected char after escape token.content.append((char) c).append((char) reader.getLastChar()); } else if (isQuoteChar(c)) { if (isQuoteChar(reader.lookAhead())) { if (isDelimiter(c)) { token.type = TOKEN; return token; } else if (isEndOfFile(c)) { token.type = EOF; token.isReady = true; // There is data at EOF return token; } else if (readEndOfLine(c)) { token.type = EORECORD; return token; } else if (!isWhitespace(c)) { throw new IOException("(line " + getCurrentLineNumber() + ") invalid char between encapsulated token and delimiter"); } else if (isEndOfFile(c)) {
if (readEndOfLine(ch)) { token.type = EORECORD; break; } else if (isEndOfFile(ch)) { token.type = EOF; token.isReady = true; // There is data at EOF break; } else if (isDelimiter(ch)) { token.type = TOKEN; break; } else if (isEscape(ch)) { final int unescaped = readEscape(); if (unescaped == END_OF_STREAM) { // unexpected char after escape token.content.append((char) ch).append((char) reader.getLastChar()); trimTrailingSpaces(token.content);