public abstract class CsvParser
extends java.lang.Object
parse(InputStream)
method and the setters are synchronized so that
the object cannot be modified when parsing.Constructor and Description |
---|
CsvParser() |
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
getNoHeader() |
char |
getQuote() |
char |
getSeparator() |
java.lang.Boolean |
getStrictLineAsLongAsHeader() |
void |
parse(java.io.InputStream in)
Parses the CSV file (stream is closed at the end)
|
void |
parse(java.io.InputStream in,
java.lang.String encoding)
Parses the CSV file (stream is closed at the end)
|
protected java.lang.Boolean |
parseLine(java.lang.String str,
java.util.List<java.lang.String> tokens,
java.lang.StringBuffer currStr,
java.lang.Boolean wasInquote)
Parses a line character by character for performance purpose
|
protected java.lang.String |
preProcessLine(java.lang.String line)
Called before each (logical) line is processed, giving a change to modify
it (typically for cleaning dirty files).
|
protected abstract void |
processLine(java.lang.Integer lineNumber,
java.util.List<java.lang.String> header,
java.util.List<java.lang.String> tokens)
Actually process a parsed line.
|
void |
setNoHeader(java.lang.Boolean noHeader) |
void |
setQuote(char quote) |
void |
setSeparator(char separator) |
void |
setStrictLineAsLongAsHeader(java.lang.Boolean strictLineAsLongAsHeader) |
protected abstract void processLine(java.lang.Integer lineNumber, java.util.List<java.lang.String> header, java.util.List<java.lang.String> tokens)
setStrictLineAsLongAsHeader(Boolean)
is true (default) the
header and the tokens are guaranteed to have the same size.lineNumber
- the current line number, starts at 1 (the header, if header
processing is enabled, the first line otherwise)header
- the read-only header or null if setNoHeader(Boolean)
is true (default is false)tokens
- the parsed tokenspublic void parse(java.io.InputStream in)
public void parse(java.io.InputStream in, java.lang.String encoding)
protected java.lang.String preProcessLine(java.lang.String line)
protected java.lang.Boolean parseLine(java.lang.String str, java.util.List<java.lang.String> tokens, java.lang.StringBuffer currStr, java.lang.Boolean wasInquote)
public char getSeparator()
public void setSeparator(char separator)
public char getQuote()
public void setQuote(char quote)
public java.lang.Boolean getNoHeader()
public void setNoHeader(java.lang.Boolean noHeader)
public java.lang.Boolean getStrictLineAsLongAsHeader()
public void setStrictLineAsLongAsHeader(java.lang.Boolean strictLineAsLongAsHeader)
Copyright © 2007–2020. All rights reserved.