|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectliquibase.util.csv.opencsv.CSVParser
public class CSVParser
A very simple CSV parser released under a commercial-friendly license. This just implements splitting a single line into fields.
Field Summary | |
---|---|
static char |
DEFAULT_ESCAPE_CHARACTER
The default escape character to use if none is supplied to the constructor. |
static boolean |
DEFAULT_IGNORE_QUOTATIONS
If the quote character is set to null then there is no quote character. |
static CSVReaderNullFieldIndicator |
DEFAULT_NULL_FIELD_INDICATOR
Denotes what field contents will cause the parser to return null: EMPTY_SEPARATORS, EMPTY_QUOTES, BOTH, NEITHER (default) |
static char |
DEFAULT_QUOTE_CHARACTER
The default quote character to use if none is supplied to the constructor. |
static char |
DEFAULT_SEPARATOR
The default separator to use if none is supplied to the constructor. |
static boolean |
DEFAULT_STRICT_QUOTES
The default strict quote behavior to use if none is supplied to the constructor. |
static int |
INITIAL_READ_SIZE
The average size of a line read by openCSV (used for setting the size of StringBuilders). |
static char |
NULL_CHARACTER
This is the "null" character - if a value is set to this then it is ignored. |
static int |
READ_BUFFER_SIZE
In most cases we know the size of the line we want to read. |
Constructor Summary | |
---|---|
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 CSVReader 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. |
Method Summary | |
---|---|
char |
getEscape()
|
char |
getQuotechar()
|
char |
getSeparator()
|
protected boolean |
isAllWhiteSpace(CharSequence sb)
Checks if every element is the character sequence is whitespace. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char DEFAULT_SEPARATOR
public static final int INITIAL_READ_SIZE
public static final int READ_BUFFER_SIZE
public static final char DEFAULT_QUOTE_CHARACTER
public static final char DEFAULT_ESCAPE_CHARACTER
public static final boolean DEFAULT_STRICT_QUOTES
public static final boolean DEFAULT_IGNORE_QUOTATIONS
public static final char NULL_CHARACTER
public static final CSVReaderNullFieldIndicator DEFAULT_NULL_FIELD_INDICATOR
Constructor Detail |
---|
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.Method Detail |
---|
public char getSeparator()
public char getQuotechar()
public char getEscape()
public boolean isStrictQuotes()
public boolean isIgnoreLeadingWhiteSpace()
public boolean isIgnoreQuotations()
public boolean isPending()
public String[] parseLineMulti(String nextLine) throws IOException
nextLine
- current line to be processed
IOException
- if bad things happen during the readpublic String[] parseLine(String nextLine) throws IOException
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 line
protected boolean isAllWhiteSpace(CharSequence sb)
sb
- A sequence of characters to examine
public CSVReaderNullFieldIndicator nullFieldIndicator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |