public class CSVParser extends Object
| Constructor and Description |
|---|
CSVParser()
Constructs CSVParser using a comma for the separator.
|
| Modifier and Type | Method and Description |
|---|---|
char |
getEscapeChar() |
char |
getQuoteChar() |
char |
getSeparatorChar() |
protected boolean |
isAllWhiteSpace(CharSequence sb)
Checks if every element is the character sequence is whitespace.
|
boolean |
isIgnoreLeadingWhiteSpace() |
boolean |
isIgnoreQuotations() |
protected boolean |
isNextCharacterEscapable(String sNextLine,
boolean bInQuotes,
int nIndex)
Checks to see if the character after the current index in a String is an
escapable character.
|
boolean |
isPending() |
boolean |
isStrictQuotes() |
List<String> |
parseLine(String sNextLine)
Parses an incoming String and returns an array of elements.
|
List<String> |
parseLineMulti(String sNextLine)
Parses an incoming String and returns an array of elements.
|
CSVParser |
setEscapeChar(char cEscapeChar)
Sets the character to use for escaping a separator or quote.
|
CSVParser |
setIgnoreLeadingWhiteSpace(boolean bIgnoreLeadingWhiteSpace)
Sets the ignore leading whitespace setting - if true, white space in front
of a quote in a field is ignored.
|
CSVParser |
setIgnoreQuotations(boolean bIgnoreQuotations)
Sets the ignore quotations mode - if
true, quotations are
ignored. |
CSVParser |
setQuoteChar(char cQuoteChar)
Sets the character to use for quoted elements.
|
CSVParser |
setSeparatorChar(char cSeparator)
Sets the delimiter to use for separating entries.
|
CSVParser |
setStrictQuotes(boolean bStrictQuotes)
Sets the strict quotes setting - if true, characters outside the quotes are
ignored.
|
public CSVParser()
public char getSeparatorChar()
@Nonnull public CSVParser setSeparatorChar(char cSeparator)
cSeparator - the delimiter to use for separating entriespublic char getQuoteChar()
@Nonnull public CSVParser setQuoteChar(char cQuoteChar)
cQuoteChar - the character to use for quoted element.public char getEscapeChar()
@Nonnull public CSVParser setEscapeChar(char cEscapeChar)
cEscapeChar - the character to use for escaping a separator or quote.public boolean isStrictQuotes()
@Nonnull public CSVParser setStrictQuotes(boolean bStrictQuotes)
bStrictQuotes - if true, characters outside the quotes are ignoredpublic boolean isIgnoreLeadingWhiteSpace()
@Nonnull public CSVParser setIgnoreLeadingWhiteSpace(boolean bIgnoreLeadingWhiteSpace)
bIgnoreLeadingWhiteSpace - if true, white space in front of a quote in a field is
ignoredpublic boolean isIgnoreQuotations()
@Nonnull public CSVParser setIgnoreQuotations(boolean bIgnoreQuotations)
true, quotations are
ignored.bIgnoreQuotations - if true, quotations are ignoredpublic boolean isPending()
@Nullable public List<String> parseLineMulti(@Nullable String sNextLine) throws IOException
sNextLine - current line to be processednull if nextLine is
nullIOException - if bad things happen during the read@Nullable public List<String> parseLine(@Nullable String sNextLine) throws IOException
sNextLine - Line to be parsed.null if nextLine is
nullIOException - if bad things happen during the readprotected boolean isNextCharacterEscapable(@Nonnull String sNextLine, boolean bInQuotes, int nIndex)
sNextLine - the current linebInQuotes - true if the current context is quotednIndex - current index in linetrue if the following character is a quoteprotected boolean isAllWhiteSpace(@Nonnull CharSequence sb)
sb - A sequence of characters to examinetrue if every character in the sequence is whitespaceCopyright © 2014–2015 Philip Helger. All rights reserved.