Class CSVParser
java.lang.Object
com.inductiveautomation.ignition.common.util.csv.CSVParser
A very simple CSV parser released under a commercial-friendly license.
 This just implements splitting a single line into fields.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final charThe default escape character to use if none is supplied to the constructor.static final booleanThe default leading whitespace behavior to use if none is supplied to the constructorstatic final charThe default quote character to use if none is supplied to the constructor.static final charThe default separator to use if none is supplied to the constructor.static final booleanThe default strict quote behavior to use if none is supplied to the constructorstatic final int
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs 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 SummaryModifier and TypeMethodDescriptionprotected booleanprecondition: sb.length() > 0protected booleanisNextCharacterEscapable(String nextLine, boolean inQuotes, int i) precondition: the current character is an escapebooleanString[]String[]parseLineMulti(String nextLine) 
- 
Field Details- 
DEFAULT_SEPARATORpublic static final char DEFAULT_SEPARATORThe default separator to use if none is supplied to the constructor.- See Also:
 
- 
INITIAL_READ_SIZEpublic static final int INITIAL_READ_SIZE- See Also:
 
- 
DEFAULT_QUOTE_CHARACTERpublic static final char DEFAULT_QUOTE_CHARACTERThe default quote character to use if none is supplied to the constructor.- See Also:
 
- 
DEFAULT_ESCAPE_CHARACTERpublic static final char DEFAULT_ESCAPE_CHARACTERThe default escape character to use if none is supplied to the constructor.- See Also:
 
- 
DEFAULT_STRICT_QUOTESpublic static final boolean DEFAULT_STRICT_QUOTESThe default strict quote behavior to use if none is supplied to the constructor- See Also:
 
- 
DEFAULT_IGNORE_LEADING_WHITESPACEpublic static final boolean DEFAULT_IGNORE_LEADING_WHITESPACEThe default leading whitespace behavior to use if none is supplied to the constructor- See Also:
 
 
- 
- 
Constructor Details- 
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 Details- 
isPendingpublic boolean isPending()- Returns:
- true if something was left over from last call(s)
 
- 
parseLineMulti- Throws:
- IOException
 
- 
parseLine- Throws:
- IOException
 
- 
isNextCharacterEscapableprecondition: 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
 
- 
isAllWhiteSpaceprecondition: sb.length() > 0- Parameters:
- sb- A sequence of characters to examine
- Returns:
- true if every character in the sequence is whitespace
 
 
-