public class CSVParser extends Object implements ICSVParser
DEFAULT_ESCAPE_CHARACTER, DEFAULT_IGNORE_LEADING_WHITESPACE, DEFAULT_IGNORE_QUOTATIONS, DEFAULT_NULL_FIELD_INDICATOR, DEFAULT_QUOTE_CHARACTER, DEFAULT_SEPARATOR, DEFAULT_STRICT_QUOTES, INITIAL_READ_SIZE, NULL_CHARACTER, READ_BUFFER_SIZE
Constructor and Description |
---|
CSVParser()
Constructs CSVParser using a comma for the separator.
|
CSVParser(char separator)
Constructs CSVParser with supplied separator.
|
CSVParser(char separator,
char quotechar)
Constructs CSVParser with supplied separator and quote char.
|
CSVParser(char separator,
char quotechar,
char escape)
Constructs CSVParser with supplied separator and quote char.
|
CSVParser(char separator,
char quotechar,
char escape,
boolean strictQuotes)
Constructs CSVParser with supplied separator and quote char.
|
CSVParser(char separator,
char quotechar,
char escape,
boolean strictQuotes,
boolean ignoreLeadingWhiteSpace)
Constructs CSVParser with supplied separator and quote char.
|
CSVParser(char separator,
char quotechar,
char escape,
boolean strictQuotes,
boolean ignoreLeadingWhiteSpace,
boolean ignoreQuotations)
Constructs CSVParser with supplied separator and quote char.
|
Modifier and Type | Method and Description |
---|---|
char |
getEscape() |
char |
getQuotechar() |
char |
getSeparator() |
boolean |
isIgnoreLeadingWhiteSpace() |
boolean |
isIgnoreQuotations() |
protected boolean |
isNextCharacterEscapable(String nextLine,
boolean inQuotes,
int i)
Checks to see if the character after the current index in a String is an
escapable character.
|
boolean |
isPending() |
boolean |
isStrictQuotes() |
CSVReaderNullFieldIndicator |
nullFieldIndicator() |
String[] |
parseLine(String nextLine)
Parses an incoming String and returns an array of elements.
|
protected String[] |
parseLine(String nextLine,
boolean multi)
Parses an incoming String and returns an array of elements.
|
String[] |
parseLineMulti(String nextLine)
Parses an incoming String and returns an array of elements.
|
public CSVParser()
public CSVParser(char separator)
separator
- The delimiter to use for separating entries.public CSVParser(char separator, char quotechar)
separator
- The delimiter to use for separating entriesquotechar
- The character to use for quoted elementspublic CSVParser(char separator, char quotechar, char escape)
separator
- The delimiter to use for separating entriesquotechar
- The character to use for quoted elementsescape
- The character to use for escaping a separator or quotepublic CSVParser(char separator, char quotechar, char escape, boolean strictQuotes)
separator
- The delimiter to use for separating entriesquotechar
- The character to use for quoted elementsescape
- The character to use for escaping a separator or quotestrictQuotes
- If true, characters outside the quotes are ignoredpublic CSVParser(char separator, char quotechar, char escape, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)
separator
- The delimiter to use for separating entriesquotechar
- The character to use for quoted elementsescape
- The character to use for escaping a separator or quotestrictQuotes
- If true, characters outside the quotes are ignoredignoreLeadingWhiteSpace
- If true, white space in front of a quote in a field is ignoredpublic CSVParser(char separator, char quotechar, char escape, boolean strictQuotes, boolean ignoreLeadingWhiteSpace, boolean ignoreQuotations)
separator
- The delimiter to use for separating entriesquotechar
- The character to use for quoted elementsescape
- The character to use for escaping a separator or quotestrictQuotes
- If true, characters outside the quotes are ignoredignoreLeadingWhiteSpace
- If true, white space in front of a quote in a field is ignoredignoreQuotations
- If true, treat quotations like any other character.public char getSeparator()
getSeparator
in interface ICSVParser
public char getQuotechar()
getQuotechar
in interface ICSVParser
public char getEscape()
public boolean isStrictQuotes()
public boolean isIgnoreLeadingWhiteSpace()
public boolean isIgnoreQuotations()
public boolean isPending()
isPending
in interface ICSVParser
public String[] parseLineMulti(String nextLine) throws IOException
parseLineMulti
in interface ICSVParser
nextLine
- Current line to be processedIOException
- If bad things happen during the readpublic String[] parseLine(String nextLine) throws IOException
parseLine
in interface ICSVParser
nextLine
- Line to be parsed.IOException
- If bad things happen during the readprotected String[] parseLine(String nextLine, boolean multi) throws IOException
nextLine
- The string to parsemulti
- Does it take multiple lines to form a single record.IOException
- If bad things happen during the readprotected boolean isNextCharacterEscapable(String nextLine, boolean inQuotes, int i)
nextLine
- The current lineinQuotes
- True if the current context is quotedi
- Current index in linepublic CSVReaderNullFieldIndicator nullFieldIndicator()
nullFieldIndicator
in interface ICSVParser
Copyright © 2017. All rights reserved.