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
-
Method Summary
Modifier and TypeMethodDescriptionWhen a file is delimited, thisString
will be used as the delimiter between fields.File encoding for the output file.Format used with theFormatterLineAggregator
.String used to separate lines in output.TheLocale
used when generating the output file.int
The longest a record is allowed to be.int
The minimum record length.getName()
Returns the configured value of the name used to calculateExecutionContext
keys.String[]
getNames()
Names of the fields to be extracted into the output.org.springframework.core.io.Resource
The output file for theFlatFileItemWriter
.boolean
isAppend()
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 theDelimitedLineAggregator
to generate the output per item.void
setDelimiter
(String delimiter) Configure theString
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
Configure the format theFormatterLineAggregator
will use for each item.void
setFormatted
(boolean formatted) Indicates to use aFormatterLineAggregator
to generate the output per item.void
setLineSeparator
(String lineSeparator) Configure theString
used to separate each line.void
Configure theLocale
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 theExecutionContext
.void
Provide an ordered array of field names used to generate the output of a file.void
setResource
(org.springframework.core.io.Resource resource) TheResource
to be used as output.void
setSaveState
(boolean saveState) Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
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.
-
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 theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- Parameters:
saveState
- defaults to true
-
getName
Returns the configured value of the name used to calculateExecutionContext
keys.- Returns:
- the name
-
setName
The name used to calculate the key within theExecutionContext
. Required ifsetSaveState(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 theFlatFileItemWriter
.- Returns:
- a
Resource
-
setResource
public void setResource(org.springframework.core.io.Resource resource) TheResource
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 theDelimitedLineAggregator
to generate the output per item.- Parameters:
delimited
- indicator if the file will be delimited or not
-
getDelimiter
When a file is delimited, thisString
will be used as the delimiter between fields.- Returns:
- delimiter
-
setDelimiter
Configure theString
used to delimit the fields in the output file.- Parameters:
delimiter
-String
used to delimit the fields of the output file.
-
getNames
Names of the fields to be extracted into the output.- Returns:
- An array of field names
-
setNames
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 aFormatterLineAggregator
to generate the output per item.- Parameters:
formatted
- true if the output should be formatted via theFormatterLineAggregator
-
getEncoding
File encoding for the output file.- Returns:
- the configured encoding for the output file (Defaults to
FlatFileItemWriter.DEFAULT_CHARSET
)
-
setEncoding
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
String used to separate lines in output. Defaults to the System property line.separator.- Returns:
- the separator string
-
setLineSeparator
Configure theString
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
Format used with theFormatterLineAggregator
.- Returns:
- the format for each item's output.
-
setFormat
Configure the format theFormatterLineAggregator
will use for each item.- Parameters:
format
- the format for each item's output.
-
getLocale
TheLocale
used when generating the output file.- Returns:
- configured
Locale
. Defaults toLocale.getDefault()
-
setLocale
Configure theLocale
to use when generating the output.- Parameters:
locale
- the configuredLocale
-
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.
-