|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.batch.item.util.ExecutionContextUserSupport
org.springframework.batch.item.file.FlatFileItemWriter<T>
public class FlatFileItemWriter<T>
This class is an item writer that writes data to a file or stream. The writer
also provides restart. The location of the output file is defined by a
Resource and must represent a writable file.
Uses buffered writer to improve performance.
The implementation is *not* thread-safe.
| Field Summary | |
|---|---|
protected static Log |
logger
|
| Constructor Summary | |
|---|---|
FlatFileItemWriter()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Assert that mandatory properties (lineAggregator) are set. |
void |
close()
If any resources are needed for the stream to operate they need to be destroyed here. |
void |
open(ExecutionContext executionContext)
Initialize the reader. |
void |
setEncoding(String newEncoding)
Sets encoding for output template. |
void |
setFooterCallback(FlatFileFooterCallback footerCallback)
footerCallback will be called after writing the last item to file, but before the file is closed. |
void |
setHeaderCallback(FlatFileHeaderCallback headerCallback)
headerCallback will be called before writing the first item to file. |
void |
setLineAggregator(LineAggregator<T> lineAggregator)
Public setter for the LineAggregator. |
void |
setLineSeparator(String lineSeparator)
Public setter for the line separator. |
void |
setResource(Resource resource)
Setter for 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 appended. |
void |
update(ExecutionContext executionContext)
Indicates that the execution context provided during open is about to be saved. |
void |
write(List<? extends T> items)
Writes out a string followed by a "new line", where the format of the new line separator is determined by the underlying operating system. |
| Methods inherited from class org.springframework.batch.item.util.ExecutionContextUserSupport |
|---|
getKey, getName, setName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Log logger
| Constructor Detail |
|---|
public FlatFileItemWriter()
| Method Detail |
|---|
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface InitializingBeanExceptionInitializingBean.afterPropertiesSet()public void setLineSeparator(String lineSeparator)
lineSeparator - the line separator to setpublic void setLineAggregator(LineAggregator<T> lineAggregator)
LineAggregator. This will be used to
translate the item into a line for output.
lineAggregator - the LineAggregator to setpublic void setResource(Resource resource)
setResource in interface ResourceAwareItemWriterItemStream<T>resource - public void setEncoding(String newEncoding)
public void setShouldDeleteIfExists(boolean shouldDeleteIfExists)
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 setHeaderCallback(FlatFileHeaderCallback headerCallback)
public void setFooterCallback(FlatFileFooterCallback footerCallback)
public void write(List<? extends T> items)
throws Exception
write in interface ItemWriter<T>items - list of items to be written to output stream
Exception - if the transformer or file output fail,
WriterNotOpenException if the writer has not been initialized.public void close()
ItemStream
close in interface ItemStreamItemStream.close()
public void open(ExecutionContext executionContext)
throws ItemStreamException
open in interface ItemStreamItemStreamExceptionItemStream.open(ExecutionContext)public void update(ExecutionContext executionContext)
ItemStream
update in interface ItemStreamexecutionContext - to be updatedItemStream.update(ExecutionContext)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||