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 java.lang.String |
DELIMITER_COMMA
Convenient constant for the common case of a comma delimiter.
|
static java.lang.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(java.lang.String delimiter)
Create a new instance of the
DelimitedLineTokenizer class. |
Modifier and Type | Method and Description |
---|---|
protected java.util.List<java.lang.String> |
doTokenize(java.lang.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(java.lang.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 java.lang.String DELIMITER_TAB
public static final java.lang.String DELIMITER_COMMA
public static final char DEFAULT_QUOTE_CHARACTER
public DelimitedLineTokenizer()
DelimitedLineTokenizer
class for the
common case where the delimiter is a comma
.DelimitedLineTokenizer(String)
,
DELIMITER_COMMA
public DelimitedLineTokenizer(java.lang.String delimiter)
DelimitedLineTokenizer
class.delimiter
- the desired delimiterpublic void setDelimiter(java.lang.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 java.util.List<java.lang.String> doTokenize(java.lang.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)