Class FlatFileItemWriterBuilder<T>
java.lang.Object
org.springframework.batch.item.file.builder.FlatFileItemWriterBuilder<T>
A builder implementation for the
FlatFileItemWriter- Since:
- 4.0
- Author:
- Michael Minella, Glenn Renfro, Mahmoud Ben Hassine, Drummond Dawson, Stefano Cordio
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder for constructing aDelimitedLineAggregatorstatic classA builder for constructing aFormatterLineAggregator. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(boolean append) If set to true and the file exists, the output will be appended to the existing file.build()Validates and builds aFlatFileItemWriter.Returns an instance of aFlatFileItemWriterBuilder.DelimitedBuilderfor building aDelimitedLineAggregator.Encoding used for output.footerCallback(FlatFileFooterCallback callback) A callback for footer processingforceSync(boolean forceSync) A flag indicating that changes should be force-synced to disk on flush.Returns an instance of aFlatFileItemWriterBuilder.FormattedBuilderfor building aFormatterLineAggregator.headerCallback(FlatFileHeaderCallback callback) A callback for header processing.lineAggregator(LineAggregator<T> lineAggregator) Line aggregator used to build the String version of each item.lineSeparator(String lineSeparator) String used to separate lines in output.The name used to calculate the key within theExecutionContext.resource(org.springframework.core.io.WritableResource resource) TheWritableResourceto be used as output.saveState(boolean saveState) Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.shouldDeleteIfEmpty(boolean shouldDelete) If set to true, once the step is complete, if the resource previously provided is empty, it will be deleted.shouldDeleteIfExists(boolean shouldDelete) If set to true, upon the start of the step, if the resource already exists, it will be deleted and recreated.transactional(boolean transactional) If set to true, the flushing of the buffer is delayed while a transaction is active.
-
Field Details
-
logger
protected org.apache.commons.logging.Log logger
-
-
Constructor Details
-
FlatFileItemWriterBuilder
public FlatFileItemWriterBuilder()
-
-
Method Details
-
saveState
Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- Parameters:
saveState- defaults to true- Returns:
- The current instance of the builder.
-
name
The name used to calculate the key within theExecutionContext. Required ifsaveState(boolean)is set to true.- Parameters:
name- name of the writer instance- Returns:
- The current instance of the builder.
- See Also:
-
resource
TheWritableResourceto be used as output.- Parameters:
resource- the output of the writer.- Returns:
- The current instance of the builder.
- See Also:
-
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- Returns:
- The current instance of the builder.
- See Also:
-
lineSeparator
String used to separate lines in output. Defaults to the System property line.separator.- Parameters:
lineSeparator- value to use for a line separator- Returns:
- The current instance of the builder.
- See Also:
-
lineAggregator
Line aggregator used to build the String version of each item.- Parameters:
lineAggregator-LineAggregatorimplementation- Returns:
- The current instance of the builder.
- See Also:
-
encoding
Encoding used for output.- Parameters:
encoding- encoding type.- Returns:
- The current instance of the builder.
- See Also:
-
shouldDeleteIfEmpty
If set to true, once the step is complete, if the resource previously provided is empty, it will be deleted.- Parameters:
shouldDelete- defaults to false- Returns:
- The current instance of the builder
- See Also:
-
shouldDeleteIfExists
If set to true, upon the start of the step, if the resource already exists, it will be deleted and recreated.- Parameters:
shouldDelete- defaults to true- Returns:
- The current instance of the builder
- See Also:
-
append
If set to true and the file exists, the output will be appended to the existing file.- Parameters:
append- defaults to false- Returns:
- The current instance of the builder
- See Also:
-
headerCallback
A callback for header processing.- Parameters:
callback-FlatFileHeaderCallbackimpl- Returns:
- The current instance of the builder
- See Also:
-
transactional
If set to true, the flushing of the buffer is delayed while a transaction is active.- Parameters:
transactional- defaults to true- Returns:
- The current instance of the builder
- See Also:
-
delimited
Returns an instance of aFlatFileItemWriterBuilder.DelimitedBuilderfor building aDelimitedLineAggregator. TheDelimitedLineAggregatorconfigured by this builder will only be used if one is not explicitly configured vialineAggregator- Returns:
- a
FlatFileItemWriterBuilder.DelimitedBuilder
-
formatted
Returns an instance of aFlatFileItemWriterBuilder.FormattedBuilderfor building aFormatterLineAggregator. TheFormatterLineAggregatorconfigured by this builder will only be used if one is not explicitly configured vialineAggregator- Returns:
- a
FlatFileItemWriterBuilder.FormattedBuilder
-
build
Validates and builds aFlatFileItemWriter.- Returns:
- a
FlatFileItemWriter
-