Class CSVParser
- java.lang.Object
- 
- com.inductiveautomation.ignition.common.util.csv.CSVParser
 
- 
 public class CSVParser extends java.lang.ObjectA very simple CSV parser released under a commercial-friendly license. This just implements splitting a single line into fields.
- 
- 
Field SummaryFields Modifier and Type Field Description static charDEFAULT_ESCAPE_CHARACTERThe default escape character to use if none is supplied to the constructor.static booleanDEFAULT_IGNORE_LEADING_WHITESPACEThe default leading whitespace behavior to use if none is supplied to the constructorstatic charDEFAULT_QUOTE_CHARACTERThe default quote character to use if none is supplied to the constructor.static charDEFAULT_SEPARATORThe default separator to use if none is supplied to the constructor.static booleanDEFAULT_STRICT_QUOTESThe default strict quote behavior to use if none is supplied to the constructorstatic intINITIAL_READ_SIZE
 - 
Constructor SummaryConstructors Constructor 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 CSVReader with supplied separator and quote char.CSVParser(char separator, char quotechar, char escape, boolean strictQuotes)Constructs CSVReader with supplied separator and quote char.CSVParser(char separator, char quotechar, char escape, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)Constructs CSVReader with supplied separator and quote char.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanisAllWhiteSpace(java.lang.CharSequence sb)precondition: sb.length() > 0protected booleanisNextCharacterEscapable(java.lang.String nextLine, boolean inQuotes, int i)precondition: the current character is an escapebooleanisPending()java.lang.String[]parseLine(java.lang.String nextLine)java.lang.String[]parseLineMulti(java.lang.String nextLine)
 
- 
- 
- 
Field Detail- 
DEFAULT_SEPARATORpublic static final char DEFAULT_SEPARATOR The default separator to use if none is supplied to the constructor.- See Also:
- Constant Field Values
 
 - 
INITIAL_READ_SIZEpublic static final int INITIAL_READ_SIZE - See Also:
- Constant Field Values
 
 - 
DEFAULT_QUOTE_CHARACTERpublic static final char DEFAULT_QUOTE_CHARACTER The default quote character to use if none is supplied to the constructor.- See Also:
- Constant Field Values
 
 - 
DEFAULT_ESCAPE_CHARACTERpublic static final char DEFAULT_ESCAPE_CHARACTER The default escape character to use if none is supplied to the constructor.- See Also:
- Constant Field Values
 
 - 
DEFAULT_STRICT_QUOTESpublic static final boolean DEFAULT_STRICT_QUOTES The default strict quote behavior to use if none is supplied to the constructor- See Also:
- Constant Field Values
 
 - 
DEFAULT_IGNORE_LEADING_WHITESPACEpublic static final boolean DEFAULT_IGNORE_LEADING_WHITESPACE The default leading whitespace behavior to use if none is supplied to the constructor- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
CSVParserpublic CSVParser() Constructs CSVParser using a comma for the separator.
 - 
CSVParserpublic CSVParser(char separator) Constructs CSVParser with supplied separator.- Parameters:
- separator- the delimiter to use for separating entries.
 
 - 
CSVParserpublic CSVParser(char separator, char quotechar)Constructs CSVParser with supplied separator and quote char.- Parameters:
- separator- the delimiter to use for separating entries
- quotechar- the character to use for quoted elements
 
 - 
CSVParserpublic CSVParser(char separator, char quotechar, char escape)Constructs CSVReader with supplied separator and quote char.- Parameters:
- separator- the delimiter to use for separating entries
- quotechar- the character to use for quoted elements
- escape- the character to use for escaping a separator or quote
 
 - 
CSVParserpublic CSVParser(char separator, char quotechar, char escape, boolean strictQuotes)Constructs CSVReader with supplied separator and quote char. Allows setting the "strict quotes" flag- Parameters:
- separator- the delimiter to use for separating entries
- quotechar- the character to use for quoted elements
- escape- the character to use for escaping a separator or quote
- strictQuotes- if true, characters outside the quotes are ignored
 
 - 
CSVParserpublic CSVParser(char separator, char quotechar, char escape, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)Constructs CSVReader with supplied separator and quote char. Allows setting the "strict quotes" and "ignore leading whitespace" flags- Parameters:
- separator- the delimiter to use for separating entries
- quotechar- the character to use for quoted elements
- escape- the character to use for escaping a separator or quote
- strictQuotes- if true, characters outside the quotes are ignored
- ignoreLeadingWhiteSpace- if true, white space in front of a quote in a field is ignored
 
 
- 
 - 
Method Detail- 
isPendingpublic boolean isPending() - Returns:
- true if something was left over from last call(s)
 
 - 
parseLineMultipublic java.lang.String[] parseLineMulti(java.lang.String nextLine) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
parseLinepublic java.lang.String[] parseLine(java.lang.String nextLine) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
isNextCharacterEscapableprotected boolean isNextCharacterEscapable(java.lang.String nextLine, boolean inQuotes, int i)precondition: the current character is an escape- Parameters:
- nextLine- the current line
- inQuotes- true if the current context is quoted
- i- current index in line
- Returns:
- true if the following character is a quote
 
 - 
isAllWhiteSpaceprotected boolean isAllWhiteSpace(java.lang.CharSequence sb) precondition: sb.length() > 0- Parameters:
- sb- A sequence of characters to examine
- Returns:
- true if every character in the sequence is whitespace
 
 
- 
 
-