|
BeanIO 2.0.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.beanio.spring.BeanIOFlatFileItemWriter<T>
T
- Class type written to the filepublic class BeanIOFlatFileItemWriter<T>
A Spring Batch item writer that uses a BeanIO stream mapping file to write items to a flat file. Restart capabilities are fully supported.
This implementation requires Spring 2.5 or greater, and Spring Batch 2.1.x.
Constructor Summary | |
---|---|
BeanIOFlatFileItemWriter()
Constructs a new BeanIOFlatFileItemWriter. |
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
void |
close()
|
protected void |
initializeStreamFactory()
Creates a StreamFactory if one was not set, loads the stream
mapping resource if set, and validates the StreamFactory has a
mapping for the configured stream name. |
void |
open(ExecutionContext executionContext)
|
void |
setAppendAllowed(boolean append)
Flag to indicate that the target file should be appended if it already exists. |
void |
setEncoding(String encoding)
Sets the output stream encoding. |
void |
setHeaderCallback(FlatFileHeaderCallback headerCallback)
The FlatFileHeaderCallback if called before writing the first item to the file. |
void |
setLineSeparator(String lineSeparator)
Sets the line separator used for the header and footer callback only. |
void |
setName(String name)
Sets the name to use for prefixing keys added to the execution context. |
void |
setResource(Resource resource)
|
void |
setSaveState(boolean saveState)
Set the flag indicating whether or not state should be saved in the provided ExecutionContext during the ItemStream call to
update. |
void |
setShouldDeleteIfEmpty(boolean shouldDeleteIfEmpty)
Flag to indicate that the target file should be deleted if no lines have been written (other than header and footer) on close. |
void |
setShouldDeleteIfExists(boolean shouldDeleteIfExists)
Flag to indicate that the target file should be deleted if it already exists, otherwise it will be created. |
void |
setStreamFactory(StreamFactory streamFactory)
Sets the StreamFactory for loading stream mapping configurations. |
void |
setStreamMapping(Resource streamMapping)
Sets the mapping file resource. |
void |
setStreamName(String streamName)
Sets the mapping configuration's stream name for writing this output stream. |
void |
setTransactional(boolean transactional)
Flag to indicate that writing to the buffer should be delayed if a transaction is active. |
void |
update(ExecutionContext executionContext)
|
void |
write(List<? extends T> items)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BeanIOFlatFileItemWriter()
Method Detail |
---|
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public void open(ExecutionContext executionContext) throws ItemStreamException
open
in interface ItemStream
ItemStreamException
public void update(ExecutionContext executionContext) throws ItemStreamException
update
in interface ItemStream
ItemStreamException
public void close() throws ItemStreamException
close
in interface ItemStream
ItemStreamException
public void write(List<? extends T> items) throws Exception
write
in interface ItemWriter<T>
Exception
public void setStreamFactory(StreamFactory streamFactory)
StreamFactory
for loading stream mapping configurations. If not set,
a new default StreamFactory is created.
streamFactory
- the StreamFactory to use for loading stream
mapping configurationspublic void setStreamMapping(Resource streamMapping)
streamMapping
- the stream mapping resourcepublic void setStreamName(String streamName)
streamName
- the stream namepublic void setResource(Resource resource)
setResource
in interface ResourceAwareItemWriterItemStream<T>
public void setEncoding(String encoding)
encoding
- output stream encodingprotected void initializeStreamFactory() throws Exception
StreamFactory
if one was not set, loads the stream
mapping resource if set, and validates the StreamFactory has a
mapping for the configured stream name.
IllegalStateException
- if the configured stream name is not found
in the StreamFactory after loading the stream mapping
Exception
public void setAppendAllowed(boolean append)
shouldDeleteIfExists
is
automatically set to false, so that flag should not be set explicitly.
Defaults to false.
append
- the flag value to setpublic void setShouldDeleteIfExists(boolean shouldDeleteIfExists)
appendAllowed
is also false then there will be an exception when the
stream is opened to prevent existing data being potentially corrupted.
shouldDeleteIfExists
- the flag value to setpublic void setShouldDeleteIfEmpty(boolean shouldDeleteIfEmpty)
shouldDeleteIfEmpty
- the flag value to setpublic void setSaveState(boolean saveState)
ExecutionContext
during the ItemStream
call to
update. Setting this to false means that it will always start at the
beginning on a restart.
saveState
- public void setTransactional(boolean transactional)
transactional
- set to false to disable buffering
writes for transactionspublic void setName(String name)
name
- context key prefixpublic void setLineSeparator(String lineSeparator)
lineSeparator
- the line separator to setpublic void setHeaderCallback(FlatFileHeaderCallback headerCallback)
headerCallback
- the FlatFileHeaderCallback
to invoke when writing
to a new file
|
BeanIO 2.0.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |