Class FlatFileItemReaderProperties

java.lang.Object
org.springframework.cloud.task.batch.autoconfigure.flatfile.FlatFileItemReaderProperties

@ConfigurationProperties(prefix="spring.batch.job.flatfileitemreader") public class FlatFileItemReaderProperties extends Object
Properties to configure a FlatFileItemReader.
Since:
2.3
Author:
Michael Minella
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List of String values used to indicate what records are comments.
    int
    Provides the index of the current item.
    The String used to divide the record into fields.
    Returns the encoding for the input file.
    A List of indices indicating what fields to include.
    int
    Number of lines to skip when reading the input file.
    int
    The maximum number of items to be read.
    Returns the configured value of the name used to calculate ExecutionContext keys.
    Names of each column.
    char
    The char used to indicate that a field is quoted.
    List<org.springframework.batch.item.file.transform.Range>
    The column ranges to be used to parsed a fixed width file.
    org.springframework.core.io.Resource
    The input file for the FlatFileItemReader.
    boolean
    Indicates if the input file is a delimited file or not.
    boolean
    Indicates that a file contains records with fixed length columns.
    boolean
    Indicates if the number of tokens must match the number of configured fields.
    boolean
    Returns the configured value of if the state of the reader will be persisted.
    boolean
    Returns true if a missing input file is considered an error.
    void
    setComments(List<String> comments)
    Takes a list of String elements used to indicate what records are comments.
    void
    setCurrentItemCount(int currentItemCount)
    Index for the current item.
    void
    setDelimited(boolean delimited)
    Indicates that a DelimitedLineTokenizer should be used to parse each line.
    void
    setDelimiter(String delimiter)
    Define the delimiter for the file.
    void
    setEncoding(String encoding)
    Configure the encoding used by the reader to read the input source.
    void
    setFixedLength(boolean fixedLength)
    Indicates that a FixedLengthTokenizer should be used to parse the records in the file.
    void
    setIncludedFields(List<Integer> includedFields)
    A list of indices of the fields within a delimited file to be included.
    void
    setLinesToSkip(int linesToSkip)
    The number of lines to skip at the beginning of reading the file.
    void
    setMaxItemCount(int maxItemCount)
    Configure the max number of items to be read.
    void
    The name used to calculate the key within the ExecutionContext.
    void
    setNames(String[] names)
    The names of the fields to be parsed from the file.
    void
    setParsingStrict(boolean parsingStrict)
    Indicates if the number of tokens must match the number of configured fields.
    void
    setQuoteCharacter(char quoteCharacter)
    Define the character used to quote fields.
    void
    setRanges(List<org.springframework.batch.item.file.transform.Range> ranges)
    Column ranges for each field.
    void
    setResource(org.springframework.core.io.Resource resource)
    The Resource to be used as input.
    void
    setSaveState(boolean saveState)
    Configure if the state of the ItemStreamSupport should be persisted within the ExecutionContext for restart purposes.
    void
    setStrict(boolean strict)
    Configure if the reader should be in strict mode (require the input Resource to exist).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FlatFileItemReaderProperties

      public FlatFileItemReaderProperties()
  • Method Details

    • isSaveState

      public boolean isSaveState()
      Returns the configured value of if the state of the reader will be persisted.
      Returns:
      true if the state will be persisted
    • setSaveState

      public void setSaveState(boolean saveState)
      Configure if the state of the ItemStreamSupport should be persisted within the ExecutionContext for restart purposes.
      Parameters:
      saveState - defaults to true
    • getName

      public String getName()
      Returns the configured value of the name used to calculate ExecutionContext keys.
      Returns:
      the name
    • setName

      public void setName(String name)
      The name used to calculate the key within the ExecutionContext. Required if setSaveState(boolean) is set to true.
      Parameters:
      name - name of the reader instance
      See Also:
      • ItemStreamSupport.setName(String)
    • getMaxItemCount

      public int getMaxItemCount()
      The maximum number of items to be read.
      Returns:
      the configured number of items, defaults to Integer.MAX_VALUE
    • setMaxItemCount

      public void setMaxItemCount(int maxItemCount)
      Configure the max number of items to be read.
      Parameters:
      maxItemCount - the max items to be read
      See Also:
      • AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)
    • getCurrentItemCount

      public int getCurrentItemCount()
      Provides the index of the current item.
      Returns:
      item index
    • setCurrentItemCount

      public void setCurrentItemCount(int currentItemCount)
      Index for the current item. Also used on restarts to indicate where to start from.
      Parameters:
      currentItemCount - current index
      See Also:
      • AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)
    • getComments

      public List<String> getComments()
      List of String values used to indicate what records are comments.
      Returns:
      list of comment indicators
    • setComments

      public void setComments(List<String> comments)
      Takes a list of String elements used to indicate what records are comments.
      Parameters:
      comments - strings used to indicate commented lines
    • getResource

      public org.springframework.core.io.Resource getResource()
      The input file for the FlatFileItemReader.
      Returns:
      a Resource
    • setResource

      public void setResource(org.springframework.core.io.Resource resource)
      The Resource to be used as input.
      Parameters:
      resource - the input to the reader.
      See Also:
      • FlatFileItemReader.setResource(Resource)
    • isStrict

      public boolean isStrict()
      Returns true if a missing input file is considered an error.
      Returns:
      true if the input file is required.
    • setStrict

      public void setStrict(boolean strict)
      Configure if the reader should be in strict mode (require the input Resource to exist).
      Parameters:
      strict - true if the input file is required to exist.
      See Also:
      • FlatFileItemReader.setStrict(boolean)
    • getEncoding

      public String getEncoding()
      Returns the encoding for the input file. Defaults to FlatFileItemReader#DEFAULT_CHARSET.
      Returns:
      the configured encoding
    • setEncoding

      public void setEncoding(String encoding)
      Configure the encoding used by the reader to read the input source. Default value is FlatFileItemReader.DEFAULT_CHARSET.
      Parameters:
      encoding - to use to read the input source.
      See Also:
      • FlatFileItemReader.setEncoding(String)
    • getLinesToSkip

      public int getLinesToSkip()
      Number of lines to skip when reading the input file.
      Returns:
      number of lines
    • setLinesToSkip

      public void setLinesToSkip(int linesToSkip)
      The number of lines to skip at the beginning of reading the file.
      Parameters:
      linesToSkip - number of lines to be skipped.
      See Also:
      • FlatFileItemReader.setLinesToSkip(int)
    • isDelimited

      public boolean isDelimited()
      Indicates if the input file is a delimited file or not.
      Returns:
      true if the file is delimited
    • setDelimited

      public void setDelimited(boolean delimited)
      Indicates that a DelimitedLineTokenizer should be used to parse each line.
      Parameters:
      delimited - true if the file is a delimited file
    • getDelimiter

      public String getDelimiter()
      The String used to divide the record into fields.
      Returns:
      the delimiter
    • setDelimiter

      public void setDelimiter(String delimiter)
      Define the delimiter for the file.
      Parameters:
      delimiter - String used as a delimiter between fields.
      See Also:
      • DelimitedLineTokenizer.setDelimiter(String)
    • getQuoteCharacter

      public char getQuoteCharacter()
      The char used to indicate that a field is quoted.
      Returns:
      the quote char
    • setQuoteCharacter

      public void setQuoteCharacter(char quoteCharacter)
      Define the character used to quote fields.
      Parameters:
      quoteCharacter - char used to define quoted fields
      See Also:
      • DelimitedLineTokenizer.setQuoteCharacter(char)
    • getIncludedFields

      public List<Integer> getIncludedFields()
      A List of indices indicating what fields to include.
      Returns:
      list of indices
    • setIncludedFields

      public void setIncludedFields(List<Integer> includedFields)
      A list of indices of the fields within a delimited file to be included.
      Parameters:
      includedFields - indices of the fields
      See Also:
      • DelimitedLineTokenizer.setIncludedFields(int[])
    • isFixedLength

      public boolean isFixedLength()
      Indicates that a file contains records with fixed length columns.
      Returns:
      true if the file is parsed using column indices
    • setFixedLength

      public void setFixedLength(boolean fixedLength)
      Indicates that a FixedLengthTokenizer should be used to parse the records in the file.
      Parameters:
      fixedLength - true if the records should be tokenized by column index
    • getRanges

      public List<org.springframework.batch.item.file.transform.Range> getRanges()
      The column ranges to be used to parsed a fixed width file.
      Returns:
      a list of Range instances
    • setRanges

      public void setRanges(List<org.springframework.batch.item.file.transform.Range> ranges)
      Column ranges for each field.
      Parameters:
      ranges - list of ranges in start-end format (end is optional)
    • getNames

      public String[] getNames()
      Names of each column.
      Returns:
      names
    • setNames

      public void setNames(String[] names)
      The names of the fields to be parsed from the file.
      Parameters:
      names - names of fields
    • isParsingStrict

      public boolean isParsingStrict()
      Indicates if the number of tokens must match the number of configured fields.
      Returns:
      true if they must match
    • setParsingStrict

      public void setParsingStrict(boolean parsingStrict)
      Indicates if the number of tokens must match the number of configured fields.
      Parameters:
      parsingStrict - true if they must match