public class DelimitedLineTokenizer extends AbstractLineTokenizer
LineTokenizer
implementation that splits the input String on a
configurable delimiter. This implementation also supports the use of an
escape character to escape delimiters and line endings.Modifier and Type | Field and Description |
---|---|
static char |
DEFAULT_QUOTE_CHARACTER
Convenient constant for the common case of a " character used to escape
delimiters or line endings.
|
static String |
DELIMITER_COMMA
Convenient constant for the common case of a comma delimiter.
|
static String |
DELIMITER_TAB
Convenient constant for the common case of a tab delimiter.
|
names
Constructor and Description |
---|
DelimitedLineTokenizer()
Create a new instance of the
DelimitedLineTokenizer class for the
common case where the delimiter is a comma . |
DelimitedLineTokenizer(String delimiter)
Create a new instance of the
DelimitedLineTokenizer class. |
Modifier and Type | Method and Description |
---|---|
protected List<String> |
doTokenize(String line)
Yields the tokens resulting from the splitting of the supplied
line . |
protected boolean |
isQuoteCharacter(char c)
Is the supplied character a quote character?
|
void |
setDelimiter(String delimiter)
Setter for the delimiter character.
|
void |
setIncludedFields(int[] includedFields)
The fields to include in the output by position (starting at 0).
|
void |
setQuoteCharacter(char quoteCharacter)
Public setter for the quoteCharacter.
|
hasNames, isStrict, setFieldSetFactory, setNames, setStrict, tokenize
public static final String DELIMITER_TAB
public static final String DELIMITER_COMMA
public static final char DEFAULT_QUOTE_CHARACTER
public DelimitedLineTokenizer()
DelimitedLineTokenizer
class for the
common case where the delimiter is a comma
.public DelimitedLineTokenizer(String delimiter)
DelimitedLineTokenizer
class.delimiter
- the desired delimiterpublic void setDelimiter(String delimiter)
delimiter
- public void setIncludedFields(int[] includedFields)
includedFields
- the included fields to setpublic void setQuoteCharacter(char quoteCharacter)
quoteCharacter
- the quoteCharacter to setDEFAULT_QUOTE_CHARACTER
protected List<String> doTokenize(String line)
line
.doTokenize
in class AbstractLineTokenizer
line
- the line to be tokenizedprotected boolean isQuoteCharacter(char c)
c
- the character to be checkedtrue
if the supplied character is an quote charactersetQuoteCharacter(char)
Copyright © 2014 Pivotal. All rights reserved.