Package org.apache.calcite.adapter.csv
Class CsvStreamReader
- java.lang.Object
-
- au.com.bytecode.opencsv.CSVReader
-
- org.apache.calcite.adapter.csv.CsvStreamReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
class CsvStreamReader extends au.com.bytecode.opencsv.CSVReader implements java.io.Closeable
Extension toCSVReader
that can read newly appended file content.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CsvStreamReader.CsvContentListener
Watches for content being appended to a CSV file.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Queue<java.lang.String>
contentQueue
static long
DEFAULT_MONITOR_DELAY
The default file monitor delay.static int
DEFAULT_SKIP_LINES
The default line to start reading.protected au.com.bytecode.opencsv.CSVParser
parser
protected int
skipLines
protected org.apache.commons.io.input.Tailer
tailer
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
CsvStreamReader(Source source)
private
CsvStreamReader(Source source, char separator, char quoteChar, char escape, int line, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)
Creates a CsvStreamReader with supplied separator and quote char.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the underlying reader.private java.lang.String
getNextLine()
Reads the next line from the file.java.lang.String[]
readNext()
Reads the next line from the buffer and converts to a string array.
-
-
-
Field Detail
-
parser
protected au.com.bytecode.opencsv.CSVParser parser
-
skipLines
protected int skipLines
-
tailer
protected org.apache.commons.io.input.Tailer tailer
-
contentQueue
protected java.util.Queue<java.lang.String> contentQueue
-
DEFAULT_SKIP_LINES
public static final int DEFAULT_SKIP_LINES
The default line to start reading.- See Also:
- Constant Field Values
-
DEFAULT_MONITOR_DELAY
public static final long DEFAULT_MONITOR_DELAY
The default file monitor delay.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CsvStreamReader
CsvStreamReader(Source source)
-
CsvStreamReader
private CsvStreamReader(Source source, char separator, char quoteChar, char escape, int line, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)
Creates a CsvStreamReader with supplied separator and quote char.- Parameters:
source
- The file to an underlying CSV sourceseparator
- The delimiter to use for separating entriesquoteChar
- The character to use for quoted elementsescape
- The character to use for escaping a separator or quoteline
- The line number to skip for start readingstrictQuotes
- Sets if characters outside the quotes are ignoredignoreLeadingWhiteSpace
- If true, parser should ignore white space before a quote in a field
-
-
Method Detail
-
readNext
public java.lang.String[] readNext() throws java.io.IOException
Reads the next line from the buffer and converts to a string array.- Overrides:
readNext
in classau.com.bytecode.opencsv.CSVReader
- Returns:
- a string array with each comma-separated element as a separate entry.
- Throws:
java.io.IOException
- if bad things happen during the read
-
getNextLine
private java.lang.String getNextLine() throws java.io.IOException
Reads the next line from the file.- Returns:
- the next line from the file without trailing newline
- Throws:
java.io.IOException
- if bad things happen during the read
-
close
public void close() throws java.io.IOException
Closes the underlying reader.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classau.com.bytecode.opencsv.CSVReader
- Throws:
java.io.IOException
- if the close fails
-
-