|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.batch.item.ExecutionContextUserSupport
org.springframework.batch.item.file.FlatFileItemWriter
public class FlatFileItemWriter
This class is an output target that writes data to a file or stream. The
writer also provides restart, statistics and transaction features by
implementing corresponding interfaces where possible (with a file). The
location of the file is defined by a Resource
and must represent a
writable file.
Uses buffered writer to improve performance.
This class will be updated in the future to use a buffering approach to handling transactions, rather than outputting directly to the file and truncating on rollback
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 Output Template. |
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 |
setLineAggregator(LineAggregator lineAggregator)
Public setter for the LineAggregator . |
void |
setResource(Resource resource)
Setter for resource. |
void |
setSaveState(boolean saveState)
Set the boolean 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.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 InitializingBean
Exception
InitializingBean.afterPropertiesSet()
public 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 write(Object data) throws Exception
write
in interface ItemWriter
data
- Object (a String or Object that can be converted) to be
written to output stream
Exception
- if the transformer or file output failpublic void close(ExecutionContext executionContext)
ItemStream
close
in interface ItemStream
executionContext
- TODOItemStream.close(ExecutionContext)
public void setEncoding(String newEncoding)
public void setBufferSize(int newSize)
public void setShouldDeleteIfExists(boolean shouldDeleteIfExists)
shouldDeleteIfExists
- the shouldDeleteIfExists to setpublic void open(ExecutionContext executionContext)
open
in interface ItemStream
ItemStream.open(ExecutionContext)
public void update(ExecutionContext executionContext)
ItemStream
update
in interface ItemStream
executionContext
- to be updatedItemStream.update(ExecutionContext)
public void clear() throws ClearFailedException
ItemWriter
clear
in interface ItemWriter
ClearFailedException
- 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 flush() throws FlushFailedException
ItemWriter
flush
in interface ItemWriter
FlushFailedException
- 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 setSaveState(boolean saveState)
ExecutionContext
during the ItemStream
call to
update. Setting this to false means that it will always start at the
beginning.
saveState
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |