Package org.supercsv.io
Class AbstractTokenizer
- java.lang.Object
-
- org.supercsv.io.AbstractTokenizer
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ITokenizer
- Direct Known Subclasses:
Tokenizer
public abstract class AbstractTokenizer extends java.lang.Object implements ITokenizer
Defines the standard behaviour of a Tokenizer. Extend this class if you want the line-reading functionality of the defaultTokenizer, but want to define your own implementation ofITokenizer.readColumns(List).- Since:
- 2.0.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.LineNumberReaderlnrprivate CsvPreferencepreferences
-
Constructor Summary
Constructors Constructor Description AbstractTokenizer(java.io.Reader reader, CsvPreference preferences)Constructs a new AbstractTokenizer, which reads the CSV file, line by line.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlying reader.intgetLineNumber()Gets the line number currently being tokenized (the first line is line 1).protected CsvPreferencegetPreferences()Gets the CSV preferences.protected java.lang.StringreadLine()Reads a line of text.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.supercsv.io.ITokenizer
getUntokenizedRow, readColumns
-
-
-
-
Field Detail
-
preferences
private final CsvPreference preferences
-
lnr
private final java.io.LineNumberReader lnr
-
-
Constructor Detail
-
AbstractTokenizer
public AbstractTokenizer(java.io.Reader reader, CsvPreference preferences)Constructs a new AbstractTokenizer, which reads the CSV file, line by line.- Parameters:
reader- the readerpreferences- the CSV preferences- Throws:
java.lang.NullPointerException- if reader or preferences is null
-
-
Method Detail
-
close
public void close() throws java.io.IOExceptionCloses the underlying reader.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getLineNumber
public int getLineNumber()
Gets the line number currently being tokenized (the first line is line 1). This number increments at every line terminator as the data is read, i.e. it will be- 0, if
ITokenizer.readColumns(List)hasn't been called yet - 1, when the first line is being read/tokenized
- 2, when the second line is being read/tokenized
- Specified by:
getLineNumberin interfaceITokenizer- Returns:
- the line number currently being tokenized
- 0, if
-
readLine
protected java.lang.String readLine() throws java.io.IOExceptionReads a line of text. Whenever a line terminator is read the current line number is incremented.- Returns:
- A String containing the contents of the line, not including any line termination characters, or null if the end of the stream has been reached
- Throws:
java.io.IOException- If an I/O error occurs
-
getPreferences
protected CsvPreference getPreferences()
Gets the CSV preferences.- Returns:
- the preferences
-
-