Class StaxEventItemWriterBuilder<T>
- java.lang.Object
- org.springframework.batch.item.xml.builder.StaxEventItemWriterBuilder<T>
public class StaxEventItemWriterBuilder<T> extends java.lang.ObjectA builder for theStaxEventItemWriter.- Since:
- 4.0
- Author:
- Michael Minella
- See Also:
StaxEventItemWriter
Constructor Summary
Constructors Constructor Description StaxEventItemWriterBuilder()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StaxEventItemWriter<T>build()Returns a configuredStaxEventItemWriterStaxEventItemWriterBuilder<T>encoding(java.lang.String encoding)Encoding for the file.StaxEventItemWriterBuilder<T>footerCallback(StaxWriterCallback footerCallback)AStaxWriterCallbackto provide any footer elementsStaxEventItemWriterBuilder<T>forceSync(boolean forceSync)Flag to indicate that changes should be force-synced to disk on flush.StaxEventItemWriterBuilder<T>headerCallback(StaxWriterCallback headerCallback)AStaxWriterCallbackto provide any header elementsStaxEventItemWriterBuilder<T>marshaller(org.springframework.oxm.Marshaller marshaller)TheMarshallerimplementation responsible for the serialization of the items to XML.StaxEventItemWriterBuilder<T>name(java.lang.String name)The name used to calculate the key within theExecutionContext.StaxEventItemWriterBuilder<T>overwriteOutput(boolean overwriteOutput)Indicates if an existing file should be overwritten if found.StaxEventItemWriterBuilder<T>resource(org.springframework.core.io.Resource resource)TheResourceto be used as output.StaxEventItemWriterBuilder<T>rootElementAttributes(java.util.Map<java.lang.String,java.lang.String> rootElementAttributes)A Map of attributes to be included in the document's root element.StaxEventItemWriterBuilder<T>rootTagName(java.lang.String rootTagName)The name of the root tag for the output document.StaxEventItemWriterBuilder<T>saveState(boolean saveState)Indicates if the state of the writer should be saved in theExecutionContext.StaxEventItemWriterBuilder<T>shouldDeleteIfEmpty(boolean shouldDelete)Flag to indicate that the output file should be deleted if no results were written to it.StaxEventItemWriterBuilder<T>transactional(boolean transactional)The resulting writer is participating in a transaction and writes should be delayed as late as possible.StaxEventItemWriterBuilder<T>version(java.lang.String version)Version of XML to be generated.
Method Detail
name
public StaxEventItemWriterBuilder<T> name(java.lang.String name)
The name used to calculate the key within theExecutionContext. Required ifsaveState(boolean)is set to true.- Parameters:
name- name of the reader instance- Returns:
- The current instance of the builder.
- See Also:
ItemStreamSupport.setName(String)
resource
public StaxEventItemWriterBuilder<T> resource(org.springframework.core.io.Resource resource)
TheResourceto be used as output.- Parameters:
resource- the output from the writer- Returns:
- the current instance of the builder.
- See Also:
StaxEventItemWriter.setResource(Resource)
marshaller
public StaxEventItemWriterBuilder<T> marshaller(org.springframework.oxm.Marshaller marshaller)
TheMarshallerimplementation responsible for the serialization of the items to XML. This field is required.- Parameters:
marshaller- the component used to generate XML- Returns:
- the current instance of the builder.
- See Also:
StaxEventItemWriter.setMarshaller(Marshaller)
headerCallback
public StaxEventItemWriterBuilder<T> headerCallback(StaxWriterCallback headerCallback)
AStaxWriterCallbackto provide any header elements- Parameters:
headerCallback- aStaxWriterCallback- Returns:
- the current instance of the builder.
- See Also:
StaxEventItemWriter.setHeaderCallback(StaxWriterCallback)
footerCallback
public StaxEventItemWriterBuilder<T> footerCallback(StaxWriterCallback footerCallback)
AStaxWriterCallbackto provide any footer elements- Parameters:
footerCallback- aStaxWriterCallback- Returns:
- the current instance of the builder.
- See Also:
StaxEventItemWriter.setFooterCallback(StaxWriterCallback)
transactional
public StaxEventItemWriterBuilder<T> transactional(boolean transactional)
The resulting writer is participating in a transaction and writes should be delayed as late as possible.- Parameters:
transactional- indicates that the writer is transactional. Defaults to false.- Returns:
- the current instance of the builder
- See Also:
StaxEventItemWriter.setTransactional(boolean)
forceSync
public StaxEventItemWriterBuilder<T> forceSync(boolean forceSync)
Flag to indicate that changes should be force-synced to disk on flush.- Parameters:
forceSync- indicates if force sync should occur. Defaults to false.- Returns:
- the current instance of the builder
- See Also:
StaxEventItemWriter.setForceSync(boolean)
shouldDeleteIfEmpty
public StaxEventItemWriterBuilder<T> shouldDeleteIfEmpty(boolean shouldDelete)
Flag to indicate that the output file should be deleted if no results were written to it. Defaults to false.- Parameters:
shouldDelete- indicator- Returns:
- the current instance of the builder
- See Also:
StaxEventItemWriter.setShouldDeleteIfEmpty(boolean)
encoding
public StaxEventItemWriterBuilder<T> encoding(java.lang.String encoding)
Encoding for the file. Defaults to UTF-8.- Parameters:
encoding- String encoding algorithm- Returns:
- the current instance of the builder
- See Also:
StaxEventItemWriter.setEncoding(String)
version
public StaxEventItemWriterBuilder<T> version(java.lang.String version)
Version of XML to be generated. Must be supported by theMarshallerprovided.- Parameters:
version- XML version- Returns:
- the current instance of the builder
- See Also:
StaxEventItemWriter.version
rootTagName
public StaxEventItemWriterBuilder<T> rootTagName(java.lang.String rootTagName)
The name of the root tag for the output document.- Parameters:
rootTagName- tag name- Returns:
- the current instance of the builder
- See Also:
StaxEventItemWriter.setRootTagName(String)
rootElementAttributes
public StaxEventItemWriterBuilder<T> rootElementAttributes(java.util.Map<java.lang.String,java.lang.String> rootElementAttributes)
A Map of attributes to be included in the document's root element.- Parameters:
rootElementAttributes- map fo attributes- Returns:
- the current instance of the builder.
- See Also:
StaxEventItemWriter.setRootElementAttributes(Map)
overwriteOutput
public StaxEventItemWriterBuilder<T> overwriteOutput(boolean overwriteOutput)
Indicates if an existing file should be overwritten if found. Defaults to true.- Parameters:
overwriteOutput- indicator- Returns:
- the current instance of the builder.
- See Also:
StaxEventItemWriter.setOverwriteOutput(boolean)
saveState
public StaxEventItemWriterBuilder<T> saveState(boolean saveState)
Indicates if the state of the writer should be saved in theExecutionContext. Setting this to false will impact restartability. Defaults to true.- Parameters:
saveState- indicator- Returns:
- the current instance of the builder
- See Also:
StaxEventItemWriter.setSaveState(boolean)
build
public StaxEventItemWriter<T> build()
Returns a configuredStaxEventItemWriter- Returns:
- a StaxEventItemWriter