Class FlatFileItemWriterProperties

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

@ConfigurationProperties(prefix="spring.batch.job.flatfileitemwriter") public class FlatFileItemWriterProperties extends Object
Properties for configuring a FlatFileItemWriter.
Since:
2.3
Author:
Michael Minella
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    When a file is delimited, this String will be used as the delimiter between fields.
    File encoding for the output file.
    Format used with the FormatterLineAggregator.
    String used to separate lines in output.
    The Locale used when generating the output file.
    int
    The longest a record is allowed to be.
    int
    The minimum record length.
    Returns the configured value of the name used to calculate ExecutionContext keys.
    Names of the fields to be extracted into the output.
    org.springframework.core.io.Resource
    The output file for the FlatFileItemWriter.
    boolean
    True if an output file is found and should be added onto instead of replaced/deleted.
    boolean
    Indicates of the output will be delimited by a configured string (, by default).
    boolean
    A flag indicating that changes should be force-synced to disk on flush.
    boolean
    Indicates that the output file will use String formatting to generate the output.
    boolean
    Returns the configured value of if the state of the reader will be persisted.
    boolean
    Indicates if the output file should be deleted if no output was written to it.
    boolean
    Indicates if an existing output file should be deleted on startup.
    boolean
    Indicates if flushing the buffer should be delayed while a transaction is active.
    void
    setAppend(boolean append)
    Configure if the output file is found if it should be appended to.
    void
    setDelimited(boolean delimited)
    Configure the use of the DelimitedLineAggregator to generate the output per item.
    void
    setDelimiter(String delimiter)
    Configure the String used to delimit the fields in the output file.
    void
    setEncoding(String encoding)
    Configure encoding of the output file.
    void
    setForceSync(boolean forceSync)
    A flag indicating that changes should be force-synced to disk on flush.
    void
    setFormat(String format)
    Configure the format the FormatterLineAggregator will use for each item.
    void
    setFormatted(boolean formatted)
    Indicates to use a FormatterLineAggregator to generate the output per item.
    void
    setLineSeparator(String lineSeparator)
    Configure the String used to separate each line.
    void
    setLocale(Locale locale)
    Configure the Locale to use when generating the output.
    void
    setMaximumLength(int maximumLength)
    Configure the maximum record length.
    void
    setMinimumLength(int minimumLength)
    Configure the minimum record length.
    void
    The name used to calculate the key within the ExecutionContext.
    void
    setNames(String[] names)
    Provide an ordered array of field names used to generate the output of a file.
    void
    setResource(org.springframework.core.io.Resource resource)
    The Resource to be used as output.
    void
    setSaveState(boolean saveState)
    Configure if the state of the ItemStreamSupport should be persisted within the ExecutionContext for restart purposes.
    void
    setShouldDeleteIfEmpty(boolean shouldDeleteIfEmpty)
    Configure if an empty output file should be deleted once the step is complete.
    void
    setShouldDeleteIfExists(boolean shouldDeleteIfExists)
    Configures if an existing output file should be deleted on the start of the step.
    void
    setTransactional(boolean transactional)
    Configure if output should not be flushed to disk during an active transaction.

    Methods inherited from class java.lang.Object

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

    • FlatFileItemWriterProperties

      public FlatFileItemWriterProperties()
  • 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)
    • getResource

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

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

      public boolean isDelimited()
      Indicates of the output will be delimited by a configured string (, by default).
      Returns:
      true if the output file is a delimited file
    • setDelimited

      public void setDelimited(boolean delimited)
      Configure the use of the DelimitedLineAggregator to generate the output per item.
      Parameters:
      delimited - indicator if the file will be delimited or not
    • getDelimiter

      public String getDelimiter()
      When a file is delimited, this String will be used as the delimiter between fields.
      Returns:
      delimiter
    • setDelimiter

      public void setDelimiter(String delimiter)
      Configure the String used to delimit the fields in the output file.
      Parameters:
      delimiter - String used to delimit the fields of the output file.
    • getNames

      public String[] getNames()
      Names of the fields to be extracted into the output.
      Returns:
      An array of field names
    • setNames

      public void setNames(String[] names)
      Provide an ordered array of field names used to generate the output of a file.
      Parameters:
      names - An array of field names
    • isAppend

      public boolean isAppend()
      True if an output file is found and should be added onto instead of replaced/deleted. False by default.
      Returns:
      appending indicator
    • setAppend

      public void setAppend(boolean append)
      Configure if the output file is found if it should be appended to. Defaults to false.
      Parameters:
      append - true if the output file should be appended onto if found.
    • isFormatted

      public boolean isFormatted()
      Indicates that the output file will use String formatting to generate the output.
      Returns:
      true if the file will contain formatted records defaults to true
    • setFormatted

      public void setFormatted(boolean formatted)
      Indicates to use a FormatterLineAggregator to generate the output per item.
      Parameters:
      formatted - true if the output should be formatted via the FormatterLineAggregator
    • getEncoding

      public String getEncoding()
      File encoding for the output file.
      Returns:
      the configured encoding for the output file (Defaults to FlatFileItemWriter.DEFAULT_CHARSET)
    • setEncoding

      public void setEncoding(String encoding)
      Configure encoding of the output file.
      Parameters:
      encoding - output encoding
    • isForceSync

      public boolean isForceSync()
      A flag indicating that changes should be force-synced to disk on flush. Defaults to false.
      Returns:
      The current instance of the builder.
    • setForceSync

      public void setForceSync(boolean forceSync)
      A flag indicating that changes should be force-synced to disk on flush. Defaults to false.
      Parameters:
      forceSync - value to set the flag to
    • getLineSeparator

      public String getLineSeparator()
      String used to separate lines in output. Defaults to the System property line.separator.
      Returns:
      the separator string
    • setLineSeparator

      public void setLineSeparator(String lineSeparator)
      Configure the String used to separate each line.
      Parameters:
      lineSeparator - defaults to System's line.separator property
    • isShouldDeleteIfEmpty

      public boolean isShouldDeleteIfEmpty()
      Indicates if the output file should be deleted if no output was written to it. Defaults to false.
      Returns:
      true if a file that is empty at the end of the step should be deleted.
    • setShouldDeleteIfEmpty

      public void setShouldDeleteIfEmpty(boolean shouldDeleteIfEmpty)
      Configure if an empty output file should be deleted once the step is complete. Defaults to false.
      Parameters:
      shouldDeleteIfEmpty - true if the file should be deleted if no items have been written to it.
    • isShouldDeleteIfExists

      public boolean isShouldDeleteIfExists()
      Indicates if an existing output file should be deleted on startup. Defaults to true.
      Returns:
      if an existing output file should be deleted.
    • setShouldDeleteIfExists

      public void setShouldDeleteIfExists(boolean shouldDeleteIfExists)
      Configures if an existing output file should be deleted on the start of the step. Defaults to true.
      Parameters:
      shouldDeleteIfExists - if true and an output file of a previous run is found, it will be deleted.
    • isTransactional

      public boolean isTransactional()
      Indicates if flushing the buffer should be delayed while a transaction is active. Defaults to true.
      Returns:
      flag indicating if flushing should be delayed during a transaction
    • setTransactional

      public void setTransactional(boolean transactional)
      Configure if output should not be flushed to disk during an active transaction.
      Parameters:
      transactional - defaults to true
    • getFormat

      public String getFormat()
      Format used with the FormatterLineAggregator.
      Returns:
      the format for each item's output.
    • setFormat

      public void setFormat(String format)
      Configure the format the FormatterLineAggregator will use for each item.
      Parameters:
      format - the format for each item's output.
    • getLocale

      public Locale getLocale()
      The Locale used when generating the output file.
      Returns:
      configured Locale. Defaults to Locale.getDefault()
    • setLocale

      public void setLocale(Locale locale)
      Configure the Locale to use when generating the output.
      Parameters:
      locale - the configured Locale
    • getMaximumLength

      public int getMaximumLength()
      The longest a record is allowed to be. If 0, the maximum is unlimited.
      Returns:
      the max record length allowed. Defaults to 0.
    • setMaximumLength

      public void setMaximumLength(int maximumLength)
      Configure the maximum record length. If 0, the size is unbounded.
      Parameters:
      maximumLength - the maximum record length allowed.
    • getMinimumLength

      public int getMinimumLength()
      The minimum record length.
      Returns:
      the minimum record length allowed.
    • setMinimumLength

      public void setMinimumLength(int minimumLength)
      Configure the minimum record length.
      Parameters:
      minimumLength - the minimum record length.