Class AbstractLineTokenizer

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

public abstract class AbstractLineTokenizer extends Object implements LineTokenizer
Abstract class handling common concerns of various LineTokenizer implementations such as dealing with names and actual construction of FieldSet
Dave Syer, Robert Kasanicky, Lucas Ward, Michael Minella, Mahmoud Ben Hassine
  • Field Details

    • names

      protected String[] names
  • Constructor Details

    • AbstractLineTokenizer

      public AbstractLineTokenizer()
  • Method Details

    • 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.
      strict - the strict flag to set
    • isStrict

      protected boolean isStrict()
      Provides access to the strict flag for subclasses if needed.
      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.
      fieldSetFactory - the FieldSetFactory to set
    • setNames

      public void setNames(String... names)
      Setter for column names. Optional, but if set, then all lines must have as many or fewer tokens.
      names - names of each column
    • hasNames

      public boolean hasNames()
      true if column names have been specified
      See Also:
    • tokenize

      public FieldSet tokenize(@Nullable String line)
      Yields the tokens resulting from the splitting of the supplied line.
      Specified by:
      tokenize in interface LineTokenizer
      line - the line to be tokenized (can be null)
      the resulting tokens
    • doTokenize

      protected abstract List<String> doTokenize(String line)