org.springframework.batch.item.file.transform

## Class AbstractLineTokenizer

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

- All Implemented Interfaces:
    LineTokenizer
  Direct Known Subclasses:
    DelimitedLineTokenizer, FixedLengthTokenizer, RegexLineTokenizer

      public abstract class AbstractLineTokenizer
      extends java.lang.Object
      implements LineTokenizer

  Abstract class handling common concerns of various `LineTokenizer` implementations such as dealing with names and actual construction of `FieldSet`
  Author:
    Dave Syer, Robert Kasanicky, Lucas Ward, Michael Minella

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String[]` | `names`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractLineTokenizer()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract java.util.List<java.lang.String>` | `doTokenize(java.lang.String line)`
    `boolean` | `hasNames()`
    `protected boolean` | `isStrict()` Provides access to the strict flag for subclasses if needed.
    `void` | `setFieldSetFactory(FieldSetFactory fieldSetFactory)` Factory for `FieldSet` instances.
    `void` | `setNames(java.lang.String[] names)` Setter for column names.
    `void` | `setStrict(boolean strict)` Public setter for the strict flag.
    `FieldSet` | `tokenize(java.lang.String line)` Yields the tokens resulting from the splitting of the supplied `line`.

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

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

- - ### Field Detail

    - #### names

          protected java.lang.String[] names

  - ### Constructor Detail

    - #### AbstractLineTokenizer

          public AbstractLineTokenizer()

  - ### Method Detail

    - #### setStrict

          public void setStrict(boolean strict)

      Public setter for the strict flag. If true (the default) then number of tokens in line must match the number of tokens defined (by `Range`, columns, etc.) in `LineTokenizer`. If false then lines with less tokens will be tolerated and padded with empty columns, and lines with more tokens will simply be truncated.
      Parameters:
        `strict` - the strict flag to set

    - #### isStrict

          protected boolean isStrict()

      Provides access to the strict flag for subclasses if needed.
      Returns:
        the strict flag value

    - #### setFieldSetFactory

          public void setFieldSetFactory(FieldSetFactory fieldSetFactory)

      Factory for `FieldSet` instances. Can be injected by clients to customize the default number and date formats.
      Parameters:
        `fieldSetFactory` - the `FieldSetFactory` to set

    - #### setNames

          public void setNames(java.lang.String[] names)

      Setter for column names. Optional, but if set, then all lines must have as many or fewer tokens.
      Parameters:
        `names` -

    - #### hasNames

          public boolean hasNames()

      Returns:
        `true` if column names have been specified
      See Also:
        `setNames(String[])`

    - #### tokenize

          public FieldSet tokenize(java.lang.String line)

      Yields the tokens resulting from the splitting of the supplied `line`.
      Specified by:
        `tokenize` in interface `LineTokenizer`
      Parameters:
        `line` - the line to be tokenized (can be `null`)
      Returns:
        the resulting tokens

    - #### doTokenize

          protected abstract java.util.List<java.lang.String> doTokenize(java.lang.String line)