Package org.springframework.batch.item.file.transform

# Class DelimitedLineTokenizer

java.lang.Object
org.springframework.batch.item.file.transform.AbstractLineTokenizer
org.springframework.batch.item.file.transform.DelimitedLineTokenizer

All Implemented Interfaces:
  `LineTokenizer`, `org.springframework.beans.factory.InitializingBean`

public class DelimitedLineTokenizer extends AbstractLineTokenizer implements org.springframework.beans.factory.InitializingBean
A `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.

Author:
  Rob Harrop, Dave Syer, Michael Minella, Olivier Bourgain

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final char`
  `DEFAULT_QUOTE_CHARACTER`
  Convenient constant for the common case of a " character used to escape delimiters or line endings.
  `static final String`
  `DELIMITER_COMMA`
  Convenient constant for the common case of a comma delimiter.
  `static final String`
  `DELIMITER_TAB`
  Convenient constant for the common case of a tab delimiter.

  ### Fields inherited from class org.springframework.batch.item.file.transform.AbstractLineTokenizer

  `names`

- ## Constructor Summary

  Constructors
  Constructor
  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.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `afterPropertiesSet()`
  `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.

  ### Methods inherited from class org.springframework.batch.item.file.transform.AbstractLineTokenizer

  `hasNames, isStrict, setFieldSetFactory, setNames, setStrict, tokenize`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### DELIMITER_TAB

    public static final String DELIMITER_TAB
    Convenient constant for the common case of a tab delimiter.
    See Also:
      - Constant Field Values

  - ### DELIMITER_COMMA

    public static final String DELIMITER_COMMA
    Convenient constant for the common case of a comma delimiter.
    See Also:
      - Constant Field Values

  - ### DEFAULT_QUOTE_CHARACTER

    public static final char DEFAULT_QUOTE_CHARACTER
    Convenient constant for the common case of a " character used to escape delimiters or line endings.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### DelimitedLineTokenizer

    public DelimitedLineTokenizer()
    Create a new instance of the `DelimitedLineTokenizer` class for the common case where the delimiter is a `comma`.
    See Also:
      - `DelimitedLineTokenizer(String)`
      - `DELIMITER_COMMA`

  - ### DelimitedLineTokenizer

    public DelimitedLineTokenizer(String delimiter)
    Create a new instance of the `DelimitedLineTokenizer` class.
    Parameters:
      `delimiter` - the desired delimiter. This is required

- ## Method Details

  - ### setDelimiter

    public void setDelimiter(String delimiter)
    Setter for the delimiter character.
    Parameters:
      `delimiter` - the String used as a delimiter

  - ### setIncludedFields

    public void setIncludedFields(int... includedFields)
    The fields to include in the output by position (starting at 0). By default all fields are included, but this property can be set to pick out only a few fields from a larger set. Note that if field names are provided, their number must match the number of included fields.
    Parameters:
      `includedFields` - the included fields to set

  - ### setQuoteCharacter

    public void setQuoteCharacter(char quoteCharacter)
    Public setter for the quoteCharacter. The quote character can be used to extend a field across line endings or to enclose a String which contains the delimiter. Inside a quoted token the quote character can be used to escape itself, thus "a""b""c" is tokenized to a"b"c.
    Parameters:
      `quoteCharacter` - the quoteCharacter to set
    See Also:
      - `DEFAULT_QUOTE_CHARACTER`

  - ### doTokenize

    protected List<String> doTokenize(String line)
    Yields the tokens resulting from the splitting of the supplied `line`.
    Specified by:
      `doTokenize` in class `AbstractLineTokenizer`
    Parameters:
      `line` - the line to be tokenized
    Returns:
      the resulting tokens

  - ### isQuoteCharacter

    protected boolean isQuoteCharacter(char c)
    Is the supplied character a quote character?
    Parameters:
      `c` - the character to be checked
    Returns:
      `true` if the supplied character is an quote character
    See Also:
      - `setQuoteCharacter(char)`

  - ### afterPropertiesSet

    public void afterPropertiesSet() throws Exception
    Specified by:
      `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
    Throws:
      `Exception`