|
||||||||||
| 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
public class FlatFileItemWriter
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.
Output lines are buffered until flush() is called and only then the
actual writing to file occurs.
| Constructor Summary | |
|---|---|
FlatFileItemWriter()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Assert that mandatory properties (resource) are set. |
void |
clear()
Clear any buffers that are being held. |
void |
close(ExecutionContext executionContext)
If any resources are needed for the stream to operate they need to be destroyed here. |
void |
flush()
Flush any buffers that are being held. |
void |
open(ExecutionContext executionContext)
Initialize the reader. |
void |
setBufferSize(int newSize)
Sets buffer size for output template |
void |
setEncoding(String newEncoding)
Sets encoding for output template. |
void |
setFieldSetCreator(FieldSetCreator fieldSetCreator)
Public setter for the FieldSetCreator. |
void |
setHeaderLines(String[] headerLines)
Public setter for the header lines. |
void |
setLineAggregator(LineAggregator 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 |
setShouldDeleteIfExists(boolean shouldDeleteIfExists)
|
void |
update(ExecutionContext executionContext)
Indicates that the execution context provided during open is about to be saved. |
void |
write(Object data)
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, setName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 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 lineAggregator)
LineAggregator. This will be used to
translate a FieldSet into a line for output.
lineAggregator - the LineAggregator to setpublic void setFieldSetCreator(FieldSetCreator fieldSetCreator)
FieldSetCreator. This will be used to
transform the item into a FieldSet before it is aggregated by the
LineAggregator.
fieldSetCreator - the FieldSetCreator to setpublic void setResource(Resource resource)
resource - public void setEncoding(String newEncoding)
public void setBufferSize(int newSize)
public void setShouldDeleteIfExists(boolean shouldDeleteIfExists)
shouldDeleteIfExists - the shouldDeleteIfExists 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 setHeaderLines(String[] headerLines)
write(Object) (and not on restart
unless the restart is after a failure before the first flush).
headerLines - the header lines to set
public void write(Object data)
throws Exception
write in interface ItemWriterdata - Object (a String or Object that can be converted) 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(ExecutionContext executionContext)
ItemStream
close in interface ItemStreamexecutionContext - the current execution context in case it is neededItemStream.close(ExecutionContext)
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)
public void flush()
throws FlushFailedException
ItemWriter
flush in interface ItemWriterFlushFailedException - in case of an error. If this exception is
thrown the writer may be in an inconsistent state and manual intervention
might be required to reconcile the data with persistent output.
public void clear()
throws ClearFailedException
ItemWriter
clear in interface ItemWriterClearFailedException - in case of an error. If this exception is
thrown the writer may be in an inconsistent state and manual intervention
might be required to reconcile the data with persistent output.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||