Since it shares the same interface with the CSVParser there are methods here that will do nothing. For example, the RFC4180 specification does not have a concept of an escape character, so the getEscape method will return char 0. The methods that are not supported are noted in the Javadocs.
Another departure from the CSVParser is that there are only two constructors and only one is available publicly. The intent is that if you want to create anything other than a default RFC4180Parser you should use the CSVParserBuilder. This way the code will not become cluttered with constructors as the CSVParser did.
You can view the RFC4180 specification at the Internet Engineering Task Force (IETF) website.
Examples:
ICSVParser parser = new RFC4180Parser();
or
CSVParserBuilder builder = new CSVParserBuilder()
ICSVParser parser = builder.withParserType(ParserType.RFC4180Parser).build()
| Access | Constructor and Description |
|---|---|
| public | |
| protected | RFC4180Parser(char
The character to use for quoted elements quoteChar, char The delimiter to use for separating entries separator, CSVReaderNullFieldIndicator Indicate what should be considered null nullFieldIndicator)Constructor used by the CSVParserBuilder. |
| Modifier and Type | Method and Description |
|---|---|
| protected String | convertToCsvValue(String value, boolean applyQuotesToAll)
Implements abstract com. Used when reverse parsing an array of strings to a single string. |
| private int | |
| private String[] | |
| private String | |
| private boolean | |
| private boolean | |
| private boolean | |
| private boolean | |
| protected String[] | Returns: The list of elements, or null if nextLine is nullThe string to parse nextLine, boolean Does it take multiple lines to form a single record? multi)Implements abstract com. Parses an incoming String and returns an array of elements. |
| public void | setErrorLocale(Locale errorLocale)
Implements com. Sets the locale for all error messages. |
| private String[] | |
| private boolean | |
| private String[] |
| RFC4180Parser | back to summary |
|---|---|
| public RFC4180Parser() Default constructor for the RFC4180Parser. Uses values from the ICSVParser. | |
| RFC4180Parser | back to summary |
|---|---|
| protected RFC4180Parser(char quoteChar, char separator, CSVReaderNullFieldIndicator nullFieldIndicator) Constructor used by the CSVParserBuilder.
| |
| convertToCsvValue | back to summary |
|---|---|
| protected String convertToCsvValue(String value, boolean applyQuotesToAll) Implements abstract com. Doc from com. Used when reverse parsing an array of strings to a single string. Handles the application of quotes around the string and handling any quotes within the string.
| |
| findEndOfFieldFromPosition | back to summary |
|---|---|
| private int findEndOfFieldFromPosition(String nextLine, int currentPosition) | |
| handleEmptySeparators | back to summary |
|---|---|
| private String[] handleEmptySeparators(String[] strings) | |
| handleQuotes | back to summary |
|---|---|
| private String handleQuotes(String element) | |
| hasOddQuotes | back to summary |
|---|---|
| private boolean hasOddQuotes(String lastElement) | |
| hasOnlyOneQuote | back to summary |
|---|---|
| private boolean hasOnlyOneQuote(String lastElement) | |
| haveNotFoundLastQuote | back to summary |
|---|---|
| private boolean haveNotFoundLastQuote(String nextLine, int nextQuote) | |
| lastElementStartedWithQuoteButDidNotEndInOne | back to summary |
|---|---|
| private boolean lastElementStartedWithQuoteButDidNotEndInOne(List<String> elements) | |
| parseLine | back to summary |
|---|---|
| protected String[] parseLine(String nextLine, boolean multi) Implements abstract com. Parses an incoming String and returns an array of elements. | |
| setErrorLocale | back to summary |
|---|---|
| public void setErrorLocale(Locale errorLocale) Implements com. Doc from com. Sets the locale for all error messages.
| |
| splitWhileNotInQuotes | back to summary |
|---|---|
| private String[] splitWhileNotInQuotes(String nextLine, boolean multi) | |
| startsButDoesNotEndWithQuote | back to summary |
|---|---|
| private boolean startsButDoesNotEndWithQuote(String lastElement) | |
| tokenizeStringIntoArray | back to summary |
|---|---|
| private String[] tokenizeStringIntoArray(String nextLine) | |